diff --git a/source/drivers/gamecube/audio.c b/source/drivers/gamecube/audio.c index c7f77c8..f30a477 100644 --- a/source/drivers/gamecube/audio.c +++ b/source/drivers/gamecube/audio.c @@ -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; } diff --git a/source/drivers/gamecube/dvdcode.c b/source/drivers/gamecube/dvdcode.c index daaeca4..8e8b8ea 100644 --- a/source/drivers/gamecube/dvdcode.c +++ b/source/drivers/gamecube/dvdcode.c @@ -6,160 +6,160 @@ * * http://www.ninjamod.com ****************************************************************************/ - + #include 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 ); - } diff --git a/source/drivers/gamecube/gcdvd.c b/source/drivers/gamecube/gcdvd.c index 1bfbbab..315e551 100644 --- a/source/drivers/gamecube/gcdvd.c +++ b/source/drivers/gamecube/gcdvd.c @@ -17,7 +17,7 @@ #include "gcdvd.h" /*** Simplified Directory Entry Record - I only care about a couple of values ***/ + I only care about a couple of values ***/ #define RECLEN 0 #define EXTENT 6 #define FILE_LENGTH 14 @@ -48,9 +48,9 @@ extern int IsXenoGCImage( char *buffer ); void GetSDInfo (); extern int choosenSDSlot; /*extern void ClearScreen(); -int LoadDVDFile( unsigned char *buffer ); -extern int unzipDVDFile( unsigned char *outbuffer, unsigned int discoffset, unsigned int length); -extern int CentreTextPosition( char *text );*/ + int LoadDVDFile( unsigned char *buffer ); + extern int unzipDVDFile( unsigned char *outbuffer, unsigned int discoffset, unsigned int length); + extern int CentreTextPosition( char *text );*/ /** true if we the emulator is running on a wii **/ bool isWii = false; @@ -71,17 +71,17 @@ int sdslot = 0; void dvd_inquiry() { - dvd[0] = 0x2e; - dvd[1] = 0; - dvd[2] = 0x12000000; - dvd[3] = 0; - dvd[4] = 0x20; - dvd[5] = 0x80000000; - dvd[6] = 0x20; - dvd[7] = 3; + dvd[0] = 0x2e; + dvd[1] = 0; + dvd[2] = 0x12000000; + dvd[3] = 0; + dvd[4] = 0x20; + dvd[5] = 0x80000000; + dvd[6] = 0x20; + dvd[7] = 3; - while( dvd[7] & 1 ); - DCFlushRange((void *)0x80000000, 32); + while( dvd[7] & 1 ); + DCFlushRange((void *)0x80000000, 32); } void dvd_unlock() @@ -104,16 +104,16 @@ void dvd_unlock() void dvd_extension() { - dvd[0] = 0x2E; - dvd[1] = 0; + dvd[0] = 0x2E; + dvd[1] = 0; - dvd[2] = 0x55010000; - dvd[3] = 0; - dvd[4] = 0; - dvd[5] = 0; - dvd[6] = 0; - dvd[7] = 1; // enable reading! - while (dvd[7] & 1); + dvd[2] = 0x55010000; + dvd[3] = 0; + dvd[4] = 0; + dvd[5] = 0; + dvd[6] = 0; + dvd[7] = 1; // enable reading! + while (dvd[7] & 1); } #define DEBUG_STOP_DRIVE 0 @@ -124,69 +124,69 @@ void dvd_extension() void dvd_motor_on_extra() { - dvd[0] = 0x2e; - dvd[1] = 0; - dvd[2] = 0xfe110000 | DEBUG_START_DRIVE | DEBUG_ACCEPT_COPY | DEBUG_DISC_CHECK; - dvd[3] = 0; - dvd[4] = 0; - dvd[5] = 0; - dvd[6] = 0; - dvd[7] = 1; - while ( dvd[7] & 1 ); + dvd[0] = 0x2e; + dvd[1] = 0; + dvd[2] = 0xfe110000 | DEBUG_START_DRIVE | DEBUG_ACCEPT_COPY | DEBUG_DISC_CHECK; + dvd[3] = 0; + dvd[4] = 0; + dvd[5] = 0; + dvd[6] = 0; + dvd[7] = 1; + while ( dvd[7] & 1 ); } void dvd_motor_off( ) { - dvd[0] = 0x2e; - dvd[1] = 0; - dvd[2] = 0xe3000000; - dvd[3] = 0; - dvd[4] = 0; - dvd[5] = 0; - dvd[6] = 0; - dvd[7] = 1; // Do immediate - while (dvd[7] & 1); + dvd[0] = 0x2e; + dvd[1] = 0; + dvd[2] = 0xe3000000; + dvd[3] = 0; + dvd[4] = 0; + dvd[5] = 0; + dvd[6] = 0; + dvd[7] = 1; // Do immediate + while (dvd[7] & 1); - /*** PSO Stops blackscreen at reload ***/ - dvd[0] = 0x14; - dvd[1] = 0; + /*** PSO Stops blackscreen at reload ***/ + dvd[0] = 0x14; + dvd[1] = 0; } void dvd_setstatus() { - dvd[0] = 0x2E; - dvd[1] = 0; + dvd[0] = 0x2E; + dvd[1] = 0; - dvd[2] = 0xee060300; - dvd[3] = 0; - dvd[4] = 0; - dvd[5] = 0; - dvd[6] = 0; - dvd[7] = 1; // enable reading! - while (dvd[7] & 1); + dvd[2] = 0xee060300; + dvd[3] = 0; + dvd[4] = 0; + dvd[5] = 0; + dvd[6] = 0; + dvd[7] = 1; // enable reading! + while (dvd[7] & 1); } unsigned int dvd_read_id(void *dst) { - if ((((int)dst) & 0xC0000000) == 0x80000000) // cached? - DCInvalidateRange((void *)dst, 0x20); + if ((((int)dst) & 0xC0000000) == 0x80000000) // cached? + DCInvalidateRange((void *)dst, 0x20); - dvd[0] = 0x2E; - dvd[1] = 0; + dvd[0] = 0x2E; + dvd[1] = 0; - dvd[2] = 0xA8000040; - dvd[3] = 0; - dvd[4] = 0x20; - dvd[5] = (unsigned long)dst; - dvd[6] = 0x20; - dvd[7] = 3; // enable reading! + dvd[2] = 0xA8000040; + dvd[3] = 0; + dvd[4] = 0x20; + dvd[5] = (unsigned long)dst; + dvd[6] = 0x20; + dvd[7] = 3; // enable reading! - while (dvd[7] & 1); + while (dvd[7] & 1); - if (dvd[0] & 0x4) - return 1; - return 0; + if (dvd[0] & 0x4) + return 1; + return 0; } unsigned int dvd_read(void *dst, unsigned int len, u64 offset) @@ -197,7 +197,7 @@ unsigned int dvd_read(void *dst, unsigned int len, u64 offset) if (len > 2048 ) return 1; - + DCInvalidateRange ((void *) buffer, len); if (offset < 0x57057C00 || (isWii == true && offset < 0x1FD3E0000LL)) // don't read past the end of the dvd @@ -213,7 +213,7 @@ unsigned int dvd_read(void *dst, unsigned int len, u64 offset) while (dvd[7] & 1); memcpy (dst, buffer, len); } else // Let's not read past end of DVD - return 1; + return 1; if (dvd[0] & 0x4) /* Ensure it has completed */ return 1; @@ -224,15 +224,15 @@ unsigned int dvd_read(void *dst, unsigned int len, u64 offset) void dvd_reset(void) { - int i; + int i; - *(unsigned long*)0xcc006004 = 2; - unsigned long v = *(unsigned long*)0xcc003024; - *(unsigned long*)0xcc003024 = (v &~4) | 1; + *(unsigned long*)0xcc006004 = 2; + unsigned long v = *(unsigned long*)0xcc003024; + *(unsigned long*)0xcc003024 = (v &~4) | 1; - for ( i = 0; i < 10000; i++ ); + for ( i = 0; i < 10000; i++ ); - *(unsigned long*)0xcc003024 = v | 5; + *(unsigned long*)0xcc003024 = v | 5; } /**************************************************************************** @@ -245,54 +245,54 @@ static int rootdirlength = 0; static int shadowroot, shadowlength; int IsPVD() { - int sector = 16; -// u32 offset32; - - IsJoliet = rootdir = 0; - - /*** Read the ISO section looking for a valid - Primary Volume Decriptor. - Spec says first 8 characters are id ***/ - while ( sector < 32 ) { + int sector = 16; + // u32 offset32; - dvd_read( &readbuffer, 2048, sector << 11 ); - if ( memcmp( &readbuffer, "\2CD001\1", 8 ) == 0 ) { - //memcpy(&offset32, &readbuffer[PVDROOT + EXTENT], 4); - //memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); - //rootdir = (u64)offset32; - memcpy(&rootdir, &readbuffer[PVDROOT + EXTENT], 4); - memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); - IsJoliet = 2; - break; - } + IsJoliet = rootdir = 0; - sector++; - } + /*** Read the ISO section looking for a valid + Primary Volume Decriptor. + Spec says first 8 characters are id ***/ + while ( sector < 32 ) { - if ( IsJoliet == 0 ) { - sector = 16; + dvd_read( &readbuffer, 2048, sector << 11 ); + if ( memcmp( &readbuffer, "\2CD001\1", 8 ) == 0 ) { + //memcpy(&offset32, &readbuffer[PVDROOT + EXTENT], 4); + //memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); + //rootdir = (u64)offset32; + memcpy(&rootdir, &readbuffer[PVDROOT + EXTENT], 4); + memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); + IsJoliet = 2; + break; + } - while ( sector < 32 ) { + sector++; + } - if ( memcmp( &readbuffer, "\1CD001\1", 8 ) == 0 ) { - /*memcpy(&offset32, &readbuffer[PVDROOT + EXTENT], 4); - memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); - rootdir = (u64)offset32;*/ - memcpy(&rootdir, &readbuffer[PVDROOT + EXTENT], 4); - memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); - IsJoliet = 1; - break; - } + if ( IsJoliet == 0 ) { + sector = 16; - sector++; - } - } + while ( sector < 32 ) { - rootdir <<= 11; - shadowroot = rootdir; - shadowlength = rootdirlength; + if ( memcmp( &readbuffer, "\1CD001\1", 8 ) == 0 ) { + /*memcpy(&offset32, &readbuffer[PVDROOT + EXTENT], 4); + memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); + rootdir = (u64)offset32;*/ + memcpy(&rootdir, &readbuffer[PVDROOT + EXTENT], 4); + memcpy(&rootdirlength, &readbuffer[PVDROOT + FILE_LENGTH], 4); + IsJoliet = 1; + break; + } - return IsJoliet; + sector++; + } + } + + rootdir <<= 11; + shadowroot = rootdir; + shadowlength = rootdirlength; + + return IsJoliet; } /**************************************************************************** @@ -303,85 +303,85 @@ int IsPVD() static int diroffset = 0; int getfiles( int filecount ) { - char fname[256]; - char *ptr; - char *filename; - char *filenamelength; - char *rr; - int j; - //u32 offset32; + char fname[256]; + char *ptr; + char *filename; + char *filenamelength; + char *rr; + int j; + //u32 offset32; - /*** Do some basic checks ***/ - if ( filecount == MAXFILES ) return 0; - if ( diroffset >= 2048 ) return 0; + /*** Do some basic checks ***/ + if ( filecount == MAXFILES ) return 0; + if ( diroffset >= 2048 ) return 0; - /*** Now decode this entry ***/ - if ( readbuffer[diroffset] != 0 ) - { + /*** Now decode this entry ***/ + if ( readbuffer[diroffset] != 0 ) + { - ptr = (char *)&readbuffer[0]; - ptr += diroffset; - filename = ptr + FILENAME; - filenamelength = ptr + FILENAME_LENGTH; - - if ( diroffset + readbuffer[diroffset] > 2048 ) return 0; + ptr = (char *)&readbuffer[0]; + ptr += diroffset; + filename = ptr + FILENAME; + filenamelength = ptr + FILENAME_LENGTH; - if ( *filenamelength ) { + if ( diroffset + readbuffer[diroffset] > 2048 ) return 0; - memset(&fname, 0, 128); + if ( *filenamelength ) { - /*** Return the values needed ***/ - if ( IsJoliet == 1 ) strcpy(fname, filename); - else { - for ( j = 0; j < ( *filenamelength >> 1 ); j++ ) { - fname[j] = filename[j*2+1]; - } + memset(&fname, 0, 128); - fname[j] = 0; - - if ( strlen(fname) >= MAXJOLIET ) fname[MAXJOLIET-1] = 0; + /*** Return the values needed ***/ + if ( IsJoliet == 1 ) strcpy(fname, filename); + else { + for ( j = 0; j < ( *filenamelength >> 1 ); j++ ) { + fname[j] = filename[j*2+1]; + } - if ( strlen(fname) == 0 ) fname[0] = filename[0]; - } + fname[j] = 0; - if ( strlen(fname) == 0 ) strcpy(fname,"ROOT"); - else { - if ( fname[0] == 1 ) strcpy(fname,".."); - else{ - //fname[ *filenamelength ] = 0; - /* - * Move *filenamelength to t, - * Only to stop gcc warning for noobs :) - */ - int t = *filenamelength; - fname[t] = 0; - } - } - - /** Rockridge Check **/ /*** Remove any trailing ;1 from ISO name ***/ - rr = strstr (fname, ";"); //if ( fname[ strlen(fname) - 2 ] == ';' ) - if (rr != NULL) *rr = 0; //fname[ strlen(fname) - 2 ] = 0;*/ + if ( strlen(fname) >= MAXJOLIET ) fname[MAXJOLIET-1] = 0; - /*strcpy(filelist[filecount].filename, fname); - memcpy(&offset32, &readbuffer[diroffset + EXTENT], 4); - memcpy(&cdfiles[filecount].length, &readbuffer[diroffset + FILE_LENGTH], 4); - memcpy(&cdfiles[filecount].flags, &readbuffer[diroffset + FILE_FLAGS], 1); - cdfiles[filecount].offset = (u64)offset32;*/ - strcpy(filelist[filecount].filename, fname); - memcpy(&filelist[filecount].offset, &readbuffer[diroffset + EXTENT], 4); - memcpy(&filelist[filecount].length, &readbuffer[diroffset + FILE_LENGTH], 4); - memcpy(&filelist[filecount].flags, &readbuffer[diroffset + FILE_FLAGS], 1); + if ( strlen(fname) == 0 ) fname[0] = filename[0]; + } - filelist[filecount].offset <<= 11; - filelist[filecount].flags = filelist[filecount].flags & 2; + if ( strlen(fname) == 0 ) strcpy(fname,"ROOT"); + else { + if ( fname[0] == 1 ) strcpy(fname,".."); + else{ + //fname[ *filenamelength ] = 0; + /* + * Move *filenamelength to t, + * Only to stop gcc warning for noobs :) + */ + int t = *filenamelength; + fname[t] = 0; + } + } - /*** Prepare for next entry ***/ - diroffset += readbuffer[diroffset]; - - return 1; - } - } - return 0; + /** Rockridge Check **/ /*** Remove any trailing ;1 from ISO name ***/ + rr = strstr (fname, ";"); //if ( fname[ strlen(fname) - 2 ] == ';' ) + if (rr != NULL) *rr = 0; //fname[ strlen(fname) - 2 ] = 0;*/ + + /*strcpy(filelist[filecount].filename, fname); + memcpy(&offset32, &readbuffer[diroffset + EXTENT], 4); + memcpy(&cdfiles[filecount].length, &readbuffer[diroffset + FILE_LENGTH], 4); + memcpy(&cdfiles[filecount].flags, &readbuffer[diroffset + FILE_FLAGS], 1); + cdfiles[filecount].offset = (u64)offset32;*/ + strcpy(filelist[filecount].filename, fname); + memcpy(&filelist[filecount].offset, &readbuffer[diroffset + EXTENT], 4); + memcpy(&filelist[filecount].length, &readbuffer[diroffset + FILE_LENGTH], 4); + memcpy(&filelist[filecount].flags, &readbuffer[diroffset + FILE_FLAGS], 1); + + filelist[filecount].offset <<= 11; + filelist[filecount].flags = filelist[filecount].flags & 2; + + /*** Prepare for next entry ***/ + diroffset += readbuffer[diroffset]; + + return 1; + } + } + return 0; } /**************************************************************************** @@ -392,37 +392,37 @@ int getfiles( int filecount ) int parsedir() { - int pdlength; - int pdoffset; - int rdoffset; - int len = 0; - int filecount = 0; + int pdlength; + int pdoffset; + int rdoffset; + int len = 0; + int filecount = 0; - pdoffset = rdoffset = rootdir; - pdlength = rootdirlength; - filecount = 0; + pdoffset = rdoffset = rootdir; + pdlength = rootdirlength; + filecount = 0; - /*** Clear any existing values ***/ - memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES); + /*** Clear any existing values ***/ + memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES); - /*** Get as many files as possible ***/ - while ( len < pdlength ) - { - if (dvd_read (&readbuffer, 2048, pdoffset) == 0) return 0; - //dvd_read(&readbuffer, 2048, pdoffset); - diroffset = 0; + /*** Get as many files as possible ***/ + while ( len < pdlength ) + { + if (dvd_read (&readbuffer, 2048, pdoffset) == 0) return 0; + //dvd_read(&readbuffer, 2048, pdoffset); + diroffset = 0; - while ( getfiles( filecount ) ) - { - if ( filecount < MAXFILES ) - filecount++; - } + while ( getfiles( filecount ) ) + { + if ( filecount < MAXFILES ) + filecount++; + } - len += 2048; - pdoffset = rdoffset + len; - } + len += 2048; + pdoffset = rdoffset + len; + } - return filecount; + return filecount; } /*************************************************************************** @@ -430,55 +430,55 @@ int parsedir() ***************************************************************************/ int updateSDdirname() { - int size=0; - char *test; - char temp[1024]; -// char tmpCompare[1024]; + int size=0; + char *test; + char temp[1024]; + // char tmpCompare[1024]; - /* current directory doesn't change */ - if (strcmp(filelist[selection].filename,".") == 0) return 0; - - /* go up to parent directory */ - else if (strcmp(filelist[selection].filename,"..") == 0) - { - /* determine last subdirectory namelength */ - sprintf(temp,"%s",rootSDdir); - test= strtok(temp,"\\"); - while (test != NULL) - { - size = strlen(test); - test = strtok(NULL,"\\"); - } - - /* remove last subdirectory name */ - size = strlen(rootSDdir) - size - 1; - rootSDdir[size] = 0; + /* current directory doesn't change */ + if (strcmp(filelist[selection].filename,".") == 0) return 0; - /* handles root name */ - //sprintf(tmpCompare, "dev%d:",choosenSDSlot); - if (strcmp(rootSDdir, sdslot ? "dev1:":"dev0:") == 0)sprintf(rootSDdir,"dev%d:\\fceu\\..", sdslot); - - return 1; - } - else - { - /* test new directory namelength */ - if ((strlen(rootSDdir)+1+strlen(filelist[selection].filename)) < SDCARD_MAX_PATH_LEN) - { - /* handles root name */ - //sprintf(tmpCompare, "dev%d:\\fceu\\..",choosenSDSlot); - //if (strcmp(rootSDdir, tmpCompare) == 0) sprintf(rootSDdir,"dev%d:",choosenSDSlot); - if (strcmp(rootSDdir, sdslot ? "dev1:\\fceu\\.." : "dev0:\\fceu\\..") == 0) sprintf(rootSDdir,"dev%d:",sdslot); - - /* update current directory name */ - sprintf(rootSDdir, "%s\\%s",rootSDdir, filelist[selection].filename); - return 1; - } - else - { - WaitPrompt ("Dirname is too long !"); - return -1; - } + /* go up to parent directory */ + else if (strcmp(filelist[selection].filename,"..") == 0) + { + /* determine last subdirectory namelength */ + sprintf(temp,"%s",rootSDdir); + test= strtok(temp,"\\"); + while (test != NULL) + { + size = strlen(test); + test = strtok(NULL,"\\"); + } + + /* remove last subdirectory name */ + size = strlen(rootSDdir) - size - 1; + rootSDdir[size] = 0; + + /* handles root name */ + //sprintf(tmpCompare, "dev%d:",choosenSDSlot); + if (strcmp(rootSDdir, sdslot ? "dev1:":"dev0:") == 0)sprintf(rootSDdir,"dev%d:\\fceu\\..", sdslot); + + return 1; + } + else + { + /* test new directory namelength */ + if ((strlen(rootSDdir)+1+strlen(filelist[selection].filename)) < SDCARD_MAX_PATH_LEN) + { + /* handles root name */ + //sprintf(tmpCompare, "dev%d:\\fceu\\..",choosenSDSlot); + //if (strcmp(rootSDdir, tmpCompare) == 0) sprintf(rootSDdir,"dev%d:",choosenSDSlot); + if (strcmp(rootSDdir, sdslot ? "dev1:\\fceu\\.." : "dev0:\\fceu\\..") == 0) sprintf(rootSDdir,"dev%d:",sdslot); + + /* update current directory name */ + sprintf(rootSDdir, "%s\\%s",rootSDdir, filelist[selection].filename); + return 1; + } + else + { + WaitPrompt ("Dirname is too long !"); + return -1; + } } } @@ -488,38 +488,38 @@ int updateSDdirname() int parseSDdirectory() { - int entries = 0; - int nbfiles = 0; - int numstored = 0; - DIR *sddir = NULL; + int entries = 0; + int nbfiles = 0; + int numstored = 0; + DIR *sddir = NULL; - /* initialize selection */ - selection = offset = 0; - - /* Get a list of files from the actual root directory */ - entries = SDCARD_ReadDir (rootSDdir, &sddir); - //entries = SDCARD_ReadDir (sdcardpath, &sddir); + /* initialize selection */ + selection = offset = 0; - if (entries <= 0) entries = 0; - if (entries>MAXFILES) entries = MAXFILES; + /* Get a list of files from the actual root directory */ + entries = SDCARD_ReadDir (rootSDdir, &sddir); + //entries = SDCARD_ReadDir (sdcardpath, &sddir); - while (entries) - { - if (strcmp((const char*)sddir[nbfiles].fname, ".") != 0) { // Skip "." directory - memset (&filelist[numstored], 0, sizeof (FILEENTRIES)); - strncpy(filelist[numstored].filename,(const char*)sddir[nbfiles].fname,MAXJOLIET); - filelist[numstored].filename[MAXJOLIET-1] = 0; - filelist[numstored].length = sddir[nbfiles].fsize; - filelist[numstored].flags = (char)(sddir[nbfiles].fattr & SDCARD_ATTR_DIR); - numstored++; + if (entries <= 0) entries = 0; + if (entries>MAXFILES) entries = MAXFILES; + + while (entries) + { + if (strcmp((const char*)sddir[nbfiles].fname, ".") != 0) { // Skip "." directory + memset (&filelist[numstored], 0, sizeof (FILEENTRIES)); + strncpy(filelist[numstored].filename,(const char*)sddir[nbfiles].fname,MAXJOLIET); + filelist[numstored].filename[MAXJOLIET-1] = 0; + filelist[numstored].length = sddir[nbfiles].fsize; + filelist[numstored].flags = (char)(sddir[nbfiles].fattr & SDCARD_ATTR_DIR); + numstored++; + } + nbfiles++; + entries--; } - nbfiles++; - entries--; - } - free(sddir); + free(sddir); - return nbfiles; + return nbfiles; } /**************************************************************************** * ShowFiles @@ -529,36 +529,36 @@ int parseSDdirectory() void ShowFiles( int offset, int selection ) { - int i,j; - char text[45]; + int i,j; + char text[45]; - ClearScreen(); - - j = 0; - for ( i = offset; i < ( offset + PAGESIZE ) && ( i < maxfiles ); i++ ) - { - if ( filelist[i].flags ) { - strcpy(text,"["); - strncat(text, filelist[i].filename,43); - strcat(text,"]"); - } else - strncpy(text, filelist[i].filename, 45); + ClearScreen(); - text[45]=0; - - /*if ( j == ( selection - offset ) ) - writex( CentreTextPosition(text), ( j * font_height ) + 117, - GetTextWidth(text), font_height, text, blit_lookup_inv ); - else - writex( CentreTextPosition(text), ( j * font_height ) + 117, - GetTextWidth(text), font_height, text, blit_lookup );*/ + j = 0; + for ( i = offset; i < ( offset + PAGESIZE ) && ( i < maxfiles ); i++ ) + { + if ( filelist[i].flags ) { + strcpy(text,"["); + strncat(text, filelist[i].filename,43); + strcat(text,"]"); + } else + strncpy(text, filelist[i].filename, 45); - writex( CentreTextPosition(text), ( j * font_height ) + 130, GetTextWidth(text), font_height, text, j == ( selection - offset ) ); + text[45]=0; - j++; - } + /*if ( j == ( selection - offset ) ) + writex( CentreTextPosition(text), ( j * font_height ) + 117, + GetTextWidth(text), font_height, text, blit_lookup_inv ); + else + writex( CentreTextPosition(text), ( j * font_height ) + 117, + GetTextWidth(text), font_height, text, blit_lookup );*/ - SetScreen(); + writex( CentreTextPosition(text), ( j * font_height ) + 130, GetTextWidth(text), font_height, text, j == ( selection - offset ) ); + + j++; + } + + SetScreen(); } @@ -573,38 +573,38 @@ extern int PADCAL; void FileSelector() { - short p; - short q = 0; - signed char a; - int haverom = 0; - int redraw = 1; + short p; + short q = 0; + signed char a; + int haverom = 0; + int redraw = 1; - while ( haverom == 0 ) - { - if ( redraw ) ShowFiles( offset, selection ); + while ( haverom == 0 ) + { + if ( redraw ) ShowFiles( offset, selection ); + + redraw = 0; + p = PAD_ButtonsDown(0); + a = PAD_StickY(0); + + if (p & PAD_BUTTON_B) return; - redraw = 0; - p = PAD_ButtonsDown(0); - a = PAD_StickY(0); - - if (p & PAD_BUTTON_B) return; - if ( ( p & PAD_BUTTON_DOWN ) || ( a < -PADCAL ) ){ - selection++; + selection++; if (selection == maxfiles) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; - redraw = 1; + redraw = 1; } // End of down if ( ( p & PAD_BUTTON_UP ) || ( a > PADCAL ) ) - { - selection--; + { + selection--; if ( selection < 0 ){ - selection = maxfiles - 1; - offset = selection - PAGESIZE + 1; + selection = maxfiles - 1; + offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; - if ( offset < 0 ) offset = 0; - redraw = 1; + if ( offset < 0 ) offset = 0; + redraw = 1; } // End of Up if ( (p & PAD_BUTTON_LEFT) || (p & PAD_TRIGGER_L) ) @@ -617,7 +617,7 @@ void FileSelector() } if ( selection < offset ) offset -= PAGESIZE; if ( offset < 0 ) offset = 0; - redraw = 1; + redraw = 1; } if (( p & PAD_BUTTON_RIGHT ) || (p & PAD_TRIGGER_R)) @@ -626,333 +626,333 @@ void FileSelector() selection += PAGESIZE; if ( selection > maxfiles - 1 ) selection = offset = 0; if ( ( selection - offset ) >= PAGESIZE ) offset += PAGESIZE; - redraw = 1; + redraw = 1; } - if ( p & PAD_BUTTON_A ) { - if ( filelist[selection].flags ) /*** This is directory ***/ - { - if (UseSDCARD) + if ( p & PAD_BUTTON_A ) { + if ( filelist[selection].flags ) /*** This is directory ***/ + { + if (UseSDCARD) { - //if ( filelist[selection].filename[0] == 0x2e) { - /* update current directory and set new entry list if directory has changed */ - int status = updateSDdirname(); - if (status == 1) - { - maxfiles = parseSDdirectory(); - if (!maxfiles) - { - WaitPrompt ("Error reading directory !"); - haverom = 1; // quit SD menu - haveSDdir = 0; // reset everything at next access - } - } - else if (status == -1) - { - haverom = 1; // quit SD menu - haveSDdir = 0; // reset everything at next access - } - } else { - rootdir = filelist[selection].offset; - rootdirlength = filelist[selection].length; - offset = selection = 0; - maxfiles = parsedir(); - } - } - else if(selection == 0 && inSz == true) - { - rootdir = filelist[1].offset; - rootdirlength = filelist[1].length; - offset = 0; - maxfiles = parsedir(); - inSz = false; - SzClose(); - } - else if(inSz == false && SzDvdIsArchive(filelist[selection].offset) == SZ_OK) - { - // parse the 7zip file - SzParse(); - if(SzRes == SZ_OK) - { - inSz = true; - offset = selection = 0; - } - else - { - SzDisplayError(SzRes); - } - } - else if(inSz == true) - { - // extract the selected ROM from the 7zip file to the buffer - if(SzExtractROM(filelist[selection].offset, nesromptr) == true) - { - haverom = 1; - inSz = false; - - // go one directory up - rootdir = filelist[1].offset; - rootdirlength = filelist[1].length; - offset = selection = 0; - maxfiles = parsedir(); - } - } - else - { - rootdir = filelist[selection].offset; - rootdirlength = filelist[selection].length; - // Now load the DVD file to it's offset - LoadDVDFile(nesromptr); - haverom = 1; - } - redraw = 1; - } - /*if ( p & PAD_BUTTON_B ) { - if ( cdfiles[1].filename[0] == 0x2e && cdfiles[1].filename[1] == 0x2e && cdfiles[1].flags ) { - if (UseSDCARD) { - char fname[SDCARD_MAX_PATH_LEN]; - int pathpos = strlen(cdfiles[1].sdcardpath); - while (pathpos > 6) { - if (cdfiles[1].sdcardpath[pathpos] == '\\') break; - pathpos--; + //if ( filelist[selection].filename[0] == 0x2e) { + /* update current directory and set new entry list if directory has changed */ + int status = updateSDdirname(); + if (status == 1) + { + maxfiles = parseSDdirectory(); + if (!maxfiles) + { + WaitPrompt ("Error reading directory !"); + haverom = 1; // quit SD menu + haveSDdir = 0; // reset everything at next access + } } - if (pathpos < 7) {pathpos = 16; cdfiles[1].sdcardpath[pathpos-3] = '\\'; cdfiles[1].sdcardpath[pathpos-2] = '.'; cdfiles[1].sdcardpath[pathpos-1] = '.'; } // handle root case - strncpy(fname, cdfiles[1].sdcardpath, pathpos); - fname[pathpos] = 0; - offset = selection = 0; - maxfiles = parse_sdcard_dir(fname); - } - else if(inSz == true) - { - rootdir = cdfiles[1].offset; - rootdirlength = cdfiles[1].length; - offset = selection = 0; - maxfiles = parsedir(); - inSz = false; - SzClose(); - } - else { - rootdir = cdfiles[1].offset; - rootdirlength = cdfiles[1].length; - offset = selection = 0; - maxfiles = parsedir(); + else if (status == -1) + { + haverom = 1; // quit SD menu + haveSDdir = 0; // reset everything at next access + } + } else { + rootdir = filelist[selection].offset; + rootdirlength = filelist[selection].length; + offset = selection = 0; + maxfiles = parsedir(); + } + } + else if(selection == 0 && inSz == true) + { + rootdir = filelist[1].offset; + rootdirlength = filelist[1].length; + offset = 0; + maxfiles = parsedir(); + inSz = false; + SzClose(); + } + else if(inSz == false && SzDvdIsArchive(filelist[selection].offset) == SZ_OK) + { + // parse the 7zip file + SzParse(); + if(SzRes == SZ_OK) + { + inSz = true; + offset = selection = 0; + } + else + { + SzDisplayError(SzRes); + } + } + else if(inSz == true) + { + // extract the selected ROM from the 7zip file to the buffer + if(SzExtractROM(filelist[selection].offset, nesromptr) == true) + { + haverom = 1; + inSz = false; + + // go one directory up + rootdir = filelist[1].offset; + rootdirlength = filelist[1].length; + offset = selection = 0; + maxfiles = parsedir(); + } + } + else + { + rootdir = filelist[selection].offset; + rootdirlength = filelist[selection].length; + // Now load the DVD file to it's offset + LoadDVDFile(nesromptr); + haverom = 1; } redraw = 1; - } - }*/ - } -} - -/**************************************************************************** - * LoadDVDFile - ****************************************************************************/ -int LoadDVDFile( unsigned char *buffer ) -{ - u64 offset; - int blocks; - int i; - u64 discoffset; - - /*** SDCard Addition ***/ - if (UseSDCARD) GetSDInfo (); - if (rootdirlength == 0) return 0; - - /*** How many 2k blocks to read ***/ - blocks = rootdirlength / 2048; - offset = 0; - discoffset = rootdir; - - ShowAction("Loading ... Wait"); - if (UseSDCARD) SDCARD_ReadFile (filehandle, &readbuffer, 2048); - else dvd_read(&readbuffer, 2048, discoffset); - - if ( isZipFile() == false ) - { - if (UseSDCARD) SDCARD_SeekFile (filehandle, 0, SDCARD_SEEK_SET); - for ( i = 0; i < blocks; i++ ) - { - if (UseSDCARD) SDCARD_ReadFile (filehandle, &readbuffer, 2048); - else dvd_read(&readbuffer, 2048, discoffset); - memcpy(&buffer[offset], &readbuffer, 2048); - offset += 2048; - discoffset += 2048; - } - - /*** And final cleanup ***/ - if( rootdirlength % 2048 ) - { - i = rootdirlength % 2048; - if (UseSDCARD) SDCARD_ReadFile (filehandle, &readbuffer, i); - else dvd_read(&readbuffer, 2048, discoffset); - memcpy(&buffer[offset], &readbuffer, i); - } - } else { - return unzipDVDFile( buffer, discoffset, rootdirlength); - } - if (UseSDCARD) SDCARD_CloseFile (filehandle); - - return rootdirlength; -} - -/**************************************************************************** - * OpenDVD - * - * This function performs the swap task for softmodders. - * For Viper/Qoob users, sector 0 is read, and if it contains all nulls - * an ISO disc is assumed. - ****************************************************************************/ -static int havedir = 0; - -int OpenDVD() -{ - - int i, j; - int driveid=-99; - - haveSDdir = 0; - - /*** Get Drive Type ***/ - dvd_inquiry(); - driveid = (int)inquiry[2]; - - /*** Make sure it's one I now about ***/ - if ( ( driveid != 4 ) && ( driveid != 6 ) && ( driveid != 8 ) ) { - isWii = true; - } - - memset(&readbuffer, 0x80, 2048); - dvd_read(&readbuffer, 2048,0); - - for ( i = j = 0; i < 2048; i++ ) - j += readbuffer[i]; - - if ( j ) { - if ( IsXenoGCImage( (char *)&readbuffer ) ) - j = 0; - } - - /*** Was there any data in sector 0 ? ***/ - // do not do all this stuff here if we are running on a Wii - // because the modchip will take care of this. - havedir = offset = selection = 0; - if (isWii == false && j ) { - /*** Yes - so start swap sequence ***/ - ShowAction("Stopping DVD ... Wait"); - dvd_motor_off(); - WaitPrompt("Insert an ISO 9660 DVD"); - ShowAction("Resetting DVD ... Wait"); - dvd_reset(); - - /*** Now the fun begins - This is essentially the cactus implementation from gc-linux - sequence of events. There may well be a better way to do it - from inside libogc, but no documentation is available. ***/ - - /*** Reset the DVD Drive, to enable the firmware update ***/ - /*** Reset - Unlock - SendCode - Enable Extension - Unlock - Motor On - SetStatus - ReadID ***/ - - ShowAction("Sending Drive Code ... Wait"); - dvd_unlock(); - SendDriveCode(driveid); - dvd_extension(); - dvd_unlock(); - ShowAction("Mounting DVD ... Wait"); - dvd_motor_on_extra(); - dvd_setstatus(); - dvd_read_id((void *)0x80000000); - } - - /*** At this point I should have an unlocked DVD ... so let's do the ISO ***/ - if ( havedir != 1 ) { - if ( IsPVD() ) - { - /*** Have a valid PVD, so start reading directory entries ***/ - maxfiles = parsedir(); - if ( maxfiles ) { - offset = selection = 0; - FileSelector(); - havedir = 1; - } - } else { - return 0; - } - } else - FileSelector(); - - return 1; -} - -int OpenSD () -{ - UseSDCARD = 1; - char msg[128]; - - if (choosenSDSlot != sdslot) haveSDdir = 0; - - if (haveSDdir == 0) - { - /* don't mess with DVD entries */ - havedir = 0; - - /* Reset SDCARD root directory */ - sprintf(rootSDdir,"dev%d:\\fceu\\roms",choosenSDSlot); - sdslot = choosenSDSlot; - - /* Parse initial root directory and get entries list */ - ShowAction("Reading Directory ..."); - if ((maxfiles = parseSDdirectory ())) - { - sprintf (msg, "Found %d entries", maxfiles); - WaitPrompt (msg); - /* Select an entry */ - FileSelector (); - - /* memorize last entries list, actual root directory and selection for next access */ - haveSDdir = 1; - } - else - { - /* no entries found */ - sprintf (msg, "Error reading dev%d:\\fceu\\roms", choosenSDSlot); - WaitPrompt (msg); - return 0; - } - } - /* Retrieve previous entries list and made a new selection */ - else FileSelector (); - - return 1; -} - -/**************************************************************************** - * SDCard Get Info - ****************************************************************************/ -void GetSDInfo () { - char fname[SDCARD_MAX_PATH_LEN]; - rootdirlength = 0; - - /* Check filename length */ - if ((strlen(rootSDdir)+1+strlen(filelist[selection].filename)) < SDCARD_MAX_PATH_LEN) - sprintf(fname, "%s\\%s",rootSDdir,filelist[selection].filename); - - else - { - WaitPrompt ("Maximum Filename Length reached !"); - haveSDdir = 0; // reset everything before next access - } - - filehandle = SDCARD_OpenFile (fname, "rb"); - if (filehandle == NULL) - { - WaitPrompt ("Unable to open file!"); - return; + } + /*if ( p & PAD_BUTTON_B ) { + if ( cdfiles[1].filename[0] == 0x2e && cdfiles[1].filename[1] == 0x2e && cdfiles[1].flags ) { + if (UseSDCARD) { + char fname[SDCARD_MAX_PATH_LEN]; + int pathpos = strlen(cdfiles[1].sdcardpath); + while (pathpos > 6) { + if (cdfiles[1].sdcardpath[pathpos] == '\\') break; + pathpos--; + } + if (pathpos < 7) {pathpos = 16; cdfiles[1].sdcardpath[pathpos-3] = '\\'; cdfiles[1].sdcardpath[pathpos-2] = '.'; cdfiles[1].sdcardpath[pathpos-1] = '.'; } // handle root case + strncpy(fname, cdfiles[1].sdcardpath, pathpos); + fname[pathpos] = 0; + offset = selection = 0; + maxfiles = parse_sdcard_dir(fname); + } + else if(inSz == true) + { + rootdir = cdfiles[1].offset; + rootdirlength = cdfiles[1].length; + offset = selection = 0; + maxfiles = parsedir(); + inSz = false; + SzClose(); + } + else { + rootdir = cdfiles[1].offset; + rootdirlength = cdfiles[1].length; + offset = selection = 0; + maxfiles = parsedir(); + } + redraw = 1; + } + }*/ + } + } + + /**************************************************************************** + * LoadDVDFile + ****************************************************************************/ + int LoadDVDFile( unsigned char *buffer ) + { + u64 offset; + int blocks; + int i; + u64 discoffset; + + /*** SDCard Addition ***/ + if (UseSDCARD) GetSDInfo (); + if (rootdirlength == 0) return 0; + + /*** How many 2k blocks to read ***/ + blocks = rootdirlength / 2048; + offset = 0; + discoffset = rootdir; + + ShowAction("Loading ... Wait"); + if (UseSDCARD) SDCARD_ReadFile (filehandle, &readbuffer, 2048); + else dvd_read(&readbuffer, 2048, discoffset); + + if ( isZipFile() == false ) + { + if (UseSDCARD) SDCARD_SeekFile (filehandle, 0, SDCARD_SEEK_SET); + for ( i = 0; i < blocks; i++ ) + { + if (UseSDCARD) SDCARD_ReadFile (filehandle, &readbuffer, 2048); + else dvd_read(&readbuffer, 2048, discoffset); + memcpy(&buffer[offset], &readbuffer, 2048); + offset += 2048; + discoffset += 2048; + } + + /*** And final cleanup ***/ + if( rootdirlength % 2048 ) + { + i = rootdirlength % 2048; + if (UseSDCARD) SDCARD_ReadFile (filehandle, &readbuffer, i); + else dvd_read(&readbuffer, 2048, discoffset); + memcpy(&buffer[offset], &readbuffer, i); + } + } else { + return unzipDVDFile( buffer, discoffset, rootdirlength); + } + if (UseSDCARD) SDCARD_CloseFile (filehandle); + + return rootdirlength; + } + + /**************************************************************************** + * OpenDVD + * + * This function performs the swap task for softmodders. + * For Viper/Qoob users, sector 0 is read, and if it contains all nulls + * an ISO disc is assumed. + ****************************************************************************/ + static int havedir = 0; + + int OpenDVD() + { + + int i, j; + int driveid=-99; + + haveSDdir = 0; + + /*** Get Drive Type ***/ + dvd_inquiry(); + driveid = (int)inquiry[2]; + + /*** Make sure it's one I now about ***/ + if ( ( driveid != 4 ) && ( driveid != 6 ) && ( driveid != 8 ) ) { + isWii = true; + } + + memset(&readbuffer, 0x80, 2048); + dvd_read(&readbuffer, 2048,0); + + for ( i = j = 0; i < 2048; i++ ) + j += readbuffer[i]; + + if ( j ) { + if ( IsXenoGCImage( (char *)&readbuffer ) ) + j = 0; + } + + /*** Was there any data in sector 0 ? ***/ + // do not do all this stuff here if we are running on a Wii + // because the modchip will take care of this. + havedir = offset = selection = 0; + if (isWii == false && j ) { + /*** Yes - so start swap sequence ***/ + ShowAction("Stopping DVD ... Wait"); + dvd_motor_off(); + WaitPrompt("Insert an ISO 9660 DVD"); + ShowAction("Resetting DVD ... Wait"); + dvd_reset(); + + /*** Now the fun begins + This is essentially the cactus implementation from gc-linux + sequence of events. There may well be a better way to do it + from inside libogc, but no documentation is available. ***/ + + /*** Reset the DVD Drive, to enable the firmware update ***/ + /*** Reset + Unlock + SendCode + Enable Extension + Unlock + Motor On + SetStatus + ReadID ***/ + + ShowAction("Sending Drive Code ... Wait"); + dvd_unlock(); + SendDriveCode(driveid); + dvd_extension(); + dvd_unlock(); + ShowAction("Mounting DVD ... Wait"); + dvd_motor_on_extra(); + dvd_setstatus(); + dvd_read_id((void *)0x80000000); + } + + /*** At this point I should have an unlocked DVD ... so let's do the ISO ***/ + if ( havedir != 1 ) { + if ( IsPVD() ) + { + /*** Have a valid PVD, so start reading directory entries ***/ + maxfiles = parsedir(); + if ( maxfiles ) { + offset = selection = 0; + FileSelector(); + havedir = 1; + } + } else { + return 0; + } + } else + FileSelector(); + + return 1; + } + + int OpenSD () + { + UseSDCARD = 1; + char msg[128]; + + if (choosenSDSlot != sdslot) haveSDdir = 0; + + if (haveSDdir == 0) + { + /* don't mess with DVD entries */ + havedir = 0; + + /* Reset SDCARD root directory */ + sprintf(rootSDdir,"dev%d:\\fceu\\roms",choosenSDSlot); + sdslot = choosenSDSlot; + + /* Parse initial root directory and get entries list */ + ShowAction("Reading Directory ..."); + if ((maxfiles = parseSDdirectory ())) + { + sprintf (msg, "Found %d entries", maxfiles); + WaitPrompt (msg); + /* Select an entry */ + FileSelector (); + + /* memorize last entries list, actual root directory and selection for next access */ + haveSDdir = 1; + } + else + { + /* no entries found */ + sprintf (msg, "Error reading dev%d:\\fceu\\roms", choosenSDSlot); + WaitPrompt (msg); + return 0; + } + } + /* Retrieve previous entries list and made a new selection */ + else FileSelector (); + + return 1; + } + + /**************************************************************************** + * SDCard Get Info + ****************************************************************************/ + void GetSDInfo () { + char fname[SDCARD_MAX_PATH_LEN]; + rootdirlength = 0; + + /* Check filename length */ + if ((strlen(rootSDdir)+1+strlen(filelist[selection].filename)) < SDCARD_MAX_PATH_LEN) + sprintf(fname, "%s\\%s",rootSDdir,filelist[selection].filename); + + else + { + WaitPrompt ("Maximum Filename Length reached !"); + haveSDdir = 0; // reset everything before next access + } + + filehandle = SDCARD_OpenFile (fname, "rb"); + if (filehandle == NULL) + { + WaitPrompt ("Unable to open file!"); + return; + } + rootdirlength = SDCARD_GetFileSize (filehandle); } - rootdirlength = SDCARD_GetFileSize (filehandle); -} diff --git a/source/drivers/gamecube/gcdvd.h b/source/drivers/gamecube/gcdvd.h index 1b7bfc2..de3ffb7 100644 --- a/source/drivers/gamecube/gcdvd.h +++ b/source/drivers/gamecube/gcdvd.h @@ -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]; diff --git a/source/drivers/gamecube/gcvideo.c b/source/drivers/gamecube/gcvideo.c index 735a2a8..055e7bf 100644 --- a/source/drivers/gamecube/gcvideo.c +++ b/source/drivers/gamecube/gcvideo.c @@ -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; - } + } } diff --git a/source/drivers/gamecube/gcxenogc.c b/source/drivers/gamecube/gcxenogc.c index 9627014..a2bd0d4 100644 --- a/source/drivers/gamecube/gcxenogc.c +++ b/source/drivers/gamecube/gcxenogc.c @@ -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; } diff --git a/source/drivers/gamecube/gczip.c b/source/drivers/gamecube/gczip.c index d873a3f..03b2a1c 100644 --- a/source/drivers/gamecube/gczip.c +++ b/source/drivers/gamecube/gczip.c @@ -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; } diff --git a/source/drivers/gamecube/info.b b/source/drivers/gamecube/info.b deleted file mode 100644 index 6f57e06..0000000 --- a/source/drivers/gamecube/info.b +++ /dev/null @@ -1,1041 +0,0 @@ -/**************************************************************************** - * Intro and Credits - * - * Just own up to who did what - ****************************************************************************/ - -#include -#include -#include -#include -#include "../../iplfont/iplfont.h" - -#define MARGIN 0 -//#define PSOSDLOADID 0x7c6000a6 - -#define JOY_UP 0x10 -#define JOY_DOWN 0x20 - -static int currpal = 0; -static int timing = 0; - -static int FSDisable = 1; - -static int slimit = 1; - -extern int scrollerx; - -extern void FCEUI_DisableSpriteLimitation( int a ); - -extern void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b); -extern void FCEU_ResetPalette(void); -extern void WaitPrompt( char *text ); -//extern void MCManage( int mode ); -extern void ManageState(int mode, int slot, int device); - -extern void StartGX(); - -extern signed int CARDSLOT; -extern int PADCAL; -extern int PADTUR; - -extern void scroller(int y, unsigned char text[][512], int nlines); - -extern void FCEUI_DisableFourScore(int a); - -extern int line; - -extern char backdrop[640 * 480 * 2]; - -extern int UseSDCARD; - -extern unsigned char DecodeJoy( unsigned short pp ); -extern unsigned char GetAnalog(int Joy); - -#define MAXPAL 12 - -#define SCROLLY 380 - -/* color palettes */ -struct - { - char *name, *desc; - unsigned int data[64]; - } -palettes[] = -{ - /* The default NES palette must be the first entry in the array */ - { "loopy", "Loopy's NES palette", - { 0x757575, 0x271b8f, 0x0000ab, 0x47009f, - 0x8f0077, 0xab0013, 0xa70000, 0x7f0b00, - 0x432f00, 0x004700, 0x005100, 0x003f17, - 0x1b3f5f, 0x000000, 0x000000, 0x000000, - 0xbcbcbc, 0x0073ef, 0x233bef, 0x8300f3, - 0xbf00bf, 0xe7005b, 0xdb2b00, 0xcb4f0f, - 0x8b7300, 0x009700, 0x00ab00, 0x00933b, - 0x00838b, 0x000000, 0x000000, 0x000000, - 0xffffff, 0x3fbfff, 0x5f97ff, 0xa78bfd, - 0xf77bff, 0xff77b7, 0xff7763, 0xff9b3b, - 0xf3bf3f, 0x83d313, 0x4fdf4b, 0x58f898, - 0x00ebdb, 0x000000, 0x000000, 0x000000, - 0xffffff, 0xabe7ff, 0xc7d7ff, 0xd7cbff, - 0xffc7ff, 0xffc7db, 0xffbfb3, 0xffdbab, - 0xffe7a3, 0xe3ffa3, 0xabf3bf, 0xb3ffcf, - 0x9ffff3, 0x000000, 0x000000, 0x000000 } - }, - { "quor", "Quor's palette from Nestra 0.63", - { 0x3f3f3f, 0x001f3f, 0x00003f, 0x1f003f, - 0x3f003f, 0x3f0020, 0x3f0000, 0x3f2000, - 0x3f3f00, 0x203f00, 0x003f00, 0x003f20, - 0x003f3f, 0x000000, 0x000000, 0x000000, - 0x7f7f7f, 0x405f7f, 0x40407f, 0x5f407f, - 0x7f407f, 0x7f4060, 0x7f4040, 0x7f6040, - 0x7f7f40, 0x607f40, 0x407f40, 0x407f60, - 0x407f7f, 0x000000, 0x000000, 0x000000, - 0xbfbfbf, 0x809fbf, 0x8080bf, 0x9f80bf, - 0xbf80bf, 0xbf80a0, 0xbf8080, 0xbfa080, - 0xbfbf80, 0xa0bf80, 0x80bf80, 0x80bfa0, - 0x80bfbf, 0x000000, 0x000000, 0x000000, - 0xffffff, 0xc0dfff, 0xc0c0ff, 0xdfc0ff, - 0xffc0ff, 0xffc0e0, 0xffc0c0, 0xffe0c0, - 0xffffc0, 0xe0ffc0, 0xc0ffc0, 0xc0ffe0, - 0xc0ffff, 0x000000, 0x000000, 0x000000 } - }, - { "chris", "Chris Covell's NES palette", - { 0x808080, 0x003DA6, 0x0012B0, 0x440096, - 0xA1005E, 0xC70028, 0xBA0600, 0x8C1700, - 0x5C2F00, 0x104500, 0x054A00, 0x00472E, - 0x004166, 0x000000, 0x050505, 0x050505, - 0xC7C7C7, 0x0077FF, 0x2155FF, 0x8237FA, - 0xEB2FB5, 0xFF2950, 0xFF2200, 0xD63200, - 0xC46200, 0x358000, 0x058F00, 0x008A55, - 0x0099CC, 0x212121, 0x090909, 0x090909, - 0xFFFFFF, 0x0FD7FF, 0x69A2FF, 0xD480FF, - 0xFF45F3, 0xFF618B, 0xFF8833, 0xFF9C12, - 0xFABC20, 0x9FE30E, 0x2BF035, 0x0CF0A4, - 0x05FBFF, 0x5E5E5E, 0x0D0D0D, 0x0D0D0D, - 0xFFFFFF, 0xA6FCFF, 0xB3ECFF, 0xDAABEB, - 0xFFA8F9, 0xFFABB3, 0xFFD2B0, 0xFFEFA6, - 0xFFF79C, 0xD7E895, 0xA6EDAF, 0xA2F2DA, - 0x99FFFC, 0xDDDDDD, 0x111111, 0x111111 } - }, - { "matt", "Matthew Conte's NES palette", - { 0x808080, 0x0000bb, 0x3700bf, 0x8400a6, - 0xbb006a, 0xb7001e, 0xb30000, 0x912600, - 0x7b2b00, 0x003e00, 0x00480d, 0x003c22, - 0x002f66, 0x000000, 0x050505, 0x050505, - 0xc8c8c8, 0x0059ff, 0x443cff, 0xb733cc, - 0xff33aa, 0xff375e, 0xff371a, 0xd54b00, - 0xc46200, 0x3c7b00, 0x1e8415, 0x009566, - 0x0084c4, 0x111111, 0x090909, 0x090909, - 0xffffff, 0x0095ff, 0x6f84ff, 0xd56fff, - 0xff77cc, 0xff6f99, 0xff7b59, 0xff915f, - 0xffa233, 0xa6bf00, 0x51d96a, 0x4dd5ae, - 0x00d9ff, 0x666666, 0x0d0d0d, 0x0d0d0d, - 0xffffff, 0x84bfff, 0xbbbbff, 0xd0bbff, - 0xffbfea, 0xffbfcc, 0xffc4b7, 0xffccae, - 0xffd9a2, 0xcce199, 0xaeeeb7, 0xaaf7ee, - 0xb3eeff, 0xdddddd, 0x111111, 0x111111 } - }, - { "pasofami", "Palette from PasoFami/99", - { 0x7f7f7f, 0x0000ff, 0x0000bf, 0x472bbf, - 0x970087, 0xab0023, 0xab1300, 0x8b1700, - 0x533000, 0x007800, 0x006b00, 0x005b00, - 0x004358, 0x000000, 0x000000, 0x000000, - 0xbfbfbf, 0x0078f8, 0x0058f8, 0x6b47ff, - 0xdb00cd, 0xe7005b, 0xf83800, 0xe75f13, - 0xaf7f00, 0x00b800, 0x00ab00, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x000000, - 0xf8f8f8, 0x3fbfff, 0x6b88ff, 0x9878f8, - 0xf878f8, 0xf85898, 0xf87858, 0xffa347, - 0xf8b800, 0xb8f818, 0x5bdb57, 0x58f898, - 0x00ebdb, 0x787878, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xd8b8f8, - 0xf8b8f8, 0xfba7c3, 0xf0d0b0, 0xffe3ab, - 0xfbdb7b, 0xd8f878, 0xb8f8b8, 0xb8f8d8, - 0x00ffff, 0xf8d8f8, 0x000000, 0x000000 } - }, - { "crashman", "CrashMan's NES palette", - { 0x585858, 0x001173, 0x000062, 0x472bbf, - 0x970087, 0x910009, 0x6f1100, 0x4c1008, - 0x371e00, 0x002f00, 0x005500, 0x004d15, - 0x002840, 0x000000, 0x000000, 0x000000, - 0xa0a0a0, 0x004499, 0x2c2cc8, 0x590daa, - 0xae006a, 0xb00040, 0xb83418, 0x983010, - 0x704000, 0x308000, 0x207808, 0x007b33, - 0x1c6888, 0x000000, 0x000000, 0x000000, - 0xf8f8f8, 0x267be1, 0x5870f0, 0x9878f8, - 0xff73c8, 0xf060a8, 0xd07b37, 0xe09040, - 0xf8b300, 0x8cbc00, 0x40a858, 0x58f898, - 0x00b7bf, 0x787878, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xd8b8f8, - 0xe6a6ff, 0xf29dc4, 0xf0c0b0, 0xfce4b0, - 0xe0e01e, 0xd8f878, 0xc0e890, 0x95f7c8, - 0x98e0e8, 0xf8d8f8, 0x000000, 0x000000 } - }, - { "mess", "palette from the MESS NES driver", - { 0x747474, 0x24188c, 0x0000a8, 0x44009c, - 0x8c0074, 0xa80010, 0xa40000, 0x7c0800, - 0x402c00, 0x004400, 0x005000, 0x003c14, - 0x183c5c, 0x000000, 0x000000, 0x000000, - 0xbcbcbc, 0x0070ec, 0x2038ec, 0x8000f0, - 0xbc00bc, 0xe40058, 0xd82800, 0xc84c0c, - 0x887000, 0x009400, 0x00a800, 0x009038, - 0x008088, 0x000000, 0x000000, 0x000000, - 0xfcfcfc, 0x3cbcfc, 0x5c94fc, 0x4088fc, - 0xf478fc, 0xfc74b4, 0xfc7460, 0xfc9838, - 0xf0bc3c, 0x80d010, 0x4cdc48, 0x58f898, - 0x00e8d8, 0x000000, 0x000000, 0x000000, - 0xfcfcfc, 0xa8e4fc, 0xc4d4fc, 0xd4c8fc, - 0xfcc4fc, 0xfcc4d8, 0xfcbcb0, 0xfcd8a8, - 0xfce4a0, 0xe0fca0, 0xa8f0bc, 0xb0fccc, - 0x9cfcf0, 0x000000, 0x000000, 0x000000 } - }, - { "zaphod-cv", "Zaphod's VS Castlevania palette", - { 0x7f7f7f, 0xffa347, 0x0000bf, 0x472bbf, - 0x970087, 0xf85898, 0xab1300, 0xf8b8f8, - 0xbf0000, 0x007800, 0x006b00, 0x005b00, - 0xffffff, 0x9878f8, 0x000000, 0x000000, - 0xbfbfbf, 0x0078f8, 0xab1300, 0x6b47ff, - 0x00ae00, 0xe7005b, 0xf83800, 0x7777ff, - 0xaf7f00, 0x00b800, 0x00ab00, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x472bbf, - 0xf8f8f8, 0xffe3ab, 0xf87858, 0x9878f8, - 0x0078f8, 0xf85898, 0xbfbfbf, 0xffa347, - 0xc800c8, 0xb8f818, 0x7f7f7f, 0x007800, - 0x00ebdb, 0x000000, 0x000000, 0xffffff, - 0xffffff, 0xa7e7ff, 0x5bdb57, 0xe75f13, - 0x004358, 0x0000ff, 0xe7005b, 0x00b800, - 0xfbdb7b, 0xd8f878, 0x8b1700, 0xffe3ab, - 0x00ffff, 0xab0023, 0x000000, 0x000000 } - }, - { "zaphod-smb", "Zaphod's VS SMB palette", - { 0x626a00, 0x0000ff, 0x006a77, 0x472bbf, - 0x970087, 0xab0023, 0xab1300, 0xb74800, - 0xa2a2a2, 0x007800, 0x006b00, 0x005b00, - 0xffd599, 0xffff00, 0x009900, 0x000000, - 0xff66ff, 0x0078f8, 0x0058f8, 0x6b47ff, - 0x000000, 0xe7005b, 0xf83800, 0xe75f13, - 0xaf7f00, 0x00b800, 0x5173ff, 0x00ab47, - 0x008b8b, 0x000000, 0x91ff88, 0x000088, - 0xf8f8f8, 0x3fbfff, 0x6b0000, 0x4855f8, - 0xf878f8, 0xf85898, 0x595958, 0xff009d, - 0x002f2f, 0xb8f818, 0x5bdb57, 0x58f898, - 0x00ebdb, 0x787878, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0x590400, 0xbb0000, - 0xf8b8f8, 0xfba7c3, 0xffffff, 0x00e3e1, - 0xfbdb7b, 0xffae00, 0xb8f8b8, 0xb8f8d8, - 0x00ff00, 0xf8d8f8, 0xffaaaa, 0x004000 } - }, - { "vs-drmar", "VS Dr. Mario palette", - { 0x5f97ff, 0x000000, 0x000000, 0x47009f, - 0x00ab00, 0xffffff, 0xabe7ff, 0x000000, - 0x000000, 0x000000, 0x000000, 0x000000, - 0xe7005b, 0x000000, 0x000000, 0x000000, - 0x5f97ff, 0x000000, 0x000000, 0x000000, - 0x000000, 0x8b7300, 0xcb4f0f, 0x000000, - 0xbcbcbc, 0x000000, 0x000000, 0x000000, - 0x000000, 0x000000, 0x000000, 0x000000, - 0x00ebdb, 0x000000, 0x000000, 0x000000, - 0x000000, 0xff9b3b, 0x000000, 0x000000, - 0x83d313, 0x000000, 0x3fbfff, 0x000000, - 0x0073ef, 0x000000, 0x000000, 0x000000, - 0x00ebdb, 0x000000, 0x000000, 0x000000, - 0x000000, 0x000000, 0xf3bf3f, 0x000000, - 0x005100, 0x000000, 0xc7d7ff, 0xffdbab, - 0x000000, 0x000000, 0x000000, 0x000000 } - }, - { "vs-cv", "VS Castlevania palette", - { 0xaf7f00, 0xffa347, 0x008b8b, 0x472bbf, - 0x970087, 0xf85898, 0xab1300, 0xf8b8f8, - 0xf83800, 0x007800, 0x006b00, 0x005b00, - 0xffffff, 0x9878f8, 0x00ab00, 0x000000, - 0xbfbfbf, 0x0078f8, 0xab1300, 0x6b47ff, - 0x000000, 0xe7005b, 0xf83800, 0x6b88ff, - 0xaf7f00, 0x00b800, 0x6b88ff, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x472bbf, - 0xf8f8f8, 0xffe3ab, 0xf87858, 0x9878f8, - 0x0078f8, 0xf85898, 0xbfbfbf, 0xffa347, - 0x004358, 0xb8f818, 0x7f7f7f, 0x007800, - 0x00ebdb, 0x000000, 0x000000, 0xffffff, - 0xffffff, 0xa7e7ff, 0x5bdb57, 0x6b88ff, - 0x004358, 0x0000ff, 0xe7005b, 0x00b800, - 0xfbdb7b, 0xffa347, 0x8b1700, 0xffe3ab, - 0xb8f818, 0xab0023, 0x000000, 0x007800 } - }, -/* The default VS palette must be the last entry in the array */ - { "vs-smb", "VS SMB/VS Ice Climber palette", - { 0xaf7f00, 0x0000ff, 0x008b8b, 0x472bbf, - 0x970087, 0xab0023, 0x0000ff, 0xe75f13, - 0xbfbfbf, 0x007800, 0x5bdb57, 0x005b00, - 0xf0d0b0, 0xffe3ab, 0x00ab00, 0x000000, - 0xbfbfbf, 0x0078f8, 0x0058f8, 0x6b47ff, - 0x000000, 0xe7005b, 0xf83800, 0xf87858, - 0xaf7f00, 0x00b800, 0x6b88ff, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x3fbfff, - 0xf8f8f8, 0x006b00, 0x8b1700, 0x9878f8, - 0x6b47ff, 0xf85898, 0x7f7f7f, 0xe7005b, - 0x004358, 0xb8f818, 0x0078f8, 0x58f898, - 0x00ebdb, 0xfbdb7b, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xf83800, - 0xf8b8f8, 0xfba7c3, 0xffffff, 0x00ffff, - 0xfbdb7b, 0xffa347, 0xb8f8b8, 0xb8f8d8, - 0xb8f818, 0xf8d8f8, 0x000000, 0x007800 } - } -}; - -extern int whichfb; -extern unsigned int *xfb[2]; -extern GXRModeObj *vmode; -extern int font_size[256]; -extern int font_height; -extern int screenscaler; -/*extern long blit_lookup[4]; -extern long blit_lookup_inv[4];*/ - -/**************************************************************************** - * SetScreen - ****************************************************************************/ - -void SetScreen() -{ - - VIDEO_SetNextFramebuffer( xfb[whichfb] ); - VIDEO_Flush(); - VIDEO_WaitVSync(); - -} - -void ClearScreen() -{ - whichfb ^= 1; - /*VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], 0x258e2573);*/ - memcpy (xfb[whichfb], &backdrop, 1280 * 480); -} - -/*************************************************************************** - * Configuration Menu - * - * Called when the user presses the Z Trigger on Pad 0 - * - * Options - * - * 1. Emulator Options - * 1.1 Select Screen Size - * 1.2 Select Palette - * 1.3 Timing - * 1.4 Reset NES - * - * 2. Save Game Manager - * 1.1 Save Current State - * 1.2 Load Existing State - * 1.3 Delete Save Game - * - * 3. Game Information - * 3.1 Show Game Info - * - * 4. Load ROM - * 4.1 Load ROM from DVD-R - ***************************************************************************/ - -void DrawMenu(char items[][30], int maxitems, int select) -{ - int i,w,p,h; - - ClearScreen(); - - /*** Draw Title Centred ***/ - - p = (480 - (maxitems * font_height)) / 2 + 10; - - for( i = 0; i < maxitems; i++ ) - { - w = CentreTextPosition(items[i]); - h = GetTextWidth(items[i]); - -/* if ( i == select ) - writex( w, p, h, font_height, items[i], blit_lookup_inv ); - else - writex( w, p, h, font_height, items[i], blit_lookup );*/ - - writex( w, p, h, font_height, items[i], i == select ); - - p += font_height; - } - - SetScreen(); -} - -/**************************************************************************** - * PADMap - * - * Remap a pad to the correct key - ****************************************************************************/ -extern unsigned short gcpadmap[12]; -char PADMap( int padvalue, int padnum ) -{ - char padkey; - - switch( padvalue ) - { - case 0: gcpadmap[padnum] = PAD_BUTTON_A; padkey = 'A'; break; - case 1: gcpadmap[padnum] = PAD_BUTTON_B; padkey = 'B'; break; - case 2: gcpadmap[padnum] = PAD_BUTTON_X; padkey = 'X'; break; - case 3: gcpadmap[padnum] = PAD_BUTTON_Y; padkey = 'Y'; break; - case 4: gcpadmap[padnum] = PAD_BUTTON_START; padkey = 'S'; break; - case 5: gcpadmap[padnum] = PAD_TRIGGER_Z; padkey = 'Z'; break; - } - - return padkey; -} - -/**************************************************************************** - * PAD Configuration - * - * This screen simply let's the user swap A/B/X/Y around. - ****************************************************************************/ - -int configpadcount = 10; -char padmenu[10][30] = { - { "NES BUTTON A - A" }, { " BUTTON B - B" }, { " START - S" }, - { " SELECT - Z" }, { " TURBO A - X" }, { " TURBO B - Y" }, - { " FOUR SCORE - OFF" }, { " ANALOG CLIP - 70"}, { " TURBO SPEED - 30.00 pps" }, - { "Return to previous" } -}; - -char mpads[2]; - -int PADCON = 0; - -void ConfigPAD() -{ - - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - int i; - - unsigned char text[][512] = { - //PAD Configuration - { "Configure Your Gamepad" }, - { "Up, up, down, down, left, right, left, right, B, A, start" } - }; - - for ( i = 0; i < 6; i++ ) - { - mpads[i] = padmenu[i][15] == 'A' ? 0 : - padmenu[i][15] == 'B' ? 1 : - padmenu[i][15] == 'X' ? 2 : - padmenu[i][15] == 'Y' ? 3 : - padmenu[i][15] == 'S' ? 4 : - padmenu[i][15] == 'Z' ? 5 : 0; - } - - line = 0; - scrollerx = 320 - MARGIN; - - while ( quit == 0 ) - { - if ( redraw ) DrawMenu(&padmenu[0], configpadcount, menu); - - redraw = 0; - j = PAD_ButtonsDown(0); - - if ( j & PAD_BUTTON_DOWN ) { - menu++; - redraw = 1; - } - - if ( j & PAD_BUTTON_UP ) { - menu--; - redraw = 1; - } - - if ( j & PAD_BUTTON_A ) { - redraw = 1; - switch( menu ) { - - case 0: i = 0; break; - - case 1: i = 1; break; - - case 2: i = 2; break; - - case 3: i = 3; break; - - case 4: i = 4; break; - - case 5: i = 5; break; - - case 6: i = -1; - FSDisable ^= 1; - if ( FSDisable ) - strcpy(padmenu[6], " FOUR SCORE - OFF"); - else - strcpy(padmenu[6], " FOUR SCORE - ON "); - - FCEUI_DisableFourScore(FSDisable); - break; - - case 7: i = -1; - PADCAL += 5; - if ( PADCAL > 90 ) - PADCAL = 40; - - sprintf(padmenu[7]," ANALOG CLIP - %d", PADCAL); - break; - - case 8: i = -1; - PADTUR += 1; - if ( PADTUR > 10 ) PADTUR += 4; - if ( PADTUR > 30 ) - PADTUR = 2; - - sprintf(padmenu[8]," TURBO SPEED - %.2f pps", (float)60/PADTUR); - break; - - case 9: quit=1; return; break; - default: break; - } - - if ( i >= 0 ) { - mpads[i]++; - if ( mpads[i] == 6 ) mpads[i] = 0; - - padmenu[i][15] = PADMap( mpads[i], i ); - } - } - - if ( menu < 0 ) menu = configpadcount - 1; - - if ( menu == configpadcount ) menu = 0; - - scroller(SCROLLY, &text[0], 2); - VIDEO_WaitVSync(); - } - - return; -} - -/**************************************************************************** - * Save Game Manager - ****************************************************************************/ - -int mccount = 5; -char mcmenu[5][30] = { - { "Use: SLOT A" }, { "Device: MCARD" }, - { "Save Game State" }, { "Load Game State" }, - { "Return to Main Menu" } -}; - -int slot = 0; -int device = 0; - -int StateManager() -{ - - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - //int i; - - unsigned char text[][512] = { - //Save game - { "From where do you wish to load/save your game?" }, - { "Hard time making up your mind?" } - }; - - line = 0; - scrollerx = 320 - MARGIN; - - while ( quit == 0 ) - { - - - if ( redraw ){ - sprintf(mcmenu[0], (slot == 0) ? "Use: SLOT A" : "Use: SLOT B"); - sprintf(mcmenu[1], (device == 0) ? "Device: MCARD" : "Device: SDCARD"); - DrawMenu(&mcmenu[0], mccount, menu); - } - - redraw = 0; - - j = PAD_ButtonsDown(0); - - if ( j & PAD_BUTTON_DOWN ) { - menu++; - redraw = 1; - } - - if ( j & PAD_BUTTON_UP ) { - menu--; - redraw = 1; - } - - if ( j & PAD_BUTTON_A ) { - redraw = 1; - switch( menu ) { - /*case 0 : CARDSLOT = CARD_SLOTA; MCManage(0); return 1; break; - case 1 : CARDSLOT = CARD_SLOTA; MCManage(1); return 1; break; - case 2 : CARDSLOT = CARD_SLOTB; MCManage(0); return 1; break; - case 3 : CARDSLOT = CARD_SLOTB; MCManage(1); return 1; break;*/ - case 0 : - slot ^= 1; - break; - case 1 : - device ^= 1; - break; - case 2 : - ManageState(0, slot, device); //Save - break; - case 3 : - ManageState(1, slot, device); //Load - break; - case 4 : - quit = 1;//return 0 ; - break; - default: - break; - } - } - - if ( menu < 0 ) - menu = mccount - 1; - - if ( menu == mccount ) - menu = 0; - - scroller(SCROLLY, &text[0], 2); - VIDEO_WaitVSync(); - - } - - return 0; -} - -/**************************************************************************** - * Video Enhancement Screen - ****************************************************************************/ - -int vecount = 5; -char vemenu[5][30] = { - { "Screen Scaler - GX" }, { "Palette - Default" }, - { "8 Sprite Limit - ON " },{ "Timing - NTSC" }, - { "Return to Main Menu" } -}; - -int VideoEnhancements() -{ - - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - int i; - unsigned char r,g,b; - - unsigned char text[][512] = { - //Screen Configurator - { "Wow, these colors and shapes sure are beautiful, brings back the memories." }, - { "Be sure not to mess these settings up, You don't want to ruin the experience! :D" } - }; - - line = 0; - scrollerx = 320 - MARGIN; - - while ( quit == 0) - { - if ( redraw ) - DrawMenu(&vemenu[0], vecount, menu ); - - redraw = 0; - - j = PAD_ButtonsDown(0); - - if ( j & PAD_BUTTON_DOWN ) { - menu++; - redraw = 1; - } - - if ( j & PAD_BUTTON_UP ) { - menu--; - redraw = 1; - } - - if ( j & PAD_BUTTON_A ) { - redraw = 1; - switch ( menu ) { - case 0: /*** Scaler ***/ - screenscaler++; - screenscaler = ( screenscaler > 2 ) ? 0 : screenscaler; - - switch ( screenscaler ) - { - case 2: strcpy(vemenu[0], "Screen Scaler - GX"); break; - case 1: strcpy(vemenu[0], "Screen Scaler - Cheesy"); break; - case 0: strcpy(vemenu[0], "Screen Scaler - 2x"); break; - } - break; - case 1: /*** Palette ***/ - currpal++; - if ( currpal > MAXPAL ) - currpal = 0; - - if ( currpal == 0 ) { - strcpy(vemenu[1],"Palette - Default"); - /*** Do palette reset ***/ - FCEU_ResetPalette(); - } else { - strcpy(vemenu[1],"Palette - "); - strcat(vemenu[1], palettes[currpal-1].name); - - /*** Now setup this palette ***/ - for ( i = 0; i < 64; i++ ) - { - r = palettes[currpal-1].data[i] >> 16; - g = ( palettes[currpal-1].data[i] & 0xff00 ) >> 8; - b = ( palettes[currpal-1].data[i] & 0xff ); - FCEUD_SetPalette( i, r, g, b); - FCEUD_SetPalette( i+64, r, g, b); - FCEUD_SetPalette( i+128, r, g, b); - FCEUD_SetPalette( i+192, r, g, b); - - } - } - - break; - - case 2: slimit ^=1; - if ( slimit ) - strcpy(vemenu[2], "8 Sprite Limit - ON "); - else - strcpy(vemenu[2], "8 Sprite Limit - OFF"); - FCEUI_DisableSpriteLimitation( slimit ); - break; - - case 3: timing ^= 1; - if ( timing ) - strcpy(vemenu[3], "Timing - PAL "); - else - strcpy(vemenu[3], "Timing - NTSC"); - - FCEUI_SetVidSystem( timing ); - - break; - - case 4: quit = 1; break; - - default: break; - - } - } - - if ( menu < 0 ) - menu = vecount - 1; - - if ( menu == vecount ) - menu = 0; - - scroller(SCROLLY, &text[0], 2); - VIDEO_WaitVSync(); - - } - - return 0; - -} - -/**************************************************************************** - * ROM Information - ****************************************************************************/ - -typedef struct { - char ID[4]; /*NES^Z*/ - u8 ROM_size; - u8 VROM_size; - u8 ROM_type; - u8 ROM_type2; - u8 reserve[8]; -} iNES_HEADER; - -extern int MapperNo; -extern iNES_HEADER head; -extern u32 ROM_size; -extern u32 VROM_size; -extern u32 iNESGameCRC32; -extern u8 iNESMirroring; - -void ShowROMInfo() -{ - - int i,p; - char *title = "ROM Information"; - char info[128]; - - ClearScreen(); - - p = (480 - (7 * font_height)) / 2 + 5; - - write_font( CentreTextPosition( title ), p, title ); - p += ( font_height << 1 ); - - for ( i = 0; i < 5; i++ ) - { - switch (i) { - case 0: sprintf(info, "ROM Size : %d", head.ROM_size ); break; - case 1: sprintf(info, "VROM Size : %d", head.VROM_size ); break; - case 2: sprintf(info, "iNES CRC : %08x", iNESGameCRC32 ); break; - case 3: sprintf(info, "Mapper : %d", MapperNo ); break; - case 4: sprintf(info, "Mirroring : %d", iNESMirroring );break; - } - - write_font( CentreTextPosition( info ), p, info ); - p+=font_height; - - } - - SetScreen(); - - while ( !(PAD_ButtonsDown(0) & PAD_BUTTON_A ) ) - - { VIDEO_WaitVSync(); } - -} - -/**************************************************************************** - * Media Select Screen - ****************************************************************************/ - -int mediacount = 3; -char mediamenu[3][30] = { - { "Load from DVD" }, { "Load from SDCARD"}, { "Return to previous" } -}; - -int MediaSelect() -{ - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - - unsigned char text[][512] = { - //Screen Configurator - { "What are You waiting for? Load some games!" }, - { "Still here?" }, - { "How can You wait this long?! The games are waiting for You!!" } - }; - - line = 0; - scrollerx = 320 - MARGIN; - - while ( quit == 0 ) - { - if ( redraw ) - DrawMenu(&mediamenu[0], mediacount, menu ); - - redraw = 0; - - j = PAD_ButtonsDown(0); - - if ( j & PAD_BUTTON_DOWN ) { - menu++; - redraw = 1; - } - - if ( j & PAD_BUTTON_UP ) { - menu--; - redraw = 1; - } - - if ( j & PAD_BUTTON_A ) { - redraw = 1; - switch ( menu ) { - case 0: UseSDCARD = 0; - OpenDVD(); - return 1; - break; - - case 1: UseSDCARD = 1; - OpenSD(); - return 1; - break; - - case 2: quit = 1; - break; - - default: break ; - } - } - - if ( menu == mediacount ) - menu = 0; - - if ( menu < 0 ) - menu = mediacount - 1; - - scroller(SCROLLY, &text[0], 3); - VIDEO_WaitVSync(); - - } - - return 0; -} - -/**************************************************************************** - * Configuration Screen - ****************************************************************************/ -int configmenucount = 10; -char configmenu[10][30] = { - { "Play Game" }, { "Game Information" }, { "Configure Joypads" }, - { "Video Options" }, { "Load new Game" }, { "Reset NES" }, - { "Stop DVD Motor" }, { "STATE Manager" }, { "PSO/SD Reload" } , - { "Credits" } -}; - -int ConfigScreen() -{ - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - - int *psoid = (int *) 0x80001800; - void (*PSOReload) () = (void (*)()) 0x80001800; - - unsigned char text[][512] = { - //ConfigScreen - { "FCE Ultra GameCube Edition - Version 1.0.8 \"SUPER-DELUXE\" ;)" }, - { "Press L + R anytime to return to this menu!" }, - { "Press START + B + X anytime for PSO/SD-reload" }, - { "* * *" }, - { "FCE Ultra GC is a modified port of the FCE Ultra 0.98.12 Nintendo Entertainment system for x86 (Windows/Linux) PC's. In English you can play NES games on your GameCube using either a softmod and/or modchip from a DVD or via a networked connection to your PC." }, - { "Disclaimer - Use at your own RISK!" }, - { "Official Homepage: http://www.tehskeen.net" } - }; - - char credits[][512] = { - { "Technical" }, - { "Gamecube port by softdev" }, - { "Original FCE by BERO" }, - { "FCE Ultra by Xodnizel" }, - { "DevkitPPC/libogc by wntrmute and shagkur" }, - { "IPLFont by Qoob" }, - { "DVD Codes Courtesy of Ninjamod" }, - { "Zlib by Jean-loup Gailly" }, - { "Miscellaneous addons and spelling errors by KruLLo" }, - //{ " " }, - { "Thank you to" }, - { "brakken, mithos, luciddream, HonkeyKong" }, - //{ " " }, - { "... and everyone who supported v1.0!" } }; - - - /*** Stop any running Audio ***/ - AUDIO_StopDMA(); - - line = 0; - scrollerx = 320 - MARGIN; - - while ( quit == 0 ) - { - if ( redraw ) - /*DrawMenu("FCEU GC Configuration", &configmenu[0], configmenucount, menu );*/ - DrawMenu(&configmenu[0], configmenucount, menu ); - - redraw = 0; - - while (menu == 9 && !(PAD_ButtonsDown(0) & PAD_BUTTON_UP) && !(PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)) - { scroller(SCROLLY, &credits[0], 12);VIDEO_WaitVSync(); } - - if (menu == 9) { - scrollerx = 320 - MARGIN; - line = 0; - } - - j = PAD_ButtonsDown(0); - - if (j & PAD_BUTTON_DOWN) { - menu++; - redraw = 1; - if (menu == 9) { - scrollerx = 320 - MARGIN; - line = 0; - } - } - - if (j & PAD_BUTTON_UP) { - menu--; - redraw = 1; - if (menu < 0) { - scrollerx = 320 - MARGIN; - line = 0; - } - } - - if (j & PAD_BUTTON_A ) { - redraw = 1; - switch ( menu ) { - case 0: quit = 1; break; - - case 1: ShowROMInfo(); break; - - case 2: ConfigPAD(); scrollerx = 320 - MARGIN; break; - - case 3: if (VideoEnhancements()) - return 2; - scrollerx = 320 - MARGIN; - break; - - case 4: if (MediaSelect()) { - GCMemROM(); /* Fix by Garglub. Thanks! */ - return 1; - } - scrollerx = 320 - MARGIN; - break; - - case 5: ResetNES(); - return 1; - break; - - case 6: ShowAction("Stopping Motor"); - dvd_motor_off(); - WaitPrompt("DVD Motor Stopped"); - break; - - case 7: if (StateManager()) - return 2; - scrollerx = 320 - MARGIN; - break; - - case 8: - PSOReload (); - break; - - case 9: break; - - default: break ; - } - } - - if ( menu == configmenucount ) - menu = 0; - - if ( menu < 0 ) - menu = configmenucount - 1; - - scroller(SCROLLY, &text[0], 7); - VIDEO_WaitVSync(); - - } - - /*** Remove any still held buttons ***/ - while(PAD_ButtonsHeld(0)) VIDEO_WaitVSync(); - - /*** Stop the DVD from causing clicks while playing ***/ - uselessinquiry (); - - return 0; -} - diff --git a/source/drivers/gamecube/info.c b/source/drivers/gamecube/info.c index 22809a1..7d0d167 100644 --- a/source/drivers/gamecube/info.c +++ b/source/drivers/gamecube/info.c @@ -3,7 +3,7 @@ * * Just own up to who did what ****************************************************************************/ - + #include #include #include @@ -59,230 +59,230 @@ extern unsigned char GetAnalog(int Joy); /* color palettes */ struct - { +{ char *name, *desc; unsigned int data[64]; - } +} palettes[] = { - /* The default NES palette must be the first entry in the array */ - { "loopy", "Loopy's NES palette", - { 0x757575, 0x271b8f, 0x0000ab, 0x47009f, - 0x8f0077, 0xab0013, 0xa70000, 0x7f0b00, - 0x432f00, 0x004700, 0x005100, 0x003f17, - 0x1b3f5f, 0x000000, 0x000000, 0x000000, - 0xbcbcbc, 0x0073ef, 0x233bef, 0x8300f3, - 0xbf00bf, 0xe7005b, 0xdb2b00, 0xcb4f0f, - 0x8b7300, 0x009700, 0x00ab00, 0x00933b, - 0x00838b, 0x000000, 0x000000, 0x000000, - 0xffffff, 0x3fbfff, 0x5f97ff, 0xa78bfd, - 0xf77bff, 0xff77b7, 0xff7763, 0xff9b3b, - 0xf3bf3f, 0x83d313, 0x4fdf4b, 0x58f898, - 0x00ebdb, 0x000000, 0x000000, 0x000000, - 0xffffff, 0xabe7ff, 0xc7d7ff, 0xd7cbff, - 0xffc7ff, 0xffc7db, 0xffbfb3, 0xffdbab, - 0xffe7a3, 0xe3ffa3, 0xabf3bf, 0xb3ffcf, - 0x9ffff3, 0x000000, 0x000000, 0x000000 } - }, - { "quor", "Quor's palette from Nestra 0.63", - { 0x3f3f3f, 0x001f3f, 0x00003f, 0x1f003f, - 0x3f003f, 0x3f0020, 0x3f0000, 0x3f2000, - 0x3f3f00, 0x203f00, 0x003f00, 0x003f20, - 0x003f3f, 0x000000, 0x000000, 0x000000, - 0x7f7f7f, 0x405f7f, 0x40407f, 0x5f407f, - 0x7f407f, 0x7f4060, 0x7f4040, 0x7f6040, - 0x7f7f40, 0x607f40, 0x407f40, 0x407f60, - 0x407f7f, 0x000000, 0x000000, 0x000000, - 0xbfbfbf, 0x809fbf, 0x8080bf, 0x9f80bf, - 0xbf80bf, 0xbf80a0, 0xbf8080, 0xbfa080, - 0xbfbf80, 0xa0bf80, 0x80bf80, 0x80bfa0, - 0x80bfbf, 0x000000, 0x000000, 0x000000, - 0xffffff, 0xc0dfff, 0xc0c0ff, 0xdfc0ff, - 0xffc0ff, 0xffc0e0, 0xffc0c0, 0xffe0c0, - 0xffffc0, 0xe0ffc0, 0xc0ffc0, 0xc0ffe0, - 0xc0ffff, 0x000000, 0x000000, 0x000000 } - }, - { "chris", "Chris Covell's NES palette", - { 0x808080, 0x003DA6, 0x0012B0, 0x440096, - 0xA1005E, 0xC70028, 0xBA0600, 0x8C1700, - 0x5C2F00, 0x104500, 0x054A00, 0x00472E, - 0x004166, 0x000000, 0x050505, 0x050505, - 0xC7C7C7, 0x0077FF, 0x2155FF, 0x8237FA, - 0xEB2FB5, 0xFF2950, 0xFF2200, 0xD63200, - 0xC46200, 0x358000, 0x058F00, 0x008A55, - 0x0099CC, 0x212121, 0x090909, 0x090909, - 0xFFFFFF, 0x0FD7FF, 0x69A2FF, 0xD480FF, - 0xFF45F3, 0xFF618B, 0xFF8833, 0xFF9C12, - 0xFABC20, 0x9FE30E, 0x2BF035, 0x0CF0A4, - 0x05FBFF, 0x5E5E5E, 0x0D0D0D, 0x0D0D0D, - 0xFFFFFF, 0xA6FCFF, 0xB3ECFF, 0xDAABEB, - 0xFFA8F9, 0xFFABB3, 0xFFD2B0, 0xFFEFA6, - 0xFFF79C, 0xD7E895, 0xA6EDAF, 0xA2F2DA, - 0x99FFFC, 0xDDDDDD, 0x111111, 0x111111 } - }, - { "matt", "Matthew Conte's NES palette", - { 0x808080, 0x0000bb, 0x3700bf, 0x8400a6, - 0xbb006a, 0xb7001e, 0xb30000, 0x912600, - 0x7b2b00, 0x003e00, 0x00480d, 0x003c22, - 0x002f66, 0x000000, 0x050505, 0x050505, - 0xc8c8c8, 0x0059ff, 0x443cff, 0xb733cc, - 0xff33aa, 0xff375e, 0xff371a, 0xd54b00, - 0xc46200, 0x3c7b00, 0x1e8415, 0x009566, - 0x0084c4, 0x111111, 0x090909, 0x090909, - 0xffffff, 0x0095ff, 0x6f84ff, 0xd56fff, - 0xff77cc, 0xff6f99, 0xff7b59, 0xff915f, - 0xffa233, 0xa6bf00, 0x51d96a, 0x4dd5ae, - 0x00d9ff, 0x666666, 0x0d0d0d, 0x0d0d0d, - 0xffffff, 0x84bfff, 0xbbbbff, 0xd0bbff, - 0xffbfea, 0xffbfcc, 0xffc4b7, 0xffccae, - 0xffd9a2, 0xcce199, 0xaeeeb7, 0xaaf7ee, - 0xb3eeff, 0xdddddd, 0x111111, 0x111111 } - }, - { "pasofami", "Palette from PasoFami/99", - { 0x7f7f7f, 0x0000ff, 0x0000bf, 0x472bbf, - 0x970087, 0xab0023, 0xab1300, 0x8b1700, - 0x533000, 0x007800, 0x006b00, 0x005b00, - 0x004358, 0x000000, 0x000000, 0x000000, - 0xbfbfbf, 0x0078f8, 0x0058f8, 0x6b47ff, - 0xdb00cd, 0xe7005b, 0xf83800, 0xe75f13, - 0xaf7f00, 0x00b800, 0x00ab00, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x000000, - 0xf8f8f8, 0x3fbfff, 0x6b88ff, 0x9878f8, - 0xf878f8, 0xf85898, 0xf87858, 0xffa347, - 0xf8b800, 0xb8f818, 0x5bdb57, 0x58f898, - 0x00ebdb, 0x787878, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xd8b8f8, - 0xf8b8f8, 0xfba7c3, 0xf0d0b0, 0xffe3ab, - 0xfbdb7b, 0xd8f878, 0xb8f8b8, 0xb8f8d8, - 0x00ffff, 0xf8d8f8, 0x000000, 0x000000 } - }, - { "crashman", "CrashMan's NES palette", - { 0x585858, 0x001173, 0x000062, 0x472bbf, - 0x970087, 0x910009, 0x6f1100, 0x4c1008, - 0x371e00, 0x002f00, 0x005500, 0x004d15, - 0x002840, 0x000000, 0x000000, 0x000000, - 0xa0a0a0, 0x004499, 0x2c2cc8, 0x590daa, - 0xae006a, 0xb00040, 0xb83418, 0x983010, - 0x704000, 0x308000, 0x207808, 0x007b33, - 0x1c6888, 0x000000, 0x000000, 0x000000, - 0xf8f8f8, 0x267be1, 0x5870f0, 0x9878f8, - 0xff73c8, 0xf060a8, 0xd07b37, 0xe09040, - 0xf8b300, 0x8cbc00, 0x40a858, 0x58f898, - 0x00b7bf, 0x787878, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xd8b8f8, - 0xe6a6ff, 0xf29dc4, 0xf0c0b0, 0xfce4b0, - 0xe0e01e, 0xd8f878, 0xc0e890, 0x95f7c8, - 0x98e0e8, 0xf8d8f8, 0x000000, 0x000000 } - }, - { "mess", "palette from the MESS NES driver", - { 0x747474, 0x24188c, 0x0000a8, 0x44009c, - 0x8c0074, 0xa80010, 0xa40000, 0x7c0800, - 0x402c00, 0x004400, 0x005000, 0x003c14, - 0x183c5c, 0x000000, 0x000000, 0x000000, - 0xbcbcbc, 0x0070ec, 0x2038ec, 0x8000f0, - 0xbc00bc, 0xe40058, 0xd82800, 0xc84c0c, - 0x887000, 0x009400, 0x00a800, 0x009038, - 0x008088, 0x000000, 0x000000, 0x000000, - 0xfcfcfc, 0x3cbcfc, 0x5c94fc, 0x4088fc, - 0xf478fc, 0xfc74b4, 0xfc7460, 0xfc9838, - 0xf0bc3c, 0x80d010, 0x4cdc48, 0x58f898, - 0x00e8d8, 0x000000, 0x000000, 0x000000, - 0xfcfcfc, 0xa8e4fc, 0xc4d4fc, 0xd4c8fc, - 0xfcc4fc, 0xfcc4d8, 0xfcbcb0, 0xfcd8a8, - 0xfce4a0, 0xe0fca0, 0xa8f0bc, 0xb0fccc, - 0x9cfcf0, 0x000000, 0x000000, 0x000000 } - }, - { "zaphod-cv", "Zaphod's VS Castlevania palette", - { 0x7f7f7f, 0xffa347, 0x0000bf, 0x472bbf, - 0x970087, 0xf85898, 0xab1300, 0xf8b8f8, - 0xbf0000, 0x007800, 0x006b00, 0x005b00, - 0xffffff, 0x9878f8, 0x000000, 0x000000, - 0xbfbfbf, 0x0078f8, 0xab1300, 0x6b47ff, - 0x00ae00, 0xe7005b, 0xf83800, 0x7777ff, - 0xaf7f00, 0x00b800, 0x00ab00, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x472bbf, - 0xf8f8f8, 0xffe3ab, 0xf87858, 0x9878f8, - 0x0078f8, 0xf85898, 0xbfbfbf, 0xffa347, - 0xc800c8, 0xb8f818, 0x7f7f7f, 0x007800, - 0x00ebdb, 0x000000, 0x000000, 0xffffff, - 0xffffff, 0xa7e7ff, 0x5bdb57, 0xe75f13, - 0x004358, 0x0000ff, 0xe7005b, 0x00b800, - 0xfbdb7b, 0xd8f878, 0x8b1700, 0xffe3ab, - 0x00ffff, 0xab0023, 0x000000, 0x000000 } - }, - { "zaphod-smb", "Zaphod's VS SMB palette", - { 0x626a00, 0x0000ff, 0x006a77, 0x472bbf, - 0x970087, 0xab0023, 0xab1300, 0xb74800, - 0xa2a2a2, 0x007800, 0x006b00, 0x005b00, - 0xffd599, 0xffff00, 0x009900, 0x000000, - 0xff66ff, 0x0078f8, 0x0058f8, 0x6b47ff, - 0x000000, 0xe7005b, 0xf83800, 0xe75f13, - 0xaf7f00, 0x00b800, 0x5173ff, 0x00ab47, - 0x008b8b, 0x000000, 0x91ff88, 0x000088, - 0xf8f8f8, 0x3fbfff, 0x6b0000, 0x4855f8, - 0xf878f8, 0xf85898, 0x595958, 0xff009d, - 0x002f2f, 0xb8f818, 0x5bdb57, 0x58f898, - 0x00ebdb, 0x787878, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0x590400, 0xbb0000, - 0xf8b8f8, 0xfba7c3, 0xffffff, 0x00e3e1, - 0xfbdb7b, 0xffae00, 0xb8f8b8, 0xb8f8d8, - 0x00ff00, 0xf8d8f8, 0xffaaaa, 0x004000 } - }, - { "vs-drmar", "VS Dr. Mario palette", - { 0x5f97ff, 0x000000, 0x000000, 0x47009f, - 0x00ab00, 0xffffff, 0xabe7ff, 0x000000, - 0x000000, 0x000000, 0x000000, 0x000000, - 0xe7005b, 0x000000, 0x000000, 0x000000, - 0x5f97ff, 0x000000, 0x000000, 0x000000, - 0x000000, 0x8b7300, 0xcb4f0f, 0x000000, - 0xbcbcbc, 0x000000, 0x000000, 0x000000, - 0x000000, 0x000000, 0x000000, 0x000000, - 0x00ebdb, 0x000000, 0x000000, 0x000000, - 0x000000, 0xff9b3b, 0x000000, 0x000000, - 0x83d313, 0x000000, 0x3fbfff, 0x000000, - 0x0073ef, 0x000000, 0x000000, 0x000000, - 0x00ebdb, 0x000000, 0x000000, 0x000000, - 0x000000, 0x000000, 0xf3bf3f, 0x000000, - 0x005100, 0x000000, 0xc7d7ff, 0xffdbab, - 0x000000, 0x000000, 0x000000, 0x000000 } - }, - { "vs-cv", "VS Castlevania palette", - { 0xaf7f00, 0xffa347, 0x008b8b, 0x472bbf, - 0x970087, 0xf85898, 0xab1300, 0xf8b8f8, - 0xf83800, 0x007800, 0x006b00, 0x005b00, - 0xffffff, 0x9878f8, 0x00ab00, 0x000000, - 0xbfbfbf, 0x0078f8, 0xab1300, 0x6b47ff, - 0x000000, 0xe7005b, 0xf83800, 0x6b88ff, - 0xaf7f00, 0x00b800, 0x6b88ff, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x472bbf, - 0xf8f8f8, 0xffe3ab, 0xf87858, 0x9878f8, - 0x0078f8, 0xf85898, 0xbfbfbf, 0xffa347, - 0x004358, 0xb8f818, 0x7f7f7f, 0x007800, - 0x00ebdb, 0x000000, 0x000000, 0xffffff, - 0xffffff, 0xa7e7ff, 0x5bdb57, 0x6b88ff, - 0x004358, 0x0000ff, 0xe7005b, 0x00b800, - 0xfbdb7b, 0xffa347, 0x8b1700, 0xffe3ab, - 0xb8f818, 0xab0023, 0x000000, 0x007800 } - }, -/* The default VS palette must be the last entry in the array */ - { "vs-smb", "VS SMB/VS Ice Climber palette", - { 0xaf7f00, 0x0000ff, 0x008b8b, 0x472bbf, - 0x970087, 0xab0023, 0x0000ff, 0xe75f13, - 0xbfbfbf, 0x007800, 0x5bdb57, 0x005b00, - 0xf0d0b0, 0xffe3ab, 0x00ab00, 0x000000, - 0xbfbfbf, 0x0078f8, 0x0058f8, 0x6b47ff, - 0x000000, 0xe7005b, 0xf83800, 0xf87858, - 0xaf7f00, 0x00b800, 0x6b88ff, 0x00ab47, - 0x008b8b, 0x000000, 0x000000, 0x3fbfff, - 0xf8f8f8, 0x006b00, 0x8b1700, 0x9878f8, - 0x6b47ff, 0xf85898, 0x7f7f7f, 0xe7005b, - 0x004358, 0xb8f818, 0x0078f8, 0x58f898, - 0x00ebdb, 0xfbdb7b, 0x000000, 0x000000, - 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xf83800, - 0xf8b8f8, 0xfba7c3, 0xffffff, 0x00ffff, - 0xfbdb7b, 0xffa347, 0xb8f8b8, 0xb8f8d8, - 0xb8f818, 0xf8d8f8, 0x000000, 0x007800 } - } + /* The default NES palette must be the first entry in the array */ + { "loopy", "Loopy's NES palette", + { 0x757575, 0x271b8f, 0x0000ab, 0x47009f, + 0x8f0077, 0xab0013, 0xa70000, 0x7f0b00, + 0x432f00, 0x004700, 0x005100, 0x003f17, + 0x1b3f5f, 0x000000, 0x000000, 0x000000, + 0xbcbcbc, 0x0073ef, 0x233bef, 0x8300f3, + 0xbf00bf, 0xe7005b, 0xdb2b00, 0xcb4f0f, + 0x8b7300, 0x009700, 0x00ab00, 0x00933b, + 0x00838b, 0x000000, 0x000000, 0x000000, + 0xffffff, 0x3fbfff, 0x5f97ff, 0xa78bfd, + 0xf77bff, 0xff77b7, 0xff7763, 0xff9b3b, + 0xf3bf3f, 0x83d313, 0x4fdf4b, 0x58f898, + 0x00ebdb, 0x000000, 0x000000, 0x000000, + 0xffffff, 0xabe7ff, 0xc7d7ff, 0xd7cbff, + 0xffc7ff, 0xffc7db, 0xffbfb3, 0xffdbab, + 0xffe7a3, 0xe3ffa3, 0xabf3bf, 0xb3ffcf, + 0x9ffff3, 0x000000, 0x000000, 0x000000 } + }, + { "quor", "Quor's palette from Nestra 0.63", + { 0x3f3f3f, 0x001f3f, 0x00003f, 0x1f003f, + 0x3f003f, 0x3f0020, 0x3f0000, 0x3f2000, + 0x3f3f00, 0x203f00, 0x003f00, 0x003f20, + 0x003f3f, 0x000000, 0x000000, 0x000000, + 0x7f7f7f, 0x405f7f, 0x40407f, 0x5f407f, + 0x7f407f, 0x7f4060, 0x7f4040, 0x7f6040, + 0x7f7f40, 0x607f40, 0x407f40, 0x407f60, + 0x407f7f, 0x000000, 0x000000, 0x000000, + 0xbfbfbf, 0x809fbf, 0x8080bf, 0x9f80bf, + 0xbf80bf, 0xbf80a0, 0xbf8080, 0xbfa080, + 0xbfbf80, 0xa0bf80, 0x80bf80, 0x80bfa0, + 0x80bfbf, 0x000000, 0x000000, 0x000000, + 0xffffff, 0xc0dfff, 0xc0c0ff, 0xdfc0ff, + 0xffc0ff, 0xffc0e0, 0xffc0c0, 0xffe0c0, + 0xffffc0, 0xe0ffc0, 0xc0ffc0, 0xc0ffe0, + 0xc0ffff, 0x000000, 0x000000, 0x000000 } + }, + { "chris", "Chris Covell's NES palette", + { 0x808080, 0x003DA6, 0x0012B0, 0x440096, + 0xA1005E, 0xC70028, 0xBA0600, 0x8C1700, + 0x5C2F00, 0x104500, 0x054A00, 0x00472E, + 0x004166, 0x000000, 0x050505, 0x050505, + 0xC7C7C7, 0x0077FF, 0x2155FF, 0x8237FA, + 0xEB2FB5, 0xFF2950, 0xFF2200, 0xD63200, + 0xC46200, 0x358000, 0x058F00, 0x008A55, + 0x0099CC, 0x212121, 0x090909, 0x090909, + 0xFFFFFF, 0x0FD7FF, 0x69A2FF, 0xD480FF, + 0xFF45F3, 0xFF618B, 0xFF8833, 0xFF9C12, + 0xFABC20, 0x9FE30E, 0x2BF035, 0x0CF0A4, + 0x05FBFF, 0x5E5E5E, 0x0D0D0D, 0x0D0D0D, + 0xFFFFFF, 0xA6FCFF, 0xB3ECFF, 0xDAABEB, + 0xFFA8F9, 0xFFABB3, 0xFFD2B0, 0xFFEFA6, + 0xFFF79C, 0xD7E895, 0xA6EDAF, 0xA2F2DA, + 0x99FFFC, 0xDDDDDD, 0x111111, 0x111111 } + }, + { "matt", "Matthew Conte's NES palette", + { 0x808080, 0x0000bb, 0x3700bf, 0x8400a6, + 0xbb006a, 0xb7001e, 0xb30000, 0x912600, + 0x7b2b00, 0x003e00, 0x00480d, 0x003c22, + 0x002f66, 0x000000, 0x050505, 0x050505, + 0xc8c8c8, 0x0059ff, 0x443cff, 0xb733cc, + 0xff33aa, 0xff375e, 0xff371a, 0xd54b00, + 0xc46200, 0x3c7b00, 0x1e8415, 0x009566, + 0x0084c4, 0x111111, 0x090909, 0x090909, + 0xffffff, 0x0095ff, 0x6f84ff, 0xd56fff, + 0xff77cc, 0xff6f99, 0xff7b59, 0xff915f, + 0xffa233, 0xa6bf00, 0x51d96a, 0x4dd5ae, + 0x00d9ff, 0x666666, 0x0d0d0d, 0x0d0d0d, + 0xffffff, 0x84bfff, 0xbbbbff, 0xd0bbff, + 0xffbfea, 0xffbfcc, 0xffc4b7, 0xffccae, + 0xffd9a2, 0xcce199, 0xaeeeb7, 0xaaf7ee, + 0xb3eeff, 0xdddddd, 0x111111, 0x111111 } + }, + { "pasofami", "Palette from PasoFami/99", + { 0x7f7f7f, 0x0000ff, 0x0000bf, 0x472bbf, + 0x970087, 0xab0023, 0xab1300, 0x8b1700, + 0x533000, 0x007800, 0x006b00, 0x005b00, + 0x004358, 0x000000, 0x000000, 0x000000, + 0xbfbfbf, 0x0078f8, 0x0058f8, 0x6b47ff, + 0xdb00cd, 0xe7005b, 0xf83800, 0xe75f13, + 0xaf7f00, 0x00b800, 0x00ab00, 0x00ab47, + 0x008b8b, 0x000000, 0x000000, 0x000000, + 0xf8f8f8, 0x3fbfff, 0x6b88ff, 0x9878f8, + 0xf878f8, 0xf85898, 0xf87858, 0xffa347, + 0xf8b800, 0xb8f818, 0x5bdb57, 0x58f898, + 0x00ebdb, 0x787878, 0x000000, 0x000000, + 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xd8b8f8, + 0xf8b8f8, 0xfba7c3, 0xf0d0b0, 0xffe3ab, + 0xfbdb7b, 0xd8f878, 0xb8f8b8, 0xb8f8d8, + 0x00ffff, 0xf8d8f8, 0x000000, 0x000000 } + }, + { "crashman", "CrashMan's NES palette", + { 0x585858, 0x001173, 0x000062, 0x472bbf, + 0x970087, 0x910009, 0x6f1100, 0x4c1008, + 0x371e00, 0x002f00, 0x005500, 0x004d15, + 0x002840, 0x000000, 0x000000, 0x000000, + 0xa0a0a0, 0x004499, 0x2c2cc8, 0x590daa, + 0xae006a, 0xb00040, 0xb83418, 0x983010, + 0x704000, 0x308000, 0x207808, 0x007b33, + 0x1c6888, 0x000000, 0x000000, 0x000000, + 0xf8f8f8, 0x267be1, 0x5870f0, 0x9878f8, + 0xff73c8, 0xf060a8, 0xd07b37, 0xe09040, + 0xf8b300, 0x8cbc00, 0x40a858, 0x58f898, + 0x00b7bf, 0x787878, 0x000000, 0x000000, + 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xd8b8f8, + 0xe6a6ff, 0xf29dc4, 0xf0c0b0, 0xfce4b0, + 0xe0e01e, 0xd8f878, 0xc0e890, 0x95f7c8, + 0x98e0e8, 0xf8d8f8, 0x000000, 0x000000 } + }, + { "mess", "palette from the MESS NES driver", + { 0x747474, 0x24188c, 0x0000a8, 0x44009c, + 0x8c0074, 0xa80010, 0xa40000, 0x7c0800, + 0x402c00, 0x004400, 0x005000, 0x003c14, + 0x183c5c, 0x000000, 0x000000, 0x000000, + 0xbcbcbc, 0x0070ec, 0x2038ec, 0x8000f0, + 0xbc00bc, 0xe40058, 0xd82800, 0xc84c0c, + 0x887000, 0x009400, 0x00a800, 0x009038, + 0x008088, 0x000000, 0x000000, 0x000000, + 0xfcfcfc, 0x3cbcfc, 0x5c94fc, 0x4088fc, + 0xf478fc, 0xfc74b4, 0xfc7460, 0xfc9838, + 0xf0bc3c, 0x80d010, 0x4cdc48, 0x58f898, + 0x00e8d8, 0x000000, 0x000000, 0x000000, + 0xfcfcfc, 0xa8e4fc, 0xc4d4fc, 0xd4c8fc, + 0xfcc4fc, 0xfcc4d8, 0xfcbcb0, 0xfcd8a8, + 0xfce4a0, 0xe0fca0, 0xa8f0bc, 0xb0fccc, + 0x9cfcf0, 0x000000, 0x000000, 0x000000 } + }, + { "zaphod-cv", "Zaphod's VS Castlevania palette", + { 0x7f7f7f, 0xffa347, 0x0000bf, 0x472bbf, + 0x970087, 0xf85898, 0xab1300, 0xf8b8f8, + 0xbf0000, 0x007800, 0x006b00, 0x005b00, + 0xffffff, 0x9878f8, 0x000000, 0x000000, + 0xbfbfbf, 0x0078f8, 0xab1300, 0x6b47ff, + 0x00ae00, 0xe7005b, 0xf83800, 0x7777ff, + 0xaf7f00, 0x00b800, 0x00ab00, 0x00ab47, + 0x008b8b, 0x000000, 0x000000, 0x472bbf, + 0xf8f8f8, 0xffe3ab, 0xf87858, 0x9878f8, + 0x0078f8, 0xf85898, 0xbfbfbf, 0xffa347, + 0xc800c8, 0xb8f818, 0x7f7f7f, 0x007800, + 0x00ebdb, 0x000000, 0x000000, 0xffffff, + 0xffffff, 0xa7e7ff, 0x5bdb57, 0xe75f13, + 0x004358, 0x0000ff, 0xe7005b, 0x00b800, + 0xfbdb7b, 0xd8f878, 0x8b1700, 0xffe3ab, + 0x00ffff, 0xab0023, 0x000000, 0x000000 } + }, + { "zaphod-smb", "Zaphod's VS SMB palette", + { 0x626a00, 0x0000ff, 0x006a77, 0x472bbf, + 0x970087, 0xab0023, 0xab1300, 0xb74800, + 0xa2a2a2, 0x007800, 0x006b00, 0x005b00, + 0xffd599, 0xffff00, 0x009900, 0x000000, + 0xff66ff, 0x0078f8, 0x0058f8, 0x6b47ff, + 0x000000, 0xe7005b, 0xf83800, 0xe75f13, + 0xaf7f00, 0x00b800, 0x5173ff, 0x00ab47, + 0x008b8b, 0x000000, 0x91ff88, 0x000088, + 0xf8f8f8, 0x3fbfff, 0x6b0000, 0x4855f8, + 0xf878f8, 0xf85898, 0x595958, 0xff009d, + 0x002f2f, 0xb8f818, 0x5bdb57, 0x58f898, + 0x00ebdb, 0x787878, 0x000000, 0x000000, + 0xffffff, 0xa7e7ff, 0x590400, 0xbb0000, + 0xf8b8f8, 0xfba7c3, 0xffffff, 0x00e3e1, + 0xfbdb7b, 0xffae00, 0xb8f8b8, 0xb8f8d8, + 0x00ff00, 0xf8d8f8, 0xffaaaa, 0x004000 } + }, + { "vs-drmar", "VS Dr. Mario palette", + { 0x5f97ff, 0x000000, 0x000000, 0x47009f, + 0x00ab00, 0xffffff, 0xabe7ff, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, + 0xe7005b, 0x000000, 0x000000, 0x000000, + 0x5f97ff, 0x000000, 0x000000, 0x000000, + 0x000000, 0x8b7300, 0xcb4f0f, 0x000000, + 0xbcbcbc, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, + 0x00ebdb, 0x000000, 0x000000, 0x000000, + 0x000000, 0xff9b3b, 0x000000, 0x000000, + 0x83d313, 0x000000, 0x3fbfff, 0x000000, + 0x0073ef, 0x000000, 0x000000, 0x000000, + 0x00ebdb, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0xf3bf3f, 0x000000, + 0x005100, 0x000000, 0xc7d7ff, 0xffdbab, + 0x000000, 0x000000, 0x000000, 0x000000 } + }, + { "vs-cv", "VS Castlevania palette", + { 0xaf7f00, 0xffa347, 0x008b8b, 0x472bbf, + 0x970087, 0xf85898, 0xab1300, 0xf8b8f8, + 0xf83800, 0x007800, 0x006b00, 0x005b00, + 0xffffff, 0x9878f8, 0x00ab00, 0x000000, + 0xbfbfbf, 0x0078f8, 0xab1300, 0x6b47ff, + 0x000000, 0xe7005b, 0xf83800, 0x6b88ff, + 0xaf7f00, 0x00b800, 0x6b88ff, 0x00ab47, + 0x008b8b, 0x000000, 0x000000, 0x472bbf, + 0xf8f8f8, 0xffe3ab, 0xf87858, 0x9878f8, + 0x0078f8, 0xf85898, 0xbfbfbf, 0xffa347, + 0x004358, 0xb8f818, 0x7f7f7f, 0x007800, + 0x00ebdb, 0x000000, 0x000000, 0xffffff, + 0xffffff, 0xa7e7ff, 0x5bdb57, 0x6b88ff, + 0x004358, 0x0000ff, 0xe7005b, 0x00b800, + 0xfbdb7b, 0xffa347, 0x8b1700, 0xffe3ab, + 0xb8f818, 0xab0023, 0x000000, 0x007800 } + }, + /* The default VS palette must be the last entry in the array */ + { "vs-smb", "VS SMB/VS Ice Climber palette", + { 0xaf7f00, 0x0000ff, 0x008b8b, 0x472bbf, + 0x970087, 0xab0023, 0x0000ff, 0xe75f13, + 0xbfbfbf, 0x007800, 0x5bdb57, 0x005b00, + 0xf0d0b0, 0xffe3ab, 0x00ab00, 0x000000, + 0xbfbfbf, 0x0078f8, 0x0058f8, 0x6b47ff, + 0x000000, 0xe7005b, 0xf83800, 0xf87858, + 0xaf7f00, 0x00b800, 0x6b88ff, 0x00ab47, + 0x008b8b, 0x000000, 0x000000, 0x3fbfff, + 0xf8f8f8, 0x006b00, 0x8b1700, 0x9878f8, + 0x6b47ff, 0xf85898, 0x7f7f7f, 0xe7005b, + 0x004358, 0xb8f818, 0x0078f8, 0x58f898, + 0x00ebdb, 0xfbdb7b, 0x000000, 0x000000, + 0xffffff, 0xa7e7ff, 0xb8b8f8, 0xf83800, + 0xf8b8f8, 0xfba7c3, 0xffffff, 0x00ffff, + 0xfbdb7b, 0xffa347, 0xb8f8b8, 0xb8f8d8, + 0xb8f818, 0xf8d8f8, 0x000000, 0x007800 } + } }; extern int whichfb; @@ -292,7 +292,7 @@ extern int font_size[256]; extern int font_height; extern int screenscaler; /*extern long blit_lookup[4]; -extern long blit_lookup_inv[4];*/ + extern long blit_lookup_inv[4];*/ /**************************************************************************** * SetScreen @@ -301,17 +301,17 @@ extern long blit_lookup_inv[4];*/ void SetScreen() { - VIDEO_SetNextFramebuffer( xfb[whichfb] ); - VIDEO_Flush(); - VIDEO_WaitVSync(); + VIDEO_SetNextFramebuffer( xfb[whichfb] ); + VIDEO_Flush(); + VIDEO_WaitVSync(); } void ClearScreen() { - whichfb ^= 1; - /*VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], 0x258e2573);*/ - memcpy (xfb[whichfb], &backdrop, 1280 * 480); + whichfb ^= 1; + /*VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], 0x258e2573);*/ + memcpy (xfb[whichfb], &backdrop, 1280 * 480); } /*************************************************************************** @@ -341,30 +341,30 @@ void ClearScreen() void DrawMenu(char items[][30], int maxitems, int select) { - int i,w,p,h; + int i,w,p,h; - ClearScreen(); + ClearScreen(); - /*** Draw Title Centred ***/ + /*** Draw Title Centred ***/ - p = (480 - (maxitems * font_height)) / 2 + 10; + p = (480 - (maxitems * font_height)) / 2 + 10; - for( i = 0; i < maxitems; i++ ) - { - w = CentreTextPosition(items[i]); - h = GetTextWidth(items[i]); + for( i = 0; i < maxitems; i++ ) + { + w = CentreTextPosition(items[i]); + h = GetTextWidth(items[i]); -/* if ( i == select ) - writex( w, p, h, font_height, items[i], blit_lookup_inv ); - else - writex( w, p, h, font_height, items[i], blit_lookup );*/ + /* if ( i == select ) + writex( w, p, h, font_height, items[i], blit_lookup_inv ); + else + writex( w, p, h, font_height, items[i], blit_lookup );*/ - writex( w, p, h, font_height, items[i], i == select ); + writex( w, p, h, font_height, items[i], i == select ); - p += font_height; - } + p += font_height; + } - SetScreen(); + SetScreen(); } /**************************************************************************** @@ -375,19 +375,19 @@ void DrawMenu(char items[][30], int maxitems, int select) extern unsigned short gcpadmap[12]; char PADMap( int padvalue, int padnum ) { - char padkey; + char padkey; - switch( padvalue ) - { - case 0: gcpadmap[padnum] = PAD_BUTTON_A; padkey = 'A'; break; - case 1: gcpadmap[padnum] = PAD_BUTTON_B; padkey = 'B'; break; - case 2: gcpadmap[padnum] = PAD_BUTTON_X; padkey = 'X'; break; - case 3: gcpadmap[padnum] = PAD_BUTTON_Y; padkey = 'Y'; break; - case 4: gcpadmap[padnum] = PAD_BUTTON_START; padkey = 'S'; break; - case 5: gcpadmap[padnum] = PAD_TRIGGER_Z; padkey = 'Z'; break; - } + switch( padvalue ) + { + case 0: gcpadmap[padnum] = PAD_BUTTON_A; padkey = 'A'; break; + case 1: gcpadmap[padnum] = PAD_BUTTON_B; padkey = 'B'; break; + case 2: gcpadmap[padnum] = PAD_BUTTON_X; padkey = 'X'; break; + case 3: gcpadmap[padnum] = PAD_BUTTON_Y; padkey = 'Y'; break; + case 4: gcpadmap[padnum] = PAD_BUTTON_START; padkey = 'S'; break; + case 5: gcpadmap[padnum] = PAD_TRIGGER_Z; padkey = 'Z'; break; + } - return padkey; + return padkey; } /**************************************************************************** @@ -395,19 +395,19 @@ char PADMap( int padvalue, int padnum ) * * This screen simply let's the user swap A/B/X/Y around. ****************************************************************************/ - + int configpadcount = 10; char padmenu[10][30] = { - { "NES BUTTON A - A" }, { " BUTTON B - B" }, { " START - S" }, - { " SELECT - Z" }, { " TURBO A - X" }, { " TURBO B - Y" }, - { " FOUR SCORE - OFF" }, { " ANALOG CLIP - 40"}, { " TURBO SPEED - 30.00 pps" }, - { "Return to previous" } + { "NES BUTTON A - A" }, { " BUTTON B - B" }, { " START - S" }, + { " SELECT - Z" }, { " TURBO A - X" }, { " TURBO B - Y" }, + { " FOUR SCORE - OFF" }, { " ANALOG CLIP - 40"}, { " TURBO SPEED - 30.00 pps" }, + { "Return to previous" } }; unsigned char text[][512] = { - //PAD Configuration - { "Configure Your Gamepad" }, - { "Up, up, down, down, left, right, left, right, B, A, start" } + //PAD Configuration + { "Configure Your Gamepad" }, + { "Up, up, down, down, left, right, left, right, B, A, start" } }; @@ -418,24 +418,24 @@ int PADCON = 0; void ConfigPAD() { - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - int i; + int menu = 0; + int quit = 0; + short j; + int redraw = 1; + int i; - for ( i = 0; i < 6; i++ ) - { - mpads[i] = padmenu[i][15] == 'A' ? 0 : - padmenu[i][15] == 'B' ? 1 : - padmenu[i][15] == 'X' ? 2 : - padmenu[i][15] == 'Y' ? 3 : - padmenu[i][15] == 'S' ? 4 : - padmenu[i][15] == 'Z' ? 5 : 0; - } + for ( i = 0; i < 6; i++ ) + { + mpads[i] = padmenu[i][15] == 'A' ? 0 : + padmenu[i][15] == 'B' ? 1 : + padmenu[i][15] == 'X' ? 2 : + padmenu[i][15] == 'Y' ? 3 : + padmenu[i][15] == 'S' ? 4 : + padmenu[i][15] == 'Z' ? 5 : 0; + } - line = 0; - scrollerx = 320 - MARGIN; + line = 0; + scrollerx = 320 - MARGIN; while ( quit == 0 ) { @@ -443,7 +443,7 @@ void ConfigPAD() redraw = 0; j = PAD_ButtonsDown(0); - + if ( j & PAD_BUTTON_DOWN ) { menu++; redraw = 1; @@ -456,59 +456,59 @@ void ConfigPAD() if ( j & PAD_BUTTON_A ) { redraw = 1; - switch( menu ) { + switch( menu ) { - case 0: i = 0; break; + case 0: i = 0; break; - case 1: i = 1; break; + case 1: i = 1; break; - case 2: i = 2; break; + case 2: i = 2; break; - case 3: i = 3; break; + case 3: i = 3; break; - case 4: i = 4; break; + case 4: i = 4; break; - case 5: i = 5; break; + case 5: i = 5; break; - case 6: i = -1; - FSDisable ^= 1; - if ( FSDisable ) - strcpy(padmenu[6], " FOUR SCORE - OFF"); - else - strcpy(padmenu[6], " FOUR SCORE - ON "); - - FCEUI_DisableFourScore(FSDisable); - break; - - case 7: i = -1; - PADCAL += 5; - if ( PADCAL > 90 ) - PADCAL = 40; + case 6: i = -1; + FSDisable ^= 1; + if ( FSDisable ) + strcpy(padmenu[6], " FOUR SCORE - OFF"); + else + strcpy(padmenu[6], " FOUR SCORE - ON "); - sprintf(padmenu[7]," ANALOG CLIP - %d", PADCAL); - break; + FCEUI_DisableFourScore(FSDisable); + break; - case 8: i = -1; - PADTUR += 1; - if ( PADTUR > 10 ) PADTUR += 4; - if ( PADTUR > 30 ) - PADTUR = 2; + case 7: i = -1; + PADCAL += 5; + if ( PADCAL > 90 ) + PADCAL = 40; - sprintf(padmenu[8]," TURBO SPEED - %.2f pps", (float)60/PADTUR); - break; - - case 9: quit=1; return; break; - default: break; - } + sprintf(padmenu[7]," ANALOG CLIP - %d", PADCAL); + break; - if ( i >= 0 ) { + case 8: i = -1; + PADTUR += 1; + if ( PADTUR > 10 ) PADTUR += 4; + if ( PADTUR > 30 ) + PADTUR = 2; + + sprintf(padmenu[8]," TURBO SPEED - %.2f pps", (float)60/PADTUR); + break; + + case 9: quit=1; return; break; + default: break; + } + + if ( i >= 0 ) { mpads[i]++; - if ( mpads[i] == 6 ) mpads[i] = 0; + if ( mpads[i] == 6 ) mpads[i] = 0; padmenu[i][15] = PADMap( mpads[i], i ); - } - } - + } + } + if ( j & PAD_BUTTON_B ) { quit=1; return; } @@ -517,28 +517,28 @@ void ConfigPAD() if ( menu == configpadcount ) menu = 0; - scroller(SCROLLY, &text[0], 2); + scroller(SCROLLY, &text[0], 2); VIDEO_WaitVSync(); - } + } - return; + return; } /**************************************************************************** * Save Game Manager ****************************************************************************/ - + int mccount = 5; char mcmenu[5][30] = { - { "Use: SLOT A" }, { "Device: MCARD" }, - { "Save Game State" }, { "Load Game State" }, - { "Return to Main Menu" } + { "Use: SLOT A" }, { "Device: MCARD" }, + { "Save Game State" }, { "Load Game State" }, + { "Return to Main Menu" } }; unsigned char sgmtext[][512] = { - //Save game - { "From where do you wish to load/save your game?" }, - { "Hard time making up your mind?" } + //Save game + { "From where do you wish to load/save your game?" }, + { "Hard time making up your mind?" } }; int slot = 0; @@ -547,206 +547,206 @@ int device = 0; int StateManager() { - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - //int i; + int menu = 0; + int quit = 0; + short j; + int redraw = 1; + //int i; - line = 0; - scrollerx = 320 - MARGIN; + line = 0; + scrollerx = 320 - MARGIN; - while ( quit == 0 ) - { - - if ( redraw ){ - sprintf(mcmenu[0], (slot == 0) ? "Use: SLOT A" : "Use: SLOT B"); - sprintf(mcmenu[1], (device == 0) ? "Device: MCARD" : "Device: SDCARD"); - DrawMenu(&mcmenu[0], mccount, menu); - } + while ( quit == 0 ) + { - redraw = 0; + if ( redraw ){ + sprintf(mcmenu[0], (slot == 0) ? "Use: SLOT A" : "Use: SLOT B"); + sprintf(mcmenu[1], (device == 0) ? "Device: MCARD" : "Device: SDCARD"); + DrawMenu(&mcmenu[0], mccount, menu); + } - j = PAD_ButtonsDown(0); + redraw = 0; - if ( j & PAD_BUTTON_DOWN ) { - menu++; - redraw = 1; - } + j = PAD_ButtonsDown(0); - if ( j & PAD_BUTTON_UP ) { - menu--; - redraw = 1; - } + if ( j & PAD_BUTTON_DOWN ) { + menu++; + redraw = 1; + } - if ( j & PAD_BUTTON_A ) { - redraw = 1; - switch( menu ) { - case 0 : - slot ^= 1; - break; - case 1 : - device ^= 1; - break; - case 2 : - ManageState(0, slot, device); //Save - break; - case 3 : - ManageState(1, slot, device); //Load - break; - case 4 : - quit = 1;//return 0 ; - break; - default: - break; - } - } + if ( j & PAD_BUTTON_UP ) { + menu--; + redraw = 1; + } - if ( j & PAD_BUTTON_B ) quit = 1; + if ( j & PAD_BUTTON_A ) { + redraw = 1; + switch( menu ) { + case 0 : + slot ^= 1; + break; + case 1 : + device ^= 1; + break; + case 2 : + ManageState(0, slot, device); //Save + break; + case 3 : + ManageState(1, slot, device); //Load + break; + case 4 : + quit = 1;//return 0 ; + break; + default: + break; + } + } - if ( menu < 0 ) - menu = mccount - 1; + if ( j & PAD_BUTTON_B ) quit = 1; - if ( menu == mccount ) - menu = 0; + if ( menu < 0 ) + menu = mccount - 1; - scroller(SCROLLY, &sgmtext[0], 2); + if ( menu == mccount ) + menu = 0; + + scroller(SCROLLY, &sgmtext[0], 2); VIDEO_WaitVSync(); - } + } - return 0; + return 0; } /**************************************************************************** * Video Enhancement Screen ****************************************************************************/ - + int vecount = 5; char vemenu[5][30] = { - { "Screen Scaler - GX" }, { "Palette - Default" }, - { "8 Sprite Limit - ON " },{ "Timing - NTSC" }, - { "Return to Main Menu" } + { "Screen Scaler - GX" }, { "Palette - Default" }, + { "8 Sprite Limit - ON " },{ "Timing - NTSC" }, + { "Return to Main Menu" } }; unsigned char vestext[][512] = { - //Screen Configurator - { "Wow, these colors and shapes sure are beautiful, brings back the memories." }, - { "Be sure not to mess these settings up, You don't want to ruin the experience! :D" } + //Screen Configurator + { "Wow, these colors and shapes sure are beautiful, brings back the memories." }, + { "Be sure not to mess these settings up, You don't want to ruin the experience! :D" } }; int VideoEnhancements() { - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - int i; - unsigned char r,g,b; + int menu = 0; + int quit = 0; + short j; + int redraw = 1; + int i; + unsigned char r,g,b; - line = 0; - scrollerx = 320 - MARGIN; + line = 0; + scrollerx = 320 - MARGIN; - while ( quit == 0) - { - if ( redraw ) - DrawMenu(&vemenu[0], vecount, menu ); + while ( quit == 0) + { + if ( redraw ) + DrawMenu(&vemenu[0], vecount, menu ); - redraw = 0; + redraw = 0; - j = PAD_ButtonsDown(0); + j = PAD_ButtonsDown(0); - if ( j & PAD_BUTTON_DOWN ) { - menu++; - redraw = 1; - } + if ( j & PAD_BUTTON_DOWN ) { + menu++; + redraw = 1; + } - if ( j & PAD_BUTTON_UP ) { - menu--; - redraw = 1; - } + if ( j & PAD_BUTTON_UP ) { + menu--; + redraw = 1; + } - if ( j & PAD_BUTTON_A ) { - redraw = 1; - switch ( menu ) { - case 0: /*** Scaler ***/ - screenscaler++; - screenscaler = ( screenscaler > 2 ) ? 0 : screenscaler; + if ( j & PAD_BUTTON_A ) { + redraw = 1; + switch ( menu ) { + case 0: /*** Scaler ***/ + screenscaler++; + screenscaler = ( screenscaler > 2 ) ? 0 : screenscaler; - switch ( screenscaler ) - { - case 2: strcpy(vemenu[0], "Screen Scaler - GX"); break; - case 1: strcpy(vemenu[0], "Screen Scaler - Cheesy"); break; - case 0: strcpy(vemenu[0], "Screen Scaler - 2x"); break; - } - break; - case 1: /*** Palette ***/ - currpal++; - if ( currpal > MAXPAL ) - currpal = 0; + switch ( screenscaler ) + { + case 2: strcpy(vemenu[0], "Screen Scaler - GX"); break; + case 1: strcpy(vemenu[0], "Screen Scaler - Cheesy"); break; + case 0: strcpy(vemenu[0], "Screen Scaler - 2x"); break; + } + break; + case 1: /*** Palette ***/ + currpal++; + if ( currpal > MAXPAL ) + currpal = 0; - if ( currpal == 0 ) { - strcpy(vemenu[1],"Palette - Default"); - /*** Do palette reset ***/ - FCEU_ResetPalette(); - } else { - strcpy(vemenu[1],"Palette - "); - strcat(vemenu[1], palettes[currpal-1].name); + if ( currpal == 0 ) { + strcpy(vemenu[1],"Palette - Default"); + /*** Do palette reset ***/ + FCEU_ResetPalette(); + } else { + strcpy(vemenu[1],"Palette - "); + strcat(vemenu[1], palettes[currpal-1].name); - /*** Now setup this palette ***/ - for ( i = 0; i < 64; i++ ) - { - r = palettes[currpal-1].data[i] >> 16; - g = ( palettes[currpal-1].data[i] & 0xff00 ) >> 8; - b = ( palettes[currpal-1].data[i] & 0xff ); - FCEUD_SetPalette( i, r, g, b); - FCEUD_SetPalette( i+64, r, g, b); - FCEUD_SetPalette( i+128, r, g, b); - FCEUD_SetPalette( i+192, r, g, b); + /*** Now setup this palette ***/ + for ( i = 0; i < 64; i++ ) + { + r = palettes[currpal-1].data[i] >> 16; + g = ( palettes[currpal-1].data[i] & 0xff00 ) >> 8; + b = ( palettes[currpal-1].data[i] & 0xff ); + FCEUD_SetPalette( i, r, g, b); + FCEUD_SetPalette( i+64, r, g, b); + FCEUD_SetPalette( i+128, r, g, b); + FCEUD_SetPalette( i+192, r, g, b); - } - } + } + } - break; + break; - case 2: slimit ^=1; - if ( slimit ) - strcpy(vemenu[2], "8 Sprite Limit - ON "); - else - strcpy(vemenu[2], "8 Sprite Limit - OFF"); - FCEUI_DisableSpriteLimitation( slimit ); - break; + case 2: slimit ^=1; + if ( slimit ) + strcpy(vemenu[2], "8 Sprite Limit - ON "); + else + strcpy(vemenu[2], "8 Sprite Limit - OFF"); + FCEUI_DisableSpriteLimitation( slimit ); + break; - case 3: timing ^= 1; - if ( timing ) - strcpy(vemenu[3], "Timing - PAL "); - else - strcpy(vemenu[3], "Timing - NTSC"); + case 3: timing ^= 1; + if ( timing ) + strcpy(vemenu[3], "Timing - PAL "); + else + strcpy(vemenu[3], "Timing - NTSC"); - FCEUI_SetVidSystem( timing ); - - break; + FCEUI_SetVidSystem( timing ); - case 4: quit = 1; break; + break; - default: break; + case 4: quit = 1; break; - } - } - - if ( j & PAD_BUTTON_B ) quit = 1; - if ( menu < 0 ) - menu = vecount - 1; + default: break; - if ( menu == vecount ) - menu = 0; + } + } - scroller(SCROLLY, &vestext[0], 2); + if ( j & PAD_BUTTON_B ) quit = 1; + if ( menu < 0 ) + menu = vecount - 1; + + if ( menu == vecount ) + menu = 0; + + scroller(SCROLLY, &vestext[0], 2); VIDEO_WaitVSync(); - } + } - return 0; + return 0; } @@ -755,12 +755,12 @@ int VideoEnhancements() ****************************************************************************/ typedef struct { - char ID[4]; /*NES^Z*/ - u8 ROM_size; - u8 VROM_size; - u8 ROM_type; - u8 ROM_type2; - u8 reserve[8]; + char ID[4]; /*NES^Z*/ + u8 ROM_size; + u8 VROM_size; + u8 ROM_type; + u8 ROM_type2; + u8 reserve[8]; } iNES_HEADER; extern int MapperNo; @@ -773,334 +773,334 @@ extern u8 iNESMirroring; void ShowROMInfo() { - int i,p; - char *title = "ROM Information"; - char info[128]; + int i,p; + char *title = "ROM Information"; + char info[128]; - ClearScreen(); + ClearScreen(); - p = (480 - (7 * font_height)) / 2 + 5; + p = (480 - (7 * font_height)) / 2 + 5; - write_font( CentreTextPosition( title ), p, title ); - p += ( font_height << 1 ); + write_font( CentreTextPosition( title ), p, title ); + p += ( font_height << 1 ); - for ( i = 0; i < 5; i++ ) - { - switch (i) { - case 0: sprintf(info, "ROM Size : %d", head.ROM_size ); break; - case 1: sprintf(info, "VROM Size : %d", head.VROM_size ); break; - case 2: sprintf(info, "iNES CRC : %08x", iNESGameCRC32 ); break; - case 3: sprintf(info, "Mapper : %d", MapperNo ); break; - case 4: sprintf(info, "Mirroring : %d", iNESMirroring );break; - } + for ( i = 0; i < 5; i++ ) + { + switch (i) { + case 0: sprintf(info, "ROM Size : %d", head.ROM_size ); break; + case 1: sprintf(info, "VROM Size : %d", head.VROM_size ); break; + case 2: sprintf(info, "iNES CRC : %08x", iNESGameCRC32 ); break; + case 3: sprintf(info, "Mapper : %d", MapperNo ); break; + case 4: sprintf(info, "Mirroring : %d", iNESMirroring );break; + } - write_font( CentreTextPosition( info ), p, info ); - p+=font_height; + write_font( CentreTextPosition( info ), p, info ); + p+=font_height; - } + } + + SetScreen(); - SetScreen(); - while ( !(PAD_ButtonsDown(0) & (PAD_BUTTON_A | PAD_BUTTON_B)) ) { VIDEO_WaitVSync(); } - + } /**************************************************************************** * Media Select Screen ****************************************************************************/ - + int mediacount = 3; char mediamenu[3][30] = { - { "Load from DVD" }, { "Load from SDCARD"}, - //{ "Rom loading in SDCARD: SLOT A" }, - { "Return to previous" } + { "Load from DVD" }, { "Load from SDCARD"}, + //{ "Rom loading in SDCARD: SLOT A" }, + { "Return to previous" } }; unsigned char msstext[][512] = { - //Screen Configurator - { "What are You waiting for? Load some games!" }, - { "Still here?" }, - { "How can You wait this long?! The games are waiting for You!!" } + //Screen Configurator + { "What are You waiting for? Load some games!" }, + { "Still here?" }, + { "How can You wait this long?! The games are waiting for You!!" } }; //int choosenSDSlot = 0; int MediaSelect() { - int menu = 0; - int quit = 0; - short j; - int redraw = 1; + int menu = 0; + int quit = 0; + short j; + int redraw = 1; - line = 0; - scrollerx = 320 - MARGIN; + line = 0; + scrollerx = 320 - MARGIN; - while ( quit == 0 ) - { - if ( redraw ) - DrawMenu(&mediamenu[0], mediacount, menu ); - - redraw = 0; + while ( quit == 0 ) + { + if ( redraw ) + DrawMenu(&mediamenu[0], mediacount, menu ); - j = PAD_ButtonsDown(0); + redraw = 0; - if ( j & PAD_BUTTON_DOWN ) { - menu++; - redraw = 1; - } + j = PAD_ButtonsDown(0); - if ( j & PAD_BUTTON_UP ) { - menu--; - redraw = 1; - } + if ( j & PAD_BUTTON_DOWN ) { + menu++; + redraw = 1; + } - if ( j & PAD_BUTTON_A ) { - redraw = 1; - switch ( menu ) { - case 0: UseSDCARD = 0; //DVD - OpenDVD(); - return 1; - break; + if ( j & PAD_BUTTON_UP ) { + menu--; + redraw = 1; + } - case 1: UseSDCARD = 1; //SDCard - OpenSD(); - return 1; - break; - /*case 2: choosenSDSlot ^= 1; //Pick Slot - sprintf(mediamenu[2], (!choosenSDSlot) ? "Rom loading in SDCARD: SLOT A" : "Rom loading in SDCARD: SLOT B"); - break;*/ - case 2: quit = 1; //Previous - break; + if ( j & PAD_BUTTON_A ) { + redraw = 1; + switch ( menu ) { + case 0: UseSDCARD = 0; //DVD + OpenDVD(); + return 1; + break; - default: break ; - } - } + case 1: UseSDCARD = 1; //SDCard + OpenSD(); + return 1; + break; + /*case 2: choosenSDSlot ^= 1; //Pick Slot + sprintf(mediamenu[2], (!choosenSDSlot) ? "Rom loading in SDCARD: SLOT A" : "Rom loading in SDCARD: SLOT B"); + break;*/ + case 2: quit = 1; //Previous + break; - if ( j & PAD_BUTTON_B ) - quit = 1; + default: break ; + } + } - if ( menu == mediacount ) - menu = 0; + if ( j & PAD_BUTTON_B ) + quit = 1; - if ( menu < 0 ) - menu = mediacount - 1; + if ( menu == mediacount ) + menu = 0; - scroller(SCROLLY, &msstext[0], 3); - VIDEO_WaitVSync(); + if ( menu < 0 ) + menu = mediacount - 1; - } + scroller(SCROLLY, &msstext[0], 3); + VIDEO_WaitVSync(); - return 0; + } + + return 0; } /**************************************************************************** -* Credits screen -*****************************************************************************/ + * Credits screen + *****************************************************************************/ char credits[12][512] = { - //{ "Technical" }, - { "Gamecube port by softdev" }, - { "Original FCE by BERO" }, - { "FCE Ultra by Xodnizel" }, - { "DevkitPPC/libogc by wntrmute and shagkur" }, - { "IPLFont by Qoob" }, - { "DVD Codes Courtesy of Ninjamod" }, - { "Zlib by Jean-loup Gailly" }, - { "Misc. addons by KruLLo" }, - { "Extras features Askot" }, - { "Thank you to" }, - { "brakken, mithos, luciddream, HonkeyKong," }, - { "dsbomb for bringing it to the Wii" }, + //{ "Technical" }, + { "Gamecube port by softdev" }, + { "Original FCE by BERO" }, + { "FCE Ultra by Xodnizel" }, + { "DevkitPPC/libogc by wntrmute and shagkur" }, + { "IPLFont by Qoob" }, + { "DVD Codes Courtesy of Ninjamod" }, + { "Zlib by Jean-loup Gailly" }, + { "Misc. addons by KruLLo" }, + { "Extras features Askot" }, + { "Thank you to" }, + { "brakken, mithos, luciddream, HonkeyKong," }, + { "dsbomb for bringing it to the Wii" }, }; void ShowCredits(){ - int i,p; - char *title = "Credits"; - char info[128]; + int i,p; + char *title = "Credits"; + char info[128]; - ClearScreen(); + ClearScreen(); - //p = (480 - (7 * font_height)) / 2 + 5; //150 - p = 105; - - write_font( CentreTextPosition( title ), p, title ); - //p += ( font_height << 1 ); - - p = 133; - for ( i = 0; i < 12; i++ ) - { - sprintf(info, credits[i]); - write_font( CentreTextPosition( info ), p, info ); - p+=24; - //p+=font_height; - } + //p = (480 - (7 * font_height)) / 2 + 5; //150 + p = 105; + + write_font( CentreTextPosition( title ), p, title ); + //p += ( font_height << 1 ); + + p = 133; + for ( i = 0; i < 12; i++ ) + { + sprintf(info, credits[i]); + write_font( CentreTextPosition( info ), p, info ); + p+=24; + //p+=font_height; + } + + SetScreen(); - SetScreen(); - while ( !(PAD_ButtonsDown(0) & (PAD_BUTTON_A | PAD_BUTTON_B)) ) { VIDEO_WaitVSync(); } - + } /**************************************************************************** * Configuration Screen ****************************************************************************/ int configmenucount = 11; char configmenu[11][30] = { - { "Play Game" }, - { "Reset NES" }, - { "Load New Game" }, - { "State Manager" }, - { "ROM Information" }, - { "Configure Joypads" }, - { "Video Options" }, - { "Stop DVD Motor" }, - { "PSO/SD Reload" } , - { "Reboot Gamecube" }, - { "Credits" } + { "Play Game" }, + { "Reset NES" }, + { "Load New Game" }, + { "State Manager" }, + { "ROM Information" }, + { "Configure Joypads" }, + { "Video Options" }, + { "Stop DVD Motor" }, + { "PSO/SD Reload" } , + { "Reboot Gamecube" }, + { "Credits" } }; unsigned char cstext[][512] = { - //ConfigScreen - { "FCE Ultra GameCube Edition - Version 1.0.9 \"SUPER-DELUXE\" ;)" }, - { "Press L + R anytime to return to this menu!" }, - { "Press START + B + X anytime for PSO/SD-reload" }, - { "* * *" }, - { "FCE Ultra GC is a modified port of the FCE Ultra 0.98.12 Nintendo Entertainment system for x86 (Windows/Linux) PC's. In English you can play NES games on your GameCube using either a softmod and/or modchip from a DVD or via a networked connection to your PC." }, - { "Disclaimer - Use at your own RISK!" }, - { "Official Homepage: http://www.tehskeen.net" } + //ConfigScreen + { "FCE Ultra GameCube Edition - Version 1.0.9 \"SUPER-DELUXE\" ;)" }, + { "Press L + R anytime to return to this menu!" }, + { "Press START + B + X anytime for PSO/SD-reload" }, + { "* * *" }, + { "FCE Ultra GC is a modified port of the FCE Ultra 0.98.12 Nintendo Entertainment system for x86 (Windows/Linux) PC's. In English you can play NES games on your GameCube using either a softmod and/or modchip from a DVD or via a networked connection to your PC." }, + { "Disclaimer - Use at your own RISK!" }, + { "Official Homepage: http://www.tehskeen.net" } }; int ConfigScreen() { - int menu = 0; - int quit = 0; - short j; - int redraw = 1; - - //int *psoid = (int *) 0x80001800; - void (*PSOReload) () = (void (*)()) 0x80001800; + int menu = 0; + int quit = 0; + short j; + int redraw = 1; - /*** Stop any running Audio ***/ - AUDIO_StopDMA(); + //int *psoid = (int *) 0x80001800; + void (*PSOReload) () = (void (*)()) 0x80001800; - line = 0; - scrollerx = 320 - MARGIN; + /*** Stop any running Audio ***/ + AUDIO_StopDMA(); - while ( quit == 0 ) - { - if ( redraw ) - /*DrawMenu("FCEU GC Configuration", &configmenu[0], configmenucount, menu );*/ - DrawMenu(&configmenu[0], configmenucount, menu ); - - redraw = 0; + line = 0; + scrollerx = 320 - MARGIN; - //while (menu == 9 && !(PAD_ButtonsDown(0) & PAD_BUTTON_UP) && !(PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)) - // { scroller(SCROLLY, &credits[0], 12);VIDEO_WaitVSync(); } + while ( quit == 0 ) + { + if ( redraw ) + /*DrawMenu("FCEU GC Configuration", &configmenu[0], configmenucount, menu );*/ + DrawMenu(&configmenu[0], configmenucount, menu ); - /*if (menu == 9) { - scrollerx = 320 - MARGIN; - line = 0; - }*/ + redraw = 0; - j = PAD_ButtonsDown(0); + //while (menu == 9 && !(PAD_ButtonsDown(0) & PAD_BUTTON_UP) && !(PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)) + // { scroller(SCROLLY, &credits[0], 12);VIDEO_WaitVSync(); } - if (j & PAD_BUTTON_DOWN) { - menu++; - redraw = 1; - /*if (menu == 9) { - scrollerx = 320 - MARGIN; - line = 0; - }*/ - } + /*if (menu == 9) { + scrollerx = 320 - MARGIN; + line = 0; + }*/ - if (j & PAD_BUTTON_UP) { - menu--; - redraw = 1; - if (menu < 0) { - scrollerx = 320 - MARGIN; - line = 0; - } - } + j = PAD_ButtonsDown(0); - if (j & PAD_BUTTON_A ) { - redraw = 1; - switch ( menu ) { - case 0: // Play Game - quit = 1; - break; + if (j & PAD_BUTTON_DOWN) { + menu++; + redraw = 1; + /*if (menu == 9) { + scrollerx = 320 - MARGIN; + line = 0; + }*/ + } - case 1: // Reset NES - ResetNES(); - return 1; - break; + if (j & PAD_BUTTON_UP) { + menu--; + redraw = 1; + if (menu < 0) { + scrollerx = 320 - MARGIN; + line = 0; + } + } - case 2: // Load new Game - //if (MediaSelect()) { - // if (GCMemROM() >= 0) return 1;/* Fix by Garglub. Thanks! */ - //} - MediaSelect(); - scrollerx = 320 - MARGIN; - break; + if (j & PAD_BUTTON_A ) { + redraw = 1; + switch ( menu ) { + case 0: // Play Game + quit = 1; + break; - case 3: // State Manager - if (StateManager()) return 2; - scrollerx = 320 - MARGIN; - break; + case 1: // Reset NES + ResetNES(); + return 1; + break; - case 4: // Game Information - ShowROMInfo(); - break; + case 2: // Load new Game + //if (MediaSelect()) { + // if (GCMemROM() >= 0) return 1;/* Fix by Garglub. Thanks! */ + //} + MediaSelect(); + scrollerx = 320 - MARGIN; + break; - case 5: // COnfigure Joypads - ConfigPAD(); - scrollerx = 320 - MARGIN; - break; + case 3: // State Manager + if (StateManager()) return 2; + scrollerx = 320 - MARGIN; + break; - case 6: // Video Options - if (VideoEnhancements()) return 2; - scrollerx = 320 - MARGIN; - break; + case 4: // Game Information + ShowROMInfo(); + break; - case 7: // Stop DVD Motor - ShowAction("Stopping Motor"); - dvd_motor_off(); - WaitPrompt("DVD Motor Stopped"); - break; + case 5: // COnfigure Joypads + ConfigPAD(); + scrollerx = 320 - MARGIN; + break; - case 8: // PSO/SD Reload - PSOReload (); - break; + case 6: // Video Options + if (VideoEnhancements()) return 2; + scrollerx = 320 - MARGIN; + break; - case 9: // Reboot + case 7: // Stop DVD Motor + ShowAction("Stopping Motor"); + dvd_motor_off(); + WaitPrompt("DVD Motor Stopped"); + break; + + case 8: // PSO/SD Reload + PSOReload (); + break; + + case 9: // Reboot *SOFTRESET_ADR = 0x00000000; break; - case 10: // Credits - ShowCredits(); - break; + case 10: // Credits + ShowCredits(); + break; - default: break ; - } - } + default: break ; + } + } - if ( menu == configmenucount ) - menu = 0; + if ( menu == configmenucount ) + menu = 0; - if ( menu < 0 ) - menu = configmenucount - 1; + if ( menu < 0 ) + menu = configmenucount - 1; - scroller(SCROLLY, &cstext[0], 7); - VIDEO_WaitVSync(); + scroller(SCROLLY, &cstext[0], 7); + VIDEO_WaitVSync(); - } - - /*** Remove any still held buttons ***/ - while(PAD_ButtonsHeld(0)) VIDEO_WaitVSync(); - - /*** Stop the DVD from causing clicks while playing ***/ - uselessinquiry (); - - return 0; + } + + /*** Remove any still held buttons ***/ + while(PAD_ButtonsHeld(0)) VIDEO_WaitVSync(); + + /*** Stop the DVD from causing clicks while playing ***/ + uselessinquiry (); + + return 0; } diff --git a/source/drivers/gamecube/main.c b/source/drivers/gamecube/main.c index a076d2e..8fdeea1 100644 --- a/source/drivers/gamecube/main.c +++ b/source/drivers/gamecube/main.c @@ -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! */ } diff --git a/source/drivers/gamecube/memload.c b/source/drivers/gamecube/memload.c index 6abba81..9cc0f6f 100644 --- a/source/drivers/gamecube/memload.c +++ b/source/drivers/gamecube/memload.c @@ -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;; } diff --git a/source/drivers/gamecube/memstate.c b/source/drivers/gamecube/memstate.c index 2b3cacf..90d83fa 100644 --- a/source/drivers/gamecube/memstate.c +++ b/source/drivers/gamecube/memstate.c @@ -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); + } } diff --git a/source/drivers/gamecube/pad.c b/source/drivers/gamecube/pad.c index 800b314..4633485 100644 --- a/source/drivers/gamecube/pad.c +++ b/source/drivers/gamecube/pad.c @@ -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; } diff --git a/source/drivers/gamecube/saveicon.h b/source/drivers/gamecube/saveicon.h index 575e220..af857b7 100644 --- a/source/drivers/gamecube/saveicon.h +++ b/source/drivers/gamecube/saveicon.h @@ -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, }; diff --git a/source/drivers/gamecube/sz.c b/source/drivers/gamecube/sz.c index 14e30c3..aaa73a7 100644 --- a/source/drivers/gamecube/sz.c +++ b/source/drivers/gamecube/sz.c @@ -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; + } } diff --git a/source/drivers/gamecube/sz.h b/source/drivers/gamecube/sz.h index 894ee4e..57f3072 100644 --- a/source/drivers/gamecube/sz.h +++ b/source/drivers/gamecube/sz.h @@ -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 #include #include @@ -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