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.
|
2006-07-09 11:47:17 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "system.h"
|
|
|
|
|
|
|
|
#include "common/util.h"
|
|
|
|
#include "common/rect.h"
|
|
|
|
#include "common/savefile.h"
|
|
|
|
|
|
|
|
#include "osystem_ds.h"
|
|
|
|
#include "nds.h"
|
|
|
|
#include "dsmain.h"
|
|
|
|
#include "nds/registers_alt.h"
|
|
|
|
#include "config-manager.h"
|
|
|
|
#include "common/str.h"
|
|
|
|
#include "cdaudio.h"
|
|
|
|
#include "graphics/surface.h"
|
2007-06-30 23:03:03 +00:00
|
|
|
#include "touchkeyboard.h"
|
2006-07-09 11:47:17 +00:00
|
|
|
|
|
|
|
OSystem_DS* OSystem_DS::_instance = NULL;
|
|
|
|
|
|
|
|
OSystem_DS::OSystem_DS()
|
2007-12-21 18:36:40 +00:00
|
|
|
: eventNum(0), lastPenFrame(0), queuePos(0), _mixer(NULL), _timer(NULL), _frameBufferExists(false)
|
2006-07-09 11:47:17 +00:00
|
|
|
{
|
2007-12-21 18:36:40 +00:00
|
|
|
// eventNum = 0;
|
|
|
|
// lastPenFrame = 0;
|
|
|
|
// queuePos = 0;
|
2006-07-09 11:47:17 +00:00
|
|
|
_instance = this;
|
2007-12-21 18:36:40 +00:00
|
|
|
// _mixer = NULL;
|
|
|
|
// _timer = NULL;
|
|
|
|
//_frameBufferExists = false;
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OSystem_DS::~OSystem_DS() {
|
2006-11-03 23:16:29 +00:00
|
|
|
delete _mixer;
|
|
|
|
delete _timer;
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
|
2006-11-03 23:16:29 +00:00
|
|
|
int OSystem_DS::timerHandler(int t)
|
2006-10-25 19:37:43 +00:00
|
|
|
{
|
|
|
|
DSTimerManager *tm = (DSTimerManager *)g_system->getTimerManager();
|
|
|
|
tm->handler();
|
|
|
|
return t;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
void OSystem_DS::initBackend() {
|
|
|
|
ConfMan.setInt("autosave_period", 0);
|
2006-11-03 23:16:29 +00:00
|
|
|
ConfMan.setBool("FM_medium_quality", true);
|
2006-10-22 15:42:29 +00:00
|
|
|
|
2006-10-25 19:18:38 +00:00
|
|
|
_mixer = new DSAudioMixer;
|
|
|
|
_timer = new DSTimerManager;
|
2006-10-25 19:37:43 +00:00
|
|
|
DS::setSoundProc(Audio::Mixer::mixCallback, _mixer);
|
2006-11-03 23:16:29 +00:00
|
|
|
DS::setTimerCallback(&OSystem_DS::timerHandler, 10);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-10-22 15:42:29 +00:00
|
|
|
OSystem::initBackend();
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_DS::hasFeature(Feature f) {
|
|
|
|
// consolePrintf("hasfeature\n");
|
|
|
|
return (f == kFeatureVirtualKeyboard);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::setFeatureState(Feature f, bool enable) {
|
|
|
|
// consolePrintf("setfeature f=%d e=%d\n", f, enable);
|
|
|
|
if (f == kFeatureVirtualKeyboard) DS::setKeyboardIcon(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_DS::getFeatureState(Feature f) {
|
|
|
|
// consolePrintf("getfeat\n");
|
|
|
|
if (f == kFeatureVirtualKeyboard) return DS::getKeyboardIcon();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OSystem::GraphicsMode* OSystem_DS::getSupportedGraphicsModes() const {
|
|
|
|
return s_supportedGraphicsModes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int OSystem_DS::getDefaultGraphicsMode() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_DS::setGraphicsMode(int mode) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_DS::setGraphicsMode(const char *name) {
|
|
|
|
// consolePrintf("Set gfx mode %s\n", name);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int OSystem_DS::getGraphicsMode() const {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::initSize(uint width, uint height) {
|
|
|
|
// consolePrintf("Set gfx mode %d x %d\n", width, height);
|
|
|
|
DS::setGameSize(width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_DS::getHeight() {
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_DS::getWidth() {
|
|
|
|
return 320;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
|
|
|
|
// consolePrintf("Set palette %d, %d colours\n", start, num);
|
2006-11-03 23:16:29 +00:00
|
|
|
//return;
|
2006-07-09 11:47:17 +00:00
|
|
|
if (!DS::getIsDisplayMode8Bit()) return;
|
|
|
|
for (unsigned int r = start; r < start + num; r++) {
|
|
|
|
int red = *colors;
|
|
|
|
int green = *(colors + 1);
|
|
|
|
int blue = *(colors + 2);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
red >>= 3;
|
|
|
|
green >>= 3;
|
|
|
|
blue >>= 3;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-06-30 23:03:03 +00:00
|
|
|
// if (r != 255)
|
2008-01-27 19:47:41 +00:00
|
|
|
{
|
2007-06-30 23:03:03 +00:00
|
|
|
BG_PALETTE[r] = red | (green << 5) | (blue << 10);
|
|
|
|
if (!DS::getKeyboardEnable()) {
|
|
|
|
BG_PALETTE_SUB[r] = red | (green << 5) | (blue << 10);
|
|
|
|
}
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
// if (num == 16) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
colors += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-18 11:10:41 +00:00
|
|
|
bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
|
|
|
|
surf->create(DS::getGameWidth(), DS::getGameHeight(), 1);
|
|
|
|
|
|
|
|
// Ensure we copy using 16 bit quantities due to limitation of VRAM addressing
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-08-18 11:10:41 +00:00
|
|
|
|
|
|
|
u16* image = (u16 *) DS::get8BitBackBuffer();
|
|
|
|
for (int y = 0; y < DS::getGameHeight(); y++)
|
|
|
|
{
|
|
|
|
DC_FlushRange(image + (y << 8), DS::getGameWidth());
|
|
|
|
for (int x = 0; x < DS::getGameWidth() >> 1; x++)
|
|
|
|
{
|
|
|
|
*(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y << 8 + x];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2006-07-09 11:47:17 +00:00
|
|
|
|
|
|
|
void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) {
|
|
|
|
// consolePrintf("Grabpalette");
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
for (unsigned int r = start; r < start + num; r++) {
|
|
|
|
*colors++ = (BG_PALETTE[r] & 0x001F) << 3;
|
|
|
|
*colors++ = (BG_PALETTE[r] & 0x03E0) >> 5 << 3;
|
|
|
|
*colors++ = (BG_PALETTE[r] & 0x7C00) >> 10 << 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
// consolePrintf("Copy rect %d, %d %d, %d ", x, y, w, h);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
if (w <= 1) return;
|
|
|
|
if (h < 0) return;
|
|
|
|
if (!DS::getIsDisplayMode8Bit()) return;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
u16* bgSub = (u16 *) BG_GFX_SUB;
|
|
|
|
u16* bg = (u16 *) DS::get8BitBackBuffer();
|
|
|
|
u16* src = (u16 *) buf;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
if (DS::getKeyboardEnable()) {
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-06-30 23:03:03 +00:00
|
|
|
for (int dy = y; dy < y + h; dy++) {
|
2006-07-09 11:47:17 +00:00
|
|
|
u16* dest = bg + (dy << 8) + (x >> 1);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
DC_FlushRange(src, w << 1);
|
|
|
|
DC_FlushRange(dest, w << 1);
|
|
|
|
dmaCopyHalfWords(3, src, dest, w);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
src += pitch >> 1;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
} else {
|
2007-06-30 23:03:03 +00:00
|
|
|
for (int dy = y; dy < y + h; dy++) {
|
2006-07-09 11:47:17 +00:00
|
|
|
u16* dest1 = bg + (dy << 8) + (x >> 1);
|
|
|
|
u16* dest2 = bgSub + (dy << 8) + (x >> 1);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
DC_FlushRange(src, w << 1);
|
|
|
|
DC_FlushRange(dest1, w << 1);
|
|
|
|
DC_FlushRange(dest2, w << 1);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
dmaCopyHalfWords(3, src, dest1, w);
|
|
|
|
dmaCopyHalfWords(3, src, dest2, w);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
src += pitch >> 1;
|
|
|
|
}
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
// consolePrintf("Done\n");
|
2008-01-27 19:47:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::updateScreen()
|
|
|
|
{
|
2007-12-21 18:36:40 +00:00
|
|
|
|
|
|
|
if (_frameBufferExists)
|
|
|
|
{
|
|
|
|
// Copy temp framebuffer back to screen
|
|
|
|
copyRectToScreen((byte *)_framebuffer.pixels, _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-12-21 18:36:40 +00:00
|
|
|
// Free memory
|
|
|
|
_framebuffer.free();
|
|
|
|
|
|
|
|
_frameBufferExists = false;
|
|
|
|
}
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
DS::displayMode16BitFlipBuffer();
|
|
|
|
DS::doSoundCallback();
|
|
|
|
// DS::doTimerCallback();
|
|
|
|
DS::addEventsToQueue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::setShakePos(int shakeOffset) {
|
|
|
|
DS::setShakePos(shakeOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::showOverlay ()
|
|
|
|
{
|
|
|
|
// consolePrintf("showovl\n");
|
|
|
|
DS::displayMode16Bit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::hideOverlay ()
|
|
|
|
{
|
|
|
|
DS::displayMode8Bit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::clearOverlay ()
|
|
|
|
{
|
|
|
|
memset((u16 *) DS::get16BitBackBuffer(), 0, 512 * 256 * 2);
|
|
|
|
// consolePrintf("clearovl\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::grabOverlay (OverlayColor *buf, int pitch)
|
|
|
|
{
|
|
|
|
// consolePrintf("grabovl\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
u16* bg = (u16 *) DS::get16BitBackBuffer();
|
|
|
|
u16* src = (u16 *) buf;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
// if (x + w > 256) w = 256 - x;
|
|
|
|
//if (x + h > 256) h = 256 - y;
|
|
|
|
|
|
|
|
// consolePrintf("Copy rect ovl %d, %d %d, %d %d\n", x, y, w, h, pitch);
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
for (int dy = y; dy < y + h; dy++) {
|
2008-01-27 19:47:41 +00:00
|
|
|
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
// Slow but save copy:
|
|
|
|
for (int dx = x; dx < x + w; dx++) {
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
*(bg + (dy * 512) + dx) = *src;
|
|
|
|
//if ((*src) != 0) consolePrintf("%d,%d: %d ", dx, dy, *src);
|
|
|
|
//consolePrintf("%d,", *src);
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
src += (pitch - w);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
// Fast but broken copy: (why?)
|
|
|
|
/*
|
|
|
|
REG_IME = 0;
|
|
|
|
dmaCopy(src, bg + (dy << 9) + x, w * 2);
|
|
|
|
REG_IME = 1;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
src += pitch;*/
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
// consolePrintf("Copy rect ovl done");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_DS::getOverlayHeight()
|
|
|
|
{
|
|
|
|
// consolePrintf("getovlheight\n");
|
|
|
|
return getHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_DS::getOverlayWidth()
|
|
|
|
{
|
|
|
|
// consolePrintf("getovlwid\n");
|
|
|
|
return getWidth();
|
|
|
|
}
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
bool OSystem_DS::showMouse(bool visible)
|
|
|
|
{
|
2007-06-30 23:03:03 +00:00
|
|
|
DS::setShowCursor(visible);
|
2006-07-09 11:47:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::warpMouse(int x, int y)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetCursorScale) {
|
2007-06-30 23:03:03 +00:00
|
|
|
DS::setCursorIcon(buf, w, h, keycolor, hotspotX, hotspotY);
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
void OSystem_DS::addEvent(Common::Event& e) {
|
2006-07-09 11:47:17 +00:00
|
|
|
eventQueue[queuePos++] = e;
|
|
|
|
}
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
bool OSystem_DS::pollEvent(Common::Event &event)
|
2006-07-09 11:47:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (lastPenFrame != DS::getMillis()) {
|
|
|
|
|
|
|
|
if (eventNum == queuePos) {
|
|
|
|
eventNum = 0;
|
|
|
|
queuePos = 0;
|
|
|
|
// Bodge - this last event seems to be processed sometimes and not others.
|
|
|
|
// So we make it something harmless which won't cause any adverse effects.
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_KEYUP;
|
2006-07-09 11:47:17 +00:00
|
|
|
event.kbd.ascii = 0;
|
2007-08-18 11:10:41 +00:00
|
|
|
event.kbd.keycode = Common::KEYCODE_INVALID;
|
2006-07-09 11:47:17 +00:00
|
|
|
event.kbd.flags = 0;
|
2007-06-30 23:03:03 +00:00
|
|
|
// consolePrintf("type: %d\n", event.type);
|
2006-07-09 11:47:17 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
event = eventQueue[eventNum++];
|
2007-06-30 23:03:03 +00:00
|
|
|
// consolePrintf("type: %d\n", event.type);
|
2006-07-09 11:47:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* if (lastPenFrame != DS::getMillis()) {
|
|
|
|
if ((eventNum == 0)) {
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_MOUSEMOVE;
|
2006-07-09 11:47:17 +00:00
|
|
|
event.mouse = Common::Point(DS::getPenX(), DS::getPenY());
|
|
|
|
eventNum = 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (eventNum == 1) {
|
|
|
|
eventNum = 0;
|
|
|
|
lastPenFrame = DS::getMillis();
|
2008-01-27 19:47:41 +00:00
|
|
|
if (DS::getPenDown()) {
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_LBUTTONDOWN;
|
2006-07-09 11:47:17 +00:00
|
|
|
event.mouse = Common::Point(DS::getPenX(), DS::getPenY());
|
|
|
|
consolePrintf("Down %d, %d ", event.mouse.x, event.mouse.y);
|
|
|
|
return true;
|
|
|
|
} else if (DS::getPenReleased()) {
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_LBUTTONUP;
|
2006-07-09 11:47:17 +00:00
|
|
|
event.mouse = Common::Point(DS::getPenX(), DS::getPenY());
|
|
|
|
consolePrintf("Up %d, %d ", event.mouse.x, event.mouse.y);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 OSystem_DS::getMillis()
|
|
|
|
{
|
|
|
|
return DS::getMillis();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::delayMillis(uint msecs)
|
|
|
|
{
|
|
|
|
int st = getMillis();
|
|
|
|
DS::addEventsToQueue();
|
|
|
|
DS::CD::update();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
DS::doSoundCallback();
|
|
|
|
while (st + msecs >= getMillis()) {
|
|
|
|
DS::doSoundCallback();
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
DS::doTimerCallback();
|
|
|
|
DS::checkSleepMode();
|
|
|
|
DS::addEventsToQueue();
|
|
|
|
}
|
|
|
|
|
2008-05-14 07:04:14 +00:00
|
|
|
void OSystem_DS::getTimeAndDate(struct tm &t) const {
|
|
|
|
time_t curTime = time(0);
|
|
|
|
t = *localtime(&curTime);
|
|
|
|
}
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
OSystem::MutexRef OSystem_DS::createMutex(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::lockMutex(MutexRef mutex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::unlockMutex(MutexRef mutex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::deleteMutex(MutexRef mutex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::clearSoundCallback()
|
|
|
|
{
|
|
|
|
consolePrintf("Clearing sound callback");
|
|
|
|
// DS::setSoundProc(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int OSystem_DS::getOutputSampleRate() const
|
|
|
|
{
|
2006-11-03 23:16:29 +00:00
|
|
|
return DS::getSoundFrequency();
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_DS::openCD(int drive)
|
|
|
|
{
|
|
|
|
return DS::CD::checkCD();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_DS::pollCD()
|
|
|
|
{
|
|
|
|
return DS::CD::isPlaying();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::playCD(int track, int num_loops, int start_frame, int duration)
|
|
|
|
{
|
|
|
|
DS::CD::playTrack(track, num_loops, start_frame, duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::stopCD()
|
|
|
|
{
|
|
|
|
DS::CD::stopTrack();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::updateCD()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::quit()
|
|
|
|
{
|
|
|
|
/* consolePrintf("Soft resetting...");
|
|
|
|
IPC->reset = 1;
|
|
|
|
REG_IE = 0;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
asm("swi 0x26\n");
|
|
|
|
swiSoftReset();*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::setWindowCaption(const char *caption)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::displayMessageOnOSD(const char *msg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SaveFileManager* OSystem_DS::getSavefileManager()
|
|
|
|
{
|
|
|
|
bool forceSram;
|
|
|
|
|
|
|
|
if (ConfMan.hasKey("forcesramsave", "ds")) {
|
|
|
|
forceSram = ConfMan.getBool("forcesramsave", "ds");
|
|
|
|
} else {
|
|
|
|
forceSram = false;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
if (forceSram) {
|
2006-07-09 11:47:17 +00:00
|
|
|
consolePrintf("Using SRAM save method!\n");
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
if (DS::isGBAMPAvailable() && (!forceSram)) {
|
|
|
|
return &mpSaveManager;
|
|
|
|
} else {
|
|
|
|
return &saveManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-21 18:36:40 +00:00
|
|
|
|
|
|
|
Graphics::Surface* OSystem_DS::createTempFrameBuffer() {
|
|
|
|
// For now, we create a full temporary screen surface, to which we copy the
|
2007-08-18 11:10:41 +00:00
|
|
|
// the screen content. Later unlockScreen will copy everything back.
|
|
|
|
// Not very nice nor efficient, but at least works, and is not worse
|
|
|
|
// than in the bad old times where we used grabRawScreen + copyRectToScreen.
|
2007-12-21 18:36:40 +00:00
|
|
|
// consolePrintf("lockScreen()\n");
|
2007-08-18 11:10:41 +00:00
|
|
|
_framebuffer.create(DS::getGameWidth(), DS::getGameHeight(), 1);
|
2007-01-20 17:29:20 +00:00
|
|
|
|
|
|
|
// Ensure we copy using 16 bit quantities due to limitation of VRAM addressing
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-12-21 18:36:40 +00:00
|
|
|
size_t imageStrideInBytes = DS::isCpuScalerEnabled()? DS::getGameWidth() : 512;
|
|
|
|
size_t imageStrideInWords = imageStrideInBytes / 2;
|
2007-06-15 09:04:08 +00:00
|
|
|
|
2007-01-20 17:29:20 +00:00
|
|
|
u16* image = (u16 *) DS::get8BitBackBuffer();
|
2007-12-21 18:36:40 +00:00
|
|
|
for (int y = 0; y < DS::getGameHeight(); y++) {
|
2007-10-13 15:40:11 +00:00
|
|
|
DC_FlushRange(image + (y * imageStrideInWords), DS::getGameWidth());
|
2007-12-21 18:36:40 +00:00
|
|
|
for (int x = 0; x < DS::getGameWidth() >> 1; x++) {
|
|
|
|
*(((u16 *) (_framebuffer.pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[(y << 8) + x];
|
|
|
|
// *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y * imageStrideInWords + x];
|
2007-01-20 17:29:20 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-21 18:36:40 +00:00
|
|
|
// consolePrintf("lockScreen() done\n");
|
|
|
|
_frameBufferExists = true;
|
|
|
|
|
|
|
|
return &_framebuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Graphics::Surface *OSystem_DS::lockScreen() {
|
|
|
|
if (!_frameBufferExists) {
|
|
|
|
createTempFrameBuffer();
|
|
|
|
}
|
2007-01-20 17:29:20 +00:00
|
|
|
|
2007-12-21 18:36:40 +00:00
|
|
|
return &_framebuffer;
|
2007-08-18 11:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::unlockScreen() {
|
2007-12-21 18:36:40 +00:00
|
|
|
|
|
|
|
// consolePrintf("unlockScreen()\n");
|
|
|
|
|
|
|
|
// Copy temp framebuffer back to screen
|
|
|
|
// copyRectToScreen((byte *)_framebuffer.pixels, _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h);
|
2007-08-18 11:10:41 +00:00
|
|
|
|
|
|
|
// Free memory
|
2007-12-21 18:36:40 +00:00
|
|
|
// _framebuffer.free();
|
|
|
|
// consolePrintf("unlockScreen() done\n");
|
2006-07-09 11:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::setFocusRectangle(const Common::Rect& rect) {
|
|
|
|
DS::setTalkPos(rect.left + rect.width() / 2, rect.top + rect.height() / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::clearFocusRectangle() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-30 23:03:03 +00:00
|
|
|
void OSystem_DS::addAutoComplete(const char *word) {
|
|
|
|
DS::addAutoComplete((char *) word);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::clearAutoComplete() {
|
|
|
|
DS::clearAutoComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_DS::setCharactersEntered(int count) {
|
|
|
|
DS::setCharactersEntered(count);
|
|
|
|
}
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
OSystem *OSystem_DS_create() {
|
|
|
|
return new OSystem_DS();
|
|
|
|
}
|
|
|
|
|
2007-08-18 11:10:41 +00:00
|
|
|
|
|
|
|
|