RC2014 (Mini) on MAME

138 views
Skip to first unread message

Chris Swan

unread,
Feb 21, 2022, 12:47:34 PMFeb 21
to RC2014-Z80
I've seen some folk in the retro community doing very cool things with MAME, so a while back I thought I'd have a go at doing RC2014, as it's pretty much the simplest practical computer. And after cloning MAME and poking around some of the 'drivers' I realised that I didn't know where to start (and sadly the docs don't exactly start with a beginners guide). Maybe if I was better at C++ it would all be obvious, but I was lost without a map.

But then the London Retro Computing Meetup had an event 'Using MAME as a development tool', where Phill, one of the core devs, provided a walk through of building a simple driver. Even more fortuitously I spotted that somebody had added the Grant Searle Simple Z-80 Machine since I'd last taken a look. Now I had my Rosetta Stone for figuring out which lumps of code corresponded to which lumps of hardware, and how they're 'wired' together.

So now I have a driver at https://github.com/cpswan/mame/blob/cpswan-rc2014mini/src/mame/drivers/rc2014mini.cpp which I've yet to pull request upstream; and there's a blog post at https://blog.thestateofme.com/2022/02/21/rc2014-mini-on-mame/ providing some background.

And I'm wondering if anybody else has tried something like this, or wants to try something like this? What would you add or do differently? How should I approach 'modules'? (Phill showed how to use MAME for a Z-80 clock along with LED segment displays and lots of hardware stuff, so it should be possible to emulate blinkenlights and buttons etc.).

John Kennedy

unread,
Feb 26, 2022, 6:33:57 AMFeb 26
to RC2014-Z80
Great idea - glad you made concrete progress. 

Phillip Stevens

unread,
Feb 26, 2022, 10:10:37 AMFeb 26
to RC2014-Z80
I've seen some folk in the retro community doing very cool things with MAME, so a while back I thought I'd have a go at doing RC2014, as it's pretty much the simplest practical computer.
And I'm wondering if anybody else has tried something like this, or wants to try something like this? What would you add or do differently?

It is not in the same league as MAME, but related is z88dk-ticks which is a command line emulator for z80 (also 8085, z180 and z80n) that can be used to time execution speed of code, or test programs on a host computer. z88dk-ticks includes a debugger and disassembler in addition to supporting hotspot analysis. It doesn't get much air-time, because it sort of disappears inside the z88dk, but I use it all the time.

It supports a very simple RC2014 machine model, using the ACIA Module on the standard ports. It also supports the APU Module at the correct 3:1 clock ratio, so trade-offs can be calculated.
The RC2014 support is enabled simply by including "rc2014" in the name of the binary file loaded. The code is very simple, so can be extended for specific applications if anyone is interested.

It also supports CP/M applications, simply by feeding in a file with ".COM" in the name of the file.

It does our cycle accurate benchmarking, so we can compare compilers and libraries accurately.
I used this recently to check the Hi-Tech C v7.80p2 performance, for example, and also to update the SDCC results for the below release.

SDCC recently (in upcoming 4.2.0 release) has started issuing new library calls, where two int are multiplied to a long, in both signed and unsigned versions.
I wanted to include these calls in the am9511 APU Module math library for the RC2014, but previously I'd tested that the APU was slower than the RC2014 z80 when handling integers.
So, z88dk-ticks was useful to analyse the performance of the two alternatives for 32_16x16 multiplies, and it turned out that the z80 is faster with unsigned multiplies, but the APU is faster with signed multiplies. Not something you would just guess, unless you're counting a lot of lines of code.

The hotspot analysis (enabled in the debugger) is also useful for working out what code is being used all the time, and therefore can benefit from optimisation.
Whether it is in-lining a code fragment, or simply exchanging a jr for a jp, you can get a concrete analysis based on the benchmarks or other test code.

Anyway,  hope that's useful info, and an option for emulations when you don't have an RC2014 machine to hand.

Cheers, Phillip

$ z88dk-ticks

Ticks v0.14c beta, a silent Z80 emulator by Antonio Villena, 10 Jan 2013

  ticks [-pc X] [-start X] [-end X] [-counter X] [-output <file>] <input_file>

  <input_file>   File between 1 and 65536 bytes with Z80 machine code
  -tape <file>   emulates ZX tape in port $FE from a .WAV file
  -trace         outputs register values and disassembly while executing
  -pc X          X in hexadecimal is the initial PC value
  -start X       X in hexadecimal is the PC condition to start the counter
  -end X         X in hexadecimal is the PC condition to exit
  -counter X     X in decimal is another condition to exit
  -int X         X in decimal are number of cycles for periodic interrupts
  -w X           Maximum amount of running time (400000000 cycles per unit)
  -d             Enable debugger
  -l X           Load file to address
  -b <model>     Memory model (zxn/zx/z180)
  -m8080         Emulate an 8080
  -m8085         Emulate an 8085 (mostly)
  -mgbz80        Emulate a gbz80 (mostly)
  -mz80          Emulate a z80
  -mz180         Emulate a z180
  -mr2ka         Emulate a Rabbit 2000
  -mr3k          Emulate a Rabbit 3000
  -mz80n         Emulate a Spectrum Next z80n
  -mez80         Emulate an ez80 (z80 mode)
  -x <file>      Symbol file to read
  -ide0 <file>   Set file to be ide device 0
  -ide1 <file>   Set file to be ide device 1
  -iochar X      Set port X to be character input/output
  -output <file> dumps the RAM content to a 64K file
  -rom X         write-protect memory, X in hexadecimal is first RAM address

  Default values for -pc, -start and -end are 0000 if omitted. When the program exits, it'll show the number of cycles between start and end trigger in decimal

$

Chris Swan

unread,
Mar 4, 2022, 8:27:47 AMMar 4
to RC2014-Z80
Things have moved on a fair bit since my original post.

The MAME team thought the rc2014mini driver was too similar to the gsz80 driver to be on its own, so the resultant work was incorporated into gsz80.cpp, but after much back and forth on the pull request there's now RC2014 (Mini) support in upstream MAME, which should be in the 0.242 release when that comes along. I've kept my original driver on a branch.

I'm still hoping to get more RC2014 stuff into MAME in due course, and I'm also planning to write a series of blog posts explaining the process of creating a driver.

Reply all
Reply to author
Forward
0 new messages