mirror of
https://github.com/dborth/fceugx.git
synced 2024-11-01 06:55:05 +01:00
reformat gc code
This commit is contained in:
parent
345fa23539
commit
f0b068bfff
@ -20,50 +20,50 @@ static int isPlaying; /*** Is Playing ***/
|
|||||||
static void AudioSwitchBuffers()
|
static void AudioSwitchBuffers()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( buffSize[whichab] ) {
|
if ( buffSize[whichab] ) {
|
||||||
AUDIO_StopDMA();
|
AUDIO_StopDMA();
|
||||||
AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]);
|
AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]);
|
||||||
DCFlushRange(&audiobuffer[whichab], buffSize[whichab]);
|
DCFlushRange(&audiobuffer[whichab], buffSize[whichab]);
|
||||||
AUDIO_StartDMA();
|
AUDIO_StartDMA();
|
||||||
isPlaying = 0;
|
isPlaying = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
whichab ^= 1;
|
whichab ^= 1;
|
||||||
buffSize[whichab] = 0;
|
buffSize[whichab] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitialiseSound()
|
void InitialiseSound()
|
||||||
{
|
{
|
||||||
|
|
||||||
AUDIO_Init(NULL); /*** Start audio subsystem ***/
|
AUDIO_Init(NULL); /*** Start audio subsystem ***/
|
||||||
|
|
||||||
/*** Set default samplerate to 48khz ***/
|
/*** Set default samplerate to 48khz ***/
|
||||||
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
||||||
|
|
||||||
/*** and the DMA Callback ***/
|
/*** and the DMA Callback ***/
|
||||||
AUDIO_RegisterDMACallback( AudioSwitchBuffers );
|
AUDIO_RegisterDMACallback( AudioSwitchBuffers );
|
||||||
|
|
||||||
buffSize[0] = buffSize[1] = 0;
|
buffSize[0] = buffSize[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartAudio()
|
void StartAudio()
|
||||||
{
|
{
|
||||||
AUDIO_StartDMA();
|
AUDIO_StartDMA();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopAudio()
|
void StopAudio()
|
||||||
{
|
{
|
||||||
AUDIO_StopDMA();
|
AUDIO_StopDMA();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned short FLIP16(unsigned short b)
|
static inline unsigned short FLIP16(unsigned short b)
|
||||||
{
|
{
|
||||||
return((b<<8)|((b>>8)&0xFF));
|
return((b<<8)|((b>>8)&0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 FLIP32(u32 b)
|
static inline u32 FLIP32(u32 b)
|
||||||
{
|
{
|
||||||
return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) );
|
return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -78,37 +78,37 @@ static short MBuffer[ 8 * 96000 / 50 ];
|
|||||||
void PlaySound( unsigned int *Buffer, int count )
|
void PlaySound( unsigned int *Buffer, int count )
|
||||||
{
|
{
|
||||||
|
|
||||||
int P;
|
int P;
|
||||||
unsigned short *s = (unsigned short *)&MBuffer[0];
|
unsigned short *s = (unsigned short *)&MBuffer[0];
|
||||||
unsigned int *d = (unsigned int *)&audiobuffer[whichab][buffSize[whichab]];
|
unsigned int *d = (unsigned int *)&audiobuffer[whichab][buffSize[whichab]];
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
int ms;
|
int ms;
|
||||||
|
|
||||||
isWriting = 1;
|
isWriting = 1;
|
||||||
|
|
||||||
for ( P = 0; P < count; P++ ) {
|
for ( P = 0; P < count; P++ ) {
|
||||||
MBuffer[P] = Buffer[P];
|
MBuffer[P] = Buffer[P];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Now do Mono - Stereo Conversion ***/
|
/*** Now do Mono - Stereo Conversion ***/
|
||||||
ms = count;
|
ms = count;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
c = 0xffff & *s++;
|
c = 0xffff & *s++;
|
||||||
*d++ = (c | (c<<16));
|
*d++ = (c | (c<<16));
|
||||||
} while(--ms);
|
} while(--ms);
|
||||||
|
|
||||||
buffSize[whichab] += ( count << 2 );
|
buffSize[whichab] += ( count << 2 );
|
||||||
/*** This is the kicker for the entire audio loop ***/
|
/*** This is the kicker for the entire audio loop ***/
|
||||||
if ( isPlaying == 0 )
|
if ( isPlaying == 0 )
|
||||||
{
|
{
|
||||||
if ( buffSize[whichab] > AUDIOBUFFER )
|
if ( buffSize[whichab] > AUDIOBUFFER )
|
||||||
{
|
{
|
||||||
isPlaying = 1;
|
isPlaying = 1;
|
||||||
AudioSwitchBuffers();
|
AudioSwitchBuffers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isWriting = 0;
|
isWriting = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,154 +12,154 @@
|
|||||||
volatile long *dvdio=(volatile long *)0xCC006000;
|
volatile long *dvdio=(volatile long *)0xCC006000;
|
||||||
|
|
||||||
unsigned int Drive04[] = {
|
unsigned int Drive04[] = {
|
||||||
0x40D000,
|
0x40D000,
|
||||||
12,0xf4e1a538,0xcfdc0080,0xf4712aea,
|
12,0xf4e1a538,0xcfdc0080,0xf4712aea,
|
||||||
12,0x08806ef4,0xe1135fcf,0xdc6e80a0,
|
12,0x08806ef4,0xe1135fcf,0xdc6e80a0,
|
||||||
12,0xf9b801f4,0xe1295fcf,0xf47447d0,
|
12,0xf9b801f4,0xe1295fcf,0xf47447d0,
|
||||||
12,0x40f7204c,0x80f474d6,0x9c08f720,
|
12,0x40f7204c,0x80f474d6,0x9c08f720,
|
||||||
12,0xd6fcf474,0x28ae08f7,0x20d2fc80,
|
12,0xd6fcf474,0x28ae08f7,0x20d2fc80,
|
||||||
12,0x04c4dafc,0xf4747ed4,0x08f000c8,
|
12,0x04c4dafc,0xf4747ed4,0x08f000c8,
|
||||||
12,0xdafcf500,0x01e803fc,0xe200a0f4,
|
12,0xdafcf500,0x01e803fc,0xe200a0f4,
|
||||||
12,0x7400ec40,0xf51002f5,0x1003f510,
|
12,0x7400ec40,0xf51002f5,0x1003f510,
|
||||||
12,0x04f51005,0xf51006f5,0x1007f510,
|
12,0x04f51005,0xf51006f5,0x1007f510,
|
||||||
12,0x08f51009,0xf5100af5,0x100bf510,
|
12,0x08f51009,0xf5100af5,0x100bf510,
|
||||||
12,0x0cf5100d,0xc8dafcf5,0x0002e803,
|
12,0x0cf5100d,0xc8dafcf5,0x0002e803,
|
||||||
12,0xfc3d01f4,0x74f9ec40,0x8002f020,
|
12,0xfc3d01f4,0x74f9ec40,0x8002f020,
|
||||||
12,0xc88480c0,0x9c81dcb4,0x80f53000,
|
12,0xc88480c0,0x9c81dcb4,0x80f53000,
|
||||||
12,0xf444f9d1,0x40f8aa00,0x10f4d0f4,
|
12,0xf444f9d1,0x40f8aa00,0x10f4d0f4,
|
||||||
12,0xd140f001,0xdcb480f5,0x3000f748,
|
12,0xd140f001,0xdcb480f5,0x3000f748,
|
||||||
12,0xaa00e907,0xf4c4f9d1,0x4010fed8,
|
12,0xaa00e907,0xf4c4f9d1,0x4010fed8,
|
||||||
12,0x32e81df7,0x48a800e8,0x26f748ab,
|
12,0x32e81df7,0x48a800e8,0x26f748ab,
|
||||||
12,0x00e820f7,0x48e100e8,0x1af748ee,
|
12,0x00e820f7,0x48e100e8,0x1af748ee,
|
||||||
12,0x00e83bd8,0x55e82ffe,0x7104fd20,
|
12,0x00e83bd8,0x55e82ffe,0x7104fd20,
|
||||||
12,0x00f45100,0xd240a0f5,0x1000fef2,
|
12,0x00f45100,0xd240a0f5,0x1000fef2,
|
||||||
12,0xf9f4d200,0xd2407104,0xfd0a00f2,
|
12,0xf9f4d200,0xd2407104,0xfd0a00f2,
|
||||||
12,0x49fd0500,0x5104f236,0xfef721bc,
|
12,0x49fd0500,0x5104f236,0xfef721bc,
|
||||||
12,0xfff731bc,0xfffeccb5,0x80fd5300,
|
12,0xfff731bc,0xfffeccb5,0x80fd5300,
|
||||||
12,0xea0cccb5,0x80c4b081,0xccb680c4,
|
12,0xea0cccb5,0x80c4b081,0xccb680c4,
|
||||||
12,0x9481dcb4,0x80f8e000,0x10a0f510,
|
12,0x9481dcb4,0x80f8e000,0x10a0f510,
|
||||||
12,0x01f51002,0xf51003fe,0xccdafcf7,
|
12,0x01f51002,0xf51003fe,0xccdafcf7,
|
||||||
12,0x00feffc4,0xdafccc44,0xfcf700fe,
|
12,0x00feffc4,0xdafccc44,0xfcf700fe,
|
||||||
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
||||||
12,0x01e9027c,0x04f47585,0xd1405120,
|
12,0x01e9027c,0x04f47585,0xd1405120,
|
||||||
12,0x7134f47d,0xc18508e9,0x1b8000cd,
|
12,0x7134f47d,0xc18508e9,0x1b8000cd,
|
||||||
12,0xdafcd800,0xe906f701,0xf7ffea03,
|
12,0xdafcd800,0xe906f701,0xf7ffea03,
|
||||||
12,0xf50908c5,0xdafcf475,0xf8d14014,
|
12,0xf50908c5,0xdafcf475,0xf8d14014,
|
||||||
12,0xfe8001ea,0xe2f710ff,0xf721f749,
|
12,0xfe8001ea,0xe2f710ff,0xf721f749,
|
||||||
12,0x0806e905,0x8502f511,0x0121f479,
|
12,0x0806e905,0x8502f511,0x0121f479,
|
||||||
12,0x00f000e9,0x0e8000f4,0xc9f8d140,
|
12,0x00f000e9,0x0e8000f4,0xc9f8d140,
|
||||||
12,0xd900e803,0xf5100921,0xd906e90f,
|
12,0xd900e803,0xf5100921,0xd906e90f,
|
||||||
12,0x6106f4c8,0xf8d140d8,0x00e802d5,
|
12,0x6106f4c8,0xf8d140d8,0x00e802d5,
|
||||||
12,0x064106f4,0xe06fdccf,0xccdafcf7,
|
12,0x064106f4,0xe06fdccf,0xccdafcf7,
|
||||||
12,0x00fdffc4,0xdafccc44,0xfcf700fe,
|
12,0x00fdffc4,0xdafccc44,0xfcf700fe,
|
||||||
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
||||||
12,0x01e9027c,0x04f475ed,0xd1405120,
|
12,0x01e9027c,0x04f475ed,0xd1405120,
|
||||||
12,0xfef4e05c,0xcbcf0000,0x740a0800,
|
12,0xfef4e05c,0xcbcf0000,0x740a0800,
|
||||||
12,0x01000000,0x00000000,0x00000080,
|
12,0x01000000,0x00000000,0x00000080,
|
||||||
12,0x00000000,0x00000000,0x00000000,
|
12,0x00000000,0x00000000,0x00000000,
|
||||||
00,0x00804c,
|
00,0x00804c,
|
||||||
03,0x00D04000,
|
03,0x00D04000,
|
||||||
99 };
|
99 };
|
||||||
|
|
||||||
unsigned int Drive06[] = {
|
unsigned int Drive06[] = {
|
||||||
0x40D000,
|
0x40D000,
|
||||||
12,0xf4e1a538,0xc7dc0080,0xf471c8e9,
|
12,0xf4e1a538,0xc7dc0080,0xf471c8e9,
|
||||||
12,0x08806ef4,0xe11a5fc7,0xdc6e80a0,
|
12,0x08806ef4,0xe11a5fc7,0xdc6e80a0,
|
||||||
12,0xf9ac01f4,0xe1305fc7,0xf47447d0,
|
12,0xf9ac01f4,0xe1305fc7,0xf47447d0,
|
||||||
12,0x40f7204c,0x80f47442,0x9d08f720,
|
12,0x40f7204c,0x80f47442,0x9d08f720,
|
||||||
12,0xd6fcf474,0x45b108f7,0x20d2fc80,
|
12,0xd6fcf474,0x45b108f7,0x20d2fc80,
|
||||||
12,0x04c4dafc,0xf4741ed4,0x08f000c8,
|
12,0x04c4dafc,0xf4741ed4,0x08f000c8,
|
||||||
12,0xdafcf500,0x01e803fc,0xe200a0f4,
|
12,0xdafcf500,0x01e803fc,0xe200a0f4,
|
||||||
12,0x7400ec40,0xf51002f5,0x1003f510,
|
12,0x7400ec40,0xf51002f5,0x1003f510,
|
||||||
12,0x04f51005,0xf51006f5,0x1007f510,
|
12,0x04f51005,0xf51006f5,0x1007f510,
|
||||||
12,0x08f51009,0xf5100af5,0x100bf510,
|
12,0x08f51009,0xf5100af5,0x100bf510,
|
||||||
12,0x0cf5100d,0xc8dafcf5,0x0002e803,
|
12,0x0cf5100d,0xc8dafcf5,0x0002e803,
|
||||||
12,0xfc3d01f4,0x7402ed40,0x8002f020,
|
12,0xfc3d01f4,0x7402ed40,0x8002f020,
|
||||||
12,0xc87880c0,0x9081dca8,0x80f53000,
|
12,0xc87880c0,0x9081dca8,0x80f53000,
|
||||||
12,0xf444f9d1,0x40f8aa00,0x10f4d0f4,
|
12,0xf444f9d1,0x40f8aa00,0x10f4d0f4,
|
||||||
12,0xd140f001,0xdca880f5,0x3000f748,
|
12,0xd140f001,0xdca880f5,0x3000f748,
|
||||||
12,0xaa00e907,0xf4c4f9d1,0x4010fed8,
|
12,0xaa00e907,0xf4c4f9d1,0x4010fed8,
|
||||||
12,0x32e81df7,0x48a800e8,0x26f748ab,
|
12,0x32e81df7,0x48a800e8,0x26f748ab,
|
||||||
12,0x00e820f7,0x48e100e8,0x1af748ee,
|
12,0x00e820f7,0x48e100e8,0x1af748ee,
|
||||||
12,0x00e83bd8,0x55e82ffe,0x7104fd20,
|
12,0x00e83bd8,0x55e82ffe,0x7104fd20,
|
||||||
12,0x00f45100,0xd240a0f5,0x1000fef2,
|
12,0x00f45100,0xd240a0f5,0x1000fef2,
|
||||||
12,0xf9f4d200,0xd2407104,0xfd0a00f2,
|
12,0xf9f4d200,0xd2407104,0xfd0a00f2,
|
||||||
12,0x49fd0500,0x5104f236,0xfef721bc,
|
12,0x49fd0500,0x5104f236,0xfef721bc,
|
||||||
12,0xfff731bc,0xfffecca9,0x80fd5300,
|
12,0xfff731bc,0xfffecca9,0x80fd5300,
|
||||||
12,0xea0ccca9,0x80c4a481,0xccaa80c4,
|
12,0xea0ccca9,0x80c4a481,0xccaa80c4,
|
||||||
12,0x8881dca8,0x80f8e000,0x10a0f510,
|
12,0x8881dca8,0x80f8e000,0x10a0f510,
|
||||||
12,0x01f51002,0xf51003fe,0xccdafcf7,
|
12,0x01f51002,0xf51003fe,0xccdafcf7,
|
||||||
12,0x00feffc4,0xdafccc44,0xfcf700fe,
|
12,0x00feffc4,0xdafccc44,0xfcf700fe,
|
||||||
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
||||||
12,0x01e9027c,0x04f47585,0xd1405120,
|
12,0x01e9027c,0x04f47585,0xd1405120,
|
||||||
12,0x7134f47d,0xb98508e9,0x1b8000cd,
|
12,0x7134f47d,0xb98508e9,0x1b8000cd,
|
||||||
12,0xdafcd800,0xe906f701,0xf7ffea03,
|
12,0xdafcd800,0xe906f701,0xf7ffea03,
|
||||||
12,0xf50908c5,0xdafcf475,0xf8d14014,
|
12,0xf50908c5,0xdafcf475,0xf8d14014,
|
||||||
12,0xfe8001ea,0xe2f710ff,0xf721f749,
|
12,0xfe8001ea,0xe2f710ff,0xf721f749,
|
||||||
12,0x0806e905,0x8502f511,0x0121f479,
|
12,0x0806e905,0x8502f511,0x0121f479,
|
||||||
12,0x00f000e9,0x0e8000f4,0xc9f8d140,
|
12,0x00f000e9,0x0e8000f4,0xc9f8d140,
|
||||||
12,0xd900e803,0xf5100921,0xd906e90f,
|
12,0xd900e803,0xf5100921,0xd906e90f,
|
||||||
12,0x6106f4c8,0xf8d140d8,0x00e802d5,
|
12,0x6106f4c8,0xf8d140d8,0x00e802d5,
|
||||||
12,0x064106f4,0xe08cdfc7,0xccdafcf7,
|
12,0x064106f4,0xe08cdfc7,0xccdafcf7,
|
||||||
12,0x00fdffc4,0xdafccc44,0xfcf700fe,
|
12,0x00fdffc4,0xdafccc44,0xfcf700fe,
|
||||||
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
||||||
12,0x01e9027c,0x04f475ed,0xd1405120,
|
12,0x01e9027c,0x04f475ed,0xd1405120,
|
||||||
12,0xfef4e0de,0xcbc70000,0x740a0800,
|
12,0xfef4e0de,0xcbc70000,0x740a0800,
|
||||||
12,0x01000000,0x00000000,0x00000080,
|
12,0x01000000,0x00000000,0x00000080,
|
||||||
12,0x00000000,0x00000000,0x00000000,
|
12,0x00000000,0x00000000,0x00000000,
|
||||||
00,0x00804c,
|
00,0x00804c,
|
||||||
03,0x00D04000,
|
03,0x00D04000,
|
||||||
99 };
|
99 };
|
||||||
|
|
||||||
unsigned int Drive08[] = {
|
unsigned int Drive08[] = {
|
||||||
0x40D000,
|
0x40D000,
|
||||||
12,0xf4e1a538,0xcfdc0080,0xf4717cea,
|
12,0xf4e1a538,0xcfdc0080,0xf4717cea,
|
||||||
12,0x08806ef4,0xe1135fcf,0xdc6e80a0,
|
12,0x08806ef4,0xe1135fcf,0xdc6e80a0,
|
||||||
12,0xf9b601f4,0xe1295fcf,0xf47447d0,
|
12,0xf9b601f4,0xe1295fcf,0xf47447d0,
|
||||||
12,0x40f7204c,0x80f47432,0x9d08f720,
|
12,0x40f7204c,0x80f47432,0x9d08f720,
|
||||||
12,0xd6fcf474,0x75ae08f7,0x20d2fc80,
|
12,0xd6fcf474,0x75ae08f7,0x20d2fc80,
|
||||||
12,0x04c4dafc,0xf474d9d4,0x08f000c8,
|
12,0x04c4dafc,0xf474d9d4,0x08f000c8,
|
||||||
12,0xdafcf500,0x01e803fc,0xe200a0f4,
|
12,0xdafcf500,0x01e803fc,0xe200a0f4,
|
||||||
12,0x7400ec40,0xf51002f5,0x1003f510,
|
12,0x7400ec40,0xf51002f5,0x1003f510,
|
||||||
12,0x04f51005,0xf51006f5,0x1007f510,
|
12,0x04f51005,0xf51006f5,0x1007f510,
|
||||||
12,0x08f51009,0xf5100af5,0x100bf510,
|
12,0x08f51009,0xf5100af5,0x100bf510,
|
||||||
12,0x0cf5100d,0xc8dafcf5,0x0002e803,
|
12,0x0cf5100d,0xc8dafcf5,0x0002e803,
|
||||||
12,0xfc3d01f4,0x74f5ec40,0x8002f020,
|
12,0xfc3d01f4,0x74f5ec40,0x8002f020,
|
||||||
12,0xc88080c0,0x9881dcb0,0x80f53000,
|
12,0xc88080c0,0x9881dcb0,0x80f53000,
|
||||||
12,0xf444f9d1,0x40f8aa00,0x10f4d0f4,
|
12,0xf444f9d1,0x40f8aa00,0x10f4d0f4,
|
||||||
12,0xd140f001,0xdcb080f5,0x3000f748,
|
12,0xd140f001,0xdcb080f5,0x3000f748,
|
||||||
12,0xaa00e907,0xf4c4f9d1,0x4010fed8,
|
12,0xaa00e907,0xf4c4f9d1,0x4010fed8,
|
||||||
12,0x32e81df7,0x48a800e8,0x26f748ab,
|
12,0x32e81df7,0x48a800e8,0x26f748ab,
|
||||||
12,0x00e820f7,0x48e100e8,0x1af748ee,
|
12,0x00e820f7,0x48e100e8,0x1af748ee,
|
||||||
12,0x00e83bd8,0x55e82ffe,0x7104fd20,
|
12,0x00e83bd8,0x55e82ffe,0x7104fd20,
|
||||||
12,0x00f45100,0xd240a0f5,0x1000fef2,
|
12,0x00f45100,0xd240a0f5,0x1000fef2,
|
||||||
12,0xf9f4d200,0xd2407104,0xfd0a00f2,
|
12,0xf9f4d200,0xd2407104,0xfd0a00f2,
|
||||||
12,0x49fd0500,0x5104f236,0xfef721bc,
|
12,0x49fd0500,0x5104f236,0xfef721bc,
|
||||||
12,0xfff731bc,0xfffeccb1,0x80fd5300,
|
12,0xfff731bc,0xfffeccb1,0x80fd5300,
|
||||||
12,0xea0cccb1,0x80c4ac81,0xccb280c4,
|
12,0xea0cccb1,0x80c4ac81,0xccb280c4,
|
||||||
12,0x9081dcb0,0x80f8e000,0x10a0f510,
|
12,0x9081dcb0,0x80f8e000,0x10a0f510,
|
||||||
12,0x01f51002,0xf51003fe,0xccdafcf7,
|
12,0x01f51002,0xf51003fe,0xccdafcf7,
|
||||||
12,0x00feffc4,0xdafccc44,0xfcf700fe,
|
12,0x00feffc4,0xdafccc44,0xfcf700fe,
|
||||||
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
||||||
12,0x01e9027c,0x04f47585,0xd1405120,
|
12,0x01e9027c,0x04f47585,0xd1405120,
|
||||||
12,0x7134f47d,0xc18508e9,0x1b8000cd,
|
12,0x7134f47d,0xc18508e9,0x1b8000cd,
|
||||||
12,0xdafcd800,0xe906f701,0xf7ffea03,
|
12,0xdafcd800,0xe906f701,0xf7ffea03,
|
||||||
12,0xf50908c5,0xdafcf475,0xf8d14014,
|
12,0xf50908c5,0xdafcf475,0xf8d14014,
|
||||||
12,0xfe8001ea,0xe2f710ff,0xf721f749,
|
12,0xfe8001ea,0xe2f710ff,0xf721f749,
|
||||||
12,0x0806e905,0x8502f511,0x0121f479,
|
12,0x0806e905,0x8502f511,0x0121f479,
|
||||||
12,0x00f000e9,0x0e8000f4,0xc9f8d140,
|
12,0x00f000e9,0x0e8000f4,0xc9f8d140,
|
||||||
12,0xd900e803,0xf5100921,0xd906e90f,
|
12,0xd900e803,0xf5100921,0xd906e90f,
|
||||||
12,0x6106f4c8,0xf8d140d8,0x00e802d5,
|
12,0x6106f4c8,0xf8d140d8,0x00e802d5,
|
||||||
12,0x064106f4,0xe0bcdccf,0xccdafcf7,
|
12,0x064106f4,0xe0bcdccf,0xccdafcf7,
|
||||||
12,0x00fdffc4,0xdafccc44,0xfcf700fe,
|
12,0x00fdffc4,0xdafccc44,0xfcf700fe,
|
||||||
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
12,0xffc444fc,0xf27cd004,0xcc5b80d8,
|
||||||
12,0x01e9027c,0x04f475ed,0xd1405120,
|
12,0x01e9027c,0x04f475ed,0xd1405120,
|
||||||
12,0xfef4e0b5,0xcbcf0000,0x740a0800,
|
12,0xfef4e0b5,0xcbcf0000,0x740a0800,
|
||||||
12,0x01000000,0x00000000,0x00000080,
|
12,0x01000000,0x00000000,0x00000080,
|
||||||
12,0x00000000,0x00000000,0x00000000,
|
12,0x00000000,0x00000000,0x00000000,
|
||||||
00,0x00804c,
|
00,0x00804c,
|
||||||
03,0x00D04000,
|
03,0x00D04000,
|
||||||
99 };
|
99 };
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Drivecode
|
* Drivecode
|
||||||
@ -170,74 +170,74 @@ unsigned int Drive08[] = {
|
|||||||
void SendDriveCode( int model )
|
void SendDriveCode( int model )
|
||||||
{
|
{
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int length;
|
int length;
|
||||||
unsigned int cmd = 0xfe010100;
|
unsigned int cmd = 0xfe010100;
|
||||||
unsigned int loadaddress;
|
unsigned int loadaddress;
|
||||||
unsigned int *DriveCode;
|
unsigned int *DriveCode;
|
||||||
unsigned char debug[100];
|
unsigned char debug[100];
|
||||||
|
|
||||||
switch( model )
|
switch( model )
|
||||||
{ case 4: DriveCode = (unsigned int *)Drive04; break;
|
{ case 4: DriveCode = (unsigned int *)Drive04; break;
|
||||||
case 6: DriveCode = (unsigned int *)Drive06; break;
|
case 6: DriveCode = (unsigned int *)Drive06; break;
|
||||||
case 8: DriveCode = (unsigned int *)Drive08; break;
|
case 8: DriveCode = (unsigned int *)Drive08; break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadaddress = DriveCode[i++];
|
loadaddress = DriveCode[i++];
|
||||||
length = DriveCode[i++];
|
length = DriveCode[i++];
|
||||||
|
|
||||||
while ( length == 12 )
|
while ( length == 12 )
|
||||||
{
|
{
|
||||||
|
|
||||||
/*** Address Select ***/
|
/*** Address Select ***/
|
||||||
dvdio[0] |= 0x14;
|
dvdio[0] |= 0x14;
|
||||||
dvdio[1] = 0;
|
dvdio[1] = 0;
|
||||||
dvdio[2] = cmd;
|
dvdio[2] = cmd;
|
||||||
dvdio[3] = loadaddress;
|
dvdio[3] = loadaddress;
|
||||||
dvdio[4] = (length << 16);
|
dvdio[4] = (length << 16);
|
||||||
dvdio[5] = 0;
|
dvdio[5] = 0;
|
||||||
dvdio[6] = 0;
|
dvdio[6] = 0;
|
||||||
dvdio[7] = 3;
|
dvdio[7] = 3;
|
||||||
while ( dvdio[7] & 1 );
|
while ( dvdio[7] & 1 );
|
||||||
|
|
||||||
dvdio[0] |= 0x14;
|
dvdio[0] |= 0x14;
|
||||||
dvdio[1] = 0;
|
dvdio[1] = 0;
|
||||||
dvdio[2] = DriveCode[i++];
|
dvdio[2] = DriveCode[i++];
|
||||||
dvdio[3] = DriveCode[i++];
|
dvdio[3] = DriveCode[i++];
|
||||||
dvdio[4] = DriveCode[i++];
|
dvdio[4] = DriveCode[i++];
|
||||||
dvdio[5] = 0;
|
dvdio[5] = 0;
|
||||||
dvdio[6] = 0;
|
dvdio[6] = 0;
|
||||||
dvdio[7] = 1;
|
dvdio[7] = 1;
|
||||||
while ( dvdio[7] & 1 );
|
while ( dvdio[7] & 1 );
|
||||||
|
|
||||||
loadaddress += length;
|
loadaddress += length;
|
||||||
length = DriveCode[i++];
|
length = DriveCode[i++];
|
||||||
}
|
}
|
||||||
|
|
||||||
loadaddress = DriveCode[i++];
|
loadaddress = DriveCode[i++];
|
||||||
length = DriveCode[i++];
|
length = DriveCode[i++];
|
||||||
|
|
||||||
/*** Do SendDriveCommand End ***/
|
/*** Do SendDriveCommand End ***/
|
||||||
dvdio[0] |= 0x14;
|
dvdio[0] |= 0x14;
|
||||||
dvdio[1] = 0;
|
dvdio[1] = 0;
|
||||||
dvdio[2] = cmd;
|
dvdio[2] = cmd;
|
||||||
dvdio[3] = loadaddress;
|
dvdio[3] = loadaddress;
|
||||||
dvdio[4] = (length << 16);
|
dvdio[4] = (length << 16);
|
||||||
dvdio[5] = 0;
|
dvdio[5] = 0;
|
||||||
dvdio[6] = 0;
|
dvdio[6] = 0;
|
||||||
dvdio[7] = 3;
|
dvdio[7] = 3;
|
||||||
while ( dvdio[7] & 1 );
|
while ( dvdio[7] & 1 );
|
||||||
|
|
||||||
dvdio[0] |= 0x14;
|
dvdio[0] |= 0x14;
|
||||||
dvdio[1] = 0;
|
dvdio[1] = 0;
|
||||||
dvdio[2] = DriveCode[i++];
|
dvdio[2] = DriveCode[i++];
|
||||||
dvdio[3] = 0;
|
dvdio[3] = 0;
|
||||||
dvdio[4] = 0;
|
dvdio[4] = 0;
|
||||||
dvdio[5] = 0;
|
dvdio[5] = 0;
|
||||||
dvdio[6] = 0;
|
dvdio[6] = 0;
|
||||||
dvdio[7] = 1;
|
dvdio[7] = 1;
|
||||||
while ( dvdio[7] & 1 );
|
while ( dvdio[7] & 1 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,11 +4,11 @@
|
|||||||
#define MAXFILES 1000
|
#define MAXFILES 1000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char filename[MAXJOLIET];
|
char filename[MAXJOLIET];
|
||||||
char sdcardpath[SDCARD_MAX_PATH_LEN];
|
char sdcardpath[SDCARD_MAX_PATH_LEN];
|
||||||
u64 offset;
|
u64 offset;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
char flags;
|
char flags;
|
||||||
}FILEENTRIES;
|
}FILEENTRIES;
|
||||||
|
|
||||||
extern FILEENTRIES filelist[MAXFILES];
|
extern FILEENTRIES filelist[MAXFILES];
|
||||||
|
@ -25,9 +25,9 @@ extern unsigned char backdrop[614400];
|
|||||||
|
|
||||||
/*** Need something to hold the PC palette ***/
|
/*** Need something to hold the PC palette ***/
|
||||||
struct pcpal {
|
struct pcpal {
|
||||||
unsigned char r;
|
unsigned char r;
|
||||||
unsigned char g;
|
unsigned char g;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
} pcpalette[256];
|
} pcpalette[256];
|
||||||
|
|
||||||
unsigned int gcpalette[256]; /*** Much simpler GC palette ***/
|
unsigned int gcpalette[256]; /*** Much simpler GC palette ***/
|
||||||
@ -46,42 +46,42 @@ extern int font_width;
|
|||||||
|
|
||||||
int GetTextWidth( char *text )
|
int GetTextWidth( char *text )
|
||||||
{
|
{
|
||||||
unsigned int i, w = 0;
|
unsigned int i, w = 0;
|
||||||
|
|
||||||
for ( i = 0; i < strlen(text); i++ )
|
for ( i = 0; i < strlen(text); i++ )
|
||||||
w += font_width;
|
w += font_width;
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CentreTextPosition( char *text )
|
int CentreTextPosition( char *text )
|
||||||
{
|
{
|
||||||
return ( ( 640 - GetTextWidth(text) ) >> 1 );
|
return ( ( 640 - GetTextWidth(text) ) >> 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteCentre( int y, char *text )
|
void WriteCentre( int y, char *text )
|
||||||
{
|
{
|
||||||
write_font( CentreTextPosition(text), y, text);
|
write_font( CentreTextPosition(text), y, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitPrompt( char *msg )
|
void WaitPrompt( char *msg )
|
||||||
{
|
{
|
||||||
int quit = 0;
|
int quit = 0;
|
||||||
|
|
||||||
while ( PAD_ButtonsDown(0) & PAD_BUTTON_A ) {} ;
|
while ( PAD_ButtonsDown(0) & PAD_BUTTON_A ) {} ;
|
||||||
|
|
||||||
while( !(PAD_ButtonsDown(0) & PAD_BUTTON_A ) && (quit == 0 ))
|
while( !(PAD_ButtonsDown(0) & PAD_BUTTON_A ) && (quit == 0 ))
|
||||||
{
|
{
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
|
|
||||||
WriteCentre( 220, msg);
|
WriteCentre( 220, msg);
|
||||||
WriteCentre( 220 + font_height, "Press A to Continue");
|
WriteCentre( 220 + font_height, "Press A to Continue");
|
||||||
|
|
||||||
if ( PAD_ButtonsDown(0) & PAD_BUTTON_A )
|
if ( PAD_ButtonsDown(0) & PAD_BUTTON_A )
|
||||||
quit = 1;
|
quit = 1;
|
||||||
|
|
||||||
SetScreen();
|
SetScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,27 +105,27 @@ int WaitButtonAB ()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a prompt with choice of two options. Returns 1 if A button was pressed
|
* Show a prompt with choice of two options. Returns 1 if A button was pressed
|
||||||
and 0 if B button was pressed.
|
and 0 if B button was pressed.
|
||||||
*/
|
*/
|
||||||
int WaitPromptChoice (char *msg, char *bmsg, char *amsg)
|
int WaitPromptChoice (char *msg, char *bmsg, char *amsg)
|
||||||
{
|
{
|
||||||
char choiceOption[80];
|
char choiceOption[80];
|
||||||
sprintf (choiceOption, "B = %s : A = %s", bmsg, amsg);
|
sprintf (choiceOption, "B = %s : A = %s", bmsg, amsg);
|
||||||
|
|
||||||
ClearScreen ();
|
ClearScreen ();
|
||||||
WriteCentre(220, msg);
|
WriteCentre(220, msg);
|
||||||
WriteCentre(220 + font_height, choiceOption);
|
WriteCentre(220 + font_height, choiceOption);
|
||||||
SetScreen ();
|
SetScreen ();
|
||||||
|
|
||||||
return WaitButtonAB ();
|
return WaitButtonAB ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowAction( char *msg )
|
void ShowAction( char *msg )
|
||||||
{
|
{
|
||||||
memcpy (xfb[whichfb], &backdrop, 1280 * 480);
|
memcpy (xfb[whichfb], &backdrop, 1280 * 480);
|
||||||
/*ClearScreen();*/
|
/*ClearScreen();*/
|
||||||
WriteCentre( 220 + ( font_height >> 1), msg);
|
WriteCentre( 220 + ( font_height >> 1), msg);
|
||||||
SetScreen();
|
SetScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -133,11 +133,11 @@ void ShowAction( char *msg )
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static void copy_to_xfb()
|
static void copy_to_xfb()
|
||||||
{
|
{
|
||||||
if ( copynow == GX_TRUE ) {
|
if ( copynow == GX_TRUE ) {
|
||||||
GX_CopyDisp(xfb[whichfb],GX_TRUE);
|
GX_CopyDisp(xfb[whichfb],GX_TRUE);
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
copynow = GX_FALSE;
|
copynow = GX_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -146,56 +146,56 @@ static void copy_to_xfb()
|
|||||||
|
|
||||||
void StartGX()
|
void StartGX()
|
||||||
{
|
{
|
||||||
/*** Clear out FIFO area ***/
|
/*** Clear out FIFO area ***/
|
||||||
memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE);
|
memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE);
|
||||||
|
|
||||||
/*** Initialise GX ***/
|
/*** Initialise GX ***/
|
||||||
GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE);
|
GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE);
|
||||||
GX_SetCopyClear(background, 0x00ffffff);
|
GX_SetCopyClear(background, 0x00ffffff);
|
||||||
|
|
||||||
/*** Additions from libogc ***/
|
/*** Additions from libogc ***/
|
||||||
GX_SetViewport(10,0,vmode->fbWidth,vmode->efbHeight,0,1);
|
GX_SetViewport(10,0,vmode->fbWidth,vmode->efbHeight,0,1);
|
||||||
GX_SetDispCopyYScale((f32)vmode->xfbHeight/(f32)vmode->efbHeight);
|
GX_SetDispCopyYScale((f32)vmode->xfbHeight/(f32)vmode->efbHeight);
|
||||||
GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight);
|
GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight);
|
||||||
GX_SetDispCopyDst(vmode->fbWidth,vmode->xfbHeight);
|
GX_SetDispCopyDst(vmode->fbWidth,vmode->xfbHeight);
|
||||||
|
|
||||||
GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
||||||
|
|
||||||
GX_SetCullMode(GX_CULL_NONE);
|
GX_SetCullMode(GX_CULL_NONE);
|
||||||
GX_SetZMode(GX_FALSE,GX_ALWAYS,GX_TRUE);
|
GX_SetZMode(GX_FALSE,GX_ALWAYS,GX_TRUE);
|
||||||
GX_SetColorUpdate(GX_TRUE);
|
GX_SetColorUpdate(GX_TRUE);
|
||||||
GX_CopyDisp(xfb[whichfb],GX_TRUE);
|
GX_CopyDisp(xfb[whichfb],GX_TRUE);
|
||||||
|
|
||||||
/*** Additions from ogc spaceship ***/
|
/*** Additions from ogc spaceship ***/
|
||||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||||
|
|
||||||
GX_ClearVtxDesc();
|
GX_ClearVtxDesc();
|
||||||
GX_SetVtxAttrFmt(GX_VTXFMT0,GX_VA_POS,GX_POS_XYZ,GX_F32,0);
|
GX_SetVtxAttrFmt(GX_VTXFMT0,GX_VA_POS,GX_POS_XYZ,GX_F32,0);
|
||||||
GX_SetVtxAttrFmt(GX_VTXFMT0,GX_VA_TEX0,GX_TEX_ST,GX_F32,0);
|
GX_SetVtxAttrFmt(GX_VTXFMT0,GX_VA_TEX0,GX_TEX_ST,GX_F32,0);
|
||||||
GX_SetVtxDesc(GX_VA_POS,GX_DIRECT);
|
GX_SetVtxDesc(GX_VA_POS,GX_DIRECT);
|
||||||
GX_SetVtxDesc(GX_VA_TEX0,GX_DIRECT);
|
GX_SetVtxDesc(GX_VA_TEX0,GX_DIRECT);
|
||||||
|
|
||||||
GX_SetNumChans(0); /* default, color = vertex color */
|
GX_SetNumChans(0); /* default, color = vertex color */
|
||||||
GX_SetNumTexGens(1);
|
GX_SetNumTexGens(1);
|
||||||
GX_SetTexCoordGen(GX_TEXCOORD0,GX_TG_MTX2x4,GX_TG_TEX0,GX_IDENTITY);
|
GX_SetTexCoordGen(GX_TEXCOORD0,GX_TG_MTX2x4,GX_TG_TEX0,GX_IDENTITY);
|
||||||
GX_SetTevOrder(GX_TEVSTAGE0,GX_TEXCOORD0,GX_TEXMAP0,GX_COLORNULL);
|
GX_SetTevOrder(GX_TEVSTAGE0,GX_TEXCOORD0,GX_TEXMAP0,GX_COLORNULL);
|
||||||
GX_SetTevOp(GX_TEVSTAGE0,GX_REPLACE);
|
GX_SetTevOp(GX_TEVSTAGE0,GX_REPLACE);
|
||||||
|
|
||||||
GX_InitTexObj(&texobj,&texturemem,TEX_WIDTH,TEX_HEIGHT,
|
GX_InitTexObj(&texobj,&texturemem,TEX_WIDTH,TEX_HEIGHT,
|
||||||
GX_TF_RGB565,GX_REPEAT,GX_REPEAT,GX_FALSE);
|
GX_TF_RGB565,GX_REPEAT,GX_REPEAT,GX_FALSE);
|
||||||
|
|
||||||
DCFlushRange(&texturemem, TEX_WIDTH * TEX_HEIGHT * 2);
|
DCFlushRange(&texturemem, TEX_WIDTH * TEX_HEIGHT * 2);
|
||||||
GX_LoadTexObj(&texobj,GX_TEXMAP0);
|
GX_LoadTexObj(&texobj,GX_TEXMAP0);
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* load projection matrix */
|
/* load projection matrix */
|
||||||
/*** Setting Height to 648 get's it right ? ***/
|
/*** Setting Height to 648 get's it right ? ***/
|
||||||
guOrtho(projectionMatrix,10,610,640,0,-1,1);
|
guOrtho(projectionMatrix,10,610,640,0,-1,1);
|
||||||
GX_LoadProjectionMtx(projectionMatrix,GX_ORTHOGRAPHIC);
|
GX_LoadProjectionMtx(projectionMatrix,GX_ORTHOGRAPHIC);
|
||||||
|
|
||||||
/* load model view matrix */
|
/* load model view matrix */
|
||||||
c_guMtxScale(modelViewMatrix,660,640,1);
|
c_guMtxScale(modelViewMatrix,660,640,1);
|
||||||
GX_LoadPosMtxImm(modelViewMatrix,GX_PNMTX0);
|
GX_LoadPosMtxImm(modelViewMatrix,GX_PNMTX0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,72 +207,72 @@ void StartGX()
|
|||||||
void GXDraw( unsigned char *XBuf )
|
void GXDraw( unsigned char *XBuf )
|
||||||
{
|
{
|
||||||
|
|
||||||
float gs = 1.0;
|
float gs = 1.0;
|
||||||
float gt = 1.0;
|
float gt = 1.0;
|
||||||
int width, height,t,xb;
|
int width, height,t,xb;
|
||||||
unsigned short *texture;
|
unsigned short *texture;
|
||||||
|
|
||||||
memset(&texturemem, 0, TEX_WIDTH * TEX_HEIGHT * 2);
|
memset(&texturemem, 0, TEX_WIDTH * TEX_HEIGHT * 2);
|
||||||
texture = ( unsigned short *)&texturemem[ 16 * TEX_WIDTH ];
|
texture = ( unsigned short *)&texturemem[ 16 * TEX_WIDTH ];
|
||||||
|
|
||||||
/*** Now draw the texture ***/
|
/*** Now draw the texture ***/
|
||||||
t = 0;
|
t = 0;
|
||||||
for ( height = 0; height < 120; height++ )
|
for ( height = 0; height < 120; height++ )
|
||||||
{
|
{
|
||||||
xb = height * 512;
|
xb = height * 512;
|
||||||
for( width = 256; width > 0; width -= 4 )
|
for( width = 256; width > 0; width -= 4 )
|
||||||
{
|
|
||||||
/*** Row one ***/
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-1]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-2]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-3]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-4]];
|
|
||||||
|
|
||||||
/*** Row three ***/
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-1]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-2]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-3]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + width-4]];
|
|
||||||
|
|
||||||
/*** Row one ***/
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-1]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-2]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-3]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-4]];
|
|
||||||
|
|
||||||
/*** Row three ***/
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-1]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-2]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-3]];
|
|
||||||
texture[t++] = rgb565[XBuf[xb + 256 + width-4]];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DCFlushRange(&texturemem, TEX_WIDTH * TEX_HEIGHT * 2);
|
|
||||||
|
|
||||||
/* setup GX */
|
|
||||||
GX_InvalidateTexAll();
|
|
||||||
|
|
||||||
// ok render the triangles now
|
|
||||||
GX_Begin(GX_QUADS,GX_VTXFMT0,4);
|
|
||||||
{
|
{
|
||||||
GX_Position3f32(0,0,0);
|
/*** Row one ***/
|
||||||
GX_TexCoord2f32(0,0);
|
texture[t++] = rgb565[XBuf[xb + width-1]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + width-2]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + width-3]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + width-4]];
|
||||||
|
|
||||||
GX_Position3f32(0,1,0);
|
/*** Row three ***/
|
||||||
GX_TexCoord2f32(0,gt);
|
texture[t++] = rgb565[XBuf[xb + width-1]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + width-2]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + width-3]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + width-4]];
|
||||||
|
|
||||||
GX_Position3f32(1,1,0);
|
/*** Row one ***/
|
||||||
GX_TexCoord2f32(gs,gt);
|
texture[t++] = rgb565[XBuf[xb + 256 + width-1]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + 256 + width-2]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + 256 + width-3]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + 256 + width-4]];
|
||||||
|
|
||||||
|
/*** Row three ***/
|
||||||
|
texture[t++] = rgb565[XBuf[xb + 256 + width-1]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + 256 + width-2]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + 256 + width-3]];
|
||||||
|
texture[t++] = rgb565[XBuf[xb + 256 + width-4]];
|
||||||
|
|
||||||
GX_Position3f32(1,0,0);
|
|
||||||
GX_TexCoord2f32(gs,0);
|
|
||||||
}
|
}
|
||||||
GX_End();
|
|
||||||
GX_DrawDone();
|
}
|
||||||
copynow = GX_TRUE;
|
|
||||||
|
DCFlushRange(&texturemem, TEX_WIDTH * TEX_HEIGHT * 2);
|
||||||
|
|
||||||
|
/* setup GX */
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
// ok render the triangles now
|
||||||
|
GX_Begin(GX_QUADS,GX_VTXFMT0,4);
|
||||||
|
{
|
||||||
|
GX_Position3f32(0,0,0);
|
||||||
|
GX_TexCoord2f32(0,0);
|
||||||
|
|
||||||
|
GX_Position3f32(0,1,0);
|
||||||
|
GX_TexCoord2f32(0,gt);
|
||||||
|
|
||||||
|
GX_Position3f32(1,1,0);
|
||||||
|
GX_TexCoord2f32(gs,gt);
|
||||||
|
|
||||||
|
GX_Position3f32(1,0,0);
|
||||||
|
GX_TexCoord2f32(gs,0);
|
||||||
|
}
|
||||||
|
GX_End();
|
||||||
|
GX_DrawDone();
|
||||||
|
copynow = GX_TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,49 +287,49 @@ void GXDraw( unsigned char *XBuf )
|
|||||||
void initDisplay()
|
void initDisplay()
|
||||||
{
|
{
|
||||||
|
|
||||||
/*** Start VIDEO Subsystem ***/
|
/*** Start VIDEO Subsystem ***/
|
||||||
VIDEO_Init();
|
VIDEO_Init();
|
||||||
|
|
||||||
/*** Determine display mode
|
/*** Determine display mode
|
||||||
NOTE: Force 60Hz 640x480 for PAL or NTSC ***/
|
NOTE: Force 60Hz 640x480 for PAL or NTSC ***/
|
||||||
|
|
||||||
/* switch(VIDEO_GetCurrentTvMode())
|
/* switch(VIDEO_GetCurrentTvMode())
|
||||||
{
|
{
|
||||||
case VI_NTSC:
|
case VI_NTSC:
|
||||||
vmode = &TVNtsc480IntDf;
|
vmode = &TVNtsc480IntDf;
|
||||||
break;
|
break;
|
||||||
case VI_PAL:
|
case VI_PAL:
|
||||||
case VI_MPAL:
|
case VI_MPAL:
|
||||||
vmode = &TVMpal480IntDf;
|
vmode = &TVMpal480IntDf;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vmode = &TVNtsc480IntDf;
|
vmode = &TVNtsc480IntDf;
|
||||||
break;
|
break;
|
||||||
}*/
|
}*/
|
||||||
//vmode = &TVPal528IntDf;
|
//vmode = &TVPal528IntDf;
|
||||||
|
|
||||||
// works for NTSC and PAL on GC and Wii :)
|
// works for NTSC and PAL on GC and Wii :)
|
||||||
vmode = &TVNtsc480IntDf;
|
vmode = &TVNtsc480IntDf;
|
||||||
|
|
||||||
xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
|
xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
|
||||||
xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
|
xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
|
||||||
/*init_font();*/
|
/*init_font();*/
|
||||||
|
|
||||||
VIDEO_Configure(vmode);
|
VIDEO_Configure(vmode);
|
||||||
VIDEO_SetNextFramebuffer(xfb[0]);
|
VIDEO_SetNextFramebuffer(xfb[0]);
|
||||||
VIDEO_SetBlack(FALSE);
|
VIDEO_SetBlack(FALSE);
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
if(vmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
if(vmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||||
VIDEO_SetPostRetraceCallback(PAD_ScanPads);
|
VIDEO_SetPostRetraceCallback(PAD_ScanPads);
|
||||||
/*** Setup a console - guard against spurious printf ***/
|
/*** Setup a console - guard against spurious printf ***/
|
||||||
VIDEO_SetPreRetraceCallback(copy_to_xfb);
|
VIDEO_SetPreRetraceCallback(copy_to_xfb);
|
||||||
VIDEO_SetNextFramebuffer(xfb[0]);
|
VIDEO_SetNextFramebuffer(xfb[0]);
|
||||||
|
|
||||||
PAD_Init();
|
PAD_Init();
|
||||||
StartGX();
|
StartGX();
|
||||||
DVD_Init();
|
DVD_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -342,47 +342,47 @@ void initDisplay()
|
|||||||
void RenderFrame( char *XBuf, int style )
|
void RenderFrame( char *XBuf, int style )
|
||||||
{
|
{
|
||||||
|
|
||||||
int gcdispOffset = 32; /*** Offset to centre on screen ***/
|
int gcdispOffset = 32; /*** Offset to centre on screen ***/
|
||||||
int w,h;
|
int w,h;
|
||||||
int c,i;
|
int c,i;
|
||||||
|
|
||||||
whichfb ^= 1;
|
whichfb ^= 1;
|
||||||
|
|
||||||
switch( style ) {
|
switch( style ) {
|
||||||
|
|
||||||
case 0 :
|
case 0 :
|
||||||
VIDEO_ClearFrameBuffer( vmode, xfb[whichfb], COLOR_BLACK);
|
VIDEO_ClearFrameBuffer( vmode, xfb[whichfb], COLOR_BLACK);
|
||||||
|
|
||||||
/*** Simply go through each row ***/
|
/*** Simply go through each row ***/
|
||||||
for( h = 0; h < NESHEIGHT; h++ )
|
for( h = 0; h < NESHEIGHT; h++ )
|
||||||
{
|
{
|
||||||
for( w = 0; w < NESWIDTH; w++ )
|
for( w = 0; w < NESWIDTH; w++ )
|
||||||
{
|
{
|
||||||
c = ( h << 8 ) + w;
|
c = ( h << 8 ) + w;
|
||||||
i = gcdispOffset + w;
|
i = gcdispOffset + w;
|
||||||
/*** Fast Zoom - Repeat each row, use 1 Xbuf == 2 GC
|
/*** Fast Zoom - Repeat each row, use 1 Xbuf == 2 GC
|
||||||
To speed up more, use indexed palette array ***/
|
To speed up more, use indexed palette array ***/
|
||||||
|
|
||||||
xfb[whichfb][i] = gcpalette[ (unsigned char)XBuf[ c ] ];
|
xfb[whichfb][i] = gcpalette[ (unsigned char)XBuf[ c ] ];
|
||||||
xfb[whichfb][i + 320] = gcpalette[ (unsigned char)XBuf[ c ] ];
|
xfb[whichfb][i + 320] = gcpalette[ (unsigned char)XBuf[ c ] ];
|
||||||
}
|
}
|
||||||
gcdispOffset += 640;
|
gcdispOffset += 640;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
CheesyScale( XBuf );
|
CheesyScale( XBuf );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
GXDraw( XBuf );
|
GXDraw( XBuf );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Now resync with VSync ***/
|
/*** Now resync with VSync ***/
|
||||||
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -392,22 +392,22 @@ void RenderFrame( char *XBuf, int style )
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
unsigned int rgbcolor( unsigned char r1, unsigned char g1, unsigned char b1,
|
unsigned int rgbcolor( unsigned char r1, unsigned char g1, unsigned char b1,
|
||||||
unsigned char r2, unsigned char g2, unsigned char b2)
|
unsigned char r2, unsigned char g2, unsigned char b2)
|
||||||
{
|
{
|
||||||
int y1,cb1,cr1,y2,cb2,cr2,cb,cr;
|
int y1,cb1,cr1,y2,cb2,cr2,cb,cr;
|
||||||
|
|
||||||
y1=(299*r1+587*g1+114*b1)/1000;
|
y1=(299*r1+587*g1+114*b1)/1000;
|
||||||
cb1=(-16874*r1-33126*g1+50000*b1+12800000)/100000;
|
cb1=(-16874*r1-33126*g1+50000*b1+12800000)/100000;
|
||||||
cr1=(50000*r1-41869*g1-8131*b1+12800000)/100000;
|
cr1=(50000*r1-41869*g1-8131*b1+12800000)/100000;
|
||||||
|
|
||||||
y2=(299*r2+587*g2+114*b2)/1000;
|
y2=(299*r2+587*g2+114*b2)/1000;
|
||||||
cb2=(-16874*r2-33126*g2+50000*b2+12800000)/100000;
|
cb2=(-16874*r2-33126*g2+50000*b2+12800000)/100000;
|
||||||
cr2=(50000*r2-41869*g2-8131*b2+12800000)/100000;
|
cr2=(50000*r2-41869*g2-8131*b2+12800000)/100000;
|
||||||
|
|
||||||
cb=(cb1+cb2) >> 1;
|
cb=(cb1+cb2) >> 1;
|
||||||
cr=(cr1+cr2) >> 1;
|
cr=(cr1+cr2) >> 1;
|
||||||
|
|
||||||
return ( (y1 << 24) | (cb << 16) | (y2 << 8) | cr );
|
return ( (y1 << 24) | (cb << 16) | (y2 << 8) | cr );
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -418,18 +418,18 @@ unsigned int rgbcolor( unsigned char r1, unsigned char g1, unsigned char b1,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b)
|
void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b)
|
||||||
{
|
{
|
||||||
/*** Make PC compatible copy ***/
|
/*** Make PC compatible copy ***/
|
||||||
pcpalette[index].r = r;
|
pcpalette[index].r = r;
|
||||||
pcpalette[index].g = g;
|
pcpalette[index].g = g;
|
||||||
pcpalette[index].b = b;
|
pcpalette[index].b = b;
|
||||||
|
|
||||||
/*** Generate Gamecube palette ***/
|
/*** Generate Gamecube palette ***/
|
||||||
gcpalette[index] = rgbcolor(r,g,b,r,g,b);
|
gcpalette[index] = rgbcolor(r,g,b,r,g,b);
|
||||||
|
|
||||||
/*** Generate RGB565 texture palette ***/
|
/*** Generate RGB565 texture palette ***/
|
||||||
rgb565[index] = ( ( r & 0xf8 ) << 8 ) |
|
rgb565[index] = ( ( r & 0xf8 ) << 8 ) |
|
||||||
( ( g & 0xfc ) << 3 ) |
|
( ( g & 0xfc ) << 3 ) |
|
||||||
( ( b & 0xf8 ) >> 3 );
|
( ( b & 0xf8 ) >> 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -437,9 +437,9 @@ void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, uns
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g, unsigned char *b)
|
void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g, unsigned char *b)
|
||||||
{
|
{
|
||||||
*r = pcpalette[i].r;
|
*r = pcpalette[i].r;
|
||||||
*g = pcpalette[i].g;
|
*g = pcpalette[i].g;
|
||||||
*b = pcpalette[i].b;
|
*b = pcpalette[i].b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -452,56 +452,56 @@ void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g, unsig
|
|||||||
void CheesyScale( unsigned char *XBuf )
|
void CheesyScale( unsigned char *XBuf )
|
||||||
{
|
{
|
||||||
|
|
||||||
static int newrow[320]; /*** New cheesy row ***/
|
static int newrow[320]; /*** New cheesy row ***/
|
||||||
unsigned int cheesypal[256]; /*** Enhanced Cheesy Palette ***/
|
unsigned int cheesypal[256]; /*** Enhanced Cheesy Palette ***/
|
||||||
int i,j,c,p = 0;
|
int i,j,c,p = 0;
|
||||||
unsigned char p1,p2;
|
unsigned char p1,p2;
|
||||||
unsigned int ofs, gcdispOffset = 0;
|
unsigned int ofs, gcdispOffset = 0;
|
||||||
int h, n, nw;
|
int h, n, nw;
|
||||||
|
|
||||||
/*** Stretch ***/
|
/*** Stretch ***/
|
||||||
for ( h = 0; h < NESHEIGHT; h++ )
|
for ( h = 0; h < NESHEIGHT; h++ )
|
||||||
{
|
{
|
||||||
j = c = p = 0;
|
j = c = p = 0;
|
||||||
for ( i = 0; i < NESWIDTH; i++ )
|
for ( i = 0; i < NESWIDTH; i++ )
|
||||||
{
|
{
|
||||||
|
|
||||||
/*** Every fifth pixel is stretched by adding
|
/*** Every fifth pixel is stretched by adding
|
||||||
the mid colour range ***/
|
the mid colour range ***/
|
||||||
n = ( h << 8 ) + i;
|
n = ( h << 8 ) + i;
|
||||||
newrow[j++] = XBuf[ n ];
|
newrow[j++] = XBuf[ n ];
|
||||||
c++;
|
c++;
|
||||||
if ( c == 4 )
|
if ( c == 4 )
|
||||||
{ /*** Done 4 pixels, so add the fifth ***/
|
{ /*** Done 4 pixels, so add the fifth ***/
|
||||||
p1 = XBuf[n];
|
p1 = XBuf[n];
|
||||||
p2 = XBuf[n+1];
|
p2 = XBuf[n+1];
|
||||||
cheesypal[p] = rgbcolor( pcpalette[p1].r, pcpalette[p1].g, pcpalette[p1].b,
|
cheesypal[p] = rgbcolor( pcpalette[p1].r, pcpalette[p1].g, pcpalette[p1].b,
|
||||||
pcpalette[p2].r, pcpalette[p2].g, pcpalette[p2].b );
|
pcpalette[p2].r, pcpalette[p2].g, pcpalette[p2].b );
|
||||||
newrow[j++] = 0x8000 + p;
|
newrow[j++] = 0x8000 + p;
|
||||||
p++;
|
p++;
|
||||||
c = 0;
|
c = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*** Now update the screen display with the new colours ***/
|
/*** Now update the screen display with the new colours ***/
|
||||||
ofs = gcdispOffset;
|
ofs = gcdispOffset;
|
||||||
for ( nw = 0; nw < 320; nw++ )
|
for ( nw = 0; nw < 320; nw++ )
|
||||||
{
|
{
|
||||||
if ( newrow[nw] & 0x8000 ) {
|
if ( newrow[nw] & 0x8000 ) {
|
||||||
xfb[whichfb][ofs + nw] = cheesypal[newrow[nw] & 0xff ];
|
xfb[whichfb][ofs + nw] = cheesypal[newrow[nw] & 0xff ];
|
||||||
xfb[whichfb][ofs + 320 + nw] = cheesypal[newrow[nw] & 0xff];
|
xfb[whichfb][ofs + 320 + nw] = cheesypal[newrow[nw] & 0xff];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xfb[whichfb][ofs + nw] = gcpalette[ newrow[nw] ];
|
xfb[whichfb][ofs + nw] = gcpalette[ newrow[nw] ];
|
||||||
xfb[whichfb][ofs + nw + 320] = gcpalette[ newrow[nw] ];
|
xfb[whichfb][ofs + nw + 320] = gcpalette[ newrow[nw] ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gcdispOffset += 640;
|
gcdispOffset += 640;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
int IsXenoGCImage( char *buffer )
|
int IsXenoGCImage( char *buffer )
|
||||||
{
|
{
|
||||||
|
|
||||||
/*** All Xeno GC Homebrew Boot have id GBLPGL ***/
|
/*** All Xeno GC Homebrew Boot have id GBLPGL ***/
|
||||||
if ( memcmp( buffer, "GBLPGL", 6 ) )
|
if ( memcmp( buffer, "GBLPGL", 6 ) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( memcmp( &buffer[0x20], "GAMECUBE \"EL TORITO\" BOOTLOADER", 31 ) )
|
if ( memcmp( &buffer[0x20], "GAMECUBE \"EL TORITO\" BOOTLOADER", 31 ) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,39 +31,39 @@ extern unsigned int dvd_read(void *dst, unsigned int len, unsigned int offset);
|
|||||||
/*** PKWare Zip Header ***/
|
/*** PKWare Zip Header ***/
|
||||||
#define PKZIPID 0x504b0304
|
#define PKZIPID 0x504b0304
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int zipid __attribute__ ((__packed__)); // 0x04034b50
|
unsigned int zipid __attribute__ ((__packed__)); // 0x04034b50
|
||||||
unsigned short zipversion __attribute__ ((__packed__));
|
unsigned short zipversion __attribute__ ((__packed__));
|
||||||
unsigned short zipflags __attribute__ ((__packed__));
|
unsigned short zipflags __attribute__ ((__packed__));
|
||||||
unsigned short compressionMethod __attribute__ ((__packed__));
|
unsigned short compressionMethod __attribute__ ((__packed__));
|
||||||
unsigned short lastmodtime __attribute__ ((__packed__));
|
unsigned short lastmodtime __attribute__ ((__packed__));
|
||||||
unsigned short lastmoddate __attribute__ ((__packed__));
|
unsigned short lastmoddate __attribute__ ((__packed__));
|
||||||
unsigned int crc32 __attribute__ ((__packed__));
|
unsigned int crc32 __attribute__ ((__packed__));
|
||||||
unsigned int compressedSize __attribute__ ((__packed__));
|
unsigned int compressedSize __attribute__ ((__packed__));
|
||||||
unsigned int uncompressedSize __attribute__ ((__packed__));
|
unsigned int uncompressedSize __attribute__ ((__packed__));
|
||||||
unsigned short filenameLength __attribute__ ((__packed__));
|
unsigned short filenameLength __attribute__ ((__packed__));
|
||||||
unsigned short extraDataLength __attribute__ ((__packed__));
|
unsigned short extraDataLength __attribute__ ((__packed__));
|
||||||
} PKZIPHEADER;
|
} PKZIPHEADER;
|
||||||
|
|
||||||
static inline u32 FLIP32(u32 b)
|
static inline u32 FLIP32(u32 b)
|
||||||
{
|
{
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
|
|
||||||
c = ( b & 0xff000000 ) >> 24;
|
c = ( b & 0xff000000 ) >> 24;
|
||||||
c |= ( b & 0xff0000 ) >> 8;
|
c |= ( b & 0xff0000 ) >> 8;
|
||||||
c |= ( b & 0xff00 ) << 8;
|
c |= ( b & 0xff00 ) << 8;
|
||||||
c |= ( b & 0xff ) << 24;
|
c |= ( b & 0xff ) << 24;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u16 FLIP16(u16 b)
|
static inline u16 FLIP16(u16 b)
|
||||||
{
|
{
|
||||||
u16 c;
|
u16 c;
|
||||||
|
|
||||||
c = ( b & 0xff00 ) >> 8;
|
c = ( b & 0xff00 ) >> 8;
|
||||||
c |= ( b &0xff ) << 8;
|
c |= ( b &0xff ) << 8;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -78,10 +78,10 @@ static inline u16 FLIP16(u16 b)
|
|||||||
|
|
||||||
bool isZipFile()
|
bool isZipFile()
|
||||||
{
|
{
|
||||||
u32 check;
|
u32 check;
|
||||||
|
|
||||||
memcpy(&check, &readbuffer, 4);
|
memcpy(&check, &readbuffer, 4);
|
||||||
return ( check == PKZIPID ) ? true : false;
|
return ( check == PKZIPID ) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -93,92 +93,92 @@ bool isZipFile()
|
|||||||
* Unzip terminates on Z_END_STREAM.
|
* Unzip terminates on Z_END_STREAM.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int unzipDVDFile( unsigned char *outbuffer,
|
int unzipDVDFile( unsigned char *outbuffer,
|
||||||
unsigned int discoffset, unsigned int length)
|
unsigned int discoffset, unsigned int length)
|
||||||
{
|
{
|
||||||
PKZIPHEADER pkzip;
|
PKZIPHEADER pkzip;
|
||||||
int zipoffset = 0;
|
int zipoffset = 0;
|
||||||
int zipchunk = 0;
|
int zipchunk = 0;
|
||||||
char out[ZIPCHUNK];
|
char out[ZIPCHUNK];
|
||||||
z_stream zs;
|
z_stream zs;
|
||||||
int res;
|
int res;
|
||||||
int bufferoffset = 0;
|
int bufferoffset = 0;
|
||||||
int have = 0;
|
int have = 0;
|
||||||
char debug[128];
|
char debug[128];
|
||||||
|
|
||||||
/*** Copy PKZip header to local, used as info ***/
|
/*** Copy PKZip header to local, used as info ***/
|
||||||
memcpy(&pkzip, &readbuffer, sizeof(PKZIPHEADER));
|
memcpy(&pkzip, &readbuffer, sizeof(PKZIPHEADER));
|
||||||
|
|
||||||
sprintf(debug, "Unzipping %d bytes ... Wait", FLIP32(pkzip.uncompressedSize));
|
sprintf(debug, "Unzipping %d bytes ... Wait", FLIP32(pkzip.uncompressedSize));
|
||||||
ShowAction(debug);
|
ShowAction(debug);
|
||||||
|
|
||||||
/*** Prepare the zip stream ***/
|
/*** Prepare the zip stream ***/
|
||||||
memset(&zs, 0, sizeof(z_stream));
|
memset(&zs, 0, sizeof(z_stream));
|
||||||
zs.zalloc = Z_NULL;
|
zs.zalloc = Z_NULL;
|
||||||
zs.zfree = Z_NULL;
|
zs.zfree = Z_NULL;
|
||||||
zs.opaque = Z_NULL;
|
zs.opaque = Z_NULL;
|
||||||
zs.avail_in = 0;
|
zs.avail_in = 0;
|
||||||
zs.next_in = Z_NULL;
|
zs.next_in = Z_NULL;
|
||||||
res = inflateInit2(&zs, -MAX_WBITS);
|
res = inflateInit2(&zs, -MAX_WBITS);
|
||||||
|
|
||||||
if ( res != Z_OK )
|
if ( res != Z_OK )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*** Set ZipChunk for first pass ***/
|
/*** Set ZipChunk for first pass ***/
|
||||||
zipoffset = ( sizeof(PKZIPHEADER) + FLIP16(pkzip.filenameLength) + FLIP16(pkzip.extraDataLength ));
|
zipoffset = ( sizeof(PKZIPHEADER) + FLIP16(pkzip.filenameLength) + FLIP16(pkzip.extraDataLength ));
|
||||||
zipchunk = ZIPCHUNK - zipoffset;
|
zipchunk = ZIPCHUNK - zipoffset;
|
||||||
|
|
||||||
/*** No do it! ***/
|
/*** No do it! ***/
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
zs.avail_in = zipchunk;
|
zs.avail_in = zipchunk;
|
||||||
zs.next_in = (Bytef *)&readbuffer[zipoffset];
|
zs.next_in = (Bytef *)&readbuffer[zipoffset];
|
||||||
|
|
||||||
/*** Now inflate until input buffer is exhausted ***/
|
/*** Now inflate until input buffer is exhausted ***/
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
zs.avail_out = ZIPCHUNK;
|
zs.avail_out = ZIPCHUNK;
|
||||||
zs.next_out = (Bytef *)&out;
|
zs.next_out = (Bytef *)&out;
|
||||||
|
|
||||||
res = inflate(&zs, Z_NO_FLUSH);
|
res = inflate(&zs, Z_NO_FLUSH);
|
||||||
|
|
||||||
if ( res == Z_MEM_ERROR ) {
|
if ( res == Z_MEM_ERROR ) {
|
||||||
inflateEnd(&zs);
|
inflateEnd(&zs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
have = ZIPCHUNK - zs.avail_out;
|
have = ZIPCHUNK - zs.avail_out;
|
||||||
if ( have ) {
|
if ( have ) {
|
||||||
/*** Copy to normal block buffer ***/
|
/*** Copy to normal block buffer ***/
|
||||||
memcpy(&outbuffer[bufferoffset], &out, have);
|
memcpy(&outbuffer[bufferoffset], &out, have);
|
||||||
bufferoffset += have;
|
bufferoffset += have;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while ( zs.avail_out == 0 );
|
} while ( zs.avail_out == 0 );
|
||||||
|
|
||||||
/*** Readup the next 2k block ***/
|
/*** Readup the next 2k block ***/
|
||||||
zipoffset = 0;
|
zipoffset = 0;
|
||||||
zipchunk = ZIPCHUNK;
|
zipchunk = ZIPCHUNK;
|
||||||
discoffset += 2048;
|
discoffset += 2048;
|
||||||
if ( UseSDCARD )
|
if ( UseSDCARD )
|
||||||
SDCARD_ReadFile(filehandle, &readbuffer, 2048);
|
SDCARD_ReadFile(filehandle, &readbuffer, 2048);
|
||||||
else
|
else
|
||||||
dvd_read(&readbuffer, 2048, discoffset);
|
dvd_read(&readbuffer, 2048, discoffset);
|
||||||
|
|
||||||
} while ( res != Z_STREAM_END );
|
} while ( res != Z_STREAM_END );
|
||||||
|
|
||||||
inflateEnd(&zs);
|
inflateEnd(&zs);
|
||||||
|
|
||||||
if ( UseSDCARD )
|
if ( UseSDCARD )
|
||||||
SDCARD_CloseFile(filehandle);
|
SDCARD_CloseFile(filehandle);
|
||||||
|
|
||||||
if ( res == Z_STREAM_END ) {
|
if ( res == Z_STREAM_END ) {
|
||||||
if ( FLIP32(pkzip.uncompressedSize == (u32)bufferoffset ) )
|
if ( FLIP32(pkzip.uncompressedSize == (u32)bufferoffset ) )
|
||||||
return bufferoffset;
|
return bufferoffset;
|
||||||
else
|
else
|
||||||
return FLIP32(pkzip.uncompressedSize);
|
return FLIP32(pkzip.uncompressedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -55,44 +55,44 @@ int choosenSDSlot = 0;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
initDisplay();
|
initDisplay();
|
||||||
SYS_SetResetCallback (reset_cb);
|
SYS_SetResetCallback (reset_cb);
|
||||||
InitialiseSound();
|
InitialiseSound();
|
||||||
SDCARD_Init ();
|
SDCARD_Init ();
|
||||||
|
|
||||||
/*** Minimal Emulation Loop ***/
|
/*** Minimal Emulation Loop ***/
|
||||||
if ( !FCEUI_Initialize() ) {
|
if ( !FCEUI_Initialize() ) {
|
||||||
printf("Ooops - unable to initialize system\n");
|
printf("Ooops - unable to initialize system\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
palyo=0;
|
palyo=0;
|
||||||
FCEUI_SetVidSystem(palyo);
|
FCEUI_SetVidSystem(palyo);
|
||||||
genie&=1;
|
genie&=1;
|
||||||
FCEUI_SetGameGenie(genie);
|
FCEUI_SetGameGenie(genie);
|
||||||
fullscreen&=1;
|
fullscreen&=1;
|
||||||
soundo&=1;
|
soundo&=1;
|
||||||
FCEUI_SetSoundVolume(soundvolume);
|
FCEUI_SetSoundVolume(soundvolume);
|
||||||
FCEUI_SetSoundQuality(soundquality);
|
FCEUI_SetSoundQuality(soundquality);
|
||||||
|
|
||||||
cleanSFMDATA();
|
cleanSFMDATA();
|
||||||
GCMemROM();
|
GCMemROM();
|
||||||
|
|
||||||
choosenSDSlot = !WaitPromptChoice("Choose a SLOT to load Roms from SDCARD", "SLOT B", "SLOT A");
|
choosenSDSlot = !WaitPromptChoice("Choose a SLOT to load Roms from SDCARD", "SLOT B", "SLOT A");
|
||||||
ConfigScreen();
|
ConfigScreen();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
uint8 *gfx;
|
uint8 *gfx;
|
||||||
int32 *sound;
|
int32 *sound;
|
||||||
int32 ssize;
|
int32 ssize;
|
||||||
|
|
||||||
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
|
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
|
||||||
xbsave = gfx;
|
xbsave = gfx;
|
||||||
FCEUD_Update(gfx, sound, ssize);
|
FCEUD_Update(gfx, sound, ssize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -101,7 +101,7 @@ int main(int argc, char *argv[])
|
|||||||
/*** File Control ***/
|
/*** File Control ***/
|
||||||
FILE *FCEUD_UTF8fopen(const char *n, const char *m)
|
FILE *FCEUD_UTF8fopen(const char *n, const char *m)
|
||||||
{
|
{
|
||||||
return(fopen(n,m));
|
return(fopen(n,m));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** General Logging ***/
|
/*** General Logging ***/
|
||||||
@ -117,9 +117,9 @@ void FCEUD_Message(char *text)
|
|||||||
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
|
||||||
{
|
{
|
||||||
|
|
||||||
PlaySound(Buffer, Count);
|
PlaySound(Buffer, Count);
|
||||||
RenderFrame( XBuf, screenscaler );
|
RenderFrame( XBuf, screenscaler );
|
||||||
GetJoy(); /* Fix by Garglub. Thanks! */
|
GetJoy(); /* Fix by Garglub. Thanks! */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,46 +29,46 @@ extern unsigned char nesrom[];
|
|||||||
int GCMemROM()
|
int GCMemROM()
|
||||||
{
|
{
|
||||||
|
|
||||||
nesromptr = &nesrom[0];
|
nesromptr = &nesrom[0];
|
||||||
|
|
||||||
ResetGameLoaded();
|
ResetGameLoaded();
|
||||||
|
|
||||||
/*** Allocate and clear GameInfo ***/
|
/*** Allocate and clear GameInfo ***/
|
||||||
FCEUGameInfo = malloc(sizeof(FCEUGI));
|
FCEUGameInfo = malloc(sizeof(FCEUGI));
|
||||||
memset(FCEUGameInfo, 0, sizeof(FCEUGI));
|
memset(FCEUGameInfo, 0, sizeof(FCEUGI));
|
||||||
|
|
||||||
/*** Set some default values ***/
|
/*** Set some default values ***/
|
||||||
FCEUGameInfo->soundchan = 1;
|
FCEUGameInfo->soundchan = 1;
|
||||||
FCEUGameInfo->soundrate = SAMPLERATE;
|
FCEUGameInfo->soundrate = SAMPLERATE;
|
||||||
FCEUGameInfo->name=0;
|
FCEUGameInfo->name=0;
|
||||||
FCEUGameInfo->type=GIT_CART;
|
FCEUGameInfo->type=GIT_CART;
|
||||||
FCEUGameInfo->vidsys=GIV_USER;
|
FCEUGameInfo->vidsys=GIV_USER;
|
||||||
FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1;
|
FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1;
|
||||||
FCEUGameInfo->inputfc=-1;
|
FCEUGameInfo->inputfc=-1;
|
||||||
FCEUGameInfo->cspecial=0;
|
FCEUGameInfo->cspecial=0;
|
||||||
|
|
||||||
/*** Set internal sound information ***/
|
/*** Set internal sound information ***/
|
||||||
FCEUI_Sound(SAMPLERATE);
|
FCEUI_Sound(SAMPLERATE);
|
||||||
FCEUI_SetSoundQuality(0);
|
FCEUI_SetSoundQuality(0);
|
||||||
FCEUI_SetSoundVolume(100);
|
FCEUI_SetSoundVolume(100);
|
||||||
FCEUI_SetLowPass(0);
|
FCEUI_SetLowPass(0);
|
||||||
|
|
||||||
InitialisePads();
|
InitialisePads();
|
||||||
|
|
||||||
if ( iNESMemLoad( nesromptr ) )
|
if ( iNESMemLoad( nesromptr ) )
|
||||||
{
|
{
|
||||||
FCEU_ResetVidSys();
|
FCEU_ResetVidSys();
|
||||||
PowerNES();
|
PowerNES();
|
||||||
FCEU_ResetPalette();
|
FCEU_ResetPalette();
|
||||||
FCEU_ResetMessages(); // Save state, status messages, etc.
|
FCEU_ResetMessages(); // Save state, status messages, etc.
|
||||||
SetSoundVariables();
|
SetSoundVariables();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Bad cartridge!");
|
WaitPrompt("Bad cartridge!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;;
|
return 0;;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,39 +47,39 @@ static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN(32);
|
|||||||
/*** Open a file ***/
|
/*** Open a file ***/
|
||||||
void memopen()
|
void memopen()
|
||||||
{
|
{
|
||||||
sboffset = 0;
|
sboffset = 0;
|
||||||
memset(&statebuffer[0], 0, sizeof(statebuffer));
|
memset(&statebuffer[0], 0, sizeof(statebuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Close a file ***/
|
/*** Close a file ***/
|
||||||
void memclose()
|
void memclose()
|
||||||
{
|
{
|
||||||
sboffset = 0;
|
sboffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Write to the file ***/
|
/*** Write to the file ***/
|
||||||
void memfwrite( void *buffer, int len )
|
void memfwrite( void *buffer, int len )
|
||||||
{
|
{
|
||||||
if ( (sboffset + len ) > sizeof(statebuffer))
|
if ( (sboffset + len ) > sizeof(statebuffer))
|
||||||
WaitPrompt("Buffer Exceeded");
|
WaitPrompt("Buffer Exceeded");
|
||||||
|
|
||||||
if ( len > 0 ) {
|
if ( len > 0 ) {
|
||||||
memcpy(&statebuffer[sboffset], buffer, len );
|
memcpy(&statebuffer[sboffset], buffer, len );
|
||||||
sboffset += len;
|
sboffset += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Read from a file ***/
|
/*** Read from a file ***/
|
||||||
void memfread( void *buffer, int len )
|
void memfread( void *buffer, int len )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( ( sboffset + len ) > sizeof(statebuffer))
|
if ( ( sboffset + len ) > sizeof(statebuffer))
|
||||||
WaitPrompt("Buffer exceeded");
|
WaitPrompt("Buffer exceeded");
|
||||||
|
|
||||||
if ( len > 0 ) {
|
if ( len > 0 ) {
|
||||||
memcpy(buffer, &statebuffer[sboffset], len);
|
memcpy(buffer, &statebuffer[sboffset], len);
|
||||||
sboffset += len;
|
sboffset += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -90,53 +90,53 @@ void memfread( void *buffer, int len )
|
|||||||
|
|
||||||
int GCReadChunk( int chunkid, SFORMAT *sf )
|
int GCReadChunk( int chunkid, SFORMAT *sf )
|
||||||
{
|
{
|
||||||
int csize;
|
int csize;
|
||||||
static char chunk[6];
|
static char chunk[6];
|
||||||
int chunklength;
|
int chunklength;
|
||||||
int thischunk;
|
int thischunk;
|
||||||
char info[128];
|
char info[128];
|
||||||
|
|
||||||
memfread(&chunk, 4);
|
memfread(&chunk, 4);
|
||||||
memfread(&thischunk, 4);
|
memfread(&thischunk, 4);
|
||||||
memfread(&chunklength, 4);
|
memfread(&chunklength, 4);
|
||||||
|
|
||||||
if ( strcmp(chunk, "CHNK") == 0 )
|
if ( strcmp(chunk, "CHNK") == 0 )
|
||||||
{
|
{
|
||||||
if ( chunkid == thischunk )
|
if ( chunkid == thischunk )
|
||||||
{
|
{
|
||||||
/*** Now decode the array of chunks to this one ***/
|
/*** Now decode the array of chunks to this one ***/
|
||||||
while ( sf->v )
|
while ( sf->v )
|
||||||
{
|
{
|
||||||
memfread(&chunk, 4);
|
memfread(&chunk, 4);
|
||||||
if ( memcmp(&chunk, "CHKE", 4) == 0 )
|
if ( memcmp(&chunk, "CHKE", 4) == 0 )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ( memcmp(&chunk, sf->desc, 4) == 0 )
|
if ( memcmp(&chunk, sf->desc, 4) == 0 )
|
||||||
{
|
{
|
||||||
memfread(&csize, 4);
|
memfread(&csize, 4);
|
||||||
if ( csize == ( sf->s & ( ~RLSB ) ) )
|
if ( csize == ( sf->s & ( ~RLSB ) ) )
|
||||||
{
|
{
|
||||||
memfread( sf->v, csize );
|
memfread( sf->v, csize );
|
||||||
sprintf(info,"%s %d", chunk, csize);
|
sprintf(info,"%s %d", chunk, csize);
|
||||||
} else {
|
} else {
|
||||||
WaitPrompt("Bad chunk link");
|
WaitPrompt("Bad chunk link");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprintf(info, "No Sync %s %s", chunk, sf->desc);
|
sprintf(info, "No Sync %s %s", chunk, sf->desc);
|
||||||
WaitPrompt(info);
|
WaitPrompt(info);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf++;
|
sf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -147,33 +147,33 @@ int GCReadChunk( int chunkid, SFORMAT *sf )
|
|||||||
|
|
||||||
int GCFCEUSS_Load()
|
int GCFCEUSS_Load()
|
||||||
{
|
{
|
||||||
int totalsize = 0;
|
int totalsize = 0;
|
||||||
|
|
||||||
sboffset = 16 + sizeof(saveicon) + 64; /*** Reset memory file pointer ***/
|
sboffset = 16 + sizeof(saveicon) + 64; /*** Reset memory file pointer ***/
|
||||||
|
|
||||||
memcpy(&totalsize, &statebuffer[FILESIZEOFFSET], 4);
|
memcpy(&totalsize, &statebuffer[FILESIZEOFFSET], 4);
|
||||||
|
|
||||||
/*** Now read the chunks back ***/
|
/*** Now read the chunks back ***/
|
||||||
if ( GCReadChunk( 1, SFCPU ) )
|
if ( GCReadChunk( 1, SFCPU ) )
|
||||||
{
|
{
|
||||||
if ( GCReadChunk( 2, SFCPUC ) )
|
if ( GCReadChunk( 2, SFCPUC ) )
|
||||||
{
|
{
|
||||||
if ( GCReadChunk( 3, FCEUPPU_STATEINFO ) )
|
if ( GCReadChunk( 3, FCEUPPU_STATEINFO ) )
|
||||||
{
|
{
|
||||||
if ( GCReadChunk( 4, FCEUCTRL_STATEINFO ) )
|
if ( GCReadChunk( 4, FCEUCTRL_STATEINFO ) )
|
||||||
{
|
{
|
||||||
if ( GCReadChunk( 5, FCEUSND_STATEINFO ) )
|
if ( GCReadChunk( 5, FCEUSND_STATEINFO ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( GCReadChunk( 0x10, SFMDATA ) )
|
if ( GCReadChunk( 0x10, SFMDATA ) )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,46 +184,46 @@ int GCFCEUSS_Load()
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int GCSaveChunk( int chunkid, SFORMAT *sf )
|
int GCSaveChunk( int chunkid, SFORMAT *sf )
|
||||||
{
|
{
|
||||||
int chnkstart;
|
int chnkstart;
|
||||||
int csize = 0;
|
int csize = 0;
|
||||||
int chsize = 0;
|
int chsize = 0;
|
||||||
char chunk[] = "CHNK";
|
char chunk[] = "CHNK";
|
||||||
|
|
||||||
/*** Add chunk marker ***/
|
/*** Add chunk marker ***/
|
||||||
memfwrite(&chunk, 4);
|
memfwrite(&chunk, 4);
|
||||||
memfwrite(&chunkid, 4);
|
memfwrite(&chunkid, 4);
|
||||||
chnkstart = sboffset; /*** Save ptr ***/
|
chnkstart = sboffset; /*** Save ptr ***/
|
||||||
sboffset += 4; /*** Space for length ***/
|
sboffset += 4; /*** Space for length ***/
|
||||||
csize += 12;
|
csize += 12;
|
||||||
|
|
||||||
/*** Now run through this structure ***/
|
/*** Now run through this structure ***/
|
||||||
while (sf->v)
|
while (sf->v)
|
||||||
{
|
{
|
||||||
/*** Check that there is a decription ***/
|
/*** Check that there is a decription ***/
|
||||||
if ( sf->desc == NULL)
|
if ( sf->desc == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*** Write out the description ***/
|
/*** Write out the description ***/
|
||||||
memfwrite( sf->desc, 4);
|
memfwrite( sf->desc, 4);
|
||||||
|
|
||||||
/*** Write the length of this chunk ***/
|
/*** Write the length of this chunk ***/
|
||||||
chsize = ( sf->s & (~RLSB) );
|
chsize = ( sf->s & (~RLSB) );
|
||||||
memfwrite( &chsize, 4);
|
memfwrite( &chsize, 4);
|
||||||
|
|
||||||
if ( chsize > 0 )
|
if ( chsize > 0 )
|
||||||
/*** Write the actual data ***/
|
/*** Write the actual data ***/
|
||||||
memfwrite( sf->v, chsize );
|
memfwrite( sf->v, chsize );
|
||||||
|
|
||||||
csize += 8;
|
csize += 8;
|
||||||
csize += chsize;
|
csize += chsize;
|
||||||
|
|
||||||
sf++;
|
sf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Update CHNK length ***/
|
/*** Update CHNK length ***/
|
||||||
memcpy(&statebuffer[chnkstart], &csize, 4);
|
memcpy(&statebuffer[chnkstart], &csize, 4);
|
||||||
|
|
||||||
return csize;
|
return csize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -235,49 +235,49 @@ int GCSaveChunk( int chunkid, SFORMAT *sf )
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int GCFCEUSS_Save()
|
int GCFCEUSS_Save()
|
||||||
{
|
{
|
||||||
int totalsize = 0;
|
int totalsize = 0;
|
||||||
static unsigned char header[16] = "FCS\xff";
|
static unsigned char header[16] = "FCS\xff";
|
||||||
char chunk[] = "CHKE";
|
char chunk[] = "CHKE";
|
||||||
int zero = 0;
|
int zero = 0;
|
||||||
char Comment[2][32] = { { "FCEU GC Version 1.0.9" }, { "A GAME" } };
|
char Comment[2][32] = { { "FCEU GC Version 1.0.9" }, { "A GAME" } };
|
||||||
|
|
||||||
memopen(); /*** Reset Memory File ***/
|
memopen(); /*** Reset Memory File ***/
|
||||||
|
|
||||||
/*** Add version ID ***/
|
/*** Add version ID ***/
|
||||||
memcpy(&header[8], &mcversion, 4);
|
memcpy(&header[8], &mcversion, 4);
|
||||||
|
|
||||||
/*** Do internal Saving ***/
|
/*** Do internal Saving ***/
|
||||||
FCEUPPU_SaveState();
|
FCEUPPU_SaveState();
|
||||||
FCEUSND_SaveState();
|
FCEUSND_SaveState();
|
||||||
|
|
||||||
/*** Write Icon ***/
|
/*** Write Icon ***/
|
||||||
memfwrite(&saveicon, sizeof(saveicon));
|
memfwrite(&saveicon, sizeof(saveicon));
|
||||||
totalsize += sizeof(saveicon);
|
totalsize += sizeof(saveicon);
|
||||||
|
|
||||||
/*** And Comments ***/
|
/*** And Comments ***/
|
||||||
sprintf(Comment[1], "NES CRC 0x%08x", iNESGameCRC32);
|
sprintf(Comment[1], "NES CRC 0x%08x", iNESGameCRC32);
|
||||||
memfwrite(&Comment[0], 64);
|
memfwrite(&Comment[0], 64);
|
||||||
totalsize += 64;
|
totalsize += 64;
|
||||||
|
|
||||||
/*** Write header ***/
|
/*** Write header ***/
|
||||||
memfwrite(&header, 16);
|
memfwrite(&header, 16);
|
||||||
totalsize += 16;
|
totalsize += 16;
|
||||||
totalsize += GCSaveChunk(1, SFCPU);
|
totalsize += GCSaveChunk(1, SFCPU);
|
||||||
totalsize += GCSaveChunk(2, SFCPUC);
|
totalsize += GCSaveChunk(2, SFCPUC);
|
||||||
totalsize += GCSaveChunk(3, FCEUPPU_STATEINFO);
|
totalsize += GCSaveChunk(3, FCEUPPU_STATEINFO);
|
||||||
totalsize += GCSaveChunk(4, FCEUCTRL_STATEINFO);
|
totalsize += GCSaveChunk(4, FCEUCTRL_STATEINFO);
|
||||||
totalsize += GCSaveChunk(5, FCEUSND_STATEINFO);
|
totalsize += GCSaveChunk(5, FCEUSND_STATEINFO);
|
||||||
totalsize += GCSaveChunk(0x10, SFMDATA);
|
totalsize += GCSaveChunk(0x10, SFMDATA);
|
||||||
|
|
||||||
/*** Add terminating CHNK ***/
|
/*** Add terminating CHNK ***/
|
||||||
memfwrite(&chunk,4);
|
memfwrite(&chunk,4);
|
||||||
memfwrite(&zero,4);
|
memfwrite(&zero,4);
|
||||||
totalsize += 8;
|
totalsize += 8;
|
||||||
|
|
||||||
/*** Update size element ***/
|
/*** Update size element ***/
|
||||||
memcpy(&statebuffer[FILESIZEOFFSET], &totalsize, 4);
|
memcpy(&statebuffer[FILESIZEOFFSET], &totalsize, 4);
|
||||||
|
|
||||||
return totalsize;
|
return totalsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -287,8 +287,8 @@ int GCFCEUSS_Save()
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int CardReady = 0;
|
int CardReady = 0;
|
||||||
void CardRemoved(s32 chn,s32 result) {
|
void CardRemoved(s32 chn,s32 result) {
|
||||||
CARD_Unmount(chn);
|
CARD_Unmount(chn);
|
||||||
CardReady = 0;
|
CardReady = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -296,40 +296,40 @@ void CardRemoved(s32 chn,s32 result) {
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void uselessinquiry()
|
void uselessinquiry()
|
||||||
{
|
{
|
||||||
volatile long *udvd = ( volatile long *)0xCC006000;
|
volatile long *udvd = ( volatile long *)0xCC006000;
|
||||||
|
|
||||||
udvd[0] = 0;
|
udvd[0] = 0;
|
||||||
udvd[1] = 0;
|
udvd[1] = 0;
|
||||||
udvd[2] = 0x12000000;
|
udvd[2] = 0x12000000;
|
||||||
udvd[3] = 0;
|
udvd[3] = 0;
|
||||||
udvd[4] = 0x20;
|
udvd[4] = 0x20;
|
||||||
udvd[5] = 0x80000000;
|
udvd[5] = 0x80000000;
|
||||||
udvd[6] = 0x20;
|
udvd[6] = 0x20;
|
||||||
udvd[7] = 1;
|
udvd[7] = 1;
|
||||||
|
|
||||||
while ( udvd[7] & 1 );
|
while ( udvd[7] & 1 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MountTheCard()
|
int MountTheCard()
|
||||||
{
|
{
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
int CardError;
|
int CardError;
|
||||||
while ( tries < 10 )
|
while ( tries < 10 )
|
||||||
{
|
{
|
||||||
*(unsigned long*)(0xcc006800) |= 1<<13; /*** Disable Encryption ***/
|
*(unsigned long*)(0xcc006800) |= 1<<13; /*** Disable Encryption ***/
|
||||||
uselessinquiry();
|
uselessinquiry();
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
CardError = CARD_Mount(CARDSLOT, SysArea, NULL); /*** Don't need or want a callback ***/
|
CardError = CARD_Mount(CARDSLOT, SysArea, NULL); /*** Don't need or want a callback ***/
|
||||||
if ( CardError == 0 )
|
if ( CardError == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
EXI_ProbeReset();
|
EXI_ProbeReset();
|
||||||
}
|
|
||||||
tries++;
|
|
||||||
}
|
}
|
||||||
|
tries++;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -341,207 +341,207 @@ int MountTheCard()
|
|||||||
void MCManage(int mode, int slot)
|
void MCManage(int mode, int slot)
|
||||||
{
|
{
|
||||||
|
|
||||||
char mcFilename[80];
|
char mcFilename[80];
|
||||||
int CardError;
|
int CardError;
|
||||||
card_dir CardDir;
|
card_dir CardDir;
|
||||||
card_file CardFile;
|
card_file CardFile;
|
||||||
int SectorSize;
|
int SectorSize;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int FileSize;
|
int FileSize;
|
||||||
int actualSize;
|
int actualSize;
|
||||||
int savedBytes=0;
|
int savedBytes=0;
|
||||||
char debug[128];
|
char debug[128];
|
||||||
|
|
||||||
CARDSLOT = slot;
|
CARDSLOT = slot;
|
||||||
/*** Build the file name ***/
|
/*** Build the file name ***/
|
||||||
sprintf(mcFilename, "FCEU-%08x.fcs", iNESGameCRC32);
|
sprintf(mcFilename, "FCEU-%08x.fcs", iNESGameCRC32);
|
||||||
|
|
||||||
/*** Mount the Card ***/
|
/*** Mount the Card ***/
|
||||||
CARD_Init("FCEU", "00");
|
CARD_Init("FCEU", "00");
|
||||||
|
|
||||||
/*** Try for memory card in slot A ***/
|
/*** Try for memory card in slot A ***/
|
||||||
CardError = CARD_Mount(CARDSLOT, SysArea, CardRemoved );
|
CardError = CARD_Mount(CARDSLOT, SysArea, CardRemoved );
|
||||||
|
|
||||||
if ( CardError >= 0 )
|
if ( CardError >= 0 )
|
||||||
{
|
{
|
||||||
/*** Get card sector size ***/
|
/*** Get card sector size ***/
|
||||||
CardError = CARD_GetSectorSize(CARDSLOT, &SectorSize);
|
CardError = CARD_GetSectorSize(CARDSLOT, &SectorSize);
|
||||||
|
|
||||||
switch ( mode ) {
|
switch ( mode ) {
|
||||||
|
|
||||||
case 0 : { /*** Save Game ***/
|
case 0 : { /*** Save Game ***/
|
||||||
/*** Look for this file ***/
|
/*** Look for this file ***/
|
||||||
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
||||||
|
|
||||||
found = 0;
|
found = 0;
|
||||||
|
|
||||||
card_stat CardStatus;
|
card_stat CardStatus;
|
||||||
while ( CardError != CARD_ERROR_NOFILE )
|
while ( CardError != CARD_ERROR_NOFILE )
|
||||||
{
|
{
|
||||||
CardError = CARD_FindNext(&CardDir);
|
CardError = CARD_FindNext(&CardDir);
|
||||||
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Determine number of sectors required ***/
|
/*** Determine number of sectors required ***/
|
||||||
savedBytes = actualSize = GCFCEUSS_Save();
|
savedBytes = actualSize = GCFCEUSS_Save();
|
||||||
sprintf(debug, "Saving in MC ...");
|
sprintf(debug, "Saving in MC ...");
|
||||||
ShowAction(debug);
|
ShowAction(debug);
|
||||||
|
|
||||||
FileSize = ( actualSize / SectorSize ) * SectorSize;
|
FileSize = ( actualSize / SectorSize ) * SectorSize;
|
||||||
if ( actualSize % SectorSize )
|
if ( actualSize % SectorSize )
|
||||||
FileSize += SectorSize;
|
FileSize += SectorSize;
|
||||||
|
|
||||||
/*** Now write the file out ***/
|
/*** Now write the file out ***/
|
||||||
if ( !found )
|
if ( !found )
|
||||||
CardError = CARD_Create(CARDSLOT, mcFilename, FileSize, &CardFile);
|
CardError = CARD_Create(CARDSLOT, mcFilename, FileSize, &CardFile);
|
||||||
else
|
else
|
||||||
CardError = CARD_Open(CARDSLOT, mcFilename, &CardFile);
|
CardError = CARD_Open(CARDSLOT, mcFilename, &CardFile);
|
||||||
|
|
||||||
CARD_GetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
CARD_GetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
||||||
CardStatus.icon_addr = 0;
|
CardStatus.icon_addr = 0;
|
||||||
CardStatus.icon_fmt = 2;
|
CardStatus.icon_fmt = 2;
|
||||||
CardStatus.icon_speed = 1;
|
CardStatus.icon_speed = 1;
|
||||||
CardStatus.comment_addr = sizeof(saveicon);
|
CardStatus.comment_addr = sizeof(saveicon);
|
||||||
CARD_SetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
CARD_SetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
||||||
|
|
||||||
/*** Haha! libogc only write one block at a time! ***/
|
/*** Haha! libogc only write one block at a time! ***/
|
||||||
if ( CardError == 0 )
|
if ( CardError == 0 )
|
||||||
{
|
{
|
||||||
int sbo = 0;
|
int sbo = 0;
|
||||||
while ( actualSize > 0 )
|
while ( actualSize > 0 )
|
||||||
{
|
{
|
||||||
CardError = CARD_Write(&CardFile, &statebuffer[sbo], SectorSize, sbo );
|
CardError = CARD_Write(&CardFile, &statebuffer[sbo], SectorSize, sbo );
|
||||||
actualSize -= SectorSize;
|
actualSize -= SectorSize;
|
||||||
sbo += SectorSize;
|
sbo += SectorSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardError = CARD_Close(&CardFile);
|
CardError = CARD_Close(&CardFile);
|
||||||
sprintf(debug, "Saved %d bytes successfully!", savedBytes);
|
sprintf(debug, "Saved %d bytes successfully!", savedBytes);
|
||||||
WaitPrompt(debug);
|
WaitPrompt(debug);
|
||||||
}
|
}
|
||||||
else WaitPrompt("Save Failed!");
|
else WaitPrompt("Save Failed!");
|
||||||
|
|
||||||
CARD_Unmount(CARDSLOT);
|
CARD_Unmount(CARDSLOT);
|
||||||
|
|
||||||
}
|
}
|
||||||
break; /*** End save ***/
|
break; /*** End save ***/
|
||||||
|
|
||||||
case 1: { /*** Load state ***/
|
case 1: { /*** Load state ***/
|
||||||
/*** Look for this file ***/
|
/*** Look for this file ***/
|
||||||
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
||||||
|
|
||||||
memopen(); /*** Clear the buffer ***/
|
memopen(); /*** Clear the buffer ***/
|
||||||
|
|
||||||
found = 0;
|
found = 0;
|
||||||
|
|
||||||
while ( CardError != CARD_ERROR_NOFILE )
|
while ( CardError != CARD_ERROR_NOFILE )
|
||||||
{
|
{
|
||||||
CardError = CARD_FindNext(&CardDir);
|
CardError = CARD_FindNext(&CardDir);
|
||||||
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( found == 0 )
|
if ( found == 0 )
|
||||||
{
|
{
|
||||||
WaitPrompt("No Save Game Found");
|
WaitPrompt("No Save Game Found");
|
||||||
CARD_Unmount(CARDSLOT);
|
CARD_Unmount(CARDSLOT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Load the file into memory ***/
|
/*** Load the file into memory ***/
|
||||||
CardError = CARD_Open(CARDSLOT, mcFilename, &CardFile);
|
CardError = CARD_Open(CARDSLOT, mcFilename, &CardFile);
|
||||||
CardError = CARD_Read(&CardFile, &statebuffer, SectorSize, 0);
|
CardError = CARD_Read(&CardFile, &statebuffer, SectorSize, 0);
|
||||||
|
|
||||||
/*** Get actual size of the file ***/
|
/*** Get actual size of the file ***/
|
||||||
memcpy(&actualSize, &statebuffer[FILESIZEOFFSET], 4);
|
memcpy(&actualSize, &statebuffer[FILESIZEOFFSET], 4);
|
||||||
savedBytes = actualSize;
|
savedBytes = actualSize;
|
||||||
|
|
||||||
int sbo = SectorSize;
|
int sbo = SectorSize;
|
||||||
actualSize -= SectorSize;
|
actualSize -= SectorSize;
|
||||||
while( actualSize > 0 )
|
while( actualSize > 0 )
|
||||||
{
|
{
|
||||||
CARD_Read(&CardFile, &statebuffer[sbo], SectorSize, sbo);
|
CARD_Read(&CardFile, &statebuffer[sbo], SectorSize, sbo);
|
||||||
actualSize -= SectorSize;
|
actualSize -= SectorSize;
|
||||||
sbo += SectorSize;
|
sbo += SectorSize;
|
||||||
}
|
}
|
||||||
CARD_Close(&CardFile);
|
CARD_Close(&CardFile);
|
||||||
|
|
||||||
/*** Finally, do load ***/
|
/*** Finally, do load ***/
|
||||||
GCFCEUSS_Load();
|
GCFCEUSS_Load();
|
||||||
|
|
||||||
CARD_Unmount(CARDSLOT);
|
CARD_Unmount(CARDSLOT);
|
||||||
sprintf(debug, "Loaded %d bytes successfully!", savedBytes);
|
sprintf(debug, "Loaded %d bytes successfully!", savedBytes);
|
||||||
WaitPrompt(debug);
|
WaitPrompt(debug);
|
||||||
|
|
||||||
}
|
}
|
||||||
break; /*** End load ***/
|
break; /*** End load ***/
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WaitPrompt("Cannot Mount Memory Card!");
|
WaitPrompt("Cannot Mount Memory Card!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SD_Manage(int mode, int slot){
|
void SD_Manage(int mode, int slot){
|
||||||
|
|
||||||
sd_file *handle;
|
sd_file *handle;
|
||||||
char path[1024];
|
char path[1024];
|
||||||
char msg[128];
|
char msg[128];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
//sprintf (filepath, "dev%d:\\%s\\%08x.fcs", slot, SAVEDIR, iNESGameCRC32);
|
//sprintf (filepath, "dev%d:\\%s\\%08x.fcs", slot, SAVEDIR, iNESGameCRC32);
|
||||||
sprintf (path, "dev%d:\\%08x.fcs", slot, iNESGameCRC32);
|
sprintf (path, "dev%d:\\%08x.fcs", slot, iNESGameCRC32);
|
||||||
|
|
||||||
if (mode == 0) ShowAction ("Saving STATE to SD...");
|
if (mode == 0) ShowAction ("Saving STATE to SD...");
|
||||||
else ShowAction ("Loading STATE from SD...");
|
else ShowAction ("Loading STATE from SD...");
|
||||||
|
|
||||||
handle = (mode == 0) ? SDCARD_OpenFile (path, "wb") : SDCARD_OpenFile (path, "rb");
|
handle = (mode == 0) ? SDCARD_OpenFile (path, "wb") : SDCARD_OpenFile (path, "rb");
|
||||||
|
|
||||||
if (handle == NULL){
|
if (handle == NULL){
|
||||||
sprintf(msg, "Couldn't open %s", path);
|
sprintf(msg, "Couldn't open %s", path);
|
||||||
WaitPrompt(msg);
|
WaitPrompt(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == 0){ //Save
|
if (mode == 0){ //Save
|
||||||
filesize = GCFCEUSS_Save();
|
filesize = GCFCEUSS_Save();
|
||||||
|
|
||||||
len = SDCARD_WriteFile (handle, statebuffer, filesize);
|
len = SDCARD_WriteFile (handle, statebuffer, filesize);
|
||||||
SDCARD_CloseFile (handle);
|
SDCARD_CloseFile (handle);
|
||||||
|
|
||||||
if (len != filesize){
|
if (len != filesize){
|
||||||
sprintf (msg, "Error writing %s", path);
|
sprintf (msg, "Error writing %s", path);
|
||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (msg, "Saved %d bytes successfully", filesize);
|
sprintf (msg, "Saved %d bytes successfully", filesize);
|
||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
}
|
}
|
||||||
else{ //Load
|
else{ //Load
|
||||||
|
|
||||||
memopen();
|
memopen();
|
||||||
while ((len = SDCARD_ReadFile (handle, &statebuffer[offset], 1024)) > 0) offset += len;
|
while ((len = SDCARD_ReadFile (handle, &statebuffer[offset], 1024)) > 0) offset += len;
|
||||||
SDCARD_CloseFile (handle);
|
SDCARD_CloseFile (handle);
|
||||||
|
|
||||||
sprintf (msg, "Loaded %d bytes successfully", offset);
|
sprintf (msg, "Loaded %d bytes successfully", offset);
|
||||||
WaitPrompt(msg);
|
WaitPrompt(msg);
|
||||||
|
|
||||||
GCFCEUSS_Load();
|
GCFCEUSS_Load();
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManageState(int mode, int slot, int device){
|
void ManageState(int mode, int slot, int device){
|
||||||
|
|
||||||
if (device == 0){
|
if (device == 0){
|
||||||
MCManage(mode, slot);
|
MCManage(mode, slot);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
SD_Manage(mode, slot);
|
SD_Manage(mode, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,21 +22,21 @@ extern int ConfigScreen();
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void InitialisePads()
|
void InitialisePads()
|
||||||
{
|
{
|
||||||
int attrib = 0;
|
int attrib = 0;
|
||||||
void *InputDPR;
|
void *InputDPR;
|
||||||
|
|
||||||
FCEUI_DisableFourScore(1);
|
FCEUI_DisableFourScore(1);
|
||||||
|
|
||||||
InputDPR = &JSReturn;
|
InputDPR = &JSReturn;
|
||||||
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, attrib);
|
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, attrib);
|
||||||
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, attrib);
|
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, attrib);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short gcpadmap[] = { PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_START, PAD_TRIGGER_Z, PAD_BUTTON_X, PAD_BUTTON_Y,
|
unsigned short gcpadmap[] = { PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_START, PAD_TRIGGER_Z, PAD_BUTTON_X, PAD_BUTTON_Y,
|
||||||
PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT };
|
PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT };
|
||||||
|
|
||||||
unsigned int nespadmap[] = { JOY_A, JOY_B, JOY_START, JOY_SELECT, JOY_A, JOY_B,
|
unsigned int nespadmap[] = { JOY_A, JOY_B, JOY_START, JOY_SELECT, JOY_A, JOY_B,
|
||||||
JOY_UP, JOY_DOWN, JOY_LEFT, JOY_RIGHT };
|
JOY_UP, JOY_DOWN, JOY_LEFT, JOY_RIGHT };
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Convert GC Joystick Readings to JOY
|
* Convert GC Joystick Readings to JOY
|
||||||
@ -45,40 +45,40 @@ int PADTUR = 2;
|
|||||||
|
|
||||||
unsigned char DecodeJoy( unsigned short pp )
|
unsigned char DecodeJoy( unsigned short pp )
|
||||||
{
|
{
|
||||||
unsigned short p = PAD_ButtonsHeld(pp);
|
unsigned short p = PAD_ButtonsHeld(pp);
|
||||||
|
|
||||||
unsigned char J = 0;
|
unsigned char J = 0;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((skipa[pp] == 0) || ((op[pp] & gcpadmap[4]) == 0)) {
|
if ((skipa[pp] == 0) || ((op[pp] & gcpadmap[4]) == 0)) {
|
||||||
nespadmap[4] = JOY_A;
|
nespadmap[4] = JOY_A;
|
||||||
skipa[pp] = PADTUR;
|
skipa[pp] = PADTUR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((skipb[pp] == 0) || ((op[pp] & gcpadmap[5]) == 0)) {
|
if ((skipb[pp] == 0) || ((op[pp] & gcpadmap[5]) == 0)) {
|
||||||
nespadmap[5] = JOY_B;
|
nespadmap[5] = JOY_B;
|
||||||
skipb[pp] = PADTUR;
|
skipb[pp] = PADTUR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
if (p & gcpadmap[i])
|
if (p & gcpadmap[i])
|
||||||
J |= nespadmap[i];
|
J |= nespadmap[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipa[pp] > 0){
|
if (skipa[pp] > 0){
|
||||||
nespadmap[4] = 0;
|
nespadmap[4] = 0;
|
||||||
skipa[pp]--;
|
skipa[pp]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipb[pp] > 0){
|
if (skipb[pp] > 0){
|
||||||
nespadmap[5] = 0;
|
nespadmap[5] = 0;
|
||||||
skipb[pp]--;
|
skipb[pp]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
op[pp] = p;
|
op[pp] = p;
|
||||||
|
|
||||||
return J;
|
return J;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -91,65 +91,65 @@ int PADCAL = 40;
|
|||||||
unsigned char GetAnalog(int Joy)
|
unsigned char GetAnalog(int Joy)
|
||||||
{
|
{
|
||||||
|
|
||||||
signed char x, y;
|
signed char x, y;
|
||||||
unsigned char i = 0;
|
unsigned char i = 0;
|
||||||
|
|
||||||
x = PAD_StickX(Joy);
|
x = PAD_StickX(Joy);
|
||||||
y = PAD_StickY(Joy);
|
y = PAD_StickY(Joy);
|
||||||
|
|
||||||
if (x * x + y * y > PADCAL * PADCAL) {
|
if (x * x + y * y > PADCAL * PADCAL) {
|
||||||
|
|
||||||
if (x > 0 && y == 0) return JOY_RIGHT;
|
if (x > 0 && y == 0) return JOY_RIGHT;
|
||||||
if (x < 0 && y == 0) return JOY_LEFT;
|
if (x < 0 && y == 0) return JOY_LEFT;
|
||||||
if (x == 0 && y > 0) return JOY_UP;
|
if (x == 0 && y > 0) return JOY_UP;
|
||||||
if (x == 0 && y < 0) return JOY_DOWN;
|
if (x == 0 && y < 0) return JOY_DOWN;
|
||||||
|
|
||||||
if ((float)y / x >= -2.41421356237 && (float)y / x < 2.41421356237) {
|
if ((float)y / x >= -2.41421356237 && (float)y / x < 2.41421356237) {
|
||||||
if (x >= 0)
|
if (x >= 0)
|
||||||
i |= JOY_RIGHT;
|
i |= JOY_RIGHT;
|
||||||
else
|
else
|
||||||
i |= JOY_LEFT;
|
i |= JOY_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((float)x / y >= -2.41421356237 && (float)x / y < 2.41421356237) {
|
if ((float)x / y >= -2.41421356237 && (float)x / y < 2.41421356237) {
|
||||||
if (y >= 0)
|
if (y >= 0)
|
||||||
i |= JOY_UP;
|
i |= JOY_UP;
|
||||||
else
|
else
|
||||||
i |= JOY_DOWN;
|
i |= JOY_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetJoy()
|
int GetJoy()
|
||||||
{
|
{
|
||||||
unsigned char pad[4];
|
unsigned char pad[4];
|
||||||
short i;
|
short i;
|
||||||
int t = 0;
|
int t = 0;
|
||||||
|
|
||||||
void (*PSOReload)() = (void(*)())0x80001800;
|
void (*PSOReload)() = (void(*)())0x80001800;
|
||||||
|
|
||||||
/*** Before checking anything else, look for PSOReload ***/
|
/*** Before checking anything else, look for PSOReload ***/
|
||||||
if ( PAD_ButtonsHeld(0) == ( PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_START ) )
|
if ( PAD_ButtonsHeld(0) == ( PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_START ) )
|
||||||
PSOReload();
|
PSOReload();
|
||||||
|
|
||||||
/*** Look for config menu ***/
|
/*** Look for config menu ***/
|
||||||
signed char px;
|
signed char px;
|
||||||
px = PAD_SubStickX (0);
|
px = PAD_SubStickX (0);
|
||||||
if (((px < -PADCAL)) || (PAD_ButtonsHeld(0) == ( PAD_TRIGGER_L | PAD_TRIGGER_R ))) {
|
if (((px < -PADCAL)) || (PAD_ButtonsHeld(0) == ( PAD_TRIGGER_L | PAD_TRIGGER_R ))) {
|
||||||
t = ConfigScreen();
|
t = ConfigScreen();
|
||||||
if (t == 1) {
|
if (t == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
pad[i] = DecodeJoy(i) | GetAnalog(i);
|
pad[i] = DecodeJoy(i) | GetAnalog(i);
|
||||||
|
|
||||||
|
|
||||||
JSReturn = pad[0] | pad[1] << 8 | pad[2] << 16 | pad[3] << 24;
|
JSReturn = pad[0] | pad[1] << 8 | pad[2] << 16 | pad[3] << 24;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,132 +1,132 @@
|
|||||||
unsigned short saveicon[1024] = {
|
unsigned short saveicon[1024] = {
|
||||||
|
|
||||||
0xDAD6, 0xEF7B, 0xE318, 0xCA52, 0xA94A, 0xCA52, 0xF7BD, 0xF7BD,
|
0xDAD6, 0xEF7B, 0xE318, 0xCA52, 0xA94A, 0xCA52, 0xF7BD, 0xF7BD,
|
||||||
0x8C63, 0xA108, 0xCE73, 0xBDEF, 0x8421, 0x8C63, 0x9CE7, 0x8C63,
|
0x8C63, 0xA108, 0xCE73, 0xBDEF, 0x8421, 0x8C63, 0x9CE7, 0x8C63,
|
||||||
0xB5AD, 0xAD6B, 0xA94A, 0xCE71, 0xDEF7, 0xCE73, 0xF7BB, 0xFFFF,
|
0xB5AD, 0xAD6B, 0xA94A, 0xCE71, 0xDEF7, 0xCE73, 0xF7BB, 0xFFFF,
|
||||||
0xA94A, 0xC20F, 0xEB58, 0xFBBB, 0x8421, 0xC1EE, 0xE2F5, 0xDED3,
|
0xA94A, 0xC20F, 0xEB58, 0xFBBB, 0x8421, 0xC1EE, 0xE2F5, 0xDED3,
|
||||||
0xDEF5, 0xDED4, 0xDEF4, 0xDED4, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
0xDEF5, 0xDED4, 0xDEF4, 0xDED4, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
||||||
0xF7BA, 0xF7BA, 0xFBBA, 0xFBBA, 0xDAD4, 0xDED4, 0xDED4, 0xDED4,
|
0xF7BA, 0xF7BA, 0xFBBA, 0xFBBA, 0xDAD4, 0xDED4, 0xDED4, 0xDED4,
|
||||||
0xDAB3, 0xDAB3, 0xDAB3, 0xD6B3, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
0xDAB3, 0xDAB3, 0xDAB3, 0xD6B3, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
||||||
0xFBBA, 0xFBBB, 0xFBBA, 0xFBBA, 0xDED4, 0xDEF4, 0xDED4, 0xCA0E,
|
0xFBBA, 0xFBBB, 0xFBBA, 0xFBBA, 0xDED4, 0xDEF4, 0xDED4, 0xCA0E,
|
||||||
0xD692, 0xD692, 0xD692, 0xD272, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
0xD692, 0xD692, 0xD692, 0xD272, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
||||||
0xFFBB, 0xFFBB, 0xFBBA, 0xFBBA, 0xBD8A, 0xDAB2, 0xE2F4, 0xE2F4,
|
0xFFBB, 0xFFBB, 0xFBBA, 0xFBBA, 0xBD8A, 0xDAB2, 0xE2F4, 0xE2F4,
|
||||||
0xD292, 0xD692, 0xD692, 0xD292, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
0xD292, 0xD692, 0xD692, 0xD292, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
||||||
0xFBBA, 0xF7BA, 0xF798, 0xF799, 0xE2F4, 0xE2F4, 0xDAB2, 0xDAD2,
|
0xFBBA, 0xF7BA, 0xF798, 0xF799, 0xE2F4, 0xE2F4, 0xDAB2, 0xDAD2,
|
||||||
0xD272, 0xCE71, 0xBDEE, 0xA529, 0xFFFF, 0xFFFF, 0xFFFF, 0xDAD4,
|
0xD272, 0xCE71, 0xBDEE, 0xA529, 0xFFFF, 0xFFFF, 0xFFFF, 0xDAD4,
|
||||||
0xFBBA, 0xFBBA, 0xFB99, 0xD270, 0xDED4, 0xDED3, 0xDED3, 0xD670,
|
0xFBBA, 0xFBBA, 0xFB99, 0xD270, 0xDED4, 0xDED3, 0xDED3, 0xD670,
|
||||||
0x98C6, 0x8C63, 0x8421, 0x8000, 0x9CE7, 0x8842, 0x8000, 0x8000,
|
0x98C6, 0x8C63, 0x8421, 0x8000, 0x9CE7, 0x8842, 0x8000, 0x8000,
|
||||||
0x9CE5, 0x8000, 0x8000, 0x8000, 0xA0E5, 0x8000, 0x8000, 0x8000,
|
0x9CE5, 0x8000, 0x8000, 0x8000, 0xA0E5, 0x8000, 0x8000, 0x8000,
|
||||||
0x8421, 0x8842, 0x9084, 0x8421, 0x8000, 0x8421, 0x8C63, 0xB9CC,
|
0x8421, 0x8842, 0x9084, 0x8421, 0x8000, 0x8421, 0x8C63, 0xB9CC,
|
||||||
0x8000, 0x8421, 0xB18B, 0xD6B3, 0x8000, 0x8421, 0xD6B3, 0xE717,
|
0x8000, 0x8421, 0xB18B, 0xD6B3, 0x8000, 0x8421, 0xD6B3, 0xE717,
|
||||||
0xA528, 0xCE71, 0xDED4, 0xDAD3, 0xCE71, 0xE736, 0xE315, 0xE2F5,
|
0xA528, 0xCE71, 0xDED4, 0xDAD3, 0xCE71, 0xE736, 0xE315, 0xE2F5,
|
||||||
0xE316, 0xDAD4, 0xDAD4, 0xDAD4, 0xB18B, 0xA528, 0xA528, 0xA128,
|
0xE316, 0xDAD4, 0xDAD4, 0xDAD4, 0xB18B, 0xA528, 0xA528, 0xA128,
|
||||||
0xDAB3, 0xDED3, 0xDED4, 0xDED4, 0xE2F5, 0xE715, 0xE715, 0xE715,
|
0xDAB3, 0xDED3, 0xDED4, 0xDED4, 0xE2F5, 0xE715, 0xE715, 0xE715,
|
||||||
0xDED4, 0xDED4, 0xDED4, 0xDED4, 0xA107, 0xA507, 0xA528, 0xA528,
|
0xDED4, 0xDED4, 0xDED4, 0xDED4, 0xA107, 0xA507, 0xA528, 0xA528,
|
||||||
0xDED4, 0xDED4, 0xDED4, 0xDEB3, 0xE715, 0xE716, 0xE715, 0xE716,
|
0xDED4, 0xDED4, 0xDED4, 0xDEB3, 0xE715, 0xE716, 0xE715, 0xE716,
|
||||||
0xDED5, 0xDED4, 0xDED5, 0xDEF5, 0xA528, 0xA528, 0xA528, 0xA528,
|
0xDED5, 0xDED4, 0xDED5, 0xDEF5, 0xA528, 0xA528, 0xA528, 0xA528,
|
||||||
0xDA92, 0xDED3, 0xDED3, 0xDAD3, 0xE716, 0xE716, 0xE715, 0xE2F5,
|
0xDA92, 0xDED3, 0xDED3, 0xDAD3, 0xE716, 0xE716, 0xE715, 0xE2F5,
|
||||||
0xDEF5, 0xDEF5, 0xE2F5, 0xE2F5, 0xA528, 0xA528, 0xA528, 0xA528,
|
0xDEF5, 0xDEF5, 0xE2F5, 0xE2F5, 0xA528, 0xA528, 0xA528, 0xA528,
|
||||||
0xDED3, 0xDED3, 0xDAB2, 0xDAB3, 0xE715, 0xE715, 0xE2F4, 0xE2F5,
|
0xDED3, 0xDED3, 0xDAB2, 0xDAB3, 0xE715, 0xE715, 0xE2F4, 0xE2F5,
|
||||||
0xE2F5, 0xE2F5, 0xE315, 0xE315, 0xA528, 0xA528, 0xA528, 0xA528,
|
0xE2F5, 0xE2F5, 0xE315, 0xE315, 0xA528, 0xA528, 0xA528, 0xA528,
|
||||||
0xDED3, 0xDED3, 0xDEB2, 0xDA90, 0xE2F5, 0xE315, 0xE2F4, 0xDEB2,
|
0xDED3, 0xDED3, 0xDEB2, 0xDA90, 0xE2F5, 0xE315, 0xE2F4, 0xDEB2,
|
||||||
0xE316, 0xE716, 0xEB36, 0xEF37, 0xA928, 0xA528, 0xA928, 0xB5AB,
|
0xE316, 0xE716, 0xEB36, 0xEF37, 0xA928, 0xA528, 0xA928, 0xB5AB,
|
||||||
0xA927, 0x8000, 0x8000, 0x8000, 0xB589, 0xB189, 0x8000, 0x8000,
|
0xA927, 0x8000, 0x8000, 0x8000, 0xB589, 0xB189, 0x8000, 0x8000,
|
||||||
0xD670, 0xB9AB, 0x98C4, 0x8000, 0xDED3, 0xD26F, 0xA927, 0x8000,
|
0xD670, 0xB9AB, 0x98C4, 0x8000, 0xDED3, 0xD26F, 0xA927, 0x8000,
|
||||||
0x8000, 0xAD8B, 0xE738, 0xC210, 0x8000, 0xB9CD, 0xF39B, 0xA109,
|
0x8000, 0xAD8B, 0xE738, 0xC210, 0x8000, 0xB9CD, 0xF39B, 0xA109,
|
||||||
0x8000, 0xBE0F, 0xEB5A, 0xA52A, 0x8000, 0xC20F, 0xE739, 0xAD6D,
|
0x8000, 0xBE0F, 0xEB5A, 0xA52A, 0x8000, 0xC20F, 0xE739, 0xAD6D,
|
||||||
0x94A4, 0x9084, 0x9084, 0x9084, 0x8442, 0x8842, 0x8842, 0x9083,
|
0x94A4, 0x9084, 0x9084, 0x9084, 0x8442, 0x8842, 0x8842, 0x9083,
|
||||||
0x8843, 0x8C63, 0x8C62, 0x8841, 0x98E8, 0x94A6, 0x8862, 0x8842,
|
0x8843, 0x8C63, 0x8C62, 0x8841, 0x98E8, 0x94A6, 0x8862, 0x8842,
|
||||||
0x9083, 0x9083, 0x9083, 0x9084, 0x94A5, 0x94A5, 0x94A5, 0x94A4,
|
0x9083, 0x9083, 0x9083, 0x9084, 0x94A5, 0x94A5, 0x94A5, 0x94A4,
|
||||||
0x8862, 0x8862, 0x8842, 0x8842, 0x8842, 0x8841, 0x8421, 0x8421,
|
0x8862, 0x8862, 0x8842, 0x8842, 0x8842, 0x8841, 0x8421, 0x8421,
|
||||||
0x9484, 0x9484, 0x9084, 0x9084, 0x94A4, 0x94A5, 0x94A5, 0x94A5,
|
0x9484, 0x9484, 0x9084, 0x9084, 0x94A4, 0x94A5, 0x94A5, 0x94A5,
|
||||||
0x8862, 0x8862, 0x8C62, 0x8C62, 0x8421, 0x8421, 0x8421, 0x8421,
|
0x8862, 0x8862, 0x8C62, 0x8C62, 0x8421, 0x8421, 0x8421, 0x8421,
|
||||||
0x94A4, 0x9084, 0x94A4, 0x94A4, 0x94A5, 0x94A5, 0x94A5, 0x94A5,
|
0x94A4, 0x9084, 0x94A4, 0x94A4, 0x94A5, 0x94A5, 0x94A5, 0x94A5,
|
||||||
0x8C62, 0x8C62, 0x8C62, 0x8C62, 0x8421, 0x8421, 0x8421, 0x8421,
|
0x8C62, 0x8C62, 0x8C62, 0x8C62, 0x8421, 0x8421, 0x8421, 0x8421,
|
||||||
0x94A4, 0x94A4, 0x94A4, 0x94A4, 0x94A5, 0x94A5, 0x94A5, 0x9083,
|
0x94A4, 0x94A4, 0x94A4, 0x94A4, 0x94A5, 0x94A5, 0x94A5, 0x9083,
|
||||||
0x8C62, 0x8C63, 0x8C63, 0x9484, 0x8421, 0x8421, 0x8421, 0x8841,
|
0x8C62, 0x8C63, 0x8C63, 0x9484, 0x8421, 0x8421, 0x8421, 0x8841,
|
||||||
0x94A4, 0x94A4, 0x94A4, 0x9CE6, 0x8C62, 0x8842, 0x8841, 0x8841,
|
0x94A4, 0x94A4, 0x94A4, 0x9CE6, 0x8C62, 0x8842, 0x8841, 0x8841,
|
||||||
0x9083, 0x8C62, 0x8C63, 0x8841, 0x8C62, 0x8C62, 0x8C62, 0x8421,
|
0x9083, 0x8C62, 0x8C63, 0x8841, 0x8C62, 0x8C62, 0x8C62, 0x8421,
|
||||||
0xB58A, 0xDA91, 0xB58A, 0x8000, 0x94A4, 0xDA91, 0xBDCB, 0x8000,
|
0xB58A, 0xDA91, 0xB58A, 0x8000, 0x94A4, 0xDA91, 0xBDCB, 0x8000,
|
||||||
0x9062, 0xD690, 0xBDCB, 0x8000, 0x8C62, 0xDA91, 0xC5ED, 0x8000,
|
0x9062, 0xD690, 0xBDCB, 0x8000, 0x8C62, 0xDA91, 0xC5ED, 0x8000,
|
||||||
0x8000, 0xBDEF, 0xEB5A, 0x98C7, 0x8000, 0xB9CD, 0xEB5A, 0x90A5,
|
0x8000, 0xBDEF, 0xEB5A, 0x98C7, 0x8000, 0xB9CD, 0xEB5A, 0x90A5,
|
||||||
0x8000, 0xA549, 0xD294, 0x98E7, 0x8000, 0x8421, 0xC651, 0xA128,
|
0x8000, 0xA549, 0xD294, 0x98E7, 0x8000, 0x8421, 0xC651, 0xA128,
|
||||||
0xA96D, 0x9085, 0x8C63, 0x8C63, 0x94A6, 0x8421, 0x9CE7, 0x8C63,
|
0xA96D, 0x9085, 0x8C63, 0x8C63, 0x94A6, 0x8421, 0x9CE7, 0x8C63,
|
||||||
0x8422, 0x8421, 0xA529, 0x94A4, 0x8421, 0x8421, 0x98C5, 0x9083,
|
0x8422, 0x8421, 0xA529, 0x94A4, 0x8421, 0x8421, 0x98C5, 0x9083,
|
||||||
0x8C63, 0x8C63, 0x8C63, 0x8C63, 0x8842, 0x8C62, 0x8C63, 0x9084,
|
0x8C63, 0x8C63, 0x8C63, 0x8C63, 0x8842, 0x8C62, 0x8C63, 0x9084,
|
||||||
0x8842, 0x8C62, 0x9084, 0x8C63, 0x8C42, 0x8C62, 0x8842, 0x8862,
|
0x8842, 0x8C62, 0x9084, 0x8C63, 0x8C42, 0x8C62, 0x8842, 0x8862,
|
||||||
0x8421, 0x8421, 0x8421, 0x8421, 0x8C63, 0x8421, 0x8421, 0x8421,
|
0x8421, 0x8421, 0x8421, 0x8421, 0x8C63, 0x8421, 0x8421, 0x8421,
|
||||||
0x94A4, 0x8842, 0x8421, 0x8421, 0x9D07, 0x8862, 0x8421, 0x8421,
|
0x94A4, 0x8842, 0x8421, 0x8421, 0x9D07, 0x8862, 0x8421, 0x8421,
|
||||||
0x8421, 0x8421, 0x8421, 0x8C63, 0x8421, 0x8421, 0x8421, 0x94A4,
|
0x8421, 0x8421, 0x8421, 0x8C63, 0x8421, 0x8421, 0x8421, 0x94A4,
|
||||||
0x8421, 0x8421, 0x8421, 0xA108, 0x8421, 0x8421, 0x8421, 0xAD6B,
|
0x8421, 0x8421, 0x8421, 0xA108, 0x8421, 0x8421, 0x8421, 0xAD6B,
|
||||||
0x9084, 0x8421, 0x8421, 0x8441, 0x94A4, 0x8421, 0x8421, 0x8421,
|
0x9084, 0x8421, 0x8421, 0x8441, 0x94A4, 0x8421, 0x8421, 0x8421,
|
||||||
0x94A4, 0x8821, 0x8841, 0x8841, 0x9484, 0x8421, 0x8842, 0x8842,
|
0x94A4, 0x8821, 0x8841, 0x8841, 0x9484, 0x8421, 0x8842, 0x8842,
|
||||||
0x8841, 0x8421, 0x8841, 0x8420, 0x9084, 0x9084, 0x8C62, 0x8421,
|
0x8841, 0x8421, 0x8841, 0x8420, 0x9084, 0x9084, 0x8C62, 0x8421,
|
||||||
0x94A4, 0x9CE7, 0x8842, 0x8421, 0x9084, 0x98C5, 0x8841, 0x8421,
|
0x94A4, 0x9CE7, 0x8842, 0x8421, 0x9084, 0x98C5, 0x8841, 0x8421,
|
||||||
0x8C62, 0xDA91, 0xC5ED, 0x8000, 0x9083, 0xDA92, 0xC1ED, 0x8000,
|
0x8C62, 0xDA91, 0xC5ED, 0x8000, 0x9083, 0xDA92, 0xC1ED, 0x8000,
|
||||||
0x94A4, 0xC1ED, 0xAD69, 0x8000, 0x98A5, 0xB5AB, 0x8000, 0x8000,
|
0x94A4, 0xC1ED, 0xAD69, 0x8000, 0x98A5, 0xB5AB, 0x8000, 0x8000,
|
||||||
0x8000, 0x8421, 0xC230, 0xA94A, 0x8000, 0x8421, 0xBE0F, 0xAD6B,
|
0x8000, 0x8421, 0xC230, 0xA94A, 0x8000, 0x8421, 0xBE0F, 0xAD6B,
|
||||||
0x8000, 0x8421, 0xA98B, 0xB5CD, 0x8000, 0x8421, 0x8C63, 0xA149,
|
0x8000, 0x8421, 0xA98B, 0xB5CD, 0x8000, 0x8421, 0x8C63, 0xA149,
|
||||||
0x8421, 0x8421, 0x94A4, 0x90A4, 0x8020, 0x8421, 0x8841, 0x9484,
|
0x8421, 0x8421, 0x94A4, 0x90A4, 0x8020, 0x8421, 0x8841, 0x9484,
|
||||||
0x8862, 0x8421, 0x8420, 0x8821, 0xA128, 0xA129, 0xA549, 0x8883,
|
0x8862, 0x8421, 0x8420, 0x8821, 0xA128, 0xA129, 0xA549, 0x8883,
|
||||||
0x8842, 0x8842, 0x8841, 0x8C63, 0x8C42, 0x8842, 0x8841, 0x9084,
|
0x8842, 0x8842, 0x8841, 0x8C63, 0x8C42, 0x8842, 0x8841, 0x9084,
|
||||||
0x8842, 0x8842, 0x8842, 0x8C63, 0x8441, 0x8421, 0x8421, 0x8842,
|
0x8842, 0x8842, 0x8842, 0x8C63, 0x8441, 0x8421, 0x8421, 0x8842,
|
||||||
0x9CE7, 0x8842, 0x8421, 0x8421, 0x9084, 0x8421, 0x8421, 0x8421,
|
0x9CE7, 0x8842, 0x8421, 0x8421, 0x9084, 0x8421, 0x8421, 0x8421,
|
||||||
0x8842, 0x8422, 0x8421, 0x8421, 0x8421, 0x8822, 0x8822, 0x8421,
|
0x8842, 0x8422, 0x8421, 0x8421, 0x8421, 0x8822, 0x8822, 0x8421,
|
||||||
0x8841, 0x8421, 0x8841, 0x98C5, 0x8441, 0x8421, 0x8441, 0x8C63,
|
0x8841, 0x8421, 0x8841, 0x98C5, 0x8441, 0x8421, 0x8441, 0x8C63,
|
||||||
0x8421, 0x8421, 0x8441, 0x8421, 0x8421, 0x8421, 0x8421, 0x8421,
|
0x8421, 0x8421, 0x8441, 0x8421, 0x8421, 0x8421, 0x8421, 0x8421,
|
||||||
0x94A4, 0x8000, 0x8421, 0x8842, 0x9084, 0x8842, 0x8421, 0x8842,
|
0x94A4, 0x8000, 0x8421, 0x8842, 0x9084, 0x8842, 0x8421, 0x8842,
|
||||||
0x8C42, 0x8C62, 0x8822, 0x8842, 0x8421, 0x8821, 0x8821, 0x8841,
|
0x8C42, 0x8C62, 0x8822, 0x8842, 0x8421, 0x8821, 0x8821, 0x8841,
|
||||||
0x8842, 0x8C63, 0x8841, 0x8021, 0x8C63, 0x9084, 0x8421, 0x8000,
|
0x8842, 0x8C63, 0x8841, 0x8021, 0x8C63, 0x9084, 0x8421, 0x8000,
|
||||||
0x8842, 0x8C43, 0x8421, 0x8000, 0x9484, 0xA0E7, 0x9CC6, 0xB58B,
|
0x8842, 0x8C43, 0x8421, 0x8000, 0x9484, 0xA0E7, 0x9CC6, 0xB58B,
|
||||||
0x9CC5, 0xB5AB, 0x8000, 0x8000, 0xA527, 0xB18A, 0x8000, 0x8000,
|
0x9CC5, 0xB5AB, 0x8000, 0x8000, 0xA527, 0xB18A, 0x8000, 0x8000,
|
||||||
0xB9AB, 0xB18A, 0x8000, 0x8000, 0xDAB3, 0xC1ED, 0xB58A, 0xA106,
|
0xB9AB, 0xB18A, 0x8000, 0x8000, 0xDAB3, 0xC1ED, 0xB58A, 0xA106,
|
||||||
0x8000, 0x8421, 0x8C63, 0x8421, 0x8000, 0x8421, 0x8C63, 0x8421,
|
0x8000, 0x8421, 0x8C63, 0x8421, 0x8000, 0x8421, 0x8C63, 0x8421,
|
||||||
0x8000, 0x8421, 0x8C63, 0x8421, 0x8000, 0x8421, 0x8C63, 0xAD8C,
|
0x8000, 0x8421, 0x8C63, 0x8421, 0x8000, 0x8421, 0x8C63, 0xAD8C,
|
||||||
0x8000, 0x8000, 0x8000, 0x90C5, 0x8000, 0x8000, 0x90A5, 0xA129,
|
0x8000, 0x8000, 0x8000, 0x90C5, 0x8000, 0x8000, 0x90A5, 0xA129,
|
||||||
0x98E7, 0xB5CE, 0xC652, 0xC210, 0xC651, 0xE318, 0xDEF7, 0xCE72,
|
0x98E7, 0xB5CE, 0xC652, 0xC210, 0xC651, 0xE318, 0xDEF7, 0xCE72,
|
||||||
0x94C6, 0xA529, 0xB9CE, 0xC632, 0xCA52, 0xDAD6, 0xDAD6, 0xD6B6,
|
0x94C6, 0xA529, 0xB9CE, 0xC632, 0xCA52, 0xDAD6, 0xDAD6, 0xD6B6,
|
||||||
0xD6B5, 0xD6B6, 0xD6B6, 0xD6B5, 0xC631, 0xD6B6, 0xD6B6, 0xD6B5,
|
0xD6B5, 0xD6B6, 0xD6B6, 0xD6B5, 0xC631, 0xD6B6, 0xD6B6, 0xD6B5,
|
||||||
0xC632, 0xB18D, 0xB16C, 0xA108, 0xEF7C, 0xE73A, 0xD6B6, 0xB5AD,
|
0xC632, 0xB18D, 0xB16C, 0xA108, 0xEF7C, 0xE73A, 0xD6B6, 0xB5AD,
|
||||||
0xEB5A, 0xEF9C, 0xDEF7, 0xD693, 0xE73A, 0xF39D, 0xDAB5, 0xD271,
|
0xEB5A, 0xEF9C, 0xDEF7, 0xD693, 0xE73A, 0xF39D, 0xDAB5, 0xD271,
|
||||||
0x8401, 0xA108, 0xA528, 0xA508, 0x9083, 0xC20F, 0xCA30, 0xCA30,
|
0x8401, 0xA108, 0xA528, 0xA508, 0x9083, 0xC20F, 0xCA30, 0xCA30,
|
||||||
0xC60F, 0xD272, 0xD271, 0xD250, 0xD671, 0xCE2F, 0xD270, 0xD670,
|
0xC60F, 0xD272, 0xD271, 0xD250, 0xD671, 0xCE2F, 0xD270, 0xD670,
|
||||||
0xA929, 0xB16A, 0xBDED, 0xCA2F, 0xD250, 0xCA0E, 0xDA92, 0xDAB2,
|
0xA929, 0xB16A, 0xBDED, 0xCA2F, 0xD250, 0xCA0E, 0xDA92, 0xDAB2,
|
||||||
0xD24F, 0xD24E, 0xD250, 0xCE2E, 0xD670, 0xD66F, 0xD64F, 0xCE2D,
|
0xD24F, 0xD24E, 0xD250, 0xCE2E, 0xD670, 0xD66F, 0xD64F, 0xCE2D,
|
||||||
0xD271, 0xDEB4, 0xDED4, 0xDED4, 0xD670, 0xD24F, 0xDA70, 0xD670,
|
0xD271, 0xDEB4, 0xDED4, 0xDED4, 0xD670, 0xD24F, 0xDA70, 0xD670,
|
||||||
0xD24E, 0xD24E, 0xD24E, 0xD24F, 0xD22E, 0xD24E, 0xD64E, 0xD64E,
|
0xD24E, 0xD24E, 0xD24E, 0xD24F, 0xD22E, 0xD24E, 0xD64E, 0xD64E,
|
||||||
0xDAB2, 0xCE50, 0xCA2E, 0xCA0D, 0xD670, 0xCE2E, 0xC5ED, 0xC5EC,
|
0xDAB2, 0xCE50, 0xCA2E, 0xCA0D, 0xD670, 0xCE2E, 0xC5ED, 0xC5EC,
|
||||||
0xD24F, 0xCE0D, 0xC5EC, 0xC5EC, 0xD24E, 0xCE2D, 0xCA0C, 0xCA0D,
|
0xD24F, 0xCE0D, 0xC5EC, 0xC5EC, 0xD24E, 0xCE2D, 0xCA0C, 0xCA0D,
|
||||||
0x8000, 0x8421, 0xD2B4, 0xDAF7, 0x8000, 0x9D08, 0xE75A, 0xEB7B,
|
0x8000, 0x8421, 0xD2B4, 0xDAF7, 0x8000, 0x9D08, 0xE75A, 0xEB7B,
|
||||||
0x90C6, 0xB5CE, 0xEF7C, 0xF7BD, 0xBE0F, 0xEB39, 0xE739, 0xF39C,
|
0x90C6, 0xB5CE, 0xEF7C, 0xF7BD, 0xBE0F, 0xEB39, 0xE739, 0xF39C,
|
||||||
0xE318, 0xDEF7, 0xDEF7, 0xDEF7, 0xDEF8, 0xE318, 0xDEF8, 0xE2F8,
|
0xE318, 0xDEF7, 0xDEF7, 0xDEF7, 0xDEF8, 0xE318, 0xDEF8, 0xE2F8,
|
||||||
0xE739, 0xE318, 0xE318, 0xE318, 0xF39C, 0xE739, 0xE739, 0xE739,
|
0xE739, 0xE318, 0xE318, 0xE318, 0xF39C, 0xE739, 0xE739, 0xE739,
|
||||||
0xC630, 0xCA52, 0xDAB6, 0xD6B5, 0xDED6, 0xC20F, 0xD293, 0xD6B5,
|
0xC630, 0xCA52, 0xDAB6, 0xD6B5, 0xDED6, 0xC20F, 0xD293, 0xD6B5,
|
||||||
0xE319, 0xDAD6, 0xC630, 0xDEF7, 0xE718, 0xE739, 0xDAB5, 0xD294,
|
0xE319, 0xDAD6, 0xC630, 0xDEF7, 0xE718, 0xE739, 0xDAB5, 0xD294,
|
||||||
0xE739, 0xF39D, 0xE2F7, 0xDAB3, 0xDEF8, 0xF39D, 0xE718, 0xDAD4,
|
0xE739, 0xF39D, 0xE2F7, 0xDAB3, 0xDEF8, 0xF39D, 0xE718, 0xDAD4,
|
||||||
0xDAD6, 0xF39D, 0xE739, 0xDED4, 0xD274, 0xE73A, 0xEB5A, 0xE2F5,
|
0xDAD6, 0xF39D, 0xE739, 0xDED4, 0xD274, 0xE73A, 0xEB5A, 0xE2F5,
|
||||||
0xD270, 0xD670, 0xD671, 0xD691, 0xD670, 0xDA91, 0xDA91, 0xDA91,
|
0xD270, 0xD670, 0xD671, 0xD691, 0xD670, 0xDA91, 0xDA91, 0xDA91,
|
||||||
0xDA91, 0xDEB1, 0xDEB2, 0xE2D2, 0xDEB2, 0xE2D3, 0xE2D3, 0xE2D3,
|
0xDA91, 0xDEB1, 0xDEB2, 0xE2D2, 0xDEB2, 0xE2D3, 0xE2D3, 0xE2D3,
|
||||||
0xDA91, 0xDA91, 0xD66F, 0xD22D, 0xDEB2, 0xDE91, 0xCE2D, 0xD22E,
|
0xDA91, 0xDA91, 0xD66F, 0xD22D, 0xDEB2, 0xDE91, 0xCE2D, 0xD22E,
|
||||||
0xE6D3, 0xE2B2, 0xC9EC, 0xCA0D, 0xE6F3, 0xDA90, 0xCA0D, 0xCA0D,
|
0xE6D3, 0xE2B2, 0xC9EC, 0xCA0D, 0xE6F3, 0xDA90, 0xCA0D, 0xCA0D,
|
||||||
0xD24E, 0xD24E, 0xD64E, 0xD66F, 0xD24E, 0xD64E, 0xD66F, 0xDA70,
|
0xD24E, 0xD24E, 0xD64E, 0xD66F, 0xD24E, 0xD64E, 0xD66F, 0xDA70,
|
||||||
0xD66F, 0xDA70, 0xDA91, 0xDA92, 0xDEB3, 0xDEB3, 0xE2D4, 0xE2D4,
|
0xD66F, 0xDA70, 0xDA91, 0xDA92, 0xDEB3, 0xDEB3, 0xE2D4, 0xE2D4,
|
||||||
0xD64F, 0xCE2E, 0xCE2E, 0xD24F, 0xD670, 0xCE2E, 0xD24F, 0xD670,
|
0xD64F, 0xCE2E, 0xCE2E, 0xD24F, 0xD670, 0xCE2E, 0xD24F, 0xD670,
|
||||||
0xDAB2, 0xD250, 0xCE2E, 0xB148, 0xE2D4, 0xDA92, 0xD24F, 0xB969,
|
0xDAB2, 0xD250, 0xCE2E, 0xB148, 0xE2D4, 0xDA92, 0xD24F, 0xB969,
|
||||||
0xE739, 0xE317, 0xE318, 0xE739, 0xE318, 0xDEF7, 0xDAD6, 0xDAD6,
|
0xE739, 0xE317, 0xE318, 0xE739, 0xE318, 0xDEF7, 0xDAD6, 0xDAD6,
|
||||||
0xDEF7, 0xDAD6, 0xD6B5, 0xD6B4, 0xDEF7, 0xDAD6, 0xD6B4, 0xD294,
|
0xDEF7, 0xDAD6, 0xD6B5, 0xD6B4, 0xDEF7, 0xDAD6, 0xD6B4, 0xD294,
|
||||||
0xF7BD, 0xEB5A, 0xE739, 0xE738, 0xE318, 0xE739, 0xDAD6, 0xDAD6,
|
0xF7BD, 0xEB5A, 0xE739, 0xE738, 0xE318, 0xE739, 0xDAD6, 0xDAD6,
|
||||||
0xD294, 0xDAD6, 0xDAD6, 0xD294, 0xD294, 0xD294, 0xDAD6, 0xD294,
|
0xD294, 0xDAD6, 0xDAD6, 0xD294, 0xD294, 0xD294, 0xDAD6, 0xD294,
|
||||||
0xE738, 0xE739, 0xEB39, 0xD693, 0xDAD6, 0xDAD6, 0xDED6, 0xDAD5,
|
0xE738, 0xE739, 0xEB39, 0xD693, 0xDAD6, 0xDAD6, 0xDED6, 0xDAD5,
|
||||||
0xD294, 0xD294, 0xD294, 0xD694, 0xD273, 0xD293, 0xD273, 0xD273,
|
0xD294, 0xD294, 0xD294, 0xD694, 0xD273, 0xD293, 0xD273, 0xD273,
|
||||||
0xC630, 0xD6B5, 0xE738, 0xE2F5, 0xC630, 0xC631, 0xD6B5, 0xDAB3,
|
0xC630, 0xD6B5, 0xE738, 0xE2F5, 0xC630, 0xC631, 0xD6B5, 0xDAB3,
|
||||||
0xCE72, 0xC1EF, 0xCE72, 0xCA30, 0xD293, 0xC630, 0xC610, 0xD272,
|
0xCE72, 0xC1EF, 0xCE72, 0xCA30, 0xD293, 0xC630, 0xC610, 0xD272,
|
||||||
0xDEB2, 0xE2D3, 0xE2D3, 0xDEB2, 0xD270, 0xD250, 0xCE2F, 0xD24F,
|
0xDEB2, 0xE2D3, 0xE2D3, 0xDEB2, 0xD270, 0xD250, 0xCE2F, 0xD24F,
|
||||||
0xC60E, 0xCA2F, 0xCE50, 0xD271, 0xCE50, 0xCE51, 0xD251, 0xD271,
|
0xC60E, 0xCA2F, 0xCE50, 0xD271, 0xCE50, 0xCE51, 0xD251, 0xD271,
|
||||||
0xD670, 0xDEB2, 0xE2D3, 0xD691, 0xD691, 0xDAB2, 0xD692, 0xD693,
|
0xD670, 0xDEB2, 0xE2D3, 0xD691, 0xD691, 0xDAB2, 0xD692, 0xD693,
|
||||||
0xD271, 0xCE71, 0xD271, 0xD272, 0xD271, 0xD271, 0xD271, 0xD271,
|
0xD271, 0xCE71, 0xD271, 0xD272, 0xD271, 0xD271, 0xD271, 0xD271,
|
||||||
0xE716, 0xE716, 0xE2F5, 0xE716, 0xDAB4, 0xE2F6, 0xDAB4, 0xDEB4,
|
0xE716, 0xE716, 0xE2F5, 0xE716, 0xDAB4, 0xE2F6, 0xDAB4, 0xDEB4,
|
||||||
0xD272, 0xDAB4, 0xDAB3, 0xD271, 0xD672, 0xD692, 0xDAB4, 0xD250,
|
0xD272, 0xDAB4, 0xDAB3, 0xD271, 0xD672, 0xD692, 0xDAB4, 0xD250,
|
||||||
0xE6F6, 0xDEB3, 0xD670, 0xD24F, 0xDEB3, 0xD691, 0xD670, 0xD670,
|
0xE6F6, 0xDEB3, 0xD670, 0xD24F, 0xDEB3, 0xD691, 0xD670, 0xD670,
|
||||||
0xD270, 0xD270, 0xD250, 0xD671, 0xCE4F, 0xCE4F, 0xCE2F, 0xD24F,
|
0xD270, 0xD270, 0xD250, 0xD671, 0xCE4F, 0xCE4F, 0xCE2F, 0xD24F,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
// 7zip error list
|
// 7zip error list
|
||||||
char szerrormsg[][30] = {"7z: Data error",
|
char szerrormsg[][30] = {"7z: Data error",
|
||||||
"7z: Out of memory",
|
"7z: Out of memory",
|
||||||
"7z: CRC Error",
|
"7z: CRC Error",
|
||||||
"7z: Not implemented",
|
"7z: Not implemented",
|
||||||
"7z: Fail",
|
"7z: Fail",
|
||||||
"7z: Archive error"};
|
"7z: Archive error"};
|
||||||
|
|
||||||
|
|
||||||
SZ_RESULT SzRes;
|
SZ_RESULT SzRes;
|
||||||
@ -55,180 +55,180 @@ u64 dvdsf_last_length = 0;
|
|||||||
|
|
||||||
int dvd_buffered_read(void *dst, u32 len, u64 offset)
|
int dvd_buffered_read(void *dst, u32 len, u64 offset)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
// only read data if the data inside dvdsf_buffer cannot be used
|
// only read data if the data inside dvdsf_buffer cannot be used
|
||||||
if(offset != dvdsf_last_offset || len > dvdsf_last_length)
|
if(offset != dvdsf_last_offset || len > dvdsf_last_length)
|
||||||
{
|
{
|
||||||
memset(&dvdsf_buffer, '\0', DVD_SECTOR_SIZE);
|
memset(&dvdsf_buffer, '\0', DVD_SECTOR_SIZE);
|
||||||
ret = dvd_read(&dvdsf_buffer, len, offset);
|
ret = dvd_read(&dvdsf_buffer, len, offset);
|
||||||
dvdsf_last_offset = offset;
|
dvdsf_last_offset = offset;
|
||||||
dvdsf_last_length = len;
|
dvdsf_last_length = len;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dst, &dvdsf_buffer, len);
|
memcpy(dst, &dvdsf_buffer, len);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dvd_safe_read(void *dst_v, u32 len, u64 offset)
|
int dvd_safe_read(void *dst_v, u32 len, u64 offset)
|
||||||
{
|
{
|
||||||
unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector
|
unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector
|
||||||
|
|
||||||
// if read size and length are a multiply of DVD_(OFFSET,LENGTH)_MULTIPLY and length < DVD_MAX_READ_LENGTH
|
// if read size and length are a multiply of DVD_(OFFSET,LENGTH)_MULTIPLY and length < DVD_MAX_READ_LENGTH
|
||||||
// we don't need to fix anything
|
// we don't need to fix anything
|
||||||
if(len % DVD_LENGTH_MULTIPLY == 0 && offset % DVD_OFFSET_MULTIPLY == 0 && len <= DVD_MAX_READ_LENGTH)
|
if(len % DVD_LENGTH_MULTIPLY == 0 && offset % DVD_OFFSET_MULTIPLY == 0 && len <= DVD_MAX_READ_LENGTH)
|
||||||
{
|
{
|
||||||
int ret = dvd_buffered_read(buffer, len, offset);
|
int ret = dvd_buffered_read(buffer, len, offset);
|
||||||
memcpy(dst_v, &buffer, len);
|
memcpy(dst_v, &buffer, len);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no errors yet -> ret = 0
|
// no errors yet -> ret = 0
|
||||||
// the return value of dvd_read will be OR'd with ret
|
// the return value of dvd_read will be OR'd with ret
|
||||||
// because dvd_read does return 1 on error and 0 on success and
|
// because dvd_read does return 1 on error and 0 on success and
|
||||||
// because 0 | 1 = 1 ret will also contain 1 if at least one error
|
// because 0 | 1 = 1 ret will also contain 1 if at least one error
|
||||||
// occured and 0 otherwise ;)
|
// occured and 0 otherwise ;)
|
||||||
int ret = 0; // return value of dvd_read
|
int ret = 0; // return value of dvd_read
|
||||||
|
|
||||||
// we might need to fix all 3 issues
|
// we might need to fix all 3 issues
|
||||||
unsigned char *dst = (unsigned char *)dst_v; // gcc will not allow to use var[num] on void* types
|
unsigned char *dst = (unsigned char *)dst_v; // gcc will not allow to use var[num] on void* types
|
||||||
u64 bytesToRead; // the number of bytes we still need to read & copy to the output buffer
|
u64 bytesToRead; // the number of bytes we still need to read & copy to the output buffer
|
||||||
u64 currentOffset; // the current dvd offset
|
u64 currentOffset; // the current dvd offset
|
||||||
u64 bufferOffset; // the current buffer offset
|
u64 bufferOffset; // the current buffer offset
|
||||||
u64 i, j, k; // temporary variables which might be used for different stuff
|
u64 i, j, k; // temporary variables which might be used for different stuff
|
||||||
// unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector
|
// unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector
|
||||||
|
|
||||||
currentOffset = offset;
|
currentOffset = offset;
|
||||||
bytesToRead = len;
|
bytesToRead = len;
|
||||||
bufferOffset = 0;
|
bufferOffset = 0;
|
||||||
|
|
||||||
// fix first issue (offset is not a multiply of 32)
|
// fix first issue (offset is not a multiply of 32)
|
||||||
if(offset % DVD_OFFSET_MULTIPLY)
|
if(offset % DVD_OFFSET_MULTIPLY)
|
||||||
{
|
{
|
||||||
// calcualte offset of the prior 32 byte position
|
// calcualte offset of the prior 32 byte position
|
||||||
i = currentOffset - (currentOffset % DVD_OFFSET_MULTIPLY);
|
i = currentOffset - (currentOffset % DVD_OFFSET_MULTIPLY);
|
||||||
|
|
||||||
// calculate the offset from which the data of the dvd buffer will be copied
|
// calculate the offset from which the data of the dvd buffer will be copied
|
||||||
j = currentOffset % DVD_OFFSET_MULTIPLY;
|
j = currentOffset % DVD_OFFSET_MULTIPLY;
|
||||||
|
|
||||||
// calculate the number of bytes needed to reach the next DVD_OFFSET_MULTIPLY byte mark
|
// calculate the number of bytes needed to reach the next DVD_OFFSET_MULTIPLY byte mark
|
||||||
k = DVD_OFFSET_MULTIPLY - j;
|
k = DVD_OFFSET_MULTIPLY - j;
|
||||||
|
|
||||||
// maybe we'll only need to copy a few bytes and we therefore don't even reach the next sector
|
// maybe we'll only need to copy a few bytes and we therefore don't even reach the next sector
|
||||||
if(k > len)
|
if(k > len)
|
||||||
{
|
{
|
||||||
k = len;
|
k = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read 32 bytes from the last 32 byte position
|
// read 32 bytes from the last 32 byte position
|
||||||
ret |= dvd_buffered_read(buffer, DVD_OFFSET_MULTIPLY, i);
|
ret |= dvd_buffered_read(buffer, DVD_OFFSET_MULTIPLY, i);
|
||||||
|
|
||||||
// copy the bytes to the output buffer and update currentOffset, bufferOffset and bytesToRead
|
// copy the bytes to the output buffer and update currentOffset, bufferOffset and bytesToRead
|
||||||
memcpy(&dst[bufferOffset], &buffer[j], k);
|
memcpy(&dst[bufferOffset], &buffer[j], k);
|
||||||
currentOffset += k;
|
currentOffset += k;
|
||||||
bufferOffset += k;
|
bufferOffset += k;
|
||||||
bytesToRead -= k;
|
bytesToRead -= k;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix second issue (more than 2048 bytes are needed)
|
// fix second issue (more than 2048 bytes are needed)
|
||||||
if(bytesToRead > DVD_MAX_READ_LENGTH)
|
if(bytesToRead > DVD_MAX_READ_LENGTH)
|
||||||
{
|
{
|
||||||
// calculate the number of 2048 bytes sector needed to get all data
|
// calculate the number of 2048 bytes sector needed to get all data
|
||||||
i = (bytesToRead - (bytesToRead % DVD_MAX_READ_LENGTH)) / DVD_MAX_READ_LENGTH;
|
i = (bytesToRead - (bytesToRead % DVD_MAX_READ_LENGTH)) / DVD_MAX_READ_LENGTH;
|
||||||
|
|
||||||
// read data in 2048 byte sector
|
// read data in 2048 byte sector
|
||||||
for(j = 0; j < i; j++)
|
for(j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read sector
|
ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read sector
|
||||||
memcpy(&dst[bufferOffset], buffer, DVD_MAX_READ_LENGTH); // copy to output buffer
|
memcpy(&dst[bufferOffset], buffer, DVD_MAX_READ_LENGTH); // copy to output buffer
|
||||||
|
|
||||||
// update currentOffset, bufferOffset and bytesToRead
|
// update currentOffset, bufferOffset and bytesToRead
|
||||||
currentOffset += DVD_MAX_READ_LENGTH;
|
currentOffset += DVD_MAX_READ_LENGTH;
|
||||||
bufferOffset += DVD_MAX_READ_LENGTH;
|
bufferOffset += DVD_MAX_READ_LENGTH;
|
||||||
bytesToRead -= DVD_MAX_READ_LENGTH;
|
bytesToRead -= DVD_MAX_READ_LENGTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix third issue (length is not a multiply of 32)
|
// fix third issue (length is not a multiply of 32)
|
||||||
if(bytesToRead)
|
if(bytesToRead)
|
||||||
{
|
{
|
||||||
ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read 32 byte from the dvd
|
ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read 32 byte from the dvd
|
||||||
memcpy(&dst[bufferOffset], buffer, bytesToRead); // copy bytes to output buffer
|
memcpy(&dst[bufferOffset], buffer, bytesToRead); // copy bytes to output buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
//free(tmp);
|
//free(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// function used by the 7zip SDK to read data from the DVD (fread)
|
// function used by the 7zip SDK to read data from the DVD (fread)
|
||||||
SZ_RESULT SzDvdFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize)
|
SZ_RESULT SzDvdFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize)
|
||||||
{
|
{
|
||||||
// the void* object is a SzFileInStream
|
// the void* object is a SzFileInStream
|
||||||
SzFileInStream *s = (SzFileInStream *)object;
|
SzFileInStream *s = (SzFileInStream *)object;
|
||||||
|
|
||||||
// calculate dvd sector offset
|
// calculate dvd sector offset
|
||||||
u64 offset = (u64)(s->offset + s->pos);
|
u64 offset = (u64)(s->offset + s->pos);
|
||||||
|
|
||||||
if(maxRequiredSize > 2048)
|
if(maxRequiredSize > 2048)
|
||||||
{
|
{
|
||||||
maxRequiredSize = 2048;
|
maxRequiredSize = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read data
|
// read data
|
||||||
dvd_safe_read(sz_buffer, maxRequiredSize, offset);
|
dvd_safe_read(sz_buffer, maxRequiredSize, offset);
|
||||||
*buffer = sz_buffer;
|
*buffer = sz_buffer;
|
||||||
*processedSize = maxRequiredSize;
|
*processedSize = maxRequiredSize;
|
||||||
s->pos += *processedSize;
|
s->pos += *processedSize;
|
||||||
|
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function used by the 7zip SDK to change the filepointer (fseek(object, pos, SEEK_SET))
|
// function used by the 7zip SDK to change the filepointer (fseek(object, pos, SEEK_SET))
|
||||||
SZ_RESULT SzDvdFileSeekImp(void *object, CFileSize pos)
|
SZ_RESULT SzDvdFileSeekImp(void *object, CFileSize pos)
|
||||||
{
|
{
|
||||||
// the void* object is a SzFileInStream
|
// the void* object is a SzFileInStream
|
||||||
SzFileInStream *s = (SzFileInStream *)object;
|
SzFileInStream *s = (SzFileInStream *)object;
|
||||||
|
|
||||||
// check if the 7z SDK wants to move the pointer to somewhere after the EOF
|
// check if the 7z SDK wants to move the pointer to somewhere after the EOF
|
||||||
if(pos >= s->len)
|
if(pos >= s->len)
|
||||||
{
|
{
|
||||||
WaitPrompt("7z Error: The 7z SDK wants to start reading somewhere behind the EOF...");
|
WaitPrompt("7z Error: The 7z SDK wants to start reading somewhere behind the EOF...");
|
||||||
return SZE_FAIL;
|
return SZE_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save new position and return
|
// save new position and return
|
||||||
s->pos = pos;
|
s->pos = pos;
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SZ_RESULT SzDvdIsArchive(u64 dvd_offset)
|
SZ_RESULT SzDvdIsArchive(u64 dvd_offset)
|
||||||
{
|
{
|
||||||
// 7z signautre
|
// 7z signautre
|
||||||
static Byte Signature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
static Byte Signature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||||
Byte Candidate[6];
|
Byte Candidate[6];
|
||||||
|
|
||||||
// read the data from the DVD
|
// read the data from the DVD
|
||||||
dvd_safe_read (&Candidate, 6, dvd_offset);
|
dvd_safe_read (&Candidate, 6, dvd_offset);
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for(i = 0; i < 6; i++)
|
for(i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
if(Candidate[i] != Signature[i])
|
if(Candidate[i] != Signature[i])
|
||||||
{
|
{
|
||||||
return SZE_FAIL;
|
return SZE_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// display an error message
|
// display an error message
|
||||||
void SzDisplayError(SZ_RESULT res)
|
void SzDisplayError(SZ_RESULT res)
|
||||||
{
|
{
|
||||||
WaitPrompt(szerrormsg[(res - 1)]);
|
WaitPrompt(szerrormsg[(res - 1)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 rootdir;
|
static u64 rootdir;
|
||||||
@ -236,119 +236,119 @@ static int rootdirlength;
|
|||||||
|
|
||||||
void SzParse(void)
|
void SzParse(void)
|
||||||
{
|
{
|
||||||
// save the offset and the length of this file inside the archive stream structure
|
// save the offset and the length of this file inside the archive stream structure
|
||||||
SzArchiveStream.offset = filelist[selection].offset;
|
SzArchiveStream.offset = filelist[selection].offset;
|
||||||
SzArchiveStream.len = filelist[selection].length;
|
SzArchiveStream.len = filelist[selection].length;
|
||||||
SzArchiveStream.pos = 0;
|
SzArchiveStream.pos = 0;
|
||||||
|
|
||||||
// set handler functions for reading data from DVD and setting the position
|
// set handler functions for reading data from DVD and setting the position
|
||||||
SzArchiveStream.InStream.Read = SzDvdFileReadImp;
|
SzArchiveStream.InStream.Read = SzDvdFileReadImp;
|
||||||
SzArchiveStream.InStream.Seek = SzDvdFileSeekImp;
|
SzArchiveStream.InStream.Seek = SzDvdFileSeekImp;
|
||||||
|
|
||||||
// set default 7Zip SDK handlers for allocation and freeing memory
|
// set default 7Zip SDK handlers for allocation and freeing memory
|
||||||
SzAllocImp.Alloc = SzAlloc;
|
SzAllocImp.Alloc = SzAlloc;
|
||||||
SzAllocImp.Free = SzFree;
|
SzAllocImp.Free = SzFree;
|
||||||
SzAllocTempImp.Alloc = SzAllocTemp;
|
SzAllocTempImp.Alloc = SzAllocTemp;
|
||||||
SzAllocTempImp.Free = SzFreeTemp;
|
SzAllocTempImp.Free = SzFreeTemp;
|
||||||
|
|
||||||
// prepare CRC and 7Zip database structures
|
// prepare CRC and 7Zip database structures
|
||||||
InitCrcTable();
|
InitCrcTable();
|
||||||
SzArDbExInit(&SzDb);
|
SzArDbExInit(&SzDb);
|
||||||
|
|
||||||
// open the archive
|
// open the archive
|
||||||
SzRes = SzArchiveOpen(&SzArchiveStream.InStream, &SzDb, &SzAllocImp, &SzAllocTempImp);
|
SzRes = SzArchiveOpen(&SzArchiveStream.InStream, &SzDb, &SzAllocImp, &SzAllocTempImp);
|
||||||
|
|
||||||
if(SzRes != SZ_OK)
|
if(SzRes != SZ_OK)
|
||||||
{
|
{
|
||||||
// free memory used by the 7z SDK
|
// free memory used by the 7z SDK
|
||||||
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// archive opened successfully
|
// archive opened successfully
|
||||||
|
|
||||||
// erase all previous entries
|
// erase all previous entries
|
||||||
memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES);
|
memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES);
|
||||||
|
|
||||||
// add '../' folder
|
// add '../' folder
|
||||||
strncpy(filelist[0].filename, "../", 3);
|
strncpy(filelist[0].filename, "../", 3);
|
||||||
filelist[0].length = rootdirlength; // store rootdir in case the user wants to go one folder up
|
filelist[0].length = rootdirlength; // store rootdir in case the user wants to go one folder up
|
||||||
filelist[0].offset = rootdir; // -''- rootdir length -''-
|
filelist[0].offset = rootdir; // -''- rootdir length -''-
|
||||||
filelist[0].flags = 0;
|
filelist[0].flags = 0;
|
||||||
|
|
||||||
// get contents and parse them into the dvd file list structure
|
// get contents and parse them into the dvd file list structure
|
||||||
unsigned int SzI, SzJ;
|
unsigned int SzI, SzJ;
|
||||||
SzJ = 1;
|
SzJ = 1;
|
||||||
for(SzI = 0; SzI < SzDb.Database.NumFiles; SzI++)
|
for(SzI = 0; SzI < SzDb.Database.NumFiles; SzI++)
|
||||||
{
|
{
|
||||||
SzF = SzDb.Database.Files + SzI;
|
SzF = SzDb.Database.Files + SzI;
|
||||||
|
|
||||||
// skip directories
|
// skip directories
|
||||||
if(SzF->IsDirectory)
|
if(SzF->IsDirectory)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not exceed MAXFILES to avoid possible buffer overflows
|
// do not exceed MAXFILES to avoid possible buffer overflows
|
||||||
if(SzJ == (MAXFILES - 1))
|
if(SzJ == (MAXFILES - 1))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse information about this file to the dvd file list structure
|
// parse information about this file to the dvd file list structure
|
||||||
strncpy(filelist[SzJ].filename, SzF->Name, MAXJOLIET); // copy joliet name (useless...)
|
strncpy(filelist[SzJ].filename, SzF->Name, MAXJOLIET); // copy joliet name (useless...)
|
||||||
filelist[SzJ].filename[MAXJOLIET] = 0; // terminate string
|
filelist[SzJ].filename[MAXJOLIET] = 0; // terminate string
|
||||||
filelist[SzJ].length = SzF->Size; // filesize
|
filelist[SzJ].length = SzF->Size; // filesize
|
||||||
filelist[SzJ].offset = SzI; // the extraction function identifies the file with this number
|
filelist[SzJ].offset = SzI; // the extraction function identifies the file with this number
|
||||||
filelist[SzJ].flags = 0; // only files will be displayed (-> no flags)
|
filelist[SzJ].flags = 0; // only files will be displayed (-> no flags)
|
||||||
SzJ++;
|
SzJ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update maxfiles and select the first entry
|
// update maxfiles and select the first entry
|
||||||
maxfiles = SzJ;
|
maxfiles = SzJ;
|
||||||
offset = selection = 0;
|
offset = selection = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SzClose(void)
|
void SzClose(void)
|
||||||
{
|
{
|
||||||
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SzExtractROM(int i, unsigned char *buffer)
|
bool SzExtractROM(int i, unsigned char *buffer)
|
||||||
{
|
{
|
||||||
|
|
||||||
// prepare some variables
|
// prepare some variables
|
||||||
SzBlockIndex = 0xFFFFFFFF;
|
SzBlockIndex = 0xFFFFFFFF;
|
||||||
SzOffset = 0;
|
SzOffset = 0;
|
||||||
|
|
||||||
// Unzip the file
|
// Unzip the file
|
||||||
ShowAction("Un7zipping file. Please wait...");
|
ShowAction("Un7zipping file. Please wait...");
|
||||||
SzRes = SzExtract2(
|
SzRes = SzExtract2(
|
||||||
&SzArchiveStream.InStream,
|
&SzArchiveStream.InStream,
|
||||||
&SzDb,
|
&SzDb,
|
||||||
i, /* index of file */
|
i, /* index of file */
|
||||||
&SzBlockIndex, /* index of solid block */
|
&SzBlockIndex, /* index of solid block */
|
||||||
&buffer,
|
&buffer,
|
||||||
&SzBufferSize,
|
&SzBufferSize,
|
||||||
&SzOffset, /* offset of stream for required file in *outBuffer */
|
&SzOffset, /* offset of stream for required file in *outBuffer */
|
||||||
&SzOutSizeProcessed, /* size of file in *outBuffer */
|
&SzOutSizeProcessed, /* size of file in *outBuffer */
|
||||||
&SzAllocImp,
|
&SzAllocImp,
|
||||||
&SzAllocTempImp);
|
&SzAllocTempImp);
|
||||||
|
|
||||||
// check for errors
|
// check for errors
|
||||||
if(SzRes != SZ_OK)
|
if(SzRes != SZ_OK)
|
||||||
{
|
{
|
||||||
// display error message
|
// display error message
|
||||||
WaitPrompt(szerrormsg[(SzRes - 1)]);
|
WaitPrompt(szerrormsg[(SzRes - 1)]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// close 7Zip archive and free memory
|
// close 7Zip archive and free memory
|
||||||
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
typedef struct _SzFileInStream
|
typedef struct _SzFileInStream
|
||||||
{
|
{
|
||||||
ISzInStream InStream;
|
ISzInStream InStream;
|
||||||
u64 offset; // offset of the file
|
u64 offset; // offset of the file
|
||||||
unsigned int len; // length of the file
|
unsigned int len; // length of the file
|
||||||
u64 pos; // current position of the file pointer
|
u64 pos; // current position of the file pointer
|
||||||
} SzFileInStream;
|
} SzFileInStream;
|
||||||
|
|
||||||
extern SZ_RESULT SzRes;
|
extern SZ_RESULT SzRes;
|
||||||
|
Loading…
Reference in New Issue
Block a user