Firmware: Fix various endianness issues. Most importantly, this fixes a bug with touch input not working correctly on big-endian systems. (Regression from commit bb38022.)
This commit is contained in:
parent
471f53e506
commit
8c2379f6f8
|
@ -254,7 +254,7 @@ bool CFIRMWARE::load(const char *firmwareFilePath)
|
|||
{
|
||||
return this->_isLoaded;
|
||||
}
|
||||
|
||||
|
||||
this->_fwFilePath = firmwareFilePath;
|
||||
this->_header = newFirmwareData->header;
|
||||
|
||||
|
@ -272,7 +272,7 @@ bool CFIRMWARE::load(const char *firmwareFilePath)
|
|||
}
|
||||
|
||||
memcpy(&MMU.fw.data, newFirmwareData, fileSize);
|
||||
delete newFirmwareData;
|
||||
delete newFirmwareData;
|
||||
|
||||
this->_isLoaded = true;
|
||||
return this->_isLoaded;
|
||||
|
@ -292,7 +292,7 @@ bool CFIRMWARE::unpack()
|
|||
return false;
|
||||
}
|
||||
|
||||
NDSFirmwareData *workingFirmwareData = new NDSFirmwareData;
|
||||
NDSFirmwareData *workingFirmwareData = new NDSFirmwareData;
|
||||
memcpy(workingFirmwareData, &MMU.fw.data, sizeof(NDSFirmwareData));
|
||||
|
||||
shift1 = ((this->_header.shift >> 0) & 0x07);
|
||||
|
@ -456,18 +456,18 @@ bool CFIRMWARE::unpack()
|
|||
INFO(" * ARM7 unpacked size: 0x%08X (%i) bytes\n", arm7Size, arm7Size);
|
||||
}
|
||||
|
||||
memcpy(&MMU.fw.data, workingFirmwareData, size);
|
||||
delete workingFirmwareData;
|
||||
memcpy(&MMU.fw.data, workingFirmwareData, size);
|
||||
delete workingFirmwareData;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFIRMWARE::loadSettings(const char *firmwareUserSettingsFilePath)
|
||||
{
|
||||
if ( (firmwareUserSettingsFilePath == NULL) || (strlen(firmwareUserSettingsFilePath) == 0) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
{
|
||||
if ( (firmwareUserSettingsFilePath == NULL) || (strlen(firmwareUserSettingsFilePath) == 0) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE *fp = fopen(firmwareUserSettingsFilePath, "rb");
|
||||
if (fp)
|
||||
|
@ -507,16 +507,16 @@ bool CFIRMWARE::loadSettings(const char *firmwareUserSettingsFilePath)
|
|||
}
|
||||
|
||||
bool CFIRMWARE::saveSettings(const char *firmwareUserSettingsFilePath)
|
||||
{
|
||||
if ( (firmwareUserSettingsFilePath == NULL) || (strlen(firmwareUserSettingsFilePath) == 0) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
{
|
||||
if ( (firmwareUserSettingsFilePath == NULL) || (strlen(firmwareUserSettingsFilePath) == 0) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FWUserSettings &userSettings0 = MMU.fw.data.userSettings0;
|
||||
FWUserSettings &userSettings1 = MMU.fw.data.userSettings1;
|
||||
|
||||
if (userSettings1.updateCounter == ((userSettings0.updateCounter + 1) & 0x7F))
|
||||
if (userSettings1.updateCounter == ((LE_TO_LOCAL_16(userSettings0.updateCounter) + 1) & 0x7F))
|
||||
{
|
||||
userSettings0 = userSettings1;
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ void NDS_InitFirmwareWithConfig(const FirmwareConfig &inConfig)
|
|||
fw.header.identifier[3] = 'P';
|
||||
|
||||
// User Settings offset 0x3fe00 / 8
|
||||
fw.header.userSettingsOffset = offsetof(NDSFirmwareData, userSettings0) / 8;
|
||||
fw.header.userSettingsOffset = LOCAL_TO_LE_16( (u16)(offsetof(NDSFirmwareData, userSettings0) / 8) );
|
||||
|
||||
// NDS type
|
||||
if (inConfig.consoleType == NDS_CONSOLE_TYPE_DSI)
|
||||
|
@ -833,26 +833,26 @@ void NDS_InitFirmwareWithConfig(const FirmwareConfig &inConfig)
|
|||
fw.userSettings0.birthdayDay = inConfig.birthdayDay;
|
||||
|
||||
// Copy the default char buffers into the UTF-16 string buffers.
|
||||
fw.userSettings0.nicknameLength = inConfig.nicknameLength;
|
||||
fw.userSettings0.messageLength = inConfig.nicknameLength;
|
||||
fw.userSettings0.nicknameLength = LOCAL_TO_LE_16((u16)inConfig.nicknameLength);
|
||||
fw.userSettings0.messageLength = LOCAL_TO_LE_16((u16)inConfig.messageLength);
|
||||
|
||||
for (size_t i = 0; i < fw.userSettings0.nicknameLength; i++)
|
||||
for (size_t i = 0; i < inConfig.nicknameLength; i++)
|
||||
{
|
||||
fw.userSettings0.nickname[i] = inConfig.nickname[i];
|
||||
fw.userSettings0.nickname[i] = LOCAL_TO_LE_16(inConfig.nickname[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < fw.userSettings0.messageLength; i++)
|
||||
for (size_t i = 0; i < inConfig.messageLength; i++)
|
||||
{
|
||||
fw.userSettings0.message[i] = inConfig.message[i];
|
||||
fw.userSettings0.message[i] = LOCAL_TO_LE_16(inConfig.message[i]);
|
||||
}
|
||||
|
||||
// Default touch-screen calibration settings.
|
||||
fw.userSettings0.tscADC_x1 = inConfig.tscADC_x1;
|
||||
fw.userSettings0.tscADC_y1 = inConfig.tscADC_y1;
|
||||
fw.userSettings0.tscADC_x1 = LOCAL_TO_LE_16(inConfig.tscADC_x1);
|
||||
fw.userSettings0.tscADC_y1 = LOCAL_TO_LE_16(inConfig.tscADC_y1);
|
||||
fw.userSettings0.tscPixel_x1 = inConfig.tscPixel_x1;
|
||||
fw.userSettings0.tscPixel_y1 = inConfig.tscPixel_y1;
|
||||
fw.userSettings0.tscADC_x2 = inConfig.tscADC_x2;
|
||||
fw.userSettings0.tscADC_y2 = inConfig.tscADC_y2;
|
||||
fw.userSettings0.tscADC_x2 = LOCAL_TO_LE_16(inConfig.tscADC_x2);
|
||||
fw.userSettings0.tscADC_y2 = LOCAL_TO_LE_16(inConfig.tscADC_y2);
|
||||
fw.userSettings0.tscPixel_x2 = inConfig.tscPixel_x2;
|
||||
fw.userSettings0.tscPixel_y2 = inConfig.tscPixel_y2;
|
||||
|
||||
|
@ -870,10 +870,10 @@ void NDS_InitFirmwareWithConfig(const FirmwareConfig &inConfig)
|
|||
// Copy the default config for userSettings0 into userSettings1.
|
||||
fw.userSettings1 = fw.userSettings0;
|
||||
|
||||
fw.userSettings0.updateCounter = 0;
|
||||
fw.userSettings1.updateCounter = 1;
|
||||
fw.userSettings0.crc16 = (u16)calc_CRC16(0xFFFF, &fw.userSettings0, 0x70);
|
||||
fw.userSettings1.crc16 = (u16)calc_CRC16(0xFFFF, &fw.userSettings1, 0x70);
|
||||
fw.userSettings0.updateCounter = 0x0000;
|
||||
fw.userSettings1.updateCounter = 0x0001;
|
||||
fw.userSettings0.crc16 = LOCAL_TO_LE_16( (u16)calc_CRC16(0xFFFF, &fw.userSettings0, 0x70) );
|
||||
fw.userSettings1.crc16 = LOCAL_TO_LE_16( (u16)calc_CRC16(0xFFFF, &fw.userSettings1, 0x70) );
|
||||
|
||||
// Begin setting up the WiFi info.
|
||||
fw.wifiInfo.length = 0x0138;
|
||||
|
@ -929,7 +929,7 @@ void NDS_InitFirmwareWithConfig(const FirmwareConfig &inConfig)
|
|||
fw.wifiInfo.MACAddr[5] = inConfig.MACAddress[5];
|
||||
|
||||
// Wifi settings CRC16
|
||||
fw.wifiInfo.crc16 = calc_CRC16(0, &fw.wifiInfo.length, fw.wifiInfo.length);
|
||||
fw.wifiInfo.crc16 = LOCAL_TO_LE_16( (u16)calc_CRC16(0, &fw.wifiInfo.length, fw.wifiInfo.length) );
|
||||
|
||||
// WFC User ID, uniquely located on the first WiFi profile and no other
|
||||
fw.wifiAP1.wfcUserID[0] = inConfig.WFCUserID[0];
|
||||
|
@ -1042,9 +1042,9 @@ void NDS_InitFirmwareWithConfig(const FirmwareConfig &inConfig)
|
|||
fw.wifiAP3.configureMode = 0xFF;
|
||||
}
|
||||
|
||||
fw.wifiAP1.crc16 = (u16)calc_CRC16(0, &fw.wifiAP1, 254);
|
||||
fw.wifiAP2.crc16 = (u16)calc_CRC16(0, &fw.wifiAP2, 254);
|
||||
fw.wifiAP3.crc16 = (u16)calc_CRC16(0, &fw.wifiAP3, 254);
|
||||
fw.wifiAP1.crc16 = LOCAL_TO_LE_16( (u16)calc_CRC16(0, &fw.wifiAP1, 254) );
|
||||
fw.wifiAP2.crc16 = LOCAL_TO_LE_16( (u16)calc_CRC16(0, &fw.wifiAP2, 254) );
|
||||
fw.wifiAP3.crc16 = LOCAL_TO_LE_16( (u16)calc_CRC16(0, &fw.wifiAP3, 254) );
|
||||
|
||||
if (&inConfig != &CommonSettings.fwConfig)
|
||||
{
|
||||
|
|
|
@ -102,6 +102,7 @@ typedef union __PACKED
|
|||
|
||||
struct
|
||||
{
|
||||
#ifndef MSB_FIRST
|
||||
u16 language:3;
|
||||
u16 gbaModeScreenSelection:1;
|
||||
u16 backlightLevel:2;
|
||||
|
@ -116,6 +117,22 @@ typedef union __PACKED
|
|||
u16 settingsOkay3:1;
|
||||
u16 settingsOkay4:1;
|
||||
u16 settingsOkay5:1;
|
||||
#else
|
||||
u16 :1;
|
||||
u16 bootmenuDisable:1;
|
||||
u16 backlightLevel:2;
|
||||
u16 gbaModeScreenSelection:1;
|
||||
u16 language:3;
|
||||
|
||||
u16 settingsOkay5:1;
|
||||
u16 settingsOkay4:1;
|
||||
u16 settingsOkay3:1;
|
||||
u16 settingsOkay2:1;
|
||||
u16 :1;
|
||||
u16 settingsOkay1:1;
|
||||
u16 settingsLost:1;
|
||||
u16 :1;
|
||||
#endif
|
||||
};
|
||||
} FW_USERSETTINGS_LANGUAGE_FLAGS;
|
||||
|
||||
|
@ -420,8 +437,8 @@ public:
|
|||
bool saveSettings(const char *firmwareUserSettingsFilePath);
|
||||
|
||||
bool loaded();
|
||||
void* getTouchCalibrate();
|
||||
|
||||
void* getTouchCalibrate();
|
||||
|
||||
static std::string GetUserSettingsFilePath(const char *firmwareFilePath);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue