6502 command stream player, part 18
- fix short wait for multiples of 256 - fix arp implementation - fix vibrato implementation - make example command table bigger - add a basic status view
This commit is contained in:
parent
216518d65b
commit
6acc835d71
|
@ -1,7 +1,7 @@
|
|||
all: test.nes
|
||||
test.nes: test.o test.ini
|
||||
wlalink -v -S test.ini test.nes
|
||||
test.o: test.s nes.i chr.bin ../stream.s
|
||||
test.o: test.s nes.i chr.bin ../stream.s ../seq.bin
|
||||
wla-6502 -o test.o test.s
|
||||
|
||||
clean:
|
||||
|
|
|
@ -12,6 +12,8 @@ PPUDATA=$2007
|
|||
|
||||
APUBASE=$4000
|
||||
OAMDMA=$4014
|
||||
JOY1=$4016
|
||||
JOY2=$4017
|
||||
|
||||
; memory map
|
||||
.MEMORYMAP
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
.include "nes.i"
|
||||
|
||||
pendingTick=$400
|
||||
curChan=$401
|
||||
joyInput=$402
|
||||
joyPrev=$403
|
||||
|
||||
; program ROM
|
||||
.BANK 1 SLOT 1
|
||||
|
@ -94,7 +97,7 @@ loop:
|
|||
beq loop
|
||||
; wait a bit so we can see the raster
|
||||
ldy #$ff
|
||||
ldx #$03
|
||||
ldx #$02
|
||||
|
||||
- dey
|
||||
bne -
|
||||
|
@ -115,12 +118,134 @@ loop:
|
|||
|
||||
jmp loop
|
||||
|
||||
.MACRO ppuPos
|
||||
bit PPUSTATUS
|
||||
lda #>($2000+((\1))+((\2)<<5))
|
||||
sta PPUADDR
|
||||
lda #<($2000+((\1))+((\2)<<5))
|
||||
sta PPUADDR
|
||||
.ENDM
|
||||
|
||||
; interrupt handlers
|
||||
nmi:
|
||||
php
|
||||
pha
|
||||
lda #1
|
||||
|
||||
; read controller
|
||||
lda joyInput
|
||||
sta joyPrev
|
||||
lda #$01
|
||||
sta JOY1
|
||||
sta joyInput
|
||||
lsr
|
||||
sta JOY1
|
||||
|
||||
- lda JOY1
|
||||
lsr
|
||||
rol joyInput
|
||||
bcc -
|
||||
|
||||
; PPU update
|
||||
ppuPos 10, 4
|
||||
|
||||
lda curChan
|
||||
jsr printNum
|
||||
|
||||
lda curChan
|
||||
rol
|
||||
tax
|
||||
|
||||
ppuPos 12, 6
|
||||
|
||||
lda chanPC.w+1,x
|
||||
jsr printNum
|
||||
lda chanPC.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 12, 7
|
||||
|
||||
lda chanTicks.w+1,x
|
||||
jsr printNum
|
||||
lda chanTicks.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 14, 8
|
||||
lda chanNote.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 14, 9
|
||||
lda chanPitch.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 20, 9
|
||||
lda chanVibratoDebug.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 14, 10
|
||||
lda chanVibrato.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 14, 11
|
||||
lda chanVibratoPos.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 14, 12
|
||||
lda chanArp.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 20, 12
|
||||
lda chanArpTicks.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 23, 12
|
||||
lda chanArpStage.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 14, 13
|
||||
lda chanPortaSpeed.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 20, 13
|
||||
lda chanPortaTarget.w,x
|
||||
jsr printNum
|
||||
|
||||
ppuPos 12, 14
|
||||
lda chanVol.w+1,x
|
||||
jsr printNum
|
||||
lda chanVol.w,x
|
||||
jsr printNum
|
||||
|
||||
; end of PPU update
|
||||
bit PPUSTATUS
|
||||
lda #0
|
||||
sta PPUSCROLL
|
||||
sta PPUSCROLL
|
||||
|
||||
; process joy input
|
||||
lda joyInput
|
||||
eor joyPrev
|
||||
and joyInput
|
||||
|
||||
; left
|
||||
pha
|
||||
and #$02
|
||||
beq +
|
||||
dec curChan
|
||||
bpl +
|
||||
lda #0
|
||||
sta curChan
|
||||
|
||||
; right
|
||||
+ pla
|
||||
and #$01
|
||||
beq +
|
||||
inc curChan
|
||||
|
||||
; set pendingTick
|
||||
+ lda #1
|
||||
sta pendingTick
|
||||
|
||||
; end
|
||||
pla
|
||||
plp
|
||||
rti
|
||||
|
@ -128,6 +253,22 @@ nmi:
|
|||
irq:
|
||||
rti
|
||||
|
||||
printNum:
|
||||
pha
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
tay
|
||||
lda hexChar.w,y
|
||||
sta PPUDATA
|
||||
pla
|
||||
and #$0f
|
||||
tay
|
||||
lda hexChar.w,y
|
||||
sta PPUDATA
|
||||
rts
|
||||
|
||||
; command stream player definition
|
||||
FCS_MAX_CHAN=8
|
||||
|
||||
|
@ -147,17 +288,23 @@ fcsCmdTableHigh=fcsCmdTableExample
|
|||
screenText:
|
||||
.db " Furnace Test Player "
|
||||
.db " "
|
||||
.db " channel "
|
||||
.db " "
|
||||
.db " PC tick "
|
||||
.db " note pitch "
|
||||
.db " vib vibPos "
|
||||
.db " arp porta "
|
||||
.db " vol volS "
|
||||
.db " pan "
|
||||
.db " channel 00 "
|
||||
.db " "
|
||||
.db " PC $0000 (00) "
|
||||
.db " tick 0000 "
|
||||
.db " note 00 "
|
||||
.db " pitch 00 ~00 "
|
||||
.db " vib 00 "
|
||||
.db " vibPos 00 "
|
||||
.db " arp 00 (00/00) "
|
||||
.db " porta 00 -> 00 "
|
||||
.db " vol 0000 "
|
||||
.db " pan 0000 "
|
||||
.db 0
|
||||
|
||||
hexChar:
|
||||
.db "0123456789ABCDEF"
|
||||
|
||||
ppuPalette:
|
||||
.db $0e, $00, $10, $30
|
||||
.db $0e, $00, $10, $30
|
||||
|
@ -165,7 +312,16 @@ ppuPalette:
|
|||
.db $0e, $00, $10, $30
|
||||
|
||||
volMaxArray:
|
||||
.dw $40, $40, $40, $40
|
||||
.db $7f, 00
|
||||
.db $7f, 00
|
||||
.db $7f, 00
|
||||
.db $7f, 00
|
||||
.db $7f, 00
|
||||
.db $7f, 00
|
||||
.db $7f, 00
|
||||
.db $7f, 00
|
||||
|
||||
.ORGA $9000
|
||||
|
||||
cmdStream:
|
||||
.incbin "../seq.bin"
|
||||
|
|
|
@ -55,6 +55,7 @@ chanVolSpeed=fcsAddrBase+24+(FCS_MAX_CHAN*12) ; short
|
|||
chanPan=fcsAddrBase+24+(FCS_MAX_CHAN*14) ; short
|
||||
chanArpStage=fcsAddrBase+24+(FCS_MAX_CHAN*16) ; char
|
||||
chanArpTicks=fcsAddrBase+24+(FCS_MAX_CHAN*16)+1 ; char
|
||||
chanVibratoDebug=fcsAddrBase+24+(FCS_MAX_CHAN*18) ; char
|
||||
|
||||
; may be used for driver detection
|
||||
fcsDriverInfo:
|
||||
|
@ -244,10 +245,10 @@ fcsNoOpOneByte:
|
|||
|
||||
fcsPan:
|
||||
fcsReadNext
|
||||
sta chanPan,x
|
||||
sta chanPan.w,x
|
||||
sta fcsArg0
|
||||
fcsReadNext
|
||||
sta chanPan+1,x
|
||||
sta chanPan.w+1,x
|
||||
sta fcsArg1
|
||||
ldy #10
|
||||
jsr fcsDispatchCmd
|
||||
|
@ -379,9 +380,14 @@ fcsTickRate:
|
|||
rts
|
||||
|
||||
fcsWaitS:
|
||||
sec
|
||||
fcsReadNext
|
||||
and #$ff
|
||||
sta chanTicks,x
|
||||
fcsReadNext
|
||||
bne +
|
||||
clc
|
||||
+ fcsReadNext
|
||||
adc #$ff
|
||||
sta chanTicks+1,x
|
||||
rts
|
||||
|
||||
|
@ -565,8 +571,16 @@ fcsChannelPost:
|
|||
jmp fcsChanDoPitch1
|
||||
|
||||
; update vibrato
|
||||
; get vibrato
|
||||
; 1. store vibrato pitch table offset
|
||||
+ lda chanVibrato,x
|
||||
rol
|
||||
rol
|
||||
rol
|
||||
rol
|
||||
and #$f0
|
||||
sta fcsTempPtr
|
||||
; 2. update vibrato position
|
||||
lda chanVibrato,x
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
|
@ -575,16 +589,7 @@ fcsChannelPost:
|
|||
adc chanVibratoPos,x
|
||||
and #$3f
|
||||
sta chanVibratoPos,x
|
||||
; calculate vibrato pitch (TODO)
|
||||
; 1. store table offset
|
||||
lda chanVibrato,x
|
||||
rol
|
||||
rol
|
||||
rol
|
||||
rol
|
||||
and #$f0
|
||||
sta fcsTempPtr
|
||||
; 2. calculate vibrato position
|
||||
; 3. calculate vibrato pitch
|
||||
; - we use 15 quarter sine tables, one for each vibrato depth
|
||||
; - 32-63 are negatives of 0-31
|
||||
; - a&31: zero is zero. otherwise a-1 in the table unless a&16
|
||||
|
@ -635,6 +640,7 @@ fcsChannelPost:
|
|||
; at this point, a contains the vibrato pitch
|
||||
fcsPostVibratoCalc1:
|
||||
sta fcsArg0
|
||||
sta chanVibratoDebug,x
|
||||
; extend sign
|
||||
bmi +
|
||||
lda #0
|
||||
|
@ -850,7 +856,17 @@ fcsInit:
|
|||
bne -
|
||||
|
||||
; set volumes
|
||||
; TODO
|
||||
ldx #0
|
||||
- lda fcsVolMax.w,x
|
||||
sta chanVol+1,x
|
||||
inx
|
||||
inx
|
||||
cpx #(FCS_MAX_CHAN*2)
|
||||
bne -
|
||||
|
||||
; set arp speed
|
||||
lda #1
|
||||
sta fcsArpSpeed
|
||||
|
||||
; success
|
||||
lda #0
|
||||
|
@ -1198,13 +1214,5 @@ fcsVolMaxExample:
|
|||
.db $7f, $00
|
||||
.db $7f, $00
|
||||
|
||||
; first 64 commands
|
||||
fcsCmdTableExample:
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.dsb 256, 0
|
||||
|
|
Loading…
Reference in a new issue