-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
141 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2024, Extrems <[email protected]> | ||
* | ||
* This file is part of Swiss. | ||
* | ||
* Swiss 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. | ||
* | ||
* Swiss 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 | ||
* with Swiss. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <ogc/system.h> | ||
#include <stdbool.h> | ||
#include "deviceHandler.h" | ||
#include "sram.h" | ||
#include "swiss.h" | ||
|
||
static s32 onreset(s32 final) | ||
{ | ||
if (!final) updateSRAM(&swissSettings, false); | ||
return TRUE; | ||
} | ||
|
||
static sys_resetinfo resetinfo = { | ||
{NULL, NULL}, onreset, 0 | ||
}; | ||
|
||
__attribute((constructor)) | ||
static void initSRAM(void) | ||
{ | ||
bool writeSram = false; | ||
syssram *sram = __SYS_LockSram(); | ||
|
||
if (!__SYS_CheckSram()) { | ||
memset(sram, 0, sizeof(syssram)); | ||
sram->flags |= 0x10; | ||
sram->flags |= 0x04; | ||
writeSram = true; | ||
} | ||
|
||
__SYS_UnlockSram(writeSram); | ||
while (!__SYS_SyncSram()); | ||
|
||
SYS_RegisterResetFunc(&resetinfo); | ||
} | ||
|
||
void refreshSRAM(SwissSettings *settings) | ||
{ | ||
settings->sramHOffset = SYS_GetDisplayOffsetH(); | ||
settings->sram60Hz = SYS_GetEuRGB60(); | ||
settings->sramLanguage = SYS_GetLanguage(); | ||
settings->sramProgressive = SYS_GetProgressiveScan(); | ||
settings->sramStereo = SYS_GetSoundMode(); | ||
settings->sramVideo = SYS_GetVideoMode(); | ||
|
||
syssramex *sramex = __SYS_LockSramEx(); | ||
|
||
settings->configDeviceId = sramex->__padding0; | ||
if (settings->configDeviceId > DEVICE_ID_MAX || !(getDeviceByUniqueId(settings->configDeviceId)->features & FEAT_CONFIG_DEVICE)) | ||
settings->configDeviceId = DEVICE_ID_UNK; | ||
|
||
__SYS_UnlockSramEx(FALSE); | ||
} | ||
|
||
void updateSRAM(SwissSettings *settings, bool syncSram) | ||
{ | ||
SYS_SetDisplayOffsetH(settings->sramHOffset); | ||
SYS_SetEuRGB60(settings->sram60Hz); | ||
SYS_SetLanguage(settings->sramLanguage); | ||
SYS_SetProgressiveScan(settings->sramProgressive); | ||
SYS_SetSoundMode(settings->sramStereo); | ||
SYS_SetVideoMode(settings->sramVideo); | ||
|
||
bool writeSram = false; | ||
syssramex *sramex = __SYS_LockSramEx(); | ||
|
||
if (sramex->__padding0 != settings->configDeviceId) { | ||
sramex->__padding0 = settings->configDeviceId; | ||
writeSram = true; | ||
} | ||
|
||
__SYS_UnlockSramEx(writeSram); | ||
while (syncSram && !__SYS_SyncSram()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2024, Extrems <[email protected]> | ||
* | ||
* This file is part of Swiss. | ||
* | ||
* Swiss 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. | ||
* | ||
* Swiss 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 | ||
* with Swiss. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __SRAM_H__ | ||
#define __SRAM_H__ | ||
|
||
#include <stdbool.h> | ||
#include "swiss.h" | ||
|
||
void refreshSRAM(SwissSettings *settings); | ||
void updateSRAM(SwissSettings *settings, bool syncSram); | ||
|
||
#endif /* __SRAM_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters