Category : C Source Code
Archive   : DYNAM_S1.ZIP
Filename : YCROSS.C

 
Output of file : YCROSS.C contained in archive : DYNAM_S1.ZIP
/******************* (C) 1986,7,8 by JAMES A. YORKE **************************/
/******************************** YCROSS.C ***********************************/
/************************* Routines in YCROSS.C ***************************
CRTcrossON(x1,y1,m,n,Color)/ colors m dots on each side of screen point
(row,col) and n above and below; /
SetCross(pointnumber)
CrossPosition()
turnoff()

******************************************************************************/

#include "yinclud.h"

#ifndef X11
#define BLANK 0
#define COLOR color

#ifdef DESMET
#define _setcolor(x) null(x)
#endif

/* for use with IsCross0Set and IsCross1Set */
static int CrossVertColor[2][TWICESCRNCROSSHEIGHT];/* [...] = 64 now */
static int CrossHorzColor[2][TWICESCRNCROSSWIDTH];
extern int xmax, ymax; /* set by FindPixel */
#endif /* X11 */

static double crossX0, crossX1, crossY0, crossY1;

#ifndef X11 /* X11 version in YXCROSS.C */
CRTcrossON(x1, y1, m, n, Color)/* colors m dots on each side of screen point
(row,col) and n above and below; */
double x1,
y1;
int m,
n,
Color;
{
int J,
x,
y;

_setcolor(Color);
FindPixel(x1, y1, 1);
/* this routine puts the coordinates in the vector COL,ROW; "1" means they
are for the crt while if == 2 they are for the core copy */
x = COL;
y = ROW;

/* HORIZONTAL BAR OF CROSS: */
if(y > 0 && y < ymax)
for(J = x - m; J <= x + m; J++)/* left and right */
if(J != x && J >= 0 && J < xmax) {
/* xmax is set by FindPixel */
setPixel(J, y, Color);
/* in MSC, the 3rd variable in setPixel is a dumby and
changes in the color must be set independently */
}

/* VERTICAL BAR OF CROSS: */
if(x > 0 && x < xmax)
for(J = y - n; J <= y + n; J++)/* above and below */
/* now pixel x,J */
if(J >= 0 && J < ymax && J != y) {
setPixel(x, J, Color);
}
}
#endif /* X11 */

#ifndef MAINFRAME
SetCross(crossnumber) /* when turning on the small cross, it
temporarily turns off the big cross, and
then turns it back on */
int crossnumber; /* =0 or 1 */
{
int should0BeOn; /* this keeps track of whether cross 0
(=BIGCROSS) has been turned off(but should
be on) in order to move the little cross; in
this case it is YES, otherwise NO */
int ss;

if(crossnumber == BIGCROSS) {
turnoff(BIGCROSS); /* does nothing if already off */
crossX0 = plotX;/* crossnumber 1 below is very different; why?
*/
crossY0 = plotY;
cross(crossX0, crossY0, SCRNCROSSWIDTH, SCRNCROSSHEIGHT, SCRN,
BIGCROSS);
IsCross0Set = YES;
}
if(crossnumber == SMALLCROSS) {
should0BeOn = IsCross0Set;
turnoff(BIGCROSS);
turnoff(SMALLCROSS); /* does nothing if already off */
ss = ScrnSec;
crossX1 = y[eqn0 + ssX_coord[ss]];
crossY1 = y[eqn0 + ssY_coord[ss]];
cross(crossX1, crossY1, SCRNCROSSWIDTH / 2, SCRNCROSSHEIGHT / 2,
SCRN, SMALLCROSS);
IsCross1Set = YES;

if(crossStatus == ON && printer >= 2)
/* if crossStatus is 1, we print position of
small cross */
CrossPosition();
if(should0BeOn == YES && IsCross0Set == NO)
/* turn BIGCROSS back on */
SetCross(BIGCROSS);
should0BeOn = NO;
}
return;
}
#endif /* ifndef MAINFRAME */

CrossPosition() {
scr_rowcol(2, 28);
PRINT " y1 = small cross at x=%g, y=%g ",
y[eqn0 + ssX_coord[ScrnSec]], y[eqn0 + ssY_coord[ScrnSec]]);
scr_rowcol(0, 0);
}

