/*
SOFTNET BBS DEMO
October 5, 1994
PLEASE NOTE: We are not the sysops of this BBS. The people pictured in
this demo are the owners and sysops. This demo was written
for a local computer fair, and was done overnight as a
favour.
It is included in this package to demonstrate the use of
some VESA commands which are not in the WGT examples.
Hit the RETURN key to end the demo.
Written by Barry Egerter.
PLUG: SOFTNET BBS, 24hrs a day, (519) 457-0059
*/
#include <stdio.h>
#include <dos.h>
#include <wgt5.h>
#include <wgtvesa.h>
#define INFOLINES 42
#define STRING_CENTER -1
#define LINE_COMPARE 0x18
#define OVERFLOW 0x07
#define MAX_SCAN_LINE 0x09
short inforows[4][3] = {0, 36, 72, 0, 36, 72, 108, 144, 180, 108, 144, 180};
short infocols[4] = {0, 640, 640, 0};
char info[INFOLINES][80] = {
"ONLINE SINCE",
"APRIL 1985",
" ",
"EIGHT FULL-TIME",
"NODES AND GROWING",
" ",
"ELEVEN UP-TO-DATE",
"CD-ROM DISCS ONLINE",
" ",
" ",
"OVER 8 GIGABYTES!",
" ",
"NEW CDROMS - PIER 5",
"WINDOWS XTRA-SEP 94",
"NIGHT OWL 13",
"90 MINUTES ACCESS",
"A DAY",
" ",
"UNLIMITED DOWNLOADS",
"COMPARE ELSEWHERE!",
" ",
"CONVENIENT VISA AND",
"MASTERCARD PAYMENT",
" ",
"SOFTNET'S EXCLUSIVE",
"'QUICK CONNECT'",
"SUBSCRIPTION SYSTEM",
"NO ONLINE CHARGES",
"NO FILE RATIOS",
"NO DAILY BYTE LIMITS",
"OUR OWN -TRUE-",
"SATELLITE",
"FILE FEEDS",
"USATODAY NEWSPAPER!",
"AUTO E-MAILED TO",
"YOU EVERY MORNING!",
"OVER 500 INTERNET",
"NEWSGROUPS",
" ",
"CURRENTLY IN OUR",
"10TH YEAR!",
" "
};
block title;
block brian;
block dave;
block sprites [128];
color pal[256];
int timer_ctr;
int do_nothing;
/****************************************************************************/
void do_string (char *word, short y, short x)/* Center text on a given line */
{
short num, ctr, posit;
/* Center text */
posit=0;
for (ctr = 0; ctr < strlen(word); ctr++)
if (sprites[word[ctr]] != NULL)
posit += wgetblockwidth (sprites[word[ctr]]);
posit= 320 - (posit / 2);
for (ctr=0; ctr<strlen(word); ctr++)
{
num = word[ctr]; /* Find sprite # of letter */
if (sprites[num] != NULL)
{
wvesa_putblock (posit + x, y, sprites[num], XRAY);/* Show letter */
x += wgetblockwidth (sprites[num]); /* Advance to next x coordinate */
}
}
}
int inporttemp;
#define INPUT_STATUS_0 0x3da //input status 0 register
#define AC_INDEX 0x03c0 //Attribute controller index
#define AC_MODE_CONTROL 0x10 //Index of mode control register in AC
/**************************************************************************/
void setsplit(short scanline) /* Tells VGA to split screen */
{
unsigned char readmask;
_disable ();
outp(0x3d4, LINE_COMPARE); /* Line compare register */
outp(0x3d5, scanline & 0x00ff); /* Set bits 0-7 */
outp(0x3d4, OVERFLOW); /* Overflow register */
readmask= inp(0x3d5) & 0xef; /* Get all bits except 4 */
outp(0x3d5, readmask | ((scanline & 0x100) >> 4) ); /* Set bit 8 */
outp(0x3d4, MAX_SCAN_LINE); /* Max scan line register */
readmask= inp(0x3d5) & 0xbf; /* Get all bits except 6 */
outp(0x3d5, readmask | ((scanline & 0x200) >> 3) ); /* Set bit 9 */
_enable ();
wretrace();
inporttemp = inp (INPUT_STATUS_0);
//Send bit 5 to prevent screen blanking
outp (AC_INDEX, AC_MODE_CONTROL + 0x20);
//get the current AC mode control reg
inporttemp = inp (AC_INDEX + 1);
//Enable split screen pel panning suppression
inporttemp |= 0x20;
outp (AC_INDEX, inporttemp);
}
void timerproc (void)
{
timer_ctr++;
}
void main (void)
{
short nodelay;
short oldmode;
short startstring;
short leftedge;
short quadrant;
short nextrow;
short curpos;
short ctr;
short split;
float speed;
char ch;
oldmode = wgetmode ();
if ( (!wvesa_detected ()) || (!wvesa_supported (V640x480)) )
{
printf ("VESA driver not found or 640*480*256 not supported.\n");
exit (0);
}
if (VGA.TotalMemory < 16)
{
printf("Demo needs 1024 meg video card. This card only has %dk\n", VGA.TotalMemory);
exit (1);
}
vga256 (); /* Set 320*200 graphics mode */
wvesa_init (V640x480); /* Now init VESA mode */
wvesa_cls (0);
wloadsprites (pal, "bbsdemo.spr", sprites, 0, 127); /* Load font */
wsetpalette (0, 255, pal);
if (!wvesa_setwidth (1280))
{
wsetmode (3);
printf ("Unable to obtain virtual screen width.\n");
exit (0);
}
wvesa_cls (0);
/* Show SOFTNET logo */
title = wloadbmp("softnet.bmp", pal);
wvesa_putblock (0, 0, title, NORMAL);
wfreeblock (title);
brian = wloadblock ("brianpic.blk");
wvesa_putblock (0, 179, brian, XRAY); /* Paste Brian */
wfreeblock (brian);
dave = wloadblock ("davepic.blk");
wvesa_putblock (300, 179, dave, XRAY); /* Paste Dave */
wfreeblock (dave);
wvesa_setlogical (480); /* Draw all fonts on screen 2 */
wsetcolor (0);
wvesa_bar (0, 0, 1279, 215);
setsplit (1); /* Split screen at scanline 1 */
startstring = 3; /* Draw first 3 info lines */
nextrow = 3;
for (ctr = 0; ctr < 3; ctr++)
do_string (info[ctr], inforows[0][ctr], infocols[0]);
wvesa_setphysical (0, 480); /* Show first 3 info lines at top */
for (split = 1; split < 108; split++) /* Drop the split screen so we can */
{ /* see the text we just placed */
wretrace ();
setsplit (split);
}
ch = 0;
leftedge = 0;
quadrant = 0;
nodelay = 0;
winittimer ();
wstarttimer (timerproc, TICKS(100));
while (ch != 13)
{
timer_ctr = 0;
if (nodelay == 0) /* Wait for 5 seconds */
while ((timer_ctr < 500) && (!kbhit ()))
{
do_nothing++;
}
ch = 0;
if (kbhit ()) /* Get keypress if needed */
ch = getch ();
if (ch == 32)
nodelay = !nodelay;
if (ch != 13)
{
quadrant++;
if (quadrant > 3)
quadrant = 0;
wsetcolor (0);
/* Erase the area where we will put the next 3 text lines */
wvesa_bar (infocols[quadrant], inforows[quadrant][0], infocols[quadrant]+639, inforows[quadrant][2]+35);
/* Output the three info lines and scroll down to them */
do_string (info[startstring++], inforows[quadrant][0], infocols[quadrant]);
do_string (info[startstring++], inforows[quadrant][1], infocols[quadrant]);
do_string (info[startstring++], inforows[quadrant][2], infocols[quadrant]);
if (quadrant == 0)
for (curpos = 588; curpos > 479; curpos--)
{
wvesa_setphysical (0, curpos);
wretrace ();
}
else if (quadrant == 1)
for (leftedge = 0; leftedge < 641; leftedge += 4)
wvesa_setphysical (leftedge, 480);
else if (quadrant == 2)
for (curpos = 480; curpos < 589; curpos++)
{
wvesa_setphysical (640, curpos);
wretrace ();
}
else if (quadrant == 3)
for (leftedge = 640; leftedge >= 0; leftedge -= 4)
wvesa_setphysical (leftedge, 588);
}
if (startstring > INFOLINES - 3) /* Wrap around to first 3 lines? */
startstring = 0;
}
wstoptimer ();
wdonetimer ();
wvesa_setlogical (480); /* Draw all fonts on screen 2 */
wvesa_bar (0, 0, 1279, 323);
wvesa_setphysical (0, 480);
/* Now raise the split screen */
for (split = 107; split >= 0; split --)
{
setsplit (split);
wretrace ();
}
wvesa_setphysical (0, 0); /* Return to original settings & mode */
wvesa_setlogical (0);
wsetmode (oldmode);
}