public void Dispose() { if (!disposed) { // if (SaveRamModified) // DisposedSaveRam = CloneSaveRam(); // KillMemCallbacks(); if (CD != null) { CD.Dispose(); } if (elf != null) { elf.Dispose(); elf = null; gpgx = null; } disposed = true; } }
public GPGXDynamic(CoreComm comm, byte[] rom, DiscSystem.Disc CD, object Settings, object SyncSettings) { ServiceProvider = new BasicServiceProvider(this); (ServiceProvider as BasicServiceProvider).Register <ITraceable>(_tracer); // this can influence some things internally string romextension = "GEN"; // 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 //hack, don't use //romfile = File.ReadAllBytes(@"D:\encodes\bizhawksrc\output\SANIC CD\PierSolar (E).bin"); if (rom != null && rom.Length > 16 * 1024 * 1024) { throw new InvalidOperationException("ROM too big! Did you try to load a CD as a ROM?"); } elf = new ElfRunner(Path.Combine(comm.CoreFileProvider.DllPath(), "gpgx.elf")); try { gpgx = new LibGPGXDynamic(); elf.PopulateInterface(gpgx); _SyncSettings = (GPGXSyncSettings)SyncSettings ?? new GPGXSyncSettings(); CoreComm = comm; LoadCallback = new LibGPGXDynamic.load_archive_cb(load_archive); this.romfile = rom; this.CD = CD; LibGPGXDynamic.INPUT_SYSTEM system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_NONE; LibGPGXDynamic.INPUT_SYSTEM system_b = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_NONE; switch (this._SyncSettings.ControlType) { case ControlType.None: default: break; case ControlType.Activator: system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_ACTIVATOR; system_b = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_ACTIVATOR; break; case ControlType.Normal: system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_MD_GAMEPAD; system_b = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_MD_GAMEPAD; break; case ControlType.OnePlayer: system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_MD_GAMEPAD; break; case ControlType.Xea1p: system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_XE_A1P; break; case ControlType.Teamplayer: system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_TEAMPLAYER; system_b = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_TEAMPLAYER; break; case ControlType.Wayplay: system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_WAYPLAY; system_b = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_WAYPLAY; break; case ControlType.Mouse: system_a = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_MD_GAMEPAD; // seems like mouse in port 1 would be supported, but not both at the same time system_b = LibGPGXDynamic.INPUT_SYSTEM.SYSTEM_MOUSE; break; } if (!gpgx.gpgx_init(romextension, LoadCallback, this._SyncSettings.UseSixButton, system_a, system_b, this._SyncSettings.Region)) { throw new Exception("gpgx_init() failed"); } { int fpsnum = 60; int fpsden = 1; gpgx.gpgx_get_fps(ref fpsnum, ref fpsden); CoreComm.VsyncNum = fpsnum; CoreComm.VsyncDen = fpsden; DisplayType = CoreComm.VsyncRate > 55 ? DisplayType.NTSC : DisplayType.PAL; } // compute state size { byte[] tmp = new byte[gpgx.gpgx_state_max_size()]; int size = gpgx.gpgx_state_size(tmp, tmp.Length); if (size <= 0) { throw new Exception("Couldn't Determine GPGX internal state size!"); } savebuff = new byte[size]; savebuff2 = new byte[savebuff.Length + 13]; Console.WriteLine("GPGX Internal State Size: {0}", size); } SetControllerDefinition(); // pull the default video size from the core update_video_initial(); SetMemoryDomains(); InputCallback = new LibGPGXDynamic.input_cb(input_callback); gpgx.gpgx_set_input_callback(InputCallback); if (CD != null) { DriveLightEnabled = true; } PutSettings((GPGXSettings)Settings ?? new GPGXSettings()); InitMemCallbacks(); KillMemCallbacks(); } catch { Dispose(); throw; } }
public CName(string Name, LibGPGXDynamic.INPUT_KEYS Key) { this.Name = Name; this.Key = Key; }
public void Convert(IController source, LibGPGXDynamic.InputData target) { this.source = source; this.target = target; target.ClearAllBools(); foreach (var f in Converts) f(); this.source = null; this.target = null; }
public GPGXControlConverterDynamic(LibGPGXDynamic.InputData input) { Console.WriteLine("Genesis Controller report:"); foreach (var e in input.system) Console.WriteLine("S:{0}", e); foreach (var e in input.dev) Console.WriteLine("D:{0}", e); int player = 1; ControllerDef = new ControllerDefinition(); ControllerDef.BoolButtons.Add("Power"); ControllerDef.BoolButtons.Add("Reset"); for (int i = 0; i < LibGPGXDynamic.MAX_DEVICES; i++) { switch (input.dev[i]) { case LibGPGXDynamic.INPUT_DEVICE.DEVICE_PAD3B: AddToController(i, player, Genesis3); player++; break; case LibGPGXDynamic.INPUT_DEVICE.DEVICE_PAD6B: AddToController(i, player, Genesis6); player++; break; case LibGPGXDynamic.INPUT_DEVICE.DEVICE_MOUSE: AddToController(i, player, Mouse); DoMouseAnalog(i, player); player++; break; case LibGPGXDynamic.INPUT_DEVICE.DEVICE_NONE: break; case LibGPGXDynamic.INPUT_DEVICE.DEVICE_LIGHTGUN: // supports menacers and justifiers AddToController(i, player, Lightgun); DoLightgunAnalog(i, player); player++; break; case LibGPGXDynamic.INPUT_DEVICE.DEVICE_PAD2B: case LibGPGXDynamic.INPUT_DEVICE.DEVICE_PADDLE: case LibGPGXDynamic.INPUT_DEVICE.DEVICE_SPORTSPAD: case LibGPGXDynamic.INPUT_DEVICE.DEVICE_TEREBI: throw new Exception("Master System only device? Something went wrong."); case LibGPGXDynamic.INPUT_DEVICE.DEVICE_ACTIVATOR: AddToController(i, player, Activator); player++; break; case LibGPGXDynamic.INPUT_DEVICE.DEVICE_XE_A1P: AddToController(i, player, XEA1P); DoXEA1PAnalog(i, player); player++; break; case LibGPGXDynamic.INPUT_DEVICE.DEVICE_PICO: // PICO isn't finished on the unmanaged side either throw new Exception("Sega PICO not implemented yet!"); default: throw new Exception("Unknown Genesis control device! Something went wrong."); } } ControllerDef.Name = "GPGX Genesis Controller"; }