コード例 #1
0
        public void ProcessANSIFile(string sFile, byte[] aFile = null)
        {
            if (bDebug)
            {
                Console.WriteLine("Process ANS File: " + sFile);
            }
            int StoreX   = 1;
            int StoreY   = 1;
            int AnsiMode = 0;

            byte[]   aAnsi = null;
            string[] aPar;
            bool     bDrawChar;
            bool     bEnde;
            int      CurChr;
            int      iLoop2;
            string   sStr       = "";
            string   sEsc       = "";
            Bitmap   Frame      = null;
            double   multiplier = 0.0;

            LineWrap = false;
            Yoffset  = 0;
            int BPF = (int)Math.Floor((BPS / 8) / FPS);

            cBPF         = 0;
            iFramesCount = 0;
            if ((!(aFile == null)))
            {
                aAnsi = ConverterSupport.Convert.MergeByteArrays(ConverterSupport.Convert.NullByteArray(), aFile);
            }
            else
            {
                if (File.Exists(sFile))
                {
                    aAnsi = ConverterSupport.InputOutput.ReadBinaryFile(sFile);
                    aAnsi = ConverterSupport.Convert.MergeByteArrays(ConverterSupport.Convert.NullByteArray(), aAnsi);
                }
            }
            ConverterSupport.Mappings.BuildMappings(sCodePg);

            ForeColor = 7;
            BackColor = 0;
            LineWrap  = true;
            Blink     = false;
            Bold      = 0;
            Reversed  = false;
            LinesUsed = 0;
            // ERROR: Not supported in C#: ReDimStatement

            for (int x = minX; x <= maxX; x++)
            {
                for (int Y = minY; Y <= maxY; Y++)
                {
                    Screen[x, Y] = new ConverterSupport.ScreenChar(x);
                }
            }
            System.Windows.Forms.Application.DoEvents();
            XPos = minX;
            YPos = minY;
            if (!(aAnsi == null))
            {
                if (UBound(aAnsi) > 0)
                {
                    iLoop = 1;
                    if (bMakeVideo)
                    {
                        multiplier = 100 / UBound(aAnsi);

                        if (InfoMsg != null)
                        {
                            InfoMsg(" - Frames Created: ", true, false);
                        }
                        if (InfoMsg != null)
                        {
                            InfoMsg("[b]    0[/b] (  0.00%)", false, false);
                        }
                    }

                    while (iLoop <= UBound(aAnsi))
                    {
                        bDrawChar = true;
                        CurChr    = (int)aAnsi[iLoop];
                        switch (AnsiMode)
                        {
                        case 0:
                            //ESC
                            if (CurChr == 27)
                            {
                                AnsiMode  = 1;
                                bDrawChar = false;
                            }
                            //SUB or "S"
                            if (CurChr == 26 | CurChr == 83)
                            {
                                int iSauceOffset = (int)IIf(CurChr == 83, 1, 0);
                                if (UBound(aAnsi) >= iLoop + 128 - iSauceOffset)
                                {
                                    sStr = "";
                                    for (iLoop2 = 1 - iSauceOffset; iLoop2 <= 5 - iSauceOffset; iLoop2++)
                                    {
                                        sStr += Chr(aAnsi[iLoop + iLoop2]);
                                    }
                                    if (sStr == "SAUCE")
                                    {
                                        bDrawChar = false;
                                        iLoop    += 1 - iSauceOffset;
                                        iLoop     = oSauce.GetFromByteArray(aAnsi, iLoop);
                                        bHasSauce = true;
                                        //Read Sauce
                                        //  If bDebug = True Then Console.WriteLine("Sauce Meta found")
                                    }
                                }
                            }
                            break;

                        case 1:
                            //[
                            if (CurChr == 91)
                            {
                                AnsiMode  = 2;
                                bDrawChar = false;
                            }
                            else
                            {
                                if (ConverterSupport.Convert.SetChar(Chr(27).ToString()) == false)
                                {
                                    iLoop = UBound(aAnsi) + 1;
                                }
                                else
                                {
                                    bDrawChar = true;
                                    AnsiMode  = 0;
                                }
                            }
                            break;

                        case 2:
                            object aRRSize;
                            aRRSize = UBound(aAnsi);
                            sEsc    = Chr(CurChr).ToString();
                            //0-9 or ; or ?
                            if ((CurChr >= 48 & CurChr <= 57) | CurChr == 59 | CurChr == 63)
                            {
                                bEnde = false;
                                while (bEnde == false)
                                {
                                    iLoop += 1;
                                    if (iLoop > (int)aRRSize)
                                    {
                                        bEnde = true;
                                    }
                                    else
                                    {
                                        CurChr = aAnsi[iLoop];
                                        sEsc  += (string)Chr(CurChr).ToString();
                                        //A-Z, a-z
                                        if ((CurChr >= 65 & CurChr <= 90) | (CurChr >= 97 & CurChr <= 122) | CurChr == 27)
                                        {
                                            bEnde = true;
                                        }
                                    }
                                    if (CurChr == 27)
                                    {
                                        AnsiMode  = 1;
                                        bDrawChar = false;
                                    }
                                }
                            }

                            if (AnsiMode == 2)
                            {
                                aPar = BuildParams(sEsc);
                                int NumParams = UBound(aPar);
                                switch (Chr(CurChr).ToString())
                                {
                                case "A":
                                    //Move Cursor Up
                                    if (NumParams > 0)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                        if (iLoop2 == 0)
                                        {
                                            iLoop2 = 1;
                                        }
                                    }
                                    else
                                    {
                                        iLoop2 = 1;
                                    }
                                    YPos = YPos - iLoop2;
                                    int iSavY = YPos;
                                    // If bDebug = True Then Console.WriteLine("YPos - " & iLoop2 & ", New YPos: " & YPos)
                                    if (YPos < minY)
                                    {
                                        YPos = minY;
                                    }
                                    //If YPos < Yoffset Then
                                    //Yoffset = YPos
                                    //End If
                                    // If iSavY <> YPos Then
                                    //If bDebug = True Then Console.WriteLine("Adjusted Pos Y: " & YPos)
                                    // End If
                                    cBPF -= 1;
                                    break;

                                case "B":
                                    //Move Cursor Down
                                    if (NumParams > 0)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                        if (iLoop2 == 0)
                                        {
                                            iLoop2 = 1;
                                        }
                                    }
                                    else
                                    {
                                        iLoop2 = 1;
                                    }
                                    YPos  = YPos + iLoop2;
                                    iSavY = YPos;
                                    // If bDebug = True Then Console.WriteLine("YPos + " & iLoop2 & ", New YPos: " & YPos)
                                    if (YPos > maxY - 1)
                                    {
                                        YPos = maxY - 1;
                                    }
                                    if (YPos > LinesUsed)
                                    {
                                        // If LinesUsed > 25 Then
                                        //Yoffset += (YPos - LinesUsed)
                                        //End If
                                        LinesUsed = YPos;
                                    }
                                    // If iSavY <> YPos Then
                                    //If bDebug = True Then Console.WriteLine("Adjusted Pos Y: " & YPos)
                                    // End If
                                    cBPF -= 1;
                                    break;

                                case "C":
                                    //Move Cursor Right
                                    if (NumParams > 0)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                        if (iLoop2 == 0)
                                        {
                                            iLoop2 = 1;
                                        }
                                    }
                                    else
                                    {
                                        iLoop2 = 1;
                                    }
                                    for (int x = 1; x <= iLoop2; x++)
                                    {
                                        if (ConverterSupport.Convert.SetChar("-2") == false)
                                        {
                                            iLoop = UBound(aAnsi) + 1;
                                        }
                                    }

                                    cBPF -= 1;
                                    break;

                                case "D":
                                    //Move Cursor left
                                    if (NumParams > 0)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                        if (iLoop2 == 0)
                                        {
                                            iLoop2 = 1;
                                        }
                                    }
                                    else
                                    {
                                        iLoop2 = 1;
                                    }
                                    if (iLoop2 == 255)
                                    {
                                        XPos = minX;
                                    }
                                    else
                                    {
                                        for (int x = 1; x <= iLoop2; x++)
                                        {
                                            if (ConverterSupport.Convert.SetChar("-3") == false)
                                            {
                                                iLoop = UBound(aAnsi) + 1;
                                            }
                                        }
                                    }
                                    cBPF -= 1;
                                    break;

                                case "H":
                                    //Move Cursor to pos

                                    if (NumParams > 0)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                        YPos   = (int)IIf(iLoop2 > 0, minY + (iLoop2 - 1), minY);
                                    }
                                    else
                                    {
                                        YPos = minY;
                                    }
                                    if (NumParams > 1)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[2]);
                                        XPos   = (int)IIf(iLoop2 > 0, minX + (iLoop2 - 1), minX);
                                    }
                                    else
                                    {
                                        XPos = minX;
                                    }
                                    int iSavX = XPos;
                                    iSavY = YPos;
                                    // If bDebug = True Then Console.WriteLine("New Cursor Pos X:" & XPos & ", Y: " & YPos)
                                    if (YPos > maxY - 1)
                                    {
                                        YPos = maxY - 1;
                                    }
                                    if (YPos < minY)
                                    {
                                        YPos = minY;
                                    }
                                    if (XPos > maxX)
                                    {
                                        XPos = maxX;
                                    }
                                    if (XPos < minX)
                                    {
                                        XPos = minX;
                                    }
                                    if (YPos > LinesUsed)
                                    {
                                        if (LinesUsed > 25)
                                        {
                                            Yoffset += (YPos - LinesUsed);
                                        }
                                        LinesUsed = YPos;
                                    }
                                    if (YPos < Yoffset)
                                    {
                                        Yoffset = YPos - 1;
                                    }
                                    // If iSavX <> XPos Or iSavY <> YPos Then
                                    // If bDebug = True Then Console.WriteLine("Adjusted Pos X: " & XPos & ", Y: " & YPos)
                                    // End If
                                    cBPF -= 1;
                                    break;

                                case "f":
                                    //Move Cursor to pos
                                    if (NumParams > 0)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                        YPos   = (int)IIf(iLoop2 > 0, minY + (iLoop2 - 1), minY);
                                    }
                                    else
                                    {
                                        YPos = minY;
                                    }
                                    if (NumParams > 1)
                                    {
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[2]);
                                        XPos   = (int)IIf(iLoop2 > 0, minX + (iLoop2 - 1), minX);
                                    }
                                    else
                                    {
                                        XPos = minX;
                                    }
                                    iSavX = XPos;
                                    iSavY = YPos;
                                    if (YPos > maxY - 1)
                                    {
                                        YPos = maxY - 1;
                                    }
                                    if (YPos < minY)
                                    {
                                        YPos = minY;
                                    }
                                    if (XPos > maxX)
                                    {
                                        XPos = maxX;
                                    }
                                    if (XPos < minX)
                                    {
                                        XPos = minX;
                                    }
                                    if (YPos > LinesUsed)
                                    {
                                        //Yoffset()
                                        if (LinesUsed > 25)
                                        {
                                            Yoffset += (YPos - LinesUsed);
                                        }
                                        LinesUsed = YPos;
                                    }
                                    if (YPos < Yoffset)
                                    {
                                        Yoffset = YPos - 1;
                                    }
                                    //If iSavX <> XPos Or iSavY <> YPos Then
                                    // If bDebug = True Then Console.WriteLine("Adjusted Pos X: " & XPos & ", Y: " & YPos)
                                    // End If
                                    cBPF -= 1;
                                    break;

                                case "J":
                                    //ForeColor = 7 : BackColor = 0 : Blink = False : Bold = 0 : Reversed = False
                                    if (NumParams > 0)
                                    {
                                        switch (ConverterSupport.Convert.ChkNum(aPar[1]))
                                        {
                                        case 0:
                                            //erase from cursor to end of screen
                                            ClearLineFromCursor(YPos, XPos);
                                            if (YPos < maxY)
                                            {
                                                for (int Y = YPos + 1; Y <= maxY; Y++)
                                                {
                                                    ClearLine(Y);
                                                }
                                            }
                                            break;

                                        //   If bDebug = True Then Console.WriteLine("Clear Cursor to End of Screen X:" & XPos & ", Y: " & YPos)
                                        case 1:
                                            //Erase from beginning of screen to cursor
                                            ClearLineToCursor(YPos, XPos);
                                            if (YPos > minY)
                                            {
                                                for (int Y = YPos - 1; Y <= minY; Y++)
                                                {
                                                    ClearLine(Y);
                                                }
                                            }
                                            break;

                                        //If bDebug = True Then Console.WriteLine("Clear Beginning of Screen to Cursor X:" & XPos & ", Y: " & YPos)
                                        case 2:
                                            //Clear screen and home cursor
                                            for (int Y = minY; Y <= LinesUsed; Y++)
                                            {
                                                ClearLine(Y);
                                            }

                                            XPos = minX;
                                            YPos = minY;
                                            break;
                                            //If bDebug = True Then Console.WriteLine("Clear Screen X:" & XPos & ", Y: " & YPos)
                                        }
                                        //Erase from cursor to end of screen
                                    }
                                    else
                                    {
                                        ClearLineFromCursor(YPos, XPos);
                                        if (YPos < maxY)
                                        {
                                            for (int Y = YPos + 1; Y <= maxY; Y++)
                                            {
                                                ClearLine(Y);
                                            }
                                        }
                                        //  If bDebug = True Then Console.WriteLine("Clear Cursor to End of Screen X:" & XPos & ", Y: " & YPos)
                                    }

                                    cBPF -= 1;
                                    break;

                                case "m":
                                    //Set Attribute
                                    if (NumParams == 0)
                                    {
                                        ForeColor = 7;
                                        BackColor = 0;
                                        Blink     = false;
                                        Bold      = 0;
                                        Reversed  = false;
                                    }
                                    for (int iLoop3 = 1; iLoop3 <= NumParams; iLoop3++)
                                    {
                                        object i2;
                                        iLoop2 = ConverterSupport.Convert.ChkNum(aPar[iLoop3]);
                                        switch (iLoop2)
                                        {
                                        case 0:
                                            if ((string)Left(aPar[iLoop3], 1) == "0")
                                            {
                                                ForeColor = 7;
                                                BackColor = 0;
                                                Blink     = false;
                                                Bold      = 0;
                                                Reversed  = false;
                                            }
                                            break;

                                        case 1:
                                            Bold = 8;
                                            break;

                                        case 2:
                                            Bold = 0;
                                            break;

                                        case 5:
                                            Blink = true;
                                            break;

                                        case 7:
                                            i2        = ForeColor;
                                            ForeColor = BackColor;
                                            BackColor = (int)i2;
                                            Reversed  = true;
                                            break;

                                        case 22:
                                            Bold = 0;
                                            break;

                                        case 25:
                                            Blink = false;
                                            break;

                                        case 27:
                                            i2        = ForeColor;
                                            ForeColor = BackColor;
                                            BackColor = (int)i2;
                                            Reversed  = false;
                                            break;

                                        case 30:
                                            ForeColor = 0;
                                            break;

                                        case 31:
                                            ForeColor = 4;
                                            break;

                                        case 32:
                                            ForeColor = 2;
                                            break;

                                        case 33:
                                            ForeColor = 6;
                                            break;

                                        case 34:
                                            ForeColor = 1;
                                            break;

                                        case 35:
                                            ForeColor = 5;
                                            break;

                                        case 36:
                                            ForeColor = 3;
                                            break;

                                        case 37:
                                            ForeColor = 7;
                                            break;

                                        case 40:
                                            BackColor = 0;
                                            break;

                                        case 41:
                                            BackColor = 4;
                                            break;

                                        case 42:
                                            BackColor = 2;
                                            break;

                                        case 43:
                                            BackColor = 6;
                                            break;

                                        case 44:
                                            BackColor = 1;
                                            break;

                                        case 45:
                                            BackColor = 5;
                                            break;

                                        case 46:
                                            BackColor = 3;
                                            break;

                                        case 47:
                                            BackColor = 7;
                                            break;
                                        }
                                        cBPF -= 1;
                                    }
                                    break;

                                case "K":
                                    if (NumParams > 0)
                                    {
                                        switch (ConverterSupport.Convert.ChkNum(aPar[1]))
                                        {
                                        case 0:
                                            //clear to the end of the line
                                            ClearLineFromCursor(YPos, XPos);
                                            break;

                                        case 1:
                                            //Erase from beginning of line to cursor
                                            ClearLineToCursor(YPos, XPos);
                                            break;

                                        case 2:
                                            //Erase line containing the cursor
                                            ClearLine(YPos);
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        ClearLineFromCursor(YPos, XPos);
                                        //clear to the end of the line
                                    }
                                    cBPF -= 1;
                                    break;

                                //iLoop2 = XPos
                                //Do While iLoop2 <= maxX
                                // iLoop2 = IIf(SetChar("-1"), iLoop2 + 1, maxX + 1)
                                // Loop
                                case "s":
                                    StoreX = XPos;
                                    StoreY = YPos;
                                    //save cursor position
                                    cBPF -= 2;
                                    break;

                                //If bDebug = True Then Console.WriteLine("Save pos X: " & XPos & ", Y:" & YPos)
                                case "u":
                                    // If bDebug = True Then Console.WriteLine("Restore pos X: " & StoreX & ", Y:" & StoreY & ", Old Pos X: " & XPos & ", Y:" & YPos)
                                    XPos = StoreX;
                                    YPos = StoreY;
                                    //return to saved position
                                    cBPF -= 1;
                                    if (YPos > LinesUsed)
                                    {
                                        //Yoffset()
                                        if (LinesUsed > 25)
                                        {
                                            Yoffset += (YPos - LinesUsed);
                                        }
                                        LinesUsed = YPos;
                                    }
                                    break;
                                    // If YPos < Yoffset Then
                                    //Yoffset = YPos - 1
                                    break;

                                //End If
                                case "n":
                                    //Report Cursor Position
                                    cBPF -= 2;
                                    break;

                                case "h":
                                    //Set Display Mode
                                    //<[=Xh   X = Mode, 7 = Turn ON linewrap
                                    if (NumParams > 0)
                                    {
                                        if (aPar[1] == "?7" | aPar[1] == "7")
                                        {
                                            //If bDebug = True Then Console.WriteLine(aPar[1] & ", Turn on Linewrap")
                                            LineWrap = true;
                                        }
                                    }
                                    break;

                                case "l":
                                    //Set Display Mode
                                    //<[=7l  = Truncate Lines longer than 80 chars
                                    if (NumParams > 0)
                                    {
                                        if (aPar[1] == "?7" | aPar[1] == "7")
                                        {
                                            //If bDebug = True Then Console.WriteLine(aPar[1] & ", Truncate Lines longer than 80 chars")
                                            LineWrap = false;
                                        }
                                    }
                                    break;

                                default:
                                    if (bDebug)
                                    {
                                        Console.WriteLine("Unknown ANSI Command: " + Chr(CurChr).ToString() + " (" + CurChr.ToString() + ") Params: " + Join(aPar, "|").ToString());
                                    }
                                    break;
                                }
                                bDrawChar = false;
                                AnsiMode  = 0;
                            }
                            break;
                        }

                        if (bDrawChar == true & AnsiMode == 0)
                        {
                            switch (CurChr)
                            {
                            case 10:
                                YPos += 1;
                                if (YPos > maxY - 1)
                                {
                                    YPos  = maxY - 1;
                                    iLoop = UBound(aAnsi) + 1;
                                }
                                else
                                {
                                    XPos = minX;
                                }
                                if (YPos > LinesUsed)
                                {
                                    if (LinesUsed > 25)
                                    {
                                        Yoffset += (YPos - LinesUsed);
                                    }
                                    LinesUsed = YPos;
                                }
                                break;

                            //If YPos < Yoffset Then
                            //Yoffset = YPos
                            //End If
                            // restore X in linefeed so's to support *nix type files
                            case 13:
                                // XPos = 1
                                //ignore
                                break;

                            case 26:
                            default:
                                if (ConverterSupport.Convert.SetChar(Chr(CurChr).ToString()) == false)
                                {
                                    iLoop = UBound(aAnsi) + 1;
                                }
                                break;
                            }
                        }
                        if (YPos > LinesUsed)
                        {
                            //   If LinesUsed > 25 Then
                            //Yoffset += (YPos - LinesUsed)
                            //End If
                            LinesUsed = YPos;
                        }
                        //If YPos < Yoffset Then
                        //Yoffset = YPos - 1
                        //End If
                        iLoop += 1;
                        cBPF  += 1;
                        if (cBPF == BPF)
                        {
                            if (bMakeVideo)
                            {
                                Frame = ConverterSupport.Convert.CreateVideoFrame(pSmallFont, pNoColors, Yoffset);
                                //TempVideoFolder
                                iFramesCount += 1;
                                //oAVIFile.AddFrame(Frame)
                                //If bDebug Then
                                //
                                string newOutFile = Path.Combine(TempVideoFolder, Path.GetFileNameWithoutExtension(OutFileWrite) + "_" + Strings.Right("00000" + iFramesCount.ToString(), 5) + ".PNG");
                                Frame.Save(newOutFile, System.Drawing.Imaging.ImageFormat.Png);
                                if (iFramesCount / 10 == (int)iFramesCount / 10)
                                {
                                    if (InfoMsg != null)
                                    {
                                        InfoMsg("[b]" + Strings.Right("     " + iFramesCount.ToString(), 5) + "[/b] (" + Strings.Right("   " + Math.Round(iLoop * multiplier, 2).ToString(), 6) + "%)", true, true);
                                    }
                                }

                                //End If
                                //
                            }
                            cBPF = 0;
                        }
                        if (iLoop / 1000 == (int)iLoop / 1000)
                        {
                            System.Windows.Forms.Application.DoEvents();
                        }
                    }
                    if (bMakeVideo)
                    {
                        if (InfoMsg != null)
                        {
                            InfoMsg("[b]" + Strings.Right("     " + iFramesCount.ToString(), 5) + "[/b] (100.00%)", true, true);
                        }
                        if (LastFrame > 0 & !(Frame == null))
                        {
                            for (int tmpi = 1; tmpi <= Math.Floor(FPS * LastFrame); tmpi++)
                            {
                                iFramesCount += 1;
                                string newOutFile = Path.Combine(TempVideoFolder, Path.GetFileNameWithoutExtension(OutFileWrite) + "_" + Strings.Right("00000" + iFramesCount.ToString(), 5) + ".PNG");
                                Frame.Save(newOutFile, System.Drawing.Imaging.ImageFormat.Png);
                                if (InfoMsg != null)
                                {
                                    InfoMsg("[b]" + Strings.Right("     " + iFramesCount.ToString(), 5) + "[/b] (100.00%)", true, true);
                                }
                            }
                        }
                        if (InfoMsg != null)
                        {
                            InfoMsg("[b]" + Strings.Right("     " + iFramesCount.ToString(), 5) + "[/b] (100.00%)", true, true);
                        }
                        if (InfoMsg != null)
                        {
                            InfoMsg(Environment.NewLine, true, false);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: ANM.cs プロジェクト: SemperFu/ansiconverter
        public static string[] ProcessANSIAnimationFile(string sFile, string sOutFile, byte[] aFile = null)
        {
            int StoreX   = 1;
            int StoreY   = 1;
            int AnsiMode = 0;

            byte[]   aAnsi = null;
            string[] aPar;
            bool     bDrawChar;
            bool     bEnde;
            int      CurChr;
            int      iLoop2;
            string   sStr = "";
            string   sEsc = "";
            string   sRes = "";

            LineWrap = false;
            object[] aOutAnm = new Object[5000];

            //aOutAnm = Data.RedimPreserve(aOutAnm, 5000);
            // ERROR: Not supported in C#: ReDimStatement

            int iCmdCnt;

            iCmdCnt = 0;
            if (!(aFile == null))
            {
                aAnsi = ConverterSupport.Convert.MergeByteArrays(ConverterSupport.Convert.NullByteArray(), aFile);
            }
            else
            {
                if (File.Exists(sFile))
                {
                    aAnsi = ConverterSupport.InputOutput.ReadBinaryFile(sFile);
                    aAnsi = ConverterSupport.Convert.MergeByteArrays(ConverterSupport.Convert.NullByteArray(), aAnsi);
                }
            }

            ConverterSupport.Mappings.BuildMappings(sCodePg);
            System.Windows.Forms.Application.DoEvents();
            ForeColor      = 7;
            Data.BackColor = 0;
            Data.LineWrap  = true;
            Data.Blink     = false;
            Data.Bold      = 0;
            Data.Reversed  = false;
            Data.LinesUsed = 0;

            Data.XPos = Data.minX;
            Data.YPos = Data.minY;
            if (!(aAnsi == null))
            {
                if (Information.UBound(aAnsi) > 0)
                {
                    Data.iLoop = 1;
                    while (iLoop <= Information.UBound(aAnsi))
                    {
                        if (iCmdCnt > Information.UBound((Array)aOutAnm) - 100)
                        {
                            Array.Resize(ref aOutAnm, Information.UBound((Array)aOutAnm) + 1001);
                        }
                        bDrawChar = true;
                        CurChr    = (int)aAnsi[iLoop];
                        switch (AnsiMode)
                        {
                        case 0:
                            //ESC
                            if (CurChr == 27)
                            {
                                AnsiMode  = 1;
                                bDrawChar = false;
                            }
                            //SUB or "S"
                            if (CurChr == 26 | CurChr == 83)
                            {
                                int iSauceOffset = (int)IIf(CurChr == 83, 1, 0);
                                if (Information.UBound(aAnsi) >= iLoop + 128 - iSauceOffset)
                                {
                                    sStr = "";
                                    for (iLoop2 = 1 - iSauceOffset; iLoop2 <= 5 - iSauceOffset; iLoop2++)
                                    {
                                        sStr += Chr(aAnsi[iLoop + iLoop2]);
                                    }
                                    if (sStr == "SAUCE")
                                    {
                                        bDrawChar = false;
                                        iLoop    += 1 - iSauceOffset;
                                        iLoop     = oSauce.GetFromByteArray(aAnsi, iLoop);
                                        bHasSauce = true;
                                        //Read Sauce
                                        if (bDebug == true)
                                        {
                                            Console.WriteLine("Sauce Meta found");
                                        }
                                    }
                                }
                            }
                            break;

                        case 1:
                            //[
                            if (CurChr == 91)
                            {
                                AnsiMode  = 2;
                                bDrawChar = false;
                            }
                            else
                            {
                                aOutAnm[iCmdCnt] = "X" + Hex(27);
                                iCmdCnt         += 1;
                                bDrawChar        = true;
                                AnsiMode         = 0;
                            }
                            break;

                        case 2:
                            int aRRSize;
                            aRRSize = UBound(aAnsi);
                            sEsc    = Chr(CurChr).ToString();
                            //0-9 or ;
                            if ((CurChr >= 48 & CurChr <= 57) | CurChr == 59)
                            {
                                bEnde = false;
                                while (bEnde == false)
                                {
                                    iLoop += 1;
                                    if (iLoop > aRRSize)
                                    {
                                        bEnde = true;
                                    }
                                    else
                                    {
                                        CurChr = aAnsi[iLoop];
                                        sEsc  += (string)Chr(CurChr).ToString();
                                        if ((CurChr >= 65 & CurChr <= 90) | (CurChr >= 97 & CurChr <= 122))
                                        {
                                            bEnde = true;
                                        }
                                    }
                                }
                            }
                            aPar = oAnsi.BuildParams(sEsc);
                            int NumParams = UBound(aPar);
                            switch (Chr(CurChr).ToString())
                            {
                            case "A":
                                //Move Cursor Up
                                if (NumParams > 0)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                    if (iLoop2 == 0)
                                    {
                                        iLoop2 = 1;
                                    }
                                }
                                else
                                {
                                    iLoop2 = 1;
                                }
                                aOutAnm[iCmdCnt] = "A" + Right("0" + Conversion.Hex(iLoop2), 2);
                                iCmdCnt         += 1;
                                break;

                            case "B":
                                //Move Cursor Down
                                if (NumParams > 0)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                    if (iLoop2 == 0)
                                    {
                                        iLoop2 = 1;
                                    }
                                }
                                else
                                {
                                    iLoop2 = 1;
                                }
                                YPos             = YPos + iLoop2;
                                aOutAnm[iCmdCnt] = "B" + Strings.Right("0" + Conversion.Hex(iLoop2), 2);
                                iCmdCnt         += 1;
                                break;

                            case "C":
                                //Move Cursor Right
                                if (NumParams > 0)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                    if (iLoop2 == 0)
                                    {
                                        iLoop2 = 1;
                                    }
                                }
                                else
                                {
                                    iLoop2 = 1;
                                }
                                aOutAnm[iCmdCnt] = "C" + Strings.Right("0" + Conversion.Hex(iLoop2), 2);
                                iCmdCnt         += 1;
                                break;

                            case "D":
                                //Move Cursor left
                                if (NumParams > 0)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                    if (iLoop2 == 0)
                                    {
                                        iLoop2 = 1;
                                    }
                                }
                                else
                                {
                                    iLoop2 = 1;
                                }
                                aOutAnm[iCmdCnt] = "D" + Strings.Right("0" + Conversion.Hex(iLoop2), 2);
                                iCmdCnt         += 1;
                                break;

                            case "H":
                                //Move Cursor
                                if (NumParams > 0)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                    YPos   = (int)IIf(iLoop2 > 0, minY + (iLoop2 - 1), minY);
                                }
                                else
                                {
                                    YPos = minY;
                                }
                                if (NumParams > 1)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[2]);
                                    XPos   = (int)IIf(iLoop2 > 0, minX + (iLoop2 - 1), minX);
                                }
                                else
                                {
                                    XPos = minX;
                                }
                                aOutAnm[iCmdCnt] = "P" + escapchr(Chr(XPos + 45).ToString()) + escapchr(Chr(YPos + 96).ToString());
                                iCmdCnt         += 1;
                                break;

                            case "f":
                                //Move Cursor
                                if (NumParams > 0)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[1]);
                                    YPos   = (int)IIf(iLoop2 > 0, minY + (iLoop2 - 1), minY);
                                }
                                else
                                {
                                    YPos = minY;
                                }
                                if (NumParams > 1)
                                {
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[2]);
                                    XPos   = (int)IIf(iLoop2 > 0, minX + (iLoop2 - 1), minX);
                                }
                                else
                                {
                                    XPos = minX;
                                }
                                aOutAnm[iCmdCnt] = "P" + escapchr(Chr(XPos + 45).ToString()) + escapchr(Chr(YPos + 96).ToString());
                                iCmdCnt         += 1;
                                break;

                            case "J":
                                //ForeColor = 7 : BackColor = 0 : Blink = False : Bold = 0 : Reversed = False
                                if (NumParams > 0)
                                {
                                    switch (ConverterSupport.Convert.ChkNum(aPar[1]))
                                    {
                                    case 0:
                                        //erase from cursor to end of screen
                                        aOutAnm[iCmdCnt] = "K";
                                        iCmdCnt         += 1;
                                        break;

                                    case 1:
                                        //Erase from beginning of screen to cursor
                                        aOutAnm[iCmdCnt] = "J";
                                        iCmdCnt         += 1;
                                        break;

                                    case 2:
                                        //Clear screen and home cursor
                                        aOutAnm[iCmdCnt] = "F";
                                        iCmdCnt         += 1;
                                        break;
                                    }
                                    //Erase from cursor to end of screen
                                }
                                else
                                {
                                    aOutAnm[iCmdCnt] = "K";
                                    iCmdCnt         += 1;
                                }
                                break;

                            case "m":
                                //Set Attribute
                                if (NumParams == 0)
                                {
                                    Data.ForeColor   = 7;
                                    BackColor        = 0;
                                    Blink            = false;
                                    Bold             = 0;
                                    Reversed         = false;
                                    aOutAnm[iCmdCnt] = "T07";
                                    iCmdCnt         += 1;
                                    aOutAnm[iCmdCnt] = "L0";
                                    iCmdCnt         += 1;
                                }
                                for (int iLoop3 = 1; iLoop3 <= NumParams; iLoop3++)
                                {
                                    object i2;
                                    iLoop2 = ConverterSupport.Convert.ChkNum(aPar[iLoop3]);
                                    switch (iLoop2)
                                    {
                                    case 0:
                                        if ((string)Left(aPar[iLoop3], 1) == "0")
                                        {
                                            ForeColor        = 7;
                                            BackColor        = 0;
                                            Blink            = false;
                                            Bold             = 0;
                                            Reversed         = false;
                                            aOutAnm[iCmdCnt] = "T07";
                                            iCmdCnt         += 1;
                                            aOutAnm[iCmdCnt] = "L0";
                                            iCmdCnt         += 1;
                                        }
                                        break;

                                    case 1:
                                        Bold             = 8;
                                        aOutAnm[iCmdCnt] = "T" + Conversion.Hex(BackColor) + Conversion.Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 2:
                                        Bold             = 0;
                                        aOutAnm[iCmdCnt] = "T" + Conversion.Hex(BackColor) + Conversion.Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 5:
                                        Blink            = true;
                                        aOutAnm[iCmdCnt] = "L1";
                                        iCmdCnt         += 1;
                                        break;

                                    case 7:
                                        i2               = ForeColor;
                                        ForeColor        = BackColor;
                                        BackColor        = (int)i2;
                                        Reversed         = true;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 22:
                                        Bold             = 0;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 25:
                                        Blink            = false;
                                        aOutAnm[iCmdCnt] = "L0";
                                        iCmdCnt         += 1;
                                        break;

                                    case 27:
                                        i2               = ForeColor;
                                        ForeColor        = BackColor;
                                        BackColor        = (int)i2;
                                        Reversed         = false;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 30:
                                        ForeColor        = 0;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 31:
                                        ForeColor        = 4;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 32:
                                        ForeColor        = 2;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 33:
                                        ForeColor        = 6;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 34:
                                        ForeColor        = 1;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 35:
                                        ForeColor        = 5;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 36:
                                        ForeColor        = 3;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 37:
                                        ForeColor        = 7;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 40:
                                        BackColor        = 0;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 41:
                                        BackColor        = 4;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 42:
                                        BackColor        = 2;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 43:
                                        BackColor        = 6;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 44:
                                        BackColor        = 1;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 45:
                                        BackColor        = 5;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 46:
                                        BackColor        = 3;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;

                                    case 47:
                                        BackColor        = 7;
                                        aOutAnm[iCmdCnt] = "T" + Hex(BackColor) + Hex(ForeColor + Bold);
                                        iCmdCnt         += 1;
                                        break;
                                    }
                                }
                                break;

                            case "K":
                                if (NumParams > 0)
                                {
                                    switch (ConverterSupport.Convert.ChkNum(aPar[1]))
                                    {
                                    case 0:
                                        //clear to the end of the line
                                        aOutAnm[iCmdCnt] = "G";
                                        iCmdCnt         += 1;
                                        break;

                                    case 1:
                                        //Erase from beginning of line to cursor
                                        aOutAnm[iCmdCnt] = "H";
                                        iCmdCnt         += 1;
                                        break;

                                    case 2:
                                        //Erase line containing the cursor
                                        aOutAnm[iCmdCnt] = "I";
                                        iCmdCnt         += 1;
                                        break;
                                    }
                                }
                                else
                                {
                                    //clear to the end of the line
                                    aOutAnm[iCmdCnt] = "G";
                                    iCmdCnt         += 1;
                                }
                                break;

                            case "s":
                                //save cursor position
                                aOutAnm[iCmdCnt] = "S";
                                iCmdCnt         += 1;
                                break;

                            case "u":
                                //Restore Position
                                aOutAnm[iCmdCnt] = "R";
                                iCmdCnt         += 1;
                                break;

                            case "n":
                                //Report Cursor Position
                                aOutAnm[iCmdCnt] = "W01";
                                iCmdCnt         += 1;
                                break;

                            //Set Display Mode
                            case "h":
                            //<[=Xh   X = Mode, 7 = Turn ON linewrap

                            //Set Display Mode
                            case "l":
                            //<[=7l  = Truncate Lines longer than 80 chars
                            default:

                                Console.WriteLine("Unknown ANSI Command: " + Chr(CurChr).ToString() + " (" + CurChr.ToString() + ") Params: " + Join(aPar, "|").ToString() + ",File: " + sFile + ", Pos: " + iLoop.ToString());
                                break;
                            }

                            bDrawChar = false;
                            AnsiMode  = 0;
                            break;
                        }

                        if (bDrawChar == true & AnsiMode == 0)
                        {
                            switch (CurChr)
                            {
                            case 10:
                                aOutAnm[iCmdCnt] = "N";
                                iCmdCnt         += 1;
                                break;

                            // restore X in linefeed so's to support *nix type files
                            case 13:
                                // XPos = 1
                                break;

                            case 32:
                                aOutAnm[iCmdCnt] = "Z01";
                                iCmdCnt         += 1;
                                //ignore
                                break;

                            case 26:
                            default:
                                // If CurChr >= 1 Then
                                aOutAnm[iCmdCnt] = "X" + Hex(CurChr);
                                iCmdCnt         += 1;
                                //End If
                                break;
                            }
                        }
                        iLoop += 1;
                        if (iLoop / 1000 == (int)iLoop / 1000)
                        {
                            System.Windows.Forms.Application.DoEvents();
                        }
                    }
                }
            }

            string SubBlock = "F";
            int    SubCnt   = 1;

            string[] aTmp = new string[iCmdCnt - 1];
            string   sPrevCmd;
            int      ExecCnt;
            string   sCurCmd  = "";
            int      iNewPos  = 0;
            string   sCombStr = "";

            if (iCmdCnt > 0)
            {
                // ERROR: Not supported in C#: ReDimStatement

                sPrevCmd = "";
                ExecCnt  = 0;
                for (iLoop2 = 0; iLoop2 <= iCmdCnt - 1; iLoop2++)
                {
                    sCurCmd = Strings.Left(aOutAnm[iLoop2].ToString(), 1);
                    if (sPrevCmd != sCurCmd)
                    {
                        if (sPrevCmd != "")
                        {
                            switch (sPrevCmd)
                            {
                            //Case "P" : SubBlock &= " " & sCombStr : SubCnt += 1
                            case "T":
                                SubBlock += " " + sCombStr;
                                SubCnt   += 1;
                                break;

                            case "S":
                                if (ExecCnt > 1)
                                {
                                    SubBlock += " S";
                                    SubCnt   += 1;
                                    SubBlock += " W" + Right("0" + Hex(ExecCnt - 1), 2);
                                    SubCnt   += 1;
                                }
                                else
                                {
                                    SubBlock += " S";
                                    SubCnt   += 1;
                                }
                                break;

                            case "R":
                                if (ExecCnt > 1)
                                {
                                    SubBlock += " R";
                                    SubCnt   += 1;
                                    SubBlock += " W" + Right("0" + Hex(ExecCnt - 1), 2);
                                    SubCnt   += 1;
                                }
                                else
                                {
                                    SubBlock += " R";
                                    SubCnt   += 1;
                                }
                                break;

                            case "W":
                                SubBlock += " W" + Right("0" + Hex(ExecCnt), 2);
                                SubCnt   += 1;
                                break;

                            case "Z":
                                SubBlock += " Z" + Right("0" + Hex(ExecCnt), 2);
                                SubCnt   += 1;
                                break;

                            case "X":
                                SubBlock += IIf(ExecCnt > 1, " x" + sCombStr, " X" + sCombStr);
                                SubCnt   += 1;
                                break;

                            default:
                                //shouldn't be here
                                break;
                            }
                            if (SubCnt > 1000)
                            {
                                aTmp[iNewPos] = Trim(SubBlock);
                                iNewPos      += 1;
                                SubCnt        = 0;
                                SubBlock      = "";
                            }
                        }
                        sCombStr = "";
                        ExecCnt  = 1;
                        switch (sCurCmd)
                        {
                        //Case "P" : sCombStr = aOutAnm[iLoop2] : sPrevCmd = sCurCmd
                        case "T":
                            sCombStr = aOutAnm[iLoop2].ToString();
                            sPrevCmd = sCurCmd;
                            break;

                        case "S":
                            ExecCnt  = 1;
                            sPrevCmd = sCurCmd;
                            break;

                        case "R":
                            ExecCnt  = 1;
                            sPrevCmd = sCurCmd;
                            break;

                        case "W":
                            ExecCnt  = 1;
                            sPrevCmd = sCurCmd;
                            break;

                        case "Z":
                            ExecCnt  = 1;
                            sPrevCmd = sCurCmd;
                            break;

                        case "X":
                            sCombStr = Right(aOutAnm[iLoop2].ToString(), aOutAnm[iLoop2].ToString().Length - 1);
                            ExecCnt  = 1;
                            sPrevCmd = sCurCmd;
                            break;

                        default:
                            SubBlock += " " + aOutAnm[iLoop2];
                            SubCnt   += 1;
                            sPrevCmd  = "";
                            break;
                        }
                    }
                    else
                    {
                        switch (sCurCmd)
                        {
                        //Case "P" : sCombStr = aOutAnm[iLoop2]
                        case "T":
                            sCombStr = aOutAnm[iLoop2].ToString();
                            break;

                        case "S":
                            ExecCnt += 1;
                            break;

                        case "R":
                            ExecCnt += 1;
                            break;

                        case "W":
                            ExecCnt += 1;
                            break;

                        case "Z":
                            ExecCnt += 1;
                            break;

                        case "X":
                            sCombStr += ";" + Right(aOutAnm[iLoop2].ToString(), aOutAnm[iLoop2].ToString().Length - 1);
                            ExecCnt  += 1;
                            break;
                        }
                    }
                }
                if (sPrevCmd != "")
                {
                    switch (sPrevCmd)
                    {
                    //Case "P" : SubBlock &= " " & sCombStr : SubCnt += 1
                    case "T":
                        SubBlock += " " + sCombStr;
                        SubCnt   += 1;
                        break;

                    case "S":
                        if (ExecCnt > 1)
                        {
                            SubBlock += " S";
                            SubCnt   += 1;
                            SubBlock += " W" + Right("0" + Hex(ExecCnt - 1), 2);
                            SubCnt   += 1;
                        }
                        else
                        {
                            SubBlock += " S";
                            SubCnt   += 1;
                        }
                        break;

                    case "R":
                        if (ExecCnt > 1)
                        {
                            SubBlock += " R";
                            SubCnt   += 1;
                            SubBlock += " W" + Right("0" + Hex(ExecCnt - 1), 2);
                            SubCnt   += 1;
                        }
                        else
                        {
                            SubBlock += " R";
                            SubCnt   += 1;
                        }
                        break;

                    case "W":
                        SubBlock += " W" + Right("0" + Hex(ExecCnt), 2);
                        SubCnt   += 1;
                        break;

                    case "Z":
                        SubBlock += " Z" + Right("0" + Hex(ExecCnt), 2);
                        SubCnt   += 1;
                        break;

                    case "X":
                        SubBlock += IIf(ExecCnt > 1, " x" + sCombStr, " X" + sCombStr);
                        SubCnt   += 1;
                        break;

                    default:
                        //shouldn't be here
                        Console.WriteLine("shouldn't be here. sPrevCmd='" + sPrevCmd + "'");
                        break;
                    }

                    aTmp[iNewPos] = Trim(SubBlock);
                    iNewPos      += 1;
                    SubCnt        = 0;
                    SubBlock      = "";
                }
                if (SubCnt > 0)
                {
                    aTmp[iNewPos] = Trim(SubBlock);
                    iNewPos      += 1;
                    SubCnt        = 0;
                    SubBlock      = "";
                }
                Array.Resize(ref aTmp, iNewPos);
                sRes = Join(aTmp, ",");
                sRes = "var aAnim" + ProcFilesCounter + "=[\"" + Replace(sRes, ",", "\",\"", 1, -1, CompareMethod.Text) + "\"];";
            }
            string sOut = "";

            if (bHTMLComplete == true)
            {
                sOut += "<html><head>\r\n";
                sOut += ConverterSupport.InputOutput.BuildCSSforHTML();
                sOut += "</head><body>\r\n";
            }

            sOut += "<div class=ANSICSS id=\"anm" + ProcFilesCounter + "\"><pre>\r\n";
            iLoop = 0;
            for (int a = 1; a <= 25; a++)
            {
                for (int b = minX; b <= maxX; b++)
                {
                    sOut  += "<span class=\"II\" id=\"" + Hex(iLoop) + "\">&nbsp;</span>";
                    iLoop += 1;
                }
                sOut += Environment.NewLine;
            }
            sOut += Environment.NewLine + "</pre></div>\r\n";

            sOut += "<script language=\"Javascript\">\r\n";

            string sJS;

            //= ByteArrayToString(Resources.ANSIJS)
            sJS = ConverterSupport.Convert.ByteArrayToStr(Resources.ANSIJSBA, FFormats.us_ascii);             //NEw VS makes it a string not byte[] Added another file for now with diff ext

            //sJS = ByteArrayToStr(Resources.ANSIJS2, FFormats.us_ascii)

            sJS = ConverterSupport.Convert.CutorSandR(sJS, "//VARDEFSTART", "//VARDEFEND", "I", "I", "C", "1");
            sJS = ConverterSupport.Convert.CutorSandR(sJS, "//CALLSTART", "//CALLEND", "I", "I", "C", "1");

            sJS = Replace(sJS, "//AANIMVAR", sRes, 1, 1, CompareMethod.Text);

            string sMap = "";

            sMap += "var aMappings" + ProcFilesCounter + "=[";
            for (int a = 0; a <= 255; a++)
            {
                sMap += "\"" + HTMLUniEncode(a) + "\"";
                if (a < 255)
                {
                    sMap += ",";
                }
            }
            sMap += "];\r\n";
            sJS   = Replace(sJS, "//AMAPPINGSVAR", sMap, 1, 1, CompareMethod.Text);

            string sFN = "StartAnsiAnimation('anm" + ProcFilesCounter + "',aAnim" + ProcFilesCounter + ",aMappings" + ProcFilesCounter + ");\r\n";

            sJS = Replace(sJS, "//CALLPLACEHOLDER", sFN, 1, 1, CompareMethod.Text);

            sOut += sJS;
            sOut += "</script>\r\n";

            if (bHTMLComplete == true)
            {
                sOut += "</body></html>";
            }

            return((string[])ConverterSupport.InputOutput.WriteFile(sOutFile, sOut, bForceOverwrite, OutputFileExists, false, false));
        }
