Routines

30292: Check for walls, closed doors and closed windows in character's path


Used by routines at 30380, 30804 and 31254. Returns with the carry flag set if there is a wall, closed door or closed window in the character's path.

DE Coordinates of point in front of character
H Character number (183-214)

30292 E5 PUSH HL
30293 21F47F LD HL,32756 Doors flags
30296 7B LD A,E
30297 FEBE CP 190 190: Far wall of girls' skool
30299 3022 JR NC,30335 Jump if the character's facing this
30301 7A LD A,D A=character's y-coordinate
30302 FE05 CP 5 Is the character on the top floor (or just below it)?
30304 3020 JR NC,30338 Jump if not
30306 7B LD A,E
30307 FE9F CP 159 159: Left wall of girls' skool
30309 2818 JR Z,30335 Jump if the character's facing this
30311 1601 LD D,1 Set bit 0: left study door
30313 FE48 CP 72 72: Left study door
30315 280E JR Z,30331 Jump if the character's facing this
30317 14 INC D Set bit 1: right study door
30318 FE54 CP 84 84: Right study door
30320 2809 JR Z,30331 Jump if the character's facing this
30322 1640 LD D,64 Set bit 6: top floor window
30324 FE5C CP 92 92: Top floor window in boys' skool
30326 2803 JR Z,30331 Jump if the character's facing this
30328 A7 AND A Clear carry: no obstacles ahead
30329 E1 POP HL
30330 C9 RET Return with the carry flag reset
30331 7A LD A,D Bit set in A corresponds to door/window on top floor
30332 A6 AND (HL) Is this door/window open?
30333 20FA JR NZ,30329 Jump if so
30335 37 SCF Set carry: no admittance
30336 E1 POP HL
30337 C9 RET Return with the carry flag set
30338 FE0C CP 12
30340 7B LD A,E
30341 3017 JR NC,30366 Jump if the character's on the bottom floor (or just above it)
30343 FE9F CP 159 159: Left wall of girls' skool
30345 28F4 JR Z,30335 Jump if the character's facing this
30347 FE3E CP 62 62: Far wall of science lab storeroom
30349 28F0 JR Z,30335 Jump if character's facing this
30351 FE35 CP 53 53: Science lab storeroom door
30353 1604 LD D,4 Set bit 2: science lab storeroom door
30355 28E6 JR Z,30331 Jump if the character's facing this
30357 1680 LD D,128 Set bit 7: middle floor window in boys' skool
30359 FE5E CP 94 94: Middle floor window in boys' skool
30361 28E0 JR Z,30331 Jump if character's facing this
30363 A7 AND A Clear carry: no obstacles ahead
30364 E1 POP HL
30365 C9 RET
30366 1608 LD D,8 Set bit 3: boys' skool door
30368 FE5E CP 94 94: Boys' skool door
30370 28D7 JR Z,30331 Jump if character's facing this
30372 1610 LD D,16 Set bit 4: skool gate
30374 FE85 CP 133 133: Skool gate
30376 28D1 JR Z,30331 Jump if the character's facing this
30378 18EF JR 30363 Otherwise it's all clear