- 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 July 12, 2022.
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 evolves over time. Also note I’m using BUSTER. I have a Raspios BULLSEYE script that seems to work, but I’ve not tested it much and it seemed to be slightly laggy when I was running demos, and I also lost capability of routing audio out of HDMI – only my headphone jack worked. Sticking with BUSTER for now.
Here are the relevant versions for this article and install script:
- Raspbian Pi OS Lite 2022-04-04-raspios-buster-armhf-lite
- SDL 2.0.22
- VICE 3.6.1 January 4, 2022
To that end, 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.
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 4 Image
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) – 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
Step 3 – Download and execute 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.
I execute it with this command directly:
wget -O https://raw.githubusercontent.com/erkrystof/vice/master/install-vice-3.6.1-buster-raspi-4.sh | bash
I’ve also decided to just script most of this out, where the script handles these steps:
- 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.
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.
Setting the Video Driver in Raspi-Config (No more!)
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 4 – 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 ./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.
However, this new build of VICE 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 the above settings 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 5 – 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