Exemple #1
0
        public static string getText2(byte[] buffer, int index)         //int address) //Dark Dawn
        {
            System.Text.StringBuilder strbuild = new StringBuilder(0x200);
            //int addr2 = Bits.getInt32(buffer, address) + 0x220B80;
            int addr2 = Bits.getInt32(buffer, 0x220B80 + index * 4) + 0x220B80;
            int length = 2000; int pos = addr2 & 0xFFFFFF;

            //MessageBox.Show(addr2.ToString("x8"));
            while (length-- > 0)
            {
                int c = Bits.getInt16(buffer, pos); pos += 2;
                if (c == 0)
                {
                    break;
                }
                if ((c < 0x100) && (c > 0xF))
                {
                    strbuild.Append((char)c);
                }
                else
                {
                    strbuild.Append("[" + c.ToString("X4") + "]");
                }
            }
            return(strbuild.ToString());
        }
Exemple #2
0
        //Random Encounters
        private void initRandEnctrs()
        {
            Table_Manager tm = new Table_Manager();

            tm.setTable(test.rom, 0xEDACC, 0x1C);
            tm.setPanel(tabControl1.SelectedTab);            //tabPage8);
            tabPage8.Text = "Encounters";

            List <int> items = new List <int>();

            //ListBox lstb = tm.doTableListbox();
            for (int ind3 = 0; ind3 < 0x6E; ind3++)
            {
                int ind2 = Bits.getInt16(test.rom, 0xEDACC + 4 + ind3 * 0x1C);
                int ind  = Bits.getInt16(test.rom, 0x12CE7C + ind2 * 0x18);
                //StringBuilder str = new StringBuilder(0x200);
                //str.Append((ind3).ToString().PadLeft(3, ' ') + "|");
                //items.Add((ind3).ToString().PadLeft(3, ' ') + "|" + getTextStrShort(1068 + ind));
                items.Add(1068 + ind);
            }
            tm.doTableListbox(txt, items);             //items);

            int pnlx = tabPage8.Width / 2 - 150 + 100 + 25;
            int pnly = tabPage8.Height / 2 - 125;

            tm.doLabel(pnlx, pnly, "Frequency");
            tm.doNud(pnlx, pnly + 20, 0, 16);
            tm.doLabel(pnlx + 200, pnly, "Target Level");
            tm.doNud(pnlx + 200, pnly + 20, 2, 16);


            tm.doLabel(pnlx, pnly + 60, "Group");
            tm.doLabel(pnlx + 200, pnly + 60, "Rate");
            String[] enGroups = new String[660];
            for (int ind2 = 0; ind2 < 660; ind2++)
            {
                enGroups[ind2] = ind2.ToString().PadLeft(3, ' ') + "|" + Bits.getTextShort(txt, 1068 + Bits.getInt16(test.rom, 0x12CE7C + ind2 * 0x18));
            }
            tm.doCombo(pnlx, pnly + 80, Bits.textToBytes(enGroups), Bits.numList(660), 4, 16);
            tm.doCombo(pnlx, pnly + 100, Bits.textToBytes(enGroups), Bits.numList(660), 6, 16);
            tm.doCombo(pnlx, pnly + 120, Bits.textToBytes(enGroups), Bits.numList(660), 8, 16);
            tm.doCombo(pnlx, pnly + 140, Bits.textToBytes(enGroups), Bits.numList(660), 10, 16);
            tm.doCombo(pnlx, pnly + 160, Bits.textToBytes(enGroups), Bits.numList(660), 12, 16);
            tm.doCombo(pnlx, pnly + 180, Bits.textToBytes(enGroups), Bits.numList(660), 14, 16);
            tm.doCombo(pnlx, pnly + 200, Bits.textToBytes(enGroups), Bits.numList(660), 16, 16);
            tm.doCombo(pnlx, pnly + 220, Bits.textToBytes(enGroups), Bits.numList(660), 18, 16);

            tm.doNud(pnlx + 200, pnly + 80, 20, 8);
            tm.doNud(pnlx + 200, pnly + 100, 21, 8);
            tm.doNud(pnlx + 200, pnly + 120, 22, 8);
            tm.doNud(pnlx + 200, pnly + 140, 23, 8);
            tm.doNud(pnlx + 200, pnly + 160, 24, 8);
            tm.doNud(pnlx + 200, pnly + 180, 25, 8);
            tm.doNud(pnlx + 200, pnly + 200, 26, 8);
            tm.doNud(pnlx + 200, pnly + 220, 27, 8);

            //lstb.SelectedIndex = 0;
        }
