Hi
I’ve made a few changes to Grit, the nifty bitmap conversion and tilemapping tool for GBA by Jasper Vijn, to create a version for Virtual Boy.
More info and download link here. Let me know if you find anything amiss.
Notes:
I haven’t updated the html doc yet, see grit.txt (in the .zip) for the default options for VB. Tile palette reduction needs work.
dasi
- This topic was modified 16 years, 6 months ago by dasi.
- This topic was modified 16 years, 6 months ago by dasi.
- This topic was modified 16 years, 6 months ago by dasi.
- This topic was modified 16 years, 6 months ago by dasi.
- This topic was modified 16 years, 6 months ago by dasi.
- This topic was modified 16 years, 6 months ago by dasi.
- This topic was modified 16 years, 6 months ago by dasi.
Edit: Grit for Virtual Boy has been updated to v0.8.1.
I haven’t gotten a chance to try it out, but what exactly does it do? Does it convert graphics to a header file (like the Map Constructor in VIDE)?
DogP
It’s a command-line tool that converts 4 colour indexed images (bmp, gif, png, etc) into 8x8p 2bpp tiles and map data for the VB. The output is C/asm arrays.
I didn’t know this tool existed, but I was thinking of making this exact thing from scratch. Thanks for beating me to it! 😉
It’ll be great when I get a proper build system going. I can just edit the bitmaps and make will automatically pick up the changes.
However, not to pick nits, but I think since it’s under GPL you are required to release your source/changes. Thanks for the patch, dasi!
BTW, a handy option would be a way to specify which palette indices/colors are mapped to which VB pixel values. Maybe something like:
-p0 n
-p1 n
-p2 n
-p3 n
where n is a palette index (or HTML-style color?) in the source file.
Of course, with source I could probably add this myself… 😎
- This reply was modified 16 years, 6 months ago by RunnerPack.
Hi RP,
Here’s the patch with my changes to v0.8.1.
> I can just edit the bitmaps and make will automatically pick
> up the changes.
Yep, check out the new manual chapter: Grit in project builds.
dasi
WOOT! Just patched and built under MinGW with nary a hitch!
Now to investigate the color mapping switches idea…
Bug?
I used this command-line:
grit.exe ground.bmp -o ground.c -fh -ftc -mRa -gu8
and both arrays had a comma after the last element. I didn’t check, but I assume the compiler would throw an error because of this. These seem to be correct options…
So, I added a conditional to line 729 of pathfun.cpp. This fixed the tile array, but the map data still has the offending comma. AFAICT, the same function is outputting both arrays, so I cannot see the problem (of course, I am quite tired… ;-)).
I could just stick to the asm output with a C header (thanks to jorge’s magic makefile ;-)) but I’d still like to find the bug…
Any thoughts?
No bug. A trailing comma at the end of an array-initialiser list is A-Okay ANSI C.
You should still use asm arrays though, as they don’t need to be compiled.
-mRa isn’t a valid tile reduction option. Typo?
- This reply was modified 16 years, 3 months ago by dasi.
dasi wrote:
No bug. A trailing comma at the end of an array-initialiser list is A-Okay ANSI C.
Hmm… I’m sure I’ve gotten an error from that before… Maybe it was messed up slightly differently.
That’s kind of weird to allow that, though. Oh, well; you learn something new every day! 😉
dasi also wrote:
You should still use asm arrays though, as they don’t need to be compiled.
Good point.
dasi wrote more:
-mRa isn’t a valid tile reduction option. Typo?
Edit:
I was just browsing the source and noticed you commented out that option. I shall update the docs to reflect this.
Well, thanks for clearing that up, dasi!
- This reply was modified 16 years, 2 months ago by RunnerPack.
RunnerPack wrote:
I was just browsing the source and noticed you commented out that option.
Oh yeah, -mRa is one of the tile reduction combo options, equivalent to -mRt. I commented it out because the GBA doesn’t allow tile flipping in affine BGs whereas the VB does; on the VB we always want -mRtf, which is the default.
Edit: can we have HTML on, please?
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
- This reply was modified 16 years, 2 months ago by dasi.
I am currently trying to add automatic image conversion using grit 0.8.6 to the VBDE build process. It’s working well, but I can’t get Grit to generate tile maps along with the tiles. Here’s just one set of parameters I’ve tried with no luck:
grit.exe {{file}} -o objects\{{file}}.s -mRtf -gu8
Am I doing anything wrong?
Try adding: “-mLs”. If that doesn’t work, my only theory is that the “-o” switch is messing something up. I don’t think it’s necessary, anyway. It’s just a matter of finding out how it generates filenames (probably just changes the extension) and getting make to do it the same way.
If that doesn’t work, maybe you could split it into two calls; one generating maps and one generating chars (kind of inefficient, but probably not too bad on modern hardware).
Another idea that might work is adding the “-gS” switch to generate shared chars from all the images, and “-O” to specify the filename.
When you get this working, could you share the changes for those of us who already have it installed? (Or will there be a good reason to reinstall the whole thing?)
I talked to dasi and he gave me a number of parameters which worked for me: -gB2 -p! -mLs -mB16:p2hv_i11
Now the only thing left for me to figure out is how to include the generated *.s files. I am currently using a batch file to convert the images before I call make. Would the solution be to call grit from make, as suggested in the official docs, or would a little parameter in my (very simple and generic) makefile would be sufficient? Here the makefile:
$(TARGET).vb: $(TARGET).o $(TARGET).o: $(TARGET).c v810-gcc -Wall -nodefaultlibs -mv810 -Tc:/vbde/gccvb/v810/lib/vb.ld -xc -o $(TARGET).o $(TARGET).c v810-objcopy -S -O binary $(TARGET).o $(TARGET).vb
About VBDE: there will be quite a lot of things cleaned up and changed so you should reinstall, but it should be no big deal. It’s a very easy install after all and projects should need no change to still compile (I think).
If you haven’t already, you’ll probably want to check out “gritmake.htm” from the grit website (and maybe put it and the rest of the docs near grit itself in the downloads section).
After that, the first thing I would do is make a global “vbde.grit” containing the relevant grit options, to make it easier to write the makefile/batchfile.
Next, you should add a rule to the makefile to assemble “.s” files into “.o” files. It should be as simple as passing the file to the “gcc” command and letting it call the assembler appropriately. I don’t think any specific options are required, but problems can be dealt with as they appear.
Once that rule is ready, you just have to tell make to find the image files, run grit on them to produce the “.s” and “.h” files, assemble the .s files into .o files with the aforesaid rule, then link said objects with the game code into the final executable ROM as usual.
Regarding changes to VBDE: In light of blitter’s reported problems with gcc 4.x, are there any plans to try to incorporate 2.95.whatever as an alternative? Although, I suppose two versions of the library would have to be maintained (or a bunch of “#ifdefs” inserted), among other things, for this to work, to say nothing of how one would switch between the two…
Anyway, let me know if I can be of further help.