mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
CGE: Format code
This commit is contained in:
+321
-366
@@ -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];
|
||||
BITMAP::BITMAP(const char *fname, bool rem) : M(NULL), V(NULL) {
|
||||
char pat[MAXPATH];
|
||||
ForceExt(pat, fname, ".VBM");
|
||||
|
||||
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)
|
||||
#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 + H * sizeof(*B)];// the same for 4 planes
|
||||
// + room for wash table
|
||||
if (v == NULL)
|
||||
error("No core");
|
||||
|
||||
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;
|
||||
*(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 (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::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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
while (true) { // at most 2 times: for (V == NULL) & for allocated block;
|
||||
uint8 *im = V + 2;
|
||||
uint16 *cp = (uint16 *) V;
|
||||
int bpl;
|
||||
|
||||
bm += W;
|
||||
if (W < SCR_WID)
|
||||
{
|
||||
if (skip)
|
||||
{
|
||||
cnt += (SCR_WID - j + 3) / 4;
|
||||
if (V) { // 2nd pass - fill the hide table
|
||||
for (i = 0; i < H; i ++) {
|
||||
B[i].skip = 0xFFFF;
|
||||
B[i].hide = 0x0000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt |= CPY;
|
||||
if (V)
|
||||
{
|
||||
*cp = cnt;
|
||||
}
|
||||
cp = (uint16 *) im;
|
||||
im += 2;
|
||||
skip = true;
|
||||
cnt = (SCR_WID - j + 3) / 4;
|
||||
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");
|
||||
|
||||
B = (HideDesc *)(V + sizV);
|
||||
}
|
||||
if (cnt && ! skip)
|
||||
{
|
||||
cnt |= CPY;
|
||||
if (V)
|
||||
{
|
||||
*cp = cnt;
|
||||
}
|
||||
cp = (uint16 *) im;
|
||||
im += 2;
|
||||
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 (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;
|
||||
w = *(uint16 *) m;
|
||||
m += 2;
|
||||
t = w & 0xC000;
|
||||
w &= 0x3FFF;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
while (true) {
|
||||
uint16 w, t;
|
||||
|
||||
w = * (uint16 *) m;
|
||||
m += 2;
|
||||
t = w & 0xC000;
|
||||
w &= 0x3FFF;
|
||||
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;
|
||||
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));
|
||||
|
||||
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)
|
||||
if (p)
|
||||
f->Write((uint8 *)Pal, 256 * sizeof(DAC));
|
||||
|
||||
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
|
||||
|
||||
+43
-43
@@ -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
|
||||
|
||||
|
||||
+183
-164
@@ -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,
|
||||
#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 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 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 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 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
|
||||
};
|
||||
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
|
||||
#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,
|
||||
#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
|
||||
};
|
||||
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,
|
||||
#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 _
|
||||
_ _ _ _ _ _ _ _ _
|
||||
};
|
||||
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
|
||||
};
|
||||
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
|
||||
#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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+38
-38
@@ -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
|
||||
|
||||
|
||||
+97
-145
@@ -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 (void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < BT_LEVELS; i ++)
|
||||
{
|
||||
PutPage(i);
|
||||
delete Buff[i].Page;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BTFILE::PutPage (int lev, bool hard)
|
||||
{
|
||||
if (hard || Buff[lev].Updt)
|
||||
{
|
||||
Seek(Buff[lev].PgNo * sizeof(BT_PAGE));
|
||||
Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE));
|
||||
Buff[lev].Updt = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BT_PAGE * BTFILE::GetPage (int lev, uint16 pgn)
|
||||
{
|
||||
if (Buff[lev].PgNo != pgn)
|
||||
{
|
||||
uint32 pos = pgn * sizeof(BT_PAGE);
|
||||
PutPage(lev);
|
||||
Buff[lev].PgNo = pgn;
|
||||
if (Size() > pos)
|
||||
{
|
||||
Seek((uint32) pgn * sizeof(BT_PAGE));
|
||||
Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE));
|
||||
Buff[lev].Updt = FALSE;
|
||||
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");
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
BTFILE::~BTFILE(void) {
|
||||
for (int i = 0; i < BT_LEVELS; i ++) {
|
||||
PutPage(i);
|
||||
delete Buff[i].Page;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int keycomp (const void * k1, const void * k2)
|
||||
{
|
||||
return memicmp(k1, k2, BT_KEYLEN);
|
||||
void BTFILE::PutPage(int lev, bool hard) {
|
||||
if (hard || Buff[lev].Updt) {
|
||||
Seek(Buff[lev].PgNo * sizeof(BT_PAGE));
|
||||
Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE));
|
||||
Buff[lev].Updt = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) {
|
||||
if (Buff[lev].PgNo != pgn) {
|
||||
uint32 pos = pgn * sizeof(BT_PAGE);
|
||||
PutPage(lev);
|
||||
Buff[lev].PgNo = pgn;
|
||||
if (Size() > pos) {
|
||||
Seek((uint32) pgn * sizeof(BT_PAGE));
|
||||
Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE));
|
||||
Buff[lev].Updt = FALSE;
|
||||
} else {
|
||||
Buff[lev].Page->Hea.Count = 0;
|
||||
Buff[lev].Page->Hea.Down = BT_NONE;
|
||||
memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data));
|
||||
Buff[lev].Updt = TRUE;
|
||||
}
|
||||
Buff[lev].Indx = -1;
|
||||
}
|
||||
return Buff[lev].Page;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++);
|
||||
Buff[1].Updt = TRUE;
|
||||
}
|
||||
Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++);
|
||||
Buff[1].Updt = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace CGE
|
||||
|
||||
+42
-53
@@ -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
|
||||
|
||||
+193
-288
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
void IOBUF::WriteBuff(void) {
|
||||
if (Lim) {
|
||||
IOHAND::Write(Buff, Lim);
|
||||
BufMark = IOHAND::Mark();
|
||||
Lim = 0;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
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(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;
|
||||
}
|
||||
*buf = '\0';
|
||||
return total;
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
uint16 IOBUF::Read(uint8 *buf) {
|
||||
uint16 total = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
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 WriteBuff();
|
||||
}
|
||||
return tot;
|
||||
*buf = '\0';
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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(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();
|
||||
}
|
||||
}
|
||||
return len;
|
||||
return tot;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint16 CFILE::MaxLineLen = LINE_MAX;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CFILE::CFILE (const char * name, IOMODE mode, CRYPT * crpt)
|
||||
: IOBUF(name, mode, crpt)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CFILE::~CFILE (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CFILE::Flush (void)
|
||||
{
|
||||
if (Mode > REA) WriteBuff();
|
||||
else Lim = 0;
|
||||
|
||||
/*
|
||||
_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::Seek (long pos)
|
||||
{
|
||||
if (pos >= BufMark && pos < BufMark + Lim)
|
||||
{
|
||||
((Mode == REA) ? Ptr : Lim) = (uint16) (pos - BufMark);
|
||||
return pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mode > REA)
|
||||
{
|
||||
WriteBuff();
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Lim = 0;
|
||||
}
|
||||
Ptr = 0;
|
||||
return BufMark = IOHAND::Seek(pos);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
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 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;
|
||||
uint16 CFILE::MaxLineLen = LINE_MAX;
|
||||
|
||||
|
||||
CFILE::CFILE(const char *name, IOMODE mode, CRYPT *crpt)
|
||||
: IOBUF(name, mode, crpt) {
|
||||
}
|
||||
|
||||
|
||||
CFILE::~CFILE(void) {
|
||||
}
|
||||
|
||||
|
||||
void CFILE::Flush(void) {
|
||||
if (Mode > REA)
|
||||
WriteBuff();
|
||||
else
|
||||
Lim = 0;
|
||||
|
||||
/*
|
||||
_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::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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
+33
-38
@@ -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
|
||||
|
||||
+14
-17
@@ -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
|
||||
|
||||
+11
-9
@@ -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
|
||||
|
||||
+1613
-1962
File diff suppressed because it is too large
Load Diff
+125
-147
@@ -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 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 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 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 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 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 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 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
|
||||
|
||||
//#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])
|
||||
#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;
|
||||
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
|
||||
|
||||
|
||||
+186
-215
@@ -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 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 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
|
||||
#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 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 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 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 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 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 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 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 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 } };
|
||||
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]);
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+139
-153
@@ -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
|
||||
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:
|
||||
*/
|
||||
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";
|
||||
/*
|
||||
static char e[] = "EMMXXXX0";
|
||||
|
||||
asm mov ax,0x3D40
|
||||
asm mov dx,offset e
|
||||
asm int 0x21
|
||||
asm jc fail
|
||||
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 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 pop bx
|
||||
asm push ax
|
||||
asm mov ax,0x3E00
|
||||
asm int 0x21
|
||||
asm pop ax
|
||||
|
||||
asm cmp al,0x00
|
||||
asm je fail
|
||||
asm cmp al,0x00
|
||||
asm je fail
|
||||
|
||||
success:
|
||||
return TRUE;
|
||||
fail:
|
||||
return FALSE;
|
||||
*/
|
||||
success:
|
||||
return TRUE;
|
||||
fail:
|
||||
return FALSE;
|
||||
*/
|
||||
warning("EMM::Test");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
EMS * EMM::Alloc (uint16 siz) {
|
||||
/*
|
||||
long size = SIZ(siz),
|
||||
top = Top;
|
||||
EMS *EMM::Alloc(uint16 siz) {
|
||||
/*
|
||||
long size = SIZ(siz),
|
||||
top = Top;
|
||||
|
||||
uint16 pgn = (uint16) (top >> 14),
|
||||
cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn;
|
||||
uint16 pgn = (uint16) (top >> 14),
|
||||
cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn;
|
||||
|
||||
if (cnt > 4)
|
||||
{
|
||||
top = (top + PAGE_MASK) & 0xFFFFC000L;
|
||||
++ pgn;
|
||||
-- cnt;
|
||||
}
|
||||
|
||||
if (size <= Lim - top)
|
||||
{
|
||||
EMS * e = new EMS, * f;
|
||||
|
||||
if (e)
|
||||
{
|
||||
Top = (e->Ptr = top) + (e->Siz = siz);
|
||||
e->Emm = this;
|
||||
|
||||
if (List)
|
||||
if (cnt > 4)
|
||||
{
|
||||
for (f = List; f->Nxt; f = f->Nxt);
|
||||
return (f->Nxt = e); // existing list: link to the end
|
||||
top = (top + PAGE_MASK) & 0xFFFFC000L;
|
||||
++ pgn;
|
||||
-- cnt;
|
||||
}
|
||||
else
|
||||
|
||||
if (size <= Lim - top)
|
||||
{
|
||||
return (List = e); // empty list: link to the head
|
||||
EMS * e = new EMS, * f;
|
||||
|
||||
if (e)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
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
|
||||
_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;
|
||||
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
|
||||
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);
|
||||
*/
|
||||
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
|
||||
|
||||
+46
-72
@@ -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
|
||||
|
||||
+18
-25
@@ -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
|
||||
|
||||
+208
-189
@@ -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
|
||||
};
|
||||
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*)) {
|
||||
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;
|
||||
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;
|
||||
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 *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)
|
||||
{
|
||||
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 (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;
|
||||
*/
|
||||
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)
|
||||
//#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;
|
||||
*/
|
||||
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
|
||||
|
||||
|
||||
+143
-168
@@ -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
|
||||
|
||||
|
||||
+79
-95
@@ -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::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(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::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;
|
||||
void GET_TEXT::Tick(void) {
|
||||
if (++ Cntr >= GTBLINK) {
|
||||
Buff[Len] ^= (' ' ^ '_');
|
||||
Cntr = 0;
|
||||
}
|
||||
}
|
||||
else SPRITE::Touch(mask, x, y);
|
||||
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);
|
||||
}
|
||||
|
||||
} // End of namespace CGE
|
||||
|
||||
+18
-20
@@ -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
|
||||
|
||||
+8
-9
@@ -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
|
||||
|
||||
|
||||
+98
-97
@@ -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 BEL 7
|
||||
#define BS 8
|
||||
#define HT 9
|
||||
#define LF 10
|
||||
#define FF 12
|
||||
#define CR 13
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define MAXFILE 128
|
||||
#define MAXFILE 128
|
||||
|
||||
#define NULL 0
|
||||
#define OFF false
|
||||
#define ON true
|
||||
#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 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
|
||||
#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);
|
||||
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)
|
||||
#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,
|
||||
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;
|
||||
} Keys;
|
||||
|
||||
struct KeyStatStruct
|
||||
{
|
||||
int RShift : 1;
|
||||
int LShift : 1;
|
||||
int Ctrl : 1;
|
||||
int Alt : 1;
|
||||
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 ScrollLock : 1;
|
||||
int NumLock : 1;
|
||||
int CapsLock : 1;
|
||||
int Ins : 1;
|
||||
|
||||
int LeftCtrl : 1;
|
||||
int LeftAlt : 1;
|
||||
int Unused : 6;
|
||||
};
|
||||
int LeftCtrl : 1;
|
||||
int LeftAlt : 1;
|
||||
int Unused : 6;
|
||||
};
|
||||
|
||||
#define HGC_Cursor 0x0B0C
|
||||
#define CGA_Cursor 0x0607
|
||||
#define OFF_Cursor 0x2000
|
||||
#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 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 FOR(i,n) for(i = 0; i < (n); i++)
|
||||
|
||||
#define TRAP(x) { if (x) asm { int 3 } }
|
||||
#define TRAP(x) { warning("STUB: TRAP"); /*if (x) asm { int 3 } */ }
|
||||
|
||||
#ifdef DEBUG
|
||||
#define Debug(x) x
|
||||
#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
|
||||
|
||||
|
||||
+97
-98
@@ -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) (...);
|
||||
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) {
|
||||
// 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;
|
||||
_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
|
||||
// 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;
|
||||
// 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
|
||||
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;
|
||||
// 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
|
||||
_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:
|
||||
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");
|
||||
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
|
||||
|
||||
+24
-21
@@ -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
|
||||
|
||||
+89
-106
@@ -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;
|
||||
extern MOUSE Mouse;
|
||||
|
||||
bool MIXER::Appear = false;
|
||||
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;
|
||||
|
||||
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
|
||||
|
||||
// slaves
|
||||
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 < 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;
|
||||
|
||||
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]);
|
||||
|
||||
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;
|
||||
//--- 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;
|
||||
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::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::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();
|
||||
}
|
||||
}
|
||||
Time = MIX_DELAY;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
+21
-22
@@ -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
|
||||
#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);
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+136
-174
@@ -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) {
|
||||
/*
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
Step(1);
|
||||
if (Busy) Busy->Step(1);
|
||||
}
|
||||
EvtTail = (EvtTail + 1) % EVT_MAX;
|
||||
}
|
||||
if (Hold)
|
||||
#ifndef DEBUG
|
||||
if (Hold->Flags.Drag)
|
||||
#endif
|
||||
Hold->Goto(X-hx, Y-hy);
|
||||
*/
|
||||
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::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();
|
||||
}
|
||||
EvtTail = (EvtTail + 1) % EVT_MAX;
|
||||
}
|
||||
if (Hold)
|
||||
#ifndef DEBUG
|
||||
if (Hold->Flags.Drag)
|
||||
#endif
|
||||
Hold->Goto(X - hx, Y - hy);
|
||||
}
|
||||
|
||||
} // End of namespace CGE
|
||||
|
||||
+42
-46
@@ -25,61 +25,57 @@
|
||||
* 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;
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
};
|
||||
|
||||
} // End of namespace CGE
|
||||
|
||||
|
||||
+1075
-1257
File diff suppressed because it is too large
Load Diff
+71
-69
@@ -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 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 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);
|
||||
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[];
|
||||
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
|
||||
|
||||
|
||||
+40
-46
@@ -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
|
||||
|
||||
+160
-248
@@ -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::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 (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 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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
void SOUND::Stop(void) {
|
||||
SNDDigiStop(&smpinf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
FX::~FX(void) {
|
||||
Clear();
|
||||
delete[] Cache;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
return Current;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
static uint8 * 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 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
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 p;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
return Current;
|
||||
}
|
||||
|
||||
|
||||
static uint8 *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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
} // End of namespace CGE
|
||||
|
||||
+34
-42
@@ -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
|
||||
|
||||
|
||||
+133
-141
@@ -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>
|
||||
#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>
|
||||
#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]);
|
||||
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;
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
#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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
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
|
||||
|
||||
+29
-32
@@ -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
|
||||
|
||||
|
||||
+254
-334
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
++ m;
|
||||
}
|
||||
}
|
||||
++ tx;
|
||||
}
|
||||
TS[0]->Code();
|
||||
SetShapeList(TS);
|
||||
}
|
||||
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
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(void)
|
||||
: SPRITE(NULL), Mode(PURE) {
|
||||
TS[0] = TS[1] = NULL;
|
||||
Flags.Syst = true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
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];
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
++tx;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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
|
||||
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;
|
||||
// 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
|
||||
// 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;
|
||||
// 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];
|
||||
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;
|
||||
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];
|
||||
uint8 *fp = Font.Map + Font.Pos[*tx];
|
||||
|
||||
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;
|
||||
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
|
||||
|
||||
+39
-53
@@ -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
|
||||
|
||||
+183
-240
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
for (Size = 0; Size < size; Size ++) {
|
||||
Cache[Size].Ref = 0;
|
||||
Cache[Size].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;
|
||||
TEXT::~TEXT(void) {
|
||||
Clear();
|
||||
delete[] Cache;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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::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;
|
||||
}
|
||||
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);
|
||||
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 NULL;
|
||||
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;
|
||||
|
||||
char * TEXT::operator [] (int ref)
|
||||
{
|
||||
int i;
|
||||
if ((i = Find(ref)) < Size) return Cache[i].Txt;
|
||||
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;
|
||||
|
||||
if ((i = Find(0)) >= Size)
|
||||
{
|
||||
Clear(SYSTXT_MAX); // clear non-system
|
||||
if ((i = Find(0)) >= Size)
|
||||
{
|
||||
Clear(); // clear all
|
||||
i = 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Load(i, ref);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x <= 5 + TEXT_RD + sw) east = true;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
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;
|
||||
}
|
||||
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
|
||||
|
||||
+38
-38
@@ -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_REF 301
|
||||
#define SAY_REF 302
|
||||
#define INF_NAME 101
|
||||
#define SAY_NAME 102
|
||||
|
||||
#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
|
||||
|
||||
|
||||
+1192
-1257
File diff suppressed because it is too large
Load Diff
+236
-241
@@ -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 NO_SEQ (-1)
|
||||
#define NO_PTR ((uint8)-1)
|
||||
|
||||
#define SPR_EXT ".SPR"
|
||||
#define SPR_EXT ".SPR"
|
||||
|
||||
#define IsFile(s) (access(s,0)==0)
|
||||
#define IsWrit(s) (access(s,2)==0)
|
||||
#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 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 union {
|
||||
DAC dac;
|
||||
RGB rgb;
|
||||
} TRGB;
|
||||
|
||||
typedef struct { uint8 idx, adr; uint8 clr, set; } VgaRegBlk;
|
||||
typedef struct {
|
||||
uint8 idx, adr;
|
||||
uint8 clr, set;
|
||||
} VgaRegBlk;
|
||||
|
||||
typedef struct { uint8 Now, Next; signed char Dx, Dy; int Dly; } SEQ;
|
||||
typedef struct {
|
||||
uint8 Now, Next;
|
||||
signed char Dx, Dy;
|
||||
int Dly;
|
||||
} SEQ;
|
||||
|
||||
extern SEQ Seq1[];
|
||||
extern SEQ Seq2[];
|
||||
//extern SEQ * Compass[];
|
||||
//extern SEQ TurnToS[];
|
||||
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)
|
||||
#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;
|
||||
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 ;
|
||||
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!
|
||||
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
|
||||
|
||||
|
||||
+103
-123
@@ -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;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef h
|
||||
}
|
||||
|
||||
|
||||
+20
-19
@@ -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
|
||||
|
||||
+36
-49
@@ -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;
|
||||
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(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
|
||||
|
||||
+41
-43
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+92
-81
@@ -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;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user