2019-05-22 19:52:05 +00:00
|
|
|
;===========================================
|
|
|
|
; Library to decode Vortex Tracker PT3 files
|
|
|
|
; in 6502 assembly for Apple ][ Mockingboard
|
|
|
|
;
|
|
|
|
; by Vince Weaver <vince@deater.net>
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
; Roughly based on the Formats.pas Pascal code from Ay_Emul
|
2019-05-22 19:52:05 +00:00
|
|
|
|
|
|
|
; Size Optimization -- Mem+Code (pt3_lib_end-note_a)
|
|
|
|
; + 3407 bytes -- original working implementation
|
|
|
|
; + 3302 bytes -- autogenerate the volume tables
|
2019-05-22 21:08:52 +00:00
|
|
|
; + 3297 bytes -- remove some un-needed bytes from struct
|
|
|
|
; + 3262 bytes -- combine some duplicated code in $1X/$BX env setting
|
2019-05-24 00:53:41 +00:00
|
|
|
; + 3253 bytes -- remove unnecessary variable
|
2019-05-24 05:08:36 +00:00
|
|
|
; + 3203 bytes -- combine common code in note decoder
|
2019-05-22 19:52:05 +00:00
|
|
|
|
2019-05-07 04:28:42 +00:00
|
|
|
; TODO
|
|
|
|
; move some of these flags to be bits rather than bytes?
|
|
|
|
; enabled could be bit 6 or 7 for fast checking
|
2019-05-24 00:53:41 +00:00
|
|
|
; NOTE_ENABLED,ENVELOPE_ENABLED,SIMPLE_GLISS,ENV_SLIDING,AMP_SLIDING?
|
|
|
|
|
|
|
|
|
2019-05-07 04:28:42 +00:00
|
|
|
; Use memset to set things to 0?
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
NOTE_VOLUME =0
|
|
|
|
NOTE_TONE_SLIDING_L =1
|
|
|
|
NOTE_TONE_SLIDING_H =2
|
|
|
|
NOTE_ENABLED =3
|
|
|
|
NOTE_ENVELOPE_ENABLED =4
|
|
|
|
NOTE_SAMPLE_POINTER_L =5
|
|
|
|
NOTE_SAMPLE_POINTER_H =6
|
|
|
|
NOTE_SAMPLE_LOOP =7
|
|
|
|
NOTE_SAMPLE_LENGTH =8
|
|
|
|
NOTE_TONE_L =9
|
|
|
|
NOTE_TONE_H =10
|
|
|
|
NOTE_AMPLITUDE =11
|
|
|
|
NOTE_NOTE =12
|
|
|
|
NOTE_LEN =13
|
|
|
|
NOTE_LEN_COUNT =14
|
2019-05-24 00:53:41 +00:00
|
|
|
NOTE_ADDR_L =15
|
|
|
|
NOTE_ADDR_H =16
|
|
|
|
NOTE_ORNAMENT_POINTER_L =17
|
|
|
|
NOTE_ORNAMENT_POINTER_H =18
|
|
|
|
NOTE_ORNAMENT_LOOP =19
|
|
|
|
NOTE_ORNAMENT_LENGTH =20
|
|
|
|
NOTE_ONOFF =21
|
|
|
|
NOTE_TONE_ACCUMULATOR_L =22
|
|
|
|
NOTE_TONE_ACCUMULATOR_H =23
|
|
|
|
NOTE_TONE_SLIDE_COUNT =24
|
|
|
|
NOTE_ORNAMENT_POSITION =25
|
|
|
|
NOTE_SAMPLE_POSITION =26
|
|
|
|
NOTE_ENVELOPE_SLIDING =27
|
|
|
|
NOTE_NOISE_SLIDING =28
|
|
|
|
NOTE_AMPLITUDE_SLIDING =29
|
2019-05-30 14:53:33 +00:00
|
|
|
NOTE_ONOFF_DELAY =30
|
|
|
|
NOTE_OFFON_DELAY =31
|
2019-05-24 00:53:41 +00:00
|
|
|
NOTE_TONE_SLIDE_STEP_L =32
|
|
|
|
NOTE_TONE_SLIDE_STEP_H =33
|
|
|
|
NOTE_TONE_SLIDE_DELAY =34
|
|
|
|
NOTE_SIMPLE_GLISS =35
|
|
|
|
NOTE_SLIDE_TO_NOTE =36
|
|
|
|
NOTE_TONE_DELTA_L =37
|
|
|
|
NOTE_TONE_DELTA_H =38
|
|
|
|
NOTE_TONE_SLIDE_TO_STEP =39
|
|
|
|
|
|
|
|
NOTE_STRUCT_SIZE=40
|
2019-05-13 04:36:44 +00:00
|
|
|
|
2019-05-07 04:28:42 +00:00
|
|
|
note_a:
|
|
|
|
.byte $0 ; NOTE_VOLUME
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDING_L
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDING_H
|
2019-05-07 04:28:42 +00:00
|
|
|
.byte $0 ; NOTE_ENABLED
|
|
|
|
.byte $0 ; NOTE_ENVELOPE_ENABLED
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_SAMPLE_POINTER_L
|
|
|
|
.byte $0 ; NOTE_SAMPLE_POINTER_H
|
2019-05-07 04:28:42 +00:00
|
|
|
.byte $0 ; NOTE_SAMPLE_LOOP
|
|
|
|
.byte $0 ; NOTE_SAMPLE_LENGTH
|
2019-05-07 19:11:52 +00:00
|
|
|
.byte $0 ; NOTE_TONE_L
|
|
|
|
.byte $0 ; NOTE_TONE_H
|
|
|
|
.byte $0 ; NOTE_AMPLITUDE
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_NOTE
|
|
|
|
.byte $0 ; NOTE_LEN
|
|
|
|
.byte $0 ; NOTE_LEN_COUNT
|
2019-05-10 04:22:17 +00:00
|
|
|
.byte $0 ; NOTE_ADDR_L
|
|
|
|
.byte $0 ; NOTE_ADDR_H
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POINTER_L
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POINTER_H
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_LOOP
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_LENGTH
|
2019-05-10 16:20:44 +00:00
|
|
|
.byte $0 ; NOTE_ONOFF
|
|
|
|
.byte $0 ; NOTE_TONE_ACCUMULATOR_L
|
|
|
|
.byte $0 ; NOTE_TONE_ACCUMULATOR_H
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_COUNT
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POSITION
|
|
|
|
.byte $0 ; NOTE_SAMPLE_POSITION
|
|
|
|
.byte $0 ; NOTE_ENVELOPE_SLIDING
|
|
|
|
.byte $0 ; NOTE_NOISE_SLIDING
|
|
|
|
.byte $0 ; NOTE_AMPLITUDE_SLIDING
|
2019-05-11 03:06:56 +00:00
|
|
|
.byte $0 ; NOTE_ONOFF_DELAY
|
|
|
|
.byte $0 ; NOTE_OFFON_DELAY
|
2019-05-13 00:55:13 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_STEP_L
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_STEP_H
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_DELAY
|
|
|
|
.byte $0 ; NOTE_SIMPLE_GLISS
|
|
|
|
.byte $0 ; NOTE_SLIDE_TO_NOTE
|
2019-05-13 03:32:58 +00:00
|
|
|
.byte $0 ; NOTE_TONE_DELTA_L
|
|
|
|
.byte $0 ; NOTE_TONE_DELTA_H
|
2019-05-13 00:55:13 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_TO_STEP
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-07 04:28:42 +00:00
|
|
|
note_b:
|
|
|
|
.byte $0 ; NOTE_VOLUME
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDING_L
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDING_H
|
2019-05-07 04:28:42 +00:00
|
|
|
.byte $0 ; NOTE_ENABLED
|
|
|
|
.byte $0 ; NOTE_ENVELOPE_ENABLED
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_SAMPLE_POINTER_L
|
|
|
|
.byte $0 ; NOTE_SAMPLE_POINTER_H
|
2019-05-07 04:28:42 +00:00
|
|
|
.byte $0 ; NOTE_SAMPLE_LOOP
|
|
|
|
.byte $0 ; NOTE_SAMPLE_LENGTH
|
2019-05-07 19:11:52 +00:00
|
|
|
.byte $0 ; NOTE_TONE_L
|
|
|
|
.byte $0 ; NOTE_TONE_H
|
|
|
|
.byte $0 ; NOTE_AMPLITUDE
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_NOTE
|
|
|
|
.byte $0 ; NOTE_LEN
|
|
|
|
.byte $0 ; NOTE_LEN_COUNT
|
2019-05-10 04:22:17 +00:00
|
|
|
.byte $0 ; NOTE_ADDR_L
|
|
|
|
.byte $0 ; NOTE_ADDR_H
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POINTER_L
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POINTER_H
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_LOOP
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_LENGTH
|
2019-05-10 16:20:44 +00:00
|
|
|
.byte $0 ; NOTE_ONOFF
|
|
|
|
.byte $0 ; NOTE_TONE_ACCUMULATOR_L
|
|
|
|
.byte $0 ; NOTE_TONE_ACCUMULATOR_H
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_COUNT
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POSITION
|
|
|
|
.byte $0 ; NOTE_SAMPLE_POSITION
|
|
|
|
.byte $0 ; NOTE_ENVELOPE_SLIDING
|
|
|
|
.byte $0 ; NOTE_NOISE_SLIDING
|
|
|
|
.byte $0 ; NOTE_AMPLITUDE_SLIDING
|
2019-05-11 03:06:56 +00:00
|
|
|
.byte $0 ; NOTE_ONOFF_DELAY
|
|
|
|
.byte $0 ; NOTE_OFFON_DELAY
|
2019-05-13 00:55:13 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_STEP_L
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_STEP_H
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_DELAY
|
|
|
|
.byte $0 ; NOTE_SIMPLE_GLISS
|
|
|
|
.byte $0 ; NOTE_SLIDE_TO_NOTE
|
2019-05-13 03:32:58 +00:00
|
|
|
.byte $0 ; NOTE_TONE_DELTA_L
|
|
|
|
.byte $0 ; NOTE_TONE_DELTA_H
|
2019-05-13 00:55:13 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_TO_STEP
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-07 04:28:42 +00:00
|
|
|
note_c:
|
|
|
|
.byte $0 ; NOTE_VOLUME
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDING_L
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDING_H
|
2019-05-07 04:28:42 +00:00
|
|
|
.byte $0 ; NOTE_ENABLED
|
|
|
|
.byte $0 ; NOTE_ENVELOPE_ENABLED
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_SAMPLE_POINTER_L
|
|
|
|
.byte $0 ; NOTE_SAMPLE_POINTER_H
|
2019-05-07 04:28:42 +00:00
|
|
|
.byte $0 ; NOTE_SAMPLE_LOOP
|
|
|
|
.byte $0 ; NOTE_SAMPLE_LENGTH
|
2019-05-07 19:11:52 +00:00
|
|
|
.byte $0 ; NOTE_TONE_L
|
|
|
|
.byte $0 ; NOTE_TONE_H
|
|
|
|
.byte $0 ; NOTE_AMPLITUDE
|
2019-05-09 17:40:54 +00:00
|
|
|
.byte $0 ; NOTE_NOTE
|
|
|
|
.byte $0 ; NOTE_LEN
|
|
|
|
.byte $0 ; NOTE_LEN_COUNT
|
2019-05-10 04:22:17 +00:00
|
|
|
.byte $0 ; NOTE_ADDR_L
|
|
|
|
.byte $0 ; NOTE_ADDR_H
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POINTER_L
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POINTER_H
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_LOOP
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_LENGTH
|
2019-05-10 16:20:44 +00:00
|
|
|
.byte $0 ; NOTE_ONOFF
|
|
|
|
.byte $0 ; NOTE_TONE_ACCUMULATOR_L
|
|
|
|
.byte $0 ; NOTE_TONE_ACCUMULATOR_H
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_COUNT
|
|
|
|
.byte $0 ; NOTE_ORNAMENT_POSITION
|
|
|
|
.byte $0 ; NOTE_SAMPLE_POSITION
|
|
|
|
.byte $0 ; NOTE_ENVELOPE_SLIDING
|
|
|
|
.byte $0 ; NOTE_NOISE_SLIDING
|
|
|
|
.byte $0 ; NOTE_AMPLITUDE_SLIDING
|
2019-05-11 03:06:56 +00:00
|
|
|
.byte $0 ; NOTE_ONOFF_DELAY
|
|
|
|
.byte $0 ; NOTE_OFFON_DELAY
|
2019-05-13 00:55:13 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_STEP_L
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_STEP_H
|
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_DELAY
|
|
|
|
.byte $0 ; NOTE_SIMPLE_GLISS
|
|
|
|
.byte $0 ; NOTE_SLIDE_TO_NOTE
|
2019-05-13 03:32:58 +00:00
|
|
|
.byte $0 ; NOTE_TONE_DELTA_L
|
|
|
|
.byte $0 ; NOTE_TONE_DELTA_H
|
2019-05-13 00:55:13 +00:00
|
|
|
.byte $0 ; NOTE_TONE_SLIDE_TO_STEP
|
2019-05-07 04:28:42 +00:00
|
|
|
|
2019-05-09 04:28:52 +00:00
|
|
|
pt3_version: .byte $0
|
|
|
|
pt3_frequency_table: .byte $0
|
|
|
|
pt3_speed: .byte $0
|
|
|
|
pt3_loop: .byte $0
|
|
|
|
|
2019-05-07 04:28:42 +00:00
|
|
|
pt3_noise_period: .byte $0
|
|
|
|
pt3_noise_add: .byte $0
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-09 15:27:08 +00:00
|
|
|
pt3_envelope_period_l: .byte $0
|
|
|
|
pt3_envelope_period_h: .byte $0
|
|
|
|
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
|
2019-05-07 19:11:52 +00:00
|
|
|
pt3_envelope_add: .byte $0
|
2019-05-07 04:28:42 +00:00
|
|
|
pt3_envelope_type: .byte $0
|
2019-05-09 04:28:52 +00:00
|
|
|
pt3_envelope_type_old: .byte $0
|
2019-05-09 15:27:08 +00:00
|
|
|
pt3_envelope_delay: .byte $0
|
|
|
|
pt3_envelope_delay_orig:.byte $0
|
2019-05-07 19:11:52 +00:00
|
|
|
|
|
|
|
pt3_mixer_value: .byte $0
|
2019-05-07 04:28:42 +00:00
|
|
|
|
2019-05-14 15:52:50 +00:00
|
|
|
pt3_pattern_done: .byte $0
|
|
|
|
|
2019-05-09 15:27:08 +00:00
|
|
|
temp_word_l: .byte $0
|
|
|
|
temp_word_h: .byte $0
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
note_command: ; shared space with sample_b0
|
2019-05-11 03:06:56 +00:00
|
|
|
sample_b0: .byte $0
|
|
|
|
sample_b1: .byte $0
|
2019-05-09 15:27:08 +00:00
|
|
|
|
2019-05-17 00:33:12 +00:00
|
|
|
convert_177: .byte $1
|
|
|
|
|
2019-05-07 15:33:07 +00:00
|
|
|
; Header offsets
|
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
PT3_VERSION = $0D
|
2019-05-10 04:22:17 +00:00
|
|
|
PT3_HEADER_FREQUENCY = $63
|
2019-05-14 14:45:55 +00:00
|
|
|
PT3_SPEED = $64
|
2019-05-17 17:19:04 +00:00
|
|
|
PT3_LOOP = $66
|
2019-05-10 04:22:17 +00:00
|
|
|
PT3_PATTERN_LOC_L = $67
|
|
|
|
PT3_PATTERN_LOC_H = $68
|
|
|
|
PT3_SAMPLE_LOC_L = $69
|
|
|
|
PT3_SAMPLE_LOC_H = $6A
|
|
|
|
PT3_ORNAMENT_LOC_L = $A9
|
2019-05-22 19:52:05 +00:00
|
|
|
PT3_ORNAMENT_LOC_H = $AA
|
2019-05-10 04:22:17 +00:00
|
|
|
PT3_PATTERN_TABLE = $C9
|
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
ysave: .byte $00
|
|
|
|
freq_l: .byte $00
|
|
|
|
freq_h: .byte $00
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-20 14:11:29 +00: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
|
|
|
|
|
2019-05-10 04:22:17 +00:00
|
|
|
;===========================
|
|
|
|
; Load Ornament
|
|
|
|
;===========================
|
2019-05-11 03:06:56 +00:00
|
|
|
; ornament value in A
|
2019-05-13 16:47:29 +00:00
|
|
|
; note offset in X
|
2019-05-07 15:33:07 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
; Ornament table pointers are 16-bits little endian
|
|
|
|
; There are 16 of these pointers starting at $aa:$a9
|
|
|
|
; Our ornament starts at address (A*2)+that pointer
|
|
|
|
; We point ORNAMENT_H:ORNAMENT_L to this
|
|
|
|
; then we load the length/data values
|
|
|
|
; and then leave ORNAMENT_H:ORNAMENT_L pointing to begnning of
|
|
|
|
; the ornament data
|
|
|
|
|
|
|
|
; Optimization:
|
|
|
|
; Loop and length only used once, can be located negative
|
|
|
|
; from the pointer, but 6502 doesn't make addressing like that
|
|
|
|
; easy. Can't self modify as channels A/B/C have own copies
|
|
|
|
; of the var.
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
load_ornament:
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
sty ysave ; save Y value ; 3
|
2019-05-11 03:06:56 +00:00
|
|
|
|
|
|
|
;pt3->ornament_patterns[i]=
|
|
|
|
; (pt3->data[0xaa+(i*2)]<<8)|pt3->data[0xa9+(i*2)];
|
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
asl ; A*2 ; 2
|
2019-05-30 14:53:33 +00:00
|
|
|
adc #PT3_ORNAMENT_LOC_L ; 2
|
2019-05-20 02:11:56 +00:00
|
|
|
tay ; 2
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
; a->ornament_pointer=pt3->ornament_patterns[a->ornament];
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
lda PT3_LOC,Y ; 4+
|
2019-05-20 02:11:56 +00:00
|
|
|
sta ORNAMENT_L ; 3
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
iny ; 2
|
|
|
|
lda PT3_LOC,Y ; 4+
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
; we're assuming PT3 is loaded to a page boundary
|
|
|
|
|
|
|
|
adc #>PT3_LOC ; 2
|
|
|
|
sta ORNAMENT_H ; 3
|
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
lda #0 ; 2
|
|
|
|
sta note_a+NOTE_ORNAMENT_POSITION,X ; 5
|
|
|
|
|
|
|
|
tay ; 2
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
; Set the loop value
|
|
|
|
; a->ornament_loop=pt3->data[a->ornament_pointer];
|
2019-05-20 02:11:56 +00:00
|
|
|
lda (ORNAMENT_L),Y ; 5+
|
|
|
|
sta note_a+NOTE_ORNAMENT_LOOP,X ; 5
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
; Set the length value
|
|
|
|
; a->ornament_length=pt3->data[a->ornament_pointer];
|
2019-05-20 02:11:56 +00:00
|
|
|
iny ; 2
|
|
|
|
lda (ORNAMENT_L),Y ; 5+
|
|
|
|
sta note_a+NOTE_ORNAMENT_LENGTH,X ; 5
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
; Set the pointer to the value past the length
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
lda ORNAMENT_L ; 3
|
|
|
|
adc #$2 ; 2
|
|
|
|
sta note_a+NOTE_ORNAMENT_POINTER_L,X ; 5
|
|
|
|
lda ORNAMENT_H ; 3
|
|
|
|
adc #$0 ; 2
|
|
|
|
sta note_a+NOTE_ORNAMENT_POINTER_H,X ; 5
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
ldy ysave ; restore Y value ; 3
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
rts ; 6
|
|
|
|
|
|
|
|
;============
|
2019-06-01 04:15:50 +00:00
|
|
|
; 87
|
2019-05-07 04:28:42 +00:00
|
|
|
|
2019-05-10 04:22:17 +00:00
|
|
|
;===========================
|
|
|
|
; Load Sample
|
|
|
|
;===========================
|
2019-05-12 04:14:09 +00:00
|
|
|
; sample in A
|
2019-05-13 16:47:29 +00:00
|
|
|
; which note offset in X
|
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
; Sample table pointers are 16-bits little endian
|
|
|
|
; There are 32 of these pointers starting at $6a:$69
|
|
|
|
; Our sample starts at address (A*2)+that pointer
|
|
|
|
; We point SAMPLE_H:SAMPLE_L to this
|
|
|
|
; then we load the length/data values
|
|
|
|
; and then leave SAMPLE_H:SAMPLE_L pointing to begnning of
|
|
|
|
; the sample data
|
|
|
|
|
|
|
|
; Optimization:
|
|
|
|
; see comments on ornament setting
|
|
|
|
|
2019-05-07 04:28:42 +00:00
|
|
|
load_sample:
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
sty ysave ; 3
|
2019-05-12 04:14:09 +00:00
|
|
|
|
|
|
|
;pt3->ornament_patterns[i]=
|
|
|
|
; (pt3->data[0x6a+(i*2)]<<8)|pt3->data[0x69+(i*2)];
|
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
asl ; A*2 ; 2
|
2019-05-30 14:53:33 +00:00
|
|
|
adc #PT3_SAMPLE_LOC_L ; 2
|
2019-05-20 02:11:56 +00:00
|
|
|
tay ; 2
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
; Set the initial sample pointer
|
|
|
|
; a->sample_pointer=pt3->sample_patterns[a->sample];
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
lda PT3_LOC,Y ; 4+
|
2019-05-20 02:11:56 +00:00
|
|
|
sta SAMPLE_L ; 3
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
iny ; 2
|
|
|
|
lda PT3_LOC,Y ; 4+
|
2019-05-20 02:11:56 +00:00
|
|
|
|
|
|
|
; assume pt3 file is at page boundary
|
|
|
|
adc #>PT3_LOC ; 2
|
|
|
|
sta SAMPLE_H ; 3
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
; Set the loop value
|
|
|
|
; a->sample_loop=pt3->data[a->sample_pointer];
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
ldy #0 ; 2
|
|
|
|
lda (SAMPLE_L),Y ; 5+
|
|
|
|
sta note_a+NOTE_SAMPLE_LOOP,X ; 5
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
; Set the length value
|
|
|
|
; a->sample_length=pt3->data[a->sample_pointer];
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
iny ; 2
|
|
|
|
lda (SAMPLE_L),Y ; 5+
|
|
|
|
sta note_a+NOTE_SAMPLE_LENGTH,X ; 5
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
; Set pointer to beginning of samples
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
lda SAMPLE_L ; 3
|
|
|
|
adc #$2 ; 2
|
|
|
|
sta note_a+NOTE_SAMPLE_POINTER_L,X ; 5
|
|
|
|
lda SAMPLE_H ; 3
|
|
|
|
adc #$0 ; 2
|
|
|
|
sta note_a+NOTE_SAMPLE_POINTER_H,X ; 5
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
ldy ysave ; 3
|
2019-05-07 04:28:42 +00:00
|
|
|
|
2019-05-20 02:11:56 +00:00
|
|
|
rts ; 6
|
|
|
|
;============
|
2019-06-01 04:15:50 +00:00
|
|
|
; 80
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
;====================================
|
|
|
|
; pt3_init_song
|
|
|
|
;====================================
|
|
|
|
;
|
2019-05-20 03:42:13 +00:00
|
|
|
; TODO: change to a memset type instruction?
|
2019-06-01 04:15:50 +00:00
|
|
|
; it will save bytes only if the labels are adjacent
|
|
|
|
; it will add a lot more cycles, though
|
2019-05-07 04:28:42 +00:00
|
|
|
pt3_init_song:
|
2019-05-20 03:42:13 +00:00
|
|
|
lda #$f ; 2
|
|
|
|
sta note_a+NOTE_VOLUME ; 4
|
|
|
|
sta note_b+NOTE_VOLUME ; 4
|
|
|
|
sta note_c+NOTE_VOLUME ; 4
|
|
|
|
|
|
|
|
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
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_H ; 4
|
|
|
|
sta note_b+NOTE_TONE_SLIDING_H ; 4
|
|
|
|
sta note_c+NOTE_TONE_SLIDING_H ; 4
|
|
|
|
sta note_a+NOTE_ENABLED ; 4
|
|
|
|
sta note_b+NOTE_ENABLED ; 4
|
|
|
|
sta note_c+NOTE_ENABLED ; 4
|
|
|
|
sta note_a+NOTE_ENVELOPE_ENABLED ; 4
|
|
|
|
sta note_b+NOTE_ENVELOPE_ENABLED ; 4
|
|
|
|
sta note_c+NOTE_ENVELOPE_ENABLED ; 4
|
|
|
|
|
|
|
|
sta pt3_noise_period ; 4
|
|
|
|
sta pt3_noise_add ; 4
|
|
|
|
sta pt3_envelope_period_l ; 4
|
|
|
|
sta pt3_envelope_period_h ; 4
|
|
|
|
sta pt3_envelope_type ; 4
|
2019-05-13 16:47:29 +00:00
|
|
|
|
|
|
|
; default ornament/sample in A
|
2019-05-20 03:42:13 +00:00
|
|
|
ldx #(NOTE_STRUCT_SIZE*0) ; 2
|
2019-05-24 05:08:36 +00:00
|
|
|
jsr load_ornament ; 6+93
|
2019-05-20 03:42:13 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
jsr load_sample ; 6+86
|
2019-05-13 16:47:29 +00:00
|
|
|
|
|
|
|
; default ornament/sample in B
|
2019-05-20 03:42:13 +00:00
|
|
|
lda #0 ; 2
|
|
|
|
ldx #(NOTE_STRUCT_SIZE*1) ; 2
|
2019-05-24 05:08:36 +00:00
|
|
|
jsr load_ornament ; 6+93
|
2019-05-20 03:42:13 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
jsr load_sample ; 6+86
|
2019-05-13 16:47:29 +00:00
|
|
|
|
|
|
|
; default ornament/sample in C
|
2019-05-20 03:42:13 +00:00
|
|
|
lda #0 ; 2
|
|
|
|
ldx #(NOTE_STRUCT_SIZE*2) ; 2
|
2019-05-24 05:08:36 +00:00
|
|
|
jsr load_ornament ; 6+93
|
2019-05-20 03:42:13 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
jsr load_sample ; 6+86
|
2019-05-07 04:28:42 +00:00
|
|
|
|
2019-05-22 19:37:00 +00:00
|
|
|
;=======================
|
|
|
|
; load default speed
|
|
|
|
; FIXME: change to self-modifying code
|
|
|
|
|
|
|
|
lda PT3_LOC+PT3_SPEED ; 4
|
|
|
|
sta pt3_speed ; 4
|
|
|
|
|
|
|
|
;=======================
|
|
|
|
; load loop
|
|
|
|
; FIXME: change to self-modifying code
|
|
|
|
|
|
|
|
lda PT3_LOC+PT3_LOOP ; 4
|
|
|
|
sta pt3_loop ; 4
|
|
|
|
|
2019-05-14 02:41:07 +00:00
|
|
|
|
|
|
|
;======================
|
|
|
|
; calculate version
|
2019-06-01 04:19:44 +00:00
|
|
|
ldx #6 ; 2
|
2019-05-20 03:42:13 +00:00
|
|
|
lda PT3_LOC+PT3_VERSION ; 4
|
|
|
|
sec ; 2
|
|
|
|
sbc #'0' ; 2
|
2019-06-01 04:19:44 +00:00
|
|
|
cmp #9 ; 2
|
|
|
|
bcs not_ascii_number ; bge ; 2/3
|
|
|
|
tax ; 2
|
2019-05-14 02:41:07 +00:00
|
|
|
|
2019-05-14 15:15:12 +00:00
|
|
|
not_ascii_number:
|
2019-06-01 04:19:44 +00:00
|
|
|
stx pt3_version ; 3
|
2019-05-14 15:15:12 +00:00
|
|
|
|
2019-05-14 14:45:55 +00:00
|
|
|
;=======================
|
2019-05-22 19:37:00 +00:00
|
|
|
; Pick which volume number, based on version
|
2019-05-14 14:45:55 +00:00
|
|
|
|
2019-05-22 19:37:00 +00:00
|
|
|
; if (PlParams.PT3.PT3_Version <= 4)
|
2019-05-14 14:45:55 +00:00
|
|
|
|
2019-06-01 04:19:44 +00:00
|
|
|
cpx #5 ; 2
|
2019-05-17 17:19:04 +00:00
|
|
|
|
2019-05-22 19:37:00 +00:00
|
|
|
; carry clear = 3.3/3.4 table
|
|
|
|
; carry set = 3.5 table
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jsr VolTableCreator ; 6+??
|
2019-05-17 17:19:04 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
rts ; 6
|
2019-05-07 04:28:42 +00:00
|
|
|
|
2019-05-15 18:13:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
|
2019-05-13 01:30:01 +00:00
|
|
|
|
2019-05-15 18:13:54 +00:00
|
|
|
|
2019-05-07 15:33:07 +00:00
|
|
|
;=====================================
|
|
|
|
; Calculate Note
|
|
|
|
;=====================================
|
2019-05-13 04:36:44 +00:00
|
|
|
; note offset in X
|
|
|
|
|
2019-05-07 19:11:52 +00:00
|
|
|
calculate_note:
|
2019-05-09 04:28:52 +00:00
|
|
|
|
2019-05-22 19:52:05 +00:00
|
|
|
lda note_a+NOTE_ENABLED,X ; 4+
|
|
|
|
bne note_enabled ; 2/3
|
2019-05-09 04:28:52 +00:00
|
|
|
|
2019-05-22 19:52:05 +00:00
|
|
|
sta note_a+NOTE_AMPLITUDE,X ; 5
|
|
|
|
jmp done_note ; 3
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
note_enabled:
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-22 19:52:05 +00:00
|
|
|
lda note_a+NOTE_SAMPLE_POINTER_H,X ; 4+
|
|
|
|
sta SAMPLE_H ; 3
|
|
|
|
lda note_a+NOTE_SAMPLE_POINTER_L,X ; 4+
|
|
|
|
sta SAMPLE_L ; 3
|
2019-05-13 16:59:59 +00:00
|
|
|
|
2019-05-22 19:52:05 +00:00
|
|
|
lda note_a+NOTE_ORNAMENT_POINTER_H,X ; 4+
|
|
|
|
sta ORNAMENT_H ; 3
|
|
|
|
lda note_a+NOTE_ORNAMENT_POINTER_L,X ; 4+
|
|
|
|
sta ORNAMENT_L ; 3
|
2019-05-13 16:59:59 +00:00
|
|
|
|
|
|
|
|
2019-05-22 19:52:05 +00:00
|
|
|
lda note_a+NOTE_SAMPLE_POSITION,X ; 4+
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
tay ; 2
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
; b0 = pt3->data[a->sample_pointer + a->sample_position * 4];
|
2019-05-22 21:08:52 +00:00
|
|
|
lda (SAMPLE_L),Y ; 5+
|
|
|
|
sta sample_b0 ; 4
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
; b1 = pt3->data[a->sample_pointer + a->sample_position * 4 + 1];
|
2019-05-22 21:08:52 +00:00
|
|
|
iny ; 2
|
|
|
|
lda (SAMPLE_L),Y ; 5+
|
|
|
|
sta sample_b1 ; 4
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
; a->tone = pt3->data[a->sample_pointer + a->sample_position*4+2];
|
|
|
|
; a->tone+=(pt3->data[a->sample_pointer + a->sample_position*4+3])<<8;
|
2019-06-01 04:26:29 +00:00
|
|
|
; a->tone += a->tone_accumulator;
|
2019-05-22 21:08:52 +00:00
|
|
|
iny ; 2
|
2019-06-01 04:26:29 +00:00
|
|
|
clc ; 2
|
2019-05-22 21:08:52 +00:00
|
|
|
lda (SAMPLE_L),Y ; 5+
|
2019-06-01 04:26:29 +00:00
|
|
|
adc note_a+NOTE_TONE_ACCUMULATOR_L,X ; 4+
|
2019-05-22 21:08:52 +00:00
|
|
|
sta note_a+NOTE_TONE_L,X ; 4
|
2019-05-12 04:14:09 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
iny ; 2
|
|
|
|
lda (SAMPLE_L),Y ; 5+
|
2019-05-30 14:54:03 +00:00
|
|
|
adc note_a+NOTE_TONE_ACCUMULATOR_H,X ; 4+
|
2019-06-01 04:26:29 +00:00
|
|
|
sta note_a+NOTE_TONE_H,X ; 4
|
2019-05-30 14:54:03 +00:00
|
|
|
|
2019-05-13 20:48:47 +00:00
|
|
|
;=============================
|
2019-05-13 00:11:17 +00:00
|
|
|
; Accumulate tone if set
|
2019-05-13 20:48:47 +00:00
|
|
|
; (if sample_b1 & $40)
|
2019-05-11 03:06:56 +00:00
|
|
|
|
|
|
|
bit sample_b1
|
2019-06-01 04:26:29 +00:00
|
|
|
bvc no_accum ; (so, if b1&0x40 is zero, skip it)
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-06-01 04:26:29 +00:00
|
|
|
sta note_a+NOTE_TONE_ACCUMULATOR_H,X
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_L,X ; tone_accumulator=tone
|
|
|
|
sta note_a+NOTE_TONE_ACCUMULATOR_L,X
|
2019-05-11 03:06:56 +00:00
|
|
|
|
|
|
|
no_accum:
|
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
;============================
|
|
|
|
; Calculate tone
|
|
|
|
; j = a->note + (pt3->data[a->ornament_pointer + a->ornament_position]
|
2019-06-01 04:26:29 +00:00
|
|
|
clc ;;can be removed if ADC ACCUMULATOR_H cannot overflow
|
|
|
|
ldy note_a+NOTE_ORNAMENT_POSITION,X
|
2019-05-13 16:59:59 +00:00
|
|
|
lda (ORNAMENT_L),Y
|
2019-05-13 04:36:44 +00:00
|
|
|
adc note_a+NOTE_NOTE,X
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
; if (j < 0) j = 0;
|
|
|
|
bpl note_not_negative
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
; if (j > 95) j = 95;
|
|
|
|
note_not_negative:
|
|
|
|
cmp #96
|
2019-05-13 20:48:47 +00:00
|
|
|
bcc note_not_too_high ; blt
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
lda #95
|
|
|
|
|
|
|
|
note_not_too_high:
|
|
|
|
|
|
|
|
; w = GetNoteFreq(j,pt3->frequency_table);
|
|
|
|
|
|
|
|
jsr GetNoteFreq
|
|
|
|
|
|
|
|
; a->tone = (a->tone + a->tone_sliding + w) & 0xfff;
|
|
|
|
|
|
|
|
clc
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_L,X
|
|
|
|
adc note_a+NOTE_TONE_SLIDING_L,X
|
|
|
|
sta note_a+NOTE_TONE_L,X
|
|
|
|
lda note_a+NOTE_TONE_H,X
|
|
|
|
adc note_a+NOTE_TONE_SLIDING_H,X
|
|
|
|
sta note_a+NOTE_TONE_H,X
|
2019-05-13 00:11:17 +00:00
|
|
|
|
2019-06-01 04:26:29 +00:00
|
|
|
clc ;;can be removed if ADC SLIDING_H cannot overflow
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_L,X
|
2019-05-13 00:11:17 +00:00
|
|
|
adc freq_l
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_TONE_L,X
|
|
|
|
lda note_a+NOTE_TONE_H,X
|
2019-05-13 20:48:47 +00:00
|
|
|
adc freq_h
|
2019-05-13 00:11:17 +00:00
|
|
|
and #$0f
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_TONE_H,X
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
;=====================
|
2019-05-13 00:55:13 +00:00
|
|
|
; handle tone sliding
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_SLIDE_COUNT,X
|
2019-05-13 00:55:13 +00:00
|
|
|
bmi no_tone_sliding ; if (a->tone_slide_count > 0) {
|
2019-05-13 21:09:01 +00:00
|
|
|
beq no_tone_sliding
|
2019-05-13 00:55:13 +00:00
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
dec note_a+NOTE_TONE_SLIDE_COUNT,X ; a->tone_slide_count--;
|
2019-05-13 00:55:13 +00:00
|
|
|
bne no_tone_sliding ; if (a->tone_slide_count==0) {
|
|
|
|
|
|
|
|
|
|
|
|
; a->tone_sliding+=a->tone_slide_step
|
2019-06-01 04:26:29 +00:00
|
|
|
clc ;;can be removed if ADC freq_h cannot overflow
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_SLIDING_L,X
|
|
|
|
adc note_a+NOTE_TONE_SLIDE_STEP_L,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_L,X
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_H,X
|
|
|
|
adc note_a+NOTE_TONE_SLIDE_STEP_H,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_H,X
|
2019-05-13 00:55:13 +00:00
|
|
|
|
|
|
|
; a->tone_slide_count = a->tone_slide_delay;
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_SLIDE_DELAY,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDE_COUNT,X
|
2019-05-13 00:55:13 +00:00
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_SIMPLE_GLISS,X
|
2019-05-13 00:55:13 +00:00
|
|
|
bne no_tone_sliding ; if (!a->simplegliss) {
|
|
|
|
|
2019-05-13 17:30:57 +00:00
|
|
|
; FIXME: do these need to be signed compares?
|
|
|
|
|
2019-05-13 00:55:13 +00:00
|
|
|
check1:
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_SLIDE_STEP_H,X
|
2019-05-13 00:55:13 +00:00
|
|
|
bpl check2 ; if ( ((a->tone_slide_step < 0) &&
|
2019-05-13 03:32:58 +00:00
|
|
|
|
2019-05-13 21:09:01 +00:00
|
|
|
; (a->tone_sliding <= a->tone_delta) ||
|
|
|
|
|
2019-05-14 02:11:32 +00:00
|
|
|
; 16 bit signed compare
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_L,X ; NUM1-NUM2
|
|
|
|
cmp note_a+NOTE_TONE_DELTA_L,X ;
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_H,X
|
|
|
|
sbc note_a+NOTE_TONE_DELTA_H,X
|
|
|
|
bvc sc_loser1 ; N eor V
|
|
|
|
eor #$80
|
|
|
|
sc_loser1:
|
|
|
|
bmi slide_to_note ; then A (signed) < NUM (signed) and BMI will branch
|
2019-05-13 00:55:13 +00:00
|
|
|
|
2019-05-14 05:02:41 +00:00
|
|
|
; equals case
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_L,X
|
|
|
|
cmp note_a+NOTE_TONE_DELTA_L,X
|
|
|
|
bne check2
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_H,X
|
|
|
|
cmp note_a+NOTE_TONE_DELTA_H,X
|
|
|
|
beq slide_to_note
|
2019-05-14 02:11:32 +00:00
|
|
|
|
2019-05-13 00:55:13 +00:00
|
|
|
check2:
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_TONE_SLIDE_STEP_H,X
|
2019-05-13 00:55:13 +00:00
|
|
|
bmi no_tone_sliding ; ((a->tone_slide_step >= 0) &&
|
2019-05-13 03:32:58 +00:00
|
|
|
|
2019-05-13 21:09:01 +00:00
|
|
|
; (a->tone_sliding >= a->tone_delta)
|
2019-05-14 02:11:32 +00:00
|
|
|
|
|
|
|
; 16 bit signed compare
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_L,X ; NUM1-NUM2
|
|
|
|
cmp note_a+NOTE_TONE_DELTA_L,X ;
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_H,X
|
|
|
|
sbc note_a+NOTE_TONE_DELTA_H,X
|
|
|
|
bvc sc_loser2 ; N eor V
|
|
|
|
eor #$80
|
|
|
|
sc_loser2:
|
|
|
|
bmi no_tone_sliding ; then A (signed) < NUM (signed) and BMI will branch
|
|
|
|
|
2019-05-13 00:55:13 +00:00
|
|
|
slide_to_note:
|
2019-05-14 05:02:41 +00:00
|
|
|
; a->note = a->slide_to_note;
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_SLIDE_TO_NOTE,X
|
2019-05-14 05:02:41 +00:00
|
|
|
sta note_a+NOTE_NOTE,X
|
2019-05-13 00:55:13 +00:00
|
|
|
lda #0
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_COUNT,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_L,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
2019-05-13 00:55:13 +00:00
|
|
|
|
|
|
|
no_tone_sliding:
|
2019-05-13 21:09:01 +00:00
|
|
|
|
|
|
|
;=========================
|
|
|
|
; Calculate the amplitude
|
|
|
|
;=========================
|
2019-05-14 02:11:32 +00:00
|
|
|
calc_amplitude:
|
2019-05-13 21:09:01 +00:00
|
|
|
; get base value from the sample (bottom 4 bits of sample_b1)
|
2019-05-11 04:11:53 +00:00
|
|
|
|
2019-05-11 03:06:56 +00:00
|
|
|
lda sample_b1 ; a->amplitude= (b1 & 0xf);
|
|
|
|
and #$f
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_AMPLITUDE,X
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-05-13 21:09:01 +00:00
|
|
|
;========================================
|
2019-05-22 19:52:05 +00:00
|
|
|
; if b0 top bit is set, it means sliding
|
2019-05-13 21:09:01 +00:00
|
|
|
|
2019-05-11 04:11:53 +00:00
|
|
|
; adjust amplitude sliding
|
|
|
|
|
2019-06-01 04:29:56 +00:00
|
|
|
bit sample_b0 ; if ((b0 & 0x80)!=0) {
|
|
|
|
bpl done_amp_sliding ; so if top bit not set, skip
|
2019-05-11 04:11:53 +00:00
|
|
|
|
2019-05-13 21:09:01 +00:00
|
|
|
;================================
|
|
|
|
; if top bits 0b11 then slide up
|
|
|
|
; if top buts 0b10 then slide down
|
|
|
|
|
2019-06-01 04:29:56 +00:00
|
|
|
; if ((b0 & 0x40)!=0) {
|
|
|
|
bvc amp_slide_down
|
2019-05-13 21:09:01 +00:00
|
|
|
|
2019-05-11 04:11:53 +00:00
|
|
|
amp_slide_up:
|
2019-05-13 16:33:52 +00:00
|
|
|
; if (a->amplitude_sliding < 15) {
|
|
|
|
; a pain to do signed compares
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
2019-05-13 16:33:52 +00:00
|
|
|
sec
|
|
|
|
sbc #15
|
|
|
|
bvc asu_signed
|
|
|
|
eor #$80
|
|
|
|
asu_signed:
|
|
|
|
bpl done_amp_sliding ; skip if A>=15
|
|
|
|
inc note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding++;
|
2019-06-01 04:29:56 +00:00
|
|
|
bne done_amp_sliding
|
2019-05-13 21:09:01 +00:00
|
|
|
|
2019-05-11 04:11:53 +00:00
|
|
|
amp_slide_down:
|
2019-05-13 16:33:52 +00:00
|
|
|
; if (a->amplitude_sliding > -15) {
|
|
|
|
; a pain to do signed compares
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
2019-05-13 16:33:52 +00:00
|
|
|
sec
|
|
|
|
sbc #$f1 ; -15
|
|
|
|
bvc asd_signed
|
|
|
|
eor #$80
|
|
|
|
asd_signed:
|
|
|
|
bmi done_amp_sliding ; if A < -15, skip subtract
|
|
|
|
|
|
|
|
dec note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding--;
|
2019-05-11 04:11:53 +00:00
|
|
|
|
|
|
|
done_amp_sliding:
|
|
|
|
|
|
|
|
; a->amplitude+=a->amplitude_sliding;
|
|
|
|
clc
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_AMPLITUDE,X
|
|
|
|
adc note_a+NOTE_AMPLITUDE_SLIDING,X
|
|
|
|
sta note_a+NOTE_AMPLITUDE,X
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-09 04:28:52 +00:00
|
|
|
; clamp amplitude to 0 - 15
|
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_AMPLITUDE,X
|
2019-05-09 04:28:52 +00:00
|
|
|
check_amp_lo:
|
|
|
|
bpl check_amp_hi
|
|
|
|
lda #0
|
2019-06-01 04:29:56 +00:00
|
|
|
beq write_clamp_amplitude
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
check_amp_hi:
|
|
|
|
cmp #16
|
|
|
|
bcc done_clamp_amplitude ; blt
|
|
|
|
lda #15
|
|
|
|
write_clamp_amplitude:
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_AMPLITUDE,X
|
2019-05-13 21:09:01 +00:00
|
|
|
|
2019-05-09 04:28:52 +00:00
|
|
|
done_clamp_amplitude:
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-22 19:37:00 +00:00
|
|
|
; We generate the proper table at runtime now
|
|
|
|
; so always in Volume Table
|
2019-05-13 21:09:01 +00:00
|
|
|
; a->amplitude = PT3VolumeTable_33_34[a->volume][a->amplitude];
|
2019-05-22 19:37:00 +00:00
|
|
|
; a->amplitude = PT3VolumeTable_35[a->volume][a->amplitude];
|
2019-05-13 17:36:24 +00:00
|
|
|
|
2019-05-22 19:37:00 +00:00
|
|
|
lda note_a+NOTE_VOLUME,X ; 4+
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
asl ; 2
|
|
|
|
ora note_a+NOTE_AMPLITUDE,X ; 4+
|
2019-05-13 17:36:24 +00:00
|
|
|
|
2019-05-22 19:37:00 +00:00
|
|
|
tay ; 2
|
|
|
|
lda VolumeTable,Y ; 4+
|
|
|
|
sta note_a+NOTE_AMPLITUDE,X ; 5
|
2019-05-13 04:36:44 +00:00
|
|
|
|
2019-05-13 17:36:24 +00:00
|
|
|
done_table:
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-05-13 21:09:01 +00:00
|
|
|
|
|
|
|
check_envelope_enable:
|
|
|
|
; Bottom bit of b0 indicates our sample has envelope
|
|
|
|
; Also make sure envelopes are enabled
|
|
|
|
|
|
|
|
|
|
|
|
; if (((b0 & 0x1) == 0) && ( a->envelope_enabled)) {
|
|
|
|
lda sample_b0
|
2019-05-30 14:53:33 +00:00
|
|
|
and #$1
|
|
|
|
bne envelope_slide
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_ENVELOPE_ENABLED,X
|
2019-05-13 00:11:17 +00:00
|
|
|
beq envelope_slide
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-05-13 21:09:01 +00:00
|
|
|
|
|
|
|
; Bit 4 of the per-channel AY-3-8910 amplitude specifies
|
|
|
|
; envelope enabled
|
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_AMPLITUDE,X ; a->amplitude |= 16;
|
2019-05-11 03:06:56 +00:00
|
|
|
ora #$10
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_AMPLITUDE,X
|
2019-05-07 19:11:52 +00:00
|
|
|
|
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
envelope_slide:
|
2019-06-01 04:36:03 +00:00
|
|
|
lda sample_b0
|
|
|
|
lsr
|
|
|
|
tay
|
|
|
|
|
2019-05-13 01:30:01 +00:00
|
|
|
; Envelope slide
|
|
|
|
; If b1 top bits are 10 or 11
|
|
|
|
|
2019-05-30 14:54:03 +00:00
|
|
|
lda #$20
|
|
|
|
bit sample_b0
|
2019-06-01 04:36:03 +00:00
|
|
|
php
|
|
|
|
|
|
|
|
bit sample_b1
|
|
|
|
bpl else_noise_slide ; if ((b1 & 0x80) != 0) {
|
|
|
|
|
|
|
|
plp
|
|
|
|
php
|
|
|
|
;;bug? always falls through
|
2019-05-13 01:30:01 +00:00
|
|
|
beq envelope_slide_down ; if ((b0 & 0x20) != 0) {
|
|
|
|
|
|
|
|
; FIXME: this can be optimized
|
2019-05-14 14:45:55 +00:00
|
|
|
|
|
|
|
envelope_slide_down:
|
|
|
|
|
|
|
|
; j = ((b0>>1)|0xF0) + a->envelope_sliding
|
2019-06-01 04:36:03 +00:00
|
|
|
tya
|
2019-05-13 01:30:01 +00:00
|
|
|
ora #$f0
|
|
|
|
clc
|
2019-05-13 04:36:44 +00:00
|
|
|
adc note_a+NOTE_ENVELOPE_SLIDING,X
|
2019-05-14 14:45:55 +00:00
|
|
|
sta e_slide_amount ; j
|
2019-06-01 04:36:03 +00:00
|
|
|
;;+jmp envelope_slide_done?
|
2019-05-14 14:45:55 +00:00
|
|
|
|
|
|
|
envelope_slide_up:
|
|
|
|
; j = ((b0>>1)&0xF) + a->envelope_sliding;
|
2019-06-01 04:36:03 +00:00
|
|
|
tya
|
2019-05-13 01:30:01 +00:00
|
|
|
and #$0f
|
|
|
|
clc
|
2019-05-13 04:36:44 +00:00
|
|
|
adc note_a+NOTE_ENVELOPE_SLIDING,X
|
2019-05-14 14:45:55 +00:00
|
|
|
sta e_slide_amount ; j
|
2019-05-13 01:30:01 +00:00
|
|
|
|
|
|
|
envelope_slide_done:
|
|
|
|
|
2019-06-01 04:36:03 +00:00
|
|
|
plp
|
2019-05-13 01:30:01 +00:00
|
|
|
beq last_envelope ; if (( b1 & 0x20) != 0) {
|
2019-05-14 14:45:55 +00:00
|
|
|
|
|
|
|
; a->envelope_sliding = j;
|
|
|
|
sta note_a+NOTE_ENVELOPE_SLIDING,X
|
2019-05-13 01:30:01 +00:00
|
|
|
|
|
|
|
last_envelope:
|
|
|
|
|
2019-05-14 14:45:55 +00:00
|
|
|
; pt3->envelope_add+=j;
|
|
|
|
|
2019-05-13 01:30:01 +00:00
|
|
|
clc
|
|
|
|
lda e_slide_amount
|
|
|
|
adc pt3_envelope_add
|
2019-05-14 14:45:55 +00:00
|
|
|
sta pt3_envelope_add
|
2019-05-13 01:30:01 +00:00
|
|
|
|
2019-05-13 16:33:52 +00:00
|
|
|
jmp noise_slide_done ; skip else
|
|
|
|
|
2019-05-14 14:45:55 +00:00
|
|
|
else_noise_slide:
|
2019-05-13 01:30:01 +00:00
|
|
|
; Noise slide
|
|
|
|
; else {
|
|
|
|
|
2019-05-14 14:45:55 +00:00
|
|
|
; pt3->noise_add = (b0>>1) + a->noise_sliding;
|
2019-06-01 04:36:03 +00:00
|
|
|
tya
|
2019-05-13 01:30:01 +00:00
|
|
|
clc
|
2019-05-13 04:36:44 +00:00
|
|
|
adc note_a+NOTE_NOISE_SLIDING,X
|
2019-05-14 14:45:55 +00:00
|
|
|
sta pt3_noise_add
|
2019-05-13 01:30:01 +00:00
|
|
|
|
2019-06-01 04:36:03 +00:00
|
|
|
plp
|
2019-05-13 01:30:01 +00:00
|
|
|
beq noise_slide_done ; if ((b1 & 0x20) != 0) {
|
2019-05-14 14:45:55 +00:00
|
|
|
|
|
|
|
; noise_sliding = pt3_noise_add
|
|
|
|
sta note_a+NOTE_NOISE_SLIDING,X
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-13 01:30:01 +00:00
|
|
|
noise_slide_done:
|
2019-05-11 04:11:53 +00:00
|
|
|
;======================
|
|
|
|
; set mixer
|
|
|
|
|
|
|
|
lda sample_b1 ; pt3->mixer_value = ((b1 >>1) & 0x48) | pt3->mixer_value;
|
|
|
|
lsr
|
|
|
|
and #$48
|
|
|
|
ora pt3_mixer_value
|
|
|
|
sta pt3_mixer_value
|
|
|
|
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-13 00:11:17 +00:00
|
|
|
;========================
|
|
|
|
; increment sample position
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
inc note_a+NOTE_SAMPLE_POSITION,X ; a->sample_position++;
|
2019-05-13 17:30:57 +00:00
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_SAMPLE_POSITION,X
|
|
|
|
cmp note_a+NOTE_SAMPLE_LENGTH,X
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
bcc sample_pos_ok ; blt
|
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_SAMPLE_LOOP,X
|
|
|
|
sta note_a+NOTE_SAMPLE_POSITION,X
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
sample_pos_ok:
|
|
|
|
|
|
|
|
;========================
|
|
|
|
; increment ornament position
|
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
inc note_a+NOTE_ORNAMENT_POSITION,X ; a->ornament_position++;
|
|
|
|
lda note_a+NOTE_ORNAMENT_POSITION,X
|
|
|
|
cmp note_a+NOTE_ORNAMENT_LENGTH,X
|
2019-05-13 00:11:17 +00:00
|
|
|
|
|
|
|
bcc ornament_pos_ok ; blt
|
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_ORNAMENT_LOOP,X
|
2019-05-13 17:30:57 +00:00
|
|
|
sta note_a+NOTE_ORNAMENT_POSITION,X
|
2019-05-13 00:11:17 +00:00
|
|
|
ornament_pos_ok:
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-09 04:28:52 +00:00
|
|
|
done_note:
|
|
|
|
; set mixer value
|
|
|
|
; this is a bit complex (from original code)
|
|
|
|
; after 3 calls it is set up properly
|
2019-06-01 04:40:25 +00:00
|
|
|
lsr pt3_mixer_value
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-11 03:06:56 +00:00
|
|
|
handle_onoff:
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_ONOFF,X ;if (a->onoff>0) {
|
2019-05-11 03:06:56 +00:00
|
|
|
beq done_onoff
|
|
|
|
|
2019-05-13 04:36:44 +00:00
|
|
|
dec note_a+NOTE_ONOFF,X ; a->onoff--;
|
2019-05-11 03:06:56 +00:00
|
|
|
|
|
|
|
bne done_onoff ; if (a->onoff==0) {
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_ENABLED,X
|
2019-05-11 03:06:56 +00:00
|
|
|
eor #$1 ; toggle
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_ENABLED,X
|
2019-05-11 03:06:56 +00:00
|
|
|
|
|
|
|
bne do_offon
|
|
|
|
do_onoff:
|
2019-05-30 14:53:33 +00:00
|
|
|
lda note_a+NOTE_ONOFF_DELAY,X ; if (a->enabled) a->onoff=a->onoff_delay;
|
|
|
|
jmp put_offon
|
2019-05-11 03:06:56 +00:00
|
|
|
do_offon:
|
2019-05-13 04:36:44 +00:00
|
|
|
lda note_a+NOTE_OFFON_DELAY,X ; else a->onoff=a->offon_delay;
|
2019-05-11 03:06:56 +00:00
|
|
|
put_offon:
|
2019-05-13 04:36:44 +00:00
|
|
|
sta note_a+NOTE_ONOFF,X
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-11 03:06:56 +00:00
|
|
|
done_onoff:
|
2019-05-07 15:33:07 +00:00
|
|
|
|
2019-05-22 19:52:05 +00:00
|
|
|
rts ; 6
|
2019-05-07 15:33:07 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spec_command: .byte $0
|
|
|
|
|
2019-05-07 15:33:07 +00:00
|
|
|
;=====================================
|
|
|
|
; Decode Note
|
|
|
|
;=====================================
|
2019-05-13 04:18:09 +00:00
|
|
|
; X points to the note offset
|
2019-05-07 15:33:07 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
; Timings (from ===>)
|
2019-05-24 05:08:36 +00:00
|
|
|
; 00: 14+30
|
|
|
|
; 0X: 14+15
|
|
|
|
; 10: 14+5 +124
|
|
|
|
; 1X: 14+5 +193
|
|
|
|
; 2X/3X: 14+5 +17
|
|
|
|
; 4X: 14+5+5 + 111
|
|
|
|
; 5X: 14+5+5+ 102
|
|
|
|
;
|
2019-05-22 21:08:52 +00:00
|
|
|
|
2019-05-07 19:11:52 +00:00
|
|
|
decode_note:
|
2019-05-07 15:33:07 +00:00
|
|
|
|
2019-05-09 17:40:54 +00:00
|
|
|
; Init vars
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
lda #0 ; 2
|
|
|
|
sta spec_command ; 4
|
|
|
|
sta decode_done ; 4
|
2019-05-09 17:40:54 +00:00
|
|
|
|
|
|
|
; Skip decode if note still running
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_a+NOTE_LEN_COUNT,X ; 4+
|
|
|
|
cmp #2 ; 2
|
2019-05-30 14:53:33 +00:00
|
|
|
bcc keep_decoding ; blt, assume not negative ; 2/3
|
|
|
|
|
|
|
|
; we are still running, decrement and early return
|
|
|
|
dec note_a+NOTE_LEN_COUNT,X ; 7
|
|
|
|
rts ; 6
|
2019-05-09 17:40:54 +00:00
|
|
|
|
|
|
|
keep_decoding:
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_a+NOTE_NOTE,X ; store prev note ; 4+
|
|
|
|
sta prev_note ; 4
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_a+NOTE_TONE_SLIDING_H,X ; store prev sliding ; 4+
|
|
|
|
sta prev_sliding_h ; 4
|
|
|
|
lda note_a+NOTE_TONE_SLIDING_L,X ; 4+
|
|
|
|
sta prev_sliding_l ; 4
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
ldy #0 ; 2
|
2019-05-22 21:08:52 +00:00
|
|
|
;============
|
2019-05-30 14:53:33 +00:00
|
|
|
; 26
|
2019-05-11 03:06:56 +00:00
|
|
|
|
2019-05-09 17:40:54 +00:00
|
|
|
note_decode_loop:
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_a+NOTE_LEN,X ; re-up length count ; 4+
|
|
|
|
sta note_a+NOTE_LEN_COUNT,X ; 5
|
|
|
|
|
|
|
|
lda note_a+NOTE_ADDR_L,X ; 4+
|
|
|
|
sta PATTERN_L ; 3
|
|
|
|
lda note_a+NOTE_ADDR_H,X ; 4+
|
|
|
|
sta PATTERN_H ; 3
|
|
|
|
;===>
|
2019-05-10 14:57:08 +00:00
|
|
|
; get next value
|
2019-05-22 21:08:52 +00:00
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
sta note_command ; save termporarily ; 4
|
2019-05-10 14:57:08 +00:00
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
; FIXME: use a jump table??
|
2019-05-22 21:08:52 +00:00
|
|
|
; further reflection, that would require 32-bytes of addresses
|
|
|
|
; in addition to needing X or Y to index the jump table. hmmm
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
and #$f0 ; 2
|
2019-05-10 16:20:44 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
; cmp #$00
|
|
|
|
bne decode_case_1X ; 2/3
|
|
|
|
;=============
|
|
|
|
; 14
|
2019-05-10 16:20:44 +00:00
|
|
|
|
|
|
|
decode_case_0X:
|
2019-05-10 17:09:05 +00:00
|
|
|
;==============================
|
|
|
|
; $0X set special effect
|
|
|
|
;==============================
|
2019-05-22 21:08:52 +00:00
|
|
|
; -1
|
|
|
|
lda note_command ; 4
|
|
|
|
and #$f ; 2
|
2019-05-10 17:09:05 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
; we can always store spec as 0 means no spec
|
|
|
|
|
|
|
|
; FIXME: what if multiple spec commands?
|
|
|
|
; Doesn't seem to happen in practice
|
|
|
|
; But AY_emul has code to handle it
|
2019-05-10 17:09:05 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
sta spec_command ; 4
|
2019-05-10 17:09:05 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
bne decode_case_0X_not_zero ; 2/3
|
|
|
|
;=============
|
|
|
|
; 12
|
2019-05-20 13:50:49 +00:00
|
|
|
; 00 case
|
|
|
|
; means end of pattern
|
2019-05-22 21:08:52 +00:00
|
|
|
; -1
|
|
|
|
sta note_a+NOTE_LEN_COUNT,X ; len_count=0; ; 5
|
2019-05-10 17:09:05 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
sta decode_done ; 4+
|
2019-05-14 15:52:50 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
dec pt3_pattern_done ; 6
|
2019-05-10 17:09:05 +00:00
|
|
|
|
|
|
|
decode_case_0X_not_zero:
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
jmp done_decode ; 3
|
2019-05-10 17:09:05 +00:00
|
|
|
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
decode_case_1X:
|
2019-05-10 17:09:05 +00:00
|
|
|
;==============================
|
|
|
|
; $1X -- Set Envelope Type
|
|
|
|
;==============================
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
cmp #$10 ; 2
|
|
|
|
bne decode_case_2X ; 2/3
|
|
|
|
;============
|
|
|
|
; 5
|
2019-05-10 16:20:44 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
; -1
|
|
|
|
lda note_command ; 4
|
2019-05-10 17:09:05 +00:00
|
|
|
and #$0f
|
2019-05-24 05:08:36 +00:00
|
|
|
bne decode_case_not_10 ; 3
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-10 17:09:05 +00:00
|
|
|
decode_case_10:
|
2019-05-24 05:08:36 +00:00
|
|
|
; 10 case - disable ; -1
|
2019-05-22 21:08:52 +00:00
|
|
|
sta note_a+NOTE_ENVELOPE_ENABLED,X ; A is 0 ; 5
|
|
|
|
beq decode_case_1x_common ; branch always ; 3
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-10 17:09:05 +00:00
|
|
|
decode_case_not_10:
|
2019-05-24 05:08:36 +00:00
|
|
|
; -1
|
2019-05-22 21:08:52 +00:00
|
|
|
jsr set_envelope ; 6+64
|
2019-05-10 17:09:05 +00:00
|
|
|
|
|
|
|
decode_case_1x_common:
|
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
iny ; 2
|
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
lsr ; 2
|
|
|
|
jsr load_sample ; 6+86
|
2019-05-10 17:09:05 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
lda #0 ; 2
|
|
|
|
sta note_a+NOTE_ORNAMENT_POSITION,X ; ornament_position=0 ; 5
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
jmp done_decode ; 3
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
decode_case_2X:
|
|
|
|
decode_case_3X:
|
|
|
|
;==============================
|
2019-05-24 05:08:36 +00:00
|
|
|
; $2X/$3X set noise period
|
2019-05-10 16:20:44 +00:00
|
|
|
;==============================
|
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
cmp #$40 ; 2
|
|
|
|
bcs decode_case_4X ; branch greater/equal ; 3
|
|
|
|
; -1
|
|
|
|
lda note_command ; 3
|
2019-05-30 14:53:33 +00:00
|
|
|
sec ; 2
|
|
|
|
sbc #$20 ; 2
|
2019-05-24 05:08:36 +00:00
|
|
|
sta pt3_noise_period ; 3
|
2019-05-10 16:20:44 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
jmp done_decode ; 3
|
|
|
|
;===========
|
2019-05-30 14:53:33 +00:00
|
|
|
; 17
|
2019-05-10 16:20:44 +00:00
|
|
|
|
|
|
|
decode_case_4X:
|
|
|
|
;==============================
|
2019-05-10 16:38:41 +00:00
|
|
|
; $4X -- set ornament
|
2019-05-10 16:20:44 +00:00
|
|
|
;==============================
|
2019-05-24 05:08:36 +00:00
|
|
|
; cmp #$40 ; already set ;
|
|
|
|
bne decode_case_5X ; 3
|
|
|
|
; -1
|
|
|
|
lda note_command ; 4
|
|
|
|
and #$0f ; set ornament to bottom nibble ; 2
|
|
|
|
jsr load_ornament ; 6+93
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
jmp done_decode ; 3
|
|
|
|
;============
|
|
|
|
; 110
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
decode_case_5X:
|
|
|
|
;==============================
|
|
|
|
; $5X-$AX set note
|
|
|
|
;==============================
|
2019-05-24 05:08:36 +00:00
|
|
|
cmp #$B0 ; 2
|
|
|
|
bcs decode_case_bX ; branch greater/equal ; 3
|
2019-05-10 16:20:44 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
; -1
|
|
|
|
lda note_command ; 4
|
2019-05-30 14:53:33 +00:00
|
|
|
sec ; 2
|
|
|
|
sbc #$50 ; 2
|
2019-05-24 05:08:36 +00:00
|
|
|
sta note_a+NOTE_NOTE,X ; note=(current_val-0x50); ; 5
|
2019-05-10 16:20:44 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
jsr reset_note ; 6+69
|
2019-05-10 16:20:44 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
sta note_a+NOTE_ENABLED,X ; enabled=1 ; 5
|
|
|
|
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp done_decode ; 3
|
2019-05-10 16:20:44 +00:00
|
|
|
|
|
|
|
decode_case_bX:
|
2019-05-10 16:38:41 +00:00
|
|
|
;============================================
|
|
|
|
; $BX -- note length or envelope manipulation
|
|
|
|
;============================================
|
2019-05-24 05:08:36 +00:00
|
|
|
; cmp #$b0 ; already set from before
|
2019-05-10 16:20:44 +00:00
|
|
|
bne decode_case_cX
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_command
|
2019-05-10 17:09:05 +00:00
|
|
|
and #$f
|
|
|
|
beq decode_case_b0
|
2019-05-30 14:53:33 +00:00
|
|
|
cmp #1
|
2019-06-01 04:40:25 +00:00
|
|
|
bne decode_case_bx_higher
|
2019-05-10 17:09:05 +00:00
|
|
|
|
|
|
|
decode_case_b1:
|
|
|
|
; Set Length
|
|
|
|
|
|
|
|
; get next byte
|
|
|
|
iny
|
|
|
|
lda (PATTERN_L),Y
|
|
|
|
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_LEN,X
|
|
|
|
sta note_a+NOTE_LEN_COUNT,X
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp done_decode
|
2019-05-10 17:09:05 +00:00
|
|
|
|
2019-06-01 04:40:25 +00:00
|
|
|
decode_case_b0:
|
|
|
|
; Disable envelope
|
|
|
|
sta note_a+NOTE_ENVELOPE_ENABLED,X
|
|
|
|
sta note_a+NOTE_ORNAMENT_POSITION,X
|
|
|
|
jmp done_decode
|
|
|
|
|
|
|
|
|
2019-05-10 17:09:05 +00:00
|
|
|
decode_case_bx_higher:
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
sec
|
|
|
|
sbc #1 ; envelope_type=(current_val&0xf)-1;
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
jsr set_envelope ; 6+64
|
2019-05-14 05:57:46 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp done_decode
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
decode_case_cX:
|
|
|
|
;==============================
|
2019-05-10 16:38:41 +00:00
|
|
|
; $CX -- set volume
|
2019-05-10 16:20:44 +00:00
|
|
|
;==============================
|
|
|
|
cmp #$c0
|
|
|
|
bne decode_case_dX
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_command
|
2019-05-10 16:38:41 +00:00
|
|
|
and #$0f
|
|
|
|
bne decode_case_cx_not_c0
|
|
|
|
|
|
|
|
decode_case_c0:
|
|
|
|
; special case $C0 means shut down the note
|
|
|
|
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_ENABLED,X ; enabled=0
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
jsr reset_note ; 6+69
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp done_decode
|
2019-05-10 16:38:41 +00:00
|
|
|
|
|
|
|
decode_case_cx_not_c0:
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_VOLUME,X ; volume=current_val&0xf;
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp done_decode
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
decode_case_dX:
|
|
|
|
;==============================
|
2019-05-10 16:38:41 +00:00
|
|
|
; $DX -- change sample
|
2019-05-10 16:20:44 +00:00
|
|
|
;==============================
|
2019-05-10 16:38:41 +00:00
|
|
|
; FIXME: merge with below?
|
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
cmp #$d0
|
|
|
|
bne decode_case_eX
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_command
|
2019-05-10 16:38:41 +00:00
|
|
|
and #$0f
|
|
|
|
bne decode_case_dx_not_d0
|
|
|
|
|
|
|
|
;========================
|
|
|
|
; d0 case means end note
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
lda #1
|
|
|
|
sta decode_done
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp done_decode
|
2019-05-10 16:20:44 +00:00
|
|
|
decode_case_eX:
|
|
|
|
;==============================
|
2019-05-10 16:38:41 +00:00
|
|
|
; $EX -- change sample
|
2019-05-10 16:20:44 +00:00
|
|
|
;==============================
|
|
|
|
cmp #$e0
|
|
|
|
bne decode_case_fX
|
2019-05-10 16:38:41 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_command
|
2019-05-10 16:38:41 +00:00
|
|
|
sec
|
|
|
|
sbc #$d0
|
2019-06-01 04:40:25 +00:00
|
|
|
;fall through
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-06-01 04:40:25 +00:00
|
|
|
decode_case_dx_not_d0:
|
2019-05-30 14:54:03 +00:00
|
|
|
|
2019-06-01 04:40:25 +00:00
|
|
|
jsr load_sample ; load sample in bottom nybble
|
|
|
|
|
|
|
|
jmp done_decode
|
2019-05-10 16:20:44 +00:00
|
|
|
decode_case_fX:
|
|
|
|
;==============================
|
|
|
|
; $FX - change ornament/sample
|
|
|
|
;==============================
|
|
|
|
|
|
|
|
; disable envelope
|
|
|
|
lda #0
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_ENVELOPE_ENABLED,X
|
2019-05-10 16:20:44 +00:00
|
|
|
|
|
|
|
; Set ornament to low byte of command
|
2019-05-22 21:08:52 +00:00
|
|
|
lda note_command
|
2019-05-10 16:20:44 +00:00
|
|
|
and #$f
|
|
|
|
jsr load_ornament ; ornament to load in A
|
|
|
|
|
|
|
|
; Get next byte
|
|
|
|
iny ; point to next byte
|
|
|
|
lda (PATTERN_L),Y
|
|
|
|
|
|
|
|
; Set sample to value/2
|
|
|
|
lsr ; divide by two
|
|
|
|
jsr load_sample ; sample to load in A
|
|
|
|
|
|
|
|
; fallthrough
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-10 16:20:44 +00:00
|
|
|
done_decode:
|
|
|
|
|
|
|
|
iny ; point to next byte
|
|
|
|
|
|
|
|
lda decode_done
|
|
|
|
bne handle_effects
|
|
|
|
|
2019-05-11 03:06:56 +00:00
|
|
|
jmp note_decode_loop
|
2019-05-10 16:20:44 +00:00
|
|
|
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;=================================
|
|
|
|
; handle effects
|
|
|
|
;=================================
|
|
|
|
; Note, the AYemul code has code to make sure these are applied
|
|
|
|
; In the same order they appear. We don't bother?
|
2019-05-10 16:20:44 +00:00
|
|
|
handle_effects:
|
2019-05-13 02:14:07 +00:00
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
lda spec_command ; 4
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;==============================
|
|
|
|
; Effect #1 -- Tone Down
|
|
|
|
;==============================
|
|
|
|
effect_1:
|
|
|
|
cmp #$1
|
|
|
|
bne effect_2
|
|
|
|
|
2019-06-01 04:40:25 +00:00
|
|
|
sta note_a+NOTE_SIMPLE_GLISS,X
|
|
|
|
lsr
|
|
|
|
sta note_a+NOTE_ONOFF,X
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
lda (PATTERN_L),Y ; load byte, set as slide delay
|
|
|
|
iny
|
|
|
|
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_DELAY,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDE_COUNT,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as slide step low
|
|
|
|
iny
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as slide step high
|
|
|
|
iny
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
jmp no_effect
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;==============================
|
|
|
|
; Effect #2 -- Portamento
|
|
|
|
;==============================
|
|
|
|
effect_2:
|
|
|
|
cmp #$2
|
2019-05-13 03:32:58 +00:00
|
|
|
beq effect_2_small
|
|
|
|
jmp effect_3
|
|
|
|
effect_2_small: ; FIXME: make smaller
|
|
|
|
lda #0
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_SIMPLE_GLISS,X
|
|
|
|
sta note_a+NOTE_ONOFF,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as delay
|
|
|
|
iny
|
|
|
|
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_DELAY,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDE_COUNT,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as slide_step low
|
|
|
|
iny
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as slide_step high
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_H,X
|
2019-05-13 02:14:07 +00:00
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
; 16-bit absolute value
|
|
|
|
bpl slide_step_positive
|
|
|
|
|
|
|
|
eor #$ff
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_H,X
|
|
|
|
lda note_a+NOTE_TONE_SLIDE_STEP_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
eor #$ff
|
2019-06-01 04:40:25 +00:00
|
|
|
adc #$0 ;+carry set by earlier CMP
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_L,X
|
2019-06-01 04:40:25 +00:00
|
|
|
bcc skip_step_inc1
|
|
|
|
inc note_a+NOTE_TONE_SLIDE_STEP_H,X
|
|
|
|
skip_step_inc1:
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
slide_step_positive:
|
|
|
|
|
2019-05-14 05:02:41 +00:00
|
|
|
iny ; moved here as it messed with flags
|
|
|
|
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
; a->tone_delta=GetNoteFreq(a->note,pt3)-
|
|
|
|
; GetNoteFreq(prev_note,pt3);
|
|
|
|
|
2019-05-13 04:18:09 +00:00
|
|
|
lda note_a+NOTE_NOTE,X
|
2019-05-13 03:32:58 +00:00
|
|
|
jsr GetNoteFreq
|
|
|
|
lda freq_l
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_DELTA_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
lda freq_h
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_DELTA_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
lda prev_note
|
|
|
|
jsr GetNoteFreq
|
|
|
|
|
|
|
|
sec
|
2019-05-13 04:18:09 +00:00
|
|
|
lda note_a+NOTE_TONE_DELTA_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
sbc freq_l
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_DELTA_L,X
|
|
|
|
lda note_a+NOTE_TONE_DELTA_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
sbc freq_h
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_DELTA_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
2019-05-14 03:27:44 +00:00
|
|
|
; a->slide_to_note=a->note;
|
2019-05-13 04:18:09 +00:00
|
|
|
lda note_a+NOTE_NOTE,X
|
2019-05-14 03:27:44 +00:00
|
|
|
sta note_a+NOTE_SLIDE_TO_NOTE,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
2019-05-14 03:27:44 +00:00
|
|
|
; a->note=prev_note;
|
2019-05-13 03:32:58 +00:00
|
|
|
lda prev_note
|
2019-05-14 03:27:44 +00:00
|
|
|
sta note_a+NOTE_NOTE,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
lda pt3_version
|
|
|
|
cmp #$6
|
|
|
|
bcc weird_version ; blt
|
|
|
|
|
|
|
|
lda prev_sliding_l
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDING_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
lda prev_sliding_h
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDING_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
weird_version:
|
|
|
|
|
|
|
|
; annoying 16-bit subtract, only care if negative
|
|
|
|
; if ((a->tone_delta - a->tone_sliding) < 0) {
|
|
|
|
sec
|
2019-05-13 04:18:09 +00:00
|
|
|
lda note_a+NOTE_TONE_DELTA_L,X
|
|
|
|
sbc note_a+NOTE_TONE_SLIDING_L,X
|
|
|
|
lda note_a+NOTE_TONE_DELTA_H,X
|
|
|
|
sbc note_a+NOTE_TONE_SLIDING_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
bpl no_need
|
|
|
|
|
|
|
|
; a->tone_slide_step = -a->tone_slide_step;
|
|
|
|
|
2019-05-13 04:18:09 +00:00
|
|
|
lda note_a+NOTE_TONE_SLIDE_STEP_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
eor #$ff
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_H,X
|
|
|
|
lda note_a+NOTE_TONE_SLIDE_STEP_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
eor #$ff
|
2019-05-14 03:27:44 +00:00
|
|
|
clc
|
2019-05-13 03:32:58 +00:00
|
|
|
adc #$1
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_STEP_L,X
|
2019-06-01 04:45:24 +00:00
|
|
|
bcc skip_step_inc2
|
|
|
|
inc note_a+NOTE_TONE_SLIDE_STEP_H,X
|
|
|
|
skip_step_inc2:
|
2019-05-13 03:32:58 +00:00
|
|
|
|
|
|
|
no_need:
|
|
|
|
|
|
|
|
jmp no_effect
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;==============================
|
|
|
|
; Effect #3 -- Sample Position
|
|
|
|
;==============================
|
|
|
|
effect_3:
|
|
|
|
cmp #$3
|
|
|
|
bne effect_4
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
lda (PATTERN_L),Y ; load byte, set as sample position
|
|
|
|
iny
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_SAMPLE_POSITION,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp no_effect
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;==============================
|
|
|
|
; Effect #4 -- Ornament Position
|
|
|
|
;==============================
|
|
|
|
effect_4:
|
|
|
|
cmp #$4
|
|
|
|
bne effect_5
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
lda (PATTERN_L),Y ; load byte, set as ornament position
|
|
|
|
iny
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_ORNAMENT_POSITION,X
|
2019-05-13 03:32:58 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp no_effect
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;==============================
|
|
|
|
; Effect #5 -- Vibrato
|
|
|
|
;==============================
|
|
|
|
effect_5:
|
|
|
|
cmp #$5
|
|
|
|
bne effect_8
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
lda (PATTERN_L),Y ; load byte, set as onoff delay
|
|
|
|
iny
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_ONOFF_DELAY,X
|
|
|
|
sta note_a+NOTE_ONOFF,X
|
2019-05-13 02:14:07 +00:00
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
lda (PATTERN_L),Y ; load byte, set as offon delay
|
|
|
|
iny
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_OFFON_DELAY,X
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
lda #0
|
2019-05-13 04:18:09 +00:00
|
|
|
sta note_a+NOTE_TONE_SLIDE_COUNT,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_L,X
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_H,X
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp no_effect
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;==============================
|
|
|
|
; Effect #8 -- Envelope Down
|
|
|
|
;==============================
|
|
|
|
effect_8:
|
|
|
|
cmp #$8
|
|
|
|
bne effect_9
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
; delay
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as speed
|
|
|
|
iny
|
|
|
|
sta pt3_envelope_delay
|
|
|
|
sta pt3_envelope_delay_orig
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
; low value
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as low
|
|
|
|
iny
|
|
|
|
sta pt3_envelope_slide_add_l
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
; high value
|
|
|
|
lda (PATTERN_L),Y ; load byte, set as high
|
|
|
|
iny
|
|
|
|
sta pt3_envelope_slide_add_h
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
jmp no_effect
|
2019-05-13 02:14:07 +00:00
|
|
|
|
|
|
|
;==============================
|
|
|
|
; Effect #9 -- Set Speed
|
|
|
|
;==============================
|
|
|
|
effect_9:
|
|
|
|
cmp #$9
|
|
|
|
bne no_effect
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
lda (PATTERN_L),Y ; load byte, set as speed
|
|
|
|
iny
|
|
|
|
sta pt3_speed
|
2019-05-09 17:40:54 +00:00
|
|
|
|
2019-05-13 02:14:07 +00:00
|
|
|
no_effect:
|
|
|
|
|
|
|
|
;================================
|
|
|
|
; add y into the address pointer
|
|
|
|
|
2019-05-13 03:32:58 +00:00
|
|
|
clc
|
|
|
|
tya
|
2019-05-13 04:18:09 +00:00
|
|
|
adc note_a+NOTE_ADDR_L,X
|
|
|
|
sta note_a+NOTE_ADDR_L,X
|
2019-05-13 03:32:58 +00:00
|
|
|
lda #0
|
2019-05-13 04:18:09 +00:00
|
|
|
adc note_a+NOTE_ADDR_H,X
|
|
|
|
sta note_a+NOTE_ADDR_H,X
|
2019-05-13 03:32:58 +00:00
|
|
|
sta PATTERN_H
|
2019-05-13 02:14:07 +00:00
|
|
|
|
2019-05-07 15:33:07 +00:00
|
|
|
rts
|
|
|
|
|
2019-05-22 21:08:52 +00:00
|
|
|
|
|
|
|
;=======================================
|
|
|
|
; Set Envelope
|
|
|
|
;=======================================
|
|
|
|
; pulls out common code from $1X and $BX
|
|
|
|
; commands
|
|
|
|
|
|
|
|
; A = new envelope type
|
|
|
|
|
|
|
|
set_envelope:
|
|
|
|
|
|
|
|
sta pt3_envelope_type ; 4
|
|
|
|
|
|
|
|
; give fake old to force update? maybe only needed if printing?
|
|
|
|
; pt3->envelope_type_old=0x78;
|
|
|
|
|
|
|
|
lda #$78 ; 2
|
|
|
|
sta pt3_envelope_type_old ; 4
|
|
|
|
|
|
|
|
; get next byte
|
|
|
|
iny ; 2
|
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
sta pt3_envelope_period_h ; 4
|
|
|
|
|
|
|
|
iny ; 2
|
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
sta pt3_envelope_period_l ; 4
|
|
|
|
|
2019-06-01 04:45:24 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
sta note_a+NOTE_ENVELOPE_ENABLED,X ; envelope_enabled=1 ; 5
|
|
|
|
lsr ; 2
|
2019-05-22 21:08:52 +00:00
|
|
|
sta note_a+NOTE_ORNAMENT_POSITION,X ; ornament_position=0 ; 5
|
|
|
|
sta pt3_envelope_delay ; envelope_delay=0 ; 4
|
|
|
|
sta pt3_envelope_slide_l ; envelope_slide=0 ; 4
|
|
|
|
sta pt3_envelope_slide_h ; 4
|
|
|
|
|
|
|
|
rts ; 6
|
|
|
|
;===========
|
|
|
|
; 64
|
|
|
|
|
2019-05-24 05:08:36 +00:00
|
|
|
;========================
|
|
|
|
; reset note
|
|
|
|
;========================
|
|
|
|
; common code from the decode note code
|
|
|
|
|
|
|
|
reset_note:
|
|
|
|
lda #0 ; 2
|
|
|
|
sta note_a+NOTE_SAMPLE_POSITION,X ; sample_position=0 ; 5
|
|
|
|
sta note_a+NOTE_AMPLITUDE_SLIDING,X ; amplitude_sliding=0 ; 5
|
|
|
|
sta note_a+NOTE_NOISE_SLIDING,X ; noise_sliding=0 ; 5
|
|
|
|
sta note_a+NOTE_ENVELOPE_SLIDING,X ; envelope_sliding=0 ; 5
|
|
|
|
sta note_a+NOTE_ORNAMENT_POSITION,X ; ornament_position=0 ; 5
|
|
|
|
sta note_a+NOTE_TONE_SLIDE_COUNT,X ; tone_slide_count=0 ; 5
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_L,X ; tone_sliding=0 ; 5
|
|
|
|
sta note_a+NOTE_TONE_SLIDING_H,X ; 5
|
|
|
|
sta note_a+NOTE_TONE_ACCUMULATOR_L,X ; tone_accumulator=0 ; 5
|
|
|
|
sta note_a+NOTE_TONE_ACCUMULATOR_H,X ; 5
|
|
|
|
sta note_a+NOTE_ONOFF,X ; onoff=0; ; 5
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
lda #1 ; 2
|
|
|
|
sta decode_done ; decode_done=1 ; 4
|
2019-05-24 05:08:36 +00:00
|
|
|
|
|
|
|
rts ; 6
|
|
|
|
;============
|
|
|
|
; 69
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
;=====================================
|
|
|
|
; Decode Line
|
|
|
|
;=====================================
|
|
|
|
|
|
|
|
pt3_decode_line:
|
|
|
|
; decode_note(&pt3->a,&(pt3->a_addr),pt3);
|
|
|
|
ldx #(NOTE_STRUCT_SIZE*0)
|
|
|
|
jsr decode_note
|
|
|
|
|
|
|
|
; decode_note(&pt3->b,&(pt3->b_addr),pt3);
|
|
|
|
ldx #(NOTE_STRUCT_SIZE*1)
|
|
|
|
jsr decode_note
|
|
|
|
|
|
|
|
; decode_note(&pt3->c,&(pt3->c_addr),pt3);
|
|
|
|
ldx #(NOTE_STRUCT_SIZE*2)
|
|
|
|
jsr decode_note
|
|
|
|
|
|
|
|
; if (pt3->a.all_done && pt3->b.all_done && pt3->c.all_done) {
|
|
|
|
; return 1;
|
|
|
|
; }
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2019-05-10 04:22:17 +00:00
|
|
|
current_subframe: .byte $0
|
|
|
|
current_line: .byte $0
|
|
|
|
current_pattern: .byte $0
|
|
|
|
|
2019-05-09 04:28:52 +00:00
|
|
|
;=====================================
|
|
|
|
; Set Pattern
|
|
|
|
;=====================================
|
2019-05-20 14:11:29 +00:00
|
|
|
; FIXME: inline this? we do call it from outside
|
|
|
|
; in the player note length code
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
pt3_set_pattern:
|
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; Lookup current pattern in pattern table
|
|
|
|
ldy current_pattern ; 4
|
|
|
|
lda PT3_LOC+PT3_PATTERN_TABLE,Y ; 4+
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; if value is $FF we are at the end of the song
|
|
|
|
cmp #$ff ; 2
|
2019-05-30 14:53:33 +00:00
|
|
|
bne not_done ; 2/3
|
2019-05-14 03:27:44 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
; done with song, set it to non-zero
|
|
|
|
sta DONE_SONG ; 3
|
|
|
|
rts ; 6
|
2019-05-20 14:11:29 +00:00
|
|
|
;============
|
2019-05-30 14:53:33 +00:00
|
|
|
; 21 if end
|
2019-05-14 03:27:44 +00:00
|
|
|
|
|
|
|
not_done:
|
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; set up the three pattern address pointers
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
asl ; mul pattern offset by two, as word sized ; 2
|
|
|
|
tay ; 2
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; point PATTERN_H/PATTERN_L to the pattern address table
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
clc ; 2
|
|
|
|
lda PT3_LOC+PT3_PATTERN_LOC_L ; 4
|
|
|
|
sta PATTERN_L ; 3
|
|
|
|
lda PT3_LOC+PT3_PATTERN_LOC_H ; 4
|
|
|
|
adc #>PT3_LOC ; assume page boundary ; 2
|
|
|
|
sta PATTERN_H ; 3
|
|
|
|
|
|
|
|
; First 16-bits points to the Channel A address
|
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
sta note_a+NOTE_ADDR_L ; 4
|
|
|
|
iny ; 2
|
2019-05-30 14:53:33 +00:00
|
|
|
clc ; needed? ; 2
|
2019-05-20 14:11:29 +00:00
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
adc #>PT3_LOC ; assume page boundary ; 2
|
|
|
|
sta note_a+NOTE_ADDR_H ; 4
|
|
|
|
iny ; 2
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; Next 16-bits points to the Channel B address
|
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
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
|
2019-05-14 15:52:50 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; Next 16-bits points to the Channel C address
|
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
sta note_c+NOTE_ADDR_L ; 4
|
|
|
|
iny ; 2
|
|
|
|
lda (PATTERN_L),Y ; 5+
|
|
|
|
adc #>PT3_LOC ; assume page boundary ; 2
|
|
|
|
sta note_c+NOTE_ADDR_H ; 4
|
2019-05-14 15:52:50 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; clear out the noise channel
|
|
|
|
lda #0 ; 2
|
|
|
|
sta pt3_noise_period ; 4
|
2019-05-14 15:52:50 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
; Set all three channels as active
|
|
|
|
; FIXME: num_channels, may need to be 6 if doing 6-channel pt3?
|
|
|
|
lda #3 ; 2
|
|
|
|
sta pt3_pattern_done ; 4
|
2019-05-10 04:22:17 +00:00
|
|
|
|
2019-05-20 14:11:29 +00:00
|
|
|
rts ; 6
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-07 19:11:52 +00:00
|
|
|
;=====================================
|
|
|
|
; pt3 make frame
|
|
|
|
;=====================================
|
2019-05-20 14:11:29 +00:00
|
|
|
; update pattern or line if necessary
|
|
|
|
; then calculate the values for the next frame
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-06-01 04:45:24 +00:00
|
|
|
;==========================
|
|
|
|
; pattern done early!
|
2019-05-10 14:57:08 +00:00
|
|
|
|
2019-06-01 04:45:24 +00:00
|
|
|
early_end:
|
|
|
|
inc current_pattern ; increment pattern ; 6
|
|
|
|
sta current_line ; 4
|
|
|
|
sta current_subframe ; 4
|
2019-05-20 14:11:29 +00:00
|
|
|
|
2019-06-01 04:45:24 +00:00
|
|
|
check_subframe:
|
2019-05-20 14:11:29 +00:00
|
|
|
lda current_subframe ; 4
|
|
|
|
bne pattern_good ; 2/3
|
2019-05-10 14:57:08 +00:00
|
|
|
|
2019-05-14 16:27:06 +00:00
|
|
|
; load a new pattern in
|
2019-05-20 14:11:29 +00:00
|
|
|
jsr pt3_set_pattern ;6+?
|
2019-05-10 14:57:08 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
lda DONE_SONG ; 3
|
|
|
|
beq pattern_good ; 2/3
|
|
|
|
rts ; 6
|
2019-05-14 03:27:44 +00:00
|
|
|
|
2019-06-01 04:45:24 +00:00
|
|
|
pt3_make_frame:
|
|
|
|
|
|
|
|
; see if we need a new pattern
|
|
|
|
; we do if line==0 and subframe==0
|
|
|
|
; allow fallthrough where possible
|
|
|
|
lda current_line ; 4
|
|
|
|
beq check_subframe ; 2/3
|
|
|
|
|
2019-05-10 14:57:08 +00:00
|
|
|
pattern_good:
|
|
|
|
|
|
|
|
; see if we need a new line
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
lda current_subframe ; 4
|
|
|
|
bne line_good ; 2/3
|
2019-05-10 14:57:08 +00:00
|
|
|
|
|
|
|
; decode a new line
|
2019-05-20 16:40:35 +00:00
|
|
|
jsr pt3_decode_line ; 6+?
|
2019-05-13 18:50:33 +00:00
|
|
|
|
2019-05-14 16:27:06 +00:00
|
|
|
; check if pattern done early
|
2019-05-20 16:40:35 +00:00
|
|
|
lda pt3_pattern_done ; 4
|
2019-06-01 04:45:24 +00:00
|
|
|
beq early_end ; 2/3
|
2019-05-14 16:27:06 +00:00
|
|
|
|
2019-05-10 14:57:08 +00:00
|
|
|
line_good:
|
|
|
|
|
|
|
|
; Increment everything
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
inc current_subframe ; subframe++ ; 6
|
|
|
|
lda current_subframe ; 4
|
|
|
|
|
|
|
|
; if we hit pt3_speed, move to next
|
2019-06-01 04:45:24 +00:00
|
|
|
eor pt3_speed ; 4
|
2019-05-20 16:40:35 +00:00
|
|
|
bne do_frame ; 2/3
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
next_line:
|
2019-06-01 04:45:24 +00:00
|
|
|
sta current_subframe ; reset subframe to 0 ; 4
|
2019-05-09 04:28:52 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
inc current_line ; and increment line ; 6
|
|
|
|
lda current_line ; 4
|
2019-05-14 15:52:50 +00:00
|
|
|
|
2019-06-01 04:45:24 +00:00
|
|
|
eor #64 ; always end at 64. ; 2
|
2019-05-20 16:40:35 +00:00
|
|
|
bne do_frame ; is this always needed? ; 2/3
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
next_pattern:
|
2019-06-01 04:45:24 +00:00
|
|
|
sta current_line ; reset line to 0 ; 4
|
2019-05-10 14:57:08 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
inc current_pattern ; increment pattern ; 6
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
do_frame:
|
2019-05-07 19:11:52 +00:00
|
|
|
; AY-3-8910 register summary
|
|
|
|
;
|
|
|
|
; R0/R1 = A period low/high
|
|
|
|
; R2/R3 = B period low/high
|
|
|
|
; R4/R5 = C period low/high
|
2019-05-20 03:42:13 +00:00
|
|
|
; R6 = Noise period
|
|
|
|
; R7 = Enable XX Noise=!CBA Tone=!CBA
|
2019-05-07 19:11:52 +00:00
|
|
|
; R8/R9/R10 = Channel A/B/C amplitude M3210, M=envelope enable
|
|
|
|
; R11/R12 = Envelope Period low/high
|
|
|
|
; R13 = Envelope Shape, 0xff means don't write
|
|
|
|
; R14/R15 = I/O (ignored)
|
|
|
|
|
2019-05-30 14:54:03 +00:00
|
|
|
lda #0 ; 2
|
2019-05-20 16:40:35 +00:00
|
|
|
sta pt3_mixer_value ; 4
|
|
|
|
sta pt3_envelope_add ; 4
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
ldx #(NOTE_STRUCT_SIZE*0) ; Note A ; 2
|
|
|
|
jsr calculate_note ; 6+?
|
|
|
|
ldx #(NOTE_STRUCT_SIZE*1) ; Note B ; 2
|
|
|
|
jsr calculate_note ; 6+?
|
|
|
|
ldx #(NOTE_STRUCT_SIZE*2) ; Note C ; 2
|
|
|
|
jsr calculate_note ; 6+?
|
2019-05-07 19:11:52 +00:00
|
|
|
|
|
|
|
; Load up the Frequency Registers
|
|
|
|
|
2019-05-30 14:54:03 +00:00
|
|
|
lda note_a+NOTE_TONE_L ; Note A Period L ; 4
|
|
|
|
sta AY_REGISTERS+0 ; into R0 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
lda note_a+NOTE_TONE_H ; Note A Period H ; 4
|
|
|
|
sta AY_REGISTERS+1 ; into R1 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
|
|
|
|
; FIXME: make this self-modifying?
|
|
|
|
|
|
|
|
lda convert_177 ; 4
|
|
|
|
beq no_scale_a ; 2/3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
; conversion costs 100 cycles!
|
|
|
|
|
2019-05-17 02:16:50 +00:00
|
|
|
; first multiply by 8
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+0 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+1 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+0 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+1 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+0 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+1 ; 5
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; add in original to get 9
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
2019-05-30 14:54:03 +00:00
|
|
|
lda note_a+NOTE_TONE_L ; 4
|
|
|
|
adc AY_REGISTERS+0 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
sta AY_REGISTERS+0 ; 3
|
|
|
|
lda note_a+NOTE_TONE_H ; 4
|
|
|
|
adc AY_REGISTERS+1 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
sta AY_REGISTERS+1 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; divide by 16 to get proper value
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+1 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+0 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+1 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+0 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+1 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+0 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+1 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+0 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
lda AY_REGISTERS+1 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
and #$0f ; 2
|
|
|
|
sta AY_REGISTERS+1 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
no_scale_a:
|
|
|
|
|
2019-05-30 14:54:03 +00:00
|
|
|
lda note_b+NOTE_TONE_L ; Note B Period L ; 4
|
|
|
|
sta AY_REGISTERS+2 ; into R2 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
lda note_b+NOTE_TONE_H ; Note B Period H ; 4
|
|
|
|
sta AY_REGISTERS+3 ; into R3 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
|
|
|
|
lda convert_177 ; 4
|
|
|
|
beq no_scale_b ; 2/3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
|
|
|
|
|
|
|
|
; first multiply by 8
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+2 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+3 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+2 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+3 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+2 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+3 ; 5
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; add in original to get 9
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
2019-05-30 14:54:03 +00:00
|
|
|
lda note_b+NOTE_TONE_L ; 4
|
|
|
|
adc AY_REGISTERS+2 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
sta AY_REGISTERS+2 ; 3
|
|
|
|
lda note_b+NOTE_TONE_H ; 4
|
|
|
|
adc AY_REGISTERS+3 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
sta AY_REGISTERS+3 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; divide by 16 to get proper value
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+3 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+2 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+3 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+2 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+3 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+2 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+3 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+2 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
lda AY_REGISTERS+3 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
and #$0f ; 2
|
|
|
|
sta AY_REGISTERS+3 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
no_scale_b:
|
|
|
|
|
2019-05-30 14:54:03 +00:00
|
|
|
lda note_c+NOTE_TONE_L ; Note C Period L ; 4
|
|
|
|
sta AY_REGISTERS+4 ; into R4 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
lda note_c+NOTE_TONE_H ; Note C Period H ; 4
|
|
|
|
sta AY_REGISTERS+5 ; into R5 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
|
|
|
|
lda convert_177 ; 4
|
|
|
|
beq no_scale_c ; 2/3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
|
|
|
|
|
|
|
|
; first multiply by 8
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+4 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+5 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+4 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+5 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+4 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+5 ; 5
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; add in original to get 9
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
2019-05-30 14:54:03 +00:00
|
|
|
lda note_c+NOTE_TONE_L ; 4
|
|
|
|
adc AY_REGISTERS+4 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
sta AY_REGISTERS+4 ; 3
|
|
|
|
lda note_c+NOTE_TONE_H ; 4
|
|
|
|
adc AY_REGISTERS+5 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
sta AY_REGISTERS+5 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; divide by 16 to get proper value
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+5 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+4 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+5 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+4 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+5 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+4 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+5 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+4 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
lda AY_REGISTERS+5 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
and #$0f ; 2
|
|
|
|
sta AY_REGISTERS+5 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
no_scale_c:
|
|
|
|
|
|
|
|
|
2019-05-07 19:11:52 +00:00
|
|
|
; Noise
|
|
|
|
; frame[6]= (pt3->noise_period+pt3->noise_add)&0x1f;
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
|
|
|
lda pt3_noise_period ; 4
|
|
|
|
adc pt3_noise_add ; 4
|
|
|
|
and #$1f ; 2
|
|
|
|
sta AY_REGISTERS+6 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
sta temp_word_l ; 4
|
2019-05-17 02:16:50 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
lda convert_177 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
beq no_scale_n ; 2/3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
|
|
|
|
|
|
|
|
; first multiply by 8
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+6 ; 5
|
|
|
|
asl AY_REGISTERS+6 ; 5
|
|
|
|
asl AY_REGISTERS+6 ; 5
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; add in original to get 9
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
2019-05-30 14:54:03 +00:00
|
|
|
lda temp_word_l ; 4
|
|
|
|
adc AY_REGISTERS+6 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; divide by 16 to get proper value
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+6 ; 5
|
|
|
|
ror AY_REGISTERS+6 ; 5
|
|
|
|
ror AY_REGISTERS+6 ; 5
|
|
|
|
ror AY_REGISTERS+6 ; 5
|
|
|
|
lda AY_REGISTERS+6 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
and #$1f ; 2
|
2019-05-30 14:53:33 +00:00
|
|
|
sta AY_REGISTERS+6 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
no_scale_n:
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
;=======================
|
2019-05-07 19:11:52 +00:00
|
|
|
; Mixer
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
lda pt3_mixer_value ; 4
|
|
|
|
sta AY_REGISTERS+7 ; 3
|
|
|
|
|
|
|
|
;=======================
|
2019-05-07 19:11:52 +00:00
|
|
|
; Amplitudes
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
lda note_a+NOTE_AMPLITUDE ; 4
|
|
|
|
sta AY_REGISTERS+8 ; 3
|
|
|
|
lda note_b+NOTE_AMPLITUDE ; 4
|
|
|
|
sta AY_REGISTERS+9 ; 3
|
|
|
|
lda note_c+NOTE_AMPLITUDE ; 4
|
|
|
|
sta AY_REGISTERS+10 ; 3
|
|
|
|
|
|
|
|
;======================================
|
2019-05-07 19:11:52 +00:00
|
|
|
; Envelope period
|
2019-05-09 15:27:08 +00:00
|
|
|
; result=period+add+slide (16-bits)
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
|
|
|
lda pt3_envelope_period_l ; 4
|
|
|
|
adc pt3_envelope_add ; 4
|
|
|
|
sta temp_word_l ; 4
|
|
|
|
lda pt3_envelope_period_h ; 4
|
|
|
|
adc #0 ; 2
|
|
|
|
sta temp_word_h ; 4
|
2019-05-09 15:27:08 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
|
|
|
lda pt3_envelope_slide_l ; 4
|
|
|
|
adc temp_word_l ; 4
|
2019-05-30 14:54:03 +00:00
|
|
|
sta temp_word_l ; 4
|
2019-05-20 16:40:35 +00:00
|
|
|
sta AY_REGISTERS+11 ; 3
|
|
|
|
lda temp_word_h ; 4
|
|
|
|
adc pt3_envelope_slide_h ; 4
|
|
|
|
sta temp_word_h ; 4
|
|
|
|
sta AY_REGISTERS+12 ; 3
|
|
|
|
|
|
|
|
lda convert_177 ; 4
|
|
|
|
beq no_scale_e ; 2/3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
|
|
|
|
|
|
|
|
; first multiply by 8
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+11 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+12 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+11 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+12 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
asl AY_REGISTERS+11 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
rol AY_REGISTERS+12 ; 5
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; add in original to get 9
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 2
|
2019-05-30 14:54:03 +00:00
|
|
|
lda temp_word_l ; 4
|
2019-05-20 16:40:35 +00:00
|
|
|
adc AY_REGISTERS+11 ; 3
|
|
|
|
sta AY_REGISTERS+11 ; 3
|
|
|
|
lda temp_word_h ; 4
|
|
|
|
adc AY_REGISTERS+12 ; 3
|
2019-05-30 14:54:03 +00:00
|
|
|
sta AY_REGISTERS+12 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
; divide by 16 to get proper value
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+12 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+11 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+12 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+11 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+12 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+11 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
ror AY_REGISTERS+12 ; 5
|
2019-05-20 16:40:35 +00:00
|
|
|
ror AY_REGISTERS+11 ; 5
|
2019-05-30 14:54:03 +00:00
|
|
|
lda AY_REGISTERS+12 ; 3
|
2019-05-20 16:40:35 +00:00
|
|
|
and #$0f ; 2
|
|
|
|
sta AY_REGISTERS+12 ; 3
|
2019-05-17 02:16:50 +00:00
|
|
|
|
|
|
|
no_scale_e:
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
;========================
|
2019-05-09 04:28:52 +00:00
|
|
|
; Envelope shape
|
2019-05-20 16:40:35 +00:00
|
|
|
|
|
|
|
lda pt3_envelope_type ; 4
|
|
|
|
cmp pt3_envelope_type_old ; 4
|
|
|
|
bne envelope_diff ; 2/3
|
2019-05-09 04:28:52 +00:00
|
|
|
envelope_same:
|
2019-05-20 16:40:35 +00:00
|
|
|
lda #$ff ; if same, store $ff ; 2
|
2019-05-09 04:28:52 +00:00
|
|
|
envelope_diff:
|
2019-05-20 16:40:35 +00:00
|
|
|
sta AY_REGISTERS+13 ; 3
|
|
|
|
|
2019-05-30 14:54:03 +00:00
|
|
|
lda pt3_envelope_type ; 4
|
|
|
|
sta pt3_envelope_type_old ; copy old to new ; 4
|
|
|
|
|
2019-05-09 04:28:52 +00:00
|
|
|
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
;==============================
|
|
|
|
; end-of-frame envelope update
|
|
|
|
;==============================
|
2019-05-09 04:28:52 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
lda pt3_envelope_delay ; 4
|
|
|
|
beq done_do_frame ; assume can't be negative? ; 2/3
|
2019-05-09 15:27:08 +00:00
|
|
|
; do this if envelope_delay>0
|
2019-05-20 16:40:35 +00:00
|
|
|
dec pt3_envelope_delay ; 6
|
|
|
|
bne done_do_frame ; 2/3
|
2019-05-09 15:27:08 +00:00
|
|
|
; only do if we hit 0
|
2019-05-20 16:40:35 +00:00
|
|
|
lda pt3_envelope_delay_orig ; reset envelope delay ; 4
|
|
|
|
sta pt3_envelope_delay ; 4
|
2019-05-09 15:27:08 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
clc ; 16-bit add ; 2
|
|
|
|
lda pt3_envelope_slide_l ; 4
|
|
|
|
adc pt3_envelope_slide_add_l ; 4
|
|
|
|
sta pt3_envelope_slide_l ; 4
|
|
|
|
lda pt3_envelope_slide_h ; 4
|
|
|
|
adc pt3_envelope_slide_add_h ; 4
|
|
|
|
sta pt3_envelope_slide_h ; 4
|
2019-05-09 15:27:08 +00:00
|
|
|
|
|
|
|
done_do_frame:
|
2019-05-07 19:11:52 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
rts ; 6
|
2019-05-07 15:33:07 +00:00
|
|
|
|
|
|
|
;======================================
|
|
|
|
; GetNoteFreq
|
|
|
|
;======================================
|
|
|
|
; Return frequency from lookup table
|
2019-05-13 00:11:17 +00:00
|
|
|
; Which note is in A
|
|
|
|
; return in freq_l/freq_h
|
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
; FIXME: self modify code
|
|
|
|
GetNoteFreq:
|
2019-05-07 15:33:07 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
sty ysave ; 4
|
2019-05-13 00:11:17 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
tay ; 2
|
|
|
|
lda PT3_LOC+PT3_HEADER_FREQUENCY ; 4
|
|
|
|
cmp #1 ; 2
|
|
|
|
bne freq_table_2 ; 2/3
|
2019-05-07 15:33:07 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
lda PT3NoteTable_ST_high,Y ; 4+
|
|
|
|
sta freq_h ; 4
|
|
|
|
lda PT3NoteTable_ST_low,Y ; 4+
|
|
|
|
sta freq_l ; 4
|
2019-05-13 00:11:17 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
ldy ysave ; 4
|
|
|
|
rts ; 6
|
|
|
|
;===========
|
|
|
|
; 40
|
2019-05-13 00:11:17 +00:00
|
|
|
|
2019-05-07 04:43:20 +00:00
|
|
|
|
2019-05-20 16:40:35 +00:00
|
|
|
freq_table_2:
|
|
|
|
lda PT3NoteTable_ASM_34_35_high,Y ; 4+
|
|
|
|
sta freq_h ; 4
|
|
|
|
lda PT3NoteTable_ASM_34_35_low,Y ; 4+
|
|
|
|
sta freq_l ; 4
|
|
|
|
|
|
|
|
ldy ysave ; 4
|
|
|
|
rts ; 6
|
|
|
|
;===========
|
|
|
|
; 41
|
2019-05-07 04:43:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2019-05-07 15:17:46 +00:00
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2019-05-07 15:33:07 +00:00
|
|
|
PT3NoteTable_ASM_34_35_low:
|
2019-05-07 15:17:46 +00:00
|
|
|
.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
|
|
|
|
|
|
|
|
|
2019-05-22 19:37:00 +00:00
|
|
|
;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
|
2019-05-07 15:17:46 +00:00
|
|
|
|
|
|
|
|
2019-05-22 04:31:31 +00:00
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
;==========================
|
|
|
|
; 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
|
|
|
|
|
|
|
|
|
2019-05-22 04:31:31 +00:00
|
|
|
z80_h: .byte $0
|
|
|
|
z80_l: .byte $0
|
|
|
|
z80_d: .byte $0
|
|
|
|
z80_e: .byte $0
|
|
|
|
|
2019-05-30 14:53:33 +00:00
|
|
|
VolTableCreator:
|
|
|
|
|
|
|
|
; Init initial variables
|
|
|
|
lda #$0
|
|
|
|
sta z80_h
|
|
|
|
sta z80_d
|
|
|
|
sta z80_e
|
|
|
|
lda #$11
|
|
|
|
sta z80_l
|
|
|
|
|
|
|
|
; Set up self modify
|
|
|
|
|
|
|
|
lda #$2A ; ROL for self-modify
|
|
|
|
bcs vol_type_35
|
|
|
|
|
|
|
|
vol_type_33:
|
|
|
|
|
|
|
|
; For older table, we set initial conditions a bit
|
|
|
|
; different
|
|
|
|
|
|
|
|
lda #$10
|
|
|
|
sta z80_l ; l=16
|
|
|
|
sta z80_e ; e=16
|
|
|
|
|
|
|
|
lda #$ea ; NOP for self modify
|
|
|
|
|
|
|
|
vol_type_35:
|
|
|
|
sta vol_smc ; set the self-modify code
|
|
|
|
|
|
|
|
ldy #16 ; skip first row, all zeros
|
|
|
|
ldx #16 ; c=16
|
|
|
|
vol_outer:
|
|
|
|
lda z80_h
|
|
|
|
pha
|
|
|
|
lda z80_l
|
|
|
|
pha ; save HL
|
|
|
|
|
|
|
|
clc ; add HL,DE
|
2019-05-30 14:54:03 +00:00
|
|
|
lda z80_l
|
2019-05-30 14:53:33 +00:00
|
|
|
adc z80_e
|
2019-05-30 14:54:03 +00:00
|
|
|
sta z80_l
|
2019-05-30 14:53:33 +00:00
|
|
|
lda z80_h
|
|
|
|
adc z80_d
|
2019-05-30 14:54:03 +00:00
|
|
|
sta z80_h ; carry is important
|
|
|
|
|
|
|
|
lda z80_h ; ex de,hl ; swap
|
|
|
|
pha
|
|
|
|
lda z80_l
|
|
|
|
pha
|
|
|
|
lda z80_d
|
|
|
|
sta z80_h
|
|
|
|
lda z80_e
|
|
|
|
sta z80_l
|
|
|
|
pla
|
|
|
|
sta z80_e
|
|
|
|
pla
|
|
|
|
sta z80_d
|
2019-05-30 14:53:33 +00:00
|
|
|
|
|
|
|
; sbc hl,hl
|
|
|
|
bcs vol_ffs
|
|
|
|
vol_zeros:
|
|
|
|
lda #0
|
2019-05-30 14:54:03 +00:00
|
|
|
beq vol_write
|
2019-05-30 14:53:33 +00:00
|
|
|
|
|
|
|
vol_ffs:
|
2019-05-30 14:54:03 +00:00
|
|
|
lda #$ff
|
2019-05-30 14:53:33 +00:00
|
|
|
vol_write:
|
|
|
|
sta z80_h
|
|
|
|
sta z80_l
|
|
|
|
|
|
|
|
vol_inner:
|
|
|
|
lda z80_l
|
|
|
|
|
|
|
|
vol_smc:
|
|
|
|
nop ; nop or ROL depending
|
|
|
|
|
|
|
|
lda z80_h
|
|
|
|
|
|
|
|
adc #$0 ; a=a+carry;
|
|
|
|
|
|
|
|
sta VolumeTable,Y
|
|
|
|
iny
|
|
|
|
|
|
|
|
clc ; add HL,DE
|
|
|
|
lda z80_l
|
|
|
|
adc z80_e
|
|
|
|
sta z80_l
|
|
|
|
lda z80_h
|
|
|
|
adc z80_d
|
|
|
|
sta z80_h
|
|
|
|
|
|
|
|
inx ; inc C
|
|
|
|
txa ; a=c
|
|
|
|
and #$f
|
|
|
|
bne vol_inner
|
|
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
sta z80_l
|
|
|
|
pla
|
|
|
|
sta z80_h ; restore HL
|
|
|
|
|
|
|
|
lda z80_e ; a=e
|
|
|
|
cmp #$77
|
|
|
|
bne vol_m3
|
|
|
|
|
|
|
|
inc z80_e
|
|
|
|
bne vol_blah
|
|
|
|
inc z80_d
|
|
|
|
vol_blah:
|
|
|
|
|
|
|
|
vol_m3:
|
|
|
|
txa ; a=c
|
|
|
|
;bne vol_outer
|
|
|
|
beq vol_done
|
|
|
|
jmp vol_outer
|
|
|
|
|
|
|
|
vol_done:
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-22 04:31:31 +00:00
|
|
|
VolumeTable:
|
|
|
|
.res 256,0
|
2019-05-22 19:37:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
pt3_lib_end:
|