Prev: 56293 Up: Map Next: 56514
56395: Move Tile Down
Used by the routines at 61025 and 62526.
MoveTile_Down 56395 LD A,(59230) 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.
56398 DEC A
56399 LD (59232),A
Set the total of how many spaces the tile will be moving.
56402 LD A,(59233) B=*Tile_SpacesToMove.
56405 LD B,A
This is the tile loop, each space moved will decrease this counter by one.
MoveTile_Down_Loop 56406 PUSH BC Stash the number of spaces left to move on the stack.
56407 LD A,(59229) Take *Tile_Horizontal_Position and add 2 which adjusts the value for the tile height. Write this value back to *Tile_Horizontal_Coordinate.
56410 ADD A,2
56412 LD (59231),A
Start moving the tile a single space.
56415 LD B,4 Set a counter in B for the height of the tile in bytes (4 rows).
MoveTile_Down_RowLoop 56417 PUSH BC Stash the row counter (tile height) on the stack.
Get the screen buffer address from the co-ordinates.
56418 LD A,(59231) B=*Tile_Horizontal_Coordinate.
56421 LD B,A
56422 LD A,(59232) C=*Tile_Vertical_Coordinate.
56425 LD C,A
56426 CALL Calculate_ScreenBlockAddress Call Calculate_ScreenBlockAddress.
56429 PUSH HL Stash the destination screen buffer address on the stack.
56430 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 + 1.
56431 CALL Calculate_ScreenBlockAddress
56434 PUSH HL
56435 POP DE
56436 POP HL HL=screen buffer address of the tile.
56437 LD A,8 Set the number of bytes in a character block to A.
56439 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.
56442 PUSH HL Stash the current screen buffer address of the tile on the stack.
Start moving the current row.
MoveTile_Down_ColumnLoop 56443 PUSH HL Stash the current screen buffer address of the tile on the stack.
56444 PUSH DE Stash the current screen buffer address of the tile on the stack.
56445 LDIR LDIR.
56447 DEC HL Decrease HL by one.
56448 PUSH HL Stash HL on the stack.
56449 LD (HL),C Write C to *HL.
56450 POP DE Restore DE from the stack.
56451 DEC DE Decrease DE by one.
56452 LD BC,3 BC=0003.
56455 LDDR LDDR.
56457 POP DE Restore DE and HL from the stack.
56458 POP HL
56459 INC D Move to the next pixel row in the destination address.
56460 INC H Move to the next pixel row in the source address.
56461 LD BC,4 BC=0004.
56464 DEC A Decrease the pixel row counter by one.
56465 JP NZ,MoveTile_Down_ColumnLoop Jump back to MoveTile_Down_ColumnLoop until all pixels in the row have been moved.
56468 POP HL Restore HL from the stack.
56469 CALL Calculate_AttributeAddress Call Calculate_AttributeAddress.
Move DE down one attribute row.
56472 LD HL,32 DE+=0032.
56475 ADD HL,DE
56476 EX DE,HL
56477 LD BC,4 Copy 0004 attribute bytes from .
56480 LDIR
56482 LD BC,3 BC=0003.
56485 LD A,71 A=INK: WHITE, PAPER: BLACK (BRIGHT) .
56487 DEC HL Decrease HL by one.
56488 LD (HL),A Write A to *HL.
56489 PUSH HL Stash HL on the stack.
56490 POP DE Restore DE from the stack.
56491 DEC DE Decrease DE by one.
56492 LDDR LDDR.
56494 LD HL,59231 Decrease *Tile_Horizontal_Coordinate by one.
56497 DEC (HL)
56498 POP BC Restore the pixel row counter from the stack.
56499 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!
56501 POP BC Using the number of spaces left to move (from the stack) call Sound_TileMovement.
56502 PUSH BC
56503 CALL Sound_TileMovement
56506 LD HL,59229 Increment *Tile_Horizontal_Position by one.
56509 INC (HL)
56510 POP BC Restore the number of spaces left to move from the stack.
56511 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.
56513 RET Return.
Prev: 56293 Up: Map Next: 56514