Print Story Go me!
Diary
By dark nowhere (Mon Feb 25, 2008 at 12:12:46 PM EST) (all tags)
So I started programming for the Nintendo DS. I can happily say that, while perhaps most of the time my code hasn't done what I'd expected, only 3 times out of hundreds has the code actually crashed, locked up or otherwise failed to run.

Also, something about perl failing at bitwise operations for those who are into that sort of thing.



I started with the framebuffer, made breakout... and didn't finish it... because it was time to move on to something more robust: 3D.

The system is a lot easier to develop for that I'd expected. Without an OS in the way, setting up is a lot easier. Like the framebuffer, learning the 3D system was pretty quick (despite the lack of documentation... and my ignorance of OpenGL.) I've actually spent a lot more time on my model converter in perl total than on getting the model rendered on the DS.



Speaking of perl - here's the weird thing that happened. When calculating normals I had to convert them to 1.0.9 fixed point and pack the vector into a 32 bit type. In perl I was just using something to the effect of:

$vn += $x *(1<<(10 * 2 - $c));

in a loop where $c = 0..2 and $x is one of the coords. ($vn is the packed vector.)

The problem is that it would give me the correct end result once or twice, and then start giving me a result which would be correct except for being a 64 bit value with the upper 32 bits set to 0xffffffff. No, it didn't ever overflow, and $vn was set to 0 before the loop.

It's still doing that now, but I'm AND-ing it with 0xffffffff to yield only the bits I care about.


I'm glad to be back to coding in C. Give me pointer arithmetic! There's something special about getting code running on hardware too, I can't describe it. Someone nerdier than I called it "progasm."

< Attention Boston Infidels! | BBC White season: 'Rivers of Blood' >
Go me! | 4 comments (4 topical, 0 hidden) | Trackback
Nerdgasm by wiredog (4.00 / 1) #1 Mon Feb 25, 2008 at 12:53:37 PM EST
Enough of those and you achieve nerdvana.

Sounds like a sizeof(int) issue. Ther machine always returns a 64 bit int. If it's consistent that's OK.

Earth First!
(We can strip mine the rest later.)



Seems buggy to me by dark nowhere (2.00 / 0) #2 Mon Feb 25, 2008 at 02:04:58 PM EST
but in the end I'm just thankful that I can use shifts in perl, even if I have to go out of my way to patch it up. The manpage does say that it's a straight call to the C op, and who knows what doing that to a perl data type could do.

I am not your dupe account.
[ Parent ]

Beware of endianess issues too. by wiredog (2.00 / 0) #3 Mon Feb 25, 2008 at 02:49:05 PM EST


Earth First!
(We can strip mine the rest later.)

[ Parent ]

Thankfully by dark nowhere (2.00 / 0) #4 Mon Feb 25, 2008 at 06:22:55 PM EST
the endianness matches... but also, the code is so full of shifts (fixed point math, packed aligned data ftw!) that it would be the rare thing indeed that would crop up. I guess that's prime breeding grounds for the gotchas though.

How I miss C. My input was all texty so I made the mistake of thinking perl would be better, but between perl's insane references and the complexity of the data I think I'll suffer through a tiny bit of text processing in C. Maybe then I'll even bother to generate normals data properly.

I am not your dupe account.
[ Parent ]

Go me! | 4 comments (4 topical, 0 hidden) | Trackback