2002-06-29 16:11:13 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2001-2005 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Video script opcodes for Simon1/Simon2
|
|
|
|
#include "stdafx.h"
|
2002-08-21 16:07:07 +00:00
|
|
|
#include "simon/simon.h"
|
|
|
|
#include "simon/intern.h"
|
2002-10-22 12:05:04 +00:00
|
|
|
#include "simon/vga.h"
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
|
|
|
|
2003-10-03 19:42:27 +00:00
|
|
|
namespace Simon {
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
typedef void (SimonEngine::*VgaOpcodeProc) ();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
// Opcode tables
|
|
|
|
static const VgaOpcodeProc vga_opcode_table[] = {
|
2002-07-07 19:06:48 +00:00
|
|
|
NULL,
|
2003-06-01 09:41:56 +00:00
|
|
|
&SimonEngine::vc_1_dummy_op,
|
|
|
|
&SimonEngine::vc_2_call,
|
|
|
|
&SimonEngine::vc_3_new_sprite,
|
|
|
|
&SimonEngine::vc_4_dummy_op,
|
|
|
|
&SimonEngine::vc_5_skip_if_neq,
|
|
|
|
&SimonEngine::vc_6_skip_ifn_sib_with_a,
|
|
|
|
&SimonEngine::vc_7_skip_if_sib_with_a,
|
|
|
|
&SimonEngine::vc_8_skip_if_parent_is,
|
|
|
|
&SimonEngine::vc_9_skip_if_unk3_is,
|
|
|
|
&SimonEngine::vc_10_draw,
|
|
|
|
&SimonEngine::vc_11_clear_pathfind_array,
|
|
|
|
&SimonEngine::vc_12_delay,
|
|
|
|
&SimonEngine::vc_13_set_sprite_offset_x,
|
|
|
|
&SimonEngine::vc_14_set_sprite_offset_y,
|
|
|
|
&SimonEngine::vc_15_wakeup_id,
|
|
|
|
&SimonEngine::vc_16_sleep_on_id,
|
|
|
|
&SimonEngine::vc_17_set_pathfind_item,
|
|
|
|
&SimonEngine::vc_18_jump_rel,
|
|
|
|
&SimonEngine::vc_19_chain_to_script,
|
|
|
|
&SimonEngine::vc_20_set_code_word,
|
|
|
|
&SimonEngine::vc_21_jump_if_code_word,
|
|
|
|
&SimonEngine::vc_22_set_sprite_palette,
|
|
|
|
&SimonEngine::vc_23_set_sprite_priority,
|
|
|
|
&SimonEngine::vc_24_set_sprite_xy,
|
|
|
|
&SimonEngine::vc_25_halt_sprite,
|
|
|
|
&SimonEngine::vc_26_set_window,
|
|
|
|
&SimonEngine::vc_27_reset,
|
|
|
|
&SimonEngine::vc_28_dummy_op,
|
|
|
|
&SimonEngine::vc_29_stop_all_sounds,
|
|
|
|
&SimonEngine::vc_30_set_base_delay,
|
|
|
|
&SimonEngine::vc_31_set_palette_mode,
|
|
|
|
&SimonEngine::vc_32_copy_var,
|
|
|
|
&SimonEngine::vc_33_force_unlock,
|
|
|
|
&SimonEngine::vc_34_force_lock,
|
|
|
|
&SimonEngine::vc_35,
|
|
|
|
&SimonEngine::vc_36_saveload_thing,
|
|
|
|
&SimonEngine::vc_37_set_sprite_offset_y,
|
|
|
|
&SimonEngine::vc_38_skip_if_var_zero,
|
|
|
|
&SimonEngine::vc_39_set_var,
|
|
|
|
&SimonEngine::vc_40_var_add,
|
|
|
|
&SimonEngine::vc_41_var_sub,
|
|
|
|
&SimonEngine::vc_42_delay_if_not_eq,
|
|
|
|
&SimonEngine::vc_43_skip_if_bit_clear,
|
|
|
|
&SimonEngine::vc_44_skip_if_bit_set,
|
|
|
|
&SimonEngine::vc_45_set_sprite_x,
|
|
|
|
&SimonEngine::vc_46_set_sprite_y,
|
|
|
|
&SimonEngine::vc_47_add_var_f,
|
|
|
|
&SimonEngine::vc_48,
|
|
|
|
&SimonEngine::vc_49_set_bit,
|
|
|
|
&SimonEngine::vc_50_clear_bit,
|
|
|
|
&SimonEngine::vc_51_clear_hitarea_bit_0x40,
|
|
|
|
&SimonEngine::vc_52_play_sound,
|
|
|
|
&SimonEngine::vc_53_no_op,
|
|
|
|
&SimonEngine::vc_54_no_op,
|
|
|
|
&SimonEngine::vc_55_offset_hit_area,
|
2003-10-26 04:35:35 +00:00
|
|
|
&SimonEngine::vc_56_delay,
|
2003-06-01 09:41:56 +00:00
|
|
|
&SimonEngine::vc_57_no_op,
|
|
|
|
&SimonEngine::vc_58,
|
|
|
|
&SimonEngine::vc_59,
|
|
|
|
&SimonEngine::vc_60_kill_sprite,
|
|
|
|
&SimonEngine::vc_61_sprite_change,
|
|
|
|
&SimonEngine::vc_62_palette_thing,
|
|
|
|
&SimonEngine::vc_63_palette_thing_2,
|
|
|
|
&SimonEngine::vc_64_skip_if_no_speech,
|
|
|
|
&SimonEngine::vc_65_palette_thing_3,
|
|
|
|
&SimonEngine::vc_66_skip_if_nz,
|
|
|
|
&SimonEngine::vc_67_skip_if_ge,
|
|
|
|
&SimonEngine::vc_68_skip_if_le,
|
|
|
|
&SimonEngine::vc_69_play_track,
|
|
|
|
&SimonEngine::vc_70_queue_music,
|
|
|
|
&SimonEngine::vc_71_check_music_queue,
|
|
|
|
&SimonEngine::vc_72_play_track_2,
|
|
|
|
&SimonEngine::vc_73_set_op189_flag,
|
|
|
|
&SimonEngine::vc_74_clear_op189_flag,
|
2002-06-29 16:11:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Script parser
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::run_vga_script() {
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint opcode;
|
|
|
|
|
2003-03-06 19:16:24 +00:00
|
|
|
if (_continous_vgascript) {
|
2004-12-18 01:33:21 +00:00
|
|
|
if (_vc_ptr != (const byte *)&_vc_get_out_of_code) {
|
2003-03-06 19:16:24 +00:00
|
|
|
fprintf(_dump_file, "%.5d %.5X: %5d %4d ", _vga_tick_counter, _vc_ptr - _cur_vga_file_1, _vga_cur_sprite_id, _vga_cur_file_id);
|
|
|
|
dump_video_script(_vc_ptr, true);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
2003-06-14 18:52:30 +00:00
|
|
|
opcode = READ_BE_UINT16(_vc_ptr);
|
2002-06-29 16:11:13 +00:00
|
|
|
_vc_ptr += 2;
|
|
|
|
} else {
|
|
|
|
opcode = *_vc_ptr++;
|
|
|
|
}
|
|
|
|
|
2003-12-01 00:45:16 +00:00
|
|
|
if (opcode >= NUM_VIDEO_OP_CODES)
|
2002-06-29 16:11:13 +00:00
|
|
|
error("Invalid VGA opcode '%d' encountered", opcode);
|
|
|
|
|
|
|
|
if (opcode == 0)
|
|
|
|
return;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
(this->*vga_opcode_table[opcode]) ();
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
int SimonEngine::vc_read_var_or_word() {
|
2002-06-29 16:11:13 +00:00
|
|
|
int16 var = vc_read_next_word();
|
|
|
|
if (var < 0)
|
|
|
|
var = vc_read_var(-var);
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
uint SimonEngine::vc_read_next_word() {
|
2003-06-14 18:52:30 +00:00
|
|
|
uint a = READ_BE_UINT16(_vc_ptr);
|
2002-06-29 16:11:13 +00:00
|
|
|
_vc_ptr += 2;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
uint SimonEngine::vc_read_next_byte() {
|
2002-06-29 16:11:13 +00:00
|
|
|
return *_vc_ptr++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_skip_next_instruction() {
|
2002-06-29 16:11:13 +00:00
|
|
|
static const byte opcode_param_len_simon1[] = {
|
2002-07-07 19:06:48 +00:00
|
|
|
0, 6, 2, 10, 6, 4, 2, 2,
|
|
|
|
4, 4, 10, 0, 2, 2, 2, 2,
|
2002-06-29 16:11:13 +00:00
|
|
|
2, 0, 2, 0, 4, 2, 4, 2,
|
2002-07-07 19:06:48 +00:00
|
|
|
8, 0, 10, 0, 8, 0, 2, 2,
|
2002-06-29 16:11:13 +00:00
|
|
|
4, 0, 0, 4, 4, 2, 2, 4,
|
|
|
|
4, 4, 4, 2, 2, 2, 2, 4,
|
|
|
|
0, 2, 2, 2, 2, 4, 6, 6,
|
|
|
|
0, 0, 0, 0, 2, 6, 0, 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const byte opcode_param_len_simon2[] = {
|
|
|
|
0, 6, 2, 12, 6, 4, 2, 2,
|
|
|
|
4, 4, 9, 0, 1, 2, 2, 2,
|
|
|
|
2, 0, 2, 0, 4, 2, 4, 2,
|
|
|
|
7, 0, 10, 0, 8, 0, 2, 2,
|
|
|
|
4, 0, 0, 4, 4, 2, 2, 4,
|
|
|
|
4, 4, 4, 2, 2, 2, 2, 4,
|
|
|
|
0, 2, 2, 2, 2, 4, 6, 6,
|
|
|
|
2, 0, 6, 6, 4, 6, 0, 0,
|
|
|
|
0, 0, 4, 4, 4, 4, 4, 0,
|
|
|
|
4, 2, 2
|
|
|
|
};
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint opcode = vc_read_next_byte();
|
|
|
|
_vc_ptr += opcode_param_len_simon2[opcode];
|
|
|
|
} else {
|
|
|
|
uint opcode = vc_read_next_word();
|
|
|
|
_vc_ptr += opcode_param_len_simon1[opcode];
|
|
|
|
}
|
|
|
|
|
2002-12-01 08:56:04 +00:00
|
|
|
if (_continous_vgascript)
|
2002-11-20 06:33:12 +00:00
|
|
|
fprintf(_dump_file, "; skipped\n");
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_read_vgares_23() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon1 Only
|
2002-06-29 16:11:13 +00:00
|
|
|
if (_vga_res_328_loaded == true) {
|
|
|
|
_vga_res_328_loaded = false;
|
|
|
|
_lock_word |= 0x4000;
|
|
|
|
read_vga_from_datfile_1(23);
|
|
|
|
_lock_word &= ~0x4000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_read_vgares_328() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon1 Only
|
2002-06-29 16:11:13 +00:00
|
|
|
if (_vga_res_328_loaded == false) {
|
|
|
|
_vga_res_328_loaded = true;
|
|
|
|
_lock_word |= 0x4000;
|
|
|
|
read_vga_from_datfile_1(328);
|
|
|
|
_lock_word &= ~0x4000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VGA Script commands
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_1_dummy_op() {
|
2002-06-29 16:11:13 +00:00
|
|
|
/* dummy opcode */
|
|
|
|
_vc_ptr += 6;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_2_call() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaPointersEntry *vpe;
|
|
|
|
uint num;
|
|
|
|
uint res;
|
|
|
|
byte *old_file_1, *old_file_2;
|
2004-12-18 01:33:21 +00:00
|
|
|
byte *b, *bb;
|
|
|
|
const byte *vc_ptr_org;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
num = vc_read_var_or_word();
|
|
|
|
|
|
|
|
old_file_1 = _cur_vga_file_1;
|
|
|
|
old_file_2 = _cur_vga_file_2;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
2002-06-29 16:11:13 +00:00
|
|
|
res = num / 100;
|
|
|
|
vpe = &_vga_buffer_pointers[res];
|
|
|
|
|
|
|
|
_cur_vga_file_1 = vpe->vgaFile1;
|
|
|
|
_cur_vga_file_2 = vpe->vgaFile2;
|
|
|
|
if (vpe->vgaFile1 != NULL)
|
|
|
|
break;
|
|
|
|
if (_vga_cur_file_2 != res)
|
|
|
|
_video_var_7 = _vga_cur_file_2;
|
|
|
|
|
|
|
|
ensureVgaResLoaded(res);
|
|
|
|
_video_var_7 = 0xFFFF;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
bb = _cur_vga_file_1;
|
2003-06-14 18:52:30 +00:00
|
|
|
b = bb + READ_BE_UINT16(&((VgaFile1Header *) bb)->hdr2_start);
|
|
|
|
b = bb + READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk2_offs);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-06-14 18:52:30 +00:00
|
|
|
while (READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->id) != num)
|
2002-06-29 16:11:13 +00:00
|
|
|
b += sizeof(VgaFile1Struct0x8);
|
|
|
|
|
|
|
|
vc_ptr_org = _vc_ptr;
|
|
|
|
|
2003-06-14 18:52:30 +00:00
|
|
|
_vc_ptr = _cur_vga_file_1 + READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->script_offs);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-11-29 09:09:35 +00:00
|
|
|
//dump_vga_script(_vc_ptr, res, num);
|
2002-06-29 16:11:13 +00:00
|
|
|
run_vga_script();
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
_cur_vga_file_1 = old_file_1;
|
|
|
|
_cur_vga_file_2 = old_file_2;
|
|
|
|
|
|
|
|
_vc_ptr = vc_ptr_org;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_3_new_sprite() {
|
2003-10-21 11:41:33 +00:00
|
|
|
uint16 a, f, base_color, x, y, vga_sprite_id;
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 res;
|
|
|
|
VgaSprite *vsp;
|
|
|
|
VgaPointersEntry *vpe;
|
2002-07-07 19:06:48 +00:00
|
|
|
byte *p, *pp;
|
2003-07-14 12:00:20 +00:00
|
|
|
byte *old_file_1;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
a = vc_read_next_word(); /* 0 */
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-07-07 19:06:48 +00:00
|
|
|
f = vc_read_next_word(); /* 0 */
|
2003-10-21 11:41:33 +00:00
|
|
|
vga_sprite_id = vc_read_next_word(); /* 2 */
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
2003-10-21 11:41:33 +00:00
|
|
|
vga_sprite_id = vc_read_next_word(); /* 2 */
|
|
|
|
f = vga_sprite_id / 100;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-10-21 10:34:56 +00:00
|
|
|
x = vc_read_next_word(); /* 4 */
|
|
|
|
y = vc_read_next_word(); /* 6 */
|
|
|
|
base_color = vc_read_next_word(); /* 8 */
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
/* 2nd param ignored with simon1 */
|
2003-10-21 11:45:46 +00:00
|
|
|
if (has_vga_sprite_with_id(vga_sprite_id, f))
|
2002-06-29 16:11:13 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
vsp = _vga_sprites;
|
2002-07-07 19:06:48 +00:00
|
|
|
while (vsp->id)
|
|
|
|
vsp++;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-10-21 10:34:56 +00:00
|
|
|
vsp->base_color = base_color;
|
2002-06-29 16:11:13 +00:00
|
|
|
vsp->unk6 = a;
|
2002-11-28 00:22:24 +00:00
|
|
|
vsp->priority = 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
vsp->unk4 = 0;
|
|
|
|
vsp->image = 0;
|
2003-10-21 10:34:56 +00:00
|
|
|
vsp->x = x;
|
|
|
|
vsp->y = y;
|
2003-10-21 11:41:33 +00:00
|
|
|
vsp->id = vga_sprite_id;
|
2002-06-29 16:11:13 +00:00
|
|
|
vsp->unk7 = res = f;
|
|
|
|
|
2003-07-14 12:00:20 +00:00
|
|
|
old_file_1 = _cur_vga_file_1;
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
2002-06-29 16:11:13 +00:00
|
|
|
vpe = &_vga_buffer_pointers[res];
|
|
|
|
_cur_vga_file_1 = vpe->vgaFile1;
|
|
|
|
|
|
|
|
if (vpe->vgaFile1 != NULL)
|
|
|
|
break;
|
2003-10-16 09:41:35 +00:00
|
|
|
if (_vga_cur_file_2 != res)
|
2003-07-14 12:00:20 +00:00
|
|
|
_video_var_7 = _vga_cur_file_2;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
ensureVgaResLoaded(res);
|
|
|
|
_video_var_7 = 0xFFFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
pp = _cur_vga_file_1;
|
2003-06-14 18:52:30 +00:00
|
|
|
p = pp + READ_BE_UINT16(&((VgaFile1Header *) pp)->hdr2_start);
|
|
|
|
p = pp + READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_table);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2003-10-21 11:41:33 +00:00
|
|
|
while (READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->id) != vga_sprite_id)
|
2002-06-29 16:11:13 +00:00
|
|
|
p += sizeof(VgaFile1Struct0x6);
|
|
|
|
|
|
|
|
#ifdef DUMP_FILE_NR
|
2002-07-07 19:06:48 +00:00
|
|
|
{
|
|
|
|
static bool dumped = false;
|
|
|
|
if (res == DUMP_FILE_NR && !dumped) {
|
|
|
|
dumped = true;
|
|
|
|
dump_vga_file(_cur_vga_file_1);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DUMP_BITMAPS_FILE_NR
|
2002-07-07 19:06:48 +00:00
|
|
|
{
|
|
|
|
static bool dumped = false;
|
|
|
|
if (res == DUMP_BITMAPS_FILE_NR && !dumped) {
|
|
|
|
dumped = true;
|
|
|
|
dump_vga_bitmaps(_cur_vga_file_2, _cur_vga_file_1, res);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-12-20 06:39:24 +00:00
|
|
|
if (_start_vgascript)
|
|
|
|
dump_vga_script(_cur_vga_file_1 + READ_BE_UINT16(&((VgaFile1Struct0x6*)p)->script_offs), res, vga_sprite_id);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-12-01 00:45:16 +00:00
|
|
|
add_vga_timer(VGA_DELAY_BASE, _cur_vga_file_1 + READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->script_offs), vga_sprite_id, res);
|
2003-07-14 12:00:20 +00:00
|
|
|
_cur_vga_file_1 = old_file_1;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_4_dummy_op() {
|
2002-06-29 16:11:13 +00:00
|
|
|
/* dummy opcode */
|
|
|
|
_vc_ptr += 6;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_5_skip_if_neq() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint var = vc_read_next_word();
|
|
|
|
uint value = vc_read_next_word();
|
|
|
|
if (vc_read_var(var) != value)
|
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_6_skip_ifn_sib_with_a() {
|
2003-03-07 03:26:30 +00:00
|
|
|
if (!itemIsSiblingOf(vc_read_next_word()))
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_7_skip_if_sib_with_a() {
|
2003-03-07 03:26:30 +00:00
|
|
|
if (itemIsSiblingOf(vc_read_next_word()))
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_8_skip_if_parent_is() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = vc_read_next_word();
|
|
|
|
uint b = vc_read_next_word();
|
2003-03-07 03:26:30 +00:00
|
|
|
if (!itemIsParentOf(a, b))
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_9_skip_if_unk3_is() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = vc_read_next_word();
|
|
|
|
uint b = vc_read_next_word();
|
2002-07-07 19:06:48 +00:00
|
|
|
if (!vc_maybe_skip_proc_1(a, b))
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:16:24 +00:00
|
|
|
byte *vc_10_depack_column(VC10_state * vs) {
|
2002-06-29 16:11:13 +00:00
|
|
|
int8 a = vs->depack_cont;
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *src = vs->depack_src;
|
2002-06-29 16:11:13 +00:00
|
|
|
byte *dst = vs->depack_dest;
|
|
|
|
byte dh = vs->dh;
|
|
|
|
byte color;
|
|
|
|
|
2004-03-14 17:53:19 +00:00
|
|
|
if (a == -0x80)
|
|
|
|
a = *src++;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
|
|
|
if (a >= 0) {
|
2002-06-29 16:11:13 +00:00
|
|
|
color = *src++;
|
|
|
|
do {
|
|
|
|
*dst++ = color;
|
|
|
|
if (!--dh) {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (--a < 0)
|
2002-06-29 16:11:13 +00:00
|
|
|
a = -0x80;
|
|
|
|
else
|
|
|
|
src--;
|
|
|
|
goto get_out;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (--a >= 0);
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
|
|
|
do {
|
|
|
|
*dst++ = *src++;
|
|
|
|
if (!--dh) {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (++a == 0)
|
2002-06-29 16:11:13 +00:00
|
|
|
a = -0x80;
|
|
|
|
goto get_out;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (++a != 0);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2004-03-14 17:53:19 +00:00
|
|
|
a = *src++;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_out:;
|
|
|
|
vs->depack_src = src;
|
|
|
|
vs->depack_cont = a;
|
|
|
|
return vs->depack_dest + vs->y_skip;
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:16:24 +00:00
|
|
|
void vc_10_skip_cols(VC10_state *vs) {
|
2002-06-29 16:11:13 +00:00
|
|
|
vs->depack_cont = -0x80;
|
2002-07-07 19:06:48 +00:00
|
|
|
while (vs->x_skip) {
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_10_depack_column(vs);
|
|
|
|
vs->x_skip--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-18 01:33:21 +00:00
|
|
|
byte *SimonEngine::vc_10_depack_swap(const byte *src, uint w, uint h) {
|
2002-07-07 19:06:48 +00:00
|
|
|
w <<= 3;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
byte *dst_org = _video_buf_1 + w;
|
|
|
|
byte color;
|
|
|
|
int8 cur = -0x80;
|
|
|
|
uint w_cur = w;
|
|
|
|
|
|
|
|
do {
|
|
|
|
byte *dst = dst_org;
|
|
|
|
uint h_cur = h;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
if (cur == -0x80)
|
|
|
|
cur = *src++;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
for (;;) {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (cur >= 0) {
|
|
|
|
/* rle_same */
|
|
|
|
color = *src++;
|
|
|
|
do {
|
|
|
|
*dst = color;
|
|
|
|
dst += w;
|
|
|
|
if (!--h_cur) {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (--cur < 0)
|
2002-06-29 16:11:13 +00:00
|
|
|
cur = -0x80;
|
|
|
|
else
|
|
|
|
src--;
|
|
|
|
goto next_line;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (--cur >= 0);
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
|
|
|
/* rle_diff */
|
|
|
|
do {
|
|
|
|
*dst = *src++;
|
|
|
|
dst += w;
|
|
|
|
if (!--h_cur) {
|
|
|
|
if (++cur == 0)
|
|
|
|
cur = -0x80;
|
|
|
|
goto next_line;
|
|
|
|
}
|
|
|
|
} while (++cur != 0);
|
|
|
|
}
|
|
|
|
cur = *src++;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
next_line:
|
2002-06-29 16:11:13 +00:00
|
|
|
dst_org++;
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (--w_cur);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
byte *dst_org, *src_org;
|
|
|
|
uint i;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
src_org = dst_org = _video_buf_1 + w;
|
|
|
|
|
|
|
|
do {
|
|
|
|
byte *dst = dst_org;
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = 0; i != w; ++i) {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte b = src_org[i];
|
2002-07-07 19:06:48 +00:00
|
|
|
b = (b >> 4) | (b << 4);
|
2002-06-29 16:11:13 +00:00
|
|
|
*--dst = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
src_org += w;
|
|
|
|
dst_org += w;
|
|
|
|
} while (--h);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return _video_buf_1;
|
|
|
|
}
|
|
|
|
|
2004-12-18 01:33:21 +00:00
|
|
|
byte *SimonEngine::vc_10_no_depack_swap(const byte *src, uint w, uint h) {
|
2003-07-30 09:36:48 +00:00
|
|
|
if (src == _vc_10_base_ptr_old)
|
|
|
|
return _video_buf_1;
|
|
|
|
|
|
|
|
_vc_10_base_ptr_old = src;
|
|
|
|
h *= 8;
|
|
|
|
byte *dst = _video_buf_1 + h - 1;
|
|
|
|
|
|
|
|
uint h_cur = h;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
*dst = *src << 4;
|
|
|
|
(*dst--) |= (*src++) >> 4;
|
|
|
|
} while (--h_cur != 0);
|
|
|
|
h_cur = h;
|
|
|
|
dst += h * 2;
|
|
|
|
} while (--w != 0);
|
|
|
|
|
|
|
|
return _video_buf_1;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* must not be const */
|
|
|
|
static uint16 _video_windows[128] = {
|
|
|
|
0, 0, 20, 200,
|
2002-07-07 19:06:48 +00:00
|
|
|
0, 0, 3, 136,
|
|
|
|
17, 0, 3, 136,
|
2002-06-29 16:11:13 +00:00
|
|
|
0, 0, 20, 200,
|
|
|
|
0, 0, 20, 134
|
|
|
|
};
|
|
|
|
|
|
|
|
/* simon2 specific */
|
2004-12-18 01:33:21 +00:00
|
|
|
void SimonEngine::decodeStripA(byte *dst, const byte *src, int height) {
|
2002-06-29 16:11:13 +00:00
|
|
|
const uint pitch = _dx_surface_pitch;
|
|
|
|
int8 reps = (int8)0x80;
|
|
|
|
byte color;
|
|
|
|
byte *dst_org = dst;
|
2003-03-07 03:26:30 +00:00
|
|
|
uint h = height, w = 8;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
for (;;) {
|
2002-06-29 16:11:13 +00:00
|
|
|
reps = *src++;
|
|
|
|
if (reps >= 0) {
|
|
|
|
color = *src++;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
do {
|
2002-06-29 16:11:13 +00:00
|
|
|
*dst = color;
|
|
|
|
dst += pitch;
|
|
|
|
|
|
|
|
/* reached bottom? */
|
|
|
|
if (--h == 0) {
|
2002-07-07 19:06:48 +00:00
|
|
|
/* reached right edge? */
|
2002-06-29 16:11:13 +00:00
|
|
|
if (--w == 0)
|
|
|
|
return;
|
|
|
|
dst = ++dst_org;
|
2003-03-07 03:26:30 +00:00
|
|
|
h = height;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (--reps >= 0);
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
do {
|
2002-06-29 16:11:13 +00:00
|
|
|
*dst = *src++;
|
|
|
|
dst += pitch;
|
|
|
|
|
|
|
|
/* reached bottom? */
|
|
|
|
if (--h == 0) {
|
2002-07-07 19:06:48 +00:00
|
|
|
/* reached right edge? */
|
2002-06-29 16:11:13 +00:00
|
|
|
if (--w == 0)
|
|
|
|
return;
|
|
|
|
dst = ++dst_org;
|
2003-03-07 03:26:30 +00:00
|
|
|
h = height;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
} while (++reps != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_10_draw() {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte *p2;
|
2002-07-07 19:06:48 +00:00
|
|
|
uint width, height;
|
2002-06-29 16:11:13 +00:00
|
|
|
byte flags;
|
|
|
|
const uint16 *vlut;
|
|
|
|
VC10_state state;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
int cur;
|
|
|
|
|
|
|
|
state.image = (int16)vc_read_next_word();
|
2002-07-07 19:06:48 +00:00
|
|
|
if (state.image == 0)
|
2002-06-29 16:11:13 +00:00
|
|
|
return;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
state.base_color = (_vc_ptr[1] << 4);
|
2002-06-29 16:11:13 +00:00
|
|
|
_vc_ptr += 2;
|
|
|
|
state.x = (int16)vc_read_next_word();
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
state.x -= _x_scroll;
|
|
|
|
}
|
|
|
|
state.y = (int16)vc_read_next_word();
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
2002-06-29 16:11:13 +00:00
|
|
|
state.e = vc_read_next_word();
|
|
|
|
} else {
|
|
|
|
state.e = vc_read_next_byte();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state.image < 0)
|
|
|
|
state.image = vc_read_var(-state.image);
|
|
|
|
|
|
|
|
p2 = _cur_vga_file_2 + state.image * 8;
|
2003-06-14 18:52:30 +00:00
|
|
|
state.depack_src = _cur_vga_file_2 + READ_BE_UINT32(p2);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-06-14 18:52:30 +00:00
|
|
|
width = READ_BE_UINT16(p2 + 6) >> 4;
|
2002-06-29 16:11:13 +00:00
|
|
|
height = p2[5];
|
|
|
|
flags = p2[4];
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (height == 0 || width == 0)
|
2002-06-29 16:11:13 +00:00
|
|
|
return;
|
|
|
|
|
2003-12-11 09:14:10 +00:00
|
|
|
if (_dump_images)
|
|
|
|
dump_single_bitmap(_vga_cur_file_id, state.image, state.depack_src, width * 16, height,
|
|
|
|
state.base_color);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (flags & 0x80 && !(state.e & 0x10)) {
|
|
|
|
if (state.e & 1) {
|
|
|
|
state.e &= ~1;
|
|
|
|
state.e |= 0x10;
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
2002-07-07 19:06:48 +00:00
|
|
|
state.e |= 0x8;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2 && width >= 21) {
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *src;
|
|
|
|
byte *dst;
|
2002-06-29 16:11:13 +00:00
|
|
|
uint w;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
_vga_var1 = width * 2 - 40;
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_var7 = state.depack_src;
|
2004-12-18 02:08:32 +00:00
|
|
|
_sprite_height = height;
|
2002-07-07 19:06:48 +00:00
|
|
|
if (_variableArray[34] == -1)
|
2004-07-27 07:21:28 +00:00
|
|
|
state.x = _variableArray[251];
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
_x_scroll = state.x;
|
|
|
|
|
|
|
|
vc_write_var(0xfb, _x_scroll);
|
|
|
|
|
|
|
|
dst = dx_lock_attached();
|
|
|
|
src = state.depack_src + _x_scroll * 4;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2003-03-07 03:26:30 +00:00
|
|
|
for (w = 0; w < 40; w++) {
|
2003-06-14 18:52:30 +00:00
|
|
|
decodeStripA(dst, src + READ_BE_UINT32(src), height);
|
2002-06-29 16:11:13 +00:00
|
|
|
dst += 8;
|
|
|
|
src += 4;
|
2003-03-07 03:26:30 +00:00
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
dx_unlock_attached();
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
return;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-05-25 03:03:40 +00:00
|
|
|
if (state.e & 0x10) {
|
2002-06-29 16:11:13 +00:00
|
|
|
state.depack_src = vc_10_depack_swap(state.depack_src, width, height);
|
2003-05-25 03:03:40 +00:00
|
|
|
} else if (state.e & 1) {
|
2003-07-30 09:36:48 +00:00
|
|
|
state.depack_src = vc_10_no_depack_swap(state.depack_src, width, height);
|
2003-05-25 03:03:40 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
vlut = &_video_windows[_video_palette_mode * 4];
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
state.draw_width = width << 1; /* cl */
|
|
|
|
state.draw_height = height; /* ch */
|
|
|
|
|
|
|
|
state.x_skip = 0; /* colums to skip = bh */
|
|
|
|
state.y_skip = 0; /* rows to skip = bl */
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
cur = state.x;
|
|
|
|
if (cur < 0) {
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (!--state.draw_width)
|
|
|
|
return;
|
2002-06-29 16:11:13 +00:00
|
|
|
state.x_skip++;
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (++cur);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
state.x = cur;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
cur += state.draw_width - (vlut[2] << 1);
|
2002-06-29 16:11:13 +00:00
|
|
|
if (cur > 0) {
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (!--state.draw_width)
|
|
|
|
return;
|
2002-06-29 16:11:13 +00:00
|
|
|
} while (--cur);
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
cur = state.y;
|
|
|
|
if (cur < 0) {
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (!--state.draw_height)
|
|
|
|
return;
|
2002-06-29 16:11:13 +00:00
|
|
|
state.y_skip++;
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (++cur);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
state.y = cur;
|
|
|
|
|
|
|
|
cur += state.draw_height - vlut[3];
|
|
|
|
if (cur > 0) {
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (!--state.draw_height)
|
|
|
|
return;
|
2002-06-29 16:11:13 +00:00
|
|
|
} while (--cur);
|
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
assert(state.draw_width != 0 && state.draw_height != 0);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
state.draw_width <<= 2;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
state.surf2_addr = dx_lock_2();
|
|
|
|
state.surf2_pitch = _dx_surface_pitch;
|
|
|
|
|
|
|
|
state.surf_addr = dx_lock_attached();
|
|
|
|
state.surf_pitch = _dx_surface_pitch;
|
|
|
|
|
|
|
|
{
|
2003-12-23 08:59:30 +00:00
|
|
|
uint offs, offs2;
|
|
|
|
// Allow one section of Simon the Sorcerer 1 introduction to be displayed
|
|
|
|
// in lower half of screen
|
|
|
|
if (!(_game & GF_SIMON2) && _subroutine == 2926) {
|
|
|
|
offs = ((vlut[0]) * 2 + state.x) * 8;
|
|
|
|
offs2 = (vlut[1] + state.y);
|
|
|
|
} else {
|
|
|
|
offs = ((vlut[0] - _video_windows[16]) * 2 + state.x) * 8;
|
|
|
|
offs2 = (vlut[1] - _video_windows[17] + state.y);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
state.surf2_addr += offs + offs2 * state.surf2_pitch;
|
|
|
|
state.surf_addr += offs + offs2 * state.surf_pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state.e & 0x20) {
|
|
|
|
byte *mask, *src, *dst;
|
|
|
|
byte h;
|
|
|
|
uint w;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
state.x_skip <<= 2;
|
2002-06-29 16:11:13 +00:00
|
|
|
state.dl = width;
|
|
|
|
state.dh = height;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_10_skip_cols(&state);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
w = 0;
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
mask = vc_10_depack_column(&state); /* esi */
|
|
|
|
src = state.surf2_addr + w * 2; /* ebx */
|
|
|
|
dst = state.surf_addr + w * 2; /* edi */
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
h = state.draw_height;
|
2003-07-30 16:25:05 +00:00
|
|
|
if (!(_game & GF_SIMON2) && vc_get_bit(88)) {
|
|
|
|
/* transparency */
|
|
|
|
do {
|
|
|
|
if (mask[0] & 0xF0) {
|
|
|
|
if ((dst[0] & 0x0F0) == 0x20)
|
|
|
|
dst[0] = src[0];
|
|
|
|
}
|
|
|
|
if (mask[0] & 0x0F) {
|
|
|
|
if ((dst[1] & 0x0F0) == 0x20)
|
|
|
|
dst[1] = src[1];
|
|
|
|
}
|
|
|
|
mask++;
|
|
|
|
dst += state.surf_pitch;
|
|
|
|
src += state.surf2_pitch;
|
|
|
|
} while (--h);
|
|
|
|
} else {
|
|
|
|
/* no transparency */
|
|
|
|
do {
|
|
|
|
if (mask[0] & 0xF0)
|
|
|
|
dst[0] = src[0];
|
|
|
|
if (mask[0] & 0x0F)
|
|
|
|
dst[1] = src[1];
|
|
|
|
mask++;
|
|
|
|
dst += state.surf_pitch;
|
|
|
|
src += state.surf2_pitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (++w != state.draw_width);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
/* vc_10_helper_5 */
|
2002-07-07 19:06:48 +00:00
|
|
|
} else if (_lock_word & 0x20 && state.base_color == 0 || state.base_color == 0xC0) {
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *src;
|
|
|
|
byte *dst;
|
2002-07-07 19:06:48 +00:00
|
|
|
uint h, i;
|
|
|
|
|
|
|
|
if (!(state.e & 8)) {
|
|
|
|
src = state.depack_src + (width * state.y_skip << 4) + (state.x_skip << 3);
|
2002-06-29 16:11:13 +00:00
|
|
|
dst = state.surf_addr;
|
|
|
|
|
|
|
|
state.draw_width *= 2;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
if (state.e & 2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
/* no transparency */
|
|
|
|
h = state.draw_height;
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
memcpy(dst, src, state.draw_width);
|
2002-06-29 16:11:13 +00:00
|
|
|
dst += 320;
|
|
|
|
src += width * 16;
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (--h);
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
|
|
|
/* transparency */
|
|
|
|
h = state.draw_height;
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = 0; i != state.draw_width; i++)
|
|
|
|
if (src[i])
|
2002-06-29 16:11:13 +00:00
|
|
|
dst[i] = src[i];
|
|
|
|
dst += 320;
|
|
|
|
src += width * 16;
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (--h);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
byte *dst_org = state.surf_addr;
|
|
|
|
src = state.depack_src;
|
|
|
|
/* AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE
|
|
|
|
* aaaaabbb bbcccccd ddddeeee efffffgg ggghhhhh
|
|
|
|
*/
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
if (state.e & 2) {
|
|
|
|
/* no transparency */
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint count = state.draw_width >> 2;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
dst = dst_org;
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint32 bits = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | (src[3]);
|
|
|
|
|
|
|
|
dst[0] = (byte)((bits >> (32 - 5)) & 31);
|
|
|
|
dst[1] = (byte)((bits >> (32 - 10)) & 31);
|
|
|
|
dst[2] = (byte)((bits >> (32 - 15)) & 31);
|
|
|
|
dst[3] = (byte)((bits >> (32 - 20)) & 31);
|
|
|
|
dst[4] = (byte)((bits >> (32 - 25)) & 31);
|
|
|
|
dst[5] = (byte)((bits >> (32 - 30)) & 31);
|
|
|
|
|
|
|
|
bits = (bits << 8) | src[4];
|
|
|
|
|
|
|
|
dst[6] = (byte)((bits >> (40 - 35)) & 31);
|
2002-06-29 16:11:13 +00:00
|
|
|
dst[7] = (byte)((bits) & 31);
|
|
|
|
|
|
|
|
dst += 8;
|
|
|
|
src += 5;
|
|
|
|
} while (--count);
|
|
|
|
dst_org += 320;
|
|
|
|
} while (--state.draw_height);
|
|
|
|
} else {
|
|
|
|
/* transparency */
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint count = state.draw_width >> 2;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
dst = dst_org;
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint32 bits = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | (src[3]);
|
2002-06-29 16:11:13 +00:00
|
|
|
byte tmp;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
tmp = (byte)((bits >> (32 - 5)) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[0] = tmp;
|
|
|
|
tmp = (byte)((bits >> (32 - 10)) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[1] = tmp;
|
|
|
|
tmp = (byte)((bits >> (32 - 15)) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[2] = tmp;
|
|
|
|
tmp = (byte)((bits >> (32 - 20)) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[3] = tmp;
|
|
|
|
tmp = (byte)((bits >> (32 - 25)) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[4] = tmp;
|
|
|
|
tmp = (byte)((bits >> (32 - 30)) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[5] = tmp;
|
|
|
|
|
|
|
|
bits = (bits << 8) | src[4];
|
|
|
|
|
|
|
|
tmp = (byte)((bits >> (40 - 35)) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[6] = tmp;
|
|
|
|
tmp = (byte)((bits) & 31);
|
|
|
|
if (tmp)
|
|
|
|
dst[7] = tmp;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
dst += 8;
|
|
|
|
src += 5;
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (--count);
|
2002-06-29 16:11:13 +00:00
|
|
|
dst_org += 320;
|
|
|
|
} while (--state.draw_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* vc_10_helper_4 */
|
|
|
|
} else {
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2 && state.e & 0x4 && _bit_array[10] & 0x800) {
|
2002-06-29 16:11:13 +00:00
|
|
|
state.surf_addr = state.surf2_addr;
|
|
|
|
state.surf_pitch = state.surf2_pitch;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
if (state.e & 0x8) {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint w, h;
|
|
|
|
byte *src, *dst, *dst_org;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
state.x_skip <<= 2; /* reached */
|
2002-06-29 16:11:13 +00:00
|
|
|
state.dl = width;
|
|
|
|
state.dh = height;
|
|
|
|
|
|
|
|
vc_10_skip_cols(&state);
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (state.e & 2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
dst_org = state.surf_addr;
|
|
|
|
w = 0;
|
|
|
|
do {
|
|
|
|
src = vc_10_depack_column(&state);
|
|
|
|
dst = dst_org;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
h = 0;
|
|
|
|
do {
|
|
|
|
dst[0] = (*src >> 4) | state.base_color;
|
2002-07-07 19:06:48 +00:00
|
|
|
dst[1] = (*src & 15) | state.base_color;
|
2002-06-29 16:11:13 +00:00
|
|
|
dst += 320;
|
|
|
|
src++;
|
|
|
|
} while (++h != state.draw_height);
|
|
|
|
dst_org += 2;
|
|
|
|
} while (++w != state.draw_width);
|
|
|
|
} else {
|
|
|
|
dst_org = state.surf_addr;
|
2002-07-07 19:06:48 +00:00
|
|
|
if (state.e & 0x40) { /* reached */
|
2002-06-29 16:11:13 +00:00
|
|
|
dst_org += vc_read_var(252);
|
|
|
|
}
|
|
|
|
w = 0;
|
|
|
|
do {
|
|
|
|
byte color;
|
|
|
|
|
|
|
|
src = vc_10_depack_column(&state);
|
|
|
|
dst = dst_org;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
h = 0;
|
|
|
|
do {
|
|
|
|
color = (*src >> 4);
|
2002-07-07 19:06:48 +00:00
|
|
|
if (color)
|
|
|
|
dst[0] = color | state.base_color;
|
|
|
|
color = (*src & 15);
|
|
|
|
if (color)
|
|
|
|
dst[1] = color | state.base_color;
|
2002-06-29 16:11:13 +00:00
|
|
|
dst += 320;
|
|
|
|
src++;
|
|
|
|
} while (++h != state.draw_height);
|
|
|
|
dst_org += 2;
|
2002-07-07 19:06:48 +00:00
|
|
|
} while (++w != state.draw_width);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
/* vc_10_helper_6 */
|
|
|
|
} else {
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *src;
|
|
|
|
byte *dst;
|
2002-06-29 16:11:13 +00:00
|
|
|
uint count;
|
|
|
|
|
|
|
|
src = state.depack_src + (width * state.y_skip) * 8;
|
|
|
|
dst = state.surf_addr;
|
|
|
|
state.x_skip <<= 2;
|
2002-07-07 19:06:48 +00:00
|
|
|
if (state.e & 2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
for (count = 0; count != state.draw_width; count++) {
|
|
|
|
dst[count * 2] = (src[count + state.x_skip] >> 4) | state.base_color;
|
|
|
|
dst[count * 2 + 1] = (src[count + state.x_skip] & 15) | state.base_color;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
src += width * 8;
|
|
|
|
} while (--state.draw_height);
|
|
|
|
} else {
|
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
for (count = 0; count != state.draw_width; count++) {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte color;
|
2002-07-07 19:06:48 +00:00
|
|
|
color = (src[count + state.x_skip] >> 4);
|
|
|
|
if (color)
|
|
|
|
dst[count * 2] = color | state.base_color;
|
|
|
|
color = (src[count + state.x_skip] & 15);
|
|
|
|
if (color)
|
|
|
|
dst[count * 2 + 1] = color | state.base_color;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
dst += 320;
|
|
|
|
src += width * 8;
|
|
|
|
} while (--state.draw_height);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vc_10_helper_7 */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dx_unlock_2();
|
|
|
|
dx_unlock_attached();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_11_clear_pathfind_array() {
|
2002-06-29 16:11:13 +00:00
|
|
|
memset(&_pathfind_array, 0, sizeof(_pathfind_array));
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_12_delay() {
|
2004-01-30 03:26:47 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
2002-06-29 16:11:13 +00:00
|
|
|
uint num;
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
2002-06-29 16:11:13 +00:00
|
|
|
num = vc_read_var_or_word();
|
|
|
|
} else {
|
|
|
|
num = vc_read_next_byte() * _vga_base_delay;
|
|
|
|
}
|
|
|
|
|
2004-01-30 03:26:47 +00:00
|
|
|
// Work around to allow inventory arrows to be
|
|
|
|
// shown in some versions of Simon the Sorcerer 1
|
|
|
|
if (!(_game & GF_SIMON2) && !(_game & GF_WIN) && vsp->id == 0x80)
|
|
|
|
num = 0;
|
|
|
|
else
|
|
|
|
num += VGA_DELAY_BASE;
|
2003-10-26 04:37:11 +00:00
|
|
|
|
2004-01-30 03:26:47 +00:00
|
|
|
add_vga_timer(num, _vc_ptr, _vga_cur_sprite_id, _vga_cur_file_id);
|
2004-12-18 01:33:21 +00:00
|
|
|
_vc_ptr = (byte *)&_vc_get_out_of_code;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_13_set_sprite_offset_x() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
2003-05-29 07:02:14 +00:00
|
|
|
vsp->x += (int16)vc_read_next_word();
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_14_set_sprite_offset_y() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
2003-05-29 07:02:14 +00:00
|
|
|
vsp->y += (int16)vc_read_next_word();
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_15_wakeup_id() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSleepStruct *vfs = _vga_sleep_structs, *vfs_tmp;
|
|
|
|
uint16 id = vc_read_next_word();
|
|
|
|
while (vfs->ident != 0) {
|
|
|
|
if (vfs->ident == id) {
|
2003-12-01 00:45:16 +00:00
|
|
|
add_vga_timer(VGA_DELAY_BASE, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
|
2002-06-29 16:11:13 +00:00
|
|
|
vfs_tmp = vfs;
|
|
|
|
do {
|
|
|
|
memcpy(vfs_tmp, vfs_tmp + 1, sizeof(VgaSleepStruct));
|
|
|
|
vfs_tmp++;
|
|
|
|
} while (vfs_tmp->ident != 0);
|
|
|
|
} else {
|
|
|
|
vfs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear a wait event */
|
|
|
|
if (id == _vga_wait_for)
|
|
|
|
_vga_wait_for = 0;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_16_sleep_on_id() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSleepStruct *vfs = _vga_sleep_structs;
|
|
|
|
while (vfs->ident)
|
|
|
|
vfs++;
|
|
|
|
|
|
|
|
vfs->ident = vc_read_next_word();
|
|
|
|
vfs->code_ptr = _vc_ptr;
|
|
|
|
vfs->sprite_id = _vga_cur_sprite_id;
|
|
|
|
vfs->cur_vga_file = _vga_cur_file_id;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2004-12-18 01:33:21 +00:00
|
|
|
_vc_ptr = (byte *)&_vc_get_out_of_code;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_17_set_pathfind_item() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = vc_read_next_word();
|
2004-12-18 01:33:21 +00:00
|
|
|
_pathfind_array[a - 1] = (const uint16 *)_vc_ptr;
|
2003-06-14 18:52:30 +00:00
|
|
|
while (READ_BE_UINT16(_vc_ptr) != 999)
|
2002-06-29 16:11:13 +00:00
|
|
|
_vc_ptr += 4;
|
|
|
|
_vc_ptr += 2;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_18_jump_rel() {
|
2002-06-29 16:11:13 +00:00
|
|
|
int16 offs = vc_read_next_word();
|
|
|
|
_vc_ptr += offs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* chain to script? */
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_19_chain_to_script() {
|
2003-07-30 11:16:09 +00:00
|
|
|
/* unused */
|
2002-11-29 10:18:32 +00:00
|
|
|
error("vc_19_chain_to_script: not implemented");
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* helper routines */
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_20_set_code_word() {
|
2004-12-18 02:08:32 +00:00
|
|
|
/* FIXME: This opcode is somewhat strange: it first reads a BE word from
|
2004-12-18 01:33:21 +00:00
|
|
|
* the script (advancing the script pointer in doing so); then it writes
|
|
|
|
* back the same word, this time as LE, into the script.
|
|
|
|
*/
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 a = vc_read_next_word();
|
2004-12-18 01:33:21 +00:00
|
|
|
WRITE_LE_UINT16(const_cast<byte *>(_vc_ptr), a);
|
2002-06-29 16:11:13 +00:00
|
|
|
_vc_ptr += 2;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_21_jump_if_code_word() {
|
2003-07-28 11:48:07 +00:00
|
|
|
int16 a = vc_read_next_word();
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *tmp = _vc_ptr + a;
|
2003-07-28 11:48:07 +00:00
|
|
|
if (_game & GF_SIMON2)
|
|
|
|
tmp += 3;
|
|
|
|
else
|
|
|
|
tmp += 4;
|
|
|
|
|
2004-12-18 01:33:21 +00:00
|
|
|
uint16 val = READ_LE_UINT16(tmp);
|
2003-07-28 11:48:07 +00:00
|
|
|
if (val != 0) {
|
2004-12-18 01:33:21 +00:00
|
|
|
// Decrement counter
|
|
|
|
WRITE_LE_UINT16(const_cast<byte *>(tmp), val - 1);
|
2003-07-28 11:48:07 +00:00
|
|
|
_vc_ptr = tmp + 2;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_22_set_sprite_palette() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = vc_read_next_word();
|
|
|
|
uint b = vc_read_next_word();
|
2002-07-07 19:06:48 +00:00
|
|
|
uint num = a == 0 ? 0x20 : 0x10;
|
2002-06-29 16:11:13 +00:00
|
|
|
byte *palptr, *src;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
palptr = &_palette[(a << 6)];
|
|
|
|
|
|
|
|
src = _cur_vga_file_1 + 6 + b * 96;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
palptr[0] = src[0] << 2;
|
|
|
|
palptr[1] = src[1] << 2;
|
|
|
|
palptr[2] = src[2] << 2;
|
2002-06-29 16:11:13 +00:00
|
|
|
palptr[3] = 0;
|
|
|
|
|
|
|
|
palptr += 4;
|
|
|
|
src += 3;
|
|
|
|
} while (--num);
|
|
|
|
|
|
|
|
_video_var_9 = 2;
|
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_23_set_sprite_priority() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite(), *vus2;
|
|
|
|
uint16 pri = vc_read_next_word();
|
|
|
|
VgaSprite bak;
|
|
|
|
|
2003-07-30 11:16:09 +00:00
|
|
|
if (vsp->id == 0)
|
2003-07-16 12:21:09 +00:00
|
|
|
return;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
memcpy(&bak, vsp, sizeof(bak));
|
2002-11-28 00:22:24 +00:00
|
|
|
bak.priority = pri;
|
2002-06-29 16:11:13 +00:00
|
|
|
bak.unk6 |= 0x8000;
|
|
|
|
|
|
|
|
vus2 = vsp;
|
|
|
|
|
2002-11-28 00:22:24 +00:00
|
|
|
if (vsp != _vga_sprites && pri < vsp[-1].priority) {
|
2002-06-29 16:11:13 +00:00
|
|
|
do {
|
|
|
|
vsp--;
|
2002-11-28 00:22:24 +00:00
|
|
|
} while (vsp != _vga_sprites && pri < vsp[-1].priority);
|
2002-06-29 16:11:13 +00:00
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
memcpy(vus2, vus2 - 1, sizeof(VgaSprite));
|
2002-06-29 16:11:13 +00:00
|
|
|
} while (--vus2 != vsp);
|
|
|
|
memcpy(vus2, &bak, sizeof(VgaSprite));
|
2002-11-28 00:22:24 +00:00
|
|
|
} else if (vsp[1].id != 0 && pri >= vsp[1].priority) {
|
2002-06-29 16:11:13 +00:00
|
|
|
do {
|
|
|
|
vsp++;
|
2002-11-28 00:22:24 +00:00
|
|
|
} while (vsp[1].id != 0 && pri >= vsp[1].priority);
|
2002-06-29 16:11:13 +00:00
|
|
|
do {
|
2002-07-07 19:06:48 +00:00
|
|
|
memcpy(vus2, vus2 + 1, sizeof(VgaSprite));
|
2002-06-29 16:11:13 +00:00
|
|
|
} while (++vus2 != vsp);
|
|
|
|
memcpy(vus2, &bak, sizeof(VgaSprite));
|
|
|
|
} else {
|
2002-11-28 00:22:24 +00:00
|
|
|
vsp->priority = pri;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_24_set_sprite_xy() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
|
|
|
vsp->image = vc_read_var_or_word();
|
|
|
|
|
|
|
|
vsp->x += (int16)vc_read_next_word();
|
|
|
|
vsp->y += (int16)vc_read_next_word();
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
2002-06-29 16:11:13 +00:00
|
|
|
vsp->unk4 = vc_read_next_word();
|
|
|
|
} else {
|
|
|
|
vsp->unk4 = vc_read_next_byte();
|
|
|
|
}
|
|
|
|
|
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_25_halt_sprite() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
|
|
|
while (vsp->id != 0) {
|
2002-07-07 19:06:48 +00:00
|
|
|
memcpy(vsp, vsp + 1, sizeof(VgaSprite));
|
2002-06-29 16:11:13 +00:00
|
|
|
vsp++;
|
|
|
|
}
|
2004-12-18 01:33:21 +00:00
|
|
|
_vc_ptr = (byte *)&_vc_get_out_of_code;
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_26_set_window() {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint16 *as = &_video_windows[vc_read_next_word() * 4];
|
2002-06-29 16:11:13 +00:00
|
|
|
as[0] = vc_read_next_word();
|
|
|
|
as[1] = vc_read_next_word();
|
|
|
|
as[2] = vc_read_next_word();
|
|
|
|
as[3] = vc_read_next_word();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_27_reset_simon1() {
|
2002-07-07 19:06:48 +00:00
|
|
|
VgaSprite bak, *vsp;
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSleepStruct *vfs;
|
2002-07-07 19:06:48 +00:00
|
|
|
VgaTimerEntry *vte, *vte2;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
_lock_word |= 8;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
memset(&bak, 0, sizeof(bak));
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
vsp = _vga_sprites;
|
|
|
|
while (vsp->id) {
|
2003-12-20 04:20:22 +00:00
|
|
|
if (vsp->id == 0x80) {
|
2002-07-07 19:06:48 +00:00
|
|
|
memcpy(&bak, vsp, sizeof(VgaSprite));
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
vsp->id = 0;
|
|
|
|
vsp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bak.id != 0)
|
|
|
|
memcpy(_vga_sprites, &bak, sizeof(VgaSprite));
|
|
|
|
|
|
|
|
vfs = _vga_sleep_structs;
|
|
|
|
while (vfs->ident) {
|
|
|
|
vfs->ident = 0;
|
|
|
|
vfs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
vte = _vga_timer_list;
|
|
|
|
while (vte->delay) {
|
|
|
|
if (vte->sprite_id != 0x80) {
|
|
|
|
vte2 = vte;
|
|
|
|
while (vte2->delay) {
|
2002-07-07 19:06:48 +00:00
|
|
|
memcpy(vte2, vte2 + 1, sizeof(VgaTimerEntry));
|
2002-06-29 16:11:13 +00:00
|
|
|
vte2++;
|
|
|
|
}
|
2003-12-20 04:20:22 +00:00
|
|
|
} else {
|
2002-06-29 16:11:13 +00:00
|
|
|
vte++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vc_write_var(0xFE, 0);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
_lock_word &= ~8;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_27_reset_simon2() {
|
2002-06-29 16:11:13 +00:00
|
|
|
_lock_word |= 8;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
{
|
|
|
|
VgaSprite *vsp = _vga_sprites;
|
|
|
|
while (vsp->id) {
|
|
|
|
vsp->id = 0;
|
|
|
|
vsp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
VgaSleepStruct *vfs = _vga_sleep_structs;
|
|
|
|
while (vfs->ident) {
|
|
|
|
vfs->ident = 0;
|
|
|
|
vfs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
{
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaTimerEntry *vte = _vga_timer_list;
|
|
|
|
while (vte->delay) {
|
|
|
|
VgaTimerEntry *vte2 = vte;
|
|
|
|
while (vte2->delay) {
|
2002-07-07 19:06:48 +00:00
|
|
|
memcpy(vte2, vte2 + 1, sizeof(VgaTimerEntry));
|
2002-06-29 16:11:13 +00:00
|
|
|
vte2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vc_write_var(0xFE, 0);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
_lock_word &= ~8;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_27_reset() {
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2))
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_27_reset_simon1();
|
|
|
|
else
|
|
|
|
vc_27_reset_simon2();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_28_dummy_op() {
|
2003-07-30 11:16:09 +00:00
|
|
|
/* unused */
|
2002-06-29 16:11:13 +00:00
|
|
|
_vc_ptr += 8;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_29_stop_all_sounds() {
|
2002-11-24 12:53:01 +00:00
|
|
|
_sound->stopAll();
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_30_set_base_delay() {
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_base_delay = vc_read_next_word();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_31_set_palette_mode() {
|
2002-06-29 16:11:13 +00:00
|
|
|
_video_palette_mode = vc_read_next_word();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
uint SimonEngine::vc_read_var(uint var) {
|
2002-07-07 19:06:48 +00:00
|
|
|
assert(var < 255);
|
2002-06-29 16:11:13 +00:00
|
|
|
return (uint16)_variableArray[var];
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_write_var(uint var, int16 value) {
|
2002-06-29 16:11:13 +00:00
|
|
|
_variableArray[var] = value;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_32_copy_var() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 a = vc_read_var(vc_read_next_word());
|
|
|
|
vc_write_var(vc_read_next_word(), a);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_33_force_unlock() {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (_lock_counter != 0) {
|
|
|
|
_lock_counter = 1;
|
|
|
|
unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_34_force_lock() {
|
2002-06-29 16:11:13 +00:00
|
|
|
lock();
|
|
|
|
_lock_counter = 200;
|
|
|
|
_left_button_down = 0;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_35() {
|
2003-07-30 11:16:09 +00:00
|
|
|
/* unused */
|
2002-06-29 16:11:13 +00:00
|
|
|
_vc_ptr += 4;
|
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_36_saveload_thing() {
|
2002-12-19 15:46:02 +00:00
|
|
|
_video_var_8 = false;
|
2002-06-29 16:11:13 +00:00
|
|
|
uint vga_res = vc_read_next_word();
|
|
|
|
uint mode = vc_read_next_word();
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (mode == 16) {
|
|
|
|
_copy_partial_mode = 2;
|
|
|
|
} else {
|
2002-07-07 19:06:48 +00:00
|
|
|
set_video_mode_internal(mode, vga_res);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-07-07 19:06:48 +00:00
|
|
|
set_video_mode_internal(mode, vga_res);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_37_set_sprite_offset_y() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
|
|
|
vsp->y += vc_read_var(vc_read_next_word());
|
2002-07-07 19:06:48 +00:00
|
|
|
_vga_sprite_changed++;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_38_skip_if_var_zero() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint var = vc_read_next_word();
|
|
|
|
if (vc_read_var(var) == 0)
|
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_39_set_var() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint var = vc_read_next_word();
|
|
|
|
int16 value = vc_read_next_word();
|
2002-07-07 19:06:48 +00:00
|
|
|
vc_write_var(var, value);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_40_var_add() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint var = vc_read_next_word();
|
|
|
|
int16 value = vc_read_var(var) + vc_read_next_word();
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2 && var == 0xF && !(_bit_array[5] & 1)) {
|
2002-06-29 16:11:13 +00:00
|
|
|
int16 tmp;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (_vga_var2 != 0) {
|
|
|
|
if (_vga_var2 >= 0)
|
|
|
|
goto no_scroll;
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_var2 = 0;
|
|
|
|
} else {
|
2004-12-18 02:08:32 +00:00
|
|
|
if (_xscroll_step != 0)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto no_scroll;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (value - _x_scroll >= 30) {
|
|
|
|
_vga_var2 = 20;
|
|
|
|
tmp = _vga_var1 - _x_scroll;
|
|
|
|
if (tmp < 20)
|
|
|
|
_vga_var2 = tmp;
|
2003-12-23 09:08:11 +00:00
|
|
|
add_vga_timer(6, NULL, 0, 0); /* special timer */
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
no_scroll:;
|
|
|
|
|
|
|
|
vc_write_var(var, value);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_41_var_sub() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint var = vc_read_next_word();
|
|
|
|
int16 value = vc_read_var(var) - vc_read_next_word();
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2 && var == 0xF && !(_bit_array[5] & 1)) {
|
2002-06-29 16:11:13 +00:00
|
|
|
int16 tmp;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (_vga_var2 != 0) {
|
|
|
|
if (_vga_var2 < 0)
|
|
|
|
goto no_scroll;
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_var2 = 0;
|
|
|
|
} else {
|
2004-12-18 02:08:32 +00:00
|
|
|
if (_xscroll_step != 0)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto no_scroll;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((uint16)(value - _x_scroll) < 11) {
|
|
|
|
_vga_var2 = -20;
|
|
|
|
tmp = _vga_var1 - _x_scroll;
|
|
|
|
if (_x_scroll < 20)
|
|
|
|
_vga_var2 = -_x_scroll;
|
2003-12-23 09:08:11 +00:00
|
|
|
add_vga_timer(6, NULL, 0, 0); /* special timer */
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
no_scroll:;
|
|
|
|
|
|
|
|
vc_write_var(var, value);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_42_delay_if_not_eq() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint val = vc_read_var(vc_read_next_word());
|
2003-12-20 07:59:42 +00:00
|
|
|
if (val != vc_read_next_word()) {
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
add_vga_timer(_vga_base_delay + 1, _vc_ptr - 4, _vga_cur_sprite_id, _vga_cur_file_id);
|
2004-12-18 01:33:21 +00:00
|
|
|
_vc_ptr = (byte *)&_vc_get_out_of_code;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_43_skip_if_bit_clear() {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (!vc_get_bit(vc_read_next_word())) {
|
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_44_skip_if_bit_set() {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (vc_get_bit(vc_read_next_word())) {
|
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_45_set_sprite_x() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
|
|
|
vsp->x = vc_read_var(vc_read_next_word());
|
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_46_set_sprite_y() {
|
2002-06-29 16:11:13 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
|
|
|
vsp->y = vc_read_var(vc_read_next_word());
|
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_47_add_var_f() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint var = vc_read_next_word();
|
|
|
|
vc_write_var(var, vc_read_var(var) + vc_read_var(vc_read_next_word()));
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_48() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = (uint16)_variableArray[12];
|
|
|
|
uint b = (uint16)_variableArray[13];
|
|
|
|
int c = _variableArray[14];
|
2004-12-18 01:33:21 +00:00
|
|
|
const uint16 *p = _pathfind_array[a - 1];
|
2002-06-29 16:11:13 +00:00
|
|
|
int step;
|
2002-07-07 19:06:48 +00:00
|
|
|
int y1, y2;
|
2002-06-29 16:11:13 +00:00
|
|
|
int16 *vp;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
p += b * 2 + 1;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
step = 2;
|
2002-07-07 19:06:48 +00:00
|
|
|
if (c < 0) {
|
2002-06-29 16:11:13 +00:00
|
|
|
c = -c;
|
|
|
|
step = -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
vp = &_variableArray[20];
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
do {
|
2003-06-14 18:52:30 +00:00
|
|
|
y2 = READ_BE_UINT16(p);
|
2002-06-29 16:11:13 +00:00
|
|
|
p += step;
|
2003-06-14 18:52:30 +00:00
|
|
|
y1 = READ_BE_UINT16(p) - y2;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
vp[0] = y1 >> 1;
|
|
|
|
vp[1] = y1 - (y1 >> 1);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
vp += 2;
|
|
|
|
} while (--c);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_set_bit_to(uint bit, bool value) {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint16 *bits = &_bit_array[bit >> 4];
|
|
|
|
*bits = (*bits & ~(1 << (bit & 15))) | (value << (bit & 15));
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
bool SimonEngine::vc_get_bit(uint bit) {
|
2002-07-07 19:06:48 +00:00
|
|
|
uint16 *bits = &_bit_array[bit >> 4];
|
|
|
|
return (*bits & (1 << (bit & 15))) != 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_49_set_bit() {
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_set_bit_to(vc_read_next_word(), true);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_50_clear_bit() {
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_set_bit_to(vc_read_next_word(), false);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_51_clear_hitarea_bit_0x40() {
|
2002-06-29 16:11:13 +00:00
|
|
|
clear_hitarea_bit_0x40(vc_read_next_word());
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_52_play_sound() {
|
2003-10-21 10:34:56 +00:00
|
|
|
uint16 sound_id = vc_read_next_word();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-01-03 12:06:30 +00:00
|
|
|
if (_game == GAME_SIMON1DOS) {
|
2003-10-21 10:34:56 +00:00
|
|
|
playSting(sound_id);
|
2003-03-01 22:52:49 +00:00
|
|
|
} else if (!(_game & GF_SIMON2)) {
|
2003-10-21 10:34:56 +00:00
|
|
|
_sound->playEffects(sound_id);
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
2003-10-21 10:34:56 +00:00
|
|
|
if (sound_id >= 0x8000) {
|
|
|
|
sound_id = -sound_id;
|
|
|
|
_sound->playAmbient(sound_id);
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
2003-10-21 10:34:56 +00:00
|
|
|
_sound->playEffects(sound_id);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_53_no_op() {
|
2003-07-30 11:16:09 +00:00
|
|
|
/* unused */
|
|
|
|
_vc_ptr += 4;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_54_no_op() {
|
2003-07-30 11:16:09 +00:00
|
|
|
/* unused */
|
|
|
|
_vc_ptr += 6;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_55_offset_hit_area() {
|
2002-06-29 16:11:13 +00:00
|
|
|
HitArea *ha = _hit_areas;
|
|
|
|
uint count = ARRAYSIZE(_hit_areas);
|
|
|
|
uint16 id = vc_read_next_word();
|
|
|
|
int16 x = vc_read_next_word();
|
|
|
|
int16 y = vc_read_next_word();
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (ha->id == id) {
|
|
|
|
ha->x += x;
|
|
|
|
ha->y += y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ha++;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
_need_hitarea_recalc++;
|
|
|
|
}
|
|
|
|
|
2003-10-26 04:35:35 +00:00
|
|
|
void SimonEngine::vc_56_delay() {
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint num = vc_read_var_or_word() * _vga_base_delay;
|
|
|
|
|
2003-12-01 00:45:16 +00:00
|
|
|
add_vga_timer(num + VGA_DELAY_BASE, _vc_ptr, _vga_cur_sprite_id, _vga_cur_file_id);
|
2004-12-18 01:33:21 +00:00
|
|
|
_vc_ptr = (byte *)&_vc_get_out_of_code;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_59() {
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint file = vc_read_next_word();
|
|
|
|
uint start = vc_read_next_word();
|
|
|
|
uint end = vc_read_next_word() + 1;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
do {
|
2003-05-24 12:26:28 +00:00
|
|
|
vc_kill_sprite(file, start);
|
2002-06-29 16:11:13 +00:00
|
|
|
} while (++start != end);
|
|
|
|
} else {
|
2003-12-24 00:25:18 +00:00
|
|
|
if (!_sound->_voice_handle.isActive())
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_58() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint sprite = _vga_cur_sprite_id;
|
|
|
|
uint file = _vga_cur_file_id;
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *vc_ptr_org;
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 tmp;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_cur_file_id = vc_read_next_word();
|
|
|
|
_vga_cur_sprite_id = vc_read_next_word();
|
|
|
|
|
|
|
|
tmp = TO_BE_16(vc_read_next_word());
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2003-10-16 09:41:35 +00:00
|
|
|
vc_ptr_org = _vc_ptr;
|
2002-07-07 19:06:48 +00:00
|
|
|
_vc_ptr = (byte *)&tmp;
|
2003-05-29 07:02:14 +00:00
|
|
|
vc_23_set_sprite_priority();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-10-16 09:41:35 +00:00
|
|
|
_vc_ptr = vc_ptr_org;
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_cur_sprite_id = sprite;
|
|
|
|
_vga_cur_file_id = file;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_57_no_op() {
|
2003-07-30 11:16:09 +00:00
|
|
|
/* unused */
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_kill_sprite(uint file, uint sprite) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 old_sprite_id, old_cur_file_id;
|
|
|
|
VgaSleepStruct *vfs;
|
|
|
|
VgaSprite *vsp;
|
|
|
|
VgaTimerEntry *vte;
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *vc_ptr_org;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
old_sprite_id = _vga_cur_sprite_id;
|
|
|
|
old_cur_file_id = _vga_cur_file_id;
|
2003-10-16 09:41:35 +00:00
|
|
|
vc_ptr_org = _vc_ptr;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
_vga_cur_file_id = file;
|
|
|
|
_vga_cur_sprite_id = sprite;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
vfs = _vga_sleep_structs;
|
|
|
|
while (vfs->ident != 0) {
|
|
|
|
if (vfs->sprite_id == _vga_cur_sprite_id
|
2003-03-01 22:52:49 +00:00
|
|
|
&& (vfs->cur_vga_file == _vga_cur_file_id || !(_game & GF_SIMON2))
|
2002-07-07 19:06:48 +00:00
|
|
|
) {
|
|
|
|
while (vfs->ident != 0) {
|
|
|
|
memcpy(vfs, vfs + 1, sizeof(VgaSleepStruct));
|
2002-06-29 16:11:13 +00:00
|
|
|
vfs++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
vfs++;
|
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
vsp = find_cur_sprite();
|
2002-06-29 16:11:13 +00:00
|
|
|
if (vsp->id) {
|
2003-05-24 12:13:23 +00:00
|
|
|
vc_25_halt_sprite();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
vte = _vga_timer_list;
|
|
|
|
while (vte->delay != 0) {
|
|
|
|
if (vte->sprite_id == _vga_cur_sprite_id
|
2003-03-01 22:52:49 +00:00
|
|
|
&& (vte->cur_vga_file == _vga_cur_file_id || !(_game & GF_SIMON2))
|
2002-07-07 19:06:48 +00:00
|
|
|
) {
|
2002-06-29 16:11:13 +00:00
|
|
|
delete_vga_timer(vte);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
vte++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_vga_cur_file_id = old_cur_file_id;
|
|
|
|
_vga_cur_sprite_id = old_sprite_id;
|
2003-10-16 09:41:35 +00:00
|
|
|
_vc_ptr = vc_ptr_org;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_60_kill_sprite() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint file;
|
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-06-29 16:11:13 +00:00
|
|
|
file = vc_read_next_word();
|
|
|
|
} else {
|
|
|
|
file = _vga_cur_file_id;
|
|
|
|
}
|
|
|
|
uint sprite = vc_read_next_word();
|
2003-05-24 12:26:28 +00:00
|
|
|
vc_kill_sprite(file, sprite);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_61_sprite_change() {
|
2002-07-07 19:06:48 +00:00
|
|
|
VgaSprite *vsp = find_cur_sprite();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
vsp->image = vc_read_var_or_word();
|
|
|
|
|
|
|
|
vsp->x += vc_read_next_word();
|
|
|
|
vsp->y += vc_read_next_word();
|
|
|
|
vsp->unk4 = 36;
|
|
|
|
|
|
|
|
_vga_sprite_changed++;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_62_palette_thing() {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint i;
|
|
|
|
|
|
|
|
vc_29_stop_all_sounds();
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-12-22 08:08:53 +00:00
|
|
|
if (!_video_var_3) {
|
2002-12-22 09:26:42 +00:00
|
|
|
_video_var_3 = true;
|
2002-11-24 13:05:44 +00:00
|
|
|
|
2003-05-21 11:49:41 +00:00
|
|
|
_video_num_pal_colors = 256;
|
|
|
|
if (_video_palette_mode == 4)
|
|
|
|
_video_num_pal_colors = 208;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-05-21 11:49:41 +00:00
|
|
|
memcpy(_video_buf_1, _palette_backup, _video_num_pal_colors * sizeof(uint32));
|
|
|
|
for (i = NUM_PALETTE_FADEOUT; i != 0; --i) {
|
|
|
|
palette_fadeout((uint32 *)_video_buf_1, _video_num_pal_colors);
|
2004-02-28 12:58:13 +00:00
|
|
|
_system->setPalette(_video_buf_1, 0, _video_num_pal_colors);
|
2003-12-18 10:47:12 +00:00
|
|
|
if (_fade)
|
2004-02-28 12:58:13 +00:00
|
|
|
_system->updateScreen();
|
2003-05-21 11:49:41 +00:00
|
|
|
delay(5);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-12-20 04:20:22 +00:00
|
|
|
if (!(_game & GF_SIMON2)) {
|
2003-05-21 11:49:41 +00:00
|
|
|
uint16 params[5]; /* parameters to vc_10_draw */
|
|
|
|
VgaSprite *vsp;
|
|
|
|
VgaPointersEntry *vpe;
|
2004-12-18 01:33:21 +00:00
|
|
|
const byte *vc_ptr_org = _vc_ptr;
|
2003-05-21 11:49:41 +00:00
|
|
|
|
|
|
|
vsp = _vga_sprites;
|
|
|
|
while (vsp->id != 0) {
|
2003-12-06 04:18:48 +00:00
|
|
|
if (vsp->id == 0x80) {
|
2003-10-16 09:41:35 +00:00
|
|
|
byte *old_file_1 = _cur_vga_file_1;
|
|
|
|
byte *old_file_2 = _cur_vga_file_2;
|
2003-05-21 11:49:41 +00:00
|
|
|
uint palmode = _video_palette_mode;
|
|
|
|
|
|
|
|
vpe = &_vga_buffer_pointers[vsp->unk7];
|
|
|
|
_cur_vga_file_1 = vpe->vgaFile1;
|
|
|
|
_cur_vga_file_2 = vpe->vgaFile2;
|
|
|
|
_video_palette_mode = vsp->unk6;
|
|
|
|
|
2003-06-14 18:52:30 +00:00
|
|
|
params[0] = READ_BE_UINT16(&vsp->image);
|
|
|
|
params[1] = READ_BE_UINT16(&vsp->base_color);
|
|
|
|
params[2] = READ_BE_UINT16(&vsp->x);
|
|
|
|
params[3] = READ_BE_UINT16(&vsp->y);
|
|
|
|
params[4] = READ_BE_UINT16(&vsp->unk4);
|
2003-05-21 11:49:41 +00:00
|
|
|
_vc_ptr = (byte *)params;
|
|
|
|
vc_10_draw();
|
|
|
|
|
|
|
|
_video_palette_mode = palmode;
|
2003-10-16 09:41:35 +00:00
|
|
|
_cur_vga_file_1 = old_file_1;
|
|
|
|
_cur_vga_file_2 = old_file_2;
|
2003-05-21 11:49:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
vsp++;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2003-12-02 05:12:49 +00:00
|
|
|
_vc_ptr = vc_ptr_org;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 08:59:30 +00:00
|
|
|
// Allow one section of Simon the Sorcerer 1 introduction to be displayed
|
|
|
|
// in lower half of screen
|
2004-01-27 13:33:21 +00:00
|
|
|
if (!(_game & GF_SIMON2) && (_subroutine == 2923 || _subroutine == 2926))
|
2003-12-23 08:59:30 +00:00
|
|
|
dx_clear_surfaces(200);
|
|
|
|
else
|
|
|
|
dx_clear_surfaces(_video_palette_mode == 4 ? 134 : 200);
|
2003-05-21 11:49:41 +00:00
|
|
|
}
|
|
|
|
if (_game & GF_SIMON2) {
|
|
|
|
if (_next_music_to_play != -1)
|
|
|
|
loadMusic(_next_music_to_play);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_63_palette_thing_2() {
|
2002-06-29 16:11:13 +00:00
|
|
|
_palette_color_count = 208;
|
2002-07-07 19:06:48 +00:00
|
|
|
if (_video_palette_mode != 4) {
|
2002-06-29 16:11:13 +00:00
|
|
|
_palette_color_count = 256;
|
|
|
|
}
|
|
|
|
_video_var_3 = false;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_64_skip_if_no_speech() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2004-02-09 05:11:54 +00:00
|
|
|
if (!_sound->_voice_handle.isActive() || (_subtitles && _language != 20))
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_65_palette_thing_3() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2003-12-02 05:12:49 +00:00
|
|
|
_palette_color_count = 624;
|
|
|
|
_video_num_pal_colors = 208;
|
2002-11-28 05:52:55 +00:00
|
|
|
if (_video_palette_mode != 4) {
|
2003-12-02 05:12:49 +00:00
|
|
|
_palette_color_count = 768;
|
|
|
|
_video_num_pal_colors = 256;
|
2002-11-28 05:52:55 +00:00
|
|
|
}
|
|
|
|
_palette_color_count |= 0x8000;
|
|
|
|
_video_var_3 = false;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_66_skip_if_nz() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = vc_read_next_word();
|
|
|
|
uint b = vc_read_next_word();
|
|
|
|
|
|
|
|
if (vc_read_var(a) != vc_read_var(b))
|
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_67_skip_if_ge() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = vc_read_next_word();
|
|
|
|
uint b = vc_read_next_word();
|
|
|
|
|
|
|
|
if (vc_read_var(a) >= vc_read_var(b))
|
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_68_skip_if_le() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2002-06-29 16:11:13 +00:00
|
|
|
uint a = vc_read_next_word();
|
|
|
|
uint b = vc_read_next_word();
|
|
|
|
|
|
|
|
if (vc_read_var(a) <= vc_read_var(b))
|
|
|
|
vc_skip_next_instruction();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_69_play_track() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2003-05-21 00:44:37 +00:00
|
|
|
int16 track = vc_read_next_word();
|
2003-05-21 04:36:09 +00:00
|
|
|
int16 loop = vc_read_next_word();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-05-21 00:44:37 +00:00
|
|
|
// Jamieson630:
|
2003-05-21 04:36:09 +00:00
|
|
|
// This is a "play track". The original
|
2003-05-21 00:44:37 +00:00
|
|
|
// design stored the track to play if one was
|
|
|
|
// already in progress, so that the next time a
|
|
|
|
// "fill MIDI stream" event occured, the MIDI
|
|
|
|
// player would find the change and switch
|
|
|
|
// tracks. We use a different architecture that
|
|
|
|
// allows for an immediate response here, but
|
|
|
|
// we'll simulate the variable changes so other
|
|
|
|
// scripts don't get thrown off.
|
|
|
|
// NOTE: This opcode looks very similar in function
|
|
|
|
// to vc_72(), except that vc_72() may allow for
|
|
|
|
// specifying a non-valid track number (999 or -1)
|
|
|
|
// as a means of stopping what music is currently
|
|
|
|
// playing.
|
2003-09-24 06:33:59 +00:00
|
|
|
midi.setLoop(loop != 0);
|
|
|
|
midi.startTrack(track);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_70_queue_music() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2003-05-21 04:36:09 +00:00
|
|
|
uint16 track = vc_read_next_word();
|
|
|
|
uint16 loop = vc_read_next_word();
|
|
|
|
|
|
|
|
// Jamieson630:
|
|
|
|
// This sets the "on end of track" action.
|
|
|
|
// It specifies whether to loop the current
|
|
|
|
// track and, if not, whether to switch to
|
|
|
|
// a different track upon completion.
|
2003-05-21 11:23:53 +00:00
|
|
|
if (track != 0xFFFF && track != 999)
|
2003-09-24 06:33:59 +00:00
|
|
|
midi.queueTrack(track, loop != 0);
|
2003-07-13 06:29:49 +00:00
|
|
|
else
|
2003-09-24 06:33:59 +00:00
|
|
|
midi.setLoop(loop != 0);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_71_check_music_queue() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2003-05-21 04:36:09 +00:00
|
|
|
// Jamieson630:
|
|
|
|
// This command skips the next instruction
|
|
|
|
// unless (1) there is a track playing, AND
|
|
|
|
// (2) there is a track queued to play after it.
|
|
|
|
if (!midi.isPlaying (true))
|
|
|
|
vc_skip_next_instruction();
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_72_play_track_2() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2003-05-21 00:44:37 +00:00
|
|
|
// Jamieson630:
|
2003-05-21 05:12:04 +00:00
|
|
|
// This is a "play or stop track". Note that
|
|
|
|
// this opcode looks very similar in function
|
|
|
|
// to vc_69(), except that this opcode may allow
|
2003-05-21 00:44:37 +00:00
|
|
|
// for specifying a track of 999 or -1 in order to
|
|
|
|
// stop the music. We'll code it that way for now.
|
2003-05-21 04:36:09 +00:00
|
|
|
|
|
|
|
// NOTE: It's possible that when "stopping" a track,
|
|
|
|
// we're supposed to just go on to the next queued
|
|
|
|
// track, if any. Must find out if there is ANY
|
|
|
|
// case where this is used to stop a track in the
|
|
|
|
// first place.
|
|
|
|
|
2003-05-21 00:44:37 +00:00
|
|
|
int16 track = vc_read_next_word();
|
2003-05-21 04:36:09 +00:00
|
|
|
int16 loop = vc_read_next_word();
|
2003-05-21 00:44:37 +00:00
|
|
|
|
2003-05-21 05:12:04 +00:00
|
|
|
if (track == -1 || track == 999) {
|
|
|
|
midi.stop();
|
|
|
|
} else {
|
|
|
|
midi.setLoop (loop != 0);
|
2003-05-21 06:13:47 +00:00
|
|
|
midi.startTrack (track);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_73_set_op189_flag() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_read_next_byte();
|
2002-07-07 19:06:48 +00:00
|
|
|
_op_189_flags |= 1 << vc_read_next_byte();
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::vc_74_clear_op189_flag() {
|
2003-03-06 19:16:24 +00:00
|
|
|
// Simon2
|
2002-06-29 16:11:13 +00:00
|
|
|
vc_read_next_byte();
|
2002-07-07 19:06:48 +00:00
|
|
|
_op_189_flags &= ~(1 << vc_read_next_byte());
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2003-10-03 19:42:27 +00:00
|
|
|
|
|
|
|
} // End of namespace Simon
|