![]() |
Routines |
| Prev: 5EDB | Up: Map | Next: 5FA1 |
|
Draws a single tile to the room buffer at the current drawing position stored in *RoomDrawPosition. The position is advanced after each call. If bit 0 of D is set, the position is advanced but no tile is drawn (used for skip tiles in command 01).
|
||||||||||
|
Load and advance the current column/row drawing position.
|
||||||||||
| Draw_Room_Tile | 5F35 | LD BC,($5FB9) | Load the current drawing position from *RoomDrawPosition into BC. | |||||||
| 5F39 | INC C | Increment the column in C. | ||||||||
| 5F3A | EX AF,AF' | Stash the tile character in shadow AF. | ||||||||
|
If the column has reached 20 (past the right edge), wrap to the start of the next row.
|
||||||||||
| 5F3B | BIT 5,C | Jump to Draw_Room_Tile_Next_Row if bit 5 of C is set (column has wrapped). | ||||||||
| 5F3D | JR NZ,Draw_Room_Tile_Next_Row | |||||||||
| 5F3F | JR Draw_Room_Tile_Store_Position | Jump to Draw_Room_Tile_Store_Position. | ||||||||
| Draw_Room_Tile_Next_Row | 5F41 | INC B | Increment the row in B. | |||||||
| 5F42 | LD C,$00 | Reset the column to 00. | ||||||||
| Draw_Room_Tile_Store_Position | 5F44 | LD ($5FB9),BC | Write the updated drawing position back to *RoomDrawPosition. | |||||||
| 5F48 | BIT 0,D | Return if this is a position-advance-only call (bit 0 of D is set). | ||||||||
| 5F4A | RET NZ | |||||||||
|
Calculate the room buffer address from the column (C) and row (B). Converts the character cell coordinates into a pixel address within the room buffer at RoomBuffer.
|
||||||||||
| 5F4B | LD L,C | Copy the column to L. | ||||||||
| 5F4C | LD A,B | Mask B to get the row within the current screen third. | ||||||||
| 5F4D | AND %00000111 | |||||||||
| 5F4F | RRCA | Rotate right three positions to move into bits 5-7. | ||||||||
| 5F50 | RRCA | |||||||||
| 5F51 | RRCA | |||||||||
| 5F52 | OR L | Merge in the column bits from L. | ||||||||
| 5F53 | LD L,A | Store the combined low byte in L. | ||||||||
| 5F54 | LD A,B | Mask B to get the screen third index. | ||||||||
| 5F55 | AND %00011000 | |||||||||
| 5F57 | OR %11000000 | Set bits 6-7 for the room buffer base at RoomBuffer. | ||||||||
| 5F59 | LD H,A | Store the high byte in H. | ||||||||
|
Look up the tile graphic data from the active tile set and copy all 08 pixel rows to the room buffer.
|
||||||||||
| 5F5A | PUSH HL | Stash the room buffer address on the stack. | ||||||||
| 5F5B | LD DE,($5FC1) | Load the active tile set base address from *PointerActiveTileSet into DE. | ||||||||
| 5F5F | EX AF,AF' | Retrieve the tile character from shadow AF. | ||||||||
| 5F60 | SUB $08 | Subtract 08 to convert from the tile character to a zero-based tile index. | ||||||||
| 5F62 | LD L,A | Transfer the tile index to HL. | ||||||||
| 5F63 | LD H,$00 | |||||||||
| 5F65 | ADD HL,HL | Multiply by 08 (bytes per tile graphic). | ||||||||
| 5F66 | ADD HL,HL | |||||||||
| 5F67 | ADD HL,HL | |||||||||
| 5F68 | ADD HL,DE | Add the tile set base address to get the graphic data pointer. | ||||||||
| 5F69 | EX DE,HL | Exchange so DE points to the tile graphic data. | ||||||||
| 5F6A | POP HL | Restore the room buffer address from the stack. | ||||||||
| 5F6B | LD B,$08 | Set the pixel row counter to 08 in B. | ||||||||
| Draw_Room_Tile_Copy_Loop | 5F6D | LD A,(DE) | Copy one byte of tile graphic data to the room buffer. | |||||||
| 5F6E | LD (HL),A | |||||||||
| 5F6F | INC DE | Advance the tile graphic data pointer. | ||||||||
| 5F70 | INC H | Move down one pixel row in the room buffer. | ||||||||
| 5F71 | DJNZ Draw_Room_Tile_Copy_Loop | Decrease the row counter and loop back to Draw_Room_Tile_Copy_Loop until all 08 rows are drawn. | ||||||||
| 5F73 | RET | Return. | ||||||||
|
This entry point is used by the routine at Command03_FillAttributes.
End of room attribute data. Finalises the room setup by resetting game flags and calculating the room's object data base address.
|
||||||||||
| Room_Attributes_End | 5F74 | LD A,($5FA9) | Jump to Calculate_Room_Object_Base if *EggDropFlag (egg drop flag) is zero. | |||||||
| 5F77 | OR A | |||||||||
| 5F78 | JR Z,Calculate_Room_Object_Base | |||||||||
| 5F7A | XOR A | Write 00 to *EggDropFlag (cancel any active egg drop). | ||||||||
| 5F7B | LD ($5FA9),A | |||||||||
| 5F7E | NOP | Two NOPs (unused?) | ||||||||
| 5F7F | NOP | |||||||||
| 5F80 | LD ($DAE3),A | Write 00 to *Egg_Frame_ID (clear the egg sprite frame). | ||||||||
|
Calculate the base address for this room's object data. Each room has 20 bytes of object data stored sequentially from Room_Object_Data, so multiply the zero-indexed room number by 20 and add the base.
|
||||||||||
| Calculate_Room_Object_Base | 5F83 | LD A,($5FC5) | Fetch the current room number from *CurrentRoom. | |||||||
| 5F86 | DEC A | Decrement to make it zero-indexed. | ||||||||
| 5F87 | LD DE,$DE9E | Point DE at Room_Object_Data (room object data base). | ||||||||
| 5F8A | LD L,A | Transfer the room index to HL. | ||||||||
| 5F8B | LD H,$00 | |||||||||
| 5F8D | ADD HL,HL | Multiply by 20 to calculate the offset for this room. | ||||||||
| 5F8E | ADD HL,HL | |||||||||
| 5F8F | ADD HL,HL | |||||||||
| 5F90 | ADD HL,HL | |||||||||
| 5F91 | ADD HL,HL | |||||||||
| 5F92 | ADD HL,DE | Add the base address. | ||||||||
| 5F93 | LD ($5FB5),HL | Write the result to *Room_Object_Data_Pointer (room object data pointer for this room). | ||||||||
|
Wait for the next interrupt frame, then transfer the completed room buffer to the display.
|
||||||||||
| 5F96 | EI | Enable interrupts. | ||||||||
| 5F97 | HALT | Halt (wait for the next interrupt). | ||||||||
| 5F98 | DI | Disable interrupts. | ||||||||
|
Draw the room buffer to the screen.
|
||||||||||
| 5F99 | LD B,$16 | Set the row counter to 16 in B. | ||||||||
| 5F9B | LD HL,$C000 | Point HL at RoomBuffer (room buffer). | ||||||||
| 5F9E | JP Draw_Room_Rows_Loop | Jump to Draw_Room_Rows_Loop. | ||||||||
| Prev: 5EDB | Up: Map | Next: 5FA1 |