diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge/bitmap.cpp | 7 | ||||
-rw-r--r-- | engines/cge/btfile.cpp | 208 | ||||
-rw-r--r-- | engines/cge/btfile.h | 99 | ||||
-rw-r--r-- | engines/cge/cfile.cpp | 3 | ||||
-rw-r--r-- | engines/cge/config.cpp | 322 | ||||
-rw-r--r-- | engines/cge/config.h | 37 | ||||
-rw-r--r-- | engines/cge/module.mk | 2 | ||||
-rw-r--r-- | engines/cge/talk.h | 2 | ||||
-rw-r--r-- | engines/cge/vga13h.h | 2 | ||||
-rw-r--r-- | engines/cge/vol.cpp | 3 | ||||
-rw-r--r-- | engines/cge/vol.h | 2 |
11 files changed, 679 insertions, 8 deletions
diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index e9a9bbe220..5c416500d6 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -36,10 +36,11 @@ #include "cge/drop.h" #endif -#include <alloc.h> +//#include <alloc.h> +//#include <dir.h> +//#include <mem.h> #include <dos.h> -#include <dir.h> -#include <mem.h> +#include "common/system.h" namespace CGE { diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp new file mode 100644 index 0000000000..4068f323a0 --- /dev/null +++ b/engines/cge/btfile.cpp @@ -0,0 +1,208 @@ +/* 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 + */ + +#include "cge/btfile.h" +//#include <alloc.h> +#include "common/system.h" +#include <string.h> + + + +#ifdef DROP_H + #include "cge/drop.h" +#else + #include <stdio.h> + #include <stdlib.h> +#endif + +namespace CGE { + +#ifndef DROP_H + #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } +#endif + +#ifndef BT_SIZE + #define BT_SIZE K(1) +#endif + +#ifndef BT_KEYLEN + #define BT_KEYLEN 13 +#endif + + + + + +BTFILE::BTFILE (const char * name, IOMODE mode, CRYPT * crpt) +: IOHAND(name, mode, crpt) +{ + int i; + for (i = 0; i < BT_LEVELS; i ++) + { + Buff[i].Page = new BT_PAGE; + Buff[i].PgNo = BT_NONE; + Buff[i].Indx = -1; + Buff[i].Updt = FALSE; + if (Buff[i].Page == NULL) DROP("No core", NULL); + } +} + + + + + + + + + +BTFILE::~BTFILE (void) +{ + int i; + for (i = 0; i < BT_LEVELS; i ++) + { + PutPage(i); + delete Buff[i].Page; + } +} + + + + + + +void BTFILE::PutPage (int lev, bool hard) +{ + if (hard || Buff[lev].Updt) + { + Seek(Buff[lev].PgNo * sizeof(BT_PAGE)); + Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); + Buff[lev].Updt = FALSE; + } +} + + + + + + +BT_PAGE * BTFILE::GetPage (int lev, uint16 pgn) +{ + if (Buff[lev].PgNo != pgn) + { + uint32 pos = pgn * sizeof(BT_PAGE); + PutPage(lev); + Buff[lev].PgNo = pgn; + if (Size() > pos) + { + Seek((uint32) pgn * sizeof(BT_PAGE)); + Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); + Buff[lev].Updt = FALSE; + } + else + { + Buff[lev].Page->Hea.Count = 0; + Buff[lev].Page->Hea.Down = BT_NONE; + _fmemset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); + Buff[lev].Updt = TRUE; + } + Buff[lev].Indx = -1; + } + return Buff[lev].Page; +} + + + + + +BT_KEYPACK * BTFILE::Find (const uint8 * key) +{ + int lev = 0; + uint16 nxt = BT_ROOT; + while (! Error) + { + BT_PAGE * pg = GetPage(lev, nxt); + // search + if (pg->Hea.Down != BT_NONE) + { + int i; + for (i = 0; i < pg->Hea.Count; i ++) + if (_fmemicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) + break; + nxt = (i) ? pg->Inn[i-1].Down : pg->Hea.Down; + Buff[lev].Indx = i-1; + ++ lev; + } + else + { + int i; + for (i = 0; i < pg->Hea.Count-1; i ++) + if (_fstricmp(key, pg->Lea[i].Key) <= 0) + break; + Buff[lev].Indx = i; + return &pg->Lea[i]; + } + } + return NULL; +} + + + + +int keycomp (const void * k1, const void * k2) +{ + return _fmemicmp(k1, k2, BT_KEYLEN); +} + + + +void BTFILE::Make(BT_KEYPACK * keypack, uint16 count) +{ + #if BT_LEVELS != 2 + #error This tiny BTREE implementation works with exactly 2 levels! + #endif + _fqsort(keypack, count, sizeof(*keypack), keycomp); + uint16 n = 0; + BT_PAGE * Root = GetPage(0, n ++), + * Leaf = GetPage(1, n); + Root->Hea.Down = n; + PutPage(0, TRUE); + while (count --) + { + if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) + { + PutPage(1, TRUE); // save filled page + Leaf = GetPage(1, ++n); // take empty page + _fmemcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); + Root->Inn[Root->Hea.Count ++].Down = n; + Buff[0].Updt = TRUE; + } + Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++); + Buff[1].Updt = TRUE; + } +} + +} // End of namespace CGE diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h new file mode 100644 index 0000000000..0599bee72a --- /dev/null +++ b/engines/cge/btfile.h @@ -0,0 +1,99 @@ +/* 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 + */ + +#ifndef __BTFILE__ +#define __BTFILE__ + +#include "cge/general.h" + +namespace CGE { + +#define BT_SIZE K(1) +#define BT_KEYLEN 13 +#define BT_LEVELS 2 + +#define BT_NONE 0xFFFF +#define BT_ROOT 0 + + +struct BT_KEYPACK +{ + uint8 Key[BT_KEYLEN]; + uint32 Mark; + uint16 Size; +}; + + + +struct BT_PAGE +{ + struct HEA + { + uint16 Count; + uint16 Down; + } Hea; + union + { + // dummy filler to make proper size of union + uint8 Data[BT_SIZE-sizeof(HEA)]; + // inner version of data: key + word-sized page link + struct INNER + { + uint8 Key[BT_KEYLEN]; + uint16 Down; + } Inn[(BT_SIZE-sizeof(HEA))/sizeof(INNER)]; + // leaf version of data: key + all user data + BT_KEYPACK Lea[(BT_SIZE-sizeof(HEA))/sizeof(BT_KEYPACK)]; + }; +}; + + + + + +class BTFILE : public IOHAND +{ + struct + { + BT_PAGE * Page; + uint16 PgNo; + int Indx; + bool Updt; + } Buff[BT_LEVELS]; + void PutPage (int lev, bool hard = FALSE); + BT_PAGE * GetPage (int lev, uint16 pgn); +public: + BTFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL); + virtual ~BTFILE (void); + BT_KEYPACK * Find(const byte * key); + BT_KEYPACK * Next(void); + void Make(BT_KEYPACK * keypack, uint16 count); +}; + +} // End of namespace CGE + +#endif diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 499a7033ac..56383ca92e 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -29,7 +29,8 @@ #include <dos.h> #include <fcntl.h> #include <string.h> -#include <alloc.h> +//#include <alloc.h> +#include "common/system.h" #ifdef DROP_H #include "cge/drop.h" diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp new file mode 100644 index 0000000000..4add18bd43 --- /dev/null +++ b/engines/cge/config.cpp @@ -0,0 +1,322 @@ +/* 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 + */ + +#include "cge/config.h" +#include "cge/sound.h" +#include "cge/vmenu.h" +#include "cge/text.h" +#include "cge/cge_main.h" + +namespace CGE { + +/* + 51=wska§ typ posiadanej karty d¦wi‘kowej + 52=wybierz numer portu dla karty d¦wi‘kowej + 53=wybierz numer przerwania dla karty d¦wi‘kowej + 54=wybierz numer kana’u DMA dla karty d¦wi‘kowej + 55=wybierz numer portu dla General MIDI + 55=konfiguracja karty d¦wi‘kowej +*/ +#define STYPE_TEXT 51 +#define SPORT_TEXT 52 +#define SIRQ_TEXT 53 +#define SDMA_TEXT 54 +#define MPORT_TEXT 55 +#define MENU_TEXT 56 + +#define NONE_TEXT 60 +#define SB_TEXT 61 +#define SBM_TEXT 62 +#define GUS_TEXT 63 +#define GUSM_TEXT 64 +#define MIDI_TEXT 65 +#define AUTO_TEXT 66 + +#define DETECT 0xFFFF + + +void NONE (void); +void SB (void); +void SBM (void); +void GUS (void); +void GUSM (void); +void MIDI (void); +void AUTO (void); +void SetPortD (void); +void SetPortM (void); +void SetIRQ (void); +void SetDMA (void); + + +static int DevName[] = { NONE_TEXT, SB_TEXT, SBM_TEXT, + GUS_TEXT, GUSM_TEXT, + MIDI_TEXT, AUTO_TEXT }; + +static CHOICE DevMenu[]={ { NULL, NONE }, + { NULL, SB }, + { NULL, SBM }, + { NULL, GUS }, + { NULL, GUSM }, + { NULL, MIDI }, + { NULL, AUTO }, + { NULL, NULL } }; + + +static CHOICE DigiPorts[]={ { " 210h", SetPortD }, + { " 220h", SetPortD }, + { " 230h", SetPortD }, + { " 240h", SetPortD }, + { " 250h", SetPortD }, + { " 260h", SetPortD }, + { "AUTO ", SetPortD }, + { NULL, NULL } }; + +static CHOICE MIDIPorts[]={ { " 220h", SetPortM }, + { " 230h", SetPortM }, + { " 240h", SetPortM }, + { " 250h", SetPortM }, + { " 300h", SetPortM }, + { " 320h", SetPortM }, + { " 330h", SetPortM }, + { " 340h", SetPortM }, + { " 350h", SetPortM }, + { " 360h", SetPortM }, + { "AUTO ", SetPortM }, + { NULL, NULL } }; + +static CHOICE BlsterIRQ[]={ { "IRQ 2", SetIRQ }, + { "IRQ 5", SetIRQ }, + { "IRQ 7", SetIRQ }, + { "IRQ 10", SetIRQ }, + { "AUTO ", SetIRQ }, + { NULL, NULL } }; + +static CHOICE GravisIRQ[]={ { "IRQ 2", SetIRQ }, + { "IRQ 5", SetIRQ }, + { "IRQ 7", SetIRQ }, + { "IRQ 11", SetIRQ }, + { "IRQ 12", SetIRQ }, + { "IRQ 15", SetIRQ }, + { "AUTO ", SetIRQ }, + { NULL, NULL } }; + +static CHOICE GravisDMA[]={ { "DMA 1", SetDMA }, + { "DMA 3", SetDMA }, + { "DMA 5", SetDMA }, + { "DMA 6", SetDMA }, + { "DMA 7", SetDMA }, + { "AUTO ", SetDMA }, + { NULL, NULL } }; + +static CHOICE BlsterDMA[]={ { "DMA 0", SetDMA }, + { "DMA 1", SetDMA }, + { "DMA 3", SetDMA }, + { "AUTO ", SetDMA }, + { NULL, NULL } }; + + + + +void SelectSound (void) +{ + int i; + Sound.Close(); + if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); + Inf(Text[STYPE_TEXT]); + Talk->Goto(Talk->X, FONT_HIG/2); + for (i = 0; i < ArrayCount(DevName); i ++) + DevMenu[i].Text = Text[DevName[i]]; + (new VMENU(DevMenu, SCR_WID/2, Talk->Y+Talk->H+TEXT_VM+FONT_HIG))->SetName(Text[MENU_TEXT]); +} + + + + +static void Reset (void) +{ + SNDDrvInfo.DBASE = SNDDrvInfo.DIRQ = SNDDrvInfo.DDMA = SNDDrvInfo.MBASE = DETECT; +} + + + + + +static uint16 deco (const char * str, uint16 (*dco)(const char *)) +{ + while (*str && ! IsDigit(*str)) ++ str; + if (*str) return dco(str); + else return DETECT; +} + + + + +static uint16 ddeco (const char * str) +{ + return deco(str, atow); +} + + + + +static uint16 xdeco (const char * str) +{ + return deco(str, xtow); +} + + + + +static CHOICE * Cho; +static int Hlp; + +static void SNSelect (void) +{ + Inf(Text[Hlp]); + Talk->Goto(Talk->X, FONT_HIG / 2); + (new VMENU(Cho, SCR_WID/2, Talk->Y+Talk->H+TEXT_VM+FONT_HIG))->SetName(Text[MENU_TEXT]); +} + + + + +static void Select (CHOICE * cho, int hlp) +{ + Cho = cho; + Hlp = hlp; + SNPOST(SNEXEC, -1, 0, (void *) SNSelect); +} + + + + + + +static void NONE (void) +{ + SNDDrvInfo.DDEV = DEV_QUIET; + SNDDrvInfo.MDEV = DEV_QUIET; + Sound.Open(); +} + + + +static void SB (void) +{ + SNDDrvInfo.DDEV = DEV_SB; + SNDDrvInfo.MDEV = DEV_SB; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + + +static void SBM (void) +{ + SNDDrvInfo.DDEV = DEV_SB; + SNDDrvInfo.MDEV = DEV_GM; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + +static void GUS (void) +{ + SNDDrvInfo.DDEV = DEV_GUS; + SNDDrvInfo.MDEV = DEV_GUS; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + + +static void GUSM (void) +{ + SNDDrvInfo.DDEV = DEV_GUS; + SNDDrvInfo.MDEV = DEV_GM; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + +static void MIDI (void) +{ + SNDDrvInfo.DDEV = DEV_QUIET; + SNDDrvInfo.MDEV = DEV_GM; + SNDDrvInfo.MBASE = DETECT; + Select(MIDIPorts, MPORT_TEXT); +} + + + +static void AUTO (void) +{ + SNDDrvInfo.DDEV = DEV_AUTO; + SNDDrvInfo.MDEV = DEV_AUTO; + Reset(); + Sound.Open(); +} + + + + + + +static void SetPortD (void) +{ + SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text); + Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); +} + + + +static void SetPortM (void) +{ + SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); + Sound.Open(); +} + + + + +static void SetIRQ (void) +{ + SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); + Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); +} + + + + +static void SetDMA (void) +{ + SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); + if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); + else Sound.Open(); +} + +} // End of namespace CGE diff --git a/engines/cge/config.h b/engines/cge/config.h new file mode 100644 index 0000000000..1e692afc4d --- /dev/null +++ b/engines/cge/config.h @@ -0,0 +1,37 @@ +/* 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 + */ + +#ifndef __CONFIG__ +#define __CONFIG__ + +namespace CGE { + +void SelectSound (void); + +} // End of namespace CGE + +#endif diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 7424c8bc38..e028d7feb4 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -3,9 +3,11 @@ MODULE := engines/cge MODULE_OBJS := \ bitmap.o \ bitmaps.o \ + btfile.o \ cfile.o \ cge.o \ cge_main.o \ + config.o \ console.o \ detection.o \ game.o \ diff --git a/engines/cge/talk.h b/engines/cge/talk.h index fb1d450f2d..76539fbcf9 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -29,7 +29,7 @@ #define __TALK__ #include "cge/vga13h.h" -#include <dir.h> +//#include <dir.h> namespace CGE { diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d8e2273557..e5c34d238f 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -30,7 +30,7 @@ #include "cge/general.h" #include <stddef.h> -#include <dir.h> +//#include <dir.h> #include "cge/bitmap.h" #include "cge/snail.h" diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 8a94dbe8af..9f4391cc9a 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -26,7 +26,8 @@ */ #include "cge/vol.h" -#include <alloc.h> +//#include <alloc.h> +#include "common/system.h" #include <stdlib.h> #include <string.h> #include <errno.h> diff --git a/engines/cge/vol.h b/engines/cge/vol.h index a98dbbeee2..b63b08e7a1 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -29,7 +29,7 @@ #define __VOL__ -#include <dir.h> +//#include <dir.h> #include "cge/btfile.h" #include "cge/cfile.h" |