peasant: more work on inventory

This commit is contained in:
Vince Weaver 2021-08-31 01:15:12 -04:00
parent 138a2e4bbc
commit 971aa1c147
7 changed files with 202 additions and 20 deletions

View File

@ -44,10 +44,13 @@ hgr_text_box:
adc #0 adc #0
sta OUTH sta OUTH
; ; fallthrough
;
;
;=======================
; disp_put_string
; OUTL:OUTH has co-ords followed by string
; CR (13) goes to next line
disp_put_string:
ldy #0 ldy #0
lda (OUTL),Y lda (OUTL),Y
sta CURSOR_X sta CURSOR_X
@ -57,6 +60,9 @@ hgr_text_box:
lda (OUTL),Y lda (OUTL),Y
sta CURSOR_Y sta CURSOR_Y
jsr inc_outl jsr inc_outl
disp_one_line:
disp_put_string_loop: disp_put_string_loop:
ldy #0 ldy #0
lda (OUTL),Y lda (OUTL),Y

View File

@ -5,7 +5,113 @@
;===================== ;=====================
show_inventory: show_inventory:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #14
sta BOX_X1L
lda #20
sta BOX_Y1
lda #1
sta BOX_X2H
lda #5 ; ?
sta BOX_X2L
lda #135
sta BOX_Y2
jsr hgr_partial_save
jsr draw_box
;===================
; draw main text
lda #<inventory_message
sta OUTL
lda #>inventory_message
sta OUTH
jsr disp_put_string
; left column
lda #28
sta CURSOR_Y
ldy #0
left_column_loop:
lda #4
sta CURSOR_X
tya
pha
clc
lda left_item_offsets,Y
adc #<item_strings
sta OUTL
lda #0
adc #>item_strings
sta OUTH
jsr disp_one_line
lda CURSOR_Y
clc
adc #8
sta CURSOR_Y
pla
tay
iny
cpy #8
bne left_column_loop
; extra for riches
;================
; right column
lda #28
sta CURSOR_Y
ldy #0
right_column_loop:
lda #23
sta CURSOR_X
tya
pha
clc
lda right_item_offsets,Y
adc #<item_strings
sta OUTL
lda #0
adc #>item_strings
sta OUTH
jsr disp_one_line
lda CURSOR_Y
clc
adc #8
sta CURSOR_Y
pla
tay
iny
cpy #8
bne right_column_loop
jsr wait_until_keypress
rts rts
@ -20,50 +126,101 @@ show_inventory:
.byte "Hit return to go back to list",0 .byte "Hit return to go back to list",0
; first is only printed if have in inventory, though still can ; first is only printed if have in inventory, though still can
.byte "Press return for description",0 inventory_message:
.byte 5,106," Press return for description",13
.byte "Press ESC or Backspace to exit",0 .byte "Press ESC or Backspace to exit",0
;==================== ;====================
; Inventory Strings ; Inventory Strings
;==================== ;====================
.byte "????",0 unknown_string:
.byte "???",0
left_item_offsets:
.byte (item_arrow-item_strings)
.byte (item_baby-item_strings)
.byte (item_kerrek_belt-item_strings)
.byte (item_chicken_feed-item_strings)
.byte (item_funbow-item_strings)
.byte (item_monster_mask-item_strings)
.byte (item_pebbles-item_strings)
.byte (item_pills-item_strings)
right_item_offsets:
.byte (item_robe-item_strings)
.byte (item_soda-item_strings)
.byte (item_meatball_sub-item_strings)
.byte (item_super_trinket-item_strings)
.byte (item_troghelmet-item_strings)
.byte (item_trogshield-item_strings)
.byte (item_trogsword-item_strings)
.byte (item_impossible-item_strings)
item_strings:
item_arrow:
.byte "arrow",0 .byte "arrow",0
item_baby:
.byte "baby",0 .byte "baby",0
item_kerrek_belt:
.byte "kerrek belt",0 .byte "kerrek belt",0
item_chicken_feed:
.byte "chicken feed",0 .byte "chicken feed",0
.byte "SuperTime FunBow TM",0 item_funbow:
.byte "SuprTime FunBow TM",0 ; should be Super, makes column too wide
item_monster_mask:
.byte "monster maskus",0 .byte "monster maskus",0
item_pebbles:
.byte "pebbles",0 .byte "pebbles",0
item_pills:
.byte "pills",0 .byte "pills",0
item_riches:
.byte "riches",0 .byte "riches",0
item_robe:
.byte "robe",0 .byte "robe",0
item_soda:
.byte "soda",0 .byte "soda",0
item_meatball_sub:
.byte "meatball sub",0 .byte "meatball sub",0
item_super_trinket:
.byte "super trinket",0 .byte "super trinket",0
item_troghelmet:
.byte "TrogHelmet",0 .byte "TrogHelmet",0
item_trogshield:
.byte "TrogShield",0 .byte "TrogShield",0
item_trogsword:
.byte "TrogSword",0 .byte "TrogSword",0
;.byte "???",0 item_impossible:
.byte "???",0
item_shirt:
.byte "shirt",0 .byte "shirt",0
; arrow ; arrow
arrow_description:
.byte "Boy, you sure know how to pick",13 .byte "Boy, you sure know how to pick",13
.byte "em! This arrow's kinda pointy even!!",0 .byte "em! This arrow's kinda pointy even!!",0
; baby ; baby
baby_description:
.byte "Awww! Peasant babies are",13 .byte "Awww! Peasant babies are",13
.byte "adorable. No wonder they fetch",13 .byte "adorable. No wonder they fetch",13
.byte "such a pretty penny on the black",13 .byte "such a pretty penny on the black",13
.byte "market.",0 .byte "market.",0
; kerrek belt ; kerrek belt
kerrek_belt_description:
.byte "Phew! This thing stinks like all",13 .byte "Phew! This thing stinks like all",13
.byte "getout. Why couldn't the Kerrek",13 .byte "getout. Why couldn't the Kerrek",13
.byte "have kidnapped a hot wench or",13 .byte "have kidnapped a hot wench or",13
.byte "something that you coulda saved?",0 .byte "something that you coulda saved?",0
; chicken feed ; chicken feed
chicken_feed_description:
.byte "Woah! Gold nuggets! Oh",13 .byte "Woah! Gold nuggets! Oh",13
.byte "wait...This is just chicken",13 .byte "wait...This is just chicken",13
.byte "feed. Crap.",0 .byte "feed. Crap.",0

