1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-04 17:04:58 +00:00
cc65/testcode/lib/gamate/audiotest.s

458 lines
9.1 KiB
ArmAsm
Raw Normal View History

2015-11-29 19:04:10 +00:00
;
2015-11-29 00:24:01 +00:00
; original audiotest.s by PeT (mess@utanet.at)
2015-11-29 19:04:10 +00:00
;
; cl65 -t gamate -o audiotest.bin audiotest.s
;
2015-11-22 18:02:47 +00:00
2015-11-29 00:14:59 +00:00
.include "gamate.inc"
2015-11-29 00:24:01 +00:00
.zeropage
2015-11-29 19:04:10 +00:00
addr: .word 0
psa: .word 0
readaddr: .word 0
editbuffer1: .byte 0,0,0,0, 0,0,0,0
writeaddr: .word 0
editbuffer2: .byte 0,0,0,0, 0,0,0,0
cursor: .byte 0
controlslast: .byte 0
controlsedge: .byte 0
.bss
temp_x: .byte 0
temp_y: .byte 0
temp_a: .byte 0
irq_count: .byte 0
nmi_count: .byte 0
psx: .byte 0
psy: .byte 0
xpos: .byte 0
ypos: .byte 0
.rodata
2015-11-14 12:15:29 +00:00
chars: .incbin "cga2.chr"
hex2asc: .byte "0123456789abcdef"
2015-11-14 12:15:29 +00:00
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 19:04:10 +00:00
.proc IRQStub
2015-11-29 00:14:59 +00:00
inc irq_count
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
lda #>AUDIO_BASE
sta writeaddr+1
sta readaddr+1
lda #<AUDIO_BASE
sta writeaddr
sta readaddr
lda #$10
sta editbuffer1+6
lda #$e
sta editbuffer2+5
lda #$ff
sta editbuffer2+3
lda #$ff
sta editbuffer2+4
lda #$0f
sta editbuffer2
lda #$0f
sta editbuffer2+1
lda #$0e
sta editbuffer2+2
lda #$38
sta editbuffer1+7
lda #0
sta LCD_XPOS
sta LCD_YPOS
sta irq_count
sta cursor
lda #1
sta nmi_count
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
jsr printy
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
lda #1
sta ZP_IRQ_CTRL
2015-11-14 12:15:29 +00:00
2015-11-29 19:04:10 +00:00
loop:
lda irq_count
2015-11-14 12:15:29 +00:00
loop1:
2015-11-29 19:04:10 +00:00
cmp irq_count
beq loop1
lda irq_count
and #7
bne loop1
lda #LCD_MODE_INC_Y
sta LCD_MODE
ldx #3
ldy #32
lda irq_count
jsr printhex
lda cursor
ldy #0
cmp #20
bcc firstline
2015-11-29 00:14:59 +00:00
sec
2015-11-29 19:04:10 +00:00
sbc #20
ldy #24
2015-11-14 12:15:29 +00:00
firstline:
2015-11-29 19:04:10 +00:00
sta LCD_X
sty LCD_Y
lda #' '
jsr printsign
2015-11-14 12:15:29 +00:00
norclearcursor:
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
jsr inputs
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
lda irq_count
and #8
bne nocursor
lda cursor
ldy #0
cmp #20
bcc firstline2
2015-11-29 00:14:59 +00:00
sec
2015-11-29 19:04:10 +00:00
sbc #20
ldy #24
2015-11-14 12:15:29 +00:00
firstline2:
2015-11-29 19:04:10 +00:00
sta LCD_X
sty LCD_Y
lda #'x'
jsr printsign
2015-11-14 12:15:29 +00:00
nocursor:
2015-11-29 19:04:10 +00:00
lda #LCD_MODE_INC_Y
sta LCD_MODE
jsr printy
jmp loop
2015-11-14 12:15:29 +00:00
.endproc
.proc printy
2015-11-29 19:04:10 +00:00
ldy #0
2015-11-14 12:15:29 +00:00
loop1:
2015-11-29 00:14:59 +00:00
tya
pha
asl
tax
2015-11-29 19:04:10 +00:00
lda readaddr,y
ldy #8
jsr printhex
2015-11-29 00:14:59 +00:00
pla
tay
iny
2015-11-29 19:04:10 +00:00
cpy #10
bne loop1
2015-11-14 12:15:29 +00:00
loop2:
2015-11-29 00:14:59 +00:00
tya
pha
tya
sec
2015-11-29 19:04:10 +00:00
sbc #10
2015-11-29 00:14:59 +00:00
asl
tax
2015-11-29 19:04:10 +00:00
lda readaddr,y
ldy #16
jsr printhex
2015-11-29 00:14:59 +00:00
pla
tay
iny
2015-11-29 19:04:10 +00:00
cpy #20
bne loop2
2015-11-29 00:14:59 +00:00
2015-11-29 19:04:10 +00:00
ldx #0
ldy #32
lda nmi_count
jsr printhex
2015-11-29 00:14:59 +00:00
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 inputs
2015-11-29 19:04:10 +00:00
lda controlslast
eor JOY_DATA
and controlslast
eor #$ff
sta controlsedge
and #JOY_DATA_UP
bne notup
lda cursor
2015-11-29 00:14:59 +00:00
lsr
tay
2015-11-29 19:04:10 +00:00
bcs uplow
lda readaddr,y
2015-11-29 00:14:59 +00:00
clc
2015-11-29 19:04:10 +00:00
adc #$10
sta readaddr,y
jmp notup
uplow:
lda readaddr,y
2015-11-29 00:14:59 +00:00
clc
2015-11-29 19:04:10 +00:00
adc #1
sta readaddr,y
notup:
lda controlsedge
and #JOY_DATA_DOWN
bne notdown
lda cursor
2015-11-29 00:14:59 +00:00
lsr
tay
2015-11-29 19:04:10 +00:00
bcs downlow
lda readaddr,y
2015-11-29 00:14:59 +00:00
sec
2015-11-29 19:04:10 +00:00
sbc #$10
sta readaddr,y
jmp notdown
2015-11-14 12:15:29 +00:00
downlow:
2015-11-29 19:04:10 +00:00
lda readaddr,y
2015-11-29 00:14:59 +00:00
sec
2015-11-29 19:04:10 +00:00
sbc #1
sta readaddr,y
notdown:
lda controlsedge
and #JOY_DATA_LEFT
bne notleft
lda cursor
beq notleft
dec cursor
notleft:
lda controlsedge
and #JOY_DATA_RIGHT
bne notright
lda cursor
cmp #40
beq notright
inc cursor
notright:
lda controlsedge
and #JOY_DATA_START
bne notstart
lda #0
sta AUDIO_BASE
sta AUDIO_BASE+1
sta AUDIO_BASE+2
sta AUDIO_BASE+3
sta AUDIO_BASE+4
sta AUDIO_BASE+5
sta AUDIO_BASE+6
sta AUDIO_BASE+8
sta AUDIO_BASE+9
sta AUDIO_BASE+10
sta AUDIO_BASE+11
sta AUDIO_BASE+12
sta AUDIO_BASE+13
sta AUDIO_BASE+7
notstart:
lda controlsedge
and #JOY_DATA_SELECT
bne notselect
2015-11-30 18:16:28 +00:00
2015-11-29 19:04:10 +00:00
lda editbuffer1
sta AUDIO_BASE
lda editbuffer1+1
sta AUDIO_BASE+1
lda editbuffer1+2
sta AUDIO_BASE+2
lda editbuffer1+3
sta AUDIO_BASE+3
lda editbuffer1+4
sta AUDIO_BASE+4
lda editbuffer1+5
sta AUDIO_BASE+5
lda editbuffer1+6
sta AUDIO_BASE+6
lda editbuffer2
sta AUDIO_BASE+8
lda editbuffer2+1
sta AUDIO_BASE+9
lda editbuffer2+2
sta AUDIO_BASE+10
lda editbuffer2+3
sta AUDIO_BASE+11
lda editbuffer2+4
sta AUDIO_BASE+12
lda editbuffer2+5
sta AUDIO_BASE+13
lda editbuffer1+7
sta AUDIO_BASE+7
notselect:
lda controlsedge
and #JOY_DATA_FIRE_A
bne notbuttona
ldy #0
ldy #0
writea:
lda editbuffer1,y
sta (writeaddr),y
2015-11-29 00:14:59 +00:00
iny
2015-11-29 19:04:10 +00:00
cpy #8
bne writea
writeb:
lda editbuffer2-8,y
sta (writeaddr),y
2015-11-29 00:14:59 +00:00
iny
2015-11-29 19:04:10 +00:00
cpy #16
bne writeb
notbuttona:
lda controlsedge
and #JOY_DATA_FIRE_B
bne notbuttonb
ldy #0
reada:
lda (readaddr),y
sta editbuffer1,y
2015-11-29 00:14:59 +00:00
iny
2015-11-29 19:04:10 +00:00
cpy #8
bne reada
readb: lda (readaddr),y
sta editbuffer2-8,y
2015-11-29 00:14:59 +00:00
iny
2015-11-29 19:04:10 +00:00
cpy #16
2015-11-29 00:14:59 +00:00
bne readb
2015-11-14 12:15:29 +00:00
notbuttonb:
2015-11-29 19:04:10 +00:00
lda JOY_DATA
sta controlslast
2015-11-29 00:14:59 +00:00
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 19:04:10 +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
2015-11-29 00:14:59 +00:00
clc
2015-11-29 19:04:10 +00:00
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 19:04:10 +00:00
lda (addr),y
sta LCD_DATA
2015-11-29 00:14:59 +00:00
iny
dex
2015-11-29 19:04:10 +00:00
bne printsign1
ldx temp_x
ldy temp_y
2015-11-29 00:14:59 +00:00
rts
2015-11-14 12:15:29 +00:00
.endproc