peasant: split out the draw peasant routine

This commit is contained in:
Vince Weaver 2021-08-14 13:48:02 -04:00
parent f00749f6b8
commit 80747fd82d
4 changed files with 64 additions and 63 deletions

View File

@ -71,7 +71,7 @@ PEASANT: peasant.o
peasant.o: peasant.s graphics/graphics.inc sprites/peasant_sprite.inc \
draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \
hgr_7x30_sprite.s hgr_1x5_sprite.s hgr_save_restore.s \
wait_a_bit.s \
wait_a_bit.s draw_peasant.s \
title.s directions.s \
cottage.s lake_w.s lake_e.s river.s knight.s \
ending.s

View File

@ -246,65 +246,6 @@ display_cottage_text3:
rts
;============================
; draw peasant
;============================
draw_peasant:
lda PEASANT_X
sta CURSOR_X
lda PEASANT_Y
sta CURSOR_Y
lda PEASANT_DIR
cmp #PEASANT_DIR_RIGHT
beq peasant_right
;=====================
; up up up up
peasant_up:
lda FRAME
and #1
beq peasant_up1
peasant_up2:
lda #<peasant_up2_sprite
sta INL
lda #>peasant_up2_sprite
jmp done_pick_draw
peasant_up1:
lda #<peasant_up1_sprite
sta INL
lda #>peasant_up1_sprite
jmp done_pick_draw
peasant_right:
lda CURSOR_X
and #1
bne draw_right1
draw_right2:
lda #<peasant_right2_sprite
sta INL
lda #>peasant_right2_sprite
jmp done_pick_draw
draw_right1:
lda #<peasant_right1_sprite
sta INL
lda #>peasant_right1_sprite
done_pick_draw:
sta INH
jsr hgr_draw_sprite_7x30
rts
peasant_text:
.byte 25,2,"Peasant's Quest",0
@ -338,9 +279,6 @@ cottage_text3:
; Walk to edge of screen
.include "sprites/peasant_sprite.inc"
cottage_path:
.byte 10,117 ; 0 ; 5s, text 1

View File

@ -0,0 +1,61 @@
;============================
; draw peasant
;============================
draw_peasant:
lda PEASANT_X
sta CURSOR_X
lda PEASANT_Y
sta CURSOR_Y
lda PEASANT_DIR
cmp #PEASANT_DIR_RIGHT
beq peasant_right
;=====================
; up up up up
peasant_up:
lda FRAME
and #1
beq peasant_up1
peasant_up2:
lda #<peasant_up2_sprite
sta INL
lda #>peasant_up2_sprite
jmp done_pick_draw
peasant_up1:
lda #<peasant_up1_sprite
sta INL
lda #>peasant_up1_sprite
jmp done_pick_draw
peasant_right:
lda CURSOR_X
and #1
bne draw_right1
draw_right2:
lda #<peasant_right2_sprite
sta INL
lda #>peasant_right2_sprite
jmp done_pick_draw
draw_right1:
lda #<peasant_right1_sprite
sta INL
lda #>peasant_right1_sprite
done_pick_draw:
sta INH
jsr hgr_draw_sprite_7x30
rts
.include "sprites/peasant_sprite.inc"

View File

@ -87,6 +87,8 @@ peasant_quest:
.include "river.s"
.include "knight.s"
.include "draw_peasant.s"
.include "hgr_font.s"
.include "draw_box.s"
.include "hgr_rectangle.s"