Cleaned up the VIDAPI interface - renderers now export only one symbol.

DirectDraw and Direct3D modules re-integrated as one single driver.
VNC is now enabled by default, it will be runtime-disabled if the DLL is not found.
The BUGGER device moved to devices/ ; will be an external device (DLL) soon.
This commit is contained in:
waltje
2018-05-08 03:09:43 -04:00
parent b93b520a83
commit c5b29c2a09
30 changed files with 5197 additions and 812 deletions

View File

@@ -12,7 +12,7 @@
* it on Windows XP, and possibly also Vista. Use the
* -DANSI_CFG for use on these systems.
*
* Version: @(#)config.c 1.0.22 2018/05/06
* Version: @(#)config.c 1.0.23 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -256,7 +256,7 @@ load_general(const char *cat)
vid_resize = !!config_get_int(cat, "vid_resize", 0);
p = config_get_string(cat, "vid_renderer", "default");
vid_api = plat_vidapi(p);
vid_api = plat_vidapi_from_internal_name(p);
vid_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0);
@@ -311,7 +311,7 @@ save_general(const char *cat)
if (vid_resize == 0)
config_delete_var(cat, "vid_resize");
str = plat_vidapi_name(vid_api);
str = plat_vidapi_internal_name(vid_api);
if (! strcmp(str, "default")) {
config_delete_var(cat, "vid_renderer");
} else {
@@ -1548,7 +1548,7 @@ config_default(void)
#endif
scale = 1;
video_card = VID_CGA;
vid_api = plat_vidapi("default");;
vid_api = plat_vidapi_from_internal_name("default");;
enable_sync = 1;
joystick_type = 0;
hdc_type = 0;

View File

@@ -44,7 +44,7 @@
* configuration register (CTRL_SPCFG bit set) but have to
* remember that stuff first...
*
* Version: @(#)bugger.c 1.0.5 2018/04/28
* Version: @(#)bugger.c 1.0.6 2018/05/06
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -85,11 +85,11 @@
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include "emu.h"
#include "io.h"
#include "device.h"
#include "ui/ui.h"
#include "plat.h"
#include "../emu.h"
#include "../io.h"
#include "../device.h"
#include "../ui/ui.h"
#include "../plat.h"
#include "bugger.h"

View File

@@ -8,7 +8,7 @@
*
* Main emulator module where most things are controlled.
*
* Version: @(#)pc.c 1.0.36 2018/05/06
* Version: @(#)pc.c 1.0.37 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -64,7 +64,6 @@
#include "timer.h"
#include "device.h"
#include "nvr.h"
#include "bugger.h"
#include "devices/ports/game.h"
#include "devices/ports/serial.h"
#include "devices/ports/parallel.h"
@@ -85,6 +84,7 @@
#include "devices/sound/sound.h"
#include "devices/sound/snd_speaker.h"
#include "devices/video/video.h"
#include "devices/misc/bugger.h"
#include "ui/ui.h"
#include "plat.h"
@@ -1132,7 +1132,7 @@ pc_thread(void *param)
/* If needed, handle a screen resize. */
if (doresize && !vid_fullscreen) {
plat_resize(scrnsz_x, scrnsz_y);
ui_resize(scrnsz_x, scrnsz_y);
doresize = 0;
}

View File

@@ -8,7 +8,7 @@
*
* Define the various platform support functions.
*
* Version: @(#)plat.h 1.0.12 2018/05/06
* Version: @(#)plat.h 1.0.13 2018/05/07
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -89,6 +89,21 @@
extern "C" {
#endif
/* Define a "vidapi", or, rather, a Renderer API. */
typedef struct {
const char *name;
int local;
int (*init)(int fs);
void (*close)(void);
void (*reset)(int fs);
void (*resize)(int x, int y);
int (*pause)(void);
void (*screenshot)(const wchar_t *fn);
int (*available)(void);
} vidapi_t;
/* Global variables residing in the platform module. */
GLOBAL int dopause, /* system is paused */
doresize, /* screen resize requested */
@@ -121,14 +136,18 @@ extern uint32_t plat_get_ticks(void);
extern void plat_delay_ms(uint32_t count);
extern void plat_pause(int p);
extern void plat_mouse_capture(int on);
extern int plat_vidapi(const char *name);
extern const char *plat_vidapi_name(int api);
extern int plat_setvid(int api);
extern void plat_vidsize(int x, int y);
extern void plat_setfullscreen(int on);
extern void plat_resize(int x, int y);
extern int plat_fdd_icon(int);
/* Platform VidApi. */
extern int plat_vidapi_count(void);
extern int plat_vidapi_available(int api);
extern int plat_vidapi_from_internal_name(const char *name);
extern const char *plat_vidapi_internal_name(int api);
extern int plat_vidapi_set(int api);
extern void plat_vidapi_resize(int x, int y);
extern int plat_vidapi_pause(void);
extern void plat_vidapi_reset(void);
/* Resource management. */
extern void set_language(int id);

View File

@@ -8,7 +8,7 @@
*
* Define the various UI functions.
*
* Version: @(#)ui.h 1.0.6 2018/04/30
* Version: @(#)ui.h 1.0.7 2018/05/07
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -132,6 +132,7 @@ extern int voodoo_do_log;
#endif
/* Main GUI functions. */
extern void ui_resize(int x, int y);
extern int ui_msgbox(int type, void *arg);
extern void ui_menu_reset_all(void);
extern int ui_menu_command(int idm);

View File

@@ -11,7 +11,7 @@
* This code is called by the UI frontend modules, and, also,
* depends on those same modules for lower-level functions.
*
* Version: @(#)ui_main.c 1.0.8 2018/05/06
* Version: @(#)ui_main.c 1.0.10 2018/05/07
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -256,7 +256,18 @@ ui_menu_reset_all(void)
menu_set_item(IDM_RESIZE, vid_resize);
menu_set_item(IDM_REMEMBER, window_remember);
menu_set_radio_item(IDM_RENDER_1, 4, -1);
/*
* The Renderer menu is more complicated.
*
* We first hide all items, and then we show only
* items that are configured in the code. We then
* disable items that are currently unavailable.
*/
for (i = 0; i < plat_vidapi_count(); i++) {
if (! plat_vidapi_available(i))
menu_enable_item(IDM_RENDER_1 + i, 0);
}
menu_set_radio_item(IDM_RENDER_1, plat_vidapi_count(), vid_api);
menu_set_radio_item(IDM_SCALE_1, 4, scale);
@@ -350,8 +361,11 @@ ui_menu_command(int idm)
case IDM_RENDER_2:
case IDM_RENDER_3:
case IDM_RENDER_4:
plat_setvid(idm - IDM_RENDER_1);
menu_set_radio_item(IDM_RENDER_1, 4, vid_api);
case IDM_RENDER_5:
case IDM_RENDER_6:
case IDM_RENDER_7:
case IDM_RENDER_8:
plat_vidapi_set(idm - IDM_RENDER_1);
config_save();
break;

View File

@@ -8,7 +8,7 @@
*
* Platform-independent resource identifiers.
*
* Version: @(#)ui_resource.h 1.0.5 2018/04/30
* Version: @(#)ui_resource.h 1.0.6 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -71,10 +71,14 @@
#define IDM_RESIZE (IDM_VIEW+1)
#define IDM_REMEMBER (IDM_VIEW+2)
#define IDM_RENDER (IDM_VIEW+10)
# define IDM_RENDER_1 (IDM_RENDER+1) /* DDraw */
# define IDM_RENDER_2 (IDM_RENDER+2) /* D3D */
# define IDM_RENDER_3 (IDM_RENDER+3) /* VNC */
# define IDM_RENDER_4 (IDM_RENDER+4) /* RDP */
# define IDM_RENDER_1 (IDM_RENDER+1)
# define IDM_RENDER_2 (IDM_RENDER+2)
# define IDM_RENDER_3 (IDM_RENDER+3)
# define IDM_RENDER_4 (IDM_RENDER+4)
# define IDM_RENDER_5 (IDM_RENDER+5)
# define IDM_RENDER_6 (IDM_RENDER+6)
# define IDM_RENDER_7 (IDM_RENDER+7)
# define IDM_RENDER_8 (IDM_RENDER+8)
#define IDM_SCALE (IDM_VIEW+20)
# define IDM_SCALE_1 (IDM_SCALE+1)
# define IDM_SCALE_2 (IDM_SCALE+2)
@@ -236,7 +240,7 @@
#define IDS_2092 2092 // "Bus"
#define IDS_2093 2093 // "DMA"
#define IDS_2094 2094 // "KB"
#define IDS_2095 2095 // "Neither DirectDraw nor Dire.."
#define IDS_2095 2095 // "Selected renderer not avai.."
#define IDS_2096 2096 // "Slave"
#define IDS_2097 2097 // "SCSI (ID %s, LUN %s)"
#define IDS_2098 2098 // "Adapter Type"

117
src/vnc.c
View File

@@ -8,7 +8,9 @@
*
* Implement the VNC remote renderer with LibVNCServer.
*
* Version: @(#)vnc.c 1.0.2 2018/05/06
* TODO: Implement screenshots, and maybe Audio?
*
* Version: @(#)vnc.c 1.0.4 2018/05/07
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
* Based on raw code by RichardG, <richardg867@gmail.com>
@@ -61,12 +63,19 @@
#include "vnc.h"
#ifdef _WIN32
# define PATH_VNC_DLL "libvncserver.dll"
#else
# define PATH_VNC_DLL "libvncserver.so"
#endif
#define VNC_MIN_X 320
#define VNC_MAX_X 2048
#define VNC_MIN_Y 200
#define VNC_MAX_Y 2048
static void *vnc_handle = NULL; /* handle to libVNCserver DLL */
static rfbScreenInfoPtr rfb = NULL;
static int clients;
static int updatingSize;
@@ -75,6 +84,37 @@ static int allowedX,
static int ptr_x, ptr_y, ptr_but;
/* Pointers to the real functions. */
static rfbScreenInfoPtr (*f_rfbGetScreen)(int* argc,char** argv,int width,
int height,int bitsPerSample,
int samplesPerPixel,
int bytesPerPixel);
static void (*f_rfbInitServer)(rfbScreenInfoPtr rfbScreen);
static void (*f_rfbRunEventLoop)(rfbScreenInfoPtr screenInfo,
long usec,
rfbBool runInBackground);
static void (*f_rfbScreenCleanup)(rfbScreenInfoPtr screenInfo);
static rfbClientIteratorPtr (*f_rfbGetClientIterator)(rfbScreenInfoPtr rfbScreen);
static rfbClientPtr (*f_rfbClientIteratorNext)(rfbClientIteratorPtr iterator);
static void (*f_rfbMarkRectAsModified)(rfbScreenInfoPtr rfbScreen,
int x1,int y1,int x2,int y2);
static void (*f_rfbDefaultPtrAddEvent)(int buttonMask,int x,
int y,rfbClientPtr cl);
static dllimp_t vnc_imports[] = {
{ "rfbGetScreen", &f_rfbGetScreen },
{ "rfbInitServerWithPthreadsAndZRLE", &f_rfbInitServer },
{ "rfbRunEventLoop", &f_rfbRunEventLoop },
{ "rfbScreenCleanup", &f_rfbScreenCleanup },
{ "rfbGetClientIterator", &f_rfbGetClientIterator },
{ "rfbClientIteratorNext", &f_rfbClientIteratorNext },
{ "rfbMarkRectAsModified", &f_rfbMarkRectAsModified },
{ "rfbDefaultPtrAddEvent", &f_rfbDefaultPtrAddEvent },
{ NULL, NULL }
};
static void
vnc_kbdevent(rfbBool down, rfbKeySym k, rfbClientPtr cl)
{
@@ -108,7 +148,7 @@ vnc_ptrevent(int but, int x, int y, rfbClientPtr cl)
}
}
rfbDefaultPtrAddEvent(but, x, y, cl);
f_rfbDefaultPtrAddEvent(but, x, y, cl);
}
@@ -190,13 +230,13 @@ vnc_blit(int x, int y, int y1, int y2, int w, int h)
video_blit_complete();
if (! updatingSize)
rfbMarkRectAsModified(rfb, 0,0, allowedX,allowedY);
f_rfbMarkRectAsModified(rfb, 0,0, allowedX,allowedY);
}
/* Initialize VNC for operation. */
int
vnc_init(UNUSED(void *arg))
static int
vnc_init(int fs)
{
static char title[128];
rfbPixelFormat rpf = {
@@ -212,6 +252,19 @@ vnc_init(UNUSED(void *arg))
32, 32, 0, 1, 255,255,255, 16, 8, 0, 0, 0
};
/* We do not support fullscreen, folks. */
if (fs) {
pclog("VNC: fullscreen mode is not supported!\n");
return(0);
}
/* Try loading the DLL. */
vnc_handle = dynld_module(PATH_VNC_DLL, vnc_imports);
if (vnc_handle == NULL) {
pclog("VNC: unable to load '%s', VNC not available.\n", PATH_VNC_DLL);
return(0);
}
cgapal_rebuild();
if (rfb == NULL) {
@@ -220,7 +273,7 @@ vnc_init(UNUSED(void *arg))
allowedX = scrnsz_x;
allowedY = scrnsz_y;
rfb = rfbGetScreen(0, NULL, VNC_MAX_X, VNC_MAX_Y, 8, 3, 4);
rfb = f_rfbGetScreen(0, NULL, VNC_MAX_X, VNC_MAX_Y, 8, 3, 4);
rfb->desktopName = title;
rfb->frameBuffer = (char *)malloc(VNC_MAX_X*VNC_MAX_Y*4);
@@ -235,9 +288,9 @@ vnc_init(UNUSED(void *arg))
rfb->width = allowedX;
rfb->height = allowedY;
rfbInitServer(rfb);
f_rfbInitServer(rfb);
rfbRunEventLoop(rfb, -1, TRUE);
f_rfbRunEventLoop(rfb, -1, TRUE);
}
/* Set up our BLIT handlers. */
@@ -251,7 +304,7 @@ vnc_init(UNUSED(void *arg))
}
void
static void
vnc_close(void)
{
video_setblit(NULL);
@@ -259,14 +312,20 @@ vnc_close(void)
if (rfb != NULL) {
free(rfb->frameBuffer);
rfbScreenCleanup(rfb);
f_rfbScreenCleanup(rfb);
rfb = NULL;
}
/* Unload the DLL if possible. */
if (vnc_handle != NULL) {
dynld_close(vnc_handle);
vnc_handle = NULL;
}
}
void
static void
vnc_resize(int x, int y)
{
rfbClientIteratorPtr iterator;
@@ -289,8 +348,8 @@ vnc_resize(int x, int y)
rfb->width = x;
rfb->height = y;
iterator = rfbGetClientIterator(rfb);
while ((cl = rfbClientIteratorNext(iterator)) != NULL) {
iterator = f_rfbGetClientIterator(rfb);
while ((cl = f_rfbClientIteratorNext(iterator)) != NULL) {
LOCK(cl->updateMutex);
cl->newFBSizePending = 1;
UNLOCK(cl->updateMutex);
@@ -300,15 +359,41 @@ vnc_resize(int x, int y)
/* Tell them to pause if we have no clients. */
int
static int
vnc_pause(void)
{
return((clients > 0) ? 0 : 1);
}
void
vnc_take_screenshot(wchar_t *fn)
static void
vnc_screenshot(const wchar_t *fn)
{
pclog("VNC: take_screenshot\n");
}
/* See if this module is available or not. */
static int
vnc_available(void)
{
void *handle;
handle = dynld_module(PATH_VNC_DLL, NULL);
if (handle != NULL) return(1);
return(0);
}
const vidapi_t vnc_vidapi = {
"VNC",
0,
vnc_init,
vnc_close,
NULL,
vnc_resize,
vnc_pause,
vnc_screenshot,
vnc_available
};

View File

@@ -8,7 +8,7 @@
*
* Definitions for the VNC renderer.
*
* Version: @(#)vnc.h 1.0.1 2018/02/14
* Version: @(#)vnc.h 1.0.2 2018/05/07
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -52,14 +52,10 @@
extern "C" {
#endif
extern int vnc_init(void *);
extern void vnc_close(void);
extern void vnc_resize(int x, int y);
extern int vnc_pause(void);
extern const vidapi_t vnc_vidapi;
extern void vnc_kbinput(int, int);
extern void vnc_take_screenshot(wchar_t *fn);
extern void vnc_kbinput(int, int);
#ifdef __cplusplus
}

View File

@@ -8,7 +8,7 @@
*
* Application resource script for Windows.
*
* Version: @(#)VARCem.rc 1.0.25 2018/04/30
* Version: @(#)VARCem.rc 1.0.26 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -78,13 +78,26 @@ BEGIN
MENUITEM SEPARATOR
POPUP "Re&nderer"
BEGIN
MENUITEM "&DirectDraw", IDM_RENDER_1
MENUITEM "Direct&3D 9", IDM_RENDER_2
MENUITEM "DirectDraw", IDM_RENDER_1
MENUITEM "Direct3D", IDM_RENDER_2
#define IDM_NEXT IDM_RENDER_2 + 1
#ifdef USE_SDL
# define IDM_RENDER_SDL IDM_NEXT
MENUITEM "SDL", IDM_RENDER_SDL
# undef IDM_NEXT
# define IDM_NEXT IDM_RENDER_SDL + 1
#endif
#ifdef USE_VNC
MENUITEM "&VNC", IDM_RENDER_3
# define IDM_RENDER_VNC IDM_NEXT
MENUITEM "VNC Remote", IDM_RENDER_VNC
# undef IDM_NEXT
# define IDM_NEXT IDM_RENDER_VNC + 1
#endif
#ifdef USE_RDP
MENUITEM "&RDP", IDM_RENDER_4
# define IDM_RENDER_RDP IDM_NEXT
MENUITEM "RDP Remote", IDM_RENDER_RDP
# undef IDM_NEXT
# define IDM_NEXT IDM_RENDER_RDP + 1
#endif
END
MENUITEM SEPARATOR
@@ -962,7 +975,7 @@ BEGIN
IDS_2092 "Bus"
IDS_2093 "DMA"
IDS_2094 "KB"
IDS_2095 "Neither DirectDraw nor Direct3D available !"
IDS_2095 "Selected renderer '%S' not available. Reset to default?"
IDS_2096 "Slave"
IDS_2097 "SCSI (ID %s, LUN %s)"
IDS_2098 "Adapter Type"

View File

@@ -8,7 +8,7 @@
#
# Makefile for Windows systems using the MinGW32 environment.
#
# Version: @(#)Makefile.mingw 1.0.38 2018/05/06
# Version: @(#)Makefile.mingw 1.0.40 2018/05/07
#
# Author: Fred N. van Kempen, <decwiz@yahoo.com>
#
@@ -90,7 +90,7 @@ ifndef USB
USB := n
endif
ifndef VNC
VNC := n
VNC := y
endif
ifndef RDP
RDP := n
@@ -206,7 +206,7 @@ VPATH := $(EXPATH) . cpu \
devices/cdrom devices/disk devices/floppy \
devices/floppy/lzf devices/input devices/input/game \
devices/network devices/network/slirp devices/ports \
devices/sio devices/system devices/scsi \
devices/sio devices/system devices/scsi devices\misc \
devices/sound \
devices/sound/munt devices/sound/munt/c_interface \
devices/sound/munt/sha1 devices/sound/munt/srchelper \
@@ -396,11 +396,10 @@ OPTS += -DUSE_VNC
RFLAGS += -DUSE_VNC
ifneq ($(VNC_PATH), )
OPTS += -I$(VNC_PATH)\INCLUDE
VNCLIB := -L$(VNC_PATH)\LIB
VNCLIB := -L$(VNC_PATH)\LIB -lvncserver
endif
VNCLIB += -lvncserver
VNCOBJ := vnc.o vnc_keymap.o
LIBS += $(VNCLIB) -lws2_32
//LIBS += $(VNCLIB) -lws2_32
endif
ifeq ($(RDP), y)

View File

@@ -0,0 +1,261 @@
unsigned char default8x16FontData[4096+1]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x6c,0xfe,0xfe,0xfe,0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x3c,0x3c,0xe7,0xe7,0xe7,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x7e,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x1e,0x0e,0x1a,0x32,0x78,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x66,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x3f,0x33,0x3f,0x30,0x30,0x30,0x30,0x70,0xf0,0xe0,0x00,0x00,0x00,0x00,
0x00,0x00,0x7f,0x63,0x7f,0x63,0x63,0x63,0x63,0x67,0xe7,0xe6,0xc0,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x18,0xdb,0x3c,0xe7,0x3c,0xdb,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfe,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,
0x00,0x02,0x06,0x0e,0x1e,0x3e,0xfe,0x3e,0x1e,0x0e,0x06,0x02,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x7f,0xdb,0xdb,0xdb,0x7b,0x1b,0x1b,0x1b,0x1b,0x1b,0x00,0x00,0x00,0x00,
0x00,0x7c,0xc6,0x60,0x38,0x6c,0xc6,0xc6,0x6c,0x38,0x0c,0xc6,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0xfe,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0xfe,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x30,0x60,0xfe,0x60,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x38,0x7c,0x7c,0xfe,0xfe,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0xfe,0x7c,0x7c,0x38,0x38,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x3c,0x3c,0x3c,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x6c,0x6c,0xfe,0x6c,0x6c,0x6c,0xfe,0x6c,0x6c,0x00,0x00,0x00,0x00,
0x18,0x18,0x7c,0xc6,0xc2,0xc0,0x7c,0x06,0x06,0x86,0xc6,0x7c,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0xc2,0xc6,0x0c,0x18,0x30,0x60,0xc6,0x86,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6c,0x6c,0x38,0x76,0xdc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0c,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0x0c,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x18,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x18,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x06,0x0c,0x18,0x30,0x60,0xc0,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0xce,0xde,0xf6,0xe6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0x06,0x0c,0x18,0x30,0x60,0xc0,0xc6,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0x06,0x06,0x3c,0x06,0x06,0x06,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x0c,0x1c,0x3c,0x6c,0xcc,0xfe,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00,
0x00,0x00,0xfe,0xc0,0xc0,0xc0,0xfc,0x06,0x06,0x06,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x60,0xc0,0xc0,0xfc,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0xfe,0xc6,0x06,0x06,0x0c,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7e,0x06,0x06,0x06,0x0c,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x06,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0x0c,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,
0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x66,0x66,0x66,0x66,0xfc,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc0,0xc2,0x66,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0xf8,0x6c,0x66,0x66,0x66,0x66,0x66,0x66,0x6c,0xf8,0x00,0x00,0x00,0x00,
0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xde,0xc6,0xc6,0x66,0x3a,0x00,0x00,0x00,0x00,
0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0xe6,0x66,0x66,0x6c,0x78,0x78,0x6c,0x66,0x66,0xe6,0x00,0x00,0x00,0x00,
0x00,0x00,0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0xc3,0xe7,0xff,0xff,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3,0x00,0x00,0x00,0x00,
0x00,0x00,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x60,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xd6,0xde,0x7c,0x0c,0x0e,0x00,0x00,
0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x6c,0x66,0x66,0x66,0xe6,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0xc6,0xc6,0x60,0x38,0x0c,0x06,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xdb,0x99,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xdb,0xdb,0xff,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0xc3,0xc3,0x66,0x3c,0x18,0x18,0x3c,0x66,0xc3,0xc3,0x00,0x00,0x00,0x00,
0x00,0x00,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xc3,0x86,0x0c,0x18,0x30,0x60,0xc1,0xc3,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x06,0x02,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00,0x00,0x00,0x00,
0x10,0x38,0x6c,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,
0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0xe0,0x60,0x60,0x78,0x6c,0x66,0x66,0x66,0x66,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xc0,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x1c,0x0c,0x0c,0x3c,0x6c,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0xcc,0x78,0x00,
0x00,0x00,0xe0,0x60,0x60,0x6c,0x76,0x66,0x66,0x66,0x66,0xe6,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x06,0x00,0x0e,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3c,0x00,
0x00,0x00,0xe0,0x60,0x60,0x66,0x6c,0x78,0x78,0x6c,0x66,0xe6,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xe6,0xff,0xdb,0xdb,0xdb,0xdb,0xdb,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x7c,0x60,0x60,0xf0,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x0c,0x1e,0x00,
0x00,0x00,0x00,0x00,0x00,0xdc,0x76,0x66,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0x60,0x38,0x0c,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x30,0x30,0xfc,0x30,0x30,0x30,0x30,0x36,0x1c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc3,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc3,0xc3,0xc3,0xdb,0xdb,0xff,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc3,0x66,0x3c,0x18,0x3c,0x66,0xc3,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7e,0x06,0x0c,0xf8,0x00,
0x00,0x00,0x00,0x00,0x00,0xfe,0xcc,0x18,0x30,0x60,0xc6,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x0e,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0e,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0x18,0x18,0x18,0x0e,0x18,0x18,0x18,0x18,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x76,0xdc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xc6,0xfe,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc2,0x66,0x3c,0x0c,0x06,0x7c,0x00,0x00,
0x00,0x00,0xcc,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x0c,0x18,0x30,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x10,0x38,0x6c,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0xcc,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x60,0x30,0x18,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x38,0x6c,0x38,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3c,0x66,0x60,0x60,0x66,0x3c,0x0c,0x06,0x3c,0x00,0x00,0x00,
0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0xc6,0x00,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x66,0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x18,0x3c,0x66,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x60,0x30,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0xc6,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,
0x38,0x6c,0x38,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,
0x18,0x30,0x60,0x00,0xfe,0x66,0x60,0x7c,0x60,0x60,0x66,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x6e,0x3b,0x1b,0x7e,0xd8,0xdc,0x77,0x00,0x00,0x00,0x00,
0x00,0x00,0x3e,0x6c,0xcc,0xcc,0xfe,0xcc,0xcc,0xcc,0xcc,0xce,0x00,0x00,0x00,0x00,
0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0xc6,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x30,0x78,0xcc,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x60,0x30,0x18,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0xc6,0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7e,0x06,0x0c,0x78,0x00,
0x00,0xc6,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0xc6,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x18,0x18,0x7e,0xc3,0xc0,0xc0,0xc0,0xc3,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0x60,0xe6,0xfc,0x00,0x00,0x00,0x00,
0x00,0x00,0xc3,0x66,0x3c,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0xfc,0x66,0x66,0x7c,0x62,0x66,0x6f,0x66,0x66,0x66,0xf3,0x00,0x00,0x00,0x00,
0x00,0x0e,0x1b,0x18,0x18,0x18,0x7e,0x18,0x18,0x18,0x18,0x18,0xd8,0x70,0x00,0x00,
0x00,0x18,0x30,0x60,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x0c,0x18,0x30,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00,
0x00,0x18,0x30,0x60,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x18,0x30,0x60,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x76,0xdc,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x76,0xdc,0x00,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,
0x00,0x3c,0x6c,0x6c,0x3e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x6c,0x6c,0x38,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,0xc0,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0xc0,0xc0,0xc2,0xc6,0xcc,0x18,0x30,0x60,0xce,0x9b,0x06,0x0c,0x1f,0x00,0x00,
0x00,0xc0,0xc0,0xc2,0xc6,0xcc,0x18,0x30,0x66,0xce,0x96,0x3e,0x06,0x06,0x00,0x00,
0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x18,0x3c,0x3c,0x3c,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x36,0x6c,0xd8,0x6c,0x36,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xd8,0x6c,0x36,0x6c,0xd8,0x00,0x00,0x00,0x00,0x00,0x00,
0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,
0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,
0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xf6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xf6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x00,0x00,0x00,0x00,0x00,0xfe,0x06,0xf6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xf7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xf7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x18,0x18,0x18,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x18,0x18,0x18,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xdc,0xd8,0xd8,0xd8,0xdc,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x78,0xcc,0xcc,0xcc,0xd8,0xcc,0xc6,0xc6,0xc6,0xcc,0x00,0x00,0x00,0x00,
0x00,0x00,0xfe,0xc6,0xc6,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0xc6,0x60,0x30,0x18,0x30,0x60,0xc6,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7e,0xd8,0xd8,0xd8,0xd8,0xd8,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x7c,0x60,0x60,0xc0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x76,0xdc,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7e,0x18,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0x6c,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6c,0xc6,0xc6,0xc6,0x6c,0x6c,0x6c,0x6c,0xee,0x00,0x00,0x00,0x00,
0x00,0x00,0x1e,0x30,0x18,0x0c,0x3e,0x66,0x66,0x66,0x66,0x3c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7e,0xdb,0xdb,0xdb,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0x06,0x7e,0xdb,0xdb,0xf3,0x7e,0x60,0xc0,0x00,0x00,0x00,0x00,
0x00,0x00,0x1c,0x30,0x60,0x60,0x7c,0x60,0x60,0x60,0x30,0x1c,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x00,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x00,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x0e,0x1b,0x1b,0x1b,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xd8,0xd8,0xd8,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x7e,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xdc,0x00,0x76,0xdc,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x6c,0x6c,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0f,0x0c,0x0c,0x0c,0x0c,0x0c,0xec,0x6c,0x6c,0x3c,0x1c,0x00,0x00,0x00,0x00,
0x00,0xd8,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x70,0xd8,0x30,0x60,0xc8,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
int default8x16FontMetaData[256*5+1]={
0,8,16,0,0,16,8,16,0,0,32,8,16,0,0,48,8,16,0,0,64,8,16,0,0,80,8,16,0,0,96,8,16,0,0,112,8,16,0,0,128,8,16,0,0,144,8,16,0,0,160,8,16,0,0,176,8,16,0,0,192,8,16,0,0,208,8,16,0,0,224,8,16,0,0,240,8,16,0,0,256,8,16,0,0,272,8,16,0,0,288,8,16,0,0,304,8,16,0,0,320,8,16,0,0,336,8,16,0,0,352,8,16,0,0,368,8,16,0,0,384,8,16,0,0,400,8,16,0,0,416,8,16,0,0,432,8,16,0,0,448,8,16,0,0,464,8,16,0,0,480,8,16,0,0,496,8,16,0,0,512,8,16,0,0,528,8,16,0,0,544,8,16,0,0,560,8,16,0,0,576,8,16,0,0,592,8,16,0,0,608,8,16,0,0,624,8,16,0,0,640,8,16,0,0,656,8,16,0,0,672,8,16,0,0,688,8,16,0,0,704,8,16,0,0,720,8,16,0,0,736,8,16,0,0,752,8,16,0,0,768,8,16,0,0,784,8,16,0,0,800,8,16,0,0,816,8,16,0,0,832,8,16,0,0,848,8,16,0,0,864,8,16,0,0,880,8,16,0,0,896,8,16,0,0,912,8,16,0,0,928,8,16,0,0,944,8,16,0,0,960,8,16,0,0,976,8,16,0,0,992,8,16,0,0,1008,8,16,0,0,1024,8,16,0,0,1040,8,16,0,0,1056,8,16,0,0,1072,8,16,0,0,1088,8,16,0,0,1104,8,16,0,0,1120,8,16,0,0,1136,8,16,0,0,1152,8,16,0,0,1168,8,16,0,0,1184,8,16,0,0,1200,8,16,0,0,1216,8,16,0,0,1232,8,16,0,0,1248,8,16,0,0,1264,8,16,0,0,1280,8,16,0,0,1296,8,16,0,0,1312,8,16,0,0,1328,8,16,0,0,1344,8,16,0,0,1360,8,16,0,0,1376,8,16,0,0,1392,8,16,0,0,1408,8,16,0,0,1424,8,16,0,0,1440,8,16,0,0,1456,8,16,0,0,1472,8,16,0,0,1488,8,16,0,0,1504,8,16,0,0,1520,8,16,0,0,1536,8,16,0,0,1552,8,16,0,0,1568,8,16,0,0,1584,8,16,0,0,1600,8,16,0,0,1616,8,16,0,0,1632,8,16,0,0,1648,8,16,0,0,1664,8,16,0,0,1680,8,16,0,0,1696,8,16,0,0,1712,8,16,0,0,1728,8,16,0,0,1744,8,16,0,0,1760,8,16,0,0,1776,8,16,0,0,1792,8,16,0,0,1808,8,16,0,0,1824,8,16,0,0,1840,8,16,0,0,1856,8,16,0,0,1872,8,16,0,0,1888,8,16,0,0,1904,8,16,0,0,1920,8,16,0,0,1936,8,16,0,0,1952,8,16,0,0,1968,8,16,0,0,1984,8,16,0,0,2000,8,16,0,0,2016,8,16,0,0,2032,8,16,0,0,2048,8,16,0,0,2064,8,16,0,0,2080,8,16,0,0,2096,8,16,0,0,2112,8,16,0,0,2128,8,16,0,0,2144,8,16,0,0,2160,8,16,0,0,2176,8,16,0,0,2192,8,16,0,0,2208,8,16,0,0,2224,8,16,0,0,2240,8,16,0,0,2256,8,16,0,0,2272,8,16,0,0,2288,8,16,0,0,2304,8,16,0,0,2320,8,16,0,0,2336,8,16,0,0,2352,8,16,0,0,2368,8,16,0,0,2384,8,16,0,0,2400,8,16,0,0,2416,8,16,0,0,2432,8,16,0,0,2448,8,16,0,0,2464,8,16,0,0,2480,8,16,0,0,2496,8,16,0,0,2512,8,16,0,0,2528,8,16,0,0,2544,8,16,0,0,2560,8,16,0,0,2576,8,16,0,0,2592,8,16,0,0,2608,8,16,0,0,2624,8,16,0,0,2640,8,16,0,0,2656,8,16,0,0,2672,8,16,0,0,2688,8,16,0,0,2704,8,16,0,0,2720,8,16,0,0,2736,8,16,0,0,2752,8,16,0,0,2768,8,16,0,0,2784,8,16,0,0,2800,8,16,0,0,2816,8,16,0,0,2832,8,16,0,0,2848,8,16,0,0,2864,8,16,0,0,2880,8,16,0,0,2896,8,16,0,0,2912,8,16,0,0,2928,8,16,0,0,2944,8,16,0,0,2960,8,16,0,0,2976,8,16,0,0,2992,8,16,0,0,3008,8,16,0,0,3024,8,16,0,0,3040,8,16,0,0,3056,8,16,0,0,3072,8,16,0,0,3088,8,16,0,0,3104,8,16,0,0,3120,8,16,0,0,3136,8,16,0,0,3152,8,16,0,0,3168,8,16,0,0,3184,8,16,0,0,3200,8,16,0,0,3216,8,16,0,0,3232,8,16,0,0,3248,8,16,0,0,3264,8,16,0,0,3280,8,16,0,0,3296,8,16,0,0,3312,8,16,0,0,3328,8,16,0,0,3344,8,16,0,0,3360,8,16,0,0,3376,8,16,0,0,3392,8,16,0,0,3408,8,16,0,0,3424,8,16,0,0,3440,8,16,0,0,3456,8,16,0,0,3472,8,16,0,0,3488,8,16,0,0,3504,8,16,0,0,3520,8,16,0,0,3536,8,16,0,0,3552,8,16,0,0,3568,8,16,0,0,3584,8,16,0,0,3600,8,16,0,0,3616,8,16,0,0,3632,8,16,0,0,3648,8,16,0,0,3664,8,16,0,0,3680,8,16,0,0,3696,8,16,0,0,3712,8,16,0,0,3728,8,16,0,0,3744,8,16,0,0,3760,8,16,0,0,3776,8,16,0,0,3792,8,16,0,0,3808,8,16,0,0,3824,8,16,0,0,3840,8,16,0,0,3856,8,16,0,0,3872,8,16,0,0,3888,8,16,0,0,3904,8,16,0,0,3920,8,16,0,0,3936,8,16,0,0,3952,8,16,0,0,3968,8,16,0,0,3984,8,16,0,0,4000,8,16,0,0,4016,8,16,0,0,4032,8,16,0,0,4048,8,16,0,0,4064,8,16,0,0,4080,8,16,0,0,};
rfbFontData default8x16Font = { default8x16FontData, default8x16FontMetaData };

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,796 @@
#ifndef RFB_H
#define RFB_H
/*
* rfb.h - header file for RFB DDX implementation.
*/
/*
* Copyright (C) 2002 RealVNC Ltd.
* OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
* Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.
* All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#if(defined __cplusplus)
extern "C"
{
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rfb/rfbproto.h>
#ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef __MINGW32__
#include <winsock2.h>
#endif
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
#include <pthread.h>
#if 0 /* debugging */
#define LOCK(mutex) (rfbLog("%s:%d LOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_lock(&(mutex)))
#define UNLOCK(mutex) (rfbLog("%s:%d UNLOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_unlock(&(mutex)))
#define MUTEX(mutex) pthread_mutex_t (mutex)
#define INIT_MUTEX(mutex) (rfbLog("%s:%d INIT_MUTEX(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_init(&(mutex),NULL))
#define TINI_MUTEX(mutex) (rfbLog("%s:%d TINI_MUTEX(%s)\n",__FILE__,__LINE__,#mutex), pthread_mutex_destroy(&(mutex)))
#define TSIGNAL(cond) (rfbLog("%s:%d TSIGNAL(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_signal(&(cond)))
#define WAIT(cond,mutex) (rfbLog("%s:%d WAIT(%s,%s)\n",__FILE__,__LINE__,#cond,#mutex), pthread_cond_wait(&(cond),&(mutex)))
#define COND(cond) pthread_cond_t (cond)
#define INIT_COND(cond) (rfbLog("%s:%d INIT_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_init(&(cond),NULL))
#define TINI_COND(cond) (rfbLog("%s:%d TINI_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_destroy(&(cond)))
#define IF_PTHREADS(x) x
#else
#define LOCK(mutex) pthread_mutex_lock(&(mutex));
#define UNLOCK(mutex) pthread_mutex_unlock(&(mutex));
#define MUTEX(mutex) pthread_mutex_t (mutex)
#define INIT_MUTEX(mutex) pthread_mutex_init(&(mutex),NULL)
#define TINI_MUTEX(mutex) pthread_mutex_destroy(&(mutex))
#define TSIGNAL(cond) pthread_cond_signal(&(cond))
#define WAIT(cond,mutex) pthread_cond_wait(&(cond),&(mutex))
#define COND(cond) pthread_cond_t (cond)
#define INIT_COND(cond) pthread_cond_init(&(cond),NULL)
#define TINI_COND(cond) pthread_cond_destroy(&(cond))
#define IF_PTHREADS(x) x
#endif
#else
#define LOCK(mutex)
#define UNLOCK(mutex)
#define MUTEX(mutex)
#define INIT_MUTEX(mutex)
#define TINI_MUTEX(mutex)
#define TSIGNAL(cond)
#define WAIT(cond,mutex) this_is_unsupported
#define COND(cond)
#define INIT_COND(cond)
#define TINI_COND(cond)
#define IF_PTHREADS(x)
#endif
/* end of stuff for autoconf */
/* if you use pthreads, but don't define LIBVNCSERVER_HAVE_LIBPTHREAD, the structs
get all mixed up. So this gives a linker error reminding you to compile
the library and your application (at least the parts including rfb.h)
with the same support for pthreads. */
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
#ifdef LIBVNCSERVER_HAVE_LIBZ
#define rfbInitServer rfbInitServerWithPthreadsAndZRLE
#else
#define rfbInitServer rfbInitServerWithPthreadsButWithoutZRLE
#endif
#else
#ifdef LIBVNCSERVER_HAVE_LIBZ
#define rfbInitServer rfbInitServerWithoutPthreadsButWithZRLE
#else
#define rfbInitServer rfbInitServerWithoutPthreadsAndZRLE
#endif
#endif
struct _rfbClientRec;
struct _rfbScreenInfo;
struct rfbCursor;
enum rfbNewClientAction {
RFB_CLIENT_ACCEPT,
RFB_CLIENT_ON_HOLD,
RFB_CLIENT_REFUSE
};
typedef void (*rfbKbdAddEventProcPtr) (rfbBool down, rfbKeySym keySym, struct _rfbClientRec* cl);
typedef void (*rfbKbdReleaseAllKeysProcPtr) (struct _rfbClientRec* cl);
typedef void (*rfbPtrAddEventProcPtr) (int buttonMask, int x, int y, struct _rfbClientRec* cl);
typedef void (*rfbSetXCutTextProcPtr) (char* str,int len, struct _rfbClientRec* cl);
typedef struct rfbCursor* (*rfbGetCursorProcPtr) (struct _rfbClientRec* pScreen);
typedef rfbBool (*rfbSetTranslateFunctionProcPtr)(struct _rfbClientRec* cl);
typedef rfbBool (*rfbPasswordCheckProcPtr)(struct _rfbClientRec* cl,const char* encryptedPassWord,int len);
typedef enum rfbNewClientAction (*rfbNewClientHookPtr)(struct _rfbClientRec* cl);
typedef void (*rfbDisplayHookPtr)(struct _rfbClientRec* cl);
typedef struct {
uint32_t count;
rfbBool is16; /* is the data format short? */
union {
uint8_t* bytes;
uint16_t* shorts;
} data; /* there have to be count*3 entries */
} rfbColourMap;
/*
* Per-screen (framebuffer) structure. There can be as many as you wish,
* each serving different clients. However, you have to call
* rfbProcessEvents for each of these.
*/
typedef struct _rfbScreenInfo
{
int width;
int paddedWidthInBytes;
int height;
int depth;
int bitsPerPixel;
int sizeInBytes;
rfbPixel blackPixel;
rfbPixel whitePixel;
/* some screen specific data can be put into a struct where screenData
* points to. You need this if you have more than one screen at the
* same time while using the same functions.
*/
void* screenData;
/* The following two members are used to minimise the amount of unnecessary
drawing caused by cursor movement. Whenever any drawing affects the
part of the screen where the cursor is, the cursor is removed first and
then the drawing is done (this is what the sprite routines test for).
Afterwards, however, we do not replace the cursor, even when the cursor
is logically being moved across the screen. We only draw the cursor
again just as we are about to send the client a framebuffer update.
We need to be careful when removing and drawing the cursor because of
their relationship with the normal drawing routines. The drawing
routines can invoke the cursor routines, but also the cursor routines
themselves end up invoking drawing routines.
Removing the cursor (rfbUndrawCursor) is eventually achieved by
doing a CopyArea from a pixmap to the screen, where the pixmap contains
the saved contents of the screen under the cursor. Before doing this,
however, we set cursorIsDrawn to FALSE. Then, when CopyArea is called,
it sees that cursorIsDrawn is FALSE and so doesn't feel the need to
(recursively!) remove the cursor before doing it.
Putting up the cursor (rfbDrawCursor) involves a call to
PushPixels. While this is happening, cursorIsDrawn must be FALSE so
that PushPixels doesn't think it has to remove the cursor first.
Obviously cursorIsDrawn is set to TRUE afterwards.
Another problem we face is that drawing routines sometimes cause a
framebuffer update to be sent to the RFB client. When the RFB client is
already waiting for a framebuffer update and some drawing to the
framebuffer then happens, the drawing routine sees that the client is
ready, so it calls rfbSendFramebufferUpdate. If the cursor is not drawn
at this stage, it must be put up, and so rfbSpriteRestoreCursor is
called. However, if the original drawing routine was actually called
from within rfbSpriteRestoreCursor or rfbSpriteRemoveCursor we don't
want this to happen. So both the cursor routines set
dontSendFramebufferUpdate to TRUE, and all the drawing routines check
this before calling rfbSendFramebufferUpdate. */
rfbBool cursorIsDrawn; /* TRUE if the cursor is currently drawn */
rfbBool dontSendFramebufferUpdate; /* TRUE while removing or drawing the
cursor */
/* additions by libvncserver */
rfbPixelFormat serverFormat;
rfbColourMap colourMap; /* set this if rfbServerFormat.trueColour==FALSE */
const char* desktopName;
char thisHost[255];
rfbBool autoPort;
int port;
SOCKET listenSock;
int maxSock;
int maxFd;
#ifdef __MINGW32__
struct fd_set allFds;
#else
fd_set allFds;
#endif
rfbBool socketInitDone;
SOCKET inetdSock;
rfbBool inetdInitDone;
int udpPort;
SOCKET udpSock;
struct _rfbClientRec* udpClient;
rfbBool udpSockConnected;
struct sockaddr_in udpRemoteAddr;
int maxClientWait;
/* http stuff */
rfbBool httpInitDone;
rfbBool httpEnableProxyConnect;
int httpPort;
char* httpDir;
SOCKET httpListenSock;
SOCKET httpSock;
rfbPasswordCheckProcPtr passwordCheck;
void* authPasswdData;
/* If rfbAuthPasswdData is given a list, this is the first
view only password. */
int authPasswdFirstViewOnly;
/* send only this many rectangles in one update */
int maxRectsPerUpdate;
/* this is the amount of milliseconds to wait at least before sending
* an update. */
int deferUpdateTime;
#ifdef TODELETE
char* screen;
#endif
rfbBool alwaysShared;
rfbBool neverShared;
rfbBool dontDisconnect;
struct _rfbClientRec* clientHead;
/* cursor */
int cursorX, cursorY,oldCursorX,oldCursorY,underCursorBufferLen;
char* underCursorBuffer;
rfbBool dontConvertRichCursorToXCursor;
struct rfbCursor* cursor;
/* the frameBufferhas to be supplied by the serving process.
* The buffer will not be freed by
*/
char* frameBuffer;
rfbKbdAddEventProcPtr kbdAddEvent;
rfbKbdReleaseAllKeysProcPtr kbdReleaseAllKeys;
rfbPtrAddEventProcPtr ptrAddEvent;
rfbSetXCutTextProcPtr setXCutText;
rfbGetCursorProcPtr getCursorPtr;
rfbSetTranslateFunctionProcPtr setTranslateFunction;
/* newClientHook is called just after a new client is created */
rfbNewClientHookPtr newClientHook;
/* displayHook is called just before a frame buffer update */
rfbDisplayHookPtr displayHook;
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
MUTEX(cursorMutex);
rfbBool backgroundLoop;
#endif
/* if TRUE, an ignoring signal handler is installed for SIGPIPE */
rfbBool ignoreSIGPIPE;
/* if not zero, only a slice of this height is processed every time
* an update should be sent. This should make working on a slow
* link more interactive. */
int progressiveSliceHeight;
} rfbScreenInfo, *rfbScreenInfoPtr;
/*
* rfbTranslateFnType is the type of translation functions.
*/
typedef void (*rfbTranslateFnType)(char *table, rfbPixelFormat *in,
rfbPixelFormat *out,
char *iptr, char *optr,
int bytesBetweenInputLines,
int width, int height);
/* region stuff */
struct sraRegion;
typedef struct sraRegion* sraRegionPtr;
/*
* Per-client structure.
*/
typedef void (*ClientGoneHookPtr)(struct _rfbClientRec* cl);
typedef struct _rfbClientRec {
/* back pointer to the screen */
rfbScreenInfoPtr screen;
/* private data. You should put any application client specific data
* into a struct and let clientData point to it. Don't forget to
* free the struct via clientGoneHook!
*
* This is useful if the IO functions have to behave client specific.
*/
void* clientData;
ClientGoneHookPtr clientGoneHook;
SOCKET sock;
char *host;
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
pthread_t client_thread;
#endif
/* Possible client states: */
enum {
RFB_PROTOCOL_VERSION, /* establishing protocol version */
RFB_AUTHENTICATION, /* authenticating */
RFB_INITIALISATION, /* sending initialisation messages */
RFB_NORMAL /* normal protocol messages */
} state;
rfbBool reverseConnection;
rfbBool onHold;
rfbBool readyForSetColourMapEntries;
rfbBool useCopyRect;
int preferredEncoding;
int correMaxWidth, correMaxHeight;
rfbBool viewOnly;
/* The following member is only used during VNC authentication */
uint8_t authChallenge[CHALLENGESIZE];
/* The following members represent the update needed to get the client's
framebuffer from its present state to the current state of our
framebuffer.
If the client does not accept CopyRect encoding then the update is
simply represented as the region of the screen which has been modified
(modifiedRegion).
If the client does accept CopyRect encoding, then the update consists of
two parts. First we have a single copy from one region of the screen to
another (the destination of the copy is copyRegion), and second we have
the region of the screen which has been modified in some other way
(modifiedRegion).
Although the copy is of a single region, this region may have many
rectangles. When sending an update, the copyRegion is always sent
before the modifiedRegion. This is because the modifiedRegion may
overlap parts of the screen which are in the source of the copy.
In fact during normal processing, the modifiedRegion may even overlap
the destination copyRegion. Just before an update is sent we remove
from the copyRegion anything in the modifiedRegion. */
sraRegionPtr copyRegion; /* the destination region of the copy */
int copyDX, copyDY; /* the translation by which the copy happens */
sraRegionPtr modifiedRegion;
/* As part of the FramebufferUpdateRequest, a client can express interest
in a subrectangle of the whole framebuffer. This is stored in the
requestedRegion member. In the normal case this is the whole
framebuffer if the client is ready, empty if it's not. */
sraRegionPtr requestedRegion;
/* The following member represents the state of the "deferred update" timer
- when the framebuffer is modified and the client is ready, in most
cases it is more efficient to defer sending the update by a few
milliseconds so that several changes to the framebuffer can be combined
into a single update. */
struct timeval startDeferring;
/* translateFn points to the translation function which is used to copy
and translate a rectangle from the framebuffer to an output buffer. */
rfbTranslateFnType translateFn;
char *translateLookupTable;
rfbPixelFormat format;
/*
* UPDATE_BUF_SIZE must be big enough to send at least one whole line of the
* framebuffer. So for a max screen width of say 2K with 32-bit pixels this
* means 8K minimum.
*/
#define UPDATE_BUF_SIZE 30000
char updateBuf[UPDATE_BUF_SIZE];
int ublen;
/* statistics */
int bytesSent[MAX_ENCODINGS];
int rectanglesSent[MAX_ENCODINGS];
int lastRectMarkersSent;
int lastRectBytesSent;
int cursorShapeBytesSent;
int cursorShapeUpdatesSent;
int cursorPosBytesSent;
int cursorPosUpdatesSent;
int framebufferUpdateMessagesSent;
int rawBytesEquivalent;
int keyEventsRcvd;
int pointerEventsRcvd;
#ifdef LIBVNCSERVER_HAVE_LIBZ
/* zlib encoding -- necessary compression state info per client */
struct z_stream_s compStream;
rfbBool compStreamInited;
uint32_t zlibCompressLevel;
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
/* tight encoding -- preserve zlib streams' state for each client */
z_stream zsStruct[4];
rfbBool zsActive[4];
int zsLevel[4];
int tightCompressLevel;
int tightQualityLevel;
#endif
#endif
rfbBool enableLastRectEncoding; /* client supports LastRect encoding */
rfbBool enableCursorShapeUpdates; /* client supports cursor shape updates */
rfbBool enableCursorPosUpdates; /* client supports cursor position updates */
rfbBool useRichCursorEncoding; /* rfbEncodingRichCursor is preferred */
rfbBool cursorWasChanged; /* cursor shape update should be sent */
rfbBool cursorWasMoved; /* cursor position update should be sent */
rfbBool useNewFBSize; /* client supports NewFBSize encoding */
rfbBool newFBSizePending; /* framebuffer size was changed */
#ifdef LIBVNCSERVER_BACKCHANNEL
rfbBool enableBackChannel; /* custom channel for special clients */
#endif
struct _rfbClientRec *prev;
struct _rfbClientRec *next;
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
/* whenever a client is referenced, the refCount has to be incremented
and afterwards decremented, so that the client is not cleaned up
while being referenced.
Use the functions rfbIncrClientRef(cl) and rfbDecrClientRef(cl);
*/
int refCount;
MUTEX(refCountMutex);
COND(deleteCond);
MUTEX(outputMutex);
MUTEX(updateMutex);
COND(updateCond);
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
void* zrleData;
#endif
/* if progressive updating is on, this variable holds the current
* y coordinate of the progressive slice. */
int progressiveSliceY;
} rfbClientRec, *rfbClientPtr;
/*
* This macro is used to test whether there is a framebuffer update needing to
* be sent to the client.
*/
#define FB_UPDATE_PENDING(cl) \
((!(cl)->enableCursorShapeUpdates && !(cl)->screen->cursorIsDrawn) || \
((cl)->enableCursorShapeUpdates && (cl)->cursorWasChanged) || \
((cl)->useNewFBSize && (cl)->newFBSizePending) || \
((cl)->enableCursorPosUpdates && (cl)->cursorWasMoved) || \
!sraRgnEmpty((cl)->copyRegion) || !sraRgnEmpty((cl)->modifiedRegion))
/*
* Macros for endian swapping.
*/
#define Swap16(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
#define Swap24(l) ((((l) & 0xff) << 16) | (((l) >> 16) & 0xff) | \
(((l) & 0x00ff00)))
#define Swap32(l) (((l) >> 24) | \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
((l) << 24))
extern char rfbEndianTest;
#define Swap16IfLE(s) (rfbEndianTest ? Swap16(s) : (s))
#define Swap24IfLE(l) (rfbEndianTest ? Swap24(l) : (l))
#define Swap32IfLE(l) (rfbEndianTest ? Swap32(l) : (l))
/* sockets.c */
extern int rfbMaxClientWait;
extern void rfbInitSockets(rfbScreenInfoPtr rfbScreen);
extern void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen);
extern void rfbCloseClient(rfbClientPtr cl);
extern int rfbReadExact(rfbClientPtr cl, char *buf, int len);
extern int rfbReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
extern int rfbWriteExact(rfbClientPtr cl, const char *buf, int len);
extern void rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
extern int rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port);
extern int rfbConnectToTcpAddr(char* host, int port);
extern int rfbListenOnTCPPort(int port);
extern int rfbListenOnUDPPort(int port);
/* rfbserver.c */
/* Routines to iterate over the client list in a thread-safe way.
Only a single iterator can be in use at a time process-wide. */
typedef struct rfbClientIterator *rfbClientIteratorPtr;
extern void rfbClientListInit(rfbScreenInfoPtr rfbScreen);
extern rfbClientIteratorPtr rfbGetClientIterator(rfbScreenInfoPtr rfbScreen);
extern rfbClientPtr rfbClientIteratorNext(rfbClientIteratorPtr iterator);
extern void rfbReleaseClientIterator(rfbClientIteratorPtr iterator);
extern void rfbNewClientConnection(rfbScreenInfoPtr rfbScreen,int sock);
extern rfbClientPtr rfbNewClient(rfbScreenInfoPtr rfbScreen,int sock);
extern rfbClientPtr rfbNewUDPClient(rfbScreenInfoPtr rfbScreen);
extern rfbClientPtr rfbReverseConnection(rfbScreenInfoPtr rfbScreen,char *host, int port);
extern void rfbClientConnectionGone(rfbClientPtr cl);
extern void rfbProcessClientMessage(rfbClientPtr cl);
extern void rfbClientConnFailed(rfbClientPtr cl, char *reason);
extern void rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen,int sock);
extern void rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen);
extern rfbBool rfbSendFramebufferUpdate(rfbClientPtr cl, sraRegionPtr updateRegion);
extern rfbBool rfbSendRectEncodingRaw(rfbClientPtr cl, int x,int y,int w,int h);
extern rfbBool rfbSendUpdateBuf(rfbClientPtr cl);
extern void rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len);
extern rfbBool rfbSendCopyRegion(rfbClientPtr cl,sraRegionPtr reg,int dx,int dy);
extern rfbBool rfbSendLastRectMarker(rfbClientPtr cl);
extern rfbBool rfbSendNewFBSize(rfbClientPtr cl, int w, int h);
extern rfbBool rfbSendSetColourMapEntries(rfbClientPtr cl, int firstColour, int nColours);
extern void rfbSendBell(rfbScreenInfoPtr rfbScreen);
void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len);
#ifdef LIBVNCSERVER_BACKCHANNEL
extern void rfbSendBackChannel(rfbScreenInfoPtr s,char* message,int len);
#endif
/* translate.c */
extern rfbBool rfbEconomicTranslate;
extern void rfbTranslateNone(char *table, rfbPixelFormat *in,
rfbPixelFormat *out,
char *iptr, char *optr,
int bytesBetweenInputLines,
int width, int height);
extern rfbBool rfbSetTranslateFunction(rfbClientPtr cl);
extern rfbBool rfbSetClientColourMap(rfbClientPtr cl, int firstColour, int nColours);
extern void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour, int nColours);
/* httpd.c */
extern void rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen);
extern void rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen);
/* auth.c */
extern void rfbAuthNewClient(rfbClientPtr cl);
extern void rfbAuthProcessClientMessage(rfbClientPtr cl);
/* rre.c */
extern rfbBool rfbSendRectEncodingRRE(rfbClientPtr cl, int x,int y,int w,int h);
/* corre.c */
extern rfbBool rfbSendRectEncodingCoRRE(rfbClientPtr cl, int x,int y,int w,int h);
/* hextile.c */
extern rfbBool rfbSendRectEncodingHextile(rfbClientPtr cl, int x, int y, int w,
int h);
#ifdef LIBVNCSERVER_HAVE_LIBZ
/* zlib.c */
/* Minimum zlib rectangle size in bytes. Anything smaller will
* not compress well due to overhead.
*/
#define VNC_ENCODE_ZLIB_MIN_COMP_SIZE (17)
/* Set maximum zlib rectangle size in pixels. Always allow at least
* two scan lines.
*/
#define ZLIB_MAX_RECT_SIZE (128*256)
#define ZLIB_MAX_SIZE(min) ((( min * 2 ) > ZLIB_MAX_RECT_SIZE ) ? \
( min * 2 ) : ZLIB_MAX_RECT_SIZE )
extern rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w,
int h);
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
/* tight.c */
#define TIGHT_DEFAULT_COMPRESSION 6
extern rfbBool rfbTightDisableGradient;
extern int rfbNumCodedRectsTight(rfbClientPtr cl, int x,int y,int w,int h);
extern rfbBool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h);
#endif
#endif
/* cursor.c */
typedef struct rfbCursor {
/* set this to true if LibVNCServer has to free this cursor */
rfbBool cleanup, cleanupSource, cleanupMask, cleanupRichSource;
unsigned char *source; /* points to bits */
unsigned char *mask; /* points to bits */
unsigned short width, height, xhot, yhot; /* metrics */
unsigned short foreRed, foreGreen, foreBlue; /* device-independent colour */
unsigned short backRed, backGreen, backBlue; /* device-independent colour */
unsigned char *richSource; /* source bytes for a rich cursor */
} rfbCursor, *rfbCursorPtr;
extern unsigned char rfbReverseByte[0x100];
extern rfbBool rfbSendCursorShape(rfbClientPtr cl/*, rfbScreenInfoPtr pScreen*/);
extern rfbBool rfbSendCursorPos(rfbClientPtr cl);
extern void rfbConvertLSBCursorBitmapOrMask(int width,int height,unsigned char* bitmap);
extern rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskString);
extern char* rfbMakeMaskForXCursor(int width,int height,char* cursorString);
extern void rfbMakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void rfbFreeCursor(rfbCursorPtr cursor);
extern void rfbDrawCursor(rfbScreenInfoPtr rfbScreen);
extern void rfbUndrawCursor(rfbScreenInfoPtr rfbScreen);
extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,rfbBool freeOld);
/* cursor handling for the pointer */
extern void rfbDefaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl);
/* zrle.c */
#ifdef LIBVNCSERVER_HAVE_LIBZ
extern rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w,int h);
extern void rfbFreeZrleData(rfbClientPtr cl);
#endif
/* stats.c */
extern void rfbResetStats(rfbClientPtr cl);
extern void rfbPrintStats(rfbClientPtr cl);
/* font.c */
typedef struct rfbFontData {
unsigned char* data;
/*
metaData is a 256*5 array:
for each character
(offset,width,height,x,y)
*/
int* metaData;
} rfbFontData,* rfbFontDataPtr;
int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,rfbPixel colour);
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,rfbPixel colour);
/* if colour==backColour, background is transparent */
int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,int x1,int y1,int x2,int y2,rfbPixel colour,rfbPixel backColour);
void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,int x1,int y1,int x2,int y2,rfbPixel colour,rfbPixel backColour);
int rfbWidthOfString(rfbFontDataPtr font,const char* string);
int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c);
void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2);
/* this returns the smallest box enclosing any character of font. */
void rfbWholeFontBBox(rfbFontDataPtr font,int *x1, int *y1, int *x2, int *y2);
/* dynamically load a linux console font (4096 bytes, 256 glyphs a 8x16 */
rfbFontDataPtr rfbLoadConsoleFont(char *filename);
/* free a dynamically loaded font */
void rfbFreeFont(rfbFontDataPtr font);
/* draw.c */
/* You have to call rfbUndrawCursor before using these functions */
void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col);
void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,rfbPixel col);
void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col);
/* selbox.c */
/* this opens a modal select box. list is an array of strings, the end marked
with a NULL.
It returns the index in the list or -1 if cancelled or something else
wasn't kosher. */
typedef void (*SelectionChangedHookPtr)(int _index);
extern int rfbSelectBox(rfbScreenInfoPtr rfbScreen,
rfbFontDataPtr font, char** list,
int x1, int y1, int x2, int y2,
rfbPixel foreColour, rfbPixel backColour,
int border,SelectionChangedHookPtr selChangedHook);
/* cargs.c */
extern void rfbUsage(void);
extern void rfbPurgeArguments(int* argc,int* position,int count,char *argv[]);
extern rfbBool rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]);
extern rfbBool rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]);
/* main.c */
extern void rfbLogEnable(int enabled);
typedef void (*rfbLogProc)(const char *format, ...);
extern rfbLogProc rfbLog, rfbErr;
extern void rfbLogPerror(const char *str);
void rfbScheduleCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy);
void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy);
void rfbDoCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy);
void rfbDoCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy);
void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2);
void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen,sraRegionPtr modRegion);
void rfbDoNothingWithClient(rfbClientPtr cl);
enum rfbNewClientAction defaultNewClientHook(rfbClientPtr cl);
/* to check against plain passwords */
rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len);
/* functions to make a vnc server */
extern rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
int width,int height,int bitsPerSample,int samplesPerPixel,
int bytesPerPixel);
extern void rfbInitServer(rfbScreenInfoPtr rfbScreen);
extern void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen,char *framebuffer,
int width,int height, int bitsPerSample,int samplesPerPixel,
int bytesPerPixel);
extern void rfbScreenCleanup(rfbScreenInfoPtr screenInfo);
/* functions to accept/refuse a client that has been put on hold
by a NewClientHookPtr function. Must not be called in other
situations. */
extern void rfbStartOnHoldClient(rfbClientPtr cl);
extern void rfbRefuseOnHoldClient(rfbClientPtr cl);
/* call one of these two functions to service the vnc clients.
usec are the microseconds the select on the fds waits.
if you are using the event loop, set this to some value > 0, so the
server doesn't get a high load just by listening. */
extern void rfbRunEventLoop(rfbScreenInfoPtr screenInfo, long usec, rfbBool runInBackground);
extern void rfbProcessEvents(rfbScreenInfoPtr screenInfo,long usec);
#endif
#if(defined __cplusplus)
}
#endif

