-
Notifications
You must be signed in to change notification settings - Fork 11
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
6 changed files
with
94 additions
and
4 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,62 @@ | ||
#include <stdbool.h> | ||
#include <ogc/system.h> | ||
|
||
#include "flippy_sync.h" | ||
|
||
extern syssram* __SYS_LockSram(void); | ||
extern syssramex* __SYS_LockSramEx(void); | ||
extern u32 __SYS_UnlockSram(u32 write); | ||
extern u32 __SYS_UnlockSramEx(u32 write); | ||
extern u32 __SYS_SyncSram(void); | ||
|
||
#define DEVICE_ID_J 0x13 // FlippyDrive | ||
#define DEVICE_ID_K 0x14 // FlippyDrive Flash | ||
|
||
void set_sram_swiss(bool syncSram) { | ||
bool writeSram = false; | ||
syssramex *sramex = __SYS_LockSramEx(); | ||
|
||
if (sramex->__padding0 != 0) { | ||
sramex->__padding0 = DEVICE_ID_J; | ||
writeSram = true; | ||
} | ||
|
||
__SYS_UnlockSramEx(writeSram); | ||
while (syncSram && !__SYS_SyncSram()); | ||
} | ||
|
||
#define SWISS_GLOBAL_CONFIG_PATH "/swiss/settings/global.ini" | ||
|
||
void create_swiss_config() { | ||
// mkdir all | ||
dvd_custom_mkdir("/swiss"); | ||
dvd_custom_mkdir("/swiss/settings"); | ||
|
||
// check swiss global config | ||
dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU); | ||
|
||
GCN_ALIGNED(file_status_t) status; | ||
int ret = dvd_custom_status(&status); | ||
if (ret != 0) return; | ||
|
||
// file exists | ||
if(status.result == 0 && status.fd != 0) { | ||
dvd_custom_close(status.fd); | ||
return; | ||
} | ||
|
||
// create swiss global config | ||
ret = dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU | IPC_FILE_FLAG_WRITE); | ||
if (ret != 0) return; | ||
|
||
// TODO: what do we put in this file? | ||
// I have checked and it can safely generate defaults from an empty file | ||
|
||
// file created! | ||
if(status.result == 0 && status.fd != 0) { | ||
dvd_custom_close(status.fd); | ||
return; | ||
} | ||
|
||
return; | ||
} |
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,5 @@ | ||
#include <stdbool.h> | ||
#include <ogc/system.h> | ||
|
||
void set_sram_swiss(bool syncSram); | ||
void create_swiss_config(); |
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,25 @@ | ||
static const unsigned int tinf_crc32tab[16] = { | ||
0x00000000, 0x1DB71064, 0x3B6E20C8, 0x26D930AC, 0x76DC4190, | ||
0x6B6B51F4, 0x4DB26158, 0x5005713C, 0xEDB88320, 0xF00F9344, | ||
0xD6D6A3E8, 0xCB61B38C, 0x9B64C2B0, 0x86D3D2D4, 0xA00AE278, | ||
0xBDBDF21C | ||
}; | ||
|
||
unsigned int tinf_crc32(const void *data, unsigned int length) | ||
{ | ||
const unsigned char *buf = (const unsigned char *) data; | ||
unsigned int crc = 0xFFFFFFFF; | ||
unsigned int i; | ||
|
||
if (length == 0) { | ||
return 0; | ||
} | ||
|
||
for (i = 0; i < length; ++i) { | ||
crc ^= buf[i]; | ||
crc = tinf_crc32tab[crc & 0x0F] ^ (crc >> 4); | ||
crc = tinf_crc32tab[crc & 0x0F] ^ (crc >> 4); | ||
} | ||
|
||
return crc ^ 0xFFFFFFFF; | ||
} |
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 @@ | ||
unsigned int tinf_crc32(const void *data, unsigned int length); |