void InitalizeComponent() { Application.targetFrameRate = 60; //Create display texture = new Texture2D(width, height); Sprite sprite = Sprite.Create(texture, new Rect(0, 0, width, height), Vector2.zero, 1); sprite.name = "Screen"; GogbGraphic = GameObject.Find("GameBoyScreen"); GogbGraphic.GetComponent <SpriteRenderer>().sprite = sprite; Vector2 pivotPoints = new Vector2(0.0f, 0.0f); GogbGraphic.GetComponent <RectTransform>().pivot = pivotPoints; //Load Cartiridge gbCart = new GameBoyCartiridge(0); try { gbCart.LoadRom(pathToRom); } catch { Debug.Log("NO ROM LOADED"); } //Create memory gbMemory = new GameBoyMemory(gbCart); bool reset = false; try { gbMemory.LoadBios(pathToBios); } catch { reset = true; } //Create Interrupts gbInterrupts = new GameBoyInterrupts(gbMemory); //Create Timer gbTimer = new GameBoyTimer(gbMemory, gbInterrupts); gbMemory.AddTimer(gbTimer); //Create CPU gbCPU = new GameBoyCPU(gbMemory, gbInterrupts); if (reset && !GameBoyCartiridge.IsGameBoyColor) { gbCPU.ResetGBNoBios(); } else if (reset && GameBoyCartiridge.IsGameBoyColor) { gbCPU.ResetCGBNoBios(); } //Create GPU gbGraphic = new GameBoyGraphic(width, height, texture, gbInterrupts, gbMemory); //Create Audio gbAudio = new GameBoyAudio(); gbMemory.AddGraphics(gbGraphic); gbMemory.AddAudio(gbAudio); //Create Keyboard gbJoyPad = new GameBoyJoyPad(gbInterrupts, gbMemory); Debug.Log(GameBoyCartiridge.Title); Debug.Log(GameBoyCartiridge.IsGameBoyColor); Debug.Log(gbCart.CartiridgeType.ToString("X2")); }
private uint speed = 1; //1 == normal, 2 == double public GameBoyMemory(GameBoyCartiridge gbCart) { this.gbCart = gbCart; this.workRam = new WorkRam(); memory = new List <byte>(new byte[memorySize]); }