tony@wldrdg.UUCP (06/10/87)
Here's the version of curses for Megamax that I promised. The readme.too
file contains comments specific to the Megamax version.
Tony Andrews
ihnp4!onecom!wldrdg!tony
Wildridge Consulting, Inc.
Boulder, CO
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# readme.too
# readme.txt
# twinkle.c
# portab.h
# curses.man
# curses.h
# This archive created: Tue Jun 9 23:02:35 1987
export PATH; PATH=/bin:$PATH
if test -f 'readme.too'
then
echo shar: will not over-write existing file "'readme.too'"
else
cat << \HE_HATES_THESE_CANS > 'readme.too'
Notes for the Megamax Version of Curses
This version of curses compiles with the Megamax C compiler. A couple
of bug fixes were needed and the wgetstr routine was hacked quite a bit.
Notes:
1. The overlay() routine was renamed woverlay() to avoid a conflict with
the Megamax reserved word.
2. The entire file was placed in an overlay because I needed the space.
You may want to get rid of the overlay line in curses.c depending on
what you're linking curses with.
3. The routines printw() and scanw() are implemented in the usual brute-
force way since Megamax doesn't have varargs. These are at the end
of curses.c.
4. Remember to change your init.c to get extra stack space.
5. The file portab.h contains the definitions needed from the Alcyon
file of the same name. If you have a more complete version, use it.
6. twinkle.tos isn't in this distribution because I wanted to post this
stuff as clear text.
Tony Andrews
ihnp4!onecom!wldrdg!tony
Wildridge Consulting, Inc.
Boulder, CO
HE_HATES_THESE_CANS
fi # end of overwriting check
if test -f 'readme.txt'
then
echo shar: will not over-write existing file "'readme.txt'"
else
cat << \HE_HATES_THESE_CANS > 'readme.txt'
This is Atari-curses, read the curses.doc file about installing first.
The archive should contain the following files :
CURSES.C Source for CURSES, compile once.
CURSES.H Include file for CURSES.C and any program using CURSES.
CURSES.MAN CURSES short docs, a manual page for UN*X-freaks.
CURSES.DOC CURSES long docs, this is what you will want to read when
you are going to use CURSES.
README.TXT This file.
TWINKLE.C Sample application.
TWINKLE.TOS Ready to run sample application.
This is essentially a shareware program, its usage is subject to the following
conditions :
PUBLIC-DOMAIN : don't take the credit for it.
Commercial purposes : Send 5 US-dollars or equivalent currency and return
postage to me to get a written consent to use it.
CURSES may be distributed to anyone, provided that all of the above files
remain in the archive, and the various copyright notices remain intact.
Bug reports and suggestions are welcome, send me e-mail.
Rene van't Veen ( ...!mcvax!nikhefh!u13 )
Debussystraat 27
1817 GL Alkmaar
The Netherlands
HE_HATES_THESE_CANS
fi # end of overwriting check
if test -f 'twinkle.c'
then
echo shar: will not over-write existing file "'twinkle.c'"
else
cat << \HE_HATES_THESE_CANS > 'twinkle.c'
/* sample application using curses calls, this takes about 25 seconds on the */
/* Atari and over 6 minutes on a mainframe, using a vt100 on a 4800 baud */
/* line. Even on the mainframe it uses 24 seconds of computation time. */
#include "portab.h"
#include "curses.h"
#define NCOLS 80
#define NLINES 24
#define MAXPATT 4
struct locs {
char y,x ;
} ;
typedef struct locs LOCS ;
LOCS Layout[NCOLS*NLINES] ;
int pat ;
int nstar ;
main()
{
int i ;
initscr() ;
leaveok(stdscr,1) ;
for ( i = 0 ; i < 10 ; i++ )
{
makeboard() ;
puton('*') ;
puton(' ') ;
} ;
endwin() ;
}
makeboard()
{
int y,x ;
LOCS *lp ;
pat = rand() % MAXPATT ;
lp = Layout ;
for ( y = 0 ; y < NLINES ; y++ )
for ( x = 0 ; x < NCOLS ; x++ )
if ( ison(y,x) )
{
lp->y = y ;
lp->x = x ;
lp++ ;
} ;
nstar = lp - Layout ;
}
ison(y,x)
int y,x ;
{
switch ( pat )
{
case 0:
return(!(y & 0x01)) ;
case 1:
if ( x >= NLINES && y >= NCOLS )
return(0) ;
if ( y < 3 || y >= NLINES - 3 )
return(1) ;
return((x < 3 || x >= NCOLS - 3 )) ;
case 2:
return(((x+y) & 0x01)) ;
case 3:
return(( y>= 9 && y <= 15 )) ;
} ;
}
puton(ch)
char ch ;
{
LOCS *lp, *end, temp ;
int r ;
end = &(Layout[nstar]) ;
for ( lp = Layout ; lp < end ; lp++ )
{
r = ((unsigned int) rand()) % nstar ;
temp = *lp ;
*lp = Layout[r] ;
Layout[r] = temp ;
} ;
for ( lp = Layout ; lp < end ; lp++ )
{
mvaddch(lp->y,lp->x,ch) ;
refresh() ;
} ;
}
HE_HATES_THESE_CANS
fi # end of overwriting check
if test -f 'portab.h'
then
echo shar: will not over-write existing file "'portab.h'"
else
cat << \HE_HATES_THESE_CANS > 'portab.h'
/*
* This file re-implements portions of the Alcyon portab.h needed
* by curses. If you have a more complete portab.h that contains
* the following definitions, use it.
*/
#define BYTE char
#define WORD int
#define LONG long
HE_HATES_THESE_CANS
fi # end of overwriting check
if test -f 'curses.man'
then
echo shar: will not over-write existing file "'curses.man'"
else
cat << \HE_HATES_THESE_CANS > 'curses.man'
CURSES(3X) CURSES(3X)
NAME
curses - screen functions with "optimal" cursor motion
DESCRIPTION
The functions in the curses-package give you an implementation of the
UN*X-curses package for the Atari ST series computer. It allows you to do
terminal-oriented graphics of a crude nature. An image is kept of what the
current screen looks like, while the user creates a new image. Refresh()
must be called to make the current screen look like the one the user has
prepared. Initscr() must be called to initialize the package and endwin()
to clean up before exiting.
SEE ALSO
Screen Updating and Cursor Movement Optimization : A Library Package,
Ken Arnold.
The CURSES screen updating and cursor movement package : A collection
of C-functions for the Atari ST-series computers, R. van 't Veen.
AUTHORS
UN*X-curses : Ken Arnold.
Atari-curses : Rene van 't Veen.
FUNCTIONS
addch(c) add a character to stdscr
addstr(s) add a string to stdscr
box(win,v,h) draw a box around a window
crmode() set cbreak mode
clear() clear stdscr
clearok(scr,f) set clear flag for scr
cltobot() clear to bottom on stdscr
clrtoeol() clear to end of line on stdscr
delch() delete a character
deleteln() delete a line
delwin(w) delete window w
echo() set echo mode
endwin() end window mode
erase() erase stdscr
getch() get a char through stdscr
getstr() get a string through stdscr
getyx(w,y,x) get current coordinates
inch() get char at current coordinates
initscr() initialize curses
insch() insert a character
insertln() insert a line
leaveok(w,f) set leave flag for window w
longname(termbuf, name) get a long terminal name
move(y,x) move to (y,x) on stdscr
mvcur(ly,lx,ny,nx) actually move the cursor
newwin(lines,cols,begin_y,begin_x) create a window
nl() set newline mapping on
nocrmode() unset cbreak mode
noecho() unset echo mode
nonl() set newline mapping off
noraw() unset raw mode
overlay(win1,win2) overlay win1 on win2
overwrite(win1,win2) overwrite win1 on win2
raw() set raw mode
refresh() make terminal look like stdscr
scroll(win) scroll win one line up
scrollok(w,f) set scroll flag for window win
standend() leave standout mode
standout() enter standout mode
subwin(win,lines,cols,begin_y,begin_x) create a sub window
touchwin(win) change everything on win
waddch(win,c) add char to win
waddstr(win,s) add string to win
wclear(w) clear w
wclrtobot(w) clear w to bottom of w
wclrtoeol(w) clear w to end of line
wdelch(w) delete character from w
wdeleteln(w) delete line from w
werase(w) erase w
wgetch(w) get a character through w
wgetstr(w,s) get a string through w
winch(w) get char at current (y,x) of w
winsch(w,c) insert a char on w
winsertln(w) insert a line on w
wmove(w,y,x) set current coordinates of w
wrefresh(w) make terminal look like w
wstandend(w) leave standout mode for w
wstandout(w) enter standout mode for w
BUGS
Hopefully none, but you never know ...
If you find any, please let me know,
I ( Rene ) am at ..!mcvax!nikhefh!u13 .
HE_HATES_THESE_CANS
fi # end of overwriting check
if test -f 'curses.h'
then
echo shar: will not over-write existing file "'curses.h'"
else
cat << \HE_HATES_THESE_CANS > 'curses.h'
/* ************************************************************************ */
/* */
/* CURSES.H include file for programs using CURSES */
/* */
/* ************************************************************************ */
/* */
/* This source and resulting object may be modified, used or distributed by */
/* anyone who so desires under the following conditions : */
/* */
/* 1) This notice and the copyright notice shall not be removed or */
/* changed. */
/* 2) No credit shall be taken for this source and resulting objects */
/* 3) This source or resulting objects is not to be traded, sold or */
/* used for personal gain or profit. */
/* 4) Inclusion of this source or resulting objects in commercially */
/* available packages is forbidden without written consent of the */
/* author of this source. */
/* */
/* ************************************************************************ */
#include "portab.h"
#include "stdio.h"
#define reg register
#define bool BYTE
#define TRUE 1
#define FALSE 0
#define _SUBWIN 01
#define _ENDLINE 02
#define _FULLWIN 04
#define _SCROLLWIN 010
#define _STANDOUT 0200
#define WINDOW struct _win_st
#define TOUCHED 0x0200
#define STANDOUT 0x0100
#define addch(c) waddch(stdscr, c)
#define mvaddch(y,x,c) { wmove(stdscr,y,x) ; waddch(stdscr,c) ; }
#define mvwaddch(w,y,x,c) { wmove(w,y,x) ; waddch(w,c) ; }
#define addstr(s) waddstr(stdscr,s)
#define mvaddstr(y,x,s) { wmove(stdscr,y,x) ; waddstr(stdscr,s) ; }
#define mvwaddstr(w,y,x,s) { wmove(w,y,x) ; waddstr(w,s) ; }
#define clear() wclear(stdscr)
#define clearok(w,f) { w->_clear = (w->_flags & _FULLWIN) ? f : w->_clear ; }
#define clrtobot() wclrtobot(stdscr)
#define clrtoeol() wclrtoeol(stdscr)
#define delch() wdelch(stdscr)
#define mvdelch(y,x) { wmove(stdscr,y,x) ; wdelch(stdscr) ; }
#define mvwdelch(w,y,x) { wmove(w,y,x) ; wdelch(w) ; }
#define deleteln() wdeleteln(stdscr)
#define mvdeleteln(y,x) { wmove(stdscr,y,x) ; wdeleteln(stdscr) ; }
#define mvwdeleteln(w,y,x) { wmove(w,y,x) ; wdeleteln(w) ; }
#define erase() werase(stdscr)
#define insch(c) winsch(stdscr,c)
#define mvinsch(y,x,c) { wmove(stdscr,y,x) ; winsch(stdscr,c) ; }
#define mvwinsch(w,y,x,c) { wmove(w,y,x) ; winsch(w,c) ; }
#define insertln() winsertln(stdscr)
#define mvinsertln(y,x) { wmove(stdscr,y,x) ; winsertln(stdscr) ; }
#define mvwinsertln(w,y,x) { wmove(w,y,x) ; winsertln(w) ; }
#define move(y,x) wmove(stdscr,y,x)
#define refresh() wrefresh(stdscr)
#define standout() wstandout(stdscr)
#define standend() wstandend(stdscr)
#define getch() wgetch(stdscr)
#define mvgetch(y,x) ( wmove(stdscr,y,x) , wgetch(stdscr) )
#define mvwgetch(w,y,x) ( wmove(w,y,x) , wgetch(w) )
#define getstr(s) wgetstr(stdscr,s)
#define mvgetstr(y,x,s) { wmove(stdscr,y,x) ; wgetstr(stdscr,s) ; }
#define mvwgetstr(w,y,x,s) { wmove(w,y,x) ; wgetstr(w,s) ; }
#define getyx(w,y,x) { y = w->_cury ; x = w->_curx ; }
#define inch() (stdscr->_y[stdscr->_cury][stdscr->_curx])
#define mvinch(y,x) ( wmove(stdscr,y,x) , stdscr->_y[stdscr->_cury][stdscr->_curx])
#define mvwinch(w,y,x) ( wmove(w,y,x) , w4->_y[w->_cury][w->_curx])
#define winch(w) (w->_y[w->_cury][w->_curx])
struct _win_st {
WORD _cury, _curx ;
WORD _maxy, _maxx ;
WORD _begy, _begx ;
WORD _flags ;
BYTE _clear ;
BYTE _leave ;
BYTE _scroll ;
WORD **_y ;
WORD *_firstch ;
WORD *_lastch ;
} ;
extern WINDOW *curscr ;
extern WINDOW *stdscr ;
extern char *Def_term ;
extern bool My_term ;
extern char *ttytype ;
extern int LINES ;
extern int COLS ;
extern int ERR ;
extern int OK ;
HE_HATES_THESE_CANS
fi # end of overwriting check
# End of shell archive
exit 0