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 > Text Tiles, Resetting

#15251 - Dreamer - Tue Jan 20, 2004 2:04 am

I wrote a tile-based Text system that displays 8x8 monospace alphanumerics to given background coordinates. I was wondering if there was a way to 'undo' or unset a tile display (short of displaying something else over the offending tile). I assume I can't just assign NULL to the data, so is there some handy thing I can look into to reset tiles? The tiles used are in bmp format to use with the Warder1's Map Editor, and I can't set a transparency for the palette.

#15256 - tepples - Tue Jan 20, 2004 3:35 am

To unset a map space, overwrite it with the number of a blank tile. If your text engine is anything like my text engine, tile number 0x0020 (space) should be blank.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#15263 - Dreamer - Tue Jan 20, 2004 5:08 am

Unless I'm using the map editor wrong, when I load a tileset and make a new map, it takes the 0th tile (which is just black on my tileset) and fills the map with it. So when I use this (0x00) to overwrite, it just outputs black, not blank.

#15268 - sajiimori - Tue Jan 20, 2004 6:02 am

You've offered very little information, so the only reliable answer is: to undo a change you made in memory, replace it with whatever was there before.

#15270 - Dreamer - Tue Jan 20, 2004 6:09 am

Sorry. In more detail, I make a tileset as a .bmp, with 8x8 tiles for various aspects of the background. I made the first block black, to be a default, hoping this would be the 'transparent' block. I run Warder1's Map Editor, load the tiles, and choose a new map. This fills the space with all black, and I proceed to draw my background with the tileset.

I export and put it in my program. This background layer is static. I have another background layer, though, that I used to dynamically change certain tiles of the background. When I initialize the background I don't even set the map data for the background at all. I.e. in the first background, I initialize a u16 array to copy over data from the map file I made with tiles before. In the second one, though, I don't do this at all:

Code:

// First background gets its data initialized to display
// the tile background I want (map was converted
// to a .c file with BoardTileX as the data array
temp = (u16*)BoardTileX;
for(loop = 0; loop < 32*32/2; loop++)
    bg2.mapData[loop] = temp[loop];

// The second background doesn't employ this step,
// so bg3.mapData is never initialized, since I can't get
// a 'blank' tile to work.  I then just set parts of
// bg3.mapData[] when I need it, but I can't unset them.


Am I just making a stupid mistake in how I use the map generator, where it should let me have a 'blank' tile?


Last edited by Dreamer on Tue Jan 20, 2004 6:14 am; edited 1 time in total

#15271 - tepples - Tue Jan 20, 2004 6:11 am

You'll want to look in VisualBoyAdvance's tile viewer to find the offset of a transparent tile.

Black is not necessarily the "transparent color." Color index 0 is the transparent color index. You'll need to use an image editor that lets you control which color corresponds to index 0.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#15273 - Dreamer - Tue Jan 20, 2004 6:16 am

Hmm, interesting. Using the map viewer, it seems it only recognizes BG2, which shows tiles from both bg2 and bg3 variables. I have a feeling I'm using the same memory location for both maps. The tile viewer also is showing me a very strange looking set of tiles, with every other one being skipped (although I can draw all of them fine). The problem is I don't quite understand what 0x600000 is doing despite reading tutorials and source, so I'm somewhat slapping pieces together.

Ok I seem to have some memory management errors I need to solve. Back to the coding board go I.

Edit: The trouble with that (I use the palette spot 0 for transparencies for many sprite palettes and such) is that my tiles are in .bmp format for use with the editor, which don't support transparency, which was why I was more hoping to just unset a tile instead of writing a transparent one. I'll poke around and see what I can figure out. Thanks.

#15278 - sajiimori - Tue Jan 20, 2004 9:43 am

Transparency on GBA has absolutely *nothing* to do with transparency in image file formats such as BMP. Palette index 0 is transparent, and that's all there is to it.

Have you ever seen "The Neverending Story", where The Nothing is destroying the fantasy world? What you said earlier reminds me of some dialog that could be paraphrased like this:
Quote:

Rock eater: Long ago I had some beautiful graphics in my Character Base Block... until one night, The Nothing came. The next morning, my graphics were gone!

Boy: What, VRAM was set to all zeros?

Rock eater: No, not even zeros were there. There was Nothing.

There is no such thing as "unsetting" the contents of some memory. Every byte of memory contains *something* at all times, even if it's just zeros or random garbage.

#15299 - tepples - Tue Jan 20, 2004 4:50 pm

Dreamer wrote:
The tile viewer also is showing me a very strange looking set of tiles, with every other one being skipped

Displaying only even-numbered 256-color tiles in Tile Viewer is a known bug in older versions of VisualBoyAdvance. I made a test case and reported this bug to Forgotten. I don't recall which version first fixed it, but I do remember that at least VBA 1.6 contained a fix. VBA 1.7 has been released.

Quote:
my tiles are in .bmp format for use with the editor, which don't support transparency

You shouldn't have a problem if you can control what color represents index 0 in your image editor. For example, if you convert an image from RGB to indexed in GIMP, it should make color 0 match the pixel in the upper-left corner.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.