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
|
## Debug
|
||||||
Vice --> Activate Monitor
|
Vice --> Activate Monitor
|
||||||
|
program currently start att $080D
|
||||||
|
|
||||||
## Chitty endian
|
## Chitty endian
|
||||||
2 bits 00 88 --> real world 8800
|
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)
|
[good (expansive)](https://www.masswerk.at/6502/6502_instruction_set.html#CLD)
|
||||||
[wikipedia (minimalistic)](https://en.wikibooks.org/wiki/6502_Assembly)
|
[wikipedia (minimalistic)](https://en.wikibooks.org/wiki/6502_Assembly)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### sprites
|
### sprites
|
||||||
[sprite](https://www.c64-wiki.com/wiki/Sprite#Sprite_priority)
|
[sprite](https://www.c64-wiki.com/wiki/Sprite#Sprite_priority)
|
||||||
|
|
||||||
|
@ -38,11 +37,8 @@ Vice --> Activate Monitor
|
||||||
|
|
||||||
### Holding hand instructions :)
|
### Holding hand instructions :)
|
||||||
[codeburst hard asembly code](https://codeburst.io/lets-write-some-harder-assembly-language-code-c7860dcceba)
|
[codeburst hard asembly code](https://codeburst.io/lets-write-some-harder-assembly-language-code-c7860dcceba)
|
||||||
|
|
||||||
[flag intro](http://www.6502.org/tutorials/vflag.html)
|
[flag intro](http://www.6502.org/tutorials/vflag.html)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Basic
|
## Basic
|
||||||
[peek and poke](https://en.wikipedia.org/wiki/PEEK_and_POKE)
|
[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!
|
;;Se below for some fast 16bit logic
|
||||||
;; And X or Y is b_hi
|
;;http://6502.org/tutorials/compare_beyond.html
|
||||||
;; 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
|
;; 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
|
;; IF to run it fast
|
||||||
.ifblank fast_unsafe
|
.ifblank fast_unsafe
|
||||||
CLC
|
CLC
|
||||||
|
@ -16,8 +22,10 @@
|
||||||
STA a_hi
|
STA a_hi
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
; Untested!
|
;; Untested!
|
||||||
.macro Add_16_AX low, hi, fast_unsafe; , A, X
|
;; 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
|
;; IF to run it fast
|
||||||
.ifblank fast_unsafe
|
.ifblank fast_unsafe
|
||||||
CLC
|
CLC
|
||||||
|
@ -29,7 +37,10 @@
|
||||||
STA hi
|
STA hi
|
||||||
.endmacro
|
.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
|
.ifblank fast_unsafe
|
||||||
SEC
|
SEC
|
||||||
.endif
|
.endif
|
||||||
|
@ -42,7 +53,9 @@
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
;; Untested
|
;; Untested
|
||||||
.macro Sub_16_AX low, hi, fast_unsafe; , A, X
|
;; 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
|
;; IF to run it fast
|
||||||
.ifblank fast_unsafe
|
.ifblank fast_unsafe
|
||||||
SEC
|
SEC
|
||||||
|
@ -54,7 +67,9 @@
|
||||||
STA hi
|
STA hi
|
||||||
.endmacro
|
.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
|
;; IF to run it fast
|
||||||
.ifblank fast_unsafe
|
.ifblank fast_unsafe
|
||||||
CLC
|
CLC
|
||||||
|
@ -62,18 +77,16 @@
|
||||||
ROL low_
|
ROL low_
|
||||||
ROL hi_
|
ROL hi_
|
||||||
.endmacro
|
.endmacro
|
||||||
;;Se below for some fast 16bit logic
|
|
||||||
;;http://6502.org/tutorials/compare_beyond.html
|
|
||||||
|
|
||||||
;; exampel 4.1.1
|
;;Larger then operation, uses the A register
|
||||||
;;Larger then operation. IF a < b then jump to label
|
;;IF a < b then: jump to label
|
||||||
.macro Lag_16 a_low, a_hi, b_low, b_hi, label ; [low, hi] = [low, hi]*2
|
.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
|
CMP b_hi
|
||||||
BCC label ; if NUM1H < NUM2H then NUM1 < NUM2
|
BCC label
|
||||||
BNE LABEL ; if NUM1H <> NUM2H then NUM1 > NUM2 (so NUM1 >= NUM2)
|
BNE LABEL
|
||||||
LDA a_low ; compare low bytes
|
LDA a_low
|
||||||
CMP b_low
|
CMP b_low
|
||||||
BCC label ; if NUM1L < NUM2L then NUM1 < NUM2
|
BCC label
|
||||||
LABEL:
|
LABEL:
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
;; Max 1.5s eller 0.9s vet ej villken
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
;; skriv time_start .. kod .. time_stop
|
|
||||||
;; och läs värdet i f1
|
;; 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
|
.macro time_start
|
||||||
PHA
|
PHA
|
||||||
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
||||||
|
@ -11,7 +19,7 @@
|
||||||
LDA $DC08
|
LDA $DC08
|
||||||
;;Time is only at bit 0 ..3
|
;;Time is only at bit 0 ..3
|
||||||
AND #%00001111
|
AND #%00001111
|
||||||
STA $f1
|
STA time
|
||||||
PLA
|
PLA
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
@ -20,7 +28,7 @@
|
||||||
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
||||||
AND #%00001111
|
AND #%00001111
|
||||||
SEC
|
SEC
|
||||||
SBC $f1
|
SBC time
|
||||||
STA $f1
|
STA time
|
||||||
PLA
|
PLA
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;;Not values but register position in memory
|
;;Not values but register position in memory
|
||||||
X_end = $04
|
X_end = $04
|
||||||
Y_end = $05
|
Y_end = $05
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
.proc line; X_pos =< X_end skall alltid gälla
|
.proc line; X_pos =< X_end skall alltid gälla
|
||||||
;; note that these have same adresses as stuff in line.inc
|
;; note that these have same adresses as stuff in line.inc
|
||||||
;; This should be used as a optimisation in the future
|
;; This should be used as a optimisation in the future
|
||||||
|
@ -11,7 +13,6 @@
|
||||||
BCC dx_no_underflow;; X_end >= X_pos
|
BCC dx_no_underflow;; X_end >= X_pos
|
||||||
EOR #$ff ; Fix bit underflow
|
EOR #$ff ; Fix bit underflow
|
||||||
dx_no_underflow:
|
dx_no_underflow:
|
||||||
|
|
||||||
SEC
|
SEC
|
||||||
LDA Y_pos
|
LDA Y_pos
|
||||||
SBC Y_end
|
SBC Y_end
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;;drawing line from 2 cordinates
|
;;drawing line from 2 cordinates
|
||||||
.proc line_down
|
|
||||||
;;# (X_pos, Y_pos) #
|
;;# (X_pos, Y_pos) #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# (X_end, Y_end) #
|
;;# (X_end, Y_end) #
|
||||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg!
|
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg!
|
||||||
|
|
||||||
|
.proc line_down
|
||||||
.include "line.inc"; Defines memory positions, ex X_pos
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
|
|
||||||
;;We need to clear this memory
|
;;We need to clear this memory
|
||||||
|
@ -50,6 +53,8 @@
|
||||||
|
|
||||||
LDY #$00
|
LDY #$00
|
||||||
jsr pixel_draw ;;only used first pixel. after this relative position is abused
|
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:
|
for_x:
|
||||||
;; Lets increment btp_mem_pos with +8
|
;; Lets increment btp_mem_pos with +8
|
||||||
;; Read more in pixel_draw to understand this!
|
;; 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
|
;;drawing line from 2 cordinates
|
||||||
.proc line_down_inv
|
|
||||||
;;# (X_pos, Y_pos) #
|
;;# (X_pos, Y_pos) #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# (X_end, Y_end) #
|
;;# (X_end, Y_end) #
|
||||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
|
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
|
||||||
|
.proc line_down_inv
|
||||||
.include "line.inc"; Defines memory positions, ex X_pos
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
|
|
||||||
;;We need to clear this memory
|
;;We need to clear this memory
|
||||||
|
@ -65,7 +67,6 @@ increment_y_pos_end:
|
||||||
LDX Y_pos
|
LDX Y_pos
|
||||||
CPX Y_end
|
CPX Y_end
|
||||||
BEQ end
|
BEQ end
|
||||||
|
|
||||||
;;If D < %00000010 00000000: case_2
|
;;If D < %00000010 00000000: case_2
|
||||||
;;else case 1.
|
;;else case 1.
|
||||||
Lag_16 >D, <D, #$00, #$02, case_2
|
Lag_16 >D, <D, #$00, #$02, case_2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
X_end = $04
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
Y_end = $05
|
|
||||||
X_pos = $FC
|
.include "line.inc"
|
||||||
Y_pos = $FB
|
|
||||||
;;for testing stuff
|
;;for testing stuff
|
||||||
Y_pos_ = $0D
|
Y_pos_ = $0D
|
||||||
X_pos_ = $0E
|
X_pos_ = $0E
|
||||||
|
@ -31,8 +30,6 @@
|
||||||
jmp @loop
|
jmp @loop
|
||||||
end__:
|
end__:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; Full anfle test
|
;; Full anfle test
|
||||||
@loop:
|
@loop:
|
||||||
LDA Y_pos_
|
LDA Y_pos_
|
||||||
|
@ -48,7 +45,6 @@ end__:
|
||||||
jmp @loop
|
jmp @loop
|
||||||
end:
|
end:
|
||||||
;;Long lines
|
;;Long lines
|
||||||
|
|
||||||
;;Lets cleer bitmap
|
;;Lets cleer bitmap
|
||||||
LDA #>VIC_bank
|
LDA #>VIC_bank
|
||||||
STA $FC
|
STA $FC
|
||||||
|
@ -76,7 +72,6 @@ STA Y_end
|
||||||
STA Y_pos
|
STA Y_pos
|
||||||
LDA X_pos_
|
LDA X_pos_
|
||||||
STA X_pos
|
STA X_pos
|
||||||
|
|
||||||
jsr line
|
jsr line
|
||||||
INC Y_end
|
INC Y_end
|
||||||
LDA Y_end
|
LDA Y_end
|
||||||
|
@ -85,6 +80,5 @@ STA Y_end
|
||||||
jmp @loop
|
jmp @loop
|
||||||
end_:
|
end_:
|
||||||
jmp exit
|
jmp exit
|
||||||
|
|
||||||
.include "line.s"
|
.include "line.s"
|
||||||
.include "macros/"
|
.include "macros/"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
X_end = $04
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
Y_end = $05
|
|
||||||
X_pos = $FC
|
.include "line.inc"
|
||||||
Y_pos = $FB
|
|
||||||
;;for testing stuff
|
;;for testing stuff
|
||||||
Y_pos_ = $0D
|
Y_pos_ = $0D
|
||||||
X_pos_ = $0E
|
X_pos_ = $0E
|
||||||
|
@ -18,14 +17,13 @@
|
||||||
|
|
||||||
;; Short test for timing
|
;; Short test for timing
|
||||||
time_start
|
time_start
|
||||||
|
|
||||||
@loop:;; mem f1
|
@loop:;; mem f1
|
||||||
LDA Y_pos_
|
LDA Y_pos_
|
||||||
STA Y_pos
|
STA Y_pos
|
||||||
LDA X_pos_
|
LDA X_pos_
|
||||||
STA X_pos
|
STA X_pos
|
||||||
|
|
||||||
jsr line
|
jsr line_down
|
||||||
INC Y_end
|
INC Y_end
|
||||||
LDA Y_end
|
LDA Y_end
|
||||||
CMP #$50
|
CMP #$50
|
||||||
|
@ -35,4 +33,4 @@ end__:
|
||||||
time_stop
|
time_stop
|
||||||
jmp exit
|
jmp exit
|
||||||
|
|
||||||
.include "line.s"
|
.include "line_down.s"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;;drawing line from 2 cordinates
|
;;drawing line from 2 cordinates
|
||||||
.proc line_up
|
|
||||||
;;# * (X_end, Y_end) #
|
;;# * (X_end, Y_end) #
|
||||||
;;# #
|
;;# #
|
||||||
;;# * #
|
;;# * #
|
||||||
|
@ -7,17 +8,9 @@
|
||||||
;;# (X_pos, Y_pos) #
|
;;# (X_pos, Y_pos) #
|
||||||
;;
|
;;
|
||||||
;;NOTE THAT X_pos <= X_end, Y_pos >= Y_end. Max 45deg!
|
;;NOTE THAT X_pos <= X_end, Y_pos >= Y_end. Max 45deg!
|
||||||
.include "line.inc"; Defines memory positions, ex X_pos
|
|
||||||
|
|
||||||
;;example values ~~~~~ SHOULD BE PRECOMPILED
|
.proc line_up
|
||||||
;LDA #$90
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
;STA X_pos
|
|
||||||
;STA Y_pos
|
|
||||||
;LDA #$aa
|
|
||||||
;STA X_end
|
|
||||||
;LDA #$80
|
|
||||||
;STA Y_end
|
|
||||||
;;~~~~~~~~~~
|
|
||||||
|
|
||||||
;;We need to clear this memory
|
;;We need to clear this memory
|
||||||
LDA #$00
|
LDA #$00
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;drawing line from 2 cordinates
|
;drawing line from 2 cordinates
|
||||||
.proc line_up_inv
|
|
||||||
;;# (X_end, Y_end) #
|
;;# (X_end, Y_end) #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# * #
|
;;# * #
|
||||||
;;# (X_pos, Y_pos) #
|
;;# (X_pos, Y_pos) #
|
||||||
;;NOTE THAT Y_pos >) Y_end, X_pos <= X_end. Min 45deg!
|
;;NOTE THAT Y_pos >) Y_end, X_pos <= X_end. Min 45deg!
|
||||||
.include "line.inc"
|
|
||||||
|
|
||||||
;;We need to clear this memory
|
.proc line_up_inv
|
||||||
|
include "line.inc"
|
||||||
|
|
||||||
|
;We need to clear this memory
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA <V
|
STA <V
|
||||||
STA <dx_2
|
STA <dx_2
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;;##### HANDLES BIG MEMORY MANAGMENTS ############
|
;;##### HANDLES BIG MEMORY MANAGMENTS ############
|
||||||
;;recursive write to memory.
|
;;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.
|
;;Screen print. Draws a pixel at a specified position.
|
||||||
;; Destroys A X Y
|
;; Destroys A X Y
|
||||||
.proc pixel_draw; Draws a pixel at [Y = FB , X = FC, FD]. Y = 0 - 320, X= 0 - 200
|
.proc pixel_draw; Draws a pixel at [Y = FB , X = FC, FD]. Y = 0 - 320, X= 0 - 200
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
# !/bin/bash
|
# !/bin/bash
|
||||||
killall x64sc
|
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 \
|
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 &
|
&& nohup flatpak run net.sf.VICE -windowypos 0 -windowxpos 960 -windowwidth 945 -windowheight 720 file.prg </dev/null &>/dev/null &
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
rm source.o
|
rm source.o
|
||||||
|
rm file.prg
|
||||||
|
|
Loading…
Add table
Reference in a new issue