Exemple #3
0
        //0x16E
        void getText(System.Text.StringBuilder strbuild, byte[] buffer, int address)
        {
            int addr2 = Bits.getInt32(buffer, address);
            int length = 2000; int pos = addr2 & 0xFFFFFF;

            //MessageBox.Show(addr2.ToString("x8"));
            while (length-- > 0)
            {
                int c = Bits.getInt16(buffer, pos); pos += 2;
                if (c == 0)
                {
                    break;
                }
                if ((c < 0x100) && (c > 0xF))
                {
                    strbuild.Append((char)c);
                }
                else
                {
                    strbuild.Append("[" + c.ToString("X4") + "]");
                }
            }
        }
Exemple #4
0
 void drawStringI(string text, int[] bmpdata, int x, int y)
 {
     //MessageBox.Show(((byte)text[1]).ToString());
     //0805A4E0 = Italics font
     byte[] rom = Globals.mainForm.rom;
     for (int stri = 0; stri < text.Length; stri++)
     {
         int chri = (byte)text[stri] - 0x20;
         for (int yi = 0; yi < 14; yi++)
         {
             int row = Bits.getInt16(rom, 0x5A4E0 + (chri * 0x20) + 2 + (yi * 2));
             for (int xi = 0; xi < 14; xi++)
             {
                 if ((row & 0x8000) != 0)
                 {
                     bmpdata[(y + yi) * scnw + (x + xi)]         = 0xF8F8F8;
                     bmpdata[(y + yi + 1) * scnw + (x + xi + 1)] = 0;
                 }
                 row <<= 1;
             }
         }
         x += Bits.getInt16(rom, 0x5A4E0 + (chri * 0x20));
     }
 }
Exemple #5
0
        static public byte[] decompTextOld(byte[] src)
        {
            DateTime c         = DateTime.Now;
            int      asmpchar  = Bits.getInt32(src, 0x38578) - 0x8000000;
            int      asmptext  = Bits.getInt32(src, 0x385DC) - 0x8000000;
            int      chardata  = Bits.getInt32(src, asmpchar) - 0x08000000;
            int      charpntrs = Bits.getInt32(src, asmpchar + 4) - 0x08000000;

            byte[] des = new byte[0x800000]; int desEntry = 0, desPos = 0xC300;
            for (int srcI = 0; srcI < 12461; srcI++)
            {
                Bits.setInt32(des, desEntry, desPos - 0xC300); desEntry += 4;
                int srcInd = srcI;

                int textTree    = Bits.getInt32(src, asmptext + ((srcInd >> 8) << 3)) - 0x08000000;
                int textLenAddr = Bits.getInt32(src, asmptext + ((srcInd >> 8) << 3) + 4) - 0x08000000;
                srcInd &= 0xFF;
                while (srcInd-- != 0)
                {
                    int cLen;
                    do
                    {
                        cLen      = src[textLenAddr++];
                        textTree += cLen;
                    } while (cLen == 0xFF);
                }
                int initChar = 0;

                textTree <<= 3;
                do
                {
                    int charTree = (chardata + Bits.getInt16(src, charpntrs + (initChar << 1))) << 3;
                    int charSlot = charTree - 12;
                    while (((src[charTree >> 3] >> (charTree++ & 7)) & 1) == 0)
                    {
                        if (((src[textTree >> 3] >> (textTree++ & 7)) & 1) == 1)
                        {
                            int depth = 0;
                            while (depth >= 0)
                            {
                                while (((src[charTree >> 3] >> (charTree++ & 7)) & 1) == 0)
                                {
                                    depth++;
                                }
                                charSlot -= 12;
                                depth--;
                            }
                        }
                    }
                    initChar      = (Bits.getInt16(src, charSlot >> 3) >> (charSlot & 7)) & 0xFFF;
                    des[desPos++] = (byte)initChar;
                    //do {
                    // n=getNextCharacter(argument0)
                    // if n!=0 {
                    //  if (n<32 || n>ord('~')) {
                    //   if argument2
                    //   { str+='['+string(n)+']'; }
                    //   if argument3 && (n==1 || n==3) && (p<17 || p>20) && p!=26 && p!=29
                    //   { n=0 }
                    //  } else { str+=chr(n); }
                    // }
                    // p=n
                    //} until n=0
                } while (initChar != 0);
            }
            Console.WriteLine(DateTime.Now - c + " (Old Text Decompression)");
            return(des);
        }
