peasant: split out river animation code and share it

This commit is contained in:
Vince Weaver 2021-12-30 20:03:27 -05:00
parent 1a5134193b
commit 0fc854f149
4 changed files with 130 additions and 112 deletions

View File

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

View File

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

View File

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

View File

@ -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 <haystack_lzsa ; 5 -- haystack