diff --git a/Plugins/DSDecmp/DSDecmp/Formats/LZOvl.cs b/Plugins/DSDecmp/DSDecmp/Formats/LZOvl.cs
index 688a746..4e36962 100644
--- a/Plugins/DSDecmp/DSDecmp/Formats/LZOvl.cs
+++ b/Plugins/DSDecmp/DSDecmp/Formats/LZOvl.cs
@@ -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++;
diff --git a/Tinke/Dialog/SaveOptions.Designer.cs b/Tinke/Dialog/SaveOptions.Designer.cs
index d38bfe0..a333b7f 100644
--- a/Tinke/Dialog/SaveOptions.Designer.cs
+++ b/Tinke/Dialog/SaveOptions.Designer.cs
@@ -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;
}
}
diff --git a/Tinke/Dialog/SaveOptions.cs b/Tinke/Dialog/SaveOptions.cs
index d46ca67..56ecf0b 100644
--- a/Tinke/Dialog/SaveOptions.cs
+++ b/Tinke/Dialog/SaveOptions.cs
@@ -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();
diff --git a/Tinke/Sistema.cs b/Tinke/Sistema.cs
index 0c06db4..6a7d427 100644
--- a/Tinke/Sistema.cs
+++ b/Tinke/Sistema.cs
@@ -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();
diff --git a/Tinke/Tools/ARM9BLZ.cs b/Tinke/Tools/ARM9BLZ.cs
index 6fb2eed..6253b0c 100644
--- a/Tinke/Tools/ARM9BLZ.cs
+++ b/Tinke/Tools/ARM9BLZ.cs
@@ -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);
diff --git a/Tinke/langs/en-us.xml b/Tinke/langs/en-us.xml
index 2fccd25..d271ffa 100644
--- a/Tinke/langs/en-us.xml
+++ b/Tinke/langs/en-us.xml
@@ -427,6 +427,7 @@
Keep Original RSA SHA1 Signature
Recompress ARM9 binary (BLZ)
Better compress method (BLZ-Cue)
+ Is FlashCart Firmware
File
diff --git a/Tinke/langs/es-es.xml b/Tinke/langs/es-es.xml
index 8e88300..7c38313 100644
--- a/Tinke/langs/es-es.xml
+++ b/Tinke/langs/es-es.xml
@@ -431,6 +431,7 @@
Keep Original RSA SHA1 Signature
Recompress ARM9 binary (BLZ)
Better compress method (BLZ-Cue)
+ Is FlashCart Firmware
Archivo
diff --git a/Tinke/langs/fr-fr.xml b/Tinke/langs/fr-fr.xml
index c449685..7587d76 100644
--- a/Tinke/langs/fr-fr.xml
+++ b/Tinke/langs/fr-fr.xml
@@ -427,6 +427,7 @@
Keep Original RSA SHA1 Signature
Recompress ARM9 binary (BLZ)
Better compress method (BLZ-Cue)
+ Is FlashCart Firmware
Archive
diff --git a/Tinke/langs/it-it.xml b/Tinke/langs/it-it.xml
index b591a43..7a9b509 100644
--- a/Tinke/langs/it-it.xml
+++ b/Tinke/langs/it-it.xml
@@ -426,6 +426,7 @@
Keep Original RSA SHA1 Signature
Recompress ARM9 binary (BLZ)
Better compress method (BLZ-Cue)
+ Is FlashCart Firmware
File
diff --git a/Tinke/langs/zh-hans.xml b/Tinke/langs/zh-hans.xml
index 0e79d24..e7cc24c 100644
--- a/Tinke/langs/zh-hans.xml
+++ b/Tinke/langs/zh-hans.xml
@@ -424,6 +424,7 @@
保持原始的 RSA SHA1 签名
重压缩 ARM9 文件 (BLZ 算法)
更好的压缩率算法 (BLZ-Cue)
+ 处理烧录卡固件
文件