Exemple #6
0
        static public byte[] decompText(byte[] src)   //, int srcInd) { // int srcPos) {
        //return decompTextOld(src);
        {
            DateTime c = DateTime.Now;

            int[]   bitcode = new int[0x10000];
            byte[]  bitLen  = new byte[0x10000];
            short[] bitChar = new short[0x10000];
            //Scan char data to generate data for faster decompression than old method.
            int asmpchar  = Bits.getInt32(src, 0x38578) - 0x8000000;
            int asmptext  = Bits.getInt32(src, 0x385DC) - 0x8000000;
            int chardata  = Bits.getInt32(src, asmpchar) - 0x08000000;
            int charpntrs = Bits.getInt32(src, asmpchar + 4) - 0x08000000;

            for (int char1 = 0; char1 < 0x100; char1++)
            {
                if (charpntrs == asmpchar)
                {
                    break;
                }
                if (Bits.getInt16(src, charpntrs) == 0x8000)
                {
                    charpntrs += 2; continue;
                }
                int  charTree = (chardata + Bits.getInt16(src, charpntrs)) << 3; charpntrs += 2;
                int  charSlot = charTree - 12;
                byte bits = 0; int bitC = 0; int entry = (char1 << 8);
                do
                {
                    while (((src[charTree >> 3] >> (charTree++ & 7)) & 1) == 0)
                    {
                        bits++;
                    }
                    bitChar[entry] = (short)((Bits.getInt16(src, charSlot >> 3) >> (charSlot & 7)) & 0xFFF); charSlot -= 12;
                    bitLen[entry]  = bits; if (bits >= 24)
                    {
                        return(decompTextOld(src));
                    }
                    bitcode[entry] = bitC;
                    while (((bitC >> (bits - 1)) & 1) == 1)
                    {
                        bits -= 1; bitC ^= 1 << bits;
                    }
                    bitC  |= 1 << (bits - 1);
                    entry += 1;
                } while (bits > 0);
            }
            //Console.WriteLine(DateTime.Now - c);
            //c = DateTime.Now;
            int textTree = 0, textLenAddr = 0;

            byte[] des = new byte[0x800000]; int desEntry = 0, desPos = 0xC300;
            for (int srcI = 0; srcI < 12461; srcI++)
            {
                Bits.setInt32(des, desEntry, desPos - 0xC300); desEntry += 4;
                int srcInd = srcI;
                if ((srcInd & 0xFF) == 0)
                {
                    textTree    = Bits.getInt32(src, asmptext + ((srcInd >> 8) << 3)) - 0x08000000;
                    textLenAddr = Bits.getInt32(src, asmptext + ((srcInd >> 8) << 3) + 4) - 0x08000000;
                }
                else
                {
                    int cLen;
                    do
                    {
                        cLen      = src[textLenAddr++];
                        textTree += cLen;
                    } while (cLen == 0xFF);
                }
                int initChar = 0, bitnum = 0, val = 0, textTree2 = textTree;
                do
                {
                    while (bitnum < 24)
                    {
                        val |= (int)src[textTree2++] << bitnum; bitnum += 8;
                    }
                    int entry = initChar << 8;
                    while ((val & ((1 << bitLen[entry]) - 1)) != bitcode[entry])
                    {
                        entry++;
                    }
                    initChar      = bitChar[entry]; val >>= bitLen[entry]; bitnum -= bitLen[entry];
                    des[desPos++] = (byte)initChar;
                    //if (desPos >= 0x10000) { break; }
                } while (initChar != 0);
            }
            Console.WriteLine(DateTime.Now - c + " (Text Decompression)");
            return(des);
        }
