Note: This post is a summary of my posts to this thread on the Bannister forums.
The PSI Ψ 98 is an early 80s micro computer manufactured by Kontron. It was mainly used for industrial controlling or science lab computer. Recently, rfka01 posted pictures, ROM images and disk images of his unit to the Bannister MAME forum. It’s specs are roughly:
- Z80 @ 4 MHz
- 256 KB RAM (up to 16 MB total, using a simple MMU)
- MC6845 CRT controller displaying 80×25 lines or 512×256 graphics on a monochrome monitor
- Various Z80 support chips: Z80DMA, Z80CTC, Z80SIO, Z80PIO
- µPD765 FDC with two 5,25 inch drives
There is some documentation available and all major components are already emulated by MAME, so it shouldn’t be too hard to add.
The first step is to load the ROMs into the correct memory address, then make sure that it can access it’s RAM. This is a bit more involved here because of the memory management, but luckily there is a good enough description in the manual. So, after making sure that writes to the memory mapper ports map memory into the correct locations we let the CPU run a bit more. It’s easy to see which I/O ports it accesses, because MAME logs reads and writes to unmapped addresses. Among the writes, we see it writing data to the 6845 and also to video memory ports. The video memory on this system isn’t mapped into the main memory map, but instead accessed via the I/O ports. After hooking those writes up, we can already see in the debugger the first screen it wants to display! So, next step: Get something displayed on the emulated screen. The 6845 drawing routine itself is nothing special and similar to other systems, so it can be implemented quickly, which results in:
That’s all it does for now. But, by looking into the log again, we see lots of accesses to floppy controller ports, which basically means that it already tries to boot from floppy (even though we haven’t hooked up a lof the Z80 support chips).
After a bit more work and hooking the µPD765 up:
Looking quite promising! CP/M complains here that it can’t load the SETCRT program. After a bit of investigation we see that it tries to load it using DMA, which wasn’t hooked up fully. Fixing this, we get this result (also added support for inverted characters here):
Sure would be nice if we could actually enter something now! The PSI supports two kinds of keyboards: A serially connected one or a parallel one (they actually use the same connector). Since the system expects ASCII codes we can just use the generic ASCII keyboard MAME offers for now and attach it to the relevant I/O ports:
With the keyboard hooked up, we can now get into the debugger stored in boot ROM by pressing Ctrl-K:
The command MT 6000 1000 I’ve entered starts a memory test. As you can see it fails here, pointing to issues with the way we implemented our system memory. There is also a disk test that you can start with the command J 1800:
Since we now have a nice test case, the memory mapping can be fixed for good which results in KOS booting fully now:
The login is “*” (which means it points to the default working directory).
It works quite nicely at this point, however any access to the second drive results in the system hanging. In the debugger we can see that it’s running in a tight loop, waiting for a value in memory to change. This means it’s waiting for an interrupt routine that changes this value to continue. The last command executed by the µPD765 is RECALIBRATE. This command issues an interrupt when it finishes, and indeed we see this interrupt happening. So, what’s going on here? The interrupt simply happens too fast, before the system has a chance to setup it’s waiting loop. Looking at the floppy disk controller code we can see that RECALIBRATE is supposed to seek to track 0, then issue the interrupt. In MAME, a freshly inserted disk always starts with the head at track 0, so the command finishes instantly. Easy fix then, just add a small delay before the command completes and issues the interrupt. This makes it possible to access the utilities disk in drive 2 and run commands from there.
One of the programs on this disk is a BASIC demo called “MAGIC”. It runs in the graphics mode, so that’s perfect for implementing it:
Playing around with the system, I’ve noticed that the disk format command didn’t work. A hang just like the problem we fixed earlier. And indeed, adding a small delay after a SEEK command when the disk is already at the correct track fixes it too:
Some things left to add: Printing over the centronics port. Load MAME like this:
mame psi98 -flop1 kos605d -flop2 util605d -prin output.txt
Then enter the following commands:
(loads the parallel output driver)
PRINT KOS.INF O=$PIO
(print the file KOS.INF to this driver).
RS-232 ports. Load MAME like this:
mame psi98 -flop1 kos605d -flop2 util605d -rs232a null_modem -bitb socket.127.0.0.1:1234
This attaches the null modem to serial port a, and connects it to port 1234 on the local computer. Start PuTTY now and tell it to connect to localhost:1234 with connection type “raw”. Let the emulated system boot now, open the TAB menu and configure the RS-232 port to 2 stop bits. Then enter the following commands:
(load serial port a driver)
(attach this driver to input channel 5)
(attach this driver to output channel 5)
(start simple terminal program)
At this point you should be able to see any entered keys in the PuTTY window, as well see everything typed into PuTTY in the emulated system. Here are some screenshots:
Pasting ASCII art:
So, what’s left? A major point is SASI (it wants the Adaptec ACB-4000 controller). For this, we need to emulate the custom DMA circuit which sadly isn’t described anywhere. The keyboard is currently HLE’ed and not emulated, but we do have a dump of the keyboard controller. It would also be nice to add an ECB card slot system and some cards (memory, I/O, etc.).