pt3: big mess finding bug in pt3_lib

was playing OOTW ending wrong

was an accidentally commented out "lda #0"  blurgh

some other code cleanups while at it, mostly making it match
the pt3_player code a bit more

also stop using TEMP from interrupt as other code might use it
This commit is contained in:
Vince Weaver 2019-08-21 15:07:20 -04:00
parent 9dc0562984
commit a0dc7d4150
11 changed files with 59 additions and 45 deletions

View File

@ -144,11 +144,11 @@ mb_detect_loop: ; self-modifying
mb_check_cycle_loop:
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
; count down
sta TEMP ; 3 cycles
sta PT3_TEMP ; 3 cycles
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
; between the two accesses to the timer
sec
sbc TEMP ; subtract to see if we had 8 cycles
sbc PT3_TEMP ; subtract to see if we had 8 cycles
cmp #$f8 ; -8
bne mb_not_in_this_slot
dex ; decrement, try one more time
@ -222,11 +222,11 @@ mb4_detect_loop: ; self-modifying
mb4_check_cycle_loop:
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
; count down
sta TEMP ; 3 cycles
sta PT3_TEMP ; 3 cycles
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
; between the two accesses to the timer
sec
sbc TEMP ; subtract to see if we had 8 cycles
sbc PT3_TEMP ; subtract to see if we had 8 cycles
cmp #$f8 ; -8
bne mb4_not_in_this_slot
dex ; decrement, try one more time

View File

