Ejemplo n.º 1
0
    public static string GetItem(string lin, string ch, int pos, string brackets)
    {
        if (lin.Length == 0 || ch.Length == 0)
        {
            return("");
        }
        string bracketarray = "";
        string part         = "";
        int    foundnum     = 0;

        for (int i = 1; i <= lin.Length; i++)
        {
            string c = VbX.Mid(lin, i, 1);
            if (c == ch & string.IsNullOrEmpty(bracketarray))
            {
                if (foundnum == pos)
                {
                    return(part);
                }
                else
                {
                    part = ""; foundnum = foundnum + 1;
                }
            }
            else
            {
                part = part + c;
            }

            //    MsgBox(c)
            if (c == VbX.Chr(34) & VbX.InStr(brackets, VbX.Chr(34)) > 0)
            {
                if (VbX.Right(bracketarray, 1) == VbX.Chr(34) & !string.IsNullOrEmpty(bracketarray))
                {
                    bracketarray = VbX.Left(bracketarray, VbX.Len(bracketarray) - 1);
                }
                else
                {
                    bracketarray = bracketarray + VbX.Chr(34);
                }
                //part = part + c
            }
            else if ((c == "(" | c == ")") & VbX.InStr(brackets, "(") > 0)
            {
                if (VbX.Right(bracketarray, 1) == "(" & c == ")" & !string.IsNullOrEmpty(bracketarray))
                {
                    bracketarray = VbX.Left(bracketarray, VbX.Len(bracketarray) - 1);
                }
                else
                {
                    bracketarray = bracketarray + "(";
                }
                //part = part + c
            }
            else if ((c == "{" | c == "}") & VbX.InStr(brackets, "{") > 0)
            {
                if (VbX.Right(bracketarray, 1) == "{" & c == "}" & !string.IsNullOrEmpty(bracketarray))
                {
                    bracketarray = VbX.Left(bracketarray, VbX.Len(bracketarray) - 1);
                }
                else
                {
                    bracketarray = bracketarray + "{";
                }
                //part = part + c
            }
        }
        if (foundnum == pos)
        {
            return(part);
        }
        if (pos == -1)
        {
            return(foundnum.ToString());
        }
        return("");
    }
Ejemplo n.º 2
0
        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();
             */
        }
Ejemplo n.º 3
0
        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();
             */
        }
Ejemplo n.º 4
0
        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);
        }