Commit 86b6a2cc authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 8d6376c7
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
#include "main.h" #include "main.h"
//#include "msounds.h"
#include "memory.h" #include "memory.h"
//#include "mainemu.h"
#include "tlcs900h.h" #include "tlcs900h.h"
#include "input.h" #include "input.h"
...@@ -42,54 +40,55 @@ extern int language; ...@@ -42,54 +40,55 @@ extern int language;
extern int tipo_consola; extern int tipo_consola;
BOOL m_bIsActive; BOOL m_bIsActive;
int exitNow=0;
EMUINFO m_emuInfo; EMUINFO m_emuInfo;
SYSTEMINFO m_sysInfo[NR_OF_SYSTEMS]; SYSTEMINFO m_sysInfo[NR_OF_SYSTEMS];
FILE *errorLog = NULL;
FILE *outputRam = NULL;
#define numberof(a) (sizeof(a)/sizeof(*(a))) #define numberof(a) (sizeof(a)/sizeof(*(a)))
void mainemuinit(void) void mainemuinit(void)
{ {
// initialize cpu memory // initialize cpu memory
mem_init(); mem_init();
graphics_init(); graphics_init();
// initialize the TLCS-900H cpu // initialize the TLCS-900H cpu
tlcs_init(); tlcs_init();
#if defined(CZ80) #if defined(CZ80)
Z80_Init(); Z80_Init();
#endif #endif
#if defined(DRZ80) || defined(CZ80) #if defined(DRZ80) || defined(CZ80)
Z80_Reset(); Z80_Reset();
#else #else
z80Init(); z80Init();
#endif #endif
// if neogeo pocket color rom, act if we are a neogeo pocket color // if neogeo pocket color rom, act if we are a neogeo pocket color
tlcsMemWriteB(0x6F91,tlcsMemReadB(0x00200023)); tlcsMemWriteB(0x6F91,tlcsMemReadB(0x00200023));
if (tipo_consola==1) tlcsMemWriteB(0x6F91,0x00); if (tipo_consola==1)
tlcsMemWriteB(0x6F91,0x00);
// pretend we're running in English mode
// pretend we're running in English mode
//NOTA setting_ngp_language 00 Ingles - 01 Jap
if (setting_ngp_language == 0){ //NOTA setting_ngp_language 00 Ingles - 01 Jap
tlcsMemWriteB(0x00006F87,0x01);} if (setting_ngp_language == 0)
if (setting_ngp_language == 1){ {
tlcsMemWriteB(0x00006F87,0x00);} tlcsMemWriteB(0x00006F87,0x01);
}
// kludges & fixes if (setting_ngp_language == 1)
switch (tlcsMemReadW(0x00200020)) {
{ tlcsMemWriteB(0x00006F87,0x00);
case 0x0059: // Sonic }
case 0x0061: // Metal SLug 2nd
*get_address(0x0020001F) = 0xFF; // kludges & fixes
break; switch (tlcsMemReadW(0x00200020))
} {
ngpSoundOff(); case 0x0059: // Sonic
case 0x0061: // Metal Slug 2nd
*get_address(0x0020001F) = 0xFF;
break;
}
ngpSoundOff();
} }
void SetActive(BOOL bActive) void SetActive(BOOL bActive)
...@@ -105,71 +104,77 @@ void SetEmu(int machine) ...@@ -105,71 +104,77 @@ void SetEmu(int machine)
bool initRom(void) bool initRom(void)
{ {
char *licenseInfo = " BY SNK CORPORATION"; int i, m;
char *ggLicenseInfo = "TMR SEGA"; char *licenseInfo = " BY SNK CORPORATION";
BOOL romFound = TRUE; char *ggLicenseInfo = "TMR SEGA";
int i, m; BOOL romFound = TRUE;
finscan=198;
if (mainrom[0x000020] == 0x65 || mainrom[0x000020] == 0x93)
{
finscan=199;
}
//dbg_print("in openNgp(%s)\n", lpszPathName); finscan=198;
// first stop the current emulation if (mainrom[0x000020] == 0x65 || mainrom[0x000020] == 0x93)
//dbg_print("openNgp: SetEmu(NONE)\n"); finscan=199;
SetEmu(NGPC);
//dbg_print("openNgp: SetActive(FALSE)\n");
SetActive(FALSE);
// check NEOGEO POCKET #if 0
// check license info dbg_print("in openNgp(%s)\n", lpszPathName);
for (i=0;i<19;i++) #endif
{
if (mainrom[0x000009 + i] != licenseInfo[i])
romFound = FALSE;
}
if (romFound)
{
//dbg_print("openNgp: romFound == TRUE\n");
i = mainrom[0x000023];
if (i == 0x10 || i == 0x00)
{
// initiazlie emulation
if (i == 0x10) {
m = NGPC;
} else {
// fix for missing Mono/Color setting in Cool Coom Jam SAMPLE rom
if (mainrom[0x000020] == 0x34 && mainrom[0x000021] == 0x12)
m = NGPC;
else m = NGP;
}
if (tipo_consola==1) m = NGP;
//dbg_print("openNgp: SetEmu(%d)\n", m);
SetEmu(m);
//dbg_print("openNgp: Calling mainemuinit(%s)\n", lpszPathName);
mainemuinit();
// start running the emulation loop
//dbg_print("openNgp: SetActive(TRUE)\n");
SetActive(TRUE);
// acknowledge opening of the document went fine // first stop the current emulation
//dbg_print("openNgp: returning success\n"); #if 0
return TRUE; dbg_print("openNgp: SetEmu(NONE)\n");
} #endif
SetEmu(NGPC);
#if 0
dbg_print("openNgp: SetActive(FALSE)\n");
#endif
SetActive(FALSE);
fprintf(stderr, "Not a valid or unsupported rom file.\n"); // check NEOGEO POCKET
return FALSE; // check license info
} for (i=0;i<19;i++)
{
if (mainrom[0x000009 + i] != licenseInfo[i])
romFound = FALSE;
}
if (romFound)
{
//dbg_print("openNgp: romFound == TRUE\n");
i = mainrom[0x000023];
if (i == 0x10 || i == 0x00)
{
/* initialize emulation */
if (i == 0x10)
m = NGPC;
else
{
// fix for missing Mono/Color setting in Cool Coom Jam SAMPLE rom
if (mainrom[0x000020] == 0x34 && mainrom[0x000021] == 0x12)
m = NGPC;
else
m = NGP;
}
if (tipo_consola==1)
m = NGP;
//dbg_print("openNgp: SetEmu(%d)\n", m);
SetEmu(m);
//dbg_print("openNgp: Calling mainemuinit(%s)\n", lpszPathName);
mainemuinit();
// start running the emulation loop
//dbg_print("openNgp: SetActive(TRUE)\n");
SetActive(TRUE);
// acknowledge opening of the document went fine
//dbg_print("openNgp: returning success\n");
return TRUE;
}
fprintf(stderr, "Not a valid or unsupported rom file.\n");
return FALSE;
}
fprintf(stderr, "Not a valid or unsupported rom file. romFound==FALSE\n"); fprintf(stderr, "Not a valid or unsupported rom file. romFound==FALSE\n");
return FALSE; return FALSE;
} }
void initSysInfo(void) void initSysInfo(void)
...@@ -180,55 +185,15 @@ void initSysInfo(void) ...@@ -180,55 +185,15 @@ void initSysInfo(void)
m_emuInfo.drv = &m_sysInfo[m_emuInfo.machine]; m_emuInfo.drv = &m_sysInfo[m_emuInfo.machine];
m_emuInfo.romSize = 0; m_emuInfo.romSize = 0;
/* strcpy(m_emuInfo.ProgramFolder, "");
strcpy(m_emuInfo.SavePath, "");
strcpy(m_emuInfo.DebugPath, "");
strcpy(m_emuInfo.RomPath, "");
strcpy(m_emuInfo.OpenFileName, "");
strcpy(m_emuInfo.SaveFileName, "");
strcpy(m_emuInfo.OpenFileName, "");
strcpy(m_emuInfo.DebugPath, "");;
strcpy(m_emuInfo.RomFileName, ""); strcpy(m_emuInfo.RomFileName, "");
strcpy(m_emuInfo.SaveFileName, "");
strcpy(m_emuInfo.ScreenPath, "");*/
strcpy(m_emuInfo.RomFileName, "");
#define NO_SOUND_OUTPUT
#ifdef NO_SOUND_OUTPUT
m_emuInfo.sample_rate = 0;
#else
m_emuInfo.sample_rate = 44100;
#endif
m_emuInfo.stereo = 1;
//m_emuInfo.fps = 60;//30;//100; //Flavor, tweak this!
/* m_sysInfo[NONE].hSize = 160;
m_sysInfo[NONE].vSize = 152;
m_sysInfo[NONE].Ticks = 0;
//m_sysInfo[NONE].sound[0].sound_type = 0;*/
m_sysInfo[NGP].hSize = 160; m_sysInfo[NGP].hSize = 160;
m_sysInfo[NGP].vSize = 152; m_sysInfo[NGP].vSize = 152;
m_sysInfo[NGP].Ticks = 6*1024*1024; m_sysInfo[NGP].Ticks = 6*1024*1024;
/* m_sysInfo[NGP].sound[0].sound_type = SOUND_SN76496;
m_sysInfo[NGP].sound[0].sound_interface = new_SN76496(1, 3*1024*1024, MIXER(50,MIXER_PAN_CENTER));
m_sysInfo[NGP].sound[1].sound_type = SOUND_DAC;
m_sysInfo[NGP].sound[1].sound_interface = new_DAC(2,MIXER(50,MIXER_PAN_LEFT),MIXER(50,MIXER_PAN_RIGHT));
m_sysInfo[NGP].sound[2].sound_type = 0;
m_sysInfo[NGP].Back0 = TRUE;
m_sysInfo[NGP].Back1 = TRUE;
m_sysInfo[NGP].Sprites = TRUE;*/
m_sysInfo[NGPC].hSize = 160; m_sysInfo[NGPC].hSize = 160;
m_sysInfo[NGPC].vSize = 152; m_sysInfo[NGPC].vSize = 152;
m_sysInfo[NGPC].Ticks = 6*1024*1024; m_sysInfo[NGPC].Ticks = 6*1024*1024;
/* m_sysInfo[NGPC].sound[0].sound_type = SOUND_SN76496;
m_sysInfo[NGPC].sound[0].sound_interface = new_SN76496(1, 3*1024*1024, 50);
m_sysInfo[NGPC].sound[1].sound_type = SOUND_DAC;
m_sysInfo[NGPC].sound[1].sound_interface = new_DAC(2,MIXER(50,MIXER_PAN_LEFT),MIXER(50,MIXER_PAN_RIGHT));
m_sysInfo[NGPC].sound[2].sound_type = 0;
m_sysInfo[NGPC].Back0 = TRUE;
m_sysInfo[NGPC].Back1 = TRUE;
m_sysInfo[NGPC].Sprites = TRUE;*/
} }
char *getFileNameExtension(char *nom_fichier) char *getFileNameExtension(char *nom_fichier)
...@@ -244,92 +209,92 @@ char *getFileNameExtension(char *nom_fichier) ...@@ -244,92 +209,92 @@ char *getFileNameExtension(char *nom_fichier)
} }
#ifdef WANT_ZIP #ifdef WANT_ZIP
int loadFromZipByName(unsigned char *buffer, char *archive, char *filename, int *filesize) int loadFromZipByName(unsigned char *buffer, char *archive,
char *filename, int *filesize)
{ {
char name[_MAX_PATH]; char name[_MAX_PATH];
//unsigned char *buffer; int i;
int i; const char *recognizedExtensions[] = {
const char *recognizedExtensions[] = { ".ngp",
".ngp", ".npc",
".npc", ".ngc"
".ngc" };
};
int zerror = UNZ_OK;
int zerror = UNZ_OK; unzFile zhandle;
unzFile zhandle; unz_file_info zinfo;
unz_file_info zinfo;
zhandle = unzOpen(archive);
zhandle = unzOpen(archive); if(!zhandle) return (0);
if(!zhandle) return (0);
/* Seek to first file in archive */
/* Seek to first file in archive */ zerror = unzGoToFirstFile(zhandle);
zerror = unzGoToFirstFile(zhandle); if(zerror != UNZ_OK)
if(zerror != UNZ_OK) {
{ unzClose(zhandle);
unzClose(zhandle); return (0);
return (0); }
}
//On scanne tous les fichiers de l'archive et ne prend que ceux qui ont une extension valable, sinon on prend le dernier fichier trouvé...
while (zerror == UNZ_OK) {
if (unzGetCurrentFileInfo(zhandle, &zinfo, name, 0xff, NULL, 0, NULL, 0) != UNZ_OK) {
unzClose(zhandle);
return 0;
}
//Vérifions que c'est la bonne extension //On scanne tous les fichiers de l'archive et ne prend que ceux qui ont une extension valable, sinon on prend le dernier fichier trouvé...
char *extension = getFileNameExtension(name); while (zerror == UNZ_OK) {
if (unzGetCurrentFileInfo(zhandle, &zinfo, name, 0xff, NULL, 0, NULL, 0) != UNZ_OK) {
unzClose(zhandle);
return 0;
}
for (i=0;i<numberof(recognizedExtensions);i++) { //Vérifions que c'est la bonne extension
if (!strcmp(extension, recognizedExtensions[i])) char *extension = getFileNameExtension(name);
break;
}
if (i < numberof(recognizedExtensions))
break;
zerror = unzGoToNextFile(zhandle); for (i=0;i<numberof(recognizedExtensions);i++) {
} if (!strcmp(extension, recognizedExtensions[i]))
break;
}
if (i < numberof(recognizedExtensions))
break;
zerror = unzGoToNextFile(zhandle);
}
/* Get information about the file */
// unzGetCurrentFileInfo(zhandle, &zinfo, &name[0], 0xff, NULL, 0, NULL, 0);
*filesize = zinfo.uncompressed_size;
/* Error: file size is zero */
if(*filesize <= 0 || *filesize > (4*1024*1024))
{
unzClose(zhandle);
return (0);
}
/* Open current file */
zerror = unzOpenCurrentFile(zhandle);
if(zerror != UNZ_OK)
{
unzClose(zhandle);
return (0);
}
/* Allocate buffer and read in file */
//buffer = malloc(*filesize);
//if(!buffer) return (NULL);
zerror = unzReadCurrentFile(zhandle, buffer, *filesize);
/* Internal error: free buffer and close file */
if(zerror < 0 || zerror != *filesize)
{
//free(buffer);
//buffer = NULL;
unzCloseCurrentFile(zhandle);
unzClose(zhandle);
return (0);
}
/* Close current file and archive file */
unzCloseCurrentFile(zhandle);
unzClose(zhandle);
/* Get information about the file */ memcpy(filename, name, _MAX_PATH);
// unzGetCurrentFileInfo(zhandle, &zinfo, &name[0], 0xff, NULL, 0, NULL, 0); return 1;
*filesize = zinfo.uncompressed_size;
/* Error: file size is zero */
if(*filesize <= 0 || *filesize > (4*1024*1024))
{
unzClose(zhandle);
return (0);
}
/* Open current file */
zerror = unzOpenCurrentFile(zhandle);
if(zerror != UNZ_OK)
{
unzClose(zhandle);
return (0);
}
/* Allocate buffer and read in file */
//buffer = malloc(*filesize);
//if(!buffer) return (NULL);
zerror = unzReadCurrentFile(zhandle, buffer, *filesize);
/* Internal error: free buffer and close file */
if(zerror < 0 || zerror != *filesize)
{
//free(buffer);
//buffer = NULL;
unzCloseCurrentFile(zhandle);
unzClose(zhandle);
return (0);
}
/* Close current file and archive file */
unzCloseCurrentFile(zhandle);
unzClose(zhandle);
memcpy(filename, name, _MAX_PATH);
return 1;
} }
#endif // WANT_ZIP #endif // WANT_ZIP
......
...@@ -14,29 +14,18 @@ struct SYSTEMINFO { ...@@ -14,29 +14,18 @@ struct SYSTEMINFO {
int vSize; int vSize;
int Ticks; int Ticks;
int InputKeys[12]; int InputKeys[12];
//MachineSound sound[4]; /* Dynamic System Info */
// Dynamic System Info
BOOL Back0; BOOL Back0;
BOOL Back1; BOOL Back1;
BOOL Sprites; BOOL Sprites;
}; };
struct EMUINFO { struct EMUINFO
/* char ProgramFolder[_MAX_PATH]; // place holders for filenames {
char SavePath[_MAX_PATH];
char DebugPath[_MAX_PATH];
char RomPath[_MAX_PATH];
char ScreenPath[_MAX_PATH];
char OpenFileName[_MAX_PATH]; // place holders for filenames
char SaveFileName[_MAX_PATH];*/
char RomFileName[_MAX_PATH]; char RomFileName[_MAX_PATH];
int machine; // what kind of machine should we emulate int machine; // what kind of machine should we emulate
int romSize; // what is the size of the currently loaded file int romSize; // what is the size of the currently loaded file
int sample_rate; // what is the current sample rate
int stereo; // play in stereo?
//unsigned int fps;
int samples; int samples;
SYSTEMINFO *drv; SYSTEMINFO *drv;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment