Change 4 spaces indenting to 8 and add string for emacs to understand indenting rules
This commit is contained in:
parent
36610e7df8
commit
a617d91183
14 changed files with 501 additions and 481 deletions
|
@ -7,6 +7,7 @@ in terminal run
|
|||
```
|
||||
## Debug
|
||||
Vice --> Activate Monitor
|
||||
program currently start att $080D
|
||||
|
||||
## Chitty endian
|
||||
2 bits 00 88 --> real world 8800
|
||||
|
@ -23,8 +24,6 @@ Vice --> Activate Monitor
|
|||
[good (expansive)](https://www.masswerk.at/6502/6502_instruction_set.html#CLD)
|
||||
[wikipedia (minimalistic)](https://en.wikibooks.org/wiki/6502_Assembly)
|
||||
|
||||
|
||||
|
||||
### sprites
|
||||
[sprite](https://www.c64-wiki.com/wiki/Sprite#Sprite_priority)
|
||||
|
||||
|
@ -38,11 +37,8 @@ Vice --> Activate Monitor
|
|||
|
||||
### Holding hand instructions :)
|
||||
[codeburst hard asembly code](https://codeburst.io/lets-write-some-harder-assembly-language-code-c7860dcceba)
|
||||
|
||||
[flag intro](http://www.6502.org/tutorials/vflag.html)
|
||||
|
||||
|
||||
|
||||
## Basic
|
||||
[peek and poke](https://en.wikipedia.org/wiki/PEEK_and_POKE)
|
||||
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;; A file containing 16-bit macro arithmatic.
|
||||
;; You may add ,! ass a 5:th parameter to skipp flagg clearing.
|
||||
;; This will make it run faster but will have unintended behavior.
|
||||
|
||||
;; Can use A as b_low!
|
||||
;; And X or Y is b_hi
|
||||
;; Can add ", !" to the end for it to run faster but C=0 is not garantied!
|
||||
.macro Add_16 a_low, a_hi, b_low, b_hi, fast_unsafe ; a = a + b
|
||||
;;Se below for some fast 16bit logic
|
||||
;;http://6502.org/tutorials/compare_beyond.html
|
||||
|
||||
;; Addition uses the A register
|
||||
;; a = a + b
|
||||
.macro Add_16 a_low, a_hi, b_low, b_hi, fast_unsafe
|
||||
;; IF to run it fast
|
||||
.ifblank fast_unsafe
|
||||
CLC
|
||||
|
@ -16,8 +22,10 @@
|
|||
STA a_hi
|
||||
.endmacro
|
||||
|
||||
; Untested!
|
||||
.macro Add_16_AX low, hi, fast_unsafe; , A, X
|
||||
;; Untested!
|
||||
;; Addition uses the A register
|
||||
;; a = a + b. b_low = A, b_hi = X
|
||||
.macro Add_16_AX low, hi, fast_unsafe
|
||||
;; IF to run it fast
|
||||
.ifblank fast_unsafe
|
||||
CLC
|
||||
|
@ -29,7 +37,10 @@
|
|||
STA hi
|
||||
.endmacro
|
||||
|
||||
.macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe ; a = a - b
|
||||
;; Subtraction uses the A register
|
||||
;; a = a - b
|
||||
.macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe
|
||||
;; IF to run it fast
|
||||
.ifblank fast_unsafe
|
||||
SEC
|
||||
.endif
|
||||
|
@ -41,8 +52,10 @@
|
|||
STA a_hi
|
||||
.endmacro
|
||||
|
||||
;;Untested
|
||||
.macro Sub_16_AX low, hi, fast_unsafe; , A, X
|
||||
;; Untested
|
||||
;; Subtraction uses the A register
|
||||
;; a = a - b. b_low = A, b_hi = X
|
||||
.macro Sub_16_AX low, hi, fast_unsafe
|
||||
;; IF to run it fast
|
||||
.ifblank fast_unsafe
|
||||
SEC
|
||||
|
@ -54,7 +67,9 @@
|
|||
STA hi
|
||||
.endmacro
|
||||
|
||||
.macro mult_16 low_, hi_, fast_unsafe ; [low, hi] = [low, hi]*2
|
||||
;; Multiplication of 2
|
||||
;; a = a*2
|
||||
.macro mult_16 low_, hi_, fast_unsafe
|
||||
;; IF to run it fast
|
||||
.ifblank fast_unsafe
|
||||
CLC
|
||||
|
@ -62,18 +77,16 @@
|
|||
ROL low_
|
||||
ROL hi_
|
||||
.endmacro
|
||||
;;Se below for some fast 16bit logic
|
||||
;;http://6502.org/tutorials/compare_beyond.html
|
||||
|
||||
;; exampel 4.1.1
|
||||
;;Larger then operation. IF a < b then jump to label
|
||||
;;Larger then operation, uses the A register
|
||||
;;IF a < b then: jump to label
|
||||
.macro Lag_16 a_low, a_hi, b_low, b_hi, label ; [low, hi] = [low, hi]*2
|
||||
LDA a_hi ; compare high bytes
|
||||
LDA a_hi
|
||||
CMP b_hi
|
||||
BCC label ; if NUM1H < NUM2H then NUM1 < NUM2
|
||||
BNE LABEL ; if NUM1H <> NUM2H then NUM1 > NUM2 (so NUM1 >= NUM2)
|
||||
LDA a_low ; compare low bytes
|
||||
BCC label
|
||||
BNE LABEL
|
||||
LDA a_low
|
||||
CMP b_low
|
||||
BCC label ; if NUM1L < NUM2L then NUM1 < NUM2
|
||||
BCC label
|
||||
LABEL:
|
||||
.endmacro
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
;; Max 1.5s eller 0.9s vet ej villken
|
||||
;; skriv time_start .. kod .. time_stop
|
||||
;; och läs värdet i f1
|
||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;; Max 0.9s
|
||||
;; Exempel i kod:
|
||||
;;
|
||||
;; time_start
|
||||
;; ...
|
||||
;; time_stop
|
||||
;;
|
||||
;; Läs tiden genom att undersöka värdet i $f1 (BSD-format)
|
||||
time = $f1
|
||||
.macro time_start
|
||||
PHA
|
||||
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
||||
|
@ -11,7 +19,7 @@
|
|||
LDA $DC08
|
||||
;;Time is only at bit 0 ..3
|
||||
AND #%00001111
|
||||
STA $f1
|
||||
STA time
|
||||
PLA
|
||||
.endmacro
|
||||
|
||||
|
@ -20,7 +28,7 @@
|
|||
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
||||
AND #%00001111
|
||||
SEC
|
||||
SBC $f1
|
||||
STA $f1
|
||||
SBC time
|
||||
STA time
|
||||
PLA
|
||||
.endmacro
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
;;Not values but register position in memory
|
||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;Not values but register position in memory
|
||||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
.proc line; X_pos =< X_end skall alltid gälla
|
||||
;; note that these have same adresses as stuff in line.inc
|
||||
;; This should be used as a optimisation in the future
|
||||
|
@ -11,7 +13,6 @@
|
|||
BCC dx_no_underflow;; X_end >= X_pos
|
||||
EOR #$ff ; Fix bit underflow
|
||||
dx_no_underflow:
|
||||
|
||||
SEC
|
||||
LDA Y_pos
|
||||
SBC Y_end
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;drawing line from 2 cordinates
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_end, Y_end) #
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg!
|
||||
|
||||
.proc line_down
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_end, Y_end) #
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg!
|
||||
.include "line.inc"; Defines memory positions, ex X_pos
|
||||
|
||||
;;We need to clear this memory
|
||||
|
@ -50,6 +53,8 @@
|
|||
|
||||
LDY #$00
|
||||
jsr pixel_draw ;;only used first pixel. after this relative position is abused
|
||||
|
||||
;;From line_test_time this is at program_start + list_file_offset = $080D + $0116 = $0923
|
||||
for_x:
|
||||
;; Lets increment btp_mem_pos with +8
|
||||
;; Read more in pixel_draw to understand this!
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;drawing line from 2 cordinates
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_end, Y_end) #
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
|
||||
.proc line_down_inv
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_end, Y_end) #
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
|
||||
.include "line.inc"; Defines memory positions, ex X_pos
|
||||
|
||||
;;We need to clear this memory
|
||||
|
@ -46,10 +48,10 @@
|
|||
jsr pixel_draw ;;only used first pixel. after this relative position is abused
|
||||
CLC ; this makes it that C =0 always on for_x
|
||||
for_y:
|
||||
LDX #$00
|
||||
LDA byte_to_paint
|
||||
ORA (>btp_mem_pos, X)
|
||||
STA (>btp_mem_pos, X)
|
||||
LDX #$00
|
||||
LDA byte_to_paint
|
||||
ORA (>btp_mem_pos, X)
|
||||
STA (>btp_mem_pos, X)
|
||||
increment_y_pos:
|
||||
Add_16 >btp_mem_pos, <btp_mem_pos, #$01, #$00, ! ; I know that C ==0 on for_y
|
||||
INY
|
||||
|
@ -65,7 +67,6 @@ increment_y_pos_end:
|
|||
LDX Y_pos
|
||||
CPX Y_end
|
||||
BEQ end
|
||||
|
||||
;;If D < %00000010 00000000: case_2
|
||||
;;else case 1.
|
||||
Lag_16 >D, <D, #$00, #$02, case_2
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
.include "line.inc"
|
||||
;;for testing stuff
|
||||
Y_pos_ = $0D
|
||||
X_pos_ = $0E
|
||||
|
@ -31,8 +30,6 @@
|
|||
jmp @loop
|
||||
end__:
|
||||
|
||||
|
||||
|
||||
;; Full anfle test
|
||||
@loop:
|
||||
LDA Y_pos_
|
||||
|
@ -47,36 +44,34 @@ end__:
|
|||
BEQ end
|
||||
jmp @loop
|
||||
end:
|
||||
;;Long lines
|
||||
;;Long lines
|
||||
;;Lets cleer bitmap
|
||||
LDA #>VIC_bank
|
||||
STA $FC
|
||||
LDA #<VIC_bank
|
||||
STA $FB
|
||||
|
||||
;;Lets cleer bitmap
|
||||
LDA #>VIC_bank
|
||||
STA $FC
|
||||
LDA #<VIC_bank
|
||||
STA $FB
|
||||
LDA #>$5f3f
|
||||
STA $FE
|
||||
LDA #<$5f3f
|
||||
STA $FD
|
||||
|
||||
LDA #>$5f3f
|
||||
STA $FE
|
||||
LDA #<$5f3f
|
||||
STA $FD
|
||||
LDA #$0
|
||||
jsr memory_rec
|
||||
|
||||
LDA #$0
|
||||
jsr memory_rec
|
||||
|
||||
LDA #$00
|
||||
STA X_pos_
|
||||
LDA #$60
|
||||
STA Y_pos_
|
||||
LDA #$ff
|
||||
STA X_end
|
||||
LDA #$0
|
||||
STA Y_end
|
||||
LDA #$00
|
||||
STA X_pos_
|
||||
LDA #$60
|
||||
STA Y_pos_
|
||||
LDA #$ff
|
||||
STA X_end
|
||||
LDA #$0
|
||||
STA Y_end
|
||||
@loop:
|
||||
LDA Y_pos_
|
||||
STA Y_pos
|
||||
LDA X_pos_
|
||||
STA X_pos
|
||||
|
||||
jsr line
|
||||
INC Y_end
|
||||
LDA Y_end
|
||||
|
@ -84,7 +79,6 @@ STA Y_end
|
|||
BEQ end_
|
||||
jmp @loop
|
||||
end_:
|
||||
jmp exit
|
||||
|
||||
jmp exit
|
||||
.include "line.s"
|
||||
.include "macros/"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
.include "line.inc"
|
||||
;;for testing stuff
|
||||
Y_pos_ = $0D
|
||||
X_pos_ = $0E
|
||||
|
@ -16,23 +15,22 @@
|
|||
LDA #$30
|
||||
STA Y_end
|
||||
|
||||
;; Short test for timing
|
||||
time_start
|
||||
|
||||
;; Short test for timing
|
||||
time_start
|
||||
@loop:;; mem f1
|
||||
LDA Y_pos_
|
||||
STA Y_pos
|
||||
LDA X_pos_
|
||||
STA X_pos
|
||||
|
||||
jsr line
|
||||
jsr line_down
|
||||
INC Y_end
|
||||
LDA Y_end
|
||||
CMP #$50
|
||||
BEQ end__
|
||||
jmp @loop
|
||||
end__:
|
||||
time_stop
|
||||
jmp exit
|
||||
time_stop
|
||||
jmp exit
|
||||
|
||||
.include "line.s"
|
||||
.include "line_down.s"
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
;;drawing line from 2 cordinates
|
||||
.proc line_up
|
||||
;;# * (X_end, Y_end) #
|
||||
;;# #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos >= Y_end. Max 45deg!
|
||||
.include "line.inc"; Defines memory positions, ex X_pos
|
||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;example values ~~~~~ SHOULD BE PRECOMPILED
|
||||
;LDA #$90
|
||||
;STA X_pos
|
||||
;STA Y_pos
|
||||
;LDA #$aa
|
||||
;STA X_end
|
||||
;LDA #$80
|
||||
;STA Y_end
|
||||
;;~~~~~~~~~~
|
||||
;;drawing line from 2 cordinates
|
||||
;;# * (X_end, Y_end) #
|
||||
;;# #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos >= Y_end. Max 45deg!
|
||||
|
||||
.proc line_up
|
||||
.include "line.inc"; Defines memory positions, ex X_pos
|
||||
|
||||
;;We need to clear this memory
|
||||
LDA #$00
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
;drawing line from 2 cordinates
|
||||
.proc line_up_inv
|
||||
;;# (X_end, Y_end) #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;NOTE THAT Y_pos >) Y_end, X_pos <= X_end. Min 45deg!
|
||||
.include "line.inc"
|
||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;We need to clear this memory
|
||||
;drawing line from 2 cordinates
|
||||
;;# (X_end, Y_end) #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# * #
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;NOTE THAT Y_pos >) Y_end, X_pos <= X_end. Min 45deg!
|
||||
|
||||
.proc line_up_inv
|
||||
include "line.inc"
|
||||
|
||||
;We need to clear this memory
|
||||
LDA #$00
|
||||
STA <V
|
||||
STA <dx_2
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;##### HANDLES BIG MEMORY MANAGMENTS ############
|
||||
;;recursive write to memory.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;Screen print. Draws a pixel at a specified position.
|
||||
;; Destroys A X Y
|
||||
.proc pixel_draw; Draws a pixel at [Y = FB , X = FC, FD]. Y = 0 - 320, X= 0 - 200
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# !/bin/bash
|
||||
killall x64sc
|
||||
|
||||
#Note that program start at $080D
|
||||
cl65 -o file.prg -u __EXEHDR__ -t c64 -C c64-asm.cfg -l file.list source.s \
|
||||
&& nohup flatpak run net.sf.VICE -windowypos 0 -windowxpos 960 -windowwidth 945 -windowheight 720 file.prg </dev/null &>/dev/null &
|
||||
|
||||
sleep 2
|
||||
rm source.o
|
||||
rm file.prg
|
||||
|
|
Loading…
Add table
Reference in a new issue