Skip to content

Commit

Permalink
Merge pull request #1058 from cassidoxa/v31.2.0-fixes
Browse files Browse the repository at this point in the history
Fix permalink heart color patching
  • Loading branch information
sporchia authored Aug 31, 2023
2 parents 346d08f + d2022fc commit 67dbf22
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 57 deletions.
4 changes: 2 additions & 2 deletions app/Rom.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
class Rom
{
const BUILD = '2023-08-22';
const HASH = 'bdb7e2398eab6003577307763fd40128';
const BUILD = '2023-08-30';
const HASH = '69f5f851d43590d3e84208e3820abdc7';
const SIZE = 2097152;

private $tmp_file;
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"source": {
"url": "https://github.com/KatDevsGames/z3randomizer",
"type": "git",
"reference": "4c98268d812e7546e247b79aac8f2df077c9e209"
"reference": "29176fa1946150784705f34d5b7641f81eda1dd0"
}
}
},
Expand Down Expand Up @@ -83,7 +83,7 @@
"source": {
"url": "https://github.com/cassidoxa/ALttPEntranceRandomizer",
"type": "git",
"reference": "408e9c2fc6400ddfcbdbd5c701782a3e64f79adb"
"reference": "eeba10fd8b9ca0f10e943a1bbe25505b67cf6064"
}
}
}
Expand Down
54 changes: 27 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 60 additions & 26 deletions resources/js/rom.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,37 +355,71 @@ export default class ROM {

setHeartColor(color_on) {
return new Promise(resolve => {
let byte = 0x24;
let file_byte = 0x05;

if (color_on === "random") {
const colorOptions = ["blue", "green", "yellow", "red"];
color_on = colorOptions[Math.floor(Math.random() * colorOptions.length)];
};

switch (color_on) {
case "blue":
byte = 0x01;

break;
case "green":
byte = 0x02;

break;
case "yellow":
byte = 0x03;
// Check ROM major version or for vanilla 0xFF value
let version = new Uint8Array(this.arrayBuffer)[0x7FE2];
if (version <= 0x03 || version == 0xFF) {
let byte = 0x24;
let file_byte = 0x05;

if (color_on === "random") {
const colorOptions = ["blue", "green", "yellow", "red"];
color_on = colorOptions[Math.floor(Math.random() * colorOptions.length)];
};

switch (color_on) {
case "blue":
byte = 0x2c;
file_byte = 0x0d;
break;
case "green":
byte = 0x3c;
file_byte = 0x19;
break;
case "yellow":
byte = 0x28;
file_byte = 0x09;
break;
case "red":
default:
// do nothing
}

break;
case "red":
byte = 0x00;
this.write(0x6fa1e, byte);
this.write(0x6fa20, byte);
this.write(0x6fa22, byte);
this.write(0x6fa24, byte);
this.write(0x6fa26, byte);
this.write(0x6fa28, byte);
this.write(0x6fa2a, byte);
this.write(0x6fa2c, byte);
this.write(0x6fa2e, byte);
this.write(0x6fa30, byte);
this.write(0x65561, file_byte);
} else {
if (color_on === "random") {
const colorOptions = ["blue", "green", "yellow", "red"];
color_on = colorOptions[Math.floor(Math.random() * colorOptions.length)];
};
let byte = 0x00;

switch (color_on) {
case "blue":
byte = 0x01;
break;
case "green":
byte = 0x02;
break;
case "yellow":
byte = 0x03;
break;
case "red":
default:
}

break;
default:
// do nothing
this.write(0x187020, byte);
}

this.write(0x187020, byte);

resolve(this);
});
}
Expand Down

0 comments on commit 67dbf22

Please sign in to comment.