- 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 17, 2023.
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
This document evolves over time – things change and old versions of Raspbian just stop being supported, and we try to make it work with the latest versions. I’ve generally had better luck with Buster compared to Bullseye, but we try to get both up and running.
All of these in records in the table below imply the general settings changes to the VICE config presented later in the document (VICE/PI General Settings I change regardless of version). Also, make sure to check out settings specific to the OS you’re using later in this document!
|OK For Use||Raspberry PI OS Version||VICE Version||Raspi 4B Status PAL||Raspi 4B Status NTSC||Raspi 400 Status PAL||Raspi 400 Status NTSC||Install Script Links|
|Yes||2023-02-21-raspios-bullseye-armhf-lite.img.xz||3.5 SVN/ Changelog / Tarball||OK!||OK!||OK!||OK!||GitHub / Raw|
|Yes||2023-02-21-raspios-buster-armhf-lite.img.xz||3.5 SVN/ Changelog / Tarball||OK!||OK!||OK!||OK!||GitHub / Raw|
|Yes||2023-02-21-raspios-bullseye-armhf-lite.img.xz||3.7.1 SVN / Changelog / Tarball||OK!||OK!||OK!||OK!||GitHub / Raw|
|Yes||2023-02-21-raspios-buster-armhf-lite.img.xz||3.7.1 SVN / Changelog / Tarball||OK!||OK!||OK!||OK!||GitHub / Raw|
Simplest way to execute the scripts is to copy the Raw link and on your raspberry pi console /ssh, do this:
wget -O - <raw script url> | bash
I’ve also added some test programs I can easily download from my VICE script github. I use these to test very basic SID/graphics functionality. Here are the credits to the great demo makers that made them:
delaytest.d64 – Written by the 8-bit guy – useful for testing lag, and also gives an audio ping each time you press a key. I start here for just the most basic ‘is this thing on?’ approach.
Booze Design – Remains (PAL) – Lovely haunting track. https://csdb.dk/release/?id=187524
SHAPE – Disco Apocalypso (PAL) – Up beat and great visuals. https://csdb.dk/release/?id=133935
Fairlight – 2600 (PAL) – https://csdb.dk/release/?id=197187
Style – Shine On (NTSC) – https://style64.org/release/shine-style – At least some graphics and smooth SID music for NTSC testing
Looking for more demos and such?
VICE/PI General Settings I change regardless of version
Unless noted here, I don’t change any system settings on my raspberry pi workbench setup, except for enabling Wifi and SSH, everything is is left as the default when Raspberry Pi OS installs.
These seem to be the best general settings for things to play smoothly on the PI. They mostly involve removing the raster line filter and adjusting audio settings.
- 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:
In C64 VICE Config form (/home/pi/.config/vice/sdl-vicerc, this looks like this:
[C64] MenuKey=293 MenuKeyUp=273 MenuKeyDown=274 MenuKeyLeft=276 MenuKeyRight=275 MenuKeyPageUp=280 MenuKeyPageDown=281 MenuKeyHome=278 MenuKeyEnd=279 SoundDeviceName="alsa" SoundSampleRate=22050 SoundBufferSize=50 AspectRatio="1.000000" VICIIVideoCache=0 VICIIDoubleScan=0 VICIIDoubleSize=0 VICIIFullscreen=1 VICIIFilter=0 SDLStatusbar=1 SidResidSampling=0 SidEngine=1 SidModel=2 ETHERNETCARTBase=56832 Acia1Base=56832
Sometimes, I mess with the sound sample rate when I’m capturing HDMI output and streaming It seems I need to set audio sample rate to 44100 to get my HDMI capture device to grab audio into OBS, but as far as the VICE/PI goes, I heard audio fine through my speakers. (
If you need to change your sample rate if you’re capturing output, you can try the various options in here: (Menu or config file)
- Sound Settings ->
- Frequency 44100 Hz
This generally sets a config file line:
VICE/PI Version specific settings I’ve changed
2023-02-21-raspios-buster-armhf-lite.img.xz / VICE specifics
Synopsis: Apply general settings and you’re good to go.
Raw Notes: After applying recommended generic settings, test programs ran fine (Before that, no so much). I was locked in at 100%/50fps using x64 and PAL/NTSC using the x64 binary. The x64sc binary still chews more CPU and runs slightly slower (naturally). I still recommend applying the generic settings I use though, since I had issues with NTSC (read on…)
However, on NTSC, I do notice the CPU/FPS drop from 100% to 80%, jump back up again. This was before applying my general settings. Once I applied those, everything worked well, no stutters or CPU drops.
2023-02-21-raspios-bullseye-armhf-lite.img.xz / VICE specifics
Synopsis: Apply general settings and change to fkms video driver, and then choose HDMI output in raspi-config.
Raw Notes: After executing the script and applying the generic settings, I noticed the strange 100% to 80% CPU drops go away. This has to be something with the audio layer, imho. Now, I just wasn’t getting audio (maybe on headphones on the 4B, but the 400 doesn’t have a headphone jack)
When I switched default audio to HDMI 0 in raspi-config, that broke ALSA in vice (error message), but I also noticed even when playing demos, the CPU was locked at 100%. Something with the sound layers… I’ve tried changing to SDL and I get no audio at all (I’m only in console mode, remember)
So, next, I tried the no longer supported but still available fkms overlay setting in /boot/config.txt. After setting that and rebooting, I was able to select HDMI in raspi-config and I got audio. So far, so good. I’m not happy about having to use fkms still for bullseye, but it at least got it working.
So, for me to get this working on Bullseye, I make the following changes:
- Make the general settings changes to sound/display in my general settings section (this is a must)
- Bring in fkms driver for HDMI audio:
Edit your /boot/config.txt and change the following:
# Enable DRM VC4 V3D driver dtoverlay=vc4-kms-v3d
# Enable DRM VC4 V3D driver dtoverlay=vc4-fkms-v3d
You must reboot after /boot/config.txt changes. You must also go into raspi-config and choose your audio device (this is how I was able to get VICE HDMI Audio on the 400)
Side note: I had flashing video artifacts on bullseye, but only when I was going through a USB HDMI capture device. Direct HDMI worked fine. Not sure why video is flashing so much when not going through the USB HDMI capture device on bullseye when it didn’t happen on buster at all. I’ve got another HDMI capture device I might use to see if it’s something specific with the flasher. Is there some refresh rate configuration difference between buster and bullseye? Same hardware, same firmware, just different OS versions and vice dependencies.
The rest of the document is a bit of a ramble since these versions change all the time but it covers the high level.
To that end, given all the changes that constantly happen in VICE, PI, and such, the video below is no longer 100% accurate. It still covers the general setup tasks, but the script is the source of truth as versions and methods change over time.
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.
Write The Raspberry Pi 4 Image
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) – This is purely optional – I used it because I’m hooking up some custom circuits to my Pi.
- Allow SSH interface access (so we can copy/paste from a Windows SSH client) – Optional if you just want to type all the commands directly to your Pi console.
- 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
Download and execute the install script
I’ve created a few scripts for various versions to do all this work on a Pi Install. Check the table at the very start of this document for matching scripts to install based on your PI or VICE or PI OS version (Yeah, it can be that twitchy). Download the script you want, chmod +x the script, and run it. Look it over yourself if you’re concerned about just running some guy’s script.
You can execute your script directly by doing this if you don’t feel like downloading it, chmod-ing it, and executing it manually:
wget -O - https://raw.githubusercontent.com/erkrystof/vice/master/<insertscriptnamehere>.sh | bash
What the script does at a high level:
- Performs the general sudo apt update/upgrade
- Downloads SDL from libsdl.org
- Compiles and installs SDL and other SDL libraries
- Downloads VICE compilation dependencies
- Downloads VICE source code from sourceforge.net
- Configures VICE to enable fast-sid options and the x64 ‘old’ binary build (as well as the new binary x64sc)
- Installs VICE into your home directory (/home/pi/vice-<version-number>) – Because I dislike /usr/local for vice.
- Binaries will be in the bin directory of where we installed VICE. You’d generally run x64 for the ‘older’ but smoother for PAL Demos binary, or the x64sc (technically more accurate, but uses more CPU and causes PIs to stutter in demos)
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.
Why compile SDL on the Pi?
We used to have to do this from a fork from Retropie, and in previous cases before that I could just install the sdl libraries and use those. However, I’ve found that every time I try to do that with the latest versions of Raspi-OS and VICE, I end up getting an SDL related error trying to draw the screen when launching from the console – so for now, I compile the SDL libraries on the Pi and things seem to work. In previous versions of Buster, I couldn’t get this to work from SDL directly, I had to use RetroPie’s fork and manipulations on some videocore headers. I no longer need to do that for what I’m assuming are changes in the OS version over the past couple of years.
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.
Apply generic settings for sound/video options in VICE.
See the VICE/PI General Settings I change regardless of version section for that. Also, if you’re in Bullseye, there are some specific tweaks in the Bullseye section to apply.
Download a demo and see it perform horribly or wonderfully?
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 ./x64 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.
Noticing stuttering and other issues? Look at the settings in the top part of the document that I apply generically as well as for certain OS/VICE combinations and try those.
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.6.1 **
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