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
This commit is contained in:
Vince Weaver 2022-03-19 21:48:03 -04:00
parent ea4f705e6d
commit 26bc0e7bc4
9 changed files with 109 additions and 93 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <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
lemm6_part1_lzsa:
.incbin "music/lemm6.part1.lzsa"
@ -296,11 +296,11 @@ lemm6_part6_lzsa:
.incbin "music/lemm6.part6.lzsa"
lemm6_part7_lzsa:
.incbin "music/lemm6.part7.lzsa"
;lemm6_part8_lzsa:
;.incbin "music/lemm6.part8.lzsa"
;lemm6_part9_lzsa:
;.incbin "music/lemm6.part9.lzsa"
;lemm6_part10_lzsa:
;.incbin "music/lemm6.part10.lzsa"
lemm6_part8_lzsa:
.incbin "music/lemm6.part8.lzsa"
lemm6_part9_lzsa:
.incbin "music/lemm6.part9.lzsa"
lemm6_part10_lzsa:
.incbin "music/lemm6.part10.lzsa"

50
games/lemm/load_music.s Normal file
View File

@ -0,0 +1,50 @@
load_music:
lda LOAD_NEXT_CHUNK ; see if we need to load next chunk
beq no_load_chunk ; outside IRQ to avoid glitch in music
jsr load_song_chunk
lda #0 ; reset
sta LOAD_NEXT_CHUNK
no_load_chunk:
rts
;========================
; 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
jsr decompress_lzsa2_fast
lda CHUNK_NEXT_LOAD ; point to next location
eor #$38
sta CHUNK_NEXT_LOAD
rts

View File

@ -165,8 +165,8 @@ which_disk_array:
.byte 1,1,1,1 ;
load_address_array:
.byte $60,$A0,$A0,$A0 ; LEMM, LEVEL1, LEVEL2, LEVEL3
.byte $A0,$A0,$A0,$A0 ; LEVEL4, LEVEL5
.byte $60,$90,$90,$90 ; LEMM, LEVEL1, LEVEL2, LEVEL3
.byte $90,$90,$A0,$A0 ; LEVEL4, LEVEL5
.byte $A0,$A0,$A0,$A0 ;
track_array:
@ -180,8 +180,8 @@ sector_array:
.byte 0, 0, 0, 0 ;
length_array:
.byte 64, 32, 32, 32 ; LEMM, LEVEL1, LEVEL2, LEVEL3
.byte 32, 32, 32, 32 ; LEVEL4, LEVEL5
.byte 48, 46, 46, 46 ; LEMM, LEVEL1, LEVEL2, LEVEL3
.byte 46, 46, 32, 32 ; LEVEL4, LEVEL5
.byte 32, 32, 32, 32 ;