Clean up VGA headers.

More changes for FF.

svn-id: r18988
This commit is contained in:
Travis Howell 2005-10-09 12:12:24 +00:00
parent 6b897dd90b
commit 0006c3f395
6 changed files with 192 additions and 90 deletions

View File

@ -207,22 +207,42 @@ void SimonEngine::dump_video_script(const byte *src, bool one_opcode_only) {
fprintf(_dumpFile, "%d ", *src++);
break;
case 'd':
fprintf(_dumpFile, "%d ", READ_BE_UINT16(src));
if (_game == GAME_FEEBLEFILES) {
fprintf(_dumpFile, "%d ", READ_LE_UINT16(src));
} else {
fprintf(_dumpFile, "%d ", READ_BE_UINT16(src));
}
src += 2;
break;
case 'v':
fprintf(_dumpFile, "[%d] ", READ_BE_UINT16(src));
if (_game == GAME_FEEBLEFILES) {
fprintf(_dumpFile, "[%d] ", READ_LE_UINT16(src));
} else {
fprintf(_dumpFile, "[%d] ", READ_BE_UINT16(src));
}
src += 2;
break;
case 'i':
fprintf(_dumpFile, "%d ", (int16)READ_BE_UINT16(src));
if (_game == GAME_FEEBLEFILES) {
fprintf(_dumpFile, "%d ", (int16)READ_LE_UINT16(src));
} else {
fprintf(_dumpFile, "%d ", (int16)READ_BE_UINT16(src));
}
src += 2;
break;
case 'q':
while (READ_BE_UINT16(src) != 999) {
fprintf(_dumpFile, "(%d,%d) ", READ_BE_UINT16(src),
READ_BE_UINT16(src + 2));
src += 4;
if (_game == GAME_FEEBLEFILES) {
while (READ_LE_UINT16(src) != 9999) {
fprintf(_dumpFile, "(%d,%d) ", READ_LE_UINT16(src),
READ_LE_UINT16(src + 2));
src += 4;
}
} else {
while (READ_BE_UINT16(src) != 999) {
fprintf(_dumpFile, "(%d,%d) ", READ_BE_UINT16(src),
READ_BE_UINT16(src + 2));
src += 4;
}
}
src++;
break;
@ -242,14 +262,14 @@ void SimonEngine::dump_vga_file(const byte *vga) {
int count;
pp = vga;
p = pp + READ_BE_UINT16(&((const VgaFile1Header *) pp)->hdr2_start);
count = READ_BE_UINT16(&((const VgaFile1Header2 *) p)->id_count);
p = pp + READ_BE_UINT16(&((const VgaFile1Header2 *) p)->id_table);
p = pp + READ_BE_UINT16(&((const VgaFileHeader_Simon *) pp)->hdr2_start);
count = READ_BE_UINT16(&((const VgaFileHeader2_Simon *) p)->animationCount);
p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Simon *) p)->animationTable);
while (--count >= 0) {
int id = READ_BE_UINT16(&((const VgaFile1Struct0x6 *) p)->id);
int id = READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->id);
dump_vga_script_always(vga + READ_BE_UINT16(&((const VgaFile1Struct0x6 *) p)->script_offs), id / 100, id);
p += sizeof(VgaFile1Struct0x6);
dump_vga_script_always(vga + READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->scriptOffs), id / 100, id);
p += sizeof(AnimationHeader_Simon);
}
}
@ -258,15 +278,15 @@ void SimonEngine::dump_vga_file(const byte *vga) {
int c;
bb = vga;
b = bb + READ_BE_UINT16(&((const VgaFile1Header *) bb)->hdr2_start);
c = READ_BE_UINT16(&((const VgaFile1Header2 *) b)->unk1);
b = bb + READ_BE_UINT16(&((const VgaFile1Header2 *) b)->unk2_offs);
b = bb + READ_BE_UINT16(&((const VgaFileHeader_Simon *) bb)->hdr2_start);
c = READ_BE_UINT16(&((const VgaFileHeader2_Simon *) b)->imageCount);
b = bb + READ_BE_UINT16(&((const VgaFileHeader2_Simon *) b)->imageTable);
while (--c >= 0) {
int id = READ_BE_UINT16(&((const VgaFile1Struct0x8 *) b)->id);
int id = READ_BE_UINT16(&((const ImageHeader_Simon *) b)->id);
dump_vga_script_always(vga + READ_BE_UINT16(&((const VgaFile1Struct0x8 *) b)->script_offs), id / 100, id);
b += sizeof(VgaFile1Struct0x8);
dump_vga_script_always(vga + READ_BE_UINT16(&((const ImageHeader_Simon *) b)->scriptOffs), id / 100, id);
b += sizeof(ImageHeader_Simon);
}
}
}

