private void GetObj0Attributes(ushort atb0) { Y = (uint)(atb0 & 0XFF); if (Y >= 128) { Y -= 128; } else { Y += 128; } atb0 = (ushort)(atb0 >> 8); RotateOrScaling = ((atb0 & 1) == 0) ? false : true; atb0 = (ushort)(atb0 >> 1); if (RotateOrScaling) { // throw new System.Exception("Rotation or scaling not Implemented."); } else { atb0 = (ushort)(atb0 >> 1); } OBJMode = (OBJMode)(atb0 & 3); atb0 = (ushort)(atb0 >> 2); Mozaic = ((atb0 & 1) == 0) ? false : true; atb0 = (ushort)(atb0 >> 1); Bpp = (Bpp)(atb0 & 1); atb0 = (ushort)(atb0 >> 1); OBJShape = (OBJShape)(atb0 & 3); }
/// <summary> /// Use this to setup the screen, this will disable the console. /// </summary> /// <param name="aSize">The dezired screen resolution</param> /// <param name="aBpp">The dezired Bytes per pixel</param> public void SetMode(ScreenSize aSize, Bpp aBpp) { //Get screen size switch (aSize) { case ScreenSize.Size320X200: ScreenWidth = 320; ScreenHeight = 200; break; case ScreenSize.Size640X400: ScreenWidth = 640; ScreenHeight = 400; break; case ScreenSize.Size640X480: ScreenWidth = 640; ScreenHeight = 480; break; case ScreenSize.Size800X600: ScreenWidth = 800; ScreenHeight = 600; break; case ScreenSize.Size1024X768: ScreenWidth = 1024; ScreenHeight = 768; break; case ScreenSize.Size1280X1024: ScreenWidth = 1280; ScreenHeight = 1024; break; } //Get bpp switch (aBpp) { case Bpp.Bpp15: ScreenBpp = 15; break; case Bpp.Bpp16: ScreenBpp = 16; break; case Bpp.Bpp24: ScreenBpp = 24; break; case Bpp.Bpp32: ScreenBpp = 32; break; } //set the screen _vbe.vbe_set((ushort)ScreenWidth, (ushort)ScreenHeight, (ushort)ScreenBpp); }
private void ConvertaPaletaOam(byte[] paleta, Bpp bpp, int idPaleta, bool fundoTransparente) { CoresPaleta = new List <Color>(); using (BinaryReader br = new BinaryReader(new MemoryStream(paleta))) { int contador = 0; if (bpp == Bpp.bpp4) { int inicio = idPaleta * 32; br.BaseStream.Position = inicio; if (inicio >= br.BaseStream.Length) { br.BaseStream.Position = br.BaseStream.Length - 32; } while (contador < 32) { int bgr = br.ReadInt16(); int r = (bgr & 31) * 255 / 31; int g = (bgr >> 5 & 31) * 255 / 31; int b = (bgr >> 10 & 31) * 255 / 31; CoresPaleta.Add(Color.FromArgb(r, g, b)); contador += 2; } } else { while (br.BaseStream.Position < paleta.Length) { int bgr = br.ReadInt16(); int r = (bgr & 31) * 255 / 31; int g = (bgr >> 5 & 31) * 255 / 31; int b = (bgr >> 10 & 31) * 255 / 31; CoresPaleta.Add(Color.FromArgb(r, g, b)); } } } if (fundoTransparente) { CoresPaleta[0] = Color.FromArgb(0, 0, 0, 0); } }
/// <summary> /// Use this to setup the screen, this will disable the console. /// </summary> /// <param name="aSize">The dezired screen resolution</param> /// <param name="aBpp">The dezired Bytes per pixel</param> public void SetMode(ScreenSize aSize, Bpp aBpp) { //Get screen size switch (aSize) { case ScreenSize.Size320x200: ScreenWidth = 320; ScreenHeight = 200; break; case ScreenSize.Size640x400: ScreenWidth = 640; ScreenHeight = 400; break; case ScreenSize.Size640x480: ScreenWidth = 640; ScreenHeight = 480; break; case ScreenSize.Size800x600: ScreenWidth = 800; ScreenHeight = 600; break; case ScreenSize.Size1024x768: ScreenWidth = 1024; ScreenHeight = 768; break; case ScreenSize.Size1280x1024: ScreenWidth = 1280; ScreenHeight = 1024; break; } //Get bpp switch (aBpp) { case Bpp.Bpp15: ScreenBpp = 15; break; case Bpp.Bpp16: ScreenBpp = 16; break; case Bpp.Bpp24: ScreenBpp = 24; break; case Bpp.Bpp32: ScreenBpp = 32; break; } //set the screen _vbe.vbe_set((ushort)ScreenWidth, (ushort)ScreenHeight, (ushort)ScreenBpp); }
public byte[] LeiaImagemERetorneBytes(Bitmap parteImg, Bpp bpp, int idPaleta, bool fundoTransparente) { List <byte> imgEmBytes = new List <byte>(); ConvertaPaletaOam(Paleta, bpp, idPaleta, fundoTransparente); List <Bitmap> tiles = ObtenhaTilesDeImagem(parteImg); foreach (var tile in tiles) { int complemento = 1; if (bpp == Bpp.bpp4) { complemento += 1; } for (int y = 0; y < tile.Height; y++) { for (int x = 0; x < tile.Width; x += complemento) { if (bpp == Bpp.bpp4) { int valor1 = ObtenhaIndexCorMaisProxima(tile.GetPixel(x, y), CoresPaleta); int valor2 = ObtenhaIndexCorMaisProxima(tile.GetPixel(x + 1, y), CoresPaleta) << 4; valor2 = valor2 + valor1; imgEmBytes.Add((byte)valor2); } else { int valor = ObtenhaIndexCorMaisProxima(tile.GetPixel(x, y), CoresPaleta); imgEmBytes.Add((byte)valor); } } } tile.Dispose(); } return(imgEmBytes.ToArray()); }
public IImageQueryable BitDepth(Bpp bpp) { return(this.Search($"bitdepth:{(int)bpp}")); }