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 > another Mac question :P

#9437 - shaktool - Mon Aug 04, 2003 8:48 pm

(for those who were paying attention, installing Jaguar DID solve my previous problems)

So, I've got Sealfin's Image-to-GBA converter. At the risk of sounding like the newbie that I am, I'm going to ask how the heck you use that thing. More specifically, how do you use Step 2? I can't run either of the step 2 things.

Quote:
To use these tools, first run step1, then run either step2-16bitConversionToHeader or step2-16bitPaletteCoversionToHeader from within the terminal.


That was the best explanation I could find anywhere, but it doesn't say which terminal or how to do it. Step1 is a terminal of sorts, but it doesn't seem to give me a chance to run the other things. The terminal that comes with OS X doesn't like it when I do:
open /.../Image-to-GBA/part2-16bitConversionToHeader
either. I know next to nothing about Unix, though, so I'm probably doing that wrong.

#9442 - crossraleigh - Mon Aug 04, 2003 11:39 pm

What people usually mean by 'terminal' is 'Unix terminal emulator'. In this case it is the Terminal.app that comes with OS X. Open it up and it will start a 'shell' (tc by OS X default) that allows you to type commands.

You shouldn't use `open`; just execute the binary, i.e., type it in and hit enter. Be sure and use the full path too. If you are in the Image-to-GBA directory (or wherever you put the tools), `./part2-16bitConversionToHeader <FILENAME>` should work just fine.

#9465 - shaktool - Tue Aug 05, 2003 2:55 pm

Thanks. I got it to work... then decided I wasn't happy with the result. With some help with my brother, I have made the Terminal my pet... to the point where I'm going to write a program for it like this one, except tailored to my needs.

I'm going away for a week or two, but when I get back and finish the program, I might show it off here.

#9597 - sealFin - Sat Aug 09, 2003 9:36 pm

shaktool, could you post why you weren't happy with the result? I'd like to improve the tool, but I can't without feedback ^_^
_________________
sealfin

:sigh: Yes, I know seals don't have fins...

#9761 - shaktool - Sat Aug 16, 2003 4:18 pm

Wow, it's Sealfin! Howdy.

When I used the 16BitConversionToHeader on the temporary file created from a 16x16 .bmp file, I ended up with a full set of RGB values for the pixels (I think), but when I used the palette version, the header file gave me a 16x8 set of values...Plus, it created its own color table, but what if I wanted a bunch of different pictures to use the same color table? Also, all the values were of the form 0x3e0 or whatever, but simple integers seem more convenient at the moment. I may change my mind about that later...

So, I'm going to try to make a program that will read 16 and 256 color .bmp files then output a header file for the picture and an optional one for the color palette. Or you could try it...

#9968 - sealFin - Sat Aug 23, 2003 7:48 pm

Quote:
Plus, it created its own color table, but what if I wanted a bunch of different pictures to use the same color table?

Create a composite image which contains all the images which you want to share in that colour palette, convert, and cut and paste the colour palette into another header?

I'll put options in a future version to only output either the image or colour palette - gimme a day.

I'll also put in the option to output either single integer values, or component integer or hex values.

Any other requests? ^_^
_________________
sealfin

:sigh: Yes, I know seals don't have fins...

#9982 - shaktool - Sun Aug 24, 2003 12:47 am

Well, I figured out why it was cutting my picture in half... I was giving your program a .bmp where each pixel was 4 bits and it thought they were all eight, so it read each pair of pixels as a single one.

I did some research and experimentation in .bmp files and how the GBA handles color palettes. I wrote a terminal program that does almost what I want it to do, but I still haven't totally figured out the colors when reading in a color palette. It seems the GBA has not three, but four colors: blue, green, brown, and dark red, in that order. If you wanted bright red, for example, then set the color to 0x00FF (I assume you already know this?)... I just need to figure out some conversion formulas.

Requests? Well, I really think your program ought to have better support .bmp files, since those are one of the closest formats you can get to GBA sprites. They support both 4 bit and 8 bit color tables, and they already are made up of a color palette and a set of references to it, and it is easy (with photoshop) to make a bunch of .bmp files use the same color palette without mixing up the colors. For more info on how .bmp files work, check out this:
http://www.brackeen.com/home/vga/bitmaps.html

