- The ‘Working’ Commodore 64/128 Diorama and Raspberry Pi VICE Emulator
- -> Installing the VICE Commodore Emulator for Console Mode on a fresh Raspberry Pi 4
- Mirroring Raspberry Pi HDMI Video to a ST7789 1.3 inch LCD Display
- Patching the VICE emulator to light up floppy drive LEDs
Last Updated on March 8, 2021.
At the time of this writing, there’s no binary package ready to install on the Raspberry Pi 4. Also, I need to make sure I can run the VICE emulator on the console and not in X-Windows for my diorama project. That install isn’t difficult but isn’t a single line or two either, so we’ll start from scratch on a fresh Raspbian lite install. This article assumes some familiarity with how VICE works. Let’s install VICE on a Raspberry Pi 4!
Raspberry Pi 4 Version Log
See below for the versions of Raspberry Pi OS and VICE used – this document has evolved over time.
This guide has been updated to reference the following versions, and was last updated on 3/7/2021.
- Raspbian Pi OS Lite January, 11, 2021
- SDL 2.0.14
- VICE 3.5 December 24, 2020
To that end, the video below is no longer 100% accurate. It still covers the general setup tasks, but SDL’s compile has changed.
Step 0 – Hardware before the Software
This part is pretty simple – you’ll need:
- Raspberry Pi 4 Model B, or Raspberry Pi 3B+
- Micro SD Card (we’re generally at the days of 16GB or higher)
- Micro HDMI cable (or full HDMI if you’re using a Raspberry Pi 3B+)
- Keyboard / Mouse for initial setup, Wifi connectivity for later SSH connectivity.
Step 1 – Write The Raspberry Pi 4Image
Step 2 – Boot the Raspberry Pi and get connected.
We know our default password is raspberry and our default user name is pi. You should change these if you’re going to keep this install around. Regardless, we need to set just a couple of things before we start with VICE – such as my desire for SSH access so I could copy/paste commands more easily. Here are those steps after you give yourself a good old fashioned
- Set hostname to vice-pi-install (This makes it unique and through bonjour lets me access it from my Windows PC as vice-pi-install.local.)
- Set WIFI up to my access point (Country Code and SSID)
- Allow SPI interface access (my diorama is going to be controlling an LCD through SPI)
- Allow SSH interface access (so we can copy/paste from a Windows SSH client)
- Setup locale, keyboard, etc.
- Verify Internet Connectivity (ping google.com)
- Perform your normal
apt update / apt upgradecommands to update your system.
sudo apt update sudo apt upgrade
Step 3 – Download the install script
I’ve created a script that does this on a fresh Pi install. You can just download it, chmod +x the script, and run it. Look it over yourself if you’re concerned about just running some guy’s script.
It’s available here: https://raw.githubusercontent.com/erkrystof/vice/master/install-vice-3.5-raspi-4.sh
I execute it with this command directly:
wget -O - https://raw.githubusercontent.com/erkrystof/vice/master/install-vice-3.5-raspi-4.sh | bash
I’ve also decided to just script most of this out, but I’ll cover the main points:
- Performs the general sudo apt update/upgrade
- Downloads SDL 2.0.14 from a fork of RetroPie’s fork of SDL2 with pi specific modifications
- Enables kmsdrm, video-rpi, and a few other tweaks
- Compiles and installs the modified SDL2.0.14 library – this is based off not SDL itself but RetroPie’s SDL mirror for 2.0.14
- Downloads VICE 3.5 compilation dependencies
- Downloads VICE 3.5 source code from sourceforge.net
- Configures VICE to enable fast-sid options and the x64 ‘old’ build
- Installs VICE into your home directory (/home/pi/vice-<version-number>) – Because I dislike /usr/local for vice.
The latest version of the script will always be at the link above. It’s configured so if it runs into any error, it aborts. The script should be re-runnable except for the piece where we move some videocore headers around, you may need to ‘undo’ that and re-run the script at this point if it breaks in that area.
Why enable kmsdrm?
I’m not in a window environment, so we need to enable the kmsdrm video driver in SDL 2 for our VICE compile. Why? We want to run VICE from the console. Unfortunately, the SDL2 libraries from package repositories don’t have the kmsdrm driver piece enabled, so we’ll make our own. I’ll use a separate directory called sdl-work in my home directory.
We will build SDL2-2.0.14 from RetroPie’s fork that has Raspberry Pi specific modifications. Part of the compilation below is from RetroPie’s SDL 2.0 install script. To learn more about the excellent RetroPie project, head on over to their site here. I’ve made a fork off that repo and that’s where I’m pulling from in my script – it’s just in case I need to make any tweaks.
Step 4 – Setting the Video Driver in Raspi-Config
This step seems to no longer be necessary! We used to have to go into raspi-config and enable the ‘Fake KMSDRM’ driver, but with changes to how we’re building SDL compared to prior versions, there doesn’t seem to be that need to change the driver configuration anymore.
Step 5 – Download a demo and see it perform horribly
I downloaded a simple demo from csdb.dk by Booze Design known as ‘The Elder Scrollers‘. Downloaded the .D64 file and uploaded that to the VICE Pi. Moving into the /home/pi/viceinstall/bin directory, I typed ./x64sc and was greeted with an old blue friend:
Now, depending on how this all comes together, you might have a really tiny C64 screen in the corner of your big monitor. Simply hit F12, scroll down to Video Settings -> Screen Settings -> Fullscreen.
However, this new build of VICE 3.5 and the latest Raspberry Pi OS had horrible performance right away. I noticed stuttered audio, general sluggishness, and just generally worse performance than I experienced with Buster Lite and VICE 3.4. I do remember reading about a change in VICE 3.5 that may be part of the issue – they did away with some synchronization of audio in their build, to this effect:
- Emulator timing is now directly driven by the host system audio device. If sound emulation is disabled, timing is synchronized with the host clock. As part of this change, the choice of sound synchronization method has been removed. -https://vice-emu.sourceforge.io/NEWS
I also noticed this flooding my SSH console:
Warning - sync is far too late, resetting sync
Here’s where things get strange. I think the combination of two things made the demos perform better:
- Only execute from the console window (don’t let your SSH session get flooded with the above log statements)
- Apply these settings in your VICE Config:
- Machine Settings -> Model Settings -> SID Settings:
- SID Model -> 8580 + digi boost (ReSID)
- reSID sampling method -> Fast
- Video Settings -> Size Settings
- Disable double size
- Disable double scan
- Select Fullscreen
- Video Settings -> Render filter
- Select ‘None’
- Sound Settings
- Buffer size 50msec
- Frequency 22050 Hz
- Machine Settings -> Model Settings -> SID Settings:
After that, I made sure to exit and restart the emulator.
The settings above caused the x64 binary to write this reference config file I have: (/home/pi/.config/vice/sdl-vicerc)
Something may still be strange about why the stuttering appears, but this fixed it for me. It definitely didn’t feel like one change alone was going to do it. Nevertheless, once I made those changes, demos ran more smoothly. I haven’t done deep tests of joysticks and other parts yet, but sound doesn’t stutter and graphic motion is smooth again.
Step 6 – Apply settings and watch a demo perform smoothly
Finally, after modifying my settings, restarting VICE, and after autostarting the demo image I downloaded, I was able to sit back and enjoy classic SID sound from the Elder Scrollers demo:
With that, we finish the install of VICE on a Raspberry Pi 4 in console mode as the foundation of my Diorama 64 project. Any thoughts or concerns, things that didn’t work well for you with your install? Leave a comment down below or join the discord at https://discord.gg/wbngTy8 and we can chat. Next up: the Raspberry Pi 4 and the LCD display turned monitor.
Raspberry Pi 3B+ Instructions
** May not work, I have NOT updated this yet for VICE 3.5 **
Generally, the build is very similar. I’m going to skip all the discussion points and run down what I think seems to work on a Raspberry Pi 3B. The key differences are how we build SDL. I didn’t seem to need to change any graphic related driver setting to get this to work.
sudo apt update sudo apt upgrade #SDL for Raspi-3B dependencies sudo apt-get install libfontconfig-dev qt5-default automake mercurial \ libtool libfreeimage-dev libopenal-dev libpango1.0-dev libsndfile-dev \ libudev-dev libtiff5-dev libwebp-dev libasound2-dev libaudio-dev \ libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxss-dev \ libesd0-dev freeglut3-dev libmodplug-dev libsmpeg-dev libjpeg-dev mkdir ~/sdlwork cd ~/sdlwork hg clone http://hg.libsdl.org/SDL cd SDL ./autogen.sh ./configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland \ --disable-video-opengl --host=arm-raspberry-linux-gnueabihf make sudo make install cd ~/sdlwork wget http://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz wget http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.tar.gz wget http://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.0.1.tar.gz wget http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz tar zxvf SDL2_image-2.0.5.tar.gz tar zxvf SDL2_mixer-2.0.4.tar.gz tar zxvf SDL2_net-2.0.1.tar.gz tar zxvf SDL2_ttf-2.0.15.tar.gz cd SDL2_image-2.0.5 ./autogen.sh ./configure make sudo make install cd .. cd SDL2_mixer-2.0.4 ./autogen.sh ./configure make sudo make install cd .. cd SDL2_net-2.0.1 ./autogen.sh ./configure make sudo make install cd .. #Interestingly enough TTF builds just fine on the 3B. cd SDL2_ttf-2.0.15 ./autogen.sh ./configure make sudo make install cd .. #Now, on to VICE for the Raspi 3B sudo apt install libmpg123-dev libpng-dev zlib1g-dev libasound2-dev libvorbis-dev libflac-dev \ libpcap-dev automake bison flex subversion libjpeg-dev portaudio19-dev texinfo xa65 mkdir ~/vicework cd ~/vicework #3.4 is the latest VICE release svn checkout svn://svn.code.sf.net/p/vice-emu/code/tags/v3.4/ cd ./v3.4/vice ./autogen.sh ./configure --prefix=/home/pi/viceinstall --enable-sdlui2 --without-oss --enable-ethernet \ --disable-catweasel --without-pulse make -j $(nproc) # I got an error here for the running of make install - you may or may not need to do the sudo. sudo make install #after this point, I went directly to the vice install directory and ran it cd ~/viceinstall/bin ./x64sc
- Balena Etcher
- Enabling Bonjour for your Raspberry Pi
- VICE Homepage
- Lemon 64 Thread on Custom SDL Build
- SDL on Raspi (for 3B compile)
- Compiling SDL2 from source
- x64 vs x64sc VICE binaries
- The Elder Scrollers Demo