View File

@ -8,7 +8,7 @@ parse_input:
parse_copy: parse_copy:
cmp #'C' cmp #'C'
bne parse_look bne parse_inventory
; want copy ; want copy
lda #NEW_FROM_DISK lda #NEW_FROM_DISK
@ -20,6 +20,14 @@ parse_copy:
jmp done_parse_message jmp done_parse_message
parse_inventory:
cmp #'I'
bne parse_look
jsr show_inventory
jmp restore_parse_message
parse_look: parse_look:
cmp #'L' cmp #'L'
bne parse_talk bne parse_talk
@ -73,6 +81,9 @@ finish_parse_message:
jsr wait_until_keypress jsr wait_until_keypress
restore_parse_message:
jsr hgr_partial_restore jsr hgr_partial_restore
done_parse_message: done_parse_message:

View File

@ -173,6 +173,8 @@ peasant_text:
.include "parse_input.s" .include "parse_input.s"
.include "inventory.s"
.include "score.s" .include "score.s"
.include "keyboard.s" .include "keyboard.s"

View File

@ -177,6 +177,8 @@ peasant_text:
.include "parse_input.s" .include "parse_input.s"
.include "inventory.s"
.include "keyboard.s" .include "keyboard.s"
.include "wait_a_bit.s" .include "wait_a_bit.s"

View File

@ -180,6 +180,8 @@ peasant_text:
.include "parse_input.s" .include "parse_input.s"
.include "inventory.s"
.include "keyboard.s" .include "keyboard.s"
.include "wait_a_bit.s" .include "wait_a_bit.s"

View File

@ -124,8 +124,8 @@ INVENTORY_1 = $A0
INV1_MONSTER_MASK = $20 INV1_MONSTER_MASK = $20
INV1_PEBBLES = $40 INV1_PEBBLES = $40
INV1_PILLS = $80 INV1_PILLS = $80
INVENTORY_2 = $A1 INVENTORY_2 = $A1
INV2_RICHES = $01
INV2_ROBE = $02 INV2_ROBE = $02
INV2_SODA = $04 INV2_SODA = $04
INV2_MEATBALL = $08 INV2_MEATBALL = $08
@ -133,10 +133,12 @@ INVENTORY_2 = $A1
INV2_TROGHELM = $20 INV2_TROGHELM = $20
INV2_TROGSHIELD = $40 INV2_TROGSHIELD = $40
INV2_TROGSWORD = $80 INV2_TROGSWORD = $80
INVENTORY_3 = $A2 INV2_IMPOSSIBLE = $01
INV3_MAP = $01
INV3_SHIRT = $02
INVENTORY_3 = $A2
INV3_RICHES = $01
INV3_SHIRT = $02
INV3_MAP = $04
INVENTORY_1_GONE = $A3 ; had item, but now it's gone INVENTORY_1_GONE = $A3 ; had item, but now it's gone
INVENTORY_2_GONE = $A4 INVENTORY_2_GONE = $A4