Initial version of Cinematique engine evo 1.

svn-id: r20813
This commit is contained in:
Eugene Sandulenko 2006-02-22 22:40:53 +00:00
parent a467247e6e
commit 71c170bb13
51 changed files with 13495 additions and 5 deletions

View File

@ -37,6 +37,11 @@ ScummVM Team
Torbjorn Andersson
Jonathan Gray
Cinematique evo 1:
Pawel Kolodziejski
Gregory Montoir
Eugene Sandulenko
FOTAQ:
David Eriksson
Gregory Montoir
@ -100,7 +105,7 @@ ScummVM Team
Tore Anderson - Former Debian GNU/Linux maintainer
Ralph Brorsen - Help with GUI implementation
Jamieson Christian - iMUSE, MIDI, all things musical
Vincent Hamm - Co-Founder
Vincent Hamm - Co-Founder, original CinE engine author
Ruediger Hanke - Port: MorphOS
Felix Jakschitsch - Zak256 reverse engineering
Mutwin Kraus - Original MacOS porter

13
configure vendored
View File

@ -58,6 +58,7 @@ _build_saga=yes
_build_gob=yes
_build_kyra=yes
_build_lure=no
_build_cine=no
_need_memalign=no
_build_plugins=no
_nasm=auto
@ -305,6 +306,7 @@ Optional Features:
--disable-gob don't build the Gobli*ns engine
--disable-kyra don't build the Legend of Kyrandia engine
--enable-lure build the Lure of the Temptress engine
--enable-cine build the Cinematique engine evo 1
--enable-plugins build engines as loadable modules instead of
static linking them
--disable-mt32emu don't enable the integrated MT-32 emulator
@ -371,6 +373,7 @@ for ac_option in $@; do
--disable-gob) _build_gob=no ;;
--disable-kyra) _build_kyra=no ;;
--enable-lure) _build_lure=yes ;;
--enable-cine) _build_cine=yes ;;
--disable-hq-scalers) _build_hq_scalers=no ;;
--disable-scalers) _build_scalers=no ;;
--enable-alsa) _alsa=yes ;;
@ -691,6 +694,12 @@ else
_mak_lure='# DISABLE_LURE = 1'
fi
if test "$_build_cine" = no ; then
_mak_lure='DISABLE_CINE = 1'
else
_mak_lure='# DISABLE_CINE = 1'
fi
if test "$_build_hq_scalers" = no ; then
_mak_hq_scalers='DISABLE_HQ_SCALERS = 1'
else
@ -1259,6 +1268,9 @@ fi
if test "$_build_lure" = yes ; then
echo " Lure of the Temptress"
fi
if test "$_build_cine" = yes ; then
echo " Cinematique evo 1"
fi
echo
@ -1395,6 +1407,7 @@ $_mak_kyra
$_mak_saga
$_mak_gob
$_mak_lure
$_mak_cine
$_mak_mt32emu
$_mak_hq_scalers

View File

@ -54,6 +54,14 @@
Jonathan Gray & \textit{}\\
\end{tabular}
\end{list}
\item \textbf{ Cinematique evo 1}
\begin{list}{}{\setlength{\leftmargin}{0.2cm}}
\item \begin{tabular}[h]{p{0.3\linewidth}p{0.6\linewidth}}
Pawe{\l} Ko{\l}odziejski & \textit{}\\
Gregory Montoir & \textit{}\\
Eugene Sandulenko & \textit{}\\
\end{tabular}
\end{list}
\item \textbf{ FOTAQ}
\begin{list}{}{\setlength{\leftmargin}{0.2cm}}
\item \begin{tabular}[h]{p{0.3\linewidth}p{0.6\linewidth}}
@ -159,7 +167,7 @@ All active team members
Tore Anderson & \textit{Former Debian GNU/Linux maintainer}\\
Ralph Brorsen & \textit{Help with GUI implementation}\\
Jamieson Christian & \textit{iMUSE, MIDI, all things musical}\\
Vincent Hamm & \textit{Co-Founder}\\
Vincent Hamm & \textit{Co-Founder, original CinE engine author}\\
Ruediger Hanke & \textit{Port: MorphOS}\\
Felix Jakschitsch & \textit{Zak256 reverse engineering}\\
Mutwin Kraus & \textit{Original MacOS porter}\\

1057
engines/cine/anim.cpp Normal file

File diff suppressed because it is too large Load Diff

66
engines/cine/anim.h Normal file
View File

@ -0,0 +1,66 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_ANIM_H_
#define CINE_ANIM_H_
extern u16 frameVar0;
struct animHeaderStruct {
u8 field_0;
u8 field_1;
u8 field_2;
u8 field_3;
u16 frameWidth;
u16 frameHeight;
u8 field_8;
u8 field_9;
u8 field_A;
u8 field_B;
u8 field_C;
u8 field_D;
u16 numFrames;
u8 field_10;
u8 field_11;
u8 field_12;
u8 field_13;
u16 field_14;
};
typedef struct animHeaderStruct animHeaderStruct;
struct animDataEntry {
char name[9];
u8 param;
};
typedef struct animDataEntry animDataEntry;
extern animDataEntry animData[];
void loadResource(char *animName);
void loadAbs(char *resourceName, u16 idx);
void loadResourcesFromSave();
#endif

49
engines/cine/auto00.cpp Normal file
View File

@ -0,0 +1,49 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
unsigned char AUT000[] = {
0x00, 0x32, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x6b, 0x6c, 0x01, 0x40,
0x50, 0x41, 0x52, 0x54,
0x30, 0x31, 0x00, 0x42, 0x00, 0x49, 0x4e, 0x54, 0x52, 0x4f, 0x2e, 0x50,
0x52, 0x43, 0x00, 0x42,
0x02, 0x49, 0x4e, 0x54, 0x52, 0x4f, 0x2e, 0x4f, 0x42, 0x4a, 0x00, 0x3d,
0x4c, 0x4f, 0x47, 0x4f,
0x2e, 0x50, 0x49, 0x31, 0x00, 0x46, 0x50, 0x6e, 0x44, 0x55, 0x47, 0x47,
0x45, 0x52, 0x2e, 0x44,
0x41, 0x54, 0x00, 0x3d, 0x43, 0x49, 0x4e, 0x45, 0x4d, 0x41, 0x2e, 0x50,
0x49, 0x31, 0x00, 0x47,
0x46, 0x6f, 0x43, 0x51, 0x00, 0x1e, 0x1e, 0x43, 0x51, 0x00,
};

32
engines/cine/auto00.h Normal file
View File

@ -0,0 +1,32 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_AUTO00_H_
#define CINE_AUTO00_H_
extern unsigned char AUT000[];
#define AUT000_size sizeof(AUT000);
#endif

154
engines/cine/bg.cpp Normal file
View File

@ -0,0 +1,154 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
u16 bgVar0;
void loadCtHigh(u8 * currentPtr) {
currentPtr += 256 * 3;
memcpy(page3Raw, currentPtr, 320 * 200);
}
u8 loadCt(const char *ctName) {
u8 *ptr;
u8 *currentPtr;
u8 i;
u16 header[0x20];
///
strcpy(currentCtName, ctName);
currentPtr = ptr = readBundleFile(findFileInBundle(ctName));
if (gameType == Cine::GID_OS) {
if (*(u16 *) currentPtr == 0x800) // detect 256 color background
{
loadCtHigh(currentPtr + 2);
return 0;
}
currentPtr += 2;
currentPtr += 0x20;
gfxResetRawPage(page3Raw);
gfxConvertSpriteToRaw(page3Raw, ptr + 0x22, 160, 200);
} else {
loadRelatedPalette(ctName);
ASSERT(strstr(ctName, ".NEO"));
memcpy(header, currentPtr, 0x20);
currentPtr += 0x20;
for (i = 0; i < 0x20; i++) {
flipU16(&header[i]);
}
gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200);
}
return 0;
}
void loadBgHigh(char *currentPtr) {
memcpy(palette256, currentPtr, 256 * 3);
currentPtr += 256 * 3;
memcpy(page2Raw, currentPtr, 320 * 200);
colorMode256 = 1;
}
u8 loadBg(const char *bgName) {
u8 *ptr;
u8 *currentPtr;
u8 i;
u8 fileIdx;
strcpy(currentBgName[0], bgName);
fileIdx = findFileInBundle(bgName);
currentPtr = ptr = readBundleFile(fileIdx);
if (*(u16 *) currentPtr == 0x800) // detect 256 color background
{
loadBgHigh((char *)currentPtr + 2);
return 0;
}
colorMode256 = 0;
memcpy(&dummyU16, currentPtr, 2);
currentPtr += 2;
memcpy(tempPalette, currentPtr, 32);
currentPtr += 0x20;
for (i = 0; i < 16; i++) {
flipU16(&tempPalette[i]);
}
loadRelatedPalette(bgName);
gfxResetRawPage(page2Raw);
gfxConvertSpriteToRaw(page2Raw, ptr + 0x22, 160, 200);
return 0;
}
u8 *additionalBgTable[9] =
{ page2Raw, NULL, NULL, NULL, NULL, NULL, NULL, NULL, page3Raw };
u8 currentAdditionalBgIdx = 0;
u8 currentAdditionalBgIdx2 = 0;
void addBackground(char *bgName, u16 bgIdx) {
u8 *ptr;
u8 *currentPtr;
u8 fileIdx;
strcpy(currentBgName[bgIdx], bgName);
fileIdx = findFileInBundle(bgName);
currentPtr = ptr = readBundleFile(fileIdx);
additionalBgTable[bgIdx] = (u8 *) malloc(320 * 200);
if (*(u16 *) currentPtr == 0x800) // detect 256 color background
{
memcpy(additionalBgTable[bgIdx], currentPtr + 2 + 3 * 256,
320 * 200);
return;
}
currentPtr += 2;
currentPtr += 0x20;
gfxConvertSpriteToRaw(additionalBgTable[bgIdx], ptr + 0x22, 160, 200);
}

39
engines/cine/bg.h Normal file
View File

@ -0,0 +1,39 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_BG_H_
#define CINE_BG_H_
u8 loadBg(const char *bgName);
u8 loadCt(const char *bgName);
extern u8 *additionalBgTable[9];
extern u8 currentAdditionalBgIdx;
extern u8 currentAdditionalBgIdx2;
void addBackground(char *bgName, u16 bgIdx);
extern u16 bgVar0;
#endif

47
engines/cine/bg_list.cpp Normal file
View File

@ -0,0 +1,47 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
void createVar9Element(s16 objIdx, s16 param);
void addSpriteFilledToBGList(s16 idx) {
s16 x;
s16 y;
s16 width;
s16 height;
x = objectTable[idx].x;
y = objectTable[idx].y;
width = animDataTable[objectTable[idx].frame].width;
height = animDataTable[objectTable[idx].frame].var2;
if (animDataTable[objectTable[idx].frame].ptr1) {
gfxFillSprite(animDataTable[objectTable[idx].frame].ptr1,
width / 2, height, page2Raw, x, y);
}
createVar9Element(idx, 1);
}

30
engines/cine/bg_list.h Normal file
View File

@ -0,0 +1,30 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_BGLIST_H_
#define CINE_BGLIST_H_
void addSpriteFilledToBGList(s16 idx);
#endif

256
engines/cine/cine.cpp Normal file
View File

