<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zvika Meiseles</title>
    <description>The latest articles on DEV Community by Zvika Meiseles (@zvikam).</description>
    <link>https://dev.to/zvikam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F15259%2Ff4a77ece-a5cb-4175-b172-292bd60f3645.jpeg</url>
      <title>DEV Community: Zvika Meiseles</title>
      <link>https://dev.to/zvikam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zvikam"/>
    <language>en</language>
    <item>
      <title>DOS on WII</title>
      <dc:creator>Zvika Meiseles</dc:creator>
      <pubDate>Fri, 22 May 2020 14:21:53 +0000</pubDate>
      <link>https://dev.to/zvikam/dos-on-wii-3d19</link>
      <guid>https://dev.to/zvikam/dos-on-wii-3d19</guid>
      <description>&lt;p&gt;So, the kids out-grew their Nintendo WII and moved on to Xbox (or Netflix). What's an electronics-hoarder like myself supposed to do?&lt;/p&gt;

&lt;p&gt;There is an old saying: "If you love it then you should have run DOOM on it", so I set out to do that, and more. And while I'm at it, why not take the scenic route?&lt;/p&gt;

&lt;p&gt;NOTE: I will not cover how to jailbreak and install homebrew.&lt;/p&gt;

&lt;h1&gt;
  
  
  Choosing a Linux distribution
&lt;/h1&gt;

