Category : C Source Code
Archive   : MNDL.ZIP
Filename : MNDLKEY.C

 
Output of file : MNDLKEY.C contained in archive : MNDL.ZIP
#include "mndldefn.h"
#include "mndlprot.h"

dokey(pcs)
CLCSV *pcs;
{
int c, stat;
extern int mode0, pause, debug, mndlmax, gxul, gyul, gbxsiz;
extern char *scrnhlp[];

c = getch();
stat = FALSE;
if (c == 0) {
c = getch();
switch(c) {
case PGUP :
case PGDN :
case CRIGHT :
case CUP :
case CDOWN :
case CLEFT : movbox(c); break;
default : dohlp(scrnhlp); waite(); break;
}
} else
switch(tolower(c)) {
case ESC : modeset(mode0); exit(0); break;
case '+' :
case '-' : movbox(c); break;
case 'b' : togbox(); break;
case '0' : pcs->sx = pcs->sy = 0; break;
case 'w' : mndlfil(pcs, MWRITE); break;
case 'r' : mndlfil(pcs, MREAD); break;
case 'd' : TOG(debug); break;
case 'p' : TOG(pause); break;
case 'm' : getint(&mndlmax, "New max loops "); break;
case 's' : shocs(pcs); if (pause) wait(); break;
case 'n' : drawmndl(pcs->p); break;
case 'y' : getint(&(pcs->sy), "New screen y "); break;
case 'c' : reset(pcs, gxul, gyul, gbxsiz); break;
default : dohlp(scrnhlp); waite(); break;
}
return stat;
}

movbox(c)
int c;
{
extern int gxul, gyul, gbmov, gbxsiz, sxmax, symax;
float rat;

rat =symax/sxmax;
togbox();
switch(c) {
case CLEFT : gxul = MAX(SXMIN, gxul - gbmov); break;
case CRIGHT: gxul = MIN(sxmax-gbxsiz, gxul + gbmov); break;
case CDOWN : gyul = MIN(symax-gbxsiz*rat, gyul + gbmov); break;
case CUP : gyul = MAX(SYMIN, gyul - gbmov); break;
case PGUP : gbxsiz = MIN(gbxsiz+gbmov, sxmax); break;
case PGDN : gbxsiz = MAX(gbxsiz-gbmov, 2); break;
case '+' : gbmov = MIN(gbmov + 1, symax/4); break;
case '-' : gbmov = MAX(gbmov - 1, 1); break;
default : break;
}
togbox();
}

reset(p, sx, sy, sxsiz)
CLCSV *p;
int sx, sy, sxsiz;
{
double x0, y0, x1, y1;
extern int symax, sxmax;

x0 = p->x0 + p->xscl * (double)sx;
x1 = p->x0 + p->xscl * (double)(sx + sxsiz);
y1 = p->y0 + p->yscl * (double)(symax - sy);
y0 = p->y0 + p->yscl * (double)(
(double)symax -
((double)sy + (double)sxsiz*(double)symax/(double)sxmax)
);
p->x0 = x0;
p->x1 = x1;
p->y0 = y0;
p->y1 = y1;
initcs(p);
return;
}


togbox()
{
int xul, yul, xlr, ylr;
unsigned style;
extern int gxul, gyul, gbxsiz, sxmax, symax;

xul = gxul;
xlr = xul + gbxsiz;
yul = gyul;
ylr = yul + (int)((float)gbxsiz*(float)symax/(float)sxmax);
style = 0xff;
boxx(xul, yul, xlr, ylr, style, 0x0f, XORIT);
}

points(x, y, clr)
int x, y, clr;
{
unsigned char mask = 0x80, exist_clr;
char far *base;
extern int sxmax, symax;

if (x sxmax || ysymax) return;

base = (char far *)(EGABASE + ((long)y * WIDTH + ((long)x/8L)));
mask >>= x % 8;
exist_clr = *base; /* Existing clr into EGA register */

OUTINDEX(0, clr); /* Set new Color */
OUTINDEX(8, mask); /* Set Mask */
*base &= TRUE; /* Force a write to the EGA */
}

linef(x1, y1, x2, y2, color, style, orxor, first_on)
int x1, y1, x2, y2, color, orxor, first_on;
unsigned style;
{
int ix, iy, i, inc, x, y, dx, dy, plot, plotx, ploty;
extern int points();
unsigned style_mask;

style = (style == 0) ? 0xFFFF : style ;
style_mask = style;

OUTINDEX(1, ENABLE);
if (orxor == XORIT) OUTINDEX(3, 0x18);
dx = x2 - x1;
dy = y2 - y1;
ix = abs(dx);
iy = abs(dy);
inc = MAX(ix, iy);

plotx = x1;
ploty = y1;
x = y = 0;

if (first_on) points(plotx, ploty, color);

for (i=0; i<= inc; ++i) {
if (style_mask == 0) style_mask = style;
x += ix;
y += iy;
plot = FALSE;
if (x>inc) {
plot = TRUE;
x -= inc;
plotx += sign(dx);
}
if (y>inc) {
plot = TRUE;
y -= inc;
ploty += sign(dy);
}
if (plot && style_mask & 0x0001)
points(plotx, ploty, color);
style_mask >>= 1;
}
OUTINDEX(0,0); /* reset register */
OUTINDEX(1,0); /* reset ENABLE */
if (orxor == XORIT) OUTINDEX(3,0); /* reset XOR */
OUTINDEX(8,TRUE); /* reset Bitmask */
}

boxx(x1, y1, x2, y2, style, color, orxor)
int x1, y1, x2, y2, color, orxor;
unsigned style;
{
int xul, yul, xlr, ylr;

xul = (x2 > x1) ? x1 : x2;
yul = (y2 > y1) ? y1 : y2;
xlr = (x2 > x1) ? x2 : x1;
ylr = (y2 > y1) ? y2 : y1;

linef(xul, yul, xlr, yul, color, style, orxor, FALSE);
linef(xlr, yul, xlr, ylr, color, style, orxor, FALSE);
linef(xlr, ylr, xul, ylr, color, style, orxor, FALSE);
linef(xul, ylr, xul, yul, color, style, orxor, FALSE);
}

  3 Responses to “Category : C Source Code
Archive   : MNDL.ZIP
Filename : MNDLKEY.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/