@ -0,0 +1,256 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/stdafx.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/config-manager.h"
#include "base/gameDetector.h"
#include "base/plugins.h"
#include "backends/fs/fs.h"
#include "sound/mididrv.h"
#include "sound/mixer.h"
#include "cine/cine.h"
#include "cine/sound_driver.h"
Audio::Mixer * cine_g_mixer;
AdlibMusic *g_cine_adlib;
static void initialize();
char *savePath;
struct CINEGameSettings {
const char *name;
const char *description;
byte id;
uint32 features;
const char *detectname;
GameSettings toGameSettings() const {
GameSettings dummy = { name, description };
return dummy;
}
};
static const CINEGameSettings cine_settings[] = {
{"fw", "Future Wars", Cine::GID_FW, MDT_ADLIB, "AUTO00.PRC"},
{"os", "Operation Stealth", Cine::GID_OS, MDT_ADLIB, "PROCS00"},
{NULL, NULL, 0, 0, NULL}
};
// Keep list of different supported games
static const GameSettings cine_list[] = {
{"fw", "Future Wars"},
{"os", "Operation Stealth"},
{0, 0}
};
GameList Engine_CINE_gameIDList() {
GameList games;
const GameSettings *g = cine_list;
while (g->gameid) {
games.push_back(*g);
g++;
}
return games;
}
GameSettings Engine_CINE_findGameID(const char *gameid) {
const GameSettings *g = cine_list;
while (g->gameid) {
if (0 == strcmp(gameid, g->gameid))
break;
g++;
}
return *g;
}
DetectedGameList Engine_CINE_detectGames(const FSList &fslist) {
DetectedGameList detectedGames;
const CINEGameSettings *g;
for (g = cine_settings; g->name; ++g) {
// Iterate over all files in the given directory
for (FSList::const_iterator file = fslist.begin();
file != fslist.end(); ++file) {
const char *gameName = file->displayName().c_str();
if (0 == scumm_stricmp(g->detectname, gameName)) {
// Match found, add to list of candidates, then abort inner loop.
detectedGames.push_back(g->toGameSettings());
break;
}
}
}
return detectedGames;
}
Engine *Engine_CINE_create(GameDetector *detector, OSystem *syst) {
return new Cine::CineEngine(detector, syst);
}
REGISTER_PLUGIN(CINE, "CINE Engine")
namespace Cine {
CineEngine::CineEngine(GameDetector *detector, OSystem *syst) : Engine(syst) {
// Setup mixer
if (!_mixer->isReady()) {
warning("Sound initialization failed.");
}
cine_g_mixer = _mixer;
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType,
ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType,
ConfMan.getInt("music_volume"));
_dataPath = getGameDataPath();
_savePath = _saveFileMan->getSavePath();
Common::File::addDefaultDirectory(_gameDataPath);
const CINEGameSettings *g;
for (g = cine_settings; g->name; ++g)
if (!scumm_stricmp(g->name, detector->_targetName.c_str()))
_gameId = g->id;
gameType = _gameId;
}
CineEngine::~CineEngine() {
}
void CineEngine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
}
int CineEngine::init(GameDetector &detector) {
// Initialize backend
_system->beginGFXTransaction();
initCommonGFX(detector, false);
_system->initSize(320, 200);
_system->endGFXTransaction();
g_cine_adlib = new AdlibMusic(_mixer);
initialize();
return 0;
}
int CineEngine::go() {
_system->showMouse(true);
mainLoop(1);
if (gameType == Cine::GID_FW)
snd_clearBasesonEntries();
delete g_cine_adlib;
return 0;
}
}
int gameType;
static void initialize() {
u16 i;
init_video();
textDataPtr = (u8 *) malloc(8000);
partBuffer = (partBufferStruct *) malloc(255 * sizeof(animDataStruct));
loadTextData("texte.dat", textDataPtr);
snd_loadBasesonEntries("BASESON.SND");
for (i = 0; i < NUM_MAX_OBJECT; i++) {
objectTable[i].part = 0;
objectTable[i].name[0] = 0;
}
for (i = 0; i < NUM_MAX_OBJECTDATA; i++) {
globalVars[i] = 0;
}
globalVars[255] = 1;
for (i = 0; i < NUM_MAX_SCRIPT; i++) {
scriptTable[i].ptr = NULL;
scriptTable[i].var4 = 0;
}
for (i = 0; i < NUM_MAX_MESSAGE; i++) {
messageTable[i].ptr = NULL;
messageTable[i].len = 0;
}
for (i = 0; i < NUM_MAX_REL; i++) {
relTable[i].ptr0 = NULL;
relTable[i].var4 = 0;
relTable[i].var6 = 0;
relTable[i].var8 = 0;
}
for (i = 0; i < NUM_MAX_PARTDATA; i++) {
animDataTable[i].ptr1 = NULL;
animDataTable[i].ptr2 = NULL;
}
overlayHead.next = NULL;
overlayHead.previous = NULL;
var8 = 0;
var9 = NULL;
objScriptList.next = NULL;
globalScriptsHead.next = NULL;
objScriptList.scriptPtr = NULL;
globalScriptsHead.scriptPtr = NULL;
var2 = 0;
var3 = 0;
var4 = 0;
var5 = 0;
freePrcLinkedList();
loadPrc(BOOT_PRC_NAME);
strcpy(currentPrcName, BOOT_PRC_NAME);
processPendingUpdates(0);
}

109
engines/cine/cine.h Normal file
View File

@ -0,0 +1,109 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_H
#define CINE_H
#include "common/stdafx.h"
#include "common/scummsys.h"
#include "common/util.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
#include "base/engine.h"
#include "base/gameDetector.h"
namespace Cine {
enum CineGameId {
GID_FW = 1,
GID_OS
};
class CineEngine : public ::Engine {
int _gameId;
void errorString(const char *buf_input, char *buf_output);
protected:
int init(GameDetector & detector);
int go();
void shutdown();
const char *_dataPath;
const char *_savePath;
public:
CineEngine(GameDetector *detector, OSystem *syst);
virtual ~CineEngine();
int getGameId() {
return _gameId;
}
};
}
extern char *savePath;
typedef unsigned char u8;
typedef unsigned short int u16;
typedef unsigned long int u32;
typedef signed char s8;
typedef signed short int s16;
typedef signed long int s32;
#define ASSERT_PTR assert
#define ASSERT assert
#pragma pack(1)
#define BOOT_PRC_NAME "AUTO00.PRC"
#include "cine/font.h"
#include "cine/various.h"
#include "cine/flip_support.h"
#include "cine/texte.h"
#include "cine/object.h"
#include "cine/rel.h"
#include "cine/script.h"
#include "cine/part.h"
#include "cine/prc.h"
#include "cine/main_loop.h"
#include "cine/resource.h"
#include "cine/msg.h"
#include "cine/bg.h"
#include "cine/pal.h"
#include "cine/gfx.h"
#include "cine/anim.h"
#include "cine/auto00.h"
#include "cine/unpack.h"
#include "cine/bg_list.h"
#include "cine/sfx_player.h"
#include "cine/sound_driver.h"
extern AdlibMusic *g_cine_adlib;
#endif

View File

@ -0,0 +1,57 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
void flipU16(u16 * pVar) {
*pVar = (((*pVar) & 0xFF) << 8) | (((*pVar) & 0xFF00) >> 8);
}
void flipU32(u32 * pVar) {
u16 part1;
u16 part2;
part1 = (u16) ((*pVar) & 0xFFFF);
part2 = (u16) (((*pVar) & 0xFFFF0000) >> 16);
flipU16(&part1);
flipU16(&part2);
*pVar = (part2) | ((u32) part1 << 16);
}
u16 readU16LE(const void *ptr) {
const u8 *b = (const u8 *)ptr;
return (b[1] << 8) | b[0];
}
u16 readU16BE(const void *ptr) {
const u8 *b = (const u8 *)ptr;
return (b[0] << 8) | b[1];
}
u32 readU32BE(const void *ptr) {
const u8 *b = (const u8 *)ptr;
return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
}

View File

@ -0,0 +1,34 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_FLIPSUPPORT_H_
#define CINE_FLIPSUPPORT_H_
void flipU16(u16 *);
void flipU32(u32 *);
u16 readU16LE(const void *ptr);
u16 readU16BE(const void *ptr);
u32 readU32BE(const void *ptr);
#endif

62
engines/cine/font.cpp Normal file
View File

@ -0,0 +1,62 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
characterEntry fontParamTable[256] = {
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, {63, 1}, {69, 5}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, {68, 3},
{64, 3}, {65, 3}, { 0, 0}, { 0, 0}, {62, 2}, {74, 6}, {66, 1}, {67, 6},
{52, 6}, {53, 6}, {54, 6}, {55, 6}, {56, 6}, {57, 6}, {58, 6}, {59, 6},
{60, 6}, {61, 6}, {76, 3}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, {75, 6},
{ 0, 0}, { 0, 6}, //a
{ 1, 6}, { 2, 6}, { 3, 6}, { 4, 6}, { 5, 6}, { 6, 6},
{ 7, 6}, { 8, 3}, { 9, 6}, {10, 6}, {11, 6}, {12, 7}, {13, 6}, {14, 6},
{15, 6}, {16, 6}, {17, 6}, {18, 6}, {19, 6}, {20, 6}, {21, 6}, {22, 7},
{23, 6}, {24, 6}, {25, 6}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, {26, 6}, //a
{27, 6}, {28, 5}, {29, 6}, {30, 6}, {31, 5}, {32, 6},
{33, 6}, {34, 4}, {35, 4}, {36, 5}, {37, 3}, {38, 7}, {39, 6}, {40, 6},
{41, 6}, {42, 6}, {43, 6}, {44, 6}, {45, 6}, {46, 6}, {47, 6}, {48, 7},
{49, 6}, {50, 6}, {51, 6}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, {70, 6}, { 0, 0}, { 0, 0}, {72, 6}, { 0, 0}, {73, 5},
{77, 6}, { 0, 0}, {71, 6}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, {77, 6},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}
};

37
engines/cine/font.h Normal file
View File

@ -0,0 +1,37 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_FONT_H_
#define CINE_FONT_H_
struct characterEntry {
u8 characterIdx;
u8 characterWidth;
};
typedef struct characterEntry characterEntry;
extern characterEntry fontParamTable[256];
#endif

386
engines/cine/gfx.cpp Normal file
View File

