Routines
| Prev: D06A | Up: Map | Next: D0D0 |
D078: Is it too dark for the actor to see? (carry if so)
|
Only for actors that need light: those with +4 bit 7 in their own record ($A017) - the player, the cabs and cabbies, the trains and a few others; everyone else sees in the dark. For them it is dark when inside something, or when the room's record has bit 7 of its first byte clear (outdoors, it seems) and C00C says it is night (8pm to 6am) - unless a light is about: a thing that also has +4 bit 7, whose +5 flags masked with $5C give $14 (full and on, not a person: the oil lamp starts like this, +5 = $94), and that C821 says is here.
Walking to Baker Street and setting the clock to 9pm, LOOK gets 'SORRY IT IS TOO DARK.' without the oil lamp and the normal description with it.
How it works:
1. Only actors with +4 bit 7 set (the player, and some others) can be in the dark.
2. Follow the actor's containment chain (C86E). A room with its light bit (+0 bit 7) is never dark; nor is anywhere by day (anything but night, C00C).
3. At night in an unlit room, look through all the things for a light: one that is in the actor's reach, alight (+5 passes the test) and shining (+4 bit 7). If one is found it is not dark.
4. Otherwise return with carry set.
|
||||||||||||||
| D078 | PUSH IX | Save IX on the stack | ||||||||||||
| D07A | PUSH IY | Save IY on the stack | ||||||||||||
| D07C | PUSH BC | Save BC on the stack | ||||||||||||
| D07D | LD IX,($A017) | Read $A017 in "Game variables" into IX - Only actors with +4 bit 7 can be in the dark | ||||||||||||
| D081 | LD A,(IX+$04) | Read byte +4 of the record at IX into A | ||||||||||||
| D084 | AND $80 | Isolate bit 7 of A (mask $80) | ||||||||||||
| D086 | JR Z,$D0C6 | If bit 7 of A was clear, jump on to D0C6 | ||||||||||||
| D088 | CALL $C86E | Call the routine "Follow an object's containment chain to its root" (C86E) - (C86E, then the room and the hour) | ||||||||||||
| D08B | INC A | Add one to A | ||||||||||||
| D08C | JR NZ,$D09E | If A is not zero, skip ahead to D09E | ||||||||||||
| D08E | CALL $D33C | Call the routine "IX = record of the actor's room" (D33C) - A lit room (record byte 0 bit 7) is never dark | ||||||||||||
| D091 | BIT 7,(IX+$00) | Test bit 7 of the first byte of the record at IX | ||||||||||||
| D095 | JR NZ,$D0C6 | If bit 7 of the first byte of the record at IX is set, jump on to D0C6 | ||||||||||||
| D097 | CALL $C00C | Call the routine "What part of the day is it? (A = 1-5)" (C00C) - Nor is anywhere by day (C00C: 1 means night, 8pm to 6am) | ||||||||||||
| D09A | CP $01 | Compare A with $01 | ||||||||||||
| D09C | JR NZ,$D0C6 | If A differs from $01, jump on to D0C6 | ||||||||||||
| D09E | LD IX,$8B6F | Point IX at "Entity index: id -> record address" (8B6F) - Night, unlit room: look through the things for a light | ||||||||||||
| D0A2 | CALL $D206 | Call the routine "Step to the next 3-byte entry" (D206) | ||||||||||||
| D0A5 | JR Z,$D0C9 | If the zero flag is set, skip ahead to D0C9 | ||||||||||||
| D0A7 | LD A,(IY+$00) | Read the first byte of the record at IY into A - One with n = 1, | ||||||||||||
| D0AA | CP $01 | Compare A with $01 | ||||||||||||
| D0AC | JR NZ,$D0A2 | If A differs from $01, go back to D0A2 | ||||||||||||
| D0AE | LD A,(IY+$05) | Read byte +5 of the record at IY into A - +5 & $5C = $14 (lit: the oil lamp once lit), | ||||||||||||
| D0B1 | XOR $B7 | Flip in A the bits that are set in $B7 | ||||||||||||
| D0B3 | AND $5C | Keep only bits 2, 3, 4, 6 of A (mask $5C) | ||||||||||||
| D0B5 | JR NZ,$D0A2 | If any of bits 2, 3, 4, 6 of A was set, go back to D0A2 | ||||||||||||
| D0B7 | LD A,(IY+$04) | Read byte +4 of the record at IY into A - +4 bit 7, | ||||||||||||
| D0BA | AND $80 | Isolate bit 7 of A (mask $80) | ||||||||||||
| D0BC | JR Z,$D0A2 | If bit 7 of A was clear, go back to D0A2 | ||||||||||||
| D0BE | LD A,(IX+$00) | Read the first byte of the record at IX into A - and here (C821): not dark after all | ||||||||||||
| D0C1 | CALL $C821 | Call the routine "Can the current actor ($A036) see thing A?" (C821) | ||||||||||||
| D0C4 | JR Z,$D0A2 | If the zero flag is set, go back to D0A2 | ||||||||||||
| D0C6 | AND A | Test A for zero (this leaves A as it was and clears carry) - NC: the actor can see | ||||||||||||
| D0C7 | JR $D0CA | Skip ahead to D0CA | ||||||||||||
| D0C9 | SCF | Set the carry flag - Carry: too dark | ||||||||||||
| D0CA | POP BC | Restore BC from the stack | ||||||||||||
| D0CB | POP IY | Restore IY from the stack | ||||||||||||
| D0CD | POP IX | Restore IX from the stack | ||||||||||||
| D0CF | RET | Return to the caller | ||||||||||||
| Prev: D06A | Up: Map | Next: D0D0 |