diff --git a/source/ngc/common.h b/source/ngc/common.h index 22a0633..f88a3ea 100644 --- a/source/ngc/common.h +++ b/source/ngc/common.h @@ -35,4 +35,4 @@ extern int eoptions; #define EO_FORCEISCALE 16384 #define EO_NOFOURSCORE 32768 -extern unsigned char * nesromptr; +extern unsigned char * nesrom; diff --git a/source/ngc/fceugc.c b/source/ngc/fceugc.c index bf9fade..0796e3a 100644 --- a/source/ngc/fceugc.c +++ b/source/ngc/fceugc.c @@ -34,7 +34,7 @@ #include #endif -extern unsigned char nesrom[]; +unsigned char * nesrom = NULL; extern bool romLoaded; bool isWii; @@ -77,6 +77,9 @@ int main(int argc, char *argv[]) DVD_Init(); #endif + // allocate memory to store rom + nesrom = (unsigned char *)malloc(1024*1024*3); // 3 MB should be plenty + /*** Minimal Emulation Loop ***/ if ( !FCEUI_Initialize() ) { printf("Unable to initialize system\n"); @@ -88,7 +91,6 @@ int main(int argc, char *argv[]) memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory cleanSFMDATA(); // clear state data - nesromptr = &nesrom[0]; // address of embedded color test ROM // Set Defaults DefaultSettings(); diff --git a/source/ngc/fceuload.c b/source/ngc/fceuload.c index 55b1e91..f6df801 100644 --- a/source/ngc/fceuload.c +++ b/source/ngc/fceuload.c @@ -32,7 +32,7 @@ #include "filesel.h" #include "smbop.h" -unsigned char *nesromptr; +unsigned char *nesrom; bool romLoaded = false; extern FCEUGI *FCEUGameInfo; @@ -99,7 +99,7 @@ int GCMemROM(method) InitialisePads(); - MakeFCEUFile((char *)nesromptr, filelist[selection].length); + MakeFCEUFile((char *)nesrom, filelist[selection].length); nesGameType = 0; diff --git a/source/ngc/fileop.c b/source/ngc/fileop.c index 0f13333..f968256 100644 --- a/source/ngc/fileop.c +++ b/source/ngc/fileop.c @@ -193,7 +193,7 @@ LoadFATFile (char *filename, int length) if (r) { - size = UnZipFATFile (nesromptr, handle); // unzip from FAT + size = UnZipFATFile (nesrom, handle); // unzip from FAT } else { @@ -201,8 +201,8 @@ LoadFATFile (char *filename, int length) fseek(handle, 0, SEEK_END); length = ftell(handle); // get filesize fseek(handle, 2048, SEEK_SET); // seek back to point where we left off - memcpy (nesromptr, zipbuffer, 2048); // copy what we already read - fread (nesromptr + 2048, 1, length - 2048, handle); + memcpy (nesrom, zipbuffer, 2048); // copy what we already read + fread (nesrom + 2048, 1, length - 2048, handle); size = length; } fclose (handle); diff --git a/source/ngc/filesel.c b/source/ngc/filesel.c index 55f765c..698e062 100644 --- a/source/ngc/filesel.c +++ b/source/ngc/filesel.c @@ -38,12 +38,9 @@ int nesGameType; int maxfiles; extern int screenheight; -int havedir = -1; extern u64 dvddir; extern int dvddirlength; -int hasloaded = 0; - // Global file entry table FILEENTRIES filelist[MAXFILES]; @@ -315,7 +312,7 @@ int FileSelector (int method) case METHOD_DVD: dvddir = filelist[selection].offset; dvddirlength = filelist[selection].length; - LoadDVDFile (nesromptr); + LoadDVDFile (nesrom); break; case METHOD_SMB: diff --git a/source/ngc/gcaudio.c b/source/ngc/gcaudio.c index a2bd0f1..d17dcb5 100644 --- a/source/ngc/gcaudio.c +++ b/source/ngc/gcaudio.c @@ -10,6 +10,7 @@ ****************************************************************************/ #include +#include #define SAMPLERATE 48000 unsigned char audiobuffer[2][64 * 1024] ATTRIBUTE_ALIGN(32); @@ -44,7 +45,7 @@ void InitialiseSound() AUDIO_Init(NULL); /*** Start audio subsystem ***/ AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); AUDIO_RegisterDMACallback( AudioSwitchBuffers ); - memset(audiobuffer, 0, (64 * 1024)); + memset(audiobuffer, 0, (64 * 1024 * 2)); buffSize[0] = buffSize[1] = 0; } diff --git a/source/ngc/gcunzip.c b/source/ngc/gcunzip.c index b5144da..b1a29ed 100644 --- a/source/ngc/gcunzip.c +++ b/source/ngc/gcunzip.c @@ -257,7 +257,7 @@ else if (inSz == false && SzDvdIsArchive(filelist[selection].offset) == SZ_OK) { } else if (inSz == true) { // extract the selected ROM from the 7zip file to the buffer - if(SzExtractROM(filelist[selection].offset, nesromptr) == true) { + if(SzExtractROM(filelist[selection].offset, nesrom) == true) { haverom = 1; inSz = false; diff --git a/source/ngc/menu.c b/source/ngc/menu.c index f3a2a87..8c154de 100644 --- a/source/ngc/menu.c +++ b/source/ngc/menu.c @@ -525,15 +525,15 @@ GetButtonMap(u16 ctrlr_type, char* btn_name) int cfg_btns_count = 10; char cfg_btns_menu[][50] = { - "B - ", - "A - ", - "SELECT - ", - "START - ", - "UP - ", - "DOWN - ", - "LEFT - ", - "RIGHT - ", - "VS INSERT COIN - " + "B - ", + "A - ", + "SELECT - ", + "START - ", + "UP - ", + "DOWN - ", + "LEFT - ", + "RIGHT - ", + "INSERT COIN - ", "Return to previous" }; diff --git a/source/ngc/nesrom.s b/source/ngc/nesrom.s deleted file mode 100644 index cf3722e..0000000 --- a/source/ngc/nesrom.s +++ /dev/null @@ -1,7 +0,0 @@ -.rodata -.globl nesrom -nesromsize: .long 1048592 -.balign 32 -nesrom: -.incbin "../source/ngc/rom/ROM.NES" - diff --git a/source/ngc/pad.c b/source/ngc/pad.c index 0c74cd0..8187256 100644 --- a/source/ngc/pad.c +++ b/source/ngc/pad.c @@ -22,6 +22,9 @@ #include "menu.h" #include "fceustate.h" #include "fceuram.h" +#include "filesel.h" + +extern bool romLoaded; // Original NES controller buttons // All other pads are mapped to this @@ -89,27 +92,31 @@ void InitialisePads() void ToggleFourScore(int set) { - FCEUI_DisableFourScore(set); + if(romLoaded) + FCEUI_DisableFourScore(set); } void ToggleZapper(int set) { - // set defaults - zapperdata[0]=NULL; - zapperdata[1]=NULL; - myzappers[0][0]=myzappers[1][0]=128; - myzappers[0][1]=myzappers[1][1]=120; - myzappers[0][2]=myzappers[1][2]=0; - - // Default ports back to gamepad - FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0); - FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0); - - if(set) + if(romLoaded) { - // enable Zapper - zapperdata[set-1] = FCEU_InitZapper(set-1); - FCEUI_SetInput(set-1, SI_ZAPPER, myzappers[set-1], 1); + // set defaults + zapperdata[0]=NULL; + zapperdata[1]=NULL; + myzappers[0][0]=myzappers[1][0]=128; + myzappers[0][1]=myzappers[1][1]=120; + myzappers[0][2]=myzappers[1][2]=0; + + // Default ports back to gamepad + FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0); + FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0); + + if(set) + { + // enable Zapper + zapperdata[set-1] = FCEU_InitZapper(set-1); + FCEUI_SetInput(set-1, SI_ZAPPER, myzappers[set-1], 1); + } } } diff --git a/source/ngc/pad.h b/source/ngc/pad.h index 01e4282..c320a12 100644 --- a/source/ngc/pad.h +++ b/source/ngc/pad.h @@ -16,7 +16,7 @@ #define PI 3.14159265f #define PADCAL 50 -#define MAXJP 8 +#define MAXJP 9 extern unsigned int gcpadmap[]; extern unsigned int wmpadmap[]; diff --git a/source/ngc/rom/ROM.NES b/source/ngc/rom/ROM.NES deleted file mode 100644 index ae87c0d..0000000 Binary files a/source/ngc/rom/ROM.NES and /dev/null differ diff --git a/source/ngc/smbop.c b/source/ngc/smbop.c index 69aabf7..392afc1 100644 --- a/source/ngc/smbop.c +++ b/source/ngc/smbop.c @@ -225,7 +225,7 @@ LoadSMBFile (char *filename, int length) return -1; } - return LoadBufferFromSMB((char *)nesromptr, SMBPath(filepath), NOTSILENT); + return LoadBufferFromSMB((char *)nesrom, SMBPath(filepath), NOTSILENT); } /****************************************************************************