Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/cart.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ typedef uint32_t u32;
#endif

/* Cartridge types */
#define CART_UNDEFINED -2
#define CART_NULL -1
#define CART_CI 0 /* 64Drive */
#define CART_EDX 1 /* EverDrive-64 X-series */
Expand Down
9 changes: 7 additions & 2 deletions src/cart/cartexit.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ int cart_exit(void)
ed_exit,
sc_exit,
};
if (cart_type < 0) return -1;
return exit[cart_type]();
int result = -1;
if (cart_type >= 0)
{
result = exit[cart_type]();
}
cart_type = CART_UNDEFINED;
return result;
}
29 changes: 18 additions & 11 deletions src/cart/cartinit.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <cart.h>
#include "cartint.h"

int cart_type = CART_NULL;
int cart_type = CART_UNDEFINED;

int cart_init(void)
{
Expand All @@ -13,8 +13,17 @@ int cart_init(void)
sc_init,
};
int i, result;
/* bail if already initialized */
if (cart_type != CART_UNDEFINED)
{
return -1;
}
/* bbplayer */
if ((IO_READ(MI_VERSION_REG) & 0xF0) == 0xB0) return -1;
if ((IO_READ(MI_VERSION_REG) & 0xF0) == 0xB0)
{
cart_type = CART_NULL;
return -1;
}
if (!__cart_dom1)
{
__cart_dom1 = 0x8030FFFF;
Expand All @@ -23,17 +32,15 @@ int cart_init(void)
__cart_acs_rel();
}
if (!__cart_dom2) __cart_dom2 = __cart_dom1;
if (cart_type < 0)
/* detect */
for (i = 0; i < CART_MAX; i++)
{
for (i = 0; i < CART_MAX; i++)
if ((result = init[i]()) >= 0)
{
if ((result = init[i]()) >= 0)
{
cart_type = i;
return result;
}
cart_type = i;
return result;
}
return -1;
}
return init[cart_type]();
cart_type = CART_NULL;
return -1;
}