2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-02-02 19:20:27 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-02-02 19:20:27 +00:00
|
|
|
*
|
2006-02-09 13:25:53 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-02-02 19:20:27 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-06-18 21:15:08 +00:00
|
|
|
#include <common/scummsys.h>
|
2006-10-07 21:05:31 +00:00
|
|
|
#include <engines/engine.h>
|
2006-04-02 00:08:22 +00:00
|
|
|
#include <base/main.h>
|
2003-12-21 18:26:56 +00:00
|
|
|
#include <base/plugins.h>
|
2002-02-02 15:44:27 +00:00
|
|
|
#include "dc.h"
|
2002-02-02 23:33:24 +00:00
|
|
|
#include "icon.h"
|
2004-08-26 21:51:26 +00:00
|
|
|
#include "DCLauncherDialog.h"
|
2005-04-27 21:58:21 +00:00
|
|
|
#include <common/config-manager.h>
|
2002-02-02 23:33:24 +00:00
|
|
|
|
2006-10-07 01:05:12 +00:00
|
|
|
#include "backends/plugins/dc/dc-provider.h"
|
2006-10-22 17:58:38 +00:00
|
|
|
#include "sound/mixer.h"
|
2006-10-07 01:05:12 +00:00
|
|
|
|
2002-02-02 15:44:27 +00:00
|
|
|
|
2002-02-02 23:33:24 +00:00
|
|
|
Icon icon;
|
2002-10-18 01:38:01 +00:00
|
|
|
const char *gGameName;
|
2002-02-02 15:44:27 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
|
2003-06-18 21:06:03 +00:00
|
|
|
OSystem_Dreamcast::OSystem_Dreamcast()
|
2006-02-09 12:30:52 +00:00
|
|
|
: _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this),
|
2006-10-22 18:35:49 +00:00
|
|
|
_ms_buf(NULL), _timer(NULL), _mixer(NULL), _savefile(NULL),
|
2006-02-09 12:30:52 +00:00
|
|
|
_current_shake_pos(0), _aspect_stretch(false), _softkbd_on(false),
|
|
|
|
_softkbd_motion(0), _enable_cursor_palette(false)
|
2003-06-18 21:06:03 +00:00
|
|
|
{
|
|
|
|
memset(screen_tx, 0, sizeof(screen_tx));
|
2004-03-13 17:32:28 +00:00
|
|
|
memset(mouse_tx, 0, sizeof(mouse_tx));
|
|
|
|
memset(ovl_tx, 0, sizeof(ovl_tx));
|
2003-06-18 21:06:03 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 17:58:38 +00:00
|
|
|
void OSystem_Dreamcast::initBackend()
|
|
|
|
{
|
|
|
|
_savefile = createSavefileManager();
|
|
|
|
_mixer = new Audio::Mixer();
|
|
|
|
_timer = new DefaultTimerManager();
|
|
|
|
}
|
|
|
|
|
2003-06-18 21:06:03 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
/* CD Audio */
|
|
|
|
static bool find_track(int track, int &first_sec, int &last_sec)
|
|
|
|
{
|
|
|
|
struct TOC *toc = cdfs_gettoc();
|
2007-09-18 20:16:33 +00:00
|
|
|
if (!toc)
|
2002-04-18 23:21:40 +00:00
|
|
|
return false;
|
|
|
|
int i, first, last;
|
|
|
|
first = TOC_TRACK(toc->first);
|
|
|
|
last = TOC_TRACK(toc->last);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (first < 1 || last > 99 || first > last)
|
2002-04-18 23:21:40 +00:00
|
|
|
return false;
|
2007-09-18 20:16:33 +00:00
|
|
|
for (i=first; i<=last; i++)
|
|
|
|
if (!(TOC_CTRL(toc->entry[i-1])&4))
|
|
|
|
if (track==1) {
|
2002-04-18 23:21:40 +00:00
|
|
|
first_sec = TOC_LBA(toc->entry[i-1]);
|
|
|
|
last_sec = TOC_LBA(toc->entry[i]);
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
--track;
|
|
|
|
return false;
|
|
|
|
}
|
2002-03-16 05:33:25 +00:00
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
void OSystem_Dreamcast::playCD(int track, int num_loops, int start_frame, int duration)
|
2002-04-18 23:21:40 +00:00
|
|
|
{
|
|
|
|
int first_sec, last_sec;
|
|
|
|
#if 1
|
2007-09-18 20:16:33 +00:00
|
|
|
if (num_loops)
|
2002-04-18 23:21:40 +00:00
|
|
|
--num_loops;
|
|
|
|
#endif
|
2007-09-18 20:16:33 +00:00
|
|
|
if (num_loops>14) num_loops=14;
|
|
|
|
else if (num_loops<0) num_loops=15; // infinity
|
|
|
|
if (!find_track(track, first_sec, last_sec))
|
2002-04-18 23:21:40 +00:00
|
|
|
return;
|
2007-09-18 20:16:33 +00:00
|
|
|
if (duration)
|
2003-07-22 20:36:43 +00:00
|
|
|
last_sec = first_sec + start_frame + duration;
|
2002-04-18 23:21:40 +00:00
|
|
|
first_sec += start_frame;
|
|
|
|
play_cdda_sectors(first_sec, last_sec, num_loops);
|
2002-02-25 20:42:46 +00:00
|
|
|
}
|
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
void OSystem_Dreamcast::stopCD()
|
2002-04-18 23:21:40 +00:00
|
|
|
{
|
|
|
|
stop_cdda();
|
2002-02-25 20:42:46 +00:00
|
|
|
}
|
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
bool OSystem_Dreamcast::pollCD()
|
2002-04-18 23:21:40 +00:00
|
|
|
{
|
|
|
|
extern int getCdState();
|
|
|
|
return getCdState() == 3;
|
|
|
|
}
|
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
void OSystem_Dreamcast::updateCD()
|
2002-04-18 23:21:40 +00:00
|
|
|
{
|
|
|
|
// Dummy. The CD drive takes care of itself.
|
|
|
|
}
|
|
|
|
|
2004-03-13 13:41:50 +00:00
|
|
|
bool OSystem_Dreamcast::openCD(int drive)
|
2002-04-18 23:21:40 +00:00
|
|
|
{
|
2004-03-13 13:41:50 +00:00
|
|
|
// Dummy.
|
|
|
|
return true;
|
|
|
|
}
|
2002-10-18 01:38:01 +00:00
|
|
|
|
2004-03-13 13:41:50 +00:00
|
|
|
void OSystem_Dreamcast::setWindowCaption(const char *caption)
|
|
|
|
{
|
|
|
|
gGameName = caption;
|
2002-04-18 23:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Dreamcast::quit() {
|
2008-01-03 13:28:04 +00:00
|
|
|
(*(void(**)(int))0x8c0000e0)(0);
|
2002-04-18 23:21:40 +00:00
|
|
|
}
|
|
|
|
|
2002-09-13 15:01:20 +00:00
|
|
|
/* Mutex handling */
|
2004-02-28 12:58:13 +00:00
|
|
|
OSystem::MutexRef OSystem_Dreamcast::createMutex()
|
2002-09-13 15:01:20 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-02-28 12:58:13 +00:00
|
|
|
void OSystem_Dreamcast::lockMutex(MutexRef mutex)
|
2002-09-13 15:01:20 +00:00
|
|
|
{
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-02-28 12:58:13 +00:00
|
|
|
void OSystem_Dreamcast::unlockMutex(MutexRef mutex)
|
2002-09-13 15:01:20 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-02-28 12:58:13 +00:00
|
|
|
void OSystem_Dreamcast::deleteMutex(MutexRef mutex)
|
2002-09-13 15:01:20 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-13 14:00:44 +00:00
|
|
|
/* Features */
|
|
|
|
bool OSystem_Dreamcast::hasFeature(Feature f)
|
|
|
|
{
|
|
|
|
switch(f) {
|
|
|
|
case kFeatureAspectRatioCorrection:
|
|
|
|
case kFeatureVirtualKeyboard:
|
2005-04-19 20:35:48 +00:00
|
|
|
case kFeatureOverlaySupportsAlpha:
|
2005-10-15 14:33:58 +00:00
|
|
|
case kFeatureCursorHasPalette:
|
2004-03-13 14:00:44 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Dreamcast::setFeatureState(Feature f, bool enable)
|
|
|
|
{
|
|
|
|
switch(f) {
|
|
|
|
case kFeatureAspectRatioCorrection:
|
2004-03-13 17:32:28 +00:00
|
|
|
_aspect_stretch = enable;
|
2007-09-18 20:16:33 +00:00
|
|
|
if (screen)
|
2004-03-13 17:32:28 +00:00
|
|
|
setScaling();
|
2004-03-13 14:00:44 +00:00
|
|
|
break;
|
|
|
|
case kFeatureVirtualKeyboard:
|
2004-03-14 22:16:22 +00:00
|
|
|
_softkbd_on = enable;
|
2004-03-13 14:00:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_Dreamcast::getFeatureState(Feature f)
|
|
|
|
{
|
|
|
|
switch(f) {
|
|
|
|
case kFeatureAspectRatioCorrection:
|
2004-03-13 17:32:28 +00:00
|
|
|
return _aspect_stretch;
|
2004-03-13 14:00:44 +00:00
|
|
|
case kFeatureVirtualKeyboard:
|
2004-03-14 22:16:22 +00:00
|
|
|
return _softkbd_on;
|
2004-03-13 14:00:44 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-01 22:12:52 +00:00
|
|
|
void OSystem_Dreamcast::getTimeAndDate(struct tm &t) const {
|
|
|
|
time_t curTime;
|
|
|
|
time(&curTime);
|
|
|
|
t = *localtime(&curTime);
|
|
|
|
}
|
2004-03-13 14:00:44 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
void dc_init_hardware()
|
2002-02-02 15:44:27 +00:00
|
|
|
{
|
|
|
|
#ifndef NOSERIAL
|
|
|
|
serial_init(57600);
|
|
|
|
usleep(2000000);
|
|
|
|
printf("Serial OK\r\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cdfs_init();
|
|
|
|
maple_init();
|
|
|
|
dc_setup_ta();
|
|
|
|
init_arm();
|
2002-05-14 11:32:16 +00:00
|
|
|
}
|
|
|
|
|
2002-10-18 01:38:01 +00:00
|
|
|
int main()
|
2002-05-14 11:32:16 +00:00
|
|
|
{
|
2004-08-26 21:51:26 +00:00
|
|
|
static char *argv[] = { "scummvm", NULL, };
|
|
|
|
static int argc = 1;
|
2002-02-02 15:44:27 +00:00
|
|
|
|
2002-10-18 01:38:01 +00:00
|
|
|
dc_init_hardware();
|
2002-02-18 18:58:15 +00:00
|
|
|
initSound();
|
|
|
|
|
2006-04-02 14:16:31 +00:00
|
|
|
g_system = new OSystem_Dreamcast();
|
|
|
|
assert(g_system);
|
|
|
|
|
2006-10-07 01:05:12 +00:00
|
|
|
#ifdef DYNAMIC_MODULES
|
|
|
|
PluginManager::instance().addPluginProvider(new DCPluginProvider());
|
|
|
|
#endif
|
|
|
|
|
2006-04-02 14:31:23 +00:00
|
|
|
int res = scummvm_main(argc, argv);
|
2004-08-26 21:51:26 +00:00
|
|
|
|
2008-01-03 13:28:04 +00:00
|
|
|
g_system->quit();
|
2004-08-26 21:51:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int DCLauncherDialog::runModal()
|
|
|
|
{
|
2005-04-27 21:58:21 +00:00
|
|
|
char *base = NULL, *dir = NULL;
|
2003-12-21 18:26:56 +00:00
|
|
|
|
2007-09-18 20:16:33 +00:00
|
|
|
if (!selectGame(base, dir, icon))
|
2008-01-03 13:28:04 +00:00
|
|
|
g_system->quit();
|
2002-02-02 15:44:27 +00:00
|
|
|
|
2005-04-22 21:30:07 +00:00
|
|
|
// Set the game path.
|
2006-05-04 21:44:36 +00:00
|
|
|
ConfMan.addGameDomain(base);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (dir != NULL)
|
2006-05-04 21:44:36 +00:00
|
|
|
ConfMan.set("path", dir, base);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-22 21:30:07 +00:00
|
|
|
// Set the target.
|
2006-05-05 00:26:03 +00:00
|
|
|
ConfMan.setActiveDomain(base);
|
2005-04-22 21:30:07 +00:00
|
|
|
|
2004-08-26 21:51:26 +00:00
|
|
|
return 0;
|
2002-02-02 15:44:27 +00:00
|
|
|
}
|
2004-08-26 21:51:26 +00:00
|
|
|
|