peasant: work on baby sprites

This commit is contained in:
Vince Weaver 2021-09-12 21:32:14 -04:00
parent 00b5d7769d
commit 7c68df5a96
6 changed files with 282 additions and 13 deletions

View File

@ -178,9 +178,9 @@ ENDING: ending.o
ending.o: ending.s zp.inc \
graphics_end/ending_graphics.inc sprites/peasant_sprite.inc \
sprites/inventory_sprites.inc \
sprites/ending_sprites.inc \
draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \
hgr_7x28_sprite_mask.s hgr_1x5_sprite.s hgr_save_restore.s \
hgr_14x14_sprite_mask.s hgr_1x5_sprite.s hgr_save_restore.s \
wait_a_bit.s draw_peasant.s hgr_text_box.s \
keyboard.s parse_input.s new_map_location.s \
peasant_move.s score.s inventory.s

View File

@ -142,6 +142,41 @@ waterfall:
;=========================
; animate baby
lda #10
sta CURSOR_X
lda #120
sta CURSOR_Y
ldx #0
stx BABY_COUNT
baby_loop:
; baby 0
jsr save_bg_14x14
ldx BABY_COUNT
lda baby_pointers_l,X
sta INL
lda baby_pointers_h,X
sta INH
jsr hgr_draw_sprite_14x14
jsr wait_until_keypress
jsr restore_bg_14x14
jsr wait_until_keypress
inc BABY_COUNT
lda BABY_COUNT
cmp #11
bne baby_loop
;
;===========================
jsr wait_until_keypress
@ -327,18 +362,20 @@ peasant_text:
;.include "draw_peasant.s"
;.include "hgr_save_restore.s"
;.include "hgr_7x28_sprite_mask.s"
;.include "clear_bottom.s"
;.include "gr_offsets.s"
;.include "gr_copy.s"
;.include "version.inc"
.include "hgr_14x14_sprite_mask.s"
.include "score.s"
.include "wait_a_bit.s"
.include "graphics_end/ending_graphics.inc"
.include "sprites/ending_sprites.inc"
boat_string:
.byte 2,40
@ -365,6 +402,32 @@ cottage_string2:
.byte "Nice work on winning and everything.",0
baby_pointers_l:
.byte <baby0_sprite
.byte <baby1_sprite
.byte <baby2_sprite
.byte <baby3_sprite
.byte <baby4_sprite
.byte <baby5_sprite
.byte <baby6_sprite
.byte <baby7_sprite
.byte <baby8_sprite
.byte <baby9_sprite
.byte <baby10_sprite
baby_pointers_h:
.byte >baby0_sprite
.byte >baby1_sprite
.byte >baby2_sprite
.byte >baby3_sprite
.byte >baby4_sprite
.byte >baby5_sprite
.byte >baby6_sprite
.byte >baby7_sprite
.byte >baby8_sprite
.byte >baby9_sprite
.byte >baby10_sprite
update_top:
; put peasant text
@ -381,7 +444,3 @@ update_top:
jsr print_score
rts

View File

@ -0,0 +1,188 @@
;===============================
; hgr 14x14 draw sprite with mask
;===============================
; SPRITE in INL/INH
; Location at CURSOR_X CURSOR_Y
; sprite AT INL/INH
; mask at INL/INH + 28
hgr_draw_sprite_14x14:
; set up sprite pointers
lda INL
sta h1414_smc1+1
sta h1414_smc2+1
lda INH
sta h1414_smc1+2
sta h1414_smc2+2
; clc
; lda INL
; adc #1
; sta h1414_smc2+1
; lda INH
; adc #0
; sta h1414_smc2+2
; set up mask pointers
clc
lda INL
adc #28
sta h1414_smc3+1
sta h1414_smc4+1
lda INH
adc #0
sta h1414_smc3+2
sta h1414_smc4+2
; clc
; lda INL
; adc #29
; sta h1414_smc4+1
; lda INH
; adc #0
; sta h1414_smc4+2
ldx #0 ; X is pointer offset
stx MASK ; actually counter
hgr_14x14_sprite_yloop:
lda MASK
clc
adc CURSOR_Y ; add in cursor_y
; calc GBASL/GBASH
tay ; get output ROW into GBASL/H
lda hposn_low,Y
sta GBASL
lda hposn_high,Y
sta GBASH
ldy CURSOR_X
lda (GBASL),Y ; load background
h1414_smc3:
and $d000,X ; mask with sprite mask
h1414_smc1:
ora $d000,X ; or in sprite
sta (GBASL),Y ; store out
inx
iny
lda (GBASL),Y ; load background
h1414_smc4:
and $d000,X ; mask with sprite mask
h1414_smc2:
ora $d000,X ; or in sprite
sta (GBASL),Y ; store out
inx
inc MASK
lda MASK
cmp #14
bne hgr_14x14_sprite_yloop
rts
;======================
; save bg 14x14
;======================
save_bg_14x14:
ldx #0
save_yloop:
txa
pha
clc
adc CURSOR_Y
; calc GBASL/GBASH
tax
lsr
lda hposn_low,X
sta GBASL
lda hposn_high,X
sta GBASH
pla
tax
ldy CURSOR_X
lda (GBASL),Y
sta save_sprite_14x14,X
iny
inx
lda (GBASL),Y
sta save_sprite_14x14,X
inx
cpx #28
bne save_yloop
rts
;======================
; restore bg 14x14
;======================
restore_bg_14x14:
ldx #0
restore_yloop:
txa ; current row
lsr
clc
adc CURSOR_Y ; add in y start point
; calc GBASL/GBASH using lookup table
tay
lda hposn_low,Y
sta GBASL
lda hposn_high,Y
sta GBASH
ldy CURSOR_X
lda save_sprite_14x14,X
sta (GBASL),Y
inx
iny
lda save_sprite_14x14,X
sta (GBASL),Y
inx
cpx #28
bne restore_yloop
rts
;====================
; save area
;====================
save_sprite_14x14:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00

