Routines

31254: Control released mouse


The address of this routine is placed into the released mouse's buffer by the routine at 31502

H Buffer number for mouse (198, 199, 206-208)

31254 2E13 LD L,19
31256 7E LD A,(HL) A=remaining distance to travel
31257 A7 AND A Is it time for this mouse to disappear for a bit?
31258 2846 JR Z,31330 Jump if so
31260 3AF47F LD A,(32756) Doors flags
31263 F5 PUSH AF
31264 E63F AND 63 Lose bits 6 and 7 (windows) for now
31266 32F47F LD (32756),A
31269 CB7E BIT 7,(HL) Is the mouse travelling towards the right?
31271 2E01 LD L,1
31273 5E LD E,(HL)
31274 2802 JR Z,31278 Jump if so
31276 1D DEC E
31277 1D DEC E
31278 1C INC E E=x-coordinate of position in front of mouse
31279 2C INC L
31280 7E LD A,(HL) A=mouse's y-coordinate
31281 57 LD D,A
31282 FE0A CP 10 Is the mouse on the middle floor?
31284 2005 JR NZ,31291 Jump if not
31286 7B LD A,E A=x-coordinate of position in front of mouse
31287 FE54 CP 84 Is mouse at top of stairs leading down to the stage?
31289 2805 JR Z,31296 Jump if so
31291 CD5476 CALL 30292 Check for closed doors and walls
31294 3008 JR NC,31304 Jump unless mouse is heading for one
31296 2E13 LD L,19
31298 7E LD A,(HL)
31299 ED44 NEG Turn the mouse round
31301 77 LD (HL),A
31302 18DD JR 31269
31304 F1 POP AF
31305 32F47F LD (32756),A Restore the doors flags
31308 CDB461 CALL 25012 Update SRB for mouse's current animatory state and location
31311 2E13 LD L,19
31313 CB7E BIT 7,(HL) Is the mouse travelling towards the right?
31315 2806 JR Z,31323 Jump if so
31317 34 INC (HL) Decrease distance left to travel before mouse disappears temporarily
31318 1D DEC E Move mouse one space left
31319 3E2F LD A,47 47: animatory state of mouse travelling left
31321 1804 JR 31327
31323 35 DEC (HL) Decrease distance left to travel before mouse disappears temporarily
31324 1C INC E Move mouse one space right
31325 3EAF LD A,175 175: animatory state of mouse travelling right
31327 C33061 JP 24880 Update SRB for mouse's new animatory state and location
31330 2C INC L L=20
31331 7E LD A,(HL)
31332 A7 AND A
31333 2825 JR Z,31372
31335 35 DEC (HL) Is it time for the mouse to disappear temporarily?
31336 2009 JR NZ,31347 Jump if not
31338 2E01 LD L,1
31340 7E LD A,(HL) A=mouse's x-coordinate
31341 2E16 LD L,22
31343 77 LD (HL),A Store this in byte 22 of the buffer for later retrieval
31344 C3D374 JP 29907 Make the mouse disappear for now
31347 E5 PUSH HL
31348 CDAE79 CALL 31150 Make any girls near this mouse start jumping
31351 E1 POP HL
31352 CD9162 CALL 25233 A=random number
31355 E683 AND 131
31357 C602 ADD A,2
31359 07 RLCA
31360 A7 AND A
31361 1F RRA
31362 3802 JR C,31366
31364 ED44 NEG
31366 2E13 LD L,19
31368 77 LD (HL),A A=new distance for mouse to travel
31369 C31C7A JP 31260
31372 2C INC L L=21
31373 35 DEC (HL)
31374 C0 RET NZ
31375 7C LD A,H A=mouse's character number
31376 FED4 CP 212 Is this a mouse that ERIC has released?
31378 202C JR NZ,31424 Jump if so
31380 3AEB7F LD A,(32747) Inventory flags
31383 CB4F BIT 1,A Has ERIC got the storeroom key?
31385 280B JR Z,31398 Jump if not
31387 3E1D LD A,29 29: animatory state of frog
31389 113B0A LD DE,2619 (E,D)=(59,10) (original location of frog)
31392 CD3061 CALL 24880 Update SRB for frog's new animatory state and location
31395 C35579 JP 31061 Bring the frog into the game
31398 CD9162 CALL 25233 A=random number
31401 E60F AND 15
31403 C605 ADD A,5
31405 77 LD (HL),A Store in byte 21
31406 CD9162 CALL 25233 A=another random number
31409 E603 AND 3
31411 C602 ADD A,2
31413 2D DEC L L=20
31414 77 LD (HL),A Store in byte 20
31415 2E16 LD L,22
31417 5E LD E,(HL) E=x-coordinate of mouse before it disappeared temporarily
31418 2E02 LD L,2
31420 56 LD D,(HL) D=y-coordinate of mouse
31421 C35D7A JP 31325
31424 2E10 LD L,16
31426 35 DEC (HL) Is it time for this mouse to disappear for ever?
31427 2016 JR NZ,31451 Jump if not

It's time for a mouse released by ERIC to die for ever, and return control of the buffer it hijacked to its original owner.
31429 2E1D LD L,29 Set bits 0 and 7 at byte 29: restart table of A&P and act on its first instruction immediately
31431 3681 LD (HL),129
31433 2E0A LD L,10 Remove the address of the controlling routine from bytes 9 and 10 of the buffer
31435 3600 LD (HL),0
31437 2E0F LD L,15 Pick up from byte 15 the animatory state of the character whose buffer the mouse borrowed
31439 7E LD A,(HL)
31440 E6F0 AND 240
31442 2E00 LD L,0
31444 77 LD (HL),A Restore this character's animatory state
31445 2C INC L
31446 3620 LD (HL),32 Set the character's x-coordinate to 32
31448 C39463 JP 25492 Return control of this buffer to the character who normally owns it
31451 3AFF7F LD A,(32767) A=column of play area at far left of screen
31454 FE90 CP 144 Is at least half the girls' skool on-screen?
31456 38E3 JR C,31429 Jump to terminate the mouse if not
31458 2E15 LD L,21
31460 18C0 JR 31398 Otherwise jump back to make the mouse reappear