@ -0,0 +1,386 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
byte *screenBuffer;
u16 c_palette[256];
unsigned char *page0;
unsigned char *page1;
unsigned char *page2;
unsigned char *page3;
u8 page1Raw[320 * 200];
u8 page2Raw[320 * 200];
u8 page3Raw[320 * 200];
void init_video() {
screenBuffer = (byte *) malloc(320 * 200 * 3);
assert(screenBuffer);
page0 = (unsigned char *)malloc(0x8000);
page1 = (unsigned char *)malloc(0x8000);
page2 = (unsigned char *)malloc(0x8000);
page3 = (unsigned char *)malloc(0x8000);
}
u16 transformColor(u16 baseColor, s8 r, s8 g, s8 b) {
s8 oriR = (baseColor & 0x7);
s8 oriG = (baseColor & 0x70) >> 4;
s8 oriB = (baseColor & 0x700) >> 8;
oriR += r;
oriG += g;
oriB += b;
if (oriR < 0)
oriR = 0;
if (oriR > 7)
oriR = 7;
if (oriG < 0)
oriG = 0;
if (oriG > 7)
oriG = 7;
if (oriB < 0)
oriB = 0;
if (oriB > 7)
oriB = 7;
return (oriR | (oriG << 4) | (oriB << 8));
}
void transformPaletteRange(u8 startColor, u8 stopColor, s8 r, s8 g, s8 b) {
u8 i;
for (i = startColor; i <= stopColor; i++) {
c_palette[i] = transformColor(tempPalette[i], b, g, r);
}
//gfxFlipPage(page2);
}
void gfxFillSprite(u8 *spritePtr, u16 width, u16 height, u8 *page, s16 x, s16 y) {
s16 i;
s16 j;
for (i = 0; i < height; i++) {
u8 *destPtr = page + x + y * 320;
destPtr += i * 320;
for (j = 0; j < width * 8; j++) {
if (x + j >= 0 && x + j < 320 && i + y >= 0
&& i + y < 200) {
if (!*(spritePtr++)) {
*(destPtr++) = 0;
} else {
destPtr++;
}
} else {
destPtr++;
spritePtr++;
}
}
}
}
void gfxDrawLine(s16 x1, s16 y1, s16 x2, s16 y2, u8 color, u8 *page) {
s16 t;
if (x1 == x2) {
if (y1 > y2) {
t = y1;
y1 = y2;
y2 = t;
}
while (y1 <= y2) {
*(page + (y1 * 320 + x1)) = color;
y1++;
}
} else {
if (x1 > x2) {
t = x1;
x1 = x2;
x2 = t;
}
while (x1 <= x2) {
*(page + (y1 * 320 + x1)) = color;
x1++;
}
}
}
void gfxDrawPlainBoxRaw(s16 x1, s16 y1, s16 x2, s16 y2, u8 color, u8 *page) {
s16 t;
if (x1 > x2) {
t = x1;
x1 = x2;
x2 = t;
}
if (y1 > y2) {
t = y1;
y1 = y2;
y2 = t;
}
t = x1;
while (y1 <= y2) {
x1 = t;
while (x1 <= x2) {
*(page + y1 * 320 + x1) = color;
x1++;
}
y1++;
}
}
s16 gfxGetBit(s16 x, s16 y, u8 *ptr, s16 width) {
u8 *ptrToData = (ptr) + y * width + x;
if (x > width) {
return 0;
}
if (*ptrToData) {
return 0;
}
return (1);
}
void gfxResetRawPage(u8 *pageRaw) {
memset(pageRaw, 0, 320 * 200);
}
void gfxConvertSpriteToRaw(u8 *dest, u8 *source, u16 width, u16 height) {
int x, y;
u8 b1, b2, b3, b4, b5, b6, b7, b8, d1a, d1b, d2a, d2b, d3a, d3b, d4a,
d4b;
for (y = 0; y < height; y++) {
for (x = 0; x < (width >> 3); x++) {
b4 = *(source++);
b8 = *(source++);
b3 = *(source++);
b7 = *(source++);
b2 = *(source++);
b6 = *(source++);
b1 = *(source++);
b5 = *(source++);
d1a = d1b = d2a = d2b = d3a = d3b = d4a = d4b = 0;
d1a |=
(((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) <<
2) | ((b1 & 1) << 3)) << 0;
d1b |=
(((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) <<
1) | ((b1 & 2) << 2)) << 0;
d2a |=
(((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >>
0) | ((b1 & 4) << 1)) << 0;
d2b |=
(((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >>
1) | ((b1 & 8) >> 0)) << 0;
b1 >>= 4;
b2 >>= 4;
b3 >>= 4;
b4 >>= 4;
d3a |=
(((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) <<
2) | ((b1 & 1) << 3)) << 0;
d3b |=
(((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) <<
1) | ((b1 & 2) << 2)) << 0;
d4a |=
(((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >>
0) | ((b1 & 4) << 1)) << 0;
d4b |=
(((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >>
1) | ((b1 & 8) >> 0)) << 0;
*(dest++) = d4b;
*(dest++) = d4a;
*(dest++) = d3b;
*(dest++) = d3a;
*(dest++) = d2b;
*(dest++) = d2a;
*(dest++) = d1b;
*(dest++) = d1a;
b1 = b5;
b2 = b6;
b3 = b7;
b4 = b8;
d1a = d1b = d2a = d2b = d3a = d3b = d4a = d4b = 0;
d1a |=
(((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) <<
2) | ((b1 & 1) << 3)) << 0;
d1b |=
(((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) <<
1) | ((b1 & 2) << 2)) << 0;
d2a |=
(((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >>
0) | ((b1 & 4) << 1)) << 0;
d2b |=
(((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >>
1) | ((b1 & 8) >> 0)) << 0;
b1 >>= 4;
b2 >>= 4;
b3 >>= 4;
b4 >>= 4;
d3a |=
(((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) <<
2) | ((b1 & 1) << 3)) << 0;
d3b |=
(((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) <<
1) | ((b1 & 2) << 2)) << 0;
d4a |=
(((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >>
0) | ((b1 & 4) << 1)) << 0;
d4b |=
(((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >>
1) | ((b1 & 8) >> 0)) << 0;
*(dest++) = d4b;
*(dest++) = d4a;
*(dest++) = d3b;
*(dest++) = d3a;
*(dest++) = d2b;
*(dest++) = d2a;
*(dest++) = d1b;
*(dest++) = d1a;
}
}
}
void gfxCopyRawPage(u8 *source, u8 *dest) {
memcpy(dest, source, 320 * 200);
}
void gfxFlipRawPage(u8 *frontBuffer) {
u8 *page = frontBuffer;
int x, y;
u8 *pixels = (u8 *) screenBuffer;
byte c;
for (y = 0; y < 200; y++) {
for (x = 0; x < 320; x++) {
c = *(page++);
if (!colorMode256) {
c = c & 15;
}
pixels[x + 0 + y * 320] = c;
}
}
byte pal[256 * 4];
int i;
if (colorMode256) {
for (i = 0; i < 256; i++) {
pal[i * 4 + 0] = palette256[i * 3 + 0];
pal[i * 4 + 1] = palette256[i * 3 + 1];
pal[i * 4 + 2] = palette256[i * 3 + 2];
pal[i * 4 + 3] = 0;
}
g_system->setPalette(pal, 0, 256);
} else {
for (i = 0; i < 16; i++) {
pal[i * 4 + 2] =
((c_palette[i] & 0x00f) >> 0) * 255 / 7;
pal[i * 4 + 1] =
((c_palette[i] & 0x0f0) >> 4) * 255 / 7;
pal[i * 4 + 0] =
((c_palette[i] & 0xf00) >> 8) * 255 / 7;
pal[i * 4 + 3] = 0;
}
g_system->setPalette(pal, 0, 16);
}
g_system->copyRectToScreen(screenBuffer, 320, 0, 0, 320, 200);
g_system->updateScreen();
g_system->delayMillis(100);
}
void drawSpriteRaw(u8 *spritePtr, u8 *maskPtr, s16 width, s16 height,
u8 *page, s16 x, s16 y) {
s16 i;
s16 j;
for (i = 0; i < height; i++) {
u8 *destPtr = page + x + y * 320;
destPtr += i * 320;
for (j = 0; j < width * 8; j++) {
if (((gameType == Cine::GID_FW && !(*maskPtr))
|| (gameType == Cine::GID_OS)) && (x + j >= 0
&& x + j < 320 && i + y >= 0 && i + y < 200)) {
*(destPtr++) = *(spritePtr++);
} else {
destPtr++;
spritePtr++;
}
maskPtr++;
}
}
}
void drawSpriteRaw2(u8 *spritePtr, u8 transColor, s16 width, s16 height,
u8 *page, s16 x, s16 y) {
s16 i;
s16 j;
for (i = 0; i < height; i++) {
u8 *destPtr = page + x + y * 320;
destPtr += i * 320;
for (j = 0; j < width * 8; j++) {
if ((*(spritePtr) != transColor) && (x + j >= 0
&& x + j < 320 && i + y >= 0 && i + y < 200)) {
*(destPtr++) = *(spritePtr++);
} else {
destPtr++;
spritePtr++;
}
}
}
}

71
engines/cine/gfx.h Normal file
View File

@ -0,0 +1,71 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_GFX_H_
#define CINE_GFX_H_
void gfxDrawSprite(u8 *src4, u16 sw, u16 sh, u8 *dst4, s16 sx, s16 sy);
extern unsigned char *page0;
extern unsigned char *page1;
extern unsigned char *page2;
extern unsigned char *page3;
void init_video();
void convertGfx(u8 *source, u8 *dest, const u16 width, const u16 height);
void convertGfx2(u8 *source, u8 *dest, const u16 width, const u16 height);
void gfxCopyPage(u8 *source, u8 *dest);
void transformPaletteRange(u8 startColor, u8 numColor, s8 r, s8 g, s8 b);
void gfxFlipPage(void);
void gfxSpriteFunc1(u8 *ptr, u16 width, u16 height, u8 *page, s16 x, s16 y);
void gfxFillSprite(u8 *src4, u16 sw, u16 sh, u8 *dst4, s16 sx, s16 sy);
void gfxSpriteFunc2(u8 *spritePtr, s16 width, s16 height, u8 *maskPtr,
s16 maskWidth, s16 maskHeight, u8 *bufferPtr, s16 x, s16 y, u8 maskIdx);
void gfxDrawLine(s16 x1, s16 y1, s16 x2, s16 y2, u8 color, u8 *page);
void gfxDrawPlainBox(s16 x1, s16 y1, s16 x2, s16 y2, u8 color);
void gfxResetPage(u8 *pagePtr);
s16 gfxGetBit(s16 x, s16 y, u8 *ptr, s16 width);
extern u8 page1Raw[320 * 200];
extern u8 page2Raw[320 * 200];
extern u8 page3Raw[320 * 200];
void gfxResetRawPage(u8 *pageRaw);
void gfxConvertSpriteToRaw(u8 *dest, u8 *source, u16 width, u16 height);
void gfxCopyRawPage(u8 *source, u8 * dest);
void gfxFlipRawPage(u8 *frontBuffer);
void drawSpriteRaw(u8 *spritePtr, u8 *maskPtr, s16 width, s16 height,
u8 *page, s16 x, s16 y);
void gfxDrawPlainBoxRaw(s16 x1, s16 y1, s16 x2, s16 y2, u8 color, u8 *page);
void drawSpriteRaw2(u8 *spritePtr, u8 transColor, s16 width, s16 height,
u8 *page, s16 x, s16 y);
#endif

232
engines/cine/main_loop.cpp Normal file
View File

@ -0,0 +1,232 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
mouseStatusStruct mouseData;
u16 mouseRight = 0;
u16 mouseLeft = 0;
u16 mouseUpdateStatus;
u16 dummyU16;
void manageEvents(void) {
OSystem::Event event;
while (g_system->pollEvent(event)) {
switch (event.type) {
case OSystem::EVENT_LBUTTONDOWN:
mouseLeft = 1;
break;
case OSystem::EVENT_RBUTTONDOWN:
mouseRight = 1;
break;
case OSystem::EVENT_MOUSEMOVE:
mouseData.X = event.mouse.x;
mouseData.Y = event.mouse.y;
break;
case OSystem::EVENT_QUIT:
exit(0);
break;
default:
break;
}
}
mouseData.left = mouseLeft;
mouseData.right = mouseRight;
mouseLeft = 0;
mouseRight = 0;
}
void getMouseData(u16 param, u16 *pButton, u16 *pX, u16 *pY) {
*pX = mouseData.X;
*pY = mouseData.Y;
*pButton = 0;
if (mouseData.right) {
(*pButton) |= 2;
}
if (mouseData.left) {
(*pButton) |= 1;
}
}
void mainLoop(int bootScriptIdx) {
u16 var_6;
u16 var_2;
u16 i;
char *di;
u16 mouseButton;
closeEngine3();
resetMessageHead();
resetUnkList();
resetglobalScriptsHead();
resetObjectScriptHead();
mainLoopSub1();
mainLoopSub2(0, 0, 20, 200);
errorVar = 0;
addScriptToList0(bootScriptIdx);
menuVar = 0;
gfxFuncGen1(page0c, page0, page0c, page0, -1);
ptrGfxFunc13();
gfxFuncGen2();
var_2 = 0;
allowPlayerInput = 0;
checkForPendingDataLoadSwitch = 0;
fadeRequired = 0;
isDrawCommandEnabled = 0;
waitForPlayerClick = 0;
var16 = 0;
playerCommand = -1;
strcpy(commandBuffer, "");
globalVars[0x1F2] = 0;
globalVars[0x1F4] = 0;
for (i = 0; i < 16; i++) {
c_palette[i] = 0;
}
var17 = 1;
strcpy(newPrcName, "");
strcpy(newRelName, "");
strcpy(newObjectName, "");
strcpy(newMsgName, "");
strcpy(currentBgName[0], "");
strcpy(currentCtName, "");
strcpy(currentPartName, "");
stopSample();
do {
mainLoopSub3();
di = (char *)executePlayerInput();
if (var18 != 0) {
if (var18 >= 100 || var19) {
stopSample();
}
}
processUnkList();
executeList1();
executeList0();
purgeList1();
purgeList0();
if (playerCommand == -1) {
processPendingUpdates(0);
} else {
processPendingUpdates(2);
}
drawOverlays();
flip();
if (waitForPlayerClick) {
var_6 = 0;
var20 <<= 3;
if (var20 < 0x800)
var20 = 0x800;
do {
manageEvents();
getMouseData(mouseUpdateStatus, &mouseButton,
&dummyU16, &dummyU16);
} while (mouseButton != 0);
menuVar = 0;
do {
manageEvents();
getMouseData(mouseUpdateStatus, &mouseButton,
&dummyU16, &dummyU16);
if (mouseButton == 0) {
if (processKeyboard(menuVar)) {
var_6 = 1;
}
} else {
var_6 = 1;
}
mainLoopSub6();
} while (!var_6);
menuVar = 0;
do {
manageEvents();
getMouseData(mouseUpdateStatus, &mouseButton,
&dummyU16, &dummyU16);
} while (mouseButton != 0);
waitForPlayerClick = 0;
}
if (checkForPendingDataLoadSwitch) {
checkForPendingDataLoad();
checkForPendingDataLoadSwitch = 0;
}
if (di) {
if (!strcmp(di, "quit")) {
var_2 = 1;
}
}
manageEvents();
} while (!exitEngine && !var_2 && var21 != 7);
hideMouse();
stopSample();
closeEngine3();
unloadAllMasks();
freePrcLinkedList();
releaseObjectScripts();
closeEngine7();
closePart();
}

31
engines/cine/main_loop.h Normal file
View File

@ -0,0 +1,31 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_MAINLOOP_H_
#define CINE_MAINLOOP_H_
void mainLoop(int bootScriptIdx);
void manageEvents(void);
#endif

36
engines/cine/module.mk Normal file
View File

@ -0,0 +1,36 @@
MODULE := engines/cine
MODULE_OBJS = \
anim.o \
auto00.o \
bg.o \
bg_list.o \
cine.o \
flip_support.o \
font.o \
gfx.o \
main_loop.o \
msg.o \
object.o \
pal.o \
part.o \
prc.o \
rel.o \
resource.o \
script.o \
sfx_player.o \
sound_driver.o \
texte.o \
unpack.o \
various.o
MODULE_DIRS += \
cine
# This module can be built as a plugin
ifdef BUILD_PLUGINS
PLUGIN := 1
endif
# Include common rules
include $(srcdir)/common.rules

76
engines/cine/msg.cpp Normal file
View File

@ -0,0 +1,76 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
u16 msgVar0;
void loadMsg(char *pMsgName) {
u16 i;
u8 *ptr;
checkDataDisk(-1);
msgVar0 = 0;
for (i = 0; i < NUM_MAX_MESSAGE; i++) {
messageTable[i].len = 0;
if (messageTable[i].ptr) {
ASSERT_PTR(messageTable[i].ptr);
free(messageTable[i].ptr);
}
messageTable[i].ptr = NULL;
}
ptr = readBundleFile(findFileInBundle(pMsgName));
processPendingUpdates(1);
msgVar0 = *(u16 *) ptr;
ptr += 2;
flipU16(&msgVar0);
ASSERT(msgVar0 <= NUM_MAX_MESSAGE);
for (i = 0; i < msgVar0; i++) {
messageTable[i].len = *(u16 *) ptr;
ptr += 2;
flipU16(&messageTable[i].len);
}
for (i = 0; i < msgVar0; i++) {
if (messageTable[i].len) {
messageTable[i].ptr =
(u8 *) malloc(messageTable[i].len);
ASSERT_PTR(messageTable[i].ptr);
memcpy(messageTable[i].ptr, ptr, messageTable[i].len);
ptr += messageTable[i].len;
}
}
}

30
engines/cine/msg.h Normal file
View File

@ -0,0 +1,30 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_MSG_H_
#define CINE_MSG_H_
void loadMsg(char *pMsgName);
#endif

490
engines/cine/object.cpp Normal file
View File

@ -0,0 +1,490 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
objectStruct objectTable[NUM_MAX_OBJECT];
u16 globalVars[NUM_MAX_OBJECTDATA];
overlayHeadElement overlayHead;
void unloadAllMasks(void) {
overlayHeadElement *current = overlayHead.next;
while (current) {
overlayHeadElement *next = current->next;
free(current);
current = next;
}
resetMessageHead();
}
void resetMessageHead(void) {
overlayHead.next = NULL;
overlayHead.previous = NULL;
}
void loadObject(char *pObjectName) {
u16 numEntry;
u16 entrySize;
u16 i;
u8 *ptr;
checkDataDisk(-1);
ptr = readBundleFile(findFileInBundle(pObjectName));
processPendingUpdates(1);
numEntry = *(u16 *) ptr;
ptr += 2;
flipU16(&numEntry);
entrySize = *(u16 *) ptr;
ptr += 2;
flipU16(&entrySize);
ASSERT(numEntry <= NUM_MAX_OBJECT);
ASSERT(entrySize == sizeof(objectStruct)); // carefull, it's directly read to memory
for (i = 0; i < numEntry; i++) {
if (objectTable[i].costume != -2) // flag is keep ?
{
memcpy(&objectTable[i], ptr, entrySize);
flipU16((u16 *) & objectTable[i].x);
flipU16((u16 *) & objectTable[i].y);
flipU16(&objectTable[i].mask);
flipU16((u16 *) & objectTable[i].frame);
flipU16((u16 *) & objectTable[i].costume);
flipU16(&objectTable[i].part);
}
ptr += entrySize;
}
if (!strcmp(pObjectName, "INTRO.OBJ")) {
for (i = 0; i < 10; i++) {
objectTable[i].costume = 0;
}
}
}
s8 removeOverlayElement(u16 objIdx, u16 param) {
overlayHeadElement *currentHeadPtr = &overlayHead;
overlayHeadElement *tempHead = currentHeadPtr;
overlayHeadElement *tempPtr2;
currentHeadPtr = tempHead->next;
while (currentHeadPtr && (objIdx == currentHeadPtr->objIdx
|| param == currentHeadPtr->type)) {
tempHead = currentHeadPtr;
currentHeadPtr = tempHead->next;
}
if (!currentHeadPtr) {
return -1;
}
if (objIdx != currentHeadPtr->objIdx || param != currentHeadPtr->type) {
return -1;
}
tempHead->next = currentHeadPtr->next;
tempPtr2 = currentHeadPtr->next;
if (!tempPtr2) {
tempPtr2 = &overlayHead;
}
tempPtr2->previous = currentHeadPtr->previous;
free(currentHeadPtr);
return (0);
}
s16 freeOverlay(u16 objIdx, u16 param) {
overlayHeadElement *currentHeadPtr = overlayHead.next;
overlayHeadElement *tempHead = &overlayHead;
overlayHeadElement *tempPtr2;
while (currentHeadPtr && ((currentHeadPtr->objIdx != objIdx)
|| (currentHeadPtr->type != param))) {
tempHead = currentHeadPtr;
currentHeadPtr = tempHead->next;
}
if (!currentHeadPtr) {
return -1;
}
if (!((currentHeadPtr->objIdx == objIdx)
&& (currentHeadPtr->type == param))) {
return -1;
}
tempHead->next = currentHeadPtr->next;
tempPtr2 = currentHeadPtr->next;
if (!tempPtr2) {
tempPtr2 = &overlayHead;
}
tempPtr2->previous = currentHeadPtr->previous;
//TODO: fix !
//free(currentHeadPtr);
return 0;
}
void loadOverlayElement(u16 objIdx, u16 param) {
overlayHeadElement *currentHeadPtr = &overlayHead;
overlayHeadElement *pNewElement;
u16 si = objectTable[objIdx].mask;
overlayHeadElement *tempHead = currentHeadPtr;
currentHeadPtr = tempHead->next;
while (currentHeadPtr
&& (objectTable[currentHeadPtr->objIdx].mask < si)) {
tempHead = currentHeadPtr;
currentHeadPtr = tempHead->next;
}
pNewElement =
(overlayHeadElement *) malloc(sizeof(overlayHeadElement));
ASSERT_PTR(pNewElement);
pNewElement->next = tempHead->next;
tempHead->next = pNewElement;
pNewElement->objIdx = objIdx;
pNewElement->type = param;
if (!currentHeadPtr) {
currentHeadPtr = &overlayHead;
}
pNewElement->previous = currentHeadPtr->previous;
currentHeadPtr->previous = pNewElement;
}
void setupObject(u8 objIdx, u16 param1, u16 param2, u16 param3, u16 param4) {
objectTable[objIdx].x = param1;
objectTable[objIdx].y = param2;
objectTable[objIdx].mask = param3;
objectTable[objIdx].frame = param4;
if (!removeOverlayElement(objIdx, 0)) {
loadOverlayElement(objIdx, 0);
}
}
void subObjectParam(u8 objIdx, u8 paramIdx, s16 newValue) {
ASSERT(objIdx <= NUM_MAX_OBJECT);
paramIdx--;
ASSERT(paramIdx >= 0 && paramIdx <= 5);
switch (paramIdx) {
case 0:
{
objectTable[objIdx].x -= newValue;
break;
}
case 1:
{
objectTable[objIdx].y -= newValue;
break;
}
case 2:
{
objectTable[objIdx].mask -= newValue;
if (!removeOverlayElement(objIdx, 0)) {
loadOverlayElement(objIdx, 0);
}
break;
}
case 3:
{
objectTable[objIdx].frame -= newValue;
break;
}
case 4:
{
objectTable[objIdx].costume -= newValue;
break;
}
case 5:
{
objectTable[objIdx].part -= newValue;
break;
}
}
}
void addObjectParam(u8 objIdx, u8 paramIdx, s16 newValue) {
ASSERT(objIdx <= NUM_MAX_OBJECT);
paramIdx--;
ASSERT(paramIdx >= 0 && paramIdx <= 5);
switch (paramIdx) {
case 0:
{
objectTable[objIdx].x += newValue;
break;
}
case 1:
{
objectTable[objIdx].y += newValue;
break;
}
case 2:
{
objectTable[objIdx].mask += newValue;
if (!removeOverlayElement(objIdx, 0)) {
loadOverlayElement(objIdx, 0);
}
break;
}
case 3:
{
objectTable[objIdx].frame += newValue;
break;
}
case 4:
{
objectTable[objIdx].costume += newValue;
break;
}
case 5:
{
objectTable[objIdx].part += newValue;
break;
}
}
}
void modifyObjectParam(u8 objIdx, u8 paramIdx, s16 newValue) {
ASSERT(objIdx <= NUM_MAX_OBJECT);
paramIdx--;
ASSERT(paramIdx >= 0 && paramIdx <= 5);
switch (paramIdx) {
case 0:
{
objectTable[objIdx].x = newValue;
break;
}
case 1:
{
objectTable[objIdx].y = newValue;
break;
}
case 2:
{
objectTable[objIdx].mask = newValue;
if (!removeOverlayElement(objIdx, 0)) {
loadOverlayElement(objIdx, 0);
}
break;
}
case 3:
{
objectTable[objIdx].frame = newValue;
break;
}
case 4:
{
if (newValue == -1) {
objectTable[objIdx].costume = globalVars[0];
} else {
objectTable[objIdx].costume = newValue;
}
break;
}
case 5:
{
objectTable[objIdx].part = newValue;
break;
}
}
}
u8 compareObjectParam(u8 objIdx, u8 param1, s16 param2) {
u8 compareResult = 0;
switch (param1 - 1) {
case 0:
{
if (objectTable[objIdx].x == param2) {
compareResult |= 1;
}
if (objectTable[objIdx].x > param2) {
compareResult |= 2;
}
if (objectTable[objIdx].x < param2) {
compareResult |= 4;
}
break;
}
case 1:
{
if (objectTable[objIdx].y == param2) {
compareResult |= 1;
}
if (objectTable[objIdx].y > param2) {
compareResult |= 2;
}
if (objectTable[objIdx].y < param2) {
compareResult |= 4;
}
break;
}
case 2:
{
if (objectTable[objIdx].mask == param2) {
compareResult |= 1;
}
if (objectTable[objIdx].mask > param2) {
compareResult |= 2;
}
if (objectTable[objIdx].mask < param2) {
compareResult |= 4;
}
break;
}
case 3:
{
if (objectTable[objIdx].frame == param2) {
compareResult |= 1;
}
if (objectTable[objIdx].frame > param2) {
compareResult |= 2;
}
if (objectTable[objIdx].frame < param2) {
compareResult |= 4;
}
break;
}
case 4:
{
if (objectTable[objIdx].costume == param2) {
compareResult |= 1;
}
if (objectTable[objIdx].costume > param2) {
compareResult |= 2;
}
if (objectTable[objIdx].costume < param2) {
compareResult |= 4;
}
break;
}
default:
{
printf
("Unsupported compare type: %d in compareObjectParam\n",
param1 - 1);
exit(1);
}
}
return (compareResult);
}
s16 getObjectParam(u16 objIdx, u16 paramIdx) {
ASSERT(objIdx <= NUM_MAX_OBJECT);
paramIdx--;
ASSERT(paramIdx >= 0 && paramIdx <= 5);
switch (paramIdx) {
case 0:
{
return objectTable[objIdx].x;
break;
}
case 1:
{
return objectTable[objIdx].y;
break;
}
case 2:
{
return objectTable[objIdx].mask;
break;
}
case 3:
{
return objectTable[objIdx].frame;
break;
}
case 4:
{
return objectTable[objIdx].costume;
break;
}
case 5:
{
return objectTable[objIdx].part;
break;
}
}
return 0;
}

76
engines/cine/object.h Normal file
View File

@ -0,0 +1,76 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_OBJECT_H_
#define CINE_OBJECT_H_
typedef struct {
s16 x;
s16 y;
u16 mask;
s16 frame;
s16 costume;
char name[20];
u16 part;
} objectStruct;
struct overlayHeadElement {
struct overlayHeadElement *next;
struct overlayHeadElement *previous;
u16 objIdx;
u16 type;
s16 x;
s16 y;
s16 var10;
s16 var12;
};
typedef struct overlayHeadElement overlayHeadElement;
#define NUM_MAX_OBJECT 255
#define NUM_MAX_OBJECTDATA 255
extern objectStruct objectTable[NUM_MAX_OBJECT];
extern u16 globalVars[NUM_MAX_OBJECTDATA];
extern overlayHeadElement overlayHead;
void unloadAllMasks(void);
void resetMessageHead(void);
void loadObject(char *pObjectName);
void setupObject(u8 objIdx, u16 param1, u16 param2, u16 param3, u16 param4);
void modifyObjectParam(u8 objIdx, u8 paramIdx, s16 newValue);
void loadOverlayElement(u16 objIdx, u16 param);
s8 removeOverlayElement(u16 objIdx, u16 param);
s16 getObjectParam(u16 objIdx, u16 paramIdx);
s16 freeOverlay(u16 objIdx, u16 param);
void addObjectParam(u8 objIdx, u8 paramIdx, s16 newValue);
void subObjectParam(u8 objIdx, u8 paramIdx, s16 newValue);
u8 compareObjectParam(u8 objIdx, u8 param1, s16 param2);
#endif

123
engines/cine/pal.cpp Normal file
View File

@ -0,0 +1,123 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
u16 tempPalette[256];
u8 colorMode256 = 0;
u8 palette256[256 * 3];
u16 palVar;
u16 palVar0;
Common::File palFileHandle;
palEntryStruct *palPtr;
u8 paletteBuffer1[16];
u8 paletteBuffer2[16];
void loadPal(const char *fileName) {
char buffer[20];
removeExtention(buffer, fileName);
strcat(buffer, ".PAL");
palFileHandle.close();
if (palPtr) {
free(palPtr);
palPtr = NULL;
}
palVar = 0;
palVar0 = 42;
palFileHandle.open(buffer);
ASSERT(palFileHandle.isOpen());
palFileHandle.read(&palVar, 2); // endian: not fliped !
palFileHandle.read(&palVar0, 2);
palPtr = (palEntryStruct *) malloc(palVar * palVar0);
ASSERT_PTR(palPtr);
palFileHandle.read(palPtr, palVar * palVar0);
}
s16 findPaletteFromName(const char *fileName) {
char buffer[10];
u16 position = 0;
u16 i;
strcpy(buffer, fileName);
while (position < strlen(fileName)) {
if (buffer[position] > 'a' && buffer[position] < 'z') {
buffer[position] += 0xE0;
}
position++;
}
for (i = 0; i < palVar; i++) {
if (!strcmp(buffer, palPtr[i].name)) {
return i;
}
}
return -1;
}
void loadRelatedPalette(const char *fileName) {
char localName[16];
u8 i;
s16 paletteIndex;
removeExtention(localName, fileName);
paletteIndex = findPaletteFromName(localName);
if (paletteIndex == -1) {
for (i = 0; i < 16; i++) // generate default palette
{
paletteBuffer1[i] = paletteBuffer2[i] = (i << 4) + i;
}
} else {
palEntryStruct *palEntryPtr = &palPtr[paletteIndex];
ASSERT_PTR(paletteBuffer2);
for (i = 0; i < 16; i++) // convert palette
{
paletteBuffer1[i] = palEntryPtr->pal1[i];
paletteBuffer2[i] = palEntryPtr->pal2[i];
}
}
}

44
engines/cine/pal.h Normal file
View File

@ -0,0 +1,44 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_PAL_H_
#define CINE_PAL_H_
struct palEntryStruct {
char name[10];
u8 pal1[16];
u8 pal2[16];
};
typedef struct palEntryStruct palEntryStruct;
void loadPal(const char *fileName);
extern u16 tempPalette[256];
extern u8 colorMode256;
extern u8 palette256[256 * 3];
void loadRelatedPalette(const char *fileName);
#endif

226
engines/cine/part.cpp Normal file
View File

@ -0,0 +1,226 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
u16 numElementInPart;
u16 partVar1;
animDataStruct animDataTable[NUM_MAX_PARTDATA];
partBufferStruct *partBuffer;
void loadPart(const char *partName) {
u16 i;
ASSERT(sizeof(partBufferStruct) == 0x1E);
for (i = 0; i < 255; i++) {
partBuffer[i].part_name[0] = 0;
partBuffer[i].offset = 0;
partBuffer[i].packed_size = 0;
partBuffer[i].unpacked_size = 0;
partBuffer[i].var1A = 0;
}
numElementInPart = 0;
partVar1 = 30;
partFileHandle.close();
checkDataDisk(-1);
partFileHandle.open(partName);
ASSERT(partFileHandle.isOpen());
processPendingUpdates(-1);
partFileHandle.read(&numElementInPart, 2);
partFileHandle.read(&partVar1, 2);
flipU16(&numElementInPart);
flipU16(&partVar1);
partFileHandle.read(partBuffer, numElementInPart * partVar1);
strcpy(currentPartName, partName);
for (i = 0; i < numElementInPart; i++) {
flipU32(&partBuffer[i].offset);
flipU32(&partBuffer[i].packed_size);
flipU32(&partBuffer[i].unpacked_size);
}
if (gameType == Cine::GID_FW)
loadPal(partName);
}
void freePartEntry(u8 idx) {
if (animDataTable[idx].ptr1) {
//free(animDataTable[idx].ptr1);
animDataTable[idx].ptr1 = NULL;
animDataTable[idx].ptr2 = NULL;
// TODO: finish
if (frameVar0 > 0)
frameVar0--;
}
}
void freePartRange(u8 startIdx, u8 numIdx) {
u8 i;
for (i = 0; i < numIdx; i++) {
freePartEntry(i + startIdx);
}
}
void closePart(void) {
}
const char *bundleNames[] = {
"EGOUBASE",
"LABYBASE",
"PROCEGOU",
"PROCLABY",
"PROCS00",
"PROCS01",
"PROCS02",
"PROCS03",
"PROCS04",
"PROCS06",
"PROCS07",
"PROCS08",
"PROCS10",
"PROCS12",
"PROCS13",
"PROCS15",
"PROCS16",
"RSC00",
"RSC01",
"RSC02",
"RSC03",
"RSC04",
"RSC05",
"RSC06",
"RSC07",
"RSC08",
"RSC09",
"RSC10",
"RSC11",
"RSC12",
"RSC13",
"RSC14",
"RSC15",
"RSC16",
"RSC17",
// english version
"SONS1",
"SONS2",
"SONS3",
"SONS4",
"SONS5",
"SONS6",
"SONS7",
"SONS8",
"SONS9",
/*
"SONS31", // french version
"SONS32",
"SONS33",
"SONS34"
*/
};
s16 findFileInBundle(const char *fileName) {
u16 i;
if (gameType == Cine::GID_OS) {
u16 j;
for (i = 0; i < numElementInPart; i++) {
if (!strcmp(fileName, partBuffer[i].part_name)) {
return i;
}
}
for (j = 0; j < 39; j++) {
loadPart(bundleNames[j]);
for (i = 0; i < numElementInPart; i++) {
if (!strcmp(fileName, partBuffer[i].part_name)) {
return i;
}
}
}
} else {
for (i = 0; i < numElementInPart; i++) {
if (!strcmp(fileName, partBuffer[i].part_name)) {
return i;
}
}
}
return -1;
}
void readFromPart(s16 idx, u8 *dataPtr) {
processPendingUpdates(1);
partFileHandle.seek(partBuffer[idx].offset, SEEK_SET);
partFileHandle.read(dataPtr, partBuffer[idx].packed_size);
}
u8 *readBundleFile(s16 foundFileIdx) {
u8 *dataPtr;
dataPtr = (u8 *) malloc(partBuffer[foundFileIdx].unpacked_size + 2);
memset(dataPtr, 0, partBuffer[foundFileIdx].unpacked_size + 2);
if (partBuffer[foundFileIdx].unpacked_size !=
partBuffer[foundFileIdx].packed_size) {
u8 *unpackBuffer;
u16 realSize;
unpackBuffer =
(u8 *) malloc(partBuffer[foundFileIdx].packed_size + 500);
readFromPart(foundFileIdx, unpackBuffer);
realSize =
*(u16 *) (unpackBuffer +
partBuffer[foundFileIdx].packed_size - 2);
flipU16(&realSize);
decomp(unpackBuffer + partBuffer[foundFileIdx].packed_size - 4,
dataPtr + realSize, realSize);
free(unpackBuffer);
} else {
readFromPart(foundFileIdx, dataPtr);
}
return dataPtr;
}

66
engines/cine/part.h Normal file
View File

@ -0,0 +1,66 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_PART_H_
#define CINE_PART_H_
typedef struct {
char part_name[10];
u32 varA; /* unused */
u32 offset;
u32 packed_size;
u32 unpacked_size;
u32 var1A; /* unused */
} partBufferStruct;
typedef struct {
u16 width;
u16 var1;
u16 field_4;
u16 var2;
u8 *ptr1;
u8 *ptr2;
s16 fileIdx;
s16 frameIdx;
char name[10];
} animDataStruct;
#define NUM_MAX_PARTDATA 255
#define NUM_MAX_ANIMDATA 255
extern animDataStruct animDataTable[NUM_MAX_ANIMDATA];
extern partBufferStruct *partBuffer;
void loadPart(const char *partName);
void freePartRange(u8 startIdx, u8 numIdx);
void closePart(void);
s16 findFileInBundle(const char *fileName);
void readFromPart(s16 idx, u8 *dataPtr);
u8 *readBundleFile(s16 foundFileIdx);
#endif

144
engines/cine/prc.cpp Normal file
View File

@ -0,0 +1,144 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
prcLinkedListStruct globalScriptsHead;
prcLinkedListStruct objScriptList;
//char currentPrcName[20];
void resetglobalScriptsHead(void) {
globalScriptsHead.next = NULL;
globalScriptsHead.scriptIdx = -1;
}
void freePrcLinkedList(void) {
prcLinkedListStruct *currentHead = globalScriptsHead.next;
while (currentHead) {
prcLinkedListStruct *temp;
ASSERT_PTR(currentHead);
temp = currentHead->next;
free(currentHead);
currentHead = temp;
}
resetglobalScriptsHead();
}
void loadPrc(char *pPrcName) {
u8 i;
u16 numEntry;
ASSERT_PTR(pPrcName);
for (i = 0; i < NUM_MAX_SCRIPT; i++) {
if (scriptTable[i].ptr) {
ASSERT_PTR(scriptTable[i].ptr);
free(scriptTable[i].ptr);
scriptTable[i].ptr = NULL;
scriptTable[i].var4 = 0;
}
}
checkDataDisk(-1);
if ((gameType == Cine::GID_FW) && (!strcmp(pPrcName, "AUTO00.PRC"))) {
unsigned char *readPtr = AUT000;
processPendingUpdates(1);
numEntry = *(unsigned short int *)readPtr;
readPtr += 2;
flipU16(&numEntry);
ASSERT(numEntry <= NUM_MAX_SCRIPT);
for (i = 0; i < numEntry; i++) {
scriptTable[i].var4 = *(unsigned short int *)readPtr;
readPtr += 2;
flipU16(&scriptTable[i].var4);
}
for (i = 0; i < numEntry; i++) {
u16 size;
size = scriptTable[i].var4;
if (size) {
scriptTable[i].ptr = (byte *) malloc(size);
ASSERT_PTR(scriptTable[i].ptr);
memcpy(scriptTable[i].ptr, readPtr, size);
readPtr += size;
computeScriptStack(scriptTable[i].ptr,
scriptTable[i].stack, size);
}
}
} else {
u8 *ptr = readBundleFile(findFileInBundle(pPrcName));
ASSERT_PTR(ptr);
processPendingUpdates(1);
numEntry = *(u16 *) ptr;
ptr += 2;
flipU16(&numEntry);
ASSERT(numEntry <= NUM_MAX_SCRIPT);
for (i = 0; i < numEntry; i++) {
scriptTable[i].var4 = *(u16 *) ptr;
ptr += 2;
flipU16(&scriptTable[i].var4);
}
for (i = 0; i < numEntry; i++) {
u16 size;
size = scriptTable[i].var4;
if (size) {
scriptTable[i].ptr = (byte *) malloc(size);
ASSERT_PTR(scriptTable[i].ptr);
memcpy(scriptTable[i].ptr, ptr, size);
ptr += size;
computeScriptStack(scriptTable[i].ptr,
scriptTable[i].stack, size);
}
}
}
}

47
engines/cine/prc.h Normal file
View File

@ -0,0 +1,47 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_PRC_H_
#define CINE_PRC_H_
struct prcLinkedListStruct {
struct prcLinkedListStruct *next;
s16 stack[SCRIPT_STACK_SIZE];
s16 localVars[50];
u16 compareResult;
u16 scriptPosition;
byte *scriptPtr;
s16 scriptIdx;
};
typedef struct prcLinkedListStruct prcLinkedListStruct;
extern prcLinkedListStruct globalScriptsHead;
extern prcLinkedListStruct objScriptList;
void resetglobalScriptsHead(void);
void freePrcLinkedList(void);
void loadPrc(char *pPrcName);
#endif

127
engines/cine/rel.cpp Normal file
View File

@ -0,0 +1,127 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
relStruct relTable[NUM_MAX_REL];
void resetObjectScriptHead(void) {
objScriptList.next = NULL;
objScriptList.scriptIdx = -1;
}
void releaseObjectScripts(void) {
prcLinkedListStruct *currentHead = objScriptList.next;
while (currentHead) {
prcLinkedListStruct *temp;
ASSERT_PTR(currentHead);
temp = currentHead->next;
free(currentHead);
currentHead = temp;
}
resetObjectScriptHead();
}
void loadRel(char *pRelName) {
u16 numEntry;
u16 i;
u8 *ptr;
checkDataDisk(-1);
for (i = 0; i < NUM_MAX_REL; i++) {
if (relTable[i].ptr0) {
ASSERT_PTR(relTable[i].ptr0);
free(relTable[i].ptr0);
relTable[i].ptr0 = NULL;
relTable[i].var4 = 0;
}
}
ptr = readBundleFile(findFileInBundle(pRelName));
processPendingUpdates(1);
numEntry = *(u16 *) ptr;
ptr += 2;
flipU16(&numEntry);
ASSERT(numEntry <= NUM_MAX_REL);
for (i = 0; i < numEntry; i++) {
relTable[i].var4 = *(u16 *) ptr;
ptr += 2;
flipU16(&relTable[i].var4);
relTable[i].var6 = *(u16 *) ptr;
ptr += 2;
flipU16(&relTable[i].var6);
relTable[i].var8 = *(u16 *) ptr;
ptr += 2;
flipU16(&relTable[i].var8);
relTable[i].varA = *(u16 *) ptr;
ptr += 2;
flipU16(&relTable[i].varA);
}
for (i = 0; i < numEntry; i++) {
if (relTable[i].var4) {
relTable[i].ptr0 = (char *)malloc(relTable[i].var4);
ASSERT_PTR(relTable[i].ptr0);
memcpy(relTable[i].ptr0, ptr, relTable[i].var4);
ptr += relTable[i].var4;
}
}
#ifdef DUMP_SCRIPTS_OBJ
{
u16 i;
u8 buffer[256];
for (i = 0; i < numEntry; i++) {
if (relTable[i].var4) {
sprintf(buffer, "%s_%03d.txt", pRelName, i);
decompileScript(relTable[i].ptr0, NULL,
relTable[i].var4, i);
dumpScript(buffer);
}
}
}
#endif
}

45
engines/cine/rel.h Normal file
View File

@ -0,0 +1,45 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_REL_H_
#define CINE_REL_H_
typedef struct relData {
char *ptr0;
u16 var4;
u16 var6;
u16 var8;
u16 varA;
} relStruct;
#define NUM_MAX_REL 255
extern relStruct relTable[NUM_MAX_REL];
void releaseObjectScripts(void);
void resetObjectScriptHead(void);
void loadRel(char *pRelName);
#endif

28
engines/cine/resource.cpp Normal file
View File

@ -0,0 +1,28 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
void checkDataDisk(s16 param) {
}

30
engines/cine/resource.h Normal file
View File

@ -0,0 +1,30 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_RESOURCE_H_
#define CINE_RESOURCE_H_
void checkDataDisk(s16 param);
#endif

4421
engines/cine/script.cpp Normal file

File diff suppressed because it is too large Load Diff

64
engines/cine/script.h Normal file
View File

@ -0,0 +1,64 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_SCRIPT_H_
#define CINE_SCRIPT_H_
#define SCRIPT_STACK_SIZE 50
typedef struct {
byte *ptr;
u16 var4;
s16 stack[SCRIPT_STACK_SIZE];
} scriptStruct;
#define NUM_MAX_SCRIPT 50
extern scriptStruct scriptTable[NUM_MAX_SCRIPT];
void computeScriptStack(byte *scriptPtr, s16 *stackPtr, u16 scriptSize);
void decompileScript(byte *scriptPtr, s16 *stackPtr, u16 scriptSize,
u16 scriptIdx);
void dumpScript(char *dumpName);
#define OP_loadPart 0x3F
#define OP_loadNewPrcName 0x41
#define OP_requestCheckPendingDataLoad 0x42
#define OP_endScript 0x50
#define OP_changeDataDisk 0x6B
#define OP_79 0x79
void addScriptToList0(u16 idx);
s16 checkCollision(s16 objIdx, s16 x, s16 y, s16 numZones, s16 zoneIdx);
void runObjectScript(s16 entryIdx);
s16 stopObjectScript(s16 entryIdx);
void executeList1(void);
void executeList0(void);
void purgeList1(void);
void purgeList0(void);
#endif

287
engines/cine/sfx_player.cpp Normal file
View File

@ -0,0 +1,287 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/stdafx.h"
#include "common/system.h"
#include "common/file.h"
#include "cine/cine.h"
u16 snd_eventsDelay;
int snd_songIsPlaying = 0;
u8 snd_nullInstrument[] = { 0, 0 };
sfxStateStruct snd_sfxState;
static u8 snd_mute = 0;
static char snd_songFileName[30];
/* LVDT specific */
static Common::File *snd_baseSndFile = NULL;
static u16 snd_numBasesonEntries = 0;
static BasesonEntryStruct *snd_basesonEntries = NULL;
int snd_loadBasesonEntries(const char *fileName) {
int i;
snd_baseSndFile = new Common::File();
snd_baseSndFile->open(fileName);
if (!snd_baseSndFile->isOpen())
return -1;
snd_numBasesonEntries = snd_baseSndFile->readUint16BE();
snd_baseSndFile->readUint16BE(); /* entry_size */
snd_basesonEntries =
(BasesonEntryStruct *) malloc(snd_numBasesonEntries *
sizeof(BasesonEntryStruct));
if (snd_basesonEntries) {
for (i = 0; i < snd_numBasesonEntries; ++i) {
BasesonEntryStruct *be = &snd_basesonEntries[i];
snd_baseSndFile->read(be->name, 14);
be->offset = snd_baseSndFile->readUint32BE();
be->size = snd_baseSndFile->readUint32BE();
be->unpackedSize = snd_baseSndFile->readUint32BE();
snd_baseSndFile->readUint32BE(); /* unused */
}
}
return 0;
}
void snd_clearBasesonEntries() {
snd_baseSndFile->close();
delete snd_baseSndFile;
free(snd_basesonEntries);
snd_basesonEntries = NULL;
snd_numBasesonEntries = 0;
}
static int snd_findBasesonEntry(const char *entryName) {
int i;
char *p;
char basesonEntryName[20];
assert(strlen(entryName) < 20);
strcpy(basesonEntryName, entryName);
for (p = basesonEntryName; *p; ++p) {
if (*p >= 'a' && *p <= 'z')
*p += 'A' - 'a';
}
for (i = 0; i < snd_numBasesonEntries; ++i) {
if (strcmp(snd_basesonEntries[i].name, basesonEntryName) == 0)
return i;
}
return -1;
}
static u8 *snd_loadBasesonEntry(const char *entryName) {
int entryNum;
u8 *entryData = NULL;
if (gameType == Cine::GID_OS) {
entryNum = findFileInBundle((const char *)entryName);
if (entryNum != -1)
entryData = readBundleFile(entryNum);
} else {
entryNum = snd_findBasesonEntry(entryName);
if (entryNum != -1 && entryNum < snd_numBasesonEntries) {
const BasesonEntryStruct *be =
&snd_basesonEntries[entryNum];
entryData = (u8 *) malloc(be->unpackedSize);
if (entryData) {
if (be->unpackedSize > be->size) {
u8 *tempData = (u8 *) malloc(be->size);
if (tempData) {
snd_baseSndFile->seek(be->
offset, SEEK_SET);
snd_baseSndFile->read(tempData,
be->size);
decomp(tempData + be->size - 4,
entryData +
be->unpackedSize,
be->unpackedSize);
free(tempData);
}
} else {
snd_baseSndFile->seek(be->offset,
SEEK_SET);
snd_baseSndFile->read(entryData,
be->size);
}
}
}
}
return entryData;
}
void snd_stopSong() {
int i;
snd_songFileName[0] = '\0';
snd_songIsPlaying = 0;
snd_fadeOutCounter = 0;
for (i = 0; i < 4; ++i)
(*snd_driver.stopChannel) (i);
snd_adlibDriverStopSong();
snd_freeSong();
}
void snd_freeSong() {
int i;
for (i = 0; i < 15; ++i) {
if (snd_sfxState.instruments[i] != snd_nullInstrument)
free(snd_sfxState.instruments[i]);
}
free(snd_sfxState.songData);
memset(&snd_sfxState, 0, sizeof(snd_sfxState));
}
int snd_loadSong(const char *songName) {
int i;
while (snd_fadeOutCounter != 0 && snd_fadeOutCounter < 100)
g_system->delayMillis(40);
snd_fadeOutCounter = 0;
if (snd_songIsPlaying)
snd_stopSong();
if ((gameType == Cine::GID_OS) && (strncmp(songName, "INTRO", 5) == 0))
return 0;
strcpy(snd_songFileName, songName);
if (gameType == Cine::GID_OS)
strcat(snd_songFileName, ".IST");
snd_sfxState.songData = snd_loadBasesonEntry(songName);
if (!snd_sfxState.songData)
return 0;
for (i = 0; i < 15; ++i) {
char instrumentName[13];
memcpy(instrumentName, snd_sfxState.songData + 20 + i * 30,
12);
instrumentName[12] = '\0';
snd_sfxState.instruments[i] = snd_nullInstrument;
if (strlen(instrumentName) != 0) {
char *dot = strrchr(instrumentName, '.');
if (dot)
*dot = '\0';
if (gameType == Cine::GID_OS)
strcat(instrumentName, ".ADL");
else
strcat(instrumentName, ".INS");
snd_sfxState.instruments[i] =
snd_loadBasesonEntry(instrumentName);
}
}
return 1;
}
void snd_fadeOutSong() {
if (snd_songIsPlaying) {
snd_songFileName[0] = '\0';
snd_songIsPlaying = 0;
snd_fadeOutCounter = 1;
}
}
void snd_playSong() {
if (strlen(snd_songFileName) != 0) {
snd_sfxState.currentInstrumentChannel[0] = -1;
snd_sfxState.currentInstrumentChannel[1] = -1;
snd_sfxState.currentInstrumentChannel[2] = -1;
snd_sfxState.currentInstrumentChannel[3] = -1;
snd_sfxState.currentOrder = 0;
snd_sfxState.currentPos = 0;
snd_sfxState.numOrders = snd_sfxState.songData[470];
snd_eventsDelay =
(252 - snd_sfxState.songData[471]) * 25 * 2 / 1060;
snd_songTicksCounter = 0;
snd_songIsPlaying = 1;
}
}
void snd_handleEvents() {
int i;
const u8 *patternData = snd_sfxState.songData + 600;
const u8 *orderTable = snd_sfxState.songData + 472;
u16 patternNum = orderTable[snd_sfxState.currentOrder] * 1024;
for (i = 0; i < 4; ++i) {
snd_handlePattern(i,
patternData + patternNum + snd_sfxState.currentPos);
patternData += 4;
}
if (snd_fadeOutCounter != 0 && snd_fadeOutCounter < 100)
snd_fadeOutCounter += 4;
snd_sfxState.currentPos += 16;
if (snd_sfxState.currentPos >= 1024) {
snd_sfxState.currentPos = 0;
++snd_sfxState.currentOrder;
if (snd_sfxState.currentOrder == snd_sfxState.numOrders)
snd_sfxState.currentOrder = 0;
}
}
void snd_handlePattern(int channelNum, const u8 *patternData) {
u16 instrNum = patternData[2] >> 4;
snd_adlibInstrumentsTable[channelNum] = snd_nullInstrument;
if (instrNum != 0) {
if (snd_sfxState.currentInstrumentChannel[channelNum] !=
instrNum) {
snd_sfxState.currentInstrumentChannel[channelNum] =
instrNum;
(*snd_driver.setupChannel) (channelNum,
snd_sfxState.instruments[instrNum - 1],
instrNum - 1);
} else if (snd_fadeOutCounter != 0) {
instrNum =
snd_sfxState.currentInstrumentChannel[channelNum];
if (instrNum != 0)
(*snd_driver.setupChannel) (channelNum,
snd_sfxState.instruments[instrNum - 1],
instrNum - 1);
}
snd_adlibInstrumentsTable[channelNum] =
snd_sfxState.instruments[instrNum - 1];
}
if (snd_mute != 0)
(*snd_driver.stopChannel) (channelNum);
else {
s16 freq = (s16) readU16BE(patternData);
if (freq > 0) {
(*snd_driver.stopChannel) (channelNum);
(*snd_driver.setChannelFrequency) (channelNum, freq);
}
}
}

59
engines/cine/sfx_player.h Normal file
View File

@ -0,0 +1,59 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_SFXPLAYER_H_
#define CINE_SFXPLAYER_H_
typedef struct {
char name[14];
u32 offset;
u32 size;
u32 unpackedSize;
} BasesonEntryStruct;
typedef struct {
u8 *songData;
int currentInstrumentChannel[4];
u8 *instruments[15];
int currentOrder;
int currentPos;
int numOrders;
} sfxStateStruct;
extern u16 snd_eventsDelay;
extern int snd_songIsPlaying;
extern u8 snd_nullInstrument[];
extern sfxStateStruct snd_sfxState;
extern int snd_loadBasesonEntries(const char *fileName);
extern void snd_clearBasesonEntries();
extern void snd_stopSong();
extern void snd_freeSong();
extern int snd_loadSong(const char *songName);
extern void snd_fadeOutSong();
extern void snd_playSong();
extern void snd_handleEvents();
extern void snd_handlePattern(int channelNum, const u8 *patternData);
#endif /* _SFXPLAYER_H_ */

View File

@ -0,0 +1,435 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
#include "cine/sound_driver.h"
#include "sound/mixer.h"
#include "sound/fmopl.h"
u8 snd_useAdlib = 0;
u16 snd_fadeOutCounter = 0;
u16 snd_songTicksCounter = 0;
u8 *snd_adlibInstrumentsTable[4];
sndDriverStruct snd_driver;
static u8 snd_adlibVibrato = 0;
static s16 snd_adlibChannelVolume[4];
static const u16 snd_adlibFreqTable[] = {
0x0157, 0x016C, 0x0181, 0x0198, 0x01B1, 0x01CB, 0x01E6, 0x0203,
0x0222, 0x0243, 0x0266, 0x028A
};
static const u8 snd_adlibOpTable[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15
};
static const u8 snd_adlibNoteTable[] = {
0x00, 0x03, 0x01, 0x04, 0x02, 0x05, 0x06, 0x09, 0x07,
0x0A, 0x08, 0x0B, 0x0C, 0x0F, 0x10, 0x10, 0x0E, 0x0E,
0x11, 0x11, 0x0D, 0x0D, 0x00, 0x00
};
static const s16 snd_adlibNoteFreqTable[] = {
0x0EEE, 0x0E17, 0x0D4D, 0x0C8C, 0x0BD9, 0x0B2F, 0x0A8E, 0x09F7,
0x0967, 0x08E0, 0x0861, 0x07E8, 0x0777, 0x070B, 0x06A6, 0x0647,
0x05EC, 0x0597, 0x0547, 0x04FB, 0x04B3, 0x0470, 0x0430, 0x03F4,
0x03BB, 0x0385, 0x0353, 0x0323, 0x02F6, 0x02CB, 0x02A3, 0x027D,
0x0259, 0x0238, 0x0218, 0x01FA, 0x01DD, 0x01C2, 0x01A9, 0x0191,
0x017B, 0x0165, 0x0151, 0x013E, 0x012C, 0x011C, 0x010C, 0x00FD,
0x00EE, 0x00E1, 0x00D4, 0x00C8, 0x00BD, 0x00B2, 0x00A8, 0x009F,
0x0096, 0x008E, 0x0086, 0x007E, 0x0077, 0x0070, 0x006A, 0x0064,
0x005E, 0x0059, 0x0054, 0x004F, 0x004B, 0x0047, 0x0043, 0x003F,
0x003B, 0x0038, 0x0035, 0x0032, 0x002F, 0x002C, 0x002A, 0x0027,
0x0025, 0x0023, 0x0021, 0x001F, 0x001D, 0x001C, 0x001A, 0x0019,
0x0017, 0x0016, 0x0015, 0x0013, 0x0012, 0x0011, 0x0010, 0x000F
};
static void snd_adlibWriteData(int port, int value)
{
OPLWriteReg(g_cine_adlib->getOPL(), port, value);
}
static void snd_adlibDriverSetupInstrument(const u8 *instrumentData, int channelNum) {
s16 tmp;
u8 waveSelect1 = instrumentData[54] & 3; /* var2 */
u8 waveSelect2 = instrumentData[56] & 3; /* var1 */
u8 fl = *instrumentData++; /* varB */
u8 ch = *instrumentData++; /* var4 */
u8 adlibOp1, adlibOp2; /* _di, varA */
if (fl != 0) {
adlibOp1 = snd_adlibOpTable[snd_adlibNoteTable[ch * 2 + 0]];
adlibOp2 = snd_adlibOpTable[snd_adlibNoteTable[ch * 2 + 1]];
} else {
adlibOp1 =
snd_adlibOpTable[snd_adlibNoteTable[channelNum * 2 + 0]];
adlibOp2 =
snd_adlibOpTable[snd_adlibNoteTable[channelNum * 2 + 1]];
}
if (fl == 0 || ch == 6) {
/* vibrato */
tmp = 0;
if (readU16LE(instrumentData + 18) != 0)
tmp |= 0x80;
if (readU16LE(instrumentData + 20) != 0)
tmp |= 0x40;
if (readU16LE(instrumentData + 10) != 0)
tmp |= 0x20;
if (readU16LE(instrumentData + 22) != 0)
tmp |= 0x10;
tmp |= (readU16LE(instrumentData + 2) & 0xF);
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_EG_KS + adlibOp1, tmp);
/* key scaling */
tmp = 0x3F - (readU16LE(instrumentData + 16) & 0x3F);
tmp = snd_adlibChannelVolume[channelNum] * tmp;
tmp += tmp + 0x7F;
tmp = 0x3F - (tmp / 0xFE);
if (readU16LE(instrumentData + 24) != 0)
tmp = readU16LE(instrumentData + 16) & 0x3F;
tmp |= readU16LE(instrumentData) << 6;
snd_adlibWriteData(ADLIB_REG_KEY_SCALING_OPERATOR_OUTPUT +
adlibOp1, tmp);
/* attack/decay rates */
tmp =
(readU16LE(instrumentData +
6) << 4) | (readU16LE(instrumentData + 12) & 0xF);
snd_adlibWriteData(ADLIB_REG_ATTACK_RATE_DECAY_RATE + adlibOp1,
tmp);
/* sustain/release rates */
tmp =
(readU16LE(instrumentData +
8) << 4) | (readU16LE(instrumentData + 14) & 0xF);
snd_adlibWriteData(ADLIB_REG_SUSTAIN_LEVEL_RELEASE_RATE_0 +
adlibOp1, tmp);
if (fl != 0) {
tmp = readU16LE(instrumentData + 4) * 2;
if (readU16LE(instrumentData + 24) == 0)
tmp |= 1;
snd_adlibWriteData
(ADLIB_REG_FEEDBACK_STRENGTH_CONNECTION_TYPE + ch,
tmp);
} else {
tmp = readU16LE(instrumentData + 4) * 2;
if (readU16LE(instrumentData + 24) == 0)
tmp |= 1;
snd_adlibWriteData
(ADLIB_REG_FEEDBACK_STRENGTH_CONNECTION_TYPE +
channelNum, tmp);
}
snd_adlibWriteData(ADLIB_REG_WAVE_SELECT + adlibOp1,
waveSelect1);
instrumentData += 26;
}
/* vibrato */
tmp = 0;
if (readU16LE(instrumentData + 18) != 0)
tmp |= 0x80;
if (readU16LE(instrumentData + 20) != 0)
tmp |= 0x40;
if (readU16LE(instrumentData + 10) != 0)
tmp |= 0x20;
if (readU16LE(instrumentData + 22) != 0)
tmp |= 0x10;
tmp |= (readU16LE(instrumentData + 2) & 0xF);
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_EG_KS + adlibOp2, tmp);
/* key scaling */
tmp = 0x3F - (readU16LE(instrumentData + 16) & 0x3F);
tmp = snd_adlibChannelVolume[channelNum] * tmp;
tmp += tmp + 0x7F;
tmp = 0x3F - (tmp / 0xFE);
tmp |= readU16LE(instrumentData) << 6;
snd_adlibWriteData(ADLIB_REG_KEY_SCALING_OPERATOR_OUTPUT + adlibOp2,
tmp);
/* attack/decay rates */
tmp =
(readU16LE(instrumentData + 6) << 4) | (readU16LE(instrumentData +
12) & 0xF);
snd_adlibWriteData(ADLIB_REG_ATTACK_RATE_DECAY_RATE + adlibOp2, tmp);
/* sustain/release rates */
tmp =
(readU16LE(instrumentData + 8) << 4) | (readU16LE(instrumentData +
14) & 0xF);
snd_adlibWriteData(ADLIB_REG_SUSTAIN_LEVEL_RELEASE_RATE_0 + adlibOp2,
tmp);
snd_adlibWriteData(ADLIB_REG_WAVE_SELECT + adlibOp2, waveSelect2);
}
static void snd_adlibInterrupt(void *param, s16 *buf, int len) {
int16 *origData = buf;
uint origLen = len;
static int samplesLeft = 0;
while (len != 0) {
int count;
if (samplesLeft == 0) {
if (snd_songIsPlaying || (snd_fadeOutCounter != 0
&& snd_fadeOutCounter < 100)) {
++snd_songTicksCounter;
if (snd_songTicksCounter > snd_eventsDelay) {
snd_handleEvents();
snd_songTicksCounter = 0;
}
}
samplesLeft = g_cine_adlib->getRate() / 50;
}
count = samplesLeft;
if (count > len)
count = len;
YM3812UpdateOne(g_cine_adlib->getOPL(), buf, count);
samplesLeft -= count;
len -= count;
buf += count;
}
// Convert mono data to stereo
for (int i = (origLen - 1); i >= 0; i--) {
origData[2 * i] = origData[2 * i + 1] = origData[i];
}
}
static void snd_adlibDriverSetupChannel(int channelNum, const u8 *data,
int instrumentNum) {
s16 vol = snd_sfxState.songData[instrumentNum];
if (vol != 0 && vol < 0x50)
vol = 0x50;
vol -= snd_fadeOutCounter;
if (vol < 0)
vol = 0;
vol += vol / 4;
if (vol > 0x7F)
vol = 0x7F;
snd_adlibChannelVolume[channelNum] = vol;
snd_adlibDriverSetupInstrument(data, channelNum);
}
static void snd_getAdlibFrequency(int frequency, int *adlibFreq) {
int i;
*adlibFreq = 95;
for (i = 0; i < 96; ++i) {
if (snd_adlibNoteFreqTable[i] <= frequency) {
*adlibFreq = i;
break;
}
}
}
static void snd_adlibDriverSetChannelFrequency(int channelNum, int frequency) {
const u8 *instr = snd_adlibInstrumentsTable[channelNum];
u8 fl = *instr++; /* var2 */
u8 ch = *instr++; /* var1 */
if (fl != 0 && ch == 6)
channelNum = 6;
if (fl == 0 || channelNum == 6) {
u16 freqLow, freqHigh; /* var8 */
int adlibFreq;
snd_getAdlibFrequency(frequency, &adlibFreq);
if (channelNum == 6)
adlibFreq %= 12;
freqLow = snd_adlibFreqTable[adlibFreq % 12];
snd_adlibWriteData(ADLIB_REG_FREQUENCY_0 + channelNum,
freqLow);
freqHigh = ((adlibFreq / 12) << 2) | ((freqLow & 0x300) >> 8);
if (fl == 0)
freqHigh |= 0x20;
snd_adlibWriteData(ADLIB_REG_KEY_ON_OCTAVE_FREQUENCY_0 +
channelNum, freqHigh);
}
if (fl != 0) {
snd_adlibVibrato |= 1 << (10 - ch);
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_RHYTHM,
snd_adlibVibrato);
}
}
static void snd_adlibDriverStopChannel(int channelNum) {
const u8 *instr = snd_adlibInstrumentsTable[channelNum];
u8 fl = *instr++; /* var2 */
u8 ch = *instr++; /* var1 */
if (fl != 0 && ch == 6)
channelNum = 6;
if (fl == 0 || channelNum == 6)
snd_adlibWriteData(ADLIB_REG_KEY_ON_OCTAVE_FREQUENCY_0 +
channelNum, 0);
if (fl != 0) {
snd_adlibVibrato &= (1 << (10 - ch)) ^ 0xFF;
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_RHYTHM,
snd_adlibVibrato);
}
}
static void snd_adlibDriverPlaySound(u8 * data, int channelNum, int volume) {
/* if (_snd_mute) return;*/
u8 fl, ch; /* var2, var1 */
assert(channelNum < 4);
data += 257;
snd_adlibInstrumentsTable[channelNum] = data;
snd_resetChannel(channelNum);
snd_adlibChannelVolume[channelNum] = 0x7F;
snd_adlibDriverSetupInstrument(data, channelNum);
fl = *data++;
ch = *data++;
if (fl != 0 && ch == 6)
channelNum = 6;
if (fl == 0 || channelNum == 6) {
u16 freqLow, freqHigh;
freqLow = snd_adlibFreqTable[0];
snd_adlibWriteData(ADLIB_REG_FREQUENCY_0 + channelNum,
freqLow);
freqHigh = 4 | ((freqLow & 0x300) >> 8);
if (fl == 0)
freqHigh |= 0x20;
snd_adlibWriteData(ADLIB_REG_KEY_ON_OCTAVE_FREQUENCY_0 +
channelNum, freqHigh);
}
if (fl != 0) {
snd_adlibVibrato = 1 << (10 - ch);
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_RHYTHM,
snd_adlibVibrato);
}
}
static sndDriverStruct snd_adlibDriver = {
&snd_adlibDriverSetupChannel,
&snd_adlibDriverSetChannelFrequency,
&snd_adlibDriverStopChannel,
&snd_adlibDriverPlaySound
};
void snd_adlibDriverStopSong() {
int i;
for (i = 0; i < 18; ++i)
snd_adlibWriteData(ADLIB_REG_KEY_SCALING_OPERATOR_OUTPUT +
snd_adlibOpTable[i], 0x3F);
for (i = 0; i < 9; ++i)
snd_adlibWriteData(ADLIB_REG_KEY_ON_OCTAVE_FREQUENCY_0 + i, 0);
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_RHYTHM, 0);
}
void snd_resetChannel(int channelNum) {
(*snd_driver.stopChannel) (channelNum);
if (snd_useAdlib)
snd_adlibDriverStopSong();
}
AdlibMusic::AdlibMusic(Audio::Mixer *pMixer) {
_mixer = pMixer;
_sampleRate = pMixer->getOutputRate();
g_cine_adlib = this;
_opl = makeAdlibOPL(_sampleRate);
snd_adlibVibrato = 0x20;
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_RHYTHM, snd_adlibVibrato);
snd_adlibWriteData(0x08, 0x40);
int i;
for (i = 0; i < 18; ++i)
snd_adlibWriteData(ADLIB_REG_KEY_SCALING_OPERATOR_OUTPUT +
snd_adlibOpTable[i], 0);
for (i = 0; i < 9; ++i)
snd_adlibWriteData(ADLIB_REG_KEY_ON_OCTAVE_FREQUENCY_0 + i, 0);
for (i = 0; i < 9; ++i)
snd_adlibWriteData(ADLIB_REG_FEEDBACK_STRENGTH_CONNECTION_TYPE
+ i, 0);
for (i = 0; i < 18; ++i)
snd_adlibWriteData(ADLIB_REG_ATTACK_RATE_DECAY_RATE +
snd_adlibOpTable[i], 0);
for (i = 0; i < 18; ++i)
snd_adlibWriteData(ADLIB_REG_SUSTAIN_LEVEL_RELEASE_RATE_0 +
snd_adlibOpTable[i], 0);
for (i = 0; i < 18; ++i)
snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_EG_KS +
snd_adlibOpTable[i], 0);
for (i = 0; i < 18; ++i)
snd_adlibWriteData(ADLIB_REG_WAVE_SELECT + snd_adlibOpTable[i],
0);
snd_adlibWriteData(1, 0x20);
snd_adlibWriteData(1, 0);
for (i = 0; i < 4; ++i)
snd_adlibInstrumentsTable[i] = snd_nullInstrument;
snd_useAdlib = 1;
snd_driver = snd_adlibDriver;
_mixer->setupPremix(this);
}
void AdlibMusic::premixerCall(int16 *data, uint len) {
snd_adlibInterrupt(NULL, data, len);
}
void AdlibMusic::setVolume(uint8 volume) {
for (int i = 0; i < 4; ++i)
snd_adlibChannelVolume[i] = volume | 128;
}
AdlibMusic::~AdlibMusic(void) {
_mixer->setupPremix(NULL);
}

