@@ -65,10 +65,11 @@ MAX_GRUE_EXPOSURE: EQU 3
65
65
TORCH_STATE_UNLIT: EQU 0
66
66
TORCH_STATE_LIT: EQU 1
67
67
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
72
73
73
74
; 3. The mirror may be normal, or broken
74
75
MIRROR_OK: EQU 0
@@ -1473,8 +1474,12 @@ get_found_it_take:
1473
1474
;
1474
1475
; Make trapdoor visible is called when the rug is taken/examined.
1475
1476
;
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
+
1478
1483
make_trapdoor_visible:
1479
1484
ld hl, item_11_name
1480
1485
call get_item_by_name
@@ -1497,6 +1502,10 @@ place_trapdoor:
1497
1502
1498
1503
; Save the location in the item.
1499
1504
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
1500
1509
ret
1501
1510
1502
1511
@@ -2501,6 +2510,13 @@ use_trapdoor_fn:
2501
2510
ld a,(IX+ITEM_TABLE_STATE_OFFSET)
2502
2511
2503
2512
; 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:
2504
2520
cp TRAPDOOR_STATE_CLOSED
2505
2521
jr z, trapdoor_was_closed
2506
2522
cp TRAPDOOR_STATE_OPEN
@@ -3373,13 +3389,13 @@ trapdoor_desc:
3373
3389
DEFW item_11_closed
3374
3390
trapdoor_edesc:
3375
3391
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
3383
3399
3384
3400
DEFW item_13_name ; meteor
3385
3401
DEFW item_13_desc
0 commit comments