32x: built-in BIOS; reset handling; 68k memhandler split

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@801 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-10-03 16:21:59 +00:00
parent 5fadfb1c37
commit 83ff19ec52
7 changed files with 405 additions and 150 deletions

View file

@ -378,23 +378,21 @@ int pm_close(pm_file *fp)
return ret;
}
static void Byteswap(unsigned char *data,int len)
// byteswap, data needs to be int aligned, src can match dst
void Byteswap(void *dst, const void *src, int len)
{
int i=0;
const unsigned int *ps = src;
unsigned int *pd = dst;
int i, m;
if (len<2) return; // Too short
if (len < 2)
return;
do
{
unsigned short *pd=(unsigned short *)(data+i);
int value=*pd; // Get 2 bytes
value=(value<<8)|(value>>8); // Byteswap it
*pd=(unsigned short)value; // Put 2b ytes
i+=2;
m = 0x00ff00ff;
for (i = 0; i < len / 4; i++) {
unsigned int t = ps[i];
pd[i] = ((t & m) << 8) | ((t & ~m) >> 8);
}
while (i+2<=len);
}
// Interleve a 16k block and byteswap
@ -524,7 +522,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)
elprintf(EL_STATUS, "SMD format detected.");
DecodeSmd(rom,size); size-=0x200; // Decode and byteswap SMD
}
else Byteswap(rom,size); // Just byteswap
else Byteswap(rom, rom, size); // Just byteswap
}
else
{
@ -621,9 +619,9 @@ static unsigned int rom_crc32(void)
elprintf(EL_STATUS, "caclulating CRC32..");
// have to unbyteswap for calculation..
Byteswap(Pico.rom, Pico.romsize);
Byteswap(Pico.rom, Pico.rom, Pico.romsize);
crc = crc32(0, Pico.rom, Pico.romsize);
Byteswap(Pico.rom, Pico.romsize);
Byteswap(Pico.rom, Pico.rom, Pico.romsize);
return crc;
}