rasterbars_sound: work on cycle-invariant pt3 player

am I mad?  probably
This commit is contained in:
Vince Weaver 2019-06-18 16:46:05 -04:00
parent 9b3ebf7c93
commit 7017d0b2a8
4 changed files with 95 additions and 93 deletions

View File

@ -45,7 +45,7 @@ RASTERBARS_SOUND: rasterbars_sound.o
rasterbars_sound.o: rasterbars_sound.s gr_copy.s \
rasterbars_screen.s rasterbars_table.s movement_table.s rb_bg.inc \
pt3_lib.s interrupt_handler.s
pt3_lib_ci.s interrupt_handler.s
ca65 -o rasterbars_sound.o rasterbars_sound.s -l rasterbars_sound.lst

View File

@ -238,3 +238,68 @@ mb4_not_in_this_slot:
ldx #00
beq done_mb4_detect
;====================================
; mb_write_frame
;====================================
; cycle counted
mb_write_frame:
ldx #0 ; set up reg count ; 2
;============
; 2
;==================================
; loop through the 14 registers
; reading the value, then write out
;==================================
mb_write_loop:
lda AY_REGISTERS,X ; load register value ; 4
; special case R13. If it is 0xff, then don't update
; otherwise might spuriously reset the envelope settings
cpx #13 ; 2
bne mb_not_13 ; 3/2nt
cmp #$ff ; 2
beq mb_skip_13 ; 3/2nt
;============
; typ 5
mb_not_13:
; address
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
ldy #MOCK_AY_LATCH_ADDR ; latch_address for PB1 ; 2
sty MOCK_6522_ORB1 ; latch_address on PB1 ; 4
sty MOCK_6522_ORB2 ; latch_address on PB2 ; 4
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
sty MOCK_6522_ORB1 ; 4
sty MOCK_6522_ORB2 ; 4
; value
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
lda #MOCK_AY_WRITE ; ; 2
sta MOCK_6522_ORB1 ; write on PB1 ; 4
sta MOCK_6522_ORB2 ; write on PB2 ; 4
sty MOCK_6522_ORB1 ; 4
sty MOCK_6522_ORB2 ; 4
;===========
; 56
mb_no_write:
inx ; point to next register ; 2
cpx #14 ; if 14 we're done ; 2
bmi mb_write_loop ; otherwise, loop ; 3/2nt
;============
; 7
mb_skip_13:
rts ; 6
pt3_loop_smc:
.byte $0,$0

View File

