|
- ; __NAME__ - ca65 assembly program for the Commodore 64.
- ;
- ; Built with cc65's c64-asm.cfg plus its BASIC stub (10 SYS 2061), so the first
- ; byte of CODE runs at $080D. Add "config": "src/my.cfg" to c64project.json if
- ; you need a custom memory layout.
- ;
- ; c64 build projects/__NAME__ c64 run projects/__NAME__ c64 test projects/__NAME__
-
- .include "c64.inc" ; cc65: VIC, SID, CIA register names
- .include "cbm_kernal.inc" ; cc65: CHROUT, GETIN, PLOT, ...
- .include "c64test.inc" ; repo lib/: TEST_PASS / TEST_FAIL
-
- ptr = $FB ; free zero page ($FB-$FE)
-
- COLOR_BLACK = 0 ; c64.inc has no color names
- COLOR_WHITE = 1
- COLOR_BLUE = 6
-
- .segment "CODE"
- main:
- lda #COLOR_BLUE
- sta VIC_BORDERCOLOR
- lda #COLOR_BLACK
- sta VIC_BG_COLOR0
- lda #<banner
- ldy #>banner
- jsr print
-
- jsr self_test
-
- TEST_PASS ; screen is ready: let `c64 test` capture it
-
- wait: jsr GETIN ; wait for a key, then return to BASIC
- beq wait
- rts
-
- ; Print the zero-terminated PETSCII string at A (low) / Y (high).
- .proc print
- sta ptr
- sty ptr+1
- ldy #0
- loop: lda (ptr),y
- beq done
- jsr CHROUT
- iny
- bne loop
- done: rts
- .endproc
-
- ; Checks that stop the test with a failure code.
- .proc self_test
- lda #2
- clc
- adc #3
- cmp #5
- beq ok
- TEST_FAIL 1
- hang: jmp hang
- ok: rts
- .endproc
-
- .segment "RODATA"
- ; ca65 converts string literals to PETSCII: lower-case ASCII becomes the letters the
- ; C64 shows in its default upper-case mode. Upper-case ASCII becomes shifted PETSCII,
- ; which displays as graphics characters. Write text in lower case.
- banner: .byte $93, $05 ; clear screen, white text
- .byte "__NAME__", $0D, $0D
- .byte "ready to go", $0D, 0
|