Porting Game Code to Plan9 (9front)

I have now embarked on porting the code from Andre LaMothe’s Game Programming books to Plan9.   Of course I am starting with 2D first, as most of the functionality is already within libdraw.  This should give me a good foundation as I work towards building a software based 2D/3D rasterizer.

The book I am starting with can be found on Amazon:

Tricks of the Game Programming Gurus, 2nd Edition

Once I have finished that one, which since I went thru it several years ago on Windows shouldn’t take that long, then I will be moving onto Dre’s next book:

Tricks of the 3D Game Programming Gurus – Advanced 3D Graphics and Rasterization

Considering that I already have both books and all of the source code you would think that getting access to the code would be pretty easy.  F**K NO!

Being the Apple guy I am I was trying to use my old ass Apple USB Superdrive to copy the files to my Linux machine which hosts my 9front instance.  But Apple has decided to f**king break their Superdrive.


I am not kidding, the Superdrive now works like shit, on purpose, on all current macOS versions.

To resolve this required some Linux magic.  See here and here on how to resolve this.  Anyway it is now all good!  I was able to copy the files off of these old CDs and get them over to my 9front installation using sshfs.


Of course this all hinges on getting sound to work properly.  This brings me to my concurrent project:  Enabling USB Audio using my Focusrite 2i2 and 6i6.  As of right now, they show up in /dev/usb but the user-space audio driver isn’t loading properly.

Ah the joys of reading the USB Audio specs over at usb.org.

I am too much of a nerd.




Clocks. Time. NTP. Plan9. 9front

Found a decent note on how to setup NTP on Plan9 on the bottom of that page:

Last, but not the least, you may also want to edit/change the TIMESYNCARGS in your /rc/bin/termrc or /rc/bin/cpurc; for example, to use an NTP service, set it to:

TIMESYNCARGS=(-n pool.ntp.org)

and reboot.

There is a command aux/timesync that is start from /rc/bin/termrc  It takes a DNS name of a time server as an argument.  If you modify the value set as default and reboot you should be good.

I ran it from the command line as a test and it worked

term% aux/timesync -n pool.ntp.org



Linux QEMU/KVM and 9front/Plan9 Networking

Oh man.  Where to begin.  Just getting the goddamn Linux bridge networking setup couldn’t have been more of a pain in the ass!  Then learning that the virtio network driver doesn’t work when using bridge networking.  Had to move to the old ass rtl8139 for it all to work.

Went from 1000MB/s down to 100MB/s instantly.


But at least I have it working now.  I am able to get a KVM instance running 9front on the network just like any other machine.  None of this NAT shit!

I will say this, once the KVM device configuration was figured out, Plan9 networking is WAY easier to configure than Linux.  Good fucking lord!

I may sing the praises of ndb for the rest of my days.  Why is Linux networking configuration so fucking hard?

Anyway, no more bitching.  Now onto getting a separate auth server setup and re-configuring this currently functioning box to be a fossil+venti fileserver.

Need hard drives!

Another resource for ndb and networking configuration.

Remaining goals for 2018

There is a lot I have to learn about Plan9.  I know most of what I need to know, but doing the following will round out my knowledge of the environment:

  1. Install and configure sectore – Now that I know how factotum works, I want my secrets stored in a centralized place, easily accessible from any machine.
  2. Install and configure venti – I need this for backups and dumps.
  3. Install and configure a CPU server – I would like to have numerous terminals open doing different things running on CPU’s on other servers.  Why not?
  4. Install and configure a separate ‘home’ file server – This will keep me from having to copy files from all over the damn place.
  5. Write a real 9p file server – I need to do this sooner or later.  Might as well do it sooner.  Most of the dev projects I want to do demand it.
  6. Port the Styx HTTP proxy from “Inferno Programming with Limbo” to C and 9front – I need something to work behind the corporate firewalls I am constantly behind
  7. Setup a 9front fileserver out on GCP – This will be interesting as it will, most likely, be a KVM instance on Linux.  If anyone has any other ideas please let me know.
  8. Port minilisp over to 9front – I already have done a Scheme Interp port, but it is very rudimentary.  Minilisp is much better example of a real Lisp interp.  It even has GC.
  9. Start working on the Game Engine and Audio Engine for 9front – TBD

We’ll see how it goes.

Removing CR;LF in files from other stupid systems

As we all know, some systems like to put carriage returns and line feeds in files.  Then when you transfer those files over to a sane system like 9front (Plan9) you have to deal with that bullshit!

Well here is how you get rid of that crap.


term% tr -d \x0d < stupidfile.txt > smartfile.txt

This will remove the legacy stink of those old OS’s you have been using.

Trick #1:  You can use this same command from within ‘acme’ to replace any selected block of text with these abominations within them.

  1. First find the offending text with the CRLF’s
  2. Select and highlight the ‘shit’ text within ‘acme’
  3. Type the following in the tag menu:
  4. | tr -d \xod
  5. Middle sweep/select/click the text above and PRESTO!  

The evil text has now been replaced with clean, beautiful chars with no CRLF’s

There is no ‘find’ command in Plan9?

Yes, on a 9p system there is no find command.  Why?  Because you don’t need it.  You do have the ‘du’ command which will dump a file tree.  Then just use the normal command line tools to filter out what you do not want.


term% du -a | grep -l ‘*.c’ | awk {print $2}

‘du’ produces the file tree from wherever you currently are.  The ‘grep’ command will select only those files with a ‘.c’ extension and ‘awk’ will select the 2nd column of information which happens to the be the full path to a file.

Stop your bitching!