From d7ece32bbb2bea984783a71612c2c07dc2672a9d Mon Sep 17 00:00:00 2001 From: Pheenoh Date: Sun, 3 Jan 2021 04:22:09 -0500 Subject: [PATCH] dSv_info_c::revSwitch OK --- include/d/d_save/d_save/d_save.h | 10 ++++---- src/d/d_save/d_save.cpp | 44 ++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/include/d/d_save/d_save/d_save.h b/include/d/d_save/d_save/d_save.h index 8701aa2abab..cef7bfafaa5 100644 --- a/include/d/d_save/d_save/d_save.h +++ b/include/d/d_save/d_save/d_save.h @@ -673,7 +673,7 @@ public: void onSwitch(int); void offSwitch(int); BOOL isSwitch(int) const; - u8 revSwitch(int); + BOOL revSwitch(int); void onItem(int); BOOL isItem(int) const; void onDungeonItem(int); @@ -747,7 +747,7 @@ public: void onSwitch(int); void offSwitch(int); BOOL isSwitch(int) const; - bool revSwitch(int); + BOOL revSwitch(int); void onItem(int); BOOL isItem(int) const; @@ -768,11 +768,11 @@ public: void onSwitch(int); void offSwitch(int); BOOL isSwitch(int) const; - bool revSwitch(int); + BOOL revSwitch(int); void onOneSwitch(int); void offOneSwitch(int); BOOL isOneSwitch(int) const; - bool revOneSwitch(int); + BOOL revOneSwitch(int); void onItem(int); BOOL isItem(int) const; void onOneItem(int); @@ -879,7 +879,7 @@ public: void onSwitch(int, int); void offSwitch(int, int); BOOL isSwitch(int, int) const; - u8 revSwitch(int, int); + BOOL revSwitch(int, int); void onItem(int, int); BOOL isItem(int, int) const; void onActor(int, int); diff --git a/src/d/d_save/d_save.cpp b/src/d/d_save/d_save.cpp index fb8caf1f142..0008a88d7e4 100644 --- a/src/d/d_save/d_save.cpp +++ b/src/d/d_save/d_save.cpp @@ -1022,7 +1022,7 @@ bool dSv_memBit_c::revSwitch(int i_no) { return (this->area_flags_bitfields1 + (i_no >> 0x5))[0x2] & tmp ? true : false; } #else -asm u8 dSv_memBit_c::revSwitch(int) { +asm BOOL dSv_memBit_c::revSwitch(int) { nofralloc #include "d/d_save/d_save/asm/func_8003488C.s" } @@ -1143,10 +1143,10 @@ BOOL dSv_danBit_c::isSwitch(int i_no) const { return this->switch_bitfield[i_no >> 0x5] & (0x1 << (i_no & 0x1F)) ? TRUE : FALSE; } -bool dSv_danBit_c::revSwitch(int i_no) { +BOOL dSv_danBit_c::revSwitch(int i_no) { int uVar1 = 1 << (i_no & 0x1F); this->switch_bitfield[i_no >> 5] ^= uVar1; - return this->switch_bitfield[i_no >> 5] & uVar1 ? true : false; + return this->switch_bitfield[i_no >> 5] & uVar1 ? TRUE : FALSE; } void dSv_danBit_c::onItem(int i_no) { @@ -1198,7 +1198,7 @@ bool dSv_zoneBit_c::revSwitch(int i_no) { return this->switch_bitfield[i_no >> 4] & uVar1 ? true : false; } #else -asm bool dSv_zoneBit_c::revSwitch(int i_no) { +asm BOOL dSv_zoneBit_c::revSwitch(int i_no) { nofralloc #include "d/d_save/d_save/asm/func_80034D78.s" } @@ -1216,10 +1216,10 @@ BOOL dSv_zoneBit_c::isOneSwitch(int i_no) const { return this->room_switch & 1 << i_no ? TRUE : FALSE; } -bool dSv_zoneBit_c::revOneSwitch(int i_no) { +BOOL dSv_zoneBit_c::revOneSwitch(int i_no) { int iVar1 = 1 << i_no; this->room_switch ^= iVar1; - return this->room_switch & iVar1 ? true : false; + return this->room_switch & iVar1 ? TRUE : FALSE; } void dSv_zoneBit_c::onItem(int i_no) { @@ -1383,8 +1383,6 @@ void dSv_info_c::offSwitch(int i_no, int i_roomNo) { } } -// doesn't like getZoneBit() returning a reference -#ifndef NONMATCHING BOOL dSv_info_c::isSwitch(int i_no, int i_roomNo) const { int value; if ((i_no == -1) || (i_no == 0xFF)) { @@ -1409,16 +1407,28 @@ BOOL dSv_info_c::isSwitch(int i_no, int i_roomNo) const { } return value; } -#else -asm BOOL dSv_info_c::isSwitch(int i_no, int i_roomNo) const { - nofralloc -#include "d/d_save/d_save/asm/func_80035360.s" -} -#endif -asm u8 dSv_info_c::revSwitch(int i_no, int i_roomNo) { - nofralloc -#include "d/d_save/d_save/asm/func_8003542c.s" + +BOOL dSv_info_c::revSwitch(int i_no, int i_roomNo) { + int value; + if ((i_no == -1) || (i_no == 0xFF)) { + return FALSE; + } + + if (i_no < 0x80) { + value = this->memory.getTempFlags().revSwitch(i_no); + } else if (i_no < 0xC0) { + value = this->dungeon_bit.revSwitch(i_no - 0x80); + } else { + int zoneNo = dStage_roomControl_c_NS_getZoneNo(i_roomNo, i_no); + if (i_no < 0xE0) { + value = this->zones[zoneNo].getZoneBit().revSwitch(i_no - 0xC0); + } else { + value = this->zones[zoneNo].getZoneBit().revOneSwitch(i_no - 0xE0); + } + } + + return value; } void dSv_info_c::onItem(int i_no, int i_roomNo) {