[rogueclone-cvs] rogue/src curses.c, 1.11.2.5, 1.11.2.6 rogue.h, 1.9.2.5, 1.9.2.6
Brought to you by:
mlehotay
From: Michael L. <mle...@us...> - 2009-01-02 20:58:42
|
Update of /cvsroot/rogueclone/rogue/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29053/src Modified Files: Tag: curses curses.c rogue.h Log Message: use standard curses interface for ROGUECURSES Index: rogue.h =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/rogue.h,v retrieving revision 1.9.2.5 retrieving revision 1.9.2.6 diff -C2 -d -r1.9.2.5 -r1.9.2.6 *** rogue.h 7 Dec 2008 01:51:26 -0000 1.9.2.5 --- rogue.h 2 Jan 2009 20:58:36 -0000 1.9.2.6 *************** *** 241,250 **** #ifdef ROGUECURSES ! extern int LINES, COLS; ! typedef unsigned short chtype; /* 8-bit attr + 8-bit char */ typedef chtype attr_t; ! /* Support for color GUI... ! */ #define COLOR_BLACK 0x00 #define COLOR_BLUE 0x01 --- 241,258 ---- #ifdef ROGUECURSES ! typedef unsigned short chtype; /* 8-bit attr + 8-bit char */ typedef chtype attr_t; ! typedef struct _win_st { ! short _cury, _curx; ! short _maxy, _maxx; ! } WINDOW; ! ! typedef unsigned char bool; /* PDCurses Boolean type */ ! ! extern int LINES, COLS; ! extern WINDOW *stdscr; /* the default screen window */ ! extern WINDOW *curscr; /* the current screen image */ ! #define COLOR_BLACK 0x00 #define COLOR_BLUE 0x01 *************** *** 267,303 **** #define PDC_COLOR_SHIFT 11 - #define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) ! /* ! #define GRAY 0x08 ! #define BRIGHT_BLUE 0x09 ! #define BRIGHT_GREEN 0x0A ! #define BRIGHT_CYAN 0x0B ! #define BRIGHT_RED 0x0C ! #define BRIGHT_MAGENTA 0x0D ! #define BRIGHT_YELLOW 0x0E ! #define BRIGHT_WHITE 0x0F ! ! union _colorChar { ! struct { ! byte color; ! char ch; ! } b8; ! unsigned short b16; ! }; ! //typedef union _colorChar color_char; ! ! #define MAKE_COLOR(fg,bg) (byte)(((fg) & 0x0F) | (((bg) & 0x0F) << 4)) ! #define MAKE_COLOR_CHAR(fg,bg,ch) (unsigned short) \ ! (((unsigned short) (ch) << 8) | MAKE_COLOR((fg),(bg))) ! ! #define INVERT_COLOR(col) (byte)( (((col) >> 4) & 0x0F) \ ! | (((col) << 4) & 0xF0) ) ! #define BGCOLOR_OF(col) (byte)(((col) >> 4) & 0x0F) ! #define FGCOLOR_OF(col) (byte)((col) & 0x0F) ! */ ! #else /* link with pdcurses. maybe other curses would work too? */ #ifdef __MSDOS__ --- 275,283 ---- #define PDC_COLOR_SHIFT 11 #define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) ! #define getch() wgetch(stdscr) ! #else /* link with pdcurses or ncurses, other curses will work too */ #ifdef __MSDOS__ *************** *** 307,311 **** #include "curses.h" ! #endif /* ROGUECURSES */ #define COLOR_STAIRS COLOR_WHITE+1 --- 287,291 ---- #include "curses.h" ! #endif */ ROGUECURSES */ #define COLOR_STAIRS COLOR_WHITE+1 *************** *** 353,357 **** short picked_up; /* sleep from wand of sleep */ unsigned short in_use_flags; ! chtype cchar; /* character underneath monster */ int dchar_ix; /* imitator's character index */ struct obj *next_object; /* next monster */ --- 333,337 ---- short picked_up; /* sleep from wand of sleep */ unsigned short in_use_flags; ! chtype cchar; /* character underneath monster */ int dchar_ix; /* imitator's character index */ struct obj *next_object; /* next monster */ *************** *** 623,655 **** /* curses.c */ #ifdef ROGUECURSES ! int has_colors(void); ! int start_color(void); int init_pair(short pair, short f, short b); int mvaddchnstr(int y, int x, const chtype *chstr, int n); ! int getch(void); ! void initscr(void); ! void move(const short row, const short col); ! void addstr(char *str); ! void mvaddstr(const short row, const short col, char *str); ! void mvaddstr_in_color(const short row, const short col, char *str, const byte color); ! void mvaddcstr(const short row, const short col, chtype *cstr); ! void addch(const int ch); ! void mvaddch(const short row, const short col, const int ch); ! void addcch(const chtype cc); ! void mvaddcch(const short row, const short col, const chtype cc); ! void refresh(void); ! void redraw(void); ! chtype mvinch(const short row, const short col); ! chtype mvincch(const short row, const short col); ! void clear(void); ! void clrtoeol(void); ! void standout(void); ! void standend(void); ! void draw_box(const chtype cset[6], const short ulrow, const short ulcol, const short height, const short width); ! void endwin(void); ! void crmode(void); ! void noecho(void); ! void nonl(void); ! #endif /* ROGUECURSES */ /* hit.c */ --- 603,632 ---- /* curses.c */ #ifdef ROGUECURSES ! int addch(const chtype ch); ! int addstr(const char *str); ! int attroff(chtype); ! int attron(chtype); ! int clear(void); ! int clrtoeol(void); ! int crmode(void); ! int def_prog_mode(void); ! int endwin(void); ! bool has_colors(void); int init_pair(short pair, short f, short b); + WINDOW *initscr(void); + int move(int row, int col); + int mvaddch(int row, int col, const chtype ch); int mvaddchnstr(int y, int x, const chtype *chstr, int n); ! int mvaddstr(int row, int col, const char *str); ! chtype mvinch(int row, int col); ! int noecho(void); ! int nonl(void); ! int refresh(void); ! int standend(void); ! int standout(void); ! int start_color(void); ! int wgetch(WINDOW *); ! int wrefresh(WINDOW *); ! #endif /* hit.c */ Index: curses.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/curses.c,v retrieving revision 1.11.2.5 retrieving revision 1.11.2.6 diff -C2 -d -r1.11.2.5 -r1.11.2.6 *** curses.c 7 Dec 2008 01:51:26 -0000 1.11.2.5 --- curses.c 2 Jan 2009 20:58:36 -0000 1.11.2.6 *************** *** 97,118 **** /* ============== CONSTANTS AND TYPEDEFS =============== */ ! struct _win_st { ! short _cury, _curx; ! short _maxy, _maxx; ! }; ! typedef struct _win_st WINDOW; - typedef union _colorChar COLORBUF; - #define BLANKCH MAKE_COLOR_CHAR(WHITE,BLACK,' ') ! /* ================== GLOBAL VARIABLES ================== */ ! int LINES=DROWS, COLS=DCOLS; ! /* static char terminal[DROWS][DCOLS]; */ ! /* static char buffer[DROWS][DCOLS]; */ ! static COLORBUF terminal[DROWS][DCOLS]; ! static COLORBUF buffer[DROWS][DCOLS]; static boolean screen_dirty; --- 97,111 ---- /* ============== CONSTANTS AND TYPEDEFS =============== */ ! /* ================== GLOBAL VARIABLES ================== */ + int LINES=DROWS, COLS=DCOLS; ! /* ================= PRIVATE PROTOTYPES ================= */ ! #define BLANKCH MAKE_COLOR_CHAR(WHITE,BLACK,' ') ! static chtype terminal[DROWS][DCOLS]; ! static chtype buffer[DROWS][DCOLS]; static boolean screen_dirty; *************** *** 130,135 **** #endif - /* ================= PRIVATE PROTOTYPES ================= */ - static void addstr_in_color(char *str, const byte color); /* only used within this file */ static void addcstr(chtype *cstr); /* only used within this file */ --- 123,126 ---- *************** *** 142,145 **** --- 133,181 ---- static void wrefresh(WINDOW *scr); /* only used within this file */ + #if 0 + /* #ifdef OLDROGUECURSES */ + void mvaddstr_in_color(const short row, const short col, char *str, const byte color); + void mvaddcstr(const short row, const short col, chtype *cstr); + void addcch(const chtype cc); + void mvaddcch(const short row, const short col, const chtype cc); + void redraw(void); + chtype mvincch(const short row, const short col); + void draw_box(const chtype cset[6], const short ulrow, const short ulcol, const short height, const short width); + + /* Support for color GUI... + */ + + /* + #define GRAY 0x08 + #define BRIGHT_BLUE 0x09 + #define BRIGHT_GREEN 0x0A + #define BRIGHT_CYAN 0x0B + #define BRIGHT_RED 0x0C + #define BRIGHT_MAGENTA 0x0D + #define BRIGHT_YELLOW 0x0E + #define BRIGHT_WHITE 0x0F + + union _colorChar { + struct { + byte color; + char ch; + } b8; + unsigned short b16; + }; + //typedef union _colorChar color_char; + + #define MAKE_COLOR(fg,bg) (byte)(((fg) & 0x0F) | (((bg) & 0x0F) << 4)) + #define MAKE_COLOR_CHAR(fg,bg,ch) (unsigned short) \ + (((unsigned short) (ch) << 8) | MAKE_COLOR((fg),(bg))) + + #define INVERT_COLOR(col) (byte)( (((col) >> 4) & 0x0F) \ + | (((col) << 4) & 0xF0) ) + #define BGCOLOR_OF(col) (byte)(((col) >> 4) & 0x0F) + #define FGCOLOR_OF(col) (byte)((col) & 0x0F) + */ + + /* #endif OLDROGUECURSES */ + #endif + /* ================== PUBLIC FUNCTIONS ================== */ |