Zymosis and ZXEmuT

Struggling with Fuse or trying to find an emulator with a specific feature. Ask your questions here.
User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Zymosis and ZXEmuT

Post by ketmar »

hi. just found this site (yes, i am that slow), and thought that i can share my Z80 CPU Emulation library with you.

libzymosis (Zymosis) is a standalone Z80 emulation library that can be used when you need to emulate one or more Z80 CPUs. it has almost-perfect emulation (the only test it failed is SCF/CCF, and i'm planning to [eventually] fix that too), and i used it in my ZXEmuT Speccy emulator.

interesting Zymosis features:
* written in C (yet it may contain some UBs due to integer wraparound and bit patterns, so you'd better compile it with gcc -fwrapv for now; i may fix that later);
* written from scratch, doesn't use code from other projects, and licensed as WTFPL (this is basically means "public domain");
* not table-generated: Zymosis does opcode decoding almost like real CPU could, by inspecting various opcode bits, and using common code for common opcode groups;
* due to the previous bullet, Zymosis is small (only about 50 KB of C source code) and self-contained;
* uses callbacks for port and memory i/o, so you can implement anything you need;
* supports contention tables, so you can emulate contention effects (ZXEmuT can run multicolor software without any problems, for example);
* passes all FUSE CPU tests;
* comes with small supplemental library to ease code analysis (determine if opcode does any memory/port IO, is conditional jump, and so on).


ZXEmuT is ZX Spectrum emulator based on Zymosis. i don't think that it is that interesting by itself (it was written mostly as a testbed for CPU emulator), it is not very user-friendly (and GNU/Linux only), but it is quite capable:
* can emulate 48K/128K Spectrums (with memory contention);
* emulates Pentagon (and partially Pentagon border effects);
* supports Beta-Disk emulation;
* has built-in debugger.
yes, nothing really special here, but hey, it works!


i consider both projects as "mostly finished" (i.e. no major new features are planned). still, you may be interested in (fairly) small, but feature-complete Z80 CPU emulator for your projects.


p.s.: oops. just noticed that i forgot to link source code repository. the link is in my signature, of course, but just in case somebody turned signatures off... ;-)
5 x

User avatar
utz
Dizzy
Posts: 88
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Zymosis and ZXEmuT

Post by utz »

Ah yes, I studied Zymosis quite extensively when I wrote my own z80 emulation library a few years ago. It's an excellent piece of code. Glad to see you're still working on it.
0 x

User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Re: Zymosis and ZXEmuT

Post by ketmar »

thank you! i'm basically just playing games with ZXEmuT these days (and as you can see i never really put my hands on fixing SCF/CCF emulation), so not much work is going into the code. but Zymosis is "feature complete" anyway, and ZXEmuT is pending Yet Another Rewrite (as i am not happy with the architecture).

i also ported Zymosis to D, but managed to break MEMPTR (and prolly something else) along the way. ;-) despite that, DZXEmuT (D rewrite) is working quite good.

p.s.: oh, i forgot about liburasm! as i can't append it to the starting topic, i'll do it here.

in the repository you can also find liburasm, table-driven assembler/disassembler library. it is "UR" becase it was inspired by the code from Unreal Spectrum, but i ended up creating the table (and all the code) from scratch. you can use it to easily add disasm dump and asm input to your Z80 debuggers.

also, there is slightly newer version of the library in my standalone assembler project UrAsm. i used that assembler to (cross-)write some Speccy software. it doesn't have macro support, but does have support for forward/backward labels (a-la fasm), and local labels (".name:"). it also has simple "module" system: modules exports all their non-local labels prefixed with module name. it also can generate relocatable code (along with fixup table). of course, it is absolutely undocumented, so i doubt that anybody will find it useful, but who knows? ;-)
0 x

User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Re: Zymosis and ZXEmuT

Post by ketmar »

so, i fixed SCF/CCF bug (it was actually a bug in interrupt acknowledge code) -- now Zymosis pass all z80test tests!

i also removed C UBs (i hope), so the code should be standard-compliant. and replaced conditional checks in branch/call opcodes with branch-less computations.

thank you all for this forum, without it i would prolly never return to Speccy coding again. ;-)
3 x

User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Re: Zymosis and ZXEmuT

Post by ketmar »

and just for fun, i added ZXNext Z80N support to liburasm (and to UrAsm assembler).
0 x

User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Re: Zymosis and ZXEmuT

Post by ketmar »

added disassembler library to Zymosis. it is based on the same instruction decoding logic as Zymosis itself, so it is only 20 kb of source code, and quite fast. now you can skip importing heavyweight liburasm if you only need to show some disassembly in your debugger.

it lives in separate source file, so if you don't need it, you can simply copy "zymosis.h" and "zymosis.c" to your project, ignoring other libzymosis sources.
0 x

User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Re: Zymosis and ZXEmuT

Post by ketmar »

oh, it's fun to code for Speccy again! while experimenting with various game engine ideas, i fixed several bugs in UrAsm assembler, added label file output from UrAsm and loading labels to ZXEmuT (yeah 8-years-back me did his coding without that), added some colors to ZXEmuT debug window, added tstate counter, upgraded WD1739 emulator to the actual version from SAM style, fixed bugs in SZX loader, and so on.
1 x

User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Re: Zymosis and ZXEmuT

Post by ketmar »

added simple ZXEmuT console command reference. ZXEmuT is fairly advanced emulator, but it is hard to know, because the only way to control it is built-in command console! ;-)
0 x

User avatar
utz
Dizzy
Posts: 88
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Zymosis and ZXEmuT

Post by utz »

Is it possible to control ZXEmuT through stdin? If so, I could actually use it as an alternative to MAME in my Bintracker music editor.
0 x

User avatar
ketmar
Manic Miner
Posts: 207
Joined: Tue Jun 16, 2020 5:25 pm

Re: Zymosis and ZXEmuT

Post by ketmar »

utz wrote:
Sat Jul 04, 2020 9:42 am
Is it possible to control ZXEmuT through stdin? If so, I could actually use it as an alternative to MAME in my Bintracker music editor.
no. but it has full-featured Jim Tcl interpreter, and it can load external scripts with "load" console command. you can also execute any console command from CLI using quake syntax, i.e.:

zxemut +quit

will immediately quit. ;-)

there is also undocumented feature to control ZXEmuT from Z80 code:

Code: Select all

  defb #ED,#FE  ; ZXEmuT trap code
  jr .skipdata
  defb controldata
.skipdata:
for other emulators this will do nothing, but ZXEmuT will detect this, and will execute some commands. for now, there are only very simple commands to activate debugger and pause/unpause the emulator, but i can add other commands if you'll need them.

p.s.: if you need some special feature, just ask here. i'm ok with adding features people may need (if it is not too hard ;-).

p.p.s.: ah, i see. you want ZXEmuT to run in background, and to control it from your app? this is doable too, but i prefer to use some named pipe or unix socket for that. unix socket will be the best choice for me. if it's ok, i can add unix socket interface, so you'll be able to send console commands with it.

p.p.p.s.: ;-) ZXEmuT is using BlipBuffer to render sound (the same code that is used in FUSE), so i believe that speaker sound quality is quite good.
1 x

Post Reply