View File

@ -1,6 +1,6 @@
HGR_SPRITE = ../../../utils/hgr-utils/hgr_make_sprite
all: inventory_sprites.inc
all: inventory_sprites.inc ending_sprites.inc
inventory_sprites.inc: inventory.png
$(HGR_SPRITE) -l arrow_sprite inventory.png 14 3 27 19 > inventory_sprites.inc
@ -23,10 +23,29 @@ inventory_sprites.inc: inventory.png
$(HGR_SPRITE) -l tshirt_sprite inventory.png 42 139 55 155 >> inventory_sprites.inc
ending_sprites.inc: end_sprites.png
$(HGR_SPRITE) -l baby0_sprite end_sprites.png 14 3 27 17 > ending_sprites.inc
$(HGR_SPRITE) -l baby0_mask end_sprites.png 42 3 55 17 >> ending_sprites.inc
$(HGR_SPRITE) -l baby1_sprite end_sprites.png 14 20 27 34 >> ending_sprites.inc
$(HGR_SPRITE) -l baby1_mask end_sprites.png 42 20 55 34 >> ending_sprites.inc
$(HGR_SPRITE) -l baby2_sprite end_sprites.png 14 37 27 51 >> ending_sprites.inc
$(HGR_SPRITE) -l baby2_mask end_sprites.png 42 37 55 51 >> ending_sprites.inc
$(HGR_SPRITE) -l baby3_sprite end_sprites.png 14 54 27 68 >> ending_sprites.inc
$(HGR_SPRITE) -l baby3_mask end_sprites.png 42 54 55 68 >> ending_sprites.inc
$(HGR_SPRITE) -l baby4_sprite end_sprites.png 14 71 27 85 >> ending_sprites.inc
$(HGR_SPRITE) -l baby4_mask end_sprites.png 42 71 55 85 >> ending_sprites.inc
$(HGR_SPRITE) -l baby5_sprite end_sprites.png 14 88 27 102 >> ending_sprites.inc
$(HGR_SPRITE) -l baby5_mask end_sprites.png 42 88 55 102 >> ending_sprites.inc
$(HGR_SPRITE) -l baby6_sprite end_sprites.png 14 105 27 119 >> ending_sprites.inc
$(HGR_SPRITE) -l baby6_mask end_sprites.png 42 105 55 119 >> ending_sprites.inc
$(HGR_SPRITE) -l baby7_sprite end_sprites.png 14 122 27 136 >> ending_sprites.inc
$(HGR_SPRITE) -l baby7_mask end_sprites.png 42 122 55 136 >> ending_sprites.inc
$(HGR_SPRITE) -l baby8_sprite end_sprites.png 14 139 27 153 >> ending_sprites.inc
$(HGR_SPRITE) -l baby8_mask end_sprites.png 42 139 55 153 >> ending_sprites.inc
$(HGR_SPRITE) -l baby9_sprite end_sprites.png 14 156 27 170 >> ending_sprites.inc
$(HGR_SPRITE) -l baby9_mask end_sprites.png 42 156 55 170 >> ending_sprites.inc
$(HGR_SPRITE) -l baby10_sprite end_sprites.png 14 173 27 187 >> ending_sprites.inc
$(HGR_SPRITE) -l baby10_mask end_sprites.png 42 173 55 187 >> ending_sprites.inc
clean:
rm -f *~ inventory_sprites.inc
rm -f *~ inventory_sprites.inc ending_sprites.inc

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -164,6 +164,9 @@ BOX_Y2 = $C6
SAVED_Y1 = $C7
SAVED_Y2 = $C8
; temp for animations, etc
BABY_COUNT = $C9
; D0-D? used by HGR?
WHICH_SLOT = $DA