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.

Graphics > help! scrolly background, an interesting one.

#8011 - magictoy - Mon Jun 30, 2003 7:03 pm

Okay, I'm trying to achieve a similar effect to the floor in streetfighter 2. It looks to me like capcom have the floor as one background and they are changing the xposition of the background with every HBLANK interrupt.
I'm currently using HAM devkit and have tried to achieve this effect but I think the reason why I am failing is due to the double buffering. The background is updaed every time I call ham_CopyObjToOAM(); which flips the offscreen canvas and the one that is displayed.

Am I on the right track? I've already tried changing the colour palettes on each HBLANK but it mucks up. So any hints on achieving gradients that way would be appreciated too.

Fingers crossed someone has already succeeded in what I'm attempting to do. Oh, I'm using screenmode 1 btw, I've already used the rotating bg and one of the tiled backgrounds already in my project which leeaves me with the one remaining tiled bg. I'm reluctant to waste sprites to create a less appealing effect but with every hour I lose more hair the more likely it seems that I will have to use them...

please help
Nick
_________________
-------
To the winch, wench!

#8396 - magictoy - Wed Jul 09, 2003 5:14 pm

Hiya,

if it helps anyone, the game "tetanus on drugs" which source is available on gbadev.org uses this effect.

I, however, do not understand the code and therefore cannot replicate the effect. If any very kind and generous person can help at all, possibly pointing me in the right direction will forever be appreciated.

thanks in advance
Nick
_________________
-------
To the winch, wench!

#8405 - tepples - Wed Jul 09, 2003 8:04 pm

magictoy wrote:
the game "tetanus on drugs" which source is available on gbadev.org uses this effect.

Actually, TOD uses rot/scale mode.

The effect you describe is Pole Position style parallax scrolling, which can be done entirely without rot/scale mode. The effect was used in dozens of auto racing games (especially on NES, Game Boy, Game Gear, and Sega Genesis, which had no rot/scale mode), in NBA Jam and Super Street Fighter II for Super NES and Sega Genesis, and even in the backdrops of 16-bit platformers such as Actraiser, Sonic the Hedgehog 2, Donkey Kong Country 2, and Toy Story.

To achieve this effect on the Game Boy Advance video hardware, use hblank DMA. Make an array of 'unsigned short' containing an x scroll position for each scanline, and fill it with appropriate data. During vblank, set up an hblank-triggered DMA transfer with 16-bit transfer word size, increasing source address (set to scanline_x[1] in *WRAM), constant destination address (set to BG0HOFS), and length 1 word. Remember to declare the registers volatile, and remember to turn off the DMA channel (DMA0CNT = 0) before setting up the next transfer.

Effects like those of TOD are not that much harder. Instead of the array of 'unsigned short', make an array of structs that represent the format of BG2 affine registers. Then follow the above instructions with these changes: 32-bit word size, destination BG2 pa, length 2 words.

I don't know how to set up such a DMA with HAMlib calls because I don't use HAMlib.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#8799 - headspin - Sun Jul 20, 2003 12:51 pm

I'm not sure if your talking about the same thing, but I gave some sample code for a wave effect at http://forum.gbadev.org/viewtopic.php?t=300. It uses a sine table and vblank interrupt, although the code is a little unfinished (I had issues getting the sine table to loop over without a split in the wave).