View File

@ -0,0 +1,91 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_SNDDRIVER_H_
#define CINE_SNDDRIVER_H_
#define ADLIB_REG_TIMER_1_DATA 2
#define ADLIB_REG_TIMER_CONTROL_FLAGS 4
#define ADLIB_REG_AM_VIBRATO_EG_KS 0x20
#define ADLIB_REG_KEY_SCALING_OPERATOR_OUTPUT 0x40
#define ADLIB_REG_ATTACK_RATE_DECAY_RATE 0x60
#define ADLIB_REG_SUSTAIN_LEVEL_RELEASE_RATE_0 0x80
#define ADLIB_REG_FREQUENCY_0 0xA0
#define ADLIB_REG_KEY_ON_OCTAVE_FREQUENCY_0 0xB0
#define ADLIB_REG_AM_VIBRATO_RHYTHM 0xBD
#define ADLIB_REG_FEEDBACK_STRENGTH_CONNECTION_TYPE 0xC0
#define ADLIB_REG_WAVE_SELECT 0xE0
typedef struct {
void (*setupChannel) (int channelNum, const u8 * data,
int instrumentNum);
void (*setChannelFrequency) (int channelNum, int frequency);
void (*stopChannel) (int channelNum);
void (*playSound) (u8 * data, int channelNum, int volume);
} sndDriverStruct;
extern u16 snd_fadeOutCounter, snd_songTicksCounter;
extern u8 *snd_adlibInstrumentsTable[4];
extern sndDriverStruct snd_driver;
extern void snd_adlibDriverInit();
extern void snd_adlibDriverExit();
extern void snd_adlibDriverStopSong();
extern void snd_resetChannel(int channelNum);
#include "sound/audiostream.h"
#include "sound/fmopl.h"
namespace Audio {
class Mixer;
}
class AdlibMusic : public AudioStream {
public:
AdlibMusic(Audio::Mixer * pMixer);
~AdlibMusic(void);
virtual void setVolume(uint8 volume);
FM_OPL *getOPL() {
return _opl;
}
// AudioStream API
int readBuffer(int16 *buffer, const int numSamples) {
premixerCall(buffer, numSamples / 2);
return numSamples;
}
bool isStereo() const { return true; }
bool endOfData() const { return false; }
int getRate() const { return _sampleRate; }
private:
FM_OPL *_opl;
Audio::Mixer * _mixer;
uint32 _sampleRate;
void premixerCall(int16 *buf, uint len);
};
#endif /* CINE_SNDDRIVER_H_ */

