-- Majora's Mask (U): Love Costs Money
-- by Jimmie1717
-- BizHawk 1.11.8.2
-- This will only work with the NTSC-U version of the game.
console.clear();
readByte = memory.read_u8;
readWord = memory.read_u16_be;
readSWord = memory.read_s16_be;
readDWord = memory.read_u32_be;
readFloat = memory.readfloat;
writeByte = memory.write_u8;
writeWord = memory.write_u16_be;
writeSWord = memory.write_s16_be;
writeDWord = memory.write_u32_be;
writeFloat = memory.writefloat;
drawText = gui.drawText;
local counter = 0;
local counter2 = 0;
local text = {
[0] = 0x01,
[1] = 0x48,
[2] = 0x65,
[3] = 0x61,
[4] = 0x72,
[5] = 0x74,
[6] = 0x20,
[7] = 0x43,
[8] = 0x6F,
[9] = 0x6E,
[10] = 0x74,
[11] = 0x61,
[12] = 0x69,
[13] = 0x6E,
[14] = 0x65,
[15] = 0x72,
[16] = 0x73,
[17] = 0x11,
[18] = 0x00,
[19] = 0x43,
[20] = 0x75,
[21] = 0x72,
[22] = 0x72,
[23] = 0x65,
[24] = 0x6E,
[25] = 0x74,
[26] = 0x20,
[27] = 0x50,
[28] = 0x72,
[29] = 0x69,
[30] = 0x63,
[31] = 0x65,
[32] = 0x3A,
[33] = 0x20,
[34] = 0x00,
[35] = 0x00,
[36] = 0x00,
[37] = 0x00,
[38] = 0x11,
[39] = 0x00,
[40] = 0x42,
[41] = 0x6F,
[42] = 0x75,
[43] = 0x67,
[44] = 0x68,
[45] = 0x74,
[46] = 0x3A,
[47] = 0x20,
[48] = 0x04,
[49] = 0x04,
[50] = 0x04,
[51] = 0x04,
[52] = 0x04,
[53] = 0x04,
[54] = 0x00,
[55] = 0xBF
};
function buyHeartContainer()
if (readDWord(0x1F065C) < 15 and readWord(0x1EF6AA) > 44) then
writeSWord(0x1F0688, -45);
getHeart();
elseif (readDWord(0x1F065C) < 30 and readWord(0x1EF6AA) > 49) then
writeSWord(0x1F0688, -50);
getHeart();
elseif (readDWord(0x1F065C) < 45 and readWord(0x1EF6AA) > 54) then
writeSWord(0x1F0688, -55);
getHeart();
elseif (readDWord(0x1F065C) < 60 and readWord(0x1EF6AA) > 59) then
writeSWord(0x1F0688, -60);
getHeart();
elseif (readDWord(0x1F065C) < 75 and readWord(0x1EF6AA) > 69) then
writeSWord(0x1F0688, -70);
getHeart();
elseif (readDWord(0x1F065C) < 90 and readWord(0x1EF6AA) > 84) then
writeSWord(0x1F0688, -85);
getHeart();
elseif (readDWord(0x1F065C) > 89 and readWord(0x1EF6AA) > 99) then
writeSWord(0x1F0688, -100);
getHeart();
end
end
function getHeart()
writeDWord(0x1F065C, readDWord(0x1F065C) + 1);
writeWord(0x1EF6A4, readWord(0x1EF6A4) + 0x10);
end
function deleteHeart()
writeWord(0x1EF6A4, readWord(0x1EF6A4) - 0x10);
end
function tunic(color)
local address = readDWord(0x3FFFF4) - 0x80012E58;
if (readDWord(address) == 0xFA0000FF) then
writeDWord(address + 0x0004, color);
writeDWord(address + 0x052C, color);
writeDWord(address + 0x0A34, color);
writeDWord(address + 0x0C0C, color);
writeDWord(address + 0x0CCC, color);
writeDWord(address + 0x12D4, color);
writeDWord(address + 0x174C, color);
writeDWord(address + 0x1984, color);
writeDWord(address + 0x1E54, color);
end
end
function setPrice()
local address = 0x3FCE3D;
if (readDWord(0x1F065C) < 0xFFFFFFFF) then
local values = {
[0] = 0x08,
[1] = 0x31,
[2] = 0x30,
[3] = 0x30
};
for i = 0, 3, 1 do
writeByte(address + i, values[i]);
end
end
if (readDWord(0x1F065C) < 0x0000005A) then
local values = {
[0] = 0x04,
[1] = 0x04,
[2] = 0x38,
[3] = 0x35
};
for i = 0, 3, 1 do
writeByte(address + i, values[i]);
end
end
if (readDWord(0x1F065C) < 0x0000004B) then
local values = {
[0] = 0x07,
[1] = 0x07,
[2] = 0x37,
[3] = 0x30
};
for i = 0, 3, 1 do
writeByte(address + i, values[i]);
end
end
if (readDWord(0x1F065C) < 0x0000003C) then
local values = {
[0] = 0x06,
[1] = 0x06,
[2] = 0x36,
[3] = 0x30
};
for i = 0, 3, 1 do
writeByte(address + i, values[i]);
end
end
if (readDWord(0x1F065C) < 0x0000002D) then
local values = {
[0] = 0x01,
[1] = 0x01,
[2] = 0x35,
[3] = 0x35
};
for i = 0, 3, 1 do
writeByte(address + i, values[i]);
end
end
if (readDWord(0x1F065C) < 0x0000001E) then
local values = {
[0] = 0x05,
[1] = 0x05,
[2] = 0x35,
[3] = 0x30
};
for i = 0, 3, 1 do
writeByte(address + i, values[i]);
end
end
if (readDWord(0x1F065C) < 0x0000000F) then
local values = {
[0] = 0x02,
[1] = 0x02,
[2] = 0x34,
[3] = 0x35
};
for i = 0, 3, 1 do
writeByte(address + i, values[i]);
end
end
end
function setBought()
local bought = readDWord(0x1F065C);
local thousands = 0x3FCE4C;
local hundreds = 0x3FCE4E;
local tens = 0x3FCE4F;
local ones = 0x3FCE50;
if (bought >= 9000 and bought < 10000) then
writeWord(thousands, 0x392C);
bought = bought - 9000;
elseif (bought >= 8000 and bought < 9000) then
writeWord(thousands, 0x382C);
bought = bought - 8000;
elseif (bought >= 7000 and bought < 8000) then
writeWord(thousands, 0x372C);
bought = bought - 7000;
elseif (bought >= 6000 and bought < 7000) then
writeWord(thousands, 0x362C);
bought = bought - 6000;
elseif (bought >= 5000 and bought < 6000) then
writeWord(thousands, 0x352C);
bought = bought - 5000;
elseif (bought >= 4000 and bought < 5000) then
writeWord(thousands, 0x342C);
bought = bought - 4000;
elseif (bought >= 3000 and bought < 4000) then
writeWord(thousands, 0x332C);
bought = bought - 3000;
elseif (bought >= 2000 and bought < 3000) then
writeWord(thousands, 0x322C);
bought = bought - 2000;
elseif (bought >= 1000 and bought < 2000) then
writeWord(thousands, 0x312C);
bought = bought - 1000;
end
if (bought >= 900 and bought < 1000) then
writeByte(hundreds, 0x39);
bought = bought - 900;
elseif (bought >= 800 and bought < 900) then
writeByte(hundreds, 0x38);
bought = bought - 800;
elseif (bought >= 700 and bought < 800) then
writeByte(hundreds, 0x37);
bought = bought - 700;
elseif (bought >= 600 and bought < 700) then
writeByte(hundreds, 0x36);
bought = bought - 600;
elseif (bought >= 500 and bought < 600) then
writeByte(hundreds, 0x35);
bought = bought - 500;
elseif (bought >= 400 and bought < 500) then
writeByte(hundreds, 0x34);
bought = bought - 400;
elseif (bought >= 300 and bought < 400) then
writeByte(hundreds, 0x33);
bought = bought - 300;
elseif (bought >= 200 and bought < 300) then
writeByte(hundreds, 0x32);
bought = bought - 200;
elseif (bought >= 100 and bought < 200) then
writeByte(hundreds, 0x31);
bought = bought - 100;
end
if (bought >= 90 and bought < 100) then
writeByte(tens, 0x39);
bought = bought - 90;
elseif (bought >= 80 and bought < 90) then
writeByte(tens, 0x38);
bought = bought - 80;
elseif (bought >= 70 and bought < 80) then
writeByte(tens, 0x37);
bought = bought - 70;
elseif (bought >= 60 and bought < 70) then
writeByte(tens, 0x36);
bought = bought - 60;
elseif (bought >= 50 and bought < 60) then
writeByte(tens, 0x35);
bought = bought - 50;
elseif (bought >= 40 and bought < 50) then
writeByte(tens, 0x34);
bought = bought - 40;
elseif (bought >= 30 and bought < 40) then
writeByte(tens, 0x33);
bought = bought - 30;
elseif (bought >= 20 and bought < 30) then
writeByte(tens, 0x32);
bought = bought - 20;
elseif (bought >= 10 and bought < 20) then
writeByte(tens, 0x31);
bought = bought - 10;
end
if (bought >= 0 and bought < 10) then
writeByte(ones, bought + 0x30);
end
end
while true do
if (readByte(0x3E6BC2) == 0x01 and readDWord(0x1F35B8) == 0x0000FFFA) then
writeDWord(0x1F35B8, 0x0000FFEF);
end
if (readDWord(0x1F3310) ~= 0x000000FF and readByte(0x3E6BC2) == 0x01) then
if (readDWord(0x1EF670) == 0x00001C00) then
writeDWord(0x1EF670, 0x0000C000);
writeByte(0x1EF692, 0x01);
writeWord(0x1EF6B0, 0x0100);
writeByte(0x1EF6E0, 0x00);
writeByte(0x1EF72E, 0x10);
writeByte(0x1F3D9B, 0x01);
writeDWord(0x1F065C, 0x00000000);
elseif (readDWord(0x1EF670) == 0x0000D800) then
if (readWord(0x1EF6A4) < 0x0020) then
writeWord(0x1EF6A4, 0x0020);
writeWord(0x1EF6A6, 0x0020);
end
end
end
if joypad.get(1)['A'] then
if (readByte(0x3E6BC2) == 0x02 and readWord(0x3FDA54) == 0x0002 and readWord(0x3FDABC) == 0x0016 and readWord(0x1F0688) == 0x0000 and readWord(0x1EF6A4) < 0x0140) then
buyHeartContainer();
end
end
if (readDWord(0x3FF398) == 0x00000000) then
counter = 0;
else
counter = counter + 1;
if (counter == 3) then
if (readByte(0x3E6BC2) ~= 0x01 and readDWord(0x1F35B8) ~= 0x0000FFFA and readDWord(0x3FF398) ~= 0x00001C00) then
deleteHeart();
end
end
if (counter > 3 and readWord(0x1EF6A4) == 0x00) then
writeDWord(0x1EF670, 0x00001C00);
writeDWord(0x1F35B8, 0x0000FFFA);
end
end
if (readDWord(0x3FFDD8) > 0xC55AC000 and readDWord(0x3FFDD8) < 0xC57A0000 and readWord(0x1EF6A4) < 0x0020) then
writeByte(0x3FF395, 0x14);
writeDWord(0x3FF398, 0x00001C00);
writeDWord(0x1F35B8, 0x0000FFFA);
end
if (readWord(0x1EF6A6) ~= 0x0000) then
counter2 = 0;
else
counter2 = counter2 + 1;
if (counter2 > 87 and readWord(0x1EF6A4) < 0x0020) then
writeByte(0x3FF395, 0x14);
writeDWord(0x3FF398, 0x00001C00);
writeDWord(0x1F35B8, 0x0000FFFA);
writeWord(0x1EF6A4, 0x0030);
end
end
if (bit.band(memory.read_u16_be(0x1EF72C), bit.bnot(0x0FFF)) > 0x0000) then
if (bit.band(memory.read_u16_be(0x1EF72C), bit.bnot(0xF0FF)) == 0x0000) then
writeByte(0x1EF72C, 0x00);
end
if (bit.band(memory.read_u16_be(0x1EF72C), bit.bnot(0xF0FF)) == 0x0100) then
writeByte(0x1EF72C, 0x01);
end
end
if (readDWord(0x3FF398) == 0x00006C00) then
writeDWord(0x3FF398, 0x0000D480);
writeWord(0x1EF6A4, readWord(0x1EF6A4) + 0x0010);
end
writeWord(0x1BFD2C, 0x00B4);
writeWord(0x1BFD2E, 0x0069);
writeWord(0x1BFD30, 0x00FF);
writeWord(0x1BFD32, 0x00FF);
writeWord(0x1BFD34, 0x00E2);
writeWord(0x1BFD36, 0x004F);
writeWord(0x1BFD38, 0x00FF);
writeWord(0x1BFD3A, 0x00A7);
writeWord(0x1BFD3C, 0x004F);
writeWord(0x1BFD1C, 0x0000);
writeWord(0x1BFD24, 0x0003);
writeWord(0x1C1E2C, 0x00FA);
writeWord(0x1C1E2E, 0x01F4);
writeWord(0x1C1E30, 0x03E7);
if (readDWord(0x3FFFF4) ~= 0x00000000) then
-- Tunic Color (0xRRGGBBFF)
tunic(0x224473FF);
end
if (readDWord(0x3FCE2C) == 0x74205761 and readDWord(0x3FCE30) == 0x6C6C6574 and (readByte(0x1EF672) == 0xD4 or readByte(0x1EF672) == 0x4A)) then
writeDWord(0x3FCE84, 0x04353030);
end
if (readDWord(0x3FCE2C) == 0x2057616C and readDWord(0x3FCE30) == 0x6C657400 and (readByte(0x1EF672) == 0xD4 or readByte(0x1EF672) == 0x4A)) then
writeDWord(0x3FCE60, 0x08393939);
end
if (readByte(0x3E6BC2) == 0x02 and readWord(0x3FDA54) == 0x0002 and readWord(0x3FDABC) == 0x0004) then
if (readWord(0x3FCE22) == 0x2053 and readDWord(0x3FCE24) == 0x6869656C) then
writeByte(0x3FCE12, 0x0D);
for i = 0, 55, 1 do
writeByte(0x3FCE1B + i, text[i]);
end
setPrice();
setBought();
end
end
if (readByte(0x3E6BC2) ~= 0x01 and readByte(0x1EF672) == 0x6A) then
if (readDWord(0x3FCE1C) == 0x61792074 and readDWord(0x3FCE20) == 0x6F20676F and readDWord(0x3FCE24) == 0x2C204D69) then
local address = 0x3FCE30;
if (readDWord(0x1EF688) == 0x00000001) then
local values = {
[0] = 0x55,
[1] = 0x6E,
[2] = 0x66,
[3] = 0x6F,
[4] = 0x72,
[5] = 0x74,
[6] = 0x75,
[7] = 0x6E,
[8] = 0x61,
[9] = 0x74,
[10] = 0x65,
[11] = 0x6C,
[12] = 0x79,
[13] = 0x20,
[14] = 0x77,
[15] = 0x65,
[16] = 0x20,
[17] = 0x72,
[18] = 0x61,
[19] = 0x6E,
[20] = 0x20,
[21] = 0x6F,
[22] = 0x75,
[23] = 0x74,
[24] = 0x20,
[25] = 0x6F,
[26] = 0x66,
[27] = 0x20,
[28] = 0x72,
[29] = 0x75,
[30] = 0x70,
[31] = 0x65,
[32] = 0x65,
[33] = 0x73,
[34] = 0x11,
[35] = 0x01,
[36] = 0x79,
[37] = 0x65,
[38] = 0x73,
[39] = 0x74,
[40] = 0x65,
[41] = 0x72,
[42] = 0x64,
[43] = 0x61,
[44] = 0x79,
[45] = 0x00,
[46] = 0x2E,
[47] = 0x19,
[48] = 0xBF
};
for i = 0, 48, 1 do
writeByte(address + i, values[i]);
end
elseif (readDWord(0x1EF688) == 0x00000002) then
local values = {
[0] = 0x55,
[1] = 0x6E,
[2] = 0x66,
[3] = 0x6F,
[4] = 0x72,
[5] = 0x74,
[6] = 0x75,
[7] = 0x6E,
[8] = 0x61,
[9] = 0x74,
[10] = 0x65,
[11] = 0x6C,
[12] = 0x79,
[13] = 0x20,
[14] = 0x77,
[15] = 0x65,
[16] = 0x20,
[17] = 0x72,
[18] = 0x61,
[19] = 0x6E,
[20] = 0x20,
[21] = 0x6F,
[22] = 0x75,
[23] = 0x74,
[24] = 0x20,
[25] = 0x6F,
[26] = 0x66,
[27] = 0x20,
[28] = 0x72,
[29] = 0x75,
[30] = 0x70,
[31] = 0x65,
[32] = 0x65,
[33] = 0x73,
[34] = 0x11,
[35] = 0x01,
[36] = 0x32,
[37] = 0x20,
[38] = 0x64,
[39] = 0x61,
[40] = 0x79,
[41] = 0x73,
[42] = 0x20,
[43] = 0x61,
[44] = 0x67,
[45] = 0x6F,
[46] = 0x00,
[47] = 0x2E,
[48] = 0x19,
[49] = 0xBF
};
for i = 0, 49, 1 do
writeByte(address + i, values[i]);
end
elseif (readDWord(0x1EF688) == 0x00000003) then
local values = {
[0] = 0x55,
[1] = 0x6E,
[2] = 0x66,
[3] = 0x6F,
[4] = 0x72,
[5] = 0x74,
[6] = 0x75,
[7] = 0x6E,
[8] = 0x61,
[9] = 0x74,
[10] = 0x65,
[11] = 0x6C,
[12] = 0x79,
[13] = 0x20,
[14] = 0x77,
[15] = 0x65,
[16] = 0x20,
[17] = 0x72,
[18] = 0x61,
[19] = 0x6E,
[20] = 0x20,
[21] = 0x6F,
[22] = 0x75,
[23] = 0x74,
[24] = 0x20,
[25] = 0x6F,
[26] = 0x66,
[27] = 0x20,
[28] = 0x72,
[29] = 0x75,
[30] = 0x70,
[31] = 0x65,
[32] = 0x65,
[33] = 0x73,
[34] = 0x11,
[35] = 0x01,
[36] = 0x33,
[37] = 0x20,
[38] = 0x64,
[39] = 0x61,
[40] = 0x79,
[41] = 0x73,
[42] = 0x20,
[43] = 0x61,
[44] = 0x67,
[45] = 0x6F,
[46] = 0x00,
[47] = 0x2E,
[48] = 0x19,
[49] = 0xBF
};
for i = 0, 49, 1 do
writeByte(address + i, values[i]);
end
end
elseif (readDWord(0x3FCE1C) == 0x656C6C2C and readDWord(0x3FCE20) == 0x20686572 and readDWord(0x3FCE24) == 0x65277320) then
local address = 0x3FCE1B;
local values = {
[0] = 0x53,
[1] = 0x6B,
[2] = 0x75,
[3] = 0x6C,
[4] = 0x6C,
[5] = 0x6B,
[6] = 0x69,
[7] = 0x64,
[8] = 0x20,
[9] = 0x22,
[10] = 0x77,
[11] = 0x6F,
[12] = 0x6E,
[13] = 0x22,
[14] = 0x20,
[15] = 0x74,
[16] = 0x68,
[17] = 0x65,
[18] = 0x6D,
[19] = 0x20,
[20] = 0x61,
[21] = 0x6C,
[22] = 0x6C,
[23] = 0x2E,
[24] = 0x2E,
[25] = 0x2E,
[26] = 0x11,
[27] = 0x13,
[28] = 0x13,
[29] = 0x12,
[30] = 0x53,
[31] = 0x69,
[32] = 0x6E,
[33] = 0x63,
[34] = 0x65,
[35] = 0x20,
[36] = 0x77,
[37] = 0x65,
[38] = 0x20,
[39] = 0x11,
[40] = 0x64,
[41] = 0x6F,
[42] = 0x6E,
[43] = 0x27,
[44] = 0x74,
[45] = 0x20,
[46] = 0x68,
[47] = 0x61,
[48] = 0x76,
[49] = 0x65,
[50] = 0x20,
[51] = 0x61,
[52] = 0x6E,
[53] = 0x79,
[54] = 0x20,
[55] = 0x6C,
[56] = 0x65,
[57] = 0x66,
[58] = 0x74,
[59] = 0x20,
[60] = 0x79,
[61] = 0x6F,
[62] = 0x75,
[63] = 0x20,
[64] = 0x77,
[65] = 0x69,
[66] = 0x6C,
[67] = 0x6C,
[68] = 0x20,
[69] = 0x68,
[70] = 0x61,
[71] = 0x76,
[72] = 0x65,
[73] = 0x20,
[74] = 0x11,
[75] = 0x74,
[76] = 0x6F,
[77] = 0x20,
[78] = 0x70,
[79] = 0x61,
[80] = 0x79,
[81] = 0x20,
[82] = 0x66,
[83] = 0x6F,
[84] = 0x72,
[85] = 0x20,
[86] = 0x74,
[87] = 0x68,
[88] = 0x65,
[89] = 0x20,
[90] = 0x72,
[91] = 0x65,
[92] = 0x70,
[93] = 0x6C,
[94] = 0x61,
[95] = 0x63,
[96] = 0x65,
[97] = 0x6D,
[98] = 0x65,
[99] = 0x6E,
[100] = 0x74,
[101] = 0x73,
[102] = 0x2E
};
for i = 0, 102, 1 do
writeByte(address + i, values[i]);
end
elseif (readDWord(0x3FCE1C) == 0x6F752067 and readDWord(0x3FCE20) == 0x65742006 and readDWord(0x3FCE24) == 0x39302052) then
local address = 0x3FCE1B;
local values = {
[0] = 0x59,
[1] = 0x6F,
[2] = 0x75,
[3] = 0x20,
[4] = 0x6C,
[5] = 0x6F,
[6] = 0x73,
[7] = 0x74,
[8] = 0x20,
[9] = 0x06,
[10] = 0x31,
[11] = 0x30,
[12] = 0x20,
[13] = 0x52,
[14] = 0x75,
[15] = 0x70,
[16] = 0x65,
[17] = 0x65,
[18] = 0x73,
[19] = 0x00,
[20] = 0x21,
[21] = 0xE0,
[22] = 0xBF
};
for i = 0, 22, 1 do
writeByte(address + i, values[i]);
end
elseif (readDWord(0x3FCE1C) == 0x616B6520 and readDWord(0x3FCE20) == 0x74686520 and readDWord(0x3FCE24) == 0x6368616C) then
local address = 0x3FCE1B;
local values = {
[0] = 0x59,
[1] = 0x6F,
[2] = 0x75,
[3] = 0x20,
[4] = 0x63,
[5] = 0x61,
[6] = 0x6E,
[7] = 0x20,
[8] = 0x70,
[9] = 0x6C,
[10] = 0x61,
[11] = 0x79,
[12] = 0x20,
[13] = 0x61,
[14] = 0x67,
[15] = 0x61,
[16] = 0x69,
[17] = 0x6E,
[18] = 0x20,
[19] = 0x69,
[20] = 0x66,
[21] = 0x20,
[22] = 0x79,
[23] = 0x6F,
[24] = 0x75,
[25] = 0x20,
[26] = 0x77,
[27] = 0x61,
[28] = 0x6E,
[29] = 0x74,
[30] = 0x20,
[31] = 0x74,
[32] = 0x6F,
[33] = 0x2E,
[34] = 0xE0,
[35] = 0xBF
};
for i = 0, 35, 1 do
writeByte(address + i, values[i]);
end
end
if (readWord(0x1F0688) < 0x005B and readWord(0x1F0688) > 0x0050) then
writeSWord(0x1F0688, -11);
end
end
emu.frameadvance();
end