aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mortevielle/alert.cpp4
-rw-r--r--engines/mortevielle/disk.cpp69
-rw-r--r--engines/mortevielle/level15.cpp31
-rw-r--r--engines/mortevielle/mor.cpp2
-rw-r--r--engines/mortevielle/mor2.cpp6
-rw-r--r--engines/mortevielle/ovd1.cpp88
-rw-r--r--engines/mortevielle/taffich.cpp35
7 files changed, 144 insertions, 91 deletions
diff --git a/engines/mortevielle/alert.cpp b/engines/mortevielle/alert.cpp
index c35ba4f62e..1a1356747a 100644
--- a/engines/mortevielle/alert.cpp
+++ b/engines/mortevielle/alert.cpp
@@ -39,7 +39,7 @@ const int nligne = 7;
const int coord[3][4] = {
{0, 0, 0, 0},
- {0, 150, 72, 103),
+ {0, 150, 72, 103},
{0, 143, 107, 183}
};
@@ -126,7 +126,7 @@ static void fait_choix(Common::String c, int &coldep, int &nbcase, Common::Strin
int do_alert(Common::String str_, int n) {
int coldep, esp, i, l, nbcase, quoi, ix;
Common::String st, chaine;
- matrix<1, 2, 1, 2, int> limit;
+ int limit[3][3];
char c, dumi;
Common::String s[3];
int cx, cy, cd, nbcol, nblig;
diff --git a/engines/mortevielle/disk.cpp b/engines/mortevielle/disk.cpp
index 89d01c59c9..daf25d21e9 100644
--- a/engines/mortevielle/disk.cpp
+++ b/engines/mortevielle/disk.cpp
@@ -25,17 +25,25 @@
* Copyright (c) 1988-1989 Lankhor
*/
+#include "common/file.h"
+#include "common/system.h"
+#include "common/savefile.h"
+#include "common/serializer.h"
#include "mortevielle/disk.h"
+#include "mortevielle/var_mor.h"
namespace Mortevielle {
+/**
+ * Ensure disk 1 data is available
+ */
void dem1() {
- untyped_file f;
int k;
- /* -- demande de disk 1 -- */
+/* Deprecated in ScummVM
+ // -- demande de disk 1 --
assign(f, "mort.005");
- /*$i-*/
+ //*$i-*
k = ioresult;
reset(f);
while (ioresult != 0) {
@@ -45,26 +53,47 @@ void dem1() {
reset(f);
}
close(f);
+ */
+}
+
+static void sync_save(Common::Serializer &sz) {
+ sz.syncAsSint16LE(s1.conf);
+ sz.syncBytes((byte *)&s1.pourc[0], 11);
+ sz.syncBytes((byte *)&s1.teauto[0], 43);
+ sz.syncBytes((byte *)&s1.sjer[0], 31);
+ sz.syncAsSint16LE(s1.mlieu);
+ sz.syncAsSint16LE(s1.iboul);
+ sz.syncAsSint16LE(s1.ibag);
+ sz.syncAsSint16LE(s1.icave);
+ sz.syncAsSint16LE(s1.ivier);
+ sz.syncAsSint16LE(s1.ipuit);
+ sz.syncAsSint16LE(s1.derobj);
+ sz.syncAsSint16LE(s1.iloic);
+ sz.syncAsSint16LE(s1.icryp);
+ sz.syncAsSint16LE(s1.ipre);
+ sz.syncAsSint16LE(s1.heure);
}
void takesav(int n) {
- untyped_file f;
int i;
Common::String st;
dem1();
- /* -- chargement du fichier 'sauve#n.mor' -- */
- st = string("sav") + chr(n + 48) + ".mor";
- assign(f, st);
- reset(f, 497);
- blockread(f, s1, 1);
- if (ioresult != 0) {
+ // -- Load the file 'sauve#n.mor'
+ Common::String saveName = Common::String::format("sav%d.mor", n);
+ Common::InSaveFile *f = g_system->getSaveManager().openForLoading(st);
+
+ Common::Serializer sz(f, NULL);
+ sync_save(sz);
+
+ if (f.err()) {
i = do_alert(err_mess, 1);
- exit(0);
+ mortevielle_exit(0);
}
s = s1;
for (i = 0; i <= 389; i ++) tabdon[i + acha] = bufcha[i];
- close(f);
+
+ delete f;
}
void ld_game(int n) {
@@ -81,7 +110,7 @@ void ld_game(int n) {
}
void sv_game(int n) {
- untyped_file f;
+ Common::OutSaveFile *f;
int i;
hide_mouse();
@@ -91,10 +120,16 @@ void sv_game(int n) {
for (i = 0; i <= 389; i ++) bufcha[i] = tabdon[i + acha];
s1 = s;
if (s1.mlieu == 26) s1.mlieu = 15;
- assign(f, string("sav") + chr(n + 48) + ".mor");
- rewrite(f, 497);
- blockwrite(f, s1, 1);
- close(f);
+
+ Common::String saveName = Common::String::format("sav%d.mor", n);
+ f = g_system->getSaveFileManager().openForSaving(saveName);
+
+ Common::Serializer sz(NULL, f);
+ sync_save(sz);
+
+ f->finalize();
+ delete f;
+
dem2();
show_mouse();
}
diff --git a/engines/mortevielle/level15.cpp b/engines/mortevielle/level15.cpp
index e7a9c2116b..b655b7a23e 100644
--- a/engines/mortevielle/level15.cpp
+++ b/engines/mortevielle/level15.cpp
@@ -25,6 +25,7 @@
* Copyright (c) 1988-1989 Lankhor
*/
+#include "common/file.h"
#include "mortevielle/level15.h"
#include "mortevielle/var_mor.h"
#include "mortevielle/mouse.h"
@@ -149,35 +150,37 @@ end;
*/
void adzon() {
- untyped_file f;
- file<byte> g;
+ Common::File f;
+// Common::File g;
byte a;
int i;
- assign(f, "don.mor");
- reset(f, 256);
- blockread(f, tabdon, 7);
- close(f);
- assign(f, "bmor.mor");
- reset(f, 1916);
- blockread(f, tabdon[fleche], 1);
+ if (!f.open("don.mor"))
+ error("Missing file - don.mor");
+ f.read(tabdon, 7);
+ f.close();
+
+ if (!f.open("bmor.mor"))
+ error("Missing file - bmor.mor");
+ f.read(&tabdon[fleche], 1);
/*i:=fleche;
repeat
read(g,a);
tabdon[i]:=a;
i:=succ(i);
until i=fleche + 1916;*/
- close(f);
- assign(f, "dec.mor");
- reset(f, 1664);
- blockread(f, mem[0x73a2 + 0], 1);
+ f.close();
+
+ if (!f.open("dec.mor"))
+ error("Missing files - dec.moir");
+ f.read(mem[0x73a2 + 0], 1);
/*i:=0;
repeat
read(g,a);
mem[$73A2:i]:=a;
i:=succ(i);
until eof(g);*/
- close(f);
+ f.close();
}
int animof(int ouf, int num) {
diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp
index b4e3fb3082..2938834f9e 100644
--- a/engines/mortevielle/mor.cpp
+++ b/engines/mortevielle/mor.cpp
@@ -29,7 +29,7 @@
#include "common/textconsole.h"
#include "mortevielle/alert.h"
#include "mortevielle/boite.h"
-#include "mortevielle/droite.h
+#include "mortevielle/droite.h"
#include "mortevielle/level15.h"
#include "mortevielle/menu.h"
#include "mortevielle/mor.h"
diff --git a/engines/mortevielle/mor2.cpp b/engines/mortevielle/mor2.cpp
index 9b9fa68768..bdf207fb5c 100644
--- a/engines/mortevielle/mor2.cpp
+++ b/engines/mortevielle/mor2.cpp
@@ -325,7 +325,11 @@ void st4(int ob) {
case 158 :
crep = 113;
break;
- case RANGE_5(152, 156):
+ case 152:
+ case 153:
+ case 154:
+ case 155:
+ case 156:
case 150:
case 100:
case 157:
diff --git a/engines/mortevielle/ovd1.cpp b/engines/mortevielle/ovd1.cpp
index 906600f44c..1a73b34267 100644
--- a/engines/mortevielle/ovd1.cpp
+++ b/engines/mortevielle/ovd1.cpp
@@ -25,19 +25,22 @@
* Copyright (c) 1988-1989 Lankhor
*/
+#include "common/file.h"
#include "mortevielle/ovd1.h"
#include "mortevielle/var_mor.h"
namespace Mortevielle {
void dem2() {
+ /* Deprecated check for disk 2
+
untyped_file f;
int k;
- /* -- demande de disk 2 -- */
+ // -- demande de disk 2 --
while (ioresult != 0);
assign(f, "mort.001");
- /*$i-*/
+ //$i-
reset(f);
while (ioresult != 0) {
show_mouse();
@@ -46,6 +49,7 @@ void dem2() {
reset(f);
}
close(f);
+ */
}
void ani50() {
@@ -81,13 +85,14 @@ void ani50() {
/* overlay */ void init_menu() {
int i, j, tai;
char st[1410];
- untyped_file f;
+ Common::File f;
+
+ if (!f.open("menufr.mor"))
+ error("Missing file - menufr.mor");
+
+ f.read(lettres, 7 * 24);
+ f.close();
- assign(f, "menufr.mor");
- /*$i-*/
- reset(f, 144);
- blockread(f, lettres, 1);
- close(f);
/* ---- Demande de changement de disquette ---- */
dem2();
@@ -171,15 +176,16 @@ void ani50() {
/* overlay */ void chartex() {
int i;
- untyped_file fibyte;
+ Common::File fibyte;
char s[1410];
/* debug('o3 chartex'); */
i = 0;
- assign(fibyte, "TXX.INP");
- /*$i-*/
- reset(fibyte);
- blockread(fibyte, t_mot, 125);
+ if (!fibyte.open("TXX.INP"))
+ error("missing file - TXX.INP");
+
+ fibyte.read(&t_mot, 125);
+
close(fibyte);
assign(sauv_t, "TXX.NTP");
reset(sauv_t);
@@ -275,7 +281,7 @@ void ani50() {
/* overlay */ void music() {
- untyped_file fic;
+ Common::File fic;
int k;
bool fin;
char ch;
@@ -285,12 +291,14 @@ void ani50() {
/* debug('o3 music'); */
if (sonoff) return;
rech_cfiec = true;
- assign(fic, "mort.img");
- /*$i-*/
- reset(fic);
- blockread(fic, mem[0x3800 + 0], 500);
- blockread(fic, mem[0x47a0 + 0], 123);
- close(fic);
+
+ if (!f.open("mort.img"))
+ error("Missing file - mort.img");
+
+ fic.read(mem[0x3800 + 0], 500);
+ fic.read(mem[0x47a0 + 0], 123);
+ f.close();
+
demus(0x3800, 0x5000, 623);
addfix = (float)((tempo_mus - addv[1])) / 256;
cctable(tbi);
@@ -308,41 +316,39 @@ void ani50() {
/* overlay */ void charge_bruit5() {
- untyped_file f;
+ Common::File f;
- assign(f, "bruit5");
- /*$i-*/
- reset(f);
- if (ioresult != 0) {
- caff = do_alert(err_mess, 1);
- exit(0);
- }
- blockread(f, mem[adbruit5 + 0], 149);
+ if (!f.open("bruit5"))
+ error("Missing file - bruit5");
+
+ f.read(mem[adbruit5 + 0], 149);
/*blockread(f,mem[$5CB0:0],100);
blockread(f,mem[$3D1F:0],49);*/
- close(f);
+ f.close();
}
/* overlay */ void charge_cfiec() {
- untyped_file f;
+ Common::File f;
+
+ if (!f.open("cfiec.mor"))
+ error("Missing file - cfiec.mor");
- assign(f, "cfiec.mor");
/*$i-*/
- reset(f);
- blockread(f, mem[adcfiec + 0], 511);
- blockread(f, mem[adcfiec + 4088 + 0], 311);
- close(f);
+ f.read(mem[adcfiec + 0], 511);
+ f.read(mem[adcfiec + 4088 + 0], 311);
+ f.close();
+
rech_cfiec = false;
}
/* overlay */ void charge_cfiph() {
- untyped_file f;
+ Common::File f;
- assign(f, "cfiph.mor");
- /*$i-*/
- reset(f, 256);
- blockread(f, t_cph, 50);
+ if (!f.open("cfiph.mor"))
+ error("Missing file - cfiph.mor");
+
+ f.read(t_cph, 50);
close(f);
}
diff --git a/engines/mortevielle/taffich.cpp b/engines/mortevielle/taffich.cpp
index 6969cf6aea..1a20a1b9f9 100644
--- a/engines/mortevielle/taffich.cpp
+++ b/engines/mortevielle/taffich.cpp
@@ -25,6 +25,7 @@
* Copyright (c) 1988-1989 Lankhor
*/
+#include "common/file.h"
#include "common/str.h"
#include "mortevielle/mouse.h"
#include "mortevielle/taffich.h"
@@ -35,29 +36,31 @@ namespace Mortevielle {
void chardes(Common::String nom, float passe, int long_) {
int i, p, l;
byte b;
- untyped_file f;
+ Common::File f;
/* debug('chardes'); */
- assign(f, nom);
- /*$i-*/
- reset(f);
+ if (!f.open(nom))
+ error("Missing file %s", nom.c_str());
+
testfi();
p = 0;
while (passe > 127) {
p = p + 1;
passe = passe - 128;
}
- if (p != 0) seek(f, p);
+ if (p != 0)
+ f.seek(p);
p = trunc(passe);
l = long_ + p;
i = 0;
while (l > 0) {
- blockread(f, mem[0x6000 + i], 1);
+ f.read(mem[0x6000 + i], 1);
testfi();
l = l - 128;
i = i + 128;
}
- close(f);
+ f.close();
+
for (i = p; i <= long_ + p; i ++) mem[0x7000 + i - p] = mem[0x6000 + i];
/*$i+*/
}
@@ -65,31 +68,33 @@ void chardes(Common::String nom, float passe, int long_) {
void charani(Common::String nom, float passe, int long_) {
int i, p, l;
byte b;
- untyped_file f;
+ Common::File f;
/* debug('charani'); */
- assign(f, nom);
- /*$i-*/
- reset(f);
+ if (!f.open(nom))
+ error("Missing file - %s", nom.c_str());
+
testfi();
p = 0;
while (passe > 127) {
passe = passe - 128;
p = p + 1;
}
- if (p != 0) seek(f, p);
+ if (p != 0)
+ f.seek(p);
+
p = trunc(passe);
l = long_ + p;
i = 0;
while (l > 0) {
- blockread(f, mem[0x6000 + i], 1);
+ f.read(mem[0x6000 + i], 1);
testfi();
l = l - 128;
i = i + 128;
}
- close(f);
+ f.close();
+
for (i = p; i <= long_ + p; i ++) mem[0x7314 + i - p] = mem[0x6000 + i];
- /*$i+*/
}
void taffich() {