82
engines/cine/texte.cpp Normal file
View File

@ -0,0 +1,82 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
u8 *textDataPtr;
u8 textTable[256][2][16 * 8];
void generateMask(u8 *sprite, u8 *mask, u16 size, u8 transparency);
void loadTextData(char *pFileName, u8 *pDestinationBuffer) {
Common::File pFileHandle;
u16 entrySize;
u16 numEntry;
u16 i;
u8 *tempBuffer;
u16 dataSize;
assert(pFileName);
assert(pDestinationBuffer);
pFileHandle.open(pFileName);
assert(pFileHandle.isOpen());
pFileHandle.read(&entrySize, 2);
flipU16(&entrySize);
pFileHandle.read(&numEntry, 2);
flipU16(&numEntry);
dataSize = numEntry * entrySize;
pFileHandle.read(pDestinationBuffer, numEntry * entrySize);
tempBuffer = pDestinationBuffer;
if (gameType == Cine::GID_FW) {
dataSize = dataSize / 0x4E;
loadRelatedPalette(pFileName);
for (i = 0; i < 0x4E; i++) {
gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 16,
8);
generateMask(textTable[i][0], textTable[i][1], 16 * 8,
0);
tempBuffer += dataSize;
}
} else {
for (i = 0; i < 90; i++) {
gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 8,
8);
generateMask(textTable[i][0], textTable[i][1], 8 * 8,
0);
tempBuffer += 0x40;
}
}
pFileHandle.close();
}

