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 > gfx2gba question

#178366 - punchki - Tue Apr 07, 2015 8:12 pm

I've been following tonc tutorials for quite a bit now, and I've gotten to the point where I want to make some of my own programs.

I made a circuit that uses a sensor to get the heart rate of a person, and outputs either a high or low signal. I want to use the GBA to display information on the heartrate and have a little heart flickering at the beat of the heart. Once I get my program working, I will put the two together.

But first...

The issue that I'm getting to is when using gfx2gba I want to take an image and turn it into a mode 4 .c However, using this:

gfx2gba -fsrc -c256 heart.bmp

I end up getting an output of a .raw.c and a master pallete, but the pallete doesn't seem to be in the format I want it.

How can I use gfx2gba to output me a pallete in the format:

Code:

// THIS IS NOT THE ACTUAL PAL

const unsigned int heartPal[8]=
{
   0x00100000,0x7FE00300,0x00007C18,0xFFFF1111,0x00000000,0x00000000,0x00000000,0x00000000,
};


Sorry if I'm not very clear... please let me know if it is unclear!

#178370 - Edward_Stryfe - Thu Apr 09, 2015 2:43 am

Hey man I'm afraid I can't help you but I'd just like to say welcome aboard. In all honesty this is probably for myself more than anything bcause I didn't actually think anyone would start using the GB/C/A for any type of application. Something that might help though is you say you've been to tonc[a place I need to go] and I've been to this place called loirak[dot]com the tutorials are for the newbiest of newbs but they have some nice resources that might help.

Good luck on your venture man with this whole deal and if you don't mind maybe if you finish the product post it at the end of the thread so we can see the output.

#178371 - DekuTree64 - Thu Apr 09, 2015 3:30 am

What format is it outputting? Just an unsigned short array rather than int? You can always just cast the pointer to whatever type you want when you go to copy it into palette RAM or whatever.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#178377 - punchki - Thu Apr 09, 2015 11:56 pm

Thanks for the reply guys :)

I was actually able to figure it out. I was opening the wrong file that had only one letter differently... But like you guys said it wrote just fine, no matter the data type.

I will submit some of my WIP soon :) the project is going great!

#178378 - punchki - Fri Apr 10, 2015 12:19 am

Here is a quick video I made of my wip :)

https://youtu.be/FFI7yanMn9Y

Let me know what you guys think! I'm really new to this, but I find when I come up with my own projects that I learn the fastest.

Any suggestions on the best way to get text in Mode 4?

Thanks,
Punchki

PS:
Things still to do~~

* Error checking for outliers
* Add text output to display heartrate
* clean up code!!!!!
* Sound of a heartbeat?

#178380 - gauauu - Fri Apr 10, 2015 3:17 pm

punchki wrote:

Any suggestions on the best way to get text in Mode 4?


There's not any magic bullet to make text simple in mode 4. You basically need to be able to render each character into your bitmap at runtime. I'd have a big array of each character's graphic data, and do a traditional blit calculation to copy the graphic data for each character into the right place in the bitmap.

Unfortunately for you, most of the time most games spend their time in modes 0-2, so most example code will be for those modes.