While working on rktcr, I've spent a while thinking about how to checkpoint Box2D simulations so that one can rewind and play them back exactly.(Useful for replays, or time control when you really care about doing it right.)This turns out to be both harder and easier than one would expect:harder, because some of the simulation state (e.g. order of contact processing) is hard to access, much less properly save;easier, because one can hook memory allocations in Box2D and just save everything.This is one of those hacks where I'm very glad I use a language that can talk about memory.
I'm releasing this code as public domain -- you can find it from GitHub here.There is a small patch you'll need to apply to Box2D included.If you enjoy (or are confused), please let me know,
News
Wednesday, February 8, 2012
Saturday, August 20, 2011
Added Sworderation
I've added a game I worked on in 2004 -- Sworderation -- to the games section.I just played through it again, and it's still fun.I hope you think so too.
Labels:
games,
legacy,
sworderation
Monday, July 12, 2010
ICFP 2010
(This legacy post contained a description of what I did for gate encoding in the 2010 ICFP. I have moved this content to the projects section.)
Labels:
legacy
Sunday, July 12, 2009
wmiirc and Disks
(From the not-useful-unless-you-use-Linux-like-I-do department.)
So, I've been using wmii as the window manager on my laptop.Other than changing its default meta key to be the winkey (I should really do something about that branding), setting it to launch uxterms, configuring it to show CPU and battery info, and setting up pidgin to change a tag color on new messages, I haven't had to change its default settings at all.
That may seem like a lot, but in the world of "nonstandard" window managers, well, it isn't.Programmers (the probable main consumers of -- and face-slappingly-obviously main producers of -- such WMs) are picky people.Indeed, the fact that I didn't have to edit the source code to do any of this is right civilized!(Unlike switching the meta key in, say, Fluxbox.)
However, I did manage to do something stupid when performing that second-to-last tweak.First some background:wmii has a status line at the bottom of the screen.In the wmiirc script there is a function --
But my hard drive has been being accessed every five seconds (even when the computer is apparently idle) ever since I set that script up.Turns out that here-documents in bash create temp files.Creating temp files is disk activity.Disk activity makes kjournald decide to write a journal every five seconds.Which is probably not good for the disk, definitely not good for battery life, and quite annoying.Here'my version with that problem fixed:
So, I've been using wmii as the window manager on my laptop.Other than changing its default meta key to be the winkey (I should really do something about that branding), setting it to launch uxterms, configuring it to show CPU and battery info, and setting up pidgin to change a tag color on new messages, I haven't had to change its default settings at all.
That may seem like a lot, but in the world of "nonstandard" window managers, well, it isn't.Programmers (the probable main consumers of -- and face-slappingly-obviously main producers of -- such WMs) are picky people.Indeed, the fact that I didn't have to edit the source code to do any of this is right civilized!(Unlike switching the meta key in, say, Fluxbox.)
However, I did manage to do something stupid when performing that second-to-last tweak.First some background:wmii has a status line at the bottom of the screen.In the wmiirc script there is a function --
status() -- whose output is pasted into the lower right at some frequency.To display battery information you simply create a program (likely a shell script) to echo the information you'd like displayed and have status() call it.I learned as much from this forum post, which also includes a handy script to produce exactly the sort of info I wanted to display.Thus, I adapted this script to my needs and it has been quietly working ever since.But my hard drive has been being accessed every five seconds (even when the computer is apparently idle) ever since I set that script up.Turns out that here-documents in bash create temp files.Creating temp files is disk activity.Disk activity makes kjournald decide to write a journal every five seconds.Which is probably not good for the disk, definitely not good for battery life, and quite annoying.Here'my version with that problem fixed:
#!/bin/sh #based on http://bbs.archlinux.org/viewtopic.php?id=1809 rate=`grep 'present rate' /proc/acpi/battery/BAT0/state | tr -d -c 0-9` current=`grep 'remaining capacity' /proc/acpi/battery/BAT0/state | tr -d -c 0-9` total=`grep 'last full capacity' /proc/acpi/battery/BAT0/info | tr -d -c 0-9` percent=`echo "100 * $current / $total" | bc` speed=`grep -m1 -o 'cpu MHz.*\.' /proc/cpuinfo | tr -d -c '\n0-9'` if grep -q discharging /proc/acpi/battery/BAT0/state then minutes=`echo "60 * $current / $rate" | bc` echo $speed $minutes $percent'%' else echo $speed $percent'%' fiBy the way, should you find yourself in a similar pickle,
echo '1' > /proc/sys/vm/block_dump.It will produce kernel messages (viewable by dmesg -- you probably want to turn off your system logger while doing this) which will let you know who is causing blocks to need writeback.
Monday, January 19, 2009
SIGGRAPH Panic
(Reported far after the deadline.)
SIGGRAPH is crazy. What do you do when you need more space to edit your video? Well, to be fair, I had those backed up on another computer. Still, it was the most convenient spare 10+ gig.
And kdenlive is quite buggy (not old days cinelerra bad, but...). I've resisted up to now, but I may have to write my own nonlinear video editor. Or maybe try blender's built-in editor. The key is to write up a library that can load and seek video files in a frame-accurate way, with minimal pre-processing and memory overhead.
SIGGRAPH is crazy. What do you do when you need more space to edit your video? Well, to be fair, I had those backed up on another computer. Still, it was the most convenient spare 10+ gig.
And kdenlive is quite buggy (not old days cinelerra bad, but...). I've resisted up to now, but I may have to write my own nonlinear video editor. Or maybe try blender's built-in editor. The key is to write up a library that can load and seek video files in a frame-accurate way, with minimal pre-processing and memory overhead.
Sunday, November 23, 2008
Saturday, September 13, 2008
Dead-Bugging a QFP32
This morning I spent a few hours soldering a QT1103.Now, the QT1103 comes in a QFP32 form factor --a form factor which was almost certainly never meant to be soldered by hand,and, just as certainly, never meant to be soldered without a nice little footprint of tinned smd pads.But you can connect to them, so I had read, byflipping 'em on their back and soldering small wires to each pin, the result of which you see above.While this may look like a terrible job (a) there aren't any bridges and (b) this is really really small -- these wires are individual strands of a stranded copper wire.
Of course, I have yet to see if the device will actually work after I went to all this trouble (I could have cooked it, after all).But whatever the outcome, it was certainly the most fiddly soldering job I've ever done. I begin to see why people pay $20-$40 to have a PCB made.
Labels:
legacy
Subscribe to:
Posts (Atom)

