From 55549cd3b2415b5b5d7b7a66223c39fa25446116 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 16 Dec 2004 12:49:25 +0000 Subject: Split simon.cpp more for PalmOS port. svn-id: r16078 --- simon/cursor.cpp | 231 +++++++++++++ simon/icons.cpp | 228 +++++++++++++ simon/module.mk | 3 + simon/saveload.cpp | 614 +++++++++++++++++++++++++++++++++ simon/simon.cpp | 983 ----------------------------------------------------- 5 files changed, 1076 insertions(+), 983 deletions(-) create mode 100644 simon/cursor.cpp create mode 100644 simon/icons.cpp create mode 100644 simon/saveload.cpp diff --git a/simon/cursor.cpp b/simon/cursor.cpp new file mode 100644 index 0000000000..4f8cb75b7d --- /dev/null +++ b/simon/cursor.cpp @@ -0,0 +1,231 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001-2004 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$ + * + */ + +#include "stdafx.h" + +#include "simon/simon.h" +#include "simon/intern.h" + +namespace Simon { + +#ifdef __PALM_OS__ +static const byte *_simon1_cursor; +#else +static const byte _simon1_cursor[256] = { + 0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe1,0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe1,0xe1,0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe1,0xe1,0xe1,0xe1,0xe0,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe1,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +}; +#endif +static const byte _simon2_cursors[10][256] = { + // cross hair + { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xec,0xec,0xec,0xec,0xec,0xef,0xff,0xea,0xff,0xef,0xec,0xec,0xec,0xec,0xec,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + // examine + { 0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xef,0xee,0xeb,0xe4,0xe4,0xe4,0xee,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xef,0xee,0xeb,0xee,0xef,0xef,0xee,0xec,0xee,0xef,0xff,0xff,0xff,0xff,0xff,0xff, + 0xef,0xeb,0xee,0xef,0xee,0xee,0xef,0xee,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, + 0xef,0xeb,0xef,0xef,0xef,0xec,0xee,0xef,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, + 0xef,0xeb,0xef,0xef,0xee,0xef,0xef,0xef,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, + 0xef,0xeb,0xee,0xef,0xef,0xef,0xef,0xee,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, + 0xef,0xee,0xeb,0xee,0xef,0xef,0xee,0xe4,0xee,0xef,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xef,0xee,0xeb,0xeb,0xeb,0xeb,0xee,0xe4,0xec,0xef,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xeb,0xe4,0xee,0xef,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xee,0xe4,0xeb,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xe4,0xeb,0xef,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xec,0xeb,0xef,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xe4,0xef,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xef,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + // pick up + { 0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe5,0xe6,0xe6,0xe7,0xe7,0xe6,0xe6,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe5,0xe7,0xe7,0xe7,0xe7,0xe8,0xe8,0xe8,0xe8,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xe5,0xe6,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe8,0xe9,0xe7,0xe5,0xff,0xff, + 0xff,0xe5,0xe6,0xe7,0xe6,0xe5,0xff,0xff,0xff,0xff,0xe5,0xe6,0xe8,0xe6,0xe5,0xff, + 0xff,0xe5,0xe7,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xe7,0xe5,0xff, + 0xff,0xe5,0xe7,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe7,0xe7,0xe5,0xff, + 0xff,0xef,0xeb,0xeb,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xeb,0xef,0xff, + 0xff,0xef,0xee,0xeb,0xee,0xef,0xff,0xff,0xff,0xff,0xef,0xee,0xeb,0xee,0xef,0xff, + 0xff,0xff,0xef,0xeb,0xeb,0xef,0xff,0xff,0xff,0xff,0xef,0xeb,0xeb,0xef,0xff,0xff, + 0xff,0xff,0xef,0xee,0xe4,0xee,0xef,0xff,0xff,0xef,0xee,0xe4,0xee,0xef,0xff,0xff, + 0xff,0xff,0xff,0xef,0xe4,0xeb,0xef,0xff,0xff,0xef,0xeb,0xe4,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xeb,0xeb,0xeb,0xef,0xef,0xeb,0xeb,0xeb,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xef,0xee,0xee,0xee,0xee,0xe1,0xe1,0xef,0xff,0xff,0xff,0xe4, + 0xef,0xee,0xeb,0xeb,0xeb,0xeb,0xeb,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,0xeb,0xec, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe4 }, + // give + { 0xff,0xff,0xff,0xff,0xff,0xe5,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe9,0xe7,0xe8,0xe8,0xe8,0xe7,0xe9,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xe5,0xe7,0xea,0xe8,0xe8,0xe8,0xea,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe7,0xe8,0xe8,0xea,0xe9,0xea,0xe8,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff, + 0xe5,0xe7,0xe9,0xe8,0xe8,0xe9,0xec,0xe9,0xe8,0xe8,0xe8,0xe7,0xe5,0xff,0xff,0xff, + 0xe5,0xe7,0xe7,0xe9,0xe8,0xec,0xe9,0xec,0xe8,0xe9,0xe7,0xe6,0xe5,0xff,0xff,0xff, + 0xe5,0xe7,0xe7,0xe8,0xec,0xe9,0xe9,0xe9,0xec,0xe7,0xe6,0xe6,0xe5,0xff,0xff,0xff, + 0xe5,0xe7,0xe7,0xea,0xe8,0xe9,0xe9,0xe9,0xe7,0xec,0xec,0xe4,0xe5,0xff,0xff,0xff, + 0xe5,0xe7,0xe7,0xe9,0xe7,0xe8,0xe9,0xe7,0xe6,0xec,0xe4,0xec,0xe4,0xef,0xff,0xff, + 0xe5,0xe6,0xe7,0xe9,0xe7,0xe7,0xe8,0xe6,0xe6,0xe4,0xec,0xe4,0xec,0xe4,0xef,0xff, + 0xff,0xe5,0xe6,0xe9,0xe7,0xe7,0xe8,0xe6,0xe6,0xe8,0xe4,0xec,0xe4,0xec,0xeb,0xff, + 0xff,0xff,0xe5,0xe9,0xe7,0xe7,0xe8,0xe6,0xe6,0xe8,0xe6,0xe4,0xec,0xeb,0xef,0xff, + 0xff,0xff,0xff,0xe8,0xe7,0xe7,0xe8,0xe6,0xe6,0xe7,0xff,0xef,0xeb,0xef,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + // talk + { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xe5,0xe7,0xe8,0xe8,0xe8,0xe7,0xe6,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe6,0xe9,0xea,0xe6,0xea,0xe9,0xe8,0xe9,0xe8,0xe7,0xe5,0xff,0xff,0xff, + 0xff,0xe5,0xe7,0xe5,0xef,0xe5,0xec,0xea,0xe5,0xea,0xec,0xe5,0xe9,0xe6,0xff,0xff, + 0xff,0xe5,0xe6,0xe5,0xef,0xef,0xef,0xe5,0xef,0xef,0xe5,0xef,0xef,0xe8,0xe5,0xff, + 0xff,0xe5,0xe9,0xea,0xe5,0xe8,0xe7,0xe6,0xe6,0xe8,0xe7,0xe5,0xec,0xe9,0xe5,0xff, + 0xff,0xe5,0xe9,0xe8,0xe5,0xe7,0xe8,0xe8,0xe9,0xe9,0xe8,0xe5,0xe9,0xe9,0xe5,0xff, + 0xff,0xe5,0xe6,0xec,0xea,0xe5,0xe6,0xe6,0xe7,0xe7,0xe6,0xe5,0xec,0xe8,0xe5,0xff, + 0xff,0xff,0xe5,0xe9,0xe8,0xe9,0xe5,0xe8,0xe5,0xe8,0xe5,0xe9,0xe9,0xe7,0xe5,0xff, + 0xff,0xff,0xe5,0xe7,0xe9,0xec,0xe8,0xec,0xe8,0xec,0xe8,0xec,0xe8,0xe5,0xff,0xff, + 0xff,0xff,0xff,0xe5,0xe6,0xe8,0xe9,0xe9,0xe9,0xe9,0xe9,0xe8,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + // use + { 0xff,0xff,0xff,0xff,0xff,0xee,0xe1,0xeb,0xee,0xef,0xef,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xe4,0xeb,0xee,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xeb,0xe4,0xe4,0xeb,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xeb,0xe4,0xec,0xe4,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xeb,0xeb,0xe4,0xe4,0xee,0xef,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xee,0xeb,0xeb,0xeb,0xe1,0xef,0xee,0xef, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xef,0xef,0xee,0xeb,0xeb,0xe4,0xee, + 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xff,0xff,0xff,0xef,0xeb,0xec,0xeb,0xef, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xe5,0xff,0xff,0xff,0xee,0xe4,0xeb,0xef,0xff, + 0xff,0xff,0xff,0xe5,0xe5,0xe6,0xe5,0xff,0xff,0xff,0xff,0xef,0xee,0xef,0xff,0xff, + 0xff,0xff,0xe5,0xe6,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff, + 0xff,0xe5,0xe6,0xe8,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe5,0xe6,0xe8,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xe5,0xe6,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + // wear + { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xef,0xeb,0xed,0xe4,0xe2,0xeb,0xee,0xee,0xee,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xef,0xe2,0xec,0xe2,0xe1,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xef,0xeb,0xed,0xeb,0xee,0xef,0xef,0xef,0xee,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xef,0xee,0xe4,0xeb,0xee,0xef,0xef,0xee,0xef,0xef,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xef,0xe4,0xeb,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xef,0xe2,0xeb,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xef,0xeb,0xe1,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xef,0xeb,0xe1,0xee,0xef,0xef,0xef,0xef,0xff,0xff,0xff,0xff, + 0xff,0xef,0xef,0xef,0xe1,0xe4,0xe4,0xe4,0xe1,0xeb,0xee,0xef,0xef,0xef,0xff,0xff, + 0xef,0xee,0xee,0xef,0xee,0xee,0xee,0xee,0xee,0xef,0xef,0xef,0xee,0xee,0xef,0xff, + 0xff,0xef,0xef,0xee,0xe1,0xe2,0xe4,0xe4,0xe4,0xeb,0xe1,0xee,0xef,0xef,0xff,0xff, + 0xff,0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + // move + { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xff, + 0xff,0xe1,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe1,0xff, + 0xff,0xe1,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe1,0xff, + 0xff,0xe1,0xe3,0xe3,0xed,0xec,0xe3,0xe3,0xe3,0xe3,0xec,0xed,0xe3,0xe3,0xe1,0xff, + 0xff,0xe1,0xe3,0xed,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xed,0xe3,0xe1,0xff, + 0xff,0xe1,0xed,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xed,0xe1,0xff, + 0xff,0xe1,0xe3,0xed,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xed,0xe3,0xe1,0xff, + 0xff,0xe1,0xe3,0xe3,0xed,0xec,0xe3,0xe3,0xe3,0xe3,0xec,0xed,0xe3,0xe3,0xe1,0xff, + 0xff,0xe1,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe1,0xff, + 0xff,0xe1,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe1,0xff, + 0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, + // open + { 0xff,0xff,0xe5,0xe8,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xe5,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xe5,0xe7,0xe5,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe5,0xff,0xe5,0xe7,0xe6,0xe9,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xe6,0xea,0xe6,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe6,0xea,0xe6,0xe7,0xe5,0xff,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe6,0xea,0xe6,0xff,0xe5,0xe7,0xe5,0xe7,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe6,0xea,0xe6,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe5,0xff,0xff,0xff, + 0xff,0xe5,0xe6,0xea,0xe6,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe8,0xe5,0xff,0xff,0xff, + 0xff,0xe5,0xe9,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe9,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xea,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe9,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe9,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe9,0xe8,0xe8,0xe8,0xe8,0xe8,0xe7,0xe7,0xe9,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe9,0xe6,0xe6,0xe6,0xe6,0xe6,0xe6,0xe5,0xe9,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe9,0xe8,0xe8,0xe8,0xe8,0xe8,0xe8,0xe7,0xe9,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xe5,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe5,0xff,0xff,0xff,0xff }, + // question mark + { 0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe5,0xe7,0xea,0xec,0xec,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe5,0xe7,0xea,0xec,0xea,0xe9,0xea,0xec,0xe9,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe5,0xe9,0xec,0xe9,0xe8,0xe7,0xe8,0xea,0xec,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xff,0xe5,0xe8,0xe9,0xe8,0xe5,0xe5,0xe8,0xe9,0xec,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe8,0xe9,0xec,0xe9,0xe5,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xec,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xec,0xea,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xea,0xe9,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe7,0xe9,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xe9,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xe9,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, +}; + +void SimonEngine::draw_mouse_pointer() { + if (_game & GF_SIMON2) + _system->setMouseCursor(_simon2_cursors[_mouse_cursor], 16, 16, 7, 7); + else + _system->setMouseCursor(_simon1_cursor, 16, 16, 0, 0); +} + +} // End of namespace Simon diff --git a/simon/icons.cpp b/simon/icons.cpp new file mode 100644 index 0000000000..413195ec8e --- /dev/null +++ b/simon/icons.cpp @@ -0,0 +1,228 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001-2004 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$ + * + */ + +#include "stdafx.h" + +#include "common/file.h" + +#include "simon/simon.h" +#include "simon/intern.h" + +namespace Simon { + +void SimonEngine::loadIconFile() { + File in; + if (_game & GF_ACORN) + in.open("ICONDATA"); + else if (_game & GF_AMIGA) + in.open("icon.pkd"); + else + in.open("ICON.DAT"); + uint size; + + if (in.isOpen() == false) + error("Can't open icons file 'ICON.DAT'"); + + size = in.size(); + + _icon_file_ptr = (byte *)malloc(size); + if (_icon_file_ptr == NULL) + error("Out of icon memory"); + + in.read(_icon_file_ptr, size); + in.close(); +} + +// Thanks to Stuart Caie for providing the original +// C conversion upon which this function is based. +void decompress_icon_amiga (byte *dst, byte *src, byte base, uint pitch) { + byte icon_pln[288]; + byte *i, *o, x, y; + + // Decode RLE planar icon data + i = src; + o = icon_pln; + while (o < &icon_pln[288]) { + x = *i++; + if (x < 128) { + do { + *o++ = *i++; + *o++ = *i++; + *o++ = *i++; + } while (x-- > 0); + } else { + x = 256 - x; + do { + *o++ = i[0]; + *o++ = i[1]; + *o++ = i[2]; + } while (x-- > 0); + i += 3; + } + } + + // Translate planar data to chunky (very slow method) + for (y = 0; y < 24; y++) { + for (x = 0; x < 24; x++) { + byte pixel = + (icon_pln[(( y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 1 : 0) + | (icon_pln[((24 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 2 : 0) + | (icon_pln[((48 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 4 : 0) + | (icon_pln[((72 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 8 : 0); + if (pixel) + dst[x] = pixel | base; + } + dst += pitch; + } +} + +static void decompress_icon(byte *dst, byte *src, uint w, uint h_org, byte base, uint pitch) { + int8 reps; + byte color_1, color_2; + byte *dst_org = dst; + uint h = h_org; + + for (;;) { + reps = *src++; + if (reps < 0) { + reps--; + color_1 = *src >> 4; + if (color_1 != 0) + color_1 |= base; + color_2 = *src++ & 0xF; + if (color_2 != 0) + color_2 |= base; + + do { + if (color_1 != 0) + *dst = color_1; + dst += pitch; + if (color_2 != 0) + *dst = color_2; + dst += pitch; + + // reached bottom? + if (--h == 0) { + // reached right edge? + if (--w == 0) + return; + dst = ++dst_org; + h = h_org; + } + } while (++reps != 0); + } else { + do { + color_1 = *src >> 4; + if (color_1 != 0) + *dst = color_1 | base; + dst += pitch; + + color_2 = *src++ & 0xF; + if (color_2 != 0) + *dst = color_2 | base; + dst += pitch; + + // reached bottom? + if (--h == 0) { + // reached right edge? + if (--w == 0) + return; + dst = ++dst_org; + h = h_org; + } + } while (--reps >= 0); + } + } +} + + +void SimonEngine::draw_icon_c(FillOrCopyStruct *fcs, uint icon, uint x, uint y) { + byte *dst; + byte *src; + + _lock_word |= 0x8000; + dst = dx_lock_2(); + + if (!(_game & GF_SIMON2)) { + // Simon 1 + dst += (x + fcs->x) * 8; + dst += (y * 25 + fcs->y) * _dx_surface_pitch; + + if (_game & GF_AMIGA) { + src = _icon_file_ptr; + src += READ_BE_UINT32(&((uint32 *)src)[icon]); + decompress_icon_amiga (dst, src, 0xE0, _dx_surface_pitch); + } else { + src = _icon_file_ptr; + src += READ_LE_UINT16(&((uint16 *)src)[icon]); + decompress_icon(dst, src, 24, 12, 0xE0, _dx_surface_pitch); + } + } else { + // Simon 2 + dst += 110; + dst += x; + dst += (y + fcs->y) * _dx_surface_pitch; + + src = _icon_file_ptr; + src += READ_LE_UINT16(&((uint16 *)src)[icon * 2 + 0]); + decompress_icon(dst, src, 20, 10, 0xE0, _dx_surface_pitch); + + src = _icon_file_ptr; + src += READ_LE_UINT16(&((uint16 *)src)[icon * 2 + 1]); + decompress_icon(dst, src, 20, 10, 0xD0, _dx_surface_pitch); + } + + dx_unlock_2(); + _lock_word &= ~0x8000; +} + +uint SimonEngine::setup_icon_hit_area(FillOrCopyStruct *fcs, uint x, uint y, uint icon_number, + Item *item_ptr) { + HitArea *ha; + + ha = findEmptyHitArea(); + + if (!(_game & GF_SIMON2)) { + ha->x = (x + fcs->x) << 3; + ha->y = y * 25 + fcs->y; + ha->item_ptr = item_ptr; + ha->width = 24; + ha->height = 24; + ha->flags = 0xB0; + ha->id = 0x7FFD; + ha->layer = 100; + ha->unk3 = 0xD0; + } else { + ha->x = x + 110; + ha->y = fcs->y + y; + ha->item_ptr = item_ptr; + ha->width = 20; + ha->height = 20; + ha->flags = 0xB0; + ha->id = 0x7FFD; + ha->layer = 100; + ha->unk3 = 0xD0; + } + + return ha - _hit_areas; +} + +} // End of namespace Simon diff --git a/simon/module.mk b/simon/module.mk index 9b3677995f..28878d9ce3 100644 --- a/simon/module.mk +++ b/simon/module.mk @@ -2,12 +2,15 @@ MODULE := simon MODULE_OBJS := \ simon/charset.o \ + simon/cursor.o \ simon/debug.o \ simon/debugger.o \ + simon/icons.o \ simon/items.o \ simon/midi.o \ simon/midiparser_s1d.o \ simon/res.o \ + simon/saveload.o \ simon/sound.o \ simon/simon.o \ simon/verb.o \ diff --git a/simon/saveload.cpp b/simon/saveload.cpp new file mode 100644 index 0000000000..34c8903722 --- /dev/null +++ b/simon/saveload.cpp @@ -0,0 +1,614 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001-2004 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$ + * + */ + +#include "stdafx.h" + +#include "gui/about.h" +#include "gui/message.h" + +#include "simon/simon.h" +#include "simon/intern.h" + +namespace Simon { + +void SimonEngine::o_save_game() { + save_or_load_dialog(false); +} + +void SimonEngine::o_load_game() { + save_or_load_dialog(true); +} + +int SimonEngine::count_savegames() { + SaveFile *f; + uint i = 1; + bool marks[256]; + + char *prefix = gen_savename(999); + prefix[strlen(prefix)-3] = '\0'; + _saveFileMan->listSavefiles(prefix, marks, 256); + + while (i < 256) { + if (marks[i] && + (f = _saveFileMan->openSavefile(gen_savename(i), false))) { + i++; + delete f; + } else + break; + } + return i; +} + +int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) { + int slot, last_slot; + SaveFile *in; + + showMessageFormat("\xC"); + + memset(dst, 0, 18 * 6); + + slot = curpos; + + while (curpos + 6 > slot) { + if(!(in = _saveFileMan->openSavefile(gen_savename(slot), false))) + break; + + in->read(dst, 18); + delete in; + last_slot = slot; + if (slot < 10) + showMessageFormat(" "); + showMessageFormat("%d", slot); + showMessageFormat(".%s\n", dst); + dst += 18; + slot++; + } + // while_break + if (!load) { + if (curpos + 6 == slot) + slot++; + else { + if (slot < 10) + showMessageFormat(" "); + showMessageFormat("%d.\n", slot); + } + } else { + if (curpos + 6 == slot) { + if((in = _saveFileMan->openSavefile(gen_savename(slot), false))) { + slot++; + delete in; + } + } + } + + return slot - curpos; +} + +void SimonEngine::quick_load_or_save() { + // simon1demo subroutines are missing too many segments + // original demo didn't allow load or save either. + if (_game == GAME_SIMON1DEMO) + return; + + bool success; + char buf[50]; + + char *filename = gen_savename(_saveLoadSlot); + if (_saveLoadFlag == 2) { + Subroutine *sub; + success = load_game(_saveLoadSlot); + if (!success) { + sprintf(buf, "Failed to load game state to file:\n\n%s", filename); + } else { + // Redraw Inventory + lock(); + fcs_unk_proc_1(2, getItem1Ptr(), 0, 0); + unlock(); + // Reset engine? + vc_set_bit_to(97, true); + sub = getSubroutineByID(100); + startSubroutine(sub); + } + } else { + success = save_game(_saveLoadSlot, _saveLoadName); + if (!success) + sprintf(buf, "Failed to save game state to file:\n\n%s", filename); + } + + if (!success) { + GUI::MessageDialog dialog(buf, "OK"); + dialog.runModal(); + + } else if (_saveLoadFlag == 1) { + sprintf(buf, "Successfully saved game state in file:\n\n%s", filename); + GUI::TimedMessageDialog dialog(buf, 1500); + dialog.runModal(); + + } + + _saveLoadFlag = 0; +} + +void SimonEngine::savegame_dialog(char *buf) { + int i; + + o_unk_132_helper_3(); + + i = display_savegame_list(_saveload_row_curpos, _save_or_load, buf); + + _savedialog_flag = true; + + if (i != 7) { + i++; + if (!_save_or_load) + i++; + _savedialog_flag = false; + } + + if (!--i) + return; + + do { + clear_hitarea_bit_0x40(0xd0 + i - 1); + } while (--i); +} + +void SimonEngine::save_or_load_dialog(bool load) { + time_t save_time; + int number_of_savegames; + int i; + int unk132_result; + FillOrCopyStruct *fcs; + char *name; + int name_len; + bool b; + char buf[108]; + + _save_or_load = load; + + save_time = time(NULL); + + _copy_partial_mode = 1; + + number_of_savegames = count_savegames(); + if (!load) + number_of_savegames++; + number_of_savegames -= 6; + if (number_of_savegames < 0) + number_of_savegames = 0; + number_of_savegames++; + _num_savegame_rows = number_of_savegames; + + _saveload_row_curpos = 1; + if (!load) + _saveload_row_curpos = number_of_savegames; + + _saveload_flag = false; + +restart:; + do { + i = o_unk_132_helper(&b, buf); + } while (!b); + + if (i == 205) + goto get_out; + if (!load) { + // if_1 + if_1:; + unk132_result = i; + + set_hitarea_bit_0x40(0xd0 + i); + leaveHitAreaById(0xd0 + i); + + // some code here + + fcs = _fcs_ptr_array_3[5]; + + fcs->textRow = unk132_result; + + if (_language == 20) { //Hebrew + // init x offset with a 2 character savegame number + a period (18 pix) + fcs->textColumn = 3; + fcs->textColumnOffset = 6; + fcs->textLength = 3; + } else { + // init x offset with a 2 character savegame number + a period (18 pix) + fcs->textColumn = 2; + fcs->textColumnOffset = 2; + fcs->textLength = 3; + } + + name = buf + i * 18; + + // now process entire savegame name to get correct x offset for cursor + name_len = 0; + while (name[name_len]) { + if (_language == 20) { //Hebrew + byte width = 6; + if (name[name_len] >= 64 && name[name_len] < 91) + width = _hebrew_char_widths [name[name_len] - 64]; + fcs->textLength++; + fcs->textColumnOffset -= width; + if (fcs->textColumnOffset < width) { + fcs->textColumnOffset += 8; + fcs->textColumn++; + } + } else { + fcs->textLength++; + fcs->textColumnOffset += 6; + if (name[name_len] == 'i' || name[name_len] == 'l') + fcs->textColumnOffset -= 2; + if (fcs->textColumnOffset >= 8) { + fcs->textColumnOffset -= 8; + fcs->textColumn++; + } + } + name_len++; + } + // while_1_end + + // do_3_start + for (;;) { + video_putchar(fcs, 0x7f); + + _saveload_flag = true; + + // do_2 + do { + i = o_unk_132_helper(&b, buf); + + if (b) { + if (i == 205) + goto get_out; + clear_hitarea_bit_0x40(0xd0 + unk132_result); + if (_saveload_flag) { + o_clear_character(_fcs_ptr_array_3[5], 8); + // move code + } + goto if_1; + } + + // is_not_b + if (!_saveload_flag) { + clear_hitarea_bit_0x40(0xd0 + unk132_result); + goto restart; + } + } while (i >= 0x80 || i == 0); + + // after_do_2 + o_clear_character(_fcs_ptr_array_3[5], 8); + if (i == 10 || i == 13) + break; + if (i == 8) { + // do_backspace + if (name_len != 0) { + int x; + byte m; + + name_len--; + m = name[name_len]; + + if (_language == 20) //Hebrew + x = 8; + else + x = (name[name_len] == 'i' || name[name_len] == 'l') ? 1 : 8; + + name[name_len] = 0; + + o_clear_character(_fcs_ptr_array_3[5], x, m); + } + } else if (i >= 32 && name_len != 17) { + name[name_len++] = i; + + video_putchar(_fcs_ptr_array_3[5], i); + } + } + + // do_save + if (!save_game(_saveload_row_curpos + unk132_result, buf + unk132_result * 18)) + o_file_error(_fcs_ptr_array_3[5], true); + } else { + if (!load_game(_saveload_row_curpos + i)) + o_file_error(_fcs_ptr_array_3[5], false); + } + +get_out:; + o_unk_132_helper_3(); + + _base_time = time(NULL) - save_time + _base_time; + _copy_partial_mode = 0; + + dx_copy_rgn_from_3_to_2(94, 208, 46, 80); + + i = _timer_4; + do { + delay(10); + } while (i == _timer_4); + + g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); +} + +void SimonEngine::o_file_error(FillOrCopyStruct *fcs, bool save_error) { + HitArea *ha; + const char *string, *string2; + + if (save_error) { + string = "\r Save failed."; + string2 = "\r Disk error."; + } else { + string = "\r Load failed."; + string2 = "\r File not found."; + } + + video_putchar(fcs, 0xC); + for (; *string; string++) + video_putchar(fcs, *string); + for (; *string2; string2++) + video_putchar(fcs, *string2); + + fcs->textColumn = (fcs->width >> 1) - 3; + fcs->textRow = fcs->height - 1; + fcs->textLength = 0; + + string = "[ OK ]"; + for (; *string; string++) + video_putchar(fcs, *string); + + ha = findEmptyHitArea(); + ha->x = ((fcs->width >> 1) + (fcs->x - 3)) << 3; + ha->y = (fcs->height << 3) + fcs->y - 8; + ha->width = 48; + ha->height = 8; + ha->flags = 0x20; + ha->id = 0x7FFF; + ha->layer = 0x3EF; + +loop:; + _last_hitarea = _last_hitarea_3 = 0; + + do { + delay(1); + } while (_last_hitarea_3 == 0); + + ha = _last_hitarea; + if (ha == NULL || ha->id != 0x7FFF) + goto loop; + + // Return + delete_hitarea(0x7FFF); +} + +bool SimonEngine::save_game(uint slot, char *caption) { + SaveFile *f; + uint item_index, num_item, i, j; + TimeEvent *te; + + _lock_word |= 0x100; + +#ifndef _WIN32_WCE + errno = 0; +#endif + + + f = _saveFileMan->openSavefile(gen_savename(slot), true); + if (f == NULL) { + _lock_word &= ~0x100; + return false; + } + + f->write(caption, 0x12); + + f->writeUint32BE(_itemarray_inited - 1); + f->writeUint32BE(0xFFFFFFFF); + f->writeUint32BE(0); + f->writeUint32BE(0); + + i = 0; + for (te = _first_time_struct; te; te = te->next) + i++; + f->writeUint32BE(i); + + for (te = _first_time_struct; te; te = te->next) { + f->writeUint32BE(te->time + _base_time); + f->writeUint16BE(te->subroutine_id); + } + + item_index = 1; + for (num_item = _itemarray_inited - 1; num_item; num_item--) { + Item *item = _itemarray_ptr[item_index++]; + + f->writeUint16BE(item->parent); + f->writeUint16BE(item->sibling); + f->writeUint16BE(item->unk3); + f->writeUint16BE(item->unk4); + + Child1 *child1 = (Child1 *)findChildOfType(item, 1); + if (child1) { + f->writeUint16BE(child1->fr2); + } + + Child2 *child2 = (Child2 *)findChildOfType(item, 2); + if (child2) { + f->writeUint32BE(child2->avail_props); + i = child2->avail_props & 1; + + for (j = 1; j < 16; j++) { + if ((1 << j) & child2->avail_props) { + f->writeUint16BE(child2->array[i++]); + } + } + } + + Child9 *child9 = (Child9 *) findChildOfType(item, 9); + if (child9) { + for (i = 0; i != 4; i++) { + f->writeUint16BE(child9->array[i]); + } + } + } + + // write the 255 variables + for (i = 0; i != 255; i++) { + f->writeUint16BE(readVariable(i)); + } + + // write the items in array 6 + for (i = 0; i != 10; i++) { + f->writeUint16BE(itemPtrToID(_item_array_6[i])); + } + + // Write the bits in array 1 & 2 + for (i = 0; i != 32; i++) + f->writeUint16BE(_bit_array[i]); + + delete f; + + _lock_word &= ~0x100; + + return true; +} + +char *SimonEngine::gen_savename(int slot) { + static char buf[15]; + + if (_game & GF_SIMON2) { + sprintf(buf, "simon2.%.3d", slot); + } else { + sprintf(buf, "simon1.%.3d", slot); + } + return buf; +} + +bool SimonEngine::load_game(uint slot) { + char ident[18]; + SaveFile *f; + uint num, item_index, i, j; + + _lock_word |= 0x100; + +#ifndef _WIN32_WCE + errno = 0; +#endif + + + f = _saveFileMan->openSavefile(gen_savename(slot), false); + if (f == NULL) { + _lock_word &= ~0x100; + return false; + } + + f->read(ident, 18); + + num = f->readUint32BE(); + + if (f->readUint32BE() != 0xFFFFFFFF || num != _itemarray_inited - 1) { + delete f; + _lock_word &= ~0x100; + return false; + } + + f->readUint32BE(); + f->readUint32BE(); + _no_parent_notify = true; + + + // add all timers + killAllTimers(); + for (num = f->readUint32BE(); num; num--) { + uint32 timeout = f->readUint32BE(); + uint16 func_to_call = f->readUint16BE(); + addTimeEvent(timeout, func_to_call); + } + + item_index = 1; + for (num = _itemarray_inited - 1; num; num--) { + Item *item = _itemarray_ptr[item_index++], *parent_item; + + uint parent = f->readUint16BE(); + uint sibling = f->readUint16BE(); + + parent_item = derefItem(parent); + + setItemParent(item, parent_item); + + if (parent_item == NULL) { + item->parent = parent; + item->sibling = sibling; + } + + item->unk3 = f->readUint16BE(); + item->unk4 = f->readUint16BE(); + + Child1 *child1 = (Child1 *)findChildOfType(item, 1); + if (child1 != NULL) { + child1->fr2 = f->readUint16BE(); + } + + Child2 *child2 = (Child2 *)findChildOfType(item, 2); + if (child2 != NULL) { + child2->avail_props = f->readUint32BE(); + i = child2->avail_props & 1; + + for (j = 1; j < 16; j++) { + if ((1 << j) & child2->avail_props) { + child2->array[i++] = f->readUint16BE(); + } + } + } + + Child9 *child9 = (Child9 *) findChildOfType(item, 9); + if (child9) { + for (i = 0; i != 4; i++) { + child9->array[i] = f->readUint16BE(); + } + } + } + + + // read the 255 variables + for (i = 0; i != 255; i++) { + writeVariable(i, f->readUint16BE()); + } + + // write the items in array 6 + for (i = 0; i != 10; i++) { + _item_array_6[i] = derefItem(f->readUint16BE()); + } + + // Write the bits in array 1 & 2 + for (i = 0; i != 32; i++) + _bit_array[i] = f->readUint16BE(); + + delete f; + + _no_parent_notify = false; + + _lock_word &= ~0x100; + +#ifndef _WIN32_WCE + if (errno != 0) + error("load failed"); +#endif + + return true; +} + +} // End of namespace Simon diff --git a/simon/simon.cpp b/simon/simon.cpp index bb455aae93..48fceb20f6 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -1933,60 +1933,6 @@ uint SimonEngine::item_get_icon_number(Item *item) { return child->array[offs]; } -void SimonEngine::loadIconFile() { - File in; - if (_game & GF_ACORN) - in.open("ICONDATA"); - else if (_game & GF_AMIGA) - in.open("icon.pkd"); - else - in.open("ICON.DAT"); - uint size; - - if (in.isOpen() == false) - error("Can't open icons file 'ICON.DAT'"); - - size = in.size(); - - _icon_file_ptr = (byte *)malloc(size); - if (_icon_file_ptr == NULL) - error("Out of icon memory"); - - in.read(_icon_file_ptr, size); - in.close(); -} - -uint SimonEngine::setup_icon_hit_area(FillOrCopyStruct *fcs, uint x, uint y, uint icon_number, - Item *item_ptr) { - HitArea *ha; - - ha = findEmptyHitArea(); - - if (!(_game & GF_SIMON2)) { - ha->x = (x + fcs->x) << 3; - ha->y = y * 25 + fcs->y; - ha->item_ptr = item_ptr; - ha->width = 24; - ha->height = 24; - ha->flags = 0xB0; - ha->id = 0x7FFD; - ha->layer = 100; - ha->unk3 = 0xD0; - } else { - ha->x = x + 110; - ha->y = fcs->y + y; - ha->item_ptr = item_ptr; - ha->width = 20; - ha->height = 20; - ha->flags = 0xB0; - ha->id = 0x7FFD; - ha->layer = 100; - ha->unk3 = 0xD0; - } - - return ha - _hit_areas; -} - void SimonEngine::f10_key() { HitArea *ha, *dha; uint count; @@ -2719,328 +2665,6 @@ void SimonEngine::o_force_lock() { } } -void SimonEngine::o_save_game() { - save_or_load_dialog(false); -} - -void SimonEngine::o_load_game() { - save_or_load_dialog(true); -} - -int SimonEngine::count_savegames() { - SaveFile *f; - uint i = 1; - bool marks[256]; - - char *prefix = gen_savename(999); - prefix[strlen(prefix)-3] = '\0'; - _saveFileMan->listSavefiles(prefix, marks, 256); - - while (i < 256) { - if (marks[i] && - (f = _saveFileMan->openSavefile(gen_savename(i), false))) { - i++; - delete f; - } else - break; - } - return i; -} - -int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) { - int slot, last_slot; - SaveFile *in; - - showMessageFormat("\xC"); - - memset(dst, 0, 18 * 6); - - slot = curpos; - - while (curpos + 6 > slot) { - if(!(in = _saveFileMan->openSavefile(gen_savename(slot), false))) - break; - - in->read(dst, 18); - delete in; - last_slot = slot; - if (slot < 10) - showMessageFormat(" "); - showMessageFormat("%d", slot); - showMessageFormat(".%s\n", dst); - dst += 18; - slot++; - } - // while_break - if (!load) { - if (curpos + 6 == slot) - slot++; - else { - if (slot < 10) - showMessageFormat(" "); - showMessageFormat("%d.\n", slot); - } - } else { - if (curpos + 6 == slot) { - if((in = _saveFileMan->openSavefile(gen_savename(slot), false))) { - slot++; - delete in; - } - } - } - - return slot - curpos; -} - -void SimonEngine::savegame_dialog(char *buf) { - int i; - - o_unk_132_helper_3(); - - i = display_savegame_list(_saveload_row_curpos, _save_or_load, buf); - - _savedialog_flag = true; - - if (i != 7) { - i++; - if (!_save_or_load) - i++; - _savedialog_flag = false; - } - - if (!--i) - return; - - do { - clear_hitarea_bit_0x40(0xd0 + i - 1); - } while (--i); -} - -void SimonEngine::save_or_load_dialog(bool load) { - time_t save_time; - int number_of_savegames; - int i; - int unk132_result; - FillOrCopyStruct *fcs; - char *name; - int name_len; - bool b; - char buf[108]; - - _save_or_load = load; - - save_time = time(NULL); - - _copy_partial_mode = 1; - - number_of_savegames = count_savegames(); - if (!load) - number_of_savegames++; - number_of_savegames -= 6; - if (number_of_savegames < 0) - number_of_savegames = 0; - number_of_savegames++; - _num_savegame_rows = number_of_savegames; - - _saveload_row_curpos = 1; - if (!load) - _saveload_row_curpos = number_of_savegames; - - _saveload_flag = false; - -restart:; - do { - i = o_unk_132_helper(&b, buf); - } while (!b); - - if (i == 205) - goto get_out; - if (!load) { - // if_1 - if_1:; - unk132_result = i; - - set_hitarea_bit_0x40(0xd0 + i); - leaveHitAreaById(0xd0 + i); - - // some code here - - fcs = _fcs_ptr_array_3[5]; - - fcs->textRow = unk132_result; - - if (_language == 20) { //Hebrew - // init x offset with a 2 character savegame number + a period (18 pix) - fcs->textColumn = 3; - fcs->textColumnOffset = 6; - fcs->textLength = 3; - } else { - // init x offset with a 2 character savegame number + a period (18 pix) - fcs->textColumn = 2; - fcs->textColumnOffset = 2; - fcs->textLength = 3; - } - - name = buf + i * 18; - - // now process entire savegame name to get correct x offset for cursor - name_len = 0; - while (name[name_len]) { - if (_language == 20) { //Hebrew - byte width = 6; - if (name[name_len] >= 64 && name[name_len] < 91) - width = _hebrew_char_widths [name[name_len] - 64]; - fcs->textLength++; - fcs->textColumnOffset -= width; - if (fcs->textColumnOffset < width) { - fcs->textColumnOffset += 8; - fcs->textColumn++; - } - } else { - fcs->textLength++; - fcs->textColumnOffset += 6; - if (name[name_len] == 'i' || name[name_len] == 'l') - fcs->textColumnOffset -= 2; - if (fcs->textColumnOffset >= 8) { - fcs->textColumnOffset -= 8; - fcs->textColumn++; - } - } - name_len++; - } - // while_1_end - - // do_3_start - for (;;) { - video_putchar(fcs, 0x7f); - - _saveload_flag = true; - - // do_2 - do { - i = o_unk_132_helper(&b, buf); - - if (b) { - if (i == 205) - goto get_out; - clear_hitarea_bit_0x40(0xd0 + unk132_result); - if (_saveload_flag) { - o_clear_character(_fcs_ptr_array_3[5], 8); - // move code - } - goto if_1; - } - - // is_not_b - if (!_saveload_flag) { - clear_hitarea_bit_0x40(0xd0 + unk132_result); - goto restart; - } - } while (i >= 0x80 || i == 0); - - // after_do_2 - o_clear_character(_fcs_ptr_array_3[5], 8); - if (i == 10 || i == 13) - break; - if (i == 8) { - // do_backspace - if (name_len != 0) { - int x; - byte m; - - name_len--; - m = name[name_len]; - - if (_language == 20) //Hebrew - x = 8; - else - x = (name[name_len] == 'i' || name[name_len] == 'l') ? 1 : 8; - - name[name_len] = 0; - - o_clear_character(_fcs_ptr_array_3[5], x, m); - } - } else if (i >= 32 && name_len != 17) { - name[name_len++] = i; - - video_putchar(_fcs_ptr_array_3[5], i); - } - } - - // do_save - if (!save_game(_saveload_row_curpos + unk132_result, buf + unk132_result * 18)) - o_file_error(_fcs_ptr_array_3[5], true); - } else { - if (!load_game(_saveload_row_curpos + i)) - o_file_error(_fcs_ptr_array_3[5], false); - } - -get_out:; - o_unk_132_helper_3(); - - _base_time = time(NULL) - save_time + _base_time; - _copy_partial_mode = 0; - - dx_copy_rgn_from_3_to_2(94, 208, 46, 80); - - i = _timer_4; - do { - delay(10); - } while (i == _timer_4); - - g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); -} - -void SimonEngine::o_file_error(FillOrCopyStruct *fcs, bool save_error) { - HitArea *ha; - const char *string, *string2; - - if (save_error) { - string = "\r Save failed."; - string2 = "\r Disk error."; - } else { - string = "\r Load failed."; - string2 = "\r File not found."; - } - - video_putchar(fcs, 0xC); - for (; *string; string++) - video_putchar(fcs, *string); - for (; *string2; string2++) - video_putchar(fcs, *string2); - - fcs->textColumn = (fcs->width >> 1) - 3; - fcs->textRow = fcs->height - 1; - fcs->textLength = 0; - - string = "[ OK ]"; - for (; *string; string++) - video_putchar(fcs, *string); - - ha = findEmptyHitArea(); - ha->x = ((fcs->width >> 1) + (fcs->x - 3)) << 3; - ha->y = (fcs->height << 3) + fcs->y - 8; - ha->width = 48; - ha->height = 8; - ha->flags = 0x20; - ha->id = 0x7FFF; - ha->layer = 0x3EF; - -loop:; - _last_hitarea = _last_hitarea_3 = 0; - - do { - delay(1); - } while (_last_hitarea_3 == 0); - - ha = _last_hitarea; - if (ha == NULL || ha->id != 0x7FFF) - goto loop; - - // Return - delete_hitarea(0x7FFF); -} - void SimonEngine::o_wait_for_vga(uint a) { _vga_wait_for = a; _timer_1 = 0; @@ -3668,352 +3292,6 @@ void SimonEngine::pause() { } -#ifdef __PALM_OS__ -static const byte *_simon1_cursor; -#else -static const byte _simon1_cursor[256] = { - 0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe1,0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe1,0xe1,0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe1,0xe1,0xe1,0xe1,0xe0,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe1,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe1,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -}; -#endif - -static const byte _simon2_cursors[10][256] = { - // cross hair - { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xec,0xec,0xec,0xec,0xec,0xef,0xff,0xea,0xff,0xef,0xec,0xec,0xec,0xec,0xec,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, - // examine - { 0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xef,0xee,0xeb,0xe4,0xe4,0xe4,0xee,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xef,0xee,0xeb,0xee,0xef,0xef,0xee,0xec,0xee,0xef,0xff,0xff,0xff,0xff,0xff,0xff, - 0xef,0xeb,0xee,0xef,0xee,0xee,0xef,0xee,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, - 0xef,0xeb,0xef,0xef,0xef,0xec,0xee,0xef,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, - 0xef,0xeb,0xef,0xef,0xee,0xef,0xef,0xef,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, - 0xef,0xeb,0xee,0xef,0xef,0xef,0xef,0xee,0xe4,0xef,0xff,0xff,0xff,0xff,0xff,0xff, - 0xef,0xee,0xeb,0xee,0xef,0xef,0xee,0xe4,0xee,0xef,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xef,0xee,0xeb,0xeb,0xeb,0xeb,0xee,0xe4,0xec,0xef,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xeb,0xe4,0xee,0xef,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xee,0xe4,0xeb,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xe4,0xeb,0xef,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xec,0xeb,0xef,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xe4,0xef,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xef,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, - // pick up - { 0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe5,0xe6,0xe6,0xe7,0xe7,0xe6,0xe6,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe5,0xe7,0xe7,0xe7,0xe7,0xe8,0xe8,0xe8,0xe8,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xe5,0xe6,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe8,0xe9,0xe7,0xe5,0xff,0xff, - 0xff,0xe5,0xe6,0xe7,0xe6,0xe5,0xff,0xff,0xff,0xff,0xe5,0xe6,0xe8,0xe6,0xe5,0xff, - 0xff,0xe5,0xe7,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xe7,0xe5,0xff, - 0xff,0xe5,0xe7,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe7,0xe7,0xe5,0xff, - 0xff,0xef,0xeb,0xeb,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xeb,0xeb,0xef,0xff, - 0xff,0xef,0xee,0xeb,0xee,0xef,0xff,0xff,0xff,0xff,0xef,0xee,0xeb,0xee,0xef,0xff, - 0xff,0xff,0xef,0xeb,0xeb,0xef,0xff,0xff,0xff,0xff,0xef,0xeb,0xeb,0xef,0xff,0xff, - 0xff,0xff,0xef,0xee,0xe4,0xee,0xef,0xff,0xff,0xef,0xee,0xe4,0xee,0xef,0xff,0xff, - 0xff,0xff,0xff,0xef,0xe4,0xeb,0xef,0xff,0xff,0xef,0xeb,0xe4,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xeb,0xeb,0xeb,0xef,0xef,0xeb,0xeb,0xeb,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xef,0xee,0xee,0xee,0xee,0xe1,0xe1,0xef,0xff,0xff,0xff,0xe4, - 0xef,0xee,0xeb,0xeb,0xeb,0xeb,0xeb,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,0xeb,0xec, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe4 }, - // give - { 0xff,0xff,0xff,0xff,0xff,0xe5,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe9,0xe7,0xe8,0xe8,0xe8,0xe7,0xe9,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xe5,0xe7,0xea,0xe8,0xe8,0xe8,0xea,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe7,0xe8,0xe8,0xea,0xe9,0xea,0xe8,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff, - 0xe5,0xe7,0xe9,0xe8,0xe8,0xe9,0xec,0xe9,0xe8,0xe8,0xe8,0xe7,0xe5,0xff,0xff,0xff, - 0xe5,0xe7,0xe7,0xe9,0xe8,0xec,0xe9,0xec,0xe8,0xe9,0xe7,0xe6,0xe5,0xff,0xff,0xff, - 0xe5,0xe7,0xe7,0xe8,0xec,0xe9,0xe9,0xe9,0xec,0xe7,0xe6,0xe6,0xe5,0xff,0xff,0xff, - 0xe5,0xe7,0xe7,0xea,0xe8,0xe9,0xe9,0xe9,0xe7,0xec,0xec,0xe4,0xe5,0xff,0xff,0xff, - 0xe5,0xe7,0xe7,0xe9,0xe7,0xe8,0xe9,0xe7,0xe6,0xec,0xe4,0xec,0xe4,0xef,0xff,0xff, - 0xe5,0xe6,0xe7,0xe9,0xe7,0xe7,0xe8,0xe6,0xe6,0xe4,0xec,0xe4,0xec,0xe4,0xef,0xff, - 0xff,0xe5,0xe6,0xe9,0xe7,0xe7,0xe8,0xe6,0xe6,0xe8,0xe4,0xec,0xe4,0xec,0xeb,0xff, - 0xff,0xff,0xe5,0xe9,0xe7,0xe7,0xe8,0xe6,0xe6,0xe8,0xe6,0xe4,0xec,0xeb,0xef,0xff, - 0xff,0xff,0xff,0xe8,0xe7,0xe7,0xe8,0xe6,0xe6,0xe7,0xff,0xef,0xeb,0xef,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, - // talk - { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xe5,0xe7,0xe8,0xe8,0xe8,0xe7,0xe6,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe6,0xe9,0xea,0xe6,0xea,0xe9,0xe8,0xe9,0xe8,0xe7,0xe5,0xff,0xff,0xff, - 0xff,0xe5,0xe7,0xe5,0xef,0xe5,0xec,0xea,0xe5,0xea,0xec,0xe5,0xe9,0xe6,0xff,0xff, - 0xff,0xe5,0xe6,0xe5,0xef,0xef,0xef,0xe5,0xef,0xef,0xe5,0xef,0xef,0xe8,0xe5,0xff, - 0xff,0xe5,0xe9,0xea,0xe5,0xe8,0xe7,0xe6,0xe6,0xe8,0xe7,0xe5,0xec,0xe9,0xe5,0xff, - 0xff,0xe5,0xe9,0xe8,0xe5,0xe7,0xe8,0xe8,0xe9,0xe9,0xe8,0xe5,0xe9,0xe9,0xe5,0xff, - 0xff,0xe5,0xe6,0xec,0xea,0xe5,0xe6,0xe6,0xe7,0xe7,0xe6,0xe5,0xec,0xe8,0xe5,0xff, - 0xff,0xff,0xe5,0xe9,0xe8,0xe9,0xe5,0xe8,0xe5,0xe8,0xe5,0xe9,0xe9,0xe7,0xe5,0xff, - 0xff,0xff,0xe5,0xe7,0xe9,0xec,0xe8,0xec,0xe8,0xec,0xe8,0xec,0xe8,0xe5,0xff,0xff, - 0xff,0xff,0xff,0xe5,0xe6,0xe8,0xe9,0xe9,0xe9,0xe9,0xe9,0xe8,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, - // use - { 0xff,0xff,0xff,0xff,0xff,0xee,0xe1,0xeb,0xee,0xef,0xef,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xe4,0xeb,0xee,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xeb,0xe4,0xe4,0xeb,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xeb,0xe4,0xec,0xe4,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xeb,0xeb,0xe4,0xe4,0xee,0xef,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xee,0xeb,0xeb,0xeb,0xe1,0xef,0xee,0xef, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xef,0xef,0xee,0xeb,0xeb,0xe4,0xee, - 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xff,0xff,0xff,0xef,0xeb,0xec,0xeb,0xef, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe6,0xe5,0xff,0xff,0xff,0xee,0xe4,0xeb,0xef,0xff, - 0xff,0xff,0xff,0xe5,0xe5,0xe6,0xe5,0xff,0xff,0xff,0xff,0xef,0xee,0xef,0xff,0xff, - 0xff,0xff,0xe5,0xe6,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff, - 0xff,0xe5,0xe6,0xe8,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe5,0xe6,0xe8,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xe5,0xe6,0xe6,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, - // wear - { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xef,0xeb,0xed,0xe4,0xe2,0xeb,0xee,0xee,0xee,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xef,0xe2,0xec,0xe2,0xe1,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xef,0xeb,0xed,0xeb,0xee,0xef,0xef,0xef,0xee,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xef,0xee,0xe4,0xeb,0xee,0xef,0xef,0xee,0xef,0xef,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xef,0xe4,0xeb,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xef,0xe2,0xeb,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xef,0xeb,0xe1,0xee,0xef,0xef,0xee,0xef,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xef,0xeb,0xe1,0xee,0xef,0xef,0xef,0xef,0xff,0xff,0xff,0xff, - 0xff,0xef,0xef,0xef,0xe1,0xe4,0xe4,0xe4,0xe1,0xeb,0xee,0xef,0xef,0xef,0xff,0xff, - 0xef,0xee,0xee,0xef,0xee,0xee,0xee,0xee,0xee,0xef,0xef,0xef,0xee,0xee,0xef,0xff, - 0xff,0xef,0xef,0xee,0xe1,0xe2,0xe4,0xe4,0xe4,0xeb,0xe1,0xee,0xef,0xef,0xff,0xff, - 0xff,0xff,0xff,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, - // move - { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xff, - 0xff,0xe1,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe1,0xff, - 0xff,0xe1,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe1,0xff, - 0xff,0xe1,0xe3,0xe3,0xed,0xec,0xe3,0xe3,0xe3,0xe3,0xec,0xed,0xe3,0xe3,0xe1,0xff, - 0xff,0xe1,0xe3,0xed,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xed,0xe3,0xe1,0xff, - 0xff,0xe1,0xed,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xed,0xe1,0xff, - 0xff,0xe1,0xe3,0xed,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xec,0xed,0xe3,0xe1,0xff, - 0xff,0xe1,0xe3,0xe3,0xed,0xec,0xe3,0xe3,0xe3,0xe3,0xec,0xed,0xe3,0xe3,0xe1,0xff, - 0xff,0xe1,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe3,0xed,0xe3,0xe3,0xe3,0xe1,0xff, - 0xff,0xe1,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe1,0xff, - 0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, - // open - { 0xff,0xff,0xe5,0xe8,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xe5,0xe8,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xe5,0xe7,0xe5,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe5,0xff,0xe5,0xe7,0xe6,0xe9,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xe6,0xea,0xe6,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe6,0xea,0xe6,0xe7,0xe5,0xff,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe6,0xea,0xe6,0xff,0xe5,0xe7,0xe5,0xe7,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe6,0xea,0xe6,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe5,0xff,0xff,0xff, - 0xff,0xe5,0xe6,0xea,0xe6,0xff,0xff,0xff,0xe5,0xe7,0xe8,0xe8,0xe5,0xff,0xff,0xff, - 0xff,0xe5,0xe9,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe9,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xea,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe9,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe9,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe9,0xe8,0xe8,0xe8,0xe8,0xe8,0xe7,0xe7,0xe9,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe9,0xe6,0xe6,0xe6,0xe6,0xe6,0xe6,0xe5,0xe9,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe9,0xe8,0xe8,0xe8,0xe8,0xe8,0xe8,0xe7,0xe9,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xe5,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe5,0xff,0xff,0xff,0xff }, - // question mark - { 0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe5,0xe7,0xea,0xec,0xec,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe5,0xe7,0xea,0xec,0xea,0xe9,0xea,0xec,0xe9,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe5,0xe9,0xec,0xe9,0xe8,0xe7,0xe8,0xea,0xec,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xff,0xe5,0xe8,0xe9,0xe8,0xe5,0xe5,0xe8,0xe9,0xec,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xe5,0xe8,0xe9,0xec,0xe9,0xe5,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xec,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xec,0xea,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xea,0xe9,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe7,0xe9,0xe7,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xe9,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe9,0xec,0xe9,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xe5,0xe8,0xe9,0xe8,0xe5,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, -}; - -void SimonEngine::draw_mouse_pointer() { - if (_game & GF_SIMON2) - _system->setMouseCursor(_simon2_cursors[_mouse_cursor], 16, 16, 7, 7); - else - _system->setMouseCursor(_simon1_cursor, 16, 16, 0, 0); -} - -// Thanks to Stuart Caie for providing the original -// C conversion upon which this function is based. -void decompress_icon_amiga (byte *dst, byte *src, byte base, uint pitch) { - byte icon_pln[288]; - byte *i, *o, x, y; - - // Decode RLE planar icon data - i = src; - o = icon_pln; - while (o < &icon_pln[288]) { - x = *i++; - if (x < 128) { - do { - *o++ = *i++; - *o++ = *i++; - *o++ = *i++; - } while (x-- > 0); - } else { - x = 256 - x; - do { - *o++ = i[0]; - *o++ = i[1]; - *o++ = i[2]; - } while (x-- > 0); - i += 3; - } - } - - // Translate planar data to chunky (very slow method) - for (y = 0; y < 24; y++) { - for (x = 0; x < 24; x++) { - byte pixel = - (icon_pln[(( y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 1 : 0) - | (icon_pln[((24 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 2 : 0) - | (icon_pln[((48 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 4 : 0) - | (icon_pln[((72 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 8 : 0); - if (pixel) - dst[x] = pixel | base; - } - dst += pitch; - } -} - -static void decompress_icon(byte *dst, byte *src, uint w, uint h_org, byte base, uint pitch) { - int8 reps; - byte color_1, color_2; - byte *dst_org = dst; - uint h = h_org; - - for (;;) { - reps = *src++; - if (reps < 0) { - reps--; - color_1 = *src >> 4; - if (color_1 != 0) - color_1 |= base; - color_2 = *src++ & 0xF; - if (color_2 != 0) - color_2 |= base; - - do { - if (color_1 != 0) - *dst = color_1; - dst += pitch; - if (color_2 != 0) - *dst = color_2; - dst += pitch; - - // reached bottom? - if (--h == 0) { - // reached right edge? - if (--w == 0) - return; - dst = ++dst_org; - h = h_org; - } - } while (++reps != 0); - } else { - do { - color_1 = *src >> 4; - if (color_1 != 0) - *dst = color_1 | base; - dst += pitch; - - color_2 = *src++ & 0xF; - if (color_2 != 0) - *dst = color_2 | base; - dst += pitch; - - // reached bottom? - if (--h == 0) { - // reached right edge? - if (--w == 0) - return; - dst = ++dst_org; - h = h_org; - } - } while (--reps >= 0); - } - } -} - - -void SimonEngine::draw_icon_c(FillOrCopyStruct *fcs, uint icon, uint x, uint y) { - byte *dst; - byte *src; - - _lock_word |= 0x8000; - dst = dx_lock_2(); - - if (!(_game & GF_SIMON2)) { - // Simon 1 - dst += (x + fcs->x) * 8; - dst += (y * 25 + fcs->y) * _dx_surface_pitch; - - if (_game & GF_AMIGA) { - src = _icon_file_ptr; - src += READ_BE_UINT32(&((uint32 *)src)[icon]); - decompress_icon_amiga (dst, src, 0xE0, _dx_surface_pitch); - } else { - src = _icon_file_ptr; - src += READ_LE_UINT16(&((uint16 *)src)[icon]); - decompress_icon(dst, src, 24, 12, 0xE0, _dx_surface_pitch); - } - } else { - // Simon 2 - dst += 110; - dst += x; - dst += (y + fcs->y) * _dx_surface_pitch; - - src = _icon_file_ptr; - src += READ_LE_UINT16(&((uint16 *)src)[icon * 2 + 0]); - decompress_icon(dst, src, 20, 10, 0xE0, _dx_surface_pitch); - - src = _icon_file_ptr; - src += READ_LE_UINT16(&((uint16 *)src)[icon * 2 + 1]); - decompress_icon(dst, src, 20, 10, 0xD0, _dx_surface_pitch); - } - - dx_unlock_2(); - _lock_word &= ~0x8000; -} - void SimonEngine::video_toggle_colors(HitArea * ha, byte a, byte b, byte c, byte d) { byte *src, color; uint w, h, i; @@ -4754,52 +4032,6 @@ void SimonEngine::shutdown() { _system->quit(); } -void SimonEngine::quick_load_or_save() { - // simon1demo subroutines are missing too many segments - // original demo didn't allow load or save either. - if (_game == GAME_SIMON1DEMO) - return; - - bool success; - char buf[50]; - - char *filename = gen_savename(_saveLoadSlot); - if (_saveLoadFlag == 2) { - Subroutine *sub; - success = load_game(_saveLoadSlot); - if (!success) { - sprintf(buf, "Failed to load game state to file:\n\n%s", filename); - } else { - // Redraw Inventory - lock(); - fcs_unk_proc_1(2, getItem1Ptr(), 0, 0); - unlock(); - // Reset engine? - vc_set_bit_to(97, true); - sub = getSubroutineByID(100); - startSubroutine(sub); - } - } else { - success = save_game(_saveLoadSlot, _saveLoadName); - if (!success) - sprintf(buf, "Failed to save game state to file:\n\n%s", filename); - } - - if (!success) { - GUI::MessageDialog dialog(buf, "OK"); - dialog.runModal(); - - } else if (_saveLoadFlag == 1) { - sprintf(buf, "Successfully saved game state in file:\n\n%s", filename); - GUI::TimedMessageDialog dialog(buf, 1500); - dialog.runModal(); - - } - - _saveLoadFlag = 0; -} - - void SimonEngine::delay(uint amount) { OSystem::Event event; @@ -4906,221 +4138,6 @@ void SimonEngine::delay(uint amount) { } while (cur < start + amount); } -bool SimonEngine::save_game(uint slot, char *caption) { - SaveFile *f; - uint item_index, num_item, i, j; - TimeEvent *te; - - _lock_word |= 0x100; - -#ifndef _WIN32_WCE - errno = 0; -#endif - - - f = _saveFileMan->openSavefile(gen_savename(slot), true); - if (f == NULL) { - _lock_word &= ~0x100; - return false; - } - - f->write(caption, 0x12); - - f->writeUint32BE(_itemarray_inited - 1); - f->writeUint32BE(0xFFFFFFFF); - f->writeUint32BE(0); - f->writeUint32BE(0); - - i = 0; - for (te = _first_time_struct; te; te = te->next) - i++; - f->writeUint32BE(i); - - for (te = _first_time_struct; te; te = te->next) { - f->writeUint32BE(te->time + _base_time); - f->writeUint16BE(te->subroutine_id); - } - - item_index = 1; - for (num_item = _itemarray_inited - 1; num_item; num_item--) { - Item *item = _itemarray_ptr[item_index++]; - - f->writeUint16BE(item->parent); - f->writeUint16BE(item->sibling); - f->writeUint16BE(item->unk3); - f->writeUint16BE(item->unk4); - - Child1 *child1 = (Child1 *)findChildOfType(item, 1); - if (child1) { - f->writeUint16BE(child1->fr2); - } - - Child2 *child2 = (Child2 *)findChildOfType(item, 2); - if (child2) { - f->writeUint32BE(child2->avail_props); - i = child2->avail_props & 1; - - for (j = 1; j < 16; j++) { - if ((1 << j) & child2->avail_props) { - f->writeUint16BE(child2->array[i++]); - } - } - } - - Child9 *child9 = (Child9 *) findChildOfType(item, 9); - if (child9) { - for (i = 0; i != 4; i++) { - f->writeUint16BE(child9->array[i]); - } - } - } - - // write the 255 variables - for (i = 0; i != 255; i++) { - f->writeUint16BE(readVariable(i)); - } - - // write the items in array 6 - for (i = 0; i != 10; i++) { - f->writeUint16BE(itemPtrToID(_item_array_6[i])); - } - - // Write the bits in array 1 & 2 - for (i = 0; i != 32; i++) - f->writeUint16BE(_bit_array[i]); - - delete f; - - _lock_word &= ~0x100; - - return true; -} - -char *SimonEngine::gen_savename(int slot) { - static char buf[15]; - - if (_game & GF_SIMON2) { - sprintf(buf, "simon2.%.3d", slot); - } else { - sprintf(buf, "simon1.%.3d", slot); - } - return buf; -} - -bool SimonEngine::load_game(uint slot) { - char ident[18]; - SaveFile *f; - uint num, item_index, i, j; - - _lock_word |= 0x100; - -#ifndef _WIN32_WCE - errno = 0; -#endif - - - f = _saveFileMan->openSavefile(gen_savename(slot), false); - if (f == NULL) { - _lock_word &= ~0x100; - return false; - } - - f->read(ident, 18); - - num = f->readUint32BE(); - - if (f->readUint32BE() != 0xFFFFFFFF || num != _itemarray_inited - 1) { - delete f; - _lock_word &= ~0x100; - return false; - } - - f->readUint32BE(); - f->readUint32BE(); - _no_parent_notify = true; - - - // add all timers - killAllTimers(); - for (num = f->readUint32BE(); num; num--) { - uint32 timeout = f->readUint32BE(); - uint16 func_to_call = f->readUint16BE(); - addTimeEvent(timeout, func_to_call); - } - - item_index = 1; - for (num = _itemarray_inited - 1; num; num--) { - Item *item = _itemarray_ptr[item_index++], *parent_item; - - uint parent = f->readUint16BE(); - uint sibling = f->readUint16BE(); - - parent_item = derefItem(parent); - - setItemParent(item, parent_item); - - if (parent_item == NULL) { - item->parent = parent; - item->sibling = sibling; - } - - item->unk3 = f->readUint16BE(); - item->unk4 = f->readUint16BE(); - - Child1 *child1 = (Child1 *)findChildOfType(item, 1); - if (child1 != NULL) { - child1->fr2 = f->readUint16BE(); - } - - Child2 *child2 = (Child2 *)findChildOfType(item, 2); - if (child2 != NULL) { - child2->avail_props = f->readUint32BE(); - i = child2->avail_props & 1; - - for (j = 1; j < 16; j++) { - if ((1 << j) & child2->avail_props) { - child2->array[i++] = f->readUint16BE(); - } - } - } - - Child9 *child9 = (Child9 *) findChildOfType(item, 9); - if (child9) { - for (i = 0; i != 4; i++) { - child9->array[i] = f->readUint16BE(); - } - } - } - - - // read the 255 variables - for (i = 0; i != 255; i++) { - writeVariable(i, f->readUint16BE()); - } - - // write the items in array 6 - for (i = 0; i != 10; i++) { - _item_array_6[i] = derefItem(f->readUint16BE()); - } - - // Write the bits in array 1 & 2 - for (i = 0; i != 32; i++) - _bit_array[i] = f->readUint16BE(); - - delete f; - - _no_parent_notify = false; - - _lock_word &= ~0x100; - -#ifndef _WIN32_WCE - if (errno != 0) - error("load failed"); -#endif - - return true; -} - void SimonEngine::loadMusic (uint music) { if (_game & GF_SIMON2) { // Simon 2 music midi.stop(); -- cgit v1.2.3