kdw1@sphinx.uchicago.edu (Keith Waclena) (01/23/88)
I have gotten omega sort of working on our 3B15 running System Vr2.
In particular, I fixed the bug that causes the screen to be redrawn
zillions of times in a row (thanks Scott). As far as I understand it,
this is due to incorrect curses usage: the code if full of calls to
the clear function (and its siblings) insetad of the erase function.
Both clear and erase reset the window to blanks, but clear sets the
``clear flag'' which causes the next refresh to clear the screen,
while erase doesn't. Changing most of the clears to erases is great
improvement, though the display is still fiddled with more than is
necessary: I didn't have time to fine tune it.
I had to make a few other changes to System V'ify it (mostly changing
strings.h to string.h and changing the random number code), and one
other change for general portability (changing a char to an int that
breaks the program on machines with unsigned ints).
Unfortunately, due to low disk space and low priority for this project
:-), I couldn't keep a copy of the original code and so can't post
diffs in general. What follows is basically the output of pgrep (my
paragraph-oriented grep) searching for #ifn?def BSD, so you get file
names followed by a chunk of code with my changes.
I am including context diffs for oscr.c, which is where all the clear
to erase changes are, and Makefile (trivial changes due mostly to
short System V filenames).
Good luck, and mail me back further Sys V improvements!
[ Too lazy to do a shar (I'm supposedly working right now..); search
for /- Cut Here/ and use your scissors.]
Keith
--
Keith Waclena University of Chicago Graduate Library School
1100 E. 57th Street, Chicago, Illinois 60637
...ihnp4!gargoyle!sphinx!cerberus!keith
#include <disclaimer.h> keith@cerberus.UChicago.{EDU,BITNET,MAILNET,CSNET}
----- Cut Here ----- [ pgrep output ] -----
o.c
#include <stdio.h>
#include <signal.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "odefs.h"
o.c
/* This may be implementation dependent */
void initrand()
{
#ifdef BSD
srandom(time()+Seed);
#else
srand48(time((long *) 0)+Seed);
#endif
}
oaux1.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oaux2.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
ochar.c
#include <stdio.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
ocity.c
#include <stdio.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
ocom.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
odepths.c
#include <stdio.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oeffect1.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oeffect2.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oetc.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
ofile.c
#include <curses.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#ifndef BSD
#include <sys/types.h>
#endif
#include <sys/file.h>
#include "oglob.h"
ofile.c
#ifndef BSD
#define R_OK 4 /* test for read permission */
#define W_OK 2 /* test for write permission */
#define X_OK 1 /* test for execute (search) permission */
#define F_OK 0 /* test for presence of file */
#endif
ofile.c
/* display a file page at a time */
void showfile(fd)
FILE *fd;
{
/* KDW: bug here due to possible char signity:
char c,d=' ';
On machines with unsigned chars, c can never == EOF (-1), resulting
in an infinite loop. Can't tell you how many times I've seen this one..
*/
int c,d=' ';
int x,y;
clear();
refresh();
c = fgetc(fd);
while ((c != EOF)&&(d != 'q')&&(d!=ESCAPE)) {
getyx(stdscr,y,x);
if (y > 20) {
printw("\n-More-");
refresh();
d = wgetch(stdscr);
clear();
}
printw("%c",c);
c = fgetc(fd);
}
if ((d != 'q')&&(d!=ESCAPE)) {
printw("\n-Done-");
refresh();
getch();
}
}
oguild.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oinititem1.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oinititem2.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oinitmon0to3.c
#include <stdio.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oinitmon4to7.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oinitmon8-10.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oinv.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oitem.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oitemf.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
olev.c
#include <stdio.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
omon.c
#include <stdio.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
omonf.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
omove.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
oscr.c
#include <curses.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include <sys/types.h>
#ifdef BSD
#include <sys/timeb.h>
#endif
#include "oglob.h"
osite.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
ospell.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
otime.c
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include "oglob.h"
outil.c
int random_range(k)
int k;
{
#ifdef BSD
return( k==0 ? 0 : ((int) random()) % k ) ;
#else
return( k==0 ? 0 : ((int) drand48()) % k ) ;
#endif
}
----- Cut Here ----- [ diff -c output for oscr.c ] -----
*** oscr.c~ Wed Dec 16 10:29:57 1987
--- oscr.c Sat Dec 19 16:47:16 1987
***************
*** 60,66
void phaseprint()
{
! wclear(Phasew);
wprintw(Phasew,"Moon's Phase:\n");
switch(Phase/2) {
case 0: wprintw(Phasew,"NEW"); break;
--- 60,66 -----
void phaseprint()
{
! werase(Phasew);
wprintw(Phasew,"Moon's Phase:\n");
switch(Phase/2) {
case 0: wprintw(Phasew,"NEW"); break;
***************
*** 92,98
int y;
{
int i,j,seen,top,bottom;
! wclear(Levelw);
switch(y) {
case 0:
top = TOPEDGE;
--- 92,98 -----
int y;
{
int i,j,seen,top,bottom;
! werase(Levelw);
switch(y) {
case 0:
top = TOPEDGE;
***************
*** 175,181
/* for external call */
void clearmsg()
{
! wclear(Msgw);
wrefresh(Msgw);
}
--- 175,181 -----
/* for external call */
void clearmsg()
{
! werase(Msgw);
wrefresh(Msgw);
}
***************
*** 182,188
void erase_level()
{
! wclear(Levelw);
}
--- 182,188 -----
void erase_level()
{
! werase(Levelw);
}
***************
*** 196,202
getyx(Msgw,y,x);
if (x+strlen(s) > 64) {
morewait();
! wclear(Msgw);
}
wprintw(Msgw,s);
waddch(Msgw,' ');
--- 196,202 -----
getyx(Msgw,y,x);
if (x+strlen(s) > 64) {
morewait();
! werase(Msgw);
}
wprintw(Msgw,s);
waddch(Msgw,' ');
***************
*** 264,279
scrollok(Msgw,TRUE);
! wclear(Msgw);
! wclear(Locw);
! wclear(Levelw);
! wclear(Timew);
! wclear(Flagw);
! wclear(Phasew);
! wclear(Dataw);
! wclear(Menuw1);
! wclear(Menuw2);
! wclear(Comwin);
clear();
refresh();
--- 264,279 -----
scrollok(Msgw,TRUE);
! werase(Msgw);
! werase(Locw);
! werase(Levelw);
! werase(Timew);
! werase(Flagw);
! werase(Phasew);
! werase(Dataw);
! werase(Menuw1);
! werase(Menuw2);
! werase(Comwin);
clear();
refresh();
***************
*** 493,499
void commanderror()
{
! wclear(Msgw);
wrefresh(Msgw);
wprintw(Msgw,"%c : unknown command",Cmd);
wrefresh(Msgw);
--- 493,499 -----
void commanderror()
{
! werase(Msgw);
wrefresh(Msgw);
wprintw(Msgw,"%c : unknown command",Cmd);
wrefresh(Msgw);
***************
*** 501,507
void timeprint()
{
! wclear(Timew);
wprintw(Timew,"%d",showhour());
wprintw(Timew,hour()>11 ? " PM \n" : " AM \n");
wprintw(Timew,month());
--- 501,507 -----
void timeprint()
{
! werase(Timew);
wprintw(Timew,"%d",showhour());
wprintw(Timew,hour()>11 ? " PM \n" : " AM \n");
wprintw(Timew,month());
***************
*** 513,519
void comwinprint()
{
! wclear(Comwin);
wprintw(Comwin,"Hit: %d \n",Player.hit);
wprintw(Comwin,"Dmg: %d \n",Player.dmg);
wprintw(Comwin,"Def: %d \n",Player.defense);
--- 513,519 -----
void comwinprint()
{
! werase(Comwin);
wprintw(Comwin,"Hit: %d \n",Player.hit);
wprintw(Comwin,"Dmg: %d \n",Player.dmg);
wprintw(Comwin,"Def: %d \n",Player.defense);
***************
*** 524,530
void dataprint()
{
! wclear(Dataw);
wprintw(Dataw,"HP:%d/%d MANA:%d/%d AU:%d LEVEL:%d/%d CARRY:%d/%d \n",
Player.hp,Player.maxhp,Player.mana,Player.maxmana,Player.cash,
Player.level,Player.xp,Player.itemweight,Player.maxweight);
--- 524,530 -----
void dataprint()
{
! werase(Dataw);
wprintw(Dataw,"HP:%d/%d MANA:%d/%d AU:%d LEVEL:%d/%d CARRY:%d/%d \n",
Player.hp,Player.maxhp,Player.mana,Player.maxmana,Player.cash,
Player.level,Player.xp,Player.itemweight,Player.maxweight);
***************
*** 539,545
void displaystats(statpoints)
int statpoints;
{
! wclear(Dataw);
wprintw(Dataw," Statistic Points Left: %d \n",statpoints);
wprintw(Dataw,"STR:%d CON:%d DEX:%d AGI:%d INT:%d POW:%d ",
Player.maxstr,Player.maxcon,Player.maxdex,Player.maxagi,Player.maxiq,
--- 539,545 -----
void displaystats(statpoints)
int statpoints;
{
! werase(Dataw);
wprintw(Dataw," Statistic Points Left: %d \n",statpoints);
wprintw(Dataw,"STR:%d CON:%d DEX:%d AGI:%d INT:%d POW:%d ",
Player.maxstr,Player.maxcon,Player.maxdex,Player.maxagi,Player.maxiq,
***************
*** 558,564
/* redraw each permanent window */
void xredraw()
{
! wclear(Rightside);
wrefresh(Rightside);
scrollok(Msgw,FALSE);
touchwin(Msgw);
--- 558,564 -----
/* redraw each permanent window */
void xredraw()
{
! werase(Rightside);
wrefresh(Rightside);
scrollok(Msgw,FALSE);
touchwin(Msgw);
***************
*** 612,618
{
int display;
do {
! wclear(Morew);
if (display) wprintw(Morew,"*** MORE ***");
else wprintw(Morew,"+++ MORE +++");
display = ! display;
--- 612,618 -----
{
int display;
do {
! werase(Morew);
if (display) wprintw(Morew,"*** MORE ***");
else wprintw(Morew,"+++ MORE +++");
display = ! display;
***************
*** 618,624
display = ! display;
wrefresh(Morew);
} while (wgetch(Msgw) != SPACE);
! wclear(Morew);
wrefresh(Morew);
}
--- 618,624 -----
display = ! display;
wrefresh(Morew);
} while (wgetch(Msgw) != SPACE);
! werase(Morew);
wrefresh(Morew);
}
***************
*** 624,631
void menuclear()
{
! wclear(Menuw1);
! wclear(Menuw2);
wrefresh(Menuw1);
wrefresh(Menuw2);
CurrentMenu = Menuw1;
--- 624,631 -----
void menuclear()
{
! werase(Menuw1);
! werase(Menuw2);
wrefresh(Menuw1);
wrefresh(Menuw2);
CurrentMenu = Menuw1;
***************
*** 754,760
void locprint(s)
char *s;
{
! wclear(Locw);
wprintw(Locw,s);
wrefresh(Locw);
}
--- 754,760 -----
void locprint(s)
char *s;
{
! werase(Locw);
wprintw(Locw,s);
wrefresh(Locw);
}
***************
*** 937,943
{
phaseprint();
! wclear(Flagw);
if (Player.food > 20)
wprintw(Flagw,"Satiated\n");
else if (Player.food < 0)
--- 937,943 -----
{
phaseprint();
! werase(Flagw);
if (Player.food > 20)
wprintw(Flagw,"Satiated\n");
else if (Player.food < 0)
----- Cut Here ----- [ diff -c output for Makefile. ] -----
*** Makefile~ Wed Dec 16 09:17:26 1987
--- Makefile Wed Dec 16 10:04:46 1987
***************
*** 6,12
objects = o.o oaux1.o oaux2.o ochar.o ocity.o ocom.o odepths.o\
oeffect1.o oeffect2.o\
oetc.o ofile.o ogen.o oguild.o oinititem1.o oinititem2.o\
! oinitmon0to3.o oinitmon4to7.o oinitmon8to10.o\
oinv.o oitem.o oitemf.o olev.o omon.o omonf.o omove.o\
oscr.o osite.o ospell.o otime.o outil.o
--- 6,12 -----
objects = o.o oaux1.o oaux2.o ochar.o ocity.o ocom.o odepths.o\
oeffect1.o oeffect2.o\
oetc.o ofile.o ogen.o oguild.o oinititem1.o oinititem2.o\
! oinitmon0to3.o oinitmon4to7.o oinitmon8-10.o\
oinv.o oitem.o oitemf.o olev.o omon.o omonf.o omove.o\
oscr.o osite.o ospell.o otime.o outil.o
***************
*** 14,20
objectflags = -g
! libraries = -lcurses -ltermlib
omega: $(objects)
cc -o $@ $(objectflags) $(objects) $(libraries)
--- 14,20 -----
objectflags = -g
! libraries = -lcurses
omega: $(objects)
cc -o $@ $(objectflags) $(objects) $(libraries)