1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-26 08:32:00 +00:00
cc65/targettest/gamate/lcdtest.s

422 lines
8.1 KiB
ArmAsm
Raw Normal View History

2015-11-29 19:04:10 +00:00
;
2015-11-29 00:24:01 +00:00
; original lcdtest.s by PeT (mess@utanet.at)
2015-11-29 19:04:10 +00:00
;
; cl65 -t gamate -o lcdtest.bin lcdtest.s
;
2015-11-29 00:24:01 +00:00
.include "gamate.inc"
2015-11-22 18:02:47 +00:00
2015-11-29 00:24:01 +00:00
.zeropage
2015-11-29 19:04:10 +00:00
addr: .word 0
psa: .word 0
.bss
temp_x: .byte 0
temp_y: .byte 0
2019-02-05 22:27:52 +00:00
temp_a: .byte 0
2015-11-29 19:04:10 +00:00
irq_count: .byte 0
nmi_count: .byte 0
psx: .byte 0
psy: .byte 0
count: .word 0
counted: .word 0
xpos: .byte 0
ypos: .byte 0
.rodata
chars: .incbin "cga2.chr"
2015-11-29 00:14:59 +00:00
hex2asc: .byte "0123456789abcdef"
format: .byte "IrqNmiCountXposYpos", 0
xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0
ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
2015-11-29 19:04:10 +00:00
.code
2015-11-29 00:14:59 +00:00
;-------------------------------------------------------------------------------
.export IRQStub, NMIStub
2015-11-29 00:14:59 +00:00
.proc NMIStub
2015-11-29 00:14:59 +00:00
inc nmi_count
rts
2015-11-14 12:15:29 +00:00
.endproc
2015-11-29 00:14:59 +00:00
.proc IRQStub
2015-11-22 18:02:47 +00:00
2015-11-29 00:14:59 +00:00
inc irq_count
lda count
sta counted
lda count+1
sta counted+1
lda #0
sta count
sta count+1
rts
2015-11-14 12:15:29 +00:00
.endproc
2015-11-29 00:14:59 +00:00
;-------------------------------------------------------------------------------
.export Start
2015-11-29 00:14:59 +00:00
.proc Start
2015-11-29 19:04:10 +00:00
sei
lda #0
sta ZP_IRQ_CTRL
2015-11-29 00:14:59 +00:00
lda #0
2015-11-29 19:04:10 +00:00
sta LCD_XPOS
sta LCD_YPOS
2015-11-29 00:14:59 +00:00
cli
2015-11-29 19:04:10 +00:00
lda #LCD_MODE_INC_Y
sta LCD_MODE
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
lda #0
sta LCD_X
lda #<xdesc
ldx #>xdesc
ldy #0
jsr printstring
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
lda #LCD_XPOS_PLANE2
sta LCD_X
lda #<xdesc
ldx #>xdesc
ldy #128
jsr printstring
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
lda #0
sta LCD_X
lda #<ydesc
ldx #>ydesc
ldy #0
sty LCD_Y
jsr printstringy
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
lda #(LCD_XPOS_PLANE2|(128/8)) ; ???
sta LCD_X
lda #<ydesc
ldx #>ydesc
ldy #0
sty LCD_Y
jsr printstringy
lda #<format
ldx #>format
ldy #8
jsr printstring
lda #0
sta LCD_MODE
lda #24/8
sta LCD_X
lda #24
sta LCD_Y
lda #'X'
jsr printsign
lda #$80
sta LCD_MODE
lda #32/8
sta LCD_X
lda #32
sta LCD_Y
lda #'Y'
jsr printsign
lda #$c0
sta LCD_MODE
lda #40/8
sta LCD_X
lda #40
sta LCD_Y
lda #'Z'
jsr printsign
lda #0
sta LCD_MODE
lda #LCD_XPOS_PLANE2|(48/8)
sta LCD_X
lda #48
sta LCD_Y
lda #'x'
jsr printsign
lda #$80
sta LCD_MODE
lda #(LCD_XPOS_PLANE2|(56/8))
sta LCD_X
lda #56
sta LCD_Y
lda #'y'
jsr printsign
lda #$c0
sta LCD_MODE
lda #(LCD_XPOS_PLANE2|(64/8))
sta LCD_X
lda #64
sta LCD_Y
lda #'z'
jsr printsign
lda #LCD_MODE_INC_Y|1
sta LCD_MODE
lda #16/8
sta LCD_X
lda #72
sta LCD_Y
lda #'V'
jsr printsign
lda #LCD_MODE_INC_Y|2
sta LCD_MODE
lda #24/8
sta LCD_X
lda #72
sta LCD_Y
lda #'V'
jsr printsign
lda #LCD_MODE_INC_Y|4
sta LCD_MODE
lda #32/8
sta LCD_X
lda #72
sta LCD_Y
lda #'V'
jsr printsign
lda #LCD_MODE_INC_Y|8
sta LCD_MODE
lda #40/8
sta LCD_X
lda #72
sta LCD_Y
lda #'V'
jsr printsign
lda #1
sta ZP_IRQ_CTRL
loop:
lda count
2015-11-29 00:14:59 +00:00
clc
2015-11-29 19:04:10 +00:00
adc #1
sta count
lda count+1
adc #0
sta count+1
2015-11-14 12:15:29 +00:00
2015-11-29 19:04:10 +00:00
lda irq_count
cmp irq_count
beq loop
2015-11-14 12:15:29 +00:00
2015-11-29 19:04:10 +00:00
jsr inputs
2015-11-14 12:15:29 +00:00
2015-11-29 19:04:10 +00:00
lda #LCD_MODE_INC_Y
sta LCD_MODE
jsr printy
2015-11-14 12:15:29 +00:00
2015-11-29 19:04:10 +00:00
jmp loop
2015-11-14 12:15:29 +00:00
.endproc
2015-11-29 00:14:59 +00:00
;-------------------------------------------------------------------------------
2015-11-14 12:15:29 +00:00
.proc printy
2015-11-29 19:04:10 +00:00
ldx #0
ldy #16
lda irq_count
jsr printhex
ldx #3
ldy #16
lda nmi_count
jsr printhex
ldx #6
ldy #16
lda counted+1
jsr printhex
ldx #8
ldy #16
lda counted
jsr printhex
ldx #11
ldy #16
lda xpos
jsr printhex
ldx #14
ldy #16
lda ypos
jsr printhex
2015-11-29 00:14:59 +00:00
rts
2015-11-14 12:15:29 +00:00
.endproc
.proc inputs
2015-11-29 19:04:10 +00:00
lda JOY_DATA
and #JOY_DATA_UP
bne notup
dec ypos
lda ypos
sta LCD_YPOS
notup:
lda JOY_DATA
and #JOY_DATA_DOWN
bne notdown
inc ypos
lda ypos
sta LCD_YPOS
notdown:
lda JOY_DATA
and #JOY_DATA_LEFT
bne notleft
dec xpos
lda xpos
sta LCD_XPOS
notleft:
lda JOY_DATA
and #JOY_DATA_RIGHT
bne notright
inc xpos
lda xpos
sta LCD_XPOS
notright:
lda JOY_DATA
and #JOY_DATA_START
bne notstart
notstart:
lda JOY_DATA
and #JOY_DATA_SELECT
bne notselect
notselect:
lda JOY_DATA
and #JOY_DATA_FIRE_A
bne notbuttona
notbuttona:
lda JOY_DATA
and #JOY_DATA_FIRE_B
bne notbuttonb
notbuttonb:
rts
2015-11-14 12:15:29 +00:00
.endproc
2015-11-29 00:14:59 +00:00
;-------------------------------------------------------------------------------
2015-11-14 12:15:29 +00:00
.proc printstring
2015-11-29 19:04:10 +00:00
sta psa
stx psa+1
ldx #0
stx psx
sty psy
2015-11-14 12:15:29 +00:00
printstring2:
2015-11-29 19:04:10 +00:00
ldy #0
lda (psa),y
beq printstring1
ldx psx
stx LCD_X
ldy psy
sty LCD_Y
jsr printsign
inc psx
lda psa
2015-11-29 00:14:59 +00:00
clc
2015-11-29 19:04:10 +00:00
adc #1
sta psa
lda psa+1
adc #0
sta psa+1
jmp printstring2
2015-11-14 12:15:29 +00:00
printstring1:
2015-11-29 00:14:59 +00:00
rts
2015-11-14 12:15:29 +00:00
.endproc
.proc printstringy
2015-11-29 19:04:10 +00:00
sta psa
stx psa+1
2015-11-14 12:15:29 +00:00
printstring2:
2015-11-29 19:04:10 +00:00
ldy #0
lda (psa),y
beq printstring1
jsr printsign
lda psa
2015-11-29 00:14:59 +00:00
clc
2015-11-29 19:04:10 +00:00
adc #1
sta psa
lda psa+1
adc #0
sta psa+1
jmp printstring2
2015-11-14 12:15:29 +00:00
printstring1:
2015-11-29 00:14:59 +00:00
rts
2015-11-14 12:15:29 +00:00
.endproc
.proc printhex
2015-11-29 00:14:59 +00:00
pha
lsr
lsr
lsr
lsr
2015-11-29 19:04:10 +00:00
and #$0f
stx temp_x
2015-11-29 00:14:59 +00:00
tax
2015-11-29 19:04:10 +00:00
lda hex2asc,x
ldx temp_x
stx LCD_X
sty LCD_Y
jsr printsign
2015-11-29 00:14:59 +00:00
pla
2015-11-29 19:04:10 +00:00
and #$0f
2015-11-29 00:14:59 +00:00
inx
2015-11-29 19:04:10 +00:00
stx temp_x
2015-11-29 00:14:59 +00:00
tax
2015-11-29 19:04:10 +00:00
lda hex2asc,x
ldx temp_x
stx LCD_X
sty LCD_Y
jmp printsign
2015-11-14 12:15:29 +00:00
.endproc
.proc printsign
2015-11-29 00:14:59 +00:00
sty temp_y
stx temp_x
sta temp_a
lda temp_a
sta addr
lda #0
sta addr+1
asl addr
rol addr+1
asl addr
rol addr+1
asl addr
rol addr+1
lda addr
clc
adc #<chars
sta addr
lda addr+1
adc #>chars
sta addr+1
ldx #8
ldy #0
2015-11-14 12:15:29 +00:00
printsign1:
2015-11-29 00:14:59 +00:00
lda (addr),y
sta LCD_DATA
iny
dex
bne printsign1
ldx temp_x
ldy temp_y
rts
2015-11-14 12:15:29 +00:00
.endproc