33
engines/cine/texte.h Normal file
View File

@ -0,0 +1,33 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_TEXTE_H_
#define CINE_TEXTE_H_
extern u8 *textDataPtr;
extern u8 textTable[256][2][16 * 8];
void loadTextData(char *pFileName, u8 *pDestinationBuffer);
#endif

151
engines/cine/unpack.cpp Normal file
View File

@ -0,0 +1,151 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cine/cine.h"
u32 crc; // variable at 5C5A
u32 bitbucket; // dx:bx
u16 swap16(u16 r) {
return (r >> 8) | (r << 8);
}
#define loadd(p, d) {\
d = *(--p);\
d |= (*(--p)) << 8;\
d |= (*(--p)) << 16;\
d |= (*(--p)) << 24;\
}
#define store(p, b) *(--p) = b
#define getbit(p, b) {\
b = bitbucket & 1;\
bitbucket >>= 1;\
if (!bitbucket) {\
loadd(p, bitbucket);\
crc ^= bitbucket;\
b = bitbucket & 1;\
bitbucket >>= 1;\
bitbucket |= 0x80000000;\
}\
}
#define loadbits(p, b) {\
b = 0;\
do {\
getbit(p, bit);\
b <<= 1;\
b |= bit;\
nbits--;\
} while (nbits);\
}
int decomp(u8 *in, u8 *out, int size) {
u8 bit; // Carry flag
u8 nbits; // cl
u8 byte = 0; // ch
u16 counter; // bp
u16 var = 0; // variable at 5C58
u16 ptr;
u16 flags;
enum {
DO_COPY,
DO_UNPACK
} action;
loadd(in, crc);
loadd(in, bitbucket);
crc ^= bitbucket;
do { // 5A4C
getbit(in, bit);
if (!bit) { // 5A94
getbit(in, bit);
if (!bit) { // 5AC8
nbits = 3;
byte = 0;
action = DO_COPY;
} else { // 5ACA
var = 1;
nbits = 8;
action = DO_UNPACK;
}
} else { // 5B4F
nbits = 2;
loadbits(in, flags);
if (flags < 2) {
nbits = flags + 9; // 5BC3
var = flags + 2;
action = DO_UNPACK;
} else if (flags == 3) {
nbits = 8; // 5B4A
byte = 8;
action = DO_COPY;
} else {
nbits = 8;
loadbits(in, var);
nbits = 12;
action = DO_UNPACK;
}
}
switch (action) {
case DO_COPY:
{
// 5AD1
loadbits(in, counter); // 5AFD
counter += byte;
counter++;
size -= counter;
do {
nbits = 8;
loadbits(in, byte); // 5B3F
store(out, byte);
counter--;
} while (counter); // 5B45
break;
}
case DO_UNPACK:
// 5BD3
loadbits(in, ptr); // 5BFF
counter = var + 1;
size -= counter;
do {
byte = *(out + ptr - 1);
store(out, byte);
counter--;
} while (counter);
}
} while (size > 0);
// 5C32
// ???
if (crc) {
return -1;
} else {
return 0;
}
}

