Mini Micro has an "attract mode"!

joestrout

JoeStrout

Posted on October 9, 2024

Mini Micro has an "attract mode"!

Mini Micro is the free neo-retro virtual computer that is a popular environment for writing retro-style games and demos in MiniScript. It contains a large number of demo programs in the /sys/demo directory. But did you know there is an "attract mode" that cycles through some of these demos — even self-playing a game of Asteroids?

The "demos" demo

One of the program files in /sys/demo is demos.ms. You can load and run this manually, or, as a short-cut (defined in /sys/startup.ms), you can just type demos at the prompt to launch it. It comes up like this.

Screenshot of demos program in its default state

You can see a list of games and demos on the left, and the MiniScript code for the currently selected program on the right. Instructions are at the bottom: press up/down arrow to select a program, and then press Return (or Enter) to run it. Or press the Esc key to exit.

When you press Return to run a demo, the program actually "types out" the load and run commands for you. This is to help new users learn how to do these things themselves. Then the selected program is actually launched. When the program exits (some demos wait for you to press Esc before exiting), it should automatically return to the demos list.

Animated GIF of running the

The list of programs here does not include all the demos on the /sys disk. It's just a hand-selected subset. So this certainly shouldn't be the only way you explore the contents of /sys/demo, but it's a handy way, especially when you're new to the platform. It could also be useful for little users, for whom use of the dir, load, and run commands might be a bit much (at least at first).

But wait! There's more!

The last option in the list on the left is labeled "(More...)". Selecting this presents the screen below.

Screen shot of

This encourages the user to exit to the command-line and explore the demos directly. But it also points out the auto-run or "attract mode" feature, accessed by pressing the A key.

Pressing A puts the system into auto-run mode, and launches the globe demo. It then cycles through an even smaller subset of visually interesting demos. In Mini Micro 1.2, these are:

  • Globe
  • Quadris
  • The Matrix
  • Turtle Demo
  • Asteroids

Quadris and Asteroids — normally single-player games — detect that the system is in auto-run mode (by looking at the env.autorun environment variable), and go into automatic play. They don't play very well, but they are still entertaining to watch.

Animated GIF of asteroids demo self-play

Left alone, Mini Micro will cycle through these demos forever. This is like the attract mode that arcade games used to use to catch the attention of passing gamers; it's the machine's way of saying "play with me!" It also acted as a screen saver, avoiding burn-in that could occur if the same image were drawn on the screen for too long.

Of course, when you want to stop the autorun mode, you can press Esc between demos, or press Control-C at any time.

How it works

The demos demo makes use of two little-known features of the Mini Micro environment:

1. It sets env.shell to /sys/demo/demos.ms, i.e., its own file path. Setting this environment variable defines that program as the shell, i.e., the program that should be launched whenever the current program exits normally. The desktop and lcars programs also act as shells, and you can make your own shell program this way too.

Note that if a program exits because of an error, or because you pressed Control-C, then the shell is not automatically launched; instead you are dropped into the normal MiniScript REPL (command line). But in that case, the exit command will return you to the shell.

2. While in autorun mode, it also sets env.autorun to the name of the program it's running. This isn't anything built into Mini Micro, but just a convenient place for the demos shell to stash this extra bit of information it needs to know what program to launch next.

When demos is launched and env.autorun is nonempty, it knows it's in auto-run mode, and it uses the string found there to figure out which demo to launch next. The Asteroids and Quadris programs also check this to know when to do their auto-play thing.

So now you know — Mini Micro has an attract mode! What will you do with it? Share your thoughts in the comments below!

💖 💪 🙅 🚩
joestrout
JoeStrout

Posted on October 9, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Mini Micro has an "attract mode"!
miniscript Mini Micro has an "attract mode"!

October 9, 2024