home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
newcom.zip
/
NEWCOM.MOD
Wrap
Text File
|
1990-11-08
|
10KB
|
279 lines
/***************************************************************
NEWCOM1.MOD
Buffered I/O Communications Routines for WWIV
Makes WWIV noticeably faster to the users!
Especially when multitasking!
By One Eyed Willy 1 @18852 WWIVLink
WWIV simply excels other BBS softwares in many ways. One
of which is speed. However, WWIV is capable of even more speed.
An extra increase can be acheived by using comm routines
that buffer both incoming and outgoing data.
If outgoing data is buffered, then the computer can be sending
data while doing something else such as reading the next message from
the hard disk. This tactic is often used by external protocols such
as DSZ, but why not a BBS? WildCat! Software has had such routines
installed. So its WWIV's turn.
When multitasking, buffered comm routines make multitasking
virutally unnoticeable. Ever notice how DSZ USUALLY gets 23x CPS, even
though you may set Desqview's clock ticks to 5:1, the BBS having 1?
Well, now your BBS can be the same way. Another big advantage is
when you have a slow hard disk. With the standard routines, the user
normally sees the title printed, then has to wait a breif second while
the message is read into memory. The buffered routines will allow the
BBS to be printing the title WHILE the message is being read. Much
faster!
One drawback on Wildcat! boards is that these types of routines
make messages un-space-abortable. This is due to an incredible lack of
common sense by the authors. A very small addition will handle this
problem for the WWIV software.
On with the mod...
I cannot say I owe these comm routines to anybody. I have looked
high and low on all the programming BBSes in the area, and none could
supply these types of routines. After doing some DEBUG disassembly of
DSZ.COM, I caught the general gist of how you deal with these types of
routines, and proceeded down the long hard road of trial-and-error
testing. I was about to give the project up entirely, but I had one
last idea, which turned out to be the key to the operation of these
routines. So now I'm proud to present: NEWCOM1.MOD.
You may include these routines in any developed software
package without any sort of "tribute". These did take me many
hours of testing, however, I beleive they're for the good of computing,
and do not require any special registration or recognition.
This mod will load up an output buffer before slowing down
to the normal 2400 baud that a sysop is used to seeing. The SysOp's
side becomes very fast, but remember, the user's side is always trying
to catch up. A whole message might appear on your side that hasn't
gotten to the user's side yet.
>>> MAKE SURE YOU MAKE A BACKUP OF YOUR SOURCE BEFORE INSTALLING! <<<
These type of routines are very fast indeed, but do not work on
some systems with slow UART chips. Of course, DSZ uses this same type
of output, so if DSZ works, this should work as well. It has not yet
been tested with 9600+ baud modems, I have no idea how it will react
with such speed requirements. It should not pose problems, however,
may not increase the speed.
==== Step 1: VARS.H
To start, we must first create ourselves the actual buffer. Load up
VARS.H, and search for the following, near the top:
volatile int head,tail;
volatile char buffer[max_buf];
and change them to read:
volatile int head,tail,ohead,otail;
volatile char buffer[max_buf],obuffer[max_buf];
==== Step 2: (The Dreaded) VARDEC.H
Now we need to lower the output buffer. Might as well lower the input buffer
as well, I don't think anybody's gonna type 1024 letters while the BBS isn't
paying attention. This step is optional, however, not doing this will result
in an output buffer that is too large, and will make things a bit unabortable.
Even though the mod will erase the buffer when it detects a "Space abort", if
the SysOp's side has reached a prompt, "Space" no longer is aborting anything.
256 bytes is definitely reasonable. If your system multitasks very jerkily
or are using a high speed modem, however, I suggest 512.
So, load up VARDEC.H, and search for:
#define max_buf 1024
and change it to read:
#define max_buf 256
==== Step 3: COM.C
First thing to do in COM.C is add in the "extrn"s so the compiler is aware
of the new buffer you have put into VARS.H. Load up COM.C, and search for:
extern volatile int head,tail;
extern volatile char buffer[max_buf];
and as in Step 1, change them to read:
extern volatile int head,tail,ohead,otail;
extern volatile char buffer[max_buf],obuffer[max_buf];
Now, we must remove Wayne's outdated and slow routines, and put in the
new set of routines. Remove the following functions:
void far interrupt async_isr ()
void outcomch(char ch)
char get1c()
void initport(int port_num)
And replace them with the following code:
void far interrupt async_isr()
{
static int i;
enable(); /* Re-Enable Interrupts */
for(;;) {
i=inportb(base+2); /* Why was the handler called? */
if (i & 1) { /* Anything more to do? */
outportb(0x20,0x20); /* No? Reset INT Controller. */
return; /* Resume processing */
}
switch (i) {
case 0: /* Modem Status Changed */
inportb(base+6); /* Just read it in, its not useful*/
break;
case 2: /* Ready to output character */
if (otail!=ohead) { /* Is there a character to send? */
outportb(base,obuffer[otail++]); /* Send it */
if (otail==max_buf)
otail=0;
}
break;
case 4: /* Character waiting to be read. */
buffer[head++] = inportb(base); /* Read it */
if (head==max_buf)
head=0;
break;
case 6: /* Line Status has changed. */
inportb(base+5); /* Again, useless, just read it */
break;
}
}
}
void outcomch(char ch)
{
enable(); /* Make sure data can be outputted. */
/* If buffer is full, wait for an available position */
while(otail-1==ohead || (ohead==max_buf-1 && otail==0));
/* Make sure nothing happens while modifying the buffer */
disable();
obuffer[ohead++]=ch;
if (ohead==max_buf)
ohead=0;
enable(); /* Resume buffer processing */
/* Enable output interrupt. Is shut off when inactive. */
outportb(base+1,0x0f);
}
char get1c()
{
char c;
if (head!=tail) {
c=buffer[tail++];
if (tail==max_buf)
tail=0;
return(c);
} else
return(0);
}
void set_up_irq()
{
int i,m;
setvect(8+async_irq,async_isr); /* Set communications handler */
disable(); /* Disable during initialization */
outportb(base+3, inportb(base+3) & 0x7f); /* Turn on DTR and RTS */
i=inportb(base+5); /* Read status */
i=inportb(base); /* Read character */
i=inportb(0x21); /* Get interrupt settings */
m=(1<<async_irq) ^ 0xff; /* Turn on the modem's IRQ */
outportb(0x21,i & m); /* Set new settings. */
i=inportb(base+4); /* Enable Interrupt Gate */
outportb(base+4,i | 0x0b);
outportb(base+1,0x0f); /* Turn on all IRQ Events */
outportb(0x20,0x20); /* Clear INT chip */
enable(); /* Reenable all ints */
}
void dumpo()
/* Dump output buffer */
{
disable();
ohead=otail=0;
enable();
}
void initport(int port_num)
{
base = syscfg.com_base[port_num];
async_irq = syscfg.com_ISR[port_num];
head = tail = ohead = otail = 0;
set_up_irq();
}
==== Step 4: EXTERN.C
Whenever the BBS runs an external program, there's no guarantee that
when the program returns, the BBS will still have control of the modem.
To handle this, Wayne has two functions for initializing. However, the
original initport function doesn't need to do the "destructive" things
that the old one did, as they are done at other times. So, just replace
the initporte() function with this:
void initporte(int port_num)
{
int temp;
if (!ok_modem_stuff)
return;
initport(port_num);
}
Whoa, hard, eh?
==== Step 5: BBSUTL.C
Now you have the comm routines in your bbs software. One more
thing to do to make messages space-abortable. Load up BBSUTL.C
and in void checka(), replace to make it read:
void checka(int *abort, int *next)
{
char ch;
while ((!empty()) && (!(*abort)) && (!hangup)) {
checkhangup();
ch=inkey();
lines_listed=0;
switch(ch) {
case 14:
dumpo();
*next=1;
case 3:
case 32:
case 24:
*abort=1;
dumpo();
break;
case 'P':
case 'p':
case 19:
ch=getkey();
break;
}
}
}
And that should do it. To multitasking maniacs - Enjoy the freedom
to compile WWIV without worrying about your users complaining about
speed problems!