[Scummvm-cvs-logs] CVS: scummvm/backends/ps2 Gs2dScreen.cpp,1.3,1.4 Gs2dScreen.h,1.3,1.4 asyncfio.cpp,1.3,1.4 asyncfio.h,1.3,1.4 ps2pad.cpp,1.3,1.4 savefile.cpp,1.3,1.4 systemps2.cpp,1.4,1.5 systemps2.h,1.4,1.5

Robert Göffringmann lavosspawn at users.sourceforge.net
Wed May 11 00:33:13 CEST 2005


Update of /cvsroot/scummvm/scummvm/backends/ps2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26678/backends/ps2

Modified Files:
	Gs2dScreen.cpp Gs2dScreen.h asyncfio.cpp asyncfio.h ps2pad.cpp 
	savefile.cpp systemps2.cpp systemps2.h 
Log Message:
some ps2 changes...

Index: Gs2dScreen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/Gs2dScreen.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Gs2dScreen.cpp	5 May 2005 03:06:31 -0000	1.3
+++ Gs2dScreen.cpp	11 May 2005 07:31:43 -0000	1.4
@@ -137,7 +137,7 @@
 
     // 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 @@
 	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);
 

Index: Gs2dScreen.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/Gs2dScreen.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Gs2dScreen.h	5 May 2005 03:06:31 -0000	1.3
+++ Gs2dScreen.h	11 May 2005 07:31:44 -0000	1.4
@@ -24,6 +24,7 @@
 
 #include "sysdefs.h"
 #include "backends/ps2/DmaPipe.h"
+
 enum TVMode {
 	TV_DONT_CARE = 0,
 	TV_PAL,
@@ -35,8 +36,6 @@
 	GS_INTERLACED
 };
 
-//class DmaPipe;
-
 class Gs2dScreen {
 public:
 	Gs2dScreen(uint16 width, uint16 height, TVMode tvMode);
@@ -46,6 +45,7 @@
 
 	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);

Index: asyncfio.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/asyncfio.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- asyncfio.cpp	5 May 2005 03:06:31 -0000	1.3
+++ asyncfio.cpp	11 May 2005 07:31:44 -0000	1.4
@@ -49,12 +49,7 @@
 	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 @@
 	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::checkSync(void) {
 	if (_runningOp) {
-		assert(fileXioWaitAsync(FXIO_WAIT, (int *)_runningOp) == FXIO_COMPLETE);
+		fileXioWaitAsync(FXIO_WAIT, (int *)_runningOp);
 		_runningOp = NULL;
 	}
 }
@@ -99,25 +94,55 @@
 }
 
 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)

Index: asyncfio.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/asyncfio.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- asyncfio.h	5 May 2005 03:06:31 -0000	1.3
+++ asyncfio.h	11 May 2005 07:31:44 -0000	1.4
@@ -20,6 +20,7 @@
  */
 
 #define MAX_HANDLES 32
+#include <sys/stat.h>
 
 class AsyncFio {
 public:
@@ -31,6 +32,9 @@
 	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);

Index: ps2pad.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/ps2pad.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ps2pad.cpp	5 May 2005 03:06:31 -0000	1.3
+++ ps2pad.cpp	11 May 2005 07:31:44 -0000	1.4
@@ -103,7 +103,7 @@
 			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;
 			}

Index: savefile.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/savefile.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- savefile.cpp	5 May 2005 03:06:31 -0000	1.3
+++ savefile.cpp	11 May 2005 07:31:44 -0000	1.4
@@ -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 @@
 	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 @@
 		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 @@
 			UclInSaveFile *file = new UclInSaveFile(fullName, _screen);
 			if (file) {
 				if (!file->ioFailed()) {
-					return (InSaveFile*)file;
+					return file;
 				} else
 					delete file;
 			}
@@ -192,7 +193,7 @@
 	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 @@
 		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 @@
 	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 @@
 	return -1;
 }
 
-
 uint32 UclOutSaveFile::write(const void *ptr, uint32 size) {
 	assert(_bufPos <= _bufSize);
 	uint32 bytesFree = _bufSize - _bufPos;

Index: systemps2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/systemps2.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- systemps2.cpp	5 May 2005 03:06:31 -0000	1.4
+++ systemps2.cpp	11 May 2005 07:31:44 -0000	1.5
@@ -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 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 @@
 
 	_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 @@
 	sioprintf("Initializing ps2Input");
 	_input = new Ps2Input(this, _useMouse, _useKbd);
 
-	sio_puts("OSystem_PS2 constructor done\n");
 	_screen->wantAnim(false);
 }
 
@@ -360,48 +356,47 @@
 	}
 }
 
-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 @@
 	_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 @@
 	SignalSema(_soundSema);
 }
 
-SaveFileManager *OSystem_PS2::getSavefileManager(void) {
+Common::SaveFileManager *OSystem_PS2::getSavefileManager(void) {
 	return _saveManager;
 }
 
@@ -630,25 +629,98 @@
 	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_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),
+		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);
+
+		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 @@
 	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;
 	}
 

Index: systemps2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/systemps2.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- systemps2.h	10 May 2005 23:17:13 -0000	1.4
+++ systemps2.h	11 May 2005 07:31:44 -0000	1.5
@@ -38,6 +38,7 @@
 	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 @@
 	int _soundSema;
 
 	void initTimer(void);
+	void fatalError(char *str);
 
-	bool loadModules(void);
+	bool loadModules(char *errorStr);
 	bool _mouseVisible;
 	bool _useHdd, _useMouse, _useKbd;
 





More information about the Scummvm-git-logs mailing list