View File

@ -1258,10 +1258,12 @@ const char *const feeblefiles_video_opcode_name_table[] = {
"bb|SET_MARK",
"bb|CLEAR_MARK",
"dd|SETSCALE",
/* 76 */
"ddd|SETSCALEXOFFS",
"ddd|SETSCALEYOFFS",
"|PATHUNK1",
"|PATHUNK1",
/* 80 */
"ddd|SETOVERLAPIMAGE",
"dd|SETRANDOM",
"d|PATHUNK3",

View File

@ -365,11 +365,11 @@ SimonEngine::SimonEngine(GameDetector *detector, OSystem *syst)
if (_game == GAME_FEEBLEFILES) {
NUM_VIDEO_OP_CODES = 85;
#ifndef __PALM_OS__
VGA_MEM_SIZE = 2000000;
VGA_MEM_SIZE = 7500000;
#else
VGA_MEM_SIZE = gVars->memory[kMemSimon2Games];
#endif
TABLES_MEM_SIZE = 100000;
TABLES_MEM_SIZE = 200000;
} else if (_game & GF_SIMON2) {
TABLE_INDEX_BASE = 1580 / 4;
TEXT_INDEX_BASE = 1500 / 4;
@ -2498,7 +2498,7 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
uint num, num_lines;
VgaPointersEntry *vpe;
byte *bb, *b;
// uint16 c;
// uint16 count;
const byte *vc_ptr_org;
_windowNum = mode;
@ -2533,19 +2533,19 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
bb = _curVgaFile1;
if (_game == GAME_FEEBLEFILES) {
b = bb + READ_LE_UINT16(&((FFVgaFile1Header *) bb)->hdr2_start);
//c = READ_LE_UINT16(&((FFVgaFile1Header2 *) b)->unk1);
b = bb + READ_LE_UINT16(&((FFVgaFile1Header2 *) b)->unk2_offs);
b = bb + READ_LE_UINT16(&((VgaFileHeader_Feeble *) bb)->hdr2_start);
//count = READ_LE_UINT16(&((VgaFileHeader2_Feeble *) b)->imageCount);
b = bb + READ_LE_UINT16(&((VgaFileHeader2_Feeble *) b)->imageTable);
while (READ_LE_UINT16(&((FFVgaFile1Struct0x8 *) b)->id) != vga_res_id)
b += sizeof(FFVgaFile1Struct0x8);
while (READ_LE_UINT16(&((ImageHeader_Feeble *) b)->id) != vga_res_id)
b += sizeof(ImageHeader_Feeble);
} else {
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);
b = bb + READ_BE_UINT16(&((VgaFileHeader_Simon *) bb)->hdr2_start);
//count = READ_BE_UINT16(&((VgaFileHeader2_Simon *) b)->imageCount);
b = bb + READ_BE_UINT16(&((VgaFileHeader2_Simon *) b)->imageTable);
while (READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->id) != vga_res_id)
b += sizeof(VgaFile1Struct0x8);
while (READ_BE_UINT16(&((ImageHeader_Simon *) b)->id) != vga_res_id)
b += sizeof(ImageHeader_Simon);
}
if (!(_game & GF_SIMON2)) {
@ -2566,9 +2566,9 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
vc_ptr_org = _vcPtr;
if (_game == GAME_FEEBLEFILES) {
_vcPtr = _curVgaFile1 + READ_LE_UINT16(&((FFVgaFile1Struct0x8 *) b)->script_offs);
_vcPtr = _curVgaFile1 + READ_LE_UINT16(&((ImageHeader_Feeble *) b)->scriptOffs);
} else {
_vcPtr = _curVgaFile1 + READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->script_offs);
_vcPtr = _curVgaFile1 + READ_BE_UINT16(&((ImageHeader_Simon *) b)->scriptOffs);
}
//dump_vga_script(_vcPtr, num, vga_res_id);
run_vga_script();
@ -2825,10 +2825,17 @@ void SimonEngine::timer_vga_sprites() {
_windowNum = vsp->windowNum;
_vgaCurSpriteId = vsp->id;
params[0] = READ_BE_UINT16(&vsp->image);
params[1] = READ_BE_UINT16(&vsp->palette);
params[2] = READ_BE_UINT16(&vsp->x);
params[3] = READ_BE_UINT16(&vsp->y);
if (_game == GAME_FEEBLEFILES) {
params[0] = READ_LE_UINT16(&vsp->image);
params[1] = READ_LE_UINT16(&vsp->palette);
params[2] = READ_LE_UINT16(&vsp->x);
params[3] = READ_LE_UINT16(&vsp->y);
} else {
params[0] = READ_BE_UINT16(&vsp->image);
params[1] = READ_BE_UINT16(&vsp->palette);
params[2] = READ_BE_UINT16(&vsp->x);
params[3] = READ_BE_UINT16(&vsp->y);
}
if (_game & GF_SIMON2) {
*(byte *)(&params[4]) = (byte)vsp->flags;
@ -2906,11 +2913,19 @@ void SimonEngine::timer_vga_sprites_2() {
if (vsp->image)
fprintf(_dumpFile, "id:%5d image:%3d base-color:%3d x:%3d y:%3d flags:%x\n",
vsp->id, vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags);
params[0] = READ_BE_UINT16(&vsp->image);
params[1] = READ_BE_UINT16(&vsp->palette);
params[2] = READ_BE_UINT16(&vsp->x);
params[3] = READ_BE_UINT16(&vsp->y);
params[4] = READ_BE_UINT16(&vsp->flags);
if (_game == GAME_FEEBLEFILES) {
params[0] = READ_LE_UINT16(&vsp->image);
params[1] = READ_LE_UINT16(&vsp->palette);
params[2] = READ_LE_UINT16(&vsp->x);
params[3] = READ_LE_UINT16(&vsp->y);
params[4] = READ_LE_UINT16(&vsp->flags);
} else {
params[0] = READ_BE_UINT16(&vsp->image);
params[1] = READ_BE_UINT16(&vsp->palette);
params[2] = READ_BE_UINT16(&vsp->x);
params[3] = READ_BE_UINT16(&vsp->y);
params[4] = READ_BE_UINT16(&vsp->flags);
}
_vcPtr = (const byte *)params;
vc10_draw();
@ -3469,21 +3484,37 @@ void SimonEngine::loadSprite(uint windowNum, uint fileId, uint vgaSpriteId, uint
}
pp = _curVgaFile1;
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);
if (_game == GAME_FEEBLEFILES) {
p = pp + READ_LE_UINT16(&((VgaFileHeader_Feeble *) pp)->hdr2_start);
count = READ_LE_UINT16(&((VgaFileHeader2_Feeble *) p)->animationCount);
p = pp + READ_LE_UINT16(&((VgaFileHeader2_Feeble *) p)->animationTable);
} else {
p = pp + READ_BE_UINT16(&((VgaFileHeader_Simon *) pp)->hdr2_start);
count = READ_BE_UINT16(&((VgaFileHeader2_Simon *) p)->animationCount);
p = pp + READ_BE_UINT16(&((VgaFileHeader2_Simon *) p)->animationTable);
}
for (;;) {
if (READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->id) == vgaSpriteId) {
if (_game == GAME_FEEBLEFILES) {
if (READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->id) == vgaSpriteId) {
if (_startVgaScript)
dump_vga_script(pp + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), fileId, vgaSpriteId);
if (_startVgaScript)
dump_vga_script(pp + READ_BE_UINT16(&((VgaFile1Struct0x6*)p)->script_offs), fileId, vgaSpriteId);
add_vga_timer(VGA_DELAY_BASE, pp + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, fileId);
break;
}
p += sizeof(AnimationHeader_Feeble);
} else {
if (READ_BE_UINT16(&((AnimationHeader_Simon *) p)->id) == vgaSpriteId) {
if (_startVgaScript)
dump_vga_script(pp + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), fileId, vgaSpriteId);
add_vga_timer(VGA_DELAY_BASE, pp + READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->script_offs), vgaSpriteId, fileId);
break;
add_vga_timer(VGA_DELAY_BASE, pp + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, fileId);
break;
}
p += sizeof(AnimationHeader_Simon);
}
p += sizeof(VgaFile1Struct0x6);
if (!--count) {
vsp->id = 0;
break;

View File

@ -322,7 +322,7 @@ protected:
HitArea _hitAreas[90];
VgaPointersEntry _vgaBufferPointers[180];
VgaPointersEntry _vgaBufferPointers[450];
VgaSprite _vgaSprites[180];
VgaSleepStruct _vgaSleepStructs[30];

View File

@ -281,15 +281,27 @@ void SimonEngine::vc2_call() {
bb = _curVgaFile1;
b = bb + READ_BE_UINT16(&((VgaFile1Header *) bb)->hdr2_start);
b = bb + READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk2_offs);
if (_game == GAME_FEEBLEFILES) {
b = bb + READ_LE_UINT16(&((VgaFileHeader_Feeble *) bb)->hdr2_start);
b = bb + READ_LE_UINT16(&((VgaFileHeader2_Feeble *) b)->imageTable);
while (READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->id) != num)
b += sizeof(VgaFile1Struct0x8);
while (READ_LE_UINT16(&((ImageHeader_Feeble *) b)->id) != num)
b += sizeof(ImageHeader_Feeble);
} else {
b = bb + READ_BE_UINT16(&((VgaFileHeader_Simon *) bb)->hdr2_start);
b = bb + READ_BE_UINT16(&((VgaFileHeader2_Simon *) b)->imageTable);
while (READ_BE_UINT16(&((ImageHeader_Simon *) b)->id) != num)
b += sizeof(ImageHeader_Simon);
}
vc_ptr_org = _vcPtr;
_vcPtr = _curVgaFile1 + READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->script_offs);
if (_game == GAME_FEEBLEFILES) {
_vcPtr = _curVgaFile1 + READ_LE_UINT16(&((ImageHeader_Feeble *) b)->scriptOffs);
} else {
_vcPtr = _curVgaFile1 + READ_BE_UINT16(&((ImageHeader_Feeble *) b)->scriptOffs);
}
//dump_vga_script(_vcPtr, res, num);
run_vga_script();
@ -355,11 +367,19 @@ void SimonEngine::vc3_loadSprite() {
}
pp = _curVgaFile1;
p = pp + READ_BE_UINT16(&((VgaFile1Header *) pp)->hdr2_start);
p = pp + READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_table);
if (_game == GAME_FEEBLEFILES) {
p = pp + READ_LE_UINT16(&((VgaFileHeader_Feeble *) pp)->hdr2_start);
p = pp + READ_LE_UINT16(&((VgaFileHeader2_Feeble *) p)->animationTable);
while (READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->id) != vgaSpriteId)
p += sizeof(VgaFile1Struct0x6);
while (READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->id) != vgaSpriteId)
p += sizeof(AnimationHeader_Feeble);
} else {
p = pp + READ_BE_UINT16(&((VgaFileHeader_Simon *) pp)->hdr2_start);
p = pp + READ_BE_UINT16(&((VgaFileHeader2_Simon *) p)->animationTable);
while (READ_BE_UINT16(&((AnimationHeader_Simon *) p)->id) != vgaSpriteId)
p += sizeof(AnimationHeader_Simon);
}
#ifdef DUMP_FILE_NR
{
@ -381,10 +401,21 @@ void SimonEngine::vc3_loadSprite() {
}
#endif
if (_startVgaScript)
dump_vga_script(_curVgaFile1 + READ_BE_UINT16(&((VgaFile1Struct0x6*)p)->script_offs), res, vgaSpriteId);
if (_startVgaScript) {
if (_game == GAME_FEEBLEFILES) {
dump_vga_script(_curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), res, vgaSpriteId);
} else {
dump_vga_script(_curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), res, vgaSpriteId);
}
}
if (_game == GAME_FEEBLEFILES) {
add_vga_timer(VGA_DELAY_BASE, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, res);
} else {
add_vga_timer(VGA_DELAY_BASE, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, res);
}
add_vga_timer(VGA_DELAY_BASE, _curVgaFile1 + READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->script_offs), vgaSpriteId, res);
_curVgaFile1 = old_file_1;
}
@ -674,7 +705,7 @@ void SimonEngine::vc10_draw() {
state.palette);
// TODO::Add support for image scaling
if (flags & 0x40)
if (_game == GAME_FEEBLEFILES)
return;
if (flags & 0x80 && !(state.flags & 0x10)) {
@ -1126,8 +1157,14 @@ void SimonEngine::vc16_sleep_on_id() {
void SimonEngine::vc17_setPathfinderItem() {
uint a = vc_read_next_word();
_pathFindArray[a - 1] = (const uint16 *)_vcPtr;
while (READ_BE_UINT16(_vcPtr) != 999)
_vcPtr += 4;
if (_game == GAME_FEEBLEFILES) {
while (READ_LE_UINT16(_vcPtr) != 9999)
_vcPtr += 4;
} else {
while (READ_BE_UINT16(_vcPtr) != 999)
_vcPtr += 4;
}
_vcPtr += 2;
}
@ -1508,9 +1545,15 @@ void SimonEngine::vc48_setPathFinder() {
vp = &_variableArray[20];
do {
y2 = READ_BE_UINT16(p);
p += step;
y1 = READ_BE_UINT16(p) - y2;
if (_game == GAME_FEEBLEFILES) {
y2 = READ_LE_UINT16(p);
p += step;
y1 = READ_LE_UINT16(p) - y2;
} else {
y2 = READ_BE_UINT16(p);
p += step;
y1 = READ_BE_UINT16(p) - y2;
}
vp[0] = y1 >> 1;
vp[1] = y1 - (y1 >> 1);

View File

@ -29,60 +29,66 @@ namespace Simon {
#endif
// Feeble Files
struct FFVgaFile1Header {
struct VgaFileHeader_Feeble {
uint16 x_1;
uint16 hdr2_start;
uint16 x_2, x_3;
} GCC_PACK;
struct FFVgaFile1Header2 {
uint16 unk1;
struct VgaFileHeader2_Feeble {
uint16 imageCount;
uint16 x_2;
uint16 id_count;
uint16 animationCount;
uint16 x_3;
uint16 unk2_offs;
uint16 imageTable;
uint16 x_4;
uint16 id_table;
uint16 animationTable;
uint16 x_5;
} GCC_PACK;
struct FFVgaFile1Struct0x8 {
struct ImageHeader_Feeble {
uint16 id;
uint16 x_1;
uint16 script_offs;
uint16 scriptOffs;
uint16 x_2;
} GCC_PACK;
struct AnimationHeader_Feeble {
uint16 scriptOffs;
uint16 x_2;
uint16 id;
} GCC_PACK;
// Simon 1/2
struct VgaFile1Header {
struct VgaFileHeader_Simon {
uint16 x_1, x_2;
uint16 hdr2_start;
uint16 x_3, x_4;
} GCC_PACK;
struct VgaFile1Header2 {
struct VgaFileHeader2_Simon {
uint16 x_1;
uint16 unk1;
uint16 imageCount;
uint16 x_2;
uint16 id_count;
uint16 animationCount;
uint16 x_3;
uint16 unk2_offs;
uint16 imageTable;
uint16 x_4;
uint16 id_table;
uint16 animationTable;
uint16 x_5;
} GCC_PACK;
struct VgaFile1Struct0x8 {
struct ImageHeader_Simon {
uint16 id;
uint16 x_1;
uint16 x_2;
uint16 script_offs;
uint16 scriptOffs;
} GCC_PACK;
struct VgaFile1Struct0x6 {
struct AnimationHeader_Simon {
uint16 id;
uint16 x_2;
uint16 script_offs;
uint16 scriptOffs;
} GCC_PACK;