mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
api change: renamed cx16.push/pop_vera_context() to save/restore_vera_context()
this better reflects its capability because it doesn't use a stack, only a single buffer
This commit is contained in:
parent
d01a26ec61
commit
a296d26328
@ -104,6 +104,7 @@ psg {
|
||||
; you have to call this routine every 1/60th second, for example from your vsync irq handler,
|
||||
; or just install this routine as the only irq handler if you don't have to do other things there.
|
||||
; Example: cx16.set_irq(&psg.envelopes_irq, true)
|
||||
; NOTE: this routine calls save/restore_vera_context() for you, don't nest this!
|
||||
|
||||
; cx16.r0 = the volume word (volume scaled by 256)
|
||||
; cx16.r1L = the voice number
|
||||
@ -148,7 +149,7 @@ psg {
|
||||
}
|
||||
|
||||
; set new volumes of all 16 voices, using vera stride of 4
|
||||
cx16.push_vera_context()
|
||||
cx16.save_vera_context()
|
||||
cx16.VERA_CTRL = 0
|
||||
cx16.VERA_ADDR_L = $c2
|
||||
cx16.VERA_ADDR_M = $f9
|
||||
@ -160,7 +161,7 @@ psg {
|
||||
for cx16.r1L in 0 to 15 {
|
||||
cx16.VERA_DATA0 = cx16.VERA_DATA1 & %11000000 | msb(envelope_volumes[cx16.r1L])
|
||||
}
|
||||
cx16.pop_vera_context()
|
||||
cx16.restore_vera_context()
|
||||
popw(cx16.r9)
|
||||
pop(cx16.r2L)
|
||||
pop(cx16.r1L)
|
||||
|
@ -786,7 +786,7 @@ IRQ_SCRATCH_ZPWORD2 .word 0
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub push_vera_context() clobbers(A) {
|
||||
asmsub save_vera_context() clobbers(A) {
|
||||
; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state
|
||||
%asm {{
|
||||
; note cannot store this on cpu hardware stack because this gets called as a subroutine
|
||||
@ -813,24 +813,24 @@ _vera_storage: .byte 0,0,0,0,0,0,0,0
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub pop_vera_context() clobbers(A) {
|
||||
asmsub restore_vera_context() clobbers(A) {
|
||||
; -- use this at the end of your IRQ handler if it uses Vera registers, to restore the state
|
||||
%asm {{
|
||||
lda cx16.push_vera_context._vera_storage+7
|
||||
lda cx16.save_vera_context._vera_storage+7
|
||||
sta cx16.VERA_CTRL
|
||||
lda cx16.push_vera_context._vera_storage+6
|
||||
lda cx16.save_vera_context._vera_storage+6
|
||||
sta cx16.VERA_ADDR_H
|
||||
lda cx16.push_vera_context._vera_storage+5
|
||||
lda cx16.save_vera_context._vera_storage+5
|
||||
sta cx16.VERA_ADDR_M
|
||||
lda cx16.push_vera_context._vera_storage+4
|
||||
lda cx16.save_vera_context._vera_storage+4
|
||||
sta cx16.VERA_ADDR_L
|
||||
lda cx16.push_vera_context._vera_storage+3
|
||||
lda cx16.save_vera_context._vera_storage+3
|
||||
sta cx16.VERA_CTRL
|
||||
lda cx16.push_vera_context._vera_storage+2
|
||||
lda cx16.save_vera_context._vera_storage+2
|
||||
sta cx16.VERA_ADDR_H
|
||||
lda cx16.push_vera_context._vera_storage+1
|
||||
lda cx16.save_vera_context._vera_storage+1
|
||||
sta cx16.VERA_ADDR_M
|
||||
lda cx16.push_vera_context._vera_storage+0
|
||||
lda cx16.save_vera_context._vera_storage+0
|
||||
sta cx16.VERA_ADDR_L
|
||||
rts
|
||||
}}
|
||||
|
@ -162,9 +162,9 @@ The Commander X16 syslib does provides two additional routines that should be us
|
||||
They take care of saving and restoring the Vera state of the interrupted main program, otherwise the IRQ handler's manipulation
|
||||
will corrupt any Vera operations that were going on in the main program. The routines are::
|
||||
|
||||
cx16.push_vera_context()
|
||||
cx16.save_vera_context()
|
||||
; ... do your work that uses vera here...
|
||||
cx16.pop_vera_context()
|
||||
cx16.restore_vera_context()
|
||||
|
||||
.. caution::
|
||||
The Commander X16's 16 'virtual registers' R0-R15 are located in zeropage and *are not preserved* in the IRQ handler!
|
||||
|
Loading…
Reference in New Issue
Block a user