notaz.gp2x.de
/
picodrive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cyclone: gcc 4.4 buildfix
[picodrive.git]
/
pico
/
cart.c
diff --git
a/pico/cart.c
b/pico/cart.c
index
067b422
..
45f3866
100644
(file)
--- a/
pico/cart.c
+++ b/
pico/cart.c
@@
-21,7
+21,7
@@
void (*PicoCartMemSetup)(void);
void (*PicoCartLoadProgressCB)(int percent) = NULL;
\r
void (*PicoCDLoadProgressCB)(const char *fname, int percent) = NULL; // handled in Pico/cd/cd_file.c
\r
\r
void (*PicoCartLoadProgressCB)(int percent) = NULL;
\r
void (*PicoCDLoadProgressCB)(const char *fname, int percent) = NULL; // handled in Pico/cd/cd_file.c
\r
\r
-static void PicoCartDetect(
void
);
\r
+static void PicoCartDetect(
const char *carthw_cfg
);
\r
\r
/* cso struct */
\r
typedef struct _cso_struct
\r
\r
/* cso struct */
\r
typedef struct _cso_struct
\r
@@
-378,23
+378,21
@@
int pm_close(pm_file *fp)
return ret;
\r
}
\r
\r
return ret;
\r
}
\r
\r
-
\r
-
static void Byteswap(unsigned char *data,
int len)
\r
+// byteswap, data needs to be int aligned, src can match dst
\r
+
void Byteswap(void *dst, const void *src,
int len)
\r
{
\r
{
\r
-
int i=0
;
\r
-
\r
- i
f (len<2) return; // Too short
\r
+
const unsigned int *ps = src
;
\r
+ unsigned int *pd = dst;
\r
+ i
nt i, m;
\r
\r
\r
- do
\r
- {
\r
- unsigned short *pd=(unsigned short *)(data+i);
\r
- int value=*pd; // Get 2 bytes
\r
+ if (len < 2)
\r
+ return;
\r
\r
\r
- value=(value<<8)|(value>>8); // Byteswap it
\r
- *pd=(unsigned short)value; // Put 2b ytes
\r
- i+=2;
\r
+ m = 0x00ff00ff;
\r
+ for (i = 0; i < len / 4; i++) {
\r
+ unsigned int t = ps[i];
\r
+ pd[i] = ((t & m) << 8) | ((t & ~m) >> 8);
\r
}
\r
}
\r
- while (i+2<=len);
\r
}
\r
\r
// Interleve a 16k block and byteswap
\r
}
\r
\r
// Interleve a 16k block and byteswap
\r
@@
-524,7
+522,7
@@
int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)
elprintf(EL_STATUS, "SMD format detected.");
\r
DecodeSmd(rom,size); size-=0x200; // Decode and byteswap SMD
\r
}
\r
elprintf(EL_STATUS, "SMD format detected.");
\r
DecodeSmd(rom,size); size-=0x200; // Decode and byteswap SMD
\r
}
\r
- else Byteswap(rom,size); // Just byteswap
\r
+ else Byteswap(rom,
rom,
size); // Just byteswap
\r
}
\r
else
\r
{
\r
}
\r
else
\r
{
\r
@@
-543,7
+541,7
@@
int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)
}
\r
\r
// Insert a cartridge:
\r
}
\r
\r
// Insert a cartridge:
\r
-int PicoCartInsert(unsigned char *rom,
unsigned int romsize
)
\r
+int PicoCartInsert(unsigned char *rom,
unsigned int romsize, const char *carthw_cfg
)
\r
{
\r
// notaz: add a 68k "jump one op back" opcode to the end of ROM.
\r
// This will hang the emu, but will prevent nasty crashes.
\r
{
\r
// notaz: add a 68k "jump one op back" opcode to the end of ROM.
\r
// This will hang the emu, but will prevent nasty crashes.
\r
@@
-574,7
+572,7
@@
int PicoCartInsert(unsigned char *rom,unsigned int romsize)
carthw_chunks = NULL;
\r
\r
if (!(PicoAHW & (PAHW_MCD|PAHW_SMS)))
\r
carthw_chunks = NULL;
\r
\r
if (!(PicoAHW & (PAHW_MCD|PAHW_SMS)))
\r
- PicoCartDetect();
\r
+ PicoCartDetect(
carthw_cfg
);
\r
\r
// setup correct memory map for loaded ROM
\r
switch (PicoAHW) {
\r
\r
// setup correct memory map for loaded ROM
\r
switch (PicoAHW) {
\r
@@
-605,6
+603,9
@@
void PicoCartUnload(void)
PicoCartUnloadHook = NULL;
\r
}
\r
\r
PicoCartUnloadHook = NULL;
\r
}
\r
\r
+ if (PicoAHW & PAHW_32X)
\r
+ PicoUnload32x();
\r
+
\r
if (Pico.rom != NULL) {
\r
SekFinishIdleDet();
\r
free(Pico.rom);
\r
if (Pico.rom != NULL) {
\r
SekFinishIdleDet();
\r
free(Pico.rom);
\r
@@
-618,9
+619,9
@@
static unsigned int rom_crc32(void)
elprintf(EL_STATUS, "caclulating CRC32..");
\r
\r
// have to unbyteswap for calculation..
\r
elprintf(EL_STATUS, "caclulating CRC32..");
\r
\r
// have to unbyteswap for calculation..
\r
- Byteswap(Pico.rom, Pico.romsize);
\r
+ Byteswap(Pico.rom, Pico.rom
, Pico.rom
size);
\r
crc = crc32(0, Pico.rom, Pico.romsize);
\r
crc = crc32(0, Pico.rom, Pico.romsize);
\r
- Byteswap(Pico.rom, Pico.romsize);
\r
+ Byteswap(Pico.rom, Pico.rom
, Pico.rom
size);
\r
return crc;
\r
}
\r
\r
return crc;
\r
}
\r
\r
@@
-694,16
+695,16
@@
static int is_expr(const char *expr, char **pr)
return 1;
\r
}
\r
\r
return 1;
\r
}
\r
\r
-static void parse_carthw(int *fill_sram)
\r
+static void parse_carthw(
const char *carthw_cfg,
int *fill_sram)
\r
{
\r
int line = 0, any_checks_passed = 0, skip_sect = 0;
\r
int tmp, rom_crc = 0;
\r
char buff[256], *p, *r;
\r
FILE *f;
\r
\r
{
\r
int line = 0, any_checks_passed = 0, skip_sect = 0;
\r
int tmp, rom_crc = 0;
\r
char buff[256], *p, *r;
\r
FILE *f;
\r
\r
- f = fopen(
"carthw.cfg"
, "r");
\r
+ f = fopen(
carthw_cfg
, "r");
\r
if (f == NULL) {
\r
if (f == NULL) {
\r
- elprintf(EL_STATUS, "couldn't open carthw.
txt
!");
\r
+ elprintf(EL_STATUS, "couldn't open carthw.
cfg
!");
\r
return;
\r
}
\r
\r
return;
\r
}
\r
\r
@@
-923,7
+924,7
@@
no_checks:
/*
\r
* various cart-specific things, which can't be handled by generic code
\r
*/
\r
/*
\r
* various cart-specific things, which can't be handled by generic code
\r
*/
\r
-static void PicoCartDetect(
void
)
\r
+static void PicoCartDetect(
const char *carthw_cfg
)
\r
{
\r
int fill_sram = 0;
\r
\r
{
\r
int fill_sram = 0;
\r
\r
@@
-953,7
+954,8
@@
static void PicoCartDetect(void)
SRam.eeprom_bit_in = 0;
\r
SRam.eeprom_bit_out= 0;
\r
\r
SRam.eeprom_bit_in = 0;
\r
SRam.eeprom_bit_out= 0;
\r
\r
- parse_carthw(&fill_sram);
\r
+ if (carthw_cfg != NULL)
\r
+ parse_carthw(carthw_cfg, &fill_sram);
\r
\r
if (SRam.flags & SRF_ENABLED)
\r
{
\r
\r
if (SRam.flags & SRF_ENABLED)
\r
{
\r