Prev: F2DF Up: Map Next: F3D4
F2E2: Deal with ERIC when he's sitting or lying down
Used by the routine at F7AD when bit 2 at 7FFB is set (by the routine at F28E, F3D7 or FBCC). Makes ERIC stand up if 'S' is pressed, or open a desk (and collect any contents) if 'O' is pressed.
F2E2 LD HL,$7FF3 7FF3 holds ERIC's main action timer
F2E5 DEC (HL) Is it time to deal with ERIC yet?
F2E6 RET NZ Return if not
F2E7 LD A,($7FDE) 7FDE holds 0xFF if we're in demo mode, 0x00 otherwise
F2EA INC A Are we in demo mode?
F2EB JR NZ,$F320 Jump if not
We're in demo mode. Figure out ERIC's next move depending on what little boy no. 10 is doing.
F2ED CALL $F6BE Exit demo mode and start a new game if a key was pressed; otherwise return here with ERIC's animatory state in A
F2F0 LD HL,$C700 Point HL at byte 0x00 of little boy no. 10's buffer
F2F3 CP $04 0x04: Is ERIC sitting in a chair?
F2F5 JR Z,$F2FB Jump if so
F2F7 CP $85 0x85: Is ERIC sitting on the floor facing right?
F2F9 JR NZ,$F308 Jump if not
F2FB ADD A,$40 A=0x44 (little boy sitting on a chair) or 0xC5 (little boy sitting on the floor facing right)
F2FD CP (HL) Compare ERIC's animatory state with that of little boy no. 10
F2FE LD HL,$7FDC 7FDC holds the counter that determines the delay between little boy no. 10 standing up and ERIC standing up
F301 JR NZ,$F306 Jump if ERIC's not doing what little boy no. 10 is doing
F303 LD (HL),$2D Initialise the stand-up delay counter at 7FDC to 45
F305 RET
F306 DEC (HL) Decrement the stand-up delay counter at 7FDC
F307 RET NZ Return if it's not time for ERIC to stand up
F308 LD HL,$7FFB 7FFB holds ERIC's status flags
F30B LD (HL),$00 Clear all of them (ERIC is no longer sitting or lying down)
This entry point is used by the routine at 5E6F.
F30D CALL $7154 Make a sound effect
F310 LD H,$D2 0xD2=ERIC
F312 CALL $61B4 Update the SRB for ERIC's current animatory state and location
F315 AND $80 A=0x00/0x80: ERIC standing up
This entry point is used by the routines at 5D63, 5E45, FAF2 and FBA0.
F317 CALL $6130 Update ERIC's animatory state and location and update the SRB
F31A LD A,$06 Set ERIC's main action timer (at 7FF3) to 6
F31C LD ($7FF3),A
F31F RET
We're not in demo mode.
F320 CALL $71BE Collect the code of the last key pressed in A
F323 RET Z Return if no keys were pressed
F324 RES 5,A Normalise the code to upper case
F326 CP $53 Was 'S' pressed?
F328 JR Z,$F308 Make ERIC stand up if so
F32A CP $4F Was 'O' pressed?
F32C RET NZ Return if not
F32D LD A,($D200) A=ERIC's animatory state
F330 CP $04 0x04: Is ERIC sitting in a chair?
F332 RET NZ Return if not
ERIC is sitting in a chair and 'O' (open desk) was pressed. Compute the ID of the desk ERIC is sitting at so we can determine whether he's found the water pistol or the stinkbombs.
F333 LD A,($D601) Pick up the x-coordinate of whatever object is using buffer 0xD6
F336 CP $C0 Is this buffer being used at the moment?
F338 RET C Return if so
F339 LD DE,($D201) Pick up ERIC's coordinates in DE
F33D LD A,D A=ERIC's y-coordinate
F33E CP $0A Is ERIC on the middle floor?
F340 JR Z,$F356 Jump if so
F342 CP $03 Is ERIC on the top floor?
F344 RET NZ Return if not
F345 LD A,E A=ERIC's x-coordinate
F346 CP $16 Is ERIC in the Blue Room?
F348 JR C,$F352 Jump if so
F34A SUB $1B
F34C CP $22 Is ERIC in the Yellow Room?
F34E JR C,$F352 Jump if so
F350 SUB $6A
F352 SUB $09
F354 JR $F35F
F356 LD A,E A=ERIC's x-coordinate
F357 CP $35 Is ERIC in the Science lab?
F359 JR C,$F35D Jump if so
F35B SUB $71
F35D SUB $02
F35F RRA
F360 LD B,A
At this point B holds the identifier of the desk that ERIC's sitting at.
Desk IDs Room
0x01-0x06 Blue Room
0x07-0x0C Yellow Room
0x0D-0x12 Top-floor room in the girls' skool
0x13-0x19 Science Lab
0x1A-0x1F Middle-floor room in the girls' skool
Now we check whether the water pistol has been placed in a desk yet.
F361 LD HL,$7FDA 7FDA holds the ID of the desk containing the water pistol
F364 LD A,(HL) Has the water pistol been placed in a desk yet?
F365 AND A
F366 JR NZ,$F376 Jump if so
The water pistol hasn't been placed in a desk yet. Pick one at random that doesn't match the desk containing the stinkbombs.
F368 CALL $6291 A=random desk ID from 0x01 to 0x1F
F36B AND $1F
F36D JR Z,$F368
F36F LD L,$DB HL=7FDB (which holds the ID of the desk containing the stinkbombs)
F371 CP (HL) Is this the desk containing the stinkbombs?
F372 JR Z,$F368 Get another random desk ID if so
F374 DEC L Otherwise place the newly determined ID of the desk containing the water pistol into 7FDA
F375 LD (HL),A
Check whether ERIC has found the water pistol.
F376 CP B Is ERIC sitting at the desk that contains the water pistol?
F377 JR NZ,$F389 Jump if not
F379 LD (HL),$00 Set 7FDA to 0 (the water pistol is not in any desk now)
F37B LD L,$EB HL=7FEB (inventory flags)
F37D LD A,(HL) Pick these up in A
F37E AND $18 Keep only bits 3 and 4 (the pistol bits)
F380 LD A,$2C 0x2C: animatory state of a desk lid
F382 JR NZ,$F3A9 Jump if ERIC already has a water pistol
F384 SET 3,(HL) Give ERIC a water pistol (full of water)
F386 INC A 0x2D: animatory state of a desk lid with a water pistol
F387 JR $F3A9
There was no water pistol in the desk. Check whether there are stinkbombs.
F389 INC L HL=7FDB (which holds the ID of the desk containing the stinkbombs)
F38A LD A,(HL) Have the stinkbombs been placed in a desk yet?
F38B AND A
F38C JR NZ,$F39C Jump if so
The stinkbombs haven't been placed in a desk yet. Pick one at random that doesn't match the desk containing the water pistol.
F38E CALL $6291 A=random desk ID from 0x01 to 0x1F
F391 AND $1F
F393 JR Z,$F38E
F395 LD L,$DA HL=7FDA (which holds the ID of the desk containing the water pistol)
F397 CP (HL) Is this the desk containing the water pistol?
F398 JR Z,$F38E Get another random desk ID if so
F39A INC L Otherwise place the newly determined ID of the desk containing the stinkbombs into 7FDB
F39B LD (HL),A
Check whether ERIC has found the stinkbombs.
F39C CP B Compare the ID of the desk ERIC's sitting at (A) with the ID of the desk containing the stinkbombs (B)
F39D LD A,$2C 0x2C: animatory state of a desk lid
F39F JR NZ,$F3A9 Jump if ERIC isn't sitting at the desk that contains the stinkbombs
F3A1 LD L,$EB HL=7FEB (inventory flags)
F3A3 LD A,(HL) Set bits 5-7, giving ERIC three stinkbombs
F3A4 OR $E0
F3A6 LD (HL),A
F3A7 LD A,$2E 0x2E: animatory state of a desk lid with stinkbombs
Now A holds the animatory state of the desk lid: 0x2C (empty desk), 0x2D (with pistol), or 0x2E (with stinkbombs).
F3A9 LD HL,$D613 Point HL at byte 0x13 of the desk lid's buffer
F3AC LD (HL),$08 Initialise the counter determining how long the desk lid stays up
F3AE DEC E E=x-coordinate of the desk lid in front of ERIC
F3AF CALL $7746 Update the SRB for the desk lid's appearance and place address F3B2 (below) into bytes 0x11 and 0x12 of its buffer
The address of this entry point is placed into bytes 0x11 and 0x12 of the desk lid's buffer by the instruction above.
F3B2 LD L,$13 Byte 0x13 of the desk lid's buffer holds the delay counter that determines when the desk lid will shut
F3B4 DEC (HL) Decrement this counter
F3B5 LD A,(HL) Copy its current value to A
F3B6 JP Z,$74CF Jump if it's time for the desk lid to close
F3B9 SUB $06 Is it time for ERIC to collect the contents of the desk?
F3BB RET NZ Return if not
F3BC LD L,A L=0x00
F3BD LD A,(HL) A=animatory state of a desk lid (with contents, if any)
F3BE CP $2C 0x2C: Is the desk empty?
F3C0 RET Z Return if so
This entry point is used by the routines at 5DDC, 7316 and 7380.
F3C1 CALL $7C02 Print the inventory
This entry point is used by the routine at 5F1C.
F3C4 LD C,$05 Make a celebratory sound effect (ERIC has achieved something rather handy)
F3C6 LD B,$03
F3C8 LD HL,$FF17
F3CB LD D,H
F3CC LD E,H
F3CD CALL $F2CB
F3D0 DEC C
F3D1 JR NZ,$F3C6
F3D3 RET
Prev: F2DF Up: Map Next: F3D4