Toki Tori looks like a GBA game

Discussion of programming and development for the original Game Boy and Game Boy Color.
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: GBjam Pirate Pop

Post by Drag »

For chr-ram parallax scrolling, vertical positioning is free because you just change which byte offset you copy from. Horizontal positioning is free every 8th increment, because again, you just change which byte offset you copy from. From here, you have two choices. One choice is to store 8 versions of the original background, each offset horizontally by one pixel, and the other is to shift the pixels in software. For a 64x64 pixel graphic, the worst case scenario is to shift 4 pixels (Instead of shifting 5 pixels, you move to the next byte (effectively shifting 8 pixels) and shift 3 pixels in the opposite direction), which would equate to 4 (shifts) * 8 (bytes per row) * 8 (rows per tile) * 8 (rows of tiles) * 2 (bits per pixel) = 4096 shifts.

A compromise between shift and CPU effort is to store two copies of the 64x64 graphic, with one copy offset by 4 pixels. Here, the worst case scenario is 2 shifts (for 3 shifts, you move to the other table (effectively shifting 4 pixels) and shift once in the opposite direction). Instead of 8 copies of the 64x64 graphic, you only have 2, and instead of a maximum shift of 4 pixels, it's now a max of 2.

I'm not sure how comfortable I'd personally be with a subroutine that burns a variable amount of operations between 0 and 2048 depending on the screen's scroll position, but if it can be proven to not negatively impact the game, then this would be a feasible solution.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: GBjam Pirate Pop

Post by tepples »

Try this: Store half the pattern offset by 4 pixels (or by 2 in the compromise version). Then the number of shift operations is constant no matter what the offset is: 0+4, 1+3, or 2+2.

I'm about to split the discussion of Toki Tori's scrolling.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: GBjam Pirate Pop

Post by Sik »

Drag wrote:For chr-ram parallax scrolling, vertical positioning is free because you just change which byte offset you copy from.
This is what I thought at first, but then I remembered that the DMA addresses (both source and destination) have to be aligned to 16 bytes (the size of a tile). So the vertical granurality is as bad as the horizontal one (i.e. steps of 8 pixels).

Still, worst case would be 64 different copies, i.e. 64KB. Given the ROM size being mentioned before, that doesn't sound as bad as it may seem at first.
Post Reply