Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Z80 simulator for unit testing?

Reply to topic
Author Message
  • Joined: 05 Dec 2019
  • Posts: 56
  • Location: USA
Reply with quote
Z80 simulator for unit testing?
Post Posted: Wed Feb 05, 2020 6:44 pm
In the topic "Graphics corpus for compression research", Maxim expressed interest in testing graphics decompression code for correctness and cycle count. This would involve building a Z80 simulator.

For comparison, I'll describe a unit testing tool for another ISA. The cc65 project includes "sim65", a command-line 6502 simulator written in C. It provides 64 KiB of RAM as well as six paravirtualized functions in $FFF0-$FFFF for standard input/output and file input/output. Calling one of these addresses causes the simulator to halt the 6502, pop arguments from a software stack per the calling convention specified by C code, perform the function, and return. It has options -c to print the number of elapsed cycles and -x 100000 to set a cycle deadline.

How hard would it be to make an analogous Z80 simulator? Is one widely used? And how would we test the simulator itself for correctness?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
Post Posted: Wed Feb 05, 2020 6:53 pm
I think you want more of a cut down system simulator though, for example to write stuff to the VDP control ports and assert something about the contents of VRAM after it's done. I was also concerned with cycle counting and (sometimes) the access rate when targeting the active display period. The cycle counting would want to exclude any setup and teardown cost.

Zexall might be good for testing the simulator itself as it demands fairly high quality emulation, although it doesn't cover everything.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3823
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Feb 07, 2020 10:32 am
I never used it, but SDCC comes with an Z80 simulator, sz80.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Aug 2009
  • Posts: 213
  • Location: Seattle, WA
Reply with quote
Post Posted: Fri Feb 07, 2020 2:46 pm
Could Emulicious not be used for this? It tracks cycle counts and enforces VDP limits. You could use its profiler along with a screenshot comparison tool to validate expected vs. actual.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
Post Posted: Fri Feb 07, 2020 7:55 pm
It can't be automated currently...
  View user's profile Send private message Visit poster's website
  • Joined: 05 Jul 2017
  • Posts: 67
  • Location: Cornwall, United Kingdom
Reply with quote
Post Posted: Mon Feb 10, 2020 6:52 pm
How would it need to be automated?

I automate operation of Emulicious on my Mac using third-party solutions:
- Keyboard Maestro
- Controller Mate

I have custom hot keys and macros and have a DJ controller with big rubber buttons set to various debugger/step/user functions.

In fact, Calindro was kind enough to make some changes (window title, interface text, menus, shortcut keys) to help me automate things more easily.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
Post Posted: Mon Feb 10, 2020 7:00 pm
To run unit tests you might want to pass a bunch of stuff on the command line to make it do the thing and then emit a results file in a standard format for parsing.
  View user's profile Send private message Visit poster's website
  • Joined: 07 Aug 2007
  • Posts: 220
  • Location: Yach, Germany
Reply with quote
Post Posted: Mon Feb 17, 2020 11:39 am
I suggest to have a look at ucsim.

The Small Device C Compiler uses nightly regression testing compiling about 12000 tests, and executing them on the ucsim simulator.

To invoke the regression tests manually, try "make test-ucz80" in support/regression of a SDCC tarball or svn checkout.

Since it works well for SDCC, it should work for other projects that want to do regression testing of Z80 code.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!