Add code for save game interface in FF

svn-id: r21843
This commit is contained in:
Travis Howell 2006-04-13 14:26:46 +00:00
parent e9034e274f
commit 89c89c0209
7 changed files with 183 additions and 81 deletions

View file

@ -283,6 +283,10 @@ static const byte feebleFontSize[208] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
}; };
uint SimonEngine::getFeebleFontSize(byte chr) {
return feebleFontSize[chr - 32];
}
void SimonEngine::showMessageFormat(const char *s, ...) { void SimonEngine::showMessageFormat(const char *s, ...) {
char buf[STRINGBUFLEN]; char buf[STRINGBUFLEN];
char *str; char *str;
@ -382,7 +386,7 @@ void SimonEngine::showmessage_helper_3(uint a, uint b) {
_newLines = 0; _newLines = 0;
} }
void SimonEngine::videoPutchar(WindowBlock *window, byte c, byte b) { void SimonEngine::windowPutChar(WindowBlock *window, byte c, byte b) {
byte width = 6; byte width = 6;
if (c == 12) { if (c == 12) {

View file

@ -321,6 +321,7 @@ void SimonEngine::setupOpcodes() {
opcode_table[124] = &SimonEngine::o3_ifTime; opcode_table[124] = &SimonEngine::o3_ifTime;
opcode_table[127] = &SimonEngine::o3_playTune; opcode_table[127] = &SimonEngine::o3_playTune;
opcode_table[131] = &SimonEngine::o3_setTime; opcode_table[131] = &SimonEngine::o3_setTime;
opcode_table[132] = &SimonEngine::o3_saveUserGame,
opcode_table[133] = &SimonEngine::o3_loadUserGame; opcode_table[133] = &SimonEngine::o3_loadUserGame;
opcode_table[134] = &SimonEngine::o3_listSaveGames; opcode_table[134] = &SimonEngine::o3_listSaveGames;
opcode_table[135] = &SimonEngine::o3_checkCD; opcode_table[135] = &SimonEngine::o3_checkCD;
@ -1823,6 +1824,12 @@ void SimonEngine::o3_setTime() {
_timeStore -= _gameStoppedClock; _timeStore -= _gameStoppedClock;
} }
void SimonEngine::o3_saveUserGame() {
// 132: save game
_noOracleScroll = 0;
saveUserGame(countSaveGames() + 1 - readVariable(55));
}
void SimonEngine::o3_loadUserGame() { void SimonEngine::o3_loadUserGame() {
// 133: load game // 133: load game
loadGame(readVariable(55)); loadGame(readVariable(55));

View file

@ -154,73 +154,6 @@ void SimonEngine::oracleTextDown() {
} }
} }
void SimonEngine::listSaveGames(int n) {
char b[108];
Common::InSaveFile *in;
uint16 j, k, z, maxFiles;
int OK;
memset(b, 0, 108);
maxFiles = countSaveGames() - 1;
j = maxFiles - n + 1;
k = maxFiles - j + 1;
z = maxFiles;
if (getBitFlag(95)) {
j++;
z++;
}
while(1) {
OK=1;
if (getBitFlag(93) || getBitFlag(94)) {
OK = 0;
if(j > z)
break;
}
if (getBitFlag(93)) {
if (((_newLines + 1) >= _textWindow->scrollY) && ((_newLines + 1) < (_textWindow->scrollY + 3)))
OK = 1;
}
if (getBitFlag(94)) {
if ((_newLines + 1) == (_textWindow->scrollY + 7))
OK = 1;
}
if (OK == 1) {
if (j == maxFiles + 1) {
showMessageFormat("\n");
hyperLinkOn(j + 400);
setTextColor(116);
showMessageFormat(" %d. ",1);
hyperLinkOff();
setTextColor(113);
k++;
j--;
}
if (!(in = _saveFileMan->openForLoading(gen_savename(j))))
break;
in->read(b, 100);
delete in;
}
showMessageFormat("\n");
hyperLinkOn(j + 400);
setTextColor(116);
if (k < 10)
showMessageFormat(" ");
showMessageFormat("%d. ",k);
setTextColor(113);
showMessageFormat("%s ",b);
hyperLinkOff();
j--;
k++;
}
}
void SimonEngine::scrollOracleUp() { void SimonEngine::scrollOracleUp() {
byte *src, *dst; byte *src, *dst;
uint16 w, h; uint16 w, h;
@ -360,4 +293,157 @@ void SimonEngine::swapCharacterLogo() {
} }
} }
void SimonEngine::listSaveGames(int n) {
char b[108];
Common::InSaveFile *in;
uint16 j, k, z, maxFiles;
int OK;
memset(b, 0, 108);
maxFiles = countSaveGames() - 1;
j = maxFiles - n + 1;
k = maxFiles - j + 1;
z = maxFiles;
if (getBitFlag(95)) {
j++;
z++;
}
while(1) {
OK=1;
if (getBitFlag(93) || getBitFlag(94)) {
OK = 0;
if(j > z)
break;
}
if (getBitFlag(93)) {
if (((_newLines + 1) >= _textWindow->scrollY) && ((_newLines + 1) < (_textWindow->scrollY + 3)))
OK = 1;
}
if (getBitFlag(94)) {
if ((_newLines + 1) == (_textWindow->scrollY + 7))
OK = 1;
}
if (OK == 1) {
if (j == maxFiles + 1) {
showMessageFormat("\n");
hyperLinkOn(j + 400);
setTextColor(116);
showMessageFormat(" %d. ",1);
hyperLinkOff();
setTextColor(113);
k++;
j--;
}
if (!(in = _saveFileMan->openForLoading(gen_savename(j))))
break;
in->read(b, 100);
delete in;
}
showMessageFormat("\n");
hyperLinkOn(j + 400);
setTextColor(116);
if (k < 10)
showMessageFormat(" ");
showMessageFormat("%d. ",k);
setTextColor(113);
showMessageFormat("%s ",b);
hyperLinkOff();
j--;
k++;
}
}
void SimonEngine::saveUserGame(int slot) {
WindowBlock *window;
Common::InSaveFile *in;
char name[108];
int len;
memset(name, 0, 108);
window = _windowArray[3];
window->textRow = (slot + 1 - window->scrollY) * 15;
window->textColumn = 26;
if ((in = _saveFileMan->openForLoading(gen_savename(readVariable(55))))) {
in->read(name, 100);
delete in;
}
len = 0;
while (name[len]) {
byte chr = name[len - 32];
window->textColumn += getFeebleFontSize(chr);
len++;
}
windowPutChar(window, 0x7f);
for (;;) {
_keyPressed = 0;
delay(1);
if (_keyPressed == 0 || _keyPressed >= 127)
continue;
window->textColumn -= getFeebleFontSize(127);
name[len] = 0;
windowBackSpace(_windowArray[3]);
if (_keyPressed == 27) {
writeVariable(55, _keyPressed);
break;
}
if (_keyPressed == 10 || _keyPressed == 13) {
if (!saveGame(readVariable(55), name))
writeVariable(55, 0xFFFF);
else
writeVariable(55, 0);
break;
}
if (_keyPressed == 8 && len != 0) {
len--;
byte chr = name[len];
window->textColumn -= getFeebleFontSize(chr);
name[len] = 0;
windowBackSpace(_windowArray[3]);
windowPutChar(window, 0x7f);
}
if (_keyPressed >= 32 && window->textColumn + 26 <= window->width) {
name[len++] = _keyPressed;
windowPutChar(_windowArray[3], _keyPressed);
windowPutChar(window, 0x7f);
}
}
}
void SimonEngine::windowBackSpace(WindowBlock *window) {
byte *dst;
uint x, y, h, w;
_lockWord |= 0x8000;
x = window->x + window->textColumn;
y = window->y + window->textRow;
dst = getFrontBuf() + _dxSurfacePitch * y + x;
for (h = 0; h < 13; h++) {
for (w = 0; w < 8; w++) {
if (dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
dst[w] = 0;
}
dst += _screenWidth;
}
_lockWord &= ~0x8000;
}
} // End of namespace Simon } // End of namespace Simon

View file

@ -263,7 +263,7 @@ restart:;
// do_3_start // do_3_start
for (;;) { for (;;) {
videoPutchar(window, 0x7f); windowPutChar(window, 0x7f);
_saveLoadFlag = true; _saveLoadFlag = true;
@ -314,7 +314,7 @@ restart:;
} else if (i >= 32 && name_len != 17) { } else if (i >= 32 && name_len != 17) {
name[name_len++] = i; name[name_len++] = i;
videoPutchar(_windowArray[5], i); windowPutChar(_windowArray[5], i);
} }
} }
@ -410,7 +410,7 @@ void SimonEngine::unk_132_helper_3() {
void SimonEngine::clearCharacter(WindowBlock *window, int x, byte b) { void SimonEngine::clearCharacter(WindowBlock *window, int x, byte b) {
byte old_text; byte old_text;
videoPutchar(window, x, b); windowPutChar(window, x, b);
old_text = window->text_color; old_text = window->text_color;
window->text_color = window->fill_color; window->text_color = window->fill_color;
@ -423,10 +423,10 @@ void SimonEngine::clearCharacter(WindowBlock *window, int x, byte b) {
} }
videoPutchar(window, x); windowPutChar(window, x);
window->text_color = old_text; window->text_color = old_text;
videoPutchar(window, 8); windowPutChar(window, 8);
} }
void SimonEngine::fileError(WindowBlock *window, bool save_error) { void SimonEngine::fileError(WindowBlock *window, bool save_error) {
@ -441,11 +441,11 @@ void SimonEngine::fileError(WindowBlock *window, bool save_error) {
string2 = "\r File not found."; string2 = "\r File not found.";
} }
videoPutchar(window, 0xC); windowPutChar(window, 0xC);
for (; *string; string++) for (; *string; string++)
videoPutchar(window, *string); windowPutChar(window, *string);
for (; *string2; string2++) for (; *string2; string2++)
videoPutchar(window, *string2); windowPutChar(window, *string2);
window->textColumn = (window->width / 2) - 3; window->textColumn = (window->width / 2) - 3;
window->textRow = window->height - 1; window->textRow = window->height - 1;
@ -453,7 +453,7 @@ void SimonEngine::fileError(WindowBlock *window, bool save_error) {
string = "[ OK ]"; string = "[ OK ]";
for (; *string; string++) for (; *string; string++)
videoPutchar(window, *string); windowPutChar(window, *string);
ha = findEmptyHitArea(); ha = findEmptyHitArea();
ha->x = ((window->width >> 1) + (window->x - 3)) * 8; ha->x = ((window->width >> 1) + (window->x - 3)) * 8;

View file

@ -2886,7 +2886,7 @@ void SimonEngine::delete_hitarea_by_index(uint index) {
void SimonEngine::windowPutChar(uint a) { void SimonEngine::windowPutChar(uint a) {
if (_textWindow != _windowArray[0]) if (_textWindow != _windowArray[0])
videoPutchar(_textWindow, a); windowPutChar(_textWindow, a);
} }
void SimonEngine::clearWindow(WindowBlock *window) { void SimonEngine::clearWindow(WindowBlock *window) {

View file

@ -592,9 +592,11 @@ protected:
void hyperLinkOff(); void hyperLinkOff();
void linksUp(); void linksUp();
void linksDown(); void linksDown();
void listSaveGames(int n);
void oracleTextUp(); void oracleTextUp();
void oracleTextDown(); void oracleTextDown();
void listSaveGames(int n);
void saveUserGame(int slot);
void windowBackSpace(WindowBlock *window);
void bltOracleText(); void bltOracleText();
void oracleLogo(); void oracleLogo();
@ -636,7 +638,7 @@ protected:
HitArea *findHitAreaByID(uint hitarea_id); HitArea *findHitAreaByID(uint hitarea_id);
void showActionString(const byte *string); void showActionString(const byte *string);
void videoPutchar(WindowBlock *window, byte c, byte b = 0); void windowPutChar(WindowBlock *window, byte c, byte b = 0);
void clearWindow(WindowBlock *window); void clearWindow(WindowBlock *window);
void video_toggle_colors(HitArea * ha, byte a, byte b, byte c, byte d); void video_toggle_colors(HitArea * ha, byte a, byte b, byte c, byte d);
@ -671,6 +673,8 @@ protected:
void hitarea_stuff_helper(); void hitarea_stuff_helper();
void permitInput(); void permitInput();
uint getFeebleFontSize(byte chr);
void showmessage_helper_3(uint a, uint b); void showmessage_helper_3(uint a, uint b);
void showmessage_print_char(byte chr); void showmessage_print_char(byte chr);
@ -958,6 +962,7 @@ public:
void o3_ifTime(); void o3_ifTime();
void o3_playTune(); void o3_playTune();
void o3_setTime(); void o3_setTime();
void o3_saveUserGame();
void o3_loadUserGame(); void o3_loadUserGame();
void o3_listSaveGames(); void o3_listSaveGames();
void o3_checkCD(); void o3_checkCD();

View file

@ -301,7 +301,7 @@ void SimonEngine::showActionString(const byte *string) {
window->textColumnOffset = x & 7; window->textColumnOffset = x & 7;
for (; *string; string++) for (; *string; string++)
videoPutchar(window, *string); windowPutChar(window, *string);
} }
void SimonEngine::resetNameWindow() { void SimonEngine::resetNameWindow() {