mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-12-27 02:31:00 +00:00
pt3: create combined version for pt3_lib and pt3_player
keeping separate versions was a pain
This commit is contained in:
parent
4583337bd0
commit
283279506e
@ -21,7 +21,9 @@ HELLO: hello.bas
|
||||
PT3_TEST: pt3_test.o
|
||||
ld65 -o PT3_TEST pt3_test.o -C ../linker_scripts/apple2_1000.inc
|
||||
|
||||
pt3_test.o: pt3_test.s pt3_lib.s interrupt_handler.s zp.inc
|
||||
pt3_test.o: pt3_test.s \
|
||||
pt3_lib_init.s pt3_lib_core.s interrupt_handler.s \
|
||||
zp.inc
|
||||
ca65 -o pt3_test.o pt3_test.s -l pt3_test.lst
|
||||
#
|
||||
|
||||
|
5
pt3_lib/gr_offsets.s
Normal file
5
pt3_lib/gr_offsets.s
Normal file
@ -0,0 +1,5 @@
|
||||
gr_offsets:
|
||||
.word $400,$480,$500,$580,$600,$680,$700,$780
|
||||
.word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8
|
||||
.word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0
|
||||
|
@ -30,104 +30,8 @@ interrupt_handler:
|
||||
|
||||
; inc $0404 ; debug (flashes char onscreen)
|
||||
|
||||
bit $C404 ; clear 6522 interrupt by reading T1C-L ; 4
|
||||
|
||||
lda DONE_PLAYING ; 3
|
||||
beq pt3_play_music ; if song done, don't play music ; 3/2nt
|
||||
jmp exit_interrupt ; 3
|
||||
;============
|
||||
; 13
|
||||
|
||||
pt3_play_music:
|
||||
|
||||
; decode a frame of music
|
||||
|
||||
jsr pt3_make_frame
|
||||
|
||||
; handle song over condition
|
||||
lda DONE_SONG
|
||||
beq mb_write_frame ; if not done, continue
|
||||
|
||||
lda LOOP ; see if looping
|
||||
beq move_to_next
|
||||
|
||||
pt3_loop_smc:
|
||||
lda #0 ; looping, move to loop location
|
||||
sta current_pattern
|
||||
lda #$0
|
||||
sta current_line
|
||||
sta current_subframe
|
||||
sta DONE_SONG ; undo the next song
|
||||
|
||||
beq done_interrupt ; branch always
|
||||
|
||||
move_to_next:
|
||||
; same as "press right"
|
||||
ldx #$20
|
||||
jmp quiet_exit
|
||||
|
||||
;======================================
|
||||
; Write frames to Mockingboard
|
||||
;======================================
|
||||
; for speed could merge this into
|
||||
; the decode code
|
||||
|
||||
mb_write_frame:
|
||||
|
||||
|
||||
tax ; 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
|
||||
lda #MOCK_AY_LATCH_ADDR ; latch_address for PB1 ; 2
|
||||
sta MOCK_6522_ORB1 ; latch_address on PB1 ; 4
|
||||
sta 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
|
||||
lda AY_REGISTERS,X ; load register value ; 4
|
||||
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
|
||||
;===========
|
||||
; 60
|
||||
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:
|
||||
|
||||
.include "pt3_lib_irq_handler.s"
|
||||
|
||||
jmp exit_interrupt
|
||||
|
||||
@ -135,16 +39,14 @@ mb_skip_13:
|
||||
; Finally done with this interrupt
|
||||
;=================================
|
||||
|
||||
done_interrupt:
|
||||
|
||||
quiet_exit:
|
||||
stx DONE_PLAYING
|
||||
jsr clear_ay_both
|
||||
|
||||
;ldx #$ff ; also mute the channel
|
||||
stx AY_REGISTERS+7 ; just in case
|
||||
ldx #$ff ; also mute the channel
|
||||
stx AY_REGISTERS+7 ; just in case
|
||||
|
||||
|
||||
done_key:
|
||||
exit_interrupt:
|
||||
|
||||
pla
|
||||
@ -164,4 +66,3 @@ interrupt_smc:
|
||||
; typical
|
||||
; ???? cycles
|
||||
|
||||
|
||||
|
@ -91,6 +91,7 @@ NOTE_TONE_SLIDE_TO_STEP =39
|
||||
|
||||
NOTE_STRUCT_SIZE=40
|
||||
|
||||
.ifdef USE_ZERO_PAGE
|
||||
note_a = $80
|
||||
note_b = $80+(NOTE_STRUCT_SIZE*1)
|
||||
note_c = $80+(NOTE_STRUCT_SIZE*2)
|
||||
@ -98,7 +99,8 @@ note_c = $80+(NOTE_STRUCT_SIZE*2)
|
||||
begin_vars=$80
|
||||
end_vars=$80+(NOTE_STRUCT_SIZE*3)
|
||||
|
||||
.if 0
|
||||
|
||||
.else ; !USE_ZERO_PAGE
|
||||
begin_vars:
|
||||
|
||||
note_a: ; reset?
|
||||
@ -383,438 +385,6 @@ load_ornament:
|
||||
|
||||
|
||||
|
||||
;====================================
|
||||
; pt3_init_song
|
||||
;====================================
|
||||
;
|
||||
pt3_init_song:
|
||||
|
||||
lda #$0
|
||||
sta DONE_SONG ; 3
|
||||
ldx #(end_vars-begin_vars)
|
||||
zero_song_structs_loop:
|
||||
dex
|
||||
sta note_a,X
|
||||
bne zero_song_structs_loop
|
||||
|
||||
sta pt3_noise_period_smc+1 ; 4
|
||||
sta pt3_noise_add_smc+1 ; 4
|
||||
|
||||
sta pt3_envelope_period_l_smc+1 ; 4
|
||||
sta pt3_envelope_period_h_smc+1 ; 4
|
||||
sta pt3_envelope_slide_l_smc+1 ; 4
|
||||
sta pt3_envelope_slide_h_smc+1 ; 4
|
||||
sta pt3_envelope_slide_add_l_smc+1 ; 4
|
||||
sta pt3_envelope_slide_add_h_smc+1 ; 4
|
||||
sta pt3_envelope_add_smc+1 ; 4
|
||||
sta pt3_envelope_type_smc+1 ; 4
|
||||
sta pt3_envelope_type_old_smc+1 ; 4
|
||||
sta pt3_envelope_delay_smc+1 ; 4
|
||||
sta pt3_envelope_delay_orig_smc+1 ; 4
|
||||
|
||||
sta PT3_MIXER_VAL ; 3
|
||||
|
||||
sta current_pattern_smc+1 ; 4
|
||||
sta current_line_smc+1 ; 4
|
||||
sta current_subframe_smc+1 ; 4
|
||||
|
||||
lda #$f ; 2
|
||||
sta note_a+NOTE_VOLUME ; 4
|
||||
sta note_b+NOTE_VOLUME ; 4
|
||||
sta note_c+NOTE_VOLUME ; 4
|
||||
|
||||
; default ornament/sample in A
|
||||
; X is zero coming in here
|
||||
;ldx #(NOTE_STRUCT_SIZE*0) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
; default ornament/sample in B
|
||||
ldx #(NOTE_STRUCT_SIZE*1) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
; default ornament/sample in C
|
||||
ldx #(NOTE_STRUCT_SIZE*2) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
;=======================
|
||||
; load default speed
|
||||
|
||||
lda PT3_LOC+PT3_SPEED ; 4
|
||||
sta pt3_speed_smc+1 ; 4
|
||||
|
||||
;=======================
|
||||
; load loop
|
||||
|
||||
lda PT3_LOC+PT3_LOOP ; 4
|
||||
sta pt3_loop_smc+1 ; 4
|
||||
|
||||
|
||||
;========================
|
||||
;========================
|
||||
; set up note/freq table
|
||||
; this saves some space and makes things marginally faster longrun
|
||||
;========================
|
||||
;========================
|
||||
; note (heh) that there are separate tables if version 3.3
|
||||
; but we are going to assume we are only going to be playing
|
||||
; newer 3.4+ version files so only need the newer tables
|
||||
|
||||
ldx PT3_LOC+PT3_HEADER_FREQUENCY ; 4
|
||||
beq use_freq_table_0
|
||||
dex
|
||||
beq use_freq_table_1
|
||||
dex
|
||||
beq use_freq_table_2
|
||||
; fallthrough (freq table 3)
|
||||
|
||||
use_freq_table_3:
|
||||
;=================================================
|
||||
; Create Table #3, v4+, "PT3NoteTable_REAL_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11 ; !2
|
||||
freq_table_3_copy_loop:
|
||||
; note, high lookup almost same as 2v4, just need to adjust one value
|
||||
|
||||
lda base2_v4_high,Y ; !3
|
||||
sta NoteTable_high,Y ; !3
|
||||
lda base3_low,Y ; !3
|
||||
sta NoteTable_low,Y ; !3
|
||||
dey ; !1
|
||||
bpl freq_table_3_copy_loop ; !2
|
||||
|
||||
dec NoteTable_high ; adjust to right value
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table3_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table3_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
|
||||
|
||||
use_freq_table_2:
|
||||
;=================================================
|
||||
; Create Table #2, v4+, "PT3NoteTable_ASM_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_2_copy_loop:
|
||||
lda base2_v4_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base2_v4_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_2_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table2_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table2_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
use_freq_table_1:
|
||||
;=================================================
|
||||
; Create Table #1, "PT3NoteTable_ST"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_1_copy_loop:
|
||||
lda base1_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base1_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_1_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
; last adjustments
|
||||
lda #$FD ; Tone[23]=$3FD
|
||||
sta NoteTable_low+23
|
||||
dec NoteTable_low+46 ; Tone[46]-=1;
|
||||
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
|
||||
use_freq_table_0:
|
||||
;=================================================
|
||||
; Create Table #0, "PT3NoteTable_PT_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_0_copy_loop:
|
||||
lda base0_v4_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base0_v4_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_0_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table0_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table0_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
|
||||
done_set_freq_table:
|
||||
|
||||
|
||||
;======================
|
||||
; calculate version
|
||||
ldx #6 ; 2
|
||||
lda PT3_LOC+PT3_VERSION ; 4
|
||||
sec ; 2
|
||||
sbc #'0' ; 2
|
||||
cmp #9 ; 2
|
||||
bcs not_ascii_number ; bge ; 2/3
|
||||
tax ; 2
|
||||
|
||||
not_ascii_number:
|
||||
|
||||
; adjust version<6 SMC code in the slide code
|
||||
|
||||
; FIXME: I am sure there's a more clever way to do this
|
||||
|
||||
lda #$2C ; BIT ; 2
|
||||
cpx #$6 ; 2
|
||||
bcs version_greater_than_or_equal_6 ; bgt ; 3
|
||||
; less than 6, jump
|
||||
; also carry is known to be clear
|
||||
adc #$20 ; BIT->JMP 2C->4C ; 2
|
||||
version_greater_than_or_equal_6:
|
||||
sta version_smc ; 4
|
||||
|
||||
pick_volume_table:
|
||||
|
||||
;=======================
|
||||
; Pick which volume number, based on version
|
||||
|
||||
; if (PlParams.PT3.PT3_Version <= 4)
|
||||
|
||||
cpx #5 ; 2
|
||||
|
||||
; carry clear = 3.3/3.4 table
|
||||
; carry set = 3.5 table
|
||||
|
||||
;==========================
|
||||
; VolTableCreator
|
||||
;==========================
|
||||
; Creates the appropriate volume table
|
||||
; based on z80 code by Ivan Roshin ZXAYHOBETA/VTII10bG.asm
|
||||
;
|
||||
|
||||
; Called with carry==0 for 3.3/3.4 table
|
||||
; Called with carry==1 for 3.5 table
|
||||
|
||||
; 177f-1932 = 435 bytes, not that much better than 512 of lookup
|
||||
|
||||
|
||||
VolTableCreator:
|
||||
|
||||
; Init initial variables
|
||||
lda #$0
|
||||
sta z80_d_smc+1
|
||||
ldy #$11
|
||||
|
||||
; Set up self modify
|
||||
|
||||
ldx #$2A ; ROL for self-modify
|
||||
bcs vol_type_35
|
||||
|
||||
vol_type_33:
|
||||
|
||||
; For older table, we set initial conditions a bit
|
||||
; different
|
||||
|
||||
dey
|
||||
tya
|
||||
|
||||
ldx #$ea ; NOP for self modify
|
||||
|
||||
vol_type_35:
|
||||
sty z80_l_smc+1 ; l=16 or 17
|
||||
sta z80_e_smc+1 ; e=16 or 0
|
||||
stx vol_smc ; set the self-modify code
|
||||
|
||||
ldy #16 ; skip first row, all zeros
|
||||
ldx #16 ; c=16
|
||||
vol_outer:
|
||||
clc ; add HL,DE
|
||||
z80_l_smc:
|
||||
lda #$d1
|
||||
z80_e_smc:
|
||||
adc #$d1
|
||||
sta z80_e_smc+1
|
||||
lda #0
|
||||
z80_d_smc:
|
||||
adc #$d1
|
||||
sta z80_d_smc+1 ; carry is important
|
||||
|
||||
; sbc hl,hl
|
||||
lda #0
|
||||
adc #$ff
|
||||
eor #$ff
|
||||
|
||||
vol_write:
|
||||
sta z80_h_smc+1
|
||||
pha
|
||||
|
||||
vol_inner:
|
||||
pla
|
||||
pha
|
||||
|
||||
vol_smc:
|
||||
nop ; nop or ROL depending
|
||||
|
||||
z80_h_smc:
|
||||
lda #$d1
|
||||
|
||||
adc #$0 ; a=a+carry;
|
||||
|
||||
sta VolumeTable,Y
|
||||
iny
|
||||
|
||||
pla ; add HL,DE
|
||||
adc z80_e_smc+1
|
||||
pha
|
||||
lda z80_h_smc+1
|
||||
adc z80_d_smc+1
|
||||
sta z80_h_smc+1
|
||||
|
||||
inx ; inc C
|
||||
txa ; a=c
|
||||
and #$f
|
||||
bne vol_inner
|
||||
|
||||
|
||||
pla
|
||||
|
||||
lda z80_e_smc+1 ; a=e
|
||||
cmp #$77
|
||||
bne vol_m3
|
||||
|
||||
inc z80_e_smc+1
|
||||
|
||||
vol_m3:
|
||||
txa ; a=c
|
||||
bne vol_outer
|
||||
|
||||
vol_done:
|
||||
rts
|
||||
|
||||
|
||||
;=========================================
|
||||
; copy note table seed to proper location
|
||||
;=========================================
|
||||
|
||||
; faster inlined
|
||||
|
||||
;NoteTableCopy:
|
||||
|
||||
; ldy #11 ; !2
|
||||
;note_table_copy_loop:
|
||||
;ntc_smc1:
|
||||
; lda base1_high,Y ; !3
|
||||
; sta NoteTable_high,Y ; !3
|
||||
;ntc_smc2:
|
||||
; lda base1_low,Y ; !3
|
||||
; sta NoteTable_low,Y ; !3
|
||||
; dey ; !1
|
||||
; bpl note_table_copy_loop ; !2
|
||||
; rts ; !1
|
||||
|
||||
|
||||
;==========================================
|
||||
; propogate the freq down, dividing by two
|
||||
;==========================================
|
||||
NoteTablePropogate:
|
||||
|
||||
ldy #0
|
||||
note_table_propogate_loop:
|
||||
clc
|
||||
lda NoteTable_high,Y
|
||||
ror
|
||||
sta NoteTable_high+12,Y
|
||||
|
||||
lda NoteTable_low,Y
|
||||
ror
|
||||
sta NoteTable_low+12,Y
|
||||
|
||||
iny
|
||||
cpy #84
|
||||
bne note_table_propogate_loop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;================================================
|
||||
; propogation isn't enough, various values
|
||||
; are ofte off by one, so adjust using a bitmask
|
||||
;================================================
|
||||
NoteTableAdjust:
|
||||
|
||||
ldx #0
|
||||
note_table_adjust_outer:
|
||||
|
||||
note_table_adjust_smc:
|
||||
lda table0_v4_adjust,X
|
||||
sta TEMP
|
||||
|
||||
; reset smc
|
||||
lda #<NoteTable_low
|
||||
sta ntl_smc+1
|
||||
lda #>NoteTable_low
|
||||
sta ntl_smc+2
|
||||
|
||||
|
||||
ldy #7
|
||||
note_table_adjust_inner:
|
||||
ror TEMP
|
||||
bcc note_table_skip_adjust
|
||||
|
||||
ntl_smc:
|
||||
inc NoteTable_low,X
|
||||
|
||||
note_table_skip_adjust:
|
||||
clc
|
||||
lda #12
|
||||
adc ntl_smc+1
|
||||
sta ntl_smc+1
|
||||
lda #0
|
||||
adc ntl_smc+2 ; unnecessary if aligned
|
||||
sta ntl_smc+2
|
||||
|
||||
skip_adjust_done:
|
||||
dey
|
||||
bpl note_table_adjust_inner
|
||||
|
||||
inx
|
||||
cpx #12
|
||||
bne note_table_adjust_outer
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;=====================================
|
||||
; Calculate Note
|
||||
;=====================================
|
||||
@ -1259,7 +829,12 @@ do_onoff:
|
||||
do_offon:
|
||||
ldy note_a+NOTE_OFFON_DELAY,X ; else a->onoff=a->offon_delay;
|
||||
put_offon:
|
||||
.ifdef USE_ZERO_PAGE
|
||||
sty note_a+NOTE_ONOFF,X
|
||||
.else
|
||||
lda note_a+NOTE_ONOFF,X
|
||||
tay
|
||||
.endif
|
||||
|
||||
done_onoff:
|
||||
|
||||
@ -1701,7 +1276,7 @@ skip_step_inc1:
|
||||
; a->tone_delta=GetNoteFreq(a->note,pt3)-
|
||||
; GetNoteFreq(prev_note,pt3);
|
||||
|
||||
sty TEMP ; save Y
|
||||
sty PT3_TEMP ; save Y
|
||||
prev_note_smc:
|
||||
ldy #$d1
|
||||
lda NoteTable_low,Y ; GetNoteFreq
|
||||
@ -1725,7 +1300,7 @@ temp_word_h2_smc:
|
||||
lda note_a+NOTE_NOTE,X
|
||||
sta note_a+NOTE_SLIDE_TO_NOTE,X
|
||||
|
||||
ldy TEMP ; restore Y
|
||||
ldy PT3_TEMP ; restore Y
|
||||
|
||||
; a->note=prev_note;
|
||||
lda prev_note_smc+1
|
||||
@ -2403,51 +1978,8 @@ done_do_frame:
|
||||
rts ; 6
|
||||
|
||||
|
||||
|
||||
;base0_v3_high:
|
||||
;.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||
;base0_v3_low:
|
||||
;.byte $21,$73,$CE,$33,$A0,$16,$93,$18,$A4,$36,$CE,$6D
|
||||
|
||||
; note: same as base0_v3_high
|
||||
base0_v4_high:
|
||||
.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||
base0_v4_low:
|
||||
.byte $22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF,$6D
|
||||
|
||||
base1_high:
|
||||
.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07
|
||||
base1_low:
|
||||
.byte $F8,$10,$60,$80,$D8,$28,$88,$F0,$60,$E0,$58,$E0
|
||||
|
||||
;base2_v3_high:
|
||||
;.byte $0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07,$07,$07
|
||||
;base2_v3_low:
|
||||
;.byte $3E,$80,$CC,$22,$82,$EC,$5C,$D6,$58,$E0,$6E,$04
|
||||
|
||||
; note almost same as above
|
||||
base2_v4_high:
|
||||
.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||
base2_v4_low:
|
||||
.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8,$3B,$C5,$55,$EC
|
||||
|
||||
; note almost same as above
|
||||
;base3_high:
|
||||
;.byte $0C,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||
base3_low:
|
||||
.byte $DA,$22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF
|
||||
|
||||
|
||||
; Adjustment factors
|
||||
table0_v4_adjust:
|
||||
.byte $40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c,$5a
|
||||
|
||||
table2_v4_adjust:
|
||||
.byte $20,$a8,$40,$f8,$bc,$90,$78,$70,$74,$08,$2a,$50
|
||||
|
||||
table3_v4_adjust:
|
||||
.byte $B4,$40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c
|
||||
|
||||
; note, you might have slightly better performance if these are aligned
|
||||
; so that loads don't have to cross page boundaries
|
||||
|
||||
NoteTable_high:
|
||||
.res 96,0
|
||||
@ -2459,101 +1991,3 @@ VolumeTable:
|
||||
|
||||
|
||||
pt3_lib_end:
|
||||
|
||||
|
||||
|
||||
; Table #1 of Pro Tracker 3.3x - 3.5x
|
||||
;PT3NoteTable_ST_high:
|
||||
;.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09
|
||||
;.byte $09,$08,$08,$07,$07,$07,$06,$06
|
||||
;.byte $05,$05,$05,$04,$04,$04,$04,$03
|
||||
;.byte $03,$03,$03,$03,$02,$02,$02,$02
|
||||
;.byte $02,$02,$02,$01,$01,$01,$01,$01
|
||||
;.byte $01,$01,$01,$01,$01,$01,$01,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
;PT3NoteTable_ST_low:
|
||||
;.byte $F8,$10,$60,$80,$D8,$28,$88,$F0
|
||||
;.byte $60,$E0,$58,$E0,$7C,$08,$B0,$40
|
||||
;.byte $EC,$94,$44,$F8,$B0,$70,$2C,$FD
|
||||
;.byte $BE,$84,$58,$20,$F6,$CA,$A2,$7C
|
||||
;.byte $58,$38,$16,$F8,$DF,$C2,$AC,$90
|
||||
;.byte $7B,$65,$51,$3E,$2C,$1C,$0A,$FC
|
||||
;.byte $EF,$E1,$D6,$C8,$BD,$B2,$A8,$9F
|
||||
;.byte $96,$8E,$85,$7E,$77,$70,$6B,$64
|
||||
;.byte $5E,$59,$54,$4F,$4B,$47,$42,$3F
|
||||
;.byte $3B,$38,$35,$32,$2F,$2C,$2A,$27
|
||||
;.byte $25,$23,$21,$1F,$1D,$1C,$1A,$19
|
||||
;.byte $17,$16,$15,$13,$12,$11,$10,$0F
|
||||
|
||||
|
||||
; Table #2 of Pro Tracker 3.4x - 3.5x
|
||||
;PT3NoteTable_ASM_34_35_high:
|
||||
;.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08
|
||||
;.byte $08,$07,$07,$06,$06,$06,$05,$05
|
||||
;.byte $05,$04,$04,$04,$04,$03,$03,$03
|
||||
;.byte $03,$03,$02,$02,$02,$02,$02,$02
|
||||
;.byte $02,$01,$01,$01,$01,$01,$01,$01
|
||||
;.byte $01,$01,$01,$01,$01,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
;PT3NoteTable_ASM_34_35_low:
|
||||
;.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8
|
||||
;.byte $3B,$C5,$55,$EC,$88,$2A,$D2,$7E
|
||||
;.byte $2F,$E5,$9E,$5C,$1D,$E2,$AB,$76
|
||||
;.byte $44,$15,$E9,$BF,$98,$72,$4F,$2E
|
||||
;.byte $0F,$F1,$D5,$BB,$A2,$8B,$74,$60
|
||||
;.byte $4C,$39,$28,$17,$07,$F9,$EB,$DD
|
||||
;.byte $D1,$C5,$BA,$B0,$A6,$9D,$94,$8C
|
||||
;.byte $84,$7C,$75,$6F,$69,$63,$5D,$58
|
||||
;.byte $53,$4E,$4A,$46,$42,$3E,$3B,$37
|
||||
;.byte $34,$31,$2F,$2C,$29,$27,$25,$23
|
||||
;.byte $21,$1F,$1D,$1C,$1A,$19,$17,$16
|
||||
;.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
|
||||
;.byte $0,$0,$0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3
|
||||
;.byte $0,$0,$0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4
|
||||
;.byte $0,$0,$0,$1,$1,$1,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||
;.byte $0,$0,$0,$1,$1,$2,$2,$3,$3,$3,$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,$0,$1,$1,$2,$2,$3,$3,$4,$5,$5,$6,$6,$7,$7,$8
|
||||
;.byte $0,$0,$1,$1,$2,$3,$3,$4,$5,$5,$6,$6,$7,$8,$8,$9
|
||||
;.byte $0,$0,$1,$2,$2,$3,$4,$4,$5,$6,$6,$7,$8,$8,$9,$A
|
||||
;.byte $0,$0,$1,$2,$3,$3,$4,$5,$6,$6,$7,$8,$9,$9,$A,$B
|
||||
;.byte $0,$0,$1,$2,$3,$4,$4,$5,$6,$7,$8,$8,$9,$A,$B,$C
|
||||
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$7,$7,$8,$9,$A,$B,$C,$D
|
||||
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$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
|
||||
|
||||
;PT3VolumeTable_35:
|
||||
;.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,$1,$1,$1,$1,$1,$1,$1,$1,$2,$2,$2,$2
|
||||
;.byte $0,$0,$0,$1,$1,$1,$1,$1,$2,$2,$2,$2,$2,$3,$3,$3
|
||||
;.byte $0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3,$4,$4
|
||||
;.byte $0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||
;.byte $0,$0,$1,$1,$2,$2,$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
|
575
pt3_lib/pt3_lib_init.s
Normal file
575
pt3_lib/pt3_lib_init.s
Normal file
@ -0,0 +1,575 @@
|
||||
; pt3_lib_init.s
|
||||
|
||||
; Initialize a song
|
||||
|
||||
; this is done before song starts playing so it is not
|
||||
; as performance / timing critical
|
||||
|
||||
;====================================
|
||||
; pt3_init_song
|
||||
;====================================
|
||||
;
|
||||
pt3_init_song:
|
||||
|
||||
lda #$0
|
||||
sta DONE_SONG ; 3
|
||||
ldx #(end_vars-begin_vars)
|
||||
zero_song_structs_loop:
|
||||
dex
|
||||
sta note_a,X
|
||||
bne zero_song_structs_loop
|
||||
|
||||
sta pt3_noise_period_smc+1 ; 4
|
||||
sta pt3_noise_add_smc+1 ; 4
|
||||
|
||||
sta pt3_envelope_period_l_smc+1 ; 4
|
||||
sta pt3_envelope_period_h_smc+1 ; 4
|
||||
sta pt3_envelope_slide_l_smc+1 ; 4
|
||||
sta pt3_envelope_slide_h_smc+1 ; 4
|
||||
sta pt3_envelope_slide_add_l_smc+1 ; 4
|
||||
sta pt3_envelope_slide_add_h_smc+1 ; 4
|
||||
sta pt3_envelope_add_smc+1 ; 4
|
||||
sta pt3_envelope_type_smc+1 ; 4
|
||||
sta pt3_envelope_type_old_smc+1 ; 4
|
||||
sta pt3_envelope_delay_smc+1 ; 4
|
||||
sta pt3_envelope_delay_orig_smc+1 ; 4
|
||||
|
||||
sta PT3_MIXER_VAL ; 3
|
||||
|
||||
sta current_pattern_smc+1 ; 4
|
||||
sta current_line_smc+1 ; 4
|
||||
sta current_subframe_smc+1 ; 4
|
||||
|
||||
lda #$f ; 2
|
||||
sta note_a+NOTE_VOLUME ; 4
|
||||
sta note_b+NOTE_VOLUME ; 4
|
||||
sta note_c+NOTE_VOLUME ; 4
|
||||
|
||||
; default ornament/sample in A
|
||||
; X is zero coming in here
|
||||
;ldx #(NOTE_STRUCT_SIZE*0) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
; default ornament/sample in B
|
||||
ldx #(NOTE_STRUCT_SIZE*1) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
; default ornament/sample in C
|
||||
ldx #(NOTE_STRUCT_SIZE*2) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
;=======================
|
||||
; load default speed
|
||||
|
||||
lda PT3_LOC+PT3_SPEED ; 4
|
||||
sta pt3_speed_smc+1 ; 4
|
||||
|
||||
;=======================
|
||||
; load loop
|
||||
|
||||
lda PT3_LOC+PT3_LOOP ; 4
|
||||
sta pt3_loop_smc+1 ; 4
|
||||
|
||||
|
||||
;========================
|
||||
;========================
|
||||
; set up note/freq table
|
||||
; this saves some space and makes things marginally faster longrun
|
||||
;========================
|
||||
;========================
|
||||
; note (heh) that there are separate tables if version 3.3
|
||||
; but we are going to assume we are only going to be playing
|
||||
; newer 3.4+ version files so only need the newer tables
|
||||
|
||||
ldx PT3_LOC+PT3_HEADER_FREQUENCY ; 4
|
||||
beq use_freq_table_0
|
||||
dex
|
||||
beq use_freq_table_1
|
||||
dex
|
||||
beq use_freq_table_2
|
||||
; fallthrough (freq table 3)
|
||||
|
||||
use_freq_table_3:
|
||||
;=================================================
|
||||
; Create Table #3, v4+, "PT3NoteTable_REAL_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11 ; !2
|
||||
freq_table_3_copy_loop:
|
||||
; note, high lookup almost same as 2v4, just need to adjust one value
|
||||
|
||||
lda base2_v4_high,Y ; !3
|
||||
sta NoteTable_high,Y ; !3
|
||||
lda base3_low,Y ; !3
|
||||
sta NoteTable_low,Y ; !3
|
||||
dey ; !1
|
||||
bpl freq_table_3_copy_loop ; !2
|
||||
|
||||
dec NoteTable_high ; adjust to right value
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table3_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table3_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
|
||||
|
||||
use_freq_table_2:
|
||||
;=================================================
|
||||
; Create Table #2, v4+, "PT3NoteTable_ASM_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_2_copy_loop:
|
||||
lda base2_v4_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base2_v4_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_2_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table2_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table2_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
use_freq_table_1:
|
||||
;=================================================
|
||||
; Create Table #1, "PT3NoteTable_ST"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_1_copy_loop:
|
||||
lda base1_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base1_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_1_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
; last adjustments
|
||||
lda #$FD ; Tone[23]=$3FD
|
||||
sta NoteTable_low+23
|
||||
dec NoteTable_low+46 ; Tone[46]-=1;
|
||||
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
|
||||
use_freq_table_0:
|
||||
;=================================================
|
||||
; Create Table #0, "PT3NoteTable_PT_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_0_copy_loop:
|
||||
lda base0_v4_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base0_v4_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_0_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table0_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table0_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
|
||||
done_set_freq_table:
|
||||
|
||||
|
||||
;======================
|
||||
; calculate version
|
||||
ldx #6 ; 2
|
||||
lda PT3_LOC+PT3_VERSION ; 4
|
||||
sec ; 2
|
||||
sbc #'0' ; 2
|
||||
cmp #9 ; 2
|
||||
bcs not_ascii_number ; bge ; 2/3
|
||||
tax ; 2
|
||||
|
||||
not_ascii_number:
|
||||
|
||||
; adjust version<6 SMC code in the slide code
|
||||
|
||||
; FIXME: I am sure there's a more clever way to do this
|
||||
|
||||
lda #$2C ; BIT ; 2
|
||||
cpx #$6 ; 2
|
||||
bcs version_greater_than_or_equal_6 ; bgt ; 3
|
||||
; less than 6, jump
|
||||
; also carry is known to be clear
|
||||
adc #$20 ; BIT->JMP 2C->4C ; 2
|
||||
version_greater_than_or_equal_6:
|
||||
sta version_smc ; 4
|
||||
|
||||
pick_volume_table:
|
||||
|
||||
;=======================
|
||||
; Pick which volume number, based on version
|
||||
|
||||
; if (PlParams.PT3.PT3_Version <= 4)
|
||||
|
||||
cpx #5 ; 2
|
||||
|
||||
; carry clear = 3.3/3.4 table
|
||||
; carry set = 3.5 table
|
||||
|
||||
;==========================
|
||||
; VolTableCreator
|
||||
;==========================
|
||||
; Creates the appropriate volume table
|
||||
; based on z80 code by Ivan Roshin ZXAYHOBETA/VTII10bG.asm
|
||||
;
|
||||
|
||||
; Called with carry==0 for 3.3/3.4 table
|
||||
; Called with carry==1 for 3.5 table
|
||||
|
||||
; 177f-1932 = 435 bytes, not that much better than 512 of lookup
|
||||
|
||||
|
||||
VolTableCreator:
|
||||
|
||||
; Init initial variables
|
||||
lda #$0
|
||||
sta z80_d_smc+1
|
||||
ldy #$11
|
||||
|
||||
; Set up self modify
|
||||
|
||||
ldx #$2A ; ROL for self-modify
|
||||
bcs vol_type_35
|
||||
|
||||
vol_type_33:
|
||||
|
||||
; For older table, we set initial conditions a bit
|
||||
; different
|
||||
|
||||
dey
|
||||
tya
|
||||
|
||||
ldx #$ea ; NOP for self modify
|
||||
|
||||
vol_type_35:
|
||||
sty z80_l_smc+1 ; l=16 or 17
|
||||
sta z80_e_smc+1 ; e=16 or 0
|
||||
stx vol_smc ; set the self-modify code
|
||||
|
||||
ldy #16 ; skip first row, all zeros
|
||||
ldx #16 ; c=16
|
||||
vol_outer:
|
||||
clc ; add HL,DE
|
||||
z80_l_smc:
|
||||
lda #$d1
|
||||
z80_e_smc:
|
||||
adc #$d1
|
||||
sta z80_e_smc+1
|
||||
lda #0
|
||||
z80_d_smc:
|
||||
adc #$d1
|
||||
sta z80_d_smc+1 ; carry is important
|
||||
|
||||
; sbc hl,hl
|
||||
lda #0
|
||||
adc #$ff
|
||||
eor #$ff
|
||||
|
||||
vol_write:
|
||||
sta z80_h_smc+1
|
||||
pha
|
||||
|
||||
vol_inner:
|
||||
pla
|
||||
pha
|
||||
|
||||
vol_smc:
|
||||
nop ; nop or ROL depending
|
||||
|
||||
z80_h_smc:
|
||||
lda #$d1
|
||||
|
||||
adc #$0 ; a=a+carry;
|
||||
|
||||
sta VolumeTable,Y
|
||||
iny
|
||||
|
||||
pla ; add HL,DE
|
||||
adc z80_e_smc+1
|
||||
pha
|
||||
lda z80_h_smc+1
|
||||
adc z80_d_smc+1
|
||||
sta z80_h_smc+1
|
||||
|
||||
inx ; inc C
|
||||
txa ; a=c
|
||||
and #$f
|
||||
bne vol_inner
|
||||
|
||||
|
||||
pla
|
||||
|
||||
lda z80_e_smc+1 ; a=e
|
||||
cmp #$77
|
||||
bne vol_m3
|
||||
|
||||
inc z80_e_smc+1
|
||||
|
||||
vol_m3:
|
||||
txa ; a=c
|
||||
bne vol_outer
|
||||
|
||||
vol_done:
|
||||
rts
|
||||
|
||||
|
||||
;=========================================
|
||||
; copy note table seed to proper location
|
||||
;=========================================
|
||||
|
||||
; faster inlined
|
||||
|
||||
;NoteTableCopy:
|
||||
|
||||
; ldy #11 ; !2
|
||||
;note_table_copy_loop:
|
||||
;ntc_smc1:
|
||||
; lda base1_high,Y ; !3
|
||||
; sta NoteTable_high,Y ; !3
|
||||
;ntc_smc2:
|
||||
; lda base1_low,Y ; !3
|
||||
; sta NoteTable_low,Y ; !3
|
||||
; dey ; !1
|
||||
; bpl note_table_copy_loop ; !2
|
||||
; rts ; !1
|
||||
|
||||
|
||||
;==========================================
|
||||
; propogate the freq down, dividing by two
|
||||
;==========================================
|
||||
NoteTablePropogate:
|
||||
|
||||
ldy #0
|
||||
note_table_propogate_loop:
|
||||
clc
|
||||
lda NoteTable_high,Y
|
||||
ror
|
||||
sta NoteTable_high+12,Y
|
||||
|
||||
lda NoteTable_low,Y
|
||||
ror
|
||||
sta NoteTable_low+12,Y
|
||||
|
||||
iny
|
||||
cpy #84
|
||||
bne note_table_propogate_loop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;================================================
|
||||
; propogation isn't enough, various values
|
||||
; are ofte off by one, so adjust using a bitmask
|
||||
;================================================
|
||||
NoteTableAdjust:
|
||||
|
||||
ldx #0
|
||||
note_table_adjust_outer:
|
||||
|
||||
note_table_adjust_smc:
|
||||
lda table0_v4_adjust,X
|
||||
sta PT3_TEMP
|
||||
|
||||
; reset smc
|
||||
lda #<NoteTable_low
|
||||
sta ntl_smc+1
|
||||
lda #>NoteTable_low
|
||||
sta ntl_smc+2
|
||||
|
||||
|
||||
ldy #7
|
||||
note_table_adjust_inner:
|
||||
ror PT3_TEMP
|
||||
bcc note_table_skip_adjust
|
||||
|
||||
ntl_smc:
|
||||
inc NoteTable_low,X
|
||||
|
||||
note_table_skip_adjust:
|
||||
clc
|
||||
lda #12
|
||||
adc ntl_smc+1
|
||||
sta ntl_smc+1
|
||||
lda #0
|
||||
adc ntl_smc+2 ; unnecessary if aligned
|
||||
sta ntl_smc+2
|
||||
|
||||
skip_adjust_done:
|
||||
dey
|
||||
bpl note_table_adjust_inner
|
||||
|
||||
inx
|
||||
cpx #12
|
||||
bne note_table_adjust_outer
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;base0_v3_high:
|
||||
;.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||
;base0_v3_low:
|
||||
;.byte $21,$73,$CE,$33,$A0,$16,$93,$18,$A4,$36,$CE,$6D
|
||||
|
||||
; note: same as base0_v3_high
|
||||
base0_v4_high:
|
||||
.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||
base0_v4_low:
|
||||
.byte $22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF,$6D
|
||||
|
||||
base1_high:
|
||||
.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07
|
||||
base1_low:
|
||||
.byte $F8,$10,$60,$80,$D8,$28,$88,$F0,$60,$E0,$58,$E0
|
||||
|
||||
;base2_v3_high:
|
||||
;.byte $0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07,$07,$07
|
||||
;base2_v3_low:
|
||||
;.byte $3E,$80,$CC,$22,$82,$EC,$5C,$D6,$58,$E0,$6E,$04
|
||||
|
||||
; note almost same as above
|
||||
base2_v4_high:
|
||||
.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||
base2_v4_low:
|
||||
.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8,$3B,$C5,$55,$EC
|
||||
|
||||
; note almost same as above
|
||||
;base3_high:
|
||||
;.byte $0C,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||
base3_low:
|
||||
.byte $DA,$22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF
|
||||
|
||||
|
||||
; Adjustment factors
|
||||
table0_v4_adjust:
|
||||
.byte $40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c,$5a
|
||||
|
||||
table2_v4_adjust:
|
||||
.byte $20,$a8,$40,$f8,$bc,$90,$78,$70,$74,$08,$2a,$50
|
||||
|
||||
table3_v4_adjust:
|
||||
.byte $B4,$40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c
|
||||
|
||||
|
||||
; Table #1 of Pro Tracker 3.3x - 3.5x
|
||||
;PT3NoteTable_ST_high:
|
||||
;.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09
|
||||
;.byte $09,$08,$08,$07,$07,$07,$06,$06
|
||||
;.byte $05,$05,$05,$04,$04,$04,$04,$03
|
||||
;.byte $03,$03,$03,$03,$02,$02,$02,$02
|
||||
;.byte $02,$02,$02,$01,$01,$01,$01,$01
|
||||
;.byte $01,$01,$01,$01,$01,$01,$01,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
;PT3NoteTable_ST_low:
|
||||
;.byte $F8,$10,$60,$80,$D8,$28,$88,$F0
|
||||
;.byte $60,$E0,$58,$E0,$7C,$08,$B0,$40
|
||||
;.byte $EC,$94,$44,$F8,$B0,$70,$2C,$FD
|
||||
;.byte $BE,$84,$58,$20,$F6,$CA,$A2,$7C
|
||||
;.byte $58,$38,$16,$F8,$DF,$C2,$AC,$90
|
||||
;.byte $7B,$65,$51,$3E,$2C,$1C,$0A,$FC
|
||||
;.byte $EF,$E1,$D6,$C8,$BD,$B2,$A8,$9F
|
||||
;.byte $96,$8E,$85,$7E,$77,$70,$6B,$64
|
||||
;.byte $5E,$59,$54,$4F,$4B,$47,$42,$3F
|
||||
;.byte $3B,$38,$35,$32,$2F,$2C,$2A,$27
|
||||
;.byte $25,$23,$21,$1F,$1D,$1C,$1A,$19
|
||||
;.byte $17,$16,$15,$13,$12,$11,$10,$0F
|
||||
|
||||
|
||||
; Table #2 of Pro Tracker 3.4x - 3.5x
|
||||
;PT3NoteTable_ASM_34_35_high:
|
||||
;.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08
|
||||
;.byte $08,$07,$07,$06,$06,$06,$05,$05
|
||||
;.byte $05,$04,$04,$04,$04,$03,$03,$03
|
||||
;.byte $03,$03,$02,$02,$02,$02,$02,$02
|
||||
;.byte $02,$01,$01,$01,$01,$01,$01,$01
|
||||
;.byte $01,$01,$01,$01,$01,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
;PT3NoteTable_ASM_34_35_low:
|
||||
;.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8
|
||||
;.byte $3B,$C5,$55,$EC,$88,$2A,$D2,$7E
|
||||
;.byte $2F,$E5,$9E,$5C,$1D,$E2,$AB,$76
|
||||
;.byte $44,$15,$E9,$BF,$98,$72,$4F,$2E
|
||||
;.byte $0F,$F1,$D5,$BB,$A2,$8B,$74,$60
|
||||
;.byte $4C,$39,$28,$17,$07,$F9,$EB,$DD
|
||||
;.byte $D1,$C5,$BA,$B0,$A6,$9D,$94,$8C
|
||||
;.byte $84,$7C,$75,$6F,$69,$63,$5D,$58
|
||||
;.byte $53,$4E,$4A,$46,$42,$3E,$3B,$37
|
||||
;.byte $34,$31,$2F,$2C,$29,$27,$25,$23
|
||||
;.byte $21,$1F,$1D,$1C,$1A,$19,$17,$16
|
||||
;.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
|
||||
;.byte $0,$0,$0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3
|
||||
;.byte $0,$0,$0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4
|
||||
;.byte $0,$0,$0,$1,$1,$1,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||
;.byte $0,$0,$0,$1,$1,$2,$2,$3,$3,$3,$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,$0,$1,$1,$2,$2,$3,$3,$4,$5,$5,$6,$6,$7,$7,$8
|
||||
;.byte $0,$0,$1,$1,$2,$3,$3,$4,$5,$5,$6,$6,$7,$8,$8,$9
|
||||
;.byte $0,$0,$1,$2,$2,$3,$4,$4,$5,$6,$6,$7,$8,$8,$9,$A
|
||||
;.byte $0,$0,$1,$2,$3,$3,$4,$5,$6,$6,$7,$8,$9,$9,$A,$B
|
||||
;.byte $0,$0,$1,$2,$3,$4,$4,$5,$6,$7,$8,$8,$9,$A,$B,$C
|
||||
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$7,$7,$8,$9,$A,$B,$C,$D
|
||||
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$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
|
||||
|
||||
;PT3VolumeTable_35:
|
||||
;.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,$1,$1,$1,$1,$1,$1,$1,$1,$2,$2,$2,$2
|
||||
;.byte $0,$0,$0,$1,$1,$1,$1,$1,$2,$2,$2,$2,$2,$3,$3,$3
|
||||
;.byte $0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3,$4,$4
|
||||
;.byte $0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||
;.byte $0,$0,$1,$1,$2,$2,$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
|
109
pt3_lib/pt3_lib_irq_handler.s
Normal file
109
pt3_lib/pt3_lib_irq_handler.s
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
|
||||
pt3_irq_handler:
|
||||
|
||||
bit $C404 ; clear 6522 interrupt by reading T1C-L ; 4
|
||||
|
||||
lda DONE_PLAYING ; 3
|
||||
beq pt3_play_music ; if song done, don't play music ; 3/2nt
|
||||
jmp done_pt3_irq_handler ; 3
|
||||
;============
|
||||
; 13
|
||||
|
||||
pt3_play_music:
|
||||
|
||||
; decode a frame of music
|
||||
|
||||
jsr pt3_make_frame
|
||||
|
||||
; handle song over condition
|
||||
lda DONE_SONG
|
||||
beq mb_write_frame ; if not done, continue
|
||||
|
||||
lda LOOP ; see if looping
|
||||
beq move_to_next
|
||||
|
||||
pt3_loop_smc:
|
||||
lda #$d1 ; looping, move to loop location
|
||||
; non-zero to avoid the temptation
|
||||
; to merge with following lda #$0
|
||||
sta current_pattern_smc+1
|
||||
lda #$0
|
||||
sta current_line_smc+1
|
||||
sta current_subframe_smc+1
|
||||
sta DONE_SONG ; undo the next song
|
||||
|
||||
beq done_pt3_irq_handler ; branch always
|
||||
|
||||
move_to_next:
|
||||
; same as "press right"
|
||||
ldx #$20
|
||||
jmp quiet_exit
|
||||
|
||||
;======================================
|
||||
; Write frames to Mockingboard
|
||||
;======================================
|
||||
; for speed could merge this into
|
||||
; the decode code
|
||||
|
||||
mb_write_frame:
|
||||
|
||||
|
||||
tax ; 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:
|
||||
|
||||
|
||||
;=================================
|
||||
; Finally done with this interrupt
|
||||
;=================================
|
||||
|
||||
done_pt3_irq_handler:
|
@ -32,8 +32,8 @@ pt3_setup:
|
||||
cmp #6
|
||||
beq apple_iie_or_newer
|
||||
|
||||
lda #1 ; set if older than a IIe
|
||||
sta apple_ii
|
||||
;lda #$d0 ; set if older than a IIe
|
||||
;sta apple_ii_smc
|
||||
jmp done_apple_detect
|
||||
apple_iie_or_newer:
|
||||
lda $FBC0 ; 0 on a IIc
|
||||
@ -69,9 +69,11 @@ done_apple_detect:
|
||||
;===============
|
||||
|
||||
lda #0
|
||||
sta DRAW_PAGE
|
||||
sta DONE_PLAYING
|
||||
sta LOOP
|
||||
|
||||
|
||||
;=======================
|
||||
; Detect mockingboard
|
||||
;========================
|
||||
@ -83,32 +85,32 @@ done_apple_detect:
|
||||
|
||||
; print detection message
|
||||
|
||||
; lda #<mocking_message ; load loading message
|
||||
; sta OUTL
|
||||
; lda #>mocking_message
|
||||
; sta OUTH
|
||||
; jsr move_and_print ; print it
|
||||
lda #<mocking_message ; load loading message
|
||||
sta OUTL
|
||||
lda #>mocking_message
|
||||
sta OUTH
|
||||
jsr move_and_print ; print it
|
||||
|
||||
jsr mockingboard_detect_slot4 ; call detection routine
|
||||
cpx #$1
|
||||
beq mockingboard_found
|
||||
|
||||
; lda #<not_message ; if not found, print that
|
||||
; sta OUTL
|
||||
; lda #>not_message
|
||||
; sta OUTH
|
||||
; inc CV
|
||||
; jsr move_and_print
|
||||
lda #<not_message ; if not found, print that
|
||||
sta OUTL
|
||||
lda #>not_message
|
||||
sta OUTH
|
||||
inc CV
|
||||
jsr move_and_print
|
||||
|
||||
; jmp forever_loop ; and wait forever
|
||||
jmp forever_loop ; and wait forever
|
||||
|
||||
mockingboard_found:
|
||||
; lda #<found_message ; print found message
|
||||
; sta OUTL
|
||||
; lda #>found_message
|
||||
; sta OUTH
|
||||
; inc CV
|
||||
; jsr move_and_print
|
||||
lda #<found_message ; print found message
|
||||
sta OUTL
|
||||
lda #>found_message
|
||||
sta OUTH
|
||||
inc CV
|
||||
jsr move_and_print
|
||||
|
||||
;============================
|
||||
; Init the Mockingboard
|
||||
@ -170,8 +172,8 @@ start_interrupts:
|
||||
;============================
|
||||
; Loop forever
|
||||
;============================
|
||||
forever_loop:
|
||||
main_loop:
|
||||
|
||||
jmp main_loop
|
||||
|
||||
|
||||
@ -187,23 +189,26 @@ main_loop:
|
||||
; vars
|
||||
;=========
|
||||
|
||||
time_frame: .byte $0
|
||||
apple_ii: .byte $0
|
||||
|
||||
;=========
|
||||
;routines
|
||||
;=========
|
||||
.include "mockingboard_a.s"
|
||||
.include "interrupt_handler.s"
|
||||
.include "pt3_lib.s"
|
||||
.include "pt3_lib_core.s"
|
||||
.include "pt3_lib_init.s"
|
||||
|
||||
.include "text_print.s"
|
||||
.include "gr_offsets.s"
|
||||
|
||||
;=========
|
||||
; strings
|
||||
;=========
|
||||
;mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
|
||||
not_message: .byte "NOT "
|
||||
found_message: .asciiz "FOUND"
|
||||
;done_message: .asciiz "DONE PLAYING"
|
||||
mocking_message: .byte $0,$0
|
||||
.asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
|
||||
not_message: .byte $0,$1
|
||||
.asciiz "+ NOT FOUND"
|
||||
found_message: .byte $0,$1
|
||||
.asciiz "+ FOUND"
|
||||
|
||||
;=============
|
||||
; include song
|
||||
|
142
pt3_lib/text_print.s
Normal file
142
pt3_lib/text_print.s
Normal file
@ -0,0 +1,142 @@
|
||||
|
||||
;================================
|
||||
; move_and_print
|
||||
;================================
|
||||
; get X,Y from OUTL/OUTH
|
||||
; then print following string to that address
|
||||
; stop at NUL
|
||||
; convert to APPLE ASCII (or with 0x80)
|
||||
; leave OUTL/OUTH pointing to next string
|
||||
|
||||
move_and_print:
|
||||
ldy #0
|
||||
lda (OUTL),Y
|
||||
sta CH
|
||||
iny
|
||||
lda (OUTL),Y
|
||||
asl
|
||||
tay
|
||||
lda gr_offsets,Y ; lookup low-res memory address
|
||||
clc
|
||||
adc CH ; add in xpos
|
||||
sta BASL ; store out low byte of addy
|
||||
|
||||
lda gr_offsets+1,Y ; look up high byte
|
||||
adc DRAW_PAGE ;
|
||||
sta BASH ; and store it out
|
||||
; BASH:BASL now points at right place
|
||||
|
||||
clc
|
||||
lda OUTL
|
||||
adc #2
|
||||
sta OUTL
|
||||
lda OUTH
|
||||
adc #0
|
||||
sta OUTH
|
||||
|
||||
;================================
|
||||
; print_string
|
||||
;================================
|
||||
|
||||
print_string:
|
||||
ldy #0
|
||||
print_string_loop:
|
||||
lda (OUTL),Y
|
||||
beq done_print_string
|
||||
eor #$80 ; flip from ASCII to text char
|
||||
sta (BASL),Y
|
||||
iny
|
||||
bne print_string_loop
|
||||
done_print_string:
|
||||
iny
|
||||
clc
|
||||
tya
|
||||
adc OUTL
|
||||
sta OUTL
|
||||
lda OUTH
|
||||
adc #0
|
||||
sta OUTH
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;================================
|
||||
; move and print a list of lines
|
||||
;================================
|
||||
move_and_print_list:
|
||||
jsr move_and_print
|
||||
ldy #0
|
||||
lda (OUTL),Y
|
||||
bpl move_and_print_list
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;================================
|
||||
; move and print a list of lines
|
||||
;================================
|
||||
move_and_print_list_both_pages:
|
||||
lda DRAW_PAGE
|
||||
pha
|
||||
|
||||
lda OUTL
|
||||
pha
|
||||
lda OUTH
|
||||
pha
|
||||
|
||||
lda #0
|
||||
sta DRAW_PAGE
|
||||
|
||||
jsr move_and_print_list
|
||||
|
||||
pla
|
||||
sta OUTH
|
||||
pla
|
||||
sta OUTL
|
||||
|
||||
lda #4
|
||||
sta DRAW_PAGE
|
||||
|
||||
jsr move_and_print_list
|
||||
|
||||
pla
|
||||
sta DRAW_PAGE
|
||||
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;=======================
|
||||
; print to both pages
|
||||
;=======================
|
||||
print_both_pages:
|
||||
lda DRAW_PAGE
|
||||
pha
|
||||
|
||||
lda OUTL
|
||||
pha
|
||||
lda OUTH
|
||||
pha
|
||||
|
||||
lda #0
|
||||
sta DRAW_PAGE
|
||||
|
||||
jsr move_and_print
|
||||
|
||||
pla
|
||||
sta OUTH
|
||||
pla
|
||||
sta OUTL
|
||||
|
||||
lda #4
|
||||
sta DRAW_PAGE
|
||||
|
||||
jsr move_and_print
|
||||
|
||||
pla
|
||||
sta DRAW_PAGE
|
||||
|
||||
|
||||
rts
|
@ -34,6 +34,10 @@ SEEDH = $4F
|
||||
; dos33 zero page = 26-2f, 35-38, 3e 3f 40-4d
|
||||
; overlap applesoft 67-6a,6f,70,af,b0,ca-cd,d8
|
||||
|
||||
DRAW_PAGE = $6D
|
||||
OUTL = $6E
|
||||
OUTH = $6F
|
||||
|
||||
AY_REGISTERS = $70
|
||||
A_FINE_TONE = $70
|
||||
A_COARSE_TONE = $71
|
||||
@ -43,6 +47,7 @@ C_FINE_TONE = $74
|
||||
C_COARSE_TONE = $75
|
||||
NOISE = $76
|
||||
ENABLE = $77
|
||||
PT3_MIXER_VAL = $77
|
||||
A_VOLUME = $78
|
||||
B_VOLUME = $79
|
||||
C_VOLUME = $7A
|
||||
|
@ -78,8 +78,9 @@ PT3_PLAYER: pt3_player.o
|
||||
ld65 -o PT3_PLAYER pt3_player.o -C ../linker_scripts/apple2_1000.inc
|
||||
|
||||
pt3_player.o: pt3_player.s \
|
||||
gr_fast_clear.s pt3_lib.s interrupt_handler.s random16.s fire.s \
|
||||
gr_putsprite.s put_letters.s zp.inc
|
||||
gr_fast_clear.s random16.s fire.s \
|
||||
gr_putsprite.s put_letters.s zp.inc \
|
||||
pt3_lib_init.s pt3_lib_core.s interrupt_handler.s
|
||||
ca65 -o pt3_player.o pt3_player.s -l pt3_player.lst
|
||||
|
||||
#
|
||||
@ -88,7 +89,8 @@ PT3_TIMER: pt3_timer.o
|
||||
ld65 -o PT3_TIMER pt3_timer.o -C ../linker_scripts/apple2_1000.inc
|
||||
|
||||
pt3_timer.o: pt3_timer.s \
|
||||
gr_fast_clear.s pt3_lib.s interrupt_handler.s zp.inc
|
||||
gr_fast_clear.s zp.inc \
|
||||
pt3_lib_init.s pt3_lib_core.s
|
||||
ca65 -o pt3_timer.o pt3_timer.s -l pt3_timer.lst
|
||||
|
||||
#
|
||||
@ -97,7 +99,8 @@ PT3_DUMPER: pt3_dumper.o
|
||||
ld65 -o PT3_DUMPER pt3_dumper.o -C ../linker_scripts/apple2_1000.inc
|
||||
|
||||
pt3_dumper.o: pt3_dumper.s \
|
||||
gr_fast_clear.s pt3_lib.s interrupt_handler.s zp.inc
|
||||
gr_fast_clear.s zp.inc \
|
||||
pt3_lib_init.s pt3_lib_core.s
|
||||
ca65 -o pt3_dumper.o pt3_dumper.s -l pt3_dumper.lst
|
||||
|
||||
#
|
||||
@ -106,7 +109,7 @@ PT3_TABLE_TEST: pt3_table_test.o
|
||||
ld65 -o PT3_TABLE_TEST pt3_table_test.o -C ../linker_scripts/apple2_1000.inc
|
||||
|
||||
pt3_table_test.o: pt3_table_test.s \
|
||||
gr_fast_clear.s pt3_lib.s interrupt_handler.s zp.inc
|
||||
gr_fast_clear.s pt3_lib_core.s pt3_lib_init.s zp.inc
|
||||
ca65 -o pt3_table_test.o pt3_table_test.s -l pt3_table_test.lst
|
||||
|
||||
#
|
||||
|
@ -29,116 +29,17 @@ interrupt_handler:
|
||||
tya
|
||||
pha ; save Y
|
||||
|
||||
|
||||
|
||||
; inc $0404 ; debug (flashes char onscreen)
|
||||
|
||||
bit $C404 ; clear 6522 interrupt by reading T1C-L ; 4
|
||||
|
||||
.include "pt3_lib_irq_handler.s"
|
||||
|
||||
;==============================================
|
||||
; only update time counter if not done playing
|
||||
;==============================================
|
||||
|
||||
lda DONE_PLAYING ; 3
|
||||
beq pt3_play_music ; if song done, don't play music ; 3/2nt
|
||||
jmp check_keyboard ; 3
|
||||
;============
|
||||
; 13
|
||||
|
||||
pt3_play_music:
|
||||
|
||||
; decode a frame of music
|
||||
|
||||
jsr pt3_make_frame
|
||||
|
||||
; handle song over condition
|
||||
lda DONE_SONG
|
||||
beq mb_write_frame ; if not done, continue
|
||||
|
||||
lda LOOP ; see if looping
|
||||
beq move_to_next
|
||||
|
||||
pt3_loop_smc:
|
||||
lda #$d1 ; looping, move to loop location
|
||||
; non-zero to avoid the temptation
|
||||
; to merge with following lda #$0
|
||||
sta current_pattern_smc+1
|
||||
lda #$0
|
||||
sta current_line_smc+1
|
||||
sta current_subframe_smc+1
|
||||
sta DONE_SONG ; undo the next song
|
||||
|
||||
beq done_interrupt ; branch always
|
||||
|
||||
move_to_next:
|
||||
; same as "press right"
|
||||
ldx #$20
|
||||
jmp quiet_exit
|
||||
|
||||
;======================================
|
||||
; Write frames to Mockingboard
|
||||
;======================================
|
||||
; for speed could merge this into
|
||||
; the decode code
|
||||
|
||||
mb_write_frame:
|
||||
|
||||
|
||||
tax ; 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:
|
||||
|
||||
|
||||
;=================================
|
||||
; Finally done with this interrupt
|
||||
;=================================
|
||||
|
||||
done_interrupt:
|
||||
|
||||
bne check_keyboard
|
||||
|
||||
;=====================
|
||||
; Update time counter
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
PT3_LOC = $4000
|
||||
|
||||
NUM_FILES = 15
|
||||
|
||||
PT3_USE_ZERO_PAGE = 1
|
||||
|
||||
;=============================
|
||||
; Setup
|
||||
@ -231,20 +230,6 @@ new_song:
|
||||
; Init Variables
|
||||
;=========================
|
||||
|
||||
; ?
|
||||
|
||||
|
||||
;===========================
|
||||
; Print loading message
|
||||
;===========================
|
||||
|
||||
; lda #<loading_message
|
||||
; sta OUTL
|
||||
; lda #>loading_message
|
||||
; sta OUTH
|
||||
; jsr print_cout
|
||||
|
||||
|
||||
;===========================
|
||||
; Load in PT3 file
|
||||
;===========================
|
||||
@ -365,30 +350,6 @@ filename_found:
|
||||
|
||||
rts
|
||||
|
||||
;===============================
|
||||
; Increment file we want to load
|
||||
;===============================
|
||||
increment_file:
|
||||
inc WHICH_FILE
|
||||
lda WHICH_FILE
|
||||
cmp #NUM_FILES
|
||||
bne done_increment
|
||||
lda #0
|
||||
sta WHICH_FILE
|
||||
done_increment:
|
||||
rts
|
||||
|
||||
;===============================
|
||||
; Decrement file we want to load
|
||||
;===============================
|
||||
decrement_file:
|
||||
dec WHICH_FILE
|
||||
bpl done_decrement
|
||||
lda #(NUM_FILES-1)
|
||||
sta WHICH_FILE
|
||||
done_decrement:
|
||||
rts
|
||||
|
||||
|
||||
;===============
|
||||
; print cout
|
||||
@ -422,21 +383,26 @@ FRAMEH: .byte $00
|
||||
|
||||
song_list:
|
||||
|
||||
; .asciiz "IT.PT3" ; ST
|
||||
.asciiz "IT.PT3" ; ST
|
||||
; .asciiz "CR.PT3" ; ST
|
||||
; .asciiz "EA.PT3" ; ST
|
||||
; .asciiz "RI.PT3" ; ST
|
||||
; .asciiz "OO.PT3" ; ASM_34_35
|
||||
; .asciiz "DY.PT3" ; ASM_34_35
|
||||
; .asciiz "BH.PT3" ; PT_34_35
|
||||
.asciiz "CH.PT3" ; REAL_34_35
|
||||
; .asciiz "CH.PT3" ; REAL_34_35
|
||||
|
||||
;=========
|
||||
;routines
|
||||
;=========
|
||||
.include "qkumba_rts.s"
|
||||
;.include "../pt3_lib/pt3_lib.s"
|
||||
.include "pt3_lib.s"
|
||||
|
||||
.include "pt3_lib_core.s"
|
||||
.include "pt3_lib_init.s"
|
||||
|
||||
|
||||
|
||||
|
||||
;============
|
||||
; dummy vars
|
||||
|
File diff suppressed because it is too large
Load Diff
575
pt3_player/pt3_lib_init.s
Normal file
575
pt3_player/pt3_lib_init.s
Normal file
@ -0,0 +1,575 @@
|
||||
; pt3_lib_init.s
|
||||
|
||||
; Initialize a song
|
||||
|
||||
; this is done before song starts playing so it is not
|
||||
; as performance / timing critical
|
||||
|
||||
;====================================
|
||||
; pt3_init_song
|
||||
;====================================
|
||||
;
|
||||
pt3_init_song:
|
||||
|
||||
lda #$0
|
||||
sta DONE_SONG ; 3
|
||||
ldx #(end_vars-begin_vars)
|
||||
zero_song_structs_loop:
|
||||
dex
|
||||
sta note_a,X
|
||||
bne zero_song_structs_loop
|
||||
|
||||
sta pt3_noise_period_smc+1 ; 4
|
||||
sta pt3_noise_add_smc+1 ; 4
|
||||
|
||||
sta pt3_envelope_period_l_smc+1 ; 4
|
||||
sta pt3_envelope_period_h_smc+1 ; 4
|
||||
sta pt3_envelope_slide_l_smc+1 ; 4
|
||||
sta pt3_envelope_slide_h_smc+1 ; 4
|
||||
sta pt3_envelope_slide_add_l_smc+1 ; 4
|
||||
sta pt3_envelope_slide_add_h_smc+1 ; 4
|
||||
sta pt3_envelope_add_smc+1 ; 4
|
||||
sta pt3_envelope_type_smc+1 ; 4
|
||||
sta pt3_envelope_type_old_smc+1 ; 4
|
||||
sta pt3_envelope_delay_smc+1 ; 4
|
||||
sta pt3_envelope_delay_orig_smc+1 ; 4
|
||||
|
||||
sta PT3_MIXER_VAL ; 3
|
||||
|
||||
sta current_pattern_smc+1 ; 4
|
||||
sta current_line_smc+1 ; 4
|
||||
sta current_subframe_smc+1 ; 4
|
||||
|
||||
lda #$f ; 2
|
||||
sta note_a+NOTE_VOLUME ; 4
|
||||
sta note_b+NOTE_VOLUME ; 4
|
||||
sta note_c+NOTE_VOLUME ; 4
|
||||
|
||||
; default ornament/sample in A
|
||||
; X is zero coming in here
|
||||
;ldx #(NOTE_STRUCT_SIZE*0) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
; default ornament/sample in B
|
||||
ldx #(NOTE_STRUCT_SIZE*1) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
; default ornament/sample in C
|
||||
ldx #(NOTE_STRUCT_SIZE*2) ; 2
|
||||
jsr load_ornament0_sample1 ; 6+93
|
||||
|
||||
;=======================
|
||||
; load default speed
|
||||
|
||||
lda PT3_LOC+PT3_SPEED ; 4
|
||||
sta pt3_speed_smc+1 ; 4
|
||||
|
||||
;=======================
|
||||
; load loop
|
||||
|
||||
lda PT3_LOC+PT3_LOOP ; 4
|
||||
sta pt3_loop_smc+1 ; 4
|
||||
|
||||
|
||||
;========================
|
||||
;========================
|
||||
; set up note/freq table
|
||||
; this saves some space and makes things marginally faster longrun
|
||||
;========================
|
||||
;========================
|
||||
; note (heh) that there are separate tables if version 3.3
|
||||
; but we are going to assume we are only going to be playing
|
||||
; newer 3.4+ version files so only need the newer tables
|
||||
|
||||
ldx PT3_LOC+PT3_HEADER_FREQUENCY ; 4
|
||||
beq use_freq_table_0
|
||||
dex
|
||||
beq use_freq_table_1
|
||||
dex
|
||||
beq use_freq_table_2
|
||||
; fallthrough (freq table 3)
|
||||
|
||||
use_freq_table_3:
|
||||
;=================================================
|
||||
; Create Table #3, v4+, "PT3NoteTable_REAL_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11 ; !2
|
||||
freq_table_3_copy_loop:
|
||||
; note, high lookup almost same as 2v4, just need to adjust one value
|
||||
|
||||
lda base2_v4_high,Y ; !3
|
||||
sta NoteTable_high,Y ; !3
|
||||
lda base3_low,Y ; !3
|
||||
sta NoteTable_low,Y ; !3
|
||||
dey ; !1
|
||||
bpl freq_table_3_copy_loop ; !2
|
||||
|
||||
dec NoteTable_high ; adjust to right value
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table3_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table3_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
|
||||
|
||||
use_freq_table_2:
|
||||
;=================================================
|
||||
; Create Table #2, v4+, "PT3NoteTable_ASM_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_2_copy_loop:
|
||||
lda base2_v4_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base2_v4_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_2_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table2_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table2_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
use_freq_table_1:
|
||||
;=================================================
|
||||
; Create Table #1, "PT3NoteTable_ST"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_1_copy_loop:
|
||||
lda base1_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base1_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_1_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
; last adjustments
|
||||
lda #$FD ; Tone[23]=$3FD
|
||||
sta NoteTable_low+23
|
||||
dec NoteTable_low+46 ; Tone[46]-=1;
|
||||
|
||||
|
||||
jmp done_set_freq_table
|
||||
|
||||
|
||||
use_freq_table_0:
|
||||
;=================================================
|
||||
; Create Table #0, "PT3NoteTable_PT_34_35"
|
||||
;=================================================
|
||||
|
||||
ldy #11
|
||||
freq_table_0_copy_loop:
|
||||
lda base0_v4_high,Y
|
||||
sta NoteTable_high,Y
|
||||
lda base0_v4_low,Y
|
||||
sta NoteTable_low,Y
|
||||
dey
|
||||
bpl freq_table_0_copy_loop
|
||||
|
||||
jsr NoteTablePropogate ; !3
|
||||
|
||||
lda #<table0_v4_adjust
|
||||
sta note_table_adjust_smc+1
|
||||
lda #>table0_v4_adjust
|
||||
sta note_table_adjust_smc+2
|
||||
|
||||
jsr NoteTableAdjust
|
||||
|
||||
|
||||
done_set_freq_table:
|
||||
|
||||
|
||||
;======================
|
||||
; calculate version
|
||||
ldx #6 ; 2
|
||||
lda PT3_LOC+PT3_VERSION ; 4
|
||||
sec ; 2
|
||||
sbc #'0' ; 2
|
||||
cmp #9 ; 2
|
||||
bcs not_ascii_number ; bge ; 2/3
|
||||
tax ; 2
|
||||
|
||||
not_ascii_number:
|
||||
|
||||
; adjust version<6 SMC code in the slide code
|
||||
|
||||
; FIXME: I am sure there's a more clever way to do this
|
||||
|
||||
lda #$2C ; BIT ; 2
|
||||
cpx #$6 ; 2
|
||||
bcs version_greater_than_or_equal_6 ; bgt ; 3
|
||||
; less than 6, jump
|
||||
; also carry is known to be clear
|
||||
adc #$20 ; BIT->JMP 2C->4C ; 2
|
||||
version_greater_than_or_equal_6:
|
||||
sta version_smc ; 4
|
||||
|
||||
pick_volume_table:
|
||||
|
||||
;=======================
|
||||
; Pick which volume number, based on version
|
||||
|
||||
; if (PlParams.PT3.PT3_Version <= 4)
|
||||
|
||||
cpx #5 ; 2
|
||||
|
||||
; carry clear = 3.3/3.4 table
|
||||
; carry set = 3.5 table
|
||||
|
||||
;==========================
|
||||
; VolTableCreator
|
||||
;==========================
|
||||
; Creates the appropriate volume table
|
||||
; based on z80 code by Ivan Roshin ZXAYHOBETA/VTII10bG.asm
|
||||
;
|
||||
|
||||
; Called with carry==0 for 3.3/3.4 table
|
||||
; Called with carry==1 for 3.5 table
|
||||
|
||||
; 177f-1932 = 435 bytes, not that much better than 512 of lookup
|
||||
|
||||
|
||||
VolTableCreator:
|
||||
|
||||
; Init initial variables
|
||||
lda #$0
|
||||
sta z80_d_smc+1
|
||||
ldy #$11
|
||||
|
||||
; Set up self modify
|
||||
|
||||
ldx #$2A ; ROL for self-modify
|
||||
bcs vol_type_35
|
||||
|
||||
vol_type_33:
|
||||
|
||||
; For older table, we set initial conditions a bit
|
||||
; different
|
||||
|
||||
dey
|
||||
tya
|
||||
|
||||
ldx #$ea ; NOP for self modify
|
||||
|
||||
vol_type_35:
|
||||
sty z80_l_smc+1 ; l=16 or 17
|
||||
sta z80_e_smc+1 ; e=16 or 0
|
||||
stx vol_smc ; set the self-modify code
|
||||
|
||||
ldy #16 ; skip first row, all zeros
|
||||
ldx #16 ; c=16
|
||||
vol_outer:
|
||||
clc ; add HL,DE
|
||||
z80_l_smc:
|
||||
lda #$d1
|
||||
z80_e_smc:
|
||||
adc #$d1
|
||||
sta z80_e_smc+1
|
||||
lda #0
|
||||
z80_d_smc:
|
||||
adc #$d1
|
||||
sta z80_d_smc+1 ; carry is important
|
||||
|
||||
; sbc hl,hl
|
||||
lda #0
|
||||
adc #$ff
|
||||
eor #$ff
|
||||
|
||||
vol_write:
|
||||
sta z80_h_smc+1
|
||||
pha
|
||||
|
||||
vol_inner:
|
||||
pla
|
||||
pha
|
||||
|
||||
vol_smc:
|
||||
nop ; nop or ROL depending
|
||||
|
||||
z80_h_smc:
|
||||
lda #$d1
|
||||
|
||||
adc #$0 ; a=a+carry;
|
||||
|
||||
sta VolumeTable,Y
|
||||
iny
|
||||
|
||||
pla ; add HL,DE
|
||||
adc z80_e_smc+1
|
||||
pha
|
||||
lda z80_h_smc+1
|
||||
adc z80_d_smc+1
|
||||
sta z80_h_smc+1
|
||||
|
||||
inx ; inc C
|
||||
txa ; a=c
|
||||
and #$f
|
||||
bne vol_inner
|
||||
|
||||
|
||||
pla
|
||||
|
||||
lda z80_e_smc+1 ; a=e
|
||||
cmp #$77
|
||||
bne vol_m3
|
||||
|
||||
inc z80_e_smc+1
|
||||
|
||||
vol_m3:
|
||||
txa ; a=c
|
||||
bne vol_outer
|
||||
|
||||
vol_done:
|
||||
rts
|
||||
|
||||
|
||||
;=========================================
|
||||
; copy note table seed to proper location
|
||||
;=========================================
|
||||
|
||||
; faster inlined
|
||||
|
||||
;NoteTableCopy:
|
||||
|
||||
; ldy #11 ; !2
|
||||
;note_table_copy_loop:
|
||||
;ntc_smc1:
|
||||
; lda base1_high,Y ; !3
|
||||
; sta NoteTable_high,Y ; !3
|
||||
;ntc_smc2:
|
||||
; lda base1_low,Y ; !3
|
||||
; sta NoteTable_low,Y ; !3
|
||||
; dey ; !1
|
||||
; bpl note_table_copy_loop ; !2
|
||||
; rts ; !1
|
||||
|
||||
|
||||
;==========================================
|
||||
; propogate the freq down, dividing by two
|
||||
;==========================================
|
||||
NoteTablePropogate:
|
||||
|
||||
ldy #0
|
||||
note_table_propogate_loop:
|
||||
clc
|
||||
lda NoteTable_high,Y
|
||||
ror
|
||||
sta NoteTable_high+12,Y
|
||||
|
||||
lda NoteTable_low,Y
|
||||
ror
|
||||
sta NoteTable_low+12,Y
|
||||
|
||||
iny
|
||||
cpy #84
|
||||
bne note_table_propogate_loop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;================================================
|
||||
; propogation isn't enough, various values
|
||||
; are ofte off by one, so adjust using a bitmask
|
||||
;================================================
|
||||
NoteTableAdjust:
|
||||
|
||||
ldx #0
|
||||
note_table_adjust_outer:
|
||||
|
||||
note_table_adjust_smc:
|
||||
lda table0_v4_adjust,X
|
||||
sta PT3_TEMP
|
||||
|
||||
; reset smc
|
||||
lda #<NoteTable_low
|
||||
sta ntl_smc+1
|
||||
lda #>NoteTable_low
|
||||
sta ntl_smc+2
|
||||
|
||||
|
||||
ldy #7
|
||||
note_table_adjust_inner:
|
||||
ror PT3_TEMP
|
||||
bcc note_table_skip_adjust
|
||||
|
||||
ntl_smc:
|
||||
inc NoteTable_low,X
|
||||
|
||||
note_table_skip_adjust:
|
||||
clc
|
||||
lda #12
|
||||
adc ntl_smc+1
|
||||
sta ntl_smc+1
|
||||
lda #0
|
||||
adc ntl_smc+2 ; unnecessary if aligned
|
||||
sta ntl_smc+2
|
||||
|
||||
skip_adjust_done:
|
||||
dey
|
||||
bpl note_table_adjust_inner
|
||||
|
||||
inx
|
||||
cpx #12
|
||||
bne note_table_adjust_outer
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;base0_v3_high:
|
||||
;.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||
;base0_v3_low:
|
||||
;.byte $21,$73,$CE,$33,$A0,$16,$93,$18,$A4,$36,$CE,$6D
|
||||
|
||||
; note: same as base0_v3_high
|
||||
base0_v4_high:
|
||||
.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||
base0_v4_low:
|
||||
.byte $22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF,$6D
|
||||
|
||||
base1_high:
|
||||
.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07
|
||||
base1_low:
|
||||
.byte $F8,$10,$60,$80,$D8,$28,$88,$F0,$60,$E0,$58,$E0
|
||||
|
||||
;base2_v3_high:
|
||||
;.byte $0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07,$07,$07
|
||||
;base2_v3_low:
|
||||
;.byte $3E,$80,$CC,$22,$82,$EC,$5C,$D6,$58,$E0,$6E,$04
|
||||
|
||||
; note almost same as above
|
||||
base2_v4_high:
|
||||
.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||
base2_v4_low:
|
||||
.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8,$3B,$C5,$55,$EC
|
||||
|
||||
; note almost same as above
|
||||
;base3_high:
|
||||
;.byte $0C,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||
base3_low:
|
||||
.byte $DA,$22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF
|
||||
|
||||
|
||||
; Adjustment factors
|
||||
table0_v4_adjust:
|
||||
.byte $40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c,$5a
|
||||
|
||||
table2_v4_adjust:
|
||||
.byte $20,$a8,$40,$f8,$bc,$90,$78,$70,$74,$08,$2a,$50
|
||||
|
||||
table3_v4_adjust:
|
||||
.byte $B4,$40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c
|
||||
|
||||
|
||||
; Table #1 of Pro Tracker 3.3x - 3.5x
|
||||
;PT3NoteTable_ST_high:
|
||||
;.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09
|
||||
;.byte $09,$08,$08,$07,$07,$07,$06,$06
|
||||
;.byte $05,$05,$05,$04,$04,$04,$04,$03
|
||||
;.byte $03,$03,$03,$03,$02,$02,$02,$02
|
||||
;.byte $02,$02,$02,$01,$01,$01,$01,$01
|
||||
;.byte $01,$01,$01,$01,$01,$01,$01,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
;PT3NoteTable_ST_low:
|
||||
;.byte $F8,$10,$60,$80,$D8,$28,$88,$F0
|
||||
;.byte $60,$E0,$58,$E0,$7C,$08,$B0,$40
|
||||
;.byte $EC,$94,$44,$F8,$B0,$70,$2C,$FD
|
||||
;.byte $BE,$84,$58,$20,$F6,$CA,$A2,$7C
|
||||
;.byte $58,$38,$16,$F8,$DF,$C2,$AC,$90
|
||||
;.byte $7B,$65,$51,$3E,$2C,$1C,$0A,$FC
|
||||
;.byte $EF,$E1,$D6,$C8,$BD,$B2,$A8,$9F
|
||||
;.byte $96,$8E,$85,$7E,$77,$70,$6B,$64
|
||||
;.byte $5E,$59,$54,$4F,$4B,$47,$42,$3F
|
||||
;.byte $3B,$38,$35,$32,$2F,$2C,$2A,$27
|
||||
;.byte $25,$23,$21,$1F,$1D,$1C,$1A,$19
|
||||
;.byte $17,$16,$15,$13,$12,$11,$10,$0F
|
||||
|
||||
|
||||
; Table #2 of Pro Tracker 3.4x - 3.5x
|
||||
;PT3NoteTable_ASM_34_35_high:
|
||||
;.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08
|
||||
;.byte $08,$07,$07,$06,$06,$06,$05,$05
|
||||
;.byte $05,$04,$04,$04,$04,$03,$03,$03
|
||||
;.byte $03,$03,$02,$02,$02,$02,$02,$02
|
||||
;.byte $02,$01,$01,$01,$01,$01,$01,$01
|
||||
;.byte $01,$01,$01,$01,$01,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
;PT3NoteTable_ASM_34_35_low:
|
||||
;.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8
|
||||
;.byte $3B,$C5,$55,$EC,$88,$2A,$D2,$7E
|
||||
;.byte $2F,$E5,$9E,$5C,$1D,$E2,$AB,$76
|
||||
;.byte $44,$15,$E9,$BF,$98,$72,$4F,$2E
|
||||
;.byte $0F,$F1,$D5,$BB,$A2,$8B,$74,$60
|
||||
;.byte $4C,$39,$28,$17,$07,$F9,$EB,$DD
|
||||
;.byte $D1,$C5,$BA,$B0,$A6,$9D,$94,$8C
|
||||
;.byte $84,$7C,$75,$6F,$69,$63,$5D,$58
|
||||
;.byte $53,$4E,$4A,$46,$42,$3E,$3B,$37
|
||||
;.byte $34,$31,$2F,$2C,$29,$27,$25,$23
|
||||
;.byte $21,$1F,$1D,$1C,$1A,$19,$17,$16
|
||||
;.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
|
||||
;.byte $0,$0,$0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3
|
||||
;.byte $0,$0,$0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4
|
||||
;.byte $0,$0,$0,$1,$1,$1,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||
;.byte $0,$0,$0,$1,$1,$2,$2,$3,$3,$3,$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,$0,$1,$1,$2,$2,$3,$3,$4,$5,$5,$6,$6,$7,$7,$8
|
||||
;.byte $0,$0,$1,$1,$2,$3,$3,$4,$5,$5,$6,$6,$7,$8,$8,$9
|
||||
;.byte $0,$0,$1,$2,$2,$3,$4,$4,$5,$6,$6,$7,$8,$8,$9,$A
|
||||
;.byte $0,$0,$1,$2,$3,$3,$4,$5,$6,$6,$7,$8,$9,$9,$A,$B
|
||||
;.byte $0,$0,$1,$2,$3,$4,$4,$5,$6,$7,$8,$8,$9,$A,$B,$C
|
||||
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$7,$7,$8,$9,$A,$B,$C,$D
|
||||
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$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
|
||||
|
||||
;PT3VolumeTable_35:
|
||||
;.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,$1,$1,$1,$1,$1,$1,$1,$1,$2,$2,$2,$2
|
||||
;.byte $0,$0,$0,$1,$1,$1,$1,$1,$2,$2,$2,$2,$2,$3,$3,$3
|
||||
;.byte $0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3,$4,$4
|
||||
;.byte $0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||
;.byte $0,$0,$1,$1,$2,$2,$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
|
109
pt3_player/pt3_lib_irq_handler.s
Normal file
109
pt3_player/pt3_lib_irq_handler.s
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
|
||||
pt3_irq_handler:
|
||||
|
||||
bit $C404 ; clear 6522 interrupt by reading T1C-L ; 4
|
||||
|
||||
lda DONE_PLAYING ; 3
|
||||
beq pt3_play_music ; if song done, don't play music ; 3/2nt
|
||||
jmp done_pt3_irq_handler ; 3
|
||||
;============
|
||||
; 13
|
||||
|
||||
pt3_play_music:
|
||||
|
||||
; decode a frame of music
|
||||
|
||||
jsr pt3_make_frame
|
||||
|
||||
; handle song over condition
|
||||
lda DONE_SONG
|
||||
beq mb_write_frame ; if not done, continue
|
||||
|
||||
lda LOOP ; see if looping
|
||||
beq move_to_next
|
||||
|
||||
pt3_loop_smc:
|
||||
lda #$d1 ; looping, move to loop location
|
||||
; non-zero to avoid the temptation
|
||||
; to merge with following lda #$0
|
||||
sta current_pattern_smc+1
|
||||
lda #$0
|
||||
sta current_line_smc+1
|
||||
sta current_subframe_smc+1
|
||||
sta DONE_SONG ; undo the next song
|
||||
|
||||
beq done_pt3_irq_handler ; branch always
|
||||
|
||||
move_to_next:
|
||||
; same as "press right"
|
||||
ldx #$20
|
||||
jmp quiet_exit
|
||||
|
||||
;======================================
|
||||
; Write frames to Mockingboard
|
||||
;======================================
|
||||
; for speed could merge this into
|
||||
; the decode code
|
||||
|
||||
mb_write_frame:
|
||||
|
||||
|
||||
tax ; 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:
|
||||
|
||||
|
||||
;=================================
|
||||
; Finally done with this interrupt
|
||||
;=================================
|
||||
|
||||
done_pt3_irq_handler:
|
@ -10,6 +10,8 @@
|
||||
; If you change this, you need to update the Makefile
|
||||
PT3_LOC = $4000
|
||||
|
||||
PT3_USE_ZERO_PAGE = 1
|
||||
|
||||
; Number of files. Should probably detect this automatically
|
||||
NUM_FILES = 19
|
||||
|
||||
@ -724,8 +726,14 @@ song_list:
|
||||
.include "gr_setpage.s"
|
||||
.include "qkumba_rts.s"
|
||||
.include "keypress_minimal.s"
|
||||
|
||||
|
||||
; pt3_lib stuff
|
||||
.include "pt3_lib_core.s"
|
||||
.include "pt3_lib_init.s"
|
||||
.include "interrupt_handler.s"
|
||||
.include "pt3_lib.s"
|
||||
|
||||
; visualization
|
||||
.include "fire.s"
|
||||
.include "random16.s"
|
||||
.include "gr_putsprite.s"
|
||||
|
@ -136,7 +136,8 @@ error:
|
||||
;routines
|
||||
;=========
|
||||
|
||||
.include "pt3_lib.s"
|
||||
.include "pt3_lib_core.s"
|
||||
.include "pt3_lib_init.s"
|
||||
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
PT3_LOC = $4000
|
||||
|
||||
NUM_FILES = 15
|
||||
PT3_USE_ZERO_PAGE = 1
|
||||
|
||||
;=============================
|
||||
; Setup
|
||||
@ -240,31 +240,6 @@ filename_found:
|
||||
|
||||
rts
|
||||
|
||||
;===============================
|
||||
; Increment file we want to load
|
||||
;===============================
|
||||
increment_file:
|
||||
inc WHICH_FILE
|
||||
lda WHICH_FILE
|
||||
cmp #NUM_FILES
|
||||
bne done_increment
|
||||
lda #0
|
||||
sta WHICH_FILE
|
||||
done_increment:
|
||||
rts
|
||||
|
||||
;===============================
|
||||
; Decrement file we want to load
|
||||
;===============================
|
||||
decrement_file:
|
||||
dec WHICH_FILE
|
||||
bpl done_decrement
|
||||
lda #(NUM_FILES-1)
|
||||
sta WHICH_FILE
|
||||
done_decrement:
|
||||
rts
|
||||
|
||||
|
||||
;==========
|
||||
; filenames
|
||||
;==========
|
||||
@ -278,7 +253,9 @@ song_list:
|
||||
;=========
|
||||
.include "mockingboard_a.s"
|
||||
.include "qkumba_rts.s"
|
||||
.include "pt3_lib.s"
|
||||
|
||||
.include "pt3_lib_core.s"
|
||||
.include "pt3_lib_init.s"
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user