From 1288d4fdcdb824f174c242c3b9406ef649267c1e Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 9 Jun 2023 01:16:10 +0100 Subject: [PATCH] Save db fixes --- assets/.gitkeep | 0 src/menu/menu_fileinfo.h | 2 -- src/menu/menu_info.c | 2 +- src/menu/menu_info.h | 2 ++ src/menu/menu_main.c | 27 +++++++++++++++++++++++++-- src/menu/rom_database.c | 21 ++++++++++----------- src/menu/rom_database.h | 5 +++++ src/menu/settings.h | 1 - 8 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 assets/.gitkeep diff --git a/assets/.gitkeep b/assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/menu/menu_fileinfo.h b/src/menu/menu_fileinfo.h index 5a811740..06b4fe0e 100644 --- a/src/menu/menu_fileinfo.h +++ b/src/menu/menu_fileinfo.h @@ -3,8 +3,6 @@ #include -//struct n64_rom_header - void menu_fileinfo(FILINFO current_fileinfo); #endif diff --git a/src/menu/menu_info.c b/src/menu/menu_info.c index fe123f6a..68d47023 100644 --- a/src/menu/menu_info.c +++ b/src/menu/menu_info.c @@ -25,7 +25,7 @@ void menu_info(void) { int16_t vertical_position = 40; graphics_draw_text(disp, horizontal_start_position, vertical_position, "Menu Version:"); - graphics_draw_text(disp, horizontal_indent,vertical_position += font_vertical_pixels, "Vx.x.x.x"); // FIXME: use global setting. + graphics_draw_text(disp, horizontal_indent,vertical_position += font_vertical_pixels, MENU_VERSION); vertical_position += (font_vertical_pixels * 2); graphics_draw_text(disp, horizontal_start_position, vertical_position, "Authors:"); graphics_draw_text(disp, horizontal_indent, vertical_position += font_vertical_pixels, "JonesAlmighty / NetworkFusion"); diff --git a/src/menu/menu_info.h b/src/menu/menu_info.h index 5c9872a6..4fb6d5d4 100644 --- a/src/menu/menu_info.h +++ b/src/menu/menu_info.h @@ -1,6 +1,8 @@ #ifndef MENU_INFO_H__ #define MENU_INFO_H__ +#define MENU_VERSION "V0.0.0.3" + void menu_info(void); #endif diff --git a/src/menu/menu_main.c b/src/menu/menu_main.c index b361afcb..c8846c9a 100644 --- a/src/menu/menu_main.c +++ b/src/menu/menu_main.c @@ -16,7 +16,7 @@ #include "../utils/str_utils.h" - +//const int max_files_on_screen = 16; static int scroll_menu_position = 1; static int items_in_dir = 1; @@ -48,10 +48,15 @@ void load_n64_rom() { printf("ROM checksum: %llu\n\n", temp_header.checksum); // FIXME: if the ROM header does not make sense, it is an invalid ROM. + wait_ms(5000); // wait used for debugging. Can be removed later. + uint8_t save_type = rom_db_match_save_type(temp_header); printf("save type: %d\n", save_type); + + wait_ms(5000); // wait used for debugging. Can be removed later. + sprintf(sd_path_buffer, "%s.%llu.sav", current_fileinfo.fname, temp_header.checksum); wait_ms(5000); // wait used for debugging. Can be removed later. @@ -202,12 +207,30 @@ void menu_main_init (settings_t *settings) { if (joypad.c[0].A) { // TODO: move this to a function and check that the ROM is valid by checking the header... - if (str_endswith(current_fileinfo.fname, ".z64") || str_endswith(current_fileinfo.fname, ".n64") || str_endswith(current_fileinfo.fname, ".v64") || str_endswith(current_fileinfo.fname, ".rom")) { + if (str_endswith(current_fileinfo.fname, ".z64")) { load_n64_rom(); break; //required! } + else if (str_endswith(current_fileinfo.fname, ".n64") || str_endswith(current_fileinfo.fname, ".v64") || str_endswith(current_fileinfo.fname, ".rom")) { + console_init(); + console_clear(); + + printf("ROM : %s\n", current_fileinfo.fname); + printf("Not loading due to potential conversion issue.\n"); + wait_ms(10000); // wait used for debugging. Can be removed later. + menu_main_refresh(current_dir); + } + else if (str_endswith(current_fileinfo.fname, ".zip")) { + console_init(); + console_clear(); + + printf("ZIP : %s\n", current_fileinfo.fname); + printf("Not loading due to potential conversion issue.\n"); + wait_ms(10000); // wait used for debugging. Can be removed later. + menu_main_refresh(current_dir); + } else { if (current_fileinfo.fattrib & AM_DIR) { // if this is a directory we need to transverse to it! diff --git a/src/menu/rom_database.c b/src/menu/rom_database.c index 760b8bb8..7cd57a5d 100644 --- a/src/menu/rom_database.c +++ b/src/menu/rom_database.c @@ -75,15 +75,15 @@ uint8_t rom_db_match_save_type(rom_header_t rom_header) { return extract_homebrew_save_type(high_nibble); } - // Second: Match the default entries for crc_high. - // FIXME: use full check code, or pad. - if (rom_header.checksum == 0xbcb1f89f)return DB_SAVE_TYPE_EEPROM_4K; // kirby v1.3 - if (rom_header.checksum == 0x46039fb4)return DB_SAVE_TYPE_EEPROM_16K; // kirby U - if (rom_header.checksum == 0x0d93ba11)return DB_SAVE_TYPE_EEPROM_16K; // kirby U - if (rom_header.checksum == 0xce84793d)return DB_SAVE_TYPE_SRAM; // donkey kong f2 - if (rom_header.checksum == 0x4cbc3b56)return DB_SAVE_TYPE_SRAM; // DMTJ 64DD game - if (rom_header.checksum == 0x0dd4abab)return DB_SAVE_TYPE_EEPROM_16K; // DK Retail kiosk demo (shares ID with Dinosaur planet, but hacks are unlikely)! - if (rom_header.checksum == 0xeb85ebc9)return DB_SAVE_TYPE_FLASHRAM; // DOUBUTSU BANCHOU (ANIMAL LEADER, Cubivore) - Contains no game ID + // // Second: Match the default entries for crc_high. + // // FIXME: use full check code, or pad. + // if (rom_header.checksum == 0xbcb1f89f)return DB_SAVE_TYPE_EEPROM_4K; // kirby v1.3 + // if (rom_header.checksum == 0x46039fb4)return DB_SAVE_TYPE_EEPROM_16K; // kirby U + // if (rom_header.checksum == 0x0d93ba11)return DB_SAVE_TYPE_EEPROM_16K; // kirby U + // if (rom_header.checksum == 0xce84793d)return DB_SAVE_TYPE_SRAM; // donkey kong f2 + // if (rom_header.checksum == 0x4cbc3b56)return DB_SAVE_TYPE_SRAM; // DMTJ 64DD game + // if (rom_header.checksum == 0x0dd4abab)return DB_SAVE_TYPE_EEPROM_16K; // DK Retail kiosk demo (shares ID with Dinosaur planet, but hacks are unlikely)! + // if (rom_header.checksum == 0xeb85ebc9)return DB_SAVE_TYPE_FLASHRAM; // DOUBUTSU BANCHOU (ANIMAL LEADER, Cubivore) - Contains no game ID // FIXME: we need to take into account the Category (first char) and the Region code (last char) before a general match of the ID. @@ -122,8 +122,7 @@ uint8_t rom_db_match_save_type(rom_header_t rom_header) { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // EEP16K 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, diff --git a/src/menu/rom_database.h b/src/menu/rom_database.h index b5ce008c..53a69cbd 100644 --- a/src/menu/rom_database.h +++ b/src/menu/rom_database.h @@ -1,3 +1,6 @@ +#ifndef ROM_DATABASE_H__ +#define ROM_DATABASE_H__ + #include // NOTE: these values are independent of flashcart / OS @@ -75,3 +78,5 @@ typedef struct { rom_header_t file_read_rom_header(char *path); uint8_t rom_db_match_save_type(rom_header_t rom_header); + +#endif diff --git a/src/menu/settings.h b/src/menu/settings.h index 1573c612..b77ea1fe 100644 --- a/src/menu/settings.h +++ b/src/menu/settings.h @@ -2,7 +2,6 @@ #define SETTINGS_H__ #include "flashcart/flashcart.h" -#include "libs/toml/toml.h" #include "boot/boot.h" #define SC64_SETTINGS_FILEPATH "sd://config.sc64.toml.txt"