<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="https://publishpress.com/"
	>

<channel>
	<title>Commodore Archives - Krystof.IO</title>
	<atom:link href="https://krystof.io/tags/commodore/feed/" rel="self" type="application/rss+xml" />
	<link>https://krystof.io/tags/commodore/</link>
	<description>Numerous hobbies, various ramblings.</description>
	<lastBuildDate>Fri, 17 Mar 2023 15:34:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.9</generator>

<image>
	<url>https://krystof.io/wp-content/uploads/2019/10/cropped-site-icon-low-32x32.jpg</url>
	<title>Commodore Archives - Krystof.IO</title>
	<link>https://krystof.io/tags/commodore/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Retro Gaming PC Build Log Part 2 : Commodore 64</title>
		<link>https://krystof.io/retro-gaming-pc-build-log-part-2-commodore-64/</link>
					<comments>https://krystof.io/retro-gaming-pc-build-log-part-2-commodore-64/#respond</comments>
		
		<dc:creator><![CDATA[Eric R. Krystof]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 01:10:25 +0000</pubDate>
				<category><![CDATA[Retro Gaming]]></category>
		<category><![CDATA[Commodore]]></category>
		<category><![CDATA[VICE]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Emulation]]></category>
		<category><![CDATA[Build Log]]></category>
		<guid isPermaLink="false">https://krystof.io/?p=1882</guid>

					<description><![CDATA[<p>Working through LaunchBox and VICE emulator configs for Commodore 64 game emulation</p>
<p>The post <a rel="nofollow" href="https://krystof.io/retro-gaming-pc-build-log-part-2-commodore-64/">Retro Gaming PC Build Log Part 2 : Commodore 64</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Figured I&#8217;d start off with my favorite system &#8211; The Commodore 64.  Here are the key software components I used:</p>



<figure class="wp-block-table"><table><tbody><tr><td><a href="https://c64preservation.com/dp.php?pg=nibtools" target="_blank" rel="noreferrer noopener">Nib Tools</a></td><td>Used to convert any images that are .nib format to .G64 format that VICE can read.  D64 images are for unprotected (no copy protection) disks, while  .g64 and .nib are two formats that retain all of the copy protection.  So we&#8217;re going from NIB -&gt; G64</td></tr><tr><td>VICE 3.6.1 (<a href="https://vice-emu.sourceforge.io/windows.html" target="_blank" rel="noreferrer noopener" class="broken_link">Windows 64-bit SDL version</a>)</td><td>VICE is the emulator I&#8217;m most familiar with from my Diorama project and RetroPie tinkering, so I&#8217;ll continue with that here, same reason for the SDL version over GTK3.  </td></tr></tbody></table></figure>



<h2 class="wp-block-heading" id="h-nibconv-and-nib-disks">Nibconv and .NIB disks</h2>



<p>I have some disk images that are already the D64 or G64 type, and some that are .NIB.  I need to convert those using the nibconv from the Nib Tools package first.  A simple batch file that worked for me (drop it in the folder where you have nibconv.exe and .NIB files and it will handle the rest.  It deletes the G64 file first since mine would lock if the file already existed.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
for %%f in (*.nib) do (
	del &quot;%%~nf.g64&quot;
	nibconv &quot;%%~nf.nib&quot; &quot;%%~nf.g64&quot;
)
pause
</pre></div>


<h2 class="wp-block-heading">VICE install</h2>



<p>VICE doesn&#8217;t install &#8211; it just unpacks into a directory.  I put mine in a common emulators folder D:\Emulators\SDL2VICE-3.6.1-win64.  Underneath there are all sorts of binaries and such but the primary one is x64sc, and that&#8217;s what I&#8217;ll be configuring as I test out some games.</p>



<h2 class="wp-block-heading">First LaunchBox import and adding VICE as an emulator</h2>



<p>I put my Bruce Lee G64 file in a temporary directory just to try this out.  I&#8217;m going to let LaunchBox manage the Commodore 64 ROM files necessary, so it will &#8216;move it&#8217; into the LaunchBox Games directory on import:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" src="https://krystof.io/wp-content/uploads/2022/08/image.png" alt="" class="wp-image-1892" width="542" height="399" srcset="https://krystof.io/wp-content/uploads/2022/08/image.png 722w, https://krystof.io/wp-content/uploads/2022/08/image-300x221.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-585x431.png 585w" sizes="(max-width: 542px) 100vw, 542px" /></figure></div>

<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-1.png" alt="" class="wp-image-1893" width="545" height="404" srcset="https://krystof.io/wp-content/uploads/2022/08/image-1.png 727w, https://krystof.io/wp-content/uploads/2022/08/image-1-300x222.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-1-585x434.png 585w" sizes="(max-width: 545px) 100vw, 545px" /></figure></div>


<p>Now here is where I may deviate from most.  I like the <em>idea</em> of RetroArch, and perhaps I&#8217;ll revisit it in the future, but I found while I can create global configurations to be shared across multiple emulators, I really liked having features in the later versions of emulators that don&#8217;t have an updated RetroArch core, or the core has crippled some features I desire.  So in general, I rarely use RetroArch at this time.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-2.png" alt="" class="wp-image-1894" width="548" height="409" srcset="https://krystof.io/wp-content/uploads/2022/08/image-2.png 731w, https://krystof.io/wp-content/uploads/2022/08/image-2-300x224.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-2-585x436.png 585w" sizes="(max-width: 548px) 100vw, 548px" /><figcaption>This page REALLY messed me up.  It actually populated RetroArch into the Associated Platforms list of the &#8216;Manually Configured Emulator&#8217;.  So I had to wipe those out (read on to see how that was diagnosed)</figcaption></figure></div>

<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-3.png" alt="" class="wp-image-1928" width="549" height="413" srcset="https://krystof.io/wp-content/uploads/2022/08/image-3.png 732w, https://krystof.io/wp-content/uploads/2022/08/image-3-300x225.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-3-585x440.png 585w" sizes="(max-width: 549px) 100vw, 549px" /></figure></div>


<p>For starters, all I&#8217;m populating is the name (VICE 64) and the location to x64sc.exe (The VICE C64 binary)</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="564" height="111" src="https://krystof.io/wp-content/uploads/2022/08/image-4-edited.png" alt="" class="wp-image-1932" srcset="https://krystof.io/wp-content/uploads/2022/08/image-4-edited.png 564w, https://krystof.io/wp-content/uploads/2022/08/image-4-edited-300x59.png 300w" sizes="(max-width: 564px) 100vw, 564px" /></figure></div>


<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="732" height="176" src="https://krystof.io/wp-content/uploads/2022/08/image-6.png" alt="" class="wp-image-1934" srcset="https://krystof.io/wp-content/uploads/2022/08/image-6.png 732w, https://krystof.io/wp-content/uploads/2022/08/image-6-300x72.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-6-585x141.png 585w" sizes="(max-width: 732px) 100vw, 732px" /></figure>



<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="733" height="129" src="https://krystof.io/wp-content/uploads/2022/08/image-7.png" alt="" class="wp-image-1935" srcset="https://krystof.io/wp-content/uploads/2022/08/image-7.png 733w, https://krystof.io/wp-content/uploads/2022/08/image-7-300x53.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-7-585x103.png 585w" sizes="(max-width: 733px) 100vw, 733px" /></figure>



<p>I let it populate all the checkboxes for both LaunchBox and EMU Movies.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-8.png" alt="" class="wp-image-1936" width="548" height="410" srcset="https://krystof.io/wp-content/uploads/2022/08/image-8.png 731w, https://krystof.io/wp-content/uploads/2022/08/image-8-300x224.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-8-585x437.png 585w" sizes="(max-width: 548px) 100vw, 548px" /></figure></div>

<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-9.png" alt="" class="wp-image-1937" width="543" height="403" srcset="https://krystof.io/wp-content/uploads/2022/08/image-9.png 724w, https://krystof.io/wp-content/uploads/2022/08/image-9-300x223.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-9-585x434.png 585w" sizes="(max-width: 543px) 100vw, 543px" /></figure></div>


<p>I leave these options as default:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="549" height="309" src="https://krystof.io/wp-content/uploads/2022/08/image-10.png" alt="" class="wp-image-1938" srcset="https://krystof.io/wp-content/uploads/2022/08/image-10.png 549w, https://krystof.io/wp-content/uploads/2022/08/image-10-300x169.png 300w" sizes="(max-width: 549px) 100vw, 549px" /></figure></div>

<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="722" height="204" src="https://krystof.io/wp-content/uploads/2022/08/image-11.png" alt="" class="wp-image-1939" srcset="https://krystof.io/wp-content/uploads/2022/08/image-11.png 722w, https://krystof.io/wp-content/uploads/2022/08/image-11-300x85.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-11-585x165.png 585w" sizes="(max-width: 722px) 100vw, 722px" /></figure></div>


<p>After searching the online databases for media, I now show Bruce Lee in my LaunchBox main view:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="628" height="420" src="https://krystof.io/wp-content/uploads/2022/08/image-12.png" alt="" class="wp-image-1940" srcset="https://krystof.io/wp-content/uploads/2022/08/image-12.png 628w, https://krystof.io/wp-content/uploads/2022/08/image-12-300x201.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-12-585x391.png 585w, https://krystof.io/wp-content/uploads/2022/08/image-12-263x175.png 263w" sizes="(max-width: 628px) 100vw, 628px" /></figure></div>


<h2 class="wp-block-heading">Testing the first game &#8211; Failure and Fix</h2>



<p>Double clicking on Bruce Lee does&#8230; nothing.  I see nothing.  I got nothing.  What gives?</p>



<p>I decide to launch the emulator directly (x64sc.exe in the VICE directory) and it worked fine:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-13.png" alt="" class="wp-image-1943" width="338" height="272" srcset="https://krystof.io/wp-content/uploads/2022/08/image-13.png 676w, https://krystof.io/wp-content/uploads/2022/08/image-13-300x241.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-13-585x470.png 585w" sizes="(max-width: 338px) 100vw, 338px" /></figure></div>


<p>I then decided to load the G64 image directly through VICE, bypassing LaunchBox.  Result:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-14.png" alt="" class="wp-image-1944" width="336" height="268" srcset="https://krystof.io/wp-content/uploads/2022/08/image-14.png 671w, https://krystof.io/wp-content/uploads/2022/08/image-14-300x239.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-14-585x466.png 585w" sizes="(max-width: 336px) 100vw, 336px" /></figure></div>


<p>Okay.  So now I now there&#8217;s something up with LaunchBox dealing with VICE.  I&#8217;m actually used to loading VICE first on my RetroPie and loading the image directly.  So this means I&#8217;ve got a command line argument issue.  Turns out LaunchBox tried to force my hand with RetroArch even though I wanted to configure the emulator manually!</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="288" height="224" src="https://krystof.io/wp-content/uploads/2022/08/image-16.png" alt="" class="wp-image-1946"/><figcaption>I didn&#8217;t ask for this, and I don&#8217;t want it.  It also pre populated entries in the &#8216;Associated Platforms&#8217; screen which causes it to think it needs a -f parameter and a RetroArch core.  </figcaption></figure></div>


<p>Perhaps I should have set the emulator up first, but if you run into this, you&#8217;ll see in your emulator config under &#8216;associated platforms&#8217; a WIDE list of items, and they also populate well known RetroArch cores.  </p>



<p>I missed the little &#8216;pop up&#8217; that stated it populated RetroArch for me.  I wish it hadn&#8217;t done that, it caused me a small headache.  So I went back into my VICE config and wiped out ALL of the associated platforms, left that tab, went back to an empty one (so it doesn&#8217;t show the RetroArch core column), and added one entry for Commodore 64 like so:</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="143" src="https://krystof.io/wp-content/uploads/2022/08/image-15-1024x143.png" alt="" class="wp-image-1945" srcset="https://krystof.io/wp-content/uploads/2022/08/image-15-1024x143.png 1024w, https://krystof.io/wp-content/uploads/2022/08/image-15-300x42.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-15-768x108.png 768w, https://krystof.io/wp-content/uploads/2022/08/image-15-585x82.png 585w, https://krystof.io/wp-content/uploads/2022/08/image-15.png 1164w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>After that, VICE finally launched from LaunchBox properly:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2022/08/image-17.png" alt="" class="wp-image-1947" width="669" height="514" srcset="https://krystof.io/wp-content/uploads/2022/08/image-17.png 669w, https://krystof.io/wp-content/uploads/2022/08/image-17-300x230.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-17-585x449.png 585w" sizes="(max-width: 669px) 100vw, 669px" /><figcaption>Finally!</figcaption></figure></div>


<h2 class="wp-block-heading">Configuring VICE on Windows</h2>



<p>Great, now we know we can launch at least one game from LaunchBox using VICE.  Now I need to configure it to my tastes.  First off, it&#8217;s a tiny window in the center of the screen, and not full screen.  There are plenty of other things I like to configure for VICE, and here is where I&#8217;ll record those &#8216;default&#8217; settings I immediately set into the VICE configuration when I first install VICE.  I may tweak this over time but the settings below are my current reference settings of choice.</p>



<p>First off, VICE by default is storing it&#8217;s settings in C:\Users\&lt;userid&gt;\AppData\Roaming\vice.  Underneath there is a sdl-vice.ini after saving the first time and vice.log for any interesting execution log statements.  Good to know.</p>



<p>Side note: Try out wireless gamepads for the PC (Like XBOX controllers).  Luna loves chewing cables.</p>



<p>Here are the highlights for my VICE 3.61 Windows SDL version&#8217;s settings that deviate from the known defaults.</p>



<ul><li>SDL audio instead of WMM &#8211; Things sounded horrendous otherwise.</li><li>NTSC Mode vs Pal- I had NTSC, but sometimes images I have require PAL.  So I set up both</li><li>I set the VICE snapshots directory to the Snapshots directory I created underneath my C64 LaunchBox game folder for easier visibility.</li><li>I set the drive sound emulation to 1.  It&#8217;s just music to my ears.</li><li>Joystick &#8211; I set by default, Joystick 2 to my game controller (a generic gamepad), and Joystick 1 to the numeric keypad.  VICE by default sets my A button to Joystick firing, B button to bring up the VICE menu.  I manually set the Y button to toggle WARP speed on and off, and the X button to &#8216;swap&#8217; the Joystick ports.  I also set the left trigger to the &#8216;Load snapshot&#8217; menu, and the right trigger to &#8216;Save snapshot&#8217; menu.</li></ul>



<p>What I ended up doing was creating two emulator profiles &#8211; one for NTSC and one for PAL.  The two config files allow me to tweak the two &#8216;versions&#8217; of C64 emulation differently, and sometimes I just need to do that for some games.</p>



<p>VICE 64 &#8211; NTSC setup example (points to NTSC config)</p>



<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="648" height="200" src="https://krystof.io/wp-content/uploads/2022/08/image-23.png" alt="" class="wp-image-1978" srcset="https://krystof.io/wp-content/uploads/2022/08/image-23.png 648w, https://krystof.io/wp-content/uploads/2022/08/image-23-300x93.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-23-585x181.png 585w" sizes="(max-width: 648px) 100vw, 648px" /></figure>



<p>VICE 64 PAL &#8211; PAL setup example (points to PAL config)</p>



<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="619" height="205" src="https://krystof.io/wp-content/uploads/2022/08/image-22.png" alt="" class="wp-image-1977" srcset="https://krystof.io/wp-content/uploads/2022/08/image-22.png 619w, https://krystof.io/wp-content/uploads/2022/08/image-22-300x99.png 300w, https://krystof.io/wp-content/uploads/2022/08/image-22-585x194.png 585w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<p>Current reference settings:</p>



<p><strong>sdl-vice-ntsc.ini:</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#91;C64SC]
SDLStatusbar=1
SoundDeviceName=&quot;sdl&quot;
VirtualDevice1=1
MachineVideoStandard=2
IECReset=1
CIA1Model=0
CIA2Model=0
KernalRev=-1
VICIIFullscreen=1
VICIIModel=3
SidModel=0
JoyPort10Device=0
JoyPort9Device=0
JoyPort8Device=0
JoyPort7Device=0
JoyPort6Device=0
JoyPort5Device=0
JoyPort4Device=0
JoyPort3Device=0
JoyDevice1=4
EventSnapshotDir=&quot;D:\LaunchBox\Games\Commodore 64\Snapshots\&quot;
GlueLogic=0
DriveSoundEmulation=1

</pre></div>


<p><strong>sdl-vice-pal.ini:</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#91;C64SC]
SDLStatusbar=1
SoundDeviceName=&quot;sdl&quot;
VirtualDevice1=1
IECReset=1
CIA1Model=0
CIA2Model=0
KernalRev=-1
VICIIFullscreen=1
VICIIModel=0
SidModel=0
JoyPort10Device=0
JoyPort9Device=0
JoyPort8Device=0
JoyPort7Device=0
JoyPort6Device=0
JoyPort5Device=0
JoyPort4Device=0
JoyPort3Device=0
JoyDevice1=4
EventSnapshotDir=&quot;D:\LaunchBox\Games\Commodore 64\Snapshots\&quot;
GlueLogic=0
DriveSoundEmulation=1

</pre></div>


<p>LaunchBox specific settings:</p>



<p>Command line parameters:</p>



<ul><li>-chdir &#8220;D:\LaunchBox\Games\Commodore 64&#8221;  (Sets the autostart image directory to our games folder)</li></ul>



<h2 class="wp-block-heading">Game Specific Settings</h2>



<p>Game specific tweaks and oddities</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Game</strong></td><td><strong>Command Line</strong></td></tr><tr><td>Jingle Disks</td><td>Couldn&#8217;t fix this with command line alone.  Must manually Load &#8220;Jingle&#8221;,8,1 and go from there.</td></tr></tbody></table></figure>
<p>The post <a rel="nofollow" href="https://krystof.io/retro-gaming-pc-build-log-part-2-commodore-64/">Retro Gaming PC Build Log Part 2 : Commodore 64</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://krystof.io/retro-gaming-pc-build-log-part-2-commodore-64/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<series:name><![CDATA[Retro Gaming PC Build Log]]></series:name>
	</item>
		<item>
		<title>Patching the VICE emulator to light up floppy drive LEDs</title>
		<link>https://krystof.io/patching-the-vice-emulator-to-light-up-floppy-drive-leds/</link>
					<comments>https://krystof.io/patching-the-vice-emulator-to-light-up-floppy-drive-leds/#respond</comments>
		
		<dc:creator><![CDATA[Eric R. Krystof]]></dc:creator>
		<pubDate>Sat, 15 Feb 2020 17:03:24 +0000</pubDate>
				<category><![CDATA[Retro Gaming]]></category>
		<category><![CDATA[Emulation]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Commodore]]></category>
		<category><![CDATA[VICE]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[c]]></category>
		<guid isPermaLink="false">https://krystof.io/?p=1379</guid>

					<description><![CDATA[<p>To make the miniature floppy drive LED light up when VICE is using the virtual disk image, we need to patch VICE source code and write some new code to pass instructions on to the PI and toggle the LED activity light.</p>
<p>The post <a rel="nofollow" href="https://krystof.io/patching-the-vice-emulator-to-light-up-floppy-drive-leds/">Patching the VICE emulator to light up floppy drive LEDs</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In a previous article of the <a href="https://krystof.io/series/diorama-64">Diorama 64</a> series, we <a href="https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/">installed VICE 3.4</a>, unmodified, on our Raspberry Pi 4.  I didn&#8217;t cover any customization of <a rel="noreferrer noopener" label="VICE  (opens in a new tab)" href="http://vice-emu.sourceforge.net/" target="_blank" class="broken_link">VICE </a>in that article because I wanted to &#8216;walk before I run&#8217;.  However, our goal is to take a miniature floppy drive model, shove a LED into it, and have our VICE emulator control when the LED blinks on or off, mirroring the Commodore 1541 disk drive activity LED.  This article won&#8217;t cover the circuit itself (that&#8217;s a later article), but it is focused on modifying the VICE source code, and using some Python to transfer data from VICE and drive the Raspberry PI&#8217;s GPIO pins, which would later drive an LED light.</p>



<p>While the circuit details will come in a later article, here&#8217;s a little visual of the circuit setup &#8211; a Raspberry Pi 4 with GPIO pins attached to a breakout board, attached to a breadboard.  The top breadboard is used to drive a separate power source for the LEDs, but you can see the green &#8216;power&#8217; LEDs and one of the red &#8216;activity&#8217; LEDs light up there, that&#8217;s all driven by the Raspberry PI and VICE.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="866" height="506" src="https://krystof.io/wp-content/uploads/2020/02/vice-python-test-circuit.jpg" alt="" class="wp-image-1385" srcset="https://krystof.io/wp-content/uploads/2020/02/vice-python-test-circuit.jpg 866w, https://krystof.io/wp-content/uploads/2020/02/vice-python-test-circuit-300x175.jpg 300w, https://krystof.io/wp-content/uploads/2020/02/vice-python-test-circuit-768x449.jpg 768w, https://krystof.io/wp-content/uploads/2020/02/vice-python-test-circuit-585x342.jpg 585w" sizes="(max-width: 866px) 100vw, 866px" /><figcaption class="wp-element-caption">Pretend those LEDs are inside tiny disk drive models. </figcaption></figure>



<h2 class="wp-block-heading" id="h-high-level-design">High Level Design</h2>



<p>Since VICE is an open source project (thank goodness!), I figured I&#8217;d need to get in that code and see if I can detect when the virtual floppy drives are being used.  If I could do that, I&#8217;d want to send that data to a different program that would be responsible for driving the Raspberry Pi GPIO pins, which then drive the LEDs.  I purposefully did not want to drive the LEDs directly from VICE itself &#8211; I wanted to affect the actual emulator process as little as possible.  Just enough to get the data out of VICE.  After that, some other process takes the data and controls the circuit.  The secondary program would be written in Python, primarily because it&#8217;s very easy to interface with the Raspberry PI with the Python GPIO libraries.  VICE, of course, is written in C.</p>



<p>So I&#8217;d have a C program that gathers data, and a Python program that does something with it.  We typically call that a <strong>Publisher/Subscriber</strong> scenario.  VICE is the <em><strong>Publisher</strong></em> as it is sourcing data, and making it available (publishing) for other processes to use, and VICE isn&#8217;t getting any data back &#8211; this is a one-sided conversation.  Our Python program will be one of the <strong><em>Subscribers</em></strong><em> </em>as it will poll for new &#8216;messages&#8217; or changes in state.  The Python program will then, in turn, send signals via the GPIO library and Raspberry PI GPIO pins to the Darlington Array, which controls individual LEDs, namely our Commodore 1541 Floppy Disk Drive Activity Lights.  Here&#8217;s a high level flow:</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2020/02/2020-02-06_15-28-45-1024x576.jpg" alt="" class="wp-image-1387" srcset="https://krystof.io/wp-content/uploads/2020/02/2020-02-06_15-28-45-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2020/02/2020-02-06_15-28-45-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/02/2020-02-06_15-28-45-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2020/02/2020-02-06_15-28-45-1170x658.jpg 1170w, https://krystof.io/wp-content/uploads/2020/02/2020-02-06_15-28-45-585x329.jpg 585w, https://krystof.io/wp-content/uploads/2020/02/2020-02-06_15-28-45.jpg 1440w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">High level design flow &#8211; in this article we cover VICE and Python.</figcaption></figure>



<p>The first real question I pondered was how I&#8217;d get a C program and a Python program on a Raspberry PI to share data, even if the conversation is one-sided.  I figured I had four options off the top of my head:</p>



<ol>
<li><strong>Datafile access</strong> &#8211; Vice writes to a file that the Python program constantly reads from to determine drive status.  While this is definitely feasible, I wanted to avoid constant file-system access, OS caching or not.  The LED is meant to blink on and off rapidly, that&#8217;s a lot of file updates to apply on a SD card.</li>



<li><strong>Networking Channel</strong> &#8211; UDP or TCP, some sort of client/server or packet broadcast.  This would be necessary if the diorama was remote (an interesting idea), but ultimately the emulator and the consumer are on the same machine, so I wanted to keep the communications channel a little tighter.</li>



<li><strong>UNIX Sockets</strong> &#8211; Since the Raspberry Pi 4 is running Raspbian, it supports UNIX style sockets for a simple IPC (Inter-process Communication) channel between the VICE and Python processes.  However, it&#8217;s still a lot of code to inject into VICE.</li>



<li><strong><em>The Winner</em> &#8211; Shared Memory</strong> &#8211; I finally decided on a shared memory solution to avoid a lot of unnecessary and potentially harmful patching to VICE with any networking related code (the less I&#8217;m in VICE the less I affect its processing), along with Python recently getting support for shared memory between disparate processes with Python 3.8 and above.  </li>
</ol>



<p>While we are calling this a &#8216;Publisher/Subscriber&#8217; model, it&#8217;s a very loose fit &#8211; there&#8217;s no middle-ware here handling message flow &#8211; it&#8217;s a bit bucket we poll for state changes every few milliseconds.  Therefore, I hesitate to apply the terminology of &#8216;Publisher/Subscriber&#8217; without a few grains of salt.   Thy key point: VICE is decoupled from the consuming process(es).</p>



<h2 class="wp-block-heading" id="h-patching-vice">Patching VICE</h2>



<p>Remember where we compiled <a href="https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/">VICE on the command line</a>?  Even if a binary was available, the reason why I wanted to compile VICE was because I knew I&#8217;d be tinkering with the source code.  To that end, I downloaded their SVN source and started searching through the code for key strings like &#8216;1541&#8217;, &#8216;drive&#8217;, &#8216;floppy&#8217;, etc. until I found drive.c and drive.h.  I won&#8217;t include the whole pieces here, but this part is what I found particularly interesting &#8211; I wanted to find some place to initialize the shared memory, and some place to write to it so we can &#8216;publish&#8217; our floppy drive status updates.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
/* Initialize the hardware-level drive emulation (should be called at least
   once before anything else).  Return 0 on success, -1 on error.  */
int drive_init(void)
{
    unsigned int dnr;
    drive_t *drive;

    if (rom_loaded) {
        return 0;
    }

//..... More
}
</pre></div>


<p>Great!  <em>drive_init</em> sounds like a good hook method &#8211; we don&#8217;t want to constantly be creating shared memory segments, create it once, but write to it many times.  Here&#8217;s where I figured I&#8217;d place the &#8216;publishing&#8217; code:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
static void drive_led_update(drive_t *drive, drive_t *drive0)
{
    int my_led_status = 0;
    CLOCK led_period;
    unsigned int led_pwm;

    /* Actually update the LED status only if the `trap idle&#039;
       idling method is being used, as the LED status could be
       incorrect otherwise.  */

    if (drive0-&gt;idling_method != DRIVE_IDLE_SKIP_CYCLES) {
        my_led_status = drive-&gt;led_status;
    }

//More.....
}
</pre></div>


<p>So now, we know the two spots that sound like they&#8217;d be great for initialization and continuous updates of our shared memory with drive status.  Let&#8217;s look at the modifications necessary, then.   Our goal is to allocate some shared memory (just enough to hold drive status for drive devices 8 through 11), and when VICE is updating it&#8217;s UI LED, we want to update shared memory with that status, a simple 1 or 0 toggle will suffice.  That&#8217;s a pretty straightforward hook!</p>



<h3 class="wp-block-heading" id="h-modifications-for-drive-c"><strong>Modifications for drive.c</strong></h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
#include &lt;fcntl.h&gt;
#include &lt;sys/shm.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;sys/mman.h&gt;
#include &lt;unistd.h&gt;

const char *led_shm_name = &quot;vice-drive-led-shm&quot;;

void *viceDriveLedShmPointer;

void init_drive_led_shm(void) {

	int shm_fd;

	const int SIZE = 16;

	/* create the shared memory object */
	shm_fd = shm_open(led_shm_name, O_CREAT | O_RDWR, 0666);

	/* configure the size of the shared memory object */
	ftruncate(shm_fd, SIZE);

	/* memory map the shared memory object */
	viceDriveLedShmPointer = mmap(0, SIZE, PROT_WRITE, MAP_SHARED, shm_fd, 0);

	sprintf(viceDriveLedShmPointer, &quot;%s&quot;, &quot;80900010&quot;);
}

void update_shm_drive_status(unsigned int driveNumber,
		int driveLedStatus) {
//      Uncomment for some simple and extreme debugging
//	log_warning(drive_log, &quot;Hey! Drive %d Status : %d&quot;, driveNumber,
//			driveLedStatus);

	if (drive_init_was_called) {
		((char*) viceDriveLedShmPointer)&#91;(driveNumber * 2) + 1] = (
				driveLedStatus == 0 ? &#039;0&#039; : &#039;1&#039;);
	}
}

//  Call our initialization method from drive_init
init_drive_led_shm();

//  Add this to update our status in the existing function drive_led_update
update_shm_drive_status(drive-&gt;mynumber, my_led_status);
</pre></div>


<h3 class="wp-block-heading" id="h-modifications-to-drive-h"><strong>Modifications to drive.h</strong></h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
extern void init_drive_led_shm(void);
extern void update_shm_drive_status(unsigned int driveNumber, int driveLedStatus);
</pre></div>


<h3 class="wp-block-heading" id="h-modifications-for-compilation"><strong>Modifications for compilation</strong></h3>



<p>There&#8217;s not much else to this &#8211; all I needed to add  (and this was a quite a bit of stumbling around on my part as I&#8217;m not comfortable or familiar with automake/autoconf) was adding the system libraries to work with shared memory to the configuration file configure.proto, around line 3316, before references to GFXOUTPUT_DRIVERS</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
dnl Patch to add -lrt for shared memory IPC work
echo &quot;Patch to add -lrt for shared memory IPC work&quot;
old_LIBS=&quot;$LIBS&quot;
LIBS=&quot;$LIBS -lrt&quot;
</pre></div>


<h3 class="wp-block-heading" id="h-github-repo">Github repo</h3>



<p>Of course, you don&#8217;t have to copy these and paste them yourselves.  I put a GitHub repo for my modifications here:</p>



<p><a href="https://github.com/erkrystof/vice">https://github.com/erkrystof/vice</a></p>



<p>You&#8217;ll want to check the tags for &#8216;pure VICE&#8217; and tags for my modifications to see deltas or pull the version you desire.</p>



<p>When I wrote this &#8211; there was one tag that represented my modifications and VICE 3.4 combined:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
git clone --single-branch --branch 3.4-Modded-1.0 https://github.com/erkrystof/vice
</pre></div>


<h2 class="wp-block-heading" id="h-running-vice-with-our-patch">Running VICE with our patch</h2>



<p>After running the same build commands as I did when installing basic VICE, executing the binary should have no discernible difference (unless you un-comment that log statement) in the logs for the way VICE handles.</p>



<p>However, you should now notice there&#8217;s a piece of shared memory  you can see, and that you can read, given that everything in *nix is a file.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
pi@vice-pi:/dev/shm $ ls -l
total 4
-rw-r--r-- 1 pi pi 16 Feb  9 09:16 vice-drive-led-shm
pi@vice-pi:/dev/shm $ cat vice-drive-led-shm
80900010
pi@vice-pi:/dev/shm $

</pre></div>


<p>Excellent, we now know it&#8217;s working!  If I loop over that in an SSH console, just to see, and run VICE and load a floppy, you should see the second byte (0/1 &#8211; the drive 8 status LED) flip between 1 and 0.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
for i in {1..10000}; do cat vice-drive-led-shm; echo ... Counter: $i; done
#Sample output:
80900010... Counter: 43
80900010... Counter: 44
80900010... Counter: 45
81900010... Counter: 46  &lt;----- We have activity on drive 8
81900010... Counter: 47
81900010... Counter: 48
81900010... Counter: 49
</pre></div>


<p>Looking good so far.  So VICE is essentially done &#8211; it&#8217;s &#8216;publishing&#8217; drive status to an area in shared memory that we&#8217;ll now want to read from and drive the LEDs connected to the Raspberry Pi GPIO pins.</p>



<h2 class="wp-block-heading" id="h-reading-the-1541-drive-status-with-python">Reading the 1541 drive status with Python</h2>



<p>We&#8217;re halfway there &#8211; the next step is to work on a separate process &#8211; our subscriber that reads the VICE drive status and sends commands to the Raspberry Pi&#8217;s GPIO pins to drive our LEDs.  I could have done this in C, matching how we read shared memory that we&#8217;re writing to in VICE, but I wasn&#8217;t familiar with driving a Raspberry Pi&#8217;s GPIO pins from C.  I am a bit more comfortable with the GPIO libraries available in Python, however, though the question of reading shared memory needed an answer.</p>



<p>Granted, I could probably just read from <code>/dev/shm/vice-drive-led-shm</code>, but I really wanted to keep this semi-portable in the sense that I wanted to use the available shared-memory libraries instead of  a known *nix-specific file behavior.  After doing some research on Python and shared memory, it turns out we need a more recent version of Python than may come with your default Raspbian install &#8211; Python 3.8 or greater.</p>



<h3 class="wp-block-heading" id="h-python-3-8-or-greater-and-rpi-gpio-libraries">Python 3.8 or greater and RPi.GPIO libraries</h3>



<p>For that installation, I&#8217;m going to divert away from this article to a separate one that&#8217;s not necessarily part of the series as reference if you need it &#8211; <a href="https://krystof.io/installing-alternative-python-versions-on-raspberry-pi/">How to install Python 3.8 on the Raspberry Pi</a>. </p>



<p>If you already have Python 3.8 or greater, you&#8217;ll just need to make sure you have the RPi GPIO library installed:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo python3.8 -m pip install RPi.GPIO
</pre></div>


<h3 class="wp-block-heading" id="h-a-simple-python-client">A simple Python client</h3>



<p>The latest source code for the Python piece is available on <a rel="noreferrer noopener" aria-label="GitHub (opens in a new tab)" href="https://github.com/erkrystof/diorama-64-1541-status-consumer-gpio-led-driver" target="_blank">GitHub</a>, although I&#8217;ll go over this roughly below.  </p>



<div data-padding="10" class="wp-block-simple-blocks-info-block" style="background-color:#000000;color:#ffffff;padding:10px"><div data-iconsize="20" data-iconspace="20" class="icon" style="margin-right:20px"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-info"><path d="M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1 4c0-.55-.45-1-1-1s-1 .45-1 1 .45 1 1 1 1-.45 1-1zm0 9V9H9v6h2z"></path></svg></div><div>I&#8217;m not a Python programmer by trade &#8211; this was just enough to illustrate the point of reading shared memory and routing commands to the Raspberry Pi, not a gold standard of Python coding.</div></div>



<h4 class="wp-block-heading" id="h-initialization">Initialization</h4>



<p>Let&#8217;s look at the first chunk, primarily initialization and some structure:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
powerLedsPin = 23
drive8ActivityPin = 27
drive9ActivityPin = 22

DRIVE_8_ACTIVITY_INDEX = 1
DRIVE_9_ACTIVITY_INDEX = 3

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(&#91;powerLedsPin,drive8ActivityPin,drive9ActivityPin],
        GPIO.OUT, initial=GPIO.HIGH)
</pre></div>


<p>My diorama has four &#8216;devices&#8217; &#8211; two 1541 floppy drives, a Commodore keyboard, and a Commodore monitor.  We use one pin for all green &#8216;power&#8217; LEDs, since I didn&#8217;t feel like controlling power LEDs separately, it&#8217;s all the same output.  For the floppy drive activity LEDs, however, I needed them controlled separately, so I created a drive 8 and drive 9 pin and reserved them to pins 27 and 22, respectively.</p>



<p>After that I&#8217;m setting up the state to be HIGH &#8211; initialize all LEDs as on.</p>



<h4 class="wp-block-heading" id="h-load-the-shared-memory-reference">Load the shared memory reference</h4>



<p>Our primary code must first initialize the reference to shared memory:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
try:
    print (&quot;Consumix Python version starting up.&quot;)

    while (True):
        try:
            shm_vice = shared_memory.SharedMemory(name=&quot;vice-drive-led-shm&quot;, create=False, size=16)
            break;
        except Exception as e:
            print (e)
            print (&quot;Error Trying to Open Shared Memory... Trying again in a bit.&quot;)
            time.sleep(.5)
            continue

    print (&quot;Shared memory found, let&#039;s read it.&quot;)
</pre></div>


<p> We&#8217;re using the same shared memory name we used in VICE, and we say &#8216;create=False&#8217; since VICE is responsible for creating the shared memory object &#8211; we are just reading 16 bytes worth.  In the case that the Python program starts before VICE, we catch the exception and try again in a little bit.  I had to add that slightly fault tolerant try/catch loop as this Python client ends up staring <em>before</em> VICE when I startup my Raspberry Pi.</p>



<h4 class="wp-block-heading" id="h-read-shared-write-led">Read Shared, Write LED</h4>



<p>Now that we&#8217;ve loaded our shared memory reference, we read from the shared memory, place it into a character array, and update the LEDs with a loop and a function:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
while (True):
        driveData = array.array(&#039;b&#039;,shm_vice.buf&#91;:8])
        driveDataString = driveData.tostring().decode(&quot;utf-8&quot;)
        updateLEDLighting(driveDataString)
        time.sleep(0.025)

#... more stuff after....
#update function for reference:

def updateLEDLighting(driveDataString):
    if (driveDataString&#91;DRIVE_8_ACTIVITY_INDEX] == &#039;1&#039;):
        GPIO.output(drive8ActivityPin,GPIO.HIGH)
    else:
        GPIO.output(drive8ActivityPin,GPIO.LOW)

    if (driveDataString&#91;DRIVE_9_ACTIVITY_INDEX] == &#039;1&#039;):
        GPIO.output(drive9ActivityPin,GPIO.HIGH)
    else:
        GPIO.output(drive9ActivityPin,GPIO.LOW)
</pre></div>


<p>It&#8217;s a pretty simple program overall &#8211; but it does the job.  Since I only ended up wiring up two drives, I only read the drive 8 and 9 data, and ignore 10 and 11.</p>



<h3 class="wp-block-heading" id="h-a-note-on-python-shared-memory">A note on Python shared memory</h3>



<p>This isn&#8217;t as fault tolerant as I&#8217;d like though &#8211; if you quit your Python client, the shared memory reference seems to be <strong><em>destroyed</em></strong> &#8211; which completely baffles me.  The creator of a resource is in charge of closing it, not some other process.  So if VICE is creating the shared memory, I could understand if my Python client needs to open and close a <em>reference</em>, but not the shared memory itself.  </p>



<p>Regardless, when I close my Python client, it destroys the shared memory object completely, even if I try to &#8216;close&#8217; the reference ahead of time.  Perhaps I&#8217;ve wired something up wrong here &#8211; but i think, based on some of these links referencing the shared-memory usage in Python 3.8, that I&#8217;m not entirely crazy.</p>



<p><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://bugs.python.org/issue38119" target="_blank">https://bugs.python.org/issue38119</a></p>



<p>Now, I&#8217;m not really worried about this myself &#8211; but it could be an interesting read for others &#8211; as far as my Python client goes, I don&#8217;t need to restart it, so it shouldn&#8217;t start closing the shared memory VICE created on me.  What I may need to do now and then is restart VICE, however, and this setup handles that just fine (my patched-VICE simply uses the existing shared-memory object and the Python client keeps reading happily).</p>



<h2 class="wp-block-heading" id="h-the-outcome">The outcome</h2>



<p>Load up VICE and the Python client, and watch your GPIO pins toggle high and low with drive activity.  You can debug by tailing the shared memory object as we did above, you could use an oscilloscope or multimeter to watch some voltage changes on the GPIO pins, or you could do what I did &#8211; have some LEDs on the pins and watch them blink on and off &#8211; which is exactly what I&#8217;m looking for.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2020/02/20200105_141239-1024x576.jpg" alt="" class="wp-image-1417" srcset="https://krystof.io/wp-content/uploads/2020/02/20200105_141239-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2020/02/20200105_141239-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/02/20200105_141239-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2020/02/20200105_141239-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2020/02/20200105_141239-scaled.jpg 2048w, https://krystof.io/wp-content/uploads/2020/02/20200105_141239-1170x658.jpg 1170w, https://krystof.io/wp-content/uploads/2020/02/20200105_141239-1920x1080.jpg 1920w, https://krystof.io/wp-content/uploads/2020/02/20200105_141239-585x329.jpg 585w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Green Power LEDs are go, and drive 8 is active (Red LED lit)</figcaption></figure>



<p></p>
<p>The post <a rel="nofollow" href="https://krystof.io/patching-the-vice-emulator-to-light-up-floppy-drive-leds/">Patching the VICE emulator to light up floppy drive LEDs</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://krystof.io/patching-the-vice-emulator-to-light-up-floppy-drive-leds/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<series:name><![CDATA[Diorama 64]]></series:name>
	</item>
		<item>
		<title>Installing the VICE Commodore Emulator for Console Mode on a fresh Raspberry Pi 4</title>
		<link>https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/</link>
					<comments>https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/#comments</comments>
		
		<dc:creator><![CDATA[Eric R. Krystof]]></dc:creator>
		<pubDate>Sun, 12 Jan 2020 19:46:25 +0000</pubDate>
				<category><![CDATA[Retro Gaming]]></category>
		<category><![CDATA[Emulation]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[VICE]]></category>
		<category><![CDATA[Commodore]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<guid isPermaLink="false">https://krystof.io/?p=999</guid>

					<description><![CDATA[<p>Let's download, compile, and install the VICE Commodore 64 emulator on a fresh Raspberry Pi 4 install. We'll make sure it works in a non windows console by running a Commodore demo program.</p>
<p>The post <a rel="nofollow" href="https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/">Installing the VICE Commodore Emulator for Console Mode on a fresh Raspberry Pi 4</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>At the time of this writing, there&#8217;s no binary package ready to install on the Raspberry Pi 4.  Also, I need to make sure I can run the <a label=" (opens in a new tab)" rel="noreferrer noopener" href="http://vice-emu.sourceforge.net/" target="_blank" class="broken_link">VICE</a> emulator on the console and <strong>not</strong> in X-Windows for my diorama project.  That install isn&#8217;t difficult but isn&#8217;t a single line or two either, so we&#8217;ll start from scratch on a fresh Raspbian lite install.  This article assumes some familiarity with how VICE works.  Let&#8217;s install VICE on a Raspberry Pi 4! </p>



<h2 class="wp-block-heading" id="h-raspberry-pi-4-version-log">Raspberry Pi 4 Version Log</h2>



<div data-padding="10" class="wp-block-simple-blocks-info-block" style="background-color:#0010f4;color:#ffffff;padding:10px"><div data-iconsize="20" data-iconspace="20" class="icon" style="margin-right:20px"><span class="dashicon dashicons dashicons-info"></span></div><div>EVOLVING VERSIONS NOTE: <br>This document evolves over time &#8211; things change and old versions of Raspbian just stop being supported, and we try to make it work with the latest versions.  I&#8217;ve generally had better luck with Buster compared to Bullseye, but we try to get both up and running.</div></div>



<p>All of these in records in the table below imply the general settings changes to the VICE config presented later in the document (<em>VICE/PI General Settings I change regardless of version</em>).  Also, make sure to check out settings specific to the OS you&#8217;re using later in this document!</p>



<figure class="wp-block-table is-style-stripes"><table><tbody><tr><td>OK For Use</td><td>Raspberry PI OS Version</td><td>VICE Version</td><td>Raspi 4B Status PAL</td><td>Raspi 4B Status NTSC</td><td>Raspi 400 Status PAL</td><td>Raspi 400 Status NTSC</td><td>Install Script Links</td></tr><tr><td>Yes</td><td><a href="https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-02-22/2023-02-21-raspios-bullseye-armhf-lite.img.xz">2023-02-21-raspios-bullseye-armhf-lite.img.xz</a></td><td>3.5 <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.5/vice/" target="_blank" rel="noreferrer noopener">SVN</a>/ <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.5/vice/NEWS" target="_blank" rel="noreferrer noopener">Changelog </a>/ <a href="https://sourceforge.net/projects/vice-emu/files/releases/vice-3.5.tar.gz/download" target="_blank" rel="noreferrer noopener" class="broken_link">Tarball</a></td><td>OK!</td><td>OK!</td><td>OK!</td><td>OK!</td><td><a href="https://github.com/erkrystof/vice/blob/master/install-vice-3.5-raspi-4-bullseye-2023-02-21.sh" target="_blank" rel="noreferrer noopener">GitHub </a>/ <a href="https://raw.githubusercontent.com/erkrystof/vice/master/install-vice-3.5-raspi-4-bullseye-2023-02-21.sh" target="_blank" rel="noreferrer noopener">Raw</a></td></tr><tr><td>Yes</td><td><a href="https://downloads.raspberrypi.org/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-02-22/2023-02-21-raspios-buster-armhf-lite.img.xz">2023-02-21-raspios-buster-armhf-lite.img.xz</a></td><td>3.5 <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.5/vice/" target="_blank" rel="noreferrer noopener">SVN</a>/ <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.5/vice/NEWS" target="_blank" rel="noreferrer noopener">Changelog </a>/ <a href="https://sourceforge.net/projects/vice-emu/files/releases/vice-3.5.tar.gz/download" target="_blank" rel="noreferrer noopener" class="broken_link">Tarball</a></td><td>OK!</td><td>OK!</td><td>OK!</td><td>OK!</td><td><a href="https://github.com/erkrystof/vice/blob/master/install-vice-3.5-raspi-4-buster-2023-02-21.sh" target="_blank" rel="noreferrer noopener">GitHub </a>/ <a href="https://raw.githubusercontent.com/erkrystof/vice/master/install-vice-3.5-raspi-4-buster-2023-02-21.sh" target="_blank" rel="noreferrer noopener">Raw</a> </td></tr><tr><td>Yes</td><td><a href="https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-02-22/2023-02-21-raspios-bullseye-armhf-lite.img.xz" rel="nofollow">2023-02-21-raspios-bullseye-armhf-lite.img.xz</a>  </td><td>3.7.1 <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.7.1/vice/" target="_blank" rel="noreferrer noopener nofollow">SVN</a> / <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.7.1/vice/NEWS" target="_blank" rel="noreferrer noopener nofollow">Changelog</a> / <a href="https://sourceforge.net/projects/vice-emu/files/releases/vice-3.7.1.tar.gz/download" rel="nofollow" class="broken_link">Tarball</a></td><td>OK!</td><td>OK!</td><td>OK!</td><td>OK!</td><td><a href="https://github.com/erkrystof/vice/blob/master/install-vice-3.7.1-raspi-4-bullseye-2023-02-21.sh" target="_blank" rel="noreferrer noopener">GitHub</a> / <a href="https://raw.githubusercontent.com/erkrystof/vice/master/install-vice-3.7.1-raspi-4-bullseye-2023-02-21.sh" target="_blank" rel="noreferrer noopener">Raw</a> </td></tr><tr><td>Yes</td><td><a href="https://downloads.raspberrypi.org/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-02-22/2023-02-21-raspios-buster-armhf-lite.img.xz" rel="nofollow">2023-02-21-raspios-buster-armhf-lite.img.xz</a></td><td>3.7.1 <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.7.1/vice/" target="_blank" rel="noreferrer noopener nofollow">SVN</a> / <a href="http://svn.code.sf.net/p/vice-emu/code/tags/v3.7.1/vice/NEWS" target="_blank" rel="noreferrer noopener nofollow">Changelog</a> / <a href="https://sourceforge.net/projects/vice-emu/files/releases/vice-3.7.1.tar.gz/download" class="broken_link">Tarball</a></td><td>OK!</td><td>OK!</td><td>OK!</td><td>OK!</td><td><a href="https://github.com/erkrystof/vice/blob/master/install-vice-3.7.1-raspi-4-buster-2023-02-21.sh" target="_blank" rel="noreferrer noopener">GitHub </a>/ <a href="https://raw.githubusercontent.com/erkrystof/vice/master/install-vice-3.7.1-raspi-4-buster-2023-02-21.sh" target="_blank" rel="noreferrer noopener">Raw</a> </td></tr></tbody></table><figcaption class="wp-element-caption">This is your VICE life now, and it&#8217;s changing every SVN tag at a time.</figcaption></figure>



<div data-padding="10" class="wp-block-simple-blocks-info-block" style="background-color:#3279dd;color:#ffffff;padding:10px"><div data-iconsize="20" data-iconspace="20" class="icon" style="margin-right:20px"><span class="dashicon dashicons dashicons-info"></span></div><div>Which binary to run? x64sc or x64?  The configure line from VICE in the script has &#8216;&#8211;enable-x64&#8217;.  By default VICE builds create an x64sc binary, but NOT an x64 binary anymore.  What&#8217;s the difference?  Seems the SC binary is preferred as it focuses on accuracy of emulation over speed.  That being said, I find I like to use x64 on the C64 Demo Scene that still lives on to this day &#8211; otherwise the demos were occasionally quite choppy.  For normal game play I use x64sc but fall back to x64 if I detect heavy lag.  Your mileage may vary.  I find a lot of C64 scene demos don&#8217;t work well with x64sc, and I often fall back to x64.</div></div>



<p>Simplest way to execute the scripts is to copy the Raw link and on your raspberry pi console /ssh, do this:</p>



<pre class="wp-block-code"><code>wget -O - &lt;raw script url> | bash</code></pre>



<h3 class="wp-block-heading" id="h-test-programs">Test Programs</h3>



<p>I&#8217;ve also added some <a href="https://github.com/erkrystof/vice/tree/master/testprograms" target="_blank" rel="noreferrer noopener nofollow">test programs</a> 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:</p>



<p><strong>delaytest.d64</strong> &#8211; Written by the 8-bit guy &#8211; useful for testing lag, and also gives an audio ping each time you press a key. I start here for just the most basic &#8216;is this thing on?&#8217; approach.</p>



<p><strong>Booze Design &#8211; Remains (PAL)</strong> &#8211; Lovely haunting track.  <a href="https://csdb.dk/release/?id=187524" target="_blank" rel="noreferrer noopener">https://csdb.dk/release/?id=187524</a></p>



<p><strong>SHAPE &#8211; Disco Apocalypso</strong> <strong>(PAL)</strong>  &#8211; Up beat and great visuals. <a href="https://csdb.dk/release/?id=133935" target="_blank" rel="noreferrer noopener">https://csdb.dk/release/?id=133935</a></p>



<p><strong>Fairlight &#8211; 2600 (PAL) &#8211; </strong><a href="https://csdb.dk/release/?id=197187" target="_blank" rel="noreferrer noopener">https://csdb.dk/release/?id=197187</a></p>



<p><strong>Style &#8211; Shine On (NTSC)</strong> &#8211; <a href="https://style64.org/release/shine-style" target="_blank" rel="noreferrer noopener">https://style64.org/release/shine-style</a> &#8211; At least some graphics and smooth SID music for NTSC testing</p>



<p>Looking for more demos and such?</p>



<p><a href="https://csdb.dk" target="_blank" rel="noreferrer noopener">https://csdb.dk</a></p>



<p><a href="http://www.atlantis-prophecy.org/recollection/?load=home" target="_blank" rel="noreferrer noopener">http://www.atlantis-prophecy.org/recollection/?load=home</a></p>



<h3 class="wp-block-heading">VICE/PI General Settings I change regardless of version</h3>



<p><em>Unless noted here, I don&#8217;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.</em></p>



<p>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.</p>



<ul>
<li>Apply these settings in your VICE Config:
<ol>
<li>Machine Settings -&gt; Model Settings -&gt; SID Settings:
<ol>
<li>SID Model -&gt; 8580 + digi boost (ReSID)</li>



<li>reSID sampling method -&gt; Fast</li>
</ol>
</li>



<li>Video Settings -&gt; Size Settings
<ol>
<li>Disable double size</li>



<li>Disable double scan</li>



<li>Select Fullscreen</li>
</ol>
</li>



<li>Video Settings -&gt; Render filter
<ol>
<li>Select &#8216;None&#8217;</li>
</ol>
</li>



<li>Sound Settings
<ol>
<li>Buffer size 50msec</li>



<li>Frequency 22050 Hz</li>
</ol>
</li>
</ol>
</li>
</ul>



<p>In C64 VICE Config form (/home/pi/.config/vice/sdl-vicerc, this looks like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#91;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
</pre></div>


<p>Sometimes, I mess with the sound sample rate when I&#8217;m capturing HDMI output and streaming <em>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.</em> (<code>SoundSampleRate=44100</code>)</p>



<p><em>If you need to change your sample rate if you&#8217;re capturing output</em>, you can try the various options in here: (Menu or config file)</p>



<ul>
<li>Sound Settings -&gt; 
<ul>
<li>Frequency 44100 Hz</li>
</ul>
</li>
</ul>



<p>This generally sets a config file line:</p>



<p><code>SoundSampleRate=44100</code></p>



<h3 class="wp-block-heading">VICE/PI Version specific settings I&#8217;ve changed</h3>



<h4 class="wp-block-heading">2023-02-21-raspios-buster-armhf-lite.img.xz / VICE specifics</h4>



<p><strong>Synopsis: </strong>Apply general settings and you&#8217;re good to go.</p>



<p><strong>Raw Notes:</strong> 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 <strong>x64 </strong>binary.  The <strong>x64sc </strong>binary still chews more CPU and runs slightly slower (naturally).  <strong>I still recommend applying the generic settings I use though, since I had issues with NTSC (read on&#8230;)</strong></p>



<p>However, on NTSC, I do notice the CPU/FPS drop from 100% to 80%, jump back up again.  <strong>This was before applying my general settings.  </strong>Once I applied those, everything worked well, no stutters or CPU drops.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">2023-02-21-raspios-bullseye-armhf-lite.img.xz / VICE specifics</h4>



<p><strong>Synopsis: </strong>Apply general settings and change to fkms video driver, and then choose HDMI output in raspi-config.</p>



<p><strong>Raw Notes: </strong>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&#8217;t getting audio (maybe on headphones on the 4B, but the 400 doesn&#8217;t have a headphone jack)</p>



<p>When I switched default audio to HDMI 0 in raspi-config, <strong>that broke ALSA in vice</strong> (error message), but I also noticed even when playing demos, the CPU was locked at 100%.  Something with the sound layers&#8230;  I&#8217;ve tried changing to SDL and I get no audio at all (I&#8217;m only in console mode, remember)</p>



<p>So, next, I tried the <strong>no longer supported but still available fkms overlay</strong> setting in <strong>/boot/config.txt</strong>.  After setting that and rebooting, I was able to select HDMI in raspi-config and I got audio.  So far, so good.  I&#8217;m not happy about having to use fkms still for bullseye, but it at least got it working.</p>



<p>So, for me to get this working on Bullseye, I make the following changes:</p>



<ol>
<li>Make the general settings changes to sound/display in my general settings section (this is a must)</li>



<li>Bring in fkms driver for HDMI audio:</li>
</ol>



<p>Edit your <strong>/boot/config.txt</strong> and change the following:</p>



<p>BEFORE:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
</pre></div>


<p>AFTER:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
# Enable DRM VC4 V3D driver
dtoverlay=vc4-fkms-v3d
</pre></div>


<p>You must reboot after <strong>/boot/config.txt</strong> changes. <strong>You must also go into raspi-config and choose your audio device</strong> (this is how I was able to get VICE HDMI Audio on the 400) </p>



<p>Side note: I had <strong>flashing video artifacts on bullseye</strong>, but <strong>only when I was going through a USB HDMI capture device</strong>.  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&#8217;t happen on buster at all.  I&#8217;ve got another HDMI capture device I might use to see if it&#8217;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.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>The rest of the document is a bit of a ramble since these versions change all the time but it covers the high level.</p>



<p><strong><em>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.</em></strong></p>



<figure class="wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Installing the VICE Commodore Emulator for Console Mode on a Fresh Raspberry Pi 4" width="1170" height="658" src="https://www.youtube.com/embed/uRVTAgqs7pU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<hr class="wp-block-separator has-css-opacity"/>



<div data-padding="10" class="wp-block-simple-blocks-info-block" style="background-color:#0010f4;color:#ffffff;padding:10px"><div data-iconsize="20" data-iconspace="20" class="icon" style="margin-right:20px"><span class="dashicon dashicons dashicons-info"></span></div><div>You may wonder why I am doing it this way vs RetroPie, Combian 64, or BMC64&#8230; I probably could have, but I knew I&#8217;d be in the VICE source code a bit in a later article so I wanted to start with the basics first and make sure I could compile VICE myself.  Plus, at this time , the packages referenced above aren&#8217;t completely ready for the Raspberry Pi 4. </div></div>



<hr class="wp-block-separator has-css-opacity"/>



<h2 class="wp-block-heading" id="h-hardware-before-the-software">Hardware before the Software</h2>



<p>This part is pretty simple &#8211; you&#8217;ll need:</p>



<ul>
<li>Raspberry Pi 4 Model B, or Raspberry Pi 3B+</li>



<li>Micro SD Card (we&#8217;re generally at the days of 16GB or higher)</li>



<li>Micro HDMI cable (or full HDMI if you&#8217;re using a Raspberry Pi 3B+)</li>



<li>Keyboard / Mouse for initial setup, Wifi connectivity for later SSH connectivity.</li>
</ul>



<div data-padding="10" class="wp-block-simple-blocks-info-block" style="background-color:#0010f4;color:#ffffff;padding:10px"><div data-iconsize="20" data-iconspace="20" class="icon" style="margin-right:20px"><span class="dashicon dashicons dashicons-info"></span></div><div>Got a Raspberry Pi 3B?  I&#8217;ve added notes on that at the very end of this document.</div></div>



<h2 class="wp-block-heading" id="h-write-the-raspberry-pi-4-image">Write The Raspberry Pi 4 Image</h2>



<p>We&#8217;ll start with a fresh SD Card and a <a aria-label=" (opens in a new tab)" href="https://www.raspberrypi.org" target="_blank" rel="noreferrer noopener">Raspberry Pi 4</a>.   We&#8217;re going to burn <a label=" (opens in a new tab)" href="https://www.raspberrypi.org/downloads/raspbian/" target="_blank" rel="noreferrer noopener" class="broken_link">Raspberry Pi OS L</a><a href="https://www.raspberrypi.org/downloads/raspbian/" class="broken_link">ite</a> (I&#8217;m not using a window environment) on to the SD Card using <a aria-label=" (opens in a new tab)" href="https://www.balena.io/etcher/" target="_blank" rel="noreferrer noopener">Balena Etcher</a>.</p>


<div class="wp-block-image is-style-default">
<figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="515" height="309" src="https://krystof.io/wp-content/uploads/2019/12/balena-etcher.jpg" alt="" class="wp-image-1004" srcset="https://krystof.io/wp-content/uploads/2019/12/balena-etcher.jpg 515w, https://krystof.io/wp-content/uploads/2019/12/balena-etcher-300x180.jpg 300w" sizes="(max-width: 515px) 100vw, 515px" /></figure></div>


<h2 class="wp-block-heading" id="h-boot-the-raspberry-pi-and-get-connected"> Boot the Raspberry Pi and get connected.</h2>



<p>We know our default password is <em>raspberry</em> and our default user name is <em>pi</em>.  You should change these if you&#8217;re going to keep this install around.  Regardless, we need to set just a couple of things before we start with VICE &#8211; 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 <code>sudo raspi-config</code>:</p>



<ol>
<li>Set hostname to vice-pi-install (This makes it unique and through <a href="https://www.howtogeek.com/167190/how-and-why-to-assign-the-.local-domain-to-your-raspberry-pi/" class="broken_link">bonjour </a>lets me access it from my Windows PC as <strong>vice-pi-install.local</strong>.)</li>



<li>Set WIFI up to my access point (Country Code and SSID)</li>



<li>Allow SPI interface access (my diorama is going to be controlling an LCD through SPI) &#8211; <strong>This is purely optional </strong>&#8211; I used it because I&#8217;m hooking up some custom circuits to my Pi.</li>



<li>Allow SSH interface access (so we can copy/paste from a Windows SSH client) &#8211; Optional if you just want to type all the commands directly to your Pi console.</li>



<li>Setup locale, keyboard, etc. </li>



<li>Verify Internet Connectivity (ping google.com)</li>



<li>Perform your normal <strong><code>apt update / apt upgrade</code></strong> commands to update your system.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo apt update
sudo apt upgrade
</pre></div>


<h2 class="wp-block-heading" id="h-download-and-execute-the-install-script">Download and execute the install script</h2>



<p>I&#8217;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&#8217;re concerned about just running some guy&#8217;s script.</p>



<p>You can execute your script directly by doing this if you don&#8217;t feel like downloading it, chmod-ing it, and executing it manually:</p>



<pre class="wp-block-code"><code>wget -O - https://raw.githubusercontent.com/erkrystof/vice/master/&lt;insertscriptnamehere&gt;.sh | bash</code></pre>



<p id="block-6664aacb-64da-4b18-beca-9ec7d167a79c">What the script does at a high level:</p>



<ol>
<li>Performs the general sudo apt update/upgrade</li>



<li>Downloads SDL from libsdl.org</li>



<li>Compiles and installs SDL and other SDL libraries</li>



<li>Downloads VICE compilation dependencies</li>



<li>Downloads VICE source code from sourceforge.net</li>



<li>Configures VICE to enable fast-sid options and the x64 &#8216;old&#8217; binary build (as well as the new binary x64sc)</li>



<li>Installs VICE into your home directory (/home/pi/vice-&lt;version-number>) &#8211; Because I dislike /usr/local for vice.</li>



<li>Binaries will be in the bin directory of where we installed VICE.  You&#8217;d generally run x64 for the &#8216;older&#8217; but smoother for PAL Demos binary, or the x64sc (technically more accurate, but uses more CPU and causes PIs to stutter in demos)</li>
</ol>



<p>The latest version of the script will always be at the link above.  It&#8217;s configured so if it runs into any error, it aborts. </p>



<div data-padding="10" class="wp-block-simple-blocks-info-block" style="background-color:#0010f4;color:#ffffff;padding:10px"><div data-iconsize="20" data-iconspace="20" class="icon" style="margin-right:20px"><span class="dashicon dashicons dashicons-info"></span></div><div>This script takes about 45 minutes to execute.  You are free to examine the script ahead of time to make sure it seems safe for your system.  I promise I&#8217;m not doing anything untoward.  It&#8217;s downloading, compiling, and taking VICE straight from the source.</div></div>



<h3 class="wp-block-heading" id="h-why-compile-sdl-on-the-pi">Why compile SDL on the Pi?</h3>



<p>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&#8217;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 &#8211; so for now, I compile the SDL libraries on the Pi and things seem to work.  In previous versions of Buster, I couldn&#8217;t get this to work from SDL directly, I had to use RetroPie&#8217;s fork and manipulations on some videocore headers.  <em>I no longer need to do that for what I&#8217;m assuming are changes in the OS version over the past couple of years.</em></p>



<p><s><strong><em>We will build SDL2-2.0.14 from&nbsp;<a rel="noreferrer noopener" href="https://github.com/RetroPie/SDL-mirror" target="_blank">RetroPie’s fork</a>&nbsp;that has&nbsp;<a href="https://github.com/RetroPie/SDL-mirror/tree/retropie-2.0.14" target="_blank" rel="noreferrer noopener">Raspberry Pi specific modifications</a></em></strong>. 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&nbsp;<a rel="noreferrer noopener" href="https://retropie.org.uk/" target="_blank">here</a>.  I&#8217;ve made a fork off that repo and that&#8217;s where I&#8217;m pulling from in my script &#8211; it&#8217;s just in case I need to make any tweaks.</s></p>



<h2 class="wp-block-heading">Apply generic settings for sound/video options in VICE.</h2>



<p>See the <em>VICE/PI General Settings I change regardless of version</em> section for that.  Also, if you&#8217;re in Bullseye, there are some specific tweaks in the Bullseye section to apply.</p>



<h2 class="wp-block-heading" id="h-download-a-demo-and-see-it-perform-horribly-or-wonderfully">Download a demo and see it perform horribly or wonderfully?</h2>



<p>I downloaded a simple demo from csdb.dk by Booze Design known as &#8216;<a aria-label=" (opens in a new tab)" href="https://csdb.dk/release/?id=179123" target="_blank" rel="noreferrer noopener">The Elder Scrollers</a>&#8216;.  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:</p>



<figure class="wp-block-image size-large is-style-default"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2019/12/commodore-64-ready-1024x576.jpg" alt="" class="wp-image-1021" srcset="https://krystof.io/wp-content/uploads/2019/12/commodore-64-ready-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2019/12/commodore-64-ready-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2019/12/commodore-64-ready-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2019/12/commodore-64-ready-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2019/12/commodore-64-ready.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Hello, Retro my old friend&#8230;</figcaption></figure>



<p>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 -&gt; Screen Settings -&gt; Fullscreen.</p>



<p><strong>Noticing stuttering and other issues?  </strong>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.</p>



<h2 class="wp-block-heading" id="h-apply-settings-and-watch-a-demo-perform-smoothly">Apply settings and watch a demo perform smoothly</h2>



<p>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:</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2019/12/the-elder-scrollers-1024x576.jpg" alt="" class="wp-image-1020" srcset="https://krystof.io/wp-content/uploads/2019/12/the-elder-scrollers-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2019/12/the-elder-scrollers-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2019/12/the-elder-scrollers-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2019/12/the-elder-scrollers-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2019/12/the-elder-scrollers.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">I&#8217;ve come to scroll with you again&#8230;</figcaption></figure>



<p>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&#8217;t work well for you with your install?  Leave a comment down below or join the discord at <a rel="noreferrer noopener" aria-label="https://discord.gg/wbngTy8 (opens in a new tab)" href="https://discord.gg/wbngTy8" target="_blank">https://discord.gg/wbngTy8</a> and we can chat.  Next up: the Raspberry Pi 4 and the LCD display turned monitor.</p>



<h2 class="wp-block-heading" id="h-raspberry-pi-3b-instructions">Raspberry Pi 3B+ Instructions</h2>



<p>** May not work, I have NOT updated this yet for VICE 3.6.1 **</p>



<p>Generally, the build is very similar.  I&#8217;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&#8217;t seem to need to change any graphic related driver setting to get this to work.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
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
</pre></div>


<h2 class="wp-block-heading" id="h-references">References:</h2>



<ul>
<li><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://www.balena.io/etcher/" target="_blank">Balena Etcher</a></li>



<li><a rel="noreferrer noopener" label=" (opens in a new tab)" href="https://www.howtogeek.com/167190/how-and-why-to-assign-the-.local-domain-to-your-raspberry-pi/" target="_blank" class="broken_link">Enabling Bonjour for your Raspberry Pi</a></li>



<li><a rel="noreferrer noopener" label=" (opens in a new tab)" href="http://vice-emu.sourceforge.net/" target="_blank" class="broken_link">VICE Homepage</a></li>



<li><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://www.lemon64.com/forum/viewtopic.php?t=69443&amp;sid=b254aba4aa2e196e85420ada952765e5" target="_blank">Lemon 64 Thread on Custom SDL Build</a> </li>



<li><a href="https://choccyhobnob.com/sdl2-2-0-8-on-raspberry-pi/" target="_blank" rel="noreferrer noopener" label="SDL on Raspi (for 3B compile) (opens in a new tab)" class="broken_link">SDL on Raspi (for 3B compile)</a></li>



<li><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/midwan/amiberry/wiki/Compile-SDL2-from-source" target="_blank">Compiling SDL2 from source</a></li>



<li><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://www.lemon64.com/forum/viewtopic.php?t=44766&amp;sid=390e12b2777730f68569acebafcbb945" target="_blank">x64 vs x64sc VICE binaries</a></li>



<li><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://csdb.dk/release/?id=179123" target="_blank">The Elder Scrollers Demo</a></li>
</ul>
<p>The post <a rel="nofollow" href="https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/">Installing the VICE Commodore Emulator for Console Mode on a fresh Raspberry Pi 4</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/feed/</wfw:commentRss>
			<slash:comments>68</slash:comments>
		
		
		
		<series:name><![CDATA[Diorama 64]]></series:name>
	</item>
		<item>
		<title>The Diorama is getting around&#8230;</title>
		<link>https://krystof.io/the-diorama-is-getting-around/</link>
					<comments>https://krystof.io/the-diorama-is-getting-around/#respond</comments>
		
		<dc:creator><![CDATA[Eric R. Krystof]]></dc:creator>
		<pubDate>Fri, 10 Jan 2020 13:42:04 +0000</pubDate>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Commodore]]></category>
		<guid isPermaLink="false">https://krystof.io/?p=1135</guid>

					<description><![CDATA[<p>While I continue to work on the Diorama 64 series, I noticed a few spots I posted (reddit, facebook, etc.) have had the links taken and shared elsewhere. Very cool&#8230;</p>
<p>The post <a rel="nofollow" href="https://krystof.io/the-diorama-is-getting-around/">The Diorama is getting around&#8230;</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>While I continue to work on the <a href="https://krystof.io/series/diorama-64/">Diorama 64 series</a>, I noticed a few spots I posted (reddit, facebook, etc.) have had the links taken and shared elsewhere.   Very cool and humbling to see other Commodore enthusiasts enjoy the outcome of this project in places outside of my own personal postings.</p>



<p>It&#8217;s popped up on a few sites far and away from my little neck of the woods:</p>



<p>A German Home Theater Enthusiasts Forum &#8211; <a rel="noreferrer noopener" href="https://www.heimkinotreff.com/showthread.php/2489-Der-Thread-fuer-Geeks-und-Nerds-(nur-noch-geekiger-und-nerdiger)?p=83554&amp;viewfull=1#post83554" target="_blank" class="broken_link">HeimKinoTreff.com</a> in a side thread about other &#8216;geeky and nerdy&#8217; things.  Fair and accurate, that one.</p>



<p>The German Commodore Enthusiasts Forum &#8211; <a rel="noreferrer noopener" href="https://www.forum64.de/index.php?thread/96869-c64-jugendzimmer-mit-vice-auf-raspberry-pi-als-diorama-64-miniatur-wunderland-64/" target="_blank">Forum64.de</a> from poster emulaThor.</p>



<p>The Netherlands hosted <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://www.commodore.news/news/index/1/en/desktop" target="_blank">Commodore News</a> run by <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://twitter.com/rlagendijk" target="_blank">Richard Lagendijk</a> :</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="768" height="337" src="https://krystof.io/wp-content/uploads/2020/01/CommodoreNews-Diorama.png" alt="" class="wp-image-1138" srcset="https://krystof.io/wp-content/uploads/2020/01/CommodoreNews-Diorama.png 768w, https://krystof.io/wp-content/uploads/2020/01/CommodoreNews-Diorama-300x132.png 300w" sizes="(max-width: 768px) 100vw, 768px" /><figcaption>I love the &#8216;Commodored&#8217; photo of the diorama!</figcaption></figure>



<p>I don&#8217;t know if it will pop up anywhere else new over time, but if it does I&#8217;ll update this post for posterity.  </p>
<p>The post <a rel="nofollow" href="https://krystof.io/the-diorama-is-getting-around/">The Diorama is getting around&#8230;</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://krystof.io/the-diorama-is-getting-around/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The &#8216;Working&#8217; Commodore 64/128 Diorama and Raspberry Pi VICE Emulator</title>
		<link>https://krystof.io/diorama-64-part-1-overview/</link>
					<comments>https://krystof.io/diorama-64-part-1-overview/#comments</comments>
		
		<dc:creator><![CDATA[Eric R. Krystof]]></dc:creator>
		<pubDate>Sun, 05 Jan 2020 00:53:04 +0000</pubDate>
				<category><![CDATA[Arcade Building]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Emulation]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[VICE]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Commodore]]></category>
		<guid isPermaLink="false">https://krystof.io/?p=973</guid>

					<description><![CDATA[<p>A ‘working’ diorama of my 1980s Commodore 128/64 computer room, with mirrored LCD display monitor and working 1541 disk drive lights. Driven by a Raspberry PI, custom circuit board, and VICE C64 emulator. Additional flavor added in the form of miniature floppy disks, game boxes, and wall posters, advertisements, and game maps from my youth.</p>
<p>The post <a rel="nofollow" href="https://krystof.io/diorama-64-part-1-overview/">The &#8216;Working&#8217; Commodore 64/128 Diorama and Raspberry Pi VICE Emulator</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A little bit of backstory:  It&#8217;s 1985 and the Nintendo Entertainment System begins its assault on North American wallets in the late fall season.  As a child of the 1980&#8217;s, I was ready and willing to throw my parent&#8217;s savings towards the Nintendo firing lines.  The problem was, Dad was an unwilling partner.</p>



<p><strong>10 Year Old Me:</strong> <em>Dad, I want a Nintendo!</em></p>



<p><strong>Older, Wiser Father: </strong><em>Well, Son, I bought you this Commodore 128 Computer instead.</em></p>



<p> <strong>10 Year Old Me:</strong> <em>God damn it, Dad (internal dialogue).</em> </p>



<p>There went my hopes and dreams of having a Nintendo &#8211; replaced with this many keyed Commodore paperweight.  Dad&#8217;s goal, unbeknownst to me, was simple &#8211; get something that <em>could play games</em> but could also be used to <em>learn about computers</em>.  One day I was bored enough to pick up the manual&#8230;</p>



<div class="wp-block-image"><figure class="aligncenter size-medium"><img decoding="async" loading="lazy" width="300" height="300" src="https://krystof.io/wp-content/uploads/2019/12/Commodore-128-System-Guide-300x300.jpg" alt="" class="wp-image-981" srcset="https://krystof.io/wp-content/uploads/2019/12/Commodore-128-System-Guide-300x300.jpg 300w, https://krystof.io/wp-content/uploads/2019/12/Commodore-128-System-Guide-150x150.jpg 150w, https://krystof.io/wp-content/uploads/2019/12/Commodore-128-System-Guide.jpg 814w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption>Hello, Mr. Krystof.  This is Fate knocking.<br>It&#8217;s time to open this up.</figcaption></figure></div>



<p>I don&#8217;t remember which exact program I first built &#8211; but I do recall it was making use of the Commodore&#8217;s sprite mechanisms &#8211; some extremely crude animations and graphics manipulation.  Of course, most of the time with the Commodore 128 was spent in it&#8217;s &#8217;64 mode&#8217;, where almost all of the software library resided.</p>



<p>Nevertheless, thanks to my Nintendo-dodging father, I knew exactly what field I was going to get into in some way, shape, or form, by the time I was eleven.  I never had a console beyond the Atari 2600 until I was in my late thirties.</p>



<p>Fast forward through the years and Dad&#8217;s &#8216;spare room&#8217; (or &#8216;pit of crap&#8217; according to my mother) became the &#8216;computer room&#8217; as far as I was concerned.  Now, in the present, I want to pay homage to that era with a diorama capturing the spirit of that back room.  I also wanted to <em>play some of those old games again</em>, along with games <em>I never knew existed</em> at the time.</p>



<h2 class="wp-block-heading" id="h-birth-of-a-diorama-emulator-combo">Birth of a diorama / emulator combo</h2>



<p>I&#8217;ve put together Raspberry Pi <a href="https://krystof.io/the-tardis-arcade-hardware-invasion/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">emulator setups before</a>, and I wanted to create one for myself, and I wanted to use this to specifically target my Commodore days.  While you&#8217;ll see a model of a Commodore 128, anybody who really used one will tell you it spends most of it&#8217;s time in &#8217;64 mode&#8217; since it was backwards compatible.  So the first thought was a 3D printed case that looks like a Commodore computer to wrap around my Raspberry Pi.</p>



<p>I found a few models online on sites like Thingiverse, an example being this <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://www.thingiverse.com/thing:1954782" target="_blank">one</a>.  </p>



<div class="wp-block-image"><figure class="aligncenter size-medium"><img decoding="async" loading="lazy" width="300" height="225" src="https://krystof.io/wp-content/uploads/2019/12/raspberrypi-c64-case-300x225.jpg" alt="" class="wp-image-990" srcset="https://krystof.io/wp-content/uploads/2019/12/raspberrypi-c64-case-300x225.jpg 300w, https://krystof.io/wp-content/uploads/2019/12/raspberrypi-c64-case.jpg 628w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption>I loved this model by Freakadude, but I really needed the Commodore 128 look.</figcaption></figure></div>



<p>I liked the idea, but I thought maybe I could add something to it &#8211; like LEDs?  A monitor?  A 1541 disk drive to hold an SD Card?  This will run the popular <a rel="noreferrer noopener" label=" (opens in a new tab)" href="http://vice-emu.sourceforge.net/" target="_blank" class="broken_link">VICE</a> Commodore emulator, so I figured a retro case like this to display the <a rel="noreferrer noopener" label=" (opens in a new tab)" href="https://www.raspberrypi.org/products/raspberry-pi-4-model-b/" target="_blank" class="broken_link">Raspberry Pi 4</a> I was planning to use would be a cool little project to take on.   Unfortunately, my brain wasn&#8217;t going to let me get off that easily.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" id="h-my-brain-goes-down-a-creative-spiral">My brain goes down a creative spiral.</h3>



<p>If I&#8217;m going to print a case and a little disk drive, why not a monitor?  Instead of that, what about a little computer desk and smaller versions of those components?  My mother does 1/12th scale miniatures (1 inch = 1 foot) as a hobby, so I just naturally went with that scale.   The more I thought about it, the more I realized trying to rebuild the Commodore setup I had as a child was really the way to go.  We (sadly) sold those pieces long ago; I felt building a diorama that captured the spirit of that room was now my goal.</p>



<p>Now I know I&#8217;m building a &#8216;room&#8217;, what about those LEDs?  Could I incorporate some simple little power LEDs into each component &#8211; monitor, disk drives, and keyboard?</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2020/01/20191206_155205-1024x576.jpg" alt="" class="wp-image-1085" srcset="https://krystof.io/wp-content/uploads/2020/01/20191206_155205-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/20191206_155205-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/20191206_155205-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/20191206_155205-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2020/01/20191206_155205-scaled.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>It&#8217;s 1 and 1/2 inches wide.</figcaption></figure></div>



<p>If I&#8217;m going to build and/or manipulate 3D models to house LEDs for power &#8211; what about disk drive activity?  Could I have the classic red activity light on a 1541 disk drive turn on when the VICE emulator loads &#8216;virtual&#8217; floppy disk data?</p>



<p>If I&#8217;m going to manipulate power and activity LEDs for the components&#8230; what about a tiny LCD screen inside the Commodore 1802 monitor?  Could I play animations?  Show the &#8216;READY&#8217; screen?  Could I even mirror the Raspberry Pi output?</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2020/01/20191110_165347-1024x576.jpg" alt="" class="wp-image-1086" srcset="https://krystof.io/wp-content/uploads/2020/01/20191110_165347-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/20191110_165347-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/20191110_165347-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/20191110_165347-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2020/01/20191110_165347-scaled.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Not quite 1/12 scale, but it&#8217;s actually legible and that&#8217;s what I wanted.</figcaption></figure></div>



<p>If I&#8217;m going to do all that, I should get some sort of Commodore styled keyboard of some sort to type with so I can use those special <a href="https://en.wikipedia.org/wiki/PETSCII">PETSCII</a> keys.  </p>



<p>The VICE emulator also had some special keys for those common emulator functions, like mounting a virtual floppy image, pausing the emulator, loading/saving emulator machine state, etc.  Maybe I could build a little &#8216;mini-macro&#8217; keyboard to shorten those keystrokes.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2020/01/20191208_202526-1024x576.jpg" alt="" class="wp-image-1087" srcset="https://krystof.io/wp-content/uploads/2020/01/20191208_202526-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/20191208_202526-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/20191208_202526-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/20191208_202526-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2020/01/20191208_202526-scaled.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Never built a keyboard of any kind until now, this was a fun exercise.</figcaption></figure></div>



<p>I had a few other design ideas that went farther, but this is where I stopped.  If I went too far, I knew I&#8217;d never get it done.  Nevertheless, that was my thought process behind the diorama / emulator combo.  I wanted to pay homage to that era as well as have a working emulator.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="h-the-diorama-is-still-a-room">The Diorama is still a &#8216;room&#8217;</h2>



<p>My mother has been creating miniatures for years now &#8211; primarily 1/12 &#8216;dollhouse&#8217; scale.  Once I mentioned the idea of the diorama to her, her &#8216;miniature brain&#8217; (ahem, don&#8217;t read that literally) went to work and she built the structure for the room box, carpet, desk, shelves, and even the old rolling chair we had plus some family pets.  It really started to feel like this diorama would capture the spirit of the computer room of my youth.  What I wasn&#8217;t expecting was mixing some &#8216;old me&#8217; and &#8216;young me&#8217;, as she found a figure, and with some paint in the right spots, created&#8230; mini-me.</p>



<div data-padding="10" class="wp-block-simple-blocks-info-block" style="background-color:#000000;color:#ffffff;padding:10px"><div data-iconsize="20" data-iconspace="20" class="icon" style="margin-right:20px"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-info"><path d="M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1 4c0-.55-.45-1-1-1s-1 .45-1 1 .45 1 1 1 1-.45 1-1zm0 9V9H9v6h2z"></path></svg></div><div>Yes, I know it&#8217;s a guy with a beard&#8230; It&#8217;s the old me in the young me&#8217;s room.  Man that sounds creepy.</div></div>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="576" height="1024" src="https://krystof.io/wp-content/uploads/2020/01/IMG_20191015_192807795-576x1024.jpg" alt="" class="wp-image-1094" srcset="https://krystof.io/wp-content/uploads/2020/01/IMG_20191015_192807795-576x1024.jpg 576w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191015_192807795-169x300.jpg 169w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191015_192807795-768x1366.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191015_192807795-864x1536.jpg 864w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191015_192807795-scaled.jpg 1152w" sizes="(max-width: 576px) 100vw, 576px" /><figcaption>It&#8217;s not that far off, really.</figcaption></figure></div>



<p>She created her own prototype of the diorama with a domed room, with myself and my Siamese Luna enjoying what little air is left under this glass by playing some Pac-Man (which I&#8217;d be replacing with Commodore specifics).</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img decoding="async" loading="lazy" src="https://krystof.io/wp-content/uploads/2020/01/IMG_20191103_174350649-576x1024.jpg" alt="" class="wp-image-1098" width="288" height="512" srcset="https://krystof.io/wp-content/uploads/2020/01/IMG_20191103_174350649-576x1024.jpg 576w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191103_174350649-169x300.jpg 169w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191103_174350649-768x1366.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191103_174350649-864x1536.jpg 864w, https://krystof.io/wp-content/uploads/2020/01/IMG_20191103_174350649-scaled.jpg 1152w" sizes="(max-width: 288px) 100vw, 288px" /></figure></div>



<h2 class="wp-block-heading" id="h-making-the-mini-commodore-parts">Making The Mini Commodore Parts </h2>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="496" src="https://krystof.io/wp-content/uploads/2020/01/Resized_20191017_202858-1024x496.jpeg" alt="" class="wp-image-1095" srcset="https://krystof.io/wp-content/uploads/2020/01/Resized_20191017_202858-1024x496.jpeg 1024w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191017_202858-300x145.jpeg 300w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191017_202858-768x372.jpeg 768w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191017_202858-1536x744.jpeg 1536w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191017_202858-scaled.jpeg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Some resin, some filament&#8230; All Retro.</figcaption></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Taking a few models from Thingiverse (the series article on the modeling will have the details), and modifying them for some future LED wiring, I went to work recreating the system we had &#8211; A Commodore 128, two 1541 drives, and a monitor.  I also went about creating some floppy disks which you can see below, though I ended up making them thinner later.</p>



<div class="wp-block-envira-envira-gallery"><div class="envira-gallery-feed-output"><img class="envira-gallery-feed-image" tabindex="0" src="https://krystof.io/wp-content/uploads/2020/01/Resized_20191103_095418.jpeg" title="" alt="" /></div></div>



<p>After slimming down those floppies I created envelopes resembling some of the makers I remembered from my youth &#8211; Commodore branded floppies, BONUS, Elephant, Maxell, and Verbatim.  You may also recognize an EA branded floppy envelope from the days where EA was ground breaking and universally adored.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="496" src="https://krystof.io/wp-content/uploads/2020/01/Resized_20191103_153824-1024x496.jpeg" alt="" class="wp-image-1092" srcset="https://krystof.io/wp-content/uploads/2020/01/Resized_20191103_153824-1024x496.jpeg 1024w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191103_153824-300x145.jpeg 300w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191103_153824-768x372.jpeg 768w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191103_153824-1536x744.jpeg 1536w, https://krystof.io/wp-content/uploads/2020/01/Resized_20191103_153824-scaled.jpeg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>3D printed floppies, write protection notches included.</figcaption></figure>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2020/01/20191223_141023-scaled-1024x576.jpg" alt="" class="wp-image-1101" srcset="https://krystof.io/wp-content/uploads/2020/01/20191223_141023-scaled-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/20191223_141023-scaled-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/20191223_141023-scaled-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/20191223_141023-scaled-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2020/01/20191223_141023-scaled.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Game Boxes &#8211; Those floppies and manuals have to go somewhere.  Also going to need some posters for the back wall of that diorama.</figcaption></figure>



<h2 class="wp-block-heading" id="h-a-living-breathing-commodore">A &#8216;living, breathing&#8217; Commodore.</h2>



<p>The LED related goals of the diorama: <strong>Power LEDs</strong> and <strong>drive activity LEDs</strong> that match our VICE emulator install.  When you load a virtual floppy in VICE, I want the drive 8 LED to light up.  That requires a customization we&#8217;ve made to VICE itself (details in the series article), but it all has to come together connecting to the Raspberry Pi, a custom circuit board, and power.  Needless to say, the breadboard came in mighty useful during this endeavor.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="768" height="1024" src="https://krystof.io/wp-content/uploads/2020/01/img_20191208_201211-768x1024.jpg" alt="" class="wp-image-1102" srcset="https://krystof.io/wp-content/uploads/2020/01/img_20191208_201211-768x1024.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/img_20191208_201211-225x300.jpg 225w, https://krystof.io/wp-content/uploads/2020/01/img_20191208_201211-1152x1536.jpg 1152w, https://krystof.io/wp-content/uploads/2020/01/img_20191208_201211.jpg 1536w" sizes="(max-width: 768px) 100vw, 768px" /><figcaption>The &#8216;Sleep / Shutdown&#8217; button, and the drive LEDs in the background.</figcaption></figure>



<p>Also, I wanted the 3d printed monitor to work as an enclosure for a small LCD that mirrors the HDMI output of the Raspberry Pi &#8211; here&#8217;s the initial capture I took when it somehow didn&#8217;t melt upon plugging all of it together:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="320" height="165" src="https://krystof.io/wp-content/uploads/2020/01/Dual-Display.gif" alt="" class="wp-image-1091"/></figure></div>



<h2 class="wp-block-heading" id="h-twitching-the-progression">Twitching The Progression</h2>



<p>I decided to clean up the work space <em>a little bit</em> and get the <a rel="noreferrer noopener" aria-label="Twitch  (opens in a new tab)" href="https://www.twitch.tv/mrkrystof" target="_blank">Twitch </a>stream going.  Figured I&#8217;d work on this and if anyone decided to stop by and chat about it, they could.  In fact, they did.  So far I&#8217;ve met a few interested in the old Commodore retro scene, some more on the electronics side of the circuit, and some just curious as to what the hell I&#8217;m doing.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="576" src="https://krystof.io/wp-content/uploads/2020/01/20191219_184626-1024x576.jpg" alt="" class="wp-image-1082" srcset="https://krystof.io/wp-content/uploads/2020/01/20191219_184626-1024x576.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/20191219_184626-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/20191219_184626-768x432.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/20191219_184626-1536x864.jpg 1536w, https://krystof.io/wp-content/uploads/2020/01/20191219_184626-scaled.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Testing the final circuit build and the dual display of the VICE screens.</figcaption></figure>



<h2 class="wp-block-heading" id="h-diorama-emulator-parts-breakdown">Diorama/Emulator Parts Breakdown</h2>



<p>This diorama / emulator combo breaks down into these major components, and thus the series articles for more detail follow this list.  As I wrap up each one I&#8217;ll post the links here for posterity.</p>



<ul><li><strong>Raspberry Pi 4</strong> &#8211; The heart of the electronics &#8211; this runs the emulator as well as drives the circuit controlling power and drive activity LED&#8217;s. <strong>You can now see more on the VICE and OS install here: </strong> <a href="https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/">https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/</a> </li><li><strong>LCD display</strong> &#8211; this mirrors the Raspberry PI&#8217;s HDMI output, so as the big-me plays games, the mini-me in the diorama is playing the same game &#8211; or is it the other way around?</li><li> <strong>LED circuit board</strong> &#8211; This reads GPIO pin inputs from the Raspberry Pi and switches on the power and drive activity LED&#8217;s.  I also decided to try out a simple &#8216;Power&#8217; button to ease the shutdown of the Raspberry Pi. </li><li> <strong>3D Printed Commodore Models</strong> &#8211; Modified and scaled accordingly, printed in resin or filament, and painted by hand (crap-fully)  </li><li><strong>Custom VICE build and LED driver software</strong> &#8211; I created a custom VICE build to get my hook into the floppy drive activity and get that state sent to the LED circuit &#8211; so when VICE considers a floppy drive active, my LED circuit turns the LED on or off accordingly.</li><li><strong>Diorama Room</strong> containing models of our old computer desk, floppy disk holders, game boxes, and wall art I would hang in the computer room or my bedroom over the years.</li><li><strong>Input Peripherals</strong> &#8211; I need a keyboard to type on and joysticks to &#8230; joy with.</li><li><strong>Custom Keyboard Deck</strong> &#8211; This keyboard of 10 keys controls common emulator functions (mount floppy image, pause, restart emulator machine, etc.)</li><li><strong>Diorama case &#8216;base&#8217;</strong> &#8211; where we&#8217;re going to store the electronics of this diorama/emulator combo &#8211; underneath in a 3 inch tall base for the diorama to rest on.</li></ul>



<p>There are some parallel threads in the series here &#8211; I worked on many pieces at the same time &#8211; and you could to if you were recreating it.  Nevertheless, here&#8217;s how the series is presented &#8211; and I&#8217;ll do my best to keep this cohesive.</p>



<h2 class="wp-block-heading" id="h-series-breakdown">Series Breakdown</h2>



<p>As I upload articles and videos, this list will be updated and links created.  Stay tuned!</p>



<ol><li>This entry &#8211; the overview and motivation &#8211; <em><strong>Released</strong> <strong>Jan 4 2020</strong> </em></li><li><a href="https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/">VICE on the Raspberry Pi 4 Install</a> &#8211; Raspberry Pi 4, VICE Compiling &#8211; <strong><em>Released Jan 12 2020</em></strong></li><li><a href="https://krystof.io/mirroring-raspberry-pi-hdmi-video-to-a-st7789-1-3-inch-lcd-display/">Raspberry Pi 4 and  ST7789 LCD Install</a> &#8211; How to get frame buffer copying and display rotation working. &#8211; <strong><em>Released Jan 19 2020</em></strong></li><li><a href="https://krystof.io/patching-the-vice-emulator-to-light-up-floppy-drive-leds/">Custom VICE build and Python Shared Memory</a> &#8211; Using Linux shared memory to communicate between VICE and Python to drive the proper drive activity LEDs<strong><em> &#8211; Released Feb 15 2020</em></strong></li><li>Controlling LEDs from a Raspberry Pi and a Darlington Array &#8211; Isolating the power driving LEDs  and building the LED circuit </li><li> 3D Modeling the Commodore Computer &#8211; Modifications to support LED housing and wiring, painting, and decals </li><li>Input Peripherals &#8211; Keyboard and Joysticks and some alternate considerations</li><li>VICE Custom Keyboard Deck &#8211; Using an Arduino compatible Teensy to act as a USB HID Keyboard</li><li> Diorama Room &#8211; It&#8217;s not a diorama without some background items and finishing touches. </li><li>Diorama Case Base &#8211; Final touches and assembly of the diorama.</li><li>Retrospective &#8211; Looking back as we moved forward through this series.</li></ol>
<p>The post <a rel="nofollow" href="https://krystof.io/diorama-64-part-1-overview/">The &#8216;Working&#8217; Commodore 64/128 Diorama and Raspberry Pi VICE Emulator</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://krystof.io/diorama-64-part-1-overview/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
		
		<series:name><![CDATA[Diorama 64]]></series:name>
	</item>
	</channel>
</rss>
