Prev: D870 Up: Map Next: D8D4
D8A2: Goldfish Game: Animate Boats
Used by the routine at GoldfishGame.
boats-animation
Every other frame, scroll the on-screen boats one pixel left.
GoldfishGame_AnimateBoats D8A2 LD A,($D93D) A=*GoldfishGame_BuoyancyCounter.
D8A5 AND %00000001 Keep only bit 0.
D8A7 RET Z Return if this is a skipped frame.
Walk the top third of the display: eight pixel-row groups, then eight scanlines in each group.
D8A8 LD DE,$4000 DE=4000 (top of the screen).
D8AB LD B,$08 B=08 (pixel-row groups).
GoldfishGame_AnimateBoats_BoatLoop D8AD PUSH BC Stash the group counter and the scanline pointer on the stack.
D8AE PUSH DE
D8AF LD B,$08 B=08 (scanlines in this group).
GoldfishGame_AnimateBoats_CopyLoop D8B1 PUSH BC Stash the scanline counter and pointer on the stack.
D8B2 PUSH DE
D8B3 LD A,(DE) Seed the carry with the leftmost pixel of this scanline.
D8B4 RL A
D8B6 PUSH AF Point HL at the rightmost byte of the scanline.
D8B7 LD HL,$001F
D8BA ADD HL,DE
D8BB LD B,$20 B=20 (bytes in one scanline).
GoldfishGame_AnimateBoats_ByteLoop D8BD POP AF Rotate this screen byte left through the carry.
D8BE RL (HL)
D8C0 PUSH AF
D8C1 DEC HL Step left one byte and loop back to GoldfishGame_AnimateBoats_ByteLoop until the whole scanline has scrolled.
D8C2 DJNZ GoldfishGame_AnimateBoats_ByteLoop
D8C4 POP AF Restore the carry and the scanline pointer from the stack.
D8C5 POP DE
D8C6 LD HL,$0020 Move DE on to the next scanline in this character row.
D8C9 ADD HL,DE
D8CA EX DE,HL
D8CB POP BC Restore the scanline counter from the stack.
D8CC DJNZ GoldfishGame_AnimateBoats_CopyLoop Decrease the scanline counter and loop back to GoldfishGame_AnimateBoats_CopyLoop until all 08 scanlines are done.
D8CE POP DE Restore the scanline pointer and group counter from the stack.
D8CF POP BC
D8D0 INC D Move to the next pixel-row group and loop back to GoldfishGame_AnimateBoats_BoatLoop until all 08 groups are done.
D8D1 DJNZ GoldfishGame_AnimateBoats_BoatLoop
D8D3 RET Return.
Prev: D870 Up: Map Next: D8D4