pt3: sort of have ornament/sample loading going

This commit is contained in:
Vince Weaver 2019-05-12 00:14:09 -04:00
parent 2348e249d9
commit 479d2ccb29
3 changed files with 167 additions and 99 deletions

View File

@ -1,2 +1,5 @@
PT3_player PT3_player
ASR = CMP #$80 / ROR

View File

@ -197,6 +197,8 @@ PT3_ORNAMENT_LOC_L = $A9
PT3_OTNAMENT_LOC_H = $AA PT3_OTNAMENT_LOC_H = $AA
PT3_PATTERN_TABLE = $C9 PT3_PATTERN_TABLE = $C9
ysave: .byte $00
;=========================== ;===========================
; Load Ornament ; Load Ornament
;=========================== ;===========================
@ -204,42 +206,102 @@ PT3_PATTERN_TABLE = $C9
load_ornament: load_ornament:
sty ysave
; save as new ornament ; save as new ornament
; sta note_a+NOTE_ORNAMENT ; do we use this? ; sta note_a+NOTE_ORNAMENT ; do we use this?
;pt3->ornament_patterns[i]= ;pt3->ornament_patterns[i]=
; (pt3->data[0xaa+(i*2)]<<8)|pt3->data[0xa9+(i*2)]; ; (pt3->data[0xaa+(i*2)]<<8)|pt3->data[0xa9+(i*2)];
; 20A9+(a*2) -> ornament_pointer_l ; 20A9+(a*2) -> ornament_pointer_l
; 20AA+(a*2) -> ornament_pointer_h
; a->ornament_pointer=pt3->ornament_patterns[a->ornament];
; a->ornament_loop=pt3->data[a->ornament_pointer];
; a->ornament_pointer++;
; a->ornament_length=pt3->data[a->ornament_pointer];
; a->ornament_pointer++;
clc clc
lda note_a+NOTE_ORNAMENT_POINTER_L asl ; A*2
adc #2 adc #$a9
sta note_a+NOTE_ORNAMENT_POINTER_L tay
lda note_a+NOTE_ORNAMENT_POINTER_H
adc #0
sta note_a+NOTE_ORNAMENT_POINTER_H
lda PT3_LOC,Y
sta ORNAMENT_A_L
iny
lda PT3_LOC,Y
clc
adc #>PT3_LOC
sta ORNAMENT_A_H ; a->ornament_pointer=pt3->ornament_patterns[a->ornament];
ldy #0
lda (ORNAMENT_A_L),Y
sta note_a+NOTE_ORNAMENT_LOOP
; a->ornament_loop=pt3->data[a->ornament_pointer];
iny
lda (ORNAMENT_A_L),Y
sta note_a+NOTE_ORNAMENT_LENGTH
; a->ornament_length=pt3->data[a->ornament_pointer];
clc
lda ORNAMENT_A_L
adc #$2
sta ORNAMENT_A_L
; clc
; lda note_a+NOTE_ORNAMENT_POINTER_L
; adc #2
; sta note_a+NOTE_ORNAMENT_POINTER_L
; lda note_a+NOTE_ORNAMENT_POINTER_H
; adc #0
; sta note_a+NOTE_ORNAMENT_POINTER_H
ldy ysave
rts rts
;=========================== ;===========================
; Load Sample ; Load Sample
;=========================== ;===========================
; ; sample in A
load_sample: load_sample:
; a->sample_pointer=pt3->sample_patterns[a->sample];
; a->sample_loop=pt3->data[a->sample_pointer]; sty ysave
; a->sample_pointer++;
; a->sample_length=pt3->data[a->sample_pointer]; ;pt3->ornament_patterns[i]=
; a->sample_pointer++; ; (pt3->data[0x6a+(i*2)]<<8)|pt3->data[0x69+(i*2)];
clc
asl ; A*2
adc #$69
tay
lda PT3_LOC,Y
sta SAMPLE_A_L
iny
lda PT3_LOC,Y
clc
adc #>PT3_LOC
sta SAMPLE_A_H ; a->sample_pointer=pt3->sample_patterns[a->sample];
ldy #0
lda (SAMPLE_A_L),Y
sta note_a+NOTE_SAMPLE_LOOP ; a->sample_loop=pt3->data[a->sample_pointer];
iny
lda (SAMPLE_A_L),Y
sta note_a+NOTE_SAMPLE_LENGTH ; a->sample_length=pt3->data[a->sample_pointer];
clc
lda SAMPLE_A_L
adc #$2
sta SAMPLE_A_L
ldy ysave
rts rts
@ -265,17 +327,20 @@ pt3_init_song:
lda #0 lda #0
jsr load_ornament jsr load_ornament
lda #'A' lda #'A'
lda #1
jsr load_sample jsr load_sample
lda #'B' ; lda #'B'
lda #0 ; lda #0
jsr load_ornament ; jsr load_ornament
lda #'B' ; lda #'B'
jsr load_sample ; lda #1
lda #'C' ; jsr load_sample
lda #0 ; lda #'C'
jsr load_ornament ; lda #0
lda #'C' ; jsr load_ornament
jsr load_sample ; lda #'C'
; lda #1
; jsr load_sample
lda #$0 lda #$0
sta pt3_noise_period sta pt3_noise_period
@ -291,17 +356,44 @@ pt3_init_song:
; Calculate Note ; Calculate Note
;===================================== ;=====================================
calculate_note: calculate_note:
ldy #0
lda note_a+NOTE_ENABLED,Y lda note_a+NOTE_ENABLED
bne note_enabled bne note_enabled
lda #0 lda #0
sta note_a+NOTE_AMPLITUDE,Y sta note_a+NOTE_AMPLITUDE
jmp done_note jmp done_note
note_enabled: note_enabled:
lda note_a+NOTE_SAMPLE_POSITION
asl
asl
tay
lda (SAMPLE_A_L),Y
sta sample_b0
iny
lda (SAMPLE_A_L),Y
sta sample_b1
iny
lda (SAMPLE_A_L),Y
sta note_a+NOTE_TONE_L
iny
lda (SAMPLE_A_L),Y
sta note_a+NOTE_TONE_H
clc
lda note_a+NOTE_TONE_ACCUMULATOR_L
adc note_a+NOTE_TONE_L
sta note_a+NOTE_TONE_L
lda note_a+NOTE_TONE_H
adc note_a+NOTE_TONE_ACCUMULATOR_H
sta note_a+NOTE_TONE_H
; b0 = pt3->data[a->sample_pointer + a->sample_position * 4]; ; b0 = pt3->data[a->sample_pointer + a->sample_position * 4];
; b1 = pt3->data[a->sample_pointer + a->sample_position * 4 + 1]; ; b1 = pt3->data[a->sample_pointer + a->sample_position * 4 + 1];
; a->tone = pt3->data[a->sample_pointer + a->sample_position * 4 + 2]; ; a->tone = pt3->data[a->sample_pointer + a->sample_position * 4 + 2];
@ -381,7 +473,7 @@ done_amp_sliding:
; clamp amplitude to 0 - 15 ; clamp amplitude to 0 - 15
lda note_a+NOTE_AMPLITUDE,Y lda note_a+NOTE_AMPLITUDE
check_amp_lo: check_amp_lo:
bpl check_amp_hi bpl check_amp_hi
lda #0 lda #0
@ -392,7 +484,7 @@ check_amp_hi:
bcc done_clamp_amplitude ; blt bcc done_clamp_amplitude ; blt
lda #15 lda #15
write_clamp_amplitude: write_clamp_amplitude:
sta note_a+NOTE_AMPLITUDE,Y sta note_a+NOTE_AMPLITUDE
done_clamp_amplitude: done_clamp_amplitude:
; if (PlParams.PT3.PT3_Version <= 4) ; if (PlParams.PT3.PT3_Version <= 4)
@ -400,15 +492,15 @@ done_clamp_amplitude:
; } ; }
; else { ; else {
lda note_a+NOTE_VOLUME,Y lda note_a+NOTE_VOLUME
asl asl
asl asl
asl asl
asl asl
ora note_a+NOTE_AMPLITUDE,Y ora note_a+NOTE_AMPLITUDE
tax tax
lda PT3VolumeTable_35,X lda PT3VolumeTable_35,X
sta note_a+NOTE_AMPLITUDE,Y ; a->amplitude = PT3VolumeTable_35[a->volume][a->amplitude]; sta note_a+NOTE_AMPLITUDE ; a->amplitude = PT3VolumeTable_35[a->volume][a->amplitude];
; } ; }
lda sample_b0 ; if (((b0 & 0x1) == 0) && ( a->envelope_enabled)) { lda sample_b0 ; if (((b0 & 0x1) == 0) && ( a->envelope_enabled)) {
@ -722,7 +814,7 @@ decode_case_bX:
;============================================ ;============================================
; $BX -- note length or envelope manipulation ; $BX -- note length or envelope manipulation
;============================================ ;============================================
cmp #$b0 cmp #$b0 ; FIXME: this cmp not needed, from before?
bne decode_case_cX bne decode_case_cX
txa txa
@ -1020,10 +1112,10 @@ pt3_decode_line:
jsr decode_note jsr decode_note
; decode_note(&pt3->b,&(pt3->b_addr),pt3); ; decode_note(&pt3->b,&(pt3->b_addr),pt3);
jsr decode_note ; jsr decode_note
; decode_note(&pt3->c,&(pt3->c_addr),pt3); ; decode_note(&pt3->c,&(pt3->c_addr),pt3);
jsr decode_note ; jsr decode_note
; if (pt3->a.all_done && pt3->b.all_done && pt3->c.all_done) { ; if (pt3->a.all_done && pt3->b.all_done && pt3->c.all_done) {
; return 1; ; return 1;
@ -1179,10 +1271,10 @@ do_frame:
lda #0 ; Note A lda #0 ; Note A
jsr calculate_note jsr calculate_note
lda #1 ; Note B ; lda #1 ; Note B
jsr calculate_note ; jsr calculate_note
lda #2 ; Note C ; lda #2 ; Note C
jsr calculate_note ; jsr calculate_note
; Load up the Frequency Registers ; Load up the Frequency Registers

View File

@ -84,63 +84,36 @@ ENVELOPE_COARSE EQU $7C
ENVELOPE_SHAPE EQU $7D ENVELOPE_SHAPE EQU $7D
COPY_OFFSET EQU $7E COPY_OFFSET EQU $7E
DECODER_STATE EQU $7F DECODER_STATE EQU $7F
;SPACEY_I EQU $70
;SPACEY_F EQU $71
;CY_I EQU $72
;CY_F EQU $73
;TEMP_I EQU $74
;TEMP_F EQU $75
;DISTANCE_I EQU $76
;DISTANCE_F EQU $77
;SPACEZ_I EQU $78
;SPACEZ_F EQU $79
;DRAW_SPLASH EQU $7A
;SPEED EQU $7B
;SPLASH_COUNT EQU $7C
;OVER_LAND EQU $7D
;NUM1L EQU $7E
;NUM1H EQU $7F
PATTERN_L EQU $80 PATTERN_L EQU $80
PATTERN_H EQU $81 PATTERN_H EQU $81
DECODE_ERROR EQU $82 ORNAMENT_A_L EQU $82
ORNAMENT_A_H EQU $83
SAMPLE_A_L EQU $84
SAMPLE_A_H EQU $85
A_COLOR EQU $83
B_COLOR EQU $84
C_COLOR EQU $85
COPY_TIME EQU $86 DECODE_ERROR EQU $90
DECOMPRESS_TIME EQU $87 A_COLOR EQU $91
TIME_TAKEN EQU $88 B_COLOR EQU $92
SCREEN_Y EQU $89 C_COLOR EQU $93
WHICH_FILE EQU $8A COPY_TIME EQU $94
;NUM2L EQU $80 DECOMPRESS_TIME EQU $95
;NUM2H EQU $81 TIME_TAKEN EQU $96
;RESULT EQU $82 ; 83,84,85 SCREEN_Y EQU $97
;NEGATE EQU $86 ; UNUSED? WHICH_FILE EQU $98
;LAST_SPACEX_I EQU $87 COLOR_MASK EQU $99
;LAST_SPACEY_I EQU $88 RASTERBARS_ON EQU $9A
;LAST_MAP_COLOR EQU $89 RANDOM_POINTER EQU $9B
;DRAW_SKY EQU $8A FRAME_COUNT EQU $9C
COLOR_MASK EQU $8B MB_VALUE EQU $9D
RASTERBARS_ON EQU $8C ;MB_CHUNK EQU $9E
;KEY_COUNT EQU $8C MB_ADDRL EQU $9F
;KEY_OFFSET EQU $8D MB_ADDRH EQU $A0
;DRAW_BLUE_SKY EQU $8E DONE_PLAYING EQU $A1
RANDOM_POINTER EQU $8F MB_CHUNK_OFFSET EQU $A2
FRAME_COUNT EQU $90
MB_VALUE EQU $91
;MB_CHUNK EQU $92
MB_ADDRL EQU $91
MB_ADDRH EQU $92
DONE_PLAYING EQU $93
;MB_FRAME_DIFF EQU $94
MB_CHUNK_OFFSET EQU $94
;LZSS_RL EQU $95
;LZSS_RH EQU $96
;LZSS_COUNT EQU $97
;LZSS_MASK EQU $98
;LZSS_ENDL EQU $99
;LZSS_ENDH EQU $9A
;MB_FRAME_DIFF2 EQU $9F
; More zero-page addresses ; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related ; we try not to conflict with anything DOS, MONITOR or BASIC related