tung's blog

LuaJIT 2.0 with devkitARM (Nintendo DS)

tung's picture

I just compiled LuaJIT with devkitARM, a toolchain for making homebrew Nintendo DS ROMs. The steps are:

  1. Have devkitARM set up.
  2. Get the LuaJIT source code.
  3. Tweak src/Makefile.
  4. Build LuaJIT.
  5. Copy over the LuaJIT headers and library.
  6. Use LuaJIT.

The following notes are really hacky; follow them at your own risk.

Read more »

The Elements of RPGs

tung's picture

There aren't many hobbyist game devs working on role-playing games (RPGs). For those who are, it's useful to think about what the different parts of an RPG are, and how they fit together.

I won't talk about plot or characters; this blog entry is strictly about gameplay. Getting gameplay right in an RPG is hard enough without the burden of writing and editing a plot and characters.

There are 5 elements to any RPG:

  • Roles
  • Enemies
  • Skills
  • Items
  • Exploration

Read on for their explanations.

Read more »

New server!

tung's picture

Sorry for the month-long downtime, but I'm happy to report that this site is now being hosted by kamatsu, who is also taking over from rjt hosting the Sphere forums and the Sphere wiki.

The preferred domain of this site is now just tung.spheredev.org, though old links should still work.

My current project is Quipkit (project page and forum thread), an RPG kit for programmers seeking a simple game engine and a flexible editor. It's still in the drawing board phase.

Read more »

C++, Threads and Linux Audio: A Brief Retrospective

tung's picture

I just spent the last few days trawling through someone else's multi-threaded C++ Linux audio code, so I thought I'd share a few of my experiences.

First: The commit.

That code converts direct audio hardware access via ALSA into newer plugin-based output. It also fixes a race condition that occurs at the seam of the two subsystems involved: the client code provided a mixer callback that used a buffer that is initialised immediately after the server spawns the thread that needs it. It's a mistake made by the code's author, but to be fair I wouldn't have spotted it either if the code hadn't segfaulted on me.

If you ever find yourself in this situation, here are some tips:

  • Print statements really work. Yes, even with threads. Especially with C++, where control flow isn't obvious.

  • In threaded code, if you just insert print statements and behaviour changes, that's almost certainly a sign of a race condition.

  • C++ is harder to grep through than C, but it still works, if less effectively. C++ adds a lot of context that makes individual identifiers less useful on the isolated lines printed by grep.

  • Persistence pays. Even if the best programmers in the world say that threaded debugging is difficult, it can still be done.

  • If you're in college/university and going the computer/software route, take the Operating Systems course(s). Threads and concurrency get a lot of good exposure in them.

Read more »

Building Thatcher Ulrich's luaSDL for Lua 5.1 on Windows with MinGW

tung's picture

luaSDL is a library that can be loaded by Lua to make use of SDL. To get a fresh new luaSDL.dll that Lua 5.1 can load, read on!

Ingredients

Read on to get a fresh new luaSDL.dll for you to load and use!

Read more »

Making an RPG with Quipkit (Hypothetically)

tung's picture

Quipkit is a work-in-progress (read: not even near finished) indie RPG dev kit. This blog entry describes how we might make an RPG using Quipkit.

1. Vague Game Description

Most games start as vague ideas, and indie RPGs are no exception. Here's one for our hypothetical RPG:

You play a guy in a traditional fantasy RPG. You walk around a map of grass and water, and every so often you encounter a monster. You exchange blows with said monster in the battle system until either you or it dies. If you win, you gain experience. With enough experience, the guy can gain a level and grow in strength. This continues until the player chooses to exit.

It shall be dubbed... Island Dude.

How would be breathe life into this little RPG? Read on!

Read more »

Installing Git on Windows, as of June 2010

tung's picture

As of June 2010, there's no one-click installer of Git for Windows. Following this blog entry will get you:

  • msysgit, without its shell integration
  • TortoiseGit shell integration instead

msysgit's shell integration is nasty to uninstall, and if you do it wrong it'll pop up a dialog every 10 seconds.

Here's how you do it...

Read more »

How do I autoconf?

tung's picture

I was working on a project when general upgrade instability caused it to stop working on my development machine (read: starting OpenGL kills X for some reason). Off of Arch and onto Ubuntu 9.04, and I find that my Linux-based project won't build under Linux.

Autoconf is a set of tools that smooths over differences in build environments, like different file system conventions, library names, search paths, tool chains, and so on.

The following is based on a series of long articles over at the Free Software Magazine: the only tutorial/guide that didn't attempt to shove 20 years of history down my throat from the get-go. It's my personal reference and I'll update it as I learn.

Read more »

libpng's man page makes a crap tutorial

tung's picture

If there were a competition for world's worst man page, libpng's would be right up there. Instead of individual man pages for each function and struct, it rolls everything into the one huge document. That would be acceptable if it gave descriptions for each of the functions, but it doesn't, instead providing an nigh-impenetrable wall of text which is borderline useless as a guide or a reference.

Misgivings aside, I've managed to extract the useful information for the simple loading of a PNG image and put it in the code sample below:

Read more »

Where in the world is me?

tung's picture

Another 1 hour upgrade for Drupal. More voodoo rain dances required, but this time, the core Update Status checker module doesn't work: enabling it causes all admin pages to blank out.

It's just as well, because I've done most of my updating elsewhere.

@tungtn is where I post interesting articles that I find on Hacker News, and the occasional thought.

I talk with people on Google Buzz. If you've got Gmail, check it out, and feel free to follow.

I think that's about it.

Read more »
Syndicate content