mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-22 02:29:19 +01:00
Update libdragon and libcart
This commit is contained in:
parent
a1d20ae36e
commit
d5485a2f12
@ -1 +1 @@
|
|||||||
Subproject commit 251c821158cfc6099baa5577680223dc9897ef57
|
Subproject commit 352679922bad5403f8ea4b9123dfe0403d030bc2
|
@ -47,45 +47,44 @@ static flashcart_t *flashcart = &((flashcart_t) {
|
|||||||
|
|
||||||
|
|
||||||
flashcart_error_t flashcart_init (void) {
|
flashcart_error_t flashcart_init (void) {
|
||||||
bool sd_initialized;
|
|
||||||
flashcart_error_t error;
|
flashcart_error_t error;
|
||||||
|
|
||||||
|
// NOTE: Explicitly support only these flashcarts in this specific initialization order.
|
||||||
|
struct {
|
||||||
|
int type;
|
||||||
|
int (* libcart_init) (void);
|
||||||
|
flashcart_t *(* get) (void);
|
||||||
|
} flashcarts[CART_MAX] = {
|
||||||
|
{ CART_CI, ci_init, NULL }, // 64drive
|
||||||
|
{ CART_SC, sc_init, sc64_get_flashcart }, // SC64
|
||||||
|
{ CART_EDX, edx_init, NULL }, // Series X EverDrive-64
|
||||||
|
{ CART_ED, ed_init, NULL }, // Original EverDrive-64
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < CART_MAX; i++) {
|
||||||
|
if (flashcarts[i].libcart_init() >= 0) {
|
||||||
|
cart_type = flashcarts[i].type;
|
||||||
|
if (flashcarts[i].get) {
|
||||||
|
flashcart = flashcarts[i].get();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cart_type == CART_NULL) {
|
||||||
|
return FLASHCART_ERROR_NOT_DETECTED;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// NOTE: Some flashcarts doesn't have USB port, can't throw error here
|
// NOTE: Some flashcarts doesn't have USB port, can't throw error here
|
||||||
debug_init_usblog();
|
debug_init_usblog();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 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 on some flashcarts at this point
|
|
||||||
// and might result in setting incorrect PI config.
|
|
||||||
extern uint32_t cart_dom1;
|
|
||||||
cart_dom1 = 0x80371240;
|
|
||||||
|
|
||||||
sd_initialized = debug_init_sdfs("sd:/", -1);
|
|
||||||
|
|
||||||
// NOTE: Flashcart model is extracted from libcart after debug_init_sdfs call is made
|
|
||||||
extern int cart_type;
|
|
||||||
|
|
||||||
switch (cart_type) {
|
|
||||||
case CART_CI: // 64drive
|
|
||||||
case CART_ED: // Original EverDrive-64
|
|
||||||
case CART_EDX: // Series X EverDrive-64
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CART_SC: // SC64
|
|
||||||
flashcart = sc64_get_flashcart();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return FLASHCART_ERROR_NOT_DETECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((error = flashcart->init()) != FLASHCART_OK) {
|
if ((error = flashcart->init()) != FLASHCART_OK) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sd_initialized) {
|
if (!debug_init_sdfs("sd:/", -1)) {
|
||||||
return FLASHCART_ERROR_SD_CARD;
|
return FLASHCART_ERROR_SD_CARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,15 +105,9 @@ flashcart_error_t flashcart_load_rom (char *rom_path, bool byte_swap, flashcart_
|
|||||||
return FLASHCART_ERROR_ARGS;
|
return FLASHCART_ERROR_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cart_card_byteswap(byte_swap)) {
|
cart_card_byteswap = byte_swap;
|
||||||
return FLASHCART_ERROR_INT;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = flashcart->load_rom(rom_path, progress);
|
error = flashcart->load_rom(rom_path, progress);
|
||||||
|
cart_card_byteswap = false;
|
||||||
if (cart_card_byteswap(false)) {
|
|
||||||
return FLASHCART_ERROR_INT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user