mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-12-27 17:29:49 +00:00
pt3: init zeroed vars with loop
switching songs, sometimes they'd start wrong due to vars not being initialized. Easier to just zero everything than try to figure out which field we weren't getting. Also makes code smaller.
This commit is contained in:
parent
ea4e5f44f2
commit
ae3d819970
@ -25,6 +25,7 @@ Code Optimization
|
||||
Qkumba#1 2937 ?? 1D.18 29s 171s 17%
|
||||
Qkumba#2 2879 ?? 1C.18 28s 171s 16%
|
||||
Qkumba#3+vmw 2816 ?? 1C.22 28s 171s 16%
|
||||
Fixes,zero init 2776 ?? 1C.10 28s 171s 16%
|
||||
|
||||
Times: Validated
|
||||
BH.PT3: 10.0B 16 1:33 93 17.2%
|
||||
|
@ -1,2 +1,2 @@
|
||||
10 PRINT "PT3 PLAYER V0.7"
|
||||
10 PRINT "PT3 PLAYER V0.8"
|
||||
100 PRINT CHR$ (4)"BRUN PT3_PLAYER"
|
||||
|
@ -19,6 +19,8 @@
|
||||
; + 2832 bytes -- combine $D0 and $E0 decode
|
||||
; + 2816 bytes -- eliminate "decode_done" variable (2.75k)
|
||||
; + 2817 bytes -- eliminate pt3_version. Slighly faster but also bigger
|
||||
; + 2828 bytes -- fix some correctness issues
|
||||
; + 2776 bytes -- init vars with loop (slower, but more correct and smaller)
|
||||
|
||||
; TODO
|
||||
; move some of these flags to be bits rather than bytes?
|
||||
@ -84,16 +86,18 @@ NOTE_TONE_SLIDE_TO_STEP =39
|
||||
|
||||
NOTE_STRUCT_SIZE=40
|
||||
|
||||
note_a:
|
||||
.byte $0 ; NOTE_VOLUME ; 0
|
||||
.byte $0 ; NOTE_TONE_SLIDING_L ; 1
|
||||
.byte $0 ; NOTE_TONE_SLIDING_H ; 2
|
||||
.byte $0 ; NOTE_ENABLED ; 3
|
||||
.byte $0 ; NOTE_ENVELOPE_ENABLED ; 4
|
||||
.byte $0 ; NOTE_SAMPLE_POINTER_L ; 5
|
||||
.byte $0 ; NOTE_SAMPLE_POINTER_H ; 6
|
||||
.byte $0 ; NOTE_SAMPLE_LOOP ; 7
|
||||
.byte $0 ; NOTE_SAMPLE_LENGTH ; 8
|
||||
begin_vars:
|
||||
|
||||
note_a: ; reset?
|
||||
.byte $0 ; NOTE_VOLUME ; 0 ; Y
|
||||
.byte $0 ; NOTE_TONE_SLIDING_L ; 1 ; Y
|
||||
.byte $0 ; NOTE_TONE_SLIDING_H ; 2 ; Y
|
||||
.byte $0 ; NOTE_ENABLED ; 3 ; Y
|
||||
.byte $0 ; NOTE_ENVELOPE_ENABLED ; 4 ; Y
|
||||
.byte $0 ; NOTE_SAMPLE_POINTER_L ; 5 ; Y
|
||||
.byte $0 ; NOTE_SAMPLE_POINTER_H ; 6 ; Y
|
||||
.byte $0 ; NOTE_SAMPLE_LOOP ; 7 ; Y
|
||||
.byte $0 ; NOTE_SAMPLE_LENGTH ; 8 ; Y
|
||||
.byte $0 ; NOTE_TONE_L ; 9
|
||||
.byte $0 ; NOTE_TONE_H ; 10
|
||||
.byte $0 ; NOTE_AMPLITUDE ; 11
|
||||
@ -102,16 +106,16 @@ note_a:
|
||||
.byte $0 ; NOTE_LEN_COUNT ; 14
|
||||
.byte $0 ; NOTE_ADDR_L ; 15
|
||||
.byte $0 ; NOTE_ADDR_H ; 16
|
||||
.byte $0 ; NOTE_ORNAMENT_POINTER_L ; 17
|
||||
.byte $0 ; NOTE_ORNAMENT_POINTER_H ; 18
|
||||
.byte $0 ; NOTE_ORNAMENT_LOOP ; 19
|
||||
.byte $0 ; NOTE_ORNAMENT_LENGTH ; 20
|
||||
.byte $0 ; NOTE_ORNAMENT_POINTER_L ; 17 ; Y
|
||||
.byte $0 ; NOTE_ORNAMENT_POINTER_H ; 18 ; Y
|
||||
.byte $0 ; NOTE_ORNAMENT_LOOP ; 19 ; Y
|
||||
.byte $0 ; NOTE_ORNAMENT_LENGTH ; 20 ; Y
|
||||
.byte $0 ; NOTE_ONOFF ; 21
|
||||
.byte $0 ; NOTE_TONE_ACCUMULATOR_L ; 22
|
||||
.byte $0 ; NOTE_TONE_ACCUMULATOR_H ; 23
|
||||
.byte $0 ; NOTE_TONE_SLIDE_COUNT ; 24
|
||||
.byte $0 ; NOTE_ORNAMENT_POSITION ; 25
|
||||
.byte $0 ; NOTE_SAMPLE_POSITION ; 26
|
||||
.byte $0 ; NOTE_ORNAMENT_POSITION ; 25 ; Y
|
||||
.byte $0 ; NOTE_SAMPLE_POSITION ; 26 ; Y
|
||||
.byte $0 ; NOTE_ENVELOPE_SLIDING ; 27
|
||||
.byte $0 ; NOTE_NOISE_SLIDING ; 28
|
||||
.byte $0 ; NOTE_AMPLITUDE_SLIDING ; 29
|
||||
@ -219,23 +223,23 @@ current_line: .byte $0
|
||||
current_pattern: .byte $0
|
||||
pt3_pattern_done: .byte $0
|
||||
|
||||
pt3_noise_period: .byte $0
|
||||
pt3_noise_add: .byte $0
|
||||
pt3_noise_period: .byte $0 ; Y
|
||||
pt3_noise_add: .byte $0 ; Y
|
||||
|
||||
pt3_envelope_period_l: .byte $0
|
||||
pt3_envelope_period_h: .byte $0
|
||||
pt3_envelope_period_l: .byte $0 ; Y
|
||||
pt3_envelope_period_h: .byte $0 ; Y
|
||||
pt3_envelope_slide_l: .byte $0
|
||||
pt3_envelope_slide_h: .byte $0
|
||||
pt3_envelope_slide_add_l:.byte $0
|
||||
pt3_envelope_slide_add_h:.byte $0
|
||||
pt3_envelope_add: .byte $0
|
||||
pt3_envelope_type: .byte $0
|
||||
pt3_envelope_type: .byte $0 ; Y
|
||||
pt3_envelope_type_old: .byte $0
|
||||
pt3_envelope_delay: .byte $0
|
||||
pt3_envelope_delay_orig:.byte $0
|
||||
|
||||
pt3_mixer_value: .byte $0
|
||||
|
||||
end_vars:
|
||||
|
||||
;==========================
|
||||
; local variables
|
||||
@ -423,13 +427,22 @@ load_sample:
|
||||
; it will save bytes only if the labels are adjacent
|
||||
; it will add a lot more cycles, though
|
||||
pt3_init_song:
|
||||
|
||||
lda #$0
|
||||
sta DONE_SONG ; 3
|
||||
ldx #(end_vars-begin_vars)
|
||||
zero_song_structs_loop:
|
||||
dex
|
||||
sta note_a,X
|
||||
bne zero_song_structs_loop
|
||||
|
||||
|
||||
lda #$f ; 2
|
||||
sta note_a+NOTE_VOLUME ; 4
|
||||
sta note_b+NOTE_VOLUME ; 4
|
||||
sta note_c+NOTE_VOLUME ; 4
|
||||
|
||||
.if 0
|
||||
lda #$0 ; 2
|
||||
sta DONE_SONG ; 3
|
||||
sta note_a+NOTE_TONE_SLIDING_L ; 4
|
||||
sta note_b+NOTE_TONE_SLIDING_L ; 4
|
||||
sta note_c+NOTE_TONE_SLIDING_L ; 4
|
||||
@ -442,12 +455,16 @@ pt3_init_song:
|
||||
sta note_a+NOTE_ENVELOPE_ENABLED ; 4
|
||||
sta note_b+NOTE_ENVELOPE_ENABLED ; 4
|
||||
sta note_c+NOTE_ENVELOPE_ENABLED ; 4
|
||||
sta note_a+NOTE_SAMPLE_POSITION ; 4
|
||||
sta note_b+NOTE_SAMPLE_POSITION ; 4
|
||||
sta note_c+NOTE_SAMPLE_POSITION ; 4
|
||||
|
||||
sta pt3_noise_period ; 4
|
||||
sta pt3_noise_add ; 4
|
||||
sta pt3_envelope_period_l ; 4
|
||||
sta pt3_envelope_period_h ; 4
|
||||
sta pt3_envelope_type ; 4
|
||||
.endif
|
||||
|
||||
; default ornament/sample in A
|
||||
ldx #(NOTE_STRUCT_SIZE*0) ; 2
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user