#9983 - shaktool - Sun Aug 24, 2003 1:42 am

Further research reveals my silly mistake with the colors. 4 colors? Hah!

5 bits per color? Who would have thought of that? Well, that explains why I thought there was a brown color... it was actually the last three bits of green and the first bit of red.

Aww, Shaktool, you so crazy.

#9987 - shaktool - Sun Aug 24, 2003 6:03 am

My tool is finished. Of course, by finished, I mean it's ready for testing. It works perfectly on my 16x16 pixels, 16 color .bmp file, but I haven't tested anything else yet (it's past my bed time). I do know, though, it won't work on anything larger than 256x256... is that worth fixing?

I'll upload it somewhere soon for folks to try out, if you want. It is not nearly as deluxe as Sealfin's tool, but unlike his, it does exactly what I want it to.

#9993 - sealFin - Sun Aug 24, 2003 9:47 am

Quote:
[...]I was giving your program a .bmp where each pixel was 4 bits and it thought they were all eight[...]

Sure this isn't a bug in the code you're using to show the image on the GBA? As there are no 'hard coded' formats in the tool, as all conversion uses QuickTime...

If you want, I'll email you the source (~fifty lines) to the test beds I'd tested the tool with?

Anyways, I'll probably have a new version of the tool with implementations of all the improvements in the previous post by Monday.
_________________
sealfin

:sigh: Yes, I know seals don't have fins...

#10002 - shaktool - Sun Aug 24, 2003 4:28 pm

From the same picture, your program yeilds:

Code:
   //   Image conversion tools by sealFin.

const u8
   goomba__x = 8,
   goomba__y = 16;

const u16
   goomba[ ( 8 * 16 ) ] =
   {
      0x0, 0x0, 0x100, 0x101, 0x201, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x301, 0x303, 0x103, 0x2, 0x0, 0x0, 0x0, 0x100, 0x504, 0x505,
      0x403, 0x202, 0x0, 0x0, 0x0, 0x100, 0x403, 0x305, 0x104, 0x202,
      0x2, 0x0, 0x0, 0x101, 0x406, 0x303, 0x604, 0x101, 0x202, 0x0,
      0x300, 0x303, 0x707, 0x103, 0x707, 0x101, 0x201, 0x2, 0x301, 0x505,
      0x505, 0x303, 0x303, 0x303, 0x101, 0x202, 0x301, 0x505, 0x505, 0x505,
      0x305, 0x103, 0x201, 0x202, 0x101, 0x103, 0x207, 0x202, 0x107, 0x101,
      0x202, 0x202, 0x200, 0x101, 0x301, 0x303, 0x101, 0x202, 0x202, 0x2,
      0x0, 0x200, 0x101, 0x101, 0x201, 0x202, 0x0, 0x0, 0x0, 0x0,
      0x800, 0x909, 0x909, 0x808, 0x0, 0x0, 0xa00, 0xa0a, 0x80b, 0xc09,
      0x80c, 0xa08, 0xa0a, 0xb, 0xd0a, 0xa0e, 0xb0a, 0x808, 0x808, 0xe0a,
      0xe0d, 0xb0a, 0xe0a, 0xa0e, 0xb0a, 0xb, 0x0, 0xe0a, 0xe0e, 0xb0a,
      0xa0b, 0xa0a, 0xb0b, 0xb, 0x0, 0xa0a, 0xa0a, 0xb0b
   },
   goomba__palette[ 0x100 ] =
   {
      0x7fff, 0x8d, 0x8, 0x111, 0x0, 0x196, 0x6f7b, 0x5ad6, 0x85, 0x108,
      0x180, 0xe0, 0x12c, 0x220, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0, 0x0, 0x0
   };


and mine yeilds:

Code:
// This header file was created using Shaktool's .bmp to header file conversion tool for GBA.
// This particular one contains the goomba sprite.

#define goomba__x 16
#define goomba__y 16

const u32 goomba__palette[ 16 ] =
{
        0,
        32767,
        576,
        480,
        384,
        224,
        265,
        332,
        166,
        406,
        306,
        173,
        9,
        29596,
        24311,
        32767
};

const u16 goomba[ ( 16 * 16 ) ] =
{
        1, 1, 1, 1, 1, 11, 11, 11, 11, 12, 1, 1, 1, 1, 1, 1,
        1, 1, 1, 1, 11, 10, 10, 10, 10, 11, 12, 1, 1, 1, 1, 1,
        1, 1, 1, 11, 0, 9, 9, 9, 10, 0, 12, 12, 1, 1, 1, 1,
        1, 1, 1, 11, 10, 0, 9, 10, 0, 11, 12, 12, 12, 1, 1, 1,
        1, 1, 11, 11, 13, 0, 10, 10, 0, 13, 11, 11, 12, 12, 1, 1,
        1, 10, 10, 10, 14, 14, 10, 11, 14, 14, 11, 11, 11, 12, 12, 1,
        11, 10, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 12, 12,
        11, 10, 9, 9, 9, 9, 9, 9, 9, 10, 10, 11, 11, 12, 12, 12,
        11, 11, 10, 11, 14, 12, 12, 12, 14, 11, 11, 11, 12, 12, 12, 12,
        1, 12, 11, 11, 11, 10, 10, 10, 11, 11, 12, 12, 12, 12, 12, 1,
        1, 1, 1, 12, 11, 11, 11, 11, 11, 12, 12, 12, 1, 1, 1, 1,
        1, 1, 1, 1, 1, 8, 6, 6, 6, 6, 8, 8, 1, 1, 1, 1,
        1, 4, 4, 4, 5, 8, 6, 7, 7, 8, 8, 4, 4, 4, 5, 1,
        4, 2, 3, 4, 4, 5, 8, 8, 8, 8, 4, 3, 2, 3, 4, 5,
        4, 3, 3, 4, 4, 5, 5, 1, 1, 1, 4, 3, 3, 3, 4, 5,
        5, 4, 4, 4, 5, 5, 5, 1, 1, 1, 4, 4, 4, 4, 5, 5
};


My code is terribly convoluted and inefficient, but it's such a small program that I don't really care. I'd be happy to show it to you (at the risk of PROVING that I'm a newbie to C) if you think it could help you. My email address is Neskoliosis@comcast.net, if you're interested.

