Exemple #1
0
 static public void LoadROM(string _romPath)
 {
     byte[] data = SharpEmulator.LoadROMData(_romPath);
     ROM.Current           = new ROM(data);
     ROM.Current.Path      = _romPath;
     SharpEmulator.Redraw += SharpEmulator_Redraw;
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #5
0
 static public Bitmap GetVideoMemory(int start)
 {
     byte[,] pixels = SharpEmulator.GetVideoMemory(start);
     return(MatrixToBitmap(pixels, 128, 128));
 }
Exemple #6
0
 static public int GetRomNumber()
 {
     return(SharpEmulator.GetRomNumber());
 }
Exemple #7
0
 static public int GetCycleCount()
 {
     return(SharpEmulator.GetCycleCount());
 }
Exemple #8
0
 static public bool GetIME()
 {
     return(SharpEmulator.GetIME());
 }
Exemple #9
0
 static public void StopEmulation()
 {
     SharpEmulator.StopEmulation();
 }
Exemple #10
0
 static public string GetMemoryValue(int address)
 {
     return("0x" + SharpEmulator.GetMemoryValue(address).ToString("X2"));
 }
Exemple #11
0
 static public void SendKeys(Keys?key, bool pressed)
 {
     SharpEmulator.SendKey(key, pressed);
 }
Exemple #12
0
 static public string GetRegister(Register register)
 {
     return(SharpEmulator.GetRegister((int)register).ToString("X4"));
 }
Exemple #13
0
 static public void SaveGame()
 {
     SharpEmulator.SaveGame();
 }
Exemple #14
0
 static public void UpdateCheats(List <Cheat> cheats)
 {
     SharpEmulator.UpdateCheats(cheats);
 }
Exemple #15
0
 static public void LoadMemory(string path)
 {
     SharpEmulator.LoadMemory(path);
 }
Exemple #16
0
 static public void SaveMemory(string path)
 {
     SharpEmulator.SaveMemory(path);
 }
Exemple #17
0
 static public void ExecuteStep()
 {
     SharpEmulator.ExecuteStep();
 }
Exemple #18
0
 static public Bitmap DrawFullWindow()
 {
     byte[,] pixels = SharpEmulator.DrawFullWindow();
     return(MatrixToBitmap(pixels, 256, 256));
 }