View File

@@ -0,0 +1,204 @@
#ifndef RFBCLIENT_H
#define RFBCLIENT_H
/*
* Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved.
* Copyright (C) 2000 Tridia Corporation. All Rights Reserved.
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
/*
* vncviewer.h
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <rfb/rfbproto.h>
#include <rfb/keysym.h>
#define rfbClientSwap16IfLE(s) \
(*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
#define rfbClientSwap32IfLE(l) \
(*(char *)&client->endianTest ? ((((l) & 0xff000000) >> 24) | \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24)) : (l))
#define FLASH_PORT_OFFSET 5400
#define LISTEN_PORT_OFFSET 5500
#define TUNNEL_PORT_OFFSET 5500
#define SERVER_PORT_OFFSET 5900
#define DEFAULT_SSH_CMD "/usr/bin/ssh"
#define DEFAULT_TUNNEL_CMD \
(DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20")
#define DEFAULT_VIA_CMD \
(DEFAULT_SSH_CMD " -f -L %L:%H:%R %G sleep 20")
/* vncrec */
typedef struct {
FILE* file;
struct timeval tv;
rfbBool readTimestamp;
rfbBool doNotSleep;
} rfbVNCRec;
typedef struct {
rfbBool shareDesktop;
rfbBool viewOnly;
const char* encodingsString;
rfbBool useBGR233;
int nColours;
rfbBool forceOwnCmap;
rfbBool forceTrueColour;
int requestedDepth;
int compressLevel;
int qualityLevel;
rfbBool enableJPEG;
rfbBool useRemoteCursor;
} AppData;
struct _rfbClient;
typedef rfbBool (*HandleCursorPosProc)(struct _rfbClient* client, int x, int y);
typedef void (*SoftCursorLockAreaProc)(struct _rfbClient* client, int x, int y, int w, int h);
typedef void (*SoftCursorUnlockScreenProc)(struct _rfbClient* client);
typedef void (*GotFrameBufferUpdateProc)(struct _rfbClient* client, int x, int y, int w, int h);
typedef char* (*GetPasswordProc)(struct _rfbClient* client);
typedef rfbBool (*MallocFrameBufferProc)(struct _rfbClient* client);
typedef void (*BellProc)(struct _rfbClient* client);
typedef struct _rfbClient {
uint8_t* frameBuffer;
int width, height;
int endianTest;
AppData appData;
const char* programName;
char* serverHost;
int serverPort; /* if -1, then use file recorded by vncrec */
rfbBool listenSpecified;
int listenPort, flashPort;
/* Note that the CoRRE encoding uses this buffer and assumes it is big enough
to hold 255 * 255 * 32 bits -> 260100 bytes. 640*480 = 307200 bytes.
Hextile also assumes it is big enough to hold 16 * 16 * 32 bits.
Tight encoding assumes BUFFER_SIZE is at least 16384 bytes. */
#define RFB_BUFFER_SIZE (640*480)
char buffer[RFB_BUFFER_SIZE];
/* rfbproto.c */
int sock;
rfbBool canUseCoRRE;
rfbBool canUseHextile;
char *desktopName;
rfbPixelFormat format;
rfbServerInitMsg si;
char *serverCutText;
rfbBool newServerCutText;
/* sockets.c */
#define RFB_BUF_SIZE 8192
char buf[RFB_BUF_SIZE];
char *bufoutptr;
int buffered;
/* cursor.c */
uint8_t *rcSource, *rcMask;
/* private data pointer */
void* clientData;
rfbVNCRec* vncRec;
/* hooks */
HandleCursorPosProc HandleCursorPos;
SoftCursorLockAreaProc SoftCursorLockArea;
SoftCursorUnlockScreenProc SoftCursorUnlockScreen;
GotFrameBufferUpdateProc GotFrameBufferUpdate;
/* the pointer returned by GetPassword will be freed after use! */
GetPasswordProc GetPassword;
MallocFrameBufferProc MallocFrameBuffer;
BellProc Bell;
} rfbClient;
/* cursor.c */
extern rfbBool HandleCursorShape(rfbClient* client,int xhot, int yhot, int width, int height, uint32_t enc);
/* listen.c */
extern void listenForIncomingConnections(rfbClient* viewer);
/* rfbproto.c */
extern rfbBool rfbEnableClientLogging;
typedef void (*rfbClientLogProc)(const char *format, ...);
extern rfbClientLogProc rfbClientLog,rfbClientErr;
extern rfbBool ConnectToRFBServer(rfbClient* client,const char *hostname, int port);
extern rfbBool InitialiseRFBConnection(rfbClient* client);
extern rfbBool SetFormatAndEncodings(rfbClient* client);
extern rfbBool SendIncrementalFramebufferUpdateRequest(rfbClient* client);
extern rfbBool SendFramebufferUpdateRequest(rfbClient* client,
int x, int y, int w, int h,
rfbBool incremental);
extern rfbBool SendPointerEvent(rfbClient* client,int x, int y, int buttonMask);
extern rfbBool SendKeyEvent(rfbClient* client,uint32_t key, rfbBool down);
extern rfbBool SendClientCutText(rfbClient* client,char *str, int len);
extern rfbBool HandleRFBServerMessage(rfbClient* client);
extern void PrintPixelFormat(rfbPixelFormat *format);
/* sockets.c */
extern rfbBool errorMessageOnReadFailure;
extern rfbBool ReadFromRFBServer(rfbClient* client, char *out, unsigned int n);
extern rfbBool WriteToRFBServer(rfbClient* client, char *buf, int n);
extern int FindFreeTcpPort(void);
extern int ListenAtTcpPort(int port);
extern int ConnectClientToTcpAddr(unsigned int host, int port);
extern int AcceptTcpConnection(int listenSock);
extern rfbBool SetNonBlocking(int sock);
extern rfbBool StringToIPAddr(const char *str, unsigned int *addr);
extern rfbBool SameMachine(int sock);
extern int WaitForMessage(rfbClient* client,unsigned int usecs);
/* vncviewer.c */
rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,int bytesPerPixel);
rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv);
void rfbClientCleanup(rfbClient* client);
#endif

