From 8b090686c3b534693a9fb49676104a7091e26c93 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 21 Jun 2024 17:05:56 -0400 Subject: [PATCH] riven: hook up orb sound --- games/riven_hgr/Makefile | 4 +- games/riven_hgr/disk40_files/Makefile | 20 +- games/riven_hgr/disk40_files/disk40.s | 8 +- .../riven_hgr/disk40_files/disk40_defines.inc | 9 +- .../ball2_n.png => graphics_orb1/orb2_n.png} | Bin .../ball_n.png => graphics_orb1/orb_n.png} | Bin games/riven_hgr/disk40_files/level_orb.s | 186 ++++++++++++++++++ .../riven_hgr/disk40_files/leveldata_orb.inc | 32 +++ .../disk40_files/leveldata_outside.inc | 2 +- games/riven_hgr/lc_detect.s | 40 ++++ games/riven_hgr/title.s | 42 ++-- games/riven_hgr/zp.inc | 3 +- 12 files changed, 310 insertions(+), 36 deletions(-) rename games/riven_hgr/disk40_files/{graphics_outside/ball2_n.png => graphics_orb1/orb2_n.png} (100%) rename games/riven_hgr/disk40_files/{graphics_outside/ball_n.png => graphics_orb1/orb_n.png} (100%) create mode 100644 games/riven_hgr/disk40_files/level_orb.s create mode 100644 games/riven_hgr/disk40_files/leveldata_orb.inc create mode 100644 games/riven_hgr/lc_detect.s diff --git a/games/riven_hgr/Makefile b/games/riven_hgr/Makefile index 330a9cc3..ee3bd5f2 100644 --- a/games/riven_hgr/Makefile +++ b/games/riven_hgr/Makefile @@ -51,7 +51,8 @@ riven_disk39.dsk: QBOOT QLOAD TITLE_39 \ riven_disk40.dsk: QBOOT QLOAD TITLE_40 \ disk40_files/DISK40 \ disk40_files/LEVEL_MAGLEV \ - disk40_files/LEVEL_OUTSIDE + disk40_files/LEVEL_OUTSIDE \ + disk40_files/LEVEL_ORB cp $(EMPTY_DISK)/empty.dsk riven_disk40.dsk $(DOS33_RAW) riven_disk40.dsk 0 0 QBOOT 0 1 $(DOS33_RAW) riven_disk40.dsk 0 2 QBOOT 1 1 @@ -61,6 +62,7 @@ riven_disk40.dsk: QBOOT QLOAD TITLE_40 \ $(DOS33_RAW) riven_disk40.dsk 1 9 TITLE_40 0 0 $(DOS33_RAW) riven_disk40.dsk 2 0 disk40_files/LEVEL_MAGLEV 0 0 $(DOS33_RAW) riven_disk40.dsk 9 0 disk40_files/LEVEL_OUTSIDE 0 0 + $(DOS33_RAW) riven_disk40.dsk 17 0 disk40_files/LEVEL_ORB 0 0 riven_disk43.dsk: QBOOT QLOAD TITLE_43 \ disk43_files/DISK43 \ diff --git a/games/riven_hgr/disk40_files/Makefile b/games/riven_hgr/disk40_files/Makefile index 0038a7d2..adb9b791 100644 --- a/games/riven_hgr/disk40_files/Makefile +++ b/games/riven_hgr/disk40_files/Makefile @@ -3,7 +3,7 @@ include ../../../Makefile.inc LINKER_SCRIPTS = ../../../linker_scripts/ -all: DISK40 LEVEL_MAGLEV LEVEL_OUTSIDE +all: DISK40 LEVEL_MAGLEV LEVEL_OUTSIDE LEVEL_ORB ### @@ -38,6 +38,19 @@ level_outside.o: level_outside.s \ graphics_outside/outside_graphics.inc ca65 -o level_outside.o level_outside.s -l level_outside.lst +#### + +LEVEL_ORB: level_orb.o + ld65 -o LEVEL_ORB level_orb.o -C $(LINKER_SCRIPTS)/apple2_4000.inc + +level_orb.o: level_orb.s \ + ../zp.inc ../hardware.inc ../qload.inc \ + ../common_defines.inc disk40_defines.inc \ + leveldata_orb.inc \ + graphics_orb1/orb1_graphics.inc + ca65 -o level_orb.o level_orb.s -l level_orb.lst + + #### @@ -46,11 +59,14 @@ graphics_maglev/maglev_graphics.inc: graphics_outside/outside_graphics.inc: cd graphics_outside && make + +graphics_orb1/orb1_graphics.inc: + cd graphics_orb1 && make #### clean: rm -f *~ *.o *.lst \ - LEVEL_MAGLEV LEVEL_OUTSIDE + LEVEL_MAGLEV LEVEL_OUTSIDE LEVEL_ORB #### diff --git a/games/riven_hgr/disk40_files/disk40.s b/games/riven_hgr/disk40_files/disk40.s index aef51ef6..6ce41907 100644 --- a/games/riven_hgr/disk40_files/disk40.s +++ b/games/riven_hgr/disk40_files/disk40.s @@ -4,19 +4,19 @@ which_disk: .byte $40 ; BCD load_address_array: - .byte $40,$40,$40,$00 ; TITLE, MAGLEV, OUTSIDE + .byte $40,$40,$40,$40 ; TITLE, MAGLEV, OUTSIDE, ORB .byte $00,$00,$00,$00 track_array: - .byte 1, 2, 9,17 ; TITLE, MAGLEV, OUTSIDE + .byte 1, 2, 9,17 ; TITLE, MAGLEV, OUTSIDE, ORB .byte 0, 0, 0, 0 sector_array: - .byte 9, 0, 0, 0 ; TITLE, MAGLEV, OUTSIDE + .byte 9, 0, 0, 0 ; TITLE, MAGLEV, OUTSIDE, ORB .byte 0,0,0,0 length_array: - .byte 8, 96,112, 64 ; TITLE, MAGLEV, OUTSIDE + .byte 8, 96,112, 64 ; TITLE, MAGLEV, OUTSIDE, ORB .byte 0,0,0,0 disk_exit_disk: ; note: BCD (yes I'm lazy) diff --git a/games/riven_hgr/disk40_files/disk40_defines.inc b/games/riven_hgr/disk40_files/disk40_defines.inc index 75e11232..0119e292 100644 --- a/games/riven_hgr/disk40_files/disk40_defines.inc +++ b/games/riven_hgr/disk40_files/disk40_defines.inc @@ -1,8 +1,9 @@ LOAD_TITLE = 0 LOAD_MAGLEV = 1 LOAD_OUTSIDE = 2 -LOAD_MOVIE1 = 3 -LOAD_MOVIE2 = 4 +LOAD_ORB = 3 +LOAD_MOVIE1 = 4 +LOAD_MOVIE2 = 5 ;================================ ; Level definitions @@ -20,3 +21,7 @@ RIVEN_OUTSIDE_PATH = 0 RIVEN_OUTSIDE_PLAZA = 1 RIVEN_CAVE_ENTRANCE = 2 +; Orb + +RIVEN_ORB1 = 0 + diff --git a/games/riven_hgr/disk40_files/graphics_outside/ball2_n.png b/games/riven_hgr/disk40_files/graphics_orb1/orb2_n.png similarity index 100% rename from games/riven_hgr/disk40_files/graphics_outside/ball2_n.png rename to games/riven_hgr/disk40_files/graphics_orb1/orb2_n.png diff --git a/games/riven_hgr/disk40_files/graphics_outside/ball_n.png b/games/riven_hgr/disk40_files/graphics_orb1/orb_n.png similarity index 100% rename from games/riven_hgr/disk40_files/graphics_outside/ball_n.png rename to games/riven_hgr/disk40_files/graphics_orb1/orb_n.png diff --git a/games/riven_hgr/disk40_files/level_orb.s b/games/riven_hgr/disk40_files/level_orb.s new file mode 100644 index 00000000..cb394824 --- /dev/null +++ b/games/riven_hgr/disk40_files/level_orb.s @@ -0,0 +1,186 @@ +; Riven -- Jungle Island -- Looking at the first orb + +; by deater (Vince Weaver) + +; Zero Page + .include "../zp.inc" + .include "../hardware.inc" + .include "../common_defines.inc" + .include "../qload.inc" + .include "disk40_defines.inc" + +riven_jungle_orb: + + ;=================== + ; init screen + ;=================== + +; jsr TEXT +; jsr HOME + bit KEYRESET + + bit SET_GR + bit PAGE1 + bit HIRES + bit FULLGR + + ;=============================== + ; load sound into language card + ;=============================== + + lda SOUND_STATUS + and #SOUND_IN_LC + beq do_not_load_audio + + ; load sounds into LC + + ; read ram, write ram, use $d000 bank1 + bit $C08B + bit $C08B + + lda #orb_audio + sta ZX0_src+1 + + lda #$D0 ; decompress to $D000 + + jsr full_decomp + + ; read rom, nowrite, use $d000 bank1 + bit $C08A + + +do_not_load_audio: + + ;======================== + ; set up location + ;======================== + + lda #locations + sta LOCATIONS_H + + lda #0 + sta DRAW_PAGE + sta LEVEL_OVER + + lda #0 + sta JOYSTICK_ENABLED + sta UPDATE_POINTER + + lda #1 + sta CURSOR_VISIBLE + + lda #20 + sta CURSOR_X + sta CURSOR_Y + + + + + ;=================================== + ; init + ;=================================== + + jsr change_location + + jsr save_bg_14x14 ; save old bg + +game_loop: + + ;=================================== + ; draw pointer + ;=================================== + + jsr draw_pointer + + ;=================================== + ; handle keypress/joystick + ;=================================== + + jsr handle_keypress + + ;=================================== + ; increment frame count + ;=================================== + + inc FRAMEL + bne frame_no_oflo + + inc FRAMEH +frame_no_oflo: + + ;==================================== + ; check level over + ;==================================== + + lda LEVEL_OVER + bne really_exit + + jmp game_loop + +really_exit: + + rts + + + ;===================================== + ; handle orb being clicked + ;===================================== + +orb_clicked: + + ; only play sound if language card + + lda SOUND_STATUS + and #SOUND_IN_LC + bne do_play_audio + + ; wait a bit instead + + ldx #20 + jsr wait_50xms + +do_play_audio: + ; switch in language card + ; read/write RAM $d000 bank 1 + + bit $C08B + bit $C08B + + ; call the btc player + + lda #$00 + sta BTC_L + + lda #$D0 + sta BTC_H + + ldx #45 ; length + + jsr play_audio + + ; read ROM/no-write + + bit $c08A ; restore language card + +done_play_audio: + + rts + + + ;========================== + ; includes + ;========================== + + +.include "graphics_orb1/orb1_graphics.inc" + +.include "leveldata_orb.inc" + +.include "../audio.s" + +orb_audio: + .incbin "audio/ball1.btc.zx02" diff --git a/games/riven_hgr/disk40_files/leveldata_orb.inc b/games/riven_hgr/disk40_files/leveldata_orb.inc new file mode 100644 index 00000000..c5a5ea52 --- /dev/null +++ b/games/riven_hgr/disk40_files/leveldata_orb.inc @@ -0,0 +1,32 @@ +;=============================================== +; level data for 1st Orb +;=============================================== + +locations: + .word location0 + + +; technically in the actual game you can look south/west to slightly +; different backgrounds, but for various reasons we're going to just +; back out when given the chance + +; RIVEN_ORB1 -- first orb +location0: + .byte LOAD_OUTSIDE<<4|RIVEN_OUTSIDE_PLAZA ; north exit + .byte $FF ; south exit + .byte $FF ; east exit + .byte $FF ; west exit + .byte DIRECTION_N ; north exit_dir + .byte $ff ; south exit_dir + .byte $ff ; east exit_dir + .byte $ff ; west exit_dir + .word orb_n_zx02 ; north bg + .word $0000 ; south bg + .word $0000 ; east bg + .word $0000 ; west bg + .byte BG_NORTH + .byte DIRECTION_N ; special exit + .byte 15,23 ; special x + .byte 64,118 ; special y + .word orb_clicked-1 ; special function + diff --git a/games/riven_hgr/disk40_files/leveldata_outside.inc b/games/riven_hgr/disk40_files/leveldata_outside.inc index d68c59dc..3b5f7d32 100644 --- a/games/riven_hgr/disk40_files/leveldata_outside.inc +++ b/games/riven_hgr/disk40_files/leveldata_outside.inc @@ -25,7 +25,7 @@ location0: ; RIVEN_OUTSIDE_PLAZA -- plaza near maglev location1: - .byte $ff ; TODO: ball ; north exit + .byte LOAD_ORB<<4|RIVEN_ORB1 ; north exit .byte RIVEN_CAVE_ENTRANCE ; south exit .byte RIVEN_OUTSIDE_PATH ; east exit .byte $FF ; west exit diff --git a/games/riven_hgr/lc_detect.s b/games/riven_hgr/lc_detect.s new file mode 100644 index 00000000..3123a6ae --- /dev/null +++ b/games/riven_hgr/lc_detect.s @@ -0,0 +1,40 @@ +; Code from TotalReplay by 4am and qkumba + +;------------------------------------------------------------------------------ +; Has64K +; Checks whether computer has functioning language card (64K) +; +; in: none +; out: C clear if 64K detected +; C set if 64K not detected +; all other flags and registers clobbered +; ROM in memory (not LC RAM bank) +;------------------------------------------------------------------------------ + +detect_language_card: + + ; enable language card + ; READ_RAM1_WRITE_RAM1 + + bit $C08B + bit $C08B + + lda #$AA ; test #1 for $D0 page + sta $D000 + eor $D000 + bne no_lc + lsr $D000 ; test #2 for $D0 page + lda #$55 + eor $D000 + bne no_lc + clc + bcc done_detect + +no_lc: + sec + +done_detect: + ; READ_ROM_NO_WRITE + bit $C08A + + rts diff --git a/games/riven_hgr/title.s b/games/riven_hgr/title.s index b4dd8ed6..ca8ca36a 100644 --- a/games/riven_hgr/title.s +++ b/games/riven_hgr/title.s @@ -27,18 +27,7 @@ riven_title: - ;============================ - ; check to see if new game - ; if so print title screen - ; otherwise we get here after flipping disks - ; so skip all the init -; lda NEW_GAME -; bne new_game - -; jmp disk_change - -new_game: ;=========================== ; print the title message that used to be ; in hello.bas @@ -193,16 +182,16 @@ reload_everything: ; and load sound into it if possible ;=================================== -; lda #0 -; sta SOUND_STATUS ; clear out, sound enabled + lda #0 + sta SOUND_STATUS ; clear out, sound enabled -; jsr detect_language_card -; bcs no_language_card + jsr detect_language_card + bcs no_language_card ; update sound status -; lda SOUND_STATUS -; ora #SOUND_IN_LC -; sta SOUND_STATUS + lda SOUND_STATUS + ora #SOUND_IN_LC + sta SOUND_STATUS ; load sounds into LC @@ -282,13 +271,16 @@ done_setup_sound: ; clear out zero page values to 0 ; clear everything from $80 .. $A0? - lda #0 - ldx #$20 -clear_loop: - sta $80,X - dex - bpl clear_loop +; lda #0 +; ldx #$20 +;clear_loop: +; sta $80,X +; dex +; bpl clear_loop + lda #0 + sta LEVEL_OVER + ; init hi-res graphics @@ -377,7 +369,7 @@ clear_loop: ; .include "gr_offsets.s" -; .include "lc_detect.s" + .include "lc_detect.s" model_string: .byte "DETECTED APPLE II",0,0,0 diff --git a/games/riven_hgr/zp.inc b/games/riven_hgr/zp.inc index 6cf75fb2..1ede9ade 100644 --- a/games/riven_hgr/zp.inc +++ b/games/riven_hgr/zp.inc @@ -19,7 +19,8 @@ DRIVE2_DISK = $0C DRIVE1_TRACK = $0D DRIVE2_TRACK = $0E NEW_DISK = $0F - +BTC_L = $10 +BTC_H = $11 ;; Zero page monitor routines addresses