#ifndef X11 /* X11 version in YXCROSS.C */
cross(x1, y1, m, n, picnum, crossnum)
/* reverses m dots on each side of screen point
(row,col) and n above and below; picnum = 1
means the screen; = 2 means the core picture
*/
double x1,
y1;
int m,
n,
picnum,
crossnum;
{
int J,
x,
y,
switchColor;
int *pixel;

FindPixel(x1, y1, picnum);
/* this routine puts the coordinates in the vector COL,ROW; if picnum == 1,
they are for the crt while if == 2 they are for the core copy */
x = COL;
y = ROW;

if(picnum == SCRN) {
#ifndef MAINFRAME
/* switchColor == YES means the cross should be turned off, restoring
the color that was saved in Cross...[][] */
if((crossnum == BIGCROSS && IsCross0Set == YES)
|| (crossnum == SMALLCROSS && IsCross1Set == YES))
switchColor = YES;
else
switchColor = NO;

/* HORIZONTAL BAR OF CROSS: */
if(y > 0 && y < ymax)
for(J = x - m; J <= x + m; J++)/* left and right */
if(J != x && J >= 0 && J < xmax) {
/* xmax is set by FindPixel */
pixel = &CrossHorzColor[crossnum][J - (x - m)];
if(switchColor == YES) {
/* restore pixel J,y */
_setcolor(*pixel);
setPixel(J, y, *pixel);
_setcolor(COLOR);
/* in MSC, the 3rd variable in setPixel
is a dumby and changes in the color
must be set independently */
}
else {
/* save the current color of the pixel and change it to COLOR, unless it is
already COLOR in which case it gets blanked */
if((*pixel = getPixel (J, y)) != COLOR) {
setPixel(J, y, COLOR);
}
else {
_setcolor(BLANK);
setPixel(J, y, BLANK);
_setcolor(COLOR);
}
}/* end else */
}
/* VERTICAL BAR OF CROSS: */
if(x > 0 && x < xmax)
for(J = y - n; J <= y + n; J++)/* above and below */
/* now pixel x,J */
if(J >= 0 && J < ymax && J != y) {
pixel = &CrossVertColor[crossnum][J - (y - n)];
if(switchColor == YES) {
/* restore pixel x,J */
_setcolor(*pixel);
setPixel(x, J, *pixel);
_setcolor(COLOR);
}
else {
/* save the current color of the pixel and change it to COLOR, unless it is
already COLOR in which case it gets blanked */
if((*pixel = getPixel (x, J)) != COLOR) {
setPixel(x, J, COLOR);
}
else {
_setcolor(BLANK);
setPixel(x, J, BLANK);
_setcolor(COLOR);
}
}/* end else */
}
#endif /* ifndef MAINFRAME */
}
else
{ /* CORE */
if(y > 0 && y < ymax)
for(J = x - m; J <= x + m; J++)/* left and right */
if(J >= 0 && J < xmax)
/* xmax is set by FindPixel */
reverseCore(J, y);

if(x > 0 && x < xmax)
for(J = y - n; J <= y + n; J++)/* above and below */
if(J >= 0 && J < ymax)
reverseCore(x, J);
}
}
#endif /* X11 */

#ifndef X11 /* X11 version omits this function */
drawcross(x1, y1, m, n, picnum)/*
draws m dots on each side of screen point having coordinates
(row,col), and n dots above and below;
picnum
= SCRN = 1 means the screen;
= CORE = 2 means the core picture
= HORIZSCRN 3 means horizontal line segment on screen
= VERTSCRN 4 means vertical line segment on screen
= HORIZCORE 5 means horizontal line segment on core
= VERTCORE 6 means vertical line segment on core
*/
double x1,
y1;
int m,
n,
picnum;
{
int J,
x,
y,
pick;
unsigned row;

if(picnum == SCRN || picnum == HORIZSCRN || picnum == VERTSCRN)
pick = SCRN;
else
pick = CORE;
FindPixel(x1, y1, pick);
/* this routine puts the coordinates in the vector COL,ROW; if pick == SCRN,
they are for the crt while if == CORE they are for the core copy */
x = COL;
y = ROW;

if(y > 0 && y < ymax)
for(J = x - m; J <= x + m; J++)/* left and right */
if(J >= 0 && J < xmax) {
/* xmax is set by FindPixel */
#ifndef MAINFRAME
if(picnum == SCRN || picnum == HORIZSCRN)
setPixel(J, y, COLOR);
/* in MSC, the 3rd variable in setPixel is a dumby and
changes in the color must be set independently */
else
#endif /* ifndef MAINFRAME */
if(picnum == CORE || picnum == HORIZCORE) {
/* first get the relevant byte of
pic1[] */
rowbit = y % 8;
row = y / 8;

/* change the bit to a 1 */

/* now put it in pic1[] */
corePixel(J * corerows + row, mask[rowbit]);
}
} /* end if(J >= 0 ... */
if(x > 0 && x < xmax)
for(J = y - n; J <= y + n; J++)/* above and below */
if(J >= 0 && J < ymax) {
#ifndef MAINFRAME
if(picnum == SCRN || picnum == VERTSCRN)
setPixel(x, J, COLOR);
else
#endif /* ifndef MAINFRAME */
if(picnum == CORE || picnum == VERTCORE) {
/* first get the relevant byte of pic1[] */
rowbit = J % 8;
row = J / 8;
corePixel(x * corerows + row, mask[rowbit]);
}
} /* end if(J >= 0 ... */
}
#endif /* X11 */

#ifndef X11 /* X11 version in YXCROSS.C */
turnoff(crossnumber)
int crossnumber;
{
if(crossnumber == BIGCROSS) {
if(IsCross0Set == YES)
cross(crossX0, crossY0, SCRNCROSSWIDTH,
SCRNCROSSHEIGHT, SCRN, BIGCROSS);
IsCross0Set = NO;
} else if(crossnumber == SMALLCROSS) {
if(IsCross1Set == YES)
cross(crossX1, crossY1, SCRNCROSSWIDTH / 2,
SCRNCROSSHEIGHT / 2, SCRN, SMALLCROSS);
IsCross1Set = NO;
}
return;
}
#endif /* X11 */


/***************************** END of YCROSS.C *******************************/


  3 Responses to “Category : C Source Code
Archive   : DYNAM_S1.ZIP
Filename : YCROSS.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/