mirror of
https://github.com/R-YaTian/TinkeDSi.git
synced 2025-06-18 16:45:43 -04:00
Add a save option to parse the header of flashcart firmware
This commit is contained in:
parent
a39ebedf66
commit
ed336a23b6
@ -206,7 +206,8 @@ namespace DSDecmp.Formats
|
||||
{
|
||||
if (readBytes >= compressedSize)
|
||||
throw new NotEnoughDataException(currentOutSize, decompressedLength);
|
||||
flags = buffer[buffer.Length - 1 - readBytes]; readBytes++;
|
||||
flags = buffer[buffer.Length - 1 - readBytes];
|
||||
readBytes++;
|
||||
mask = 0x80;
|
||||
}
|
||||
else
|
||||
@ -225,8 +226,15 @@ namespace DSDecmp.Formats
|
||||
{
|
||||
throw new NotEnoughDataException(currentOutSize, decompressedLength);
|
||||
}
|
||||
int byte1 = buffer[compressedSize - 1 - readBytes]; readBytes++;
|
||||
int byte2 = buffer[compressedSize - 1 - readBytes]; readBytes++;
|
||||
int byte1 = buffer[compressedSize - 1 - readBytes];
|
||||
readBytes++;
|
||||
|
||||
if (readBytes == compressedSize)
|
||||
{
|
||||
throw new NotEnoughDataException(currentOutSize, decompressedLength);
|
||||
}
|
||||
int byte2 = buffer[compressedSize - 1 - readBytes];
|
||||
readBytes++;
|
||||
|
||||
// the number of bytes to copy
|
||||
int length = byte1 >> 4;
|
||||
@ -261,7 +269,8 @@ namespace DSDecmp.Formats
|
||||
{
|
||||
if (readBytes >= inLength)
|
||||
throw new NotEnoughDataException(currentOutSize, decompressedLength);
|
||||
byte next = buffer[buffer.Length - 1 - readBytes]; readBytes++;
|
||||
byte next = buffer[buffer.Length - 1 - readBytes];
|
||||
readBytes++;
|
||||
|
||||
outbuffer[outbuffer.Length - 1 - currentOutSize] = next;
|
||||
currentOutSize++;
|
||||
|
19
Tinke/Dialog/SaveOptions.Designer.cs
generated
19
Tinke/Dialog/SaveOptions.Designer.cs
generated
@ -34,6 +34,7 @@
|
||||
this.btn_Cancel = new System.Windows.Forms.Button();
|
||||
this.checkBox3 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox4 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox5 = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkBox1
|
||||
@ -60,7 +61,7 @@
|
||||
//
|
||||
this.btn_OK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btn_OK.Image = global::Tinke.Properties.Resources.accept;
|
||||
this.btn_OK.Location = new System.Drawing.Point(12, 112);
|
||||
this.btn_OK.Location = new System.Drawing.Point(12, 139);
|
||||
this.btn_OK.Name = "btn_OK";
|
||||
this.btn_OK.Size = new System.Drawing.Size(90, 30);
|
||||
this.btn_OK.TabIndex = 3;
|
||||
@ -73,7 +74,7 @@
|
||||
//
|
||||
this.btn_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btn_Cancel.Image = global::Tinke.Properties.Resources.cancel;
|
||||
this.btn_Cancel.Location = new System.Drawing.Point(137, 112);
|
||||
this.btn_Cancel.Location = new System.Drawing.Point(137, 139);
|
||||
this.btn_Cancel.Name = "btn_Cancel";
|
||||
this.btn_Cancel.Size = new System.Drawing.Size(90, 30);
|
||||
this.btn_Cancel.TabIndex = 4;
|
||||
@ -104,10 +105,21 @@
|
||||
this.checkBox4.Text = "S21";
|
||||
this.checkBox4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox5
|
||||
//
|
||||
this.checkBox5.AutoSize = true;
|
||||
this.checkBox5.Location = new System.Drawing.Point(12, 112);
|
||||
this.checkBox5.Name = "checkBox5";
|
||||
this.checkBox5.Size = new System.Drawing.Size(53, 19);
|
||||
this.checkBox5.TabIndex = 7;
|
||||
this.checkBox5.Text = "S22";
|
||||
this.checkBox5.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SaveOptions
|
||||
//
|
||||
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
this.ClientSize = new System.Drawing.Size(239, 154);
|
||||
this.ClientSize = new System.Drawing.Size(239, 181);
|
||||
this.Controls.Add(this.checkBox5);
|
||||
this.Controls.Add(this.checkBox4);
|
||||
this.Controls.Add(this.checkBox3);
|
||||
this.Controls.Add(this.btn_Cancel);
|
||||
@ -135,5 +147,6 @@
|
||||
private System.Windows.Forms.Button btn_Cancel;
|
||||
private System.Windows.Forms.CheckBox checkBox3;
|
||||
private System.Windows.Forms.CheckBox checkBox4;
|
||||
private System.Windows.Forms.CheckBox checkBox5;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace Tinke.Dialog
|
||||
checkBox2.Text = xml.Element("S1F").Value;
|
||||
checkBox3.Text = xml.Element("S20").Value;
|
||||
checkBox4.Text = xml.Element("S21").Value;
|
||||
checkBox5.Text = xml.Element("S22").Value;
|
||||
}
|
||||
catch { throw new NotImplementedException("There was an error reading the language file"); }
|
||||
}
|
||||
@ -48,6 +49,11 @@ namespace Tinke.Dialog
|
||||
get { return checkBox4.Checked; }
|
||||
}
|
||||
|
||||
public bool IsFlashCartFirmware
|
||||
{
|
||||
get { return checkBox5.Checked; }
|
||||
}
|
||||
|
||||
private void btn_OK_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
|
@ -1501,6 +1501,7 @@ namespace Tinke
|
||||
bool keep_original = false;
|
||||
bool a9_recomp = false;
|
||||
bool a9_bestcomp = false;
|
||||
bool bIsFlashCartFW = false;
|
||||
Nitro.Estructuras.ROMHeader header = romInfo.Cabecera;
|
||||
|
||||
Dialog.SaveOptions dialog = new Dialog.SaveOptions();
|
||||
@ -1514,6 +1515,8 @@ namespace Tinke
|
||||
a9_recomp = true;
|
||||
if (dialog.IsBetterCompress)
|
||||
a9_bestcomp = true;
|
||||
if (dialog.IsFlashCartFirmware)
|
||||
bIsFlashCartFW = true;
|
||||
|
||||
Thread create = new Thread(ThreadEspera)
|
||||
{
|
||||
@ -1588,7 +1591,7 @@ namespace Tinke
|
||||
}
|
||||
|
||||
// Calc Secure Area CRC
|
||||
if (header.ARM9romOffset == 0x4000 && header.ARM9size >= 0x4000)
|
||||
if (header.ARM9romOffset == 0x4000 && header.ARM9size >= 0x4000 && !bIsFlashCartFW)
|
||||
{
|
||||
Array.Copy(arm9Data, 0x800, this.secureArea.EncryptedData, 0x800, 0x3800);
|
||||
header.secureCRC16 = SecureArea.CalcCRC(this.secureArea.EncryptedData, gameCode);
|
||||
@ -1792,7 +1795,8 @@ namespace Tinke
|
||||
Nitro.FAT.Write(fileFAT, accion.Root, header.FAToffset, accion.SortedIDs, arm9overlayOffset, arm7overlayOffset, header);
|
||||
currPos += (uint)new FileInfo(fileFAT).Length;
|
||||
|
||||
header.bannerOffset = currPos;
|
||||
if (!bIsFlashCartFW)
|
||||
header.bannerOffset = currPos;
|
||||
currPos += (uint)new FileInfo(banner).Length;
|
||||
|
||||
// Escribimos los archivos
|
||||
@ -1801,7 +1805,8 @@ namespace Tinke
|
||||
currPos += (uint)new FileInfo(files).Length;
|
||||
|
||||
// Update the ROM size values of the header
|
||||
header.ROMsize = currPos;
|
||||
if (!bIsFlashCartFW)
|
||||
header.ROMsize = currPos;
|
||||
|
||||
// Update DSi staff header info
|
||||
if (this.twl != null && (header.unitCode & 2) > 0)
|
||||
@ -1898,10 +1903,13 @@ namespace Tinke
|
||||
hmac.Dispose();
|
||||
}
|
||||
|
||||
header.tamaño = (uint)Math.Ceiling(Math.Log(currPos, 2));
|
||||
// Ref. to TWL SDK' "Card Manual" for DSi Cartrige ROMs
|
||||
if ((header.unitCode & 2) > 0 && (header.tid_high & 0xF) == 0 && header.tamaño < 25) header.tamaño = 25;
|
||||
header.tamaño = (uint)Math.Pow(2, header.tamaño);
|
||||
if (!bIsFlashCartFW)
|
||||
{
|
||||
header.tamaño = (uint)Math.Ceiling(Math.Log(currPos, 2));
|
||||
// Ref. to TWL SDK' "Card Manual" for DSi Cartrige ROMs
|
||||
if ((header.unitCode & 2) > 0 && (header.tid_high & 0xF) == 0 && header.tamaño < 25) header.tamaño = 25;
|
||||
header.tamaño = (uint)Math.Pow(2, header.tamaño);
|
||||
}
|
||||
|
||||
// Get Header CRC
|
||||
string tempHeader = Path.GetTempFileName();
|
||||
|
@ -35,7 +35,7 @@ namespace Tinke.Tools
|
||||
hdrptr = hdr.ARM9ramAddress + hdr.ARM9size;
|
||||
}
|
||||
uint postSize = (uint)arm9Data.Length - (hdrptr - hdr.ARM9ramAddress);
|
||||
bool cmparm9 = hdrptr > hdr.ARM9ramAddress && hdrptr + nitrocode_length >= hdr.ARM9ramAddress + arm9Data.Length;
|
||||
bool cmparm9 = hdrptr > hdr.ARM9ramAddress && hdrptr + nitrocode_length > hdr.ARM9ramAddress + arm9Data.Length;
|
||||
if (cmparm9)
|
||||
{
|
||||
Stream input = new MemoryStream(arm9Data);
|
||||
|
@ -427,6 +427,7 @@
|
||||
<S1F>Keep Original RSA SHA1 Signature</S1F>
|
||||
<S20>Recompress ARM9 binary (BLZ)</S20>
|
||||
<S21>Better compress method (BLZ-Cue)</S21>
|
||||
<S22>Is FlashCart Firmware</S22>
|
||||
</Dialog>
|
||||
<VisorHex>
|
||||
<S00>File</S00>
|
||||
|
@ -431,6 +431,7 @@
|
||||
<S1F>Keep Original RSA SHA1 Signature</S1F>
|
||||
<S20>Recompress ARM9 binary (BLZ)</S20>
|
||||
<S21>Better compress method (BLZ-Cue)</S21>
|
||||
<S22>Is FlashCart Firmware</S22>
|
||||
</Dialog>
|
||||
<VisorHex>
|
||||
<S00>Archivo</S00>
|
||||
|
@ -427,6 +427,7 @@
|
||||
<S1F>Keep Original RSA SHA1 Signature</S1F>
|
||||
<S20>Recompress ARM9 binary (BLZ)</S20>
|
||||
<S21>Better compress method (BLZ-Cue)</S21>
|
||||
<S22>Is FlashCart Firmware</S22>
|
||||
</Dialog>
|
||||
<VisorHex>
|
||||
<S00>Archive</S00>
|
||||
|
@ -426,6 +426,7 @@
|
||||
<S1F>Keep Original RSA SHA1 Signature</S1F>
|
||||
<S20>Recompress ARM9 binary (BLZ)</S20>
|
||||
<S21>Better compress method (BLZ-Cue)</S21>
|
||||
<S22>Is FlashCart Firmware</S22>
|
||||
</Dialog>
|
||||
<VisorHex>
|
||||
<S00>File</S00>
|
||||
|
@ -424,6 +424,7 @@
|
||||
<S1F>保持原始的 RSA SHA1 签名</S1F>
|
||||
<S20>重压缩 ARM9 文件 (BLZ 算法)</S20>
|
||||
<S21>更好的压缩率算法 (BLZ-Cue)</S21>
|
||||
<S22>处理烧录卡固件</S22>
|
||||
</Dialog>
|
||||
<VisorHex>
|
||||
<S00>文件</S00>
|
||||
|
Loading…
Reference in New Issue
Block a user