![]() |
Routines |
| Prev: BBDD | Up: Map | Next: BC5A |
|
Draws the graphics of a room. The room data is a list of graphics, each with the address of the graphic and the position to draw it at. Each graphic is drawn with DrawRoom_Process.
|
|||||||||||||||||
The room data is held as:
Fetch the room data graphic address.
|
|||||||||||||||||
| DrawRoom | BBF7 | LD E,(HL) | Fetch the address of the graphic. | ||||||||||||||
| BBF8 | INC HL | ||||||||||||||||
| BBF9 | LD D,(HL) | ||||||||||||||||
| BBFA | LD A,E | Return if the end of the room data has been reached (the address is zero). | |||||||||||||||
| BBFB | OR D | ||||||||||||||||
| BBFC | RET Z | ||||||||||||||||
|
Fetch the X/ Y position data.
|
|||||||||||||||||
| BBFD | INC HL | Move onto the X position of the graphic. | |||||||||||||||
| BBFE | LD C,(HL) | Fetch the X position into C and the Y position into B. | |||||||||||||||
| BBFF | INC HL | ||||||||||||||||
| BC00 | LD B,(HL) | ||||||||||||||||
| BC01 | INC HL | Move onto the next graphic in the room data. | |||||||||||||||
| BC02 | PUSH HL | Stash the pointer to the room data on the stack. | |||||||||||||||
| BC03 | LD H,B | Copy the position into HL. | |||||||||||||||
| BC04 | LD L,C | ||||||||||||||||
| BC05 | CALL DrawRoom_Process | Draw the graphic. | |||||||||||||||
| BC08 | POP HL | Restore the pointer to the room data from the stack. | |||||||||||||||
| BC09 | JR DrawRoom | Jump back to DrawRoom to draw the next graphic. | |||||||||||||||
|
This entry point is used by the routine at ShowAmulet.
At the point of processing; HL contains X/ Y position data, DE contains the room data graphic address (and BC is throwaway).
|
|||||||||||||||||
| DrawRoom_Process | BC0B | PUSH HL | Stash the position of the graphic on the stack. | ||||||||||||||
| BC0C | CALL ScreenAddress | Convert the position into a screen address. | |||||||||||||||
| BC0F | LD A,(DE) | Fetch the height of the graphic into C. | |||||||||||||||
| BC10 | LD C,A | ||||||||||||||||
| BC11 | INC DE | Increment DE by one. | |||||||||||||||
| BC12 | LD A,(DE) | Fetch the width of the graphic into B. | |||||||||||||||
| BC13 | LD B,A | ||||||||||||||||
| BC14 | INC DE | Increment DE by one. | |||||||||||||||
| DrawRoom_Row_Loop | BC15 | PUSH BC | Stash the counters on the stack. | ||||||||||||||
| DrawRoom_Write_Row | BC16 | LD A,(DE) | Fetch a byte of the graphic. | ||||||||||||||
| BC17 | CPL | Invert the bits. | |||||||||||||||
| BC18 | LD (HL),A | Draw the byte on the screen. | |||||||||||||||
| BC19 | INC L | Move onto the next column. | |||||||||||||||
| BC1A | INC DE | Move onto the next byte of the graphic. | |||||||||||||||
| BC1B | DJNZ DrawRoom_Write_Row | Decrease the width counter by one and loop back to DrawRoom_Write_Row until counter is zero. | |||||||||||||||
| BC1D | POP BC | Restore the counters from the stack. | |||||||||||||||
| BC1E | LD A,L | Move back to the first column. | |||||||||||||||
| BC1F | SUB B | ||||||||||||||||
| BC20 | LD L,A | ||||||||||||||||
| BC21 | CALL ScreenPosition1PixelBelow | Move down to the next pixel line. | |||||||||||||||
| BC24 | DEC C | Decrease the height counter by one and loop back to DrawRoom_Row_Loop until counter is zero. | |||||||||||||||
| BC25 | JR NZ,DrawRoom_Row_Loop | ||||||||||||||||
| BC27 | POP HL | Restore the position of the graphic from the stack. | |||||||||||||||
| BC28 | CALL AttributeAddress | Convert the position into an attribute address. | |||||||||||||||
|
Now set the attributes.
|
|||||||||||||||||
| BC2B | LD A,(DE) | Fetch the height of the attribute data into C. | |||||||||||||||
| BC2C | INC DE | ||||||||||||||||
| BC2D | LD C,A | ||||||||||||||||
| BC2E | LD A,(DE) | Fetch the width of the attribute data into B. | |||||||||||||||
| BC2F | INC DE | ||||||||||||||||
| BC30 | LD B,A | ||||||||||||||||
| BC31 | LD A,($96B2) | Jump to DrawRoom_Second_Attributes if AttributeSetFlag is not zero, to use the second set of attributes. | |||||||||||||||
| BC34 | AND A | ||||||||||||||||
| BC35 | JR NZ,DrawRoom_Second_Attributes | ||||||||||||||||
| DrawRoom_Attribute_Row_Loop | BC37 | PUSH BC | Stash the counters on the stack. | ||||||||||||||
| BC38 | PUSH HL | Stash the start of the row on the stack. | |||||||||||||||
| DrawRoom_Attribute_Loop | BC39 | LD A,(DE) | Fetch an attribute. | ||||||||||||||
| BC3A | INC DE | Move onto the next attribute. | |||||||||||||||
| BC3B | LD (HL),A | Set the attribute on the screen. | |||||||||||||||
| BC3C | INC L | Move onto the next column. | |||||||||||||||
| BC3D | DJNZ DrawRoom_Attribute_Loop | Decrease the width counter by one and loop back to DrawRoom_Attribute_Loop until counter is zero. | |||||||||||||||
| BC3F | POP HL | Restore the start of the row from the stack. | |||||||||||||||
| BC40 | LD BC,$0020 | BC=0020. | |||||||||||||||
| BC43 | ADD HL,BC | Move down one row of attributes. | |||||||||||||||
| BC44 | POP BC | Restore the counters from the stack. | |||||||||||||||
| BC45 | DEC C | Decrease the row counter by one and loop back to DrawRoom_Attribute_Row_Loop until all of the rows of attributes have been set. | |||||||||||||||
| BC46 | JR NZ,DrawRoom_Attribute_Row_Loop | ||||||||||||||||
| BC48 | RET | Return. | |||||||||||||||
|
Use the second set of attributes, by skipping over the first set.
|
|||||||||||||||||
| DrawRoom_Second_Attributes | BC49 | PUSH BC | Stash the counters on the stack. | ||||||||||||||
| BC4A | XOR A | Start the total at zero. | |||||||||||||||
| BC4B | LD ($96B2),A | Clear AttributeSetFlag, so the first set of attributes is used next time. | |||||||||||||||
| DrawRoom_Skip_Attributes | BC4E | ADD A,C | Add the height to A, once for each column, to find the size of the first set. | ||||||||||||||
| BC4F | DJNZ DrawRoom_Skip_Attributes | Decrease B by one and loop back to DrawRoom_Skip_Attributes until it is zero. | |||||||||||||||
| BC51 | LD C,A | C=A. | |||||||||||||||
| BC52 | LD B,$00 | B=00. | |||||||||||||||
| BC54 | EX DE,HL | Swap DE and HL. | |||||||||||||||
| BC55 | ADD HL,BC | Move the attribute data pointer past the first set. | |||||||||||||||
| BC56 | EX DE,HL | Swap DE and HL back. | |||||||||||||||
| BC57 | POP BC | Restore the counters from the stack. | |||||||||||||||
| BC58 | JR DrawRoom_Attribute_Row_Loop | Jump to DrawRoom_Attribute_Row_Loop. | |||||||||||||||
| Prev: BBDD | Up: Map | Next: BC5A |