Prev: 28277 Up: Map Next: 28323
28291: Change Magic Knight's current room if possible
Used by the routines at 28323 and 28346.
Input
A Magic Knight's new x-coordinate upon entering new room
DE Exit that Magic Knight is leaving old room from; either 0 (left exit) or 1 (right exit)
Output
F Zero flag set if Magic Knight can't leave his current room, reset otherwise
28291 PUSH AF Store new x-coordinate for later
28292 XOR A Set Magic Knight's temporary-movement flags to zero (new room, so Magic Knight can move both left and right)...
28293 LD (23463),A ...
28296 LD HL,37022 Point HL to room connectivity data table
28299 LD A,(23701) Load Magic Knight's current room's index into A...
28302 ADD A,A ...double it...
28303 LD C,A ...and load into BC...
28304 LD B,0 ...
28306 ADD HL,BC Add BC as offset to HL
28307 ADD HL,DE Point to left or right exit from current room, as determined by DE
28308 LD A,(HL) Load new room number into A...
28309 CP 255 ...and if this is 255 (i.e. Magic Knight can't leave his current room)...
28311 JR Z,28320 ...set zero flag and exit routine...
28313 LD (23701),A ...else update Magic Knight's current room to be this new room index
28316 POP BC Restore new x-coordinate to B...
28317 LD A,B ...and load back into A
28318 OR A Reset zero flag
28319 RET Return
28320 POP BC Restore AF to BC...
28321 LD A,B ...and load A with contents of B to restore to what it was on entering this routine
28322 RET Return
Prev: 28277 Up: Map Next: 28323