frodo-wii/Src/main.cpp

111 lines
2.6 KiB
C++
Raw Permalink Normal View History

2008-12-31 17:16:24 +01:00
/*
* main.cpp - Main program
*
2009-01-12 20:54:49 +01:00
* 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
2008-12-31 17:16:24 +01:00
*/
#include "sysdeps.h"
#include "main.h"
#include "C64.h"
#include "Display.h"
#include "Prefs.h"
#include "SAM.h"
// Global variables
2009-01-12 20:54:49 +01:00
C64 *TheC64 = NULL; // Global C64 object
2008-12-31 17:16:24 +01:00
char AppDirPath[1024]; // Path of application directory
// ROM file names
2009-01-12 20:54:49 +01:00
#ifndef DATADIR
#define DATADIR
#endif
2008-12-31 17:16:24 +01:00
#ifdef __riscos__
#define BASIC_ROM_FILE "FrodoRsrc:Basic_ROM"
#define KERNAL_ROM_FILE "FrodoRsrc:Kernal_ROM"
#define CHAR_ROM_FILE "FrodoRsrc:Char_ROM"
2009-01-12 20:54:49 +01:00
#define DRIVE_ROM_FILE "FrodoRsrc:1541_ROM"
2008-12-31 17:16:24 +01:00
#else
2009-01-12 20:54:49 +01:00
#define BASIC_ROM_FILE DATADIR "Basic ROM"
#define KERNAL_ROM_FILE DATADIR "Kernal ROM"
#define CHAR_ROM_FILE DATADIR "Char ROM"
#define DRIVE_ROM_FILE DATADIR "1541 ROM"
2008-12-31 17:16:24 +01:00
#endif
2009-01-12 20:54:49 +01:00
// Builtin ROMs
#include "Basic_ROM.h"
#include "Kernal_ROM.h"
#include "Char_ROM.h"
#include "1541_ROM.h"
2008-12-31 17:16:24 +01:00
/*
* Load C64 ROM files
*/
2009-01-12 20:54:49 +01:00
void Frodo::load_rom(const char *which, const char *path, uint8 *where, size_t size, const uint8 *builtin)
2008-12-31 17:16:24 +01:00
{
2009-01-12 20:54:49 +01:00
FILE *f = fopen(path, "rb");
if (f) {
size_t actual = fread(where, 1, size, f);
fclose(f);
if (actual == size)
return;
2008-12-31 17:16:24 +01:00
}
2009-01-12 20:54:49 +01:00
// Use builtin ROM
printf("%s ROM file (%s) not readable, using builtin.\n", which, path);
memcpy(where, builtin, size);
}
2008-12-31 17:16:24 +01:00
2009-01-12 20:54:49 +01:00
void Frodo::load_rom_files()
{
load_rom("Basic", BASIC_ROM_FILE, TheC64->Basic, BASIC_ROM_SIZE, builtin_basic_rom);
load_rom("Kernal", KERNAL_ROM_FILE, TheC64->Kernal, KERNAL_ROM_SIZE, builtin_kernal_rom);
load_rom("Char", CHAR_ROM_FILE, TheC64->Char, CHAR_ROM_SIZE, builtin_char_rom);
load_rom("1541", DRIVE_ROM_FILE, TheC64->ROM1541, DRIVE_ROM_SIZE, builtin_drive_rom);
2008-12-31 17:16:24 +01:00
}
#ifdef __BEOS__
2009-01-12 20:54:49 +01:00
#include "main_Be.h"
2008-12-31 17:16:24 +01:00
#endif
#ifdef AMIGA
2009-01-12 20:54:49 +01:00
#include "main_Amiga.h"
2008-12-31 17:16:24 +01:00
#endif
#ifdef __unix
2009-01-12 20:54:49 +01:00
#include "main_x.h"
2008-12-31 17:16:24 +01:00
#endif
#ifdef __mac__
2009-01-12 20:54:49 +01:00
#include "main_mac.h"
2008-12-31 17:16:24 +01:00
#endif
#ifdef WIN32
2009-01-12 20:54:49 +01:00
#include "main_WIN32.h"
2008-12-31 17:16:24 +01:00
#endif
2009-01-12 20:54:49 +01:00
#ifdef __riscos__
#include "main_Acorn.h"
2008-12-31 17:16:24 +01:00
#endif