ds: try to make the sound playing code generic

This commit is contained in:
Vince Weaver 2019-11-07 17:05:53 -05:00
parent 7b1cc8238e
commit c0cae15565
3 changed files with 122 additions and 78 deletions

View File

@ -52,6 +52,7 @@ demosplash.o: demosplash.s \
appleII_intro.s font.s \
pt3_lib_init.s pt3_lib_core.s pt3_lib_mockingboard.s \
pt3_lib_play_frame.s pt3_lib_write_frame.s \
pt3_lib_write_lc.s \
interrupt_handler.s \
missing.s k_40_48d.inc create_update_type1.s \
open_book.s graphics/book_open/book_open.inc \

View File

@ -28,84 +28,7 @@ demosplash2019:
; generate 4 patterns worth of music
; at address $D000-$FC00
; page offset
lda #0
sta FRAME_PAGE
; offset within page
lda #0
sta FRAME_OFFSET
frame_decode_loop:
jsr pt3_make_frame
jsr pt3_write_frame
inc FRAME_OFFSET
lda FRAME_OFFSET
cmp #59*3 ; FIXME: make this depend on song
; hardcoding for 59 for our song
bne frame_decode_loop
; add 11 to all of the output pointers
clc
lda r0_wrsmc+2
adc #$b
sta r0_wrsmc+2
lda r1_wrsmc+2
adc #$b
sta r1_wrsmc+2
lda r2_wrsmc+2
adc #$b
sta r2_wrsmc+2
lda r4_wrsmc+2
adc #$b
sta r4_wrsmc+2
lda r13_wrsmc+2
adc #$b
sta r13_wrsmc+2
lda r6_wrsmc+2
adc #$b
sta r6_wrsmc+2
lda r7_wrsmc+2
adc #$b
sta r7_wrsmc+2
lda r8_wrsmc+2
adc #$b
sta r8_wrsmc+2
lda r9_wrsmc+2
adc #$b
sta r9_wrsmc+2
lda r11_wrsmc+2
adc #$b
sta r11_wrsmc+2
lda r12_wrsmc+2
adc #$b
sta r12_wrsmc+2
inc FRAME_PAGE
lda FRAME_PAGE
cmp #4
bne frame_decode_loop
lda #0
sta FRAME_OFFSET
jsr pt3_write_lc_4
; lda #1
; sta LOOP
@ -275,6 +198,7 @@ wait_until_keypressed:
.include "interrupt_handler.s"
.include "pt3_lib_play_frame.s"
.include "pt3_lib_write_frame.s"
.include "pt3_lib_write_lc.s"
.include "create_update_type1.s"
.include "create_update_type2.s"

View File

@ -0,0 +1,119 @@
;====================================
; generate 4 patterns worth of music
; at address $D000-$FC00
pt3_write_lc_4:
; page offset
lda #0
sta FRAME_PAGE
lc4_frame_decode_loop:
jsr pt3_set_pages
jsr pt3_write_lc
lda FRAME_PAGE
cmp #4
bne lc4_frame_decode_loop
rts
;==============================
; write one page of frame data
pt3_write_lc_1:
; page offset
lda #0
sta FRAME_PAGE
jsr pt3_set_pages
jsr pt3_write_lc
rts
;==============================
; write one page of frame data
pt3_write_lc:
; offset within page
lda #0
sta FRAME_OFFSET
lc_frame_decode_loop:
jsr pt3_make_frame
jsr pt3_write_frame
inc FRAME_OFFSET
lda FRAME_OFFSET
cmp #59*3 ; FIXME: make this depend on song
; hardcoding for 59 for our song
bne lc_frame_decode_loop
inc FRAME_PAGE
rts
pt3_set_pages:
lda FRAME_PAGE
asl
asl
asl
asl
tay
lda music_addr_table+0,Y
sta r0_wrsmc+2
lda music_addr_table+1,Y
sta r1_wrsmc+2
lda music_addr_table+2,Y
sta r2_wrsmc+2
lda music_addr_table+3,Y
sta r4_wrsmc+2
lda music_addr_table+4,Y
sta r13_wrsmc+2
lda music_addr_table+5,Y
sta r6_wrsmc+2
lda music_addr_table+6,Y
sta r7_wrsmc+2
lda music_addr_table+7,Y
sta r8_wrsmc+2
lda music_addr_table+8,Y
sta r9_wrsmc+2
lda music_addr_table+9,Y
sta r11_wrsmc+2
lda music_addr_table+10,Y
sta r12_wrsmc+2
rts
music_table_begin:
music_addr_table:
.byte $f1,$f2,$f3,$f4,$f5,$f6,$f7,$f8,$f9,$fa,$fb,$BB,$CC,$DD,$EE,$FF
.byte $e6,$e7,$e8,$e9,$ea,$eb,$ec,$ed,$ee,$ef,$f0,$BB,$CC,$DD,$EE,$FF
.byte $db,$dc,$dd,$de,$df,$e0,$e1,$e2,$e3,$e4,$e5,$BB,$CC,$DD,$EE,$FF
.byte $d0,$d1,$d2,$d3,$d4,$d5,$d6,$d7,$d8,$d9,$da,$BB,$CC,$DD,$EE,$FF
music_table_end:
.assert >music_table_begin = >music_table_end, error, "music_table crosses page"