Prev: 9D28 Up: Map Next: 9DD6
9DA0: Draw Special Room Frame
Used by the routine at Draw_Room.
Draws the frame of a special room (one with a room y below 10).
In these rooms the first byte of the world map entry is not a set of flags (see Draw_Room) but four codes of three bits each, which overlap by one bit. Each code selects one of eight routines from a table of eight addresses (see Special_Room_Frame_Tables) and each routine draws the pictures for one part of the frame. The codes are:
Bits Part of the frame Table
0 to 2 Top right Special_Room_Frame_Tables
2 to 4 Bottom right Special_Room_Frame_Tables_Bottom_Right
4 to 6 Bottom left Special_Room_Frame_Tables_Bottom_Left
6, 7 and 0 Top left Special_Room_Frame_Tables_Top_Left
The first three routines run with the shadow registers, which keeps DE safe, and the last runs with the main registers.
Input
E First byte of the world map entry
Draw_Special_Room_Frame 9DA0 LD A,E Fetch the first byte of the world map entry.
9DA1 EXX Switch to the shadow registers.
9DA2 AND %00000111 Keep bits 0 to 2 (the code for the top right).
9DA4 LD HL,$9DD6 Point at the table for the top right (Special_Room_Frame_Tables).
9DA7 CALL Draw_Frame_Part Draw the top right of the frame.
9DAA EXX Switch to the main registers.
9DAB LD A,E Fetch the first byte of the world map entry.
9DAC EXX Switch to the shadow registers.
9DAD RRA Move bits 2 to 4 down to bits 0 to 2.
9DAE RRA
9DAF LD HL,$9DE6 Point at the table for the bottom right (Special_Room_Frame_Tables_Bottom_Right).
9DB2 CALL Draw_Frame_Part Draw the bottom right of the frame.
9DB5 EXX Switch to the main registers.
9DB6 LD A,E Fetch the first byte of the world map entry.
9DB7 EXX Switch to the shadow registers.
9DB8 RRA Move bits 4 to 6 down to bits 0 to 2.
9DB9 RRA
9DBA RRA
9DBB RRA
9DBC LD HL,$9DF6 Point at the table for the bottom left (Special_Room_Frame_Tables_Bottom_Left).
9DBF CALL Draw_Frame_Part Draw the bottom left of the frame.
9DC2 EXX Switch to the main registers.
9DC3 LD A,E Fetch the first byte of the world map entry.
9DC4 RLCA Rotate bits 6, 7 and 0 into bits 0 to 2.
9DC5 RLCA
9DC6 LD HL,$9E06 Point at the table for the top left (Special_Room_Frame_Tables_Top_Left).
Run the routine that the code selects from the table. The routine returns to the caller of this one.
Draw_Frame_Part 9DC9 AND %00000111 Keep bits 0 to 2 (the code).
9DCB LD E,A Make the code into an offset in DE.
9DCC LD D,$00
9DCE ADD HL,DE Add the code to the address of the table.
9DCF ADD HL,DE Add the code to the address of the table again, as the entries are two bytes long.
9DD0 LD A,(HL) Fetch the low byte of the address of the routine.
9DD1 INC HL Move on to the high byte.
9DD2 LD H,(HL) Fetch the high byte of the address of the routine.
9DD3 LD L,A Copy the low byte into L.
9DD4 JP (HL) Jump to the routine.
Several codes in the tables lead here, so nothing is drawn.
Draw_Nothing 9DD5 RET Return.
Prev: 9D28 Up: Map Next: 9DD6