mirror of
https://github.com/marcrobledo/RomPatcher.js.git
synced 2025-06-27 16:25:54 +00:00
added Byte Flipper module
This commit is contained in:
parent
ac73b92873
commit
ca220a0161
2 changed files with 26 additions and 0 deletions
26
ByteFlipper.js
Normal file
26
ByteFlipper.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* ByteFlipper.js v20170717 - Marc Robledo 2013-2017 - http://www.marcrobledo.com/license */
|
||||||
|
function flipFile(){
|
||||||
|
var type=el('radio8').checked?8:4;
|
||||||
|
if(tempFile.fileSize>MAX_ROM_SIZE){
|
||||||
|
MarcDialogs.alert('Too big file');
|
||||||
|
return false;
|
||||||
|
}else if(tempFile.fileSize%type!==0){
|
||||||
|
MarcDialogs.alert('File is not divisible by '+type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tempFile2=new MarcBinFile(tempFile.fileSize);
|
||||||
|
var offset=0;
|
||||||
|
for(var i=0; i<tempFile.fileSize; i+=type){
|
||||||
|
tempFile2.writeBytes(offset, tempFile.readBytes(offset, type).reverse());
|
||||||
|
offset+=type;
|
||||||
|
}
|
||||||
|
tempFile2.fileName=tempFile.fileName.replace(/\.(.*?)$/, ' (byteflipped).$1');
|
||||||
|
tempFile2.save();
|
||||||
|
}
|
||||||
|
function flipBytesInFile(){
|
||||||
|
if(el('input-file-flip').files.length)
|
||||||
|
tempFile=new MarcBinFile(el('input-file-flip'), flipFile);
|
||||||
|
else
|
||||||
|
MarcDialogs.alert('No file selected');
|
||||||
|
}
|
BIN
RomPatcher.png
BIN
RomPatcher.png
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
Loading…
Add table
Add a link
Reference in a new issue