Nanorogue2 in BASIC

I've completed my BASIC 10-Liner contest entry, download on itch.io

Just shove the disk (.atr) in Atari800MacX or any other compatible Atari 800XL emulator, disable BASIC and hit reset, it should boot up into the launcher:

Where you can read docs or source:

And play the game!

So, the source for my first pass was manually-packed down, and I couldn't really fit everything I wanted in there, or switch to text-graphics mode. With some rethinking, and a better source editing tool, I could… So I wrote a filter program "Basic2List.py" that removes comments & blank lines, joins up everything after a numbered line with colons, lets me insert binary codes with \xFF escapes. It still looks a little dense, because I have to manually use abbreviated statement names or remove spaces, I'd like to make it smart enough about BASIC source to do that itself.

But it lets me turn source like:

5   POKE731,1       // noclick
    GR.1            // 20x20 wide chars, 40x4 regular
    SE.1,13,15      // palette 1 to gold
    W=20            // world size
    DIME$(27),M(W,W)    // E$() encounter table, M() map
    //RRRZZZD$$..........#######>
    E$="\xF2\xF2\xF2\xFA\xFA\xFA\xE4\x04\x04\xAE\xAE\xAE\xAE\xAE\xAE\xAE\xAE\xAE\xAE#######\x3E"
    H=10        // Hit Points
    L=1     // Level
    // G=0      // Gold, default value
    ?"NANOROGUE BY MDHUGHES"

into:

5 POKE731,1:GR.1:SE.1,13,15:W=20:DIME$(27),M(W,W):E$="RRRZZZD$$..........#######>":H=10:L=1:?"NANOROGUE BY MDHUGHES"

(except the RRR... are inverse & graphics chars)

See the Atari BASIC Quick Reference Guide to learn the abbreviations and some of Atari's peculiarities. And it's running in Turbo Basic XL which really helped the program size, so I was able to squeeze in stairs!

Last time I was using the compiler, and that worked but it distorted my sounds, and I couldn't make LAUNCHER.CTB run NANOROG2.CTB! So if I just left them all uncompiled (but tokenized) .BAS files it works fine.

The only down side is it's stuck in easy mode. I'd love to have a difficulty which increases the GP to Level Up, and makes monsters hit harder (but not reward more), but that didn't quite make the cut.

Generally I'm pretty pleased by this!

The ZX Spectrum (non-Next) port is turning out to be hard, it lacks a few things and doesn't have ELSE, either, so I don't know if it can be done.

10-Line BASIC Contest

Let's go back to the 1980s!

So I knocked down a tiny subset of my already tiny BASIC demo program, NANOROGUE, and plan to make 10-line versions for Atari 800 and ZX Spectrum. Getting it running on desktop in Chipmunk BASIC was trivial. Just a little ANSI for screen positioning.

Initially I just used standard Atari BASIC, and that worked fine, if very very tightly packed, and not fast… but the lack of an ELSE statement left me with an 11-line program, I wanted to end with 50 ... :GOTO 20:ELSE:GOTO 20:ENDIF but had to move it to a new line. Very frustrating. So I'm using an enhanced BASIC, which is allowed for the PUR-120 tier, for one command.

Being "compiled" (to bytecode, don't expect miracles) and making AUTORUN.SYS easier than my own utility is nice. TBXL is at least a 1985 tool; though at the time I was using the "official" BASIC XE cartridge instead, which had similar features, and mainly moving over to Action!, 6502 ASM, and C. But for retrocomputing it's fair game.

Making a TBXL executable & bootable disk is a little fussy.

  1. Make a blank floppy ATR (emulator disk format), format it, put Atari DOS 2.5 on it or whatever you like (from DOS 2.5, H to write DOS files). This is your program disk. Like TRON, everything you do will be encoded on it, and losing it will subject you to immediate deresolution.
  2. Turbo BASIC XL disk in D1, program disk in D2. Control menu, Disable BASIC, Cold Reset (Sh-F5). You should see a red load screen, then READY. Check you're in TBXL by typing DIR.
  3. Write your program. I recommend writing BASIC as LST files in a desktop editor, then Cmd-E "Edit an atr disk image", click "Atari/Mac Linefeed Translation", "Import Files From Mac". In BASIC, ENTER "D2:FOO.LST". RUN to test it. But if you like living the '80s lifestyle all the way (or using non-ASCII chars, which are annoying to work with), you can work entirely in TBXL.
  4. Save your program tokenized: SAVE "D2:FOO.BAS"
  5. BRUN "D1:COMPILER.COM", now swap D1 and D2 (Cmd-D, click the swap buttons; you want your program disk in D1!), hit 1, pick FOO.BAS, save as AUTORUN.CTB. Swap disks back (you want your program disk in D2!).
  6. Ctrl-D, J for Ja (yes) to go to DOS-XE. COPY D1:RUNTIME.COM D2:AUTORUN.SYS
  7. Now put your program disk in D1, reset, and it should come right up into your program, then prompt for Dos, Run, or Load when it ends. Nice!


So resuming work on NANOROG, I get:

The only down side is this tiny version has a very slow redraw, it renders the entire screen each move, instead of just fixing last/new positions. I'm pondering changing it to graphics 1 (wide text, 4 colors) and poking screen memory which is probably faster than printing. I made some acceptable bleeps and buzzes with SOUND commands; I'm a poor sound designer, but I get there with some trial and error.

Anyway, next week's task is the ZX Spectrum version. Speccy BASIC is pretty good, so I expect I can knock that out quick and without all these shenanigans.

Textfiles

Looking for VT100 documentation, I found a folder of textfiles VT100 animations, including the classic Bambi vs. Godzilla.

Slightly difficult to watch on any modern computer, so save this script: (works on Mac & other Unix-likes, wtf knows what Windows does for clear and reset.)

Use: % slowblade.py ~/Downloads/bambi_godzila.txt 500

slowblade.py: [update 2021-01-14, encoding]

#!/usr/bin/env python3
# by Mark Damon Hughes. Licensed under Creative Commons Attribution 4.0 International license.

import os, sys, time

def slowblade(f, spd):
    try:
        os.system("clear")
        text = open(f, encoding='Windows-1252').read()
        for c in text:
            sys.stdout.write(c); sys.stdout.flush()
            time.sleep(1.0/spd)
        print("")
        input("[press enter]")
    finally:
        os.system("reset")

if __name__ == "__main__":
    if len(sys.argv) == 1: raise Exception("Usage: slowblade.py FILENAME [SPEED (default 100)]")
    else: slowblade(sys.argv[1], int(sys.argv[2]) if len(sys.argv) >= 3 else 100)

Computer Archaeology: Public Caves Discovered!

Exploring the archives of the People's Computer Company (a public timesharing computer center in the early '70s, yes before home computers), and many of the programs we're familiar with from David H. Ahl's Creative Computing come from here. 15 different variations on guess the number and guess a coordinate, sure, but also some really important things, many of them long forgotten.

Then I find this artifact:

pcaves

What the. This is basically a MUD†, from 1973!

Source code (uses a very long TREES library on previous pages).

Everyone knows WUMPUS, which is based on CAVES, but this is the rock star of these! How does everyone not have a copy of PCAVES? This is like finding a working Airwolf helicopter in a cave with ochre handprints on the walls. HOW THE FUCK did cavemen do that? Why don't we all have an Airwolf, if it existed 47 years ago?!

So anyway some barely-modernized version of this will be added to the MysticDungeon soon, you'll all be able to graffiti up a cave!

† more like a MUSH ("Multi-User Shared Hallucination") with one user at a time, specifically.

  • Note: You can play a version from the Narrascope conference 2019: PublicCavesNarrascope
  • Renga in Blue typed it in for the above event, and briefly reviews it as an adventure game. Which it's not, this is a social environment, literally a MUSH.

Lost Treasure

In 1979, I learned to program in BASIC on a TRS-80 Model I. Sometime in the next year, I read one of my first programming books:

I played Monster Chase and Lost Treasure, modified them extensively, and combined them, so the cave on the island had a monster chase to reach the exit. I recall having problems getting Starship Alpha and Devil's Dungeon to work, but they joined my software library eventually.

One of my earliest and happiest programming memories was sitting at the dining room table, reading Monster Chase, and writing out a smarter movement system and obstacles in a notebook; at the time the only computers were at school, so I wrote code on paper and typed them in later.

So when I found the book again on archive.org last night, I was very excited, and had to reimplement it. I actually typed this into Pythonista on my phone with the PDF open on an iPad, only moved it to the computer to do some final cleanup and upload it.

The book suggests some modifications, and I did some minor ones: Lowered the movement error to 10%, and risk of shark attack to 10%, rising by 1.5x rather than a flat +50% each time; being anywhere near the island edge killed you too often in the original. I also don't move you out of the water automatically, that should cost a turn.

I realized in converting it that I hate, hate, hate Row,Column coordinates instead of Cartesian X,Y; tons of mainframe-era computing resources used Row,Column, and you can still see it in some APIs like Curses. Note that the original program is 74 lines, mine's 214; BASIC is a terrible language, but it's terse.

I could adapt this into another doorgame for my Mystic Dungeon BBS, but I'm not sure what the multiplayer aspect would be, and it has limited replayability without doing some randomization.