Example #1
0
        unsafe void DrawSprites(MobileBmpView mbv)
        {
            mbv.BmpView.ChangeBitmapSize(1024, 512);
            Bitmap bmp      = mbv.BmpView.bmp;
            var    lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            // Clear()
            Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride));

            int *pixels = (int *)lockdata.Scan0;
            int  pitch  = lockdata.Stride / sizeof(int);

            ushort *sprites = (ushort *)oam;
            byte *  tiles   = (byte *)vram + 65536;

            ushort dispcnt = ((ushort *)mmio)[0];
            bool   twodee  = !dispcnt.Bit(6);

            for (int sy = 0; sy < 8; sy++)
            {
                for (int sx = 0; sx < 16; sx++)
                {
                    DrawSprite(pixels, pitch, sprites, tiles, twodee);
                    pixels  += 64;
                    sprites += 4;
                }
                pixels -= 1024;
                pixels += pitch * 64;
            }

            bmp.UnlockBits(lockdata);
            mbv.BmpView.Refresh();
        }
Example #2
0
        unsafe void DrawSpriteTiles(MobileBmpView mbv, bool tophalfonly, bool eightbit)
        {
            int tw = eightbit ? 16 : 32;
            int th = tophalfonly ? 16 : 32;

            mbv.BmpView.ChangeBitmapSize(tw * 8, 256);
            Bitmap bmp      = mbv.BmpView.bmp;
            var    lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            int *pixels = (int *)lockdata.Scan0;
            int  pitch  = lockdata.Stride / sizeof(int);

            byte *tiles = (byte *)vram + 65536;
            // TODO: palette changing (in 4 bit mode anyway)
            ushort *palette = (ushort *)palram + 256;

            if (tophalfonly)
            {
                Win32.MemSet(lockdata.Scan0, 0xff, (uint)(128 * lockdata.Stride));
                pixels += 128 * pitch;
                tiles  += 16384;
            }
            DrawTileRange(pixels, pitch, tiles, palette, tw, th, eightbit);
            bmp.UnlockBits(lockdata);
            mbv.BmpView.Refresh();
        }
Example #3
0
        public void Clear()
        {
            var lockdata = BMP.LockBits(new Rectangle(0, 0, BMP.Width, BMP.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride));
            BMP.UnlockBits(lockdata);
            Refresh();
        }