Essential Travel Items

We've recently enjoyed a fantastic holiday in Fuerteventura (near the resort of Jandia). A brilliant place to relax, and it's on a 30km stretch of beautiful sandy beach. The weather was fantastic too (it's often a bit breezy on Fuerteventura but we don't mind that).

The view from our balcony was quite nice too:

When travelling, I carry a bag to keep my Camera, Kindle, Tablet, etc... in, but it greatly amuses my wife that I also carry: graph paper, a variety of pens, a ruler, and a protractor. I view this as entirely sensible, since at any moment I may decide I need to draw some kind of diagram.

Now, I don't actually use graph paper or a protractor very often when I'm on holiday, but I still like to carry them... just in case. I find it strangely comforting. Is that weird?

Having said that, I also make sure I have a C compiler on my tablet these days, which is actually quite likely to see gentle use during a holiday. That probably is weird, but I'm happy to accept that.

For example, during this holiday I wrote some C helper functions to make it easier to allocate resizable blocks of memory. Basic boilerplate stuff, but I enjoy tinkering with things like that...

Raspberry Pi low-res fractal in C

Of course, it wouldn't be me unless I tried drawing a mandelbrot on the Raspberry Pi. Here is the traditional ASCII character version, but with some low-res colours.

Raspberry Pi Mandelbrot in C

I have to admit that the colour idea was inspired by somebody called Paulo Lellis, who had read some of my previous posts and adapted my code to include colour codes. It was very kind of Paulo to show me what he had done. I've simply tweaked it some more.

Anyway, if you'd like to try it, here is the source code:

#include <stdio.h>

/*
   Compile like this:
   gcc mandel.c

   Then run the code, like this
   /.a.out
*/

main()
{
   float b,e,r,n,d;
   int h;
	
   for(e=1.1; e>-1.2; e-=.1)
   {
      for(b=-2; b<1; b+=.04)
      {
         // see: http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
         printf("\033[1;4%dm%c\033[0m",(h%8),32);
				
         n=0;
         h=127;
         for(r=0; r*r+n*n<4 && --h>32; d=r)
         {
            r = r*r-n*n+b;
            n = 2*d*n+e;
         }
      }
      printf("\r\n");
   }
}

Well, I had to try the C compiler on the Raspberry Pi at some point.

Z80 C Compiler

z88dk logo

I like BBC Basic programming on the Z88, but I also wanted to write proper Z88 applications that appear in the main menu.  But I didn't really want to have to resort to Assembly Language.  This is where Z88dk comes in.  It is a C compiler that originally targetted the Z88 specifically.  So now I can write applications for the Z88 in C.  As a bonus Z88dk also works for many other Z80 based machines.

But rather than copy the resulting files straight to a real Z88; I've also found this rather good emulator:

Z88 emulator

...which seems a very easy way to test your code before sending to a physical machine. This emulator seems to work fine on Windows 7, even the 64 bit version.