@ -19,6 +19,9 @@
; + 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)
; TODO
; move some of these flags to be bits rather than bytes?
@ -86,16 +89,16 @@ NOTE_STRUCT_SIZE=40
begin_vars:
note_a:
.byte $0 ; NOTE_VOLUME ; 0
.byte $0 ; NOTE_TONE_SLIDING_L ; 1
.byte $0 ; NOTE_TONE_SLIDING_H ; 2
.byte $0 ; NOTE_ENABLED ; 3
.byte $0 ; NOTE_ENVELOPE_ENABLED ; 4
.byte $0 ; NOTE_SAMPLE_POINTER_L ; 5
.byte $0 ; NOTE_SAMPLE_POINTER_H ; 6
.byte $0 ; NOTE_SAMPLE_LOOP ; 7
.byte $0 ; NOTE_SAMPLE_LENGTH ; 8
note_a: ; reset?
.byte $0 ; NOTE_VOLUME ; 0 ; Y
.byte $0 ; NOTE_TONE_SLIDING_L ; 1 ; Y
.byte $0 ; NOTE_TONE_SLIDING_H ; 2 ; Y
.byte $0 ; NOTE_ENABLED ; 3 ; Y
.byte $0 ; NOTE_ENVELOPE_ENABLED ; 4 ; Y
.byte $0 ; NOTE_SAMPLE_POINTER_L ; 5 ; Y
.byte $0 ; NOTE_SAMPLE_POINTER_H ; 6 ; Y
.byte $0 ; NOTE_SAMPLE_LOOP ; 7 ; Y
.byte $0 ; NOTE_SAMPLE_LENGTH ; 8 ; Y
.byte $0 ; NOTE_TONE_L ; 9
.byte $0 ; NOTE_TONE_H ; 10
.byte $0 ; NOTE_AMPLITUDE ; 11
@ -104,16 +107,16 @@ note_a:
.byte $0 ; NOTE_LEN_COUNT ; 14
.byte $0 ; NOTE_ADDR_L ; 15
.byte $0 ; NOTE_ADDR_H ; 16
.byte $0 ; NOTE_ORNAMENT_POINTER_L ; 17
.byte $0 ; NOTE_ORNAMENT_POINTER_H ; 18
.byte $0 ; NOTE_ORNAMENT_LOOP ; 19
.byte $0 ; NOTE_ORNAMENT_LENGTH ; 20
.byte $0 ; NOTE_ORNAMENT_POINTER_L ; 17 ; Y
.byte $0 ; NOTE_ORNAMENT_POINTER_H ; 18 ; Y
.byte $0 ; NOTE_ORNAMENT_LOOP ; 19 ; Y
.byte $0 ; NOTE_ORNAMENT_LENGTH ; 20 ; Y
.byte $0 ; NOTE_ONOFF ; 21
.byte $0 ; NOTE_TONE_ACCUMULATOR_L ; 22
.byte $0 ; NOTE_TONE_ACCUMULATOR_H ; 23
.byte $0 ; NOTE_TONE_SLIDE_COUNT ; 24
.byte $0 ; NOTE_ORNAMENT_POSITION ; 25
.byte $0 ; NOTE_SAMPLE_POSITION ; 26
.byte $0 ; NOTE_ORNAMENT_POSITION ; 25 ; Y
.byte $0 ; NOTE_SAMPLE_POSITION ; 26 ; Y
.byte $0 ; NOTE_ENVELOPE_SLIDING ; 27
.byte $0 ; NOTE_NOISE_SLIDING ; 28
.byte $0 ; NOTE_AMPLITUDE_SLIDING ; 29
@ -221,17 +224,17 @@ current_line: .byte $0
current_pattern: .byte $0
pt3_pattern_done: .byte $0
pt3_noise_period: .byte $0
pt3_noise_add: .byte $0
pt3_noise_period: .byte $0 ; Y
pt3_noise_add: .byte $0 ; Y
pt3_envelope_period_l: .byte $0
pt3_envelope_period_h: .byte $0
pt3_envelope_period_l: .byte $0 ; Y
pt3_envelope_period_h: .byte $0 ; Y
pt3_envelope_slide_l: .byte $0
pt3_envelope_slide_h: .byte $0
pt3_envelope_slide_add_l:.byte $0
pt3_envelope_slide_add_h:.byte $0
pt3_envelope_add: .byte $0
pt3_envelope_type: .byte $0
pt3_envelope_type: .byte $0 ; Y
pt3_envelope_type_old: .byte $0
pt3_envelope_delay: .byte $0
pt3_envelope_delay_orig:.byte $0
@ -295,7 +298,7 @@ load_ornament0:
load_ornament:
sty TEMP ; save Y value ; 3
sty PT3_TEMP ; save Y value ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0xaa+(i*2)]<<8)|pt3->data[0xa9+(i*2)];
@ -340,7 +343,7 @@ load_ornament:
adc #$0 ; 2
sta note_a+NOTE_ORNAMENT_POINTER_H,X ; 5
ldy TEMP ; restore Y value ; 3
ldy PT3_TEMP ; restore Y value ; 3
rts ; 6
@ -369,7 +372,7 @@ load_sample1:
load_sample:
sty TEMP ; 3
sty PT3_TEMP ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0x6a+(i*2)]<<8)|pt3->data[0x69+(i*2)];
@ -412,7 +415,7 @@ load_sample:
adc #$0 ; 2
sta note_a+NOTE_SAMPLE_POINTER_H,X ; 5
ldy TEMP ; 3
ldy PT3_TEMP ; 3
rts ; 6
;============
@ -426,7 +429,8 @@ load_sample:
pt3_init_song:
lda #$0
sta DONE_SONG ; 3
sta DONE_SONG
; 3
ldx #(end_vars-begin_vars)
zero_song_structs_loop:
dex
@ -438,9 +442,9 @@ zero_song_structs_loop:
sta note_a+NOTE_VOLUME ; 4
sta note_b+NOTE_VOLUME ; 4
sta note_c+NOTE_VOLUME ; 4
.if 0
lda #$0 ; 2
sta DONE_SONG ; 3
sta note_a+NOTE_TONE_SLIDING_L ; 4
sta note_b+NOTE_TONE_SLIDING_L ; 4
sta note_c+NOTE_TONE_SLIDING_L ; 4
@ -453,6 +457,9 @@ zero_song_structs_loop:
sta note_a+NOTE_ENVELOPE_ENABLED ; 4
sta note_b+NOTE_ENVELOPE_ENABLED ; 4
sta note_c+NOTE_ENVELOPE_ENABLED ; 4
sta note_a+NOTE_SAMPLE_POSITION ; 4
sta note_b+NOTE_SAMPLE_POSITION ; 4
sta note_c+NOTE_SAMPLE_POSITION ; 4
sta pt3_noise_period ; 4
sta pt3_noise_add ; 4
@ -460,6 +467,7 @@ zero_song_structs_loop:
sta pt3_envelope_period_h ; 4
sta pt3_envelope_type ; 4
.endif
lda #0
; default ornament/sample in A
ldx #(NOTE_STRUCT_SIZE*0) ; 2
jsr load_ornament ; 6+93
@ -2205,7 +2213,7 @@ done_do_frame:
; FIXME: self modify code
GetNoteFreq:
sty TEMP ; 3
sty PT3_TEMP ; 3
tay ; 2
lda PT3_LOC+PT3_HEADER_FREQUENCY ; 4
@ -2217,7 +2225,7 @@ GetNoteFreq:
lda PT3NoteTable_ST_low,Y ; 4+
sta freq_l ; 4
ldy TEMP ; 3
ldy PT3_TEMP ; 3
rts ; 6
;===========
; 40
@ -2229,7 +2237,7 @@ freq_table_2:
lda PT3NoteTable_ASM_34_35_low,Y ; 4+
sta freq_l ; 4
ldy TEMP ; 3
ldy PT3_TEMP ; 3
rts ; 6
;===========
; 41

