aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorRobert Göffringmann2005-05-11 07:31:44 +0000
committerRobert Göffringmann2005-05-11 07:31:44 +0000
commitd0fabce0ad8facec467adbdeb25503195353122f (patch)
treed8830d8f09e18366c940bc1540f0ccbbb8efc1fb /backends
parente0e27b0a094a6866f09c61a207bdb0e8b3c67c2c (diff)
downloadscummvm-rg350-d0fabce0ad8facec467adbdeb25503195353122f.tar.gz
scummvm-rg350-d0fabce0ad8facec467adbdeb25503195353122f.tar.bz2
scummvm-rg350-d0fabce0ad8facec467adbdeb25503195353122f.zip
some ps2 changes...
svn-id: r18046
Diffstat (limited to 'backends')
-rw-r--r--backends/ps2/Gs2dScreen.cpp11
-rw-r--r--backends/ps2/Gs2dScreen.h4
-rw-r--r--backends/ps2/asyncfio.cpp47
-rw-r--r--backends/ps2/asyncfio.h4
-rw-r--r--backends/ps2/ps2pad.cpp2
-rw-r--r--backends/ps2/savefile.cpp23
-rw-r--r--backends/ps2/systemps2.cpp211
-rw-r--r--backends/ps2/systemps2.h4
8 files changed, 212 insertions, 94 deletions
diff --git a/backends/ps2/Gs2dScreen.cpp b/backends/ps2/Gs2dScreen.cpp
index 274367847e..7c108d6174 100644
--- a/backends/ps2/Gs2dScreen.cpp
+++ b/backends/ps2/Gs2dScreen.cpp
@@ -137,7 +137,7 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
// set screen size, 640x544 for pal, 640x448 for ntsc
_tvWidth = 640;
- _tvHeight = ((_videoMode == TV_PAL) ? 544 : 448);
+ _tvHeight = ((_videoMode == TV_PAL) ? 544 : 448); // PAL => 512?
kFullScreen[0].z = kFullScreen[1].z = 0;
kFullScreen[0].x = ORIGIN_X;
kFullScreen[0].y = ORIGIN_Y;
@@ -304,6 +304,15 @@ void Gs2dScreen::setPalette(const uint32 *pal, uint8 start, uint16 num) {
SignalSema(g_DmacSema);
}
+void Gs2dScreen::grabPalette(uint32 *pal, uint8 start, uint16 num) {
+ assert(start + num <= 256);
+ for (uint16 cnt = 0; cnt < num; cnt++) {
+ uint16 src = start + cnt;
+ src = (src & 0xE7) | ((src & 0x8) << 1) | ((src & 0x10) >> 1);
+ pal[cnt] = _clut[src];
+ }
+}
+
void Gs2dScreen::updateScreen(void) {
WaitSema(_screenSema);
diff --git a/backends/ps2/Gs2dScreen.h b/backends/ps2/Gs2dScreen.h
index 7f011b5a8a..bb2ad7218f 100644
--- a/backends/ps2/Gs2dScreen.h
+++ b/backends/ps2/Gs2dScreen.h
@@ -24,6 +24,7 @@
#include "sysdefs.h"
#include "backends/ps2/DmaPipe.h"
+
enum TVMode {
TV_DONT_CARE = 0,
TV_PAL,
@@ -35,8 +36,6 @@ enum GsInterlace {
GS_INTERLACED
};
-//class DmaPipe;
-
class Gs2dScreen {
public:
Gs2dScreen(uint16 width, uint16 height, TVMode tvMode);
@@ -46,6 +45,7 @@ public:
void copyScreenRect(const uint8 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h);
void setPalette(const uint32 *pal, uint8 start, uint16 num);
+ void grabPalette(uint32 *pal, uint8 start, uint16 num);
void updateScreen(void);
//- overlay routines
void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h);
diff --git a/backends/ps2/asyncfio.cpp b/backends/ps2/asyncfio.cpp
index 9d6c27b3c3..abecc559cc 100644
--- a/backends/ps2/asyncfio.cpp
+++ b/backends/ps2/asyncfio.cpp
@@ -49,12 +49,7 @@ int AsyncFio::open(const char *name, int ioMode) {
checkSync();
int res;
fileXioOpen(name, ioMode, DEFAULT_MODE);
- int fioRes = fileXioWaitAsync(FXIO_WAIT, &res);
- if (fioRes != FXIO_COMPLETE) {
- sioprintf("ERROR: fioOpen(%s, %X):\n", name, ioMode);
- sioprintf(" fioSync returned %d, open res = %d\n", fioRes, res);
- SleepThread();
- }
+ fileXioWaitAsync(FXIO_WAIT, &res);
SignalSema(_ioSema);
return res;
}
@@ -64,7 +59,7 @@ void AsyncFio::close(int handle) {
checkSync();
fileXioClose(handle);
int res;
- assert(fileXioWaitAsync(FXIO_WAIT, &res) == FXIO_COMPLETE);
+ fileXioWaitAsync(FXIO_WAIT, &res);
if (res != 0) {
sioprintf("ERROR: fileXioClose failed, EC %d", res);
SleepThread();
@@ -75,7 +70,7 @@ void AsyncFio::close(int handle) {
void AsyncFio::checkSync(void) {
if (_runningOp) {
- assert(fileXioWaitAsync(FXIO_WAIT, (int *)_runningOp) == FXIO_COMPLETE);
+ fileXioWaitAsync(FXIO_WAIT, (int *)_runningOp);
_runningOp = NULL;
}
}
@@ -99,25 +94,55 @@ void AsyncFio::write(int fd, const void *src, unsigned int len) {
}
int AsyncFio::seek(int fd, int offset, int whence) {
+ int res;
WaitSema(_ioSema);
checkSync();
fileXioLseek(fd, offset, whence);
- int res;
- assert(fileXioWaitAsync(FXIO_WAIT, &res) == FXIO_COMPLETE);
+ fileXioWaitAsync(FXIO_WAIT, &res);
SignalSema(_ioSema);
return res;
}
int AsyncFio::mkdir(const char *name) {
+ int res;
WaitSema(_ioSema);
checkSync();
fileXioMkdir(name, DEFAULT_MODE);
+ fileXioWaitAsync(FXIO_WAIT, &res);
+ SignalSema(_ioSema);
+ return res;
+}
+
+int AsyncFio::dopen(const char *name) {
int res;
- assert(fileXioWaitAsync(FXIO_WAIT, &res) == FXIO_COMPLETE);
+ WaitSema(_ioSema);
+ checkSync();
+ fileXioDopen(name);
+ fileXioWaitAsync(FXIO_WAIT, &res);
SignalSema(_ioSema);
return res;
}
+int AsyncFio::dread(int fd, iox_dirent_t *dest) {
+ int res;
+ WaitSema(_ioSema);
+ checkSync();
+ fileXioDread(fd, dest);
+ fileXioWaitAsync(FXIO_WAIT, &res);
+ SignalSema(_ioSema);
+ return res;
+}
+
+void AsyncFio::dclose(int fd) {
+ int res;
+ WaitSema(_ioSema);
+ checkSync();
+ fileXioDclose(fd);
+ fileXioWaitAsync(FXIO_WAIT, &res);
+ assert(res == 0);
+ SignalSema(_ioSema);
+}
+
int AsyncFio::sync(int fd) {
WaitSema(_ioSema);
if (_runningOp == _ioSlots + fd)
diff --git a/backends/ps2/asyncfio.h b/backends/ps2/asyncfio.h
index 765b7eb74f..39a7093fb6 100644
--- a/backends/ps2/asyncfio.h
+++ b/backends/ps2/asyncfio.h
@@ -20,6 +20,7 @@
*/
#define MAX_HANDLES 32
+#include <sys/stat.h>
class AsyncFio {
public:
@@ -31,6 +32,9 @@ public:
void write(int fd, const void *src, unsigned int len);
int seek(int fd, int offset, int whence);
int mkdir(const char *name);
+ int dopen(const char *name);
+ int dread(int fd, iox_dirent_t *dest);
+ void dclose(int fd);
int sync(int fd);
bool poll(int fd);
bool fioAvail(void);
diff --git a/backends/ps2/ps2pad.cpp b/backends/ps2/ps2pad.cpp
index 599030f489..4396297541 100644
--- a/backends/ps2/ps2pad.cpp
+++ b/backends/ps2/ps2pad.cpp
@@ -103,7 +103,7 @@ void Ps2Pad::initPad(void) {
if (_system->getMillis() - _padInitTime > 5000) {
// still no pad, give up.
if (padPortClose(_port, _slot) != 1)
- printf("WARNING: can't close port: %d/%d\n");
+ printf("WARNING: can't close port: %d/%d\n", _port, _slot);
printf("looking for pad, gave up and closed port\n");
_padStatus = STAT_NONE;
}
diff --git a/backends/ps2/savefile.cpp b/backends/ps2/savefile.cpp
index 1449c94510..05539c5ab1 100644
--- a/backends/ps2/savefile.cpp
+++ b/backends/ps2/savefile.cpp
@@ -34,7 +34,7 @@
extern AsyncFio fio;
-class UclOutSaveFile : public Common::WriteStream {
+class UclOutSaveFile : public Common::OutSaveFile {
public:
UclOutSaveFile(const char *filename, Gs2dScreen *screen);
virtual ~UclOutSaveFile(void);
@@ -50,14 +50,15 @@ private:
bool _ioFailed;
};
-class UclInSaveFile : public Common::ReadStream {
+class UclInSaveFile : public Common::InSaveFile {
public:
UclInSaveFile(const char *filename, Gs2dScreen *screen);
virtual ~UclInSaveFile(void);
virtual bool eos(void) const;
virtual uint32 read(void *ptr, uint32 size);
virtual bool ioFailed(void);
- virtual void clearIOFailed(void);
+ virtual void clearIOFailed(void);
+ virtual void skip(uint32 offset);
private:
Gs2dScreen *_screen;
uint8 *_buf;
@@ -165,7 +166,7 @@ bool Ps2SaveFileManager::mcReadyForDir(const char *dir) {
return true;
}
-InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) {
+Common::InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) {
_screen->wantAnim(true);
char dir[256], name[256];
@@ -181,7 +182,7 @@ InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) {
UclInSaveFile *file = new UclInSaveFile(fullName, _screen);
if (file) {
if (!file->ioFailed()) {
- return (InSaveFile*)file;
+ return file;
} else
delete file;
}
@@ -192,7 +193,7 @@ InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) {
return NULL;
}
-OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) {
+Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) {
_screen->wantAnim(true);
char dir[256], name[256];
splitPath(filename, dir, name);
@@ -219,7 +220,7 @@ OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) {
if (!file->ioFailed()) {
// we're creating a file, mc will have to be updated next time
_mcNeedsUpdate = true;
- return (OutSaveFile*)file;
+ return file;
} else
delete file;
}
@@ -393,6 +394,13 @@ uint32 UclInSaveFile::read(void *ptr, uint32 size) {
return size;
}
+void UclInSaveFile::skip(uint32 offset) {
+ if (_bufPos + offset <= _bufSize)
+ _bufPos += offset;
+ else
+ _bufPos = _bufSize;
+}
+
UclOutSaveFile::UclOutSaveFile(const char *filename, Gs2dScreen *screen) {
_screen = screen;
_bufPos = 0;
@@ -456,7 +464,6 @@ int UclOutSaveFile::flush(void) {
return -1;
}
-
uint32 UclOutSaveFile::write(const void *ptr, uint32 size) {
assert(_bufPos <= _bufSize);
uint32 bytesFree = _bufSize - _bufPos;
diff --git a/backends/ps2/systemps2.cpp b/backends/ps2/systemps2.cpp
index 8e30d1f7bc..fabd362812 100644
--- a/backends/ps2/systemps2.cpp
+++ b/backends/ps2/systemps2.cpp
@@ -30,6 +30,7 @@
#include <assert.h>
#include <iopcontrol.h>
#include <iopheap.h>
+#include <osd_config.h>
#include "scummsys.h"
#include "../intern.h"
#include "base/engine.h"
@@ -45,6 +46,8 @@
#include "backends/ps2/cd.h"
#include <sio.h>
#include <fileXio_rpc.h>
+#include "graphics/surface.h"
+#include "graphics/font.h"
#define TIMER_STACK_SIZE (1024 * 32)
#define SOUND_STACK_SIZE (1024 * 32)
@@ -66,14 +69,16 @@ static int g_MainWaitSema = -1, g_TimerWaitSema = -1;
static volatile int32 g_MainWakeUp = 0, g_TimerWakeUp = 0;
static volatile uint64 msecCount = 0;
-extern void NORETURN CDECL error(const char *s, ...);
-
OSystem_PS2 *g_systemPs2 = NULL;
void readRtcTime(void);
int gBitFormat = 555;
+namespace Graphics {
+ extern const NewFont g_sysfont;
+};
+
void sioprintf(const char *zFormat, ...) {
va_list ap;
char resStr[2048];
@@ -186,34 +191,26 @@ OSystem_PS2::OSystem_PS2(void) {
_screen->wantAnim(true);
- if (!loadModules()) {
- sioprintf("ERROR: Can't load modules");
- printf("ERROR: Can't load modules\n");
- _screen->wantAnim(false);
- SleepThread();
- // Todo: handle this correctly...
- }
- sioprintf("Modules: UsbMouse %sloaded, UsbKbd %sloaded, Hdd %sloaded.", _useMouse ? "" : "not ", _useKbd ? "" : "not ", _useHdd ? "" : "not ");
+ char errorStr[256];
+ if (!loadModules(errorStr))
+ fatalError(errorStr);
sioprintf("Initializing SjPCM");
if (SjPCM_Init(0) < 0)
- sioprintf("SjPCM Bind failed");
+ fatalError("SjPCM Bind failed");
- sioprintf("Initializing LibCDVD.");
- int res = CDVD_Init();
- sioprintf("result = %d", res);
+ if (CDVD_Init() != 0)
+ fatalError("CDVD_Init failed");
- _timerTid = _soundTid = -1;
_mouseVisible = false;
sioprintf("reading RTC");
readRtcTime();
sioprintf("Initializing FXIO");
- if (fileXioInit() < 0) {
- sioprintf("Can't init fileXio\n");
- SleepThread();
- }
+ if (fileXioInit() < 0)
+ fatalError("Can't init fileXio");
+
fileXioSetBlockMode(FXIO_NOWAIT);
sioprintf("Starting SavefileManager");
@@ -225,7 +222,6 @@ OSystem_PS2::OSystem_PS2(void) {
sioprintf("Initializing ps2Input");
_input = new Ps2Input(this, _useMouse, _useKbd);
- sio_puts("OSystem_PS2 constructor done\n");
_screen->wantAnim(false);
}
@@ -360,48 +356,47 @@ void OSystem_PS2::soundThread(void) {
}
}
-bool OSystem_PS2::loadModules(void) {
+char *irxModules[] = {
+ "rom0:SIO2MAN",
+ "rom0:MCMAN",
+ "rom0:MCSERV",
+ "rom0:PADMAN",
+ "rom0:LIBSD",
+#ifndef USE_PS2LINK
+ IRX_PREFIX "IOMANX.IRX" IRX_SUFFIX,
+#endif
+ IRX_PREFIX "FILEXIO.IRX" IRX_SUFFIX,
+ IRX_PREFIX "CDVD.IRX" IRX_SUFFIX,
+ IRX_PREFIX "SJPCM.IRX" IRX_SUFFIX
+};
+
+bool OSystem_PS2::loadModules(char *errorStr) {
_useHdd = _useMouse = _useKbd = false;
int res;
- if ((res = SifLoadModule("rom0:SIO2MAN", 0, NULL)) < 0)
- sioprintf("Cannot load module: SIO2MAN (%d)\n", res);
- else if ((res = SifLoadModule("rom0:MCMAN", 0, NULL)) < 0)
- sioprintf("Cannot load module: MCMAN (%d)\n", res);
- else if ((res = SifLoadModule("rom0:MCSERV", 0, NULL)) < 0)
- sioprintf("Cannot load module: MCSERV (%d)\n", res);
- else if ((res = SifLoadModule("rom0:PADMAN", 0, NULL)) < 0)
- sioprintf("Cannot load module: PADMAN (%d)\n", res);
- else if ((res = SifLoadModule("rom0:LIBSD", 0, NULL)) < 0)
- sioprintf("Cannot load module: LIBSD (%d)\n", res);
-#ifndef USE_PS2LINK
- else if ((res = SifLoadModule(IRX_PREFIX "IOMANX.IRX" IRX_SUFFIX, 0, NULL)) < 0)
- sioprintf("Cannot load module: IOMANX.IRX (%d)\n", res);
-#endif
- else if ((res = SifLoadModule(IRX_PREFIX "FILEXIO.IRX" IRX_SUFFIX, 0, NULL)) < 0)
- sioprintf("Cannot load module: FILEXIO.IRX (%d)\n", res);
- else if ((res = SifLoadModule(IRX_PREFIX "CDVD.IRX" IRX_SUFFIX, 0, NULL)) < 0)
- sioprintf("Cannot load module CDVD.IRX (%d)\n", res);
- else if ((res = SifLoadModule(IRX_PREFIX "SJPCM.IRX" IRX_SUFFIX, 0, NULL)) < 0)
- sioprintf("Cannot load module: SJPCM.IRX (%d)\n", res);
- else {
- sioprintf("modules loaded");
- if ((res = SifLoadModule(IRX_PREFIX "USBD.IRX" IRX_SUFFIX, 0, NULL)) < 0)
- sioprintf("Cannot load module: USBD.IRX (%d)\n", res);
- else {
- if ((res = SifLoadModule(IRX_PREFIX "PS2MOUSE.IRX" IRX_SUFFIX, 0, NULL)) < 0)
- sioprintf("Cannot load module: PS2MOUSE.IRX (%d)\n", res);
- else
- _useMouse = true;
- if ((res = SifLoadModule(IRX_PREFIX "RPCKBD.IRX" IRX_SUFFIX, 0, NULL)) < 0)
- sioprintf("Cannot load module: RPCKBD.IRX (%d)\n", res);
- else
- _useKbd = true;
+ for (int i = 0; i < ARRAYSIZE(irxModules); i++) {
+ if ((res = SifLoadModule(irxModules[i], 0, NULL)) < 0) {
+ sprintf(errorStr, "Can't load module %s (%d)", irxModules[i], res);
+ return false;
}
- return true;
}
- return false;
+ printf("Modules loaded\n");
+ // now try to load optional IRXs
+ if ((res = SifLoadModule(IRX_PREFIX "USBD.IRX" IRX_SUFFIX, 0, NULL)) < 0)
+ sioprintf("Cannot load module: USBD.IRX (%d)\n", res);
+ else {
+ if ((res = SifLoadModule(IRX_PREFIX "PS2MOUSE.IRX" IRX_SUFFIX, 0, NULL)) < 0)
+ sioprintf("Cannot load module: PS2MOUSE.IRX (%d)\n", res);
+ else
+ _useMouse = true;
+ if ((res = SifLoadModule(IRX_PREFIX "RPCKBD.IRX" IRX_SUFFIX, 0, NULL)) < 0)
+ sioprintf("Cannot load module: RPCKBD.IRX (%d)\n", res);
+ else
+ _useKbd = true;
+ }
+ sioprintf("Modules: UsbMouse %sloaded, UsbKbd %sloaded, Hdd %sloaded.", _useMouse ? "" : "not ", _useKbd ? "" : "not ", _useHdd ? "" : "not ");
+ return true;
}
void OSystem_PS2::initSize(uint width, uint height, int overscale) {
@@ -422,6 +417,10 @@ void OSystem_PS2::setPalette(const byte *colors, uint start, uint num) {
_screen->setPalette((const uint32*)colors, (uint8)start, (uint16)num);
}
+void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) {
+ _screen->grabPalette((uint32*)colors, (uint8)start, (uint16)num);
+}
+
void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
if (x < 0) {
w += x;
@@ -497,7 +496,7 @@ void OSystem_PS2::clearSoundCallback(void) {
SignalSema(_soundSema);
}
-SaveFileManager *OSystem_PS2::getSavefileManager(void) {
+Common::SaveFileManager *OSystem_PS2::getSavefileManager(void) {
return _saveManager;
}
@@ -630,25 +629,98 @@ void OSystem_PS2::quit(void) {
SleepThread();
}
+void OSystem_PS2::fatalError(char *errorStr) {
+ sioprintf("ERROR: %s", errorStr);
+ printf("ERROR: %s\n", errorStr);
+ Graphics::Surface surf;
+ surf.create(300, 200, 1);
+ Common::String str(errorStr);
+ Graphics::g_sysfont.drawString(&surf, str, 0, 0, 300, 0xFF);
+
+ uint32 palette[256];
+ palette[0] = 0x00400000;
+ for (int i = 1; i < 256; i++)
+ palette[i] = 0xFFFFFFFF;
+
+ _screen->setPalette(palette, 0, 256);
+ _screen->hideOverlay();
+ _screen->wantAnim(false);
+
+ _screen->copyScreenRect((uint8*)surf.getBasePtr(0, 0), surf.pitch, 10, 10, 300, 100);
+ _screen->updateScreen();
+ SleepThread();
+}
+
static uint32 g_timeSecs;
-static uint8 g_day, g_month, g_year;
+static int g_day, g_month, g_year;
static uint32 g_lastTimeCheck;
+void buildNewDate(int dayDiff) {
+ static int daysPerMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+ if (((g_year % 4) == 0) && (((g_year % 100) != 0) || ((g_year % 1000) == 0)))
+ daysPerMonth[1] = 29;
+ else
+ daysPerMonth[1] = 28;
+
+ if (dayDiff == -1) {
+ g_day--;
+ if (g_day == 0) {
+ g_month--;
+ if (g_month == 0) {
+ g_year--;
+ g_month = 12;
+ }
+ g_day = daysPerMonth[g_month - 1];
+ }
+ } else if (dayDiff == 1) {
+ g_day++;
+ if (g_day > daysPerMonth[g_month - 1]) {
+ g_day = 1;
+ g_month++;
+ if (g_month > 12) {
+ g_month = 1;
+ g_year++;
+ }
+ }
+ }
+}
+
+#define SECONDS_PER_DAY (24 * 60 * 60)
+
void readRtcTime(void) {
struct CdClock cdClock;
CDVD_ReadClock(&cdClock);
g_lastTimeCheck = (uint32)(msecCount >> 32);
- if (cdClock.stat)
- printf("Unable to read RTC time.\n");
+ if (cdClock.stat) {
+ printf("Unable to read RTC time, EC: %d\n", cdClock.stat);
+ g_day = g_month = 1;
+ g_year = 0;
+ g_timeSecs = 0;
+ } else {
+ int gmtOfs = configGetTimezone();
+ if (configIsDaylightSavingEnabled())
+ gmtOfs += 60;
+
+ g_timeSecs = (FROM_BCD(cdClock.hour) * 60 + FROM_BCD(cdClock.minute)) * 60 + FROM_BCD(cdClock.second);
+
+ g_timeSecs -= 9 * 60 * 60; // minus 9 hours, JST -> GMT conversion
+ g_timeSecs += gmtOfs * 60; // GMT -> timezone the user selected
+
+ g_day = FROM_BCD(cdClock.day);
+ g_month = FROM_BCD(cdClock.month);
+ g_year = FROM_BCD(cdClock.year);
- g_timeSecs = ((FROM_BCD(cdClock.hour) * 60) + FROM_BCD(cdClock.minute)) * 60 + FROM_BCD(cdClock.second);
- g_day = FROM_BCD(cdClock.day);
- g_month = FROM_BCD(cdClock.month);
- g_year = FROM_BCD(cdClock.year);
- // todo: add something here to convert from JST to the right time zone
- sioprintf("Got RTC time: %d:%02d:%02d %d.%d.%4d\n",
- FROM_BCD(cdClock.hour), FROM_BCD(cdClock.minute), FROM_BCD(cdClock.second),
+ if (g_timeSecs < 0) {
+ buildNewDate(-1);
+ g_timeSecs += SECONDS_PER_DAY;
+ } else if (g_timeSecs >= SECONDS_PER_DAY) {
+ buildNewDate(+1);
+ g_timeSecs -= SECONDS_PER_DAY;
+ }
+ }
+
+ sioprintf("Time: %d:%02d:%02d - %d.%d.%4d", g_timeSecs / (60 * 60), (g_timeSecs / 60) % 60, g_timeSecs % 60,
g_day, g_month, g_year + 2000);
}
@@ -658,12 +730,11 @@ extern time_t time(time_t *p) {
return blah;
}
-#define SECONDS_PER_DAY (24 * 60 * 60)
-
extern struct tm *localtime(const time_t *p) {
uint32 currentSecs = g_timeSecs + ((msecCount >> 32) - g_lastTimeCheck) / 1000;
if (currentSecs >= SECONDS_PER_DAY) {
- readRtcTime();
+ buildNewDate(+1);
+ g_timeSecs -= SECONDS_PER_DAY;
currentSecs = g_timeSecs + ((msecCount >> 32) - g_lastTimeCheck) / 1000;
}
diff --git a/backends/ps2/systemps2.h b/backends/ps2/systemps2.h
index 20c97da085..01eb5c6f40 100644
--- a/backends/ps2/systemps2.h
+++ b/backends/ps2/systemps2.h
@@ -38,6 +38,7 @@ public:
virtual int16 getHeight(void);
virtual int16 getWidth(void);
virtual void setPalette(const byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num);
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual void updateScreen();
@@ -97,8 +98,9 @@ private:
int _soundSema;
void initTimer(void);
+ void fatalError(char *str);
- bool loadModules(void);
+ bool loadModules(char *errorStr);
bool _mouseVisible;
bool _useHdd, _useMouse, _useKbd;