dos33fsprogs/games/peasant/peasant2.s

537 lines
8.5 KiB
ArmAsm
Raw Normal View History

; Peasant's Quest
; Peasantry Part 2 (second line of map)
2021-09-29 20:53:41 +00:00
; haystack, puddle, archery, river, knight (pass)
2021-08-15 04:23:41 +00:00
; by Vince `deater` Weaver vince@deater.net
; with apologies to everyone
.include "hardware.inc"
.include "zp.inc"
.include "qload.inc"
2024-09-19 18:23:45 +00:00
.include "./inventory/inventory.inc"
.include "parse_input.inc"
LOCATION_BASE = LOCATION_HAY_BALE ; index starts here (5)
2021-10-21 05:18:02 +00:00
peasantry2:
2021-08-15 04:23:41 +00:00
2021-08-15 05:12:43 +00:00
lda #0
sta LEVEL_OVER
2021-08-15 04:23:41 +00:00
sta FRAME
2021-09-27 20:44:40 +00:00
jsr hgr_make_tables ; necessary?
; jsr hgr2 ; necessary?
2021-09-27 20:44:40 +00:00
; decompress dialog to $D000
lda #<peasant2_text_zx02
sta zx_src_l+1
lda #>peasant2_text_zx02
sta zx_src_h+1
lda #$D0
jsr zx02_full_decomp
2021-08-29 03:05:36 +00:00
; update score
jsr update_score
2021-10-21 15:43:20 +00:00
;=============================
;=============================
; new screen location
;=============================
;=============================
new_location:
lda #0
sta LEVEL_OVER
;==========================
; load updated verb table
; setup default verb table
jsr setup_default_verb_table
; we are PEASANT2 so locations 5...9 map to 0...4
lda MAP_LOCATION
sec
sbc #LOCATION_BASE
tax
lda verb_tables_low,X
sta INL
lda verb_tables_hi,X
sta INH
jsr load_custom_verb_table
;============================
; load priority to $400
; indirectly as we can't trash screen holes
2021-08-15 04:23:41 +00:00
; we are PEASANT2 so locations 5...9 map to 0...4
lda MAP_LOCATION
sec
sbc #LOCATION_BASE
tax
lda map_priority_low,X
sta zx_src_l+1
lda map_priority_hi,X
sta zx_src_h+1
2021-08-15 04:23:41 +00:00
lda #$20
2021-08-15 04:23:41 +00:00
jsr zx02_full_decomp
2021-08-15 04:23:41 +00:00
jsr gr_copy_to_page1
;=====================
; load bg
2021-08-24 17:38:03 +00:00
; we are PEASANT2 so locations 5...9 map to 0...4
lda MAP_LOCATION
sec
sbc #LOCATION_BASE
2021-08-24 17:38:03 +00:00
tax
lda map_backgrounds_low,X
sta zx_src_l+1
lda map_backgrounds_hi,X
sta zx_src_h+1
2021-08-24 17:38:03 +00:00
lda #$20
jsr zx02_full_decomp
2021-08-24 17:38:03 +00:00
; copy to $4000
jsr hgr_copy
2021-08-24 17:38:03 +00:00
; put peasant text
2021-08-15 04:23:41 +00:00
lda #<peasant_text
sta OUTL
lda #>peasant_text
sta OUTH
jsr hgr_put_string
; put score
2021-08-29 03:05:36 +00:00
jsr print_score
2021-08-15 04:23:41 +00:00
;====================
; save background
; lda PEASANT_X
; sta CURSOR_X
; lda PEASANT_Y
; sta CURSOR_Y
2021-08-15 04:23:41 +00:00
;=======================
; draw initial peasant
; jsr save_bg_1x28
2021-08-15 05:19:26 +00:00
; jsr draw_peasant
2021-08-15 04:23:41 +00:00
2021-12-06 03:57:18 +00:00
;======================
; check if in hay
jsr check_haystack_exit
2021-11-20 05:17:47 +00:00
;=====================
; special archery
;=====================
lda ARROW_SCORE
bpl game_loop
; coming back from archery game
and #$7f ; unset
sta ARROW_SCORE
and #$f ; see if score (bottom) is 0
beq arrow_game_zero
sta TEMP0
lda ARROW_SCORE
lsr
lsr
lsr
lsr
cmp TEMP0
bne arrow_game_lost
arrow_game_won:
; get 3 points
lda #3
jsr score_points
; get bow
lda INVENTORY_1
ora #INV1_BOW
sta INVENTORY_1
; set won
lda GAME_STATE_0
ora #ARROW_BEATEN
sta GAME_STATE_0
lda TEMP0
clc
adc #'0'
sta archery_won_message+14
ldx #<archery_won_message
ldy #>archery_won_message
jsr partial_message_step
jmp game_loop
arrow_game_zero:
ldx #<archery_zero_message
ldy #>archery_zero_message
jsr partial_message_step
jmp arrow_game_lose_common
arrow_game_lost:
lda TEMP0
clc
adc #'0'
sta archery_some_message+24 ; urgh affected by compression
ldx #<archery_some_message
ldy #>archery_some_message
jsr partial_message_step
arrow_game_lose_common:
ldx #<archery_lose_message
ldy #>archery_lose_message
jsr partial_message_step
;================================
;================================
;================================
; main loop
;================================
;================================
;================================
2021-08-15 04:23:41 +00:00
game_loop:
;====================
; move peasant
2021-08-24 17:52:11 +00:00
jsr move_peasant
2021-08-15 04:23:41 +00:00
lda LEVEL_OVER
bmi oops_new_location
bne level_over
2021-11-02 04:58:20 +00:00
;=====================
; level specific
;=====================
lda MAP_LOCATION
cmp #LOCATION_MUD_PUDDLE
beq at_mud_puddle
cmp #LOCATION_RIVER_STONE
beq at_river
cmp #LOCATION_ARCHERY
beq at_archery
2021-11-02 04:58:20 +00:00
bne skip_level_specific
;=======================
; handle river animation
;=======================
at_river:
jsr animate_river
jmp skip_level_specific
;=======================
; archery animations
;=======================
at_archery:
jsr animate_archery
jmp skip_level_specific
;=====================
; handle mud puddle
;=====================
2021-11-02 04:58:20 +00:00
at_mud_puddle:
; see if falling in
; see if puddle wet
lda GAME_STATE_1
and #PUDDLE_WET
beq skip_level_specific
; see if clean
lda GAME_STATE_2
and #COVERED_IN_MUD
bne skip_level_specific
; see if X in range
lda PEASANT_X
cmp #$B
bcc skip_level_specific
cmp #$1B
bcs skip_level_specific
; see if Y in range
lda PEASANT_Y
cmp #$64
bcc skip_level_specific
cmp #$80
bcs skip_level_specific
; in range!
ldx #<puddle_walk_in_message
ldy #>puddle_walk_in_message
jsr partial_message_step
; make muddy
lda GAME_STATE_2
ora #COVERED_IN_MUD
sta GAME_STATE_2
; do animation?
; points if we haven't already
lda GAME_STATE_2
and #GOT_MUDDY_ALREADY
bne skip_level_specific
; add 2 points to score
lda #2
jsr score_points
lda GAME_STATE_2
ora #GOT_MUDDY_ALREADY
sta GAME_STATE_2
skip_level_specific:
;====================
; always draw peasant
jsr draw_peasant
;====================
; increment frame
inc FRAME
;====================
; check keyboard
lda #13
sta WAIT_LOOP
wait_loop:
jsr check_keyboard
2021-08-15 05:12:43 +00:00
lda #50 ; approx 7ms
jsr wait
dec WAIT_LOOP
bne wait_loop
;=====================
2021-08-15 05:19:26 +00:00
; delay
; lda #200 ; approx 100ms
; jsr wait
2021-08-15 05:19:26 +00:00
2021-08-15 04:23:41 +00:00
jmp game_loop
oops_new_location:
jmp new_location
2021-08-15 04:23:41 +00:00
2021-10-26 04:01:39 +00:00
;========================
; exit level
2021-10-26 04:01:39 +00:00
;========================
level_over:
cmp #NEW_FROM_LOAD ; skip to end if loading save game
beq really_level_over
2021-12-13 03:29:36 +00:00
; specical case if going outside inn
; we don't want to end up behind inn
lda MAP_LOCATION
cmp #LOCATION_OUTSIDE_INN
2021-12-13 03:29:36 +00:00
bne not_behind_inn
; be sure we're in range
lda PEASANT_X
cmp #6
2021-12-13 03:29:36 +00:00
bcc really_level_over ; fine if at far right
cmp #18
2021-12-13 03:29:36 +00:00
bcc to_left_of_inn
cmp #30
2021-12-13 03:29:36 +00:00
bcc to_right_of_inn
; fine if at far left
not_behind_inn:
lda MAP_LOCATION
cmp #LOCATION_CLIFF_BASE
bne not_going_to_cliff
lda #18
sta PEASANT_X
lda #140
sta PEASANT_Y
lda #0
sta PEASANT_XADD
sta PEASANT_YADD
sta PEASANT_DIR
2021-08-15 05:12:43 +00:00
2021-12-13 03:29:36 +00:00
not_going_to_cliff:
really_level_over:
rts
2021-12-13 03:29:36 +00:00
to_right_of_inn:
lda #31
sta PEASANT_X
2021-08-15 05:12:43 +00:00
rts
2021-12-13 03:29:36 +00:00
to_left_of_inn:
lda #5
sta PEASANT_X
rts
2021-08-15 05:12:43 +00:00
;========================
; animate archery
;=========================
animate_archery:
lda FRAME
and #4
bne mendelev_arm_moved
mendelev_normal:
lda #107
sta SAVED_Y1
lda #110
sta SAVED_Y2
lda #29
ldx #31
jmp hgr_partial_restore
mendelev_arm_moved:
lda #<mendelev1_sprite
sta INL
inx
lda #>mendelev1_sprite
sta INH
lda #29
sta CURSOR_X
lda #107
sta CURSOR_Y
jmp hgr_draw_sprite ;
2021-12-06 03:57:18 +00:00
.include "peasant_common.s"
.include "move_peasant.s"
2021-08-15 04:23:41 +00:00
.include "draw_peasant.s"
2021-08-24 17:38:03 +00:00
.include "gr_copy.s"
.include "new_map_location.s"
.include "keyboard.s"
.include "wait.s"
2021-08-15 04:23:41 +00:00
.include "wait_a_bit.s"
.include "graphics_peasantry/graphics_peasant2.inc"
.include "graphics_peasantry/priority_peasant2.inc"
2021-08-15 04:23:41 +00:00
.include "hgr_copy.s"
.include "hgr_sprite.s"
.include "animate_river.s"
.include "sprites/archery_sprites.inc"
map_backgrounds_low:
.byte <haystack_zx02 ; 5 -- haystack
.byte <puddle_zx02 ; 6 -- puddle
.byte <archery_zx02 ; 7 -- archery
.byte <river_zx02 ; 8 -- river
.byte <knight_zx02 ; 9 -- knight
map_backgrounds_hi:
.byte >haystack_zx02 ; 5 -- haystack
.byte >puddle_zx02 ; 6 -- puddle
.byte >archery_zx02 ; 7 -- archery
.byte >river_zx02 ; 8 -- river
.byte >knight_zx02 ; 9 -- knight
2021-08-24 17:38:03 +00:00
map_priority_low:
.byte <haystack_priority_zx02 ; 5 -- haystack
.byte <puddle_priority_zx02 ; 6 -- puddle
.byte <archery_priority_zx02 ; 7 -- archery
.byte <river_priority_zx02 ; 8 -- river
.byte <knight_priority_zx02 ; 9 -- knight
2021-08-24 17:38:03 +00:00
map_priority_hi:
.byte >haystack_priority_zx02 ; 5 -- haystack
.byte >puddle_priority_zx02 ; 6 -- puddle
.byte >archery_priority_zx02 ; 7 -- archery
.byte >river_priority_zx02 ; 8 -- river
.byte >knight_priority_zx02 ; 9 -- knight
verb_tables_low:
.byte <hay_bale_verb_table ; 5 -- haystack
2021-10-20 17:34:59 +00:00
.byte <puddle_verb_table ; 6 -- puddle
2021-10-20 20:37:54 +00:00
.byte <archery_verb_table ; 7 -- archery
.byte <river_stone_verb_table ; 8 -- river
.byte <mountain_pass_verb_table ; 9 -- knight
verb_tables_hi:
.byte >hay_bale_verb_table ; 5 -- haystack
2021-10-20 17:34:59 +00:00
.byte >puddle_verb_table ; 6 -- puddle
2021-10-20 20:37:54 +00:00
.byte >archery_verb_table ; 7 -- archery
.byte >river_stone_verb_table ; 8 -- river
.byte >mountain_pass_verb_table ; 9 -- knight
peasant2_text_zx02:
2024-10-03 03:47:28 +00:00
.incbin "text/DIALOG_PEASANT2.ZX02"
2021-10-20 04:47:40 +00:00
.include "peasant2_actions.s"