Greetings All,
I am so sorry that I am posting here. The devkitPro forum is dead. I tried posting there multiple times, only to find out my messages have to be approved by a moderator, which never happens …
So here is my situation. I am using devkitPro to develop an in-house engine for my game. I am going to release the game and engine as open source.
In my game, I want to be able to scroll the screen in all directions: horizontal, vertical, diagonal.
The game is using a screen size of 32x32 tiles. My maps, however, are way larger than that. Even the 64x64 tiles size that the GBA supports is not enough for my maps.
I followed an example from devkitPro’s examples that scrolls a text message horizontally.
The way the example works is, the screen is scrolled to the right and the scroll offset is stored in a variable. When the offset reaches 7 pixels, the offset is set to 0. Then the whole 32x32 screen gets filled with the tiles from the map, just 1 tile to the left.
Here is the code which I modified slightly to fit my needs:
Scrolling the screen this way does work, but it is inefficient and there is quite a bit of screen tear. A video of this approach is shown below:
I discovered that the GBA wraps the screen around, when the scroll offset goes outside of the screen width. This way, tiles that are on the left side of the screen (that are outside of the screen) are drawn at the right side of the screen (in view).
THis is illustrated by the diagram below:
As you can see, the Red rectangle is the scroll position of the “GBA Window”, the black rectangle is VRAM (32x32 tiles) and the purple is the vertical strip of tiles that gets drawn on the right side (is wrapped around).
By doing scrolling this way, only a single vertical strip needs to be updated at a time to achieve the effect. This gives us a giant speed boost.
The code for this is here: https://pastebin.com/NQzLFvWV
Here is a video that illustrates this approach:
This approach, however, has a drawback. It cannot be used for diagonal scrolling. The vertical strip that gets wrapped around for horizontal scrolling overlaps with the horizontal strip that would be used vertical scrolling. This creates weird artifacts, which can be seen in the following video:
Can somebody give me a hand with this? :(