Posts from December 2007
Some Knitting Projects
Well, I finally have some photos of my latest knitting projects uploaded. First, we have Michelles Scarf, which was actually completed and shipped off months ago, but only now have I gotten to posting a photo:
This is, without question, my favorite piece. The cable pattern is reversible, which is very cool, and the yarn Lenore helped pick out looks really fantastic in pattern (it’s got a glossy, satin-ey finish… very nice, given it’s just off-the-shelf stuff from Michael’s). It was also a heck of a lot of fun to put together (I really love cabling).
Secondly, we have Abigails Baby Blanket, which I just recently completed. It’s a pretty simple pattern, just a nice shell-and-cable deal, but it looks great in the green yarn Lenore, again, helped pick out:
‘course, with all the work on NetHackDS, I’ve had little time to pick up the needles lately. Which is unfortunate, as I really need to begin working on a project for our now-quite-pregnant receptionist. Oh well, I’m sure it’ll be done… you know… a couple months after the baby is born. Ish.
Victory is Mine!
Well, I won the battle, anyway, even if the war is still ongoing. Word wrapping appears to work, menu items wrap, larger font sizes are now fully supported. And it looks mighty fine! And so, NetHackDS version 1.10 is now available!
Of course, now I have to move on to the myriad other features on the list.
Slow, Inexorable Progress
Very very slow… or, at least it feels that way. In reality, I can’t really complain. Word wrapping, even nice paragraph-reflowing word wrapping, is in and works quite nicely. Meanwhile, the command window is now finished, and supports snazzy scrolling when it’s necessary (of course, the default font still doesn’t require it, but switching to, say, the map font, which is 8x16, results in four pages of commands). It’s lightening quick, too, unlike the rest of the rendering code (yay large backbuffers and DMA copies). Meanwhile, the menu item wrapping code is… coming along.
Of course, the menu code has been a constant thorn in my side… I’m starting to realize I really need to go back and rethink how the code is designed, but at this point, I just want to get it working and move the heck on. Of course, that may be easier said than done. Currently, the big problem is that, previously, I could assume menu pages were the same size. After all, every item had the same height, so once the page size was calculated, it was basically constant. But now, with items being wrapped, they may take up two or even three lines in the menu, and I suddenly need a much smarter algorithm for determining how to page forward/back through the menu. It’s all quite tedious… which is why, I suspect, I left it for so long. sigh
Update:
Well, in a wave of inspiration, I managed to get the scrolling issues fixed before I left for work this morning (yay for extremely simple solutions). There’s still at least one crasher I’ve come across, but so far things are looking pretty darn good, if I do say so myself.
Word Wrapping For The Win
While development has slowed considerably on NetHackDS, partly due to me play… err… testing, partly due to me just needing a bit of a frickin’ break (and partly due to the excessive drinking I did during our company Christmas party, which left me nonfunctional for much of today), I have been putting some effort into one of the more difficult enhancements I’m doing to the codebase: adding proper word wrapping.
The impetus of all this started with a comment from one of my users who noted that, due to his/her poor vision, they’ve found my port rather difficult to use, as it makes use of a fairly small font. As such, they were wondering if I could add support for larger font sizes, and I, of course, said I’d take a look at it. It also happens that the only major remaining “known issue” in the code is one of text clipping: since the DS can only display, oh, maybe 65 columns of text, while much of the text in the game is designed for an 80-column display, there are a number of instances where the text is just chopped off on the right-hand side. And this is related to the font size issue because both problems require the same solution: word wrapping.
Now, the most basic word wrapping algorithm one might come up with, where you simply chop text where it’s too long, and print the remaining portion on the next line, does the job well enough, but it’s pretty unsightly. You end up getting things like this:
Before:
Hello, this is a really long piece of text I'm using for an example. And here is another line of text.
After:
Hello, this is a really long piece of text I'm using for an example. And here is another line of text.
Ideally, in a situation like this, what you really want is for the word wrapping engine to understand that the text is really a paragraph, and the words shouldn’t just be wrapped, but reflowed as well, so you get something like:
Hello, this is a really long piece of text I'm using for an example. And here is another line of text.
instead. So, being the wildly talented programmer that I am, I reinvented yet another wheel, wrote a reflowing word-wrapping algorithm, and voila! Fancy reflowed text. And it looks mighty fine, too. But there’s a problem. In order to write an algorithm like this, you have to identify paragraphs. Now, it just so happens that blank lines are usually used to separate paragraphs (you need only look at this post to see that), and so it’s pretty easy to identify where one paragraph starts and the other ends. But, NetHack also likes to generate tabular data like this:
No Points Name Hp [max] 1 48117 brettk-Val-Hum-Fem-Neu died in The Gnomish Mines on level 12. Killed by an Elvenking. - [115] 2 39115 brettk-Val-Hum-Fem-Neu died in The Gnomish Mines on level 10 [max 11]. Killed by a vampire lord. - [79] 3 29901 brettk-Bar-Hum-Mal-Neu died in The Gnomish Mines on level 11. Killed by a hallucinogen-distorted giant ant, while helpless. - [105]
and if you identify paragraphs by blank lines, and you reflow text, you end up with:
No Points Name Hp [max] 1 48117 brettk-Val-Hum-Fem-Neu died in The Gnomish Mines on level 12. Killed by an Elvenking. - [115] 2 39115 brettk-Val-Hum-Fem-Neu died in The Gnomish Mines on level 10 [max 11]. Killed by a vampire lord. - [79] 3 29901 brettk-Bar-Hum-Mal-Neu died in The Gnomish Mines on level 11. Killed by a hallucinogen-distorted giant ant, while helpless. - [105]
Notice how the rows are all jammed together. See, to the word wrapping engine, this looks like one big paragraph, thus it wrapped it accordingly, and the result is an unreadable mess. So, in this case, you don’t want to reflow the text. In fact, there’s really no nice way of handling this, so you’re best off just using the ol’ chop-and-print approach, as at least it somewhat preserves the tabular layout. But what the heck do we do, now?
Well, the NetHack putstr() call that is used to write text to a window, and is the entry point I implement, takes an attribute, which normally specifies bold, underline, etc, for the text. So, I created a new attribute bit, 0x1000, which basically says “don’t reflow this text”. I then went into the NetHack core (yeah, more core mods… I don’t like it, either) and altered the topten code so that, for the NDS version, it specifies this “dont reflow” attribute. This same attribute is also used wherever files are paged out (such as the in-game help text). But that does mean that, in effect, I’ve had to special case the NetHack core in a couple places in order to get the correct wrapping effect… basically, the solution sucks. Unfortunately, I don’t know of a better one.
But, on the bright side, the word wrapping works! And I’m using the same code in the status updates, the text windows, the message output, and eventually the menu code. Then, I just need to create a scrollable command window (the current one is entirely static), and the new, non-clipping, larger-font-capable NHDS will be ready! Ish.
Slowing it Down
Well, the past week or so has been an absolute whirlwind of software development. My NetHackDS project has developed considerably, expanding from a fairly basic port to supporting multiple rendering modes, control schemes, and so forth. And many of the features I’ve implemented haven’t even been my ideas… having actual users is surprisingly useful when trying to dream up new feature ideas. :)
But, with such an accelerated pace of development (I’ve been making new releases more or less every other day), it’s inevitable that bugs creep in, particularly since I’ve been spending far more time developing NetHackDS, and far less time playing it. As such, my plan over the next week is to dial back on new feature additions and focus primarily on a) playtesting, and b) bug fixing.
Of course, that’s not to say I won’t be doing any new feature development. Right now, I have it in my head to enhance the minimap, so it displays more useful information, and so I’ll probably plug away at that over the next little while. But aside from that, there are no major features I see desperately needing work in the short term… unless someone requests one. :)
Bitter Defeat
The current version of NHDS does a kind of funny thing when you die: instead of returning you to the fancy schmancy splash screen, it powers the DS off. As it happens, it does the same thing when the user saves their game (which is a good thing, IMHO), and this is no coincidence. It just so happens they share the same shutdown codepath.
Well, a couple people mentioned this, and I thought, yeah, I should try to fix that. It is, after all, rather irritating to have to power the DS back on after YASD. But, alas, I stand defeated. The problem is this: the NetHack core contains a lot of internal state. And the initialization of this state happens in a variety of places, and it’s not very neatly factored out. As an example, the core function, moveloop(), which is what gets the game going, performs a bunch of state initialization for the player.
Now, on, say, the Unix port, when the game ends, the program terminates. There’s no concept of the game restarting. And so all of this state isn’t a problem. But the case of NHDS is different. If I attempt to start the game again (and trust me, I’ve tried), the core gets mightily confused, puzzled why various bits of state are initialized, and further puzzled when it’s attempts to initialize others bits of state fail. It’s all quite the mess, really.
The consequence? I can see no way of fixing this problem. It’s an inherent issue with the way the game is structured. Oh well… on the bright side, at least I can just blame the DevTeam.
NHDS Progressing
Well, progress continues unabated on the NetHack port. A little part of me is actually somewhat concerned over the fate of my marriage, given the sheer amount of time I’ve been spending on this thing. But, on the (not so) bright side, Lenore’s been so sick the last couple days, she’s barely noticed that when I’m not attending to her needs, I’m hacking by the warm glowing warming glow of the laptop backlight.
Meanwhile, reception seems to be pretty positive, with most people of the opinion that yeah, my port seems to work pretty well. Of course, that’s not to say there isn’t plenty more to do, and tons of bugs to fix (just this morning Jeremy pointed out an odd colour problem on corpses… ie, they’re the wrong colour. Not to mention the fact that, as of this writing, you can’t write on the floor using just your finger), but it’s certainly a comfortably playable port, especially with the snazzy ANSI graphics mode!
As for imminent work, I just cleaned up the textmode cursor stuff this morning after a brainwave hit me in the shower, which means things like projectiles move the cursor correctly. Next, I think I’ll fix the engraving bug Jeremy spotted, and take a look at the tile-mode invisibility bug that’s been lingering since I first released the code. And somewhere in there, I need to figure out why the corpses are the wrong colour… and… and… and…
NetHackDS Released
Yup, I finally got it to a state where I think it’s done, and it now has it’s own home page. Sleep mode works. Key config is implemented. And text continues to be clipped. Of course, there’s plenty of bugs (I just spotted some weird behaviour in the message window), but I consider it “good enough” for public consumption.
NethackDS Screenshots
Well, I promised some shots of my Nethack port in action, and I aim to please! Now, I couldn’t figure out how to get my code working with Desmume, so I just gave up and used a camera. You’ll have to forgive the consequent bluriness…
Here we see a newly minted game. On the bottom screen you can see the visible play area. On the top screen you can see the minimap, with a red box representing the displayed region on the lower screen, as well as the player’s status and the welcome message.
This shows the popup command menu. The user holds the L button (eventually this will be swappable, for you lefties) to make the menu popup, at which point the user can tap a command to have it execute. Much nicer than an on-screen keyboard, I think…
And this last shot shows the inventory list after selecting the Inventory command. As you can see, there’s a bit of clipping, but it otherwise works as advertised. If this were a Drop command or something similar, the user would be able to tap items to select them (multiple taps begin counting from 1).
So there you go! See, it’s not vapour after all! Well, not technically, anyway…
Update:
And now key remapping is implemented! This includes handedness swapping (swaps the shoulder buttons), and mapping commands to the joypad and the primary buttons. And the changes are persisted across sessions. Neat, eh?