School starts in a couple days, and I don't have the time to look at your program right now, sorry.

#10032 - sealFin - Sun Aug 24, 2003 11:53 pm

shaktool, I cut and pasted the header source you posted which had been produced by my tool - the resulting image is below...
[Images not permitted - Click here to view it]
with the display code...
Code:
#include "gba.h"
#include "goomba.h"



int main( void  )
{
  u8
    x,
    y;
  u16
    loop;



  Set_screen_mode( kEnable_screen_mode_4 | kEnable_background_2 )
  for( loop = 0;
    loop < 0x100;
    loop ++ )
      PaletteBuffer[ loop ] = goomba__palette[ loop ];
  for( y = 0;
    y < 16;
    y ++ )
      for( x = 0;
        x < 8;
        x ++ )
          VideoBuffer[ ( y * 120 + x ) ] = goomba[ ( y * 8 + x ) ];
  return 0;
}


As I've been able to get it to display, I'd assume that the bug is in your display code...
_________________
sealfin

:sigh: Yes, I know seals don't have fins...

#10033 - shaktool - Mon Aug 25, 2003 12:56 am

Hmmm... Yep, that's my goomba. Except for the black part in his shoes, that's what he looks like. I'll look into it more... and thanks for the example display code!

I still like my program, though... it's cute.

It seems the next thing on my list of things to learn about GBA programming is how to display a sprite, since my technique, though successful, is apparently not the best.

Sooner or later I'm gonna have to dedicate something to you and crossraleigh ;)

#10034 - shaktool - Mon Aug 25, 2003 1:15 am

