aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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-xconfigure23
-rw-r--r--engines/cge/cge.cpp2
-rw-r--r--engines/cge/vga13h.cpp6
-rw-r--r--engines/dialogs.cpp5
-rw-r--r--engines/draci/game.cpp75
-rw-r--r--engines/draci/game.h9
-rw-r--r--engines/draci/saveload.cpp7
-rw-r--r--engines/draci/saveload.h2
-rw-r--r--engines/draci/script.cpp21
-rw-r--r--engines/draci/walking.cpp10
-rw-r--r--engines/draci/walking.h5
-rw-r--r--engines/fullpipe/constants.h47
-rw-r--r--engines/fullpipe/fullpipe.cpp12
-rw-r--r--engines/fullpipe/fullpipe.h13
-rw-r--r--engines/fullpipe/input.cpp33
-rw-r--r--engines/fullpipe/messagehandlers.cpp62
-rw-r--r--engines/fullpipe/messages.cpp4
-rw-r--r--engines/fullpipe/messages.h1
-rw-r--r--engines/fullpipe/modal.cpp177
-rw-r--r--engines/fullpipe/modal.h37
-rw-r--r--engines/fullpipe/motion.cpp244
-rw-r--r--engines/fullpipe/motion.h5
-rw-r--r--engines/fullpipe/scenes.cpp4
-rw-r--r--engines/fullpipe/sound.cpp301
-rw-r--r--engines/fullpipe/sound.h14
-rw-r--r--engines/fullpipe/statics.cpp55
-rw-r--r--engines/fullpipe/statics.h3
-rw-r--r--engines/pegasus/menu.cpp2
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoria.cpp4
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp15
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoriabomb.h3
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp6
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoriamessages.h2
-rw-r--r--engines/pegasus/neighborhood/mars/mars.cpp11
-rw-r--r--engines/pegasus/neighborhood/neighborhood.cpp11
-rw-r--r--engines/pegasus/neighborhood/neighborhood.h2
-rw-r--r--engines/pegasus/neighborhood/norad/delta/globegame.cpp5
-rw-r--r--engines/pegasus/neighborhood/norad/delta/globegame.h2
-rw-r--r--engines/pegasus/neighborhood/norad/delta/noraddelta.cpp18
-rw-r--r--engines/pegasus/neighborhood/norad/delta/noraddelta.h3
-rw-r--r--engines/pegasus/pegasus.cpp7
-rw-r--r--engines/sci/detection_tables.h18
-rw-r--r--engines/sword25/util/lua/loslib.cpp10
-rw-r--r--gui/dialog.cpp13
-rw-r--r--gui/widgets/tab.cpp29
-rw-r--r--gui/widgets/tab.h7
89 files changed, 2683 insertions, 914 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..f0c01cea42 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,9 @@ case $_host_os in
CXXFLAGS="$CXXFLAGS -G2"
DEFINES="$DEFINES -D_EE"
DEFINES="$DEFINES -D__PLAYSTATION2__"
+ if test -z "$PS2SDK_OLD"; then
+ DEFINES="$DEFINES -D__NEW_PS2SDK__"
+ fi
;;
ps3)
# Force use of SDL and freetype from the ps3 toolchain
@@ -2695,6 +2701,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 +2710,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 +3232,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 +3371,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 +4135,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/cge/cge.cpp b/engines/cge/cge.cpp
index 3f7aa4abc9..7058314b9d 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -219,7 +219,7 @@ Common::Error CGEEngine::run() {
}
// Initialize graphics using following:
- initGraphics(320, 200, false);
+ initGraphics(kScrWidth, kScrHeight, false);
// Setup necessary game objects
init();
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index d5e1be5122..d7dccd2c65 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -819,14 +819,14 @@ void Vga::update() {
_setPal = false;
}
if (_vm->_showBoundariesFl) {
- Vga::_page[0]->hLine(0, 200 - kPanHeight, 320, 0xee);
+ Vga::_page[0]->hLine(0, kScrHeight - kPanHeight, kScrWidth, 0xee);
if (_vm->_barriers[_vm->_now]._horz != 255) {
for (int i = 0; i < 8; i++)
- Vga::_page[0]->vLine((_vm->_barriers[_vm->_now]._horz * 8) + i, 0, 200, 0xff);
+ Vga::_page[0]->vLine((_vm->_barriers[_vm->_now]._horz * 8) + i, 0, kScrHeight, 0xff);
}
if (_vm->_barriers[_vm->_now]._vert != 255) {
for (int i = 0; i < 4; i++)
- Vga::_page[0]->hLine(0, 80 + (_vm->_barriers[_vm->_now]._vert * 4) + i, 320, 0xff);
+ Vga::_page[0]->hLine(0, 80 + (_vm->_barriers[_vm->_now]._vert * 4) + i, kScrWidth, 0xff);
}
}
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/draci/game.cpp b/engines/draci/game.cpp
index e5ff1f079a..4893b0fe34 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -72,6 +72,7 @@ Game::Game(DraciEngine *vm) : _vm(vm), _walkingState(vm) {
_fadePhases = 0;
_fadePhase = 0;
_fadeTick = 0;
+ _isFadeOut = 1;
_mouseChangeTick = 0;
_enableQuickHero = 0;
_wantQuickHero = 0;
@@ -216,6 +217,7 @@ void Game::start() {
// init scripts. This flag was turned on to skip the rest of
// those programs. Don't call loop(), because the
// location may have changed.
+ fadePalette(true);
continue;
}
@@ -478,6 +480,7 @@ void Game::handleDialogueLoop() {
}
void Game::fadePalette(bool fading_out) {
+ _isFadeOut = fading_out;
const byte *startPal = NULL;
const byte *endPal = _currentRoom._palette >= 0
? _vm->_paletteArchive->getFile(_currentRoom._palette)->_data
@@ -551,6 +554,19 @@ void Game::advanceAnimationsAndTestLoopExit() {
_vm->_anims->drawScene(_vm->_screen->getSurface());
_vm->_screen->copyToScreen();
_vm->_system->delayMillis(kTimeUnit);
+ if(_isFadeOut) {
+ fadePalette(false);
+ // Set cursor state
+ // Need to do this after we set the palette since the cursors use it
+ if (_currentRoom._mouseOn) {
+ debugC(6, kDraciLogicDebugLevel, "Mouse: ON");
+ _vm->_mouse->cursorOn();
+ _vm->_mouse->setCursorType(kNormalCursor);
+ } else {
+ debugC(6, kDraciLogicDebugLevel, "Mouse: OFF");
+ _vm->_mouse->cursorOff();
+ }
+ }
// If the hero has arrived at his destination, after even the last
// phase was correctly animated, run the callback.
@@ -598,6 +614,8 @@ void Game::loop(LoopSubstatus substatus, bool shouldExit) {
break;
}
+ advanceAnimationsAndTestLoopExit();
+
if (_vm->_mouse->isCursorOn()) {
// Find animation under cursor and the game object
// corresponding to it
@@ -629,8 +647,6 @@ void Game::loop(LoopSubstatus substatus, bool shouldExit) {
}
}
- advanceAnimationsAndTestLoopExit();
-
} while (!shouldExitLoop());
setLoopSubstatus(kOuterLoop);
@@ -875,9 +891,6 @@ void Game::putItem(GameItem *item, int position) {
void Game::inventoryInit() {
// Pause all "background" animations
_vm->_anims->pauseAnimations();
- if (_walkingState.isActive()) {
- walkHero(_hero.x, _hero.y, kDirectionLast);
- }
// Draw the inventory and the current items
inventoryDraw();
@@ -888,6 +901,13 @@ void Game::inventoryInit() {
// Set the appropriate loop status
setLoopStatus(kStatusInventory);
+ if (_walkingState.isActive()) {
+ _walkingState.stopWalking();
+ walkHero(_hero.x, _hero.y, kDirectionLast);
+ } else {
+ _lastTarget = _hero;
+ }
+
// Don't return from the inventory mode immediately if the mouse is out.
_mouseChangeTick = kMouseDoNotSwitch;
}
@@ -906,6 +926,10 @@ void Game::inventoryDone() {
}
}
+ // Start moving to last target
+ walkHero(_lastTarget.x, _lastTarget.y, kDirectionLast);
+ _walkingState.callbackLast();
+
// Reset item under cursor
_itemUnderCursor = NULL;
@@ -926,10 +950,12 @@ void Game::inventoryDraw() {
void Game::inventoryReload() {
// Make sure all items are loaded into memory (e.g., after loading a
// savegame) by re-putting them on the same spot in the inventory.
+ GameItem *tempItem = _currentItem;
for (uint i = 0; i < kInventorySlots; ++i) {
putItem(_inventory[i], i);
}
setPreviousItemPosition(0);
+ _currentItem = tempItem;
}
void Game::inventorySwitch(int keycode) {
@@ -1190,6 +1216,12 @@ void Game::walkHero(int x, int y, SightDirection dir) {
debug(1, "Unreachable point [%d,%d]", target.x, target.y);
return;
}
+
+ // Save point of player's last target.
+ if (_loopStatus != kStatusInventory) {
+ _lastTarget = target;
+ }
+
_walkingMap.obliquePath(shortestPath, &obliquePath);
debugC(2, kDraciWalkingDebugLevel, "Walking path lengths: shortest=%d oblique=%d", shortestPath.size(), obliquePath.size());
if (_vm->_showWalkingMap) {
@@ -1433,7 +1465,6 @@ void Game::enterNewRoom() {
_vm->_screen->setPalette(NULL, 0, kNumColors);
_vm->_anims->drawScene(_vm->_screen->getSurface());
_vm->_screen->copyToScreen();
- fadePalette(false);
// Run the program for the gate the dragon came through
debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", _newGate);
@@ -1446,17 +1477,6 @@ void Game::enterNewRoom() {
// Don't immediately switch to the map or inventory even if the mouse
// position tell us to.
_mouseChangeTick = kMouseDoNotSwitch;
-
- // Set cursor state
- // Need to do this after we set the palette since the cursors use it
- if (_currentRoom._mouseOn) {
- debugC(6, kDraciLogicDebugLevel, "Mouse: ON");
- _vm->_mouse->cursorOn();
- _vm->_mouse->setCursorType(kNormalCursor);
- } else {
- debugC(6, kDraciLogicDebugLevel, "Mouse: OFF");
- _vm->_mouse->cursorOff();
- }
}
void Game::positionAnimAsHero(Animation *anim) {
@@ -1572,7 +1592,7 @@ Game::~Game() {
delete[] _items;
}
-void Game::DoSync(Common::Serializer &s) {
+void Game::DoSync(Common::Serializer &s, uint8 saveVersion) {
s.syncAsUint16LE(_currentRoom._roomNum);
for (uint i = 0; i < _info._numObjects; ++i) {
@@ -1603,6 +1623,25 @@ void Game::DoSync(Common::Serializer &s) {
s.syncAsSint16LE(_dialogueVars[i]);
}
+ if(saveVersion >= 2) {
+ setPositionLoaded(true);
+ if (s.isSaving()) {
+ s.syncAsSint16LE(_hero.x);
+ s.syncAsSint16LE(_hero.y);
+
+ int handItemID = _currentItem ? _currentItem->_absNum : -1;
+ s.syncAsSint16LE(handItemID);
+ } else {
+ s.syncAsSint16LE(_heroLoading.x);
+ s.syncAsSint16LE(_heroLoading.y);
+
+ int handItemID = -1;
+ s.syncAsSint16LE(handItemID);
+ _currentItem = getItem(handItemID);
+ }
+ } else {
+ _currentItem = 0;
+ }
}
static double real_to_double(byte real[6]) {
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 4a8f3de269..53a472a552 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -215,6 +215,7 @@ public:
void walkHero(int x, int y, SightDirection dir); // start walking and leave callback as is
void setHeroPosition(const Common::Point &p);
const Common::Point &getHeroPosition() const { return _hero; }
+ const Common::Point &getHeroLoadingPosition() const { return _heroLoading; }
void positionAnimAsHero(Animation *anim);
void positionHeroAsAnim(Animation *anim);
@@ -290,6 +291,8 @@ public:
void setExitLoop(bool exit) { _shouldExitLoop = exit; }
bool isReloaded() const { return _isReloaded; }
void setIsReloaded(bool value) { _isReloaded = value; }
+ bool isPositionLoaded() { return _isPositionLoaded; }
+ void setPositionLoaded(bool value) { _isPositionLoaded = value; }
void setSpeechTiming(uint tick, uint duration);
void shiftSpeechAndFadeTick(int delta);
@@ -327,7 +330,7 @@ public:
void setEnableSpeedText(bool value) { _enableSpeedText = value; }
bool getEnableSpeedText() const { return _enableSpeedText; }
- void DoSync(Common::Serializer &s);
+ void DoSync(Common::Serializer &s, uint8 saveVersion);
private:
void updateOrdinaryCursor();
@@ -352,6 +355,8 @@ private:
GameInfo _info;
Common::Point _hero;
+ Common::Point _heroLoading;
+ Common::Point _lastTarget;
int *_variables;
Person *_persons;
@@ -395,6 +400,7 @@ private:
bool _shouldQuit;
bool _shouldExitLoop;
bool _isReloaded;
+ bool _isPositionLoaded;
uint _speechTick;
uint _speechDuration;
@@ -408,6 +414,7 @@ private:
int _fadePhases;
int _fadePhase;
uint _fadeTick;
+ bool _isFadeOut;
int _mouseChangeTick;
bool _enableQuickHero;
diff --git a/engines/draci/saveload.cpp b/engines/draci/saveload.cpp
index 31ac63b791..3e7f8651c1 100644
--- a/engines/draci/saveload.cpp
+++ b/engines/draci/saveload.cpp
@@ -45,7 +45,8 @@ bool readSavegameHeader(Common::InSaveFile *in, DraciSavegameHeader &header) {
return false;
header.version = in->readByte();
- if (header.version != DRACI_SAVEGAME_VERSION)
+ // Version 1 is compatible with Version 2
+ if (header.version > DRACI_SAVEGAME_VERSION)
return false;
// Read in the string
@@ -106,7 +107,7 @@ Common::Error saveSavegameData(int saveGameIdx, const Common::String &saveName,
} else {
// Create the remainder of the savegame
Common::Serializer s(NULL, f);
- vm._game->DoSync(s);
+ vm._game->DoSync(s, header.version);
f->finalize();
delete f;
@@ -140,7 +141,7 @@ Common::Error loadSavegameData(int saveGameIdx, DraciEngine *vm) {
// Synchronise the remaining data of the savegame
Common::Serializer s(f, NULL);
- vm->_game->DoSync(s);
+ vm->_game->DoSync(s, header.version);
delete f;
// Post-processing
diff --git a/engines/draci/saveload.h b/engines/draci/saveload.h
index 8b38ccb94f..6f951a3409 100644
--- a/engines/draci/saveload.h
+++ b/engines/draci/saveload.h
@@ -29,7 +29,7 @@
namespace Draci {
-#define DRACI_SAVEGAME_VERSION 1
+#define DRACI_SAVEGAME_VERSION 2
struct DraciSavegameHeader {
uint8 version;
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 97dde39809..09c74f5e0d 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -634,8 +634,16 @@ void Script::stayOn(const Common::Array<int> &params) {
return;
}
- int x = params[0];
- int y = params[1];
+ int x, y;
+ Common::Point afterLoadingPos = _vm->_game->getHeroLoadingPosition();
+ if(_vm->_game->isPositionLoaded() == true) {
+ x = afterLoadingPos.x;
+ y = afterLoadingPos.y;
+ }
+ else {
+ x = params[0];
+ y = params[1];
+ }
SightDirection dir = static_cast<SightDirection> (params[2]);
// Jumps into the given position regardless of the walking map.
@@ -670,6 +678,11 @@ void Script::walkOnPlay(const Common::Array<int> &params) {
return;
}
+ if(_vm->_game->isPositionLoaded() == true) {
+ _vm->_game->setPositionLoaded(false);
+ return;
+ }
+
int x = params[0];
int y = params[1];
SightDirection dir = static_cast<SightDirection> (params[2]);
@@ -687,6 +700,10 @@ void Script::newRoom(const Common::Array<int> &params) {
return;
}
+ if(_vm->_game->isPositionLoaded() == true) {
+ _vm->_game->setPositionLoaded(false);
+ }
+
int room = params[0] - 1;
int gate = params[1] - 1;
diff --git a/engines/draci/walking.cpp b/engines/draci/walking.cpp
index 1467ecee35..6914898ec1 100644
--- a/engines/draci/walking.cpp
+++ b/engines/draci/walking.cpp
@@ -439,8 +439,8 @@ void WalkingState::startWalking(const Common::Point &p1, const Common::Point &p2
}
void WalkingState::setCallback(const GPL2Program *program, uint16 offset) {
- _callback = program;
- _callbackOffset = offset;
+ _callback = _callbackLast = program;
+ _callbackOffset = _callbackOffsetLast = offset;
}
void WalkingState::callback() {
@@ -452,6 +452,12 @@ void WalkingState::callback() {
const GPL2Program &originalCallback = *_callback;
_callback = NULL;
_vm->_script->runWrapper(originalCallback, _callbackOffset, true, false);
+ _callbackLast = NULL;
+ _callbackOffset = NULL;
+}
+
+void WalkingState::callbackLast() {
+ setCallback(_callbackLast, _callbackOffsetLast);
}
bool WalkingState::continueWalkingOrClearPath() {
diff --git a/engines/draci/walking.h b/engines/draci/walking.h
index ee2b48d083..fcdef3830e 100644
--- a/engines/draci/walking.h
+++ b/engines/draci/walking.h
@@ -110,6 +110,8 @@ public:
_lastAnimPhase = 0;
_turningFinished = 0;
_callbackOffset = 0;
+ _callbackOffsetLast = 0;
+ _callbackLast = 0;
stopWalking();
}
@@ -124,6 +126,7 @@ public:
void setCallback(const GPL2Program *program, uint16 offset);
void callback();
+ void callbackLast();
bool isActive() const { return _path.size() > 0; }
@@ -157,7 +160,9 @@ private:
bool _turningFinished;
const GPL2Program *_callback;
+ const GPL2Program *_callbackLast;
uint16 _callbackOffset;
+ uint16 _callbackOffsetLast;
// Initiates turning of the dragon into the direction for the next
// segment / after walking. Returns false when there is nothing left
diff --git a/engines/fullpipe/constants.h b/engines/fullpipe/constants.h
index 8f3f587714..b257fca949 100644
--- a/engines/fullpipe/constants.h
+++ b/engines/fullpipe/constants.h
@@ -43,6 +43,8 @@ namespace Fullpipe {
#define MV_LFT_OPEN 1048
#define MV_MAN_GOLADDER 451
#define MV_MAN_GOLADDER2 2844
+#define MV_MAN_HMRKICK 1028
+#define MV_MAN_HMRKICK_COINLESS 1445
#define MV_MAN_LIFTDOWN 1052
#define MV_MAN_LIFTUP 1051
#define MV_MAN_LOOKUP 4773
@@ -219,8 +221,11 @@ namespace Fullpipe {
#define SC_MAINMENU 4620
#define SC_MAP 5222
#define SC_TITLES 5166
+#define SND_CMN_015 3139
#define SND_CMN_031 3516
#define SND_CMN_032 3517
+#define SND_CMN_054 4762
+#define SND_CMN_055 4763
#define SND_CMN_060 4921
#define SND_CMN_061 4922
#define SND_CMN_070 5199
@@ -287,6 +292,48 @@ namespace Fullpipe {
#define PIC_MOV_CANCEL 5345
#define PIC_MOV_OK 5344
+// Saveload dialog
+#define PIC_MLD_BGR 4645
+#define PIC_MLD_CANCEL_D 4648
+#define PIC_MLD_CANCEL_L 4649
+#define PIC_MLD_OK_D 4646
+#define PIC_MLD_OK_L 4647
+#define PIC_MSV_0_D 4643
+#define PIC_MSV_0_L 4644
+#define PIC_MSV_1_D 4651
+#define PIC_MSV_1_L 4660
+#define PIC_MSV_2_D 4652
+#define PIC_MSV_2_L 4661
+#define PIC_MSV_3_D 4653
+#define PIC_MSV_3_L 4662
+#define PIC_MSV_4_D 4654
+#define PIC_MSV_4_L 4663
+#define PIC_MSV_5_D 4655
+#define PIC_MSV_5_L 4664
+#define PIC_MSV_6_D 4656
+#define PIC_MSV_6_L 4665
+#define PIC_MSV_7_D 4657
+#define PIC_MSV_7_L 4666
+#define PIC_MSV_8_D 4658
+#define PIC_MSV_8_L 4667
+#define PIC_MSV_9_D 4659
+#define PIC_MSV_9_L 4668
+#define PIC_MSV_BGR 4634
+#define PIC_MSV_CANCEL_D 4637
+#define PIC_MSV_CANCEL_L 4638
+#define PIC_MSV_DOTS_D 4670
+#define PIC_MSV_DOTS_L 4669
+#define PIC_MSV_DOT_D 5188
+#define PIC_MSV_DOT_L 5189
+#define PIC_MSV_EMPTY_D 4639
+#define PIC_MSV_EMPTY_L 4640
+#define PIC_MSV_FULL_D 4641
+#define PIC_MSV_FULL_L 4642
+#define PIC_MSV_OK_D 4635
+#define PIC_MSV_OK_L 4636
+#define PIC_MSV_SPACE_D 5190
+#define PIC_MSV_SPACE_L 5191
+
// Intro
#define ANI_IN1MAN 5110
#define MSG_INTR_ENDINTRO 5139
diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp
index 246510e227..5369c05de7 100644
--- a/engines/fullpipe/fullpipe.cpp
+++ b/engines/fullpipe/fullpipe.cpp
@@ -104,6 +104,18 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc)
_musicAllowed = -1;
_musicGameVar = 0;
+ _musicMinDelay = 0;
+ _musicMaxDelay = 0;
+ _musicLocal = 0;
+ _trackStartDelay = 0;
+
+ memset(_sceneTracks, 0, sizeof(_sceneTracks));
+ memset(_trackName, 0, sizeof(_trackName));
+ memset(_sceneTracksCurrentTrack, 0, sizeof(_sceneTracksCurrentTrack));
+
+ _numSceneTracks = 0;
+ _sceneTrackHasSequence = false;
+ _sceneTrackIsPlaying = false;
_aniMan = 0;
_aniMan2 = 0;
diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h
index 5718b16ab3..27505252ab 100644
--- a/engines/fullpipe/fullpipe.h
+++ b/engines/fullpipe/fullpipe.h
@@ -151,12 +151,24 @@ public:
int _currSoundListCount;
bool _soundEnabled;
bool _flgSoundList;
+ char _sceneTracks[10][260];
+ int _numSceneTracks;
+ bool _sceneTrackHasSequence;
+ int _musicMinDelay;
+ int _musicMaxDelay;
+ int _musicLocal;
+ char _trackName[2600];
+ int _trackStartDelay;
+ char _sceneTracksCurrentTrack[260];
+ bool _sceneTrackIsPlaying;
void stopAllSounds();
void toggleMute();
void playSound(int id, int flag);
void playTrack(GameVar *sceneVar, const char *name, bool delayed);
+ int getSceneTrack();
void startSceneTrack();
+ void startSoundStream1(char *trackName);
void stopSoundStream2();
void stopAllSoundStreams();
void stopAllSoundInstances(int id);
@@ -300,6 +312,7 @@ public:
GameVar *_musicGameVar;
Audio::SoundHandle _sceneTrackHandle;
+
public:
bool _isSaveAllowed;
diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp
index 0678d15368..7c97461a24 100644
--- a/engines/fullpipe/input.cpp
+++ b/engines/fullpipe/input.cpp
@@ -275,6 +275,8 @@ void FullpipeEngine::updateCursorCommon() {
}
void FullpipeEngine::initArcadeKeys(const char *varname) {
+ _arcadeKeys.clear();
+
GameVar *var = getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("KEYPOS");
if (!var)
@@ -294,6 +296,37 @@ void FullpipeEngine::initArcadeKeys(const char *varname) {
}
}
+void FullpipeEngine::processArcade(ExCommand *cmd) {
+ if (!g_fp->_aniMan2)
+ return;
+
+ int idx;
+
+ if (cmd->_sceneClickX <= g_fp->_aniMan2->_ox) {
+ for (idx = (int)_arcadeKeys.size() - 1; idx >= 0; idx--) {
+ if (_arcadeKeys[idx]->x < g_fp->_aniMan2->_ox)
+ break;
+ }
+
+ if (idx < 0)
+ return;
+ } else {
+ for (idx = 0; idx < (int)_arcadeKeys.size(); idx++) {
+ if (_arcadeKeys[idx]->x > g_fp->_aniMan2->_ox)
+ break;
+ }
+
+ if (idx >= (int)_arcadeKeys.size())
+ return;
+ }
+
+ cmd->_sceneClickX = _arcadeKeys[idx]->x;
+ cmd->_sceneClickY = _arcadeKeys[idx]->y;
+
+ cmd->_x = cmd->_sceneClickX - g_fp->_sceneRect.left;
+ cmd->_y = cmd->_sceneClickY - g_fp->_sceneRect.top;
+}
+
void FullpipeEngine::setArcadeOverlay(int picId) {
Common::Point point;
Common::Point point2;
diff --git a/engines/fullpipe/messagehandlers.cpp b/engines/fullpipe/messagehandlers.cpp
index 17af2bf4fd..15aa78d342 100644
--- a/engines/fullpipe/messagehandlers.cpp
+++ b/engines/fullpipe/messagehandlers.cpp
@@ -34,11 +34,69 @@
namespace Fullpipe {
void global_messageHandler_KickStucco() {
- warning("STUB: global_messageHandler_KickStucco()");
+ Movement *mov = g_fp->_aniMan->getMovementById(MV_MAN_HMRKICK);
+ int end = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ bool flip = false;
+
+ for (int i = 0; i < end; i++) {
+ ExCommand *ex = mov->getDynamicPhaseByIndex(i)->_exCommand;
+
+ if (ex)
+ if (ex->_messageKind == 35)
+ if (ex->_messageNum == SND_CMN_015) {
+ if (flip) {
+ ex->_messageNum = SND_CMN_055;
+ } else {
+ ex->_messageNum = SND_CMN_054;
+ flip = true;
+ }
+ }
+ }
+
+ mov = g_fp->_aniMan->getMovementById(MV_MAN_HMRKICK_COINLESS);
+ end = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ flip = false;
+
+ for (int i = 0; i < end; i++) {
+ ExCommand *ex = mov->getDynamicPhaseByIndex(i)->_exCommand;
+
+ if (ex)
+ if (ex->_messageKind == 35)
+ if (ex->_messageNum == SND_CMN_015) {
+ if (flip) {
+ ex->_messageNum = SND_CMN_055;
+ } else {
+ ex->_messageNum = SND_CMN_054;
+ flip = true;
+ }
+ }
+ }
}
void global_messageHandler_KickMetal() {
- warning("STUB: global_messageHandler_KickMetal()");
+ Movement *mov = g_fp->_aniMan->getMovementById(MV_MAN_HMRKICK);
+ int end = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+
+ for (int i = 0; i < end; i++) {
+ ExCommand *ex = mov->getDynamicPhaseByIndex(i)->_exCommand;
+
+ if (ex)
+ if (ex->_messageKind == 35)
+ if (ex->_messageNum == SND_CMN_054 || ex->_messageNum == SND_CMN_055)
+ ex->_messageNum = SND_CMN_015;
+ }
+
+ mov = g_fp->_aniMan->getMovementById(MV_MAN_HMRKICK_COINLESS);
+ end = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+
+ for (int i = 0; i < end; i++) {
+ ExCommand *ex = mov->getDynamicPhaseByIndex(i)->_exCommand;
+
+ if (ex)
+ if (ex->_messageKind == 35)
+ if (ex->_messageNum == SND_CMN_054 || ex->_messageNum == SND_CMN_055)
+ ex->_messageNum = SND_CMN_015;
+ }
}
int global_messageHandler1(ExCommand *cmd) {
diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp
index 9c8f5ac4e2..8257d1459f 100644
--- a/engines/fullpipe/messages.cpp
+++ b/engines/fullpipe/messages.cpp
@@ -699,6 +699,10 @@ void GlobalMessageQueueList::addMessageQueue(MessageQueue *msg) {
push_back(msg);
}
+void clearGlobalMessageQueueList() {
+ g_fp->_globalMessageQueueList->clear();
+}
+
void clearGlobalMessageQueueList1() {
clearMessages();
diff --git a/engines/fullpipe/messages.h b/engines/fullpipe/messages.h
index da579d58c0..e6f7f05150 100644
--- a/engines/fullpipe/messages.h
+++ b/engines/fullpipe/messages.h
@@ -193,6 +193,7 @@ void clearMessageHandlers();
void processMessages();
void updateGlobalMessageQueue(int id, int objid);
void clearMessages();
+void clearGlobalMessageQueueList();
void clearGlobalMessageQueueList1();
bool chainQueue(int queueId, int flags);
diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp
index 65274bfcf1..bba5df0cd5 100644
--- a/engines/fullpipe/modal.cpp
+++ b/engines/fullpipe/modal.cpp
@@ -1446,18 +1446,187 @@ bool ModalQuery::init(int counterdiff) {
}
ModalSaveGame::ModalSaveGame() {
- warning("STUB: ModalSaveGame::ModalSaveGame()");
-
_oldBgX = 0;
_oldBgY = 0;
+
+ _bgr = 0;
+ _okD = 0;
+ _okL = 0;
+ _cancelD = 0;
+ _cancelL = 0;
+ _emptyD = 0;
+ _emptyL = 0;
+ _queryRes = -1;
+ _rect = g_fp->_sceneRect;
+ _queryDlg = 0;
+ _mode = 1;
+}
+
+ModalSaveGame::~ModalSaveGame() {
+ g_fp->_sceneRect = _rect;
+
+ _arrayD.clear();
+ _arrayL.clear();
+
+ for (uint i = 0; i < _files.size(); i++)
+ free(_files[i]);
+
+ _files.clear();
}
void ModalSaveGame::setScene(Scene *sc) {
- warning("STUB: ModalSaveGame::setScene()");
+ _queryRes = -1;
+ _menuScene = sc;
+}
+
+void ModalSaveGame::processKey(int key) {
+ if (key == 27)
+ _queryRes = 0;
+}
+
+bool ModalSaveGame::init(int counterdiff) {
+ if (_queryDlg) {
+ if (!_queryDlg->init(counterdiff)) {
+ if (!_queryDlg->getQueryResult())
+ _queryRes = -1;
+
+ delete _queryDlg;
+ _queryDlg = 0;
+ }
+
+ return true;
+ }
+
+ if (_queryRes == -1)
+ return true;
+
+ g_fp->_sceneRect = _rect;
+
+ if (g_fp->_currentScene) {
+ g_fp->_currentScene->_x = _oldBgX;
+ g_fp->_currentScene->_y = _oldBgY;
+ }
+
+ if (!_queryRes) {
+ ModalMainMenu *m = new ModalMainMenu;
+
+ g_fp->_modalObject = m;
+
+ m->_parentObj = _parentObj;
+ m->_screct = _rect;
+ m->_bgX = _oldBgX;
+ m->_bgY = _oldBgY;
+
+ delete this;
+
+ return true;
+ }
+
+ return false;
}
void ModalSaveGame::setup(Scene *sc, int mode) {
- warning("STUB: ModalSaveGame::setup()");
+ _files.clear();
+ _arrayL.clear();
+ _arrayD.clear();
+ _mode = mode;
+
+ if (mode) {
+ _bgr = sc->getPictureObjectById(PIC_MSV_BGR, 0);
+ _cancelD = sc->getPictureObjectById(PIC_MSV_CANCEL_D, 0);
+ _cancelL = sc->getPictureObjectById(PIC_MSV_CANCEL_L, 0);
+ _okD = sc->getPictureObjectById(PIC_MSV_OK_D, 0);
+ _okL = sc->getPictureObjectById(PIC_MSV_OK_L, 0);
+ _emptyD = sc->getPictureObjectById(PIC_MSV_EMPTY_D, 0);
+ _emptyL = sc->getPictureObjectById(PIC_MSV_EMPTY_L, 0);
+ } else {
+ _bgr = sc->getPictureObjectById(PIC_MLD_BGR, 0);
+ _cancelD = sc->getPictureObjectById(PIC_MLD_CANCEL_D, 0);
+ _cancelL = sc->getPictureObjectById(PIC_MLD_CANCEL_L, 0);
+ _okD = sc->getPictureObjectById(PIC_MLD_OK_D, 0);
+ _okL = sc->getPictureObjectById(PIC_MLD_OK_L, 0);
+ _emptyD = sc->getPictureObjectById(PIC_MSV_EMPTY_D, 0);
+ _emptyL = sc->getPictureObjectById(PIC_MSV_EMPTY_D, 0);
+ }
+
+ _fullD = sc->getPictureObjectById(PIC_MSV_FULL_D, 0);
+ _fullL = sc->getPictureObjectById(PIC_MSV_FULL_L, 0);
+ _queryRes = -1;
+
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_0_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_0_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_1_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_1_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_2_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_2_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_3_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_3_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_4_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_4_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_5_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_5_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_6_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_6_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_7_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_7_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_8_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_8_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_9_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_9_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_DOTS_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_DOTS_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_DOT_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_DOT_L, 0));
+ _arrayL.push_back(sc->getPictureObjectById(PIC_MSV_SPACE_D, 0));
+ _arrayD.push_back(sc->getPictureObjectById(PIC_MSV_SPACE_L, 0));
+
+ Common::Point point;
+
+ int x = _bgr->_ox + _bgr->getDimensions(&point)->x / 2;
+ int y = _bgr->_oy + 90;
+ int w;
+ FileInfo *fileinfo;
+
+ for (int i = 0; i < 7; i++) {
+ fileinfo = new FileInfo;
+ memset(fileinfo, 0, sizeof(FileInfo));
+
+ snprintf(fileinfo->filename, 160, "save%02d.sav", i);
+
+ if (!getFileInfo(fileinfo->filename, fileinfo)) {
+ fileinfo->empty = true;
+ w = _emptyD->getDimensions(&point)->x;
+ } else {
+ w = 0;
+
+ for (int j = 0; j < 16; j++) {
+ _arrayL[j]->getDimensions(&point);
+ w += point.x + 2;
+ }
+ }
+
+ fileinfo->fx1 = x - w / 2;
+ fileinfo->fx2 = x + w / 2;
+ fileinfo->fy1 = y;
+ fileinfo->fy2 = y + _emptyD->getDimensions(&point)->y;
+
+ _files.push_back(fileinfo);
+
+ y = fileinfo->fy2 + 3;
+ }
+}
+
+char *ModalSaveGame::getSaveName() {
+ if (_queryRes < 0)
+ return 0;
+
+ return _files[_queryRes]->filename;
+}
+
+bool ModalSaveGame::getFileInfo(char *filename, FileInfo *fileinfo) {
+ warning("STUB: ModalSaveGame::getFileInfo()");
+
+ return false;
}
void FullpipeEngine::openHelp() {
diff --git a/engines/fullpipe/modal.h b/engines/fullpipe/modal.h
index f7264057fb..a214b1c639 100644
--- a/engines/fullpipe/modal.h
+++ b/engines/fullpipe/modal.h
@@ -29,6 +29,19 @@ class PictureObject;
class Picture;
class Sound;
+struct FileInfo {
+ char filename[260];
+ bool empty;
+ int day;
+ int month;
+ int year;
+ int time;
+ int fx1;
+ int fx2;
+ int fy1;
+ int fy2;
+};
+
class BaseModalObject {
public:
@@ -240,20 +253,40 @@ private:
class ModalSaveGame : public BaseModalObject {
public:
ModalSaveGame();
- virtual ~ModalSaveGame() {}
+ virtual ~ModalSaveGame();
virtual bool pollEvent() { return true; }
virtual bool handleMessage(ExCommand *message) { return false; }
- virtual bool init(int counterdiff) { return true; }
+ virtual bool init(int counterdiff);
virtual void update() {}
virtual void saveload() {}
void setScene(Scene *sc);
void setup(Scene *sc, int mode);
+ void processKey(int key);
+
+ char *getSaveName();
+ bool getFileInfo(char *filename, FileInfo *fileinfo);
Common::Rect _rect;
int _oldBgX;
int _oldBgY;
+ PictureObject *_bgr;
+ PictureObject *_okD;
+ PictureObject *_okL;
+ PictureObject *_cancelD;
+ PictureObject *_cancelL;
+ PictureObject *_emptyD;
+ PictureObject *_emptyL;
+ PictureObject *_fullD;
+ PictureObject *_fullL;
+ Scene *_menuScene;
+ int _mode;
+ ModalQuery *_queryDlg;
+ Common::Array <FileInfo *> _files;
+ Common::Array <PictureObject *> _arrayL;
+ Common::Array <PictureObject *> _arrayD;
+ int _queryRes;
};
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index f40c1ae08b..35da154570 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -1824,6 +1824,89 @@ void MGM::clear() {
_items.clear();
}
+MessageQueue *MGM::genMQ(StaticANIObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr) {
+ int idx = getItemIndexById(ani->_id);
+
+ if (idx == -1)
+ return 0;
+
+ int stid = staticsId;
+
+ if (!staticsId) {
+ if (ani->_movement) {
+ stid = ani->_movement->_staticsObj2->_staticsId;
+ } else {
+ if (!ani->_statics)
+ return 0;
+
+ stid = ani->_statics->_staticsId;
+ }
+ }
+
+ if (stid == staticsIndex)
+ return new MessageQueue(g_fp->_globalMessageQueueList->compact());
+
+ int startidx = getStaticsIndexById(idx, stid);
+ int endidx = getStaticsIndexById(idx, staticsIndex);
+ int subidx = startidx + endidx * _items[idx]->statics.size();
+
+ if (!_items[idx]->subItems[subidx]->movement) {
+ clearMovements2(idx);
+ recalcOffsets(idx, startidx, endidx, 0, 1);
+ }
+
+ if (!_items[idx]->subItems[subidx]->movement)
+ return 0;
+
+ MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact());
+ Common::Point point;
+ ExCommand *ex;
+
+ int i = 0;
+ do {
+ subidx = startidx + endidx * _items[idx]->statics.size();
+
+ _items[idx]->subItems[subidx]->movement->calcSomeXY(point, 0);
+
+ if (pointArr) {
+ int sz;
+
+ if (_items[idx]->subItems[subidx]->movement->_currMovement)
+ sz = _items[idx]->subItems[subidx]->movement->_currMovement->_dynamicPhases.size();
+ else
+ sz = _items[idx]->subItems[subidx]->movement->_dynamicPhases.size();
+
+ ex = new ExCommand2(20, ani->_id, &pointArr[i], sz);
+
+ ex->_messageNum = _items[idx]->subItems[subidx]->movement->_id;
+ } else {
+ ex = new ExCommand(ani->_id, 1, _items[idx]->subItems[subidx]->movement->_id, 0, 0, 0, 1, 0, 0, 0);
+ }
+
+ ex->_keyCode = ani->_okeyCode;
+ ex->_field_3C = 1;
+ ex->_field_24 = 1;
+
+ mq->addExCommandToEnd(ex);
+
+ if (resStatId)
+ *resStatId = _items[idx]->subItems[subidx]->movement->_id;
+
+ startidx = _items[idx]->subItems[subidx]->staticsIndex;
+
+ uint step;
+
+ if (_items[idx]->subItems[subidx]->movement->_currMovement)
+ step = _items[idx]->subItems[subidx]->movement->_currMovement->_dynamicPhases.size();
+ else
+ step = _items[idx]->subItems[subidx]->movement->_dynamicPhases.size();
+
+ i += step;
+ } while (startidx != endidx);
+
+ return mq;
+}
+
MGMItem::MGMItem() {
objId = 0;
}
@@ -1881,15 +1964,10 @@ int MGM::getItemIndexById(int objId) {
}
MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
- warning("STUB: MGM::genMovement()");
-
- return 0;
-
-#if 0
if (!mgminfo->ani)
return 0;
- mov = mgminfo->ani->_movement;
+ Movement *mov = mgminfo->ani->_movement;
if (!mov && !mgminfo->ani->_statics)
return 0;
@@ -1901,14 +1979,17 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
mgminfo->staticsId1 = mgminfo->ani->_statics->_staticsId;
}
+ Common::Point point;
+
if (!(mgminfo->flags & 0x10) || !(mgminfo->flags & 0x20)) {
int nx = mgminfo->ani->_ox;
int ny = mgminfo->ani->_oy;
if (mgminfo->ani->_movement) {
- mgminfo->ani->calcNextStep(&point2);
- nx += point2.x;
- ny += point2.y;
+ mgminfo->ani->calcNextStep(&point);
+
+ nx += point.x;
+ ny += point.y;
}
if (!(mgminfo->flags & 0x10))
@@ -1923,40 +2004,37 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
if (!mov)
return 0;
- itemIdx = getItemIndexById(mgminfo->ani->_id);
- subIdx = getStaticsIndexById(itemIdx, mgminfo->staticsId1);
- st2idx = getStaticsIndexById(itemIdx, mov->_staticsObj1->_staticsId);
- st1idx = getStaticsIndexById(itemIdx, mov->_staticsObj2->_staticsId);
- subOffset = getStaticsIndexById(itemIdx, mgminfo->staticsId2);
+ int itemIdx = getItemIndexById(mgminfo->ani->_id);
+ int subIdx = getStaticsIndexById(itemIdx, mgminfo->staticsId1);
+ int st2idx = getStaticsIndexById(itemIdx, mov->_staticsObj1->_staticsId);
+ int st1idx = getStaticsIndexById(itemIdx, mov->_staticsObj2->_staticsId);
+ int subOffset = getStaticsIndexById(itemIdx, mgminfo->staticsId2);
clearMovements2(itemIdx);
recalcOffsets(itemIdx, subIdx, st2idx, 0, 1);
clearMovements2(itemIdx);
recalcOffsets(itemIdx, st1idx, subOffset, 0, 1);
- v71 = (Message *)(28 * itemIdx);
- v16 = items[itemIdx].objId;
- v17 = *(_DWORD *)(v16 + offsetof(MGMItem, staticsListCount));
- off = *(_DWORD *)(v16 + offsetof(MGMItem, subItems));
- v18 = (MGMSubItem *)(off + 24 * (subIdx + st2idx * v17));
- x1 = (int)&v18->movement->go.CObject.vmt;
- v19 = (MGMSubItem *)(off + 24 * (st1idx + subOffset * v17));
- v69 = (LONG)&v19->movement->go.CObject.vmt;
+ MGMSubItem *sub1 = _items[itemIdx]->subItems[subIdx + st2idx * _items[itemIdx]->statics.size()];
+ MGMSubItem *sub2 = _items[itemIdx]->subItems[st1idx + subOffset * _items[itemIdx]->statics.size()];
- if (subIdx != st2idx && !x1)
+ if (subIdx != st2idx && !sub1->movement)
return 0;
- if (st1idx != subOffset && !v69)
+ if (st1idx != subOffset && !sub2->movement)
return 0;
- int n1x = mgminfo->x1 - mgminfo->x2 - v18->x - v19->x;
- int n1y = mgminfo->y1 - mgminfo->y2 - v18->y - v19->y;
+ int n1x = mgminfo->x1 - mgminfo->x2 - sub1->x - sub2->x;
+ int n1y = mgminfo->y1 - mgminfo->y2 - sub1->y - sub2->y;
- mov->calcSomeXY(&point1, 0);
+ Common::Point point1;
+
+ mov->calcSomeXY(point1, 0);
int n2x = point1.x;
int n2y = point1.y;
int mult;
+ int len;
if (mgminfo->flags & 0x40) {
mult = mgminfo->field_10;
@@ -1973,20 +2051,20 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
len = -1;
n2x = mult * point1.x;
n1x = mult * point1.x;
- mgminfo->x1 = mgminfo->x2 + mult * point1.x + v18->x + v19->x;
+ mgminfo->x1 = mgminfo->x2 + mult * point1.x + sub1->x + sub2->x;
}
if (!(mgminfo->flags & 4)) {
n2y = mult * point1.y;
n1y = mult * point1.y;
len = -1;
- mgminfo->y1 = mgminfo->y2 + mult * point1.y + v18->y + v19->y;
+ mgminfo->y1 = mgminfo->y2 + mult * point1.y + sub1->y + sub2->y;
}
int px = 0;
int py = 0;
- if (x1) {
+ if (sub1->movement) {
px = countPhases(itemIdx, subIdx, st2idx, 1);
py = countPhases(itemIdx, subIdx, st2idx, 2);
}
@@ -2001,13 +2079,14 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
py += mov->countPhasesWithFlag(len, 2);
}
- if (v69) {
+ if (sub2->movement) {
px += countPhases(itemIdx, st1idx, subOffset, 1);
py += countPhases(itemIdx, st1idx, subOffset, 2);
}
int dx1 = n1x - n2x;
int dy1 = n1y - n2y;
+ int x1, y1;
if (px) {
x1 = (int)((double)dx1 / (double)px);
@@ -2021,6 +2100,8 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
y1 = 0;
}
+ Common::Point x2, y2;
+
y2.x = dx1 - px * x1;
y2.y = dy1 - py * y1;
@@ -2037,16 +2118,19 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact());
ExCommand2 *ex2;
- for (v42 = subIdx; v42 != st2idx; v42 = v43->staticsIndex) {
- v43 = &(*(MGMSubItem **)((char *)&this->items->subItems + (unsigned int)v71))[v42 + st2idx * *(int *)((char *)&this->items->staticsListCount + (unsigned int)v71)];
- ex2 = buildExCommand2(v43->movement, mgminfo->ani->go._id, x1, y1, &x2, &y2, -1);
+ for (int i = subIdx; i != st2idx;) {
+ MGMSubItem *s = _items[itemIdx]->subItems[i + subOffset * _items[itemIdx]->statics.size()];
+
+ ex2 = buildExCommand2(s->movement, mgminfo->ani->_id, x1, y1, &x2, &y2, -1);
ex2->_parId = mq->_id;
ex2->_keyCode = mgminfo->ani->_okeyCode;
mq->addExCommandToEnd(ex2);
+
+ i = s->staticsIndex;
}
- for (i = 0; i < mult; ++i) {
+ for (int i = 0; i < mult; ++i) {
int plen;
if (i == mult - 1)
@@ -2061,14 +2145,16 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
mq->addExCommandToEnd(ex2);
}
- for (j = st1idx; j != subOffset; j = v50->staticsIndex) {
- v50 = &(*(MGMSubItem **)((char *)&this->items->subItems + (unsigned int)v71))[j + subOffset * *(int *)((char *)&this->items->staticsListCount + (unsigned int)v71)];
+ for (int j = st1idx; j != subOffset;) {
+ MGMSubItem *s = _items[itemIdx]->subItems[j + subOffset * _items[itemIdx]->statics.size()];
- ex2 = buildExCommand2(v50->movement, mgminfo->ani->_id, x1, y1, &x2, &y2, -1);
+ ex2 = buildExCommand2(s->movement, mgminfo->ani->_id, x1, y1, &x2, &y2, -1);
ex2->_parId = mq->_id;
ex2->_keyCode = mgminfo->ani->_okeyCode;
mq->addExCommandToEnd(ex2);
+
+ j = s->staticsIndex;
}
ExCommand *ex = new ExCommand(mgminfo->ani->_id, 5, -1, mgminfo->x1, mgminfo->y1, 0, 1, 0, 0, 0);
@@ -2081,9 +2167,25 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
mq->addExCommandToEnd(ex);
return mq;
-#endif
}
+int MGM::countPhases(int idx, int subIdx, int endIdx, int flag) {
+ int res = 0;
+
+ if (endIdx < 0)
+ return 0;
+
+ while (subIdx != endIdx) {
+ if (subIdx < 0)
+ break;
+
+ res += _items[idx]->subItems[subIdx + endIdx * _items[idx]->statics.size()]->movement->countPhasesWithFlag(-1, flag);
+
+ subIdx = _items[idx]->subItems[subIdx + 6 * endIdx * _items[idx]->statics.size()]->staticsIndex;
+ }
+
+ return res;
+}
void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) {
if (getItemIndexById(ani->_id) == -1)
return;
@@ -2182,9 +2284,8 @@ void MGM::clearMovements2(int idx) {
}
int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
-#if 0
MGMItem *item = _items[idx];
- int subIdx = st1idx + st2idx * item->staticsListCount;
+ int subIdx = st1idx + st2idx * item->statics.size();
if (st1idx == st2idx) {
memset(&item->subItems[subIdx], 0, sizeof(item->subItems[subIdx]));
@@ -2196,8 +2297,8 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
Common::Point point;
- for (int i = 0; i < item->movementListCount; i++) {
- mov = item->movements1[i];
+ for (uint i = 0; i < item->movements1.size(); i++) {
+ Movement *mov = item->movements1[i];
if (mov->_staticsObj1 == item->statics[st1idx]) {
if (!item->movements2[i] && (!flop || mov->_field_50)) {
@@ -2205,22 +2306,21 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
int stidx = getStaticsIndex(idx, item->movements1[i]->_staticsObj2);
int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
+ int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ int newsz = sz + item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->field_C;
if (recalc >= 0) {
- if (!item->subItems[subIdx].movement || item->subItems[subIdx].field_8 > recalc + 1 ||
- (item->subItems[subIdx].field_8 == recalc + 1 && item->subItems[subIdx].field_C > v20) {
- item->subItems[subIdx].movement = mov;
- item->subItems[subIdx].staticsIndex = stidx;
- item->subItems[subIdx].field_8 = recalc + 1;
-
- int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1 ||
+ (item->subItems[subIdx]->field_8 == recalc + 1 && item->subItems[subIdx]->field_C > newsz)) {
+ item->subItems[subIdx]->movement = mov;
+ item->subItems[subIdx]->staticsIndex = stidx;
+ item->subItems[subIdx]->field_8 = recalc + 1;
+ item->subItems[subIdx]->field_C = newsz;
- item->subItems[subIdx].field_C = sz + item->subItems[stidx + 6 * st2idx * _items[idx].staticsListCount]->field_C;
+ mov->calcSomeXY(point, 0);
- mov->calcSomeXY(&point, 0);
-
- item->subItems[subIdx].x = item->subItems[stidx + 6 * st2idx * _items[idx].staticsListCount]->x + point.x;
- item->subItems[subIdx].y = item->subItems[stidx + 6 * st2idx * _items[idx].staticsListCount]->y + point.y;
+ item->subItems[subIdx]->x = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->x + point.x;
+ item->subItems[subIdx]->y = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->y + point.y;
}
}
}
@@ -2235,17 +2335,17 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
if (recalc >= 0) {
if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1) {
item->subItems[subIdx]->movement = mov;
- item->subItems[subIdx].staticsIndex = stidx;
- item->subItems[subIdx].field_8 = recalc + 1;
+ item->subItems[subIdx]->staticsIndex = stidx;
+ item->subItems[subIdx]->field_8 = recalc + 1;
int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
- item->subItems[subIdx].field_C = sz + item->subItems[stidx + 6 * st2idx * _items[idx].staticsListCount]->field_C;
+ item->subItems[subIdx]->field_C = sz + item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->field_C;
- mov->calcSomeXY(&point, 0);
+ mov->calcSomeXY(point, 0);
- item->subItems[subIdx].x = item->subItems[stidx + 6 * st2idx * _items[idx].staticsListCount]->x - point.x;
- item->subItems[subIdx].y = item->subItems[stidx + 6 * st2idx * _items[idx].staticsListCount]->y - point.y;
+ item->subItems[subIdx]->x = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->x - point.x;
+ item->subItems[subIdx]->y = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->y - point.y;
}
}
}
@@ -2257,10 +2357,26 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
return item->subItems[subIdx]->field_8;
return -1;
-#endif
- warning("STUB: MGM::recalcOffsets()");
+}
- return 0;
+int MGM::refreshOffsets(int objectId, int idx1, int idx2) {
+ int idx = getItemIndexById(objectId);
+
+ if (idx != -1) {
+ int from = getStaticsIndexById(idx, idx1);
+ int to = getStaticsIndexById(idx, idx2);
+
+ MGMSubItem *sub = _items[idx]->subItems[from + to * _items[idx]->statics.size()];
+
+ if (sub->movement) {
+ idx = sub->field_8;
+ } else {
+ clearMovements2(idx);
+ idx = recalcOffsets(idx, from, to, 0, 1);
+ }
+ }
+
+ return idx;
}
Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, int *mult, int *len, int flag) {
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index 96442cac51..4d92fd7fed 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -138,7 +138,7 @@ struct MGMItem {
Common::Array<MGMSubItem *> subItems;
Common::Array<Statics *> statics;
Common::Array<Movement *> movements1;
- Common::Array<Movement *> movements2;
+ Common::Array<int> movements2;
MGMItem();
};
@@ -178,6 +178,9 @@ public:
int recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop);
Common::Point *calcLength(Common::Point *point, Movement *mov, int x, int y, int *mult, int *len, int flag);
ExCommand2 *buildExCommand2(Movement *mov, int objId, int x1, int y1, Common::Point *x2, Common::Point *y2, int len);
+ MessageQueue *genMQ(StaticANIObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr);
+ int countPhases(int idx, int subIdx, int subOffset, int flag);
+ int refreshOffsets(int objectId, int idx1, int idx2);
};
struct MctlLadderMovementVars {
diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp
index 47c6a3c8cd..7420c1b1cf 100644
--- a/engines/fullpipe/scenes.cpp
+++ b/engines/fullpipe/scenes.cpp
@@ -1106,10 +1106,6 @@ int defaultUpdateCursor() {
return g_fp->_cursorId;
}
-void FullpipeEngine::processArcade(ExCommand *ex) {
- warning("STUB: FullpipeEngine::processArcade()");
-}
-
void FullpipeEngine::updateMapPiece(int mapId, int update) {
for (int i = 0; i < 200; i++) {
int hiWord = (_mapTable[i] >> 16) & 0xffff;
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index aa91f25087..3c13bad854 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -26,6 +26,7 @@
#include "fullpipe/scene.h"
#include "fullpipe/sound.h"
#include "fullpipe/ngiarchive.h"
+#include "fullpipe/messages.h"
#include "common/memstream.h"
#include "audio/audiostream.h"
#include "audio/decoders/vorbis.h"
@@ -73,6 +74,18 @@ bool SoundList::loadFile(const char *fname, char *libname) {
return load(archive, libname);
}
+Sound *SoundList::getSoundItemById(int id) {
+ if (_soundItemsCount == 0) {
+ return _soundItems[0]->getId() != id ? 0 : _soundItems[0];
+ }
+
+ for (int i = 0; i < _soundItemsCount; i++) {
+ if (_soundItems[i]->getId() == id)
+ return _soundItems[i];
+ }
+ return NULL;
+}
+
Sound::Sound() {
_id = 0;
_directSoundBuffer = 0;
@@ -80,10 +93,13 @@ Sound::Sound() {
_objectId = 0;
memset(_directSoundBuffers, 0, sizeof(_directSoundBuffers));
_description = 0;
+ _volume = 100;
}
Sound::~Sound() {
- warning("STUB: Sound::~Sound()");
+ freeSound();
+
+ free(_description);
}
bool Sound::load(MfcArchive &file, NGIArchive *archive) {
@@ -120,27 +136,156 @@ void Sound::setPanAndVolumeByStaticAni() {
}
void Sound::setPanAndVolume(int vol, int pan) {
- warning("STUB: Sound::setPanAndVolume");
+ g_fp->_mixer->setChannelVolume(_handle, vol / 39); // 0..10000
+ g_fp->_mixer->setChannelBalance(_handle, pan / 78); // -10000..10000
+}
+
+void Sound::play(int flag) {
+ Audio::SoundHandle handle = getHandle();
+
+ if (g_fp->_mixer->isSoundHandleActive(handle))
+ return;
+
+ byte *soundData = loadData();
+ Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(soundData, getDataSize());
+ Audio::RewindableAudioStream *wav = Audio::makeWAVStream(dataStream, DisposeAfterUse::YES);
+ Audio::AudioStream *audioStream = new Audio::LoopingAudioStream(wav, (flag == 1) ? 0 : 1);
+
+ g_fp->_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);
+}
+
+void Sound::freeSound() {
+ stop();
+
+ free(_soundData);
+}
+
+int Sound::getVolume() {
+ return g_fp->_mixer->getChannelVolume(_handle) * 39; // 0..10000
+}
+
+void Sound::stop() {
+ g_fp->_mixer->stopHandle(_handle);
}
-void FullpipeEngine::setSceneMusicParameters(GameVar *var) {
+void FullpipeEngine::setSceneMusicParameters(GameVar *gvar) {
warning("STUB: FullpipeEngine::setSceneMusicParameters()");
- // TODO: Finish this (MINDELAY, MAXDELAY, LOCAL, SEQUENCE, STARTDELAY etc)
- stopAllSoundStreams();
+#if 0
+ stopSoundStream2();
+
+ if (soundStream3)
+ FSOUND_Stream_Stop(soundStream4);
+#endif
+
+ if (_musicLocal)
+ stopAllSoundStreams();
+
+ GameVar *var = gvar->getSubVarByName("MUSIC");
+
+ memset(_sceneTracks, 0, sizeof(_sceneTracks));
+
+ _numSceneTracks = 0;
+ _sceneTrackHasSequence = false;
+
+ if (!var)
+ return;
+
_musicGameVar = var;
+
+ GameVar *tr = var->getSubVarByName("TRACKS");
+ if (tr) {
+ GameVar *sub = tr->_subVars;
+
+ while (sub) {
+ if (_musicAllowed & sub->_value.intValue) {
+ strcpy(_sceneTracks[_numSceneTracks], sub->_varName);
+
+ _numSceneTracks++;
+ }
+
+ sub = sub->_nextVarObj;
+ }
+ }
+
+ _musicMinDelay = var->getSubVarAsInt("MINDELAY");
+ _musicMaxDelay = var->getSubVarAsInt("MAXDELAY");
+ _musicLocal = var->getSubVarAsInt("LOCAL");
+
+ GameVar *seq = var->getSubVarByName("SEQUENCE");
+
+ if (seq) {
+ _sceneTrackHasSequence = true;
+
+ strcpy(_trackName, seq->_value.stringValue);
+ }
+
+ if (_musicLocal)
+ stopAllSoundStreams();
+
+ if (!_sceneTrackIsPlaying || _musicLocal)
+ _trackStartDelay = var->getSubVarAsInt("STARTDELAY");
}
void FullpipeEngine::startSceneTrack() {
- // TODO: Finish this
-#ifdef USE_VORBIS
- if (g_fp->_mixer->isSoundHandleActive(_sceneTrackHandle))
- return;
+ if (!_sceneTrackIsPlaying && _numSceneTracks > 0) {
+ if (_trackStartDelay > 0) {
+ _trackStartDelay--;
+ } else {
+ int trackNum = getSceneTrack();
+
+ if (trackNum == -1) {
+ strcpy(_sceneTracksCurrentTrack, "silence");
+
+ _trackStartDelay = 2880;
+ _sceneTrackIsPlaying = 0;
+ } else {
+ strcpy(_sceneTracksCurrentTrack, _sceneTracks[trackNum]);
+
+ startSoundStream1(_sceneTracksCurrentTrack);
+
+ _sceneTrackIsPlaying = true;
+ }
+ }
+ }
+}
+
+int FullpipeEngine::getSceneTrack() {
+ int res;
+
+ if (_sceneTrackHasSequence) {
+ int num = _musicGameVar->getSubVarAsInt("TRACKS");
+
+ if (_trackName[num + 1] == 's') { // 'silence'
+ res = -1;
+ } else {
+ res = _trackName[num + 1] - '0';
+
+ if (res < 0 || res >= _numSceneTracks)
+ res = 0;
+ }
- GameVar *musicTrackVar = _musicGameVar->getSubVarByName("MUSIC")->getSubVarByName("TRACKS")->_subVars;
- if (!musicTrackVar)
+ int track = num + 1;
+
+ if (!_trackName[num + 2])
+ track = 0;
+
+ _musicGameVar->setSubVarAsInt("TRACKS", track);
+ } else {
+ res = _numSceneTracks * (_updateTicks % 10) / 10;
+ }
+
+ return res;
+}
+
+void FullpipeEngine::startSoundStream1(char *trackName) {
+ warning("STUB: FullpipeEngine::startSoundStream1(%s)", trackName);
+
+ stopAllSoundStreams();
+
+#ifdef USE_VORBIS
+ if (_mixer->isSoundHandleActive(_sceneTrackHandle))
return;
- char *trackName = musicTrackVar->_varName;
Common::File *track = new Common::File();
if (!track->open(trackName)) {
warning("Could not open %s", trackName);
@@ -148,40 +293,130 @@ void FullpipeEngine::startSceneTrack() {
return;
}
Audio::RewindableAudioStream *ogg = Audio::makeVorbisStream(track, DisposeAfterUse::YES);
- g_fp->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_sceneTrackHandle, ogg);
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, &_sceneTrackHandle, ogg);
#endif
}
void FullpipeEngine::stopAllSounds() {
// TODO: Differences from stopAllSoundStreams()
- g_fp->_mixer->stopAll();
+ _mixer->stopAll();
}
void FullpipeEngine::toggleMute() {
- warning("STUB: FullpipeEngine::toggleMute()");
+ if (_soundEnabled) {
+ _sfxVolume = _sfxVolume != -10000 ? -10000 : 0;
+
+ updateSoundVolume();
+ }
}
void FullpipeEngine::playSound(int id, int flag) {
- SoundList *soundList = g_fp->_currentScene->_soundList;
- Sound *sound = soundList->getSoundById(id);
+ Sound *sound = 0;
+
+ for (int i = 0; i < _currSoundListCount; i++) {
+ sound = _currSoundList1[i]->getSoundItemById(id);
+
+ if (sound)
+ break;
+ }
+
if (!sound) {
warning("playSound: Can't find sound with ID %d", id);
return;
}
- byte *soundData = sound->loadData();
- Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(soundData, sound->getDataSize());
- Audio::RewindableAudioStream *wav = Audio::makeWAVStream(dataStream, DisposeAfterUse::YES);
- Audio::AudioStream *audioStream = new Audio::LoopingAudioStream(wav, (flag == 1) ? 0 : 1);
- Audio::SoundHandle handle = sound->getHandle();
- g_fp->_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);
+
+ sound->play(flag);
}
void FullpipeEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) {
warning("STUB: FullpipeEngine::playTrack(var, %s, %d)", name, delayed);
+#if 0
+ stopSoundStream2();
+
+ if (soundStream3)
+ FSOUND_Stream_Stop(soundStream4);
+#endif
+
+ if (_musicLocal)
+ stopAllSoundStreams();
+
+ GameVar *var = sceneVar->getSubVarByName(name);
+
+ memset(_sceneTracks, 0, sizeof(_sceneTracks));
+
+ _numSceneTracks = 0;
+ _sceneTrackHasSequence = false;
+
+ if (!var)
+ return;
+
+ _musicGameVar = var;
+
+ GameVar *tr = var->getSubVarByName("TRACKS");
+ if (tr) {
+ GameVar *sub = tr->_subVars;
+
+ while (sub) {
+ if (_musicAllowed & sub->_value.intValue) {
+ strcpy(_sceneTracks[_numSceneTracks], sub->_varName);
+
+ _numSceneTracks++;
+ }
+
+ sub = sub->_nextVarObj;
+ }
+ }
+
+ _musicMinDelay = var->getSubVarAsInt("MINDELAY");
+ _musicMaxDelay = var->getSubVarAsInt("MAXDELAY");
+ _musicLocal = var->getSubVarAsInt("LOCAL");
+
+ GameVar *seq = var->getSubVarByName("SEQUENCE");
+
+ if (seq) {
+ _sceneTrackHasSequence = true;
+
+ strcpy(_trackName, seq->_value.stringValue);
+ }
+
+ if (delayed) {
+ if (_sceneTrackIsPlaying && _numSceneTracks == 1) {
+ if (strcmp(_sceneTracksCurrentTrack, _sceneTracks[0]))
+ stopAllSoundStreams();
+ }
+
+ _trackStartDelay = var->getSubVarAsInt("STARTDELAY");
+ }
}
void global_messageHandler_handleSound(ExCommand *cmd) {
- debug(0, "STUB: global_messageHandler_handleSound()");
+ if (!g_fp->_soundEnabled)
+ return;
+
+ Sound *snd = 0;
+
+ for (int i = 0; i < g_fp->_currSoundListCount; i++)
+ snd = g_fp->_currSoundList1[i]->getSoundItemById(cmd->_messageNum);
+
+ if (!snd)
+ return;
+
+ if (cmd->_field_14 & 1) {
+ if (!g_fp->_flgSoundList && (cmd->_field_14 & 4))
+ snd->freeSound();
+
+ snd->updateVolume();
+
+ if (snd->_objectId && g_fp->_currentScene->getStaticANIObject1ById(snd->_objectId, -1))
+ snd->setPanAndVolumeByStaticAni();
+ else
+ snd->setPanAndVolume(g_fp->_sfxVolume, 0);
+
+ if (snd->getVolume() > -3500)
+ snd->play(cmd->_keyCode);
+ } else if (cmd->_field_14 & 2) {
+ snd->stop();
+ }
}
void FullpipeEngine::stopSoundStream2() {
@@ -190,21 +425,23 @@ void FullpipeEngine::stopSoundStream2() {
void FullpipeEngine::stopAllSoundStreams() {
// TODO: Differences from stopAllSounds()
- g_fp->_mixer->stopAll();
+ _mixer->stopAll();
}
void FullpipeEngine::stopAllSoundInstances(int id) {
- SoundList *soundList = g_fp->_currentScene->_soundList;
- for (int i = 0; i < soundList->getCount(); i++) {
- Sound *sound = soundList->getSoundByIndex(i);
- if (sound->getId() == id) {
- g_fp->_mixer->stopHandle(sound->getHandle());
- }
+ for (int i = 0; i < _currSoundListCount; i++) {
+ Sound *sound = _currSoundList1[i]->getSoundItemById(id);
+
+ if (sound)
+ sound->stop();
}
}
void FullpipeEngine::updateSoundVolume() {
- debug(3, "STUB FullpipeEngine::updateSoundVolume()");
+ for (int i = 0; i < _currSoundListCount; i++)
+ for (int j = 0; i < _currSoundList1[i]->getCount(); j++) {
+ _currSoundList1[i]->getSoundByIndex(j)->setPanAndVolume(_sfxVolume, 0);
+ }
}
void FullpipeEngine::setMusicVolume(int vol) {
diff --git a/engines/fullpipe/sound.h b/engines/fullpipe/sound.h
index e284e5efab..14e766f5bb 100644
--- a/engines/fullpipe/sound.h
+++ b/engines/fullpipe/sound.h
@@ -32,6 +32,7 @@ class Sound : public MemoryObject {
int _directSoundBuffers[7];
byte *_soundData;
Audio::SoundHandle _handle;
+ int _volume;
public:
int16 _objectId;
@@ -46,6 +47,11 @@ public:
int getId() const { return _id; }
Audio::SoundHandle getHandle() const { return _handle; }
+ void play(int flag);
+ void freeSound();
+ int getVolume();
+ void stop();
+
void setPanAndVolumeByStaticAni();
void setPanAndVolume(int vol, int pan);
};
@@ -63,13 +69,7 @@ class SoundList : public CObject {
int getCount() { return _soundItemsCount; }
Sound *getSoundByIndex(int idx) { return _soundItems[idx]; }
- Sound *getSoundById(int id) {
- for (int i = 0; i < _soundItemsCount; i++) {
- if (_soundItems[i]->getId() == id)
- return _soundItems[i];
- }
- return NULL;
- }
+ Sound *getSoundItemById(int id);
};
} // End of namespace Fullpipe
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index a3a160b5b2..f1abac5778 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -277,8 +277,11 @@ void StaticANIObject::deleteFromGlobalMessageQueue() {
}
}
-void StaticANIObject::queueMessageQueue(MessageQueue *mq) {
- if (isIdle() && !(_flags & 0x80)) {
+bool StaticANIObject::queueMessageQueue(MessageQueue *mq) {
+ if (_flags & 0x80)
+ return false;
+
+ if (isIdle()) {
deleteFromGlobalMessageQueue();
_messageQueueId = 0;
_messageNum = 0;
@@ -296,6 +299,8 @@ void StaticANIObject::queueMessageQueue(MessageQueue *mq) {
_messageQueueId = 0;
}
}
+
+ return true;
}
void StaticANIObject::restartMessageQueue(MessageQueue *mq) {
@@ -1019,9 +1024,26 @@ void StaticANIObject::adjustSomeXY() {
}
MessageQueue *StaticANIObject::changeStatics1(int msgNum) {
- warning("STUB: StaticANIObject::changeStatics1(%d)", msgNum);
+ g_fp->_mgm->addItem(_id);
- return 0;
+ MessageQueue *mq = g_fp->_mgm->genMQ(this, msgNum, 0, 0, 0);
+
+ if (!mq)
+ return 0;
+
+ if (mq->getCount() <= 0) {
+ g_fp->_globalMessageQueueList->addMessageQueue(mq);
+
+ if (_flags & 1)
+ _messageQueueId = mq->_id;
+ } else {
+ if (!queueMessageQueue(mq))
+ return 0;
+
+ g_fp->_globalMessageQueueList->addMessageQueue(mq);
+ }
+
+ return mq;
}
void StaticANIObject::changeStatics2(int objId) {
@@ -1347,6 +1369,31 @@ bool StaticANIObject::startAnim(int movementId, int messageQueueId, int dynPhase
return true;
}
+Common::Point *StaticANIObject::calcStepLen(Common::Point *p) {
+ if (_movement) {
+ Common::Point point;
+
+ _movement->calcSomeXY(point, 0);
+
+ p->x = point.x;
+ p->y = point.y;
+
+ int idx = _stepArray.getCurrPointIndex() - _movement->_currDynamicPhaseIndex - 1;
+
+ if (idx >= 0) {
+ _stepArray.getPoint(&point, idx, _movement->_currDynamicPhaseIndex + 2);
+
+ p->x += point.x;
+ p->y += point.y;
+ }
+ } else {
+ p->x = 0;
+ p->y = 0;
+ }
+
+ return p;
+}
+
Statics::Statics() {
_staticsId = 0;
_picture = 0;
diff --git a/engines/fullpipe/statics.h b/engines/fullpipe/statics.h
index 89703965cd..d678957163 100644
--- a/engines/fullpipe/statics.h
+++ b/engines/fullpipe/statics.h
@@ -217,7 +217,7 @@ public:
void setAlpha(int alpha);
void deleteFromGlobalMessageQueue();
- void queueMessageQueue(MessageQueue *msg);
+ bool queueMessageQueue(MessageQueue *msg);
void restartMessageQueue(MessageQueue *msg);
MessageQueue *getMessageQueue();
bool trySetMessageQueue(int msgNum, int qId);
@@ -246,6 +246,7 @@ public:
void draw2();
MovTable *countMovements();
+ Common::Point *calcStepLen(Common::Point *p);
void setSpeed(int speed);
void updateStepPos();
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index e55c006f86..4bbda8fd93 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -227,6 +227,7 @@ MainMenu::MainMenu() : GameMenu(kMainMenuID), _menuBackground(0), _overviewButto
_menuLoop.attachFader(&_menuFader);
_menuLoop.initFromAIFFFile("Sounds/Main Menu.aiff");
+ _menuFader.setMasterVolume(((PegasusEngine *)g_engine)->getAmbienceLevel());
updateDisplay();
}
@@ -736,6 +737,7 @@ DeathMenu::DeathMenu(const DeathReason deathReason) : GameMenu(kDeathMenuID), _d
_largeSelect.startDisplaying();
} else {
_triumphSound.initFromQuickTime("Sounds/Caldoria/Galactic Triumph");
+ _triumphSound.setVolume(((PegasusEngine *)g_engine)->getAmbienceLevel());
_triumphSound.playSound();
}
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 7977c17f12..9d2d6723a9 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -196,6 +196,8 @@ void Caldoria::start() {
if (!pullbackMovie->loadFile("Images/Caldoria/Pullback.movie"))
error("Could not load pullback movie");
+ pullbackMovie->setVolume(MIN<uint>(_vm->getSoundFXLevel(), 0xFF));
+
// Draw the first frame so we can fade to it
const Graphics::Surface *frame = pullbackMovie->decodeNextFrame();
assert(frame);
@@ -907,7 +909,7 @@ void Caldoria::arriveAtCaldoria49() {
setCurrentAlternate(kAltCaldoriaNormal);
// Need to force the loop to play.
- if (GameState.getCurrentDirection() == kNorth) {
+ if (GameState.getCurrentDirection() == kNorth && !GameState.getCaldoriaSinclairShot()) {
GameState.setCaldoriaFuseTimeLimit(kSinclairShootsTimeLimit);
startExtraSequence(kCa49NorthVoiceAnalysis, kExtraCompletedFlag, kFilterNoInput);
}
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
index abf34d3863..c964e3458b 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
@@ -1167,6 +1167,18 @@ CaldoriaBomb::~CaldoriaBomb() {
delete[] _bombLevel[i];
}
+void CaldoriaBomb::setSoundFXLevel(const uint16) {
+ // The transition sounds between levels are ambience, so overwrite what
+ // Neighborhood::setSoundFXLevel does and keep using the ambience volume level
+ if (_timer.isRunning())
+ _owner->_navMovie.setVolume(((PegasusEngine *)g_engine)->getAmbienceLevel());
+}
+
+void CaldoriaBomb::setAmbienceLevel(const uint16 level) {
+ if (_timer.isRunning())
+ _owner->_navMovie.setVolume(level);
+}
+
void CaldoriaBomb::openInteraction() {
_grid.moveElementTo(kCaldoriaBombGridLeft, kCaldoriaBombGridTop);
_grid.setDisplayOrder(kCaldoriaBombGridOrder);
@@ -1234,6 +1246,7 @@ void CaldoriaBomb::receiveNotification(Notification *notification, const Notific
_timer.start();
_currentLevel = 0;
_lastVertex = -1;
+ _owner->_navMovie.setVolume(((PegasusEngine *)g_engine)->getAmbienceLevel());
startBombAmbient("Sounds/Caldoria/BmbLoop1.22K.AIFF");
break;
case kCaldoria56BombStage2:
@@ -1258,6 +1271,7 @@ void CaldoriaBomb::receiveNotification(Notification *notification, const Notific
_grid.hide();
_timer.stop();
_timer.hide();
+ _owner->_navMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
_owner->loadLoopSound1("");
_owner->playDeathExtra(kCaldoria56BombExplodes, kDeathNuclearExplosion);
}
@@ -1411,6 +1425,7 @@ void CaldoriaBomb::handleInput(const Input &input, const Hotspot *hotspot) {
_timer.stop();
_grid.hide();
_timer.hide();
+ _owner->_navMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
_owner->startExtraSequence(kCaldoria56BombStage7, kExtraCompletedFlag, kFilterNoInput);
break;
}
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.h b/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
index 5bb39b4122..ba6d1e8998 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
@@ -122,6 +122,9 @@ public:
CaldoriaBomb(Neighborhood *, NotificationManager *);
virtual ~CaldoriaBomb();
+ void setSoundFXLevel(const uint16);
+ void setAmbienceLevel(const uint16);
+
long getNumHints();
Common::String getHintMovie(uint);
void doSolve();
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
index a3ce97d438..2ae990d775 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
@@ -24,6 +24,7 @@
*/
#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
#include "pegasus/neighborhood/neighborhood.h"
#include "pegasus/neighborhood/caldoria/caldoria.h"
#include "pegasus/neighborhood/caldoria/caldoriamessages.h"
@@ -45,6 +46,10 @@ void CaldoriaMessages::openInteraction() {
_messageNumber = 1;
}
+void CaldoriaMessages::setSoundFXLevel(const uint16 fxLevel) {
+ _messageMovie.setVolume(fxLevel);
+}
+
void CaldoriaMessages::initInteraction() {
GameInteraction::_owner->startExtraSequence(kCaBedroomVidPhone, kExtraCompletedFlag, kFilterNoInput);
}
@@ -101,6 +106,7 @@ void CaldoriaMessages::play1Message(uint messageNumber) {
GameState.setCaldoriaSeenMessages(true);
}
+ _messageMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
_messageMovie.moveElementTo(kCaldoriaMessageLeft, kCaldoriaMessageTop);
_messageMovie.setDisplayOrder(kCaldoriaMessagesOrder);
_messageMovie.startDisplaying();
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.h b/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
index 955fe10ce9..b2fc7c3bf9 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
@@ -41,6 +41,8 @@ public:
CaldoriaMessages(Neighborhood *, const NotificationID, NotificationManager *);
virtual ~CaldoriaMessages() {}
+ void setSoundFXLevel(const uint16);
+
protected:
void openInteraction();
void initInteraction();
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index f7493dbe75..df5a75541c 100644
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -2402,6 +2402,8 @@ void Mars::doCanyonChase() {
if (!video->loadFile("Images/Mars/M44ESA.movie"))
error("Could not load interface->shuttle transition video");
+ video->setVolume(MIN<uint>(_vm->getSoundFXLevel(), 0xFF));
+
video->start();
while (!_vm->shouldQuit() && !video->endOfVideo()) {
@@ -2612,6 +2614,7 @@ void Mars::startUpFromFinishedSpaceChase() {
kShuttleJunkTop, false);
initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
+ _explosions.setVolume(_vm->getSoundFXLevel());
_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
_energyBeam.initShuttleWeapon();
@@ -2650,6 +2653,7 @@ void Mars::startUpFromFinishedSpaceChase() {
initOneMovie(&_canyonChaseMovie, "Images/Mars/M98EAS.movie", kShuttleTractorBeamMovieOrder,
kShuttleWindowLeft, kShuttleWindowTop, true);
+ _canyonChaseMovie.setVolume(_vm->getSoundFXLevel());
_canyonChaseMovie.setTime(_canyonChaseMovie.getDuration());
_canyonChaseMovie.redrawMovieWorld();
}
@@ -2725,6 +2729,7 @@ void Mars::startUpFromSpaceChase() {
kShuttleJunkTop, false);
initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
+ _explosions.setVolume(_vm->getSoundFXLevel());
_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
_energyBeam.initShuttleWeapon();
@@ -2788,6 +2793,10 @@ void Mars::startUpFromSpaceChase() {
void Mars::setSoundFXLevel(const uint16 level) {
Neighborhood::setSoundFXLevel(level);
+ if (GameState.getCurrentRoomAndView() == MakeRoomView(kMars48, kEast) &&
+ !GameState.getMarsAvoidedReactorRobot())
+ _loop2Fader.setMasterVolume(level);
+
if (_canyonChaseMovie.isMovieValid())
_canyonChaseMovie.setVolume(level);
@@ -2842,6 +2851,7 @@ void Mars::marsTimerExpired(MarsTimerEvent &event) {
initOneMovie(&_junk, "Images/Mars/Junk.movie", kShuttleJunkOrder, kShuttleJunkLeft, kShuttleJunkTop, false);
initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
+ _explosions.setVolume(_vm->getSoundFXLevel());
_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
_energyBeam.initShuttleWeapon();
@@ -3175,6 +3185,7 @@ void Mars::spaceChaseClick(const Input &input, const HotSpotID id) {
// Shameless reuse of a variable :P
initOneMovie(&_canyonChaseMovie, "Images/Mars/M98EAS.movie", kShuttleTractorBeamMovieOrder,
kShuttleWindowLeft, kShuttleWindowTop, true);
+ _canyonChaseMovie.setVolume(_vm->getSoundFXLevel());
_canyonChaseMovie.redrawMovieWorld();
playMovieSegment(&_canyonChaseMovie, 0, _canyonChaseMovie.getDuration());
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 320fbdabaa..c9be349694 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -1495,7 +1495,15 @@ void Neighborhood::loadLoopSound2(const Common::String &soundName, uint16 volume
if (!_loop2SoundString.empty()) {
_soundLoop2.initFromAIFFFile(_loop2SoundString);
_soundLoop2.loopSound();
- _loop2Fader.setMasterVolume(_vm->getAmbienceLevel());
+ // HACK: Some ambient loops are actually sound effects, like Ares waiting at
+ // the reactor and Poseidon at the launch console. Detect these and use the
+ // SFX volume instead of ambience.
+ if (soundName == "Sounds/Mars/Robot Loop.aiff" ||
+ soundName == "Sounds/Norad/Breathing Typing.22K.AIFF" ||
+ soundName == "Sounds/Norad/N54NAS.32K.AIFF")
+ _loop2Fader.setMasterVolume(_vm->getSoundFXLevel());
+ else
+ _loop2Fader.setMasterVolume(_vm->getAmbienceLevel());
_loop2Fader.setFaderValue(0);
faderMove.makeTwoKnotFaderSpec(fadeScale, 0, 0, fadeIn, volume);
_loop2Fader.startFaderSync(faderMove);
@@ -1580,6 +1588,7 @@ void Neighborhood::closeCroppedMovie() {
void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, CoordType left, CoordType top, const InputBits interruptionFilter) {
openCroppedMovie(movieName, left, top);
+ _croppedMovie.setVolume(_vm->getSoundFXLevel());
_croppedMovie.redrawMovieWorld();
_croppedMovie.start();
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 3c1c5eac92..f7f2b038c6 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -91,6 +91,7 @@ struct QueueRequest {
bool operator==(const QueueRequest &arg1, const QueueRequest &arg2);
bool operator!=(const QueueRequest &arg1, const QueueRequest &arg2);
+class CaldoriaBomb;
class GameInteraction;
class Item;
class Neighborhood;
@@ -109,6 +110,7 @@ protected:
typedef Common::Queue<QueueRequest> NeighborhoodActionQueue;
class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler {
+friend class CaldoriaBomb;
friend class StriderCallBack;
public:
diff --git a/engines/pegasus/neighborhood/norad/delta/globegame.cpp b/engines/pegasus/neighborhood/norad/delta/globegame.cpp
index 0b95e9bc2b..5c321a8e8a 100644
--- a/engines/pegasus/neighborhood/norad/delta/globegame.cpp
+++ b/engines/pegasus/neighborhood/norad/delta/globegame.cpp
@@ -453,8 +453,13 @@ GlobeGame::GlobeGame(Neighborhood *handler) : GameInteraction(kNoradGlobeGameInt
_neighborhoodNotification = handler->getNeighborhoodNotification();
}
+void GlobeGame::setSoundFXLevel(const uint16 fxLevel) {
+ _monitorMovie.setVolume(fxLevel);
+}
+
void GlobeGame::openInteraction() {
_monitorMovie.initFromMovieFile("Images/Norad Delta/N79 Left Monitor");
+ _monitorMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
_monitorMovie.moveElementTo(kGlobeMonitorLeft, kGlobeMonitorTop);
_monitorMovie.setDisplayOrder(kGlobeMonitorLayer);
_monitorMovie.startDisplaying();
diff --git a/engines/pegasus/neighborhood/norad/delta/globegame.h b/engines/pegasus/neighborhood/norad/delta/globegame.h
index 73ed48866f..93235a1784 100644
--- a/engines/pegasus/neighborhood/norad/delta/globegame.h
+++ b/engines/pegasus/neighborhood/norad/delta/globegame.h
@@ -98,6 +98,8 @@ public:
GlobeGame(Neighborhood *);
virtual ~GlobeGame() {}
+ void setSoundFXLevel(const uint16);
+
void handleInput(const Input &, const Hotspot *);
void clickInHotspot(const Input &, const Hotspot *);
void activateHotspots();
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
index 1eea2f0156..ee047d72b2 100644
--- a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
+++ b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
@@ -514,6 +514,17 @@ void NoradDelta::openDoor() {
}
}
+void NoradDelta::cantMoveThatWay(CanOpenDoorReason reason) {
+ // WORKAROUND: The door outside the launch console room isn't treated as a door,
+ // so play the correct sound.
+ if (reason == kCantMoveBlocked && GameState.getCurrentRoomAndView() == MakeRoomView(kNorad67, kNorth)) {
+ cantOpenDoor(kCantOpenLocked);
+ return;
+ }
+
+ Neighborhood::cantMoveThatWay(reason);
+}
+
void NoradDelta::activateHotspots() {
Norad::activateHotspots();
@@ -863,6 +874,13 @@ void NoradDelta::doSolve() {
}
}
+void NoradDelta::setSoundFXLevel(const uint16 level) {
+ Neighborhood::setSoundFXLevel(level);
+
+ if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad54North, kNorth))
+ _loop2Fader.setMasterVolume(level);
+}
+
Common::String NoradDelta::getSoundSpotsName() {
return "Sounds/Norad/Norad Delta Spots";
}
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.h b/engines/pegasus/neighborhood/norad/delta/noraddelta.h
index 11065f2c9d..591fd691a2 100644
--- a/engines/pegasus/neighborhood/norad/delta/noraddelta.h
+++ b/engines/pegasus/neighborhood/norad/delta/noraddelta.h
@@ -68,6 +68,8 @@ public:
bool canSolve();
void doSolve();
+ void setSoundFXLevel(const uint16);
+
void doorOpened();
protected:
@@ -90,6 +92,7 @@ protected:
void arriveAtNorad79West();
TimeValue getViewTime(const RoomID, const DirectionConstant);
void openDoor();
+ void cantMoveThatWay(CanMoveForwardReason);
void activateHotspots();
void clickInHotspot(const Input &, const Hotspot *);
void receiveNotification(Notification *, const NotificationFlags);
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a0ec12a7c4..0010180d8d 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -307,6 +307,7 @@ void PegasusEngine::runIntro() {
Video::VideoDecoder *video = new Video::QuickTimeDecoder();
if (video->loadFile(_introDirectory + "/BandaiLogo.movie")) {
+ video->setVolume(MIN<uint>(getAmbienceLevel(), 0xFF));
video->start();
while (!shouldQuit() && !video->endOfVideo() && !skipped) {
@@ -338,6 +339,8 @@ void PegasusEngine::runIntro() {
if (!video->loadFile(_introDirectory + "/Big Movie.movie"))
error("Could not load intro movie");
+ video->setVolume(MIN<uint>(getAmbienceLevel(), 0xFF));
+
video->seek(Audio::Timestamp(0, 10 * 600, 600));
video->start();
@@ -794,6 +797,8 @@ void PegasusEngine::introTimerExpired() {
if (!video->loadFile(_introDirectory + "/LilMovie.movie"))
error("Failed to load little movie");
+ video->setVolume(MIN<uint>(getAmbienceLevel(), 0xFF));
+
bool saveAllowed = swapSaveAllowed(false);
bool openAllowed = swapLoadAllowed(false);
@@ -941,6 +946,8 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
if (!video->loadFile(_introDirectory + "/Closing.movie"))
error("Could not load closing movie");
+ video->setVolume(MIN<uint>(getSoundFXLevel(), 0xFF));
+
uint16 x = (640 - video->getWidth() * 2) / 2;
uint16 y = (480 - video->getHeight() * 2) / 2;
diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index e97db04a8f..8c5f9be425 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -4020,12 +4020,14 @@ static const struct ADGameDescription SciGameDescriptions[] = {
#endif // ENABLE_SCI32
// SCI Fanmade Games
+ FANMADE("120 Degrees Below Zero", "57f6135bd073802215c9b97f32d6aea3", 504, "03adf530a34557dfc20f848c9572f4d0", 320749),
FANMADE("Al Pond: Island Quest 2", "4cba6a5a4c8f66f21935ed78b0511a92", 870, "876587dc9a5ec569287a3dc4b29139d8", 613769),
FANMADE("Al Pond 2: Island Quest", "9625372e710d1a95d2027b48f9e325af", 1506, "a0f9aa65b9bf3d8703adff5a621f243c", 889843),
FANMADE("Al Pond 2: Island Quest (Updated)", "64be277cdcc6aafce7d9f26e88ad31a8", 1500, "571547228a212d63315f0c114cf48d54", 885241),
FANMADE("Another DG Game: I Want My C64 Back", "4a8ca7ca2abd18899ef856f47665e2e9", 588, "12ff558d20c72e42cc6adb408f34d6d8", 150513),
FANMADE_L("Another DG Game: I Want My C64 Back", "13dc1d9ebc57daf8895412eee5e39fea", 576, "e2ad60b3a280171429db5c85f158f84a", 141697, Common::FR_FRA),
FANMADE("Aquarius: An Aquatic Experience", "2e23bc3b82f22a454be202ea593fb478", 480, "01555c8de683d25405bda270aa1ff014", 272372),
+ FANMADE("Betrayed Alliance", "b1f43f496a83cb8503f290a838b26242", 4062, "e637255aae6191ee92b9e843ad276288", 2367197),
FANMADE("Bluntman and Chronic (Politically Correct Version)", "c3ef9fa6c7c5fb840078bf28d87c7f8b", 1362, "441636a9f6f86710844868fded868ee7", 596688),
FANMADE("Cascade Quest", "c94efc10d18c040b6e22a1dc6d3adfe1", 3468, "8ada33dfa945f81531e5508240b573de", 1432195),
FANMADE("Circus Quest", "35871f6b4e1df56af4113c0203a0b223", 630, "7d6f97d7935d8733f488d4cb74315e5b", 279627),
@@ -4033,26 +4035,40 @@ static const struct ADGameDescription SciGameDescriptions[] = {
FANMADE("Curt's Quest 1.1", "54084c29346683296e45ef32d7ae74f3", 1128, "c851182cdf6fc6a81b840f4d4875f1a0", 302000),
FANMADE("Demo Quest", "c89a0c9e0a4e4af0ecedb300a3b31dbf", 384, "a32f3495ba24764cba091119cc3f1e13", 160098),
FANMADE("Dr. Jummybummy's Space Adventure 2", "6ae6cb7de423f51736d9487b4ca0c6da", 810, "26e5b563f578e104d79689f36568b7cf", 394670),
+ FANMADE("Edy Oliver into the Cave of Whistling Skulls Demo", "eba0a0e86768ee3f14e78fecbc5af011", 2388, "4f6eab79a0f7980960eed101ab8122ad", 2601551),
+ FANMADE("Footsteps Sound Demo", "d9dabee6e1550b1fdb793f442f227738", 372, "06561df40dea49c6e84184e0ba6f19cb", 114212),
FANMADE_L("Grostesteing: Plus Mechant que Jamais", "ec9a97ccb134f69249f6ea8b16c13d8e", 1500, "b869f5f11bfe2ab5f67f4f0c618f2ce1", 464657, Common::FR_FRA), // FIXME: Accent
FANMADE("Humanoid Demo", "97d8331293a6d57e8bad58c1efc89a63", 624, "fb354b9abe64011b12159e45d724633f", 452320),
+ FANMADE("Island of Secrets Demo 0.3", "61279176c3e4530fec9b578877aecda7", 504, "7f4ed7a81b86bea22c62bc98e6d9ec39", 197790),
FANMADE("Jim’s Quest 1: The Phantom Thesis", "0af50be1d3f0cb77a09137709a76ef4f", 960, "9c042c136548b20d9183495668e03526", 496446),
+ FANMADE("King's Quest II SCI Pre-Alpha Version", "cdea1c081022e7697a1afffb1d2f9f6a", 2646, "fb2ce39002c3e05f3d83533638dea105", 2310356),
FANMADE("Knight's Quest Demo 1.0", "5e816edf993956752ed06fccfeeae6d9", 1260, "959321f88a22905fa1f8c6d897874744", 703836),
FANMADE("LockerGnome Quest", "3eeff9130206cad0c4e1551e2b9dd2c5", 420, "ae05ca90806fd90cc43f147c82d3547c", 158906),
+ FANMADE("LockerGnome Quest Redux", "55b0081dbdd77a07807c76cec3606970", 492, "75c9c5e8a475a7b5f1a6cb18edad67f2", 168069),
FANMADE("New Year's Mystery", "e4dcab1b1d3cb4a2c070a07a9c9589e0", 708, "e00ca5e44fd4e98d8174b467b31b0f21", 295425),
FANMADE("New Year's Mystery (Updated)", "efd1beb5120293725065c95959144f81", 714, "b3bd3c2372ed6efa28adb12403c4c31a", 305027),
FANMADE("Ocean Battle", "c2304a0568e0eb84f8e9a0915f01170a", 408, "46c520c1ac9b63528854d0f58c7e1b74", 142234),
FANMADE("Osama", "db8f1710453cfbecf4214b2946970043", 390, "7afd75d4620dedf97a84ae8f0a7523cf", 123827),
FANMADE("Quest for the Cheat", "a359d4cf27f98264b42b55c017671214", 882, "8a943029f73c4bc85d454b7f473455ba", 455209),
+ FANMADE("Robust Parse Demo 1.2", "c956d40b6eb42292ec328c510acb11d8", 540, "26f092bab5ec4490737d8463fd3ebbd5", 229044),
FANMADE("SCI Capture the Flag", "4cd679a51d93b8b27c6b38d81be24b8b", 432, "98ae1f6ed7b4c21f88addbf643dd1d2f", 147878),
FANMADE("SCI Companion Template", "ad54d4f504086cd597aa2348d0aa3b09", 354, "6798b7b601ce8154c1d1bc0f0edcdd18", 113061),
+ FANMADE("SCI Logging Demo", "615c30c1445ea9349847e8868312a674", 558, "2df6858526177612ef9473e7af5b31c6", 171012),
+#ifdef 0
+ // Disabled as this requires network access to the Google Translate API, which is not available as OSystem has no network API.
+ FANMADE("SCI Narration Demo", "731f4f2b726a13c153380af08da16591", 360, "38c80558fb942e8568f011d4a1a4af59", 109789),
+#endif
FANMADE("SCI Programming April 2010 Competition Template", "36e5c4011dd7c92e1ae4c6fede7d698d", 456, "20c87fbb7f73e2a3eb2c5dfab4d76b5a", 142221),
FANMADE("SCI Studio Template 3.0", "ca0dc8d586e0a8670b7621cde090b532", 354, "58a48ee692a86c0575e6bd0b00a92b9a", 113097),
FANMADE("SCI Quest", "9067e1f1e54436d2dbfce855524bc84a", 552, "ffa7d355cd9223f245289108a696bcd2", 149634),
FANMADE("SCI-Man", "3ab85bd39a86c11f85781764f9db09bb", 468, "bb8f9992f504a242bf0860e3588e150b", 131810),
- FANMADE("The Black Cauldron", "5e1ff2833c7f33ebcfa456ba836e2067", 2592, "2f8e6264d2db91bb54982ab8aa18b3b4", 1881839),
+ FANMADE("Text Views Demo", "ad0485a96470566517f184ff5dd049f8", 372, "727b946b37588ed334737732c55007c4", 115788),
+ FANMADE("The Black Cauldron Demo", "5e1ff2833c7f33ebcfa456ba836e2067", 2592, "2f8e6264d2db91bb54982ab8aa18b3b4", 1881839),
+ FANMADE("The Black Cauldron Final", "cbb4705f0cd73760996e5b27aae54f6a", 2484, "fc3bcaa7783b91bb78faefa345c6b3d9", 1677293),
FANMADE("The Farm Nightmare", "fb6cbfddaa7c055e2c3d8cf4c683a7db", 906, "50655e8b8925f717e698e08f006f40be", 338303),
FANMADE("The Gem Scenario", "ef5f61f4d2c6d31122d3e2baf89ad976", 642, "2f16be390dd90c3d7ca1c8a594ac0bfa", 244794),
FANMADE("The Legend of the Lost Jewel", "ba1bca315e3818c5626eda51bcfbcccf", 636, "9b0736d69924af0cff32a0f78db96855", 300398),
+ FANMADE("Winter Wonderland", "c1ffaf8327462effd4ad21eeed9eea59", 504, "5d48666dc62f90d852a1d0de6e69195f", 305076),
// FIXME: The vga demo does not have a resource.000/001 file.
//FANMADE_V("SCI VGA Demo", "00b1abd87bad356b90fcdfcb6132c26f", 8, "", 0, 0),
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;
}
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index ec392a877a..fa4e508494 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -250,7 +250,18 @@ void Dialog::handleKeyDown(Common::KeyState state) {
close();
}
- // TODO: tab/shift-tab should focus the next/previous focusable widget
+ if (state.keycode == Common::KEYCODE_TAB) {
+ // TODO: Maybe add Tab behaviours for all widgets too.
+ // searches through widgets on screen for tab widget
+ Widget *w = _firstWidget;
+ while (w) {
+ if (w->_type == kTabWidget)
+ if (w->handleKeyDown(state))
+ return;
+
+ w = w->_next;
+ }
+ }
}
void Dialog::handleKeyUp(Common::KeyState state) {
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index a8b3f5450d..756781a04b 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -183,6 +183,7 @@ void TabWidget::setActiveTab(int tabID) {
}
_activeTab = tabID;
_firstWidget = _tabs[tabID].firstWidget;
+
_boss->draw();
}
}
@@ -226,12 +227,34 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) {
}
bool TabWidget::handleKeyDown(Common::KeyState state) {
- // TODO: maybe there should be a way to switch between tabs
- // using the keyboard? E.g. Alt-Shift-Left/Right-Arrow or something
- // like that.
+ if (state.hasFlags(Common::KBD_SHIFT) && state.keycode == Common::KEYCODE_TAB)
+ adjustTabs(kTabBackwards);
+ else if (state.keycode == Common::KEYCODE_TAB)
+ adjustTabs(kTabForwards);
+
return Widget::handleKeyDown(state);
}
+void TabWidget::adjustTabs(int value) {
+ // Determine which tab is next
+ int tabID = _activeTab + value;
+ if (tabID >= (int)_tabs.size())
+ tabID = 0;
+ else if (tabID < 0)
+ tabID = ((int)_tabs.size() - 1);
+
+ // Slides _firstVisibleTab forward to the correct tab
+ int maxTabsOnScreen = (_w / _tabWidth);
+ if (tabID >= maxTabsOnScreen && (_firstVisibleTab + maxTabsOnScreen) < (int)_tabs.size())
+ _firstVisibleTab++;
+
+ // Slides _firstVisibleTab backwards to the correct tab
+ while (tabID < _firstVisibleTab)
+ _firstVisibleTab--;
+
+ setActiveTab(tabID);
+}
+
void TabWidget::reflowLayout() {
Widget::reflowLayout();
diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h
index 38aa089eb5..a01ee2d9dc 100644
--- a/gui/widgets/tab.h
+++ b/gui/widgets/tab.h
@@ -28,6 +28,11 @@
#include "common/array.h"
namespace GUI {
+
+enum {
+ kTabForwards = 1,
+ kTabBackwards = -1
+};
class TabWidget : public Widget {
typedef Common::String String;
@@ -109,6 +114,8 @@ protected:
virtual void drawWidget();
virtual Widget *findWidget(int x, int y);
+
+ virtual void adjustTabs(int value);
};
} // End of namespace GUI