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