mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-25 12:06:54 +01:00
SC64 libcart PI setting fix
This commit is contained in:
parent
da49393d6f
commit
02010f1cbb
@ -38,18 +38,12 @@ static flashcart_t *flashcart = &((flashcart_t) {
|
|||||||
|
|
||||||
|
|
||||||
flashcart_error_t flashcart_init (void) {
|
flashcart_error_t flashcart_init (void) {
|
||||||
|
flashcart_error_t error;
|
||||||
|
|
||||||
if (usb_initialize() == CART_NONE) {
|
if (usb_initialize() == CART_NONE) {
|
||||||
return FLASHCART_ERROR_NOT_DETECTED;
|
return FLASHCART_ERROR_NOT_DETECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
assertf(debug_init_usblog(), "Couldn't initialize USB debugging");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!debug_init_sdfs("sd:/", -1)) {
|
|
||||||
return FLASHCART_ERROR_SD_CARD_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (usb_getcart()) {
|
switch (usb_getcart()) {
|
||||||
case CART_64DRIVE:
|
case CART_64DRIVE:
|
||||||
case CART_EVERDRIVE:
|
case CART_EVERDRIVE:
|
||||||
@ -63,7 +57,19 @@ flashcart_error_t flashcart_init (void) {
|
|||||||
return FLASHCART_ERROR_UNSUPPORTED;
|
return FLASHCART_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flashcart->init();
|
if ((error = flashcart->init()) != FLASHCART_OK) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!debug_init_sdfs("sd:/", -1)) {
|
||||||
|
return FLASHCART_ERROR_SD_CARD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
assertf(debug_init_usblog(), "Couldn't initialize USB debugging");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return FLASHCART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
flashcart_error_t flashcart_deinit (void) {
|
flashcart_error_t flashcart_deinit (void) {
|
||||||
@ -80,7 +86,7 @@ flashcart_error_t flashcart_load_rom (char *rom_path, bool byte_swap) {
|
|||||||
return flashcart->load_rom(rom_path, byte_swap);
|
return flashcart->load_rom(rom_path, byte_swap);
|
||||||
}
|
}
|
||||||
|
|
||||||
flashcart_error_t flashcart_load_save (char *save_path, flashcart_save_type_t save_type, bool save_writeback) {
|
flashcart_error_t flashcart_load_save (char *save_path, flashcart_save_type_t save_type) {
|
||||||
flashcart_error_t error;
|
flashcart_error_t error;
|
||||||
uint32_t sectors[WRITEBACK_MAX_SECTORS] __attribute__((aligned(8)));
|
uint32_t sectors[WRITEBACK_MAX_SECTORS] __attribute__((aligned(8)));
|
||||||
|
|
||||||
@ -110,7 +116,7 @@ flashcart_error_t flashcart_load_save (char *save_path, flashcart_save_type_t sa
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save_writeback) {
|
if (flashcart->set_save_writeback) {
|
||||||
if (file_get_sectors(save_path, sectors, WRITEBACK_MAX_SECTORS)) {
|
if (file_get_sectors(save_path, sectors, WRITEBACK_MAX_SECTORS)) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERROR_LOAD;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ typedef struct {
|
|||||||
flashcart_error_t flashcart_init (void);
|
flashcart_error_t flashcart_init (void);
|
||||||
flashcart_error_t flashcart_deinit (void);
|
flashcart_error_t flashcart_deinit (void);
|
||||||
flashcart_error_t flashcart_load_rom (char *rom_path, bool byte_swap);
|
flashcart_error_t flashcart_load_rom (char *rom_path, bool byte_swap);
|
||||||
flashcart_error_t flashcart_load_save (char *save_path, flashcart_save_type_t save_type, bool save_writeback);
|
flashcart_error_t flashcart_load_save (char *save_path, flashcart_save_type_t save_type);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,6 +61,12 @@ static flashcart_error_t sc64_init (void) {
|
|||||||
uint16_t major;
|
uint16_t major;
|
||||||
uint16_t minor;
|
uint16_t minor;
|
||||||
|
|
||||||
|
// HACK: Because libcart reads PI config from address 0x10000000 when initializing
|
||||||
|
// we need to write safe value before running any libcart function.
|
||||||
|
// Data in SDRAM can be undefined at this point and result in setting incorrect PI config.
|
||||||
|
extern uint32_t cart_dom1;
|
||||||
|
cart_dom1 = 0x80371240;
|
||||||
|
|
||||||
sc64_unlock();
|
sc64_unlock();
|
||||||
|
|
||||||
if (!sc64_check_presence()) {
|
if (!sc64_check_presence()) {
|
||||||
@ -87,6 +93,7 @@ static flashcart_error_t sc64_init (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static flashcart_error_t sc64_deinit (void) {
|
static flashcart_error_t sc64_deinit (void) {
|
||||||
|
sc64_set_config(CFG_ROM_WRITE_ENABLE, false);
|
||||||
sc64_lock();
|
sc64_lock();
|
||||||
return FLASHCART_OK;
|
return FLASHCART_OK;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
|
|
||||||
|
#include "../menu_res_setup.h"
|
||||||
#include "views.h"
|
#include "views.h"
|
||||||
|
|
||||||
#include "../menu_res_setup.h"
|
|
||||||
|
|
||||||
#ifndef MENU_VERSION
|
#ifndef MENU_VERSION
|
||||||
#define MENU_VERSION "0.0.0.4"
|
#define MENU_VERSION "0.0.0.4"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
|
|
||||||
#include "views.h"
|
|
||||||
#include "../menu_res_setup.h"
|
#include "../menu_res_setup.h"
|
||||||
|
#include "views.h"
|
||||||
|
|
||||||
|
|
||||||
static void process (menu_t *menu) {
|
static void process (menu_t *menu) {
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
|
|
||||||
#include "views.h"
|
|
||||||
|
|
||||||
#include "../menu_res_setup.h"
|
#include "../menu_res_setup.h"
|
||||||
#include "../../utils/str_utils.h"
|
|
||||||
#include "../rom_database.h"
|
#include "../rom_database.h"
|
||||||
|
|
||||||
#include "fragments/fragments.h"
|
#include "fragments/fragments.h"
|
||||||
|
#include "utils/str_utils.h"
|
||||||
|
#include "views.h"
|
||||||
|
|
||||||
|
|
||||||
static FILINFO info;
|
static FILINFO info;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
|
|
||||||
|
#include "../rom_database.h"
|
||||||
#include "flashcart/flashcart.h"
|
#include "flashcart/flashcart.h"
|
||||||
|
|
||||||
#include "fragments/fragments.h"
|
#include "fragments/fragments.h"
|
||||||
#include "views.h"
|
#include "views.h"
|
||||||
#include "../rom_database.h"
|
|
||||||
|
|
||||||
|
|
||||||
static bool load_pending;
|
static bool load_pending;
|
||||||
@ -101,7 +100,7 @@ static void load (menu_t *menu) {
|
|||||||
uint8_t save_type = rom_db_match_save_type(rom_header);
|
uint8_t save_type = rom_db_match_save_type(rom_header);
|
||||||
|
|
||||||
path_ext_replace(path, "sav");
|
path_ext_replace(path, "sav");
|
||||||
menu->flashcart_error = flashcart_load_save(path_get(path), convert_save_type(save_type), true);
|
menu->flashcart_error = flashcart_load_save(path_get(path), convert_save_type(save_type));
|
||||||
if (menu->flashcart_error != FLASHCART_OK) {
|
if (menu->flashcart_error != FLASHCART_OK) {
|
||||||
menu->next_mode = MENU_MODE_FAULT;
|
menu->next_mode = MENU_MODE_FAULT;
|
||||||
path_free(path);
|
path_free(path);
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
|
|
||||||
|
#include "../mp3player.h"
|
||||||
#include "fragments/fragments.h"
|
#include "fragments/fragments.h"
|
||||||
#include "views.h"
|
#include "views.h"
|
||||||
|
|
||||||
#include "../mp3player.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define SEEK_SECONDS 10
|
#define SEEK_SECONDS 10
|
||||||
#define SEEK_UNMUTE_TIMEOUT 17
|
#define SEEK_UNMUTE_TIMEOUT 17
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
|
|
||||||
#include "views.h"
|
|
||||||
#include "../menu_res_setup.h"
|
#include "../menu_res_setup.h"
|
||||||
|
#include "views.h"
|
||||||
|
|
||||||
|
|
||||||
char *accessory_type_s( int accessory )
|
char *accessory_type_s( int accessory )
|
||||||
|
Loading…
Reference in New Issue
Block a user