unsafe void DrawM4BG(MobileBmpView mbv, bool secondFrame) { mbv.ChangeAllSizes(240, 160); Bitmap bmp = mbv.BmpView.Bmp; var lockData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); int *pixels = (int *)lockData.Scan0; int pitch = lockData.Stride / sizeof(int); byte * frame = (byte *)_vram + (secondFrame ? 40960 : 0); ushort *palette = (ushort *)_palRam; for (int y = 0; y < 160; y++) { for (int x = 0; x < 240; x++) { *pixels++ = _colorConversion[palette[*frame++]]; } pixels -= 240; pixels += pitch; } bmp.UnlockBits(lockData); mbv.BmpView.Refresh(); }
unsafe void DrawAffineBG(int n, MobileBmpView mbv) { ushort bgcnt = ((ushort *)_mmio)[4 + n]; int ssize = bgcnt >> 14; switch (ssize) { case 0: mbv.ChangeAllSizes(128, 128); break; case 1: mbv.ChangeAllSizes(256, 256); break; case 2: mbv.ChangeAllSizes(512, 512); break; case 3: mbv.ChangeAllSizes(1024, 1024); break; } Bitmap bmp = mbv.BmpView.Bmp; var lockData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); int *pixels = (int *)lockData.Scan0; int pitch = lockData.Stride / sizeof(int); byte *tiles = (byte *)_vram + ((bgcnt & 0xc) << 12); byte *nametable = (byte *)_vram + ((bgcnt & 0x1f00) << 3); for (int ty = 0; ty < bmp.Height / 8; ty++) { for (int tx = 0; tx < bmp.Width / 8; tx++) { DrawTile256(pixels, pitch, tiles + *nametable++ *64, (ushort *)_palRam, false, false); pixels += 8; } pixels -= bmp.Width; pixels += 8 * pitch; } bmp.UnlockBits(lockData); mbv.BmpView.Refresh(); }
unsafe void DrawM5BG(MobileBmpView mbv, bool secondframe) { mbv.ChangeAllSizes(160, 128); 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); ushort *frame = (ushort *)vram + (secondframe ? 20480 : 0); for (int y = 0; y < 128; y++) { for (int x = 0; x < 160; x++) { *pixels++ = ColorConversion[*frame++]; } pixels -= 160; pixels += pitch; } bmp.UnlockBits(lockdata); mbv.BmpView.Refresh(); }
unsafe void DrawTextBG(int n, MobileBmpView mbv) { ushort bgcnt = ((ushort *)_mmio)[4 + n]; int ssize = bgcnt >> 14; switch (ssize) { case 0: mbv.ChangeAllSizes(256, 256); break; case 1: mbv.ChangeAllSizes(512, 256); break; case 2: mbv.ChangeAllSizes(256, 512); break; case 3: mbv.ChangeAllSizes(512, 512); break; } Bitmap bmp = mbv.BmpView.Bmp; var lockData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); int *pixels = (int *)lockData.Scan0; int pitch = lockData.Stride / sizeof(int); byte *tiles = (byte *)_vram + ((bgcnt & 0xc) << 12); ushort *nametable = (ushort *)_vram + ((bgcnt & 0x1f00) << 2); bool eighthBit = bgcnt.Bit(7); switch (ssize) { case 0: DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); break; case 1: DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); pixels += 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); break; case 2: DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); pixels += pitch * 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); break; case 3: DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); pixels += 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); pixels -= 256; pixels += pitch * 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); pixels += 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eighthBit); break; } bmp.UnlockBits(lockData); mbv.BmpView.Refresh(); }
unsafe void DrawM5BG(MobileBmpView mbv, bool secondframe) { mbv.ChangeAllSizes(160, 128); 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); ushort* frame = (ushort*)vram + (secondframe ? 20480 : 0); for (int y = 0; y < 128; y++) { for (int x = 0; x < 160; x++) *pixels++ = ColorConversion[*frame++]; pixels -= 160; pixels += pitch; } bmp.UnlockBits(lockdata); mbv.BmpView.Refresh(); }
unsafe void DrawAffineBG(int n, MobileBmpView mbv) { ushort bgcnt = ((ushort*)mmio)[4 + n]; int ssize = bgcnt >> 14; switch (ssize) { case 0: mbv.ChangeAllSizes(128, 128); break; case 1: mbv.ChangeAllSizes(256, 256); break; case 2: mbv.ChangeAllSizes(512, 512); break; case 3: mbv.ChangeAllSizes(1024, 1024); break; } 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 + ((bgcnt & 0xc) << 12); byte* nametable = (byte*)vram + ((bgcnt & 0x1f00) << 3); for (int ty = 0; ty < bmp.Height / 8; ty++) { for (int tx = 0; tx < bmp.Width / 8; tx++) { DrawTile256(pixels, pitch, tiles + *nametable++ * 64, (ushort*)palram, false, false); pixels += 8; } pixels -= bmp.Width; pixels += 8 * pitch; } bmp.UnlockBits(lockdata); mbv.BmpView.Refresh(); }
unsafe void DrawTextBG(int n, MobileBmpView mbv) { ushort bgcnt = ((ushort*)mmio)[4 + n]; int ssize = bgcnt >> 14; switch (ssize) { case 0: mbv.ChangeAllSizes(256, 256); break; case 1: mbv.ChangeAllSizes(512, 256); break; case 2: mbv.ChangeAllSizes(256, 512); break; case 3: mbv.ChangeAllSizes(512, 512); break; } 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 + ((bgcnt & 0xc) << 12); ushort* nametable = (ushort*)vram + ((bgcnt & 0x1f00) << 2); bool eightbit = bgcnt.Bit(7); switch (ssize) { case 0: DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); break; case 1: DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); pixels += 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); break; case 2: DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); pixels += pitch * 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); break; case 3: DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); pixels += 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); pixels -= 256; pixels += pitch * 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); pixels += 256; nametable += 1024; DrawTextNameTable(pixels, pitch, nametable, tiles, eightbit); break; } bmp.UnlockBits(lockdata); mbv.BmpView.Refresh(); }