コード例 #3
0
ファイル: BIN.cs プロジェクト: SemperFu/ansiconverter
        public static void ProcessBINFile(string sFile, byte[] aFile = null)
        {
            byte[] aAnsi = null;
            bool   bDrawChar;
            int    CurChr;
            int    iLoop2;
            string sStr = "";

            string sCol = "";

            if (!(aFile == null))
            {
                aAnsi = ConverterSupport.Convert.MergeByteArrays(ConverterSupport.Convert.NullByteArray(), aFile);
            }
            else
            {
                if (File.Exists(sFile))
                {
                    aAnsi = ConverterSupport.InputOutput.ReadBinaryFile(sFile);
                    aAnsi = ConverterSupport.Convert.MergeByteArrays(ConverterSupport.Convert.NullByteArray(), aAnsi);
                }
            }

            ConverterSupport.Mappings.BuildMappings(sCodePg);

            ForeColor = 7;
            BackColor = 0;
            LineWrap  = true;
            Blink     = false;
            Bold      = 0;
            Reversed  = false;
            LinesUsed = 0;
            // ERROR: Not supported in C#: ReDimStatement

            for (int x = minX; x <= maxX; x++)
            {
                for (int Y = minY; Y <= maxY; Y++)
                {
                    Data.Screen[x, Y] = new ConverterSupport.ScreenChar(x);
                }
            }
            System.Windows.Forms.Application.DoEvents();
            XPos = minX;
            YPos = minY;
            if (!(aAnsi == null))
            {
                if (UBound(aAnsi) > 0)
                {
                    iLoop = 1;
                    while (iLoop <= UBound(aAnsi))
                    {
                        bDrawChar = true;
                        CurChr    = (int)aAnsi[iLoop];

                        //SUB or "S"
                        if (CurChr == 26 | CurChr == 83)
                        {
                            int iSauceOffset = (int)IIf(CurChr == 83, 1, 0);
                            if (UBound(aAnsi) >= iLoop + 128 - iSauceOffset)
                            {
                                sStr = "";
                                for (iLoop2 = 1 - iSauceOffset; iLoop2 <= 5 - iSauceOffset; iLoop2++)
                                {
                                    sStr += Chr(aAnsi[iLoop + iLoop2]);
                                }
                                if (sStr == "SAUCE")
                                {
                                    bDrawChar = false;
                                    iLoop    += 1 - iSauceOffset;
                                    iLoop     = oSauce.GetFromByteArray(aAnsi, iLoop);
                                    bHasSauce = true;
                                    //Read Sauce
                                    if (bDebug == true)
                                    {
                                        Console.WriteLine("Sauce Meta found");
                                    }
                                }
                            }
                        }
                        if (bDrawChar == true)
                        {
                            if (UBound(aAnsi) >= iLoop + 1)
                            {
                                sStr      = CurChr.ToString();
                                iLoop    += 1;
                                CurChr    = (int)aAnsi[iLoop];
                                sCol      = Right("0" + Hex(CurChr), 2);
                                ForeColor = (int)ConverterSupport.Convert.HexToDec(Right(sCol, 1));
                                BackColor = (int)ConverterSupport.Convert.HexToDec(Left(sCol, 1));
                                if (ForeColor > 7)
                                {
                                    Bold       = 8;
                                    ForeColor -= 8;
                                }
                                else
                                {
                                    Bold = 0;
                                }
                                CurChr = System.Convert.ToInt32(sStr);
                                if (CurChr == 0)
                                {
                                    if (!ConverterSupport.Convert.SetChar(" "))
                                    {
                                        iLoop = UBound(aAnsi) + 1;
                                    }
                                    bDrawChar = false;
                                }
                            }
                        }

                        if (bDrawChar == true)
                        {
                            if (ConverterSupport.Convert.SetChar(Chr(CurChr).ToString()) == false)
                            {
                                iLoop = UBound(aAnsi) + 1;
                            }
                        }
                        iLoop += 1;
                        if (iLoop / 1000 == (int)iLoop / 1000)
                        {
                            System.Windows.Forms.Application.DoEvents();
                        }
                    }
                }
            }
        }