Skip to content

Commit

Permalink
ram save/load fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xrip committed Oct 9, 2023
1 parent 7328463 commit 21fbbd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 8 additions & 3 deletions inc/peanut_gb.h
Original file line number Diff line number Diff line change
Expand Up @@ -4120,16 +4120,21 @@ const char* gb_get_rom_name(struct gb_s* gb, char *title_str)
{
uint_fast16_t title_loc = 0x134;
/* End of title may be 0x13E for newer games. */
const uint_fast16_t title_end = 0x143;
//const uint_fast16_t title_end = 0x14в;
const char* title_start = title_str;

for(; title_loc <= title_end; title_loc++)
for(; title_loc <= title_loc+ 24; title_loc++)
{
const char title_char = gb->gb_rom_read(gb, title_loc);

if(title_char >= ' ' && title_char <= '_')
{
*title_str = title_char;
if(title_char == ' ') {
*title_str = '_';
} else {
*title_str = title_char;
}

title_str++;
}
else
Expand Down
8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,10 @@ const MenuItem menu_items[MENU_ITEMS_NUMBER] = {

void save() {
char pathname[255];
char filename[24];
gb_get_rom_name(&gb, filename);

sprintf(pathname, "GB\\%s.save", &rom_filename);
sprintf(pathname, "GB\\%s.save", filename);
FRESULT fr = f_mount(&fs, "", 1);
FIL fd;
fr = f_open(&fd, pathname, FA_CREATE_ALWAYS | FA_WRITE);
Expand All @@ -698,8 +700,10 @@ void save() {

void load() {
char pathname[255];
char filename[24];
gb_get_rom_name(&gb, filename);

sprintf(pathname, "GB\\%s.save", &rom_filename);
sprintf(pathname, "GB\\%s.save", filename);
FRESULT fr = f_mount(&fs, "", 1);
FIL fd;
fr = f_open(&fd, pathname, FA_READ);
Expand Down

0 comments on commit 21fbbd0

Please sign in to comment.