<p>This podcast is about a little programming exercise I learned in my first programming class. The idea is to generate a random text-based maze and make mouse ('@') search the maze systematically to find the cheese ('V'). If it does so before it runs out of energy (moves) it wins ('$' == happy mouse). Otherwise it starves ('%' == dead mouse).</p>
<p>You can find my git repos for the Raspberry PI code including this program at these locations:</p>
<ul>
<li><a href="https://gitlab.com/catrpi/catrpi.git" class="uri">https://gitlab.com/catrpi/catrpi.git</a></li>
<li><a href="https://github.com/ctelfer/catrpi.git" class="uri">https://github.com/ctelfer/catrpi.git</a></li>
</ul>
<p>The Mouse-in-a-maze program also requires the catlib library as well which is at:</p>
<ul>
<li><a href="https://gitlab.com/catlib/catlib.git" class="uri">https://gitlab.com/catlib/catlib.git</a></li>
<li><a href="https://github.com/ctelfer/catlib.git" class="uri">https://github.com/ctelfer/catlib.git</a></li>
</ul>
<p>You may note that these directories are different from those in my previous RPI episodes. The repositories used to be on gitorious. However since gitlab acquired gitorious, I have migrated the repositories. They currently live on both github and gitlab and I have pushing updates to both for the time being. So I have been waffling about which one will be the ultimate master for these projects. But since, I am doing most all the work on this code myself, it doesn't much matter for the time being.</p>
<p>If this is your first time playing with bare metal programming in the RPI you can get more info and tips from HPR episodes 1619, 1630 and 1666. Note that the gitorious links in those episodes are outdated as mentioned above. The github links therein should still be fine though.</p>
<p>The mouse code itself is in the <code>apps/mouse0</code> directory. If you haven't played with this environment before you'll need to do the following:</p>
<ul>
<li>Get a compatible ARM toolchain up and running to build for the RPI. I recommend using: <a href="https://github.com/dwelch67/build_gcc/blob/master/build_arm" class="uri">https://github.com/dwelch67/build_gcc/blob/master/build_arm</a></li>
<li>You'll need a USB-to-TTL serial cable to hook up to the RPI. I use: <a href="https://www.adafruit.com/products/954" class="uri">https://www.adafruit.com/products/954</a></li>
<li>You'll also need a small SD card to boot from.</li>
<li>Follow the steps in catrpi/README.txt to
<ul>
<li>create an SD-card with a loader on it.</li>
<li>build catlib for the RPI locally (a prereq for building mouse0.bin)</li>
<li>set up your serial connection to the RPI</li>
<li>start up a minicom instance to connect to the RPI</li>
</ul></li>
</ul>
<p>Once those prerequisites are taken care of you can:</p>
<ul>
<li>change directory to <code>/path/to/catrpi/apps/mouse0</code> type <code>make</code> to build</li>
<li>mouse0.bin power on the RPI at the loader prompt, type 'x' in the</li>
<li>serial console to start X-modem reception on the RPI</li>
<li>use your terminal program to send the mouse0.bin file via X-modem. In minicom you do this by CTRL-A followed by 's'. You then select 'xmodem' as the protocol and navigate to and select the file <code>mouse0.bin</code> to send.</li>
<li>when the transfer completes type 's' to start the program</li>
</ul>
<p>These pages describe VT100 Terminal codes:</p>
<ul>
<li><a href="https://ascii-table.com/ansi-escape-sequences-vt-100.php" class="uri">https://ascii-table.com/ansi-escape-sequences-vt-100.php</a></li>
<li><a href="https://www.termsys.demon.co.uk/vtansi.htm" class="uri">https://www.termsys.demon.co.uk/vtansi.htm</a></li>
</ul>
<p>Sample traversal:</p>
<pre><code>  ########################################
  #+0****## #+#...###...#..$ ##  #  #    #
  ##+###+## #+++......#...# ##       #   #
  # #.+++++#....#   #      #    #      # #
  #  #+++++#+.+..#  #  #          #      #
  #  #.##.+++#+.### #     #   #   ##     #
  #  ###.+.##++.##     #   ###     #   # #
  ####+.#..#++#.##   #      #####   ##   #
  #++#.#.###+.##    ##       ##    #   # #
  #++++++.##.++.#   #  ##     #  # #  # ##
  #+++++#..##.##      ## #  #### # #    ##
  #+.....#..#.  ##   #      #     ##  ## #
  #+..+.......   # #      #      #  ##   #
  #+...#..###       # #  #          ##  ##
  #.#..#.........# # # # ##### # #    ## #
  #.......##  ##....  #        ###   ##  #
  ##......# ##   ##..#  #####          # #
  #.+.#...###    ###. ##          ##  # ##
  ##.+...#  #      ####      #   ##    # #
  ########################################
  Mouse found the cheese!  :)  Press any key to restart!</code></pre>
<h3 id="links">Links</h3>
<ul>
<li><a href="https://gitlab.com/catrpi/catrpi.git" class="uri">https://gitlab.com/catrpi/catrpi.git</a></li>
<li><a href="https://github.com/ctelfer/catrpi.git" class="uri">https://github.com/ctelfer/catrpi.git</a></li>
<li><a href="https://gitlab.com/catlib/catlib.git" class="uri">https://gitlab.com/catlib/catlib.git</a></li>
<li><a href="https://github.com/ctelfer/catlib.git" class="uri">https://github.com/ctelfer/catlib.git</a></li>
<li><a href="https://github.com/dwelch67/build_gcc/blob/master/build_arm" class="uri">https://github.com/dwelch67/build_gcc/blob/master/build_arm</a></li>
<li><a href="https://www.adafruit.com/products/954" class="uri">https://www.adafruit.com/products/954</a></li>
<li><a href="https://ascii-table.com/ansi-escape-sequences-vt-100.php" class="uri">https://ascii-table.com/ansi-escape-sequences-vt-100.php</a></li>
<li><a href="https://www.termsys.demon.co.uk/vtansi.htm" class="uri">https://www.termsys.demon.co.uk/vtansi.htm</a></li>
</ul>
