Computer Haiku (converted from C64)

Here's the original C64/PET program - "Computer Haiku" by Commodore Educational Software, 1983

This was brought to my attention on t'other forum and I thought it looked interesting - but we can't have Commie programs clogging up the pages of Sinclair forums, can we, either this one or that one (or Sinclair ZX World, or anything else out there for that matter)? Once I'd discovered the original program was written in BASIC, I thought I'd examine the listing and convert it for the Spectrum. Obviously, all the colours were going to be different and the layout was probably going to be different seeing as the Commie can handle 40 columns at a time, but it should otherwise have been a straightforward job.. right?

Most of the original code was discarded as the Bread Bin has no PRINT AT or colour commands, and uses massive strings of system variables, POKEs and control characters instead - so the title screen, menu and instructions sections were all rewritten to make them look like the original, just in different colours. More system variables and control characters had to be worked round from line 1000 in the original (660 in this version), to make the haiku appear as it should. Generating it in the first place was more complicated on the Commie as - for reasons only known to the original programmer - the random number generator was set by the system timer. I thought it unnecessary to PEEK 23672 (the Spectrum's equivalent) and translate that - it's just using RANDOMIZE at the start of the program and then taking whatever comes from then onwards. The second line had to be generated first, so that the length of the line could be checked and junked if it was over 32 characters - one place the Commie had an advantage. I think my introduction and exit screens are far better than the original, though.

The original was full of error-checking routines which were unnecessary on the C64 but which would stop the program in its tracks if it was run on a PET that couldn't handle it. (There was probably a VIC-20 version as well, but with its horrifically limited text screen, everything would spill over onto two lines.) None of these were needed - all I had to do was condense the program after I found out it couldn't be loaded on a 16K Spectrum (see that as the equivalent of a PET in this case). This involved removing all the REM statements - which I've shown below just in case anyone wants to examine the structure of the program and make it easier - but it also meant wheeling out the old 1K ZX81 trick of using NOT PI, SGN PI, INT PI and a ton of VALs every time a numerical value appeared... and there were a lot of them. Still, that meant plenty of bytes were saved, and the program would run on the smallest Spectrum with ease. It now looks like a complete mess, but at least on a Spectrum the memory-saving tricks don't slow the process down anywhere near as noticeably as they did on a ZX81.



Download the program
Write computing-based haiku
You have much honour.


  • edited September 20
    if haiku's have a name , this one is
    kilos in bytes
    deliver heavy duty
    of free conducted words
    Post edited by Crisis on
    my old website has changed to so just click it and select a file
  • edited September 23
    Hi, reading your comment on the 'other' site i would say, nice job and even some times to good!
    line 120 IF z$<"1" OR z$>"4" will do and will save another few bytes.
    You could choose to reserve 'n' and 'o' for n=0 and o=1. Its a little bit slower, but saves 1 byte per NOT PI etc.
    If you want to even drop the DIM bit and go for a RESTORE LINE aproach, ???
    then you are re-programming and not porting, but it will save about 1.2 kb i think?
    Post edited by Crisis on
    my old website has changed to so just click it and select a file
Sign In or Register to comment.