From 926b91fadc6bb3259f4ddef9a14781928da2c7ac Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 20 May 2024 18:04:33 -0400 Subject: [PATCH] riven_hgr: more work on movie --- games/riven_hgr/graphics_outside/Makefile | 3 +- games/riven_hgr/movie1.s | 245 ++++++++++++++++++---- games/riven_hgr/movie1/convert.sh | 5 + games/riven_hgr/movie1/overlays/Makefile | 10 +- games/riven_hgr/wait.s | 35 ++++ games/riven_hgr/zp.inc | 32 +-- 6 files changed, 257 insertions(+), 73 deletions(-) create mode 100755 games/riven_hgr/movie1/convert.sh create mode 100644 games/riven_hgr/wait.s diff --git a/games/riven_hgr/graphics_outside/Makefile b/games/riven_hgr/graphics_outside/Makefile index 8d6e5a67..6312ae24 100644 --- a/games/riven_hgr/graphics_outside/Makefile +++ b/games/riven_hgr/graphics_outside/Makefile @@ -9,7 +9,8 @@ all: outside_graphics.inc outside_graphics.inc: \ maglev1_n.hgr.zx02 maglev1_s.hgr.zx02 maglev1_e.hgr.zx02 maglev1_w.hgr.zx02 \ - magpath_n.hgr.zx02 magpath_s.hgr.zx02 + magpath_n.hgr.zx02 magpath_s.hgr.zx02 \ + overlook_n.hgr.zx02 echo "maglev1_n_zx02: .incbin \"maglev1_n.hgr.zx02\"" > outside_graphics.inc echo "maglev1_s_zx02: .incbin \"maglev1_s.hgr.zx02\"" >> outside_graphics.inc echo "maglev1_e_zx02: .incbin \"maglev1_e.hgr.zx02\"" >> outside_graphics.inc diff --git a/games/riven_hgr/movie1.s b/games/riven_hgr/movie1.s index 733478b8..9aabbcb4 100644 --- a/games/riven_hgr/movie1.s +++ b/games/riven_hgr/movie1.s @@ -6,6 +6,35 @@ .include "hardware.inc" +overlays = $2000 + + ;================================= + ; so, movie. each frame is 1/5 second (200ms) + ; 25..28 displays initial for 4 frames + ; 29..35 displays handle moving (8 frames) + ; 36..52 sits there + ; 53..87 rotates + ; 88..97 sits there + ; 98 control returns to user + ; space? + ; 188*8=overlays (1.5k) + ; 35 rotations * 188 = (7k) not so bad? + ;=================== + ; notes for movie2 + ; 103..109 = overlay animation + ; 110..112 = sit there + ; 113..270 = fun animation 157! = 30k??? + ; 271..285 = handle rotate + ; 286..306 = sit there + + + ; timing, want whole thing to finish in 200ms or so + ; + ; decompressing: + ; ade2 = 44,514 cycles + ; do_overlay: + ; 9c78 = 40,056 cycles + movie1_start: @@ -19,10 +48,46 @@ movie1_start: bit PAGE1 lda #0 +; sta DRAW_PAGE + sta SCENE_COUNT + + lda #4 sta DRAW_PAGE bit KEYRESET + ;=============================== + ;=============================== + ; set up graphics + ;=============================== + ;=============================== + + ;============================= + ; load overlay mask to $c00 + ;============================= + + lda #overlay_mask_zx02 + sta ZX0_src+1 + + lda #$0c + + jsr full_decomp + + + ;=============================== + ;=============================== + ; move the handle + ;=============================== + ;=============================== + +.if 0 + ;=============================== + ; decompress initial background + ;=============================== + +before: lda #img025_bg_zx02 @@ -31,36 +96,42 @@ movie1_start: lda #$04 ; decompress page1 (dangerous? holes?) jsr full_decomp +after: +.endif + ;============================= + ; load overlays to $2000-$2FFF + ;============================= + lda #0 + sta WHICH_OVERLAY - lda #overlay + lda overlays_h,X sta ZX0_src+1 - lda #$0c + lda WHICH_OVERLAY + asl + asl + clc + adc #>overlays jsr full_decomp - jsr do_overlay - - - -.if 0 - lda #num_scenes - sta SCENE_COUNT - - lda #frame15 - sta INH -.endif - - -.if 0 + inc WHICH_OVERLAY + lda WHICH_OVERLAY + cmp #8 + bne load_overlay_loop + ; could save bytes going backwards? + lda #0 + sta WHICH_OVERLAY scene_loop: + + jsr draw_scene ;============================ @@ -78,34 +149,60 @@ was_page1: done_pageflip: sta DRAW_PAGE ; 3 - lda #12 - sta IRQ_COUNTDOWN - -wait_for_irq: - lda IRQ_COUNTDOWN - bne wait_for_irq lda KEYPRESS - bmi done_threed + bmi done_movie1 - dec SCENE_COUNT - bne scene_loop -.endif + inc WHICH_OVERLAY + lda WHICH_OVERLAY + cmp #8 + bne overlay_good + + lda #0 + sta WHICH_OVERLAY + +overlay_good: + + ldx #2 + jsr wait_50xms + + inc SCENE_COUNT +; bne scene_loop + jmp scene_loop done_movie1: bit KEYRESET - jmp done_movie1 + jmp movie1_start rts - ;=============================== + ; do overlay + ;=============================== + ; INL/H = overlay + ; MASKL/H = mask + ; OUTL/H = gr location do_overlay: + lda DRAW_PAGE + clc + adc #$4 + sta OUTH + + lda WHICH_OVERLAY + asl + asl + clc + adc #$20 + sta INH + lda #$c - sta overlayin_smc+2 - lda #$4 - sta overlayout_smc+2 + sta MASKH + + lda #0 + sta OUTL + sta INL + sta MASKL do_overlay_outer: @@ -113,27 +210,55 @@ do_overlay_outer: do_overlay_inner: overlayin_smc: - lda $c00,Y + lda (INL),Y + and (MASKL),Y + sta TEMP - cmp #$AA ; both pixels transparent - beq skip_write - -overlayout_smc: - sta $400,Y + lda (MASKL),Y + eor #$ff + and (OUTL),Y + ora TEMP + sta (OUTL),Y skip_write: dey bne do_overlay_inner - inc overlayin_smc+2 - inc overlayout_smc+2 - lda overlayin_smc+2 + + inc OUTH + inc INH + inc MASKH + lda MASKH cmp #$10 bne do_overlay_inner rts + ;=============================== + ;=============================== +draw_scene: + + + ;=============================== + ; decompress background + ;=============================== + +before: + lda #img025_bg_zx02 + sta ZX0_src+1 + + clc + lda DRAW_PAGE + adc #$4 + + jsr full_decomp +after: + + jmp do_overlay + ;=================================== ; .include "../wait_keypress.s" @@ -143,8 +268,38 @@ skip_write: .include "zx02_optim.s" + .include "wait.s" .include "movie1/movie1.inc" -overlay: - .incbin "movie1/overlays/maglev_overlay.gr.zx02" +overlays_l: + .byte overlay25,>overlay29,>overlay30 + .byte >overlay31,>overlay32,>overlay33 + .byte >overlay34,>overlay35 + +overlay_mask_zx02: + .incbin "movie1/overlays/maglev_overlay_mask.gr.zx02" + +overlay25: + .incbin "movie1/overlays/overlay25.gr.zx02" +overlay29: + .incbin "movie1/overlays/overlay29.gr.zx02" +overlay30: + .incbin "movie1/overlays/overlay30.gr.zx02" +overlay31: + .incbin "movie1/overlays/overlay31.gr.zx02" +overlay32: + .incbin "movie1/overlays/overlay32.gr.zx02" +overlay33: + .incbin "movie1/overlays/overlay33.gr.zx02" +overlay34: + .incbin "movie1/overlays/overlay34.gr.zx02" +overlay35: + .incbin "movie1/overlays/overlay35.gr.zx02" + + diff --git a/games/riven_hgr/movie1/convert.sh b/games/riven_hgr/movie1/convert.sh new file mode 100755 index 00000000..c23f9fd9 --- /dev/null +++ b/games/riven_hgr/movie1/convert.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +#$i = 25 + +/home/vince/research/apple2/dos33fsprogs.git/demos/second/part18_3d/auto/box_convert ./img025_bg.png> frame025.inc ; diff --git a/games/riven_hgr/movie1/overlays/Makefile b/games/riven_hgr/movie1/overlays/Makefile index 70f9ca00..abdeb55d 100644 --- a/games/riven_hgr/movie1/overlays/Makefile +++ b/games/riven_hgr/movie1/overlays/Makefile @@ -3,7 +3,15 @@ include ../../../../Makefile.inc ZX02 = ~/research/6502_compression/zx02.git/build/zx02 PNG2GR = ../../../../utils/gr-utils/png2gr -all: maglev_overlay.gr.zx02 maglev_overlay_mask.gr.zx02 +all: maglev_overlay.gr.zx02 maglev_overlay_mask.gr.zx02 \ + overlay25.gr.zx02 \ + overlay29.gr.zx02 \ + overlay30.gr.zx02 \ + overlay31.gr.zx02 \ + overlay32.gr.zx02 \ + overlay33.gr.zx02 \ + overlay34.gr.zx02 \ + overlay35.gr.zx02 #### diff --git a/games/riven_hgr/wait.s b/games/riven_hgr/wait.s new file mode 100644 index 00000000..0b690fc9 --- /dev/null +++ b/games/riven_hgr/wait.s @@ -0,0 +1,35 @@ +; copy of ROM wait +; because we might disable ROM + +; waits 0.5 * (26 + 27A + 5A^2) useconds + +wait: + sec +wait2: + pha +wait3: + sbc #$01 + bne wait3 + pla + sbc #$01 + bne wait2 + rts +wait_end: + + + ; to wait 50ms its approximately 139? + +wait_50ms: + ldx #1 +wait_50xms: + +wait_50_loop: + lda #139 + jsr wait + dex + bne wait_50_loop + + rts + + +.assert (>wait_end - >wait) < 1 , error, "wait crosses page boundary" diff --git a/games/riven_hgr/zp.inc b/games/riven_hgr/zp.inc index 008c297f..affc7762 100644 --- a/games/riven_hgr/zp.inc +++ b/games/riven_hgr/zp.inc @@ -125,7 +125,7 @@ SOUND_STATUS = $DE SOUND_IN_LC = $01 ; $01 sound effects in language card SOUND_MOCKINGBOARD = $02 ; mockingboard detected -GRID_PAGE = $DF +SCENE_COUNT = $DF ANIMATE_FRAME = $E0 LEVEL_OVER = $E1 GAME_OVER = $FF @@ -144,31 +144,11 @@ STAR_CYCLE = $E5 DISP_PAGE = $ED ; ALL DRAW_PAGE = $EE ; ALL -; rest of pt3_player -MB_DETECTED = $EF -WHICH_CHUNK = $F0 -MB_CHUNK_OFFSET = $F1 -LOOP = $F4 -MB_VALUE = $F5 -MB_ADDR_L = $F6 -MB_ADDR_H = $F7 -DONE_PLAYING = $F8 -DONE_SONG = $F9 - -; rest of pt3_player -PT3_TEMP = $EF -ORNAMENT_L = $F0 -ORNAMENT_H = $F1 -SAMPLE_L = $F2 -SAMPLE_H = $F3 - - - -MUSIC_PTR = $F7 -LEADING_ZERO = $F8 -TEMP_STATUS = $F9 -TEMP = $FA -TEMPY = $FB +WHICH_OVERLAY = $F8 +TEMP = $F9 +;TEMPY = $FB +MASKL = $FA +MASKH = $FB INL = $FC INH = $FD OUTL = $FE