diff options
-rw-r--r-- | actor.cpp | 1 | ||||
-rw-r--r-- | akos.cpp | 1 | ||||
-rw-r--r-- | boxes.cpp | 1 | ||||
-rw-r--r-- | costume.cpp | 1 | ||||
-rw-r--r-- | debug.cpp | 1 | ||||
-rw-r--r-- | gfx.cpp | 1 | ||||
-rw-r--r-- | gui.cpp | 3 | ||||
-rw-r--r-- | insane.cpp | 587 | ||||
-rw-r--r-- | object.cpp | 1 | ||||
-rw-r--r-- | resource.cpp | 1 | ||||
-rw-r--r-- | saveload.cpp | 1 | ||||
-rw-r--r-- | script.cpp | 1 | ||||
-rw-r--r-- | script_v1.cpp | 1 | ||||
-rw-r--r-- | script_v2.cpp | 1 | ||||
-rw-r--r-- | scumm.h | 1458 | ||||
-rw-r--r-- | scummvm.cpp | 1 | ||||
-rw-r--r-- | sdl.cpp | 1 | ||||
-rw-r--r-- | sound.cpp | 1 | ||||
-rw-r--r-- | sound/adlib.cpp | 3 | ||||
-rw-r--r-- | sound/gmidi.cpp | 5 | ||||
-rw-r--r-- | sound/imuse.cpp | 3 | ||||
-rw-r--r-- | stdafx.cpp | 7 | ||||
-rw-r--r-- | string.cpp | 1 | ||||
-rw-r--r-- | sys.cpp | 1 | ||||
-rw-r--r-- | vars.cpp | 23 | ||||
-rw-r--r-- | verbs.cpp | 1 |
26 files changed, 714 insertions, 1393 deletions
@@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/costume.cpp b/costume.cpp index 35827ceb0b..0a44774c15 100644 --- a/costume.cpp +++ b/costume.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001 The ScummVM project + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/insane.cpp b/insane.cpp index 095714c007..7b6eca6bde 100644 --- a/insane.cpp +++ b/insane.cpp @@ -1,8 +1,23 @@ -// insane.cpp : Defines the entry point for the console application. - -// - - +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ #if !defined(__APPLE__CW) #define NEED_SDL_HEADERS @@ -10,71 +25,42 @@ #include "stdafx.h" - #include "scumm.h" - - #define SWAP2(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000)) - - void invalidblock(uint32 tag) { - error("Encountered invalid block %c%c%c%c", tag>>24, tag>>16, tag>>8, tag); - } - - uint32 SmushPlayer::nextBE32() { - uint32 a = *((uint32*)_cur); - _cur += sizeof(uint32); return SWAP2(a); - } - - void SmushPlayer::fileRead(void *mem, int len) { - if (fread(mem, len,1, _in) != 1) - error("EOF while reading"); } - - uint32 SmushPlayer::fileReadBE32() { - uint32 number; fileRead(&number, sizeof(number)); - return SWAP2(number); - } - - uint32 SmushPlayer::fileReadLE32() { - uint32 number; fileRead(&number, sizeof(number)); - return number; - } - - void SmushPlayer::openFile(byte* fileName) { - byte buf[100]; sprintf((char*)buf,"%sVIDEO/%s",(char*)sm->_gameDataPath,(char*)fileName); @@ -85,1067 +71,552 @@ void SmushPlayer::openFile(byte* fileName) { _in = fopen((char*)buf, "rb"); } - } - - void SmushPlayer::nextBlock() { - _blockTag = fileReadBE32(); - _blockSize = fileReadBE32(); - - if (_block != NULL) - free(_block); - - _block = (byte*)malloc(_blockSize); if (_block==NULL) - error("cannot allocate memory"); - - fileRead(_block, _blockSize); - } - - bool SmushPlayer::parseTag() { - switch(nextBlock(), _blockTag) { case 'AHDR': - parseAHDR(); - break; case 'FRME': - parseFRME(); - break; - + default: - invalidblock(_blockTag); - } return true; - } void SmushPlayer::parseAHDR() { - // memcpy(_fluPalette, _block, 0x300); - _paletteChanged = true; - - printf("parse AHDR\n"); - } void SmushPlayer::parseNPAL() { - memcpy(_fluPalette, _cur, 0x300); _paletteChanged = true; - } void codec1(CodecData *cd) { - uint y = cd->y; - byte *src = cd->src; - byte *dest= cd->out; - uint h = cd->h; - - if (!h || !cd->w) - return; - - dest += cd->y * cd->pitch; - - do { - byte color; - uint len, num; - uint x; if ((uint)y >= (uint)cd->outheight) { - src += *(uint16*)(src) + 2; - continue; - } len = cd->w; - x = cd->x; - - - src += 2; do { - byte code = *src++; num = (code>>1)+1; - if (num>len) num=len; - len -= num; if (code&1) { - color = *src++; - // if ((color = *src++)!=0) { - do { - if ((uint)x < (uint)cd->outwidth) - dest[x] = color; - } while (++x,--num); - // } else { - // x += num; - // } - } else { - do { - color = *src++; - if (/*(color=*src++) != 0 &&*/ (uint)x < (uint)cd->outwidth) - dest[x] = color; - } while (++x,--num); - } - } while (len); - } while (dest += cd->pitch,y++,--h); - } void codec37_bompdepack(byte *dst, byte *src, int len) { - byte code; - byte color; - int num; - - do { - code = *src++; - if (code & 1) { - num = (code>>1) + 1; - color = *src++; - memset(dst, color, num); - dst += num; - } else { - num = (code>>1) + 1; - memcpy(dst,src,num); - dst += num; - src += num; - } - } while (len -= num); - } - - void codec37_proc5(byte *dst, byte *src, int next_offs, int bw, int bh, int pitch, int16 *table) { - byte code, *tmp; - int i; - - - if (pitch != 320) - - { - + if (pitch != 320) { warning("invalid pitch"); - return; - } - - do { - i = bw; - do { - code = *src++; - if (code==0xFF) { - *(uint32*)(dst+0) = ((uint32*)src)[0]; - *(uint32*)(dst+320) = ((uint32*)src)[1]; - *(uint32*)(dst+320*2) = ((uint32*)src)[2]; - *(uint32*)(dst+320*3) = ((uint32*)src)[3]; - src += 16; - dst += 4; - } else { - tmp = dst + table[code] + next_offs; - *(uint32*)(dst+0) = *(uint32*)(tmp); - *(uint32*)(dst+320) = *(uint32*)(tmp+320); - *(uint32*)(dst+320*2) = *(uint32*)(tmp+320*2); - *(uint32*)(dst+320*3) = *(uint32*)(tmp+320*3); - dst += 4; - } - } while(--i); - dst += 320*4 - 320; - } while (--bh); - } static const int8 maketable_bytes[] = { - 0, 0, 1, 0, 2, 0, 3, 0, 5, 0, 8, 0, 13, 0, 21, 0, - -1, 0, -2, 0, -3, 0, -5, 0, -8, 0, -13, 0, -17, 0, -21, 0, - 0, 1, 1, 1, 2, 1, 3, 1, 5, 1, 8, 1, 13, 1, 21, 1, - -1, 1, -2, 1, -3, 1, -5, 1, -8, 1, -13, 1, -17, 1, -21, 1, - 0, 2, 1, 2, 2, 2, 3, 2, 5, 2, 8, 2, 13, 2, 21, 2, - -1, 2, -2, 2, -3, 2, -5, 2, -8, 2, -13, 2, -17, 2, -21, 2, - 0, 3, 1, 3, 2, 3, 3, 3, 5, 3, 8, 3, 13, 3, 21, 3, - -1, 3, -2, 3, -3, 3, -5, 3, -8, 3, -13, 3, -17, 3, -21, 3, - 0, 5, 1, 5, 2, 5, 3, 5, 5, 5, 8, 5, 13, 5, 21, 5, - -1, 5, -2, 5, -3, 5, -5, 5, -8, 5, -13, 5, -17, 5, -21, 5, - 0, 8, 1, 8, 2, 8, 3, 8, 5, 8, 8, 8, 13, 8, 21, 8, - -1, 8, -2, 8, -3, 8, -5, 8, -8, 8, -13, 8, -17, 8, -21, 8, - 0, 13, 1, 13, 2, 13, 3, 13, 5, 13, 8, 13, 13, 13, 21, 13, - -1, 13, -2, 13, -3, 13, -5, 13, -8, 13, -13, 13, -17, 13, -21, 13, - 0, 21, 1, 21, 2, 21, 3, 21, 5, 21, 8, 21, 13, 21, 21, 21, - -1, 21, -2, 21, -3, 21, -5, 21, -8, 21, -13, 21, -17, 21, -21, 21, - 0, -1, 1, -1, 2, -1, 3, -1, 5, -1, 8, -1, 13, -1, 21, -1, - -1, -1, -2, -1, -3, -1, -5, -1, -8, -1, -13, -1, -17, -1, -21, -1, - 0, -2, 1, -2, 2, -2, 3, -2, 5, -2, 8, -2, 13, -2, 21, -2, - -1, -2, -2, -2, -3, -2, -5, -2, -8, -2, -13, -2, -17, -2, -21, -2, - 0, -3, 1, -3, 2, -3, 3, -3, 5, -3, 8, -3, 13, -3, 21, -3, - -1, -3, -2, -3, -3, -3, -5, -3, -8, -3, -13, -3, -17, -3, -21, -3, - 0, -5, 1, -5, 2, -5, 3, -5, 5, -5, 8, -5, 13, -5, 21, -5, - -1, -5, -2, -5, -3, -5, -5, -5, -8, -5, -13, -5, -17, -5, -21, -5, - 0, -8, 1, -8, 2, -8, 3, -8, 5, -8, 8, -8, 13, -8, 21, -8, - -1, -8, -2, -8, -3, -8, -5, -8, -8, -8, -13, -8, -17, -8, -21, -8, - 0, -13, 1, -13, 2, -13, 3, -13, 5, -13, 8, -13, 13, -13, 21, -13, - -1, -13, -2, -13, -3, -13, -5, -13, -8, -13, -13, -13, -17, -13, -21, -13, - 0, -17, 1, -17, 2, -17, 3, -17, 5, -17, 8, -17, 13, -17, 21, -17, - -1, -17, -2, -17, -3, -17, -5, -17, -8, -17, -13, -17, -17, -17, -21, -17, - 0, -21, 1, -21, 2, -21, 3, -21, 5, -21, 8, -21, 13, -21, 21, -21, - -1, -21, -2, -21, -3, -21, -5, -21, -8, -21, -13, -21, -17, -21, 0, 0, - -8, -29, 8, -29, -18, -25, 17, -25, 0, -23, -6, -22, 6, -22, -13, -19, - 12, -19, 0, -18, 25, -18, -25, -17, -5, -17, 5, -17, -10, -15, 10, -15, - 0, -14, -4, -13, 4, -13, 19, -13, -19, -12, -8, -11, -2, -11, 0, -11, - 2, -11, 8, -11, -15, -10, -4, -10, 4, -10, 15, -10, -6, -9, -1, -9, - 1, -9, 6, -9, -29, -8, -11, -8, -8, -8, -3, -8, 3, -8, 8, -8, - 11, -8, 29, -8, -5, -7, -2, -7, 0, -7, 2, -7, 5, -7, -22, -6, - -9, -6, -6, -6, -3, -6, -1, -6, 1, -6, 3, -6, 6, -6, 9, -6, - 22, -6, -17, -5, -7, -5, -4, -5, -2, -5, 0, -5, 2, -5, 4, -5, - 7, -5, 17, -5, -13, -4, -10, -4, -5, -4, -3, -4, -1, -4, 0, -4, - 1, -4, 3, -4, 5, -4, 10, -4, 13, -4, -8, -3, -6, -3, -4, -3, - -3, -3, -2, -3, -1, -3, 0, -3, 1, -3, 2, -3, 4, -3, 6, -3, - 8, -3, -11, -2, -7, -2, -5, -2, -3, -2, -2, -2, -1, -2, 0, -2, - 1, -2, 2, -2, 3, -2, 5, -2, 7, -2, 11, -2, -9, -1, -6, -1, - -4, -1, -3, -1, -2, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, - 4, -1, 6, -1, 9, -1, -31, 0, -23, 0, -18, 0, -14, 0, -11, 0, - -7, 0, -5, 0, -4, 0, -3, 0, -2, 0, -1, 0, 0, -31, 1, 0, - 2, 0, 3, 0, 4, 0, 5, 0, 7, 0, 11, 0, 14, 0, 18, 0, - 23, 0, 31, 0, -9, 1, -6, 1, -4, 1, -3, 1, -2, 1, -1, 1, - 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 6, 1, 9, 1, -11, 2, - -7, 2, -5, 2, -3, 2, -2, 2, -1, 2, 0, 2, 1, 2, 2, 2, - 3, 2, 5, 2, 7, 2, 11, 2, -8, 3, -6, 3, -4, 3, -2, 3, - -1, 3, 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 6, 3, 8, 3, - -13, 4, -10, 4, -5, 4, -3, 4, -1, 4, 0, 4, 1, 4, 3, 4, - 5, 4, 10, 4, 13, 4, -17, 5, -7, 5, -4, 5, -2, 5, 0, 5, - 2, 5, 4, 5, 7, 5, 17, 5, -22, 6, -9, 6, -6, 6, -3, 6, - -1, 6, 1, 6, 3, 6, 6, 6, 9, 6, 22, 6, -5, 7, -2, 7, - 0, 7, 2, 7, 5, 7, -29, 8, -11, 8, -8, 8, -3, 8, 3, 8, - 8, 8, 11, 8, 29, 8, -6, 9, -1, 9, 1, 9, 6, 9, -15, 10, - -4, 10, 4, 10, 15, 10, -8, 11, -2, 11, 0, 11, 2, 11, 8, 11, - 19, 12, -19, 13, -4, 13, 4, 13, 0, 14, -10, 15, 10, 15, -5, 17, - 5, 17, 25, 17, -25, 18, 0, 18, -12, 19, 13, 19, -6, 22, 6, 22, - 0, 23, -17, 25, 18, 25, -8, 29, 8, 29, 0, 31, 0, 0, -6, -22, - 6, -22, -13, -19, 12, -19, 0, -18, -5, -17, 5, -17, -10, -15, 10, -15, - 0, -14, -4, -13, 4, -13, 19, -13, -19, -12, -8, -11, -2, -11, 0, -11, - 2, -11, 8, -11, -15, -10, -4, -10, 4, -10, 15, -10, -6, -9, -1, -9, - 1, -9, 6, -9, -11, -8, -8, -8, -3, -8, 0, -8, 3, -8, 8, -8, - 11, -8, -5, -7, -2, -7, 0, -7, 2, -7, 5, -7, -22, -6, -9, -6, - -6, -6, -3, -6, -1, -6, 1, -6, 3, -6, 6, -6, 9, -6, 22, -6, - -17, -5, -7, -5, -4, -5, -2, -5, -1, -5, 0, -5, 1, -5, 2, -5, - 4, -5, 7, -5, 17, -5, -13, -4, -10, -4, -5, -4, -3, -4, -2, -4, - -1, -4, 0, -4, 1, -4, 2, -4, 3, -4, 5, -4, 10, -4, 13, -4, - -8, -3, -6, -3, -4, -3, -3, -3, -2, -3, -1, -3, 0, -3, 1, -3, - 2, -3, 3, -3, 4, -3, 6, -3, 8, -3, -11, -2, -7, -2, -5, -2, - -4, -2, -3, -2, -2, -2, -1, -2, 0, -2, 1, -2, 2, -2, 3, -2, - 4, -2, 5, -2, 7, -2, 11, -2, -9, -1, -6, -1, -5, -1, -4, -1, - -3, -1, -2, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, - 5, -1, 6, -1, 9, -1, -23, 0, -18, 0, -14, 0, -11, 0, -7, 0, - -5, 0, -4, 0, -3, 0, -2, 0, -1, 0, 0, -23, 1, 0, 2, 0, - 3, 0, 4, 0, 5, 0, 7, 0, 11, 0, 14, 0, 18, 0, 23, 0, - -9, 1, -6, 1, -5, 1, -4, 1, -3, 1, -2, 1, -1, 1, 0, 1, - 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 9, 1, -11, 2, - -7, 2, -5, 2, -4, 2, -3, 2, -2, 2, -1, 2, 0, 2, 1, 2, - 2, 2, 3, 2, 4, 2, 5, 2, 7, 2, 11, 2, -8, 3, -6, 3, - -4, 3, -3, 3, -2, 3, -1, 3, 0, 3, 1, 3, 2, 3, 3, 3, - 4, 3, 6, 3, 8, 3, -13, 4, -10, 4, -5, 4, -3, 4, -2, 4, - -1, 4, 0, 4, 1, 4, 2, 4, 3, 4, 5, 4, 10, 4, 13, 4, - -17, 5, -7, 5, -4, 5, -2, 5, -1, 5, 0, 5, 1, 5, 2, 5, - 4, 5, 7, 5, 17, 5, -22, 6, -9, 6, -6, 6, -3, 6, -1, 6, - 1, 6, 3, 6, 6, 6, 9, 6, 22, 6, -5, 7, -2, 7, 0, 7, - 2, 7, 5, 7, -11, 8, -8, 8, -3, 8, 0, 8, 3, 8, 8, 8, - 11, 8, -6, 9, -1, 9, 1, 9, 6, 9, -15, 10, -4, 10, 4, 10, - 15, 10, -8, 11, -2, 11, 0, 11, 2, 11, 8, 11, 19, 12, -19, 13, - -4, 13, 4, 13, 0, 14, -10, 15, 10, 15, -5, 17, 5, 17, 0, 18, - -12, 19, 13, 19, -6, 22, 6, 22, 0, 23, - }; - - - - void codec37_maketable(PersistentCodecData37 *pcd, int pitch, byte idx) { - int i,j; - - if (pcd->table_last_pitch==pitch && pcd->table_last_flags==idx) - return; pcd->table_last_pitch = pitch; - pcd->table_last_flags = idx; - - assert(idx*255 + 254 < (int)(sizeof(maketable_bytes)/2)); - - for(i=0; i<255; i++) { - j = i + idx*255; - pcd->table1[i] = maketable_bytes[j*2+1] * pitch + maketable_bytes[j*2]; - } - - - } void codec37(CodecData *cd, PersistentCodecData37 *pcd) { - int width_in_blocks, height_in_blocks; - int src_pitch; - byte *curbuf; - uint size; - bool result = false; - - width_in_blocks = (cd->w + 3) >> 2; - height_in_blocks = (cd->h + 3) >> 2; - src_pitch = width_in_blocks * 4; - - codec37_maketable(pcd, src_pitch, cd->src[1]); - - switch(cd->src[0]) { - case 0: { - curbuf = pcd->deltaBufs[pcd->curtable]; - memset(pcd->deltaBuf, 0, curbuf - pcd->deltaBuf); - size = *(uint32*)(cd->src + 4); - memset(curbuf + size, 0, pcd->deltaBuf + pcd->deltaSize - curbuf - size); - memcpy(curbuf, cd->src + 16, size); - break; - - } + } case 2: { - size = *(uint32*)(cd->src + 4); - curbuf = pcd->deltaBufs[pcd->curtable]; - if(size==64000) - codec37_bompdepack(curbuf, cd->src+16, size); - else - return; memset(pcd->deltaBuf, 0, curbuf - pcd->deltaBuf); - memset(curbuf + size, 0, pcd->deltaBuf + pcd->deltaSize - curbuf - size); - break; - - } + } case 3: { - uint16 number = *(uint16*)(cd->src + 2); if ( number && pcd->flags+1 != number) - break; - - if (number&1 && cd->src[12]&1 && cd->flags&0x10) { - result=true; - break; - } - - if ((number&1) || !(cd->src[12]&1)) { - pcd->curtable ^= 1; - } - - codec37_proc5(pcd->deltaBufs[pcd->curtable], cd->src+16, - pcd->deltaBufs[pcd->curtable^1] - pcd->deltaBufs[pcd->curtable], - width_in_blocks, height_in_blocks, src_pitch, - pcd->table1); - break; - - } - - + } case 1: - case 4: - printf("code %d", cd->src[0]); - return; default: - error("codec37 default case"); - } - - - - pcd->flags = *(uint16*)(cd->src + 2); - - if (result) { - pcd->curtable ^= 1; - } else { - memcpy(cd->out, pcd->deltaBufs[pcd->curtable], 320*200); - } - - - } - - - - void codec37_init(PersistentCodecData37 *pcd, int width, int height) { - pcd->width = width; - pcd->height = height; - pcd->deltaSize = width*height*2+0x3E00+0xBA00; - pcd->deltaBuf = (byte*)calloc(pcd->deltaSize, 1); - pcd->deltaBufs[0] = pcd->deltaBuf + 0x3E00; - pcd->deltaBufs[1] = pcd->deltaBuf + width * height + 0xBA00; - pcd->curtable = 0; - pcd->table1 = (int16*)calloc(255,sizeof(uint16)); - } - - void SmushPlayer::parseFOBJ() { - byte codec; - CodecData cd; - - cd.out = _renderBitmap; - cd.pitch = cd.outwidth = 320; - cd.outheight = 200; - cd.y = 0; - cd.x = 0; - cd.src = _cur + 0xE; - cd.w = *(uint16*)(_cur + 6); - cd.h = *(uint16*)(_cur + 8); - - codec = _cur[0]; - - switch(codec) { - case 1: - codec1(&cd); - break; - case 37: - codec37(&cd, &pcd37); - break; - default: - error("invalid codec %d", codec); - } - - - - - } - - void SmushPlayer::parsePSAD() { - //printf("parse PSAD\n"); - } - - void SmushPlayer::parseTRES() { - // printf("parse TRES\n"); - } - - void SmushPlayer::parseXPAL() { - int num; - int i; - - num = *(uint16*)(_cur + 2); - - - if (num==0 || num==0x200) { - if (num==0x200) - memcpy(_fluPalette, _cur + 0x604, 0x300); - - for(i=0; i<0x300; i++) { - _fluPalMul129[i] = _fluPalette[i] * 129; - _fluPalWords[i] = *(uint16*)(_cur + 4 + i*2); - } - return; - } - - for(i=0; i<0x300; i++) { - _fluPalMul129[i] += _fluPalWords[i]; - _fluPalette[i] = _fluPalMul129[i]>>7; - } - - _paletteChanged = true; - } - - void SmushPlayer::parseFRME() { - _cur = _block; - - do { - _frmeTag = nextBE32(); - _frmeSize = nextBE32(); - - switch(_frmeTag) { - case 'NPAL': - parseNPAL(); - break; - case 'FOBJ': - parseFOBJ(); - break; - case 'PSAD': - parsePSAD(); - break; - case 'TRES': - parseTRES(); - break; - case 'XPAL': - parseXPAL(); - break; - case 'IACT': - parseTRES(); - + break; + case 'STOR': + case 'FTCH': break; default: - invalidblock(_frmeTag); - } - - _cur += (_frmeSize + 1) & ~1; - - - } while (_cur + 4 < _block + _blockSize); - } - - void SmushPlayer::init() { - _renderBitmap = (byte*)malloc(320*200); - codec37_init(&pcd37, 320, 200); - } - - void SmushPlayer::go() { - while (parseTag()) {} - } - - - - void SmushPlayer::setPalette() { - int i; - - for(i=0;i<768;i++) - sm->_currentPalette[i]=_fluPalette[i]; - } - - void SmushPlayer::startVideo(short int arg, byte* videoFile) - { - int frameIndex=0; - - _in=NULL; - _paletteChanged=0; - _block=NULL; - _blockTag=0; - _blockSize=0; - _cur=NULL; - _renderBitmap=NULL; - _frameSize=0; - _frmeTag=0; - _frmeSize=0; - _deltaBuf=NULL; - _deltaBufSize=0; - - pcd37.deltaBuf=NULL; - pcd37.deltaBufs[0]=NULL; - pcd37.deltaBufs[1]=NULL; - pcd37.deltaSize=0; - pcd37.width=0; - pcd37.height=0; - pcd37.curtable=0; - pcd37.unk2=0; - pcd37.unk3=0; - pcd37.flags=0; - pcd37.table1=NULL; - pcd37.table_last_pitch=0; - pcd37.table_last_flags=0; - - - - - - init(); - openFile(videoFile); - - if(_in==NULL) - return; - - - if (fileReadBE32() != 'ANIM') - + if (fileReadBE32() != 'ANIM') error("file is not an anim"); - - fileSize=fileReadBE32(); - - - - do { - if(ftell(_in)>=fileSize ) - return; - - parseTag(); - frameIndex++; - - if (_paletteChanged) { - _paletteChanged = false; - setPalette(); - sm->setDirtyColors(0, 255); - } - - blitToScreen(sm,_renderBitmap, 0, 0, 320 ,200); - - - updateScreen(sm); - - waitForTimer(sm,20); - - if(sm->_keyPressed == sm->_vars[sm->VAR_CUTSCENEEXIT_KEY]) - return; - - - } while (1); - } diff --git a/object.cpp b/object.cpp index da1ed47ed3..30b4f98afe 100644 --- a/object.cpp +++ b/object.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/resource.cpp b/resource.cpp index 6f8c22303b..cad701fca9 100644 --- a/resource.cpp +++ b/resource.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/saveload.cpp b/saveload.cpp index 339d11773a..6a03dbe159 100644 --- a/saveload.cpp +++ b/saveload.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/script.cpp b/script.cpp index 1f96cb8e51..a6a67bea63 100644 --- a/script.cpp +++ b/script.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/script_v1.cpp b/script_v1.cpp index 83153c64f1..1a1020331d 100644 --- a/script_v1.cpp +++ b/script_v1.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/script_v2.cpp b/script_v2.cpp index 2538fd3bf1..be6b448fe9 100644 --- a/script_v2.cpp +++ b/script_v2.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,7 +34,7 @@ #define SWAP(a,b) do{int tmp=a; a=b; b=tmp; } while(0) #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) -struct Scumm; +class Scumm; struct Actor; struct gate_location @@ -879,364 +879,748 @@ struct BoxCoords { ScummPoint lr; }; -#ifdef COMPRESSED_SOUND_FILE -struct OffsetTable { +struct OffsetTable { /* Compressed Sound (.SO3) */ int org_offset; int new_offset; int num_tags; int compressed_size; }; -#endif -struct Scumm { - uint32 _features; - const char *_gameText; - byte _gameId; -// byte _majorScummVersion; -// byte _middleScummVersion; -// byte _minorScummVersion; - ScummDebugger *_debugger; - void *_gui; /* actually a pointer to a Gui */ +class Scumm { +public: - byte OF_OWNER_ROOM; - - int _gameTempo, _saveSound; - int _lastLoadedRoom; - int _roomResource; - - byte _encbyte; - void *_fileHandle; - void *_sfxFile; - char *_exe_name; - char *_gameDataPath; - char *_savegame_dir; - int akos_findManyDirection(int16 ManyDirection, uint16 facing); - - byte _saveLoadFlag; - byte _saveLoadSlot; - bool _saveLoadCompatible; + struct { + byte mode[rtNumTypes]; + uint16 num[rtNumTypes]; + uint32 tags[rtNumTypes]; + const char *name[rtNumTypes]; + byte **address[rtNumTypes]; + byte *flags[rtNumTypes]; + byte *roomno[rtNumTypes]; + uint32 *roomoffs[rtNumTypes]; + } res; - bool _dynamicRoomOffsets; - byte _resFilePathId; + struct { + uint32 cutScenePtr[5]; + byte cutSceneScript[5]; + int16 cutSceneData[5]; + int16 cutSceneScriptIndex; + byte cutSceneStackPointer; + ScriptSlot slot[NUM_SCRIPT_SLOT]; + NestedScript nest[15]; + int16 localvar[NUM_SCRIPT_SLOT][17]; + } vm; - bool _soundsPaused; - bool _soundsPaused2; - bool _useTalkAnims; - - char *_resFilePrefix; - char *_resFilePath; + struct { + int16 x,y; + } mouse; - int _keyPressed; + /* Init functions, etc*/ + byte _fastMode; + char *getGameName(); + + void scummInit(); + void scummMain(int argc, char **argv); + int scummLoop(int delta); + void initScummVars(); + + void pauseGame(bool user); + void shutDown(int i); + void setOptions(void); + + void main(); + void parseCommandLine(int argc, char **argv); + void showHelpAndExit(); + bool detectGame(); + void processKbd(); + void clear_fullRedraw(); - int _midi_driver; + int checkKeyHit(); + void convertKeysToClicks(); + + /* Random number generation */ + uint32 _randSeed1, _randSeed2; + void initRandSeeds(); + uint getRandomNumber(uint max); + uint getRandomNumberRng(uint min, uint max); + + /* Core variable definitions */ + uint32 _features; + byte _gameId; + const char *_gameText; + char *_gameDataPath; + + /* Core class/array definitions */ void *_soundEngine; + void *_gui; + Gdi gdi; - uint16 *_inventory; - byte *_arrays; + Actor actor[MAX_ACTORS]; VerbSlot *_verbs; ObjectData *_objs; + ScummDebugger *_debugger; + + uint16 *_inventory; + byte *_arrays; uint16 *_newNames; int16 *_vars; int16 _varwatch; byte *_bitVars; - const OpcodeProc *_opcodes; - const char* *_opcodes_lookup; - - int _xPos, _yPos; - int _dir; + /* Global resource tables */ + int _numVariables, _numBitVariables, _numLocalObjects; + int _numGlobalObjects, _numArray, _numVerbs, _numFlObject; + int _numInventory, _numRooms, _numScripts, _numSounds; + int _numCharsets, _numCostumes, _numNewNames, _numGlobalScripts; + int NUM_ACTORS; + /* Current objects - can go in their respective classes */ byte _curActor; int _curVerb; int _curVerbSlot; - int _curPalIndex; - + byte _currentRoom; VirtScreen *_curVirtScreen; - - byte *_scriptPointer, *_scriptOrgPointer; - byte *_scriptPointerStart; - byte _opcode; - - int _numVariables; - int _numBitVariables; - int _numLocalObjects; - int _numGlobalObjects; - int _numArray; - int _numVerbs; - int _numFlObject; - int _numInventory; - int _numRooms; - int _numScripts; - int _numSounds; - int _numCharsets; - int _numCostumes; - int _numNewNames; - int _numGlobalScripts; + bool _egoPositioned; + int _xPos, _yPos, _dir; + int _keyPressed; + uint16 _lastKeyHit; + uint16 _mouseButStat; + byte _leftBtnPressed, _rightBtnPressed; - byte *_msgPtrToAdd; - - uint8 *_roomFileIndexes; - byte *_objectOwnerTable; - byte *_objectRoomTable; - byte *_objectStateTable; - uint32 *_classData; + int16 _virtual_mouse_x, _virtual_mouse_y, _bootParam; + uint16 _debugMode, _currentDrive, _soundCardType; + byte _mousePresent; - byte _expire_counter; + /* Not sure where this stuff goes */ + byte isMaskActiveAt(int l, int t, int r, int b, byte *mem); + void startScene(int room, Actor *a, int b); + void setupScummVarsOld(); // Both of these will simply be one + void setupScummVarsNew(); // 'setupScummVars' in each Scumm_Vx + byte *_objectOwnerTable, *_objectRoomTable, *_objectStateTable; + byte _numObjectsInRoom; + int8 _userPut; + int _resourceHeaderSize; + void unkRoomFunc3(int a, int b, int c, int d, int e); + void unkRoomFunc4(int a, int b, int c, int d, int e); + void setScaleItem(int slot, int a, int b, int c, int d); + void clearClickedStatus(); + void startManiac(); - bool _noTalkAnims; + /* GUI class */ + void drawString(int a); + int getKeyInput(int a); - bool _mouthSyncMode; - bool _endOfMouthSync; + /* Save/Load class - some of this may be GUI */ + byte _saveLoadFlag, _saveLoadSlot; + bool _saveLoadCompatible; + char _saveLoadName[32]; - uint32 _randSeed1; - uint32 _randSeed2; + bool saveState(int slot, bool compat); + bool loadState(int slot, bool compat); + void saveOrLoad(Serializer *s); - uint16 _screenB, _screenH; + bool getSavegameName(int slot, char *desc); + void makeSavegameName(char *out, int slot, bool compatible); + void saveLoadResource(Serializer *ser, int type, int index); - uint16 _defaultTalkDelay; - byte _haveMsg; - byte _newEffect; - bool _fullRedraw; - uint16 _soundParam,_soundParam2,_soundParam3; + /* Heap and memory management */ + uint32 _maxHeapThreshold, _minHeapThreshold; + void checkRange(int max, int min, int no, const char *str); + void lock(int type, int i); + void unlock(int type, int i); + void heapClear(int mode); + void unkHeapProc2(int a, int b); + + /* Script VM - should be in Script class */ + uint32 _localScriptList[NUM_LOCALSCRIPT]; + byte *_scriptPointer, *_scriptOrgPointer, *_scriptPointerStart; + byte _opcode, _numNestedScripts, _currentScript; + uint16 _curExecScript; + const OpcodeProc *_opcodes; + const char* *_opcodes_lookup; + byte **_lastCodePtr; + int _resultVarNumber, _scummStackPos; + int16 _localParamList[16], _scummStack[150]; + + OpcodeProc getOpcode(int i) { return _opcodes[i]; } + void initializeLocals(int slot, int16 *vars); + int getScriptSlot(); + void runScript(int script, int a, int b, int16 *lvarptr); + void stopScriptNr(int script); + void runScriptNested(int script); + void executeScript(); + void updateScriptPtr(); + void getScriptBaseAddress(); + void getScriptEntryPoint(); + byte fetchScriptByte(); + int fetchScriptWord(); + void ignoreScriptWord() { fetchScriptWord(); } + void ignoreScriptByte() { fetchScriptByte(); } + uint getVarOrDirectWord(byte mask); + uint getVarOrDirectByte(byte mask); + void getResultPos(); + void setResult(int result); + int readVar(uint var); + void writeVar(uint var, int value); + void push(int a); + int pop(); + void runHook(int i); + bool isScriptInUse(int script); + int getStringLen(byte *ptr); - byte _switchRoomEffect2, _switchRoomEffect; + void freezeScripts(int scr); + void unfreezeScripts(); + void runAllScripts(); + void setupOpcodes(); + void setupOpcodes2(); + void cutscene(int16 *args); + void endCutscene(); + void exitCutscene(); + void runExitScript(); + void runEntryScript(); - int _resourceHeaderSize; + void beginOverride(); + void endOverride(); + void killScriptsAndResources(); + void checkAndRunVar33(); + void decreaseScriptDelay(int amount); + bool isScriptRunning(int script); + bool isRoomScriptRunning(int script); + void arrayop_1(int a, byte *ptr); + void copyString(byte *dst, byte *src, int len); + void doSentence(int c, int b, int a); + int popRoomAndObj(int *room); + int getWordVararg(int16 *ptr); + void decodeParseString(); + void decodeParseString2(int a, int b); + + /* Script VM or Object class? */ + void stopObjectCode(); + void stopObjectScript(int script); - bool _egoPositioned; - bool _doEffect; - bool _screenEffectFlag; - bool _keepText; - uint32 _maxHeapThreshold; - uint32 _minHeapThreshold; - bool _fullScreen; - int _videoMode; + /* Should be in Resource class */ + byte _encbyte; + void *_fileHandle; + char *_resFilePrefix, *_resFilePath; + uint32 _fileOffset; + char *_exe_name; + bool _dynamicRoomOffsets; + byte _resourceMapper[128]; + uint32 _allocatedSize; + byte _expire_counter; - byte _bkColor; - uint16 _lastXstart; - - int16 _talkDelay; + void allocateArrays(); + void openRoom(int room); + void deleteRoomOffsets(); + void readRoomsOffsets(); + void askForDisk(const char *filename); + bool openResourceFile(const char *filename); + void loadPtrToResource(int type, int i, byte *ptr); + void readResTypeList(int id, uint32 tag, const char *name); + void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode); + byte *createResource(int type, int index, uint32 size); + void nukeResource(int type, int i); + byte *getResourceAddress(int type, int i); + byte *getStringAddress(int i); + void ensureResourceLoaded(int type, int i); + int loadResource(int type, int i); + int getResourceRoomNr(int type, int index); + int readSoundResource(int type, int index); + void setResourceCounter(int type, int index, byte flag); + void validateResource(const char *str, int type, int index); + void increaseResourceCounter(); + bool isResourceInUse(int type, int i); + bool isResourceLoaded(int type, int index); + void initRoomSubBlocks(); + void loadRoomObjects(); + void loadRoomObjectsSmall(); + void readArrayFromIndexFile(); + void readMAXS(); + void readIndexFile(); + void readIndexFileSmall(); + void loadCharset(int i); + void nukeCharset(int i); - bool _shakeEnabled; - uint _shakeFrame; + bool fileReadFailed(void *handle); + void clearFileReadFailed(void *handle); - int16 _virtual_mouse_x, _virtual_mouse_y; + int _lastLoadedRoom, _roomResource; + byte _resFilePathId, _fileReadFailed; + byte *findResourceData(uint32 tag, byte *ptr); + int getResourceDataSize(byte *ptr); + + int getArrayId(); + void nukeArray(int a); + int defineArray(int a, int b, int c, int d); + int readArray(int array, int index, int base); + void writeArray(int array, int index, int base, int value); - int _cursorHotspotX, _cursorHotspotY; - int _cursorWidth, _cursorHeight; - byte _cursorAnimateIndex; - byte _cursorAnimate; + void resourceStats(); + void expireResources(uint32 size); + void freeResources(); + void destroy(); + void dumpResource(char *tag, int index, byte *ptr); - byte _charsetColor; - uint16 _debugMode; + /* Should be in Object class */ + byte OF_OWNER_ROOM; + struct FindObjectInRoom { + CodeHeader *cdhd; + byte *obcd; + ImageHeader *imhd; + byte *obim; + byte *roomptr; + }; - uint16 _noSubtitles; // skip all subtitles? - unsigned int _scale; // multiplier to resolution (2 is default) + enum FindObjectWhat { + foCodeHeader = 1, + foImageHeader = 2, + foCheckAlreadyLoaded = 4 + }; + int getInventorySlot(); + void SamInventoryHack(int obj); // FIXME: Sam and Max hack + int findInventory(int owner, int index); + int getInventoryCount(int owner); - byte *_messagePtr; + void setupRoomObject(ObjectData *od, byte *room); + void removeObjectFromRoom(int obj); + void loadFlObject(uint object, uint room); + void nukeFlObjects(int min, int max); + int findFlObjectSlot(); + void addObjectToInventory(uint obj, uint room); + void fixObjectFlags(); + bool getClass(int obj, int cls); + void putClass(int obj, int cls, bool set); + int getState(int obj); + void putState(int obj, int state); + void setObjectState(int obj, int state, int x, int y); + int getOwner(int obj); + void putOwner(int obj, int owner); + void setOwnerOf(int obj, int owner); + void clearOwnerOf(int obj); + int getObjectRoom(int obj); + int getObjX(int obj); + int getObjY(int obj); + void getObjectXYPos(int object); + int getObjOldDir(int obj); + int getObjNewDir(int obj); + int getObjectIndex(int object); + int whereIsObject(int object); + int findObject(int x, int y); + void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room); + int getObjectOrActorXY(int object); // Object and Actor... + int getObjActToObjActDist(int a, int b); // Not sure how to handle + byte *getObjOrActorName(int obj); // these three.. - byte _numNestedScripts; - byte _currentScript; + void addObjectToDrawQue(int object); + void clearDrawObjectQueue(); + void processDrawQue(); - byte _currentRoom; - byte _numObjectsInRoom; - byte _actorToPrintStrFor; + uint32 getOBCDOffs(int object); + byte *getOBCDFromObject(int obj); + int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f); - int _screenStartStrip; - int _screenEndStrip; - int _screenLeft; - int _screenTop; - byte _fastMode; - - bool _completeScreenRedraw; + /* Should be in akos class */ + bool akos_drawCostume(AkosRenderer *ar); + void akos_setPalette(AkosRenderer *ar, byte *palette); + void akos_setCostume(AkosRenderer *ar, int costume); + void akos_setFacing(AkosRenderer *ar, Actor *a); + bool akos_drawCostumeChannel(AkosRenderer *ar, int chan); + void akos_codec1(AkosRenderer *ar); + void akos_codec5(AkosRenderer *ar); + void akos_codec16(AkosRenderer *ar); + void akos_codec1_ignorePakCols(AkosRenderer *ar, int num); + void akos_c1_spec2(AkosRenderer *ar); + void akos_c1_spec3(AkosRenderer *ar); - int8 _userPut; - int8 _cursorState; + void akos_c1_0_decode(AkosRenderer *ar); + void akos_c1_12_decode(AkosRenderer *ar); + void akos_c1_12y_decode(AkosRenderer *ar); + void akos_c1_3_decode(AkosRenderer *ar); + void akos_c1_4_decode(AkosRenderer *ar); + void akos_c1_4y_decode(AkosRenderer *ar); + void akos_c1_56_decode(AkosRenderer *ar); + void akos_c1_56y_decode(AkosRenderer *ar); + void akos_c1_7_decode(AkosRenderer *ar); - byte _sfxMode; + bool akos_increaseAnims(byte *akos, Actor *a); + bool akos_increaseAnim(Actor *a, int i, byte *aksq, uint16 *akfo, int numakfo); - uint16 _mouseButStat; - byte _leftBtnPressed, _rightBtnPressed; + int getAnimVar(Actor *a, byte var); + void setAnimVar(Actor *a, byte var, int value); - int _numInMsgStack; + void akos_queCommand(byte cmd, Actor *a, int param_1, int param_2); + bool akos_compare(int a, int b, byte cmd); + void akos_decodeData(Actor *a, int frame, uint usemask); + int akos_frameToAnim(Actor *a, int frame); + bool akos_hasManyDirections(Actor *a); + int akos_findManyDirection(int16 ManyDirection, uint16 facing); - uint32 _localScriptList[NUM_LOCALSCRIPT]; - VirtScreen virtscr[4]; - uint32 _ENCD_offs, _EXCD_offs; - uint32 _CLUT_offs, _EPAL_offs; - uint32 _IM00_offs; - uint32 _PALS_offs; + /* Should be in Costume class */ + void loadCostume(LoadedCostume *lc, int costume); + void cost_setPalette(CostumeRenderer *cr, byte *palette); + void cost_setFacing(CostumeRenderer *cr, Actor *a); + void cost_setCostume(CostumeRenderer *cr, int costume); + byte cost_increaseAnims(LoadedCostume *lc, Actor *a); + byte cost_increaseAnim(LoadedCostume *lc, Actor *a, int slot); + void cost_decodeData(Actor *a, int frame, uint usemask); + int cost_frameToAnim(Actor *a, int frame); + + + /* Should be in Verb class */ + uint16 _verbMouseOver; + void redrawVerbs(); + void checkExecVerbs(); + void verbMouseOver(int verb); + int checkMouseOver(int x, int y); + void drawVerb(int verb, int mode); + void runInputScript(int a, int cmd, int mode); + void restoreVerbBG(int verb); + void drawVerbBitmap(int vrb, int x, int y); + int getVerbEntrypoint(int obj, int entry); + int getVerbSlot(int id, int mode); + void killVerb(int slot); + void runVerbCode(int script, int entry, int a, int b, int16 *vars); + void setVerbObject(uint room, uint object, uint verb); - uint32 _allocatedSize; + /* Should be in Sound class */ + MixerChannel _mixer_channel[NUM_MIXER]; + int _gameTempo, _midi_driver; + byte _sfxMode; + int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx; + int _saveSound; + void *_sfxFile; + uint16 _soundParam,_soundParam2,_soundParam3; uint32 _talk_sound_a, _talk_sound_b; byte _talk_sound_mode; + bool _mouthSyncMode; + bool _endOfMouthSync; + uint16 _mouthSyncTimes[52]; + uint _curSoundPos; + int current_cd_sound; - int _drawObjectQueNr; - byte _drawObjectQue[200]; + int16 _soundQuePos, _soundQue[0x100]; + byte _soundQue2Pos, _soundQue2[10]; + bool _soundsPaused, _soundsPaused2; - uint16 _currentDrive; - uint16 _soundCardType; - byte _mousePresent; + void setupSound(); + void processSoundQues(); + void playSound(int sound); + void stopAllSounds(); + void stopSound(int sound); + bool isSoundInQueue(int sound); + void clearSoundQue(); + void talkSound(uint32 a, uint32 b, int mode); + void processSfxQueues(); + void startTalkSound(uint32 a, uint32 b, int mode); + void stopTalkSound(); + bool isMouthSyncOff(uint pos); + void startSfxSound(void *file, int size); + void *openSfxFile(); + void addSoundToQueue(int sound); + void addSoundToQueue2(int sound); + void soundKludge(int16 *list); + OffsetTable *offset_table; // SO3 MP3 compressed audio + int num_sound_effects; // SO3 MP3 compressed audio - int16 _palManipStart; - int16 _palManipEnd; - int16 _palManipCounter; + void pauseSounds(bool pause); + MixerChannel *allocateMixer(); + bool isSfxFinished(); + void playSfxSound(void *sound, uint32 size, uint rate); + void playSfxSound_MP3(void *sound, uint32 size); + void stopSfxSound(); + void mixWaves(int16 *sounds, int len); - int16 _sound_volume_master; - int16 _sound_volume_music; - int16 _sound_volume_sfx; + bool _useTalkAnims; + uint16 _defaultTalkDelay; + byte _haveMsg; + int isSoundRunning(int a); - struct { - byte mode[rtNumTypes]; - uint16 num[rtNumTypes]; - uint32 tags[rtNumTypes]; - const char *name[rtNumTypes]; - byte **address[rtNumTypes]; - byte *flags[rtNumTypes]; - byte *roomno[rtNumTypes]; - uint32 *roomoffs[rtNumTypes]; - } res; - struct { - uint32 cutScenePtr[5]; - byte cutSceneScript[5]; - int16 cutSceneData[5]; - int16 cutSceneScriptIndex; - byte cutSceneStackPointer; - ScriptSlot slot[NUM_SCRIPT_SLOT]; - NestedScript nest[15]; - int16 localvar[NUM_SCRIPT_SLOT][17]; - } vm; + /* Should be in Actor class */ + Actor *derefActor(int id) {return &actor[id];} + Actor *derefActorSafe(int id, const char *errmsg); + Actor *getFirstActor() {return actor;} + void putActor(Actor *a, int x, int y, byte room); + void hideActor(Actor *a); + void showActor(Actor *a); + void showActors(); - struct { - int16 x,y; - } mouse; + void initActor(Actor *a, int mode); + void setActorWalkSpeed(Actor *a, uint speed1, uint speed2); + int calcMovementFactor(Actor *a, int newx, int newy); + int actorWalkStep(Actor *a); + int remapDirection(Actor *a, int dir); + void setupActorScale(Actor *a); + void stopActorMoving(Actor *a); + uint32 *_classData; + void startWalkAnim(Actor *a, int cmd, int angle); + void startAnimActor(Actor *a, int frame); + void setActorBox(Actor *a, int box); - Actor actor[MAX_ACTORS]; + int newDirToOldDir(int dir); + int oldDirToNewDir(int dir); - uint32 gfxUsageBits[200]; + static int normalizeAngle(int angle); + int getAngleFromPos(int x, int y); + static int fromSimpleDir(int dirtype, int dir); + static int toSimpleDir(int dirtype, int dir); + static int numSimpleDirDirections(int dirType); + int updateActorDirection(Actor *a); + void startAnimActorEx(Actor *a, int frame, int direction); + int getProgrDirChange(Actor *a, int mode); + void initActorCostumeData(Actor *a); + void fixActorDirection(Actor *a, int direction); - CharsetRenderer charset; + int getActorXYPos(Actor *a); + void adjustActorPos(Actor *a); + void turnToDirection(Actor *a, int newdir); + AdjustBoxResult adjustXYToBeInBox(Actor *a, int x, int y, int pathfrom); + void walkActors(); + void playActorSounds(); + void walkActor(Actor *a); + void setActorRedrawFlags(); + void resetActorBgs(); + void processActors(); + void drawActorCostume(Actor *a); + void actorAnimate(Actor *a); + int getActorFromPos(int x, int y); + void setActorCostume(Actor *a, int c); + byte *getActorName(Actor *a); + void faceActorToObj(int act, int obj); + void animateActor(int act, int anim); + void actorFollowCamera(int act); + void startWalkActor(Actor *a, int x, int y, int dir); - byte _charsetData[10][16]; + void remapActor(Actor *a, int b, int c, int d, int e); + void walkActorOld(Actor *a); + bool isCostumeInUse(int i); - byte _resourceMapper[128]; + /* Actor talking stuff */ + byte _actorToPrintStrFor; + int _sentenceNum; + SentenceTab sentence[6]; + StringTab string[6]; + void actorTalk(); + void stopTalk(); - uint16 _extraBoxFlags[65]; - byte **_lastCodePtr; - byte *_shadowPalette; - int _shadowPaletteSize; - -// int _numSoundTags; -// byte *_soundTagTable; - int16 _bootParam; + /* Should be in Graphics class? */ + uint16 _screenB, _screenH; + int _scrHeight, _scrWidth; + VirtScreen virtscr[4]; // Virtual screen areas + CameraData camera; // 'Camera' - viewport + ColorCycle _colorCycle[16]; // Palette cycles - uint32 _fileOffset; + uint32 _ENCD_offs, _EXCD_offs; + uint32 _CLUT_offs, _EPAL_offs; + uint32 _IM00_offs, _PALS_offs; - byte _fileReadFailed; - byte _fileMode; + bool _fullScreen, _fullRedraw, _BgNeedsRedraw, _shakeEnabled; + bool _screenEffectFlag, _completeScreenRedraw; - uint32 _whereInResToRead; + int _cursorHotspotX, _cursorHotspotY, _cursorWidth, _cursorHeight; + byte _cursorAnimate, _cursorAnimateIndex, _grabbedCursor[2048]; + int8 _cursorState; - CameraData camera; + byte _newEffect, _switchRoomEffect2, _switchRoomEffect; + bool _doEffect; - int _resultVarNumber; + void getGraphicsPerformance(); + void initScreens(int a, int b, int w, int h); + void initVirtScreen(int slot, int top, int height, bool twobufs, bool fourextra); + void initBGBuffers(); + void initCycl(byte *ptr); // Color cycle - int _sentenceNum; - SentenceTab sentence[6]; + void drawObject(int obj, int arg); + void drawRoomObjects(int arg); + void drawRoomObject(int i, int arg); + void drawMouse(); + void drawBox(int x, int y, int x2, int y2, int color); + void drawBomp(BompDrawData *bd); - StringTab string[6]; + void restoreBG(int left, int top, int right, int bottom); + void redrawBGStrip(int start, int num); + void redrawBGAreas(); + void redrawLines(int from, int to); + + void moveCamera(); + void cameraMoved(); + void setCameraAtEx(int at); + void setCameraAt(int pos_x, int pos_y); + void panCameraTo(int x, int y); + void setCameraFollows(Actor *a); + void clampCameraPos(ScummPoint *pt); - uint16 _mouthSyncTimes[52]; + byte *getPalettePtr(); + void setPalette(int pal); + void setPaletteFromPtr(byte *ptr); + void setPaletteFromRes(); + void setPalColor(int index, int r, int g, int b); + void setDirtyColors(int min, int max); + byte *findPalInPals(byte *pal, int index); + void swapPalColors(int a, int b); + void cyclePalette(); + void stopCycle(int i); + void palManipulate(); + int remapPaletteColor(int r, int g, int b, uint threshold); + void moveMemInPalRes(int start, int end, byte direction); + void setupShadowPalette(int slot,int rfact,int gfact,int bfact,int from,int to); + void darkenPalette(int a, int b, int c, int d, int e); - int16 _soundQuePos; - int16 _soundQue[0x100]; + void setShake(int mode); - uint16 _enqueue_b,_enqueue_c,_enqueue_d,_enqueue_e; + void setCursor(int cursor); + void setCursorImg(uint img, uint room, uint imgindex); + void setCursorHotspot2(int x,int y); + void grabCursor(int x, int y, int w, int h); + void grabCursor(byte *ptr, int width, int height); + void makeCursorColorTransparent(int a); + void setupCursor() { _cursorAnimate = 1; } + void decompressDefaultCursor(int index); + void useIm01Cursor(byte *im, int w, int h); + void useBompCursor(byte *im, int w, int h); - int _enqueuePos; - EnqueuedObject _enqueuedObjects[32]; - byte _soundQue2Pos; - byte _soundQue2[10]; + void updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits); + void setDirtyRange(int slot, int a, int height); + void drawDirtyScreenParts(); + void updateDirtyScreen(int slot); - int16 _vararg_temp_pos[16]; + VirtScreen *findVirtScreen(int y); + void unkVirtScreen4(int a); + static void setVirtscreenDirty(VirtScreen *vs, int left, int top, int right, int bottom); - uint16 _curExecScript; + void screenEffect(int effect); + void unkScreenEffect1(); + void unkScreenEffect2(); + void unkScreenEffect3(); + void unkScreenEffect4(); + void unkScreenEffect5(int a); + void unkScreenEffect6(); + void unkScreenEffect7(int a); - int _scrWidth; - int _scrHeight; + void decompressBomp(byte *dst, byte *src, int w, int h); + int _videoMode; + uint _shakeFrame; + int _screenStartStrip, _screenEndStrip; + int _screenLeft, _screenTop; + unsigned int _scale; // Resolution multiplier (2 is default) + uint16 _enqueue_b,_enqueue_c,_enqueue_d,_enqueue_e; + int _enqueuePos; + EnqueuedObject _enqueuedObjects[32]; - byte _currentPalette[0x300]; + void enqueueObject(int a, int b, int c, int d, int e, int f, int g, int h, int mode); + void clearEnqueue() { _enqueuePos = 0; } + void drawEnqueuedObjects(); + void drawEnqueuedObject(EnqueuedObject *eo); + void removeEnqueuedObjects(); + void removeEnqueuedObject(EnqueuedObject *eo); + int _drawObjectQueNr; + byte _drawObjectQue[200]; + int16 _palManipStart, _palManipEnd, _palManipCounter; + uint32 gfxUsageBits[200]; + byte *_shadowPalette; + int _shadowPaletteSize; + byte _currentPalette[0x300]; int _palDirtyMin, _palDirtyMax; + byte _bkColor; + uint16 _lastXstart; - uint _curSoundPos; - - ColorCycle _colorCycle[16]; - - Gdi gdi; - bool _BgNeedsRedraw; - int16 _localParamList[16]; - uint16 _verbMouseOver; - - int16 _foundPathX; - int16 _foundPathY; - - uint16 _lastKeyHit; - - int _scummStackPos; - int16 _scummStack[150]; + /* Walkbox / Navigation class */ int _maxBoxVertexHeap; byte *_boxMatrixPtr4, *_boxMatrixPtr1, *_boxMatrixPtr3; int _boxPathVertexHeapIndex; int _boxMatrixItem; - byte _grabbedCursor[2048]; - - char _saveLoadName[32]; + gate_location p[5]; + int gate1ax, gate1ay, gate1bx, gate1by, gate2ax, gate2ay, gate2bx, gate2by; + uint16 _extraBoxFlags[65]; + int16 _foundPathX, _foundPathY; + int CloX[8], CloY[8]; - MixerChannel _mixer_channel[NUM_MIXER]; + PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node); + PathNode *unkMatrixProc2(PathVertex *vtx, int i); + bool areBoxesNeighbours(int i, int j); + void addToBoxMatrix(byte b); + int CompareSlope(int X1,int Y1,int X2,int Y2,int X3,int Y3); + void SetGate(int line1,int line2, int polyx[8], int polyy[8]); + void *addToBoxVertexHeap(int size); + PathVertex *addPathVertex(); + bool checkXYInBoxBounds(int box, int x, int y); + uint distanceFromPt(int x, int y, int ptx, int pty); + ScummPoint closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y); + bool getSideOfLine(int x1,int y1, int x2, int y2, int x, int y, int box); + void getBoxCoordinates(int boxnum, BoxCoords *bc); + byte getMaskFromBox(int box); + Box *getBoxBaseAddr(int box); + byte getBoxFlags(int box); + int getBoxScale(int box); + byte getNumBoxes(); + byte *getBoxMatrixBaseAddr(); + int getPathToDestBox(byte from, byte to); + int findPathTowards(Actor *a, byte box, byte box2, byte box3); + int findPathTowardsOld(Actor *a, byte box, byte box2, byte box3); + void GetGates(int trap1,int trap2); + bool inBoxQuickReject(int box, int x, int y, int threshold); + AdjustBoxResult getClosestPtOnBox(int box, int x, int y); + + void setBoxFlags(int box, int val); + void setBoxScale(int box, int b); + void createBoxMatrix(); - OpcodeProc getOpcode(int i) { return _opcodes[i]; } -#ifdef COMPRESSED_SOUND_FILE - OffsetTable *offset_table; - int num_sound_effects; -#endif - int current_cd_sound; + /* String class */ + CharsetRenderer charset; + byte _charsetColor; + uint16 _noSubtitles; // Skip all subtitles? + byte _charsetData[10][16]; + void initCharset(int charset); + void restoreCharsetBg(); + int hasCharsetMask(int x, int y, int x2, int y2); + void CHARSET_1(); + byte *_msgPtrToAdd; + byte *addMessageToStack(byte *msg); + void unkAddMsgToStack2(int var); + void unkAddMsgToStack3(int var); + void unkAddMsgToStack4(int var); + void unkAddMsgToStack5(int var); + void unkMessage1(); + void unkMessage2(); + void clearMsgQueue(); + int _numInMsgStack; + byte *_messagePtr; + int16 _talkDelay; + bool _keepText; - void openRoom(int room); - void deleteRoomOffsets(); - void readRoomsOffsets(); - void askForDisk(const char *filename); - bool openResourceFile(const char *filename); - + /* Should be in System class */ + byte _fileMode; + uint32 _whereInResToRead; void fileClose(void *file); void *fileOpen(const char *filename, int mode); void fileSeek(void *file, long offs, int whence); void fileRead(void *handle, void *ptr, uint32 size); bool fileEof(void *handle); uint32 filePos(void *handle); + bool checkFixedDisk(); int fileReadByte(); uint32 fileReadDwordLE(); @@ -1252,116 +1636,7 @@ struct Scumm { static byte *alloc(int size); static void free(void *mem); - void readResTypeList(int id, uint32 tag, const char *name); - void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode); - - void initRandSeeds(); - - uint getRandomNumber(uint max); - uint getRandomNumberRng(uint min, uint max); - - void loadCharset(int i); - void nukeCharset(int i); - void initScreens(int a, int b, int w, int h); - - void setShake(int mode); - void setCursor(int cursor); - - void clearDrawObjectQueue(); - - byte *createResource(int type, int index, uint32 size); - - void initScummVars(); - void getGraphicsPerformance(); - - void nukeResource(int type, int i); - byte *getResourceAddress(int type, int i); - byte *getStringAddress(int i); - void ensureResourceLoaded(int type, int i); - int loadResource(int type, int i); - int getResourceRoomNr(int type, int index); - int readSoundResource(int type, int index); - void setResourceCounter(int type, int index, byte flag); - void validateResource(const char *str, int type, int index); - - void initVirtScreen(int slot, int top, int height, bool twobufs, bool fourextra); - void setDirtyRange(int slot, int a, int height); - void drawDirtyScreenParts(); - void updateDirtyScreen(int slot); - void unkVirtScreen4(int a); - - void restoreMouse(); - void initActor(Actor *a, int mode); - bool checkFixedDisk(); - - void setActorWalkSpeed(Actor *a, uint speed1, uint speed2); - int calcMovementFactor(Actor *a, int newx, int newy); - int actorWalkStep(Actor *a); - int remapDirection(Actor *a, int dir); - - bool checkXYInBoxBounds(int box, int x, int y); - void setupActorScale(Actor *a); - - void checkRange(int max, int min, int no, const char *str); - - bool fileReadFailed(void *handle); - void clearFileReadFailed(void *handle); - - bool getClass(int obj, int cls); - void putClass(int obj, int cls, bool set); - int getState(int obj); - void putState(int obj, int state); - int getOwner(int obj); - void putOwner(int obj, int owner); - int getObjectRoom(int obj); - void SamInventoryHack(int obj); // FIXME: Sam and Max hack - - void main(); - - uint distanceFromPt(int x, int y, int ptx, int pty); - ScummPoint closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y); - bool getSideOfLine(int x1,int y1, int x2, int y2, int x, int y, int box); - void getBoxCoordinates(int boxnum, BoxCoords *bc); - byte getMaskFromBox(int box); - Box *getBoxBaseAddr(int box); - byte getBoxFlags(int box); - int getBoxScale(int box); - byte getNumBoxes(); - byte *getBoxMatrixBaseAddr(); - -// void startAnimActor(Actor *a, int frame); - void startAnimActor(Actor *a, int frame); - void startAnimActorEx(Actor *a, int frame, int direction); -// void startAnimActor(Actor *a, int frame, byte direction); - int getProgrDirChange(Actor *a, int mode); - void initActorCostumeData(Actor *a); - void fixActorDirection(Actor *a, int direction); - void cpst_decodeData(Actor *a, int frame, uint mask); - - void scummInit(); - void scummMain(int argc, char **argv); - - void runScript(int script, int a, int b, int16 *lvarptr); - void stopScriptNr(int script); - int getScriptSlot(); - void runScriptNested(int script); - void updateScriptPtr(); - void getScriptBaseAddress(); - void getScriptEntryPoint(); - void executeScript(); - byte fetchScriptByte(); - int fetchScriptWord(); - void ignoreScriptWord() { fetchScriptWord(); } - void ignoreScriptByte() { fetchScriptByte(); } - uint getVarOrDirectWord(byte mask); - uint getVarOrDirectByte(byte mask); - int readVar(uint var); - void writeVar(uint var, int value); - void getResultPos(); - void setResult(int result); - - int getObjectIndex(int object); - + /* Version 5 script opcodes */ void o5_actorFollowCamera(); void o5_actorFromPos(); void o5_actorSet(); @@ -1463,9 +1738,14 @@ struct Scumm { void o5_walkActorTo(); void o5_walkActorToActor(); void o5_walkActorToObject(); - void o5_oldRoomEffect(); + void o5_oldRoomEffect(); void o5_pickupObjectOld(); - + + /* Version 6 script opcodes */ + int getStackList(int16 *args, uint maxnum); + void setStringVars(int i); + void unkMiscOp9(); + void o6_bompWindow(); void o6_pushByte(); void o6_pushWord(); @@ -1615,456 +1895,8 @@ struct Scumm { void o6_getAnimateVariable(); void o6_drawBlastObject(); - int popRoomAndObj(int *room); - - void soundKludge(int16 *list); - - void stopObjectCode(); - void stopObjectScript(int script); - void putActor(Actor *a, int x, int y, byte room); - void clearMsgQueue(); - void adjustActorPos(Actor *a); - - void hideActor(Actor *a); - void showActor(Actor *a); - void showActors(); - void turnToDirection(Actor *a, int newdir); - - int whereIsObject(int object); - int getObjectOrActorXY(int object); - void addSoundToQueue(int sound); - void addSoundToQueue2(int sound); - bool isScriptInUse(int script); - int getActorXYPos(Actor *a); - void getObjectXYPos(int object); - AdjustBoxResult adjustXYToBeInBox(Actor *a, int x, int y, int pathfrom); - - int getWordVararg(int16 *ptr); - - int getObjActToObjActDist(int a, int b); - void processSoundQues(); - bool inBoxQuickReject(int box, int x, int y, int threshold); - AdjustBoxResult getClosestPtOnBox(int box, int x, int y); - - void setCameraAt(int pos_x, int pos_y); - void stopTalk(); - void restoreCharsetBg(); - - void setCameraFollows(Actor *a); - void runHook(int i); - void startScene(int room, Actor *a, int b); - - void freezeScripts(int scr); - void unfreezeScripts(); - - void runAllScripts(); - - int findObject(int x, int y); - void stopCycle(int i); - void killScriptsAndResources(); - void runExitScript(); - void runEntryScript(); - - void increaseResourceCounter(); - bool isResourceInUse(int type, int i); - void initRoomSubBlocks(); - void loadRoomObjects(); - void loadRoomObjectsSmall(); - - void setPaletteFromRes(); - void initCycl(byte *ptr); - void initBGBuffers(); - void setDirtyColors(int min, int max); - - void setScaleItem(int slot, int a, int b, int c, int d); - - void cyclePalette(); - - void moveMemInPalRes(int start, int end, byte direction); - - void redrawBGAreas(); - void drawRoomObjects(int arg); - void drawRoomObject(int i, int arg); - void redrawBGStrip(int start, int num); - void drawObject(int obj, int arg); - - int hasCharsetMask(int x, int y, int x2, int y2); - - void restoreBG(int left, int top, int right, int bottom); - void updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits); - VirtScreen *findVirtScreen(int y); - - void unkScreenEffect1(); - void unkScreenEffect2(); - void unkScreenEffect3(); - void unkScreenEffect4(); - void unkScreenEffect5(int a); - void unkScreenEffect6(); - void unkScreenEffect7(int a); - - void playSound(int sound); - - void decreaseScriptDelay(int amount); - void processKbd(); - - void redrawVerbs(); - void checkExecVerbs(); - void checkAndRunVar33(); - void CHARSET_1(); - void walkActors(); - void moveCamera(); - void fixObjectFlags(); - void clear_fullRedraw(); - void palManipulate(); - void screenEffect(int effect); - void clearClickedStatus(); - void verbMouseOver(int verb); - int checkMouseOver(int x, int y); - void playActorSounds(); - void processDrawQue(); - void setActorRedrawFlags(); - void resetActorBgs(); - void processActors(); - void drawVerb(int verb, int mode); - - void runInputScript(int a, int cmd, int mode); - - void cameraMoved(); - - void walkActor(Actor *a); - - int checkKeyHit(); - - int getPathToDestBox(byte from, byte to); - int findPathTowards(Actor *a, byte box, byte box2, byte box3); - int findPathTowardsOld(Actor *a, byte box, byte box2, byte box3); - - void drawActorCostume(Actor *a); - void actorAnimate(Actor *a); - - int getActorFromPos(int x, int y); - - void restoreVerbBG(int verb); - - void drawString(int a); - void drawVerbBitmap(int vrb, int x, int y); - - void setActorCostume(Actor *a, int c); - void loadPtrToResource(int type, int i, byte *ptr); - - void push(int a); - int pop(); - - void walkActorTo(Actor *a, int x, int y, int direction); - - void setCursorImg(uint img, uint room, uint imgindex); -// void setCursorHotspot(int cursor, int x, int y); - void initCharset(int charset); - void addObjectToDrawQue(int object); - int getVerbEntrypoint(int obj, int entry); - int isSoundRunning(int a); - void startWalkActor(Actor *a, int x, int y, int dir); - void setBoxFlags(int box, int val); - void setBoxScale(int box, int b); - void createBoxMatrix(); - void addObjectToInventory(uint obj, uint room); - void removeObjectFromRoom(int obj); - void decodeParseString(); - void pauseGame(bool user); - void setOptions(void); - void shutDown(int i); - void lock(int type, int i); - void unlock(int type, int i); - void heapClear(int mode); - void unkHeapProc2(int a, int b); - void loadFlObject(uint object, uint room); - void setPalColor(int index, int r, int g, int b); - void darkenPalette(int a, int b, int c, int d, int e); - void unkRoomFunc3(int a, int b, int c, int d, int e); - void unkRoomFunc4(int a, int b, int c, int d, int e); - int getVerbSlot(int id, int mode); - void killVerb(int slot); - byte *getOBCDFromObject(int obj); - byte *getObjOrActorName(int obj); - void clearOwnerOf(int obj); - void runVerbCode(int script, int entry, int a, int b, int16 *vars); - void setVerbObject(uint room, uint object, uint verb); - void unkMessage1(); - void unkMessage2(); - void actorTalk(); - - byte *addMessageToStack(byte *msg); - - void unkAddMsgToStack2(int var); - void unkAddMsgToStack3(int var); - void unkAddMsgToStack4(int var); - void unkAddMsgToStack5(int var); - - byte *getActorName(Actor *a); - uint32 getOBCDOffs(int object); - - byte isMaskActiveAt(int l, int t, int r, int b, byte *mem); - - int getInventorySlot(); - - - int getKeyInput(int a); - void convertKeysToClicks(); - - void drawBox(int x, int y, int x2, int y2, int color); - - void drawMouse(); - - void dumpResource(char *tag, int index, byte *ptr); - - bool saveState(int slot, bool compat); - bool loadState(int slot, bool compat); - void saveOrLoad(Serializer *s); - - void saveLoadResource(Serializer *ser, int type, int index); - bool isResourceLoaded(int type, int index); - - - Actor *derefActor(int id) { return &actor[id]; } - Actor *derefActorSafe(int id, const char *errmsg); - Actor *getFirstActor() { return actor; } - - PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node); - PathNode *unkMatrixProc2(PathVertex *vtx, int i); - bool areBoxesNeighbours(int i, int j); - void addToBoxMatrix(byte b); - PathVertex *addPathVertex(); - void *addToBoxVertexHeap(int size); - - void parseCommandLine(int argc, char **argv); - - void showHelpAndExit(); - - char *getGameName(); - bool detectGame(); - - void setupOpcodes(); - void setupOpcodes2(); - void endCutscene(); - void cutscene(int16 *args); - - void setOwnerOf(int obj, int owner); - void panCameraTo(int x, int y); - void actorFollowCamera(int act); - void setCameraAtEx(int at); - - void clampCameraPos(ScummPoint *pt); - - void setCursorHotspot2(int x,int y); - - void makeCursorColorTransparent(int a); - - void faceActorToObj(int act, int obj); - void animateActor(int act, int anim); - bool isScriptRunning(int script); - bool isRoomScriptRunning(int script); - int getObjX(int obj); - int getObjY(int obj); - int getObjOldDir(int obj); - int getObjNewDir(int obj); - int findInventory(int owner, int index); - int getInventoryCount(int owner); - - void beginOverride(); - void endOverride(); - - void setPalette(int pal); - void setPaletteFromPtr(byte *ptr); - byte *findPalInPals(byte *pal, int index); - - int getStringLen(byte *ptr); - - void readArrayFromIndexFile(); - void readMAXS(); - void readIndexFile(); - void readIndexFileSmall(); - - int readArray(int array, int index, int base); - void writeArray(int array, int index, int base, int value); - - int getStackList(int16 *args, uint maxnum); - void setObjectState(int obj, int state, int x, int y); - - void setStringVars(int i); - void decodeParseString2(int a, int b); - - void arrayop_1(int a, byte *ptr); - - void copyString(byte *dst, byte *src, int len); - int getArrayId(); - - void nukeArray(int a); - int defineArray(int a, int b, int c, int d); - int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f); - void grabCursor(int x, int y, int w, int h); - void unkMiscOp9(); - void startManiac(); - - void grabCursor(byte *ptr, int width, int height); - byte *getPalettePtr(); - void setupSound(); - void stopAllSounds(); - void stopSound(int sound); - bool isSoundInQueue(int sound); - void clearSoundQue(); - void talkSound(uint32 a, uint32 b, int mode); - void processSfxQueues(); - void startTalkSound(uint32 a, uint32 b, int mode); - void stopTalkSound(); - bool isMouthSyncOff(uint pos); - void startSfxSound(void *file, int size); - void *openSfxFile(); - void resourceStats(); - bool isCostumeInUse(int i); - void expireResources(uint32 size); - - void freeResources(); - void destroy(); - - void useIm01Cursor(byte *im, int w, int h); - void useBompCursor(byte *im, int w, int h); - - void decompressBomp(byte *dst, byte *src, int w, int h); - - void setupCursor() { _cursorAnimate = 1; } - - void decompressDefaultCursor(int index); - - void allocateArrays(); - - void initializeLocals(int slot, int16 *vars); - - static void setVirtscreenDirty(VirtScreen *vs, int left, int top, int right, int bottom); - int scummLoop(int delta); - - bool getSavegameName(int slot, char *desc); - void makeSavegameName(char *out, int slot, bool compatible); - - void exitCutscene(); - void nukeFlObjects(int min, int max); - - void swapPalColors(int a, int b); - - void enqueueObject(int a, int b, int c, int d, int e, int f, int g, int h, int mode); - - void clearEnqueue() { _enqueuePos = 0; } - void drawEnqueuedObjects(); - void drawEnqueuedObject(EnqueuedObject *eo); - void removeEnqueuedObjects(); - void removeEnqueuedObject(EnqueuedObject *eo); - - void pauseSounds(bool pause); - - MixerChannel *allocateMixer(); - bool isSfxFinished(); - void playSfxSound(void *sound, uint32 size, uint rate); -#ifdef COMPRESSED_SOUND_FILE - void playSfxSound_MP3(void *sound, uint32 size); -#endif - void stopSfxSound(); - - void mixWaves(int16 *sounds, int len); - - struct FindObjectInRoom { - CodeHeader *cdhd; - byte *obcd; - ImageHeader *imhd; - byte *obim; - byte *roomptr; - }; - - enum FindObjectWhat { - foCodeHeader = 1, - foImageHeader = 2, - foCheckAlreadyLoaded = 4 - }; - - void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room); - void setupRoomObject(ObjectData *od, byte *room); - int findFlObjectSlot(); - - void runTalkScript(int frame); - - int remapPaletteColor(int r, int g, int b, uint threshold); - void remapActor(Actor *a, int b, int c, int d, int e); - - byte *findResourceData(uint32 tag, byte *ptr); - int getResourceDataSize(byte *ptr); - - void akos_decodeData(Actor *a, int frame, uint usemask); - int akos_frameToAnim(Actor *a, int frame); - bool akos_hasManyDirections(Actor *a); - void stopActorMoving(Actor *a); - - int newDirToOldDir(int dir); - int oldDirToNewDir(int dir); - void startWalkAnim(Actor *a, int cmd, int angle); - void setActorBox(Actor *a, int box); - int getAngleFromPos(int x, int y); - int updateActorDirection(Actor *a); - - bool akos_drawCostume(AkosRenderer *ar); - void akos_setPalette(AkosRenderer *ar, byte *palette); - void akos_setCostume(AkosRenderer *ar, int costume); - void akos_setFacing(AkosRenderer *ar, Actor *a); - bool akos_drawCostumeChannel(AkosRenderer *ar, int chan); - void akos_codec1(AkosRenderer *ar); - void akos_codec5(AkosRenderer *ar); - void akos_codec16(AkosRenderer *ar); - void akos_codec1_ignorePakCols(AkosRenderer *ar, int num); - void akos_c1_spec2(AkosRenderer *ar); - void akos_c1_spec3(AkosRenderer *ar); - - void akos_c1_0_decode(AkosRenderer *ar); - void akos_c1_12_decode(AkosRenderer *ar); - void akos_c1_12y_decode(AkosRenderer *ar); - void akos_c1_3_decode(AkosRenderer *ar); - void akos_c1_4_decode(AkosRenderer *ar); - void akos_c1_4y_decode(AkosRenderer *ar); - void akos_c1_56_decode(AkosRenderer *ar); - void akos_c1_56y_decode(AkosRenderer *ar); - void akos_c1_7_decode(AkosRenderer *ar); - - bool akos_increaseAnims(byte *akos, Actor *a); - bool akos_increaseAnim(Actor *a, int i, byte *aksq, uint16 *akfo, int numakfo); - - int getAnimVar(Actor *a, byte var); - void setAnimVar(Actor *a, byte var, int value); - - void akos_queCommand(byte cmd, Actor *a, int param_1, int param_2); - bool akos_compare(int a, int b, byte cmd); - - static int normalizeAngle(int angle); - static int fromSimpleDir(int dirtype, int dir); - static int toSimpleDir(int dirtype, int dir); - static int numSimpleDirDirections(int dirType); - - void doSentence(int c, int b, int a); - int cost_frameToAnim(Actor *a, int frame); - - void setupShadowPalette(int slot,int rfact,int gfact,int bfact,int from,int to); - - void drawBomp(BompDrawData *bd); - void loadCostume(LoadedCostume *lc, int costume); - - void cost_setPalette(CostumeRenderer *cr, byte *palette); - void cost_setFacing(CostumeRenderer *cr, Actor *a); - void cost_setCostume(CostumeRenderer *cr, int costume); - byte cost_increaseAnims(LoadedCostume *lc, Actor *a); - byte cost_increaseAnim(LoadedCostume *lc, Actor *a, int slot); - void cost_decodeData(Actor *a, int frame, uint usemask); - - void redrawLines(int from, int to); - - void setupScummVarsOld(); - void setupScummVarsNew(); - - byte VAR_EGO; + /* Scumm Vars */ + byte VAR_EGO; byte VAR_CAMERA_POS_X; byte VAR_HAVE_MSG; byte VAR_ROOM; @@ -2164,31 +1996,11 @@ struct Scumm { byte VAR_UNK_SCRIPT; byte VAR_UNK_SCRIPT_2; - void GetGates(int trap1,int trap2); - byte VAR_DEFAULT_TALK_DELAY; byte VAR_CHARSET_MASK; - - int NUM_ACTORS; - - byte _videoPath[50]; - - gate_location p[5]; - - int CompareSlope(int X1,int Y1,int X2,int Y2,int X3,int Y3); - void SetGate(int line1,int line2, int polyx[8], int polyy[8]); - - int gate1ax, gate1ay; - int gate1bx, gate1by; - int gate2ax, gate2ay; - int gate2bx, gate2by; - - int CloX[8]; - int CloY[8]; - - void walkActorOld(Actor *a); }; + enum AkosOpcodes{ AKC_Return = 0xC001, AKC_SetVar = 0xC010, diff --git a/scummvm.cpp b/scummvm.cpp index 1f3577d3b0..37aba0e60f 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/sound/adlib.cpp b/sound/adlib.cpp index faa3dd371e..5b54aa40b7 100644 --- a/sound/adlib.cpp +++ b/sound/adlib.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001 The ScummVM project + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/sound/gmidi.cpp b/sound/gmidi.cpp index 397a457fb2..957a999e52 100644 --- a/sound/gmidi.cpp +++ b/sound/gmidi.cpp @@ -1,5 +1,6 @@ - /* ScummVM - Scumm Interpreter - * Copyright (C) 2001 The ScummVM project +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/sound/imuse.cpp b/sound/imuse.cpp index d717841e8a..f62afb984c 100644 --- a/sound/imuse.cpp +++ b/sound/imuse.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001 The ScummVM project + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/stdafx.cpp b/stdafx.cpp index fb2b30bab7..fd4f341c7b 100644 --- a/stdafx.cpp +++ b/stdafx.cpp @@ -1,8 +1 @@ -// stdafx.cpp : source file that includes just the standard includes -// scummvm.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - #include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/string.cpp b/string.cpp index 2ea2d0e947..4151cbfc11 100644 --- a/string.cpp +++ b/string.cpp @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1,3 +1,26 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + + #include "stdafx.h" #include "scumm.h" @@ -1,5 +1,6 @@ /* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License |