View File

@ -213,3 +213,4 @@ found_message: .asciiz "FOUND"
; to be made throughout the player code
song:
.incbin "../pt3_player/music/EA.PT3"
;.incbin "../ootw/ootw_audio/ootw_outro.pt3"

View File

@ -63,5 +63,4 @@ MB_ADDRL = $86
MB_ADDRH = $87
DONE_PLAYING = $88
DONE_SONG = $89
TEMP = $FA
PT3_TEMP = $8A

View File

@ -31,6 +31,7 @@ pt3_player.dsk: PT3_PLAYER HELLO
$(DOS33) -y pt3_player.dsk BSAVE -a 0x4000 ./music/CH.PT3
$(DOS33) -y pt3_player.dsk BSAVE -a 0x4000 ./music/BH.PT3
$(DOS33) -y pt3_player.dsk BSAVE -a 0x4000 ./music/ND.PT3
$(DOS33) -y pt3_player.dsk BSAVE -a 0x4000 ./music/OO.PT3
pt3_debug.dsk: PT3_DUMPER PT3_TIMER PT3_TABLE_TEST HELLO_DEBUG DUMP
@ -59,6 +60,7 @@ pt3_debug.dsk: PT3_DUMPER PT3_TIMER PT3_TABLE_TEST HELLO_DEBUG DUMP
$(DOS33) -y pt3_debug.dsk BSAVE -a 0x4000 ./music/CH.PT3
$(DOS33) -y pt3_debug.dsk BSAVE -a 0x4000 ./music/BH.PT3
$(DOS33) -y pt3_debug.dsk BSAVE -a 0x4000 ./music/ND.PT3
$(DOS33) -y pt3_debug.dsk BSAVE -a 0x4000 ./music/OO.PT3
HELLO: hello.bas
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO

BIN
pt3_player/music/OO.PT3 Normal file

Binary file not shown.

View File

@ -424,12 +424,14 @@ song_list:
; .asciiz "CR.PT3"
; .asciiz "EA.PT3"
.asciiz "RI.PT3"
; .asciiz "RI.PT3"
.asciiz "OO.PT3"
;=========
;routines
;=========
.include "qkumba_rts.s"
;.include "../pt3_lib/pt3_lib.s"
.include "pt3_lib.s"
;============

View File

@ -254,7 +254,7 @@ load_sample1:
load_sample:
sty TEMP ; 3
sty PT3_TEMP ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0x6a+(i*2)]<<8)|pt3->data[0x69+(i*2)];
@ -297,7 +297,7 @@ load_sample:
adc #$0 ; 2
sta note_a+NOTE_SAMPLE_POINTER_H,X ; 5
ldy TEMP ; 3
ldy PT3_TEMP ; 3
rts ; 6
;============
@ -326,7 +326,7 @@ load_sample:
load_ornament:
sty TEMP ; save Y value ; 3
sty PT3_TEMP ; save Y value ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0xaa+(i*2)]<<8)|pt3->data[0xa9+(i*2)];
@ -371,7 +371,7 @@ load_ornament:
adc #$0 ; 2
sta note_a+NOTE_ORNAMENT_POINTER_H,X ; 5
ldy TEMP ; restore Y value ; 3
ldy PT3_TEMP ; restore Y value ; 3
rts ; 6
@ -2195,7 +2195,7 @@ done_do_frame:
; FIXME: self modify code
GetNoteFreq:
sty TEMP ; 3
sty PT3_TEMP ; 3
tay ; 2
lda PT3_LOC+PT3_HEADER_FREQUENCY ; 4
@ -2207,7 +2207,7 @@ GetNoteFreq:
lda PT3NoteTable_ST_low,Y ; 4+
sta freq_l_smc+1 ; 4
ldy TEMP ; 3
ldy PT3_TEMP ; 3
rts ; 6
;===========
; 40
@ -2219,7 +2219,7 @@ freq_table_2:
lda PT3NoteTable_ASM_34_35_low,Y ; 4+
sta freq_l_smc+1 ; 4
ldy TEMP ; 3
ldy PT3_TEMP ; 3
rts ; 6
;===========
; 41

View File

@ -11,7 +11,7 @@
PT3_LOC = $4000
; Number of files. Should probably detect this automatically
NUM_FILES = 18
NUM_FILES = 19
;=============================

View File

@ -16,4 +16,5 @@
.asciiz "CH.PT3"
.asciiz "BH.PT3"
.asciiz "ND.PT3"
.asciiz "OO.PT3"

View File

@ -68,6 +68,7 @@ ORNAMENT_H = $03
SAMPLE_L = $04
SAMPLE_H = $05
PT3_TEMP = $62
WHICH_FILE = $63
LOOP = $64
MB_ADDRL = $65