Another cleanup. VNC now has fixed blitters, so 8bit cards (vga,mda,herc et al) work. More cleanups with the %ls stuff, cleanup of threads modules, and MOVED THE MAKEFILE to win/.

This commit is contained in:
waltje
2017-10-14 20:04:21 -04:00
parent 25b4014ce0
commit c1abfe2362
18 changed files with 169 additions and 167 deletions

View File

@@ -8,7 +8,7 @@
*
* Windows resource script.
*
* Version: @(#)86Box.rc 1.0.16 2017/10/12
* Version: @(#)86Box.rc 1.0.17 2017/10/14
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -823,7 +823,7 @@ BEGIN
IDS_2155 "IRQ %i"
IDS_2156 "%" PRIu64
IDS_2157 "%" PRIu64 " MB (CHS: %" PRIu64 ", %" PRIu64 ", %" PRIu64 ")"
IDS_2158 "Floppy %i (%s): %S"
IDS_2158 "Floppy %i (%s): %ls"
IDS_2159"All floppy images (*.0??;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.JSON;*.TD0;*.VFD;*.XDF)\0*.0??;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.JSON;*.TD0;*.VFD;*.XDF\0Advanced sector-based images (*.IMD;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector-based images (*.0??;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMG;*.JSON;*.VFD;*.XDF)\0*.0??;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMG;*.JSON;*.VFD;*.XDF\0Flux images (*.FDI)\0*.FDI\0Surface-based images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"
IDS_2160 "Configuration files (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0"
IDS_2161 "&New image..."
@@ -869,7 +869,7 @@ BEGIN
IDS_4112 "Please enter a valid file name"
IDS_4113 "Remember to partition and format the new drive"
IDS_4114 "MFM/RLL or ESDI CD-ROM drives never existed"
IDS_4115 "Removable disk %i (SCSI): %S"
IDS_4115 "Removable disk %i (SCSI): %ls"
IDS_4352 "MFM/RLL"
IDS_4353 "XT IDE"

526
src/win/Makefile.mingw Normal file
View File

@@ -0,0 +1,526 @@
#
# 86Box A hypervisor and IBM PC system emulator that specializes in
# running old operating systems and software designed for IBM
# PC systems and compatibles from 1981 through fairly recent
# system designs based on the PCI bus.
#
# This file is part of the 86Box distribution.
#
# Makefile for Win32 (MinGW32) environment.
#
# Version: @(#)Makefile.mingw 1.0.62 2017/10/14
#
# Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
#
# Name of the executable.
ifndef PROG
PROG := 86Box
endif
# Various compile-time options.
# -DROM_TRACE=0xc800 traces ROM access from segment C800
# -DIO_TRACE=0x66 traces I/O on port 0x66
STUFF :=
# Add feature selections here.
# -DANSI_CFG forces the config file to ANSI encoding.
# -DENABLE_VRAM_DUMP enables Video Ram dumping.
# -DENABLE_LOG_BREAKPOINT enables extra logging.
# -DENABLE_SCSI_BIOS_COMMAND_LOG=n enables extra logging.
# -DENABLE_AHA154X_LOG=n enables extra logging.
# -DENABLE_BUSLOGIC_LOG=n enables extra logging.
# -DENABLE_CDROM_LOG enables extra logging.
# -DENABLE_D86F_LOG enables extra logging.
# -DENABLE_FDC_LOG enables extra logging.
# -DENABLE_HDD_IMAGE_LOG enables extra logging.
# -DENABLE_IDE_LOG enables extra logging.
# -DENABLE_SERIAL_LOG enables extra logging.
# -DENABLE_NIC_LOG enables extra logging.
# -DENABLE_KEYBOARD_LOG enables extra logging.
ifndef EXTRAS
EXTRAS :=
endif
# Defaults for several build options (possibly defined in a chained file.)
ifndef AUTODEP
AUTODEP := n
endif
ifndef DEBUG
DEBUG := n
endif
ifndef OPTIM
OPTIM := n
endif
ifndef RELEASE
RELEASE := n
endif
ifndef USB
USB := n
endif
ifndef VNC
VNC := n
endif
ifndef RDP
RDP := n
endif
ifndef DEV_BUILD
DEV_BUILD := n
endif
ifndef DEV_BRANCH
DEV_BRANCH := n
endif
ifndef CIRRUS
CIRRUS := n
endif
ifndef NE1000
NE1000 := n
endif
ifndef NV_RIVA
NV_RIVA := n
endif
ifndef FLUIDSYNTH
FLUIDSYNTH := y
endif
ifndef MUNT
MUNT := y
endif
ifndef PAS16
PAS16 = n
endif
ifndef X64
X64 := n
endif
ifeq ($(DEV_BUILD), y)
DEV_BRANCH := y
CIRRUS := y
NE1000 := y
NV_RIVA := y
PAS16 := y
VNC := y
endif
#########################################################################
# Nothing should need changing from here on.. #
#########################################################################
VPATH := $(EXPATH) . cpu \
cdrom disk floppy game machine \
sound \
sound/munt sound/munt/c_interface sound/munt/sha1 \
sound/munt/srchelper \
sound/resid-fp \
scsi video lzf network network/slirp win
ifeq ($(X64), y)
CPP := g++ -m64
CC := gcc -m64
else
CPP := g++ -m32
CC := gcc -m32
endif
WINDRES := windres
DEPS = -MMD -MF $*.d -c $<
DEPFILE := win/.depends
# Set up the correct toolchain flags.
OPTS := -DWIN32 $(EXTRAS) $(STUFF)
ifdef EXFLAGS
OPTS += $(EXFLAGS)
endif
ifdef EXINC
OPTS += -I$(EXINC)
endif
ifeq ($(X64), y)
ifeq ($(OPTIM), y)
DFLAGS := -march=native
else
DFLAGS :=
endif
else
ifeq ($(OPTIM), y)
DFLAGS := -march=native
else
DFLAGS := -march=i686
endif
endif
ifeq ($(DEBUG), y)
DFLAGS += -ggdb -DDEBUG
AOPTIM :=
ifndef COPTIM
COPTIM := -Og
endif
else
ifeq ($(OPTIM), y)
AOPTIM := -mtune=native
ifndef COPTIM
COPTIM := -O6
endif
else
ifndef COPTIM
COPTIM := -O3
endif
endif
endif
AFLAGS := -msse -msse2 -mfpmath=sse
CFLAGS := $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) $(AFLAGS) \
-fomit-frame-pointer -mstackrealign -Wall
RFLAGS := --input-format=rc -O coff
ifeq ($(RELEASE), y)
CFLAGS += -DRELEASE_BUILD
RFLAGS += -DRELEASE_BUILD
endif
ifeq ($(VRAMDUMP), y)
CFLAGS += -DENABLE_VRAM_DUMP
RFLAGS += -DENABLE_VRAM_DUMP
endif
ifeq ($(X64), y)
PLATCG := codegen_x86-64.o
CGOPS := codegen_ops_x86-64.h
VCG := vid_voodoo_codegen_x86-64.h
else
PLATCG := codegen_x86.o
CGOPS := codegen_ops_x86.h
VCG := vid_voodoo_codegen_x86.h
endif
# Optional modules.
ifeq ($(FLUIDSYNTH), y)
CFLAGS += -DUSE_FLUIDSYNTH
FSYNTHOBJ := midi_fluidsynth.o
endif
ifeq ($(MUNT), y)
CFLAGS += -DUSE_MUNT
MUNTOBJ := midi_mt32.o \
Analog.o BReverbModel.o File.o FileStream.o LA32Ramp.o \
LA32FloatWaveGenerator.o LA32WaveGenerator.o \
MidiStreamParser.o Part.o Partial.o PartialManager.o \
Poly.o ROMInfo.o SampleRateConverter_dummy.o Synth.o \
Tables.o TVA.o TVF.o TVP.o sha1.o c_interface.o
endif
ifeq ($(VNC), y)
CFLAGS += -DUSE_VNC
RFLAGS += -DUSE_VNC
ifneq ($(VNC_PATH), )
CFLAGS += -I$(VNC_PATH)\INCLUDE
VNCLIB := -L$(VNC_PATH)\LIB
endif
VNCLIB += -lvncserver
VNCOBJ := win_vnc.o
endif
ifeq ($(RDP), y)
CFLAGS += -DUSE_RDP
RFLAGS += -DUSE_RDP
ifneq ($(RDP_PATH), )
CFLAGS += -I$(RDP_PATH)\INCLUDE
RDPLIB := -L$(RDP_PATH)\LIB
endif
RDPLIB += -lrdp
RDPOBJ := win_rdp.o
endif
# Options for the DEV branch.
ifeq ($(DEV_BRANCH), y)
CFLAGS += -DDEV_BRANCH
DEVBROBJ :=
ifeq ($(CIRRUS), y)
CFLAGS += -DUSE_CIRRUS
DEVBROBJ += vid_cl_gd.o vid_cl_gd_blit.o vid_cl_ramdac.o
endif
ifeq ($(NE1000), y)
CFLAGS += -DUSE_NE1000
endif
ifeq ($(NV_RIVA), y)
CFLAGS += -DUSE_RIVA
DEVBROBJ += vid_nv_riva128.o
endif
ifeq ($(PAS16), y)
CFLAGS += -DUSE_PAS16
DEVBROBJ += snd_pas16.o
endif
endif
# Options for works-in-progress.
ifndef SERIAL
SERIAL := serial.o
endif
ifndef EUROPC
EUROPC := machine_europc.o
endif
MAINOBJ := pc.o config.o random.o timer.o io.o dma.o nmi.o pic.o \
pit.o ppi.o pci.o mca.o mcr.o mem.o memregs.o rom.o \
device.o nvr.o nvr_at.o nvr_ps2.o \
intel.o intel_flash.o intel_sio.o
CPUOBJ := cpu.o 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o \
codegen.o \
codegen_ops.o \
codegen_timing_common.o codegen_timing_486.o \
codegen_timing_686.o codegen_timing_pentium.o \
codegen_timing_winchip.o $(PLATCG) \
x86seg.o x87.o
MCHOBJ := machine.o \
machine_common.o \
machine_amstrad.o $(EUROPC) \
machine_olivetti_m24.o \
machine_pcjr.o \
machine_tandy.o \
machine_xt.o machine_xt_laserxt.o \
machine_at.o \
machine_at_ali1429.o machine_at_commodore.o \
machine_at_neat.o machine_at_headland.o \
machine_at_opti495.o machine_at_scat.o \
machine_at_wd76c10.o \
machine_at_sis_85c471.o machine_at_sis_85c496.o \
machine_at_430lx_nx.o machine_at_430fx.o \
machine_at_430hx.o machine_at_430vx.o \
machine_at_440fx.o \
machine_ps1.o \
machine_ps2_isa.o machine_ps2_mca.o
DEVOBJ := bugger.o lpt.o $(SERIAL) \
tandy_eeprom.o tandy_rom.o \
sio_detect.o \
sio_fdc37c665.o sio_fdc37c669.o sio_fdc37c932fr.o \
sio_pc87306.o sio_w83877f.o sio_um8669f.o piix.o \
keyboard.o \
keyboard_xt.o keyboard_at.o keyboard_pcjr.o \
keyboard_amstrad.o keyboard_olim24.o \
gameport.o \
joystick_standard.o joystick_ch_flightstick_pro.o \
joystick_sw_pad.o joystick_tm_fcs.o \
mouse.o \
mouse_serial.o mouse_ps2.o mouse_bus.o
FDDOBJ := fdd.o fdc.o fdi2raw.o \
floppy.o floppy_common.o floppy_86f.o \
floppy_fdi.o floppy_imd.o floppy_img.o floppy_json.o \
floppy_td0.o
HDDOBJ := hdd.o \
hdd_image.o hdd_table.o \
hdc.o \
hdc_esdi_at.o hdc_esdi_mca.o hdc_ide.o hdc_mfm_at.o \
hdc_mfm_xt.o hdc_xtide.o
CDROMOBJ := cdrom.o \
cdrom_dosbox.o cdrom_image.o cdrom_null.o
ifeq ($(USB), y)
USBOBJ := usb.o
endif
SCSIOBJ := scsi.o \
scsi_bus.o scsi_device.o \
scsi_disk.o \
scsi_x54x.o \
scsi_buslogic.o scsi_aha154x.o \
scsi_ncr5380.o
NETOBJ := network.o \
net_pcap.o \
net_slirp.o \
bootp.o ip_icmp.o misc.o socket.o tcp_timer.o cksum.o \
ip_input.o queue.o tcp_input.o debug.o ip_output.o \
sbuf.o tcp_output.o udp.o if.o mbuf.o slirp.o tcp_subr.o \
net_ne2000.o
SNDOBJ := sound.o \
openal.o \
dbopl.o nukedopl.o \
snd_resid.o \
convolve.o convolve-sse.o envelope.o extfilt.o \
filter.o pot.o sid.o voice.o wave6581__ST.o \
wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \
wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \
wave8580_PST.o wave.o \
midi.o $(FSYNTHOBJ) $(MUNTOBJ) \
midi_system.o \
snd_speaker.o \
snd_ps1.o snd_pssj.o \
snd_lpt_dac.o snd_lpt_dss.o \
snd_adlib.o snd_adlibgold.o snd_ad1848.o snd_audiopci.o \
snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \
snd_emu8k.o snd_gus.o snd_opl.o \
snd_mpu401.o \
snd_sn76489.o snd_ssi2001.o snd_wss.o \
snd_ym7128.o
VIDOBJ := video.o \
vid_table.o \
vid_cga.o vid_cga_comp.o vid_mda.o \
vid_ega.o vid_ega_render.o \
vid_vga.o vid_svga.o vid_svga_render.o \
vid_hercules.o vid_herculesplus.o vid_incolor.o \
vid_colorplus.o \
vid_genius.o \
vid_s3.o vid_s3_virge.o \
vid_et4000.o vid_et4000w32.o vid_icd2061.o \
vid_oti067.o \
vid_paradise.o \
vid_tvga.o vid_tgui9440.o vid_tkd8001_ramdac.o \
vid_ati_eeprom.o vid_ati18800.o vid_ati28800.o \
vid_ati68860_ramdac.o vid_ati_mach64.o \
vid_ics2595.o \
vid_sc1502x_ramdac.o \
vid_sdac_ramdac.o \
vid_stg_ramdac.o \
vid_wy700.o \
vid_voodoo.o \
vid_pcjr.o \
vid_ps1_svga.o \
vid_olivetti_m24.o \
vid_pc1512.o vid_pc1640.o \
vid_pc200.o \
vid_tandy.o vid_tandysl.o
PLATOBJ := win.o \
win_ddraw.o win_ddraw_fs.o win_d3d.o win_d3d_fs.o \
$(VNCOBJ) $(RDPOBJ) \
win_dynld.o win_thread.o $(WSERIAL) win_cdrom.o win_cdrom_ioctl.o \
win_keyboard.o win_mouse.o win_joystick.o win_midi.o \
win_dialog.o win_about.o win_status.o win_stbar.o \
win_settings.o win_deviceconfig.o win_joystickconfig.o \
$(OPENDIR)
OBJ := $(MAINOBJ) $(CPUOBJ) $(MCHOBJ) $(DEVOBJ) \
$(FDDOBJ) $(CDROMOBJ) $(HDDOBJ) \
$(USBOBJ) $(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \
$(PLATOBJ) $(DEVBROBJ)
ifdef EXOBJ
OBJ += $(EXOBJ)
endif
LZFOBJ := lzf_c.o lzf_d.o
LIBS := -mwindows \
-lopenal.dll \
-lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \
-lcomctl32 -lwinmm
ifeq ($(VNC), y)
LIBS += $(VNCLIB) -lws2_32 -lz
endif
ifeq ($(RDP), y)
LIBS += $(RDPLIB)
endif
LIBS += -lkernel32 -lwsock32 -liphlpapi -lpsapi
LIBS += -lpthread -static -lstdc++ -lgcc
LIBS += -Wl,--large-address-aware
# Build module rules.
ifeq ($(AUTODEP), y)
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $(DEPS) -c $<
%.o: %.cc
@echo $<
@$(CPP) $(CFLAGS) $(DEPS) -c $<
%.o: %.cpp
@echo $<
@$(CPP) $(CFLAGS) $(DEPS) -c $<
else
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) -c $<
%.o: %.cc
@echo $<
@$(CPP) $(CFLAGS) -c $<
%.o: %.cpp
@echo $<
@$(CPP) $(CFLAGS) -c $<
%.d: %.c $(wildcard $*.d)
@echo $<
@$(CC) $(CFLAGS) $(DEPS) -E $< >NUL
%.d: %.cc $(wildcard $*.d)
@echo $<
@$(CPP) $(CFLAGS) $(DEPS) -E $< >NUL
%.d: %.cpp $(wildcard $*.d)
@echo $<
@$(CPP) $(CFLAGS) $(DEPS) -E $< >NUL
endif
all: $(PROG).exe pcap_if.exe
86Box.res: 86Box.rc
@echo Processing $<
@$(WINDRES) $(RFLAGS) $(EXTRAS) -i $< -o 86Box.res
$(PROG).exe: $(OBJ) $(LZFOBJ) 86Box.res
@echo Linking $(PROG).exe ..
@$(CC) -o $(PROG).exe $(OBJ) $(LZFOBJ) 86Box.res $(LIBS)
ifneq ($(DEBUG), y)
@strip $(PROG).exe
endif
pcap_if.res: pcap_if.rc
@echo Processing $<
@$(WINDRES) $(RFLAGS) -i $< -o pcap_if.res
pcap_if.exe: pcap_if.o win_dynld.o pcap_if.res
@echo Linking pcap_if.exe ..
@$(CC) -o pcap_if.exe pcap_if.o win_dynld.o pcap_if.res
ifneq ($(DEBUG), y)
@strip pcap_if.exe
endif
clean:
@echo Cleaning objects..
@-rm -f *.o 2>NUL
@-rm -f *.res 2>NUL
clobber: clean
@echo Cleaning executables..
@-rm -f *.d 2>NUL
@-rm -f *.exe 2>NUL
# @-rm -f $(DEPFILE) 2>NUL
ifneq ($(AUTODEP), y)
depclean:
@-rm -f $(DEPFILE) 2>NUL
@echo Creating dependencies..
@echo # Run "make depends" to re-create this file. $(DEPFILE)
depends: DEPOBJ=$(OBJ:%.o=%.d)
depends: depclean $(OBJ:%.o=%.d)
@-cat $(DEPOBJ) >>$(DEPFILE)
@-rm -f $(DEPOBJ)
$(DEPFILE):
endif
# Module dependencies.
ifeq ($(AUTODEP), y)
#-include $(OBJ:%.o=%.d) (better, but sloooowwwww)
-include *.d
else
include $(wildcard $(DEPFILE))
endif
# End of Makefile.mingw.

33
src/win/Makefile.mingw64 Normal file
View File

@@ -0,0 +1,33 @@
#
# 86Box A hypervisor and IBM PC system emulator that specializes in
# running old operating systems and software designed for IBM
# PC systems and compatibles from 1981 through fairly recent
# system designs based on the PCI bus.
#
# This file is part of the 86Box distribution.
#
# Modified Makefile for Win64 MinGW 64-bit environment.
#
# Version: @(#)Makefile.mingw64 1.0.2 2017/05/06
#
# Authors: Kotori, <oubattler@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
# Sarah Walker,
# Richard G.,
#
# Include the default Makefile.
include Makefile.mingw
# Name of the executable.
PROG = 86Box64
# Various compile-time options.
STUFF =
EXTRAS =
DEBUG = n
OPTIM = n
X64 = y
DEV_BRANCH = n
# End of Makefile.mingw64.

View File

@@ -8,7 +8,7 @@
*
* The Emulator's Windows core.
*
* Version: @(#)win.c 1.0.23 2017/10/13
* Version: @(#)win.c 1.0.24 2017/10/14
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -1403,7 +1403,7 @@ get_executable_name(wchar_t *s, int size)
}
void
wchar_t *
set_window_title(wchar_t *s)
{
if (! video_fullscreen) {
@@ -1414,6 +1414,8 @@ set_window_title(wchar_t *s)
SetWindowText(hwndMain, s);
}
return(s);
}
@@ -1590,7 +1592,7 @@ take_screenshot(void)
ddraw_fs_take_screenshot(path);
else
ddraw_take_screenshot(path);
pclog("Screenshot: fn='%S'\n", path);
pclog("Screenshot: fn='%ls'\n", path);
break;
case 1: /* d3d9 */
@@ -1600,7 +1602,7 @@ take_screenshot(void)
d3d_fs_take_screenshot(path);
else
d3d_take_screenshot(path);
pclog("Screenshot: fn='%S'\n", path);
pclog("Screenshot: fn='%ls'\n", path);
break;
#ifdef USE_VNC
@@ -1608,7 +1610,7 @@ take_screenshot(void)
wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info);
append_filename_w(path, cfg_path, fn, 1024);
vnc_take_screenshot(path);
pclog("Screenshot: fn='%S'\n", path);
pclog("Screenshot: fn='%ls'\n", path);
break;
#endif
}

