tiny_music: optimize some more

This commit is contained in:
Vince Weaver 2021-11-04 14:06:52 -04:00
parent 902e1cdcbe
commit da37bbf9a1
5 changed files with 30 additions and 64 deletions

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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