Routines |
Prev: D3AF | Up: Map | Next: D4BE |
Used by the routines at GoldfishGame_Collision, GoldfishGame_EraseSprite and GoldfishGame_PrintBoats.
|
||||||||||||||
GoldfishGame_PrintSprite | D460 | PUSH HL | Preserve HL on the stack as it's not actively used. | |||||||||||
Store the Sprite ID. Note; it is incremented on each UDG character block being printed (see GoldfishGame_PrintSprite_PrintUDG), hence why it's -01 here.
|
||||||||||||||
D461 | DEC A | Decrease the Spite ID by one and store it at *GoldfishGame_TempSpriteID. | ||||||||||||
D462 | LD ($DB3C),A | |||||||||||||
D465 | LD A,E | Store the Sprite width at *GoldfishGame_TempSpriteWidth. | ||||||||||||
D466 | LD ($DB3B),A | |||||||||||||
Ensure that we're printing within the screen boundaries.
|
||||||||||||||
GoldfishGame_PrintSprite_Loop | D469 | LD A,C | Jump to GoldfishGame_PrintSprite_Return if C is lower than 02. | |||||||||||
D46A | CP $02 | |||||||||||||
D46C | JP C,GoldfishGame_PrintSprite_Return | |||||||||||||
D46F | LD A,($DB3B) | E=*GoldfishGame_TempSpriteWidth. | ||||||||||||
D472 | LD E,A | |||||||||||||
D473 | LD A,C | Jump to GoldfishGame_FindViewableSprite if C is higher than 22. | ||||||||||||
D474 | CP $22 | |||||||||||||
D476 | JP NC,GoldfishGame_FindViewableSprite | |||||||||||||
GoldfishGame_PrintSprite_At | D479 | PUSH BC | Stash the print co-ordinates and the sprite height/ width on the stack. | |||||||||||
D47A | PUSH DE | |||||||||||||
Set the current printing location.
|
||||||||||||||
D47B | CALL $0DD9 | Call CL_SET. | ||||||||||||
D47E | POP DE | Restore the sprite height/ width from the stack, they're used here as loop counters. | ||||||||||||
Action this sprite ID (+01 and print it to the screen buffer).
|
||||||||||||||
GoldfishGame_PrintSprite_PrintUDG | D47F | LD A,($DB3C) | Increment *GoldfishGame_TempSpriteID by one. | |||||||||||
D482 | INC A | |||||||||||||
D483 | LD ($DB3C),A | |||||||||||||
D486 | CALL GoldfishGame_PrintColourUDG | Call GoldfishGame_PrintColourUDG. | ||||||||||||
D489 | LD A,C | Call GoldfishGame_PrintSprite_0 if C is equal to 02. | ||||||||||||
D48A | CP $02 | |||||||||||||
D48C | CALL Z,GoldfishGame_PrintSprite_0 | |||||||||||||
Keep track of where we're printing to on the screen.
|
||||||||||||||
D48F | DEC C | Move right one character block. | ||||||||||||
D490 | DEC E | Decrease the sprite width counter by one. | ||||||||||||
D491 | JR NZ,GoldfishGame_PrintSprite_PrintUDG | Jump to GoldfishGame_PrintSprite_PrintUDG until the sprite width counter is zero. | ||||||||||||
A row of the sprite has been printed, so restore the screen position and move onto the next line.
|
||||||||||||||
D493 | POP BC | Restore the current print co-ordinates from the stack. | ||||||||||||
D494 | DEC D | Decrease the sprite height counter by one. | ||||||||||||
D495 | JR Z,GoldfishGame_PrintSprite_Return | Jump to GoldfishGame_PrintSprite_Return if the whole sprite has now finished printing. | ||||||||||||
D497 | DEC B | Move down one row. | ||||||||||||
D498 | JR GoldfishGame_PrintSprite_Loop | Jump to GoldfishGame_PrintSprite_Loop. | ||||||||||||
Housekeeping, and return.
|
||||||||||||||
GoldfishGame_PrintSprite_Return | D49A | POP HL | Restore HL from the stack. | |||||||||||
D49B | RET | Return. | ||||||||||||
GoldfishGame_PrintSprite_0 | D49C | DEC E | Decrease E by one. | |||||||||||
D49D | PUSH AF | Stash AF on the stack. | ||||||||||||
D49E | INC E | Increment E by one. | ||||||||||||
D49F | LD A,($DB3C) | Increment *GoldfishGame_TempSpriteID by one. | ||||||||||||
D4A2 | INC A | |||||||||||||
D4A3 | LD ($DB3C),A | |||||||||||||
D4A6 | POP AF | Restore AF from the stack. | ||||||||||||
D4A7 | RET Z | Return if A is zero. | ||||||||||||
D4A8 | DEC E | Decrease E by one. | ||||||||||||
D4A9 | JR GoldfishGame_PrintSprite_0 | Jump to GoldfishGame_PrintSprite_0. | ||||||||||||
Try to discover the printable part of the sprite.
|
||||||||||||||
GoldfishGame_FindViewableSprite | D4AB | LD A,($DB3C) | Increment *GoldfishGame_TempSpriteID by one. | |||||||||||
D4AE | INC A | |||||||||||||
D4AF | LD ($DB3C),A | |||||||||||||
D4B2 | DEC E | Decrease the sprite width counter by one. | ||||||||||||
D4B3 | JP Z,GoldfishGame_PrintSprite_Return | Jump to GoldfishGame_PrintSprite_Return if the sprite width counter is zero. | ||||||||||||
D4B6 | DEC C | Move right one character block. | ||||||||||||
D4B7 | LD A,C | Jump to GoldfishGame_PrintSprite_At if C is higher than 22. | ||||||||||||
D4B8 | CP $22 | |||||||||||||
D4BA | JR NC,GoldfishGame_PrintSprite_At | |||||||||||||
D4BC | JR GoldfishGame_FindViewableSprite | Keep looping back to GoldfishGame_FindViewableSprite until we either return if this is invalid, or find a printable part of the sprite. |
Prev: D3AF | Up: Map | Next: D4BE |