diff --git a/src/cc/rogue/armor.c b/src/cc/rogue/armor.c index 5244628b1..20c5704a8 100644 --- a/src/cc/rogue/armor.c +++ b/src/cc/rogue/armor.c @@ -9,7 +9,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/chase.c b/src/cc/rogue/chase.c index 73d53e1fd..059df470d 100644 --- a/src/cc/rogue/chase.c +++ b/src/cc/rogue/chase.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" #define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */ diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 63aed25be..1a32246bb 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -10,10 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index 8309dc642..1da06d499 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -11,7 +11,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" #define EMPTY 0 diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 436aa004d..42e685320 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -10,7 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/extern.c b/src/cc/rogue/extern.c index 39a48b23f..fdb77307c 100644 --- a/src/cc/rogue/extern.c +++ b/src/cc/rogue/extern.c @@ -10,7 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 486d85ff1..fc3454830 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -13,6 +13,9 @@ #ifndef H_EXTERN_ROGUE_H #define H_EXTERN_ROGUE_H +#include +#include + #ifdef HAVE_CONFIG_H #ifdef PDCURSES #undef HAVE_UNISTD_H diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index 7f4aad587..43474616e 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" //#define EQSTR(a, b) (strcmp(a, b) == 0) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 1f63e1d51..1603474e2 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 30795f2ad..6791c26a4 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -4,10 +4,10 @@ * @(#)io.c 4.32 (Berkeley) 02/05/99 */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /* @@ -162,7 +162,8 @@ readchar(struct rogue_state *rs) //fprintf(stderr,"(%c) ",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); //if ( (rand() & 1) == 0 ) // return(ESCAPE); diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 6affc662c..622af60cd 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -10,9 +10,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" #ifdef MASTER diff --git a/src/cc/rogue/mach_dep.c b/src/cc/rogue/mach_dep.c index 34e502816..6d0e1c66f 100644 --- a/src/cc/rogue/mach_dep.c +++ b/src/cc/rogue/mach_dep.c @@ -46,7 +46,8 @@ #include #include #include -#include +//#include +#include "rogue.h" #include "extern.h" #define NOOP(x) (x += 0) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index acd257617..443ef1e60 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -44,7 +44,7 @@ #undef MOUSE_MOVED #endif -#include +//#include #include "extern.h" #if defined(HAVE_SYS_TYPES) diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 168886b6b..7db9d073a 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 4649de9a2..2f6d68362 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -10,10 +10,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" -#include +//#include /* * List of monsters in rough order of vorpalness diff --git a/src/cc/rogue/move.c b/src/cc/rogue/move.c index 3bdf90d37..c70d668ca 100644 --- a/src/cc/rogue/move.c +++ b/src/cc/rogue/move.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index 9dc0d761f..b55d3e42c 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -11,8 +11,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" #define TREAS_ROOM 20 /* one chance in TREAS_ROOM for a treasure room */ diff --git a/src/cc/rogue/options.c b/src/cc/rogue/options.c index 6907da598..d74979365 100644 --- a/src/cc/rogue/options.c +++ b/src/cc/rogue/options.c @@ -12,10 +12,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" #define EQSTR(a, b, c) (strncmp(a, b, c) == 0) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index ee628b4f0..b6debc966 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -10,9 +10,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/passages.c b/src/cc/rogue/passages.c index 79b3706aa..5437f4972 100644 --- a/src/cc/rogue/passages.c +++ b/src/cc/rogue/passages.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index de09efb9b..00865b5dd 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" typedef struct diff --git a/src/cc/rogue/rings.c b/src/cc/rogue/rings.c index 56f7a0294..747da302a 100644 --- a/src/cc/rogue/rings.c +++ b/src/cc/rogue/rings.c @@ -10,7 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index a5b3e7208..be97fb867 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -11,14 +11,14 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" #include "score.h" diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 00cda9426..be17b25be 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -8,12 +8,11 @@ * @(#)main.c 4.22 (Berkeley) 02/05/99 */ -#include -#include +//#include +//#include #include -#include -#include -#include +//#include +//#include #include "rogue.h" #ifdef STANDALONE #include "../komodo/src/komodo_cJSON.h" @@ -88,6 +87,8 @@ void rogueiterate(struct rogue_state *rs) endwin(); my_exit(1); } + //fprintf(stderr,"LINES %d, COLS %d\n",LINES,COLS); + // Set up windows if ( hw == NULL ) 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); rogueiterate(rs); - /*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); - sleep(2); - - starttime = (uint32_t)time(NULL); - for (i=0; i<100; i++) + if ( 0 ) { - 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(2); + + starttime = (uint32_t)time(NULL); + for (i=0; i<10000; i++) + { + 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 ) { save_file(rs,fp,0); diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index a407ae8a6..419d5aa1b 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -12,10 +12,92 @@ #ifndef H_ROGUE_H #define H_ROGUE_H +#include +#include +#include +#include +#include +#include +#include /* we need va_list */ +#include /* we want wchar_t */ +#include +#include -#include "extern.h" +#include +#include +#include +#include +#include -#undef lines +#ifndef DONTUSEGUI +#include +#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 #undef LINES @@ -27,6 +109,11 @@ #define LINES 24 #define COLS 80 +#include "extern.h" + + +#undef lines + #define NOOP(x) (x += 0) #define CCHAR(x) ( (char) (x & A_CHARTEXT) ) /* diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index 31991b08f..41041d627 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" typedef struct spot { /* position matrix for maze positions */ diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index adec30e2e..718c5074b 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -10,13 +10,13 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include #include "rogue.h" #include "score.h" diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index b6854ab07..5554a5701 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -10,8 +10,8 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 3db54a319..e034039a8 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -29,9 +29,9 @@ SUCH DAMAGE. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" /************************************************************************/ diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index 39e098339..f048f9423 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -11,9 +11,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" /* diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 4e572c60b..29c51c4ed 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -11,9 +11,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #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 (inv_type == INV_OVER && fmt == NULL && !newpage) - { - msg(rs,""); + { + msg(rs,""); if ( rs->sleeptime != 0 ) refresh(); - tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); - sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); - for (y = 0; y <= line_cnt; y++) - { - wmove(sw, y, 0); - for (x = 0; x <= maxlen; x++) - waddch(sw, mvwinch(hw, y, x)); - } - wmove(tw, line_cnt, 1); - waddstr(tw, prompt); - /* - * if there are lines below, use 'em - */ - if (LINES > NUMLINES) - { - if (NUMLINES + line_cnt > LINES) - mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); - else - mvwin(tw, NUMLINES, 0); - } - touchwin(tw); - wrefresh(tw); - wait_for(rs,' '); - if (md_hasclreol()) - { - werase(tw); - leaveok(tw, TRUE); - wrefresh(tw); - } - delwin(tw); - touchwin(stdscr); + tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); + sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); + for (y = 0; y <= line_cnt; y++) + { + wmove(sw, y, 0); + for (x = 0; x <= maxlen; x++) + waddch(sw, mvwinch(hw, y, x)); + } + wmove(tw, line_cnt, 1); + waddstr(tw, prompt); + /* + * if there are lines below, use 'em + */ + if (LINES > NUMLINES) + { + if (NUMLINES + line_cnt > LINES) + mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); + else + mvwin(tw, NUMLINES, 0); + } + touchwin(tw); + wrefresh(tw); + wait_for(rs,' '); + if (md_hasclreol()) + { + werase(tw); + leaveok(tw, TRUE); + wrefresh(tw); + } + delwin(tw); + touchwin(stdscr); } else { - wmove(hw, LINES - 1, 0); - waddstr(hw, prompt); - wrefresh(hw); - wait_for(rs,' '); - clearok(curscr, TRUE); - wclear(hw); - touchwin(stdscr); - } - newpage = TRUE; - line_cnt = 0; - maxlen = (int) strlen(prompt); + wmove(hw, LINES - 1, 0); + waddstr(hw, prompt); + wrefresh(hw); + wait_for(rs,' '); + clearok(curscr, TRUE); + wclear(hw); + touchwin(stdscr); + } + newpage = TRUE; + line_cnt = 0; + maxlen = (int) strlen(prompt); } if (fmt != NULL && !(line_cnt == 0 && *fmt == '\0')) { diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 6693f0814..e5a5eacf6 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -10,9 +10,9 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include +//#include +//#include +//#include #include "rogue.h" #define NO_WEAPON -1 diff --git a/src/cc/rogue/wizard.c b/src/cc/rogue/wizard.c index e56928d33..ee16b2d9b 100644 --- a/src/cc/rogue/wizard.c +++ b/src/cc/rogue/wizard.c @@ -11,10 +11,10 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "rogue.h" /*