Skip to content

Commit b0a3740

Browse files
authored
Merge pull request #36 from skx/33-trapdoor
The trapdoor has three logical states.
2 parents 86f5527 + 672344f commit b0a3740

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

game.z80

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ MAX_GRUE_EXPOSURE: EQU 3
6565
TORCH_STATE_UNLIT: EQU 0
6666
TORCH_STATE_LIT: EQU 1
6767

68-
; 2. The trapdoor may be open or closed.
69-
; [It may also be invisible, but that is handled via another mechanism]
70-
TRAPDOOR_STATE_CLOSED: EQU 0
71-
TRAPDOOR_STATE_OPEN: EQU 1
68+
; 2. The trapdoor may be invisible, open, or closed.
69+
; [The objects have an invisible state, but we can't use that here.]
70+
TRAPDOOR_STATE_INVISIBLE: EQU 0
71+
TRAPDOOR_STATE_CLOSED: EQU 1
72+
TRAPDOOR_STATE_OPEN: EQU 2
7273

7374
; 3. The mirror may be normal, or broken
7475
MIRROR_OK: EQU 0
@@ -1473,8 +1474,12 @@ get_found_it_take:
14731474
;
14741475
; Make trapdoor visible is called when the rug is taken/examined.
14751476
;
1476-
; It moves the trapdoor into the appropriate location within the
1477-
; map.
1477+
; The trapdoor has three states:
1478+
;
1479+
; invisible, open, closed
1480+
;
1481+
; If the current state is invisible then we mark it as visible.
1482+
14781483
make_trapdoor_visible:
14791484
ld hl, item_11_name
14801485
call get_item_by_name
@@ -1497,6 +1502,10 @@ place_trapdoor:
14971502

14981503
; Save the location in the item.
14991504
ld (IX+ITEM_TABLE_LOCATION_OFFSET),a
1505+
1506+
; Update the state
1507+
ld a, TRAPDOOR_STATE_CLOSED
1508+
ld (IX+ITEM_TABLE_STATE_OFFSET), a
15001509
ret
15011510

15021511

@@ -2501,6 +2510,13 @@ use_trapdoor_fn:
25012510
ld a,(IX+ITEM_TABLE_STATE_OFFSET)
25022511

25032512
; update the state to be open
2513+
cp TRAPDOOR_STATE_INVISIBLE
2514+
jr nz, not_invisible
2515+
2516+
ld de, item_not_present_msg
2517+
call bios_output_string
2518+
ret
2519+
not_invisible:
25042520
cp TRAPDOOR_STATE_CLOSED
25052521
jr z, trapdoor_was_closed
25062522
cp TRAPDOOR_STATE_OPEN
@@ -3373,13 +3389,13 @@ trapdoor_desc:
33733389
DEFW item_11_closed
33743390
trapdoor_edesc:
33753391
DEFW item_11_desc_closed
3376-
DEFB 0,0 ; No take function
3377-
DEFB 0,0 ; No drop function
3378-
DEFB 0,0 ; no custom examine function
3379-
DEFW use_trapdoor_fn ; open function
3380-
DEFB TRAPDOOR_STATE_CLOSED ; item state
3381-
DEFB 0 ; this item cannot be picked up
3382-
DEFB ITEM_INVISIBLE ; hidden until the rug is moved
3392+
DEFB 0,0 ; No take function
3393+
DEFB 0,0 ; No drop function
3394+
DEFB 0,0 ; no custom examine function
3395+
DEFW use_trapdoor_fn ; open function
3396+
DEFB TRAPDOOR_STATE_INVISIBLE ; item state
3397+
DEFB 0 ; this item cannot be picked up
3398+
DEFB ITEM_INVISIBLE ; hidden until the rug is moved
33833399

33843400
DEFW item_13_name ; meteor
33853401
DEFW item_13_desc

0 commit comments

Comments
 (0)