Scripting

Options like -icmd, -menu and -cmd take a command or list of commands as a parameter. A command may be a single word like reset which will reset the emulator. Or it can be a list, for example [ poke 3c00 45 ] which puts an "A" in the top left of the Model 1 screen. The square brackets may also be used to create a list of commands. For instance, [ [ poke 3c00 45 ] [ poke 3fff 5b ] ] is two commands which put "A" in the top left of the Model 1 screen and "Z" in the bottom right.

The -ib file option takes a script file which is a series of commands, one per line. Here are the two poke commands in a file:

     poke 3c00 45
     poke 3fff 5b

If the file starts with #! then it will be recognized as a script and its commands will run if passed directly on the command line or dragged and dropped onto the main window.

On Linux and MacOS trs80gp can be used as a script processor using the usual #! (hash bang) file start. For example, if trs80gp is in /user/george/trs80gp then this script will launch it emulating the Color Computer and have the software keyboard and debugger start up.

    #!/user/george/trs80gp -mc
    postmsg debug
    postmsg soft_keyboard
Unix only allows a single command line argument which we use up specifying the model to emulate. A mechanism to provide more command line arguments in this case is planned.

Generally speaking commands will alter the state of the emulator machine or the emulator itself. Here is a list of all the commands for reference each linked to their full description.

input command

    input

Changes the input mode for automated input.

poke command

    poke address-set value .. value

Set one or more memory locations to the given values. If address-set can be a single memory location values are put there and in following addresses until they are used up. If it is a range then the values are repeated until the entire range is filled. If there are no values then the entire range is filled with zeros. The address-set can be multiple comma-separated ranges. Values may be hexadecimal or symbol names. By default data is put into the memory space view of the main processor. The optional argument can select different memory spaces like -ram for the main random access memory or -vram for the display.

poke 3c00 21 will put a ! in the top left of the Model 1 or 3 screen.
poke 3c00:3fff 21 will fill the screen with !.
poke -vram 0:200 41 will fill the top half of the screen with A

pokew command

    pokew address-set value .. value

The same as the poke command except that two byte word values are poked into memory. These values will be poked with the correct endian for the CPU the TRS-80 uses. Little endian for Z-80, Z-180 and 8080, Big endian for 6800, 6803, 6809 and 68000.

pokestr command

    pokestr address-set string .. string

The same as the poke command except that the strings are poked into memory. The strings can have escape codes such as \xFF.

poke -vram 0:3ff Hey! fills the screen with Hey!

pokefile command

    pokefile address-set file .. file

As with poke but the contents of one or more files are put into memory. The files are loaded as raw data unlike the (upcoming) load command which interprets /CMD files and other binary executable formats.

postmsg command

    postmsg

Sends a message to the user interface. Messages have various effects, usually popping up a dialog box or choosing a setting.

Ultimately this command should be replaced with sets of better controlled commands to trigger the various UI elements and settings. But it is too irresistable as it is easy to implement and powerful.

A full reference needs to be written up but some of the more useful ones are:

reset command

Causes a warm restart of the TRS-80.