![]() |
Routines |
| Prev: 6752 | Up: Map | Next: 67CC |
|
Entered from the routine at F918.
|
||||
| 6767 | LD HL,($7FF7) | 7FF7 holds the lesson clock | ||
| 676A | DEC HL | Decrease it by 1 and set the zero flag if it's time to ring the bell | ||
| 676B | LD A,H | |||
| 676C | OR L | |||
| 676D | LD ($7FF7),HL | |||
| 6770 | CALL Z,$66E6 | Change the lesson if the lesson clock reached zero | ||
| 6773 | CALL $6226 | Move the characters | ||
| 6776 | CALL $6AD9 | Move ERIC | ||
| 6779 | JR C,$67BC | Jump if ERIC has already been dealt with | ||
| 677B | LD HL,$7FE8 | Decrement ERIC's main action timer at 7FE8 | ||
| 677E | DEC (HL) | |||
| 677F | JR NZ,$67BC | Jump unless it's time to deal with ERIC | ||
| 6781 | INC L | Pick up the midstride indicator at 7FE9 | ||
| 6782 | LD A,(HL) | |||
| 6783 | AND A | Is ERIC midstride? | ||
| 6784 | JR Z,$678B | Jump if not | ||
| 6786 | CALL $6500 | Move ERIC from the midstride position, then scroll the screen left or right if necessary | ||
| 6789 | JR $67BF | |||
|
Time to check the keyboard (or simulate a keypress in demo mode) to see how ERIC should move next.
|
||||
| 678B | DEC L | Reset ERIC's main action timer at 7FE8 to 9 | ||
| 678C | LD (HL),$09 | |||
| 678E | CALL $F5DA | Collect or simulate a keypress | ||
| 6791 | JR Z,$67BC | Jump if no relevant keypress was collected or simulated | ||
| 6793 | LD HL,$7FFB | 7FFB holds ERIC's status flags | ||
| 6796 | BIT 5,(HL) | Is ERIC writing on a blackboard? | ||
| 6798 | JR Z,$679F | Jump if not | ||
| 679A | CALL $F6AA | Deal with keypresses while ERIC is writing on the board | ||
| 679D | JR $67BC | |||
| 679F | INC L | DE=7FFC (which holds the ASCII code of the last keypress) | ||
| 67A0 | EX DE,HL | |||
| 67A1 | CP $20 | Was the keypress ASCII code >= 0x20? | ||
| 67A3 | JR C,$67BC | Jump if not | ||
| 67A5 | LD HL,$67BC | Push the address of the entry point at 67BC (see below) onto the stack | ||
| 67A8 | PUSH HL | |||
| 67A9 | LD L,A | Point HL at the appropriate entry in the keypress offset table | ||
| 67AA | LD H,$68 | |||
| 67AC | LD L,(HL) | |||
| 67AD | LDI | Copy the ASCII code of the keypress into 7FFC | ||
| 67AF | LD E,(HL) | Pick up in DE the address of the appropriate routine for dealing with the keypress | ||
| 67B0 | INC L | |||
| 67B1 | LD D,(HL) | |||
| 67B2 | PUSH DE | Push this address onto the stack | ||
| 67B3 | LD HL,$AC60 | Point HL at byte 0x60 of ERIC's buffer | ||
| 67B6 | LD B,(HL) | Pick up ERIC's animatory state in B and his coordinates in DE | ||
| 67B7 | INC L | |||
| 67B8 | LD D,(HL) | |||
| 67B9 | INC L | |||
| 67BA | LD E,(HL) | |||
| 67BB | RET | Make an indirect jump to the appropriate routine for dealing with ERIC, then return to 67BC below | ||
|
Now that ERIC has been moved or otherwise dealt with, update the display.
|
||||
| 67BC | CALL $6992 | Update the display | ||
|
The next section of code ensures that we don't pass through the main loop more than once every 20 milliseconds.
|
||||
| 67BF | LD HL,$7FFA | Wait until the system variable FRAMES at 5C78 has been incremented since the last time it was checked (FRAMES is incremented every 20ms) | ||
| 67C2 | LD A,($5C78) | |||
| 67C5 | CP (HL) | |||
| 67C6 | JR Z,$67C2 | |||
| 67C8 | LD (HL),A | |||
| 67C9 | JP $6767 | Jump back to the beginning of the main loop | ||
| Prev: 6752 | Up: Map | Next: 67CC |