![]() |
Routines |
| Prev: 56190 | Up: Map | Next: 56395 |
| MoveTile_Left | 56293 | LD A,(59229) | Take *Tile_Horizontal_Position and decrease it by one, which adjusts the value for the tile width. Write this value back to *Tile_Horizontal_Coordinate. | |
| 56296 | DEC A | |||
| 56297 | LD (59231),A | |||
|
Set the total of how many spaces the tile will be moving.
|
||||
| 56300 | LD A,(59233) | B=*Tile_SpacesToMove. | ||
| 56303 | LD B,A | |||
|
This is the tile loop, each space moved will decrease this counter by one.
|
||||
| MoveTile_Left_Loop | 56304 | PUSH BC | Stash the number of spaces left to move on the stack. | |
| 56305 | LD A,(59230) | Take *Tile_Vertical_Position and subtract 1 which adjusts the value for the tile height. Write this value back to *Tile_Vertical_Coordinate. | ||
| 56308 | DEC A | |||
| 56309 | LD (59232),A | |||
|
Start moving the tile a single space.
|
||||
| 56312 | LD B,4 | Set a counter in B for the height of the tile in bytes (4 rows). | ||
| MoveTile_Left_RowLoop | 56314 | PUSH BC | Stash the row counter (tile height) on the stack. | |
|
Get the screen buffer address from the co-ordinates.
|
||||
| 56315 | LD A,(59231) | B=*Tile_Horizontal_Coordinate. | ||
| 56318 | LD B,A | |||
| 56319 | LD A,(59232) | C=*Tile_Vertical_Coordinate. | ||
| 56322 | LD C,A | |||
| 56323 | CALL Calculate_ScreenBlockAddress | Call Calculate_ScreenBlockAddress. | ||
| 56326 | LD A,8 | Set the number of bytes in a character block to A. | ||
| 56328 | LD BC,4 | Set a counter in B for the number of bytes in a row (4), and set C to 0 which is used for erasing the left-over tile pixels. | ||
| 56331 | PUSH HL | HL=screen buffer address of the tile. | ||
| 56332 | POP DE | DE=screen buffer address of the tile (using the stack) - 1. | ||
| 56333 | DEC DE | |||
| 56334 | PUSH HL | Stash the current screen buffer address of the tile on the stack. | ||
|
Start moving the current row.
|
||||
| MoveTile_Left_ColumnLoop | 56335 | PUSH HL | Stash the current screen buffer address of the tile on the stack. | |
| 56336 | LDIR | Move 0004 screen data bytes from left to right. | ||
|
This leaves the last byte unprocessed - which should be blank. So, let's erase it.
|
||||
| 56338 | DEC HL | Erase the right-most byte (C contains 0). | ||
| 56339 | LD (HL),C | |||
| 56340 | POP HL | Restore the current screen buffer address from the stack. | ||
| 56341 | INC H | Move down one row. | ||
|
Update the screen buffer address for the next loop iteration.
|
||||
| 56342 | PUSH HL | HL=screen buffer address of the tile. | ||
| 56343 | POP DE | DE=screen buffer address of the tile (using the stack) - 1. | ||
| 56344 | DEC DE | |||
| 56345 | LD BC,4 | Restore BC back to 0004. | ||
| 56348 | DEC A | Decrease the column/ byte counter by one. | ||
| 56349 | JP NZ,MoveTile_Left_ColumnLoop | Jump to MoveTile_Left_ColumnLoop until all four bytes in this row have been moved. | ||
|
Now onto the attribute buffer bytes.
Convert the screen buffer location into a corresponding attribute buffer address.
|
||||
| 56352 | POP HL | Restore the current screen buffer address from the stack. | ||
| 56353 | CALL Calculate_AttributeAddress | Call Calculate_AttributeAddress. | ||
| 56356 | PUSH DE | HL=attribute buffer address of the tile (using the stack). | ||
| 56357 | POP HL | |||
| 56358 | DEC DE | DE=attribute buffer address of the tile - 1. | ||
| 56359 | LD BC,5 | Move 0005 attribute bytes from left to right. | ||
| 56362 | LDIR | |||
|
This leaves the last attribute space unprocessed - which should be blank. So, let's erase it.
|
||||
| 56364 | LD A,71 | A=INK: WHITE, PAPER: BLACK (BRIGHT) . | ||
| 56366 | DEC DE | Erase the right-most attribute block. | ||
| 56367 | LD (DE),A | |||
|
Move to the next attribute row.
|
||||
| 56368 | LD HL,59231 | Increment *Tile_Horizontal_Coordinate by one. | ||
| 56371 | INC (HL) | |||
| 56372 | POP BC | Restore the attribute row counter from the stack. | ||
| 56373 | DJNZ MoveTile_Left_RowLoop | Decrease the attribute row counter by one and loop back to MoveTile_Left_RowLoop until the whole row has been processed. | ||
|
The tile has successfully moved one space!
|
||||
| 56375 | POP BC | Using the number of spaces left to move (from the stack) call Sound_TileMovement. | ||
| 56376 | PUSH BC | |||
| 56377 | CALL Sound_TileMovement | |||
| 56380 | LD A,(59229) | Take *Tile_Horizontal_Position and decrease it by one, which adjusts the value for the tile width. Write it back to *Tile_Horizontal_Coordinate. | ||
| 56383 | DEC A | |||
| 56384 | LD (59231),A | |||
| 56387 | LD HL,59230 | Decrease *Tile_Vertical_Position by one. | ||
| 56390 | DEC (HL) | |||
| 56391 | POP BC | Restore the number of spaces left to move from the stack. | ||
| 56392 | DJNZ MoveTile_Left_Loop | Decrease the number of spaces counter by one and loop back to MoveTile_Left_Loop until the tile is in the destination space. | ||
| 56394 | RET | Return. | ||
| Prev: 56190 | Up: Map | Next: 56395 |