public static bool GetGBSettingsScript(out GBSettings gbSettingsScript) { GameObject geoBrushObj; if (GetGeometryBrushToolObject(out geoBrushObj) == false) { gbSettingsScript = null; return(false); } gbSettingsScript = geoBrushObj.GetComponent <GBSettings>(); if (gbSettingsScript == null) { Debug.LogError("Error, 'GBSettings' game object must have the 'GBSettings' script component attached."); gbSettingsScript = null; return(false); } return(true); }
public GBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ GBSettings settings, GBSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); cpu = new LR35902 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, OnExecFetch = ExecFetch, SpeedFunc = SpeedFunc, GetIntRegs = GetIntRegs, SetIntRegs = SetIntRegs }; timer = new Timer(); audio = new Audio(); serialport = new SerialPort(); _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _controllerDeck = new GBHawkControllerDeck(_syncSettings.Port1); byte[] Bios = null; // Load up a BIOS and initialize the correct PPU if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.Auto) { if (game.System == "GB") { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } } else if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.GB) { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } if (Bios == null) { throw new MissingFirmwareException("Missing Gamboy Bios"); } _bios = Bios; // set up IR register to off state if (is_GBC) { IR_mask = 0; IR_reg = 0x3E; IR_receive = 2; IR_self = 2; IR_signal = 2; } // Here we modify the BIOS if GBA mode is set (credit to ExtraTricky) if (is_GBC && _syncSettings.GBACGB) { for (int i = 0; i < 13; i++) { _bios[i + 0xF3] = (byte)((GBA_override[i] + _bios[i + 0xF3]) & 0xFF); } IR_mask = 2; } // CPU needs to know about GBC status too cpu.is_GBC = is_GBC; Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); if (is_GBC && ((header[0x43] != 0x80) && (header[0x43] != 0xC0))) { ppu = new GBC_GB_PPU(); } Console.WriteLine("MD5: " + rom.HashMD5(0, rom.Length)); Console.WriteLine("SHA1: " + rom.HashSHA1(0, rom.Length)); _rom = rom; Setup_Mapper(); if (cart_RAM != null) { cart_RAM_vbls = new byte[cart_RAM.Length]; } timer.Core = this; audio.Core = this; ppu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(audio); ServiceProvider = ser; _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); ser.Register <IStatable>(new StateSerializer(SyncState)); SetupMemoryDomains(); cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); HardReset(); iptr0 = Marshal.AllocHGlobal(VRAM.Length + 1); iptr1 = Marshal.AllocHGlobal(OAM.Length + 1); iptr2 = Marshal.AllocHGlobal(ppu.color_palette.Length * 8 * 8 + 1); iptr3 = Marshal.AllocHGlobal(ppu.color_palette.Length * 8 * 8 + 1); _scanlineCallback = null; }
public PutSettingsDirtyBits PutSettings(GBSettings o) { _settings = o; return(PutSettingsDirtyBits.None); }
public bool PutSettings(GBSettings o) { _settings = o; return(false); }
public static void CreateAndPlaceObject(GameObject obj, Vector3 placementPos, Vector3 normal, Vector3 scale, Quaternion rotation, GBSettings gbSettingsScript, int randomID) { GameObject newObject; string assetPath = gbSettingsScript.activeGeometryPaths[randomID]; string[] str = assetPath.Split(new char[] { '/' }); if (str[str.Length - 1].EndsWith(".prefab") == true && Application.isEditor) { // inastantiate a prefab to keep link newObject = PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject))) as GameObject; } else { newObject = (GameObject)Instantiate(obj); } newObject.transform.localScale = scale; newObject.transform.position = placementPos; if (gbSettingsScript.alignToNormal) { // newObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, normal); // always use randomRotation newObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, normal) * Quaternion.Euler( Random.Range(-gbSettingsScript.randomRotation.x, gbSettingsScript.randomRotation.x), Random.Range(-gbSettingsScript.randomRotation.y, gbSettingsScript.randomRotation.y), Random.Range(-gbSettingsScript.randomRotation.z, gbSettingsScript.randomRotation.z) ); } else { newObject.transform.rotation = Quaternion.Euler( Random.Range(-gbSettingsScript.randomRotation.x, gbSettingsScript.randomRotation.x), Random.Range(-gbSettingsScript.randomRotation.y, gbSettingsScript.randomRotation.y), Random.Range(-gbSettingsScript.randomRotation.z, gbSettingsScript.randomRotation.z) ); } if (gbSettingsScript.parentObject != null) { newObject.transform.parent = gbSettingsScript.parentObject.transform; } }
public static void CreateAndPlaceObject( GameObject obj, Vector3 placementPos, Vector3 normal, Vector3 scale, Quaternion rotation, GBSettings gbSettingsScript, int randomID ){ GameObject newObject; string assetPath = gbSettingsScript.activeGeometryPaths[randomID]; string[] str = assetPath.Split( new char[]{'/'} ); if ( str[str.Length-1].EndsWith(".prefab") == true && Application.isEditor ) { // inastantiate a prefab to keep link newObject = PrefabUtility.InstantiatePrefab( AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) ) as GameObject; } else { newObject = (GameObject)Instantiate(obj); } newObject.transform.localScale = scale; newObject.transform.position = placementPos; if ( gbSettingsScript.alignToNormal ){ // newObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, normal); // always use randomRotation newObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, normal) * Quaternion.Euler( Random.Range(-gbSettingsScript.randomRotation.x, gbSettingsScript.randomRotation.x), Random.Range(-gbSettingsScript.randomRotation.y, gbSettingsScript.randomRotation.y), Random.Range(-gbSettingsScript.randomRotation.z, gbSettingsScript.randomRotation.z) ); } else { newObject.transform.rotation = Quaternion.Euler( Random.Range(-gbSettingsScript.randomRotation.x, gbSettingsScript.randomRotation.x), Random.Range(-gbSettingsScript.randomRotation.y, gbSettingsScript.randomRotation.y), Random.Range(-gbSettingsScript.randomRotation.z, gbSettingsScript.randomRotation.z) ); } if ( gbSettingsScript.parentObject != null ){ newObject.transform.parent = gbSettingsScript.parentObject.transform; } }
public static bool GetGBSettingsScript( out GBSettings gbSettingsScript ){ GameObject geoBrushObj; if ( GetGeometryBrushToolObject( out geoBrushObj ) == false ){ gbSettingsScript = null; return false; } gbSettingsScript = geoBrushObj.GetComponent<GBSettings>(); if ( gbSettingsScript == null ){ Debug.LogError ("Error, 'GBSettings' game object must have the 'GBSettings' script component attached."); gbSettingsScript = null; return false; } return true; }
public GBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ GBSettings settings, GBSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); cpu = new LR35902 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, OnExecFetch = ExecFetch, SpeedFunc = SpeedFunc, GetButtons = GetButtons, GetIntRegs = GetIntRegs, SetIntRegs = SetIntRegs }; timer = new Timer(); audio = new Audio(); serialport = new SerialPort(); _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); byte[] Bios = null; // Load up a BIOS and initialize the correct PPU if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.Auto) { if (game.System == "GB") { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } } else if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.GB) { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } if (Bios == null) { throw new MissingFirmwareException("Missing Gamboy Bios"); } _bios = Bios; // set up IR register to off state if (is_GBC) { IR_mask = 0; IR_reg = 0x3E; IR_receive = 2; IR_self = 2; IR_signal = 2; } // Here we modify the BIOS if GBA mode is set (credit to ExtraTricky) if (is_GBC && _syncSettings.GBACGB) { for (int i = 0; i < 13; i++) { _bios[i + 0xF3] = (byte)((GBA_override[i] + _bios[i + 0xF3]) & 0xFF); } IR_mask = 2; } // CPU needs to know about GBC status too cpu.is_GBC = is_GBC; Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); if (is_GBC && ((header[0x43] != 0x80) && (header[0x43] != 0xC0))) { ppu = new GBC_GB_PPU(); } Console.WriteLine("MD5: " + rom.HashMD5(0, rom.Length)); Console.WriteLine("SHA1: " + rom.HashSHA1(0, rom.Length)); _rom = rom; string mppr = Setup_Mapper(); if (cart_RAM != null) { cart_RAM_vbls = new byte[cart_RAM.Length]; } if (mppr == "MBC7") { _controllerDeck = new GBHawkControllerDeck(_syncSettings.Port1); } else { _controllerDeck = new GBHawkControllerDeck(GBHawkControllerDeck.DefaultControllerName); } timer.Core = this; audio.Core = this; ppu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(audio); ServiceProvider = ser; _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); ser.Register <IStatable>(new StateSerializer(SyncState)); SetupMemoryDomains(); cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); HardReset(); iptr0 = Marshal.AllocHGlobal(VRAM.Length + 1); iptr1 = Marshal.AllocHGlobal(OAM.Length + 1); iptr2 = Marshal.AllocHGlobal(ppu.color_palette.Length * 8 * 8 + 1); iptr3 = Marshal.AllocHGlobal(ppu.color_palette.Length * 8 * 8 + 1); _scanlineCallback = null; for (int i = 0; i < ZP_RAM.Length; i++) { ZP_RAM[i] = 0; } if (is_GBC) { if (_syncSettings.GBACGB) { // on GBA, initial RAM is mostly random, choosing 0 allows for stable clear and hotswap for games that encounter // uninitialized RAM for (int i = 0; i < RAM.Length; i++) { RAM[i] = 0; } } else { for (int i = 0; i < 0x800; i++) { if ((i & 0xF) < 8) { RAM[i] = 0xFF; RAM[i + 0x1000] = 0xFF; RAM[i + 0x2000] = 0xFF; RAM[i + 0x3000] = 0xFF; RAM[i + 0x4000] = 0xFF; RAM[i + 0x5000] = 0xFF; RAM[i + 0x6000] = 0xFF; RAM[i + 0x7000] = 0xFF; RAM[i + 0x800] = 0; RAM[i + 0x1800] = 0; RAM[i + 0x2800] = 0; RAM[i + 0x3800] = 0; RAM[i + 0x4800] = 0; RAM[i + 0x5800] = 0; RAM[i + 0x6800] = 0; RAM[i + 0x7800] = 0; } else { RAM[i] = 0; RAM[i + 0x1000] = 0; RAM[i + 0x2000] = 0; RAM[i + 0x3000] = 0; RAM[i + 0x4000] = 0; RAM[i + 0x5000] = 0; RAM[i + 0x6000] = 0; RAM[i + 0x7000] = 0; RAM[i + 0x800] = 0xFF; RAM[i + 0x1800] = 0xFF; RAM[i + 0x2800] = 0xFF; RAM[i + 0x3800] = 0xFF; RAM[i + 0x4800] = 0xFF; RAM[i + 0x5800] = 0xFF; RAM[i + 0x6800] = 0xFF; RAM[i + 0x7800] = 0xFF; } } // some bytes are like this is Gambatte, hardware anomoly? Is it consistent across versions? /* * for (int i = 0; i < 16; i++) * { * RAM[0xE02 + (16 * i)] = 0; * RAM[0xE0A + (16 * i)] = 0xFF; * * RAM[0x1E02 + (16 * i)] = 0; * RAM[0x1E0A + (16 * i)] = 0xFF; * * RAM[0x2E02 + (16 * i)] = 0; * RAM[0x2E0A + (16 * i)] = 0xFF; * * RAM[0x3E02 + (16 * i)] = 0; * RAM[0x3E0A + (16 * i)] = 0xFF; * * RAM[0x4E02 + (16 * i)] = 0; * RAM[0x4E0A + (16 * i)] = 0xFF; * * RAM[0x5E02 + (16 * i)] = 0; * RAM[0x5E0A + (16 * i)] = 0xFF; * * RAM[0x6E02 + (16 * i)] = 0; * RAM[0x6E0A + (16 * i)] = 0xFF; * * RAM[0x7E02 + (16 * i)] = 0; * RAM[0x7E0A + (16 * i)] = 0xFF; * } */ } } else { for (int j = 0; j < 2; j++) { for (int i = 0; i < 0x100; i++) { RAM[j * 0x1000 + i] = 0; RAM[j * 0x1000 + i + 0x100] = 0xFF; RAM[j * 0x1000 + i + 0x200] = 0; RAM[j * 0x1000 + i + 0x300] = 0xFF; RAM[j * 0x1000 + i + 0x400] = 0; RAM[j * 0x1000 + i + 0x500] = 0xFF; RAM[j * 0x1000 + i + 0x600] = 0; RAM[j * 0x1000 + i + 0x700] = 0xFF; RAM[j * 0x1000 + i + 0x800] = 0; RAM[j * 0x1000 + i + 0x900] = 0xFF; RAM[j * 0x1000 + i + 0xA00] = 0; RAM[j * 0x1000 + i + 0xB00] = 0xFF; RAM[j * 0x1000 + i + 0xC00] = 0; RAM[j * 0x1000 + i + 0xD00] = 0xFF; RAM[j * 0x1000 + i + 0xE00] = 0; RAM[j * 0x1000 + i + 0xF00] = 0xFF; } } } }
public PutSettingsDirtyBits PutSettings(GBSettings o) { _settings = o; _disassembler.UseRGBDSSyntax = _settings.UseRGBDSSyntax; return(PutSettingsDirtyBits.None); }