Esempio n. 1
0
        private void PopulateMakerId()
        {
            // Maker Code
            FileStream fileStream = new FileStream(@path, FileMode.Open, FileAccess.Read);

            fileStream.Seek(4, SeekOrigin.Begin);   // Seek to 4 (5th) byte in the file

            string makerCode = "";

            int x = 0;

            while (x < 2)
            {
                string makerId     = fileStream.ReadByte().ToString("X");
                string makerIdChar = "";

                while (makerId.Length > 0)
                {
                    // Use ToChar() to convert each hex byte to char
                    makerIdChar += System.Convert.ToChar(System.Convert.ToUInt32(makerId.Substring(0, 2), 16)).ToString();
                    // Remove from the hex object the converted value
                    makerId = makerId.Substring(2, makerId.Length - 2);
                }
                makerIDAsciiTextBox.Text += makerIdChar;

                makerCode += makerIdChar;
                x++;
            }
            fileStream.Close();

            WiiDiscData wiiDiscData = new WiiDiscData();

            wiiDiscData.GetMakerByMakerCode(makerCode);
            makerIDTextBox.Text = wiiDiscData.GetMakerByMakerCode(makerCode);
        }
Esempio n. 2
0
        private void LoadWadfile()
        {
            //1.get wad game code (offset 3728, 4 bytes)
            string gcComplete   = "";
            string gcFirstThree = "";
            string gcLastOne    = "";
            int    x            = 0;
            //gonna need a try/catch here in case the file is in use
            FileStream fileStream = new FileStream(@path2, FileMode.Open, FileAccess.Read);

            fileStream.Seek(3728, SeekOrigin.Begin);   // Seek to 3728th byte in the file

            while (x < 4)
            {
                string gc = fileStream.ReadByte().ToString("X");
                //if length is single digit add a 0 ( 1 now is 01)
                if (gc.Length == 1)
                {
                    gc = "0" + gc;
                }

                //convert the hex to ascii
                char gcAscii = (char)Int32.Parse(gc, NumberStyles.AllowHexSpecifier);

                gcComplete += gcAscii;
                if (x < 3)
                {
                    //so we can just get the first 3 for identification below
                    gcFirstThree += gcAscii;
                }
                if (x > 2)
                {
                    gcLastOne += gcAscii;
                }
                x += 1;
            }

            fileStream.Close();

            gamecodeTextBox.Text = gcComplete;
            try
            {
                gameNameTextBox.Text = WSFConstants.WadGamesDictionary[gcFirstThree];
                platformTextBox.Text = WSFConstants.WadMakerCodesDictionary[gcFirstThree];
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                //throw;
            }


            //3.get maker code (offset 3736, 2 bytes, ascii)
            x = 0;
            string mcComplete = "";

            fileStream = new FileStream(@path2, FileMode.Open, FileAccess.Read);
            fileStream.Seek(3736, SeekOrigin.Begin);   // Seek to 3736th byte in the file

            while (x < 2)
            {
                string mc = fileStream.ReadByte().ToString("X");
                //if length is single digit add a 0 ( 1 now is 01)
                if (mc.Length == 1)
                {
                    mc = "0" + mc;
                }

                //convert the hex to ascii
                char mcAscii = (char)Int32.Parse(mc, NumberStyles.AllowHexSpecifier);

                mcComplete += mcAscii;

                x += 1;
            }
            fileStream.Close();


            makerCodeTextBox.Text = mcComplete;

            WiiDiscData wiiDiscData = new WiiDiscData();

            wiiDiscData.GetMakerByMakerCode(mcComplete);
            makerCodeCoTextBox.Text = wiiDiscData.GetMakerByMakerCode(mcComplete);


            //4.get region string (offset 3741, 16 bytes)
            x = 0;
            string rsComplete = "";

            fileStream = new FileStream(@path2, FileMode.Open, FileAccess.Read);
            fileStream.Seek(3742, SeekOrigin.Begin);   // Seek to 3742th byte in the file

            while (x < 16)
            {
                string rs = fileStream.ReadByte().ToString("X");
                //if length is single digit add a 0 ( 1 now is 01)
                if (rs.Length == 1)
                {
                    rs = "0" + rs;
                }

                //convert the hex to ascii
                //char mc_ascii = (char)Int32.Parse(mc, NumberStyles.AllowHexSpecifier);

                rsComplete += rs + " ";

                x += 1;
            }
            fileStream.Close();


            regionStringTextBox.Text = rsComplete;

            //5.get region code (offset 3804, 2 bytes)
            x = 0;
            string rcComplete = "";

            fileStream = new FileStream(@path2, FileMode.Open, FileAccess.Read);
            fileStream.Seek(3804, SeekOrigin.Begin);   // Seek to 3804th byte in the file

            while (x < 2)
            {
                string rc = fileStream.ReadByte().ToString("X");
                //if length is single digit add a 0 ( 1 now is 01)
                if (rc.Length == 1)
                {
                    rc = "0" + rc;
                }


                rcComplete += rc;

                x += 1;
            }
            fileStream.Close();

            switch (rcComplete)
            {
            case "0000":
                rcComplete = "0000 [JAP]";
                break;

            case "0001":
                rcComplete = "0001 [USA]";
                break;

            case "0002":
                rcComplete = "0002 [PAL]";
                break;

            case "0003":
                rcComplete = "0003 [Region Free]";
                break;

            default:
                rcComplete = "???? [Unknown Region]";
                break;
            }

            regionCodeTextBox.Text = rcComplete;
        }