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 > Help needed with background tiles

#5817 - machinerider - Fri May 09, 2003 12:58 am

Hi,

I'm having some problems with my game, Jewel Crash. My background tiles are getting overrun with rubbish data.

It seems to happen when you finish a line of jewels in the top half of the playing grid. At that point, it looks like something is writing to the background buffer at 0x6000000.

I've gone through my code about 500 times and still can't find what I'm doing wrong.

The game + source is available for download on the front page of gbadev.org, or, failing that, you can get it from www.machinerider.com/downloads/

Thanks!

Daniel Crowley -Wilson
www.machinerider.com

#5818 - niltsair - Fri May 09, 2003 1:01 am

A common thing to look out for, the maps. Since they use the same memory area than the tiles, you might make one overwrite the other one.

Load your tiles starting form bottom, and your maps from the top of the memory.

#5825 - Quirky - Fri May 09, 2003 8:16 am

I've managed to get the bug to appear and it happens just after the jewels fall down. I guess the problem is in CheckCombos(). I'd look at the final ClearSprites in that routine, as that seems a bit suspicious to me - make sure sprite_count and sprite_grid_count are doing what you expect. Course I may be barking up the wrong tree entirely, but I can't see what else it might be.

Also, to sort out your keypad "stickyness" it's a good idea to not read directly from the key register. It's a tricky thing to get right though, the feel of the keys, try experimenting with storing the register every frame and testing for repeats, etc. Emulators behave quite differently to the real thing in this respect, so storing the register's value and using this is the only way to make sure the game plays the same way on hardware.

Finally you should avoid putting implementation code in .h files. Better to seperate the actual routines into .c files with the function prototypes, defines etc only in the header, then you can compile the individual parts into seperate .o files and save compiling the whole thing everytime, amongst other benefits (readability, easier to include modules in other projects, etc).

#5882 - machinerider - Mon May 12, 2003 7:49 am

Niltsair and Quirky, thank you kindly for your replies. I think I've isolated the background problem. I'm going to experiment with the key registers a bit more, and take your ideas of storing the vals per frame under advice.

Finally, isolating my function implementation into .c files is one those classic "d'oh!" moments.. as soon as you've read it you wonder why you never thought of it, because it seems so obvious!

Thanks again for taking the time to look through my code - it really does help getting a third party to point out the little things that are so easy for the author to miss.

For those interested in downloading the final version, it will be available on my site at www.machinerider.com/downloads, hopefully in a few days max.