2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-06-29 16:11:13 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-06-29 16:11:13 +00:00
|
|
|
*
|
2006-02-11 12:46:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-06-29 16:11:13 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
// AGOS debug functions
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-04-29 14:23:16 +00:00
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
#include "agos/debug.h"
|
|
|
|
#include "agos/agos.h"
|
|
|
|
#include "agos/intern.h"
|
|
|
|
#include "agos/vga.h"
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
namespace AGOS {
|
2003-10-03 19:42:27 +00:00
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
const byte *AGOSEngine::dumpOpcode(const byte *p) {
|
2006-09-29 05:36:53 +00:00
|
|
|
uint opcode;
|
2002-06-29 16:11:13 +00:00
|
|
|
const char *s, *st;
|
|
|
|
|
2006-10-06 05:13:09 +00:00
|
|
|
if (getGameType() == GType_ELVIRA1) {
|
2006-09-28 23:22:07 +00:00
|
|
|
opcode = READ_BE_UINT16(p);
|
|
|
|
p += 2;
|
2006-09-29 05:38:50 +00:00
|
|
|
if (opcode == 10000)
|
2006-09-28 23:22:07 +00:00
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
opcode = *p++;
|
|
|
|
if (opcode == 255)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-10-01 10:04:23 +00:00
|
|
|
if (getGameType() == GType_PP) {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = puzzlepack_opcodeNameTable[opcode];
|
2006-10-01 10:04:23 +00:00
|
|
|
} else if (getGameType() == GType_FF) {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = feeblefiles_opcodeNameTable[opcode];
|
2005-11-12 06:01:24 +00:00
|
|
|
} else if (getGameType() == GType_SIMON2 && getFeatures() & GF_TALKIE) {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = simon2talkie_opcodeNameTable[opcode];
|
2005-11-12 06:01:24 +00:00
|
|
|
} else if (getFeatures() & GF_TALKIE) {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = simon1talkie_opcodeNameTable[opcode];
|
2005-11-12 06:01:24 +00:00
|
|
|
} else if (getGameType() == GType_SIMON2) {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = simon2dos_opcodeNameTable[opcode];
|
2006-09-19 11:59:13 +00:00
|
|
|
} else if (getGameType() == GType_SIMON1) {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = simon1dos_opcodeNameTable[opcode];
|
2006-10-13 11:38:41 +00:00
|
|
|
} else if (getGameType() == GType_WW) {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = waxworks_opcodeNameTable[opcode];
|
2006-10-13 11:38:41 +00:00
|
|
|
} else if (getGameType() == GType_ELVIRA2) {
|
|
|
|
st = s = elvira2_opcodeNameTable[opcode];
|
2006-10-06 07:44:03 +00:00
|
|
|
} else {
|
2006-10-07 03:31:17 +00:00
|
|
|
st = s = elvira1_opcodeNameTable[opcode];
|
2002-11-20 05:43:43 +00:00
|
|
|
}
|
2006-10-06 08:30:07 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
if (s == NULL) {
|
2006-10-06 08:30:07 +00:00
|
|
|
error("dumpOpcode: INVALID OPCODE %d", opcode);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2006-10-06 08:30:07 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
while (*st != '|')
|
|
|
|
st++;
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("%s ", st + 1);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
|
|
|
switch (*s++) {
|
2002-06-29 16:11:13 +00:00
|
|
|
case 'x':
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("\n");
|
2002-06-29 16:11:13 +00:00
|
|
|
return NULL;
|
|
|
|
case '|':
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("\n");
|
2002-06-29 16:11:13 +00:00
|
|
|
return p;
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'B':{
|
|
|
|
byte b = *p++;
|
|
|
|
if (b == 255)
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("[%d] ", *p++);
|
2002-07-07 19:06:48 +00:00
|
|
|
else
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("%d ", b);
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'V':{
|
|
|
|
byte b = *p++;
|
|
|
|
if (b == 255)
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("[[%d]] ", *p++);
|
2002-07-07 19:06:48 +00:00
|
|
|
else
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("[%d] ", b);
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'W':{
|
2006-09-30 05:51:06 +00:00
|
|
|
int n = (int16)READ_BE_UINT16(p);
|
2002-07-07 19:06:48 +00:00
|
|
|
p += 2;
|
2006-09-30 05:51:06 +00:00
|
|
|
if (getGameType() == GType_PP) {
|
|
|
|
if (n >= 60000 && n < 62048)
|
|
|
|
printf("[%d] ", n - 60000);
|
|
|
|
else
|
|
|
|
printf("%d ", n);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-09-30 05:51:06 +00:00
|
|
|
} else {
|
|
|
|
if (n >= 30000 && n < 30512)
|
|
|
|
printf("[%d] ", n - 30000);
|
|
|
|
else
|
|
|
|
printf("%d ", n);
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'w':{
|
2006-09-30 05:51:06 +00:00
|
|
|
int n = (int16)READ_BE_UINT16(p);
|
2002-07-07 19:06:48 +00:00
|
|
|
p += 2;
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("%d ", n);
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'I':{
|
2006-09-30 05:51:06 +00:00
|
|
|
int n = (int16)READ_BE_UINT16(p);
|
2002-07-07 19:06:48 +00:00
|
|
|
p += 2;
|
|
|
|
if (n == -1)
|
2006-10-28 03:29:58 +00:00
|
|
|
printf("SUBJECT_ITEM ");
|
2002-07-07 19:06:48 +00:00
|
|
|
else if (n == -3)
|
2006-10-28 03:29:58 +00:00
|
|
|
printf("OBJECT_ITEM ");
|
2002-07-07 19:06:48 +00:00
|
|
|
else if (n == -5)
|
2006-10-28 03:29:58 +00:00
|
|
|
printf("ME_ITEM ");
|
2002-07-07 19:06:48 +00:00
|
|
|
else if (n == -7)
|
2006-10-28 03:29:58 +00:00
|
|
|
printf("ACTOR_ITEM ");
|
2002-07-07 19:06:48 +00:00
|
|
|
else if (n == -9)
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("ITEM_A_PARENT ");
|
2002-07-07 19:06:48 +00:00
|
|
|
else
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("<%d> ", n);
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-03-06 19:16:24 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'J':{
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("-> ");
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'T':{
|
2006-09-30 05:51:06 +00:00
|
|
|
uint n = READ_BE_UINT16(p);
|
2002-07-07 19:06:48 +00:00
|
|
|
p += 2;
|
|
|
|
if (n != 0xFFFF)
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("\"%s\"(%d) ", getStringPtrByID(n), n);
|
2002-07-07 19:06:48 +00:00
|
|
|
else
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("NULL_STRING ");
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::dumpSubroutineLine(SubroutineLine *sl, Subroutine *sub) {
|
2004-12-18 02:08:32 +00:00
|
|
|
const byte *p;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
printf("; ****\n");
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
p = (byte *)sl + SUBROUTINE_LINE_SMALL_SIZE;
|
2002-06-29 16:11:13 +00:00
|
|
|
if (sub->id == 0) {
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("; verb=%d, noun1=%d, noun2=%d\n", sl->verb, sl->noun1, sl->noun2);
|
2002-07-07 19:06:48 +00:00
|
|
|
p = (byte *)sl + SUBROUTINE_LINE_BIG_SIZE;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
2002-06-29 16:11:13 +00:00
|
|
|
p = dumpOpcode(p);
|
2002-07-07 19:06:48 +00:00
|
|
|
if (p == NULL)
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::dumpSubroutine(Subroutine *sub) {
|
2002-06-29 16:11:13 +00:00
|
|
|
SubroutineLine *sl;
|
|
|
|
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("\n******************************************\n;Subroutine, ID=%d:\nSUB_%d:\n", sub->id, sub->id);
|
2002-07-07 19:06:48 +00:00
|
|
|
sl = (SubroutineLine *)((byte *)sub + sub->first);
|
|
|
|
for (; (byte *)sl != (byte *)sub; sl = (SubroutineLine *)((byte *)sub + sl->next)) {
|
2002-06-29 16:11:13 +00:00
|
|
|
dumpSubroutineLine(sl, sub);
|
|
|
|
}
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("\nEND ******************************************\n");
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::dumpSubroutines() {
|
2005-05-06 11:37:33 +00:00
|
|
|
Subroutine *sub = _subroutineList;
|
2002-07-07 19:06:48 +00:00
|
|
|
for (; sub; sub = sub->next) {
|
2002-06-29 16:11:13 +00:00
|
|
|
dumpSubroutine(sub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-27 11:39:04 +00:00
|
|
|
void AGOSEngine::dumpAllSubroutines() {
|
|
|
|
for (int i = 0; i < 65536; i++) {
|
|
|
|
Subroutine *sub = getSubroutineByID(i);
|
|
|
|
if (sub != NULL) {
|
|
|
|
dumpSubroutine(sub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-06 08:30:07 +00:00
|
|
|
void AGOSEngine::dumpVideoScript(const byte *src, bool one_opcode_only) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint opcode;
|
|
|
|
const char *str, *strn;
|
|
|
|
|
|
|
|
do {
|
2006-09-30 05:51:06 +00:00
|
|
|
if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
|
|
|
|
opcode = *src++;
|
|
|
|
} else {
|
2003-06-14 18:52:30 +00:00
|
|
|
opcode = READ_BE_UINT16(src);
|
2002-07-07 19:06:48 +00:00
|
|
|
src += 2;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2006-05-04 02:23:52 +00:00
|
|
|
if (opcode >= _numVideoOpcodes) {
|
2006-10-05 16:43:11 +00:00
|
|
|
error("Invalid opcode %x", opcode);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2006-09-28 23:22:07 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP) {
|
2006-10-07 03:31:17 +00:00
|
|
|
strn = str = feeblefiles_videoOpcodeNameTable[opcode];
|
2005-11-12 06:01:24 +00:00
|
|
|
} else if (getGameType() == GType_SIMON2) {
|
2006-10-07 03:31:17 +00:00
|
|
|
strn = str = simon2_videoOpcodeNameTable[opcode];
|
2006-09-19 11:59:13 +00:00
|
|
|
} else if (getGameType() == GType_SIMON1) {
|
2006-10-07 03:31:17 +00:00
|
|
|
strn = str = simon1_videoOpcodeNameTable[opcode];
|
2006-10-06 06:12:57 +00:00
|
|
|
} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
|
2006-10-07 03:31:17 +00:00
|
|
|
strn = str = ww_videoOpcodeNameTable[opcode];
|
2006-10-06 06:12:57 +00:00
|
|
|
} else {
|
2006-10-07 03:31:17 +00:00
|
|
|
strn = str = elvira1_videoOpcodeNameTable[opcode];
|
2002-11-20 05:43:43 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-10-06 08:30:07 +00:00
|
|
|
if (strn == NULL) {
|
|
|
|
error("dumpVideoScript: INVALID OPCODE %d", opcode);
|
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
while (*strn != '|')
|
|
|
|
strn++;
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("%.2d: %s ", opcode, strn + 1);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2006-09-28 23:22:07 +00:00
|
|
|
int end = (getGameType() == GType_FF || getGameType() == GType_PP) ? 9999 : 999;
|
2002-07-07 19:06:48 +00:00
|
|
|
for (; *str != '|'; str++) {
|
|
|
|
switch (*str) {
|
|
|
|
case 'x':
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("\n");
|
2002-07-07 19:06:48 +00:00
|
|
|
return;
|
|
|
|
case 'b':
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("%d ", *src++);
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
2006-04-06 06:14:47 +00:00
|
|
|
case 'd':
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("%d ", (int16)readUint16Wrapper(src));
|
2006-04-06 06:14:47 +00:00
|
|
|
src += 2;
|
|
|
|
break;
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'v':
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("[%d] ", readUint16Wrapper(src));
|
2002-07-07 19:06:48 +00:00
|
|
|
src += 2;
|
|
|
|
break;
|
|
|
|
case 'i':
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("%d ", (int16)readUint16Wrapper(src));
|
2002-07-07 19:06:48 +00:00
|
|
|
src += 2;
|
|
|
|
break;
|
2006-11-05 06:10:41 +00:00
|
|
|
case 'j':
|
|
|
|
printf("-> ");
|
|
|
|
break;
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'q':
|
2005-10-12 00:35:54 +00:00
|
|
|
while (readUint16Wrapper(src) != end) {
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("(%d,%d) ", readUint16Wrapper(src),
|
2005-10-12 00:35:54 +00:00
|
|
|
readUint16Wrapper(src + 2));
|
|
|
|
src += 4;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2006-10-05 16:43:11 +00:00
|
|
|
src += 2;
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Invalid fmt string '%c' in decompile VGA", *str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("\n");
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (!one_opcode_only);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2006-10-28 13:31:30 +00:00
|
|
|
void AGOSEngine::dumpVgaScript(const byte *ptr, uint res, uint sprite_id) {
|
|
|
|
dumpVgaScriptAlways(ptr, res, sprite_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AGOSEngine::dumpVgaScriptAlways(const byte *ptr, uint res, uint sprite_id) {
|
|
|
|
printf("; address=%x, vgafile=%d vgasprite=%d\n",
|
|
|
|
(unsigned int)(ptr - _vgaBufferPointers[res].vgaFile1), res, sprite_id);
|
|
|
|
dumpVideoScript(ptr, false);
|
|
|
|
printf("; end\n");
|
|
|
|
}
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
void AGOSEngine::dumpVgaFile(const byte *vga) {
|
2006-05-04 12:20:49 +00:00
|
|
|
const byte *pp;
|
|
|
|
const byte *p;
|
|
|
|
int count;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2006-05-04 12:20:49 +00:00
|
|
|
pp = vga;
|
2006-10-27 11:39:04 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP) {
|
|
|
|
p = pp + READ_LE_UINT16(pp + 2);
|
|
|
|
count = READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->animationCount);
|
|
|
|
p = pp + READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->animationTable);
|
|
|
|
|
|
|
|
while (--count >= 0) {
|
|
|
|
int id = READ_LE_UINT16(&((const AnimationHeader_Feeble *) p)->id);
|
|
|
|
|
|
|
|
dumpVgaScriptAlways(vga + READ_LE_UINT16(&((const AnimationHeader_Feeble *) p)->scriptOffs), id / 100, id);
|
|
|
|
p += sizeof(AnimationHeader_Feeble);
|
|
|
|
}
|
|
|
|
} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
|
|
|
|
p = pp + READ_BE_UINT16(pp + 4);
|
|
|
|
count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationCount);
|
|
|
|
p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationTable);
|
|
|
|
|
|
|
|
while (--count >= 0) {
|
|
|
|
int id = READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->id);
|
|
|
|
|
|
|
|
dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->scriptOffs), id / 100, id);
|
|
|
|
p += sizeof(AnimationHeader_Simon);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
p = pp + READ_BE_UINT16(pp + 10) + 20;
|
|
|
|
count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationCount);
|
|
|
|
p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationTable);
|
|
|
|
|
|
|
|
while (--count >= 0) {
|
|
|
|
int id = READ_BE_UINT16(&((const AnimationHeader_WW *) p)->id);
|
|
|
|
|
|
|
|
dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const AnimationHeader_WW *) p)->scriptOffs), id / 100, id);
|
|
|
|
p += sizeof(AnimationHeader_WW);
|
|
|
|
}
|
2006-05-04 12:20:49 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2006-05-04 12:20:49 +00:00
|
|
|
pp = vga;
|
2006-10-27 11:39:04 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP) {
|
2007-02-16 17:13:29 +00:00
|
|
|
p = pp + READ_LE_UINT16(pp + 2);
|
2006-10-28 13:31:30 +00:00
|
|
|
count = READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->imageCount);
|
|
|
|
p = pp + READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->imageTable);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2006-10-27 11:39:04 +00:00
|
|
|
while (--count >= 0) {
|
2006-10-28 13:31:30 +00:00
|
|
|
int id = READ_LE_UINT16(&((const ImageHeader_Feeble *) p)->id);
|
2006-05-04 12:20:49 +00:00
|
|
|
|
2006-10-28 13:31:30 +00:00
|
|
|
dumpVgaScriptAlways(vga + READ_LE_UINT16(&((const ImageHeader_Feeble *) p)->scriptOffs), id / 100, id);
|
2006-10-27 11:39:04 +00:00
|
|
|
p += sizeof(ImageHeader_Feeble);
|
|
|
|
}
|
|
|
|
} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
|
2007-02-16 17:13:29 +00:00
|
|
|
p = pp + READ_BE_UINT16(pp + 4);
|
2006-10-27 11:39:04 +00:00
|
|
|
count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageCount);
|
|
|
|
p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageTable);
|
|
|
|
|
|
|
|
while (--count >= 0) {
|
|
|
|
int id = READ_BE_UINT16(&((const ImageHeader_Simon *) p)->id);
|
|
|
|
|
|
|
|
dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const ImageHeader_Simon *) p)->scriptOffs), id / 100, id);
|
|
|
|
p += sizeof(ImageHeader_Simon);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
p = pp + READ_BE_UINT16(pp + 10) + 20;
|
|
|
|
count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageCount);
|
|
|
|
p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageTable);
|
|
|
|
|
|
|
|
while (--count >= 0) {
|
|
|
|
int id = READ_BE_UINT16(&((const ImageHeader_WW *) p)->id);
|
|
|
|
|
|
|
|
dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const ImageHeader_WW *) p)->scriptOffs), id / 100, id);
|
|
|
|
p += sizeof(ImageHeader_WW);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-18 01:33:21 +00:00
|
|
|
static const byte bmp_hdr[] = {
|
2002-07-07 19:06:48 +00:00
|
|
|
0x42, 0x4D,
|
|
|
|
0x9E, 0x14, 0x00, 0x00, /* offset 2, file size */
|
|
|
|
0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x36, 0x04, 0x00, 0x00,
|
|
|
|
0x28, 0x00, 0x00, 0x00,
|
|
|
|
|
|
|
|
0x3C, 0x00, 0x00, 0x00, /* image width */
|
|
|
|
0x46, 0x00, 0x00, 0x00, /* image height */
|
|
|
|
0x01, 0x00, 0x08, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
|
|
|
0x00, 0x01, 0x00, 0x00,
|
|
|
|
0x00, 0x01, 0x00, 0x00,
|
2002-06-29 16:11:13 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
void dumpBMP(const char *filename, int w, int h, const byte *bytes, const uint32 *palette) {
|
2007-02-17 20:37:57 +00:00
|
|
|
Common::File out;
|
2002-06-29 16:11:13 +00:00
|
|
|
byte my_hdr[sizeof(bmp_hdr)];
|
|
|
|
int i;
|
|
|
|
|
2007-02-17 20:37:57 +00:00
|
|
|
out.open(filename, Common::File::kFileWriteMode);
|
|
|
|
if (!out.isOpen())
|
2002-06-29 16:11:13 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
memcpy(my_hdr, bmp_hdr, sizeof(bmp_hdr));
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
*(uint32 *)(my_hdr + 2) = w * h + 1024 + sizeof(bmp_hdr);
|
|
|
|
*(uint32 *)(my_hdr + 18) = w;
|
|
|
|
*(uint32 *)(my_hdr + 22) = h;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2007-02-17 20:37:57 +00:00
|
|
|
out.write(my_hdr, sizeof(my_hdr));
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
for (i = 0; i != 256; i++, palette++) {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte color[4];
|
|
|
|
color[0] = (byte)(*palette >> 16);
|
|
|
|
color[1] = (byte)(*palette >> 8);
|
|
|
|
color[2] = (byte)(*palette);
|
|
|
|
color[3] = 0;
|
2007-02-17 20:37:57 +00:00
|
|
|
out.write(color, 4);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (--h >= 0) {
|
2007-02-17 20:37:57 +00:00
|
|
|
out.write(bytes + h * ((w + 3) & ~3), ((w + 3) & ~3));
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette,
|
2006-03-27 13:32:44 +00:00
|
|
|
byte base) {
|
|
|
|
|
2006-09-30 05:51:06 +00:00
|
|
|
if (getGameType() != GType_FF && getGameType() != GType_PP)
|
2006-03-27 13:32:44 +00:00
|
|
|
w *= 16;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
/* allocate */
|
2002-07-07 19:06:48 +00:00
|
|
|
byte *b = (byte *)malloc(w * h);
|
|
|
|
int i, j;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
VC10_state state;
|
|
|
|
|
|
|
|
state.depack_cont = -0x80;
|
2007-04-15 00:55:16 +00:00
|
|
|
state.srcPtr = offs;
|
2002-06-29 16:11:13 +00:00
|
|
|
state.dh = h;
|
|
|
|
state.y_skip = 0;
|
|
|
|
|
2006-09-28 23:22:07 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP) {
|
2006-03-27 12:49:17 +00:00
|
|
|
for (i = 0; i != w; i++) {
|
2006-04-14 09:57:43 +00:00
|
|
|
byte *c = vc10_depackColumn(&state);
|
2006-03-27 12:49:17 +00:00
|
|
|
for (j = 0; j != h; j++) {
|
2006-10-27 11:39:04 +00:00
|
|
|
b[j * w + i] = c[j];
|
2006-03-27 12:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i != w; i += 2) {
|
2006-04-14 09:57:43 +00:00
|
|
|
byte *c = vc10_depackColumn(&state);
|
2006-03-27 12:49:17 +00:00
|
|
|
for (j = 0; j != h; j++) {
|
|
|
|
byte pix = c[j];
|
|
|
|
b[j * w + i] = (pix >> 4) | base;
|
|
|
|
b[j * w + i + 1] = (pix & 0xF) | base;
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
dumpBMP(filename, w, h, b, (const uint32 *)palette);
|
2002-06-29 16:11:13 +00:00
|
|
|
free(b);
|
|
|
|
}
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
void AGOSEngine::dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base) {
|
2003-12-11 09:29:56 +00:00
|
|
|
char buf[40];
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-12-11 09:14:10 +00:00
|
|
|
sprintf(buf, "dumps/File%d_Image%d.bmp", file, image);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2007-02-17 20:37:57 +00:00
|
|
|
if (Common::File::exists(buf))
|
2002-06-29 16:11:13 +00:00
|
|
|
return;
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
dumpBitmap(buf, offs, w, h, 0, _displayPalette, base);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
void palLoad(byte *pal, const byte *vga1, int a, int b) {
|
2003-11-08 20:54:31 +00:00
|
|
|
uint num = (a == 0) ? 0x20 : 0x10;
|
2002-11-20 13:08:01 +00:00
|
|
|
byte *palptr;
|
|
|
|
const byte *src;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-08 20:54:31 +00:00
|
|
|
palptr = (byte *)&pal[a << 4];
|
|
|
|
src = vga1 + 6 + b * 96;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-11-20 13:08:01 +00:00
|
|
|
do {
|
2003-11-08 20:54:31 +00:00
|
|
|
palptr[0] = src[0] << 2;
|
|
|
|
palptr[1] = src[1] << 2;
|
|
|
|
palptr[2] = src[2] << 2;
|
2002-11-20 13:08:01 +00:00
|
|
|
palptr[3] = 0;
|
|
|
|
|
|
|
|
palptr += 4;
|
|
|
|
src += 3;
|
|
|
|
} while (--num);
|
|
|
|
}
|
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
void AGOSEngine::dumpVgaBitmaps(const byte *vga, byte *vga1, int res) {
|
2002-11-20 13:08:01 +00:00
|
|
|
int i;
|
|
|
|
uint32 offs;
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *p2;
|
2002-11-20 13:08:01 +00:00
|
|
|
byte pal[768];
|
|
|
|
|
2006-05-04 12:20:49 +00:00
|
|
|
memset(pal, 0, sizeof(pal));
|
2006-10-21 01:51:59 +00:00
|
|
|
palLoad(pal, vga1, 2, 0);
|
|
|
|
palLoad(pal, vga1, 3, 1);
|
|
|
|
palLoad(pal, vga1, 4, 2);
|
|
|
|
palLoad(pal, vga1, 5, 3);
|
2002-11-20 13:08:01 +00:00
|
|
|
|
|
|
|
int width, height, flags;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-08 21:49:52 +00:00
|
|
|
for (i = 1; ; i++) {
|
2002-11-20 13:08:01 +00:00
|
|
|
p2 = vga + i * 8;
|
2006-10-27 11:39:04 +00:00
|
|
|
offs = readUint32Wrapper(p2);
|
2002-11-20 13:08:01 +00:00
|
|
|
|
|
|
|
/* try to detect end of images.
|
|
|
|
* assume the end when offset >= 200kb */
|
2006-10-27 11:39:04 +00:00
|
|
|
if (offs >= 204800)
|
2002-11-20 13:08:01 +00:00
|
|
|
return;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-10-27 11:39:04 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP) {
|
|
|
|
width = READ_LE_UINT16(p2 + 6);
|
|
|
|
height = READ_LE_UINT16(p2 + 4) & 0x7FFF;
|
|
|
|
flags = p2[5];
|
|
|
|
} else {
|
|
|
|
width = READ_BE_UINT16(p2 + 6) / 16;
|
|
|
|
height = p2[5];
|
|
|
|
flags = p2[4];
|
|
|
|
}
|
2002-11-20 13:08:01 +00:00
|
|
|
|
2006-05-04 12:20:49 +00:00
|
|
|
printf("Image %d. Width=%d, Height=%d, Flags=0x%X\n", i, width, height, flags);
|
2002-11-20 13:08:01 +00:00
|
|
|
|
|
|
|
/* dump bitmap */
|
2006-05-04 12:20:49 +00:00
|
|
|
char buf[40];
|
|
|
|
sprintf(buf, "dumps/Res%d_Image%d.bmp", res, i);
|
2002-11-20 13:08:01 +00:00
|
|
|
|
2006-10-21 01:51:59 +00:00
|
|
|
dumpBitmap(buf, vga + offs, width, height, flags, pal, 0);
|
2002-11-20 13:08:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
} // End of namespace AGOS
|