Ejemplo n.º 1
0
        private void loadCLPSData()
        {
            clps_addr          = _owner.m_Overlay.ReadPointer(0x60);
            clps_num           = _owner.m_Overlay.Read16(clps_addr + 0x06);
            clps_size          = (uint)(8 + (clps_num * 8));
            txtNumEntries.Text = "" + clps_num;
            entries            = new byte[clps_num][];

            gridCLPSData.ColumnCount      = 8;
            gridCLPSData.RowCount         = clps_num;
            gridCLPSData.Columns[0].Width = 32;
            uint entry = clps_addr + 0x08;

            // Set column widths
            for (int i = 0; i < 8; i++)
            {
                gridCLPSData.Columns[i].Width = 32;
            }

            DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();

            cmb.HeaderText = "Type/Description";
            cmb.Items.Add("Other/Unknown");
            cmb.Width = 160;
            foreach (string name in GLOBAL_CLPS_TYPES.GetFirstToSecond().Keys)
            {
                cmb.Items.Add(name);
            }
            gridCLPSData.Columns.Add(cmb);

            for (int i = 0; i < clps_num; i++)
            {
                gridCLPSData.Rows[i].HeaderCell.Value = "" + i;
                entries[i] = new byte[8];
                for (int j = 0; j < 8; j++)
                {
                    entries[i][j] = _owner.m_Overlay.Read8((uint)(entry + (j)));
                    gridCLPSData.Rows[i].Cells[j].Value = entries[i][j];
                }

                // Fill in Type/Description column
                if (GLOBAL_CLPS_TYPES.GetSecondToFirst().ContainsKey(entries[i]))
                {
                    gridCLPSData.Rows[i].Cells[8].Value = GLOBAL_CLPS_TYPES.GetSecondToFirst()[entries[i]];
                }
                else
                {
                    gridCLPSData.Rows[i].Cells[8].Value = cmb.Items[0];// Other/Unknown
                }
                entry += 8;
            }
        }
Ejemplo n.º 2
0
        private List <byte> EncodeString(String msg)
        {
            String newMsg = msg.Replace("[\\r]", "\r");

            char[]      newTextByte   = newMsg.ToCharArray();
            List <byte> encodedString = new List <byte>();

            int i = 0;

            while (i < newTextByte.Length)
            {
                /*
                 * // Upper
                 * // nintendo encoding = ('A' + cur - 0x0A);
                 * // ascii = A + ne - 0x0A
                 * // ascii - A + 0x0A = ne
                 * if (Char.IsNumber(newTextByte[i]))// Numeric
                 *  encodedString.Add((byte)(newTextByte[i] - '0'));
                 * else if (newTextByte[i] >= 0x41 && newTextByte[i] <= 0x5A)//Uppercase
                 *  encodedString.Add((byte)(newTextByte[i] - 'A' + 0x0A));
                 * else if (newTextByte[i] >= 0x61 && newTextByte[i] <= 0x7A)// Lowercase
                 *  encodedString.Add((byte)(newTextByte[i] - 'a' + 0x2D));
                 * else if (newTextByte[i] >= 0x80 && newTextByte[i] < (0xFF + 0x01))// Extended characters 128 to 255
                 *  encodedString.Add((byte)(newTextByte[i] - 0x30));// Character - offset of 0x30 to get Nintendo character*/

                if (langNames[langIndex] == "jpn")
                {
                    if (JAP_CHARS.GetSecondToFirst().ContainsKey("" + newTextByte[i]))
                    {
                        encodedString.Add(JAP_CHARS.GetBySecond("" + newTextByte[i]));
                    }
                }
                else
                {
                    if (BASIC_EUR_US_CHARS.GetSecondToFirst().ContainsKey("" + newTextByte[i]))
                    {
                        encodedString.Add(BASIC_EUR_US_CHARS.GetBySecond("" + newTextByte[i]));
                    }
                    else if (EXTENDED_ASCII_CHARS.GetSecondToFirst().ContainsKey("" + newTextByte[i]))
                    {
                        encodedString.Add(EXTENDED_ASCII_CHARS.GetBySecond("" + newTextByte[i]));
                    }
                }
                if (newTextByte[i].Equals('\r')) // New Line is \r\n
                {
                    i++;                         // Point after r
                    if (newTextByte[i].Equals('\n'))
                    {
                        encodedString.Add((byte)0xFD);
                        i++;
                        continue;
                    }
                    // 0xFE denotes special character
                    else if (newTextByte[i].Equals('F') && newTextByte[i + 1].Equals('E'))
                    {
                        //FE 05 03 00 06 - [R) glyph
                        //FE 07 01 00 00 00 XX - number of stars till you get XX
                        String byte2 = "" + newTextByte[i + 2] + newTextByte[i + 3];
                        int    len   = int.Parse(byte2, System.Globalization.NumberStyles.HexNumber);
                        for (int j = 0; j < (len * 2); j += 2)
                        {
                            String temp = "" + newTextByte[i + j] + newTextByte[i + j + 1];
                            encodedString.Add((byte)int.Parse(temp, System.Globalization.NumberStyles.HexNumber));
                        }
                        i += (len * 2);

                        continue;
                    }
                    else
                    {
                        // Special characters [\r]C [\r]S [\r]s [\r]D [\r]A [\r]B [\r]X [\r]Y

                        string specialChar = "[\\r]" + newTextByte[i];
                        uint   size        = 0;
                        byte   val         = 0xFF;

                        if (langNames[langIndex] == "jpn")
                        {
                            size = JAP_SIZES[specialChar];
                            val  = JAP_CHARS.GetBySecond(specialChar);
                        }
                        else
                        {
                            if (BASIC_EUR_US_SIZES.ContainsKey(specialChar))
                            {
                                size = BASIC_EUR_US_SIZES[specialChar];
                            }
                            else if (EXTENDED_ASCII_SIZES.ContainsKey(specialChar))
                            {
                                size = EXTENDED_ASCII_SIZES[specialChar];
                            }

                            if (BASIC_EUR_US_CHARS.GetSecondToFirst().ContainsKey(specialChar))
                            {
                                val = BASIC_EUR_US_CHARS.GetBySecond(specialChar);
                            }
                            else if (EXTENDED_ASCII_CHARS.GetSecondToFirst().ContainsKey(specialChar))
                            {
                                val = EXTENDED_ASCII_CHARS.GetBySecond(specialChar);
                            }
                        }

                        for (int j = 0; j < size; j++)
                        {
                            encodedString.Add((byte)(val + j));
                        }

                        i++;
                        continue;
                    }
                }
                i++;
            }

            encodedString.Add(0xFF);// End of message

            return(encodedString);
        }