HOPKINS: Move breakout highscore table to savegames, and fixes to display
This commit is contained in:
parent
bfcebeac7d
commit
dee719390c
7 changed files with 42 additions and 33 deletions
|
@ -58,7 +58,7 @@ ComputerManager::ComputerManager(HopkinsEngine *vm) {
|
||||||
_minBreakoutMoveSpeed = 0;
|
_minBreakoutMoveSpeed = 0;
|
||||||
_maxBreakoutMoveSpeed = 0;
|
_maxBreakoutMoveSpeed = 0;
|
||||||
_lastBreakoutMoveSpeed = 0;
|
_lastBreakoutMoveSpeed = 0;
|
||||||
_breakoutHiscore = 0;
|
_lowestHiScore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -578,27 +578,28 @@ void ComputerManager::displayGamesSubMenu() {
|
||||||
* Load Highscore from file
|
* Load Highscore from file
|
||||||
*/
|
*/
|
||||||
void ComputerManager::loadHiscore() {
|
void ComputerManager::loadHiscore() {
|
||||||
byte *ptr = _vm->_globals->allocMemory(100);
|
const byte *ptr = _vm->_globals->_highScoreData;
|
||||||
_vm->_saveLoad->load("HISCORE.DAT", ptr);
|
|
||||||
|
|
||||||
for (int scoreIndex = 0; scoreIndex < 6; ++scoreIndex) {
|
for (int scoreIndex = 0; scoreIndex < 6; ++scoreIndex) {
|
||||||
for (int i = 0; i < 5; ++i) {
|
_score[scoreIndex]._name = " ";
|
||||||
|
_score[scoreIndex]._score = " ";
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
char nextChar = ptr[(16 * scoreIndex) + i];
|
char nextChar = ptr[(16 * scoreIndex) + i];
|
||||||
if (!nextChar)
|
if (!nextChar)
|
||||||
nextChar = ' ';
|
nextChar = ' ';
|
||||||
_score[scoreIndex]._name += nextChar;
|
_score[scoreIndex]._name.setChar(nextChar, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
char nextChar = ptr[(scoreIndex * 16) + 6 + i];
|
char nextChar = ptr[(scoreIndex * 16) + 6 + i];
|
||||||
if (!nextChar)
|
if (!nextChar)
|
||||||
nextChar = '0';
|
nextChar = '0';
|
||||||
_score[scoreIndex]._score += nextChar;
|
_score[scoreIndex]._score.setChar(nextChar, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_globals->freeMemory(ptr);
|
_lowestHiScore = atol(_score[5]._score.c_str());
|
||||||
_breakoutHiscore = atol(_score[5]._score.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -779,7 +780,7 @@ void ComputerManager::playBreakout() {
|
||||||
_vm->_events->mouseOn();
|
_vm->_events->mouseOn();
|
||||||
_vm->_objectsMan->removeSprite(0);
|
_vm->_objectsMan->removeSprite(0);
|
||||||
_vm->_objectsMan->removeSprite(1);
|
_vm->_objectsMan->removeSprite(1);
|
||||||
if (_breakoutScore > _breakoutHiscore)
|
if (_breakoutScore > _lowestHiScore)
|
||||||
getScoreName();
|
getScoreName();
|
||||||
if (displayHiscores() != 1)
|
if (displayHiscores() != 1)
|
||||||
break;
|
break;
|
||||||
|
@ -823,11 +824,11 @@ int ComputerManager::displayHiscores() {
|
||||||
yp += 46;
|
yp += 46;
|
||||||
|
|
||||||
// Display the characters of the name
|
// Display the characters of the name
|
||||||
for (int i = 0; i <= 5; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
displayHiscoreLine(ptr, 9 * i + 69, yp, _score[scoreIndex]._name[i]);
|
displayHiscoreLine(ptr, 9 * i + 69, yp, _score[scoreIndex]._name[i]);
|
||||||
|
|
||||||
// Display the digits of the score
|
// Display the digits of the score
|
||||||
for (int i = 0; i <= 8; i++)
|
for (int i = 0; i < 9; i++)
|
||||||
displayHiscoreLine(ptr, 9 * i + 199, yp, _score[scoreIndex]._score[i]);
|
displayHiscoreLine(ptr, 9 * i + 199, yp, _score[scoreIndex]._score[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,6 +865,19 @@ void ComputerManager::getScoreName() {
|
||||||
_vm->_graphicsMan->setColorPercentage(254, 0, 0, 0);
|
_vm->_graphicsMan->setColorPercentage(254, 0, 0, 0);
|
||||||
byte *ptr = _vm->_fileIO->loadFile("ALPHA.SPR");
|
byte *ptr = _vm->_fileIO->loadFile("ALPHA.SPR");
|
||||||
_vm->_graphicsMan->fadeInBreakout();
|
_vm->_graphicsMan->fadeInBreakout();
|
||||||
|
|
||||||
|
// Figure out the line to put the new high score on
|
||||||
|
int scoreLine = 0;
|
||||||
|
while (scoreLine < 5 && _breakoutScore < atol(_score[scoreLine]._score.c_str()))
|
||||||
|
++scoreLine;
|
||||||
|
|
||||||
|
// If it's not the lasat line, move the lines down
|
||||||
|
for (int line = 5; line > scoreLine; --line) {
|
||||||
|
_score[line]._name = _score[line - 1]._name;
|
||||||
|
_score[line]._score = _score[line - 1]._score;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the name for the new high score
|
||||||
for (int strPos = 0; strPos <= 4; strPos++) {
|
for (int strPos = 0; strPos <= 4; strPos++) {
|
||||||
displayHiscoreLine(ptr, 9 * strPos + 140, 78, 1);
|
displayHiscoreLine(ptr, 9 * strPos + 140, 78, 1);
|
||||||
|
|
||||||
|
@ -873,13 +887,15 @@ void ComputerManager::getScoreName() {
|
||||||
if ((curChar > '9') && (curChar < 'A'))
|
if ((curChar > '9') && (curChar < 'A'))
|
||||||
curChar = ' ';
|
curChar = ' ';
|
||||||
|
|
||||||
_score[5]._name.setChar(curChar, strPos);
|
_score[scoreLine]._name.setChar(curChar, strPos);
|
||||||
displayHiscoreLine(ptr, 9 * strPos + 140, 78, curChar);
|
displayHiscoreLine(ptr, 9 * strPos + 140, 78, curChar);
|
||||||
|
|
||||||
for (int idx = 0; idx < 12; ++idx)
|
for (int idx = 0; idx < 12; ++idx)
|
||||||
_vm->_events->refreshScreenAndEvents();
|
_vm->_events->refreshScreenAndEvents();
|
||||||
}
|
}
|
||||||
_score[5]._score = " ";
|
|
||||||
|
// Set up the new score
|
||||||
|
_score[scoreLine]._score = " ";
|
||||||
|
|
||||||
char score[16];
|
char score[16];
|
||||||
sprintf(score, "%d", _breakoutScore);
|
sprintf(score, "%d", _breakoutScore);
|
||||||
|
@ -888,8 +904,8 @@ void ComputerManager::getScoreName() {
|
||||||
++scoreLen;
|
++scoreLen;
|
||||||
while (score[scoreLen]);
|
while (score[scoreLen]);
|
||||||
|
|
||||||
for (int i = scoreLen, scorePos = 8; i >= 0; i--) {
|
for (int i = scoreLen - 1, scorePos = 8; i >= 0; i--) {
|
||||||
_score[5]._score.setChar(score[i], scorePos--);
|
_score[scoreLine]._score.setChar(score[i], scorePos--);
|
||||||
}
|
}
|
||||||
_vm->_graphicsMan->fadeOutBreakout();
|
_vm->_graphicsMan->fadeOutBreakout();
|
||||||
_vm->_globals->freeMemory(ptr);
|
_vm->_globals->freeMemory(ptr);
|
||||||
|
@ -969,11 +985,11 @@ void ComputerManager::saveScore() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byte *ptr = _vm->_globals->allocMemory(100);
|
byte *ptr = _vm->_globals->_highScoreData;
|
||||||
memset(ptr, 0, 99);
|
memset(ptr, 0, 99);
|
||||||
for (int scorePlaceIdx = 0; scorePlaceIdx <= 5; scorePlaceIdx++) {
|
for (int scorePlaceIdx = 0; scorePlaceIdx <= 5; scorePlaceIdx++) {
|
||||||
int curBufPtr = 16 * scorePlaceIdx;
|
int curBufPtr = 16 * scorePlaceIdx;
|
||||||
for (int namePos = 0; namePos <= 4; namePos++) {
|
for (int namePos = 0; namePos < 6; namePos++) {
|
||||||
char curChar = _score[scorePlace[scorePlaceIdx]]._name[namePos];
|
char curChar = _score[scorePlace[scorePlaceIdx]]._name[namePos];
|
||||||
if (!curChar)
|
if (!curChar)
|
||||||
curChar = ' ';
|
curChar = ' ';
|
||||||
|
@ -990,9 +1006,6 @@ void ComputerManager::saveScore() {
|
||||||
};
|
};
|
||||||
ptr[curBufPtr + 15] = 0;
|
ptr[curBufPtr + 15] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_saveLoad->saveFile("HISCORE.DAT", ptr, 100);
|
|
||||||
_vm->_globals->freeMemory(ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
bool _ballUpFl;
|
bool _ballUpFl;
|
||||||
int _breakoutLevelNbr;
|
int _breakoutLevelNbr;
|
||||||
int _padPositionX;
|
int _padPositionX;
|
||||||
int _breakoutHiscore;
|
int _lowestHiScore;
|
||||||
int _minBreakoutMoveSpeed;
|
int _minBreakoutMoveSpeed;
|
||||||
int _maxBreakoutMoveSpeed;
|
int _maxBreakoutMoveSpeed;
|
||||||
int _lastBreakoutMoveSpeed;
|
int _lastBreakoutMoveSpeed;
|
||||||
|
|
|
@ -70,6 +70,8 @@ Globals::Globals(HopkinsEngine *vm) {
|
||||||
for (int i = 0; i < 36; ++i)
|
for (int i = 0; i < 36; ++i)
|
||||||
_inventory[i] = 0;
|
_inventory[i] = 0;
|
||||||
|
|
||||||
|
Common::fill(&_highScoreData[0], &_highScoreData[100], 0);
|
||||||
|
|
||||||
// Initialize fields
|
// Initialize fields
|
||||||
_language = LANG_EN;
|
_language = LANG_EN;
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,7 @@ public:
|
||||||
Common::String _zoneFilename;
|
Common::String _zoneFilename;
|
||||||
Common::String _textFilename;
|
Common::String _textFilename;
|
||||||
byte *_levelSpriteBuf;
|
byte *_levelSpriteBuf;
|
||||||
|
byte _highScoreData[100];
|
||||||
|
|
||||||
EventMode _eventMode;
|
EventMode _eventMode;
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,6 @@ Common::Error HopkinsEngine::saveGameState(int slot, const Common::String &desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error HopkinsEngine::run() {
|
Common::Error HopkinsEngine::run() {
|
||||||
_saveLoad->initSaves();
|
|
||||||
|
|
||||||
_globals->setConfig();
|
_globals->setConfig();
|
||||||
_fileIO->initCensorship();
|
_fileIO->initCensorship();
|
||||||
initializeSystem();
|
initializeSystem();
|
||||||
|
|
|
@ -60,14 +60,6 @@ bool SaveLoadManager::saveFile(const Common::String &file, const void *buf, size
|
||||||
return save(file, buf, n);
|
return save(file, buf, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveLoadManager::initSaves() {
|
|
||||||
Common::String dataFilename = "HISCORE.DAT";
|
|
||||||
byte data[100];
|
|
||||||
Common::fill(&data[0], &data[100], 0);
|
|
||||||
|
|
||||||
saveFile(dataFilename, data, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveLoadManager::load(const Common::String &file, byte *buf) {
|
void SaveLoadManager::load(const Common::String &file, byte *buf) {
|
||||||
Common::InSaveFile *savefile = g_system->getSavefileManager()->openForLoading(file);
|
Common::InSaveFile *savefile = g_system->getSavefileManager()->openForLoading(file);
|
||||||
if (savefile == NULL)
|
if (savefile == NULL)
|
||||||
|
@ -259,6 +251,10 @@ void SaveLoadManager::createThumbnail(Graphics::Surface *s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveLoadManager::syncSavegameData(Common::Serializer &s, int version) {
|
void SaveLoadManager::syncSavegameData(Common::Serializer &s, int version) {
|
||||||
|
if (version >= 3)
|
||||||
|
// Sync embedded Breakout game high score data
|
||||||
|
s.syncBytes(&_vm->_globals->_highScoreData[0], 100);
|
||||||
|
|
||||||
s.syncBytes(&_vm->_globals->_saveData->_data[0], 2050);
|
s.syncBytes(&_vm->_globals->_saveData->_data[0], 2050);
|
||||||
syncCharacterLocation(s, _vm->_globals->_saveData->_cloneHopkins);
|
syncCharacterLocation(s, _vm->_globals->_saveData->_cloneHopkins);
|
||||||
syncCharacterLocation(s, _vm->_globals->_saveData->_realHopkins);
|
syncCharacterLocation(s, _vm->_globals->_saveData->_realHopkins);
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Hopkins {
|
||||||
|
|
||||||
class HopkinsEngine;
|
class HopkinsEngine;
|
||||||
|
|
||||||
#define HOPKINS_SAVEGAME_VERSION 2
|
#define HOPKINS_SAVEGAME_VERSION 3
|
||||||
|
|
||||||
struct hopkinsSavegameHeader {
|
struct hopkinsSavegameHeader {
|
||||||
uint8 _version;
|
uint8 _version;
|
||||||
|
@ -56,7 +56,6 @@ private:
|
||||||
public:
|
public:
|
||||||
SaveLoadManager(HopkinsEngine *vm);
|
SaveLoadManager(HopkinsEngine *vm);
|
||||||
|
|
||||||
void initSaves();
|
|
||||||
bool save(const Common::String &file, const void *buf, size_t n);
|
bool save(const Common::String &file, const void *buf, size_t n);
|
||||||
bool saveFile(const Common::String &file, const void *buf, size_t n);
|
bool saveFile(const Common::String &file, const void *buf, size_t n);
|
||||||
void load(const Common::String &file, byte *buf);
|
void load(const Common::String &file, byte *buf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue