0
0
mirror of https://github.com/marcrobledo/savegame-editors.git synced 2025-04-28 09:05:10 +00:00
2017-07-07 00:04:20 +02:00

44 lines
1.2 KiB
JavaScript

/*
Pokémon Picross for HTML5 Save Editor v20170706
by Marc Robledo 2016-2017
*/
SavegameEditor={
Name:'Pokémon Picross',
Filename:'all.dat',
Offsets:{
PICRITES:0x0b40,
BOUGHTPICRITES:0x0b44,
PENDINGPICRITES:0x0b48, /* if there is an error after buying, they are queued here */
UNLOCKEDSHOPFLAG:0x0b4c,
},
/* check if savegame is valid */
checkValidSavegame:function(){
return (tempFile.fileSize==14920)
},
/* preload function */
preload:function(){
setNumericRange('picrites', 0, 9999);
setNumericRange('boughtpicrites', 0, 5000);
},
/* load function */
load:function(){
tempFile.fileName='all.dat';
setValue('picrites', tempFile.readShort(this.Offsets.PICRITES));
setValue('boughtpicrites', tempFile.readShort(this.Offsets.BOUGHTPICRITES));
},
/* save function */
save:function(){
tempFile.writeShort(this.Offsets.PICRITES, getValue('picrites'));
var boughtPicrites=getValue('boughtpicrites');
tempFile.writeShort(this.Offsets.BOUGHTPICRITES, boughtPicrites);
var unlockedShopByte=tempFile.readByte(this.Offsets.UNLOCKEDSHOPFLAG) & ~0x01;
tempFile.writeByte(this.Offsets.UNLOCKEDSHOPFLAG, unlockedShopByte+(boughtPicrites>=5000)?0x01:0x00);
}
}