[Scummvm-cvs-logs] CVS: scummvm/sky control.cpp,1.102,1.103 control.h,1.39,1.40 disk.cpp,1.73,1.74 intro.cpp,1.60,1.61 logic.cpp,1.158,1.159 logic.h,1.46,1.47 sky.cpp,1.185,1.186 sky.h,1.69,1.70 skydefs.h,1.32,1.33 sound.cpp,1.57,1.58 sound.h,1.31,1.32 struc.h,1.19,1.20 text.cpp,1.72,1.73 text.h,1.39,1.40
Robert Göffringmann
lavosspawn at users.sourceforge.net
Sun Dec 4 21:04:01 CET 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sky/music adlibchannel.cpp,1.21,1.22 adlibmusic.cpp,1.27,1.28 adlibmusic.h,1.15,1.16 gmmusic.cpp,1.26,1.27 gmmusic.h,1.16,1.17 musicbase.cpp,1.26,1.27 musicbase.h,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/tools scumm-md5.txt,1.103,1.104
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14280/sky
Modified Files:
control.cpp control.h disk.cpp intro.cpp logic.cpp logic.h
sky.cpp sky.h skydefs.h sound.cpp sound.h struc.h text.cpp
text.h
Log Message:
some cleanup, engine returns to the launcher now instead of calling OSystem::quit.
I suppose it leaks memory though...
Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/control.cpp,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- control.cpp 21 Nov 2005 18:21:44 -0000 1.102
+++ control.cpp 5 Dec 2005 05:02:42 -0000 1.103
@@ -182,10 +182,9 @@
}
void ControlStatus::setToText(uint16 textNum) {
- _skyText->getText(textNum);
if (_textData)
free(_textData);
- displayText_t disText = _skyText->displayText(NULL, true, STATUS_WIDTH, 255);
+ displayText_t disText = _skyText->displayText(textNum, NULL, true, STATUS_WIDTH, 255);
_textData = (dataFileHeader *)disText.textData;
_statusText->setSprite(_textData);
_statusText->drawToScreen(WITH_MASK);
@@ -338,12 +337,10 @@
_curButtonText = pButton->_text;
if (pButton->_text) {
displayText_t textRes;
- if (pButton->_text == 0xFFFF) { // text for autosave button
+ if (pButton->_text == 0xFFFF) // text for autosave button
textRes = _skyText->displayText(autoSave, NULL, false, PAN_LINE_WIDTH, 255);
- } else {
- _skyText->getText(pButton->_text);
- textRes = _skyText->displayText(NULL, false, PAN_LINE_WIDTH, 255);
- }
+ else
+ textRes = _skyText->displayText(pButton->_text, NULL, false, PAN_LINE_WIDTH, 255);
_textSprite = (dataFileHeader *)textRes.textData;
_text->setSprite(_textSprite);
} else
@@ -475,7 +472,7 @@
_textSprite = NULL;
uint16 clickRes = 0;
- while (!quitPanel) {
+ while (!quitPanel && !SkyEngine::_systemVars.quitGame) {
_text->drawToScreen(WITH_MASK);
_system->updateScreen();
_mouseClicked = false;
@@ -501,12 +498,13 @@
_mouseClicked = false;
}
}
- if (!haveButton) buttonControl(NULL);
-
+ if (!haveButton)
+ buttonControl(NULL);
}
memset(_screenBuf, 0, GAME_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
_system->copyRectToScreen(_screenBuf, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
- _system->updateScreen();
+ if (!SkyEngine::_systemVars.quitGame)
+ _system->updateScreen();
_skyScreen->forceRefresh();
_skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette));
removePanel();
@@ -583,11 +581,8 @@
return 0;
case QUIT_TO_DOS:
animClick(pButton);
- if (getYesNo(quitDos)) {
- showGameQuitMsg(false);
- delay(1500);
- _system->quit();
- }
+ if (getYesNo(quitDos))
+ SkyEngine::_systemVars.quitGame = true;
return 0;
default:
error("Control::handleClick: unknown routine: %X",pButton->_onClick);
@@ -1538,8 +1533,7 @@
case OSystem::EVENT_RBUTTONDOWN:
break;
case OSystem::EVENT_QUIT:
- if (!SkyEngine::_systemVars.quitting)
- showGameQuitMsg(false);
+ SkyEngine::_systemVars.quitGame = true;
break;
default:
break;
@@ -1559,20 +1553,17 @@
} while (cur < start + amount);
}
-void Control::showGameQuitMsg(bool useScreen) {
+void Control::showGameQuitMsg(void) {
- SkyEngine::_systemVars.quitting = true;
_skyText->fnSetFont(0);
uint8 *textBuf1 = (uint8 *)malloc(GAME_SCREEN_WIDTH * 14 + sizeof(dataFileHeader));
uint8 *textBuf2 = (uint8 *)malloc(GAME_SCREEN_WIDTH * 14 + sizeof(dataFileHeader));
uint8 *screenData;
- if (useScreen) {
- if (_skyScreen->sequenceRunning())
- _skyScreen->stopSequence();
+ if (_skyScreen->sequenceRunning())
+ _skyScreen->stopSequence();
+
+ screenData = _skyScreen->giveCurrent();
- screenData = _skyScreen->giveCurrent();
- } else
- screenData = _screenBuf;
_skyText->displayText(_quitTexts[SkyEngine::_systemVars.language * 2 + 0], textBuf1, true, 320, 255);
_skyText->displayText(_quitTexts[SkyEngine::_systemVars.language * 2 + 1], textBuf2, true, 320, 255);
uint8 *curLine1 = textBuf1 + sizeof(dataFileHeader);
@@ -1591,19 +1582,8 @@
}
_skyScreen->halvePalette();
_skyScreen->showScreen(screenData);
- free(textBuf1); free(textBuf2);
-
- // __tom (FIXME): This is a poor method of turning
- // off music. ~GmMusic, ~AdlibMusic, and ~MT32Music
- // should do it themselves so the appropriate MIDI
- // controller events (e.g. 123/'All Notes Off') can
- // be sent. However, that requires a re-write of
- // other code and for now this fixes hanging notes
- // on MT-32 + other external GMIDI synths.
- _skyMusic->stopMusic();
- delay(1500);
- ConfMan.flushToDisk();
- _system->quit();
+ free(textBuf1);
+ free(textBuf2);
}
char Control::_quitTexts[16][35] = {
Index: control.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/control.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- control.h 18 Oct 2005 01:30:23 -0000 1.39
+++ control.h 5 Dec 2005 05:02:42 -0000 1.40
@@ -181,7 +181,7 @@
void doControlPanel(void);
void doLoadSavePanel(void);
void restartGame(void);
- void showGameQuitMsg(bool useScreen = true);
+ void showGameQuitMsg(void);
void doAutoSave(void);
uint16 quickXRestore(uint16 slot);
bool loadSaveAllowed(void);
Index: disk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/disk.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- disk.cpp 3 Dec 2005 18:58:31 -0000 1.73
+++ disk.cpp 5 Dec 2005 05:02:43 -0000 1.74
@@ -77,6 +77,8 @@
_dnrHandle->close();
if (_dataDiskHandle->isOpen())
_dataDiskHandle->close();
+ fnFlushBuffers();
+ free(_dinnerTableArea);
delete _dnrHandle;
delete _dataDiskHandle;
}
@@ -374,7 +376,7 @@
uint8 lCnt = 0;
while (_loadedFilesList[lCnt]) {
free(SkyEngine::_itemList[_loadedFilesList[lCnt] & 2047]);
- SkyEngine::_itemList[_loadedFilesList[lCnt] & 2047] = 0;
+ SkyEngine::_itemList[_loadedFilesList[lCnt] & 2047] = NULL;
lCnt++;
}
_loadedFilesList[0] = 0;
Index: intro.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/intro.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- intro.cpp 18 Oct 2005 01:30:23 -0000 1.60
+++ intro.cpp 5 Dec 2005 05:02:43 -0000 1.61
@@ -827,8 +827,7 @@
uint16 command = *data++;
switch(command) {
case IC_PREPARE_TEXT:
- _skyText->getText(*data++);
- _skyText->displayText(_textBuf, true, INTRO_TEXT_WIDTH, 255);
+ _skyText->displayText(*data++, _textBuf, true, INTRO_TEXT_WIDTH, 255);
break;
case IC_SHOW_TEXT:
((dataFileHeader*)_textBuf)->s_x = *data++;
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- logic.cpp 5 Nov 2005 19:06:00 -0000 1.158
+++ logic.cpp 5 Dec 2005 05:02:43 -0000 1.159
@@ -87,6 +87,11 @@
initScriptVariables();
}
+Logic::~Logic(void) {
+ delete _skyGrid;
+ delete _skyAutoRoute;
+}
+
void Logic::initScreen0(void) {
fnEnterSection(0, 0, 0);
_skyMusic->startMusic(2);
@@ -2464,8 +2469,8 @@
}
bool Logic::fnQuitToDos(uint32 a, uint32 b, uint32 c) {
- _skyControl->showGameQuitMsg(); // calls _system->quit()
- return true;
+ SkyEngine::_systemVars.quitGame = true;
+ return false;
}
bool Logic::fnPauseFx(uint32 a, uint32 b, uint32 c) {
@@ -2561,7 +2566,7 @@
if (speechUsed)
target->spTime = 10;
else
- target->spTime = (uint16)_skyText->_dtLetters + 5;
+ target->spTime = (uint16)_skyText->_numLetters + 5;
target->logic = L_TALK;
}
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- logic.h 5 Nov 2005 19:06:01 -0000 1.46
+++ logic.h 5 Dec 2005 05:02:43 -0000 1.47
@@ -140,6 +140,7 @@
MusicBase *skyMusic,
Mouse *skyMouse,
Sound *skySound);
+ ~Logic(void);
void engine();
void useControlInstance(Control *control) { _skyControl = control; };
Index: sky.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- sky.cpp 23 Nov 2005 19:11:33 -0000 1.185
+++ sky.cpp 5 Dec 2005 05:02:43 -0000 1.186
@@ -123,6 +123,8 @@
SkyEngine::~SkyEngine() {
+ _timer->removeTimerProc(&timerHandler);
+
delete _skyLogic;
delete _skySound;
delete _skyMusic;
@@ -130,6 +132,11 @@
delete _skyMouse;
delete _skyScreen;
delete _debugger;
+ delete _skyDisk;
+
+ for (int i = 0; i < 300; i++)
+ if (_itemList[i])
+ free(_itemList[i]);
}
void SkyEngine::errorString(const char *buf1, char *buf2) {
@@ -206,6 +213,8 @@
int SkyEngine::go() {
+ _systemVars.quitGame = false;
+
_mouseX = GAME_SCREEN_WIDTH / 2;
_mouseY = GAME_SCREEN_HEIGHT / 2;
_keyFlags = _keyPressed = 0;
@@ -216,25 +225,24 @@
if (result != GAME_RESTORED) {
bool introSkipped = false;
- if (_systemVars.gameVersion > 267) {// don't do intro for floppydemos
+ if (_systemVars.gameVersion > 267) { // don't do intro for floppydemos
_skyIntro = new Intro(_skyDisk, _skyScreen, _skyMusic, _skySound, _skyText, _mixer, _system);
introSkipped = !_skyIntro->doIntro(_floppyIntro);
- if (_skyIntro->_quitProg) {
- delete _skyIntro;
- _skyControl->showGameQuitMsg();
- }
+ _systemVars.quitGame = _skyIntro->_quitProg;
+
delete _skyIntro;
}
- _skyLogic->initScreen0();
-
- if (introSkipped)
- _skyControl->restartGame();
+ if (!_systemVars.quitGame) {
+ _skyLogic->initScreen0();
+ if (introSkipped)
+ _skyControl->restartGame();
+ }
}
_lastSaveTime = _system->getMillis();
- while (1) {
+ while (!_systemVars.quitGame) {
if (_debugger->isAttached())
_debugger->onFrame();
@@ -273,6 +281,10 @@
delay((frameTime + _systemVars.gameSpeed) - _system->getMillis());
}
+ _skyControl->showGameQuitMsg();
+ _skyMusic->stopMusic();
+ ConfMan.flushToDisk();
+ delay(1500);
return 0;
}
@@ -372,12 +384,12 @@
if (!_skyDisk->fileExists(60600 + SkyEngine::_systemVars.language * 8)) {
warning("The language you selected does not exist in your BASS version.");
if (_skyDisk->fileExists(60600))
- SkyEngine::_systemVars.language = SKY_ENGLISH;
+ SkyEngine::_systemVars.language = SKY_ENGLISH; // default to GB english if it exists..
else if (_skyDisk->fileExists(60600 + SKY_USA * 8))
- SkyEngine::_systemVars.language = SKY_USA;
+ SkyEngine::_systemVars.language = SKY_USA; // try US english...
else
for (uint8 cnt = SKY_ENGLISH; cnt <= SKY_SPANISH; cnt++)
- if (_skyDisk->fileExists(60600 + cnt * 8)) {
+ if (_skyDisk->fileExists(60600 + cnt * 8)) { // pick the first language we can find
SkyEngine::_systemVars.language = cnt;
break;
}
@@ -395,22 +407,6 @@
for (int i = 0; i < 300; i++)
_itemList[i] = NULL;
-
- //init the non-null items
- // I don't see where the script could possible access this.. so it should be safe to
- // leave these as NULL.
- /*_itemList[119] = (void **)SkyCompact::data_0; // Compacts - Section 0
- _itemList[120] = (void **)SkyCompact::data_1; // Compacts - Section 1
-
- if (isDemo()) {
- _itemList[121] = _itemList[122] = _itemList[123] = _itemList[124] = _itemList[125] = (void **)SkyCompact::data_0;
- } else {
- _itemList[121] = (void **)SkyCompact::data_2; // Compacts - Section 2
- _itemList[122] = (void **)SkyCompact::data_3; // Compacts - Section 3
- _itemList[123] = (void **)SkyCompact::data_4; // Compacts - Section 4
- _itemList[124] = (void **)SkyCompact::data_5; // Compacts - Section 5
- _itemList[125] = (void **)SkyCompact::data_6; // Compacts - Section 6
- }*/
}
void SkyEngine::loadFixedItems(void) {
@@ -486,8 +482,7 @@
_skyMouse->buttonPressed(1);
break;
case OSystem::EVENT_QUIT:
- if (!SkyEngine::_systemVars.quitting)
- _skyControl->showGameQuitMsg(); // will call _system->quit()
+ _systemVars.quitGame = true;
break;
default:
break;
Index: sky.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- sky.h 18 Oct 2005 01:30:23 -0000 1.69
+++ sky.h 5 Dec 2005 05:02:43 -0000 1.70
@@ -38,7 +38,7 @@
uint16 gameSpeed;
uint16 currentMusic;
bool pastIntro;
- bool quitting;
+ bool quitGame;
bool paused;
};
Index: skydefs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/skydefs.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- skydefs.h 18 Oct 2005 01:30:23 -0000 1.32
+++ skydefs.h 5 Dec 2005 05:02:43 -0000 1.33
@@ -57,6 +57,7 @@
#define SEQUENCE_COUNT 3
#define FIRST_TEXT_COMPACT 23
+#define LAST_TEXT_COMPACT 33
#define FIXED_TEXT_WIDTH 128
//screen/grid defines
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sound.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- sound.cpp 18 Oct 2005 01:30:23 -0000 1.57
+++ sound.cpp 5 Dec 2005 05:02:43 -0000 1.58
@@ -1028,7 +1028,8 @@
Sound::~Sound(void) {
_mixer->stopAll();
- if (_soundData) free(_soundData);
+ if (_soundData)
+ free(_soundData);
}
void Sound::playSound(uint32 id, byte *sound, uint32 size, Audio::SoundHandle *handle) {
@@ -1048,7 +1049,8 @@
fnStopFx();
_mixer->stopAll();
- if (_soundData) free(_soundData);
+ if (_soundData)
+ free(_soundData);
_soundData = _skyDisk->loadFile(pSection * 4 + SOUND_FILE_BASE);
uint16 asmOfs;
if (SkyEngine::_systemVars.gameVersion == 109) {
@@ -1065,10 +1067,8 @@
error("Unknown sounddriver version!");
_soundsTotal = _soundData[asmOfs + 1];
- uint16 sRateTabOfs = (_soundData[asmOfs + 0x2A] << 8) | _soundData[asmOfs + 0x29];
- _sfxBaseOfs = (_soundData[asmOfs + 0x32] << 8) | _soundData[asmOfs + 0x31];
+ _sfxBaseOfs = READ_LE_UINT16(_soundData + asmOfs + 0x31);
- _sampleRates = _soundData + sRateTabOfs;
_sfxInfo = _soundData + _sfxBaseOfs;
// if we just restored a savegame, the sfxqueue holds the sound we need to restart
if (!(SkyEngine::_systemVars.systemFlags & SF_GAME_RESTORED))
@@ -1093,20 +1093,15 @@
return;
}
- volume = ((volume & 0x7F) + 1) << 1;
- if (volume > 255)
- volume = 255;
+ volume = (volume & 0x7F) << 1;
sound &= 0xFF;
// note: all those tables are big endian. Don't ask me why. *sigh*
- uint16 sampleRate = (_sampleRates[sound << 2] << 8) | _sampleRates[(sound << 2) | 1];
- if (sampleRate > 11025)
- sampleRate = 11025;
- uint32 dataOfs = ((_sfxInfo[sound << 3] << 8) | _sfxInfo[(sound << 3) | 1]) << 4;
+ uint32 dataOfs = READ_BE_UINT16(_sfxInfo + (sound << 3) + 0) << 4;
+ uint32 dataSize = READ_BE_UINT16(_sfxInfo + (sound << 3) + 2);
+ uint32 dataLoop = READ_BE_UINT16(_sfxInfo + (sound << 3) + 6);
dataOfs += _sfxBaseOfs;
- uint16 dataSize = (_sfxInfo[(sound << 3) | 2] << 8) | _sfxInfo[(sound << 3) | 3];
- uint16 dataLoop = (_sfxInfo[(sound << 3) | 6] << 8) | _sfxInfo[(sound << 3) | 7];
-
+
byte flags = Audio::Mixer::FLAG_UNSIGNED;
uint32 loopSta = 0, loopEnd = 0;
@@ -1117,9 +1112,9 @@
}
if (channel == 0)
- _mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH0, volume, 0, loopSta, loopEnd);
+ _mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, 11025, flags, SOUND_CH0, volume, 0, loopSta, loopEnd);
else
- _mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH1, volume, 0, loopSta, loopEnd);
+ _mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, 11025, flags, SOUND_CH1, volume, 0, loopSta, loopEnd);
}
void Sound::fnStartFx(uint32 sound, uint8 channel) {
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sound.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- sound.h 18 Oct 2005 01:30:23 -0000 1.31
+++ sound.h 5 Dec 2005 05:02:43 -0000 1.32
@@ -82,7 +82,7 @@
Disk *_skyDisk;
uint16 _sfxBaseOfs;
uint8 *_soundData;
- uint8 *_sampleRates, *_sfxInfo;
+ uint8 *_sfxInfo;
uint8 _mainSfxVolume;
static uint16 _speechConvertTable[8];
Index: struc.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/struc.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- struc.h 18 Oct 2005 01:30:23 -0000 1.19
+++ struc.h 5 Dec 2005 05:02:43 -0000 1.20
@@ -26,6 +26,7 @@
struct lowTextManager_t {
byte *textData;
+ uint32 textWidth;
uint16 compactNum;
};
Index: text.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/text.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- text.cpp 18 Oct 2005 01:30:23 -0000 1.72
+++ text.cpp 5 Dec 2005 05:02:43 -0000 1.73
@@ -31,6 +31,7 @@
#define FIRST_TEXT_SEC 77
#define FIRST_TEXT_BUFFER 274
+#define LAST_TEXT_BUFFER 284
#define NO_OF_TEXT_SECTIONS 8 // 8 sections per language
#define CHAR_SET_FILE 60150
#define MAX_SPEECH_SECTION 7
@@ -63,18 +64,21 @@
_controlCharacterSet.addr = NULL;
_linkCharacterSet.addr = NULL;
}
-
- if (SkyEngine::isCDVersion()) {
- _preAfterTableArea = _skyDisk->loadFile(60522);
- } else
- _preAfterTableArea = NULL;
}
Text::~Text(void) {
+ for (int i = FIRST_TEXT_BUFFER; i <= LAST_TEXT_BUFFER; i++)
+ if (SkyEngine::_itemList[i]) {
+ free(SkyEngine::_itemList[i]);
+ SkyEngine::_itemList[i] = NULL;
+ }
- if (_controlCharacterSet.addr) free(_controlCharacterSet.addr);
- if (_linkCharacterSet.addr) free(_linkCharacterSet.addr);
- if (_preAfterTableArea) free(_preAfterTableArea);
+ if (_mainCharacterSet.addr)
+ free(_mainCharacterSet.addr);
+ if (_controlCharacterSet.addr)
+ free(_controlCharacterSet.addr);
+ if (_linkCharacterSet.addr)
+ free(_linkCharacterSet.addr);
}
void Text::patchChar(byte *charSetPtr, int width, int height, int c, const uint16 *data) {
@@ -97,9 +101,9 @@
byte *charSetPtr = _controlCharacterSet.addr;
int charHeight = _controlCharacterSet.charHeight;
- // In v0.0288, decrease the character spacing is too wide. Decrease
- // the width for every character by one, except for space which needs
- // to be one pixel wider than before.
+ // In v0.0288, the character spacing is too wide. Decrease the width
+ // for every character by one, except for space which needs to be one
+ // pixel wider than before.
if (SkyEngine::_systemVars.gameVersion == 288) {
for (int i = 1; i < CHAR_SET_HEADER; i++)
@@ -247,8 +251,6 @@
patchChar(charSetPtr, 5, charHeight, 74, normal_j);
patchChar(charSetPtr, 6, charHeight, 17, normal_1);
- // TODO: Verify that these work in all versions
-
patchChar(charSetPtr, 5, charHeight, 11, e_acute);
patchChar(charSetPtr, 5, charHeight, 61, e_grave);
patchChar(charSetPtr, 5, charHeight, 29, e_circumflex);
@@ -311,68 +313,57 @@
uint32 sectionNo = (textNr & 0x0F000) >> 12;
- if (SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo] == (void **)NULL) { //check if already loaded
+ if (SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo] == NULL) { //check if already loaded
debug(5, "Loading Text item(s) for Section %d", (sectionNo >> 2));
uint32 fileNo = sectionNo + ((SkyEngine::_systemVars.language * NO_OF_TEXT_SECTIONS) + 60600);
SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo] = (void **)_skyDisk->loadFile((uint16)fileNo);
}
- _textItemPtr = (uint8 *)SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo];
+ uint8 *textDataPtr = (uint8 *)SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo];
uint32 offset = 0;
- uint32 nr32MsgBlocks = (textNr & 0x0fe0);
- uint32 skipBytes;
- byte *blockPtr;
- bool bitSeven;
- if (nr32MsgBlocks) {
- blockPtr = (byte *)(_textItemPtr + 4);
- nr32MsgBlocks >>= 5;
+ uint32 blockNr = textNr & 0xFE0;
+ textNr &= 0x1F;
+
+ if (blockNr) {
+ uint16 *blockPtr = (uint16*)(textDataPtr + 4);
+ uint32 nr32MsgBlocks = blockNr >> 5;
+
do {
offset += READ_LE_UINT16(blockPtr);
- blockPtr += 2;
+ blockPtr++;
} while (--nr32MsgBlocks);
}
- uint32 remItems = textNr;
- textNr &= 0x1f;
if (textNr) {
-
- remItems &= 0x0fe0;
- remItems += READ_LE_UINT16(_textItemPtr);
- blockPtr = _textItemPtr + remItems;
-
+ uint8 *blockPtr = textDataPtr + blockNr + READ_LE_UINT16(textDataPtr);
do {
- skipBytes = *blockPtr++;
- bitSeven = (bool)((skipBytes >> (7)) & 0x1);
- skipBytes &= ~(1UL << 7);
-
- if (bitSeven)
+ uint8 skipBytes = *blockPtr++;
+ if (skipBytes & 0x80) {
+ skipBytes &= 0x7F;
skipBytes <<= 3;
-
+ }
offset += skipBytes;
-
} while (--textNr);
}
- uint32 numBits = offset;
+ uint32 bitPos = offset & 3;
offset >>= 2;
- offset += READ_LE_UINT16(_textItemPtr + 2);
- _textItemPtr += offset;
+ offset += READ_LE_UINT16(textDataPtr + 2);
+
+ textDataPtr += offset;
//bit pointer: 0->8, 1->6, 2->4 ...
- numBits &= 3;
- numBits ^= 3;
- numBits++;
- numBits <<= 1;
+ bitPos ^= 3;
+ bitPos++;
+ bitPos <<= 1;
- _inputValue = *_textItemPtr++;
char *dest = (char *)_textBuffer;
char textChar;
- _shiftBits = (uint8) numBits;
do {
- textChar = getTextChar();
+ textChar = getTextChar(&textDataPtr, &bitPos);
*dest++ = textChar;
} while (textChar);
}
@@ -384,12 +375,16 @@
Logic::_scriptVariables[CURSOR_ID] = text.compactNum;
if (Logic::_scriptVariables[MENU]) {
_mouseOfsY = TOP_LEFT_Y - 2;
- if (mouseX < 150) _mouseOfsX = TOP_LEFT_X + 24;
- else _mouseOfsX = TOP_LEFT_X - 8 - _lowTextWidth;
+ if (mouseX < 150)
+ _mouseOfsX = TOP_LEFT_X + 24;
+ else
+ _mouseOfsX = TOP_LEFT_X - 8 - text.textWidth;
} else {
_mouseOfsY = TOP_LEFT_Y - 10;
- if (mouseX < 150) _mouseOfsX = TOP_LEFT_X + 13;
- else _mouseOfsX = TOP_LEFT_X - 8 - _lowTextWidth;
+ if (mouseX < 150)
+ _mouseOfsX = TOP_LEFT_X + 13;
+ else
+ _mouseOfsX = TOP_LEFT_X - 8 - text.textWidth;
}
Compact *textCompact = _skyCompact->fetchCpt(text.compactNum);
logicCursor(textCompact, mouseX, mouseY);
@@ -399,46 +394,50 @@
textCompact->xcood = (uint16)(mouseX + _mouseOfsX);
textCompact->ycood = (uint16)(mouseY + _mouseOfsY);
- if (textCompact->ycood < TOP_LEFT_Y) textCompact->ycood = TOP_LEFT_Y;
+ if (textCompact->ycood < TOP_LEFT_Y)
+ textCompact->ycood = TOP_LEFT_Y;
}
-bool Text::getTBit() {
+bool Text::getTextBit(uint8 **data, uint32 *bitPos) {
- if (_shiftBits) {
- (_shiftBits)--;
+ if (*bitPos) {
+ (*bitPos)--;
} else {
- _inputValue = *_textItemPtr++;
- _shiftBits = 7;
+ (*data)++;
+ *bitPos = 7;
}
- return (bool)(((_inputValue) >> (_shiftBits)) & 1);
+ return (bool)(((**data) >> (*bitPos)) & 1);
}
-displayText_t Text::displayText(uint8 *dest, bool centre, uint16 pixelWidth, uint8 color) {
- //Render text in _textBuffer in buffer *dest
- return displayText(this->_textBuffer, dest, centre, pixelWidth, color);
+char Text::getTextChar(uint8 **data, uint32 *bitPos) {
+ int pos = 0;
+ while (1) {
+ if (getTextBit(data, bitPos))
+ pos = _huffTree[pos].rChild;
+ else
+ pos = _huffTree[pos].lChild;
+
+ if (_huffTree[pos].lChild == 0 && _huffTree[pos].rChild == 0) {
+ return _huffTree[pos].value;
+ }
+ }
+}
+
+displayText_t Text::displayText(uint32 textNum, uint8 *dest, bool centre, uint16 pixelWidth, uint8 color) {
+ //Render text into buffer *dest
+ getText(textNum);
+ return displayText(_textBuffer, dest, centre, pixelWidth, color);
}
displayText_t Text::displayText(char *textPtr, uint8 *dest, bool centre, uint16 pixelWidth, uint8 color) {
//Render text pointed to by *textPtr in buffer *dest
-
- uint8 textChar;
- char *curPos = textPtr;
- char *lastSpace = curPos;
- byte *centerTblPtr = _centreTable;
+ uint32 centerTable[10];
uint16 lineWidth = 0;
- _dtCol = color;
- _dtLineWidth = pixelWidth;
- _dtLines = 0;
- _dtLetters = 1;
- _dtData = dest;
- _dtText = textPtr;
- _dtCentre = centre;
-
- textChar = (uint8)*curPos++;
- _dtLetters++;
+ uint32 numLines = 0;
+ _numLetters = 2;
// work around bug #778105 (line width exceeded)
char *tmpPtr = strstr(textPtr, "MUND-BEATMUNG!");
@@ -452,6 +451,10 @@
if (tmpPtr)
strcpy(tmpPtr, "MANIFESTACION ARTISTICA.");
+ char *curPos = textPtr;
+ char *lastSpace = textPtr;
+ uint8 textChar = (uint8)*curPos++;
+
while (textChar >= 0x20) {
if ((_curCharSet == 1) && (textChar >= 0x80))
textChar = 0x20;
@@ -459,10 +462,10 @@
textChar -= 0x20;
if (textChar == 0) {
lastSpace = curPos; //keep track of last space
- *(uint32 *)centerTblPtr = TO_LE_32(lineWidth);
+ centerTable[numLines] = lineWidth;
}
- lineWidth += *(_characterSet+textChar); //add character width
+ lineWidth += _characterSet[textChar]; //add character width
lineWidth += (uint16)_dtCharSpacing; //include character spacing
if (pixelWidth <= lineWidth) {
@@ -472,74 +475,68 @@
*(lastSpace-1) = 10;
lineWidth = 0;
- _dtLines++;
- centerTblPtr += 4; //get next space in centering table
+ numLines++;
curPos = lastSpace; //go back for new count
}
textChar = (uint8)*curPos++;
- _dtLetters++;
+ _numLetters++;
}
- _dtLastWidth = lineWidth; //save width of last line
- *(uint32 *)centerTblPtr = TO_LE_32(lineWidth); //and update centering table
- _dtLines++;
+ uint32 dtLastWidth = lineWidth; //save width of last line
+ centerTable[numLines] = lineWidth; //and update centering table
+ numLines++;
- if (_dtLines > MAX_NO_LINES)
+ if (numLines > MAX_NO_LINES)
error("Maximum no. of lines exceeded!");
- _dtLineSize = pixelWidth * _charHeight;
- uint32 numBytes = (_dtLineSize * _dtLines) + sizeof(struct dataFileHeader) + 4;
-
- if (_dtData == NULL)
- _dtData = (byte *)malloc(numBytes);
+ uint32 dtLineSize = pixelWidth * _charHeight;
+ uint32 numBytes = (dtLineSize * numLines) + sizeof(struct dataFileHeader) + 4;
- uint8 *curDest = _dtData;
+ if (!dest)
+ dest = (uint8*)malloc(numBytes);
- uint32 bytesToClear = numBytes; //no of bytes to clear
- bytesToClear -= sizeof(struct dataFileHeader); //don't touch the header.
- memset(curDest + sizeof(struct dataFileHeader), 0, bytesToClear);
- curPos += bytesToClear;
+ // clear text sprite buffer
+ memset(dest + sizeof(struct dataFileHeader), 0, numBytes - sizeof(struct dataFileHeader));
//make the header
- ((struct dataFileHeader *)curDest)->s_width = _dtLineWidth;
- ((struct dataFileHeader *)curDest)->s_height = (uint16)(_charHeight * _dtLines);
- ((struct dataFileHeader *)curDest)->s_sp_size = (uint16)(_dtLineWidth * _charHeight * _dtLines);
- ((struct dataFileHeader *)curDest)->s_offset_x = 0;
- ((struct dataFileHeader *)curDest)->s_offset_y = 0;
+ ((struct dataFileHeader *)dest)->s_width = pixelWidth;
+ ((struct dataFileHeader *)dest)->s_height = (uint16)(_charHeight * numLines);
+ ((struct dataFileHeader *)dest)->s_sp_size = (uint16)(pixelWidth * _charHeight * numLines);
+ ((struct dataFileHeader *)dest)->s_offset_x = 0;
+ ((struct dataFileHeader *)dest)->s_offset_y = 0;
//reset position
curPos = textPtr;
- curDest += sizeof(struct dataFileHeader); //point to where pixels start
+ uint8 *curDest = dest + sizeof(struct dataFileHeader); //point to where pixels start
byte *prevDest = curDest;
- centerTblPtr = _centreTable;
+ uint32 *centerTblPtr = centerTable;
do {
- if (_dtCentre) {
-
- uint32 width = (_dtLineWidth - READ_LE_UINT32(centerTblPtr)) >> 1;
- centerTblPtr += 4;
+ if (centre) {
+ uint32 width = (pixelWidth - *centerTblPtr) >> 1;
+ centerTblPtr++;
curDest += width;
}
textChar = (uint8)*curPos++;
while (textChar >= 0x20) {
- makeGameCharacter(textChar - 0x20, _characterSet, curDest, color);
+ makeGameCharacter(textChar - 0x20, _characterSet, curDest, color, pixelWidth);
textChar = *curPos++;
}
- prevDest = curDest = prevDest + _dtLineSize; //start of last line + start of next
+ prevDest = curDest = prevDest + dtLineSize; //start of last line + start of next
} while (textChar >= 10);
struct displayText_t ret;
- ret.textData = _dtData;
- ret.textWidth = _dtLastWidth;
+ ret.textData = dest;
+ ret.textWidth = dtLastWidth;
return ret;
}
-void Text::makeGameCharacter(uint8 textChar, uint8 *charSetPtr, uint8 *&dest, uint8 color) {
+void Text::makeGameCharacter(uint8 textChar, uint8 *charSetPtr, uint8 *&dest, uint8 color, uint16 bufPitch) {
bool maskBit, dataBit;
uint8 charWidth = (uint8)((*(charSetPtr + textChar)) + 1 - _dtCharSpacing);
@@ -571,29 +568,20 @@
curPos++;
}
-
//advance a line
- curPos = prevPos + _dtLineWidth;
+ curPos = prevPos + bufPitch;
}
-
//update position
dest = startPos + charWidth + _dtCharSpacing * 2 - 1;
-
}
lowTextManager_t Text::lowTextManager(uint32 textNum, uint16 width, uint16 logicNum, uint8 color, bool centre) {
getText(textNum);
-
- struct displayText_t textInfo = displayText(NULL, centre, width, color);
-
- _lowTextWidth = textInfo.textWidth;
- byte *textData = textInfo.textData;
+ struct displayText_t textInfo = displayText(_textBuffer, NULL, centre, width, color);
uint32 compactNum = FIRST_TEXT_COMPACT;
-
Compact *cpt = _skyCompact->fetchCpt(compactNum);
-
while (cpt->status != 0) {
compactNum++;
cpt = _skyCompact->fetchCpt(compactNum);
@@ -601,18 +589,18 @@
cpt->flag = (uint16)(compactNum - FIRST_TEXT_COMPACT) + FIRST_TEXT_BUFFER;
- byte *oldText = (byte *)SkyEngine::_itemList[cpt->flag];
- SkyEngine::_itemList[cpt->flag] = (void **)textData;
+ if (SkyEngine::_itemList[cpt->flag])
+ free(SkyEngine::_itemList[cpt->flag]);
- if (oldText != NULL)
- free (oldText);
+ SkyEngine::_itemList[cpt->flag] = textInfo.textData;
cpt->logic = logicNum;
cpt->status = ST_LOGIC | ST_FOREGROUND | ST_RECREATE;
cpt->screen = (uint16) Logic::_scriptVariables[SCREEN];
struct lowTextManager_t ret;
- ret.textData = _dtData;
+ ret.textData = textInfo.textData;
+ ret.textWidth = textInfo.textWidth;
ret.compactNum = (uint16)compactNum;
return ret;
@@ -623,7 +611,12 @@
dataFileHeader *header = (dataFileHeader *)sprData;
sprData += sizeof(dataFileHeader);
for (uint16 cnt = 0; cnt < header->s_sp_size; cnt++)
- if (sprData[cnt] >= 241) sprData[cnt] = newCol;
+ if (sprData[cnt] >= 241)
+ sprData[cnt] = newCol;
+}
+
+uint32 Text::giveCurrentCharSet(void) {
+ return _curCharSet;
}
void Text::initHuffTree() {
@@ -660,19 +653,6 @@
}
}
-char Text::getTextChar() {
- int pos = 0;
- for (;;) {
- if (getTBit() == 0)
- pos = _huffTree[pos].lChild;
- else
- pos = _huffTree[pos].rChild;
- if (_huffTree[pos].lChild == 0 && _huffTree[pos].rChild == 0) {
- return _huffTree[pos].value;
- }
- }
-}
-
bool Text::patchMessage(uint32 textNum) {
uint16 patchIdx = _patchLangIdx[SkyEngine::_systemVars.language];
Index: text.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/text.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- text.h 5 Nov 2005 18:57:41 -0000 1.39
+++ text.h 5 Dec 2005 05:02:43 -0000 1.40
@@ -48,31 +48,31 @@
public:
Text(Disk *skyDisk, SkyCompact *skyCompact);
~Text(void);
- void getText(uint32 textNr);
- struct displayText_t displayText(uint8 *dest, bool centre, uint16 pixelWidth, uint8 color);
+ struct displayText_t displayText(uint32 textNum, uint8 *dest, bool centre, uint16 pixelWidth, uint8 color);
struct displayText_t displayText(char *textPtr, uint8 *dest, bool centre, uint16 pixelWidth, uint8 color);
- void makeGameCharacter(uint8 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);
void fnPointerText(uint32 pointedId, uint16 mouseX, uint16 mouseY);
void logicCursor(Compact *textCompact, uint16 mouseX, uint16 mouseY);
void changeTextSpriteColour(uint8 *sprData, uint8 newCol);
- uint32 giveCurrentCharSet(void) { return _curCharSet; };
+ uint32 giveCurrentCharSet(void);
+
+ uint32 _numLetters; //no of chars in message
-protected:
- bool getTBit();
+private:
void initHuffTree();
- char getTextChar();
+ void getText(uint32 textNr);
+ char getTextChar(uint8 **data, uint32 *bitPos);
+ bool getTextBit(uint8 **data, uint32 *bitPos);
+ void makeGameCharacter(uint8 textChar, uint8 *charSetPtr, uint8 *&data, uint8 color, uint16 bufPitch);
+
void patchChar(byte *charSetPtr, int width, int height, int c, const uint16 *data);
void patchLINCCharset();
bool patchMessage(uint32 textNum);
Disk *_skyDisk;
SkyCompact *_skyCompact;
- uint8 _inputValue;
- uint8 _shiftBits;
- uint8 *_textItemPtr;
const HuffTree *_huffTree;
@@ -85,23 +85,14 @@
uint32 _curCharSet;
uint8 *_characterSet;
uint8 _charHeight;
- uint8 *_preAfterTableArea;
char _textBuffer[1024];
- uint8 _centreTable[40];
- uint8 *_mouseTextData; //space for the mouse text
- uint8 _dtCol;
- uint16 _dtLineWidth; //width of line in pixels
- uint32 _dtLines; //no of lines to do
- uint32 _dtLineSize; //size of one line in bytes
- uint8 *_dtData; //address of textdata
- char *_dtText; //pointer to text
uint32 _dtCharSpacing; //character separation adjustment
- uint32 _dtWidth; //width of chars in last line (for editing (?))
- uint32 _dtLastWidth;
- bool _dtCentre; //set for centre text
- uint32 _lowTextWidth, _mouseOfsX, _mouseOfsY;
+ uint32 _mouseOfsX, _mouseOfsY;
+ static const PatchMessage _patchedMessages[NUM_PATCH_MSG];
+ static const uint16 _patchLangIdx[8];
+ static const uint16 _patchLangNum[8];
#ifndef PALMOS_68K
static const HuffTree _huffTree_00109[]; // trees moved to hufftext.cpp
@@ -124,15 +115,7 @@
static const HuffTree *_huffTree_00365;
static const HuffTree *_huffTree_00368;
static const HuffTree *_huffTree_00372;
-protected:
#endif
-
- static const PatchMessage _patchedMessages[NUM_PATCH_MSG];
- static const uint16 _patchLangIdx[8];
- static const uint16 _patchLangNum[8];
-
-public:
- uint32 _dtLetters; //no of chars in message
};
} // End of namespace Sky
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sky/music adlibchannel.cpp,1.21,1.22 adlibmusic.cpp,1.27,1.28 adlibmusic.h,1.15,1.16 gmmusic.cpp,1.26,1.27 gmmusic.h,1.16,1.17 musicbase.cpp,1.26,1.27 musicbase.h,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/tools scumm-md5.txt,1.103,1.104
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list