From 0fc854f14948cdddf8e229bece42c2a2d1b140da Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 30 Dec 2021 20:03:27 -0500 Subject: [PATCH] peasant: split out river animation code and share it --- games/peasant/Makefile | 4 +- games/peasant/animate_river.s | 103 +++++++++++++++++++++++++++++++++ games/peasant/intro_river.s | 106 +--------------------------------- games/peasant/peasant2.s | 29 +++++++--- 4 files changed, 130 insertions(+), 112 deletions(-) create mode 100644 games/peasant/animate_river.s diff --git a/games/peasant/Makefile b/games/peasant/Makefile index a2eaa86c..924f3745 100644 --- a/games/peasant/Makefile +++ b/games/peasant/Makefile @@ -215,6 +215,7 @@ intro.o: intro.s zp.inc qload.inc music.inc \ sprites/bubble_sprites_w.inc \ sprites/river_bubble_sprites.inc \ text/intro.inc \ + animate_river.s \ draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \ hgr_1x28_sprite_mask.s hgr_save_restore.s \ hgr_partial_save.s \ @@ -341,7 +342,8 @@ peasant2.o: peasant2.s zp.inc inventory.inc \ peasant2_actions.s DIALOG_PEASANT2.LZSA dialog_peasant2.inc \ graphics_peasantry/graphics_peasant2.inc sprites/peasant_sprites.inc \ graphics_peasantry/priority_peasant2.inc \ - sprites/inventory_sprites.inc \ + sprites/river_bubble_sprites.inc \ + animate_river.s \ peasant_common.s \ draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \ hgr_1x28_sprite_mask.s hgr_save_restore.s \ diff --git a/games/peasant/animate_river.s b/games/peasant/animate_river.s new file mode 100644 index 00000000..a1bd2bf6 --- /dev/null +++ b/games/peasant/animate_river.s @@ -0,0 +1,103 @@ + + ;================ + ; update bubbles river + +animate_river: + + ; 5,166 + ; 9,154 + ; 7,160 + + ; bubble 1 + + lda FRAME + and #3 + asl + tax + + lda bubble_progress_r,X + sta INL + inx + lda bubble_progress_r,X + sta INH + + lda #5 + sta CURSOR_X + lda #166 + sta CURSOR_Y + + jsr hgr_draw_sprite ;_1x5 + + + ; bubble 2 + + lda FRAME + adc #3 + and #3 + asl + tax + + lda bubble_progress_r,X + sta INL + inx + lda bubble_progress_r,X + sta INH + + lda #9 + sta CURSOR_X + lda #154 + sta CURSOR_Y + + jsr hgr_draw_sprite ;_1x5 + + ; bubble 3 + + lda FRAME + adc #5 + and #3 + asl + tax + + lda bubble_progress_r,X + sta INL + inx + lda bubble_progress_r,X + sta INH + + lda #7 + sta CURSOR_X + lda #160 + sta CURSOR_Y + + jsr hgr_draw_sprite ;_1x5 + + rts + + +bubble_progress_r: + .word bubble_r_sprite0 + .word bubble_r_sprite0 + .word bubble_r_sprite1 + .word bubble_r_sprite1 + + + .include "sprites/river_bubble_sprites.inc" + +.if 0 +bubble_r_sprite0: + .byte 1,5 + .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB + .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW + .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB + .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW + .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB + +bubble_r_sprite1: + .byte 1,5 + .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW + .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB + .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB + .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB + .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW + +.endif diff --git a/games/peasant/intro_river.s b/games/peasant/intro_river.s index 849c7f80..da8b70f3 100644 --- a/games/peasant/intro_river.s +++ b/games/peasant/intro_river.s @@ -123,9 +123,7 @@ check_river_action2: done_river_action: - jsr update_bubbles_r - - + jsr animate_river ; jsr wait_until_keypress @@ -186,104 +184,4 @@ river_path: .byte $FF,$FF - ;================ - ; update bubbles river -update_bubbles_r: - - ; 5,166 - ; 9,154 - ; 7,160 - - ; bubble 1 - - lda FRAME - and #3 - asl - tax - - lda bubble_progress_r,X - sta INL - inx - lda bubble_progress_r,X - sta INH - - lda #5 - sta CURSOR_X - lda #166 - sta CURSOR_Y - - jsr hgr_draw_sprite ;_1x5 - - - ; bubble 2 - - lda FRAME - adc #3 - and #3 - asl - tax - - lda bubble_progress_r,X - sta INL - inx - lda bubble_progress_r,X - sta INH - - lda #9 - sta CURSOR_X - lda #154 - sta CURSOR_Y - - jsr hgr_draw_sprite ;_1x5 - - ; bubble 3 - - lda FRAME - adc #5 - and #3 - asl - tax - - lda bubble_progress_r,X - sta INL - inx - lda bubble_progress_r,X - sta INH - - lda #7 - sta CURSOR_X - lda #160 - sta CURSOR_Y - - jsr hgr_draw_sprite ;_1x5 - - rts - - -bubble_progress_r: - .word bubble_r_sprite0 - .word bubble_r_sprite0 - .word bubble_r_sprite1 - .word bubble_r_sprite1 - - - .include "sprites/river_bubble_sprites.inc" - -.if 0 -bubble_r_sprite0: - .byte 1,5 - .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB - .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW - .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB - .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW - .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB - -bubble_r_sprite1: - .byte 1,5 - .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW - .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB - .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB - .byte $AA ; 1010 1010 0 10 10 10 BBBBBBB - .byte $FF ; 1111 1111 1 11 11 11 WWWWWWW - -.endif +.include "animate_river.s" diff --git a/games/peasant/peasant2.s b/games/peasant/peasant2.s index 5a688c44..f3a24d72 100644 --- a/games/peasant/peasant2.s +++ b/games/peasant/peasant2.s @@ -239,6 +239,10 @@ game_loop: jsr move_peasant + lda LEVEL_OVER + bmi oops_new_location + bne level_over + ;==================== ; always draw peasant @@ -254,6 +258,7 @@ game_loop: jsr check_keyboard + ;===================== ; level specific ;===================== @@ -261,8 +266,21 @@ game_loop: lda MAP_LOCATION cmp #LOCATION_MUD_PUDDLE beq at_mud_puddle + cmp #LOCATION_RIVER_STONE + beq at_river bne skip_level_specific + ;======================= + ; handle river animation + ;======================= +at_river: + jsr animate_river + jmp skip_level_specific + + ;===================== + ; handle mud puddle + ;===================== + at_mud_puddle: ; see if falling in @@ -318,16 +336,13 @@ at_mud_puddle: skip_level_specific: - lda LEVEL_OVER - bmi oops_new_location - bne level_over + ; delay lda #200 jsr wait - jmp game_loop oops_new_location: @@ -396,9 +411,6 @@ to_left_of_inn: .include "new_map_location.s" - -;.include "parse_input.s" - .include "keyboard.s" .include "wait.s" @@ -408,6 +420,9 @@ to_left_of_inn: .include "graphics_peasantry/priority_peasant2.inc" .include "hgr_copy.s" +.include "hgr_sprite.s" + +.include "animate_river.s" map_backgrounds_low: .byte