View File

@@ -0,0 +1,342 @@
#ifndef _RFB_RFBCONFIG_H
# define _RFB_RFBCONFIG_H
/* Enable 24 bit per pixel in native framebuffer */
#ifndef LIBVNCSERVER_ALLOW24BPP
# define LIBVNCSERVER_ALLOW24BPP 1
#endif
/* Enable BackChannel communication */
#ifndef LIBVNCSERVER_BACKCHANNEL
# define LIBVNCSERVER_BACKCHANNEL 1
#endif
/* Use ffmpeg (for vnc2mpg) */
/* #undef LIBVNCSERVER_FFMPEG */
/* Define to 1 if you have the <arpa/inet.h> header file. */
#ifndef LIBVNCSERVER_HAVE_ARPA_INET_H
# define LIBVNCSERVER_HAVE_ARPA_INET_H 1
#endif
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef LIBVNCSERVER_HAVE_DOPRNT */
/* Define to 1 if you have the <fcntl.h> header file. */
#ifndef LIBVNCSERVER_HAVE_FCNTL_H
# define LIBVNCSERVER_HAVE_FCNTL_H 1
#endif
/* Define to 1 if you have the `fork' function. */
/* #undef LIBVNCSERVER_HAVE_FORK */
/* Define to 1 if you have the `ftime' function. */
#ifndef LIBVNCSERVER_HAVE_FTIME
#define LIBVNCSERVER_HAVE_FTIME 1
#endif
/* Define to 1 if you have the `gethostbyname' function. */
#ifndef LIBVNCSERVER_HAVE_GETHOSTBYNAME
#define LIBVNCSERVER_HAVE_GETHOSTBYNAME 1
#endif
/* Define to 1 if you have the `gethostname' function. */
#ifndef LIBVNCSERVER_HAVE_GETHOSTNAME
#define LIBVNCSERVER_HAVE_GETHOSTNAME 1
#endif
/* Define to 1 if you have the `gettimeofday' function. */
#ifndef LIBVNCSERVER_HAVE_GETTIMEOFDAY
#define LIBVNCSERVER_HAVE_GETTIMEOFDAY 1
#endif
/* Define to 1 if you have the `inet_ntoa' function. */
#ifndef LIBVNCSERVER_HAVE_INET_NTOA
#define LIBVNCSERVER_HAVE_INET_NTOA 1
#endif
/* Define to 1 if you have the <inttypes.h> header file. */
#ifndef LIBVNCSERVER_HAVE_INTTYPES_H
#define LIBVNCSERVER_HAVE_INTTYPES_H 1
#endif
/* Define to 1 if you have the `jpeg' library (-ljpeg). */
/* #undef LIBVNCSERVER_HAVE_LIBJPEG */
/* Define to 1 if you have the `nsl' library (-lnsl). */
/* #undef LIBVNCSERVER_HAVE_LIBNSL */
/* Define to 1 if you have the `pthread' library (-lpthread). */
#ifndef LIBVNCSERVER_HAVE_LIBPTHREAD
#define LIBVNCSERVER_HAVE_LIBPTHREAD 1
#endif
/* Define to 1 if you have the `socket' library (-lsocket). */
/* #undef LIBVNCSERVER_HAVE_LIBSOCKET */
/* Define to 1 if you have the `z' library (-lz). */
#ifndef LIBVNCSERVER_HAVE_LIBZ
#define LIBVNCSERVER_HAVE_LIBZ 1
#endif
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#ifndef LIBVNCSERVER_HAVE_MALLOC
#define LIBVNCSERVER_HAVE_MALLOC 1
#endif
/* Define to 1 if you have the `memmove' function. */
#ifndef LIBVNCSERVER_HAVE_MEMMOVE
#define LIBVNCSERVER_HAVE_MEMMOVE 1
#endif
/* Define to 1 if you have the <memory.h> header file. */
#ifndef LIBVNCSERVER_HAVE_MEMORY_H
#define LIBVNCSERVER_HAVE_MEMORY_H 1
#endif
/* Define to 1 if you have the `memset' function. */
#ifndef LIBVNCSERVER_HAVE_MEMSET
#define LIBVNCSERVER_HAVE_MEMSET 1
#endif
/* Define to 1 if you have the `mkfifo' function. */
/* #unndef LIBVNCSERVER_HAVE_MKFIFO */
/* Define to 1 if you have the <netdb.h> header file. */
#ifndef LIBVNCSERVER_HAVE_NETDB_H
#define LIBVNCSERVER_HAVE_NETDB_H 1
#endif
/* Define to 1 if you have the <netinet/in.h> header file. */
/* #undef LIBVNCSERVER_HAVE_NETINET_IN_H */
/* Define to 1 if you have the `select' function. */
#ifndef LIBVNCSERVER_HAVE_SELECT
#define LIBVNCSERVER_HAVE_SELECT 1
#endif
/* Define to 1 if you have the `setsid' function. */
/* #undef LIBVNCSERVER_HAVE_SETSID */
/* Define to 1 if you have the `socket' function. */
#ifndef LIBVNCSERVER_HAVE_SOCKET
#define LIBVNCSERVER_HAVE_SOCKET 1
#endif
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
/* #undef LIBVNCSERVER_HAVE_STAT_EMPTY_STRING_BUG */
/* Define to 1 if you have the <stdint.h> header file. */
#ifndef LIBVNCSERVER_HAVE_STDINT_H
#define LIBVNCSERVER_HAVE_STDINT_H 1
#endif
/* Define to 1 if you have the <stdlib.h> header file. */
#ifndef LIBVNCSERVER_HAVE_STDLIB_H
#define LIBVNCSERVER_HAVE_STDLIB_H 1
#endif
/* Define to 1 if you have the `strchr' function. */
#ifndef LIBVNCSERVER_HAVE_STRCHR
#define LIBVNCSERVER_HAVE_STRCHR 1
#endif
/* Define to 1 if you have the `strcspn' function. */
#ifndef LIBVNCSERVER_HAVE_STRCSPN
#define LIBVNCSERVER_HAVE_STRCSPN 1
#endif
/* Define to 1 if you have the `strdup' function. */
#ifndef LIBVNCSERVER_HAVE_STRDUP
#define LIBVNCSERVER_HAVE_STRDUP 1
#endif
/* Define to 1 if you have the `strerror' function. */
#ifndef LIBVNCSERVER_HAVE_STRERROR
#define LIBVNCSERVER_HAVE_STRERROR 1
#endif
/* Define to 1 if you have the `strftime' function. */
#ifndef LIBVNCSERVER_HAVE_STRFTIME
#define LIBVNCSERVER_HAVE_STRFTIME 1
#endif
/* Define to 1 if you have the <strings.h> header file. */
#ifndef LIBVNCSERVER_HAVE_STRINGS_H
#define LIBVNCSERVER_HAVE_STRINGS_H 1
#endif
/* Define to 1 if you have the <string.h> header file. */
#ifndef LIBVNCSERVER_HAVE_STRING_H
#define LIBVNCSERVER_HAVE_STRING_H 1
#endif
/* Define to 1 if you have the `strstr' function. */
#ifndef LIBVNCSERVER_HAVE_STRSTR
#define LIBVNCSERVER_HAVE_STRSTR 1
#endif
/* Define to 1 if you have the <syslog.h> header file. */
/* #undef LIBVNCSERVER_HAVE_SYSLOG_H */
/* Define to 1 if you have the <sys/socket.h> header file. */
/* #undef LIBVNCSERVER_HAVE_SYS_SOCKET_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#ifndef LIBVNCSERVER_HAVE_SYS_STAT_H
#define LIBVNCSERVER_HAVE_SYS_STAT_H 1
#endif
/* Define to 1 if you have the <sys/timeb.h> header file. */
#ifndef LIBVNCSERVER_HAVE_SYS_TIMEB_H
#define LIBVNCSERVER_HAVE_SYS_TIMEB_H 1
#endif
/* Define to 1 if you have the <sys/time.h> header file. */
#ifndef LIBVNCSERVER_HAVE_SYS_TIME_H
#define LIBVNCSERVER_HAVE_SYS_TIME_H 1
#endif
/* Define to 1 if you have the <sys/types.h> header file. */
#ifndef LIBVNCSERVER_HAVE_SYS_TYPES_H
#define LIBVNCSERVER_HAVE_SYS_TYPES_H 1
#endif
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#ifndef LIBVNCSERVER_HAVE_SYS_WAIT_H
#define LIBVNCSERVER_HAVE_SYS_WAIT_H 1
#endif
/* Define to 1 if you have the <unistd.h> header file. */
#ifndef LIBVNCSERVER_HAVE_UNISTD_H
#define LIBVNCSERVER_HAVE_UNISTD_H 1
#endif
/* Define to 1 if you have the `vfork' function. */
/* #undef LIBVNCSERVER_HAVE_VFORK */
/* Define to 1 if you have the <vfork.h> header file. */
/* #undef LIBVNCSERVER_HAVE_VFORK_H */
/* Define to 1 if you have the `vprintf' function. */
#ifndef LIBVNCSERVER_HAVE_VPRINTF
#define LIBVNCSERVER_HAVE_VPRINTF 1
#endif
/* Define to 1 if `fork' works. */
/* #undef LIBVNCSERVER_HAVE_WORKING_FORK */
/* Define to 1 if `vfork' works. */
/* #undef LIBVNCSERVER_HAVE_WORKING_VFORK */
/* XKEYBOARD extension build environment present */
/* #undef LIBVNCSERVER_HAVE_XKEYBOARD */
/* MIT-SHM extension build environment present */
/* #undef LIBVNCSERVER_HAVE_XSHM */
/* XTEST extension build environment present */
/* #undef LIBVNCSERVER_HAVE_XTEST */
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
/* #undef LIBVNCSERVER_LSTAT_FOLLOWS_SLASHED_SYMLINK */
/* Name of package */
#ifndef LIBVNCSERVER_PACKAGE
#define LIBVNCSERVER_PACKAGE "LibVNCServer"
#endif
/* Define to the address where bug reports for this package should be sent. */
#ifndef LIBVNCSERVER_PACKAGE_BUGREPORT
#define LIBVNCSERVER_PACKAGE_BUGREPORT "http://sourceforge.net/projects/libvncserver"
#endif
/* Define to the full name of this package. */
#ifndef LIBVNCSERVER_PACKAGE_NAME
#define LIBVNCSERVER_PACKAGE_NAME "LibVNCServer"
#endif
/* Define to the full name and version of this package. */
#ifndef LIBVNCSERVER_PACKAGE_STRING
#define LIBVNCSERVER_PACKAGE_STRING "LibVNCServer 0.7"
#endif
/* Define to the one symbol short name of this package. */
#ifndef LIBVNCSERVER_PACKAGE_TARNAME
#define LIBVNCSERVER_PACKAGE_TARNAME "libvncserver"
#endif
/* Define to the version of this package. */
#ifndef LIBVNCSERVER_PACKAGE_VERSION
#define LIBVNCSERVER_PACKAGE_VERSION "0.7"
#endif
/* The number of bytes in type char */
/* #undef LIBVNCSERVER_SIZEOF_CHAR */
/* The number of bytes in type int */
/* #undef LIBVNCSERVER_SIZEOF_INT */
/* The number of bytes in type long */
/* #undef LIBVNCSERVER_SIZEOF_LONG */
/* The number of bytes in type short */
/* #undef LIBVNCSERVER_SIZEOF_SHORT */
/* The number of bytes in type void* */
/* #undef LIBVNCSERVER_SIZEOF_VOIDP */
/* Define to 1 if you have the ANSI C header files. */
#ifndef LIBVNCSERVER_STDC_HEADERS
#define LIBVNCSERVER_STDC_HEADERS 1
#endif
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#ifndef LIBVNCSERVER_TIME_WITH_SYS_TIME
#define LIBVNCSERVER_TIME_WITH_SYS_TIME 1
#endif
/* Version number of package */
#ifndef LIBVNCSERVER_VERSION
#define LIBVNCSERVER_VERSION "0.7"
#endif
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef LIBVNCSERVER_WORDS_BIGENDIAN */
/* Define to 1 if the X Window System is missing or not being used. */
#ifndef LIBVNCSERVER_X_DISPLAY_MISSING
#define LIBVNCSERVER_X_DISPLAY_MISSING 1
#endif
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef _libvncserver_const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef _libvncserver_inline */
#endif
/* Define to rpl_malloc if the replacement function should be used. */
/* #undef _libvncserver_malloc */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef _libvncserver_pid_t */
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef _libvncserver_size_t */
/* The type for socklen */
/* #undef _libvncserver_socklen_t */
/* Define as `fork' if `vfork' does not work. */
/* #undef _libvncserver_vfork */
/* once: _RFB_RFBCONFIG_H */
#endif

