2011-06-10 05:45:18 +00:00
|
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
|
*
|
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
|
*
|
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This code is based on original Soltys source code
|
|
|
|
|
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
|
|
|
|
|
*/
|
|
|
|
|
|
2011-06-29 11:17:07 +00:00
|
|
|
|
#include "common/scummsys.h"
|
2011-06-28 22:35:21 +00:00
|
|
|
|
#include "cge/general.h"
|
|
|
|
|
#include "cge/boot.h"
|
|
|
|
|
#include "cge/ident.h"
|
|
|
|
|
#include "cge/sound.h"
|
|
|
|
|
#include "cge/startup.h"
|
|
|
|
|
#include "cge/config.h"
|
|
|
|
|
#include "cge/vga13h.h"
|
|
|
|
|
#include "cge/snail.h"
|
|
|
|
|
#include "cge/text.h"
|
|
|
|
|
#include "cge/game.h"
|
2011-07-02 06:19:36 +00:00
|
|
|
|
#include "cge/events.h"
|
2011-06-28 22:35:21 +00:00
|
|
|
|
#include "cge/cfile.h"
|
|
|
|
|
#include "cge/vol.h"
|
|
|
|
|
#include "cge/talk.h"
|
|
|
|
|
#include "cge/vmenu.h"
|
|
|
|
|
#include "cge/gettext.h"
|
|
|
|
|
#include "cge/mixer.h"
|
|
|
|
|
#include "cge/cge_main.h"
|
|
|
|
|
#include "cge/cge.h"
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <fcntl.h>
|
2011-06-11 20:35:21 +00:00
|
|
|
|
#include "common/str.h"
|
|
|
|
|
|
2011-06-10 20:57:09 +00:00
|
|
|
|
namespace CGE {
|
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
#define STACK_SIZ (K(2))
|
|
|
|
|
#define SVGCHKSUM (1956 + Now + OldLev + Game + Music + DemoText)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
#define SVG0NAME ("{{INIT}}" SVG_EXT)
|
|
|
|
|
#define SVG0FILE INI_FILE
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
extern uint16 _stklen = (STACK_SIZ * 2);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-20 21:40:22 +00:00
|
|
|
|
VGA *Vga;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Heart *_heart;
|
2011-06-20 21:40:22 +00:00
|
|
|
|
WALK *Hero;
|
|
|
|
|
SYSTEM *Sys;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *_pocLight;
|
2011-07-02 08:38:25 +00:00
|
|
|
|
EventManager *_eventManager;
|
2011-07-02 06:46:31 +00:00
|
|
|
|
Keyboard *_keyboard;
|
|
|
|
|
MOUSE *_mouse;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *_pocket[POCKET_NX];
|
|
|
|
|
Sprite *_sprite;
|
|
|
|
|
Sprite *_miniCave;
|
|
|
|
|
Sprite *_shadow;
|
|
|
|
|
Sprite *_horzLine;
|
2011-06-21 17:38:16 +00:00
|
|
|
|
INFO_LINE *InfoLine;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *_cavLight;
|
2011-06-21 17:38:16 +00:00
|
|
|
|
INFO_LINE *DebugLine;
|
|
|
|
|
|
|
|
|
|
BMP_PTR MB[2];
|
|
|
|
|
BMP_PTR HL[2];
|
|
|
|
|
BMP_PTR MC[3];
|
|
|
|
|
BMP_PTR PR[2];
|
|
|
|
|
BMP_PTR SP[3];
|
|
|
|
|
BMP_PTR LI[5];
|
2011-06-19 22:55:47 +00:00
|
|
|
|
|
2011-06-22 06:11:18 +00:00
|
|
|
|
SNAIL *Snail;
|
|
|
|
|
SNAIL *Snail_;
|
|
|
|
|
|
2011-06-09 06:20:53 +00:00
|
|
|
|
// 0.75 - 17II95 - full sound support
|
|
|
|
|
// 0.76 - 18II95 - small MiniEMS in DEMO,
|
|
|
|
|
// unhide CavLight in SNLEVEL
|
|
|
|
|
// keyclick suppress in startup
|
|
|
|
|
// keyclick on key service in: SYSTEM, GET_TEXT
|
|
|
|
|
// 1.01 - 17VII95 - default savegame with sound ON
|
|
|
|
|
// coditionals EVA for 2-month evaluation version
|
|
|
|
|
|
|
|
|
|
/*
|
2011-06-13 09:57:24 +00:00
|
|
|
|
char Copr[] = "Common Game Engine "
|
|
|
|
|
#ifdef EVA
|
|
|
|
|
"<EFBFBD>"
|
|
|
|
|
#else
|
|
|
|
|
#ifdef CD
|
|
|
|
|
"<EFBFBD>"
|
|
|
|
|
#else
|
|
|
|
|
" "
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
" version 1.05 ["
|
|
|
|
|
#if sizeof(INI_FILE) == sizeof(VFILE)
|
|
|
|
|
"I"
|
|
|
|
|
#else
|
|
|
|
|
"i"
|
|
|
|
|
#endif
|
|
|
|
|
#if sizeof(PIC_FILE) == sizeof(VFILE)
|
|
|
|
|
"B"
|
|
|
|
|
#else
|
|
|
|
|
"b"
|
|
|
|
|
#endif
|
|
|
|
|
"]\n"
|
|
|
|
|
"Copyright (c) 1994 by Janusz B. Wi$niewski";
|
2011-06-09 06:20:53 +00:00
|
|
|
|
*/
|
2011-06-13 09:57:24 +00:00
|
|
|
|
char Copr[] = "To be fixed - Copr[]";
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static char UsrFnam[15] = "\0ɱ%^<5E><>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>";
|
|
|
|
|
static int OldLev = 0;
|
|
|
|
|
static int DemoText = DEMO_TEXT;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
bool JBW = false;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int PocPtr = 0;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
static EMS *Mini = MiniEmm.alloc((uint16)MINI_EMM_SIZE);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static BMP_PTR *MiniShpList = NULL;
|
|
|
|
|
static BMP_PTR MiniShp[] = { NULL, NULL };
|
|
|
|
|
static bool Finis = false;
|
|
|
|
|
static int Startup = 1;
|
2011-06-19 09:17:54 +00:00
|
|
|
|
int OffUseCount;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
uint16 *intStackPtr = false;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
HXY HeroXY[CAVE_MAX] = {{0, 0}};
|
|
|
|
|
BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } };
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
extern int FindPocket(Sprite *);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
extern Dac _stdPal[58];
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
void FeedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL
|
2011-07-01 06:37:40 +00:00
|
|
|
|
uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT];
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
uint8 &Cluster::cell(void) {
|
|
|
|
|
return _map[_b][_a];
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
bool Cluster::Protected(void) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
/*
|
|
|
|
|
if (A == Barriers[Now].Vert || B == Barriers[Now].Horz)
|
|
|
|
|
return true;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
_DX = (MAP_ZCNT << 8) + MAP_XCNT;
|
|
|
|
|
_BX = (uint16) this;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
asm mov ax,1
|
|
|
|
|
asm mov cl,[bx].(COUPLE)A
|
|
|
|
|
asm mov ch,[bx].(COUPLE)B
|
|
|
|
|
asm test cx,0x8080 // (A < 0) || (B < 0)
|
|
|
|
|
asm jnz xit
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
asm cmp cl,dl
|
|
|
|
|
asm jge xit
|
|
|
|
|
asm cmp ch,dh
|
|
|
|
|
asm jge xit
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
asm mov al,dl
|
|
|
|
|
asm mul ch
|
|
|
|
|
asm xor ch,ch
|
|
|
|
|
asm add ax,cx
|
|
|
|
|
asm mov bx,ax
|
|
|
|
|
_BX += (uint16) Map;
|
|
|
|
|
//asm add bx,offset CLUSTER::Map
|
|
|
|
|
asm mov al,[bx]
|
|
|
|
|
asm and ax,0xFF
|
|
|
|
|
asm jz xit
|
|
|
|
|
asm mov ax,1
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// return Map[B][A] != 0;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
xit: return _AX;
|
|
|
|
|
*/
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
warning("STUB: CLUSTER::Protected()");
|
2011-06-18 06:54:22 +00:00
|
|
|
|
return true;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Cluster XZ(int x, int y) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (y < MAP_TOP)
|
|
|
|
|
y = MAP_TOP;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (y > MAP_TOP + MAP_HIG - MAP_ZGRID)
|
|
|
|
|
y = MAP_TOP + MAP_HIG - MAP_ZGRID;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
return Cluster(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Cluster XZ(Couple xy) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
signed char x, y;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
xy.split(x, y);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
return XZ(x, y);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int pocref[POCKET_NX];
|
|
|
|
|
uint8 volume[2];
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
struct SavTab {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
void *Ptr;
|
|
|
|
|
int Len;
|
|
|
|
|
uint8 Flg;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SavTab _savTab[] = {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
{ &Now, sizeof(Now), 1 },
|
|
|
|
|
{ &OldLev, sizeof(OldLev), 1 },
|
|
|
|
|
{ &DemoText, sizeof(DemoText), 1 },
|
|
|
|
|
{ &Game, sizeof(Game), 1 },
|
|
|
|
|
{ &Game, sizeof(Game), 1 }, // spare 1
|
|
|
|
|
{ &Game, sizeof(Game), 1 }, // spare 2
|
|
|
|
|
{ &Game, sizeof(Game), 1 }, // spare 3
|
|
|
|
|
{ &Game, sizeof(Game), 1 }, // spare 4
|
2011-06-19 22:13:41 +00:00
|
|
|
|
// { &VGA::Mono, sizeof(VGA::Mono), 0 },
|
2011-06-13 09:57:24 +00:00
|
|
|
|
{ &Music, sizeof(Music), 1 },
|
|
|
|
|
{ volume, sizeof(volume), 1 },
|
|
|
|
|
{ Flag, sizeof(Flag), 1 },
|
|
|
|
|
{ HeroXY, sizeof(HeroXY), 1 },
|
|
|
|
|
{ Barriers, sizeof(Barriers), 1 },
|
|
|
|
|
{ pocref, sizeof(pocref), 1 },
|
|
|
|
|
{ NULL, 0, 0 }
|
|
|
|
|
};
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::loadGame(XFile &file, bool tiny = false) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
SavTab *st;
|
|
|
|
|
Sprite *spr;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int i;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
for (st = _savTab; st->Ptr; st++) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (file._error)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
error("Bad SVG");
|
2011-06-30 06:30:23 +00:00
|
|
|
|
file.read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-30 06:30:23 +00:00
|
|
|
|
file.read((uint8 *) &i, sizeof(i));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (i != SVGCHKSUM)
|
2011-06-29 07:57:16 +00:00
|
|
|
|
error("%s", Text->getText(BADSVG_TEXT));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (STARTUP::Core < CORE_HIG)
|
|
|
|
|
Music = false;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) {
|
|
|
|
|
SNDDrvInfo.VOL2.D = volume[0];
|
|
|
|
|
SNDDrvInfo.VOL2.M = volume[1];
|
|
|
|
|
SNDSetVolume();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (! tiny) { // load sprites & pocket
|
2011-07-01 06:37:40 +00:00
|
|
|
|
while (!file._error) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite S(this, NULL);
|
2011-06-30 06:30:23 +00:00
|
|
|
|
uint16 n = file.read((uint8 *) &S, sizeof(S));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
|
|
|
|
|
if (n != sizeof(S))
|
|
|
|
|
break;
|
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
S._prev = S._next = NULL;
|
2011-07-01 23:02:14 +00:00
|
|
|
|
spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL)
|
2011-06-28 22:35:21 +00:00
|
|
|
|
: new Sprite(this, NULL);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (spr == NULL)
|
|
|
|
|
error("No core");
|
|
|
|
|
*spr = S;
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->SpareQ->Append(spr);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-26 10:07:42 +00:00
|
|
|
|
for (i = 0; i < POCKET_NX; i++) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
register int r = pocref[i];
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_pocket[i] = (r < 0) ? NULL : Vga->SpareQ->Locate(r);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SaveSound(void) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
CFile cfg(UsrPath(progName(CFG_EXT)), WRI);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (!cfg._error)
|
2011-06-30 06:30:23 +00:00
|
|
|
|
cfg.write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
static void SaveGame(XFile &file) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
SavTab *st;
|
|
|
|
|
Sprite *spr;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int i;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-26 10:07:42 +00:00
|
|
|
|
for (i = 0; i < POCKET_NX; i++) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
register Sprite *s = _pocket[i];
|
|
|
|
|
pocref[i] = (s) ? s->_ref : -1;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
volume[0] = SNDDrvInfo.VOL2.D;
|
|
|
|
|
volume[1] = SNDDrvInfo.VOL2.M;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
for (st = _savTab; st->Ptr; st++) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (file._error)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
error("Bad SVG");
|
2011-06-30 06:30:23 +00:00
|
|
|
|
file.write((uint8 *) st->Ptr, st->Len);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-30 06:30:23 +00:00
|
|
|
|
file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
for (spr = Vga->SpareQ->First(); spr; spr = spr->_next)
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (spr->_ref >= 1000)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (!file._error)
|
2011-06-30 06:30:23 +00:00
|
|
|
|
file.write((uint8 *)spr, sizeof(*spr));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void HeroCover(int cvr) {
|
|
|
|
|
SNPOST(SNCOVER, 1, cvr, NULL);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void Trouble(int seq, int txt) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Hero->park();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST(SNWAIT, -1, -1, Hero);
|
|
|
|
|
SNPOST(SNSEQ, -1, seq, Hero);
|
|
|
|
|
SNPOST(SNSOUND, -1, 2, Hero);
|
|
|
|
|
SNPOST(SNWAIT, -1, -1, Hero);
|
|
|
|
|
SNPOST(SNSAY, 1, txt, Hero);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void OffUse(void) {
|
|
|
|
|
Trouble(OFF_USE, OFF_USE_TEXT + new_random(OffUseCount));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void TooFar(void) {
|
|
|
|
|
Trouble(TOO_FAR, TOO_FAR_TEXT);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-29 07:57:16 +00:00
|
|
|
|
// Used in stubbed function, do not remove!
|
2011-07-01 06:37:40 +00:00
|
|
|
|
static void noWay() {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Trouble(NO_WAY, NO_WAY_TEXT);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void LoadHeroXY(void) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
INI_FILE cf(progName(".HXY"));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
memset(HeroXY, 0, sizeof(HeroXY));
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (!cf._error)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
cf.CFREAD(&HeroXY);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void LoadMapping(void) {
|
|
|
|
|
if (Now <= CAVE_MAX) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
INI_FILE cf(progName(".TAB"));
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (!cf._error) {
|
|
|
|
|
memset(Cluster::_map, 0, sizeof(Cluster::_map));
|
|
|
|
|
cf.seek((Now - 1) * sizeof(Cluster::_map));
|
|
|
|
|
cf.read((uint8 *) Cluster::_map, sizeof(Cluster::_map));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Cluster Trace[MAX_FIND_LEVEL];
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int FindLevel;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-26 23:03:47 +00:00
|
|
|
|
WALK::WALK(CGEEngine *vm, BMP_PTR *shpl)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
: Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _vm(vm) {
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void WALK::tick() {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_flags._hide)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
return;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
_here = XZ(_x + _w / 2, _y + _h);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (Dir != NO_DIR) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *spr;
|
2011-06-20 21:40:22 +00:00
|
|
|
|
Sys->FunTouch();
|
2011-06-29 14:13:17 +00:00
|
|
|
|
for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (distance(spr) < 2) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (!spr->_flags._near) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
FeedSnail(spr, NEAR);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
spr->_flags._near = true;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-29 14:13:17 +00:00
|
|
|
|
} else {
|
|
|
|
|
spr->_flags._near = false;
|
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (_flags._hold || _tracePtr < 0)
|
|
|
|
|
park();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
else {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (_here == Trace[_tracePtr]) {
|
|
|
|
|
if (--_tracePtr < 0)
|
|
|
|
|
park();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
signed char dx, dz;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
(Trace[_tracePtr] - _here).split(dx, dz);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
turn(d);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-01 23:02:14 +00:00
|
|
|
|
step();
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if ((Dir == WW && _x <= 0) ||
|
|
|
|
|
(Dir == EE && _x + _w >= SCR_WID) ||
|
|
|
|
|
(Dir == SS && _y + _w >= WORLD_HIG - 2))
|
2011-07-01 06:37:40 +00:00
|
|
|
|
park();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
else {
|
|
|
|
|
signed char x; // dummy var
|
2011-07-01 06:37:40 +00:00
|
|
|
|
_here.split(x, _z); // take current Z position
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
int WALK::distance(Sprite *spr) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int dx, dz;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
dx = spr->_x - (_x + _w - WALKSIDE);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (dx < 0)
|
2011-06-29 14:13:17 +00:00
|
|
|
|
dx = (_x + WALKSIDE) - (spr->_x + spr->_w);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (dx < 0)
|
|
|
|
|
dx = 0;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
dx /= MAP_XGRID;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
dz = spr->_z - _z;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (dz < 0)
|
|
|
|
|
dz = - dz;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
dx = dx * dx + dz * dz;
|
2011-06-26 10:07:42 +00:00
|
|
|
|
for (dz = 1; dz * dz < dx; dz++)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
return dz - 1;
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void WALK::turn(DIR d) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
DIR dir = (Dir == NO_DIR) ? SS : Dir;
|
|
|
|
|
if (d != Dir) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Dir = d;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void WALK::park(void) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_time == 0)
|
|
|
|
|
++_time;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (Dir != NO_DIR) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
step(9 + 4 * Dir + Dir);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Dir = NO_DIR;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
_tracePtr = -1;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void WALK::findWay(Cluster c) {
|
|
|
|
|
warning("STUB: WALK::findWay");
|
2011-06-13 09:57:24 +00:00
|
|
|
|
/*
|
|
|
|
|
bool Find1Way(void);
|
|
|
|
|
extern uint16 Target;
|
|
|
|
|
|
|
|
|
|
if (c != Here) {
|
2011-06-26 10:07:42 +00:00
|
|
|
|
for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel++) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
signed char x, z;
|
|
|
|
|
Here.Split(x, z);
|
|
|
|
|
Target = (z << 8) | x;
|
|
|
|
|
c.Split(x, z);
|
|
|
|
|
_CX = (z << 8) | x;
|
|
|
|
|
if (Find1Way())
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
TracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1);
|
|
|
|
|
if (TracePtr < 0)
|
|
|
|
|
NoWay();
|
|
|
|
|
Time = 1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void WALK::findWay(Sprite *spr) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (spr && spr != this) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
int x = spr->_x;
|
|
|
|
|
int z = spr->_z;
|
|
|
|
|
if (spr->_flags._east)
|
|
|
|
|
x += spr->_w + _w / 2 - WALKSIDE;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
else
|
2011-06-29 14:13:17 +00:00
|
|
|
|
x -= _w / 2 - WALKSIDE;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
findWay(Cluster((x / MAP_XGRID),
|
2011-06-13 09:57:24 +00:00
|
|
|
|
((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1)
|
|
|
|
|
: (z - 1))));
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
bool WALK::lower(Sprite *spr) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
return (spr->_y > _y + (_h * 3) / 5);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void WALK::reach(Sprite *spr, int mode) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (spr) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Hero->findWay(spr);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (mode < 0) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
mode = spr->_flags._east;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (lower(spr))
|
2011-06-13 09:57:24 +00:00
|
|
|
|
mode += 2;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// note: insert SNAIL commands in reverse order
|
|
|
|
|
SNINSERT(SNPAUSE, -1, 64, NULL);
|
|
|
|
|
SNINSERT(SNSEQ, -1, TSEQ + mode, this);
|
|
|
|
|
if (spr) {
|
|
|
|
|
SNINSERT(SNWAIT, -1, -1, Hero); /////--------$$$$$$$
|
|
|
|
|
//SNINSERT(SNWALK, -1, -1, spr);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// sequence is not finished,
|
|
|
|
|
// now it is just at sprite appear (disappear) point
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
class SQUARE : public Sprite {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
public:
|
2011-06-26 23:03:47 +00:00
|
|
|
|
SQUARE(CGEEngine *vm);
|
2011-07-02 10:04:30 +00:00
|
|
|
|
virtual void touch(uint16 mask, int x, int y);
|
2011-06-26 23:03:47 +00:00
|
|
|
|
private:
|
|
|
|
|
CGEEngine *_vm;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
};
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-26 23:03:47 +00:00
|
|
|
|
SQUARE::SQUARE(CGEEngine *vm)
|
2011-06-28 22:35:21 +00:00
|
|
|
|
: Sprite(vm, MB), _vm(vm) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_flags._kill = true;
|
|
|
|
|
_flags._bDel = false;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-02 10:04:30 +00:00
|
|
|
|
void SQUARE::touch(uint16 mask, int x, int y) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Sprite::touch(mask, x, y);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (mask & L_UP) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
XZ(_x + x, _y + y).cell() = 0;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST_(SNKILL, -1, 0, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::setMapBrick(int x, int z) {
|
2011-06-26 23:03:47 +00:00
|
|
|
|
SQUARE *s = new SQUARE(this);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (s) {
|
|
|
|
|
static char n[] = "00:00";
|
2011-07-01 23:02:14 +00:00
|
|
|
|
s->gotoxy(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
wtom(x, n + 0, 10, 2);
|
|
|
|
|
wtom(z, n + 3, 10, 2);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Cluster::_map[z][x] = 1;
|
2011-07-01 23:02:14 +00:00
|
|
|
|
s->setName(n);
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->ShowQ->Insert(s, Vga->ShowQ->First());
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SwitchColorMode(void);
|
2011-06-18 06:54:22 +00:00
|
|
|
|
static void SwitchDebug(void);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SwitchMusic(void);
|
|
|
|
|
static void KillSprite(void);
|
|
|
|
|
static void PushSprite(void);
|
|
|
|
|
static void PullSprite(void);
|
|
|
|
|
static void NextStep(void);
|
|
|
|
|
static void SaveMapping(void);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void KeyClick(void) {
|
|
|
|
|
SNPOST_(SNSOUND, -1, 5, NULL);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::resetQSwitch() {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST_(SNSEQ, 123, 0, NULL);
|
|
|
|
|
KeyClick();
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::quit() {
|
2011-06-26 23:03:47 +00:00
|
|
|
|
static CHOICE QuitMenu[] = {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
{ NULL, &CGEEngine::startCountDown },
|
|
|
|
|
{ NULL, &CGEEngine::resetQSwitch },
|
2011-06-26 23:03:47 +00:00
|
|
|
|
{ NULL, &CGEEngine::dummy }
|
2011-06-13 09:57:24 +00:00
|
|
|
|
};
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (Snail->Idle() && ! Hero->_flags._hide) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (VMENU::Addr) {
|
|
|
|
|
SNPOST_(SNKILL, -1, 0, VMENU::Addr);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
resetQSwitch();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
} else {
|
2011-06-19 09:17:54 +00:00
|
|
|
|
QuitMenu[0].Text = Text->getText(QUIT_TEXT);
|
|
|
|
|
QuitMenu[1].Text = Text->getText(NOQUIT_TEXT);
|
2011-07-01 23:02:14 +00:00
|
|
|
|
(new VMENU(this, QuitMenu, -1, -1))->setName(Text->getText(QUIT_TITLE));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST_(SNSEQ, 123, 1, NULL);
|
|
|
|
|
KeyClick();
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void AltCtrlDel(void) {
|
|
|
|
|
SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 07:57:16 +00:00
|
|
|
|
// Used in stubbed function, do not remove!
|
2011-07-01 06:37:40 +00:00
|
|
|
|
static void miniStep(int stp) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (stp < 0)
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_miniCave->_flags._hide = true;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
else {
|
|
|
|
|
&*Mini;
|
|
|
|
|
*MiniShp[0] = *MiniShpList[stp];
|
|
|
|
|
if (Fx.Current)
|
|
|
|
|
&*(Fx.Current->EAddr());
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_miniCave->_flags._hide = false;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void PostMiniStep(int stp) {
|
2011-06-13 11:44:52 +00:00
|
|
|
|
//static int recent = -2;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
//TODO Change the SNPOST message send to a special way to send function pointer
|
|
|
|
|
//if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep);
|
|
|
|
|
warning("STUB: PostMiniStep()");
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
void SYSTEM::SetPal(void) {
|
2011-06-27 17:25:24 +00:00
|
|
|
|
uint i;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Dac *p = VGA::SysPal + 256 - ArrayCount(_stdPal);
|
|
|
|
|
for (i = 0; i < ArrayCount(_stdPal); i++) {
|
|
|
|
|
p[i]._r = _stdPal[i]._r >> 2;
|
|
|
|
|
p[i]._g = _stdPal[i]._g >> 2;
|
|
|
|
|
p[i]._b = _stdPal[i]._b >> 2;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
void SYSTEM::FunTouch(void) {
|
|
|
|
|
uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0;
|
|
|
|
|
if (Talk == NULL || n > FunDel)
|
|
|
|
|
FunDel = n;
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void ShowBak(int ref) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *spr = Vga->SpareQ->Locate(ref);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (spr) {
|
2011-06-30 06:30:23 +00:00
|
|
|
|
Bitmap::_pal = VGA::SysPal;
|
2011-07-01 23:02:14 +00:00
|
|
|
|
spr->expand();
|
2011-06-30 06:30:23 +00:00
|
|
|
|
Bitmap::_pal = NULL;
|
2011-07-01 23:02:14 +00:00
|
|
|
|
spr->show(2);
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->CopyPage(1, 2);
|
2011-06-20 21:40:22 +00:00
|
|
|
|
Sys->SetPal();
|
2011-07-01 23:02:14 +00:00
|
|
|
|
spr->contract();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
static void caveUp() {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int BakRef = 1000 * Now;
|
|
|
|
|
if (Music)
|
|
|
|
|
LoadMIDI(Now);
|
|
|
|
|
|
|
|
|
|
ShowBak(BakRef);
|
|
|
|
|
LoadMapping();
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Text->Preload(BakRef, BakRef + 1000);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *spr = Vga->SpareQ->First();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
while (spr) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
Sprite *n = spr->_next;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (spr->_cave == Now || spr->_cave == 0)
|
|
|
|
|
if (spr->_ref != BakRef) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (spr->_flags._back)
|
2011-07-01 23:02:14 +00:00
|
|
|
|
spr->backShow();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
else
|
|
|
|
|
ExpandSprite(spr);
|
|
|
|
|
}
|
|
|
|
|
spr = n;
|
|
|
|
|
}
|
|
|
|
|
if (SNDDrvInfo.DDEV) {
|
|
|
|
|
Sound.Stop();
|
|
|
|
|
Fx.Clear();
|
|
|
|
|
Fx.Preload(0);
|
|
|
|
|
Fx.Preload(BakRef);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (Hero) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->gotoxy(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// following 2 lines trims Hero's Z position!
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->tick();
|
2011-06-29 14:13:17 +00:00
|
|
|
|
Hero->_time = 1;
|
|
|
|
|
Hero->_flags._hide = false;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (! Dark)
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Vga->Sunset();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->CopyPage(0, 1);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SelectPocket(-1);
|
|
|
|
|
if (Hero)
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->ShowQ->Insert(Vga->ShowQ->Remove(Hero));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (_shadow) {
|
|
|
|
|
Vga->ShowQ->Remove(_shadow);
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_shadow->makeXlat(glass(VGA::SysPal, 204, 204, 204));
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->ShowQ->Insert(_shadow, Hero);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_shadow->_z = Hero->_z;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-19 22:13:41 +00:00
|
|
|
|
FeedSnail(Vga->ShowQ->Locate(BakRef + 999), TAKE);
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Vga->Show();
|
|
|
|
|
Vga->CopyPage(1, 0);
|
|
|
|
|
Vga->Show();
|
2011-06-27 08:57:58 +00:00
|
|
|
|
Vga->Sunrise(VGA::SysPal);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Dark = false;
|
|
|
|
|
if (! Startup)
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_mouse->On();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = true;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::caveDown() {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *spr;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (!_horzLine->_flags._hide)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
switchMapping();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-19 22:13:41 +00:00
|
|
|
|
for (spr = Vga->ShowQ->First(); spr;) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
Sprite *n = spr->_next;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (spr->_ref >= 1000 /*&& spr->_cave*/) {
|
|
|
|
|
if (spr->_ref % 1000 == 999)
|
2011-06-18 06:54:22 +00:00
|
|
|
|
FeedSnail(spr, TAKE);
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->SpareQ->Append(Vga->ShowQ->Remove(spr));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-18 06:54:22 +00:00
|
|
|
|
spr = n;
|
|
|
|
|
}
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Text->Clear(1000);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::xCave() {
|
|
|
|
|
caveDown();
|
|
|
|
|
caveUp();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::qGame() {
|
|
|
|
|
caveDown();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
OldLev = Lev;
|
|
|
|
|
SaveSound();
|
2011-06-30 06:30:23 +00:00
|
|
|
|
CFile file = CFile(UsrPath(UsrFnam), WRI, RCrypt);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SaveGame(file);
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Vga->Sunset();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Finis = true;
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::switchCave(int cav) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (cav != Now) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = false;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (cav < 0) {
|
|
|
|
|
SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint
|
|
|
|
|
//TODO Change the SNPOST message send to a special way to send function pointer
|
|
|
|
|
//SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave
|
|
|
|
|
warning("SwitchCave() - SNPOST");
|
|
|
|
|
} else {
|
|
|
|
|
Now = cav;
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_mouse->Off();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (Hero) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Hero->park();
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->step(0);
|
2011-06-26 23:03:47 +00:00
|
|
|
|
if (!_isDemo)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
///// protection: auto-destruction on! ----------------------
|
2011-06-26 23:03:47 +00:00
|
|
|
|
Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
/////--------------------------------------------------------
|
|
|
|
|
}
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_cavLight->gotoxy(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
|
2011-06-13 09:57:24 +00:00
|
|
|
|
CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
|
|
|
|
|
KillText();
|
2011-06-19 22:13:41 +00:00
|
|
|
|
if (! Startup)
|
|
|
|
|
KeyClick();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint
|
|
|
|
|
//TODO Change the SNPOST message send to a special way to send function pointer
|
|
|
|
|
//SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave
|
|
|
|
|
warning("SwitchCave() - SNPOST");
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
SYSTEM::SYSTEM(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
|
2011-06-20 21:40:22 +00:00
|
|
|
|
FunDel = HEROFUN0;
|
|
|
|
|
SetPal();
|
|
|
|
|
Tick();
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-02 10:04:30 +00:00
|
|
|
|
void SYSTEM::touch(uint16 mask, int x, int y) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static int pp = 0;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
FunTouch();
|
|
|
|
|
|
|
|
|
|
if (mask & KEYB) {
|
|
|
|
|
int pp0;
|
|
|
|
|
KeyClick();
|
|
|
|
|
KillText();
|
|
|
|
|
if (Startup == 1) {
|
|
|
|
|
SNPOST(SNCLEAR, -1, 0, NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pp0 = pp;
|
|
|
|
|
switch (x) {
|
|
|
|
|
case Del:
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (_keyboard->_key[ALT] && _keyboard->_key[CTRL])
|
2011-06-18 06:54:22 +00:00
|
|
|
|
AltCtrlDel();
|
|
|
|
|
else
|
|
|
|
|
KillSprite();
|
|
|
|
|
break;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
case 'F':
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (_keyboard->_key[ALT]) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *m = Vga->ShowQ->Locate(17001);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (m) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
m->step(1);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
m->_time = 216; // 3s
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case PgUp:
|
|
|
|
|
PushSprite();
|
|
|
|
|
break;
|
|
|
|
|
case PgDn:
|
|
|
|
|
PullSprite();
|
|
|
|
|
break;
|
|
|
|
|
case '+':
|
|
|
|
|
NextStep();
|
|
|
|
|
break;
|
|
|
|
|
case '`':
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (_keyboard->_key[ALT])
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SaveMapping();
|
|
|
|
|
else
|
2011-07-01 06:37:40 +00:00
|
|
|
|
_vm->switchMapping();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F1:
|
|
|
|
|
SwitchDebug();
|
|
|
|
|
break;
|
|
|
|
|
case F3:
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->step(TSEQ + 4);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F4:
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->step(TSEQ + 5);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F5:
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->step(TSEQ + 0);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F6:
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->step(TSEQ + 1);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F7:
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->step(TSEQ + 2);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F8:
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->step(TSEQ + 3);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F9:
|
2011-06-20 21:40:22 +00:00
|
|
|
|
Sys->FunDel = 1;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'X':
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (_keyboard->_key[ALT])
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Finis = true;
|
|
|
|
|
break;
|
|
|
|
|
case '0':
|
|
|
|
|
case '1':
|
|
|
|
|
case '2':
|
|
|
|
|
case '3':
|
|
|
|
|
case '4':
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (_keyboard->_key[ALT]) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST(SNLEVEL, -1, x - '0', NULL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case '5':
|
|
|
|
|
case '6':
|
|
|
|
|
case '7':
|
|
|
|
|
case '8':
|
|
|
|
|
case '9':
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (_sprite)
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_sprite->step(x - '0');
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case F10 :
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (Snail->Idle() && ! Hero->_flags._hide)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
_vm->startCountDown();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'J':
|
|
|
|
|
if (pp == 0)
|
|
|
|
|
++pp;
|
|
|
|
|
break;
|
|
|
|
|
case 'B':
|
|
|
|
|
if (pp == 1)
|
|
|
|
|
++pp;
|
|
|
|
|
break;
|
|
|
|
|
case 'W':
|
|
|
|
|
if (pp == 2)
|
|
|
|
|
JBW = !JBW;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (pp == pp0)
|
|
|
|
|
pp = 0;
|
|
|
|
|
} else {
|
|
|
|
|
if (Startup)
|
|
|
|
|
return;
|
2011-06-13 11:44:52 +00:00
|
|
|
|
int cav = 0;
|
2011-06-21 17:38:16 +00:00
|
|
|
|
InfoLine->Update(NULL);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (y >= WORLD_HIG) {
|
|
|
|
|
if (x < BUTTON_X) { // select cave?
|
|
|
|
|
if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY &&
|
|
|
|
|
x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && ! Game) {
|
|
|
|
|
cav = ((y - CAVE_Y) / CAVE_DY) * CAVE_NX + (x - CAVE_X) / CAVE_DX + 1;
|
|
|
|
|
if (cav > MaxCave)
|
|
|
|
|
cav = 0;
|
|
|
|
|
} else {
|
|
|
|
|
cav = 0;
|
|
|
|
|
}
|
|
|
|
|
} else if (mask & L_UP) {
|
|
|
|
|
if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY &&
|
|
|
|
|
x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) {
|
|
|
|
|
int n = ((y - POCKET_Y) / POCKET_DY) * POCKET_NX + (x - POCKET_X) / POCKET_DX;
|
|
|
|
|
SelectPocket(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
PostMiniStep(cav - 1);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (mask & L_UP) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (cav && Snail->Idle() && Hero->_tracePtr < 0)
|
|
|
|
|
_vm->switchCave(cav);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (!_horzLine->_flags._hide) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) {
|
2011-06-13 11:44:52 +00:00
|
|
|
|
int8 x1, z1;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
XZ(x, y).split(x1, z1);
|
|
|
|
|
Cluster::_map[z1][x1] = 1;
|
|
|
|
|
_vm->setMapBrick(x1, z1);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
{
|
2011-06-22 06:11:18 +00:00
|
|
|
|
if (! Talk && Snail->Idle() && Hero
|
2011-06-13 09:57:24 +00:00
|
|
|
|
&& y >= MAP_TOP && y < MAP_TOP + MAP_HIG && ! Game) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Hero->findWay(XZ(x, y));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
void SYSTEM::Tick(void) {
|
|
|
|
|
if (! Startup) if (-- FunDel == 0) {
|
|
|
|
|
KillText();
|
2011-06-22 06:11:18 +00:00
|
|
|
|
if (Snail->Idle()) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (PAIN)
|
|
|
|
|
HeroCover(9);
|
|
|
|
|
else if (STARTUP::Core >= CORE_MID) {
|
|
|
|
|
int n = new_random(100);
|
|
|
|
|
if (n > 96)
|
2011-06-29 14:13:17 +00:00
|
|
|
|
HeroCover(6 + (Hero->_x + Hero->_w / 2 < SCR_WID / 2));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
else {
|
|
|
|
|
if (n > 90)
|
|
|
|
|
HeroCover(5);
|
|
|
|
|
else {
|
|
|
|
|
if (n > 60)
|
|
|
|
|
HeroCover(4);
|
|
|
|
|
else
|
|
|
|
|
HeroCover(3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FunTouch();
|
|
|
|
|
}
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_time = SYSTIMERATE;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
/*
|
|
|
|
|
static void SpkOpen(void) {
|
|
|
|
|
asm in al,0x61
|
|
|
|
|
asm or al,0x03
|
|
|
|
|
asm out 0x61,al
|
|
|
|
|
asm mov al,0x90
|
|
|
|
|
asm out 0x43,al
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SpkClose(void) {
|
|
|
|
|
asm in al,0x61
|
|
|
|
|
asm and al,0xFC
|
|
|
|
|
asm out 0x61,al
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
*/
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SwitchColorMode(void) {
|
2011-06-19 22:13:41 +00:00
|
|
|
|
SNPOST_(SNSEQ, 121, Vga->Mono = !Vga->Mono, NULL);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
KeyClick();
|
2011-06-27 08:57:58 +00:00
|
|
|
|
Vga->SetColors(VGA::SysPal, 64);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SwitchMusic(void) {
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (_keyboard->_key[ALT]) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (VMENU::Addr)
|
|
|
|
|
SNPOST_(SNKILL, -1, 0, VMENU::Addr);
|
|
|
|
|
else {
|
|
|
|
|
SNPOST_(SNSEQ, 122, (Music = false), NULL);
|
|
|
|
|
//TODO Change the SNPOST message send to a special way to send function pointer
|
2011-07-01 06:37:40 +00:00
|
|
|
|
// SNPOST(SNEXEC, -1, 0, (void *)&selectSound);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
warning("SwitchMusic() - SNPOST");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (STARTUP::Core < CORE_HIG)
|
|
|
|
|
SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL);
|
|
|
|
|
else {
|
|
|
|
|
SNPOST_(SNSEQ, 122, (Music = ! Music), NULL);
|
|
|
|
|
KeyClick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Music)
|
|
|
|
|
LoadMIDI(Now);
|
|
|
|
|
else
|
|
|
|
|
KillMIDI();
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::startCountDown() {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
//SNPOST(SNSEQ, 123, 0, NULL);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
switchCave(-1);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::takeName() {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
if (GetText::_ptr)
|
|
|
|
|
SNPOST_(SNKILL, -1, 0, GetText::_ptr);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
else {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
GetText *tn = new GetText(this, Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (tn) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
tn->setName(Text->getText(GETNAME_TITLE));
|
|
|
|
|
tn->center();
|
|
|
|
|
tn->gotoxy(tn->_x, tn->_y - 10);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
tn->_z = 126;
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->ShowQ->Insert(tn);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::switchMapping() {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_horzLine->_flags._hide) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int i;
|
2011-06-26 10:07:42 +00:00
|
|
|
|
for (i = 0; i < MAP_ZCNT; i++) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int j;
|
2011-06-26 10:07:42 +00:00
|
|
|
|
for (j = 0; j < MAP_XCNT; j++) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (Cluster::_map[i][j])
|
|
|
|
|
setMapBrick(j, i);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *s;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
for (s = Vga->ShowQ->First(); s; s = s->_next)
|
|
|
|
|
if (s->_w == MAP_XGRID && s->_h == MAP_ZGRID)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST_(SNKILL, -1, 0, s);
|
|
|
|
|
}
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_horzLine->_flags._hide = !_horzLine->_flags._hide;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void KillSprite(void) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_sprite->_flags._kill = true;
|
|
|
|
|
_sprite->_flags._bDel = true;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
SNPOST_(SNKILL, -1, 0, _sprite);
|
|
|
|
|
_sprite = NULL;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void PushSprite(void) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
Sprite *spr = _sprite->_prev;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (spr) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
while (_sprite->_z > _sprite->_next->_z)
|
|
|
|
|
_sprite->_z--;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
} else
|
|
|
|
|
SNPOST_(SNSOUND, -1, 2, NULL);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void PullSprite(void) {
|
|
|
|
|
bool ok = false;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
Sprite *spr = _sprite->_next;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (spr) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
spr = spr->_next;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (spr)
|
2011-06-29 14:13:17 +00:00
|
|
|
|
ok = (!spr->_flags._slav);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (ok) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_sprite->_prev)
|
|
|
|
|
while (_sprite->_z < _sprite->_prev->_z)
|
|
|
|
|
_sprite->_z++;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
} else
|
|
|
|
|
SNPOST_(SNSOUND, -1, 2, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void NextStep(void) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
SNPOST_(SNSTEP, 0, 0, _sprite);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
static void SaveMapping() {
|
2011-06-09 06:20:53 +00:00
|
|
|
|
{
|
2011-07-01 23:02:14 +00:00
|
|
|
|
IoHand cf(progName(".TAB"), UPD);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (!cf._error) {
|
|
|
|
|
cf.seek((Now - 1) * sizeof(Cluster::_map));
|
|
|
|
|
cf.write((uint8 *) Cluster::_map, sizeof(Cluster::_map));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
2011-07-01 23:02:14 +00:00
|
|
|
|
IoHand cf(progName(".HXY"), WRI);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (!cf._error) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
HeroXY[Now - 1]._x = Hero->_x;
|
|
|
|
|
HeroXY[Now - 1]._y = Hero->_y;
|
2011-06-30 06:30:23 +00:00
|
|
|
|
cf.write((uint8 *) HeroXY, sizeof(HeroXY));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// 1111111111222222222233333333 334444444444555555555566666666667777777777
|
|
|
|
|
// 01234567890123456789012345678901234567 890123456789012345678901234567890123456789
|
|
|
|
|
static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 000:000:000 000:000 00 ";
|
|
|
|
|
|
|
|
|
|
#define NFRE (DebugText + 3)
|
|
|
|
|
#define FFRE (DebugText + 11)
|
|
|
|
|
#define ABSX (DebugText + 20)
|
|
|
|
|
#define ABSY (DebugText + 26)
|
|
|
|
|
#define FRPS (DebugText + 34)
|
|
|
|
|
#define XSPR (DebugText + 38)
|
|
|
|
|
#define SP_N (DebugText + 41)
|
|
|
|
|
#define SP_S (DebugText + 44)
|
|
|
|
|
|
|
|
|
|
#define SP_X (DebugText + 47)
|
|
|
|
|
#define SP_Y (DebugText + 51)
|
|
|
|
|
#define SP_Z (DebugText + 55)
|
|
|
|
|
#define SP_W (DebugText + 59)
|
|
|
|
|
#define SP_H (DebugText + 63)
|
|
|
|
|
#define SP_F (DebugText + 67)
|
|
|
|
|
#define SP__ (DebugText + 70)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SayDebug(void) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (!DebugLine->_flags._hide) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static long t = -1L;
|
2011-07-01 23:02:14 +00:00
|
|
|
|
long t1 = timer();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (t1 - t >= 18) {
|
|
|
|
|
static uint32 old = 0L;
|
2011-06-19 09:17:54 +00:00
|
|
|
|
uint32 now = Vga->FrmCnt;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
dwtom(now - old, FRPS, 10, 4);
|
|
|
|
|
old = now;
|
|
|
|
|
t = t1;
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-02 06:46:31 +00:00
|
|
|
|
dwtom(_mouse->_x, ABSX, 10, 3);
|
|
|
|
|
dwtom(_mouse->_y, ABSY, 10, 3);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// dwtom(coreleft(), NFRE, 10, 5);
|
|
|
|
|
// dwtom(farcoreleft(), FFRE, 10, 6);
|
|
|
|
|
|
|
|
|
|
// sprite queue size
|
|
|
|
|
uint16 n = 0;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite *spr;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
++ n;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (spr == _sprite) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
*XSPR = ' ';
|
|
|
|
|
dwtom(n, SP_N, 10, 2);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
dwtom(_sprite->_x, SP_X, 10, 3);
|
|
|
|
|
dwtom(_sprite->_y, SP_Y, 10, 3);
|
|
|
|
|
dwtom(_sprite->_z, SP_Z, 10, 3);
|
|
|
|
|
dwtom(_sprite->_w, SP_W, 10, 3);
|
|
|
|
|
dwtom(_sprite->_h, SP_H, 10, 3);
|
|
|
|
|
dwtom(*(uint16 *)(&_sprite->_flags), SP_F, 16, 2);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dwtom(n, SP_S, 10, 2);
|
|
|
|
|
// *SP__ = (heapcheck() < 0) ? '!' : ' ';
|
2011-06-21 17:38:16 +00:00
|
|
|
|
DebugLine->Update(DebugText);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static void SwitchDebug(void) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
DebugLine->_flags._hide = ! DebugLine->_flags._hide;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::optionTouch(int opt, uint16 mask) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
switch (opt) {
|
|
|
|
|
case 1 :
|
|
|
|
|
if (mask & L_UP)
|
|
|
|
|
SwitchColorMode();
|
|
|
|
|
break;
|
|
|
|
|
case 2 :
|
|
|
|
|
if (mask & L_UP)
|
|
|
|
|
SwitchMusic();
|
|
|
|
|
else if (mask & R_UP)
|
2011-07-01 23:02:14 +00:00
|
|
|
|
if (!Mixer::_appear) {
|
|
|
|
|
Mixer::_appear = true;
|
|
|
|
|
new Mixer(this, BUTTON_X, BUTTON_Y);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3 :
|
|
|
|
|
if (mask & L_UP)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
quit();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
#pragma argsused
|
2011-07-01 23:02:14 +00:00
|
|
|
|
void Sprite::touch(uint16 mask, int x, int y) {
|
2011-06-20 21:40:22 +00:00
|
|
|
|
Sys->FunTouch();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if ((mask & ATTN) == 0) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
InfoLine->Update(name());
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (mask & (R_DN | L_DN))
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = this;
|
|
|
|
|
if (_ref / 10 == 12) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
_vm->optionTouch(_ref % 10, mask);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
return;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_flags._syst)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
return; // cannot access system sprites
|
|
|
|
|
if (Game) if (mask & L_UP) {
|
|
|
|
|
mask &= ~L_UP;
|
|
|
|
|
mask |= R_UP;
|
|
|
|
|
}
|
2011-06-22 06:11:18 +00:00
|
|
|
|
if ((mask & R_UP) && Snail->Idle()) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
Sprite *ps = (_pocLight->_seqPtr) ? _pocket[PocPtr] : NULL;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (ps) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (_flags._kept || Hero->distance(this) < MAX_DISTANCE) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
if (works(ps)) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
FeedSnail(ps, TAKE);
|
2011-06-13 11:07:45 +00:00
|
|
|
|
} else
|
2011-06-13 09:57:24 +00:00
|
|
|
|
OffUse();
|
|
|
|
|
SelectPocket(-1);
|
2011-06-13 11:07:45 +00:00
|
|
|
|
} else
|
2011-06-13 09:57:24 +00:00
|
|
|
|
TooFar();
|
|
|
|
|
} else {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_flags._kept)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
mask |= L_UP;
|
|
|
|
|
else {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (Hero->distance(this) < MAX_DISTANCE) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
///
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_flags._port) {
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (FindPocket(NULL) < 0)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
PocFul();
|
|
|
|
|
else {
|
|
|
|
|
SNPOST(SNREACH, -1, -1, this);
|
|
|
|
|
SNPOST(SNKEEP, -1, -1, this);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_flags._port = false;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
if (_takePtr != NO_PTR) {
|
|
|
|
|
if (snList(TAKE)[_takePtr].Com == SNNEXT)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
OffUse();
|
2011-06-13 11:07:45 +00:00
|
|
|
|
else
|
2011-06-13 09:57:24 +00:00
|
|
|
|
FeedSnail(this, TAKE);
|
2011-06-13 11:07:45 +00:00
|
|
|
|
} else
|
2011-06-13 09:57:24 +00:00
|
|
|
|
OffUse();
|
|
|
|
|
}
|
|
|
|
|
}///
|
2011-06-13 11:07:45 +00:00
|
|
|
|
else
|
2011-06-13 09:57:24 +00:00
|
|
|
|
TooFar();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-22 06:11:18 +00:00
|
|
|
|
if ((mask & L_UP) && Snail->Idle()) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
if (_flags._kept) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
int n;
|
2011-06-26 10:07:42 +00:00
|
|
|
|
for (n = 0; n < POCKET_NX; n++) {
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (_pocket[n] == this) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SelectPocket(n);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-13 11:07:45 +00:00
|
|
|
|
} else
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
static const char *Comd[] = { "Name", "Type", "Phase", "East",
|
|
|
|
|
"Left", "Right", "Top", "Bottom",
|
|
|
|
|
"Seq", "Near", "Take",
|
|
|
|
|
"Portable", "Transparent",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
static const char *Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS",
|
|
|
|
|
"FLY", NULL
|
|
|
|
|
};
|
|
|
|
|
char line[LINE_MAX];
|
|
|
|
|
|
|
|
|
|
int shpcnt = 0;
|
|
|
|
|
int type = 0; // DEAD
|
|
|
|
|
bool east = false;
|
|
|
|
|
bool port = false;
|
|
|
|
|
bool tran = false;
|
|
|
|
|
int i, lcnt = 0;
|
|
|
|
|
uint16 len;
|
|
|
|
|
|
2011-07-01 23:02:14 +00:00
|
|
|
|
mergeExt(line, fname, SPR_EXT);
|
2011-06-30 06:30:23 +00:00
|
|
|
|
if (INI_FILE::exist(line)) { // sprite description file exist
|
2011-06-13 09:57:24 +00:00
|
|
|
|
INI_FILE sprf(line);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (sprf._error)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
error("Bad SPR [%s]", line);
|
|
|
|
|
|
2011-06-30 06:30:23 +00:00
|
|
|
|
while ((len = sprf.read((uint8 *)line)) != 0) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
++ lcnt;
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (len && line[len - 1] == '\n')
|
2011-06-13 09:57:24 +00:00
|
|
|
|
line[-- len] = '\0';
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (len == 0 || *line == '.')
|
2011-06-13 09:57:24 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2011-07-01 23:02:14 +00:00
|
|
|
|
if ((i = takeEnum(Comd, strtok(line, " =\t"))) < 0)
|
2011-06-29 07:57:16 +00:00
|
|
|
|
error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
|
case 0 : // Name - will be taken in Expand routine
|
|
|
|
|
break;
|
|
|
|
|
case 1 : // Type
|
2011-07-01 23:02:14 +00:00
|
|
|
|
if ((type = takeEnum(Type, strtok(NULL, " \t,;/"))) < 0)
|
2011-06-29 07:57:16 +00:00
|
|
|
|
error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2 : // Phase
|
|
|
|
|
++ shpcnt;
|
|
|
|
|
break;
|
|
|
|
|
case 3 : // East
|
|
|
|
|
east = (atoi(strtok(NULL, " \t,;/")) != 0);
|
|
|
|
|
break;
|
|
|
|
|
case 11 : // Portable
|
|
|
|
|
port = (atoi(strtok(NULL, " \t,;/")) != 0);
|
|
|
|
|
break;
|
|
|
|
|
case 12 : // Transparent
|
|
|
|
|
tran = (atoi(strtok(NULL, " \t,;/")) != 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (! shpcnt)
|
|
|
|
|
error("No shapes [%s]", fname);
|
|
|
|
|
} else { // no sprite description: mono-shaped sprite with only .BMP file
|
|
|
|
|
++shpcnt;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// make sprite of choosen type
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 1 : { // AUTO
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = new Sprite(this, NULL);
|
|
|
|
|
if (_sprite) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_sprite->gotoxy(col, row);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
//Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
case 2 : { // WALK
|
2011-06-26 23:03:47 +00:00
|
|
|
|
WALK *w = new WALK(this, NULL);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (w && ref == 1) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
w->gotoxy(col, row);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (Hero)
|
|
|
|
|
error("2nd HERO [%s]", fname);
|
|
|
|
|
Hero = w;
|
|
|
|
|
}
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = w;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
/*
|
|
|
|
|
case 3 : // NEWTON
|
|
|
|
|
NEWTON * n = new NEWTON(NULL);
|
|
|
|
|
if (n)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
{
|
2011-06-13 09:57:24 +00:00
|
|
|
|
n->Ay = (bottom-n->H);
|
|
|
|
|
n->By = 90;
|
|
|
|
|
n->Cy = 3;
|
|
|
|
|
n->Bx = 99;
|
|
|
|
|
n->Cx = 3;
|
|
|
|
|
n->Goto(col, row);
|
|
|
|
|
}
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = n;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
*/
|
|
|
|
|
case 4 : { // LISSAJOUS
|
|
|
|
|
error("Bad type [%s]", fname);
|
|
|
|
|
/*
|
|
|
|
|
LISSAJOUS * l = new LISSAJOUS(NULL);
|
|
|
|
|
if (l)
|
|
|
|
|
{
|
|
|
|
|
l->Ax = SCR_WID/2;
|
|
|
|
|
l->Ay = SCR_HIG/2;
|
|
|
|
|
l->Bx = 7;
|
|
|
|
|
l->By = 13;
|
|
|
|
|
l->Cx = 300;
|
|
|
|
|
l->Cy = 500;
|
2011-06-26 10:07:42 +00:00
|
|
|
|
*(long *) &l->Dx = 0; // movex * cnt
|
2011-06-13 09:57:24 +00:00
|
|
|
|
l->Goto(col, row);
|
|
|
|
|
}
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = l;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
*/
|
|
|
|
|
break;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
case 5 : { // FLY
|
2011-07-01 06:37:40 +00:00
|
|
|
|
Fly *f = new Fly(this, NULL);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = f;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
//////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$
|
|
|
|
|
break;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
|
default: { // DEAD
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = new Sprite(this, NULL);
|
|
|
|
|
if (_sprite)
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_sprite->gotoxy(col, row);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (_sprite) {
|
|
|
|
|
_sprite->_ref = ref;
|
|
|
|
|
_sprite->_cave = cav;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_sprite->_z = pos;
|
|
|
|
|
_sprite->_flags._east = east;
|
|
|
|
|
_sprite->_flags._port = port;
|
|
|
|
|
_sprite->_flags._tran = tran;
|
|
|
|
|
_sprite->_flags._kill = true;
|
|
|
|
|
_sprite->_flags._bDel = true;
|
2011-06-29 11:17:07 +00:00
|
|
|
|
|
|
|
|
|
// Extract the filename, without the extension
|
2011-07-01 23:02:14 +00:00
|
|
|
|
strcpy(_sprite->_file, fname);
|
|
|
|
|
char *p = strchr(_sprite->_file, '.');
|
2011-06-29 11:17:07 +00:00
|
|
|
|
if (p)
|
|
|
|
|
*p = '\0';
|
2011-06-13 09:57:24 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_sprite->_shpCnt = shpcnt;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->SpareQ->Append(_sprite);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::loadScript(const char *fname) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
char line[LINE_MAX];
|
|
|
|
|
char *SpN;
|
|
|
|
|
int SpI, SpA, SpX, SpY, SpZ;
|
|
|
|
|
bool BkG = false;
|
|
|
|
|
INI_FILE scrf(fname);
|
|
|
|
|
int lcnt = 0;
|
|
|
|
|
bool ok = true;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (scrf._error)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
return;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-30 06:30:23 +00:00
|
|
|
|
while (scrf.read((uint8 *)line) != 0) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
char *p;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
lcnt++;
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (*line == 0 || *line == '\n' || *line == '.')
|
2011-06-13 09:57:24 +00:00
|
|
|
|
continue;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
ok = false; // not OK if break
|
|
|
|
|
// sprite ident number
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if ((p = strtok(line, " \t\n")) == NULL)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
break;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SpI = atoi(p);
|
|
|
|
|
// sprite file name
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
break;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// sprite cave
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
break;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SpA = atoi(p);
|
|
|
|
|
// sprite column
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
break;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SpX = atoi(p);
|
|
|
|
|
// sprite row
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
break;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SpY = atoi(p);
|
|
|
|
|
// sprite Z pos
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
break;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SpZ = atoi(p);
|
|
|
|
|
// sprite life
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
break;
|
|
|
|
|
BkG = atoi(p) == 0;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
ok = true; // no break: OK
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_sprite = NULL;
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadSprite(SpN, SpI, SpA, SpX, SpY, SpZ);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if (_sprite && BkG)
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_sprite->_flags._back = true;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (! ok)
|
|
|
|
|
error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-02 08:38:25 +00:00
|
|
|
|
#define GAME_FRAME_DELAY (1000 / 50)
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::mainLoop() {
|
2011-06-18 06:54:22 +00:00
|
|
|
|
SayDebug();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
|
2011-06-26 23:03:47 +00:00
|
|
|
|
if (_isDemo) {
|
2011-06-29 07:57:16 +00:00
|
|
|
|
// static uint32 tc = 0;
|
2011-06-26 23:03:47 +00:00
|
|
|
|
if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ Talk == NULL && Snail->Idle()) {
|
|
|
|
|
if (Text->getText(DemoText)) {
|
|
|
|
|
SNPOST(SNSOUND, -1, 4, NULL); // drumla
|
|
|
|
|
SNPOST(SNINF, -1, DemoText, NULL);
|
|
|
|
|
SNPOST(SNLABEL, -1, -1, NULL);
|
|
|
|
|
if (Text->getText(++ DemoText) == NULL)
|
|
|
|
|
DemoText = DEMO_TEXT + 1;
|
|
|
|
|
}
|
|
|
|
|
//FIXME: tc = TimerCount;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Vga->Show();
|
2011-06-22 06:11:18 +00:00
|
|
|
|
Snail_->RunCom();
|
|
|
|
|
Snail->RunCom();
|
2011-06-29 11:17:07 +00:00
|
|
|
|
|
2011-07-02 08:38:25 +00:00
|
|
|
|
// Game frame delay
|
|
|
|
|
uint32 millis = g_system->getMillis();
|
|
|
|
|
while (!_eventManager->_quitFlag && (millis < (_lastFrame + GAME_FRAME_DELAY))) {
|
|
|
|
|
// Handle any pending events
|
|
|
|
|
_eventManager->poll();
|
|
|
|
|
|
|
|
|
|
// Slight delay
|
|
|
|
|
g_system->delayMillis(10);
|
|
|
|
|
millis = g_system->getMillis();
|
|
|
|
|
}
|
|
|
|
|
_lastFrame = millis;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::loadUser() {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// set scene
|
|
|
|
|
if (STARTUP::Mode == 0) { // user .SVG file found
|
2011-06-30 06:30:23 +00:00
|
|
|
|
CFile cfile = CFile(UsrPath(UsrFnam), REA, RCrypt);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadGame(cfile);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (STARTUP::Mode == 1) {
|
|
|
|
|
SVG0FILE file = SVG0FILE(SVG0NAME);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadGame(file);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
} else {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
loadScript(progName(INI_EXT));
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Music = true;
|
2011-06-30 06:30:23 +00:00
|
|
|
|
CFile file = CFile(SVG0NAME, WRI);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SaveGame(file);
|
|
|
|
|
error("Ok [%s]", SVG0NAME);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-07-01 23:02:14 +00:00
|
|
|
|
loadScript(progName(IN0_EXT));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::runGame() {
|
2011-07-02 08:38:25 +00:00
|
|
|
|
if (_eventManager->_quitFlag)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Text->Clear();
|
|
|
|
|
Text->Preload(100, 1000);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
LoadHeroXY();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_cavLight->_flags._tran = true;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->ShowQ->Append(_cavLight);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_cavLight->_flags._hide = true;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
static Seq pocSeq[] = { { 0, 0, 0, 0, 20 },
|
2011-06-13 09:57:24 +00:00
|
|
|
|
{ 1, 2, 0, 0, 4 },
|
|
|
|
|
{ 2, 3, 0, 0, 4 },
|
|
|
|
|
{ 3, 4, 0, 0, 16 },
|
|
|
|
|
{ 2, 5, 0, 0, 4 },
|
|
|
|
|
{ 1, 6, 0, 0, 4 },
|
|
|
|
|
{ 0, 1, 0, 0, 16 },
|
|
|
|
|
};
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_pocLight->setSeq(pocSeq);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_pocLight->_flags._tran = true;
|
|
|
|
|
_pocLight->_time = 1;
|
|
|
|
|
_pocLight->_z = 120;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->ShowQ->Append(_pocLight);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SelectPocket(-1);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 11:17:07 +00:00
|
|
|
|
// FIXME: Allow ScummVM to handle mouse display
|
|
|
|
|
// Vga->ShowQ->Append(Mouse);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
|
|
|
|
// ___________
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadUser();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
// ~~~~~~~~~~~
|
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if ((_sprite = Vga->SpareQ->Locate(121)) != NULL)
|
|
|
|
|
SNPOST_(SNSEQ, -1, Vga->Mono, _sprite);
|
|
|
|
|
if ((_sprite = Vga->SpareQ->Locate(122)) != NULL)
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_sprite->step(Music);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
SNPOST_(SNSEQ, -1, Music, _sprite);
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (! Music)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
KillMIDI();
|
|
|
|
|
|
2011-06-30 06:30:23 +00:00
|
|
|
|
if (Mini && INI_FILE::exist("MINI.SPR")) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
uint8 *ptr = (uint8 *) &*Mini;
|
|
|
|
|
if (ptr != NULL) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadSprite("MINI", -1, 0, MINI_X, MINI_Y);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
ExpandSprite(_miniCave = _sprite); // NULL is ok
|
|
|
|
|
if (_miniCave) {
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_miniCave->_flags._hide = true;
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_miniCave->moveShapes(ptr);
|
|
|
|
|
MiniShp[0] = new Bitmap(*_miniCave->shp());
|
|
|
|
|
MiniShpList = _miniCave->setShapeList(MiniShp);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
PostMiniStep(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (Hero) {
|
|
|
|
|
ExpandSprite(Hero);
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Hero->gotoxy(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y);
|
2011-06-30 06:30:23 +00:00
|
|
|
|
if (INI_FILE::exist("00SHADOW.SPR")) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
if ((_shadow = _sprite) != NULL) {
|
|
|
|
|
_shadow->_ref = 2;
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_shadow->_flags._tran = true;
|
|
|
|
|
Hero->_flags._shad = true;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->ShowQ->Insert(Vga->SpareQ->Remove(_shadow), Hero);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-01 23:02:14 +00:00
|
|
|
|
InfoLine->gotoxy(INFO_X, INFO_Y);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
InfoLine->_flags._tran = true;
|
2011-06-21 17:38:16 +00:00
|
|
|
|
InfoLine->Update(NULL);
|
|
|
|
|
Vga->ShowQ->Insert(InfoLine);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
DebugLine->_z = 126;
|
2011-06-21 17:38:16 +00:00
|
|
|
|
Vga->ShowQ->Insert(DebugLine);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
_horzLine->_y = MAP_TOP - (MAP_TOP > 0);
|
|
|
|
|
_horzLine->_z = 126;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Vga->ShowQ->Insert(_horzLine);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_mouse->Busy = Vga->SpareQ->Locate(BUSY_REF);
|
|
|
|
|
if (_mouse->Busy)
|
|
|
|
|
ExpandSprite(_mouse->Busy);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Startup = 0;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
SNPOST(SNLEVEL, -1, OldLev, &_cavLight);
|
2011-07-01 23:02:14 +00:00
|
|
|
|
_cavLight->gotoxy(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
|
2011-06-13 09:57:24 +00:00
|
|
|
|
CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
caveUp();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_keyboard->setClient(Sys);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
// main loop
|
2011-07-02 08:38:25 +00:00
|
|
|
|
while (! Finis && !_eventManager->_quitFlag) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
//TODO Change the SNPOST message send to a special way to send function pointer
|
|
|
|
|
// if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame);
|
|
|
|
|
warning("RunGame: problematic use of SNPOST");
|
2011-07-01 06:37:40 +00:00
|
|
|
|
mainLoop();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_keyboard->setClient(NULL);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = false;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST(SNCLEAR, -1, 0, NULL);
|
|
|
|
|
SNPOST_(SNCLEAR, -1, 0, NULL);
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_mouse->Off();
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->ShowQ->Clear();
|
|
|
|
|
Vga->SpareQ->Clear();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Hero = NULL;
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_shadow = NULL;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
void CGEEngine::movie(const char *ext) {
|
2011-07-02 08:38:25 +00:00
|
|
|
|
if (_eventManager->_quitFlag)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-07-01 23:02:14 +00:00
|
|
|
|
const char *fn = progName(ext);
|
2011-06-30 06:30:23 +00:00
|
|
|
|
if (INI_FILE::exist(fn)) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadScript(fn);
|
2011-06-19 22:13:41 +00:00
|
|
|
|
ExpandSprite(Vga->SpareQ->Locate(999));
|
|
|
|
|
FeedSnail(Vga->ShowQ->Locate(999), TAKE);
|
2011-06-29 11:17:07 +00:00
|
|
|
|
|
|
|
|
|
// FIXME: Allow ScummVM to handle mouse display
|
|
|
|
|
//Vga->ShowQ->Append(Mouse);
|
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = true;
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_keyboard->setClient(Sys);
|
2011-07-02 08:38:25 +00:00
|
|
|
|
while (!Snail->Idle() && !_eventManager->_quitFlag)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
mainLoop();
|
2011-06-22 06:11:18 +00:00
|
|
|
|
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_keyboard->setClient(NULL);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = false;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SNPOST(SNCLEAR, -1, 0, NULL);
|
|
|
|
|
SNPOST_(SNCLEAR, -1, 0, NULL);
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->ShowQ->Clear();
|
|
|
|
|
Vga->SpareQ->Clear();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
bool CGEEngine::showTitle(const char *name) {
|
2011-07-02 08:38:25 +00:00
|
|
|
|
if (_eventManager->_quitFlag)
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-06-30 06:30:23 +00:00
|
|
|
|
Bitmap::_pal = VGA::SysPal;
|
|
|
|
|
BMP_PTR LB[] = { new Bitmap(name, true), NULL };
|
|
|
|
|
Bitmap::_pal = NULL;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
bool usr_ok = false;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-28 22:35:21 +00:00
|
|
|
|
Sprite D(this, LB);
|
2011-06-29 14:13:17 +00:00
|
|
|
|
D._flags._kill = true;
|
|
|
|
|
D._flags._bDel = true;
|
2011-07-01 23:02:14 +00:00
|
|
|
|
D.center();
|
|
|
|
|
D.show(2);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (STARTUP::Mode == 2) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
inf(SVG0NAME);
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Talk->show(2);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Vga->Sunset();
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->CopyPage(1, 2);
|
|
|
|
|
Vga->CopyPage(0, 1);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
SelectPocket(-1);
|
2011-06-27 08:57:58 +00:00
|
|
|
|
Vga->Sunrise(VGA::SysPal);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
|
2011-06-22 06:11:18 +00:00
|
|
|
|
if (STARTUP::Mode < 2 && !STARTUP::SoundOk) {
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->CopyPage(1, 2);
|
|
|
|
|
Vga->CopyPage(0, 1);
|
2011-07-02 06:46:31 +00:00
|
|
|
|
Vga->ShowQ->Append(_mouse);
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = true;
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_mouse->On();
|
2011-07-02 08:38:25 +00:00
|
|
|
|
for (selectSound(); !Snail->Idle() || VMENU::Addr;) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
mainLoop();
|
2011-07-02 08:38:25 +00:00
|
|
|
|
if (_eventManager->_quitFlag)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-02 06:46:31 +00:00
|
|
|
|
_mouse->Off();
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = false;
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->ShowQ->Clear();
|
|
|
|
|
Vga->CopyPage(0, 2);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
STARTUP::SoundOk = 2;
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (Music)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
LoadMIDI(0);
|
|
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (STARTUP::Mode < 2) {
|
2011-06-26 23:03:47 +00:00
|
|
|
|
if (_isDemo) {
|
2011-07-01 23:02:14 +00:00
|
|
|
|
strcpy(UsrFnam, progName(SVG_EXT));
|
2011-06-26 23:03:47 +00:00
|
|
|
|
usr_ok = true;
|
|
|
|
|
} else {
|
|
|
|
|
//-----------------------------------------
|
2011-06-13 09:57:24 +00:00
|
|
|
|
#ifndef EVA
|
|
|
|
|
#ifdef CD
|
2011-06-26 23:03:47 +00:00
|
|
|
|
STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
#else
|
2011-06-26 23:03:47 +00:00
|
|
|
|
// Boot * b = ReadBoot(getdisk());
|
|
|
|
|
warning("ShowTitle: FIXME ReadBoot");
|
2011-07-01 23:02:14 +00:00
|
|
|
|
Boot *b = readBoot(0);
|
2011-06-30 06:30:23 +00:00
|
|
|
|
uint32 sn = (b->_xSign == 0x29) ? b->_serial : b->_lTotSecs;
|
2011-06-26 23:03:47 +00:00
|
|
|
|
free(b);
|
2011-07-01 23:02:14 +00:00
|
|
|
|
sn -= ((Ident *)Copr)->_disk;
|
2011-06-26 23:03:47 +00:00
|
|
|
|
STARTUP::Summa |= Lo(sn) | Hi(sn);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
#endif
|
2011-06-26 23:03:47 +00:00
|
|
|
|
//-----------------------------------------
|
2011-07-01 06:37:40 +00:00
|
|
|
|
movie("X00"); // paylist
|
2011-06-26 23:03:47 +00:00
|
|
|
|
Vga->CopyPage(1, 2);
|
|
|
|
|
Vga->CopyPage(0, 1);
|
2011-07-02 06:46:31 +00:00
|
|
|
|
Vga->ShowQ->Append(_mouse);
|
2011-06-26 23:03:47 +00:00
|
|
|
|
//Mouse.On();
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = true;
|
2011-07-02 08:38:25 +00:00
|
|
|
|
for (takeName(); GetText::_ptr;) {
|
2011-07-01 06:37:40 +00:00
|
|
|
|
mainLoop();
|
2011-07-02 08:38:25 +00:00
|
|
|
|
if (_eventManager->_quitFlag)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-06-28 22:35:21 +00:00
|
|
|
|
_heart->_enable = false;
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (_keyboard->last() == Enter && *UsrFnam)
|
2011-06-26 23:03:47 +00:00
|
|
|
|
usr_ok = true;
|
|
|
|
|
if (usr_ok)
|
|
|
|
|
strcat(UsrFnam, SVG_EXT);
|
|
|
|
|
//Mouse.Off();
|
|
|
|
|
Vga->ShowQ->Clear();
|
|
|
|
|
Vga->CopyPage(0, 2);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
#endif
|
2011-06-26 23:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (usr_ok && STARTUP::Mode == 0) {
|
|
|
|
|
const char *n = UsrPath(UsrFnam);
|
2011-06-30 06:30:23 +00:00
|
|
|
|
if (CFile::exist(n)) {
|
|
|
|
|
CFile file = CFile(n, REA, RCrypt);
|
2011-07-01 06:37:40 +00:00
|
|
|
|
loadGame(file, true); // only system vars
|
2011-06-27 08:57:58 +00:00
|
|
|
|
Vga->SetColors(VGA::SysPal, 64);
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Vga->Update();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
if (FINIS) {
|
|
|
|
|
++ STARTUP::Mode;
|
|
|
|
|
FINIS = false;
|
|
|
|
|
}
|
2011-06-13 11:07:45 +00:00
|
|
|
|
} else
|
2011-06-13 09:57:24 +00:00
|
|
|
|
++STARTUP::Mode;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (STARTUP::Mode < 2)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
movie("X01"); // wink
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-19 22:13:41 +00:00
|
|
|
|
Vga->CopyPage(0, 2);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-26 23:03:47 +00:00
|
|
|
|
if (_isDemo)
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return (STARTUP::Mode == 2 || usr_ok);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-06-18 06:54:22 +00:00
|
|
|
|
void StkDump (void) {
|
2011-06-09 06:20:53 +00:00
|
|
|
|
CFILE f("!STACK.DMP", BFW);
|
2011-06-10 17:02:13 +00:00
|
|
|
|
f.Write((uint8 *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2011-06-26 23:03:47 +00:00
|
|
|
|
void CGEEngine::cge_main(void) {
|
2011-06-13 09:57:24 +00:00
|
|
|
|
uint16 intStack[STACK_SIZ / 2];
|
|
|
|
|
intStackPtr = intStack;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
|
//Debug( memset((void *) (-K(2)), 0, K(1)); )
|
|
|
|
|
//Debug( memset((void *) (-K(4)), 0, K(1)); )
|
|
|
|
|
memset(Barriers, 0xFF, sizeof(Barriers));
|
2011-06-09 06:20:53 +00:00
|
|
|
|
|
2011-07-02 06:46:31 +00:00
|
|
|
|
if (!_mouse->Exist)
|
2011-06-19 09:17:54 +00:00
|
|
|
|
error("%s", Text->getText(NO_MOUSE_TEXT));
|
2011-06-28 22:35:21 +00:00
|
|
|
|
|
2011-06-30 06:30:23 +00:00
|
|
|
|
if (!SVG0FILE::exist(SVG0NAME))
|
2011-06-13 09:57:24 +00:00
|
|
|
|
STARTUP::Mode = 2;
|
|
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
|
DebugLine->_flags._hide = true;
|
|
|
|
|
_horzLine->_flags._hide = true;
|
2011-06-13 09:57:24 +00:00
|
|
|
|
|
|
|
|
|
//srand((uint16) Timer());
|
2011-06-26 23:03:47 +00:00
|
|
|
|
Sys = new SYSTEM(this);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (Music && STARTUP::SoundOk)
|
2011-06-13 09:57:24 +00:00
|
|
|
|
LoadMIDI(0);
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (STARTUP::Mode < 2)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
movie(LGO_EXT);
|
2011-07-02 08:38:25 +00:00
|
|
|
|
|
2011-07-01 06:37:40 +00:00
|
|
|
|
if (showTitle("WELCOME")) {
|
2011-06-26 23:03:47 +00:00
|
|
|
|
if ((!_isDemo) && (STARTUP::Mode == 1))
|
2011-07-01 06:37:40 +00:00
|
|
|
|
movie("X02"); // intro
|
|
|
|
|
runGame();
|
2011-06-13 09:57:24 +00:00
|
|
|
|
Startup = 2;
|
2011-06-13 11:07:45 +00:00
|
|
|
|
if (FINIS)
|
2011-07-01 06:37:40 +00:00
|
|
|
|
movie("X03");
|
2011-06-13 11:07:45 +00:00
|
|
|
|
} else
|
2011-06-19 09:17:54 +00:00
|
|
|
|
Vga->Sunset();
|
2011-06-09 06:20:53 +00:00
|
|
|
|
}
|
2011-06-10 20:57:09 +00:00
|
|
|
|
|
|
|
|
|
} // End of namespace CGE
|