Simplify a bit more: Remove main_x/main_wii

This commit is contained in:
simon.kagstrom 2010-02-07 15:14:52 +00:00
parent fb256c76d6
commit 1500513de6
5 changed files with 102 additions and 266 deletions

View File

@ -28,7 +28,7 @@
#define C64_NETWORK_BROKER "c64-network.game-host.org"
/* TODO: */
extern char *fixme_tmp_network_server;
extern char *network_server_connect;
static struct timeval tv_start;
@ -61,9 +61,9 @@ void C64::c64_ctor1(void)
this->network_connection_type = NONE;
this->peer = NULL;
if (fixme_tmp_network_server) {
printf("Connecting to %s\n", fixme_tmp_network_server);
strcpy(this->server_hostname, fixme_tmp_network_server);
if (network_server_connect) {
printf("Connecting to %s\n", network_server_connect);
strcpy(this->server_hostname, network_server_connect);
this->peer = new Network(this->server_hostname, this->server_port);
this->network_connection_type = CONNECT;
}

View File

@ -17,6 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <SDL.h>
#include <SDL_ttf.h>
#include "sysdeps.h"
@ -25,9 +27,15 @@
#include "Display.h"
#include "Prefs.h"
#include "SAM.h"
#include "gui/gui.hh"
// Global variables
extern int init_graphics(void);
// Global variables
char Frodo::prefs_path[256] = "";
C64 *TheC64 = NULL; // Global C64 object
char AppDirPath[1024]; // Path of application directory
@ -90,32 +98,99 @@ void Frodo::load_rom_files()
load_rom("1541", DRIVE_ROM_FILE, TheC64->ROM1541, DRIVE_ROM_SIZE, builtin_drive_rom);
}
/*
* Create application object and start it
*/
#ifdef __BEOS__
#include "main_Be.h"
#endif
extern "C" int main(int argc, char **argv)
{
timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_usec);
#ifdef AMIGA
#include "main_Amiga.h"
#endif
// Init SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0) {
fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
return 1;
}
if (TTF_Init() < 0)
{
fprintf(stderr, "Unable to init TTF: %s\n", TTF_GetError() );
return 1;
}
#ifdef __unix
#include "main_x.h"
#endif
if (!init_graphics())
return 1;
fflush(stdout);
#ifdef __mac__
#include "main_mac.h"
#endif
Frodo *the_app = new Frodo();
the_app->ArgvReceived(argc, argv);
the_app->ReadyToRun();
delete the_app;
#ifdef WIN32
#include "main_WIN32.h"
#endif
return 0;
}
#ifdef __riscos__
#include "main_Acorn.h"
#endif
#ifdef GEKKO
#include "main_wii.h"
#endif
/*
* Constructor: Initialize member variables
*/
Frodo::Frodo()
{
TheC64 = NULL;
}
/*
* Process command line arguments
*/
char *network_server_connect = 0;
void Frodo::ArgvReceived(int argc, char **argv)
{
if (argc == 2)
network_server_connect = argv[1];
}
/*
* Arguments processed, run emulation
*/
void Frodo::ReadyToRun(void)
{
getcwd(AppDirPath, 256);
// Load preferences
if (!prefs_path[0]) {
char *home = getenv("HOME");
if (home != NULL && strlen(home) < 240) {
strncpy(prefs_path, home, 200);
strcat(prefs_path, "/");
}
strcat(prefs_path, ".frodorc");
}
ThePrefs.Load(prefs_path);
if (network_server_connect)
strncpy(ThePrefs.NetworkServer, network_server_connect,
sizeof(ThePrefs.NetworkServer));
// Create and start C64
TheC64 = new C64;
Gui::init();
load_rom_files();
TheC64->Run();
delete TheC64;
}
/*
* 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);
}

View File

@ -35,6 +35,8 @@ public:
void ArgvReceived(int argc, char **argv);
void ReadyToRun(void);
void LoadFrodorc();
private:
void load_rom(const char *which, const char *path, uint8 *where, size_t size, const uint8 *builtin);
void load_rom_files();

View File

@ -1,116 +0,0 @@
/*
* main_wii.i - Main program, Wii specific stuff
*
* Frodo (C) 1994-1997,2002 Christian Bauer
*/
#include "Version.h"
#include <SDL.h>
#include <SDL_ttf.h>
#include <fat.h>
#include <wiiuse/wpad.h>
#include <network.h>
#include "gui/gui.hh"
extern int init_graphics(void);
/*
* Create application object and start it
*/
char *fixme_tmp_network_client = 0;
int fixme_tmp_network_server = 0;
extern "C" int main(int argc, char **argv)
{
Frodo *the_app;
timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_usec);
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;
}
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;
// SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
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(PREFS_PATH);
// Create and start C64
TheC64 = new C64;
Gui::init();
load_rom_files();
TheC64->Run();
delete TheC64;
}
/*
* 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);
}

View File

@ -1,125 +0,0 @@
/*
* main_x.h - Main program, Unix specific stuff
*
* Frodo (C) 1994-1997,2002-2005 Christian Bauer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Version.h"
#include <SDL.h>
#include <SDL_ttf.h>
#include "gui/gui.hh"
extern int init_graphics(void);
// Global variables
char Frodo::prefs_path[256] = "";
/*
* Create application object and start it
*/
int main(int argc, char **argv)
{
timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_usec);
// Init SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0) {
fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
return 1;
}
if (TTF_Init() < 0)
{
fprintf(stderr, "Unable to init TTF: %s\n", TTF_GetError() );
return 1;
}
if (!init_graphics())
return 1;
fflush(stdout);
Frodo *the_app = new Frodo();
the_app->ArgvReceived(argc, argv);
the_app->ReadyToRun();
delete the_app;
return 0;
}
/*
* Constructor: Initialize member variables
*/
Frodo::Frodo()
{
TheC64 = NULL;
}
/*
* Process command line arguments
*/
char *fixme_tmp_network_server = 0;
void Frodo::ArgvReceived(int argc, char **argv)
{
if (argc == 2)
fixme_tmp_network_server = argv[1];
}
/*
* Arguments processed, run emulation
*/
void Frodo::ReadyToRun(void)
{
getcwd(AppDirPath, 256);
// Load preferences
if (!prefs_path[0]) {
char *home = getenv("HOME");
if (home != NULL && strlen(home) < 240) {
strncpy(prefs_path, home, 200);
strcat(prefs_path, "/");
}
strcat(prefs_path, ".frodorc");
}
ThePrefs.Load(prefs_path);
// Create and start C64
TheC64 = new C64;
Gui::init();
load_rom_files();
TheC64->Run();
delete TheC64;
}
/*
* 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);
}