View File

@@ -0,0 +1,17 @@
#ifndef _RFB_RFBINT_H
#define _RFB_RFBINT_H 1
#ifndef _GENERATED_STDINT_H
#define _GENERATED_STDINT_H "LibVNCServer 0.7"
/* generated using a gnu compiler version gcc (Debian 4.9.2-10) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
#include <stdint.h>
/* system headers have good uint64_t */
#ifndef _HAVE_UINT64_T
#define _HAVE_UINT64_T
#endif
/* once */
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
#ifndef SRAREGION_H
#define SRAREGION_H
/* -=- SRA - Simple Region Algorithm
* A simple rectangular region implementation.
* Copyright (c) 2001 James "Wez" Weatherall, Johannes E. Schindelin
*/
/* -=- sraRect */
typedef struct _rect {
int x1;
int y1;
int x2;
int y2;
} sraRect;
typedef struct sraRegion sraRegion;
/* -=- Region manipulation functions */
extern sraRegion *sraRgnCreate();
extern sraRegion *sraRgnCreateRect(int x1, int y1, int x2, int y2);
extern sraRegion *sraRgnCreateRgn(const sraRegion *src);
extern void sraRgnDestroy(sraRegion *rgn);
extern void sraRgnMakeEmpty(sraRegion *rgn);
extern rfbBool sraRgnAnd(sraRegion *dst, const sraRegion *src);
extern void sraRgnOr(sraRegion *dst, const sraRegion *src);
extern rfbBool sraRgnSubtract(sraRegion *dst, const sraRegion *src);
extern void sraRgnOffset(sraRegion *dst, int dx, int dy);
extern rfbBool sraRgnPopRect(sraRegion *region, sraRect *rect,
unsigned long flags);
extern unsigned long sraRgnCountRects(const sraRegion *rgn);
extern rfbBool sraRgnEmpty(const sraRegion *rgn);
extern sraRegion *sraRgnBBox(const sraRegion *src);
/* -=- rectangle iterator */
typedef struct sraRectangleIterator {
rfbBool reverseX,reverseY;
int ptrSize,ptrPos;
struct sraSpan** sPtrs;
} sraRectangleIterator;
extern sraRectangleIterator *sraRgnGetIterator(sraRegion *s);
extern sraRectangleIterator *sraRgnGetReverseIterator(sraRegion *s,rfbBool reverseX,rfbBool reverseY);
extern rfbBool sraRgnIteratorNext(sraRectangleIterator *i,sraRect *r);
extern void sraRgnReleaseIterator(sraRectangleIterator *i);
void sraRgnPrint(const sraRegion *s);
/* -=- Rectangle clipper (for speed) */
extern rfbBool sraClipRect(int *x, int *y, int *w, int *h,
int cx, int cy, int cw, int ch);
#endif

