mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Improved memory buffer organization
This commit is contained in:
parent
68b81ade76
commit
8e4b04a18e
@ -46,10 +46,13 @@
|
||||
|
||||
// buffer area defines (in use by godmode.c)
|
||||
#define DIR_BUFFER (0x21000000)
|
||||
#define WORK_BUFFER ((u8*)0x21100000)
|
||||
#define DIR_BUFFER_SIZE (0x100000)
|
||||
#define WORK_BUFFER_SIZE (0x100000)
|
||||
// buffer area defines (in use by fs.c)
|
||||
// buffer area defines (temporary, in use by various functions)
|
||||
// -> godmode.c hexviewer
|
||||
// -> ncch.c seed setup
|
||||
#define TEMP_BUFFER ((u8*)0x21100000)
|
||||
#define TEMP_BUFFER_SIZE (0x100000)
|
||||
// buffer area defines (in use by fs.c and gameio.c)
|
||||
#define MAIN_BUFFER ((u8*)0x21200000)
|
||||
#define MAIN_BUFFER_SIZE (0x100000) // must be multiple of 0x200
|
||||
// buffer area defines (in use by nand.c)
|
||||
@ -58,11 +61,8 @@
|
||||
// buffer area defines (in use by sddata.c)
|
||||
#define SDCRYPT_BUFFER ((u8*)0x21400000)
|
||||
#define SDCRYPT_BUFFER_SIZE (0x100000)
|
||||
// buffer area defines (in use by cia.c)
|
||||
#define GAME_BUFFER ((u8*)0x21500000)
|
||||
#define GAME_BUFFER_SIZE (0x100000)
|
||||
// buffer area defines (in use by vgame.c)
|
||||
#define VGAME_BUFFER ((u8*)0x21600000)
|
||||
#define VGAME_BUFFER ((u8*)0x21500000)
|
||||
#define VGAME_BUFFER_SIZE (0x200000) // 2MB, big RomFS
|
||||
// buffer area defines (in use by image.c, for RAMdrive)
|
||||
#define RAMDRV_BUFFER_O3DS ((u8*)0x22200000) // in O3DS FCRAM
|
||||
|
@ -97,7 +97,7 @@ u32 GetNcchSeed(u8* seed, NcchHeader* ncch) {
|
||||
nand_drv[i], sha256sum[0], sha256sum[1], sha256sum[2], sha256sum[3]);
|
||||
|
||||
// check seedsave for seed
|
||||
u8* seedsave = (u8*) GAME_BUFFER;
|
||||
u8* seedsave = (u8*) TEMP_BUFFER;
|
||||
if (f_open(&file, path, FA_READ | FA_OPEN_EXISTING) != FR_OK)
|
||||
continue;
|
||||
f_read(&file, seedsave, 0x200, &btr);
|
||||
@ -124,11 +124,11 @@ u32 GetNcchSeed(u8* seed, NcchHeader* ncch) {
|
||||
// not found -> try seeddb.bin
|
||||
const char* base[] = { INPUT_PATHS };
|
||||
for (u32 i = 0; i < (sizeof(base)/sizeof(char*)); i++) {
|
||||
SeedInfo* seeddb = (SeedInfo*) GAME_BUFFER;
|
||||
SeedInfo* seeddb = (SeedInfo*) TEMP_BUFFER;
|
||||
snprintf(path, 128, "%s/%s", base[i], SEEDDB_NAME);
|
||||
if (f_open(&file, path, FA_READ | FA_OPEN_EXISTING) != FR_OK)
|
||||
continue;
|
||||
f_read(&file, seeddb, GAME_BUFFER_SIZE, &btr);
|
||||
f_read(&file, seeddb, TEMP_BUFFER_SIZE, &btr);
|
||||
f_close(&file);
|
||||
if (seeddb->n_entries > (btr - 16) / 32)
|
||||
continue; // filesize / seeddb size mismatch
|
||||
|
@ -244,8 +244,8 @@ u32 SdFormatMenu(void) {
|
||||
u32 HexViewer(const char* path) {
|
||||
static const u32 max_data = (SCREEN_HEIGHT / 8) * 16;
|
||||
static u32 mode = 0;
|
||||
u8* data = WORK_BUFFER;
|
||||
u8* bottom_cpy = WORK_BUFFER + 0xC0000; // a copy of the bottom screen framebuffer
|
||||
u8* data = TEMP_BUFFER;
|
||||
u8* bottom_cpy = TEMP_BUFFER + 0xC0000; // a copy of the bottom screen framebuffer
|
||||
u32 fsize = FileGetSize(path);
|
||||
|
||||
bool dual_screen;
|
||||
@ -264,8 +264,8 @@ u32 HexViewer(const char* path) {
|
||||
|
||||
static const u32 edit_bsize = 0x4000; // should be multiple of 0x200 * 2
|
||||
bool edit_mode = false;
|
||||
u8* edit_buffer = WORK_BUFFER;
|
||||
u8* edit_buffer_cpy = WORK_BUFFER + edit_bsize;
|
||||
u8* edit_buffer = TEMP_BUFFER;
|
||||
u8* edit_buffer_cpy = TEMP_BUFFER + edit_bsize;
|
||||
u32 edit_start;
|
||||
int cursor = 0;
|
||||
|
||||
@ -478,7 +478,7 @@ u32 HexViewer(const char* path) {
|
||||
if (diffs && ShowPrompt(true, "You made edits in %i place(s).\nWrite changes to file?", diffs))
|
||||
if (!FileSetData(path, edit_buffer, min(edit_bsize, (fsize - edit_start)), edit_start, false))
|
||||
ShowPrompt(false, "Failed writing to file!");
|
||||
data = WORK_BUFFER;
|
||||
data = TEMP_BUFFER;
|
||||
last_offset = (u32) -1; // force reload from file
|
||||
} else if (pad_state & BUTTON_A) {
|
||||
if (pad_state & BUTTON_DOWN) data[cursor]--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user