From a38436af740d0c47a4b67e0bc14d361959ed99f1 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 6 Mar 2022 00:15:31 -0500 Subject: [PATCH] lemm: full song plays awkward pauses though, takes more than 50Hz/20ms to decompress --- games/lemm/interrupt_handler.s | 93 +++++++++++++++------------- games/lemm/lemm_test.s | 77 +++++++++++++---------- games/lemm/zp.inc | 108 +-------------------------------- 3 files changed, 97 insertions(+), 181 deletions(-) diff --git a/games/lemm/interrupt_handler.s b/games/lemm/interrupt_handler.s index c42a0eee..5963c18d 100644 --- a/games/lemm/interrupt_handler.s +++ b/games/lemm/interrupt_handler.s @@ -50,7 +50,13 @@ ym_play_music: frame_loop: ldy #0 lda (CURRENT_FRAME_L),Y - jsr update_register + cmp #$ff + bne all_good + cpx #1 ; see if A coarse is $FF + beq go_next_chunk ; if so, end of song, loop + +all_good: + jsr update_ay_register clc lda CURRENT_FRAME_H @@ -70,20 +76,59 @@ frame_loop: cmp #$D4 bne not_oflo - ; FIXME: handle out of data properly - lda #$D0 - sta BASE_FRAME_H +go_next_chunk: + inc CURRENT_CHUNK + jsr load_song_chunk + not_oflo: + jmp exit_interrupt + + ;================================= + ; Finally done with this interrupt + ;================================= + +quiet_exit: + stx DONE_PLAYING + jsr clear_ay_both + + ; mute the sound + + ldx #7 + lda #$ff + jsr update_ay_register - jmp done_pt3_update_register +exit_interrupt: + + pla + tay ; restore Y + pla + tax ; restore X + pla ; restore a ; 4 + + ; on II+/IIe (but not IIc) we need to do this? +interrupt_smc: + lda $45 ; restore A + plp + + rti ; return from interrupt ; 6 + + ;============ + ; typical + ; ???? cycles -update_register: + + ;========================= + ; update ay_register + ; reg in X + ; value in A + +update_ay_register: pt3_irq_smc2: stx MOCK_6522_ORA1 ; put address on PA1 ; 4 @@ -111,42 +156,6 @@ pt3_irq_smc7: rts -done_pt3_update_register: done_pt3_irq_handler: - jmp exit_interrupt - - ;================================= - ; Finally done with this interrupt - ;================================= - -quiet_exit: - stx DONE_PLAYING - jsr clear_ay_both - - ldx #$ff ; also mute the channel - stx AY_REGISTERS+7 ; just in case - - -exit_interrupt: - - pla - tay ; restore Y - pla - tax ; restore X - pla ; restore a ; 4 - - ; on II+/IIe (but not IIc) we need to do this? -interrupt_smc: - lda $45 ; restore A - plp - - rti ; return from interrupt ; 6 - - ;============ - ; typical - ; ???? cycles - - - diff --git a/games/lemm/lemm_test.s b/games/lemm/lemm_test.s index a9330fbe..0f9cfa10 100644 --- a/games/lemm/lemm_test.s +++ b/games/lemm/lemm_test.s @@ -163,34 +163,21 @@ skip_all_checks: ; switch in language card ; read/write RAM, $d000 bank 2 - lda $C083 - lda $C083 - -; lda $C081 ; enable ROM -; lda $C081 ; enable write + lda $C083 + lda $C083 ; actually load it - lda #lemm5_part1_lzsa - sta getsrc_smc+2 ; LZSA_SRC_HI + lda #0 + sta CURRENT_CHUNK + sta DONE_PLAYING - lda #$d0 + jsr load_song_chunk - jsr decompress_lzsa2_fast + lda #1 + sta LOOP - lda #0 - sta DONE_PLAYING - sta BASE_FRAME_L - - lda #$D0 - sta BASE_FRAME_H - - lda #1 - sta LOOP - - jsr mockingboard_patch ; patch to work in slots other than 4? + jsr mockingboard_patch ; patch to work in slots other than 4? ;======================= ; Set up 50Hz interrupt @@ -283,6 +270,34 @@ load_graphics_loop: + ;======================== + ; load song chunk + ; CURRENT_CHUNK is which one + +load_song_chunk: + ldx CURRENT_CHUNK + lda music_parts_l,X + sta getsrc_smc+1 ; LZSA_SRC_LO + lda music_parts_h,X + sta getsrc_smc+2 ; LZSA_SRC_HI + bne load_song_chunk_good + + ; wrapped + lda #$00 + sta CURRENT_CHUNK + beq load_song_chunk ; try again + +load_song_chunk_good: + lda #$d0 + sta BASE_FRAME_H + + jsr decompress_lzsa2_fast + + lda #0 + sta BASE_FRAME_L + + rts + ;========================== ; includes ;========================== @@ -319,19 +334,17 @@ config_string: .byte 0,23,"APPLE II?, 48K, MOCKINGBOARD: NO, SSI: N",0 ; MOCKINGBOARD: NONE - -; .include "pt3_lib_core.s" -; .include "pt3_lib_init.s" -; .include "interrupt_handler.s" -; .include "pt3_lib_mockingboard_detect.s" -; .include "pt3_lib_mockingboard_setup.s" - new_title: .include "graphics/graphics_test.inc" - - +music_parts_h: + .byte >lemm5_part1_lzsa,>lemm5_part2_lzsa,>lemm5_part3_lzsa,$00 +music_parts_l: + .byte