Gather curses dependencies

This commit is contained in:
jl777
2019-02-15 04:44:22 -11:00
parent 2b4dfbbcda
commit c9b2389854
33 changed files with 242 additions and 149 deletions

View File

@@ -9,7 +9,7 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -10,8 +10,8 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
#define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */ #define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */

View File

@@ -10,10 +10,7 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <curses.h>
#include <string.h>
#include <curses.h>
#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -11,7 +11,7 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
#define EMPTY 0 #define EMPTY 0

View File

@@ -10,7 +10,7 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -10,7 +10,7 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"

View File

@@ -13,6 +13,9 @@
#ifndef H_EXTERN_ROGUE_H #ifndef H_EXTERN_ROGUE_H
#define H_EXTERN_ROGUE_H #define H_EXTERN_ROGUE_H
#include <stdio.h>
#include <stdbool.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#ifdef PDCURSES #ifdef PDCURSES
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H

View File

@@ -10,10 +10,10 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
//#define EQSTR(a, b) (strcmp(a, b) == 0) //#define EQSTR(a, b) (strcmp(a, b) == 0)

View File

@@ -10,10 +10,10 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include <ctype.h> //#include <ctype.h>
#include <string.h> //#include <string.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -4,10 +4,10 @@
* @(#)io.c 4.32 (Berkeley) 02/05/99 * @(#)io.c 4.32 (Berkeley) 02/05/99
*/ */
#include <stdarg.h> //#include <stdarg.h>
#include <curses.h> //#include <curses.h>
#include <ctype.h> //#include <ctype.h>
#include <string.h> //#include <string.h>
#include "rogue.h" #include "rogue.h"
/* /*
@@ -162,7 +162,8 @@ readchar(struct rogue_state *rs)
//fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); //fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]);
return(rs->keystrokes[rs->ind++]); return(rs->keystrokes[rs->ind++]);
} }
fprintf(stderr,"replay finished but readchar called\n"); if ( rs->replaydone != 0 )
fprintf(stderr,"replay finished but readchar called\n");
rs->replaydone = (uint32_t)time(NULL); rs->replaydone = (uint32_t)time(NULL);
//if ( (rand() & 1) == 0 ) //if ( (rand() & 1) == 0 )
// return(ESCAPE); // return(ESCAPE);

View File

@@ -10,9 +10,9 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include <memory.h> //#include <memory.h>
#include "rogue.h" #include "rogue.h"
#ifdef MASTER #ifdef MASTER

View File

@@ -46,7 +46,8 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
#include <curses.h> //#include <curses.h>
#include "rogue.h"
#include "extern.h" #include "extern.h"
#define NOOP(x) (x += 0) #define NOOP(x) (x += 0)

View File

@@ -44,7 +44,7 @@
#undef MOUSE_MOVED #undef MOUSE_MOVED
#endif #endif
#include <curses.h> //#include <curses.h>
#include "extern.h" #include "extern.h"
#if defined(HAVE_SYS_TYPES) #if defined(HAVE_SYS_TYPES)

View File

@@ -10,10 +10,10 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -10,10 +10,10 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include "rogue.h" #include "rogue.h"
#include <ctype.h> //#include <ctype.h>
/* /*
* List of monsters in rough order of vorpalness * List of monsters in rough order of vorpalness

View File

@@ -10,8 +10,8 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -11,8 +11,8 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include "rogue.h" #include "rogue.h"
#define TREAS_ROOM 20 /* one chance in TREAS_ROOM for a treasure room */ #define TREAS_ROOM 20 /* one chance in TREAS_ROOM for a treasure room */

View File

@@ -12,10 +12,10 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include <ctype.h> //#include <ctype.h>
#include <string.h> //#include <string.h>
#include "rogue.h" #include "rogue.h"
#define EQSTR(a, b, c) (strncmp(a, b, c) == 0) #define EQSTR(a, b, c) (strncmp(a, b, c) == 0)

View File

@@ -10,9 +10,9 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <string.h> //#include <string.h>
#include <curses.h> //#include <curses.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -10,8 +10,8 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -10,8 +10,8 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
typedef struct typedef struct

View File

@@ -10,7 +10,7 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -11,14 +11,14 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <string.h> //#include <string.h>
#include <time.h> //#include <time.h>
#include <signal.h> #include <signal.h>
#include <sys/types.h> //#include <sys/types.h>
#include <ctype.h> //#include <ctype.h>
#include <fcntl.h> //#include <fcntl.h>
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
#include "score.h" #include "score.h"

View File

@@ -8,12 +8,11 @@
* @(#)main.c 4.22 (Berkeley) 02/05/99 * @(#)main.c 4.22 (Berkeley) 02/05/99
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <string.h> //#include <string.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> //#include <unistd.h>
#include <time.h> //#include <curses.h>
#include <curses.h>
#include "rogue.h" #include "rogue.h"
#ifdef STANDALONE #ifdef STANDALONE
#include "../komodo/src/komodo_cJSON.h" #include "../komodo/src/komodo_cJSON.h"
@@ -88,6 +87,8 @@ void rogueiterate(struct rogue_state *rs)
endwin(); endwin();
my_exit(1); my_exit(1);
} }
//fprintf(stderr,"LINES %d, COLS %d\n",LINES,COLS);
// Set up windows // Set up windows
if ( hw == NULL ) if ( hw == NULL )
hw = newwin(LINES, COLS, 0, 0); hw = newwin(LINES, COLS, 0, 0);
@@ -247,21 +248,24 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu
} }
uint32_t starttime = (uint32_t)time(NULL); uint32_t starttime = (uint32_t)time(NULL);
rogueiterate(rs); rogueiterate(rs);
/*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); if ( 0 )
sleep(2);
starttime = (uint32_t)time(NULL);
for (i=0; i<100; i++)
{ {
memset(rs,0,sizeof(*rs)); fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime);
rs->seed = seed; sleep(2);
rs->keystrokes = keystrokes;
rs->numkeys = num; starttime = (uint32_t)time(NULL);
rs->sleeptime = 0; for (i=0; i<10000; i++)
rogueiterate(rs); {
memset(rs,0,sizeof(*rs));
rs->seed = seed;
rs->keystrokes = keystrokes;
rs->numkeys = num;
rs->sleeptime = 0;
rogueiterate(rs);
}
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime);
sleep(3);
} }
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime);
sleep(1);*/
if ( (fp= fopen("checkfile","wb")) != 0 ) if ( (fp= fopen("checkfile","wb")) != 0 )
{ {
save_file(rs,fp,0); save_file(rs,fp,0);

View File

@@ -12,10 +12,92 @@
#ifndef H_ROGUE_H #ifndef H_ROGUE_H
#define H_ROGUE_H #define H_ROGUE_H
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h> /* we need va_list */
#include <stddef.h> /* we want wchar_t */
#include <stdbool.h>
#include <ctype.h>
#include "extern.h" #include <time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#undef lines #ifndef DONTUSEGUI
#include <curses.h>
#else
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef void *WINDOW;
WINDOW stdscr;
#define standout()
#define standend()
#define refresh()
#define raw()
#define noecho()
#define flushinp()
#define initscr()
#define clear()
#define clrtoeol()
#define addch(a)
#define werase(a)
#define wclear(a)
#define delwin(a)
#define addstr(a)
#define touchwin(a)
#define idlok(a,b)
#define clearok(a,b)
#define keypad(a,b)
#define leaveok(a,b)
#define waddch(a,b)
#define waddstr(a,b)
#define move(a,b)
#define mvwin(a,b,c)
#define wmove(a,b,c)
#define mvaddch(a,b,c)
#define mvaddstr(a,b,c)
#define wgetnstr(a,b,c)
#define getyx(a,b,c)
#define mvcur(a,b,c,d)
#define mvwaddch(a,b,c,d)
#define mvprintw(...)
#define printw(...)
#define wprintw(...)
#define mvwprintw(...)
#define A_CHARTEXT 0xff
#define inch() 0
#define endwin() 1
#define isendwin() 0
#define baudrate() 9600
#define killchar() 3
#define erasechar() 8
#define wclrtoeol(a) 0
#define wrefresh(a) 0
#define unctrl(a) "^x"
#define getmaxx(a) COLS
#define getmaxy(a) LINES
#define mvinch(a,b) '.'
#define mvwinch(a,b,c) 0
#define newwin(a,b,c,d) 0
#define subwin(a,b,c,d,e) 0
#endif
#ifdef LINES #ifdef LINES
#undef LINES #undef LINES
@@ -27,6 +109,11 @@
#define LINES 24 #define LINES 24
#define COLS 80 #define COLS 80
#include "extern.h"
#undef lines
#define NOOP(x) (x += 0) #define NOOP(x) (x += 0)
#define CCHAR(x) ( (char) (x & A_CHARTEXT) ) #define CCHAR(x) ( (char) (x & A_CHARTEXT) )
/* /*

View File

@@ -10,8 +10,8 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <ctype.h> //#include <ctype.h>
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
typedef struct spot { /* position matrix for maze positions */ typedef struct spot { /* position matrix for maze positions */

View File

@@ -10,13 +10,13 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <sys/types.h> //#include <sys/types.h>
#include <sys/stat.h> //#include <sys/stat.h>
#include <errno.h> //#include <errno.h>
#include <signal.h> //#include <signal.h>
#include <string.h> //#include <string.h>
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
#include "score.h" #include "score.h"

View File

@@ -10,8 +10,8 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -29,9 +29,9 @@
SUCH DAMAGE. SUCH DAMAGE.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <string.h> //#include <string.h>
#include <curses.h> //#include <curses.h>
#include "rogue.h" #include "rogue.h"
/************************************************************************/ /************************************************************************/

View File

@@ -11,9 +11,9 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*

View File

@@ -11,9 +11,9 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*
@@ -498,55 +498,55 @@ add_line(struct rogue_state *rs,char *fmt, char *arg)
if (line_cnt >= LINES - 1 || fmt == NULL) if (line_cnt >= LINES - 1 || fmt == NULL)
{ {
if (inv_type == INV_OVER && fmt == NULL && !newpage) if (inv_type == INV_OVER && fmt == NULL && !newpage)
{ {
msg(rs,""); msg(rs,"");
if ( rs->sleeptime != 0 ) if ( rs->sleeptime != 0 )
refresh(); refresh();
tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3);
sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2);
for (y = 0; y <= line_cnt; y++) for (y = 0; y <= line_cnt; y++)
{ {
wmove(sw, y, 0); wmove(sw, y, 0);
for (x = 0; x <= maxlen; x++) for (x = 0; x <= maxlen; x++)
waddch(sw, mvwinch(hw, y, x)); waddch(sw, mvwinch(hw, y, x));
} }
wmove(tw, line_cnt, 1); wmove(tw, line_cnt, 1);
waddstr(tw, prompt); waddstr(tw, prompt);
/* /*
* if there are lines below, use 'em * if there are lines below, use 'em
*/ */
if (LINES > NUMLINES) if (LINES > NUMLINES)
{ {
if (NUMLINES + line_cnt > LINES) if (NUMLINES + line_cnt > LINES)
mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3);
else else
mvwin(tw, NUMLINES, 0); mvwin(tw, NUMLINES, 0);
} }
touchwin(tw); touchwin(tw);
wrefresh(tw); wrefresh(tw);
wait_for(rs,' '); wait_for(rs,' ');
if (md_hasclreol()) if (md_hasclreol())
{ {
werase(tw); werase(tw);
leaveok(tw, TRUE); leaveok(tw, TRUE);
wrefresh(tw); wrefresh(tw);
} }
delwin(tw); delwin(tw);
touchwin(stdscr); touchwin(stdscr);
} }
else else
{ {
wmove(hw, LINES - 1, 0); wmove(hw, LINES - 1, 0);
waddstr(hw, prompt); waddstr(hw, prompt);
wrefresh(hw); wrefresh(hw);
wait_for(rs,' '); wait_for(rs,' ');
clearok(curscr, TRUE); clearok(curscr, TRUE);
wclear(hw); wclear(hw);
touchwin(stdscr); touchwin(stdscr);
} }
newpage = TRUE; newpage = TRUE;
line_cnt = 0; line_cnt = 0;
maxlen = (int) strlen(prompt); maxlen = (int) strlen(prompt);
} }
if (fmt != NULL && !(line_cnt == 0 && *fmt == '\0')) if (fmt != NULL && !(line_cnt == 0 && *fmt == '\0'))
{ {

View File

@@ -10,9 +10,9 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
#define NO_WEAPON -1 #define NO_WEAPON -1

View File

@@ -11,10 +11,10 @@
* See the file LICENSE.TXT for full copyright and licensing information. * See the file LICENSE.TXT for full copyright and licensing information.
*/ */
#include <stdlib.h> //#include <stdlib.h>
#include <curses.h> //#include <curses.h>
#include <string.h> //#include <string.h>
#include <ctype.h> //#include <ctype.h>
#include "rogue.h" #include "rogue.h"
/* /*