2008-09-02 03:57:21 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* FCE Ultra 0.98.12
|
|
|
|
* Nintendo Wii/Gamecube Port
|
|
|
|
*
|
|
|
|
* Tantric September 2008
|
|
|
|
*
|
|
|
|
* fceugc.c
|
|
|
|
*
|
|
|
|
* This file controls overall program flow. Most things start and end here!
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2008-10-01 07:25:38 +02:00
|
|
|
#include <string.h>
|
2008-09-02 03:57:21 +02:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <gctypes.h>
|
|
|
|
#include <ogc/system.h>
|
|
|
|
#include <fat.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#include "gcvideo.h"
|
|
|
|
#include "pad.h"
|
|
|
|
#include "fceuload.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "menudraw.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "fceuconfig.h"
|
|
|
|
#include "preferences.h"
|
2008-09-04 04:46:04 +02:00
|
|
|
#include "gcaudio.h"
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
#ifdef WII_DVD
|
|
|
|
#include <di/di.h>
|
|
|
|
#endif
|
|
|
|
|
2008-10-01 08:03:16 +02:00
|
|
|
unsigned char * nesrom = NULL;
|
2008-09-02 03:57:21 +02:00
|
|
|
extern bool romLoaded;
|
|
|
|
bool isWii;
|
|
|
|
|
|
|
|
uint8 *xbsave=NULL;
|
|
|
|
|
|
|
|
extern int cleanSFMDATA();
|
|
|
|
extern void ResetNES(void);
|
2008-10-01 07:25:38 +02:00
|
|
|
extern uint8 FDSBIOS[8192];
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef WII_DVD
|
|
|
|
DI_Init(); // first
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int selectedMenu = -1;
|
|
|
|
|
|
|
|
#ifdef HW_RVL
|
|
|
|
WPAD_Init();
|
|
|
|
// read wiimote accelerometer and IR data
|
|
|
|
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
|
|
|
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
initDisplay();
|
|
|
|
|
|
|
|
/*** Initialise freetype ***/
|
|
|
|
if (FT_Init ())
|
|
|
|
{
|
|
|
|
printf ("Cannot initialise font subsystem!\n");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
InitialiseSound();
|
|
|
|
fatInitDefault();
|
|
|
|
#ifndef HW_RVL
|
|
|
|
DVD_Init();
|
|
|
|
#endif
|
|
|
|
|
2008-10-01 08:03:16 +02:00
|
|
|
// allocate memory to store rom
|
2008-10-02 07:28:01 +02:00
|
|
|
nesrom = (unsigned char *)malloc(1024*1024*2); // 2 MB should be plenty
|
2008-10-01 08:03:16 +02:00
|
|
|
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Minimal Emulation Loop ***/
|
|
|
|
if ( !FCEUI_Initialize() ) {
|
|
|
|
printf("Unable to initialize system\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-09-04 04:46:04 +02:00
|
|
|
FCEUI_SetVidSystem(0); // 0 - NTSC, 1 - PAL
|
2008-09-06 05:30:42 +02:00
|
|
|
FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON
|
2008-09-02 03:57:21 +02:00
|
|
|
|
2008-10-01 07:25:38 +02:00
|
|
|
memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory
|
2008-09-06 20:24:52 +02:00
|
|
|
cleanSFMDATA(); // clear state data
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
// Set Defaults
|
|
|
|
DefaultSettings();
|
|
|
|
|
|
|
|
// Load preferences
|
2008-09-04 04:46:04 +02:00
|
|
|
|
|
|
|
if(!LoadPrefs())
|
2008-09-02 03:57:21 +02:00
|
|
|
{
|
|
|
|
WaitPrompt((char*) "Preferences reset - check settings!");
|
|
|
|
selectedMenu = 3; // change to preferences menu
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go to main menu
|
|
|
|
MainMenu (selectedMenu);
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
uint8 *gfx;
|
|
|
|
int32 *sound;
|
|
|
|
int32 ssize;
|
|
|
|
|
|
|
|
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
|
|
|
|
xbsave = gfx;
|
|
|
|
FCEUD_Update(gfx, sound, ssize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* FCEU Support Functions to be written
|
|
|
|
****************************************************************************/
|
2008-10-01 07:25:38 +02:00
|
|
|
// File Control
|
2008-09-02 03:57:21 +02:00
|
|
|
FILE *FCEUD_UTF8fopen(const char *n, const char *m)
|
|
|
|
{
|
2008-10-01 23:00:12 +02:00
|
|
|
return NULL;
|
|
|
|
//return(fopen(n,m));
|
2008-09-02 03:57:21 +02:00
|
|
|
}
|
|
|
|
|
2008-10-01 07:25:38 +02:00
|
|
|
// General Logging
|
2008-09-02 03:57:21 +02:00
|
|
|
void FCEUD_PrintError(char *s)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCEUD_Message(char *text)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-10-01 07:25:38 +02:00
|
|
|
// main interface to FCE Ultra
|
|
|
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int32 Count)
|
2008-09-02 03:57:21 +02:00
|
|
|
{
|
2008-10-01 07:25:38 +02:00
|
|
|
PlaySound(Buffer, Count); // play sound
|
|
|
|
RenderFrame( (char *)XBuf, GCSettings.screenscaler); // output video frame
|
|
|
|
GetJoy(); // check controller input
|
2008-09-02 03:57:21 +02:00
|
|
|
}
|
|
|
|
|
2008-10-01 07:25:38 +02:00
|
|
|
// Netplay
|
2008-09-02 03:57:21 +02:00
|
|
|
int FCEUD_SendData(void *data, uint32 len)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FCEUD_RecvData(void *data, uint32 len)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCEUD_NetworkClose(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCEUD_NetplayText(uint8 *text)
|
|
|
|
{
|
|
|
|
}
|