gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > GBA Hardware Scrolling

#12796 - punchy - Wed Nov 26, 2003 7:18 pm

I'm using 16 colour tiles and a 32*32 tile background. What i want to do is change the horizontal scrolling of the background for each horizontal line of 32 tiles. In other words I want to be able to move each horizontal line of tiles independantly.

I suspect this may be possible using interrupts but I have no experience of using them. Any pointers on the most efficient way of doing this would be most appreciated.

Thanks.

#12797 - tepples - Wed Nov 26, 2003 7:29 pm

If you don't know interrupts, try scrolling each scanline with hblank DMA, setting each 8 consecutive entries to the same x-value.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12798 - punchy - Wed Nov 26, 2003 7:50 pm

Thanks for the reply.

I am keen to get to grips with gba interupts though so what would be the approach using interupts.

#12801 - tepples - Wed Nov 26, 2003 8:22 pm

First of all, set up your interrupts:
1. Copy your ISR's pointer to the vector in IWRAM.
2. Turn on the hblank interrupt source in REG_DISPSTAT.
3. Turn on the hblank interrupt mask in REG_IE.
4. Turn on REG_IME.

In the ISR, set the background's X scroll position.

However, this will probably incur more CPU overhead than just using HDMA.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12804 - poslundc - Wed Nov 26, 2003 8:25 pm

See Day 5 of the Pern Project tutorial for an introduction to interrupts.

Make sure that interrupts are enabled in your crt0.s file; the tutorial briefly talks about this but it's easy to miss. Just open the crt0.s and scroll through the directions. You will have to uncomment a line or two.

Dan.

#12805 - ampz - Wed Nov 26, 2003 8:31 pm

Trying to do mode 7 are we? :)

#12807 - poslundc - Wed Nov 26, 2003 8:46 pm

ampz wrote:
Trying to do mode 7 are we? :)


Not if he's just altering the horizontal scroll, he won't be... my guess is a simple raster effect (like a sinusoid).

Dan.

#12808 - punchy - Wed Nov 26, 2003 9:00 pm

Actually i'm emulating some arcade hardware :)

Thanks again for the replies. I'm determined to have this sussed before i go to sleep. Could be a long night.