Kevin Vance - I got a bit sidetracked on my DS project, but still making some good…

Entries | Archive | Friends | Friends' Friends | User Info

01:04 am

Tuesday, February 17th, 2009
Previous Entry Share Next Entry

Text printing screenshotI got a bit sidetracked on my DS project, but still making some good progress. The 3D world now renders correctly on the hardware. The sprite was showing up as all black with a transparent background, or color with a black background depending on whether or not I used the DECAL shading mode. Turns out it needed a fake material (emit=100%) and a normal vector.

You can also move around, collide with walls, and collide with sprites. These are using simple bounding box/bounding circle tests. A big box for the room bounds, and smaller boxes for obstacles. And circles for sprites. I also have an additional circle called the "interaction radius" where something can light up on the GUI and you can press a button to interact with it. This will be useful for interacting with sprites, and environmental features.

Then I started getting off track... first of all, I could not find a way to convert 8 bits/channel color images to 5 bits/channel (NDS format) using GIMP, ImageMagick, or PIL. So I wrote my own converter in python, using floating point and floyd-steinberg dithering. It's incredibly slow, but that doesn't really matter. The blue background of the example image has been run through that program.

Then I started looking at compression, since the output of my image depth crusher is in 16bpp NDS framebuffer format... very large. I originally used the LZ77 decompression routines that are conveniently in the BIOS. But unfortunately:
  1. They only seem to output to VRAM or WRAM, which is inconvenient.
  2. I switched emulators to no$gba in wine, which doesn't emulate that without a copy of the NDS ROM.
So I ended up with zlib instead. Despite some intimidating documentation and header files, there is a handy uncompress() function that does all the work. So that background image is zlib compressed framebuffer data, while the font is a zlib compressed PCX.

The font stuff is an extension of my earlier HexxagonDS text renderer. I nudged it over to C++, added some basic line-wrapping, and now it can draw 2-color fonts (an outline and a fill color).

Next: putting these together to have a 3D demo where you interact with stuff via text boxes!
Link )Reply )

[User Picture]From: dariusk
2009-02-17 01:43 pm (UTC)
Sweeeeeeet. (That is pretty much the only thing I'll be saying to this project :P )
(Reply) (Thread)
[User Picture]From: kvance
2009-02-17 04:17 pm (UTC)
Works for me. After I posted this, I thought "I just wrote a wall of gibberish that like 3 people on my flist are going to understand." :)
(Reply) (Parent) (Thread)
[User Picture]From: dariusk
2009-02-17 04:59 pm (UTC)
Also, I'm surprised that ImageMagick doesn't handle 5-bit BMPs. Not surprised in a "What, I thought I heard it did that" way, but more a, "Oh, I thought ImageMagick did EVERYTHING" way.
(Reply) (Parent) (Thread)
[User Picture]From: kvance
2009-02-17 05:33 pm (UTC)
I know! IM supports multiple bit depths, but not arbitrary ones.
(Reply) (Parent) (Thread)
From: preshgsi
2009-02-17 05:31 pm (UTC)
No idea what NDS is, but I'm pretty sure I understood most of everything else you posted. :P
(Reply) (Parent) (Thread)
[User Picture]From: kvance
2009-02-17 05:34 pm (UTC)
Heh, oops. NDS stands for Nintendo DS :)
(Reply) (Parent) (Thread)
From: zztzed
2009-02-17 08:56 pm (UTC)
I switched emulators to no$gba in wine, which doesn't emulate that without a copy of the NDS ROM.
Can't you dump a copy from a real DS?
(Reply) (Thread)
[User Picture]From: kvance
2009-02-17 09:03 pm (UTC)
Probably. But I'd like for people without a DS to be able to play, and no$gba seems to be the best emulator currently (Desmume can emulate the BIOS without a ROM, but it has other problems).
(Reply) (Parent) (Thread)