-
-
Save devinacker/6c578f3ead9bb6b0491be010d520d1fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.include "libSFX.i" | |
.smart | |
.feature force_range | |
;------------------------------------------------------------------------------- | |
.segment "LORAM" | |
currtest: .res 1 | |
textptr: .res 2 | |
tilebuf: .res $800 | |
;------------------------------------------------------------------------------- | |
.segment "CODE" | |
VRAM_TILEMAP = $0000 | |
VRAM_CHARSET = $4000 | |
testvals: | |
.byte $0a, $1a, $2a, $3a | |
.byte $4a, $5a, $6a, $7a | |
.byte $ca, $da, $ea, $fa | |
.byte 0 | |
errormsg: | |
.byte "the SMP died. RIP :(", 0 | |
donemsg: | |
.byte "all tests finished!", 0 | |
Main: | |
; load font | |
VRAM_memcpy VRAM_CHARSET, charset, sizeof_charset | |
; set up a basic palette | |
CGRAM_setcolor_rgb 0, 0,0,0 | |
CGRAM_setcolor_rgb 1, 7, 7, 7 | |
CGRAM_setcolor_rgb 2, 15 ,15, 15 | |
CGRAM_setcolor_rgb 3, 28, 28, 28 | |
sep #$20 | |
; bg1 tile map address at $0000, 1x1 map | |
lda #$00 | |
sta BG1SC | |
; layer 1 char data at $2000 | |
lda #$02 | |
sta BG12NBA | |
; turn on layer 1 | |
lda #tm(ON, OFF, OFF, OFF, OFF) | |
sta TM | |
;Turn on screen | |
lda #inidisp(ON, DISP_BRIGHTNESS_MAX) | |
sta INIDISP | |
; load SPC test program | |
SMP_ready | |
SMP_exec SMP_RAM, __SMPCODE_LOAD__, __SMPCODE_SIZE__, SMP_RAM | |
pea $2100 | |
pld | |
@main: | |
sep #$20 | |
rep #$10 | |
: | |
ldx #$0542 | |
stx textptr | |
lda z:$40 ; wait for SMP program to get ready | |
pha | |
jsr PrintByte | |
inc textptr | |
inc textptr | |
lda z:$41 | |
jsr PrintByte | |
inc textptr | |
inc textptr | |
jsr UpdateText | |
pla | |
bne :- | |
lda currtest | |
pha | |
rep #$20 | |
and #$00ff | |
asl | |
asl | |
asl | |
asl | |
asl | |
asl | |
adc #$42 | |
sta textptr | |
sep #$30 | |
plx | |
lda testvals, x | |
beq @end | |
inc currtest | |
pha | |
jsr PrintByte | |
pla | |
inc textptr | |
inc textptr | |
rep #$30 | |
ora #$100 | |
tay | |
sep #$20 | |
lda #$aa | |
ldx #$0000 | |
sty z:$40 ; write test value and nonzero byte to SMP | |
: | |
inx | |
beq @hung | |
cmp z:$40 ; wait for IPL to finish | |
bne :- | |
rep #$20 | |
txa | |
jsr PrintWord | |
jsr UpdateText | |
; restart SPC program | |
sep #$20 | |
pea $0000 | |
pld | |
SMP_jmp SMP_RAM | |
pea $2100 | |
pld | |
jmp @main | |
@hung: | |
rep #$10 | |
ldx #errormsg | |
jsr PrintString | |
jsr UpdateText | |
: bra :- | |
@end: | |
rep #$10 | |
lda currtest | |
inc | |
rep #$30 | |
and #$00ff | |
asl | |
asl | |
asl | |
asl | |
asl | |
asl | |
adc #$42 | |
sta textptr | |
ldx #donemsg | |
jsr PrintString | |
jsr UpdateText | |
: bra :- | |
UpdateText: | |
php | |
sep #$20 | |
WAIT_vbl | |
VRAM_memcpy VRAM_TILEMAP, tilebuf, $800 | |
plp | |
rts | |
PrintString: | |
php | |
rep #$20 | |
: | |
lda a:0,x | |
and #$00ff | |
beq :+ | |
sec | |
sbc #$20 | |
ora #$0000 ; char properties | |
ldy textptr | |
sta a:tilebuf,y | |
inc textptr | |
inc textptr | |
inx | |
bra :- | |
: | |
plp | |
rts | |
Numbers: | |
.byte "0123456789ABCDEF" | |
PrintNibble: | |
php | |
sep #$20 | |
and #$f | |
jsr PrintNum | |
plp | |
rts | |
PrintWord: | |
php | |
rep #$20 | |
pha | |
xba | |
jsr PrintByte | |
pla | |
jsr PrintByte | |
plp | |
rts | |
PrintByte: | |
php | |
sep #$20 | |
; print first digit | |
pha | |
lsr | |
lsr | |
lsr | |
lsr | |
jsr PrintNum | |
pla | |
and #$f | |
jsr PrintNum | |
plp | |
rts | |
PrintNum: | |
php | |
sep #$30 | |
tax | |
lda Numbers,x | |
rep #$30 | |
and #$00ff | |
sec | |
sbc #$20 | |
ldx textptr | |
sta a:tilebuf,x | |
rep #$20 | |
inc textptr | |
inc textptr | |
plp | |
rts | |
.segment "RODATA" | |
incbin charset, "data/alpha.chr" | |
.byte "by revenant 2017/06/29" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment