• Please review our updated Terms and Rules here

MAME running workstations

This is a utility I wrote for patching the OS to accept more than just mapping videomem and RTC in userspace.
And it turns out there are 2 OS variables, shared_page0 and shared_page1 whose values specify address of 4k pages to be mapped on a call
to phys(2) and phys(3).

 
Got the x2210 NVRAM chip hooked up so it can persist its MAC address.
Also got am7990 ethernet controller chip working - ish. There is some issue with with IRQ. I'm using IRQ_4 which I *think* is right.
 
Got the x2210 NVRAM chip hooked up so it can persist its MAC address.
Also got am7990 ethernet controller chip working - ish. There is some issue with with IRQ. I'm using IRQ_4 which I *think* is right.
Wrong - was IRQ2.

But I have managed to telnet into a Tektronix 4404 MAME emulation which is kinda crazy.


Screenshot 2025-02-05 093155.png
 
Early tests doing floating point matrix multiplies using vanilla C runtime vs mapping the ns32081 into user space and writing directly to it are promising - just using the native C compiler (which isn't great at optimal loops) its around 500% faster.

Annoyingly, gcc1.42 does a pretty good job but outputs some move instructions like this:

Code:
move.l d0, 0x00(a3)

And the native assembler chokes on a hex constant offset.. 🤪 Rebuilding gcc1.42 is moderately scary and will have to wait for another day.
 
Or you could patch the printf format inside gcc binary from %x to %d (or whatever the assembler expects)...
 
Or you could patch the printf format inside gcc binary from %x to %d (or whatever the assembler expects)...
Just need to carve out some time and sit down to go through the gcc config/tm- files to see where it outputs offsets in hex and rebuild.
You know the drill, its one of those things that you can't just dip into - you need to dive deep into it for a few hours.
 
Fixed the millisecond alarm emulation in MAME so ESetAlarm() / signal(SIGMILLI, ...) now work. It works by using the timer 1&2 output pins to latch the interrupt and then have addresses 0x100 above this reset the interrupt. This IRQ (IRQ1) is shared with the printer but I've ignored that for now.

Screenshot 2025-02-23 at 10.35.50.png
 
@shattered I've done a quick port of tar to Uniflex. Wrapped not having group id in a macro to minimize visible code changes.

https://github.com/Elektraglide/tek4404/blob/main/tar.c

sys++ tar xvf test2.tar
Tar: blocksize = 20
x wmgr/events.c, 2654 bytes, 6 tape blocks
x wmgr/vtemu.c, 15317 bytes, 30 tape blocks
x wmgr/win.c, 59 bytes, 1 tape blocks
x wmgr/wmgr.c, 36045 bytes, 71 tape blocks
 
I was surprised to learn at the beginning of the year that MAME - the thing that started life as an arcade emulator - has changed over the years to be per-chip signal accurate emulator and supports many workstations such as Sun, MG1 etc.

For the past 6 months I've been battling with getting the MAME Tektronix 4404 emulator to work and I am very close but could do with some advice / ideas.

When I started, the emu would start but do little else. I got it to run and pass its selftest with some input of a couple of folks on the MAME discord but it would not boot the OS.
Over the summer I did manage to fix loading the OS file by adding a 3.5us delay on one of the scsi protocol commands (XFI_OUT_ACK). What was happening is the (emulated) scsi would finish and immediate raise an IRQ. The Tek4404 was not expecting this so quick and would clear the IRQ then busy wait listening for an IRQ that it had just erased. Doh!

Anyway, that allowed it to load the OS (see screenshot) and start the OS proper. Woot.

Once task#0 is running it runs a task that execs the program /etc/init. How this works is the code is loaded, then its all swapped out to disk, then it starts execution (typically at address 0x0). This immediately page faults (nothing there), brings in the page and continues. This works (with a caveat).

[Tek4404 has a custom MMU that only does address translation in user mode that I *think* I've implemented correctly but wise peeps of MAME tell me the code is not in the preferred place.]

I can then single step the /etc/init code for a few instructions in the text section after which it writes a word to its data section at 0x507e (ie page table entry 5). Only text is in memory at this point so it page faults, goes off, allocates a new VM page, and (I assume) reads that 1 page into newly allocated memory. The code to restart task execution inspects the task signal to confirm the page has swapped in but never gets the signal it completed, so never makes it ready to run, so never re-starts the faulting instruction.

So it does not halt. Its running the scheduler, doing idle tasks and and a whole bunch of housekeeping. It just never sees the task#1 as ready to run so continues indefinitely.

So I somehow need to work back to figure out why it never gets the signal from scsi that its loaded - my hunch is its a timing issue like when it was loading the OS.

The ghidra file is on my repo if you want to dig around. Its not helped that I don't know alot about scsi protocol implementations - I *think* its just a couple of guys in MAME dev community that sort of own that code. The Tek4404 uses the ncr5385 scsi controller chip and its this file that I've been poking at over the months.

Thoughts?



View attachment 1291425
WOW - this is so awesome. I have a couple of CDS68020 machines that I would like to get UniFLEX running on. I have the 6809 version running on the Kees 6809 UniFLEX system that I built from bare boards. I also have it running on my 6809 emulator (SWTPCemuApp). I have not however been able to locate a copy for the CDS68020. I know that it existed at some point because I have seen ads for it. Peripheral Technology still makes the CDS68020 (aka PT68K-5). I currently have the CDS68020 machines running SK*DOS and OS9. The PT68K-2 and PT68K-4, I have running SK*DOS and minix version 1.4b for the 68K. I would like to find a copy of the hard drive image that you are booting the MAME emulator for the 4404 with. I have a copy of it I scarfed from somewhere, but I am not sure it is legit. Also, note that the FloppyMaintenance program understands the image that I have.
 
WOW - this is so awesome. I have a couple of CDS68020 machines that I would like to get UniFLEX running on. I have the 6809 version running on the Kees 6809 UniFLEX system that I built from bare boards. I also have it running on my 6809 emulator (SWTPCemuApp). I have not however been able to locate a copy for the CDS68020. I know that it existed at some point because I have seen ads for it. Peripheral Technology still makes the CDS68020 (aka PT68K-5). I currently have the CDS68020 machines running SK*DOS and OS9. The PT68K-2 and PT68K-4, I have running SK*DOS and minix version 1.4b for the 68K. I would like to find a copy of the hard drive image that you are booting the MAME emulator for the 4404 with. I have a copy of it I scarfed from somewhere, but I am not sure it is legit. Also, note that the FloppyMaintenance program understands the image that I have.
Uniflex on the Tektronix 4404 is obviously written to the custom MMU this machine uses, so not sure it would be very useful for the CDS68020s.. Plus all the drivers are specific to the hardware features of the machine too.

I wonder whether you'd be better off starting with whatever is on there and adding 4.2BSD feechurs + gcc for example.

If you want a command shell that runs in 44k, this is what I wrote for tek4404 :-)
https://github.com/Elektraglide/ash

 
Hello,
Awesome work with the emulator! I'm trying to install UniFLEX myself. I created a 40Mb chd with "chdman createhd --chs 830,6,17 -o disk0.chd" (although I would prefer to create the 90Mb disk in the brochures, I haven't been able to find the exact disk model for it so I don't know the CHS value), booted from the OS 2.0 SYSREFORMAT disk but after a minute or so I'm met with a blank cursor and no activity. Is this normal? (For reference, I've built mame from the tek4404_working2 branch)
 
Hello,
Awesome work with the emulator! I'm trying to install UniFLEX myself. I created a 40Mb chd with "chdman createhd --chs 830,6,17 -o disk0.chd" (although I would prefer to create the 90Mb disk in the brochures, I haven't been able to find the exact disk model for it so I don't know the CHS value), booted from the OS 2.0 SYSREFORMAT disk but after a minute or so I'm met with a blank cursor and no activity. Is this normal? (For reference, I've built mame from the tek4404_working2 branch)

No, it should boot.
If you start mame with -debug it will have the mame debugger window visible. This allows you to press F3 to emulate pressing the reset button. Pressing F3 twice will bring up the diagnostic program that allows testing various things. Have you all the roms you need?

Let me bundle together a folder with mame 4404 emu + all the files you need for a known good setup and see how you get on.

Adam
 
From the self-tests, Interval Timer (spams the screen with errors), Virtual Memory, Mouse Interface seem to fail. Others are OK.
Oh, and also to note, I am on an Apple silicon Mac.
 
OK, here you go. Download this into your MAME build folder and unpack it.
It will add neccessary roms and a couple of launch scripts to your mame folder:
mac4404.sh
win4404.bat

as well as macmame and winmame which are builds of MAME with just the Tektronix drivers (ie much smaller than the fullfat version).

At the command line, you should be able to run the appropriate one to boot Tektronix 4404 and get to the login prompt.

https://elektraglide.com/mame_4404_overlay.zip


Screenshot 2025-07-06 at 17.10.53.png
 
Any chance you could share the bar.chd file as well?

Also, you don't have to enable the debugger to use the F3 keybind, just have to enable the front end controls (Delete key on macOS (fn+backspace), ScrollLock on Windows I believe?)
 
Back
Top