pt3: more comments and cycle counting

This commit is contained in:
Vince Weaver 2019-05-20 10:11:29 -04:00
parent f775b116da
commit 5b2ad332e4

View File

@ -220,7 +220,7 @@ convert_177: .byte $1
; Header offsets ; Header offsets
PT3_VERSION = $D PT3_VERSION = $0D
PT3_HEADER_FREQUENCY = $63 PT3_HEADER_FREQUENCY = $63
PT3_SPEED = $64 PT3_SPEED = $64
PT3_LOOP = $66 PT3_LOOP = $66
@ -236,6 +236,14 @@ ysave: .byte $00
freq_l: .byte $00 freq_l: .byte $00
freq_h: .byte $00 freq_h: .byte $00
e_slide_amount: .byte $0
prev_note: .byte $0
prev_sliding_l: .byte $0
prev_sliding_h: .byte $0
decode_done: .byte $0
current_val: .byte $0
;=========================== ;===========================
; Load Ornament ; Load Ornament
;=========================== ;===========================
@ -338,7 +346,7 @@ load_sample:
clc ; 2 clc ; 2
asl ; A*2 ; 2 asl ; A*2 ; 2
adc #PT3_SAMPLE_LOC_L ; 2 adc #PT3_SAMPLE_LOC_L ; 2
tay ; 2 tay ; 2
; Set the initial sample pointer ; Set the initial sample pointer
@ -476,7 +484,7 @@ not_ascii_number:
e_slide_amount: .byte $0
;===================================== ;=====================================
@ -966,11 +974,7 @@ done_onoff:
rts rts
prev_note: .byte $0
prev_sliding_l: .byte $0
prev_sliding_h: .byte $0
decode_done: .byte $0
current_val: .byte $0
;===================================== ;=====================================
; Decode Note ; Decode Note
@ -1652,89 +1656,99 @@ current_pattern: .byte $0
;===================================== ;=====================================
; Set Pattern ; Set Pattern
;===================================== ;=====================================
; FIXME: inline this? we do call it from outside
; in the player note length code
pt3_set_pattern: pt3_set_pattern:
ldy current_pattern ; Lookup current pattern in pattern table
lda PT3_LOC+PT3_PATTERN_TABLE,Y ; get pattern table value ldy current_pattern ; 4
lda PT3_LOC+PT3_PATTERN_TABLE,Y ; 4+
cmp #$ff ; if value is $FF we are at the end of the song
bne not_done cmp #$ff ; 2
bne not_done ; 2/3
sta DONE_SONG ; done with song, set it to non-zero
rts sta DONE_SONG ; 3
rts ; 6
;============
; 21 if end
not_done: not_done:
asl ; mul by two, as word sized ; set up the three pattern address pointers
tay
clc asl ; mul pattern offset by two, as word sized ; 2
tay ; 2
lda PT3_LOC+PT3_PATTERN_LOC_L ; point PATTERN_H/PATTERN_L to the pattern address table
sta PATTERN_L
lda PT3_LOC+PT3_PATTERN_LOC_H
adc #>PT3_LOC ; assume page boundary
sta PATTERN_H
lda (PATTERN_L),Y clc ; 2
sta note_a+NOTE_ADDR_L lda PT3_LOC+PT3_PATTERN_LOC_L ; 4
iny sta PATTERN_L ; 3
lda PT3_LOC+PT3_PATTERN_LOC_H ; 4
adc #>PT3_LOC ; assume page boundary ; 2
sta PATTERN_H ; 3
clc ; First 16-bits points to the Channel A address
lda (PATTERN_L),Y lda (PATTERN_L),Y ; 5+
adc #>PT3_LOC ; assume page boundary sta note_a+NOTE_ADDR_L ; 4
sta note_a+NOTE_ADDR_H iny ; 2
iny clc ; needed? ; 2
lda (PATTERN_L),Y ; 5+
adc #>PT3_LOC ; assume page boundary ; 2
sta note_a+NOTE_ADDR_H ; 4
iny ; 2
lda (PATTERN_L),Y ; Next 16-bits points to the Channel B address
sta note_b+NOTE_ADDR_L lda (PATTERN_L),Y ; 5+
iny sta note_b+NOTE_ADDR_L ; 4
iny ; 2
lda (PATTERN_L),Y ; 5+
adc #>PT3_LOC ; assume page boundary ; 2
sta note_b+NOTE_ADDR_H ; 4
iny ; 2
lda (PATTERN_L),Y ; Next 16-bits points to the Channel C address
adc #>PT3_LOC ; assume page boundary lda (PATTERN_L),Y ; 5+
sta note_b+NOTE_ADDR_H sta note_c+NOTE_ADDR_L ; 4
iny iny ; 2
lda (PATTERN_L),Y ; 5+
adc #>PT3_LOC ; assume page boundary ; 2
sta note_c+NOTE_ADDR_H ; 4
lda (PATTERN_L),Y ; clear out the noise channel
sta note_c+NOTE_ADDR_L lda #0 ; 2
iny sta pt3_noise_period ; 4
lda (PATTERN_L),Y ; Set all three channels as active
adc #>PT3_LOC ; assume page boundary ; FIXME: num_channels, may need to be 6 if doing 6-channel pt3?
sta note_c+NOTE_ADDR_H lda #3 ; 2
sta pt3_pattern_done ; 4
lda #0 rts ; 6
sta pt3_noise_period
lda #3 ; FIXME: num_channels
sta pt3_pattern_done
rts
;===================================== ;=====================================
; pt3 make frame ; pt3 make frame
;===================================== ;=====================================
pt3_make_frame: ; update pattern or line if necessary
; for(i=0;i < pt3.music_len;i++) { ; then calculate the values for the next frame
; pt3_set_pattern(i,&pt3);
; for(j=0;j<64;j++) {
; if (pt3_decode_line(&pt3)) break;
pt3_make_frame:
; see if we need a new pattern ; see if we need a new pattern
; we do if line==0 and subframe==0 ; we do if line==0 and subframe==0
lda current_line lda current_line ; 4
bne pattern_good bne pattern_good ; 2/3
lda current_subframe lda current_subframe ; 4
bne pattern_good bne pattern_good ; 2/3
; load a new pattern in ; load a new pattern in
jsr pt3_set_pattern jsr pt3_set_pattern ;6+?
lda DONE_SONG lda DONE_SONG
beq pattern_good beq pattern_good