2002-06-29 16:11:13 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Simon debug functions
|
|
|
|
#include "stdafx.h"
|
2002-08-21 16:07:07 +00:00
|
|
|
#include "simon/simon.h"
|
|
|
|
#include "simon/intern.h"
|
2002-11-20 05:43:43 +00:00
|
|
|
#include "simon/debug.h"
|
2002-10-22 12:05:04 +00:00
|
|
|
#include "simon/vga.h"
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-10-22 13:03:40 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2003-10-03 19:42:27 +00:00
|
|
|
namespace Simon {
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
byte *SimonEngine::dumpOpcode(byte *p) {
|
2002-07-07 19:06:48 +00:00
|
|
|
byte opcode;
|
2002-06-29 16:11:13 +00:00
|
|
|
const char *s, *st;
|
|
|
|
|
|
|
|
opcode = *p++;
|
|
|
|
if (opcode == 255)
|
|
|
|
return NULL;
|
2003-05-17 08:54:46 +00:00
|
|
|
if (_game & GF_SIMON2 && _game & GF_TALKIE) {
|
2003-06-16 08:28:15 +00:00
|
|
|
st = s = simon2talkie_opcode_name_table[opcode];
|
2003-05-17 08:54:46 +00:00
|
|
|
} else if (_game & GF_TALKIE) {
|
2003-06-16 08:28:15 +00:00
|
|
|
st = s = simon1talkie_opcode_name_table[opcode];
|
2003-05-17 08:54:46 +00:00
|
|
|
} else if (_game & GF_SIMON2) {
|
2003-06-16 08:28:15 +00:00
|
|
|
st = s = simon2dos_opcode_name_table[opcode];
|
2003-05-17 08:54:46 +00:00
|
|
|
} else {
|
2003-06-16 08:28:15 +00:00
|
|
|
st = s = simon1dos_opcode_name_table[opcode];
|
2002-11-20 05:43:43 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
if (s == NULL) {
|
2003-07-13 16:22:17 +00:00
|
|
|
error("INVALID OPCODE %d", opcode);
|
2002-06-29 16:11:13 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
while (*st != '|')
|
|
|
|
st++;
|
|
|
|
fprintf(_dump_file, "%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':
|
2002-07-07 19:06:48 +00:00
|
|
|
fprintf(_dump_file, "\n");
|
2002-06-29 16:11:13 +00:00
|
|
|
return NULL;
|
|
|
|
case '|':
|
2002-07-07 19:06:48 +00:00
|
|
|
fprintf(_dump_file, "\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)
|
|
|
|
fprintf(_dump_file, "[%d] ", *p++);
|
|
|
|
else
|
|
|
|
fprintf(_dump_file, "%d ", b);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'V':{
|
|
|
|
byte b = *p++;
|
|
|
|
if (b == 255)
|
|
|
|
fprintf(_dump_file, "[[%d]] ", *p++);
|
|
|
|
else
|
|
|
|
fprintf(_dump_file, "[%d] ", b);
|
|
|
|
break;
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'W':{
|
|
|
|
int n = (int16)((p[0] << 8) | p[1]);
|
|
|
|
p += 2;
|
|
|
|
if (n >= 30000 && n < 30512)
|
|
|
|
fprintf(_dump_file, "[%d] ", n - 30000);
|
|
|
|
else
|
|
|
|
fprintf(_dump_file, "%d ", n);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'w':{
|
|
|
|
int n = (int16)((p[0] << 8) | p[1]);
|
|
|
|
p += 2;
|
|
|
|
fprintf(_dump_file, "%d ", n);
|
|
|
|
break;
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'I':{
|
|
|
|
int n = (int16)((p[0] << 8) | p[1]);;
|
|
|
|
p += 2;
|
|
|
|
if (n == -1)
|
|
|
|
fprintf(_dump_file, "ITEM_M1 ");
|
|
|
|
else if (n == -3)
|
|
|
|
fprintf(_dump_file, "ITEM_M3 ");
|
|
|
|
else if (n == -5)
|
|
|
|
fprintf(_dump_file, "ITEM_1 ");
|
|
|
|
else if (n == -7)
|
|
|
|
fprintf(_dump_file, "ITEM_0 ");
|
|
|
|
else if (n == -9)
|
|
|
|
fprintf(_dump_file, "ITEM_A_PARENT ");
|
|
|
|
else
|
|
|
|
fprintf(_dump_file, "<%d> ", n);
|
|
|
|
break;
|
|
|
|
}
|
2003-03-06 19:16:24 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'J':{
|
|
|
|
fprintf(_dump_file, "-> ");
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 'T':{
|
|
|
|
uint n = ((p[0] << 8) | p[1]);
|
|
|
|
p += 2;
|
|
|
|
if (n != 0xFFFF)
|
|
|
|
fprintf(_dump_file, "\"%s\"(%d) ", getStringPtrByID(n), n);
|
|
|
|
else
|
|
|
|
fprintf(_dump_file, "NULL_STRING ");
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dumpSubroutineLine(SubroutineLine *sl, Subroutine *sub) {
|
2002-06-29 16:11:13 +00:00
|
|
|
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) {
|
2002-07-07 19:06:48 +00:00
|
|
|
fprintf(_dump_file, "; cond_a=%d, cond_b=%d, cond_c=%d\n", sl->cond_a, sl->cond_b, sl->cond_c);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dumpSubroutine(Subroutine *sub) {
|
2002-06-29 16:11:13 +00:00
|
|
|
SubroutineLine *sl;
|
|
|
|
|
2002-11-05 05:41:52 +00:00
|
|
|
fprintf(_dump_file, "\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);
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
fprintf(_dump_file, "\nEND ******************************************\n");
|
2002-06-29 16:11:13 +00:00
|
|
|
fflush(_dump_file);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dumpSubroutines() {
|
2002-06-29 16:11:13 +00:00
|
|
|
Subroutine *sub = _subroutine_list;
|
2002-07-07 19:06:48 +00:00
|
|
|
for (; sub; sub = sub->next) {
|
2002-06-29 16:11:13 +00:00
|
|
|
dumpSubroutine(sub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dump_video_script(byte *src, bool one_opcode_only) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint opcode;
|
|
|
|
const char *str, *strn;
|
|
|
|
|
|
|
|
do {
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
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
|
|
|
} else {
|
|
|
|
opcode = *src++;
|
|
|
|
}
|
|
|
|
|
2003-12-01 00:45:16 +00:00
|
|
|
if (opcode >= NUM_VIDEO_OP_CODES) {
|
2002-06-29 16:11:13 +00:00
|
|
|
error("Invalid opcode %x\n", opcode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
2003-06-16 08:28:15 +00:00
|
|
|
strn = str = simon1_video_opcode_name_table[opcode];
|
2002-11-20 05:43:43 +00:00
|
|
|
} else {
|
2003-06-16 08:28:15 +00:00
|
|
|
strn = str = simon2_video_opcode_name_table[opcode];
|
2002-11-20 05:43:43 +00:00
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
while (*strn != '|')
|
|
|
|
strn++;
|
|
|
|
fprintf(_dump_file, "%.2d: %s ", opcode, strn + 1);
|
|
|
|
|
|
|
|
for (; *str != '|'; str++) {
|
|
|
|
switch (*str) {
|
|
|
|
case 'x':
|
|
|
|
fprintf(_dump_file, "\n");
|
|
|
|
return;
|
|
|
|
case 'b':
|
|
|
|
fprintf(_dump_file, "%d ", *src++);
|
|
|
|
break;
|
|
|
|
case 'd':
|
2003-06-14 18:52:30 +00:00
|
|
|
fprintf(_dump_file, "%d ", READ_BE_UINT16(src));
|
2002-07-07 19:06:48 +00:00
|
|
|
src += 2;
|
|
|
|
break;
|
|
|
|
case 'v':
|
2003-06-14 18:52:30 +00:00
|
|
|
fprintf(_dump_file, "[%d] ", READ_BE_UINT16(src));
|
2002-07-07 19:06:48 +00:00
|
|
|
src += 2;
|
|
|
|
break;
|
|
|
|
case 'i':
|
2003-06-14 18:52:30 +00:00
|
|
|
fprintf(_dump_file, "%d ", (int16)READ_BE_UINT16(src));
|
2002-07-07 19:06:48 +00:00
|
|
|
src += 2;
|
|
|
|
break;
|
|
|
|
case 'q':
|
2003-06-14 18:52:30 +00:00
|
|
|
while (READ_BE_UINT16(src) != 999) {
|
|
|
|
fprintf(_dump_file, "(%d,%d) ", READ_BE_UINT16(src),
|
|
|
|
READ_BE_UINT16(src + 2));
|
2002-06-29 16:11:13 +00:00
|
|
|
src += 4;
|
|
|
|
}
|
|
|
|
src++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Invalid fmt string '%c' in decompile VGA", *str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
fprintf(_dump_file, "\n");
|
|
|
|
} while (!one_opcode_only);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dump_vga_file(byte *vga) {
|
2002-06-29 16:11:13 +00:00
|
|
|
{
|
|
|
|
byte *pp;
|
|
|
|
byte *p;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
pp = vga;
|
2003-06-14 18:52:30 +00:00
|
|
|
p = pp + READ_BE_UINT16(&((VgaFile1Header *) pp)->hdr2_start);
|
|
|
|
count = READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_count);
|
|
|
|
p = pp + READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_table);
|
2002-06-29 16:11:13 +00:00
|
|
|
while (--count >= 0) {
|
2003-06-14 18:52:30 +00:00
|
|
|
int id = READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->id);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-06-14 18:52:30 +00:00
|
|
|
dump_vga_script_always(vga + READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->script_offs), id / 100, id);
|
2002-06-29 16:11:13 +00:00
|
|
|
p += sizeof(VgaFile1Struct0x6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
byte *bb, *b;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
bb = vga;
|
2003-06-14 18:52:30 +00:00
|
|
|
b = bb + READ_BE_UINT16(&((VgaFile1Header *) bb)->hdr2_start);
|
|
|
|
c = READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk1);
|
|
|
|
b = bb + READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk2_offs);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
while (--c >= 0) {
|
2003-06-14 18:52:30 +00:00
|
|
|
int id = READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->id);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-06-14 18:52:30 +00:00
|
|
|
dump_vga_script_always(vga + READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->script_offs), id / 100, id);
|
2002-06-29 16:11:13 +00:00
|
|
|
b += sizeof(VgaFile1Struct0x8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2003-03-06 19:16:24 +00:00
|
|
|
void dump_bmp(const char *filename, int w, int h, const byte *bytes, const uint32 *palette) {
|
2002-06-29 16:11:13 +00:00
|
|
|
FILE *out = fopen(filename, "wb");
|
|
|
|
byte my_hdr[sizeof(bmp_hdr)];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (out == NULL) {
|
|
|
|
printf("DUMP ERROR\n");
|
|
|
|
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
|
|
|
|
|
|
|
fwrite(my_hdr, 1, sizeof(my_hdr), out);
|
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;
|
|
|
|
fwrite(color, 1, 4, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (--h >= 0) {
|
2002-07-07 19:06:48 +00:00
|
|
|
fwrite(bytes + h * ((w + 3) & ~3), ((w + 3) & ~3), 1, out);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fclose(out);
|
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
void dump_bitmap(const char *filename, byte *offs, int w, int h, int flags, const byte *palette,
|
|
|
|
byte base)
|
|
|
|
{
|
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;
|
|
|
|
state.depack_src = offs;
|
|
|
|
state.dh = h;
|
|
|
|
state.y_skip = 0;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = 0; i != w; i += 2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte *c = vc_10_depack_column(&state);
|
2002-07-07 19:06:48 +00:00
|
|
|
for (j = 0; j != h; j++) {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte pix = c[j];
|
2002-07-07 19:06:48 +00:00
|
|
|
b[j * w + i] = (pix >> 4) | base;
|
|
|
|
b[j * w + i + 1] = (pix & 0xF) | base;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-21 17:49:33 +00:00
|
|
|
dump_bmp(filename, w, h, b, (const uint32 *)palette);
|
2002-06-29 16:11:13 +00:00
|
|
|
free(b);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dump_single_bitmap(int file, int image, byte *offs, int w, int h, byte base) {
|
2003-12-11 09:29:56 +00:00
|
|
|
char buf[40];
|
2003-12-21 15:53:38 +00:00
|
|
|
#if !defined(__PALM_OS__) && !defined(__DC__)
|
2002-06-29 16:11:13 +00:00
|
|
|
struct stat statbuf;
|
2003-12-15 15:17:06 +00:00
|
|
|
#endif
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-12-11 09:14:10 +00:00
|
|
|
#if defined(MACOS_CARBON)
|
|
|
|
sprintf(buf, ":dumps:File%d_Image%d.bmp", file, image);
|
|
|
|
#else
|
|
|
|
sprintf(buf, "dumps/File%d_Image%d.bmp", file, image);
|
|
|
|
#endif
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-12-21 15:53:38 +00:00
|
|
|
#if !defined(__PALM_OS__) && !defined(__DC__)
|
2002-06-29 16:11:13 +00:00
|
|
|
if (stat(buf, &statbuf) == 0)
|
|
|
|
return;
|
2003-12-15 15:17:06 +00:00
|
|
|
#endif
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
dump_bitmap(buf, offs, w, h, 0, _palette, base);
|
|
|
|
}
|
|
|
|
|
2002-11-20 13:08:01 +00:00
|
|
|
void pal_load(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;
|
|
|
|
|
2003-11-08 20:54:31 +00:00
|
|
|
palptr = (byte *)&pal[a << 4];
|
|
|
|
src = vga1 + 6 + b * 96;
|
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);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dump_vga_bitmaps(byte *vga, byte *vga1, int res) {
|
2002-11-20 13:19:50 +00:00
|
|
|
|
2002-11-20 13:08:01 +00:00
|
|
|
int i;
|
|
|
|
uint32 offs;
|
|
|
|
byte *p2;
|
|
|
|
byte pal[768];
|
|
|
|
|
|
|
|
{
|
|
|
|
memset(pal, 0, sizeof(pal));
|
|
|
|
pal_load(pal, vga1, 2, 0);
|
|
|
|
pal_load(pal, vga1, 3, 1);
|
|
|
|
pal_load(pal, vga1, 4, 2);
|
|
|
|
pal_load(pal, vga1, 5, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
int width, height, flags;
|
|
|
|
|
2002-11-29 16:06:15 +00:00
|
|
|
i = 538;
|
2002-11-20 13:08:01 +00:00
|
|
|
|
2003-11-08 20:54:31 +00:00
|
|
|
for(i = 1; ; i++) {
|
2002-11-20 13:08:01 +00:00
|
|
|
p2 = vga + i * 8;
|
2003-11-08 20:54:31 +00:00
|
|
|
offs = TO_BE_32(*(uint32 *)p2);
|
2002-11-20 13:08:01 +00:00
|
|
|
|
|
|
|
/* try to detect end of images.
|
|
|
|
* assume the end when offset >= 200kb */
|
|
|
|
if (offs >= 200*1024)
|
|
|
|
return;
|
|
|
|
|
2003-11-08 20:54:31 +00:00
|
|
|
width = TO_BE_16(*(uint16 *)(p2 + 6));
|
2002-11-20 13:08:01 +00:00
|
|
|
height = p2[5];
|
|
|
|
flags = p2[4];
|
|
|
|
|
|
|
|
fprintf(_dump_file, "Image %d. Width=%d, Height=%d, Flags=0x%X\n", i, width, height, flags);
|
|
|
|
fflush(_dump_file);
|
|
|
|
|
|
|
|
/* dump bitmap */
|
|
|
|
{
|
2003-12-11 09:29:56 +00:00
|
|
|
char buf[40];
|
2003-12-11 09:14:10 +00:00
|
|
|
#if defined(MACOS_CARBON)
|
|
|
|
sprintf(buf, ":dumps:Res%d_Image%d.bmp", res, i);
|
|
|
|
#else
|
|
|
|
sprintf(buf, "dumps/Res%d_Image%d.bmp", res, i);
|
|
|
|
#endif
|
2002-11-20 13:08:01 +00:00
|
|
|
|
|
|
|
dump_bitmap(buf, vga + offs, width, height, flags, pal, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dump_vga_script_always(byte *ptr, uint res, uint sprite_id) {
|
2002-07-07 19:06:48 +00:00
|
|
|
fprintf(_dump_file, "; address=%x, vgafile=%d vgasprite=%d\n",
|
|
|
|
ptr - _vga_buffer_pointers[res].vgaFile1, res, sprite_id);
|
2002-06-29 16:11:13 +00:00
|
|
|
dump_video_script(ptr, false);
|
2002-07-07 19:06:48 +00:00
|
|
|
fprintf(_dump_file, "; end\n");
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::dump_vga_script(byte *ptr, uint res, uint sprite_id) {
|
2002-10-22 12:05:04 +00:00
|
|
|
dump_vga_script_always(ptr, res, sprite_id);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-10-03 19:42:27 +00:00
|
|
|
} // End of namespace Simon
|