aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins
diff options
context:
space:
mode:
authorPaul Gilbert2012-10-27 20:19:21 +1100
committerPaul Gilbert2012-10-27 20:19:21 +1100
commit1651bb07d9d3dedb643eb2ac2cb4070980f33ba5 (patch)
tree51306ffae26167ec2f4a87361e952e50fb6888da /engines/hopkins
parent9b00ee5c8c8683640e31738663224386e6e5ae78 (diff)
downloadscummvm-rg350-1651bb07d9d3dedb643eb2ac2cb4070980f33ba5.tar.gz
scummvm-rg350-1651bb07d9d3dedb643eb2ac2cb4070980f33ba5.tar.bz2
scummvm-rg350-1651bb07d9d3dedb643eb2ac2cb4070980f33ba5.zip
HOPKINS: Move Save/Load dialog code from menu.cpp to dialogs.cpp
Diffstat (limited to 'engines/hopkins')
-rw-r--r--engines/hopkins/dialogs.cpp270
-rw-r--r--engines/hopkins/dialogs.h4
-rw-r--r--engines/hopkins/events.cpp2
-rw-r--r--engines/hopkins/events.h1
-rw-r--r--engines/hopkins/menu.cpp264
-rw-r--r--engines/hopkins/menu.h4
-rw-r--r--engines/hopkins/saveload.cpp69
-rw-r--r--engines/hopkins/saveload.h17
8 files changed, 362 insertions, 269 deletions
diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp
index a77c919c8f..f979caa4b6 100644
--- a/engines/hopkins/dialogs.cpp
+++ b/engines/hopkins/dialogs.cpp
@@ -460,9 +460,10 @@ LABEL_7:
if (_vm->_eventsManager.btsouris == 1)
showOptionsDialog();
if (_vm->_eventsManager.btsouris == 3)
- _vm->_menuManager.CHARGE_PARTIE();
+ _vm->_dialogsManager.CHARGE_PARTIE();
if (_vm->_eventsManager.btsouris == 2)
- _vm->_menuManager.SAUVE_PARTIE();
+ _vm->_dialogsManager.SAUVE_PARTIE();
+
_vm->_eventsManager.btsouris = 4;
_vm->_eventsManager.CHANGE_MOUSE(4);
_vm->_objectsManager.old_cady = 0;
@@ -534,4 +535,269 @@ void DialogsManager::TEST_INVENT() {
}
}
+// Load Game
+void DialogsManager::CHARGE_PARTIE() {
+ int v1;
+ char v3;
+ byte *v4;
+ int v5;
+ Common::String s;
+ Common::String v8;
+ char v9;
+ char v10;
+ char v11;
+ Common::String v12;
+ char v13;
+ char v14;
+ char v15;
+ char v16;
+ char v17;
+ Common::File f;
+
+ _vm->_eventsManager.VBL();
+ LOAD_SAUVE(2);
+ do {
+ do {
+ v1 = CHERCHE_PARTIE();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_eventsManager.BMOUSE() != 1);
+ } while (!v1);
+ _vm->_objectsManager.SL_FLAG = 0;
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, 457, 413);
+ _vm->_objectsManager.BOBTOUS = 1;
+ _vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
+ _vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+ if (v1 != 7) {
+ s = Common::String::format("%d", v1);
+ v8 = 80;
+ v9 = 65;
+ v10 = 82;
+ v11 = 84;
+ v12 = s;
+ v13 = 46;
+ v14 = 68;
+ v15 = 65;
+ v16 = 84;
+ v17 = 0;
+ _vm->_fileManager.CONSTRUIT_LINUX(v8);
+ if (f.open(_vm->_globals.NFICHIER)) {
+ f.close();
+
+ v3 = _vm->_globals.SAUVEGARDE->data[svField10];
+ _vm->_fileManager.CONSTRUIT_LINUX(v8);
+ _vm->_fileManager.bload(_vm->_globals.NFICHIER, &_vm->_globals.SAUVEGARDE->data[0]);
+
+ v4 = &_vm->_globals.SAUVEGARDE->data[svField1300];
+ v5 = 0;
+ do {
+ _vm->_globals.INVENTAIRE[v5] = (int16)READ_LE_UINT16(v4 + 2 * v5);
+ ++v5;
+ } while (v5 <= 34);
+
+ _vm->_globals.SAUVEGARDE->data[svField10] = v3;
+ _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField5];
+ _vm->_globals.SAUVEGARDE->data[svField6] = 0;
+ _vm->_globals.ECRAN = 0;
+ }
+ }
+
+ _vm->_objectsManager.CHANGE_OBJET(14);
+}
+
+// Save Game
+void DialogsManager::SAUVE_PARTIE() {
+ byte *v1;
+ int slotNumber;
+ byte *invItemP;
+ int v4;
+ Common::String s;
+ Common::String v7;
+ char v12;
+ char v13;
+ char v14;
+ char v15;
+ char v16;
+
+ _vm->_eventsManager.VBL();
+ v1 = _vm->_globals.dos_malloc2(0x2DB4u);
+ _vm->_graphicsManager.Reduc_Ecran(_vm->_graphicsManager.VESA_BUFFER, v1, _vm->_eventsManager.start_x, 20,
+ SCREEN_WIDTH, SCREEN_HEIGHT - 40, 80);
+ _vm->_graphicsManager.INIT_TABLE(45, 80, _vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.Trans_bloc2(v1, _vm->_graphicsManager.TABLE_COUL, 11136);
+ LOAD_SAUVE(1);
+ do {
+ do {
+ slotNumber = CHERCHE_PARTIE();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_eventsManager.BMOUSE() != 1);
+ } while (!slotNumber);
+ _vm->_objectsManager.SL_FLAG = 0;
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, _vm->_eventsManager.start_x + 457, 413);
+ _vm->_objectsManager.BOBTOUS = 1;
+ _vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
+ _vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+
+ if (slotNumber != 7) {
+ // Set the selected slot number
+ _vm->_globals.SAUVEGARDE->data[svField10] = slotNumber;
+
+ // Set up the inventory
+ invItemP = &_vm->_globals.SAUVEGARDE->data[svField1300];
+ v4 = 0;
+ do {
+ WRITE_LE_UINT16(invItemP + 2 * v4, _vm->_globals.INVENTAIRE[v4]);
+ ++v4;
+ } while (v4 <= 34);
+
+ _vm->_fileManager.CONSTRUIT_LINUX(v7);
+// SAUVE_FICHIER(_vm->_globals.NFICHIER, &_vm->_globals.SAUVEGARDE->data[0], 0x7D0u);
+ v12 = 46;
+ v13 = 69;
+ v14 = 67;
+ v15 = 82;
+ v16 = 0;
+ _vm->_fileManager.CONSTRUIT_LINUX(v7);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, v1, 0x2B80u);
+ }
+ _vm->_globals.dos_free2(v1);
+}
+
+
+// Load Save
+void DialogsManager::LOAD_SAUVE(int a1) {
+ int v1;
+// byte *v2;
+// byte *v3;
+ Common::String s;
+ Common::File f;
+
+ switch (_vm->_globals.FR) {
+ case 0:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEAN.SPR");
+ break;
+ case 1:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEFR.SPR");
+ break;
+ case 2:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEES.SPR");
+ break;
+ }
+
+ _vm->_objectsManager.SL_SPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVE2.SPR");
+ _vm->_objectsManager.SL_SPR2 = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 483, 360, 0);
+
+ if (_vm->_globals.FR) {
+ if (a1 == 1)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 525, 375, 1);
+ if (a1 == 2)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 515, 375, 2);
+ } else {
+ if (a1 == 1)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 535, 372, 1);
+ if (a1 == 2)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 539, 372, 2);
+ }
+
+ v1 = 1;
+ do {
+ s = Common::String::format("ART%d.ECR", v1);
+
+ _vm->_fileManager.CONSTRUIT_LINUX(s);
+/* TODO: Get from save file manager as part of save files
+ if (f.exists(_vm->_globals.NFICHIER)) {
+ v2 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ v3 = v2;
+ if (v1 == 1)
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v2, _vm->_eventsManager.start_x + 190, 112, 0x80u, 87);
+ if (v1 == 2)
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 323, 112, 0x80u, 87);
+ if (v1 == 3)
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 190, 203, 0x80u, 87);
+ if (v1 == 4)
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 323, 203, 0x80u, 87);
+ if (v1 == 5)
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 190, 294, 0x80u, 87);
+ if (v1 == 6)
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 323, 294, 0x80u, 87);
+ _vm->_globals.dos_free2(v3);
+ }
+*/
+ ++v1;
+ } while (v1 <= 6);
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 183, 60, 0x112u, 353);
+ _vm->_objectsManager.SL_FLAG = 1;
+ _vm->_objectsManager.SL_MODE = a1;
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+}
+
+// Search Game
+int DialogsManager::CHERCHE_PARTIE() {
+ int v0;
+ int v1;
+ int v2;
+
+ v0 = 0;
+ v1 = _vm->_eventsManager.XMOUSE();
+ v2 = _vm->_eventsManager.YMOUSE();
+ _vm->_graphicsManager.ofscroll = _vm->_eventsManager.start_x;
+ if ((uint16)(v2 - 112) <= 0x56u) {
+ if (v1 > _vm->_eventsManager.start_x + 189 && v1 < _vm->_eventsManager.start_x + 318)
+ v0 = 1;
+ if ((uint16)(v2 - 112) <= 0x56u && v1 > _vm->_graphicsManager.ofscroll + 322 && v1 < _vm->_graphicsManager.ofscroll + 452)
+ v0 = 2;
+ }
+ if ((uint16)(v2 - 203) <= 0x56u) {
+ if (v1 > _vm->_graphicsManager.ofscroll + 189 && v1 < _vm->_graphicsManager.ofscroll + 318)
+ v0 = 3;
+ if ((uint16)(v2 - 203) <= 0x56u && v1 > _vm->_graphicsManager.ofscroll + 322 && v1 < _vm->_graphicsManager.ofscroll + 452)
+ v0 = 4;
+ }
+ if ((uint16)(v2 - 294) <= 0x56u) {
+ if (v1 > _vm->_graphicsManager.ofscroll + 189 && v1 < _vm->_graphicsManager.ofscroll + 318)
+ v0 = 5;
+ if ((uint16)(v2 - 294) <= 0x56u && v1 > _vm->_graphicsManager.ofscroll + 322 && v1 < _vm->_graphicsManager.ofscroll + 452)
+ v0 = 6;
+ }
+ if ((uint16)(v2 - 388) <= 0x10u && v1 > _vm->_graphicsManager.ofscroll + 273 && v1 < _vm->_graphicsManager.ofscroll + 355)
+ v0 = 7;
+ if (v0 == 1) {
+ _vm->_objectsManager.SL_X = 189;
+ _vm->_objectsManager.SL_Y = 111;
+ }
+ if (v0 == 2) {
+ _vm->_objectsManager.SL_X = 322;
+ _vm->_objectsManager.SL_Y = 111;
+ }
+ if (v0 == 3) {
+ _vm->_objectsManager.SL_X = 189;
+ _vm->_objectsManager.SL_Y = 202;
+ }
+ if (v0 == 4) {
+ _vm->_objectsManager.SL_X = 322;
+ _vm->_objectsManager.SL_Y = 202;
+ }
+ if (v0 == 5) {
+ _vm->_objectsManager.SL_X = 189;
+ _vm->_objectsManager.SL_Y = 293;
+ }
+ if (v0 == 6) {
+ _vm->_objectsManager.SL_X = 322;
+ _vm->_objectsManager.SL_Y = 293;
+ }
+ if (v0 == 7 || !v0) {
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+ }
+ return v0;
+}
+
} // End of namespace Hopkins
diff --git a/engines/hopkins/dialogs.h b/engines/hopkins/dialogs.h
index ddec3fb4a1..7e049bf717 100644
--- a/engines/hopkins/dialogs.h
+++ b/engines/hopkins/dialogs.h
@@ -56,6 +56,10 @@ public:
void INVENT_ANIM();
void TEST_INVENT();
+ void CHARGE_PARTIE();
+ void SAUVE_PARTIE();
+ void LOAD_SAUVE(int a1);
+ int CHERCHE_PARTIE();
};
} // End of namespace Hopkins
diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp
index 9bcdeda735..0eb65c8f01 100644
--- a/engines/hopkins/events.cpp
+++ b/engines/hopkins/events.cpp
@@ -41,6 +41,7 @@ EventsManager::EventsManager() {
souris_bb = 0;
souris_b = 0;
pointeur_souris = NULL;
+ _gameCounter = 0;
lItCounter = 0;
ESC_KEY = false;
KEY_INVENT = false;
@@ -204,6 +205,7 @@ void EventsManager::checkForNextFrameCounter() {
while ((milli - _priorCounterTime) >= 10) {
_priorCounterTime += 10;
lItCounter += 3;
+ ++_gameCounter;
}
// Check for next game frame
diff --git a/engines/hopkins/events.h b/engines/hopkins/events.h
index 3181b77d5f..8aa87e0cdc 100644
--- a/engines/hopkins/events.h
+++ b/engines/hopkins/events.h
@@ -54,6 +54,7 @@ public:
int souris_bb;
int souris_b;
byte *pointeur_souris;
+ uint32 _gameCounter;
uint32 lItCounter;
uint32 _priorCounterTime;
uint32 _priorFrameTime;
diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp
index 1de66a103c..cfa9ed2c0f 100644
--- a/engines/hopkins/menu.cpp
+++ b/engines/hopkins/menu.cpp
@@ -189,7 +189,7 @@ int MenuManager::MENU() {
_vm->_eventsManager.delay(200);
_vm->_globals.SORTIE = -1;
- CHARGE_PARTIE();
+ _vm->_dialogsManager.CHARGE_PARTIE();
if (_vm->_globals.SORTIE != -1) {
v6 = _vm->_globals.SORTIE;
@@ -233,138 +233,6 @@ int MenuManager::MENU() {
return v6;
}
-// Load Game
-void MenuManager::CHARGE_PARTIE() {
- int v1;
- char v3;
- byte *v4;
- int v5;
- Common::String s;
- Common::String v8;
- char v9;
- char v10;
- char v11;
- Common::String v12;
- char v13;
- char v14;
- char v15;
- char v16;
- char v17;
- Common::File f;
-
- _vm->_eventsManager.VBL();
- LOAD_SAUVE(2);
- do {
- do {
- v1 = CHERCHE_PARTIE();
- _vm->_eventsManager.VBL();
- } while (_vm->_eventsManager.BMOUSE() != 1);
- } while (!v1);
- _vm->_objectsManager.SL_FLAG = 0;
- _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
- _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, 457, 413);
- _vm->_objectsManager.BOBTOUS = 1;
- _vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
- _vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
- _vm->_objectsManager.SL_X = 0;
- _vm->_objectsManager.SL_Y = 0;
- if (v1 != 7) {
- s = Common::String::format("%d", v1);
- v8 = 80;
- v9 = 65;
- v10 = 82;
- v11 = 84;
- v12 = s;
- v13 = 46;
- v14 = 68;
- v15 = 65;
- v16 = 84;
- v17 = 0;
- _vm->_fileManager.CONSTRUIT_LINUX(v8);
- if (f.open(_vm->_globals.NFICHIER)) {
- f.close();
-
- v3 = _vm->_globals.SAUVEGARDE->data[svField10];
- _vm->_fileManager.CONSTRUIT_LINUX(v8);
- _vm->_fileManager.bload(_vm->_globals.NFICHIER, &_vm->_globals.SAUVEGARDE->data[0]);
-
- v4 = &_vm->_globals.SAUVEGARDE->data[svField1300];
- v5 = 0;
- do {
- _vm->_globals.INVENTAIRE[v5] = (int16)READ_LE_UINT16(v4 + 2 * v5);
- ++v5;
- } while (v5 <= 34);
-
- _vm->_globals.SAUVEGARDE->data[svField10] = v3;
- _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField5];
- _vm->_globals.SAUVEGARDE->data[svField6] = 0;
- _vm->_globals.ECRAN = 0;
- }
- }
-
- _vm->_objectsManager.CHANGE_OBJET(14);
-}
-
-// Save Game
-void MenuManager::SAUVE_PARTIE() {
- byte *v1;
- int v2;
- byte *v3;
- int v4;
- Common::String s;
- Common::String v7;
- char v12;
- char v13;
- char v14;
- char v15;
- char v16;
-
- _vm->_eventsManager.VBL();
- v1 = _vm->_globals.dos_malloc2(0x2DB4u);
- _vm->_graphicsManager.Reduc_Ecran(_vm->_graphicsManager.VESA_BUFFER, v1, _vm->_eventsManager.start_x, 20,
- SCREEN_WIDTH, SCREEN_HEIGHT - 40, 80);
- _vm->_graphicsManager.INIT_TABLE(45, 80, _vm->_graphicsManager.Palette);
- _vm->_graphicsManager.Trans_bloc2(v1, _vm->_graphicsManager.TABLE_COUL, 11136);
- LOAD_SAUVE(1);
- do {
- do {
- v2 = CHERCHE_PARTIE();
- _vm->_eventsManager.VBL();
- } while (_vm->_eventsManager.BMOUSE() != 1);
- } while (!v2);
- _vm->_objectsManager.SL_FLAG = 0;
- _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
- _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, _vm->_eventsManager.start_x + 457, 413);
- _vm->_objectsManager.BOBTOUS = 1;
- _vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
- _vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
- _vm->_objectsManager.SL_X = 0;
- _vm->_objectsManager.SL_Y = 0;
- if (v2 != 7) {
- s = Common::String::format("%d", v2);
- v7 = Common::String::format("PART%c.DAT", s[0]);
-
- _vm->_globals.SAUVEGARDE->data[svField10] = v2;
- v3 = &_vm->_globals.SAUVEGARDE->data[svField1300];
- v4 = 0;
- do {
- WRITE_LE_UINT16(v3 + 2 * v4, _vm->_globals.INVENTAIRE[v4]);
- ++v4;
- } while (v4 <= 34);
-
- _vm->_fileManager.CONSTRUIT_LINUX(v7);
- _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, &_vm->_globals.SAUVEGARDE->data[0], 0x7D0u);
- v12 = 46;
- v13 = 69;
- v14 = 67;
- v15 = 82;
- v16 = 0;
- _vm->_fileManager.CONSTRUIT_LINUX(v7);
- _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, v1, 0x2B80u);
- }
- _vm->_globals.dos_free2(v1);
-}
-
void MenuManager::COMPUT_HOPKINS(int idx) {
// This is a text mode display?
warning("TODO: COMPUT_HOPKINS");
@@ -562,135 +430,5 @@ void MenuManager::COMPUT_HOPKINS(int idx) {
*/
}
-// Load Save
-void MenuManager::LOAD_SAUVE(int a1) {
- int v1;
-// byte *v2;
-// byte *v3;
- Common::String s;
- Common::File f;
-
- switch (_vm->_globals.FR) {
- case 0:
- _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEAN.SPR");
- break;
- case 1:
- _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEFR.SPR");
- break;
- case 2:
- _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEES.SPR");
- break;
- }
-
- _vm->_objectsManager.SL_SPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
- _vm->_fileManager.CONSTRUIT_SYSTEM("SAVE2.SPR");
- _vm->_objectsManager.SL_SPR2 = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
- _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 483, 360, 0);
-
- if (_vm->_globals.FR) {
- if (a1 == 1)
- _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 525, 375, 1);
- if (a1 == 2)
- _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 515, 375, 2);
- } else {
- if (a1 == 1)
- _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 535, 372, 1);
- if (a1 == 2)
- _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 539, 372, 2);
- }
-
- v1 = 1;
- do {
- s = Common::String::format("ART%d.ECR", v1);
-
- _vm->_fileManager.CONSTRUIT_LINUX(s);
-/* TODO: Get from save file manager as part of save files
- if (f.exists(_vm->_globals.NFICHIER)) {
- v2 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
- v3 = v2;
- if (v1 == 1)
- _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v2, _vm->_eventsManager.start_x + 190, 112, 0x80u, 87);
- if (v1 == 2)
- _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 323, 112, 0x80u, 87);
- if (v1 == 3)
- _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 190, 203, 0x80u, 87);
- if (v1 == 4)
- _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 323, 203, 0x80u, 87);
- if (v1 == 5)
- _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 190, 294, 0x80u, 87);
- if (v1 == 6)
- _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v3, _vm->_eventsManager.start_x + 323, 294, 0x80u, 87);
- _vm->_globals.dos_free2(v3);
- }
-*/
- ++v1;
- } while (v1 <= 6);
- _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 183, 60, 0x112u, 353);
- _vm->_objectsManager.SL_FLAG = 1;
- _vm->_objectsManager.SL_MODE = a1;
- _vm->_objectsManager.SL_X = 0;
- _vm->_objectsManager.SL_Y = 0;
-}
-
-// Search Game
-int MenuManager::CHERCHE_PARTIE() {
- int v0;
- int v1;
- int v2;
-
- v0 = 0;
- v1 = _vm->_eventsManager.XMOUSE();
- v2 = _vm->_eventsManager.YMOUSE();
- _vm->_graphicsManager.ofscroll = _vm->_eventsManager.start_x;
- if ((uint16)(v2 - 112) <= 0x56u) {
- if (v1 > _vm->_eventsManager.start_x + 189 && v1 < _vm->_eventsManager.start_x + 318)
- v0 = 1;
- if ((uint16)(v2 - 112) <= 0x56u && v1 > _vm->_graphicsManager.ofscroll + 322 && v1 < _vm->_graphicsManager.ofscroll + 452)
- v0 = 2;
- }
- if ((uint16)(v2 - 203) <= 0x56u) {
- if (v1 > _vm->_graphicsManager.ofscroll + 189 && v1 < _vm->_graphicsManager.ofscroll + 318)
- v0 = 3;
- if ((uint16)(v2 - 203) <= 0x56u && v1 > _vm->_graphicsManager.ofscroll + 322 && v1 < _vm->_graphicsManager.ofscroll + 452)
- v0 = 4;
- }
- if ((uint16)(v2 - 294) <= 0x56u) {
- if (v1 > _vm->_graphicsManager.ofscroll + 189 && v1 < _vm->_graphicsManager.ofscroll + 318)
- v0 = 5;
- if ((uint16)(v2 - 294) <= 0x56u && v1 > _vm->_graphicsManager.ofscroll + 322 && v1 < _vm->_graphicsManager.ofscroll + 452)
- v0 = 6;
- }
- if ((uint16)(v2 - 388) <= 0x10u && v1 > _vm->_graphicsManager.ofscroll + 273 && v1 < _vm->_graphicsManager.ofscroll + 355)
- v0 = 7;
- if (v0 == 1) {
- _vm->_objectsManager.SL_X = 189;
- _vm->_objectsManager.SL_Y = 111;
- }
- if (v0 == 2) {
- _vm->_objectsManager.SL_X = 322;
- _vm->_objectsManager.SL_Y = 111;
- }
- if (v0 == 3) {
- _vm->_objectsManager.SL_X = 189;
- _vm->_objectsManager.SL_Y = 202;
- }
- if (v0 == 4) {
- _vm->_objectsManager.SL_X = 322;
- _vm->_objectsManager.SL_Y = 202;
- }
- if (v0 == 5) {
- _vm->_objectsManager.SL_X = 189;
- _vm->_objectsManager.SL_Y = 293;
- }
- if (v0 == 6) {
- _vm->_objectsManager.SL_X = 322;
- _vm->_objectsManager.SL_Y = 293;
- }
- if (v0 == 7 || !v0) {
- _vm->_objectsManager.SL_X = 0;
- _vm->_objectsManager.SL_Y = 0;
- }
- return v0;
-}
} // End of namespace Hopkins
diff --git a/engines/hopkins/menu.h b/engines/hopkins/menu.h
index 8b2812b476..58788fca46 100644
--- a/engines/hopkins/menu.h
+++ b/engines/hopkins/menu.h
@@ -40,11 +40,7 @@ public:
void setParent(HopkinsEngine *vm);
int MENU();
- void CHARGE_PARTIE();
- void SAUVE_PARTIE();
void COMPUT_HOPKINS(int a1);
- void LOAD_SAUVE(int a1);
- int CHERCHE_PARTIE();
};
} // End of namespace Hopkins
diff --git a/engines/hopkins/saveload.cpp b/engines/hopkins/saveload.cpp
index 1c29eca36f..364a02ae67 100644
--- a/engines/hopkins/saveload.cpp
+++ b/engines/hopkins/saveload.cpp
@@ -22,12 +22,20 @@
#include "common/system.h"
#include "common/savefile.h"
+#include "graphics/surface.h"
+#include "graphics/scaler.h"
+#include "graphics/thumbnail.h"
#include "hopkins/saveload.h"
#include "hopkins/files.h"
#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
namespace Hopkins {
+const char *SAVEGAME_STR = "HOPKINS";
+#define SAVEGAME_STR_SIZE 13
+
void SaveLoadManager::setParent(HopkinsEngine *vm) {
_vm = vm;
}
@@ -68,4 +76,65 @@ void SaveLoadManager::bload(const Common::String &file, byte *buf) {
delete f;
}
+bool SaveLoadManager::readSavegameHeader(Common::InSaveFile *in, hopkinsSavegameHeader &header) {
+ char saveIdentBuffer[SAVEGAME_STR_SIZE + 1];
+ header.thumbnail = NULL;
+
+ // Validate the header Id
+ in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1);
+ if (strncmp(saveIdentBuffer, SAVEGAME_STR, SAVEGAME_STR_SIZE))
+ return false;
+
+ header.version = in->readByte();
+ if (header.version > HOPKINS_SAVEGAME_VERSION)
+ return false;
+
+ // Read in the string
+ header.saveName.clear();
+ char ch;
+ while ((ch = (char)in->readByte()) != '\0') header.saveName += ch;
+
+ // Get the thumbnail
+ header.thumbnail = Graphics::loadThumbnail(*in);
+ if (!header.thumbnail)
+ return false;
+
+ // Read in save date/time
+ header.saveYear = in->readSint16LE();
+ header.saveMonth = in->readSint16LE();
+ header.saveDay = in->readSint16LE();
+ header.saveHour = in->readSint16LE();
+ header.saveMinutes = in->readSint16LE();
+ header.totalFrames = in->readUint32LE();
+
+ return true;
+}
+
+void SaveLoadManager::writeSavegameHeader(Common::OutSaveFile *out, hopkinsSavegameHeader &header) {
+ // Write out a savegame header
+ out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1);
+
+ out->writeByte(HOPKINS_SAVEGAME_VERSION);
+
+ // Write savegame name
+ out->write(header.saveName.c_str(), header.saveName.size() + 1);
+
+ // Create a thumbnail and save it
+ Graphics::Surface *thumb = new Graphics::Surface();
+// ::createThumbnail(thumb, _vm->_graphicsManager.VESA_SCREEN, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
+ Graphics::saveThumbnail(*out, *thumb);
+ thumb->free();
+ delete thumb;
+
+ // Write out the save date/time
+ TimeDate td;
+ g_system->getTimeAndDate(td);
+ out->writeSint16LE(td.tm_year + 1900);
+ out->writeSint16LE(td.tm_mon + 1);
+ out->writeSint16LE(td.tm_mday);
+ out->writeSint16LE(td.tm_hour);
+ out->writeSint16LE(td.tm_min);
+ out->writeUint32LE(_vm->_eventsManager._gameCounter);
+}
+
} // End of namespace Hopkins
diff --git a/engines/hopkins/saveload.h b/engines/hopkins/saveload.h
index 4777f33148..a1aa71532a 100644
--- a/engines/hopkins/saveload.h
+++ b/engines/hopkins/saveload.h
@@ -24,12 +24,24 @@
#define HOPKINS_SAVELOAD_H
#include "common/scummsys.h"
+#include "common/savefile.h"
#include "common/str.h"
namespace Hopkins {
class HopkinsEngine;
+#define HOPKINS_SAVEGAME_VERSION 1
+
+struct hopkinsSavegameHeader {
+ uint8 version;
+ Common::String saveName;
+ Graphics::Surface *thumbnail;
+ int saveYear, saveMonth, saveDay;
+ int saveHour, saveMinutes;
+ int totalFrames;
+};
+
class SaveLoadManager {
private:
HopkinsEngine *_vm;
@@ -40,6 +52,11 @@ public:
bool bsave(const Common::String &file, const void *buf, size_t n);
bool SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n);
void bload(const Common::String &file, byte *buf);
+
+ static bool readSavegameHeader(Common::InSaveFile *in, hopkinsSavegameHeader &header);
+ void writeSavegameHeader(Common::OutSaveFile *out, hopkinsSavegameHeader &header);
+ Common::Error save(int slot, const Common::String &saveName);
+ Common::Error restore(int slot);
};
} // End of namespace Hopkins