Routines |
Prev: DBE5 | Up: Map | Next: DCC2 |
MoveTile_Down | DC4B | LD A,($E75E) | Take *Tile_Vertical_Position and decrease it by one, which adjusts the value for the tile height. Write this value back to *Tile_Vertical_Coordinate. | |
DC4E | DEC A | |||
DC4F | LD ($E760),A | |||
Set the total of how many spaces the tile will be moving.
|
||||
DC52 | LD A,($E761) | B=*Tile_SpacesToMove. | ||
DC55 | LD B,A | |||
This is the tile loop, each space moved will decrease this counter by one.
|
||||
MoveTile_Down_Loop | DC56 | PUSH BC | Stash the number of spaces left to move on the stack. | |
DC57 | LD A,($E75D) | Take *Tile_Horizontal_Position and add 02 which adjusts the value for the tile height. Write this value back to *Tile_Horizontal_Coordinate. | ||
DC5A | ADD A,$02 | |||
DC5C | LD ($E75F),A | |||
Start moving the tile a single space.
|
||||
DC5F | LD B,$04 | Set a counter in B for the height of the tile in bytes (04 rows). | ||
MoveTile_Down_RowLoop | DC61 | PUSH BC | Stash the row counter (tile height) on the stack. | |
Get the screen buffer address from the co-ordinates.
|
||||
DC62 | LD A,($E75F) | B=*Tile_Horizontal_Coordinate. | ||
DC65 | LD B,A | |||
DC66 | LD A,($E760) | C=*Tile_Vertical_Coordinate. | ||
DC69 | LD C,A | |||
DC6A | CALL Calculate_ScreenBlockAddress | Call Calculate_ScreenBlockAddress. | ||
DC6D | PUSH HL | Stash the destination screen buffer address on the stack. | ||
DC6E | INC B | Call Calculate_ScreenBlockAddress but increment the position by one. This allows us to fetch the screen buffer address of the next position. DE=screen buffer address of the tile + 01. | ||
DC6F | CALL Calculate_ScreenBlockAddress | |||
DC72 | PUSH HL | |||
DC73 | POP DE | |||
DC74 | POP HL | HL=screen buffer address of the tile. | ||
DC75 | LD A,$08 | Set the number of bytes in a character block to A. | ||
DC77 | LD BC,$0004 | Set a counter in B for the number of bytes in a row (04), and set C to 00 which is used for erasing the left-over tile pixels. | ||
DC7A | PUSH HL | Stash the current screen buffer address of the tile on the stack. | ||
Start moving the current row.
|
||||
MoveTile_Down_ColumnLoop | DC7B | PUSH HL | Stash the current screen buffer address of the tile on the stack. | |
DC7C | PUSH DE | Stash the current screen buffer address of the tile on the stack. | ||
DC7D | LDIR | LDIR. | ||
DC7F | DEC HL | Decrease HL by one. | ||
DC80 | PUSH HL | Stash HL on the stack. | ||
DC81 | LD (HL),C | Write C to *HL. | ||
DC82 | POP DE | Restore DE from the stack. | ||
DC83 | DEC DE | Decrease DE by one. | ||
DC84 | LD BC,$0003 | BC=0003. | ||
DC87 | LDDR | LDDR. | ||
DC89 | POP DE | Restore DE and HL from the stack. | ||
DC8A | POP HL | |||
DC8B | INC D | Move to the next pixel row in the destination address. | ||
DC8C | INC H | Move to the next pixel row in the source address. | ||
DC8D | LD BC,$0004 | BC=0004. | ||
DC90 | DEC A | Decrease the pixel row counter by one. | ||
DC91 | JP NZ,MoveTile_Down_ColumnLoop | Jump back to MoveTile_Down_ColumnLoop until all pixels in the row have been moved. | ||
DC94 | POP HL | Restore HL from the stack. | ||
DC95 | CALL Calculate_AttributeAddress | Call Calculate_AttributeAddress. | ||
Move DE down one attribute row.
|
||||
DC98 | LD HL,$0020 | DE+=0020. | ||
DC9B | ADD HL,DE | |||
DC9C | EX DE,HL | |||
DC9D | LD BC,$0004 | Copy 0004 attribute bytes from . | ||
DCA0 | LDIR | |||
DCA2 | LD BC,$0003 | BC=0003. | ||
DCA5 | LD A,$47 | A=INK: WHITE, PAPER: BLACK (BRIGHT) . | ||
DCA7 | DEC HL | Decrease HL by one. | ||
DCA8 | LD (HL),A | Write A to *HL. | ||
DCA9 | PUSH HL | Stash HL on the stack. | ||
DCAA | POP DE | Restore DE from the stack. | ||
DCAB | DEC DE | Decrease DE by one. | ||
DCAC | LDDR | LDDR. | ||
DCAE | LD HL,$E75F | Decrease *Tile_Horizontal_Coordinate by one. | ||
DCB1 | DEC (HL) | |||
DCB2 | POP BC | Restore the pixel row counter from the stack. | ||
DCB3 | DJNZ MoveTile_Down_RowLoop | Decrease the pixel row counter by one and loop back to MoveTile_Down_RowLoop until counter is zero. | ||
The tile has successfully moved one space!
|
||||
DCB5 | POP BC | Using the number of spaces left to move (from the stack) call Sound_TileMovement. | ||
DCB6 | PUSH BC | |||
DCB7 | CALL Sound_TileMovement | |||
DCBA | LD HL,$E75D | Increment *Tile_Horizontal_Position by one. | ||
DCBD | INC (HL) | |||
DCBE | POP BC | Restore the number of spaces left to move from the stack. | ||
DCBF | DJNZ MoveTile_Down_Loop | Decrease the number of spaces counter by one and loop back to MoveTile_Down_Loop until the tile is in the destination space. | ||
DCC1 | RET | Return. |
Prev: DBE5 | Up: Map | Next: DCC2 |