Prev: 93E3 Up: Map Next: 9443
9421: A door the serf can use
Three doors, three entry points, one test. Each subtracts a character's first sprite from the player's current one and asks whether what is left is under $10 -- which is exactly "is the player this character", since each character owns sixteen consecutive sprite codes. DOOR_SERF takes $21 for the serf, DOOR_WIZARD takes $11 for the wizard and DOOR_KNIGHT takes 1 for the knight. The records that reach them are types $1A (a barrel), $17 (a bookcase) and $10 (a grandfather clock), drawn as graphics $BB, $B8 and $B1 -- handler-table entries $BC, $B9 and $B2.
Pass the test and the thing behaves as an ordinary door, through the same DOOR that every other door goes through. Fail it and control goes to DRAW_DOOR instead, which draws it and nothing more: the door is there, visible, and will not open.
Input
IX The door
DOOR_SERF 9421 LD A,($EA90) The serf's sprites start at $21.
9424 SUB $21
9426 JR DOOR_SERF_0
DOOR_WIZARD 9428 LD A,($EA90) The wizard's at $11.
942B SUB $11
942D JR DOOR_SERF_0
DOOR_KNIGHT 942F LD A,($EA90) The knight's at 1.
9432 DEC A
DOOR_SERF_0 9433 CP $10 Sixteen codes per character, so anything under $10 is a match.
9435 JR NC,DOOR_SERF_1
9437 CALL OPEN_DOOR The right character: let them through.
943A JP DOOR
DOOR_SERF_1 943D CALL SHUT_DOOR The wrong one: draw it and leave it shut.
9440 JP DRAW_DOOR
Prev: 93E3 Up: Map Next: 9443