30
engines/cine/unpack.h Normal file
View File

@ -0,0 +1,30 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_UNPACK_H_
#define CINE_UNPACK_H_
int decomp(u8 *in, u8 *out, int size);
#endif

3263
engines/cine/various.cpp Normal file

File diff suppressed because it is too large Load Diff

193
engines/cine/various.h Normal file
View File

@ -0,0 +1,193 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef CINE_VARIOUS_H_
#define CINE_VARIOUS_H_
#include "cine/cine.h"
extern int gameType;
typedef char commandeType[20];
s16 makeMenuChoice(const commandeType commandList[], u16 height, u16 X, u16 Y,
u16 width);
s16 makeMenuChoice2(const commandeType commandList[], u16 height, u16 X, u16 Y,
u16 width);
extern s16 allowSystemMenu;
typedef struct {
u8 *ptr;
u16 len;
} unk1Struct;
#define NUM_MAX_MESSAGE 255
extern unk1Struct messageTable[NUM_MAX_MESSAGE];
struct unkListElementStruct {
struct unkListElementStruct *next;
s16 var4;
s16 var6;
s16 var8;
s16 varA;
s16 varC;
s16 varE;
s16 var10;
s16 var12;
s16 var14;
s16 var16;
s16 var18;
s16 var1A;
s16 var1C;
s16 var1E;
};
typedef struct unkListElementStruct unkListElementStruct;
extern unkListElementStruct unkList;
extern u32 var6;
extern u32 var8;
extern u8 *var9;
extern u16 var2;
extern u16 var3;
extern u16 var4;
extern u16 var5;
extern Common::File palFileHandle;
extern Common::File partFileHandle;
void processPendingUpdates(s16 param);
void closeEngine3(void);
void mainLoopSub1(void);
void mainLoopSub2(u16 param1, u16 param2, u16 param3, u16 param4);
extern u16 errorVar;
extern u8 menuVar;
void gfxFuncGen1(u8 *param1, u8 *param2, u8 *param3, u8 *param4,
s16 param5);
extern u8 *page0;
extern u8 *page0c;
void ptrGfxFunc13(void);
void gfxFuncGen2(void);
extern u16 allowPlayerInput;
extern u16 checkForPendingDataLoadSwitch;
extern u16 fadeRequired;
extern u16 isDrawCommandEnabled;
extern u16 waitForPlayerClick;
extern u16 var16;
extern u16 var17;
extern u16 var18;
extern u16 var19;
extern u16 var20;
extern u8 var21;
extern s16 playerCommand;
extern char commandBuffer[80];
extern u16 c_palette[256];
extern char currentPrcName[20];
extern char currentRelName[20];
extern char currentObjectName[20];
extern char currentMsgName[20];
extern char newPrcName[20];
extern char newRelName[20];
extern char newObjectName[20];
extern char newMsgName[20];
extern char currentBgName[8][15];
extern char currentCtName[15];
extern char currentPartName[15];
void stopSample(void);
void mainLoopSub3(void);
u16 executePlayerInput(void);
void drawOverlays(void);
void flip(void);
extern u16 mouseUpdateStatus;
extern u16 dummyU16;
void getMouseData(u16 param, u16 *pButton, u16 *pX, u16 *pY);
u16 processKeyboard(u16 param);
void mainLoopSub6(void);
void checkForPendingDataLoad(void);
extern u16 exitEngine;
void hideMouse(void);
void closeEngine7(void);
extern u16 var22;
void removeExtention(char *dest, const char *source);
struct selectedObjStruct {
s16 idx;
s16 param;
};
typedef struct selectedObjStruct selectedObjStruct;
extern u16 defaultMenuBoxColor;
extern u16 defaultMenuBoxColor2;
#define NUM_MAX_ZONE 16
extern u16 zoneData[NUM_MAX_ZONE];
void addMessage(u8 param1, s16 param2, s16 param3, s16 param4, s16 param5);
void blitScreen(u8 *frontBuffer, u8 *backbuffer);
struct mouseStatusStruct {
int left;
int right;
int X;
int Y;
};
typedef struct mouseStatusStruct mouseStatusStruct;
extern s16 additionalBgVScroll;
void addUnkListElement(s16 param0, s16 param1, s16 param2, s16 param3,
s16 param4, s16 param5, s16 param6, s16 param7, s16 param8);
void resetUnkList();
void processUnkList(void);
#endif

