Configure Sublime Editor with KickAss on Debian 8 Jessie

After a long time I got the urge to code something for our bellowed Commodore 64. Since it’s a pain to do it on a real machine, it takes a lot of time to set everything up since I do not have permanent location for my C64 in the apartment.

I decided to use Sublime editor with KickAss and VICE emulator.

Since KickAss is java application you need to make sure you have proper java version to run it. By default Debian 8 (jessie) has openjdk-7-jre and openjdk-7-jre-headless packages installed, which are not compatible with KickAss.

You can check the default java version with command:

# java -version
 java version "1.7.0_111"
 OpenJDK Runtime Environment (IcedTea 2.6.7) (7u111-2.6.7-1~deb8u1)
 OpenJDK 64-Bit Server VM (build 24.111-b01, mixed mode)

If you try to compile any source with this Java version you will get following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: kickass/KickAssembler : Unsupported major.minor version 52.0
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

First thing you need to do is to install jdk-8 with following command:

apt-get install openjdk-8-jre

If you do not remove old java version it will still be the default one used on your system.

In order to use your newly installed Java 8 you need to update alternatives with command:

# update-alternatives --config java
 There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
 ------------------------------------------------------------
 * 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
  1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
  2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 manual mode

Press enter to keep the current choice[*], or type selection number: 2

After selecting Java 8 and pressing enter you will get confirmation message:

update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

Check if correct java version is configured:

$ java -version
 openjdk version "1.8.0_102"
 OpenJDK Runtime Environment (build 1.8.0_102-8u102-b14.1-1~bpo8+1-b14)
 OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

Next thing you need is to install Sublime Text Editor. Since there is no package for Debian, you can use Ubuntu package, by downloading it from following link amd64 (64bit) or i386 (32bit). Or visit Sublime homepage by clicking this link.

Install the package manually with:

dpkg -i sublime-text_build-3126_amd64.deb

Download Kick Assembler from http://theweb.dk/KickAssembler/ and extract it to any path you like. In my case the path to the file is: ~/C64/bin/.

You need to update your CLASSPATH variable, which is not set by default in Debian so you need to append this to your ~/.bashrc file:

CLASSPATH=~/C64/bin/KickAss.jar:$CLASSPATH
 export CLASSPATH

Remember you need to re-login or start new shell window in order to get this loaded. You can check by echoing $CLASSPATH:

$ echo $CLASSPATH
 /home/erol/C64/bin/KickAss.jar:

After this is done install VICE emulator by using standard apt-get command:

apt-get install vice

Start sublime editor by running command:

subl

When Sublime is started install Package Control by pressing CTRL+` and paste this to console window part:

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

More info about this procedure you can find on this page.

From Preferances > Package Control chose Install Package and type KickAss then select Kick Assembler (C64) .

Make sure KickAssembler (C64) is selected as Build System:

kickass4

You can first check if KickAss is working by compiling one of the provided examples in my case path where KickAss is installed is “C64/bin/KickAss.jar” so the command looks like this:

java -jar C64/bin/KickAss.jar C64/bin/Examples/01.MusicIrq/MusicIrq.asm
 //------------------------------------------------------
 //------------------------------------------------------
 // Kick Assembler v4.3 by Mads Nielsen 
 //------------------------------------------------------
 //------------------------------------------------------
 parsing
 flex pass 1
 flex pass 2
 flex pass 3
 Output pass

Memory Map
 ----------
 $0801-$080d Basic
 $080e-$080d Basic End
 $1000-$2290 Music
 $4000-$405e Main Program

Writing file: C64/bin/Examples/01.MusicIrq/MusicIrq.prg
 Writing Symbol file: C64/bin/Examples/01.MusicIrq/MusicIrq.sym

Now load that same file in Sublime and press CTRL+B. Output in the lower part of the screen should be same as the above.

kickass2

If you selected to run it after compilation program will run in your X64 emulator (VICE).

kickass3

UPDATE: I found an easier way to setup CLASSPATH variable before starting the sublime editor. Just edit the icon for sublime editor and prefix it to look like this:

export CLASSPATH=/home/erol/C64/bin/KickAss.jar;/opt/sublime_text/sublime_text %F

With this you do not need to edit your .bashrc if you are going to start the editor via shortcut icon.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.