mirror of
https://github.com/marcrobledo/RomPatcher.js.git
synced 2025-06-27 16:25:54 +00:00
new features explained
parent
6b3eb8f688
commit
7aee9c413f
1 changed files with 49 additions and 7 deletions
|
@ -20,7 +20,8 @@ Take a look at [`index_template.html`](https://github.com/marcrobledo/RomPatcher
|
||||||
window.addEventListener('load', function(){
|
window.addEventListener('load', function(){
|
||||||
const myPatcherSettings={
|
const myPatcherSettings={
|
||||||
language: 'en',
|
language: 'en',
|
||||||
allowDropFiles: false /* if true, it adds drag and drop support,*/
|
requireValidation: false, /* if true, user won't be able to apply patch if the provided ROM is not valid*/
|
||||||
|
allowDropFiles: false /* if true, it adds basic drag and drop support */
|
||||||
};
|
};
|
||||||
RomPatcherWeb.initialize(myPatcherSettings, 'my_patch.ips');
|
RomPatcherWeb.initialize(myPatcherSettings, 'my_patch.ips');
|
||||||
});
|
});
|
||||||
|
@ -64,6 +65,31 @@ RomPatcherWeb.initialize(myPatcherSettings, {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
You can define some patches as optional. They won't appear in the select dropdown but as checkboxes. User will be able to choose and combine several patches.
|
||||||
|
```js
|
||||||
|
RomPatcherWeb.initialize(myPatcherSettings, {
|
||||||
|
file: 'my_patches.zip', //zip containing patches
|
||||||
|
patches: [ //information about patches inside the zip
|
||||||
|
{
|
||||||
|
file: 'my_main_patch.ips', //required
|
||||||
|
name: 'My game improvement hack (Base)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: 'my_optional_patch_1.ips',
|
||||||
|
name: 'Alternate colors',
|
||||||
|
description: 'Check this to change main characters\' colors',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: 'my_optional_patch_2.ips',
|
||||||
|
name: 'Hard mode',
|
||||||
|
description: 'Check this to alter game\'s difficulty',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
/* ... */
|
||||||
|
]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,22 +99,25 @@ If you want to go further, you can run your own code via events:
|
||||||
const myPatcherSettings={
|
const myPatcherSettings={
|
||||||
language: 'en',
|
language: 'en',
|
||||||
|
|
||||||
|
oninitialize: function (romFile) {
|
||||||
|
/* triggered when Rom Patcher JS has been initialized */
|
||||||
|
},
|
||||||
onloadrom: function (romFile) {
|
onloadrom: function (romFile) {
|
||||||
/* this event is triggered when user provides a ROM and before validating it */
|
/* triggered when user provides a ROM and before validating it */
|
||||||
/* can be used to: */
|
/* can be used to: */
|
||||||
/* - modify it before validation (e.g. add/remove/fix header, change endianness...) */
|
/* - modify it before validation (e.g. add/remove/fix header, change endianness...) */
|
||||||
/* - to switch to another patch file in the dropdown selector */
|
/* - to switch to another patch file in the dropdown selector */
|
||||||
},
|
},
|
||||||
onvalidaterom: function (romFile, isRomValid) {
|
onvalidaterom: function (romFile, isRomValid) {
|
||||||
/* this event is triggered after ROM is validated */
|
/* triggered after ROM is validated */
|
||||||
/* can be used to show a custom error message if provided ROM is not valid */
|
/* can be used to show a custom error message if provided ROM is not valid */
|
||||||
},
|
},
|
||||||
onloadpatch: function (patchFile, embededPatchInformation) {
|
onloadpatch: function (patchFile, embededPatchInformation) {
|
||||||
/* this event is triggered when user selects a patch from the dropdown */
|
/* triggered when user selects a patch from the dropdown */
|
||||||
/* can be used to toggle HTML elements in your site depending on the selected patch */
|
/* can be used to toggle HTML elements in your site depending on the selected patch */
|
||||||
},
|
},
|
||||||
onpatch: function (romFile) {
|
onpatch: function (romFile) {
|
||||||
/* this event is triggered a ROM is patched */
|
/* triggered a ROM is patched */
|
||||||
/* can be used to modify it before the patched ROM file is saved */
|
/* can be used to modify it before the patched ROM file is saved */
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -143,7 +172,7 @@ If your zip file contains several patches for different ROMs, you can make Rom P
|
||||||
```js
|
```js
|
||||||
const SML2_CHECKSUM_WORLD = 0xd5ec24e4;
|
const SML2_CHECKSUM_WORLD = 0xd5ec24e4;
|
||||||
const SML2_CHECKSUM_JAPAN = 0xa715daf5;
|
const SML2_CHECKSUM_JAPAN = 0xa715daf5;
|
||||||
const SML2_CHECKSUMS_INVALID = [0xe6f886e5, 0x635a9112, 0xbf733e10, 0x29e0911a];
|
const SML2_CHECKSUMS_INVALID = [0xe6f886e5, 0x635a9112, 0xbf733e10, 0x29e0911a]; /* incompatible SML2 revisions */
|
||||||
|
|
||||||
RomPatcher.initialize(
|
RomPatcher.initialize(
|
||||||
{
|
{
|
||||||
|
@ -158,7 +187,7 @@ If your zip file contains several patches for different ROMs, you can make Rom P
|
||||||
},
|
},
|
||||||
onvalidaterom: function (romFile, isRomValid) {
|
onvalidaterom: function (romFile, isRomValid) {
|
||||||
const crc32 = romFile.hashCRC32();
|
const crc32 = romFile.hashCRC32();
|
||||||
/* if ROM is a known SML2 revision that is not compatible with the patch*/
|
/* if ROM is a known SML2 revision that is not compatible with the patch */
|
||||||
if (!isRomValid && SML2_CHECKSUMS_INVALID.indexOf(crc32) !== -1)
|
if (!isRomValid && SML2_CHECKSUMS_INVALID.indexOf(crc32) !== -1)
|
||||||
RomPatcherWeb.setErrorMessage('Please provide a v1.0 SML2 ROM');
|
RomPatcherWeb.setErrorMessage('Please provide a v1.0 SML2 ROM');
|
||||||
}
|
}
|
||||||
|
@ -241,3 +270,16 @@ By detecting which patch the user selected, you can do cool things in your site
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Example: Change embeded patches
|
||||||
|
You can reset the embeded patches easily, so you could offer a Rom Patcher JS compatible with different games.
|
||||||
|
```js
|
||||||
|
RomPatcher.setEmbededPatches({
|
||||||
|
file: 'other_patches.zip',
|
||||||
|
name: 'Other patches',
|
||||||
|
patches: [
|
||||||
|
/* ... */
|
||||||
|
]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue