home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
text
/
pastex-1.3-1of8.lha
/
PasTeX
/
src
/
SpecialHost
/
SpecialWin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-25
|
34KB
|
1,409 lines
/* *** specialwin.c *** */
#include "specialhost.h"
static struct TextFont *font = NULL;
static struct TextAttr txtAttr;
#include "specialwin.h"
/**------------------*** Icon Data ***------------------**/
static USHORT __chip imageData1[] = {
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x0000, 0x0001,
0x0000, 0x0000, 0x07FE, 0x0001,
0x0100, 0x0000, 0x0402, 0x0001,
0x0380, 0x0000, 0x07FE, 0x0001,
0x0540, 0x0000, 0x0402, 0x0001,
0x0100, 0x0000, 0x01DC, 0x0001,
0x0000, 0x0000, 0x0402, 0x0001,
0x0100, 0x0000, 0x07DA, 0x0001,
0x0100, 0x0000, 0x0400, 0x0001,
0x0100, 0x0000, 0x07DA, 0x0001,
0x0100, 0x00F7, 0x4402, 0x0001,
0x0100, 0x00C0, 0x41DA, 0x0001,
0x0100, 0x0092, 0x4402, 0x0001,
0x0100, 0x00A4, 0xC7FE, 0x0001,
0x011F, 0xF8C9, 0x4402, 0x0001,
0x0115, 0x5892, 0x47FE, 0x00C1,
0x011A, 0xA8A4, 0xC402, 0x0061,
0x1FFF, 0xFFFF, 0xFFFF, 0xFFF1,
0x0100, 0x0000, 0x0000, 0x0061,
0x0100, 0x0000, 0x0000, 0x00C1,
0x0000, 0x0000, 0x0000, 0x0001,
0x7FFF, 0xFFFF, 0xFFFF, 0xFFFF,
/**/
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
0x8000, 0x0000, 0x0000, 0x0000,
0x8000, 0x0000, 0x0000, 0x0000,
0x8000, 0x0000, 0x0000, 0x0000,
0x8FFC, 0x0E1C, 0x0000, 0x0000,
0x88C4, 0x0B34, 0x0000, 0x0000,
0x80C0, 0x01E0, 0x0000, 0x0000,
0x80CF, 0xC0C0, 0x7800, 0x0000,
0x80CC, 0x41E0, 0x0000, 0x0000,
0x80CC, 0x0B34, 0x0000, 0x0000,
0x80CF, 0x8E1C, 0x0000, 0x0000,
0x800C, 0x0000, 0x0000, 0x0000,
0x800C, 0x4000, 0x0000, 0x0000,
0x800F, 0xC000, 0x0000, 0x0000,
0x8000, 0x0000, 0x07FE, 0x0000,
0x8100, 0x0000, 0x0402, 0x0000,
0x8380, 0x0000, 0x07FE, 0x0000,
0x8540, 0x0000, 0x0402, 0x0000,
0x8301, 0xC38F, 0x0FFF, 0x8800,
0x8102, 0x2448, 0x9526, 0x4800,
0x8182, 0x0448, 0x17FE, 0x4800,
0x8141, 0xC78F, 0x1427, 0xC800,
0x8120, 0x2408, 0x17FE, 0x4800,
0x8112, 0x24FF, 0xD526, 0x4900,
0x8109, 0xC4CF, 0x4FFE, 0x4F00,
0x8100, 0x0092, 0x4402, 0x0000,
0x8100, 0x00A4, 0xC7FE, 0x0000,
0x811F, 0xF8C9, 0x4402, 0x0000,
0x8115, 0x5892, 0x47FE, 0x00C0,
0x811A, 0xA8A4, 0xC402, 0x0060,
0x9FFF, 0xFFFF, 0xFFFF, 0xFFF0,
0x8100, 0x0000, 0x0000, 0x0060,
0x8100, 0x0000, 0x0000, 0x00C0,
0x8000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
/**/
};
struct Image image1 = {
0, /* LeftEdge */
0, /* TopEdge */
ICON_WIDTH, /* Width */
ICON_HEIGHT, /* Height */
2, /* Depth */
NULL, /* ImageData */
0x3, /* PlanePick */
0x0, /* PlaneOnOff */
0, /* [NextImage] */
};
struct scroll_win {
struct scroll_text *top; /* first viewed line */
struct scroll_text *first_free;
long number; /* number of used lines in buffer */
long displayed; /* number of displayed lines */
};
struct scroll_text {
char *line;
struct scroll_text *next_line;
struct scroll_text *prev_line;
short is_first; /* is first line in buffer */
short is_last; /* is last line in buffer */
};
#ifdef LATTICE
extern long _stack;
extern char * _procname;
extern long _priority;
extern long _BackGroundIO;
extern BPTR _Backstdout;
#endif
struct Library *IFFBase = NULL;
struct GfxBase *GfxBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
extern struct MsgPort *special_port;
extern IFFFILE ifffile;
extern struct BitMap *bmap;
extern short use_blitter;
extern short invert_bmap;
extern short is_os2;
extern short ECS_chips;
static short use_pubscr = FALSE;
static struct Window *win = NULL;
static UBYTE sig_win;
static struct Window *icon = NULL;
static struct scroll_win swin;
static int display_len;
static int lines_to_show;
static int height_char;
static int width_char;
static int icon_x_pos;
static int icon_y_pos;
static int win_x_pos;
static int win_y_pos;
static int win_width;
static int win_height;
static int win_title_height;
static char copyright[] = "SpecialHost Version "VERSION", last compiled: "__DATE__;
static char PubScreenName[] = "ShowDVI-PubScr";
static struct TagItem pub_window_tags[] = {
{ WA_ScreenTitle, &(copyright[0]) },
{ WA_AutoAdjust, TRUE },
{ WA_PubScreenName, &(PubScreenName[0]) },
{ WA_PubScreenFallBack, TRUE },
{ TAG_DONE, 0L }
};
static void OpenI (void);
static void OpenG (void);
static void OpenLib (void);
static void CloseLib (void);
static void CloseWin (void);
static int get_wb_screen_data (int *BarHeight);
static void CloseTopaz (void);
static void OpenTopaz (void);
static void CloseIcon (void);
static UBYTE OpenIcon (void);
static UBYTE OpenWin (void);
static UBYTE ReOpenAll (int draw_modus, int base_dpi);
static void refresh_draw_modus (int draw_modus, int base_dpi);
static void set_picture_draw_modus (long nr, int *draw_modus, int *base_dpi);
static void DrawWin (void);
static long keys (struct IntuiMessage *msg);
static void getShowDVI (void);
static long WindowMessage (int *draw_modus, int *base_dpi);
static void init_text (void);
static void DisplayText (void);
static void ScrollUp (void);
static void ScrollDown (void);
static FILE *OpenConfigFile (char *name, char *modus);
static void ReadConfig (int *draw_modus, int *base_dpi);
static void SaveConfig (int draw_modus, int base_dpi);
void close_all(void)
{
close_port_bitm();
CloseWin();
CloseIcon();
CloseTopaz();
CloseLib();
if (_Backstdout) {
Close(_Backstdout);
_Backstdout = NULL;
}
}
void Fatal(int nr)
{
long ret;
char *message;
char str[64];
switch (nr) {
case NO_INTUI:
message = "can't open Intuition-Library!";
ret = 20;
break;
case NO_GFX:
message = "can't open Graphics-Library!";
ret = 20;
break;
case LINE_TO_LONG:
message = "line too long!!!";
ret = 20;
break;
case NO_WIN:
message = "can't open window!";
ret = 15;
break;
case NO_ICON:
message = "can't open icon-window!";
ret = 15;
break;
case NO_MEMORY:
message = "not enough memory!";
ret = 15;
break;
case NOT_FIRST:
message = "SpecialHost already running!";
ret = 5;
break;
case NO_PORT:
message = "can't open message-port!";
ret = 10;
break;
case NO_MESSAGE:
message = "signal without message??";
ret = 15;
break;
case NO_MEM:
message = "no memory!";
ret = 10;
break;
case NO_OK_BIT:
message = "expect AC_OK_BITMAP!";
ret = 10;
break;
default:
message = "unknown error!?";
ret = 20;
break;
}
sprintf(str, "Fatal: %s\n", message);
if (_Backstdout) {
Write(_Backstdout, str, strlen(str));
}
else {
if (win != NULL) {
pline(message); /* a little bit hacky!!!! */
Delay(50);
}
}
close_all();
exit(ret);
}
static void OpenI(void)
{
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
if (IntuitionBase==NULL) {
Fatal(NO_INTUI);
}
is_os2 = IntuitionBase->LibNode.lib_Version >= 36L;
}
static void OpenG(void)
{
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
if (GfxBase==NULL) {
Fatal(NO_GFX);
}
if (is_os2) {
ECS_chips = GfxBase->ChipRevBits0;
}
}
static void OpenLib(void)
{
#ifndef LATTICE
int bytes;
#endif
OpenI();
OpenG();
#ifdef LATTICE
image1.ImageData = (USHORT *)&imageData1;
#else
bytes = ICON_HEIGHT * ICON_WIDTH * 2 / 8;
image1.ImageData = AllocMem(bytes, MEMF_CHIP | MEMF_PUBLIC);
if (image1.ImageData == NULL) {
Fatal(NO_MEMORY);
}
memcpy((char *)image1.ImageData, (char *)imageData1, bytes);
#endif
}
static void CloseLib(void)
{
#ifndef LATTICE
if (image1.ImageData) != NULL) {
FreeMem(image1.ImageData, ICON_HEIGHT * ICON_WIDTH * 2 / 8);
}
#endif
if (IFFBase != NULL) CloseLibrary(IFFBase);
if (IntuitionBase != NULL) CloseLibrary((stru