2009-01-13 19:46:42 +01:00
|
|
|
/*
|
|
|
|
* main_wii.i - Main program, Wii specific stuff
|
|
|
|
*
|
|
|
|
* Frodo (C) 1994-1997,2002 Christian Bauer
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Version.h"
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <fat.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
2009-03-16 21:56:04 +01:00
|
|
|
#include <network.h>
|
2009-01-13 19:46:42 +01:00
|
|
|
|
2009-02-13 08:58:33 +01:00
|
|
|
#include "menu.h"
|
|
|
|
|
2009-01-13 19:46:42 +01:00
|
|
|
extern int init_graphics(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create application object and start it
|
|
|
|
*/
|
|
|
|
|
2009-02-07 12:28:29 +01:00
|
|
|
char *fixme_tmp_network_client = 0;
|
|
|
|
int fixme_tmp_network_server = 0;
|
|
|
|
|
2009-01-13 19:46:42 +01:00
|
|
|
extern "C" int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
Frodo *the_app;
|
2009-03-16 21:56:04 +01:00
|
|
|
char myIP[16];
|
2009-01-13 19:46:42 +01:00
|
|
|
|
|
|
|
timeval tv;
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
srand(tv.tv_usec);
|
|
|
|
|
2009-03-16 21:56:04 +01:00
|
|
|
/* From Snes9x-gx */
|
|
|
|
while (net_init() == -EAGAIN);
|
|
|
|
|
|
|
|
if (if_config(myIP, NULL, NULL, true) < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\n\n\nError getting IP address via DHCP.\n");
|
|
|
|
sleep(2);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2009-01-13 19:46:42 +01:00
|
|
|
printf("%s by Christian Bauer\n", VERSION_STRING);
|
|
|
|
if (!init_graphics())
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Could not initialize graphics\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fflush(stdout);
|
|
|
|
fatInitDefault();
|
|
|
|
|
|
|
|
// Init SDL
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
|
|
|
fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (TTF_Init() < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Unable to init TTF: %s\n", TTF_GetError() );
|
|
|
|
return 0;
|
|
|
|
}
|
2009-02-13 08:58:33 +01:00
|
|
|
menu_init();
|
2009-01-13 19:46:42 +01:00
|
|
|
|
|
|
|
if (WPAD_Init() != WPAD_ERR_NONE)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed initializing controllers\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
the_app = new Frodo();
|
|
|
|
the_app->ArgvReceived(argc, argv);
|
|
|
|
the_app->ReadyToRun();
|
|
|
|
delete the_app;
|
|
|
|
|
2009-03-08 20:02:19 +01:00
|
|
|
// SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
2009-02-23 19:24:36 +01:00
|
|
|
|
2009-01-13 19:46:42 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Constructor: Initialize member variables
|
|
|
|
*/
|
|
|
|
|
|
|
|
Frodo::Frodo()
|
|
|
|
{
|
|
|
|
TheC64 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process command line arguments
|
|
|
|
*/
|
|
|
|
|
|
|
|
void Frodo::ArgvReceived(int argc, char **argv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Arguments processed, run emulation
|
|
|
|
*/
|
|
|
|
|
|
|
|
void Frodo::ReadyToRun(void)
|
|
|
|
{
|
|
|
|
getcwd(AppDirPath, 256);
|
|
|
|
|
|
|
|
ThePrefs.Load((char*)PREFS_PATH);
|
|
|
|
|
|
|
|
// Create and start C64
|
|
|
|
TheC64 = new C64;
|
|
|
|
load_rom_files();
|
|
|
|
TheC64->Run();
|
|
|
|
delete TheC64;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Prefs *Frodo::reload_prefs(void)
|
|
|
|
{
|
|
|
|
static Prefs newprefs;
|
|
|
|
newprefs.Load((char*)PREFS_PATH);
|
|
|
|
return &newprefs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine whether path name refers to a directory
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool IsDirectory(const char *path)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
|
|
|
|
}
|