Routines
| Prev: DDBE | Up: Map | Next: DE6F |
DDD0: Default action: WAIT UNTIL (verb 50)
|
Works out how many minutes there are from now until the time typed (the number at $A02F: hour and minute in 6-bit fields, bit 6 of the hour marking am and bit 6 of the minute pm), converting both times to minutes past 12 o'clock (DE48: hours x 60 + minutes, 12 counting as 0) and, when neither am nor pm was typed, taking whichever comes next; the result becomes the time the action takes ($A01F), so the player's next turn simply comes that much later (see the main loop at A064, which also lets ENTER cut the wait short). DDCB-DDCF hold the two times and the am/pm letter.
01am on Monday: WAIT UNTIL 9:00 sets the action time to 59 minutes ($89 $00 at $A02F: bit 7 marks a time); WAIT UNTIL 8 to 719 (8pm, the next 8 o'clock); WAIT UNTIL 8:30PM ($88 $5E, bit 6 of the minutes) to 749; WAIT UNTIL 7AM ($C7 $00, bit 6 of the hour) to 1379, 7am the next day. All four waits are cut short at 8:34 by the news about Lestrade.
How it works:
1. Take the time typed ($A02F) and work out the minutes past twelve for it (DE48) and for the clock now.
2. If am or pm was typed, the target is in that half of the day; otherwise it is in the same half as now, or the next.
3. The difference is how long the action takes ($A01F).
|
||||||||||||||
| DDD0 | DEFB $45,$00,$B8,$DD | Action record header: flags $45; bit 6: pre-check at DDB8; byte 1 $00 | ||||||||||||
| DDD4 | LD HL,($A02F) | Read $A02F in "Game variables" into HL - HL = the typed time ($A02F); drop bit 7 | ||||||||||||
| DDD7 | RES 7,H | Clear bit 7 of H | ||||||||||||
| DDD9 | PUSH HL | Save HL on the stack | ||||||||||||
| DDDA | LD A,H | Copy H into A - Without the am/pm bits... | ||||||||||||
| DDDB | AND $3F | Keep only bits 0, 1, 2, 3, 4, 5 of A (mask $3F) | ||||||||||||
| DDDD | LD H,A | Copy A into H | ||||||||||||
| DDDE | LD A,L | Copy L into A | ||||||||||||
| DDDF | AND $3F | Keep only bits 0, 1, 2, 3, 4, 5 of A (mask $3F) | ||||||||||||
| DDE1 | LD L,A | Copy A into L | ||||||||||||
| DDE2 | CALL $DE48 | Call DE48 (inside "Default action: WAIT UNTIL (verb 50)") - ...in minutes past twelve (DE48): the target, at DDCD | ||||||||||||
| DDE5 | LD ($DDCD),HL | Store HL in DDCD in "Script helper: wait n minutes" | ||||||||||||
| DDE8 | LD HL,($9FDF) | Read the minute (9FDF) into HL - The clock (9FDF) in minutes: now, at DDCB | ||||||||||||
| DDEB | CALL $DE48 | Call DE48 (inside "Default action: WAIT UNTIL (verb 50)") | ||||||||||||
| DDEE | LD ($DDCB),HL | Store HL in DDCB in "Script helper: wait n minutes" | ||||||||||||
| DDF1 | POP HL | Restore HL from the stack | ||||||||||||
| DDF2 | LD A,$61 | Load A with $61 - am typed: the target is in the morning (DDCF = 'a') | ||||||||||||
| DDF4 | LD ($DDCF),A | Store A in DDCF in "Script helper: wait n minutes" | ||||||||||||
| DDF7 | BIT 6,H | Test bit 6 of H | ||||||||||||
| DDF9 | JR NZ,$DE19 | If bit 6 of H is set, skip ahead to DE19 | ||||||||||||
| DDFB | LD A,$70 | Load A with $70 - pm typed: in the afternoon ('p') | ||||||||||||
| DDFD | LD ($DDCF),A | Store A in DDCF in "Script helper: wait n minutes" | ||||||||||||
| DE00 | BIT 6,L | Test bit 6 of L | ||||||||||||
| DE02 | JR NZ,$DE19 | If bit 6 of L is set, skip ahead to DE19 | ||||||||||||
| DE04 | CALL $DE60 | Call DE60 (inside "Default action: WAIT UNTIL (verb 50)") - Neither: the same half of the day as now (9FE2)... | ||||||||||||
| DE07 | LD A,($9FE2) | Read 'a' or 'p' (9FE2) into A | ||||||||||||
| DE0A | JR C,$DE0E | If the carry flag is set, skip ahead to DE0E | ||||||||||||
| DE0C | JR NZ,$DE16 | If the zero flag is clear, skip ahead to DE16 | ||||||||||||
| DE0E | CP $61 | Compare A with $61 - ...unless that time has gone (or is now): then the other half | ||||||||||||
| DE10 | LD A,$70 | Load A with $70 | ||||||||||||
| DE12 | JR Z,$DE16 | If A equals $61, skip ahead to DE16 | ||||||||||||
| DE14 | LD A,$61 | Load A with $61 | ||||||||||||
| DE16 | LD ($DDCF),A | Store A in DDCF in "Script helper: wait n minutes" | ||||||||||||
| DE19 | LD HL,($DDCD) | Read DDCD in "Script helper: wait n minutes" into HL - HL = target - now | ||||||||||||
| DE1C | LD DE,($DDCB) | Read DDCB in "Script helper: wait n minutes" into DE | ||||||||||||
| DE20 | AND A | Clear the carry flag, so that the subtraction that follows is a plain one (a compare) | ||||||||||||
| DE21 | SBC HL,DE | Subtract DE from HL (a compare: carry = HL was smaller, zero = equal) | ||||||||||||
| DE23 | LD DE,$02D0 | Load DE with $02D0 - DE = twelve hours | ||||||||||||
| DE26 | LD A,($9FE2) | Read 'a' or 'p' (9FE2) into A | ||||||||||||
| DE29 | LD C,A | Copy A into C | ||||||||||||
| DE2A | LD A,($DDCF) | Read DDCF in "Script helper: wait n minutes" into A | ||||||||||||
| DE2D | LD B,A | Copy A into B | ||||||||||||
| DE2E | CALL $DE60 | Call DE60 (inside "Default action: WAIT UNTIL (verb 50)") - Later than now: add twelve hours if it is in the other half | ||||||||||||
| DE31 | JR C,$DE3C | If the carry flag is set, skip ahead to DE3C | ||||||||||||
| DE33 | JR Z,$DE3C | If the zero flag is set, skip ahead to DE3C | ||||||||||||
| DE35 | LD A,B | Copy B into A | ||||||||||||
| DE36 | CP C | Compare A with C | ||||||||||||
| DE37 | JR Z,$DE42 | If A equals C, skip ahead to DE42 | ||||||||||||
| DE39 | ADD HL,DE | Add DE to HL | ||||||||||||
| DE3A | JR $DE42 | Skip ahead to DE42 | ||||||||||||
| DE3C | ADD HL,DE | Add DE to HL - Not later: add twelve hours, and twelve more for the same half | ||||||||||||
| DE3D | LD A,B | Copy B into A | ||||||||||||
| DE3E | CP C | Compare A with C | ||||||||||||
| DE3F | JR NZ,$DE42 | If A differs from C, skip ahead to DE42 | ||||||||||||
| DE41 | ADD HL,DE | Add DE to HL | ||||||||||||
| DE42 | LD ($A01F),HL | Store HL in $A01F in "Game variables" - That is how long the wait takes ($A01F); succeed | ||||||||||||
| DE45 | OR $01 | Make A non-zero, which clears the zero flag, and hand that back to the caller | ||||||||||||
| DE47 | RET | Return to the caller | ||||||||||||
| DE48 | PUSH DE | Save DE on the stack - HL = hours x 60 + minutes, twelve o'clock counting as 0 | ||||||||||||
| DE49 | PUSH BC | Save BC on the stack | ||||||||||||
| DE4A | LD C,L | Copy L into C | ||||||||||||
| DE4B | LD B,H | Copy H into B | ||||||||||||
| DE4C | LD HL,$0000 | Load HL with $0000 | ||||||||||||
| DE4F | LD DE,$003C | Load DE with $003C | ||||||||||||
| DE52 | LD A,B | Copy B into A | ||||||||||||
| DE53 | CP $0C | Compare A with $0C | ||||||||||||
| DE55 | JR Z,$DE5A | If A equals $0C, skip ahead to DE5A | ||||||||||||
| DE57 | ADD HL,DE | Add DE to HL | ||||||||||||
| DE58 | DJNZ $DE57 | Count B down and, while it is not zero, go back to DE57 | ||||||||||||
| DE5A | LD B,$00 | Load B with $00 | ||||||||||||
| DE5C | ADD HL,BC | Add BC to HL | ||||||||||||
| DE5D | POP BC | Restore BC from the stack | ||||||||||||
| DE5E | POP DE | Restore DE from the stack | ||||||||||||
| DE5F | RET | Return to the caller | ||||||||||||
| DE60 | PUSH HL | Save HL on the stack - Compare the target with now (carry if earlier, Z if the same) | ||||||||||||
| DE61 | PUSH DE | Save DE on the stack | ||||||||||||
| DE62 | LD HL,($DDCD) | Read DDCD in "Script helper: wait n minutes" into HL | ||||||||||||
| DE65 | LD DE,($DDCB) | Read DDCB in "Script helper: wait n minutes" into DE | ||||||||||||
| DE69 | AND A | Clear the carry flag, so that the subtraction that follows is a plain one (a compare) | ||||||||||||
| DE6A | SBC HL,DE | Subtract DE from HL (a compare: carry = HL was smaller, zero = equal) | ||||||||||||
| DE6C | POP DE | Restore DE from the stack | ||||||||||||
| DE6D | POP HL | Restore HL from the stack | ||||||||||||
| DE6E | RET | Return to the caller | ||||||||||||
| Prev: DDBE | Up: Map | Next: DE6F |