break stuff!
This commit is contained in:
parent
96dcb253aa
commit
d45faaa99c
|
@ -3221,7 +3221,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
case "GEN":
|
||||
{
|
||||
//nextEmulator = new Genesis(nextComm, game, rom.RomData);
|
||||
nextEmulator = new BizHawk.Emulation.Cores.Consoles.Sega.gpgx.GPGX(nextComm, rom.RomData, "GEN", true, Emulation.Cores.Consoles.Sega.gpgx.GPGX.ControlType.Normal);
|
||||
nextEmulator = new BizHawk.Emulation.Cores.Consoles.Sega.gpgx.GPGX(nextComm, rom.RomData, null, "GEN", true, Emulation.Cores.Consoles.Sega.gpgx.GPGX.ControlType.Normal);
|
||||
break;
|
||||
}
|
||||
case "TI83":
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
{
|
||||
static GPGX AttachedCore = null;
|
||||
|
||||
DiscSystem.Disc CD;
|
||||
byte[] romfile;
|
||||
|
||||
bool disposed = false;
|
||||
|
@ -35,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
Wayplay
|
||||
};
|
||||
|
||||
public GPGX(CoreComm NextComm, byte[] romfile, string romextension, bool sixbutton, ControlType controls)
|
||||
public GPGX(CoreComm NextComm, byte[] romfile, DiscSystem.Disc CD, string romextension, bool sixbutton, ControlType controls)
|
||||
{
|
||||
// three or six button?
|
||||
// http://www.sega-16.com/forum/showthread.php?4398-Forgotten-Worlds-giving-you-GAME-OVER-immediately-Fix-inside&highlight=forgotten%20worlds
|
||||
|
@ -130,7 +131,23 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
}
|
||||
|
||||
if (filename == "PRIMARY_ROM")
|
||||
{
|
||||
if (romfile == null)
|
||||
{
|
||||
Console.WriteLine("Couldn't satisfy firmware request PRIMARY_ROM because none was provided.");
|
||||
return 0;
|
||||
}
|
||||
srcdata = romfile;
|
||||
}
|
||||
else if (filename == "PRIMARY_CD")
|
||||
{
|
||||
if (CD == null)
|
||||
{
|
||||
Console.WriteLine("Couldn't satisfy firmware request PRIMARY_CD because none was provided.");
|
||||
return 0;
|
||||
}
|
||||
srcdata = GetCDData();
|
||||
}
|
||||
else
|
||||
{
|
||||
// use fromtend firmware interface
|
||||
|
@ -176,12 +193,62 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Couldn't satisfy firmware request {0} for unknown reasons", filename);
|
||||
return 0;
|
||||
throw new Exception();
|
||||
//Console.WriteLine("Couldn't satisfy firmware request {0} for unknown reasons", filename);
|
||||
//return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CDRead(int lba, IntPtr dest)
|
||||
{
|
||||
byte[] data = new byte[2048];
|
||||
CD.ReadLBA_2048(lba, data, 0);
|
||||
Marshal.Copy(data, 0, dest, 2048);
|
||||
}
|
||||
|
||||
LibGPGX.cd_read_cb cd_callback_handle;
|
||||
|
||||
unsafe byte[] GetCDData()
|
||||
{
|
||||
LibGPGX.CDData ret = new LibGPGX.CDData();
|
||||
int size = Marshal.SizeOf(ret);
|
||||
|
||||
ret.readcallback = cd_callback_handle = new LibGPGX.cd_read_cb(CDRead);
|
||||
|
||||
var ses = CD.TOC.Sessions[0];
|
||||
int ntrack = ses.Tracks.Count;
|
||||
|
||||
// bet you a dollar this is all wrong
|
||||
for (int i = 0; i < LibGPGX.CD_MAX_TRACKS; i++)
|
||||
{
|
||||
if (i < ntrack)
|
||||
{
|
||||
ret.tracks[i].start = ses.Tracks[i].Indexes[1].aba - 150;
|
||||
ret.tracks[i].end = ses.Tracks[i].length_aba + ret.tracks[i].start;
|
||||
if (i == ntrack - 1)
|
||||
{
|
||||
ret.end = ret.tracks[i].end;
|
||||
ret.last = ntrack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.tracks[i].start = 0;
|
||||
ret.tracks[i].end = 0;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] retdata = new byte[size];
|
||||
|
||||
fixed (byte* p = &retdata[0])
|
||||
{
|
||||
Marshal.StructureToPtr(ret, (IntPtr)p, false);
|
||||
}
|
||||
return retdata;
|
||||
}
|
||||
|
||||
|
||||
#region controller
|
||||
|
||||
GPGXControlConverter ControlConverter;
|
||||
|
|
|
@ -192,6 +192,27 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
}
|
||||
}
|
||||
|
||||
public const int CD_MAX_TRACKS = 100;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void cd_read_cb(int lba, IntPtr dest);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct CDTrack
|
||||
{
|
||||
public int start;
|
||||
public int end;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class CDData
|
||||
{
|
||||
public int end;
|
||||
public int last;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = CD_MAX_TRACKS)]
|
||||
public readonly CDTrack[] tracks = new CDTrack[CD_MAX_TRACKS];
|
||||
public cd_read_cb readcallback;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -64,11 +64,6 @@
|
|||
/* CD track */
|
||||
typedef struct
|
||||
{
|
||||
FILE *fd;
|
||||
#ifdef USE_LIBTREMOR
|
||||
OggVorbis_File vf;
|
||||
#endif
|
||||
int offset;
|
||||
int start;
|
||||
int end;
|
||||
} track_t;
|
||||
|
@ -92,7 +87,6 @@ typedef struct
|
|||
int scanOffset;
|
||||
int volume;
|
||||
uint8 status;
|
||||
uint16 sectorSize;
|
||||
toc_t toc;
|
||||
int16 audio[2];
|
||||
} cdd_t;
|
||||
|
@ -102,7 +96,7 @@ extern void cdd_init(blip_t* left, blip_t* right);
|
|||
extern void cdd_reset(void);
|
||||
extern int cdd_context_save(uint8 *state);
|
||||
extern int cdd_context_load(uint8 *state);
|
||||
extern int cdd_load(char *filename, char *header);
|
||||
extern int cdd_load(void);
|
||||
extern void cdd_unload(void);
|
||||
extern void cdd_read_data(uint8 *dst);
|
||||
extern void cdd_read_audio(unsigned int samples);
|
||||
|
|
|
@ -541,7 +541,7 @@ int load_rom(char *filename)
|
|||
}
|
||||
|
||||
/* auto-detect CD image files */
|
||||
size = 0; //cdd_load(filename, (char *)(cart.rom));
|
||||
size = cdd_load();
|
||||
if (size < 0)
|
||||
{
|
||||
/* error opening file */
|
||||
|
@ -730,7 +730,7 @@ int load_rom(char *filename)
|
|||
|
||||
/* automatically load associated .iso image */
|
||||
strncpy(&filename[strlen(filename) - 4], ".iso", 4);
|
||||
cdd_load(filename, (char *)cdc.ram);
|
||||
cdd_load(); // should this be checked for failure?
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue