mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-29 08:55:10 +00:00
tiny_tracker: optimize some more
This commit is contained in:
parent
bb7ff255cb
commit
6896a3e6b7
@ -12,17 +12,6 @@ submit: hgr_d2_1k.zip
|
|||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
hgr_d2_1k.zip: D2 d2.s file_id.diz hgr_d2.dsk
|
|
||||||
mkdir -p demosplash2021_hgr_d2_1k
|
|
||||||
cp D2 ./demosplash2021_hgr_d2_1k
|
|
||||||
cp *.s ./demosplash2021_hgr_d2_1k
|
|
||||||
cp file_id.diz ./demosplash2021_hgr_d2_1k
|
|
||||||
cp hgr_d2.dsk ./demosplash2021_hgr_d2_1k
|
|
||||||
cp hgr_d2.webm ./demosplash2021_hgr_d2_1k
|
|
||||||
zip -r hgr_d2_1k.zip demosplash2021_hgr_d2_1k
|
|
||||||
|
|
||||||
####
|
|
||||||
|
|
||||||
hgr_d2.dsk: HELLO D2
|
hgr_d2.dsk: HELLO D2
|
||||||
cp $(EMPTY_DISK)/empty.dsk ./hgr_d2.dsk
|
cp $(EMPTY_DISK)/empty.dsk ./hgr_d2.dsk
|
||||||
$(DOS33) -y hgr_d2.dsk SAVE A HELLO
|
$(DOS33) -y hgr_d2.dsk SAVE A HELLO
|
||||||
@ -57,8 +46,8 @@ D2: d2.o
|
|||||||
d2.o: d2.s \
|
d2.o: d2.s \
|
||||||
zp.inc hardware.inc \
|
zp.inc hardware.inc \
|
||||||
mA2E_2.s mA2E_3.s \
|
mA2E_2.s mA2E_3.s \
|
||||||
interrupt_handler.s mockingboard_init.s play_frame.s \
|
mockingboard_init.s play_frame.s \
|
||||||
tracker_init.s mockingboard_constants.s ay3_write_regs.s
|
tracker_init.s ay3_write_regs.s
|
||||||
ca65 -o d2.o d2.s -l d2.lst
|
ca65 -o d2.o d2.s -l d2.lst
|
||||||
|
|
||||||
####
|
####
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
;=====================
|
;=====================
|
||||||
;=====================
|
;=====================
|
||||||
;=====================
|
;=====================
|
||||||
@ -6,9 +5,7 @@
|
|||||||
;=====================
|
;=====================
|
||||||
;=====================
|
;=====================
|
||||||
;=====================
|
;=====================
|
||||||
; write all 14 registers
|
; write all 14 registers at AY_REGS
|
||||||
; address in X
|
|
||||||
; data in A
|
|
||||||
|
|
||||||
ay3_write_regs:
|
ay3_write_regs:
|
||||||
|
|
||||||
|
@ -9,11 +9,13 @@
|
|||||||
; aiming for under 256
|
; aiming for under 256
|
||||||
|
|
||||||
; 310 bytes -- initial
|
; 310 bytes -- initial
|
||||||
|
; 268 bytes -- strip out interrupts
|
||||||
|
; 262 bytes -- simplify init
|
||||||
; if can straddle interrupt vector, save 10 bytes
|
; 261 bytes -- optimize init more
|
||||||
; if can guarantee Y is 0 on entry, save 2 bytes
|
; 253 bytes -- optimize var init
|
||||||
|
; 252 bytes -- bne vs jmp
|
||||||
|
; 250 bytes -- song only has 16 notes so can never be negative
|
||||||
|
; 249 bytes -- make terminating value $80 instead of $FF
|
||||||
|
|
||||||
d2:
|
d2:
|
||||||
|
|
||||||
@ -30,24 +32,21 @@ tracker_song = peasant_song
|
|||||||
|
|
||||||
.include "tracker_init.s"
|
.include "tracker_init.s"
|
||||||
|
|
||||||
|
game_loop:
|
||||||
|
|
||||||
; start the music playing
|
; start the music playing
|
||||||
|
|
||||||
cli
|
.include "play_frame.s"
|
||||||
|
|
||||||
bob:
|
|
||||||
lda KEYPRESS
|
|
||||||
bpl bob
|
|
||||||
|
|
||||||
quiet:
|
; delay 20Hz, or 1/20s = 50ms
|
||||||
lda #$3f
|
|
||||||
sta AY_REGS+7
|
|
||||||
|
|
||||||
end:
|
lda #140
|
||||||
bne end
|
jsr WAIT
|
||||||
|
|
||||||
|
beq game_loop
|
||||||
|
|
||||||
|
|
||||||
; music
|
; music
|
||||||
.include "mA2E_2.s"
|
.include "mA2E_2.s"
|
||||||
.include "interrupt_handler.s"
|
|
||||||
; must be last
|
|
||||||
.include "mockingboard_constants.s"
|
|
||||||
|
@ -61,45 +61,17 @@ MOCK_AY_LATCH_ADDR = $7 ; 1 1 1
|
|||||||
|
|
||||||
mockingboard_init:
|
mockingboard_init:
|
||||||
|
|
||||||
; sei ; disable interrupts, is this necessary?
|
|
||||||
|
|
||||||
;=========================
|
|
||||||
; Setup Interrupt Handler
|
|
||||||
;=========================
|
|
||||||
|
|
||||||
; NOTE: we don't support IIc as it's a hack
|
|
||||||
; traditionally Mockingboard on IIc was rare
|
|
||||||
|
|
||||||
;========================
|
|
||||||
; set up interrupt
|
|
||||||
; Vector address goes to 0x3fe/0x3ff
|
|
||||||
|
|
||||||
; can save 10 bytes if we load in memory so this
|
|
||||||
; is in the right place automatically
|
|
||||||
|
|
||||||
lda #<interrupt_handler ; 2
|
|
||||||
sta $03fe ; 3
|
|
||||||
lda #>interrupt_handler ; 2
|
|
||||||
sta $03ff ; 3
|
|
||||||
;=========
|
|
||||||
; 10
|
|
||||||
;=========================
|
;=========================
|
||||||
; Initialize the 6522s
|
; Initialize the 6522s
|
||||||
; Reset Left AY-3-8910
|
; Reset Left AY-3-8910
|
||||||
;===========================
|
;===========================
|
||||||
|
|
||||||
; entries=10
|
ldx #$FF
|
||||||
; 14 + 2*entries = 34 bytes
|
stx MOCK_6522_DDRB1
|
||||||
|
stx MOCK_6522_DDRA1
|
||||||
ldy #0 ; 2
|
|
||||||
init_it_loop:
|
|
||||||
lda init_values,Y ; 3
|
|
||||||
ldx init_addresses,Y ; 3
|
|
||||||
bmi doneit ; 2
|
|
||||||
iny ; 1
|
|
||||||
sta $c400,X ; 3
|
|
||||||
bne init_it_loop ; 2
|
|
||||||
doneit:
|
|
||||||
|
|
||||||
|
|
||||||
|
inx ; #MOCK_AY_RESET $0
|
||||||
|
stx MOCK_6522_ORB1
|
||||||
|
ldx #MOCK_AY_INACTIVE ; $4
|
||||||
|
stx MOCK_6522_ORB1
|
||||||
|
|
||||||
|
@ -1,16 +1,4 @@
|
|||||||
play_frame:
|
play_frame:
|
||||||
; drop note down after first
|
|
||||||
; lda #$C
|
|
||||||
; sta AY_REGS+8
|
|
||||||
; sta AY_REGS+9
|
|
||||||
; sta AY_REGS+10
|
|
||||||
|
|
||||||
lda #$0E
|
|
||||||
sta AY_REGS+8 ; $08 volume A
|
|
||||||
lda #$0C
|
|
||||||
sta AY_REGS+9 ; $09 volume B
|
|
||||||
sta AY_REGS+10 ; $0A volume C
|
|
||||||
|
|
||||||
|
|
||||||
;============================
|
;============================
|
||||||
; see if still counting down
|
; see if still counting down
|
||||||
@ -29,18 +17,19 @@ set_notes_loop:
|
|||||||
;==================
|
;==================
|
||||||
; see if hit end
|
; see if hit end
|
||||||
|
|
||||||
cmp #$FF
|
; this song only 16 notes so valid notes always positive
|
||||||
bne all_ok
|
; cmp #$80
|
||||||
|
bpl all_ok
|
||||||
|
|
||||||
;====================================
|
;====================================
|
||||||
; if at end, loop back to beginning
|
; if at end, loop back to beginning
|
||||||
|
|
||||||
lda #0 ; reset song offset
|
asl ; reset song offset to 0
|
||||||
sta SONG_OFFSET
|
sta SONG_OFFSET
|
||||||
beq set_notes_loop ; bra
|
beq set_notes_loop
|
||||||
|
|
||||||
all_ok:
|
all_ok:
|
||||||
|
|
||||||
|
|
||||||
note_only:
|
note_only:
|
||||||
|
|
||||||
; NNNNNECC -- c=channel, e=end, n=note
|
; NNNNNECC -- c=channel, e=end, n=note
|
||||||
@ -68,9 +57,6 @@ note_only:
|
|||||||
lda frequencies_high,Y
|
lda frequencies_high,Y
|
||||||
sta AY_REGS+1,X
|
sta AY_REGS+1,X
|
||||||
|
|
||||||
lda #$F
|
|
||||||
sta AY_REGS+8
|
|
||||||
|
|
||||||
;============================
|
;============================
|
||||||
; point to next
|
; point to next
|
||||||
|
|
||||||
|
@ -455,7 +455,10 @@ printf("\n");
|
|||||||
printf("; last: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
printf("; last: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
||||||
write_note(&a_last,&b_last,&c_last,&total_len);
|
write_note(&a_last,&b_last,&c_last,&total_len);
|
||||||
|
|
||||||
printf("\t.byte $FF ; end\n");
|
// printf("\t.byte $FF ; end\n");
|
||||||
|
|
||||||
|
/* assume 16 notes or fewer */
|
||||||
|
printf("\t.byte $80 ; end\n");
|
||||||
total_len++;
|
total_len++;
|
||||||
|
|
||||||
int o,n;
|
int o,n;
|
||||||
|
@ -3,21 +3,20 @@ tracker_init:
|
|||||||
; setup initial ay-3-8910 values (this depends on song)
|
; setup initial ay-3-8910 values (this depends on song)
|
||||||
|
|
||||||
init_registers_to_zero:
|
init_registers_to_zero:
|
||||||
ldx #13
|
ldx #$13 ; zero $70--$83
|
||||||
lda #0
|
lda #0
|
||||||
sta SONG_OFFSET ; also init song stuff
|
; sta SONG_OFFSET ; also init song stuff
|
||||||
sta SONG_COUNTDOWN
|
; sta SONG_COUNTDOWN
|
||||||
init_loop:
|
init_loop:
|
||||||
sta AY_REGS,X
|
sta AY_REGS,X
|
||||||
dex
|
dex
|
||||||
bpl init_loop
|
bpl init_loop
|
||||||
|
|
||||||
; jsr ay3_write_regs
|
|
||||||
|
|
||||||
lda #$38
|
lda #$38
|
||||||
sta AY_REGS+7 ; $07 mixer (ABC on)
|
sta AY_REGS+7 ; $07 mixer (ABC on)
|
||||||
; lda #$0E
|
lda #$0E
|
||||||
; sta AY_REGS+8 ; $08 volume A
|
sta AY_REGS+8 ; $08 volume A
|
||||||
; lda #$0C
|
lda #$0C
|
||||||
; sta AY_REGS+9 ; $09 volume B
|
sta AY_REGS+9 ; $09 volume B
|
||||||
; sta AY_REGS+10 ; $0A volume C
|
sta AY_REGS+10 ; $0A volume C
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user