aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2014-04-28 21:20:42 +0300
committerEugene Sandulenko2014-04-28 21:20:42 +0300
commitc3ffbd884a2d917aede6020c4ae1ee4a13d7f861 (patch)
treeeef69449accc9a020cf1be49703a0dd698340c11
parent3d5dee897ef785e3f0c48ae3d857181f314700d1 (diff)
parent4592e0b586829fade4a5c800672849e693a0d151 (diff)
downloadscummvm-rg350-c3ffbd884a2d917aede6020c4ae1ee4a13d7f861.tar.gz
scummvm-rg350-c3ffbd884a2d917aede6020c4ae1ee4a13d7f861.tar.bz2
scummvm-rg350-c3ffbd884a2d917aede6020c4ae1ee4a13d7f861.zip
Merge pull request #426 from sunmax/master
PS2: Pull request to master for latest PS2 code
-rw-r--r--Makefile.common4
-rw-r--r--backends/fs/ps2/ps2-fs.cpp47
-rw-r--r--backends/fs/ps2/ps2-fs.h4
-rw-r--r--backends/platform/ps2/DmaPipe.cpp8
-rw-r--r--backends/platform/ps2/Gs2dScreen.cpp261
-rw-r--r--backends/platform/ps2/Gs2dScreen.h15
-rw-r--r--backends/platform/ps2/GsDefs.h172
-rw-r--r--backends/platform/ps2/Makefile.gdb104
-rw-r--r--backends/platform/ps2/Makefile.ps2232
-rw-r--r--backends/platform/ps2/Makefile.ps2.dev170
-rw-r--r--backends/platform/ps2/README.PS2189
-rw-r--r--backends/platform/ps2/asyncfio.cpp14
-rw-r--r--backends/platform/ps2/asyncfio.h3
-rw-r--r--backends/platform/ps2/cd.c38
-rw-r--r--backends/platform/ps2/eecodyvdfs.h2
-rw-r--r--backends/platform/ps2/fileio.cpp48
-rw-r--r--backends/platform/ps2/fileio.h14
-rw-r--r--backends/platform/ps2/icon.cpp2
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/common/codyvdirx.h14
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h88
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c72
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h28
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c12
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c12
-rw-r--r--backends/platform/ps2/iop/rpckbd/include/ps2kbd.h4
-rw-r--r--backends/platform/ps2/iop/rpckbd/src/ps2kbd.c4
-rw-r--r--backends/platform/ps2/irxboot.cpp85
-rw-r--r--backends/platform/ps2/irxboot.h13
-rw-r--r--backends/platform/ps2/module.mk20
-rw-r--r--backends/platform/ps2/ps2debug.cpp3
-rw-r--r--backends/platform/ps2/ps2debug.h8
-rw-r--r--backends/platform/ps2/ps2input.cpp70
-rw-r--r--backends/platform/ps2/ps2input.h2
-rw-r--r--backends/platform/ps2/ps2pad.cpp8
-rw-r--r--backends/platform/ps2/ps2time.cpp6
-rw-r--r--backends/platform/ps2/rpckbd.c2
-rw-r--r--backends/platform/ps2/savefilemgr.cpp33
-rw-r--r--backends/platform/ps2/sysdefs.h34
-rw-r--r--backends/platform/ps2/systemps2.cpp355
-rw-r--r--backends/platform/ps2/systemps2.h33
-rw-r--r--backends/plugins/elf/version.cpp8
-rw-r--r--base/version.cpp6
-rw-r--r--common/scummsys.h5
-rwxr-xr-xconfigure21
-rw-r--r--engines/dialogs.cpp5
-rw-r--r--engines/sword25/util/lua/loslib.cpp10
46 files changed, 1533 insertions, 755 deletions
diff --git a/Makefile.common b/Makefile.common
index 4071d97150..993b833f4e 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -62,6 +62,7 @@ endif
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifneq ($(VERBOSE_BUILD),1)
ifneq ($(VERBOSE_BUILD),yes)
+QUIET_CC = @echo ' ' C ' ' $@;
QUIET_CXX = @echo ' ' C++ ' ' $@;
QUIET_AS = @echo ' ' AS ' ' $@;
QUIET_NASM = @echo ' ' NASM ' ' $@;
@@ -95,6 +96,9 @@ ifdef CXX_UPDATE_DEP_FLAG
# Build rule for C++ files. Makes use of CXX_UPDATE_DEP_FLAG for advanced
# dependency tracking.
+%.o: %.c
+ $(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
+ $(QUIET_CC)$(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
%.o: %.cpp
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
diff --git a/backends/fs/ps2/ps2-fs.cpp b/backends/fs/ps2/ps2-fs.cpp
index 7cbd205ecb..9b6e1270f1 100644
--- a/backends/fs/ps2/ps2-fs.cpp
+++ b/backends/fs/ps2/ps2-fs.cpp
@@ -22,9 +22,9 @@
#if defined(__PLAYSTATION2__)
-// Disable symbol overrides so that we can use system headers.
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-
+// Disable symbol overrides so that we can use "FILE"
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
#include "backends/fs/ps2/ps2-fs.h"
@@ -58,13 +58,13 @@ const char *_lastPathComponent(const Common::String &str) {
cur++;
- // printf("lastPathComponent path=%s token=%s\n", start, cur);
+ // dbg_printf("lastPathComponent path=%s token=%s\n", start, cur);
return cur;
}
Ps2FilesystemNode::Ps2FilesystemNode() {
- printf("NEW FSNODE()\n");
+ dbg_printf("NEW FSNODE()\n");
_isHere = true;
_isDirectory = true;
@@ -75,7 +75,7 @@ Ps2FilesystemNode::Ps2FilesystemNode() {
}
Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path) {
- printf("NEW FSNODE(%s)\n", path.c_str());
+ dbg_printf("NEW FSNODE(%s)\n", path.c_str());
_path = path;
@@ -107,7 +107,7 @@ Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path) {
}
Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path, bool verify) {
- printf("NEW FSNODE(%s, %d)\n", path.c_str(), verify);
+ dbg_printf("NEW FSNODE(%s, %d)\n", path.c_str(), verify);
_path = path;
@@ -164,24 +164,24 @@ void Ps2FilesystemNode::doverify(void) {
_verified = true;
- printf(" verify: %s -> ", _path.c_str());
+ dbg_printf(" verify: %s -> ", _path.c_str());
#if 0
if (_path.empty()) {
- printf("PlayStation 2 Root !\n");
+ dbg_printf("PlayStation 2 Root !\n");
_verified = true;
return;
}
if (_path.lastChar() == ':') {
- printf("Dev: %s\n", _path.c_str());
+ dbg_printf("Dev: %s\n", _path.c_str());
_verified = true;
return;
}
#endif
if (_path[3] != ':' && _path[4] != ':') {
- printf("relative path !\n");
+ dbg_printf("relative path !\n");
_isHere = false;
_isDirectory = false;
return;
@@ -204,7 +204,7 @@ void Ps2FilesystemNode::doverify(void) {
fileXioWaitAsync(FXIO_WAIT, &fd);
if (!fd) {
- printf(" yes [stat]\n");
+ dbg_printf(" yes [stat]\n");
return true;
}
break;
@@ -218,11 +218,11 @@ void Ps2FilesystemNode::doverify(void) {
#if 1
fd = fio.open(_path.c_str(), O_RDONLY);
- printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd);
+ dbg_printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd);
if (fd >=0) {
fio.close(fd);
- printf(" yes [open]\n");
+ dbg_printf(" yes [open]\n");
_isHere = true;
if (medium==MC_DEV && _path.lastChar()=='/')
_isDirectory = true;
@@ -234,7 +234,7 @@ void Ps2FilesystemNode::doverify(void) {
fd = fio.dopen(_path.c_str());
if (fd >=0) {
fio.dclose(fd);
- printf(" yes [dopen]\n");
+ dbg_printf(" yes [dopen]\n");
_isHere = true;
_isDirectory = true;
return;
@@ -267,13 +267,13 @@ void Ps2FilesystemNode::doverify(void) {
_isHere = false;
_isDirectory = false;
- printf(" no\n");
+ dbg_printf(" no\n");
return;
}
AbstractFSNode *Ps2FilesystemNode::getChild(const Common::String &n) const {
- printf("getChild : %s\n", n.c_str());
+ dbg_printf("getChild : %s\n", n.c_str());
if (!_isDirectory)
return NULL;
@@ -328,13 +328,14 @@ AbstractFSNode *Ps2FilesystemNode::getChild(const Common::String &n) const {
bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
//TODO: honor the hidden flag
- // printf("getChildren\n");
+ // dbg_printf("getChildren\n");
if (!_isDirectory)
return false;
if (_isRoot) {
- list.push_back(new Ps2FilesystemNode("cdfs:"));
+ if (g_systemPs2->cdPresent())
+ list.push_back(new Ps2FilesystemNode("cdfs:"));
if (g_systemPs2->hddPresent())
list.push_back(new Ps2FilesystemNode("pfs0:"));
@@ -342,7 +343,7 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi
if (g_systemPs2->usbMassPresent())
list.push_back(new Ps2FilesystemNode("mass:"));
- if (g_systemPs2->getBootDevice()==HOST_DEV || g_systemPs2->netPresent())
+ if (g_systemPs2->netPresent())
list.push_back(new Ps2FilesystemNode("host:"));
if (g_systemPs2->mcPresent())
@@ -357,7 +358,7 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi
else
fd = fio.dopen(_path.c_str());
- // printf("dopen = %d\n", fd);
+ // dbg_printf("dopen = %d\n", fd);
if (fd >= 0) {
iox_dirent_t dirent;
@@ -399,7 +400,7 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi
}
AbstractFSNode *Ps2FilesystemNode::getParent() const {
- // printf("Ps2FilesystemNode::getParent : path = %s\n", _path.c_str());
+ // dbg_printf("Ps2FilesystemNode::getParent : path = %s\n", _path.c_str());
if (_isRoot)
return new Ps2FilesystemNode(this); // FIXME : 0 ???
@@ -411,7 +412,7 @@ AbstractFSNode *Ps2FilesystemNode::getParent() const {
const char *end = _lastPathComponent(_path);
Common::String str(start, end - start);
- // printf(" parent = %s\n", str.c_str());
+ // dbg_printf(" parent = %s\n", str.c_str());
return new Ps2FilesystemNode(str, true);
}
diff --git a/backends/fs/ps2/ps2-fs.h b/backends/fs/ps2/ps2-fs.h
index 4c1a9bba96..63b866ba5b 100644
--- a/backends/fs/ps2/ps2-fs.h
+++ b/backends/fs/ps2/ps2-fs.h
@@ -70,12 +70,12 @@ public:
virtual Common::String getPath() const { return _path; }
virtual bool exists() const {
- // printf("%s : is %d\n", _path.c_str(), _isHere);
+ // dbg_printf("%s : is %d\n", _path.c_str(), _isHere);
return _isHere;
}
virtual bool isDirectory() const {
- // printf("%s : dir %d\n", _path.c_str(), _isDirectory);
+ // dbg_printf("%s : dir %d\n", _path.c_str(), _isDirectory);
return _isDirectory;
}
diff --git a/backends/platform/ps2/DmaPipe.cpp b/backends/platform/ps2/DmaPipe.cpp
index e0a7d97807..a4bcf6299e 100644
--- a/backends/platform/ps2/DmaPipe.cpp
+++ b/backends/platform/ps2/DmaPipe.cpp
@@ -50,7 +50,7 @@ DmaPipe::DmaPipe(uint32 size) {
size &= ~0x1F;
_buf = (uint64 *)memalign(64, size);
_curPipe = 0;
- _pipes[0] = new SinglePipe(_buf, size >> 4);
+ _pipes[0] = new SinglePipe(_buf, size >> 4);
_pipes[1] = new SinglePipe(_buf + (size >> 4), size >> 4);
// reset DMAC Channel 2
@@ -80,7 +80,7 @@ void DmaPipe::uploadTex(uint32 dest, uint16 bufWidth, uint16 destOfsX, uint16 de
*(_pipes[_curPipe]->_chainHead) |= (1 << 28);
_pipes[_curPipe]->setGifLoopTag(4);
_pipes[_curPipe]->setReg(GPR_BITBLTBUF, GS_SET_DEST_BLTBUF((dest/256) & 0x3fff, (bufWidth/64) & 0x3f, pixelFmt & 0x3f));
- _pipes[_curPipe]->setReg( GPR_TRXPOS, GS_SET_DEST_TRXPOS(destOfsX, destOfsY));
+ _pipes[_curPipe]->setReg( GPR_TRXPOS, GS_SET_DEST_TRXPOS(destOfsX, destOfsY));
_pipes[_curPipe]->setReg( GPR_TRXREG, GS_SET_TRXREG(width, height));
_pipes[_curPipe]->setReg( GPR_TRXDIR, 0);
@@ -194,7 +194,7 @@ void DmaPipe::setConfig(uint8 prModeCont, uint8 dither, uint8 colClamp) {
// set some defaults
// alpha blending formula: (A-B) * C + D
- // set: A = dest pixel, b = 0, C = source alpha, D = source pixel, fix = don't care
+ // set: A = dest pixel, b = 0, C = source alpha, D = source pixel, fix = don't care
_pipes[_curPipe]->setReg(GPR_ALPHA_1, GS_SET_ALPHA(DEST_COLOR, ZERO_COLOR, SOURCE_ALPHA, SOURCE_COLOR, 0));
_pipes[_curPipe]->setReg( GPR_PRIM, 0);
@@ -279,7 +279,7 @@ void SinglePipe::appendChain(uint64 dmaTag) {
void SinglePipe::setReg(uint64 reg, uint64 value) {
*_bufPos++ = value;
*_bufPos++ = reg;
- (*_chainSize)++;
+ (*_chainSize)++;
}
void SinglePipe::setListReg(uint64 value1, uint64 value2) {
diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp
index 7eeedc1944..a4ec23329a 100644
--- a/backends/platform/ps2/Gs2dScreen.cpp
+++ b/backends/platform/ps2/Gs2dScreen.cpp
@@ -32,6 +32,7 @@
#include "DmaPipe.h"
#include "GsDefs.h"
#include "graphics/surface.h"
+#include "graphics/colormasks.h"
#include "backends/platform/ps2/ps2debug.h"
extern void *_gp;
@@ -43,12 +44,49 @@ enum Buffers {
PRINTF
};
+/*
+ Supported modes:
+
+ Mode #1 = SDTV progressive (NTSC: 224p / PAL: 256p)
+ Mode #2 = SDTV interlaced (NTSC: 448i / PAL: 512i) <- default
+ Mode #3 = EDTV progressive (NTSC: 480p / PAL: 576p)
+ Mode #4 = HDTV progressive (720p)
+ Mode #5 = HDTV interlaced (1080i)
+ Mode #6 = VESA (640x480@60)
+ Mode #7 = VESA (800x600@60)
+ Mode #8 = VESA (1024x768@60)
+*/
+
+static ps2_mode_t ps2_mode[] = {
+
+ // -> w, h, interlaced, pitch, mode, vck, magh, magv, dx, dy
+
+ /* #1 : SDTV - progressive */
+ { 640, 224, 0, 640, 0x02, 2560, 4, 0, 160 /*158*/, 25 /*22*/ }, /* NTSC */
+ { 640, 256, 0, 640, 0x03, 2560, 4, 0, 170 /*163*/, 35 /*36*/ }, /* PAL */
+
+ /* #2 : SDTV - interlaced */
+ { 640, 448, 1, 640, 0x02, 2560, 4, 0, 156 /*158*/, 50 /*45*/ }, /* NTSC */
+ { 640, 512, 1, 640, 0x03, 2560, 4, 0, 170 /*163*/, 70 /*72*/ }, /* PAL */
+
+ /* #3 : EDTV */
+ { 720, 480, 0, 768, 0x50, 1440, 2, 0, 58, 35 }, /* NTSC */
+ /* { 720, 576, 0, 768, 0x53, 1440, 2, 0, 62, 45 }, */ /* PAL : full */
+ /* { 656, 576, 0, 704, 0x53, 1312, 2, 0, 62, 45 }, */ /* PAL : redux @ (0,0) */
+ { 656, 576, 0, 704, 0x53, 1312, 2, 0, 78 /*314*/, 45 }, /* PAL : redux @ center'd */
+
+ /* #4/#5 : HDTV */
+ { 1280, 720, 0, 1280, 0x52, 1280, 1, 0, 76 /*302*/, 24 },
+ { 1920, 1080, 1, 1920, 0x51, 1920, 1, 0, 60 /*236*/ /*238*/, 40 },
+
+ /* #6/#7/#8 : VESA 4:3 @ 60Hz */
+ { 640, 480, 0, 640, 0x1A, 1280, 2, 0, 70 /*276*/, 34 },
+ { 800, 600, 0, 832, 0x2B, 1600, 2, 0, 105 /*420*/, 26 },
+ { 1024, 768, 0, 1024, 0x3B, 2048, 2, 0, 144 /*580*/, 34 }
+};
+
#define ANIM_STACK_SIZE (1024 * 32)
-#define DEFAULT_PAL_X 175
-#define DEFAULT_PAL_Y 72 // 60
-#define DEFAULT_NTSC_X 165
-#define DEFAULT_NTSC_Y 45
#define ORG_X 256
#define ORG_Y 256
#define ORIGIN_X (ORG_X << 4)
@@ -77,7 +115,7 @@ void runAnimThread(Gs2dScreen *param);
int vblankStartHandler(int cause) {
// start of VBlank period
- if (g_VblankCmd) { // is there a new image waiting?
+ if (g_VblankCmd) { // is there a new image waiting?
GS_DISPFB1 = g_VblankCmd; // show it.
g_VblankCmd = 0;
iSignalSema(g_VblankSema);
@@ -87,8 +125,8 @@ int vblankStartHandler(int cause) {
int dmacHandler(int channel) {
if (g_DmacCmd && (channel == 2)) { // GS DMA transfer finished,
- g_VblankCmd = g_DmacCmd; // we want to show the image
- g_DmacCmd = 0; // when the next vblank occurs
+ g_VblankCmd = g_DmacCmd; // we want to show the image
+ g_DmacCmd = 0; // when the next vblank occurs
iSignalSema(g_DmacSema);
}
return 0;
@@ -102,7 +140,8 @@ int vblankEndHandler(int cause) {
void createAnimThread(Gs2dScreen *screen);
-Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
+Gs2dScreen::Gs2dScreen(uint16 width, uint16 height) {
+
_systemQuit = false;
ee_sema_t newSema;
newSema.init_count = 1;
@@ -125,12 +164,15 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
EnableIntc(INT_VBLANK_END);
EnableDmac(2);
+ _tvMode = 0; // force detection
+ _gfxMode = 0;
+
_width = width;
_height = height;
_pitch = (width + 127) & ~127;
_screenBuf = (uint8 *)memalign(64, _width * _height);
- _overlayBuf = (uint16 *)memalign(64, _width * _height * 2);
+ _overlayBuf = (uint16 *)memalign(64, _pitch * _height * 2);
_clut = (uint32 *)memalign(64, 256 * 4);
memset(_screenBuf, 0, _width * _height);
@@ -138,32 +180,102 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
_clut[1] = GS_RGBA(0xC0, 0xC0, 0xC0, 0);
clearOverlay();
- if (mode == TV_DONT_CARE) {
-#if 1
char romver[8];
+ uint16 biosver;
int fd = fioOpen("rom0:ROMVER", O_RDONLY);
fioRead(fd, &romver, 8);
fioClose(fd);
+ biosver=atoi(romver);
+ printf("ROMVER = %s\n", romver);
+ printf("ver = %d\n", atoi(romver));
+
+ if (!_tvMode) { // determine TV standard first
+ if (ConfMan.hasKey("tv_mode", "PlayStation2")) {
+ const char *tvname = ConfMan.get("tv_mode", "PlayStation2").c_str();
+
+ if (strcmp("ntsc", tvname) == 0) {
+ _tvMode = 2;
+ }
+ else if (strcmp("pal", tvname) == 0) {
+ _tvMode = 1;
+ }
+ else
+ _tvMode = 0;
+ }
+
+ if (!_tvMode) {
+ if (romver[4] == 'E')
+ _tvMode = TV_PAL;
+ else
+ _tvMode = TV_NTSC;
+
+ printf("Auto-detect TV mode: PSX:%c PS2:%c\n", *(char *)(0x1FC7FF52), romver[4]);
+ }
+ }
+
+ uint8 mode;
+ if (!_gfxMode) { // determine GFX mode next
+ if (ConfMan.hasKey("gfx_mode", "PlayStation2")) {
+ _gfxMode = ConfMan.getInt("gfx_mode", "PlayStation2");
+ // TODO: free more video mem to support these modes
+ if (_gfxMode == 4 || _gfxMode == 5) {
+ printf("Not enough video mem: using EDTV (3)\n");
+ _gfxMode = 3;
+ }
+ else
+ if (_gfxMode == 7 || _gfxMode == 8) {
+ printf("Not enough video mem: using VGA (6)\n");
+ _gfxMode = 6;
+ }
- if (romver[4] == 'E')
- _tvMode = TV_PAL;
- else
- _tvMode = TV_NTSC;
-#else
- if (PAL_NTSC_FLAG == 'E')
- _tvMode = TV_PAL;
+ if (_gfxMode < 1 || _gfxMode > 8) _gfxMode = 2;
+ else
+ if (_gfxMode == 4 || _gfxMode == 5) _tvMode = TV_HDTV;
+ else
+ if (_gfxMode > 5) _tvMode = TV_VESA;
+ }
else
- _tvMode = TV_NTSC;
-#endif
- } else
- _tvMode = mode;
+ _gfxMode = 2;
+ }
+
+ // Remap Mode Index
+ mode = _gfxMode;
+ if (_tvMode == TV_NTSC) {
+ mode = (mode * 2) - 1;
+ }
+ else if (_tvMode == TV_PAL) {
+ mode = (mode * 2);
+ }
+ else if (_tvMode == TV_HDTV) {
+ mode += 3;
+ }
+ else /* VESA */ {
+ _tvMode = TV_VESA;
+ mode += 3;
+ }
+ mode--;
+
+ switch (_tvMode) {
+ case TV_NTSC:
+ printf("Setting up TV mode: NTSC\n");
+ break;
+ case TV_PAL:
+ printf("Setting up TV mode: PAL\n");
+ break;
+ case TV_HDTV:
+ printf("Setting up TV mode: HDTV\n");
+ break;
+ case TV_VESA:
+ printf("Setting up TV mode: VESA\n");
+ break;
+ }
+
+ _tvWidth = ps2_mode[mode].w;
+ _tvHeight = ps2_mode[mode].h;
+ _tvPitch = ps2_mode[mode].pitch;
- // _tvMode = TV_NTSC;
- printf("Setting up %s mode\n", (_tvMode == TV_PAL) ? "PAL" : "NTSC");
+ printf("Setting up GFX mode: %d x %d\n", _tvWidth, _tvHeight);
- // set screen size, 640x512 for pal, 640x448 for ntsc
- _tvWidth = 640;
- _tvHeight = ((_tvMode == TV_PAL) ? 512 /*544*/ : 448);
kFullScreen[0].z = kFullScreen[1].z = 0;
kFullScreen[0].x = ORIGIN_X;
kFullScreen[0].y = ORIGIN_Y;
@@ -176,7 +288,7 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
_texCoords[1].u = SCALE(_width);
_texCoords[1].v = SCALE(_height);
- uint32 tvFrameSize = _tvWidth * _tvHeight * 4; // 32 bits per pixel
+ uint32 tvFrameSize = _tvPitch * _tvHeight * 4; // 32 bits per pixel
// setup frame buffer pointers
_frameBufPtr[0] = 0;
@@ -186,7 +298,7 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
_clutPtrs[TEXT] = _clutPtrs[SCREEN] + 0x2000;
_texPtrs[SCREEN] = _clutPtrs[SCREEN] + 0x3000;
_texPtrs[TEXT] = 0; // these buffers are stored in the alpha gaps of the frame buffers
- _texPtrs[MOUSE] = 128 * 256 * 4;
+ _texPtrs[MOUSE] = 128 * 256 * 4;
_texPtrs[PRINTF] = _texPtrs[MOUSE] + M_SIZE * M_SIZE * 4;
_showOverlay = false;
@@ -202,12 +314,12 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
_overlayFormat.rLoss = 3;
_overlayFormat.gLoss = 3;
_overlayFormat.bLoss = 3;
- _overlayFormat.aLoss = 7;
+ _overlayFormat.aLoss = 8; // 7
_overlayFormat.rShift = 0;
_overlayFormat.gShift = 5;
_overlayFormat.bShift = 10;
- _overlayFormat.aShift = 15;
+ _overlayFormat.aShift = 0; // 15
// setup hardware now.
GS_CSR = CSR_RESET; // Reset GS
@@ -215,22 +327,39 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
GS_CSR = 0;
GsPutIMR(0x7F00);
- uint16 dispPosX, dispPosY;
- if (_tvMode == TV_PAL) {
- SetGsCrt(GS_INTERLACED, 3, 0);
- dispPosX = DEFAULT_PAL_X;
- dispPosY = DEFAULT_PAL_Y;
- } else {
- SetGsCrt(GS_INTERLACED, 2, 0);
- dispPosX = DEFAULT_NTSC_X;
- dispPosY = DEFAULT_NTSC_Y;
+ if (biosver < 220 && ps2_mode[mode].mode == 0x53) { // EDTV PAL : mode not in BIOS < 2.20
+ // no worries... we work in magic ;-)
+ /* 720x576p */
+ asm ("di");
+ asm ("sync.l; sync.p");
+ GS_PMODE = 0;
+ asm ("sync.l; sync.p");
+ GS_SMODE1 = 0x1742890504;
+ asm ("sync.l; sync.p");
+ GS_SMODE2 = 0;
+ GS_SYNCH1 = 0x402E02003C827;
+ asm ("sync.l; sync.p");
+ GS_SYNCH2 = 0x19CA67;
+ asm ("sync.l; sync.p");
+ GS_SYNCV = 0xA9000002700005;
+ asm ("sync.l; sync.p");
+ GS_SRFSH = 4;
+ asm ("sync.l; sync.p");
+ GS_SMODE1 = 0x1742880504;
+ asm ("sync.l; sync.p");
+ asm ("sync.l; sync.p");
+ GS_SMODE2 = 0;
+ asm("ei");
+ }
+ else { // BIOS
+ SetGsCrt(ps2_mode[mode].interlaced, ps2_mode[mode].mode, 0); // ps2_mode[mode].interlaced);
}
asm("di");
GS_PMODE = GS_SET_PMODE(1, 0, 1, 1, 0, 255);
GS_BGCOLOUR = GS_RGBA(0, 0, 0, 0);
- GS_DISPLAY1 = GS_SET_DISPLAY(_tvWidth, _tvHeight, dispPosX, dispPosY);
+ GS_DISPLAY1 = GS_SET_DISPLAY_MODE(ps2_mode[mode]);
asm("ei");
_curDrawBuf = 0;
@@ -238,7 +367,7 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
_dmaPipe->setOrigin(ORIGIN_X, ORIGIN_Y);
_dmaPipe->setConfig(1, 0, 1);
_dmaPipe->setScissorRect(0, 0, _tvWidth - 1, _tvHeight - 1);
- _dmaPipe->setDrawBuffer(_frameBufPtr[_curDrawBuf], _tvWidth, GS_PSMCT24, 0);
+ _dmaPipe->setDrawBuffer(_frameBufPtr[_curDrawBuf], _tvPitch, GS_PSMCT24, 0);
_dmaPipe->flush();
_clutChanged = _screenChanged = _overlayChanged = true;
@@ -249,24 +378,33 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
createAnimTextures();
// create animation thread
- ee_thread_t animationThread, thisThread;
+ #ifdef __NEW_PS2SDK__
+ ee_thread_t animThread;
+ ee_thread_status_t thisThread;
+ #else
+ ee_thread_t animThread, thisThread;
+ #endif
ReferThreadStatus(GetThreadId(), &thisThread);
- _animStack = malloc(ANIM_STACK_SIZE);
- animationThread.initial_priority = thisThread.current_priority - 3;
- animationThread.stack = _animStack;
- animationThread.stack_size = ANIM_STACK_SIZE;
- animationThread.func = (void *)runAnimThread;
- animationThread.gp_reg = &_gp;
+ _animStack = memalign(64, ANIM_STACK_SIZE);
+ animThread.initial_priority = thisThread.current_priority - 3;
+ animThread.stack = _animStack;
+ animThread.stack_size = ANIM_STACK_SIZE;
+ animThread.func = (void *)runAnimThread;
+ animThread.gp_reg = &_gp;
- _animTid = CreateThread(&animationThread);
+ _animTid = CreateThread(&animThread);
assert(_animTid >= 0);
StartThread(_animTid, this);
}
void Gs2dScreen::quit(void) {
_systemQuit = true;
+ #ifdef __NEW_PS2SDK__
+ ee_thread_status_t statAnim;
+ #else
ee_thread_t statAnim;
+ #endif
do { // wait until thread called ExitThread()
SignalSema(g_AnimSema);
ReferThreadStatus(_animTid, &statAnim);
@@ -296,15 +434,15 @@ void Gs2dScreen::createAnimTextures(void) {
for (int i = 0; i < 16; i++) {
uint32 *destPos = (uint32 *)buf;
for (int ch = 15; ch >= 0; ch--) {
- const uint32 *src = (const uint32*)(_binaryData + ((_binaryPattern[i] >> ch) & 1) * 4 * 14);
+ const uint32 *src = (const uint32 *)(_binaryData + ((_binaryPattern[i] >> ch) & 1) * 4 * 14);
for (int line = 0; line < 14; line++)
destPos[line << 4] = src[line];
destPos++;
}
if (!(i & 1))
- _dmaPipe->uploadTex( vramDest, 128, 0, 0, GS_PSMT4HH, buf, 128, 16);
+ _dmaPipe->uploadTex( vramDest, 128, 0, 0, GS_PSMT4HH, buf, 128, 16);
else {
- _dmaPipe->uploadTex( vramDest, 128, 0, 0, GS_PSMT4HL, buf, 128, 16);
+ _dmaPipe->uploadTex( vramDest, 128, 0, 0, GS_PSMT4HL, buf, 128, 16);
vramDest += 128 * 16 * 4;
}
_dmaPipe->flush();
@@ -506,10 +644,10 @@ void Gs2dScreen::updateScreen(void) {
WaitSema(g_DmacSema); // wait for dma transfer, if there's one running
WaitSema(g_VblankSema); // wait if there's already an image waiting for vblank
- g_DmacCmd = GS_SET_DISPFB(_frameBufPtr[_curDrawBuf], _tvWidth, GS_PSMCT24); // put it here for dmac/vblank handler
+ g_DmacCmd = GS_SET_DISPFB(_frameBufPtr[_curDrawBuf], _tvPitch, GS_PSMCT24); // put it here for dmac/vblank handler
_dmaPipe->flush();
_curDrawBuf ^= 1;
- _dmaPipe->setDrawBuffer(_frameBufPtr[_curDrawBuf], _tvWidth, GS_PSMCT24, 0);
+ _dmaPipe->setDrawBuffer(_frameBufPtr[_curDrawBuf], _tvPitch, GS_PSMCT24, 0);
} else
_dmaPipe->flush();
SignalSema(_screenSema);
@@ -527,6 +665,7 @@ void Gs2dScreen::hideOverlay(void) {
Graphics::PixelFormat Gs2dScreen::getOverlayFormat(void) {
return _overlayFormat;
+ // return Graphics::createPixelFormat<1555>();
}
int16 Gs2dScreen::getOverlayWidth(void) {
@@ -633,11 +772,11 @@ void Gs2dScreen::setMouseXy(int16 x, int16 y) {
_mouseX = x;
_mouseY = y;
}
-
+/*
uint8 Gs2dScreen::tvMode(void) {
return _tvMode;
}
-
+*/
uint16 Gs2dScreen::getWidth(void) {
return _width;
}
@@ -655,7 +794,7 @@ void Gs2dScreen::wantAnim(bool runIt) {
#define V 1000
#define Z_TRANSL 65
-void Gs2dScreen::animThread(void) {
+void Gs2dScreen::playAnim(void) {
// animate zeros and ones while game accesses memory card, etc.
g_RunAnim = false;
float yPos = 0.0;
@@ -750,10 +889,10 @@ void Gs2dScreen::animThread(void) {
drawY += LINE_SPACE;
}
- g_DmacCmd = GS_SET_DISPFB(_frameBufPtr[_curDrawBuf], _tvWidth, GS_PSMCT24); // put it here for dmac/vblank handler
+ g_DmacCmd = GS_SET_DISPFB(_frameBufPtr[_curDrawBuf], _tvPitch, GS_PSMCT24); // put it here for dmac/vblank handler
_dmaPipe->flush();
_curDrawBuf ^= 1;
- _dmaPipe->setDrawBuffer(_frameBufPtr[_curDrawBuf], _tvWidth, GS_PSMCT24, 0);
+ _dmaPipe->setDrawBuffer(_frameBufPtr[_curDrawBuf], _tvPitch, GS_PSMCT24, 0);
_dmaPipe->setAlphaBlend(DEST_COLOR, ZERO_COLOR, SOURCE_ALPHA, SOURCE_COLOR, 0);
SignalSema(_screenSema);
@@ -763,7 +902,7 @@ void Gs2dScreen::animThread(void) {
}
void runAnimThread(Gs2dScreen *param) {
- param->animThread();
+ param->playAnim();
}
// data for the animated zeros and ones...
diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h
index be9729b66b..ea2b1e5f78 100644
--- a/backends/platform/ps2/Gs2dScreen.h
+++ b/backends/platform/ps2/Gs2dScreen.h
@@ -25,6 +25,7 @@
#include "sysdefs.h"
#include "backends/base-backend.h"
+#include "common/config-manager.h"
#include "backends/platform/ps2/DmaPipe.h"
#include "graphics/surface.h"
@@ -32,7 +33,9 @@
enum TVMode {
TV_DONT_CARE = 0,
TV_PAL,
- TV_NTSC
+ TV_NTSC,
+ TV_HDTV, /* internal */
+ TV_VESA /* internal */
};
enum GsInterlace {
@@ -42,14 +45,14 @@ enum GsInterlace {
class Gs2dScreen {
public:
- Gs2dScreen(uint16 width, uint16 height, TVMode mode);
+ Gs2dScreen(uint16 width, uint16 height);
~Gs2dScreen(void);
void newScreenSize(uint16 width, uint16 height);
- uint8 tvMode(void);
+ // uint8 tvMode(void);
uint16 getWidth(void);
uint16 getHeight(void);
- void copyPrintfOverlay(const uint8* buf);
+ void copyPrintfOverlay(const uint8 *buf);
void clearPrintfOverlay(void);
Graphics::Surface *lockScreen();
@@ -75,7 +78,7 @@ public:
void setMouseXy(int16 x, int16 y);
void setShakePos(int shake);
- void animThread(void);
+ void playAnim(void);
void wantAnim(bool runIt);
void quit(void);
@@ -85,8 +88,10 @@ private:
void createAnimTextures(void);
DmaPipe *_dmaPipe;
+ uint8 _gfxMode;
uint8 _tvMode;
uint16 _tvWidth, _tvHeight;
+ uint16 _tvPitch;
GsVertex _blitCoords[2];
TexVertex _texCoords[2];
diff --git a/backends/platform/ps2/GsDefs.h b/backends/platform/ps2/GsDefs.h
index 07e3c50ad8..9adf6acfcc 100644
--- a/backends/platform/ps2/GsDefs.h
+++ b/backends/platform/ps2/GsDefs.h
@@ -27,16 +27,23 @@
// Gs2dScreen defines:
-#define PAL_NTSC_FLAG (*(volatile uint8*)0x1FC7FF52)
+#define PAL_NTSC_FLAG (*(volatile uint8 *)0x1FC7FF52)
-#define GS_PMODE *((volatile uint64*)0x12000000)
-#define GS_CSR *((volatile uint64*)0x12001000)
-#define GS_DISPFB1 *((volatile uint64*)0x12000070)
-#define GS_DISPLAY1 *((volatile uint64*)0x12000080)
-#define GS_BGCOLOUR *((volatile uint64*)0x120000E0)
+#define GS_PMODE *((volatile uint64 *)0x12000000)
+#define GS_CSR *((volatile uint64 *)0x12001000)
+#define GS_DISPFB1 *((volatile uint64 *)0x12000070)
+#define GS_DISPLAY1 *((volatile uint64 *)0x12000080)
+#define GS_BGCOLOUR *((volatile uint64 *)0x120000E0)
+
+#define GS_SMODE1 *((volatile uint64 *)0x12000010)
+#define GS_SMODE2 *((volatile uint64 *)0x12000020)
+#define GS_SYNCH1 *((volatile uint64 *)0x12000040)
+#define GS_SYNCH2 *((volatile uint64 *)0x12000050)
+#define GS_SYNCV *((volatile uint64 *)0x12000060)
+#define GS_SRFSH *((volatile uint64 *)0x12000030)
enum GS_CSR_FIELDS {
- CSR_SIGNAL = 1 << 0,
+ CSR_SIGNAL = 1 << 0,
CSR_FINISH = 1 << 1,
CSR_HSYNC = 1 << 2,
CSR_VSYNC = 1 << 3,
@@ -44,6 +51,19 @@ enum GS_CSR_FIELDS {
CSR_RESET = 1 << 9
};
+typedef struct {
+ u16 w;
+ u16 h;
+ u16 interlaced;
+ u16 pitch;
+ u16 mode;
+ u16 vclk;
+ u16 magh;
+ u16 magv;
+ u16 dx;
+ u16 dy;
+} ps2_mode_t;
+
#define GS_SET_PMODE(readC1, readC2, alphaSel, alphaOut, alphaBlend, alphaFixed) \
((readC1) | ((readC2) << 1) | ((alphaSel) << 5) | ((alphaOut) << 6) | ((alphaBlend) << 7) | ((alphaFixed) << 8))
@@ -52,6 +72,10 @@ enum GS_CSR_FIELDS {
((((2560 + (width - 1)) / width) - 1)<<23) | \
(ypos << 12) | (xpos * (2560 / width)))
+#define GS_SET_DISPLAY_MODE(mode) \
+ (((uint64)(mode.h - 1) << 44) | ((uint64)(mode.vclk - 1) << 32) | \
+ ((mode.magh - 1) << 23) | (mode.dy << 12) | (mode.dx << 2))
+
#define GS_SET_DISPFB(frameBufPtr, frameBufWidth, psm) \
(((frameBufPtr) / 8192) | (((frameBufWidth) / 64) << 9) | ((psm) << 15))
@@ -61,63 +85,63 @@ enum GS_CSR_FIELDS {
//DmaPipe defines:
enum GsRegs {
- GPR_PRIM = 0x00, // Select and configure current drawing primitive
- GPR_RGBAQ, // Setup current vertex color
- GPR_ST, // ...
- GPR_UV, // Specify Vertex Texture Coordinates
- GPR_XYZF2, // Set vertex coordinate
- GPR_XYZ2, // Set vertex coordinate and 'kick' drawing
- GPR_TEX0_1, // Texture Buffer Setup (Context 1)
- GPR_TEX0_2, // Texture Buffer Setup (Context 2)
- GPR_CLAMP_1, // ...
- GPR_CLAMP_2, // ...
- GPR_FOG, // ...
-
- GPR_XYZF3 = 0x0C, // ...
- GPR_XYZ3, // ...
-
- GPR_TEX1_1 = 0x14, // ...
- GPR_TEX1_2, // ...
- GPR_TEX2_1, // ...
- GPR_TEX2_2, // ...
- GPR_XYOFFSET_1, // Mapping from Primitive to Window coordinate system (Context 1)
- GPR_XYOFFSET_2, // Mapping from Primitive to Window coordinate system (Context 2)
- GPR_PRMODECONT, // ...
- GPR_PRMODE, // ...
- GPR_TEXCLUT, // ...
-
- GPR_SCANMSK = 0x22, // ...
-
- GPR_MIPTBP1_1 = 0x34, // ...
- GPR_MIPTBP1_2, // ...
- GPR_MIPTBP2_1, // ...
- GPR_MIPTBP2_2, // ...
-
- GPR_TEXA = 0x3b, // ...
-
- GPR_FOGCOL = 0x3d, // ...
-
- GPR_TEXFLUSH = 0x3f,// Write to this register before using newly loaded texture
- GPR_SCISSOR_1, // Setup clipping rectangle (Context 1)
- GPR_SCISSOR_2, // Setup clipping rectangle (Context 2)
- GPR_ALPHA_1, // Setup Alpha Blending Parameters (Context 1)
- GPR_ALPHA_2, // Setup Alpha Blending Parameters (Context 2)
- GPR_DIMX, // ...
- GPR_DTHE, // ...
- GPR_COLCLAMP, // ...
- GPR_TEST_1, // ...
- GPR_TEST_2, // ...
- GPR_PABE, // ...
- GPR_FBA_1, // ...
- GPR_FBA_2, // ...
- GPR_FRAME_1, // Frame buffer settings (Context 1)
- GPR_FRAME_2, // Frame buffer settings (Context 2)
- GPR_ZBUF_1, // ...
- GPR_ZBUF_2, // ...
- GPR_BITBLTBUF, // Setup Image Transfer Between EE and GS
- GPR_TRXPOS, // Setup Image Transfer Coordinates
- GPR_TRXREG, // Setup Image Transfer Size
- GPR_TRXDIR, // Set Image Transfer Directon + Start Transfer
+ GPR_PRIM = 0x00, // Select and configure current drawing primitive
+ GPR_RGBAQ, // Setup current vertex color
+ GPR_ST, // ...
+ GPR_UV, // Specify Vertex Texture Coordinates
+ GPR_XYZF2, // Set vertex coordinate
+ GPR_XYZ2, // Set vertex coordinate and 'kick' drawing
+ GPR_TEX0_1, // Texture Buffer Setup (Context 1)
+ GPR_TEX0_2, // Texture Buffer Setup (Context 2)
+ GPR_CLAMP_1, // ...
+ GPR_CLAMP_2, // ...
+ GPR_FOG, // ...
+
+ GPR_XYZF3 = 0x0C, // ...
+ GPR_XYZ3, // ...
+
+ GPR_TEX1_1 = 0x14, // ...
+ GPR_TEX1_2, // ...
+ GPR_TEX2_1, // ...
+ GPR_TEX2_2, // ...
+ GPR_XYOFFSET_1, // Mapping from Primitive to Window coordinate system (Context 1)
+ GPR_XYOFFSET_2, // Mapping from Primitive to Window coordinate system (Context 2)
+ GPR_PRMODECONT, // ...
+ GPR_PRMODE, // ...
+ GPR_TEXCLUT, // ...
+
+ GPR_SCANMSK = 0x22, // ...
+
+ GPR_MIPTBP1_1 = 0x34, // ...
+ GPR_MIPTBP1_2, // ...
+ GPR_MIPTBP2_1, // ...
+ GPR_MIPTBP2_2, // ...
+
+ GPR_TEXA = 0x3b, // ...
+
+ GPR_FOGCOL = 0x3d, // ...
+
+ GPR_TEXFLUSH = 0x3f, // Write to this register before using newly loaded texture
+ GPR_SCISSOR_1, // Setup clipping rectangle (Context 1)
+ GPR_SCISSOR_2, // Setup clipping rectangle (Context 2)
+ GPR_ALPHA_1, // Setup Alpha Blending Parameters (Context 1)
+ GPR_ALPHA_2, // Setup Alpha Blending Parameters (Context 2)
+ GPR_DIMX, // ...
+ GPR_DTHE, // ...
+ GPR_COLCLAMP, // ...
+ GPR_TEST_1, // ...
+ GPR_TEST_2, // ...
+ GPR_PABE, // ...
+ GPR_FBA_1, // ...
+ GPR_FBA_2, // ...
+ GPR_FRAME_1, // Frame buffer settings (Context 1)
+ GPR_FRAME_2, // Frame buffer settings (Context 2)
+ GPR_ZBUF_1, // ...
+ GPR_ZBUF_2, // ...
+ GPR_BITBLTBUF, // Setup Image Transfer Between EE and GS
+ GPR_TRXPOS, // Setup Image Transfer Coordinates
+ GPR_TRXREG, // Setup Image Transfer Size
+ GPR_TRXDIR, // Set Image Transfer Directon + Start Transfer
GPR_HWREG,
GPR_SIGNAL = 0x60,
@@ -135,15 +159,15 @@ enum PrimTypes {
PR_SPRITE
};
-#define GS_PSMCT32 0x00
-#define GS_PSMCT24 0x01
-#define GS_PSMCT16 0x02
-#define GS_PSMCT16S 0x0A
-#define GS_PSMT8 0x13
-#define GS_PSMT4 0x14
-#define GS_PSMT4HL 0x24
-#define GS_PSMT4HH 0x2C
-#define GS_PSMT8H 0x1B
+#define GS_PSMCT32 0x00
+#define GS_PSMCT24 0x01
+#define GS_PSMCT16 0x02
+#define GS_PSMCT16S 0x0A
+#define GS_PSMT8 0x13
+#define GS_PSMT4 0x14
+#define GS_PSMT4HL 0x24
+#define GS_PSMT4HH 0x2C
+#define GS_PSMT8H 0x1B
/*#define GS_SET_BITBLTBUF(sbp, sbw, spsm, dbp, dbw, dpsm) \
((uint64)(sbp) | ((uint64)(sbw) << 16) | \
@@ -210,7 +234,7 @@ enum AlphaBlendColor {
enum AlphaBlendAlpha {
SOURCE_ALPHA = 0,
DEST_ALPHA,
- FIXED_ALPHA
+ FIXED_ALPHA
};
#define GS_SET_ALPHA(a, b, c, d, fix) \
diff --git a/backends/platform/ps2/Makefile.gdb b/backends/platform/ps2/Makefile.gdb
deleted file mode 100644
index 8ca47cd9f1..0000000000
--- a/backends/platform/ps2/Makefile.gdb
+++ /dev/null
@@ -1,104 +0,0 @@
-# $Header: Exp $
- include $(PS2SDK)/Defs.make
-
-PS2_EXTRA = /works/devel/ps2/sdk-extra
-PS2_EXTRA_INCS = /zlib/include /libmad/ee/include /SjPcm/ee/src /tremor
-PS2_EXTRA_LIBS = /zlib/lib /libmad/ee/lib /SjPcm/ee/lib /tremor/tremor
-
-ENABLED=STATIC_PLUGIN
-
-ENABLE_SCUMM = $(ENABLED)
-ENABLE_SCUMM_7_8 = $(ENABLED)
-# ENABLE_HE = $(ENABLED)
-# ENABLE_AGI = $(ENABLED)
-# ENABLE_AGOS = $(ENABLED)
-# ENABLE_AGOS2 = $(ENABLED)
-# ENABLE_CINE = $(ENABLED)
-# ENABLE_CRUISE = $(ENABLED)
-# ENABLE_DRACI = $(ENABLED)
-# ENABLE_DRASCULA = $(ENABLED)
-# ENABLE_GOB = $(ENABLED)
-# ENABLE_GROOVIE = $(ENABLED)
-## ENABLE_GROOVIE2 = $(ENABLED)
-# ENABLE_HUGO = $(ENABLED)
-# ENABLE_IHNM = $(ENABLED)
-# ENABLE_KYRA = $(ENABLED)
-## ENABLE_LOL = $(ENABLED)
-# ENABLE_LURE = $(ENABLED)
-## ENABLE_M4 = $(ENABLED)
-# ENABLE_MADE = $(ENABLED)
-# ENABLE_MOHAWK = $(ENABLED)
-# ENABLE_PARALLACTION = $(ENABLED)
-# ENABLE_QUEEN = $(ENABLED)
-# ENABLE_SAGA = $(ENABLED)
-# ENABLE_SAGA2 = $(ENABLED)
-# ENABLE_SCI = $(ENABLED)
-## ENABLE_SCI32 = $(ENABLED)
-# ENABLE_SKY = $(ENABLED)
-# ENABLE_SWORD1 = $(ENABLED)
-# ENABLE_SWORD2 = $(ENABLED)
-# ENABLE_TEENAGENT = $(ENABLED)
-# ENABLE_TINSEL = $(ENABLED)
-# ENABLE_TOON = $(ENABLED)
-# ENABLE_TOUCHE = $(ENABLED)
-# ENABLE_TUCKER = $(ENABLED)
-
-
-HAVE_GCC3 = true
-
-CC = ee-gcc
-CXX = ee-g++
-AS = ee-gcc
-LD = ee-gcc
-AR = ee-ar cru
-RANLIB = ee-ranlib
-STRIP = ee-strip
-MKDIR = mkdir -p
-RM = rm -f
-
-srcdir = ../../..
-VPATH = $(srcdir)
-INCDIR = ../../../
-# DEPDIR = .deps
-
-DEFINES = -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_ZLIB -DFORCE_RTL -DDISABLE_SAVEGAME_SORTING -D_EE -D__PLAYSTATION2__ -D__PS2_DEBUG__ -g -Wall -Wno-multichar -fno-rtti -fno-exceptions # -DNO_ADAPTOR
-# for release builds:
-#DEFINES += -DRELEASE_BUILD
-
-INCLUDES = $(addprefix -I$(PS2_EXTRA),$(PS2_EXTRA_INCS))
-INCLUDES += -I $(PS2GDB)/ee -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I ./common -I . -I $(srcdir) -I $(srcdir)/engines
-
-CXX_UPDATE_DEP_FLAG = -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP
-
-TARGET = elf/scummvm.elf
-
-OBJS := $(srcdir)/backends/platform/ps2/DmaPipe.o \
- $(srcdir)/backends/platform/ps2/Gs2dScreen.o \
- $(srcdir)/backends/platform/ps2/irxboot.o \
- $(srcdir)/backends/platform/ps2/ps2input.o \
- $(srcdir)/backends/platform/ps2/ps2pad.o \
- $(srcdir)/backends/platform/ps2/savefilemgr.o \
- $(srcdir)/backends/platform/ps2/fileio.o \
- $(srcdir)/backends/platform/ps2/asyncfio.o \
- $(srcdir)/backends/platform/ps2/icon.o \
- $(srcdir)/backends/platform/ps2/cd.o \
- $(srcdir)/backends/platform/ps2/eecodyvdfs.o \
- $(srcdir)/backends/platform/ps2/rpckbd.o \
- $(srcdir)/backends/platform/ps2/systemps2.o \
- $(srcdir)/backends/platform/ps2/ps2mutex.o \
- $(srcdir)/backends/platform/ps2/ps2time.o \
- $(srcdir)/backends/platform/ps2/ps2debug.o
-
-MODULE_DIRS += .
-
-include $(srcdir)/Makefile.common
-
-LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -T $(PS2SDK)/ee/startup/linkfile
-LDFLAGS += -L $(PS2GDB)/lib -L $(PS2SDK)/ee/lib -L .
-LDFLAGS += $(addprefix -L$(PS2_EXTRA),$(PS2_EXTRA_LIBS))
-LDFLAGS += -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lmad -ltremor -lz -lm -lc -lfileXio -lps2gdbStub -lps2ip -ldebug -lkernel -lstdc++
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- $(LD) $^ $(LDFLAGS) -o $@
diff --git a/backends/platform/ps2/Makefile.ps2 b/backends/platform/ps2/Makefile.ps2
index d6ce08ae84..3631c653f6 100644
--- a/backends/platform/ps2/Makefile.ps2
+++ b/backends/platform/ps2/Makefile.ps2
@@ -1,107 +1,217 @@
-# $Header: Exp $
- include $(PS2SDK)/Defs.make
+# SCUMMVM-PS2 MakeFile
-PS2_EXTRA = /works/devel/ps2/sdk-extra
-PS2_EXTRA_INCS = /zlib/include /libmad/ee/include /SjPcm/ee/src /tremor
-PS2_EXTRA_LIBS = /zlib/lib /libmad/ee/lib /SjPcm/ee/lib /tremor/tremor
-ENABLED=STATIC_PLUGIN
+# Use only this section to modify how the makefile behaves ------------
-ENABLE_SCUMM = $(ENABLED)
-ENABLE_SCUMM_7_8 = $(ENABLED)
-ENABLE_HE = $(ENABLED)
+# Scummvm engine config: choose which engines are enabled
ENABLE_AGI = $(ENABLED)
ENABLE_AGOS = $(ENABLED)
-ENABLE_AGOS2 = $(ENABLED)
+ENABLE_AGOS2 = 1
+# ENABLE_AVALANCHE = $(ENABLED)
+ENABLE_CGE = $(ENABLED)
ENABLE_CINE = $(ENABLED)
+ENABLE_COMPOSER = $(ENABLED)
ENABLE_CRUISE = $(ENABLED)
ENABLE_DRACI = $(ENABLED)
ENABLE_DRASCULA = $(ENABLED)
+ENABLE_DREAMWEB = $(ENABLED)
+# ENABLE_FULLPIPE = $(ENABLED)
ENABLE_GOB = $(ENABLED)
ENABLE_GROOVIE = $(ENABLED)
# ENABLE_GROOVIE2 = $(ENABLED)
+# ENABLE_HOPKINS = $(ENABLED)
ENABLE_HUGO = $(ENABLED)
-ENABLE_IHNM = $(ENABLED)
ENABLE_KYRA = $(ENABLED)
-# ENABLE_LOL = $(ENABLED)
+ENABLE_LOL = 1
+ENABLE_EOB = 1
+# ENABLE_LASTEXPRESS = $(ENABLED)
ENABLE_LURE = $(ENABLED)
-# ENABLE_M4 = $(ENABLED)
ENABLE_MADE = $(ENABLED)
ENABLE_MOHAWK = $(ENABLED)
+# ENABLE_CSTIME = $(ENABLED)
+# ENABLE_RIVEN = $(ENABLED)
+# ENABLE_MYST = $(ENABLED)
+ENABLE_MORTEVIELLE = $(ENABLED)
+ENABLE_NEVERHOOD = $(ENABLED)
ENABLE_PARALLACTION = $(ENABLED)
+# ENABLE_PEGASUS = $(ENABLED)
ENABLE_QUEEN = $(ENABLED)
ENABLE_SAGA = $(ENABLED)
+ENABLE_IHNM = 1
# ENABLE_SAGA2 = $(ENABLED)
ENABLE_SCI = $(ENABLED)
# ENABLE_SCI32 = $(ENABLED)
+ENABLE_SCUMM = $(ENABLED)
+ENABLE_SCUMM_7_8 = 1
+ENABLE_HE = 1
ENABLE_SKY = $(ENABLED)
ENABLE_SWORD1 = $(ENABLED)
ENABLE_SWORD2 = $(ENABLED)
+# ENABLE_SWORD25 = $(ENABLED)
ENABLE_TEENAGENT = $(ENABLED)
+# ENABLE_TESTBED = $(ENABLED)
ENABLE_TINSEL = $(ENABLED)
+ENABLE_TOLTECS = $(ENABLED)
+# ENABLE_TONY = $(ENABLED)
ENABLE_TOON = $(ENABLED)
ENABLE_TOUCHE = $(ENABLED)
+ENABLE_TSAGE = $(ENABLED)
ENABLE_TUCKER = $(ENABLED)
-
-
-HAVE_GCC3 = true
-
-CC = ee-gcc
-CXX = ee-g++
-AS = ee-gcc
-LD = ee-gcc
+# ENABLE_WINTERMUTE = $(ENABLED)
+# ENABLE_ZVISION = $(ENABLED)
+
+# Set to 1 to enable seeing the commands to gcc
+VERBOSE_BUILD = 0
+# Set to 1 to enable, 0 to disable dynamic modules
+DYNAMIC_MODULES = 1
+# Set to 1 to enable debugging
+ENABLE_DEBUG = 0
+# Set to 1 to enable profiling
+ENABLE_PROFILING = 0
+# Set to 1 to disable HDD+NET
+DISABLE_NETWORK = 0
+# Set to 1 to enable, 0 to disable libmad and libogg
+USE_LIBMAD = 1
+USE_LIBOGG = 1
+
+# ---------------------------------------------------------------------
+
+
+# General variables
+srcdir = ../../..
+VPATH = $(srcdir)
+TARGET = scummvm.elf
+# PS2 SDK location variables
+# PS2SDK = /works/tools/devel/ps2/sdk
+
+# Check PS2SDK presence
+ifeq ($(PS2SDK),)
+$(error $$(PS2SDK) needs to be set.)
+endif
+
+# Variables for common Scummvm makefile
+CC = ee-gcc
+CXX = ee-g++
+FLAGS = -pedantic -Wall -W
+FLAGS += -Wcast-qual -Wconversion -Wpointer-arith -Wshadow -Wwrite-strings
+FLAGS += -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-unused-parameter
+CFLAGS = $(FLAGS) -std=c99
+CXXFLAGS = $(FLAGS) -Wnon-virtual-dtor -Wno-reorder -fno-exceptions -fno-rtti
+
+DEFINES = -D_EE -D__PLAYSTATION2__ -D__NEW_PS2SDK__ -DUSE_ZLIB -DFORCE_RTL -DDATA_PATH=\"host:data\"
+DEFINES += -DDISABLE_SAVEGAME_SORTING -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL -DDISABLE_SID -DDISABLE_NES_APU
+# DEFINES += -DLOGORRHEIC
+
+INCDIR := $(PS2SDK)/ee/include $(PS2SDK)/common/include $(PS2SDK)/ports/include . $(srcdir) $(srcdir)/engines
+INCLUDES := $(addprefix -I, $(INCDIR))
+DEPDIR = .deps
+MODULE_DIRS += ./
+MKDIR = mkdir -p
+RM = rm -f
+RM_REC = rm -rf
AR = ee-ar cru
RANLIB = ee-ranlib
STRIP = ee-strip
-MKDIR = mkdir -p
-RM = rm -f
-
-srcdir = ../../..
-VPATH = $(srcdir)
-INCDIR = ../../../
-# DEPDIR = .deps
-
-DEFINES = -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_ZLIB -DFORCE_RTL -DDISABLE_SAVEGAME_SORTING -D_EE -D__PLAYSTATION2__ -G2 -O2 -Wall -Wno-multichar -fno-rtti -fno-exceptions # -DNO_ADAPTOR
-# for release builds:
-#DEFINES += -DRELEASE_BUILD
-
-INCLUDES = $(addprefix -I$(PS2_EXTRA),$(PS2_EXTRA_INCS))
-INCLUDES += -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I ./common -I . -I $(srcdir) -I $(srcdir)/engines
-
-CXX_UPDATE_DEP_FLAG = -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP
-
-TARGET = elf/scummvm.elf
+AS = ee-gcc
+LD = ee-gcc
+HAVE_GCC3 = true
+CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP
+
+# Variables for dynamic plugin building
+PLUGIN_PREFIX =
+PLUGIN_SUFFIX = .plg
+PLUGIN_EXTRA_DEPS = $(TARGET)
+PLUGIN_LDFLAGS = -nostartfiles $(srcdir)/backends/plugins/elf/version.o -Wl,-q,--just-symbols,$(TARGET),--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms
+PLUGIN_LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/plugin.ld -lstdc++ -lc
+
+# Test for adding different libs
+ifeq ($(USE_LIBMAD),1)
+DEFINES += -DUSE_MAD
+LIBS += -lmad
+endif
+ifeq ($(USE_LIBOGG), 1)
+DEFINES += -DUSE_VORBIS -DUSE_TREMOR
+LIBS += -ltremor
+endif
+
+# Test for dynamic plugins
+ifeq ($(DYNAMIC_MODULES),1)
+ENABLED = DYNAMIC_PLUGIN
+DEFINES += -DDYNAMIC_MODULES -DUSE_ELF_LOADER -DMIPS_TARGET -DUNCACHED_PLUGINS -DPLUGIN_DIRECTORY=\"host:plugins\"
+PRE_OBJS_FLAGS = -Wl,--whole-archive
+POST_OBJS_FLAGS = -Wl,--no-whole-archive
+else
+ENABLED = STATIC_PLUGIN
+endif
+
+# Test for debug
+ifeq ($(ENABLE_DEBUG),1)
+DEFINES += -D__PS2_DEBUG__
+FLAGS += -G2 -g
+LIBS += -lps2gdbStub -lps2ip -ldebug
+else
+DEFINES += -DRELEASE_BUILD
+FLAGS += -G2 -O2 -s -Wuninitialized
+# LDFLAGS += -s
+endif
+
+# Test for profiling
+ifeq ($(ENABLE_PROFILING),1)
+DEFINES += -DENABLE_PROFILING
+FLAGS += -G2 -pg -g
+LDFLAGS += -pg
+endif
+
+# Test for net support
+ifeq ($(DISABLE_NETWORK),1)
+DEFINES += -DNO_ADAPTOR
+endif
+
+# PS2 LIBS
+PS2LIBS = -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lz -lm -lc -lfileXio -lkernel -lstdc++
+
+# Add in PS2SDK includes and libraries.
+LIBS += $(PS2LIBS)
OBJS := $(srcdir)/backends/platform/ps2/DmaPipe.o \
- $(srcdir)/backends/platform/ps2/Gs2dScreen.o \
- $(srcdir)/backends/platform/ps2/irxboot.o \
- $(srcdir)/backends/platform/ps2/ps2input.o \
- $(srcdir)/backends/platform/ps2/ps2pad.o \
- $(srcdir)/backends/platform/ps2/savefilemgr.o \
- $(srcdir)/backends/platform/ps2/fileio.o \
- $(srcdir)/backends/platform/ps2/asyncfio.o \
- $(srcdir)/backends/platform/ps2/icon.o \
- $(srcdir)/backends/platform/ps2/cd.o \
- $(srcdir)/backends/platform/ps2/eecodyvdfs.o \
- $(srcdir)/backends/platform/ps2/rpckbd.o \
- $(srcdir)/backends/platform/ps2/systemps2.o \
- $(srcdir)/backends/platform/ps2/ps2mutex.o \
- $(srcdir)/backends/platform/ps2/ps2time.o \
- $(srcdir)/backends/platform/ps2/ps2debug.o
-
-MODULE_DIRS += .
+ $(srcdir)/backends/platform/ps2/Gs2dScreen.o \
+ $(srcdir)/backends/platform/ps2/irxboot.o \
+ $(srcdir)/backends/platform/ps2/ps2input.o \
+ $(srcdir)/backends/platform/ps2/ps2pad.o \
+ $(srcdir)/backends/platform/ps2/savefilemgr.o \
+ $(srcdir)/backends/platform/ps2/fileio.o \
+ $(srcdir)/backends/platform/ps2/asyncfio.o \
+ $(srcdir)/backends/platform/ps2/icon.o \
+ $(srcdir)/backends/platform/ps2/cd.o \
+ $(srcdir)/backends/platform/ps2/eecodyvdfs.o \
+ $(srcdir)/backends/platform/ps2/rpckbd.o \
+ $(srcdir)/backends/platform/ps2/systemps2.o \
+ $(srcdir)/backends/platform/ps2/ps2mutex.o \
+ $(srcdir)/backends/platform/ps2/ps2time.o \
+ $(srcdir)/backends/platform/ps2/ps2debug.o
+
+ifeq ($(DYNAMIC_MODULES),1)
+OBJS += $(srcdir)/backends/plugins/elf/elf-loader.o \
+ $(srcdir)/backends/plugins/elf/elf-provider.o \
+ $(srcdir)/backends/plugins/elf/shorts-segment-manager.o \
+ $(srcdir)/backends/plugins/elf/memory-manager.o \
+ $(srcdir)/backends/plugins/elf/mips-loader.o \
+ $(srcdir)/backends/plugins/elf/version.o
+endif
BACKEND := ps2
+# Include common Scummvm makefile
include $(srcdir)/Makefile.common
+LDFLAGS += -L$(PS2SDK)/ee/lib -L$(PS2SDK)/ports/lib
+ifeq ($(DYNAMIC_MODULES),1)
+LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/main_prog.ld
+else
LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -T $(PS2SDK)/ee/startup/linkfile
-LDFLAGS += -L $(PS2SDK)/ee/lib -L .
-LDFLAGS += $(addprefix -L$(PS2_EXTRA),$(PS2_EXTRA_LIBS))
-LDFLAGS += -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lmad -ltremor -lz -lm -lc -lfileXio -lkernel -lstdc++
-LDFLAGS += -s
+endif
all: $(TARGET)
$(TARGET): $(OBJS)
- $(LD) $^ $(LDFLAGS) -o $@
+ $(LD) $(PRE_OBJS_FLAGS) $(OBJS) $(POST_OBJS_FLAGS) $(LDFLAGS) $(LIBS) -o $@
diff --git a/backends/platform/ps2/Makefile.ps2.dev b/backends/platform/ps2/Makefile.ps2.dev
new file mode 100644
index 0000000000..cd9432e2df
--- /dev/null
+++ b/backends/platform/ps2/Makefile.ps2.dev
@@ -0,0 +1,170 @@
+# SCUMMVM-PS2 MakeFile
+
+
+# Use only this section to modify how the makefile behaves ------------
+
+# Scummvm engine config: choose which engines are enabled
+ENABLE_SCUMM = $(ENABLED)
+ENABLE_SCUMM_7_8 = 1
+# ENABLE_HE = 1
+ENABLE_SCI = $(ENABLED)
+# ENABLE_SCI32 = $(ENABLED)
+# ENABLE_SKY = $(ENABLED)
+# ENABLE_SWORD1 = $(ENABLED)
+# ENABLE_SWORD2 = $(ENABLED)
+
+# Set to 1 to enable seeing the commands to gcc
+VERBOSE_BUILD = 1
+# Set to 1 to enable, 0 to disable dynamic modules
+DYNAMIC_MODULES = 0
+# Set to 1 to enable debugging
+ENABLE_DEBUG = 0
+# Set to 1 to enable profiling
+ENABLE_PROFILING = 1
+# Set to 1 to disable HDD+NET
+DISABLE_NETWORK = 0
+# Set to 1 to enable, 0 to disable libmad and libogg
+USE_LIBMAD = 1
+USE_LIBOGG = 1
+
+# ---------------------------------------------------------------------
+
+
+# General variables
+srcdir = ../../..
+VPATH = $(srcdir)
+TARGET = scummvm.elf
+# PS2 SDK location variables
+# PS2SDK = /works/tools/devel/ps2/sdk
+
+# Check PS2SDK presence
+ifeq ($(PS2SDK),)
+$(error $$(PS2SDK) needs to be set.)
+endif
+
+# Variables for common Scummvm makefile
+CC = ee-gcc
+CXX = ee-g++
+FLAGS = -pedantic -Wall -W
+FLAGS += -Wcast-qual -Wconversion -Wpointer-arith -Wshadow -Wwrite-strings
+FLAGS += -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-unused-parameter
+CFLAGS = $(FLAGS) -std=c99
+CXXFLAGS = $(FLAGS) -Wnon-virtual-dtor -Wno-reorder -fno-exceptions -fno-rtti
+
+DEFINES = -D_EE -D__PLAYSTATION2__ -D__NEW_PS2SDK__ -DUSE_ZLIB -DFORCE_RTL -DDATA_PATH=\"host:data\"
+DEFINES += -DDISABLE_SAVEGAME_SORTING -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL -DDISABLE_SID -DDISABLE_NES_APU
+# DEFINES += -DLOGORRHEIC
+
+INCDIR := $(PS2SDK)/ee/include $(PS2SDK)/common/include $(PS2SDK)/ports/include . $(srcdir) $(srcdir)/engines
+INCLUDES := $(addprefix -I, $(INCDIR))
+DEPDIR = .deps
+MODULE_DIRS += ./
+MKDIR = mkdir -p
+RM = rm -f
+RM_REC = rm -rf
+AR = ee-ar cru
+RANLIB = ee-ranlib
+STRIP = ee-strip
+AS = ee-gcc
+LD = ee-gcc
+HAVE_GCC3 = true
+CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP
+
+# Variables for dynamic plugin building
+PLUGIN_PREFIX =
+PLUGIN_SUFFIX = .plg
+PLUGIN_EXTRA_DEPS = $(TARGET)
+PLUGIN_LDFLAGS = -nostartfiles $(srcdir)/backends/plugins/elf/version.o -Wl,-q,--just-symbols,$(TARGET),--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms
+PLUGIN_LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/plugin.ld -lstdc++ -lc
+
+# Test for adding different libs
+ifeq ($(USE_LIBMAD),1)
+DEFINES += -DUSE_MAD
+LIBS += -lmad
+endif
+ifeq ($(USE_LIBOGG), 1)
+DEFINES += -DUSE_VORBIS -DUSE_TREMOR
+LIBS += -ltremor
+endif
+
+# Test for dynamic plugins
+ifeq ($(DYNAMIC_MODULES),1)
+ENABLED = DYNAMIC_PLUGIN
+DEFINES += -DDYNAMIC_MODULES -DUSE_ELF_LOADER -DMIPS_TARGET -DUNCACHED_PLUGINS -DPLUGIN_DIRECTORY=\"host:plugins\"
+PRE_OBJS_FLAGS = -Wl,--whole-archive
+POST_OBJS_FLAGS = -Wl,--no-whole-archive
+else
+ENABLED = STATIC_PLUGIN
+endif
+
+# Test for debug
+ifeq ($(ENABLE_DEBUG),1)
+DEFINES += -D__PS2_DEBUG__
+FLAGS += -G2 -g
+LIBS += -lps2gdbStub -lps2ip -ldebug
+else
+DEFINES += -DRELEASE_BUILD
+FLAGS += -G2 -O2 -s -Wuninitialized
+# LDFLAGS += -s
+endif
+
+# Test for profiling
+ifeq ($(ENABLE_PROFILING),1)
+DEFINES += -DENABLE_PROFILING
+FLAGS += -G2 -pg -g
+LDFLAGS += -pg
+endif
+
+# Test for net support
+ifeq ($(DISABLE_NETWORK),1)
+DEFINES += -DNO_ADAPTOR
+endif
+
+# PS2 LIBS
+PS2LIBS = -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lz -lm -lc -lfileXio -lkernel -lstdc++
+
+# Add in PS2SDK includes and libraries.
+LIBS += $(PS2LIBS)
+
+OBJS := $(srcdir)/backends/platform/ps2/DmaPipe.o \
+ $(srcdir)/backends/platform/ps2/Gs2dScreen.o \
+ $(srcdir)/backends/platform/ps2/irxboot.o \
+ $(srcdir)/backends/platform/ps2/ps2input.o \
+ $(srcdir)/backends/platform/ps2/ps2pad.o \
+ $(srcdir)/backends/platform/ps2/savefilemgr.o \
+ $(srcdir)/backends/platform/ps2/fileio.o \
+ $(srcdir)/backends/platform/ps2/asyncfio.o \
+ $(srcdir)/backends/platform/ps2/icon.o \
+ $(srcdir)/backends/platform/ps2/cd.o \
+ $(srcdir)/backends/platform/ps2/eecodyvdfs.o \
+ $(srcdir)/backends/platform/ps2/rpckbd.o \
+ $(srcdir)/backends/platform/ps2/systemps2.o \
+ $(srcdir)/backends/platform/ps2/ps2mutex.o \
+ $(srcdir)/backends/platform/ps2/ps2time.o \
+ $(srcdir)/backends/platform/ps2/ps2debug.o
+
+ifeq ($(DYNAMIC_MODULES),1)
+OBJS += $(srcdir)/backends/plugins/elf/elf-loader.o \
+ $(srcdir)/backends/plugins/elf/elf-provider.o \
+ $(srcdir)/backends/plugins/elf/shorts-segment-manager.o \
+ $(srcdir)/backends/plugins/elf/memory-manager.o \
+ $(srcdir)/backends/plugins/elf/mips-loader.o \
+ $(srcdir)/backends/plugins/elf/version.o
+endif
+
+BACKEND := ps2
+
+# Include common Scummvm makefile
+include $(srcdir)/Makefile.common
+
+LDFLAGS += -L$(PS2SDK)/ee/lib -L$(PS2SDK)/ports/lib
+ifeq ($(DYNAMIC_MODULES),1)
+LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/main_prog.ld
+else
+LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -T $(PS2SDK)/ee/startup/linkfile
+endif
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS)
+ $(LD) $(PRE_OBJS_FLAGS) $(OBJS) $(POST_OBJS_FLAGS) $(LDFLAGS) $(LIBS) -o $@
diff --git a/backends/platform/ps2/README.PS2 b/backends/platform/ps2/README.PS2
new file mode 100644
index 0000000000..141a79eaca
--- /dev/null
+++ b/backends/platform/ps2/README.PS2
@@ -0,0 +1,189 @@
+Dear PS2 ScummVM enthusiast user,
+
+here you will find the latest and the greatest PS2 backend ever!
+
+
+ *** Release Notes ***
+
+Released 2 builds: SCUMMVM.ELF and SCUMMVM-S.ELF. The latter has engine
+modules statically linked into (that's what the "-S" is for), the former
+uses dynamic modules (uncached). The dynamic one is much faster to start
+and has more resources available for the games. The catch is that games
+detection, when you are adding a new one, is painstakingly slow...
+(as it needs to load, test, unload the plugins one by one).
+
+Until we have an optimization for that in place I would suggest you add
+new games with "SCUMMVM-S.ELF", and when you are done adding you then
+play them with "SCUMMVM.ELF", as this will give you the best of both.
+
+We no longer have a separate ELF build with hdd & net adapter disabled,
+as we now do it in the smart way, allowing users to disable it in their
+ScummVM.ini. See under in "Configuration" for details.
+
+We also have an improved Makefile.ps2 in ps2 folder which will allow
+you to create: static, dynamic, profile and debug build version.
+
+You can now also cleanly compile using "configure" and specifying:
+
+./configure --backend=ps2 --host=ps2 ...
+
+
+ *** Installation ***
+
+Some media drivers require all capitalized letter, so to be on the
+safe side store the files (SCUMMVM.ELF and *.IRX) in upper case.
+
+Here comes a full list of the required *.IRX (don't worry they are all
+provided pre-compiled in the binary release ;-)
+
+ IOMANX.IRX
+ FILEXIO.IRX
+ CODYVDFS.IRX
+ SJPCM.IRX
+ USBD.IRX
+ USB_MASS.IRX
+ PS2MOUSE.IRX
+ RPCKBD.IRX
+ POWEROFF.IRX
+ PS2DEV9.IRX
+ PS2ATAD.IRX
+ PS2HDD.IRX
+ PS2FS.IRX
+ PS2IP.IRX
+ PS2SMAP.IRX
+ PS2HOST.IRX
+
+Make sure they are all stored in the folder that contains your SCUMMVM.ELF!
+
+If you are starting ScummVM from CD/DVD then it will look for ScummVM.ini
+a ScummVM.ini on the media folder from where you started SCUMMVM.ELF.
+
+Notes:
+
+ - depending on the media you install Scummvm/PS2 onto, it might be
+ picky about files cases, so I'd leave those *.IRX uppercase and
+ scummmodern.zip lower ;0)
+
+ - make sure you selected a save path before you start playing!
+
+ - we added PS2IPS.IRX in case you wanted to test a debug build
+ (use Makefile.gdb)
+
+
+ *** Configuration ***
+
+There is now a [PlayStation2] section in ScummVM.ini which can be used
+to make your wildest dreams come true ;-)
+
+It accepts these entries:
+
+tv_mode = [pal] [ntsc]
+gfx_mode = [mode number] [*]
+hdd_part = [partition name] [disable]
+net_addr = [PS2 IP addr] [**]
+usb_mass = [0] [disable]
+
+[*] Currently supported gfx modes are:
+
+ # 1 -> SDTV progressive (NTSC: 224p / PAL: 256p)
+ # 2 -> SDTV interlaced (NTSC: 448i / PAL: 512i) <- default
+ # 3 -> EDTV progressive (NTSC: 480p / PAL: 576p)
+ # 6 -> VESA (640x480@60)
+
+If no tv_mode is specified it will be autodected based on PS2 model.
+
+The non-interlaced (progressive) modes look much better and sharper.
+You can check the difference starting COMI and choosing About from
+the GMM (press "start" then choose "about"). You can easily see the
+difference between progressive and interlaced in scrolling text.
+
+You can use mode 6 (VGA 640x480) if you are connecting your PS2 to
+a RGB monitor. Some TVs also supports this signal.
+
+We also do some bad-ass things, like detecting the BIOS version and
+setting the GS registers by hand, for console models where a mode
+is not supported ;-)
+
+If SCUMMVM.ELF hangs at start for you try disabling the adapter by
+setting in ScummVM.ini
+
+hdd_part = 0
+net_addr = 0
+
+You can now also choose the hdd partition used for ScummVM games
+(default "+ScummVM") passing it as an argument to hdd_part:
+
+hdd_part = MyPartition (witout the "+")
+
+If you have an adapter with hdd & net, but you don't use them you
+can just set both to 0 to disable, and have a leaner and meaner
+ScummVM booting much faster!
+
+[**] TODO
+
+ *** Remote ***
+
+You will need "PS2IP.IRX", "PS2SMAP.IRX" and "PS2HOST.IRX" drivers too
+in the folder where you are starting SCUMMVM.ELF if you want to use
+the remote capability.
+
+The IP 192.168.1.20 (ps2link default) is hardcoded in the source as
+"netArg" in irxboot.cpp, feel free to modify it to match your network
+configuration.
+
+In a future release you will be able to set in ScummVM.ini using
+
+net_addr = xxx.yyy.zzz.www
+
+If you are starting SCUMMVM.ELF over the net using ps2client then you
+are already set. If you are starting it in any other way, then you
+will have to "export" the folder where you are storing ScummVM games
+and data by starting ps2client from inside that folder. Eg. from a
+terminal:
+
+> ./ps2client -h [your ps2 ip] listen
+
+Do this -after- ScummVM is up and running otherwise it will fail to
+establish a connection.
+
+
+ *** Gamepad ***
+
+The mapping is:
+
+Start Button - GMM
+R1 - 'y'
+L1 - 'n'
+R2 - '.'
+L2 - Numpad 0
+Triangle - Escape
+Square - Enter
+Cross - Left mouse button
+Circle - Right mouse button
+
+
+ *** Bugs ***
+
+Though we made our best to make this release as bug free as possible
+there are still a few bugs left:
+
+ - file handling speed : (not really a bug, but a nuisance) : there
+ is probably space for some more optimization in the current file
+ management. The only case when it really bogs me it's when you
+ try to select a saved game and there is some lag.
+
+ Some game will start faster too when this is optimized.
+
+ - feel free to add your bug, suggestion, secret wish to this list!
+
+ - SCI games have smooth audio and intro, but moving the pointer
+ and in-game animation speed might be a challenge.
+
+ - it has been reported USB media greater than 8 GB might not work
+
+Now enough reading, rush to your PlayStation2 and start playing!
+
+Are you still reading?
+
+Have a lot of fun,
+ -Max Lingua
diff --git a/backends/platform/ps2/asyncfio.cpp b/backends/platform/ps2/asyncfio.cpp
index b49fcbca75..6f15dcc628 100644
--- a/backends/platform/ps2/asyncfio.cpp
+++ b/backends/platform/ps2/asyncfio.cpp
@@ -33,7 +33,7 @@
AsyncFio::AsyncFio(void) {
_runningOp = NULL;
- memset((int *)_ioSlots, 0, MAX_HANDLES * sizeof(int));
+ memset(const_cast<int *>(_ioSlots), 0, MAX_HANDLES * sizeof(int));
ee_sema_t newSema;
newSema.init_count = 1;
newSema.max_count = 1;
@@ -63,7 +63,7 @@ int AsyncFio::open(const char *name, int ioMode, int mode) {
fileXioWaitAsync(FXIO_WAIT, &res);
SignalSema(_ioSema);
// dbg_printf("FIO: open ext(%s, %d, %d) => %d", name, ioMode, mode, res);
- return res;
+ return res;
}
void AsyncFio::close(int handle) {
@@ -80,7 +80,7 @@ void AsyncFio::close(int handle) {
void AsyncFio::checkSync(void) {
if (_runningOp) {
- fileXioWaitAsync(FXIO_WAIT, (int *)_runningOp);
+ fileXioWaitAsync(FXIO_WAIT, const_cast<int *>(_runningOp));
_runningOp = NULL;
}
}
@@ -90,7 +90,7 @@ void AsyncFio::read(int fd, void *dest, unsigned int len) {
checkSync();
assert(fd < MAX_HANDLES);
_runningOp = _ioSlots + fd;
- fileXioRead(fd, (unsigned char*)dest, len);
+ fileXioRead(fd, (unsigned char *)dest, len);
SignalSema(_ioSema);
}
@@ -99,7 +99,7 @@ void AsyncFio::write(int fd, const void *src, unsigned int len) {
checkSync();
assert(fd < MAX_HANDLES);
_runningOp = _ioSlots + fd;
- fileXioWrite(fd, (unsigned char*)src, len);
+ fileXioWrite(fd, (unsigned char *)const_cast<void *>(src), len);
SignalSema(_ioSema);
}
@@ -210,7 +210,7 @@ bool AsyncFio::poll(int fd) {
bool retVal = false;
if (PollSema(_ioSema) >= 0) {
if (_runningOp == _ioSlots + fd) {
- if (fileXioWaitAsync(FXIO_NOWAIT, (int *)_runningOp) == FXIO_COMPLETE) {
+ if (fileXioWaitAsync(FXIO_NOWAIT, const_cast<int *>(_runningOp)) == FXIO_COMPLETE) {
_runningOp = NULL;
retVal = true;
} else
@@ -226,7 +226,7 @@ bool AsyncFio::fioAvail(void) {
bool retVal = false;
if (PollSema(_ioSema) > 0) {
if (_runningOp) {
- if (fileXioWaitAsync(FXIO_NOWAIT, (int *)_runningOp) == FXIO_COMPLETE) {
+ if (fileXioWaitAsync(FXIO_NOWAIT, const_cast<int *>(_runningOp)) == FXIO_COMPLETE) {
_runningOp = NULL;
retVal = true;
} else
diff --git a/backends/platform/ps2/asyncfio.h b/backends/platform/ps2/asyncfio.h
index 2e39c8667c..6f84742da0 100644
--- a/backends/platform/ps2/asyncfio.h
+++ b/backends/platform/ps2/asyncfio.h
@@ -23,6 +23,9 @@
#define MAX_HANDLES 32
#include <sys/stat.h>
+#undef chdir // we define our own
+#undef mkdir
+
class AsyncFio {
public:
AsyncFio(void);
diff --git a/backends/platform/ps2/cd.c b/backends/platform/ps2/cd.c
index cd44b3d034..e08437d34f 100644
--- a/backends/platform/ps2/cd.c
+++ b/backends/platform/ps2/cd.c
@@ -19,35 +19,35 @@ int cdvdInitialised = 0;
void cdvdExit(void)
{
- cdvdInitialised = 0;
+ cdvdInitialised = 0;
}
int cdvdInit(int mode)
{
int i=0,len=0,ret=0;
- u8 *pkt;
-
- cdvdCd.server = NULL;
-
- do {
- if ((ret = SifBindRpc(&cdvdCd, CDVD_INIT_BIND_RPC, 0)) < 0) {
- return -1;
- }
- if (!cdvdCd.server) {
- nopdelay();
- }
- }
+ u8 *pkt;
+
+ cdvdCd.server = NULL;
+
+ do {
+ if ((ret = SifBindRpc(&cdvdCd, (signed)CDVD_INIT_BIND_RPC, 0)) < 0) {
+ return -1;
+ }
+ if (!cdvdCd.server) {
+ nopdelay();
+ }
+ }
while(!cdvdCd.server);
- pkt = sendBuffer;
- PUSHDATA( int, pkt, mode, i);
- pkt += i; len += i;
+ pkt = (unsigned char *)sendBuffer;
+ PUSHDATA(int, pkt, mode, i);
+ pkt += i; len += i;
if ((ret = SifCallRpc(&cdvdCd, 0, 0, sendBuffer, len, NULL, 0, 0, 0)) < 0)
- return -1;
+ return -1;
- cdvdInitialised = 1;
+ cdvdInitialised = 1;
- return 0;
+ return 0;
}
diff --git a/backends/platform/ps2/eecodyvdfs.h b/backends/platform/ps2/eecodyvdfs.h
index ac080873e1..f439c42125 100644
--- a/backends/platform/ps2/eecodyvdfs.h
+++ b/backends/platform/ps2/eecodyvdfs.h
@@ -40,7 +40,7 @@ struct CdClock {
#ifdef __cplusplus
extern "C" {
#endif
- int initCdvdFs(void);
+ int initCdvdFs(void);
void readRTC(struct CdClock *dest);
int driveStop(void);
int driveStandby(void);
diff --git a/backends/platform/ps2/fileio.cpp b/backends/platform/ps2/fileio.cpp
index 411e20d3bc..205a688438 100644
--- a/backends/platform/ps2/fileio.cpp
+++ b/backends/platform/ps2/fileio.cpp
@@ -20,8 +20,9 @@
*
*/
-// Disable symbol overrides so that we can use system headers.
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+// Disable symbol overrides so that we can use "FILE"
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
#include "backends/platform/ps2/fileio.h"
@@ -78,12 +79,12 @@ Ps2File::~Ps2File() {
fio.seek(_fd, 0, SEEK_SET);
fio.write(_fd, _cacheBuf, _filePos);
w = fio.sync(_fd);
- printf("flushed wbuf: %x of %x\n", w, _filePos);
+ dbg_printf("flushed wbuf: %x of %x\n", w, _filePos);
}
fio.close(_fd);
uint32 r = fio.sync(_fd);
- printf("close [%d] - sync'd = %d\n", _fd, r);
+ dbg_printf("close [%d] - sync'd = %d\n", _fd, r);
}
free(_cacheBuf);
@@ -97,7 +98,7 @@ bool Ps2File::open(const char *name, int mode) {
#if 1
_fd = fio.open(name, mode);
- printf("open %s [%d]\n", name, _fd);
+ dbg_printf("open %s [%d]\n", name, _fd);
if (_fd >= 0) {
_mode = mode;
@@ -110,9 +111,9 @@ bool Ps2File::open(const char *name, int mode) {
else
_fileSize = 0;
- printf(" _mode = %x\n", _mode);
- printf(" _fileSize = %d\n", _fileSize);
- // printf(" _filePos = %d\n", _filePos);
+ dbg_printf(" _mode = %x\n", _mode);
+ dbg_printf(" _fileSize = %d\n", _fileSize);
+ // dbg_printf(" _filePos = %d\n", _filePos);
return true;
}
@@ -130,7 +131,7 @@ bool Ps2File::open(const char *name, int mode) {
if (_fileSize && mode != O_RDONLY) {
fio.read(_fd, _cacheBuf, _fileSize);
r = fio.sync(_fd);
- printf(" sz=%d, read=%d\n", _fileSize, r);
+ dbg_printf(" sz=%d, read=%d\n", _fileSize, r);
assert(r == _fileSize);
}
@@ -141,7 +142,7 @@ bool Ps2File::open(const char *name, int mode) {
_fd = fio.open(name, mode);
- printf("open %s [%d]\n", name, _fd);
+ dbg_printf("open %s [%d]\n", name, _fd);
if (_fd >= 0) {
_mode = mode;
@@ -160,16 +161,16 @@ bool Ps2File::open(const char *name, int mode) {
if (mode != O_RDONLY) {
fio.read(_fd, _cacheBuf, _fileSize);
r = fio.sync(_fd);
- printf(" sz=%d, read=%d\n", _fileSize, r);
+ dbg_printf(" sz=%d, read=%d\n", _fileSize, r);
assert(r == _fileSize);
// _fileSize = fio.seek(_fd, 0, SEEK_END);
}
#endif
}
- printf(" _mode = %x\n", _mode);
- printf(" _fileSize = %d\n", _fileSize);
- printf(" _filePos = %d\n", _filePos);
+ dbg_printf(" _mode = %x\n", _mode);
+ dbg_printf(" _fileSize = %d\n", _fileSize);
+ dbg_printf(" _filePos = %d\n", _filePos);
return true;
} else
@@ -208,7 +209,7 @@ bool Ps2File::eof() {
#ifdef __PS2_FILE_SEMA__
SignalSema(_sema);
- // printf(" EOF [%d] : %d of %d -> %d\n", _fd, _filePos, _fileSize, res);
+ // dbg_printf(" EOF [%d] : %d of %d -> %d\n", _fd, _filePos, _fileSize, res);
#endif
return res;
}
@@ -255,8 +256,8 @@ int Ps2File::seek(int32 offset, int origin) {
_eof = true;
}
- // printf("seek [%d] %d %d\n", _fd, offset, origin);
- // printf(" res = %d\n", res);
+ // dbg_printf("seek [%d] %d %d\n", _fd, offset, origin);
+ // dbg_printf(" res = %d\n", res);
#ifdef __PS2_FILE_SEMA__
SignalSema(_sema);
@@ -338,8 +339,8 @@ uint32 Ps2File::read(void *dest, uint32 len) {
#endif
#ifdef __PS2_FILE_DEBUG__
- printf("read (1) : _filePos = %d\n", _filePos);
- printf("read (1) : _cachePos = %d\n", _cachePos);
+ dbg_printf("read (1) : _filePos = %d\n", _filePos);
+ dbg_printf("read (1) : _cachePos = %d\n", _cachePos);
#endif
if (len == 0) {
@@ -409,7 +410,10 @@ uint32 Ps2File::read(void *dest, uint32 len) {
break; // EOF
}
}
+#ifndef ENABLE_PROFILING
+ // doesn't play nice with -pg
cacheReadAhead();
+#endif
#ifdef __PS2_FILE_SEMA__
SignalSema(_sema);
#endif
@@ -473,7 +477,7 @@ uint32 PS2FileStream::write(const void *ptr, uint32 len) {
}
bool PS2FileStream::flush() {
- // printf("flush not implemented\n");
+ // dbg_printf("flush not implemented\n");
return true;
}
@@ -481,7 +485,7 @@ bool PS2FileStream::err() const {
bool errVal = _handle->getErr();
if (errVal) {
- printf("ferror -> %d\n", errVal);
+ dbg_printf("ferror -> %d\n", errVal);
}
return errVal;
@@ -501,7 +505,7 @@ FILE *ps2_fopen(const char *fname, const char *mode) {
Ps2File *file = new Ps2File();
int _mode = O_RDONLY;
- printf("fopen(%s, %s)\n", fname, mode);
+ dbg_printf("fopen(%s, %s)\n", fname, mode);
if (mode[0] == 'r' && mode [1] == 'w')
_mode = O_RDWR;
diff --git a/backends/platform/ps2/fileio.h b/backends/platform/ps2/fileio.h
index 27245dc9c9..16eb7f212a 100644
--- a/backends/platform/ps2/fileio.h
+++ b/backends/platform/ps2/fileio.h
@@ -30,13 +30,13 @@
#include "common/stream.h"
enum {
- CACHE_SIZE = 2048 * 32,
- MAX_READ_STEP = 2048 * 16,
- MAX_CACHED_FILES = 6,
- CACHE_READ_THRESHOLD = 16 * 2048,
- CACHE_FILL_MIN = 2048 * 24,
- READ_ALIGN = 64, // align all reads to the size of an EE cache line
- READ_ALIGN_MASK = READ_ALIGN - 1
+ CACHE_SIZE = 2048 * 32,
+ MAX_READ_STEP = 2048 * 16,
+ MAX_CACHED_FILES = 6,
+ CACHE_READ_THRESHOLD = 16 * 2048,
+ CACHE_FILL_MIN = 2048 * 24,
+ READ_ALIGN = 64, // align all reads to the size of an EE cache line
+ READ_ALIGN_MASK = READ_ALIGN - 1
};
// TODO: Make this a subclass of SeekableReadStream & WriteStream
diff --git a/backends/platform/ps2/icon.cpp b/backends/platform/ps2/icon.cpp
index df6a165cd4..9319d9f4d9 100644
--- a/backends/platform/ps2/icon.cpp
+++ b/backends/platform/ps2/icon.cpp
@@ -937,7 +937,7 @@ uint16 PS2Icon::decompressData(uint16 **data) {
uint16 inPos = 1;
const uint16 *rleData = (const uint16 *)_rleIcoData;
uint16 resSize = rleData[0];
- uint16 *resData = (uint16 *)malloc(resSize * sizeof(uint16));
+ uint16 *resData = (uint16 *)memalign(64, resSize * sizeof(uint16));
uint16 outPos = 0;
while (outPos < resSize) {
diff --git a/backends/platform/ps2/iop/CoDyVDfs/common/codyvdirx.h b/backends/platform/ps2/iop/CoDyVDfs/common/codyvdirx.h
index 81ef7cb6d0..6ac5a0bb65 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/common/codyvdirx.h
+++ b/backends/platform/ps2/iop/CoDyVDfs/common/codyvdirx.h
@@ -26,13 +26,13 @@
#define CDVDFS_IRX_ID 0xD004352
// commands:
-#define READ_RTC 0
-#define SET_READ_SPEED 1
-#define DRIVE_STOP 2
-#define DRIVE_STANDBY 3
+#define READ_RTC 0
+#define SET_READ_SPEED 1
+#define DRIVE_STOP 2
+#define DRIVE_STANDBY 3
-#define CdTrayOpen 0
-#define CdTrayClose 1
-#define CdTrayCheck 2
+#define CdTrayOpen 0
+#define CdTrayClose 1
+#define CdTrayCheck 2
#endif // CDVDFS_COMMON_H
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h b/backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h
index ae4fd44ce5..d9bd5287c6 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h
@@ -39,24 +39,24 @@ typedef struct {
} ISOPathTableRecord __attribute__ ((packed));
typedef struct {
- uint8 year; // Number of years since 1900
- uint8 month; // Month of the year from 1 to 12
- uint8 day; // Day of the Month from 1 to 31
- uint8 hour; // Hour of the day from 0 to 23
- uint8 min; // Minute of the hour from 0 to 59
- uint8 sec; // second of the minute from 0 to 59
- uint8 gmtOff; // Offset from Greenwich Mean Time in number of 15 minute intervals from -48(West) to +52(East)
+ uint8 year; // Number of years since 1900
+ uint8 month; // Month of the year from 1 to 12
+ uint8 day; // Day of the Month from 1 to 31
+ uint8 hour; // Hour of the day from 0 to 23
+ uint8 min; // Minute of the hour from 0 to 59
+ uint8 sec; // second of the minute from 0 to 59
+ uint8 gmtOff; // Offset from Greenwich Mean Time in number of 15 minute intervals from -48(West) to +52(East)
uint8 padding[10];
} ISOTime __attribute__ ((packed));
typedef struct {
- uint8 year; // Number of years since 1900
- uint8 month; // Month of the year from 1 to 12
- uint8 day; // Day of the Month from 1 to 31
- uint8 hour; // Hour of the day from 0 to 23
- uint8 min; // Minute of the hour from 0 to 59
- uint8 sec; // second of the minute from 0 to 59
- uint8 gmtOff; // Offset from Greenwich Mean Time in number of 15 minute intervals from -48(West) to +52(East)
+ uint8 year; // Number of years since 1900
+ uint8 month; // Month of the year from 1 to 12
+ uint8 day; // Day of the Month from 1 to 31
+ uint8 hour; // Hour of the day from 0 to 23
+ uint8 min; // Minute of the hour from 0 to 59
+ uint8 sec; // second of the minute from 0 to 59
+ uint8 gmtOff; // Offset from Greenwich Mean Time in number of 15 minute intervals from -48(West) to +52(East)
//uint8 padding[10];
} ISOFileTime __attribute__ ((packed));
@@ -96,38 +96,38 @@ typedef struct {
uint8 reserved[6];
uint8 reserved2;
uint8 reserved3;
-} ISORoot __attribute__((packed)); // 0x22
+} ISORoot __attribute__((packed)); // 0x22
typedef struct {
- uint8 type; // 0x00
- char identifier[5]; // 0x01
- uint8 version; // 0x06
- uint8 reserved1; // 0x07
- char systemIdentifier[32]; // 0x08
+ uint8 type; // 0x00
+ char identifier[5]; // 0x01
+ uint8 version; // 0x06
+ uint8 reserved1; // 0x07
+ char systemIdentifier[32]; // 0x08
char volumeIdentifier[32]; // 0x28
- uint8 reserved2[8]; // 0x48
- uint32 volumeSpaceSize; // 0x50
- uint32 volumeSpaceSizeBE; // 0x54
- char reserved3[32]; // 0x58
- uint32 volumeSetSize; // 0x78
- uint32 volumeSequenceNumber; // 0x7C
- uint32 logicalBlockSize; // 0x80
- uint32 pathTableSize; // 0x84
- uint32 pathTableSizeBE; // 0x88
- uint32 pathTablePos; // 0x8C
- uint32 pathTable2Pos; // 0x90
- uint32 pathTablePosBE; // 0x94
- uint32 pathTable2PosBE; // 0x98
- ISORoot rootDir; // 0x9C
- ISOIds ids; // 0xBE
- ISOTime creation; // 0x32D
- ISOTime modification; // 0x33E
- ISOTime expiration; // 0x34F
- ISOTime effective; // 0x360
- uint8 fileStructureVersion; // 0x371
- uint8 reserved4; // 0x372
- uint8 applicationUse[512]; // 0x373
- uint8 reserved5[653]; // 0x573
-} ISOPvd __attribute__ ((packed)); // 0x800
+ uint8 reserved2[8]; // 0x48
+ uint32 volumeSpaceSize; // 0x50
+ uint32 volumeSpaceSizeBE; // 0x54
+ char reserved3[32]; // 0x58
+ uint32 volumeSetSize; // 0x78
+ uint32 volumeSequenceNumber; // 0x7C
+ uint32 logicalBlockSize; // 0x80
+ uint32 pathTableSize; // 0x84
+ uint32 pathTableSizeBE; // 0x88
+ uint32 pathTablePos; // 0x8C
+ uint32 pathTable2Pos; // 0x90
+ uint32 pathTablePosBE; // 0x94
+ uint32 pathTable2PosBE; // 0x98
+ ISORoot rootDir; // 0x9C
+ ISOIds ids; // 0xBE
+ ISOTime creation; // 0x32D
+ ISOTime modification; // 0x33E
+ ISOTime expiration; // 0x34F
+ ISOTime effective; // 0x360
+ uint8 fileStructureVersion; // 0x371
+ uint8 reserved4; // 0x372
+ uint8 applicationUse[512]; // 0x373
+ uint8 reserved5[653]; // 0x573
+} ISOPvd __attribute__ ((packed)); // 0x800
#endif // __CDTYPES_H__
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
index e55e62853b..2a94560843 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
@@ -59,7 +59,7 @@ int verifyDriveReady(void) {
return -1; // drive still not ready
}
}
- if (mediaType == DISC_NONE)
+ if (mediaType == DISC_NONE)
return -1;
return 0;
}
@@ -72,14 +72,14 @@ int cacheEnterDir(ISODirectoryRecord *dir) {
cachedDirOfs = 0;
cacheName = cachedDir + strlen(cachedDir);
memcpy(cacheName, dir->name, dir->len_fi);
- cacheName[dir->len_fi] = '/';
+ cacheName[dir->len_fi] = '/';
cacheName[dir->len_fi + 1] = '\0';
return cdReadSectors(cachedDirLba, 1, cacheBuf, &rmode);
}
int initRootCache(void) {
CdRMode rmode = { 16, 0, CdSect2048, 0 };
- ISODirectoryRecord *root = (ISODirectoryRecord*)cacheBuf;
+ ISODirectoryRecord *root = (ISODirectoryRecord *)cacheBuf;
if (cdReadSectors(fsRootLba, 1, cacheBuf, &rmode) == 0) {
cachedDir[0] = '\0';
@@ -104,10 +104,10 @@ ISODirectoryRecord *findEntryInCache(const char *name, int nameLen) {
if (i != cachedDirOfs) {
if (cdReadSectors(cachedDirLba + i, 1, cacheBuf, &rmode) < 0)
return NULL;
- cachedDirOfs = i;
+ cachedDirOfs = i;
}
- while (entry->len_dr && ((uint8*)entry < cacheBuf + SECTOR_SIZE)) {
+ while (entry->len_dr && ((uint8 *)entry < cacheBuf + SECTOR_SIZE)) {
if ((entry->len_fi > 2) && (entry->name[entry->len_fi - 2] == ';') && (entry->name[entry->len_fi - 1] == '1')) {
if ((nameLen == entry->len_fi - 2) && (strnicmp(name, entry->name, entry->len_fi - 2) == 0))
return entry;
@@ -115,10 +115,10 @@ ISODirectoryRecord *findEntryInCache(const char *name, int nameLen) {
if ((nameLen == entry->len_fi) && (strnicmp(name, entry->name, entry->len_fi) == 0))
return entry;
}
- entry = (ISODirectoryRecord *)( (uint8*)entry + entry->len_dr );
+ entry = (ISODirectoryRecord *)( (uint8 *)entry + entry->len_dr );
}
}
- return NULL;
+ return NULL;
}
ISODirectoryRecord *findPath(const char *path) {
@@ -225,12 +225,12 @@ int initDisc(void) {
case 1:
discType = DISC_MODE1;
printf("Disc: Mode1\n");
- pvd = (ISOPvd*)(cacheBuf + 4);
+ pvd = (ISOPvd *)(cacheBuf + 4);
break;
case 2:
discType = DISC_MODE2;
printf("Disc: Mode2\n");
- pvd = (ISOPvd*)(cacheBuf + 12);
+ pvd = (ISOPvd *)(cacheBuf + 12);
break;
default:
DBG_PRINTF("Unknown Sector Type %02X\n", cacheBuf[3]);
@@ -257,7 +257,7 @@ int initDisc(void) {
mediaType = discType;
DBG_PRINTF("Root directory in sector %d\n", fsRootLba);
- return initRootCache();
+ return initRootCache();
}
}
}
@@ -290,46 +290,46 @@ int cd_init(iop_device_t *dev) {
}
iop_device_ops_t FS_ops = {
- (void *) cd_init,
- (void *) cd_dummy,
- (void *) cd_dummy,
- (void *) cd_open,
- (void *) cd_close,
- (void *) cd_read,
- (void *) cd_dummy,
- (void *) cd_lseek,
- (void *) cd_dummy,
- (void *) cd_dummy,
- (void *) cd_dummy,
- (void *) cd_dummy,
- (void *) cd_dopen,
- (void *) cd_dclose,
- (void *) cd_dread,
- (void *) cd_dummy,
- (void *) cd_dummy,
+ (void *) cd_init,
+ (void *) cd_dummy,
+ (void *) cd_dummy,
+ (void *) cd_open,
+ (void *) cd_close,
+ (void *) cd_read,
+ (void *) cd_dummy,
+ (void *) cd_lseek,
+ (void *) cd_dummy,
+ (void *) cd_dummy,
+ (void *) cd_dummy,
+ (void *) cd_dummy,
+ (void *) cd_dopen,
+ (void *) cd_dclose,
+ (void *) cd_dread,
+ (void *) cd_dummy,
+ (void *) cd_dummy,
};
#define FS_NAME "cdfs"
#define FS_DESC "CD-ROM"
iop_device_t fsdriver = {
- FS_NAME,
- IOP_DT_FS | IOP_DT_FSEXT,
- 1,
- FS_DESC,
- &FS_ops
+ FS_NAME,
+ IOP_DT_FS | IOP_DT_FSEXT,
+ 1,
+ FS_DESC,
+ &FS_ops
};
int _start(void) {
- printf("CoDyVDfs v0.01\n");
+ printf("CoDyVDfs v0.01\n");
CdInit(1);
- DelDrv(FS_NAME);
- AddDrv(&fsdriver);
+ DelDrv(FS_NAME);
+ AddDrv(&fsdriver);
initRpc();
initFio();
- return(0);
+ return(0);
}
int strnicmp(const char *s1, const char *s2, int n) {
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h
index d50e89e4f3..cc903ea841 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h
@@ -51,20 +51,20 @@ enum ReadModes {
};
enum {
- CdDiskNone = 0x00,
- CdDiskDetect, // 0x01
- CdDiskDetectCD, // 0x02
- CdDiskDetectDVD, // 0x03
- CdDiskDetectUnk = 0x05,
- CdDiskCDPS1 = 0x10,
- CdDiskCDDAPS1 = 0x11,
- CdDiskCDPS2 = 0x12,
- CdDiskCDDAPS2 = 0x13,
- CdDiskDVDPS2 = 0x14,
- CdDiskDVDV2 = 0xFC,
- CdDiskCDDA = 0xFD,
- CdDiskDVDV = 0xFE,
- CdDiskIllegal = 0xFF
+ CdDiskNone = 0x00,
+ CdDiskDetect, // 0x01
+ CdDiskDetectCD, // 0x02
+ CdDiskDetectDVD, // 0x03
+ CdDiskDetectUnk = 0x05,
+ CdDiskCDPS1 = 0x10,
+ CdDiskCDDAPS1 = 0x11,
+ CdDiskCDPS2 = 0x12,
+ CdDiskCDDAPS2 = 0x13,
+ CdDiskDVDPS2 = 0x14,
+ CdDiskDVDV2 = 0xFC,
+ CdDiskCDDA = 0xFD,
+ CdDiskDVDV = 0xFE,
+ CdDiskIllegal = 0xFF
};
#define DISC_NOT_READY(type) ((type > CdDiskNone) && (type < CdDiskCDPS1) && (type != CdDiskDetectUnk))
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
index f0a06f927b..611211a715 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
@@ -104,7 +104,7 @@ int cd_open(iop_file_t *handle, const char *name, int mode) {
fd->pos = 0;
fd->cachedLba = 0;
- handle->privdata = (void*)fdSlot;
+ handle->privdata = (void *)fdSlot;
return 0;
}
@@ -135,7 +135,7 @@ int cd_read(iop_file_t *handle, void *dest, int length) {
FioHandle *fd = fioHandles + (int)handle->privdata;
CdRMode rmode = { 16, 0, CdSect2048, 0 };
int readLba, readPos, bytesLeft;
- uint8 *destPos = (uint8*)dest;
+ uint8 *destPos = (uint8 *)dest;
int doCopy;
int numLba;
readLba = fd->lba + (fd->pos >> 11);
@@ -171,13 +171,13 @@ int cd_read(iop_file_t *handle, void *dest, int length) {
numLba = bytesLeft >> 11;
if (cdReadSectors(readLba, numLba, destPos, &rmode) != 0)
break;
- readLba += numLba;
+ readLba += numLba;
fd->pos += numLba << 11;
destPos += numLba << 11;
bytesLeft &= 0x7FF;
}
}
- return destPos - (uint8*)dest;
+ return destPos - (uint8 *)dest;
}
int cd_close(iop_file_t *handle) {
@@ -219,7 +219,7 @@ int cd_dopen(iop_file_t *handle, const char *path) {
}
dioHandles[fdSlot].curOfs = 0;
dioHandles[fdSlot].lbaOfs = 0;
- handle->privdata = (void*)fdSlot;
+ handle->privdata = (void *)fdSlot;
return fdSlot;
}
@@ -252,7 +252,7 @@ int cd_dread(iop_file_t *handle, iox_dirent_t *buf) {
}
}
}
- return 0;
+ return 0;
}
int cd_dclose(iop_file_t *handle) {
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
index 5b760faa06..983ae38716 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
@@ -69,11 +69,11 @@ void *rpcReadClock(void *data) {
void *driveStop(void *data) {
if (CdStop() == 1) {
if (CdSync(0) == 0) {
- *(int*)data = CdGetError();
+ *(int *)data = CdGetError();
} else
- *(int*)data = -0x100;
+ *(int *)data = -0x100;
} else
- *(int*)data = -0x101;
+ *(int *)data = -0x101;
return data;
}
@@ -81,11 +81,11 @@ void *driveStandby(void *data) {
int type;
if (CdStandby() == 1) {
if (CdSync(0) == 0) {
- *(int*)data = CdGetError();
+ *(int *)data = CdGetError();
} else
- *(int*)data = -0x100;
+ *(int *)data = -0x100;
} else
- *(int*)data = -0x101;
+ *(int *)data = -0x101;
do { // wait until drive detected disc type
type = CdGetDiskType();
diff --git a/backends/platform/ps2/iop/rpckbd/include/ps2kbd.h b/backends/platform/ps2/iop/rpckbd/include/ps2kbd.h
index 07d9c3d7f9..6bef7caefa 100644
--- a/backends/platform/ps2/iop/rpckbd/include/ps2kbd.h
+++ b/backends/platform/ps2/iop/rpckbd/include/ps2kbd.h
@@ -87,8 +87,8 @@ typedef struct _kbd_keymap
#define KBD_RPC_SETSPECIALMAP 7 /* Sets the special key mapping */
#define KBD_RPC_FLUSHBUFFER 9 /* Flush the internal buffer, probably best after a keymap change */
#define KBD_RPC_RESETKEYMAP 10 /* Reset keymaps to default states */
-#define KBD_RPC_READKEY 11
-#define KBD_RPC_READRAW 12
+#define KBD_RPC_READKEY 11
+#define KBD_RPC_READRAW 12
/* Note on keymaps. In normal keymap a 0 would indicate no key */
/* Key maps are represented by 3 256*8bit tables. First table maps USB key to a char when not shifted */
diff --git a/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c b/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c
index 7266afdce5..838ce9fe85 100644
--- a/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c
+++ b/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c
@@ -1089,7 +1089,7 @@ void *ps2kbd_rpc_server(int fno, void *data, int size) {
ps2kbd_rpc_flushbuffer();
break;
case KBD_RPC_SETLEDS:
- ps2kbd_rpc_setleds(*(u8*) data);
+ ps2kbd_rpc_setleds(*(u8 *) data);
break;
case KBD_RPC_RESETKEYMAP:
ps2kbd_rpc_resetkeymap();
@@ -1129,7 +1129,7 @@ int ps2kbd_init_rpc(void) {
int th;
param.attr = 0x02000000;
- param.thread = (void*)ps2kbd_start_rpc;
+ param.thread = (void *)ps2kbd_start_rpc;
param.priority = 40;
param.stacksize = 0x800;
param.option = 0;
diff --git a/backends/platform/ps2/irxboot.cpp b/backends/platform/ps2/irxboot.cpp
index d3049fcf4b..0e05047c6e 100644
--- a/backends/platform/ps2/irxboot.cpp
+++ b/backends/platform/ps2/irxboot.cpp
@@ -34,37 +34,65 @@
static const char hddArg[] = "-o" "\0" "8" "\0" "-n" "\0" "20";
static const char pfsArg[] = "-m" "\0" "2" "\0" "-o" "\0" "32" "\0" "-n" "\0" "72"; // "\0" "-debug";
-static const char netArg[] = "192.168.0.10" "\0" "255.255.255.0" "\0" "192.168.0.1";
-
-IrxFile irxFiles[] = {
- { "SIO2MAN", BIOS, NOTHING, NULL, 0 },
- { "MCMAN", BIOS, NOTHING, NULL, 0 },
- { "MCSERV", BIOS, NOTHING, NULL, 0 },
- { "PADMAN", BIOS, NOTHING, NULL, 0 },
- { "LIBSD", BIOS, NOTHING, NULL, 0 },
-
- { "IOMANX.IRX", SYSTEM, NOTHING, NULL, 0 },
- { "FILEXIO.IRX", SYSTEM, NOTHING, NULL, 0 },
- { "CODYVDFS.IRX", SYSTEM, NOTHING, NULL, 0 },
+static const char netArg[] = "192.168.1.20" "\0" "255.255.255.0" "\0" "192.168.1.1"; // TODO: set in ScummVM.ini
+
+IrxFile irxCore[] = { // core modules
+ // Memory Card
+ { "SIO2MAN", BIOS, NOTHING, NULL, 0 },
+ { "MCMAN", BIOS, NOTHING, NULL, 0 },
+ { "MCSERV", BIOS, NOTHING, NULL, 0 },
+ // Joypad
+ { "PADMAN", BIOS, NOTHING, NULL, 0 },
+ // Sound
+ { "LIBSD", BIOS, NOTHING, NULL, 0 },
{ "SJPCM.IRX", SYSTEM, NOTHING, NULL, 0 },
+ // Files I/O
+ { "IOMANX.IRX", SYSTEM, NOTHING, NULL, 0 },
+ { "FILEXIO.IRX", SYSTEM, NOTHING, NULL, 0 }
+};
+
+IrxFile irxCdrom[] = { // cdrom modules
+ // CD-Rom FS
+ { "CODYVDFS.IRX", SYSTEM, CD_DRIVER, NULL, 0 }
+};
+IrxFile irxUSB[] = { // USB mass
+ // USB drv & key
{ "USBD.IRX", USB | OPTIONAL | DEPENDANCY, USB_DRIVER, NULL, 0 },
- { "USB_MASS.IRX", USB | OPTIONAL, MASS_DRIVER, NULL, 0 },
+ { "USB_MASS.IRX", USB | OPTIONAL, MASS_DRIVER, NULL, 0 }
+};
+
+IrxFile irxInput[] = { // USB input
+ // USB mouse & kbd
{ "PS2MOUSE.IRX", USB | OPTIONAL, MOUSE_DRIVER, NULL, 0 },
- { "RPCKBD.IRX", USB | OPTIONAL, KBD_DRIVER, NULL, 0 },
-#ifndef NO_ADAPTOR
+ { "RPCKBD.IRX", USB | OPTIONAL, KBD_DRIVER, NULL, 0 }
+};
+
+IrxFile irxHDD[] = { // modules to support HDD
+ // hdd modules
{ "POWEROFF.IRX", HDD | OPTIONAL | NOT_HOST | DEPENDANCY, HDD_DRIVER, NULL, 0 },
{ "PS2DEV9.IRX", HDD | OPTIONAL | NOT_HOST | DEPENDANCY, HDD_DRIVER, NULL, 0 },
{ "PS2ATAD.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, NULL, 0 },
{ "PS2HDD.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, hddArg, sizeof(hddArg) },
- { "PS2FS.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, pfsArg, sizeof(pfsArg) },
+ { "PS2FS.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, pfsArg, sizeof(pfsArg) }
+};
+
+IrxFile irxNet[] = { // modules to support NET
+ // net modules
{ "PS2IP.IRX", NET | OPTIONAL | NOT_HOST | DEPENDANCY, NET_DRIVER, NULL, 0 },
{ "PS2SMAP.IRX", NET | OPTIONAL | NOT_HOST | DEPENDANCY, NET_DRIVER, netArg, sizeof(netArg) },
{ "PS2HOST.IRX", NET | OPTIONAL | NOT_HOST | DEPENDANCY, NET_DRIVER, NULL, 0 }
-#endif
};
-static const int numIrxFiles = sizeof(irxFiles) / sizeof(irxFiles[0]);
+IrxFile *irxType[IRX_MAX] = { irxCore, irxCdrom, irxUSB, irxInput, irxHDD, irxNet };
+
+static const int numIrx[IRX_MAX] = { sizeof(irxCore) / sizeof(IrxFile),
+ sizeof(irxCdrom) / sizeof(IrxFile),
+ sizeof(irxUSB) / sizeof(IrxFile),
+ sizeof(irxInput) / sizeof(IrxFile),
+ sizeof(irxHDD) / sizeof(IrxFile),
+ sizeof(irxNet) / sizeof(IrxFile)
+};
PS2Device detectBootPath(const char *elfPath, char *bootPath) {
@@ -113,19 +141,26 @@ PS2Device detectBootPath(const char *elfPath, char *bootPath) {
return device;
}
-int loadIrxModules(int device, const char *irxPath, IrxReference **modules) {
+int loadIrxModules(int device, const char *irxPath, IrxReference **modules, IrxType type) {
+
+ IrxReference *resModules;
+ IrxReference *curModule;
+ IrxFile *irxFiles;
+ int numFiles;
- IrxReference *resModules = (IrxReference *)malloc(numIrxFiles * sizeof(IrxReference));
- IrxReference *curModule = resModules;
+ irxFiles = irxType[type];
+ numFiles = numIrx[type];
+ resModules = (IrxReference *)memalign(64, numFiles * sizeof(IrxReference));
+ curModule = resModules;
- for (int i = 0; i < numIrxFiles; i++) {
+ for (int i = 0; i < numFiles; i++) {
curModule->fileRef = irxFiles + i;
if ((device == HOST_DEV) && (irxFiles[i].flags & NOT_HOST))
continue;
if ((irxFiles[i].flags & TYPEMASK) == BIOS) {
curModule->loc = IRX_FILE;
- curModule->path = (char *)malloc(32);
+ curModule->path = (char *)memalign(64, 32);
sprintf(curModule->path, "rom0:%s", irxFiles[i].name);
curModule->buffer = NULL;
curModule->size = 0;
@@ -134,7 +169,7 @@ int loadIrxModules(int device, const char *irxPath, IrxReference **modules) {
curModule->errorCode = 0;
} else {
curModule->loc = IRX_BUFFER;
- curModule->path = (char *)malloc(256);
+ curModule->path = (char *)memalign(64, 256);
sprintf(curModule->path, "%s%s%s", irxPath, irxFiles[i].name, (device == CD_DEV) ? ";1" : "");
int fd = fioOpen(curModule->path, O_RDONLY);
@@ -191,7 +226,7 @@ int loadIrxModules(int device, const char *irxPath, IrxReference **modules) {
pos++;
}
// and skip any remaining modules that depend on the missing one, too.
- while ((i < numIrxFiles - 1) && ((irxFiles[i + 1].flags & TYPEMASK) == (curModule->fileRef->flags & TYPEMASK)))
+ while ((i < numFiles - 1) && ((irxFiles[i + 1].flags & TYPEMASK) == (curModule->fileRef->flags & TYPEMASK)))
i++;
// the module that actually failed (curModule) is kept in the array for displaying an error message
}
diff --git a/backends/platform/ps2/irxboot.h b/backends/platform/ps2/irxboot.h
index 867911da0f..487d335553 100644
--- a/backends/platform/ps2/irxboot.h
+++ b/backends/platform/ps2/irxboot.h
@@ -25,6 +25,16 @@
#include "common/scummsys.h"
+enum IrxType {
+ IRX_CORE = 0,
+ IRX_CDROM,
+ IRX_USB,
+ IRX_INPUT,
+ IRX_HDD,
+ IRX_NET,
+ IRX_MAX
+};
+
enum IrxFlags {
BIOS = 0,
SYSTEM = 1,
@@ -40,6 +50,7 @@ enum IrxFlags {
enum IrxPurpose {
NOTHING,
+ CD_DRIVER,
HDD_DRIVER,
USB_DRIVER,
MOUSE_DRIVER,
@@ -81,6 +92,6 @@ struct IrxReference {
int errorCode;
};
-int loadIrxModules(int device, const char *irxPath, IrxReference **modules);
+int loadIrxModules(int device, const char *irxPath, IrxReference **modules, IrxType type);
#endif // __IRXBOOT_H__
diff --git a/backends/platform/ps2/module.mk b/backends/platform/ps2/module.mk
index bf95a5501d..7bcc60e58d 100644
--- a/backends/platform/ps2/module.mk
+++ b/backends/platform/ps2/module.mk
@@ -2,20 +2,20 @@ MODULE := backends/platform/ps2
MODULE_OBJS := \
DmaPipe.o \
- Gs2dScreen.o \
- irxboot.o \
+ Gs2dScreen.o \
+ irxboot.o \
ps2input.o \
ps2pad.o \
savefilemgr.o \
- fileio.o \
- asyncfio.o \
+ fileio.o \
+ asyncfio.o \
icon.o \
- cd.o \
- eecodyvdfs.o \
- rpckbd.o \
- systemps2.o \
- ps2mutex.o \
- ps2time.o \
+ cd.o \
+ eecodyvdfs.o \
+ rpckbd.o \
+ systemps2.o \
+ ps2mutex.o \
+ ps2time.o \
ps2debug.o
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
diff --git a/backends/platform/ps2/ps2debug.cpp b/backends/platform/ps2/ps2debug.cpp
index ec1e251583..84c3649faf 100644
--- a/backends/platform/ps2/ps2debug.cpp
+++ b/backends/platform/ps2/ps2debug.cpp
@@ -22,10 +22,10 @@
#include "ps2debug.h"
#include <stdio.h>
-#include <stdlib.h>
#include <sio.h>
void sioprintf(const char *zFormat, ...) {
+ #if 0 // doesn't seem to work with ps2link...
va_list ap;
char resStr[2048];
@@ -43,4 +43,5 @@ void sioprintf(const char *zFormat, ...) {
sio_putc(*pos);
pos++;
}
+ #endif
}
diff --git a/backends/platform/ps2/ps2debug.h b/backends/platform/ps2/ps2debug.h
index b3da749f60..45db850ebf 100644
--- a/backends/platform/ps2/ps2debug.h
+++ b/backends/platform/ps2/ps2debug.h
@@ -23,7 +23,13 @@
#ifndef __PS2DEBUG_H__
#define __PS2DEBUG_H__
-#define dbg_printf printf
+#ifdef LOGORRHEIC
+ #define FORBIDDEN_SYMBOL_EXCEPTION_printf
+ // #define dbg_printf sio_printf
+ #define dbg_printf printf
+#else
+ #define dbg_printf(...) /* ... */
+#endif
void sioprintf(const char *zFormat, ...);
diff --git a/backends/platform/ps2/ps2input.cpp b/backends/platform/ps2/ps2input.cpp
index 6969aef931..636176e06c 100644
--- a/backends/platform/ps2/ps2input.cpp
+++ b/backends/platform/ps2/ps2input.cpp
@@ -170,7 +170,7 @@ bool Ps2Input::pollEvent(Common::Event *event) {
}
if (checkPadMouse || checkPadKbd) {
// no usb mouse, simulate it using the pad
- uint16 buttons;
+ uint16 buttons;
int16 joyh, joyv;
_pad->readPad(&buttons, &joyh, &joyv);
uint16 btnChange = buttons ^ _padLastButtons;
@@ -474,11 +474,11 @@ const Common::KeyCode Ps2Input::_usbToSdlk[0x100] = {
/* DD */ Common::KEYCODE_INVALID,
/* DE */ Common::KEYCODE_INVALID,
/* DF */ Common::KEYCODE_INVALID,
- /* E0 */ Common::KEYCODE_LCTRL,
+ /* E0 */ Common::KEYCODE_LCTRL,
/* E1 */ Common::KEYCODE_LSHIFT,
/* E2 */ Common::KEYCODE_LALT,
/* E3 */ Common::KEYCODE_INVALID,
- /* E4 */ Common::KEYCODE_RCTRL,
+ /* E4 */ Common::KEYCODE_RCTRL,
/* E5 */ Common::KEYCODE_RSHIFT,
/* E6 */ Common::KEYCODE_RALT,
/* E7 */ Common::KEYCODE_INVALID,
@@ -509,39 +509,39 @@ const Common::KeyCode Ps2Input::_usbToSdlk[0x100] = {
};
const Common::KeyCode Ps2Input::_padCodes[16] = {
- Common::KEYCODE_1, // Select
- Common::KEYCODE_INVALID, // L3
- Common::KEYCODE_INVALID, // R3
- Common::KEYCODE_F5, // Start
- Common::KEYCODE_INVALID, // Up
- Common::KEYCODE_INVALID, // Right
- Common::KEYCODE_INVALID, // Down
- Common::KEYCODE_INVALID, // Left
- Common::KEYCODE_KP0, // L2
- Common::KEYCODE_PERIOD, // R2
- Common::KEYCODE_n, // L1
- Common::KEYCODE_y, // R1
- Common::KEYCODE_ESCAPE, // Triangle
- Common::KEYCODE_INVALID, // Circle => Right mouse button
- Common::KEYCODE_INVALID, // Cross => Left mouse button
- Common::KEYCODE_RETURN // Square
+ Common::KEYCODE_1, // Select
+ Common::KEYCODE_INVALID, // L3
+ Common::KEYCODE_INVALID, // R3
+ Common::KEYCODE_F5, // Start
+ Common::KEYCODE_INVALID, // Up
+ Common::KEYCODE_INVALID, // Right
+ Common::KEYCODE_INVALID, // Down
+ Common::KEYCODE_INVALID, // Left
+ Common::KEYCODE_KP0, // L2
+ Common::KEYCODE_PERIOD, // R2
+ Common::KEYCODE_n, // L1
+ Common::KEYCODE_y, // R1
+ Common::KEYCODE_ESCAPE, // Triangle
+ Common::KEYCODE_INVALID, // Circle => Right mouse button
+ Common::KEYCODE_INVALID, // Cross => Left mouse button
+ Common::KEYCODE_RETURN // Square
};
const Common::KeyCode Ps2Input::_padFlags[16] = {
- Common::KEYCODE_INVALID, // Select
- Common::KEYCODE_INVALID, // L3
- Common::KEYCODE_INVALID, // R3
- Common::KEYCODE_INVALID, // Start
- Common::KEYCODE_INVALID, // Up
- Common::KEYCODE_INVALID, // Right
- Common::KEYCODE_INVALID, // Down
- Common::KEYCODE_INVALID, // Left
- Common::KEYCODE_INVALID, // L2
- Common::KEYCODE_INVALID, // R2
- Common::KEYCODE_INVALID, // L1
- Common::KEYCODE_INVALID, // R1
- Common::KEYCODE_INVALID, // Triangle
- Common::KEYCODE_INVALID, // Circle
- Common::KEYCODE_INVALID, // Cross
- Common::KEYCODE_INVALID // Square
+ Common::KEYCODE_INVALID, // Select
+ Common::KEYCODE_INVALID, // L3
+ Common::KEYCODE_INVALID, // R3
+ Common::KEYCODE_INVALID, // Start
+ Common::KEYCODE_INVALID, // Up
+ Common::KEYCODE_INVALID, // Right
+ Common::KEYCODE_INVALID, // Down
+ Common::KEYCODE_INVALID, // Left
+ Common::KEYCODE_INVALID, // L2
+ Common::KEYCODE_INVALID, // R2
+ Common::KEYCODE_INVALID, // L1
+ Common::KEYCODE_INVALID, // R1
+ Common::KEYCODE_INVALID, // Triangle
+ Common::KEYCODE_INVALID, // Circle
+ Common::KEYCODE_INVALID, // Cross
+ Common::KEYCODE_INVALID // Square
};
diff --git a/backends/platform/ps2/ps2input.h b/backends/platform/ps2/ps2input.h
index 7055b64f4e..af413d262c 100644
--- a/backends/platform/ps2/ps2input.h
+++ b/backends/platform/ps2/ps2input.h
@@ -44,7 +44,7 @@ private:
int mapKey(int key, int mod);
bool getKeyEvent(Common::Event *event, uint16 buttonCode, bool down);
OSystem_PS2 *_system;
- Ps2Pad *_pad;
+ Ps2Pad *_pad;
uint16 _minx, _maxx, _miny, _maxy;
diff --git a/backends/platform/ps2/ps2pad.cpp b/backends/platform/ps2/ps2pad.cpp
index b59547baca..d990690331 100644
--- a/backends/platform/ps2/ps2pad.cpp
+++ b/backends/platform/ps2/ps2pad.cpp
@@ -34,7 +34,7 @@ Ps2Pad::Ps2Pad(OSystem_PS2 *system) {
_padStatus = STAT_NONE;
padInit(0); // initialize library
- _port = _slot = 0; // first controller, no multitap
+ _port = _slot = 0; // first controller, no multitap
initPad();
}
@@ -51,9 +51,6 @@ void Ps2Pad::initPad(void) {
} else {
if (checkPadReady(_port, _slot)) {
switch (_padStatus) {
- case STAT_NONE:
- printf("Pad Status is None. Shouldn't happen\n");
- break;
case STAT_OPEN:
_padStatus = STAT_DETECT;
break;
@@ -104,7 +101,8 @@ void Ps2Pad::initPad(void) {
_padStatus = STAT_OKAY;
break;
case STAT_OKAY:
- // pad is already initialized
+ case STAT_NONE:
+ // pad is already initialized (or not there)
break;
}
} else {
diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp
index 647cf0b661..e072ce9483 100644
--- a/backends/platform/ps2/ps2time.cpp
+++ b/backends/platform/ps2/ps2time.cpp
@@ -30,9 +30,9 @@
#define FROM_BCD(a) ((a >> 4) * 10 + (a & 0xF))
-static int g_timeSecs;
-static int g_day, g_month, g_year;
-static int g_lastTimeCheck;
+static int g_timeSecs;
+static int g_day, g_month, g_year;
+static int g_lastTimeCheck;
extern volatile uint32 msecCount;
void buildNewDate(int dayDiff) {
diff --git a/backends/platform/ps2/rpckbd.c b/backends/platform/ps2/rpckbd.c
index 0bb45208f5..e7975ab484 100644
--- a/backends/platform/ps2/rpckbd.c
+++ b/backends/platform/ps2/rpckbd.c
@@ -17,7 +17,7 @@
#include <string.h>
#include "backends/platform/ps2/rpckbd.h"
-static int curr_readmode = PS2KBD_READMODE_NORMAL;
+static unsigned int curr_readmode = PS2KBD_READMODE_NORMAL;
static int kbdRpcSema = -1;
static int kbdInitialized = 0;
diff --git a/backends/platform/ps2/savefilemgr.cpp b/backends/platform/ps2/savefilemgr.cpp
index de03e76892..4fd2b1c72b 100644
--- a/backends/platform/ps2/savefilemgr.cpp
+++ b/backends/platform/ps2/savefilemgr.cpp
@@ -21,8 +21,6 @@
*/
#define FORBIDDEN_SYMBOL_EXCEPTION_printf
-#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
-#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
#include "common/config-manager.h"
#include "common/zlib.h"
@@ -37,6 +35,7 @@
#include "savefilemgr.h"
#include "Gs2dScreen.h"
#include "ps2temp.h"
+#include "ps2debug.h"
extern AsyncFio fio;
@@ -57,20 +56,20 @@ bool Ps2SaveFileManager::mcCheck(const char *path) {
// int res;
- printf("mcCheck\n");
+ dbg_printf("mcCheck\n");
if (!dir.exists()) {
- printf("! exist -> create : ");
+ dbg_printf("! exist -> create : ");
#ifdef __USE_LIBMC__
- printf("%s\n", path+4);
+ dbg_printf("%s\n", path+4);
// WaitSema(_sema);
mcSync(0, NULL, NULL);
mcMkDir(0 /*port*/, 0 /*slot*/, path+4);
mcSync(0, NULL, &res);
- printf("sync : %d\n", res);
+ dbg_printf("sync : %d\n", res);
// SignalSema(_sema);
#else
- printf("%s\n", path);
+ dbg_printf("%s\n", path);
fio.mkdir(path);
#endif
}
@@ -108,7 +107,7 @@ Common::InSaveFile *Ps2SaveFileManager::openForLoading(const Common::String &fil
}
else {
char temp[32];
- printf("MC : filename = %s\n", filename.c_str());
+ dbg_printf("MC : filename = %s\n", filename.c_str());
strcpy(temp, filename.c_str());
// mcSplit(temp, game, ext);
@@ -149,7 +148,7 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &fil
Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
Common::WriteStream *sf;
- printf("openForSaving : %s\n", filename.c_str());
+ dbg_printf("openForSaving : %s\n", filename.c_str());
if (!savePath.exists() || !savePath.isDirectory())
return NULL;
@@ -166,10 +165,10 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &fil
sprintf(path, "mc0:ScummVM/indy4/iq-points");
}
// FIXME : hack for bs1 saved games
- else if (filename == "SAVEGAME.INF") {
- mcCheck("mc0:ScummVM/sword1");
- sprintf(path, "mc0:ScummVM/sword1/SAVEGAME.INF");
- }
+ else if (filename == "SAVEGAME.INF") {
+ mcCheck("mc0:ScummVM/sword1");
+ sprintf(path, "mc0:ScummVM/sword1/SAVEGAME.INF");
+ }
else {
char temp[32];
strcpy(temp, filename.c_str());
@@ -240,7 +239,7 @@ Common::StringArray Ps2SaveFileManager::listSavefiles(const Common::String &patt
if (!savePath.exists() || !savePath.isDirectory())
return Common::StringArray();
- printf("listSavefiles = %s\n", pattern.c_str());
+ dbg_printf("listSavefiles = %s\n", pattern.c_str());
if (_mc) {
strcpy(temp, pattern.c_str());
@@ -263,7 +262,7 @@ Common::StringArray Ps2SaveFileManager::listSavefiles(const Common::String &patt
Common::ArchiveMemberList savefiles;
Common::StringArray results;
- printf("dir = %s --- reg = %s\n", _dir.c_str(), search.c_str());
+ dbg_printf("dir = %s --- reg = %s\n", _dir.c_str(), search.c_str());
if (dir.listMatchingMembers(savefiles, search) > 0) {
for (Common::ArchiveMemberList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) {
@@ -272,11 +271,11 @@ Common::StringArray Ps2SaveFileManager::listSavefiles(const Common::String &patt
temp[3] = '\0';
sprintf(path, "%s.%s", game, temp);
results.push_back(path);
- printf(" --> found = %s -> %s\n", (*file)->getName().c_str(), path);
+ dbg_printf(" --> found = %s -> %s\n", (*file)->getName().c_str(), path);
}
else {
results.push_back((*file)->getName());
- printf(" --> found = %s\n", (*file)->getName().c_str());
+ dbg_printf(" --> found = %s\n", (*file)->getName().c_str());
}
}
}
diff --git a/backends/platform/ps2/sysdefs.h b/backends/platform/ps2/sysdefs.h
index 0b0d286189..c886d70eef 100644
--- a/backends/platform/ps2/sysdefs.h
+++ b/backends/platform/ps2/sysdefs.h
@@ -40,30 +40,30 @@ enum Interrupts {
};
// dma 2 registers
-#define D2_CHCR (*(volatile uint32*)0x1000A000)
-#define D2_QWC (*(volatile uint32*)0x1000A020)
-#define D2_TADR (*(volatile uint32*)0x1000A030)
-#define D2_MADR (*(volatile uint32*)0x1000A010)
-#define D2_ASR1 (*(volatile uint32*)0x1000A050)
-#define D2_ASR0 (*(volatile uint32*)0x1000A040)
+#define D2_CHCR (*(volatile uint32 *)0x1000A000)
+#define D2_QWC (*(volatile uint32 *)0x1000A020)
+#define D2_TADR (*(volatile uint32 *)0x1000A030)
+#define D2_MADR (*(volatile uint32 *)0x1000A010)
+#define D2_ASR1 (*(volatile uint32 *)0x1000A050)
+#define D2_ASR0 (*(volatile uint32 *)0x1000A040)
-#define D_CTRL (*(volatile uint32*)0x1000E000)
-#define D_STAT (*(volatile uint32*)0x1000E010)
-#define D_PCR (*(volatile uint32*)0x1000E020)
-#define D_SQWC (*(volatile uint32*)0x1000E030)
-#define D_RBSR (*(volatile uint32*)0x1000E040)
-#define D_RBOR (*(volatile uint32*)0x1000E050)
-#define D_STADR (*(volatile uint32*)0x1000E060)
+#define D_CTRL (*(volatile uint32 *)0x1000E000)
+#define D_STAT (*(volatile uint32 *)0x1000E010)
+#define D_PCR (*(volatile uint32 *)0x1000E020)
+#define D_SQWC (*(volatile uint32 *)0x1000E030)
+#define D_RBSR (*(volatile uint32 *)0x1000E040)
+#define D_RBOR (*(volatile uint32 *)0x1000E050)
+#define D_STADR (*(volatile uint32 *)0x1000E060)
#define CIM2 (1 << 18)
#define CIS2 (1 << 2)
// timer 0 registers
-#define T0_COUNT (*(volatile uint32*)0x10000000)
-#define T0_MODE (*(volatile uint32*)0x10000010)
-#define T0_COMP (*(volatile uint32*)0x10000020)
-#define T0_HOLD (*(volatile uint32*)0x10000030)
+#define T0_COUNT (*(volatile uint32 *)0x10000000)
+#define T0_MODE (*(volatile uint32 *)0x10000010)
+#define T0_COMP (*(volatile uint32 *)0x10000020)
+#define T0_HOLD (*(volatile uint32 *)0x10000030)
#define TIMER_MODE(clks, gate, gates, gatem, zeroret, cue, cmpe, ovfe, equf, ovff) \
((clks) | ((gate) << 2) | ((gates) << 3) | ((gatem) << 4) | ((zeroret) << 6) | \
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index feee73cba7..1aa74b7d9b 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -20,8 +20,9 @@
*
*/
-// Disable symbol overrides so that we can use system headers.
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+// Disable symbol overrides so that we can use "FILE"
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
#include <kernel.h>
#include <stdio.h>
@@ -50,7 +51,6 @@
#include "backends/platform/ps2/cd.h"
#include "backends/platform/ps2/fileio.h"
#include "backends/platform/ps2/Gs2dScreen.h"
-#include "backends/platform/ps2/irxboot.h"
#include "backends/platform/ps2/ps2debug.h"
#include "backends/platform/ps2/ps2input.h"
#include "backends/platform/ps2/savefilemgr.h"
@@ -112,7 +112,11 @@ extern "C" int scummvm_main(int argc, char *argv[]);
extern "C" int main(int argc, char *argv[]) {
SifInitRpc(0);
+ #ifdef __NEW_PS2SDK__
+ ee_thread_status_t thisThread;
+ #else
ee_thread_t thisThread;
+ #endif
int tid = GetThreadId();
ReferThreadStatus(tid, &thisThread);
@@ -147,6 +151,10 @@ extern "C" int main(int argc, char *argv[]) {
g_systemPs2->quit();
+#ifdef ENABLE_PROFILING
+ // make sure we can flush "gmon.out"
+ fileXioSetBlockMode(FXIO_WAIT);
+#endif
// control never gets here
return res;
}
@@ -184,13 +192,11 @@ void systemSoundThread(OSystem_PS2 *system) {
}
void gluePowerOffCallback(void *system) {
- ((OSystem_PS2*)system)->powerOffCallback();
+ ((OSystem_PS2 *)system)->powerOffCallback();
}
void OSystem_PS2::startIrxModules(int numModules, IrxReference *modules) {
- _usbMassLoaded = _useMouse = _useKbd = _useHdd = _useNet = false;
-
int res = 0, rv = 0;
for (int i = 0; i < numModules; i++) {
if (modules[i].loc == IRX_FILE) {
@@ -216,6 +222,9 @@ void OSystem_PS2::startIrxModules(int numModules, IrxReference *modules) {
case KBD_DRIVER:
_useKbd = true;
break;
+ case CD_DRIVER:
+ _useCd = true;
+ break;
case HDD_DRIVER:
_useHdd = true;
break;
@@ -241,20 +250,79 @@ void OSystem_PS2::startIrxModules(int numModules, IrxReference *modules) {
}
if (modules[i].buffer)
- free(modules[i].buffer);
+ ; // free(modules[i].buffer);
} else {
sioprintf("module %d of %d damaged, loc %d, path %s\n", i, numModules, modules[i].loc, modules[i].path);
}
- free(modules[i].path);
+ // free(modules[i].path);
}
- free(modules);
+ // free(modules);
sioprintf("done\n");
sioprintf("UsbMass: %sloaded\n", _usbMassLoaded ? "" : "not ");
sioprintf("Mouse: %sloaded\n", _useMouse ? "" : "not ");
sioprintf("Kbd: %sloaded\n", _useKbd ? "" : "not ");
+ sioprintf("Cd: %sloaded\n", _useCd ? "" : "not ");
sioprintf("Hdd: %sloaded\n", _useHdd ? "" : "not ");
}
+bool OSystem_PS2::loadDrivers(IrxType type)
+{
+ IrxReference *modules;
+ int numModules;
+ int res;
+
+ numModules = loadIrxModules(_bootDevice, _bootPath, &modules, type);
+ // TODO: for IRX_NET allows override IP addr
+ startIrxModules(numModules, modules);
+
+ switch (type) {
+ case IRX_CORE:
+ /* Init I/O */
+ if ((res = fileXioInit()) < 0) {
+ msgPrintf(FOREVER, "FXIO init failed: %d", res);
+ quit();
+ }
+ /* Init sound */
+ if ((res = SjPCM_Init(0)) < 0) {
+ msgPrintf(FOREVER, "SjPCM bind failed: %d\n", res);
+ quit();
+ }
+ break;
+
+ case IRX_CDROM:
+ /* Init CDROM & RTC Clock */
+ if ((res = initCdvdFs()) < 0) {
+ msgPrintf(FOREVER, "CoDyVDfs bind failed: %d", res);
+ quit();
+ }
+ sioprintf("Reading RTC\n");
+ readRtcTime(); /* depends on CDROM driver! */
+ break;
+
+ case IRX_HDD:
+ /* Check HD is available and formatted */
+ if ((hddCheckPresent() < 0) || (hddCheckFormatted() < 0)) {
+ _useHdd = false;
+ }
+ else {
+ poweroffInit();
+ poweroffSetCallback(gluePowerOffCallback, this);
+ }
+ break;
+
+ case IRX_NET:
+ if (_bootDevice == HOST_DEV) // net is pre-loaded on host
+ _useNet = true; // so we need to set by hand
+ break;
+
+ default:
+ /* zzz */
+ break;
+ }
+
+ return true;
+}
+
OSystem_PS2::OSystem_PS2(const char *elfPath) {
_soundStack = _timerStack = NULL;
_printY = 0;
@@ -262,20 +330,19 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) {
_systemQuit = false;
_modeChanged = false;
_screenChangeCount = 0;
+ _mouseVisible = false;
- _screen = new Gs2dScreen(320, 200, TV_DONT_CARE);
+ // _screen = new Gs2dScreen(320, 200, TV_DONT_CARE); // moved to ::initSize
sioprintf("Initializing system...\n");
- _screen->wantAnim(true);
+ // _screen->wantAnim(true);
- _bootPath = (char *)malloc(128);
+ _bootPath = (char *)memalign(64, 128);
_bootDevice = detectBootPath(elfPath, _bootPath);
- IrxReference *modules;
- int numModules = loadIrxModules(_bootDevice, _bootPath, &modules);
-
if (_bootDevice != HOST_DEV) {
+ // TODO: reset funx
sioprintf("Resetting IOP.\n");
cdvdInit(CDVD_EXIT);
cdvdExit();
@@ -298,50 +365,12 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) {
// TODO: ps2link 1.46 will stall on "poweroff" init / cb
}
- startIrxModules(numModules, modules);
-
- int res;
- if ((res = fileXioInit()) < 0) {
- msgPrintf(FOREVER, "FXIO Init failed: %d", res);
- quit();
- }
+ _usbMassLoaded = _useMouse = _useKbd = _useCd = _useHdd = _useNet = false;
- if ((res = initCdvdFs()) < 0) {
- msgPrintf(FOREVER, "CoDyVDfs bind failed: %d", res);
- quit();
- }
-
- if ((res = SjPCM_Init(0)) < 0) {
- msgPrintf(FOREVER, "SjPCM Bind failed: %d\n", res);
- quit();
- }
-
- if (_useHdd) {
- if ((hddCheckPresent() < 0) || (hddCheckFormatted() < 0))
- _useHdd = false;
-
- //hddPreparePoweroff();
- poweroffInit();
-
- //hddSetUserPoweroffCallback(gluePowerOffCallback, this);
- poweroffSetCallback(gluePowerOffCallback, this);
- }
+ loadDrivers(IRX_CORE);
+ loadDrivers(IRX_CDROM); // consider CDROM as "core", as RTC depends on it
fileXioSetBlockMode(FXIO_NOWAIT);
-
- _mouseVisible = false;
-
- sioprintf("reading RTC\n");
- readRtcTime();
-
- if (_useHdd) {
- // TODO : make partition path configurable
- if (fio.mount("pfs0:", "hdd0:+ScummVM", 0) >= 0)
- printf("Successfully mounted!\n");
- else
- _useHdd = false;
- }
-
initMutexes();
}
@@ -356,14 +385,67 @@ void OSystem_PS2::init(void) {
sioprintf("Starting SavefileManager\n");
_savefileManager = new Ps2SaveFileManager(this, _screen);
- sioprintf("Initializing ps2Input\n");
- _input = new Ps2Input(this, _useMouse, _useKbd);
-
prepMC();
makeConfigPath();
- _screen->wantAnim(false);
- fillScreen(0);
+ // _screen->wantAnim(false);
+ // fillScreen(0);
+}
+
+void OSystem_PS2::config(void) {
+ #ifndef NO_ADAPTOR
+ if (ConfMan.hasKey("hdd_part", "PlayStation2")) { // "hdd" ?
+ const char *hdd = ConfMan.get("hdd_part", "PlayStation2").c_str();
+
+ if ( !strcmp(hdd, "0") || !strcmp(hdd, "no") || !strcmp(hdd, "disable") ) {
+ _useHdd = false;
+ }
+ else {
+ loadDrivers(IRX_HDD);
+ hddMount(hdd);
+ }
+ }
+ else { // check for HDD and assume partition is +ScummVM
+ loadDrivers(IRX_HDD);
+ hddMount("ScummVM");
+ }
+
+ if (ConfMan.hasKey("net_addr", "PlayStation2")) { // "net" ?
+ const char *net = ConfMan.get("net_addr", "PlayStation2").c_str();
+
+ if ( !strcmp(net, "0") || !strcmp(net, "no") || !strcmp(net, "disable") ) {
+ _useNet = false;
+ }
+ else {
+ loadDrivers(IRX_NET);
+ // TODO: netInit("xxx.xxx.xxx.xxx");
+ }
+ }
+ else { // setup net - IP hardcoded 192.168.1.20
+ loadDrivers(IRX_NET);
+ }
+ #endif
+
+ // why USB drivers only load correctly post HDD ?
+ if (ConfMan.hasKey("usb_mass", "PlayStation2")) { // "usb" ?
+ const char *usb = ConfMan.get("usb_mass", "PlayStation2").c_str();
+
+ if ( !strcmp(usb, "0") || !strcmp(usb, "no") || !strcmp(usb, "disable") ) {
+ _usbMassLoaded = false;
+ }
+ else {
+ loadDrivers(IRX_USB);
+ loadDrivers(IRX_INPUT);
+ sioprintf("Initializing ps2Input\n");
+ _input = new Ps2Input(this, _useMouse, _useKbd);
+ }
+ }
+ else { // load USB drivers (mass & input(
+ loadDrivers(IRX_USB);
+ loadDrivers(IRX_INPUT);
+ sioprintf("Initializing ps2Input\n");
+ _input = new Ps2Input(this, _useMouse, _useKbd);
+ }
}
OSystem_PS2::~OSystem_PS2(void) {
@@ -380,26 +462,40 @@ void OSystem_PS2::initTimer(void) {
g_TimerThreadSema = CreateSema(&threadSema);
g_SoundThreadSema = CreateSema(&threadSema);
assert((g_TimerThreadSema >= 0) && (g_SoundThreadSema >= 0));
-
+ #ifdef __NEW_PS2SDK__
+ ee_thread_t timerThread, soundThread;
+ ee_thread_status_t thisThread;
+ #else
ee_thread_t timerThread, soundThread, thisThread;
+ #endif
ReferThreadStatus(GetThreadId(), &thisThread);
- _timerStack = (uint8 *)malloc(TIMER_STACK_SIZE);
- _soundStack = (uint8 *)malloc(SOUND_STACK_SIZE);
+ _timerStack = (uint8 *)memalign(64, TIMER_STACK_SIZE);
+ _soundStack = (uint8 *)memalign(64, SOUND_STACK_SIZE);
+ // gprof doesn't cope with higher thread priority too well
+ #ifdef ENABLE_PROFILING
+ timerThread.initial_priority = thisThread.current_priority;
+ #else
// give timer thread a higher priority than main thread
timerThread.initial_priority = thisThread.current_priority - 1;
+ #endif
timerThread.stack = _timerStack;
timerThread.stack_size = TIMER_STACK_SIZE;
timerThread.func = (void *)systemTimerThread;
- timerThread.gp_reg = &_gp;
+ timerThread.gp_reg = &_gp;
+ // gprof doesn't cope with higher thread priority too well
+ #ifdef ENABLE_PROFILING
+ soundThread.initial_priority = thisThread.current_priority;
+ #else
// soundthread's priority is higher than main- and timerthread
soundThread.initial_priority = thisThread.current_priority - 2;
+ #endif
soundThread.stack = _soundStack;
soundThread.stack_size = SOUND_STACK_SIZE;
soundThread.func = (void *)systemSoundThread;
- soundThread.gp_reg = &_gp;
+ soundThread.gp_reg = &_gp;
_timerTid = CreateThread(&timerThread);
_soundTid = CreateThread(&soundThread);
@@ -459,39 +555,39 @@ void OSystem_PS2::soundThreadCallback(void) {
// demux data into 2 buffers, L and R
__asm__ (
- "move $t2, %1\n\t" // dest buffer right
- "move $t3, %0\n\t" // dest buffer left
- "lui $t8, 0x7000\n\t" // muxed buffer, fixed at 0x70000000
- "addiu $t9, $0, 100\n\t" // number of loops
- "mtsab $0, 2\n\t" // set qword shift = 2 byte
+ "move $t2, %1\n\t" // dest buffer right
+ "move $t3, %0\n\t" // dest buffer left
+ "lui $t8, 0x7000\n\t" // muxed buffer, fixed at 0x70000000
+ "addiu $t9, $0, 100\n\t" // number of loops
+ "mtsab $0, 2\n\t" // set qword shift = 2 byte
"loop:\n\t"
- " lq $t4, 0($t8)\n\t" // load 8 muxed samples
- " lq $t5, 16($t8)\n\t" // load 8 more muxed samples
+ " lq $t4, 0($t8)\n\t" // load 8 muxed samples
+ " lq $t5, 16($t8)\n\t" // load 8 more muxed samples
- " qfsrv $t6, $0, $t4\n\t" // shift right for second
- " qfsrv $t7, $0, $t5\n\t" // packing step (right channel)
+ " qfsrv $t6, $0, $t4\n\t" // shift right for second
+ " qfsrv $t7, $0, $t5\n\t" // packing step (right channel)
- " ppach $t4, $t5, $t4\n\t" // combine left channel data
- " ppach $t6, $t7, $t6\n\t" // right channel data
+ " ppach $t4, $t5, $t4\n\t" // combine left channel data
+ " ppach $t6, $t7, $t6\n\t" // right channel data
- " sq $t4, 0($t3)\n\t" // write back
- " sq $t6, 0($t2)\n\t" //
+ " sq $t4, 0($t3)\n\t" // write back
+ " sq $t6, 0($t2)\n\t" //
- " addiu $t9, -1\n\t" // decrement loop counter
- " addiu $t2, 16\n\t" // increment pointers
+ " addiu $t9, -1\n\t" // decrement loop counter
+ " addiu $t2, 16\n\t" // increment pointers
" addiu $t3, 16\n\t"
" addiu $t8, 32\n\t"
- " bnez $t9, loop\n\t" // loop
+ " bnez $t9, loop\n\t" // loop
: // outputs
: "r"(soundBufL), "r"(soundBufR) // inputs
- // : "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "$t9" // destroyed
+ // : "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "$t9" // destroyed
: "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25" // destroyed
);
// and feed it into the SPU
// non-blocking call, the function will return before the buffer's content
// was transferred.
- SjPCM_Enqueue((short int*)soundBufL, (short int*)soundBufR, SMP_PER_BLOCK, 0);
+ SjPCM_Enqueue((short int *)soundBufL, (short int *)soundBufR, SMP_PER_BLOCK, 0);
bufferedSamples += SMP_PER_BLOCK;
}
}
@@ -510,6 +606,10 @@ bool OSystem_PS2::mcPresent(void) {
return false;
}
+bool OSystem_PS2::cdPresent(void) {
+ return _useCd;
+}
+
bool OSystem_PS2::hddPresent(void) {
return _useHdd;
}
@@ -528,11 +628,39 @@ bool OSystem_PS2::usbMassPresent(void) {
}
bool OSystem_PS2::netPresent(void) {
- return _useNet;
+ if (_useNet)
+ return true;
+
+ return false;
+}
+
+bool OSystem_PS2::hddMount(const char *partition) {
+ char name[64] = "hdd0:+ScummVM";
+
+ if (partition)
+ strcpy(name+6, partition);
+
+ if (fio.mount("pfs0:", name, 0) >= 0) {
+ dbg_printf("Successfully mounted (%s)!\n", name);
+ return true;
+ }
+ else {
+ dbg_printf("Failed to mount (%s).\n", name);
+ _useHdd = false;
+ return false;
+ }
}
void OSystem_PS2::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
- printf("initializing new size: (%d/%d)...", width, height);
+ dbg_printf("initializing new size: (%d/%d)...", width, height);
+
+ /* ugly hack: we know we can parse ScummVM.ini now */
+ if (!_screenChangeCount) { // first round
+ config();
+ _screen = new Gs2dScreen(width, height);
+ fillScreen(0);
+ }
+
_screen->newScreenSize(width, height);
_screen->setMouseXy(width / 2, height / 2);
_input->newRange(0, 0, width - 1, height - 1);
@@ -543,7 +671,7 @@ void OSystem_PS2::initSize(uint width, uint height, const Graphics::PixelFormat
_modeChanged = true;
_screenChangeCount++;
- printf("done\n");
+ dbg_printf("done\n");
}
void OSystem_PS2::setPalette(const byte *colors, uint start, uint num) {
@@ -555,7 +683,7 @@ void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) {
}
void OSystem_PS2::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
- _screen->copyScreenRect((const uint8*)buf, pitch, x, y, w, h);
+ _screen->copyScreenRect((const uint8 *)buf, pitch, x, y, w, h);
}
void OSystem_PS2::updateScreen(void) {
@@ -568,7 +696,7 @@ void OSystem_PS2::updateScreen(void) {
void OSystem_PS2::displayMessageOnOSD(const char *msg) {
/* TODO : check */
- printf("displayMessageOnOSD: %s\n", msg);
+ dbg_printf("displayMessageOnOSD: %s\n", msg);
}
uint32 OSystem_PS2::getMillis(bool skipRecord) {
@@ -666,7 +794,7 @@ void OSystem_PS2::unlockScreen(void) {
const OSystem::GraphicsMode OSystem_PS2::_graphicsMode = { NULL, NULL, 0 };
const OSystem::GraphicsMode *OSystem_PS2::getSupportedGraphicsModes(void) const {
- return &_graphicsMode;
+ return &_graphicsMode;
}
bool OSystem_PS2::setGraphicsMode(int mode) {
@@ -735,7 +863,7 @@ void OSystem_PS2::msgPrintf(int millis, const char *format, ...) {
Graphics::g_sysfont.drawString(&surf, str, posX, posY, 300 - posX, 1);
posY += 14;
- lnSta = lnEnd + 1;
+ lnSta = lnEnd + 1;
}
uint8 *scrBuf = (uint8 *)memalign(64, 320 * 200);
@@ -768,12 +896,14 @@ void OSystem_PS2::powerOffCallback(void) {
}
void OSystem_PS2::quit(void) {
- printf("OSystem_PS2::quit called\n");
+ dbg_printf("OSystem_PS2::quit called\n");
if (_bootDevice == HOST_DEV) {
- printf("OSystem_PS2::quit (HOST)\n");
+ dbg_printf("OSystem_PS2::quit (HOST)\n");
+ #ifndef ENABLE_PROFILING
SleepThread();
+ #endif
} else {
- printf("OSystem_PS2::quit (bootdev=%d)\n", _bootDevice);
+ dbg_printf("OSystem_PS2::quit (bootdev=%d)\n", _bootDevice);
if (_useHdd) {
driveStandby();
fio.umount("pfs0:");
@@ -781,18 +911,22 @@ void OSystem_PS2::quit(void) {
//setTimerCallback(NULL, 0);
_screen->wantAnim(false);
_systemQuit = true;
+ #ifdef __NEW_PS2SDK__
+ ee_thread_status_t statSound, statTimer;
+ #else
ee_thread_t statSound, statTimer;
- printf("Waiting for timer and sound thread to end\n");
+ #endif
+ dbg_printf("Waiting for timer and sound thread to end\n");
do { // wait until both threads called ExitThread()
ReferThreadStatus(_timerTid, &statTimer);
ReferThreadStatus(_soundTid, &statSound);
} while ((statSound.status != 0x10) || (statTimer.status != 0x10));
- printf("Done\n");
+ dbg_printf("Done\n");
DeleteThread(_timerTid);
DeleteThread(_soundTid);
free(_timerStack);
free(_soundStack);
- printf("Stopping timer\n");
+ dbg_printf("Stopping timer\n");
DisableIntc(INT_TIMER0);
RemoveIntcHandler(INT_TIMER0, _intrId);
@@ -801,7 +935,7 @@ void OSystem_PS2::quit(void) {
padEnd(); // stop pad library
cdvdInit(CDVD_EXIT);
- printf("resetting iop\n");
+ dbg_printf("resetting iop\n");
SifIopReset(NULL, 0);
SifExitRpc();
while (!SifIopSync());
@@ -829,7 +963,7 @@ void OSystem_PS2::quit(void) {
" li $3, 0x04;"
" syscall;"
" nop;"
- );
+ );
*/
/*
@@ -839,7 +973,7 @@ void OSystem_PS2::quit(void) {
*/
#else
// reset + load ELF from CD
- printf("Restarting ScummVM\n");
+ dbg_printf("Restarting ScummVM\n");
LoadExecPS2("cdrom0:\\SCUMMVM.ELF", 0, NULL);
#endif
}
@@ -856,12 +990,12 @@ bool OSystem_PS2::prepMC() {
if (!mcPresent())
return prep;
- printf("prepMC 0\n");
+ dbg_printf("prepMC 0\n");
// Common::String str("mc0:ScummVM/")
// Common::FSNode scumDir(str);
Common::FSNode scumDir("mc0:ScummVM/");
- printf("prepMC 00\n");
+ dbg_printf("prepMC 00\n");
if (!scumDir.exists()) {
uint16 *data, size;
@@ -869,11 +1003,11 @@ bool OSystem_PS2::prepMC() {
PS2Icon _ico;
mcIcon icon;
- printf("prepMC I\n");
+ dbg_printf("prepMC I\n");
size = _ico.decompressData(&data);
- printf("prepMC II\n");
+ dbg_printf("prepMC II\n");
_ico.setup(&icon);
@@ -888,21 +1022,21 @@ bool OSystem_PS2::prepMC() {
fio.mkdir("mc0:ScummVM");
f = ps2_fopen("mc0:ScummVM/scummvm.icn", "w");
- printf("f = %p\n", (const void *)f);
+ dbg_printf("f = %p\n", (const void *)f);
ps2_fwrite(data, size, 2, f);
ps2_fclose(f);
f = ps2_fopen("mc0:ScummVM/icon.sys", "w");
- printf("f = %p\n", (const void *)f);
+ dbg_printf("f = %p\n", (const void *)f);
ps2_fwrite(&icon, sizeof(icon), 1, f);
ps2_fclose(f);
#endif
free(data);
- printf("prepMC II\n");
+ dbg_printf("prepMC II\n");
prep = true;
}
@@ -911,7 +1045,7 @@ bool OSystem_PS2::prepMC() {
}
void OSystem_PS2::makeConfigPath() {
- FILE *src, *dst;
+ FILE *src, *dst;
char path[128], *buf;
int32 size;
@@ -926,7 +1060,7 @@ void OSystem_PS2::makeConfigPath() {
src = ps2_fopen("cdfs:ScummVM.ini", "r");
if (src) {
size = ((Ps2File *)src)->size();
- buf = (char *)malloc(size);
+ buf = (char *)memalign(64, size);
ps2_fread(buf, size, 1, src);
ps2_fclose(src);
@@ -970,6 +1104,5 @@ Common::String OSystem_PS2::getDefaultConfigFileName() {
}
void OSystem_PS2::logMessage(LogMessageType::Type type, const char *message) {
- printf("%s", message);
- sioprintf("%s", message);
+ dbg_printf("%s", message);
}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index 580eb8b6f2..45b7dfae36 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -25,6 +25,7 @@
#include "common/system.h"
#include "backends/base-backend.h"
+#include "backends/platform/ps2/irxboot.h"
#include "graphics/palette.h"
class Gs2dScreen;
@@ -51,6 +52,7 @@ public:
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
void init(void);
+ void config(void);
virtual int16 getHeight(void);
virtual int16 getWidth(void);
@@ -119,14 +121,17 @@ public:
void powerOffCallback(void);
bool mcPresent(void);
+ bool cdPresent(void);
bool hddPresent(void);
bool usbMassPresent(void);
bool netPresent(void);
+ bool hddMount(const char *partition);
bool runningFromHost(void);
int getBootDevice() { return _bootDevice; }
private:
+ bool loadDrivers(IrxType type);
void startIrxModules(int numModules, IrxReference *modules);
void initMutexes(void);
@@ -136,28 +141,28 @@ private:
Audio::MixerImpl *_scummMixer;
bool _mouseVisible;
- bool _useMouse, _useKbd, _useHdd, _usbMassLoaded, _useNet;
+ bool _useMouse, _useKbd, _useCd, _useHdd, _usbMassLoaded, _useNet;
- Gs2dScreen *_screen;
- Ps2Input *_input;
- uint16 _oldMouseX, _oldMouseY;
- uint32 _msgClearTime;
- uint16 _printY;
+ Gs2dScreen *_screen;
+ Ps2Input *_input;
+ uint16 _oldMouseX, _oldMouseY;
+ uint32 _msgClearTime;
+ uint16 _printY;
bool _modeChanged;
int _screenChangeCount;
- int _mutexSema;
- Ps2Mutex _mutex[MAX_MUTEXES];
+ int _mutexSema;
+ Ps2Mutex _mutex[MAX_MUTEXES];
- uint8 *_timerStack, *_soundStack;
- int _timerTid, _soundTid;
- int _intrId;
+ uint8 *_timerStack, *_soundStack;
+ int _timerTid, _soundTid;
+ int _intrId;
volatile bool _systemQuit;
static const GraphicsMode _graphicsMode;
- int _bootDevice;
- char *_bootPath;
- char *_configFile;
+ int _bootDevice;
+ char *_bootPath;
+ char *_configFile;
};
#endif // SYSTEMPS2_H
diff --git a/backends/plugins/elf/version.cpp b/backends/plugins/elf/version.cpp
index 48e6acd58d..ac999e1d7c 100644
--- a/backends/plugins/elf/version.cpp
+++ b/backends/plugins/elf/version.cpp
@@ -23,6 +23,10 @@
#include "backends/plugins/elf/version.h"
#ifdef USE_ELF_LOADER
-const char *gScummVMPluginBuildDate __attribute__((visibility("hidden"))) =
- __DATE__ " " __TIME__ ;
+ #ifdef __PLAYSTATION2__
+ const char *gScummVMPluginBuildDate = "Git Master"; /* ScummVM Git Master */
+ #else
+ const char *gScummVMPluginBuildDate __attribute__((visibility("hidden"))) =
+ __DATE__ " " __TIME__ ;
+ #endif
#endif
diff --git a/base/version.cpp b/base/version.cpp
index 999e90a275..fba3554f67 100644
--- a/base/version.cpp
+++ b/base/version.cpp
@@ -56,9 +56,15 @@
* to properly work in exports (i.e. release tar balls etc.).
*/
const char *gScummVMVersion = SCUMMVM_VERSION;
+#ifdef __PLAYSTATION2__
+const char *gScummVMBuildDate = "Git Master"; /* ScummVM Git Master */
+const char *gScummVMVersionDate = SCUMMVM_VERSION " - PlayStation2";
+const char *gScummVMFullVersion = "ScummVM " SCUMMVM_VERSION " - PlayStation2";
+#else
const char *gScummVMBuildDate = __DATE__ " " __TIME__;
const char *gScummVMVersionDate = SCUMMVM_VERSION " (" __DATE__ " " __TIME__ ")";
const char *gScummVMFullVersion = "ScummVM " SCUMMVM_VERSION " (" __DATE__ " " __TIME__ ")";
+#endif
const char *gScummVMFeatures = ""
#ifdef TAINTED_BUILD
// TAINTED means the build contains engines/subengines not enabled by default
diff --git a/common/scummsys.h b/common/scummsys.h
index 1342b0cde6..c30bc4a52a 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -405,8 +405,13 @@
typedef unsigned int uint32;
typedef signed int int32;
typedef unsigned int uint;
+ #ifdef __PLAYSTATION2__
+ typedef signed long int64;
+ typedef unsigned long uint64;
+ #else
typedef signed long long int64;
typedef unsigned long long uint64;
+ #endif
#endif
diff --git a/configure b/configure
index 4b1bba4d3f..b901943c7e 100755
--- a/configure
+++ b/configure
@@ -1391,6 +1391,9 @@ ps2)
_host_os=ps2
_host_cpu=mips64r5900el
_host_alias=ee
+ # PS2 bogus dirs: they actually depend on launch medium
+ datadir='host:data'
+ docdir='host:docs'
;;
ps3)
_host_os=ps3
@@ -2313,6 +2316,7 @@ case $_host_os in
CXXFLAGS="$CXXFLAGS -G2"
DEFINES="$DEFINES -D_EE"
DEFINES="$DEFINES -D__PLAYSTATION2__"
+ DEFINES="$DEFINES -D__NEW_PS2SDK__"
;;
ps3)
# Force use of SDL and freetype from the ps3 toolchain
@@ -2695,6 +2699,8 @@ if test -n "$_host"; then
DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL"
DEFINES="$DEFINES -DDISABLE_SID"
DEFINES="$DEFINES -DDISABLE_NES_APU"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
+ CXXFLAGS="$CXXFLAGS -fno-rtti"
_backend="ps2"
_build_scalers=no
_mt32emu=no
@@ -2702,10 +2708,12 @@ if test -n "$_host"; then
# This trick doesn't work for tremor right now, as the PS2 port the resulting library
# libtremor, while our code later on expects it to be called libvorbisidec.
# TODO: Enable tremor, e.g. by adding -ltremor or by renaming the lib.
+ _tremor=yes
_mad=yes
_zlib=yes
# HACK to fix compilation of C source files for now.
- add_line_to_config_mk 'CC = ee-gcc'
+ add_line_to_config_mk 'CC := ee-gcc'
+ add_line_to_config_mk 'CFLAGS := -std=c99 -W -Wno-unused-parameter -Wconversion -pedantic -G2 -s -O2 -Wuninitialized'
# HACK to fix linking for now. It seems ee-g++ does not handle linking correctly.
LD=ee-gcc
@@ -3222,9 +3230,10 @@ POST_OBJS_FLAGS := -Wl,--export-all-symbols -Wl,--no-whole-archive -Wl,--out-im
;;
ps2)
_elf_loader=yes
+ DEFINES="$DEFINES -DUNCACHED_PLUGINS"
_mak_plugins='
-LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/main_prog.ld
-PLUGIN_LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/plugin.ld -lstdc++ -lc
+LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/main_prog.ld
+PLUGIN_LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -Wl,-T$(srcdir)/backends/plugins/ps2/plugin.ld -lstdc++ -lc
'
;;
psp)
@@ -3360,6 +3369,8 @@ if test "$_tremor" = yes && test "$_vorbis" = no; then
if test "$_tremolo" = yes ; then
add_line_to_config_h '#define USE_TREMOLO'
LIBS="$LIBS $TREMOR_LIBS -ltremolo"
+ elif test "$_host" = ps2 ; then
+ LIBS="-ltremor $LIBS"
else
LIBS="$LIBS $TREMOR_LIBS -lvorbisidec"
fi
@@ -4122,6 +4133,10 @@ case $_backend in
# without a scummvm sub directory.
DEFINES="$DEFINES -DPLUGIN_DIRECTORY=\\\"$libdir\\\""
;;
+ ps2)
+ # PS2 bogus dir: it actually depends on launch medium
+ DEFINES="$DEFINES -DPLUGIN_DIRECTORY=\\\"host:plugins\\\""
+ ;;
*)
DEFINES="$DEFINES -DPLUGIN_DIRECTORY=\\\"$libdir/scummvm\\\""
;;
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
index 65840ae174..8498e50b8d 100644
--- a/engines/dialogs.cpp
+++ b/engines/dialogs.cpp
@@ -217,6 +217,11 @@ void MainMenuDialog::reflowLayout() {
void MainMenuDialog::save() {
int slot = _saveDialog->runModalWithCurrentTarget();
+ #if defined(__PLAYSTATION2__) && defined(DYNAMIC_MODULES)
+ char pokeme[32];
+ snprintf(pokeme,32,"hack");
+ #endif
+
if (slot >= 0) {
Common::String result(_saveDialog->getResultString());
if (result.empty()) {
diff --git a/engines/sword25/util/lua/loslib.cpp b/engines/sword25/util/lua/loslib.cpp
index 25bfa2d1b5..055dfdf19e 100644
--- a/engines/sword25/util/lua/loslib.cpp
+++ b/engines/sword25/util/lua/loslib.cpp
@@ -113,6 +113,9 @@ static int getfield (lua_State *L, const char *key, int d) {
static int os_date (lua_State *L) {
+ #ifdef __PLAYSTATION2__ // missing: gmtime & strftime
+ lua_pushnil(L);
+ #else
const char *s = luaL_optstring(L, 1, "%c");
// FIXME: Rewrite the code below to use OSystem::getTimeAndDate
// Alternatively, remove it, if sword25 does not use it.
@@ -160,6 +163,7 @@ static int os_date (lua_State *L) {
}
luaL_pushresult(&b);
}
+ #endif
return 1;
}
@@ -167,6 +171,9 @@ static int os_date (lua_State *L) {
static int os_time (lua_State *L) {
// FIXME: Rewrite the code below to use OSystem::getTimeAndDate.
// Alternatively, remove it, if sword25 does not use it.
+ #ifdef __PLAYSTATION2__ // missing: mktime
+ lua_pushnil(L);
+ #else
time_t t;
if (lua_isnoneornil(L, 1)) /* called without args? */
t = time(NULL); /* get current time */
@@ -187,6 +194,7 @@ static int os_time (lua_State *L) {
lua_pushnil(L);
else
lua_pushnumber(L, (lua_Number)t);
+ #endif
return 1;
}
@@ -195,8 +203,10 @@ static int os_difftime (lua_State *L) {
// FIXME: difftime is not portable, unfortunately.
// So we either have to replace this code, or just remove it,
// depending on whether sword25 actually uses it.
+ #ifndef __PLAYSTATION2__ // missing: difftime
lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
(time_t)(luaL_optnumber(L, 2, 0))));
+ #endif
return 1;
}