Commit cdfa38dc authored by deuce's avatar deuce
Browse files

Add options flags to indicate which optional features are supported.

Also, initial support for Win32 console palette setting.
parent 6947f99a
......@@ -956,6 +956,8 @@ int ansi_initciolib(long inmode)
char *init="\033[s\033[99B\033[99B\033[99B_\033[99C\033[99C\033[99C_\033[6n\033[u\033[0m_\033[2J\033[H";
time_t start;
cio_api.options = 0;
ansi_textmode(1);
cio_textinfo.screenheight=24;
cio_textinfo.screenwidth=80;
......
......@@ -244,6 +244,10 @@ int bitmap_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height,
{
if(bitmap_initialized)
return(-1);
cio_api.options |= CONIO_OPT_LOADABLE_FONTS | CONIO_OPT_BLINK_ALT_FONT
| CONIO_OPT_BOLD_ALT_FONT | CONIO_OPT_BRIGHT_BACKGROUND
| CONIO_OPT_SET_PIXEL | CONIO_OPT_CUSTOM_CURSOR
| CONIO_OPT_FONT_SELECT | CONIO_OPT_EXTENDED_PALETTE;
pthread_mutex_init(&callbacks.lock, NULL);
pthread_rwlock_init(&vstatlock, NULL);
pthread_rwlock_init(&screen.screenlock, NULL);
......
......@@ -21,7 +21,7 @@ typedef pthread_mutex_t pthread_rwlock_t;
#else
#if 0
#if 1
#define pthread_rwlock_t pthread_mutex_t
#define pthread_rwlock_init(a,b) pthread_mutex_init(a,b)
......
......@@ -342,6 +342,7 @@ int try_conio_init(int mode)
cio_api.getcustomcursor=win32_getcustomcursor;
cio_api.setcustomcursor=win32_setcustomcursor;
cio_api.getvideoflags=win32_getvideoflags;
cio_api.setpalette=win32_setpalette;
return(1);
}
return(0);
......
......@@ -275,6 +275,19 @@ struct ciolib_screen {
typedef struct {
int mode;
int mouse;
uint64_t options;
#define CONIO_OPT_LOADABLE_FONTS 1
#define CONIO_OPT_BLINK_ALT_FONT 2
#define CONIO_OPT_BOLD_ALT_FONT 4
#define CONIO_OPT_BRIGHT_BACKGROUND 8
#define CONIO_OPT_PALETTE_SETTING 16
#define CONIO_OPT_SET_PIXEL 32
#define CONIO_OPT_CUSTOM_CURSOR 64
#define CONIO_OPT_FONT_SELECT 128
#define CONIO_OPT_SET_TITLE 256
#define CONIO_OPT_SET_NAME 512
#define CONIO_OPT_SET_ICON 1024
#define CONIO_OPT_EXTENDED_PALETTE 2048
void (*clreol) (void);
int (*puttext) (int,int,int,int,void *);
int (*pputtext) (int,int,int,int,void *,uint32_t *,uint32_t *);
......
......@@ -669,6 +669,8 @@ int curs_initciolib(long inmode)
char *term;
SCREEN *tst;
cio_api.options = 0;
term=getenv("TERM");
if(term==NULL)
return(0);
......
......@@ -763,6 +763,7 @@ int sdl_init(int mode)
if(sdl_x11available)
sdl.EventState(SDL_SYSWMEVENT, SDL_ENABLE);
#endif
cio_api.options |= CONIO_OPT_PALETTE_SETTING | CONIO_OPT_SET_TITLE | CONIO_OPT_SET_NAME | CONIO_OPT_SET_ICON;
return(0);
}
......@@ -1700,6 +1701,7 @@ int sdl_video_event_thread(void *data)
else {
pthread_rwlock_rdlock(&vstatlock);
new_scaling = (int)(ev.resize.w/(vstat.charwidth*vstat.cols));
fprintf(stderr, "%d/%d - New Scaling %d\n", ev.resize.w, ev.resize.h, new_scaling);
cvstat = vstat;
pthread_rwlock_unlock(&vstatlock);
}
......
......@@ -617,6 +617,7 @@ int win32_initciolib(long inmode)
atexit(RestoreDisplayMode);
}
cio_api.mouse=1;
cio_api.options = CONIO_OPT_BRIGHT_BACKGROUND | CONIO_OPT_CUSTOM_CURSOR | CONIO_OPT_SET_TITLE;
return(1);
}
......@@ -638,6 +639,7 @@ void win32_textmode(int mode)
HANDLE h;
COORD sz;
SMALL_RECT rc;
CONSOLE_SCREEN_BUFFER_INFOEX bi;
for(i=0;i<NUMMODES;i++) {
if(vparams[i].mode==mode)
......@@ -672,6 +674,14 @@ void win32_textmode(int mode)
cio_textinfo.wintop=1;
cio_textinfo.winright=cio_textinfo.screenwidth;
cio_textinfo.winbottom=cio_textinfo.screenheight;
if (GetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &bi)) {
for (i = 0; i < 16; i++) {
bi.ColorTable[] = RGB(dac_default[vparams[modeidx].palette[i].red, dac_default[vparams[modeidx].palette[i].green, dac_default[vparams[modeidx].palette[i].blue);
}
if (SetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &bi)) {
cio_api.options |= CONIO_OPT_PALETTE_SETTING;
}
}
}
int win32_gettext(int left, int top, int right, int bottom, void* buf)
......@@ -882,3 +892,20 @@ int win32_getvideoflags(void)
return(0);
return(CIOLIB_VIDEO_BGBRIGHT);
}
int win32_setpalette(uint32_t entry, uint16_t r, uint16_t g, uint16_t b)
{
CONSOLE_SCREEN_BUFFER_INFOEX bi;
if (entry > 15)
return 0;
if (!GetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &bi))
return 0;
bi.ColorTable[entry] = RGB(r >> 8, g >> 8, b >> 8);
if (!SetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &bi))
return 0;
return 1;
}
......@@ -59,6 +59,7 @@ void win32_resume(void);
void win32_getcustomcursor(int *s, int *e, int *r, int *b, int *v);
void win32_setcustomcursor(int s, int e, int r, int b, int v);
int win32_getvideoflags(void);
int win32_setpalette(uint32_t entry, uint16_t r, uint16_t g, uint16_t b);
#ifdef __cplusplus
}
......
......@@ -440,6 +440,7 @@ int x_init(void)
pthread_mutex_destroy(&copybuf_mutex);
return(-1);
}
cio_api.options |= CONIO_OPT_PALETTE_SETTING | CONIO_OPT_SET_TITLE | CONIO_OPT_SET_NAME | CONIO_OPT_SET_ICON;
return(0);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment