1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Update for modern curses implementation

This commit is contained in:
tholo 1996-06-02 19:47:04 +00:00
parent 9ffb169b10
commit 15eabdf8fd
20 changed files with 91 additions and 147 deletions

View File

@ -106,7 +106,7 @@ readch()
}
else if (ch == CTRL('L')) {
wrefresh(curscr);
mvcur(0, 0, curscr->cury, curscr->curx);
mvcur(0, 0, curscr->_cury, curscr->_curx);
}
else
return ch;

View File

@ -52,9 +52,9 @@ static char rcsid[] = "$NetBSD: end.c,v 1.4 1995/03/24 05:01:30 cgd Exp $";
* the end-of-games points to the user who deserves it (if any).
*/
finalscore(pp)
reg PLAY *pp; {
register PLAY *pp; {
reg int temp, tot, num;
register int temp, tot, num;
if (pp->was_finished == Finished)
return;
@ -96,9 +96,9 @@ static int Last_tot[2]; /* last tot used for extrapolate */
* the end-of-games points to the user who deserves it (if any).
*/
extrapolate(pp)
reg PLAY *pp; {
register PLAY *pp; {
reg int x, num, tot, count;
register int x, num, tot, count;
num = pp - Player;
tot += SC_TRIP + SC_DELAY + SC_EXT;
@ -141,8 +141,8 @@ reg PLAY *pp; {
undoex() {
reg PLAY *pp;
reg int i;
register PLAY *pp;
register int i;
i = 0;
for (pp = Player; pp < &Player[2]; pp++) {

View File

@ -49,9 +49,9 @@ static char rcsid[] = "$NetBSD: init.c,v 1.5 1995/03/24 05:01:40 cgd Exp $";
init() {
reg PLAY *pp;
reg int i, j;
reg CARD card;
register PLAY *pp;
register int i, j;
register CARD card;
bzero(Numseen, sizeof Numseen);
Numgos = 0;
@ -92,8 +92,8 @@ init() {
shuffle() {
reg int i, r;
reg CARD temp;
register int i, r;
register CARD temp;
for (i = 0; i < DECK_SZ; i++) {
r = roll(1, DECK_SZ) - 1;
@ -168,7 +168,7 @@ newboard() {
newscore() {
reg int i, new;
register int i, new;
register PLAY *pp;
static int was_full = -1;
static int last_win = -1;

View File

@ -60,10 +60,10 @@ static char rcsid[] = "$NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $";
void rub();
main(ac, av)
reg int ac;
reg char *av[]; {
register int ac;
register char *av[]; {
reg bool restore;
register bool restore;
/* run as the user */
setuid(getuid());

View File

@ -158,11 +158,6 @@
# define erasechar() _tty.c_cc[VERASE]
# define killchar() _tty.c_cc[VKILL]
# endif
# else
# ifndef erasechar
# define erasechar() _tty.sg_erase
# define killchar() _tty.sg_kill
# endif
# endif SYSV
typedef struct {

View File

@ -45,10 +45,6 @@ static char rcsid[] = "$NetBSD: misc.c,v 1.4 1995/03/24 05:01:54 cgd Exp $";
#include <termios.h>
#include "mille.h"
#ifndef unctrl
#include "unctrl.h"
#endif
# ifdef attron
# include <term.h>
@ -77,7 +73,7 @@ char *str;
CARD
getcard()
{
reg int c, c1;
register int c, c1;
for (;;) {
while ((c = readch()) == '\n' || c == '\r' || c == ' ')
@ -124,7 +120,7 @@ cont: ;
}
check_ext(forcomp)
reg bool forcomp; {
register bool forcomp; {
if (End == 700)
@ -143,8 +139,8 @@ done:
}
}
else {
reg PLAY *pp, *op;
reg int i, safe, miles;
register PLAY *pp, *op;
register int i, safe, miles;
pp = &Player[COMP];
op = &Player[PLAYER];
@ -180,7 +176,7 @@ done:
getyn(promptno)
register int promptno; {
reg char c;
register char c;
Saved = FALSE;
for (;;) {
@ -249,7 +245,7 @@ check_more() {
readch()
{
reg int cnt;
register int cnt;
static char c;
for (cnt = 0; read(0, &c, 1) <= 0; cnt++)

View File

@ -44,9 +44,6 @@ static char rcsid[] = "$NetBSD: move.c,v 1.4 1995/03/24 05:01:57 cgd Exp $";
#include <termios.h>
#include "mille.h"
#ifndef unctrl
#include "unctrl.h"
#endif
# ifdef attron
# include <term.h>
@ -66,9 +63,9 @@ char *Movenames[] = {
domove()
{
reg PLAY *pp;
reg int i, j;
reg bool goodplay;
register PLAY *pp;
register int i, j;
register bool goodplay;
pp = &Player[Play];
if (Play == PLAYER)
@ -169,9 +166,9 @@ acc:
*/
check_go() {
reg CARD card;
reg PLAY *pp, *op;
reg int i;
register CARD card;
register PLAY *pp, *op;
register int i;
for (pp = Player; pp < &Player[2]; pp++) {
op = (pp == &Player[COMP] ? &Player[PLAYER] : &Player[COMP]);
@ -198,10 +195,10 @@ check_go() {
}
playcard(pp)
reg PLAY *pp;
register PLAY *pp;
{
reg int v;
reg CARD card;
register int v;
register CARD card;
/*
* check and see if player has picked
@ -348,7 +345,7 @@ protected:
getmove()
{
reg char c, *sp;
register char c, *sp;
#ifdef EXTRAP
static bool last_ex = FALSE; /* set if last command was E */
@ -477,9 +474,9 @@ ret:
* return whether or not the player has picked
*/
haspicked(pp)
reg PLAY *pp; {
register PLAY *pp; {
reg int card;
register int card;
if (Topcard <= Deck)
return TRUE;
@ -496,9 +493,9 @@ reg PLAY *pp; {
}
account(card)
reg CARD card; {
register CARD card; {
reg CARD oppos;
register CARD oppos;
if (card == C_INIT)
return;
@ -552,10 +549,10 @@ int promptno;
}
sort(hand)
reg CARD *hand;
register CARD *hand;
{
reg CARD *cp, *tp;
reg CARD temp;
register CARD *cp, *tp;
register CARD temp;
cp = hand;
hand += HAND_SZ;

View File

@ -52,8 +52,8 @@ static char rcsid[] = "$NetBSD: print.c,v 1.4 1995/03/24 05:02:02 cgd Exp $";
prboard() {
reg PLAY *pp;
reg int i, j, k, temp;
register PLAY *pp;
register int i, j, k, temp;
for (k = 0; k < 2; k++) {
pp = &Player[k];
@ -68,8 +68,8 @@ prboard() {
show_card(14, temp, pp->battle, &pp->sh_battle);
show_card(16, temp, pp->speed, &pp->sh_speed);
for (i = C_25; i <= C_200; i++) {
reg char *name;
reg int end;
register char *name;
register int end;
if (pp->nummiles[i] == pp->sh_nummiles[i])
continue;
@ -118,10 +118,10 @@ register CARD c, *lc;
static char Score_fmt[] = "%4d";
prscore(for_real)
reg bool for_real; {
register bool for_real; {
reg PLAY *pp;
reg int x;
register PLAY *pp;
register int x;
stdscr = Score;
for (pp = Player; pp < &Player[2]; pp++) {

View File

@ -51,9 +51,9 @@ static char rcsid[] = "$NetBSD: roll.c,v 1.4 1995/03/24 05:02:07 cgd Exp $";
*/
roll(ndie, nsides)
reg int ndie, nsides; {
register int ndie, nsides; {
reg int tot;
register int tot;
extern unsigned int random();
tot = 0;

View File

@ -47,10 +47,6 @@ static char rcsid[] = "$NetBSD: save.c,v 1.4 1995/03/24 05:02:13 cgd Exp $";
#include <termios.h>
#include "mille.h"
#ifndef unctrl
#include "unctrl.h"
#endif
# ifdef attron
# include <term.h>
# define _tty cur_term->Nttyb
@ -73,9 +69,9 @@ int read(), write();
save() {
extern int errno;
reg char *sp;
reg int outf;
reg time_t *tp;
register char *sp;
register int outf;
register time_t *tp;
char buf[80];
time_t tme;
STAT junk;
@ -149,10 +145,10 @@ over:
* be cleaned up before the game starts.
*/
rest_f(file)
reg char *file; {
register char *file; {
reg char *sp;
reg int inf;
register char *sp;
register int inf;
char buf[80];
STAT sbuf;

View File

@ -57,7 +57,7 @@ static char rcsid[] = "$NetBSD: table.c,v 1.4 1995/03/24 05:02:18 cgd Exp $";
main() {
reg int i, j, count;
register int i, j, count;
printf(" %16s -> %5s %5s %4s %s\n", "Card", "cards", "count", "need", "opposite");
for (i = 0; i < NUM_CARDS - 1; i++) {

View File

@ -48,13 +48,13 @@ static char rcsid[] = "$NetBSD: types.c,v 1.4 1995/03/24 05:02:22 cgd Exp $";
*/
isrepair(card)
reg CARD card; {
register CARD card; {
return card == C_GAS || card == C_SPARE || card == C_REPAIRS || card == C_INIT;
}
safety(card)
reg CARD card; {
register CARD card; {
switch (card) {
case C_EMPTY:

View File

@ -1,44 +0,0 @@
/* $NetBSD: unctrl.h,v 1.4 1995/03/24 05:02:28 cgd Exp $ */
/*
* Copyright (c) 1982, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)unctrl.h 8.1 (Berkeley) 5/31/93
*/
/*
* unctrl.h
*/
extern char *_unctrl[];
# define unctrl(ch) (_unctrl[ch & 0177])

View File

@ -55,8 +55,8 @@ int read(), write();
* channel file. func() is either read or write.
*/
varpush(file, func)
reg int file;
reg int (*func)(); {
register int file;
register int (*func)(); {
int temp;

View File

@ -82,7 +82,9 @@ init_field()
Dead = FALSE;
Waiting = FALSE;
#ifndef NCURSES_VERSION
flushok(stdscr, TRUE);
#endif
Score = 0;
erase();

View File

@ -163,7 +163,9 @@ over:
case 'W':
Waiting = TRUE;
leaveok(stdscr, TRUE);
#ifndef NCURSES_VERSION
flushok(stdscr, FALSE);
#endif
goto ret;
case 't':
case 'T':

View File

@ -25,7 +25,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: gnuchess.c,v 1.2 1995/12/21 14:50:10 deraadt Exp $";
static char rcsid[] = "$Id: gnuchess.c,v 1.3 1996/06/02 19:51:39 tholo Exp $";
#endif /* not lint */
#include <stdio.h>
@ -135,8 +135,8 @@ short c1,c2,*atk1,*atk2,*PC1,*PC2,EnemyKing;
short mate,post,opponent,computer,Sdepth,Awindow,Bwindow,dither;
long ResponseTime,ExtraTime,Level,et,et0,time0,cputimer,ft;
long NodeCnt,evrate,ETnodes,EvalNodes,HashCnt;
short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beep;
short wking,bking,FROMsquare,TOsquare,timeout,Zscore,zwndw,xwndw,slk;
short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beepit;
short wking,bking,FROMsquare,TOsquare,timeo,Zscore,zwndw,xwndw,slk;
short INCscore;
short HasPawn[2],HasKnight[2],HasBishop[2],HasRook[2],HasQueen[2];
short ChkFlag[maxdepth],CptrFlag[maxdepth],PawnThreat[maxdepth];
@ -405,7 +405,7 @@ short l,r,c,p;
mate = quit = reverse = bothsides = post = false;
hashflag = force = PawnStorm = false;
beep = rcptr = easy = true;
beepit = rcptr = easy = true;
lpost = NodeCnt = epsquare = et0 = 0;
dither = 0;
Awindow = 90;
@ -478,7 +478,7 @@ short side,iop;
{
static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
timeout = false;
timeo = false;
xside = otherside[side];
if (iop != 2) player = side;
if (TCflag)
@ -515,12 +515,12 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
MoveList(side,1);
for (i = TrPnt[1]; i < TrPnt[2]; i++) pick(i,TrPnt[2]-1);
if (Book != NULL) OpeningBook();
if (Book != NULL) timeout = true;
if (Book != NULL) timeo = true;
NodeCnt = ETnodes = EvalNodes = HashCnt = 0;
Zscore = 0; zwndw = 20;
}
while (!timeout && Sdepth < MaxSearchDepth)
while (!timeo && Sdepth < MaxSearchDepth)
{
Sdepth++;
ShowDepth(' ');
@ -541,17 +541,17 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
score = search(side,1,Sdepth,alpha,9000,PrVar,&rpt);
}
score = root->score;
if (!timeout)
if (!timeo)
for (i = TrPnt[1]+1; i < TrPnt[2]; i++) pick(i,TrPnt[2]-1);
ShowResults(score,PrVar,'.');
for (i = 1; i <= Sdepth; i++) killr0[i] = PrVar[i];
if (score > Zscore-zwndw && score > Tree[1].score+250) ExtraTime = 0;
else if (score > Zscore-3*zwndw) ExtraTime = ResponseTime;
else ExtraTime = 3*ResponseTime;
if (root->flags & exact) timeout = true;
if (Tree[1].score < -9000) timeout = true;
if (4*et > 2*ResponseTime + ExtraTime) timeout = true;
if (!timeout)
if (root->flags & exact) timeo = true;
if (Tree[1].score < -9000) timeo = true;
if (4*et > 2*ResponseTime + ExtraTime) timeo = true;
if (!timeo)
{
Tscore[0] = score;
if (Zscore == 0) Zscore = score;
@ -764,7 +764,7 @@ struct leaf *node,tmp;
node->reply = nxtline[ply+1];
UnmakeMove(side,node,&tempb,&tempc,&tempsf,&tempst);
}
if (node->score > best && !timeout)
if (node->score > best && !timeo)
{
if (depth > 0)
if (node->score > alpha && !(node->flags & exact))
@ -790,7 +790,7 @@ struct leaf *node,tmp;
}
}
if (NodeCnt > ETnodes) ElapsedTime(0);
if (timeout) return(-Tscore[ply-1]);
if (timeo) return(-Tscore[ply-1]);
}
node = &Tree[pbst];

View File

@ -19,7 +19,7 @@
file named COPYING. Among other things, the copyright notice
and this notice must be preserved on all copies.
$Id: gnuchess.h,v 1.1.1.1 1995/10/18 08:41:11 deraadt Exp $
$Id: gnuchess.h,v 1.2 1996/06/02 19:51:41 tholo Exp $
*/
@ -83,8 +83,8 @@ extern short c1,c2,*atk1,*atk2,*PC1,*PC2;
extern short mate,post,opponent,computer,Sdepth,Awindow,Bwindow,dither;
extern long ResponseTime,ExtraTime,Level,et,et0,time0,cputimer,ft;
extern long NodeCnt,evrate,ETnodes,EvalNodes,HashCnt;
extern short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beep,meter;
extern short timeout,xwndw;
extern short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beepit,meter;
extern short timeo,xwndw;
extern struct GameRec GameList[240];
extern short GameCnt,Game50,epsquare,lpost,rcptr,contempt;
extern short MaxSearchDepth;

View File

@ -25,7 +25,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: nondsp.c,v 1.1.1.1 1995/10/18 08:41:11 deraadt Exp $";
static char rcsid[] = "$Id: nondsp.c,v 1.2 1996/06/02 19:51:41 tholo Exp $";
#endif /* not lint */
#include <stdio.h>
@ -84,7 +84,7 @@ char s[80];
TerminateSearch()
{
timeout = true;
timeo = true;
bothsides = false;
}
#endif MSDOS
@ -159,7 +159,7 @@ char s[80];
if (strcmp(s,"list") == 0) ListGame();
if (strcmp(s,"level") == 0) SelectLevel();
if (strcmp(s,"hash") == 0) hashflag = !hashflag;
if (strcmp(s,"beep") == 0) beep = !beep;
if (strcmp(s,"beep") == 0) beepit = !beepit;
if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
if (strcmp(s,"rcptr") == 0) rcptr = !rcptr;
@ -406,7 +406,7 @@ OutputMove()
if (root->flags & epmask) UpdateDisplay(0,0,1,0);
else UpdateDisplay(root->f,root->t,0,root->flags & cstlmask);
printz("My move is: %s\n\n",mvstr1);
if (beep) printz("%c",7);
if (beepit) printz("%c",7);
if (root->flags & draw) printz("Draw game!\n");
else if (root->score == -9999) printz("opponent mates!\n");
@ -432,7 +432,7 @@ short iop;
ETnodes += 50;
if (et > et0 || iop == 1)
{
if (et > ResponseTime+ExtraTime && Sdepth > 1) timeout = true;
if (et > ResponseTime+ExtraTime && Sdepth > 1) timeo = true;
et0 = et;
if (iop == 1)
{
@ -443,7 +443,7 @@ short iop;
if (et > 0) evrate = NodeCnt/(et+ft); else evrate = 0;
if (kbhit() && Sdepth > 1)
{
timeout = true;
timeo = true;
bothsides = false;
}
#else

View File

@ -25,7 +25,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: uxdsp.c,v 1.1.1.1 1995/10/18 08:41:11 deraadt Exp $";
static char rcsid[] = "$Id: uxdsp.c,v 1.2 1996/06/02 19:51:42 tholo Exp $";
#endif /* not lint */
#include <stdio.h>
@ -82,7 +82,7 @@ TerminateSearch()
{
signal(SIGINT,SIG_IGN);
signal(SIGQUIT,SIG_IGN);
timeout = true;
timeo = true;
bothsides = false;
signal(SIGINT,Die); signal(SIGQUIT,Die);
}
@ -157,7 +157,7 @@ char s[80];
if (strcmp(s,"list") == 0) ListGame();
if (strcmp(s,"level") == 0) SelectLevel();
if (strcmp(s,"hash") == 0) hashflag = !hashflag;
if (strcmp(s,"beep") == 0) beep = !beep;
if (strcmp(s,"beep") == 0) beepit = !beepit;
if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
if (strcmp(s,"hint") == 0) GiveHint();
@ -391,7 +391,7 @@ OutputMove()
if (root->flags & epmask) UpdateDisplay(0,0,1,0);
else UpdateDisplay(root->f,root->t,0,root->flags & cstlmask);
gotoXY(50,17); printz("My move is: %s",mvstr1);
if (beep) putchar(7);
if (beepit) putchar(7);
ClrEoln();
gotoXY(50,24);
@ -425,7 +425,7 @@ short iop;
ETnodes += 50;
if (et > et0 || iop == 1)
{
if (et > ResponseTime+ExtraTime && Sdepth > 1) timeout = true;
if (et > ResponseTime+ExtraTime && Sdepth > 1) timeo = true;
et0 = et;
if (iop == 1)
{