Refactor SnesToPc and PcToSnes functions for improved readability and consistency; remove redundant core:: namespace usage

This commit is contained in:
scawful
2025-01-22 13:45:58 -05:00
parent de53ccae21
commit 43fc52dec7
12 changed files with 170 additions and 172 deletions

View File

@@ -31,7 +31,7 @@ struct MemoryEditorWithDiffChecker : public SharedRom {
static uint64_t convert_address = 0;
gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
SameLine();
Text("%x", core::SnesToPc(convert_address));
Text("%x", SnesToPc(convert_address));
// mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);

View File

@@ -125,9 +125,9 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
rom()->ReadWord(zelda3::kDungeonMapGfxPtr + (d * 2)));
ptr |= 0x0A0000; // Add bank to the short ptr
ptr_gfx |= 0x0A0000; // Add bank to the short ptr
int pc_ptr = core::SnesToPc(ptr); // Contains data for the next 25 rooms
int pc_ptr = SnesToPc(ptr); // Contains data for the next 25 rooms
int pc_ptr_gfx =
core::SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
ASSIGN_OR_RETURN(uint16_t boss_room_d,
rom()->ReadWord(zelda3::kDungeonMapBossRooms + (d * 2)));
@@ -182,8 +182,8 @@ absl::Status ScreenEditor::SaveDungeonMaps() {
for (int d = 0; d < 14; d++) {
int ptr = zelda3::kDungeonMapRoomsPtr + (d * 2);
int ptr_gfx = zelda3::kDungeonMapGfxPtr + (d * 2);
int pc_ptr = core::SnesToPc(ptr);
int pc_ptr_gfx = core::SnesToPc(ptr_gfx);
int pc_ptr = SnesToPc(ptr);
int pc_ptr_gfx = SnesToPc(ptr_gfx);
const int nbr_floors = dungeon_maps_[d].nbr_of_floor;
const int nbr_basements = dungeon_maps_[d].nbr_of_basement;

View File

@@ -154,14 +154,14 @@ std::vector<DictionaryEntry> BuildDictionaryEntries(Rom *rom) {
std::vector<uint8_t> bytes;
std::stringstream stringBuilder;
int address = core::SnesToPc(
int address = SnesToPc(
kTextData + (rom->data()[kPointersDictionaries + (i * 2) + 1] << 8) +
rom->data()[kPointersDictionaries + (i * 2)]);
int temppush_backress = core::SnesToPc(
kTextData +
(rom->data()[kPointersDictionaries + ((i + 1) * 2) + 1] << 8) +
rom->data()[kPointersDictionaries + ((i + 1) * 2)]);
int temppush_backress =
SnesToPc(kTextData +
(rom->data()[kPointersDictionaries + ((i + 1) * 2) + 1] << 8) +
rom->data()[kPointersDictionaries + ((i + 1) * 2)]);
while (address < temppush_backress) {
uint8_t uint8_tDictionary = rom->data()[address++];
@@ -233,9 +233,9 @@ absl::StatusOr<MessageData> ParseSingleMessage(
current_message_raw.append("]");
auto mutable_rom_data = const_cast<uint8_t *>(rom_data.data());
uint32_t address = core::Get24LocalFromPC(
uint32_t address = Get24LocalFromPC(
mutable_rom_data, kPointersDictionaries + (dictionary * 2));
uint32_t address_end = core::Get24LocalFromPC(
uint32_t address_end = Get24LocalFromPC(
mutable_rom_data, kPointersDictionaries + ((dictionary + 1) * 2));
for (uint32_t i = address; i < address_end; i++) {

View File

@@ -299,9 +299,9 @@ void MessageEditor::ReadAllTextDataV2() {
current_raw_message.append(util::HexWord(dictionary));
current_raw_message.append("]");
uint32_t address = core::Get24LocalFromPC(
uint32_t address = Get24LocalFromPC(
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
uint32_t address_end = core::Get24LocalFromPC(
uint32_t address_end = Get24LocalFromPC(
rom()->mutable_data(),
kPointersDictionaries + ((dictionary + 1) * 2));
@@ -397,9 +397,9 @@ void MessageEditor::ReadAllTextData() {
current_message_raw.append(util::HexWord(dictionary));
current_message_raw.append("]");
uint32_t address = core::Get24LocalFromPC(
uint32_t address = Get24LocalFromPC(
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
uint32_t address_end = core::Get24LocalFromPC(
uint32_t address_end = Get24LocalFromPC(
rom()->mutable_data(),
kPointersDictionaries + ((dictionary + 1) * 2));