6502 command stream player, part 12
optimize byte reading (from ~26 to ~14 cycles)
This commit is contained in:
parent
de86a7f742
commit
3407202f12
|
@ -59,6 +59,18 @@ fcsDriverInfo:
|
||||||
.db "Furnace"
|
.db "Furnace"
|
||||||
.db 0
|
.db 0
|
||||||
|
|
||||||
|
; x: channel*2
|
||||||
|
; a is set to next byte
|
||||||
|
.MACRO fcsReadNext
|
||||||
|
; a=chanPC[x]
|
||||||
|
lda (chanPC,x)
|
||||||
|
; increase PC
|
||||||
|
inc chanPC,x
|
||||||
|
bne +
|
||||||
|
inc chanPC+1,x
|
||||||
|
+
|
||||||
|
.ENDM
|
||||||
|
|
||||||
; note on null
|
; note on null
|
||||||
fcsNoteOnNull:
|
fcsNoteOnNull:
|
||||||
lda #0
|
lda #0
|
||||||
|
@ -79,7 +91,7 @@ fcsNoArgDispatch:
|
||||||
fcsOneByteDispatch:
|
fcsOneByteDispatch:
|
||||||
tya
|
tya
|
||||||
pha
|
pha
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta fcsArg0
|
sta fcsArg0
|
||||||
pla
|
pla
|
||||||
sec
|
sec
|
||||||
|
@ -89,7 +101,7 @@ fcsOneByteDispatch:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsPrePorta:
|
fcsPrePorta:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
pha
|
pha
|
||||||
and #$80
|
and #$80
|
||||||
sta fcsArg0
|
sta fcsArg0
|
||||||
|
@ -101,35 +113,35 @@ fcsPrePorta:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsArpTime:
|
fcsArpTime:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta fcsArpSpeed
|
sta fcsArpSpeed
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsVibrato:
|
fcsVibrato:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanVibrato,x
|
sta chanVibrato,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; TODO
|
; TODO
|
||||||
fcsVibRange:
|
fcsVibRange:
|
||||||
fcsVibShape:
|
fcsVibShape:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsPitch:
|
fcsPitch:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanPitch,x
|
sta chanPitch,x
|
||||||
lda #1
|
lda #1
|
||||||
sta fcsSendPitch
|
sta fcsSendPitch
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsArpeggio:
|
fcsArpeggio:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanArp,x
|
sta chanArp,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsVolume:
|
fcsVolume:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanVol+1,x
|
sta chanVol+1,x
|
||||||
lda #0
|
lda #0
|
||||||
sta chanVol,x
|
sta chanVol,x
|
||||||
|
@ -138,21 +150,21 @@ fcsVolume:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsVolSlide:
|
fcsVolSlide:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanVolSpeed,x
|
sta chanVolSpeed,x
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanVolSpeed+1,x
|
sta chanVolSpeed+1,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsPorta:
|
fcsPorta:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanPortaTarget,x
|
sta chanPortaTarget,x
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanPortaSpeed,x
|
sta chanPortaSpeed,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsLegato:
|
fcsLegato:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanNote,x
|
sta chanNote,x
|
||||||
sta fcsArg0
|
sta fcsArg0
|
||||||
ldy #11
|
ldy #11
|
||||||
|
@ -160,24 +172,24 @@ fcsLegato:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsVolSlideTarget:
|
fcsVolSlideTarget:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanVolSpeed,x
|
sta chanVolSpeed,x
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanVolSpeed+1,x
|
sta chanVolSpeed+1,x
|
||||||
; TODO: we don't support this yet...
|
; TODO: we don't support this yet...
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsNoOpOneByte:
|
fcsNoOpOneByte:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsPan:
|
fcsPan:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanPan,x
|
sta chanPan,x
|
||||||
sta fcsArg0
|
sta fcsArg0
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanPan+1,x
|
sta chanPan+1,x
|
||||||
sta fcsArg1
|
sta fcsArg1
|
||||||
ldy #10
|
ldy #10
|
||||||
|
@ -185,18 +197,18 @@ fcsPan:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsOptPlaceholder:
|
fcsOptPlaceholder:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsCallI:
|
fcsCallI:
|
||||||
; get address and relocate it
|
; get address and relocate it
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
clc
|
clc
|
||||||
adc #<fcsPtr
|
adc #<fcsPtr
|
||||||
pha
|
pha
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
adc #>fcsPtr
|
adc #>fcsPtr
|
||||||
pha
|
pha
|
||||||
; ignore next two bytes
|
; ignore next two bytes
|
||||||
|
@ -223,11 +235,11 @@ fcsFullCmd:
|
||||||
|
|
||||||
fcsCall:
|
fcsCall:
|
||||||
; get address and relocate it
|
; get address and relocate it
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
clc
|
clc
|
||||||
adc #<fcsPtr
|
adc #<fcsPtr
|
||||||
pha
|
pha
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
adc #>fcsPtr
|
adc #>fcsPtr
|
||||||
pha
|
pha
|
||||||
jsr fcsPushCall
|
jsr fcsPushCall
|
||||||
|
@ -267,11 +279,11 @@ fcsRet:
|
||||||
|
|
||||||
fcsJump:
|
fcsJump:
|
||||||
; get address and relocate it
|
; get address and relocate it
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
clc
|
clc
|
||||||
adc #<fcsPtr
|
adc #<fcsPtr
|
||||||
pha
|
pha
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
adc #>fcsPtr
|
adc #>fcsPtr
|
||||||
pha
|
pha
|
||||||
; ignore next two bytes
|
; ignore next two bytes
|
||||||
|
@ -288,14 +300,14 @@ fcsTickRate:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsWaitS:
|
fcsWaitS:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanTicks,x
|
sta chanTicks,x
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanTicks+1,x
|
sta chanTicks+1,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fcsWaitC:
|
fcsWaitC:
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
sta chanTicks,x
|
sta chanTicks,x
|
||||||
lda #0
|
lda #0
|
||||||
sta chanTicks+1,x
|
sta chanTicks+1,x
|
||||||
|
@ -334,19 +346,6 @@ fcsDispatchCmd:
|
||||||
; only if pointer is zero
|
; only if pointer is zero
|
||||||
+ rts
|
+ rts
|
||||||
|
|
||||||
; x: channel*2
|
|
||||||
; a is set to next byte
|
|
||||||
fcsReadNext:
|
|
||||||
; a=chanPC[x]
|
|
||||||
lda (chanPC,x)
|
|
||||||
php
|
|
||||||
; increase PC
|
|
||||||
inc chanPC,x
|
|
||||||
bne +
|
|
||||||
inc chanPC+1,x
|
|
||||||
+ plp
|
|
||||||
rts
|
|
||||||
|
|
||||||
; x: channel*2
|
; x: channel*2
|
||||||
fcsIgnoreNext:
|
fcsIgnoreNext:
|
||||||
; increase PC
|
; increase PC
|
||||||
|
@ -359,7 +358,8 @@ fcsIgnoreNext:
|
||||||
; read commands
|
; read commands
|
||||||
fcsChannelCmd:
|
fcsChannelCmd:
|
||||||
; read next byte
|
; read next byte
|
||||||
jsr fcsReadNext
|
fcsReadNext
|
||||||
|
and #$ff ; touch flags
|
||||||
|
|
||||||
; process and read arguments
|
; process and read arguments
|
||||||
; if (a<0xb3)
|
; if (a<0xb3)
|
||||||
|
|
Loading…
Reference in a new issue