![]() |
Routines |
| Prev: 24283 | Up: Map | Next: 24481 |
|
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 1).
|
||||||||||
|
Load and advance the current column/row drawing position.
|
||||||||||
| Draw_Room_Tile | 24373 | LD BC,(24505) | Load the current drawing position from *RoomDrawPosition into BC. | |||||||
| 24377 | INC C | Increment the column in C. | ||||||||
| 24378 | EX AF,AF' | Stash the tile character in shadow AF. | ||||||||
|
If the column has reached 32 (past the right edge), wrap to the start of the next row.
|
||||||||||
| 24379 | BIT 5,C | Jump to Draw_Room_Tile_Next_Row if bit 5 of C is set (column has wrapped). | ||||||||
| 24381 | JR NZ,Draw_Room_Tile_Next_Row | |||||||||
| 24383 | JR Draw_Room_Tile_Store_Position | Jump to Draw_Room_Tile_Store_Position. | ||||||||
| Draw_Room_Tile_Next_Row | 24385 | INC B | Increment the row in B. | |||||||
| 24386 | LD C,0 | Reset the column to 0. | ||||||||
| Draw_Room_Tile_Store_Position | 24388 | LD (24505),BC | Write the updated drawing position back to *RoomDrawPosition. | |||||||
| 24392 | BIT 0,D | Return if this is a position-advance-only call (bit 0 of D is set). | ||||||||
| 24394 | 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.
|
||||||||||
| 24395 | LD L,C | Copy the column to L. | ||||||||
| 24396 | LD A,B | Mask B to get the row within the current screen third. | ||||||||
| 24397 | AND %00000111 | |||||||||
| 24399 | RRCA | Rotate right three positions to move into bits 5-7. | ||||||||
| 24400 | RRCA | |||||||||
| 24401 | RRCA | |||||||||
| 24402 | OR L | Merge in the column bits from L. | ||||||||
| 24403 | LD L,A | Store the combined low byte in L. | ||||||||
| 24404 | LD A,B | Mask B to get the screen third index. | ||||||||
| 24405 | AND %00011000 | |||||||||
| 24407 | OR %11000000 | Set bits 6-7 for the room buffer base at RoomBuffer. | ||||||||
| 24409 | LD H,A | Store the high byte in H. | ||||||||
|
Look up the tile graphic data from the active tile set and copy all 8 pixel rows to the room buffer.
|
||||||||||
| 24410 | PUSH HL | Stash the room buffer address on the stack. | ||||||||
| 24411 | LD DE,(24513) | Load the active tile set base address from *PointerActiveTileSet into DE. | ||||||||
| 24415 | EX AF,AF' | Retrieve the tile character from shadow AF. | ||||||||
| 24416 | SUB 8 | Subtract 8 to convert from the tile character to a zero-based tile index. | ||||||||
| 24418 | LD L,A | Transfer the tile index to HL. | ||||||||
| 24419 | LD H,0 | |||||||||
| 24421 | ADD HL,HL | Multiply by 8 (bytes per tile graphic). | ||||||||
| 24422 | ADD HL,HL | |||||||||
| 24423 | ADD HL,HL | |||||||||
| 24424 | ADD HL,DE | Add the tile set base address to get the graphic data pointer. | ||||||||
| 24425 | EX DE,HL | Exchange so DE points to the tile graphic data. | ||||||||
| 24426 | POP HL | Restore the room buffer address from the stack. | ||||||||
| 24427 | LD B,8 | Set the pixel row counter to 8 in B. | ||||||||
| Draw_Room_Tile_Copy_Loop | 24429 | LD A,(DE) | Copy one byte of tile graphic data to the room buffer. | |||||||
| 24430 | LD (HL),A | |||||||||
| 24431 | INC DE | Advance the tile graphic data pointer. | ||||||||
| 24432 | INC H | Move down one pixel row in the room buffer. | ||||||||
| 24433 | DJNZ Draw_Room_Tile_Copy_Loop | Decrease the row counter and loop back to Draw_Room_Tile_Copy_Loop until all 8 rows are drawn. | ||||||||
| 24435 | 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 | 24436 | LD A,(24489) | Jump to Calculate_Room_Object_Base if *EggDropFlag (egg drop flag) is zero. | |||||||
| 24439 | OR A | |||||||||
| 24440 | JR Z,Calculate_Room_Object_Base | |||||||||
| 24442 | XOR A | Write 0 to *EggDropFlag (cancel any active egg drop). | ||||||||
| 24443 | LD (24489),A | |||||||||
| 24446 | NOP | Two NOPs (unused?) | ||||||||
| 24447 | NOP | |||||||||
| 24448 | LD (56035),A | Write 0 to *Egg_Frame_ID (clear the egg sprite frame). | ||||||||
|
Calculate the base address for this room's object data. Each room has 32 bytes of object data stored sequentially from Room_Object_Data, so multiply the zero-indexed room number by 32 and add the base.
|
||||||||||
| Calculate_Room_Object_Base | 24451 | LD A,(24517) | Fetch the current room number from *CurrentRoom. | |||||||
| 24454 | DEC A | Decrement to make it zero-indexed. | ||||||||
| 24455 | LD DE,56990 | Point DE at Room_Object_Data (room object data base). | ||||||||
| 24458 | LD L,A | Transfer the room index to HL. | ||||||||
| 24459 | LD H,0 | |||||||||
| 24461 | ADD HL,HL | Multiply by 32 to calculate the offset for this room. | ||||||||
| 24462 | ADD HL,HL | |||||||||
| 24463 | ADD HL,HL | |||||||||
| 24464 | ADD HL,HL | |||||||||
| 24465 | ADD HL,HL | |||||||||
| 24466 | ADD HL,DE | Add the base address. | ||||||||
| 24467 | LD (24501),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.
|
||||||||||
| 24470 | EI | Enable interrupts. | ||||||||
| 24471 | HALT | Halt (wait for the next interrupt). | ||||||||
| 24472 | DI | Disable interrupts. | ||||||||
|
Draw the room buffer to the screen.
|
||||||||||
| 24473 | LD B,22 | Set the row counter to 22 in B. | ||||||||
| 24475 | LD HL,49152 | Point HL at RoomBuffer (room buffer). | ||||||||
| 24478 | JP Draw_Room_Rows_Loop | Jump to Draw_Room_Rows_Loop. | ||||||||
| Prev: 24283 | Up: Map | Next: 24481 |