[Scummvm-cvs-logs] CVS: scummvm/backends/ps2 fileio.cpp,1.4.2.6,1.4.2.7 savefile.cpp,1.6.2.6,1.6.2.7 systemps2.cpp,1.8.2.8,1.8.2.9 systemps2.h,1.7.2.8,1.7.2.9
Robert Göffringmann
lavosspawn at users.sourceforge.net
Wed Jan 25 18:31:01 CET 2006
Update of /cvsroot/scummvm/scummvm/backends/ps2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18378/backends/ps2
Modified Files:
Tag: branch-0-8-0
fileio.cpp savefile.cpp systemps2.cpp systemps2.h
Log Message:
some ps2 changes...
Index: fileio.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/fileio.cpp,v
retrieving revision 1.4.2.6
retrieving revision 1.4.2.7
diff -u -d -r1.4.2.6 -r1.4.2.7
--- fileio.cpp 18 Jan 2006 18:07:24 -0000 1.4.2.6
+++ fileio.cpp 26 Jan 2006 02:30:04 -0000 1.4.2.7
@@ -422,9 +422,9 @@
}
if (!checkedPath && g_engine) {
- // are we playing from HDD?
- if (strncmp(g_engine->getGameDataPath(), "pfs0:", 5) == 0)
- driveStop(); // yes we are. stop dvd drive. it's noisy.
+ // are we playing from cd/dvd?
+ if (strncmp(g_engine->getGameDataPath(), "cdfs:", 5) != 0)
+ driveStop(); // no, we aren't. stop the drive. it's noisy.
// now cache the dir tree
tocManager.readEntries(g_engine->getGameDataPath());
checkedPath = true;
@@ -653,7 +653,7 @@
iox_dirent_t dirent;
int fd = fio.dopen(path);
if (fd >= 0) {
- while (fio.dread(fd, &dirent) != 0)
+ while (fio.dread(fd, &dirent) > 0)
if (dirent.name[0] != '.') { // skip '.' and '..'
*node = new TocNode;
(*node)->sub = (*node)->next = NULL;
Index: savefile.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/savefile.cpp,v
retrieving revision 1.6.2.6
retrieving revision 1.6.2.7
diff -u -d -r1.6.2.6 -r1.6.2.7
--- savefile.cpp 18 Jan 2006 18:07:24 -0000 1.6.2.6
+++ savefile.cpp 26 Jan 2006 02:30:04 -0000 1.6.2.7
@@ -54,6 +54,7 @@
int mkDir(const char *name);
int getDir(const char *name, unsigned int mode, int max, void *dest);
int getInfo(int *type, int *free, int *format);
+ int remove(const char *name);
private:
int _sema;
int _port, _slot;
@@ -131,6 +132,15 @@
return res;
}
+int McAccess::remove(const char *name) {
+ int res;
+ WaitSema(_sema);
+ mcDelete(_port, _slot, name);
+ mcSync(0, NULL, &res);
+ SignalSema(_sema);
+ return res;
+}
+
int McAccess::getDir(const char *name, unsigned int mode, int max, void *dest) {
int res;
WaitSema(_sema);
@@ -155,7 +165,7 @@
virtual ~UclOutSaveFile(void);
virtual uint32 write(const void *ptr, uint32 size);
virtual void flush(void);
- virtual bool ioFailed(void);
+ virtual bool ioFailed(void) const;
virtual void clearIOFailed(void);
private:
OSystem_PS2 *_system;
@@ -165,6 +175,7 @@
uint8 *_buf;
uint32 _bufSize, _bufPos;
bool _ioFailed, _wasFlushed;
+ char _fileName[128];
};
class UclInSaveFile : public Common::InSaveFile {
@@ -173,7 +184,7 @@
virtual ~UclInSaveFile(void);
virtual bool eos(void) const;
virtual uint32 read(void *ptr, uint32 size);
- virtual bool ioFailed(void);
+ virtual bool ioFailed(void) const;
virtual void clearIOFailed(void);
virtual void skip(uint32 offset);
private:
@@ -561,7 +572,7 @@
_systemQuit = true;
ee_thread_t statSave, statThis;
ReferThreadStatus(GetThreadId(), &statThis);
- int res = ChangeThreadPriority(_autoSaveTid, statThis.current_priority - 1);
+ ChangeThreadPriority(_autoSaveTid, statThis.current_priority - 1);
do { // wait until thread called ExitThread()
SignalSema(_autoSaveSignal);
@@ -613,7 +624,7 @@
_screen->wantAnim(false);
}
-bool UclInSaveFile::ioFailed(void) {
+bool UclInSaveFile::ioFailed(void) const {
return _ioFailed;
}
@@ -660,6 +671,7 @@
_bufSize = 65536;
_buf = (uint8*)malloc(_bufSize);
_ioFailed = false;
+ strcpy(_fileName, filename);
} else {
_ioFailed = true;
_bufSize = 0;
@@ -686,7 +698,7 @@
_screen->wantAnim(false);
}
-bool UclOutSaveFile::ioFailed(void) {
+bool UclOutSaveFile::ioFailed(void) const {
return _ioFailed;
}
@@ -695,7 +707,7 @@
}
void UclOutSaveFile::flush(void) {
- int res = 0;
+ int res;
if (_bufPos) {
if (_wasFlushed) {
@@ -712,17 +724,30 @@
res = ucl_nrv2e_99_compress(_buf, _bufPos, compBuf + 8, &compSize, NULL, 10, NULL, NULL);
if (res >= 0) {
res = _mc->write(_fd, compBuf, compSize + 8);
- if (res != (int)compSize + 8)
+ if (res != (int)compSize + 8) {
+ printf("flush: write failed, %d != %d\n", res, compSize + 8);
res = -1;
+ }
} else
printf("Unable to compress %d bytes of savedata, errorcode %d\n", _bufPos, res);
free(compBuf);
_bufPos = 0;
}
- }
- if (res < 0) {
- _ioFailed = true;
- printf("UclOutSaveFile::flush failed!\n");
+
+ if (res < 0) {
+ _ioFailed = true;
+ printf("UclOutSaveFile::flush failed!\n");
+ if (_fd >= 0) {
+ // the file is broken; delete it
+ _mc->close(_fd);
+ res = _mc->remove(_fileName);
+ if (res == 0)
+ printf("File %s: remove ok\n", _fileName);
+ else
+ printf("File %s: remove error %d\n", _fileName, res);
+ _fd = -1;
+ }
+ }
}
}
Index: systemps2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/systemps2.cpp,v
retrieving revision 1.8.2.8
retrieving revision 1.8.2.9
diff -u -d -r1.8.2.8 -r1.8.2.9
--- systemps2.cpp 18 Jan 2006 18:07:24 -0000 1.8.2.8
+++ systemps2.cpp 26 Jan 2006 02:30:04 -0000 1.8.2.9
@@ -170,11 +170,6 @@
return 0;
}
-static int iSoundCallback(void *arg) {
- iSignalSema((int)arg);
- return 0;
-}
-
void systemTimerThread(OSystem_PS2 *system) {
system->timerThread();
}
@@ -187,6 +182,14 @@
((OSystem_PS2*)system)->powerOffCallback();
}
+void mass_connect_cb(void *pkt, void *system) {
+ ((OSystem_PS2*)system)->setUsbMassConnected(true);
+}
+
+void mass_disconnect_cb(void *pkt, void *system) {
+ ((OSystem_PS2*)system)->setUsbMassConnected(false);
+}
+
OSystem_PS2::OSystem_PS2(void) {
_soundStack = _timerStack = NULL;
_scummTimerProc = NULL;
@@ -309,6 +312,11 @@
T0_COUNT = 0;
T0_COMP = CLK_DIVIS; // (BUS_CLOCK / 256) / CLK_DIVIS = 100
T0_MODE = TIMER_MODE( 2, 0, 0, 0, 1, 1, 1, 0, 1, 1);
+
+ DI();
+ SifAddCmdHandler(0x12, mass_connect_cb, this);
+ SifAddCmdHandler(0x13, mass_disconnect_cb, this);
+ EI();
}
void OSystem_PS2::timerThread(void) {
@@ -409,7 +417,7 @@
void OSystem_PS2::loadModules(void) {
- _useMouse = _useKbd = _useHdd = false;
+ _usbMassConnected = _usbMassLoaded = _useMouse = _useKbd = _useHdd = false;
static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
static char pfsarg[] = "-m" "\0" "2" "\0" "-o" "\0" "16" "\0" "-n" "\0" "40" /*"\0" "-debug"*/;
@@ -433,6 +441,10 @@
sioprintf("Cannot load module: RPCKBD.IRX (%d)", res);
else
_useKbd = true;
+ if ((res = SifLoadModule(IRX_PREFIX "USB_MASS.IRX" IRX_SUFFIX, 0, NULL)) < 0)
+ sioprintf("Cannot load module: USB_MASS.IRX (%d)", res);
+ else
+ _usbMassLoaded = true;
}
if ((res = fileXioInit()) < 0) {
@@ -455,13 +467,21 @@
_useHdd = true;
}
- sioprintf("Modules: UsbMouse %sloaded, UsbKbd %sloaded, HDD %sloaded.", _useMouse ? "" : "not ", _useKbd ? "" : "not ", _useHdd ? "" : "not ");
+ sioprintf("Modules: UsbMouse %sloaded, UsbKbd %sloaded, UsbMass %sloaded, HDD %sloaded.", _useMouse ? "" : "not ", _useKbd ? "" : "not ", _usbMassLoaded ? "" : "not ", _useHdd ? "" : "not ");
}
bool OSystem_PS2::hddPresent(void) {
return _useHdd;
}
+void OSystem_PS2::setUsbMassConnected(bool stat) {
+ _usbMassConnected = stat;
+}
+
+bool OSystem_PS2::usbMassPresent(void) {
+ return _usbMassConnected;
+}
+
void OSystem_PS2::initSize(uint width, uint height, int overscale) {
printf("initializing new size: (%d/%d)...", width, height);
_screen->newScreenSize(width, height);
@@ -760,11 +780,16 @@
}
void OSystem_PS2::makeConfigPath(char *dest) {
- FILE *handle = ps2_fopen("cdfs:/ScummVM.ini", "r");
- if (handle) {
+ FILE *handle;
+ strcpy(dest, "cdfs:/ScummVM.ini");
+ handle = ps2_fopen(dest, "r");
+ if (_usbMassConnected && !handle) {
+ strcpy(dest, "mass:/ScummVM.ini");
+ handle = ps2_fopen(dest, "r");
+ }
+ if (handle)
ps2_fclose(handle);
- strcpy(dest, "cdfs:/scummvm.ini");
- } else
+ else
strcpy(dest, "mc0:ScummVM/scummvm.ini");
}
Index: systemps2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/ps2/systemps2.h,v
retrieving revision 1.7.2.8
retrieving revision 1.7.2.9
diff -u -d -r1.7.2.8 -r1.7.2.9
--- systemps2.h 18 Jan 2006 18:07:24 -0000 1.7.2.8
+++ systemps2.h 26 Jan 2006 02:30:04 -0000 1.7.2.9
@@ -105,6 +105,8 @@
void powerOffCallback(void);
bool hddPresent(void);
+ bool usbMassPresent(void);
+ void setUsbMassConnected(bool stat);
private:
volatile OSystem::TimerProc _scummTimerProc;
@@ -117,7 +119,7 @@
void loadModules(void);
bool _mouseVisible;
- bool _useMouse, _useKbd, _useHdd;
+ bool _useMouse, _useKbd, _useHdd, _usbMassLoaded, _usbMassConnected;
Ps2SaveFileManager *_saveManager;
More information about the Scummvm-git-logs
mailing list