View File

@ -66,3 +66,10 @@ DEFINES += -DDISABLE_LURE
else
MODULES += engines/lure
endif
ifdef DISABLE_CINE
DEFINES += -DDISABLE_CINE
else
MODULES += engines/cine
endif

View File

@ -37,6 +37,11 @@ static const char *credits[] = {
"\\C\\c0""Torbjorn Andersson",
"\\C\\c0""Jonathan Gray",
"\\C\\c0""",
"\\C\\c1""Cinematique evo 1",
"\\C\\c0""Pawel Kolodziejski",
"\\C\\c0""Gregory Montoir",
"\\C\\c0""Eugene Sandulenko",
"\\C\\c0""",
"\\C\\c1""FOTAQ",
"\\C\\c0""David Eriksson",
"\\C\\c0""Gregory Montoir",
@ -106,7 +111,7 @@ static const char *credits[] = {
"\\C\\c0""Jamieson Christian",
"\\C\\c2""iMUSE, MIDI, all things musical",
"\\C\\c0""Vincent Hamm",
"\\C\\c2""Co-Founder",
"\\C\\c2""Co-Founder, original CinE engine author",
"\\C\\c0""Ruediger Hanke",
"\\C\\c2""Port: MorphOS",
"\\C\\c0""Felix Jakschitsch",

View File

@ -473,6 +473,12 @@ begin_credits("Credits");
add_person("Jonathan Gray", "khalek", "");
end_section();
begin_section("Cinematique evo 1");
add_person("Pawe&#322; Ko&#322;odziejski", "aquadran", "");
add_person("Gregory Montoir", "cyx", "");
add_person("Eugene Sandulenko", "sev", "");
end_section();
begin_section("FOTAQ"); # Flight of the Amazon Queen
add_person("David Eriksson", "twogood", "");
add_person("Gregory Montoir", "cyx", "");
@ -549,10 +555,10 @@ begin_credits("Credits");
begin_section("Retired Team Members");
begin_persons();
add_person("Tore Anderson", "tore", "Former Debian GNU/Linux maintainer");
add_person("Tore Anderson", "tore", "Former Debian GNU/Linux maintainer");
add_person("Ralph Brorsen", "painelf", "Help with GUI implementation");
add_person("Jamieson Christian", "jamieson630", "iMUSE, MIDI, all things musical");
add_person('Vincent Hamm', 'yazoo', "Co-Founder");
add_person('Vincent Hamm', 'yazoo', "Co-Founder, original CinE engine author");
add_person("Ruediger Hanke", "", "Port: MorphOS");
add_person("Felix Jakschitsch", "yot", "Zak256 reverse engineering");
add_person("Mutwin Kraus", "mutle", "Original MacOS porter");