@ -1,34 +1,11 @@
;===========================================
; Library to decode Vortex Tracker PT3 files
;===========================================================
; Cycle-invariant Library to decode Vortex Tracker PT3 files
; in 6502 assembly for Apple ][ Mockingboard
;
; by Vince Weaver <vince@deater.net>
; Roughly based on the Formats.pas Pascal code from Ay_Emul
; Size Optimization -- Mem+Code (pt3_lib_end-note_a)
; + 3407 bytes -- original working implementation
; + 3302 bytes -- autogenerate the volume tables
; + 3297 bytes -- remove some un-needed bytes from struct
; + 3262 bytes -- combine some duplicated code in $1X/$BX env setting
; + 3253 bytes -- remove unnecessary variable
; + 3203 bytes -- combine common code in note decoder
; + 2937 bytes -- qkumba first pass
; + 2879 bytes -- qkumba second pass
; + 2839 bytes -- mask note command in common code
; + 2832 bytes -- combine $D0 and $E0 decode
; + 2816 bytes -- eliminate "decode_done" variable (2.75k)
; + 2817 bytes -- eliminate pt3_version. Slighly faster but also bigger
; + 2828 bytes -- fix some correctness issues
; + 2776 bytes -- init vars with loop (slower, but more correct and smaller)
; + 2739 bytes -- qkumba's crazy SMC everywhere patch
; + 2430+120 = 2650 bytes -- move NOTE structs to page0
; TODO
; move some of these flags to be bits rather than bytes?
; enabled could be bit 6 or 7 for fast checking
; NOTE_ENABLED,ENVELOPE_ENABLED,SIMPLE_GLISS,ENV_SLIDING,AMP_SLIDING?
; Header offsets
PT3_VERSION = $0D
@ -2286,48 +2263,7 @@ PT3NoteTable_ASM_34_35_low:
.byte $15,$14,$12,$11,$10,$0F,$0E,$0D
;PT3VolumeTable_33_34:
;.byte $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
;.byte $0,$0,$0,$0,$0,$0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1
;.byte $0,$0,$0,$0,$0,$0,$1,$1,$1,$1,$1,$2,$2,$2,$2,$2
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$2,$3,$3,$4,$4,$4,$5,$5,$6,$6
;.byte $0,$0,$1,$1,$2,$2,$3,$3,$4,$4,$5,$5,$6,$6,$7,$7
;.byte $0,$1,$1,$2,$2,$3,$3,$4,$4,$5,$5,$6,$6,$7,$7,$8
;.byte $0,$1,$1,$2,$2,$3,$4,$4,$5,$5,$6,$7,$7,$8,$8,$9
;.byte $0,$1,$1,$2,$3,$3,$4,$5,$5,$6,$7,$7,$8,$9,$9,$A
;.byte $0,$1,$1,$2,$3,$4,$4,$5,$6,$7,$7,$8,$9,$A,$A,$B
;.byte $0,$1,$2,$2,$3,$4,$5,$6,$6,$7,$8,$9,$A,$A,$B,$C
;.byte $0,$1,$2,$3,$3,$4,$5,$6,$7,$8,$9,$A,$A,$B,$C,$D
;.byte $0,$1,$2,$3,$4,$5,$6,$7,$7,$8,$9,$A,$B,$C,$D,$E
;.byte $0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E,$F
VolumeTable:
.res 256,0
pt3_lib_end:

View File

@ -60,17 +60,17 @@ apple_iic:
; bypass the firmware interrupt handler
; should we do this on IIe too? probably faster
sei ; disable interrupts
lda $c08b ; disable ROM (enable language card)
lda $c08b
lda #<interrupt_handler
sta $fffe
lda #>interrupt_handler
sta $ffff
; sei ; disable interrupts
; lda $c08b ; disable ROM (enable language card)
; lda $c08b
; lda #<interrupt_handler
; sta $fffe
; lda #>interrupt_handler
; sta $ffff
lda #$EA ; nop out the "lda $45" in the irq hand
sta interrupt_smc
sta interrupt_smc+1
; lda #$EA ; nop out the "lda $45" in the irq hand
; sta interrupt_smc
; sta interrupt_smc+1
done_apple_detect:
@ -126,10 +126,10 @@ mockingboard_found:
; Vector address goes to 0x3fe/0x3ff
; FIXME: should chain any existing handler
lda #<interrupt_handler
sta $03fe
lda #>interrupt_handler
sta $03ff
; lda #<interrupt_handler
; sta $03fe
; lda #>interrupt_handler
; sta $03ff
;============================
; Enable 50Hz clock on 6522
@ -244,10 +244,11 @@ mockingboard_found:
; 310
; -3 for jmp
; -2 for cli
; 305
; 307
; Try X=14 Y=4 cycles=305
; Try X=14 Y=4 cycles=305R2
nop
ldy #4 ; 2
loopA: ldx #14 ; 2
@ -257,13 +258,6 @@ loopB: dex ; 2
bne loopA ; 2nt/3
;============================
; Enable 6502 interrupts
;============================
start_interrupts:
cli ; clear interrupt mask ; 2
jmp display_loop ; 3
@ -463,6 +457,13 @@ pad_time:
jsr draw_rasterbar ; 6+126
;============================
; Play music
;============================
jsr pt3_make_frame
jsr mb_write_frame
;============================
@ -580,8 +581,8 @@ yellow_x: .byte $20
green_x: .byte $30
blue_x: .byte $40
.include "interrupt_handler.s"
.include "pt3_lib.s"
;.include "interrupt_handler.s"
.include "pt3_lib_ci.s"
.include "mockingboard_a.s"
;=============