View File

@@ -8,7 +8,7 @@
#
# Makefile for Windows using Visual Studio 2015.
#
# Version: @(#)Makefile.VC 1.0.25 2018/05/06
# Version: @(#)Makefile.VC 1.0.26 2018/05/06
#
# Author: Fred N. van Kempen, <decwiz@yahoo.com>
#
@@ -211,7 +211,7 @@ VPATH := $(EXPATH) . cpu \
devices/cdrom devices/disk devices/floppy \
devices/floppy/lzf devices/input devices/input/game \
devices/network devices/network/slirp devices/ports \
devices/sio devices/system devices/scsi \
devices/sio devices/system devices/scsi devices\misc \
devices/sound \
devices/sound/munt devices/sound/munt/c_interface \
devices/sound/munt/sha1 devices/sound/munt/srchelper \

View File

@@ -8,7 +8,7 @@
*
* Platform main support module for Windows.
*
* Version: @(#)win.c 1.0.18 2018/05/06
* Version: @(#)win.c 1.0.19 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -56,6 +56,9 @@
#include "../ui/ui.h"
#define GLOBAL
#include "../plat.h"
#ifdef USE_SDL
# include "../sdl.h"
#endif
#ifdef USE_VNC
# include "../vnc.h"
#endif
@@ -66,9 +69,6 @@
#include "../devices/video/video.h"
#ifdef USE_WX
# include "../wx/wx_ui.h"
#else
# include "win_ddraw.h"
# include "win_d3d.h"
#endif
#include "win.h"
@@ -99,52 +99,25 @@ static rc_str_t *lpRCstr2048,
*lpRCstr7168;
static const struct {
char *name;
int local;
int (*init)(void *);
void (*close)(void);
void (*resize)(int x, int y);
int (*pause)(void);
} vid_apis[2][4] = {
{
const vidapi_t *vid_apis[] = {
#ifdef USE_WX
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
&wx_vidapi,
#else
{ "DDraw", 1, (int(*)(void*))ddraw_init, ddraw_close, NULL, ddraw_pause },
{ "D3D", 1, (int(*)(void*))d3d_init, d3d_close, d3d_resize, d3d_pause },
&ddraw_vidapi,
&d3d_vidapi,
#endif
#ifdef USE_SDL
&sdl_vidapi,
#endif
#ifdef USE_VNC
{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause },
#else
{ NULL, 0, NULL, NULL, NULL, NULL },
&vnc_vidapi,
#endif
#ifdef USE_RDP
{ "RDP", 0, rdp_init, rdp_close, rdp_resize, rdp_pause }
#else
{ NULL, 0, NULL, NULL, NULL, NULL }
&rdp_vidapi,
#endif
},
{
#ifdef USE_WX
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
#else
{ "DDraw", 1, (int(*)(void*))ddraw_init_fs, ddraw_close, NULL, ddraw_pause },
{ "D3D", 1, (int(*)(void*))d3d_init_fs, d3d_close, NULL, d3d_pause },
#endif
#ifdef USE_VNC
{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause },
#else
{ NULL, 0, NULL, NULL, NULL, NULL },
#endif
#ifdef USE_RDP
{ "RDP", 0, rdp_init, rdp_close, rdp_resize, rdp_pause }
#else
{ NULL, 0, NULL, NULL, NULL, NULL }
#endif
},
NULL
};
@@ -654,17 +627,40 @@ plat_delay_ms(uint32_t count)
}
/* Get number of VidApi entries. */
int
plat_vidapi_count(void)
{
return((sizeof(vid_apis)/sizeof(vidapi_t *)) - 1);
}
/* Get availability of a VidApi entry. */
int
plat_vidapi_available(int api)
{
int ret = 1;
if (vid_apis[api]->available != NULL)
ret = vid_apis[api]->available();
return(ret);
}
/* Return the VIDAPI number for the given name. */
int
plat_vidapi(const char *name)
plat_vidapi_from_internal_name(const char *name)
{
int i;
int i = 0;
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(1);
if (!strcasecmp(name, "default") ||
!strcasecmp(name, "system")) return(0);
for (i=0; i<4; i++) {
if (vid_apis[0][i].name &&
!strcasecmp(vid_apis[0][i].name, name)) return(i);
while(vid_apis[i] != NULL) {
if (! strcasecmp(vid_apis[i]->name, name)) return(i);
i++;
}
/* Default value. */
@@ -674,74 +670,44 @@ plat_vidapi(const char *name)
/* Return the VIDAPI name for the given number. */
const char *
plat_vidapi_name(int api)
plat_vidapi_internal_name(int api)
{
char *name = "default";
const char *name = "default";
switch(api) {
#ifdef USE_WX
case 0:
break;
case 1:
name = "wxwidgets";
break;
#else
case 0:
name = "ddraw";
break;
case 1:
name = "d3d";
break;
#endif
#ifdef USE_VNC
case 2:
name = "vnc";
break;
#endif
#ifdef USE_RDP
case 3:
name = "rdp";
break;
#endif
}
if (vid_apis[api] != NULL)
return(vid_apis[api]->name);
return(name);
}
int
plat_setvid(int api)
plat_vidapi_set(int api)
{
int i;
pclog("Initializing VIDAPI: api=%d\n", api);
startblit();
video_wait_for_blit();
/* Close the (old) API. */
vid_apis[0][vid_api].close();
vid_api = api;
vid_apis[vid_api]->close();
/* Show or hide the render window. */
#ifndef USE_WX
if (vid_apis[0][vid_api].local)
if (vid_apis[api]->local)
ShowWindow(hwndRender, SW_SHOW);
else
ShowWindow(hwndRender, SW_HIDE);
#endif
/* Initialize the (new) API. */
#ifdef USE_WX
i = vid_apis[0][vid_api].init(NULL);
#else
i = vid_apis[0][vid_api].init((void *)hwndRender);
#endif
vid_api = api;
i = vid_apis[vid_api]->init(vid_fullscreen);
/* Update the menu item. */
menu_set_radio_item(IDM_RENDER_1, 4, vid_api);
menu_set_radio_item(IDM_RENDER_1, plat_vidapi_count(), vid_api);
endblit();
if (! i) return(0);
@@ -754,29 +720,44 @@ plat_setvid(int api)
/* Tell the renderers about a new screen resolution. */
void
plat_vidsize(int x, int y)
plat_vidapi_resize(int x, int y)
{
if (! vid_apis[vid_fullscreen][vid_api].resize) return;
/* If not defined, not supported or needed. */
if (vid_apis[vid_api]->resize == NULL) return;
startblit();
video_wait_for_blit();
vid_apis[vid_fullscreen][vid_api].resize(x, y);
vid_apis[vid_api]->resize(x, y);
endblit();
}
int
get_vidpause(void)
plat_vidapi_pause(void)
{
return(vid_apis[vid_fullscreen][vid_api].pause());
/* If not defined, assume always OK. */
if (vid_apis[vid_api]->pause == NULL) return(0);
return(vid_apis[vid_api]->pause());
}
void
plat_vidapi_reset(void)
{
/* If not defined, assume always OK. */
if (vid_apis[vid_api]->reset == NULL) return;
return(vid_apis[vid_api]->reset(vid_fullscreen));
}
void
plat_setfullscreen(int on)
{
HWND *hw;
/* Want off and already off? */
if (!on && !vid_fullscreen) return;
@@ -795,10 +776,9 @@ plat_setfullscreen(int on)
win_mouse_close();
/* Close the current mode, and open the new one. */
vid_apis[vid_fullscreen][vid_api].close();
vid_apis[vid_api]->close();
vid_fullscreen = on;
hw = (vid_fullscreen) ? &hwndMain : &hwndRender;
vid_apis[vid_fullscreen][vid_api].init((void *) *hw);
vid_apis[vid_api]->init(vid_fullscreen);
#ifdef USE_WX
wx_set_fullscreen(on);
@@ -811,9 +791,6 @@ plat_setfullscreen(int on)
device_force_redraw();
/* Finally, handle the host's mouse cursor. */
#if 0
pclog("%s full screen, %s cursor\n", on ? "enter" : "leave", on ? "hide" : "show");
#endif
ui_show_cursor(vid_fullscreen ? 0 : -1);
}
@@ -826,10 +803,7 @@ take_screenshot(void)
time_t now;
pclog("Screenshot: video API is: %i\n", vid_api);
if ((vid_api < 0) || (vid_api > 1)) return;
memset(fn, 0, sizeof(fn));
memset(path, 0, sizeof(path));
if (vid_api < 0) return;
(void)time(&now);
info = localtime(&now);
@@ -844,28 +818,7 @@ take_screenshot(void)
wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info);
wcscat(path, fn);
switch(vid_api) {
#ifdef USE_WX
case 0:
case 1:
wx_screenshot(path);
break;
#else
case 0: /* ddraw */
ddraw_take_screenshot(path);
break;
case 1: /* d3d9 */
d3d_take_screenshot(path);
break;
#endif
#ifdef USE_VNC
case 2: /* vnc */
vnc_take_screenshot(path);
break;
#endif
}
vid_apis[vid_api]->screenshot(path);
}

View File

@@ -8,7 +8,7 @@
*
* Platform support defintions for Win32.
*
* Version: @(#)win.h 1.0.11 2018/05/06
* Version: @(#)win.h 1.0.12 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -40,10 +40,6 @@
# define PLAT_WIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include "resource.h" /* local resources */
#include "../ui/ui_resource.h" /* common resources */
@@ -69,16 +65,22 @@ extern "C" {
#define SB_PADDING 1 /* 1px of padding */
#ifdef __cplusplus
extern "C" {
#endif
extern HINSTANCE hInstance;
extern HICON hIcon[512];
extern HWND hwndMain,
hwndRender;
extern LCID lang_id;
extern int status_is_open;
extern DWORD filterindex;
extern int status_is_open;
extern const vidapi_t *vid_apis[];
/* VidApi initializers. */
extern const vidapi_t ddraw_vidapi;
extern const vidapi_t d3d_vidapi;
/* Internal platform support functions. */
@@ -102,7 +104,6 @@ extern uint8_t dlg_jsconf(HWND hwnd, int joy_nr, int type);
/* Platform support functions. */
extern void plat_set_language(int id);
extern int get_vidpause(void);
extern int fdd_type_icon(int type);
/* Platform UI support functions. */

View File

@@ -8,7 +8,7 @@
*
* Rendering module for Microsoft Direct3D 9.
*
* Version: @(#)win_d3d.cpp 1.0.10 2018/05/06
* Version: @(#)win_d3d.cpp 1.0.11 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -51,7 +51,6 @@
#endif
#include "../devices/video/video.h"
#include "win.h"
#include "win_d3d.h"
struct CUSTOMVERTEX {
@@ -384,149 +383,60 @@ d3d_blit(int x, int y, int y1, int y2, int w, int h)
static void
d3d_init_objects(void)
d3d_reset(int fs)
{
D3DLOCKED_RECT dr;
RECT r;
int y;
HRESULT hr;
if (FAILED(d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED,
&v_buffer,
NULL)))
fatal("CreateVertexBuffer failed\n");
if (d3ddev == NULL) return;
if (FAILED(d3ddev->CreateTexture(2048, 2048, 1, 0,
D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL)))
fatal("CreateTexture failed\n");
memset(&d3dpp, 0x00, sizeof(d3dpp));
r.top = r.left = 0;
r.bottom = r.right = 2047;
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
fatal("LockRect failed\n");
for (y = 0; y < 2048; y++) {
uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch));
memset(p, 0, 2048 * 4);
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
if (fs)
d3dpp.hDeviceWindow = d3d_device_window;
else
d3dpp.hDeviceWindow = d3d_hwnd;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
if (fs) {
d3dpp.Windowed = false;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = d3d_w;
d3dpp.BackBufferHeight = d3d_h;
} else {
d3dpp.Windowed = true;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferWidth = 0;
d3dpp.BackBufferHeight = 0;
}
d3dTexture->UnlockRect(0);
hr = d3ddev->Reset(&d3dpp);
if (hr == D3DERR_DEVICELOST) {
pclog("D3D: Unable to reset device!\n");
return;
}
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
}
int
d3d_init(HWND h)
{
HRESULT result;
d3d_hwnd = h;
cgapal_rebuild();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = h;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = true;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferWidth = 0;
d3dpp.BackBufferHeight = 0;
result = d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, h,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &d3ddev);
if (FAILED(result))
fatal("CreateDevice failed, result = 0x%08x\n", result);
d3d_init_objects();
video_setblit(d3d_blit);
return(1);
}
int
d3d_init_fs(HWND h)
{
WCHAR title[200];
cgapal_rebuild();
d3d_w = GetSystemMetrics(SM_CXSCREEN);
d3d_h = GetSystemMetrics(SM_CYSCREEN);
d3d_hwnd = h;
/*FIXME: should be done once, in win.c */
_swprintf(title, L"%s v%s", TEXT(EMU_NAME), TEXT(EMU_VERSION));
d3d_device_window = CreateWindow(
FS_CLASS_NAME,
title,
WS_POPUP,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
HWND_DESKTOP,
NULL,
NULL,
NULL
);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = d3d_device_window;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = false;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = d3d_w;
d3dpp.BackBufferHeight = d3d_h;
if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, h,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &d3ddev)))
fatal("CreateDevice failed\n");
d3d_init_objects();
video_setblit(d3d_blit_fs);
return(1);
device_force_redraw();
}
static void
d3d_close_objects(void)
{
d3d_close(void)
{
video_setblit(NULL);
if (d3dTexture) {
d3dTexture->Release();
d3dTexture = NULL;
@@ -535,15 +445,6 @@ d3d_close_objects(void)
v_buffer->Release();
v_buffer = NULL;
}
}
void
d3d_close(void)
{
video_setblit(NULL);
d3d_close_objects();
if (d3ddev) {
d3ddev->Release();
@@ -561,97 +462,142 @@ d3d_close(void)
}
void
d3d_reset(void)
static int
d3d_init(int fs)
{
WCHAR title[200];
D3DLOCKED_RECT dr;
HRESULT hr;
RECT r;
int y;
if (! d3ddev) return;
pclog("D3D: init (fs=%d)\n", fs);
memset(&d3dpp, 0, sizeof(d3dpp));
d3d_hwnd = hwndRender;
cgapal_rebuild();
if (fs) {
d3d_w = GetSystemMetrics(SM_CXSCREEN);
d3d_h = GetSystemMetrics(SM_CYSCREEN);
_swprintf(title, L"%s v%s", TEXT(EMU_NAME), TEXT(EMU_VERSION));
d3d_device_window = CreateWindow(
FS_CLASS_NAME,
title,
WS_POPUP,
CW_USEDEFAULT, CW_USEDEFAULT,
640, 480,
HWND_DESKTOP,
NULL,
NULL,
NULL
);
}
d3d = Direct3DCreate9(D3D_SDK_VERSION);
memset(&d3dpp, 0x00, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = d3d_hwnd;
if (fs)
d3dpp.hDeviceWindow = d3d_device_window;
else
d3dpp.hDeviceWindow = d3d_hwnd;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = true;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferWidth = 0;
d3dpp.BackBufferHeight = 0;
if (fs) {
d3dpp.Windowed = false;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = d3d_w;
d3dpp.BackBufferHeight = d3d_h;
} else {
d3dpp.Windowed = true;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferWidth = 0;
d3dpp.BackBufferHeight = 0;
}
hr = d3ddev->Reset(&d3dpp);
hr = d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, d3d_hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &d3ddev);
if (FAILED(hr)) {
pclog("D3D: CreateDevice failed, result = 0x%08x\n", hr);
return(0);
}
if (hr == D3DERR_DEVICELOST) return;
hr = d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED,
&v_buffer,
NULL);
if (FAILED(hr)) {
pclog("D3D: CreateVertexBuffer failed, result = %08lx\n", hr);
return(0);
}
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
hr = d3ddev->CreateTexture(2048, 2048,
1,
0,
D3DFMT_X8R8G8B8,
D3DPOOL_MANAGED,
&d3dTexture, NULL);
if (FAILED(hr)) {
pclog("D3D: CreateTexture failed, result = %08lx\n", hr);
return(0);
}
r.top = r.left = 0;
r.bottom = r.right = 2047;
hr = d3dTexture->LockRect(0, &dr, &r, 0);
if (FAILED(hr)) {
pclog("D3D: LockRect failed, result = %08lx\n", hr);
return(0);
}
for (y = 0; y < 2048; y++) {
uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch));
memset(p, 0x00, 2048 * 4);
}
d3dTexture->UnlockRect(0);
d3ddev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device_force_redraw();
if (fs)
video_setblit(d3d_blit_fs);
else
video_setblit(d3d_blit);
return(1);
}
void
d3d_reset_fs(void)
{
HRESULT hr;
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = d3d_device_window;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = false;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = d3d_w;
d3dpp.BackBufferHeight = d3d_h;
hr = d3ddev->Reset(&d3dpp);
if (hr == D3DERR_DEVICELOST) return;
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device_force_redraw();
}
void
static void
d3d_resize(int x, int y)
{
if (d3ddev == NULL) return;
d3dpp.BackBufferWidth = x;
d3dpp.BackBufferHeight = y;
d3d_reset();
d3d_reset(0);
}
int
d3d_pause(void)
{
return(0);
}
void
d3d_take_screenshot(wchar_t *fn)
static void
d3d_screenshot(const wchar_t *fn)
{
LPDIRECT3DSURFACE9 d3dSurface = NULL;
@@ -663,3 +609,16 @@ d3d_take_screenshot(wchar_t *fn)
d3dSurface->Release();
d3dSurface = NULL;
}
const vidapi_t d3d_vidapi = {
"D3D",
1,
d3d_init,
d3d_close,
d3d_reset,
d3d_resize,
NULL,
d3d_screenshot,
NULL
};

View File

@@ -1,61 +0,0 @@
/*
* VARCem Virtual ARchaeological Computer EMulator.
* An emulator of (mostly) x86-based PC systems and devices,
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
* spanning the era between 1981 and 1995.
*
* This file is part of the VARCem Project.
*
* Direct3D 9 rendererer and screenshots taking.
*
* Version: @(#)win_d3d.h 1.0.3 2018/03/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <tommowalker@tommowalker.co.uk>
*
* Copyright 2017,2018 Fred N. van Kempen.
* Copyright 2016-2018 Miran Grca.
* Copyright 2008-2018 Sarah Walker.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the:
*
* Free Software Foundation, Inc.
* 59 Temple Place - Suite 330
* Boston, MA 02111-1307
* USA.
*/
#ifndef WIN_D3D_H
# define WIN_D3D_H
#ifdef __cplusplus
extern "C" {
#endif
extern int d3d_init(HWND h);
extern int d3d_init_fs(HWND h);
extern void d3d_close(void);
extern void d3d_reset(void);
extern void d3d_reset_fs(void);
extern int d3d_pause(void);
extern void d3d_resize(int x, int y);
extern void d3d_take_screenshot(wchar_t *fn);
#ifdef __cplusplus
}
#endif
#endif /*WIN_D3D_H*/

View File

@@ -8,10 +8,7 @@
*
* Rendering module for Microsoft DirectDraw 9.
*
* NOTES: This code should be re-merged into a single init() with a
* 'fullscreen' argument, indicating FS mode is requested.
*
* Version: @(#)win_ddraw.cpp 1.0.7 2018/05/06
* Version: @(#)win_ddraw.cpp 1.0.8 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -57,14 +54,13 @@
#endif
#include "../devices/video/video.h"
#include "win.h"
#include "win_ddraw.h"
static LPDIRECTDRAW lpdd = NULL;
static LPDIRECTDRAW4 lpdd4 = NULL;
static LPDIRECTDRAWSURFACE4 lpdds_pri = NULL,
lpdds_back = NULL,
lpdds_back2 = NULL;
static LPDIRECTDRAWSURFACE4 dds_pri = NULL,
dds_back = NULL,
dds_back2 = NULL;
static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL;
static DDSURFACEDESC2 ddsd;
static HWND ddraw_hwnd;
@@ -77,6 +73,92 @@ static png_infop png_info_ptr;
#endif
static const char *
GetError(HRESULT hr)
{
const char *err = "Unknown";
switch(hr) {
case DDERR_INCOMPATIBLEPRIMARY:
err = "Incompatible Primary";
break;
case DDERR_INVALIDCAPS:
err = "Invalid Caps";
break;
case DDERR_INVALIDOBJECT:
err = "Invalid Object";
break;
case DDERR_INVALIDPARAMS:
err = "Invalid Parameters";
break;
case DDERR_INVALIDPIXELFORMAT:
err = "Invalid Pixel Format";
break;
case DDERR_NOALPHAHW:
err = "Hardware does not support Alpha";
break;
case DDERR_NOCOOPERATIVELEVELSET:
err = "No cooperative level set";
break;
case DDERR_NODIRECTDRAWHW:
err = "Hardware does not support DirectDraw";
break;
case DDERR_NOEMULATION:
err = "No emulation";
break;
case DDERR_NOEXCLUSIVEMODE:
err = "No exclusive mode available";
break;
case DDERR_NOFLIPHW:
err = "Hardware does not support flipping";
break;
case DDERR_NOMIPMAPHW:
err = "Hardware does not support MipMap";
break;
case DDERR_NOOVERLAYHW:
err = "Hardware does not support overlays";
break;
case DDERR_NOZBUFFERHW:
err = "Hardware does not support Z buffers";
break;
case DDERR_OUTOFMEMORY:
err = "Out of memory";
break;
case DDERR_OUTOFVIDEOMEMORY:
err = "Out of video memory";
break;
case DDERR_PRIMARYSURFACEALREADYEXISTS:
err = "Primary Surface already exists";
break;
case DDERR_UNSUPPORTEDMODE:
err = "Mode not supported";
break;
default:
break;
}
return(err);
}
static void
CopySurface(IDirectDrawSurface4 *pDDSurface)
{
@@ -86,13 +168,13 @@ CopySurface(IDirectDrawSurface4 *pDDSurface)
pDDSurface->GetDC(&hdc);
hmemdc = CreateCompatibleDC(hdc);
ZeroMemory(&ddsd2 ,sizeof( ddsd2 )); // better to clear before using
ddsd2.dwSize = sizeof( ddsd2 ); //initialize with size
ZeroMemory(&ddsd2, sizeof(ddsd2));
ddsd2.dwSize = sizeof(ddsd2);
pDDSurface->GetSurfaceDesc(&ddsd2);
hbitmap = CreateCompatibleBitmap( hdc ,xs ,ys);
hprevbitmap = (HBITMAP) SelectObject( hmemdc, hbitmap );
BitBlt(hmemdc,0 ,0 ,xs ,ys ,hdc ,0 ,0,SRCCOPY);
SelectObject(hmemdc,hprevbitmap); // restore the old bitmap
hbitmap = CreateCompatibleBitmap(hdc, xs, ys);
hprevbitmap = (HBITMAP)SelectObject(hmemdc, hbitmap);
BitBlt(hmemdc, 0, 0, xs, ys, hdc, 0, 0, SRCCOPY);
SelectObject(hmemdc, hprevbitmap);
DeleteDC(hmemdc);
pDDSurface->ReleaseDC(hdc);
}
@@ -102,8 +184,8 @@ CopySurface(IDirectDrawSurface4 *pDDSurface)
static void
bgra_to_rgb(png_bytep *b_rgb, uint8_t *bgra, int width, int height)
{
int i, j;
uint8_t *r, *b;
int i, j;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
@@ -118,9 +200,9 @@ bgra_to_rgb(png_bytep *b_rgb, uint8_t *bgra, int width, int height)
static void
SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
SavePNG(const wchar_t *fn, HBITMAP hBitmap)
{
static WCHAR szMessage[512];
WCHAR temp[512];
BITMAPFILEHEADER bmpFileHeader;
BITMAPINFO bmpInfo;
HDC hdc;
@@ -131,31 +213,30 @@ SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
int i;
/* Create file. */
fp = plat_fopen(szFilename, (wchar_t *) L"wb");
fp = plat_fopen(fn, L"wb");
if (fp == NULL) {
pclog("[SavePNG] File %ls could not be opened for writing", szFilename);
_swprintf(szMessage, plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
pclog("[SavePNG] File %ls could not be opened for writing!\n", fn);
_swprintf(temp, plat_get_string(IDS_2088), fn);
ui_msgbox(MBX_ERROR, temp);
return;
}
/* Initialize PNG stuff. */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) {
fclose(fp);
pclog("[SavePNG] png_create_write_struct failed");
_swprintf(szMessage, plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
(void)fclose(fp);
pclog("[SavePNG] png_create_write_struct failed!\n");
_swprintf(temp, plat_get_string(IDS_2088), fn);
ui_msgbox(MBX_ERROR, temp);
return;
}
png_info_ptr = png_create_info_struct(png_ptr);
if (png_info_ptr == NULL) {
fclose(fp);
pclog("[SavePNG] png_create_info_struct failed");
_swprintf(szMessage, plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
(void)fclose(fp);
pclog("[SavePNG] png_create_info_struct failed!\n");
_swprintf(temp, plat_get_string(IDS_2088), fn);
ui_msgbox(MBX_ERROR, temp);
return;
}
@@ -172,10 +253,10 @@ SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
if ((pBuf = malloc(bmpInfo.bmiHeader.biSizeImage)) == NULL) {
fclose(fp);
pclog("[SavePNG] Unable to Allocate Bitmap Memory");
_swprintf(szMessage, plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
(void)fclose(fp);
pclog("[SavePNG] Unable to allocate bitmap memory!\n");
_swprintf(temp, plat_get_string(IDS_2088), fn);
ui_msgbox(MBX_ERROR, temp);
return;
}
@@ -183,11 +264,11 @@ SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
bmpInfo.bmiHeader.biSizeImage <<= 1;
if ((pBuf2 = malloc(bmpInfo.bmiHeader.biSizeImage)) == NULL) {
fclose(fp);
(void)fclose(fp);
free(pBuf);
pclog("[SavePNG] Unable to Allocate Secondary Bitmap Memory");
_swprintf(szMessage, plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
pclog("[SavePNG] Unable to allocate secondary bitmap memory!\n");
_swprintf(temp, plat_get_string(IDS_2088), fn);
ui_msgbox(MBX_ERROR, temp);
return;
}
@@ -211,12 +292,12 @@ SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
b_rgb = (png_bytep *)malloc(sizeof(png_bytep)*bmpInfo.bmiHeader.biHeight));
if (b_rgb == NULL) {
fclose(fp);
(void)fclose(fp);
free(pBuf);
free(pBuf2);
pclog("[SavePNG] Unable to Allocate RGB Bitmap Memory");
_swprintf(szMessage, plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
pclog("[SavePNG] Unable to allocate RGB bitmap memory!\n");
_swprintf(temp, plat_get_string(IDS_2088), fn);
ui_msgbox(MBX_ERROR, temp);
return;
}
@@ -240,10 +321,11 @@ SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
/* Clean up. */
if (hdc) ReleaseDC(NULL,hdc);
for (i = 0; i < bmpInfo.bmiHeader.biHeight; i++)
if (b_rgb[i]) free(b_rgb[i]);
if (b_rgb) free(b_rgb);
if (b_rgb) {
for (i = 0; i < bmpInfo.bmiHeader.biHeight; i++)
free(b_rgb[i]);
free(b_rgb);
}
if (pBuf) free(pBuf);
if (pBuf2) free(pBuf2);
@@ -264,9 +346,9 @@ DoubleLines(uint8_t *dst, uint8_t *src)
static void
SaveBMP(wchar_t *szFilename, HBITMAP hBitmap)
SaveBMP(const wchar_t *fn, HBITMAP hBitmap)
{
static WCHAR szMessage[512];
WCHAR temp[512];
BITMAPFILEHEADER bmpFileHeader;
BITMAPINFO bmpInfo;
HDC hdc;
@@ -298,10 +380,9 @@ SaveBMP(wchar_t *szFilename, HBITMAP hBitmap)
GetDIBits(hdc, hBitmap, 0, bmpInfo.bmiHeader.biHeight, pBuf, &bmpInfo, DIB_RGB_COLORS);
if ((fp = _wfopen(szFilename, L"wb")) == NULL) {
_swprintf(szMessage,
plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
if ((fp = _wfopen(fn, L"wb")) == NULL) {
_swprintf(temp, plat_get_string(IDS_2088), fn);
ui_msgbox(MBX_ERROR, temp);
break;
}
@@ -311,21 +392,24 @@ SaveBMP(wchar_t *szFilename, HBITMAP hBitmap)
bmpInfo.bmiHeader.biSizeImage <<= 1;
bmpInfo.bmiHeader.biHeight <<= 1;
}
bmpFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+bmpInfo.bmiHeader.biSizeImage;
bmpFileHeader.bfType=0x4D42;
bmpFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
bmpFileHeader.bfSize = sizeof(BITMAPFILEHEADER) +
sizeof(BITMAPINFOHEADER) +
bmpInfo.bmiHeader.biSizeImage;
bmpFileHeader.bfType = 0x4D42;
bmpFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) +
sizeof(BITMAPINFOHEADER);
(void)fwrite(&bmpFileHeader,sizeof(BITMAPFILEHEADER),1,fp);
(void)fwrite(&bmpInfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp);
(void)fwrite(&bmpFileHeader, sizeof(BITMAPFILEHEADER), 1, fp);
(void)fwrite(&bmpInfo.bmiHeader, sizeof(BITMAPINFOHEADER), 1, fp);
if (pBuf2) {
DoubleLines((uint8_t *) pBuf2, (uint8_t *) pBuf);
(void)fwrite(pBuf2,bmpInfo.bmiHeader.biSizeImage,1,fp);
DoubleLines((uint8_t *)pBuf2, (uint8_t *)pBuf);
(void)fwrite(pBuf2, bmpInfo.bmiHeader.biSizeImage, 1, fp);
} else {
(void)fwrite(pBuf,bmpInfo.bmiHeader.biSizeImage,1,fp);
(void)fwrite(pBuf, bmpInfo.bmiHeader.biSizeImage, 1, fp);
}
} while(false);
if (hdc) ReleaseDC(NULL,hdc);
if (hdc) ReleaseDC(NULL, hdc);
if (pBuf2) free(pBuf2);
@@ -339,10 +423,10 @@ SaveBMP(wchar_t *szFilename, HBITMAP hBitmap)
static void
ddraw_fs_size_default(RECT w_rect, RECT *r_dest)
{
r_dest->left = 0;
r_dest->top = 0;
r_dest->right = (w_rect.right - w_rect.left) - 1;
r_dest->bottom = (w_rect.bottom - w_rect.top) - 1;
r_dest->left = 0;
r_dest->top = 0;
r_dest->right = (w_rect.right - w_rect.left) - 1;
r_dest->bottom = (w_rect.bottom - w_rect.top) - 1;
}
@@ -434,14 +518,13 @@ ddraw_fs_size(RECT w_rect, RECT *r_dest, int w, int h)
static void
ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
{
RECT r_src;
RECT r_dest;
RECT r_src, r_dest;
RECT w_rect;
int yy;
HRESULT hr;
DDBLTFX ddbltfx;
HRESULT hr;
int yy;
if (lpdds_back == NULL) {
if (dds_back == NULL) {
video_blit_complete();
return; /*Nothing to do*/
}
@@ -454,11 +537,11 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
hr = lpdds_back->Lock(NULL, &ddsd,
hr = dds_back->Lock(NULL, &ddsd,
DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr == DDERR_SURFACELOST) {
lpdds_back->Restore();
lpdds_back->Lock(NULL, &ddsd,
dds_back->Restore();
dds_back->Lock(NULL, &ddsd,
DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
device_force_redraw();
}
@@ -470,7 +553,7 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
for (yy = y1; yy < y2; yy++)
if (buffer32) memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
video_blit_complete();
lpdds_back->Unlock(NULL);
dds_back->Unlock(NULL);
w_rect.left = 0;
w_rect.top = 0;
@@ -486,19 +569,19 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
ddbltfx.dwSize = sizeof(ddbltfx);
ddbltfx.dwFillColor = 0;
lpdds_back2->Blt(&w_rect, NULL, NULL,
dds_back2->Blt(&w_rect, NULL, NULL,
DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
hr = lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
hr = dds_back2->Blt(&r_dest, dds_back, &r_src, DDBLT_WAIT, NULL);
if (hr == DDERR_SURFACELOST) {
lpdds_back2->Restore();
lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
dds_back2->Restore();
dds_back2->Blt(&r_dest, dds_back, &r_src, DDBLT_WAIT, NULL);
}
hr = lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC);
hr = dds_pri->Flip(NULL, DDFLIP_NOVSYNC);
if (hr == DDERR_SURFACELOST) {
lpdds_pri->Restore();
lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC);
dds_pri->Restore();
dds_pri->Flip(NULL, DDFLIP_NOVSYNC);
}
}
@@ -506,13 +589,12 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
static void
ddraw_blit(int x, int y, int y1, int y2, int w, int h)
{
RECT r_src;
RECT r_dest;
RECT r_src, r_dest;
POINT po;
HRESULT hr;
int yy;
if (lpdds_back == NULL) {
if (dds_back == NULL) {
video_blit_complete();
return; /*Nothing to do*/
}
@@ -525,11 +607,11 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
hr = lpdds_back->Lock(NULL, &ddsd,
hr = dds_back->Lock(NULL, &ddsd,
DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr == DDERR_SURFACELOST) {
lpdds_back->Restore();
lpdds_back->Lock(NULL, &ddsd,
dds_back->Restore();
dds_back->Lock(NULL, &ddsd,
DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
device_force_redraw();
}
@@ -545,7 +627,7 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
}
video_blit_complete();
lpdds_back->Unlock(NULL);
dds_back->Unlock(NULL);
po.x = po.y = 0;
@@ -558,24 +640,204 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
r_src.right = w;
r_src.bottom = h;
hr = lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
hr = dds_back2->Blt(&r_src, dds_back, &r_src, DDBLT_WAIT, NULL);
if (hr == DDERR_SURFACELOST) {
lpdds_back2->Restore();
lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
dds_back2->Restore();
dds_back2->Blt(&r_src, dds_back, &r_src, DDBLT_WAIT, NULL);
}
lpdds_back2->Unlock(NULL);
dds_back2->Unlock(NULL);
hr = lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
hr = dds_pri->Blt(&r_dest, dds_back2, &r_src, DDBLT_WAIT, NULL);
if (hr == DDERR_SURFACELOST) {
lpdds_pri->Restore();
lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
dds_pri->Restore();
dds_pri->Blt(&r_dest, dds_back2, &r_src, DDBLT_WAIT, NULL);
}
}
void
ddraw_take_screenshot(wchar_t *fn)
static void
ddraw_close(void)
{
pclog("DDRAW: close (fs=%d)\n", (dds_back2 != NULL)?1:0);
video_setblit(NULL);
if (dds_back2 != NULL) {
dds_back2->Release();
dds_back2 = NULL;
}
if (dds_back != NULL) {
dds_back->Release();
dds_back = NULL;
}
if (dds_pri != NULL) {
dds_pri->Release();
dds_pri = NULL;
}
if (lpdd_clipper != NULL) {
lpdd_clipper->Release();
lpdd_clipper = NULL;
}
if (lpdd4 != NULL) {
lpdd4->Release();
lpdd4 = NULL;
}
}
static int
ddraw_init(int fs)
{
HRESULT hr;
HWND h;
DWORD dw;
pclog("DDRAW: init (fs=%d)\n", fs);
cgapal_rebuild();
hr = DirectDrawCreate(NULL, &lpdd, NULL);
if (FAILED(hr)) {
pclog("DDRAW: cannot create an instance (%s)\n", GetError(hr));
return(0);
}
hr = lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4);
if (FAILED(hr)) {
pclog("DDRAW: no interfaces found (%s)\n", GetError(hr));
return(0);
}
lpdd->Release();
lpdd = NULL;
atexit(ddraw_close);
if (fs) {
dw = DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW | \
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT;
h = hwndMain;
} else {
dw = DDSCL_NORMAL;
h = hwndRender;
}
hr = lpdd4->SetCooperativeLevel(h, dw);
if (FAILED(hr)) {
pclog("DDRAW: SetCooperativeLevel failed (%s)\n", GetError(hr));
return(0);
}
if (fs) {
ddraw_w = GetSystemMetrics(SM_CXSCREEN);
ddraw_h = GetSystemMetrics(SM_CYSCREEN);
hr = lpdd4->SetDisplayMode(ddraw_w, ddraw_h, 32, 0, 0);
if (FAILED(hr)) {
pclog("DDRAW: SetDisplayMode failed (%s)\n", GetError(hr));
return(0);
}
}
memset(&ddsd, 0x00, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (fs) {
ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps |= (DDSCAPS_COMPLEX | DDSCAPS_FLIP);
ddsd.dwBackBufferCount = 1;
}
hr = lpdd4->CreateSurface(&ddsd, &dds_pri, NULL);
if (FAILED(hr)) {
pclog("DDRAW: CreateSurface failed (%s)\n", GetError(hr));
return(0);
}
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
hr = lpdd4->CreateSurface(&ddsd, &dds_back, NULL);
if (FAILED(hr)) {
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
hr = lpdd4->CreateSurface(&ddsd, &dds_back, NULL);
if (FAILED(hr)) {
pclog("DDRAW: CreateSurface back failed (%s)\n", GetError(hr));
return(0);
}
}
if (fs) {
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
hr = dds_pri->GetAttachedSurface(&ddsd.ddsCaps, &dds_back2);
if (FAILED(hr)) {
pclog("DDRAW: GetAttachedSurface failed (%s)\n", GetError(hr));
return(0);
}
}
memset(&ddsd, 0x00, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (fs)
hr = lpdd4->CreateSurface(&ddsd, &dds_back, NULL);
else
hr = lpdd4->CreateSurface(&ddsd, &dds_back2, NULL);
if (FAILED(hr)) {
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (fs)
hr = lpdd4->CreateSurface(&ddsd, &dds_back, NULL);
else
hr = lpdd4->CreateSurface(&ddsd, &dds_back2, NULL);
if (FAILED(hr)) {
pclog("DDRAW: CreateSurface(back) failed (%s)\n", GetError(hr));
return(0);
}
}
if (! fs) {
hr = lpdd4->CreateClipper(0, &lpdd_clipper, NULL);
if (FAILED(hr)) {
pclog("DDRAW: CreateClipper failed (%s)\n", GetError(hr));
return(0);
}
hr = lpdd_clipper->SetHWnd(0, h);
if (FAILED(hr)) {
pclog("DDRAW: SetHWnd failed (%s)\n", GetError(hr));
return(0);
}
hr = dds_pri->SetClipper(lpdd_clipper);
if (FAILED(hr)) {
pclog("DDRAW: SetClipper failed (%s)\n", GetError(hr));
return(0);
}
}
ddraw_hwnd = hwndRender;
if (fs)
video_setblit(ddraw_blit_fs);
else
video_setblit(ddraw_blit);
return(1);
}
static void
ddraw_screenshot(const wchar_t *fn)
{
#if 0
xs = xsize;
@@ -604,7 +866,7 @@ ddraw_take_screenshot(wchar_t *fn)
ys2 >>= 1;
}
CopySurface(lpdds_back2);
CopySurface(dds_back2);
#ifdef USE_LIBPNG
SavePNG(fn, hbitmap);
@@ -614,160 +876,14 @@ ddraw_take_screenshot(wchar_t *fn)
}
int
ddraw_init(HWND h)
{
cgapal_rebuild();
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL))) return(0);
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4)))
return(0);
lpdd->Release();
lpdd = NULL;
atexit(ddraw_close);
if (FAILED(lpdd4->SetCooperativeLevel(h, DDSCL_NORMAL))) return(0);
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_pri, NULL))) return(0);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL))) {
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL)))
fatal("CreateSurface back failed\n");
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back2, NULL))) {
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back2, NULL)))
fatal("CreateSurface back failed\n");
}
if (FAILED(lpdd4->CreateClipper(0, &lpdd_clipper, NULL))) return(0);
if (FAILED(lpdd_clipper->SetHWnd(0, h))) return(0);
if (FAILED(lpdds_pri->SetClipper(lpdd_clipper))) return(0);
ddraw_hwnd = h;
video_setblit(ddraw_blit);
return(1);
}
int
ddraw_init_fs(HWND h)
{
ddraw_w = GetSystemMetrics(SM_CXSCREEN);
ddraw_h = GetSystemMetrics(SM_CYSCREEN);
cgapal_rebuild();
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL))) return 0;
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4))) return 0;
lpdd->Release();
lpdd = NULL;
atexit(ddraw_close);
if (FAILED(lpdd4->SetCooperativeLevel(h,
DDSCL_SETFOCUSWINDOW | \
DDSCL_CREATEDEVICEWINDOW | \
DDSCL_EXCLUSIVE | \
DDSCL_FULLSCREEN | \
DDSCL_ALLOWREBOOT))) return 0;
if (FAILED(lpdd4->SetDisplayMode(ddraw_w, ddraw_h, 32, 0 ,0))) return 0;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount = 1;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_pri, NULL))) return 0;
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpdds_pri->GetAttachedSurface(&ddsd.ddsCaps, &lpdds_back2))) return 0;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL))) {
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL))) return 0;
}
ddraw_hwnd = h;
video_setblit(ddraw_blit_fs);
return(1);
}
void
ddraw_close(void)
{
video_setblit(NULL);
if (lpdds_back2) {
lpdds_back2->Release();
lpdds_back2 = NULL;
}
if (lpdds_back) {
lpdds_back->Release();
lpdds_back = NULL;
}
if (lpdds_pri) {
lpdds_pri->Release();
lpdds_pri = NULL;
}
if (lpdd_clipper) {
lpdd_clipper->Release();
lpdd_clipper = NULL;
}
if (lpdd4) {
lpdd4->Release();
lpdd4 = NULL;
}
}
int
ddraw_pause(void)
{
return(0);
}
const vidapi_t ddraw_vidapi = {
"DDraw",
1,
ddraw_init,
ddraw_close,
NULL,
NULL,
NULL,
ddraw_screenshot,
NULL
};

