mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +00:00
116 lines
2.1 KiB
ArmAsm
116 lines
2.1 KiB
ArmAsm
|
;
|
||
|
; Written by Groepaz/Hitmen <groepaz@gmx.net>
|
||
|
; Cleanup by Ullrich von Bassewitz <uz@cc65.org>
|
||
|
;
|
||
|
|
||
|
|
||
|
.export ppubuf_waitempty
|
||
|
.export ppubuf_wait
|
||
|
.export ppubuf_put
|
||
|
.export ppubuf_flush
|
||
|
.include "nes.inc"
|
||
|
|
||
|
.code
|
||
|
|
||
|
; ------------------------------------------------------------------------
|
||
|
; ppubuf_waitempty
|
||
|
; Wait until buffer is empty
|
||
|
|
||
|
.proc ppubuf_waitempty
|
||
|
|
||
|
|
||
|
@wait: lda ringcount
|
||
|
bne @wait
|
||
|
rts
|
||
|
|
||
|
.endproc
|
||
|
|
||
|
|
||
|
; ------------------------------------------------------------------------
|
||
|
; ppubuf_wait
|
||
|
; Wait until buffer is full
|
||
|
|
||
|
.proc ppubuf_wait
|
||
|
|
||
|
lda #$ff ; (($0100/3)*1)
|
||
|
@wait: cmp ringcount
|
||
|
beq @wait
|
||
|
rts
|
||
|
|
||
|
.endproc
|
||
|
|
||
|
; ------------------------------------------------------------------------
|
||
|
; Put a PPU-Memory write to buffer
|
||
|
; called from main program (not necessary when in vblank irq)
|
||
|
|
||
|
.proc ppubuf_put
|
||
|
|
||
|
sta ppuval
|
||
|
sty ppuhi
|
||
|
stx ppulo
|
||
|
|
||
|
jsr ppubuf_wait ; wait if buffer is full
|
||
|
|
||
|
ldy ringwrite
|
||
|
lda ppuhi
|
||
|
sta ringbuff,y
|
||
|
lda ppulo
|
||
|
sta ringbuff+$0100,y
|
||
|
lda ppuval
|
||
|
sta ringbuff+$0200,y
|
||
|
|
||
|
iny
|
||
|
sty ringwrite
|
||
|
inc ringcount
|
||
|
rts
|
||
|
|
||
|
.endproc
|
||
|
|
||
|
; ------------------------------------------------------------------------
|
||
|
; Flush PPU-Memory write buffer
|
||
|
; called from vblank interupt
|
||
|
|
||
|
.proc ppubuf_flush
|
||
|
|
||
|
ldy ringcount
|
||
|
bne @doloop
|
||
|
rts
|
||
|
|
||
|
@doloop:
|
||
|
ldx ringread
|
||
|
lda #$0e
|
||
|
sta temp
|
||
|
|
||
|
@loop:
|
||
|
.repeat 5
|
||
|
lda ringbuff,x
|
||
|
sta $2006
|
||
|
lda ringbuff+$0100,x
|
||
|
sta $2006
|
||
|
lda ringbuff+$0200,x
|
||
|
sta $2007
|
||
|
inx
|
||
|
|
||
|
dey
|
||
|
beq @end
|
||
|
.endrepeat
|
||
|
|
||
|
dec temp
|
||
|
bne @loop
|
||
|
|
||
|
@end: stx ringread
|
||
|
sty ringcount
|
||
|
|
||
|
rts
|
||
|
|
||
|
.endproc
|
||
|
|
||
|
; ------------------------------------------------------------------------
|
||
|
; Data
|
||
|
|
||
|
.bss
|
||
|
|
||
|
temp: .res 1
|
||
|
|
||
|
|