Hmmm... Yep, that's my goomba. Except for the black part in his shoes, that's what he looks like. I'll look into it more... and thanks for the example display code!

I still like my program, though... it's cute.

It seems the next thing on my list of things to learn about GBA programming is how to display a sprite, since my technique, though successful, is apparently not the best.

Sooner or later I'm gonna have to dedicate something to you and crossraleigh ;)

#10036 - shaktool - Mon Aug 25, 2003 4:37 am

sorry about the double post...(twenty minutes between them? how did that happen?)

well, you were using gba.h, and I'm using Socrates.h from SGADE. That could explain why things work a little differently for you.

I'm just posting to say that I'm happy, though. My tool works for me, and it will work for anyone else using SGADE, which seems to be the only thing available to novice programmers right now. I'll probably make my tool available to the world as soon as I test it a bit more.

I even tried using a .bmp as a tilemap for a background, and converted it with my tool...that was satisfying. Of course, a .bmp is not the ideal format for a tilemap... know of any good tile editting software for mac? I'm still looking for one of those.

#10051 - crossraleigh - Mon Aug 25, 2003 8:35 pm

Quote:
... know of any good tile editting software for mac? I'm still looking for one of those.

I use the Java based TileMax.. All input/output is done with plugins, so you can have the data formatted however you like. You could even use it to make your sprites and bitmaps. I use it to create SGADE maps with this plugin.

#10060 - shaktool - Tue Aug 26, 2003 1:24 am

Man, there's a LOT of things I'm ignorant about...Look at this, I made a two page topic!

Anyway... when I downloaded Tilemax, apparently all I got was the source. The build instructions told me to use "make" in the terminal to build it. I tried, and got this:
Quote:
[Shaktools-Computer:seanreid/project/tilemax] shaktool% make
javac ca/seanreid/project/tilemax/model/*.java
error: cannot read: ca/seanreid/project/tilemax/model/*.java
1 error
make: *** [all] Error 1
Help!

#10061 - crossraleigh - Tue Aug 26, 2003 2:18 am

You don't need to build it. If you download the "Download TileMax 1.6, the latest version" you can run it by typing java -cp .:tmxapp.jar:tmxmodel.jar ca.seanreid.project.tilemax.app.TileMax in the TileMax directory.

Make errors like you were getting are probably because those source files don't exist, obviously a problem if you don't have the source package.

#11453 - I.M. Weasel - Tue Oct 07, 2003 7:15 pm

Sealfin,

do I have to keep The terminal open while tilemax is running?

Also,about the export.class files,is there anyway to check them to see if the "ExportData" function will harm my system?

#11459 - shaktool - Tue Oct 07, 2003 9:51 pm

Since you've so kindly B.U.M.P.ed my post, I'll take this opportunity to explain my tool, which has changed quite a bit since my last post, as well as my position on SGADE.

I'm no longer using SGADE, which means that my tool works for anyone else who doesn't use SGADE (on a mac), which seems to be most people. However, my tool is specifically used for 16 color graphics that get divided into 8x8 tiles. This may seem foreign to people who like pixel plotting, but anyone who wants to make a traditional sort of game with backgrounds and sprites will need something like this, and Sealfin's tool doesn't do that. Well, if you align the graphics in an 8 pixel wide column, you could use his tool to make 256 color tiles...but my tool allows you to control the color palettes and accepts any image dimensions that are a multiple of 8.

I could convert it to accept 256 color graphics too, if anyone wants that, but I won't convert it to support any format other than BMP. Sorry, but I'm not experienced with Quicktime.

This tool has proven invaluable to me. Check out a screenshot of what I'm working on. It's an Ikaruga clone, if that means anything to you.

[Images not permitted - Click here to view it]

128 sprites is just barely enough...

#11470 - poslundc - Wed Oct 08, 2003 4:42 am

For the record, I have written a PHP sprite converter that will run on any platform, and a background editor that runs native in Jaguar.

These are both in-house tools for my own development, however, and neither are remotely in any shape for public release.

If there are people interested, though, I may eventually see to bumping them up to a reasonable-enough quality level for others to use them.

Dan.