Routines |
Prev: F6D5 | Up: Map | Next: F74D |
The routine at F6D5 continues here.
|
||||
F6EA | LD HL,$7FE3 | 7FE3 holds the lesson clock | ||
F6ED | DEC (HL) | Decrement the LSB | ||
F6EE | JR NZ,$F6F7 | Jump if it's non-zero | ||
F6F0 | INC L | Point HL at the MSB of the lesson clock | ||
F6F1 | DEC (HL) | Decrement the MSB | ||
F6F2 | LD A,(HL) | Copy the new MSB to A | ||
F6F3 | INC A | Have we reached the end of the lesson? | ||
F6F4 | CALL Z,$F74D | Ring the bell and start the next lesson if so | ||
F6F7 | CALL $F6B4 | Move the characters, close any temporarily open doors, and make the nearest teacher give ERIC lines if he's up to something he shouldn't be | ||
F6FA | LD HL,$7FFB | 7FFB holds ERIC's primary status flags | ||
F6FD | LD A,(HL) | Pick these up in A | ||
F6FE | AND A | Are any of the status flags set? | ||
F6FF | JR Z,$F706 | Jump if not | ||
F701 | CALL $F7AD | Deal with ERIC if any of the status flags at 7FFB are set | ||
F704 | JR $F733 | |||
No status flags at 7FFB are set, which means ERIC is standing, or midstride, or just about to finish a 'short action' (bending over, dropping a stinkbomb, firing the water pistol, or moving forward as if to kiss). Here we finish ERIC's stride if he's midstride, finish any action he's just about to finish, or check for keypresses.
|
||||
F706 | LD L,$F3 | Decrement ERIC's main action timer at 7FF3 | ||
F708 | DEC (HL) | |||
F709 | JR NZ,$F733 | Jump unless it's 0 | ||
F70B | DEC L | Collect the mid-action timer from 7FF2 into A; it will be non-zero if ERIC is midstride or mid-action | ||
F70C | LD A,(HL) | |||
F70D | LD (HL),$00 | Reset the mid-action timer to 0 | ||
F70F | INC L | Copy the previous contents of the mid-action timer into the main action timer at 7FF3 | ||
F710 | LD (HL),A | |||
F711 | AND A | Is ERIC midstride or mid-action? | ||
F712 | JR NZ,$F730 | Jump if so | ||
ERIC is neither midstride nor just about to finish a short action, so check the keyboard.
|
||||
F714 | CALL $F413 | Check for keypresses | ||
F717 | JR Z,$F733 | Jump if there haven't been any | ||
F719 | LD ($7FF1),A | Store the offset of the last keypress in 7FF1 | ||
F71C | LD H,$E5 | HL will index the table of keypress handling routines at E550 | ||
F71E | LD DE,$F733 | Push the address F733 (see below) onto the stack so we return there after dealing with the keypress | ||
F721 | PUSH DE | |||
F722 | LD L,A | Point HL at the appropriate entry | ||
F723 | LD C,(HL) | Copy the address of the routine for dealing with the keypress into BC | ||
F724 | INC L | |||
F725 | LD B,(HL) | |||
F726 | PUSH BC | Push this address onto the stack | ||
F727 | LD HL,$D200 | Point HL at byte 0x00 of ERIC's buffer | ||
F72A | LD A,(HL) | Collect ERIC's animatory state into A, and his coordinates into DE | ||
F72B | INC L | |||
F72C | LD E,(HL) | |||
F72D | INC L | |||
F72E | LD D,(HL) | |||
F72F | RET | Make an indirect jump to the relevant keypress-handling routine, and then return to F733 | ||
ERIC is midstride, or just about to finish an action (such as firing the water pistol or catching a mouse). Make him finish the stride or action.
|
||||
F730 | CALL $6E00 | Update ERIC's animatory state and location, update the SRB, and scroll the screen if necessary | ||
Now that ERIC's movements have been dealt with, the main loop continues.
|
||||
F733 | CALL $62A0 | Update the display | ||
F736 | LD HL,$7FF3 | 7FF3 holds ERIC's main action timer | ||
F739 | LD A,(HL) | Pick this up in A | ||
F73A | AND A | Did we check for keypresses on this pass? | ||
F73B | JR NZ,$F73F | Jump if not | ||
F73D | LD (HL),$02 | Otherwise reset ERIC's main action timer to 2 | ||
This next section of code ensures that we don't pass through the main loop more than once every 1/50th of a second.
|
||||
F73F | LD L,$D9 | HL=7FD9 (which holds the LSB of the system variable FRAMES as it was when the last pass through the main loop was completed) | ||
F741 | LD A,($5C78) | A=LSB of the system variable FRAMES, which is incremented every 1/50th of a second | ||
F744 | SUB (HL) | Now A=0 if FRAMES hasn't been incremented since the last pass through the main loop | ||
F745 | CP $01 | Was FRAMES incremented? | ||
F747 | JR C,$F741 | Jump back if not to check again | ||
F749 | ADD A,(HL) | Store the current value of the LSB of FRAMES at 7FD9 | ||
F74A | LD (HL),A | |||
F74B | JR $F6EA | Jump back to the start of the main loop |
Prev: F6D5 | Up: Map | Next: F74D |