aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/dc/dcmain.cpp
diff options
context:
space:
mode:
authorMarcus Comstedt2006-06-30 20:21:42 +0000
committerMarcus Comstedt2006-06-30 20:21:42 +0000
commit25f68b08ab8c1fc35aab2d060b0f38ebf7856785 (patch)
tree7a5847167a031aaa1eaeb6e3cb1a5bd8e8161330 /backends/platform/dc/dcmain.cpp
parent8c5ead1f70ec3bb49e6633af0192bbcc90f4a1bf (diff)
downloadscummvm-rg350-25f68b08ab8c1fc35aab2d060b0f38ebf7856785.tar.gz
scummvm-rg350-25f68b08ab8c1fc35aab2d060b0f38ebf7856785.tar.bz2
scummvm-rg350-25f68b08ab8c1fc35aab2d060b0f38ebf7856785.zip
Moved backends/dc into new platform directory.
svn-id: r23357
Diffstat (limited to 'backends/platform/dc/dcmain.cpp')
-rw-r--r--backends/platform/dc/dcmain.cpp230
1 files changed, 230 insertions, 0 deletions
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
new file mode 100644
index 0000000000..4b03ec1551
--- /dev/null
+++ b/backends/platform/dc/dcmain.cpp
@@ -0,0 +1,230 @@
+/* ScummVM - Scumm Interpreter
+ * Dreamcast port
+ * Copyright (C) 2002-2004 Marcus Comstedt
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include <common/stdafx.h>
+#include <common/scummsys.h>
+#include <base/engine.h>
+#include <base/main.h>
+#include <base/plugins.h>
+#include "dc.h"
+#include "icon.h"
+#include "DCLauncherDialog.h"
+#include <common/config-manager.h>
+
+
+Icon icon;
+const char *gGameName;
+
+
+OSystem_Dreamcast::OSystem_Dreamcast()
+ : _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this),
+ _ms_buf(NULL), _sound_proc(NULL), _timer_active(false),
+ _current_shake_pos(0), _aspect_stretch(false), _softkbd_on(false),
+ _softkbd_motion(0), _enable_cursor_palette(false)
+{
+ memset(screen_tx, 0, sizeof(screen_tx));
+ memset(mouse_tx, 0, sizeof(mouse_tx));
+ memset(ovl_tx, 0, sizeof(ovl_tx));
+}
+
+
+/* CD Audio */
+static bool find_track(int track, int &first_sec, int &last_sec)
+{
+ struct TOC *toc = cdfs_gettoc();
+ if(!toc)
+ return false;
+ int i, first, last;
+ first = TOC_TRACK(toc->first);
+ last = TOC_TRACK(toc->last);
+ if(first < 1 || last > 99 || first > last)
+ return false;
+ for(i=first; i<=last; i++)
+ if(!(TOC_CTRL(toc->entry[i-1])&4))
+ if(track==1) {
+ first_sec = TOC_LBA(toc->entry[i-1]);
+ last_sec = TOC_LBA(toc->entry[i]);
+ return true;
+ } else
+ --track;
+ return false;
+}
+
+void OSystem_Dreamcast::playCD(int track, int num_loops, int start_frame, int duration)
+{
+ int first_sec, last_sec;
+#if 1
+ if(num_loops)
+ --num_loops;
+#endif
+ if(num_loops>14) num_loops=14;
+ else if(num_loops<0) num_loops=15; // infinity
+ if(!find_track(track, first_sec, last_sec))
+ return;
+ if(duration)
+ last_sec = first_sec + start_frame + duration;
+ first_sec += start_frame;
+ play_cdda_sectors(first_sec, last_sec, num_loops);
+}
+
+void OSystem_Dreamcast::stopCD()
+{
+ stop_cdda();
+}
+
+bool OSystem_Dreamcast::pollCD()
+{
+ extern int getCdState();
+ return getCdState() == 3;
+}
+
+void OSystem_Dreamcast::updateCD()
+{
+ // Dummy. The CD drive takes care of itself.
+}
+
+bool OSystem_Dreamcast::openCD(int drive)
+{
+ // Dummy.
+ return true;
+}
+
+void OSystem_Dreamcast::setWindowCaption(const char *caption)
+{
+ gGameName = caption;
+}
+
+void OSystem_Dreamcast::quit() {
+ exit(0);
+}
+
+/* Mutex handling */
+OSystem::MutexRef OSystem_Dreamcast::createMutex()
+{
+ return NULL;
+}
+
+void OSystem_Dreamcast::lockMutex(MutexRef mutex)
+{
+}
+
+void OSystem_Dreamcast::unlockMutex(MutexRef mutex)
+{
+}
+
+void OSystem_Dreamcast::deleteMutex(MutexRef mutex)
+{
+}
+
+
+/* Features */
+bool OSystem_Dreamcast::hasFeature(Feature f)
+{
+ switch(f) {
+ case kFeatureAspectRatioCorrection:
+ case kFeatureVirtualKeyboard:
+ case kFeatureOverlaySupportsAlpha:
+ case kFeatureCursorHasPalette:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void OSystem_Dreamcast::setFeatureState(Feature f, bool enable)
+{
+ switch(f) {
+ case kFeatureAspectRatioCorrection:
+ _aspect_stretch = enable;
+ if(screen)
+ setScaling();
+ break;
+ case kFeatureVirtualKeyboard:
+ _softkbd_on = enable;
+ break;
+ default:
+ break;
+ }
+}
+
+bool OSystem_Dreamcast::getFeatureState(Feature f)
+{
+ switch(f) {
+ case kFeatureAspectRatioCorrection:
+ return _aspect_stretch;
+ case kFeatureVirtualKeyboard:
+ return _softkbd_on;
+ default:
+ return false;
+ }
+}
+
+
+void dc_init_hardware()
+{
+#ifndef NOSERIAL
+ serial_init(57600);
+ usleep(2000000);
+ printf("Serial OK\r\n");
+#endif
+
+ cdfs_init();
+ maple_init();
+ dc_setup_ta();
+ init_arm();
+}
+
+int main()
+{
+ static char *argv[] = { "scummvm", NULL, };
+ static int argc = 1;
+
+ dc_init_hardware();
+ initSound();
+
+ g_system = new OSystem_Dreamcast();
+ assert(g_system);
+
+ int res = scummvm_main(argc, argv);
+
+ exit(0);
+}
+
+int DCLauncherDialog::runModal()
+{
+ char *base = NULL, *dir = NULL;
+
+ if(!selectGame(base, dir, icon))
+ exit(0);
+
+ // Set the game path.
+ ConfMan.addGameDomain(base);
+ if(dir != NULL)
+ ConfMan.set("path", dir, base);
+
+ // Set the target.
+ ConfMan.setActiveDomain(base);
+
+ return 0;
+}
+