aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2013-07-09 22:18:29 +0200
committeruruk2013-07-09 22:18:29 +0200
commit223c2d82e56c3fc20100090a3263627b3066d73c (patch)
treea271fc953139a82f3f3f1f9f0f2ca1da6577af3f /engines
parent2c0b69437161d03cf08f8b8da5b45af4c3e5696d (diff)
downloadscummvm-rg350-223c2d82e56c3fc20100090a3263627b3066d73c.tar.gz
scummvm-rg350-223c2d82e56c3fc20100090a3263627b3066d73c.tar.bz2
scummvm-rg350-223c2d82e56c3fc20100090a3263627b3066d73c.zip
AVALANCHE: Implement file handling in Visa.
Diffstat (limited to 'engines')
-rw-r--r--engines/avalanche/visa2.cpp101
-rw-r--r--engines/avalanche/visa2.h4
2 files changed, 98 insertions, 7 deletions
diff --git a/engines/avalanche/visa2.cpp b/engines/avalanche/visa2.cpp
index e53f55aef4..ea5144f2a9 100644
--- a/engines/avalanche/visa2.cpp
+++ b/engines/avalanche/visa2.cpp
@@ -45,8 +45,8 @@ namespace Avalanche {
_vm = vm;
}
- const bool Visa::bubbling = false;
- const bool Visa::report_dixi_errors = true;
+ bool Visa::bubbling = false;
+ bool Visa::report_dixi_errors = true;
void Visa::unskrimble() {
for (uint16 fv = 0; fv < _vm->_gyro.bufsize; fv++)
@@ -58,13 +58,104 @@ namespace Avalanche {
_vm->_gyro.buffer[_vm->_gyro.bufsize] = 2;
}
- // File handling.
void Visa::dixi(char block, byte point) {
- warning("STUB: Visa::dixi()");
+ Common::File indexfile, sezfile;
+ uint16 idx_offset, sez_offset;
+ bool error = false;
+
+ if (!indexfile.open("avalot.idx")) {
+ warning("AVALANCHE: Visa: File not found: avalot.idx");
+ return;
+ }
+
+ indexfile.seek((toupper(block) - 65) * 2);
+ idx_offset = indexfile.readUint16LE();
+ if (idx_offset == 0)
+ error = true;
+
+ indexfile.seek(idx_offset + point * 2);
+ sez_offset = indexfile.readUint16LE();
+ if (sez_offset == 0)
+ error = true;
+
+ indexfile.close();
+
+ went_ok = !error;
+
+ if (error) {
+ if (report_dixi_errors) {
+ Common::String todisplay;
+ todisplay.format("%cError accessing scroll %c%s", 7, block, _vm->_gyro.strf(point).c_str());
+ _vm->_scrolls.display(todisplay);
+ }
+ return;
+ }
+
+ if (!sezfile.open("avalot.sez")) {
+ warning("AVALANCHE: Visa: File not found: avalot.sez");
+ return;
+ }
+ sezfile.seek(sez_offset);
+ _vm->_gyro.bufsize = sezfile.readUint16LE();
+ sezfile.read(_vm->_gyro.buffer, _vm->_gyro.bufsize);
+ sezfile.close();
+ unskrimble();
+
+ if (bubbling) do_the_bubble();
+
+ _vm->_scrolls.calldrivers();
}
- // File handling.
void Visa::speech(byte who, byte subject) {
+ Common::File indexfile, sezfile;
+ uint16 idx_offset, sez_offset, next_idx_offset;
+
+ if (subject == 0) {
+ /* No subject. */
+
+ bubbling = true;
+ report_dixi_errors = false;
+ dixi('s', who);
+ bubbling = false;
+ report_dixi_errors = true;
+ } else {
+ /* Subject given. */
+
+ went_ok = false; /* Assume that until we know otherwise. */
+
+ if (!indexfile.open("converse.avd")) {
+ warning("AVALANCHE: Visa: File not found: converse.avd");
+ return;
+ }
+
+ indexfile.seek(who * 2 - 2);
+ idx_offset = indexfile.readUint16LE();
+ next_idx_offset = indexfile.readUint16LE();
+
+ if ((idx_offset == 0) || ((((next_idx_offset - idx_offset) / 2) - 1) < subject)) return;
+
+ indexfile.seek(idx_offset + subject * 2);
+ sez_offset = indexfile.readUint16LE();
+ if ((sez_offset == 0) || (indexfile.err()))
+ return;
+ indexfile.close();
+
+ if (!sezfile.open("avalot.sez")) {
+ warning("AVALANCHE: Visa: File not found: avalot.sez");
+ return;
+ }
+ sezfile.seek(sez_offset);
+ _vm->_gyro.bufsize = sezfile.readUint16LE();
+ sezfile.read(_vm->_gyro.buffer, _vm->_gyro.bufsize);
+ sezfile.close();
+
+ unskrimble();
+ do_the_bubble();
+
+ _vm->_scrolls.calldrivers();
+ went_ok = true;
+ }
+
warning("STUB: Visa::speech()");
}
diff --git a/engines/avalanche/visa2.h b/engines/avalanche/visa2.h
index 6749a1dbbd..e33045c374 100644
--- a/engines/avalanche/visa2.h
+++ b/engines/avalanche/visa2.h
@@ -46,8 +46,8 @@ public:
private:
AvalancheEngine *_vm;
- static const bool bubbling;
- static const bool report_dixi_errors;
+ static bool bubbling;
+ static bool report_dixi_errors;
bool went_ok;