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.

Beginners > How do I load RAW images?

#27086 - WillyWonka - Sun Oct 03, 2004 12:05 am

How do I load a raw file? I've found what seems to be an excellent exporter, Tile-Quant-Do but it only saves the tilesets, palettes, and map files as raw data.

I'm using the make file from the example pcx loader on this site and as far as I can tell I need to get "make" to include the raw files the same way as the pcx files. My problem is I've never touched a "make" file before so I dunno what to do to get it to work.

Are there any tutorials on this that I'm missing?

#27109 - WillyWonka - Sun Oct 03, 2004 8:53 pm

Okay, I believe I have the raw files attached to the file. How do I copy them into memory?

The information is being stored in
Code:
extern const u8 test_palette[];
extern const u32 test_palette_size[];


I'm trying to use memcpy, but it doesn't seem to be working. I'm getting:


c:/Projects/gba/bike/source/main.c: In function `main':
c:/Projects/gba/bike/source/main.c(147): warning: implicit declaration of function `memcpy'

but I have the include line:
#include <stdlib.h>

at the top.

#27110 - sajiimori - Sun Oct 03, 2004 9:00 pm

Well, there are lots of makefile tutorials out there, but make is just a utility for automating builds and avoiding redundant recompiles. Anything you do with a makefile can be done by hand.

"Raw" doesn't actually mean a whole lot. All data has a format. Maybe somebody might say an image is in a "raw" format if it's represented as a sequence of 16 bit BGR colors that correspond to the color format that GBA modes 3 and 5 use.

In another sense, one format can be "more raw" than another if it includes less auxiliary information. For instance, compared to an image format that includes width and height information in a header, a format that includes only pixel data might be considered relatively raw.

So really, there are 2 questions to answer:

1) How do you include binary data in your ROM? (See the FAQ.)
2) How do you use this binary data with GBA? (Depends on the format and what you want to do with it. The 16-bit image described above could be DMA'd straight to VRAM when using mode 3.)

#27111 - sajiimori - Sun Oct 03, 2004 9:01 pm

memcpy is in string.h.

#27112 - WillyWonka - Sun Oct 03, 2004 9:12 pm

Thanks!

Now I'm getting:

c:/Projects/gba/bike/source/main.c: In function `main':
c:/Projects/gba/bike/source/main.c(147): warning: passing arg 3 of `memcpy' makes integer from pointer without a cast

I know I'm getting it on the 3rd argument on this line but I dunnoy how to fix it:

Code:
memcpy( &PaletteBuffer, &test_palette, test_palette_size );


(test_palette and test_palette_size are still defined the same way as in the last message)

#27113 - DiscoStew - Sun Oct 03, 2004 10:13 pm

The reason why you are getting that problem is because you are sending a pointer into that argument. This is taken from your 2nd post here...
Code:
extern const u8 test_palette[];
extern const u32 test_palette_size[];

That second line is an array of however many elements you put into the original array. If test_palette_size only specifies the size of test_palette, then that shouldn't be an array, but just a simple variable;
_________________
DS - It's all about DiscoStew