added some functions to SkyLogic, -Screen, -Talk and -Disk, moved SkyGrid out of SkyState

svn-id: r8266
This commit is contained in:
Robert Göffringmann 2003-06-02 06:42:42 +00:00
parent cee02068ca
commit 3ac5b4ccfa
10 changed files with 115 additions and 48 deletions

View File

@ -344,6 +344,18 @@ void SkyDisk::fnCacheFiles(void) {
_buildList[0] = 0;
}
void SkyDisk::fnMiniLoad(uint16 fileNum) {
uint16 cnt = 0;
while (_loadedFilesList[cnt]) {
if (_loadedFilesList[cnt] == fileNum) return ;
cnt++;
}
_loadedFilesList[cnt] = fileNum;
_loadedFilesList[cnt + 1] = 0;
SkyState::_itemList[fileNum & 2047] = (void**)loadFile(fileNum, NULL);
}
void SkyDisk::fnFlushBuffers(void) {
// dump all loaded sprites

View File

@ -46,6 +46,7 @@ public:
uint32 _lastLoadedFileSize;
void fnMiniLoad(uint16 fileNum);
void fnCacheFast(uint32 list);
void fnCacheChip(uint32 list);
void fnCacheFiles(void);

View File

@ -49,14 +49,14 @@ static const LogicTable logicTable[] = {
&SkyLogic::simpleAnim, // 16 Module anim without x,y's
};
SkyLogic::SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound) {
SkyLogic::SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound) {
_skyScreen = skyScreen;
_skyDisk = skyDisk;
_skyGrid = skyGrid;
_skyText = skyText;
_skyMusic = skyMusic;
_skySound = skySound;
_skyMouse = skyMouse;
_skyGrid = new SkyGrid(_skyDisk);
_skyAutoRoute = new SkyAutoRoute(_skyGrid);
for (int i = 0; i < ARRAYSIZE(_moduleList); i++)
@ -498,6 +498,7 @@ void SkyLogic::talk() {
if ((_compact->extCompact->spTextId == 0xFFFF) && // is this a voc file?
(_skySound->speechFinished())) { // finished?
printf("weird thing\n");
_compact->logic = L_SCRIPT; // restart character control
@ -522,6 +523,7 @@ void SkyLogic::talk() {
_compact->grafixProg = graphixProg;
}
} else {
printf("EOA reached. getTo = %d (%X) frame %X\n",_compact->getToFlag,_compact->getToFlag,_compact->getToFlag>>6);
// we ran out of frames, let actor stand still.
// TODO: we should improve this and simply restart animation.
_compact->frame = _compact->getToFlag;
@ -1510,13 +1512,32 @@ bool SkyLogic::fnSpeakMeDir(uint32 targetId, uint32 mesgNum, uint32 animNum) {
}
bool SkyLogic::fnSpeakWait(uint32 id, uint32 message, uint32 animation) {
// non player mega char speaks
// player will wait for it to finish before continuing script processing
_compact->flag = (uint16)(id & 0xffff);
_compact->logic = L_LISTEN;
return fnSpeakMe(id, message, animation);
}
bool SkyLogic::fnSpeakWaitDir(uint32 a, uint32 b, uint32 c) {
error("Stub: fnSpeakWaitDir");
/* non player mega chr$ speaks S2(20Jan93tw)
the player will wait for it to finish
before continuing script processing
this function sets the directional option whereby
the anim chosen is linked to c_dir -
_compact is player
a is ID to speak (not us)
b is text message number
c is base of mini table within anim_talk_table */
_compact->flag = (uint16)a;
_compact->logic = L_LISTEN;
Compact *speaker = SkyState::fetchCompact(a);
if (c) c += speaker->extCompact->dir << 1;
stdSpeak(speaker, b, c, speaker->extCompact->dir << 1);
return false;
}
bool SkyLogic::fnChooser(uint32 a, uint32 b, uint32 c) {
@ -1524,7 +1545,7 @@ bool SkyLogic::fnChooser(uint32 a, uint32 b, uint32 c) {
// setup the text questions to be clicked on
// read from TEXT1 until 0
// systemFlags |= 1 << SF_CHOOSING; // can't save/restore while choosing
SkyState::_systemVars.systemFlags |= SF_CHOOSING; // can't save/restore while choosing
_scriptVariables[THE_CHOSEN_ONE] = 0; // clear result
@ -1988,11 +2009,14 @@ bool SkyLogic::fnCustomJoey(uint32 id, uint32 b, uint32 c) {
}
bool SkyLogic::fnSetPalette(uint32 a, uint32 b, uint32 c) {
error("Stub: fnSetPalette");
_skyScreen->setPalette((uint8*)SkyState::fetchCompact(a));
SkyState::_systemVars.currentPalette = a;
return true;
}
bool SkyLogic::fnTextModule(uint32 a, uint32 b, uint32 c) {
error("Stub: fnTextModule");
_skyText->fnTextModule(a, b);
return true;
}
bool SkyLogic::fnChangeName(uint32 id, uint32 textNo, uint32 c) {
@ -2002,7 +2026,8 @@ bool SkyLogic::fnChangeName(uint32 id, uint32 textNo, uint32 c) {
}
bool SkyLogic::fnMiniLoad(uint32 a, uint32 b, uint32 c) {
error("Stub: fnMiniLoad");
_skyDisk->fnMiniLoad((uint16)a);
return true;
}
bool SkyLogic::fnFlushBuffers(uint32 a, uint32 b, uint32 c) {
@ -2011,7 +2036,8 @@ bool SkyLogic::fnFlushBuffers(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnFlushChip(uint32 a, uint32 b, uint32 c) {
error("Stub: fnFlushChip");
// this should be done automatically
return true;
}
bool SkyLogic::fnSaveCoods(uint32 a, uint32 b, uint32 c) {
@ -2072,18 +2098,16 @@ bool SkyLogic::fnEnterSection(uint32 sectionNo, uint32 b, uint32 c) {
if (sectionNo == 5) //linc section - has different mouse icons
_skyMouse->replaceMouseCursors(60302);
else
if (sectionNo != _currentSection) {
if (sectionNo != _currentSection) {
_currentSection = sectionNo;
_saveCurrentSection = sectionNo;
_currentSection = sectionNo;
_saveCurrentSection = sectionNo;
sectionNo++;
_skyMusic->loadSection((byte)sectionNo);
_skySound->loadSection((byte)sectionNo);
_skyGrid->loadGrids();
sectionNo++;
_skyMusic->loadSection((byte)sectionNo);
_skySound->loadSection((byte)sectionNo);
_skyGrid->loadGrids();
}
}
return true;
}
@ -2097,11 +2121,18 @@ bool SkyLogic::fnRestartGame(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnNewSwingSeq(uint32 a, uint32 b, uint32 c) {
error("Stub: fnNewSwingSeq");
// only certain files work on pc. (huh?! something we should take care of?)
if ((a == 85) || (a == 106) || (a == 75) || (a == 15)) {
_skyScreen->startSequenceItem((uint16)a);
} else {
debug(1,"SkyLogic::fnNewSwingSeq: ignored seq %d\n",a);
}
return true;
}
bool SkyLogic::fnWaitSwingEnd(uint32 a, uint32 b, uint32 c) {
error("Stub: fnWaitSwingEnd");
_skyScreen->waitForSequence();
return true;
}
bool SkyLogic::fnSkipIntroCode(uint32 a, uint32 b, uint32 c) {
@ -2110,11 +2141,18 @@ bool SkyLogic::fnSkipIntroCode(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnBlankScreen(uint32 a, uint32 b, uint32 c) {
error("Stub: fnBlankScreen");
_skyScreen->clearScreen();
return true;
}
bool SkyLogic::fnPrintCredit(uint32 a, uint32 b, uint32 c) {
error("Stub: fnPrintCredit");
lowTextManager_t creditText = _skyText->lowTextManager(a , 240, 0, 248, true);
Compact *credCompact = SkyState::fetchCompact(creditText.compactNum);
credCompact->xcood = 168;
credCompact->ycood = (uint16)c;
_scriptVariables[RESULT] = creditText.compactNum;
return true;
}
bool SkyLogic::fnLookAt(uint32 a, uint32 b, uint32 c) {
@ -2194,7 +2232,7 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32
animNum += target->extCompact->megaSet / NEXT_MEGA_SET;
animNum &= 0xFF;
printf("Doing anim %X (%d). %s\n",animNum,animNum,SkyTalkAnims::animTalkTableIsPointer[animNum]?("PTR"):("VAL"));
if (SkyTalkAnims::animTalkTableIsPointer[animNum]) //is it a pointer?
animPtr = (uint16 *)SkyTalkAnims::animTalkTablePtr[animNum];
else //then it must be a value

View File

@ -65,7 +65,7 @@ class SkyScreen;
class SkyLogic {
public:
SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound);
SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound);
void engine();
void nop();

View File

@ -84,6 +84,13 @@ SkyScreen::~SkyScreen(void) {
if (_backScreen) free(_backScreen);
}
void SkyScreen::clearScreen(void) {
memset(_currentScreen, 0, FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
_system->copy_rect(_currentScreen, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
_system->update_screen();
}
//set a new palette, pal is a pointer to dos vga rgb components 0..63
void SkyScreen::setPalette(uint8 *pal) {
@ -366,6 +373,17 @@ void SkyScreen::startSequence(uint16 fileNum) {
_seqInfo.seqDataPos = _seqInfo.seqData + 1;
_seqInfo.delay = SEQ_DELAY;
_seqInfo.running = true;
_seqInfo.runningItem = false;
}
void SkyScreen::startSequenceItem(uint16 itemNum) {
_seqInfo.seqData = (uint8*)SkyState::fetchItem(itemNum);
_seqInfo.framesLeft = _seqInfo.seqData[0];
_seqInfo.seqDataPos = _seqInfo.seqData + 1;
_seqInfo.delay = SEQ_DELAY;
_seqInfo.running = true;
_seqInfo.runningItem = true;
}
void SkyScreen::stopSequence() {
@ -423,16 +441,11 @@ void SkyScreen::processSequence(void) {
}
if (_seqInfo.framesLeft == 0) {
_seqInfo.running = false;
free(_seqInfo.seqData);
if (!_seqInfo.runningItem) free(_seqInfo.seqData);
_seqInfo.seqData = _seqInfo.seqDataPos = NULL;
}
}
bool SkyScreen::sequenceRunning(void) {
return _seqInfo.running;
}
//- sprites.asm routines
void SkyScreen::spriteEngine(void) {

View File

@ -61,8 +61,10 @@ public:
void handleTimer(void);
void startSequence(uint16 fileNum);
void startSequenceItem(uint16 itemNum);
void stopSequence(void);
bool sequenceRunning(void);
bool sequenceRunning(void) { return _seqInfo.running; };
void waitForSequence(void) { while (_seqInfo.running) _system->delay_msecs(20); };
uint32 seqFramesLeft(void) { return _seqInfo.framesLeft; };
uint8 *giveCurrent(void) { return _currentScreen; };
void halvePalette(void);
@ -72,7 +74,7 @@ public:
void fnFadeUp(uint32 palNum, uint32 scroll);
void fnFadeDown(uint32 scroll);
void fnDrawScreen(uint32 palette, uint32 scroll);
void clearScreen(void) { memset(_currentScreen, 0, FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT); };
void clearScreen(void);
void recreate(void);
void flip(void);
@ -101,13 +103,8 @@ private:
uint8 *seqData;
uint8 *seqDataPos;
bool running;
bool runningItem; // when playing an item, don't free it afterwards.
} _seqInfo;
//byte *_workScreen;
//byte *_tempPal;
//byte *_workPalette;
//byte *_halfPalette;
//byte *_scrollAddr;
//byte *_lScreenBuf, *_lPaletteBuf;
//- more regular screen.asm + layer.asm routines
void convertPalette(uint8 *inPal, uint8* outPal);

View File

@ -54,7 +54,7 @@ Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst) {
void **SkyState::_itemList[300];
SystemVars SkyState::_systemVars = {0, 0, 0, 0};
SystemVars SkyState::_systemVars = {0, 0, 0, 0, 4316};
SkyState::SkyState(GameDetector *detector, OSystem *syst)
: Engine(detector, syst) {
@ -112,7 +112,6 @@ void SkyState::showQuitMsg(void) {
SkyState::~SkyState() {
delete _skyLogic;
delete _skyGrid;
delete _skySound;
delete _skyMusic;
showQuitMsg();
@ -153,7 +152,6 @@ void SkyState::go() {
_skyScreen->spriteEngine();
_skyScreen->flip();
_system->update_screen();
//if (_skySound->speechFinished()) printf("finsihed\n"); else printf("running\n");
}
}
@ -185,8 +183,7 @@ void SkyState::initialise(void) {
//initScript();
//initialiseRouter();
loadFixedItems();
_skyGrid = new SkyGrid(_skyDisk);
_skyLogic = new SkyLogic(_skyScreen, _skyDisk, _skyGrid, _skyText, _skyMusic, _skyMouse, _skySound);
_skyLogic = new SkyLogic(_skyScreen, _skyDisk, _skyText, _skyMusic, _skyMouse, _skySound);
_timer = Engine::_timer; // initialize timer *after* _skyScreen has been initialized.
_timer->installProcedure(&timerHandler, 1000000 / 50); //call 50 times per second
@ -218,7 +215,6 @@ void SkyState::loadBase0(void) {
_skyLogic->fnEnterSection(0, 0, 0);
_skyMusic->startMusic(2);
_skyGrid->loadGrids();
}
void SkyState::loadFixedItems(void) {

View File

@ -31,7 +31,6 @@
#include "sky/text.h"
#include "sky/disk.h"
#include "sky/struc.h"
#include "sky/grid.h"
#include "sky/screen.h"
#include "sky/music/musicbase.h"
#include "sky/music/adlibmusic.h"
@ -44,14 +43,13 @@ struct SystemVars {
uint32 gameVersion;
uint32 mouseFlag;
uint16 language;
uint32 currentPalette; // I guess that's for saving.
/* uint16 sfxVolume;
uint16 musicVolume;
uint16 gameSpeed; */
};
class SkyLogic;
class SkyGrid;
class SkyAutoRoute;
class SkyScreen;
class SkyState : public Engine {
@ -86,7 +84,6 @@ protected:
SkySound *_skySound;
SkyDisk *_skyDisk;
SkyText *_skyText;
SkyGrid *_skyGrid;
SkyLogic *_skyLogic;
SkyMouse *_skyMouse;
SkyScreen *_skyScreen;

View File

@ -94,6 +94,18 @@ void SkyText::fnSetFont(uint32 fontNr) {
_dtCharSpacing = newCharSet->charSpacing;
}
void SkyText::fnTextModule(uint32 textInfoId, uint32 textNo) {
fnSetFont(1);
uint16* msgData = (uint16*)SkyState::fetchCompact(textInfoId);
lowTextManager_t textId = lowTextManager(textNo, msgData[1], msgData[2], 209, false);
SkyLogic::_scriptVariables[RESULT] = textId.compactNum;
Compact *textCompact = SkyState::fetchCompact(textId.compactNum);
textCompact->xcood = msgData[3];
textCompact->ycood = msgData[4];
fnSetFont(0);
}
void SkyText::getText(uint32 textNr) { //load text #"textNr" into textBuffer
uint32 sectionNo = (textNr & 0x0F000) >> 10;

View File

@ -40,6 +40,7 @@ public:
void makeGameCharacter(char textChar, uint8 *charSetPtr, uint8 *&data, uint8 color);
struct lowTextManager_t lowTextManager(uint32 textNum, uint16 width, uint16 logicNum, uint8 color, bool centre);
void fnSetFont(uint32 fontNr);
void fnTextModule(uint32 textInfoId, uint32 textNo);
protected:
bool getTBit();