comparison srogue/cx.h @ 36:2128c7dc8a40

Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
author elwin
date Thu, 25 Nov 2010 12:21:41 +0000
parents
children
comparison
equal deleted inserted replaced
35:05018c63a721 36:2128c7dc8a40
1 /*
2 * Super-Rogue
3 * Copyright (C) 1984 Robert D. Kindelberger
4 * All rights reserved.
5 *
6 * See the file LICENSE.TXT for full copyright and licensing information.
7 */
8
9 #include <stdio.h>
10 #include <sgtty.h>
11
12 #define bool char /* boolean variable */
13 #define reg register /* register abbr. */
14
15 #define TRUE (1)
16 #define FALSE (0)
17 #define ERR (0) /* default return on error */
18 #define OK (1) /* default return on good run */
19
20 #define _SUBWIN 01 /* window is a subwindow */
21 #define _ENDLINE 02 /* lines go to end of screen */
22 #define _FULLWIN 04 /* window is entire screen */
23 #define _SCROLLWIN 010 /* window could cause scroll */
24 #define _STANDOUT 0200 /* standout mode in effect */
25 #define _NOCHANGE -1 /* no change on this line */
26
27 #define _puts(s) tputs(s, 0, _putchar);
28
29 typedef struct sgttyb SGTTY;
30
31 #ifndef WINDOW
32
33 #define WINDOW struct _win_st
34
35 /* window description structure */
36 struct _win_st {
37 short _cury, _curx; /* current y,x positions */
38 short _maxy, _maxx; /* maximum y,x positions */
39 short _begy, _begx; /* start y,x positions */
40 short _flags; /* various window flags */
41 bool _clear; /* need to clear */
42 bool _leave; /* leave cur x,y at last update */
43 bool _scroll; /* scrolls allowed */
44 char **_y; /* actual window */
45 short *_firstch; /* first change on line */
46 short *_lastch; /* last change on line */
47 };
48
49 extern bool My_term, /* user specied terminal */
50 _echoit, /* set if echoing characters */
51 _rawmode; /* set if terminal in raw mode */
52
53 extern char *Def_term, /* default terminal type */
54 ttytype[]; /* long name of current term */
55 # ifdef DEBUG
56 extern FILE *outf; /* error outfile */
57 # endif
58
59 extern int LINES, COLS; /* # of lines & columns */
60 extern int _tty_ch; /* channel with tty on it */
61 extern WINDOW *stdscr, *curscr;
62
63 static SGTTY _tty, _res_flg;
64
65 /*
66 * Define VOID to stop lint from generating "null effect"
67 * comments.
68 */
69 # ifdef lint
70 int __void__; /* place to assign to */
71
72 # define VOID(x) (__void__ = (int) (x))
73 # else
74 # define VOID(x) (x)
75 # endif
76
77 # endif
78
79 /*
80 * psuedo functions for standard screen
81 */
82 #define addch(ch) VOID(waddch(stdscr, ch))
83 #define getch() VOID(wgetch(stdscr))
84 #define addstr(str) VOID(waddstr(stdscr, str))
85 #define getstr(str) VOID(wgetstr(stdscr, str))
86 #define move(y, x) VOID(wmove(stdscr, y, x))
87 #define clear() VOID(wclear(stdscr))
88 #define erase() VOID(werase(stdscr))
89 #define clrtobot() VOID(wclrtobot(stdscr))
90 #define clrtoeol() VOID(wclrtoeol(stdscr))
91 #define insertln() VOID(winsertln(stdscr))
92 #define deleteln() VOID(wdeleteln(stdscr))
93 #define refresh() VOID(wrefresh(stdscr))
94 #define inch() VOID(winch(stdscr))
95
96 #ifdef STANDOUT
97 #define standout() VOID(wstandout(stdscr))
98 #define standend() VOID(wstandend(stdscr))
99 #endif
100
101 /*
102 # define CBREAK FALSE
103 # define _IOSTRG 01
104 */
105
106 /*
107 * mv functions
108 */
109 #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
110 #define mvwgetch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win,ch))
111 #define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
112 #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
113 #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
114 #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
115 #define mvgetch(y,x,ch) mvwgetch(stdscr,y,x,ch)
116 #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
117 #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
118 #define mvinch(y,x) mvwinch(stdscr,y,x)
119
120 /*
121 * psuedo functions
122 */
123
124 #define clearok(win,bf) (win->_clear = bf)
125 #define leaveok(win,bf) (win->_leave = bf)
126 #define scrollok(win,bf) (win->_scroll = bf)
127 #define getyx(win,y,x) y = win->_cury, x = win->_curx
128 #define winch(win) (win->_y[win->_cury][win->_curx])
129
130 WINDOW *initscr(), *newwin();