TEENAGENT: Add Resource code to precompute Dialog Offsets.
This should allow the removal of most/all of the hardcoded eseg addresses in the Dialog calls.
This commit is contained in:
parent
78312544a6
commit
c05dfddec3
2 changed files with 37 additions and 1 deletions
|
@ -57,6 +57,32 @@ quick note on varia resources:
|
|||
#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")) {
|
||||
|
@ -73,6 +99,8 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
|
|||
|
||||
delete dat;
|
||||
|
||||
precomputeDialogOffsets();
|
||||
|
||||
FilePack varia;
|
||||
varia.open("varia.res");
|
||||
font7.load(varia, 7);
|
||||
|
|
|
@ -52,8 +52,16 @@ public:
|
|||
FilePack off, on, ons, lan000, lan500, sam_mmm, sam_sam, mmm, voices;
|
||||
#endif
|
||||
|
||||
Segment cseg, dseg, eseg;
|
||||
Segment cseg, dseg;
|
||||
Font font7, font8;
|
||||
|
||||
const byte *getDialog(uint16 dialogNum) { return eseg.ptr(dialogOffsets[dialogNum]); }
|
||||
|
||||
Segment eseg;
|
||||
private:
|
||||
void precomputeDialogOffsets();
|
||||
|
||||
Common::Array<uint16> dialogOffsets;
|
||||
};
|
||||
|
||||
} // End of namespace TeenAgent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue