Reesy posted on Sep 14 2005 at 07:25 PM said:
Well you may well be able to help.
The problem I have is that DrZ80 uses a direct pointer to memory when emulating the Z80 PC and SP registers. This basically means that instead of holding an offset into memory they actually hold the pointer to an address in the hosts system memory where the PC or SP would be.
If you take the Z80 PC for example. Most emulators would store the 16bit value ( 0x0000 to 0xFFFF ) when they want to read the next opcode at the current pc they pass the PC to their memory handlers and then the memory handlers return the byte at that address.
Now in DrZ80 I store the actual address of the next opcode. Say the Z80 PC was 0x100 and I had the emulated Z80 memory located address 0xC0000000 on the host system, the address in DrZ80's PC register would actually hold 0xC0000100.
DrZ80 PC = PC_BASE_ADDRESS + Z80PC
So instead of having to go through a memory handler I can just read the next opcode directly from address 0xC0000100. This saves a load of cpu time.
So my problem in Mame is working out what the PC_BASE_ADDRESS is, if you can think of way of doing this then I'm all ears
Reesy
Oooo...,the problem like for my integrated Cyclone problem!
follow code:
static unsigned int MyCheckPc(unsigned int pc)
{
pc-=m68000_cpu.membase; /* Get the real program counter */
if (pc<0xff0000/*pc<RomLength*/) m68000_cpu.membase=(int)m68000_rom; /* Jump to Rom */
if (pc>=0xff0000) m68000_cpu.membase=(int)m68000_ram-0xff0000; /* Jump to Ram */
return m68000_cpu.membase+pc; /* New program counter */
}
static void m68000_reset(void* param)
{
memset(&m68000_cpu, 0,sizeof(m68000_cpu));
m68000_cpu.checkpc =MyCheckPc;
m68000_cpu.read8 =MyRead8;
m68000_cpu.read16 =MyRead16;
m68000_cpu.read32 =MyRead32;
m68000_cpu.write8 =MyWrite8;
m68000_cpu.write16 =MyWrite16;
m68000_cpu.write32 =MyWrite32;
m68000_cpu.fetch8 =MyRead8;
m68000_cpu.fetch16 =MyRead16;
m68000_cpu.fetch32 =MyRead32;
m68000_cpu.srh=0x27; /* Set supervisor mode */
m68000_cpu.a[7]=m68000_cpu.read32(0); /* Get Stack Pointer */
m68000_cpu.membase=0;
{
// m68000_ram=OP_RAM;// Where is Mame0.96's RAM?
// m68000_rom=OP_ROM;// Where is Mame0.96's ROM?
}
m68000_cpu.pc=m68000_cpu.checkpc(m68000_cpu.read32(4)); /* Get Program Counter */
pending_interrupts = 0;
}
I must find a valid m68000_cpu.membase,like your PC_BASE_ADDRESS
I agree Franxis said 'We should add a function in memory.c to get pointers from diferent memory banks'... I guess it's a solve way...
Let's solve it together
BTW:What is you integrated M.A.M.E ver?My code base M.A.M.E 0.96.