From 80747fd82d9aa9981b6bb206d52939cafd4bc8f9 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 14 Aug 2021 13:48:02 -0400 Subject: [PATCH] peasant: split out the draw peasant routine --- games/peasant/Makefile | 2 +- games/peasant/cottage.s | 62 ------------------------------------ games/peasant/draw_peasant.s | 61 +++++++++++++++++++++++++++++++++++ games/peasant/peasant.s | 2 ++ 4 files changed, 64 insertions(+), 63 deletions(-) create mode 100644 games/peasant/draw_peasant.s diff --git a/games/peasant/Makefile b/games/peasant/Makefile index 3315a01e..3cf2b0fd 100644 --- a/games/peasant/Makefile +++ b/games/peasant/Makefile @@ -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 diff --git a/games/peasant/cottage.s b/games/peasant/cottage.s index 9500e2e7..294439be 100644 --- a/games/peasant/cottage.s +++ b/games/peasant/cottage.s @@ -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 - jmp done_pick_draw - -peasant_up1: - lda #peasant_up1_sprite - jmp done_pick_draw - - -peasant_right: - lda CURSOR_X - and #1 - bne draw_right1 - -draw_right2: - lda #peasant_right2_sprite - jmp done_pick_draw - -draw_right1: - 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 diff --git a/games/peasant/draw_peasant.s b/games/peasant/draw_peasant.s new file mode 100644 index 00000000..abc7224a --- /dev/null +++ b/games/peasant/draw_peasant.s @@ -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 + jmp done_pick_draw + +peasant_up1: + lda #peasant_up1_sprite + jmp done_pick_draw + + +peasant_right: + lda CURSOR_X + and #1 + bne draw_right1 + +draw_right2: + lda #peasant_right2_sprite + jmp done_pick_draw + +draw_right1: + lda #peasant_right1_sprite + +done_pick_draw: + sta INH + + jsr hgr_draw_sprite_7x30 + + rts + + +.include "sprites/peasant_sprite.inc" diff --git a/games/peasant/peasant.s b/games/peasant/peasant.s index f77e12be..0d4f051c 100644 --- a/games/peasant/peasant.s +++ b/games/peasant/peasant.s @@ -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"