udo-munk / z80pack

A Zilog Z80 and Intel 8080 systems emulation
MIT License
162 stars 37 forks source link

wrk_ram and mem_base() #172

Closed sneakywumpus closed 2 years ago

sneakywumpus commented 2 years ago

I've seen comments in simfun.c about removing wrk_ram and mem_base() from David McNaughton. Should simctl.c in z80sim and mosteksim access memory with getmem()/putmem(), so that wrk_ram and mem_base() can be removed?

sneakywumpus commented 2 years ago

And make the functions from z80sim/simctl.c usable for other machine simulations?

udo-munk commented 2 years ago

The problem is the Mostek ICE emulation used in z80sim and the Mostek machine. It accesses memory directly with the wrk_ram pointer instead of using the appropriate macros. I never found the time to fix this and then remove wrk_ram and mem_base(), this still should be done sometime, yes. Also the Mostek ICE should go into it's own module, so that it can be attached to any machine, which would be possible then.

udo-munk commented 2 years ago

Excellent work. Should be possible now to refactor the ICE out of z80sim and mosteksim into a common module, so that it can be attached to all machines.

sneakywumpus commented 2 years ago

What is WANT_GUI used for? It looks like dead code. When defined it only causes the disassembler to not output anything and cpu_z80()/cpu_8080 to call check_gui_break() which is implemented nowhere. Can this be removed?

udo-munk commented 2 years ago

No, please leave in. The ICE implemented in z80sim is text terminal based and a bit crude. Someone wrote a GTK GUI that shows CPU registers, stack, disassembly on the fly while you were stepping though the code. The WANT_GUI define provides the hooks for such a GUI. Unfornunately the GUI code was abandoned a long time ago, don't know if I still have a copy somewhere. But the hooks could be used by anyone to implement a new GUI for the ICE. I believe the check_gui_break() also is used by alternative machines with a frontpanel that has only a power or reset switch.

sneakywumpus commented 2 years ago

OK. Then I need to add back the '\n' I removed from Disass_Str?

udo-munk commented 2 years ago

Found an example of the GUI hook usage:

https://www.sydneysmith.com/wordpress/1809/z80sim-and-front-panel/

udo-munk commented 2 years ago

Probably, it was there for some reason, hard to say without looking at code using this.

sneakywumpus commented 2 years ago

I want to move disas.c & simctl.c from z80sim/srcsim to z80core as simdis.c & simmon.c. OK? And what is the business with lnsrc & ulnsrc. The GNUmakefile already directly uses z80core. Can I change the other Makefile's to just use "-I ../../z80core" and reference the z80core files directly?

sneakywumpus commented 2 years ago

I mean copying the ICE command loop & commands and not the mon() function from simctl.c to simmon.c

sneakywumpus commented 2 years ago

Or shoulid I name it simice.c?

udo-munk commented 2 years ago

Name it simice.c, because that is what it is. Right the mon() function is the common entry point for all machines and needs to be there. Only the ICE loop and commands should go into simice.c and can then be called from mon() or caused by an CTRL-\ interrupt.

udo-munk commented 2 years ago

lnsrc and ulnsrc are relicts from make programs available on UNIX System V.3 decades ago. This probably can be removed nowadays, but I would prefer if there also are working traditional UNIX make files. That GNU make is ok, but not everyone is using that, for example on some BSD's, Solaris and who knows what else.