aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2011-06-13 11:57:24 +0200
committerStrangerke2011-06-13 11:57:24 +0200
commitffc2aa4e4f41aa679d773ccafdec87bf8d7b5e85 (patch)
treeee004f6dde791239db37225c1f53057ab39bae8c /engines
parentccd934e4bfaa2997bf2dcec6818e0c418a11624f (diff)
downloadscummvm-rg350-ffc2aa4e4f41aa679d773ccafdec87bf8d7b5e85.tar.gz
scummvm-rg350-ffc2aa4e4f41aa679d773ccafdec87bf8d7b5e85.tar.bz2
scummvm-rg350-ffc2aa4e4f41aa679d773ccafdec87bf8d7b5e85.zip
CGE: Format code
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/bitmap.cpp673
-rw-r--r--engines/cge/bitmap.h86
-rw-r--r--engines/cge/bitmaps.cpp371
-rw-r--r--engines/cge/bitmaps.h18
-rw-r--r--engines/cge/boot.h76
-rw-r--r--engines/cge/btfile.cpp226
-rw-r--r--engines/cge/btfile.h95
-rw-r--r--engines/cge/cfile.cpp441
-rw-r--r--engines/cge/cfile.h71
-rw-r--r--engines/cge/cge.cpp31
-rw-r--r--engines/cge/cge.h20
-rw-r--r--engines/cge/cge_main.cpp3377
-rw-r--r--engines/cge/cge_main.h288
-rw-r--r--engines/cge/config.cpp433
-rw-r--r--engines/cge/config.h6
-rw-r--r--engines/cge/detection.cpp10
-rw-r--r--engines/cge/ems.cpp310
-rw-r--r--engines/cge/game.cpp118
-rw-r--r--engines/cge/game.h43
-rw-r--r--engines/cge/general.cpp417
-rw-r--r--engines/cge/general.h311
-rw-r--r--engines/cge/gettext.cpp174
-rw-r--r--engines/cge/gettext.h38
-rw-r--r--engines/cge/ident.h17
-rw-r--r--engines/cge/jbw.h229
-rw-r--r--engines/cge/keybd.cpp213
-rw-r--r--engines/cge/keybd.h45
-rw-r--r--engines/cge/mixer.cpp203
-rw-r--r--engines/cge/mixer.h45
-rw-r--r--engines/cge/module.mk7
-rw-r--r--engines/cge/mouse.cpp300
-rw-r--r--engines/cge/mouse.h82
-rw-r--r--engines/cge/snail.cpp1998
-rw-r--r--engines/cge/snail.h144
-rw-r--r--engines/cge/snddrv.h86
-rw-r--r--engines/cge/sound.cpp360
-rw-r--r--engines/cge/sound.h76
-rw-r--r--engines/cge/startup.cpp276
-rw-r--r--engines/cge/startup.h61
-rw-r--r--engines/cge/talk.cpp548
-rw-r--r--engines/cge/talk.h92
-rw-r--r--engines/cge/text.cpp435
-rw-r--r--engines/cge/text.h76
-rw-r--r--engines/cge/vga13h.cpp2473
-rw-r--r--engines/cge/vga13h.h505
-rw-r--r--engines/cge/vmenu.cpp208
-rw-r--r--engines/cge/vmenu.h39
-rw-r--r--engines/cge/vol.cpp89
-rw-r--r--engines/cge/vol.h84
-rw-r--r--engines/cge/wav.h175
50 files changed, 7625 insertions, 8874 deletions
diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp
index 1201b84fc6..1e5310a8e7 100644
--- a/engines/cge/bitmap.cpp
+++ b/engines/cge/bitmap.cpp
@@ -25,434 +25,389 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/bitmap.h"
-#include "cge/cfile.h"
-#include "cge/jbw.h"
-
-#ifdef VOL
- #include "cge/vol.h"
-#endif
-
-#include <dos.h>
+#include "cge/bitmap.h"
+#include "cge/cfile.h"
+#include "cge/jbw.h"
+#include "cge/vol.h"
+#include <dos.h>
#include "cge/cfile.h"
#include "common/system.h"
namespace CGE {
-//--------------------------------------------------------------------------
-
-
-
-
-DAC * BITMAP::Pal = NULL;
-
+DAC *BITMAP::Pal = NULL;
#define MAXPATH 128
#pragma argsused
-BITMAP::BITMAP (const char * fname, bool rem)
-: M(NULL), V(NULL)
-{
- char pat[MAXPATH];
-
- ForceExt(pat, fname, ".VBM");
-
- #if (BMP_MODE < 2)
- if (rem && PIC_FILE::Exist(pat))
- {
- PIC_FILE file(pat);
- if (file.Error == 0)
- if (! VBMLoad(&file))
- error("Bad VBM [%s]", fname);
- }
- else
- #endif
- {
- #if (BMP_MODE)
- ForceExt(pat, fname, ".BMP");
- PIC_FILE file(pat);
- if (file.Error == 0)
+BITMAP::BITMAP(const char *fname, bool rem) : M(NULL), V(NULL) {
+ char pat[MAXPATH];
+ ForceExt(pat, fname, ".VBM");
+
+#if (BMP_MODE < 2)
+ if (rem && PIC_FILE::Exist(pat)) {
+ PIC_FILE file(pat);
+ if ((file.Error == 0) && (!VBMLoad(&file)))
+ error("Bad VBM [%s]", fname);
+ } else
+#endif
{
- if (BMPLoad(&file))
- {
- Code();
- if (rem)
- {
- free(M);
- M = NULL;
+#if (BMP_MODE)
+ ForceExt(pat, fname, ".BMP");
+ PIC_FILE file(pat);
+ if (file.Error == 0) {
+ if (BMPLoad(&file)) {
+ Code();
+ if (rem) {
+ free(M);
+ M = NULL;
+ }
+ } else
+ error("Bad BMP [%s]", fname);
}
- }
- else
- error("Bad BMP [%s]", fname);
+#else
+ error("Bad VBM [%s]", fname);
+#endif
}
- #else
- error("Bad VBM [%s]", fname);
- #endif
- }
}
-
-
-
-BITMAP::BITMAP (uint16 w, uint16 h, uint8 * map)
-: W(w), H(h), M(map), V(NULL)
-{
- if (map) Code();
+BITMAP::BITMAP(uint16 w, uint16 h, uint8 *map) : W(w), H(h), M(map), V(NULL) {
+ if (map)
+ Code();
}
-
-
// following routine creates filled rectangle
// immediately as VGA video chunks, in near memory as fast as possible,
// especially for text line real time display
-
-BITMAP::BITMAP (uint16 w, uint16 h, uint8 fill)
-: W((w + 3) & ~3), // only full uint32 allowed!
- H(h),
- M(NULL)
-{
- uint16 dsiz = W >> 2; // data size (1 plane line size)
- uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
- uint16 psiz = H * lsiz; // - last gape, but + plane trailer
- uint8 * v = new uint8[4 * psiz // the same for 4 planes
- + H * sizeof(*B)]; // + room for wash table
- if (v == NULL)
- error("No core");
-
- * (uint16 *) v = CPY | dsiz; // data chunk hader
- memset(v+2, fill, dsiz); // data bytes
- * (uint16 *) (v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap
- memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines
- * (uint16 *) (v + psiz - 2) = EOI; // plane trailer uint16
- memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes
- HideDesc * b = (HideDesc *) (v + 4 * psiz);
- b->skip = (SCR_WID - W) >> 2;
- b->hide = W >> 2;
- memcpy(b+1, b, (H-1) * sizeof(*b)); // tricky fill entire table
- b->skip = 0; // fix the first entry
- V = v;
- B = b;
+BITMAP::BITMAP(uint16 w, uint16 h, uint8 fill)
+ : W((w + 3) & ~3), // only full uint32 allowed!
+ H(h),
+ M(NULL) {
+ uint16 dsiz = W >> 2; // data size (1 plane line size)
+ uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
+ uint16 psiz = H * lsiz; // - last gape, but + plane trailer
+ uint8 *v = new uint8[4 * psiz + H * sizeof(*B)];// the same for 4 planes
+ // + room for wash table
+ if (v == NULL)
+ error("No core");
+
+ *(uint16 *) v = CPY | dsiz; // data chunk hader
+ memset(v + 2, fill, dsiz); // data bytes
+ *(uint16 *)(v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap
+ memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines
+ *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16
+ memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes
+ HideDesc *b = (HideDesc *)(v + 4 * psiz);
+ b->skip = (SCR_WID - W) >> 2;
+ b->hide = W >> 2;
+ memcpy(b + 1, b, (H - 1) * sizeof(*b)); // tricky fill entire table
+ b->skip = 0; // fix the first entry
+ V = v;
+ B = b;
}
-
-
-
-
-
-BITMAP::BITMAP (const BITMAP& bmp)
-: W(bmp.W), H(bmp.H),
- M(NULL), V(NULL)
-{
- uint8 * v0 = bmp.V;
- if (v0)
- {
- uint16 vsiz = (uint8*)(bmp.B) - (uint8*)(v0);
- uint16 siz = vsiz + H * sizeof(HideDesc);
- uint8 * v1 = farnew(uint8, siz);
- if (v1 == NULL)
- error("No core");
- memcpy(v1, v0, siz);
- B = (HideDesc *) ((V = v1) + vsiz);
- }
+BITMAP::BITMAP(const BITMAP &bmp) : W(bmp.W), H(bmp.H), M(NULL), V(NULL) {
+ uint8 *v0 = bmp.V;
+ if (v0) {
+ uint16 vsiz = (uint8 *)(bmp.B) - (uint8 *)(v0);
+ uint16 siz = vsiz + H * sizeof(HideDesc);
+ uint8 *v1 = farnew(uint8, siz);
+ if (v1 == NULL)
+ error("No core");
+ memcpy(v1, v0, siz);
+ B = (HideDesc *)((V = v1) + vsiz);
+ }
}
-
-
-
-BITMAP::~BITMAP (void)
-{
- switch (MemType(M))
- {
- case FAR_MEM : free(M); break;
- }
- switch (MemType(V))
- {
- case NEAR_MEM : delete[] (uint8 *) V; break;
- case FAR_MEM : free(V); break;
- }
+BITMAP::~BITMAP(void) {
+ if (MemType(M) == FAR_MEM)
+ free(M);
+
+ switch (MemType(V)) {
+ case NEAR_MEM :
+ delete[](uint8 *) V;
+ break;
+ case FAR_MEM :
+ free(V);
+ break;
+ }
}
-
-BITMAP& BITMAP::operator = (const BITMAP& bmp)
-{
- uint8 * v0 = bmp.V;
- W = bmp.W;
- H = bmp.H;
- M = NULL;
- if (MemType(V) == FAR_MEM) free(V);
- if (v0 == NULL) V = NULL;
- else
- {
- uint16 vsiz = (uint8*)bmp.B - (uint8*)v0;
- uint16 siz = vsiz + H * sizeof(HideDesc);
- uint8 * v1 = farnew(uint8, siz);
- if (v1 == NULL)
- error("No core");
- memcpy(v1, v0, siz);
- B = (HideDesc *) ((V = v1) + vsiz);
- }
- return *this;
+BITMAP &BITMAP::operator = (const BITMAP &bmp) {
+ uint8 *v0 = bmp.V;
+ W = bmp.W;
+ H = bmp.H;
+ M = NULL;
+ if (MemType(V) == FAR_MEM)
+ free(V);
+ if (v0 == NULL)
+ V = NULL;
+ else {
+ uint16 vsiz = (uint8 *)bmp.B - (uint8 *)v0;
+ uint16 siz = vsiz + H * sizeof(HideDesc);
+ uint8 *v1 = farnew(uint8, siz);
+ if (v1 == NULL)
+ error("No core");
+ memcpy(v1, v0, siz);
+ B = (HideDesc *)((V = v1) + vsiz);
+ }
+ return *this;
}
-
-
-
-uint16 BITMAP::MoveVmap (uint8 * buf)
-{
- if (V)
- {
- uint16 vsiz = (uint8*)B - (uint8*)V;
- uint16 siz = vsiz + H * sizeof(HideDesc);
- memcpy(buf, V, siz);
- if (MemType(V) == FAR_MEM) free(V);
- B = (HideDesc *) ((V = buf) + vsiz);
- return siz;
- }
- return 0;
+uint16 BITMAP::MoveVmap(uint8 *buf) {
+ if (V) {
+ uint16 vsiz = (uint8 *)B - (uint8 *)V;
+ uint16 siz = vsiz + H * sizeof(HideDesc);
+ memcpy(buf, V, siz);
+ if (MemType(V) == FAR_MEM)
+ free(V);
+ B = (HideDesc *)((V = buf) + vsiz);
+ return siz;
+ }
+ return 0;
}
+BMP_PTR BITMAP::Code(void) {
+ if (M) {
+ uint16 i, cnt;
+ if (V) { // old X-map exists, so remove it
+ switch (MemType(V)) {
+ case NEAR_MEM :
+ delete[](uint8 *) V;
+ break;
+ case FAR_MEM :
+ free(V);
+ break;
+ }
+ V = NULL;
+ }
+ while (true) { // at most 2 times: for (V == NULL) & for allocated block;
+ uint8 *im = V + 2;
+ uint16 *cp = (uint16 *) V;
+ int bpl;
+ if (V) { // 2nd pass - fill the hide table
+ for (i = 0; i < H; i ++) {
+ B[i].skip = 0xFFFF;
+ B[i].hide = 0x0000;
+ }
+ }
+ for (bpl = 0; bpl < 4; bpl ++) { // once per each bitplane
+ uint8 *bm = M;
+ bool skip = (bm[bpl] == TRANS);
+ uint16 j;
+
+ cnt = 0;
+ for (i = 0; i < H; i ++) { // once per each line
+ uint8 pix;
+ for (j = bpl; j < W; j += 4) {
+ pix = bm[j];
+ if (V && pix != TRANS) {
+ if (j < B[i].skip)
+ B[i].skip = j;
+
+ if (j >= B[i].hide)
+ B[i].hide = j + 1;
+ }
+ if ((pix == TRANS) != skip || cnt >= 0x3FF0) { // end of block
+ cnt |= (skip) ? SKP : CPY;
+ if (V)
+ *cp = cnt; // store block description uint16
+
+ cp = (uint16 *) im;
+ im += 2;
+ skip = (pix == TRANS);
+ cnt = 0;
+ }
+ if (! skip) {
+ if (V)
+ *im = pix;
+ ++ im;
+ }
+ ++ cnt;
+ }
+
+ bm += W;
+ if (W < SCR_WID) {
+ if (skip) {
+ cnt += (SCR_WID - j + 3) / 4;
+ } else {
+ cnt |= CPY;
+ if (V)
+ *cp = cnt;
+
+ cp = (uint16 *) im;
+ im += 2;
+ skip = true;
+ cnt = (SCR_WID - j + 3) / 4;
+ }
+ }
+ }
+ if (cnt && ! skip) {
+ cnt |= CPY;
+ if (V)
+ *cp = cnt;
+
+ cp = (uint16 *) im;
+ im += 2;
+ }
+ if (V)
+ *cp = EOI;
+ cp = (uint16 *) im;
+ im += 2;
+ }
+ if (V)
+ break;
+ uint16 sizV = (uint16)(im - 2 - V);
+ V = farnew(uint8, sizV + H * sizeof(*B));
+ if (! V)
+ error("No core");
-BMP_PTR BITMAP::Code (void)
-{
- if (M)
- {
- uint16 i, cnt;
-
- if (V) // old X-map exists, so remove it
- {
- switch (MemType(V))
- {
- case NEAR_MEM : delete[] (uint8 *) V; break;
- case FAR_MEM : free(V); break;
- }
- V = NULL;
- }
-
- while (true) // at most 2 times: for (V == NULL) & for allocated block;
- {
- uint8 * im = V+2;
- uint16 * cp = (uint16 *) V;
- int bpl;
-
- if (V) // 2nd pass - fill the hide table
- {
- for (i = 0; i < H; i ++)
- {
- B[i].skip = 0xFFFF;
- B[i].hide = 0x0000;
+ B = (HideDesc *)(V + sizV);
}
- }
- for (bpl = 0; bpl < 4; bpl ++) // once per each bitplane
- {
- uint8 * bm = M;
- bool skip = (bm[bpl] == TRANS);
- uint16 j;
-
- cnt = 0;
- for (i = 0; i < H; i ++) // once per each line
- {
- uint8 pix;
- for (j = bpl; j < W; j += 4)
- {
- pix = bm[j];
- if (V && pix != TRANS)
- {
- if (j < B[i].skip) B[i].skip = j;
- if (j >= B[i].hide) B[i].hide = j+1;
+ cnt = 0;
+ for (i = 0; i < H; i ++) {
+ if (B[i].skip == 0xFFFF) { // whole line is skipped
+ B[i].skip = (cnt + SCR_WID) >> 2;
+ cnt = 0;
+ } else {
+ uint16 s = B[i].skip & ~3;
+ uint16 h = (B[i].hide + 3) & ~3;
+ B[i].skip = (cnt + s) >> 2;
+ B[i].hide = (h - s) >> 2;
+ cnt = SCR_WID - h;
}
- if ((pix == TRANS) != skip || cnt >= 0x3FF0) // end of block
- {
- cnt |= (skip) ? SKP : CPY;
- if (V)
- {
- *cp = cnt; // store block description uint16
- }
- cp = (uint16 *) im;
- im += 2;
- skip = (pix == TRANS);
- cnt = 0;
- }
- if (! skip)
- {
- if (V) * im = pix;
- ++ im;
- }
- ++ cnt;
- }
-
- bm += W;
- if (W < SCR_WID)
- {
- if (skip)
- {
- cnt += (SCR_WID - j + 3) / 4;
- }
- else
- {
- cnt |= CPY;
- if (V)
- {
- *cp = cnt;
- }
- cp = (uint16 *) im;
- im += 2;
- skip = true;
- cnt = (SCR_WID - j + 3) / 4;
- }
- }
}
- if (cnt && ! skip)
- {
- cnt |= CPY;
- if (V)
- {
- *cp = cnt;
- }
- cp = (uint16 *) im;
- im += 2;
- }
- if (V) *cp = EOI;
- cp = (uint16 *) im;
- im += 2;
- }
- if (V) break;
- uint16 sizV = (uint16) (im - 2 - V);
- V = farnew(uint8, sizV + H * sizeof(*B));
- if (! V)
- {
- error("No core");
- }
- B = (HideDesc *) (V + sizV);
- }
- cnt = 0;
- for (i = 0; i < H; i ++)
- {
- if (B[i].skip == 0xFFFF) // whole line is skipped
- {
- B[i].skip = (cnt + SCR_WID) >> 2;
- cnt = 0;
- }
- else
- {
- uint16 s = B[i].skip & ~3;
- uint16 h = (B[i].hide + 3) & ~3;
- B[i].skip = (cnt + s) >> 2;
- B[i].hide = (h - s) >> 2;
- cnt = SCR_WID - h;
- }
}
- }
- return this;
+ return this;
}
+bool BITMAP::SolidAt(int x, int y) {
+ uint8 *m;
+ uint16 r, n, n0;
+ if ((x >= W) || (y >= H))
+ return false;
+ m = V;
+ r = x % 4;
+ n0 = (SCR_WID * y + x) / 4, n = 0;
+ while (r) {
+ uint16 w, t;
-bool BITMAP::SolidAt (int x, int y)
-{
- uint8 * m;
- uint16 r, n, n0;
-
- if (x >= W || y >= H) return false;
+ w = *(uint16 *) m;
+ m += 2;
+ t = w & 0xC000;
+ w &= 0x3FFF;
- m = V;
- r = x % 4;
- n0 = (SCR_WID * y + x) / 4, n = 0;
-
- while (r)
- {
- uint16 w, t;
-
- w = * (uint16 *) m;
- m += 2;
- t = w & 0xC000;
- w &= 0x3FFF;
-
- switch (t)
- {
- case EOI : -- r;
- case SKP : w = 0; break;
- case REP : w = 1; break;
+ switch (t) {
+ case EOI :
+ -- r;
+ case SKP :
+ w = 0;
+ break;
+ case REP :
+ w = 1;
+ break;
+ }
+ m += w;
}
- m += w;
- }
-
- while (true)
- {
- uint16 w, t;
- w = * (uint16 *) m;
- m += 2;
- t = w & 0xC000;
- w &= 0x3FFF;
-
- if (n > n0) return false;
- n += w;
- switch (t)
- {
- case EOI : return false;
- case SKP : w = 0; break;
- case REP :
- case CPY : if (n-w <= n0 && n > n0) return true; break;
+ while (true) {
+ uint16 w, t;
+
+ w = * (uint16 *) m;
+ m += 2;
+ t = w & 0xC000;
+ w &= 0x3FFF;
+
+ if (n > n0)
+ return false;
+
+ n += w;
+ switch (t) {
+ case EOI :
+ return false;
+ case SKP :
+ w = 0;
+ break;
+ case REP :
+ case CPY :
+ if (n - w <= n0 && n > n0)
+ return true;
+ break;
+ }
+ m += (t == REP) ? 1 : w;
}
- m += (t == REP) ? 1 : w;
- }
}
+bool BITMAP::VBMSave(XFILE *f) {
+ uint16 p = (Pal != NULL),
+ n = ((uint16)(((uint8 *)B) - V)) + H * sizeof(HideDesc);
+ if (f->Error == 0)
+ f->Write((uint8 *)&p, sizeof(p));
+
+ if (f->Error == 0)
+ f->Write((uint8 *)&n, sizeof(n));
+ if (f->Error == 0)
+ f->Write((uint8 *)&W, sizeof(W));
+ if (f->Error == 0)
+ f->Write((uint8 *)&H, sizeof(H));
+ if (f->Error == 0)
+ if (p)
+ f->Write((uint8 *)Pal, 256 * sizeof(DAC));
-bool BITMAP::VBMSave (XFILE * f)
-{
- uint16 p = (Pal != NULL),
- n = ((uint16) (((uint8 *)B) - V)) + H * sizeof(HideDesc);
- if (f->Error == 0) f->Write((uint8 *)&p, sizeof(p));
- if (f->Error == 0) f->Write((uint8 *)&n, sizeof(n));
- if (f->Error == 0) f->Write((uint8 *)&W, sizeof(W));
- if (f->Error == 0) f->Write((uint8 *)&H, sizeof(H));
- if (f->Error == 0) if (p) f->Write((uint8 *)Pal, 256 * sizeof(DAC));
- if (f->Error == 0) f->Write(V, n);
- return (f->Error == 0);
+ if (f->Error == 0)
+ f->Write(V, n);
+
+ return (f->Error == 0);
}
+bool BITMAP::VBMLoad(XFILE *f) {
+ uint16 p = 0, n = 0;
+ if (f->Error == 0)
+ f->Read((uint8 *)&p, sizeof(p));
+ if (f->Error == 0)
+ f->Read((uint8 *)&n, sizeof(n));
+ if (f->Error == 0)
+ f->Read((uint8 *)&W, sizeof(W));
-bool BITMAP::VBMLoad (XFILE * f)
-{
- uint16 p = 0, n = 0;
- if (f->Error == 0) f->Read((uint8 *)&p, sizeof(p));
- if (f->Error == 0) f->Read((uint8 *)&n, sizeof(n));
- if (f->Error == 0) f->Read((uint8 *)&W, sizeof(W));
- if (f->Error == 0) f->Read((uint8 *)&H, sizeof(H));
- if (f->Error == 0)
- {
- if (p)
- {
- if (Pal) f->Read((uint8 *)Pal, 256 * sizeof(DAC));
- else f->Seek(f->Mark() + 256 * sizeof(DAC));
+ if (f->Error == 0)
+ f->Read((uint8 *)&H, sizeof(H));
+
+ if (f->Error == 0) {
+ if (p) {
+ if (Pal)
+ f->Read((uint8 *)Pal, 256 * sizeof(DAC));
+ else
+ f->Seek(f->Mark() + 256 * sizeof(DAC));
+ }
}
- }
- if ((V = farnew(uint8, n)) == NULL) return false;
- if (f->Error == 0) f->Read(V, n);
- B = (HideDesc *) (V + n - H * sizeof(HideDesc));
- return (f->Error == 0);
-}
+ if ((V = farnew(uint8, n)) == NULL)
+ return false;
+ if (f->Error == 0)
+ f->Read(V, n);
+ B = (HideDesc *)(V + n - H * sizeof(HideDesc));
+ return (f->Error == 0);
+}
} // End of namespace CGE
diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h
index 90f94b1b32..eca3be70e8 100644
--- a/engines/cge/bitmap.h
+++ b/engines/cge/bitmap.h
@@ -25,64 +25,64 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __BITMAP__
-#define __BITMAP__
+#ifndef __BITMAP__
+#define __BITMAP__
-#include "cge/general.h"
+#include "cge/general.h"
namespace CGE {
-#define EOI 0x0000
-#define SKP 0x4000
-#define REP 0x8000
-#define CPY 0xC000
+#define EOI 0x0000
+#define SKP 0x4000
+#define REP 0x8000
+#define CPY 0xC000
-#define TRANS 0xFE
+#define TRANS 0xFE
-typedef struct { uint16 b : 2;
- uint16 B : 6;
- uint16 g : 2;
- uint16 G : 6;
- uint16 r : 2;
- uint16 R : 6;
- uint16 Z : 8;
- } BGR4;
+typedef struct {
+ uint16 b : 2;
+ uint16 B : 6;
+ uint16 g : 2;
+ uint16 G : 6;
+ uint16 r : 2;
+ uint16 R : 6;
+ uint16 Z : 8;
+} BGR4;
-typedef struct { uint16 skip; uint16 hide; } HideDesc;
+typedef struct {
+ uint16 skip;
+ uint16 hide;
+} HideDesc;
-
-
-class BITMAP
-{
- bool BMPLoad (XFILE * f);
- bool VBMLoad (XFILE * f);
+class BITMAP {
+ bool BMPLoad(XFILE *f);
+ bool VBMLoad(XFILE *f);
public:
- static DAC * Pal;
- uint16 W, H;
- uint8 * M, * V; HideDesc * B;
- BITMAP (const char * fname, bool rem = true);
- BITMAP (uint16 w, uint16 h, uint8 * map);
- BITMAP (uint16 w, uint16 h, uint8 fill);
- BITMAP (const BITMAP& bmp);
- ~BITMAP (void);
- BITMAP * FlipH (void);
- BITMAP * Code ();
- BITMAP& operator = (const BITMAP& bmp);
- void Hide (int x, int y);
- void Show (int x, int y);
- void XShow (int x, int y);
- bool SolidAt (int x, int y);
- bool VBMSave (XFILE * f);
- uint16 MoveVmap (uint8 * buf);
+ static DAC *Pal;
+ uint16 W, H;
+ uint8 *M, * V;
+ HideDesc *B;
+ BITMAP(const char *fname, bool rem = true);
+ BITMAP(uint16 w, uint16 h, uint8 *map);
+ BITMAP(uint16 w, uint16 h, uint8 fill);
+ BITMAP(const BITMAP &bmp);
+ ~BITMAP(void);
+ BITMAP *FlipH(void);
+ BITMAP *Code();
+ BITMAP &operator = (const BITMAP &bmp);
+ void Hide(int x, int y);
+ void Show(int x, int y);
+ void XShow(int x, int y);
+ bool SolidAt(int x, int y);
+ bool VBMSave(XFILE *f);
+ uint16 MoveVmap(uint8 *buf);
};
-
-typedef BITMAP * BMP_PTR;
-
+typedef BITMAP *BMP_PTR;
} // End of namespace CGE
diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp
index 1eba1b55ea..8e1b7ce5e9 100644
--- a/engines/cge/bitmaps.cpp
+++ b/engines/cge/bitmaps.cpp
@@ -25,146 +25,146 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/bitmaps.h"
+#include "cge/bitmaps.h"
/*
-#define W 255,
-#define x 252,
-#define _ TRANS,
-#define o 0,
-#define L LGRAY,
-#define G GRAY,
-#define D DGRAY,
-
-static uint8 MCDesign0[]= { W W W W W W _
- W W W W W o _
- W W W W o _ _
- W W W W W _ _
- W W o W W W _
- W o _ o W W W
- o _ _ _ o W W
- _ _ _ _ _ o o };
-
-
-static uint8 MCDesign1[]= { _ };
-
-
-
-static uint8 SLDesign[] = { G G G G G G G G G _ _ _ _ _ _
- L G G G G G G G G D _ _ _ _ _
- _ L G G G G G G G D _ _ _ _ _
- _ _ L G G G G G G G D _ _ _ _
- _ _ _ L G G G G G G D _ _ _ _
- _ _ _ _ L G G G G G D _ _ _ _
- _ _ _ _ _ L G G G G G D _ _ _
- _ _ _ _ _ _ L G G G G D _ _ _
- _ _ _ _ _ _ _ L G G G D _ _ _
- _ _ _ _ _ _ _ _ L G G G D _ _
- _ _ _ _ _ _ _ _ _ L G G D _ _
- _ _ _ _ _ _ _ _ _ _ L G D _ _
- _ _ _ _ _ _ _ _ _ _ _ L G D _
- _ _ _ _ _ _ _ _ _ _ _ _ L D _
- _ _ _ _ _ _ _ _ _ _ _ _ _ L D
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ D
- };
-
-static uint8 SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G
- _ _ _ _ _ L G G G G G G G G D
- _ _ _ _ _ L G G G G G G G D _
- _ _ _ _ L G G G G G G G D _ _
- _ _ _ _ L G G G G G G D _ _ _
- _ _ _ _ L G G G G G D _ _ _ _
- _ _ _ L G G G G G D _ _ _ _ _
- _ _ _ L G G G G D _ _ _ _ _ _
- _ _ _ L G G G D _ _ _ _ _ _ _
- _ _ L G G G D _ _ _ _ _ _ _ _
- _ _ L G G D _ _ _ _ _ _ _ _ _
- _ _ L G D _ _ _ _ _ _ _ _ _ _
- _ L G D _ _ _ _ _ _ _ _ _ _ _
- _ L D _ _ _ _ _ _ _ _ _ _ _ _
- L D _ _ _ _ _ _ _ _ _ _ _ _ _
- D _ _ _ _ _ _ _ _ _ _ _ _ _ _
- };
-
-static uint8 MapBrick[] = { L L L L L L L G
- L G G G G G G D
- L G G G G G G D
- G D D D D D D D
- };
-
-#undef W
-#undef _
-#undef x
-#undef o
-#undef L
-#undef G
-#undef D
+#define W 255,
+#define x 252,
+#define _ TRANS,
+#define o 0,
+#define L LGRAY,
+#define G GRAY,
+#define D DGRAY,
+
+static uint8 MCDesign0[]= { W W W W W W _
+ W W W W W o _
+ W W W W o _ _
+ W W W W W _ _
+ W W o W W W _
+ W o _ o W W W
+ o _ _ _ o W W
+ _ _ _ _ _ o o };
+
+
+static uint8 MCDesign1[]= { _ };
+
+
+
+static uint8 SLDesign[] = { G G G G G G G G G _ _ _ _ _ _
+ L G G G G G G G G D _ _ _ _ _
+ _ L G G G G G G G D _ _ _ _ _
+ _ _ L G G G G G G G D _ _ _ _
+ _ _ _ L G G G G G G D _ _ _ _
+ _ _ _ _ L G G G G G D _ _ _ _
+ _ _ _ _ _ L G G G G G D _ _ _
+ _ _ _ _ _ _ L G G G G D _ _ _
+ _ _ _ _ _ _ _ L G G G D _ _ _
+ _ _ _ _ _ _ _ _ L G G G D _ _
+ _ _ _ _ _ _ _ _ _ L G G D _ _
+ _ _ _ _ _ _ _ _ _ _ L G D _ _
+ _ _ _ _ _ _ _ _ _ _ _ L G D _
+ _ _ _ _ _ _ _ _ _ _ _ _ L D _
+ _ _ _ _ _ _ _ _ _ _ _ _ _ L D
+ _ _ _ _ _ _ _ _ _ _ _ _ _ _ D
+ };
+
+static uint8 SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G
+ _ _ _ _ _ L G G G G G G G G D
+ _ _ _ _ _ L G G G G G G G D _
+ _ _ _ _ L G G G G G G G D _ _
+ _ _ _ _ L G G G G G G D _ _ _
+ _ _ _ _ L G G G G G D _ _ _ _
+ _ _ _ L G G G G G D _ _ _ _ _
+ _ _ _ L G G G G D _ _ _ _ _ _
+ _ _ _ L G G G D _ _ _ _ _ _ _
+ _ _ L G G G D _ _ _ _ _ _ _ _
+ _ _ L G G D _ _ _ _ _ _ _ _ _
+ _ _ L G D _ _ _ _ _ _ _ _ _ _
+ _ L G D _ _ _ _ _ _ _ _ _ _ _
+ _ L D _ _ _ _ _ _ _ _ _ _ _ _
+ L D _ _ _ _ _ _ _ _ _ _ _ _ _
+ D _ _ _ _ _ _ _ _ _ _ _ _ _ _
+ };
+
+static uint8 MapBrick[] = { L L L L L L L G
+ L G G G G G G D
+ L G G G G G G D
+ G D D D D D D D
+ };
+
+#undef W
+#undef _
+#undef x
+#undef o
+#undef L
+#undef G
+#undef D
#if 0
-#define _ TRANS,
-#define A 213,
-#define B 207,
-#define C 225,
-#define D 219,
-#define E 231,
-
-static uint8 PRDesign[] = { A E E E C C D A B
- C _ _ _ _ _ _ D A
- C _ _ _ _ _ _ D A
- C _ _ _ _ _ _ D A
- C _ _ _ _ _ _ D A
- C _ _ _ _ _ _ D A
- C _ _ _ _ _ _ D A
- B A A A A A A A B
- B B B B B B B B B
- };
+#define _ TRANS,
+#define A 213,
+#define B 207,
+#define C 225,
+#define D 219,
+#define E 231,
+
+static uint8 PRDesign[] = { A E E E C C D A B
+ C _ _ _ _ _ _ D A
+ C _ _ _ _ _ _ D A
+ C _ _ _ _ _ _ D A
+ C _ _ _ _ _ _ D A
+ C _ _ _ _ _ _ D A
+ C _ _ _ _ _ _ D A
+ B A A A A A A A B
+ B B B B B B B B B
+ };
#else
-#define _ TRANS,
-#define A 213,
-#define B 207,
-#define C 225, // DGRAY
-#define D 219,
-#define E 231,
-#define F 237,
-
-static uint8 PRDesign[] = { D D D D D D D D _
- D D D D D D D D _
- D _ _ _ _ _ _ _ _
- D _ _ _ _ _ _ _ _
- D _ _ _ _ _ _ _ _
- D _ _ _ _ _ _ _ _
- D _ _ _ _ _ _ _ _
- D _ _ _ _ _ _ C _
- D C C C C C C C _
- _ _ _ _ _ _ _ _ _
- };
+#define _ TRANS,
+#define A 213,
+#define B 207,
+#define C 225, // DGRAY
+#define D 219,
+#define E 231,
+#define F 237,
+
+static uint8 PRDesign[] = { D D D D D D D D _
+ D D D D D D D D _
+ D _ _ _ _ _ _ _ _
+ D _ _ _ _ _ _ _ _
+ D _ _ _ _ _ _ _ _
+ D _ _ _ _ _ _ _ _
+ D _ _ _ _ _ _ _ _
+ D _ _ _ _ _ _ C _
+ D C C C C C C C _
+ _ _ _ _ _ _ _ _ _
+ };
#endif
-#undef _
-#undef A
-#undef B
-#undef C
-#undef D
-#undef E
+#undef _
+#undef A
+#undef B
+#undef C
+#undef D
+#undef E
-#define _ 0x00,
-#define x 0xFF,
-#define A _ x _ x _ x _ x
-#define B A A A A A A A A
+#define _ 0x00,
+#define x 0xFF,
+#define A _ x _ x _ x _ x
+#define B A A A A A A A A
-static uint8 HLDesign[] = { B B B B B };
+static uint8 HLDesign[] = { B B B B B };
-#undef _
-#undef x
-#undef A
-#undef B
+#undef _
+#undef x
+#undef A
+#undef B
// 228 yellow
@@ -172,74 +172,93 @@ static uint8 HLDesign[] = { B B B B B };
// 226 light green
// 221 blue
-#define A 208,
-#define B 214,
-#define C 220,
-#define D 226,
-#define E 255,
+#define A 208,
+#define B 214,
+#define C 220,
+#define D 226,
+#define E 255,
-static uint8 LIDesign[][9] = { { A A A
- A B A
- A A A },
+static uint8 LIDesign[][9] = { { A A A
+ A B A
+ A A A },
- { A B A
- B C B
- A B A },
+ { A B A
+ B C B
+ A B A },
- { B C B
- C D C
- B C B },
+ { B C B
+ C D C
+ B C B },
- { C D C
- D E D
- C D C },
- };
+ { C D C
+ D E D
+ C D C },
+ };
-#undef A
-#undef B
-#undef C
-#undef D
-#undef E
+#undef A
+#undef B
+#undef C
+#undef D
+#undef E
-#define R 211,
-#define G 0,
+#define R 211,
+#define G 0,
//226,
-static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0
- { R R R R R R R R G }, // 1
- { R R R R R R R G G }, // 2
- { R R R R R R G G G }, // 3
- { R R R R R G G G G }, // 4
- { R R R R G G G G G }, // 5
- { R R R G G G G G G }, // 6
- { R R G G G G G G G }, // 7
- { R G G G G G G G G }, // 8
- { G G G G G G G G G }, // 9
- };
-
-#undef R
-#undef G
+static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0
+ { R R R R R R R R G }, // 1
+ { R R R R R R R G G }, // 2
+ { R R R R R R G G G }, // 3
+ { R R R R R G G G G }, // 4
+ { R R R R G G G G G }, // 5
+ { R R R G G G G G G }, // 6
+ { R R G G G G G G G }, // 7
+ { R G G G G G G G G }, // 8
+ { G G G G G G G G G }, // 9
+ };
+
+#undef R
+#undef G
*/
namespace CGE {
#ifdef DEBUG
- BMP_PTR MB[] = { new BITMAP("BRICK"), NULL };
- BMP_PTR HL[] = { new BITMAP("HLINE"), NULL };
+BMP_PTR MB[] = {
+ new BITMAP("BRICK"),
+ NULL
+};
+
+BMP_PTR HL[] = {
+ new BITMAP("HLINE"),
+ NULL
+};
#endif
- BMP_PTR MC[] = { new BITMAP("MOUSE"),
- new BITMAP("DUMMY"),
- NULL };
- BMP_PTR PR[] = { new BITMAP("PRESS"), NULL };
- BMP_PTR SP[] = { new BITMAP("SPK_L"),
- new BITMAP("SPK_R"),
- NULL };
- BMP_PTR LI[] = { new BITMAP("LITE0"),
- new BITMAP("LITE1"),
- new BITMAP("LITE2"),
- new BITMAP("LITE3"),
- NULL };
+BMP_PTR MC[] = {
+ new BITMAP("MOUSE"),
+ new BITMAP("DUMMY"),
+ NULL
+};
+
+BMP_PTR PR[] = {
+ new BITMAP("PRESS"),
+ NULL
+};
+
+BMP_PTR SP[] = {
+ new BITMAP("SPK_L"),
+ new BITMAP("SPK_R"),
+ NULL
+};
+
+BMP_PTR LI[] = {
+ new BITMAP("LITE0"),
+ new BITMAP("LITE1"),
+ new BITMAP("LITE2"),
+ new BITMAP("LITE3"),
+ NULL
+};
} // End of namespace CGE
diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h
index 3ca2bababd..5023c2e657 100644
--- a/engines/cge/bitmaps.h
+++ b/engines/cge/bitmaps.h
@@ -25,22 +25,22 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __BITMAPS__
-#define __BITMAPS__
+#ifndef __BITMAPS__
+#define __BITMAPS__
-#include "cge/vga13h.h"
+#include "cge/vga13h.h"
namespace CGE {
#ifdef DEBUG
- extern BITMAP * MB[];
- extern BITMAP * HL[];
+extern BITMAP *MB[];
+extern BITMAP *HL[];
#endif
-extern BITMAP * MC[];
-extern BITMAP * PR[];
-extern BITMAP * SP[];
-extern BITMAP * LI[];
+extern BITMAP *MC[];
+extern BITMAP *PR[];
+extern BITMAP *SP[];
+extern BITMAP *LI[];
} // End of namespace CGE
diff --git a/engines/cge/boot.h b/engines/cge/boot.h
index bc78b0e7fb..ab4dcde0e2 100644
--- a/engines/cge/boot.h
+++ b/engines/cge/boot.h
@@ -25,54 +25,54 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __BOOT__
-#define __BOOT__
+#ifndef __BOOT__
+#define __BOOT__
-#include "cge/jbw.h"
+#include "cge/jbw.h"
namespace CGE {
-#define BOOTSECT_SIZ 512
-#define BOOTHEAD_SIZ 62
-#define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ
-#define FreeBoot(b) free(b)
+#define BOOTSECT_SIZ 512
+#define BOOTHEAD_SIZ 62
+#define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ
+#define FreeBoot(b) free(b)
-#ifndef EC
- #define EC
+#ifndef EC
+#define EC
#endif
typedef struct {
- uint8 Jmp[3]; // NEAR jump machine code
- char OEM_ID[8]; // OEM name and version
- uint16 SectSize; // bytes per sector
- uint8 ClustSize; // sectors per cluster
- uint16 ResSecs; // sectors before 1st FAT
- uint8 FatCnt; // number of FATs
- uint16 RootSize; // root directory entries
- uint16 TotSecs; // total sectors on disk
- uint8 Media; // media descriptor byte
- uint16 FatSize; // sectors per FAT
- uint16 TrkSecs; // sectors per track
- uint16 HeadCnt; // number of sufraces
- uint16 HidnSecs; // special hidden sectors
- uint16 _; // (unknown: reserved?)
- uint32 lTotSecs; // total number of sectors
- uint16 DriveNum; // physical drive number
- uint8 XSign; // extended boot signature
- uint32 Serial; // volume serial number
- char Label[11]; // volume label
- char FileSysID[8]; // file system ID
- char Code[BOOTCODE_SIZ-8]; // 8 = length of following
- uint32 Secret; // long secret number
- uint8 BootCheck; // boot sector checksum
- uint8 BootFlags; // secret flags
- uint16 BootSig; // boot signature 0xAA55
- } Boot;
+ uint8 Jmp[3]; // NEAR jump machine code
+ char OEM_ID[8]; // OEM name and version
+ uint16 SectSize; // bytes per sector
+ uint8 ClustSize; // sectors per cluster
+ uint16 ResSecs; // sectors before 1st FAT
+ uint8 FatCnt; // number of FATs
+ uint16 RootSize; // root directory entries
+ uint16 TotSecs; // total sectors on disk
+ uint8 Media; // media descriptor byte
+ uint16 FatSize; // sectors per FAT
+ uint16 TrkSecs; // sectors per track
+ uint16 HeadCnt; // number of sufraces
+ uint16 HidnSecs; // special hidden sectors
+ uint16 _; // (unknown: reserved?)
+ uint32 lTotSecs; // total number of sectors
+ uint16 DriveNum; // physical drive number
+ uint8 XSign; // extended boot signature
+ uint32 Serial; // volume serial number
+ char Label[11]; // volume label
+ char FileSysID[8]; // file system ID
+ char Code[BOOTCODE_SIZ - 8]; // 8 = length of following
+ uint32 Secret; // long secret number
+ uint8 BootCheck; // boot sector checksum
+ uint8 BootFlags; // secret flags
+ uint16 BootSig; // boot signature 0xAA55
+} Boot;
-EC Boot * ReadBoot (int drive);
-EC uint8 CheckBoot (Boot * boot);
-EC bool WriteBoot (int drive, Boot * boot);
+EC Boot *ReadBoot(int drive);
+EC uint8 CheckBoot(Boot *boot);
+EC bool WriteBoot(int drive, Boot *boot);
} // End of namespace CGE
diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp
index 7c61157eba..b5e59e0988 100644
--- a/engines/cge/btfile.cpp
+++ b/engines/cge/btfile.cpp
@@ -25,173 +25,125 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/btfile.h"
-//#include <alloc.h>
+#include "cge/btfile.h"
#include "common/system.h"
#include "common/str.h"
-#include <string.h>
+#include <string.h>
namespace CGE {
-#ifndef BT_SIZE
- #define BT_SIZE K(1)
+#ifndef BT_SIZE
+#define BT_SIZE K(1)
#endif
-#ifndef BT_KEYLEN
- #define BT_KEYLEN 13
+#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)
- error("No core");
- }
+BTFILE::BTFILE(const char *name, IOMODE mode, CRYPT *crpt)
+ : IOHAND(name, mode, crpt) {
+ for (int 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)
+ error("No core");
+ }
}
-
-
-
-
-
-
-
-BTFILE::~BTFILE (void)
-{
- int i;
- for (i = 0; i < BT_LEVELS; i ++)
- {
- PutPage(i);
- delete Buff[i].Page;
- }
+BTFILE::~BTFILE(void) {
+ for (int 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;
- }
+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;
+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;
+ memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data));
+ Buff[lev].Updt = TRUE;
+ }
+ Buff[lev].Indx = -1;
}
- else
- {
- Buff[lev].Page->Hea.Count = 0;
- Buff[lev].Page->Hea.Down = BT_NONE;
- memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data));
- Buff[lev].Updt = TRUE;
- }
- Buff[lev].Indx = -1;
- }
- return Buff[lev].Page;
+ return Buff[lev].Page;
}
-
-
-
-BT_KEYPACK * BTFILE::Find (const char * 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 (memicmp(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;
+BT_KEYPACK *BTFILE::Find(const char *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 (memicmp(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 (scumm_stricmp((const char *)key, (const char *)pg->Lea[i].Key) <= 0)
+ break;
+ Buff[lev].Indx = i;
+ return &pg->Lea[i];
+ }
}
- else
- {
- int i;
- for (i = 0; i < pg->Hea.Count-1; i ++)
- if (scumm_stricmp((const char*)key, (const char*)pg->Lea[i].Key) <= 0)
- break;
- Buff[lev].Indx = i;
- return &pg->Lea[i];
- }
- }
- return NULL;
+ return NULL;
}
-
-
-int keycomp (const void * k1, const void * k2)
-{
- return memicmp(k1, k2, BT_KEYLEN);
+int keycomp(const void *k1, const void *k2) {
+ return memicmp(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
- memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN);
- Root->Inn[Root->Hea.Count ++].Down = n;
- Buff[0].Updt = TRUE;
+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
+ memcpy(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;
}
- 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
index 0df9636573..c55891cae4 100644
--- a/engines/cge/btfile.h
+++ b/engines/cge/btfile.h
@@ -25,73 +25,62 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __BTFILE__
-#define __BTFILE__
+#ifndef __BTFILE__
+#define __BTFILE__
-#include "cge/general.h"
+#include "cge/general.h"
namespace CGE {
-#define BT_SIZE K(1)
-#define BT_KEYLEN 13
-#define BT_LEVELS 2
+#define BT_SIZE K(1)
+#define BT_KEYLEN 13
+#define BT_LEVELS 2
-#define BT_NONE 0xFFFF
-#define BT_ROOT 0
+#define BT_NONE 0xFFFF
+#define BT_ROOT 0
-struct BT_KEYPACK
-{
- char Key[BT_KEYLEN];
- uint32 Mark;
- uint16 Size;
+struct BT_KEYPACK {
+ char 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)];
- };
+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);
+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 char * key);
- BT_KEYPACK * Next(void);
- void Make(BT_KEYPACK * keypack, uint16 count);
+ BTFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL);
+ virtual ~BTFILE(void);
+ BT_KEYPACK *Find(const char *key);
+ BT_KEYPACK *Next(void);
+ void Make(BT_KEYPACK *keypack, uint16 count);
};
} // End of namespace CGE
diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp
index fdbd6ad315..7c4f689e30 100644
--- a/engines/cge/cfile.cpp
+++ b/engines/cge/cfile.cpp
@@ -25,334 +25,239 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/cfile.h"
-#include <dos.h>
-#include <fcntl.h>
-#include <string.h>
+#include "cge/cfile.h"
+#include <dos.h>
+#include <fcntl.h>
+#include <string.h>
#include "common/system.h"
namespace CGE {
-IOBUF::IOBUF (IOMODE mode, CRYPT * crpt)
-: IOHAND(mode, crpt),
- BufMark(0),
- Ptr(0),
- Lim(0)
-{
- Buff = farnew(uint8, IOBUF_SIZE);
- if (Buff == NULL)
- error("No core for I/O");
+IOBUF::IOBUF(IOMODE mode, CRYPT *crpt)
+ : IOHAND(mode, crpt),
+ BufMark(0),
+ Ptr(0),
+ Lim(0) {
+ Buff = farnew(uint8, IOBUF_SIZE);
+ if (Buff == NULL)
+ error("No core for I/O");
}
-
-
-
-
-
-
-
-IOBUF::IOBUF (const char * name, IOMODE mode, CRYPT * crpt)
-: IOHAND(name, mode, crpt),
- BufMark(0),
- Ptr(0),
- Lim(0)
-{
- Buff = farnew(uint8, IOBUF_SIZE);
- if (Buff == NULL)
- error("No core for I/O [%s]", name);
+IOBUF::IOBUF(const char *name, IOMODE mode, CRYPT *crpt)
+ : IOHAND(name, mode, crpt),
+ BufMark(0),
+ Ptr(0),
+ Lim(0) {
+ Buff = farnew(uint8, IOBUF_SIZE);
+ if (Buff == NULL)
+ error("No core for I/O [%s]", name);
}
-
-
-
-
-
-
-
-
-IOBUF::~IOBUF (void)
-{
- if (Mode > REA) WriteBuff();
- if (Buff) free(Buff);
+IOBUF::~IOBUF(void) {
+ if (Mode > REA)
+ WriteBuff();
+ if (Buff)
+ free(Buff);
}
-
-
-
-
-void IOBUF::ReadBuff (void)
-{
- BufMark = IOHAND::Mark();
- Lim = IOHAND::Read(Buff, IOBUF_SIZE);
- Ptr = 0;
+void IOBUF::ReadBuff(void) {
+ BufMark = IOHAND::Mark();
+ Lim = IOHAND::Read(Buff, IOBUF_SIZE);
+ Ptr = 0;
}
-
-
-
-void IOBUF::WriteBuff (void)
-{
- if (Lim)
- {
- IOHAND::Write(Buff, Lim);
- BufMark = IOHAND::Mark();
- Lim = 0;
- }
+void IOBUF::WriteBuff(void) {
+ if (Lim) {
+ IOHAND::Write(Buff, Lim);
+ BufMark = IOHAND::Mark();
+ Lim = 0;
+ }
}
-
-
-
-uint16 IOBUF::Read (void *buf, uint16 len)
-{
- uint16 total = 0;
- while (len)
- {
- if (Ptr >= Lim) ReadBuff();
- uint16 n = Lim - Ptr;
- if (n)
- {
- if (len < n) n = len;
- memcpy(buf, Buff+Ptr, n);
- buf = (uint8 *)buf + n;
- len -= n;
- total += n;
- Ptr += n;
+uint16 IOBUF::Read(void *buf, uint16 len) {
+ uint16 total = 0;
+ while (len) {
+ if (Ptr >= Lim)
+ ReadBuff();
+ uint16 n = Lim - Ptr;
+ if (n) {
+ if (len < n)
+ n = len;
+ memcpy(buf, Buff + Ptr, n);
+ buf = (uint8 *)buf + n;
+ len -= n;
+ total += n;
+ Ptr += n;
+ } else
+ break;
}
- else break;
- }
- return total;
+ return total;
}
-
-
-
-
-uint16 IOBUF::Read (uint8 * buf)
-{
- uint16 total = 0;
-
- while (total < LINE_MAX-2)
- {
- if (Ptr >= Lim) ReadBuff();
- uint8 * p = Buff + Ptr;
- uint16 n = Lim - Ptr;
- if (n)
- {
- if (total + n >= LINE_MAX-2) n = LINE_MAX-2 - total;
- uint8 * eol = (uint8 *) memchr(p, '\r', n);
- if (eol) n = (uint16) (eol - p);
- uint8 * eof = (uint8 *) memchr(p, '\32', n);
- if (eof) // end-of-file
- {
- n = (uint16) (eof - p);
- Ptr = (uint16) (eof - Buff);
- }
- if (n) memcpy(buf, p, n);
- buf += n;
- total += n;
- if (eof) break;
- Ptr += n;
- if (eol)
- {
- ++ Ptr;
- * (buf ++) = '\n';
- ++ total;
- if (Ptr >= Lim) ReadBuff();
- if (Ptr < Lim) if (Buff[Ptr] == '\n') ++ Ptr;
- break;
- }
+uint16 IOBUF::Read(uint8 *buf) {
+ uint16 total = 0;
+
+ while (total < LINE_MAX - 2) {
+ if (Ptr >= Lim)
+ ReadBuff();
+ uint8 *p = Buff + Ptr;
+ uint16 n = Lim - Ptr;
+ if (n) {
+ if (total + n >= LINE_MAX - 2)
+ n = LINE_MAX - 2 - total;
+ uint8 *eol = (uint8 *) memchr(p, '\r', n);
+ if (eol)
+ n = (uint16)(eol - p);
+ uint8 *eof = (uint8 *) memchr(p, '\32', n);
+ if (eof) { // end-of-file
+ n = (uint16)(eof - p);
+ Ptr = (uint16)(eof - Buff);
+ }
+ if (n)
+ memcpy(buf, p, n);
+ buf += n;
+ total += n;
+ if (eof)
+ break;
+ Ptr += n;
+ if (eol) {
+ ++ Ptr;
+ * (buf ++) = '\n';
+ ++ total;
+ if (Ptr >= Lim)
+ ReadBuff();
+ if (Ptr < Lim)
+ if (Buff[Ptr] == '\n')
+ ++Ptr;
+ break;
+ }
+ } else
+ break;
}
- else break;
- }
- *buf = '\0';
- return total;
+ *buf = '\0';
+ return total;
}
-
-
-
-
-
-uint16 IOBUF::Write (void * buf, uint16 len)
-{
- uint16 tot = 0;
- while (len)
- {
- uint16 n = IOBUF_SIZE - Lim;
- if (n > len) n = len;
- if (n)
- {
- memcpy(Buff+Lim, buf, n);
- Lim += n;
- len -= n;
- buf = (uint8 *)buf + n;
- tot += n;
+uint16 IOBUF::Write(void *buf, uint16 len) {
+ uint16 tot = 0;
+ while (len) {
+ uint16 n = IOBUF_SIZE - Lim;
+ if (n > len)
+ n = len;
+ if (n) {
+ memcpy(Buff + Lim, buf, n);
+ Lim += n;
+ len -= n;
+ buf = (uint8 *)buf + n;
+ tot += n;
+ } else
+ WriteBuff();
}
- else WriteBuff();
- }
- return tot;
+ return tot;
}
-
-
-
-
-uint16 IOBUF::Write (uint8 * buf)
-{
- uint16 len = 0;
- if (buf)
- {
- len = strlen((const char *) buf);
- if (len) if (buf[len-1] == '\n') -- len;
- len = Write(buf, len);
- if (len)
- {
- static char EOL[] = "\r\n";
- uint16 n = Write(EOL, sizeof(EOL)-1);
- len += n;
+uint16 IOBUF::Write(uint8 *buf) {
+ uint16 len = 0;
+ if (buf) {
+ len = strlen((const char *) buf);
+ if (len)
+ if (buf[len - 1] == '\n')
+ --len;
+ len = Write(buf, len);
+ if (len) {
+ static char EOL[] = "\r\n";
+ uint16 n = Write(EOL, sizeof(EOL) - 1);
+ len += n;
+ }
}
- }
- return len;
+ return len;
}
-
-
-
-
-int IOBUF::Read (void)
-{
- if (Ptr >= Lim)
- {
- ReadBuff();
- if (Lim == 0) return -1;
- }
- return Buff[Ptr ++];
+int IOBUF::Read(void) {
+ if (Ptr >= Lim) {
+ ReadBuff();
+ if (Lim == 0)
+ return -1;
+ }
+ return Buff[Ptr ++];
}
-
-
-
-
-void IOBUF::Write (uint8 b)
-{
- if (Lim >= IOBUF_SIZE)
- {
- WriteBuff();
- }
- Buff[Lim ++] = b;
+void IOBUF::Write(uint8 b) {
+ if (Lim >= IOBUF_SIZE)
+ WriteBuff();
+ Buff[Lim ++] = b;
}
+uint16 CFILE::MaxLineLen = LINE_MAX;
-
-
- uint16 CFILE::MaxLineLen = LINE_MAX;
-
-
-
-
-
-
-
-
-CFILE::CFILE (const char * name, IOMODE mode, CRYPT * crpt)
-: IOBUF(name, mode, crpt)
-{
+CFILE::CFILE(const char *name, IOMODE mode, CRYPT *crpt)
+ : IOBUF(name, mode, crpt) {
}
-
-
-
-
-
-
-
-CFILE::~CFILE (void)
-{
+CFILE::~CFILE(void) {
}
+void CFILE::Flush(void) {
+ if (Mode > REA)
+ WriteBuff();
+ else
+ Lim = 0;
-
-
-
-void CFILE::Flush (void)
-{
- if (Mode > REA) WriteBuff();
- else Lim = 0;
-
- /*
- _BX = Handle;
- _AH = 0x68; // Flush buffer
- asm int 0x21
- */
- warning("FIXME: CFILE::Flush");
+ /*
+ _BX = Handle;
+ _AH = 0x68; // Flush buffer
+ asm int 0x21
+ */
+ warning("FIXME: CFILE::Flush");
}
-
-
-
-long CFILE::Mark (void)
-{
- return BufMark + ((Mode > REA) ? Lim : Ptr);
+long CFILE::Mark(void) {
+ return BufMark + ((Mode > REA) ? Lim : Ptr);
}
-
-
-
-long CFILE::Seek (long pos)
-{
- if (pos >= BufMark && pos < BufMark + Lim)
- {
- ((Mode == REA) ? Ptr : Lim) = (uint16) (pos - BufMark);
- return pos;
- }
- else
- {
- if (Mode > REA)
- {
- WriteBuff();
+long CFILE::Seek(long pos) {
+ if (pos >= BufMark && pos < BufMark + Lim) {
+ ((Mode == REA) ? Ptr : Lim) = (uint16)(pos - BufMark);
+ return pos;
+ } else {
+ if (Mode > REA)
+ WriteBuff();
+ else
+ Lim = 0;
+
+ Ptr = 0;
+ return BufMark = IOHAND::Seek(pos);
}
- else
- {
- Lim = 0;
- }
- Ptr = 0;
- return BufMark = IOHAND::Seek(pos);
- }
}
-
-
-
-
-void CFILE::Append (CFILE& f)
-{
- Seek(Size());
- if (f.Error == 0)
- {
- while (true)
- {
- if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) WriteBuff();
- else break;
- if ((Error = f.Error) != 0) break;
+void CFILE::Append(CFILE &f) {
+ Seek(Size());
+ if (f.Error == 0) {
+ while (true) {
+ if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE)
+ WriteBuff();
+ else
+ break;
+ if ((Error = f.Error) != 0)
+ break;
+ }
}
- }
}
} // End of namespace CGE
diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h
index e8d494c2f9..d2d5320ae5 100644
--- a/engines/cge/cfile.h
+++ b/engines/cge/cfile.h
@@ -25,59 +25,54 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __CFILE__
-#define __CFILE__
+#ifndef __CFILE__
+#define __CFILE__
-#include "cge/general.h"
-#include <io.h>
+#include "cge/general.h"
+#include <io.h>
namespace CGE {
-#define LINE_MAX 512
+#define LINE_MAX 512
-#ifndef IOBUF_SIZE
- #define IOBUF_SIZE K(2)
+#ifndef IOBUF_SIZE
+#define IOBUF_SIZE K(2)
#endif
-#define CFREAD(x) Read((uint8 *)(x),sizeof(*(x)))
+#define CFREAD(x) Read((uint8 *)(x),sizeof(*(x)))
-
-
-class IOBUF : public IOHAND
-{
+class IOBUF : public IOHAND {
protected:
- uint8 * Buff;
- uint16 Ptr, Lim;
- long BufMark;
- uint16 Seed;
- CRYPT * Crypt;
- virtual void ReadBuff (void);
- virtual void WriteBuff (void);
+ uint8 *Buff;
+ uint16 Ptr, Lim;
+ long BufMark;
+ uint16 Seed;
+ CRYPT *Crypt;
+ virtual void ReadBuff(void);
+ virtual void WriteBuff(void);
public:
- IOBUF (IOMODE mode, CRYPT * crpt = NULL);
- IOBUF (const char * name, IOMODE mode, CRYPT * crpt = NULL);
- virtual ~IOBUF (void);
- uint16 Read (void * buf, uint16 len);
- uint16 Read (uint8 * buf);
- int Read (void);
- uint16 Write (void * buf, uint16 len);
- uint16 Write (uint8 * buf);
- void Write (uint8 b);
+ IOBUF(IOMODE mode, CRYPT *crpt = NULL);
+ IOBUF(const char *name, IOMODE mode, CRYPT *crpt = NULL);
+ virtual ~IOBUF(void);
+ uint16 Read(void *buf, uint16 len);
+ uint16 Read(uint8 *buf);
+ int Read(void);
+ uint16 Write(void *buf, uint16 len);
+ uint16 Write(uint8 *buf);
+ void Write(uint8 b);
};
-
-class CFILE : public IOBUF
-{
+class CFILE : public IOBUF {
public:
- static uint16 MaxLineLen;
- CFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL);
- virtual ~CFILE (void);
- void Flush (void);
- long Mark (void);
- long Seek (long pos);
- void Append (CFILE& f);
+ static uint16 MaxLineLen;
+ CFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL);
+ virtual ~CFILE(void);
+ void Flush(void);
+ long Mark(void);
+ long Seek(long pos);
+ void Append(CFILE &f);
};
} // End of namespace CGE
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index 5613c3bb68..0d0df4ea9c 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -21,7 +21,6 @@
*/
#include "common/scummsys.h"
-
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/debug-channels.h"
@@ -29,43 +28,41 @@
#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
-
#include "engines/util.h"
-
#include "cge/cge.h"
#include "cge/cge_main.h"
-
+
namespace CGE {
-
+
CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription)
- : Engine(syst), _gameDescription(gameDescription) {
-
+ : Engine(syst), _gameDescription(gameDescription) {
+
DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel");
- _console = new CGEConsole(this);
+ _console = new CGEConsole(this);
debug("CGEEngine::CGEEngine");
}
-
+
CGEEngine::~CGEEngine() {
debug("CGEEngine::~CGEEngine");
-
+
// Remove all of our debug levels here
DebugMan.clearAllDebugChannels();
}
-
+
Common::Error CGEEngine::run() {
// Initialize graphics using following:
initGraphics(320, 200, false);
-
- // Create debugger console. It requires GFX to be initialized
+
+ // Create debugger console. It requires GFX to be initialized
_console = new CGEConsole(this);
-
+
// Additional setup.
debug("CGEEngine::init");
-
+
cge_main();
-
+
return Common::kNoError;
}
-
+
} // End of namespace CGE
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index cb2c507ffa..c6d9a099bf 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -22,7 +22,7 @@
#ifndef CGE_H
#define CGE_H
-
+
#include "common/random.h"
#include "engines/engine.h"
#include "gui/debugger.h"
@@ -33,12 +33,12 @@
#define CGE_SAVEGAME_VERSION 1
namespace CGE {
-
+
class Console;
-
+
// our engine debug channels
enum {
- kCGEDebug = 1 << 0
+ kCGEDebug = 1 << 0
};
class CGEEngine : public Engine {
@@ -49,19 +49,21 @@ public:
const ADGameDescription *_gameDescription;
virtual Common::Error run();
- GUI::Debugger *getDebugger() { return _console; }
-
+ GUI::Debugger *getDebugger() {
+ return _console;
+ }
+
private:
CGEConsole *_console;
};
-
+
// Example console class
class Console : public GUI::Debugger {
public:
Console(CGEEngine *vm) {}
virtual ~Console(void) {}
};
-
+
} // End of namespace CGE
-
+
#endif
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index cdbb94f785..62936e8c9c 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -25,57 +25,57 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#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"
-#include "cge/mouse.h"
-#include "cge/keybd.h"
-#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 <conio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dos.h>
-#include <fcntl.h>
-#include <io.h>
+#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"
+#include "cge/mouse.h"
+#include "cge/keybd.h"
+#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 <conio.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dos.h>
+#include <fcntl.h>
+#include <io.h>
#include "common/str.h"
namespace CGE {
-#define STACK_SIZ (K(2))
-#define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText)
+#define STACK_SIZ (K(2))
+#define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText)
-#ifdef DEMO
- #ifdef DEBUG
- #define SVG0NAME ("{{INIT}}" SVG_EXT)
- #else
- #define SVG0NAME (ProgName(SVG_EXT))
- #endif
+#ifdef DEMO
+#ifdef DEBUG
+#define SVG0NAME ("{{INIT}}" SVG_EXT)
+#else
+#define SVG0NAME (ProgName(SVG_EXT))
+#endif
#else
- #define SVG0NAME ("{{INIT}}" SVG_EXT)
+#define SVG0NAME ("{{INIT}}" SVG_EXT)
#endif
-#ifdef DEBUG
- #define SVG0FILE CFILE
+#ifdef DEBUG
+#define SVG0FILE CFILE
#else
- #define SVG0FILE INI_FILE
+#define SVG0FILE INI_FILE
#endif
-extern uint16 _stklen = (STACK_SIZ * 2);
+extern uint16 _stklen = (STACK_SIZ * 2);
// 0.75 - 17II95 - full sound support
// 0.76 - 18II95 - small MiniEMS in DEMO,
@@ -86,1715 +86,1398 @@ extern uint16 _stklen = (STACK_SIZ * 2);
// coditionals EVA for 2-month evaluation version
/*
- char Copr[] = "Common Game Engine "
- #ifdef EVA
- "ú"
- #else
- #ifdef CD
- "ù"
- #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";
+ char Copr[] = "Common Game Engine "
+ #ifdef EVA
+ "ú"
+ #else
+ #ifdef CD
+ "ù"
+ #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";
*/
- char Copr[] = "To be fixed - Copr[]";
+char Copr[] = "To be fixed - Copr[]";
-static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ";
-static int OldLev = 0;
-static int DemoText = DEMO_TEXT;
+static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ";
+static int OldLev = 0;
+static int DemoText = DEMO_TEXT;
//--------------------------------------------------------------------------
- bool JBW = false;
- DAC *SysPal = farnew(DAC, PAL_CNT);
+bool JBW = false;
+DAC *SysPal = farnew(DAC, PAL_CNT);
//-------------------------------------------------------------------------
- SPRITE PocLight = LI;
- SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, };
- int PocPtr = 0;
-//-------------------------------------------------------------------------
-//extern SPRITE * PocLight;
-//extern SPRITE * Pocket[];
-//extern int PocPtr;
-//-------------------------------------------------------------------------
+SPRITE PocLight = LI;
+SPRITE *Pocket[POCKET_NX] = { NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ };
+int PocPtr = 0;
- MOUSE Mouse;
-static SPRITE * Sprite = NULL;
-static SPRITE * MiniCave = NULL;
-static SPRITE * Shadow = NULL;
+MOUSE Mouse;
+static SPRITE *Sprite = NULL;
+static SPRITE *MiniCave = NULL;
+static SPRITE *Shadow = NULL;
-static VGA Vga = M13H;
-static EMS * Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE);
-static BMP_PTR * MiniShpList = NULL;
-static BMP_PTR MiniShp[] = { NULL, NULL };
-static KEYBOARD Keyboard;
-static bool Finis = false;
-static int Startup = 1;
-static int OffUseCount = atoi(Text[OFF_USE_COUNT]);
- uint16 *intStackPtr = false;
+static VGA Vga = M13H;
+static EMS *Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE);
+static BMP_PTR *MiniShpList = NULL;
+static BMP_PTR MiniShp[] = { NULL, NULL };
+static KEYBOARD Keyboard;
+static bool Finis = false;
+static int Startup = 1;
+static int OffUseCount = atoi(Text[OFF_USE_COUNT]);
+uint16 *intStackPtr = false;
- HXY HeroXY[CAVE_MAX] = {{0,0}};
- BAR Barriers[1+CAVE_MAX] = { { 0xFF, 0xFF } };
+HXY HeroXY[CAVE_MAX] = {{0, 0}};
+BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } };
-extern int FindPocket (SPRITE *);
+extern int FindPocket(SPRITE *);
-extern DAC StdPal[58];
+extern DAC StdPal[58];
-#ifdef DEBUG
-static SPRITE HorzLine = HL;
+#ifdef DEBUG
+static SPRITE HorzLine = HL;
#endif
+void FeedSnail(SPRITE *spr, SNLIST snq); // defined in SNAIL
+uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT];
-void FeedSnail (SPRITE * spr, SNLIST snq); // defined in SNAIL
-
-//--------------------------------------------------------------------------
-
-
-
-
-uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT];
-
-
-
-uint8 & CLUSTER::Cell (void)
-{
- return Map[B][A];
+uint8 &CLUSTER::Cell(void) {
+ return Map[B][A];
}
+bool CLUSTER::Protected(void) {
+/*
+ if (A == Barriers[Now].Vert || B == Barriers[Now].Horz)
+ return true;
+ _DX = (MAP_ZCNT << 8) + MAP_XCNT;
+ _BX = (uint16) this;
+ 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
+ asm cmp cl,dl
+ asm jge xit
+ asm cmp ch,dh
+ asm jge xit
+ // if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true;
+ 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
-bool CLUSTER::Protected (void)
-{
- if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return true;
- warning("STUB: CLUSTER::Protected()");
- /*
- _DX = (MAP_ZCNT << 8) + MAP_XCNT;
- _BX = (uint16) this;
-
- 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
-
- asm cmp cl,dl
- asm jge xit
- asm cmp ch,dh
- asm jge xit
-
-// if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true;
-
- 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
+ // return Map[B][A] != 0;
-// return Map[B][A] != 0;
+ xit: return _AX;
+ */
- xit: return _AX;
- */
- return TRUE;
+ warning("STUB: CLUSTER::Protected()");
+ return TRUE;
}
+CLUSTER XZ(int x, int y) {
+ if (y < MAP_TOP)
+ y = MAP_TOP;
+ if (y > MAP_TOP + MAP_HIG - MAP_ZGRID)
+ y = MAP_TOP + MAP_HIG - MAP_ZGRID;
-
-CLUSTER XZ (int x, int y)
-{
- if (y < MAP_TOP) y = MAP_TOP;
- if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) y = MAP_TOP + MAP_HIG - MAP_ZGRID;
- return CLUSTER(x / MAP_XGRID, (y-MAP_TOP) / MAP_ZGRID);
+ return CLUSTER(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID);
}
-
-
-CLUSTER XZ (COUPLE xy)
-{
- signed char x, y;
- xy.Split(x, y);
- return XZ(x, y);
+CLUSTER XZ(COUPLE xy) {
+ signed char x, y;
+ xy.Split(x, y);
+ return XZ(x, y);
}
+int pocref[POCKET_NX];
+uint8 volume[2];
+struct SAVTAB {
+ void *Ptr;
+ int Len;
+ uint8 Flg;
+} SavTab[] = {
+ { &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
+ { &VGA::Mono, sizeof(VGA::Mono), 0 },
+ { &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 }
+};
+static void LoadGame(XFILE &file, bool tiny = false) {
+ SAVTAB *st;
+ SPRITE *spr;
+ int i;
+ for (st = SavTab; st->Ptr; st ++) {
+ if (file.Error)
+ error("Bad SVG");
+ file.Read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len);
+ }
-//--------------------------------------------------------------------------
-
-
- int pocref[POCKET_NX];
- uint8 volume[2];
- struct SAVTAB { void * Ptr; int Len; uint8 Flg; } SavTab[] =
- {{ &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
- { &VGA::Mono, sizeof(VGA::Mono), 0 },
- { &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 } };
-
-
-
+ file.Read((uint8 *) &i, sizeof(i));
+ if (i != SVGCHKSUM)
+ error(Text[BADSVG_TEXT]);
+ if (STARTUP::Core < CORE_HIG)
+ Music = false;
-static void LoadGame (XFILE& file, bool tiny = false)
-{
- SAVTAB * st;
- SPRITE * spr;
- int i;
-
- for (st = SavTab; st->Ptr; st ++)
- {
- if (file.Error)
- error("Bad SVG");
- file.Read((uint8 *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len);
- }
-
- file.Read((uint8 *) &i, sizeof(i));
- if (i != SVGCHKSUM)
- error(Text[BADSVG_TEXT]);
- if (STARTUP::Core < CORE_HIG) Music = false;
- if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) {
- SNDDrvInfo.VOL2.D = volume[0];
- SNDDrvInfo.VOL2.M = volume[1];
- SNDSetVolume();
- }
-
- if (! tiny) // load sprites & pocket
- {
- while (! file.Error)
- {
- SPRITE S(NULL);
- uint16 n = file.Read((uint8 *) &S, sizeof(S));
-
- if (n != sizeof(S)) break;
- S.Prev = S.Next = NULL;
- spr = (scumm_stricmp(S.File+2, "MUCHA") == 0) ? new FLY(NULL)
- : new SPRITE(NULL);
- if (spr == NULL)
- error("No core");
- *spr = S;
- VGA::SpareQ.Append(spr);
+ if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) {
+ SNDDrvInfo.VOL2.D = volume[0];
+ SNDDrvInfo.VOL2.M = volume[1];
+ SNDSetVolume();
}
- for (i = 0; i < POCKET_NX; i ++)
- {
- register int r = pocref[i];
- Pocket[i] = (r < 0) ? NULL : VGA::SpareQ.Locate(r);
+ if (! tiny) { // load sprites & pocket
+ while (! file.Error) {
+ SPRITE S(NULL);
+ uint16 n = file.Read((uint8 *) &S, sizeof(S));
+
+ if (n != sizeof(S))
+ break;
+
+ S.Prev = S.Next = NULL;
+ spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(NULL)
+ : new SPRITE(NULL);
+ if (spr == NULL)
+ error("No core");
+ *spr = S;
+ VGA::SpareQ.Append(spr);
+ }
+
+ for (i = 0; i < POCKET_NX; i ++) {
+ register int r = pocref[i];
+ Pocket[i] = (r < 0) ? NULL : VGA::SpareQ.Locate(r);
+ }
}
- }
}
-
-
-static void SaveSound (void)
-{
- CFILE cfg(UsrPath(ProgName(CFG_EXT)), WRI);
- if (! cfg.Error) cfg.Write(&SNDDrvInfo,sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2));
+static void SaveSound(void) {
+ CFILE cfg(UsrPath(ProgName(CFG_EXT)), WRI);
+ if (! cfg.Error) cfg.Write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2));
}
+static void SaveGame(XFILE &file) {
+ SAVTAB *st;
+ SPRITE *spr;
+ int i;
+ for (i = 0; i < POCKET_NX; i ++) {
+ register SPRITE *s = Pocket[i];
+ pocref[i] = (s) ? s->Ref : -1;
+ }
+ volume[0] = SNDDrvInfo.VOL2.D;
+ volume[1] = SNDDrvInfo.VOL2.M;
+ for (st = SavTab; st->Ptr; st ++) {
+ if (file.Error)
+ error("Bad SVG");
+ file.Write((uint8 *) st->Ptr, st->Len);
+ }
-static void SaveGame (XFILE& file)
-{
- SAVTAB * st;
- SPRITE * spr;
- int i;
-
- for (i = 0; i < POCKET_NX; i ++)
- {
- register SPRITE * s = Pocket[i];
- pocref[i] = (s) ? s->Ref : -1;
- }
-
- volume[0] = SNDDrvInfo.VOL2.D;
- volume[1] = SNDDrvInfo.VOL2.M;
-
- for (st = SavTab; st->Ptr; st ++)
- {
- if (file.Error)
- error("Bad SVG");
- file.Write((uint8 *) st->Ptr, st->Len);
- }
-
- file.Write((uint8 *) &(i = SVGCHKSUM), sizeof(i));
+ file.Write((uint8 *) & (i = SVGCHKSUM), sizeof(i));
- for (spr = VGA::SpareQ.First(); spr; spr = spr->Next)
- if (spr->Ref >= 1000)
- if (!file.Error) file.Write((uint8 *)spr, sizeof(*spr));
+ for (spr = VGA::SpareQ.First(); spr; spr = spr->Next)
+ if (spr->Ref >= 1000)
+ if (!file.Error)
+ file.Write((uint8 *)spr, sizeof(*spr));
}
-
-
-
-
-
-static void HeroCover (int cvr)
-{
- SNPOST(SNCOVER, 1, cvr, NULL);
+static void HeroCover(int cvr) {
+ SNPOST(SNCOVER, 1, cvr, NULL);
}
-
-
-static void Trouble (int seq, int txt)
-{
- Hero->Park();
- 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);
+static void Trouble(int seq, int txt) {
+ Hero->Park();
+ 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);
}
-
-static void OffUse (void)
-{
- Trouble(OFF_USE, OFF_USE_TEXT+new_random(OffUseCount));
+static void OffUse(void) {
+ Trouble(OFF_USE, OFF_USE_TEXT + new_random(OffUseCount));
}
-
-
-static void TooFar (void)
-{
- Trouble(TOO_FAR, TOO_FAR_TEXT);
+static void TooFar(void) {
+ Trouble(TOO_FAR, TOO_FAR_TEXT);
}
-
-
-static void NoWay (void)
-{
- Trouble(NO_WAY, NO_WAY_TEXT);
+static void NoWay(void) {
+ Trouble(NO_WAY, NO_WAY_TEXT);
}
-
-
-
-static void LoadHeroXY (void)
-{
- INI_FILE cf(ProgName(".HXY"));
- memset(HeroXY, 0, sizeof(HeroXY));
- if (! cf.Error) cf.CFREAD(&HeroXY);
+static void LoadHeroXY(void) {
+ INI_FILE cf(ProgName(".HXY"));
+ memset(HeroXY, 0, sizeof(HeroXY));
+ if (! cf.Error)
+ cf.CFREAD(&HeroXY);
}
-
-
-
-static void LoadMapping (void)
-{
- if (Now <= CAVE_MAX)
- {
- INI_FILE cf(ProgName(".TAB"));
- 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));
+static void LoadMapping(void) {
+ if (Now <= CAVE_MAX) {
+ INI_FILE cf(ProgName(".TAB"));
+ 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));
+ }
}
- }
}
+CLUSTER Trace[MAX_FIND_LEVEL];
+int FindLevel;
-
-
-//--------------------------------------------------------------------------
-
-CLUSTER Trace[MAX_FIND_LEVEL];
-int FindLevel;
-
-
-
-
-
-
-
-
-WALK::WALK (BMP_PTR * shpl)
-: SPRITE(shpl), Dir(NO_DIR), TracePtr(-1)
-{
+WALK::WALK(BMP_PTR *shpl)
+ : SPRITE(shpl), Dir(NO_DIR), TracePtr(-1) {
}
+void WALK::Tick(void) {
+ if (Flags.Hide)
+ return;
+ Here = XZ(X + W / 2, Y + H);
-
-void WALK::Tick (void)
-{
- if (Flags.Hide) return;
-
- Here = XZ(X+W/2, Y+H);
-
- if (Dir != NO_DIR)
- {
- SPRITE * spr;
- SYSTEM::FunTouch();
- for (spr = VGA::ShowQ.First(); spr; spr = spr->Next)
- {
- if (Distance(spr) < 2)
- {
- if (! spr->Flags.Near)
- {
- FeedSnail(spr, NEAR);
- spr->Flags.Near = true;
+ if (Dir != NO_DIR) {
+ SPRITE *spr;
+ SYSTEM::FunTouch();
+ for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) {
+ if (Distance(spr) < 2) {
+ if (! spr->Flags.Near) {
+ FeedSnail(spr, NEAR);
+ spr->Flags.Near = true;
+ }
+ } else spr->Flags.Near = false;
}
- }
- else spr->Flags.Near = false;
}
- }
- if (Flags.Hold || TracePtr < 0) Park();
- else
- {
- if (Here == Trace[TracePtr])
- {
- if (-- TracePtr < 0) Park();
+ if (Flags.Hold || TracePtr < 0)
+ Park();
+ else {
+ if (Here == Trace[TracePtr]) {
+ if (-- TracePtr < 0)
+ Park();
+ } else {
+ signed char dx, dz;
+ (Trace[TracePtr] - Here).Split(dx, dz);
+ DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN);
+ Turn(d);
+ }
}
- else
- {
- signed char dx, dz;
- (Trace[TracePtr] - Here).Split(dx, dz);
- DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN);
- Turn(d);
+ Step();
+ if ((Dir == WW && X <= 0) ||
+ (Dir == EE && X + W >= SCR_WID) ||
+ (Dir == SS && Y + W >= WORLD_HIG - 2))
+ Park();
+ else {
+ signed char x; // dummy var
+ Here.Split(x, Z); // take current Z position
+ SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue
}
- }
- Step();
- if ((Dir == WW && X <= 0) ||
- (Dir == EE && X + W >= SCR_WID) ||
- (Dir == SS && Y + W >= WORLD_HIG-2)) Park();
- else
- {
- signed char x; // dummy var
- Here.Split(x, Z); // take current Z position
- SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue
- }
}
+int WALK::Distance(SPRITE *spr) {
+ int dx, dz;
+ dx = spr->X - (X + W - WALKSIDE);
+ if (dx < 0)
+ dx = (X + WALKSIDE) - (spr->X + spr->W);
+ if (dx < 0)
+ dx = 0;
+ dx /= MAP_XGRID;
+ dz = spr->Z - Z;
+ if (dz < 0)
+ dz = - dz;
+ dx = dx * dx + dz * dz;
+ for (dz = 1; dz * dz < dx; dz ++)
+ ;
-int WALK::Distance (SPRITE * spr)
-{
- int dx, dz;
- dx = spr->X - (X+W-WALKSIDE);
- if (dx < 0) dx = (X+WALKSIDE) - (spr->X+spr->W);
- if (dx < 0) dx = 0;
- dx /= MAP_XGRID;
- dz = spr->Z - Z;
- if (dz < 0) dz = - dz;
- dx = dx * dx + dz * dz;
- for (dz = 1; dz * dz < dx; dz ++) ;
- return dz-1;
+ return dz - 1;
}
-
-
-
-
-
-
-
-
-void WALK::Turn (DIR d)
-{
- DIR dir = (Dir == NO_DIR) ? SS : Dir;
- if (d != Dir)
- {
- Step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d));
- Dir = d;
- }
+void WALK::Turn(DIR d) {
+ DIR dir = (Dir == NO_DIR) ? SS : Dir;
+ if (d != Dir) {
+ Step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d));
+ Dir = d;
+ }
}
+void WALK::Park(void) {
+ if (Time == 0)
+ ++Time;
-
-
-void WALK::Park (void)
-{
- if (Time == 0) ++ Time;
- if (Dir != NO_DIR)
- {
- Step(9 + 4 * Dir + Dir);
- Dir = NO_DIR;
- TracePtr = -1;
- }
+ if (Dir != NO_DIR) {
+ Step(9 + 4 * Dir + Dir);
+ Dir = NO_DIR;
+ TracePtr = -1;
+ }
}
-
-
-
-
-
-void WALK::FindWay (CLUSTER c)
-{
+void WALK::FindWay(CLUSTER c) {
warning("STUB: Find1Way");
-/*
- bool Find1Way(void);
- extern uint16 Target;
-
- if (c != Here)
- {
- for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel ++)
- {
- signed char x, z;
- Here.Split(x, z);
- Target = (z << 8) | x;
- c.Split(x, z);
- _CX = (z << 8) | x;
- if (Find1Way()) break;
+ /*
+ bool Find1Way(void);
+ extern uint16 Target;
+
+ if (c != Here) {
+ for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel ++) {
+ 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;
}
- TracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1);
- if (TracePtr < 0) NoWay();
- Time = 1;
- }
*/
}
-
-
-
-
-void WALK::FindWay (SPRITE * spr)
-{
- if (spr && spr != this)
- {
- int x = spr->X, z = spr->Z;
- if (spr->Flags.East) x += spr->W + W/2 - WALKSIDE;
- else x -= W/2 - WALKSIDE;
- FindWay(CLUSTER((x/MAP_XGRID),
- ((z < MAP_ZCNT-MAX_DISTANCE) ? (z+1)
- : (z-1))));
- }
+void WALK::FindWay(SPRITE *spr) {
+ if (spr && spr != this) {
+ int x = spr->X, z = spr->Z;
+ if (spr->Flags.East)
+ x += spr->W + W / 2 - WALKSIDE;
+ else
+ x -= W / 2 - WALKSIDE;
+ FindWay(CLUSTER((x / MAP_XGRID),
+ ((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1)
+ : (z - 1))));
+ }
}
-
-
-
-
-bool WALK::Lower (SPRITE * spr)
-{
- return (spr->Y > Y + (H * 3) / 5);
+bool WALK::Lower(SPRITE *spr) {
+ return (spr->Y > Y + (H * 3) / 5);
}
-
-
-
-
-void WALK::Reach (SPRITE * spr, int mode)
-{
- if (spr)
- {
- Hero->FindWay(spr);
- if (mode < 0)
- {
- mode = spr->Flags.East;
- if (Lower(spr)) mode += 2;
+void WALK::Reach(SPRITE *spr, int mode) {
+ if (spr) {
+ Hero->FindWay(spr);
+ if (mode < 0) {
+ mode = spr->Flags.East;
+ if (Lower(spr))
+ mode += 2;
+ }
+ }
+ // 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);
}
- }
- // 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);
- }
- // sequence is not finished,
- // now it is just at sprite appear (disappear) point
+ // sequence is not finished,
+ // now it is just at sprite appear (disappear) point
}
-
-
-
-
-//--------------------------------------------------------------------------
-
-
-
#ifdef DEBUG
-
-class SQUARE : public SPRITE
-{
+class SQUARE : public SPRITE {
public:
- SQUARE (void);
- void Touch (uint16 mask, int x, int y);
+ SQUARE(void);
+ void Touch(uint16 mask, int x, int y);
};
-
-
-
-
-SQUARE::SQUARE (void)
-: SPRITE(MB)
-{
- Flags.Kill = true;
- Flags.BDel = false;
+SQUARE::SQUARE(void)
+ : SPRITE(MB) {
+ Flags.Kill = true;
+ Flags.BDel = false;
}
-
-
-
-
-
-
-void SQUARE::Touch (uint16 mask, int x, int y)
-{
- SPRITE::Touch(mask, x, y);
- if (mask & L_UP)
- {
- XZ(X+x, Y+y).Cell() = 0;
- SNPOST_(SNKILL, -1, 0, this);
- }
+void SQUARE::Touch(uint16 mask, int x, int y) {
+ SPRITE::Touch(mask, x, y);
+ if (mask & L_UP) {
+ XZ(X + x, Y + y).Cell() = 0;
+ SNPOST_(SNKILL, -1, 0, this);
+ }
}
-
-
-
-
-static void SetMapBrick (int x, int z)
-{
- SQUARE * s = new SQUARE;
- if (s)
- {
- static char n[] = "00:00";
- s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID);
- wtom(x, n+0, 10, 2);
- wtom(z, n+3, 10, 2);
- CLUSTER::Map[z][x] = 1;
- s->SetName(n);
- VGA::ShowQ.Insert(s, VGA::ShowQ.First());
- }
+static void SetMapBrick(int x, int z) {
+ SQUARE *s = new SQUARE;
+ if (s) {
+ static char n[] = "00:00";
+ s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID);
+ wtom(x, n + 0, 10, 2);
+ wtom(z, n + 3, 10, 2);
+ CLUSTER::Map[z][x] = 1;
+ s->SetName(n);
+ VGA::ShowQ.Insert(s, VGA::ShowQ.First());
+ }
}
-
#endif
+void dummy(void) {}
+static void SwitchMapping(void);
+static void SwitchColorMode(void);
+static void StartCountDown(void);
+Debug(static void SwitchDebug(void);)
+static void SwitchMusic(void);
+static void KillSprite(void);
+static void PushSprite(void);
+static void PullSprite(void);
+static void BackPaint(void);
+static void NextStep(void);
+static void SaveMapping(void);
-//--------------------------------------------------------------------------
-
-void dummy (void) { }
-static void SwitchMapping (void);
-static void SwitchColorMode (void);
-static void StartCountDown (void);
-Debug(static void SwitchDebug (void); )
-static void SwitchMusic (void);
-static void KillSprite (void);
-static void PushSprite (void);
-static void PullSprite (void);
-static void BackPaint (void);
-static void NextStep (void);
-static void SaveMapping (void);
-
-
- WALK * Hero = NULL;
-static INFO_LINE InfoLine = INFO_W;
-
-static HEART Heart;
-static SPRITE CavLight = PR;
+WALK *Hero = NULL;
+static INFO_LINE InfoLine = INFO_W;
+static HEART Heart;
+static SPRITE CavLight = PR;
-
-
-
-static void KeyClick (void)
-{
- SNPOST_(SNSOUND, -1, 5, NULL);
+static void KeyClick(void) {
+ SNPOST_(SNSOUND, -1, 5, NULL);
}
-
-static void ResetQSwitch (void)
-{
- SNPOST_(SNSEQ, 123, 0, NULL);
- KeyClick();
+static void ResetQSwitch(void) {
+ SNPOST_(SNSEQ, 123, 0, NULL);
+ KeyClick();
}
+static void Quit(void) {
+ static CHOICE QuitMenu[] = { { NULL, StartCountDown },
+ { NULL, ResetQSwitch },
+ { NULL, dummy }
+ };
-
-static void Quit (void)
-{
- static CHOICE QuitMenu[]={ { NULL, StartCountDown },
- { NULL, ResetQSwitch },
- { NULL, dummy } };
-
- if (Snail.Idle() && ! Hero->Flags.Hide)
- {
- if (VMENU::Addr)
- {
- SNPOST_(SNKILL, -1, 0, VMENU::Addr);
- ResetQSwitch();
- }
- else
- {
- QuitMenu[0].Text = Text[QUIT_TEXT];
- QuitMenu[1].Text = Text[NOQUIT_TEXT];
- (new VMENU(QuitMenu, -1, -1))->SetName(Text[QUIT_TITLE]);
- SNPOST_(SNSEQ, 123, 1, NULL);
- KeyClick();
+ if (Snail.Idle() && ! Hero->Flags.Hide) {
+ if (VMENU::Addr) {
+ SNPOST_(SNKILL, -1, 0, VMENU::Addr);
+ ResetQSwitch();
+ } else {
+ QuitMenu[0].Text = Text[QUIT_TEXT];
+ QuitMenu[1].Text = Text[NOQUIT_TEXT];
+ (new VMENU(QuitMenu, -1, -1))->SetName(Text[QUIT_TITLE]);
+ SNPOST_(SNSEQ, 123, 1, NULL);
+ KeyClick();
+ }
}
- }
}
-
-
-static void AltCtrlDel (void)
-{
- #if 0
- //def DEBUG
- if (KEYBOARD::Key[LSHIFT] || KEYBOARD::Key[RSHIFT])
- {
- PostFlag = 0x1234;
- POST();
- }
- else
- #endif
- SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero);
+static void AltCtrlDel(void) {
+#if 0
+ //def DEBUG
+ if (KEYBOARD::Key[LSHIFT] || KEYBOARD::Key[RSHIFT]) {
+ PostFlag = 0x1234;
+ POST();
+ } else
+#endif
+ SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero);
}
+static void MiniStep(int stp) {
+ if (stp < 0)
+ MiniCave->Flags.Hide = true;
+ else {
+ &*Mini;
+ *MiniShp[0] = *MiniShpList[stp];
+ if (Fx.Current)
+ &*(Fx.Current->EAddr());
-
-static void MiniStep (int stp)
-{
- if (stp < 0) MiniCave->Flags.Hide = true;
- else
- {
- &*Mini;
- *MiniShp[0] = *MiniShpList[stp];
- if (Fx.Current) &*(Fx.Current->EAddr());
- MiniCave->Flags.Hide = false;
- }
+ MiniCave->Flags.Hide = false;
+ }
}
-
-
-
-static void PostMiniStep (int stp)
-{
- static int recent = -2;
- //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()");
+static void PostMiniStep(int stp) {
+ static int recent = -2;
+ //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()");
}
+int SYSTEM::FunDel = HEROFUN0;
-//--------------------------------------------------------------------------
-
-
-
-int SYSTEM::FunDel = HEROFUN0;
-
-
-
-void SYSTEM::SetPal (void)
-{
- int i;
- DAC * p = 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;
- }
+void SYSTEM::SetPal(void) {
+ int i;
+ DAC *p = 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;
+ }
}
-
-
-
-void SYSTEM::FunTouch (void)
-{
- uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0;
- if (Talk == NULL || n > FunDel) FunDel = n;
+void SYSTEM::FunTouch(void) {
+ uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0;
+ if (Talk == NULL || n > FunDel)
+ FunDel = n;
}
-
-
-
-
-static void ShowBak (int ref)
-{
- SPRITE * spr = VGA::SpareQ.Locate(ref);
- if (spr)
- {
- BITMAP::Pal = SysPal;
- spr->Expand();
- BITMAP::Pal = NULL;
- spr->Show(2);
- VGA::CopyPage(1, 2);
- SYSTEM::SetPal();
- spr->Contract();
- }
+static void ShowBak(int ref) {
+ SPRITE *spr = VGA::SpareQ.Locate(ref);
+ if (spr) {
+ BITMAP::Pal = SysPal;
+ spr->Expand();
+ BITMAP::Pal = NULL;
+ spr->Show(2);
+ VGA::CopyPage(1, 2);
+ SYSTEM::SetPal();
+ spr->Contract();
+ }
}
+static void CaveUp(void) {
+ int BakRef = 1000 * Now;
+ if (Music)
+ LoadMIDI(Now);
+
+ ShowBak(BakRef);
+ LoadMapping();
+ Text.Preload(BakRef, BakRef + 1000);
+ SPRITE *spr = VGA::SpareQ.First();
+ while (spr) {
+ SPRITE *n = spr->Next;
+ if (spr->Cave == Now || spr->Cave == 0)
+ if (spr->Ref != BakRef) {
+ if (spr->Flags.Back)
+ spr->BackShow();
+ else
+ ExpandSprite(spr);
+ }
+ spr = n;
+ }
+ if (SNDDrvInfo.DDEV) {
+ Sound.Stop();
+ Fx.Clear();
+ Fx.Preload(0);
+ Fx.Preload(BakRef);
+ }
+ if (Hero) {
+ Hero->Goto(HeroXY[Now - 1].X, HeroXY[Now - 1].Y);
+ // following 2 lines trims Hero's Z position!
+ Hero->Tick();
+ Hero->Time = 1;
+ Hero->Flags.Hide = false;
+ }
+ if (! Dark)
+ Vga.Sunset();
+ VGA::CopyPage(0, 1);
+ SelectPocket(-1);
+ if (Hero)
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(Hero));
-static void CaveUp (void)
-{
- int BakRef = 1000 * Now;
- if (Music) LoadMIDI(Now);
- ShowBak(BakRef);
- LoadMapping();
- Text.Preload(BakRef, BakRef+1000);
- SPRITE * spr = VGA::SpareQ.First();
- while (spr)
- {
- SPRITE * n = spr->Next;
- if (spr->Cave == Now || spr->Cave == 0)
- if (spr->Ref != BakRef)
- {
- if (spr->Flags.Back) spr->BackShow();
- else ExpandSprite(spr);
- }
- spr = n;
- }
- if (SNDDrvInfo.DDEV)
- {
- Sound.Stop();
- Fx.Clear();
- Fx.Preload(0);
- Fx.Preload(BakRef);
- }
-
- if (Hero)
- {
- Hero->Goto(HeroXY[Now-1].X, HeroXY[Now-1].Y);
- // following 2 lines trims Hero's Z position!
- Hero->Tick();
- Hero->Time = 1;
- Hero->Flags.Hide = false;
- }
-
- if (! Dark) Vga.Sunset();
- VGA::CopyPage(0, 1);
- SelectPocket(-1);
- if (Hero) VGA::ShowQ.Insert(VGA::ShowQ.Remove(Hero));
- if (Shadow)
- {
- VGA::ShowQ.Remove(Shadow);
- Shadow->MakeXlat(Glass(SysPal, 204, 204, 204));
- VGA::ShowQ.Insert(Shadow, Hero);
- Shadow->Z = Hero->Z;
- }
- FeedSnail(VGA::ShowQ.Locate(BakRef+999), TAKE);
- Vga.Show();
- Vga.CopyPage(1, 0);
- Vga.Show();
- Vga.Sunrise(SysPal);
- Dark = false;
- if (! Startup) Mouse.On();
- HEART::Enable = true;
-}
-
-
-
-
-
-static void CaveDown (void)
-{
- SPRITE * spr;
- Debug( if (! HorzLine.Flags.Hide) SwitchMapping(); )
-
- for (spr = VGA::ShowQ.First(); spr; )
- {
- SPRITE * n = spr->Next;
- if (spr->Ref >= 1000 /*&& spr->Cave*/)
- {
- if (spr->Ref % 1000 == 999) FeedSnail(spr, TAKE);
- VGA::SpareQ.Append(VGA::ShowQ.Remove(spr));
+ if (Shadow) {
+ VGA::ShowQ.Remove(Shadow);
+ Shadow->MakeXlat(Glass(SysPal, 204, 204, 204));
+ VGA::ShowQ.Insert(Shadow, Hero);
+ Shadow->Z = Hero->Z;
}
- spr = n;
- }
- Text.Clear(1000);
-}
+ FeedSnail(VGA::ShowQ.Locate(BakRef + 999), TAKE);
+ Vga.Show();
+ Vga.CopyPage(1, 0);
+ Vga.Show();
+ Vga.Sunrise(SysPal);
+ Dark = false;
+ if (! Startup)
+ Mouse.On();
+ HEART::Enable = true;
+}
+static void CaveDown(void) {
+ SPRITE *spr;
+ Debug(if (! HorzLine.Flags.Hide) SwitchMapping();)
+ for (spr = VGA::ShowQ.First(); spr;) {
+ SPRITE *n = spr->Next;
+ if (spr->Ref >= 1000 /*&& spr->Cave*/) {
+ if (spr->Ref % 1000 == 999)
+ FeedSnail(spr, TAKE);
-static void XCave (void)
-{
- CaveDown();
- CaveUp();
+ VGA::SpareQ.Append(VGA::ShowQ.Remove(spr));
+ }
+ spr = n;
+ }
+ Text.Clear(1000);
}
-
-
-static void QGame (void)
-{
- CaveDown();
- OldLev = Lev;
- SaveSound();
- CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt);
- SaveGame(file);
- Vga.Sunset();
- Finis = true;
+static void XCave(void) {
+ CaveDown();
+ CaveUp();
}
+static void QGame(void) {
+ CaveDown();
+ OldLev = Lev;
+ SaveSound();
+ CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt);
+ SaveGame(file);
+ Vga.Sunset();
+ Finis = true;
+}
-void SwitchCave (int cav)
-{
- if (cav != Now)
- {
- HEART::Enable = false;
- 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;
- Mouse.Off();
- if (Hero)
- {
- Hero->Park();
- Hero->Step(0);
- #ifndef DEMO
- ///// protection: auto-destruction on! ----------------------
- VGA::SpareQ.Show = STARTUP::Summa * (cav <= CAVE_MAX);
- /////--------------------------------------------------------
- #endif
- }
- CavLight.Goto(CAVE_X + ((Now-1) % CAVE_NX) * CAVE_DX + CAVE_SX,
- CAVE_Y + ((Now-1) / CAVE_NX) * CAVE_DY + CAVE_SY);
- KillText();
- if (! Startup) KeyClick();
- 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");
+void SwitchCave(int cav) {
+ if (cav != Now) {
+ HEART::Enable = false;
+ 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;
+ Mouse.Off();
+ if (Hero) {
+ Hero->Park();
+ Hero->Step(0);
+#ifndef DEMO
+ ///// protection: auto-destruction on! ----------------------
+ VGA::SpareQ.Show = STARTUP::Summa * (cav <= CAVE_MAX);
+ /////--------------------------------------------------------
+#endif
+ }
+ CavLight.Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
+ CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
+ KillText();
+ if (! Startup) KeyClick();
+ 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");
+ }
}
- }
}
+void SYSTEM::Touch(uint16 mask, int x, int y) {
+ static int pp = 0;
+ void SwitchCave(int cav);
+ int cav = 0;
+ FunTouch();
+ if (mask & KEYB) {
+ int pp0;
+ KeyClick();
+ KillText();
+ if (Startup == 1) {
+ SNPOST(SNCLEAR, -1, 0, NULL);
+ return;
+ }
+ pp0 = pp;
+ switch (x) {
+ case Del:
+ if (KEYBOARD::Key[ALT] &&
+ KEYBOARD::Key[CTRL]) AltCtrlDel();
+ Debug(else KillSprite();)
+ break;
+ case 'F':
+ if (KEYBOARD::Key[ALT]) {
+ SPRITE *m = VGA::ShowQ.Locate(17001);
+ if (m) {
+ m->Step(1);
+ m->Time = 216; // 3s
+ }
+ }
+ break;
+#ifdef DEBUG
+ case PgUp:
+ PushSprite();
+ break;
+ case PgDn:
+ PullSprite();
+ break;
+ case '+':
+ NextStep();
+ break;
+ case '`':
+ if (KEYBOARD::Key[ALT])
+ SaveMapping();
+ else
+ SwitchMapping();
+ break;
+ case F1:
+ SwitchDebug();
+ break;
+ case F3:
+ Hero->Step(TSEQ + 4);
+ break;
+ case F4:
+ Hero->Step(TSEQ + 5);
+ break;
+ case F5:
+ Hero->Step(TSEQ + 0);
+ break;
+ case F6:
+ Hero->Step(TSEQ + 1);
+ break;
+ case F7:
+ Hero->Step(TSEQ + 2);
+ break;
+ case F8:
+ Hero->Step(TSEQ + 3);
+ break;
+ case F9:
+ SYSTEM::FunDel = 1;
+ break;
+ case 'X':
+ if (KEYBOARD::Key[ALT])
+ Finis = true;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ if (KEYBOARD::Key[ALT]) {
+ SNPOST(SNLEVEL, -1, x - '0', NULL);
+ break;
+ }
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (Sprite)
+ Sprite->Step(x - '0');
+ break;
+#else
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ SelectPocket(x - '1');
+ break;
+#endif
-void SYSTEM::Touch (uint16 mask, int x, int y)
-{
- static int pp = 0;
- void SwitchCave (int cav);
- int cav = 0;
-
- FunTouch();
-
- if (mask & KEYB)
- {
- int pp0;
- KeyClick();
- KillText();
- if (Startup == 1)
- {
- SNPOST(SNCLEAR, -1, 0, NULL);
- return;
- }
- pp0 = pp;
- switch (x)
- {
- case Del : if (KEYBOARD::Key[ALT] &&
- KEYBOARD::Key[CTRL]) AltCtrlDel();
- Debug ( else KillSprite(); )
- break;
- case 'F' : if (KEYBOARD::Key[ALT])
- {
- SPRITE * m = VGA::ShowQ.Locate(17001);
- if (m)
- {
- m->Step(1);
- m->Time = 216; // 3s
- }
- }
- break;
-
- #ifdef DEBUG
- case PgUp : PushSprite(); break;
- case PgDn : PullSprite(); break;
- case '+' : NextStep(); break;
- case '`' : if (KEYBOARD::Key[ALT]) SaveMapping(); else SwitchMapping(); break;
- case F1 : SwitchDebug(); break;
- case F3 : Hero->Step(TSEQ + 4); break;
- case F4 : Hero->Step(TSEQ + 5); break;
- case F5 : Hero->Step(TSEQ + 0); break;
- case F6 : Hero->Step(TSEQ + 1); break;
- case F7 : Hero->Step(TSEQ + 2); break;
- case F8 : Hero->Step(TSEQ + 3); break;
- case F9 : SYSTEM::FunDel = 1; break;
- case 'X' : if (KEYBOARD::Key[ALT]) Finis = true; break;
- case '0' :
- case '1' :
- case '2' :
- case '3' :
- case '4' : if (KEYBOARD::Key[ALT]) { SNPOST(SNLEVEL, -1, x - '0', NULL); break; }
- case '5' :
- case '6' :
- case '7' :
- case '8' :
- case '9' : if (Sprite) Sprite->Step(x - '0'); break;
- #else
- case '1' :
- case '2' :
- case '3' :
- case '4' :
- case '5' :
- case '6' :
- case '7' :
- case '8' : SelectPocket(x - '1'); break;
- #endif
-
- case F10 : if (Snail.Idle() && ! Hero->Flags.Hide)
+ case F10 :
+ if (Snail.Idle() && ! Hero->Flags.Hide)
StartCountDown();
- 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;
- InfoLine.Update(NULL);
- 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;
+ break;
+ case 'J':
+ if (pp == 0)
+ ++pp;
+ break;
+ case 'B':
+ if (pp == 1)
+ ++pp;
+ break;
+ case 'W':
+ if (pp == 2)
+ JBW = !JBW;
+ break;
}
- }
- 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);
+ if (pp == pp0)
+ pp = 0;
+ } else {
+ if (Startup)
+ return;
+
+ InfoLine.Update(NULL);
+ 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);
+ }
+ }
}
- }
- }
- PostMiniStep(cav-1);
+ PostMiniStep(cav - 1);
- if (mask & L_UP)
- {
- if (cav && Snail.Idle() && Hero->TracePtr < 0)
- {
- SwitchCave(cav);
- }
- #ifdef DEBUG
- if (! HorzLine.Flags.Hide)
- {
- if (y >= MAP_TOP && y < MAP_TOP+MAP_HIG)
- {
- signed char x1, z1;
- XZ(x, y).Split(x1, z1);
- CLUSTER::Map[z1][x1] = 1;
- SetMapBrick(x1, z1);
- }
- }
- else
- #endif
- {
- if (! Talk && Snail.Idle() && Hero
- && y >= MAP_TOP && y < MAP_TOP+MAP_HIG && ! Game)
- {
- Hero->FindWay(XZ(x, y));
+ if (mask & L_UP) {
+ if (cav && Snail.Idle() && Hero->TracePtr < 0)
+ SwitchCave(cav);
+
+#ifdef DEBUG
+ if (!HorzLine.Flags.Hide) {
+ if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) {
+ signed char x1, z1;
+ XZ(x, y).Split(x1, z1);
+ CLUSTER::Map[z1][x1] = 1;
+ SetMapBrick(x1, z1);
+ }
+ } else
+#endif
+ {
+ if (! Talk && Snail.Idle() && Hero
+ && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && ! Game) {
+ Hero->FindWay(XZ(x, y));
+ }
+ }
}
- }
}
- }
}
-
-
-
-
-
-void SYSTEM::Tick (void)
-{
- if (! Startup) if (-- FunDel == 0)
- {
- KillText();
- if (Snail.Idle())
- {
- if (PAIN) HeroCover(9);
- else if (STARTUP::Core >= CORE_MID)
- {
- int n = new_random(100);
- if (n > 96) HeroCover(6+(Hero->X+Hero->W/2 < SCR_WID/2));
- else
- {
- if (n > 90) HeroCover(5);
- else
- {
- if (n > 60) HeroCover(4);
- else HeroCover(3);
- }
+void SYSTEM::Tick(void) {
+ if (! Startup) if (-- FunDel == 0) {
+ KillText();
+ if (Snail.Idle()) {
+ if (PAIN)
+ HeroCover(9);
+ else if (STARTUP::Core >= CORE_MID) {
+ int n = new_random(100);
+ if (n > 96)
+ HeroCover(6 + (Hero->X + Hero->W / 2 < SCR_WID / 2));
+ else {
+ if (n > 90)
+ HeroCover(5);
+ else {
+ if (n > 60)
+ HeroCover(4);
+ else
+ HeroCover(3);
+ }
+ }
+ }
+ }
+ FunTouch();
}
- }
- }
- FunTouch();
- }
- Time = SYSTIMERATE;
+ Time = SYSTIMERATE;
}
-
-
-
-
-
-
-
-
-//--------------------------------------------------------------------------
-
-
-
/*
-static void SpkOpen (void)
-{
- asm in al,0x61
- asm or al,0x03
- asm out 0x61,al
- asm mov al,0x90
- asm out 0x43,al
+static void SpkOpen(void) {
+ asm in al,0x61
+ asm or al,0x03
+ asm out 0x61,al
+ asm mov al,0x90
+ asm out 0x43,al
}
-
-
-
-static void SpkClose (void)
-{
- asm in al,0x61
- asm and al,0xFC
- asm out 0x61,al
+static void SpkClose(void) {
+ asm in al,0x61
+ asm and al,0xFC
+ asm out 0x61,al
}
*/
-
-static void SwitchColorMode (void)
-{
- SNPOST_(SNSEQ, 121, VGA::Mono = ! VGA::Mono, NULL);
- KeyClick();
- VGA::SetColors(SysPal, 64);
+static void SwitchColorMode(void) {
+ SNPOST_(SNSEQ, 121, VGA::Mono = ! VGA::Mono, NULL);
+ KeyClick();
+ VGA::SetColors(SysPal, 64);
}
-static void SwitchMusic (void)
-{
- if (KEYBOARD::Key[ALT])
- {
- 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
- // SNPOST(SNEXEC, -1, 0, (void *)&SelectSound);
- warning("SwitchMusic() - SNPOST");
- }
- }
- else
- {
- if (STARTUP::Core < CORE_HIG) SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL);
- else
- {
- SNPOST_(SNSEQ, 122, (Music = ! Music), NULL);
- KeyClick();
+static void SwitchMusic(void) {
+ if (KEYBOARD::Key[ALT]) {
+ 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
+ // SNPOST(SNEXEC, -1, 0, (void *)&SelectSound);
+ 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();
+ if (Music)
+ LoadMIDI(Now);
+ else
+ KillMIDI();
}
-
-
-
-static void StartCountDown (void)
-{
- //SNPOST(SNSEQ, 123, 0, NULL);
- SwitchCave(-1);
+static void StartCountDown(void) {
+ //SNPOST(SNSEQ, 123, 0, NULL);
+ SwitchCave(-1);
}
-
-
-#ifndef DEMO
-static void TakeName (void)
-{
- if (GET_TEXT::Ptr) SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr);
- else
- {
- GET_TEXT * tn = new GET_TEXT(Text[GETNAME_PROMPT], UsrFnam, 8, KeyClick);
- if (tn)
- {
- tn->SetName(Text[GETNAME_TITLE]);
- tn->Center();
- tn->Goto(tn->X, tn->Y - 10);
- tn->Z = 126;
- VGA::ShowQ.Insert(tn);
+#ifndef DEMO
+static void TakeName(void) {
+ if (GET_TEXT::Ptr)
+ SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr);
+ else {
+ GET_TEXT *tn = new GET_TEXT(Text[GETNAME_PROMPT], UsrFnam, 8, KeyClick);
+ if (tn) {
+ tn->SetName(Text[GETNAME_TITLE]);
+ tn->Center();
+ tn->Goto(tn->X, tn->Y - 10);
+ tn->Z = 126;
+ VGA::ShowQ.Insert(tn);
+ }
}
- }
}
#endif
-
-
-
#ifdef DEBUG
-
-
-static void SwitchMapping (void)
-{
- if (HorzLine.Flags.Hide)
- {
- int i;
- for (i = 0; i < MAP_ZCNT; i ++)
- {
- int j;
- for (j = 0; j < MAP_XCNT; j ++)
- {
- if (CLUSTER::Map[i][j])
- SetMapBrick(j, i);
- }
+static void SwitchMapping(void) {
+ if (HorzLine.Flags.Hide) {
+ int i;
+ for (i = 0; i < MAP_ZCNT; i ++) {
+ int j;
+ for (j = 0; j < MAP_XCNT; j ++) {
+ if (CLUSTER::Map[i][j])
+ SetMapBrick(j, i);
+ }
+ }
+ } else {
+ SPRITE *s;
+ for (s = VGA::ShowQ.First(); s; s = s->Next)
+ if (s->W == MAP_XGRID && s->H == MAP_ZGRID)
+ SNPOST_(SNKILL, -1, 0, s);
}
- }
- else
- {
- SPRITE * s;
- for (s = VGA::ShowQ.First(); s; s = s->Next)
- if (s->W == MAP_XGRID && s->H == MAP_ZGRID)
- SNPOST_(SNKILL, -1, 0, s);
- }
- HorzLine.Flags.Hide = ! HorzLine.Flags.Hide;
+ HorzLine.Flags.Hide = ! HorzLine.Flags.Hide;
}
-
-
-
-static void KillSprite (void)
-{
- Sprite->Flags.Kill = true;
- Sprite->Flags.BDel = true;
- SNPOST_(SNKILL, -1, 0, Sprite);
- Sprite = NULL;
+static void KillSprite(void) {
+ Sprite->Flags.Kill = true;
+ Sprite->Flags.BDel = true;
+ SNPOST_(SNKILL, -1, 0, Sprite);
+ Sprite = NULL;
}
-
-
-
-static void PushSprite (void)
-{
- SPRITE * spr = Sprite->Prev;
- if (spr)
- {
- VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr);
- while (Sprite->Z > Sprite->Next->Z) -- Sprite->Z;
- }
- else SNPOST_(SNSOUND, -1, 2, NULL);
+static void PushSprite(void) {
+ SPRITE *spr = Sprite->Prev;
+ if (spr) {
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr);
+ while (Sprite->Z > Sprite->Next->Z)
+ --Sprite->Z;
+ } else
+ SNPOST_(SNSOUND, -1, 2, NULL);
}
-
-
-
-static void PullSprite (void)
-{
- bool ok = false;
- SPRITE * spr = Sprite->Next;
- if (spr)
- {
- spr = spr->Next;
- if (spr)
- {
- ok = (! spr->Flags.Slav);
+static void PullSprite(void) {
+ bool ok = false;
+ SPRITE *spr = Sprite->Next;
+ if (spr) {
+ spr = spr->Next;
+ if (spr)
+ ok = (!spr->Flags.Slav);
}
- }
- if (ok)
- {
- VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr);
- if (Sprite->Prev)
- while (Sprite->Z < Sprite->Prev->Z) ++ Sprite->Z;
- }
- else SNPOST_(SNSOUND, -1, 2, NULL);
+ if (ok) {
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr);
+ if (Sprite->Prev)
+ while (Sprite->Z < Sprite->Prev->Z)
+ ++Sprite->Z;
+ } else
+ SNPOST_(SNSOUND, -1, 2, NULL);
}
-
-
-
-
-static void NextStep (void)
-{
- SNPOST_(SNSTEP, 0, 0, Sprite);
+static void NextStep(void) {
+ SNPOST_(SNSTEP, 0, 0, Sprite);
}
-
-
-
-
-
-
-
-static void SaveMapping (void)
-{
- {
- IOHAND cf(ProgName(".TAB"), UPD);
- if (! cf.Error)
- {
- cf.Seek((Now-1) * sizeof(CLUSTER::Map));
- cf.Write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map));
- }
- }
- {
- IOHAND cf(ProgName(".HXY"), WRI);
- if (! cf.Error)
- {
- HeroXY[Now-1].X = Hero->X;
- HeroXY[Now-1].Y = Hero->Y;
- cf.Write((uint8 *) HeroXY, sizeof(HeroXY));
- }
- }
+static void SaveMapping(void) {
+ {
+ IOHAND cf(ProgName(".TAB"), UPD);
+ if (!cf.Error) {
+ cf.Seek((Now - 1) * sizeof(CLUSTER::Map));
+ cf.Write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map));
+ }
+ }
+ {
+ IOHAND cf(ProgName(".HXY"), WRI);
+ if (!cf.Error) {
+ HeroXY[Now - 1].X = Hero->X;
+ HeroXY[Now - 1].Y = Hero->Y;
+ cf.Write((uint8 *) HeroXY, sizeof(HeroXY));
+ }
+ }
}
#endif
-
-//--------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-#ifdef DEBUG
-
-
-
- // 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)
+#ifdef DEBUG
+// 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)
-INFO_LINE DebugLine(SCR_WID);
-
-static void SayDebug (void)
-{
- if (! DebugLine.Flags.Hide)
- {
- static long t = -1L;
- long t1 = Timer();
+INFO_LINE DebugLine(SCR_WID);
- if (t1 - t >= 18)
- {
- static uint32 old = 0L;
- uint32 now = Vga.FrmCnt;
- dwtom(now - old, FRPS, 10, 4);
- old = now;
- t = t1;
- }
+static void SayDebug(void) {
+ if (!DebugLine.Flags.Hide) {
+ static long t = -1L;
+ long t1 = Timer();
- dwtom(Mouse.X, ABSX, 10, 3);
- dwtom(Mouse.Y, ABSY, 10, 3);
- dwtom(coreleft(), NFRE, 10, 5);
- dwtom(farcoreleft(), FFRE, 10, 6);
+ if (t1 - t >= 18) {
+ static uint32 old = 0L;
+ uint32 now = Vga.FrmCnt;
+ dwtom(now - old, FRPS, 10, 4);
+ old = now;
+ t = t1;
+ }
- // sprite queue size
- uint16 n = 0;
- SPRITE * spr;
- for (spr = VGA::ShowQ.First(); spr; spr = spr->Next)
- {
- ++ n;
- if (spr == Sprite)
- {
- *XSPR = ' ';
- dwtom(n, SP_N, 10, 2);
- 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);
- }
+ dwtom(Mouse.X, ABSX, 10, 3);
+ dwtom(Mouse.Y, ABSY, 10, 3);
+// dwtom(coreleft(), NFRE, 10, 5);
+// dwtom(farcoreleft(), FFRE, 10, 6);
+
+ // sprite queue size
+ uint16 n = 0;
+ SPRITE *spr;
+ for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) {
+ ++ n;
+ if (spr == Sprite) {
+ *XSPR = ' ';
+ dwtom(n, SP_N, 10, 2);
+ 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);
+ }
+ }
+ dwtom(n, SP_S, 10, 2);
+// *SP__ = (heapcheck() < 0) ? '!' : ' ';
+ DebugLine.Update(DebugText);
}
- dwtom(n, SP_S, 10, 2);
- *SP__ = (heapcheck() < 0) ? '!' : ' ';
- DebugLine.Update(DebugText);
- }
}
-
-
-
-static void SwitchDebug (void)
-{
- DebugLine.Flags.Hide = ! DebugLine.Flags.Hide;
+static void SwitchDebug(void) {
+ DebugLine.Flags.Hide = ! DebugLine.Flags.Hide;
}
-
-
#endif
-
-
-
-
-static void OptionTouch (int opt, uint16 mask)
-{
- switch (opt)
- {
- case 1 : if (mask & L_UP) SwitchColorMode(); break;
- case 2 : if (mask & L_UP) SwitchMusic();
- else
- if (mask & R_UP)
- if (! MIXER::Appear)
- {
- MIXER::Appear = true;
- new MIXER(BUTTON_X, BUTTON_Y);
- }
- break;
- case 3 : if (mask & L_UP) Quit(); break;
- }
+static void OptionTouch(int opt, uint16 mask) {
+ switch (opt) {
+ case 1 :
+ if (mask & L_UP)
+ SwitchColorMode();
+ break;
+ case 2 :
+ if (mask & L_UP)
+ SwitchMusic();
+ else if (mask & R_UP)
+ if (! MIXER::Appear) {
+ MIXER::Appear = true;
+ new MIXER(BUTTON_X, BUTTON_Y);
+ }
+ break;
+ case 3 :
+ if (mask & L_UP)
+ Quit();
+ break;
+ }
}
-
-
-
#pragma argsused
-void SPRITE::Touch (uint16 mask, int x, int y)
-{
- SYSTEM::FunTouch();
- if ((mask & ATTN) == 0)
- {
- InfoLine.Update(Name());
- if (mask & (R_DN | L_DN)) Sprite = this; // DEBUG mode only?
- if (Ref/10 == 12)
- {
- OptionTouch(Ref % 10, mask);
- return;
- }
- if (Flags.Syst) return; // cannot access system sprites
- if (Game) if (mask & L_UP) { mask &= ~L_UP; mask |= R_UP; }
- if ((mask & R_UP) && Snail.Idle())
- {
- SPRITE * ps = (PocLight.SeqPtr) ? Pocket[PocPtr] : NULL;
- if (ps)
- {
- if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE)
- {
- if (Works(ps))
- {
- FeedSnail(ps, TAKE);
- }
- else OffUse();
- SelectPocket(-1);
+void SPRITE::Touch(uint16 mask, int x, int y) {
+ SYSTEM::FunTouch();
+ if ((mask & ATTN) == 0) {
+ InfoLine.Update(Name());
+ if (mask & (R_DN | L_DN))
+ Sprite = this; // DEBUG mode only?
+ if (Ref / 10 == 12) {
+ OptionTouch(Ref % 10, mask);
+ return;
}
- else TooFar();
- }
- else
- {
- if (Flags.Kept) mask |= L_UP;
- else
- {
- if (Hero->Distance(this) < MAX_DISTANCE)
- {///
- if (Flags.Port)
- {
- if (FindPocket(NULL) < 0) PocFul();
- else
- {
- SNPOST(SNREACH, -1, -1, this);
- SNPOST(SNKEEP, -1, -1, this);
- Flags.Port = false;
- }
+ if (Flags.Syst)
+ return; // cannot access system sprites
+ if (Game) if (mask & L_UP) {
+ mask &= ~L_UP;
+ mask |= R_UP;
}
- else
- {
- if (TakePtr != NO_PTR)
- {
- if (SnList(TAKE)[TakePtr].Com == SNNEXT) OffUse();
- else FeedSnail(this, TAKE);
- }
- else OffUse();
+ if ((mask & R_UP) && Snail.Idle()) {
+ SPRITE *ps = (PocLight.SeqPtr) ? Pocket[PocPtr] : NULL;
+ if (ps) {
+ if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) {
+ if (Works(ps)) {
+ FeedSnail(ps, TAKE);
+ } else
+ OffUse();
+ SelectPocket(-1);
+ } else
+ TooFar();
+ } else {
+ if (Flags.Kept)
+ mask |= L_UP;
+ else {
+ if (Hero->Distance(this) < MAX_DISTANCE) {
+ ///
+ if (Flags.Port) {
+ if (FindPocket(NULL) < 0)
+ PocFul();
+ else {
+ SNPOST(SNREACH, -1, -1, this);
+ SNPOST(SNKEEP, -1, -1, this);
+ Flags.Port = false;
+ }
+ } else {
+ if (TakePtr != NO_PTR) {
+ if (SnList(TAKE)[TakePtr].Com == SNNEXT)
+ OffUse();
+ else
+ FeedSnail(this, TAKE);
+ } else
+ OffUse();
+ }
+ }///
+ else
+ TooFar();
+ }
}
- }///
- else TooFar();
}
- }
- }
- if ((mask & L_UP) && Snail.Idle())
- {
- if (Flags.Kept)
- {
- int n;
- for (n = 0; n < POCKET_NX; n ++)
- {
- if (Pocket[n] == this)
- {
- SelectPocket(n);
- break;
- }
+ if ((mask & L_UP) && Snail.Idle()) {
+ if (Flags.Kept) {
+ int n;
+ for (n = 0; n < POCKET_NX; n ++) {
+ if (Pocket[n] == this) {
+ SelectPocket(n);
+ break;
+ }
+ }
+ } else
+ SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this);
}
- }
- else SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this);
}
- }
}
-
-
-
-
-
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-
-
-
-
-
-
-static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0)
-{
- 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;
-
- MergeExt(line, fname, SPR_EXT);
- if (INI_FILE::Exist(line)) // sprite description file exist
- {
- INI_FILE sprf(line);
- if (sprf.Error) {
- error("Bad SPR [%s]", line);
+static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) {
+ 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;
+
+ MergeExt(line, fname, SPR_EXT);
+ if (INI_FILE::Exist(line)) { // sprite description file exist
+ INI_FILE sprf(line);
+ if (sprf.Error)
+ error("Bad SPR [%s]", line);
+
+ while ((len = sprf.Read((uint8 *)line)) != 0) {
+ ++ lcnt;
+ if (len && line[len - 1] == '\n')
+ line[-- len] = '\0';
+ if (len == 0 || *line == '.')
+ continue;
+
+ if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0)
+ error("%s [%s]", NumStr("Bad line ######", lcnt), fname);
+
+
+ switch (i) {
+ case 0 : // Name - will be taken in Expand routine
+ break;
+ case 1 : // Type
+ if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0)
+ error("%s [%s]", NumStr("Bad line ######", lcnt), fname);
+ 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;
+ }
+ }
+ if (! shpcnt)
+ error("No shapes [%s]", fname);
+ } else { // no sprite description: mono-shaped sprite with only .BMP file
+ ++shpcnt;
}
- while ((len = sprf.Read((uint8*)line)) != 0)
- {
- ++ lcnt;
- if (len && line[len-1] == '\n') line[-- len] = '\0';
- if (len == 0 || *line == '.') continue;
-
- if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) {
- error("%s [%s]", NumStr("Bad line ######", lcnt), fname);
- }
-
- switch (i)
- {
- case 0 : // Name - will be taken in Expand routine
- break;
- case 1 : // Type
- if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0)
- error("%s [%s]", NumStr("Bad line ######", lcnt), fname);
- 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;
- }
+ // make sprite of choosen type
+ switch (type) {
+ case 1 : { // AUTO
+ Sprite = new SPRITE(NULL);
+ if (Sprite) {
+ Sprite->Goto(col, row);
+ //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$
+ }
+ break;
}
- if (! shpcnt)
- error("No shapes [%s]", fname);
- }
- else // no sprite description: mono-shaped sprite with only .BMP file
- {
- ++ shpcnt;
- }
-
- // make sprite of choosen type
- switch (type)
- {
- case 1 : // AUTO
- {
- Sprite = new SPRITE(NULL);
- if (Sprite)
- {
- Sprite->Goto(col, row);
- //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$
- }
- break;
- }
- case 2 : // WALK
- {
- WALK * w = new WALK(NULL);
- if (w && ref == 1)
- {
- w->Goto(col, row);
- if (Hero)
- error("2nd HERO [%s]", fname);
- Hero = w;
- }
- Sprite = w;
- break;
- }
- /*
- case 3 : // NEWTON
- NEWTON * n = new NEWTON(NULL);
- if (n)
- {
- n->Ay = (bottom-n->H);
- n->By = 90;
- n->Cy = 3;
- n->Bx = 99;
- n->Cx = 3;
- n->Goto(col, row);
- }
- Sprite = n;
- break;
- */
- case 4 : // LISSAJOUS
- {
- error("Bad type [%s]", fname);
- /*
- LISSAJOUS * l = new LISSAJOUS(NULL);
- if (l)
- {
+ case 2 : { // WALK
+ WALK *w = new WALK(NULL);
+ if (w && ref == 1) {
+ w->Goto(col, row);
+ if (Hero)
+ error("2nd HERO [%s]", fname);
+ Hero = w;
+ }
+ Sprite = w;
+ break;
+ }
+ /*
+ case 3 : // NEWTON
+ NEWTON * n = new NEWTON(NULL);
+ if (n)
+ {
+ n->Ay = (bottom-n->H);
+ n->By = 90;
+ n->Cy = 3;
+ n->Bx = 99;
+ n->Cx = 3;
+ n->Goto(col, row);
+ }
+ Sprite = n;
+ 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;
@@ -1804,448 +1487,416 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro
* (long *) &l->Dx = 0; // movex * cnt
l->Goto(col, row);
}
- Sprite = l;
- */
- break;
- }
- case 5 : // FLY
- {
- FLY * f = new FLY(NULL);
- Sprite = f;
- //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$
- break;
- }
- default: // DEAD
- {
- Sprite = new SPRITE(NULL);
- if (Sprite) Sprite->Goto(col, row);
- break;
- }
- }
- if (Sprite)
- {
- Sprite->Ref = ref;
- Sprite->Cave = cav;
- Sprite->Z = pos;
- Sprite->Flags.East = east;
- Sprite->Flags.Port = port;
- Sprite->Flags.Tran = tran;
- Sprite->Flags.Kill = true;
- Sprite->Flags.BDel = true;
- //fnsplit(fname, NULL, NULL, Sprite->File, NULL);
- warning("LoadSprite: use of fnsplit");
-
- Sprite->ShpCnt = shpcnt;
- VGA::SpareQ.Append(Sprite);
- }
-}
-
-
-
-
-
-
-static void LoadScript (const char *fname)
-{
- 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;
-
- if (scrf.Error) return;
-
- while (scrf.Read((uint8*)line) != 0)
- {
- char *p;
-
- ++ lcnt;
- if (*line == 0 || *line == '\n' || *line == '.') continue;
-
- ok = false; // not OK if break
- // sprite ident number
- if ((p = strtok(line, " \t\n")) == NULL) break;
- SpI = atoi(p);
- // sprite file name
- if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) break;
- // sprite cave
- if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break;
- SpA = atoi(p);
- // sprite column
- if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break;
- SpX = atoi(p);
- // sprite row
- if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break;
- SpY = atoi(p);
- // sprite Z pos
- if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break;
- SpZ = atoi(p);
- // sprite life
- if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break;
- BkG = atoi(p) == 0;
-
- ok = true; // no break: OK
-
- Sprite = NULL;
- LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ);
- if (Sprite && BkG) Sprite->Flags.Back = true;
- }
- if (! ok)
- error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname);
-}
-
-
-
-
-static void MainLoop (void)
-{
-#if 0
-//def DEBUG
- static VgaRegBlk Mode[] = {
+ Sprite = l;
+ */
+ break;
+ }
+ case 5 : { // FLY
+ FLY *f = new FLY(NULL);
+ Sprite = f;
+ //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$
+ break;
+ }
+ default: { // DEAD
+ Sprite = new SPRITE(NULL);
+ if (Sprite)
+ Sprite->Goto(col, row);
+ break;
+ }
+ }
+ if (Sprite) {
+ Sprite->Ref = ref;
+ Sprite->Cave = cav;
+ Sprite->Z = pos;
+ Sprite->Flags.East = east;
+ Sprite->Flags.Port = port;
+ Sprite->Flags.Tran = tran;
+ Sprite->Flags.Kill = true;
+ Sprite->Flags.BDel = true;
+ //fnsplit(fname, NULL, NULL, Sprite->File, NULL);
+ warning("LoadSprite: use of fnsplit");
+
+ Sprite->ShpCnt = shpcnt;
+ VGA::SpareQ.Append(Sprite);
+ }
+}
- { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode
- { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0
- { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0
- { 0x06, VGAGRA, 0x02, 0x00 }, // misc
+static void LoadScript(const char *fname) {
+ 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;
- { 0x14, VGACRT, 0x40, 0x00 }, // underline
- { 0x13, VGACRT, 0xFF, 0x28 }, // screen width
- { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control
+ if (scrf.Error)
+ return;
- { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end
- { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line
+ while (scrf.Read((uint8 *)line) != 0) {
+ char *p;
- { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode
+ ++lcnt;
+ if (*line == 0 || *line == '\n' || *line == '.')
+ continue;
-// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end
-// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb
-// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr
+ ok = false; // not OK if break
+ // sprite ident number
+ if ((p = strtok(line, " \t\n")) == NULL)
+ break;
+ SpI = atoi(p);
+ // sprite file name
+ if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL)
+ break;
+ // sprite cave
+ if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
+ break;
+ SpA = atoi(p);
+ // sprite column
+ if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
+ break;
+ SpX = atoi(p);
+ // sprite row
+ if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
+ break;
+ SpY = atoi(p);
+ // sprite Z pos
+ if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
+ break;
+ SpZ = atoi(p);
+ // sprite life
+ if ((p = strtok(NULL, " ,;/\t\n")) == NULL)
+ break;
+ BkG = atoi(p) == 0;
- { 0x00 } };
+ ok = true; // no break: OK
- Vga.Setup(Mode);
-#endif
+ Sprite = NULL;
+ LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ);
+ if (Sprite && BkG)
+ Sprite->Flags.Back = true;
+ }
+ if (! ok)
+ error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname);
+}
- Debug( SayDebug(); )
- #ifdef DEMO
- #define TIM ((182L*6L) * 5L)
- static uint32 tc = 0;
- if (TimerCount - tc >= TIM && Talk == NULL && Snail.Idle())
- {
- if (Text[DemoText])
- {
- SNPOST(SNSOUND, -1, 4, NULL); // drumla
- SNPOST(SNINF, -1, DemoText, NULL);
- SNPOST(SNLABEL, -1, -1, NULL);
- if (Text[++ DemoText] == NULL) DemoText = DEMO_TEXT + 1;
- }
- tc = TimerCount;
- }
- #undef TIM
- #endif
+static void MainLoop(void) {
+#if 0
+//def DEBUG
+ static VgaRegBlk Mode[] = {
- Vga.Show();
- Snail_.RunCom();
- Snail.RunCom();
-}
+ { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode
+ { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0
+ { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0
+ { 0x06, VGAGRA, 0x02, 0x00 }, // misc
+ { 0x14, VGACRT, 0x40, 0x00 }, // underline
+ { 0x13, VGACRT, 0xFF, 0x28 }, // screen width
+ { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control
+ { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end
+ { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line
+ { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode
-void LoadUser (void)
-{
- // set scene
- if (STARTUP::Mode == 0) // user .SVG file found
- {
- CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt);
- LoadGame(cfile);
- }
- else
- {
- if (STARTUP::Mode == 1)
- {
- SVG0FILE file = SVG0FILE(SVG0NAME);
- LoadGame(file);
- }
- else
- {
- LoadScript(ProgName(INI_EXT));
- Music = true;
- CFILE file = CFILE(SVG0NAME, WRI);
- SaveGame(file);
- error("Ok [%s]", SVG0NAME);
+// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end
+// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb
+// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr
+
+ { 0x00 }
+ };
+
+ Vga.Setup(Mode);
+#endif
+
+ Debug(SayDebug();)
+
+#ifdef DEMO
+#define TIM ((182L*6L) * 5L)
+ static uint32 tc = 0;
+ if (TimerCount - tc >= TIM && Talk == NULL && Snail.Idle()) {
+ if (Text[DemoText]) {
+ SNPOST(SNSOUND, -1, 4, NULL); // drumla
+ SNPOST(SNINF, -1, DemoText, NULL);
+ SNPOST(SNLABEL, -1, -1, NULL);
+ if (Text[++ DemoText] == NULL) DemoText = DEMO_TEXT + 1;
+ }
+ tc = TimerCount;
}
- }
- LoadScript(ProgName(IN0_EXT));
+#undef TIM
+#endif
+
+ Vga.Show();
+ Snail_.RunCom();
+ Snail.RunCom();
+}
+
+
+void LoadUser(void) {
+ // set scene
+ if (STARTUP::Mode == 0) { // user .SVG file found
+ CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt);
+ LoadGame(cfile);
+ } else {
+ if (STARTUP::Mode == 1) {
+ SVG0FILE file = SVG0FILE(SVG0NAME);
+ LoadGame(file);
+ } else {
+ LoadScript(ProgName(INI_EXT));
+ Music = true;
+ CFILE file = CFILE(SVG0NAME, WRI);
+ SaveGame(file);
+ error("Ok [%s]", SVG0NAME);
+ }
+ }
+ LoadScript(ProgName(IN0_EXT));
}
+static void RunGame(void) {
+ Text.Clear();
+ Text.Preload(100, 1000);
+ LoadHeroXY();
+ CavLight.Flags.Tran = true;
+ VGA::ShowQ.Append(&CavLight);
+ CavLight.Flags.Hide = true;
+ static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 },
+ { 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 },
+ };
+ PocLight.SetSeq(PocSeq);
+ PocLight.Flags.Tran = true;
+ PocLight.Time = 1;
+ PocLight.Z = 120;
+ VGA::ShowQ.Append(&PocLight);
+ SelectPocket(-1);
-static void RunGame (void)
-{
- Text.Clear();
- Text.Preload(100, 1000);
- LoadHeroXY();
-
- CavLight.Flags.Tran = true;
- VGA::ShowQ.Append(&CavLight);
- CavLight.Flags.Hide = true;
-
- static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 },
- { 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 },
- };
- PocLight.SetSeq(PocSeq);
- PocLight.Flags.Tran = true;
- PocLight.Time = 1;
- PocLight.Z = 120;
- VGA::ShowQ.Append(&PocLight);
- SelectPocket(-1);
-
- VGA::ShowQ.Append(&Mouse);
+ VGA::ShowQ.Append(&Mouse);
// ___________
- LoadUser();
+ LoadUser();
// ~~~~~~~~~~~
- if ((Sprite = VGA::SpareQ.Locate(121)) != NULL)
- SNPOST_(SNSEQ, -1, VGA::Mono, Sprite);
- if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) Sprite->Step(Music);
- SNPOST_(SNSEQ, -1, Music, Sprite);
- if (! Music) KillMIDI();
-
- if (Mini && INI_FILE::Exist("MINI.SPR"))
- {
- uint8 * ptr = (uint8 *) &*Mini;
- if (ptr != NULL)
- {
- LoadSprite("MINI", -1, 0, MINI_X, MINI_Y);
- ExpandSprite(MiniCave = Sprite); // NULL is ok
- if (MiniCave)
- {
- MiniCave->Flags.Hide = true;
- MiniCave->MoveShapes(ptr);
- MiniShp[0] = new BITMAP(*MiniCave->Shp());
- MiniShpList = MiniCave->SetShapeList(MiniShp);
- PostMiniStep(-1);
- }
+ if ((Sprite = VGA::SpareQ.Locate(121)) != NULL)
+ SNPOST_(SNSEQ, -1, VGA::Mono, Sprite);
+ if ((Sprite = VGA::SpareQ.Locate(122)) != NULL)
+ Sprite->Step(Music);
+ SNPOST_(SNSEQ, -1, Music, Sprite);
+ if (! Music)
+ KillMIDI();
+
+ if (Mini && INI_FILE::Exist("MINI.SPR")) {
+ uint8 *ptr = (uint8 *) &*Mini;
+ if (ptr != NULL) {
+ LoadSprite("MINI", -1, 0, MINI_X, MINI_Y);
+ ExpandSprite(MiniCave = Sprite); // NULL is ok
+ if (MiniCave) {
+ MiniCave->Flags.Hide = true;
+ MiniCave->MoveShapes(ptr);
+ MiniShp[0] = new BITMAP(*MiniCave->Shp());
+ MiniShpList = MiniCave->SetShapeList(MiniShp);
+ PostMiniStep(-1);
+ }
+ }
}
- }
- if (Hero)
- {
- ExpandSprite(Hero);
- Hero->Goto(HeroXY[Now-1].X, HeroXY[Now-1].Y);
- if (INI_FILE::Exist("00SHADOW.SPR"))
- {
- LoadSprite("00SHADOW", -1, 0, Hero->X + 14, Hero->Y + 51);
- if ((Shadow = Sprite) != NULL)
- {
- Shadow->Ref = 2;
- Shadow->Flags.Tran = true;
- Hero->Flags.Shad = true;
- VGA::ShowQ.Insert(VGA::SpareQ.Remove(Shadow), Hero);
- }
+ if (Hero) {
+ ExpandSprite(Hero);
+ Hero->Goto(HeroXY[Now - 1].X, HeroXY[Now - 1].Y);
+ if (INI_FILE::Exist("00SHADOW.SPR")) {
+ LoadSprite("00SHADOW", -1, 0, Hero->X + 14, Hero->Y + 51);
+ if ((Shadow = Sprite) != NULL) {
+ Shadow->Ref = 2;
+ Shadow->Flags.Tran = true;
+ Hero->Flags.Shad = true;
+ VGA::ShowQ.Insert(VGA::SpareQ.Remove(Shadow), Hero);
+ }
+ }
}
- }
-
- InfoLine.Goto(INFO_X, INFO_Y);
- InfoLine.Flags.Tran = true;
- InfoLine.Update(NULL);
- VGA::ShowQ.Insert(&InfoLine);
-
- #ifdef DEBUG
- DebugLine.Z = 126;
- VGA::ShowQ.Insert(&DebugLine);
-
- HorzLine.Y = MAP_TOP - (MAP_TOP > 0);
- HorzLine.Z = 126;
- VGA::ShowQ.Insert(&HorzLine);
- #endif
- Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF);
- if (Mouse.Busy) ExpandSprite(Mouse.Busy);
+ InfoLine.Goto(INFO_X, INFO_Y);
+ InfoLine.Flags.Tran = true;
+ InfoLine.Update(NULL);
+ VGA::ShowQ.Insert(&InfoLine);
- Startup = 0;
+#ifdef DEBUG
+ DebugLine.Z = 126;
+ VGA::ShowQ.Insert(&DebugLine);
- SNPOST(SNLEVEL, -1, OldLev, &CavLight);
- CavLight.Goto(CAVE_X + ((Now-1) % CAVE_NX) * CAVE_DX + CAVE_SX,
- CAVE_Y + ((Now-1) / CAVE_NX) * CAVE_DY + CAVE_SY);
- CaveUp();
+ HorzLine.Y = MAP_TOP - (MAP_TOP > 0);
+ HorzLine.Z = 126;
+ VGA::ShowQ.Insert(&HorzLine);
+#endif
- KEYBOARD::SetClient(Sys);
- // main loop
- while (! Finis)
- {
- //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");
- MainLoop();
- }
-
- KEYBOARD::SetClient(NULL);
- HEART::Enable = false;
- SNPOST(SNCLEAR, -1, 0, NULL);
- SNPOST_(SNCLEAR, -1, 0, NULL);
- Mouse.Off();
- VGA::ShowQ.Clear();
- VGA::SpareQ.Clear();
- Hero = NULL;
- Shadow = NULL;
-}
+ Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF);
+ if (Mouse.Busy)
+ ExpandSprite(Mouse.Busy);
+ Startup = 0;
+ SNPOST(SNLEVEL, -1, OldLev, &CavLight);
+ CavLight.Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
+ CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
+ CaveUp();
+ KEYBOARD::SetClient(Sys);
+ // main loop
+ while (! Finis) {
+ //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");
+ MainLoop();
+ }
-void Movie (const char * ext)
-{
- const char * fn = ProgName(ext);
- if (INI_FILE::Exist(fn))
- {
- LoadScript(fn);
- ExpandSprite(VGA::SpareQ.Locate(999));
- FeedSnail(VGA::ShowQ.Locate(999), TAKE);
- VGA::ShowQ.Append(&Mouse);
- HEART::Enable = true;
- KEYBOARD::SetClient(Sys);
- while (! Snail.Idle())
- {
- MainLoop();
+ KEYBOARD::SetClient(NULL);
+ HEART::Enable = false;
+ SNPOST(SNCLEAR, -1, 0, NULL);
+ SNPOST_(SNCLEAR, -1, 0, NULL);
+ Mouse.Off();
+ VGA::ShowQ.Clear();
+ VGA::SpareQ.Clear();
+ Hero = NULL;
+ Shadow = NULL;
+}
+
+
+void Movie(const char *ext) {
+ const char *fn = ProgName(ext);
+ if (INI_FILE::Exist(fn)) {
+ LoadScript(fn);
+ ExpandSprite(VGA::SpareQ.Locate(999));
+ FeedSnail(VGA::ShowQ.Locate(999), TAKE);
+ VGA::ShowQ.Append(&Mouse);
+ HEART::Enable = true;
+ KEYBOARD::SetClient(Sys);
+ while (! Snail.Idle()) {
+ MainLoop();
+ }
+ KEYBOARD::SetClient(NULL);
+ HEART::Enable = false;
+ SNPOST(SNCLEAR, -1, 0, NULL);
+ SNPOST_(SNCLEAR, -1, 0, NULL);
+ VGA::ShowQ.Clear();
+ VGA::SpareQ.Clear();
}
- KEYBOARD::SetClient(NULL);
- HEART::Enable = false;
- SNPOST(SNCLEAR, -1, 0, NULL);
- SNPOST_(SNCLEAR, -1, 0, NULL);
- VGA::ShowQ.Clear();
- VGA::SpareQ.Clear();
- }
}
+bool ShowTitle(const char *name) {
+ BITMAP::Pal = SysPal;
+ BMP_PTR LB[] = { new BITMAP(name), NULL };
+ BITMAP::Pal = NULL;
+ bool usr_ok = false;
+ SPRITE D(LB);
+ D.Flags.Kill = true;
+ D.Flags.BDel = true;
+ D.Center();
+ D.Show(2);
+ if (STARTUP::Mode == 2) {
+ Inf(SVG0NAME);
+ Talk->Show(2);
+ }
+ Vga.Sunset();
+ VGA::CopyPage(1, 2);
+ VGA::CopyPage(0, 1);
+ SelectPocket(-1);
+ Vga.Sunrise(SysPal);
+
+ if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) {
+ VGA::CopyPage(1, 2);
+ VGA::CopyPage(0, 1);
+ VGA::ShowQ.Append(&Mouse);
+ HEART::Enable = true;
+ Mouse.On();
+ for (SelectSound(); ! Snail.Idle() || VMENU::Addr;)
+ MainLoop();
+ Mouse.Off();
+ HEART::Enable = false;
+ VGA::ShowQ.Clear();
+ VGA::CopyPage(0, 2);
+ STARTUP::SoundOk = 2;
+ if (Music)
+ LoadMIDI(0);
+ }
-bool ShowTitle (const char * name)
-{
- BITMAP::Pal = SysPal;
- BMP_PTR LB[] = { new BITMAP(name), NULL };
- BITMAP::Pal = NULL;
- bool usr_ok = false;
-
- SPRITE D(LB);
- D.Flags.Kill = true;
- D.Flags.BDel = true;
- D.Center();
- D.Show(2);
-
- if (STARTUP::Mode == 2)
- {
- Inf(SVG0NAME);
- Talk->Show(2);
- }
-
- Vga.Sunset();
- VGA::CopyPage(1, 2);
- VGA::CopyPage(0, 1);
- SelectPocket(-1);
- Vga.Sunrise(SysPal);
-
- if (STARTUP::Mode < 2 && ! STARTUP::SoundOk)
- {
- VGA::CopyPage(1, 2);
- VGA::CopyPage(0, 1);
- VGA::ShowQ.Append(&Mouse);
- HEART::Enable = true;
- Mouse.On();
- for (SelectSound(); ! Snail.Idle() || VMENU::Addr; ) MainLoop();
- Mouse.Off();
- HEART::Enable = false;
- VGA::ShowQ.Clear();
- VGA::CopyPage(0, 2);
- STARTUP::SoundOk = 2;
- if (Music) LoadMIDI(0);
- }
-
- if (STARTUP::Mode < 2)
- {
- #ifdef DEMO
- strcpy(UsrFnam, ProgName(SVG_EXT));
- usr_ok = true;
- #else
- //-----------------------------------------
- #ifndef EVA
- #ifdef CD
- STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF;
- #else
+ if (STARTUP::Mode < 2) {
+#ifdef DEMO
+ strcpy(UsrFnam, ProgName(SVG_EXT));
+ usr_ok = true;
+#else
+ //-----------------------------------------
+#ifndef EVA
+#ifdef CD
+ STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF;
+#else
// Boot * b = ReadBoot(getdisk());
warning("ShowTitle: FIXME ReadBoot");
- Boot * b = ReadBoot(0);
- uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs;
- free(b);
- sn -= ((IDENT *)Copr)->disk;
- STARTUP::Summa |= Lo(sn) | Hi(sn);
- #endif
- #endif
- //-----------------------------------------
- Movie("X00"); // paylist
- VGA::CopyPage(1, 2);
- VGA::CopyPage(0, 1);
- VGA::ShowQ.Append(&Mouse);
- //Mouse.On();
- HEART::Enable = true;
- for (TakeName(); GET_TEXT::Ptr; ) MainLoop();
- HEART::Enable = false;
- if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true;
- if (usr_ok) strcat(UsrFnam, SVG_EXT);
- //Mouse.Off();
- VGA::ShowQ.Clear();
- VGA::CopyPage(0, 2);
- #endif
- if (usr_ok && STARTUP::Mode == 0)
- {
- const char *n = UsrPath(UsrFnam);
- if (CFILE::Exist(n))
- {
- CFILE file = CFILE(n, REA, RCrypt);
- LoadGame(file, true); // only system vars
- VGA::SetColors(SysPal, 64);
- Vga.Update();
- if (FINIS)
- {
- ++ STARTUP::Mode;
- FINIS = false;
+ Boot *b = ReadBoot(0);
+ uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs;
+ free(b);
+ sn -= ((IDENT *)Copr)->disk;
+ STARTUP::Summa |= Lo(sn) | Hi(sn);
+#endif
+#endif
+ //-----------------------------------------
+ Movie("X00"); // paylist
+ VGA::CopyPage(1, 2);
+ VGA::CopyPage(0, 1);
+ VGA::ShowQ.Append(&Mouse);
+ //Mouse.On();
+ HEART::Enable = true;
+ for (TakeName(); GET_TEXT::Ptr;)
+ MainLoop();
+ HEART::Enable = false;
+ if (KEYBOARD::Last() == Enter && *UsrFnam)
+ usr_ok = true;
+ if (usr_ok)
+ strcat(UsrFnam, SVG_EXT);
+ //Mouse.Off();
+ VGA::ShowQ.Clear();
+ VGA::CopyPage(0, 2);
+#endif
+ if (usr_ok && STARTUP::Mode == 0) {
+ const char *n = UsrPath(UsrFnam);
+ if (CFILE::Exist(n)) {
+ CFILE file = CFILE(n, REA, RCrypt);
+ LoadGame(file, true); // only system vars
+ VGA::SetColors(SysPal, 64);
+ Vga.Update();
+ if (FINIS) {
+ ++ STARTUP::Mode;
+ FINIS = false;
+ }
+ } else
+ ++STARTUP::Mode;
}
- }
- else ++ STARTUP::Mode;
}
- }
- if (STARTUP::Mode < 2) Movie("X01"); // wink
+ if (STARTUP::Mode < 2)
+ Movie("X01"); // wink
- VGA::CopyPage(0, 2);
+ VGA::CopyPage(0, 2);
- #ifdef DEMO
- return true;
- #else
- return (STARTUP::Mode == 2 || usr_ok);
- #endif
+#ifdef DEMO
+ return true;
+#else
+ return (STARTUP::Mode == 2 || usr_ok);
+#endif
}
-
-
/*
#ifdef DEBUG
void StkDump (void)
@@ -2257,40 +1908,40 @@ void StkDump (void)
*/
+void cge_main(void) {
+ uint16 intStack[STACK_SIZ / 2];
+ intStackPtr = intStack;
+ //Debug( memset((void *) (-K(2)), 0, K(1)); )
+ //Debug( memset((void *) (-K(4)), 0, K(1)); )
+ memset(Barriers, 0xFF, sizeof(Barriers));
-void cge_main (void)
-{
- uint16 intStack[STACK_SIZ/2];
- intStackPtr = intStack;
-
- //Debug( memset((void *) (-K(2)), 0, K(1)); )
- //Debug( memset((void *) (-K(4)), 0, K(1)); )
- memset(Barriers, 0xFF, sizeof(Barriers));
-
- if (! Mouse.Exist)
- error("%s", Text[NO_MOUSE_TEXT]);
- if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2;
-
- Debug( DebugLine.Flags.Hide = true; )
- Debug( HorzLine.Flags.Hide = true; )
-
- //srand((uint16) Timer());
- Sys = new SYSTEM;
-
- if (Music && STARTUP::SoundOk) LoadMIDI(0);
- if (STARTUP::Mode < 2) Movie(LGO_EXT);
- if (ShowTitle("WELCOME"))
- {
- #ifndef DEMO
- if (STARTUP::Mode == 1) Movie("X02"); // intro
- #endif
- RunGame();
- Startup = 2;
- if (FINIS) Movie("X03");
- }
- else Vga.Sunset();
- error("%s", Text[EXIT_OK_TEXT+FINIS]);
+ if (! Mouse.Exist)
+ error("%s", Text[NO_MOUSE_TEXT]);
+ if (! SVG0FILE::Exist(SVG0NAME))
+ STARTUP::Mode = 2;
+
+ Debug(DebugLine.Flags.Hide = true;)
+ Debug(HorzLine.Flags.Hide = true;)
+
+ //srand((uint16) Timer());
+ Sys = new SYSTEM;
+
+ if (Music && STARTUP::SoundOk)
+ LoadMIDI(0);
+ if (STARTUP::Mode < 2)
+ Movie(LGO_EXT);
+ if (ShowTitle("WELCOME")) {
+#ifndef DEMO
+ if (STARTUP::Mode == 1) Movie("X02"); // intro
+#endif
+ RunGame();
+ Startup = 2;
+ if (FINIS)
+ Movie("X03");
+ } else
+ Vga.Sunset();
+ error("%s", Text[EXIT_OK_TEXT + FINIS]);
}
} // End of namespace CGE
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index 30a07dd67e..a67cd29000 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -25,185 +25,163 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __CGE__
-#define __CGE__
+#ifndef __CGE__
+#define __CGE__
-#include "cge\wav.h"
-#include "cge\vga13h.h"
+#include "cge\wav.h"
+#include "cge\vga13h.h"
namespace CGE {
-#define TSEQ 96
-#define HTALK (TSEQ+4)
-#define TOO_FAR (TSEQ+5)
-#define NO_WAY (TSEQ+5)
-#define POC_FUL (TSEQ+5)
-#define OFF_USE (TSEQ+6)
-
-#define EXIT_OK_TEXT 40
-#define NOMUSIC_TEXT 98
-#define BADSVG_TEXT 99
-#define OFF_USE_COUNT 600
-#define OFF_USE_TEXT 601
-#define NO_WAY_TEXT 671
-#define TOO_FAR_TEXT 681
-#define POC_FUL_TEXT 691
-#define A_C_D_TEXT 777
-
-#define GETNAME_PROMPT 50
-#define GETNAME_TITLE 51
-
-#define QUIT_TITLE 200
-#define QUIT_TEXT 201
-#define NOQUIT_TEXT 202
-#define DEMO_TEXT 300
-#define NOSOUND_TEXT 310
-
-#define PAN_HIG 40
-#define WORLD_HIG (SCR_HIG-PAN_HIG)
-
-#define INFO_X 177
-#define INFO_Y 164
-#define INFO_W 140
+#define TSEQ 96
+#define HTALK (TSEQ+4)
+#define TOO_FAR (TSEQ+5)
+#define NO_WAY (TSEQ+5)
+#define POC_FUL (TSEQ+5)
+#define OFF_USE (TSEQ+6)
+
+#define EXIT_OK_TEXT 40
+#define NOMUSIC_TEXT 98
+#define BADSVG_TEXT 99
+#define OFF_USE_COUNT 600
+#define OFF_USE_TEXT 601
+#define NO_WAY_TEXT 671
+#define TOO_FAR_TEXT 681
+#define POC_FUL_TEXT 691
+#define A_C_D_TEXT 777
+
+#define GETNAME_PROMPT 50
+#define GETNAME_TITLE 51
+
+#define QUIT_TITLE 200
+#define QUIT_TEXT 201
+#define NOQUIT_TEXT 202
+#define DEMO_TEXT 300
+#define NOSOUND_TEXT 310
+
+#define PAN_HIG 40
+#define WORLD_HIG (SCR_HIG-PAN_HIG)
+
+#define INFO_X 177
+#define INFO_Y 164
+#define INFO_W 140
#if defined(DEMO)
- #define CAVE_X 4
- #define CAVE_Y 166
- #define CAVE_SX 0
- #define CAVE_SY 0
- #define CAVE_DX 23
- #define CAVE_DY 29
- #define CAVE_NX 3
- #define CAVE_NY 1
-#else
- #define CAVE_X 4
- #define CAVE_Y 166
- #define CAVE_SX 0
- #define CAVE_SY 0
- #define CAVE_DX 9
- #define CAVE_DY 10
- #define CAVE_NX 8
- #define CAVE_NY 3
+#define CAVE_X 4
+#define CAVE_Y 166
+#define CAVE_SX 0
+#define CAVE_SY 0
+#define CAVE_DX 23
+#define CAVE_DY 29
+#define CAVE_NX 3
+#define CAVE_NY 1
+#else
+#define CAVE_X 4
+#define CAVE_Y 166
+#define CAVE_SX 0
+#define CAVE_SY 0
+#define CAVE_DX 9
+#define CAVE_DY 10
+#define CAVE_NX 8
+#define CAVE_NY 3
#endif
-#define BUTTON_X 151
-#define BUTTON_Y 164
-#define BUTTON_DX 19
-#define BUTTON_DY 11
-#define BUTTON_NX 1
-#define BUTTON_NY 3
-
-#define MINI_X 86
-#define MINI_Y 162
-
-//#define MAP_XCNT 16
-//#define MAP_ZCNT 4
-#define MAP_XCNT 40
-#define MAP_ZCNT 20
-#define MAP_TOP 80
-#define MAP_HIG 80
-#define MAP_XGRID (SCR_WID / MAP_XCNT)
-#define MAP_ZGRID (MAP_HIG / MAP_ZCNT)
-
-//#if SCR_WID % MAP_XGRID
-// #error Illegal horizontal grid size or count
-//#endif
-
-//#if MAP_HIG % MAP_ZGRID
-// #error Illegal vertical grid size or count
-//#endif
-
-#define LINE_MAX 512
-#define USER_MAX 100
-#define SHP_MAX 1024
-#define STD_DELAY 3
-#define LEV_MAX 5
-#define CAVE_MAX (CAVE_NX*CAVE_NY)
-#define MAX_FIND_LEVEL 3
-#define MAX_DISTANCE 3
-
-#define INI_EXT ".INI"
-#define IN0_EXT ".IN0"
-#define LGO_EXT ".LGO"
-#define SVG_EXT ".SVG"
-
-#define WALKSIDE 10
-
-#define BUSY_REF 500
-
-#define SYSTIMERATE 6 // 12 Hz
-#define HEROFUN0 (40*12)
-#define HEROFUN1 ( 2*12)
-#define PAIN (Flag[0])
-#define FINIS (Flag[3])
-
-
-//--------------------------------------------------------------------------
-
-
-class SYSTEM : public SPRITE
-{
- int lum;
+#define BUTTON_X 151
+#define BUTTON_Y 164
+#define BUTTON_DX 19
+#define BUTTON_DY 11
+#define BUTTON_NX 1
+#define BUTTON_NY 3
+
+#define MINI_X 86
+#define MINI_Y 162
+
+//#define MAP_XCNT 16
+//#define MAP_ZCNT 4
+#define MAP_XCNT 40
+#define MAP_ZCNT 20
+#define MAP_TOP 80
+#define MAP_HIG 80
+#define MAP_XGRID (SCR_WID / MAP_XCNT)
+#define MAP_ZGRID (MAP_HIG / MAP_ZCNT)
+
+#define LINE_MAX 512
+#define USER_MAX 100
+#define SHP_MAX 1024
+#define STD_DELAY 3
+#define LEV_MAX 5
+#define CAVE_MAX (CAVE_NX*CAVE_NY)
+#define MAX_FIND_LEVEL 3
+#define MAX_DISTANCE 3
+
+#define INI_EXT ".INI"
+#define IN0_EXT ".IN0"
+#define LGO_EXT ".LGO"
+#define SVG_EXT ".SVG"
+
+#define WALKSIDE 10
+
+#define BUSY_REF 500
+
+#define SYSTIMERATE 6 // 12 Hz
+#define HEROFUN0 (40*12)
+#define HEROFUN1 ( 2*12)
+#define PAIN (Flag[0])
+#define FINIS (Flag[3])
+
+
+class SYSTEM : public SPRITE {
+ int lum;
public:
- static int FunDel;
- static void SetPal (void);
- static void FunTouch (void);
- SYSTEM (void) : SPRITE(NULL) { SetPal(); Tick(); }
- void Touch (uint16 mask, int x, int y);
- void Tick (void);
+ static int FunDel;
+ static void SetPal(void);
+ static void FunTouch(void);
+ SYSTEM(void) : SPRITE(NULL) {
+ SetPal();
+ Tick();
+ }
+ void Touch(uint16 mask, int x, int y);
+ void Tick(void);
};
-
-
-//--------------------------------------------------------------------------
-
-
-
-
-class CLUSTER : public COUPLE
-{
+class CLUSTER : public COUPLE {
public:
- static uint8 Map[MAP_ZCNT][MAP_XCNT];
- uint8 &Cell (void);
- CLUSTER (void) : COUPLE () { }
- CLUSTER (int a, int b) : COUPLE (a, b) { }
- bool Protected (void);
+ static uint8 Map[MAP_ZCNT][MAP_XCNT];
+ uint8 &Cell(void);
+ CLUSTER(void) : COUPLE() { }
+ CLUSTER(int a, int b) : COUPLE(a, b) { }
+ bool Protected(void);
};
-
-
-class WALK : public SPRITE
-{
+class WALK : public SPRITE {
public:
- CLUSTER Here;
- enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir;
- int TracePtr;
- WALK (BMP_PTR * shpl);
- void Tick (void);
- void FindWay(CLUSTER c);
- void FindWay(SPRITE * spr);
- int Distance (SPRITE * spr);
- void Turn (DIR d);
- void Park (void);
- bool Lower (SPRITE * spr);
- void Reach (SPRITE * spr, int mode = -1);
+ CLUSTER Here;
+ enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir;
+ int TracePtr;
+ WALK(BMP_PTR *shpl);
+ void Tick(void);
+ void FindWay(CLUSTER c);
+ void FindWay(SPRITE *spr);
+ int Distance(SPRITE *spr);
+ void Turn(DIR d);
+ void Park(void);
+ bool Lower(SPRITE *spr);
+ void Reach(SPRITE *spr, int mode = -1);
};
+CLUSTER XZ(int x, int y);
+CLUSTER XZ(COUPLE xy);
- CLUSTER XZ (int x, int y);
- CLUSTER XZ (COUPLE xy);
-
-
-extern WALK * Hero;
+extern WALK *Hero;
- void ExpandSprite (SPRITE * spr);
- void ContractSprite (SPRITE * spr);
- void cge_main(void);
+void ExpandSprite(SPRITE *spr);
+void ContractSprite(SPRITE *spr);
+void cge_main(void);
} // End of namespace CGE
diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp
index ee4d1771f9..c1e9ae4762 100644
--- a/engines/cge/config.cpp
+++ b/engines/cge/config.cpp
@@ -25,11 +25,11 @@
* 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"
+#include "cge/config.h"
+#include "cge/sound.h"
+#include "cge/vmenu.h"
+#include "cge/text.h"
+#include "cge/cge_main.h"
namespace CGE {
@@ -41,284 +41,255 @@ namespace CGE {
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
-
-
-static void NONE (void);
-static void SB (void);
-static void SBM (void);
-static void GUS (void);
-static void GUSM (void);
-static void MIDI (void);
-static void AUTO (void);
-static void SetPortD (void);
-static void SetPortM (void);
-static void SetIRQ (void);
-static 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]);
+#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
+
+
+static void NONE(void);
+static void SB(void);
+static void SBM(void);
+static void GUS(void);
+static void GUSM(void);
+static void MIDI(void);
+static void AUTO(void);
+static void SetPortD(void);
+static void SetPortM(void);
+static void SetIRQ(void);
+static 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 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 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 ddeco(const char *str) {
+ return deco(str, atow);
}
-
-
-static uint16 xdeco (const char * str)
-{
- return deco(str, xtow);
+static uint16 xdeco(const char *str) {
+ return deco(str, xtow);
}
+static CHOICE *Cho;
+static int Hlp;
-
-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 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;
- //TODO Change the SNPOST message send to a special way to send function pointer
- //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect);
- warning("STUB: Select");
+static void Select(CHOICE *cho, int hlp) {
+ Cho = cho;
+ Hlp = hlp;
+ //TODO Change the SNPOST message send to a special way to send function pointer
+ //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect);
+ warning("STUB: Select");
}
-
-
-
-
-static void NONE (void)
-{
- SNDDrvInfo.DDEV = DEV_QUIET;
- SNDDrvInfo.MDEV = DEV_QUIET;
- Sound.Open();
+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 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 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 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 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 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 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 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 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 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();
+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
index 1e692afc4d..e3fe094681 100644
--- a/engines/cge/config.h
+++ b/engines/cge/config.h
@@ -25,12 +25,12 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __CONFIG__
-#define __CONFIG__
+#ifndef __CONFIG__
+#define __CONFIG__
namespace CGE {
-void SelectSound (void);
+void SelectSound(void);
} // End of namespace CGE
diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp
index 7d7a82a82b..f522f872c9 100644
--- a/engines/cge/detection.cpp
+++ b/engines/cge/detection.cpp
@@ -52,7 +52,7 @@ static const ADGameDescription gameDescriptions[] = {
"soltys", "Soltys Freeware",
{
{"vol.cat", 0, "0c33e2c304821a2444d297fc5e2d67c6", 50176},
- {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8437676},
+ {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8437676},
AD_LISTEND
},
Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE
@@ -145,7 +145,9 @@ void CGEMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(fileName);
}
-int CGEMetaEngine::getMaximumSaveSlot() const { return 99; }
+int CGEMetaEngine::getMaximumSaveSlot() const {
+ return 99;
+}
SaveStateList CGEMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
@@ -249,7 +251,7 @@ bool CGEMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameD
}
#if PLUGIN_ENABLED_DYNAMIC(CGE)
- REGISTER_PLUGIN_DYNAMIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine);
+REGISTER_PLUGIN_DYNAMIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine);
#else
- REGISTER_PLUGIN_STATIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine);
+REGISTER_PLUGIN_STATIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine);
#endif
diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp
index abf118bda2..b654000553 100644
--- a/engines/cge/ems.cpp
+++ b/engines/cge/ems.cpp
@@ -24,217 +24,203 @@
* This code is based on original Soltys source code
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-
+
#include "cge/general.h"
namespace CGE {
-#define EMS_INT 0x67
-#define PAGE_MASK 0x3FFF
-#define SIZ(n) ((n) ? ((long)n) : (0x10000L))
+#define EMS_INT 0x67
+#define PAGE_MASK 0x3FFF
+#define SIZ(n) ((n) ? ((long)n) : (0x10000L))
-enum EMM_FUN { GET_STATUS = 0x40,
- GET_FRAME,
- GET_SIZE,
- OPEN_HANDLE,
- MAP_PAGE,
- CLOSE_HANDLE,
- GET_VER,
- SAVE_CONTEXT,
- REST_CONTEXT,
- GET_PAGES = 0x4B,
- GET_HANDLES,
- GET_INFO,
- CONTROL };
+enum EMM_FUN {
+ GET_STATUS = 0x40, GET_FRAME, GET_SIZE, OPEN_HANDLE, MAP_PAGE,
+ CLOSE_HANDLE, GET_VER, SAVE_CONTEXT, REST_CONTEXT, GET_PAGES = 0x4B,
+ GET_HANDLES, GET_INFO, CONTROL
+};
void *EMM::Frame = NULL;
-EMM::EMM (long size): Han(-1), Top(0), Lim(0), List(NULL) {
-/*
- if (Test())
- {
- asm mov ah,GET_FRAME // get EMS frame segment
- asm int EMS_INT // do it!
- asm or ah,ah // see status
- asm jnz xit // abort on error
- Frame = (void _seg *) _BX; // save frame segment
-
- if (size == 0)
- {
- asm mov ah,GET_SIZE // get EMS memory size
- asm int EMS_INT // do it!
- asm or ah,ah // see status
- asm jnz xit // abort on error
- asm or bx,bx // test page count
- asm jz xit // abort if no free pages
- // number of available pages in BX is ready to use by OPEN
- }
- else _BX = (uint16) ((size + PAGE_MASK) >> 14);
- asm mov ah,OPEN_HANDLE // open EMM handle
- asm int EMS_INT // do it!
- asm or ah,ah // see status
- asm jnz xit // abort on error
- Han = _DX;
- Lim = _BX;
- Lim <<= 14;
- _DX = Han;
- asm mov ah,SAVE_CONTEXT // save mapping context
- asm int EMS_INT // do it!
- }
- xit:
-*/
+EMM::EMM(long size): Han(-1), Top(0), Lim(0), List(NULL) {
+ /*
+ if (Test())
+ {
+ asm mov ah,GET_FRAME // get EMS frame segment
+ asm int EMS_INT // do it!
+ asm or ah,ah // see status
+ asm jnz xit // abort on error
+ Frame = (void _seg *) _BX; // save frame segment
+
+ if (size == 0)
+ {
+ asm mov ah,GET_SIZE // get EMS memory size
+ asm int EMS_INT // do it!
+ asm or ah,ah // see status
+ asm jnz xit // abort on error
+ asm or bx,bx // test page count
+ asm jz xit // abort if no free pages
+ // number of available pages in BX is ready to use by OPEN
+ }
+ else _BX = (uint16) ((size + PAGE_MASK) >> 14);
+ asm mov ah,OPEN_HANDLE // open EMM handle
+ asm int EMS_INT // do it!
+ asm or ah,ah // see status
+ asm jnz xit // abort on error
+ Han = _DX;
+ Lim = _BX;
+ Lim <<= 14;
+ _DX = Han;
+ asm mov ah,SAVE_CONTEXT // save mapping context
+ asm int EMS_INT // do it!
+ }
+ xit:
+ */
warning("STUB: EMM:EMM");
}
EMM::~EMM(void) {
-/*
- Release();
- if (Han >= 0)
- {
- _DX = Han;
- asm mov ah,REST_CONTEXT
- asm int EMS_INT
- asm mov ah,CLOSE_HANDLE
- asm int EMS_INT
- }
-*/
+ /*
+ Release();
+ if (Han >= 0)
+ {
+ _DX = Han;
+ asm mov ah,REST_CONTEXT
+ asm int EMS_INT
+ asm mov ah,CLOSE_HANDLE
+ asm int EMS_INT
+ }
+ */
warning("STUB: EMM::~EMM");
}
-
bool EMM::Test(void) {
-/*
- static char e[] = "EMMXXXX0";
-
- asm mov ax,0x3D40
- asm mov dx,offset e
- asm int 0x21
- asm jc fail
-
- asm push ax
- asm mov bx,ax
- asm mov ax,0x4407
- asm int 0x21
-
- asm pop bx
- asm push ax
- asm mov ax,0x3E00
- asm int 0x21
- asm pop ax
-
- asm cmp al,0x00
- asm je fail
-
- success:
- return TRUE;
- fail:
- return FALSE;
-*/
+ /*
+ static char e[] = "EMMXXXX0";
+
+ asm mov ax,0x3D40
+ asm mov dx,offset e
+ asm int 0x21
+ asm jc fail
+
+ asm push ax
+ asm mov bx,ax
+ asm mov ax,0x4407
+ asm int 0x21
+
+ asm pop bx
+ asm push ax
+ asm mov ax,0x3E00
+ asm int 0x21
+ asm pop ax
+
+ asm cmp al,0x00
+ asm je fail
+
+ success:
+ return TRUE;
+ fail:
+ return FALSE;
+ */
warning("EMM::Test");
return FALSE;
}
-EMS * EMM::Alloc (uint16 siz) {
-/*
- long size = SIZ(siz),
- top = Top;
-
- uint16 pgn = (uint16) (top >> 14),
- cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn;
+EMS *EMM::Alloc(uint16 siz) {
+ /*
+ long size = SIZ(siz),
+ top = Top;
- if (cnt > 4)
- {
- top = (top + PAGE_MASK) & 0xFFFFC000L;
- ++ pgn;
- -- cnt;
- }
+ uint16 pgn = (uint16) (top >> 14),
+ cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn;
- if (size <= Lim - top)
- {
- EMS * e = new EMS, * f;
+ if (cnt > 4)
+ {
+ top = (top + PAGE_MASK) & 0xFFFFC000L;
+ ++ pgn;
+ -- cnt;
+ }
- if (e)
- {
- Top = (e->Ptr = top) + (e->Siz = siz);
- e->Emm = this;
+ if (size <= Lim - top)
+ {
+ EMS * e = new EMS, * f;
- if (List)
+ if (e)
{
- for (f = List; f->Nxt; f = f->Nxt);
- return (f->Nxt = e); // existing list: link to the end
+ Top = (e->Ptr = top) + (e->Siz = siz);
+ e->Emm = this;
+
+ if (List)
+ {
+ for (f = List; f->Nxt; f = f->Nxt);
+ return (f->Nxt = e); // existing list: link to the end
+ }
+ else
+ {
+ return (List = e); // empty list: link to the head
+ }
}
- else
- {
- return (List = e); // empty list: link to the head
}
- }
- }
- fail: return NULL;
-*/
+ fail: return NULL;
+ */
warning("STUB: EMM::Alloc");
return NULL;
}
-void EMM::Release (void) {
- while (List)
- {
- EMS * e = List;
- List = e->Nxt;
- delete e;
- }
- Top = 0;
+void EMM::Release(void) {
+ while (List) {
+ EMS *e = List;
+ List = e->Nxt;
+ delete e;
+ }
+ Top = 0;
}
-EMS::EMS (void)
-: Ptr(0), Siz(0), Nxt(NULL)
-{
+EMS::EMS(void) : Ptr(0), Siz(0), Nxt(NULL) {
}
-void * EMS::operator & () const
-{
-/*
- uint16 pgn = (uint16) (Ptr >> 14),
- off = (uint16) Ptr & PAGE_MASK,
- cnt = (uint16) ((Ptr + SIZ(Siz) + PAGE_MASK) >> 14) - pgn,
- cmd = MAP_PAGE << 8;
-
- _DX = Emm->Han; // take EMM handle
- asm dec cnt // prapare for deferred checking
- asm or dx,dx // see if valid
- asm jns more // negative handle = unavailable
-
- fail: return NULL;
-
- more:
- asm mov ax,cmd // command + page frame index
- asm mov bx,pgn // logical page number
- asm int EMS_INT // do it!
- asm or ah,ah // check error code
- asm jnz fail // exit on error
- asm inc cmd // advance page frame index
- asm inc pgn // advance logical page number
- asm cmp al,byte ptr cnt // all pages?
- asm jb more
-
- return (void *) (EMM::Frame + (void *) off);
-*/
+void *EMS::operator & () const {
+ /*
+ uint16 pgn = (uint16) (Ptr >> 14),
+ off = (uint16) Ptr & PAGE_MASK,
+ cnt = (uint16) ((Ptr + SIZ(Siz) + PAGE_MASK) >> 14) - pgn,
+ cmd = MAP_PAGE << 8;
+
+ _DX = Emm->Han; // take EMM handle
+ asm dec cnt // prapare for deferred checking
+ asm or dx,dx // see if valid
+ asm jns more // negative handle = unavailable
+
+ fail: return NULL;
+
+ more:
+ asm mov ax,cmd // command + page frame index
+ asm mov bx,pgn // logical page number
+ asm int EMS_INT // do it!
+ asm or ah,ah // check error code
+ asm jnz fail // exit on error
+ asm inc cmd // advance page frame index
+ asm inc pgn // advance logical page number
+ asm cmp al,byte ptr cnt // all pages?
+ asm jb more
+
+ return (void *) (EMM::Frame + (void *) off);
+ */
warning("STUB: EMS::operator &");
return NULL;
}
-uint16 EMS::Size (void)
-{
- return Siz;
+uint16 EMS::Size(void) {
+ return Siz;
}
} // End of namespace CGE
diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp
index 86e1324e0b..25af315d98 100644
--- a/engines/cge/game.cpp
+++ b/engines/cge/game.cpp
@@ -25,96 +25,70 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/game.h"
-#include "cge/mouse.h"
-#include <stdlib.h>
-#include <dos.h>
+#include "cge/game.h"
+#include "cge/mouse.h"
+#include <stdlib.h>
+#include <dos.h>
namespace CGE {
-
-
-uint8 * Glass (DAC * pal, uint8 r, uint8 g, uint8 b)
-{
- uint8 * x = new uint8[256];
- if (x)
- {
- uint16 i;
- for (i = 0; i < 256; i ++)
- {
- x[i] = Closest(pal, MkDAC(((uint16)(pal[i].R) * r) / 255,
- ((uint16)(pal[i].G) * g) / 255,
- ((uint16)(pal[i].B) * b) / 255));
+uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b) {
+ uint8 *x = new uint8[256];
+ if (x) {
+ uint16 i;
+ for (i = 0; i < 256; i ++) {
+ x[i] = Closest(pal, MkDAC(((uint16)(pal[i].R) * r) / 255,
+ ((uint16)(pal[i].G) * g) / 255,
+ ((uint16)(pal[i].B) * b) / 255));
+ }
}
- }
- return x;
+ return x;
}
-
-
-
-uint8 * Mark (DAC * pal)
-{
- #define f(c) (c ^ 63)
- uint8 * x = new uint8[256];
- if (x)
- {
- uint16 i;
- for (i = 0; i < 256; i ++)
- {
- x[i] = Closest(pal, MkDAC(f(pal[i].R),
- f(pal[i].G),
- f(pal[i].B)) );
+uint8 *Mark(DAC *pal) {
+#define f(c) (c ^ 63)
+ uint8 *x = new uint8[256];
+ if (x) {
+ uint16 i;
+ for (i = 0; i < 256; i ++) {
+ x[i] = Closest(pal, MkDAC(f(pal[i].R),
+ f(pal[i].G),
+ f(pal[i].B)));
+ }
}
- }
- return x;
- #undef f
+ return x;
+#undef f
}
+int FLY::L = 20,
+ FLY::T = 40,
+ FLY::R = 110,
+ FLY::B = 100;
-
-//--------------------------------------------------------------------------
-
-
-
-int FLY::L = 20,
- FLY::T = 40,
- FLY::R = 110,
- FLY::B = 100;
-
-
-
-FLY::FLY (BITMAP ** shpl)
-: SPRITE(shpl), Tx(0), Ty(0)
-{
- Step(new_random(2));
- Goto(L + new_random(R - L - W), T + new_random(B - T - H));
+FLY::FLY(BITMAP **shpl)
+ : SPRITE(shpl), Tx(0), Ty(0) {
+ Step(new_random(2));
+ Goto(L + new_random(R - L - W), T + new_random(B - T - H));
}
-
-
-void FLY::Tick (void)
-{
- Step();
- if (! Flags.Kept)
- {
- if (new_random(10) < 1)
- {
- Tx = new_random(3) - 1;
- Ty = new_random(3) - 1;
+void FLY::Tick(void) {
+ Step();
+ if (! Flags.Kept) {
+ if (new_random(10) < 1) {
+ Tx = new_random(3) - 1;
+ Ty = new_random(3) - 1;
+ }
+ if (X + Tx < L || X + Tx + W > R)
+ Tx = -Tx;
+ if (Y + Ty < T || Y + Ty + H > B)
+ Ty = -Ty;
+ Goto(X + Tx, Y + Ty);
}
- if (X + Tx < L || X + Tx + W > R) Tx = -Tx;
- if (Y + Ty < T || Y + Ty + H > B) Ty = -Ty;
- Goto(X + Tx, Y + Ty);
- }
}
-
-//--------------------------------------------------------------------------
-
} // End of namespace CGE
diff --git a/engines/cge/game.h b/engines/cge/game.h
index 1f45667b6b..1bc24e1fd9 100644
--- a/engines/cge/game.h
+++ b/engines/cge/game.h
@@ -25,44 +25,37 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __GAME__
-#define __GAME__
+#ifndef __GAME__
+#define __GAME__
-#include "cge/vga13h.h"
-#include "cge/bitmaps.h"
+#include "cge/vga13h.h"
+#include "cge/bitmaps.h"
namespace CGE {
-#define PAN_HIG 40
-#define LBound(s) (s->X <= 0)
-#define RBound(s) (s->X+s->W >= SCR_WID)
-#define TBound(s) (s->Y <= 0)
-#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG)
+#define PAN_HIG 40
+#define LBound(s) (s->X <= 0)
+#define RBound(s) (s->X+s->W >= SCR_WID)
+#define TBound(s) (s->Y <= 0)
+#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG)
+extern SPRITE *Sys;
-extern SPRITE * Sys;
+int Sinus(long x);
+uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b);
+uint8 *Mark(DAC *pal);
-int Sinus (long x);
-uint8 * Glass (DAC * pal, uint8 r, uint8 g, uint8 b);
-uint8 * Mark (DAC * pal);
-
-
-
-
-class FLY : public SPRITE
-{
- static int L, T, R, B;
+class FLY : public SPRITE {
+ static int L, T, R, B;
public:
- int Tx, Ty;
- FLY (BITMAP ** shpl);
- void Tick (void);
+ int Tx, Ty;
+ FLY(BITMAP **shpl);
+ void Tick(void);
};
-
-
} // End of namespace CGE
#endif
diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp
index f023bb1e0f..3a0114c672 100644
--- a/engines/cge/general.cpp
+++ b/engines/cge/general.cpp
@@ -32,77 +32,77 @@
namespace CGE {
- DAC StdPal[] = {// R G B
- { 0, 60, 0}, // 198
- { 0, 104, 0}, // 199
- { 20, 172, 0}, // 200
- { 82, 82, 0}, // 201
- { 0, 132, 82}, // 202
- { 132, 173, 82}, // 203
- { 82, 0, 0}, // 204
- { 206, 0, 24}, // 205
- { 255, 33, 33}, // 206
- { 123, 41, 0}, // 207
- { 0, 41, 0}, // 208
- { 0, 0, 82}, // 209
- { 132, 0, 0}, // 210
- { 255, 0, 0}, // 211
- { 255, 66, 66}, // 212
- { 148, 66, 16}, // 213
- { 0, 82, 0}, // 214
- { 0, 0,132}, // 215
- { 173, 0, 0}, // 216
- { 255, 49, 0}, // 217
- { 255, 99, 99}, // 218
- { 181, 107, 49}, // 219
- { 0, 132, 0}, // 220
- { 0, 0,255}, // 221
- { 173, 41, 0}, // 222
- { 255, 82, 0}, // 223
- { 255, 132,132}, // 224
- { 214, 148, 74}, // 225
- { 41, 214, 0}, // 226
- { 0, 82,173}, // 227
- { 255, 214, 0}, // 228
- { 247, 132, 49}, // 229
- { 255, 165,165}, // 230
- { 239, 198,123}, // 231
- { 173, 214, 0}, // 232
- { 0, 132,214}, // 233
- { 57, 57, 57}, // 234
- { 247, 189, 74}, // 235
- { 255, 198,198}, // 236
- { 255, 239,173}, // 237
- { 214, 255,173}, // 238
- { 82, 173,255}, // 239
- { 107, 107,107}, // 240
- { 247, 222, 99}, // 241
- { 255, 0,255}, // 242
- { 255, 132,255}, // 243
- { 132, 132,173}, // 244
- { 148, 247,255}, // 245
- { 148, 148,148}, // 246
- { 82, 0, 82}, // 247
- { 112, 68,112}, // 248
- { 176, 88,144}, // 249
- { 214, 132,173}, // 250
- { 206, 247,255}, // 251
- { 198, 198,198}, // 252
- { 0, 214,255}, // 253
- { 96, 224,96 }, // 254
- { 255, 255,255}, // 255
- };
-
-EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*)) {
+DAC StdPal[] = {// R G B
+ { 0, 60, 0}, // 198
+ { 0, 104, 0}, // 199
+ { 20, 172, 0}, // 200
+ { 82, 82, 0}, // 201
+ { 0, 132, 82}, // 202
+ { 132, 173, 82}, // 203
+ { 82, 0, 0}, // 204
+ { 206, 0, 24}, // 205
+ { 255, 33, 33}, // 206
+ { 123, 41, 0}, // 207
+ { 0, 41, 0}, // 208
+ { 0, 0, 82}, // 209
+ { 132, 0, 0}, // 210
+ { 255, 0, 0}, // 211
+ { 255, 66, 66}, // 212
+ { 148, 66, 16}, // 213
+ { 0, 82, 0}, // 214
+ { 0, 0, 132}, // 215
+ { 173, 0, 0}, // 216
+ { 255, 49, 0}, // 217
+ { 255, 99, 99}, // 218
+ { 181, 107, 49}, // 219
+ { 0, 132, 0}, // 220
+ { 0, 0, 255}, // 221
+ { 173, 41, 0}, // 222
+ { 255, 82, 0}, // 223
+ { 255, 132, 132}, // 224
+ { 214, 148, 74}, // 225
+ { 41, 214, 0}, // 226
+ { 0, 82, 173}, // 227
+ { 255, 214, 0}, // 228
+ { 247, 132, 49}, // 229
+ { 255, 165, 165}, // 230
+ { 239, 198, 123}, // 231
+ { 173, 214, 0}, // 232
+ { 0, 132, 214}, // 233
+ { 57, 57, 57}, // 234
+ { 247, 189, 74}, // 235
+ { 255, 198, 198}, // 236
+ { 255, 239, 173}, // 237
+ { 214, 255, 173}, // 238
+ { 82, 173, 255}, // 239
+ { 107, 107, 107}, // 240
+ { 247, 222, 99}, // 241
+ { 255, 0, 255}, // 242
+ { 255, 132, 255}, // 243
+ { 132, 132, 173}, // 244
+ { 148, 247, 255}, // 245
+ { 148, 148, 148}, // 246
+ { 82, 0, 82}, // 247
+ { 112, 68, 112}, // 248
+ { 176, 88, 144}, // 249
+ { 214, 132, 173}, // 250
+ { 206, 247, 255}, // 251
+ { 198, 198, 198}, // 252
+ { 0, 214, 255}, // 253
+ { 96, 224, 96 }, // 254
+ { 255, 255, 255}, // 255
+};
+
+EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) {
warning("STUB: _fqsort");
}
-const char * ProgName (const char * ext) {
+const char *ProgName(const char *ext) {
warning("STUB: ProgName");
return NULL;
}
-char *MergeExt (char *buf, const char *nam, const char *ext) {
+char *MergeExt(char *buf, const char *nam, const char *ext) {
// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT];
// fnmerge(buf, dr, di, na, (fnsplit(nam, dr, di, na, ex) & EXTENSION) ? ex : ext);
// return buf;
@@ -110,7 +110,7 @@ char *MergeExt (char *buf, const char *nam, const char *ext) {
return buf;
}
-char *ForceExt (char *buf, const char *nam, const char* ext) {
+char *ForceExt(char *buf, const char *nam, const char *ext) {
// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT];
// fnsplit(nam, dr, di, na, ex);
// fnmerge(buf, dr, di, na, ext);
@@ -120,157 +120,168 @@ char *ForceExt (char *buf, const char *nam, const char* ext) {
}
-#define BUF ((uint8 *) buf)
-static unsigned Seed = 1;
+#define BUF ((uint8 *) buf)
+static unsigned Seed = 1;
-unsigned FastRand (void) { return Seed = 257 * Seed + 817; }
-unsigned FastRand (unsigned s) { return Seed = 257 * s + 817; }
+unsigned FastRand(void) {
+ return Seed = 257 * Seed + 817;
+}
+unsigned FastRand(unsigned s) {
+ return Seed = 257 * s + 817;
+}
-uint16 RCrypt (void * buf, uint16 siz, uint16 seed) {
-/*
- if (buf && siz) {
- uint8 * q = BUF + (siz-1);
- seed = FastRand(seed);
- * (BUF ++) ^= seed;
- while (buf < q) * (BUF ++) ^= FastRand();
- if (buf == q) * BUF ^= (seed = FastRand());
- }
- return seed;
-*/
+uint16 RCrypt(void *buf, uint16 siz, uint16 seed) {
+ /*
+ if (buf && siz) {
+ uint8 * q = BUF + (siz-1);
+ seed = FastRand(seed);
+ * (BUF ++) ^= seed;
+ while (buf < q) * (BUF ++) ^= FastRand();
+ if (buf == q) * BUF ^= (seed = FastRand());
+ }
+ return seed;
+ */
warning("STUB: RCrypt");
return 0;
}
-uint16 XCrypt (void *buf, uint16 siz, uint16 seed) {
-// for (uint16 i = 0; i < siz; i ++)
+uint16 XCrypt(void *buf, uint16 siz, uint16 seed) {
+// for (uint16 i = 0; i < siz; i ++)
// *(BUF ++) ^= seed;
warning("STUB: XCrypt");
return seed;
}
-uint16 atow (const char *a) {
- uint16 w = 0;
+uint16 atow(const char *a) {
+ uint16 w = 0;
if (a)
while (IsDigit(*a))
w = (10 * w) + (*(a ++) & 0xF);
- return w;
-}
-
-uint16 xtow (const char *x) {
- uint16 w = 0;
- if (x) {
- while (IsHxDig(*x)) {
- register uint16 d = * (x ++);
- if (d > '9')
- d -= 'A' - ('9' + 1);
- w = (w << 4) | (d & 0xF);
- }
- }
- return w;
-}
-
-char *wtom (uint16 val, char *str, int radix, int len) {
- while (-- len >= 0) {
- uint16 w = val % radix;
- if (w > 9) w += ('A' - ('9'+1));
- str[len] = '0' + w;
- val /= radix;
- }
- return str;
-}
-
-IOHAND::IOHAND (IOMODE mode, CRYPT * crpt)
-: XFILE(mode), Handle(-1), Crypt(crpt), Seed(SEED)
-{
-}
-
-IOHAND::IOHAND (const char *name, IOMODE mode, CRYPT *crpt)
-: XFILE(mode), Crypt(crpt), Seed(SEED)
-{
-/* switch (mode)
- {
- case REA : Error = _dos_open(name, O_RDONLY | O_DENYNONE, &Handle); break;
- case WRI : Error = _dos_creat(name, FA_ARCH, &Handle); break;
- case UPD : Error = _dos_open(name, O_RDWR | O_DENYALL, &Handle); break;
- }
- if (Error) Handle = -1;
-*/
+ return w;
+}
+
+uint16 xtow(const char *x) {
+ uint16 w = 0;
+ if (x) {
+ while (IsHxDig(*x)) {
+ register uint16 d = * (x ++);
+ if (d > '9')
+ d -= 'A' - ('9' + 1);
+ w = (w << 4) | (d & 0xF);
+ }
+ }
+ return w;
+}
+
+char *wtom(uint16 val, char *str, int radix, int len) {
+ while (--len >= 0) {
+ uint16 w = val % radix;
+ if (w > 9)
+ w += ('A' - ('9' + 1));
+ str[len] = '0' + w;
+ val /= radix;
+ }
+ return str;
+}
+
+char *dwtom(uint32 val, char *str, int radix, int len) {
+ while (--len >= 0) {
+ uint16 w = (uint16) (val % radix);
+ if (w > 9)
+ w += ('A' - ('9' + 1));
+ str[len] = '0' + w;
+ val /= radix;
+ }
+ return str;
+}
+
+IOHAND::IOHAND(IOMODE mode, CRYPT *crpt)
+ : XFILE(mode), Handle(-1), Crypt(crpt), Seed(SEED) {
+}
+
+IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt)
+ : XFILE(mode), Crypt(crpt), Seed(SEED) {
+ /* switch (mode)
+ {
+ case REA : Error = _dos_open(name, O_RDONLY | O_DENYNONE, &Handle); break;
+ case WRI : Error = _dos_creat(name, FA_ARCH, &Handle); break;
+ case UPD : Error = _dos_open(name, O_RDWR | O_DENYALL, &Handle); break;
+ }
+ if (Error) Handle = -1;
+ */
warning("STUB: IOHAND::IOHAND");
}
IOHAND::~IOHAND(void) {
-/*
- if (Handle != -1)
- {
- Error = _dos_close(Handle);
- Handle = -1;
- }
-*/
+ /*
+ if (Handle != -1)
+ {
+ Error = _dos_close(Handle);
+ Handle = -1;
+ }
+ */
warning("STUB: IOHAND::~IOHAND");
}
uint16 IOHAND::Read(void *buf, uint16 len) {
-/*
- if (Mode == WRI || Handle < 0) return 0;
- if (len) Error = _dos_read(Handle, buf, len, &len);
- if (Crypt) Seed = Crypt(buf, len, Seed);
- return len;
-*/
+ /*
+ if (Mode == WRI || Handle < 0) return 0;
+ if (len) Error = _dos_read(Handle, buf, len, &len);
+ if (Crypt) Seed = Crypt(buf, len, Seed);
+ return len;
+ */
warning("STUB: IOHAND::Read");
return 0;
}
uint16 IOHAND::Write(void *buf, uint16 len) {
-/*
- if (len) {
- if (Mode == REA || Handle < 0) return 0;
- if (Crypt) Seed = Crypt(buf, len, Seed);
- Error = _dos_write(Handle, buf, len, &len);
- if (Crypt) Seed = Crypt(buf, len, Seed); //------$$$$$$$
- }
- return len;
-*/
+ /*
+ if (len) {
+ if (Mode == REA || Handle < 0) return 0;
+ if (Crypt) Seed = Crypt(buf, len, Seed);
+ Error = _dos_write(Handle, buf, len, &len);
+ if (Crypt) Seed = Crypt(buf, len, Seed); //------$$$$$$$
+ }
+ return len;
+ */
warning("STUB: IOHAND::Write");
return 0;
}
-long IOHAND::Mark (void)
-{
- return (Handle < 0) ? 0 : tell(Handle);
+long IOHAND::Mark(void) {
+ return (Handle < 0) ? 0 : tell(Handle);
}
-long IOHAND::Seek (long pos)
-{
- if (Handle < 0) return 0;
- lseek(Handle, pos, SEEK_SET);
- return tell(Handle);
+long IOHAND::Seek(long pos) {
+ if (Handle < 0) return 0;
+ lseek(Handle, pos, SEEK_SET);
+ return tell(Handle);
}
-long IOHAND::Size (void)
-{
- if (Handle < 0) return 0;
- return filelength(Handle);
+long IOHAND::Size(void) {
+ if (Handle < 0) return 0;
+ return filelength(Handle);
}
-bool IOHAND::Exist (const char * name) {
- return access(name, 0) == 0;
+bool IOHAND::Exist(const char *name) {
+ return access(name, 0) == 0;
}
-//#define EMS_ADR(a) (FP_SEG(a) > 0xA000)
-//#define HNODE_OK(p) (heapchecknode(p)==4)
-
-MEM_TYPE MemType (void *mem) {
-/* if (FP_SEG(mem) == _DS) {
- if (heapchecknode((void *)mem)==4)
- return NEAR_MEM;
- } else {
- if (FP_SEG(mem) > 0xA000)
- return EMS_MEM;
- else if (farheapchecknode(mem)==4)
- return FAR_MEM;
- }
- return BAD_MEM;
-*/
+//#define EMS_ADR(a) (FP_SEG(a) > 0xA000)
+//#define HNODE_OK(p) (heapchecknode(p)==4)
+
+MEM_TYPE MemType(void *mem) {
+ /* if (FP_SEG(mem) == _DS) {
+ if (heapchecknode((void *)mem)==4)
+ return NEAR_MEM;
+ } else {
+ if (FP_SEG(mem) > 0xA000)
+ return EMS_MEM;
+ else if (farheapchecknode(mem)==4)
+ return FAR_MEM;
+ }
+ return BAD_MEM;
+ */
warning("STUB: MemType");
return FAR_MEM;
}
@@ -307,40 +318,48 @@ EC void SNDMIDIStop() {
warning("STUB: SNDMIDIStop");
}
-DATACK *LoadWave(XFILE * file, EMM * emm) {
+DATACK *LoadWave(XFILE *file, EMM *emm) {
warning("STUB: LoadWave");
return NULL;
}
int TakeEnum(const char **tab, const char *txt) {
- const char **e;
- if (txt)
- {
- for (e = tab; *e; e ++)
- {
- if (scumm_stricmp(txt, *e) == 0)
- {
- return e - tab;
- }
+ const char **e;
+ if (txt) {
+ for (e = tab; *e; e ++) {
+ if (scumm_stricmp(txt, *e) == 0) {
+ return e - tab;
+ }
+ }
}
- }
- return -1;
+ return -1;
}
Boot *ReadBoot(int drive) {
-/*
- struct fatinfo fi; Boot *b;
- getfat(drive+1, &fi);
- if (fi.fi_sclus & 0x80) return NULL;
- if ((b = malloc(fi.fi_bysec)) == NULL) return NULL;
- // read boot sector
- if (absread(drive, 1, 0L, b) == 0) return b;
- free(b);
- return NULL;
-*/
+ /*
+ struct fatinfo fi; Boot *b;
+ getfat(drive+1, &fi);
+ if (fi.fi_sclus & 0x80) return NULL;
+ if ((b = malloc(fi.fi_bysec)) == NULL) return NULL;
+ // read boot sector
+ if (absread(drive, 1, 0L, b) == 0) return b;
+ free(b);
+ return NULL;
+ */
warning("STUB: ReadBoot");
return NULL;
}
+long Timer(void) {
+/*
+ asm mov ax,0x40
+ asm mov es,ax
+ asm mov cx,es:[0x6C]
+ asm mov dx,es:[0x6E]
+ return ((long) _DX << 16) | _CX;
+*/
+ warning("STUB: Timer");
+ return 0;
+}
} // End of namespace CGE
diff --git a/engines/cge/general.h b/engines/cge/general.h
index 62919328ed..7c0bd7f762 100644
--- a/engines/cge/general.h
+++ b/engines/cge/general.h
@@ -25,243 +25,218 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __GENERAL__
-#define __GENERAL__
+#ifndef __GENERAL__
+#define __GENERAL__
#include "common/system.h"
#include "common/random.h"
#include "common/textconsole.h"
#include "common/str.h"
-
-#include "cge\jbw.h"
-#include <io.h>
+#include "cge/jbw.h"
+#include <io.h>
+#include "cge/boot.h"
namespace CGE {
-#define SEED 0xA5
+#define SEED 0xA5
-#define SCR_WID_ 320
-#define SCR_HIG_ 200
-#define SCR_WID ((uint16)SCR_WID_)
-#define SCR_HIG ((uint16)SCR_HIG_)
-#define SCR_SEG 0xA000
-#define SCR_ADR ((uint8 *) MK_FP(SCR_SEG, 0))
+#define SCR_WID_ 320
+#define SCR_HIG_ 200
+#define SCR_WID ((uint16)SCR_WID_)
+#define SCR_HIG ((uint16)SCR_HIG_)
+#define SCR_SEG 0xA000
+#define SCR_ADR ((uint8 *) MK_FP(SCR_SEG, 0))
-//enum CPU { _8086, _80186, _80286, _80386, _80486 };
-enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM };
-enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT };
-enum IOMODE { REA, WRI, UPD };
+//enum CPU { _8086, _80186, _80286, _80386, _80486 };
+enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM };
+enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT };
+enum IOMODE { REA, WRI, UPD };
-typedef struct {
- uint8 R, G, B;
- } DAC;
+typedef struct {
+ uint8 R, G, B;
+} DAC;
-typedef uint16 CRYPT (void *buf, uint16 siz, uint16 seed);
+typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed);
extern Common::RandomSource randSrc;
#define new_random(a) (randSrc.getRandomNumber(a))
-class COUPLE
-{
+class COUPLE {
protected:
- signed char A;
- signed char B;
+ signed char A;
+ signed char B;
public:
- COUPLE (void) { }
- COUPLE (const signed char a, const signed char b) : A(a), B(b) { }
- COUPLE operator + (COUPLE c) { return COUPLE(A+c.A, B+c.B); }
- void operator += (COUPLE c) { A += c.A; B += c.B; }
- COUPLE operator - (COUPLE c) { return COUPLE(A-c.A, B-c.B); }
- void operator -= (COUPLE c) { A -= c.A; B -= c.B; }
- bool operator == (COUPLE c) { return ((A - c.A) | (B - c.B)) == 0; }
- bool operator != (COUPLE c) { return ! (operator == (c)); }
- void Split (signed char& a, signed char& b) { a = A; b = B; }
+ COUPLE(void) { }
+ COUPLE(const signed char a, const signed char b) : A(a), B(b) { }
+ COUPLE operator + (COUPLE c) {
+ return COUPLE(A + c.A, B + c.B);
+ }
+
+ void operator += (COUPLE c) {
+ A += c.A;
+ B += c.B;
+ }
+
+ COUPLE operator - (COUPLE c) {
+ return COUPLE(A - c.A, B - c.B);
+ }
+
+ void operator -= (COUPLE c) {
+ A -= c.A;
+ B -= c.B;
+ }
+
+ bool operator == (COUPLE c) {
+ return ((A - c.A) | (B - c.B)) == 0;
+ }
+
+ bool operator != (COUPLE c) {
+ return !(operator == (c));
+ }
+
+ void Split(signed char &a, signed char &b) {
+ a = A;
+ b = B;
+ }
};
-//-------------------------------------------------------------------------
-
-
-
-class ENGINE
-{
+class ENGINE {
protected:
- static void (* OldTimer) (...);
- static void NewTimer (...);
+ static void (* OldTimer)(...);
+ static void NewTimer(...);
public:
- ENGINE (uint16 tdiv);
- ~ENGINE (void);
+ ENGINE(uint16 tdiv);
+ ~ENGINE(void);
};
-
-
-//-------------------------------------------------------------------------
-
-
class EMS;
-
-class EMM
-{
- friend EMS;
- bool Test (void);
- long Top, Lim;
- EMS * List;
- int Han;
- static void * Frame;
+class EMM {
+ friend EMS;
+ bool Test(void);
+ long Top, Lim;
+ EMS *List;
+ int Han;
+ static void *Frame;
public:
- EMM::EMM (long size = 0);
- EMM::~EMM (void);
- EMS * Alloc (uint16 siz);
- void Release (void);
+ EMM::EMM(long size = 0);
+ EMM::~EMM(void);
+ EMS *Alloc(uint16 siz);
+ void Release(void);
};
-
-
-
-class EMS
-{
- friend EMM;
- EMM * Emm;
- long Ptr;
- uint16 Siz;
- EMS * Nxt;
+class EMS {
+ friend EMM;
+ EMM *Emm;
+ long Ptr;
+ uint16 Siz;
+ EMS *Nxt;
public:
- EMS (void);
- void * operator & () const;
- uint16 Size (void);
+ EMS(void);
+ void *operator & () const;
+ uint16 Size(void);
};
-
-//-------------------------------------------------------------------------
-
-
-
-
template <class T>
-void Swap (T& A, T& B)
-{
- T a = A;
- A = B;
- B = a;
+void Swap(T &A, T &B) {
+ T a = A;
+ A = B;
+ B = a;
};
-
-
-
#ifdef __cplusplus
-
-
template <class T>
-T max (T A, T B)
-{
- return (A > B) ? A : B;
+T max(T A, T B) {
+ return (A > B) ? A : B;
};
-
-
template <class T>
-T min (T A, T B)
-{
- return (A < B) ? A : B;
+T min(T A, T B) {
+ return (A < B) ? A : B;
};
-
-
#endif
-
-
-
-
-
-class XFILE
-{
+class XFILE {
public:
- IOMODE Mode;
- uint16 Error;
- XFILE (void) : Mode(REA), Error(0) { }
- XFILE (IOMODE mode) : Mode(mode), Error(0) { }
- virtual uint16 Read (void * buf, uint16 len) = 0;
- virtual uint16 Write (void * buf, uint16 len) = 0;
- virtual long Mark (void) = 0;
- virtual long Size (void) = 0;
- virtual long Seek (long pos) = 0;
+ IOMODE Mode;
+ uint16 Error;
+ XFILE(void) : Mode(REA), Error(0) { }
+ XFILE(IOMODE mode) : Mode(mode), Error(0) { }
+ virtual uint16 Read(void *buf, uint16 len) = 0;
+ virtual uint16 Write(void *buf, uint16 len) = 0;
+ virtual long Mark(void) = 0;
+ virtual long Size(void) = 0;
+ virtual long Seek(long pos) = 0;
};
-
-
-
template <class T>
-inline uint16 XRead (XFILE * xf, T * t)
-{
- return xf->Read((uint8 *) t, sizeof(*t));
+inline uint16 XRead(XFILE *xf, T *t) {
+ return xf->Read((uint8 *) t, sizeof(*t));
};
-
-
-
-class IOHAND : public XFILE
-{
+class IOHAND : public XFILE {
protected:
- int Handle;
- uint16 Seed;
- CRYPT * Crypt;
+ int Handle;
+ uint16 Seed;
+ CRYPT *Crypt;
public:
- IOHAND (const char * name, IOMODE mode = REA, CRYPT crypt = NULL);
- IOHAND (IOMODE mode = REA, CRYPT * crpt = NULL);
- virtual ~IOHAND (void);
- static bool Exist (const char * name);
- uint16 Read (void * buf, uint16 len);
- uint16 Write (void * buf, uint16 len);
- long Mark (void);
- long Size (void);
- long Seek (long pos);
- //timeb Time (void);
- // void SetTime (timeb t);
+ IOHAND(const char *name, IOMODE mode = REA, CRYPT crypt = NULL);
+ IOHAND(IOMODE mode = REA, CRYPT *crpt = NULL);
+ virtual ~IOHAND(void);
+ static bool Exist(const char *name);
+ uint16 Read(void *buf, uint16 len);
+ uint16 Write(void *buf, uint16 len);
+ long Mark(void);
+ long Size(void);
+ long Seek(long pos);
+ //timeb Time (void);
+// void SetTime (timeb t);
};
-
-
-
-CRYPT XCrypt;
-CRYPT RCrypt;
-
-MEM_TYPE MemType (void *mem);
-uint16 atow (const char * a);
-uint16 xtow (const char * x);
-char * wtom (uint16 val, char * str, int radix, int len);
-char * dwtom (uint32 val, char * str, int radix, int len);
-int TakeEnum (const char ** tab, const char * txt);
-uint16 ChkSum (void *m, uint16 n);
-long Timer (void);
-char * MergeExt (char * buf, const char * nam, const char * ext);
-char * ForceExt (char * buf, const char * nam, const char * ext);
-int DriveCD (unsigned drv);
-bool IsVga (void);
+CRYPT XCrypt;
+CRYPT RCrypt;
+MEM_TYPE MemType(void *mem);
+uint16 atow(const char *a);
+uint16 xtow(const char *x);
+char *wtom(uint16 val, char *str, int radix, int len);
+char *dwtom(uint32 val, char *str, int radix, int len);
+int TakeEnum(const char **tab, const char *txt);
+uint16 ChkSum(void *m, uint16 n);
+long Timer(void);
+char *MergeExt(char *buf, const char *nam, const char *ext);
+char *ForceExt(char *buf, const char *nam, const char *ext);
+int DriveCD(unsigned drv);
+bool IsVga(void);
// MISSING FUNCTIONS
-EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*));
-const char *ProgName (const char *ext = NULL);
-char *MergeExt (char *buf, const char *nam, const char *ext);
-char *ForceExt (char *buf, const char *nam, const char *ext);
-unsigned FastRand (void);
-unsigned FastRand (unsigned s);
-uint16 RCrypt (void * buf, uint16 siz, uint16 seed);
-uint16 atow (const char *a);
-uint16 xtow (const char *x);
+EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *));
+const char *ProgName(const char *ext = NULL);
+char *MergeExt(char *buf, const char *nam, const char *ext);
+char *ForceExt(char *buf, const char *nam, const char *ext);
+unsigned FastRand(void);
+unsigned FastRand(unsigned s);
+uint16 RCrypt(void *buf, uint16 siz, uint16 seed);
+uint16 atow(const char *a);
+uint16 xtow(const char *x);
+char *wtom(uint16 val, char *str, int radix, int len);
+char *dwtom(uint32 val, char * str, int radix, int len);
+int TakeEnum(const char **tab, const char *txt);
+Boot *ReadBoot(int drive);
+long Timer(void);
} // End of namespace CGE
diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp
index 892ef5ee73..78cc0356a1 100644
--- a/engines/cge/gettext.cpp
+++ b/engines/cge/gettext.cpp
@@ -25,113 +25,97 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/gettext.h"
-#include "cge/keybd.h"
-#include "cge/mouse.h"
-#include <string.h>
+#include "cge/gettext.h"
+#include "cge/keybd.h"
+#include "cge/mouse.h"
+#include <string.h>
namespace CGE {
-GET_TEXT * GET_TEXT::Ptr = NULL;
-
-
-
-GET_TEXT::GET_TEXT (const char * info, char * text, int size, void (*click)(void))
-: Text(text), Size(min<int>(size, GTMAX)), Len(min<int>(Size, strlen(text))),
- Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this))
-{
- int i = 2 * TEXT_HM + Font.Width(info);
- Ptr = this;
- Mode = RECT;
- TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS);
- SetShapeList(TS);
- Flags.BDel = true;
- Flags.Kill = true;
- memcpy(Buff, text, Len);
- Buff[Len] = ' ';
- Buff[Len+1] = '\0';
- PutLine(0, info);
- Tick();
+GET_TEXT *GET_TEXT::Ptr = NULL;
+
+
+GET_TEXT::GET_TEXT(const char *info, char *text, int size, void (*click)(void))
+ : Text(text), Size(min<int>(size, GTMAX)), Len(min<int>(Size, strlen(text))),
+ Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) {
+ int i = 2 * TEXT_HM + Font.Width(info);
+ Ptr = this;
+ Mode = RECT;
+ TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS);
+ SetShapeList(TS);
+ Flags.BDel = true;
+ Flags.Kill = true;
+ memcpy(Buff, text, Len);
+ Buff[Len] = ' ';
+ Buff[Len + 1] = '\0';
+ PutLine(0, info);
+ Tick();
}
-
-
-
-
-GET_TEXT::~GET_TEXT (void)
-{
- KEYBOARD::SetClient(OldKeybClient);
- Ptr = NULL;
+GET_TEXT::~GET_TEXT(void) {
+ KEYBOARD::SetClient(OldKeybClient);
+ Ptr = NULL;
}
-
-
-
-
-void GET_TEXT::Tick (void)
-{
- if (++ Cntr >= GTBLINK)
- {
- Buff[Len] ^= (' ' ^ '_');
- Cntr = 0;
- }
- PutLine(1, Buff);
- Time = GTTIME;
+void GET_TEXT::Tick(void) {
+ if (++ Cntr >= GTBLINK) {
+ Buff[Len] ^= (' ' ^ '_');
+ Cntr = 0;
+ }
+ PutLine(1, Buff);
+ Time = GTTIME;
}
-
-
-void GET_TEXT::Touch (uint16 mask, int x, int y)
-{
- static char ogon[] = "•œ¥£˜ ¡";
- static char bezo[] = "ACELNOSXZ";
- char * p;
-
- if (mask & KEYB)
- {
- if (Click) Click();
- switch (x)
- {
- case Enter : Buff[Len] = '\0'; strcpy(Text, Buff);
- for (p = Text; *p; p ++)
- {
- char * q = strchr(ogon, *p);
- if (q) *p = bezo[q-ogon];
- }
- case Esc : SNPOST_(SNKILL, -1, 0, this); break;
- case BSp : if (Len)
- {
- -- Len;
- Buff[Len] = Buff[Len+1];
- Buff[Len+1] = Buff[Len+2];
- }
- break;
- default : if (x < 'A' || x > 'Z')
- {
- if (OldKeybClient)
- OldKeybClient->Touch(mask, x, y);
- }
- else
- {
- if (KEYBOARD::Key[ALT])
- {
- p = strchr(bezo, x);
- if (p) x = ogon[p-bezo];
- }
- if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W)
- {
- Buff[Len+2] = Buff[Len+1];
- Buff[Len+1] = Buff[Len];
- Buff[Len ++] = x;
- }
- }
- break;
- }
- }
- else SPRITE::Touch(mask, x, y);
+void GET_TEXT::Touch(uint16 mask, int x, int y) {
+ static char ogon[] = "•œ¥£˜ ¡";
+ static char bezo[] = "ACELNOSXZ";
+ char *p;
+
+ if (mask & KEYB) {
+ if (Click)
+ Click();
+ switch (x) {
+ case Enter :
+ Buff[Len] = '\0';
+ strcpy(Text, Buff);
+ for (p = Text; *p; p ++) {
+ char *q = strchr(ogon, *p);
+ if (q)
+ *p = bezo[q - ogon];
+ }
+ case Esc :
+ SNPOST_(SNKILL, -1, 0, this);
+ break;
+ case BSp :
+ if (Len) {
+ --Len;
+ Buff[Len] = Buff[Len + 1];
+ Buff[Len + 1] = Buff[Len + 2];
+ }
+ break;
+ default :
+ if (x < 'A' || x > 'Z') {
+ if (OldKeybClient)
+ OldKeybClient->Touch(mask, x, y);
+ } else {
+ if (KEYBOARD::Key[ALT]) {
+ p = strchr(bezo, x);
+ if (p)
+ x = ogon[p - bezo];
+ }
+ if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W) {
+ Buff[Len + 2] = Buff[Len + 1];
+ Buff[Len + 1] = Buff[Len];
+ Buff[Len ++] = x;
+ }
+ }
+ break;
+ }
+ } else
+ SPRITE::Touch(mask, x, y);
}
} // End of namespace CGE
diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h
index 02dbabe9c6..3fc7e4ff34 100644
--- a/engines/cge/gettext.h
+++ b/engines/cge/gettext.h
@@ -25,32 +25,30 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __GETTEXT__
-#define __GETTEXT__
+#ifndef __GETTEXT__
+#define __GETTEXT__
-#include "cge/general.h"
-#include "cge/talk.h"
+#include "cge/general.h"
+#include "cge/talk.h"
namespace CGE {
-#define GTMAX 24
-#define GTBLINK 6
-#define GTTIME 6
+#define GTMAX 24
+#define GTBLINK 6
+#define GTTIME 6
-
-class GET_TEXT : public TALK
-{
- char Buff[GTMAX+2], * Text;
- uint16 Size, Len;
- uint16 Cntr;
- SPRITE * OldKeybClient;
- void (*Click)(void);
+class GET_TEXT : public TALK {
+ char Buff[GTMAX + 2], * Text;
+ uint16 Size, Len;
+ uint16 Cntr;
+ SPRITE *OldKeybClient;
+ void (*Click)(void);
public:
- static GET_TEXT * Ptr;
- GET_TEXT (const char * info, char * text, int size, void (*click)(void) = NULL);
- ~GET_TEXT (void);
- void Touch (uint16 mask, int x, int y);
- void Tick (void);
+ static GET_TEXT *Ptr;
+ GET_TEXT(const char *info, char *text, int size, void (*click)(void) = NULL);
+ ~GET_TEXT(void);
+ void Touch(uint16 mask, int x, int y);
+ void Tick(void);
};
} // End of namespace CGE
diff --git a/engines/cge/ident.h b/engines/cge/ident.h
index 96e04f4e20..da36bfa682 100644
--- a/engines/cge/ident.h
+++ b/engines/cge/ident.h
@@ -25,18 +25,17 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __IDENT__
-#define __IDENT__
+#ifndef __IDENT__
+#define __IDENT__
namespace CGE {
-struct IDENT
- {
- char copr[83];
- char fill[8];
- unsigned long disk;
- unsigned char cork;
- };
+struct IDENT {
+ char copr[83];
+ char fill[8];
+ unsigned long disk;
+ unsigned char cork;
+};
} // End of namespace CGE
diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h
index bb01017d00..73131d71e3 100644
--- a/engines/cge/jbw.h
+++ b/engines/cge/jbw.h
@@ -32,149 +32,150 @@
namespace CGE {
+// Defines found in cge.mak
+#define DEBUG
#define VOL
-#define INI_FILE VFILE
+#define INI_FILE VFILE // Or is it CFILE?
#define PIC_FILE VFILE
#define BMP_MODE 0
-
-#define BEL 7
-#define BS 8
-#define HT 9
-#define LF 10
-#define FF 12
-#define CR 13
-
-#define TRUE 1
-#define FALSE 0
-
-#define MAXFILE 128
-
-#define NULL 0
-#define OFF false
-#define ON true
-
-#define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
-#define IsUpper(c) ((c) >= 'A' && (c) <= 'Z')
-#define IsLower(c) ((c) >= 'a' && (c) <= 'z')
-#define IsDigit(c) ((c) >= '0' && (c) <= '9')
-#define IsAlpha(c) (IsLower(c) || IsUpper(c) || (c) == '_')
-#define IsAlNum(c) (IsAlpha(c) || IsDigit(c))
-#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
-
-#define farnew(t,n) ((t *) malloc(sizeof(t) * (n)))
-#define ArrayCount(a) (sizeof(a)/sizeof((a)[0]))
-#define MAX_TIMER 0x1800B0L
-
-typedef void (MouseFunType)(void);
-
-#define Lo(d) (((int *) &d)[0])
-#define Hi(d) (((int *) &d)[1])
-#define LoWord(d) ((uint16) Lo(d))
-#define HiWord(d) ((uint16) Hi(d))
-#define K(n) (1024*(n))
-#define MASK(n) ((1<<n)-1)
-
-typedef enum
- {
- NoKey = 0, CtrlA, CtrlB, CtrlC, CtrlD, CtrlE, CtrlF, CtrlG, CtrlH,
- CtrlI, CtrlJ, CtrlK, CtrlL, CtrlM, CtrlN, CtrlO, CtrlP,
- CtrlQ, CtrlR, CtrlS, CtrlT, CtrlU, CtrlV, CtrlW, CtrlX,
- CtrlY, CtrlZ,
- BSp = 8,
- Tab = 9,
- Enter = 13,
- Eof = 26,
- Esc = 27,
- AltQ = 256+16, AltW, AltE, AltR, AltT, AltY, AltU, AltI, AltO, AltP,
- AltA = 256+30, AltS, AltD, AltF, AltG, AltH, AltJ, AltK, AltL,
- AltZ = 256+44, AltX, AltC, AltV, AltB, AltN, AltM,
- F11 = 256+87, F12,
- F1 = 256+59, F2, F3, F4, F5, F6, F7, F8, F9, F10,
- ShiftTab = 256+15,
- ShiftF1 = 256+84, ShiftF2, ShiftF3, ShiftF4, ShiftF5,
- ShiftF6, ShiftF7, ShiftF8, ShiftF9, ShiftF10,
- CtrlF1 = 256+94, CtrlF2, CtrlF3, CtrlF4, CtrlF5,
- CtrlF6, CtrlF7, CtrlF8, CtrlF9, CtrlF10,
- AltF1 = 256+104, AltF2, AltF3, AltF4, AltF5,
- AltF6, AltF7, AltF8, AltF9, AltF10,
- Home = 256+71,
+//
+
+#define BEL 7
+#define BS 8
+#define HT 9
+#define LF 10
+#define FF 12
+#define CR 13
+
+#define TRUE 1
+#define FALSE 0
+
+#define MAXFILE 128
+
+#define NULL 0
+#define OFF false
+#define ON true
+
+#define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
+#define IsUpper(c) ((c) >= 'A' && (c) <= 'Z')
+#define IsLower(c) ((c) >= 'a' && (c) <= 'z')
+#define IsDigit(c) ((c) >= '0' && (c) <= '9')
+#define IsAlpha(c) (IsLower(c) || IsUpper(c) || (c) == '_')
+#define IsAlNum(c) (IsAlpha(c) || IsDigit(c))
+#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
+
+#define farnew(t,n) ((t *) malloc(sizeof(t) * (n)))
+#define ArrayCount(a) (sizeof(a)/sizeof((a)[0]))
+#define MAX_TIMER 0x1800B0L
+
+typedef void (MouseFunType)(void);
+
+#define Lo(d) (((int *) &d)[0])
+#define Hi(d) (((int *) &d)[1])
+#define LoWord(d) ((uint16) Lo(d))
+#define HiWord(d) ((uint16) Hi(d))
+#define K(n) (1024*(n))
+#define MASK(n) ((1<<n)-1)
+
+typedef enum {
+ NoKey = 0, CtrlA, CtrlB, CtrlC, CtrlD, CtrlE, CtrlF, CtrlG, CtrlH,
+ CtrlI, CtrlJ, CtrlK, CtrlL, CtrlM, CtrlN, CtrlO, CtrlP,
+ CtrlQ, CtrlR, CtrlS, CtrlT, CtrlU, CtrlV, CtrlW, CtrlX,
+ CtrlY, CtrlZ,
+ BSp = 8,
+ Tab = 9,
+ Enter = 13,
+ Eof = 26,
+ Esc = 27,
+ AltQ = 256 + 16, AltW, AltE, AltR, AltT, AltY, AltU, AltI, AltO, AltP,
+ AltA = 256 + 30, AltS, AltD, AltF, AltG, AltH, AltJ, AltK, AltL,
+ AltZ = 256 + 44, AltX, AltC, AltV, AltB, AltN, AltM,
+ F11 = 256 + 87, F12,
+ F1 = 256 + 59, F2, F3, F4, F5, F6, F7, F8, F9, F10,
+ ShiftTab = 256 + 15,
+ ShiftF1 = 256 + 84, ShiftF2, ShiftF3, ShiftF4, ShiftF5,
+ ShiftF6, ShiftF7, ShiftF8, ShiftF9, ShiftF10,
+ CtrlF1 = 256 + 94, CtrlF2, CtrlF3, CtrlF4, CtrlF5,
+ CtrlF6, CtrlF7, CtrlF8, CtrlF9, CtrlF10,
+ AltF1 = 256 + 104, AltF2, AltF3, AltF4, AltF5,
+ AltF6, AltF7, AltF8, AltF9, AltF10,
+ Home = 256 + 71,
Up,
PgUp,
- Left = 256+75,
+ Left = 256 + 75,
Ctr,
Right,
- End = 256+79,
+ End = 256 + 79,
Down,
PgDn,
Ins,
Del,
- CtrlLeft = 256+115,
+ CtrlLeft = 256 + 115,
CtrlRight,
CtrlEnd,
CtrlPgDn,
CtrlHome,
- CtrlPgUp = 256+132,
+ CtrlPgUp = 256 + 132,
- MouseLeft = 512+1,
+ MouseLeft = 512 + 1,
MouseRight,
- TwiceLeft = 512+256+1,
+ TwiceLeft = 512 + 256 + 1,
TwiceRight
- } Keys;
-
-struct KeyStatStruct
- {
- int RShift : 1;
- int LShift : 1;
- int Ctrl : 1;
- int Alt : 1;
-
- int ScrollLock : 1;
- int NumLock : 1;
- int CapsLock : 1;
- int Ins : 1;
-
- int LeftCtrl : 1;
- int LeftAlt : 1;
- int Unused : 6;
- };
-
-#define HGC_Cursor 0x0B0C
-#define CGA_Cursor 0x0607
-#define OFF_Cursor 0x2000
-
-#define TimerCount (* ((volatile long *) ((void _seg *) 0x40 + (void *) 0x6C)))
-#define KeyStat (* ((volatile struct KeyStatStruct *) ((void _seg *) 0x40 + (void *) 0x17)))
-#define BreakFlag (* ((volatile uint8 *) ((void _seg *) 0x40 + (void *) 0x71)))
-#define PostFlag (* ((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72)))
-#define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0))
-#define SLIF if (KeyStat.ScrollLock)
-
-#define FOR(i,n) for(i=0;i<(n);i++)
-
-#define TRAP(x) { if (x) asm { int 3 } }
-
-#ifdef DEBUG
- #define Debug(x) x
+} Keys;
+
+struct KeyStatStruct {
+ int RShift : 1;
+ int LShift : 1;
+ int Ctrl : 1;
+ int Alt : 1;
+
+ int ScrollLock : 1;
+ int NumLock : 1;
+ int CapsLock : 1;
+ int Ins : 1;
+
+ int LeftCtrl : 1;
+ int LeftAlt : 1;
+ int Unused : 6;
+};
+
+#define HGC_Cursor 0x0B0C
+#define CGA_Cursor 0x0607
+#define OFF_Cursor 0x2000
+
+#define TimerCount (* ((volatile long *) ((void _seg *) 0x40 + (void *) 0x6C)))
+#define KeyStat (* ((volatile struct KeyStatStruct *) ((void _seg *) 0x40 + (void *) 0x17)))
+#define BreakFlag (* ((volatile uint8 *) ((void _seg *) 0x40 + (void *) 0x71)))
+#define PostFlag (* ((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72)))
+#define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0))
+#define SLIF if (KeyStat.ScrollLock)
+
+#define FOR(i,n) for(i = 0; i < (n); i++)
+
+#define TRAP(x) { warning("STUB: TRAP"); /*if (x) asm { int 3 } */ }
+
+#ifdef DEBUG
+#define Debug(x) x
#else
- #define Debug(x)
+#define Debug(x)
#endif
-#ifdef DEMO
- #define Demo(x) x
+#ifdef DEMO
+#define Demo(x) x
#else
- #define Demo(x)
+#define Demo(x)
#endif
-#ifdef __cplusplus
- #define EC extern "C"
+#ifdef __cplusplus
+#define EC extern "C"
#else
- #define EC
+#define EC
#endif
-extern uint16 _stklen;
-extern uint16 _heaplen;
+extern uint16 _stklen;
+extern uint16 _heaplen;
} // End of namespace CGE
diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp
index 95899bed55..a4590f4980 100644
--- a/engines/cge/keybd.cpp
+++ b/engines/cge/keybd.cpp
@@ -25,129 +25,128 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/keybd.h"
-#include "cge/mouse.h"
-#include <dos.h>
+#include "cge/keybd.h"
+#include "cge/mouse.h"
+#include <dos.h>
namespace CGE {
-SPRITE * KEYBOARD::Client = NULL;
+SPRITE *KEYBOARD::Client = NULL;
uint8 KEYBOARD::Key[0x60] = { 0 };
uint16 KEYBOARD::Current = 0;
-uint16 KEYBOARD::Code[0x60] = { 0,Esc,'1','2','3','4','5','6','7','8','9','0',
- '-','+',BSp,Tab,'Q','W','E','R','T','Y','U',
- 'I','O','P','[',']',Enter,0/*Ctrl*/,'A','S',
- 'D','F','G','H','J','K','L',';','\'','`',
- 0/*LShift*/,'\\','Z','X','C','V','B','N','M',
- ',','.','/',0/*RShift*/,'*',0/*Alt*/,' ',
- 0/*Caps*/,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,
- 0/*NumLock*/,0/*ScrollLock*/,Home,Up,PgUp,
- '-',Left,Ctr,Right,'+',End,Down,PgDn,Ins,Del,
- 0*0x54,0*0x55,0*0x56,F11,F12,0*0x59,0*0x5A,
- 0*0x5B,0*0x5C,0*0x5D,0*0x5E,0*0x5F
- };
-void (* KEYBOARD::OldKeyboard) (...);
-
-
-
-KEYBOARD::KEYBOARD (void)
-{
- // steal keyboard interrupt
- /* TODO replace totally by scummvm handling
- OldKeyboard = getvect(KEYBD_INT);
- setvect(KEYBD_INT, NewKeyboard);
- */
- warning("STUB: KEYBOARD::KEYBOARD");
+uint16 KEYBOARD::Code[0x60] = {
+ 0, Esc, '1', '2', '3',
+ '4', '5', '6', '7', '8',
+ '9', '0', '-', '+', BSp,
+ Tab, 'Q', 'W', 'E', 'R',
+ 'T', 'Y', 'U', 'I', 'O',
+ 'P', '[', ']', Enter, 0/*Ctrl*/,
+ 'A', 'S', 'D', 'F', 'G',
+ 'H', 'J', 'K', 'L', ';',
+ '\'', '`', 0/*LShift*/, '\\', 'Z',
+ 'X', 'C', 'V', 'B', 'N',
+ 'M', ',', '.', '/', 0/*RShift*/,
+ '*', 0/*Alt*/, ' ', 0/*Caps*/, F1,
+ F2, F3, F4, F5, F6,
+ F7, F8, F9, F10, 0/*NumLock*/,
+ 0/*ScrollLock*/, Home, Up, PgUp, '-',
+ Left, Ctr, Right, '+', End,
+ Down, PgDn, Ins, Del, 0 * 0x54,
+ 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59,
+ 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E,
+ 0 * 0x5F
+};
+
+void (* KEYBOARD::OldKeyboard)(...);
+
+
+KEYBOARD::KEYBOARD(void) {
+ // steal keyboard interrupt
+ /* TODO replace totally by scummvm handling
+ OldKeyboard = getvect(KEYBD_INT);
+ setvect(KEYBD_INT, NewKeyboard);
+ */
+ warning("STUB: KEYBOARD::KEYBOARD");
}
-
-
-KEYBOARD::~KEYBOARD (void)
-{
- // bring back keyboard interrupt
- /* TODO replace totally by scummvm handling
+KEYBOARD::~KEYBOARD(void) {
+ // bring back keyboard interrupt
+ /* TODO replace totally by scummvm handling
setvect(KEYBD_INT, OldKeyboard);
- */
- warning("STUB: KEYBOARD::~KEYBOARD");
+ */
+ warning("STUB: KEYBOARD::~KEYBOARD");
}
-
-
-SPRITE * KEYBOARD::SetClient (SPRITE * spr)
-{
- Swap(Client, spr);
- return spr;
+SPRITE *KEYBOARD::SetClient(SPRITE *spr) {
+ Swap(Client, spr);
+ return spr;
}
-
-
-
-void KEYBOARD::NewKeyboard (...)
-{
- // table address
+void KEYBOARD::NewKeyboard(...) {
+ // table address
/*
- _SI = (uint16) Key;
-
- // take keyboard code
- asm in al,60h
- asm mov bl,al
- asm and bx,007Fh
- asm cmp bl,60h
- asm jae xit
- asm cmp al,bl
- asm je ok // key pressed
-
- // key released...
- asm cmp [si+bx],bh // BH == 0
- asm jne ok
- // ...but not pressed: call the original service
- OldKeyboard();
- return;
-
- ok:
- asm shl ax,1
- asm and ah,1
- asm xor ah,1
- asm mov [si+bx],ah
- asm jz xit // released: exit
-
- // pressed: lock ASCII code
- _SI = (uint16) Code;
- asm add bx,bx // uint16 size
- asm mov ax,[si+bx]
- asm or ax,ax
- asm jz xit // zero means NO KEY
- Current = _AX;
-
- _SI = (uint16) Client;
- asm or si,si
- asm jz xit // if (Client) ...
-//--- fill current event entry with mask, key code and sprite
- asm mov bx,EvtHead // take queue head pointer
- asm inc byte ptr EvtHead // update queue head pointer
- asm shl bx,3 // * 8
- _AX = Current;
- asm mov Evt[bx].(struct EVENT)X,ax // key code
- asm mov ax,KEYB // event mask
- asm mov Evt[bx].(struct EVENT)Msk,ax // event mask
- //asm mov Evt[bx].(struct EVENT)Y,dx // row
- asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer
-
- xit:
-
- asm in al,61h // kbd control lines
- asm push ax // save it
- asm or al,80h // set the "enable kbd" bit
- asm out 61h,al // and write it out
- asm pop ax // original control port value
- asm out 61h,al // write it back
- asm mov al,20h // send End-Of-Interrupt
- asm out 20h,al // to the 8259 IC
- */
- warning("STUB: KEYBOARD::NewKeyboard");
+ _SI = (uint16) Key;
+
+ // take keyboard code
+ asm in al,60h
+ asm mov bl,al
+ asm and bx,007Fh
+ asm cmp bl,60h
+ asm jae xit
+ asm cmp al,bl
+ asm je ok // key pressed
+
+ // key released...
+ asm cmp [si+bx],bh // BH == 0
+ asm jne ok
+ // ...but not pressed: call the original service
+ OldKeyboard();
+ return;
+
+ ok:
+ asm shl ax,1
+ asm and ah,1
+ asm xor ah,1
+ asm mov [si+bx],ah
+ asm jz xit // released: exit
+
+ // pressed: lock ASCII code
+ _SI = (uint16) Code;
+ asm add bx,bx // uint16 size
+ asm mov ax,[si+bx]
+ asm or ax,ax
+ asm jz xit // zero means NO KEY
+ Current = _AX;
+
+ _SI = (uint16) Client;
+ asm or si,si
+ asm jz xit // if (Client) ...
+ //--- fill current event entry with mask, key code and sprite
+ asm mov bx,EvtHead // take queue head pointer
+ asm inc byte ptr EvtHead // update queue head pointer
+ asm shl bx,3 // * 8
+ _AX = Current;
+ asm mov Evt[bx].(struct EVENT)X,ax // key code
+ asm mov ax,KEYB // event mask
+ asm mov Evt[bx].(struct EVENT)Msk,ax // event mask
+ //asm mov Evt[bx].(struct EVENT)Y,dx // row
+ asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer
+
+ xit:
+
+ asm in al,61h // kbd control lines
+ asm push ax // save it
+ asm or al,80h // set the "enable kbd" bit
+ asm out 61h,al // and write it out
+ asm pop ax // original control port value
+ asm out 61h,al // write it back
+ asm mov al,20h // send End-Of-Interrupt
+ asm out 20h,al // to the 8259 IC
+ */
+ warning("STUB: KEYBOARD::NewKeyboard");
}
} // End of namespace CGE
diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h
index 5e6c9ac534..f2fa595be2 100644
--- a/engines/cge/keybd.h
+++ b/engines/cge/keybd.h
@@ -25,34 +25,37 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __KEYBD__
-#define __KEYBD__
+#ifndef __KEYBD__
+#define __KEYBD__
-#include "cge/jbw.h"
-#include "cge/vga13h.h"
+#include "cge/jbw.h"
+#include "cge/vga13h.h"
namespace CGE {
-#define KEYBD_INT 9
-#define LSHIFT 42
-#define RSHIFT 54
-#define CTRL 29
-#define ALT 56
+#define KEYBD_INT 9
+#define LSHIFT 42
+#define RSHIFT 54
+#define CTRL 29
+#define ALT 56
-class KEYBOARD
-{
+class KEYBOARD {
public:
- static void (* OldKeyboard) (...);
- static void NewKeyboard (...);
- static uint16 Code[0x60];
- static uint16 Current;
- static SPRITE * Client;
- static uint8 Key[0x60];
- static uint16 Last (void) { uint16 cur = Current; Current = 0; return cur; }
- static SPRITE * SetClient (SPRITE * spr);
- KEYBOARD (void);
- ~KEYBOARD (void);
+ static void (* OldKeyboard)(...);
+ static void NewKeyboard(...);
+ static uint16 Code[0x60];
+ static uint16 Current;
+ static SPRITE *Client;
+ static uint8 Key[0x60];
+ static uint16 Last(void) {
+ uint16 cur = Current;
+ Current = 0;
+ return cur;
+ }
+ static SPRITE *SetClient(SPRITE *spr);
+ KEYBOARD(void);
+ ~KEYBOARD(void);
};
} // End of namespace CGE
diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp
index 385634d4b8..47a6e17fc9 100644
--- a/engines/cge/mixer.cpp
+++ b/engines/cge/mixer.cpp
@@ -25,136 +25,119 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/mixer.h"
-#include "cge/text.h"
-#include "cge/snail.h"
-#include "cge/mouse.h"
-#include "cge/snddrv.h"
-#include <string.h>
-//#include <alloc.h>
+#include "cge/mixer.h"
+#include "cge/text.h"
+#include "cge/snail.h"
+#include "cge/mouse.h"
+#include "cge/snddrv.h"
+#include <string.h>
namespace CGE {
-extern MOUSE Mouse;
-
- bool MIXER::Appear = false;
-
-
-
-MIXER::MIXER (int x, int y)
-: SPRITE(NULL), Fall(MIX_FALL)
-{
- int i;
- Appear = true;
- mb[0] = new BITMAP("VOLUME");
- mb[1] = NULL;
- SetShapeList(mb);
- SetName(Text[MIX_NAME]);
- Flags.Syst = true;
- Flags.Kill = true;
- Flags.BDel = true;
- Goto(x, y);
- Z = MIX_Z;
-
- // slaves
-
- for (i = 0; i < MIX_MAX; i ++)
- {
- static char fn[] = "V00";
- wtom(i, fn+1, 10, 2);
- lb[i] = new BITMAP(fn);
- ls[i].Now = ls[i].Next = i;
- ls[i].Dx = ls[i].Dy = ls[i].Dly = 0;
- }
- lb[i] = NULL;
-
- for (i = 0; i < ArrayCount(Led); i ++)
- {
- register SPRITE * spr = new SPRITE(lb);
- spr->SetSeq(ls);
- spr->Goto(x+2+12*i, y+8);
- spr->Flags.Tran = true;
- spr->Flags.Kill = true;
- spr->Flags.BDel = false;
- spr->Z = MIX_Z;
- Led[i] = spr;
- }
- Led[ArrayCount(Led)-1]->Flags.BDel = true;
-
- VGA::ShowQ.Insert(this);
- for (i = 0; i < ArrayCount(Led); i ++) VGA::ShowQ.Insert(Led[i]);
-
- //--- reset balance
- i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2;
- SNDDrvInfo.VOL4.ML = i;
- SNDDrvInfo.VOL4.MR = i;
- i = (SNDDrvInfo.VOL4.DL + SNDDrvInfo.VOL4.DR) / 2;
- SNDDrvInfo.VOL4.DL = i;
- SNDDrvInfo.VOL4.DR = i;
- Update();
- Time = MIX_DELAY;
-}
+extern MOUSE Mouse;
+
+bool MIXER::Appear = false;
+MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) {
+ Appear = true;
+ mb[0] = new BITMAP("VOLUME");
+ mb[1] = NULL;
+ SetShapeList(mb);
+ SetName(Text[MIX_NAME]);
+ Flags.Syst = true;
+ Flags.Kill = true;
+ Flags.BDel = true;
+ Goto(x, y);
+ Z = MIX_Z;
+ // slaves
-MIXER::~MIXER (void)
-{
- Appear = false;
+ int i;
+ for (i = 0; i < MIX_MAX; i ++) {
+ static char fn[] = "V00";
+ wtom(i, fn + 1, 10, 2);
+ lb[i] = new BITMAP(fn);
+ ls[i].Now = ls[i].Next = i;
+ ls[i].Dx = ls[i].Dy = ls[i].Dly = 0;
+ }
+ lb[i] = NULL;
+
+ for (i = 0; i < ArrayCount(Led); i ++) {
+ register SPRITE *spr = new SPRITE(lb);
+ spr->SetSeq(ls);
+ spr->Goto(x + 2 + 12 * i, y + 8);
+ spr->Flags.Tran = true;
+ spr->Flags.Kill = true;
+ spr->Flags.BDel = false;
+ spr->Z = MIX_Z;
+ Led[i] = spr;
+ }
+ Led[ArrayCount(Led) - 1]->Flags.BDel = true;
+
+ VGA::ShowQ.Insert(this);
+ for (i = 0; i < ArrayCount(Led); i ++)
+ VGA::ShowQ.Insert(Led[i]);
+
+ //--- reset balance
+ i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2;
+ SNDDrvInfo.VOL4.ML = i;
+ SNDDrvInfo.VOL4.MR = i;
+ i = (SNDDrvInfo.VOL4.DL + SNDDrvInfo.VOL4.DR) / 2;
+ SNDDrvInfo.VOL4.DL = i;
+ SNDDrvInfo.VOL4.DR = i;
+ Update();
+ Time = MIX_DELAY;
}
+MIXER::~MIXER(void) {
+ Appear = false;
+}
#pragma argsused
-void MIXER::Touch (uint16 mask, int x, int y)
-{
- SPRITE::Touch(mask, x, y);
- if (mask & L_UP)
- {
- uint8 * vol = (&SNDDrvInfo.VOL2.D) + (x < W/2);
- if (y < MIX_BHIG) { if (*vol < 0xFF) *vol += 0x11; }
- else if (y >= H-MIX_BHIG) { if (*vol > 0x00) *vol -= 0x11; }
- Update();
- }
+void MIXER::Touch(uint16 mask, int x, int y) {
+ SPRITE::Touch(mask, x, y);
+ if (mask & L_UP) {
+ uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < W / 2);
+ if (y < MIX_BHIG) {
+ if (*vol < 0xFF)
+ *vol += 0x11;
+ } else if (y >= H - MIX_BHIG) {
+ if (*vol > 0x00)
+ *vol -= 0x11;
+ }
+ Update();
+ }
}
-
-void MIXER::Tick (void)
-{
- int x = Mouse.X, y = Mouse.Y;
- if (SpriteAt(x, y) == this)
- {
- Fall = MIX_FALL;
- if (Flags.Hold) Touch(L_UP, x-X, y-Y);
- }
- else
- {
- if (Fall) -- Fall;
- else
- {
- int i;
- for (i = 0; i < ArrayCount(Led); i ++)
- {
- SNPOST_(SNKILL, -1, 0, Led[i]);
- }
- SNPOST_(SNKILL, -1, 0, this);
+void MIXER::Tick(void) {
+ int x = Mouse.X, y = Mouse.Y;
+ if (SpriteAt(x, y) == this) {
+ Fall = MIX_FALL;
+ if (Flags.Hold)
+ Touch(L_UP, x - X, y - Y);
+ } else {
+ if (Fall)
+ --Fall;
+ else {
+ for (int i = 0; i < ArrayCount(Led); i ++)
+ SNPOST_(SNKILL, -1, 0, Led[i]);
+ SNPOST_(SNKILL, -1, 0, this);
+ }
}
- }
- Time = MIX_DELAY;
+ Time = MIX_DELAY;
}
+void MIXER::Update(void) {
+ Led[0]->Step(SNDDrvInfo.VOL4.ML);
+ Led[1]->Step(SNDDrvInfo.VOL4.DL);
-
-void MIXER::Update (void)
-{
- Led[0]->Step(SNDDrvInfo.VOL4.ML);
- Led[1]->Step(SNDDrvInfo.VOL4.DL);
-
- //TODO Change the SNPOST message send to a special way to send function pointer
- //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume);
- warning("FIXME: MIXER::Update");
+ //TODO Change the SNPOST message send to a special way to send function pointer
+ //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume);
+ warning("STUB: MIXER::Update");
}
} // End of namespace CGE
diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h
index 30beaf2f5d..81bc7c7cdf 100644
--- a/engines/cge/mixer.h
+++ b/engines/cge/mixer.h
@@ -25,34 +25,33 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __MIXER__
-#define __MIXER__
+#ifndef __MIXER__
+#define __MIXER__
-#include "cge/vga13h.h"
+#include "cge/vga13h.h"
namespace CGE {
-#define MIX_MAX 16 // count of Leds
-#define MIX_Z 64 // mixer Z position
-#define MIX_DELAY 12 // 6/s
-#define MIX_FALL 6 // in MIX_DELAY units
-#define MIX_BHIG 6 // mixer button high
-#define MIX_NAME 105 // sprite name
-
-class MIXER : public SPRITE
-{
- BMP_PTR mb[2];
- BMP_PTR lb[MIX_MAX+1];
- SEQ ls[MIX_MAX];
- SPRITE * Led[2];
- int Fall;
- void Update (void);
+#define MIX_MAX 16 // count of Leds
+#define MIX_Z 64 // mixer Z position
+#define MIX_DELAY 12 // 6/s
+#define MIX_FALL 6 // in MIX_DELAY units
+#define MIX_BHIG 6 // mixer button high
+#define MIX_NAME 105 // sprite name
+
+class MIXER : public SPRITE {
+ BMP_PTR mb[2];
+ BMP_PTR lb[MIX_MAX + 1];
+ SEQ ls[MIX_MAX];
+ SPRITE *Led[2];
+ int Fall;
+ void Update(void);
public:
- static bool Appear;
- MIXER (int x, int y);
- ~MIXER (void);
- void Touch (uint16 mask, int x, int y);
- void Tick (void);
+ static bool Appear;
+ MIXER(int x, int y);
+ ~MIXER(void);
+ void Touch(uint16 mask, int x, int y);
+ void Tick(void);
};
} // End of namespace CGE
diff --git a/engines/cge/module.mk b/engines/cge/module.mk
index 552cddb500..70967667a5 100644
--- a/engines/cge/module.mk
+++ b/engines/cge/module.mk
@@ -1,5 +1,5 @@
MODULE := engines/cge
-
+
MODULE_OBJS := \
bitmap.o \
bitmaps.o \
@@ -28,11 +28,12 @@ MODULE_OBJS := \
MODULE_DIRS += \
engines/cge
-
+
# This module can be built as a plugin
ifeq ($(ENABLE_CGE), DYNAMIC_PLUGIN)
PLUGIN := 1
endif
-
+
# Include common rules
include $(srcdir)/rules.mk
+
diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp
index dff2a0ff8b..d97a7eca7f 100644
--- a/engines/cge/mouse.cpp
+++ b/engines/cge/mouse.cpp
@@ -25,215 +25,177 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/mouse.h"
-#include "cge/text.h"
-#include <dos.h>
+#include "cge/mouse.h"
+#include "cge/text.h"
+#include <dos.h>
namespace CGE {
- EVENT Evt[EVT_MAX];
+EVENT Evt[EVT_MAX];
- uint16 EvtHead = 0, EvtTail = 0;
-//--------------------------------------------------------------------------
+uint16 EvtHead = 0, EvtTail = 0;
-MOUSE_FUN * MOUSE::OldMouseFun = NULL;
-uint16 MOUSE::OldMouseMask = 0;
+MOUSE_FUN *MOUSE::OldMouseFun = NULL;
+uint16 MOUSE::OldMouseMask = 0;
+MOUSE::MOUSE(BITMAP **shpl) : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) {
+ static SEQ ms[] = {
+ { 0, 0, 0, 0, 1 },
+ { 1, 1, 0, 0, 1 }
+ };
-//--------------------------------------------------------------------------
+ SetSeq(ms);
+ /* TODO Mouse handling
+ // Mouse reset
+ _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work)
+ __int__(0x33);
+ Exist = (_AX != 0);
+ Buttons = _BX;
-
-
-
-MOUSE::MOUSE (BITMAP ** shpl)
- : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0)
-{
- static SEQ ms[] = { { 0,0,0,0,1 }, { 1,1,0,0,1 } };
- SetSeq(ms);
-
- /* TODO Mouse handling
- // Mouse reset
- _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work)
- __int__(0x33);
- Exist = (_AX != 0);
- Buttons = _BX;
-
- Goto(SCR_WID/2, SCR_HIG/2);
- Z = 127;
- Step(1);
- */
+ Goto(SCR_WID/2, SCR_HIG/2);
+ Z = 127;
+ Step(1);
+ */
+ warning("STUB: MOUSE::MOUSE");
}
-
-
-MOUSE::~MOUSE (void)
-{
- Off();
+MOUSE::~MOUSE(void) {
+ Off();
}
-
-
-
//void MOUSE::SetFun (void)
//{
//}
-
-
-
-void MOUSE::On (void)
-{
- // TODO Mouse
-/*
- if (SeqPtr && Exist)
- {
- _CX = X + X; // horizontal position
- _DX = Y; // vertical position
- _AX = 0x0004; // Set Mouse Position
- __int__(0x33);
- // set new mouse fun
- _ES = FP_SEG(NewMouseFun);
- _DX = FP_OFF(NewMouseFun);
- _CX = 0x001F; // 11111b = all events
- _AX = 0x0014; // Swap User-Interrupt Vector
- __int__(0x33);
- // save old mouse fun
- OldMouseMask = _CX;
- OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX);
-
- // set X bounds
- _DX = (SCR_WID - W) * 2; // right limit
- _CX = 0; // left limit
- _AX = 0x0007; // note: each pixel = 2
- __int__(0x33);
-
- // set Y bounds
- _DX = SCR_HIG - H; // bottom limit
- _CX = 0; // top limit
- _AX = 0x0008;
- __int__(0x33);
-
- Step(0);
- if (Busy) Busy->Step(0);
- }
-*/
+void MOUSE::On(void) {
+ /*
+ if (SeqPtr && Exist)
+ {
+ _CX = X + X; // horizontal position
+ _DX = Y; // vertical position
+ _AX = 0x0004; // Set Mouse Position
+ __int__(0x33);
+ // set new mouse fun
+ _ES = FP_SEG(NewMouseFun);
+ _DX = FP_OFF(NewMouseFun);
+ _CX = 0x001F; // 11111b = all events
+ _AX = 0x0014; // Swap User-Interrupt Vector
+ __int__(0x33);
+ // save old mouse fun
+ OldMouseMask = _CX;
+ OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX);
+
+ // set X bounds
+ _DX = (SCR_WID - W) * 2; // right limit
+ _CX = 0; // left limit
+ _AX = 0x0007; // note: each pixel = 2
+ __int__(0x33);
+
+ // set Y bounds
+ _DX = SCR_HIG - H; // bottom limit
+ _CX = 0; // top limit
+ _AX = 0x0008;
+ __int__(0x33);
+
+ Step(0);
+ if (Busy) Busy->Step(0);
+ }
+ */
+ warning("STUB: MOUSE::On");
}
-
-
-
-
-void MOUSE::Off (void)
-{
-//TODO MOuse ASM
- /*
- if (SeqPtr == 0)
- {
- if (Exist)
+void MOUSE::Off(void) {
+/*
+ if (SeqPtr == 0)
+ {
+ if (Exist)
{
// bring back old mouse fun
_ES = FP_SEG(OldMouseFun);
_DX = FP_OFF(OldMouseFun);
_CX = OldMouseMask;
- _AX = 0x0014; // Swap User-Interrupt Vector
+ _AX = 0x0014; // Swap User-Interrupt Vector
__int__(0x33);
}
- Step(1);
- if (Busy) Busy->Step(1);
- }
+ Step(1);
+ if (Busy) Busy->Step(1);
+ }
*/
+ warning("STUB: MOUSE::Off");
}
-
-
-
-
-void MOUSE::ClrEvt (SPRITE * spr)
-{
- if (spr)
- {
- uint16 e;
- for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX)
- if (Evt[e].Ptr == spr) Evt[e].Msk = 0;
- }
- else EvtTail = EvtHead;
+void MOUSE::ClrEvt(SPRITE *spr) {
+ if (spr) {
+ uint16 e;
+ for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX)
+ if (Evt[e].Ptr == spr)
+ Evt[e].Msk = 0;
+ } else
+ EvtTail = EvtHead;
}
-
-
-
-
-void MOUSE::Tick (void)
-{
- Step();
- while (EvtTail != EvtHead)
- {
- EVENT e = Evt[EvtTail];
- if (e.Msk)
- {
- if (Hold && e.Ptr != Hold)
- {
- Hold->Touch(e.Msk | ATTN, e.X - Hold->X, e.Y - Hold->Y);
- }
-
- // update mouse cursor position
- if (e.Msk & ROLL)
- {
- Goto(e.X, e.Y);
- }
-
- // activate current touched SPRITE
- if (e.Ptr)
- {
- if (e.Msk & KEYB) e.Ptr->Touch(e.Msk, e.X, e.Y);
- else e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y);
- }
- else if (Sys) Sys->Touch(e.Msk, e.X, e.Y);
-
- if (e.Msk & L_DN)
- {
- Hold = e.Ptr;
- if (Hold)
- {
- Hold->Flags.Hold = true;
- #ifndef DEBUG
- if (Hold->Flags.Drag)
- #endif
- {
- hx = e.X - Hold->X;
- hy = e.Y - Hold->Y;
- }
+void MOUSE::Tick(void) {
+ Step();
+ while (EvtTail != EvtHead) {
+ EVENT e = Evt[EvtTail];
+ if (e.Msk) {
+ if (Hold && e.Ptr != Hold)
+ Hold->Touch(e.Msk | ATTN, e.X - Hold->X, e.Y - Hold->Y);
+
+ // update mouse cursor position
+ if (e.Msk & ROLL)
+ Goto(e.X, e.Y);
+
+ // activate current touched SPRITE
+ if (e.Ptr) {
+ if (e.Msk & KEYB)
+ e.Ptr->Touch(e.Msk, e.X, e.Y);
+ else
+ e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y);
+ } else if (Sys)
+ Sys->Touch(e.Msk, e.X, e.Y);
+
+ if (e.Msk & L_DN) {
+ Hold = e.Ptr;
+ if (Hold) {
+ Hold->Flags.Hold = true;
+#ifndef DEBUG
+ if (Hold->Flags.Drag)
+#endif
+ {
+ hx = e.X - Hold->X;
+ hy = e.Y - Hold->Y;
+ }
+ }
+ }
+
+ if (e.Msk & L_UP) {
+ if (Hold) {
+ Hold->Flags.Hold = false;
+ Hold = NULL;
+ }
+ }
+ ///Touched = e.Ptr;
+
+ // discard Text if button released
+ if (e.Msk & (L_UP | R_UP))
+ KillText();
}
- }
-
- if (e.Msk & L_UP)
- {
- if (Hold)
- {
- Hold->Flags.Hold = false;
- Hold = NULL;
- }
- }
- ///Touched = e.Ptr;
-
- // discard Text if button released
- if (e.Msk & (L_UP | R_UP)) KillText();
+ EvtTail = (EvtTail + 1) % EVT_MAX;
}
- EvtTail = (EvtTail + 1) % EVT_MAX;
- }
- if (Hold)
- #ifndef DEBUG
- if (Hold->Flags.Drag)
- #endif
- Hold->Goto(X-hx, Y-hy);
+ if (Hold)
+#ifndef DEBUG
+ if (Hold->Flags.Drag)
+#endif
+ Hold->Goto(X - hx, Y - hy);
}
} // End of namespace CGE
diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h
index 20015b058f..78f43665cd 100644
--- a/engines/cge/mouse.h
+++ b/engines/cge/mouse.h
@@ -25,62 +25,58 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __MOUSE__
-#define __MOUSE__
+#ifndef __MOUSE__
+#define __MOUSE__
-#include "cge/game.h"
-#include "cge/talk.h"
+#include "cge/game.h"
+#include "cge/talk.h"
namespace CGE {
-#define EVT_MAX 256
-#define ROLL 0x01
-#define L_DN 0x02
-#define L_UP 0x04
-#define R_DN 0x08
-#define R_UP 0x10
-#define ATTN 0x20
-// 0x40
-#define KEYB 0x80
+#define EVT_MAX 256
+#define ROLL 0x01
+#define L_DN 0x02
+#define L_UP 0x04
+#define R_DN 0x08
+#define R_UP 0x10
+#define ATTN 0x20 // 0x40
+#define KEYB 0x80
-extern TALK * Talk;
-
-struct EVENT { uint16 Msk;
- uint16 X, Y;
- SPRITE * Ptr;
- };
-extern EVENT Evt[EVT_MAX];
-extern uint16 EvtHead, EvtTail;
-typedef void (MOUSE_FUN) (void);
-
+extern TALK *Talk;
+struct EVENT {
+ uint16 Msk;
+ uint16 X, Y;
+ SPRITE *Ptr;
+};
+extern EVENT Evt[EVT_MAX];
+extern uint16 EvtHead, EvtTail;
+typedef void (MOUSE_FUN)(void);
-class MOUSE : public SPRITE
-{
- static MOUSE_FUN * OldMouseFun;
- static MOUSE_FUN NewMouseFun;
- static uint16 OldMouseMask;
- SPRITE * Hold;
- int hx, hy;
- //void SetFun (void);
- //void ResetFun (void);
+class MOUSE : public SPRITE {
+ static MOUSE_FUN *OldMouseFun;
+ static MOUSE_FUN NewMouseFun;
+ static uint16 OldMouseMask;
+ SPRITE *Hold;
+ int hx, hy;
+ //void SetFun (void);
+ //void ResetFun (void);
public:
- bool Exist;
- int Buttons;
- SPRITE * Busy;
- //SPRITE * Touched;
- MOUSE (BITMAP ** shpl = MC);
- ~MOUSE (void);
- void On (void);
- void Off (void);
- static void ClrEvt (SPRITE * spr = NULL);
- void Tick (void);
+ bool Exist;
+ int Buttons;
+ SPRITE *Busy;
+ //SPRITE * Touched;
+ MOUSE(BITMAP **shpl = MC);
+ ~MOUSE(void);
+ void On(void);
+ void Off(void);
+ static void ClrEvt(SPRITE *spr = NULL);
+ void Tick(void);
};
-
} // End of namespace CGE
#endif
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index 82ec4c596d..952e032222 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -25,1290 +25,1108 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/general.h"
-#include "cge/sound.h"
-#include "cge/snail.h"
-#include "cge/vga13h.h"
-#include "cge/bitmaps.h"
-#include "cge/text.h"
-#include "cge/mouse.h"
-#include "cge/cge_main.h"
-#include <dos.h>
-//#include <alloc.h>
-//#include <mem.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "cge/keybd.h"
+#include "cge/general.h"
+#include "cge/sound.h"
+#include "cge/snail.h"
+#include "cge/vga13h.h"
+#include "cge/bitmaps.h"
+#include "cge/text.h"
+#include "cge/mouse.h"
+#include "cge/cge_main.h"
+#include <dos.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "cge/keybd.h"
namespace CGE {
- int MaxCave = 0;
+int MaxCave = 0;
- SCB Scb = { NULL, 0, NULL };
- bool Flag[4];
- bool Dark = false;
- bool Game = false;
- int Now = 1;
- int Lev = -1;
- SNAIL Snail = false;
- SNAIL Snail_ = true;
+SCB Scb = { NULL, 0, NULL };
+bool Flag[4];
+bool Dark = false;
+bool Game = false;
+int Now = 1;
+int Lev = -1;
+SNAIL Snail = false;
+SNAIL Snail_ = true;
-extern SPRITE PocLight;
+extern SPRITE PocLight;
//-------------------------------------------------------------------------
-// SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL,
+// SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL,
// NULL, NULL, NULL, NULL, };
-// int PocPtr = 0;
+// int PocPtr = 0;
//-------------------------------------------------------------------------
-extern SPRITE * Pocket[];
-extern int PocPtr;
-//-------------------------------------------------------------------------
-
-extern DAC * SysPal;
-extern MOUSE Mouse;
-
-
-
-//-------------------------------------------------------------------------
-
-
-static void SNGame (SPRITE * spr, int num)
-{
- switch (num)
- {
- //--------------------------------------------------------------------
- case 1 :
- {
- #define STAGES 8
- #define DRESSED 3
- static SPRITE * dup[3] = { NULL, NULL, NULL };
- int buref = 0;
- int Stage = 0;
-
- for (dup[0] = VGA::ShowQ.First(); dup[0]; dup[0] = dup[0]->Next)
- {
- buref = dup[0]->Ref;
- if (buref / 1000 == 16 && buref % 100 == 6)
- {
- Stage = (buref / 100) % 10;
- break;
- }
- }
- if (dup[1] == NULL)
- {
- dup[1] = VGA::ShowQ.Locate(16003); // pan
- dup[2] = VGA::ShowQ.Locate(16004); // pani
- }
-
- if (Game) // continue game
- {
- int i = new_random(3), hand = (dup[0]->ShpCnt == 6);
- ++ Stage;
- if (hand && Stage > DRESSED) ++ hand;
- if (
- Debug( i >= 0 || )
- dup[i] == spr && new_random(3) == 0)
- {
- SNPOST(SNSEQ, -1, 3, dup[0]); // yes
- SNPOST(SNSEQ, -1, 3, dup[1]); // yes
- SNPOST(SNSEQ, -1, 3, dup[2]); // yes
- SNPOST(SNTNEXT, -1, 0, dup[0]); // reset Take
- SNPOST(SNTNEXT, -1, 0, dup[1]); // reset Take
- SNPOST(SNTNEXT, -1, 0, dup[2]); // reset Take
- SNPOST(SNNNEXT, -1, 0, dup[0]); // reset Near
- SNPOST(SNPAUSE, -1, 72, NULL); // little rest
- SNPOST(SNSAY, 1, 16009, NULL); // hura
- SNPOST(SNSAY, buref, 16010, NULL); // siadaj
- SNPOST(SNSAY, 1, 16011, NULL); // postoj‘
-
- if (hand)
- {
- SNPOST(SNSEND, 16060+hand, 16, NULL); // dawaj r‘k‘
- SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie
- SNPOST(SNSEQ, 16060+hand, 1, NULL); // ruch
- SNPOST(SNSOUND, 16060+hand, 16002, NULL); // szelest
- SNPOST(SNWAIT, 16060+hand, 3, NULL); // podniesie
- SNPOST(SNSWAP, buref, buref+100, NULL); // rozdziana
- SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa
- SNPOST(SNSEND, 16060+hand, -1, NULL); // chowaj r‘k‘
- SNPOST(SNWAIT, 16060+hand, -1, NULL); // r‘ka zamar’a
- }
- else
- {
- SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie
- SNPOST(SNSOUND, 16060+hand, 16002, NULL); // szelest
- SNPOST(SNWAIT, buref, -1, NULL); // zdejmie
- SNPOST(SNSWAP, buref, buref+100, NULL); // rozdziana
- SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa
- }
- //SNPOST(SNSEQ, buref+100, 0, NULL); // reset
- SNPOST(SNPAUSE, -1, 72, NULL); // chwilk‘...
-
- SNPOST(SNSEQ, -1, 0, dup[1]); // odstaw Go
- SNPOST(SNSETXY, -1, 203 + SCR_WID * 49, dup[1]);
- SNPOST(SNSETZ, -1, 7, dup[1]);
-
- SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J†
- SNPOST(SNSETXY, -1, 182 + SCR_WID * 62, dup[2]);
- SNPOST(SNSETZ, -1, 9, dup[2]);
- Game = 0;
- return;
- }
- else
- {
- SNPOST(SNSEQ, -1, 2, dup[0]); // no
- SNPOST(SNSEQ, -1, 2, dup[1]); // no
- SNPOST(SNSEQ, -1, 2, dup[2]); // no
- SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec
+extern SPRITE *Pocket[];
+extern int PocPtr;
+extern DAC *SysPal;
+extern MOUSE Mouse;
+
+
+static void SNGame(SPRITE *spr, int num) {
+ switch (num) {
+ case 1 : {
+#define STAGES 8
+#define DRESSED 3
+ static SPRITE *dup[3] = { NULL, NULL, NULL };
+ int buref = 0;
+ int Stage = 0;
+
+ for (dup[0] = VGA::ShowQ.First(); dup[0]; dup[0] = dup[0]->Next) {
+ buref = dup[0]->Ref;
+ if (buref / 1000 == 16 && buref % 100 == 6) {
+ Stage = (buref / 100) % 10;
+ break;
+ }
}
- }
- SNPOST(SNWALK, 198, 134, NULL); // na miejsce
- SNPOST(SNWAIT, 1, -1, NULL); // stoi
- SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia
- SNPOST(SNSEQ, 16101, 1, NULL); // wystaw
- SNPOST(SNWAIT, 16101, 5, NULL); // czekaj
- SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘
- SNPOST(SNSEQ, 16040, 1, NULL); // plask
- SNPOST(SNSOUND, 16101, 16001, NULL); // plask!
- SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘
- SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask
- SNPOST(SNWAIT, 16101, -1, NULL); // stoi
- SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS
- if (! Game)
- {
- SNPOST(SNSAY, buref, 16008, NULL); // zgadnij!
- Game = true;
- }
- #undef STEPS
- #undef DRESSED
- } break;
- //--------------------------------------------------------------------
- case 2 :
- {
- static SPRITE * k = NULL, * k1, * k2, * k3;
- static int count = 0;
- bool hit;
-
- if (k == NULL)
- {
- k = VGA::ShowQ.Locate(20700);
- k1 = VGA::ShowQ.Locate(20701);
- k2 = VGA::ShowQ.Locate(20702);
- k3 = VGA::ShowQ.Locate(20703);
- }
-
- if (! Game) // init
- {
- SNPOST(SNGAME, 20002, 2, NULL);
- Game = true;
- }
- else // cont
- {
- k1->Step(new_random(6));
- k2->Step(new_random(6));
- k3->Step(new_random(6));
- ///--------------------
- if (spr->Ref == 1 && KEYBOARD::Key[ALT])
- {
- k1->Step(5);
- k2->Step(5);
- k3->Step(5);
+ if (dup[1] == NULL) {
+ dup[1] = VGA::ShowQ.Locate(16003); // pan
+ dup[2] = VGA::ShowQ.Locate(16004); // pani
}
- ///--------------------
- SNPOST(SNSETZ, 20700, 0, NULL);
- hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15);
- if (hit)
- {
- if (spr->Ref == 1)
- {
- SNPOST(SNSAY, 1, 20003, NULL); // hura!
- SNPOST(SNSEQ, 20011, 2, NULL); // kamera won
- SNPOST(SNSEND, 20701, -1, NULL); // k1 won
- SNPOST(SNSEND, 20702, -1, NULL); // k2 won
- SNPOST(SNSEND, 20703, -1, NULL); // k3 won
- SNPOST(SNSEND, 20700, -1, NULL); // tv won
- SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni
- SNPOST(SNSEND, 20006, 20, NULL); // bilon
- SNPOST(SNSOUND,20006, 20002, NULL); // bilon!
- SNPOST(SNSAY, 20002, 20004, NULL);
- SNPOST(SNSEND, 20010, 20, NULL); // papier
- SNPOST(SNSOUND,20010, 20003, NULL); // papier!
- SNPOST(SNSAY, 20001, 20005, NULL);
- Game = false;
- return;
- }
- else k3->Step(new_random(5));
+
+ if (Game) { // continue game
+ int i = new_random(3), hand = (dup[0]->ShpCnt == 6);
+ ++ Stage;
+ if (hand && Stage > DRESSED)
+ ++hand;
+ if (Debug(i >= 0 ||)
+ dup[i] == spr && new_random(3) == 0) {
+ SNPOST(SNSEQ, -1, 3, dup[0]); // yes
+ SNPOST(SNSEQ, -1, 3, dup[1]); // yes
+ SNPOST(SNSEQ, -1, 3, dup[2]); // yes
+ SNPOST(SNTNEXT, -1, 0, dup[0]); // reset Take
+ SNPOST(SNTNEXT, -1, 0, dup[1]); // reset Take
+ SNPOST(SNTNEXT, -1, 0, dup[2]); // reset Take
+ SNPOST(SNNNEXT, -1, 0, dup[0]); // reset Near
+ SNPOST(SNPAUSE, -1, 72, NULL); // little rest
+ SNPOST(SNSAY, 1, 16009, NULL); // hura
+ SNPOST(SNSAY, buref, 16010, NULL); // siadaj
+ SNPOST(SNSAY, 1, 16011, NULL); // postoj‘
+
+ if (hand) {
+ SNPOST(SNSEND, 16060 + hand, 16, NULL); // dawaj r‘k‘
+ SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie
+ SNPOST(SNSEQ, 16060 + hand, 1, NULL); // ruch
+ SNPOST(SNSOUND, 16060 + hand, 16002, NULL); // szelest
+ SNPOST(SNWAIT, 16060 + hand, 3, NULL); // podniesie
+ SNPOST(SNSWAP, buref, buref + 100, NULL); // rozdziana
+ SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa
+ SNPOST(SNSEND, 16060 + hand, -1, NULL); // chowaj r‘k‘
+ SNPOST(SNWAIT, 16060 + hand, -1, NULL); // r‘ka zamar’a
+ } else {
+ SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie
+ SNPOST(SNSOUND, 16060 + hand, 16002, NULL); // szelest
+ SNPOST(SNWAIT, buref, -1, NULL); // zdejmie
+ SNPOST(SNSWAP, buref, buref + 100, NULL); // rozdziana
+ SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa
+ }
+ //SNPOST(SNSEQ, buref+100, 0, NULL); // reset
+ SNPOST(SNPAUSE, -1, 72, NULL); // chwilk‘...
+
+ SNPOST(SNSEQ, -1, 0, dup[1]); // odstaw Go
+ SNPOST(SNSETXY, -1, 203 + SCR_WID * 49, dup[1]);
+ SNPOST(SNSETZ, -1, 7, dup[1]);
+
+ SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J†
+ SNPOST(SNSETXY, -1, 182 + SCR_WID * 62, dup[2]);
+ SNPOST(SNSETZ, -1, 9, dup[2]);
+ Game = 0;
+ return;
+ } else {
+ SNPOST(SNSEQ, -1, 2, dup[0]); // no
+ SNPOST(SNSEQ, -1, 2, dup[1]); // no
+ SNPOST(SNSEQ, -1, 2, dup[2]); // no
+ SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec
+ }
+ }
+ SNPOST(SNWALK, 198, 134, NULL); // na miejsce
+ SNPOST(SNWAIT, 1, -1, NULL); // stoi
+ SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia
+ SNPOST(SNSEQ, 16101, 1, NULL); // wystaw
+ SNPOST(SNWAIT, 16101, 5, NULL); // czekaj
+ SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘
+ SNPOST(SNSEQ, 16040, 1, NULL); // plask
+ SNPOST(SNSOUND, 16101, 16001, NULL); // plask!
+ SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘
+ SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask
+ SNPOST(SNWAIT, 16101, -1, NULL); // stoi
+ SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS
+ if (! Game) {
+ SNPOST(SNSAY, buref, 16008, NULL); // zgadnij!
+ Game = true;
}
- if (count < 100)
- {
- switch (count)
- {
- case 15 : SNPOST(SNSAY, 20003, 20021, NULL); break;
- case 30 :
- case 45 :
- case 60 :
- case 75 : SNPOST(SNSAY, 20003, 20022, NULL); break;
- }
- ++ count;
+#undef STEPS
+#undef DRESSED
+ }
+ break;
+ //--------------------------------------------------------------------
+ case 2 : {
+ static SPRITE *k = NULL, * k1, * k2, * k3;
+ static int count = 0;
+ bool hit;
+
+ if (k == NULL) {
+ k = VGA::ShowQ.Locate(20700);
+ k1 = VGA::ShowQ.Locate(20701);
+ k2 = VGA::ShowQ.Locate(20702);
+ k3 = VGA::ShowQ.Locate(20703);
}
- switch (spr->Ref)
- {
- case 1 : SNPOST(SNSAY, 20001, 20011, NULL); // zapro
- SNPOST(SNSEQ, 20001, 1, NULL); // rzu
- SNPOST(SNWAIT, 20001, 1, NULL); // czekaj
- SNPOST(SNSETZ, 20700, 2, NULL); // skryj k
- SNPOST(SNHIDE, 20007, 1, NULL); // skryj k
- SNPOST(SNWAIT, 20001, 16, NULL); // czekaj
- SNPOST(SNSEQ, 20007, 1, NULL); // lec†
- SNPOST(SNHIDE, 20007, 0, NULL); // poka§
- SNPOST(SNSOUND,20007, 20001, NULL); // grzech
- SNPOST(SNWAIT, 20007, -1, NULL); // koniec
- SNPOST(SNGAME, 20001, 2, NULL); // again!
- break;
- case 20001 : SNPOST(SNSAY, 20002, 20012, NULL); // zapro
- SNPOST(SNSEQ, 20002, 1, NULL); // rzu
- SNPOST(SNWAIT, 20002, 3, NULL); // czekaj
- SNPOST(SNSETZ, 20700, 2, NULL); // skryj k
- SNPOST(SNHIDE, 20007, 1, NULL); // skryj k
- SNPOST(SNWAIT, 20002, 10, NULL); // czekaj
- SNPOST(SNSEQ, 20007, 2, NULL); // lec†
- SNPOST(SNHIDE, 20007, 0, NULL); // poka§
- SNPOST(SNSOUND,20007, 20001, NULL); // grzech
- SNPOST(SNWAIT, 20007, -1, NULL); // koniec
- SNPOST(SNGAME, 20002, 2, NULL); // again!
- break;
- case 20002 : SNPOST(SNSAY, 20002, 20010, NULL); // zapro
- SNPOST(SNWALK, 20005, -1, NULL); // do stol
- SNPOST(SNWAIT, 1, -1, NULL); // stoi
- SNPOST(SNCOVER, 1, 20101, NULL); // grasol
- SNPOST(SNSEQ, 20101, 1, NULL); // rzu
- SNPOST(SNWAIT, 20101, 5, NULL); // czekaj
- SNPOST(SNSETZ, 20700, 2, NULL); // skryj k
- SNPOST(SNHIDE, 20007, 1, NULL); // skryj k
- SNPOST(SNWAIT, 20101, 15, NULL); // czekaj
- SNPOST(SNSEQ, 20007, 1, NULL); // lec†
- SNPOST(SNHIDE, 20007, 0, NULL); // poka§
- SNPOST(SNSOUND,20007, 20001, NULL); // grzech
- SNPOST(SNWAIT, 20101, -1, NULL); // koniec
- SNPOST(SNUNCOVER, 1, 20101, NULL); // SDS
- SNPOST(SNGAME, 1, 2, NULL); // again!
- break;
+
+ if (! Game) { // init
+ SNPOST(SNGAME, 20002, 2, NULL);
+ Game = true;
+ } else { // cont
+ k1->Step(new_random(6));
+ k2->Step(new_random(6));
+ k3->Step(new_random(6));
+ ///--------------------
+ if (spr->Ref == 1 && KEYBOARD::Key[ALT]) {
+ k1->Step(5);
+ k2->Step(5);
+ k3->Step(5);
+ }
+ ///--------------------
+ SNPOST(SNSETZ, 20700, 0, NULL);
+ hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15);
+ if (hit) {
+ if (spr->Ref == 1) {
+ SNPOST(SNSAY, 1, 20003, NULL); // hura!
+ SNPOST(SNSEQ, 20011, 2, NULL); // kamera won
+ SNPOST(SNSEND, 20701, -1, NULL); // k1 won
+ SNPOST(SNSEND, 20702, -1, NULL); // k2 won
+ SNPOST(SNSEND, 20703, -1, NULL); // k3 won
+ SNPOST(SNSEND, 20700, -1, NULL); // tv won
+ SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni
+ SNPOST(SNSEND, 20006, 20, NULL); // bilon
+ SNPOST(SNSOUND, 20006, 20002, NULL); // bilon!
+ SNPOST(SNSAY, 20002, 20004, NULL);
+ SNPOST(SNSEND, 20010, 20, NULL); // papier
+ SNPOST(SNSOUND, 20010, 20003, NULL); // papier!
+ SNPOST(SNSAY, 20001, 20005, NULL);
+ Game = false;
+ return;
+ } else
+ k3->Step(new_random(5));
+ }
+ if (count < 100) {
+ switch (count) {
+ case 15 :
+ SNPOST(SNSAY, 20003, 20021, NULL);
+ break;
+ case 30 :
+ case 45 :
+ case 60 :
+ case 75 :
+ SNPOST(SNSAY, 20003, 20022, NULL);
+ break;
+ }
+ ++ count;
+ }
+ switch (spr->Ref) {
+ case 1 :
+ SNPOST(SNSAY, 20001, 20011, NULL); // zapro
+ SNPOST(SNSEQ, 20001, 1, NULL); // rzu
+ SNPOST(SNWAIT, 20001, 1, NULL); // czekaj
+ SNPOST(SNSETZ, 20700, 2, NULL); // skryj k
+ SNPOST(SNHIDE, 20007, 1, NULL); // skryj k
+ SNPOST(SNWAIT, 20001, 16, NULL); // czekaj
+ SNPOST(SNSEQ, 20007, 1, NULL); // lec†
+ SNPOST(SNHIDE, 20007, 0, NULL); // poka§
+ SNPOST(SNSOUND, 20007, 20001, NULL); // grzech
+ SNPOST(SNWAIT, 20007, -1, NULL); // koniec
+ SNPOST(SNGAME, 20001, 2, NULL); // again!
+ break;
+ case 20001 :
+ SNPOST(SNSAY, 20002, 20012, NULL); // zapro
+ SNPOST(SNSEQ, 20002, 1, NULL); // rzu
+ SNPOST(SNWAIT, 20002, 3, NULL); // czekaj
+ SNPOST(SNSETZ, 20700, 2, NULL); // skryj k
+ SNPOST(SNHIDE, 20007, 1, NULL); // skryj k
+ SNPOST(SNWAIT, 20002, 10, NULL); // czekaj
+ SNPOST(SNSEQ, 20007, 2, NULL); // lec†
+ SNPOST(SNHIDE, 20007, 0, NULL); // poka§
+ SNPOST(SNSOUND, 20007, 20001, NULL); // grzech
+ SNPOST(SNWAIT, 20007, -1, NULL); // koniec
+ SNPOST(SNGAME, 20002, 2, NULL); // again!
+ break;
+ case 20002 :
+ SNPOST(SNSAY, 20002, 20010, NULL); // zapro
+ SNPOST(SNWALK, 20005, -1, NULL); // do stol
+ SNPOST(SNWAIT, 1, -1, NULL); // stoi
+ SNPOST(SNCOVER, 1, 20101, NULL); // grasol
+ SNPOST(SNSEQ, 20101, 1, NULL); // rzu
+ SNPOST(SNWAIT, 20101, 5, NULL); // czekaj
+ SNPOST(SNSETZ, 20700, 2, NULL); // skryj k
+ SNPOST(SNHIDE, 20007, 1, NULL); // skryj k
+ SNPOST(SNWAIT, 20101, 15, NULL); // czekaj
+ SNPOST(SNSEQ, 20007, 1, NULL); // lec†
+ SNPOST(SNHIDE, 20007, 0, NULL); // poka§
+ SNPOST(SNSOUND, 20007, 20001, NULL); // grzech
+ SNPOST(SNWAIT, 20101, -1, NULL); // koniec
+ SNPOST(SNUNCOVER, 1, 20101, NULL); // SDS
+ SNPOST(SNGAME, 1, 2, NULL); // again!
+ break;
+ }
}
- }
- } break;
- //--------------------------------------------------------------------
- }
+ }
+ break;
+ }
}
-//-------------------------------------------------------------------------
-
-
-
-
-void ExpandSprite (SPRITE * spr)
-{
- if (spr) VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr));
+void ExpandSprite(SPRITE *spr) {
+ if (spr)
+ VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr));
}
-
-
-
-void ContractSprite (SPRITE * spr)
-{
- if (spr) VGA::SpareQ.Append(VGA::ShowQ.Remove(spr));
+void ContractSprite(SPRITE *spr) {
+ if (spr)
+ VGA::SpareQ.Append(VGA::ShowQ.Remove(spr));
}
-
-
-
-
-
-
-int FindPocket (SPRITE * spr)
-{
- int i;
- for (i = 0; i < POCKET_NX; i ++) if (Pocket[i] == spr) return i;
- return -1;
+int FindPocket(SPRITE *spr) {
+ for (int i = 0; i < POCKET_NX; i ++)
+ if (Pocket[i] == spr)
+ return i;
+ return -1;
}
-
-
-
-void SelectPocket (int n)
-{
- if (n < 0 || (PocLight.SeqPtr && PocPtr == n))
- {
- PocLight.Step(0);
- n = FindPocket(NULL);
- if (n >= 0) PocPtr = n;
- }
- else
- {
- if (Pocket[n] != NULL)
- {
- PocPtr = n;
- PocLight.Step(1);
+void SelectPocket(int n) {
+ if (n < 0 || (PocLight.SeqPtr && PocPtr == n)) {
+ PocLight.Step(0);
+ n = FindPocket(NULL);
+ if (n >= 0)
+ PocPtr = n;
+ } else {
+ if (Pocket[n] != NULL) {
+ PocPtr = n;
+ PocLight.Step(1);
+ }
}
- }
- PocLight.Goto(POCKET_X+PocPtr*POCKET_DX+POCKET_SX, POCKET_Y+POCKET_SY);
+ PocLight.Goto(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY);
}
-
-
-
-void PocFul (void)
-{
- Hero->Park();
- SNPOST(SNWAIT, -1, -1, Hero);
- SNPOST(SNSEQ, -1, POC_FUL, Hero);
- SNPOST(SNSOUND, -1, 2, Hero);
- SNPOST(SNWAIT, -1, -1, Hero);
- SNPOST(SNSAY, 1, POC_FUL_TEXT, Hero);
+void PocFul(void) {
+ Hero->Park();
+ SNPOST(SNWAIT, -1, -1, Hero);
+ SNPOST(SNSEQ, -1, POC_FUL, Hero);
+ SNPOST(SNSOUND, -1, 2, Hero);
+ SNPOST(SNWAIT, -1, -1, Hero);
+ SNPOST(SNSAY, 1, POC_FUL_TEXT, Hero);
}
-
-
-void Hide1 (SPRITE * spr)
-{
- SNPOST_(SNGHOST, -1, 0, spr->Ghost());
+void Hide1(SPRITE *spr) {
+ SNPOST_(SNGHOST, -1, 0, spr->Ghost());
}
-
-
-void SNGhost (BITMAP * bmp)
-{
- // TODO : Get x and y from M but not using segment / offset
- //bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M));
- bmp->M = NULL;
- delete bmp;
- warning("STUB: SNGhost");
+void SNGhost(BITMAP *bmp) {
+ // TODO : Get x and y from M but not using segment / offset
+ //bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M));
+ bmp->M = NULL;
+ delete bmp;
+ warning("STUB: SNGhost");
}
-
-
-void FeedSnail (SPRITE * spr, SNLIST snq)
-{
- if (spr) if (spr->Active())
- {
- uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr;
-
- if (ptr != NO_PTR)
- {
- SNAIL::COM * comtab = spr->SnList(snq);
- SNAIL::COM * c = comtab + ptr;
-
- if (FindPocket(NULL) < 0) // no empty pockets?
- {
- SNAIL::COM * p;
- for (p = c; p->Com != SNNEXT; p ++) // find KEEP command
- {
- if (p->Com == SNKEEP)
- {
- PocFul();
- return;
- }
- if (p->Ptr) break;
- }
- }
- while (true)
- {
- if (c->Com == SNTALK)
- {
- if ((Snail.TalkEnable = (c->Val != 0)) == false) KillText();
- }
- if (c->Com == SNNEXT)
- {
- SPRITE * s = (c->Ref < 0) ? spr : Locate(c->Ref);
- if (s)
- {
- uint8 * idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr;
- if (*idx != NO_PTR)
- {
- int v;
- switch (c->Val)
- {
- case -1 : v = c - comtab + 1; break;
- case -2 : v = c - comtab; break;
- case -3 : v = -1; break;
- default : v = c->Val; break;
- }
- if (v >= 0) *idx = v;
+void FeedSnail(SPRITE *spr, SNLIST snq) {
+ if (spr)
+ if (spr->Active()) {
+ uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr;
+
+ if (ptr != NO_PTR) {
+ SNAIL::COM *comtab = spr->SnList(snq);
+ SNAIL::COM *c = comtab + ptr;
+
+ if (FindPocket(NULL) < 0) { // no empty pockets?
+ SNAIL::COM *p;
+ for (p = c; p->Com != SNNEXT; p ++) { // find KEEP command
+ if (p->Com == SNKEEP) {
+ PocFul();
+ return;
+ }
+ if (p->Ptr)
+ break;
+ }
+ }
+ while (true) {
+ if (c->Com == SNTALK) {
+ if ((Snail.TalkEnable = (c->Val != 0)) == false)
+ KillText();
+ }
+ if (c->Com == SNNEXT) {
+ SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref);
+ if (s) {
+ uint8 *idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr;
+ if (*idx != NO_PTR) {
+ int v;
+ switch (c->Val) {
+ case -1 :
+ v = c - comtab + 1;
+ break;
+ case -2 :
+ v = c - comtab;
+ break;
+ case -3 :
+ v = -1;
+ break;
+ default :
+ v = c->Val;
+ break;
+ }
+ if (v >= 0)
+ *idx = v;
+ }
+ }
+ if (s == spr)
+ break;
+ }
+ if (c->Com == SNIF) {
+ SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref);
+ if (s) { // sprite extsts
+ if (! s->SeqTest(-1))
+ c = comtab + c->Val; // not parked
+ else
+ ++c;
+ } else
+ ++c;
+ } else {
+ SNPOST(c->Com, c->Ref, c->Val, spr);
+ if (c->Ptr)
+ break;
+ else
+ ++c;
+ }
+ }
}
- }
- if (s == spr) break;
- }
- if (c->Com == SNIF)
- {
- SPRITE * s = (c->Ref < 0) ? spr : Locate(c->Ref);
- if (s) // sprite extsts
- {
- if (! s->SeqTest(-1)) c = comtab + c->Val; // not parked
- else ++ c;
- }
- else ++ c;
- }
- else
- {
- SNPOST(c->Com, c->Ref, c->Val, spr);
- if (c->Ptr) break;
- else ++ c;
}
- }
- }
- }
}
-
-
-
-
-//--------------------------------------------------------------------------
-
-const char * SNAIL::ComTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL",
- "HIDE", "SAY", "INF", "TIME",
- "CAVE", "KILL", "RSEQ",
- "SEQ", "SEND", "SWAP", "KEEP", "GIVE",
- "IF", "GAME", "SETX0", "SETY0", "SLAVE",
- "SETXY", "RELX", "RELY", "RELZ",
- "SETX", "SETY", "SETZ", "TRANS", "PORT",
- "NEXT","NNEXT", "TNEXT", "RNNEXT", "RTNEXT",
- "RMNEAR", "RMTAKE", "FLAG", "SETREF",
- "BACKPT", "FLASH", "LIGHT",
- "SETHB", "SETVB",
- "WALK", "REACH", "COVER", "UNCOVER",
- "CLEAR", "TALK", "MOUSE",
- "SOUND", "COUNT",
- NULL };
-
-
-
-SNAIL::SNAIL (bool turbo)
-: Turbo(turbo), Busy(false), TextDelay(false),
- Pause(0), TalkEnable(true),
- Head(0), Tail(0), SNList(farnew(COM, 256))
-{
+const char *SNAIL::ComTxt[] = {
+ "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE",
+ "SAY", "INF", "TIME", "CAVE", "KILL",
+ "RSEQ", "SEQ", "SEND", "SWAP", "KEEP",
+ "GIVE", "IF", "GAME", "SETX0", "SETY0",
+ "SLAVE", "SETXY", "RELX", "RELY", "RELZ",
+ "SETX", "SETY", "SETZ", "TRANS", "PORT",
+ "NEXT", "NNEXT", "TNEXT", "RNNEXT", "RTNEXT",
+ "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT",
+ "FLASH", "LIGHT", "SETHB", "SETVB", "WALK",
+ "REACH", "COVER", "UNCOVER", "CLEAR", "TALK",
+ "MOUSE", "SOUND", "COUNT", NULL
+};
+
+
+SNAIL::SNAIL(bool turbo)
+ : Turbo(turbo), Busy(false), TextDelay(false),
+ Pause(0), TalkEnable(true),
+ Head(0), Tail(0), SNList(farnew(COM, 256)) {
}
-
-
-
-
-SNAIL::~SNAIL (void)
-{
- if (SNList) free(SNList);
+SNAIL::~SNAIL(void) {
+ if (SNList)
+ free(SNList);
}
-
-
-
-
-void SNAIL::AddCom (SNCOM com, int ref, int val, void * ptr)
-{
- _disable();
- COM * snc = &SNList[Head ++];
- snc->Com = com;
- snc->Ref = ref;
- snc->Val = val;
- snc->Ptr = ptr;
- if (com == SNCLEAR)
- {
- Tail = Head;
- KillText();
- Pause = 0;
- }
- _enable();
+void SNAIL::AddCom(SNCOM com, int ref, int val, void *ptr) {
+ _disable();
+ COM *snc = &SNList[Head ++];
+ snc->Com = com;
+ snc->Ref = ref;
+ snc->Val = val;
+ snc->Ptr = ptr;
+ if (com == SNCLEAR) {
+ Tail = Head;
+ KillText();
+ Pause = 0;
+ }
+ _enable();
}
-
-
-void SNAIL::InsCom (SNCOM com, int ref, int val, void * ptr)
-{
- COM * snc;
-
- _disable();
- if (Busy)
- {
- SNList[(Tail-1)&0xFF] = SNList[Tail];
- snc = &SNList[Tail];
- }
- else snc = &SNList[(Tail-1)&0xFF];
- -- Tail;
- snc->Com = com;
- snc->Ref = ref;
- snc->Val = val;
- snc->Ptr = ptr;
- if (com == SNCLEAR)
- {
- Tail = Head;
- KillText();
- Pause = 0;
- }
- _enable();
+void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) {
+ COM *snc;
+
+ _disable();
+ if (Busy) {
+ SNList[(Tail - 1) & 0xFF] = SNList[Tail];
+ snc = &SNList[Tail];
+ } else
+ snc = &SNList[(Tail - 1) & 0xFF];
+ --Tail;
+ snc->Com = com;
+ snc->Ref = ref;
+ snc->Val = val;
+ snc->Ptr = ptr;
+ if (com == SNCLEAR) {
+ Tail = Head;
+ KillText();
+ Pause = 0;
+ }
+ _enable();
}
-
-
-
-
-
-static void SNNNext(SPRITE * sprel, int p)
-{
- if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr = p;
+static void SNNNext(SPRITE *sprel, int p) {
+ if (sprel)
+ if (sprel->NearPtr != NO_PTR)
+ sprel->NearPtr = p;
}
-
-
-
-
-static void SNTNext(SPRITE * sprel, int p)
-{
- if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr = p;
+static void SNTNext(SPRITE *sprel, int p) {
+ if (sprel)
+ if (sprel->TakePtr != NO_PTR)
+ sprel->TakePtr = p;
}
-
-
-
-
-static void SNRNNext(SPRITE * sprel, int p)
-{
- if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr += p;
+static void SNRNNext(SPRITE *sprel, int p) {
+ if (sprel)
+ if (sprel->NearPtr != NO_PTR)
+ sprel->NearPtr += p;
}
-
-
-
-
-static void SNRTNext(SPRITE * sprel, int p)
-{
- if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr += p;
+static void SNRTNext(SPRITE *sprel, int p) {
+ if (sprel)
+ if (sprel->TakePtr != NO_PTR)
+ sprel->TakePtr += p;
}
-
-
-
-
-static void SNZTrim (SPRITE * spr)
-{
- if (spr) if (spr->Active())
- {
- bool en = HEART::Enable;
- SPRITE * s;
- HEART::Enable = false;
- s = (spr->Flags.Shad) ? spr->Prev : NULL;
- VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr));
- if (s)
- {
- s->Z = spr->Z;
- VGA::ShowQ.Insert(VGA::ShowQ.Remove(s), spr);
- }
- HEART::Enable = en;
- }
+static void SNZTrim(SPRITE *spr) {
+ if (spr)
+ if (spr->Active()) {
+ bool en = HEART::Enable;
+ SPRITE *s;
+ HEART::Enable = false;
+ s = (spr->Flags.Shad) ? spr->Prev : NULL;
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr));
+ if (s) {
+ s->Z = spr->Z;
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(s), spr);
+ }
+ HEART::Enable = en;
+ }
}
-
-
-
-
-static void SNHide (SPRITE * spr, int val)
-{
- if (spr)
- {
- spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide);
- if (spr->Flags.Shad) spr->Prev->Flags.Hide = spr->Flags.Hide;
- }
+static void SNHide(SPRITE *spr, int val) {
+ if (spr) {
+ spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide);
+ if (spr->Flags.Shad)
+ spr->Prev->Flags.Hide = spr->Flags.Hide;
+ }
}
-
-
-
-static void SNRmNear (SPRITE * spr)
-{
- if (spr) spr->NearPtr = NO_PTR;
+static void SNRmNear(SPRITE *spr) {
+ if (spr)
+ spr->NearPtr = NO_PTR;
}
-
-
-
-static void SNRmTake (SPRITE * spr)
-{
- if (spr) spr->TakePtr = NO_PTR;
+static void SNRmTake(SPRITE *spr) {
+ if (spr)
+ spr->TakePtr = NO_PTR;
}
-
-
-
-void SNSeq (SPRITE * spr, int val)
-{
- if (spr)
- {
- if (spr == Hero && val == 0) Hero->Park();
- else spr->Step(val);
- }
+void SNSeq(SPRITE *spr, int val) {
+ if (spr) {
+ if (spr == Hero && val == 0)
+ Hero->Park();
+ else
+ spr->Step(val);
+ }
}
-
-
-
-void SNRSeq (SPRITE * spr, int val)
-{
- if (spr) SNSeq(spr, spr->SeqPtr + val);
+void SNRSeq(SPRITE *spr, int val) {
+ if (spr)
+ SNSeq(spr, spr->SeqPtr + val);
}
-
-
-
-void SNSend (SPRITE * spr, int val)
-{
- if (spr)
- {
- int was = spr->Cave;
- bool was1 = (was == 0 || was == Now);
- bool val1 = (val == 0 || val == Now);
- spr->Cave = val;
- if (val1 != was1)
- {
- if (was1)
- {
- if (spr->Flags.Kept)
- {
- int n = FindPocket(spr);
- if (n >= 0) Pocket[n] = NULL;
+void SNSend(SPRITE *spr, int val) {
+ if (spr) {
+ int was = spr->Cave;
+ bool was1 = (was == 0 || was == Now);
+ bool val1 = (val == 0 || val == Now);
+ spr->Cave = val;
+ if (val1 != was1) {
+ if (was1) {
+ if (spr->Flags.Kept) {
+ int n = FindPocket(spr);
+ if (n >= 0)
+ Pocket[n] = NULL;
+ }
+ Hide1(spr);
+ ContractSprite(spr);
+ spr->Flags.Slav = false;
+ } else {
+ if (spr->Ref % 1000 == 0)
+ BITMAP::Pal = SysPal;
+ if (spr->Flags.Back)
+ spr->BackShow(true);
+ else
+ ExpandSprite(spr);
+ BITMAP::Pal = NULL;
+ }
}
- Hide1(spr);
- ContractSprite(spr);
- spr->Flags.Slav = false;
- }
- else
- {
- if (spr->Ref % 1000 == 0) BITMAP::Pal = SysPal;
- if (spr->Flags.Back) spr->BackShow(true);
- else ExpandSprite(spr);
- BITMAP::Pal = NULL;
- }
}
- }
}
-
-
-
-void SNSwap (SPRITE * spr, int xref)
-{
- SPRITE * xspr = Locate(xref);
- if (spr && xspr)
- {
- int was = spr->Cave;
- int xwas = xspr->Cave;
- bool was1 = (was == 0 || was == Now);
- bool xwas1 = (xwas == 0 || xwas == Now);
-
- Swap(spr->Cave, xspr->Cave);
- Swap(spr->X, xspr->X);
- Swap(spr->Y, xspr->Y);
- Swap(spr->Z, xspr->Z);
- if (spr->Flags.Kept)
- {
- int n = FindPocket(spr);
- if (n >= 0) Pocket[n] = xspr;
- xspr->Flags.Kept = true;
- xspr->Flags.Port = false;
- }
- if (xwas1 != was1)
- {
- if (was1)
- {
- Hide1(spr);
- ContractSprite(spr);
- }
- else ExpandSprite(spr);
- if (xwas1)
- {
- Hide1(xspr);
- ContractSprite(xspr);
- }
- else ExpandSprite(xspr);
+void SNSwap(SPRITE *spr, int xref) {
+ SPRITE *xspr = Locate(xref);
+ if (spr && xspr) {
+ int was = spr->Cave;
+ int xwas = xspr->Cave;
+ bool was1 = (was == 0 || was == Now);
+ bool xwas1 = (xwas == 0 || xwas == Now);
+
+ Swap(spr->Cave, xspr->Cave);
+ Swap(spr->X, xspr->X);
+ Swap(spr->Y, xspr->Y);
+ Swap(spr->Z, xspr->Z);
+ if (spr->Flags.Kept) {
+ int n = FindPocket(spr);
+ if (n >= 0)
+ Pocket[n] = xspr;
+ xspr->Flags.Kept = true;
+ xspr->Flags.Port = false;
+ }
+ if (xwas1 != was1) {
+ if (was1) {
+ Hide1(spr);
+ ContractSprite(spr);
+ } else
+ ExpandSprite(spr);
+ if (xwas1) {
+ Hide1(xspr);
+ ContractSprite(xspr);
+ } else
+ ExpandSprite(xspr);
+ }
}
- }
}
-
-
-
-void SNCover (SPRITE * spr, int xref)
-{
- SPRITE * xspr = Locate(xref);
- if (spr && xspr)
- {
- spr->Flags.Hide = true;
- xspr->Z = spr->Z;
- xspr->Cave = spr->Cave;
- xspr->Goto(spr->X, spr->Y);
- ExpandSprite(xspr);
- if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE)
- {
- VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr);
- spr->Flags.Shad = false;
+void SNCover(SPRITE *spr, int xref) {
+ SPRITE *xspr = Locate(xref);
+ if (spr && xspr) {
+ spr->Flags.Hide = true;
+ xspr->Z = spr->Z;
+ xspr->Cave = spr->Cave;
+ xspr->Goto(spr->X, spr->Y);
+ ExpandSprite(xspr);
+ if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE) {
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr);
+ spr->Flags.Shad = false;
+ }
+ FeedSnail(xspr, NEAR);
}
- FeedSnail(xspr, NEAR);
- }
}
-
-
-
-void SNUncover (SPRITE * spr, SPRITE * xspr)
-{
- if (spr && xspr)
- {
- spr->Flags.Hide = false;
- spr->Cave = xspr->Cave;
- spr->Goto(xspr->X, xspr->Y);
- if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE)
- {
- VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr);
- xspr->Flags.Shad = false;
+void SNUncover(SPRITE *spr, SPRITE *xspr) {
+ if (spr && xspr) {
+ spr->Flags.Hide = false;
+ spr->Cave = xspr->Cave;
+ spr->Goto(xspr->X, xspr->Y);
+ if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE) {
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr);
+ xspr->Flags.Shad = false;
+ }
+ spr->Z = xspr->Z;
+ SNSend(xspr, -1);
+ if (spr->Time == 0)
+ ++spr->Time;
}
- spr->Z = xspr->Z;
- SNSend(xspr, -1);
- if (spr->Time == 0) ++ spr->Time;
- }
}
-
-
-
-void SNSetX0 (int cav, int x0)
-{
- HeroXY[cav-1].X = x0;
+void SNSetX0(int cav, int x0) {
+ HeroXY[cav - 1].X = x0;
}
-
-
-
-void SNSetY0 (int cav, int y0)
-{
- HeroXY[cav-1].Y = y0;
+void SNSetY0(int cav, int y0) {
+ HeroXY[cav - 1].Y = y0;
}
-
-
-
-void SNSetXY (SPRITE * spr, uint16 xy)
-{
- if (spr)
- {
- spr->Goto(xy % SCR_WID, xy / SCR_WID);
- }
+void SNSetXY(SPRITE *spr, uint16 xy) {
+ if (spr)
+ spr->Goto(xy % SCR_WID, xy / SCR_WID);
}
-
-
-
-void SNRelX (SPRITE * spr, int x)
-{
- if (spr && Hero)
- {
- spr->Goto(Hero->X + x, spr->Y);
- }
+void SNRelX(SPRITE *spr, int x) {
+ if (spr && Hero)
+ spr->Goto(Hero->X + x, spr->Y);
}
-
-
-
-void SNRelY (SPRITE * spr, int y)
-{
- if (spr && Hero)
- {
- spr->Goto(spr->X, Hero->Y + y);
- }
+void SNRelY(SPRITE *spr, int y) {
+ if (spr && Hero)
+ spr->Goto(spr->X, Hero->Y + y);
}
-
-
-
-void SNRelZ (SPRITE * spr, int z)
-{
- if (spr && Hero)
- {
- spr->Z = Hero->Z + z;
- SNZTrim(spr);
- }
+void SNRelZ(SPRITE *spr, int z) {
+ if (spr && Hero) {
+ spr->Z = Hero->Z + z;
+ SNZTrim(spr);
+ }
}
-
-
-
-void SNSetX (SPRITE * spr, int x)
-{
- if (spr)
- {
- spr->Goto(x, spr->Y);
- }
+void SNSetX(SPRITE *spr, int x) {
+ if (spr)
+ spr->Goto(x, spr->Y);
}
-
-
-
-void SNSetY (SPRITE * spr, int y)
-{
- if (spr)
- {
- spr->Goto(spr->X, y);
- }
+void SNSetY(SPRITE *spr, int y) {
+ if (spr)
+ spr->Goto(spr->X, y);
}
-
-
-
-void SNSetZ (SPRITE * spr, int z)
-{
- if (spr)
- {
- spr->Z = z;
- //SNPOST_(SNZTRIM, -1, 0, spr);
- SNZTrim(spr);
- }
+void SNSetZ(SPRITE *spr, int z) {
+ if (spr) {
+ spr->Z = z;
+ //SNPOST_(SNZTRIM, -1, 0, spr);
+ SNZTrim(spr);
+ }
}
-
-
-
-void SNSlave (SPRITE * spr, int ref)
-{
- SPRITE * slv = Locate(ref);
- if (spr && slv)
- {
- if (spr->Active())
- {
- SNSend(slv, spr->Cave);
- slv->Flags.Slav = true;
- slv->Z = spr->Z;
- VGA::ShowQ.Insert(VGA::ShowQ.Remove(slv), spr->Next);
+void SNSlave(SPRITE *spr, int ref) {
+ SPRITE *slv = Locate(ref);
+ if (spr && slv) {
+ if (spr->Active()) {
+ SNSend(slv, spr->Cave);
+ slv->Flags.Slav = true;
+ slv->Z = spr->Z;
+ VGA::ShowQ.Insert(VGA::ShowQ.Remove(slv), spr->Next);
+ }
}
- }
}
-
-
-
-void SNTrans (SPRITE * spr, int trans)
-{
- if (spr)
- {
- spr->Flags.Tran = (trans < 0) ? !spr->Flags.Tran : (trans != 0);
- }
+void SNTrans(SPRITE *spr, int trans) {
+ if (spr)
+ spr->Flags.Tran = (trans < 0) ? !spr->Flags.Tran : (trans != 0);
}
-
-
-
-void SNPort (SPRITE * spr, int port)
-{
- if (spr)
- {
- spr->Flags.Port = (port < 0) ? !spr->Flags.Port : (port != 0);
- }
+void SNPort(SPRITE *spr, int port) {
+ if (spr)
+ spr->Flags.Port = (port < 0) ? !spr->Flags.Port : (port != 0);
}
-
-
-
-void SNKill (SPRITE * spr)
-{
- if (spr)
- {
- if (spr->Flags.Kept)
- {
- int n = FindPocket(spr);
- if (n >= 0) Pocket[n] = NULL;
- }
- SPRITE * nx = spr->Next;
- Hide1(spr);
- VGA::ShowQ.Remove(spr);
- MOUSE::ClrEvt(spr);
- if (spr->Flags.Kill) delete spr;
- else
- {
- spr->Cave = -1;
- VGA::SpareQ.Append(spr);
+void SNKill(SPRITE *spr) {
+ if (spr) {
+ if (spr->Flags.Kept) {
+ int n = FindPocket(spr);
+ if (n >= 0)
+ Pocket[n] = NULL;
+ }
+ SPRITE *nx = spr->Next;
+ Hide1(spr);
+ VGA::ShowQ.Remove(spr);
+ MOUSE::ClrEvt(spr);
+ if (spr->Flags.Kill)
+ delete spr;
+ else {
+ spr->Cave = -1;
+ VGA::SpareQ.Append(spr);
+ }
+ if (nx)
+ if (nx->Flags.Slav)
+ SNKill(nx);
}
- if (nx) if (nx->Flags.Slav) SNKill(nx);
- }
}
-
-
-
-static void SNSound (SPRITE * spr, int wav, int cnt)
-{
- if (SNDDrvInfo.DDEV)
- {
- if (wav == -1) Sound.Stop();
- else
- Sound.Play(Fx[wav], (spr) ? ((spr->X+spr->W/2)/(SCR_WID/16)) : 8, cnt);
- }
+static void SNSound(SPRITE *spr, int wav, int cnt) {
+ if (SNDDrvInfo.DDEV) {
+ if (wav == -1)
+ Sound.Stop();
+ else
+ Sound.Play(Fx[wav], (spr) ? ((spr->X + spr->W / 2) / (SCR_WID / 16)) : 8, cnt);
+ }
}
-
-
-
-void SNKeep (SPRITE * spr, int stp)
-{
- SelectPocket(-1);
- if (spr && ! spr->Flags.Kept && Pocket[PocPtr] == NULL)
- {
- SNSound(spr, 3, 1);
- Pocket[PocPtr] = spr;
- spr->Cave = 0;
- spr->Flags.Kept = true;
- spr->Goto(POCKET_X + POCKET_DX*PocPtr + POCKET_DX/2 - spr->W/2,
- POCKET_Y + POCKET_DY/2 - spr->H/2);
- if (stp >= 0) spr->Step(stp);
- }
- SelectPocket(-1);
+void SNKeep(SPRITE *spr, int stp) {
+ SelectPocket(-1);
+ if (spr && ! spr->Flags.Kept && Pocket[PocPtr] == NULL) {
+ SNSound(spr, 3, 1);
+ Pocket[PocPtr] = spr;
+ spr->Cave = 0;
+ spr->Flags.Kept = true;
+ spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->W / 2,
+ POCKET_Y + POCKET_DY / 2 - spr->H / 2);
+ if (stp >= 0)
+ spr->Step(stp);
+ }
+ SelectPocket(-1);
}
-
-
-
-
-void SNGive (SPRITE * spr, int stp)
-{
- if (spr)
- {
- int p = FindPocket(spr);
- if (p >= 0)
- {
- Pocket[p] = NULL;
- spr->Cave = Now;
- spr->Flags.Kept = false;
- if (stp >= 0) spr->Step(stp);
+void SNGive(SPRITE *spr, int stp) {
+ if (spr) {
+ int p = FindPocket(spr);
+ if (p >= 0) {
+ Pocket[p] = NULL;
+ spr->Cave = Now;
+ spr->Flags.Kept = false;
+ if (stp >= 0)
+ spr->Step(stp);
+ }
}
- }
- SelectPocket(-1);
+ SelectPocket(-1);
}
-
-
-static void SNBackPt (SPRITE * spr, int stp)
-{
- if (spr)
- {
- if (stp >= 0) spr->Step(stp);
- spr->BackShow(true);
- }
+static void SNBackPt(SPRITE *spr, int stp) {
+ if (spr) {
+ if (stp >= 0)
+ spr->Step(stp);
+ spr->BackShow(true);
+ }
}
-
-
-
-static void SNLevel (SPRITE * spr, int lev)
-{
- #ifdef DEMO
- static int maxcav[] = { CAVE_MAX };
- #else
- static int maxcav[] = { 1, 8, 16, 23, 24 };
- #endif
- while (Lev < lev)
- {
- SPRITE * spr;
- ++ Lev;
- spr = VGA::SpareQ.Locate(100+Lev);
- if (spr)
- {
- spr->BackShow(true);
- spr->Cave = 0;
+static void SNLevel(SPRITE *spr, int lev) {
+#ifdef DEMO
+ static int maxcav[] = { CAVE_MAX };
+#else
+ static int maxcav[] = { 1, 8, 16, 23, 24 };
+#endif
+ while (Lev < lev) {
+ SPRITE *spr;
+ ++Lev;
+ spr = VGA::SpareQ.Locate(100 + Lev);
+ if (spr) {
+ spr->BackShow(true);
+ spr->Cave = 0;
+ }
}
- }
- MaxCave = maxcav[Lev];
- if (spr) spr->Flags.Hide = false;
+ MaxCave = maxcav[Lev];
+ if (spr)
+ spr->Flags.Hide = false;
}
-
-
-
-
-static void SNFlag (int fn, bool v)
-{
- Flag[fn] = v;
+static void SNFlag(int fn, bool v) {
+ Flag[fn] = v;
}
-
-
-
-
-static void SNSetRef (SPRITE * spr, int nr)
-{
- if (spr)
- {
- spr->Ref = nr;
- }
+static void SNSetRef(SPRITE *spr, int nr) {
+ if (spr)
+ spr->Ref = nr;
}
-
-
-void SNFlash (bool on)
-{
- if (on)
- {
- DAC * pal = farnew(DAC, PAL_CNT);
- if (pal)
- {
- int i;
- memcpy(pal, SysPal, PAL_SIZ);
- for (i = 0; i < PAL_CNT; i ++)
- {
- register int c;
- c = pal[i].R << 1; pal[i].R = (c < 64) ? c : 63;
- c = pal[i].G << 1; pal[i].G = (c < 64) ? c : 63;
- c = pal[i].B << 1; pal[i].B = (c < 64) ? c : 63;
- }
- VGA::SetColors(pal, 64);
- }
- }
- else VGA::SetColors(SysPal, 64);
- Dark = false;
+void SNFlash(bool on) {
+ if (on) {
+ DAC *pal = farnew(DAC, PAL_CNT);
+ if (pal) {
+ memcpy(pal, SysPal, PAL_SIZ);
+ for (int i = 0; i < PAL_CNT; i ++) {
+ register int c;
+ c = pal[i].R << 1;
+ pal[i].R = (c < 64) ? c : 63;
+ c = pal[i].G << 1;
+ pal[i].G = (c < 64) ? c : 63;
+ c = pal[i].B << 1;
+ pal[i].B = (c < 64) ? c : 63;
+ }
+ VGA::SetColors(pal, 64);
+ }
+ } else
+ VGA::SetColors(SysPal, 64);
+ Dark = false;
}
-
-
-
-static void SNLight (bool in)
-{
- if (in) VGA::Sunrise(SysPal);
- else VGA::Sunset();
- Dark = ! in;
+static void SNLight(bool in) {
+ if (in)
+ VGA::Sunrise(SysPal);
+ else
+ VGA::Sunset();
+ Dark = ! in;
}
-
-
-
-static void SNBarrier (int cav, int bar, bool horz)
-{
- ((uint8 *) (Barriers + ((cav > 0) ? cav : Now)))[horz] = bar;
+static void SNBarrier(int cav, int bar, bool horz) {
+ ((uint8 *)(Barriers + ((cav > 0) ? cav : Now)))[horz] = bar;
}
-
-
-
-static void SNWalk (SPRITE * spr, int x, int y)
-{
- if (Hero)
- {
- if (spr && y < 0) Hero->FindWay(spr);
- else Hero->FindWay(XZ(x, y));
- }
+static void SNWalk(SPRITE *spr, int x, int y) {
+ if (Hero) {
+ if (spr && y < 0)
+ Hero->FindWay(spr);
+ else
+ Hero->FindWay(XZ(x, y));
+ }
}
-
-
-
-static void SNReach (SPRITE * spr, int mode)
-{
- if (Hero) Hero->Reach(spr, mode);
+static void SNReach(SPRITE *spr, int mode) {
+ if (Hero)
+ Hero->Reach(spr, mode);
}
-
-
-
-
-static void SNMouse (bool on)
-{
- if (on) Mouse.On();
- else Mouse.Off();
+static void SNMouse(bool on) {
+ if (on)
+ Mouse.On();
+ else
+ Mouse.Off();
}
+void SNAIL::RunCom(void) {
+ static int count = 1;
+ extern void SwitchCave(int);
+ if (! Busy) {
+ Busy = true;
+ uint8 tmphea = Head;
+ while (Tail != tmphea) {
+ COM *snc = &SNList[Tail];
+
+ if (! Turbo) { // only for the slower one
+ if (Pause)
+ break;
+ else {
+ if (TextDelay) {
+ KillText();
+ TextDelay = false;
+ }
+ }
+ if (Talk && snc->Com != SNPAUSE)
+ break;
+ }
-
-
-
-void SNAIL::RunCom (void)
-{
- static int count = 1;
- extern void SwitchCave(int);
- if (! Busy)
- {
- Busy = true;
- uint8 tmphea = Head;
- while (Tail != tmphea)
- {
- COM * snc = &SNList[Tail];
-
- if (! Turbo) // only for the slower one
- {
- if (Pause) break;
- else
- {
- if (TextDelay)
- {
- KillText();
- TextDelay = false;
- }
- }
- if (Talk && snc->Com != SNPAUSE) break;
- }
-
- SPRITE * sprel = ((snc->Ref >= 0) ? Locate(snc->Ref)
- : ((SPRITE *) snc->Ptr));
- switch (snc->Com)
- {
- case SNLABEL : break;
- case SNPAUSE : HEART::SetXTimer(&Pause, snc->Val);
- if (Talk) TextDelay = true; break;
- case SNWAIT : if (sprel)
- {
- if (sprel->SeqTest(snc->Val) &&
- (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0))
- {
- HEART::SetXTimer(&Pause, sprel->Time);
- }
- else goto xit;
- }
+ SPRITE *sprel = ((snc->Ref >= 0) ? Locate(snc->Ref) : ((SPRITE *) snc->Ptr));
+ switch (snc->Com) {
+ case SNLABEL :
+ break;
+ case SNPAUSE :
+ HEART::SetXTimer(&Pause, snc->Val);
+ if (Talk)
+ TextDelay = true;
+ break;
+ case SNWAIT :
+ if (sprel) {
+ if (sprel->SeqTest(snc->Val) &&
+ (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) {
+ HEART::SetXTimer(&Pause, sprel->Time);
+ } else
+ goto xit;
+ }
+ break;
+ case SNLEVEL :
+ SNLevel(sprel, snc->Val);
+ break;
+ case SNHIDE :
+ SNHide(sprel, snc->Val);
+ break;
+ case SNSAY :
+ if (sprel && TalkEnable) {
+ if (sprel == Hero && sprel->SeqTest(-1))
+ sprel->Step(HTALK);
+ Say(Text[snc->Val], sprel);
+ SYSTEM::FunDel = HEROFUN0;
+ }
+ break;
+ case SNINF :
+ if (TalkEnable) {
+ Inf(Text[snc->Val]);
+ SYSTEM::FunDel = HEROFUN0;
+ }
+ break;
+ case SNTIME :
+ if (sprel && TalkEnable) {
+ if (sprel == Hero && sprel->SeqTest(-1))
+ sprel->Step(HTALK);
+ SayTime(sprel);
+ }
+ break;
+ case SNCAVE :
+ SwitchCave(snc->Val);
+ break;
+ case SNKILL :
+ SNKill(sprel);
+ break;
+ case SNSEQ :
+ SNSeq(sprel, snc->Val);
+ break;
+ case SNRSEQ :
+ SNRSeq(sprel, snc->Val);
+ break;
+ case SNSEND :
+ SNSend(sprel, snc->Val);
+ break;
+ case SNSWAP :
+ SNSwap(sprel, snc->Val);
+ break;
+ case SNCOVER :
+ SNCover(sprel, snc->Val);
+ break;
+ case SNUNCOVER :
+ SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val) : ((SPRITE *) snc->Ptr));
+ break;
+ case SNKEEP :
+ SNKeep(sprel, snc->Val);
+ break;
+ case SNGIVE :
+ SNGive(sprel, snc->Val);
+ break;
+ case SNGAME :
+ SNGame(sprel, snc->Val);
+ break;
+ case SNSETX0 :
+ SNSetX0(snc->Ref, snc->Val);
+ break;
+ case SNSETY0 :
+ SNSetY0(snc->Ref, snc->Val);
break;
- case SNLEVEL : SNLevel(sprel, snc->Val); break;
- case SNHIDE : SNHide(sprel, snc->Val); break;
- case SNSAY : if (sprel && TalkEnable)
- {
- if (sprel == Hero && sprel->SeqTest(-1))
- sprel->Step(HTALK);
- Say(Text[snc->Val], sprel);
- SYSTEM::FunDel = HEROFUN0;
- }
+ case SNSETXY :
+ SNSetXY(sprel, snc->Val);
break;
- case SNINF : if (TalkEnable)
- {
- Inf(Text[snc->Val]);
- SYSTEM::FunDel = HEROFUN0;
- }
+ case SNRELX :
+ SNRelX(sprel, snc->Val);
break;
- case SNTIME : if (sprel && TalkEnable)
- {
- if (sprel == Hero && sprel->SeqTest(-1))
- sprel->Step(HTALK);
- SayTime(sprel);
- }
+ case SNRELY :
+ SNRelY(sprel, snc->Val);
break;
- case SNCAVE : SwitchCave(snc->Val); break;
- case SNKILL : SNKill(sprel); break;
- case SNSEQ : SNSeq(sprel, snc->Val); break;
- case SNRSEQ : SNRSeq(sprel, snc->Val); break;
- case SNSEND : SNSend(sprel, snc->Val); break;
- case SNSWAP : SNSwap(sprel, snc->Val); break;
- case SNCOVER : SNCover(sprel, snc->Val); break;
- case SNUNCOVER : SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val)
- : ((SPRITE *) snc->Ptr));
+ case SNRELZ :
+ SNRelZ(sprel, snc->Val);
break;
- case SNKEEP : SNKeep(sprel, snc->Val); break;
- case SNGIVE : SNGive(sprel, snc->Val); break;
- case SNGAME : SNGame(sprel, snc->Val); break;
- case SNSETX0 : SNSetX0(snc->Ref, snc->Val); break;
- case SNSETY0 : SNSetY0(snc->Ref, snc->Val); break;
- case SNSETXY : SNSetXY(sprel, snc->Val); break;
- case SNRELX : SNRelX(sprel, snc->Val); break;
- case SNRELY : SNRelY(sprel, snc->Val); break;
- case SNRELZ : SNRelZ(sprel, snc->Val); break;
- case SNSETX : SNSetX(sprel, snc->Val); break;
- case SNSETY : SNSetY(sprel, snc->Val); break;
- case SNSETZ : SNSetZ(sprel, snc->Val); break;
- case SNSLAVE : SNSlave(sprel, snc->Val); break;
- case SNTRANS : SNTrans(sprel, snc->Val); break;
- case SNPORT : SNPort(sprel, snc->Val); break;
- case SNNEXT : break;
- case SNIF : break;
- case SNTALK : break;
- case SNMOUSE : SNMouse(snc->Val != 0); break;
- case SNNNEXT : SNNNext(sprel, snc->Val); break;
- case SNTNEXT : SNTNext(sprel, snc->Val); break;
- case SNRNNEXT : SNRNNext(sprel, snc->Val); break;
- case SNRTNEXT : SNRTNext(sprel, snc->Val); break;
- case SNRMNEAR : SNRmNear(sprel); break;
- case SNRMTAKE : SNRmTake(sprel); break;
- case SNFLAG : SNFlag(snc->Ref & 3, snc->Val != 0); break;
- case SNSETREF : SNSetRef(sprel, snc->Val); break;
- case SNBACKPT : SNBackPt(sprel, snc->Val); break;
- case SNFLASH : SNFlash(snc->Val != 0); break;
- case SNLIGHT : SNLight(snc->Val != 0); break;
- case SNSETHB : SNBarrier(snc->Ref, snc->Val, true); break;
- case SNSETVB : SNBarrier(snc->Ref, snc->Val, false); break;
- case SNWALK : SNWalk(sprel, snc->Ref, snc->Val); break;
- case SNREACH : SNReach(sprel, snc->Val); break;
- case SNSOUND : SNSound(sprel, snc->Val, count); count = 1; break;
- case SNCOUNT : count = snc->Val; break;
-
- // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST
- //case SNEXEC : ((void(*)(int)) (snc->Ptr))(snc->Val); break;
- case SNEXEC : warning("STUB: SNEXEC code");
- case SNSTEP : sprel->Step(); break;
- case SNZTRIM : SNZTrim(sprel); break;
- case SNGHOST : SNGhost((BITMAP *) snc->Ptr); break;
- }
- ++ Tail;
- if (! Turbo) break;
+ case SNSETX :
+ SNSetX(sprel, snc->Val);
+ break;
+ case SNSETY :
+ SNSetY(sprel, snc->Val);
+ break;
+ case SNSETZ :
+ SNSetZ(sprel, snc->Val);
+ break;
+ case SNSLAVE :
+ SNSlave(sprel, snc->Val);
+ break;
+ case SNTRANS :
+ SNTrans(sprel, snc->Val);
+ break;
+ case SNPORT :
+ SNPort(sprel, snc->Val);
+ break;
+ case SNNEXT :
+ break;
+ case SNIF :
+ break;
+ case SNTALK :
+ break;
+ case SNMOUSE :
+ SNMouse(snc->Val != 0);
+ break;
+ case SNNNEXT :
+ SNNNext(sprel, snc->Val);
+ break;
+ case SNTNEXT :
+ SNTNext(sprel, snc->Val);
+ break;
+ case SNRNNEXT :
+ SNRNNext(sprel, snc->Val);
+ break;
+ case SNRTNEXT :
+ SNRTNext(sprel, snc->Val);
+ break;
+ case SNRMNEAR :
+ SNRmNear(sprel);
+ break;
+ case SNRMTAKE :
+ SNRmTake(sprel);
+ break;
+ case SNFLAG :
+ SNFlag(snc->Ref & 3, snc->Val != 0);
+ break;
+ case SNSETREF :
+ SNSetRef(sprel, snc->Val);
+ break;
+ case SNBACKPT :
+ SNBackPt(sprel, snc->Val);
+ break;
+ case SNFLASH :
+ SNFlash(snc->Val != 0);
+ break;
+ case SNLIGHT :
+ SNLight(snc->Val != 0);
+ break;
+ case SNSETHB :
+ SNBarrier(snc->Ref, snc->Val, true);
+ break;
+ case SNSETVB :
+ SNBarrier(snc->Ref, snc->Val, false);
+ break;
+ case SNWALK :
+ SNWalk(sprel, snc->Ref, snc->Val);
+ break;
+ case SNREACH :
+ SNReach(sprel, snc->Val);
+ break;
+ case SNSOUND :
+ SNSound(sprel, snc->Val, count);
+ count = 1;
+ break;
+ case SNCOUNT :
+ count = snc->Val;
+ break;
+ case SNEXEC :
+ // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST
+ // ((void(*)(int)) (snc->Ptr))(snc->Val); break;
+ warning("STUB: SNEXEC code");
+ case SNSTEP :
+ sprel->Step();
+ break;
+ case SNZTRIM :
+ SNZTrim(sprel);
+ break;
+ case SNGHOST :
+ SNGhost((BITMAP *) snc->Ptr);
+ break;
+ }
+ ++Tail;
+ if (!Turbo)
+ break;
+ }
+xit:
+ Busy = false;
}
- xit:
- Busy = false;
- }
}
-
-
-
-bool SNAIL::Idle (void)
-{
- return (Head == Tail);
+bool SNAIL::Idle(void) {
+ return (Head == Tail);
}
} // End of namespace CGE
diff --git a/engines/cge/snail.h b/engines/cge/snail.h
index 88bb5f09dd..f9b969a554 100644
--- a/engines/cge/snail.h
+++ b/engines/cge/snail.h
@@ -25,96 +25,98 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __SNAIL__
-#define __SNAIL__
+#ifndef __SNAIL__
+#define __SNAIL__
-#include "cge/jbw.h"
+#include "cge/jbw.h"
namespace CGE {
-#define POCKET_X 174
-#define POCKET_Y 176
-#define POCKET_DX 18
-#define POCKET_DY 22
-#define POCKET_NX 8
-#define POCKET_NY 1
+#define POCKET_X 174
+#define POCKET_Y 176
+#define POCKET_DX 18
+#define POCKET_DY 22
+#define POCKET_NX 8
+#define POCKET_NY 1
-#define POCKET_SX 8
-#define POCKET_SY 3
+#define POCKET_SX 8
+#define POCKET_SY 3
-#define SNINSERT(c,r,v,p) Snail.InsCom(c,r,v,p)
-#define SNPOST(c,r,v,p) Snail.AddCom(c,r,v,p)
-#define SNPOST_(c,r,v,p) Snail_.AddCom(c,r,v,p)
+#define SNINSERT(c,r,v,p) Snail.InsCom(c,r,v,p)
+#define SNPOST(c,r,v,p) Snail.AddCom(c,r,v,p)
+#define SNPOST_(c,r,v,p) Snail_.AddCom(c,r,v,p)
+typedef struct {
+ uint8 Horz, Vert;
+} BAR;
-typedef struct { uint8 Horz, Vert; } BAR;
+struct SCB {
+ uint8 *Ptr;
+ uint16 Siz;
+ SCB *Nxt;
+};
-struct SCB
-{
- uint8 * Ptr;
- uint16 Siz;
- SCB * Nxt;
+enum SNCOM {
+ SNLABEL, SNPAUSE, SNWAIT, SNLEVEL, SNHIDE,
+ SNSAY, SNINF, SNTIME, SNCAVE, SNKILL,
+ SNRSEQ, SNSEQ, SNSEND, SNSWAP, SNKEEP,
+ SNGIVE, SNIF, SNGAME, SNSETX0, SNSETY0,
+ SNSLAVE, SNSETXY, SNRELX, SNRELY, SNRELZ,
+ SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT,
+ SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT,
+ SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, SNBACKPT,
+ SNFLASH, SNLIGHT, SNSETHB, SNSETVB, SNWALK,
+ SNREACH, SNCOVER, SNUNCOVER, SNCLEAR, SNTALK,
+ SNMOUSE, SNSOUND, SNCOUNT, SNEXEC, SNSTEP,
+ SNZTRIM, SNGHOST
};
+enum SNLIST { NEAR, TAKE };
-
-enum SNCOM { SNLABEL, SNPAUSE, SNWAIT, SNLEVEL,
- SNHIDE, SNSAY, SNINF, SNTIME,
- SNCAVE, SNKILL, SNRSEQ,
- SNSEQ, SNSEND, SNSWAP, SNKEEP, SNGIVE,
- SNIF, SNGAME, SNSETX0, SNSETY0, SNSLAVE,
- SNSETXY, SNRELX, SNRELY, SNRELZ,
- SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT,
- SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT,
- SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF,
- SNBACKPT, SNFLASH, SNLIGHT,
- SNSETHB, SNSETVB,
- SNWALK, SNREACH, SNCOVER, SNUNCOVER,
- SNCLEAR, SNTALK, SNMOUSE,
- SNSOUND, SNCOUNT,
- SNEXEC, SNSTEP, SNZTRIM,
- SNGHOST
- };
-
-enum SNLIST { NEAR, TAKE };
-
-class SNAIL
-{
+class SNAIL {
public:
- struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } * SNList;
- uint8 Head, Tail;
- bool Turbo, Busy, TextDelay;
- uint16 Pause;
- static const char * ComTxt[];
- bool TalkEnable;
- SNAIL (bool turbo = false);
- ~SNAIL (void);
- void RunCom (void);
- void AddCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL);
- void InsCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL);
- bool Idle (void);
+ struct COM {
+ SNCOM Com;
+ int Ref;
+ int Val;
+ void *Ptr;
+ } *SNList;
+ uint8 Head, Tail;
+ bool Turbo, Busy, TextDelay;
+ uint16 Pause;
+ static const char *ComTxt[];
+ bool TalkEnable;
+ SNAIL(bool turbo = false);
+ ~SNAIL(void);
+ void RunCom(void);
+ void AddCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL);
+ void InsCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL);
+ bool Idle(void);
};
-void SelectPocket (int n);
-void PocFul (void);
-
-
-extern SCB Scb;
-extern bool Flag[4];
-extern bool Game;
-extern bool Dark;
-extern SNAIL Snail;
-extern SNAIL Snail_;
-extern int Now;
-extern int Lev;
-extern int MaxCave;
-extern int PocPtr;
-extern BAR Barriers[];
-extern struct HXY { int X; int Y; } HeroXY[];
+void SelectPocket(int n);
+void PocFul(void);
+
+
+extern SCB Scb;
+extern bool Flag[4];
+extern bool Game;
+extern bool Dark;
+extern SNAIL Snail;
+extern SNAIL Snail_;
+extern int Now;
+extern int Lev;
+extern int MaxCave;
+extern int PocPtr;
+extern BAR Barriers[];
+extern struct HXY {
+ int X;
+ int Y;
+} HeroXY[];
} // End of namespace CGE
diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h
index fc6c1aa143..3d1658e1e0 100644
--- a/engines/cge/snddrv.h
+++ b/engines/cge/snddrv.h
@@ -44,50 +44,45 @@ namespace CGE {
// ******************************************************
// available devices
-enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode
- DEV_QUIET, // disable sound
- DEV_SB, // sb/pro/16/awe32
- DEV_GUS, // gus/max
- DEV_GM // general midi
+enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode
+ DEV_QUIET, // disable sound
+ DEV_SB, // sb/pro/16/awe32
+ DEV_GUS, // gus/max
+ DEV_GM // general midi
};
-#define SERR_OK 0 // no error
-#define SERR_INITFAIL 1 // couldn't initialize
-#define SERR_BADDDEV 128 // bad device
+#define SERR_OK 0 // no error
+#define SERR_INITFAIL 1 // couldn't initialize
+#define SERR_BADDDEV 128 // bad device
// driver info
-struct DRVINFO
-{
- DEV_TYPE DDEV; // digi device
- DEV_TYPE MDEV; // midi device
- uint16 DBASE; // digi base port
- uint16 DDMA; // digi dma no
- uint16 DIRQ; // digi irq no
- uint16 MBASE; // midi base port
- union
- {
- struct
- {
- uint16 DR : 4;
- uint16 DL : 4;
- uint16 MR : 4;
- uint16 ML : 4;
- } VOL4;
- struct
- {
- uint8 D; // digi volume
- uint8 M; // midi volume
- } VOL2;
- };
+struct DRVINFO {
+ DEV_TYPE DDEV; // digi device
+ DEV_TYPE MDEV; // midi device
+ uint16 DBASE; // digi base port
+ uint16 DDMA; // digi dma no
+ uint16 DIRQ; // digi irq no
+ uint16 MBASE; // midi base port
+ union {
+ struct {
+ uint16 DR : 4;
+ uint16 DL : 4;
+ uint16 MR : 4;
+ uint16 ML : 4;
+ } VOL4;
+ struct {
+ uint8 D; // digi volume
+ uint8 M; // midi volume
+ } VOL2;
+ };
};
// sample info
-struct SMPINFO
-{
- uint8 * saddr; // address
- uint16 slen; // length
- uint16 span; // left/right pan (0-15)
- int sflag; // flag
+struct SMPINFO {
+ uint8 *saddr; // address
+ uint16 slen; // length
+ uint16 span; // left/right pan (0-15)
+ int sflag; // flag
};
// ******************************************************
@@ -106,31 +101,30 @@ extern uint16 MIDIEndFlag;
// * Driver Code *
// ******************************************************
// Init Digi Device
-EC void SNDInit (void);
+EC void SNDInit(void);
// Close Digi Device
-EC void SNDDone (void);
+EC void SNDDone(void);
// Set Volume
-EC void SNDSetVolume (void);
+EC void SNDSetVolume(void);
// Start Digi
-EC void SNDDigiStart (SMPINFO *PSmpInfo);
+EC void SNDDigiStart(SMPINFO *PSmpInfo);
// Stop Digi
-EC void SNDDigiStop (SMPINFO *PSmpInfo);
+EC void SNDDigiStop(SMPINFO *PSmpInfo);
// Start MIDI File
-EC void SNDMIDIStart (uint8 *MIDFile);
+EC void SNDMIDIStart(uint8 *MIDFile);
// Stop MIDI File
-EC void SNDMIDIStop (void);
+EC void SNDMIDIStop(void);
// Play MIDI File (to be called while interrupting)
// WARNING: Uses ALL registers!
-EC void SNDMIDIPlay (void);
+EC void SNDMIDIPlay(void);
} // End of namespace CGE
-
#endif
diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp
index d40789beee..397684849a 100644
--- a/engines/cge/sound.cpp
+++ b/engines/cge/sound.cpp
@@ -25,292 +25,204 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/general.h"
-#include "cge/startup.h"
-#include "cge/sound.h"
-
-#include "cge/text.h"
-#include "cge/cfile.h"
-#include "cge/vol.h"
+#include "cge/general.h"
+#include "cge/startup.h"
+#include "cge/sound.h"
+#include "cge/text.h"
+#include "cge/cfile.h"
+#include "cge/vol.h"
namespace CGE {
- bool Music = true;
- FX Fx = 16; // must precede SOUND!!
- SOUND Sound;
-
+bool Music = true;
+FX Fx = 16; // must precede SOUND!!
+SOUND Sound;
-SOUND::SOUND (void)
-{
- if (STARTUP::SoundOk) Open();
+SOUND::SOUND(void) {
+ if (STARTUP::SoundOk)
+ Open();
}
-
-
-SOUND::~SOUND (void)
-{
- Close();
+SOUND::~SOUND(void) {
+ Close();
}
-
-
-
-void SOUND::Close (void)
-{
- KillMIDI();
- SNDDone();
+void SOUND::Close(void) {
+ KillMIDI();
+ SNDDone();
}
-
-
-
-void SOUND::Open (void)
-{
- SNDInit();
- Play(Fx[30000], 8);
+void SOUND::Open(void) {
+ SNDInit();
+ Play(Fx[30000], 8);
}
-
-
-void SOUND::Play (DATACK * wav, int pan, int cnt)
-{
- if (wav)
- {
- Stop();
- smpinf.saddr = (uint8 *) &*(wav->EAddr());
- smpinf.slen = (uint16)wav->Size();
- smpinf.span = pan;
- smpinf.sflag = cnt;
- SNDDigiStart(&smpinf);
- }
+void SOUND::Play(DATACK *wav, int pan, int cnt) {
+ if (wav) {
+ Stop();
+ smpinf.saddr = (uint8 *) &*(wav->EAddr());
+ smpinf.slen = (uint16)wav->Size();
+ smpinf.span = pan;
+ smpinf.sflag = cnt;
+ SNDDigiStart(&smpinf);
+ }
}
-
-
-void SOUND::Stop (void)
-{
- SNDDigiStop(&smpinf);
+void SOUND::Stop(void) {
+ SNDDigiStop(&smpinf);
}
-//------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-FX::FX (int size)
-: Emm(0L), Current(NULL)
-{
- Cache = new HAN[size];
- for (Size = 0; Size < size; Size ++)
- {
- Cache[Size].Ref = 0;
- Cache[Size].Wav = NULL;
- }
+FX::FX(int size) : Emm(0L), Current(NULL) {
+ Cache = new HAN[size];
+ for (Size = 0; Size < size; Size ++) {
+ Cache[Size].Ref = 0;
+ Cache[Size].Wav = NULL;
+ }
}
-
-
-FX::~FX (void)
-{
- Clear();
- delete[] Cache;
+FX::~FX(void) {
+ Clear();
+ delete[] Cache;
}
-
-
-
-void FX::Clear (void)
-{
- HAN * p, * q;
- for (p = Cache, q = p+Size; p < q; p ++)
- {
- if (p->Ref)
- {
- p->Ref = 0;
- delete p->Wav;
- p->Wav = NULL;
+void FX::Clear(void) {
+ HAN *p, * q;
+ for (p = Cache, q = p + Size; p < q; p ++) {
+ if (p->Ref) {
+ p->Ref = 0;
+ delete p->Wav;
+ p->Wav = NULL;
+ }
}
- }
- Emm.Release();
- Current = NULL;
+ Emm.Release();
+ Current = NULL;
}
-
-
-
-int FX::Find (int ref)
-{
- HAN * p, * q;
- int i = 0;
- for (p = Cache, q = p+Size; p < q; p ++)
- {
- if (p->Ref == ref) break;
- else ++ i;
- }
- return i;
+int FX::Find(int ref) {
+ HAN *p, * q;
+ int i = 0;
+ for (p = Cache, q = p + Size; p < q; p ++) {
+ if (p->Ref == ref)
+ break;
+ else
+ ++i;
+ }
+ return i;
}
+void FX::Preload(int ref0) {
+ HAN *CacheLim = Cache + Size;
+ int ref;
-
-
-
-
-
-
-
-
-void FX::Preload (int ref0)
-{
- HAN * CacheLim = Cache + Size;
- int ref;
-
- for (ref = ref0; ref < ref0+10; ref ++)
- {
- static char fname[] = "FX00000.WAV";
- wtom(ref, fname+2, 10, 5);
- INI_FILE file = INI_FILE(fname);
- DATACK * wav = LoadWave(&file, &Emm);
- if (wav)
- {
- HAN * p = &Cache[Find(0)];
- if (p >= CacheLim) break;
- p->Wav = wav;
- p->Ref = ref;
+ for (ref = ref0; ref < ref0 + 10; ref ++) {
+ static char fname[] = "FX00000.WAV";
+ wtom(ref, fname + 2, 10, 5);
+ INI_FILE file = INI_FILE(fname);
+ DATACK *wav = LoadWave(&file, &Emm);
+ if (wav) {
+ HAN *p = &Cache[Find(0)];
+ if (p >= CacheLim)
+ break;
+ p->Wav = wav;
+ p->Ref = ref;
+ }
}
- }
}
+DATACK *FX::Load(int idx, int ref) {
+ static char fname[] = "FX00000.WAV";
+ wtom(ref, fname + 2, 10, 5);
-
-
-DATACK * FX::Load (int idx, int ref)
-{
- static char fname[] = "FX00000.WAV";
- wtom(ref, fname+2, 10, 5);
-
- INI_FILE file = INI_FILE(fname);
- DATACK * wav = LoadWave(&file, &Emm);
- if (wav)
- {
- HAN * p = &Cache[idx];
- p->Wav = wav;
- p->Ref = ref;
- }
- return wav;
+ INI_FILE file = INI_FILE(fname);
+ DATACK *wav = LoadWave(&file, &Emm);
+ if (wav) {
+ HAN *p = &Cache[idx];
+ p->Wav = wav;
+ p->Ref = ref;
+ }
+ return wav;
}
-
-
-DATACK * FX::operator [] (int ref)
-{
- int i;
- if ((i = Find(ref)) < Size) Current = Cache[i].Wav;
- else
- {
- if ((i = Find(0)) >= Size)
- {
- Clear();
- i = 0;
+DATACK *FX::operator [](int ref) {
+ int i;
+ if ((i = Find(ref)) < Size)
+ Current = Cache[i].Wav;
+ else {
+ if ((i = Find(0)) >= Size) {
+ Clear();
+ i = 0;
+ }
+ Current = Load(i, ref);
}
- Current = Load(i, ref);
- }
- return Current;
+ return Current;
}
+static uint8 *midi = NULL;
-//-------------------------------------------------------------------------
-
-
-static uint8 * midi = NULL;
-
-
-
-void KillMIDI (void)
-{
- SNDMIDIStop();
- if (midi)
- {
- delete[] midi;
- midi = NULL;
- }
+void KillMIDI(void) {
+ SNDMIDIStop();
+ if (midi) {
+ delete[] midi;
+ midi = NULL;
+ }
}
-
-
-
-void LoadMIDI (int ref)
-{
- static char fn[] = "00.MID";
- wtom(ref, fn, 10, 2);
- if (INI_FILE::Exist(fn))
- {
- KillMIDI();
- INI_FILE mid = fn;
- if (mid.Error == 0)
- {
- uint16 siz = (uint16) mid.Size();
- midi = new uint8[siz];
- if (midi)
- {
- mid.Read(midi, siz);
- if (mid.Error) KillMIDI();
- else
- {
- SNDMIDIStart(midi);
+void LoadMIDI(int ref) {
+ static char fn[] = "00.MID";
+ wtom(ref, fn, 10, 2);
+ if (INI_FILE::Exist(fn)) {
+ KillMIDI();
+ INI_FILE mid = fn;
+ if (mid.Error == 0) {
+ uint16 siz = (uint16) mid.Size();
+ midi = new uint8[siz];
+ if (midi) {
+ mid.Read(midi, siz);
+ if (mid.Error)
+ KillMIDI();
+ else
+ SNDMIDIStart(midi);
+ }
}
- }
}
- }
}
+EC void *Patch(int pat) {
+ void *p = NULL;
+ static char fn[] = "PATCH000.SND";
-
-
-
-EC void * Patch (int pat)
-{
- void * p = NULL;
- static char fn[] = "PATCH000.SND";
-
- wtom(pat, fn+5, 10, 3);
- INI_FILE snd = fn;
- if (! snd.Error)
- {
- uint16 siz = (uint16) snd.Size();
- p = (uint8 *) malloc(siz);
- if (p)
- {
- snd.Read(p, siz);
- if (snd.Error)
- {
- free(p);
- p = NULL;
- }
+ wtom(pat, fn + 5, 10, 3);
+ INI_FILE snd = fn;
+ if (! snd.Error) {
+ uint16 siz = (uint16) snd.Size();
+ p = (uint8 *) malloc(siz);
+ if (p) {
+ snd.Read(p, siz);
+ if (snd.Error) {
+ free(p);
+ p = NULL;
+ }
+ }
}
- }
- return p;
+ return p;
}
} // End of namespace CGE
diff --git a/engines/cge/sound.h b/engines/cge/sound.h
index 79c9bf563d..b617891268 100644
--- a/engines/cge/sound.h
+++ b/engines/cge/sound.h
@@ -25,64 +25,56 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __SOUND__
-#define __SOUND__
+#ifndef __SOUND__
+#define __SOUND__
-#include "cge/wav.h"
-#include "cge/snddrv.h"
+#include "cge/wav.h"
+#include "cge/snddrv.h"
namespace CGE {
-#define BAD_SND_TEXT 97
-#define BAD_MIDI_TEXT 98
+#define BAD_SND_TEXT 97
+#define BAD_MIDI_TEXT 98
-
-
-class SOUND
-{
+class SOUND {
public:
- SMPINFO smpinf;
- SOUND (void);
- ~SOUND (void);
- void Open (void);
- void Close (void);
- void Play (DATACK * wav, int pan, int cnt = 1);
- void Stop (void);
+ SMPINFO smpinf;
+ SOUND(void);
+ ~SOUND(void);
+ void Open(void);
+ void Close(void);
+ void Play(DATACK *wav, int pan, int cnt = 1);
+ void Stop(void);
};
-
-
-
-class FX
-{
- EMM Emm;
- struct HAN { int Ref; DATACK * Wav; } * Cache;
- int Size;
- DATACK * Load (int idx, int ref);
- int Find (int ref);
+class FX {
+ EMM Emm;
+ struct HAN {
+ int Ref;
+ DATACK *Wav;
+ } *Cache;
+ int Size;
+ DATACK *Load(int idx, int ref);
+ int Find(int ref);
public:
- DATACK * Current;
- FX (int size = 16);
- ~FX (void);
- void Clear (void);
- void Preload (int ref0);
- DATACK * operator[] (int ref);
+ DATACK *Current;
+ FX(int size = 16);
+ ~FX(void);
+ void Clear(void);
+ void Preload(int ref0);
+ DATACK *operator[](int ref);
};
+extern bool Music;
+extern SOUND Sound;
+extern FX Fx;
-
-
-extern bool Music;
-extern SOUND Sound;
-extern FX Fx;
-
-
-void LoadMIDI (int ref);
-void KillMIDI (void);
+void LoadMIDI(int ref);
+void KillMIDI(void);
} // End of namespace CGE
diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp
index c2badee266..2bed51af97 100644
--- a/engines/cge/startup.cpp
+++ b/engines/cge/startup.cpp
@@ -25,173 +25,165 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/startup.h"
-#include "cge/text.h"
-#include "cge/sound.h"
-#include "cge/ident.h"
-#include "cge/cfile.h"
-#include "cge/snddrv.h"
-#include <stdio.h>
-#include <process.h>
-#include <dos.h>
-//#include <alloc.h>
-#include <string.h>
-
-#ifdef DEBUG
- #include <stdlib.h>
+#include "cge/startup.h"
+#include "cge/text.h"
+#include "cge/sound.h"
+#include "cge/ident.h"
+#include "cge/cfile.h"
+#include "cge/snddrv.h"
+#include <stdio.h>
+#include <process.h>
+#include <dos.h>
+#include <string.h>
+
+#ifdef DEBUG
+#include <stdlib.h>
#endif
namespace CGE {
-extern char Copr[];
+extern char Copr[];
-#define id (*(IDENT*)Copr)
+#define id (*(IDENT*)Copr)
- EMM MiniEmm = MINI_EMM_SIZE;
+EMM MiniEmm = MINI_EMM_SIZE;
-static STARTUP StartUp;
+static STARTUP StartUp;
- int STARTUP::Mode = 0;
- int STARTUP::Core;
- int STARTUP::SoundOk = 0;
- uint16 STARTUP::Summa;
+int STARTUP::Mode = 0;
+int STARTUP::Core;
+int STARTUP::SoundOk = 0;
+uint16 STARTUP::Summa;
-
-void quit_now(int ref){
- error("%d\n", Text[ref]);
-}
-
-
-
-bool STARTUP::get_parms(void)
-{
-/*
- int i = _argc;
- while (i > 1)
- {
- static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI",
- "P", "D", "I", "M" };
- int n = TakeEnum(PrmTab, strtok(_argv[--i], " =:("));
- uint16 p = xtow(strtok(NULL, " h,)"));
- switch (n)
- {
- case 0 : if (Mode != 2) Mode = 1; break;
- case 1 : Mode = 2; break;
- case 2 : SNDDrvInfo.DDEV = DEV_QUIET; break;
- case 3 : SNDDrvInfo.DDEV = DEV_SB; break;
- case 4 : SNDDrvInfo.DDEV = DEV_GUS; break;
- case 5 : SNDDrvInfo.MDEV = DEV_GM; break;
- case 6 : SNDDrvInfo.DBASE = p; break;
- case 7 : SNDDrvInfo.DDMA = p; break;
- case 8 : SNDDrvInfo.DIRQ = p; break;
- case 9 : SNDDrvInfo.MBASE = p;
- SNDDrvInfo.MDEV = DEV_GM; break;
- default: return false;
- }
- if (n >= 2) SoundOk = 2;
- }
- #ifdef DEMO
- // protection disabled
- Summa = 0;
- #else
- #ifdef EVA
- {
- union { dosdate_t d; uint32 n; } today;
- _dos_getdate(&today.d);
- id.disk += (id.disk < today.n);
- }
- #endif
- #ifdef CD
- Summa = 0;
- #else
- // disk signature checksum
- Summa = ChkSum(Copr, sizeof(IDENT));
- #endif
- #endif
- if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV;
- */
- warning("STUB: STARTUP::get_parms");
- return true;
+void quit_now(int ref) {
+ error("%d\n", Text[ref]);
}
-
-
-STARTUP::STARTUP(void)
-{
-/*
- uint32 m = farcoreleft() >> 10;
- if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF;
-
- if (! IsVga()) quit_now(NOT_VGA_TEXT);
- if (Cpu() < _80286) quit_now(BAD_CHIP_TEXT);
- if (100 * _osmajor + _osminor < 330) quit_now(BAD_DOS_TEXT);
-
- #ifndef DEBUG
- if (Core < CORE_LOW) quit_now(NO_CORE_TEXT);
- if (Core < CORE_HIG)
- {
- SNDDrvInfo.MDEV = DEV_QUIET;
- Music = false;
- }
- #endif
- if (! get_parms()) quit_now(BAD_ARG_TEXT);
- //--- load sound configuration
- const char * fn = UsrPath(ProgName(CFG_EXT));
- if (! STARTUP::SoundOk && CFILE::Exist(fn))
- {
- CFILE cfg(fn, REA);
- if (! cfg.Error)
- {
- cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2));
- if (! cfg.Error) STARTUP::SoundOk = 1;
- }
- }
- */
- warning("STUB: STARTUP::STARTUP");
+bool STARTUP::get_parms(void) {
+ /*
+ int i = _argc;
+ while (i > 1)
+ {
+ static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI",
+ "P", "D", "I", "M" };
+ int n = TakeEnum(PrmTab, strtok(_argv[--i], " =:("));
+ uint16 p = xtow(strtok(NULL, " h,)"));
+ switch (n)
+ {
+ case 0 : if (Mode != 2) Mode = 1; break;
+ case 1 : Mode = 2; break;
+ case 2 : SNDDrvInfo.DDEV = DEV_QUIET; break;
+ case 3 : SNDDrvInfo.DDEV = DEV_SB; break;
+ case 4 : SNDDrvInfo.DDEV = DEV_GUS; break;
+ case 5 : SNDDrvInfo.MDEV = DEV_GM; break;
+ case 6 : SNDDrvInfo.DBASE = p; break;
+ case 7 : SNDDrvInfo.DDMA = p; break;
+ case 8 : SNDDrvInfo.DIRQ = p; break;
+ case 9 : SNDDrvInfo.MBASE = p;
+ SNDDrvInfo.MDEV = DEV_GM; break;
+ default: return false;
+ }
+ if (n >= 2) SoundOk = 2;
+ }
+ #ifdef DEMO
+ // protection disabled
+ Summa = 0;
+ #else
+ #ifdef EVA
+ {
+ union { dosdate_t d; uint32 n; } today;
+ _dos_getdate(&today.d);
+ id.disk += (id.disk < today.n);
+ }
+ #endif
+ #ifdef CD
+ Summa = 0;
+ #else
+ // disk signature checksum
+ Summa = ChkSum(Copr, sizeof(IDENT));
+ #endif
+ #endif
+ if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV;
+ return true;
+ */
+ warning("STUB: STARTUP::get_parms");
+ return true;
}
+STARTUP::STARTUP(void) {
+ /*
+ uint32 m = farcoreleft() >> 10;
+ if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF;
+ if (! IsVga()) quit_now(NOT_VGA_TEXT);
+ if (Cpu() < _80286) quit_now(BAD_CHIP_TEXT);
+ if (100 * _osmajor + _osminor < 330) quit_now(BAD_DOS_TEXT);
-
-
-const char *UsrPath (const char *nam)
-{
- static char buf[MAXPATH] = ".\\", *p = buf+2;
- #if defined(CD)
- if (DriveCD(0))
- {
- bool ok = false;
- CFILE ini = Text[CDINI_FNAME];
- if (!ini.Error)
- {
- char *key = Text[GAME_ID];
- int i = strlen(key);
- while (ini.Read(buf) && !ok)
+ #ifndef DEBUG
+ if (Core < CORE_LOW) quit_now(NO_CORE_TEXT);
+ if (Core < CORE_HIG)
{
- int j = strlen(buf);
- if (j) if (buf[--j] == '\n') buf[j] = '\0';
- if (memicmp(buf, key, i) == 0) ok = true;
+ SNDDrvInfo.MDEV = DEV_QUIET;
+ Music = false;
}
- if (ok)
+ #endif
+ if (! get_parms()) quit_now(BAD_ARG_TEXT);
+ //--- load sound configuration
+ const char * fn = UsrPath(ProgName(CFG_EXT));
+ if (! STARTUP::SoundOk && CFILE::Exist(fn))
+ {
+ CFILE cfg(fn, REA);
+ if (! cfg.Error)
{
- strcpy(buf, buf+i);
- p = buf + strlen(buf);
- if (*(p-1) != '\\') *(p++) = '\\';
- strcpy(p, "NUL");
- if (_dos_open(buf, 0, &i) == 0) _dos_close(i);
- else ok = false;
+ cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2));
+ if (! cfg.Error) STARTUP::SoundOk = 1;
}
+ }
+ */
+ warning("STUB: STARTUP::STARTUP");
+}
+
+
+const char *UsrPath(const char *nam) {
+ static char buf[MAXPATH] = ".\\", *p = buf + 2;
+#if defined(CD)
+ if (DriveCD(0)) {
+ bool ok = false;
+ CFILE ini = Text[CDINI_FNAME];
+ if (!ini.Error) {
+ char *key = Text[GAME_ID];
+ int i = strlen(key);
+ while (ini.Read(buf) && !ok) {
+ int j = strlen(buf);
+ if (j)
+ if (buf[--j] == '\n')
+ buf[j] = '\0';
+ if (memicmp(buf, key, i) == 0)
+ ok = true;
+ }
+ if (ok) {
+ strcpy(buf, buf + i);
+ p = buf + strlen(buf);
+ if (*(p - 1) != '\\')
+ *(p++) = '\\';
+ strcpy(p, "NUL");
+ if (_dos_open(buf, 0, &i) == 0)
+ _dos_close(i);
+ else
+ ok = false;
+ }
+ }
+ if (!ok)
+ quit_now(BADCD_TEXT);
}
- if (!ok) quit_now(BADCD_TEXT);
- }
- #endif
- strcpy(p, nam);
- return buf;
+#endif
+ strcpy(p, nam);
+ return buf;
}
} // End of namespace CGE
diff --git a/engines/cge/startup.h b/engines/cge/startup.h
index 2f1b5faa0b..5bfa9876d6 100644
--- a/engines/cge/startup.h
+++ b/engines/cge/startup.h
@@ -25,57 +25,54 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __STARTUP__
-#define __STARTUP__
+#ifndef __STARTUP__
+#define __STARTUP__
-#include "cge/general.h"
+#include "cge/general.h"
namespace CGE {
-#define GAME_ID 45
-#define CDINI_FNAME 46
+#define GAME_ID 45
+#define CDINI_FNAME 46
-#define NOT_VGA_TEXT 90
-#define BAD_CHIP_TEXT 91
-#define BAD_DOS_TEXT 92
-#define NO_CORE_TEXT 93
-#define BAD_MIPS_TEXT 94
-#define NO_MOUSE_TEXT 95
-#define BAD_ARG_TEXT 96
-#define BADCD_TEXT 97
+#define NOT_VGA_TEXT 90
+#define BAD_CHIP_TEXT 91
+#define BAD_DOS_TEXT 92
+#define NO_CORE_TEXT 93
+#define BAD_MIPS_TEXT 94
+#define NO_MOUSE_TEXT 95
+#define BAD_ARG_TEXT 96
+#define BADCD_TEXT 97
-#define CFG_EXT ".CFG"
+#define CFG_EXT ".CFG"
#if defined(DEMO)
- #define MINI_EMM_SIZE 0x00004000L
- #define CORE_HIG 400
+#define MINI_EMM_SIZE 0x00004000L
+#define CORE_HIG 400
#else
- #define MINI_EMM_SIZE 0x00010000L
- #define CORE_HIG 450
+#define MINI_EMM_SIZE 0x00010000L
+#define CORE_HIG 450
#endif
-#define CORE_MID (CORE_HIG-20)
-#define CORE_LOW (CORE_MID-20)
+#define CORE_MID (CORE_HIG - 20)
+#define CORE_LOW (CORE_MID - 20)
-class STARTUP
-{
- static bool get_parms (void);
+class STARTUP {
+ static bool get_parms(void);
public:
- static int Mode;
- static int Core;
- static int SoundOk;
- static uint16 Summa;
- STARTUP (void);
+ static int Mode;
+ static int Core;
+ static int SoundOk;
+ static uint16 Summa;
+ STARTUP(void);
};
+extern EMM MiniEmm;
-
-extern EMM MiniEmm;
-
-const char *UsrPath (const char *nam);
+const char *UsrPath(const char *nam);
} // End of namespace CGE
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 9fd32ab7d2..1dbcbad98d 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -25,384 +25,304 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/general.h"
-#include "cge/talk.h"
-#include "cge/vol.h"
-#include "cge/game.h"
-#include "cge/mouse.h"
-#include <dos.h>
-//#include <alloc.h>
-//#include <mem.h>
+#include "cge/general.h"
+#include "cge/talk.h"
+#include "cge/vol.h"
+#include "cge/game.h"
+#include "cge/mouse.h"
+#include <dos.h>
namespace CGE {
-#define WID_SIZ 256
-#define POS_SIZ 256
-#define MAP_SIZ (256*8)
+#define WID_SIZ 256
+#define POS_SIZ 256
+#define MAP_SIZ (256*8)
+//uint8 FONT::Wid[WID_SIZ];
+//uint16 FONT::Pos[POS_SIZ];
+//uint8 FONT::Map[MAP_SIZ];
-//--------------------------------------------------------------------------
-
-
-//uint8 FONT::Wid[WID_SIZ];
-//uint16 FONT::Pos[POS_SIZ];
-//uint8 FONT::Map[MAP_SIZ];
-
-
-
-
-
-
-
-FONT::FONT (const char * name)
-{
- Map = farnew(uint8, MAP_SIZ);
- Pos = farnew(uint16, POS_SIZ);
- Wid = farnew(uint8, WID_SIZ);
- if (Map == NULL || Pos == NULL || Wid == NULL)
- error("No core");
- MergeExt(Path, name, FONT_EXT);
- Load();
+FONT::FONT(const char *name) {
+ Map = farnew(uint8, MAP_SIZ);
+ Pos = farnew(uint16, POS_SIZ);
+ Wid = farnew(uint8, WID_SIZ);
+ if ((Map == NULL) || (Pos == NULL) || (Wid == NULL))
+ error("No core");
+ MergeExt(Path, name, FONT_EXT);
+ Load();
}
-
-
-FONT::~FONT (void)
-{
- free(Map);
- free(Pos);
- free(Wid);
+FONT::~FONT(void) {
+ free(Map);
+ free(Pos);
+ free(Wid);
}
-
-
-void FONT::Load (void)
-{
- INI_FILE f(Path);
- if (! f.Error)
- {
- f.Read(Wid, WID_SIZ);
- if (! f.Error)
- {
- uint16 i, p = 0;
- for (i = 0; i < POS_SIZ; i ++)
- {
- Pos[i] = p;
- p += Wid[i];
- }
- f.Read(Map, p);
+void FONT::Load(void) {
+ INI_FILE f(Path);
+ if (! f.Error) {
+ f.Read(Wid, WID_SIZ);
+ if (! f.Error) {
+ uint16 i, p = 0;
+ for (i = 0; i < POS_SIZ; i ++) {
+ Pos[i] = p;
+ p += Wid[i];
+ }
+ f.Read(Map, p);
+ }
}
- }
}
-
-
-
-uint16 FONT::Width (const char * text)
-{
- uint16 w = 0;
- if (text) while (* text) w += Wid[*(text ++)];
- return w;
+uint16 FONT::Width(const char *text) {
+ uint16 w = 0;
+ if (text)
+ while (* text)
+ w += Wid[*(text ++)];
+ return w;
}
-
/*
-void FONT::Save (void)
-{
- CFILE f((const char *) Path, WRI);
- if (! f.Error)
- {
- f.Write(Wid, WID_SIZ);
- if (! f.Error)
- {
- f.Write(Map, Pos[POS_SIZ-1] + Wid[WID_SIZ-1]);
+void FONT::Save(void) {
+ CFILE f((const char *) Path, WRI);
+ if (! f.Error) {
+ f.Write(Wid, WID_SIZ);
+ if (! f.Error)
+ f.Write(Map, Pos[POS_SIZ-1] + Wid[WID_SIZ-1]);
}
- }
}
*/
+FONT TALK::Font(ProgName());
-//--------------------------------------------------------------------------
-
-
-
-FONT TALK::Font(ProgName());
-
-
-
-TALK::TALK (const char * tx, TBOX_STYLE mode)
-: SPRITE(NULL), Mode(mode)
-{
- TS[0] = TS[1] = NULL;
- Flags.Syst = true;
- Update(tx);
+TALK::TALK(const char *tx, TBOX_STYLE mode)
+ : SPRITE(NULL), Mode(mode) {
+ TS[0] = TS[1] = NULL;
+ Flags.Syst = true;
+ Update(tx);
}
-
-
-
-TALK::TALK (void)
-: SPRITE(NULL), Mode(PURE)
-{
- TS[0] = TS[1] = NULL;
- Flags.Syst = true;
+TALK::TALK(void)
+ : SPRITE(NULL), Mode(PURE) {
+ TS[0] = TS[1] = NULL;
+ Flags.Syst = true;
}
-
-
-
/*
-TALK::~TALK (void)
-{
- uint16 i;
- for (i = 0; i < ShpCnt; i ++)
- {
- if (FP_SEG(ShpList[i]) != _DS) // small model: always false
- {
- delete ShpList[i];
- ShpList[i] = NULL;
+TALK::~TALK (void) {
+ for (uint16 i = 0; i < ShpCnt; i ++) {
+ if (FP_SEG(ShpList[i]) != _DS) { // small model: always false
+ delete ShpList[i];
+ ShpList[i] = NULL;
+ }
}
- }
}
*/
-
-void TALK::Update (const char * tx)
-{
- uint16 vmarg = (Mode) ? TEXT_VM : 0;
- uint16 hmarg = (Mode) ? TEXT_HM : 0;
- uint16 mw = 0, mh, ln = vmarg;
- const char * p;
- uint8 * m;
-
- if (! TS[0])
- {
- uint16 k = 2 * hmarg;
- mh = 2 * vmarg + FONT_HIG;
- for (p = tx; *p; p ++)
- {
- if (*p == '|' || *p == '\n')
- {
- mh += FONT_HIG + TEXT_LS;
- if (k > mw) mw = k;
- k = 2 * hmarg;
- }
- else k += Font.Wid[*p];
+void TALK::Update(const char *tx) {
+ uint16 vmarg = (Mode) ? TEXT_VM : 0;
+ uint16 hmarg = (Mode) ? TEXT_HM : 0;
+ uint16 mw = 0, mh, ln = vmarg;
+ const char *p;
+ uint8 *m;
+
+ if (!TS[0]) {
+ uint16 k = 2 * hmarg;
+ mh = 2 * vmarg + FONT_HIG;
+ for (p = tx; *p; p ++) {
+ if (*p == '|' || *p == '\n') {
+ mh += FONT_HIG + TEXT_LS;
+ if (k > mw)
+ mw = k;
+ k = 2 * hmarg;
+ } else
+ k += Font.Wid[*p];
+ }
+ if (k > mw)
+ mw = k;
+ TS[0] = Box(mw, mh);
}
- if (k > mw) mw = k;
- TS[0] = Box(mw, mh);
- }
-
- m = TS[0]->M + ln * mw + hmarg;
-
- while (* tx)
- {
- if (*tx == '|' || *tx == '\n')
- m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg;
- else
- {
- int cw = Font.Wid[*tx], i;
- uint8 * f = Font.Map + Font.Pos[*tx];
- for (i = 0; i < cw; i ++)
- {
- uint8 * p = m;
- uint16 n;
- register uint16 b = * (f ++);
- for (n = 0; n < FONT_HIG; n ++)
- {
- if (b & 1) * p = TEXT_FG;
- b >>= 1;
- p += mw;
+
+ m = TS[0]->M + ln * mw + hmarg;
+
+ while (* tx) {
+ if (*tx == '|' || *tx == '\n')
+ m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg;
+ else {
+ int cw = Font.Wid[*tx], i;
+ uint8 *f = Font.Map + Font.Pos[*tx];
+ for (i = 0; i < cw; i++) {
+ uint8 *p = m;
+ uint16 n;
+ register uint16 b = *(f++);
+ for (n = 0; n < FONT_HIG; n++) {
+ if (b & 1)
+ *p = TEXT_FG;
+ b >>= 1;
+ p += mw;
+ }
+ ++m;
+ }
}
- ++ m;
- }
+ ++tx;
}
- ++ tx;
- }
- TS[0]->Code();
- SetShapeList(TS);
+ TS[0]->Code();
+ SetShapeList(TS);
}
-BITMAP * TALK::Box (uint16 w, uint16 h)
-{
- uint8 * b, * p, * q;
- uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0;
- int i;
+BITMAP *TALK::Box(uint16 w, uint16 h) {
+ uint8 *b, * p, * q;
+ uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0;
- if (w < 8) w = 8;
- if (h < 8) h = 8;
- b = farnew(uint8, n = w * h);
- if (! b)
- error("No core");
- memset(b, TEXT_BG, n);
+ if (w < 8)
+ w = 8;
+ if (h < 8)
+ h = 8;
+ b = farnew(uint8, n = w * h);
+ if (! b)
+ error("No core");
+ memset(b, TEXT_BG, n);
- if (Mode)
- {
- p = b; q = b + n - w;
- memset(p, LGRAY, w);
- memset(q, DGRAY, w);
- while (p < q)
- {
- p += w;
- * (p-1) = DGRAY;
- * p = LGRAY;
- }
- p = b;
- for (i = 0; i < r; i ++)
- {
- int j;
- for (j = 0; j < r-i; j ++)
- {
- p[ j ] = TRANS;
- p[w-j-1] = TRANS;
- q[ j ] = TRANS;
- q[w-j-1] = TRANS;
- }
- p[ j ] = LGRAY;
- p[w-j-1] = DGRAY;
- q[ j ] = LGRAY;
- q[w-j-1] = DGRAY;
- p += w;
- q -= w;
+ if (Mode) {
+ p = b;
+ q = b + n - w;
+ memset(p, LGRAY, w);
+ memset(q, DGRAY, w);
+ while (p < q) {
+ p += w;
+ *(p - 1) = DGRAY;
+ *p = LGRAY;
+ }
+ p = b;
+ for (int i = 0; i < r; i ++) {
+ int j;
+ for (j = 0; j < r - i; j ++) {
+ p[j] = TRANS;
+ p[w - j - 1] = TRANS;
+ q[j] = TRANS;
+ q[w - j - 1] = TRANS;
+ }
+ p[j] = LGRAY;
+ p[w - j - 1] = DGRAY;
+ q[j] = LGRAY;
+ q[w - j - 1] = DGRAY;
+ p += w;
+ q -= w;
+ }
}
- }
- return new BITMAP(w, h, b);
+ return new BITMAP(w, h, b);
}
-
-
-
-void TALK::PutLine (int line, const char * text)
+void TALK::PutLine(int line, const char *text) {
// Note: (TS[0].W % 4) have to be 0
-{
- uint16 w = TS[0]->W, h = TS[0]->H;
- uint8 * v = TS[0]->V, * p;
- uint16 dsiz = w >> 2; // data size (1 plane line size)
- uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
- uint16 psiz = h * lsiz; // - last gap, but + plane trailer
- uint16 size = 4 * psiz; // whole map size
- uint16 rsiz = FONT_HIG * lsiz; // length of whole text row map
-
- // set desired line pointer
- v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz;
-
- // clear whole rectangle
- p = v; // assume blanked line above text
- memcpy(p, p-lsiz, rsiz); p += psiz; // tricky replicate lines for plane 0
- memcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 1
- memcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 2
- memcpy(p, p-lsiz, rsiz); // same for plane 3
-
- // paint text line
- if (text)
- {
- uint8 * q;
- p = v + 2 + TEXT_HM/4 + (TEXT_HM%4)*psiz;
- q = v + size;
-
- while (* text)
- {
- uint16 cw = Font.Wid[*text], i;
- uint8 * fp = Font.Map + Font.Pos[*text];
-
- for (i = 0; i < cw; i ++)
- {
- register uint16 b = fp[i];
- uint16 n;
- for (n = 0; n < FONT_HIG; n ++)
- {
- if (b & 1) *p = TEXT_FG;
- b >>= 1;
- p += lsiz;
+ uint16 w = TS[0]->W, h = TS[0]->H;
+ uint8 *v = TS[0]->V, * p;
+ uint16 dsiz = w >> 2; // data size (1 plane line size)
+ uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
+ uint16 psiz = h * lsiz; // - last gap, but + plane trailer
+ uint16 size = 4 * psiz; // whole map size
+ uint16 rsiz = FONT_HIG * lsiz; // length of whole text row map
+
+ // set desired line pointer
+ v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz;
+
+ // clear whole rectangle
+ p = v; // assume blanked line above text
+ memcpy(p, p - lsiz, rsiz);
+ p += psiz; // tricky replicate lines for plane 0
+ memcpy(p, p - lsiz, rsiz);
+ p += psiz; // same for plane 1
+ memcpy(p, p - lsiz, rsiz);
+ p += psiz; // same for plane 2
+ memcpy(p, p - lsiz, rsiz); // same for plane 3
+
+ // paint text line
+ if (text) {
+ uint8 *q;
+ p = v + 2 + TEXT_HM / 4 + (TEXT_HM % 4) * psiz;
+ q = v + size;
+
+ while (* text) {
+ uint16 cw = Font.Wid[*text], i;
+ uint8 *fp = Font.Map + Font.Pos[*text];
+
+ for (i = 0; i < cw; i ++) {
+ register uint16 b = fp[i];
+ uint16 n;
+ for (n = 0; n < FONT_HIG; n ++) {
+ if (b & 1)
+ *p = TEXT_FG;
+ b >>= 1;
+ p += lsiz;
+ }
+ p = p - rsiz + psiz;
+ if (p >= q)
+ p = p - size + 1;
+ }
+ ++text;
}
- p = p - rsiz + psiz;
- if (p >= q) p = p - size + 1;
- }
- ++ text;
}
- }
}
-
-
-
-
-//--------------------------------------------------------------------------
-
-
-
-
-INFO_LINE::INFO_LINE (uint16 w)
-: OldTxt(NULL)
-{
- TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG);
- SetShapeList(TS);
+INFO_LINE::INFO_LINE(uint16 w) : OldTxt(NULL) {
+ TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG);
+ SetShapeList(TS);
}
-
-
-
-
-void INFO_LINE::Update (const char * tx)
-{
- if (tx != OldTxt)
- {
- uint16 w = TS[0]->W, h = TS[0]->H;
- uint8 * v = (uint8 *) TS[0]->V;
- uint16 dsiz = w >> 2; // data size (1 plane line size)
- uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
- uint16 psiz = h * lsiz; // - last gape, but + plane trailer
- uint16 size = 4 * psiz; // whole map size
-
- // claer whole rectangle
- memset(v+2, TEXT_BG, dsiz); // data bytes
- memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines
- * (uint16 *) (v + psiz - 2) = EOI; // plane trailer uint16
- memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes
-
- // paint text line
- if (tx)
- {
- uint8 * p = v + 2, * q = p + size;
-
- while (* tx)
- {
- uint16 cw = Font.Wid[*tx], i;
- uint8 * fp = Font.Map + Font.Pos[*tx];
-
- for (i = 0; i < cw; i ++)
- {
- register uint16 b = fp[i];
- uint16 n;
- for (n = 0; n < FONT_HIG; n ++)
- {
- if (b & 1) *p = TEXT_FG;
- b >>= 1;
- p += lsiz;
- }
- if (p >= q) p = p - size + 1;
+void INFO_LINE::Update(const char *tx) {
+ if (tx != OldTxt) {
+ uint16 w = TS[0]->W, h = TS[0]->H;
+ uint8 *v = (uint8 *) TS[0]->V;
+ uint16 dsiz = w >> 2; // data size (1 plane line size)
+ uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
+ uint16 psiz = h * lsiz; // - last gape, but + plane trailer
+ uint16 size = 4 * psiz; // whole map size
+
+ // claer whole rectangle
+ memset(v + 2, TEXT_BG, dsiz); // data bytes
+ memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines
+ * (uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16
+ memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes
+
+ // paint text line
+ if (tx) {
+ uint8 *p = v + 2, * q = p + size;
+
+ while (*tx) {
+ uint16 cw = Font.Wid[*tx];
+ uint8 *fp = Font.Map + Font.Pos[*tx];
+
+ for (uint16 i = 0; i < cw; i++) {
+ register uint16 b = fp[i];
+ for (uint16 n = 0; n < FONT_HIG; n ++) {
+ if (b & 1)
+ *p = TEXT_FG;
+ b >>= 1;
+ p += lsiz;
+ }
+ if (p >= q)
+ p = p - size + 1;
+ }
+ ++tx;
+ }
}
- ++ tx;
- }
+ OldTxt = tx;
}
- OldTxt = tx;
- }
}
} // End of namespace CGE
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index aab6834c28..568fd82964 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -25,86 +25,72 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __TALK__
-#define __TALK__
+#ifndef __TALK__
+#define __TALK__
-#include "cge/vga13h.h"
-#include "cge/general.h"
-#include "cge/jbw.h"
-//#include <dir.h>
+#include "cge/vga13h.h"
+#include "cge/general.h"
+#include "cge/jbw.h"
namespace CGE {
-#define TEXT_FG DARK // foreground color
-#define TEXT_BG GRAY // background color
-#define TEXT_HM (6&~1) // EVEN horizontal margins!
-#define TEXT_VM 5 // vertical margins
-#define TEXT_LS 2 // line spacing
-#define TEXT_RD 3 // rounded corners
+#define TEXT_FG DARK // foreground color
+#define TEXT_BG GRAY // background color
+#define TEXT_HM (6&~1) // EVEN horizontal margins!
+#define TEXT_VM 5 // vertical margins
+#define TEXT_LS 2 // line spacing
+#define TEXT_RD 3 // rounded corners
-#define FONT_HIG 8
-#define FONT_EXT ".CFT"
+#define FONT_HIG 8
+#define FONT_EXT ".CFT"
#define MAXPATH 128
-class FONT
-{
- char Path[MAXPATH];
- void Load (void);
+class FONT {
+ char Path[MAXPATH];
+ void Load(void);
public:
// static uint8 Wid[256];
// static uint16 Pos[256];
// static uint8 Map[256*8];
- uint8 * Wid;
- uint16 * Pos;
- uint8 * Map;
- FONT (const char * name);
- ~FONT (void);
- uint16 Width (const char * text);
- void Save (void);
+ uint8 *Wid;
+ uint16 *Pos;
+ uint8 *Map;
+ FONT(const char *name);
+ ~FONT(void);
+ uint16 Width(const char *text);
+ void Save(void);
};
+enum TBOX_STYLE { PURE, RECT, ROUND };
-
-enum TBOX_STYLE { PURE, RECT, ROUND };
-
-
-
-class TALK : public SPRITE
-{
+class TALK : public SPRITE {
protected:
- TBOX_STYLE Mode;
- BITMAP * TS[2];
- BITMAP * Box(uint16 w, uint16 h);
+ TBOX_STYLE Mode;
+ BITMAP *TS[2];
+ BITMAP *Box(uint16 w, uint16 h);
public:
- static FONT Font;
- TALK (const char * tx, TBOX_STYLE mode = PURE);
- TALK (void);
- //~TALK (void);
- virtual void Update (const char * tx);
- virtual void Update (void) {}
- void PutLine (int line, const char * text);
+ static FONT Font;
+ TALK(const char *tx, TBOX_STYLE mode = PURE);
+ TALK(void);
+ //~TALK (void);
+ virtual void Update(const char *tx);
+ virtual void Update(void) {}
+ void PutLine(int line, const char *text);
};
-
-
-
-
-
-class INFO_LINE : public TALK
-{
- const char * OldTxt;
+class INFO_LINE : public TALK {
+ const char *OldTxt;
public:
- INFO_LINE (uint16 wid);
- void Update (const char * tx);
+ INFO_LINE(uint16 wid);
+ void Update(const char *tx);
};
-
} // End of namespace CGE
#endif
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index 5b79131a26..71f4f156d5 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -25,292 +25,235 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/general.h"
-#include "cge/text.h"
-#include "cge/talk.h"
-#include "cge/vol.h"
-#include "cge/bitmaps.h"
-#include "cge/game.h"
-#include "cge/snail.h"
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dos.h>
+#include "cge/general.h"
+#include "cge/text.h"
+#include "cge/talk.h"
+#include "cge/vol.h"
+#include "cge/bitmaps.h"
+#include "cge/game.h"
+#include "cge/snail.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dos.h>
namespace CGE {
- TEXT Text = ProgName();
- TALK * Talk = NULL;
+TEXT Text = ProgName();
+TALK *Talk = NULL;
+TEXT::TEXT(const char *fname, int size) {
+ Cache = new HAN[size];
+ MergeExt(FileName, fname, SAY_EXT);
+ if (!INI_FILE::Exist(FileName))
+ error("No talk\n");
-
-
-
-TEXT::TEXT (const char * fname, int size)
-{
- Cache = new HAN[size];
- MergeExt(FileName, fname, SAY_EXT);
- if (! INI_FILE::Exist(FileName)) {
- error("No talk\n");
- }
-
- for (Size = 0; Size < size; Size ++)
- {
- Cache[Size].Ref = 0;
- Cache[Size].Txt = NULL;
- }
+ for (Size = 0; Size < size; Size ++) {
+ Cache[Size].Ref = 0;
+ Cache[Size].Txt = NULL;
+ }
}
-
-
-TEXT::~TEXT (void)
-{
- Clear();
- delete[] Cache;
+TEXT::~TEXT(void) {
+ Clear();
+ delete[] Cache;
}
-
-
-
-void TEXT::Clear (int from, int upto)
-{
- HAN * p, * q;
- for (p = Cache, q = p+Size; p < q; p ++)
- {
- if (p->Ref && p->Ref >= from && p->Ref < upto)
- {
- p->Ref = 0;
- delete p->Txt;
- p->Txt = NULL;
+void TEXT::Clear(int from, int upto) {
+ HAN *p, * q;
+ for (p = Cache, q = p + Size; p < q; p ++) {
+ if (p->Ref && p->Ref >= from && p->Ref < upto) {
+ p->Ref = 0;
+ delete p->Txt;
+ p->Txt = NULL;
+ }
}
- }
}
-
-
-
-int TEXT::Find (int ref)
-{
- HAN * p, * q;
- int i = 0;
- for (p = Cache, q = p+Size; p < q; p ++)
- {
- if (p->Ref == ref) break;
- else ++ i;
- }
- return i;
+int TEXT::Find(int ref) {
+ HAN *p, * q;
+ int i = 0;
+ for (p = Cache, q = p + Size; p < q; p ++) {
+ if (p->Ref == ref)
+ break;
+ else
+ ++i;
+ }
+ return i;
}
-
-
-
-
-
-
-
-
-
-void TEXT::Preload (int from, int upto)
-{
- INI_FILE tf = FileName;
- if (! tf.Error)
- {
- HAN * CacheLim = Cache + Size;
- char line[LINE_MAX+1];
- int n;
-
- while ((n = tf.Read((uint8*)line)) != 0)
- {
- char * s;
- int ref;
-
- if (line[n-1] == '\n') line[-- n] = '\0';
- if ((s = strtok(line, " =,;/\t\n")) == NULL) continue;
- if (! IsDigit(*s)) continue;
- ref = atoi(s);
- if (ref && ref >= from && ref < upto)
- {
- HAN * p;
-
- p = &Cache[Find(ref)];
- if (p < CacheLim)
- {
- delete[] p->Txt;
- p->Txt = NULL;
+void TEXT::Preload(int from, int upto) {
+ INI_FILE tf = FileName;
+ if (! tf.Error) {
+ HAN *CacheLim = Cache + Size;
+ char line[LINE_MAX + 1];
+ int n;
+
+ while ((n = tf.Read((uint8 *)line)) != 0) {
+ char *s;
+ int ref;
+
+ if (line[n - 1] == '\n')
+ line[-- n] = '\0';
+ if ((s = strtok(line, " =,;/\t\n")) == NULL)
+ continue;
+ if (! IsDigit(*s))
+ continue;
+ ref = atoi(s);
+ if (ref && ref >= from && ref < upto) {
+ HAN *p;
+
+ p = &Cache[Find(ref)];
+ if (p < CacheLim) {
+ delete[] p->Txt;
+ p->Txt = NULL;
+ } else
+ p = &Cache[Find(0)];
+ if (p >= CacheLim)
+ break;
+ s += strlen(s);
+ if (s < line + n)
+ ++s;
+ if ((p->Txt = new char[strlen(s) + 1]) == NULL)
+ break;
+ p->Ref = ref;
+ strcpy(p->Txt, s);
+ }
}
- else p = &Cache[Find(0)];
- if (p >= CacheLim) break;
- s += strlen(s);
- if (s < line + n) ++ s;
- if ((p->Txt = new char[strlen(s) + 1]) == NULL) break;
- p->Ref = ref;
- strcpy(p->Txt, s);
- }
}
- }
}
-
-
-
-char * TEXT::Load (int idx, int ref)
-{
- INI_FILE tf = FileName;
- if (! tf.Error)
- {
- HAN * p = &Cache[idx];
- char line[LINE_MAX+1];
- int n;
-
- while ((n = tf.Read((uint8*)line)) != 0)
- {
- char * s;
-
- if (line[n-1] == '\n') line[-- n] = '\0';
- if ((s = strtok(line, " =,;/\t\n")) == NULL) continue;
- if (! IsDigit(*s)) continue;
-
- int r = atoi(s);
- if (r < ref) continue;
- if (r > ref) break;
- // (r == ref)
- s += strlen(s);
- if (s < line + n) ++ s;
- p->Ref = ref;
- if ((p->Txt = new char[strlen(s) + 1]) == NULL) return NULL;
- return strcpy(p->Txt, s);
+char *TEXT::Load(int idx, int ref) {
+ INI_FILE tf = FileName;
+ if (! tf.Error) {
+ HAN *p = &Cache[idx];
+ char line[LINE_MAX + 1];
+ int n;
+
+ while ((n = tf.Read((uint8 *)line)) != 0) {
+ char *s;
+
+ if (line[n - 1] == '\n')
+ line[-- n] = '\0';
+ if ((s = strtok(line, " =,;/\t\n")) == NULL)
+ continue;
+ if (! IsDigit(*s))
+ continue;
+
+ int r = atoi(s);
+ if (r < ref)
+ continue;
+ if (r > ref)
+ break;
+ // (r == ref)
+ s += strlen(s);
+ if (s < line + n)
+ ++s;
+ p->Ref = ref;
+ if ((p->Txt = new char[strlen(s) + 1]) == NULL)
+ return NULL;
+ return strcpy(p->Txt, s);
+ }
}
- }
- return NULL;
+ return NULL;
}
+char *TEXT::operator [](int ref) {
+ int i;
+ if ((i = Find(ref)) < Size)
+ return Cache[i].Txt;
-
-char * TEXT::operator [] (int ref)
-{
- int i;
- if ((i = Find(ref)) < Size) return Cache[i].Txt;
-
- if ((i = Find(0)) >= Size)
- {
- Clear(SYSTXT_MAX); // clear non-system
- if ((i = Find(0)) >= Size)
- {
- Clear(); // clear all
- i = 0;
+ if ((i = Find(0)) >= Size) {
+ Clear(SYSTXT_MAX); // clear non-system
+ if ((i = Find(0)) >= Size) {
+ Clear(); // clear all
+ i = 0;
+ }
}
- }
- return Load(i, ref);
+ return Load(i, ref);
}
-
-
-
-
-void Say (const char * txt, SPRITE * spr)
-{
- KillText();
- Talk = new TALK(txt, ROUND);
- if (Talk)
- {
- bool east = spr->Flags.East;
- int x = (east) ? (spr->X+spr->W-2) : (spr->X+2);
- int y = spr->Y+2;
- SPRITE * spike = new SPRITE(SP);
- uint16 sw = spike->W;
-
- if (east)
- {
- if (x + sw + TEXT_RD + 5 >= SCR_WID) east = false;
- }
- else
- {
- if (x <= 5 + TEXT_RD + sw) east = true;
+void Say(const char *txt, SPRITE *spr) {
+ KillText();
+ Talk = new TALK(txt, ROUND);
+ if (Talk) {
+ bool east = spr->Flags.East;
+ int x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2);
+ int y = spr->Y + 2;
+ SPRITE *spike = new SPRITE(SP);
+ uint16 sw = spike->W;
+
+ if (east) {
+ if (x + sw + TEXT_RD + 5 >= SCR_WID)
+ east = false;
+ } else {
+ if (x <= 5 + TEXT_RD + sw)
+ east = true;
+ }
+ x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2 - sw);
+ if (spr->Ref == 1)
+ x += (east) ? -10 : 10; // Hero
+
+ Talk->Flags.Kill = true;
+ Talk->Flags.BDel = true;
+ Talk->SetName(Text[SAY_NAME]);
+ Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H + 1);
+ Talk->Z = 125;
+ Talk->Ref = SAY_REF;
+
+ spike->Goto(x, Talk->Y + Talk->H - 1);
+ spike->Z = 126;
+ spike->Flags.Slav = true;
+ spike->Flags.Kill = true;
+ spike->SetName(Text[SAY_NAME]);
+ spike->Step(east);
+ spike->Ref = SAY_REF;
+
+ VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last());
+ VGA::ShowQ.Insert(spike, VGA::ShowQ.Last());
}
- x = (east) ? (spr->X+spr->W-2) : (spr->X+2-sw);
- if (spr->Ref == 1) x += (east) ? -10 : 10; // Hero
-
- Talk->Flags.Kill = true;
- Talk->Flags.BDel = true;
- Talk->SetName(Text[SAY_NAME]);
- Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H+1);
- Talk->Z = 125;
- Talk->Ref = SAY_REF;
-
- spike->Goto(x, Talk->Y + Talk->H - 1);
- spike->Z = 126;
- spike->Flags.Slav = true;
- spike->Flags.Kill = true;
- spike->SetName(Text[SAY_NAME]);
- spike->Step(east);
- spike->Ref = SAY_REF;
-
- VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last());
- VGA::ShowQ.Insert(spike, VGA::ShowQ.Last());
- }
}
-
-
-
-
-
-
-void Inf (const char * txt)
-{
- KillText();
- Talk = new TALK(txt, RECT);
- if (Talk)
- {
- Talk->Flags.Kill = true;
- Talk->Flags.BDel = true;
- Talk->SetName(Text[INF_NAME]);
- Talk->Center();
- Talk->Goto(Talk->X, Talk->Y - 20);
- Talk->Z = 126;
- Talk->Ref = INF_REF;
- VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last());
- }
+void Inf(const char *txt) {
+ KillText();
+ Talk = new TALK(txt, RECT);
+ if (Talk) {
+ Talk->Flags.Kill = true;
+ Talk->Flags.BDel = true;
+ Talk->SetName(Text[INF_NAME]);
+ Talk->Center();
+ Talk->Goto(Talk->X, Talk->Y - 20);
+ Talk->Z = 126;
+ Talk->Ref = INF_REF;
+ VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last());
+ }
}
-
-
-
-
-
-void SayTime (SPRITE * spr)
-{
-/*
- static char t[] = "00:00";
- struct time ti;
- gettime(&ti);
- wtom(ti.ti_hour, t+0, 10, 2);
- wtom(ti.ti_min, t+3, 10, 2);
- Say((*t == '0') ? (t+1) : t, spr);
- */
- warning("STUB: SayTime");
+void SayTime(SPRITE *spr) {
+ /*
+ static char t[] = "00:00";
+ struct time ti;
+ gettime(&ti);
+ wtom(ti.ti_hour, t+0, 10, 2);
+ wtom(ti.ti_min, t+3, 10, 2);
+ Say((*t == '0') ? (t+1) : t, spr);
+ */
+ warning("STUB: SayTime");
}
-
-
-
-
-
-void KillText (void)
-{
- if (Talk)
- {
- SNPOST_(SNKILL, -1, 0, Talk);
- Talk = NULL;
- }
+void KillText(void) {
+ if (Talk) {
+ SNPOST_(SNKILL, -1, 0, Talk);
+ Talk = NULL;
+ }
}
} // End of namespace CGE
diff --git a/engines/cge/text.h b/engines/cge/text.h
index 222a3abf7d..fe740ffacd 100644
--- a/engines/cge/text.h
+++ b/engines/cge/text.h
@@ -25,61 +25,61 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __TEXT__
-#define __TEXT__
+#ifndef __TEXT__
+#define __TEXT__
-#include "cge/talk.h"
-#include "cge/jbw.h"
-//#include <dir.h>
+#include "cge/talk.h"
+#include "cge/jbw.h"
namespace CGE {
-#ifndef SYSTXT_MAX
- #define SYSTXT_MAX 1000
+#ifndef SYSTXT_MAX
+#define SYSTXT_MAX 1000
#endif
-#define SAY_EXT ".SAY"
+#define SAY_EXT ".SAY"
-#define NOT_VGA_TEXT 90
-#define BAD_CHIP_TEXT 91
-#define BAD_DOS_TEXT 92
-#define NO_CORE_TEXT 93
-#define BAD_MIPS_TEXT 94
-#define NO_MOUSE_TEXT 95
+#define NOT_VGA_TEXT 90
+#define BAD_CHIP_TEXT 91
+#define BAD_DOS_TEXT 92
+#define NO_CORE_TEXT 93
+#define BAD_MIPS_TEXT 94
+#define NO_MOUSE_TEXT 95
-#define INF_NAME 101
-#define SAY_NAME 102
+#define INF_NAME 101
+#define SAY_NAME 102
+
+#define INF_REF 301
+#define SAY_REF 302
-#define INF_REF 301
-#define SAY_REF 302
-
-class TEXT
-{
- struct HAN { int Ref; char * Txt; } * Cache;
- int Size;
- char FileName[MAXPATH];
- char * Load (int idx, int ref);
- int Find (int ref);
+class TEXT {
+ struct HAN {
+ int Ref;
+ char *Txt;
+ } *Cache;
+ int Size;
+ char FileName[MAXPATH];
+ char *Load(int idx, int ref);
+ int Find(int ref);
public:
- TEXT (const char * fname, int size = 128);
- ~TEXT (void);
- void Clear (int from = 1, int upto = 0x7FFF);
- void Preload (int from = 1, int upto = 0x7FFF);
- char * operator[] (int ref);
+ TEXT(const char *fname, int size = 128);
+ ~TEXT(void);
+ void Clear(int from = 1, int upto = 0x7FFF);
+ void Preload(int from = 1, int upto = 0x7FFF);
+ char *operator[](int ref);
};
-
-extern TALK * Talk;
-extern TEXT Text;
+extern TALK *Talk;
+extern TEXT Text;
-void Say (const char * txt, SPRITE * spr);
-void SayTime (SPRITE * spr);
-void Inf (const char * txt);
-void KillText (void);
+void Say(const char *txt, SPRITE *spr);
+void SayTime(SPRITE *spr);
+void Inf(const char *txt);
+void KillText(void);
} // End of namespace CGE
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index 01441c85a3..e7ed6d0402 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -25,245 +25,219 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/general.h"
-#include "cge/vga13h.h"
-#include "cge/bitmap.h"
-#include "cge/vol.h"
-#include "cge/text.h"
-#include <conio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dos.h>
-#include <fcntl.h>
-#include <io.h>
+#include "cge/general.h"
+#include "cge/vga13h.h"
+#include "cge/bitmap.h"
+#include "cge/vol.h"
+#include "cge/text.h"
+#include <conio.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dos.h>
+#include <fcntl.h>
+#include <io.h>
namespace CGE {
#ifdef DEBUG
-#define REPORT
+#define REPORT
#endif
-#define OK(f) ((f).Error==0)
-#define FADE_STEP 2
+#define OK(f) ((f).Error==0)
+#define FADE_STEP 2
-#define TMR_DIV ((0x8000/TMR_RATE)*2)
+#define TMR_DIV ((0x8000/TMR_RATE)*2)
//--------------------------------------------------------------------------
-#ifdef REPORT
+#ifdef REPORT
static char Report[] = "NearHeap=..... FarHeap=......\n";
-#define NREP 9
-#define FREP 24
+#define NREP 9
+#define FREP 24
#endif
-static VgaRegBlk VideoMode[] = {
+static VgaRegBlk VideoMode[] = {
- { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode
+ { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode
+ { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0
+ { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0
+ { 0x06, VGAGRA, 0x02, 0x00 }, // misc
+ { 0x14, VGACRT, 0x40, 0x00 }, // underline
+ { 0x13, VGACRT, 0xFF, 0x28 }, // screen width
+ { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control
+ { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end
+ { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line
+ { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode
+// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end
+// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb
+// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr
+ { 0x00 }
+};
- { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0
- { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0
- { 0x06, VGAGRA, 0x02, 0x00 }, // misc
- { 0x14, VGACRT, 0x40, 0x00 }, // underline
- { 0x13, VGACRT, 0xFF, 0x28 }, // screen width
- { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control
+bool SpeedTest = false;
+SEQ Seq1[] = { { 0, 0, 0, 0, 0 } };
+SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } };
+SPRITE *Sys = NULL;
- { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end
- { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line
+extern "C" void SNDMIDIPlay(void);
- { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode
-
-// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end
-// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb
-// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr
-
- { 0x00 } };
-
-
- bool SpeedTest = false;
- SEQ Seq1[] = { { 0, 0, 0, 0, 0 } };
- SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } };
- SPRITE * Sys = NULL;
-
-extern "C" void SNDMIDIPlay (void);
-
-
-
-
-
-
-char * NumStr (char * str, int num)
-{
- char * p = strchr(str, '#');
- if (p) wtom(num, p, 10, 5);
- return str;
+char *NumStr(char *str, int num) {
+ char *p = strchr(str, '#');
+ if (p)
+ wtom(num, p, 10, 5);
+ return str;
}
-
-
-
-
-
-// TODO Video ASM
-/*
-static void Video (void)
+static void Video(void)
{
+/*
static uint16 SP_S;
-
- asm push bx
- asm push bp
- asm push si
- asm push di
- asm push es
- asm xor bx,bx // video page #0
+ asm push bx
+ asm push bp
+ asm push si
+ asm push di
+ asm push es
+ asm xor bx,bx // video page #0
SP_S = _SP;
- asm int VIDEO
+ asm int VIDEO
_SP = SP_S;
- asm pop es
- asm pop di
- asm pop si
- asm pop bp
- asm pop bx
-
+ asm pop es
+ asm pop di
+ asm pop si
+ asm pop bp
+ asm pop bx
+*/
+ warning("STUB: Video");
}
- */
-
-
-
-uint16 * SaveScreen (void)
-{
-/*
- uint16 cxy, cur, siz, * scr = NULL, * sav;
-
- // horizontal size of text mode screen
- asm mov ah,0x0F // get current video mode
- Video(); // BIOS video service
- asm xchg ah,al // answer in ah
- asm push ax // preserve width
-
- // vertical size of text mode screen
- asm mov dl,24 // last row on std screen
- asm xor bx,bx // valid request in BH
- asm mov ax,0x1130 // get EGA's last row #
- Video(); // BIOS video service
- asm inc dl // # of rows = last+1
-
- // compute screen size in words
- asm pop ax // restore width
- asm mul dl // width * height
-
- siz = _AX;
-
- asm mov ax,0x40 // system data segment
- asm mov es,ax
- asm mov ax,0B000H // Mono
- asm cmp byte ptr es:[0x49],0x07
- asm je sto
- asm mov ax,0B800H // Color
- sto: // store screen address
- asm mov word ptr scr+2,ax
-
- _AH = 0x0F; Video(); // active page
-
- // take cursor shape
- _AH = 0x03; Video(); // get cursor size
- cur = _CX;
-
- // take cursor position
- _DH = 0;
- _AH = 0x03; Video(); // get cursor
- cxy = _DX;
-
- sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor
- if (sav)
- {
- sav[0] = siz;
- sav[1] = cur;
- sav[2] = cxy;
- memcpy(sav+3, scr, siz * 2);
- }
- return sav;
- */
+uint16 *SaveScreen(void) {
+ /*
+ uint16 cxy, cur, siz, * scr = NULL, * sav;
+
+ // horizontal size of text mode screen
+ asm mov ah,0x0F // get current video mode
+ Video(); // BIOS video service
+ asm xchg ah,al // answer in ah
+ asm push ax // preserve width
+
+ // vertical size of text mode screen
+ asm mov dl,24 // last row on std screen
+ asm xor bx,bx // valid request in BH
+ asm mov ax,0x1130 // get EGA's last row #
+ Video(); // BIOS video service
+ asm inc dl // # of rows = last+1
+
+ // compute screen size in words
+ asm pop ax // restore width
+ asm mul dl // width * height
+
+ siz = _AX;
+
+ asm mov ax,0x40 // system data segment
+ asm mov es,ax
+ asm mov ax,0B000H // Mono
+ asm cmp byte ptr es:[0x49],0x07
+ asm je sto
+ asm mov ax,0B800H // Color
+ sto: // store screen address
+ asm mov word ptr scr+2,ax
+
+ _AH = 0x0F; Video(); // active page
+
+ // take cursor shape
+ _AH = 0x03; Video(); // get cursor size
+ cur = _CX;
+
+ // take cursor position
+ _DH = 0;
+ _AH = 0x03; Video(); // get cursor
+ cxy = _DX;
+
+ sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor
+ if (sav)
+ {
+ sav[0] = siz;
+ sav[1] = cur;
+ sav[2] = cxy;
+ memcpy(sav+3, scr, siz * 2);
+ }
+ return sav;
+ */
warning("STUB: SaveScreen");
return 0;
}
-void RestoreScreen (uint16 * &sav)
-{
-/*
- uint16 * scr = NULL;
+void RestoreScreen(uint16 * &sav) {
+ /*
+ uint16 * scr = NULL;
- asm mov ax,0x40 // system data segment
- asm mov es,ax
- asm mov ax,0B000H // Mono
- asm cmp byte ptr es:[0x49],0x07
- asm je sto
- asm mov ax,0B800H // Color
- sto: // store screen address
- asm mov word ptr scr+2,ax
+ asm mov ax,0x40 // system data segment
+ asm mov es,ax
+ asm mov ax,0B000H // Mono
+ asm cmp byte ptr es:[0x49],0x07
+ asm je sto
+ asm mov ax,0B800H // Color
+ sto: // store screen address
+ asm mov word ptr scr+2,ax
- memcpy(scr, sav+3, sav[0] * 2);
+ memcpy(scr, sav+3, sav[0] * 2);
- _AH = 0x0F; Video(); // active page
+ _AH = 0x0F; Video(); // active page
- // set cursor shape
- _CX = sav[1];
- _AH = 0x01; Video(); // set cursor size
+ // set cursor shape
+ _CX = sav[1];
+ _AH = 0x01; Video(); // set cursor size
- // set cursor position
- _DX = sav[2];
- _AH = 0x02; Video(); // set cursor
+ // set cursor position
+ _DX = sav[2];
+ _AH = 0x02; Video(); // set cursor
- free(sav);
- sav = NULL;
- */
+ free(sav);
+ sav = NULL;
+ */
warning("STUB: RestoreScreen");
}
-DAC MkDAC (uint8 r, uint8 g, uint8 b)
-{
- static DAC x;
- x.R = r;
- x.G = g;
- x.B = b;
- return x;
+DAC MkDAC(uint8 r, uint8 g, uint8 b) {
+ static DAC x;
+ x.R = r;
+ x.G = g;
+ x.B = b;
+ return x;
}
-RGB MkRGB (uint8 r, uint8 g, uint8 b)
-{
- static TRGB x;
- x.dac.R = r;
- x.dac.G = g;
- x.dac.B = b;
- return x.rgb;
+RGB MkRGB(uint8 r, uint8 g, uint8 b) {
+ static TRGB x;
+ x.dac.R = r;
+ x.dac.G = g;
+ x.dac.B = b;
+ return x.rgb;
}
-SPRITE * Locate (int ref)
-{
- SPRITE * spr = VGA::ShowQ.Locate(ref);
- return (spr) ? spr : VGA::SpareQ.Locate(ref);
+SPRITE *Locate(int ref) {
+ SPRITE *spr = VGA::ShowQ.Locate(ref);
+ return (spr) ? spr : VGA::SpareQ.Locate(ref);
}
-bool HEART::Enable = false;
-uint16 * HEART::XTimer = NULL;
+bool HEART::Enable = false;
+uint16 *HEART::XTimer = NULL;
-HEART::HEART (void)
-: ENGINE(TMR_DIV)
-{
+HEART::HEART(void)
+ : ENGINE(TMR_DIV) {
}
@@ -278,1323 +252,1284 @@ extern "C" void TimerProc (void)
if (*HEART::XTimer) -- *HEART::XTimer;
else HEART::XTimer = NULL;
- if (! run && HEART::Enable) // check overrun flag
+ if (! run && HEART::Enable) // check overrun flag
{
static uint16 oldSP, oldSS;
- ++ run; // disable 2nd call until current lasts
- asm mov ax,ds
- asm mov oldSS,ss
- asm mov oldSP,sp
- asm mov ss,ax
- asm mov sp,0xFF80
+ ++ run; // disable 2nd call until current lasts
+ asm mov ax,ds
+ asm mov oldSS,ss
+ asm mov oldSP,sp
+ asm mov ss,ax
+ asm mov sp,0xFF80
// system pseudo-sprite
if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick();
for (spr = VGA::ShowQ.First(); spr; spr = spr->Next)
- {
- if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick();
- }
- asm mov ss,oldSS
- asm mov sp,oldSP
+ {
+ if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick();
+ }
+ asm mov ss,oldSS
+ asm mov sp,oldSP
-- run;
}
}
*/
-void ENGINE::NewTimer(...)
-{
- static SPRITE * spr;
- static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2;
- /*
- ___1152_Hz___:
+void ENGINE::NewTimer(...) {
+ static SPRITE *spr;
+ static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2;
+ /*
+ ___1152_Hz___:
- SNDMIDIPlay();
- asm dec cntr1
- asm jz ___72_Hz___
- asm mov al,0x20 // send...
- asm out 0x020,al // ...e-o-i
- return;
+ SNDMIDIPlay();
+ asm dec cntr1
+ asm jz ___72_Hz___
+ asm mov al,0x20 // send...
+ asm out 0x020,al // ...e-o-i
+ return;
- ___72_Hz___:
+ ___72_Hz___:
- asm mov cntr1,TMR_RATE1
- asm dec cntr2
- asm jnz my_eoi
+ asm mov cntr1,TMR_RATE1
+ asm dec cntr2
+ asm jnz my_eoi
- ___18_Hz___:
+ ___18_Hz___:
- OldTimer();
- asm mov cntr2,TMR_RATE2
- asm jmp short my_int
+ OldTimer();
+ asm mov cntr2,TMR_RATE2
+ asm jmp short my_int
- // send E-O-I
- my_eoi:
- asm mov al,0x20
- asm out 0x020,al
- asm sti // enable interrupts
+ // send E-O-I
+ my_eoi:
+ asm mov al,0x20
+ asm out 0x020,al
+ asm sti // enable interrupts
- my_int: //------72Hz-------//
+ my_int: //------72Hz-------//
- // decrement external timer uint16
- if (HEART::XTimer)
- if (*HEART::XTimer) -- *HEART::XTimer;
- else HEART::XTimer = NULL;
+ // decrement external timer uint16
+ if (HEART::XTimer)
+ if (*HEART::XTimer) -- *HEART::XTimer;
+ else HEART::XTimer = NULL;
- if (! run && HEART::Enable) // check overrun flag
- {
- static uint16 oldSP, oldSS;
+ if (! run && HEART::Enable) // check overrun flag
+ {
+ static uint16 oldSP, oldSS;
- ++ run; // disable 2nd call until current lasts
- asm mov ax,ds
- asm mov oldSS,ss
- asm mov oldSP,sp
- asm mov ss,ax
- asm mov sp,0xFF80
+ ++ run; // disable 2nd call until current lasts
+ asm mov ax,ds
+ asm mov oldSS,ss
+ asm mov oldSP,sp
+ asm mov ss,ax
+ asm mov sp,0xFF80
- // system pseudo-sprite
- if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick();
+ // system pseudo-sprite
+ if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick();
- for (spr = VGA::ShowQ.First(); spr; spr = spr->Next)
+ for (spr = VGA::ShowQ.First(); spr; spr = spr->Next)
{
if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick();
}
- asm mov ss,oldSS
- asm mov sp,oldSP
- -- run;
- }
+ asm mov ss,oldSS
+ asm mov sp,oldSP
+ -- run;
+ }
*/
warning("STUB: ENGINE::NewTimer");
}
-void HEART::SetXTimer (uint16 * ptr)
-{
- if (XTimer && ptr != XTimer) *XTimer = 0;
- XTimer = ptr;
+void HEART::SetXTimer(uint16 *ptr) {
+ if (XTimer && ptr != XTimer)
+ *XTimer = 0;
+ XTimer = ptr;
}
-void HEART::SetXTimer (uint16 * ptr, uint16 time)
-{
- SetXTimer(ptr);
- *ptr = time;
+void HEART::SetXTimer(uint16 *ptr, uint16 time) {
+ SetXTimer(ptr);
+ *ptr = time;
}
-SPRITE::SPRITE (BMP_PTR * shp)
-: X(0), Y(0), Z(0), NearPtr(0), TakePtr(0),
- Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0),
- Ext(NULL), Ref(-1), Cave(0)
-{
- memset(File, 0, sizeof(File));
- *((uint16 *)&Flags) = 0;
- SetShapeList(shp);
+SPRITE::SPRITE(BMP_PTR *shp)
+ : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0),
+ Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0),
+ Ext(NULL), Ref(-1), Cave(0) {
+ memset(File, 0, sizeof(File));
+ *((uint16 *)&Flags) = 0;
+ SetShapeList(shp);
}
-SPRITE::~SPRITE (void)
-{
- Contract();
+SPRITE::~SPRITE(void) {
+ Contract();
}
-BMP_PTR SPRITE::Shp (void)
-{
- register SPREXT * e = Ext;
- if (e) if (e->Seq)
- {
- int i = e->Seq[SeqPtr].Now;
- #ifdef DEBUG
- if (i >= ShpCnt)
- {
- //char s[256];
- //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d",
- // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next);
- //VGA::Exit(s, File);
- error("Invalid PHASE in SPRITE::Shp() %s", File);
- }
- #endif
- return e->ShpList[i];
- }
- return NULL;
+BMP_PTR SPRITE::Shp(void) {
+ register SPREXT *e = Ext;
+ if (e)
+ if (e->Seq) {
+ int i = e->Seq[SeqPtr].Now;
+#ifdef DEBUG
+ if (i >= ShpCnt) {
+ //char s[256];
+ //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d",
+ // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next);
+ //VGA::Exit(s, File);
+ error("Invalid PHASE in SPRITE::Shp() %s", File);
+ }
+#endif
+ return e->ShpList[i];
+ }
+ return NULL;
}
-BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp)
-{
- BMP_PTR * r = (Ext) ? Ext->ShpList : NULL;
+BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) {
+ BMP_PTR *r = (Ext) ? Ext->ShpList : NULL;
- ShpCnt = 0;
- W = 0;
- H = 0;
+ ShpCnt = 0;
+ W = 0;
+ H = 0;
- if (shp)
- {
- BMP_PTR * p;
- for (p = shp; *p; p ++)
- {
- BMP_PTR b = (*p); // ->Code();
- if (b->W > W) W = b->W;
- if (b->H > H) H = b->H;
- ++ ShpCnt;
+ if (shp) {
+ BMP_PTR *p;
+ for (p = shp; *p; p++) {
+ BMP_PTR b = (*p); // ->Code();
+ if (b->W > W)
+ W = b->W;
+ if (b->H > H)
+ H = b->H;
+ ++ShpCnt;
+ }
+ Expand();
+ Ext->ShpList = shp;
+ if (! Ext->Seq)
+ SetSeq((ShpCnt < 2) ? Seq1 : Seq2);
}
- Expand();
- Ext->ShpList = shp;
- if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2);
- }
- return r;
-}
-
-
-void SPRITE::MoveShapes (uint8 * buf)
-{
- BMP_PTR * p;
- for (p = Ext->ShpList; *p; p ++)
- {
- buf += (*p)->MoveVmap(buf);
- }
+ return r;
}
-bool SPRITE::Works (SPRITE * spr)
-{
- if (spr) if (spr->Ext)
- {
- SNAIL::COM * c = spr->Ext->Take;
- if (c != NULL)
- {
- c += spr->TakePtr;
- if (c->Ref == Ref)
- if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now))
- return true;
+void SPRITE::MoveShapes(uint8 *buf) {
+ BMP_PTR *p;
+ for (p = Ext->ShpList; *p; p ++) {
+ buf += (*p)->MoveVmap(buf);
}
- }
- return false;
}
-SEQ * SPRITE::SetSeq (SEQ * seq)
-{
- Expand();
- register SEQ * s = Ext->Seq;
- Ext->Seq = seq;
- if (SeqPtr == NO_SEQ) Step(0);
- else
- if (Time == 0) Step(SeqPtr);
- return s;
+bool SPRITE::Works(SPRITE *spr) {
+ if (spr)
+ if (spr->Ext) {
+ SNAIL::COM *c = spr->Ext->Take;
+ if (c != NULL) {
+ c += spr->TakePtr;
+ if (c->Ref == Ref)
+ if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now))
+ return true;
+ }
+ }
+ return false;
}
-bool SPRITE::SeqTest (int n)
-{
- if (n >= 0) return (SeqPtr == n);
- if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr);
- return true;
+SEQ *SPRITE::SetSeq(SEQ *seq) {
+ Expand();
+ register SEQ *s = Ext->Seq;
+ Ext->Seq = seq;
+ if (SeqPtr == NO_SEQ)
+ Step(0);
+ else if (Time == 0)
+ Step(SeqPtr);
+ return s;
}
-SNAIL::COM * SPRITE::SnList (SNLIST type)
-{
- register SPREXT * e = Ext;
- if (e) return (type == NEAR) ? e->Near : e->Take;
- return NULL;
+bool SPRITE::SeqTest(int n) {
+ if (n >= 0)
+ return (SeqPtr == n);
+ if (Ext)
+ return (Ext->Seq[SeqPtr].Next == SeqPtr);
+ return true;
}
-void SPRITE::SetName (char * n)
-{
- if (Ext)
- {
- if (Ext->Name)
- {
- delete[] Ext->Name;
- Ext->Name = NULL;
- }
- if (n)
- {
- if ((Ext->Name = new char[strlen(n)+1]) != NULL) strcpy(Ext->Name, n);
- else
- error("No core [%s]", n);
- }
- }
+SNAIL::COM *SPRITE::SnList(SNLIST type) {
+ register SPREXT *e = Ext;
+ if (e)
+ return (type == NEAR) ? e->Near : e->Take;
+ return NULL;
}
-SPRITE * SPRITE::Expand (void)
-{
- if (! Ext)
- {
- bool enbl = HEART::Enable;
- HEART::Enable = false;
- if ((Ext = new SPREXT) == NULL)
- error("No core");
- if (*File)
- {
- static const char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL };
- char line[LINE_MAX], fname[MAXPATH];
- BMP_PTR * shplist = new BMP_PTR [ShpCnt+1];
- SEQ * seq = NULL;
- int shpcnt = 0,
- seqcnt = 0,
- neacnt = 0,
- takcnt = 0,
- maxnow = 0,
- maxnxt = 0,
- lcnt = 0,
- len;
-
- SNAIL::COM * nea = NULL;
- SNAIL::COM * tak = NULL;
- MergeExt(fname, File, SPR_EXT);
- if (INI_FILE::Exist(fname)) // sprite description file exist
- {
- INI_FILE sprf(fname);
- if (! OK(sprf))
- error("Bad SPR [%s]", fname);
-
- while ((len = sprf.Read((uint8*)line)) != 0)
- {
- ++ lcnt;
- if (len && line[len-1] == '\n') line[-- len] = '\0';
- if (len == 0 || *line == '.') continue;
-
- switch (TakeEnum(Comd, strtok(line, " =\t")))
- {
- case 0 : // Name
- {
- SetName(strtok(NULL, "")); break;
- }
- case 1 : // Phase
- {
- shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/"));
- break;
- }
- case 2 : // Seq
- {
- seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq));
- if (seq == NULL)
- error("No core [%s]", fname);
- SEQ * s = &seq[seqcnt ++];
- s->Now = atoi(strtok(NULL, " \t,;/"));
- if (s->Now > maxnow) maxnow = s->Now;
- s->Next = atoi(strtok(NULL, " \t,;/"));
- switch (s->Next)
- {
- case 0xFF : s->Next = seqcnt; break;
- case 0xFE : s->Next = seqcnt-1; break;
- }
- if (s->Next > maxnxt) maxnxt = s->Next;
- s->Dx = atoi(strtok(NULL, " \t,;/"));
- s->Dy = atoi(strtok(NULL, " \t,;/"));
- s->Dly = atoi(strtok(NULL, " \t,;/"));
- break;
- }
- case 3 : // Near
- {
- if (NearPtr != NO_PTR)
- {
- nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea));
- if (nea == NULL)
- error("No core [%s]", fname);
- else
- {
- SNAIL::COM * c = &nea[neacnt ++];
- if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0)
- error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname);
- c->Ref = atoi(strtok(NULL, " \t,;/"));
- c->Val = atoi(strtok(NULL, " \t,;/"));
- c->Ptr = NULL;
- }
- }
- }
- break;
- case 4 : // Take
- {
- if (TakePtr != NO_PTR)
- {
- tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak));
- if (tak == NULL)
- error("No core [%s]", fname);
- else
- {
- SNAIL::COM * c = &tak[takcnt ++];
- if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0)
- error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname);
- c->Ref = atoi(strtok(NULL, " \t,;/"));
- c->Val = atoi(strtok(NULL, " \t,;/"));
- c->Ptr = NULL;
- }
- }
- break;
- }
- }
+void SPRITE::SetName(char *n) {
+ if (Ext) {
+ if (Ext->Name) {
+ delete[] Ext->Name;
+ Ext->Name = NULL;
+ }
+ if (n) {
+ if ((Ext->Name = new char[strlen(n) + 1]) != NULL)
+ strcpy(Ext->Name, n);
+ else
+ error("No core [%s]", n);
}
- }
- else // no sprite description: try to read immediately from .BMP
- {
- shplist[shpcnt ++] = new BITMAP(File);
- }
- shplist[shpcnt] = NULL;
- if (seq)
- {
- if (maxnow >= shpcnt)
- error("Bad PHASE in SEQ [%s]", fname);
- if (maxnxt >= seqcnt)
- error("Bad JUMP in SEQ [%s]", fname);
- SetSeq(seq);
- }
- else SetSeq((ShpCnt == 1) ? Seq1 : Seq2);
- //disable(); // disable interupt
-
- SetShapeList(shplist);
- //enable(); // enable interupt
- if (nea) nea[neacnt-1].Ptr = Ext->Near = nea; else NearPtr = NO_PTR;
- if (tak) tak[takcnt-1].Ptr = Ext->Take = tak; else TakePtr = NO_PTR;
}
- HEART::Enable = enbl;
- }
- return this;
}
-SPRITE * SPRITE::Contract (void)
-{
- register SPREXT * e = Ext;
- if (e)
- {
- if (e->Name) delete[] e->Name;
- if (Flags.BDel && e->ShpList)
- {
- int i;
- for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i];
- if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList;
+SPRITE *SPRITE::Expand(void) {
+ if (! Ext) {
+ bool enbl = HEART::Enable;
+ HEART::Enable = false;
+ if ((Ext = new SPREXT) == NULL)
+ error("No core");
+ if (*File) {
+ static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL };
+ char line[LINE_MAX], fname[MAXPATH];
+ BMP_PTR *shplist = new BMP_PTR [ShpCnt + 1];
+ SEQ *seq = NULL;
+ int shpcnt = 0,
+ seqcnt = 0,
+ neacnt = 0,
+ takcnt = 0,
+ maxnow = 0,
+ maxnxt = 0,
+ lcnt = 0,
+ len;
+
+ SNAIL::COM *nea = NULL;
+ SNAIL::COM *tak = NULL;
+ MergeExt(fname, File, SPR_EXT);
+ if (INI_FILE::Exist(fname)) { // sprite description file exist
+ INI_FILE sprf(fname);
+ if (! OK(sprf))
+ error("Bad SPR [%s]", fname);
+
+ while ((len = sprf.Read((uint8 *)line)) != 0) {
+ ++ lcnt;
+ if (len && line[len - 1] == '\n')
+ line[-- len] = '\0';
+ if (len == 0 || *line == '.')
+ continue;
+
+ switch (TakeEnum(Comd, strtok(line, " =\t"))) {
+ case 0 : { // Name
+ SetName(strtok(NULL, ""));
+ break;
+ }
+ case 1 : { // Phase
+ shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/"));
+ break;
+ }
+ case 2 : { // Seq
+ seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq));
+ if (seq == NULL)
+ error("No core [%s]", fname);
+ SEQ *s = &seq[seqcnt ++];
+ s->Now = atoi(strtok(NULL, " \t,;/"));
+ if (s->Now > maxnow)
+ maxnow = s->Now;
+ s->Next = atoi(strtok(NULL, " \t,;/"));
+ switch (s->Next) {
+ case 0xFF :
+ s->Next = seqcnt;
+ break;
+ case 0xFE :
+ s->Next = seqcnt - 1;
+ break;
+ }
+ if (s->Next > maxnxt)
+ maxnxt = s->Next;
+ s->Dx = atoi(strtok(NULL, " \t,;/"));
+ s->Dy = atoi(strtok(NULL, " \t,;/"));
+ s->Dly = atoi(strtok(NULL, " \t,;/"));
+ break;
+ }
+ case 3 : { // Near
+ if (NearPtr != NO_PTR) {
+ nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea));
+ if (nea == NULL)
+ error("No core [%s]", fname);
+ else {
+ SNAIL::COM *c = &nea[neacnt ++];
+ if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0)
+ error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname);
+ c->Ref = atoi(strtok(NULL, " \t,;/"));
+ c->Val = atoi(strtok(NULL, " \t,;/"));
+ c->Ptr = NULL;
+ }
+ }
+ }
+ break;
+ case 4 : { // Take
+ if (TakePtr != NO_PTR) {
+ tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak));
+ if (tak == NULL)
+ error("No core [%s]", fname);
+ else {
+ SNAIL::COM *c = &tak[takcnt ++];
+ if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0)
+ error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname);
+ c->Ref = atoi(strtok(NULL, " \t,;/"));
+ c->Val = atoi(strtok(NULL, " \t,;/"));
+ c->Ptr = NULL;
+ }
+ }
+ break;
+ }
+ }
+ }
+ } else { // no sprite description: try to read immediately from .BMP
+ shplist[shpcnt ++] = new BITMAP(File);
+ }
+ shplist[shpcnt] = NULL;
+ if (seq) {
+ if (maxnow >= shpcnt)
+ error("Bad PHASE in SEQ [%s]", fname);
+ if (maxnxt >= seqcnt)
+ error("Bad JUMP in SEQ [%s]", fname);
+ SetSeq(seq);
+ } else
+ SetSeq((ShpCnt == 1) ? Seq1 : Seq2);
+ //disable(); // disable interupt
+
+ SetShapeList(shplist);
+ //enable(); // enable interupt
+ if (nea)
+ nea[neacnt - 1].Ptr = Ext->Near = nea;
+ else
+ NearPtr = NO_PTR;
+ if (tak)
+ tak[takcnt - 1].Ptr = Ext->Take = tak;
+ else
+ TakePtr = NO_PTR;
+ }
+ HEART::Enable = enbl;
}
- if (MemType(e->Seq) == NEAR_MEM) free(e->Seq);
- if (e->Near) free(e->Near);
- if (e->Take) free(e->Take);
- delete e;
- Ext = NULL;
- }
- return this;
+ return this;
}
-SPRITE * SPRITE::BackShow (bool fast)
-{
- Expand();
- Show(2);
- Show(1);
- if (fast) Show(0);
- Contract();
- return this;
-}
-
-
-void SPRITE::Step (int nr)
-{
- if (nr >= 0) SeqPtr = nr;
- if (Ext)
- {
- SEQ * seq;
- if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next;
- seq = Ext->Seq + SeqPtr;
- if (seq->Dly >= 0)
- {
- Goto(X + (seq->Dx), Y + (seq->Dy));
- Time = seq->Dly;
+SPRITE *SPRITE::Contract(void) {
+ register SPREXT *e = Ext;
+ if (e) {
+ if (e->Name)
+ delete[] e->Name;
+ if (Flags.BDel && e->ShpList) {
+ int i;
+ for (i = 0; e->ShpList[i]; i ++)
+ delete e->ShpList[i];
+ if (MemType(e->ShpList) == NEAR_MEM)
+ delete[] e->ShpList;
+ }
+ if (MemType(e->Seq) == NEAR_MEM)
+ free(e->Seq);
+ if (e->Near)
+ free(e->Near);
+ if (e->Take)
+ free(e->Take);
+ delete e;
+ Ext = NULL;
}
- }
+ return this;
}
-void SPRITE::Tick (void)
-{
- Step();
-}
-
-
-void SPRITE::MakeXlat (uint8 * x)
-{
- if (Ext)
- {
- BMP_PTR * b;
-
- if (Flags.Xlat) KillXlat();
- for (b = Ext->ShpList; *b; b ++) (*b)->M = x;
- Flags.Xlat = true;
- }
+SPRITE *SPRITE::BackShow(bool fast) {
+ Expand();
+ Show(2);
+ Show(1);
+ if (fast)
+ Show(0);
+ Contract();
+ return this;
}
-void SPRITE::KillXlat (void)
-{
- if (Flags.Xlat && Ext)
- {
- BMP_PTR * b;
- uint8 * m = (*Ext->ShpList)->M;
-
- switch (MemType(m))
- {
- case NEAR_MEM : delete[] (uint8 *) m; break;
- case FAR_MEM : free(m); break;
+void SPRITE::Step(int nr) {
+ if (nr >= 0)
+ SeqPtr = nr;
+ if (Ext) {
+ SEQ *seq;
+ if (nr < 0)
+ SeqPtr = Ext->Seq[SeqPtr].Next;
+ seq = Ext->Seq + SeqPtr;
+ if (seq->Dly >= 0) {
+ Goto(X + (seq->Dx), Y + (seq->Dy));
+ Time = seq->Dly;
+ }
}
- for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL;
- Flags.Xlat = false;
- }
}
-void SPRITE::Goto (int x, int y)
-{
- int xo = X, yo = Y;
- if (W < SCR_WID)
- {
- if (x < 0) x = 0;
- if (x + W > SCR_WID) x = (SCR_WID - W);
- X = x;
- }
- if (H < SCR_HIG)
- {
- if (y < 0) y = 0;
- if (y + H > SCR_HIG) y = (SCR_HIG - H);
- Y = y;
- }
- if (Next) if (Next->Flags.Slav) Next->Goto(Next->X-xo+X, Next->Y-yo+Y);
- if (Flags.Shad) Prev->Goto(Prev->X-xo+X, Prev->Y-yo+Y);
+void SPRITE::Tick(void) {
+ Step();
}
-void SPRITE::Center (void)
-{
- Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2);
-}
-
+void SPRITE::MakeXlat(uint8 *x) {
+ if (Ext) {
+ BMP_PTR *b;
-void SPRITE::Show (void)
-{
- register SPREXT * e;
- // asm cli // critic section...
- e = Ext;
- e->x0 = e->x1;
- e->y0 = e->y1;
- e->b0 = e->b1;
- e->x1 = X;
- e->y1 = Y;
- e->b1 = Shp();
-// asm sti // ...done!
- if (! Flags.Hide)
- {
- if (Flags.Xlat) e->b1->XShow(e->x1, e->y1);
- else e->b1->Show(e->x1, e->y1);
- }
+ if (Flags.Xlat)
+ KillXlat();
+ for (b = Ext->ShpList; *b; b ++)
+ (*b)->M = x;
+ Flags.Xlat = true;
+ }
}
-void SPRITE::Show (uint16 pg)
-{
- uint8 * a = VGA::Page[1];
- VGA::Page[1] = VGA::Page[pg & 3];
- Shp()->Show(X, Y);
- VGA::Page[1] = a;
-}
-
+void SPRITE::KillXlat(void) {
+ if (Flags.Xlat && Ext) {
+ BMP_PTR *b;
+ uint8 *m = (*Ext->ShpList)->M;
-void SPRITE::Hide (void)
-{
- register SPREXT * e = Ext;
- if (e->b0) e->b0->Hide(e->x0, e->y0);
+ switch (MemType(m)) {
+ case NEAR_MEM :
+ delete[](uint8 *) m;
+ break;
+ case FAR_MEM :
+ free(m);
+ break;
+ }
+ for (b = Ext->ShpList; *b; b ++)
+ (*b)->M = NULL;
+ Flags.Xlat = false;
+ }
}
-BMP_PTR SPRITE::Ghost (void)
-{
- register SPREXT * e = Ext;
- if (e->b1)
- {
- BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL);
- if (bmp == NULL)
- error("No core");
- bmp->W = e->b1->W;
- bmp->H = e->b1->H;
- if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL)
- error("No Core");
- bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H);
- // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment
- //bmp->M = (uint8 *) MK_FP(e->y1, e->x1);
- return bmp;
- }
- return NULL;
+void SPRITE::Goto(int x, int y) {
+ int xo = X, yo = Y;
+ if (W < SCR_WID) {
+ if (x < 0)
+ x = 0;
+ if (x + W > SCR_WID)
+ x = (SCR_WID - W);
+ X = x;
+ }
+ if (H < SCR_HIG) {
+ if (y < 0)
+ y = 0;
+ if (y + H > SCR_HIG)
+ y = (SCR_HIG - H);
+ Y = y;
+ }
+ if (Next)
+ if (Next->Flags.Slav)
+ Next->Goto(Next->X - xo + X, Next->Y - yo + Y);
+ if (Flags.Shad)
+ Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y);
}
-SPRITE * SpriteAt (int x, int y)
-{
- SPRITE * spr = NULL, * tail = VGA::ShowQ.Last();
- if (tail)
- {
- for (spr = tail->Prev; spr; spr = spr->Prev)
- if (! spr->Flags.Hide && ! spr->Flags.Tran)
- if (spr->Shp()->SolidAt(x-spr->X, y-spr->Y))
- break;
- }
- return spr;
+void SPRITE::Center(void) {
+ Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2);
}
-QUEUE::QUEUE (bool show)
-: Head(NULL), Tail(NULL), Show(show)
-{
+void SPRITE::Show(void) {
+ register SPREXT *e;
+// asm cli // critic section...
+ e = Ext;
+ e->x0 = e->x1;
+ e->y0 = e->y1;
+ e->b0 = e->b1;
+ e->x1 = X;
+ e->y1 = Y;
+ e->b1 = Shp();
+// asm sti // ...done!
+ if (! Flags.Hide) {
+ if (Flags.Xlat) e->b1->XShow(e->x1, e->y1);
+ else e->b1->Show(e->x1, e->y1);
+ }
}
-QUEUE::~QUEUE (void)
-{
- Clear();
+void SPRITE::Show(uint16 pg) {
+ uint8 *a = VGA::Page[1];
+ VGA::Page[1] = VGA::Page[pg & 3];
+ Shp()->Show(X, Y);
+ VGA::Page[1] = a;
}
-void QUEUE::Clear (void)
-{
- while (Head)
- {
- SPRITE * s = Remove(Head);
- if (s->Flags.Kill) delete s;
- }
+void SPRITE::Hide(void) {
+ register SPREXT *e = Ext;
+ if (e->b0)
+ e->b0->Hide(e->x0, e->y0);
}
-void QUEUE::ForAll (void (*fun)(SPRITE *))
-{
- SPRITE * s = Head;
- while (s)
- {
- SPRITE * n = s->Next;
- fun(s);
- s = n;
- }
+BMP_PTR SPRITE::Ghost(void) {
+ register SPREXT *e = Ext;
+ if (e->b1) {
+ BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL);
+ if (bmp == NULL)
+ error("No core");
+ bmp->W = e->b1->W;
+ bmp->H = e->b1->H;
+ if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL)
+ error("No Core");
+ bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H);
+ // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment
+ //bmp->M = (uint8 *) MK_FP(e->y1, e->x1);
+ warning("FIXME: SPRITE::Ghost");
+ return bmp;
+ }
+ return NULL;
}
-void QUEUE::Append (SPRITE * spr)
-{
- if (Tail)
- {
- spr->Prev = Tail;
- Tail->Next = spr;
- }
- else Head = spr;
- Tail = spr;
- if (Show) spr->Expand();
- else spr->Contract();
+SPRITE *SpriteAt(int x, int y) {
+ SPRITE *spr = NULL, * tail = VGA::ShowQ.Last();
+ if (tail) {
+ for (spr = tail->Prev; spr; spr = spr->Prev)
+ if (! spr->Flags.Hide && ! spr->Flags.Tran)
+ if (spr->Shp()->SolidAt(x - spr->X, y - spr->Y))
+ break;
+ }
+ return spr;
}
-void QUEUE::Insert (SPRITE * spr, SPRITE * nxt)
-{
- if (nxt == Head)
- {
- spr->Next = Head;
- Head = spr;
- if (! Tail) Tail = spr;
- }
- else
- {
- spr->Next = nxt;
- spr->Prev = nxt->Prev;
- if (spr->Prev) spr->Prev->Next = spr;
- }
- if (spr->Next) spr->Next->Prev = spr;
- if (Show) spr->Expand();
- else spr->Contract();
+QUEUE::QUEUE(bool show) : Head(NULL), Tail(NULL), Show(show) {
}
-void QUEUE::Insert (SPRITE * spr)
-{
- SPRITE * s;
- for (s = Head; s; s = s->Next)
- if (s->Z > spr->Z)
- break;
- if (s) Insert(spr, s);
- else Append(spr);
- if (Show) spr->Expand();
- else spr->Contract();
+QUEUE::~QUEUE(void) {
+ Clear();
}
-SPRITE * QUEUE::Remove (SPRITE * spr)
-{
- if (spr == Head) Head = spr->Next;
- if (spr == Tail) Tail = spr->Prev;
- if (spr->Next) spr->Next->Prev = spr->Prev;
- if (spr->Prev) spr->Prev->Next = spr->Next;
- spr->Prev = NULL;
- spr->Next = NULL;
- return spr;
+void QUEUE::Clear(void) {
+ while (Head) {
+ SPRITE *s = Remove(Head);
+ if (s->Flags.Kill)
+ delete s;
+ }
}
-SPRITE * QUEUE::Locate (int ref)
-{
- SPRITE * spr;
- for (spr = Head; spr; spr = spr->Next) if (spr->Ref == ref) return spr;
- return NULL;
+void QUEUE::ForAll(void (*fun)(SPRITE *)) {
+ SPRITE *s = Head;
+ while (s) {
+ SPRITE *n = s->Next;
+ fun(s);
+ s = n;
+ }
}
-uint16 VGA::StatAdr = VGAST1_;
-uint16 VGA::OldMode = 0;
-uint16 * VGA::OldScreen = NULL;
-const char * VGA::Msg = NULL;
-const char * VGA::Nam = NULL;
-DAC * VGA::OldColors = NULL;
-DAC * VGA::NewColors = NULL;
-bool VGA::SetPal = false;
-int VGA::Mono = 0;
-QUEUE VGA::ShowQ = true, VGA::SpareQ = false;
+void QUEUE::Append(SPRITE *spr) {
+ if (Tail) {
+ spr->Prev = Tail;
+ Tail->Next = spr;
+ } else
+ Head = spr;
+ Tail = spr;
+ if (Show)
+ spr->Expand();
+ else
+ spr->Contract();
+}
+
+
+void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) {
+ if (nxt == Head) {
+ spr->Next = Head;
+ Head = spr;
+ if (! Tail)
+ Tail = spr;
+ } else {
+ spr->Next = nxt;
+ spr->Prev = nxt->Prev;
+ if (spr->Prev)
+ spr->Prev->Next = spr;
+ }
+ if (spr->Next)
+ spr->Next->Prev = spr;
+ if (Show)
+ spr->Expand();
+ else
+ spr->Contract();
+}
+
+
+void QUEUE::Insert(SPRITE *spr) {
+ SPRITE *s;
+ for (s = Head; s; s = s->Next)
+ if (s->Z > spr->Z)
+ break;
+ if (s)
+ Insert(spr, s);
+ else
+ Append(spr);
+ if (Show)
+ spr->Expand();
+ else
+ spr->Contract();
+}
+
+
+SPRITE *QUEUE::Remove(SPRITE *spr) {
+ if (spr == Head)
+ Head = spr->Next;
+ if (spr == Tail)
+ Tail = spr->Prev;
+ if (spr->Next)
+ spr->Next->Prev = spr->Prev;
+ if (spr->Prev)
+ spr->Prev->Next = spr->Next;
+ spr->Prev = NULL;
+ spr->Next = NULL;
+ return spr;
+}
+
+
+SPRITE *QUEUE::Locate(int ref) {
+ SPRITE *spr;
+ for (spr = Head; spr; spr = spr->Next)
+ if (spr->Ref == ref)
+ return spr;
+ return NULL;
+}
+
+
+uint16 VGA::StatAdr = VGAST1_;
+uint16 VGA::OldMode = 0;
+uint16 *VGA::OldScreen = NULL;
+const char *VGA::Msg = NULL;
+const char *VGA::Nam = NULL;
+DAC *VGA::OldColors = NULL;
+DAC *VGA::NewColors = NULL;
+bool VGA::SetPal = false;
+int VGA::Mono = 0;
+QUEUE VGA::ShowQ = true, VGA::SpareQ = false;
// TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that
-uint8 * VGA::Page[4] = { 0, 0, 0, 0 };
+uint8 *VGA::Page[4] = { 0, 0, 0, 0 };
/*
-uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000),
- (uint8 *) MK_FP(SCR_SEG, 0x4000),
- (uint8 *) MK_FP(SCR_SEG, 0x8000),
- (uint8 *) MK_FP(SCR_SEG, 0xC000) };
+uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000),
+ (uint8 *) MK_FP(SCR_SEG, 0x4000),
+ (uint8 *) MK_FP(SCR_SEG, 0x8000),
+ (uint8 *) MK_FP(SCR_SEG, 0xC000) };
*/
-
-
//extern const char Copr[];
-VGA::VGA (int mode)
-: FrmCnt(0)
-{
- bool std = true;
- int i;
- for (i = 10; i < 20; i ++)
- {
- char * txt = Text[i];
- if (txt)
- {
+VGA::VGA(int mode)
+ : FrmCnt(0) {
+ bool std = true;
+ int i;
+ for (i = 10; i < 20; i ++) {
+ char *txt = Text[i];
+ if (txt) {
// puts(txt);
- warning(txt);
- #ifndef DEBUG
- std = false;
- #endif
+ warning(txt);
+#ifndef DEBUG
+ std = false;
+#endif
+ }
}
- }
-// if (std)
+// if (std)
// warning(Copr);
- warning("TODO: Fix Copr");
-
- SetStatAdr();
- if (StatAdr != VGAST1_) ++ Mono;
- if (IsVga())
- {
- OldColors = farnew(DAC, 256);
- NewColors = farnew(DAC, 256);
- OldScreen = SaveScreen();
- GetColors(OldColors);
- Sunset();
- OldMode = SetMode(mode);
- SetColors();
- Setup(VideoMode);
- Clear();
- }
+ warning("TODO: Fix Copr");
+
+ SetStatAdr();
+ if (StatAdr != VGAST1_)
+ ++Mono;
+ if (IsVga()) {
+ OldColors = farnew(DAC, 256);
+ NewColors = farnew(DAC, 256);
+ OldScreen = SaveScreen();
+ GetColors(OldColors);
+ Sunset();
+ OldMode = SetMode(mode);
+ SetColors();
+ Setup(VideoMode);
+ Clear();
+ }
}
-VGA::~VGA (void)
-{
- Mono = 0;
- if (IsVga())
- {
- Common::String buffer = "";
- Clear();
- SetMode(OldMode);
- SetColors();
- RestoreScreen(OldScreen);
- Sunrise(OldColors);
- if (OldColors) free(OldColors);
- if (NewColors) free(NewColors);
- if (Msg)
- buffer = Common::String(Msg);
- if (Nam)
- buffer = buffer + " [" + Nam + "]";
-
- warning(buffer.c_str());
- }
+VGA::~VGA(void) {
+ Mono = 0;
+ if (IsVga()) {
+ Common::String buffer = "";
+ Clear();
+ SetMode(OldMode);
+ SetColors();
+ RestoreScreen(OldScreen);
+ Sunrise(OldColors);
+ if (OldColors)
+ free(OldColors);
+ if (NewColors)
+ free(NewColors);
+ if (Msg)
+ buffer = Common::String(Msg);
+ if (Nam)
+ buffer = buffer + " [" + Nam + "]";
+
+ warning(buffer.c_str());
+ }
}
-void VGA::SetStatAdr (void)
-{
+void VGA::SetStatAdr(void) {
/*
- asm mov dx,VGAMIr_
- asm in al,dx
- asm test al,1 // CGA addressing mode flag
- asm mov ax,VGAST1_ // CGA addressing
- asm jnz set_mode_adr
- asm xor al,0x60 // MDA addressing
- set_mode_adr:
- StatAdr = _AX;
- */
+ asm mov dx,VGAMIr_
+ asm in al,dx
+ asm test al,1 // CGA addressing mode flag
+ asm mov ax,VGAST1_ // CGA addressing
+ asm jnz set_mode_adr
+ asm xor al,0x60 // MDA addressing
+ set_mode_adr:
+ StatAdr = _AX;
+ */
warning("STUB: VGA::SetStatADR");
}
#pragma argsused
-void VGA::WaitVR (bool on)
-{
-/*
- _DX = StatAdr;
- _AH = (on) ? 0x00 : 0x08;
-
- asm mov cx,2
- // wait for vertical retrace on (off)
- wait:
- asm in al,dx
- asm xor al,ah
- asm test al,0x08
- asm jnz wait
- asm xor ah,0x08
- asm loop wait
- */
+void VGA::WaitVR(bool on) {
+ /*
+ _DX = StatAdr;
+ _AH = (on) ? 0x00 : 0x08;
+
+ asm mov cx,2
+ // wait for vertical retrace on (off)
+ wait:
+ asm in al,dx
+ asm xor al,ah
+ asm test al,0x08
+ asm jnz wait
+ asm xor ah,0x08
+ asm loop wait
+ */
warning("STUB: VGA::WaitVR");
}
-void VGA::Setup (VgaRegBlk * vrb)
-{
-/*
- WaitVR(); // *--LOOK!--* resets VGAATR logic
- asm cld
- asm mov si, vrb // take address of parameter table
- asm mov dh,0x03 // higher byte of I/O address is always 3
-
- s:
- asm lodsw // take lower byte of I/O address and index
- asm or ah,ah // 0 = end of table
- asm jz xit // no more: exit
- asm or al,al // indexed register?
- asm js single // 7th bit set means single register
- asm mov dl,ah // complete I/O address
- asm out dx,al // put index into control register
- asm inc dx // data register is next to control
- asm in al,dx // take old data
-
- write:
- asm mov cl,al // preserve old data
- asm lodsw // take 2 masks from table
- asm xor al,0xFF // invert mask bits
- asm and al,cl // clear bits with "clr" mask
- asm or al,ah // set bits with "set" mask
- asm cmp dl,0xC1 // special case?
- asm jne std2 // no: standard job, otherwise...
- asm dec dx // data out reg shares address with index
- std2:
- asm out dx,al // write new value to register
- asm jmp s
-
- single: // read address in al, write address in ah
- asm mov dl,al // complete I/O read address
- asm in al,dx // take old data
- asm mov dl,ah // complete I/O write address
- asm jmp write // continue standard routine
-
- xit:
- */
+void VGA::Setup(VgaRegBlk *vrb) {
+ /*
+ WaitVR(); // *--LOOK!--* resets VGAATR logic
+ asm cld
+ asm mov si, vrb // take address of parameter table
+ asm mov dh,0x03 // higher byte of I/O address is always 3
+
+ s:
+ asm lodsw // take lower byte of I/O address and index
+ asm or ah,ah // 0 = end of table
+ asm jz xit // no more: exit
+ asm or al,al // indexed register?
+ asm js single // 7th bit set means single register
+ asm mov dl,ah // complete I/O address
+ asm out dx,al // put index into control register
+ asm inc dx // data register is next to control
+ asm in al,dx // take old data
+
+ write:
+ asm mov cl,al // preserve old data
+ asm lodsw // take 2 masks from table
+ asm xor al,0xFF // invert mask bits
+ asm and al,cl // clear bits with "clr" mask
+ asm or al,ah // set bits with "set" mask
+ asm cmp dl,0xC1 // special case?
+ asm jne std2 // no: standard job, otherwise...
+ asm dec dx // data out reg shares address with index
+ std2:
+ asm out dx,al // write new value to register
+ asm jmp s
+
+ single: // read address in al, write address in ah
+ asm mov dl,al // complete I/O read address
+ asm in al,dx // take old data
+ asm mov dl,ah // complete I/O write address
+ asm jmp write // continue standard routine
+
+ xit:
+ */
warning("STUB: VGA::Setup");
}
-int VGA::SetMode(int mode)
-{
-/*
- Clear();
- // get current mode
- asm mov ah,0x0F
- Video(); // BIOS video service
- asm xor ah,ah
- asm push ax
-
- // wait for v-retrace
- WaitVR();
-
- // set mode
- asm xor ah,ah
- asm mov al,byte ptr mode
- Video(); // BIOS video service
- SetStatAdr();
- // return previous mode
- asm pop ax
- return _AX;
- */
- warning("STUB: VGA::SetMode");
+int VGA::SetMode(int mode) {
+ /*
+ Clear();
+ // get current mode
+ asm mov ah,0x0F
+ Video(); // BIOS video service
+ asm xor ah,ah
+ asm push ax
+
+ // wait for v-retrace
+ WaitVR();
+
+ // set mode
+ asm xor ah,ah
+ asm mov al,byte ptr mode
+ Video(); // BIOS video service
+ SetStatAdr();
+ // return previous mode
+ asm pop ax
+ return _AX;
+ */
+ warning("STUB: VGA::SetMode");
return 0;
}
-void VGA::GetColors(DAC * tab)
-{
-/*
- asm cld
- asm les di,tab // color table
- asm mov dx,0x3C7 // PEL address read mode register
- asm xor al,al // start from address 0
- asm out dx,al // put address
- asm mov cx,256*3 // # of colors
- asm mov dl,0xC9 // PEL data register
-
-// asm rep insb // very fast!
-
- gc: // much slower:
- asm in al,dx // take 1 color
- asm jmp sto // little delay
- sto:
- asm stosb // store 1 color
- asm loop gc // next one?
- */
+void VGA::GetColors(DAC *tab) {
+ /*
+ asm cld
+ asm les di,tab // color table
+ asm mov dx,0x3C7 // PEL address read mode register
+ asm xor al,al // start from address 0
+ asm out dx,al // put address
+ asm mov cx,256*3 // # of colors
+ asm mov dl,0xC9 // PEL data register
+
+ // asm rep insb // very fast!
+
+ gc: // much slower:
+ asm in al,dx // take 1 color
+ asm jmp sto // little delay
+ sto:
+ asm stosb // store 1 color
+ asm loop gc // next one?
+ */
warning("STUB: VGA::GetColors");
}
-void VGA::SetColors(DAC * tab, int lum)
-{
-/*
- DAC * des = NewColors;
- asm push ds
-
- asm les di,des
- asm lds si,tab
- asm mov cx,256*3
- asm xor bx,bx
- asm mov dx,lum
-
- copcol:
- asm mov al,[si+bx]
- asm mul dl
- asm shr ax,6
- asm mov es:[di+bx],al
- asm inc bx
- asm cmp bx,cx
- asm jb copcol
-
- asm pop ds
-
- if (Mono)
- {
- asm add cx,di
- mono:
- asm xor dx,dx
- asm mov al,77 // 30% R
- asm mul byte ptr es:[di].0
- asm add dx,ax
- asm mov al,151 // 59% G
- asm mul byte ptr es:[di].1
- asm add dx,ax
- asm mov al,28 // 11% B
- asm mul byte ptr es:[di].2
- asm add dx,ax
-
- asm mov es:[di].0,dh
- asm mov es:[di].1,dh
- asm mov es:[di].2,dh
-
- asm add di,3
- asm cmp di,cx
- asm jb mono
- }
- */
- SetPal = true;
- warning("STUB: VGA::SetColors");
+void VGA::SetColors(DAC *tab, int lum) {
+ /*
+ DAC * des = NewColors;
+ asm push ds
+
+ asm les di,des
+ asm lds si,tab
+ asm mov cx,256*3
+ asm xor bx,bx
+ asm mov dx,lum
+
+ copcol:
+ asm mov al,[si+bx]
+ asm mul dl
+ asm shr ax,6
+ asm mov es:[di+bx],al
+ asm inc bx
+ asm cmp bx,cx
+ asm jb copcol
+
+ asm pop ds
+
+ if (Mono)
+ {
+ asm add cx,di
+ mono:
+ asm xor dx,dx
+ asm mov al,77 // 30% R
+ asm mul byte ptr es:[di].0
+ asm add dx,ax
+ asm mov al,151 // 59% G
+ asm mul byte ptr es:[di].1
+ asm add dx,ax
+ asm mov al,28 // 11% B
+ asm mul byte ptr es:[di].2
+ asm add dx,ax
+
+ asm mov es:[di].0,dh
+ asm mov es:[di].1,dh
+ asm mov es:[di].2,dh
+
+ asm add di,3
+ asm cmp di,cx
+ asm jb mono
+ }
+ */
+ SetPal = true;
+ warning("STUB: VGA::SetColors");
}
-void VGA::SetColors (void)
-{
- memset(NewColors, 0, PAL_SIZ);
- UpdateColors();
+void VGA::SetColors(void) {
+ memset(NewColors, 0, PAL_SIZ);
+ UpdateColors();
}
-void VGA::Sunrise (DAC * tab)
-{
- int i;
- for (i = 0; i <= 64; i += FADE_STEP)
- {
- SetColors(tab, i);
- WaitVR();
- UpdateColors();
- }
+void VGA::Sunrise(DAC *tab) {
+ for (int i = 0; i <= 64; i += FADE_STEP) {
+ SetColors(tab, i);
+ WaitVR();
+ UpdateColors();
+ }
}
-void VGA::Sunset (void)
-{
- DAC tab[256];
- int i;
- GetColors(tab);
- for (i = 64; i >= 0; i -= FADE_STEP)
- {
- SetColors(tab, i);
- WaitVR();
- UpdateColors();
- }
+void VGA::Sunset(void) {
+ DAC tab[256];
+ GetColors(tab);
+ for (int i = 64; i >= 0; i -= FADE_STEP) {
+ SetColors(tab, i);
+ WaitVR();
+ UpdateColors();
+ }
}
-void VGA::Show (void)
-{
- SPRITE * spr = ShowQ.First();
+void VGA::Show(void) {
+ SPRITE *spr = ShowQ.First();
- for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show();
- Update();
- for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide();
+ for (spr = ShowQ.First(); spr; spr = spr->Next)
+ spr->Show();
+ Update();
+ for (spr = ShowQ.First(); spr; spr = spr->Next)
+ spr->Hide();
- ++ FrmCnt;
+ ++ FrmCnt;
}
-void VGA::UpdateColors(void)
-{
-/*
- DAC * tab = NewColors;
+void VGA::UpdateColors(void) {
+ /*
+ DAC * tab = NewColors;
- asm push ds
- asm cld
- asm lds si,tab // color table
- asm mov dx,0x3C8 // PEL address write mode register
- asm xor al,al // start from address 0
- asm out dx,al // put address
- asm mov cx,256*3 // # of colors
- asm mov dl,0xC9 // PEL data register
+ asm push ds
+ asm cld
+ asm lds si,tab // color table
+ asm mov dx,0x3C8 // PEL address write mode register
+ asm xor al,al // start from address 0
+ asm out dx,al // put address
+ asm mov cx,256*3 // # of colors
+ asm mov dl,0xC9 // PEL data register
-// asm rep outsb // very fast!
+ // asm rep outsb // very fast!
- // the slower version of above:
- sc:
- asm lodsb // take 1/3 color
- asm out dx,al // put 1/3 color
- asm jmp loop // little delay
- loop:
- asm loop sc // next one?
+ // the slower version of above:
+ sc:
+ asm lodsb // take 1/3 color
+ asm out dx,al // put 1/3 color
+ asm jmp loop // little delay
+ loop:
+ asm loop sc // next one?
- asm pop ds
- */
- warning("STUB: VGA::UpdateColors");
+ asm pop ds
+ */
+ warning("STUB: VGA::UpdateColors");
}
-void VGA::Update(void)
-{
-/*
- uint8 * p = Page[1];
- Page[1] = Page[0];
- Page[0] = p;
-
- asm mov dx,VGACRT_
- asm mov al,0x0D
- asm mov ah,byte ptr p
- asm out dx,ax
- asm dec al
- asm mov ah,byte ptr p+1
- asm out dx,ax
-*/
- if (! SpeedTest) WaitVR();
+void VGA::Update(void) {
+ /*
+ uint8 * p = Page[1];
+ Page[1] = Page[0];
+ Page[0] = p;
+
+ asm mov dx,VGACRT_
+ asm mov al,0x0D
+ asm mov ah,byte ptr p
+ asm out dx,ax
+ asm dec al
+ asm mov ah,byte ptr p+1
+ asm out dx,ax
+ */
+ if (! SpeedTest) WaitVR();
- if (SetPal)
- {
- UpdateColors();
- SetPal = false;
- }
- warning("STUB: VGA::Update");
+ if (SetPal) {
+ UpdateColors();
+ SetPal = false;
+ }
+ warning("STUB: VGA::Update");
}
-void VGA::Clear(uint8 color)
-{
-/*
- uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0);
+void VGA::Clear(uint8 color) {
+ /*
+ uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0);
- asm mov dx,VGASEQ_
- asm mov ax,0x0F02 // map mask register - enable all planes
- asm out dx,ax
- asm les di,a
- asm cld
+ asm mov dx,VGASEQ_
+ asm mov ax,0x0F02 // map mask register - enable all planes
+ asm out dx,ax
+ asm les di,a
+ asm cld
- asm mov cx,0xFFFF
- asm mov al,color
- asm rep stosb
- asm stosb
- */
- warning("STUB: VGA::Clear");
+ asm mov cx,0xFFFF
+ asm mov al,color
+ asm rep stosb
+ asm stosb
+ */
+ warning("STUB: VGA::Clear");
}
-void VGA::CopyPage(uint16 d, uint16 s)
-{
-/*
- uint8 * S = Page[s & 3], * D = Page[d & 3];
+void VGA::CopyPage(uint16 d, uint16 s) {
+ /*
+ uint8 * S = Page[s & 3], * D = Page[d & 3];
- asm mov dx,VGAGRA_
- asm mov al,0x05 // R/W mode
- asm out dx,al
- asm inc dx
- asm in al,dx
- asm and al,0xF4
- asm push ax
- asm push dx
- asm or al,0x01
- asm out dx,al
+ asm mov dx,VGAGRA_
+ asm mov al,0x05 // R/W mode
+ asm out dx,al
+ asm inc dx
+ asm in al,dx
+ asm and al,0xF4
+ asm push ax
+ asm push dx
+ asm or al,0x01
+ asm out dx,al
- asm mov dx,VGASEQ_
- asm mov ax,0x0F02 // map mask register - enable all planes
- asm out dx,ax
+ asm mov dx,VGASEQ_
+ asm mov ax,0x0F02 // map mask register - enable all planes
+ asm out dx,ax
- asm push ds
+ asm push ds
- asm les di,D
- asm lds si,S
- asm cld
- asm mov cx,0x4000
- asm rep movsb
+ asm les di,D
+ asm lds si,S
+ asm cld
+ asm mov cx,0x4000
+ asm rep movsb
- asm pop ds
+ asm pop ds
- asm pop dx
- asm pop ax
- asm out dx,al // end of copy mode
- */
- warning("STUB: VGA::CopyPage");
+ asm pop dx
+ asm pop ax
+ asm out dx,al // end of copy mode
+ */
+ warning("STUB: VGA::CopyPage");
}
//--------------------------------------------------------------------------
-void BITMAP::XShow(int x, int y)
-{
-/*
- uint8 rmsk = x % 4,
- mask = 1 << rmsk,
- * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4;
- uint8 * m = (char *) M;
- uint8 * v = V;
-
- asm push bx
- asm push si
- asm push ds
-
- asm cld
- asm les di,scr
- asm lds si,v
- asm mov bx,m
-
- asm mov al,0x02 // map mask register
- asm mov ah,mask
-
- plane:
- // enable output plane
- asm mov dx,VGASEQ_
- asm out dx,ax
- asm push ax
-
- // select input plane
- asm mov dx,VGAGRA_
- asm mov al,0x04 // read map select register
- asm mov ah,rmsk
- asm out dx,ax
-
- asm push di
-
- block:
- asm lodsw
- asm mov cx,ax
- asm and ch,0x3F
- asm test ah,0xC0
- asm jz endpl
- asm jns skip
- asm jnp incsi // replicate?
- asm add si,cx // skip over data block
- asm dec si // fix it before following inc
-
- incsi:
- asm inc si
- tint:
- asm mov al,es:[di]
- //-----------------------------------------------
- // asm xlat ss:0 // unsupported with BASM!
- __emit__(0x36, 0xD7); // this stands for above!
- //-----------------------------------------------
- asm stosb
- asm loop tint
- asm jmp block
-
- skip:
- asm add di,cx
- asm jmp block
-
- endpl:
- asm pop di
- asm pop ax
- asm inc rmsk
- asm shl ah,1
- asm test ah,0x10
- asm jz x_chk
- asm mov ah,0x01
- asm mov rmsk,0
- asm inc di
- x_chk:
- asm cmp ah,mask
- asm jne plane
- asm pop ds
- asm pop si
- asm pop bx
- */
+void BITMAP::XShow(int x, int y) {
+ /*
+ uint8 rmsk = x % 4,
+ mask = 1 << rmsk,
+ * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4;
+ uint8 * m = (char *) M;
+ uint8 * v = V;
+
+ asm push bx
+ asm push si
+ asm push ds
+
+ asm cld
+ asm les di,scr
+ asm lds si,v
+ asm mov bx,m
+
+ asm mov al,0x02 // map mask register
+ asm mov ah,mask
+
+ plane:
+ // enable output plane
+ asm mov dx,VGASEQ_
+ asm out dx,ax
+ asm push ax
+
+ // select input plane
+ asm mov dx,VGAGRA_
+ asm mov al,0x04 // read map select register
+ asm mov ah,rmsk
+ asm out dx,ax
+
+ asm push di
+
+ block:
+ asm lodsw
+ asm mov cx,ax
+ asm and ch,0x3F
+ asm test ah,0xC0
+ asm jz endpl
+ asm jns skip
+ asm jnp incsi // replicate?
+ asm add si,cx // skip over data block
+ asm dec si // fix it before following inc
+
+ incsi:
+ asm inc si
+ tint:
+ asm mov al,es:[di]
+ //-----------------------------------------------
+ // asm xlat ss:0 // unsupported with BASM!
+ __emit__(0x36, 0xD7); // this stands for above!
+ //-----------------------------------------------
+ asm stosb
+ asm loop tint
+ asm jmp block
+
+ skip:
+ asm add di,cx
+ asm jmp block
+
+ endpl:
+ asm pop di
+ asm pop ax
+ asm inc rmsk
+ asm shl ah,1
+ asm test ah,0x10
+ asm jz x_chk
+ asm mov ah,0x01
+ asm mov rmsk,0
+ asm inc di
+ x_chk:
+ asm cmp ah,mask
+ asm jne plane
+ asm pop ds
+ asm pop si
+ asm pop bx
+ */
warning("STUB: BITMAP::XShow");
}
-void BITMAP::Show(int x, int y)
-{
+void BITMAP::Show(int x, int y) {
/*
- uint8 mask = 1 << (x & 3),
- * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2);
- uint8 * v = V;
-
- asm push ds // preserve DS
-
- asm cld // normal direction
- asm les di,scr // screen address
- asm lds si,v // picture address
- asm mov dx,VGASEQ_ // VGA reg
- asm mov al,0x02
- asm mov ah,mask
-
- plane:
- asm out dx,ax
- asm push ax
- asm push di
-
- block:
- asm mov cx,[si] // with ADD faster then LODSW
- asm add si,2
- asm test ch,0xC0
- asm jns skip // 1 (SKP) or 0 (EOI)
- asm jpo repeat // 2 (REP)
-
- copy: // 3 (CPY)
- asm and ch,0x3F
- asm shr cx,1
- asm rep movsw
- asm jnc block
- asm movsb
- asm jmp block
-
- repeat:
- asm and ch,0x3F
- asm mov al,[si]
- asm inc si
- asm mov ah,al
- asm shr cx,1
- asm rep stosw
- asm jnc block
- asm mov es:[di],al
- asm inc di
- asm jmp block
-
- skip:
- asm jz endpl
- asm and ch,0x3F
- asm add di,cx
- asm jmp block
-
- endpl:
- asm pop di
- asm pop ax
- asm shl ah,1
- asm test ah,0x10
- asm jz x_chk
- asm mov ah,0x01
- asm inc di
- x_chk:
- asm cmp ah,mask
- asm jne plane
- asm pop ds
+ uint8 mask = 1 << (x & 3),
+ * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2);
+ uint8 * v = V;
+
+ asm push ds // preserve DS
+
+ asm cld // normal direction
+ asm les di,scr // screen address
+ asm lds si,v // picture address
+ asm mov dx,VGASEQ_ // VGA reg
+ asm mov al,0x02
+ asm mov ah,mask
+
+ plane:
+ asm out dx,ax
+ asm push ax
+ asm push di
+
+ block:
+ asm mov cx,[si] // with ADD faster then LODSW
+ asm add si,2
+ asm test ch,0xC0
+ asm jns skip // 1 (SKP) or 0 (EOI)
+ asm jpo repeat // 2 (REP)
+
+ copy: // 3 (CPY)
+ asm and ch,0x3F
+ asm shr cx,1
+ asm rep movsw
+ asm jnc block
+ asm movsb
+ asm jmp block
+
+ repeat:
+ asm and ch,0x3F
+ asm mov al,[si]
+ asm inc si
+ asm mov ah,al
+ asm shr cx,1
+ asm rep stosw
+ asm jnc block
+ asm mov es:[di],al
+ asm inc di
+ asm jmp block
+
+ skip:
+ asm jz endpl
+ asm and ch,0x3F
+ asm add di,cx
+ asm jmp block
+
+ endpl:
+ asm pop di
+ asm pop ax
+ asm shl ah,1
+ asm test ah,0x10
+ asm jz x_chk
+ asm mov ah,0x01
+ asm inc di
+ x_chk:
+ asm cmp ah,mask
+ asm jne plane
+ asm pop ds
*/
warning("STUB: BITMAP::Show");
}
-void BITMAP::Hide(int x, int y)
-{
-/*
- uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4;
- uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]);
- HideDesc * b = B;
- uint16 extra = ((x & 3) != 0);
- uint16 h = H;
-
-// asm push bx
- asm push si
- asm push ds
-
- asm cld
- asm les di,scr
- asm mov si,di
- asm add si,d // take bytes from background page
- asm lds bx,b
-
- asm mov dx,VGAGRA_
- asm mov al,0x05 // R/W mode
- asm out dx,al
- asm inc dx
- asm in al,dx
- asm and al,0xF4
- asm push ax
- asm push dx
- asm or al,0x01
- asm out dx,al
-
- asm mov dx,VGASEQ_
- asm mov ax,0x0F02 // enable all planes
- asm out dx,ax
-
- asm mov dx,ds // save DS
-
- row:
-// skip block
- asm mov cx,[bx]
- asm add si,cx
- asm add di,cx
- asm mov cx,[bx+2]
- asm add bx,4
- asm add cx,extra
-
- asm push es
- asm pop ds // set DS to video seg
- asm rep movsb // move bytes fast
- asm sub si,extra
- asm sub di,extra
- asm mov ds,dx // restore DS
-
- asm dec h
- asm jnz row
-
- asm pop dx
- asm pop ax
- asm out dx,al // end of copy mode
-
-
- asm pop ds
- asm pop si
-// asm pop bx
-*/
+void BITMAP::Hide(int x, int y) {
+ /*
+ uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4;
+ uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]);
+ HideDesc * b = B;
+ uint16 extra = ((x & 3) != 0);
+ uint16 h = H;
+
+ // asm push bx
+ asm push si
+ asm push ds
+
+ asm cld
+ asm les di,scr
+ asm mov si,di
+ asm add si,d // take bytes from background page
+ asm lds bx,b
+
+ asm mov dx,VGAGRA_
+ asm mov al,0x05 // R/W mode
+ asm out dx,al
+ asm inc dx
+ asm in al,dx
+ asm and al,0xF4
+ asm push ax
+ asm push dx
+ asm or al,0x01
+ asm out dx,al
+
+ asm mov dx,VGASEQ_
+ asm mov ax,0x0F02 // enable all planes
+ asm out dx,ax
+
+ asm mov dx,ds // save DS
+
+ row:
+ // skip block
+ asm mov cx,[bx]
+ asm add si,cx
+ asm add di,cx
+ asm mov cx,[bx+2]
+ asm add bx,4
+ asm add cx,extra
+
+ asm push es
+ asm pop ds // set DS to video seg
+ asm rep movsb // move bytes fast
+ asm sub si,extra
+ asm sub di,extra
+ asm mov ds,dx // restore DS
+
+ asm dec h
+ asm jnz row
+
+ asm pop dx
+ asm pop ax
+ asm out dx,al // end of copy mode
+
+
+ asm pop ds
+ asm pop si
+ // asm pop bx
+ */
warning("STUB: BITMAP::Hide");
}
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index f1a4b498c4..810e781808 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -25,295 +25,290 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __VGA13H__
-#define __VGA13H__
+#ifndef __VGA13H__
+#define __VGA13H__
-#include "cge/general.h"
-#include <stddef.h>
-//#include <dir.h>
-#include "cge/bitmap.h"
-#include "cge/snail.h"
+#include "cge/general.h"
+#include <stddef.h>
+#include "cge/bitmap.h"
+#include "cge/snail.h"
namespace CGE {
-#define TMR_RATE1 16
-#define TMR_RATE2 4
-#define TMR_RATE (TMR_RATE1*TMR_RATE2)
+#define TMR_RATE1 16
+#define TMR_RATE2 4
+#define TMR_RATE (TMR_RATE1 * TMR_RATE2)
-#define MAX_NAME 20
-#define VIDEO 0x10
+#define MAX_NAME 20
+#define VIDEO 0x10
-#define NO_CLEAR 0x80
-#define TEXT_MODE 0x03
-#define M13H 0x13
+#define NO_CLEAR 0x80
+#define TEXT_MODE 0x03
+#define M13H 0x13
-#ifndef SCR_WID
- #define SCR_WID 320
+#ifndef SCR_WID
+#define SCR_WID 320
#endif
-#ifndef SCR_HIG
- #define SCR_HIG 200
+#ifndef SCR_HIG
+#define SCR_HIG 200
#endif
#if 0
- #define LIGHT 0xFF
- #define DARK 0x00
- #define DGRAY 0xF6
- #define GRAY 0xFC
- #define LGRAY 0xFF
+#define LIGHT 0xFF
+#define DARK 0x00
+#define DGRAY 0xF6
+#define GRAY 0xFC
+#define LGRAY 0xFF
#else
- #define LIGHT 0xFF
- #define DARK 207
- #define DGRAY 225 /*219*/
- #define GRAY 231
- #define LGRAY 237
+#define LIGHT 0xFF
+#define DARK 207
+#define DGRAY 225 /*219*/
+#define GRAY 231
+#define LGRAY 237
#endif
-#define NO_SEQ (-1)
-#define NO_PTR ((uint8)-1)
-
-#define SPR_EXT ".SPR"
-
-#define IsFile(s) (access(s,0)==0)
-#define IsWrit(s) (access(s,2)==0)
-
-
-
-typedef struct { uint16 r : 2; uint16 R : 6;
- uint16 g : 2; uint16 G : 6;
- uint16 b : 2; uint16 B : 6;
- } RGB;
-
-typedef union {
- DAC dac;
- RGB rgb;
- } TRGB;
-
-typedef struct { uint8 idx, adr; uint8 clr, set; } VgaRegBlk;
-
-typedef struct { uint8 Now, Next; signed char Dx, Dy; int Dly; } SEQ;
-
-extern SEQ Seq1[];
-extern SEQ Seq2[];
-//extern SEQ * Compass[];
-//extern SEQ TurnToS[];
-
-
-#define PAL_CNT 256
-#define PAL_SIZ (PAL_CNT*sizeof(DAC))
-
-#define VGAATR_ 0x3C0
-#define VGAMIw_ 0x3C0
-#define VGASEQ_ 0x3C4
-#define VGAMIr_ 0x3CC
-#define VGAGRA_ 0x3CE
-#define VGACRT_ 0x3D4
-#define VGAST1_ 0x3DA
-#define VGAATR (VGAATR_ & 0xFF)
-#define VGAMIw (VGAMIw_ & 0xFF)
-#define VGASEQ (VGASEQ_ & 0xFF)
-#define VGAMIr (VGAMIr_ & 0xFF)
-#define VGAGRA (VGAGRA_ & 0xFF)
-#define VGACRT (VGACRT_ & 0xFF)
-#define VGAST1 (VGAST1_ & 0xFF)
-
-
-
-
-
-
-class HEART : public ENGINE
-{
- friend ENGINE;
+#define NO_SEQ (-1)
+#define NO_PTR ((uint8)-1)
+
+#define SPR_EXT ".SPR"
+
+#define IsFile(s) (access(s, 0) == 0)
+#define IsWrit(s) (access(s, 2) == 0)
+
+
+
+typedef struct {
+ uint16 r : 2;
+ uint16 R : 6;
+ uint16 g : 2;
+ uint16 G : 6;
+ uint16 b : 2;
+ uint16 B : 6;
+} RGB;
+
+typedef union {
+ DAC dac;
+ RGB rgb;
+} TRGB;
+
+typedef struct {
+ uint8 idx, adr;
+ uint8 clr, set;
+} VgaRegBlk;
+
+typedef struct {
+ uint8 Now, Next;
+ signed char Dx, Dy;
+ int Dly;
+} SEQ;
+
+extern SEQ Seq1[];
+extern SEQ Seq2[];
+//extern SEQ * Compass[];
+//extern SEQ TurnToS[];
+
+
+#define PAL_CNT 256
+#define PAL_SIZ (PAL_CNT * sizeof(DAC))
+#define VGAATR_ 0x3C0
+#define VGAMIw_ 0x3C0
+#define VGASEQ_ 0x3C4
+#define VGAMIr_ 0x3CC
+#define VGAGRA_ 0x3CE
+#define VGACRT_ 0x3D4
+#define VGAST1_ 0x3DA
+#define VGAATR (VGAATR_ & 0xFF)
+#define VGAMIw (VGAMIw_ & 0xFF)
+#define VGASEQ (VGASEQ_ & 0xFF)
+#define VGAMIr (VGAMIr_ & 0xFF)
+#define VGAGRA (VGAGRA_ & 0xFF)
+#define VGACRT (VGACRT_ & 0xFF)
+#define VGAST1 (VGAST1_ & 0xFF)
+
+
+class HEART : public ENGINE {
+ friend ENGINE;
public:
- static bool Enable;
- static uint16 * XTimer;
- static void SetXTimer (uint16 * ptr);
- static void SetXTimer (uint16 * ptr, uint16 time);
- HEART (void);
+ static bool Enable;
+ static uint16 *XTimer;
+ static void SetXTimer(uint16 *ptr);
+ static void SetXTimer(uint16 *ptr, uint16 time);
+ HEART(void);
};
-
-
-
-class SPREXT
-{
+class SPREXT {
public:
- int x0, y0;
- int x1, y1;
- BMP_PTR b0, b1;
- BMP_PTR * ShpList;
- SEQ * Seq;
- char * Name;
- SNAIL::COM * Near, * Take;
- SPREXT (void) :
- x0(0), y0(0),
- x1(0), y1(0),
- b0(NULL), b1(NULL),
- ShpList(NULL), Seq(NULL),
- Name(NULL), Near(NULL), Take(NULL)
- {}
+ int x0, y0;
+ int x1, y1;
+ BMP_PTR b0, b1;
+ BMP_PTR *ShpList;
+ SEQ *Seq;
+ char *Name;
+ SNAIL::COM *Near, * Take;
+ SPREXT(void) :
+ x0(0), y0(0),
+ x1(0), y1(0),
+ b0(NULL), b1(NULL),
+ ShpList(NULL), Seq(NULL),
+ Name(NULL), Near(NULL), Take(NULL)
+ {}
};
-
-
-class SPRITE
-{
+class SPRITE {
protected:
- SPREXT * Ext;
+ SPREXT *Ext;
public:
- int Ref;
- signed char Cave;
- struct FLAGS { uint16 Hide : 1; // general visibility switch
- uint16 Near : 1; // Near action lock
- uint16 Drag : 1; // sprite is moveable
- uint16 Hold : 1; // sprite is held with mouse
- uint16 ____ : 1; // intrrupt driven animation
- uint16 Slav : 1; // slave object
- uint16 Syst : 1; // system object
- uint16 Kill : 1; // dispose memory after remove
- uint16 Xlat : 1; // 2nd way display: xlat table
- uint16 Port : 1; // portable
- uint16 Kept : 1; // kept in pocket
- uint16 East : 1; // talk to east (in opposite to west)
- uint16 Shad : 1; // shadow
- uint16 Back : 1; // 'send to background' request
- uint16 BDel : 1; // delete bitmaps in ~SPRITE
- uint16 Tran : 1; // transparent (untouchable)
- } Flags;
- int X, Y;
- signed char Z;
- uint16 W, H;
- uint16 Time;
- uint8 NearPtr, TakePtr;
- int SeqPtr;
- int ShpCnt;
- char File[MAXFILE];
- SPRITE * Prev, * Next;
- bool Works (SPRITE * spr);
- bool SeqTest (int n);
- inline bool Active (void) { return Ext != NULL; }
- SPRITE (BMP_PTR * shp);
- virtual ~SPRITE (void);
- BMP_PTR Shp (void);
- BMP_PTR * SetShapeList (BMP_PTR * shp);
- void MoveShapes (uint8 * buf);
- SPRITE * Expand (void);
- SPRITE * Contract (void);
- SPRITE * BackShow (bool fast = false);
- void SetName(char * n);
- inline char * Name(void) { return (Ext) ? Ext->Name : NULL; }
- void Goto (int x, int y);
- void Center (void);
- void Show (void);
- void Hide (void);
- BMP_PTR Ghost (void);
- void Show (uint16 pg);
- void MakeXlat (uint8 * x);
- void KillXlat (void);
- void Step (int nr = -1);
- SEQ * SetSeq (SEQ * seq);
- SNAIL::COM * SnList(SNLIST type);
- virtual void Touch (uint16 mask, int x, int y);
- virtual void Tick (void);
+ int Ref;
+ signed char Cave;
+ struct FLAGS {
+ uint16 Hide : 1; // general visibility switch
+ uint16 Near : 1; // Near action lock
+ uint16 Drag : 1; // sprite is moveable
+ uint16 Hold : 1; // sprite is held with mouse
+ uint16 ____ : 1; // intrrupt driven animation
+ uint16 Slav : 1; // slave object
+ uint16 Syst : 1; // system object
+ uint16 Kill : 1; // dispose memory after remove
+ uint16 Xlat : 1; // 2nd way display: xlat table
+ uint16 Port : 1; // portable
+ uint16 Kept : 1; // kept in pocket
+ uint16 East : 1; // talk to east (in opposite to west)
+ uint16 Shad : 1; // shadow
+ uint16 Back : 1; // 'send to background' request
+ uint16 BDel : 1; // delete bitmaps in ~SPRITE
+ uint16 Tran : 1; // transparent (untouchable)
+ } Flags;
+ int X, Y;
+ signed char Z;
+ uint16 W, H;
+ uint16 Time;
+ uint8 NearPtr, TakePtr;
+ int SeqPtr;
+ int ShpCnt;
+ char File[MAXFILE];
+ SPRITE *Prev, * Next;
+ bool Works(SPRITE *spr);
+ bool SeqTest(int n);
+ inline bool Active(void) {
+ return Ext != NULL;
+ }
+ SPRITE(BMP_PTR *shp);
+ virtual ~SPRITE(void);
+ BMP_PTR Shp(void);
+ BMP_PTR *SetShapeList(BMP_PTR *shp);
+ void MoveShapes(uint8 *buf);
+ SPRITE *Expand(void);
+ SPRITE *Contract(void);
+ SPRITE *BackShow(bool fast = false);
+ void SetName(char *n);
+ inline char *Name(void) {
+ return (Ext) ? Ext->Name : NULL;
+ }
+ void Goto(int x, int y);
+ void Center(void);
+ void Show(void);
+ void Hide(void);
+ BMP_PTR Ghost(void);
+ void Show(uint16 pg);
+ void MakeXlat(uint8 *x);
+ void KillXlat(void);
+ void Step(int nr = -1);
+ SEQ *SetSeq(SEQ *seq);
+ SNAIL::COM *SnList(SNLIST type);
+ virtual void Touch(uint16 mask, int x, int y);
+ virtual void Tick(void);
};
-
-
-
-
-class QUEUE
-{
- SPRITE * Head, * Tail;
+class QUEUE {
+ SPRITE *Head, * Tail;
public:
- bool Show;
- QUEUE (bool show = false);
- ~QUEUE (void);
- void Append (SPRITE * spr);
- void Insert (SPRITE * spr, SPRITE * nxt);
- void Insert (SPRITE * spr);
- SPRITE * Remove (SPRITE * spr);
- void ForAll (void (*fun)(SPRITE *));
- SPRITE * First (void) { return Head; }
- SPRITE * Last (void) { return Tail; }
- SPRITE * Locate (int ref);
- void Clear (void);
+ bool Show;
+ QUEUE(bool show = false);
+ ~QUEUE(void);
+ void Append(SPRITE *spr);
+ void Insert(SPRITE *spr, SPRITE *nxt);
+ void Insert(SPRITE *spr);
+ SPRITE *Remove(SPRITE *spr);
+ void ForAll(void (*fun)(SPRITE *));
+ SPRITE *First(void) {
+ return Head;
+ }
+ SPRITE *Last(void) {
+ return Tail;
+ }
+ SPRITE *Locate(int ref);
+ void Clear(void);
};
-
-
-
-
-class VGA
-{
- static uint16 OldMode;
- static uint16 * OldScreen;
- static uint16 StatAdr;
- static bool SetPal;
- static DAC * OldColors, * NewColors;
- static int SetMode (int mode);
- static void UpdateColors (void);
- static void SetColors (void);
- static const char * Msg;
- static const char * Nam;
- static void SetStatAdr (void);
- static void WaitVR (bool on = true);
+class VGA {
+ static uint16 OldMode;
+ static uint16 *OldScreen;
+ static uint16 StatAdr;
+ static bool SetPal;
+ static DAC *OldColors, * NewColors;
+ static int SetMode(int mode);
+ static void UpdateColors(void);
+ static void SetColors(void);
+ static const char *Msg;
+ static const char *Nam;
+ static void SetStatAdr(void);
+ static void WaitVR(bool on = true);
public:
- uint32 FrmCnt;
- static QUEUE ShowQ, SpareQ;
- static int Mono;
- static uint8 * Page[4];
- VGA (int mode = M13H);
- ~VGA (void);
- void Setup (VgaRegBlk * vrb);
- static void GetColors (DAC * tab);
- static void SetColors (DAC * tab, int lum);
- static void Clear (uint8 color = 0);
- static void CopyPage (uint16 d, uint16 s = 3);
- static void Sunrise (DAC * tab);
- static void Sunset (void);
- void Show (void);
- void Update (void);
+ uint32 FrmCnt;
+ static QUEUE ShowQ, SpareQ;
+ static int Mono;
+ static uint8 *Page[4];
+ VGA(int mode = M13H);
+ ~VGA(void);
+ void Setup(VgaRegBlk *vrb);
+ static void GetColors(DAC *tab);
+ static void SetColors(DAC *tab, int lum);
+ static void Clear(uint8 color = 0);
+ static void CopyPage(uint16 d, uint16 s = 3);
+ static void Sunrise(DAC *tab);
+ static void Sunset(void);
+ void Show(void);
+ void Update(void);
};
-
-DAC MkDAC (uint8 r, uint8 g, uint8 b);
-RGB MkRGB (uint8 r, uint8 g, uint8 b);
-
-
+DAC MkDAC(uint8 r, uint8 g, uint8 b);
+RGB MkRGB(uint8 r, uint8 g, uint8 b);
template <class CBLK>
-uint8 Closest (CBLK * pal, CBLK x)
-{
- #define f(col,lum) ((((uint16)(col))<<8)/lum)
- uint16 i, dif = 0xFFFF, found = 0;
- uint16 L = x.R + x.G + x.B; if (! L) ++ L;
- uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L);
- for (i = 0; i < 256; i ++)
- {
- uint16 l = pal[i].R + pal[i].G + pal[i].B; if (! l) ++ l;
- int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l);
- uint16 D = ((r > R) ? (r - R) : (R - r)) +
- ((g > G) ? (g - G) : (G - g)) +
- ((b > B) ? (b - B) : (B - b)) +
- ((l > L) ? (l - L) : (L - l)) * 10 ;
-
- if (D < dif)
- {
- found = i;
- dif = D;
- if (D == 0) break; // exact!
+uint8 Closest(CBLK *pal, CBLK x) {
+#define f(col, lum) ((((uint16)(col)) << 8) / lum)
+ uint16 i, dif = 0xFFFF, found = 0;
+ uint16 L = x.R + x.G + x.B;
+ if (!L)
+ ++L;
+ uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L);
+ for (i = 0; i < 256; i ++) {
+ uint16 l = pal[i].R + pal[i].G + pal[i].B;
+ if (! l)
+ ++l;
+ int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l);
+ uint16 D = ((r > R) ? (r - R) : (R - r)) +
+ ((g > G) ? (g - G) : (G - g)) +
+ ((b > B) ? (b - B) : (B - b)) +
+ ((l > L) ? (l - L) : (L - l)) * 10 ;
+
+ if (D < dif) {
+ found = i;
+ dif = D;
+ if (D == 0)
+ break; // exact!
+ }
}
- }
- return found;
- #undef f
+ return found;
+#undef f
};
@@ -322,14 +317,14 @@ uint8 Closest (CBLK * pal, CBLK x)
- char * NumStr (char * str, int num);
- //static void Video (void);
- uint16 * SaveScreen (void);
- void RestoreScreen (uint16 * &sav);
- SPRITE * SpriteAt (int x, int y);
- SPRITE * Locate (int ref);
+char *NumStr(char *str, int num);
+//static void Video (void);
+uint16 *SaveScreen(void);
+void RestoreScreen(uint16 * &sav);
+SPRITE *SpriteAt(int x, int y);
+SPRITE *Locate(int ref);
-extern bool SpeedTest;
+extern bool SpeedTest;
} // End if namespace CGE
diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp
index 46bb45e9c9..a8da163b33 100644
--- a/engines/cge/vmenu.cpp
+++ b/engines/cge/vmenu.cpp
@@ -25,151 +25,131 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge/vmenu.h"
-#include "cge/mouse.h"
-#include <string.h>
-//#include <alloc.h>
+#include "cge/vmenu.h"
+#include "cge/mouse.h"
+#include <string.h>
namespace CGE {
-//--------------------------------------------------------------------------
-#define RELIEF 1
-#if RELIEF
- #define MB_LT LGRAY
- #define MB_RB DGRAY
+#define RELIEF 1
+#if RELIEF
+#define MB_LT LGRAY
+#define MB_RB DGRAY
#else
- #define MB_LT DGRAY
- #define MB_RB LGRAY
+#define MB_LT DGRAY
+#define MB_RB LGRAY
#endif
-MENU_BAR::MENU_BAR (uint16 w)
-{
- int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h;
- uint8 * p = farnew(uint8, i), * p1, * p2;
-
- memset(p+w, TRANS, i-2*w);
- memset(p, MB_LT, w);
- memset(p+i-w, MB_RB, w);
- p1 = p;
- p2 = p+i-1;
- for (i = 0; i < h; i ++)
- {
- * p1 = MB_LT;
- * p2 = MB_RB;
- p1 += w;
- p2 -= w;
- }
- TS[0] = new BITMAP(w, h, p);
- SetShapeList(TS);
- Flags.Slav = true;
- Flags.Tran = true;
- Flags.Kill = true;
- Flags.BDel = true;
-}
-
-
-
-//--------------------------------------------------------------------------
-
-static char * vmgt;
+MENU_BAR::MENU_BAR(uint16 w) {
+ int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h;
+ uint8 *p = farnew(uint8, i), * p1, * p2;
-
-
-char * VMGather (CHOICE * list)
-{
- CHOICE * cp;
- int len = 0, h = 0;
-
- for (cp = list; cp->Text; cp ++)
- {
- len += strlen(cp->Text);
- ++ h;
- }
- vmgt = new char[len+h];
- if (vmgt)
- {
- *vmgt = '\0';
- for (cp = list; cp->Text; cp ++)
- {
- if (*vmgt) strcat(vmgt, "|");
- strcat(vmgt, cp->Text);
- ++ h;
+ memset(p + w, TRANS, i - 2 * w);
+ memset(p, MB_LT, w);
+ memset(p + i - w, MB_RB, w);
+ p1 = p;
+ p2 = p + i - 1;
+ for (i = 0; i < h; i ++) {
+ *p1 = MB_LT;
+ *p2 = MB_RB;
+ p1 += w;
+ p2 -= w;
}
- }
- return vmgt;
+ TS[0] = new BITMAP(w, h, p);
+ SetShapeList(TS);
+ Flags.Slav = true;
+ Flags.Tran = true;
+ Flags.Kill = true;
+ Flags.BDel = true;
}
+static char *vmgt;
-VMENU * VMENU::Addr = NULL;
-int VMENU::Recent = -1;
-
+char *VMGather(CHOICE *list) {
+ CHOICE *cp;
+ int len = 0, h = 0;
-
-
-VMENU::VMENU (CHOICE * list, int x, int y)
-: TALK(VMGather(list), RECT), Menu(list), Bar(NULL)
-{
- CHOICE * cp;
-
- Addr = this;
- delete[] vmgt;
- Items = 0;
- for (cp = list; cp->Text; cp ++) ++ Items;
- Flags.BDel = true;
- Flags.Kill = true;
- if (x < 0 || y < 0) Center();
- else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2));
- VGA::ShowQ.Insert(this, VGA::ShowQ.Last());
- Bar = new MENU_BAR(W - 2 * TEXT_HM);
- Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM);
- VGA::ShowQ.Insert(Bar, VGA::ShowQ.Last());
+ for (cp = list; cp->Text; cp ++) {
+ len += strlen(cp->Text);
+ ++h;
+ }
+ vmgt = new char[len + h];
+ if (vmgt) {
+ *vmgt = '\0';
+ for (cp = list; cp->Text; cp ++) {
+ if (*vmgt)
+ strcat(vmgt, "|");
+ strcat(vmgt, cp->Text);
+ ++ h;
+ }
+ }
+ return vmgt;
}
-
-
-VMENU::~VMENU (void)
-{
- Addr = NULL;
+VMENU *VMENU::Addr = NULL;
+int VMENU::Recent = -1;
+
+
+VMENU::VMENU(CHOICE *list, int x, int y)
+ : TALK(VMGather(list), RECT), Menu(list), Bar(NULL) {
+ CHOICE *cp;
+
+ Addr = this;
+ delete[] vmgt;
+ Items = 0;
+ for (cp = list; cp->Text; cp ++)
+ ++Items;
+ Flags.BDel = true;
+ Flags.Kill = true;
+ if (x < 0 || y < 0)
+ Center();
+ else
+ Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2));
+ VGA::ShowQ.Insert(this, VGA::ShowQ.Last());
+ Bar = new MENU_BAR(W - 2 * TEXT_HM);
+ Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM);
+ VGA::ShowQ.Insert(Bar, VGA::ShowQ.Last());
}
+VMENU::~VMENU(void) {
+ Addr = NULL;
+}
-void VMENU::Touch (uint16 mask, int x, int y)
-{
-#define h (FONT_HIG+TEXT_LS)
- int n = 0;
- bool ok = false;
+void VMENU::Touch(uint16 mask, int x, int y) {
+#define h (FONT_HIG + TEXT_LS)
+ int n = 0;
+ bool ok = false;
- if (Items)
- {
- SPRITE::Touch(mask, x, y);
+ if (Items) {
+ SPRITE::Touch(mask, x, y);
- y -= TEXT_VM-1;
- //if
- if (y >= 0)
- {
- n = y / h;
- if (n < Items) ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/);
- else n = Items-1;
- }
+ y -= TEXT_VM - 1;
+ //if
+ if (y >= 0) {
+ n = y / h;
+ if (n < Items)
+ ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/);
+ else
+ n = Items - 1;
+ }
- Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM + n * h - MB_VM);
+ Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM + n * h - MB_VM);
- if (ok && (mask & L_UP))
- {
- Items = 0;
- SNPOST_(SNKILL, -1, 0, this);
- Menu[Recent = n].Proc();
+ if (ok && (mask & L_UP)) {
+ Items = 0;
+ SNPOST_(SNKILL, -1, 0, this);
+ Menu[Recent = n].Proc();
+ }
}
- }
#undef h
}
diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h
index cdbabf9966..ecec9d51b5 100644
--- a/engines/cge/vmenu.h
+++ b/engines/cge/vmenu.h
@@ -25,38 +25,39 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __VMENU__
-#define __VMENU__
+#ifndef __VMENU__
+#define __VMENU__
-#include "cge/talk.h"
+#include "cge/talk.h"
namespace CGE {
-#define MB_VM 1
-#define MB_HM 3
+#define MB_VM 1
+#define MB_HM 3
-typedef struct { char * Text; void (* Proc)(void); } CHOICE;
+typedef struct {
+ char *Text;
+ void (* Proc)(void);
+} CHOICE;
-class MENU_BAR : public TALK
-{
+class MENU_BAR : public TALK {
public:
- MENU_BAR (uint16 w);
+ MENU_BAR(uint16 w);
};
-class VMENU : public TALK
-{
- uint16 Items;
- CHOICE * Menu;
+class VMENU : public TALK {
+ uint16 Items;
+ CHOICE *Menu;
public:
- static VMENU * Addr;
- static int Recent;
- MENU_BAR * Bar;
- VMENU (CHOICE * list, int x, int y);
- ~VMENU (void);
- void Touch (uint16 mask, int x, int y);
+ static VMENU *Addr;
+ static int Recent;
+ MENU_BAR *Bar;
+ VMENU(CHOICE *list, int x, int y);
+ ~VMENU(void);
+ void Touch(uint16 mask, int x, int y);
};
} // End of namespace CGE
diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp
index 4f39cd6186..46282d2bbe 100644
--- a/engines/cge/vol.cpp
+++ b/engines/cge/vol.cpp
@@ -35,68 +35,55 @@
namespace CGE {
#ifdef VOL_UPD
-BTFILE VFILE::Cat(CAT_NAME, UPD, CRP);
-VOLBASE DAT::File(DAT_NAME, UPD, CRP);
+BTFILE VFILE::Cat(CAT_NAME, UPD, CRP);
+VOLBASE DAT::File(DAT_NAME, UPD, CRP);
#else
-BTFILE VFILE::Cat(CAT_NAME, REA, CRP);
-VOLBASE DAT::File(DAT_NAME, REA, CRP);
+BTFILE VFILE::Cat(CAT_NAME, REA, CRP);
+VOLBASE DAT::File(DAT_NAME, REA, CRP);
+#endif
+DAT VFILE::Dat;
+VFILE *VFILE::Recent = NULL;
+
+
+VFILE::VFILE(const char *name, IOMODE mode)
+ : IOBUF(mode) {
+ if (mode == REA) {
+ if (Dat.File.Error || Cat.Error)
+ error("Bad volume data");
+ BT_KEYPACK *kp = Cat.Find(name);
+ if (scumm_stricmp(kp->Key, name) != 0)
+ Error = 1;
+ EndMark = (BufMark = BegMark = kp->Mark) + kp->Size;
+ }
+#ifdef VOL_UPD
+ else
+ Make(name);
#endif
-DAT VFILE::Dat;
-VFILE * VFILE::Recent = NULL;
-
-
-
-
-
-VFILE::VFILE (const char * name, IOMODE mode)
-: IOBUF(mode)
-{
- if (mode == REA)
- {
- if (Dat.File.Error || Cat.Error)
- error("Bad volume data");
- BT_KEYPACK * kp = Cat.Find(name);
- if (scumm_stricmp(kp->Key, name) != 0) Error = 1;
- EndMark = (BufMark = BegMark = kp->Mark) + kp->Size;
- }
- #ifdef VOL_UPD
- else Make(name);
- #endif
}
-
-
-
-VFILE::~VFILE (void)
-{
- if (Recent == this) Recent = NULL;
+VFILE::~VFILE(void) {
+ if (Recent == this)
+ Recent = NULL;
}
-
-
-
-bool VFILE::Exist (const char * name)
-{
- return scumm_stricmp(Cat.Find(name)->Key, name) == 0;
+bool VFILE::Exist(const char *name) {
+ return scumm_stricmp(Cat.Find(name)->Key, name) == 0;
}
-
-
-void VFILE::ReadBuff (void)
-{
- if (Recent != this)
- {
- Dat.File.Seek(BufMark + Lim);
- Recent = this;
- }
- BufMark = Dat.File.Mark();
- long n = EndMark - BufMark;
- if (n > IOBUF_SIZE) n = IOBUF_SIZE;
- Lim = Dat.File.Read(Buff, (uint16) n);
- Ptr = 0;
+void VFILE::ReadBuff(void) {
+ if (Recent != this) {
+ Dat.File.Seek(BufMark + Lim);
+ Recent = this;
+ }
+ BufMark = Dat.File.Mark();
+ long n = EndMark - BufMark;
+ if (n > IOBUF_SIZE)
+ n = IOBUF_SIZE;
+ Lim = Dat.File.Read(Buff, (uint16) n);
+ Ptr = 0;
}
} // End of namespace CGE
diff --git a/engines/cge/vol.h b/engines/cge/vol.h
index 421bd7593c..ea82e8bf6a 100644
--- a/engines/cge/vol.h
+++ b/engines/cge/vol.h
@@ -25,66 +25,64 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __VOL__
-#define __VOL__
+#ifndef __VOL__
+#define __VOL__
-
-//#include <dir.h>
-#include "cge/btfile.h"
-#include "cge/cfile.h"
+#include "cge/btfile.h"
+#include "cge/cfile.h"
namespace CGE {
-#define CAT_NAME "VOL.CAT"
-#define DAT_NAME "VOL.DAT"
+#define CAT_NAME "VOL.CAT"
+#define DAT_NAME "VOL.DAT"
-#ifndef CRP
- #define CRP XCrypt
+#ifndef CRP
+#define CRP XCrypt
#endif
-#define XMASK 0xA5
+#define XMASK 0xA5
-#ifdef VOL_UPD
-#define VOLBASE IOHAND
+#ifdef VOL_UPD
+#define VOLBASE IOHAND
#else
-#define VOLBASE CFILE
+#define VOLBASE CFILE
#endif
-
-class DAT
-{
- friend class VFILE;
- static VOLBASE File;
+class DAT {
+ friend class VFILE;
+ static VOLBASE File;
public:
- static bool Append (uint8 * buf, uint16 len);
- static bool Write (CFILE& f);
- static bool Read (long org, uint16 len, uint8 * buf);
+ static bool Append(uint8 *buf, uint16 len);
+ static bool Write(CFILE &f);
+ static bool Read(long org, uint16 len, uint8 *buf);
};
-
-
-
-
-
-class VFILE : public IOBUF
-{
- static DAT Dat;
- static BTFILE Cat;
- static VFILE * Recent;
- long BegMark, EndMark;
- void ReadBuff (void);
- void WriteBuff (void) { }
- void Make(const char * fspec);
+class VFILE : public IOBUF {
+ static DAT Dat;
+ static BTFILE Cat;
+ static VFILE *Recent;
+ long BegMark, EndMark;
+ void ReadBuff(void);
+ void WriteBuff(void) { }
+ void Make(const char *fspec);
public:
- VFILE (const char * name, IOMODE mode = REA);
- ~VFILE (void);
- static bool Exist (const char * name);
- static const char * Next (void);
- long Mark (void) { return (BufMark+Ptr) - BegMark; }
- long Size (void) { return EndMark - BegMark; }
- long Seek (long pos) { Recent = NULL; Lim = 0; return (BufMark = BegMark+pos); }
+ VFILE(const char *name, IOMODE mode = REA);
+ ~VFILE(void);
+ static bool Exist(const char *name);
+ static const char *Next(void);
+ long Mark(void) {
+ return (BufMark + Ptr) - BegMark;
+ }
+ long Size(void) {
+ return EndMark - BegMark;
+ }
+ long Seek(long pos) {
+ Recent = NULL;
+ Lim = 0;
+ return (BufMark = BegMark + pos);
+ }
};
diff --git a/engines/cge/wav.h b/engines/cge/wav.h
index a8da4f9e72..6d46769cf9 100644
--- a/engines/cge/wav.h
+++ b/engines/cge/wav.h
@@ -25,117 +25,128 @@
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
*/
-#ifndef __WAV__
-#define __WAV__
+#ifndef __WAV__
+#define __WAV__
-#include "cge/general.h"
-#include <string.h>
+#include "cge/general.h"
+#include <string.h>
namespace CGE {
-#define WAVE_FORMAT_PCM 0x0001
-#define IBM_FORMAT_MULAW 0x0101
-#define IBM_FORMAT_ALAW 0x0102
-#define IBM_FORMAT_ADPCM 0x0103
+#define WAVE_FORMAT_PCM 0x0001
+#define IBM_FORMAT_MULAW 0x0101
+#define IBM_FORMAT_ALAW 0x0102
+#define IBM_FORMAT_ADPCM 0x0103
+typedef char FOURCC[4]; // Four-character code
+typedef uint32 CKSIZE; // 32-bit unsigned size
-typedef char FOURCC[4]; // Four-character code
-typedef uint32 CKSIZE; // 32-bit unsigned size
-
-class CKID // Chunk type identifier
-{
- union { FOURCC Tx; uint32 Id; };
+class CKID { // Chunk type identifier
+ union {
+ FOURCC Tx;
+ uint32 Id;
+ };
protected:
- static XFILE * ckFile;
+ static XFILE *ckFile;
public:
- CKID (FOURCC t) { memcpy(Tx, t, sizeof(Tx)); }
- CKID (uint32 d) { Id = d; }
- CKID (XFILE * xf) { (ckFile = xf)->Read(Tx, sizeof(Tx)); }
- bool operator !=(CKID& X) { return Id != X.Id; }
- bool operator ==(CKID& X) { return Id == X.Id; }
- const char * Name (void);
+ CKID(FOURCC t) {
+ memcpy(Tx, t, sizeof(Tx));
+ }
+ CKID(uint32 d) {
+ Id = d;
+ }
+ CKID(XFILE *xf) {
+ (ckFile = xf)->Read(Tx, sizeof(Tx));
+ }
+ bool operator !=(CKID &X) {
+ return Id != X.Id;
+ }
+ bool operator ==(CKID &X) {
+ return Id == X.Id;
+ }
+ const char *Name(void);
};
-
-
-class CKHEA : public CKID
-{
+class CKHEA : public CKID {
protected:
- CKSIZE ckSize; // Chunk size field (size of ckData)
+ CKSIZE ckSize; // Chunk size field (size of ckData)
public:
- CKHEA (XFILE * xf) : CKID(xf) { XRead(xf, &ckSize); }
- CKHEA (char id[]) : CKID(id), ckSize(0) { }
- void Skip (void);
- CKSIZE Size (void) { return ckSize; }
+ CKHEA(XFILE *xf) : CKID(xf) {
+ XRead(xf, &ckSize);
+ }
+ CKHEA(char id[]) : CKID(id), ckSize(0) { }
+ void Skip(void);
+ CKSIZE Size(void) {
+ return ckSize;
+ }
};
-
-
-
-class FMTCK : public CKHEA
-{
- struct WAV
- {
- uint16 wFormatTag; // Format category
- uint16 wChannels; // Number of channels
- uint32 dwSamplesPerSec; // Sampling rate
- uint32 dwAvgBytesPerSec; // For buffer estimation
- uint16 wBlockAlign; // Data block size
- } Wav;
-
- union
- {
- struct PCM
- {
- uint16 wBitsPerSample; // Sample size
- } Pcm;
- };
+class FMTCK : public CKHEA {
+ struct WAV {
+ uint16 wFormatTag; // Format category
+ uint16 wChannels; // Number of channels
+ uint32 dwSamplesPerSec; // Sampling rate
+ uint32 dwAvgBytesPerSec; // For buffer estimation
+ uint16 wBlockAlign; // Data block size
+ } Wav;
+
+ union {
+ struct PCM {
+ uint16 wBitsPerSample; // Sample size
+ } Pcm;
+ };
public:
- FMTCK (CKHEA& hea);
- inline uint16 Channels (void) { return Wav.wChannels; }
- inline uint32 SmplRate (void) { return Wav.dwSamplesPerSec; }
- inline uint32 ByteRate (void) { return Wav.dwAvgBytesPerSec; }
- inline uint16 BlckSize (void) { return Wav.wBlockAlign; }
- inline uint16 SmplSize (void) { return Pcm.wBitsPerSample; }
+ FMTCK(CKHEA &hea);
+ inline uint16 Channels(void) {
+ return Wav.wChannels;
+ }
+ inline uint32 SmplRate(void) {
+ return Wav.dwSamplesPerSec;
+ }
+ inline uint32 ByteRate(void) {
+ return Wav.dwAvgBytesPerSec;
+ }
+ inline uint16 BlckSize(void) {
+ return Wav.wBlockAlign;
+ }
+ inline uint16 SmplSize(void) {
+ return Pcm.wBitsPerSample;
+ }
};
-
-
-
-class DATACK : public CKHEA
-{
- bool e;
- union
- {
- uint8 * Buf;
- EMS * EBuf;
- };
+class DATACK : public CKHEA {
+ bool e;
+ union {
+ uint8 *Buf;
+ EMS *EBuf;
+ };
public:
- DATACK (CKHEA& hea);
- DATACK (CKHEA& hea, EMM * emm);
- DATACK (int first, int last);
- ~DATACK (void);
- inline uint8 * Addr (void) { return Buf; }
- inline EMS * EAddr (void) { return EBuf; }
+ DATACK(CKHEA &hea);
+ DATACK(CKHEA &hea, EMM *emm);
+ DATACK(int first, int last);
+ ~DATACK(void);
+ inline uint8 *Addr(void) {
+ return Buf;
+ }
+ inline EMS *EAddr(void) {
+ return EBuf;
+ }
};
+extern CKID RIFF;
+extern CKID WAVE;
+extern CKID FMT;
+extern CKID DATA;
-extern CKID RIFF;
-extern CKID WAVE;
-extern CKID FMT;
-extern CKID DATA;
-
-
-DATACK * LoadWave (XFILE * file, EMM * emm = NULL);
+DATACK *LoadWave(XFILE *file, EMM *emm = NULL);
} // End of namespace CGE
-
#endif