- Robotron KC87 machine with Graphics Extension and a Plotter
- Robotron emulator JKCEMU
- Download, install and run jkcemu-X.X.X.jar – it can run on any OS
- Graphics extension drivers: WAV file (graf_com.wav) and TAP file (graf_com.tap)
- Inkscape to manipulate vector graphics
- Inkscape ExportXY extension to export point coordinates from SVG image
- Install it on top of Inkscape
- Some spreadsheet manipulation program like Excel or Numbers
- Picture that you want to plot in SVG format
All files used and created in this article can be found in my Github repository.
On a high level, to plot vector graphics on KC87 we will:
- Prepare a binary file containing coordinates of polygons to be drawn
- Write a BASIC program that will read the coordinates from memory and draw lines on the screen and on the plotter
- User emulator to test the program and produce audio files to load into a real KC87
Preparing Graphics Coordinates File
In this step we will prepare a binary file containing coordinates of the polygons to be plotted. This file will be later loaded into KC87 memory and accessed by a BASIC program that will do the plotting job.
Coordinates File Format
I used the following format for the coordinates file:
- File ends with 0xFFFFFFFF to indicate the end of plotting data
- File contains segments to be drawn as polygons. Each segment ends with the last XY coordinates repeated. This indicates that a pen must go up and a new polygon will start at the next coordinates.
- Each polygon contains coordinates of its vertices, first X, than Y
- Each vertex is encoded as 16-bit integer number in the little-endian order
Extracting coordinates from an SVG file
- Load SVG image into Inkscape
- Add more nodes to the bezier curves by selecting the whole picture and choosing Extensions→Modify Path→Add Nodes.
- Eliminate bezier curves and convert them to straight lines by selecting the whole picture and clicking Make selected segment lines icon.
- Export the coordinates data using ExportXY extension. Select all vertices and run the extension. The end of a polygon in the data is indicated by repeated vertex coordinates.
- Copy the point coordinates to a spreadsheet (eric_data.xlsx). Check and eliminate any coordinates that are equal to 65535.
- In the spreadsheet, scale the coordinates to eliminate fractions and make them positive integer numbers in the range of 0 to 32767. It does not really matter what range you assume, as it can be later brought to the screen or plotter coordinate system with the BASIC’s SCALE command. Here I scaled them to the max of 512 on the X axis. You can insert an XY chart to see the data, this is very convenient.
- You can also play with decreasing the maximum coordinate value down to zero and scaling the vertices – this produces some cool images.
- Save the processed data as a CSV file (eric_data.csv). Choose MSDOS encoding to avoid problems with Unicode characters. At the end of all polygons, add a vertex with coordinates (65535, 65535) to indicate the end of data.
- Now to transform the CSV data into the binary file (eric_data.bin), I wrote a simple Python script (csv-to-16bits.py):
- The resulting file is the binary file we need (eric_data.bin).
Preparing BASIC Program
Starting Emulator and Loading Binary Data
The JKCEMU needs to be configured with the following options (see configuration file):
- Machine: KC87
- Grafik: Farbe, Robotron-Vollgrafikerweiterung
- Memory: 16K RAM-Modul (4000h-7FFFh) and 16K RAM-Modul (8000h-BFFFh)
- Extensions: Plotter XY4131 / XY4140
After the OS booted, use the menu option Datei→Laden to load:
- Graphics driver: graf_com.tap
- Binary coordinates data file: eric-data.bin
- Choose data format: BIN-Datei (Speicherabbild ohne Kopfdaten)
- Calculate start address (Anfangsadresse) as lower than 0x4000 – bin file size. In this example start address is set to 0x2E00 = 11776.
- After data is loaded, the memory range use will be displayed in the window’s status bar only for a few seconds, for example: Datei nach 2E00-3F53 geladen. Write down the upper memory address.
- Save the binary data back to a TAP format (eric-data.tap), so the addresses do not have to be entered at each file load.
- Use option Datei→Speichern and choose KC TAP Datei and Erster Block hat Nr.0 (…KC87…) parameters.
- Enter memory start address (Anfangsadresse) and end address (Endadresse) as noted when loading binary file into memory.
- Provide a short name under Bezeichnung – this is the name by which data will be loaded from the tape of audio file later.
- Choose type (typ) as COM. This is not entirely accurate, as this is not executable data, but emulator seems to screw data name if it is not selected.
- Leave starting address (Startadresse) as empty
Now start basic by typing command BASIC and give MEMORY END lower than the binary file start address (in my case 10000).
The BASIC program reads coordinates data from the memory and draws polygons, first on the screen, then on the plotter. If the start address for binary data is different to 0x2E00, it must be changed in the code for the variable BASE.
Once BASIC is running, the SSS file can be loaded into emulator in the same way as other files before. Modified BASIC program can be saved back by choosing option Datei→BASIC-Programm Speichern. The program can be executed with a RUN command.
Running on a Real KC87
Preparing Audio Files
The audio files are required to run everything on a real KC87. The can be loaded from a modern device like tablet or mobile phone or saved to a cassette tape and played with a tape-recorder for the true experience.
The audio files can be created using Emulator’s option: Extra→Werkzeuge→Dateikonverter. Choose the following parameters:
- Convert binary coordinates TAP file (eric-data.tap) into WAV file (eric-data.wav). Please note that the name (Bezeichnung) must not contain dot and extension and the type must be COM. There is probably some but in the emulator that will save the data be named ERIC.ERI, duplicating the first three letters of the name into the extension.
- Convert BASIC SSS program file (eric-basic.sss) into WAV file (eric-basic.wav)
Loading into Real KC87
Under OS prompt, execute the following:
- Type GRAF and load graf_com.wav
- Type ERIC.ERI and load eric-data.wav
- Type BASIC and start BASIC, provide earlier calculated MEMORY END (in my case 10000)
- Type CLOAD “ERIC” and load eric-basic.wav
- Type RUN and observe the effects!
If you have troubles with finding the loading name for the files, please use the tool called analyse and play the audio files to it. For the above parameters, the resulting recordings were the following:
On a Real KC87