Routines |
Prev: DB2E | Up: Map | Next: DBE5 |
Get the current tile horizontal co-ordinate.
|
||||
MoveTile_Right | DB7E | LD A,($E75D) | 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. | |
DB81 | DEC A | |||
DB82 | LD ($E75F),A | |||
Set the total of how many spaces the tile will be moving.
|
||||
DB85 | LD A,($E761) | B=*Tile_SpacesToMove. | ||
DB88 | LD B,A | |||
This is the tile loop, each space moved will decrease this counter by one.
|
||||
MoveTile_Right_Loop | DB89 | PUSH BC | Stash the number of spaces left to move on the stack. | |
Get the current tile vertical co-ordinate.
|
||||
DB8A | LD A,($E75E) | Take *Tile_Vertical_Position and add 02 which adjusts the value for the tile height. Write this value back to *Tile_Vertical_Coordinate. | ||
DB8D | ADD A,$02 | |||
DB8F | LD ($E760),A | |||
Start moving the tile a single space.
|
||||
DB92 | LD B,$04 | Set a counter in B for the height of the tile in bytes (04 rows). | ||
MoveTile_Right_RowLoop | DB94 | PUSH BC | Stash the row counter (tile height) on the stack. | |
Get the screen buffer address from the co-ordinates.
|
||||
DB95 | LD A,($E75F) | B=*Tile_Horizontal_Coordinate. | ||
DB98 | LD B,A | |||
DB99 | LD A,($E760) | C=*Tile_Vertical_Coordinate. | ||
DB9C | LD C,A | |||
DB9D | CALL Calculate_ScreenBlockAddress | Call Calculate_ScreenBlockAddress. | ||
DBA0 | LD A,$08 | Set the number of bytes in a character block to A. | ||
DBA2 | 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. | ||
DBA5 | PUSH HL | HL=screen buffer address of the tile. | ||
DBA6 | POP DE | DE=screen buffer address of the tile (using the stack) + 01. | ||
DBA7 | INC DE | |||
DBA8 | PUSH HL | Stash the current screen buffer address of the tile on the stack. | ||
Start moving the current row.
|
||||
MoveTile_Right_ColumnLoop | DBA9 | PUSH HL | Stash the current screen buffer address of the tile on the stack. | |
DBAA | LDDR | Move 0004 screen data bytes from right to left. | ||
This leaves the last byte unprocessed - which should be blank. So, let's erase it.
|
||||
DBAC | INC HL | Erase the right-most byte (C contains 00). | ||
DBAD | LD (HL),C | |||
DBAE | POP HL | Restore the current screen buffer address from the stack. | ||
DBAF | INC H | Move down one row. | ||
Update the screen buffer address for the next loop iteration.
|
||||
DBB0 | PUSH HL | HL=screen buffer address of the tile. | ||
DBB1 | POP DE | DE=screen buffer address of the tile (using the stack) + 01. | ||
DBB2 | INC DE | |||
DBB3 | LD BC,$0004 | Restore BC back to 0004. | ||
DBB6 | DEC A | Decrease the column/ byte counter by one. | ||
DBB7 | JP NZ,MoveTile_Right_ColumnLoop | Jump to MoveTile_Right_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.
|
||||
DBBA | POP HL | Restore the current screen buffer address from the stack. | ||
DBBB | CALL Calculate_AttributeAddress | Call Calculate_AttributeAddress. | ||
DBBE | PUSH DE | HL=attribute buffer address of the tile (using the stack). | ||
DBBF | POP HL | |||
DBC0 | INC DE | DE=attribute buffer address of the tile + 01. | ||
DBC1 | LD BC,$0005 | Move 0005 attribute bytes from right to left. | ||
DBC4 | LDDR | |||
This leaves the last attribute space unprocessed - which should be blank. So, let's erase it.
|
||||
DBC6 | LD A,$47 | A=INK: WHITE, PAPER: BLACK (BRIGHT) . | ||
DBC8 | INC DE | Erase the right-most attribute block. | ||
DBC9 | LD (DE),A | |||
Move to the next attribute row.
|
||||
DBCA | LD HL,$E75F | Increment *Tile_Horizontal_Coordinate by one. | ||
DBCD | INC (HL) | |||
DBCE | POP BC | Restore the attribute row counter from the stack. | ||
DBCF | DJNZ MoveTile_Right_RowLoop | Decrease the attribute row counter by one and loop back to MoveTile_Right_RowLoop until the whole row has been processed. | ||
The tile has successfully moved one space!
|
||||
DBD1 | POP BC | Using the number of spaces left to move (from the stack) call Sound_TileMovement. | ||
DBD2 | PUSH BC | |||
DBD3 | CALL Sound_TileMovement | |||
DBD6 | LD A,($E75D) | Take *Tile_Horizontal_Position and decrease it by one, which adjusts the value for the tile width. Write it back to *Tile_Horizontal_Coordinate. | ||
DBD9 | DEC A | |||
DBDA | LD ($E75F),A | |||
DBDD | LD HL,$E75E | Increment *Tile_Vertical_Position by one. | ||
DBE0 | INC (HL) | |||
DBE1 | POP BC | Restore the number of spaces left to move from the stack. | ||
DBE2 | DJNZ MoveTile_Right_Loop | Decrease the number of spaces counter by one and loop back to MoveTile_Right_Loop until the tile is in the destination space. | ||
DBE4 | RET | Return. |
Prev: DB2E | Up: Map | Next: DBE5 |