Kevin Vance - Full scale text mode on the Nintendo DS subscreen

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

11:58 pm

Full scale text mode on the Nintendo DS subscreen

Monday, September 10th, 2007
Previous Entry Share Next Entry
Tags, ,

detail screenshot text screenshot Things are looking good for dsmzx. I implemented my idea for a 1:1 view of the textmode screen, and it worked! It's not as complicated as the scaled screen, but it presented its own technical challenges.

First of all, there is a tile size mismatch. ZZT and MegaZeux tiles are 8x14, while DS tiles are 8x8. If you assign each ZZT tile to two DS tiles (to make an 8x16), you end up with two blank lines in between every row. The answer to this is Yet Another Raster Hack. After every scanline that is a row boundary (14 lines), you scroll down two lines. This effectively gives me 8x14 tiles on the DS.

The next problem is coloring. ZZT tiles are monochrome, and can have any of 16 colors for both the foreground and background colors. The closest DS mode has 16-color tiles, which can use any of sixteen palettes for each tile. In order to have foreground and background colors, it was necessary to overlay two tiled maps on top of each other: one for foreground tiles, and one for the background color.

On the foreground plane, every character has a color of 0 for background or 1 for foreground. The 0-colored pixels will be transparent, allowing the background plane to show through. The 1-colored pixels will be assigned to the first color of any of 16 palettes. Make the first color in each palette one of the 16 textmode colors, and you're finished rendering the foreground pixels.

The background plane is a little easier, since only one type of tile is used: a totally solid one. Like the foreground tiles, it is assigned the palette that contains its color.

I've also figured out the savegame corruption problem. libfat has an error which causes filesystem corruption whenever you seek to the end of a file while writing to it. MegaZeux performs this seek for every board in order to update its board index. I bypassed this by saving the board index to memory, and seeking back to write it after the file was otherwise finished being written. libfat should really get fixed though.

My first dsmzx release is not far off!

Link )Reply )

From: c99koder
2007-09-11 11:07 am (UTC)
Looks good. There's supposed to be a video mode that allows you to rotate / scale a tile map, but it doesn't look like you can use 16 color palettes in that mode. I was hoping to use the hardware scaler to scale the 8x8 tiles to 8x14, but ZZT doesn't look too bad in 8x8 so I just left it for now.
(Reply) (Thread)
From: terryn
2007-09-11 10:31 pm (UTC)
This looks quite nice. Hopefully it'll get into a useable form soon which doesn't pop a DS! It looks like quite a task to do that, though, given the memory issues. Regardless, I'll see if I can test it out when it's ready.

In reference to an issue you posted a while back, I'm about 80% sure the second set of 16 colors is there because the editor colors are now locked; the editor's GUI isn't affected by changes in the current palette anymore.
(Reply) (Thread)
[User Picture]From: kvance
2007-09-12 12:11 am (UTC)
I've taken care of the stack problems in the game (though not in the editor :) so right now the memory only limits the size of game you can play. Seems like Catacombs (505K) will work but Dark Corner (840K) won't. If you run out of memory, the DS should crash with a nice red screen.

A memory expansion will definitely be required to load mzx files in addition to modules and samples.

That does seem to be what the secondary palette is for. Save/load dialogs too.
(Reply) (Parent) (Thread)