[Scummvm-cvs-logs] CVS: scummvm/simon simondebug.cpp,NONE,1.1 simonitems.cpp,NONE,1.1 simonverb.cpp,NONE,1.1 simonvga.cpp,NONE,1.1 simon.cpp,1.36,1.37 simon.h,1.19,1.20 simonsys.cpp,1.8,1.9
James Brown
ender at users.sourceforge.net
Sat Jun 29 09:12:02 CEST 2002
Update of /cvsroot/scummvm/scummvm/simon
In directory usw-pr-cvs1:/tmp/cvs-serv23101
Modified Files:
simon.cpp simon.h simonsys.cpp
Added Files:
simondebug.cpp simonitems.cpp simonverb.cpp simonvga.cpp
Log Message:
Large pointless commit #143: Start splitting Simon code into more managable and slightly understandable chunks
--- NEW FILE: simondebug.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* 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: /cvsroot/scummvm/scummvm/simon/simondebug.cpp,v 1.1 2002/06/29 16:11:13 ender Exp $
*
*/
// Simon debug functions
#include "stdafx.h"
#include "simon.h"
#ifdef SIMONDEBUG
#define SIMON2
#define SIMON2WIN
static const char * const opcode_name_table[256] = {
/* 0 */
"|INV_COND",
"IJ|PTRA_PARENT_IS",
"IJ|PTRA_PARENT_ISNOT",
NULL,
/* 4 */
NULL,
"IJ|PARENT_IS_1",
"IJ|PARENT_ISNOT_1",
"IIJ|PARENT_IS",
/* 8 */
NULL,
NULL,
NULL,
"VJ|IS_ZERO",
/* 12 */
"VJ|ISNOT_ZERO",
"VWJ|IS_EQ",
"VWJ|IS_NEQ",
"VWJ|IS_LE",
/* 16 */
"VWJ|IS_GE",
"VVJ|IS_EQF",
"VVJ|IS_NEQF",
"VVJ|IS_LEF",
/* 20 */
"VVJ|IS_GEF",
NULL,
NULL,
"WJ|UNK23",
/* 24 */
NULL,
"IJ|HAS_CHILD_1",
"IJ|HAS_CHILD_2",
"IWJ|ITEM_UNK3_IS",
/* 28 */
"IBJ|CHILD_HAS_FLAG",
NULL,
NULL,
"I|SET_NO_PARENT",
/* 32 */
NULL,
"II|SET_PARENT",
NULL,
NULL,
/* 36 */
"VV|MOVE",
NULL,
NULL,
NULL,
/* 40 */
NULL,
"V|ZERO",
"VW|SET",
"VW|ADD",
/* 44 */
"VW|SUB",
"VV|ADDF",
"VV|SUBF",
"VW|MUL",
/* 48 */
"VW|DIV",
"VV|MULF",
"VV|DIVF",
"VW|MOD",
/* 52 */
"VV|MODF",
"VW|RANDOM",
NULL,
"I|SET_A_PARENT",
/* 56 */
"IB|SET_CHILD2_BIT",
"IB|CLEAR_CHILD2_BIT",
"II|MAKE_SIBLING",
"I|INC_UNK3",
/* 60 */
"I|DEC_UNK3",
"IW|SET_UNK3",
"V|SHOW_INT",
"T|SHOW_STRING_NL",
/* 64 */
"T|SHOW_STRING",
"WWWWWB|ADD_HITAREA",
"BT|SET_ITEM_NAME",
#if defined SIMON1WIN || defined SIMON2
"BTw|SET_ITEM_DESC",
#endif
#ifdef SIMON1DOS
"BT|SET_ITEM_DESC",
#endif
/* 68 */
"x|HALT",
"x|RET1",
"V|SHOW_STRING_AR3",
"W|START_SUB",
/* 72 */
NULL,
NULL,
NULL,
NULL,
/* 76 */
"WW|ADD_TIMEOUT",
"J|IS_M1_EMPTY",
"J|IS_M3_EMPTY",
"ITJ|CHILD_FR2_IS",
/* 80 */
"IIJ|IS_ITEM_EQ",
NULL,
"B|UNK82",
"|RETM10",
/* 84 */
NULL,
NULL,
NULL,
"W|UNK87",
/* 88 */
"|OR_SCRIPT_WORD_10",
"|AND_SCRIPT_WORD_10",
"IB|SET_M_TO_PARENT",
"IB|SET_M_TO_SIBLING",
/* 92 */
"IB|SET_M_TO_CHILD",
NULL,
NULL,
NULL,
/* 96 */
"WB|UNK96",
"W|LOAD_VGA",
#ifdef SIMON2
"WWBWWW|START_VGA",
#else
"WBWWW|START_VGA",
#endif
#ifdef SIMON2
"WW|KILL_THREAD",
#else
"W|KILL_THREAD",
#endif
/* 100 */
"|VGA_RESET",
"BWWWWWW|UNK101",
"B|UNK102",
"|UNK103",
/* 104 */
"B|UNK104",
NULL,
NULL,
"WWWWWIW|ADD_ITEM_HITAREA",
/* 108 */
"W|DEL_HITAREA",
"W|CLEAR_HITAREA_0x40",
"W|SET_HITAREA_0x40",
"WWW|SET_HITAREA_XY",
/* 112 */
NULL,
NULL,
"IB|UNK114",
"IBJ|HAS_FLAG",
/* 116 */
"IB|SET_FLAG",
"IB|CLEAR_FLAG",
NULL,
"W|WAIT_VGA",
/* 120 */
"W|UNK120",
"BI|SET_VGA_ITEM",
NULL,
NULL,
/* 124 */
NULL,
"IJ|IS_SIBLING_WITH_A",
"IBB|UNK126",
"WW|UNK127",
/* 128 */
"W|GET_DUMMY_WORD",
"W|GET_WORD_COND_TRUE",
"Bww|UNK131",
NULL, /* opcode 131 doesn't exist */
/* 132 */
"|SAVE_GAME",
"|LOAD_GAME",
"|DUMMYPROC_134",
"|QUIT_IF_USER_PRESSES_Y",
/* 136 */
"IV|GET_ITEM_UNK3",
"B|UNK137",
"|VGA_POINTER_OP_4",
"II|SET_PARENT_SPECIAL",
/* 140 */
"|DEL_TE_AND_ADD_ONE",
"BI|SET_M1_OR_M3",
"WJ|IS_HITAREA_0x40_CLEAR",
"I|START_ITEM_SUB",
/* 144 */
NULL,
NULL,
NULL,
NULL,
/* 148 */
NULL,
NULL,
NULL,
"BI|SET_ARRAY6_TO",
/* 152 */
"BB|SET_M1_M3_TO_ARRAY6",
"B|SET_BIT",
"B|CLEAR_BIT",
"BJ|IS_BIT_CLEAR",
/* 156 */
"BJ|IS_BIT_SET",
"IBB|GET_ITEM_PROP",
"IBW|SET_ITEM_PROP",
NULL,
/* 160 */
"B|UNK160",
"BWBW|SETUP_TEXT",
#if defined SIMON1WIN || defined SIMON2
"BBTW|PRINT_STR",
#endif
#ifdef SIMON1DOS
"BBT|PRINT_STR",
#endif
"W|SOUND_1",
/* 164 */
"|UNK164",
"IWWJ|ITEM_UNK1_UNK2_IS",
"B|SET_BIT2",
"B|CLEAR_BIT2",
/* 168 */
"BJ|IS_BIT2_CLEAR",
"BJ|IS_BIT2_SET",
NULL,
NULL,
/* 172 */
NULL,
NULL,
NULL,
"|VGA_POINTER_OP_1",
/* 176 */
"|VGA_POINTER_OP_2",
"BBI|UNK177",
"WWBB|PATHFIND",
"BBB|UNK179",
/* 180 */
"|FORCE_UNLOCK",
"|FORCE_LOCK",
"|READ_VGARES_328",
"|READ_VGARES_23",
/* 184 */
"W|CLEAR_VGAPOINTER_ENTRY",
"W|DUMMY_185",
"|VGA_POINTER_OP_3",
"|FADE_TO_BLACK",
#ifdef SIMON2
/* 188 */
"BSJ|STRING2_IS",
"|UNK189",
"B|UNK190",
#endif
};
byte *SimonState::dumpOpcode(byte *p) {
byte opcode;
const char *s, *st;
opcode = *p++;
if (opcode == 255)
return NULL;
st = s = opcode_name_table[opcode];
if (s == NULL) {
error("INVALID OPCODE %d\n", opcode);
return NULL;
}
while (*st != '|') st++;
fprintf(_dump_file,"%s ", st+1);
for(;;) {
switch(*s++) {
case 'x':
fprintf(_dump_file,"\n");
return NULL;
case '|':
fprintf(_dump_file,"\n");
return p;
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;
}
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;
}
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;
}
case 'J': {
fprintf(_dump_file,"-> ");
} break;
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 ");
} break;
}
}
}
void SimonState::dumpSubroutineLine(SubroutineLine *sl, Subroutine *sub) {
byte *p;
printf("; ****\n");
p = (byte*)sl + SUBROUTINE_LINE_SMALL_SIZE;
if (sub->id == 0) {
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;
}
for(;;) {
p = dumpOpcode(p);
if (p==NULL)
break;
}
}
void SimonState::dumpSubroutine(Subroutine *sub) {
SubroutineLine *sl;
fprintf(_dump_file,"\n******************************************\n;Subroutine, ID=%d:\nSUB_%d:\n", sub->id, sub->id);
sl = (SubroutineLine*) ((byte*)sub + sub->first);
for(;(byte*)sl != (byte*)sub; sl = (SubroutineLine*) ((byte*)sub + sl->next) ) {
dumpSubroutineLine(sl, sub);
}
fprintf(_dump_file,"\nEND ******************************************\n");
fflush(_dump_file);
}
void SimonState::dumpSubroutines() {
Subroutine *sub = _subroutine_list;
for(;sub;sub = sub->next) {
dumpSubroutine(sub);
}
}
const char * const video_opcode_name_table[] = {
/* 0 */
"x|RET",
"ddd|DUMMY",
"d|CALL",
"ddddd|NEW_THREAD",
/* 4 */
"ddd|DUMMY_2",
"vd|SKIP_IF_NEQ",
"d|SKIP_IFN_SIB_WITH_A",
"d|SKIP_IF_SIB_WITH_A",
/* 8 */
"dd|SKIP_IF_PARENT_IS",
"dd|SKIP_IF_UNK3_IS",
#ifdef SIMON2
"ddddb|DRAW",
#else
"ddddd|DRAW",
#endif
"|CLEAR_PATHFIND_ARRAY",
/* 12 */
#ifdef SIMON2
"b|DELAY",
#else
"d|DELAY",
#endif
"d|OFFSET_X",
"d|OFFSET_Y",
"d|IDENT_WAKEUP",
/* 16 */
"d|IDENT_SLEEP",
"dq|SET_PATHFIND_ITEM",
"i|JUMP_REL",
"|CHAIN_TO",
/* 20 */
"dd|SET_CODE_WORD",
"i|JUMP_IF_CODE_WORD",
"dd|SET_PAL",
"d|SET_PRI",
/* 24 */
"diid|SET_IMG_XY",
"x|HALT_THREAD",
"ddddd|SET_WINDOW",
"|RESET",
/* 28 */
"dddd|DUMMY_3",
"|STOP_ALL_SOUNDS",
"d|SET_BASE_DELAY",
"d|SET_PALETTE_MODE",
/* 32 */
"vv|COPY_VAR",
"|FORCE_UNLOCK",
"|FORCE_LOCK",
"dd|DUMMY_4",
/* 36 */
"dd|SAVELOAD_THING",
"v|OFFSET_Y_F",
"v|SKIP_IF_VAR_ZERO",
"vd|SET_VAR",
/* 40 */
"vd|ADD_VAR",
"vd|SUB_VAR",
"vd|SLEEP_UNTIL_SET",
"d|SKIP_IF_BIT_CLEAR",
/* 44 */
"d|SKIP_IF_BIT_SET",
"v|SET_X_F",
"v|SET_Y_F",
"vv|ADD_VAR_F",
/* 48 */
"|VC_48",
"d|SET_BIT",
"d|CLEAR_BIT",
"d|CLEAR_HITAREA_BIT_0x40",
/* 52 */
"d|VC_52",
"dd|DUMMY_5",
"ddd|DUMMY_6",
"ddd|OFFSET_HIT_AREA",
/* 56 */
#ifdef SIMON2
"i|SLEEP_EX",
#else
"|DUMMY_7",
#endif
"|DUMMY_8",
"|DUMMY_9",
#ifdef SIMON2
"ddd|KILL_MULTI_THREAD",
#else
"|SKIP_IF_SOUND??",
#endif
/* 60 */
#ifdef SIMON2
"dd|KILL_THREAD",
#else
"d|KILL_THREAD",
#endif
"ddd|INIT_SPRITE",
"|PALETTE_THING",
"|PALETTE_THING_2",
#ifdef SIMON2
/* 64 */
"|UNK64",
"|UNK65",
"|UNK66",
"|UNK67",
/* 68 */
"|UNK68",
"dd|UNK69",
"dd|UNK70",
"|UNK71",
/* 72 */
"dd|UNK72",
"bb|UNK73",
"bb|UNK74",
#endif
};
void SimonState::dump_video_script(byte *src, bool one_opcode_only) {
uint opcode;
const char *str, *strn;
do {
if (!(_game & GAME_SIMON2)) {
opcode = READ_BE_UINT16_UNALIGNED(src);
src+=2;
} else {
opcode = *src++;
}
if (opcode >= gss->NUM_VIDEO_OP_CODES) {
error("Invalid opcode %x\n", opcode);
return;
}
strn = str = video_opcode_name_table[opcode];
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': fprintf(_dump_file,"%d ", READ_BE_UINT16_UNALIGNED(src)); src+=2; break;
case 'v': fprintf(_dump_file,"[%d] ", READ_BE_UINT16_UNALIGNED(src)); src+=2; break;
case 'i': fprintf(_dump_file,"%d ", (int16)READ_BE_UINT16_UNALIGNED(src)); src+=2; break;
case 'q':
while (READ_BE_UINT16_UNALIGNED(src) != 999) {
fprintf(_dump_file,"(%d,%d) ", READ_BE_UINT16_UNALIGNED(src), READ_BE_UINT16_UNALIGNED(src+2));
src += 4;
}
src++;
break;
default:
error("Invalid fmt string '%c' in decompile VGA", *str);
}
}
fprintf(_dump_file,"\n");
} while(!one_opcode_only);
}
void SimonState::dump_vga_file(byte *vga) {
{
byte *pp;
byte *p;
int count;
pp = vga;
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header*)pp)->hdr2_start);
count = READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2*)p)->id_count);
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2*)p)->id_table);
while (--count >= 0) {
int id = READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6*)p)->id);
dump_vga_script_always(vga + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6*)p)->script_offs), id/100, id);
p += sizeof(VgaFile1Struct0x6);
}
}
{
byte *bb, *b;
int c;
bb = vga;
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header*)bb)->hdr2_start);
c = READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2*)b)->unk1);
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2*)b)->unk2_offs);
while (--c >= 0) {
int id = READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8*)b)->id);
dump_vga_script_always(vga + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8*)b)->script_offs), id/100, id);
b += sizeof(VgaFile1Struct0x8);
}
}
}
const byte bmp_hdr[] = {
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,
};
void dump_bmp(const char *filename, int w, int h, const byte *bytes, const uint32 *palette) {
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));
*(uint32*)(my_hdr + 2) = w*h + 1024 + sizeof(bmp_hdr);
*(uint32*)(my_hdr + 18) = w;
*(uint32*)(my_hdr + 22) = h;
fwrite(my_hdr, 1, sizeof(my_hdr), out);
for(i=0; i!=256; i++,palette++) {
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) {
fwrite(bytes + h * ((w+3)&~3), ((w+3)&~3), 1, out);
}
fclose(out);
}
void dump_bitmap(const char *filename, byte *offs, int w, int h, int flags, const byte *palette, byte base) {
/* allocate */
byte *b = (byte*)malloc(w*h);
int i,j;
VC10_state state;
state.depack_cont = -0x80;
state.depack_src = offs;
state.dh = h;
state.y_skip = 0;
for(i=0; i!=w; i+=2) {
byte *c = vc_10_depack_column(&state);
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;
}
}
dump_bmp(filename, w, h, b, (uint32*)palette);
free(b);
}
void SimonState::dump_single_bitmap(int file, int image, byte *offs, int w, int h, byte base) {
/* Only supported for win32 atm. mkdir doesn't work otherwise. */
#if defined (WIN32) && !defined(_WIN32_WCE)
char buf[255], buf2[255];
struct stat statbuf;
sprintf(buf, "bmp_%d\\%d.bmp", file, image);
if (stat(buf, &statbuf) == 0)
return;
sprintf(buf2, "bmp_%d", file);
mkdir(buf2);
dump_bitmap(buf, offs, w, h, 0, _palette, base);
#endif
}
void SimonState::dump_vga_script_always(byte *ptr, uint res, uint sprite_id) {
fprintf(_dump_file,"; address=%x, vgafile=%d vgasprite=%d\n",
ptr - _vga_buffer_pointers[res].vgaFile1, res, sprite_id);
dump_video_script(ptr, false);
fprintf(_dump_file,"; end\n");
}
void SimonState::dump_vga_script(byte *ptr, uint res, uint sprite_id) {
dump_Vga_script_always(ptr,res,sprite_id);
}
#endif
--- NEW FILE: simonitems.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* 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: /cvsroot/scummvm/scummvm/simon/simonitems.cpp,v 1.1 2002/06/29 16:11:13 ender Exp $
*
[...1332 lines suppressed...]
_lock_word |= 0x4000;
_vc_ptr = (byte*)&items;
vc_60();
_lock_word &= ~0x4000;
}
/* OK */
void SimonState::o_unk26_helper(uint a, uint b, uint c, uint d, uint e, uint f, uint g, uint h) {
a &= 7;
if (_fcs_ptr_array_3[a])
fcs_delete(a);
_fcs_ptr_array_3[a] = fcs_alloc(b,c,d,e,f,g,h);
if (a == _fcs_unk_1) {
_fcs_ptr_1 = _fcs_ptr_array_3[a];
showmessage_helper_3(_fcs_ptr_1->unk6, _fcs_ptr_1->unk7);
}
}
--- NEW FILE: simonverb.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* 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: /cvsroot/scummvm/scummvm/simon/simonverb.cpp,v 1.1 2002/06/29 16:11:13 ender Exp $
*
*/
// Verb and hitarea handling
#include "stdafx.h"
#include "simon.h"
void SimonState::defocusHitarea() {
HitArea *last;
HitArea *ha;
if ((_game == GAME_SIMON2WIN) || (_game == GAME_SIMON2DOS)) {
if (_bit_array[4]&0x8000) {
o_unk_120(202);
_last_hitarea_2_ptr = NULL;
return;
}
}
last = _hitarea_ptr_5;
if (last == _hitarea_ptr_7)
return;
hitareaChangedHelper();
_hitarea_ptr_7 = last;
if (last != NULL && _hitarea_unk_6 &&
(ha = findHitAreaByID(200)) && (ha->flags&0x40) &&
!(last->flags&0x40))
focusVerb(last->id);
}
static const char * const verb_names[] = {
"Walk to",
"Look at",
"Open",
"Move",
"Consume",
"Pick up",
"Close",
"Use",
"Talk to",
"Remove",
"Wear",
"Give"
};
static const char * const verb_prep_names[] = {
"","","","",
"","","","with what ?",
"","","","to whom ?"
};
void SimonState::focusVerb(uint hitarea_id) {
uint x;
const char *txt;
hitarea_id -= 101;
CHECK_BOUNDS(hitarea_id, verb_prep_names);
if (_show_preposition) {
txt = verb_prep_names[hitarea_id];
} else {
txt = verb_names[hitarea_id];
}
x = (53 - strlen(txt)) * 3;
showActionString(x, (const byte*)txt);
}
void SimonState::showActionString(uint x, const byte *string) {
FillOrCopyStruct *fcs;
fcs = _fcs_ptr_array_3[1];
if (fcs == NULL || fcs->text_color==0)
return;
fcs->unk1 = x >> 3;
fcs->unk3 = x & 7;
for(;*string;string++)
video_putchar(fcs, *string);
}
void SimonState::hitareaChangedHelper() {
FillOrCopyStruct *fcs;
if ((_game == GAME_SIMON2WIN) || (_game == GAME_SIMON2WIN)) {
if (_bit_array[4]&0x8000)
return;
}
fcs = _fcs_ptr_array_3[1];
if (fcs != NULL && fcs->text_color != 0)
video_fill_or_copy_from_3_to_2(fcs);
_last_hitarea_2_ptr = NULL;
_hitarea_ptr_7 = NULL;
}
HitArea *SimonState::findHitAreaByID(uint hitarea_id) {
HitArea *ha = _hit_areas;
uint count = ARRAYSIZE(_hit_areas);
do{
if (ha->id == hitarea_id)
return ha;
} while(ha++,--count);
return NULL;
}
HitArea *SimonState::findEmptyHitArea() {
HitArea *ha = _hit_areas;
uint count = ARRAYSIZE(_hit_areas);
do{
if (ha->flags == 0)
return ha;
} while(ha++,--count);
return NULL;
}
void SimonState::clear_hitarea_bit_0x40(uint hitarea) {
HitArea *ha = findHitAreaByID(hitarea);
if (ha != NULL)
ha->flags &= ~0x40;
}
void SimonState::set_hitarea_bit_0x40(uint hitarea) {
HitArea *ha = findHitAreaByID(hitarea);
if (ha != NULL) {
ha->flags |= 0x40;
ha->flags &= ~2;
if (hitarea == 102)
hitarea_proc_1();
}
}
void SimonState::set_hitarea_x_y(uint hitarea, int x, int y) {
HitArea *ha = findHitAreaByID(hitarea);
if (ha != NULL) {
ha->x = x;
ha->y = y;
}
}
void SimonState::delete_hitarea(uint hitarea) {
HitArea *ha = findHitAreaByID(hitarea);
if (ha != NULL) {
ha->flags = 0;
if (ha == _last_hitarea_2_ptr)
defocusHitarea();
_need_hitarea_recalc++;
}
}
bool SimonState::is_hitarea_0x40_clear(uint hitarea) {
HitArea *ha = findHitAreaByID(hitarea);
if (ha == NULL)
return false;
return (ha->flags & 0x40) == 0;
}
void SimonState::addNewHitArea(int id, int x, int y, int width, int height,
int flags, int unk3,Item *item_ptr) {
HitArea *ha;
delete_hitarea(id);
ha = findEmptyHitArea();
ha->x = x;
ha->y = y;
ha->width = width;
ha->height = height;
ha->flags = flags | 0x20;
ha->id = ha->layer = id;
ha->unk3 = unk3;
ha->item_ptr = item_ptr;
_need_hitarea_recalc++;
}
void SimonState::hitarea_proc_1() {
uint id;
HitArea *ha;
if (_game & GAME_SIMON2) {
id=2;
if (!(_bit_array[4]&0x8000))
id = (_mouse_y >= 136) ? 102 : 101;
} else {
id = (_mouse_y >= 136) ? 102 : 101;
}
_hitarea_unk_4 = id;
ha = findHitAreaByID(id);
if (ha == NULL)
return;
if (ha->flags & 0x40) {
_hitarea_unk_4 = 999;
_hitarea_ptr_5 = NULL;
} else {
_verb_hitarea = ha->unk3;
handle_verb_hitarea(ha);
}
}
void SimonState::handle_verb_hitarea(HitArea *ha) {
HitArea *tmp = _hitarea_ptr_5;
if (ha == tmp)
return;
if (!(_game & GAME_SIMON2)) {
if (tmp != NULL) {
tmp->flags |= 8;
video_toggle_colors(tmp, 0xd5, 0xd0, 0xd5, 0xA);
}
if (ha->flags & 2)
video_toggle_colors(ha, 0xda, 0xd5, 0xd5, 5);
else
video_toggle_colors(ha, 0xdf, 0xda, 0xda, 0xA);
ha->flags &= ~ (2 + 8);
} else {
if (ha->id<101)
return;
_mouse_cursor = ha->id - 101;
_need_hitarea_recalc++;
}
_hitarea_ptr_5 = ha;
}
void SimonState::hitarea_leave(HitArea *ha) {
if (!(_game & GAME_SIMON2)) {
video_toggle_colors(ha, 0xdf, 0xd5, 0xda, 5);
} else {
video_toggle_colors(ha, 0xe7, 0xe5, 0xe6, 1);
}
}
void SimonState::leaveHitAreaById(uint hitarea_id) {
HitArea *ha = findHitAreaByID(hitarea_id);
if (ha)
hitarea_leave(ha);
}
void SimonState::handle_unk2_hitarea(FillOrCopyStruct *fcs) {
uint index;
index = get_fcs_ptr_3_index(fcs);
if (fcs->fcs_data->unk1 == 0)
return;
lock();
fcs_unk_proc_1(index, fcs->fcs_data->item_ptr,
fcs->fcs_data->unk1-1, fcs->fcs_data->unk2);
unlock();
}
void SimonState::handle_unk_hitarea(FillOrCopyStruct *fcs) {
uint index;
index = get_fcs_ptr_3_index(fcs);
lock();
fcs_unk_proc_1(index, fcs->fcs_data->item_ptr,
fcs->fcs_data->unk1+1, fcs->fcs_data->unk2);
unlock();
}
void SimonState::setup_hitarea_from_pos(uint x, uint y, uint mode) {
HitArea *best_ha;
if (_game & GAME_SIMON2) {
if (_bit_array[4]&0x8000 || y < 134) {
x += _x_scroll * 8;
}
}
{
HitArea *ha = _hit_areas;
uint count = ARRAYSIZE(_hit_areas);
uint16 layer = 0;
const uint16 x_ = x;
const uint16 y_ = y;
best_ha = NULL;
do{
if (ha->flags & 0x20) {
if (!(ha->flags & 0x40)) {
if (x_ >= ha->x && y_ >= ha->y &&
x_ - ha->x < ha->width && y_- ha->y < ha->height &&
layer <= ha->layer) {
layer = ha->layer;
best_ha = ha;
} else {
if (ha->flags & 2) {
hitarea_leave(ha);
ha->flags &=~2;
}
}
} else {
ha->flags &= ~2;
}
}
} while(ha++,--count);
}
if (best_ha == NULL) {
defocusHitarea();
return;
}
if (mode != 0 && mode != 3) {
_last_hitarea = best_ha;
_variableArray[1] = x;
_variableArray[2] = y;
}
if (best_ha->flags&4) {
defocusHitarea();
} else if (best_ha != _last_hitarea_2_ptr) {
new_current_hitarea(best_ha);
}
if (best_ha->flags&8 && !(best_ha->flags&2)) {
hitarea_leave(best_ha);
best_ha->flags |= 2;
}
return;
}
void SimonState::new_current_hitarea(HitArea *ha) {
bool result;
hitareaChangedHelper();
if (ha->flags & 1) {
result = hitarea_proc_2(ha->flags>>8);
} else {
result = hitarea_proc_3(ha->item_ptr);
}
if (result)
_last_hitarea_2_ptr = ha;
}
bool SimonState::hitarea_proc_2(uint a) {
uint x;
const byte *string_ptr;
if (_game & GAME_SIMON2) {
if (_bit_array[4]&0x8000) {
Subroutine *sub;
_variableArray[84] = a;
sub = getSubroutineByID(5003);
if (sub != NULL)
startSubroutineEx(sub);
return true;
}
}
if (a >= 20)
return false;
string_ptr = getStringPtrByID(_stringid_array_2[a]);
x = (53 - (strlen((const char*)string_ptr) - 1)) * 3;
showActionString(x, string_ptr);
return true;
}
bool SimonState::hitarea_proc_3(Item *item) {
Child2 *child2;
uint x;
const byte *string_ptr;
if (item == 0 || item==&_dummy_item_2 || item == &_dummy_item_3)
return false;
child2 = findChildOfType2(item);
if (child2 == NULL)
return false;
string_ptr = getStringPtrByID(child2->string_id);
x = (53 - (strlen((const char*)string_ptr) - 1)) * 3;
showActionString(x, string_ptr);
return true;
}
--- NEW FILE: simonvga.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* 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: /cvsroot/scummvm/scummvm/simon/simonvga.cpp,v 1.1 2002/06/29 16:11:13 ender Exp $
*
[...1797 lines suppressed...]
void SimonState::vc_72() { // Simon2
uint16 a = vc_read_next_word();
uint16 b = vc_read_next_word();
if (a != _vc72_var1) {
_vc72_var2 = b;
_vc72_var3 = a;
}
warning("vc_72(%d,%d): music stuff?", a, b);
}
void SimonState::vc_73() { // Simon2
vc_read_next_byte();
_op_189_flags |= 1<<vc_read_next_byte();
}
void SimonState::vc_74() { // Simon2
vc_read_next_byte();
_op_189_flags &= ~(1<<vc_read_next_byte());
}
Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- simon.cpp 29 Jun 2002 10:28:43 -0000 1.36
+++ simon.cpp 29 Jun 2002 16:11:12 -0000 1.37
@@ -19,23 +19,9 @@
*
*/
-
#include "stdafx.h"
-#include "scummsys.h"
-#include "system.h"
-#include "../sound/mixer.h"
#include "simon.h"
-
[...4908 lines suppressed...]
- /* Setup midi driver */
- s->midi.set_driver(driver);
-
- /* Setup mixer */
- if (!s->_mixer->bind_to_system(syst))
- warning("Sound initialization failed. "
- "Features of the game that depend on sound synchronization will most likely break");
-
- return s;
-
-}
-
void SimonState::set_volume(byte volume) {
_mixer->set_volume(volume * 256 / 100);
}
+
+byte SimonState::getByte() {
+ return *_code_ptr++;
+}
Index: simon.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- simon.h 18 Jun 2002 08:38:39 -0000 1.19
+++ simon.h 29 Jun 2002 16:11:13 -0000 1.20
@@ -19,9 +19,11 @@
*
*/
-/* GFX Settings. Sound & Music only works properly with SIMON1WIN */
-#define USE_SOUND
-#define USE_MUSIC
+#include <time.h>
+#include <sys/stat.h>
+#include "scummsys.h"
+#include "system.h"
+#include "../sound/mixer.h"
/* Various other settings */
//#define DUMP_CONTINOUS_MAINSCRIPT
@@ -42,10 +44,11 @@
uint32 fileReadLE32(FILE *in);
void fileWriteBE32(FILE *in, uint32 value);
void fileWriteBE16(FILE *in, uint16 value);
-
+uint fileReadItemID(FILE *in);
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
#define CHECK_BOUNDS(x,y) assert((uint)(x)<ARRAYSIZE(y))
+#define NUM_PALETTE_FADEOUT 32
struct Child {
Child *next;
@@ -236,7 +239,6 @@
};
int GetAsyncKeyState(int key);
-
#endif
class MidiDriver;
@@ -415,9 +417,7 @@
uint32 _last_vga_tick;
-//#ifdef SIMON2
uint16 _op_189_flags;
-//#endif
bool _scriptvar_2;
bool _run_script_return_1;
@@ -438,14 +438,9 @@
bool _dx_use_3_or_4_for_lock;
bool _mouse_pos_changed;
-
-//#ifdef SIMON2
bool _vk_t_toggle;
byte _mouse_cursor;
bool _vga_var9;
-//#endif
-
-//#ifdef SIMON2
int16 _script_unk_1;
bool _vga_var6;
int _x_scroll,_vga_var1,_vga_var2,_vga_var3,_vga_var5;
@@ -454,9 +449,6 @@
uint16 _vc72_var1, _vc72_var2, _vc72_var3;
uint16 _vc70_var1, _vc70_var2;
byte *_vga_var7;
-//#else
-// int _script_unk_1;
-//#endif
int16 _script_cond_a, _script_cond_b, _script_cond_c;
@@ -522,10 +514,6 @@
uint _invoke_timer_callback;
-// uint32 _voice_size;
-
-// uint32 _sound_size;
-// byte *_sound_ptr;
uint _vga_sprite_changed;
@@ -574,8 +562,6 @@
VgaSprite _vga_sprites[180];
VgaSleepStruct _vga_sleep_structs[30];
-// uint16 _unk21_word_array[32]; /* should be initialized to ones */
-
uint16 *_pathfind_array[20];
uint8 _palette_backup[1024];
@@ -852,6 +838,7 @@
void run_vga_script();
+ // Simon1/Simon2 video script opcodes
void vc_1();
void vc_2();
void vc_3();
@@ -917,7 +904,7 @@
void vc_62();
void vc_63();
-//#ifdef SIMON2
+ // Simon2 specific Video Script Opcodes
void vc_64();
void vc_65();
void vc_66();
@@ -929,7 +916,6 @@
void vc_72();
void vc_73();
void vc_74();
-//#endif
void delete_vga_timer(VgaTimerEntry *vte);
void vc_resume_thread(byte *code_ptr, uint16 cur_file, uint16 cur_sprite);
@@ -992,11 +978,15 @@
void dx_clear_surfaces(uint num_lines);
void dx_update_screen_and_palette();
+#ifdef SIMONDEBUG
void dump_video_script(byte *src, bool one_opcode_only);
void dump_vga_file(byte *vga);
+ void dump_vga_script(byte *ptr, uint res, uint sprite_id);
+ void dump_vga_script_always(byte *ptr, uint res, uint sprite_id);
void dump_vga_bitmaps(byte *vga, byte *vga1, int res);
void dump_single_bitmap(int file, int image, byte *offs, int w, int h, byte base);
-
+#endif
+
void dx_clear_attached_from_top(uint lines);
void dx_copy_from_attached_to_2(uint x, uint y, uint w, uint h);
void dx_copy_from_attached_to_3(uint lines);
@@ -1009,9 +999,7 @@
byte *vc_10_depack_swap(byte *src, uint w, uint h);
- void dump_vga_script(byte *ptr, uint res, uint sprite_id);
- void dump_vga_script_always(byte *ptr, uint res, uint sprite_id);
-
+
Item *getNextItemPtrStrange();
bool save_game(uint slot, const char *caption);
@@ -1027,16 +1015,10 @@
void playVoice(uint voice);
void playSound(uint sound);
-
-// void generateSound(byte *ptr, int len);
-
void playMusic(uint music);
-
void checkTimerCallback();
-
void delay(uint delay);
-//#ifdef SIMON2
void o_190_helper(uint i);
void vc_58();
void timer_vga_sprites_helper();
@@ -1044,7 +1026,6 @@
void vc_10_helper_8(byte *dst, byte *src);
void scroll_timeout();
void hitarea_stuff_helper_2();
-//#endif
void realizePalette();
void vc_kill_thread(uint file, uint sprite);
@@ -1074,10 +1055,6 @@
void NORETURN CDECL error(const char *errmsg, ...);
void CDECL warning(const char *errmsg, ...);
-//uint16 swap16(uint16 a);
-//uint32 swap32(uint32 a);
-
-
void _2xSaI (uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr, uint8 *dstPtr, uint32 dstPitch, int width, int height);
int Init_2xSaI (uint32 BitFormat);
void Super2xSaI (uint8 *srcPtr, uint32 srcPitch,
@@ -1085,6 +1062,82 @@
int width, int height);
void initializeHardware();
void dx_set_palette(uint32 *colors, uint num);
+void palette_fadeout(uint32 *pal_values,uint num);
+
+static const GameSpecificSettings simon1_settings = {
+ 1, /* VGA_DELAY_BASE */
+ 1576/4, /* TABLE_INDEX_BASE */
+ 1460/4, /* TEXT_INDEX_BASE */
+ 1700/4, /* NUM_GAME_OFFSETS */
+ 64, /* NUM_VIDEO_OP_CODES */
+ 1000000, /* VGA_MEM_SIZE */
+ 50000, /* TABLES_MEM_SIZE */
+ 3624, /* NUM_VOICE_RESOURCES */
+ 141, /* NUM_EFFECT_RESOURCES */
+ 1316/4, /* MUSIC_INDEX_BASE */
+ 0, /* SOUND_INDEX_BASE */
+ "SIMON.GME", /* gme_filename */
+ "SIMON.WAV", /* wav_filename */
+ "SIMON.VOC", /* wav_filename2 */
+ "EFFECTS.VOC", /* effects_filename */
+ "GAMEPC", /* gamepc_filename */
+};
+
+static const GameSpecificSettings simon2_settings = {
+ 5, /* VGA_DELAY_BASE */
+ 1580/4, /* TABLE_INDEX_BASE */
+ 1500/4, /* TEXT_INDEX_BASE */
+ 2116/4, /* NUM_GAME_OFFSETS */
+ 75, /* NUM_VIDEO_OP_CODES */
+ 2000000, /* VGA_MEM_SIZE */
+ 100000, /* TABLES_MEM_SIZE */
+ 12256, /* NUM_VOICE_RESOURCES */
+ 0,
+ 1128/4, /* MUSIC_INDEX_BASE */
+ 1660/4, /* SOUND_INDEX_BASE */
+ "SIMON2.GME", /* gme_filename */
+ "SIMON2.WAV", /* wav_filename */
+ NULL,
+ "",
+ "GSPTR30", /* gamepc_filename */
+};
+
+static const GameSpecificSettings simon2win_settings = {
+ 5, /* VGA_DELAY_BASE */
+ 1580/4, /* TABLE_INDEX_BASE */
+ 1500/4, /* TEXT_INDEX_BASE */
+ 2116/4, /* NUM_GAME_OFFSETS */
+ 75, /* NUM_VIDEO_OP_CODES */
+ 2000000, /* VGA_MEM_SIZE */
+ 100000, /* TABLES_MEM_SIZE */
+ 12256, /* NUM_VOICE_RESOURCES */
+ 0,
+ 1128/4, /* MUSIC_INDEX_BASE */
+ 1660/4, /* SOUND_INDEX_BASE */
+ "SIMON2.GME", /* gme_filename */
+ "SIMON2.WAV", /* wav_filename */
+ NULL,
+ "",
+ "GSPTR30", /* gamepc_filename */
+};
+
+static const GameSpecificSettings simon2dos_settings = {
+ 5, /* VGA_DELAY_BASE */
+ 1580/4, /* TABLE_INDEX_BASE */
+ 1500/4, /* TEXT_INDEX_BASE */
+ 2116/4, /* NUM_GAME_OFFSETS */
+ 75, /* NUM_VIDEO_OP_CODES */
+ 2000000, /* VGA_MEM_SIZE */
+ 100000, /* TABLES_MEM_SIZE */
+ 12256, /* NUM_VOICE_RESOURCES */
+ 0,
+ 1128/4, /* MUSIC_INDEX_BASE */
+ 1660/4, /* SOUND_INDEX_BASE */
+ "SIMON2.GME", /* gme_filename */
+ "SIMON2.WAV", /* wav_filename */
+ NULL,
+ "",
+ "GAME32", /* gamepc_filename */
+};
+
-//extern byte *sdl_buf;
-//extern byte *sdl_buf_attached;
Index: simonsys.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simonsys.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- simonsys.cpp 5 May 2002 20:04:26 -0000 1.8
+++ simonsys.cpp 29 Jun 2002 16:11:13 -0000 1.9
@@ -19,28 +19,9 @@
*
*/
-
#include "stdafx.h"
-#include "scummsys.h"
-#include "system.h"
-#include "../sound/mixer.h"
#include "simon.h"
-#include <stdarg.h>
-
-#ifdef WIN32
-#include <conio.h>
-#endif
-
-//uint16 swap16(uint16 a) {
-// return (a>>8)|(a<<8);
-//}
-
-//uint32 swap32(uint32 a) {
-// return (a>>24)|(a>>8)&0xFF00|(a<<8)&0xFF0000|(a<<24);
-//}
-
-
uint fileReadByte(FILE *in) {
byte b;
fread(&b, sizeof(b), 1, in);
@@ -84,41 +65,10 @@
-#if 0
-void NORETURN CDECL error(const char *s, ...) {
- char buf[1024];
- va_list va;
-
- va_start(va, s);
- vsprintf(buf, s, va);
- va_end(va);
-#ifdef WIN32
- fprintf(stderr, "Error: %s!\nPress a key to quit.\n", buf);
- _getch();
-#else
- fprintf(stderr, "Error: %s!\n", buf);
-#endif
- exit(1);
-
-}
-
-void CDECL warning(const char *s, ...) {
- char buf[1024];
- va_list va;
-
- va_start(va, s);
- vsprintf(buf, s, va);
- va_end(va);
- fprintf(stdout, "Warning: %s!\n", buf);
-}
-#endif
-
#ifndef WIN32
/* GetAsyncKeyState for unix */
int GetAsyncKeyState(int key) {
return 0;
}
-
-
#endif
More information about the Scummvm-git-logs
mailing list