<?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>Diorama 64 Archives - Krystof.IO</title>
	<atom:link href="https://krystof.io/series/diorama-64/feed/" rel="self" type="application/rss+xml" />
	<link>https://krystof.io/series/diorama-64/</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>Diorama 64 Archives - Krystof.IO</title>
	<link>https://krystof.io/series/diorama-64/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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[c]]></category>
		<category><![CDATA[python]]></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=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 class="post-modified-info">Last Updated on March 17, 2023.</p>
<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" 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>Mirroring Raspberry Pi HDMI Video to a ST7789 1.3 inch LCD Display</title>
		<link>https://krystof.io/mirroring-raspberry-pi-hdmi-video-to-a-st7789-1-3-inch-lcd-display/</link>
					<comments>https://krystof.io/mirroring-raspberry-pi-hdmi-video-to-a-st7789-1-3-inch-lcd-display/#comments</comments>
		
		<dc:creator><![CDATA[Eric R. Krystof]]></dc:creator>
		<pubDate>Wed, 15 Jan 2020 16:13:13 +0000</pubDate>
				<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[LCD Displays]]></category>
		<guid isPermaLink="false">https://krystof.io/?p=1126</guid>

					<description><![CDATA[<p>I needed a small display for my Commodore diorama that mirrors the output of my Raspberry Pi - I found one with this 1.3 inch ST7789 driven LCD display.  Trouble was, mirroring this wasn't as straight forward as I would have liked.</p>
<p>The post <a rel="nofollow" href="https://krystof.io/mirroring-raspberry-pi-hdmi-video-to-a-st7789-1-3-inch-lcd-display/">Mirroring Raspberry Pi HDMI Video to a ST7789 1.3 inch LCD Display</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="post-modified-info">Last Updated on May 30, 2021.</p>
<p>My Commodore 64 Diorama project was well underway.  After installing VICE on the console of a Raspberry Pi 4, the next step was to make sure I could get a tiny display that would fit some sort of &#8216;tiny monitor&#8217; I&#8217;d have to create further into the project.    I shopped around a few different places, but I ended up really liking two, both available from Adafruit.    Either way, we&#8217;re mirroring the Raspberry Pi to a ST7789 driven LCD display. </p>



<p><a href="https://krystof.io/installing-the-vice-commodore-emulator-for-console-mode-on-a-fresh-raspberry-pi-4/">Previously in the series</a>, we installed VICE on our Raspberry Pi and made sure it worked.  Now we want to mirror the HDMI output to our tiny LCD for the <a href="https://krystof.io/series/diorama-64/">diorama</a>.</p>



<p>Here&#8217;s our video that covers this article at a high level:</p>



<figure class="wp-block-embed 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="Mirroring Raspberry Pi HDMI Video to a ST7789 1.3 inch LCD Display" width="1170" height="658" src="https://www.youtube.com/embed/1zTZgx9ilWU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<h2 class="wp-block-heading" id="h-two-lcds-enter-one-lcd-leaves">Two LCDs enter, One LCD leaves</h2>



<p>The <a rel="noreferrer noopener" aria-label="OLED Breakout Board - 16-bit Color 0.96&quot; w/microSD holder (opens in a new tab)" href="https://www.adafruit.com/product/684" target="_blank">OLED Breakout Board &#8211; 16-bit Color 0.96&#8243; w/microSD holder</a> was a contender.  At about 1/12 scale this would have worked out nicely, though it felt a little &#8216;wide screen&#8217; compared to the monitors I knew of my youth.  I was also concerned with resolution, as it supports  96&#215;64, a far cry from the <a rel="noreferrer noopener" aria-label="Commodore 64's 320x200 (opens in a new tab)" href="http://www.studiostyle.sk/dmagic/gallery/gfxmodes.htm" target="_blank">Commodore 64&#8217;s 320&#215;200</a>.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="970" height="728" src="https://krystof.io/wp-content/uploads/2020/01/oled-.96inch.display.jpg" alt="" class="wp-image-1130" srcset="https://krystof.io/wp-content/uploads/2020/01/oled-.96inch.display.jpg 970w, https://krystof.io/wp-content/uploads/2020/01/oled-.96inch.display-300x225.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/oled-.96inch.display-768x576.jpg 768w" sizes="(max-width: 970px) 100vw, 970px" /><figcaption>Image from Adafruit&#8217;s Product Page</figcaption></figure>



<p>The other, and my ultimate winner &#8211; the <a rel="noreferrer noopener" aria-label="Adafruit 1.3&quot; 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789 (opens in a new tab)" href="https://www.adafruit.com/product/4313" target="_blank">Adafruit 1.3&#8243; 240&#215;240 Wide Angle TFT LCD Display with MicroSD &#8211; ST7789</a> at least got me closer with 240&#215;240, though it was a touch larger.  To that end, I&#8217;d try both with the Raspberry Pi and compare.  Once I plugged in the 240&#215;240 display and saw the Commodore 64 Ready screen, I was sold.  Even though you&#8217;d be able to make out what I was playing on the OLED display mirroring my HDMI output, with the 240&#215;240 you can actually read a good amount of text, as well.  <em>We have a winner.</em></p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="970" height="728" src="https://krystof.io/wp-content/uploads/2020/01/tftlcd-1.3inch.display.jpg" alt="" class="wp-image-1131" srcset="https://krystof.io/wp-content/uploads/2020/01/tftlcd-1.3inch.display.jpg 970w, https://krystof.io/wp-content/uploads/2020/01/tftlcd-1.3inch.display-300x225.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/tftlcd-1.3inch.display-768x576.jpg 768w" sizes="(max-width: 970px) 100vw, 970px" /><figcaption>Image from Adafruit&#8217;s Product Page</figcaption></figure>



<h2 class="wp-block-heading" id="h-a-couple-of-quests-for-the-chosen-one">A Couple of Quests for the Chosen One</h2>



<p>Adafruit has a great page in terms of how to wire this up to an Arduino and Raspberry Pi located <a rel="noreferrer noopener" aria-label="here (opens in a new tab)" href="https://learn.adafruit.com/adafruit-1-3-and-1-54-240-x-240-wide-angle-tft-lcd-displays?view=all" target="_blank">here</a>. It&#8217;s where I learned that the ST7789 chip is used to drive two different LCD displays &#8211; 240&#215;240 and 320&#215;240.  This becomes important later as I struggle with getting that working on the Raspberry Pi.  Regardless of what display I chose &#8211; I knew I needed to have the following requirements satisfied:</p>



<ul><li>The LCD should mirror HDMI output &#8211; I didn&#8217;t want this to be the primary display, but a <em><strong>mirrored</strong></em> display.</li><li>The LCD screen needed to be in a specific orientation &#8211; <strong><em>pins on the bottom</em></strong> &#8211; so they could more easily hide inside the 3D printed monitor &#8216;bottom&#8217;</li></ul>



<h3 class="wp-block-heading" id="h-wire-before-you-fire">Wire Before You Fire</h3>



<p>The display doesn&#8217;t come with header pins pre-soldered, so after remembering which end of the soldering iron is the hot end, I was able to move forward by placing the display into my breadboard:</p>



<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="804" height="226" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-11_7-22-55.jpg" alt="" class="wp-image-1149" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-11_7-22-55.jpg 804w, https://krystof.io/wp-content/uploads/2020/01/2020-01-11_7-22-55-300x84.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-11_7-22-55-768x216.jpg 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure>



<p>I followed the basic Adafruit directions for wiring the ST7789 driven 240&#215;240 display into my Raspberry Pi.  Key points:</p>



<ul><li>This is an SPI mode device.  We&#8217;re using the Raspi&#8217;s SPI0 mode, so that some of the LCD pins need to wire up to specific Raspberry Pi Pins.  More on SPI here.</li><li>We have a choice on the LCD&#8217;s reset pin, we went with a loose default of 24 on the Pi.</li><li>We have a choice on the D/C pin, we went with a loose default of GPIO 25 on the Pi.</li></ul>



<p>Here&#8217;s from Adafruit&#8217;s page specific to our ST7789 driven LCD display: <em><strong>(Editors Note &#8211; If you compare this to Adafruit&#8217;s wiring page, you may notice I swapped my RST and D/C pins &#8211; Adafruit uses 24/25 and I&#8217;m using 25/24 &#8211; It&#8217;s fine as long as you&#8217;re consistent with your physical pins and the command line options you&#8217;ll use later.  Thanks, Thomas!)</strong></em></p>



<ul><li><strong>Vin</strong>&nbsp;connects to the Raspberry Pi&#8217;s&nbsp;<strong>3V</strong>&nbsp;pin</li><li><strong>GND</strong>&nbsp;connects to the Raspberry Pi&#8217;s&nbsp;<strong>ground</strong></li><li><strong>CLK</strong>&nbsp;connects to SPI clock. On the Raspberry Pi, thats&nbsp;<strong>SCLK</strong></li><li><strong>MOSI</strong>&nbsp;connects to SPI MOSI. On the Raspberry Pi, thats also&nbsp;<strong>MOSI</strong></li><li><strong>CS</strong>&nbsp;connects to our SPI Chip Select pin. We&#8217;ll be using&nbsp;<strong>CE0</strong></li><li><strong>RST</strong>&nbsp;connects to our Reset pin. We&#8217;ll be using&nbsp;<strong>GPIO 25</strong>&nbsp;but this can be changed later. </li><li><strong>D/C</strong>&nbsp;connects to our the data/command pin. We&#8217;ll be using&nbsp;<strong>GPIO 24</strong>, but this can be changed later as well.</li></ul>



<hr class="wp-block-separator"/>



<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><em>&#8220;But I looked at Adafruit&#8217;s page and they reference CS AND D/C as SPI Chip Select?&#8221;</em>  I noticed that too&#8230; and it was confusing to me.  It seems there are variations in how SPI works, and here&#8217;s a simple summary of the same question on Adafruit&#8217;s site:  <a rel="noreferrer noopener" label=" (opens in a new tab)" href="https://forums.adafruit.com/viewtopic.php?f=47&amp;t=51949" target="_blank" class="broken_link">https://forums.adafruit.com/viewtopic.php?f=47&amp;t=51949</a>.  Also, found a great summary here on <a rel="noreferrer noopener" aria-label="particle.io (opens in a new tab)" href="https://community.particle.io/t/ssd1306-via-hardware-spi/8448/4" target="_blank">particle.io</a>:<br><br><em>The DC or D/C pin is needed by some devices to distinguish between commands or data for the controler.<br>Since SPI only pushes out anonymous bitsreams the user code has to “tell” the controler if this will be a command (e.g. D/C LOW) or a data (e.g. D/C HIGH) bitstream. And so D/C is not actually an SPI pin, but this gives you freedom which Core pin to choose.</em><br></div></div>



<hr class="wp-block-separator"/>



<p>Remember that the Raspberry PI has numerous GPIO pins, but GPIO pin 24 doesn&#8217;t mean pin 24 on the pin-out diagram &#8211; always refer to some cheat sheet like this one from <a rel="noreferrer noopener" label="RaspberryPi.org (opens in a new tab)" href="https://www.raspberrypi.org/documentation/usage/gpio/" target="_blank" class="broken_link">RaspberryPi.org</a> shown below.  Also, another great Raspberry Pi pin-out page that&#8217;s interactive is made available by <a rel="noreferrer noopener" aria-label="Gadgetoid (opens in a new tab)" href="https://pinout.xyz/" target="_blank">Gadgetoid</a>.</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/GPIO-Pinout-Diagram-2-1024x588.png" title="GPIO-Pinout-Diagram-2" alt="" /></div></div>



<p>Okay, so we&#8217;ve got it wired now, and there&#8217;s a promising backlight barely illuminating the LCD when we turn the PI on.  We&#8217;re one step closer to mirroring our Raspberry Pi to the ST7789 driven LCD Display.  Now what?</p>



<h2 class="wp-block-heading" id="h-lcd-driver-powers-activate-form-of-a-mirrored-display">LCD Driver Powers activate! Form of a mirrored display</h2>



<p>While I could have used Python to draw some Commodore images, screenshots, and other static media on the display, I want to actually mirror the display.  What shows on the HDMI output should show on the LCD, but I need the mirror scaled.  My monitor I&#8217;ll play games on doesn&#8217;t support 320&#215;240 as a resolution, the bare minimum is 800&#215;600 to make it work well enough.  So I searched around the internet and found a couple of solutions that did NOT turn the LCD into the only display or require me to overwrite with a new image.</p>



<p>This is where things might get a little confusing.  Both solutions I&#8217;m presenting here involve taking the HDMI display output and doing a little frame-buffer copy and manipulation magic.</p>



<hr class="wp-block-separator"/>



<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>Keep in mind that as the time of this writing, I&#8217;m using the Raspbian Buster Lite image on a Raspberry Pi 4.  Mileage may vary in the future.</div></div>



<hr class="wp-block-separator"/>



<ol><li>Notro&#8217;s <strong>fbtft</strong> LCD device drivers, which create an LCD frame buffer at /dev/fb1, then utilizing tasanakorn&#8217;s <strong>fbcp</strong> program which copies /dev/fb0 (HDMI output) to /dev/fb1 (LCD output), effectively mirroring the display.</li><li>juj&#8217;s <strong>fbcp-ili9341</strong> display driver that effectively does the same thing as #1, though it doesn&#8217;t technically create it&#8217;s own framebuffer, and it&#8217;s not just for ili9341 displays (it supports my ST7789!)</li></ol>



<p>Which one to use?  Well, if only one works for you, choose that one.  Otherwise, I found that  the second, <strong>fbcp-ili9341</strong> worked the best, but it does utilize a little more CPU, so you may very well want to test both (the Raspberry Pi 4 handled it fine)</p>



<p>The primary issues I had with both of these solutions involved rotation.  My requirements for either solution were to have the header pins aligned with the bottom of the display so I could more easily hide them in the mini-LCD monitor&#8217;s bottom piece.  </p>



<h3 class="wp-block-heading" id="h-option-1-fbtft-and-fbcp">Option 1 &#8211; fbtft and fbcp</h3>



<h4 class="wp-block-heading" id="h-the-journey-to-a-working-lcd-mirror">The Journey to a working LCD mirror</h4>



<p>Notro&#8217;s <a rel="noreferrer noopener" aria-label="fbtft driver (opens in a new tab)" href="https://github.com/notro/fbtft" target="_blank">fbtft driver</a> repo seems to be still a good reference point but may not be forever.  There&#8217;s a lot of discussion around the future of this project, as part of it has been brought into the Linux staging structure, and that it may stay there forever stagnating based on some discussions on the <a rel="noreferrer noopener" aria-label="development page (opens in a new tab)" href="https://github.com/notro/fbtft/wiki/Development" target="_blank">development page</a>.  Nevertheless, it did end up working.</p>



<p>There&#8217;s a lot of good information to sift through on that wiki, but I&#8217;ll keep this page more towards my journey in getting it working.</p>



<p>I saw some references in the staging code base to the ST7789 driver, so it felt promising:</p>



<p><a href="https://github.com/torvalds/linux/blob/master/drivers/staging/fbtft/fb_st7789v.c" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://github.com/torvalds/linux/blob/master/drivers/staging/fbtft/fb_st7789v.c</a></p>



<p>Now, the key here is that if these drivers are effectively already part of my Raspbian install, I should be able to use the Linux modprobe commands to load these modules in.  By looking at other sample modprobe commands I tried this against my Raspberry Pi with the LCD on the breadboard:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
#Screen mirrors but inverted colors and rotation
sudo modprobe --first-time fbtft_device name=fb_st7789v custom width=240 height=240 speed=32000000 gpios=reset:25,dc:24
</pre></div>


<p>The command above loads the <em>fbtft_device</em> module with a custom configuration based on the provided driver <em>fb_st7789v</em>.  Notice that we didn&#8217;t have to declare the standard SPI pins but we need to reference our two custom GPIO pins from the wiring section &#8211; reset and dc.</p>



<p><em>Remember that this command just creates a framebuffer for the LCD at /dev/fb1, it doesn&#8217;t actively mirror the display.  We need the fbcp program for that.</em>  I just run fbcp as a background process and voila.  The LCD came to life &#8230; but it&#8217;s a little off.  (Also, don&#8217;t worry, the full setup steps are at the end)</p>



<p>Here&#8217;s the result when I ran &#8216;htop&#8217;:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="578" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-11_20-50-06-1024x578.jpg" alt="" class="wp-image-1161" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-11_20-50-06-1024x578.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-11_20-50-06-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-11_20-50-06-768x434.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-11_20-50-06.jpg 1220w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>I want none of this.</figcaption></figure></div>



<p>If you don&#8217;t know what that <strong>should</strong> look like, I can tell you that display screen is rotated 180 degrees off my desired layout (pins on the bottom), and the screen color is &#8216;negative&#8217;.  It should be a black screen with white text.</p>



<p>Now I&#8217;m off to figure out how to rotate and how to invert the colors.  I dug around the issues page on the wiki and found this reference:</p>



<p><a href="https://github.com/notro/fbtft/issues/425">https://github.com/notro/fbtft/issues/425</a></p>



<p>Github user <a rel="noreferrer noopener" aria-label="tr1p1ea  (opens in a new tab)" href="https://github.com/tr1p1ea" target="_blank">tr1p1ea </a>references an init string argument you can also pass along in the modprobe argument, which probably was setting some ST7789 specific codes I needed to set.</p>



<pre class="wp-block-code"><code>init=-1,0x11,-2,120,-1,0x36,0x00,-1,0x3A,0x05,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1A,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x0B,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0x21,-1,0xE0,0x00,0x19,0x1E,0x0A,0x09,0x15,0x3D,0x44,0x51,0x12,0x03,0x00,0x3F,0x3F,-1,0xE1,0x00,0x18,0x1E,0x0A,0x09,0x25,0x3F,0x43,0x52,0x33,0x03,0x00,0x3F,0x3F,-1,0x29,-3</code></pre>



<p>What is all this crap?  These are initialization parameters you can send directly to your LCD driver chipset.  Notro&#8217;s page has some information there, but understanding the specifics for your LCD require the datasheet.  Nevertheless, I tried it out and we got farther&#8230;</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="579" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_7-21-49-1024x579.jpg" alt="" class="wp-image-1167" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_7-21-49-1024x579.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_7-21-49-300x170.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_7-21-49-768x434.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_7-21-49.jpg 1222w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Okay, color looks good, now let&#8217;s rotate it.</figcaption></figure></div>



<p>The fbtft_device page on the wiki references other parameters &#8211; one of them being rotate:</p>



<pre class="wp-block-code"><code>rotate
Angle to rotate display counter clockwise: 0, 90, 180, 270 </code></pre>



<p>Okay, so we rotate with our updated command &#8211; I figured 180 degrees to start.</p>



<pre class="wp-block-code"><code>sudo modprobe --first-time fbtft_device name=fb_st7789v custom width=240 height=240 speed=32000000 rotate=180 gpios=reset:25,dc:24 init=-1,0x11,-2,120,-1,0x36,0x00,-1,0x3A,0x05,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1A,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x0B,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0x21,-1,0xE0,0x00,0x19,0x1E,0x0A,0x09,0x15,0x3D,0x44,0x51,0x12,0x03,0x00,0x3F,0x3F,-1,0xE1,0x00,0x18,0x1E,0x0A,0x09,0x25,0x3F,0x43,0x52,0x33,0x03,0x00,0x3F,0x3F,-1,0x29,-3</code></pre>



<p>Which now leaves us with something completely different &#8211; I thought I saw rotation but couldn&#8217;t tell easily &#8211; so I ran VICE and saw it fill up only part of the screen!</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="580" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-32-31-1024x580.jpg" alt="" class="wp-image-1173" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-32-31-1024x580.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-32-31-300x170.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-32-31-768x435.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-32-31.jpg 1220w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>What fresh hell is this?</figcaption></figure>



<p>During my research on fbtft and fbcp, I ran across that the ST7789 driver chip supported 320&#215;240 <strong><em>and</em></strong> 240&#215;240 displays.  So it looked like to me that my 240&#215;240 lcd was acting as a viewport into the &#8216;opposite end&#8217; of the video ram that stores the 240&#215;240 image as configured by our modprobe command.</p>



<p>I had a rough idea now of what I was looking for &#8211; I need to &#8216;scroll&#8217; up about 320-240 = 80 pixels.  How the **** am I supposed to do this?  At this point I started looking for the ST7789 data sheet so I could see if there was some &#8216;mode&#8217; or related setting.  After perusing this for a while, I found something quite interesting in the <a rel="noreferrer noopener" aria-label="PDF (opens in a new tab)" href="https://www.rhydolabz.com/documents/33/ST7789.pdf" target="_blank">PDF</a>:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="535" height="622" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-39-58.jpg" alt="" class="wp-image-1174" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-39-58.jpg 535w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-39-58-258x300.jpg 258w" sizes="(max-width: 535px) 100vw, 535px" /><figcaption>This looks promising!</figcaption></figure></div>



<p>At this point it looked like I wanted to add to our init string.  Something with instruction 37h, with 2 parameters.  I defaulted the first to zero and the second to the number of pixels I wanted to &#8216;scroll&#8217;.  I wasn&#8217;t sure if my rotation settings &#8216;inverted&#8217; the pixel count so I just started with the difference of 320-240 = 80.  Of course, we&#8217;re dealing with hex, so thats 0x50.  The full piece of the initialization string I inserted after the 0x36 instruction follows:</p>



<pre class="wp-block-preformatted">-1,0x37,0x00,0x50
<strong>-1</strong> (break for new instruction)
<strong>0x37</strong> Instruction for Vertical Scroll Start Address Of RAM
<strong>0x00</strong> First Parameter  (defaulted this to 0)
<strong>0x50</strong> Second Parameter (set this to 80 pixels, converted to hex)</pre>



<p>So now my init string, with the extra 37h instruction added, yielded this result:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="577" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-47-06-1024x577.jpg" alt="" class="wp-image-1175" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-47-06-1024x577.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-47-06-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-47-06-768x433.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-12_15-47-06.jpg 1226w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Holy crap, it actually worked.</figcaption></figure></div>



<h4 class="wp-block-heading" id="h-install-instructions-for-option-1-fbtft-and-fbcp">Install Instructions for Option 1 &#8211; fbtft and fbcp</h4>



<p>So, we at least have something working.  That was the entire goal of this first stage &#8211; just get the LCD mirroring the HDMI output of my Raspberry Pi with VICE.  Good to go!  So let&#8217;s finish off option 1 by building the list of instructions.</p>



<p>Since fbtft drivers are already part of Raspbian Buster, all we really need to do is download and copy fbcp, and basing the instructions off that GitHub page: <a rel="noreferrer noopener" aria-label="https://github.com/tasanakorn/rpi-fbcp (opens in a new tab)" href="https://github.com/tasanakorn/rpi-fbcp" target="_blank">https://github.com/tasanakorn/rpi-fbcp</a></p>



<hr class="wp-block-separator"/>



<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>This option is here to best describe the journey &#8211; I ended up going with Option 2 &#8211; FBCP-ILI9341</div></div>



<hr class="wp-block-separator"/>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
mkdir ~/fbcp-src
cd ~/fbcp-src

git clone https://github.com/tasanakorn/rpi-fbcp.git
cd rpi-fbcp/

mkdir build
cd build
cmake ..
make
</pre></div>


<p>After that point, a new <em><strong>fbcp</strong></em> binary now exists in the build directory we just made.</p>



<p>To just test the general execution of these two, I&#8217;ll enter the commands into the shell.  Afterwards I&#8217;d see the LCD activate and mirror the screen properly.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
#start LCD Driver - create fb1 frame buffer
sudo modprobe --first-time fbtft_device name=fb_st7789v custom width=240 height=240 speed=32000000 rotate=180 gpios=reset:25,dc:24 init=-1,0x11,-2,120,-1,0x36,0x00,-1,0x37,0x00,0x50,-1,0x3A,0x05,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1A,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x0B,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0x21,-1,0xE0,0x00,0x19,0x1E,0x0A,0x09,0x15,0x3D,0x44,0x51,0x12,0x03,0x00,0x3F,0x3F,-1,0xE1,0x00,0x18,0x1E,0x0A,0x09,0x25,0x3F,0x43,0x52,0x33,0x03,0x00,0x3F,0x3F,-1,0x29,-3
</pre></div>


<p>Then, we need to run fbcp so it can copy the framebuffer from HDMI (/dev/fb0) to the LCD (/dev/fb1) &#8211; run this from your fbcp&#8217;s build directory you created earlier:</p>



<pre class="wp-block-preformatted">./fbcp &amp;</pre>



<p>What if we want this to run on start up?  There are numerous ways to do that, here&#8217;s a simple one &#8211; pop it into rc.local.  We&#8217;ll cover alternate methods later in the series, this article is just about getting the LCD going.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
#Copy fbcp and start it up and the fbtft drivers  (run from your fbcp build dir)
sudo cp fbcp /usr/bin 
sudo chmod +x /usr/bin/fbcp

sudo nano /etc/rc.local
</pre></div>


<p>Add the following lines to rc.local before &#8216;exit 0&#8217;.  Remember the sudo modprobe is <em>all one single line</em>.</p>



<pre class="wp-block-code"><code>sudo modprobe --first-time fbtft_device name=fb_st7789v custom width=240 height=240 speed=32000000 rotate=180 gpios=reset:25,dc:24 init=-1,0x11,-2,120,-1,0x36,0x00,-1,0x37,0x00,0x50,-1,0x3A,0x05,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1A,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x0B,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0x21,-1,0xE0,0x00,0x19,0x1E,0x0A,0x09,0x15,0x3D,0x44,0x51,0x12,0x03,0x00,0x3F,0x3F,-1,0xE1,0x00,0x18,0x1E,0x0A,0x09,0x25,0x3F,0x43,0x52,0x33,0x03,0x00,0x3F,0x3F,-1,0x29,-3

#
#Add a little sleep before starting fbcp to allow fbtft to initialize
#(your display might stay blank otherwise)
#
sleep 2

/usr/bin/fbcp &amp;</code></pre>



<p>Reboot and you should see the screen mirror after the boot process initializes some.  If you don&#8217;t have your HDMI output active, VICE may not load (it doesn&#8217;t get a good hook into /dev/fb0) &#8211; so you may need to edit your /boot/config.txt and add:</p>



<pre class="wp-block-code"><code>hdmi_force_hotplug=1</code></pre>



<h3 class="wp-block-heading" id="h-option-2-fbcp-ili9341">Option 2 &#8211; fbcp-ili9341</h3>



<h4 class="wp-block-heading" id="h-a-faster-alternative-to-fbtft-fbcp-that-uses-a-little-more-cpu">A faster alternative to fbtft/fbcp that uses a little more CPU</h4>



<p>I was initially happy with option 1 &#8211; I wasn&#8217;t planning on playing games using the tiny LCD, just mirror it so the diorama looked alive.  However, I still perused a few other search threads and found out about this other option called <strong>fbcp-ili9341</strong>, and while the name may be confusing (it doesn&#8217;t create a framebuffer, and it&#8217;s not just for the ili9341 driver), I was able to get it working with our ST7789 1.3&#8243; LCD display.  </p>



<p><strong>Why did I try it out?</strong> Turns out, SPI doesn&#8217;t have the inherent bandwidth as it stands with libtft and fbcp &#8211; and since I&#8217;m playing games, which inherently implies video as opposed to text, I noticed the refresh rate on the LCD was always a little stuttered while playing C64 games and demos.  Through some optimizations and shortcuts, the author juj has created an alternative that is faster than our option 1, all the way to 60fps.  Ohhhhh yeah.</p>



<p>So here&#8217;s the journey to making that work.  A little easier, and a bit nicer payoff.  This option, while using a little more CPU (Our Raspi has 4 cores, so it&#8217;s not a big deal), is <strong><em>fast</em></strong>.  In fact, it says so on it&#8217;s <a rel="noreferrer noopener" aria-label="GitHub page (opens in a new tab)" href="https://github.com/juj/fbcp-ili9341" target="_blank">GitHub page</a>, so you know it&#8217;s true!</p>



<p>Since the name is also confusing, here&#8217;s <em>why</em> it&#8217;s named the way it is:</p>



<p><em>The&nbsp;<code>fbcp</code>&nbsp;part in the name means&nbsp;framebuffer copy; specifically for the ILI9341 controller. fbcp-ili9341 is not actually a framebuffer copying driver, it does not create a secondary framebuffer that it would copy bytes across to from the primary framebuffer. It is also no longer a driver only for the ILI9341 controller. A more appropriate name might be&nbsp;userland-raspi-spi-display-driver&nbsp;or something like that, but the original name stuck. </em></p>



<p>So I downloaded the source and compiled it, and there&#8217;s effectively just one execution line since this takes the place of fbtft and fbcp &#8211; in fact, you can&#8217;t run both at the same time &#8211; test with Option 1 or Option 2 separately.</p>



<p>The <strong>cmake</strong> command to the build takes a few options in, and I chose these as my initial settings so I could see what it would do:</p>



<pre class="wp-block-preformatted"><strong>-DST7789=ON</strong> 
There's built in support for our chip set, so this was a natural choice.
<strong>-DGPIO_TFT_DATA_CONTROL=24</strong>
Same as option 1 - our custom pin we chose for data control.
<strong>-DGPIO_TFT_RESET_PIN=25</strong>
Same as option 1 - our custom pin for LCD display reset.
<strong>-DSPI_BUS_CLOCK_DIVISOR=30</strong>
My sensible default based on the GitHub page - lower is more responsive but may cause screen artifacts on LCDs.</pre>



<p>Compiling with those options successfully, I now had a fbcp-ili9341 binary to execute.  Survey says&#8230;</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="578" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-25-04-1024x578.jpg" alt="" class="wp-image-1191" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-25-04-1024x578.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-25-04-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-25-04-768x433.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-25-04.jpg 1225w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Rotated 90 degrees off, and looks like some debugging info at the &#8216;top&#8217;.</figcaption></figure></div>



<p>Okay, we can fix this.  Reading up on a reported issue in the project&#8217;s GitHub issues list, I found reference to a couple of items to change in the code:</p>



<pre class="wp-block-preformatted"><strong>define DISPLAY_OUTPUT_LANDSCAPE</strong> - If we comment this out, we'll rotate the display 90 degrees - which way though?  Let's try and find out what happens.</pre>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" loading="lazy" width="1024" height="491" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-30-45-1024x491.jpg" alt="" class="wp-image-1192" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-30-45-1024x491.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-30-45-300x144.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-30-45-768x369.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-30-45.jpg 1440w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Getting closer&#8230;</figcaption></figure></div>



<p>So we&#8217;re rotated properly, but we&#8217;re reversed.  The text should be on the left.  So we need to reverse the image, not just a simple rotation.  Here&#8217;s the next changes I tried:</p>



<pre class="wp-block-preformatted"><strong>madctl ^= MADCTL_COLUMN_ADDRESS_ORDER_SWAP;</strong>  - Adding this line into another file will mirror image the display - Sold!

<strong>-DSTATISTICS=0</strong> Remove that debug information</pre>



<p>So, we try this change and rebuild, and we now have&#8230;</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="578" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-36-03-1024x578.jpg" alt="" class="wp-image-1195" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-36-03-1024x578.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-36-03-300x169.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-36-03-768x434.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-36-03.jpg 1224w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>The proper orientation, but &#8230; slightly squeezed.  Like an 8-bit orange.</figcaption></figure>



<p>Now we&#8217;re getting there!  We&#8217;re oriented in the right way, and the image reads left to right.  Only thing now is to change the scaling, which is how my research led to this option:</p>



<pre class="wp-block-preformatted"><strong>-DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON</strong> - I expected something like this because our display is 240 wide, so it's scaling 180 on the vertical to maintain aspect ratio.  Let's just make it fill the whole thing so we don't have the black bars of doom.</pre>



<p>And now&#8230;.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="491" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-56-22-1024x491.jpg" alt="" class="wp-image-1196" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-56-22-1024x491.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-56-22-300x144.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-56-22-768x369.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_15-56-22.jpg 1440w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>We&#8217;re done!</figcaption></figure>



<p>So now I&#8217;ve got both options working in the same fashion.  There are differences though, and we&#8217;ll cover that in the next section below, after the &#8216;install instructions&#8217;</p>



<h4 class="wp-block-heading" id="h-install-instructions-for-option-2-fbcp-ili9341">Install Instructions for Option 2 &#8211; fbcp-ili9341</h4>



<p>Our goal is to download fbcp-ili9341, perform some quick modifications to the code, set our options, compile, and execute it.</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>If you are running Option 1 on start up of your PI, you should disable that first.  Option 1 and Option 2 are mutually exclusive.</div></div>



<p>If necessary, download the dependencies required:</p>


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


<p>Then let&#8217;s download our source code:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
mkdir ~/fbcp-ili9341
cd ~/fbcp-ili9341
git clone https://github.com/juj/fbcp-ili9341.git
</pre></div>


<p>This creates and downloads the source to /home/pi/fbcp-ili9341/fbcp-ili9341  (Yeah, it&#8217;s a double directory, I always make my own root directories for compilation work)</p>



<p>Before we compile, we need to make the edits referenced in our previous section on figuring out how Option 2 was going to work.  </p>



<p>Edit your config.h file:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
nano ~/fbcp-ili9341/fbcp-ili9341/config.h
</pre></div>


<p>Comment out the line below (the example is already commented out)</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
//#define DISPLAY_OUTPUT_LANDSCAPE
</pre></div>


<p>Next, we&#8217;ll edit our ST7789 (actually it&#8217;s a file that handles a couple of ST-made chips) specific file to do the &#8216;mirroring&#8217; swap.  Edit the following:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
nano ~/fbcp-ili9341/fbcp-ili9341/st7735r.cpp
</pre></div>


<p>and add the following line:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
madctl ^= MADCTL_COLUMN_ADDRESS_ORDER_SWAP;
</pre></div>


<p>somewhere before this line:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
SPI_TRANSFER(0x36/MADCTL: Memory Access Control/, madctl);
</pre></div>


<p><strong>Optional Gamma Change: </strong>I&#8217;ve also, over time, discovered that I like the screen a little darker, primarily because I have a camera pointed at it at the Twitch stream and it causes some overexposure of the screen compared to the diorama itself.  So you can make the gamma 1.0 by changing this line in the same file:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
SPI_TRANSFER(0x26/Gamma Curve Select/, 0x04/Gamma curve 3 (2.5x if GS=1, 2.2x otherwise)/);
</pre></div>


<p>Change the 0x04 to 0x08:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
SPI_TRANSFER(0x26/Gamma Curve Select/, 0x08/Gamma curve 3 (2.5x if GS=1, 2.2x otherwise)/);
</pre></div>


<p>That&#8217;s it for file editing, let&#8217;s get back to the compile.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
cd ~/fbcp-ili9341/fbcp-ili9341
mkdir build
cd build
cmake -DST7789=ON -DGPIO_TFT_DATA_CONTROL=24 -DGPIO_TFT_RESET_PIN=25 -DSPI_BUS_CLOCK_DIVISOR=30 -DSTATISTICS=0 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON ..
make -j
</pre></div>


<p>This will create the <strong>fbcp-ili9341</strong> binary in the build directory.  Try it out by running it and hitting CTRL-C when you&#8217;re done.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo ./fbcp-ili9341
</pre></div>


<p>If that works nicely for you, you could also make a quick hack to your /etc/rc.local file and make it boot on startup.  (This is a quick hack)</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
#Copy fbcp-ili9341 and start it up on boot
sudo cp ./fbcp-ili9341 /usr/bin 
sudo chmod +x /usr/bin/fbcp-ili9341

sudo nano /etc/rc.local
</pre></div>


<p>Add the following line to rc.local before &#8216;exit 0&#8217;.  </p>



<pre class="wp-block-code"><code>sudo /usr/bin/fbcp-ili9341 &amp;</code></pre>



<h2 class="wp-block-heading" id="h-comparing-mirroring-options">Comparing Mirroring Options</h2>



<p>You may notice right off the bat that the default initialization of our option 1 vs option 2 have a stark difference in brightness.  I didn&#8217;t investigate further in making the first option brighter, because I was just so happy with option 2 as a whole I never looked back.</p>



<figure class="wp-block-image size-large"><img decoding="async" loading="lazy" width="1024" height="590" src="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_19-27-03-1024x590.jpg" alt="" class="wp-image-1222" srcset="https://krystof.io/wp-content/uploads/2020/01/2020-01-13_19-27-03-1024x590.jpg 1024w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_19-27-03-300x173.jpg 300w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_19-27-03-768x443.jpg 768w, https://krystof.io/wp-content/uploads/2020/01/2020-01-13_19-27-03.jpg 1199w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Option 2 may seem almost too bright from the photo, but it&#8217;s actually not bad for me in person.</figcaption></figure>



<p>Option 2, as you can see in the video segment at the beginning of this article, has a much higher frame rate as promised.  While I did try two different arguments to the <strong>SPI_BUS_CLOCK_DIVISOR</strong> option (30 and 8), I really didn&#8217;t see much of a difference in my eyes.  The big difference is between fbtft/fbcp being much slower than fbcp-ili9341.  </p>



<p>What&#8217;s the trade-off?  As you see in the video, there&#8217;s about a 20-40% spike in one of my Pi&#8217;s cores on FBCP-ILI9341 vs regular old FBCP.  Given I&#8217;m using a beefy Raspberry Pi, I detected no issues in game play.  Your mileage may vary.</p>



<p>So we&#8217;ve now got part of our diorama circuitry working &#8211; we successfully mirrored the Raspberry Pi HDMI output to the ST7789 driven LCD display, showing whatever we play on our VICE Commodore emulator&#8217;s HDMI output.  There&#8217;s more to come, though!  Remember those 1541 disk drives that Commodore computers utilized?  Well, we need to make sure that the LEDs we plan on putting in those floppy drives <strong>light up according to activity in VICE</strong>.  To do that, we&#8217;ll need to create a custom VICE build (we&#8217;ll be doing a small bit of C programming) so we can drive LED activity and power LEDs based on whatever VICE is doing.  That will be the next article in the series, coming soon.</p>



<h2 class="wp-block-heading" id="h-references-and-further-reading">References and Further Reading</h2>



<p><strong>SPI &#8211; Serial Peripheral Interface</strong></p>



<p><a rel="noreferrer noopener" aria-label="https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all (opens in a new tab)" href="https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all" target="_blank">https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all</a><br><a rel="noreferrer noopener" aria-label="https://en.wikipedia.org/wiki/Serial_Peripheral_Interface (opens in a new tab)" href="https://en.wikipedia.org/wiki/Serial_Peripheral_Interface" target="_blank">https://en.wikipedia.org/wiki/Serial_Peripheral_Interface</a><br><a href="https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md" class="broken_link">https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md</a><br><a rel="noreferrer noopener" aria-label="https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/spi-sensors-devices (opens in a new tab)" href="https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/spi-sensors-devices" target="_blank">https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/spi-sensors-devices</a></p>



<p><strong>Option 1 &#8211; FBTFT/FBCP</strong></p>



<p><a href="https://github.com/notro/fbtft" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://github.com/notro/fbtft</a></p>



<p><a href="https://github.com/notro/fbtft/wiki/Development" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://github.com/notro/fbtft/wiki/Development</a></p>



<p><a href="https://github.com/torvalds/linux/blob/master/drivers/staging/fbtft/fb_st7789v.c" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://github.com/torvalds/linux/blob/master/drivers/staging/fbtft/fb_st7789v.c</a></p>



<p><a href="https://github.com/notro/fbtft/issues/425" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://github.com/notro/fbtft/issues/425</a></p>



<p><a href="https://www.rhydolabz.com/documents/33/ST7789.pdf" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://www.rhydolabz.com/documents/33/ST7789.pdf</a></p>



<p><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/tasanakorn/rpi-fbcp" target="_blank">https://github.com/tasanakorn/rpi-fbcp</a></p>



<p><strong>Option 2 &#8211; FBCP-ILI9341</strong></p>



<p><a href="https://github.com/juj/fbcp-ili9341">https://github.com/juj/fbcp-ili9341</a></p>



<p><strong>Raspberry Pi GPIO Information</strong></p>



<p><a href="https://www.raspberrypi.org/documentation/usage/gpio/" target="_blank" rel="noreferrer noopener" label=" (opens in a new tab)" class="broken_link">https://www.raspberrypi.org/documentation/usage/gpio/</a></p>



<p><strong>Adafruit</strong></p>



<p><a rel="noreferrer noopener" aria-label=".96&quot; OLED Product Page (opens in a new tab)" href="https://www.adafruit.com/product/684" target="_blank">.96&#8243; OLED Product Page</a> (Not the display I ended up going with for resolution reasons, otherwise it&#8217;s very nice.)</p>



<p><a rel="noreferrer noopener" aria-label="1.3&quot; 240x240 TFT LCD Product Page (opens in a new tab)" href="https://www.adafruit.com/product/4313" target="_blank">1.3&#8243; 240&#215;240 TFT LCD Product Page</a> (My ultimate choice for this diorama)</p>



<p><a href="https://learn.adafruit.com/adafruit-1-3-and-1-54-240-x-240-wide-angle-tft-lcd-displays?view=all">Tutorial/Learning Page for the 1.3&#8243; display</a> (wiring, python, etc.)</p>



<p><strong>VICE</strong></p>



<p><a href="https://csdb.dk/release/?id=179123" target="_blank" rel="noreferrer noopener" aria-label="The Elder Scrollers Demo by Booze Design (opens in a new tab)">The Elder Scrollers Demo by Booze Design</a></p>
<p>The post <a rel="nofollow" href="https://krystof.io/mirroring-raspberry-pi-hdmi-video-to-a-st7789-1-3-inch-lcd-display/">Mirroring Raspberry Pi HDMI Video to a ST7789 1.3 inch LCD Display</a> appeared first on <a rel="nofollow" href="https://krystof.io">Krystof.IO</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://krystof.io/mirroring-raspberry-pi-hdmi-video-to-a-st7789-1-3-inch-lcd-display/feed/</wfw:commentRss>
			<slash:comments>23</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 class="post-modified-info">Last Updated on March 17, 2023.</p>
<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 &#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 class="post-modified-info">Last Updated on October 6, 2020.</p>
<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>
