Commented the code to clear up confusion

This commit is contained in:
earthcrafterman 2022-05-22 12:10:56 -04:00
commit 64a1722d30
3 changed files with 14 additions and 0 deletions

View file

@ -19,13 +19,17 @@ MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) {
if (file == nullptr) if (file == nullptr)
return nullptr; return nullptr;
// Allocate room for an additional message
MessageTableEntry* table = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * (file->messages.size() + 1)); MessageTableEntry* table = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * (file->messages.size() + 1));
for (int i = 0; i < file->messages.size(); i++) { for (int i = 0; i < file->messages.size(); i++) {
// Look for Owl Text
if (file->messages[i].id == 0x2066) { if (file->messages[i].id == 0x2066) {
// Create a new message based on the Owl Text
char* kaeporaPatch = (char*)malloc(sizeof(char) * file->messages[i].msg.size()); char* kaeporaPatch = (char*)malloc(sizeof(char) * file->messages[i].msg.size());
file->messages[i].msg.copy(kaeporaPatch, file->messages[i].msg.size(), 0); file->messages[i].msg.copy(kaeporaPatch, file->messages[i].msg.size(), 0);
// Swap the order of yes and no in this new message
if (filePath == "text/nes_message_data_static/nes_message_data_static") { if (filePath == "text/nes_message_data_static/nes_message_data_static") {
kaeporaPatch[26] = 'Y'; kaeporaPatch[26] = 'Y';
kaeporaPatch[27] = 'e'; kaeporaPatch[27] = 'e';
@ -52,6 +56,7 @@ MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) {
kaeporaPatch[32] = 'n'; kaeporaPatch[32] = 'n';
} }
// load data into message
table[file->messages.size()].textId = 0x71B3; table[file->messages.size()].textId = 0x71B3;
table[file->messages.size()].typePos = (file->messages[i].textboxType << 4) | file->messages[i].textboxYPos; table[file->messages.size()].typePos = (file->messages[i].textboxType << 4) | file->messages[i].textboxYPos;
table[file->messages.size()].segment = kaeporaPatch; table[file->messages.size()].segment = kaeporaPatch;

View file

@ -273,6 +273,7 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) {
Font* font; Font* font;
const char* seg; const char* seg;
u16 bufferId = textId; u16 bufferId = textId;
// Use the better owl message if better owl is enabled
if (CVar_GetS32("gBetterOwl", 0) != 0 && (bufferId == 0x2066 || bufferId == 0x607B || if (CVar_GetS32("gBetterOwl", 0) != 0 && (bufferId == 0x2066 || bufferId == 0x607B ||
bufferId == 0x10C2 || bufferId == 0x10C6 || bufferId == 0x206A)) bufferId == 0x10C2 || bufferId == 0x10C6 || bufferId == 0x206A))
{ {

View file

@ -366,6 +366,7 @@ void func_80ACA7E0(EnOwl* this, GlobalContext* globalCtx) {
void EnOwl_ConfirmKokiriMessage(EnOwl* this, GlobalContext* globalCtx) { void EnOwl_ConfirmKokiriMessage(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT:
@ -394,6 +395,7 @@ void EnOwl_WaitOutsideKokiri(EnOwl* this, GlobalContext* globalCtx) {
void func_80ACA998(EnOwl* this, GlobalContext* globalCtx) { void func_80ACA998(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT:
@ -439,6 +441,7 @@ void EnOwl_WaitHyruleCastle(EnOwl* this, GlobalContext* globalCtx) {
void func_80ACAB88(EnOwl* this, GlobalContext* globalCtx) { void func_80ACAB88(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT:
@ -481,6 +484,7 @@ void EnOwl_WaitKakariko(EnOwl* this, GlobalContext* globalCtx) {
void func_80ACAD34(EnOwl* this, GlobalContext* globalCtx) { void func_80ACAD34(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT:
@ -518,6 +522,7 @@ void EnOwl_WaitGerudo(EnOwl* this, GlobalContext* globalCtx) {
void func_80ACAEB8(EnOwl* this, GlobalContext* globalCtx) { void func_80ACAEB8(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT:
@ -639,6 +644,7 @@ void EnOwl_WaitDeathMountainShortcut(EnOwl* this, GlobalContext* globalCtx) {
void func_80ACB344(EnOwl* this, GlobalContext* globalCtx) { void func_80ACB344(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT:
@ -663,6 +669,7 @@ void func_80ACB3E0(EnOwl* this, GlobalContext* globalCtx) {
void func_80ACB440(EnOwl* this, GlobalContext* globalCtx) { void func_80ACB440(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT:
@ -699,6 +706,7 @@ void EnOwl_WaitLWPreSaria(EnOwl* this, GlobalContext* globalCtx) {
void func_80ACB5C4(EnOwl* this, GlobalContext* globalCtx) { void func_80ACB5C4(EnOwl* this, GlobalContext* globalCtx) {
if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) {
// swap the order of the responses if better owl is enabled
uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex);
switch (index) { switch (index) {
case OWL_REPEAT: case OWL_REPEAT: