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.

C/C++ > Problem with compiling

#8397 - DiscoStew - Wed Jul 09, 2003 5:27 pm

I am totally stressed out because of this.
I'm working with large maps, and what I'm trying to do is whenever a background moves off by 8 pixels, it reloads the map correctly and resets the background coordinates. It all works fine and dandy, but when I use the WaitForVsync function, the program runs faster than it should (I trying to achieve 60fps to make it run smooth), so then I tried a Pern Project example on large maps which instead uses something like this...

while(!(REG_DISPSTAT & 1));//wait for vblank

//redraw the entire map...bit slow but thats okay
BlitBG(bg0map,testMap.layers[0].data,testMap.layers[0].w,(x>>3),(y>>3));

REG_BG0VOFS = y & 7;
REG_BG0HOFS = x & 7;

while((REG_DISPSTAT & 1));//Make sure VBLANK is over so our game does run faster than 60 frames per second

Note: I am not using his BlitBG function, since it does that every single frame.
I'm reloading everytime the screen is off by 8 pixels (1 tile).
I'm not sure exactly what he's doing here, but I tried it, and now the top 1/4 of the screen is jittering when I move the background. During this frustration, I came up with using the VBlank interupt so that when the screen is done drawing, it will interupt my code to where it can check and reload the map. Now here is where my problem is...

I'm using VS 6.0 and the GBA AppWizard (which I finally got working after having to change a few things in its MAK file that it creates). I have additional headers and source files that have that consist of my map functions. I use both linkers and headers from The Pern Project for my program.

My problem is that through building a program, it makes its "interupt.o" file before the "test.o" file (where my main entry point is located), which then requires me to include the necessary header/source files, since my map functions are separate. Because of this, I thought that since that is done first, commenting out those includes from my main file would work, but my program states that the specific variables/functions are undeclared. But when I remove the comments, the program states that there are multiple instances of each variable/function. It's driving me nuts!

So, my question is, how can I call a external function from interupt.cpp that is being included in the main source file if interupt.cpp is being compiled first? OR, How can I prevent VS 6.0 from creating the interupt.o before compiling test.o? I've checked the MAK file on this, and I don't see anything about it. Please help....

If what I'm saying is not clear, please ask me. thx
_________________
DS - It's all about DiscoStew

#8402 - DiscoStew - Wed Jul 09, 2003 7:17 pm

Great.....
After posting my topic, I noticed the "external" in my post, and it made me realize about calling external function and the such. Boy, my mind was somewhere else. But now comes another problem.

Everything seems to be working. I can now check my map for any needed reloading during my VBlank interupt phase, but different emulators are showing different results as of using the VBlank interupt.

When using "WaitForVsync()"
*VisualBoyAdvance:
Still fast, but its not even checking VBlank, so my map is not reloading when it's supposed to.
*BoyCotAdvance:
Nothing is even happening, like it froze or something.
*Mappy:
It's doing as it should, but it is jumping far worse than any of my other tests.

When using The Pern's Project VBlank wait (refer to code in last post)
Note: I've been using only the 2 while loops together with no other code between them.
*VisualBoyAdvance:
Works exactly like it should, smooth movement and all. Minor jumps are probably because of emulation.
*BoyCottAdvance:
Still nothing. I wonder if it can't handle VBlank interupts?
*Mappy:
Smooth movement, but jumpiness is still there.

Update: I moved the variables for map placing into the VBlank interupt, now Mappy is showing only the upper portion of the screen being jumpy.

I wonder, does anyone have a better solution as to dealing with large maps (preferably through the VBlank interupt)?
_________________
DS - It's all about DiscoStew

#8407 - tepples - Wed Jul 09, 2003 8:10 pm

In general, you shouldn't be reloading the whole map during vblank. It's best to load only the parts of the map at the "seam" and then let the map wrap around. Start your favorite commercial platform game and open up VisualBoyAdvance's tile viewer to see what a seam is.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#8409 - DiscoStew - Wed Jul 09, 2003 8:30 pm

I guess I didn't clarify myself about the map. The whole map is loaded when it starts up into an array, and at every VBlank, if the X/Y coordinates are off by 8 pixels (1 tile), it reloads from that portion that is related to the coordinates into the last ScreenBaseBlock, and I reset the coordinates to its original values. It's pretty close to The Pern's Project's large maps example, except instead of loading that portion of the map every go around, I do it in the VBlank interupt and only if the coordinates are off by 8 pixels.

I used to have Castlevania: COTM, and I've seen the way they set up there map using a 512x512 text background for their different layers, but I'm using 256x256 to save up on space for Tiles. This is really just a test of what I could try doing.
_________________
DS - It's all about DiscoStew