View File

@@ -8,7 +8,7 @@
*
* Implement threads and mutexes for the Win32 platform.
*
* Version: @(#)win_thread.c 1.0.2 2017/10/10
* Version: @(#)win_thread.c 1.0.3 2017/10/14
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -46,9 +46,7 @@ thread_create(void (*thread_rout)(void *param), void *param)
void
thread_kill(void *handle)
{
if (handle == NULL) {
return;
}
if (handle == NULL) return;
TerminateThread(handle, 0);
}
@@ -64,117 +62,98 @@ thread_sleep(int t)
event_t *
thread_create_event(void)
{
win_event_t *event = malloc(sizeof(win_event_t));
win_event_t *ev = malloc(sizeof(win_event_t));
event->handle = CreateEvent(NULL, FALSE, FALSE, NULL);
ev->handle = CreateEvent(NULL, FALSE, FALSE, NULL);
return((event_t *)event);
return((event_t *)ev);
}
void
thread_set_event(event_t *_event)
thread_set_event(event_t *arg)
{
if (_event == NULL) {
return;
}
win_event_t *ev = (win_event_t *)arg;
win_event_t *event = (win_event_t *)_event;
if (arg == NULL) return;
SetEvent(event->handle);
SetEvent(ev->handle);
}
void
thread_reset_event(event_t *_event)
thread_reset_event(event_t *arg)
{
if (_event == NULL) {
return;
}
win_event_t *ev = (win_event_t *)arg;
win_event_t *event = (win_event_t *)_event;
if (arg == NULL) return;
ResetEvent(event->handle);
ResetEvent(ev->handle);
}
int
thread_wait_event(event_t *_event, int timeout)
thread_wait_event(event_t *arg, int timeout)
{
if (_event == NULL) {
return 0;
}
win_event_t *ev = (win_event_t *)arg;
win_event_t *event = (win_event_t *)_event;
if (arg == NULL) return(0);
if (timeout == -1)
timeout = INFINITE;
if (WaitForSingleObject(event->handle, timeout)) return(1);
if (WaitForSingleObject(ev->handle, timeout)) return(1);
return(0);
}
void
thread_destroy_event(event_t *_event)
thread_destroy_event(event_t *arg)
{
win_event_t *event = (win_event_t *)_event;
win_event_t *ev = (win_event_t *)arg;
if (_event == NULL) {
return;
}
if (arg == NULL) return;
CloseHandle(event->handle);
CloseHandle(ev->handle);
free(event);
free(ev);
}
void *
mutex_t *
thread_create_mutex(wchar_t *name)
{
return((void*)CreateMutex(NULL, FALSE, name));
return((mutex_t*)CreateMutex(NULL, FALSE, name));
}
void
thread_close_mutex(void *mutex)
thread_close_mutex(mutex_t *mutex)
{
if (mutex == NULL) {
return;
}
if (mutex == NULL) return;
CloseHandle((HANDLE)mutex);
}
uint8_t
thread_wait_mutex(void *mutex)
int
thread_wait_mutex(mutex_t *mutex)
{
if (mutex == NULL) {
return 0;
}
if (mutex == NULL) return(0);
DWORD dwres = WaitForSingleObject((HANDLE)mutex, INFINITE);
switch (dwres) {
case WAIT_OBJECT_0:
return(1);
if (dwres == WAIT_OBJECT_0) return(1);
case WAIT_ABANDONED:
default:
return(0);
}
return(0);
}
uint8_t
thread_release_mutex(void *mutex)
int
thread_release_mutex(mutex_t *mutex)
{
if (mutex == NULL) {
return 0;
}
if (mutex == NULL) return(0);
return(!!ReleaseMutex((HANDLE)mutex));
}

View File

@@ -6,12 +6,12 @@
*
* This file is part of the 86Box distribution.
*
* Implement the VNC renderer.
* Implement the VNC renderer with LibVNCServer.
*
* Version: @(#)win_vnc.c 1.0.2 2017/10/13
* Version: @(#)win_vnc.c 1.0.2 2017/10/14
*
* Authors: RichardG, <richardg867@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Based on raw code by RichardG, <richardg867@gmail.com>
*
* Copyright 2017 Fred N. van Kempen.
*/
@@ -30,11 +30,8 @@
#include "win_vnc.h"
extern void video_blit_complete(void);
static rfbScreenInfoPtr rfbScreen;
static int vnc_clients;
static rfbScreenInfoPtr rfb = NULL;
static int clients;
static int updatingSize;
static int allowedX,
allowedY;
@@ -115,13 +112,12 @@ vnc_clientgone(rfbClientPtr cl)
{
pclog("VNC: client disconnected: %s\n", cl->host);
if (vnc_clients > 0)
vnc_clients--;
if (vnc_clients == 0) {
if (clients > 0)
clients--;
if (clients == 0) {
/* No more clients, pause the emulator. */
plat_pause(1);
pclog("VNC: no clients, pausing..\n");
plat_pause(1);
}
}
@@ -133,7 +129,7 @@ vnc_newclient(rfbClientPtr cl)
cl->clientGoneHook = vnc_clientgone;
pclog("VNC: new client: %s\n", cl->host);
if (++vnc_clients == 1) {
if (++clients == 1) {
/* We now have clients, un-pause the emulator. */
pclog("VNC: unpausing..\n");
plat_pause(0);
@@ -149,13 +145,11 @@ vnc_display(rfbClientPtr cl)
/* Avoid race condition between resize and update. */
if (!updatingSize && cl->newFBSizePending) {
updatingSize = 1;
pclog("VNC: updatingSize=1\n");
} else if (updatingSize && !cl->newFBSizePending) {
updatingSize = 0;
pclog("VNC: updatingSize=0\n");
allowedX = rfbScreen->width;
allowedY = rfbScreen->height;
allowedX = rfb->width;
allowedY = rfb->height;
}
}
@@ -196,35 +190,51 @@ vnc_kbdevent(rfbBool down, rfbKeySym k, rfbClientPtr cl)
static void
vnc_memtoscreen(int x, int y, int y1, int y2, int w, int h)
vnc_blit(int x, int y, int y1, int y2, int w, int h)
{
int yy, i;
uint32_t *p;
int yy;
for (yy=y1; yy<y2; yy++) {
p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*2048]);
/* y1 to <y2. */
for (yy=y1,i=0; yy<y2; yy++,i++) {
if ((y+yy) >= 0 && (y+yy) < 2048)
memcpy((uint32_t *) &(((uint8_t *) rfbScreen->frameBuffer)[yy*2048*4]), &(((uint32_t *)buffer32->line[y+yy])[x]), w*4);
memcpy(p, &(((uint32_t *)buffer32->line[y+yy])[x]), w*4);
}
video_blit_complete();
if (! updatingSize)
rfbMarkRectAsModified(rfbScreen, 0,0, allowedX,allowedY);
rfbMarkRectAsModified(rfb, 0,0, allowedX,allowedY);
}
static void
vnc_memtoscreen_8(int x, int y, int w, int h)
vnc_blit8(int x, int y, int w, int h)
{
#if 1
pclog("VNC: memtoscreen_8 %i,%i %i,%i\n", x, y, w, h);
#endif
uint32_t *p;
int xx, yy;
for (yy = 0; yy < h; yy++) {
p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*2048]);
if ((y+yy) >= 0 && (y+yy) < buffer->h) {
for (xx=0; xx<w; xx++)
p[xx] = pal_lookup[buffer->line[y+yy][x+xx]];
}
}
video_blit_complete();
if (! updatingSize)
rfbMarkRectAsModified(rfb, 0,0, x+w,y+h);
}
int
vnc_init(HWND h)
{
static char title[128];
rfbPixelFormat rpf = {
/*
* Screen format:
@@ -238,34 +248,32 @@ vnc_init(HWND h)
32, 32, 0, 1, 255,255,255, 16, 8, 0, 0, 0
};
if (rfbScreen == NULL) {
if (rfb == NULL) {
wcstombs(title, set_window_title(NULL), sizeof(title));
updatingSize = 0;
allowedX = allowedY = 2048;
rfbScreen = rfbGetScreen(0, NULL, 2048, 2048, 8, 3, 4);
rfbScreen->desktopName = "86Box";
rfbScreen->frameBuffer = (char *)malloc(2048 * 2048 * 4);
rfb = rfbGetScreen(0, NULL, 2048, 2048, 8, 3, 4);
rfb->desktopName = title;
rfb->frameBuffer = (char *)malloc(2048 * 2048 * 4);
#if 1
rfbScreen->serverFormat = rpf;
#else
rfbScreen->serverFormat = {32, 32, 0, 1, 255,255,255, 16, 8, 0, 0, 0};
#endif
rfbScreen->alwaysShared = TRUE;
rfbScreen->displayHook = vnc_display;
rfbScreen->kbdAddEvent = vnc_kbdevent;
rfbScreen->newClientHook = vnc_newclient;
rfb->serverFormat = rpf;
rfb->alwaysShared = TRUE;
rfb->displayHook = vnc_display;
rfb->kbdAddEvent = vnc_kbdevent;
rfb->newClientHook = vnc_newclient;
rfbInitServer(rfbScreen);
rfbInitServer(rfb);
rfbRunEventLoop(rfbScreen, -1, TRUE);
rfbRunEventLoop(rfb, -1, TRUE);
}
video_setblit(vnc_memtoscreen_8, vnc_memtoscreen);
/* Set up our BLIT handlers. */
video_setblit(vnc_blit8, vnc_blit);
pclog("VNC: init complete.\n");
vnc_clients = 0;
clients = 0;
return(1);
}
@@ -281,17 +289,21 @@ vnc_close(void)
void
vnc_resize(int x, int y)
{
if ((x != rfbScreen->width || y != rfbScreen->height) && x > 160 && y > 0) {
rfbClientIteratorPtr iterator;
rfbClientPtr cl;
if (rfb == NULL) return;
if ((x != rfb->width || y != rfb->height) && x > 160 && y > 0) {
pclog("VNC: updating resolution: %dx%d\n", x, y);
allowedX = (rfbScreen->width < x) ? rfbScreen->width : x;
allowedY = (rfbScreen->width < y) ? rfbScreen->width : y;
allowedX = (rfb->width < x) ? rfb->width : x;
allowedY = (rfb->width < y) ? rfb->width : y;
rfbScreen->width = x;
rfbScreen->height = y;
rfb->width = x;
rfb->height = y;
rfbClientPtr cl;
rfbClientIteratorPtr iterator = rfbGetClientIterator(rfbScreen);
iterator = rfbGetClientIterator(rfb);
while ((cl = rfbClientIteratorNext(iterator)) != NULL) {
LOCK(cl->updateMutex);
cl->newFBSizePending = 1;
@@ -304,7 +316,7 @@ vnc_resize(int x, int y)
int
vnc_pause(void)
{
return((vnc_clients > 0) ? 0 : 1);
return((clients > 0) ? 0 : 1);
}