From da37bbf9a15bf5aa8e9fc7e0e123abc231733cdf Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 4 Nov 2021 14:06:52 -0400 Subject: [PATCH] tiny_music: optimize some more --- demos/tiny_music/Makefile | 2 +- demos/tiny_music/mockingboard_setup.s | 52 +++++++++++---------------- demos/tiny_music/music.s | 5 +-- demos/tiny_music/nozp.inc | 27 -------------- demos/tiny_music/yankee_music.s | 8 +++++ 5 files changed, 30 insertions(+), 64 deletions(-) delete mode 100644 demos/tiny_music/nozp.inc diff --git a/demos/tiny_music/Makefile b/demos/tiny_music/Makefile index 10a16844..607d0051 100644 --- a/demos/tiny_music/Makefile +++ b/demos/tiny_music/Makefile @@ -26,7 +26,7 @@ MUSIC: music.o ld65 -o MUSIC music.o -C $(LINKER_SCRIPTS)/apple2_2000.inc music.o: music.s \ - zp.inc hardware.inc nozp.inc \ + zp.inc hardware.inc \ yankee_music.s \ interrupt_handler.s mockingboard_setup.s ca65 -o music.o music.s -l music.lst diff --git a/demos/tiny_music/mockingboard_setup.s b/demos/tiny_music/mockingboard_setup.s index 67502722..67385e1d 100644 --- a/demos/tiny_music/mockingboard_setup.s +++ b/demos/tiny_music/mockingboard_setup.s @@ -151,45 +151,33 @@ mockingboard_setup_interrupt: sta MOCK_6522_ORB2 init_registers: + + ; init song data + lda #0 sta SONG_OFFSET sta SONG_COUNTDOWN - ; set fine note A + ; read 14 bytes from beginning of song to init - ldx #$00 - lda #$00 + ldx #13 +init_loop: +init_smc: + txa + tay + lda (SONG_L),Y jsr ay3_write_reg + dex + bne init_loop - ; set coarse note A - - ldx #$01 - lda #$00 - jsr ay3_write_reg - - ; set mixer ABC enabled - - ldx #$07 - lda #$38 - jsr ay3_write_reg - - ; A volume 14 - - ldx #$08 - lda #$E - jsr ay3_write_reg - - ; B volume 12 - - ldx #$09 - lda #$C - jsr ay3_write_reg - - ; C volume 12 - - ldx #$0A - lda #$C - jsr ay3_write_reg + ; update SONG_L to point to beginning + lda SONG_L + clc + adc #14 + sta SONG_L + bcc no_oflo + inc SONG_H +no_oflo: rts diff --git a/demos/tiny_music/music.s b/demos/tiny_music/music.s index 4b8e48f5..1b925640 100644 --- a/demos/tiny_music/music.s +++ b/demos/tiny_music/music.s @@ -2,14 +2,13 @@ ; 514B -- Initial implementation ; 423B -- inline everything +; 400B -- put register init at end of song SONG_L = $70 SONG_H = $71 SONG_OFFSET = $72 SONG_COUNTDOWN = $73 - - ; proposed format ; CCOONNNN -- c=channel, o=octave, n=note ; 11LLLLLL -- L=length @@ -51,6 +50,4 @@ forever: .include "mockingboard_setup.s" .include "interrupt_handler.s" - .include "nozp.inc" - .include "yankee_music.s" diff --git a/demos/tiny_music/nozp.inc b/demos/tiny_music/nozp.inc deleted file mode 100644 index 239a25c1..00000000 --- a/demos/tiny_music/nozp.inc +++ /dev/null @@ -1,27 +0,0 @@ -;; Things that normally would go in the zero page - - -AY_REGISTERS: -A_FINE_TONE: .byte $00 -A_COARSE_TONE: .byte $00 -B_FINE_TONE: .byte $00 -B_COARSE_TONE: .byte $00 -C_FINE_TONE: .byte $00 -C_COARSE_TONE: .byte $00 -NOISE: .byte $00 -ENABLE: -PT3_MIXER_VAL: .byte $00 -A_VOLUME: .byte $00 -B_VOLUME: .byte $00 -C_VOLUME: .byte $00 -ENVELOPE_FINE: .byte $00 -ENVELOPE_COARSE:.byte $00 -ENVELOPE_SHAPE: .byte $00 - -LOOP: .byte $00 -MB_VALUE: .byte $00 -DONE_PLAYING: .byte $00 -DONE_SONG: .byte $00 -PT3_TEMP: .byte $00 - - diff --git a/demos/tiny_music/yankee_music.s b/demos/tiny_music/yankee_music.s index 6ebe061d..c5d39612 100644 --- a/demos/tiny_music/yankee_music.s +++ b/demos/tiny_music/yankee_music.s @@ -6,6 +6,14 @@ ; 11LLLLLL -- L=length 1/32=1, 1/16=2, 1/8=4, 1/4=8 1/2=16 1=32 yankee_doodle_song: + +; register init + .byte $00,$00,$00,$00,$00,$00 ; $00: A/B/C fine/coarse + .byte $00 ; $06 + .byte $38 ; $07 mixer (ABC on) + .byte $0E,$0C,$0C ; $08 volume A/B/C + .byte $00,$00,$00,$00 ; $09 +; music .byte $17 ;00 01 0111 G3 1/4 .byte $4B ;01 00 1011 B2 1 .byte $87 ;10 00 0111 G2 1