[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing emulator...



Dosius wrote:
> The Z80's memory accesses are directly to the corresponding 65C02
> addresses, according to the manual quote you provided.  A variable,
> cpuinuse, is set to emu6502 or emuZ80, and the opcode fetch-and-run is
> executed for the proper CPU, although this needs work.  Also, CPU
> switching doesn't seem to work right because I still get "CAN'T FIND
> Z80 SOFTCARD" (or, in the hack, "CAN'T FIND STUPID CARD.")

I took a look at your code (0.70) as I posted a bit earlier, and I think 
I've got your CPU switching bug figured out:

DAPPLE.C: line 697
if (Addr>=49360 && Addr<=49375)
 {
  if (Addr==49360) cpuinuse=(!cpuinuse);
  return 96; /* CP/M card */
 }

DAPPLE.C: line 711
 if (Addr>=50432 && Addr<=50687) return Z80ROM[Addr-50432];

Okay, the M$ Z80 SoftCard doesn't have any ROM at Cx00 (mine returns zeros), 
but that shouldn't be an issue here.  What your problem is: if the code at 
line 697 is your switching code, it's at the wrong address.  The switching 
is performed by a _write_ to the Cx00 space.  Thus, the code at DAPPLE.C 
line 711 can just return zeros (or the contents of the rom file as it is 
now), and the the code at line 697 needs to be removed.

The following (or equivalent, correct code) needs to go somewhere in Wr6502:
/* Toggle Z80/6502 microprocessor *
 * M$ SoftCard responds to write in Cx00 space */
if (Addr>=50432 && Addr<=50687)  /* C500-C5FF */
 {
  cpuinuse=(!cpuinuse);
 }

That ought to clear it up.

If I read it properly, as soon as the next instruction is fetched, the Z80 
will be active.

Let me know how it works out.

Mike