Howto: Convert a K6-2 into a C64

Edit: Unfortunately, the images originally included in this post are gone, because of hosting problems in late 2009. My apologies.

This came about when I saw the X-Amiga thread on the forums, and saw screenshots (of the installer, anyway) for that distro — one that more or less defaults straight to a pseudo-Amiga environment.

What if, I thought, you could boot straight into VICE, with no visible window manager and with very few traces of Linux underneath that? Maybe it would look like …

That’s Gutsy there, with a couple of subtle tricks happening. First of all, that’s Openbox controlling the VICE window and terminal screen you see. The root window (the wallpaper, that is) is set to match the VICE bracket around the C64 porthole.

After that, it becomes a trick of fonts and theming. The Openbox theme is stripped of the border setting, so there’s no visible box around any of the windows. The colors match the screen output given via gcolor2, so the terminal and the menu selections match the old blue color of the default background. And so forth and so on.

Another small obstacle: As far as I can tell, and I spent an hour or so searching, Openbox has no way of triggering an undecorated window at its inception. You can center windows by default through the new ObConf, but you can’t force them to appear undecorated. Once they’re on screen you can undecorate them manually, but not as they’re spawned.

In that sense, it might have been ideal to go window manager-less, but that causes another problem — X doesn’t seem to have a provision for spawning applications anywhere but in the upper left corner. And without a window manager, you can’t easily move windows around the screen. So it was a bit of a Catch-22: I could spawn borderless windows, but only in the upper left corner; or I could spawn windows that were centered, but came with frames.

To solve both of those problems, I used the aptly named devilspie. By running it when X starts, and telling it to catch VICE when it pops up, you can strip the emulator of its borders and force it to the center of the screen — killing two birds with one stone.

To do something like this, set up a command-line installation of Ubuntu, and add xorg and Openbox. Add or subtract whatever packages you like, basically setting up the system as you see fit. I added almost nothing, using only rxvt-unicode and a few fundamental additions to Openbox.

(If you do build this on a command-line installation, it helps to set up an autologin executable and to trigger startx on login. Just so you don’t have to keep logging in and typing that command. šŸ˜‰ )

After that, install VICE, either from the repositories or from scratch (I strongly recommend installing from scratch). Set VICE to start up in double size, and save those settings.

Then get devilspie from the repositories, and create a .devilspie folder in your home directory. Make a file inside called C64.ds, and put this in it.

(if (is (application_name) "C64") (begin (center) (undecorate)))

That’s all. Save and close.

Next, open your .xinitrc file, and make it look something like this.

xsetroot -solid "#cecece"
devilspie &
x64 &
exec openbox

#CECECE is the hex code for the color of the VICE bracket. Matching the root window to that bracket gives the illusion that the emulator is anchored seamlessly to the root window, even if it’s still floating.

x64 is the trigger for the emulator, but notice that the application name — the title that devilspie needs to catch — is C64: That’s why it’s in the configuration line for devilspie. And of course, the last line passes control to Openbox.

Update: Thanks to billy for pointing out how to do this in Openbox, without using devilspie. (It figures: I comb the Web for an hour, trying to figure out how to spawn undecorated windows, and all the time it’s right under my nose. …)

Inside your ~/.config/openbox/rc.xml file, near the bottom, there’s a section called “applications.” Ordinarily it’s commented out, so modifying that part of the file won’t have any effect. Remove the leading comment markers (it looks like greater-than-exclamation point-dash-dash), and the trailing one as well (same, but without an exclamation point).

Then adjust it to say this.

  <application name="C64">
    <decor>no</decor>
    <shade>no</shade>
    <position>
      <x>center</x>
      <y>center</y>
    </position>
    <focus>yes</focus>
    <desktop>1</desktop>
    <head>0</head>
    # specifies xinerama head
    <layer>normal</layer>
    # 'above', 'normal', or 'below'
    <iconic>no</iconic>
    <skip_pager>no</skip_pager>
    <skip_taskbar>no</skip_taskbar>
    <fullscreen>no</fullscreen>
    <maximized>false</maximized>
    # 'Horizontal', 'Vertical' or boolean (yes/no/on/off/true/false)
  </application>

You can modify those settings as you like, putting it on certain desktops, heads, etc. You’ll need to restart (not reconfigure) Openbox if you want them to take effect immediately. Note that those settings will apply any time you start x64, either at startup or from elsewhere.

Now if you want icing on the cake, you can use the Adore64 font on FreakyFonts.de for the urxvt console font, Openbox window font and GTK2 font. (Again, Openbox will need restarted — not reconfigured — for that font to take effect. I don’t know why, but it did for me.)

Setting up urxvt is fairly easy; add these lines to your .Xdefaults file.

urxvt.font: xft:Adore64:autohint=false:antialias=false:size=6
urxvt.background: #3a319c
urxvt.foreground: #7b71d6
urxvt.scrollBar: false
urxvt.cursorBlink: true
urxvt.geometry: 40x25

Those hex codes, again, match the startup light blue and blue presented by VICE. Use that Adore64 font at sizes that at multiples of 6 — odd sizes get antialiased, which makes it smear. Avoid the bold effects too, since they also cause visual problems. The geometry sets the window to the C64-ish 40×25, and the cursor blink is … well, you know what that’s for.

If you want, I’ve put together an C64-Openbox Theme that mimics the colors and font of the C64 startup screen. It’s not fantastic, but it is a starting point if you’re a heavy-duty themer. Remember that you’ll have to rename that file to an .obt extension (because of WordPress.com’s lame filename extension requirements), but then you should be able to install it through ObConf.

For a GTK2 theme I’d suggest Rezlooks-royale, which is fairly close to the C64’s blue shades. If you find yourself using many GTK2 applications, you might tweak those colors to be closer to the “real thing.”

What you add above and beyond that will depend on how much function or access you need. If you want to be able to surf for disk images you’ll need a browser of some sort, and you might want a file manager. For my own purposes I was content to stick with wget and console commands.

Overall, it’s a gimmick, but kind of a kick. If you still spend your spare time playing Jumpman and Bruce Lee, like I do, you’ll have a bit of fun setting it up.

P.S.: devilspie is a really cool utility that has a lot of potential. For more ideas on how to use it, check these threads and sites.

How To Set Default Workspace, Size and Window Effects in Gnome
post your devilspie config files with screenshot
Devilspie (version 0.13 and greater) s-expressions examples

And if you just want to set up a terminal with the classic C64 font, you might prefer to use the BDF font posted on this page.

10 thoughts on “Howto: Convert a K6-2 into a C64

  1. billy

    You can have undecorated windows. Add this to your rc.xml to remove all decorations:

    no

    Or replace * by the application name you want to remain undecorated

    Reply
  2. billy

    Hmm that didn’t show up…

    (applications)
    (application class=”*”)
    (decor)no(/decor)
    (/application)

    Replace the ( by and it should work.

    Reply
  3. billy

    Silly codes… The brackets should be replaced by those pointy (<) ones (whatever they are called).

    Reply
  4. K.Mandla Post author

    That worked for me, after a little bit of tweaking. I’ll update that as an alternative to using devilspie. Thanks! šŸ˜€

    Reply
  5. Methanoid

    How about packaging like X-Amiga did and releasing to the world? Or an easy installer or something?

    Reply
  6. K.Mandla Post author

    Oh geez. I don’t know if I want to get into that. I suppose I could bash script all that stuff together, but I don’t know. … šŸ˜

    Reply
  7. Pingback: Toward a better C64 terminal « Motho ke motho ka botho

  8. Pingback: Linux does C64 does Unix « Motho ke motho ka botho

Leave a comment