mirror of
https://github.com/marcrobledo/RomPatcher.js.git
synced 2025-06-27 16:25:54 +00:00
fix for IPS: can expand target ROM now if truncate flag is bigger than source ROM
This commit is contained in:
parent
e81b3d821b
commit
af60e80985
1 changed files with 8 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* IPS module for Rom Patcher JS v20200502 - Marc Robledo 2016-2020 - http://www.marcrobledo.com/license */
|
/* IPS module for Rom Patcher JS v20220417 - Marc Robledo 2016-2022 - http://www.marcrobledo.com/license */
|
||||||
/* File format specification: http://www.smwiki.net/wiki/IPS_file_format */
|
/* File format specification: http://www.smwiki.net/wiki/IPS_file_format */
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,9 +71,14 @@ IPS.prototype.export=function(fileName){
|
||||||
}
|
}
|
||||||
IPS.prototype.apply=function(romFile){
|
IPS.prototype.apply=function(romFile){
|
||||||
if(this.truncate){
|
if(this.truncate){
|
||||||
tempFile=romFile.slice(0, this.truncate);
|
if(this.truncate>romFile.fileSize){ //expand (discussed here: https://github.com/marcrobledo/RomPatcher.js/pull/46)
|
||||||
|
tempFile=new MarcFile(this.truncate);
|
||||||
|
romFile.copyToFile(tempFile, 0, romFile.fileSize, 0);
|
||||||
|
}else{ //truncate
|
||||||
|
tempFile=romFile.slice(0, this.truncate);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
|
//calculate target ROM size, expanding it if any record offset is beyond target ROM size
|
||||||
var newFileSize=romFile.fileSize;
|
var newFileSize=romFile.fileSize;
|
||||||
for(var i=0; i<this.records.length; i++){
|
for(var i=0; i<this.records.length; i++){
|
||||||
var rec=this.records[i];
|
var rec=this.records[i];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue