From 26bc0e7bc4f3e89141857aaa4739b3daf2452103 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 19 Mar 2022 21:48:03 -0400 Subject: [PATCH] lemm: some fixes to music should handle the song-dong-early case now also bump down to loading at $9000 loading right up against $BF00/$C000 was having bit flips in qboot? still need to investigate that --- games/lemm/Makefile | 11 ++++---- games/lemm/interrupt_handler.s | 5 ++-- games/lemm/lemm.s | 36 ++---------------------- games/lemm/level1.s | 12 ++++---- games/lemm/level2.s | 12 ++++---- games/lemm/level4.s | 38 +++++++++++++------------- games/lemm/level5.s | 30 ++++++++++---------- games/lemm/load_music.s | 50 ++++++++++++++++++++++++++++++++++ games/lemm/qload.s | 8 +++--- 9 files changed, 109 insertions(+), 93 deletions(-) create mode 100644 games/lemm/load_music.s diff --git a/games/lemm/Makefile b/games/lemm/Makefile index f7bddc85..fc281323 100644 --- a/games/lemm/Makefile +++ b/games/lemm/Makefile @@ -89,7 +89,7 @@ lemm.o: lemm.s zp.inc hardware.inc qload.inc \ hgr_hlin.s hgr_vlin.s update_menu.s \ interrupt_handler.s keyboard.s draw_pointer.s \ pointer_sprites.inc particle_hgr.s \ - title.s audio.s letsgo.s + title.s audio.s letsgo.s load_music.s ca65 -o lemm.o lemm.s -l lemm.lst @@ -131,11 +131,12 @@ lemm.inc: generate_common LEMM ./generate_common -a 0x6000 -s exit_x2_smc lemm.lst >> lemm.inc ./generate_common -a 0x6000 -s exit_y1_smc lemm.lst >> lemm.inc ./generate_common -a 0x6000 -s exit_y2_smc lemm.lst >> lemm.inc + ./generate_common -a 0x6000 -s load_music lemm.lst >> lemm.inc #### LEVEL1: level1.o - ld65 -o LEVEL1 level1.o -C ../../linker_scripts/apple2_a000.inc + ld65 -o LEVEL1 level1.o -C ../../linker_scripts/apple2_9000.inc level1.o: level1.s zp.inc hardware.inc qload.inc lemm.inc \ graphics/graphics_level1.inc @@ -144,7 +145,7 @@ level1.o: level1.s zp.inc hardware.inc qload.inc lemm.inc \ #### LEVEL2: level2.o - ld65 -o LEVEL2 level2.o -C ../../linker_scripts/apple2_a000.inc + ld65 -o LEVEL2 level2.o -C ../../linker_scripts/apple2_9000.inc level2.o: level2.s zp.inc hardware.inc qload.inc lemm.inc \ graphics/graphics_level2.inc @@ -153,7 +154,7 @@ level2.o: level2.s zp.inc hardware.inc qload.inc lemm.inc \ #### LEVEL4: level4.o - ld65 -o LEVEL4 level4.o -C ../../linker_scripts/apple2_a000.inc + ld65 -o LEVEL4 level4.o -C ../../linker_scripts/apple2_9000.inc level4.o: level4.s zp.inc hardware.inc qload.inc lemm.inc \ graphics/graphics_level4.inc @@ -164,7 +165,7 @@ level4.o: level4.s zp.inc hardware.inc qload.inc lemm.inc \ #### LEVEL5: level5.o - ld65 -o LEVEL5 level5.o -C ../../linker_scripts/apple2_a000.inc + ld65 -o LEVEL5 level5.o -C ../../linker_scripts/apple2_9000.inc level5.o: level5.s zp.inc hardware.inc qload.inc lemm.inc \ graphics/graphics_level5.inc diff --git a/games/lemm/interrupt_handler.s b/games/lemm/interrupt_handler.s index bdf6eb00..7407c12f 100644 --- a/games/lemm/interrupt_handler.s +++ b/games/lemm/interrupt_handler.s @@ -95,11 +95,12 @@ go_next_chunk: lda CHUNK_NEXT_PLAY ; toggle $D0/$E8 eor #$38 sta CHUNK_NEXT_PLAY - sta BASE_FRAME_H + lda #0 + sta BASE_FRAME_L ; in case song ended early - inc CURRENT_CHUNK + inc CURRENT_CHUNK ; point to next chunk ; inc LOAD_NEXT_CHUNK ; defer this until after interrupt ; jsr load_song_chunk diff --git a/games/lemm/lemm.s b/games/lemm/lemm.s index 3b5d39f2..bd2eae10 100644 --- a/games/lemm/lemm.s +++ b/games/lemm/lemm.s @@ -277,39 +277,6 @@ level_lost: - ;======================== - ; load song chunk - ; CURRENT_CHUNK is which one, 0..N - ; CHUNK_DEST is $D0 or $E8 - -load_song_chunk: - ldx CURRENT_CHUNK -chunk_l_smc: - lda $DDDD,X - sta getsrc_smc+1 ; LZSA_SRC_LO -chunk_h_smc: - lda $DDDD,X - sta getsrc_smc+2 ; LZSA_SRC_HI - bne load_song_chunk_good - - ; $00 in chunk table means we are off the end, so wrap - lda #$00 - sta CURRENT_CHUNK ; reset chunk to 0 - beq load_song_chunk ; try again - -load_song_chunk_good: - lda CHUNK_NEXT_LOAD ; decompress to $D0 or $E8 -; eor #$38 ; want the opposite of CHUNK_DEST - - jsr decompress_lzsa2_fast - - - lda CHUNK_NEXT_LOAD ; point to next location - eor #$38 - sta CHUNK_NEXT_LOAD - - rts - ;========================== ; includes ;========================== @@ -352,6 +319,7 @@ load_song_chunk_good: .include "letsgo.s" .include "particle_hgr.s" + .include "load_music.s" ; moved to qload.s @@ -382,4 +350,4 @@ letsgo: .incbin "sounds/letsgo.btc.lz4" -start_level = $a001 +start_level = $9001 diff --git a/games/lemm/level1.s b/games/lemm/level1.s index 242e7b81..35d518c7 100644 --- a/games/lemm/level1.s +++ b/games/lemm/level1.s @@ -213,16 +213,14 @@ do_level1: ;=================== l1_main_loop: - lda LOAD_NEXT_CHUNK ; see if we need to load next chunk - beq l1_no_load_chunk ; outside IRQ to avoid glitch in music + ;========================= + ; load next chunk of music + ; if necessary + ;========================= - jsr load_song_chunk - - lda #0 ; reset - sta LOAD_NEXT_CHUNK + jsr load_music -l1_no_load_chunk: lda DOOR_OPEN diff --git a/games/lemm/level2.s b/games/lemm/level2.s index 9c971195..abb1f05c 100644 --- a/games/lemm/level2.s +++ b/games/lemm/level2.s @@ -204,16 +204,14 @@ do_level2: ;=================== l2_main_loop: - lda LOAD_NEXT_CHUNK ; see if we need to load next chunk - beq l2_no_load_chunk ; outside IRQ to avoid glitch in music + ;========================= + ; load next chunk of music + ; if necessary + ;========================= - jsr load_song_chunk - - lda #0 ; reset - sta LOAD_NEXT_CHUNK + jsr load_music -l2_no_load_chunk: lda DOOR_OPEN diff --git a/games/lemm/level4.s b/games/lemm/level4.s index e253bf04..d31a25d8 100644 --- a/games/lemm/level4.s +++ b/games/lemm/level4.s @@ -202,40 +202,40 @@ do_level4: ; Main Loop ;=================== ;=================== -l2_main_loop: +l4_main_loop: - lda LOAD_NEXT_CHUNK ; see if we need to load next chunk - beq l2_no_load_chunk ; outside IRQ to avoid glitch in music + ;========================= + ; load next chunk of music + ; if necessary + ;========================= - jsr load_song_chunk - - lda #0 ; reset - sta LOAD_NEXT_CHUNK + jsr load_music -l2_no_load_chunk: + +l4_no_load_chunk: lda DOOR_OPEN - bne l2_door_is_open + bne l4_door_is_open jsr draw_door -l2_door_is_open: +l4_door_is_open: ;====================== ; release lemmings ;====================== lda LEMMINGS_TO_RELEASE - beq l2_done_release_lemmings + beq l4_done_release_lemmings lda DOOR_OPEN - beq l2_done_release_lemmings + beq l4_done_release_lemmings lda FRAMEL and #$f - bne l2_done_release_lemmings + bne l4_done_release_lemmings inc LEMMINGS_OUT jsr update_lemmings_out @@ -245,20 +245,20 @@ l2_door_is_open: dec LEMMINGS_TO_RELEASE -l2_done_release_lemmings: +l4_done_release_lemmings: jsr draw_flames lda TIMER_COUNT cmp #$50 - bcc l2_timer_not_yet + bcc l4_timer_not_yet jsr update_time lda #$0 sta TIMER_COUNT -l2_timer_not_yet: +l4_timer_not_yet: ; main drawing loop @@ -281,12 +281,12 @@ l2_timer_not_yet: inc FRAMEL lda LEVEL_OVER - bne l2_level_over + bne l4_level_over - jmp l2_main_loop + jmp l4_main_loop -l2_level_over: +l4_level_over: ; bit SET_TEXT diff --git a/games/lemm/level5.s b/games/lemm/level5.s index 195b0576..c19a4950 100644 --- a/games/lemm/level5.s +++ b/games/lemm/level5.s @@ -175,16 +175,14 @@ do_level5: ;=================== l5_main_loop: - lda LOAD_NEXT_CHUNK ; see if we need to load next chunk - beq l5_no_load_chunk ; outside IRQ to avoid glitch in music + ;========================= + ; load next chunk of music + ; if necessary + ;========================= - jsr load_song_chunk - - lda #0 ; reset - sta LOAD_NEXT_CHUNK + jsr load_music -l5_no_load_chunk: lda DOOR_OPEN @@ -274,13 +272,15 @@ l5_level_over: music6_parts_h: .byte >lemm6_part1_lzsa,>lemm6_part2_lzsa,>lemm6_part3_lzsa .byte >lemm6_part4_lzsa,>lemm6_part5_lzsa,>lemm6_part6_lzsa - .byte >lemm6_part7_lzsa + .byte >lemm6_part7_lzsa,>lemm6_part8_lzsa,>lemm6_part9_lzsa + .byte >lemm6_part10_lzsa .byte $00 music6_parts_l: .byte