aboutsummaryrefslogtreecommitdiff
path: root/engines/teenagent/resources.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/teenagent/resources.cpp')
-rw-r--r--engines/teenagent/resources.cpp71
1 files changed, 48 insertions, 23 deletions
diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp
index dff58f98e2..442d0abf16 100644
--- a/engines/teenagent/resources.cpp
+++ b/engines/teenagent/resources.cpp
@@ -27,14 +27,10 @@
namespace TeenAgent {
-Resources::Resources() {}
-
-Resources *Resources::instance() {
- static Resources i;
- return &i;
+Resources::Resources() {
}
-void Resources::deinit() {
+Resources::~Resources() {
off.close();
on.close();
ons.close();
@@ -61,6 +57,36 @@ quick note on varia resources:
11: quit shareware
*/
+#define CSEG_SIZE 46000 // 0xb3b0
+#define DSEG_SIZE 59280 // 0xe790
+#define ESEG_SIZE 35810 // 0x8be2
+
+void Resources::precomputeDialogOffsets() {
+ dialogOffsets.push_back(0);
+ int n = 0;
+ uint8 current, last = 0xff;
+ for (uint i = 0; i < eseg.size(); i++) {
+ current = eseg.get_byte(i);
+
+ if (n == 4) {
+ dialogOffsets.push_back(i);
+ n = 0;
+ }
+
+ if (current != 0x00 && last == 0x00)
+ n = 0;
+
+ if (current == 0x00)
+ n++;
+
+ last = current;
+ }
+
+ debug(1, "Resources::precomputeDialogOffsets() - Found %d dialogs", dialogOffsets.size());
+ for (uint i = 0; i < dialogOffsets.size(); i++)
+ debug(1, "\tDialog #%d: Offset 0x%04x", i, dialogOffsets[i]);
+}
+
bool Resources::loadArchives(const ADGameDescription *gd) {
Common::File *dat_file = new Common::File();
if (!dat_file->open("teenagent.dat")) {
@@ -93,18 +119,17 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
}
#endif
- cseg.read(dat, 0xb3b0);
- dseg.read(dat, 0xe790);
- eseg.read(dat, 0x8be2);
+ dat->skip(CSEG_SIZE);
+ dseg.read(dat, DSEG_SIZE);
+ eseg.read(dat, ESEG_SIZE);
delete dat;
+ precomputeDialogOffsets();
+
FilePack varia;
varia.open("varia.res");
- font7.load(varia, 7);
- font7.width_pack = 1;
- font7.height = 11;
- font8.load(varia, 8);
- font8.height = 31;
+ font7.load(varia, 7, 11, 1);
+ font8.load(varia, 8, 31, 0);
varia.close();
off.open("off.res");
@@ -150,13 +175,13 @@ Common::SeekableReadStream *Resources::loadLan000(uint32 id) const {
switch (id) {
case 81:
- if (dseg.get_byte(0xDBAD))
+ if (dseg.get_byte(dsAddr_dogHasBoneFlag))
return lan500.getStream(160);
break;
case 137:
- if (dseg.get_byte(0xDBC5) == 1) {
- if (dseg.get_byte(0xDBC6) == 1)
+ if (dseg.get_byte(dsAddr_mansionTVOnFlag) == 1) {
+ if (dseg.get_byte(dsAddr_mansionVCRPlayingTapeFlag) == 1)
return lan500.getStream(203);
else
return lan500.getStream(202);
@@ -164,31 +189,31 @@ Common::SeekableReadStream *Resources::loadLan000(uint32 id) const {
break;
case 25:
- if (dseg.get_byte(0xDBDF) == 2) {
+ if (dseg.get_byte(dsAddr_FirstActTrialState) == 2) {
return lan500.getStream(332);
}
break;
case 37:
- if (dseg.get_byte(0xdbe2) == 1) {
+ if (dseg.get_byte(dsAddr_act1GuardState) == 1) {
return lan500.getStream(351);
- } else if (dseg.get_byte(0xdbe2) == 2) {
+ } else if (dseg.get_byte(dsAddr_act1GuardState) == 2) {
return lan500.getStream(364);
}
break;
case 29:
- if (dseg.get_byte(0xDBE7) == 1) {
+ if (dseg.get_byte(dsAddr_birdOnBarRadioAntennaFlag) == 1) {
return lan500.getStream(380);
}
case 30:
- if (dseg.get_byte(0xDBE7) == 1) {
+ if (dseg.get_byte(dsAddr_birdOnBarRadioAntennaFlag) == 1) {
return lan500.getStream(381);
}
case 42:
- if (dseg.get_byte(0xDBEC) == 1) {
+ if (dseg.get_byte(dsAddr_johnNotyOutsideMansionDoorFlag) == 1) {
return lan500.getStream(400);
}
}