Prev: 38367 Up: Map Next: 38443
38381: Condition: Is The Location Lit?
Reports whether the current location is lit.
We're only interested if the currently processed character is the player. Return if not.
LocationLit 38381 LD A,(46826) Return if CurrentCharacter is not zero.
38384 AND A
38385 RET NZ
Begin...
38386 PUSH IX Save IX and BC, and point IX at the player.
38388 PUSH BC
Check if the player object is inside "something".
38389 LD IX,49435
38393 CALL ContainerLit Call ContainerLit to test whether the container is lit.
38396 INC A If the player is inside of another object then jump to LocationLit_Sword.
38397 JR NZ,LocationLit_Sword
Check the location data to see if this location is light or dark.
38399 CALL GetObjectLocationInIX Call GetObjectLocationInIX to point IX at this location.
38402 BIT 7,(IX+0) If the location is marked as being "LIGHT" then jump to LocationLit_Return to return.
38406 JR NZ,LocationLit_Return
The "Short Strong Sword" is a light source, can it be used?
LocationLit_Sword 38408 PUSH IY Save IY, point it at 14 - "Short Strong Sword", and call ConditionTheObjectIsHere.
38410 LD A,14
38412 LD IY,49925
38416 CALL ConditionTheObjectIsHere
38419 POP IY Jump to LocationLit_IsDark if ConditionTheObjectIsHere did not find that object here.
38421 JR Z,LocationLit_IsDark
38423 LD A,(49932) Read that object's attributes.
38426 XOR 247 XOR 11110111.
38428 AND 28 Jump to LocationLit_IsLight if that object gives light, is not broken and is full.
38430 JR Z,LocationLit_IsLight
The below handle the two responses for "light" and "dark" using the carry flag to signify darkness when set, and light unset.
LocationLit_IsDark 38432 LD HL,44575 Point at the message "it is dark" (44575).
38435 SCF Set carry: this location is dark.
LocationLit_Return 38436 POP BC Restore BC and IX from the stack.
38437 POP IX
38439 RET Return.
LocationLit_IsLight 38440 AND A Clear carry: this location is lit.
38441 JR LocationLit_Return Jump back to LocationLit_Return to return.
Prev: 38367 Up: Map Next: 38443