&lt;p&gt;Looking at the raw computing power, the WII should have no problem running Linux:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PowerPC CPU running at 729 MHz&lt;/li&gt;
&lt;li&gt;ATI Hollywood GPU running at 243 MHz&lt;/li&gt;
&lt;li&gt;88 MB of memory (ouch!)&lt;/li&gt;
&lt;li&gt;WiFi 802.11b/g&lt;/li&gt;
&lt;li&gt;USB, Audio, Video, blah blah blah&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a few linux distributions ported to the WII, and I went through a couple before choosing.&lt;br&gt;
The 1st time I got the WII to boot was using WiiToo. It is a Gentoo based system, so it is very flexible.&lt;br&gt;
However, I found that it requires quite a bit of work to update it on the little WII, both on my side (it's a very old version, dating back to 2009) and on Wii's side, since Gentoo is all about compiling-from-source.&lt;/p&gt;

&lt;p&gt;So I moved on, looking for a binary-package-based distribution. and I found Whiite, which is a Debian 5 (Lenny) distribution. But soon I found, again, that it is hard to get a 2009-ish system up-to-date.&lt;/p&gt;

&lt;p&gt;After taking a short break, I came back to the project and found Wii-Linux-NGX and I knew this was the one!&lt;br&gt;
Based on Debian 8, updated in 2017 - finally, something to work with.&lt;/p&gt;

&lt;p&gt;We will start with the base system, as detailed in &lt;a href="https://neagix.github.io/wii-linux-ngx/" rel="noopener noreferrer"&gt;Wii-Linux-NGX&lt;/a&gt;.&lt;br&gt;
After we successfully boot, we will start the post-installation setup.&lt;/p&gt;

&lt;p&gt;change default root password&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ passwd&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;configure Wifi&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ /root/whiite-ez-wifi-config&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;rename the network adapter device name&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;edit /etc/network/interfaces

&lt;ul&gt;
&lt;li&gt;wlan0 -&amp;gt; wlan1&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;we really need to enable swap, because compilation, which we will get to a little later, won't work with 88MB or RAM. also, we will use the actual /tmp partition on the sd-card.&lt;/p&gt;

&lt;p&gt;enable swap (in /etc/fstab)&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/dev/mmcblk0p3 swap swap defaults 0 0&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;disable tmpfs on /tmp by commenting the line &lt;em&gt;/tmpfs . . .&lt;/em&gt; in /etc/fstab&lt;br&gt;
and enable swap&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ swapon -a&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;next, enable remote ssh access, because working with a keyboard in front of the TV is sub-optimal.&lt;br&gt;
we'll use RSA keys and not passwords. feel free to skip this part&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;allow root remote login with password&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;edit /etc/ssh/sshd_config
PermitRootLogin yes
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$ service ssh restart&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;login remotely&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create /root/.ssh/authorized_keys&lt;/li&gt;
&lt;li&gt;copy RSA/DSA public keys to it&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;revert changes to /etc/ssh/sshd_config&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ service ssh restart&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;now we can log out, login remotely from a normal laptop, and move-on.&lt;/p&gt;

&lt;p&gt;next step - update the system. a lot has changed since 2017.&lt;br&gt;
for starters - the PPC repositories have been archived, so we need to point our system to the new location&lt;/p&gt;

&lt;p&gt;PowerPC APT repositories have moved, so add the new locations to /etc/apt/sources.list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;  deb http://archive.debian.org/debian/ jessie main
  deb http://ftp.ports.debian.org/debian-ports unstable main
  deb http://ftp.ports.debian.org/debian-ports unreleased main
  deb http://ftp.ports.debian.org/debian-ports experimental main
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and engage&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;apt update
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;apt upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;next, install additional packages.&lt;br&gt;
specifically, xorg and build tools, since we're going to have to compile stuff from source code&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ apt install libpng12-0 libstdc++6 libx11-6 zlib1g gcc patch autoconf automake libtool libsdl1.2-dev libsdl-sound1.2-dev libsdl-net1.2-dev make g++ xorg lightdm git&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;thinking ahead, we're going to have a few non-root users for running our software.&lt;br&gt;
we will have a separate user for each software: DOSBox, ScummVM and DOOM.&lt;/p&gt;

&lt;p&gt;since most of these are SDL based, we're going to have to grant these users low-level access to the keyboard, mouse, audio and video.&lt;br&gt;
1st, allow console access to dedicated group&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;addgroup &lt;span class="nt"&gt;--system&lt;/span&gt; console 
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;chgrp &lt;/span&gt;console /dev/console
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;g+rw /dev/console
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and add our dosbox user&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;useradd &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="nt"&gt;-U&lt;/span&gt; dosbox
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;usermod &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-G&lt;/span&gt; console dosbox
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;usermod &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-G&lt;/span&gt; &lt;span class="nb"&gt;tty &lt;/span&gt;dosbox
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;usermod &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-G&lt;/span&gt; video dosbox
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;usermod &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-G&lt;/span&gt; input dosbox
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;usermod &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-G&lt;/span&gt; audio dosbox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Building dosbox
&lt;/h1&gt;

&lt;p&gt;building dosbox from source is pretty straightforward.&lt;br&gt;
the only caveat is the build time on the WII hardware: ~1.5 hours.&lt;br&gt;
it is also the reason we had to enable swap, or gcc would fail compiling some of the more complex source files.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;wget https://netix.dl.sourceforge.net/project/dosbox/dosbox/0.74-3/dosbox-0.74-3.tar.gz
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xzf&lt;/span&gt; dosbox-0.74-3.tar.gz
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;dosbox-0.74-3
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;./autogen
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;./configure
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Building ScummVM
&lt;/h1&gt;

&lt;p&gt;as with dosbox, this is pretty straightforward but takes (a little more than) a while.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;wget https://www.scummvm.org/frs/scummvm/2.1.1/scummvm-2.1.1.tar.gz
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;LDFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-Wl,--no-keep-memory"&lt;/span&gt;  ./configure
&lt;span class="gp"&gt;  $&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Running DOOM
&lt;/h1&gt;

&lt;p&gt;Now, of course I could just run DOOM via dosbox, but since the source code is available, I decided to compile and run it.&lt;/p&gt;

&lt;p&gt;I started with the Linux SDL port of the doom code, but it turned out to have 2 major issues, and a minor one:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;it would not compile on a PPC CPU&lt;/li&gt;
&lt;li&gt;it was not full-screen&lt;/li&gt;
&lt;li&gt;it would not compile and run on a pure 64bit system&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;while #1 and #2 are crucial for our end goal, issue #3 was for debugging purposes only - it was easier developing the code on my laptop than on the WII, mainly due to compilation times.&lt;br&gt;
the code changes can be seen in detail in the github repo, but I will explain the changes in high level.&lt;/p&gt;
&lt;h4&gt;
  
  
  adding PPC support
&lt;/h4&gt;

&lt;p&gt;This was a small issue with the code when __&lt;em&gt;BIG_ENDIAN&lt;/em&gt;__ precompiler directive is defined.&lt;/p&gt;
&lt;h4&gt;
  
  
  64bit support
&lt;/h4&gt;

&lt;p&gt;This task turned out to be more than "just compile as 64bit".&lt;br&gt;
The code was very old and new GCC versions throw warnings and errors about&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;implicit &lt;em&gt;int&lt;/em&gt; variables&lt;/li&gt;
&lt;li&gt;string literals being cast to pointers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the 64bit part was a simple matter of not assuming&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sizeof(void*) == sizeof(int) == 4&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;h4&gt;
  
  
  full-screen
&lt;/h4&gt;

&lt;p&gt;the SDL 1.2 port was running doom in its native, awesome 90's resolution of 320x200, but the WII's video is aimed at pre-HDMI televisions, so the native resolution is 576x516.&lt;br&gt;
the code changes are localized to a single file &lt;em&gt;i_sdl_video.c&lt;/em&gt;.&lt;br&gt;
the original code in &lt;em&gt;I_InitGraphics&lt;/em&gt; used&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SDL_SetVideoMode(320, 200, 8, SDL_SWSURFACE)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;to initialize the the display-buffer, and then pointed the doom code to draw directly into it&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;screens[0] = (byte*) (screen-&amp;gt;pixels);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;we will modify the code to use 2 separate buffers - the screen will be initialized to our native resolution, and another buffer for doom to draw into, which is 320x200.&lt;br&gt;
1st, modify the video mode&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SDL_SetVideoMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;576&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;516&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SDL_SWSURFACE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;virt_screen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SDL_CreateRGBSurface&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SDL_SWSURFACE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;320&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;screens&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;virt_screen&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;pixels&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;now that we have both screens set up, we will need to modify the screen update routine &lt;em&gt;I_FinishUpdate&lt;/em&gt;.&lt;br&gt;
right before the original code, we will copy the image into the screen with scaling&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;virt_screen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;SDL_Flip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;for the scaling algorithm, I decided to go with a very simple algorithm, for 2 reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;speed&lt;/li&gt;
&lt;li&gt;consistency&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I wanted the copying to be as computationally-simple as possible, and give consistent results (e.g. no "random" offsets).&lt;br&gt;
the scaling math is pretty simple:&lt;br&gt;
    576 = (4*2+1)*64&lt;br&gt;
    516 ~= 500 = (3+2)*100&lt;br&gt;
this means that horizontally, we will copy&lt;br&gt;
4 times: 1 bytes --&amp;gt; 2 bytes, and another 1--&amp;gt;1&lt;br&gt;
vertically, we will duplicate 1 line 3 times, then 1 line 2 times.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;xmap&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ymap&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="c1"&gt;// *i - axis index&lt;/span&gt;
&lt;span class="c1"&gt;// *d - axis destination&lt;/span&gt;
&lt;span class="c1"&gt;// *s - axis source&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;yd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;ys&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;ys&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;xd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;xs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;xs&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;320&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;xs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// duplicate source pixel into destination line&lt;/span&gt;
      &lt;span class="n"&gt;memset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PIXEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;xd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;yd&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;PIXEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;xs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ys&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;xmap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;xi&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
      &lt;span class="n"&gt;xd&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;xmap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;xi&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
      &lt;span class="c1"&gt;// point to next destination pixel (after duplications)&lt;/span&gt;
      &lt;span class="n"&gt;xi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xi&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;SIZEOF_ARRAY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xmap&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="c1"&gt;// duplicate line as many times as required&lt;/span&gt;
   &lt;span class="c1"&gt;// -1 for the line we drew above&lt;/span&gt;
   &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;ymap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;yi&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;memcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PIXEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;yd&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;PIXEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;yd&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;576&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="c1"&gt;// point to next line (after duplications)&lt;/span&gt;
   &lt;span class="n"&gt;yd&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;ymap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;yi&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
   &lt;span class="n"&gt;yi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yi&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;SIZEOF_ARRAY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ymap&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;in order to run doom you'll need to download the WAD files, and then&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;export DOOMWADDIR=~/doom.wad.directory/
./sdl_doom/linux/sdl_doom
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and voila!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs6r24x40oypjwdu4sffp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs6r24x40oypjwdu4sffp.jpeg" alt="WII running doom on Linux, 40"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp7mrzj5tr1gbi6stfsnx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp7mrzj5tr1gbi6stfsnx.jpg" alt="old-skool DOS tools"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh2jww6p0necavqinl2yk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh2jww6p0necavqinl2yk.jpg" alt="ScummVM running all the oldies"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  finishing touches
&lt;/h1&gt;

&lt;p&gt;for each application, we will have a dedicated user that will auto-run the application when logging on.&lt;/p&gt;

&lt;p&gt;in order to accomplish that, we will simply add the relevant lines to each user's ~/.bashrc , e.g.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;dosbox
exit
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;the modified code is available here &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/zvikam" rel="noopener noreferrer"&gt;
        zvikam
      &lt;/a&gt; / &lt;a href="https://github.com/zvikam/sdl_doom" rel="noopener noreferrer"&gt;
        sdl_doom
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      SDL port of the linuxxdoom-1.10
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;SDL DOOM @ Debian/WII&lt;/h1&gt;

&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;Getting SDL-DOOM to run in full screen on Debian/WII/PowerPC&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Acknowledgements&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;ID Software &lt;a href="https://github.com/id-Software/DOOM" rel="noopener noreferrer"&gt;Linux Doom v1.10&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AlexOberhofer &lt;a href="https://github.com/AlexOberhofer/DOOM-X11-64Bit" rel="noopener noreferrer"&gt;DOOM-X11-64Bit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GeekChef.com &lt;a href="http://geekchef.com/more-doom-obsession-with-ubuntu-powerpc/" rel="nofollow noopener noreferrer"&gt;More Doom obsession with Ubuntu PowerPC&lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;License&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;see the &lt;a href="https://github.com/zvikam/sdl_doom/blob/master/DOOMLIC.TXT" rel="noopener noreferrer"&gt;DOOMLIC.TXT&lt;/a&gt; file for details&lt;/p&gt;

&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/zvikam/sdl_doom" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


</description>
      <category>dos</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
