Prev: 29468 Up: Map Next: 29514
29482: Change Magic Knight's current room if possible
Used by the routines at 29514 and 29546.
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
29482 PUSH AF Store new x-coordinate for later
29483 XOR A Set Magic Knight's temporary-movement flags to zero (new room, so Magic Knight can move both left and right)...
29484 LD (23410),A ...
29487 LD HL,41711 Point HL to room connectivity data table
29490 LD A,(65529) Load Magic Knight's current room's index into A...
29493 ADD A,A ...double it...
29494 LD C,A ...and load into BC...
29495 LD B,0 ...
29497 ADD HL,BC Add BC as offset to HL
29498 ADD HL,DE Point to left or right exit from current room, as determined by DE
29499 LD A,(HL) Load new room number into A...
29500 CP 255 ...and if this is 255 (i.e. Magic Knight can't leave his current room)...
29502 JR Z,29511 ...set zero flag and exit routine...
29504 LD (65529),A ...else update Magic Knight's current room to be this new room index
29507 POP BC Restore new x-coordinate to B...
29508 LD A,B ...and load back into A
29509 OR A Reset zero flag
29510 RET Return
29511 POP BC Restore AF to BC...
29512 LD A,B ...and load A with contents of B to restore to what it was on entering this routine
29513 RET Return
Prev: 29468 Up: Map Next: 29514