Musashi To Cyclone


nemesis112

Still Fresh
Does anybody have any experience moving from the Musashi M68k core to Cyclone? Just having some problems integrating it.


Cheers....
 
To be honest I think it's a fairly fundamental problem. I'm pretty sure i've hooked everything up and it *seems* to be starting at the right address, but I get a seg fault after it does a few CycloneRuns. Alas, i'm on windows and can't get GDB running.

I hate to be a pain but I think someone's gonna need to look at the code.
 
Well it depends what you are using it for. There are still bugs in Cyclone so it could be what ever M68K code you are trying to run on it is causing it to bomb out.

Are you sure you are setting membase correctly? If you don't then who knows where the cyclone will be reading opcodes from.

The cycle count in Cyclone is different from Musashi, are you dealing with this correctly?

Post the code somewhere, I'm sure we can get what ever you are working on going. It doesn't have to be everything. The Cyclone initialisation code, memory handlers etc.
 
Well it depends what you are using it for. There are still bugs in Cyclone so it could be what ever M68K code you are trying to run on it is causing it to bomb out.

Are you sure you are setting membase correctly? If you don't then who knows where the cyclone will be reading opcodes from.

The cycle count in Cyclone is different from Musashi, are you dealing with this correctly?

Post the code somewhere, I'm sure we can get what ever you are working on going. It doesn't have to be everything. The Cyclone initialisation code, memory handlers etc.

Yeah, i'm pretty sure it's something to do with the Cycle Count or the Membase. I've uploaded the code here: http://tonsomo.roguegunners.com/src.zip

I know for a fact that I haven't implemented the CheckPC callback correctly.

Cheers....
 
Last edited by a moderator:
Okay lets tackle the checkpc function first. I know nothing about the Jaguar hardware, so I'm just basing this on what I've quickly read.

You've current got this
Code:
switch((pc&0xF00000)>>20) {
	case 0x0:
		MyCyclone.membase=(int)memory.cpu;
		break;
	case 0x2:
		MyCyclone.membase=(int)(memory.cpu+bankaddress)-0x200000;
		break;
	case 0x1:
		if (pc<=0x10FFff) 
			MyCyclone.membase=(int)memory.ram-0x100000;
		break;
	case 0xC:
		if (pc<=0xc1FFff)
			MyCyclone.membase=(int)memory.bios-0xc00000;
		break;
	}
From the documents I've looked at the Jag memory map is as follows

Code:
$000000  +------------------------+ 
		 |						| 
		 |		  RAM		   | 
		 |						| $1FFFFF 
$200000  +------------------------+ 
		 |		 shadow		 | 
		 |   of $000000-$1FFFFF   |	with 2MB 
		 |		  RAM		   | $3FFFFF
$400000  +------------------------+ 
		 .						.
		 .		   ...		  .
		 .						.
		 .						. $7FFFFF
$800000  +------------------------+ 
		 |						|
		 |		  ROM		   |
		 |						| $DFFFFF
$E00000  +------------------------+
		 |	   BOOT-(EP)ROM	 | $E1FFFF
$E20000  +------------------------+
		 .						.
		 .		   ...		  .
		 .						. $EFFFFF
$F00000  +------------------------+
		 |		   TOM		  |
$F10000  |------------------------+
		 |		  JERRY		 |
		 +------------------------+ $F1FFFF

If the above memory map is correct then you code should look like

Code:
switch((pc&0xF00000)>>20) {
	// 0x000000 - 0x1FFFFF point should be in system ram
	case 0x0:
	case 0x1:
		MyCyclone.membase=(int)memory.ram;
		break;
	
	// 0x200000 - 0x3FFFFF - shadow ram, so point to system using offset
	case 0x2:
	case 0x3:
		MyCyclone.membase=(int)memory.ram-0x200000;
		break;	
	
	// because you've put bankaddress here I'm assuming
	// memory.cpu is the rom banks? 
	case 0x8:
	case 0x9:
	case 0xA:
	case 0xB:
	case 0xC:
	case 0xD:
		MyCyclone.membase=(int)(memory.cpu+bankaddress)-0x800000;
		break;

	// I'm assuming bios is the same as Boot rom, could be wrong
	case 0xE:
		MyCyclone.membase=(int)memory.bios-0xE00000;
		break;
	
	// anything else?  just point it at ram
	case default:
		MyCyclone.membase=(int)memory.ram-(pc&0xF00000);
		break;
	}

The above code is probably still wrong but hopefully it will help you on your way.

P.S I couldn't find where the memory object is defined, could you point me in the right direction?
 
Ah, i've managed to needlessly confuse you there, the code in the MyCheckPC function was ripped out of the Neo Geo emulator (it uses both cores, so I hoped to get info from it) trouble is the memory maps are so different that it just ended up confusing me more. I've taken what you posted and changed it to what VJ uses:

static unsigned int MyCheckPc(unsigned int pc) {
WriteLog("MyCheckPC %u\n",pc);
WriteLog("S) Offset: %u, PC: %u\n",MyCyclone.membase,pc);
pc-=MyCyclone.membase; // Get the real program counter

switch((pc&0xF00000)>>20) {
// 0x000000 - 0x1FFFFF point should be in system ram
case 0x0:
case 0x1:
MyCyclone.membase=(int)jaguar_mainRam;
break;

// 0x200000 - 0x3FFFFF - shadow ram, so point to system using offset
case 0x2:
case 0x3:
MyCyclone.membase=(int)jaguar_mainRam-0x200000;
break;

case 0x8:
case 0x9:
case 0xA:
case 0xB:
case 0xC:
case 0xD:
MyCyclone.membase=(int)jaguar_mainRom-0x800000;
break;
// I'm assuming bios is the same as Boot rom, could be wrong
case 0xE:
MyCyclone.membase=(int)jaguar_bootRom-0xE00000;
break;

// anything else? just point it at ram
default:
MyCyclone.membase=(int)jaguar_mainRam-(pc&0xF00000);
break;
}

WriteLog("E) Offset: %u, PC: %u\n",MyCyclone.membase,pc);

return MyCyclone.membase+pc; // New program counter
}

Which has made a difference, it now doesn't SegFault, so Cyclone must be happier :). Cheers for that Reesy. Now it doesn't seem to be advancing down the stack, it just stays at the initial address - which i'm assuming is the fault of my cycle code.
 
Back
Top