mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 17:57:14 +00:00
HOPKINS: Move breakout highscore table to savegames, and fixes to display
This commit is contained in:
parent
bfcebeac7d
commit
dee719390c
@ -58,7 +58,7 @@ ComputerManager::ComputerManager(HopkinsEngine *vm) {
|
||||
_minBreakoutMoveSpeed = 0;
|
||||
_maxBreakoutMoveSpeed = 0;
|
||||
_lastBreakoutMoveSpeed = 0;
|
||||
_breakoutHiscore = 0;
|
||||
_lowestHiScore = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -578,27 +578,28 @@ void ComputerManager::displayGamesSubMenu() {
|
||||
* Load Highscore from file
|
||||
*/
|
||||
void ComputerManager::loadHiscore() {
|
||||
byte *ptr = _vm->_globals->allocMemory(100);
|
||||
_vm->_saveLoad->load("HISCORE.DAT", ptr);
|
||||
const byte *ptr = _vm->_globals->_highScoreData;
|
||||
|
||||
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];
|
||||
if (!nextChar)
|
||||
nextChar = ' ';
|
||||
_score[scoreIndex]._name += nextChar;
|
||||
_score[scoreIndex]._name.setChar(nextChar, i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
char nextChar = ptr[(scoreIndex * 16) + 6 + i];
|
||||
if (!nextChar)
|
||||
nextChar = '0';
|
||||
_score[scoreIndex]._score += nextChar;
|
||||
_score[scoreIndex]._score.setChar(nextChar, i);
|
||||
}
|
||||
}
|
||||
|
||||
_vm->_globals->freeMemory(ptr);
|
||||
_breakoutHiscore = atol(_score[5]._score.c_str());
|
||||
_lowestHiScore = atol(_score[5]._score.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -779,7 +780,7 @@ void ComputerManager::playBreakout() {
|
||||
_vm->_events->mouseOn();
|
||||
_vm->_objectsMan->removeSprite(0);
|
||||
_vm->_objectsMan->removeSprite(1);
|
||||
if (_breakoutScore > _breakoutHiscore)
|
||||
if (_breakoutScore > _lowestHiScore)
|
||||
getScoreName();
|
||||
if (displayHiscores() != 1)
|
||||
break;
|
||||
@ -823,11 +824,11 @@ int ComputerManager::displayHiscores() {
|
||||
yp += 46;
|
||||
|
||||
// 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]);
|
||||
|
||||
// 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]);
|
||||
}
|
||||
|
||||
@ -864,6 +865,19 @@ void ComputerManager::getScoreName() {
|
||||
_vm->_graphicsMan->setColorPercentage(254, 0, 0, 0);
|
||||
byte *ptr = _vm->_fileIO->loadFile("ALPHA.SPR");
|
||||
_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++) {
|
||||
displayHiscoreLine(ptr, 9 * strPos + 140, 78, 1);
|
||||
|
||||
@ -873,13 +887,15 @@ void ComputerManager::getScoreName() {
|
||||
if ((curChar > '9') && (curChar < 'A'))
|
||||
curChar = ' ';
|
||||
|
||||
_score[5]._name.setChar(curChar, strPos);
|
||||
_score[scoreLine]._name.setChar(curChar, strPos);
|
||||
displayHiscoreLine(ptr, 9 * strPos + 140, 78, curChar);
|
||||
|
||||
for (int idx = 0; idx < 12; ++idx)
|
||||
_vm->_events->refreshScreenAndEvents();
|
||||
}
|
||||
_score[5]._score = " ";
|
||||
|
||||
// Set up the new score
|
||||
_score[scoreLine]._score = " ";
|
||||
|
||||
char score[16];
|
||||
sprintf(score, "%d", _breakoutScore);
|
||||
@ -888,8 +904,8 @@ void ComputerManager::getScoreName() {
|
||||
++scoreLen;
|
||||
while (score[scoreLen]);
|
||||
|
||||
for (int i = scoreLen, scorePos = 8; i >= 0; i--) {
|
||||
_score[5]._score.setChar(score[i], scorePos--);
|
||||
for (int i = scoreLen - 1, scorePos = 8; i >= 0; i--) {
|
||||
_score[scoreLine]._score.setChar(score[i], scorePos--);
|
||||
}
|
||||
_vm->_graphicsMan->fadeOutBreakout();
|
||||
_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);
|
||||
for (int scorePlaceIdx = 0; scorePlaceIdx <= 5; 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];
|
||||
if (!curChar)
|
||||
curChar = ' ';
|
||||
@ -990,9 +1006,6 @@ void ComputerManager::saveScore() {
|
||||
};
|
||||
ptr[curBufPtr + 15] = 0;
|
||||
}
|
||||
|
||||
_vm->_saveLoad->saveFile("HISCORE.DAT", ptr, 100);
|
||||
_vm->_globals->freeMemory(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
bool _ballUpFl;
|
||||
int _breakoutLevelNbr;
|
||||
int _padPositionX;
|
||||
int _breakoutHiscore;
|
||||
int _lowestHiScore;
|
||||
int _minBreakoutMoveSpeed;
|
||||
int _maxBreakoutMoveSpeed;
|
||||
int _lastBreakoutMoveSpeed;
|
||||
|
@ -70,6 +70,8 @@ Globals::Globals(HopkinsEngine *vm) {
|
||||
for (int i = 0; i < 36; ++i)
|
||||
_inventory[i] = 0;
|
||||
|
||||
Common::fill(&_highScoreData[0], &_highScoreData[100], 0);
|
||||
|
||||
// Initialize fields
|
||||
_language = LANG_EN;
|
||||
|
||||
|
@ -206,6 +206,7 @@ public:
|
||||
Common::String _zoneFilename;
|
||||
Common::String _textFilename;
|
||||
byte *_levelSpriteBuf;
|
||||
byte _highScoreData[100];
|
||||
|
||||
EventMode _eventMode;
|
||||
|
||||
|
@ -111,8 +111,6 @@ Common::Error HopkinsEngine::saveGameState(int slot, const Common::String &desc)
|
||||
}
|
||||
|
||||
Common::Error HopkinsEngine::run() {
|
||||
_saveLoad->initSaves();
|
||||
|
||||
_globals->setConfig();
|
||||
_fileIO->initCensorship();
|
||||
initializeSystem();
|
||||
|
@ -60,14 +60,6 @@ bool SaveLoadManager::saveFile(const Common::String &file, const void *buf, size
|
||||
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) {
|
||||
Common::InSaveFile *savefile = g_system->getSavefileManager()->openForLoading(file);
|
||||
if (savefile == NULL)
|
||||
@ -259,6 +251,10 @@ void SaveLoadManager::createThumbnail(Graphics::Surface *s) {
|
||||
}
|
||||
|
||||
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);
|
||||
syncCharacterLocation(s, _vm->_globals->_saveData->_cloneHopkins);
|
||||
syncCharacterLocation(s, _vm->_globals->_saveData->_realHopkins);
|
||||
|
@ -35,7 +35,7 @@ namespace Hopkins {
|
||||
|
||||
class HopkinsEngine;
|
||||
|
||||
#define HOPKINS_SAVEGAME_VERSION 2
|
||||
#define HOPKINS_SAVEGAME_VERSION 3
|
||||
|
||||
struct hopkinsSavegameHeader {
|
||||
uint8 _version;
|
||||
@ -56,7 +56,6 @@ private:
|
||||
public:
|
||||
SaveLoadManager(HopkinsEngine *vm);
|
||||
|
||||
void initSaves();
|
||||
bool save(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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user