static public void LoadROM(string _romPath) { byte[] data = SharpEmulator.LoadROMData(_romPath); ROM.Current = new ROM(data); ROM.Current.Path = _romPath; SharpEmulator.Redraw += SharpEmulator_Redraw; }
static private Bitmap MatrixToBitmap(byte[,] matrix, int largeur, int hauteur) { byte palette = SharpEmulator.GetPalette(); Bitmap bitmap = new Bitmap(largeur, hauteur); uint[,] pixels = new uint[hauteur, largeur]; uint[] shades = new uint[] { PaletteToColor((byte)(palette & 0x03)), PaletteToColor((byte)((palette >> 2) & 0x03)), PaletteToColor((byte)((palette >> 4) & 0x03)), PaletteToColor((byte)((palette >> 6) & 0x03)) }; for (int i = 0; i < hauteur; i++) { for (int j = 0; j < largeur; j++) { pixels[i, j] = shades[matrix[j, i]]; } } IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(pixels, 0); bitmap = new Bitmap(largeur, hauteur, largeur * 4, PixelFormat.Format32bppArgb, pointer); return(bitmap); }
static public Bitmap DrawScreen() { byte[,] bg = SharpEmulator.DrawBackground(); byte[,] win = SharpEmulator.DrawWindow(); List <Sprite> sprites = SharpEmulator.GetSprites(); if ((SharpEmulator.GetRegister((int)Register.LCDC) & 0x20) > 0) { for (int i = 0; i < win.GetUpperBound(0); i++) { for (int j = 0; j < win.GetUpperBound(1); j++) { bg[160 - win.GetUpperBound(0) + i, 144 - win.GetUpperBound(1) + j] = win[i, j]; } } } for (int i = 0; i < sprites.Count; i++) { Sprite s = sprites[i]; if (!s.isNull) { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int rX = x + s.X; int rY = y + s.Y; if (rX >= 168 || rX < 8) { continue; } if (rY >= 160 || rY < 16) { continue; } int xFliped = s.XFlip ? 7 - x : x; int yFliped = s.YFlip ? 7 - y : y; if (s.Tile[xFliped, yFliped] != 0) { bg[rX - 8, rY - 16] = s.Tile[xFliped, yFliped]; } } } } } return(MatrixToBitmap(bg, 160, 144)); }
public List <OpCode> LoadOpcodes() { List <OpCode> items = new List <OpCode>(); _data = SharpEmulator.LoadROMMemory(); _iOp = 0; _iBy = 0; for (int i = 0; _iOp < _data.Length; i++) { items.Add(new OpCode(_iOp, i)); if (_iOp < 0x104 || _iOp > 0x14F) { ApplyOffset(_data[_iBy]); } _iBy++; _iOp++; } return(items); }
static public Bitmap GetVideoMemory(int start) { byte[,] pixels = SharpEmulator.GetVideoMemory(start); return(MatrixToBitmap(pixels, 128, 128)); }
static public int GetRomNumber() { return(SharpEmulator.GetRomNumber()); }
static public int GetCycleCount() { return(SharpEmulator.GetCycleCount()); }
static public bool GetIME() { return(SharpEmulator.GetIME()); }
static public void StopEmulation() { SharpEmulator.StopEmulation(); }
static public string GetMemoryValue(int address) { return("0x" + SharpEmulator.GetMemoryValue(address).ToString("X2")); }
static public void SendKeys(Keys?key, bool pressed) { SharpEmulator.SendKey(key, pressed); }
static public string GetRegister(Register register) { return(SharpEmulator.GetRegister((int)register).ToString("X4")); }
static public void SaveGame() { SharpEmulator.SaveGame(); }
static public void UpdateCheats(List <Cheat> cheats) { SharpEmulator.UpdateCheats(cheats); }
static public void LoadMemory(string path) { SharpEmulator.LoadMemory(path); }
static public void SaveMemory(string path) { SharpEmulator.SaveMemory(path); }
static public void ExecuteStep() { SharpEmulator.ExecuteStep(); }
static public Bitmap DrawFullWindow() { byte[,] pixels = SharpEmulator.DrawFullWindow(); return(MatrixToBitmap(pixels, 256, 256)); }