From 7d5b7ac059fb6dd28f7574730ae71c991d23a8f0 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 14 Dec 2018 00:05:20 -0500 Subject: [PATCH] xmas2018: initial music support though it's just playing random garbage for now --- xmas_2018/Makefile | 11 +- xmas_2018/play_music.s | 269 +++++++++++++++++++++++++++++++++++++++++ xmas_2018/wreath.s | 14 ++- xmas_2018/xmas2018.s | 5 +- 4 files changed, 290 insertions(+), 9 deletions(-) create mode 100644 xmas_2018/play_music.s diff --git a/xmas_2018/Makefile b/xmas_2018/Makefile index 3138489b..f7ffde52 100644 --- a/xmas_2018/Makefile +++ b/xmas_2018/Makefile @@ -7,7 +7,7 @@ PNG_TO_RLE = ../gr-utils/png2rle all: xmas2018.dsk -xmas2018.dsk: HELLO XMAS2018 wreath.img.lz4 ball.img.lz4 merry.img.lz4 +xmas2018.dsk: HELLO XMAS2018 wreath.img.lz4 ball.img.lz4 merry.img.lz4 MUSIC $(DOS33) -y xmas2018.dsk SAVE A HELLO $(DOS33) -y xmas2018.dsk BSAVE -a 0x1000 XMAS2018 $(DOS33) -y xmas2018.dsk BSAVE -a 0xa000 wreath.img.lz4 WREATH.LZ4 @@ -24,12 +24,19 @@ XMAS2018: xmas2018.o xmas2018.o: xmas2018.s \ zp.inc hardware.inc \ vapor_lock.s delay_a.s wait_keypress.s \ - mockingboard.s rts.s \ + play_music.s mockingboard.s rts.s \ wreath.s wreath.img.lz4 \ ball.s ball.img.lz4 \ merry.s merry.img.lz4 ca65 -o xmas2018.o xmas2018.s -l xmas2018.lst +#### + +MUSIC: music.o + ld65 -o MUSIC music.o -C ../linker_scripts/apple2_1000.inc + +music.o: music.s + ca65 -o music.o music.s -l music.lst #### diff --git a/xmas_2018/play_music.s b/xmas_2018/play_music.s new file mode 100644 index 00000000..f42574e3 --- /dev/null +++ b/xmas_2018/play_music.s @@ -0,0 +1,269 @@ +;MB_VALUE = $91 +;MB_FRAME = $94 +;MB_PATTERN = $95 + + +mah00 = $8000 +mah01 = $8100 +mah02 = $8200 +mah03 = $8300 +mah04 = $8400 +mah05 = $8500 +mah06 = $8600 +mah07 = $8700 +mal00 = $8800 +mal01 = $8900 +mal02 = $8A00 +mal03 = $8B00 +mal04 = $8C00 +mal05 = $8D00 +mal06 = $8E00 +mal07 = $8F00 +mbh00 = $9000 +mbh01 = $9100 +mbh02 = $9200 +mbh03 = $9300 +mbh04 = $9400 +mbh05 = $9500 +mbh06 = $9600 +mbh07 = $9700 +mbl00 = $9800 +mbl01 = $9900 +mbl02 = $9A00 +mbl03 = $9B00 +mbl04 = $9C00 +mbl05 = $9D00 +mbl06 = $9E00 +mbl07 = $9F00 +mch00 = $A000 +mch01 = $A100 +mch02 = $A200 +mch03 = $A300 +mch04 = $A400 +mch05 = $A500 +mch06 = $A600 +mch07 = $A700 +mcl00 = $A800 +mcl01 = $A900 +mcl02 = $AA00 +mcl03 = $AB00 +mcl04 = $AC00 +mcl05 = $AD00 +mcl06 = $AE00 +mcl07 = $AF00 +mnh00 = $B000 +mnh01 = $B100 +mnh02 = $B200 +mnh03 = $B300 +mnh04 = $B400 +mnh05 = $B500 +mnh06 = $B600 +mnh07 = $B700 +mnl00 = $B800 +mnl01 = $B900 +mnl02 = $BA00 +mnl03 = $BB00 +mnl04 = $BC00 +mnl05 = $BD00 +mnl06 = $BE00 +mnl07 = $BF00 + + + + ; takes + ; 7 load pattern + ; 76 smc + ; 3 loop init + ; 910 play music 80 + 82 + 88 + 80 + 82 + 88 + 80 + 82 + 88 + 80 + 80 + ; 21 end + ;========== + ; = 1017 +play_music: + + ; self-modify the code + lda MB_PATTERN ; 3 + and #$1f ; 2 + tay ; 2 + + lda mal_pattern,Y ; 4 + sta mb_smc1+2 ; 4 + lda mah_pattern,Y ; 4 + sta mb_smc2+2 ; 4 + sta mb_smc3+2 ; 4 + + lda mbl_pattern,Y ; 4 + sta mb_smc4+2 ; 4 + lda mbh_pattern,Y ; 4 + sta mb_smc5+2 ; 4 + sta mb_smc6+2 ; 4 + + ; mcl and mch patterns are the same + lda mcl_pattern,Y ; 4 + sta mb_smc7+2 ; 4 + lda mch_pattern,Y ; 4 + sta mb_smc8+2 ; 4 + sta mb_smc9+2 ; 4 + + lda mnl_pattern,Y ; 4 + sta mb_smc10+2 ; 4 + lda mnh_pattern,Y ; 4 + sta mb_smc11+2 ; 4 + ;======= + ; 76 + + + + + ; play the code + + ldy MB_FRAME ; 3 + ;======= + + ; mal +mb_smc1: + lda mal00,Y ; 4 + sta MB_VALUE ; 3 + ldx #0 ; 2 + jsr write_ay_both ; 6+65 + ;========= + ; 80 + + ; mah +mb_smc2: + lda mal00,Y ; 4 + and #$f ; 2 + sta MB_VALUE ; 3 + ldx #1 ; 2 + jsr write_ay_both ; 6+65 + ;======== + ; 82 + +mb_smc3: + lda mal00,Y ; 4 + lsr ; 2 + lsr ; 2 + lsr ; 2 + lsr ; 2 + sta MB_VALUE ; 3 + ldx #8 ; 2 + jsr write_ay_both ; 6+65 + ;======= + ; 88 + + ; mbl +mb_smc4: + lda mbl00,Y ; 4 + sta MB_VALUE ; 3 + ldx #2 ; 2 + jsr write_ay_both ; 6+65 + ;======= + ; 80 + ; mbh +mb_smc5: + lda mbh00,Y ; 4 + and #$f ; 2 + sta MB_VALUE ; 3 + ldx #3 ; 2 + jsr write_ay_both ; 6+65 + ;======= + ; 82 + +mb_smc6: + lda mbh00,Y ; 4 + lsr ; 2 + lsr ; 2 + lsr ; 2 + lsr ; 2 + sta MB_VALUE ; 3 + ldx #9 ; 2 + jsr write_ay_both ; 6+65 + ;====== + ; 88 + ; mcl +mb_smc7: + lda mal00,Y ; 4 + sta MB_VALUE ; 3 + ldx #4 ; 2 + jsr write_ay_both ; 6+65 + ;====== + ; 80 + + ; mch +mb_smc8: + lda mal00,Y ; 4 + and #$f ; 2 + sta MB_VALUE ; 3 + ldx #5 ; 2 + jsr write_ay_both ; 6+65 + ;======= + ; 82 + +mb_smc9: + lda mal00,Y ; 4 + lsr ; 2 + lsr ; 2 + lsr ; 2 + lsr ; 2 + sta MB_VALUE ; 3 + ldx #10 ; 2 + jsr write_ay_both ; 6+65 + ;======== + ; 88 + ; mnl +mb_smc10: + lda mal00,Y ; 4 + sta MB_VALUE ; 3 + ldx #6 ; 2 + jsr write_ay_both ; 6+65 + ;======= + ; 80 + ; mnh +mb_smc11: + lda mnh00,Y ; 4 + sta MB_VALUE ; 3 + ldx #7 ; 2 + jsr write_ay_both ; 6+65 + ;======= + ; 80 + + inc MB_FRAME ; 5 + + bne mb_no_change ; 3 + ; -1 + inc MB_PATTERN ; 5 + jmp mb_done_change ; 3 +mb_no_change: + lda $0 ; 3 + nop ; 2 + nop ; 2 +mb_done_change: + + ; restore language card + rts ; 6 + ;======= + ; 21 + +.align $100 +.include "mockingboard.s" + +; patterns 8 long +mal_pattern: +.byte >mal00,>mal01,>mal02,>mal03,>mal04,>mal05,>mal06,>mal07 +mah_pattern: +.byte >mah00,>mah01,>mah02,>mah03,>mah04,>mah05,>mah06,>mah07 +mbl_pattern: +.byte >mbl00,>mbl01,>mbl02,>mbl03,>mbl04,>mbl05,>mbl06,>mbl07 +mbh_pattern: +.byte >mbh00,>mbh01,>mbh02,>mbh03,>mbh04,>mbh05,>mbh06,>mbh07 +mcl_pattern: +.byte >mcl00,>mcl01,>mcl02,>mcl03,>mcl04,>mcl05,>mcl06,>mcl07 +mch_pattern: +.byte >mch00,>mch01,>mch02,>mch03,>mch04,>mch05,>mch06,>mch07 +mnl_pattern: +.byte >mnl00,>mnl01,>mnl02,>mnl03,>mnl04,>mnl05,>mnl06,>mnl07 +mnh_pattern: +.byte >mnh00,>mnh01,>mnh02,>mnh03,>mnh04,>mnh05,>mnh06,>mnh07 + + + + diff --git a/xmas_2018/wreath.s b/xmas_2018/wreath.s index 80357b26..32b36cdf 100644 --- a/xmas_2018/wreath.s +++ b/xmas_2018/wreath.s @@ -135,18 +135,20 @@ wrloopF:dex ; 2 ;====================================================== ; do_nothing should be 4550 + ; play music 1023 ; -10 keypress - ; =========== - ; 4540 + ; =======-=== + ; 3517 -; jsr play_music ; 6+1032 + jsr play_music ; 6+1017 - ; Try X=9 Y=89 cycles=4540 + ; Try X=116 Y=6 cycles=3517 - ldy #89 ; 2 -wrloop1:ldx #9 ; 2 + + ldy #6 ; 2 +wrloop1:ldx #116 ; 2 wrloop2:dex ; 2 bne wrloop2 ; 2nt/3 dey ; 2 diff --git a/xmas_2018/xmas2018.s b/xmas_2018/xmas2018.s index b944cb57..dd105cdb 100644 --- a/xmas_2018/xmas2018.s +++ b/xmas_2018/xmas2018.s @@ -116,7 +116,6 @@ game_over_man: .include "vapor_lock.s" .include "delay_a.s" .include "wait_keypress.s" - .include "mockingboard.s" ; .include "random16.s" ; .include "hgr.s" ; .include "move_letters.s" @@ -124,6 +123,8 @@ game_over_man: ; .include "text_print.s" ; .include "screen_split.s" + .include "play_music.s" + ;============================ ; Include Sprites ;============================ @@ -131,6 +132,8 @@ game_over_man: ; .include "tfv_sprites.inc" ; .include "mode7_sprites.inc" + + ;================================= ; Include Text for Sliding Letters ; *DONT CROSS PAGES*