Exemple #7
0
        public void initForgeTable()
        {
            Table_Manager tm = new Table_Manager();

            tm.setTable(test.rom, 0x10CC34, 0x24);
            tm.setPanel(tabControl1.SelectedTab);            //tabPage6);
            tabPage6.Text = "Forge";

            //ListBox lstb = tm.doTableListbox();
            ////607
            int        ind3  = 0;
            List <int> items = new List <int>();

            while (true)             //for (int ind3 = 0; ind3 < 0x14; ind3++)
            {
                //int ind2 = Bits.getInt16(test.rom, 0xEDACC + 4 + ind3 * 0x1C);
                int ind = Bits.getInt16(test.rom, 0x10CC34 + ind3 * 0x24);
                if (ind == 0xFFFF)
                {
                    break;
                }
                //StringBuilder str = new StringBuilder(0x200);
                //str.Append((ind3).ToString().PadLeft(3, ' ') + "|");
                //items.Add((ind3).ToString().PadLeft(3, ' ') + "|" + getTextStrShort(607 + ind));
                items.Add(607 + ind);
                ind3++;
            }
            tm.doTableListbox(txt, items);            // items);
            String[] itemNames = new String[461];
            for (int ind2 = 0; ind2 < 461; ind2++)
            {
                itemNames[ind2] = ind2.ToString().PadLeft(3, ' ') + "|" + Bits.getTextShort(txt, 607 + ind2);
            }
            int   pnlx = tabPage8.Width / 2 - 150 + 100 + 25;
            int   pnly = tabPage8.Height / 2 - 125;
            Label fi   = tm.doLabel(pnlx, pnly, "Forgeable Item");

            //fi.Width = 200;
            tm.doCombo(pnlx, pnly + 20, Bits.textToBytes(itemNames), Bits.numList(461), 0, 16);
            tm.doLabel(pnlx + 200, pnly, "Just text?");
            String[] text = { "Processed", "Rusted" };
            tm.doCombo(pnlx + 200, pnly + 20, Bits.textToBytes(text), Bits.numList(2), 2, 16);
            //fi.Width = 200;
            //tm.doNud(pnlx+ 200, pnly + 20, 2, 16);

            tm.doLabel(pnlx, pnly + 60, "Item");
            tm.doLabel(pnlx + 200, pnly + 60, "Rate");

            tm.doCombo(pnlx, pnly + 80, Bits.textToBytes(itemNames), Bits.numList(461), 4, 16);
            tm.doCombo(pnlx, pnly + 100, Bits.textToBytes(itemNames), Bits.numList(461), 6, 16);
            tm.doCombo(pnlx, pnly + 120, Bits.textToBytes(itemNames), Bits.numList(461), 8, 16);
            tm.doCombo(pnlx, pnly + 140, Bits.textToBytes(itemNames), Bits.numList(461), 10, 16);
            tm.doCombo(pnlx, pnly + 160, Bits.textToBytes(itemNames), Bits.numList(461), 12, 16);
            tm.doCombo(pnlx, pnly + 180, Bits.textToBytes(itemNames), Bits.numList(461), 14, 16);
            tm.doCombo(pnlx, pnly + 200, Bits.textToBytes(itemNames), Bits.numList(461), 16, 16);
            tm.doCombo(pnlx, pnly + 220, Bits.textToBytes(itemNames), Bits.numList(461), 18, 16);

            tm.doNud(pnlx + 200, pnly + 80, 20, 16);
            tm.doNud(pnlx + 200, pnly + 100, 22, 16);
            tm.doNud(pnlx + 200, pnly + 120, 24, 16);
            tm.doNud(pnlx + 200, pnly + 140, 26, 16);
            tm.doNud(pnlx + 200, pnly + 160, 28, 16);
            tm.doNud(pnlx + 200, pnly + 180, 30, 16);
            tm.doNud(pnlx + 200, pnly + 200, 32, 16);
            tm.doNud(pnlx + 200, pnly + 220, 34, 16);

            //lstb.SelectedIndex = 0;
        }