<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harald Fernengel on Medium]]></title>
        <description><![CDATA[Stories by Harald Fernengel on Medium]]></description>
        <link>https://medium.com/@haraldfernengel?source=rss-bebe1247fe65------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9vHMzuJf0ztdddvZ.</url>
            <title>Stories by Harald Fernengel on Medium</title>
            <link>https://medium.com/@haraldfernengel?source=rss-bebe1247fe65------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 00:55:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haraldfernengel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Wing Commander 3 30th Anniversary Edition on macOS]]></title>
            <link>https://medium.com/@haraldfernengel/wing-commander-3-30th-anniversary-edition-on-macos-9e2c24c0b015?source=rss-bebe1247fe65------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e2c24c0b015</guid>
            <category><![CDATA[wing-commander]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Harald Fernengel]]></dc:creator>
            <pubDate>Mon, 09 Nov 2026 19:03:22 GMT</pubDate>
            <atom:updated>2026-11-09T19:03:22.144Z</atom:updated>
            <content:encoded><![CDATA[<p>Want to play the newly released Wing Commander 3 30th Anniversary Edition also on a Mac? With the neat new hi-res videos, sound and joystick support? If you don’t mind installing a few tools, feel free to give <a href="https://github.com/haraldF/wc3w-recomp">https://github.com/haraldF/wc3w-recomp</a> a try.</p><p>Note — it doesn’t contain any parts of the Wing Commander game itself, but tools that recompile the game to a native arm64 macOS binary with a thin emulation layer that you can run without emulators like wine or DOSBox. Run npm run play and enjoy.</p><p>There are some other small scripts, like npm run print-save that show your progress, the ship’s morale and the morale of every pilot from your save game. Remember — the higher the morale, the better they’ll fly on your wing.</p><p>And if you prefer the older style graphics of the “legacy” edition (I only tried the GOG version, but others should work as well with some tweaking): <a href="https://github.com/haraldF/wc3-recomp">https://github.com/haraldF/wc3-recomp</a></p><p>Linux is not fully supported as I hooked in directly with the macOS MIDI audio system for sound output. If you have some tokens left and want to play on Linux, feel free to create a merge request.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e2c24c0b015" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wing Commander with steady FPS]]></title>
            <link>https://medium.com/@haraldfernengel/wing-commander-with-steady-fps-50e7cc0e8b36?source=rss-bebe1247fe65------2</link>
            <guid isPermaLink="false">https://medium.com/p/50e7cc0e8b36</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[wing-commander]]></category>
            <dc:creator><![CDATA[Harald Fernengel]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 21:16:16 GMT</pubDate>
            <atom:updated>2026-10-28T21:16:16.719Z</atom:updated>
            <content:encoded><![CDATA[<p>One of my favorite retro games of all time is the good old Wing Commander, released in 1990, for MS-DOS. There are several ways to play it nowadays, like the version on <a href="https://www.gog.com/en/game/wing_commander_1_2">GOG</a>. It comes with DOSBox, so you can play it even on Mac and Linux or in most modern browsers that support WebAssembly. However — just emulating the original game has its limits, e.g. you won’t be able to easily tamper with it.</p><p>One of my main problems with the various DOS emulators is that they emulate a slow CPU, so the same issues that made the original Wing Commander annoying still persist — you’re in an asteroid field with many enemies and your game goes down to a frames per second, removing all the fun. Just increasing CPU speed makes the game run too fast, good luck hitting an enemy that flies faster than you can think.</p><p>So, can we have a version that solves these problems? Motivated by Eric S. Raymond’s <a href="https://www.heise.de/en/news/Open-Source-Guru-Raymond-AI-Ends-Closed-Source-Software-11480690.html">famous post</a>, I decided to give reverse engineering a quick try and oh boy — it became so easy. Something that would have taken me months to achieve now took half an afternoon, thanks to Claude. The game was decompiled in no time and I was able to add various tweaks, like very fast startup (e.g. no delay before the intro screen) and separate speed settings for flying vs. the rest of the game.</p><p>So if you own a copy of the GOG version of Wing Commander and you’re not afraid to install a few development tools, you can enjoy it either as native app (via SDL3) or as a web assembly app (should run on all modern browsers) with steady frames per second independent of your CPU speed:</p><p><a href="https://github.com/haraldF/wc-decomp">GitHub - haraldF/wc-decomp: Wing Commander 1 decompilation experiment</a></p><p>Both native and web versions support mouse, keyboard and joystick / gamepads as well as sound output. And since the apps are native, you can just launch it on your machine or open it in your browser, no DOS emulator required.</p><p>The <em>README</em> and <em>CLAUDE.md</em> files should be quite verbose, so if you have some tokens left and want to fix some other behavior, feel free to fork and contribute!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50e7cc0e8b36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross compiling C/C++ from macOS to Raspberry Pi in 2 easy steps]]></title>
            <link>https://medium.com/@haraldfernengel/cross-compiling-c-c-from-macos-to-raspberry-pi-in-2-easy-steps-23f391a8c63?source=rss-bebe1247fe65------2</link>
            <guid isPermaLink="false">https://medium.com/p/23f391a8c63</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[clang]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Harald Fernengel]]></dc:creator>
            <pubDate>Mon, 22 Oct 2018 16:45:10 GMT</pubDate>
            <atom:updated>2018-10-22T16:45:10.015Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Every now and then, I need to run some utility written in C++ on my Raspberry Pi. Now, there are powerful solutions like <a href="https://crosstool-ng.github.io/">crosstool-ng</a> and others, but they require a lot of setup and time. Looking for something simpler? Then here you go:</p><h4>Prerequisites</h4><p>This article expects that Xcode and <a href="https://brew.sh/">homebrew</a> are installed on your Mac and that your Raspberry Pi is running Linux and set up for login via ssh.</p><h4>Step 1: Compiler and binutils</h4><p>In order to compile for the Raspberry Pi, we need binutils to assemble and link binaries and a compiler that can produce code for the ARM CPU. In this step, we install <a href="https://clang.llvm.org/">clang</a> as compiler and the <a href="https://www.gnu.org/software/binutils/">GNU binutils</a> compiled for the hard float GNU EABI, which is what most Linux distributions run. In addition, we also install <a href="https://rsync.samba.org/">rsync</a> from homebrew, which we need later:</p><pre>brew install arm-linux-gnueabihf-binutils llvm rsync</pre><h4>Step 2: Sysroot</h4><p>In order to compile anything meaningful, we also need the libraries that come with our Raspberry Pi Linux distribution. There are multiple ways to obtain them, like using remote file systems. This is however quite slow and requires to have the Rasbperry Pi online and running all the time while compiling. I found it more convenient to simply use rsync to sync the relevant directories directly to my Mac.</p><p>Run the following command in your favourite directory (e.g. your home directory):</p><pre>rsync -rzLR --safe-links \<br>      pi@raspberrypi:/usr/lib/arm-linux-gnueabihf \<br>      pi@raspberrypi:/usr/lib/gcc/arm-linux-gnueabihf \<br>      pi@raspberrypi:/usr/include \<br>      pi@raspberrypi:/lib/arm-linux-gnueabihf \<br>      sysroot/ </pre><h4>Bringing it all together</h4><p>We now have all the pieces together, let’s compile our first C++ program. Save the C++ code below to a file called hello.cpp:</p><pre>int main() { return 42; }</pre><p>In order to compile it, we launch the clang compiler that we installed with homebrew in Step 1, letting it know where to find the binutils from Step 1 and the sysroot from Step 2:</p><pre>`brew --prefix llvm`/bin/clang++ \<br>    --target=arm-linux-gnueabihf \<br>    --sysroot=$HOME/sysroot \<br>    -isysroot=$HOME/sysroot \<br>    -isystem=$HOME/sysroot/usr/include/c++/6.3.0 \<br>    -isystem=$HOME/sysroot/usr/include/carm-linux-gnueabihf/c++/6.3.0 \<br>    -L$HOME/sysroot/usr/lib/gcc/arm-linux-gnueabihf/6.3.0 \<br>    -B$HOME/sysroot/usr/lib/gcc/arm-linux-gnueabihf/6.3.0 \<br>    --gcc-toolchain=`brew --prefix arm-linux-gnueabihf-binutils` \<br>    -o hello \<br>    hello.cpp</pre><p>Note: Adapt the paths above if your Linux doesn’t use gcc 6.3.0 as default compiler, or if you chose a different path than your home directory in Step 2.</p><p>This command creates the “hello” executable which will run on any Raspberry Pi. Happy compiling!</p><h4>Praise</h4><p>Big thanks to zw3rk for his work:</p><p><a href="https://medium.com/@zw3rk/making-a-raspbian-cross-compilation-sdk-830fe56d75ba">Making a Raspbian Cross Compilation SDK</a></p><p>And of course to the homebrew people that allowed me to submit the <em>arm-linux-gnueabihf-binutils</em> package.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23f391a8c63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiling TensorFlow Lite for a Raspberry Pi]]></title>
            <link>https://medium.com/@haraldfernengel/compiling-tensorflow-lite-for-a-raspberry-pi-786b1b98e646?source=rss-bebe1247fe65------2</link>
            <guid isPermaLink="false">https://medium.com/p/786b1b98e646</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Harald Fernengel]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 00:00:00 GMT</pubDate>
            <atom:updated>2018-02-26T09:18:23.742Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>The team behind <a href="https://www.tensorflow.org/">TensorFlow</a> recently released a “<a href="https://www.tensorflow.org/mobile/tflite/">Lite</a>” version of their open-source machine learning library. Unfortunately, the documentation only talks about iOS and Android, but not how to make it work on another embedded device, like my little <a href="https://www.raspberrypi.org/">Raspberry Pi</a> board. After a few hours of toying with build systems and cross-compiling, I managed to get the label_image example to run on my Raspberry Pi Zero W. Here’s a quick walkthrough.</p><p>Note — Since I’m using a Mac, the next chapter is Mac OS X specific. If you’re on Windows or Linux, please follow one of the many existing guides to get a cross-compiler and a corresponding CMake toolchain and skip over the next chapter.</p><h4>Setting up a cross-compiler on a Mac for a Raspberry Pi</h4><p>The first thing we need is a cross-compiler and a corresponding toolchain file that tells CMake how to invoke it.</p><p>Of the many ways to cross-compile for the Raspberry Pi, I found the walkthrough at <a href="https://medium.com/@zw3rk/making-a-raspbian-cross-compilation-sdk-830fe56d75ba">https://medium.com/@zw3rk/making-a-raspbian-cross-compilation-sdk-830fe56d75ba</a> the most convenient. It’s quick to set up and requires neither custom disk images nor bootstrapping your own compiler. Note that I used the latest LLVM and binutils, which at the time of writing were LLVM 5.0.1 and binutils 2.30.</p><p>Once we have our Raspberry Pi SDK, we need a corresponding <a href="https://cmake.org/">CMake</a> toolchain file for cross-compiling. I wrote a quick one here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa6dd05b87771fa0a92932cdfafa3a3c/href">https://medium.com/media/aa6dd05b87771fa0a92932cdfafa3a3c/href</a></iframe><p>Note — if you’ve downloaded another LLVM than 5.0.1, adapt the paths above accordingly. Save the file to rpi-toolchain.cmake and set the environment variable RPI_SDK to point to the path where you installed the Raspberry Pi SDK, for example:</p><pre>export RPI_SDK=$HOME/raspbian-sdk</pre><h4>Compiling TensorFlow Lite</h4><p>Now comes the fun part — compiling the TensorFlow Lite library and the example. TensorFlow itself is using the <a href="https://bazel.build/">Bazel</a> build system, which, while I’m sure has its reason of existence, isn’t very wide-spread yet, so rather than trying to get Bazel to do what I want, I found it easier to add a couple of CMakeLists.txt to get a cross-build. The code can be found at my private fork at <a href="https://github.com/haraldF/tensorflow/tree/cmake">https://github.com/haraldF/tensorflow/tree/cmake</a>.</p><p>First, download the source code:</p><pre>git clone <a href="https://github.com/haraldF/tensorflow.git">https://github.com/haraldF/tensorflow.git</a><br>cd tensorflow &amp;&amp; git checkout -b cmake origin/cmake</pre><p>In addition to the TensorFlow Lite code itself, some third-parties are needed. In order to get those, there’s a convenience script that we can run:</p><pre>./tensorflow/contrib/lite/download_dependencies.sh</pre><p>Now, we’re ready to build:</p><pre>cd tensorflow/contrib/lite<br>mkdir rpi-build &amp;&amp; cd rpi-build<br>cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/rpi-toolchain \<br>-DCMAKE_BUILD_TYPE=Release ..<br>make -j4</pre><p>Replace /path/to/rpi-toolchain with the CMake toolchain file for your cross compiler and -j4 with the amount of CPU cores your machine has. After a short coffee break, you should now have a file called libtensorflow-lite.a which is a static library containing the TensorFlow Lite code and the example atexamples/label_image/label_image. Copy the example and the reference bitmap (examples/label_image/testdata/grace_hopper.bmp) to your Raspberry Pi.</p><p>The example also needs the <em>mobilenet</em> model. You can find the link in the TensorFlow Lite README.md file (<a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/">link</a>). At the time of writing, the example used mobilenet_quant_v1_224.tflite. Download, unzip and copy the model to your Raspberry Pi. If everything went well, you should have the following files on your Raspberry Pi:</p><pre>grace_hopper.bmp<br>label_image<br>labels.txt<br>mobilenet_quant_v1_224.tflite</pre><p>Now we can finally run the TensorFlow Lite example by invoking:</p><pre>./label_image</pre><p>On my Raspberry Pi Zero W, it takes about 5 seconds to run, with the following output (The error about opening libneuralnetworks.so can be safely ignored):</p><pre>nnapi error: unable to open library libneuralnetworks.so<br>Loaded model ./mobilenet_quant_v1_224.tflite<br>resolved reporter<br>invoked<br>average time: 5600.14 ms<br>0.666667: 458 bow tie<br>0.290196: 653 military uniform<br>0.0117647: 835 suit<br>0.00784314: 611 jersey<br>0.00392157: 922 book jacket</pre><p>If you’ve come this far — congrats, you can now run TensorFlow Lite on your RPi :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=786b1b98e646" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>