View File

@@ -1,58 +0,0 @@
/*
* VARCem Virtual ARchaeological Computer EMulator.
* An emulator of (mostly) x86-based PC systems and devices,
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
* spanning the era between 1981 and 1995.
*
* This file is part of the VARCem Project.
*
* Definitions for the DirectDraw 9 rendering module.
*
* Version: @(#)win_ddraw.h 1.0.3 2018/03/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <tommowalker@tommowalker.co.uk>
*
* Copyright 2017,2018 Fred N. van Kempen.
* Copyright 2016-2018 Miran Grca.
* Copyright 2008-2018 Sarah Walker.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the:
*
* Free Software Foundation, Inc.
* 59 Temple Place - Suite 330
* Boston, MA 02111-1307
* USA.
*/
#ifndef WIN_DDRAW_H
# define WIN_DDRAW_H
#ifdef __cplusplus
extern "C" {
#endif
extern int ddraw_init(HWND h);
extern int ddraw_init_fs(HWND h);
extern void ddraw_close(void);
extern int ddraw_pause(void);
extern void ddraw_take_screenshot(wchar_t *fn);
#ifdef __cplusplus
}
#endif
#endif /*WIN_DDRAW_H*/

View File

@@ -8,7 +8,7 @@
*
* Try to load a support DLL.
*
* Version: @(#)win_dynld.c 1.0.4 2018/03/28
* Version: @(#)win_dynld.c 1.0.5 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -68,6 +68,12 @@ dynld_module(const char *name, const dllimp_t *table)
return(NULL);
}
/* If no table was given, we just detect library presence. */
if (table == NULL) {
CloseHandle(h);
return((void *)h);
}
/* Now load the desired function pointers. */
for (imp=table; imp->name!=NULL; imp++) {
func = GetProcAddress(h, imp->name);

View File

@@ -10,7 +10,7 @@
*
* Based on old original code @(#)dir_win32.c 1.2.0 2007/04/19
*
* Version: @(#)win_opendir.c 1.0.3 2018/05/06
* Version: @(#)win_opendir.c 1.0.5 2018/05/07
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*

View File

@@ -8,7 +8,7 @@
*
* Implement the user Interface module.
*
* Version: @(#)win_ui.c 1.0.20 2018/05/06
* Version: @(#)win_ui.c 1.0.21 2018/05/07
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -57,7 +57,6 @@
#include "../devices/input/mouse.h"
#include "../devices/video/video.h"
#include "win.h"
#include "win_d3d.h"
#ifndef GWL_WNDPROC
@@ -406,7 +405,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
MoveWindow(hwndSBAR, 0, scrnsz_y, scrnsz_x, cruft_sb, TRUE);
/* Update the renderer if needed. */
plat_vidsize(scrnsz_x, scrnsz_y);
plat_vidapi_resize(scrnsz_x, scrnsz_y);
/* Re-clip the mouse area if needed. */
if (mouse_capture) {
@@ -454,10 +453,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_RESETD3D:
startblit();
if (vid_fullscreen)
d3d_reset_fs();
else
d3d_reset();
plat_vidapi_reset();
endblit();
break;
@@ -657,9 +653,28 @@ ui_init(int nCmdShow)
}
/* Initialize the configured Video API. */
if (! plat_setvid(vid_api)) {
ui_msgbox(MBX_CONFIG, (wchar_t *)IDS_2095);
return(5);
again:
if (! plat_vidapi_set(vid_api)) {
/*
* Selected renderer is not available.
*
* This can happen if one of the optional renderers
* was selected previously, but is currently not
* available for whatever reason.
*
* Inform the user, and ask if they want to reset
* to the system default one instead.
*/
_swprintf(title, plat_get_string(IDS_2095),
plat_vidapi_internal_name(vid_api));
if (ui_msgbox(MBX_CONFIG, title) != 0) {
/* Nope, they don't, so just exit. */
return(5);
}
/* OK, reset to the default one and retry. */
vid_api = plat_vidapi_from_internal_name("default");
goto again;
}
/* Initialize the rendering window, or fullscreen. */
@@ -749,6 +764,24 @@ ui_init(int nCmdShow)
}
/* Tell the UI about a new screen resolution. */
void
ui_resize(int x, int y)
{
RECT r;
/* First, see if we should resize the UI window. */
if (vid_resize) return;
video_wait_for_blit();
/* Re-position and re-size the main window. */
GetWindowRect(hwndMain, &r);
MoveWindow(hwndMain, r.left, r.top,
x+cruft_x, y+cruft_y+cruft_sb, TRUE);
}
/*
* Re-load and reset all menus.
*
@@ -845,7 +878,7 @@ plat_pause(int p)
/* If un-pausing, as the renderer if that's OK. */
if (p == 0)
p = get_vidpause();
p = plat_vidapi_pause();
/* If already so, done. */
if (dopause == p) return;
@@ -866,24 +899,6 @@ plat_pause(int p)
}
/* Tell the UI about a new screen resolution. */
void
plat_resize(int x, int y)
{
RECT r;
/* First, see if we should resize the UI window. */
if (vid_resize) return;
video_wait_for_blit();
/* Re-position and re-size the main window. */
GetWindowRect(hwndMain, &r);
MoveWindow(hwndMain, r.left, r.top,
x+cruft_x, y+cruft_y+cruft_sb, TRUE);
}
void
plat_mouse_capture(int on)
{