From 0f74124d789488d42bc62b6a8bcf67d31e0b9bfd Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 17 Jul 2008 15:56:24 +0000 Subject: Committing PS2 changes on behalf of the other Max ;) svn-id: r33089 --- backends/platform/ps2/Makefile.ps2 | 4 +-- backends/platform/ps2/fileio.cpp | 67 ++++++++++++++++++++++++++++--------- backends/platform/ps2/irxboot.cpp | 2 +- backends/platform/ps2/systemps2.cpp | 19 +++++++---- backends/platform/ps2/systemps2.h | 7 ++-- 5 files changed, 71 insertions(+), 28 deletions(-) (limited to 'backends/platform') diff --git a/backends/platform/ps2/Makefile.ps2 b/backends/platform/ps2/Makefile.ps2 index 22cd4eaa1b..9a2c1bad1b 100644 --- a/backends/platform/ps2/Makefile.ps2 +++ b/backends/platform/ps2/Makefile.ps2 @@ -23,12 +23,12 @@ INCDIR = ../../../ DEFINES = -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_MPEG2 -DUSE_ZLIB -D_EE -D__PLAYSTATION2__ -O2 -Wall -Wno-multichar # PS2SDK-Ports from ps2dev.org's SVN repository for libmad, zlib and ucl -PS2SDK_PORTS = /home/robby/libStuffNew/ps2sdk-ports +PS2SDK_PORTS = /mnt/winxp/scummvm/ports PS2SDK_PORTS_INCS = /ucl /zlib/include /libmad/ee/include PS2SDK_PORTS_LIBS = /ucl /zlib/lib /libmad/ee/lib # we also need SjPcm, Tremor and libmpeg2 -MORE_LIBS_DIR = /home/robby/libStuff +MORE_LIBS_DIR = /mnt/winxp/scummvm/ports MORE_LIBS_INCS = /SjPcm/ee/src /mpeg2dec/include /tremor MORE_LIBS_LIBS = /SjPcm/ee/lib /mpeg2dec/libmpeg2 /tremor/tremor diff --git a/backends/platform/ps2/fileio.cpp b/backends/platform/ps2/fileio.cpp index bc310a43f4..b7fa8d03f1 100644 --- a/backends/platform/ps2/fileio.cpp +++ b/backends/platform/ps2/fileio.cpp @@ -340,8 +340,6 @@ FILE *ps2_fopen(const char *fname, const char *mode) { assert(cacheListSema >= 0); } - //printf("ps2_fopen: %s, %s\n", fname, mode); - if (((mode[0] != 'r') && (mode[0] != 'w')) || ((mode[1] != '\0') && (mode[1] != 'b'))) { printf("unsupported mode \"%s\" for file \"%s\"\n", mode, fname); return NULL; @@ -363,6 +361,8 @@ FILE *ps2_fopen(const char *fname, const char *mode) { } else { // Regular access to one of the devices + printf("ps2_fopen = %s\n", fname); // romeo : temp + if (!rdOnly) return NULL; // we only provide readaccess for cd,dvd,hdd,usb @@ -378,19 +378,22 @@ FILE *ps2_fopen(const char *fname, const char *mode) { } int64 cacheId = -1; - if (rdOnly && tocManager.haveEntries()) + if (tocManager.haveEntries()) cacheId = tocManager.fileExists(fname); if (cacheId != 0) { Ps2File *file = findInCache(cacheId); - if (file) + if (file) { + printf(" findInCache(%x)\n", cacheId); // romeo : temp return (FILE*)file; + } bool isAudioFile = strstr(fname, ".bun") || strstr(fname, ".BUN") || strstr(fname, ".Bun"); file = new Ps2ReadFile(cacheId, isAudioFile); if (file->open(fname)) { openFileCount++; + printf(" new cacheID = %x\n", cacheId); // romeo : temp return (FILE*)file; } else delete file; @@ -579,7 +582,7 @@ void TocManager::readEntries(const char *root) { } char readPath[256]; sprintf(readPath, "%s/", _root); - printf("readDir: %s\n", readPath); + printf("readDir: %s (root: %s )\n", readPath, root); readDir(readPath, &_rootNode, 0); } @@ -587,28 +590,62 @@ void TocManager::readDir(const char *path, TocNode **node, int level) { if (level <= 2) { // we don't scan deeper than that iox_dirent_t dirent; int fd = fio.dopen(path); + TocNode *eNode = NULL; // = *node; // entry node + bool first = true; + + printf("path=%s - level=%d fd=%d\n", path, level, fd); // romeo : temp if (fd >= 0) { - while (fio.dread(fd, &dirent) > 0) - if (dirent.name[0] != '.') { // skip '.' and '..' + while (fio.dread(fd, &dirent) > 0) { + if (dirent.name[0] != '.') { // skip '.' & '..' - romeo : check + // --- do we have them on PS2? *node = new TocNode; + if (first) { + eNode = *node; + first = false; + } (*node)->sub = (*node)->next = NULL; - (*node)->nameLen = strlen(dirent.name); memcpy((*node)->name, dirent.name, (*node)->nameLen + 1); - if (dirent.stat.mode & FIO_S_IFDIR) { // directory + if (dirent.stat.mode & FIO_S_IFDIR) { (*node)->isDir = true; - char nextPath[256]; - sprintf(nextPath, "%s%s/", path, dirent.name); - readDir(nextPath, &((*node)->sub), level + 1); - } else + printf("dirent.name = %s [DIR]\n", dirent.name); + } + else { (*node)->isDir = false; + printf("dirent.name = %s\n", dirent.name); + } + node = &((*node)->next); } + } + fio.dclose(fd); - } else - printf("Can't open path: %s\n", path); + } + + TocNode *iNode = eNode; + char nextPath[256]; + + while (iNode) { + if (iNode->isDir == true) { + sprintf(nextPath, "%s%s/", path, iNode->name); + readDir(nextPath, &(iNode->sub), level + 1); + } + iNode = iNode->next; + } + } + + /* + ** Wizard of Oz' trick (to get all games running from USB on PS2): + + 1. Make a list of files / dirs in level #0 (dclose before continuing) + + 2. Go through the dirs : dopen / dread them / mark dirs / dclose + + It's a safe recursion, cause it recurses on 'isDir' nodes + after dclosing the higher hierarchy + */ } int64 TocManager::fileExists(const char *name) { diff --git a/backends/platform/ps2/irxboot.cpp b/backends/platform/ps2/irxboot.cpp index 327e5bdc71..65d1e243eb 100644 --- a/backends/platform/ps2/irxboot.cpp +++ b/backends/platform/ps2/irxboot.cpp @@ -43,7 +43,7 @@ IrxFile irxFiles[] = { { "PADMAN", BIOS, NOTHING, NULL, 0 }, { "LIBSD", BIOS, NOTHING, NULL, 0 }, - { "IOMANX.IRX", SYSTEM | NOT_HOST, NOTHING, NULL, 0 }, // already loaded by ps2link + { "IOMANX.IRX", SYSTEM /*| NOT_HOST*/, NOTHING, NULL, 0 }, // already loaded by ps2link { "FILEXIO.IRX", SYSTEM, NOTHING, NULL, 0 }, { "CODYVDFS.IRX", SYSTEM, NOTHING, NULL, 0 }, { "SJPCM.IRX", SYSTEM, NOTHING, NULL, 0 }, diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 28ced7b345..d4dd9aedcf 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -54,9 +54,11 @@ #include "graphics/surface.h" #include "graphics/font.h" #include "backends/timer/default/default-timer.h" -#include "sound/mixer.h" +#include "sound/mixer_intern.h" #include "common/events.h" #include "backends/platform/ps2/ps2debug.h" +#include "backends/fs/ps2/ps2-fs-factory.h" + // asm("mfc0 %0, $9\n" : "=r"(tickStart)); extern void *_gp; @@ -309,7 +311,9 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) { void OSystem_PS2::init(void) { sioprintf("Timer...\n"); _scummTimerManager = new DefaultTimerManager(); - _scummMixer = new Audio::Mixer(); + _scummMixer = new Audio::MixerImpl(this); + _scummMixer->setOutputRate(44100); + _scummMixer->setReady(true); initTimer(); sioprintf("Starting SavefileManager\n"); @@ -410,7 +414,8 @@ void OSystem_PS2::soundThread(void) { // we have to produce more samples, call sound mixer // the scratchpad at 0x70000000 is used as temporary soundbuffer //_scummSoundProc(_scummSoundParam, (uint8*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); - Audio::Mixer::mixCallback(_scummMixer, (byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + // Audio::Mixer::mixCallback(_scummMixer, (byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + _scummMixer->mixCallback((byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); // demux data into 2 buffers, L and R __asm__ ( @@ -534,10 +539,6 @@ Common::TimerManager *OSystem_PS2::getTimerManager() { return _scummTimerManager; } -int OSystem_PS2::getOutputSampleRate(void) const { - return 48000; -} - Audio::Mixer *OSystem_PS2::getMixer() { return _scummMixer; } @@ -546,6 +547,10 @@ Common::SaveFileManager *OSystem_PS2::getSavefileManager(void) { return _saveManager; } +FilesystemFactory *OSystem_PS2::getFilesystemFactory() { + return &Ps2FilesystemFactory::instance(); +} + void OSystem_PS2::setShakePos(int shakeOffset) { _screen->setShakePos(shakeOffset); } diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index 9dbe9be553..08975ab2c8 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -33,6 +33,7 @@ class DefaultTimerManager; class Gs2dScreen; class Ps2Input; class Ps2SaveFileManager; +// class Ps2FilesystemFactory; struct IrxReference; #define MAX_MUTEXES 16 @@ -48,7 +49,7 @@ namespace Common { }; namespace Audio { - class Mixer; + class MixerImpl; }; class OSystem_PS2 : public OSystem { @@ -87,7 +88,6 @@ public: virtual bool pollEvent(Common::Event &event); virtual Audio::Mixer *getMixer(); - virtual int getOutputSampleRate(void) const; virtual bool openCD(int drive); virtual bool pollCD(); @@ -112,6 +112,7 @@ public: virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); virtual Common::SaveFileManager *getSavefileManager(); + virtual FilesystemFactory *getFilesystemFactory(); virtual void getTimeAndDate(struct tm &t) const; @@ -133,7 +134,7 @@ private: void readRtcTime(void); DefaultTimerManager *_scummTimerManager; - Audio::Mixer *_scummMixer; + Audio::MixerImpl *_scummMixer; bool _mouseVisible; -- cgit v1.2.3