public void NewRLE() { //string Filename = DoFilename(txtFilename.Text);//"Pic" + ss.GetItem(txtFilename.Text, "\\", ss.CountItems(txtFilename.Text, "\\")).Replace(".", ""); // addheader(); // globals.PicNumber += 3 ; string lastnibble = ""; string Randombytes = ""; int nibblecount = 1; int FirstY = height; // intentionally backwards! int LastY = 0; LastY = height; // intentionally backwards! FirstY = 0; //} int CurrentMode = 0; //1=nibble . 2=byte 3=repeatingbytes int lineitem = 0; String RepeatingBytes = ""; for (int y = FirstY; y < LastY; y++) { for (int x = width - 16; x >= 0; x -= 16) { string thispair = GetPair(y, x); for (int by = 0; by < 2; by++) { string ThisByte = ""; switch (by) { case 0: ThisByte = thispair.Substring(0, 2); break; case 1: ThisByte = thispair.Substring(2, 2); break; } string nibble = ""; for (int n = 0; n < 2; n++) { switch (n) { case 1: //nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "11001100"); //nibble = nibble.Substring(0, 2) + nibble.Substring(4, 2); nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "11110000"); nibble = nibble.Substring(0, 4); break; case 0: //nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "00110011"); //nibble = nibble.Substring(2 + 0, 2) + nibble.Substring(2 + 4, 2); nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "00001111"); nibble = nibble.Substring(4, 4); break; } if (nibble == lastnibble) { nibblecount++; CurrentMode = 1; } else if (lastnibble == "") { lastnibble = nibble; nibblecount = 1; } else { if (nibblecount > 1) { if (Randombytes.Length > 1) { if (Randombytes.Length == 4) { donibblebatch(Randombytes, 1); donibblebatch(lastnibble, nibblecount); lastnibble = ""; } else { dobytebatchWithRepeater(Randombytes); donibblebatch(lastnibble, nibblecount); } Randombytes = ""; } else { { donibblebatch(lastnibble, nibblecount); } } } else { if (VbX.Len(Randombytes) == 4 && n == 1) // { //finish the last byte donibblebatch(Randombytes, nibblecount); nibblecount = 0; Randombytes = lastnibble; CurrentMode = 2; } else { Randombytes = Randombytes + lastnibble; CurrentMode = 2; nibblecount = 0; } } nibblecount = 1; lastnibble = nibble; } } } } } dobytebatchWithRepeater(Randombytes); donibblebatch(lastnibble, nibblecount); /* * FirstY = FirstY + VbX.CInt(txtYpos.Text); * * globals.imagedata.Append(Filename + ":" + nl); * globals.imagedata.Append("ld hl," + Filename + "_rledata-1" + nl); * globals.imagedata.Append("ld de," + Filename + "_rledataEnd-1" + nl); * globals.imagedata.Append("ld b," + FirstY.ToString() + nl); * int thiswidth = b.Width / 4; * globals.imagedata.Append("ld ixh," + thiswidth.ToString() + nl); * * * thiswidth = VbX.CInt(txtXpos.Text) + thiswidth - 1; * * globals.imagedata.Append("ld IXL," + thiswidth.ToString() + nl); * * globals.imagedata.Append("di" + nl); * globals.imagedata.Append("exx " + nl); * globals.imagedata.Append("push bc" + nl); * globals.imagedata.Append("exx" + nl); * globals.imagedata.Append("jp RLE_Draw" + nl); * globals.imagedata.Append(Filename + "_rledata:" + nl); * globals.imagedata.Append(Chunk.ToString() + nl); * globals.imagedata.Append(Filename + "_rledataEnd: defb 0" + nl); * textBox1.Text = globals.initdata + nl + globals.imagedata.ToString() + nl + globals.globaldata.ToString(); */ }
public void NewRLE() { string lastnibble = ""; string Randombytes = ""; int nibblecount = 1; int FirstY = height; // intentionally backwards! int LastY = 0; LastY = height; // intentionally backwards! FirstY = 0; //} int CurrentMode = 0; //1=nibble . 2=byte 3=repeatingbytes int lineitem = 0; String RepeatingBytes = ""; // MSX Version has two literal bytes at the start string thispair2 = GetPair(0, 0); addbytetodata(VbX.HexToInt(thispair2.Substring(0, 2))); addbytetodata(VbX.HexToInt(thispair2.Substring(2, 2))); // MSX Version has two literal bytes at the start for (int y = FirstY; y < LastY; y++) { int fx = 0; if (y == 0) { fx = 4; // MSX Version has two literal bytes at the start } for (int x = fx; x <= width - 4; x += 4) { string thispair = GetPair(y, x); for (int by = 0; by < 2; by++) { string ThisByte = ""; switch (by) { case 0: ThisByte = thispair.Substring(0, 2); break; case 1: ThisByte = thispair.Substring(2, 2); break; } string nibble = ""; for (int n = 0; n < 2; n++) { switch (n) { case 0: //nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "11001100"); //nibble = nibble.Substring(0, 2) + nibble.Substring(4, 2); nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "11110000"); nibble = nibble.Substring(0, 4); break; case 1: //nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "00110011"); //nibble = nibble.Substring(2 + 0, 2) + nibble.Substring(2 + 4, 2); nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "00001111"); nibble = nibble.Substring(4, 4); break; } if (nibble == lastnibble) { nibblecount++; CurrentMode = 1; } else if (lastnibble == "") { lastnibble = nibble; nibblecount = 1; } else { if (nibblecount > 1) { if (Randombytes.Length > 1) { if (Randombytes.Length == 4) { donibblebatch(Randombytes, 1); donibblebatch(lastnibble, nibblecount); lastnibble = ""; } else { dobytebatchWithRepeater(Randombytes); donibblebatch(lastnibble, nibblecount); } Randombytes = ""; } else { { donibblebatch(lastnibble, nibblecount); } } } else { if (VbX.Len(Randombytes) == 4 && n == 1) // { //finish the last byte donibblebatch(Randombytes, nibblecount); nibblecount = 0; Randombytes = lastnibble; CurrentMode = 2; } else { Randombytes = Randombytes + lastnibble; CurrentMode = 2; nibblecount = 0; } } nibblecount = 1; lastnibble = nibble; } } } } } dobytebatchWithRepeater(Randombytes); donibblebatch(lastnibble, nibblecount); /* * FirstY = FirstY + VbX.CInt(txtYpos.Text); * * globals.imagedata.Append(Filename + ":" + nl); * globals.imagedata.Append("ld hl," + Filename + "_rledata-1" + nl); * globals.imagedata.Append("ld de," + Filename + "_rledataEnd-1" + nl); * globals.imagedata.Append("ld b," + FirstY.ToString() + nl); * int thiswidth = b.Width / 4; * globals.imagedata.Append("ld ixh," + thiswidth.ToString() + nl); * * * thiswidth = VbX.CInt(txtXpos.Text) + thiswidth - 1; * * globals.imagedata.Append("ld IXL," + thiswidth.ToString() + nl); * * globals.imagedata.Append("di" + nl); * globals.imagedata.Append("exx " + nl); * globals.imagedata.Append("push bc" + nl); * globals.imagedata.Append("exx" + nl); * globals.imagedata.Append("jp RLE_Draw" + nl); * globals.imagedata.Append(Filename + "_rledata:" + nl); * globals.imagedata.Append(Chunk.ToString() + nl); * globals.imagedata.Append(Filename + "_rledataEnd: defb 0" + nl); * textBox1.Text = globals.initdata + nl + globals.imagedata.ToString() + nl + globals.globaldata.ToString(); */ }
public void NewRLE() { string lastnibble = ""; string Randombytes = ""; int nibblecount = 1; int FirstY = height; // intentionally backwards! int LastY = 0; LastY = height; // intentionally backwards! FirstY = 0; //} int CurrentMode = 0; //1=nibble . 2=byte 3=repeatingbytes int lineitem = 0; String RepeatingBytes = ""; for (int y = FirstY; y < LastY; y++) { for (int x = width - 8; x >= 0; x -= 8) { string thispair = GetPair(y, x); for (int by = 0; by < 2; by++) { string ThisByte = ""; switch (by) { case 0: ThisByte = thispair.Substring(0, 2); break; case 1: ThisByte = thispair.Substring(2, 2); break; } string nibble = ""; for (int n = 0; n < 2; n++) { switch (n) { case 1: nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "11001100"); nibble = nibble.Substring(0, 2) + nibble.Substring(4, 2); break; case 0: nibble = VbX.BinAnd(VbX.HexToBin(ThisByte), "00110011"); nibble = nibble.Substring(2 + 0, 2) + nibble.Substring(2 + 4, 2); break; } if (nibble == lastnibble) { nibblecount++; CurrentMode = 1; } else if (lastnibble == "") { lastnibble = nibble; nibblecount = 1; } else { if (nibblecount > 1) { if (Randombytes.Length > 1) { if (Randombytes.Length == 4) { donibblebatch(Randombytes, 1); donibblebatch(lastnibble, nibblecount); lastnibble = ""; } else { dobytebatchWithRepeater(Randombytes); donibblebatch(lastnibble, nibblecount); } Randombytes = ""; } else { { donibblebatch(lastnibble, nibblecount); } } } else { if (VbX.Len(Randombytes) == 4 && n == 1) // { //finish the last byte donibblebatch(Randombytes, nibblecount); nibblecount = 0; Randombytes = lastnibble; CurrentMode = 2; } else { Randombytes = Randombytes + lastnibble; CurrentMode = 2; nibblecount = 0; } } nibblecount = 1; lastnibble = nibble; } } } } } dobytebatchWithRepeater(Randombytes); donibblebatch(lastnibble, nibblecount); }