From a08de1b00a0f6888e1d587f170258eb938e8b30f Mon Sep 17 00:00:00 2001 From: rogerman Date: Thu, 11 Sep 2025 23:28:46 -0700 Subject: [PATCH] Cocoa Port: More refactoring. - Add "ClientCheatManager.cpp" and "ClientFirmwareControl.cpp" files, moving all this C++ code to their own files. - Remove the "cocoa_videofilter.mm/.h" files, which were never used and aren't planned to ever be used in the future. --- desmume/src/cheatSystem.h | 7 +- .../src/frontend/cocoa/ClientCheatManager.cpp | 1574 +++++++++++++++++ .../src/frontend/cocoa/ClientCheatManager.h | 302 ++++ .../frontend/cocoa/ClientFirmwareControl.cpp | 763 ++++++++ .../frontend/cocoa/ClientFirmwareControl.h | 139 ++ .../project.pbxproj | 78 +- .../project.pbxproj | 42 +- desmume/src/frontend/cocoa/cocoa_cheat.h | 280 +-- desmume/src/frontend/cocoa/cocoa_cheat.mm | 1560 +--------------- desmume/src/frontend/cocoa/cocoa_core.mm | 1 + desmume/src/frontend/cocoa/cocoa_firmware.h | 119 +- desmume/src/frontend/cocoa/cocoa_firmware.mm | 1055 ++--------- .../src/frontend/cocoa/cocoa_videofilter.h | 63 - .../src/frontend/cocoa/cocoa_videofilter.mm | 227 --- .../userinterface/cheatWindowDelegate.mm | 4 +- .../preferencesWindowDelegate.mm | 1 - 16 files changed, 3035 insertions(+), 3180 deletions(-) create mode 100644 desmume/src/frontend/cocoa/ClientCheatManager.cpp create mode 100644 desmume/src/frontend/cocoa/ClientCheatManager.h create mode 100644 desmume/src/frontend/cocoa/ClientFirmwareControl.cpp create mode 100644 desmume/src/frontend/cocoa/ClientFirmwareControl.h delete mode 100644 desmume/src/frontend/cocoa/cocoa_videofilter.h delete mode 100644 desmume/src/frontend/cocoa/cocoa_videofilter.mm diff --git a/desmume/src/cheatSystem.h b/desmume/src/cheatSystem.h index 3f7b6ebd9..9767f3f24 100644 --- a/desmume/src/cheatSystem.h +++ b/desmume/src/cheatSystem.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2024 DeSmuME team + Copyright (C) 2009-2025 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,6 +15,9 @@ along with the this software. If not, see . */ +#ifndef _CHEAT_SYSTEM_H_ +#define _CHEAT_SYSTEM_H_ + #include #include #include @@ -327,3 +330,5 @@ void CheatItemGenerateDescriptionFlat(const char *folderName, const char *folder extern CHEATS *cheats; extern CHEATSEARCH *cheatSearch; + +#endif // _CHEAT_SYSTEM_H_ diff --git a/desmume/src/frontend/cocoa/ClientCheatManager.cpp b/desmume/src/frontend/cocoa/ClientCheatManager.cpp new file mode 100644 index 000000000..996f6695b --- /dev/null +++ b/desmume/src/frontend/cocoa/ClientCheatManager.cpp @@ -0,0 +1,1574 @@ +/* + Copyright (C) 2025 DeSmuME team + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the this software. If not, see . + */ + +#include "ClientCheatManager.h" +#include "../../MMU.h" +#undef BOOL + + +size_t CheatConvertRawCodeToCleanCode(const char *inRawCodeString, const size_t requestedCodeCount, std::string &outCleanCodeString) +{ + size_t cleanCodeLength = 0; + if ( (inRawCodeString == NULL) || + (requestedCodeCount == 0) ) + { + return cleanCodeLength; + } + + char *cleanCodeWorkingBuffer = (char *)malloc((requestedCodeCount * 16) + 1); + memset(cleanCodeWorkingBuffer, 0, (requestedCodeCount * 16) + 1); + + size_t rawCodeLength = strlen(inRawCodeString); + // remove wrong chars + for (size_t i = 0; (i < rawCodeLength) && (cleanCodeLength < (requestedCodeCount * 16)); i++) + { + char c = inRawCodeString[i]; + //apparently 100% of pokemon codes were typed with the letter O in place of zero in some places + //so let's try to adjust for that here + static const char *AR_Valid = "Oo0123456789ABCDEFabcdef"; + if (strchr(AR_Valid, c)) + { + if ( (c == 'o') || (c == 'O') ) + { + c = '0'; + } + + cleanCodeWorkingBuffer[cleanCodeLength++] = c; + } + } + + if ( (cleanCodeLength % 16) != 0) + { + // Code lines must always come in 8+8, where the first 8 characters + // are used for the target address, and the second 8 characters are + // used for the 32-bit value written to the target address. Therefore, + // if the string length isn't divisible by 16, then it is considered + // invalid. + cleanCodeLength = 0; + free(cleanCodeWorkingBuffer); + return cleanCodeLength; + } + + outCleanCodeString = cleanCodeWorkingBuffer; + free(cleanCodeWorkingBuffer); + + return (cleanCodeLength / 16); +} + +size_t CheatConvertCleanCodeToRawCode(const char *inCleanCodeString, std::string &outRawCodeString) +{ + if (inCleanCodeString == NULL) + { + return 0; + } + + // Clean code strings are assumed to be already validated, so we're not + // going to bother with any more validation here. + + const size_t cleanCodeLength = strlen(inCleanCodeString); + const size_t codeCount = cleanCodeLength / 16; + const size_t rawCodeLength = codeCount * (16 + 1 + 1); + + char *rawCodeWorkingBuffer = (char *)malloc(rawCodeLength); + memset(rawCodeWorkingBuffer, 0, rawCodeLength); + + for (size_t i = 0; i < codeCount; i++) + { + const size_t c = i * 16; + const size_t r = i * (16 + 1 + 1); + + rawCodeWorkingBuffer[r + 0] = inCleanCodeString[c + 0]; + rawCodeWorkingBuffer[r + 1] = inCleanCodeString[c + 1]; + rawCodeWorkingBuffer[r + 2] = inCleanCodeString[c + 2]; + rawCodeWorkingBuffer[r + 3] = inCleanCodeString[c + 3]; + rawCodeWorkingBuffer[r + 4] = inCleanCodeString[c + 4]; + rawCodeWorkingBuffer[r + 5] = inCleanCodeString[c + 5]; + rawCodeWorkingBuffer[r + 6] = inCleanCodeString[c + 6]; + rawCodeWorkingBuffer[r + 7] = inCleanCodeString[c + 7]; + rawCodeWorkingBuffer[r + 8] = ' '; + rawCodeWorkingBuffer[r + 9] = inCleanCodeString[c + 8]; + rawCodeWorkingBuffer[r +10] = inCleanCodeString[c + 9]; + rawCodeWorkingBuffer[r +11] = inCleanCodeString[c +10]; + rawCodeWorkingBuffer[r +12] = inCleanCodeString[c +11]; + rawCodeWorkingBuffer[r +13] = inCleanCodeString[c +12]; + rawCodeWorkingBuffer[r +14] = inCleanCodeString[c +13]; + rawCodeWorkingBuffer[r +15] = inCleanCodeString[c +14]; + rawCodeWorkingBuffer[r +16] = inCleanCodeString[c +15]; + rawCodeWorkingBuffer[r +17] = '\n'; + } + + rawCodeWorkingBuffer[rawCodeLength - 1] = '\0'; + outRawCodeString = rawCodeWorkingBuffer; + + return codeCount; +} + +bool IsCheatItemDuplicate(const ClientCheatItem *first, const ClientCheatItem *second) +{ + bool isDuplicate = false; + + if ( (first == NULL) || (second == NULL) ) + { + return isDuplicate; + } + + if (first == second) + { + isDuplicate = true; + return isDuplicate; + } + + const CheatType compareType = first->GetType(); + + switch (compareType) + { + case CheatType_Internal: + { + if ( (first->GetAddress() == second->GetAddress()) && + (first->GetValueLength() == second->GetValueLength()) && + (first->GetValue() == second->GetValue()) ) + { + isDuplicate = true; + } + break; + } + + case CheatType_ActionReplay: + { + if ( (first->GetCodeCount() == second->GetCodeCount()) && + (first->GetCleanCodeCppString() == second->GetCleanCodeCppString()) ) + { + isDuplicate = true; + } + break; + } + + case CheatType_CodeBreaker: + default: + break; + } + + return isDuplicate; +} + +ClientCheatItem::ClientCheatItem() +{ + _cheatManager = NULL; + + _isEnabled = false; + _willAddFromDB = false; + + _cheatType = CheatType_Internal; + _nameString = "No description."; + _commentString = ""; + _freezeType = CheatFreezeType_Normal; + _address = 0x02000000; + strncpy(_addressString, "0x02000000", sizeof(_addressString)); + _valueLength = 1; + _value = 0; + + _codeCount = 1; + _rawCodeString = "02000000 00000000"; + _cleanCodeString = "0200000000000000"; +} + +ClientCheatItem::~ClientCheatItem() +{ + +} + +void ClientCheatItem::Init(const CHEATS_LIST &inCheatItem) +{ + char workingCodeBuffer[32]; + + this->_isEnabled = (inCheatItem.enabled) ? true : false; + + this->_cheatType = (CheatType)inCheatItem.type; + this->_nameString = inCheatItem.description; + this->_commentString = ""; + + this->_freezeType = (CheatFreezeType)inCheatItem.freezeType; + this->_valueLength = inCheatItem.size + 1; // CHEATS_LIST.size value range is [1...4], but starts counting from 0. + this->_address = inCheatItem.code[0][0]; + this->_addressString[0] = '0'; + this->_addressString[1] = 'x'; + snprintf(this->_addressString + 2, sizeof(this->_addressString) - 2, "%08X", this->_address); + this->_value = inCheatItem.code[0][1]; + + snprintf(workingCodeBuffer, 18, "%08X %08X", this->_address, this->_value); + this->_rawCodeString = workingCodeBuffer; + snprintf(workingCodeBuffer, 17, "%08X%08X", this->_address, this->_value); + this->_cleanCodeString = workingCodeBuffer; + + if (this->_cheatType == CheatType_Internal) + { + this->_codeCount = 1; + } + else if (this->_cheatType == CheatType_ActionReplay) + { + this->_codeCount = inCheatItem.num; + + for (size_t i = 1; i < this->_codeCount; i++) + { + snprintf(workingCodeBuffer, 19, "\n%08X %08X", inCheatItem.code[i][0], inCheatItem.code[i][1]); + this->_rawCodeString += workingCodeBuffer; + snprintf(workingCodeBuffer, 17, "%08X%08X", inCheatItem.code[i][0], inCheatItem.code[i][1]); + this->_cleanCodeString += workingCodeBuffer; + } + } +} + +void ClientCheatItem::Init(const ClientCheatItem &inCheatItem) +{ + this->SetEnabled(inCheatItem.IsEnabled()); + this->SetName(inCheatItem.GetName()); + this->SetComments(inCheatItem.GetComments()); + this->SetType(inCheatItem.GetType()); + this->SetFreezeType(inCheatItem.GetFreezeType()); + + if (this->GetType() == CheatType_Internal) + { + this->SetValueLength(inCheatItem.GetValueLength()); + this->SetAddress(inCheatItem.GetAddress()); + this->SetValue(inCheatItem.GetValue()); + } + else + { + this->SetRawCodeString(inCheatItem.GetRawCodeString(), false); + } +} + +void ClientCheatItem::SetCheatManager(ClientCheatManager *cheatManager) +{ + this->_cheatManager = cheatManager; +} + +ClientCheatManager* ClientCheatItem::GetCheatManager() const +{ + return this->_cheatManager; +} + +void ClientCheatItem::SetEnabled(bool theState) +{ + if ( (this->_isEnabled != theState) && (this->_cheatManager != NULL) ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + this->_isEnabled = theState; +} + +bool ClientCheatItem::IsEnabled() const +{ + return this->_isEnabled; +} + +void ClientCheatItem::SetWillAddFromDB(bool theState) +{ + this->_willAddFromDB = theState; +} + +bool ClientCheatItem::WillAddFromDB() const +{ + return this->_willAddFromDB; +} + +CheatType ClientCheatItem::GetType() const +{ + return this->_cheatType; +} + +void ClientCheatItem::SetType(CheatType requestedType) +{ + switch (requestedType) + { + case CheatType_Internal: + case CheatType_ActionReplay: + case CheatType_CodeBreaker: + // Do nothing. + break; + + default: + // Bail if the cheat type is invalid. + return; + } + + if ( (this->_cheatType != requestedType) && (this->_cheatManager != NULL) && this->_isEnabled ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + this->_cheatType = requestedType; +} + +bool ClientCheatItem::IsSupportedType() const +{ + return (this->_cheatType != CheatType_CodeBreaker); +} + +const char* ClientCheatItem::GetName() const +{ + return this->_nameString.c_str(); +} + +void ClientCheatItem::SetName(const char *nameString) +{ + if (nameString == NULL) + { + this->_nameString = ""; + } + else + { + this->_nameString = nameString; + } +} + +const char* ClientCheatItem::GetComments() const +{ + return this->_commentString.c_str(); +} + +void ClientCheatItem::SetComments(const char *commentString) +{ + if (commentString == NULL) + { + this->_commentString = ""; + } + else + { + this->_commentString = commentString; + } +} + +CheatFreezeType ClientCheatItem::GetFreezeType() const +{ + return this->_freezeType; +} + +void ClientCheatItem::SetFreezeType(CheatFreezeType theFreezeType) +{ + switch (theFreezeType) + { + case CheatFreezeType_Normal: + case CheatFreezeType_CanDecrease: + case CheatFreezeType_CanIncrease: + // Do nothing. + break; + + default: + // Bail if the freeze type is invalid. + return; + } + + if ( (this->_freezeType != theFreezeType) && (this->_cheatManager != NULL) && this->_isEnabled ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + this->_freezeType = theFreezeType; +} + +uint32_t ClientCheatItem::GetAddress() const +{ + if (this->_cheatType != CheatType_Internal) + { + return 0; + } + + return this->_address; +} + +void ClientCheatItem::SetAddress(uint32_t theAddress) +{ + if ( (this->_address != theAddress) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + this->_address = theAddress; + + this->_addressString[0] = '0'; + this->_addressString[1] = 'x'; + snprintf(this->_addressString + 2, 9, "%08X", theAddress); + this->_addressString[10] = '\0'; + + if (this->_cheatType == CheatType_Internal) + { + this->_ConvertInternalToActionReplay(); + } +} + +const char* ClientCheatItem::GetAddressString() const +{ + return this->_addressString; +} + +const char* ClientCheatItem::GetAddressSixDigitString() const +{ + return (this->_addressString + 4); +} + +void ClientCheatItem::SetAddressSixDigitString(const char *sixDigitString) +{ + this->_addressString[0] = '0'; + this->_addressString[1] = 'x'; + this->_addressString[2] = '0'; + this->_addressString[3] = '2'; + + if (sixDigitString == NULL) + { + this->_addressString[4] = '0'; + this->_addressString[5] = '0'; + this->_addressString[6] = '0'; + this->_addressString[7] = '0'; + this->_addressString[8] = '0'; + this->_addressString[9] = '0'; + } + else + { + this->_addressString[4] = sixDigitString[0]; + this->_addressString[5] = sixDigitString[1]; + this->_addressString[6] = sixDigitString[2]; + this->_addressString[7] = sixDigitString[3]; + this->_addressString[8] = sixDigitString[4]; + this->_addressString[9] = sixDigitString[5]; + } + + this->_addressString[10] = '\0'; + + u32 theAddress = 0; + sscanf(this->_addressString + 2, "%x", &theAddress); + + if ( (this->_address != theAddress) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + this->_address = theAddress; + + if (this->_cheatType == CheatType_Internal) + { + this->_ConvertInternalToActionReplay(); + } +} + +uint32_t ClientCheatItem::GetValue() const +{ + return this->_value; +} + +void ClientCheatItem::SetValue(uint32_t theValue) +{ + if ( (this->_value != theValue) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + this->_value = theValue; + + if (this->_cheatType == CheatType_Internal) + { + this->_ConvertInternalToActionReplay(); + } +} + +uint8_t ClientCheatItem::GetValueLength() const +{ + return this->_valueLength; +} + +void ClientCheatItem::SetValueLength(uint8_t byteLength) +{ + if ( (this->_valueLength != byteLength) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + this->_valueLength = byteLength; + + if (this->_cheatType == CheatType_Internal) + { + this->_ConvertInternalToActionReplay(); + } +} + +void ClientCheatItem::SetRawCodeString(const char *rawString, const bool willSaveValidatedRawString) +{ + std::string newCleanCodeString; + + size_t cleanCodeCount = CheatConvertRawCodeToCleanCode(rawString, 1024, this->_cleanCodeString); + if (cleanCodeCount == 0) + { + return; + } + + this->_codeCount = (uint32_t)cleanCodeCount; + + if (willSaveValidatedRawString) + { + // Using the validated clean code string, the raw code string will be + // rewritten using the following format for each line: + // XXXXXXXX XXXXXXXX\n + CheatConvertCleanCodeToRawCode(this->_cleanCodeString.c_str(), this->_rawCodeString); + } + else + { + // The passed in raw code string will be saved, regardless of any syntax + // errors, flaws, or formatting issues that it may contain. + this->_rawCodeString = rawString; + } + + if ( (this->_cheatType == CheatType_ActionReplay) && (this->_cheatManager != NULL) && this->_isEnabled ) + { + this->_cheatManager->MasterNeedsUpdate(); + } + + if (this->_cheatType == CheatType_ActionReplay) + { + this->_ConvertActionReplayToInternal(); + } +} + +const char* ClientCheatItem::GetRawCodeString() const +{ + return this->_rawCodeString.c_str(); +} + +const char* ClientCheatItem::GetCleanCodeString() const +{ + return this->_cleanCodeString.c_str(); +} + +const std::string& ClientCheatItem::GetCleanCodeCppString() const +{ + return this->_cleanCodeString; +} + +uint32_t ClientCheatItem::GetCodeCount() const +{ + return this->_codeCount; +} + +void ClientCheatItem::_ConvertInternalToActionReplay() +{ + char workingCodeBuffer[16+1+1]; + + u32 function = this->_address & 0x0FFFFFFF; + u32 truncatedValue = this->_value; + + switch (this->_valueLength) + { + case 1: + function |= 0x20000000; + truncatedValue &= 0x000000FF; + break; + + case 2: + function |= 0x10000000; + truncatedValue &= 0x0000FFFF; + break; + + case 3: + truncatedValue &= 0x00FFFFFF; + break; + + default: + break; + } + + memset(workingCodeBuffer, 0, sizeof(workingCodeBuffer)); + snprintf(workingCodeBuffer, 16+1+1, "%08X %08X", function, truncatedValue); + this->_rawCodeString = workingCodeBuffer; + + memset(workingCodeBuffer, 0, sizeof(workingCodeBuffer)); + snprintf(workingCodeBuffer, 16+1, "%08X%08X", function, truncatedValue); + this->_cleanCodeString = workingCodeBuffer; + + this->_codeCount = 1; +} + +void ClientCheatItem::_ConvertActionReplayToInternal() +{ + char workingCodeBuffer[11] = {0}; + size_t cleanCodeLength = this->_cleanCodeString.length(); + size_t i = 0; + + // Note that we're only searching for the first valid command for + // a constant RAM write, since internal cheats can only support a + // single constant RAM write. + for (; i < cleanCodeLength; i+=16) + { + workingCodeBuffer[0] = '0'; + workingCodeBuffer[1] = 'x'; + strncpy(workingCodeBuffer + 2, this->_cleanCodeString.c_str() + i, 8); + workingCodeBuffer[10] = '\0'; + + if (workingCodeBuffer[2] == '2') + { + this->_valueLength = 1; + workingCodeBuffer[2] = '0'; + break; + } + else if (workingCodeBuffer[2] == '1') + { + this->_valueLength = 2; + workingCodeBuffer[2] = '0'; + break; + } + else if (workingCodeBuffer[2] == '0') + { + this->_valueLength = 4; + break; + } + else + { + continue; + } + } + + if (i >= cleanCodeLength) + { + return; + } + + strncpy(this->_addressString, workingCodeBuffer, sizeof(this->_addressString)); + sscanf(workingCodeBuffer + 2, "%x", &this->_address); + + memset(workingCodeBuffer, 0, sizeof(workingCodeBuffer)); + strncpy(workingCodeBuffer, this->_cleanCodeString.c_str() + i + 8, 8); + sscanf(workingCodeBuffer, "%x", &this->_value); + + switch (this->_valueLength) + { + case 1: + this->_value &= 0x000000FF; + break; + + case 2: + this->_value &= 0x0000FFFF; + break; + + default: + break; + } +} + +void ClientCheatItem::ClientToDesmumeCheatItem(CHEATS_LIST *outCheatItem) const +{ + if (outCheatItem == NULL) + { + return; + } + + outCheatItem->type = this->_cheatType; + outCheatItem->enabled = (this->_isEnabled) ? 1 : 0; + strncpy(outCheatItem->description, this->_nameString.c_str(), sizeof(outCheatItem->description)); + + switch (this->_cheatType) + { + case CheatType_Internal: + outCheatItem->num = 1; + outCheatItem->size = this->_valueLength - 1; // CHEATS_LIST.size value range is [1...4], but starts counting from 0. + outCheatItem->freezeType = (u8)this->_freezeType; + outCheatItem->code[0][0] = this->_address; + outCheatItem->code[0][1] = this->_value; + break; + + case CheatType_ActionReplay: + case CheatType_CodeBreaker: + { + outCheatItem->num = this->_codeCount; + outCheatItem->size = 3; + outCheatItem->freezeType = CheatFreezeType_Normal; + + char valueString[9]; + valueString[8] = '\0'; + + const char *cleanCodeStr = this->_cleanCodeString.c_str(); + for (size_t i = 0; i < this->_codeCount; i++) + { + strncpy(valueString, cleanCodeStr + (i * 16) + 0, 8); + sscanf(valueString, "%x", &outCheatItem->code[i][0]); + + strncpy(valueString, cleanCodeStr + (i * 16) + 8, 8); + sscanf(valueString, "%x", &outCheatItem->code[i][1]); + } + break; + } + + default: + break; + } +} + +#pragma mark - + +ClientCheatList::ClientCheatList() +{ + _list = new std::vector; +} + +ClientCheatList::~ClientCheatList() +{ + delete this->_list; + this->_list = NULL; +} + +CheatSystemError ClientCheatList::LoadFromFile(const char *filePath) +{ + CheatSystemError error = CheatSystemError_NoError; + + if (filePath == NULL) + { + error = CheatSystemError_FileOpenFailed; + return error; + } + + CHEATS *tempEngineList = new CHEATS; + tempEngineList->init((char *)filePath); + this->ReplaceFromEngine(tempEngineList); + delete tempEngineList; + + return error; +} + +CheatSystemError ClientCheatList::SaveToFile(const char *filePath) +{ + CheatSystemError error = CheatSystemError_NoError; + + if (filePath == NULL) + { + error = CheatSystemError_FileOpenFailed; + return error; + } + + CHEATS *tempEngineList = new CHEATS; + tempEngineList->setFilePath(filePath); + + this->CopyListToEngine(false, tempEngineList); + + bool isSaveSuccessful = tempEngineList->save(); + if (!isSaveSuccessful) + { + error = CheatSystemError_FileSaveFailed; + } + + delete tempEngineList; + + return error; +} + +bool ClientCheatList::IsItemDuplicate(const ClientCheatItem *srcItem) +{ + bool isDuplicateFound = false; + if (srcItem == NULL) + { + return isDuplicateFound; + } + + const CheatType compareType = srcItem->GetType(); + + const size_t totalCheatCount = this->_list->size(); + for (size_t i = 0; i < totalCheatCount; i++) + { + const ClientCheatItem *itemToCheck = (*this->_list)[i]; + if (itemToCheck == NULL) + { + continue; + } + + if (srcItem == itemToCheck) + { + isDuplicateFound = true; + break; + } + + switch (compareType) + { + case CheatType_Internal: + isDuplicateFound = ( (srcItem->GetAddress() == itemToCheck->GetAddress()) && + (srcItem->GetValue() == itemToCheck->GetValue()) && + (srcItem->GetValueLength() == itemToCheck->GetValueLength()) ); + break; + + case CheatType_ActionReplay: + isDuplicateFound = ( (srcItem->GetCodeCount() == itemToCheck->GetCodeCount()) && + (srcItem->GetCleanCodeCppString() == itemToCheck->GetCleanCodeCppString()) ); + break; + + case CheatType_CodeBreaker: + default: + break; + } + + if (isDuplicateFound) + { + break; + } + } + + return isDuplicateFound; +} + +ClientCheatItem* ClientCheatList::__AddItem(const ClientCheatItem *srcItem, const bool willCopy, const bool allowDuplicates) +{ + ClientCheatItem *newItem = NULL; + if (srcItem == NULL) + { + return newItem; + } + + if (allowDuplicates || !this->IsItemDuplicate(srcItem)) + { + if (willCopy) + { + this->_list->push_back(new ClientCheatItem); + newItem->Init(*srcItem); + } + else + { + this->_list->push_back((ClientCheatItem *)srcItem); + } + + newItem = this->_list->back(); + } + + return newItem; +} + +ClientCheatItem* ClientCheatList::AddNew() +{ + ClientCheatItem *newItem = new ClientCheatItem; + return this->__AddItem(newItem, false, true); +} + +ClientCheatItem* ClientCheatList::AddNewItemCopy(const ClientCheatItem *srcItem) +{ + return this->__AddItem(srcItem, true, true); +} + +ClientCheatItem* ClientCheatList::AddNewItemCopyNoDuplicate(const ClientCheatItem *srcItem) +{ + return this->__AddItem(srcItem, true, false); +} + +ClientCheatItem* ClientCheatList::AddExistingItemNoDuplicate(const ClientCheatItem *srcItem) +{ + return this->__AddItem(srcItem, false, false); +} + +bool ClientCheatList::Remove(ClientCheatItem *targetItem) +{ + return this->RemoveAtIndex( this->GetIndexOfItem(targetItem) ); +} + +bool ClientCheatList::RemoveAtIndex(size_t index) +{ + bool didRemoveItem = false; + ClientCheatItem *targetItem = this->GetItemAtIndex(index); + + if (targetItem != NULL) + { + this->_list->erase( this->_list->begin() + index ); + delete targetItem; + didRemoveItem = true; + } + + return didRemoveItem; +} + +void ClientCheatList::RemoveAll() +{ + const size_t cheatCount = this->_list->size(); + for (size_t i = 0; i < cheatCount; i++) + { + ClientCheatItem *itemToRemove = (*this->_list)[i]; + delete itemToRemove; + } + + this->_list->clear(); +} + +bool ClientCheatList::Update(const ClientCheatItem &srcItem, ClientCheatItem *targetItem) +{ + return this->UpdateAtIndex(srcItem, this->GetIndexOfItem(targetItem)); +} + +bool ClientCheatList::UpdateAtIndex(const ClientCheatItem &srcItem, size_t index) +{ + bool didUpdateItem = false; + ClientCheatItem *targetItem = this->GetItemAtIndex(index); + + if (targetItem != NULL) + { + targetItem->Init(srcItem); + didUpdateItem = true; + } + + return didUpdateItem; +} + +size_t ClientCheatList::GetTotalCheatCount() const +{ + return this->_list->size(); +} + +size_t ClientCheatList::GetActiveCheatCount() const +{ + size_t activeCount = 0; + const size_t totalCount = this->_list->size(); + + for (size_t i = 0; i < totalCount; i++) + { + ClientCheatItem *cheatItem = (*this->_list)[i]; + if (cheatItem->IsEnabled()) + { + activeCount++; + } + } + + return activeCount; +} + +std::vector* ClientCheatList::GetCheatList() const +{ + return this->_list; +} + +size_t ClientCheatList::GetIndexOfItem(const ClientCheatItem *cheatItem) const +{ + size_t outIndex = ~0; + if (cheatItem == NULL) + { + return outIndex; + } + + const size_t cheatCount = this->_list->size(); + for (size_t i = 0; i < cheatCount; i++) + { + if (cheatItem == (*this->_list)[i]) + { + return outIndex; + } + } + + return outIndex; +} + +ClientCheatItem* ClientCheatList::GetItemAtIndex(size_t index) const +{ + if (index >= this->GetTotalCheatCount()) + { + return NULL; + } + + return (*this->_list)[index]; +} + +void ClientCheatList::ReplaceFromEngine(const CHEATS *engineCheatList) +{ + if (engineCheatList == NULL) + { + return; + } + + this->RemoveAll(); + + const size_t totalCount = engineCheatList->getListSize(); + for (size_t i = 0; i < totalCount; i++) + { + ClientCheatItem *newItem = this->AddNew(); + newItem->Init( *engineCheatList->getItemPtrAtIndex(i) ); + } +} + +void ClientCheatList::CopyListToEngine(const bool willApplyOnlyEnabledItems, CHEATS *engineCheatList) +{ + if (engineCheatList == NULL) + { + return; + } + + CHEATS_LIST tempEngineItem; + + engineCheatList->clear(); + + const size_t totalCount = this->_list->size(); + for (size_t i = 0; i < totalCount; i++) + { + ClientCheatItem *cheatItem = (*this->_list)[i]; + if (cheatItem->IsEnabled() || !willApplyOnlyEnabledItems) + { + cheatItem->ClientToDesmumeCheatItem(&tempEngineItem); + engineCheatList->addItem(tempEngineItem); + } + } +} + +#pragma mark - + +ClientCheatSearcher::ClientCheatSearcher() +{ + _desmumeSearcher = new CHEATSEARCH; + _searchValueLength = 4; + _resultsCount = 0; + _didSearchStart = false; + _resultsList.resize(0); +} + +ClientCheatSearcher::~ClientCheatSearcher() +{ + delete this->_desmumeSearcher; +} + +bool ClientCheatSearcher::DidStart() const +{ + return this->_didSearchStart; +} + +void ClientCheatSearcher::Reset() +{ + this->_desmumeSearcher->close(); + this->_didSearchStart = false; + this->_resultsCount = 0; + + this->_desmumeSearcher->getListReset(); + this->_resultsList.resize(0); +} + +size_t ClientCheatSearcher::SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch) +{ + if (!this->_didSearchStart) + { + this->_searchValueLength = valueLength; + this->_didSearchStart = this->_desmumeSearcher->start((u8)CheatSearchStyle_ExactValue, this->_searchValueLength - 1, 0); + this->_resultsCount = 0; + this->_resultsList.resize(0); + } + + if (this->_didSearchStart) + { + this->_resultsCount = (size_t)this->_desmumeSearcher->search(value); + this->RefreshResults(); + } + + return this->_resultsCount; +} + +size_t ClientCheatSearcher::SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch) +{ + if (!this->_didSearchStart) + { + this->_searchValueLength = valueLength; + this->_didSearchStart = this->_desmumeSearcher->start((u8)CheatSearchStyle_Comparative, this->_searchValueLength - 1, 0); + this->_resultsCount = 0; + this->_resultsList.resize(0); + } + else + { + this->_resultsCount = (size_t)this->_desmumeSearcher->search((u8)compareStyle); + this->RefreshResults(); + } + + return this->_resultsCount; +} + +const DesmumeCheatSearchResultsList& ClientCheatSearcher::RefreshResults() +{ + bool didReadResult = false; + u32 readAddress = 0; + u32 readValue = 0; + size_t readResultIndex = 0; + + this->_desmumeSearcher->getListReset(); + this->_resultsList.clear(); + + for (size_t i = 0; i < this->_resultsCount; i++) + { + didReadResult = this->_desmumeSearcher->getList(&readAddress, &readValue); + if (didReadResult) + { + DesmumeCheatSearchItem searchResult; + searchResult.address = readAddress; + searchResult.value = readValue; + + this->_resultsList.push_back(searchResult); + readResultIndex++; + } + } + + return this->_resultsList; +} + +const DesmumeCheatSearchResultsList& ClientCheatSearcher::GetResults() +{ + return this->_resultsList; +} + +size_t ClientCheatSearcher::GetResultCount() const +{ + return this->_resultsCount; +} + +#pragma mark - + +ClientCheatDatabase::ClientCheatDatabase() +{ + _list = new ClientCheatList; + _title.resize(0); + _description.resize(0); + _lastFilePath.resize(0); +} + +ClientCheatDatabase::~ClientCheatDatabase() +{ + delete this->_list; +} + +ClientCheatList* ClientCheatDatabase::GetList() const +{ + return this->_list; +} + +ClientCheatList* ClientCheatDatabase::LoadFromFile(const char *dbFilePath) +{ + if (dbFilePath == NULL) + { + return NULL; + } + + CHEATSEXPORT *exporter = new CHEATSEXPORT(); + CheatSystemError dbError = CheatSystemError_NoError; + + bool didFileLoad = exporter->load((char *)dbFilePath); + if (didFileLoad) + { + this->_list->RemoveAll(); + this->_title = exporter->getGameTitle(); + this->_description = exporter->getDescription(); + this->_lastFilePath = dbFilePath; + + const size_t itemCount = exporter->getCheatsNum(); + const CHEATS_LIST *dbItem = exporter->getCheats(); + + for (size_t i = 0; i < itemCount; i++) + { + ClientCheatItem *newItem = this->_list->AddNew(); + if (newItem != NULL) + { + newItem->Init(dbItem[i]); + } + } + } + else + { + dbError = exporter->getErrorCode(); + } + + delete exporter; + exporter = NULL; + + if (dbError != CheatSystemError_NoError) + { + return NULL; + } + + return this->_list; +} + +const char* ClientCheatDatabase::GetTitle() const +{ + return this->_title.c_str(); +} + +const char* ClientCheatDatabase::GetDescription() const +{ + return this->_description.c_str(); +} + +#pragma mark - + +ClientCheatManager::ClientCheatManager() +{ + _currentSessionList = new ClientCheatList; + _currentDatabase = new ClientCheatDatabase; + _currentSearcher = new ClientCheatSearcher; + _pendingInternalCheatWriteList.resize(0); + + _selectedItem = NULL; + _selectedItemIndex = 0; + + _untitledCount = 0; + + _currentSessionLastFilePath.resize(0); + + _masterNeedsUpdate = true; +} + +ClientCheatManager::~ClientCheatManager() +{ + delete this->_currentSearcher; + delete this->_currentDatabase; + delete this->_currentSessionList; +} + +CHEATS* ClientCheatManager::GetMaster() +{ + return cheats; +} + +void ClientCheatManager::SetMaster(const CHEATS *masterCheats) +{ + cheats = (CHEATS *)masterCheats; +} + +ClientCheatList* ClientCheatManager::GetSessionList() const +{ + return this->_currentSessionList; +} + +const char* ClientCheatManager::GetSessionListLastFilePath() const +{ + return this->_currentSessionLastFilePath.c_str(); +} + +CheatSystemError ClientCheatManager::SessionListLoadFromFile(const char *filePath) +{ + CheatSystemError error = CheatSystemError_NoError; + + if (filePath == NULL) + { + error = CheatSystemError_FileOpenFailed; + return error; + } + + error = this->_currentSessionList->LoadFromFile(filePath); + if (error == CheatSystemError_NoError) + { + this->_currentSessionLastFilePath = filePath; + + const size_t totalCount = this->_currentSessionList->GetTotalCheatCount(); + for (size_t i = 0; i < totalCount; i++) + { + ClientCheatItem *cheatItem = this->_currentSessionList->GetItemAtIndex(i); + cheatItem->SetCheatManager(this); + } + } + + return error; +} + +CheatSystemError ClientCheatManager::SessionListSaveToFile(const char *filePath) +{ + CheatSystemError error = CheatSystemError_NoError; + + if (filePath == NULL) + { + error = CheatSystemError_FileSaveFailed; + return error; + } + + error = this->_currentSessionList->SaveToFile(filePath); + if (error == CheatSystemError_NoError) + { + this->_currentSessionLastFilePath = filePath; + } + + return error; +} + +ClientCheatItem* ClientCheatManager::SetSelectedItemByIndex(size_t index) +{ + this->_selectedItemIndex = index; + this->_selectedItem = this->_currentSessionList->GetItemAtIndex(index); + + return this->_selectedItem; +} + +ClientCheatItem* ClientCheatManager::NewItem() +{ + ClientCheatItem *newItem = this->_currentSessionList->AddNew(); + newItem->SetCheatManager(this); + + this->_untitledCount++; + if (this->_untitledCount > 1) + { + char newDesc[16]; + snprintf(newDesc, sizeof(newDesc), "Untitled %ld", (unsigned long)this->_untitledCount); + + newItem->SetName(newDesc); + } + else + { + newItem->SetName("Untitled"); + } + + if (newItem->IsEnabled()) + { + this->_masterNeedsUpdate = true; + } + + return newItem; +} + +ClientCheatItem* ClientCheatManager::AddExistingItemNoDuplicate(const ClientCheatItem *theItem) +{ + ClientCheatItem *addedItem = this->_currentSessionList->AddExistingItemNoDuplicate(theItem); + if (addedItem != NULL) + { + addedItem->SetCheatManager(this); + + if (addedItem->IsEnabled()) + { + this->_masterNeedsUpdate = true; + } + } + + return addedItem; +} + +void ClientCheatManager::RemoveItem(ClientCheatItem *targetItem) +{ + this->RemoveItemAtIndex( this->_currentSessionList->GetIndexOfItem(targetItem) ); +} + +void ClientCheatManager::RemoveItemAtIndex(size_t index) +{ + const ClientCheatItem *targetItem = this->_currentSessionList->GetItemAtIndex(index); + if (targetItem == NULL) + { + return; + } + + const bool willChangeMasterUpdateFlag = targetItem->IsEnabled(); + const bool didRemoveItem = this->_currentSessionList->RemoveAtIndex(index); + + if (didRemoveItem && willChangeMasterUpdateFlag) + { + this->_masterNeedsUpdate = true; + } +} + +void ClientCheatManager::RemoveSelectedItem() +{ + this->RemoveItemAtIndex(this->_selectedItemIndex); +} + +void ClientCheatManager::ModifyItem(const ClientCheatItem *srcItem, ClientCheatItem *targetItem) +{ + if ( (srcItem != NULL) && (srcItem == targetItem) ) + { + if (targetItem->IsEnabled()) + { + this->_masterNeedsUpdate = true; + } + return; + } + + this->ModifyItemAtIndex(srcItem, this->_currentSessionList->GetIndexOfItem(targetItem)); +} + +void ClientCheatManager::ModifyItemAtIndex(const ClientCheatItem *srcItem, size_t index) +{ + const ClientCheatItem *targetItem = this->_currentSessionList->GetItemAtIndex(index); + if ( (srcItem == NULL) || (targetItem == NULL) ) + { + return; + } + + const bool willChangeMasterUpdateFlag = targetItem->IsEnabled(); + const bool didModifyItem = this->_currentSessionList->UpdateAtIndex(*srcItem, index); + + if (didModifyItem && willChangeMasterUpdateFlag) + { + this->_masterNeedsUpdate = true; + } +} + +size_t ClientCheatManager::GetTotalCheatCount() const +{ + return this->_currentSessionList->GetTotalCheatCount(); +} + +size_t ClientCheatManager::GetActiveCheatCount() const +{ + return this->_currentSessionList->GetActiveCheatCount(); +} + +void ClientCheatManager::LoadFromMaster() +{ + size_t activeCount = 0; + const CHEATS *masterCheats = ClientCheatManager::GetMaster(); + + if (masterCheats == NULL) + { + return; + } + + this->_currentSessionLastFilePath = masterCheats->getFilePath(); + + activeCount = this->_currentSessionList->GetActiveCheatCount(); + if (activeCount > 0) + { + this->_masterNeedsUpdate = true; + } + + this->_currentSessionList->ReplaceFromEngine(masterCheats); + + const size_t totalCount = this->_currentSessionList->GetTotalCheatCount(); + for (size_t i = 0; i < totalCount; i++) + { + ClientCheatItem *cheatItem = this->_currentSessionList->GetItemAtIndex(i); + cheatItem->SetCheatManager(this); + } + + activeCount = this->_currentSessionList->GetActiveCheatCount(); + if (activeCount > 0) + { + this->_masterNeedsUpdate = true; + } +} + +void ClientCheatManager::ApplyToMaster() +{ + CHEATS *masterCheats = ClientCheatManager::GetMaster(); + if ( (masterCheats == NULL) || !this->_masterNeedsUpdate ) + { + return; + } + + this->_currentSessionList->CopyListToEngine(true, masterCheats); + this->_masterNeedsUpdate = false; +} + +void ClientCheatManager::MasterNeedsUpdate() +{ + this->_masterNeedsUpdate = true; +} + +ClientCheatList* ClientCheatManager::GetDatabaseList() const +{ + return this->_currentDatabase->GetList(); +} + +ClientCheatList* ClientCheatManager::DatabaseListLoadFromFile(const char *dbFilePath) +{ + return this->_currentDatabase->LoadFromFile(dbFilePath); +} + +const char* ClientCheatManager::GetDatabaseTitle() const +{ + return this->_currentDatabase->GetTitle(); +} + +const char* ClientCheatManager::GetDatabaseDescription() const +{ + return this->_currentDatabase->GetDescription(); +} + +bool ClientCheatManager::SearchDidStart() const +{ + return this->_currentSearcher->DidStart(); +} + +void ClientCheatManager::SearchReset() +{ + this->_currentSearcher->Reset(); +} + +size_t ClientCheatManager::SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch) +{ + return this->_currentSearcher->SearchExactValue(value, valueLength, performSignedSearch); +} + +size_t ClientCheatManager::SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch) +{ + return this->_currentSearcher->SearchComparative(compareStyle, valueLength, performSignedSearch); +} + +const DesmumeCheatSearchResultsList& ClientCheatManager::SearchResultsRefresh() +{ + return this->_currentSearcher->RefreshResults(); +} + +const DesmumeCheatSearchResultsList& ClientCheatManager::GetSearchResults() +{ + return this->_currentSearcher->GetResults(); +} + +size_t ClientCheatManager::GetSearchResultCount() const +{ + return this->_currentSearcher->GetResultCount(); +} + +void ClientCheatManager::DirectWriteInternalCheatAtIndex(size_t index) +{ + this->DirectWriteInternalCheatItem( this->_currentSessionList->GetItemAtIndex(index) ); +} + +void ClientCheatManager::DirectWriteInternalCheatItem(const ClientCheatItem *cheatItem) +{ + if ( (cheatItem == NULL) || (cheatItem->GetType() != CheatType_Internal) ) + { + return; + } + + this->DirectWriteInternalCheat( cheatItem->GetAddress(), cheatItem->GetValue(), cheatItem->GetValueLength() ); +} + +void ClientCheatManager::DirectWriteInternalCheat(uint32_t targetAddress, uint32_t newValue32, size_t newValueLength) +{ + targetAddress &= 0x00FFFFFF; + targetAddress |= 0x02000000; + + InternalCheatParam cheatWrite; + cheatWrite.address = targetAddress; + cheatWrite.value = newValue32; + cheatWrite.valueLength = newValueLength; + + this->_pendingInternalCheatWriteList.push_back(cheatWrite); +} + +void ClientCheatManager::ApplyPendingInternalCheatWrites() +{ + bool needsJitReset = false; + + const size_t writeListSize = this->_pendingInternalCheatWriteList.size(); + if (writeListSize == 0) + { + return; + } + + for (size_t i = 0; i < writeListSize; i++) + { + const InternalCheatParam cheatWrite = this->_pendingInternalCheatWriteList[i]; + + const bool shouldResetJit = CHEATS::DirectWrite(cheatWrite.valueLength, ARMCPU_ARM9, cheatWrite.address, cheatWrite.value); + if (shouldResetJit) + { + needsJitReset = true; + } + } + + this->_pendingInternalCheatWriteList.clear(); + + if (needsJitReset) + { + CHEATS::JitNeedsReset(); + CHEATS::ResetJitIfNeeded(); + } +} diff --git a/desmume/src/frontend/cocoa/ClientCheatManager.h b/desmume/src/frontend/cocoa/ClientCheatManager.h new file mode 100644 index 000000000..e84a8d831 --- /dev/null +++ b/desmume/src/frontend/cocoa/ClientCheatManager.h @@ -0,0 +1,302 @@ +/* + Copyright (C) 2025 DeSmuME team + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the this software. If not, see . + */ + +#ifndef _CLIENT_CHEAT_MANAGER_H_ +#define _CLIENT_CHEAT_MANAGER_H_ + +#include +#include +#include "../../cheatSystem.h" +#undef BOOL + + +enum CheatType +{ + CheatType_Internal = 0, + CheatType_ActionReplay = 1, + CheatType_CodeBreaker = 2 +}; + +enum CheatFreezeType +{ + CheatFreezeType_Normal = 0, + CheatFreezeType_CanDecrease = 1, + CheatFreezeType_CanIncrease = 2 +}; + +enum CheatSearchStyle +{ + CheatSearchStyle_ExactValue = 0, + CheatSearchStyle_Comparative = 1 +}; + +enum CheatSearchCompareStyle +{ + CheatSearchCompareStyle_GreaterThan = 0, + CheatSearchCompareStyle_LesserThan = 1, + CheatSearchCompareStyle_Equals = 2, + CheatSearchCompareStyle_NotEquals = 3 +}; + +class ClientCheatManager; + +union DesmumeCheatSearchItem +{ + uint64_t data; + + struct + { + uint32_t address; + uint32_t value; + }; +}; +typedef union DesmumeCheatSearchItem DesmumeCheatSearchItem; + +typedef std::vector DesmumeCheatSearchResultsList; + +struct InternalCheatParam +{ + uint32_t address; + uint32_t value; + uint8_t valueLength; +}; +typedef struct InternalCheatParam InternalCheatParam; + +class ClientCheatItem +{ +protected: + ClientCheatManager *_cheatManager; + + bool _isEnabled; + bool _willAddFromDB; + + CheatType _cheatType; + std::string _nameString; + std::string _commentString; + + // Internal cheat type parameters + CheatFreezeType _freezeType; + char _addressString[10+1]; + uint32_t _address; + uint32_t _value; + uint8_t _valueLength; + + // Action Replay parameters + uint32_t _codeCount; + std::string _rawCodeString; + std::string _cleanCodeString; + + void _ConvertInternalToActionReplay(); + void _ConvertActionReplayToInternal(); + +public: + ClientCheatItem(); + ~ClientCheatItem(); + + void Init(const CHEATS_LIST &inCheatItem); + void Init(const ClientCheatItem &inCheatItem); + + void SetCheatManager(ClientCheatManager *cheatManager); + ClientCheatManager* GetCheatManager() const; + + void SetEnabled(bool theState); + bool IsEnabled() const; + + void SetWillAddFromDB(bool theState); + bool WillAddFromDB() const; + + CheatType GetType() const; + void SetType(CheatType requestedType); + bool IsSupportedType() const; + + const char* GetName() const; + void SetName(const char *nameString); + + const char* GetComments() const; + void SetComments(const char *commentString); + + CheatFreezeType GetFreezeType() const; + void SetFreezeType(CheatFreezeType theFreezeType); + + uint32_t GetAddress() const; + void SetAddress(uint32_t theAddress); + const char* GetAddressString() const; + const char* GetAddressSixDigitString() const; + void SetAddressSixDigitString(const char *sixDigitString); + + uint32_t GetValue() const; + void SetValue(uint32_t theValue); + uint8_t GetValueLength() const; + void SetValueLength(uint8_t byteLength); + + void SetRawCodeString(const char *rawString, const bool willSaveValidatedRawString); + const char* GetRawCodeString() const; + const char* GetCleanCodeString() const; + const std::string& GetCleanCodeCppString() const; + uint32_t GetCodeCount() const; + + void ClientToDesmumeCheatItem(CHEATS_LIST *outCheatItem) const; +}; + +class ClientCheatList +{ +private: + ClientCheatItem* __AddItem(const ClientCheatItem *srcItem, const bool willCopy, const bool allowDuplicates); + +protected: + std::vector *_list; + +public: + ClientCheatList(); + ~ClientCheatList(); + + CheatSystemError LoadFromFile(const char *filePath); + CheatSystemError SaveToFile(const char *filePath); + + bool IsItemDuplicate(const ClientCheatItem *srcItem); + + ClientCheatItem* AddNew(); + ClientCheatItem* AddNewItemCopy(const ClientCheatItem *srcItem); + ClientCheatItem* AddNewItemCopyNoDuplicate(const ClientCheatItem *srcItem); + ClientCheatItem* AddExistingItemNoDuplicate(const ClientCheatItem *srcItem); + + bool Remove(ClientCheatItem *targetItem); + bool RemoveAtIndex(size_t index); + void RemoveAll(); + + bool Update(const ClientCheatItem &srcItem, ClientCheatItem *targetItem); + bool UpdateAtIndex(const ClientCheatItem &srcItem, size_t index); + + size_t GetTotalCheatCount() const; + size_t GetActiveCheatCount() const; + std::vector* GetCheatList() const; + size_t GetIndexOfItem(const ClientCheatItem *cheatItem) const; + ClientCheatItem* GetItemAtIndex(size_t index) const; + + void ReplaceFromEngine(const CHEATS *engineCheatList); + void CopyListToEngine(const bool willApplyOnlyEnabledItems, CHEATS *engineCheatList); +}; + +class ClientCheatSearcher +{ +protected: + CHEATSEARCH *_desmumeSearcher; + uint8_t _searchValueLength; + size_t _resultsCount; + bool _didSearchStart; + DesmumeCheatSearchResultsList _resultsList; + +public: + ClientCheatSearcher(); + ~ClientCheatSearcher(); + + bool DidStart() const; + void Reset(); + size_t SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch); + size_t SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch); + const DesmumeCheatSearchResultsList& RefreshResults(); + const DesmumeCheatSearchResultsList& GetResults(); + size_t GetResultCount() const; +}; + +class ClientCheatDatabase +{ +protected: + ClientCheatList *_list; + std::string _title; + std::string _description; + std::string _lastFilePath; + +public: + ClientCheatDatabase(); + ~ClientCheatDatabase(); + + ClientCheatList* GetList() const; + ClientCheatList* LoadFromFile(const char *dbFilePath); + + const char* GetTitle() const; + const char* GetDescription() const; +}; + +class ClientCheatManager +{ +protected: + ClientCheatList *_currentSessionList; + ClientCheatDatabase *_currentDatabase; + ClientCheatSearcher *_currentSearcher; + + ClientCheatItem *_selectedItem; + size_t _selectedItemIndex; + uint32_t _untitledCount; + std::string _currentSessionLastFilePath; + + std::vector _pendingInternalCheatWriteList; + + bool _masterNeedsUpdate; + +public: + ClientCheatManager(); + virtual ~ClientCheatManager(); + + static CHEATS* GetMaster(); + static void SetMaster(const CHEATS *masterCheats); + + ClientCheatList* GetSessionList() const; + const char* GetSessionListLastFilePath() const; + + virtual CheatSystemError SessionListLoadFromFile(const char *filePath); + virtual CheatSystemError SessionListSaveToFile(const char *filePath); + + ClientCheatItem* SetSelectedItemByIndex(size_t index); + + ClientCheatItem* NewItem(); + ClientCheatItem* AddExistingItemNoDuplicate(const ClientCheatItem *theItem); + + void RemoveItem(ClientCheatItem *theItem); + void RemoveItemAtIndex(size_t index); + void RemoveSelectedItem(); + + void ModifyItem(const ClientCheatItem *srcItem, ClientCheatItem *targetItem); + void ModifyItemAtIndex(const ClientCheatItem *srcItem, size_t index); + + size_t GetTotalCheatCount() const; + size_t GetActiveCheatCount() const; + + void LoadFromMaster(); + void ApplyToMaster(); + void MasterNeedsUpdate(); + + ClientCheatList* GetDatabaseList() const; + ClientCheatList* DatabaseListLoadFromFile(const char *dbFilePath); + const char* GetDatabaseTitle() const; + const char* GetDatabaseDescription() const; + + bool SearchDidStart() const; + void SearchReset(); + size_t SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch); + size_t SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch); + const DesmumeCheatSearchResultsList& SearchResultsRefresh(); + const DesmumeCheatSearchResultsList& GetSearchResults(); + size_t GetSearchResultCount() const; + + void DirectWriteInternalCheatAtIndex(size_t index); + void DirectWriteInternalCheatItem(const ClientCheatItem *cheatItem); + void DirectWriteInternalCheat(uint32_t targetAddress, uint32_t newValue32, size_t newValueLength); + void ApplyPendingInternalCheatWrites(); +}; + +#endif // _CLIENT_CHEAT_MANAGER_H_ diff --git a/desmume/src/frontend/cocoa/ClientFirmwareControl.cpp b/desmume/src/frontend/cocoa/ClientFirmwareControl.cpp new file mode 100644 index 000000000..20160423f --- /dev/null +++ b/desmume/src/frontend/cocoa/ClientFirmwareControl.cpp @@ -0,0 +1,763 @@ +/* + Copyright (C) 2025 DeSmuME team + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the this software. If not, see . + */ + +#include "ClientFirmwareControl.h" + +#include "../../firmware.h" +#undef BOOL + + +ClientFirmwareControl::ClientFirmwareControl() +{ + _macAddressSelection = FirmwareCfgMACAddrSetID_Firmware; + + // First, get the default firmware config. + _internalData = (FirmwareConfig *)malloc(sizeof(FirmwareConfig)); + NDS_GetDefaultFirmwareConfig(*_internalData); + + srand((uint32_t)time(NULL)); + + // Generate a random firmware MAC address and its associated string. + const uint32_t defaultFirmwareMACAddressValue = (uint32_t)_internalData->MACAddress[2] | ((uint32_t)_internalData->MACAddress[3] << 8) | ((uint32_t)_internalData->MACAddress[4] << 16) | ((uint32_t)_internalData->MACAddress[5] << 24); + + do + { + _firmwareMACAddressValue = (uint32_t)rand() & 0x00FFFFFF; + _firmwareMACAddressValue = (_firmwareMACAddressValue << 8) | 0x000000BF; + } while ( (_firmwareMACAddressValue == 0x000000BF) || (_firmwareMACAddressValue == 0xFFFFFFBF) || (_firmwareMACAddressValue == defaultFirmwareMACAddressValue) ); + + _internalData->MACAddress[2] = (uint8_t)( _firmwareMACAddressValue & 0x000000FF); + _internalData->MACAddress[3] = (uint8_t)((_firmwareMACAddressValue >> 8) & 0x000000FF); + _internalData->MACAddress[4] = (uint8_t)((_firmwareMACAddressValue >> 16) & 0x000000FF); + _internalData->MACAddress[5] = (uint8_t)((_firmwareMACAddressValue >> 24) & 0x000000FF); + + memset(_macAddressString, '\0', sizeof(_macAddressString)); + ClientFirmwareControl::WriteMACAddressStringToBuffer(_internalData->MACAddress[3], _internalData->MACAddress[4], _internalData->MACAddress[5], &_macAddressString[0]); + + // Generate a random custom MAC address set and their associated strings. + do + { + _customMACAddressValue = (uint32_t)rand() & 0x00FFFFFF; + _customMACAddressValue = (_customMACAddressValue << 8) | 0x000000BF; + } while ( (_customMACAddressValue == 0x000000BF) || (_customMACAddressValue == 0xFFFFFFBF) || ((_customMACAddressValue & 0xF0FFFFFF) == (_firmwareMACAddressValue & 0xF0FFFFFF)) ); + + const uint8_t customMAC4 = (_customMACAddressValue >> 8) & 0x000000FF; + const uint8_t customMAC5 = (_customMACAddressValue >> 16) & 0x000000FF; + const uint8_t customMAC6 = (_customMACAddressValue >> 24) & 0x000000F0; + + for (size_t i = 1; i <= 8; i++) + { + ClientFirmwareControl::WriteMACAddressStringToBuffer(customMAC4, customMAC5, customMAC6 + (uint8_t)i, &_macAddressString[18*i]); + } + + // Generate the WFC User ID string. + memset(_wfcUserIDString, '\0', sizeof(_wfcUserIDString)); + const uint64_t wfcUserIDValue = (uint64_t)_internalData->WFCUserID[0] | + ((uint64_t)_internalData->WFCUserID[1] << 8) | + ((uint64_t)_internalData->WFCUserID[2] << 16) | + ((uint64_t)_internalData->WFCUserID[3] << 24) | + ((uint64_t)_internalData->WFCUserID[4] << 32) | + ((uint64_t)_internalData->WFCUserID[5] << 40); + ClientFirmwareControl::WriteWFCUserIDStringToBuffer(wfcUserIDValue, _wfcUserIDString); + + // Generate the subnet mask strings. + memset(_subnetMaskString, '\0', sizeof(_subnetMaskString)); + + uint32_t subnetMaskValue = (_internalData->subnetMask_AP1 == 0) ? 0 : (0xFFFFFFFF << (32 - _internalData->subnetMask_AP1)); + snprintf(&_subnetMaskString[0], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); + + subnetMaskValue = (_internalData->subnetMask_AP2 == 0) ? 0 : (0xFFFFFFFF << (32 - _internalData->subnetMask_AP2)); + snprintf(&_subnetMaskString[16], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); + + subnetMaskValue = (_internalData->subnetMask_AP3 == 0) ? 0 : (0xFFFFFFFF << (32 - _internalData->subnetMask_AP3)); + snprintf(&_subnetMaskString[32], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); +} + +ClientFirmwareControl::~ClientFirmwareControl() +{ + free(this->_internalData); + this->_internalData = NULL; +} + +void ClientFirmwareControl::WriteMACAddressStringToBuffer(const uint8_t mac4, const uint8_t mac5, const uint8_t mac6, char *stringBuffer) +{ + if (stringBuffer == NULL) + { + return; + } + + snprintf(stringBuffer, 18, "00:09:BF:%02X:%02X:%02X", mac4, mac5, mac6); +} + +void ClientFirmwareControl::WriteMACAddressStringToBuffer(const uint32_t macAddressValue, char *stringBuffer) +{ + if (stringBuffer == NULL) + { + return; + } + + const uint8_t mac4 = (macAddressValue >> 8) & 0x000000FF; + const uint8_t mac5 = (macAddressValue >> 16) & 0x000000FF; + const uint8_t mac6 = (macAddressValue >> 24) & 0x000000FF; + + ClientFirmwareControl::WriteMACAddressStringToBuffer(mac4, mac5, mac6, stringBuffer); +} + +void ClientFirmwareControl::WriteWFCUserIDStringToBuffer(const uint64_t wfcUserIDValue, char *stringBuffer) +{ + if (stringBuffer == NULL) + { + return; + } + + const unsigned long long wfcUserIDValuePrint = (wfcUserIDValue & 0x000007FFFFFFFFFFULL) * 1000ULL; + const unsigned long long wfcUserIDValuePrint1 = wfcUserIDValuePrint / 1000000000000ULL; + const unsigned long long wfcUserIDValuePrint2 = (wfcUserIDValuePrint / 100000000ULL) - (wfcUserIDValuePrint1 * 10000ULL); + const unsigned long long wfcUserIDValuePrint3 = (wfcUserIDValuePrint / 10000ULL) - (wfcUserIDValuePrint1 * 100000000ULL) - (wfcUserIDValuePrint2 * 10000ULL); + const unsigned long long wfcUserIDValuePrint4 = wfcUserIDValuePrint - (wfcUserIDValuePrint1 * 1000000000000ULL) - (wfcUserIDValuePrint2 * 100000000ULL) - (wfcUserIDValuePrint3 * 10000ULL); + snprintf(stringBuffer, 20, "%04llu-%04llu-%04llu-%04llu", wfcUserIDValuePrint1, wfcUserIDValuePrint2, wfcUserIDValuePrint3, wfcUserIDValuePrint4); +} + +const FirmwareConfig& ClientFirmwareControl::GetFirmwareConfig() +{ + return *this->_internalData; +} + +uint32_t ClientFirmwareControl::GenerateRandomMACValue() +{ + uint32_t randomMACAddressValue = 0; + + do + { + randomMACAddressValue = (uint32_t)rand() & 0x00FFFFFF; + randomMACAddressValue = (randomMACAddressValue << 8) | 0x000000BF; + } while ( (randomMACAddressValue == 0x000000BF) || (randomMACAddressValue == 0xFFFFFFBF) || ((randomMACAddressValue & 0xF0FFFFFF) == (this->_firmwareMACAddressValue & 0xF0FFFFFF)) || ((randomMACAddressValue & 0xF0FFFFFF) == (this->_customMACAddressValue & 0xF0FFFFFF)) ); + + return randomMACAddressValue; +} + +FirmwareCfgMACAddrSetID ClientFirmwareControl::GetMACAddressSelection() +{ + return this->_macAddressSelection; +} + +void ClientFirmwareControl::SetMACAddressSelection(FirmwareCfgMACAddrSetID addressSetID) +{ + switch (addressSetID) + { + case FirmwareCfgMACAddrSetID_Firmware: + this->_macAddressSelection = FirmwareCfgMACAddrSetID_Firmware; + this->_internalData->MACAddress[0] = 0x00; + this->_internalData->MACAddress[1] = 0x09; + this->_internalData->MACAddress[2] = (uint8_t)( this->_firmwareMACAddressValue & 0x000000FF); + this->_internalData->MACAddress[3] = (uint8_t)((this->_firmwareMACAddressValue >> 8) & 0x000000FF); + this->_internalData->MACAddress[4] = (uint8_t)((this->_firmwareMACAddressValue >> 16) & 0x000000FF); + this->_internalData->MACAddress[5] = (uint8_t)((this->_firmwareMACAddressValue >> 24) & 0x000000FF); + break; + + case FirmwareCfgMACAddrSetID_Custom1: + case FirmwareCfgMACAddrSetID_Custom2: + case FirmwareCfgMACAddrSetID_Custom3: + case FirmwareCfgMACAddrSetID_Custom4: + case FirmwareCfgMACAddrSetID_Custom5: + case FirmwareCfgMACAddrSetID_Custom6: + case FirmwareCfgMACAddrSetID_Custom7: + case FirmwareCfgMACAddrSetID_Custom8: + { + this->_macAddressSelection = addressSetID; + this->_internalData->MACAddress[0] = 0x00; + this->_internalData->MACAddress[1] = 0x09; + this->_internalData->MACAddress[2] = (uint8_t)( this->_customMACAddressValue & 0x000000FF); + this->_internalData->MACAddress[3] = (uint8_t)((this->_customMACAddressValue >> 8) & 0x000000FF); + this->_internalData->MACAddress[4] = (uint8_t)((this->_customMACAddressValue >> 16) & 0x000000FF); + this->_internalData->MACAddress[5] = (uint8_t)((this->_customMACAddressValue >> 24) & 0x000000F0); + + switch (addressSetID) + { + case FirmwareCfgMACAddrSetID_Custom1: this->_internalData->MACAddress[5] += 1; break; + case FirmwareCfgMACAddrSetID_Custom2: this->_internalData->MACAddress[5] += 2; break; + case FirmwareCfgMACAddrSetID_Custom3: this->_internalData->MACAddress[5] += 3; break; + case FirmwareCfgMACAddrSetID_Custom4: this->_internalData->MACAddress[5] += 4; break; + case FirmwareCfgMACAddrSetID_Custom5: this->_internalData->MACAddress[5] += 5; break; + case FirmwareCfgMACAddrSetID_Custom6: this->_internalData->MACAddress[5] += 6; break; + case FirmwareCfgMACAddrSetID_Custom7: this->_internalData->MACAddress[5] += 7; break; + case FirmwareCfgMACAddrSetID_Custom8: this->_internalData->MACAddress[5] += 8; break; + default: break; + } + + break; + } + + default: + break; + } +} + +uint32_t ClientFirmwareControl::GetMACAddressValue(FirmwareCfgMACAddrSetID addressSetID) +{ + switch (addressSetID) + { + case FirmwareCfgMACAddrSetID_Firmware: return this->_firmwareMACAddressValue; + case FirmwareCfgMACAddrSetID_Custom1: return this->_customMACAddressValue + 0x01000000; + case FirmwareCfgMACAddrSetID_Custom2: return this->_customMACAddressValue + 0x02000000; + case FirmwareCfgMACAddrSetID_Custom3: return this->_customMACAddressValue + 0x03000000; + case FirmwareCfgMACAddrSetID_Custom4: return this->_customMACAddressValue + 0x04000000; + case FirmwareCfgMACAddrSetID_Custom5: return this->_customMACAddressValue + 0x05000000; + case FirmwareCfgMACAddrSetID_Custom6: return this->_customMACAddressValue + 0x06000000; + case FirmwareCfgMACAddrSetID_Custom7: return this->_customMACAddressValue + 0x07000000; + case FirmwareCfgMACAddrSetID_Custom8: return this->_customMACAddressValue + 0x08000000; + default: break; + } + + return 0; +} + +const char* ClientFirmwareControl::GetMACAddressString(FirmwareCfgMACAddrSetID addressSetID) +{ + switch (addressSetID) + { + case FirmwareCfgMACAddrSetID_Firmware: return &this->_macAddressString[18*0]; + case FirmwareCfgMACAddrSetID_Custom1: return &this->_macAddressString[18*1]; + case FirmwareCfgMACAddrSetID_Custom2: return &this->_macAddressString[18*2]; + case FirmwareCfgMACAddrSetID_Custom3: return &this->_macAddressString[18*3]; + case FirmwareCfgMACAddrSetID_Custom4: return &this->_macAddressString[18*4]; + case FirmwareCfgMACAddrSetID_Custom5: return &this->_macAddressString[18*5]; + case FirmwareCfgMACAddrSetID_Custom6: return &this->_macAddressString[18*6]; + case FirmwareCfgMACAddrSetID_Custom7: return &this->_macAddressString[18*7]; + case FirmwareCfgMACAddrSetID_Custom8: return &this->_macAddressString[18*8]; + default: break; + } + + return ""; +} + +uint32_t ClientFirmwareControl::GetSelectedMACAddressValue() +{ + const uint32_t selectedMACAddressValue = (uint32_t)this->_internalData->MACAddress[2] | ((uint32_t)this->_internalData->MACAddress[3] << 8) | ((uint32_t)this->_internalData->MACAddress[4] << 16) | ((uint32_t)this->_internalData->MACAddress[5] << 24); + return selectedMACAddressValue; +} + +uint64_t ClientFirmwareControl::GetSelectedWFCUserID64() +{ + const uint64_t selectedUserID64 = (uint64_t)this->_internalData->WFCUserID[0] | + ((uint64_t)this->_internalData->WFCUserID[1] << 8) | + ((uint64_t)this->_internalData->WFCUserID[2] << 16) | + ((uint64_t)this->_internalData->WFCUserID[3] << 24) | + ((uint64_t)this->_internalData->WFCUserID[4] << 32) | + ((uint64_t)this->_internalData->WFCUserID[5] << 40); + return selectedUserID64; +} + +const char* ClientFirmwareControl::GetSelectedMACAddressString() +{ + return this->GetMACAddressString(this->_macAddressSelection); +} + +void ClientFirmwareControl::SetFirmwareMACAddressValue(uint32_t macAddressValue) +{ + const uint8_t mac4 = (macAddressValue >> 8) & 0x000000FF; + const uint8_t mac5 = (macAddressValue >> 16) & 0x000000FF; + const uint8_t mac6 = (macAddressValue >> 24) & 0x000000FF; + + this->SetFirmwareMACAddressValue(mac4, mac5, mac6); +} + +void ClientFirmwareControl::SetFirmwareMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6) +{ + this->_firmwareMACAddressValue = 0x000000BF | ((uint32_t)mac4 << 8) | ((uint32_t)mac5 << 16) | ((uint32_t)mac6 << 24); + ClientFirmwareControl::WriteMACAddressStringToBuffer(mac4, mac5, mac6, &this->_macAddressString[0]); + + if (this->_macAddressSelection == FirmwareCfgMACAddrSetID_Firmware) + { + this->SetMACAddressSelection(FirmwareCfgMACAddrSetID_Firmware); + } +} + +void ClientFirmwareControl::SetCustomMACAddressValue(uint32_t macAddressValue) +{ + const uint8_t mac4 = (macAddressValue >> 8) & 0x000000FF; + const uint8_t mac5 = (macAddressValue >> 16) & 0x000000FF; + const uint8_t mac6 = (macAddressValue >> 24) & 0x000000F0; + + this->SetCustomMACAddressValue(mac4, mac5, mac6); +} + +void ClientFirmwareControl::SetCustomMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6) +{ + mac6 &= 0xF0; + this->_customMACAddressValue = 0x000000BF | ((uint32_t)mac4 << 8) | ((uint32_t)mac5 << 16) | ((uint32_t)mac6 << 24); + + for (size_t i = 1; i <= 8; i++) + { + ClientFirmwareControl::WriteMACAddressStringToBuffer(mac4, mac5, mac6 + (uint8_t)i, &this->_macAddressString[18*i]); + } + + if (this->_macAddressSelection != FirmwareCfgMACAddrSetID_Firmware) + { + this->SetMACAddressSelection(this->_macAddressSelection); + } +} + +uint8_t* ClientFirmwareControl::GetWFCUserID() +{ + return this->_internalData->WFCUserID; +} + +void ClientFirmwareControl::SetWFCUserID(uint8_t *wfcUserID) +{ + const uint64_t wfcUserIDValue = (uint64_t)wfcUserID[0] | + ((uint64_t)wfcUserID[1] << 8) | + ((uint64_t)wfcUserID[2] << 16) | + ((uint64_t)wfcUserID[3] << 24) | + ((uint64_t)wfcUserID[4] << 32) | + ((uint64_t)wfcUserID[5] << 40); + + this->SetWFCUserID64(wfcUserIDValue); +} + +uint64_t ClientFirmwareControl::GetWFCUserID64() +{ + const uint64_t userID = (uint64_t)this->_internalData->WFCUserID[0] | + ((uint64_t)this->_internalData->WFCUserID[1] << 8) | + ((uint64_t)this->_internalData->WFCUserID[2] << 16) | + ((uint64_t)this->_internalData->WFCUserID[3] << 24) | + ((uint64_t)this->_internalData->WFCUserID[4] << 32) | + ((uint64_t)this->_internalData->WFCUserID[5] << 40); + return userID; +} + +void ClientFirmwareControl::SetWFCUserID64(uint64_t wfcUserIDValue) +{ + if ( (wfcUserIDValue & 0x000007FFFFFFFFFFULL) != 0) + { + this->_internalData->WFCUserID[0] = (uint8_t)( wfcUserIDValue & 0x00000000000000FFULL); + this->_internalData->WFCUserID[1] = (uint8_t)((wfcUserIDValue >> 8) & 0x00000000000000FFULL); + this->_internalData->WFCUserID[2] = (uint8_t)((wfcUserIDValue >> 16) & 0x00000000000000FFULL); + this->_internalData->WFCUserID[3] = (uint8_t)((wfcUserIDValue >> 24) & 0x00000000000000FFULL); + this->_internalData->WFCUserID[4] = (uint8_t)((wfcUserIDValue >> 32) & 0x00000000000000FFULL); + this->_internalData->WFCUserID[5] = (uint8_t)((wfcUserIDValue >> 40) & 0x00000000000000FFULL); + } + else + { + this->_internalData->WFCUserID[0] = 0; + this->_internalData->WFCUserID[1] = 0; + this->_internalData->WFCUserID[2] = 0; + this->_internalData->WFCUserID[3] = 0; + this->_internalData->WFCUserID[4] = 0; + this->_internalData->WFCUserID[5] = 0; + } + + ClientFirmwareControl::WriteWFCUserIDStringToBuffer(wfcUserIDValue, this->_wfcUserIDString); +} + +const char* ClientFirmwareControl::GetWFCUserIDString() +{ + return this->_wfcUserIDString; +} + +uint8_t ClientFirmwareControl::GetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart) +{ + if (addrPart > 3) + { + return 0; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: return this->_internalData->ipv4Address_AP1[addrPart]; + case FirmwareCfgAPID_AP2: return this->_internalData->ipv4Address_AP2[addrPart]; + case FirmwareCfgAPID_AP3: return this->_internalData->ipv4Address_AP3[addrPart]; + } + + return 0; +} + +void ClientFirmwareControl::SetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) +{ + if (addrPart > 3) + { + return; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: this->_internalData->ipv4Address_AP1[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP2: this->_internalData->ipv4Address_AP2[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP3: this->_internalData->ipv4Address_AP3[addrPart] = addrValue; break; + } +} + +uint8_t ClientFirmwareControl::GetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart) +{ + if (addrPart > 3) + { + return 0; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: return this->_internalData->ipv4Gateway_AP1[addrPart]; + case FirmwareCfgAPID_AP2: return this->_internalData->ipv4Gateway_AP2[addrPart]; + case FirmwareCfgAPID_AP3: return this->_internalData->ipv4Gateway_AP3[addrPart]; + } + + return 0; +} + +void ClientFirmwareControl::SetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) +{ + if (addrPart > 3) + { + return; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: this->_internalData->ipv4Gateway_AP1[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP2: this->_internalData->ipv4Gateway_AP2[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP3: this->_internalData->ipv4Gateway_AP3[addrPart] = addrValue; break; + } +} + +uint8_t ClientFirmwareControl::GetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart) +{ + if (addrPart > 3) + { + return 0; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: return this->_internalData->ipv4PrimaryDNS_AP1[addrPart]; + case FirmwareCfgAPID_AP2: return this->_internalData->ipv4PrimaryDNS_AP2[addrPart]; + case FirmwareCfgAPID_AP3: return this->_internalData->ipv4PrimaryDNS_AP3[addrPart]; + } + + return 0; +} + +void ClientFirmwareControl::SetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) +{ + if (addrPart > 3) + { + return; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: this->_internalData->ipv4PrimaryDNS_AP1[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP2: this->_internalData->ipv4PrimaryDNS_AP2[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP3: this->_internalData->ipv4PrimaryDNS_AP3[addrPart] = addrValue; break; + } +} + +uint8_t ClientFirmwareControl::GetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart) +{ + if (addrPart > 3) + { + return 0; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: return this->_internalData->ipv4SecondaryDNS_AP1[addrPart]; + case FirmwareCfgAPID_AP2: return this->_internalData->ipv4SecondaryDNS_AP2[addrPart]; + case FirmwareCfgAPID_AP3: return this->_internalData->ipv4SecondaryDNS_AP3[addrPart]; + } + + return 0; +} + +void ClientFirmwareControl::SetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) +{ + if (addrPart > 3) + { + return; + } + + switch (apid) + { + case FirmwareCfgAPID_AP1: this->_internalData->ipv4SecondaryDNS_AP1[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP2: this->_internalData->ipv4SecondaryDNS_AP2[addrPart] = addrValue; break; + case FirmwareCfgAPID_AP3: this->_internalData->ipv4SecondaryDNS_AP3[addrPart] = addrValue; break; + } +} + +uint8_t ClientFirmwareControl::GetSubnetMask(FirmwareCfgAPID apid) +{ + switch (apid) + { + case FirmwareCfgAPID_AP1: return this->_internalData->subnetMask_AP1; + case FirmwareCfgAPID_AP2: return this->_internalData->subnetMask_AP2; + case FirmwareCfgAPID_AP3: return this->_internalData->subnetMask_AP3; + } + + return 0; +} + +const char* ClientFirmwareControl::GetSubnetMaskString(FirmwareCfgAPID apid) +{ + switch (apid) + { + case FirmwareCfgAPID_AP1: return &this->_subnetMaskString[0]; + case FirmwareCfgAPID_AP2: return &this->_subnetMaskString[16]; + case FirmwareCfgAPID_AP3: return &this->_subnetMaskString[32]; + } + + return ""; +} + +void ClientFirmwareControl::SetSubnetMask(FirmwareCfgAPID apid, uint8_t subnetMaskShift) +{ + if (subnetMaskShift > 28) + { + subnetMaskShift = 28; + } + + int subnetMaskCharIndex = -1; + uint32_t subnetMaskValue = 0; + + switch (apid) + { + case FirmwareCfgAPID_AP1: + this->_internalData->subnetMask_AP1 = subnetMaskShift; + subnetMaskCharIndex = 0; + break; + + case FirmwareCfgAPID_AP2: + this->_internalData->subnetMask_AP2 = subnetMaskShift; + subnetMaskCharIndex = 16; + break; + + case FirmwareCfgAPID_AP3: + this->_internalData->subnetMask_AP3 = subnetMaskShift; + subnetMaskCharIndex = 32; + break; + } + + if ( (subnetMaskCharIndex >= 0) && (subnetMaskCharIndex <= 32) ) + { + subnetMaskValue = (subnetMaskShift == 0) ? 0 : (0xFFFFFFFF << (32 - subnetMaskShift)); + memset(&this->_subnetMaskString[subnetMaskCharIndex], '\0', 16 * sizeof(char)); + snprintf(&this->_subnetMaskString[subnetMaskCharIndex], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); + } +} + +int ClientFirmwareControl::GetConsoleType() +{ + return (int)this->_internalData->consoleType; +} + +void ClientFirmwareControl::SetConsoleType(int type) +{ + this->_internalData->consoleType = (uint8_t)type; +} + +uint16_t* ClientFirmwareControl::GetNicknameStringBuffer() +{ + return this->_internalData->nickname; +} + +void ClientFirmwareControl::SetNicknameWithStringBuffer(uint16_t *buffer, size_t charLength) +{ + size_t i = 0; + + if (buffer != NULL) + { + if (charLength > MAX_FW_NICKNAME_LENGTH) + { + charLength = MAX_FW_NICKNAME_LENGTH; + } + + for (; i < charLength; i++) + { + this->_internalData->nickname[i] = buffer[i]; + } + } + else + { + charLength = 0; + } + + for (; i < MAX_FW_NICKNAME_LENGTH+1; i++) + { + this->_internalData->nickname[i] = 0; + } + + this->_internalData->nicknameLength = charLength; +} + +size_t ClientFirmwareControl::GetNicknameStringLength() +{ + return (size_t)this->_internalData->nicknameLength; +} + +void ClientFirmwareControl::SetNicknameStringLength(size_t charLength) +{ + if (charLength > MAX_FW_NICKNAME_LENGTH) + { + charLength = MAX_FW_NICKNAME_LENGTH; + } + + this->_internalData->nicknameLength = charLength; +} + +uint16_t* ClientFirmwareControl::GetMessageStringBuffer() +{ + return this->_internalData->message; +} + +void ClientFirmwareControl::SetMessageWithStringBuffer(uint16_t *buffer, size_t charLength) +{ + size_t i = 0; + + if (buffer != NULL) + { + if (charLength > MAX_FW_MESSAGE_LENGTH) + { + charLength = MAX_FW_MESSAGE_LENGTH; + } + + for (; i < charLength; i++) + { + this->_internalData->message[i] = buffer[i]; + } + } + else + { + charLength = 0; + } + + for (; i < MAX_FW_MESSAGE_LENGTH+1; i++) + { + this->_internalData->message[i] = 0; + } + + this->_internalData->messageLength = charLength; +} + +size_t ClientFirmwareControl::GetMessageStringLength() +{ + return (size_t)this->_internalData->messageLength; +} + +void ClientFirmwareControl::SetMessageStringLength(size_t charLength) +{ + if (charLength > MAX_FW_MESSAGE_LENGTH) + { + charLength = MAX_FW_MESSAGE_LENGTH; + } + + this->_internalData->messageLength = charLength; +} + +int ClientFirmwareControl::GetFavoriteColorByID() +{ + return (int)this->_internalData->favoriteColor; +} + +void ClientFirmwareControl::SetFavoriteColorByID(int colorID) +{ + this->_internalData->favoriteColor = (uint8_t)colorID; +} + +int ClientFirmwareControl::GetBirthdayDay() +{ + return (int)this->_internalData->birthdayDay; +} + +void ClientFirmwareControl::SetBirthdayDay(int day) +{ + if (day < 1) + { + day = 1; + } + + switch (this->_internalData->birthdayMonth) + { + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + { + if (day > 31) day = 31; + break; + } + + case 4: + case 6: + case 9: + case 11: + { + if (day > 30) day = 30; + break; + } + + case 2: + { + if (day > 29) day = 29; + break; + } + + default: + break; + } + + this->_internalData->birthdayDay = (uint8_t)day; +} + +int ClientFirmwareControl::GetBirthdayMonth() +{ + return (int)this->_internalData->birthdayMonth; +} + +void ClientFirmwareControl::SetBirthdayMonth(int month) +{ + if (month < 1) + { + month = 1; + } + else if (month > 12) + { + month = 12; + } + + this->_internalData->birthdayMonth = (uint8_t)month; +} + +int ClientFirmwareControl::GetLanguageByID() +{ + return (int)this->_internalData->language; +} + +void ClientFirmwareControl::SetLanguageByID(int languageID) +{ + this->_internalData->language = (uint8_t)languageID; +} + +int ClientFirmwareControl::GetBacklightLevel() +{ + return (int)this->_internalData->backlightLevel; +} + +void ClientFirmwareControl::SetBacklightLevel(int level) +{ + this->_internalData->backlightLevel = (uint8_t)level; +} diff --git a/desmume/src/frontend/cocoa/ClientFirmwareControl.h b/desmume/src/frontend/cocoa/ClientFirmwareControl.h new file mode 100644 index 000000000..fcef544ff --- /dev/null +++ b/desmume/src/frontend/cocoa/ClientFirmwareControl.h @@ -0,0 +1,139 @@ +/* + Copyright (C) 2025 DeSmuME team + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the this software. If not, see . + */ + +#ifndef _CLIENT_FIRMWARE_CONTROL_H_ +#define _CLIENT_FIRMWARE_CONTROL_H_ + +#include +#include + + +struct FirmwareConfig; + +enum FirmwareCfgAPID +{ + FirmwareCfgAPID_AP1 = 0, + FirmwareCfgAPID_AP2 = 1, + FirmwareCfgAPID_AP3 = 2 +}; + +enum FirmwareCfgMACAddrSetID +{ + FirmwareCfgMACAddrSetID_Firmware = 0, + FirmwareCfgMACAddrSetID_Custom1 = 1, + FirmwareCfgMACAddrSetID_Custom2 = 2, + FirmwareCfgMACAddrSetID_Custom3 = 3, + FirmwareCfgMACAddrSetID_Custom4 = 4, + FirmwareCfgMACAddrSetID_Custom5 = 5, + FirmwareCfgMACAddrSetID_Custom6 = 6, + FirmwareCfgMACAddrSetID_Custom7 = 7, + FirmwareCfgMACAddrSetID_Custom8 = 8 +}; + +class ClientFirmwareControl +{ +protected: + FirmwareConfig *_internalData; + + FirmwareCfgMACAddrSetID _macAddressSelection; + uint32_t _firmwareMACAddressValue; + uint32_t _customMACAddressValue; + char _macAddressString[(1 + 8) * 18]; + char _wfcUserIDString[20]; + char _subnetMaskString[3 * 16]; + +public: + ClientFirmwareControl(); + ~ClientFirmwareControl(); + + static void WriteMACAddressStringToBuffer(const uint8_t mac4, const uint8_t mac5, const uint8_t mac6, char *stringBuffer); + static void WriteMACAddressStringToBuffer(const uint32_t macAddressValue, char *stringBuffer); + static void WriteWFCUserIDStringToBuffer(const uint64_t wfcUserIDValue, char *stringBuffer); + + const FirmwareConfig& GetFirmwareConfig(); + uint32_t GenerateRandomMACValue(); + + FirmwareCfgMACAddrSetID GetMACAddressSelection(); + void SetMACAddressSelection(FirmwareCfgMACAddrSetID addressSetID); + + uint32_t GetMACAddressValue(FirmwareCfgMACAddrSetID addressSetID); + const char* GetMACAddressString(FirmwareCfgMACAddrSetID addressSetID); + uint32_t GetSelectedMACAddressValue(); + uint64_t GetSelectedWFCUserID64(); + const char* GetSelectedMACAddressString(); + + void SetFirmwareMACAddressValue(uint32_t macAddressValue); + void SetFirmwareMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6); + void SetCustomMACAddressValue(uint32_t macAddressValue); + void SetCustomMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6); + + uint8_t* GetWFCUserID(); + void SetWFCUserID(uint8_t *wfcUserID); + + uint64_t GetWFCUserID64(); + void SetWFCUserID64(uint64_t wfcUserIDValue); + + const char* GetWFCUserIDString(); + + uint8_t GetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart); + void SetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); + + uint8_t GetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart); + void SetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); + + uint8_t GetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart); + void SetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); + + uint8_t GetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart); + void SetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); + + uint8_t GetSubnetMask(FirmwareCfgAPID apid); + const char* GetSubnetMaskString(FirmwareCfgAPID apid); + void SetSubnetMask(FirmwareCfgAPID apid, uint8_t subnetMaskShift); + + int GetConsoleType(); + void SetConsoleType(int type); + + uint16_t* GetNicknameStringBuffer(); + void SetNicknameWithStringBuffer(uint16_t *buffer, size_t charLength); + + size_t GetNicknameStringLength(); + void SetNicknameStringLength(size_t charLength); + + uint16_t* GetMessageStringBuffer(); + void SetMessageWithStringBuffer(uint16_t *buffer, size_t charLength); + + size_t GetMessageStringLength(); + void SetMessageStringLength(size_t charLength); + + int GetFavoriteColorByID(); + void SetFavoriteColorByID(int colorID); + + int GetBirthdayDay(); + void SetBirthdayDay(int day); + + int GetBirthdayMonth(); + void SetBirthdayMonth(int month); + + int GetLanguageByID(); + void SetLanguageByID(int languageID); + + int GetBacklightLevel(); + void SetBacklightLevel(int level); +}; + +#endif // _CLIENT_FIRMWARE_CONTROL_H_ diff --git a/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj b/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj index a842e0b9e..90cf81113 100755 --- a/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj +++ b/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj @@ -251,7 +251,6 @@ 8C43E83A27E3CD0100A35F65 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; 8C43E83B27E3CD0100A35F65 /* cff.c in Sources */ = {isa = PBXBuildFile; fileRef = ABFEA7B01BB4EC1000B08C25 /* cff.c */; }; 8C43E83C27E3CD0100A35F65 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - 8C43E83D27E3CD0100A35F65 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; 8C43E83E27E3CD0100A35F65 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; 8C43E83F27E3CD0100A35F65 /* file_path.c in Sources */ = {isa = PBXBuildFile; fileRef = AB000DC01CCC6B0700413F02 /* file_path.c */; }; 8C43E84027E3CD0100A35F65 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; }; @@ -567,7 +566,6 @@ 8C43E99F27E3CD4C00A35F65 /* cocoa_input.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104111346652500AF11D1 /* cocoa_input.mm */; }; 8C43E9A127E3CD4C00A35F65 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; 8C43E9A227E3CD4C00A35F65 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - 8C43E9A327E3CD4C00A35F65 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; 8C43E9A427E3CD4C00A35F65 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; 8C43E9A527E3CD4C00A35F65 /* slot1comp_protocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB8B7AAB17CE8C440051CEBF /* slot1comp_protocol.cpp */; }; 8C43E9A627E3CD4C00A35F65 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; @@ -864,7 +862,6 @@ 8CCD84A727E40B730024BDD5 /* deposterize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB301BDE1D9C8BAC00246A93 /* deposterize.cpp */; }; 8CCD84A827E40B730024BDD5 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; 8CCD84A927E40B730024BDD5 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - 8CCD84AA27E40B730024BDD5 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; 8CCD84AB27E40B730024BDD5 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; 8CCD84AC27E40B730024BDD5 /* slot1comp_protocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB8B7AAB17CE8C440051CEBF /* slot1comp_protocol.cpp */; }; 8CCD84AD27E40B730024BDD5 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; @@ -1218,7 +1215,6 @@ AB36C82727F2C8AE00C763C8 /* deposterize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB301BDE1D9C8BAC00246A93 /* deposterize.cpp */; }; AB36C82827F2C8AE00C763C8 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB36C82927F2C8AE00C763C8 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB36C82A27F2C8AE00C763C8 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB36C82B27F2C8AE00C763C8 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; AB36C82C27F2C8AE00C763C8 /* slot1comp_protocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB8B7AAB17CE8C440051CEBF /* slot1comp_protocol.cpp */; }; AB36C82D27F2C8AE00C763C8 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; @@ -1560,6 +1556,28 @@ AB6E18092A6B218D003A564D /* CheatDatabaseViewer.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB6E17FF2A6B218D003A564D /* CheatDatabaseViewer.xib */; }; AB6E180A2A6B218D003A564D /* CheatDatabaseViewer.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB6E17FF2A6B218D003A564D /* CheatDatabaseViewer.xib */; }; AB6E180B2A6B218D003A564D /* CheatDatabaseViewer.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB6E17FF2A6B218D003A564D /* CheatDatabaseViewer.xib */; }; + AB6E3B462E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B472E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B482E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B492E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B4A2E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B4B2E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B4C2E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B4D2E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B4E2E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B4F2E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B502E7385710088075E /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */; }; + AB6E3B532E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B542E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B552E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B562E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B572E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B582E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B592E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B5A2E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B5B2E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B5C2E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; + AB6E3B5D2E73E7C80088075E /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */; }; AB74EC8A1738499C0026C41E /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB74EC891738499C0026C41E /* Carbon.framework */; }; AB78B5C11E384F2100297FED /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB3BF4401E262943003E2B24 /* Metal.framework */; settings = {ATTRIBUTES = (Required, ); }; }; AB78B5C21E384F2200297FED /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB3BF4401E262943003E2B24 /* Metal.framework */; settings = {ATTRIBUTES = (Required, ); }; }; @@ -1780,7 +1798,6 @@ AB7900D7215B84E50082AE82 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB7900D8215B84E50082AE82 /* cff.c in Sources */ = {isa = PBXBuildFile; fileRef = ABFEA7B01BB4EC1000B08C25 /* cff.c */; }; AB7900D9215B84E50082AE82 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB7900DA215B84E50082AE82 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB7900DB215B84E50082AE82 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; AB7900DC215B84E50082AE82 /* file_path.c in Sources */ = {isa = PBXBuildFile; fileRef = AB000DC01CCC6B0700413F02 /* file_path.c */; }; AB7900DD215B84E50082AE82 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; }; @@ -2124,7 +2141,6 @@ AB79023B215B84F20082AE82 /* cocoa_input.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104111346652500AF11D1 /* cocoa_input.mm */; }; AB79023D215B84F20082AE82 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB79023E215B84F20082AE82 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB79023F215B84F20082AE82 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB790240215B84F20082AE82 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; AB790241215B84F20082AE82 /* slot1comp_protocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB8B7AAB17CE8C440051CEBF /* slot1comp_protocol.cpp */; }; AB790242215B84F20082AE82 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; @@ -2373,7 +2389,6 @@ AB796D4F15CDCBA200C59155 /* cocoa_input.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104111346652500AF11D1 /* cocoa_input.mm */; }; AB796D5215CDCBA200C59155 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB796D5315CDCBA200C59155 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB796D5415CDCBA200C59155 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB796D5515CDCBA200C59155 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; AB796D5615CDCBA200C59155 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; }; AB796D5915CDCBA200C59155 /* inputPrefsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */; }; @@ -2674,7 +2689,6 @@ AB8F3CDB1A53AC2600A80BF6 /* cocoa_input.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104111346652500AF11D1 /* cocoa_input.mm */; }; AB8F3CDD1A53AC2600A80BF6 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB8F3CDE1A53AC2600A80BF6 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB8F3CDF1A53AC2600A80BF6 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB8F3CE01A53AC2600A80BF6 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; AB8F3CE11A53AC2600A80BF6 /* slot1comp_protocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB8B7AAB17CE8C440051CEBF /* slot1comp_protocol.cpp */; }; AB8F3CE21A53AC2600A80BF6 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; @@ -3261,7 +3275,6 @@ ABC8592628273FEE00A03EA9 /* deposterize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB301BDE1D9C8BAC00246A93 /* deposterize.cpp */; }; ABC8592728273FEE00A03EA9 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; ABC8592828273FEE00A03EA9 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - ABC8592928273FEE00A03EA9 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; ABC8592A28273FEE00A03EA9 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; ABC8592B28273FEE00A03EA9 /* slot1comp_protocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB8B7AAB17CE8C440051CEBF /* slot1comp_protocol.cpp */; }; ABC8592C28273FEE00A03EA9 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; @@ -3611,7 +3624,6 @@ ABD2CDDA26E05CB000FB15F7 /* deposterize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB301BDE1D9C8BAC00246A93 /* deposterize.cpp */; }; ABD2CDDB26E05CB000FB15F7 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; ABD2CDDC26E05CB000FB15F7 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - ABD2CDDD26E05CB000FB15F7 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; ABD2CDDE26E05CB000FB15F7 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; ABD2CDDF26E05CB000FB15F7 /* slot1comp_protocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB8B7AAB17CE8C440051CEBF /* slot1comp_protocol.cpp */; }; ABD2CDE026E05CB000FB15F7 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; @@ -4088,6 +4100,10 @@ AB6E17F32A675BF1003A564D /* CheatDatabaseWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CheatDatabaseWindowController.h; sourceTree = ""; }; AB6E17F42A675BF1003A564D /* CheatDatabaseWindowController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CheatDatabaseWindowController.mm; sourceTree = ""; }; AB6E18002A6B218D003A564D /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = translations/English.lproj/CheatDatabaseViewer.xib; sourceTree = ""; }; + AB6E3B442E7385710088075E /* ClientFirmwareControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientFirmwareControl.h; sourceTree = ""; }; + AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ClientFirmwareControl.cpp; sourceTree = ""; }; + AB6E3B512E73E7C80088075E /* ClientCheatManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientCheatManager.h; sourceTree = ""; }; + AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ClientCheatManager.cpp; sourceTree = ""; }; AB6FBEF5139B6258007BB045 /* slot1_retail_nand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slot1_retail_nand.cpp; sourceTree = ""; }; AB74EC891738499C0026C41E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; AB75226D14C7BB51009B97B3 /* AppIcon_FirmwareConfig.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon_FirmwareConfig.icns; sourceTree = ""; }; @@ -4476,8 +4492,6 @@ ABDDF7C81898F032007583C1 /* Icon_FrameJump_420x420.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_FrameJump_420x420.png; path = images/Icon_FrameJump_420x420.png; sourceTree = ""; }; ABDE648E2E21068500C03E0B /* GPU_Operations_AltiVec.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPU_Operations_AltiVec.h; sourceTree = ""; }; ABDE648F2E21068500C03E0B /* GPU_Operations_AltiVec.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPU_Operations_AltiVec.cpp; sourceTree = ""; }; - ABE5DFE3143FB1DA00835AD8 /* cocoa_videofilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_videofilter.h; sourceTree = ""; }; - ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cocoa_videofilter.mm; sourceTree = ""; }; ABE670251415DE6C00E8E4C9 /* tinystr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinystr.cpp; sourceTree = ""; }; ABE670261415DE6C00E8E4C9 /* tinystr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tinystr.h; sourceTree = ""; }; ABE670271415DE6C00E8E4C9 /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml.cpp; sourceTree = ""; }; @@ -4888,9 +4902,11 @@ ABD10AE51715FCDD00B5729D /* audiosamplegenerator.cpp */, AB79913E2E712F510030C0A6 /* ClientAudioOutput.cpp */, AB28625720AE3E9F00EAED43 /* ClientAVCaptureObject.cpp */, + AB6E3B522E73E7C80088075E /* ClientCheatManager.cpp */, ABAD07DA1E19CAA6007867CA /* ClientDisplayView.cpp */, ABDB1BE12E6602A5002AD9AF /* ClientEmulationOutput.cpp */, ABB1C9461F5281AE0004844F /* ClientExecutionControl.cpp */, + AB6E3B452E7385710088075E /* ClientFirmwareControl.cpp */, AB11AD871F6757F800CB298E /* ClientInputHandler.cpp */, ABDB1BEE2E66486E002AD9AF /* ClientVideoOutput.cpp */, AB1B9E5F1501A78000464647 /* coreaudiosound.cpp */, @@ -4904,11 +4920,13 @@ ABD10AE31715FCDD00B5729D /* audiosamplegenerator.h */, AB79913D2E712F510030C0A6 /* ClientAudioOutput.h */, AB28625820AE3E9F00EAED43 /* ClientAVCaptureObject.h */, + AB6E3B512E73E7C80088075E /* ClientCheatManager.h */, ABAD07DB1E19CAA6007867CA /* ClientDisplayView.h */, ABDB1BE02E6602A5002AD9AF /* ClientEmulationOutput.h */, - ABDB1BED2E66486E002AD9AF /* ClientVideoOutput.h */, ABB1C9471F5281AE0004844F /* ClientExecutionControl.h */, + AB6E3B442E7385710088075E /* ClientFirmwareControl.h */, AB11AD881F6757F800CB298E /* ClientInputHandler.h */, + ABDB1BED2E66486E002AD9AF /* ClientVideoOutput.h */, ABA6574914511EC90077E5E9 /* cocoa_cheat.h */, ABD103FE1346652500AF11D1 /* cocoa_core.h */, AB58F32B1364F44B0074C376 /* cocoa_file.h */, @@ -4919,7 +4937,6 @@ ABD104001346652500AF11D1 /* cocoa_rom.h */, AB5648FD186E6EA8002740F4 /* cocoa_slot2.h */, AB80E050142BC4FA00A52038 /* cocoa_util.h */, - ABE5DFE3143FB1DA00835AD8 /* cocoa_videofilter.h */, AB1B9E611501A78000464647 /* coreaudiosound.h */, AB28625520AE3E9E00EAED43 /* macOS_driver.h */, AB5B1D4821D1F31D00BF0E0F /* MetalRendererCommonShaders.h */, @@ -4939,7 +4956,6 @@ ABD104131346652500AF11D1 /* cocoa_rom.mm */, AB5648FE186E6EA8002740F4 /* cocoa_slot2.mm */, AB80E04C142BC4A800A52038 /* cocoa_util.mm */, - ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */, ); name = "Cocoa Port"; sourceTree = ""; @@ -8023,6 +8039,7 @@ 8C43E7D127E3CD0100A35F65 /* ftbase.c in Sources */, 8C43E7D227E3CD0100A35F65 /* fatfile.cpp in Sources */, 8C43E7D327E3CD0100A35F65 /* FIFO.cpp in Sources */, + AB6E3B582E73E7C80088075E /* ClientCheatManager.cpp in Sources */, ABDB1BF72E66486E002AD9AF /* ClientVideoOutput.cpp in Sources */, 8C43E7D427E3CD0100A35F65 /* sfnt.c in Sources */, 8C43E7D527E3CD0100A35F65 /* truetype.c in Sources */, @@ -8102,6 +8119,7 @@ 8C43E81D27E3CD0100A35F65 /* TDStretch.cpp in Sources */, 8C43E81E27E3CD0100A35F65 /* texcache.cpp in Sources */, 8C43E81F27E3CD0100A35F65 /* async_job.c in Sources */, + AB6E3B462E7385710088075E /* ClientFirmwareControl.cpp in Sources */, 8C43E82027E3CD0100A35F65 /* thumb_instructions.cpp in Sources */, 8C43E82127E3CD0100A35F65 /* advanscene.cpp in Sources */, 8C43E82227E3CD0100A35F65 /* ClientInputHandler.cpp in Sources */, @@ -8133,7 +8151,6 @@ 8C43E83A27E3CD0100A35F65 /* cocoa_rom.mm in Sources */, 8C43E83B27E3CD0100A35F65 /* cff.c in Sources */, 8C43E83C27E3CD0100A35F65 /* cocoa_util.mm in Sources */, - 8C43E83D27E3CD0100A35F65 /* cocoa_videofilter.mm in Sources */, 8C43E83E27E3CD0100A35F65 /* appDelegate.mm in Sources */, 8C43E83F27E3CD0100A35F65 /* file_path.c in Sources */, 8C43E84027E3CD0100A35F65 /* cheatWindowDelegate.mm in Sources */, @@ -8237,6 +8254,7 @@ 8C43E93627E3CD4C00A35F65 /* debug.cpp in Sources */, 8C43E93727E3CD4C00A35F65 /* decrypt.cpp in Sources */, 8C43E93827E3CD4C00A35F65 /* rthreads.c in Sources */, + AB6E3B502E7385710088075E /* ClientFirmwareControl.cpp in Sources */, 8C43E93927E3CD4C00A35F65 /* directory.cpp in Sources */, 8C43E93A27E3CD4C00A35F65 /* Disassembler.cpp in Sources */, 8C43E93B27E3CD4C00A35F65 /* RomInfoPanel.mm in Sources */, @@ -8307,6 +8325,7 @@ 8C43E97827E3CD4C00A35F65 /* slot2_rumblepak.cpp in Sources */, 8C43E97927E3CD4C00A35F65 /* sndOSX.cpp in Sources */, 8C43E97A27E3CD4C00A35F65 /* SndOut.cpp in Sources */, + AB6E3B542E73E7C80088075E /* ClientCheatManager.cpp in Sources */, AB6E17F82A675BF1003A564D /* CheatDatabaseWindowController.mm in Sources */, 8C43E97B27E3CD4C00A35F65 /* psnames.c in Sources */, 8C43E97C27E3CD4C00A35F65 /* Slot2WindowDelegate.mm in Sources */, @@ -8347,7 +8366,6 @@ 8C43E99F27E3CD4C00A35F65 /* cocoa_input.mm in Sources */, 8C43E9A127E3CD4C00A35F65 /* cocoa_rom.mm in Sources */, 8C43E9A227E3CD4C00A35F65 /* cocoa_util.mm in Sources */, - 8C43E9A327E3CD4C00A35F65 /* cocoa_videofilter.mm in Sources */, 8C43E9A427E3CD4C00A35F65 /* OGLRender.cpp in Sources */, 8C43E9A527E3CD4C00A35F65 /* slot1comp_protocol.cpp in Sources */, 8C43E9A627E3CD4C00A35F65 /* appDelegate.mm in Sources */, @@ -8434,6 +8452,7 @@ 8CCD844227E40B730024BDD5 /* firmware.cpp in Sources */, 8CCD844327E40B730024BDD5 /* async_job.c in Sources */, 8CCD844427E40B730024BDD5 /* gfx3d.cpp in Sources */, + AB6E3B592E73E7C80088075E /* ClientCheatManager.cpp in Sources */, ABDB1BF52E66486E002AD9AF /* ClientVideoOutput.cpp in Sources */, 8CCD844527E40B730024BDD5 /* DisplayViewCALayer.mm in Sources */, 8CCD844627E40B730024BDD5 /* GPU.cpp in Sources */, @@ -8513,6 +8532,7 @@ 8CCD848E27E40B730024BDD5 /* psnames.c in Sources */, 8CCD848F27E40B730024BDD5 /* ftpatent.c in Sources */, 8CCD849027E40B730024BDD5 /* version.cpp in Sources */, + AB6E3B4D2E7385710088075E /* ClientFirmwareControl.cpp in Sources */, 8CCD849127E40B730024BDD5 /* vfat.cpp in Sources */, 8CCD849227E40B730024BDD5 /* videofilter.cpp in Sources */, 8CCD849327E40B730024BDD5 /* ClientInputHandler.cpp in Sources */, @@ -8540,7 +8560,6 @@ 8CCD84A727E40B730024BDD5 /* deposterize.cpp in Sources */, 8CCD84A827E40B730024BDD5 /* cocoa_rom.mm in Sources */, 8CCD84A927E40B730024BDD5 /* cocoa_util.mm in Sources */, - 8CCD84AA27E40B730024BDD5 /* cocoa_videofilter.mm in Sources */, 8CCD84AB27E40B730024BDD5 /* OGLRender.cpp in Sources */, 8CCD84AC27E40B730024BDD5 /* slot1comp_protocol.cpp in Sources */, 8CCD84AD27E40B730024BDD5 /* appDelegate.mm in Sources */, @@ -8623,6 +8642,7 @@ AB36C7B127F2C8AE00C763C8 /* Disassembler.cpp in Sources */, AB88005A2AD5EC500090D47F /* slot2_hcv1000.cpp in Sources */, AB36C7B227F2C8AE00C763C8 /* disc.cpp in Sources */, + AB6E3B482E7385710088075E /* ClientFirmwareControl.cpp in Sources */, AB36C7B327F2C8AE00C763C8 /* dlditool.cpp in Sources */, AB36C7B427F2C8AE00C763C8 /* driver.cpp in Sources */, AB36C7B527F2C8AE00C763C8 /* emufat.cpp in Sources */, @@ -8718,6 +8738,7 @@ AB36C80D27F2C8AE00C763C8 /* WifiSettingsPanel.mm in Sources */, AB36C80E27F2C8AE00C763C8 /* psnames.c in Sources */, AB36C80F27F2C8AE00C763C8 /* ftpatent.c in Sources */, + AB6E3B5B2E73E7C80088075E /* ClientCheatManager.cpp in Sources */, ABDB1BE92E6602A5002AD9AF /* ClientEmulationOutput.cpp in Sources */, AB36C81027F2C8AE00C763C8 /* version.cpp in Sources */, AB36C81127F2C8AE00C763C8 /* vfat.cpp in Sources */, @@ -8741,7 +8762,6 @@ AB36C82727F2C8AE00C763C8 /* deposterize.cpp in Sources */, AB36C82827F2C8AE00C763C8 /* cocoa_rom.mm in Sources */, AB36C82927F2C8AE00C763C8 /* cocoa_util.mm in Sources */, - AB36C82A27F2C8AE00C763C8 /* cocoa_videofilter.mm in Sources */, AB36C82B27F2C8AE00C763C8 /* OGLRender.cpp in Sources */, AB36C82C27F2C8AE00C763C8 /* slot1comp_protocol.cpp in Sources */, AB36C82D27F2C8AE00C763C8 /* appDelegate.mm in Sources */, @@ -8863,8 +8883,10 @@ AB790068215B84E50082AE82 /* driver.cpp in Sources */, AB790069215B84E50082AE82 /* emufat.cpp in Sources */, AB79006A215B84E50082AE82 /* MacScreenshotCaptureTool.mm in Sources */, + AB6E3B472E7385710088075E /* ClientFirmwareControl.cpp in Sources */, AB79006B215B84E50082AE82 /* DisplayViewCALayer.mm in Sources */, AB79006C215B84E50082AE82 /* Slot2WindowDelegate.mm in Sources */, + AB6E3B532E73E7C80088075E /* ClientCheatManager.cpp in Sources */, AB79006D215B84E50082AE82 /* slot1_retail_mcrom.cpp in Sources */, AB79006E215B84E50082AE82 /* emufile.cpp in Sources */, AB79006F215B84E50082AE82 /* fatdir.cpp in Sources */, @@ -8978,7 +9000,6 @@ AB7900D7215B84E50082AE82 /* cocoa_rom.mm in Sources */, AB7900D8215B84E50082AE82 /* cff.c in Sources */, AB7900D9215B84E50082AE82 /* cocoa_util.mm in Sources */, - AB7900DA215B84E50082AE82 /* cocoa_videofilter.mm in Sources */, AB7900DB215B84E50082AE82 /* appDelegate.mm in Sources */, AB7900DC215B84E50082AE82 /* file_path.c in Sources */, AB7991272E70B1420030C0A6 /* CocoaDisplayView.mm in Sources */, @@ -9066,6 +9087,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AB6E3B4F2E7385710088075E /* ClientFirmwareControl.cpp in Sources */, AB7901AA215B84F20082AE82 /* smooth.c in Sources */, AB7901AB215B84F20082AE82 /* MacMetalDisplayViewShaders.metal in Sources */, AB7901AC215B84F20082AE82 /* ftpatent.c in Sources */, @@ -9222,7 +9244,6 @@ AB79023B215B84F20082AE82 /* cocoa_input.mm in Sources */, AB79023D215B84F20082AE82 /* cocoa_rom.mm in Sources */, AB79023E215B84F20082AE82 /* cocoa_util.mm in Sources */, - AB79023F215B84F20082AE82 /* cocoa_videofilter.mm in Sources */, AB790240215B84F20082AE82 /* OGLRender.cpp in Sources */, AB790241215B84F20082AE82 /* slot1comp_protocol.cpp in Sources */, AB790242215B84F20082AE82 /* appDelegate.mm in Sources */, @@ -9240,6 +9261,7 @@ AB79024E215B84F20082AE82 /* lq2x.cpp in Sources */, AB79914D2E71EF050030C0A6 /* CocoaAudioController.mm in Sources */, AB79024F215B84F20082AE82 /* xbrz.cpp in Sources */, + AB6E3B5A2E73E7C80088075E /* ClientCheatManager.cpp in Sources */, AB790250215B84F20082AE82 /* OGLDisplayOutput_3_2.cpp in Sources */, AB790251215B84F20082AE82 /* scanline.cpp in Sources */, AB790252215B84F20082AE82 /* coreaudiosound.cpp in Sources */, @@ -9332,8 +9354,10 @@ AB796D0215CDCBA200C59155 /* driver.cpp in Sources */, AB796D0315CDCBA200C59155 /* emufat.cpp in Sources */, ABD1FBF11F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm in Sources */, + AB6E3B4B2E7385710088075E /* ClientFirmwareControl.cpp in Sources */, AB3BF4381E25D9AE003E2B24 /* DisplayViewCALayer.mm in Sources */, AB564904186E6EBC002740F4 /* Slot2WindowDelegate.mm in Sources */, + AB6E3B5C2E73E7C80088075E /* ClientCheatManager.cpp in Sources */, AB9038B217C5ED2200F410BD /* slot1_retail_mcrom.cpp in Sources */, AB796D0415CDCBA200C59155 /* emufile.cpp in Sources */, AB796D0515CDCBA200C59155 /* fatdir.cpp in Sources */, @@ -9447,7 +9471,6 @@ AB796D5215CDCBA200C59155 /* cocoa_rom.mm in Sources */, ABFEA8851BB4EC1100B08C25 /* cff.c in Sources */, AB796D5315CDCBA200C59155 /* cocoa_util.mm in Sources */, - AB796D5415CDCBA200C59155 /* cocoa_videofilter.mm in Sources */, AB796D5515CDCBA200C59155 /* appDelegate.mm in Sources */, AB000DCB1CCC6B0700413F02 /* file_path.c in Sources */, AB79912B2E70B1420030C0A6 /* CocoaDisplayView.mm in Sources */, @@ -9535,6 +9558,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AB6E3B4C2E7385710088075E /* ClientFirmwareControl.cpp in Sources */, ABFEA8CC1BB4EC1100B08C25 /* smooth.c in Sources */, AB54718C1E27610500508C5C /* MacMetalDisplayViewShaders.metal in Sources */, ABFEA8421BB4EC1100B08C25 /* ftpatent.c in Sources */, @@ -9691,7 +9715,6 @@ AB8F3CDB1A53AC2600A80BF6 /* cocoa_input.mm in Sources */, AB8F3CDD1A53AC2600A80BF6 /* cocoa_rom.mm in Sources */, AB8F3CDE1A53AC2600A80BF6 /* cocoa_util.mm in Sources */, - AB8F3CDF1A53AC2600A80BF6 /* cocoa_videofilter.mm in Sources */, AB8F3CE01A53AC2600A80BF6 /* OGLRender.cpp in Sources */, AB8F3CE11A53AC2600A80BF6 /* slot1comp_protocol.cpp in Sources */, AB8F3CE21A53AC2600A80BF6 /* appDelegate.mm in Sources */, @@ -9709,6 +9732,7 @@ AB8F3CEC1A53AC2600A80BF6 /* lq2x.cpp in Sources */, AB7991532E71EF060030C0A6 /* CocoaAudioController.mm in Sources */, AB8F3CED1A53AC2600A80BF6 /* xbrz.cpp in Sources */, + AB6E3B562E73E7C80088075E /* ClientCheatManager.cpp in Sources */, ABB24F6F1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */, AB8F3CEE1A53AC2600A80BF6 /* scanline.cpp in Sources */, AB8F3CEF1A53AC2600A80BF6 /* coreaudiosound.cpp in Sources */, @@ -9807,6 +9831,7 @@ ABB3C6871501C04F00E0C22E /* hq2x.cpp in Sources */, ABB1C94B1F5281AE0004844F /* ClientExecutionControl.cpp in Sources */, ABB3C6881501C04F00E0C22E /* hq4x.cpp in Sources */, + AB6E3B492E7385710088075E /* ClientFirmwareControl.cpp in Sources */, AB7991422E712F510030C0A6 /* ClientAudioOutput.cpp in Sources */, ABB3C6891501C04F00E0C22E /* lq2x.cpp in Sources */, ABDB1BF92E66486E002AD9AF /* ClientVideoOutput.cpp in Sources */, @@ -9860,6 +9885,7 @@ ABB3C6A81501C04F00E0C22E /* tinyxmlerror.cpp in Sources */, AB49B552281687B90069F1D7 /* smooth.c in Sources */, ABB3C6A91501C04F00E0C22E /* tinyxmlparser.cpp in Sources */, + AB6E3B572E73E7C80088075E /* ClientCheatManager.cpp in Sources */, ABADF11E1DEA4CFC00A142B1 /* features_cpu.c in Sources */, ABB3C6AB1501C04F00E0C22E /* datetime.cpp in Sources */, AB9038B117C5ED2200F410BD /* slot1_retail_auto.cpp in Sources */, @@ -9977,8 +10003,10 @@ ABC858B928273FEE00A03EA9 /* fatfile.cpp in Sources */, ABC858BA28273FEE00A03EA9 /* FIFO.cpp in Sources */, ABC858BB28273FEE00A03EA9 /* MacScreenshotCaptureTool.mm in Sources */, + AB6E3B4A2E7385710088075E /* ClientFirmwareControl.cpp in Sources */, ABC858BC28273FEE00A03EA9 /* FIFOSampleBuffer.cpp in Sources */, ABC858BD28273FEE00A03EA9 /* file_allocation_table.cpp in Sources */, + AB6E3B552E73E7C80088075E /* ClientCheatManager.cpp in Sources */, ABC858BE28273FEE00A03EA9 /* slot1_retail_mcrom_debug.cpp in Sources */, ABC858BF28273FEE00A03EA9 /* filetime.cpp in Sources */, ABC858C028273FEE00A03EA9 /* FIRFilter.cpp in Sources */, @@ -10088,7 +10116,6 @@ ABC8592628273FEE00A03EA9 /* deposterize.cpp in Sources */, ABC8592728273FEE00A03EA9 /* cocoa_rom.mm in Sources */, ABC8592828273FEE00A03EA9 /* cocoa_util.mm in Sources */, - ABC8592928273FEE00A03EA9 /* cocoa_videofilter.mm in Sources */, ABC8592A28273FEE00A03EA9 /* OGLRender.cpp in Sources */, ABC8592B28273FEE00A03EA9 /* slot1comp_protocol.cpp in Sources */, ABC8592C28273FEE00A03EA9 /* appDelegate.mm in Sources */, @@ -10211,8 +10238,10 @@ ABD2CD6D26E05CB000FB15F7 /* fatfile.cpp in Sources */, ABD2CD6E26E05CB000FB15F7 /* FIFO.cpp in Sources */, ABD2CD6F26E05CB000FB15F7 /* MacScreenshotCaptureTool.mm in Sources */, + AB6E3B4E2E7385710088075E /* ClientFirmwareControl.cpp in Sources */, ABD2CD7026E05CB000FB15F7 /* FIFOSampleBuffer.cpp in Sources */, ABD2CD7126E05CB000FB15F7 /* file_allocation_table.cpp in Sources */, + AB6E3B5D2E73E7C80088075E /* ClientCheatManager.cpp in Sources */, ABD2CD7226E05CB000FB15F7 /* slot1_retail_mcrom_debug.cpp in Sources */, ABD2CD7326E05CB000FB15F7 /* filetime.cpp in Sources */, ABD2CD7426E05CB000FB15F7 /* FIRFilter.cpp in Sources */, @@ -10322,7 +10351,6 @@ ABD2CDDA26E05CB000FB15F7 /* deposterize.cpp in Sources */, ABD2CDDB26E05CB000FB15F7 /* cocoa_rom.mm in Sources */, ABD2CDDC26E05CB000FB15F7 /* cocoa_util.mm in Sources */, - ABD2CDDD26E05CB000FB15F7 /* cocoa_videofilter.mm in Sources */, ABD2CDDE26E05CB000FB15F7 /* OGLRender.cpp in Sources */, ABD2CDDF26E05CB000FB15F7 /* slot1comp_protocol.cpp in Sources */, ABD2CDE026E05CB000FB15F7 /* appDelegate.mm in Sources */, diff --git a/desmume/src/frontend/cocoa/DeSmuME (XCode 3).xcodeproj/project.pbxproj b/desmume/src/frontend/cocoa/DeSmuME (XCode 3).xcodeproj/project.pbxproj index 212abc6a8..570117e3c 100755 --- a/desmume/src/frontend/cocoa/DeSmuME (XCode 3).xcodeproj/project.pbxproj +++ b/desmume/src/frontend/cocoa/DeSmuME (XCode 3).xcodeproj/project.pbxproj @@ -301,6 +301,16 @@ AB1CC8311AA50C8D008B0A16 /* Icon_MicrophoneGray_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = AB1CC8181AA50C8D008B0A16 /* Icon_MicrophoneGray_256x256.png */; }; AB1CC8321AA50C8D008B0A16 /* Icon_MicrophoneGreen_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = AB1CC8191AA50C8D008B0A16 /* Icon_MicrophoneGreen_256x256.png */; }; AB1CC8331AA50C8D008B0A16 /* Icon_MicrophoneRed_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = AB1CC81A1AA50C8D008B0A16 /* Icon_MicrophoneRed_256x256.png */; }; + AB1E5A362E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A322E73F0AC008AFF9F /* ClientCheatManager.cpp */; }; + AB1E5A372E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A342E73F0AC008AFF9F /* ClientFirmwareControl.cpp */; }; + AB1E5A382E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A322E73F0AC008AFF9F /* ClientCheatManager.cpp */; }; + AB1E5A392E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A342E73F0AC008AFF9F /* ClientFirmwareControl.cpp */; }; + AB1E5A3A2E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A322E73F0AC008AFF9F /* ClientCheatManager.cpp */; }; + AB1E5A3B2E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A342E73F0AC008AFF9F /* ClientFirmwareControl.cpp */; }; + AB1E5A3C2E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A322E73F0AC008AFF9F /* ClientCheatManager.cpp */; }; + AB1E5A3D2E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A342E73F0AC008AFF9F /* ClientFirmwareControl.cpp */; }; + AB1E5A3E2E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A322E73F0AC008AFF9F /* ClientCheatManager.cpp */; }; + AB1E5A3F2E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1E5A342E73F0AC008AFF9F /* ClientFirmwareControl.cpp */; }; AB213D45170CB141006DDB0F /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB213D44170CB141006DDB0F /* InputProfileController.mm */; }; AB213D46170CB141006DDB0F /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB213D44170CB141006DDB0F /* InputProfileController.mm */; }; AB213D47170CB141006DDB0F /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB213D44170CB141006DDB0F /* InputProfileController.mm */; }; @@ -463,7 +473,6 @@ AB2A9A461725F00F0062C1A1 /* mic_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD9A46413DB99B300777194 /* mic_ext.cpp */; }; AB2A9A481725F00F0062C1A1 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB2A9A491725F00F0062C1A1 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB2A9A4A1725F00F0062C1A1 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB2A9A4B1725F00F0062C1A1 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; AB2A9A4C1725F00F0062C1A1 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; AB2A9A4D1725F00F0062C1A1 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; }; @@ -660,7 +669,6 @@ AB2F3C2515CF9C6000858373 /* mic_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD9A46413DB99B300777194 /* mic_ext.cpp */; }; AB2F3C2715CF9C6000858373 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB2F3C2815CF9C6000858373 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB2F3C2915CF9C6000858373 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB2F3C2A15CF9C6000858373 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; AB2F3C2B15CF9C6000858373 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; AB2F3C2C15CF9C6000858373 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; }; @@ -972,7 +980,6 @@ AB711F641481C35F009011C8 /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABE6702A1415DE6C00E8E4C9 /* tinyxmlparser.cpp */; }; AB711F6C1481C35F009011C8 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; AB711F6D1481C35F009011C8 /* videofilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB817A35143EE2DB00A7DFE9 /* videofilter.cpp */; }; - AB711F6E1481C35F009011C8 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB711F701481C35F009011C8 /* cocoa_cheat.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABA6574A14511EC90077E5E9 /* cocoa_cheat.mm */; }; AB711F741481C35F009011C8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; AB711F751481C35F009011C8 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ABC570D0134431CE00E7B0B1 /* AudioUnit.framework */; }; @@ -1129,7 +1136,6 @@ AB73AA131507C9F500A310C8 /* mic_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD9A46413DB99B300777194 /* mic_ext.cpp */; }; AB73AA151507C9F500A310C8 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; AB73AA161507C9F500A310C8 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - AB73AA171507C9F500A310C8 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; AB73AA181507C9F500A310C8 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; AB73AA191507C9F500A310C8 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; AB73AA1A1507C9F500A310C8 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; }; @@ -1420,7 +1426,6 @@ ABAD101B15ACE7A00000EC47 /* mic_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD9A46413DB99B300777194 /* mic_ext.cpp */; }; ABAD101D15ACE7A00000EC47 /* cocoa_rom.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104131346652500AF11D1 /* cocoa_rom.mm */; }; ABAD101E15ACE7A00000EC47 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; }; - ABAD101F15ACE7A00000EC47 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; }; ABAD102015ACE7A00000EC47 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; }; ABAD102115ACE7A00000EC47 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; }; ABAD102215ACE7A00000EC47 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; }; @@ -1949,6 +1954,10 @@ AB1CC8181AA50C8D008B0A16 /* Icon_MicrophoneGray_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneGray_256x256.png; path = images/Icon_MicrophoneGray_256x256.png; sourceTree = ""; }; AB1CC8191AA50C8D008B0A16 /* Icon_MicrophoneGreen_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneGreen_256x256.png; path = images/Icon_MicrophoneGreen_256x256.png; sourceTree = ""; }; AB1CC81A1AA50C8D008B0A16 /* Icon_MicrophoneRed_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneRed_256x256.png; path = images/Icon_MicrophoneRed_256x256.png; sourceTree = ""; }; + AB1E5A322E73F0AC008AFF9F /* ClientCheatManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClientCheatManager.cpp; sourceTree = ""; }; + AB1E5A332E73F0AC008AFF9F /* ClientCheatManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientCheatManager.h; sourceTree = ""; }; + AB1E5A342E73F0AC008AFF9F /* ClientFirmwareControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClientFirmwareControl.cpp; sourceTree = ""; }; + AB1E5A352E73F0AC008AFF9F /* ClientFirmwareControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientFirmwareControl.h; sourceTree = ""; }; AB213D43170CB141006DDB0F /* InputProfileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputProfileController.h; sourceTree = ""; }; AB213D44170CB141006DDB0F /* InputProfileController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InputProfileController.mm; sourceTree = ""; }; AB213E981710D074006DDB0F /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; @@ -2370,8 +2379,6 @@ ABD59846187D4A6C00069403 /* Icon_PaddleKnob_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_PaddleKnob_256x256.png; path = images/Icon_PaddleKnob_256x256.png; sourceTree = ""; }; ABD9A46313DB99B300777194 /* mic_ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mic_ext.h; sourceTree = ""; }; ABD9A46413DB99B300777194 /* mic_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mic_ext.cpp; sourceTree = ""; }; - ABE5DFE3143FB1DA00835AD8 /* cocoa_videofilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_videofilter.h; sourceTree = ""; }; - ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cocoa_videofilter.mm; sourceTree = ""; }; ABE670251415DE6C00E8E4C9 /* tinystr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinystr.cpp; sourceTree = ""; }; ABE670261415DE6C00E8E4C9 /* tinystr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tinystr.h; sourceTree = ""; }; ABE670271415DE6C00E8E4C9 /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml.cpp; sourceTree = ""; }; @@ -2594,9 +2601,11 @@ AB2145221714DFF4006DDB0F /* audiosamplegenerator.cpp */, AB561BFD2E72AD6E007F88A5 /* ClientAudioOutput.cpp */, ABD1267120AE812900EFE1B2 /* ClientAVCaptureObject.cpp */, + AB1E5A322E73F0AC008AFF9F /* ClientCheatManager.cpp */, AB0F13911E1B7C320075684F /* ClientDisplayView.cpp */, AB561BFF2E72AD6E007F88A5 /* ClientEmulationOutput.cpp */, ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */, + AB1E5A342E73F0AC008AFF9F /* ClientFirmwareControl.cpp */, ABC04DA11F67A20500EA6ED7 /* ClientInputHandler.cpp */, AB561C012E72AD6E007F88A5 /* ClientVideoOutput.cpp */, ABD0A5341501AA5A0074A094 /* coreaudiosound.cpp */, @@ -2610,9 +2619,11 @@ AB2145211714DFF4006DDB0F /* audiosamplegenerator.h */, AB561BFE2E72AD6E007F88A5 /* ClientAudioOutput.h */, ABD1267220AE812900EFE1B2 /* ClientAVCaptureObject.h */, + AB1E5A332E73F0AC008AFF9F /* ClientCheatManager.h */, AB0F13901E1B7C320075684F /* ClientDisplayView.h */, AB561C002E72AD6E007F88A5 /* ClientEmulationOutput.h */, ABD4F2721F54A51000D75A1F /* ClientExecutionControl.h */, + AB1E5A352E73F0AC008AFF9F /* ClientFirmwareControl.h */, ABC04DA21F67A20500EA6ED7 /* ClientInputHandler.h */, AB561C022E72AD6E007F88A5 /* ClientVideoOutput.h */, ABA6574914511EC90077E5E9 /* cocoa_cheat.h */, @@ -2625,7 +2636,6 @@ ABD104001346652500AF11D1 /* cocoa_rom.h */, ABAE2F8218682B8F00C92F4F /* cocoa_slot2.h */, AB80E050142BC4FA00A52038 /* cocoa_util.h */, - ABE5DFE3143FB1DA00835AD8 /* cocoa_videofilter.h */, ABD0A5361501AA5A0074A094 /* coreaudiosound.h */, ABD1267420AE812900EFE1B2 /* macOS_driver.h */, ABD9A46313DB99B300777194 /* mic_ext.h */, @@ -2643,7 +2653,6 @@ ABD104131346652500AF11D1 /* cocoa_rom.mm */, ABAE2F8318682B8F00C92F4F /* cocoa_slot2.mm */, AB80E04C142BC4A800A52038 /* cocoa_util.mm */, - ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */, ); name = "Cocoa Port"; sourceTree = ""; @@ -4799,7 +4808,6 @@ AB2A9A461725F00F0062C1A1 /* mic_ext.cpp in Sources */, AB2A9A481725F00F0062C1A1 /* cocoa_rom.mm in Sources */, AB2A9A491725F00F0062C1A1 /* cocoa_util.mm in Sources */, - AB2A9A4A1725F00F0062C1A1 /* cocoa_videofilter.mm in Sources */, AB2A9A4B1725F00F0062C1A1 /* OGLRender.cpp in Sources */, AB2A9A4C1725F00F0062C1A1 /* appDelegate.mm in Sources */, AB2A9A4D1725F00F0062C1A1 /* cheatWindowDelegate.mm in Sources */, @@ -4910,6 +4918,8 @@ AB561C062E72AD6E007F88A5 /* ClientAudioOutput.cpp in Sources */, AB561C072E72AD6E007F88A5 /* ClientEmulationOutput.cpp in Sources */, AB561C082E72AD6E007F88A5 /* ClientVideoOutput.cpp in Sources */, + AB1E5A382E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */, + AB1E5A392E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4999,7 +5009,6 @@ AB2F3C2515CF9C6000858373 /* mic_ext.cpp in Sources */, AB2F3C2715CF9C6000858373 /* cocoa_rom.mm in Sources */, AB2F3C2815CF9C6000858373 /* cocoa_util.mm in Sources */, - AB2F3C2915CF9C6000858373 /* cocoa_videofilter.mm in Sources */, AB2F3C2A15CF9C6000858373 /* OGLRender.cpp in Sources */, AB2F3C2B15CF9C6000858373 /* appDelegate.mm in Sources */, AB2F3C2C15CF9C6000858373 /* cheatWindowDelegate.mm in Sources */, @@ -5110,6 +5119,8 @@ AB561C092E72AD6E007F88A5 /* ClientAudioOutput.cpp in Sources */, AB561C0A2E72AD6E007F88A5 /* ClientEmulationOutput.cpp in Sources */, AB561C0B2E72AD6E007F88A5 /* ClientVideoOutput.cpp in Sources */, + AB1E5A3A2E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */, + AB1E5A3B2E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5199,7 +5210,6 @@ AB711F5E1481C35F009011C8 /* mic_ext.cpp in Sources */, AB711F481481C35F009011C8 /* cocoa_rom.mm in Sources */, AB711F6C1481C35F009011C8 /* cocoa_util.mm in Sources */, - AB711F6E1481C35F009011C8 /* cocoa_videofilter.mm in Sources */, AB3ACB7814C2361100D7D192 /* appDelegate.mm in Sources */, AB3ACB7914C2361100D7D192 /* cheatWindowDelegate.mm in Sources */, AB3ACB7C14C2361100D7D192 /* inputPrefsView.mm in Sources */, @@ -5340,6 +5350,8 @@ AB561C0F2E72AD6E007F88A5 /* ClientAudioOutput.cpp in Sources */, AB561C102E72AD6E007F88A5 /* ClientEmulationOutput.cpp in Sources */, AB561C112E72AD6E007F88A5 /* ClientVideoOutput.cpp in Sources */, + AB1E5A3E2E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */, + AB1E5A3F2E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5429,7 +5441,6 @@ AB73AA131507C9F500A310C8 /* mic_ext.cpp in Sources */, AB73AA151507C9F500A310C8 /* cocoa_rom.mm in Sources */, AB73AA161507C9F500A310C8 /* cocoa_util.mm in Sources */, - AB73AA171507C9F500A310C8 /* cocoa_videofilter.mm in Sources */, AB73AA181507C9F500A310C8 /* OGLRender.cpp in Sources */, AB73AA191507C9F500A310C8 /* appDelegate.mm in Sources */, AB73AA1A1507C9F500A310C8 /* cheatWindowDelegate.mm in Sources */, @@ -5570,6 +5581,8 @@ AB561C0C2E72AD6E007F88A5 /* ClientAudioOutput.cpp in Sources */, AB561C0D2E72AD6E007F88A5 /* ClientEmulationOutput.cpp in Sources */, AB561C0E2E72AD6E007F88A5 /* ClientVideoOutput.cpp in Sources */, + AB1E5A3C2E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */, + AB1E5A3D2E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5659,7 +5672,6 @@ ABAD101B15ACE7A00000EC47 /* mic_ext.cpp in Sources */, ABAD101D15ACE7A00000EC47 /* cocoa_rom.mm in Sources */, ABAD101E15ACE7A00000EC47 /* cocoa_util.mm in Sources */, - ABAD101F15ACE7A00000EC47 /* cocoa_videofilter.mm in Sources */, ABAD102015ACE7A00000EC47 /* OGLRender.cpp in Sources */, ABAD102115ACE7A00000EC47 /* appDelegate.mm in Sources */, ABAD102215ACE7A00000EC47 /* cheatWindowDelegate.mm in Sources */, @@ -5770,6 +5782,8 @@ AB561C032E72AD6E007F88A5 /* ClientAudioOutput.cpp in Sources */, AB561C042E72AD6E007F88A5 /* ClientEmulationOutput.cpp in Sources */, AB561C052E72AD6E007F88A5 /* ClientVideoOutput.cpp in Sources */, + AB1E5A362E73F0AC008AFF9F /* ClientCheatManager.cpp in Sources */, + AB1E5A372E73F0AC008AFF9F /* ClientFirmwareControl.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/desmume/src/frontend/cocoa/cocoa_cheat.h b/desmume/src/frontend/cocoa/cocoa_cheat.h index 13b861310..935bade05 100644 --- a/desmume/src/frontend/cocoa/cocoa_cheat.h +++ b/desmume/src/frontend/cocoa/cocoa_cheat.h @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Roger Manuel - Copyright (C) 2011-2023 DeSmuME team + Copyright (C) 2011-2025 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,284 +23,10 @@ #import -class CHEATS; -class CHEATS_LIST; -class CHEATSEARCH; + +class ClientCheatItem; class ClientCheatManager; -enum CheatType -{ - CheatType_Internal = 0, - CheatType_ActionReplay = 1, - CheatType_CodeBreaker = 2 -}; - -enum CheatFreezeType -{ - CheatFreezeType_Normal = 0, - CheatFreezeType_CanDecrease = 1, - CheatFreezeType_CanIncrease = 2 -}; - -enum CheatSearchStyle -{ - CheatSearchStyle_ExactValue = 0, - CheatSearchStyle_Comparative = 1 -}; - -enum CheatSearchCompareStyle -{ - CheatSearchCompareStyle_GreaterThan = 0, - CheatSearchCompareStyle_LesserThan = 1, - CheatSearchCompareStyle_Equals = 2, - CheatSearchCompareStyle_NotEquals = 3 -}; - -union DesmumeCheatSearchItem -{ - uint64_t data; - - struct - { - uint32_t address; - uint32_t value; - }; -}; -typedef union DesmumeCheatSearchItem DesmumeCheatSearchItem; - -typedef std::vector DesmumeCheatSearchResultsList; - -struct InternalCheatParam -{ - uint32_t address; - uint32_t value; - uint8_t valueLength; -}; -typedef struct InternalCheatParam InternalCheatParam; - -class ClientCheatItem -{ -protected: - ClientCheatManager *_cheatManager; - - bool _isEnabled; - bool _willAddFromDB; - - CheatType _cheatType; - std::string _nameString; - std::string _commentString; - - // Internal cheat type parameters - CheatFreezeType _freezeType; - char _addressString[10+1]; - uint32_t _address; - uint32_t _value; - uint8_t _valueLength; - - // Action Replay parameters - uint32_t _codeCount; - std::string _rawCodeString; - std::string _cleanCodeString; - - void _ConvertInternalToActionReplay(); - void _ConvertActionReplayToInternal(); - -public: - ClientCheatItem(); - ~ClientCheatItem(); - - void Init(const CHEATS_LIST &inCheatItem); - void Init(const ClientCheatItem &inCheatItem); - - void SetCheatManager(ClientCheatManager *cheatManager); - ClientCheatManager* GetCheatManager() const; - - void SetEnabled(bool theState); - bool IsEnabled() const; - - void SetWillAddFromDB(bool theState); - bool WillAddFromDB() const; - - CheatType GetType() const; - void SetType(CheatType requestedType); - bool IsSupportedType() const; - - const char* GetName() const; - void SetName(const char *nameString); - - const char* GetComments() const; - void SetComments(const char *commentString); - - CheatFreezeType GetFreezeType() const; - void SetFreezeType(CheatFreezeType theFreezeType); - - uint32_t GetAddress() const; - void SetAddress(uint32_t theAddress); - const char* GetAddressString() const; - const char* GetAddressSixDigitString() const; - void SetAddressSixDigitString(const char *sixDigitString); - - uint32_t GetValue() const; - void SetValue(uint32_t theValue); - uint8_t GetValueLength() const; - void SetValueLength(uint8_t byteLength); - - void SetRawCodeString(const char *rawString, const bool willSaveValidatedRawString); - const char* GetRawCodeString() const; - const char* GetCleanCodeString() const; - const std::string& GetCleanCodeCppString() const; - uint32_t GetCodeCount() const; - - void ClientToDesmumeCheatItem(CHEATS_LIST *outCheatItem) const; -}; - -class ClientCheatList -{ -private: - ClientCheatItem* __AddItem(const ClientCheatItem *srcItem, const bool willCopy, const bool allowDuplicates); - -protected: - std::vector *_list; - -public: - ClientCheatList(); - ~ClientCheatList(); - - CheatSystemError LoadFromFile(const char *filePath); - CheatSystemError SaveToFile(const char *filePath); - - bool IsItemDuplicate(const ClientCheatItem *srcItem); - - ClientCheatItem* AddNew(); - ClientCheatItem* AddNewItemCopy(const ClientCheatItem *srcItem); - ClientCheatItem* AddNewItemCopyNoDuplicate(const ClientCheatItem *srcItem); - ClientCheatItem* AddExistingItemNoDuplicate(const ClientCheatItem *srcItem); - - bool Remove(ClientCheatItem *targetItem); - bool RemoveAtIndex(size_t index); - void RemoveAll(); - - bool Update(const ClientCheatItem &srcItem, ClientCheatItem *targetItem); - bool UpdateAtIndex(const ClientCheatItem &srcItem, size_t index); - - size_t GetTotalCheatCount() const; - size_t GetActiveCheatCount() const; - std::vector* GetCheatList() const; - size_t GetIndexOfItem(const ClientCheatItem *cheatItem) const; - ClientCheatItem* GetItemAtIndex(size_t index) const; - - void ReplaceFromEngine(const CHEATS *engineCheatList); - void CopyListToEngine(const bool willApplyOnlyEnabledItems, CHEATS *engineCheatList); -}; - -class ClientCheatSearcher -{ -protected: - CHEATSEARCH *_desmumeSearcher; - uint8_t _searchValueLength; - size_t _resultsCount; - bool _didSearchStart; - DesmumeCheatSearchResultsList _resultsList; - -public: - ClientCheatSearcher(); - ~ClientCheatSearcher(); - - bool DidStart() const; - void Reset(); - size_t SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch); - size_t SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch); - const DesmumeCheatSearchResultsList& RefreshResults(); - const DesmumeCheatSearchResultsList& GetResults(); - size_t GetResultCount() const; -}; - -class ClientCheatDatabase -{ -protected: - ClientCheatList *_list; - std::string _title; - std::string _description; - std::string _lastFilePath; - -public: - ClientCheatDatabase(); - ~ClientCheatDatabase(); - - ClientCheatList* GetList() const; - ClientCheatList* LoadFromFile(const char *dbFilePath); - - const char* GetTitle() const; - const char* GetDescription() const; -}; - -class ClientCheatManager -{ -protected: - ClientCheatList *_currentSessionList; - ClientCheatDatabase *_currentDatabase; - ClientCheatSearcher *_currentSearcher; - - ClientCheatItem *_selectedItem; - size_t _selectedItemIndex; - uint32_t _untitledCount; - std::string _currentSessionLastFilePath; - - std::vector _pendingInternalCheatWriteList; - - bool _masterNeedsUpdate; - -public: - ClientCheatManager(); - virtual ~ClientCheatManager(); - - static CHEATS* GetMaster(); - static void SetMaster(const CHEATS *masterCheats); - - ClientCheatList* GetSessionList() const; - const char* GetSessionListLastFilePath() const; - - virtual CheatSystemError SessionListLoadFromFile(const char *filePath); - virtual CheatSystemError SessionListSaveToFile(const char *filePath); - - ClientCheatItem* SetSelectedItemByIndex(size_t index); - - ClientCheatItem* NewItem(); - ClientCheatItem* AddExistingItemNoDuplicate(const ClientCheatItem *theItem); - - void RemoveItem(ClientCheatItem *theItem); - void RemoveItemAtIndex(size_t index); - void RemoveSelectedItem(); - - void ModifyItem(const ClientCheatItem *srcItem, ClientCheatItem *targetItem); - void ModifyItemAtIndex(const ClientCheatItem *srcItem, size_t index); - - size_t GetTotalCheatCount() const; - size_t GetActiveCheatCount() const; - - void LoadFromMaster(); - void ApplyToMaster(); - void MasterNeedsUpdate(); - - ClientCheatList* GetDatabaseList() const; - ClientCheatList* DatabaseListLoadFromFile(const char *dbFilePath); - const char* GetDatabaseTitle() const; - const char* GetDatabaseDescription() const; - - bool SearchDidStart() const; - void SearchReset(); - size_t SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch); - size_t SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch); - const DesmumeCheatSearchResultsList& SearchResultsRefresh(); - const DesmumeCheatSearchResultsList& GetSearchResults(); - size_t GetSearchResultCount() const; - - void DirectWriteInternalCheatAtIndex(size_t index); - void DirectWriteInternalCheatItem(const ClientCheatItem *cheatItem); - void DirectWriteInternalCheat(uint32_t targetAddress, uint32_t newValue32, size_t newValueLength); - void ApplyPendingInternalCheatWrites(); -}; - @interface CocoaDSCheatItem : NSObject { ClientCheatItem *_internalData; diff --git a/desmume/src/frontend/cocoa/cocoa_cheat.mm b/desmume/src/frontend/cocoa/cocoa_cheat.mm index c2ea5755d..c736df2e4 100644 --- a/desmume/src/frontend/cocoa/cocoa_cheat.mm +++ b/desmume/src/frontend/cocoa/cocoa_cheat.mm @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Roger Manuel - Copyright (C) 2012-2023 DeSmuME team + Copyright (C) 2012-2025 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,1565 +20,11 @@ #import "cocoa_globals.h" #import "cocoa_util.h" -#include "../../MMU.h" +#include "ClientCheatManager.h" +#include "../../NDSSystem.h" #undef BOOL -size_t CheatConvertRawCodeToCleanCode(const char *inRawCodeString, const size_t requestedCodeCount, std::string &outCleanCodeString) -{ - size_t cleanCodeLength = 0; - if ( (inRawCodeString == NULL) || - (requestedCodeCount == 0) ) - { - return cleanCodeLength; - } - - char *cleanCodeWorkingBuffer = (char *)malloc((requestedCodeCount * 16) + 1); - memset(cleanCodeWorkingBuffer, 0, (requestedCodeCount * 16) + 1); - - size_t rawCodeLength = strlen(inRawCodeString); - // remove wrong chars - for (size_t i = 0; (i < rawCodeLength) && (cleanCodeLength < (requestedCodeCount * 16)); i++) - { - char c = inRawCodeString[i]; - //apparently 100% of pokemon codes were typed with the letter O in place of zero in some places - //so let's try to adjust for that here - static const char *AR_Valid = "Oo0123456789ABCDEFabcdef"; - if (strchr(AR_Valid, c)) - { - if ( (c == 'o') || (c == 'O') ) - { - c = '0'; - } - - cleanCodeWorkingBuffer[cleanCodeLength++] = c; - } - } - - if ( (cleanCodeLength % 16) != 0) - { - // Code lines must always come in 8+8, where the first 8 characters - // are used for the target address, and the second 8 characters are - // used for the 32-bit value written to the target address. Therefore, - // if the string length isn't divisible by 16, then it is considered - // invalid. - cleanCodeLength = 0; - free(cleanCodeWorkingBuffer); - return cleanCodeLength; - } - - outCleanCodeString = cleanCodeWorkingBuffer; - free(cleanCodeWorkingBuffer); - - return (cleanCodeLength / 16); -} - -size_t CheatConvertCleanCodeToRawCode(const char *inCleanCodeString, std::string &outRawCodeString) -{ - if (inCleanCodeString == NULL) - { - return 0; - } - - // Clean code strings are assumed to be already validated, so we're not - // going to bother with any more validation here. - - const size_t cleanCodeLength = strlen(inCleanCodeString); - const size_t codeCount = cleanCodeLength / 16; - const size_t rawCodeLength = codeCount * (16 + 1 + 1); - - char *rawCodeWorkingBuffer = (char *)malloc(rawCodeLength); - memset(rawCodeWorkingBuffer, 0, rawCodeLength); - - for (size_t i = 0; i < codeCount; i++) - { - const size_t c = i * 16; - const size_t r = i * (16 + 1 + 1); - - rawCodeWorkingBuffer[r + 0] = inCleanCodeString[c + 0]; - rawCodeWorkingBuffer[r + 1] = inCleanCodeString[c + 1]; - rawCodeWorkingBuffer[r + 2] = inCleanCodeString[c + 2]; - rawCodeWorkingBuffer[r + 3] = inCleanCodeString[c + 3]; - rawCodeWorkingBuffer[r + 4] = inCleanCodeString[c + 4]; - rawCodeWorkingBuffer[r + 5] = inCleanCodeString[c + 5]; - rawCodeWorkingBuffer[r + 6] = inCleanCodeString[c + 6]; - rawCodeWorkingBuffer[r + 7] = inCleanCodeString[c + 7]; - rawCodeWorkingBuffer[r + 8] = ' '; - rawCodeWorkingBuffer[r + 9] = inCleanCodeString[c + 8]; - rawCodeWorkingBuffer[r +10] = inCleanCodeString[c + 9]; - rawCodeWorkingBuffer[r +11] = inCleanCodeString[c +10]; - rawCodeWorkingBuffer[r +12] = inCleanCodeString[c +11]; - rawCodeWorkingBuffer[r +13] = inCleanCodeString[c +12]; - rawCodeWorkingBuffer[r +14] = inCleanCodeString[c +13]; - rawCodeWorkingBuffer[r +15] = inCleanCodeString[c +14]; - rawCodeWorkingBuffer[r +16] = inCleanCodeString[c +15]; - rawCodeWorkingBuffer[r +17] = '\n'; - } - - rawCodeWorkingBuffer[rawCodeLength - 1] = '\0'; - outRawCodeString = rawCodeWorkingBuffer; - - return codeCount; -} - -bool IsCheatItemDuplicate(const ClientCheatItem *first, const ClientCheatItem *second) -{ - bool isDuplicate = false; - - if ( (first == NULL) || (second == NULL) ) - { - return isDuplicate; - } - - if (first == second) - { - isDuplicate = true; - return isDuplicate; - } - - const CheatType compareType = first->GetType(); - - switch (compareType) - { - case CheatType_Internal: - { - if ( (first->GetAddress() == second->GetAddress()) && - (first->GetValueLength() == second->GetValueLength()) && - (first->GetValue() == second->GetValue()) ) - { - isDuplicate = true; - } - break; - } - - case CheatType_ActionReplay: - { - if ( (first->GetCodeCount() == second->GetCodeCount()) && - (first->GetCleanCodeCppString() == second->GetCleanCodeCppString()) ) - { - isDuplicate = true; - } - break; - } - - case CheatType_CodeBreaker: - default: - break; - } - - return isDuplicate; -} - -ClientCheatItem::ClientCheatItem() -{ - _cheatManager = NULL; - - _isEnabled = false; - _willAddFromDB = false; - - _cheatType = CheatType_Internal; - _nameString = "No description."; - _commentString = ""; - _freezeType = CheatFreezeType_Normal; - _address = 0x02000000; - strncpy(_addressString, "0x02000000", sizeof(_addressString)); - _valueLength = 1; - _value = 0; - - _codeCount = 1; - _rawCodeString = "02000000 00000000"; - _cleanCodeString = "0200000000000000"; -} - -ClientCheatItem::~ClientCheatItem() -{ - -} - -void ClientCheatItem::Init(const CHEATS_LIST &inCheatItem) -{ - char workingCodeBuffer[32]; - - this->_isEnabled = (inCheatItem.enabled) ? true : false; - - this->_cheatType = (CheatType)inCheatItem.type; - this->_nameString = inCheatItem.description; - this->_commentString = ""; - - this->_freezeType = (CheatFreezeType)inCheatItem.freezeType; - this->_valueLength = inCheatItem.size + 1; // CHEATS_LIST.size value range is [1...4], but starts counting from 0. - this->_address = inCheatItem.code[0][0]; - this->_addressString[0] = '0'; - this->_addressString[1] = 'x'; - snprintf(this->_addressString + 2, sizeof(this->_addressString) - 2, "%08X", this->_address); - this->_value = inCheatItem.code[0][1]; - - snprintf(workingCodeBuffer, 18, "%08X %08X", this->_address, this->_value); - this->_rawCodeString = workingCodeBuffer; - snprintf(workingCodeBuffer, 17, "%08X%08X", this->_address, this->_value); - this->_cleanCodeString = workingCodeBuffer; - - if (this->_cheatType == CheatType_Internal) - { - this->_codeCount = 1; - } - else if (this->_cheatType == CheatType_ActionReplay) - { - this->_codeCount = inCheatItem.num; - - for (size_t i = 1; i < this->_codeCount; i++) - { - snprintf(workingCodeBuffer, 19, "\n%08X %08X", inCheatItem.code[i][0], inCheatItem.code[i][1]); - this->_rawCodeString += workingCodeBuffer; - snprintf(workingCodeBuffer, 17, "%08X%08X", inCheatItem.code[i][0], inCheatItem.code[i][1]); - this->_cleanCodeString += workingCodeBuffer; - } - } -} - -void ClientCheatItem::Init(const ClientCheatItem &inCheatItem) -{ - this->SetEnabled(inCheatItem.IsEnabled()); - this->SetName(inCheatItem.GetName()); - this->SetComments(inCheatItem.GetComments()); - this->SetType(inCheatItem.GetType()); - this->SetFreezeType(inCheatItem.GetFreezeType()); - - if (this->GetType() == CheatType_Internal) - { - this->SetValueLength(inCheatItem.GetValueLength()); - this->SetAddress(inCheatItem.GetAddress()); - this->SetValue(inCheatItem.GetValue()); - } - else - { - this->SetRawCodeString(inCheatItem.GetRawCodeString(), false); - } -} - -void ClientCheatItem::SetCheatManager(ClientCheatManager *cheatManager) -{ - this->_cheatManager = cheatManager; -} - -ClientCheatManager* ClientCheatItem::GetCheatManager() const -{ - return this->_cheatManager; -} - -void ClientCheatItem::SetEnabled(bool theState) -{ - if ( (this->_isEnabled != theState) && (this->_cheatManager != NULL) ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - this->_isEnabled = theState; -} - -bool ClientCheatItem::IsEnabled() const -{ - return this->_isEnabled; -} - -void ClientCheatItem::SetWillAddFromDB(bool theState) -{ - this->_willAddFromDB = theState; -} - -bool ClientCheatItem::WillAddFromDB() const -{ - return this->_willAddFromDB; -} - -CheatType ClientCheatItem::GetType() const -{ - return this->_cheatType; -} - -void ClientCheatItem::SetType(CheatType requestedType) -{ - switch (requestedType) - { - case CheatType_Internal: - case CheatType_ActionReplay: - case CheatType_CodeBreaker: - // Do nothing. - break; - - default: - // Bail if the cheat type is invalid. - return; - } - - if ( (this->_cheatType != requestedType) && (this->_cheatManager != NULL) && this->_isEnabled ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - this->_cheatType = requestedType; -} - -bool ClientCheatItem::IsSupportedType() const -{ - return (this->_cheatType != CheatType_CodeBreaker); -} - -const char* ClientCheatItem::GetName() const -{ - return this->_nameString.c_str(); -} - -void ClientCheatItem::SetName(const char *nameString) -{ - if (nameString == NULL) - { - this->_nameString = ""; - } - else - { - this->_nameString = nameString; - } -} - -const char* ClientCheatItem::GetComments() const -{ - return this->_commentString.c_str(); -} - -void ClientCheatItem::SetComments(const char *commentString) -{ - if (commentString == NULL) - { - this->_commentString = ""; - } - else - { - this->_commentString = commentString; - } -} - -CheatFreezeType ClientCheatItem::GetFreezeType() const -{ - return this->_freezeType; -} - -void ClientCheatItem::SetFreezeType(CheatFreezeType theFreezeType) -{ - switch (theFreezeType) - { - case CheatFreezeType_Normal: - case CheatFreezeType_CanDecrease: - case CheatFreezeType_CanIncrease: - // Do nothing. - break; - - default: - // Bail if the freeze type is invalid. - return; - } - - if ( (this->_freezeType != theFreezeType) && (this->_cheatManager != NULL) && this->_isEnabled ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - this->_freezeType = theFreezeType; -} - -uint32_t ClientCheatItem::GetAddress() const -{ - if (this->_cheatType != CheatType_Internal) - { - return 0; - } - - return this->_address; -} - -void ClientCheatItem::SetAddress(uint32_t theAddress) -{ - if ( (this->_address != theAddress) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - this->_address = theAddress; - - this->_addressString[0] = '0'; - this->_addressString[1] = 'x'; - snprintf(this->_addressString + 2, 9, "%08X", theAddress); - this->_addressString[10] = '\0'; - - if (this->_cheatType == CheatType_Internal) - { - this->_ConvertInternalToActionReplay(); - } -} - -const char* ClientCheatItem::GetAddressString() const -{ - return this->_addressString; -} - -const char* ClientCheatItem::GetAddressSixDigitString() const -{ - return (this->_addressString + 4); -} - -void ClientCheatItem::SetAddressSixDigitString(const char *sixDigitString) -{ - this->_addressString[0] = '0'; - this->_addressString[1] = 'x'; - this->_addressString[2] = '0'; - this->_addressString[3] = '2'; - - if (sixDigitString == NULL) - { - this->_addressString[4] = '0'; - this->_addressString[5] = '0'; - this->_addressString[6] = '0'; - this->_addressString[7] = '0'; - this->_addressString[8] = '0'; - this->_addressString[9] = '0'; - } - else - { - this->_addressString[4] = sixDigitString[0]; - this->_addressString[5] = sixDigitString[1]; - this->_addressString[6] = sixDigitString[2]; - this->_addressString[7] = sixDigitString[3]; - this->_addressString[8] = sixDigitString[4]; - this->_addressString[9] = sixDigitString[5]; - } - - this->_addressString[10] = '\0'; - - u32 theAddress = 0; - sscanf(this->_addressString + 2, "%x", &theAddress); - - if ( (this->_address != theAddress) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - this->_address = theAddress; - - if (this->_cheatType == CheatType_Internal) - { - this->_ConvertInternalToActionReplay(); - } -} - -uint32_t ClientCheatItem::GetValue() const -{ - return this->_value; -} - -void ClientCheatItem::SetValue(uint32_t theValue) -{ - if ( (this->_value != theValue) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - this->_value = theValue; - - if (this->_cheatType == CheatType_Internal) - { - this->_ConvertInternalToActionReplay(); - } -} - -uint8_t ClientCheatItem::GetValueLength() const -{ - return this->_valueLength; -} - -void ClientCheatItem::SetValueLength(uint8_t byteLength) -{ - if ( (this->_valueLength != byteLength) && (this->_cheatType == CheatType_Internal) && (this->_cheatManager != NULL) && this->_isEnabled ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - this->_valueLength = byteLength; - - if (this->_cheatType == CheatType_Internal) - { - this->_ConvertInternalToActionReplay(); - } -} - -void ClientCheatItem::SetRawCodeString(const char *rawString, const bool willSaveValidatedRawString) -{ - std::string newCleanCodeString; - - size_t cleanCodeCount = CheatConvertRawCodeToCleanCode(rawString, 1024, this->_cleanCodeString); - if (cleanCodeCount == 0) - { - return; - } - - this->_codeCount = (uint32_t)cleanCodeCount; - - if (willSaveValidatedRawString) - { - // Using the validated clean code string, the raw code string will be - // rewritten using the following format for each line: - // XXXXXXXX XXXXXXXX\n - CheatConvertCleanCodeToRawCode(this->_cleanCodeString.c_str(), this->_rawCodeString); - } - else - { - // The passed in raw code string will be saved, regardless of any syntax - // errors, flaws, or formatting issues that it may contain. - this->_rawCodeString = rawString; - } - - if ( (this->_cheatType == CheatType_ActionReplay) && (this->_cheatManager != NULL) && this->_isEnabled ) - { - this->_cheatManager->MasterNeedsUpdate(); - } - - if (this->_cheatType == CheatType_ActionReplay) - { - this->_ConvertActionReplayToInternal(); - } -} - -const char* ClientCheatItem::GetRawCodeString() const -{ - return this->_rawCodeString.c_str(); -} - -const char* ClientCheatItem::GetCleanCodeString() const -{ - return this->_cleanCodeString.c_str(); -} - -const std::string& ClientCheatItem::GetCleanCodeCppString() const -{ - return this->_cleanCodeString; -} - -uint32_t ClientCheatItem::GetCodeCount() const -{ - return this->_codeCount; -} - -void ClientCheatItem::_ConvertInternalToActionReplay() -{ - char workingCodeBuffer[16+1+1]; - - u32 function = this->_address & 0x0FFFFFFF; - u32 truncatedValue = this->_value; - - switch (this->_valueLength) - { - case 1: - function |= 0x20000000; - truncatedValue &= 0x000000FF; - break; - - case 2: - function |= 0x10000000; - truncatedValue &= 0x0000FFFF; - break; - - case 3: - truncatedValue &= 0x00FFFFFF; - break; - - default: - break; - } - - memset(workingCodeBuffer, 0, sizeof(workingCodeBuffer)); - snprintf(workingCodeBuffer, 16+1+1, "%08X %08X", function, truncatedValue); - this->_rawCodeString = workingCodeBuffer; - - memset(workingCodeBuffer, 0, sizeof(workingCodeBuffer)); - snprintf(workingCodeBuffer, 16+1, "%08X%08X", function, truncatedValue); - this->_cleanCodeString = workingCodeBuffer; - - this->_codeCount = 1; -} - -void ClientCheatItem::_ConvertActionReplayToInternal() -{ - char workingCodeBuffer[11] = {0}; - size_t cleanCodeLength = this->_cleanCodeString.length(); - size_t i = 0; - - // Note that we're only searching for the first valid command for - // a constant RAM write, since internal cheats can only support a - // single constant RAM write. - for (; i < cleanCodeLength; i+=16) - { - workingCodeBuffer[0] = '0'; - workingCodeBuffer[1] = 'x'; - strncpy(workingCodeBuffer + 2, this->_cleanCodeString.c_str() + i, 8); - workingCodeBuffer[10] = '\0'; - - if (workingCodeBuffer[2] == '2') - { - this->_valueLength = 1; - workingCodeBuffer[2] = '0'; - break; - } - else if (workingCodeBuffer[2] == '1') - { - this->_valueLength = 2; - workingCodeBuffer[2] = '0'; - break; - } - else if (workingCodeBuffer[2] == '0') - { - this->_valueLength = 4; - break; - } - else - { - continue; - } - } - - if (i >= cleanCodeLength) - { - return; - } - - strncpy(this->_addressString, workingCodeBuffer, sizeof(this->_addressString)); - sscanf(workingCodeBuffer + 2, "%x", &this->_address); - - memset(workingCodeBuffer, 0, sizeof(workingCodeBuffer)); - strncpy(workingCodeBuffer, this->_cleanCodeString.c_str() + i + 8, 8); - sscanf(workingCodeBuffer, "%x", &this->_value); - - switch (this->_valueLength) - { - case 1: - this->_value &= 0x000000FF; - break; - - case 2: - this->_value &= 0x0000FFFF; - break; - - default: - break; - } -} - -void ClientCheatItem::ClientToDesmumeCheatItem(CHEATS_LIST *outCheatItem) const -{ - if (outCheatItem == NULL) - { - return; - } - - outCheatItem->type = this->_cheatType; - outCheatItem->enabled = (this->_isEnabled) ? 1 : 0; - strncpy(outCheatItem->description, this->_nameString.c_str(), sizeof(outCheatItem->description)); - - switch (this->_cheatType) - { - case CheatType_Internal: - outCheatItem->num = 1; - outCheatItem->size = this->_valueLength - 1; // CHEATS_LIST.size value range is [1...4], but starts counting from 0. - outCheatItem->freezeType = (u8)this->_freezeType; - outCheatItem->code[0][0] = this->_address; - outCheatItem->code[0][1] = this->_value; - break; - - case CheatType_ActionReplay: - case CheatType_CodeBreaker: - { - outCheatItem->num = this->_codeCount; - outCheatItem->size = 3; - outCheatItem->freezeType = CheatFreezeType_Normal; - - char valueString[9]; - valueString[8] = '\0'; - - const char *cleanCodeStr = this->_cleanCodeString.c_str(); - for (size_t i = 0; i < this->_codeCount; i++) - { - strncpy(valueString, cleanCodeStr + (i * 16) + 0, 8); - sscanf(valueString, "%x", &outCheatItem->code[i][0]); - - strncpy(valueString, cleanCodeStr + (i * 16) + 8, 8); - sscanf(valueString, "%x", &outCheatItem->code[i][1]); - } - break; - } - - default: - break; - } -} - -#pragma mark - - -ClientCheatList::ClientCheatList() -{ - _list = new std::vector; -} - -ClientCheatList::~ClientCheatList() -{ - delete this->_list; - this->_list = NULL; -} - -CheatSystemError ClientCheatList::LoadFromFile(const char *filePath) -{ - CheatSystemError error = CheatSystemError_NoError; - - if (filePath == NULL) - { - error = CheatSystemError_FileOpenFailed; - return error; - } - - CHEATS *tempEngineList = new CHEATS; - tempEngineList->init((char *)filePath); - this->ReplaceFromEngine(tempEngineList); - delete tempEngineList; - - return error; -} - -CheatSystemError ClientCheatList::SaveToFile(const char *filePath) -{ - CheatSystemError error = CheatSystemError_NoError; - - if (filePath == NULL) - { - error = CheatSystemError_FileOpenFailed; - return error; - } - - CHEATS *tempEngineList = new CHEATS; - tempEngineList->setFilePath(filePath); - - this->CopyListToEngine(false, tempEngineList); - - bool isSaveSuccessful = tempEngineList->save(); - if (!isSaveSuccessful) - { - error = CheatSystemError_FileSaveFailed; - } - - delete tempEngineList; - - return error; -} - -bool ClientCheatList::IsItemDuplicate(const ClientCheatItem *srcItem) -{ - bool isDuplicateFound = false; - if (srcItem == NULL) - { - return isDuplicateFound; - } - - const CheatType compareType = srcItem->GetType(); - - const size_t totalCheatCount = this->_list->size(); - for (size_t i = 0; i < totalCheatCount; i++) - { - const ClientCheatItem *itemToCheck = (*this->_list)[i]; - if (itemToCheck == NULL) - { - continue; - } - - if (srcItem == itemToCheck) - { - isDuplicateFound = true; - break; - } - - switch (compareType) - { - case CheatType_Internal: - isDuplicateFound = ( (srcItem->GetAddress() == itemToCheck->GetAddress()) && - (srcItem->GetValue() == itemToCheck->GetValue()) && - (srcItem->GetValueLength() == itemToCheck->GetValueLength()) ); - break; - - case CheatType_ActionReplay: - isDuplicateFound = ( (srcItem->GetCodeCount() == itemToCheck->GetCodeCount()) && - (srcItem->GetCleanCodeCppString() == itemToCheck->GetCleanCodeCppString()) ); - break; - - case CheatType_CodeBreaker: - default: - break; - } - - if (isDuplicateFound) - { - break; - } - } - - return isDuplicateFound; -} - -ClientCheatItem* ClientCheatList::__AddItem(const ClientCheatItem *srcItem, const bool willCopy, const bool allowDuplicates) -{ - ClientCheatItem *newItem = NULL; - if (srcItem == NULL) - { - return newItem; - } - - if (allowDuplicates || !this->IsItemDuplicate(srcItem)) - { - if (willCopy) - { - this->_list->push_back(new ClientCheatItem); - newItem->Init(*srcItem); - } - else - { - this->_list->push_back((ClientCheatItem *)srcItem); - } - - newItem = this->_list->back(); - } - - return newItem; -} - -ClientCheatItem* ClientCheatList::AddNew() -{ - ClientCheatItem *newItem = new ClientCheatItem; - return this->__AddItem(newItem, false, true); -} - -ClientCheatItem* ClientCheatList::AddNewItemCopy(const ClientCheatItem *srcItem) -{ - return this->__AddItem(srcItem, true, true); -} - -ClientCheatItem* ClientCheatList::AddNewItemCopyNoDuplicate(const ClientCheatItem *srcItem) -{ - return this->__AddItem(srcItem, true, false); -} - -ClientCheatItem* ClientCheatList::AddExistingItemNoDuplicate(const ClientCheatItem *srcItem) -{ - return this->__AddItem(srcItem, false, false); -} - -bool ClientCheatList::Remove(ClientCheatItem *targetItem) -{ - return this->RemoveAtIndex( this->GetIndexOfItem(targetItem) ); -} - -bool ClientCheatList::RemoveAtIndex(size_t index) -{ - bool didRemoveItem = false; - ClientCheatItem *targetItem = this->GetItemAtIndex(index); - - if (targetItem != NULL) - { - this->_list->erase( this->_list->begin() + index ); - delete targetItem; - didRemoveItem = true; - } - - return didRemoveItem; -} - -void ClientCheatList::RemoveAll() -{ - const size_t cheatCount = this->_list->size(); - for (size_t i = 0; i < cheatCount; i++) - { - ClientCheatItem *itemToRemove = (*this->_list)[i]; - delete itemToRemove; - } - - this->_list->clear(); -} - -bool ClientCheatList::Update(const ClientCheatItem &srcItem, ClientCheatItem *targetItem) -{ - return this->UpdateAtIndex(srcItem, this->GetIndexOfItem(targetItem)); -} - -bool ClientCheatList::UpdateAtIndex(const ClientCheatItem &srcItem, size_t index) -{ - bool didUpdateItem = false; - ClientCheatItem *targetItem = this->GetItemAtIndex(index); - - if (targetItem != NULL) - { - targetItem->Init(srcItem); - didUpdateItem = true; - } - - return didUpdateItem; -} - -size_t ClientCheatList::GetTotalCheatCount() const -{ - return this->_list->size(); -} - -size_t ClientCheatList::GetActiveCheatCount() const -{ - size_t activeCount = 0; - const size_t totalCount = this->_list->size(); - - for (size_t i = 0; i < totalCount; i++) - { - ClientCheatItem *cheatItem = (*this->_list)[i]; - if (cheatItem->IsEnabled()) - { - activeCount++; - } - } - - return activeCount; -} - -std::vector* ClientCheatList::GetCheatList() const -{ - return this->_list; -} - -size_t ClientCheatList::GetIndexOfItem(const ClientCheatItem *cheatItem) const -{ - size_t outIndex = ~0; - if (cheatItem == NULL) - { - return outIndex; - } - - const size_t cheatCount = this->_list->size(); - for (size_t i = 0; i < cheatCount; i++) - { - if (cheatItem == (*this->_list)[i]) - { - return outIndex; - } - } - - return outIndex; -} - -ClientCheatItem* ClientCheatList::GetItemAtIndex(size_t index) const -{ - if (index >= this->GetTotalCheatCount()) - { - return NULL; - } - - return (*this->_list)[index]; -} - -void ClientCheatList::ReplaceFromEngine(const CHEATS *engineCheatList) -{ - if (engineCheatList == NULL) - { - return; - } - - this->RemoveAll(); - - const size_t totalCount = engineCheatList->getListSize(); - for (size_t i = 0; i < totalCount; i++) - { - ClientCheatItem *newItem = this->AddNew(); - newItem->Init( *engineCheatList->getItemPtrAtIndex(i) ); - } -} - -void ClientCheatList::CopyListToEngine(const bool willApplyOnlyEnabledItems, CHEATS *engineCheatList) -{ - if (engineCheatList == NULL) - { - return; - } - - CHEATS_LIST tempEngineItem; - - engineCheatList->clear(); - - const size_t totalCount = this->_list->size(); - for (size_t i = 0; i < totalCount; i++) - { - ClientCheatItem *cheatItem = (*this->_list)[i]; - if (cheatItem->IsEnabled() || !willApplyOnlyEnabledItems) - { - cheatItem->ClientToDesmumeCheatItem(&tempEngineItem); - engineCheatList->addItem(tempEngineItem); - } - } -} - -#pragma mark - - -ClientCheatSearcher::ClientCheatSearcher() -{ - _desmumeSearcher = new CHEATSEARCH; - _searchValueLength = 4; - _resultsCount = 0; - _didSearchStart = false; - _resultsList.resize(0); -} - -ClientCheatSearcher::~ClientCheatSearcher() -{ - delete this->_desmumeSearcher; -} - -bool ClientCheatSearcher::DidStart() const -{ - return this->_didSearchStart; -} - -void ClientCheatSearcher::Reset() -{ - this->_desmumeSearcher->close(); - this->_didSearchStart = false; - this->_resultsCount = 0; - - this->_desmumeSearcher->getListReset(); - this->_resultsList.resize(0); -} - -size_t ClientCheatSearcher::SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch) -{ - if (!this->_didSearchStart) - { - this->_searchValueLength = valueLength; - this->_didSearchStart = this->_desmumeSearcher->start((u8)CheatSearchStyle_ExactValue, this->_searchValueLength - 1, 0); - this->_resultsCount = 0; - this->_resultsList.resize(0); - } - - if (this->_didSearchStart) - { - this->_resultsCount = (size_t)this->_desmumeSearcher->search(value); - this->RefreshResults(); - } - - return this->_resultsCount; -} - -size_t ClientCheatSearcher::SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch) -{ - if (!this->_didSearchStart) - { - this->_searchValueLength = valueLength; - this->_didSearchStart = this->_desmumeSearcher->start((u8)CheatSearchStyle_Comparative, this->_searchValueLength - 1, 0); - this->_resultsCount = 0; - this->_resultsList.resize(0); - } - else - { - this->_resultsCount = (size_t)this->_desmumeSearcher->search((u8)compareStyle); - this->RefreshResults(); - } - - return this->_resultsCount; -} - -const DesmumeCheatSearchResultsList& ClientCheatSearcher::RefreshResults() -{ - bool didReadResult = false; - u32 readAddress = 0; - u32 readValue = 0; - size_t readResultIndex = 0; - - this->_desmumeSearcher->getListReset(); - this->_resultsList.clear(); - - for (size_t i = 0; i < this->_resultsCount; i++) - { - didReadResult = this->_desmumeSearcher->getList(&readAddress, &readValue); - if (didReadResult) - { - DesmumeCheatSearchItem searchResult; - searchResult.address = readAddress; - searchResult.value = readValue; - - this->_resultsList.push_back(searchResult); - readResultIndex++; - } - } - - return this->_resultsList; -} - -const DesmumeCheatSearchResultsList& ClientCheatSearcher::GetResults() -{ - return this->_resultsList; -} - -size_t ClientCheatSearcher::GetResultCount() const -{ - return this->_resultsCount; -} - -#pragma mark - - -ClientCheatDatabase::ClientCheatDatabase() -{ - _list = new ClientCheatList; - _title.resize(0); - _description.resize(0); - _lastFilePath.resize(0); -} - -ClientCheatDatabase::~ClientCheatDatabase() -{ - delete this->_list; -} - -ClientCheatList* ClientCheatDatabase::GetList() const -{ - return this->_list; -} - -ClientCheatList* ClientCheatDatabase::LoadFromFile(const char *dbFilePath) -{ - if (dbFilePath == NULL) - { - return NULL; - } - - CHEATSEXPORT *exporter = new CHEATSEXPORT(); - CheatSystemError dbError = CheatSystemError_NoError; - - bool didFileLoad = exporter->load((char *)dbFilePath); - if (didFileLoad) - { - this->_list->RemoveAll(); - this->_title = exporter->getGameTitle(); - this->_description = exporter->getDescription(); - this->_lastFilePath = dbFilePath; - - const size_t itemCount = exporter->getCheatsNum(); - const CHEATS_LIST *dbItem = exporter->getCheats(); - - for (size_t i = 0; i < itemCount; i++) - { - ClientCheatItem *newItem = this->_list->AddNew(); - if (newItem != NULL) - { - newItem->Init(dbItem[i]); - } - } - } - else - { - dbError = exporter->getErrorCode(); - } - - delete exporter; - exporter = nil; - - if (dbError != CheatSystemError_NoError) - { - return NULL; - } - - return this->_list; -} - -const char* ClientCheatDatabase::GetTitle() const -{ - return this->_title.c_str(); -} - -const char* ClientCheatDatabase::GetDescription() const -{ - return this->_description.c_str(); -} - -#pragma mark - - -ClientCheatManager::ClientCheatManager() -{ - _currentSessionList = new ClientCheatList; - _currentDatabase = new ClientCheatDatabase; - _currentSearcher = new ClientCheatSearcher; - _pendingInternalCheatWriteList.resize(0); - - _selectedItem = NULL; - _selectedItemIndex = 0; - - _untitledCount = 0; - - _currentSessionLastFilePath.resize(0); - - _masterNeedsUpdate = true; -} - -ClientCheatManager::~ClientCheatManager() -{ - delete this->_currentSearcher; - delete this->_currentDatabase; - delete this->_currentSessionList; -} - -CHEATS* ClientCheatManager::GetMaster() -{ - return cheats; -} - -void ClientCheatManager::SetMaster(const CHEATS *masterCheats) -{ - cheats = (CHEATS *)masterCheats; -} - -ClientCheatList* ClientCheatManager::GetSessionList() const -{ - return this->_currentSessionList; -} - -const char* ClientCheatManager::GetSessionListLastFilePath() const -{ - return this->_currentSessionLastFilePath.c_str(); -} - -CheatSystemError ClientCheatManager::SessionListLoadFromFile(const char *filePath) -{ - CheatSystemError error = CheatSystemError_NoError; - - if (filePath == NULL) - { - error = CheatSystemError_FileOpenFailed; - return error; - } - - error = this->_currentSessionList->LoadFromFile(filePath); - if (error == CheatSystemError_NoError) - { - this->_currentSessionLastFilePath = filePath; - - const size_t totalCount = this->_currentSessionList->GetTotalCheatCount(); - for (size_t i = 0; i < totalCount; i++) - { - ClientCheatItem *cheatItem = this->_currentSessionList->GetItemAtIndex(i); - cheatItem->SetCheatManager(this); - } - } - - return error; -} - -CheatSystemError ClientCheatManager::SessionListSaveToFile(const char *filePath) -{ - CheatSystemError error = CheatSystemError_NoError; - - if (filePath == NULL) - { - error = CheatSystemError_FileSaveFailed; - return error; - } - - error = this->_currentSessionList->SaveToFile(filePath); - if (error == CheatSystemError_NoError) - { - this->_currentSessionLastFilePath = filePath; - } - - return error; -} - -ClientCheatItem* ClientCheatManager::SetSelectedItemByIndex(size_t index) -{ - this->_selectedItemIndex = index; - this->_selectedItem = this->_currentSessionList->GetItemAtIndex(index); - - return this->_selectedItem; -} - -ClientCheatItem* ClientCheatManager::NewItem() -{ - ClientCheatItem *newItem = this->_currentSessionList->AddNew(); - newItem->SetCheatManager(this); - - this->_untitledCount++; - if (this->_untitledCount > 1) - { - char newDesc[16]; - snprintf(newDesc, sizeof(newDesc), "Untitled %ld", (unsigned long)this->_untitledCount); - - newItem->SetName(newDesc); - } - else - { - newItem->SetName("Untitled"); - } - - if (newItem->IsEnabled()) - { - this->_masterNeedsUpdate = true; - } - - return newItem; -} - -ClientCheatItem* ClientCheatManager::AddExistingItemNoDuplicate(const ClientCheatItem *theItem) -{ - ClientCheatItem *addedItem = this->_currentSessionList->AddExistingItemNoDuplicate(theItem); - if (addedItem != NULL) - { - addedItem->SetCheatManager(this); - - if (addedItem->IsEnabled()) - { - this->_masterNeedsUpdate = true; - } - } - - return addedItem; -} - -void ClientCheatManager::RemoveItem(ClientCheatItem *targetItem) -{ - this->RemoveItemAtIndex( this->_currentSessionList->GetIndexOfItem(targetItem) ); -} - -void ClientCheatManager::RemoveItemAtIndex(size_t index) -{ - const ClientCheatItem *targetItem = this->_currentSessionList->GetItemAtIndex(index); - if (targetItem == NULL) - { - return; - } - - const bool willChangeMasterUpdateFlag = targetItem->IsEnabled(); - const bool didRemoveItem = this->_currentSessionList->RemoveAtIndex(index); - - if (didRemoveItem && willChangeMasterUpdateFlag) - { - this->_masterNeedsUpdate = true; - } -} - -void ClientCheatManager::RemoveSelectedItem() -{ - this->RemoveItemAtIndex(this->_selectedItemIndex); -} - -void ClientCheatManager::ModifyItem(const ClientCheatItem *srcItem, ClientCheatItem *targetItem) -{ - if ( (srcItem != NULL) && (srcItem == targetItem) ) - { - if (targetItem->IsEnabled()) - { - this->_masterNeedsUpdate = true; - } - return; - } - - this->ModifyItemAtIndex(srcItem, this->_currentSessionList->GetIndexOfItem(targetItem)); -} - -void ClientCheatManager::ModifyItemAtIndex(const ClientCheatItem *srcItem, size_t index) -{ - const ClientCheatItem *targetItem = this->_currentSessionList->GetItemAtIndex(index); - if ( (srcItem == NULL) || (targetItem == NULL) ) - { - return; - } - - const bool willChangeMasterUpdateFlag = targetItem->IsEnabled(); - const bool didModifyItem = this->_currentSessionList->UpdateAtIndex(*srcItem, index); - - if (didModifyItem && willChangeMasterUpdateFlag) - { - this->_masterNeedsUpdate = true; - } -} - -size_t ClientCheatManager::GetTotalCheatCount() const -{ - return this->_currentSessionList->GetTotalCheatCount(); -} - -size_t ClientCheatManager::GetActiveCheatCount() const -{ - return this->_currentSessionList->GetActiveCheatCount(); -} - -void ClientCheatManager::LoadFromMaster() -{ - size_t activeCount = 0; - const CHEATS *masterCheats = ClientCheatManager::GetMaster(); - - if (masterCheats == NULL) - { - return; - } - - this->_currentSessionLastFilePath = masterCheats->getFilePath(); - - activeCount = this->_currentSessionList->GetActiveCheatCount(); - if (activeCount > 0) - { - this->_masterNeedsUpdate = true; - } - - this->_currentSessionList->ReplaceFromEngine(masterCheats); - - const size_t totalCount = this->_currentSessionList->GetTotalCheatCount(); - for (size_t i = 0; i < totalCount; i++) - { - ClientCheatItem *cheatItem = this->_currentSessionList->GetItemAtIndex(i); - cheatItem->SetCheatManager(this); - } - - activeCount = this->_currentSessionList->GetActiveCheatCount(); - if (activeCount > 0) - { - this->_masterNeedsUpdate = true; - } -} - -void ClientCheatManager::ApplyToMaster() -{ - CHEATS *masterCheats = ClientCheatManager::GetMaster(); - if ( (masterCheats == NULL) || !this->_masterNeedsUpdate ) - { - return; - } - - this->_currentSessionList->CopyListToEngine(true, masterCheats); - this->_masterNeedsUpdate = false; -} - -void ClientCheatManager::MasterNeedsUpdate() -{ - this->_masterNeedsUpdate = true; -} - -ClientCheatList* ClientCheatManager::GetDatabaseList() const -{ - return this->_currentDatabase->GetList(); -} - -ClientCheatList* ClientCheatManager::DatabaseListLoadFromFile(const char *dbFilePath) -{ - return this->_currentDatabase->LoadFromFile(dbFilePath); -} - -const char* ClientCheatManager::GetDatabaseTitle() const -{ - return this->_currentDatabase->GetTitle(); -} - -const char* ClientCheatManager::GetDatabaseDescription() const -{ - return this->_currentDatabase->GetDescription(); -} - -bool ClientCheatManager::SearchDidStart() const -{ - return this->_currentSearcher->DidStart(); -} - -void ClientCheatManager::SearchReset() -{ - this->_currentSearcher->Reset(); -} - -size_t ClientCheatManager::SearchExactValue(uint32_t value, uint8_t valueLength, bool performSignedSearch) -{ - return this->_currentSearcher->SearchExactValue(value, valueLength, performSignedSearch); -} - -size_t ClientCheatManager::SearchComparative(CheatSearchCompareStyle compareStyle, uint8_t valueLength, bool performSignedSearch) -{ - return this->_currentSearcher->SearchComparative(compareStyle, valueLength, performSignedSearch); -} - -const DesmumeCheatSearchResultsList& ClientCheatManager::SearchResultsRefresh() -{ - return this->_currentSearcher->RefreshResults(); -} - -const DesmumeCheatSearchResultsList& ClientCheatManager::GetSearchResults() -{ - return this->_currentSearcher->GetResults(); -} - -size_t ClientCheatManager::GetSearchResultCount() const -{ - return this->_currentSearcher->GetResultCount(); -} - -void ClientCheatManager::DirectWriteInternalCheatAtIndex(size_t index) -{ - this->DirectWriteInternalCheatItem( this->_currentSessionList->GetItemAtIndex(index) ); -} - -void ClientCheatManager::DirectWriteInternalCheatItem(const ClientCheatItem *cheatItem) -{ - if ( (cheatItem == NULL) || (cheatItem->GetType() != CheatType_Internal) ) - { - return; - } - - this->DirectWriteInternalCheat( cheatItem->GetAddress(), cheatItem->GetValue(), cheatItem->GetValueLength() ); -} - -void ClientCheatManager::DirectWriteInternalCheat(uint32_t targetAddress, uint32_t newValue32, size_t newValueLength) -{ - targetAddress &= 0x00FFFFFF; - targetAddress |= 0x02000000; - - InternalCheatParam cheatWrite; - cheatWrite.address = targetAddress; - cheatWrite.value = newValue32; - cheatWrite.valueLength = newValueLength; - - this->_pendingInternalCheatWriteList.push_back(cheatWrite); -} - -void ClientCheatManager::ApplyPendingInternalCheatWrites() -{ - bool needsJitReset = false; - - const size_t writeListSize = this->_pendingInternalCheatWriteList.size(); - if (writeListSize == 0) - { - return; - } - - for (size_t i = 0; i < writeListSize; i++) - { - const InternalCheatParam cheatWrite = this->_pendingInternalCheatWriteList[i]; - - const bool shouldResetJit = CHEATS::DirectWrite(cheatWrite.valueLength, ARMCPU_ARM9, cheatWrite.address, cheatWrite.value); - if (shouldResetJit) - { - needsJitReset = true; - } - } - - this->_pendingInternalCheatWriteList.clear(); - - if (needsJitReset) - { - CHEATS::JitNeedsReset(); - CHEATS::ResetJitIfNeeded(); - } -} - -#pragma mark - - @implementation CocoaDSCheatItem static NSImage *iconDirectory = nil; diff --git a/desmume/src/frontend/cocoa/cocoa_core.mm b/desmume/src/frontend/cocoa/cocoa_core.mm index 7c780fdf0..a45f15efc 100644 --- a/desmume/src/frontend/cocoa/cocoa_core.mm +++ b/desmume/src/frontend/cocoa/cocoa_core.mm @@ -27,6 +27,7 @@ #include "macOS_driver.h" #include "ClientAVCaptureObject.h" +#include "ClientCheatManager.h" #include "ClientExecutionControl.h" #include "ClientInputHandler.h" #include "ClientEmulationOutput.h" diff --git a/desmume/src/frontend/cocoa/cocoa_firmware.h b/desmume/src/frontend/cocoa/cocoa_firmware.h index 5f88b4990..d32519d78 100644 --- a/desmume/src/frontend/cocoa/cocoa_firmware.h +++ b/desmume/src/frontend/cocoa/cocoa_firmware.h @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Roger Manuel - Copyright (C) 2012-2018 DeSmuME team + Copyright (C) 2012-2025 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,32 +17,11 @@ */ #import -#include class ClientExecutionControl; -class FirmwareConfigInterface; +class ClientFirmwareControl; struct FirmwareConfig; -enum FirmwareCfgAPID -{ - FirmwareCfgAPID_AP1 = 0, - FirmwareCfgAPID_AP2 = 1, - FirmwareCfgAPID_AP3 = 2 -}; - -enum FirmwareCfgMACAddrSetID -{ - FirmwareCfgMACAddrSetID_Firmware = 0, - FirmwareCfgMACAddrSetID_Custom1 = 1, - FirmwareCfgMACAddrSetID_Custom2 = 2, - FirmwareCfgMACAddrSetID_Custom3 = 3, - FirmwareCfgMACAddrSetID_Custom4 = 4, - FirmwareCfgMACAddrSetID_Custom5 = 5, - FirmwareCfgMACAddrSetID_Custom6 = 6, - FirmwareCfgMACAddrSetID_Custom7 = 7, - FirmwareCfgMACAddrSetID_Custom8 = 8 -}; - /******************************************************************************************** CocoaDSFirmware - OBJECTIVE-C CLASS @@ -54,7 +33,7 @@ enum FirmwareCfgMACAddrSetID @interface CocoaDSFirmware : NSObject { ClientExecutionControl *execControl; - FirmwareConfigInterface *_fwConfigInterface; + ClientFirmwareControl *_fwControl; FirmwareConfig *_appliedFWConfig; NSUInteger _birth_year; @@ -158,95 +137,3 @@ enum FirmwareCfgMACAddrSetID - (void) writeUserDefaultWFCUserID; @end - -class FirmwareConfigInterface -{ -protected: - FirmwareConfig *_internalData; - - FirmwareCfgMACAddrSetID _macAddressSelection; - uint32_t _firmwareMACAddressValue; - uint32_t _customMACAddressValue; - char _macAddressString[(1 + 8) * 18]; - char _wfcUserIDString[20]; - char _subnetMaskString[3 * 16]; - -public: - FirmwareConfigInterface(); - ~FirmwareConfigInterface(); - - static void WriteMACAddressStringToBuffer(const uint8_t mac4, const uint8_t mac5, const uint8_t mac6, char *stringBuffer); - static void WriteMACAddressStringToBuffer(const uint32_t macAddressValue, char *stringBuffer); - static void WriteWFCUserIDStringToBuffer(const uint64_t wfcUserIDValue, char *stringBuffer); - - const FirmwareConfig& GetFirmwareConfig(); - uint32_t GenerateRandomMACValue(); - - FirmwareCfgMACAddrSetID GetMACAddressSelection(); - void SetMACAddressSelection(FirmwareCfgMACAddrSetID addressSetID); - - uint32_t GetMACAddressValue(FirmwareCfgMACAddrSetID addressSetID); - const char* GetMACAddressString(FirmwareCfgMACAddrSetID addressSetID); - uint32_t GetSelectedMACAddressValue(); - uint64_t GetSelectedWFCUserID64(); - const char* GetSelectedMACAddressString(); - - void SetFirmwareMACAddressValue(uint32_t macAddressValue); - void SetFirmwareMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6); - void SetCustomMACAddressValue(uint32_t macAddressValue); - void SetCustomMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6); - - uint8_t* GetWFCUserID(); - void SetWFCUserID(uint8_t *wfcUserID); - - uint64_t GetWFCUserID64(); - void SetWFCUserID64(uint64_t wfcUserIDValue); - - const char* GetWFCUserIDString(); - - uint8_t GetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart); - void SetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); - - uint8_t GetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart); - void SetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); - - uint8_t GetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart); - void SetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); - - uint8_t GetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart); - void SetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue); - - uint8_t GetSubnetMask(FirmwareCfgAPID apid); - const char* GetSubnetMaskString(FirmwareCfgAPID apid); - void SetSubnetMask(FirmwareCfgAPID apid, uint8_t subnetMaskShift); - - int GetConsoleType(); - void SetConsoleType(int type); - - uint16_t* GetNicknameStringBuffer(); - void SetNicknameWithStringBuffer(uint16_t *buffer, size_t charLength); - - size_t GetNicknameStringLength(); - void SetNicknameStringLength(size_t charLength); - - uint16_t* GetMessageStringBuffer(); - void SetMessageWithStringBuffer(uint16_t *buffer, size_t charLength); - - size_t GetMessageStringLength(); - void SetMessageStringLength(size_t charLength); - - int GetFavoriteColorByID(); - void SetFavoriteColorByID(int colorID); - - int GetBirthdayDay(); - void SetBirthdayDay(int day); - - int GetBirthdayMonth(); - void SetBirthdayMonth(int month); - - int GetLanguageByID(); - void SetLanguageByID(int languageID); - - int GetBacklightLevel(); - void SetBacklightLevel(int level); -}; diff --git a/desmume/src/frontend/cocoa/cocoa_firmware.mm b/desmume/src/frontend/cocoa/cocoa_firmware.mm index cb0384d79..a4fe9e20e 100644 --- a/desmume/src/frontend/cocoa/cocoa_firmware.mm +++ b/desmume/src/frontend/cocoa/cocoa_firmware.mm @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Roger Manuel - Copyright (C) 2012-2023 DeSmuME team + Copyright (C) 2012-2025 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,10 +17,10 @@ */ #import "cocoa_firmware.h" + +#include "ClientFirmwareControl.h" #include "ClientExecutionControl.h" -#include "../../NDSSystem.h" #include "../../firmware.h" -#include "../../MMU.h" #undef BOOL @@ -113,20 +113,20 @@ } execControl = NULL; - _fwConfigInterface = new FirmwareConfigInterface; + _fwControl = new ClientFirmwareControl; _appliedFWConfig = (FirmwareConfig *)malloc(sizeof(FirmwareConfig)); _birth_year = 1970; - firmwareMACAddressString = [[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Firmware) encoding:NSUTF8StringEncoding] retain]; + firmwareMACAddressString = [[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Firmware) encoding:NSUTF8StringEncoding] retain]; firmwareMACAddressPendingString = [[firmwareMACAddressString copy] retain]; - customMACAddress1String = [[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom1) encoding:NSUTF8StringEncoding] retain]; - customMACAddress2String = [[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom2) encoding:NSUTF8StringEncoding] retain]; - customMACAddress3String = [[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom3) encoding:NSUTF8StringEncoding] retain]; - customMACAddress4String = [[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom4) encoding:NSUTF8StringEncoding] retain]; + customMACAddress1String = [[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom1) encoding:NSUTF8StringEncoding] retain]; + customMACAddress2String = [[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom2) encoding:NSUTF8StringEncoding] retain]; + customMACAddress3String = [[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom3) encoding:NSUTF8StringEncoding] retain]; + customMACAddress4String = [[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom4) encoding:NSUTF8StringEncoding] retain]; - subnetMaskString_AP1 = [[NSString stringWithCString:_fwConfigInterface->GetSubnetMaskString(FirmwareCfgAPID_AP1) encoding:NSUTF8StringEncoding] retain]; - subnetMaskString_AP2 = [[NSString stringWithCString:_fwConfigInterface->GetSubnetMaskString(FirmwareCfgAPID_AP2) encoding:NSUTF8StringEncoding] retain]; - subnetMaskString_AP3 = [[NSString stringWithCString:_fwConfigInterface->GetSubnetMaskString(FirmwareCfgAPID_AP3) encoding:NSUTF8StringEncoding] retain]; + subnetMaskString_AP1 = [[NSString stringWithCString:_fwControl->GetSubnetMaskString(FirmwareCfgAPID_AP1) encoding:NSUTF8StringEncoding] retain]; + subnetMaskString_AP2 = [[NSString stringWithCString:_fwControl->GetSubnetMaskString(FirmwareCfgAPID_AP2) encoding:NSUTF8StringEncoding] retain]; + subnetMaskString_AP3 = [[NSString stringWithCString:_fwControl->GetSubnetMaskString(FirmwareCfgAPID_AP3) encoding:NSUTF8StringEncoding] retain]; return self; } @@ -144,7 +144,7 @@ [self setSubnetMaskString_AP2:nil]; [self setSubnetMaskString_AP3:nil]; - delete _fwConfigInterface; + delete _fwControl; free(_appliedFWConfig); [super dealloc]; @@ -193,23 +193,23 @@ - (void) setAddressSelection:(NSInteger)selection { - _fwConfigInterface->SetMACAddressSelection((FirmwareCfgMACAddrSetID)selection); + _fwControl->SetMACAddressSelection((FirmwareCfgMACAddrSetID)selection); } - (NSInteger) addressSelection { - return (NSInteger)_fwConfigInterface->GetMACAddressSelection(); + return (NSInteger)_fwControl->GetMACAddressSelection(); } - (void) setFirmwareMACAddressPendingValue:(uint32_t)inMACAddressValue { - _fwConfigInterface->SetFirmwareMACAddressValue(inMACAddressValue); - [self setFirmwareMACAddressPendingString:[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Firmware) encoding:NSUTF8StringEncoding]]; + _fwControl->SetFirmwareMACAddressValue(inMACAddressValue); + [self setFirmwareMACAddressPendingString:[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Firmware) encoding:NSUTF8StringEncoding]]; } - (uint32_t) firmwareMACAddressPendingValue { - return _fwConfigInterface->GetMACAddressValue(FirmwareCfgMACAddrSetID_Firmware); + return _fwControl->GetMACAddressValue(FirmwareCfgMACAddrSetID_Firmware); } - (uint32_t) firmwareMACAddressValue @@ -224,545 +224,545 @@ - (void) setCustomMACAddressValue:(uint32_t)inMACAddressValue { - _fwConfigInterface->SetCustomMACAddressValue(inMACAddressValue); - [self setCustomMACAddress1String:[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom1) encoding:NSUTF8StringEncoding]]; - [self setCustomMACAddress2String:[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom2) encoding:NSUTF8StringEncoding]]; - [self setCustomMACAddress3String:[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom3) encoding:NSUTF8StringEncoding]]; - [self setCustomMACAddress4String:[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom4) encoding:NSUTF8StringEncoding]]; + _fwControl->SetCustomMACAddressValue(inMACAddressValue); + [self setCustomMACAddress1String:[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom1) encoding:NSUTF8StringEncoding]]; + [self setCustomMACAddress2String:[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom2) encoding:NSUTF8StringEncoding]]; + [self setCustomMACAddress3String:[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom3) encoding:NSUTF8StringEncoding]]; + [self setCustomMACAddress4String:[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Custom4) encoding:NSUTF8StringEncoding]]; } - (uint32_t) customMACAddressValue { - return (_fwConfigInterface->GetMACAddressValue(FirmwareCfgMACAddrSetID_Custom1) - 1); + return (_fwControl->GetMACAddressValue(FirmwareCfgMACAddrSetID_Custom1) - 1); } - (void) setIpv4Address_AP1_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP1_1 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 0); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 0); } - (void) setIpv4Address_AP1_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP1_2 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 1); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 1); } - (void) setIpv4Address_AP1_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP1_3 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 2); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 2); } - (void) setIpv4Address_AP1_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP1_4 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 3); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP1, 3); } - (void) setIpv4Gateway_AP1_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP1_1 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 0); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 0); } - (void) setIpv4Gateway_AP1_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP1_2 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 1); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 1); } - (void) setIpv4Gateway_AP1_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP1_3 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 2); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 2); } - (void) setIpv4Gateway_AP1_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP1_4 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 3); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP1, 3); } - (void) setIpv4PrimaryDNS_AP1_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP1_1 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 0); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 0); } - (void) setIpv4PrimaryDNS_AP1_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP1_2 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 1); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 1); } - (void) setIpv4PrimaryDNS_AP1_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP1_3 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 2); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 2); } - (void) setIpv4PrimaryDNS_AP1_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP1_4 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 3); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP1, 3); } - (void) setIpv4SecondaryDNS_AP1_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 0, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP1_1 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 0); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 0); } - (void) setIpv4SecondaryDNS_AP1_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 1, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP1_2 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 1); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 1); } - (void) setIpv4SecondaryDNS_AP1_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 2, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP1_3 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 2); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 2); } - (void) setIpv4SecondaryDNS_AP1_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 3, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP1_4 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 3); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP1, 3); } - (void) setSubnetMask_AP1:(NSInteger)subnetMask { - _fwConfigInterface->SetSubnetMask(FirmwareCfgAPID_AP1, (uint8_t)subnetMask); + _fwControl->SetSubnetMask(FirmwareCfgAPID_AP1, (uint8_t)subnetMask); - NSString *subnetMaskString = [NSString stringWithCString:_fwConfigInterface->GetSubnetMaskString(FirmwareCfgAPID_AP1) encoding:NSUTF8StringEncoding]; + NSString *subnetMaskString = [NSString stringWithCString:_fwControl->GetSubnetMaskString(FirmwareCfgAPID_AP1) encoding:NSUTF8StringEncoding]; [self setSubnetMaskString_AP1:subnetMaskString]; } - (NSInteger) subnetMask_AP1 { - return (NSInteger)_fwConfigInterface->GetSubnetMask(FirmwareCfgAPID_AP1); + return (NSInteger)_fwControl->GetSubnetMask(FirmwareCfgAPID_AP1); } - (void) setIpv4Address_AP2_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP2_1 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 0); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 0); } - (void) setIpv4Address_AP2_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP2_2 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 1); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 1); } - (void) setIpv4Address_AP2_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP2_3 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 2); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 2); } - (void) setIpv4Address_AP2_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP2_4 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 3); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP2, 3); } - (void) setIpv4Gateway_AP2_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP2_1 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 0); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 0); } - (void) setIpv4Gateway_AP2_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP2_2 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 1); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 1); } - (void) setIpv4Gateway_AP2_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP2_3 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 2); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 2); } - (void) setIpv4Gateway_AP2_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP2_4 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 3); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP2, 3); } - (void) setIpv4PrimaryDNS_AP2_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP2_1 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 0); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 0); } - (void) setIpv4PrimaryDNS_AP2_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP2_2 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 1); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 1); } - (void) setIpv4PrimaryDNS_AP2_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP2_3 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 2); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 2); } - (void) setIpv4PrimaryDNS_AP2_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP2_4 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 3); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP2, 3); } - (void) setIpv4SecondaryDNS_AP2_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 0, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP2_1 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 0); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 0); } - (void) setIpv4SecondaryDNS_AP2_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 1, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP2_2 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 1); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 1); } - (void) setIpv4SecondaryDNS_AP2_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 2, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP2_3 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 2); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 2); } - (void) setIpv4SecondaryDNS_AP2_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 3, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP2_4 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 3); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP2, 3); } - (void) setSubnetMask_AP2:(NSInteger)subnetMask { - _fwConfigInterface->SetSubnetMask(FirmwareCfgAPID_AP2, (uint8_t)subnetMask); + _fwControl->SetSubnetMask(FirmwareCfgAPID_AP2, (uint8_t)subnetMask); - NSString *subnetMaskString = [NSString stringWithCString:_fwConfigInterface->GetSubnetMaskString(FirmwareCfgAPID_AP2) encoding:NSUTF8StringEncoding]; + NSString *subnetMaskString = [NSString stringWithCString:_fwControl->GetSubnetMaskString(FirmwareCfgAPID_AP2) encoding:NSUTF8StringEncoding]; [self setSubnetMaskString_AP2:subnetMaskString]; } - (NSInteger) subnetMask_AP2 { - return (NSInteger)_fwConfigInterface->GetSubnetMask(FirmwareCfgAPID_AP2); + return (NSInteger)_fwControl->GetSubnetMask(FirmwareCfgAPID_AP2); } - (void) setIpv4Address_AP3_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP3_1 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 0); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 0); } - (void) setIpv4Address_AP3_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP3_2 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 1); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 1); } - (void) setIpv4Address_AP3_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP3_3 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 2); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 2); } - (void) setIpv4Address_AP3_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); + _fwControl->SetIPv4AddressPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); } - (NSInteger) ipv4Address_AP3_4 { - return (NSInteger)_fwConfigInterface->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 3); + return (NSInteger)_fwControl->GetIPv4AddressPart(FirmwareCfgAPID_AP3, 3); } - (void) setIpv4Gateway_AP3_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP3_1 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 0); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 0); } - (void) setIpv4Gateway_AP3_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP3_2 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 1); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 1); } - (void) setIpv4Gateway_AP3_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP3_3 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 2); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 2); } - (void) setIpv4Gateway_AP3_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); + _fwControl->SetIPv4GatewayPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); } - (NSInteger) ipv4Gateway_AP3_4 { - return (NSInteger)_fwConfigInterface->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 3); + return (NSInteger)_fwControl->GetIPv4GatewayPart(FirmwareCfgAPID_AP3, 3); } - (void) setIpv4PrimaryDNS_AP3_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP3_1 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 0); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 0); } - (void) setIpv4PrimaryDNS_AP3_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP3_2 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 1); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 1); } - (void) setIpv4PrimaryDNS_AP3_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP3_3 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 2); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 2); } - (void) setIpv4PrimaryDNS_AP3_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); + _fwControl->SetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); } - (NSInteger) ipv4PrimaryDNS_AP3_4 { - return (NSInteger)_fwConfigInterface->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 3); + return (NSInteger)_fwControl->GetIPv4PrimaryDNSPart(FirmwareCfgAPID_AP3, 3); } - (void) setIpv4SecondaryDNS_AP3_1:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 0, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP3_1 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 0); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 0); } - (void) setIpv4SecondaryDNS_AP3_2:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 1, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP3_2 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 1); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 1); } - (void) setIpv4SecondaryDNS_AP3_3:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 2, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP3_3 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 2); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 2); } - (void) setIpv4SecondaryDNS_AP3_4:(NSInteger)addrValue { - _fwConfigInterface->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); + _fwControl->SetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 3, (uint8_t)addrValue); } - (NSInteger) ipv4SecondaryDNS_AP3_4 { - return (NSInteger)_fwConfigInterface->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 3); + return (NSInteger)_fwControl->GetIPv4SecondaryDNSPart(FirmwareCfgAPID_AP3, 3); } - (void) setSubnetMask_AP3:(NSInteger)subnetMask { - _fwConfigInterface->SetSubnetMask(FirmwareCfgAPID_AP3, (uint8_t)subnetMask); + _fwControl->SetSubnetMask(FirmwareCfgAPID_AP3, (uint8_t)subnetMask); - NSString *subnetMaskString = [NSString stringWithCString:_fwConfigInterface->GetSubnetMaskString(FirmwareCfgAPID_AP3) encoding:NSUTF8StringEncoding]; + NSString *subnetMaskString = [NSString stringWithCString:_fwControl->GetSubnetMaskString(FirmwareCfgAPID_AP3) encoding:NSUTF8StringEncoding]; [self setSubnetMaskString_AP3:subnetMaskString]; } - (NSInteger) subnetMask_AP3 { - return (NSInteger)_fwConfigInterface->GetSubnetMask(FirmwareCfgAPID_AP3); + return (NSInteger)_fwControl->GetSubnetMask(FirmwareCfgAPID_AP3); } - (void) setConsoleType:(NSInteger)theType { - _fwConfigInterface->SetConsoleType((int)theType); + _fwControl->SetConsoleType((int)theType); } - (NSInteger) consoleType { - return (NSInteger)_fwConfigInterface->GetConsoleType(); + return (NSInteger)_fwControl->GetConsoleType(); } - (void) setNickname:(NSString *)theNickname @@ -776,7 +776,7 @@ characterRange.length = MAX_FW_NICKNAME_LENGTH; } - [theNickname getBytes:_fwConfigInterface->GetNicknameStringBuffer() + [theNickname getBytes:_fwControl->GetNicknameStringBuffer() maxLength:(sizeof(uint16_t) * characterRange.length) usedLength:NULL encoding:NSUTF16LittleEndianStringEncoding @@ -784,17 +784,17 @@ range:characterRange remainingRange:NULL]; - _fwConfigInterface->SetNicknameStringLength((uint8_t)characterRange.length); + _fwControl->SetNicknameStringLength((uint8_t)characterRange.length); } else { - _fwConfigInterface->SetNicknameWithStringBuffer(NULL, 0); + _fwControl->SetNicknameWithStringBuffer(NULL, 0); } } - (NSString *) nickname { - return [[[NSString alloc] initWithBytes:_fwConfigInterface->GetNicknameStringBuffer() length:(sizeof(uint16_t) * _fwConfigInterface->GetNicknameStringLength()) encoding:NSUTF16LittleEndianStringEncoding] autorelease]; + return [[[NSString alloc] initWithBytes:_fwControl->GetNicknameStringBuffer() length:(sizeof(uint16_t) * _fwControl->GetNicknameStringLength()) encoding:NSUTF16LittleEndianStringEncoding] autorelease]; } - (void) setMessage:(NSString *)theMessage @@ -808,7 +808,7 @@ characterRange.length = MAX_FW_MESSAGE_LENGTH; } - [theMessage getBytes:_fwConfigInterface->GetMessageStringBuffer() + [theMessage getBytes:_fwControl->GetMessageStringBuffer() maxLength:(sizeof(uint16_t) * characterRange.length) usedLength:NULL encoding:NSUTF16LittleEndianStringEncoding @@ -816,27 +816,27 @@ range:characterRange remainingRange:NULL]; - _fwConfigInterface->SetMessageStringLength((uint8_t)characterRange.length); + _fwControl->SetMessageStringLength((uint8_t)characterRange.length); } else { - _fwConfigInterface->SetMessageWithStringBuffer(NULL, 0); + _fwControl->SetMessageWithStringBuffer(NULL, 0); } } - (NSString *) message { - return [[[NSString alloc] initWithBytes:_fwConfigInterface->GetMessageStringBuffer() length:(sizeof(uint16_t) * _fwConfigInterface->GetMessageStringLength()) encoding:NSUTF16LittleEndianStringEncoding] autorelease]; + return [[[NSString alloc] initWithBytes:_fwControl->GetMessageStringBuffer() length:(sizeof(uint16_t) * _fwControl->GetMessageStringLength()) encoding:NSUTF16LittleEndianStringEncoding] autorelease]; } - (void) setFavoriteColor:(NSInteger)colorID { - _fwConfigInterface->SetFavoriteColorByID((int)colorID); + _fwControl->SetFavoriteColorByID((int)colorID); } - (NSInteger) favoriteColor { - return (NSInteger)_fwConfigInterface->GetFavoriteColorByID(); + return (NSInteger)_fwControl->GetFavoriteColorByID(); } - (void) setBirthday:(NSDate *)theDate @@ -855,15 +855,15 @@ [df release]; } - _fwConfigInterface->SetBirthdayMonth(theMonth); - _fwConfigInterface->SetBirthdayDay(theDay); + _fwControl->SetBirthdayMonth(theMonth); + _fwControl->SetBirthdayDay(theDay); _birth_year = theYear; } - (NSDate *) birthday { - int theMonth = _fwConfigInterface->GetBirthdayMonth(); - int theDay = _fwConfigInterface->GetBirthdayDay(); + int theMonth = _fwControl->GetBirthdayMonth(); + int theDay = _fwControl->GetBirthdayDay(); int theYear = (int)_birth_year; NSDateFormatter *df = [[NSDateFormatter alloc] init]; @@ -878,35 +878,35 @@ - (void) setLanguage:(NSInteger)languageID { - _fwConfigInterface->SetLanguageByID((int)languageID); + _fwControl->SetLanguageByID((int)languageID); } - (NSInteger) language { - return (NSInteger)_fwConfigInterface->GetLanguageByID(); + return (NSInteger)_fwControl->GetLanguageByID(); } - (void) setBacklightLevel:(NSInteger)level { - _fwConfigInterface->SetBacklightLevel((int)level); + _fwControl->SetBacklightLevel((int)level); } - (NSInteger) backlightLevel { - return (NSInteger)_fwConfigInterface->GetBacklightLevel(); + return (NSInteger)_fwControl->GetBacklightLevel(); } - (void) applySettings { - *_appliedFWConfig = _fwConfigInterface->GetFirmwareConfig(); - [self setFirmwareMACAddressString:[NSString stringWithCString:_fwConfigInterface->GetMACAddressString(FirmwareCfgMACAddrSetID_Firmware) encoding:NSUTF8StringEncoding]]; + *_appliedFWConfig = _fwControl->GetFirmwareConfig(); + [self setFirmwareMACAddressString:[NSString stringWithCString:_fwControl->GetMACAddressString(FirmwareCfgMACAddrSetID_Firmware) encoding:NSUTF8StringEncoding]]; } - (void) updateFirmwareConfigSessionValues { NSNumber *wfcUserIDNumber = nil; NSDictionary *wfcUserIDDict = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"FirmwareConfig_WFCUserID"]; - const FirmwareCfgMACAddrSetID selectionID = _fwConfigInterface->GetMACAddressSelection(); + const FirmwareCfgMACAddrSetID selectionID = _fwControl->GetMACAddressSelection(); uint32_t macAddressValue = 0; if (selectionID == FirmwareCfgMACAddrSetID_Firmware) @@ -918,7 +918,7 @@ } else { - macAddressValue = _fwConfigInterface->GetMACAddressValue(selectionID); + macAddressValue = _fwControl->GetMACAddressValue(selectionID); } if ( (wfcUserIDDict != nil) && ([wfcUserIDDict count] > 0) ) @@ -935,7 +935,7 @@ } else { - macAddressValueString = [NSString stringWithCString:_fwConfigInterface->GetSelectedMACAddressString() encoding:NSUTF8StringEncoding]; + macAddressValueString = [NSString stringWithCString:_fwControl->GetSelectedMACAddressString() encoding:NSUTF8StringEncoding]; } wfcUserIDNumber = (NSNumber *)[wfcUserIDDict objectForKey:macAddressValueString]; @@ -943,7 +943,7 @@ } const uint64_t wfcUserIDValue = (wfcUserIDNumber == nil) ? 0 : (uint64_t)[wfcUserIDNumber unsignedLongLongValue]; - _fwConfigInterface->SetWFCUserID64(wfcUserIDValue); + _fwControl->SetWFCUserID64(wfcUserIDValue); FirmwareConfig finalConfig = *_appliedFWConfig; @@ -966,7 +966,7 @@ - (uint32_t) generateRandomFirmwareMACAddress { - const uint32_t randomMACAddressValue = _fwConfigInterface->GenerateRandomMACValue(); + const uint32_t randomMACAddressValue = _fwControl->GenerateRandomMACValue(); [self setFirmwareMACAddressPendingValue:randomMACAddressValue]; return randomMACAddressValue; @@ -974,751 +974,10 @@ - (uint32_t) generateRandomCustomMACAddress { - const uint32_t randomMACAddressValue = _fwConfigInterface->GenerateRandomMACValue(); + const uint32_t randomMACAddressValue = _fwControl->GenerateRandomMACValue(); [self setCustomMACAddressValue:randomMACAddressValue]; return randomMACAddressValue; } @end - -FirmwareConfigInterface::FirmwareConfigInterface() -{ - _macAddressSelection = FirmwareCfgMACAddrSetID_Firmware; - - // First, get the default firmware config. - _internalData = (FirmwareConfig *)malloc(sizeof(FirmwareConfig)); - NDS_GetDefaultFirmwareConfig(*_internalData); - - srand((uint32_t)time(NULL)); - - // Generate a random firmware MAC address and its associated string. - const uint32_t defaultFirmwareMACAddressValue = (uint32_t)_internalData->MACAddress[2] | ((uint32_t)_internalData->MACAddress[3] << 8) | ((uint32_t)_internalData->MACAddress[4] << 16) | ((uint32_t)_internalData->MACAddress[5] << 24); - - do - { - _firmwareMACAddressValue = (uint32_t)rand() & 0x00FFFFFF; - _firmwareMACAddressValue = (_firmwareMACAddressValue << 8) | 0x000000BF; - } while ( (_firmwareMACAddressValue == 0x000000BF) || (_firmwareMACAddressValue == 0xFFFFFFBF) || (_firmwareMACAddressValue == defaultFirmwareMACAddressValue) ); - - _internalData->MACAddress[2] = (uint8_t)( _firmwareMACAddressValue & 0x000000FF); - _internalData->MACAddress[3] = (uint8_t)((_firmwareMACAddressValue >> 8) & 0x000000FF); - _internalData->MACAddress[4] = (uint8_t)((_firmwareMACAddressValue >> 16) & 0x000000FF); - _internalData->MACAddress[5] = (uint8_t)((_firmwareMACAddressValue >> 24) & 0x000000FF); - - memset(_macAddressString, '\0', sizeof(_macAddressString)); - FirmwareConfigInterface::WriteMACAddressStringToBuffer(_internalData->MACAddress[3], _internalData->MACAddress[4], _internalData->MACAddress[5], &_macAddressString[0]); - - // Generate a random custom MAC address set and their associated strings. - do - { - _customMACAddressValue = (uint32_t)rand() & 0x00FFFFFF; - _customMACAddressValue = (_customMACAddressValue << 8) | 0x000000BF; - } while ( (_customMACAddressValue == 0x000000BF) || (_customMACAddressValue == 0xFFFFFFBF) || ((_customMACAddressValue & 0xF0FFFFFF) == (_firmwareMACAddressValue & 0xF0FFFFFF)) ); - - const uint8_t customMAC4 = (_customMACAddressValue >> 8) & 0x000000FF; - const uint8_t customMAC5 = (_customMACAddressValue >> 16) & 0x000000FF; - const uint8_t customMAC6 = (_customMACAddressValue >> 24) & 0x000000F0; - - for (size_t i = 1; i <= 8; i++) - { - FirmwareConfigInterface::WriteMACAddressStringToBuffer(customMAC4, customMAC5, customMAC6 + (uint8_t)i, &_macAddressString[18*i]); - } - - // Generate the WFC User ID string. - memset(_wfcUserIDString, '\0', sizeof(_wfcUserIDString)); - const uint64_t wfcUserIDValue = (uint64_t)_internalData->WFCUserID[0] | - ((uint64_t)_internalData->WFCUserID[1] << 8) | - ((uint64_t)_internalData->WFCUserID[2] << 16) | - ((uint64_t)_internalData->WFCUserID[3] << 24) | - ((uint64_t)_internalData->WFCUserID[4] << 32) | - ((uint64_t)_internalData->WFCUserID[5] << 40); - FirmwareConfigInterface::WriteWFCUserIDStringToBuffer(wfcUserIDValue, _wfcUserIDString); - - // Generate the subnet mask strings. - memset(_subnetMaskString, '\0', sizeof(_subnetMaskString)); - - uint32_t subnetMaskValue = (_internalData->subnetMask_AP1 == 0) ? 0 : (0xFFFFFFFF << (32 - _internalData->subnetMask_AP1)); - snprintf(&_subnetMaskString[0], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); - - subnetMaskValue = (_internalData->subnetMask_AP2 == 0) ? 0 : (0xFFFFFFFF << (32 - _internalData->subnetMask_AP2)); - snprintf(&_subnetMaskString[16], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); - - subnetMaskValue = (_internalData->subnetMask_AP3 == 0) ? 0 : (0xFFFFFFFF << (32 - _internalData->subnetMask_AP3)); - snprintf(&_subnetMaskString[32], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); -} - -FirmwareConfigInterface::~FirmwareConfigInterface() -{ - free(this->_internalData); - this->_internalData = NULL; -} - -void FirmwareConfigInterface::WriteMACAddressStringToBuffer(const uint8_t mac4, const uint8_t mac5, const uint8_t mac6, char *stringBuffer) -{ - if (stringBuffer == NULL) - { - return; - } - - snprintf(stringBuffer, 18, "00:09:BF:%02X:%02X:%02X", mac4, mac5, mac6); -} - -void FirmwareConfigInterface::WriteMACAddressStringToBuffer(const uint32_t macAddressValue, char *stringBuffer) -{ - if (stringBuffer == NULL) - { - return; - } - - const uint8_t mac4 = (macAddressValue >> 8) & 0x000000FF; - const uint8_t mac5 = (macAddressValue >> 16) & 0x000000FF; - const uint8_t mac6 = (macAddressValue >> 24) & 0x000000FF; - - FirmwareConfigInterface::WriteMACAddressStringToBuffer(mac4, mac5, mac6, stringBuffer); -} - -void FirmwareConfigInterface::WriteWFCUserIDStringToBuffer(const uint64_t wfcUserIDValue, char *stringBuffer) -{ - if (stringBuffer == NULL) - { - return; - } - - const unsigned long long wfcUserIDValuePrint = (wfcUserIDValue & 0x000007FFFFFFFFFFULL) * 1000ULL; - const unsigned long long wfcUserIDValuePrint1 = wfcUserIDValuePrint / 1000000000000ULL; - const unsigned long long wfcUserIDValuePrint2 = (wfcUserIDValuePrint / 100000000ULL) - (wfcUserIDValuePrint1 * 10000ULL); - const unsigned long long wfcUserIDValuePrint3 = (wfcUserIDValuePrint / 10000ULL) - (wfcUserIDValuePrint1 * 100000000ULL) - (wfcUserIDValuePrint2 * 10000ULL); - const unsigned long long wfcUserIDValuePrint4 = wfcUserIDValuePrint - (wfcUserIDValuePrint1 * 1000000000000ULL) - (wfcUserIDValuePrint2 * 100000000ULL) - (wfcUserIDValuePrint3 * 10000ULL); - snprintf(stringBuffer, 20, "%04llu-%04llu-%04llu-%04llu", wfcUserIDValuePrint1, wfcUserIDValuePrint2, wfcUserIDValuePrint3, wfcUserIDValuePrint4); -} - -const FirmwareConfig& FirmwareConfigInterface::GetFirmwareConfig() -{ - return *this->_internalData; -} - -uint32_t FirmwareConfigInterface::GenerateRandomMACValue() -{ - uint32_t randomMACAddressValue = 0; - - do - { - randomMACAddressValue = (uint32_t)rand() & 0x00FFFFFF; - randomMACAddressValue = (randomMACAddressValue << 8) | 0x000000BF; - } while ( (randomMACAddressValue == 0x000000BF) || (randomMACAddressValue == 0xFFFFFFBF) || ((randomMACAddressValue & 0xF0FFFFFF) == (this->_firmwareMACAddressValue & 0xF0FFFFFF)) || ((randomMACAddressValue & 0xF0FFFFFF) == (this->_customMACAddressValue & 0xF0FFFFFF)) ); - - return randomMACAddressValue; -} - -FirmwareCfgMACAddrSetID FirmwareConfigInterface::GetMACAddressSelection() -{ - return this->_macAddressSelection; -} - -void FirmwareConfigInterface::SetMACAddressSelection(FirmwareCfgMACAddrSetID addressSetID) -{ - switch (addressSetID) - { - case FirmwareCfgMACAddrSetID_Firmware: - this->_macAddressSelection = FirmwareCfgMACAddrSetID_Firmware; - this->_internalData->MACAddress[0] = 0x00; - this->_internalData->MACAddress[1] = 0x09; - this->_internalData->MACAddress[2] = (uint8_t)( this->_firmwareMACAddressValue & 0x000000FF); - this->_internalData->MACAddress[3] = (uint8_t)((this->_firmwareMACAddressValue >> 8) & 0x000000FF); - this->_internalData->MACAddress[4] = (uint8_t)((this->_firmwareMACAddressValue >> 16) & 0x000000FF); - this->_internalData->MACAddress[5] = (uint8_t)((this->_firmwareMACAddressValue >> 24) & 0x000000FF); - break; - - case FirmwareCfgMACAddrSetID_Custom1: - case FirmwareCfgMACAddrSetID_Custom2: - case FirmwareCfgMACAddrSetID_Custom3: - case FirmwareCfgMACAddrSetID_Custom4: - case FirmwareCfgMACAddrSetID_Custom5: - case FirmwareCfgMACAddrSetID_Custom6: - case FirmwareCfgMACAddrSetID_Custom7: - case FirmwareCfgMACAddrSetID_Custom8: - { - this->_macAddressSelection = addressSetID; - this->_internalData->MACAddress[0] = 0x00; - this->_internalData->MACAddress[1] = 0x09; - this->_internalData->MACAddress[2] = (uint8_t)( this->_customMACAddressValue & 0x000000FF); - this->_internalData->MACAddress[3] = (uint8_t)((this->_customMACAddressValue >> 8) & 0x000000FF); - this->_internalData->MACAddress[4] = (uint8_t)((this->_customMACAddressValue >> 16) & 0x000000FF); - this->_internalData->MACAddress[5] = (uint8_t)((this->_customMACAddressValue >> 24) & 0x000000F0); - - switch (addressSetID) - { - case FirmwareCfgMACAddrSetID_Custom1: this->_internalData->MACAddress[5] += 1; break; - case FirmwareCfgMACAddrSetID_Custom2: this->_internalData->MACAddress[5] += 2; break; - case FirmwareCfgMACAddrSetID_Custom3: this->_internalData->MACAddress[5] += 3; break; - case FirmwareCfgMACAddrSetID_Custom4: this->_internalData->MACAddress[5] += 4; break; - case FirmwareCfgMACAddrSetID_Custom5: this->_internalData->MACAddress[5] += 5; break; - case FirmwareCfgMACAddrSetID_Custom6: this->_internalData->MACAddress[5] += 6; break; - case FirmwareCfgMACAddrSetID_Custom7: this->_internalData->MACAddress[5] += 7; break; - case FirmwareCfgMACAddrSetID_Custom8: this->_internalData->MACAddress[5] += 8; break; - default: break; - } - - break; - } - - default: - break; - } -} - -uint32_t FirmwareConfigInterface::GetMACAddressValue(FirmwareCfgMACAddrSetID addressSetID) -{ - switch (addressSetID) - { - case FirmwareCfgMACAddrSetID_Firmware: return this->_firmwareMACAddressValue; - case FirmwareCfgMACAddrSetID_Custom1: return this->_customMACAddressValue + 0x01000000; - case FirmwareCfgMACAddrSetID_Custom2: return this->_customMACAddressValue + 0x02000000; - case FirmwareCfgMACAddrSetID_Custom3: return this->_customMACAddressValue + 0x03000000; - case FirmwareCfgMACAddrSetID_Custom4: return this->_customMACAddressValue + 0x04000000; - case FirmwareCfgMACAddrSetID_Custom5: return this->_customMACAddressValue + 0x05000000; - case FirmwareCfgMACAddrSetID_Custom6: return this->_customMACAddressValue + 0x06000000; - case FirmwareCfgMACAddrSetID_Custom7: return this->_customMACAddressValue + 0x07000000; - case FirmwareCfgMACAddrSetID_Custom8: return this->_customMACAddressValue + 0x08000000; - default: break; - } - - return 0; -} - -const char* FirmwareConfigInterface::GetMACAddressString(FirmwareCfgMACAddrSetID addressSetID) -{ - switch (addressSetID) - { - case FirmwareCfgMACAddrSetID_Firmware: return &this->_macAddressString[18*0]; - case FirmwareCfgMACAddrSetID_Custom1: return &this->_macAddressString[18*1]; - case FirmwareCfgMACAddrSetID_Custom2: return &this->_macAddressString[18*2]; - case FirmwareCfgMACAddrSetID_Custom3: return &this->_macAddressString[18*3]; - case FirmwareCfgMACAddrSetID_Custom4: return &this->_macAddressString[18*4]; - case FirmwareCfgMACAddrSetID_Custom5: return &this->_macAddressString[18*5]; - case FirmwareCfgMACAddrSetID_Custom6: return &this->_macAddressString[18*6]; - case FirmwareCfgMACAddrSetID_Custom7: return &this->_macAddressString[18*7]; - case FirmwareCfgMACAddrSetID_Custom8: return &this->_macAddressString[18*8]; - default: break; - } - - return ""; -} - -uint32_t FirmwareConfigInterface::GetSelectedMACAddressValue() -{ - const uint32_t selectedMACAddressValue = (uint32_t)this->_internalData->MACAddress[2] | ((uint32_t)this->_internalData->MACAddress[3] << 8) | ((uint32_t)this->_internalData->MACAddress[4] << 16) | ((uint32_t)this->_internalData->MACAddress[5] << 24); - return selectedMACAddressValue; -} - -uint64_t FirmwareConfigInterface::GetSelectedWFCUserID64() -{ - const uint64_t selectedUserID64 = (uint64_t)this->_internalData->WFCUserID[0] | - ((uint64_t)this->_internalData->WFCUserID[1] << 8) | - ((uint64_t)this->_internalData->WFCUserID[2] << 16) | - ((uint64_t)this->_internalData->WFCUserID[3] << 24) | - ((uint64_t)this->_internalData->WFCUserID[4] << 32) | - ((uint64_t)this->_internalData->WFCUserID[5] << 40); - return selectedUserID64; -} - -const char* FirmwareConfigInterface::GetSelectedMACAddressString() -{ - return this->GetMACAddressString(this->_macAddressSelection); -} - -void FirmwareConfigInterface::SetFirmwareMACAddressValue(uint32_t macAddressValue) -{ - const uint8_t mac4 = (macAddressValue >> 8) & 0x000000FF; - const uint8_t mac5 = (macAddressValue >> 16) & 0x000000FF; - const uint8_t mac6 = (macAddressValue >> 24) & 0x000000FF; - - this->SetFirmwareMACAddressValue(mac4, mac5, mac6); -} - -void FirmwareConfigInterface::SetFirmwareMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6) -{ - this->_firmwareMACAddressValue = 0x000000BF | ((uint32_t)mac4 << 8) | ((uint32_t)mac5 << 16) | ((uint32_t)mac6 << 24); - FirmwareConfigInterface::WriteMACAddressStringToBuffer(mac4, mac5, mac6, &this->_macAddressString[0]); - - if (this->_macAddressSelection == FirmwareCfgMACAddrSetID_Firmware) - { - this->SetMACAddressSelection(FirmwareCfgMACAddrSetID_Firmware); - } -} - -void FirmwareConfigInterface::SetCustomMACAddressValue(uint32_t macAddressValue) -{ - const uint8_t mac4 = (macAddressValue >> 8) & 0x000000FF; - const uint8_t mac5 = (macAddressValue >> 16) & 0x000000FF; - const uint8_t mac6 = (macAddressValue >> 24) & 0x000000F0; - - this->SetCustomMACAddressValue(mac4, mac5, mac6); -} - -void FirmwareConfigInterface::SetCustomMACAddressValue(uint8_t mac4, uint8_t mac5, uint8_t mac6) -{ - mac6 &= 0xF0; - this->_customMACAddressValue = 0x000000BF | ((uint32_t)mac4 << 8) | ((uint32_t)mac5 << 16) | ((uint32_t)mac6 << 24); - - for (size_t i = 1; i <= 8; i++) - { - FirmwareConfigInterface::WriteMACAddressStringToBuffer(mac4, mac5, mac6 + (uint8_t)i, &this->_macAddressString[18*i]); - } - - if (this->_macAddressSelection != FirmwareCfgMACAddrSetID_Firmware) - { - this->SetMACAddressSelection(this->_macAddressSelection); - } -} - -uint8_t* FirmwareConfigInterface::GetWFCUserID() -{ - return this->_internalData->WFCUserID; -} - -void FirmwareConfigInterface::SetWFCUserID(uint8_t *wfcUserID) -{ - const uint64_t wfcUserIDValue = (uint64_t)wfcUserID[0] | - ((uint64_t)wfcUserID[1] << 8) | - ((uint64_t)wfcUserID[2] << 16) | - ((uint64_t)wfcUserID[3] << 24) | - ((uint64_t)wfcUserID[4] << 32) | - ((uint64_t)wfcUserID[5] << 40); - - this->SetWFCUserID64(wfcUserIDValue); -} - -uint64_t FirmwareConfigInterface::GetWFCUserID64() -{ - const uint64_t userID = (uint64_t)this->_internalData->WFCUserID[0] | - ((uint64_t)this->_internalData->WFCUserID[1] << 8) | - ((uint64_t)this->_internalData->WFCUserID[2] << 16) | - ((uint64_t)this->_internalData->WFCUserID[3] << 24) | - ((uint64_t)this->_internalData->WFCUserID[4] << 32) | - ((uint64_t)this->_internalData->WFCUserID[5] << 40); - return userID; -} - -void FirmwareConfigInterface::SetWFCUserID64(uint64_t wfcUserIDValue) -{ - if ( (wfcUserIDValue & 0x000007FFFFFFFFFFULL) != 0) - { - this->_internalData->WFCUserID[0] = (uint8_t)( wfcUserIDValue & 0x00000000000000FFULL); - this->_internalData->WFCUserID[1] = (uint8_t)((wfcUserIDValue >> 8) & 0x00000000000000FFULL); - this->_internalData->WFCUserID[2] = (uint8_t)((wfcUserIDValue >> 16) & 0x00000000000000FFULL); - this->_internalData->WFCUserID[3] = (uint8_t)((wfcUserIDValue >> 24) & 0x00000000000000FFULL); - this->_internalData->WFCUserID[4] = (uint8_t)((wfcUserIDValue >> 32) & 0x00000000000000FFULL); - this->_internalData->WFCUserID[5] = (uint8_t)((wfcUserIDValue >> 40) & 0x00000000000000FFULL); - } - else - { - this->_internalData->WFCUserID[0] = 0; - this->_internalData->WFCUserID[1] = 0; - this->_internalData->WFCUserID[2] = 0; - this->_internalData->WFCUserID[3] = 0; - this->_internalData->WFCUserID[4] = 0; - this->_internalData->WFCUserID[5] = 0; - } - - FirmwareConfigInterface::WriteWFCUserIDStringToBuffer(wfcUserIDValue, this->_wfcUserIDString); -} - -const char* FirmwareConfigInterface::GetWFCUserIDString() -{ - return this->_wfcUserIDString; -} - -uint8_t FirmwareConfigInterface::GetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart) -{ - if (addrPart > 3) - { - return 0; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: return this->_internalData->ipv4Address_AP1[addrPart]; - case FirmwareCfgAPID_AP2: return this->_internalData->ipv4Address_AP2[addrPart]; - case FirmwareCfgAPID_AP3: return this->_internalData->ipv4Address_AP3[addrPart]; - } - - return 0; -} - -void FirmwareConfigInterface::SetIPv4AddressPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) -{ - if (addrPart > 3) - { - return; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: this->_internalData->ipv4Address_AP1[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP2: this->_internalData->ipv4Address_AP2[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP3: this->_internalData->ipv4Address_AP3[addrPart] = addrValue; break; - } -} - -uint8_t FirmwareConfigInterface::GetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart) -{ - if (addrPart > 3) - { - return 0; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: return this->_internalData->ipv4Gateway_AP1[addrPart]; - case FirmwareCfgAPID_AP2: return this->_internalData->ipv4Gateway_AP2[addrPart]; - case FirmwareCfgAPID_AP3: return this->_internalData->ipv4Gateway_AP3[addrPart]; - } - - return 0; -} - -void FirmwareConfigInterface::SetIPv4GatewayPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) -{ - if (addrPart > 3) - { - return; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: this->_internalData->ipv4Gateway_AP1[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP2: this->_internalData->ipv4Gateway_AP2[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP3: this->_internalData->ipv4Gateway_AP3[addrPart] = addrValue; break; - } -} - -uint8_t FirmwareConfigInterface::GetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart) -{ - if (addrPart > 3) - { - return 0; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: return this->_internalData->ipv4PrimaryDNS_AP1[addrPart]; - case FirmwareCfgAPID_AP2: return this->_internalData->ipv4PrimaryDNS_AP2[addrPart]; - case FirmwareCfgAPID_AP3: return this->_internalData->ipv4PrimaryDNS_AP3[addrPart]; - } - - return 0; -} - -void FirmwareConfigInterface::SetIPv4PrimaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) -{ - if (addrPart > 3) - { - return; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: this->_internalData->ipv4PrimaryDNS_AP1[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP2: this->_internalData->ipv4PrimaryDNS_AP2[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP3: this->_internalData->ipv4PrimaryDNS_AP3[addrPart] = addrValue; break; - } -} - -uint8_t FirmwareConfigInterface::GetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart) -{ - if (addrPart > 3) - { - return 0; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: return this->_internalData->ipv4SecondaryDNS_AP1[addrPart]; - case FirmwareCfgAPID_AP2: return this->_internalData->ipv4SecondaryDNS_AP2[addrPart]; - case FirmwareCfgAPID_AP3: return this->_internalData->ipv4SecondaryDNS_AP3[addrPart]; - } - - return 0; -} - -void FirmwareConfigInterface::SetIPv4SecondaryDNSPart(FirmwareCfgAPID apid, uint8_t addrPart, uint8_t addrValue) -{ - if (addrPart > 3) - { - return; - } - - switch (apid) - { - case FirmwareCfgAPID_AP1: this->_internalData->ipv4SecondaryDNS_AP1[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP2: this->_internalData->ipv4SecondaryDNS_AP2[addrPart] = addrValue; break; - case FirmwareCfgAPID_AP3: this->_internalData->ipv4SecondaryDNS_AP3[addrPart] = addrValue; break; - } -} - -uint8_t FirmwareConfigInterface::GetSubnetMask(FirmwareCfgAPID apid) -{ - switch (apid) - { - case FirmwareCfgAPID_AP1: return this->_internalData->subnetMask_AP1; - case FirmwareCfgAPID_AP2: return this->_internalData->subnetMask_AP2; - case FirmwareCfgAPID_AP3: return this->_internalData->subnetMask_AP3; - } - - return 0; -} - -const char* FirmwareConfigInterface::GetSubnetMaskString(FirmwareCfgAPID apid) -{ - switch (apid) - { - case FirmwareCfgAPID_AP1: return &this->_subnetMaskString[0]; - case FirmwareCfgAPID_AP2: return &this->_subnetMaskString[16]; - case FirmwareCfgAPID_AP3: return &this->_subnetMaskString[32]; - } - - return ""; -} - -void FirmwareConfigInterface::SetSubnetMask(FirmwareCfgAPID apid, uint8_t subnetMaskShift) -{ - if (subnetMaskShift > 28) - { - subnetMaskShift = 28; - } - - int subnetMaskCharIndex = -1; - uint32_t subnetMaskValue = 0; - - switch (apid) - { - case FirmwareCfgAPID_AP1: - this->_internalData->subnetMask_AP1 = subnetMaskShift; - subnetMaskCharIndex = 0; - break; - - case FirmwareCfgAPID_AP2: - this->_internalData->subnetMask_AP2 = subnetMaskShift; - subnetMaskCharIndex = 16; - break; - - case FirmwareCfgAPID_AP3: - this->_internalData->subnetMask_AP3 = subnetMaskShift; - subnetMaskCharIndex = 32; - break; - } - - if ( (subnetMaskCharIndex >= 0) && (subnetMaskCharIndex <= 32) ) - { - subnetMaskValue = (subnetMaskShift == 0) ? 0 : (0xFFFFFFFF << (32 - subnetMaskShift)); - memset(&this->_subnetMaskString[subnetMaskCharIndex], '\0', 16 * sizeof(char)); - snprintf(&this->_subnetMaskString[subnetMaskCharIndex], 16, "%d.%d.%d.%d", (subnetMaskValue >> 24) & 0x000000FF, (subnetMaskValue >> 16) & 0x000000FF, (subnetMaskValue >> 8) & 0x000000FF, subnetMaskValue & 0x000000FF); - } -} - -int FirmwareConfigInterface::GetConsoleType() -{ - return (int)this->_internalData->consoleType; -} - -void FirmwareConfigInterface::SetConsoleType(int type) -{ - this->_internalData->consoleType = (uint8_t)type; -} - -uint16_t* FirmwareConfigInterface::GetNicknameStringBuffer() -{ - return this->_internalData->nickname; -} - -void FirmwareConfigInterface::SetNicknameWithStringBuffer(uint16_t *buffer, size_t charLength) -{ - size_t i = 0; - - if (buffer != NULL) - { - if (charLength > MAX_FW_NICKNAME_LENGTH) - { - charLength = MAX_FW_NICKNAME_LENGTH; - } - - for (; i < charLength; i++) - { - this->_internalData->nickname[i] = buffer[i]; - } - } - else - { - charLength = 0; - } - - for (; i < MAX_FW_NICKNAME_LENGTH+1; i++) - { - this->_internalData->nickname[i] = 0; - } - - this->_internalData->nicknameLength = charLength; -} - -size_t FirmwareConfigInterface::GetNicknameStringLength() -{ - return (size_t)this->_internalData->nicknameLength; -} - -void FirmwareConfigInterface::SetNicknameStringLength(size_t charLength) -{ - if (charLength > MAX_FW_NICKNAME_LENGTH) - { - charLength = MAX_FW_NICKNAME_LENGTH; - } - - this->_internalData->nicknameLength = charLength; -} - -uint16_t* FirmwareConfigInterface::GetMessageStringBuffer() -{ - return this->_internalData->message; -} - -void FirmwareConfigInterface::SetMessageWithStringBuffer(uint16_t *buffer, size_t charLength) -{ - size_t i = 0; - - if (buffer != NULL) - { - if (charLength > MAX_FW_MESSAGE_LENGTH) - { - charLength = MAX_FW_MESSAGE_LENGTH; - } - - for (; i < charLength; i++) - { - this->_internalData->message[i] = buffer[i]; - } - } - else - { - charLength = 0; - } - - for (; i < MAX_FW_MESSAGE_LENGTH+1; i++) - { - this->_internalData->message[i] = 0; - } - - this->_internalData->messageLength = charLength; -} - -size_t FirmwareConfigInterface::GetMessageStringLength() -{ - return (size_t)this->_internalData->messageLength; -} - -void FirmwareConfigInterface::SetMessageStringLength(size_t charLength) -{ - if (charLength > MAX_FW_MESSAGE_LENGTH) - { - charLength = MAX_FW_MESSAGE_LENGTH; - } - - this->_internalData->messageLength = charLength; -} - -int FirmwareConfigInterface::GetFavoriteColorByID() -{ - return (int)this->_internalData->favoriteColor; -} - -void FirmwareConfigInterface::SetFavoriteColorByID(int colorID) -{ - this->_internalData->favoriteColor = (uint8_t)colorID; -} - -int FirmwareConfigInterface::GetBirthdayDay() -{ - return (int)this->_internalData->birthdayDay; -} - -void FirmwareConfigInterface::SetBirthdayDay(int day) -{ - if (day < 1) - { - day = 1; - } - - switch (this->_internalData->birthdayMonth) - { - case 1: - case 3: - case 5: - case 7: - case 8: - case 10: - case 12: - { - if (day > 31) day = 31; - break; - } - - case 4: - case 6: - case 9: - case 11: - { - if (day > 30) day = 30; - break; - } - - case 2: - { - if (day > 29) day = 29; - break; - } - - default: - break; - } - - this->_internalData->birthdayDay = (uint8_t)day; -} - -int FirmwareConfigInterface::GetBirthdayMonth() -{ - return (int)this->_internalData->birthdayMonth; -} - -void FirmwareConfigInterface::SetBirthdayMonth(int month) -{ - if (month < 1) - { - month = 1; - } - else if (month > 12) - { - month = 12; - } - - this->_internalData->birthdayMonth = (uint8_t)month; -} - -int FirmwareConfigInterface::GetLanguageByID() -{ - return (int)this->_internalData->language; -} - -void FirmwareConfigInterface::SetLanguageByID(int languageID) -{ - this->_internalData->language = (uint8_t)languageID; -} - -int FirmwareConfigInterface::GetBacklightLevel() -{ - return (int)this->_internalData->backlightLevel; -} - -void FirmwareConfigInterface::SetBacklightLevel(int level) -{ - this->_internalData->backlightLevel = (uint8_t)level; -} diff --git a/desmume/src/frontend/cocoa/cocoa_videofilter.h b/desmume/src/frontend/cocoa/cocoa_videofilter.h deleted file mode 100644 index 3dbbba90d..000000000 --- a/desmume/src/frontend/cocoa/cocoa_videofilter.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2011 Roger Manuel - Copyright (C) 2011-2013 DeSmuME team - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the this software. If not, see . -*/ - -#import -#include "../../filter/videofilter.h" -#undef BOOL - -@class NSImage; -@class NSBitmapImageRep; - -/******************************************************************************************** - CocoaVideoFilter - OBJECTIVE-C CLASS - - This is an Objective-C wrapper class for the video filter C++ object. - - Thread Safety: - All methods are thread-safe. - ********************************************************************************************/ -@interface CocoaVideoFilter : NSObject -{ - VideoFilter *vf; - VideoFilterTypeID currentFilterType; -} - -- (id) initWithSize:(NSSize)theSize; -- (id) initWithSize:(NSSize)theSize typeID:(VideoFilterTypeID)typeID; -- (id) initWithSize:(NSSize)theSize typeID:(VideoFilterTypeID)typeID numberThreads:(NSUInteger)numThreads; -- (BOOL) setSourceSize:(NSSize)theSize; -- (BOOL) changeFilter:(VideoFilterTypeID)typeID; -- (UInt32 *) runFilter; -- (NSImage *) image; -- (NSBitmapImageRep *) bitmapImageRep; -- (VideoFilterTypeID) typeID; -- (NSString *) typeString; -- (UInt32 *) srcBufferPtr; -- (UInt32 *) dstBufferPtr; -- (NSSize) srcSize; -- (NSSize) destSize; -- (VideoFilterParamType) filterParameterType:(VideoFilterParamID)paramID; -- (int) filterParameteri:(VideoFilterParamID)paramID; -- (unsigned int) filterParameterui:(VideoFilterParamID)paramID; -- (float) filterParameterf:(VideoFilterParamID)paramID; -- (void) setFilterParameter:(VideoFilterParamID)paramID intValue:(int)value; -- (void) setFilterParameter:(VideoFilterParamID)paramID uintValue:(unsigned int)value; -- (void) setFilterParameter:(VideoFilterParamID)paramID floatValue:(float)value; -+ (NSString *) typeStringByID:(VideoFilterTypeID)typeID; - -@end diff --git a/desmume/src/frontend/cocoa/cocoa_videofilter.mm b/desmume/src/frontend/cocoa/cocoa_videofilter.mm deleted file mode 100644 index 0ba9a7293..000000000 --- a/desmume/src/frontend/cocoa/cocoa_videofilter.mm +++ /dev/null @@ -1,227 +0,0 @@ -/* - Copyright (C) 2011 Roger Manuel - Copyright (C) 2013-2024 DeSmuME team - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the this software. If not, see . -*/ - -#import "cocoa_videofilter.h" -#import -#include "../../utils/colorspacehandler/colorspacehandler.h" - -@implementation CocoaVideoFilter - -- (id)init -{ - return [self initWithSize:NSMakeSize(1, 1) typeID:VideoFilterTypeID_None numberThreads:0]; -} - -- (id) initWithSize:(NSSize)theSize -{ - return [self initWithSize:theSize typeID:VideoFilterTypeID_None numberThreads:0]; -} - -- (id) initWithSize:(NSSize)theSize typeID:(VideoFilterTypeID)typeID -{ - return [self initWithSize:theSize typeID:typeID numberThreads:0]; -} - -- (id) initWithSize:(NSSize)theSize typeID:(VideoFilterTypeID)typeID numberThreads:(NSUInteger)numThreads -{ - self = [super init]; - if (self == nil) - { - return self; - } - - vf = new VideoFilter((size_t)theSize.width, (size_t)theSize.height, typeID, numThreads); - currentFilterType = typeID; - - return self; -} - -- (void)dealloc -{ - delete vf; - [super dealloc]; -} - -- (BOOL) setSourceSize:(NSSize)theSize -{ - BOOL result = NO; - - bool cResult = vf->SetSourceSize((size_t)theSize.width, (size_t)theSize.height); - if (cResult) - { - result = YES; - } - - return result; -} - -- (BOOL) changeFilter:(VideoFilterTypeID)typeID -{ - BOOL result = NO; - - if (typeID == currentFilterType) - { - result = YES; - } - else - { - bool cResult = vf->ChangeFilterByID(typeID); - if (cResult) - { - result = YES; - currentFilterType = typeID; - } - } - - return result; -} - -- (UInt32 *) runFilter -{ - return (UInt32 *)vf->RunFilter(); -} - -- (NSImage *) image -{ - NSImage *newImage = [[NSImage alloc] initWithSize:[self destSize]]; - if (newImage == nil) - { - return newImage; - } - - NSBitmapImageRep *newImageRep = [self bitmapImageRep]; - if (newImageRep == nil) - { - [newImage release]; - newImage = nil; - return newImage; - } - - [newImage addRepresentation:newImageRep]; - - return [newImage autorelease]; -} - -- (NSBitmapImageRep *) bitmapImageRep -{ - NSUInteger w = (NSUInteger)vf->GetDstWidth(); - NSUInteger h = (NSUInteger)vf->GetDstHeight(); - - NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL - pixelsWide:w - pixelsHigh:h - bitsPerSample:8 - samplesPerPixel:4 - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bytesPerRow:w * 4 - bitsPerPixel:32]; - - if(imageRep == nil) - { - return imageRep; - } - - uint32_t *bitmapData = (uint32_t *)[imageRep bitmapData]; - ColorspaceConvertBuffer888xTo8888Opaque((const uint32_t *)[self runFilter], bitmapData, w * h); - -#ifdef MSB_FIRST - for (size_t i = 0; i < w * h; i++) - { - bitmapData[i] = LE_TO_LOCAL_32(bitmapData[i]); - } -#endif - - return [imageRep autorelease]; -} - -- (VideoFilterTypeID) typeID -{ - return vf->GetTypeID(); -} - -- (NSString *) typeString -{ - return [NSString stringWithCString:vf->GetTypeString() encoding:NSUTF8StringEncoding]; -} - -- (UInt32 *) srcBufferPtr -{ - return (UInt32 *)vf->GetSrcBufferPtr(); -} - -- (UInt32 *) dstBufferPtr -{ - return (UInt32 *)vf->GetDstBufferPtr(); -} - -- (NSSize) srcSize -{ - return NSMakeSize((CGFloat)vf->GetSrcWidth(), (CGFloat)vf->GetSrcHeight()); -} - -- (NSSize) destSize -{ - return NSMakeSize((CGFloat)vf->GetDstWidth(), (CGFloat)vf->GetDstHeight()); -} - -- (VideoFilterParamType) filterParameterType:(VideoFilterParamID)paramID -{ - return vf->GetFilterParameterType(paramID); -} - -- (int) filterParameteri:(VideoFilterParamID)paramID -{ - return vf->GetFilterParameteri(paramID); -} - -- (unsigned int) filterParameterui:(VideoFilterParamID)paramID -{ - return vf->GetFilterParameterui(paramID); -} - -- (float) filterParameterf:(VideoFilterParamID)paramID -{ - return vf->GetFilterParameterf(paramID); -} - -- (void) setFilterParameter:(VideoFilterParamID)paramID intValue:(int)value -{ - vf->SetFilterParameteri(paramID, value); -} - -- (void) setFilterParameter:(VideoFilterParamID)paramID uintValue:(unsigned int)value -{ - vf->SetFilterParameterui(paramID, value); -} - -- (void) setFilterParameter:(VideoFilterParamID)paramID floatValue:(float)value -{ - vf->SetFilterParameterf(paramID, value); -} - -+ (NSString *) typeStringByID:(VideoFilterTypeID)typeID -{ - const char *vfTypeCString = VideoFilter::GetTypeStringByID(typeID); - NSString *vfTypeString = [NSString stringWithCString:vfTypeCString encoding:NSUTF8StringEncoding]; - - return vfTypeString; -} - -@end diff --git a/desmume/src/frontend/cocoa/userinterface/cheatWindowDelegate.mm b/desmume/src/frontend/cocoa/userinterface/cheatWindowDelegate.mm index 8ce840a61..316e58ee4 100644 --- a/desmume/src/frontend/cocoa/userinterface/cheatWindowDelegate.mm +++ b/desmume/src/frontend/cocoa/userinterface/cheatWindowDelegate.mm @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Roger Manuel - Copyright (C) 2012-2023 DeSmuME team + Copyright (C) 2012-2025 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #import "cocoa_cheat.h" #import "cocoa_util.h" +#include "ClientCheatManager.h" + @implementation CheatWindowDelegate diff --git a/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm b/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm index 4060624a6..3e39a56a3 100644 --- a/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm +++ b/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm @@ -26,7 +26,6 @@ #import "cocoa_globals.h" #import "cocoa_input.h" #import "cocoa_file.h" -#import "cocoa_videofilter.h" #import "cocoa_util.h" #ifdef MAC_OS_X_VERSION_10_7