Routines

62178: Deal with ERIC when he's sitting or lying down


This routine is called by the routine at 63405 when bit 2 at 32763 is set

62178 21F37F LD HL,32755
62181 35 DEC (HL) Is it time to deal with ERIC yet?
62182 C0 RET NZ Return if not
62183 3ADE7F LD A,(32734)
62186 3C INC A Are we in demo mode?
62187 2033 JR NZ,62240 Jump if not
62189 CDBEF6 CALL 63166 Exit demo mode and start a new game if a key was pressed
62192 2100C7 LD HL,50944 H=199 (little boy no. 10), L=0
62195 FE04 CP 4 4: Is ERIC sitting in a chair?
62197 2804 JR Z,62203 Jump if so
62199 FE85 CP 133 133: Is ERIC sitting on the floor facing right?
62201 200D JR NZ,62216 Jump if not
62203 C640 ADD A,64 A=68 or 197
62205 BE CP (HL) Is ERIC doing what little boy no. 10 is doing?
62206 21DC7F LD HL,32732
62209 2003 JR NZ,62214 Jump if not
62211 362D LD (HL),45
62213 C9 RET
62214 35 DEC (HL)
62215 C0 RET NZ
62216 21FB7F LD HL,32763
62219 3600 LD (HL),0

This entry point is used by the routine at 24175:
62221 CD5471 CALL 29012 Make sound effect
62224 26D2 LD H,210 210=ERIC
62226 CDB461 CALL 25012 Update SRB for ERIC's current animatory state and location
62229 E680 AND 128 A=0/128: ERIC standing up

This entry point is used by several routines:
62231 CD3061 CALL 24880 Update SRB for ERIC's new animatory state and location
62234 3E06 LD A,6
62236 32F37F LD (32755),A
62239 C9 RET

We're not in demo mode.
62240 CDBE71 CALL 29118 Get code of last keypress in A
62243 C8 RET Z Return if no keys were pressed
62244 CBAF RES 5,A
62246 FE53 CP 83 Was 'S' pressed?
62248 28DE JR Z,62216 Jump if so
62250 FE4F CP 79 Was 'O' pressed?
62252 C0 RET NZ Return if not
62253 3A00D2 LD A,(53760) A=ERIC's animatory state
62256 FE04 CP 4 4: Is ERIC sitting in a chair?
62258 C0 RET NZ Return if not
62259 3A01D6 LD A,(54785) Pick up byte 1 of buffer 214
62262 FEC0 CP 192 Is this buffer being used at the moment?
62264 D8 RET C Return if so
62265 ED5B01D2 LD DE,(53761) Pick up ERIC's coordinates in DE
62269 7A LD A,D A=ERIC's y-coordinate
62270 FE0A CP 10 Is ERIC on the middle floor?
62272 2814 JR Z,62294 Jump if so
62274 FE03 CP 3 Is ERIC on the top floor?
62276 C0 RET NZ Return if not
62277 7B LD A,E A=ERIC's x-coordinate
62278 FE16 CP 22 Is ERIC in the Blue room?
62280 3808 JR C,62290 Jump if so
62282 D61B SUB 27
62284 FE22 CP 34 Is ERIC in the Yellow room?
62286 3802 JR C,62290 Jump if so
62288 D66A SUB 106
62290 D609 SUB 9
62292 1809 JR 62303
62294 7B LD A,E A=ERIC's x-coordinate
62295 FE35 CP 53 Is ERIC in the Science lab?
62297 3802 JR C,62301 Jump if so
62299 D671 SUB 113
62301 D602 SUB 2
62303 1F RRA
62304 47 LD B,A
62305 21DA7F LD HL,32730
62308 7E LD A,(HL)
62309 A7 AND A
62310 200E JR NZ,62326
62312 CD9162 CALL 25233 A=random number
62315 E61F AND 31
62317 28F9 JR Z,62312
62319 2EDB LD L,219 HL=32731
62321 BE CP (HL)
62322 28F4 JR Z,62312
62324 2D DEC L HL=32730
62325 77 LD (HL),A
62326 B8 CP B Is ERIC sitting at the desk which contains the water pistol?
62327 2010 JR NZ,62345 Jump if not
62329 3600 LD (HL),0
62331 2EEB LD L,235 HL=32747
62333 7E LD A,(HL) A=inventory flags
62334 E618 AND 24
62336 3E2C LD A,44 44: animatory state of desk lid
62338 2025 JR NZ,62377 Jump if ERIC already has a water pistol
62340 CBDE SET 3,(HL) Give ERIC a water pistol (full of water)
62342 3C INC A 45: animatory state of desk lid with water pistol
62343 1820 JR 62377
62345 2C INC L HL=32731
62346 7E LD A,(HL)
62347 A7 AND A
62348 200E JR NZ,62364
62350 CD9162 CALL 25233 A=random number
62353 E61F AND 31
62355 28F9 JR Z,62350
62357 2EDA LD L,218 HL=32730
62359 BE CP (HL)
62360 28F4 JR Z,62350
62362 2C INC L HL=32731
62363 77 LD (HL),A
62364 B8 CP B
62365 3E2C LD A,44 44: animatory state of desk lid
62367 2008 JR NZ,62377 Jump if ERIC isn't sitting at the desk which contains the stinkbombs
62369 2EEB LD L,235 HL=32747
62371 7E LD A,(HL) A=inventory flags
62372 F6E0 OR 224 Give ERIC three stinkbombs
62374 77 LD (HL),A
62375 3E2E LD A,46 46: animatory state of desk lid with stinkbombs
62377 2113D6 LD HL,54803 H=214, L=19
62380 3608 LD (HL),8 Set parameter controlling time desk lid stays up
62382 1D DEC E E=x-coordinate of desk lid in front of ERIC
62383 CD4677 CALL 30534 Update SRB for desk lid and place address 62386 in its buffer (214)
62386 2E13 LD L,19
62388 35 DEC (HL)
62389 7E LD A,(HL)
62390 CACF74 JP Z,29903 Jump if it's time for the desk lid to close
62393 D606 SUB 6 Is it time for ERIC to collect the contents of the desk?
62395 C0 RET NZ Return if not
62396 6F LD L,A
62397 7E LD A,(HL) A=animatory state of desk lid (with contents, if any)
62398 FE2C CP 44 44: Was the desk empty?
62400 C8 RET Z Return if so

This entry point is used by the routines at 24028, 29462 and 29568:
62401 CD027C CALL 31746 Print the inventory

This entry point is used by the routine at 24348:
62404 0E05 LD C,5 Make a celebratory sound effect (ERIC has achieved something rather handy)
62406 0603 LD B,3
62408 2117FF LD HL,65303
62411 54 LD D,H
62412 5C LD E,H
62413 CDCBF2 CALL 62155
62416 0D DEC C
62417 20F3 JR NZ,62406
62419 C9 RET