Added the IBM 5161 ISA expansion for PC and XT;

Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g  / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
This commit is contained in:
OBattler
2019-09-20 14:02:30 +02:00
parent b06296bbf6
commit 552a87ea3d
524 changed files with 129555 additions and 21862 deletions

View File

@@ -88,11 +88,10 @@ BEGIN
MENUITEM "&Fullscreen\tCtrl+Alt+PageUP", IDM_VID_FULLSCREEN
POPUP "Fullscreen &stretch mode"
BEGIN
MENUITEM "&Full screen stretch", IDM_VID_FS_FULL
MENUITEM "&4:3", IDM_VID_FS_43
MENUITEM "&Square pixels", IDM_VID_FS_SQ
MENUITEM "&Integer scale", IDM_VID_FS_INT
MENUITEM "&Keep size", IDM_VID_FS_KEEPRATIO
MENUITEM "&Full screen stretch", IDM_VID_FS_FULL
MENUITEM "&4:3", IDM_VID_FS_43
MENUITEM "&Square pixels (Keep ratio)", IDM_VID_FS_KEEPRATIO
MENUITEM "&Integer scale", IDM_VID_FS_INT
END
POPUP "E&GA/(S)VGA settings"
BEGIN
@@ -409,7 +408,7 @@ BEGIN
PUSHBUTTON "Configure",IDC_CONFIGURE_NET,214,43,46,12
END
DLG_CFG_PORTS DIALOG DISCARDABLE 97, 0, 267, 99
DLG_CFG_PORTS DIALOG DISCARDABLE 97, 0, 267, 117
STYLE DS_CONTROL | WS_CHILD
FONT 9, "Segoe UI"
BEGIN
@@ -430,8 +429,12 @@ BEGIN
CONTROL "Serial port 2",IDC_CHECK_SERIAL2,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,147,64,94,10
CONTROL "Parallel port",IDC_CHECK_PARALLEL,"Button",
CONTROL "Parallel port 1",IDC_CHECK_PARALLEL1,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,82,94,10
CONTROL "Parallel port 2",IDC_CHECK_PARALLEL2,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,147,82,94,10
CONTROL "Parallel port 3",IDC_CHECK_PARALLEL3,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,100,94,10
END
DLG_CFG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 200
@@ -931,10 +934,12 @@ BEGIN
IDS_5376 "Disabled"
IDS_5380 "ATAPI"
IDS_5381 "SCSI"
IDS_5382 "SCSI (Chinon)"
IDS_5632 "Disabled"
IDS_5636 "ATAPI (%01i:%01i)"
IDS_5637 "SCSI (ID %02i)"
IDS_5638 "SCSI (ID %02i)"
IDS_5888 "160 kB"
IDS_5889 "180 kB"
@@ -982,7 +987,7 @@ VS_VERSION_INFO VERSIONINFO
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "0409fde9"
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "IRC #SoftHistory\0"

View File

@@ -8,7 +8,7 @@
#
# Makefile for Win32 (MinGW32) environment.
#
# Version: @(#)Makefile.mingw 1.0.136 2019/01/13
# Version: @(#)Makefile.mingw 1.0.137 2019/03/03
#
# Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
@@ -53,6 +53,9 @@ ifeq ($(DEV_BUILD), y)
ifndef LASERXT
LASERXT := y
endif
ifndef MR495
MR495 := y
endif
ifndef MRTHOR
MRTHOR := y
endif
@@ -62,9 +65,24 @@ ifeq ($(DEV_BUILD), y)
ifndef PORTABLE3
PORTABLE3 := y
endif
ifndef PS1M2133
PS1M2133 := y
endif
ifndef PS2M70T4
PS2M70T4 := y
endif
ifndef RIVA128
RIVA128 := y
endif
ifndef TC430HX
TC430HX := y
endif
ifndef VECTRA54
VECTRA54 := y
endif
ifndef VGAWONDER
VGAWONDER := y
endif
ifndef VNC
VNC := y
endif
@@ -93,6 +111,9 @@ else
ifndef LASERXT
LASERXT := n
endif
ifndef MR495
MR495 := n
endif
ifndef MRTHOR
MRTHOR := n
endif
@@ -102,9 +123,21 @@ else
ifndef PORTABLE3
PORTABLE3 := n
endif
ifndef PS1M2133
PS1M2133 := n
endif
ifndef PS2M70T4
PS2M70T4 := n
endif
ifndef RIVA128
RIVA128 := n
endif
ifndef TC430HX
TC430HX := n
endif
ifndef VECTRA54
VECTRA54 := n
endif
ifndef VGAWONDER
VGAWONDER := n
endif
@@ -145,10 +178,7 @@ ifndef RDP
RDP := n
endif
ifndef DINPUT
DINPUT := y
ifeq ($(ARM), y)
DINPUT := n
endif
DINPUT := n
endif
ifndef D3DX
D3DX := y
@@ -225,7 +255,7 @@ endif
# Nothing should need changing from here on.. #
#########################################################################
VPATH := $(EXPATH) . cpu \
cdrom disk floppy game machine \
cdrom chipset disk floppy game machine \
printer \
sound \
sound/munt sound/munt/c_interface sound/munt/sha1 \
@@ -240,7 +270,7 @@ endif
CPP := ${TOOL_PREFIX}g++
CC := ${TOOL_PREFIX}gcc
WINDRES := windres
STRIP := strip
STRIP := strip
ifeq ($(ARM64), y)
CPP := aarch64-w64-mingw32-g++
CC := aarch64-w64-mingw32-gcc
@@ -316,19 +346,16 @@ ifeq ($(VRAMDUMP), y)
OPTS += -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 ($(DYNAREC), y)
ifeq ($(X64), y)
PLATCG := codegen_x86-64.o
else
PLATCG := codegen_x86.o
endif
OPTS += -DUSE_DYNAREC
RFLAGS += -DUSE_DYNAREC
DYNARECOBJ := 386_dynarec_ops.o \
@@ -422,6 +449,7 @@ endif
ifeq ($(I686), y)
OPTS += -DUSE_I686
DEVBROBJ += m_at_socket8.o
endif
ifeq ($(LASERXT), y)
@@ -429,6 +457,10 @@ OPTS += -DUSE_LASERXT
DEVBROBJ += m_xt_laserxt.o
endif
ifeq ($(MR495), y)
OPTS += -DUSE_MR495
endif
ifeq ($(MRTHOR), y)
OPTS += -DUSE_MRTHOR
endif
@@ -442,10 +474,27 @@ ifeq ($(PORTABLE3), y)
OPTS += -DUSE_PORTABLE3
endif
ifeq ($(PS1M2133), y)
OPTS += -DUSE_PS1M2133
endif
ifeq ($(PS2M70T4), y)
OPTS += -DUSE_PS2M70T4
endif
ifeq ($(RIVA128), y)
OPTS += -DUSE_RIVA128
DEVBROBJ += vid_riva128.o
endif
ifeq ($(TC430HX), y)
OPTS += -DUSE_TC430HX
endif
ifeq ($(VECTRA54), y)
OPTS += -DUSE_VECTRA54
endif
ifeq ($(VGAWONDER), y)
OPTS += -DUSE_VGAWONDER
endif
@@ -477,42 +526,45 @@ CXXFLAGS := $(CFLAGS)
#########################################################################
# Create the (final) list of objects to build. #
#########################################################################
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 $(VNCOBJ) $(RDPOBJ)
MAINOBJ := pc.o config.o random.o timer.o io.o apm.o dma.o nmi.o \
pic.o pit.o port_92.o ppi.o pci.o mca.o mcr.o mem.o \
rom.o device.o nvr.o nvr_at.o nvr_ps2.o $(VNCOBJ) $(RDPOBJ)
INTELOBJ := intel.o \
intel_flash.o \
INTELOBJ := intel_flash.o \
intel_sio.o intel_piix.o
CPUOBJ := cpu.o cpu_table.o \
808x.o 386.o 386_dynarec.o \
808x.o 386.o \
386_dynarec.o \
x86seg.o x87.o \
$(DYNARECOBJ)
CHIPSETOBJ := acc2168.o acer_m3a.o ali1429.o headland.o \
intel_4x0.o neat.o opti495.o scat.o \
sis_85c471.o sis_85c496.o \
wd76c10.o
MCHOBJ := machine.o machine_table.o \
m_xt.o m_xt_compaq.o \
m_xt_t1000.o m_xt_t1000_vid.o \
m_xt_xi8088.o \
m_xt_zenith.o \
m_xt_xi8088.o m_xt_zenith.o \
m_pcjr.o \
m_amstrad.o \
m_europc.o \
m_amstrad.o m_europc.o \
m_olivetti_m24.o m_tandy.o \
m_at.o \
m_at_ali1429.o m_at_commodore.o \
m_at_neat.o m_at_headland.o \
m_at.o m_at_commodore.o \
m_at_t3100e.o m_at_t3100e_vid.o \
m_ps1.o m_ps1_hdc.o \
m_ps2_isa.o m_ps2_mca.o \
m_at_opti495.o m_at_scat.o \
m_at_compaq.o m_at_wd76c10.o \
m_at_sis_85c471.o m_at_sis_85c496.o \
m_at_4x0.o
m_at_compaq.o \
m_at_286_386sx.o m_at_386dx_486.o \
m_at_socket4_5.o m_at_socket7_s7.o
DEVOBJ := bugger.o isamem.o isartc.o lpt.o $(SERIAL) \
sio_fdc37c66x.o sio_fdc37c669.o sio_fdc37c93x.o \
sio_pc87306.o sio_w83877f.o sio_um8669f.o \
DEVOBJ := bugger.o ibm_5161.o isamem.o isartc.o lpt.o $(SERIAL) \
sio_acc3221.o \
sio_fdc37c66x.o sio_fdc37c669.o \
sio_fdc37c93x.o \
sio_pc87306.o sio_w83877f.o \
sio_um8669f.o \
keyboard.o \
keyboard_xt.o keyboard_at.o \
gameport.o \
@@ -530,11 +582,12 @@ FDDOBJ := fdd.o fdc.o fdi2raw.o \
HDDOBJ := hdd.o \
hdd_image.o hdd_table.o \
hdc.o \
hdc_mfm_xt.o hdc_mfm_at.o \
hdc_st506_xt.o hdc_st506_at.o \
hdc_xta.o \
hdc_esdi_at.o hdc_esdi_mca.o \
hdc_xtide.o hdc_ide.o
hdc_xtide.o hdc_ide.o \
hdc_ide_sff8038i.o
CDROMOBJ := cdrom.o \
cdrom_dosbox.o cdrom_image.o
@@ -594,6 +647,7 @@ VIDOBJ := video.o \
vid_hercules.o vid_herculesplus.o vid_incolor.o \
vid_colorplus.o \
vid_genius.o \
vid_pgc.o vid_im1024.o \
vid_sigma.o \
vid_wy700.o \
vid_ega.o vid_ega_render.o \
@@ -608,6 +662,7 @@ VIDOBJ := video.o \
vid_cl54xx.o \
vid_et4000.o vid_sc1502x_ramdac.o \
vid_et4000w32.o vid_stg_ramdac.o \
vid_ht216.o \
vid_oak_oti.o \
vid_paradise.o \
vid_ti_cf62011.o \
@@ -628,8 +683,8 @@ else
PLATOBJ += win_mouse_rawinput.o win_joystick_xinput.o
endif
OBJ := $(MAINOBJ) $(INTELOBJ) $(CPUOBJ) $(MCHOBJ) $(DEVOBJ) \
$(FDDOBJ) $(CDROMOBJ) $(ZIPOBJ) $(HDDOBJ) \
OBJ := $(MAINOBJ) $(INTELOBJ) $(CPUOBJ) $(CHIPSETOBJ) $(MCHOBJ) \
$(DEVOBJ) $(FDDOBJ) $(CDROMOBJ) $(ZIPOBJ) $(HDDOBJ) \
$(USBOBJ) $(NETOBJ) $(PRINTOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \
$(PLATOBJ) $(UIOBJ) $(D2DOBJ) $(FSYNTHOBJ) $(MUNTOBJ) \
$(DEVBROBJ)
@@ -639,12 +694,12 @@ endif
LIBS := -mwindows \
-lddraw -ldxguid -ld3d9 \
-lcomctl32 -lwinmm
-lcomctl32
ifeq ($(STATIC), y)
LIBS += -lopenal -lole32
LIBS += -lopenal -lole32 -lwinmm
else
LIBS += -lopenal.dll
LIBS += -lwinmm -lopenal.dll
endif
ifeq ($(D2D), y)

848
src/win/Makefile_ndr.mingw Normal file
View File

@@ -0,0 +1,848 @@
#
# 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.137 2019/03/03
#
# Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
#
# Various compile-time options.
ifndef STUFF
STUFF :=
endif
# Add feature selections here.
ifndef EXTRAS
EXTRAS :=
endif
ifndef DEV_BUILD
DEV_BUILD := n
endif
ifndef FLTO
FLTO := full
endif
ifeq ($(DEV_BUILD), y)
ifndef DEBUG
DEBUG := y
endif
ifndef DEV_BRANCH
DEV_BRANCH := y
endif
ifndef AMD_K
AMD_K := y
endif
ifndef CRASHDUMP
CRASHDUMP := y
endif
ifndef D2D
D2D := y
endif
ifndef I686
I686 := y
endif
ifndef LASERXT
LASERXT := y
endif
ifndef MR495
MR495 := y
endif
ifndef MRTHOR
MRTHOR := y
endif
ifndef PAS16
PAS16 := y
endif
ifndef PORTABLE3
PORTABLE3 := y
endif
ifndef PS1M2133
PS1M2133 := y
endif
ifndef PS2M70T4
PS2M70T4 := y
endif
ifndef RIVA128
RIVA128 := y
endif
ifndef TC430HX
TC430HX := y
endif
ifndef VECTRA54
VECTRA54 := y
endif
ifndef VGAWONDER
VGAWONDER := y
endif
ifndef VNC
VNC := y
endif
ifndef XL24
XL24 := y
endif
else
ifndef DEBUG
DEBUG := n
endif
ifndef DEV_BRANCH
DEV_BRANCH := n
endif
ifndef AMD_K
AMD_K := n
endif
ifndef CRASHDUMP
CRASHDUMP := n
endif
ifndef D2D
D2D := n
endif
ifndef I686
I686 := n
endif
ifndef LASERXT
LASERXT := n
endif
ifndef MR495
MR495 := n
endif
ifndef MRTHOR
MRTHOR := n
endif
ifndef PAS16
PAS16 := n
endif
ifndef PORTABLE3
PORTABLE3 := n
endif
ifndef PS1M2133
PS1M2133 := n
endif
ifndef PS2M70T4
PS2M70T4 := n
endif
ifndef RIVA128
RIVA128 := n
endif
ifndef TC430HX
TC430HX := n
endif
ifndef VECTRA54
VECTRA54 := n
endif
ifndef VGAWONDER
VGAWONDER := n
endif
ifndef VNC
VNC := n
endif
ifndef XL24
XL24 := n
endif
endif
# Defaults for several build options (possibly defined in a chained file.)
ifndef AUTODEP
AUTODEP := n
endif
ifndef OPTIM
OPTIM := n
endif
ifndef RELEASE
RELEASE := n
endif
ifndef X64
X64 := n
endif
ifndef ARM
ARM := n
endif
ifndef ARM64
ARM64 := n
endif
ifndef WX
WX := n
endif
ifndef USB
USB := n
endif
ifndef RDP
RDP := n
endif
ifndef DINPUT
DINPUT := n
endif
ifndef D3DX
D3DX := y
ifeq ($(ARM), y)
D3DX := n
endif
ifeq ($(ARM64), y)
D3DX := n
endif
endif
ifndef OPENAL
OPENAL := y
endif
ifndef FLUIDSYNTH
FLUIDSYNTH := y
endif
ifndef MUNT
MUNT := y
endif
ifndef DYNAREC
DYNAREC := y
ifeq ($(ARM), y)
DYNAREC := n
endif
ifeq ($(ARM64), y)
DYNAREC := n
endif
endif
# Name of the executable.
ifndef PROG
ifneq ($(WX), n)
PROG := Wx86Box
else
PROG := 86Box
endif
endif
# WxWidgets basic info. Extract using the config program.
ifneq ($(WX), n)
EXPATH += wx
WX_CONFIG := wx-config.exe
ifeq ($(WX), y)
WX_PATH := C:/MinGW32/WxWidgets
WX_FLAGS := -I$(WX_PATH)/lib/wx/include/msw-unicode-3.0 \
-I$(WX_PATH)/include/wx-3.0 \
-D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -pthread
# -lwx_mswu_gl-3.0 -lwxtiff-3.0 -llzma
WX_LIBS := -mwindows -mthreads -L$(WX_PATH)/lib \
-lwx_mswu-3.0.dll \
-lrpcrt4 -loleaut32 -lole32 -luuid \
-lwinspool -lwinmm -lshell32 -lcomctl32 \
-lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
endif
ifeq ($(WX), static)
WX_PATH := C:/MinGW32/WxWidgets
WX_FLAGS := -I$(WX_PATH)/lib/wx/include/msw-unicode-3.0 \
-I$(WX_PATH)/include/wx-3.0 \
-D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -pthread
# -lwx_mswu_gl-3.0 -lwxtiff-3.0 -llzma
WX_LIBS := -mwindows -mthreads -L$(WX_PATH)/lib \
-lwx_mswu-3.0 -lwxscintilla-3.0 \
-lwxjpeg-3.0 -lwxpng-3.0 -lwxzlib-3.0 \
-lwxregexu-3.0 -lwxexpat-3.0 \
-lrpcrt4 -loleaut32 -lole32 -luuid \
-lwinspool -lwinmm -lshell32 -lcomctl32 \
-lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
endif
endif
#########################################################################
# Nothing should need changing from here on.. #
#########################################################################
VPATH := $(EXPATH) . cpu_new \
cdrom chipset disk floppy game machine \
printer \
sound \
sound/munt sound/munt/c_interface sound/munt/sha1 \
sound/munt/srchelper \
sound/resid-fp \
scsi video network network/slirp win
ifeq ($(X64), y)
TOOL_PREFIX := x86_64-w64-mingw32-
else
TOOL_PREFIX := i686-w64-mingw32-
endif
CPP := ${TOOL_PREFIX}g++
CC := ${TOOL_PREFIX}gcc
WINDRES := windres
STRIP := strip
ifeq ($(ARM64), y)
CPP := aarch64-w64-mingw32-g++
CC := aarch64-w64-mingw32-gcc
WINDRES := aarch64-w64-mingw32-windres
STRIP := aarch64-w64-mingw32-strip
endif
ifeq ($(ARM), y)
CPP := armv7-w64-mingw32-g++
CC := armv7-w64-mingw32-gcc
WINDRES := armv7-w64-mingw32-windres
STRIP := armv7-w64-mingw32-strip
endif
DEPS = -MMD -MF $*.d -c $<
DEPFILE := win/.depends
# Set up the correct toolchain flags.
OPTS := $(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
DFLAGS += -g0
ifeq ($(OPTIM), y)
AOPTIM := -mtune=native
ifndef COPTIM
COPTIM := -O3 -flto=$(FLTO)
endif
else
ifndef COPTIM
COPTIM := -O3
endif
endif
endif
AFLAGS := -msse2 -mfpmath=sse
ifeq ($(ARM), y)
DFLAGS := -march=armv7-a
AOPTIM :=
AFLAGS := -mfloat-abi=hard
endif
ifeq ($(ARM64), y)
DFLAGS := -march=armv8-a
AOPTIM :=
AFLAGS := -mfloat-abi=hard
endif
RFLAGS := --input-format=rc -O coff
OPTS += -DUSE_NEW_DYNAREC
ifeq ($(RELEASE), y)
OPTS += -DRELEASE_BUILD
RFLAGS += -DRELEASE_BUILD
endif
ifeq ($(VRAMDUMP), y)
OPTS += -DENABLE_VRAM_DUMP
RFLAGS += -DENABLE_VRAM_DUMP
endif
# Optional modules.
ifeq ($(DYNAREC), y)
ifeq ($(X64), y)
PLATCG := codegen_backend_x86-64.o codegen_backend_x86-64_ops.o codegen_backend_x86-64_ops_sse.o \
codegen_backend_x86-64_uops.o
else
PLATCG := codegen_backend_x86.o codegen_backend_x86_ops.o codegen_backend_x86_ops_fpu.o codegen_backend_x86_ops_sse.o \
codegen_backend_x86_uops.o
endif
OPTS += -DUSE_DYNAREC
RFLAGS += -DUSE_DYNAREC
DYNARECOBJ := 386_dynarec_ops.o \
codegen.o codegen_accumulate.o codegen_allocator.o codegen_block.o codegen_ir.o codegen_ops.o \
codegen_ops_3dnow.o codegen_ops_branch.o codegen_ops_arith.o codegen_ops_fpu_arith.o \
codegen_ops_fpu_constant.o codegen_ops_fpu_loadstore.o codegen_ops_fpu_misc.o codegen_ops_helpers.o codegen_ops_jump.o \
codegen_ops_logic.o codegen_ops_misc.o codegen_ops_mmx_arith.o codegen_ops_mmx_cmp.o \
codegen_ops_mmx_loadstore.o codegen_ops_mmx_logic.o codegen_ops_mmx_pack.o codegen_ops_mmx_shift.o \
codegen_ops_mov.o codegen_ops_shift.o codegen_ops_stack.o codegen_reg.o codegen_timing_486.o \
codegen_timing_686.o codegen_timing_common.o codegen_timing_k6.o codegen_timing_pentium.o \
codegen_timing_winchip.o codegen_timing_winchip2.o $(PLATCG)
endif
ifneq ($(WX), n)
OPTS += -DUSE_WX $(WX_FLAGS)
LIBS += $(WX_LIBS)
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
else
UIOBJ := win_ui.o win_stbar.o \
win_ddraw.o win_d3d.o win_sdl.o \
win_dialog.o win_about.o \
win_settings.o win_devconf.o win_snd_gain.o \
win_new_floppy.o win_jsconf.o
endif
ifeq ($(OPENAL), y)
OPTS += -DUSE_OPENAL
endif
ifeq ($(FLUIDSYNTH), y)
OPTS += -DUSE_FLUIDSYNTH
FSYNTHOBJ := midi_fluidsynth.o
endif
ifeq ($(MUNT), y)
OPTS += -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 ($(D2D), y)
OPTS += -DUSE_D2D
RFLAGS += -DUSE_D2D
D2DLIB := -ld2d1
D2DOBJ := win_d2d.o
endif
ifeq ($(VNC), y)
OPTS += -DUSE_VNC
RFLAGS += -DUSE_VNC
ifneq ($(VNC_PATH), )
OPTS += -I$(VNC_PATH)\INCLUDE
VNCLIB := -L$(VNC_PATH)\LIB
endif
VNCLIB += -lvncserver
VNCOBJ := vnc.o vnc_keymap.o
endif
ifeq ($(RDP), y)
OPTS += -DUSE_RDP
RFLAGS += -DUSE_RDP
ifneq ($(RDP_PATH), )
OPTS += -I$(RDP_PATH)\INCLUDE
RDPLIB := -L$(RDP_PATH)\LIB
endif
RDPLIB += -lrdp
RDPOBJ := rdp.o
endif
ifeq ($(DINPUT), y)
OPTS += -DUSE_DINPUT
endif
ifeq ($(D3DX), y)
OPTS += -DUSE_D3DX
endif
# Options for the DEV branch.
ifeq ($(DEV_BRANCH), y)
OPTS += -DDEV_BRANCH
DEVBROBJ :=
ifeq ($(AMD_K), y)
OPTS += -DUSE_AMD_K
endif
ifeq ($(CRASHDUMPOBJ), y)
OPTS += -DUSE_CRASHDUMP
DEVBROBJ += win_crashdump.o
endif
ifeq ($(I686), y)
OPTS += -DUSE_I686
DEVBROBJ += m_at_socket8.o
endif
ifeq ($(LASERXT), y)
OPTS += -DUSE_LASERXT
DEVBROBJ += m_xt_laserxt.o
endif
ifeq ($(MR495), y)
OPTS += -DUSE_MR495
endif
ifeq ($(MRTHOR), y)
OPTS += -DUSE_MRTHOR
endif
ifeq ($(PAS16), y)
OPTS += -DUSE_PAS16
DEVBROBJ += snd_pas16.o
endif
ifeq ($(PORTABLE3), y)
OPTS += -DUSE_PORTABLE3
endif
ifeq ($(PS1M2133), y)
OPTS += -DUSE_PS1M2133
endif
ifeq ($(PS2M70T4), y)
OPTS += -DUSE_PS2M70T4
endif
ifeq ($(RIVA128), y)
OPTS += -DUSE_RIVA128
DEVBROBJ += vid_riva128.o
endif
ifeq ($(TC430HX), y)
OPTS += -DUSE_TC430HX
endif
ifeq ($(VECTRA54), y)
OPTS += -DUSE_VECTRA54
endif
ifeq ($(VGAWONDER), y)
OPTS += -DUSE_VGAWONDER
endif
ifeq ($(XL24), y)
OPTS += -DUSE_XL24
endif
endif
# Options for works-in-progress.
ifndef SERIAL
SERIAL := serial.o
endif
# Final versions of the toolchain flags.
CFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \
$(AFLAGS) -fomit-frame-pointer -mstackrealign -Wall \
-fno-strict-aliasing
# Add freetyp2 references through pkgconfig
CFLAGS := $(CFLAGS) `pkg-config.exe --cflags freetype2`
CXXFLAGS := $(CFLAGS)
#########################################################################
# Create the (final) list of objects to build. #
#########################################################################
MAINOBJ := pc.o config.o random.o timer.o io.o apm.o dma.o nmi.o \
pic.o pit.o port_92.o ppi.o pci.o mca.o mcr.o mem_new.o \
rom.o device.o nvr.o nvr_at.o nvr_ps2.o $(VNCOBJ) $(RDPOBJ)
INTELOBJ := intel_flash.o \
intel_sio.o intel_piix.o
CPUOBJ := cpu.o cpu_table.o \
808x.o 386.o 386_common.o \
386_dynarec.o \
x86seg.o x87.o \
$(DYNARECOBJ)
CHIPSETOBJ := acc2168.o acer_m3a.o ali1429.o headland.o \
intel_4x0.o neat.o opti495.o scat.o \
sis_85c471.o sis_85c496.o \
wd76c10.o
MCHOBJ := machine.o machine_table_new.o \
m_xt.o m_xt_compaq.o \
m_xt_t1000.o m_xt_t1000_vid.o \
m_xt_xi8088.o m_xt_zenith.o \
m_pcjr.o \
m_amstrad.o m_europc.o \
m_olivetti_m24.o m_tandy.o \
m_at.o m_at_commodore.o \
m_at_t3100e.o m_at_t3100e_vid.o \
m_ps1.o m_ps1_hdc.o \
m_ps2_isa.o m_ps2_mca.o \
m_at_compaq.o \
m_at_286_386sx.o m_at_386dx_486.o \
m_at_socket4_5.o m_at_socket7_s7.o
DEVOBJ := bugger.o ibm_5161.o isamem.o isartc.o lpt.o $(SERIAL) \
sio_acc3221.o \
sio_fdc37c66x.o sio_fdc37c669.o \
sio_fdc37c93x.o \
sio_pc87306.o sio_w83877f.o \
sio_um8669f.o \
keyboard.o \
keyboard_xt.o keyboard_at.o \
gameport.o \
joystick_standard.o joystick_ch_flightstick_pro.o \
joystick_sw_pad.o joystick_tm_fcs.o \
mouse.o \
mouse_bus.o \
mouse_serial.o mouse_ps2.o
FDDOBJ := fdd.o fdc.o fdi2raw.o \
fdd_common.o fdd_86f.o \
fdd_fdi.o fdd_imd.o fdd_img.o fdd_json.o \
fdd_mfm.o fdd_td0.o
HDDOBJ := hdd.o \
hdd_image.o hdd_table.o \
hdc.o \
hdc_st506_xt.o hdc_st506_at.o \
hdc_xta.o \
hdc_esdi_at.o hdc_esdi_mca.o \
hdc_xtide.o hdc_ide.o \
hdc_ide_sff8038i.o
CDROMOBJ := cdrom.o \
cdrom_dosbox.o cdrom_image.o
ZIPOBJ := zip.o
ifeq ($(USB), y)
USBOBJ := usb.o
endif
SCSIOBJ := scsi.o scsi_device.o \
scsi_cdrom.o scsi_disk.o \
scsi_x54x.o \
scsi_aha154x.o scsi_buslogic.o \
scsi_ncr5380.o scsi_ncr53c8xx.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_dp8390.o \
net_3c503.o net_ne2000.o \
net_wd8003.o
PRINTOBJ := png.o prt_cpmap.o \
prt_escp.o prt_text.o
SNDOBJ := sound.o \
openal.o \
snd_opl.o snd_dbopl.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 midi_system.o \
snd_speaker.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_cms.o \
snd_gus.o \
snd_sb.o snd_sb_dsp.o \
snd_emu8k.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_compaq_cga.o \
vid_mda.o \
vid_hercules.o vid_herculesplus.o vid_incolor.o \
vid_colorplus.o \
vid_genius.o \
vid_pgc.o vid_im1024.o \
vid_sigma.o \
vid_wy700.o \
vid_ega.o vid_ega_render.o \
vid_svga.o vid_svga_render.o \
vid_vga.o \
vid_ati_eeprom.o \
vid_ati18800.o vid_ati28800.o \
vid_ati_mach64.o vid_ati68860_ramdac.o \
vid_bt48x_ramdac.o \
vid_av9194.o \
vid_icd2061.o vid_ics2595.o \
vid_cl54xx.o \
vid_et4000.o vid_sc1502x_ramdac.o \
vid_et4000w32.o vid_stg_ramdac.o \
vid_ht216.o \
vid_oak_oti.o \
vid_paradise.o \
vid_ti_cf62011.o \
vid_tvga.o \
vid_tgui9440.o vid_tkd8001_ramdac.o \
vid_att20c49x_ramdac.o \
vid_s3.o vid_s3_virge.o \
vid_sdac_ramdac.o \
vid_voodoo.o
PLATOBJ := win.o \
win_dynld.o win_thread.o \
win_cdrom.o win_keyboard.o \
win_midi.o
ifeq ($(DINPUT), y)
PLATOBJ += win_mouse.o win_joystick.o
else
PLATOBJ += win_mouse_rawinput.o win_joystick_xinput.o
endif
OBJ := $(MAINOBJ) $(INTELOBJ) $(CPUOBJ) $(CHIPSETOBJ) $(MCHOBJ) \
$(DEVOBJ) $(FDDOBJ) $(CDROMOBJ) $(ZIPOBJ) $(HDDOBJ) \
$(USBOBJ) $(NETOBJ) $(PRINTOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \
$(PLATOBJ) $(UIOBJ) $(D2DOBJ) $(FSYNTHOBJ) $(MUNTOBJ) \
$(DEVBROBJ)
ifdef EXOBJ
OBJ += $(EXOBJ)
endif
LIBS := -mwindows \
-lddraw -ldxguid -ld3d9 \
-lcomctl32
ifeq ($(STATIC), y)
LIBS += -lopenal -lole32 -lwinmm
else
LIBS += -lwinmm -lopenal.dll
endif
ifeq ($(D2D), y)
LIBS += $(D2DLIB)
endif
ifeq ($(VNC), y)
LIBS += $(VNCLIB) -lws2_32
endif
ifeq ($(RDP), y)
LIBS += $(RDPLIB)
endif
ifneq ($(WX), n)
LIBS += $(WX_LIBS) -lm
endif
LIBS += -lpng -lz -lwsock32 -liphlpapi
LIBS += -static -lstdc++
ifneq ($(X64), y)
LIBS += -Wl,--large-address-aware
endif
ifeq ($(DINPUT), y)
LIBS += -ldinput8
else
LIBS += -lxinput
endif
ifeq ($(D3DX), y)
LIBS += -ld3dx9
endif
ifeq ($(STATIC), y)
LIBS += -static
endif
# Build module rules.
ifeq ($(AUTODEP), y)
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $(DEPS) -c $<
%.o: %.cc
@echo $<
@$(CPP) $(CXXFLAGS) $(DEPS) -c $<
%.o: %.cpp
@echo $<
@$(CPP) $(CXXFLAGS) $(DEPS) -c $<
else
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) -c $<
%.o: %.cc
@echo $<
@$(CPP) $(CXXFLAGS) -c $<
%.o: %.cpp
@echo $<
@$(CPP) $(CXXFLAGS) -c $<
%.d: %.c $(wildcard $*.d)
@echo $<
@$(CC) $(CFLAGS) $(DEPS) -E $< >NUL
%.d: %.cc $(wildcard $*.d)
@echo $<
@$(CPP) $(CXXFLAGS) $(DEPS) -E $< >NUL
%.d: %.cpp $(wildcard $*.d)
@echo $<
@$(CPP) $(CXXFLAGS) $(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) 86Box.res
@echo Linking $(PROG).exe ..
@$(CC) -o $(PROG).exe $(OBJ) 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
hello.exe: hello.o
$(CXX) $(LDFLAGS) -o hello.exe hello.o $(WXLIBS) $(LIBS)
ifneq ($(DEBUG), y)
@$(STRIP) hello.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.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -160,7 +160,9 @@
#define IDC_COMBO_LPT3 1112
#define IDC_CHECK_SERIAL1 1113
#define IDC_CHECK_SERIAL2 1114
#define IDC_CHECK_PARALLEL 1115
#define IDC_CHECK_PARALLEL1 1115
#define IDC_CHECK_PARALLEL2 1116
#define IDC_CHECK_PARALLEL3 1117
#define IDC_OTHER_PERIPH 1120 /* other periph config */
#define IDC_COMBO_SCSI 1121
@@ -284,9 +286,8 @@
#define IDM_VID_FULLSCREEN 40060
#define IDM_VID_FS_FULL 40061
#define IDM_VID_FS_43 40062
#define IDM_VID_FS_SQ 40063
#define IDM_VID_FS_KEEPRATIO 40063
#define IDM_VID_FS_INT 40064
#define IDM_VID_FS_KEEPRATIO 40065
#define IDM_VID_FORCE43 40066
#define IDM_VID_OVERSCAN 40067
#define IDM_VID_INVERT 40069

View File

@@ -8,15 +8,15 @@
*
* Platform main support module for Windows.
*
* Version: @(#)win.c 1.0.55 2018/11/19
* Version: @(#)win.c 1.0.57 2019/03/06
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
* Copyright 2017,2018 Fred N. van Kempen.
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
* Copyright 2017-2019 Fred N. van Kempen.
*/
#define UNICODE
#include <windows.h>
@@ -76,34 +76,36 @@ static rc_str_t *lpRCstr2048,
static int vid_api_inited = 0;
static struct {
char *name;
static const struct {
const char *name;
int local;
int (*init)(void *);
void (*close)(void);
void (*resize)(int x, int y);
int (*pause)(void);
void (*enable)(int enable);
void (*screenshot)(const wchar_t *fn);
} vid_apis[2][RENDERERS_NUM] = {
{
{ "DDraw", 1, (int(*)(void*))ddraw_init, ddraw_close, NULL, ddraw_pause },
{ "DDraw", 1, (int(*)(void*))ddraw_init, ddraw_close, NULL, ddraw_pause, ddraw_enable, ddraw_take_screenshot },
#ifdef USE_D2D
{ "D2D", 1, (int(*)(void*))d2d_init, d2d_close, NULL, d2d_pause },
{ "D2D", 1, (int(*)(void*))d2d_init, d2d_close, NULL, d2d_pause, d2d_enable, d2d_take_screenshot },
#endif
{ "D3D", 1, (int(*)(void*))d3d_init, d3d_close, d3d_resize, d3d_pause },
{ "SDL", 1, (int(*)(void*))sdl_init, sdl_close, NULL, sdl_pause }
{ "D3D", 1, (int(*)(void*))d3d_init, d3d_close, d3d_resize, d3d_pause, d3d_enable, d3d_take_screenshot },
{ "SDL", 1, (int(*)(void*))sdl_init, sdl_close, NULL, sdl_pause, sdl_enable, sdl_take_screenshot }
#ifdef USE_VNC
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause }
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL, vnc_take_screenshot }
#endif
},
{
{ "DDraw", 1, (int(*)(void*))ddraw_init_fs, ddraw_close, NULL, ddraw_pause },
{ "DDraw", 1, (int(*)(void*))ddraw_init_fs, ddraw_close, NULL, ddraw_pause, ddraw_enable, ddraw_take_screenshot },
#ifdef USE_D2D
{ "D2D", 1, (int(*)(void*))d2d_init_fs, d2d_close, NULL, d2d_pause },
{ "D2D", 1, (int(*)(void*))d2d_init_fs, d2d_close, NULL, d2d_pause, d2d_enable, d2d_take_screenshot },
#endif
{ "D3D", 1, (int(*)(void*))d3d_init_fs, d3d_close, NULL, d3d_pause },
{ "SDL", 1, (int(*)(void*))sdl_init_fs, sdl_close, sdl_resize, sdl_pause }
{ "D3D", 1, (int(*)(void*))d3d_init_fs, d3d_close, NULL, d3d_pause, d3d_enable, d3d_take_screenshot },
{ "SDL", 1, (int(*)(void*))sdl_init_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable, sdl_take_screenshot }
#ifdef USE_VNC
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause }
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL, vnc_take_screenshot }
#endif
},
};
@@ -348,6 +350,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
{
wchar_t **argw = NULL;
int argc, i;
wchar_t * AppID = L"86Box.86Box\0";
SetCurrentProcessExplicitAppUserModelID(AppID);
/* Set this to the default value (windowed mode). */
video_fullscreen = 0;
@@ -435,6 +440,7 @@ plat_get_exe_name(wchar_t *s, int size)
GetModuleFileName(hinstance, s, size);
}
void
plat_tempfile(wchar_t *bufp, wchar_t *prefix, wchar_t *suffix)
{
@@ -455,6 +461,7 @@ plat_tempfile(wchar_t *bufp, wchar_t *prefix, wchar_t *suffix)
mbstowcs(bufp, temp, strlen(temp)+1);
}
int
plat_getcwd(wchar_t *bufp, int max)
{
@@ -478,6 +485,14 @@ plat_fopen(wchar_t *path, wchar_t *mode)
}
/* Open a file, using Unicode pathname, with 64bit pointers. */
FILE *
plat_fopen64(const wchar_t *path, const wchar_t *mode)
{
return(_wfopen(path, mode));
}
void
plat_remove(wchar_t *path)
{
@@ -507,6 +522,46 @@ plat_path_abs(wchar_t *path)
}
/* Return the last element of a pathname. */
wchar_t *
plat_get_basename(const wchar_t *path)
{
int c = (int)wcslen(path);
while (c > 0) {
if (path[c] == L'/' || path[c] == L'\\')
return((wchar_t *)&path[c]);
c--;
}
return((wchar_t *)path);
}
/* Return the 'directory' element of a pathname. */
void
plat_get_dirname(wchar_t *dest, const wchar_t *path)
{
int c = (int)wcslen(path);
wchar_t *ptr;
ptr = (wchar_t *)path;
while (c > 0) {
if (path[c] == L'/' || path[c] == L'\\') {
ptr = (wchar_t *)&path[c];
break;
}
c--;
}
/* Copy to destination. */
while (path < ptr)
*dest++ = *path++;
*dest = L'\0';
}
wchar_t *
plat_get_filename(wchar_t *s)
{
@@ -544,6 +599,7 @@ void
plat_append_filename(wchar_t *dest, wchar_t *s1, wchar_t *s2)
{
wcscat(dest, s1);
plat_path_slash(dest);
wcscat(dest, s2);
}
@@ -607,7 +663,11 @@ plat_vidapi(char *name)
{
int i;
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(0);
#ifdef USE_D2D
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(2);
#else
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(1);
#endif
for (i = 0; i < RENDERERS_NUM; i++) {
if (vid_apis[0][i].name &&
@@ -627,10 +687,7 @@ plat_vidapi_name(int api)
switch(api) {
case 0:
#if 0
/* DirectDraw is default. */
name = "ddraw";
#endif
break;
#ifdef USE_D2D
@@ -639,7 +696,10 @@ plat_vidapi_name(int api)
break;
case 2:
#if 0
/* Direct3D is default. */
name = "d3d";
#endif
break;
case 3:
@@ -647,7 +707,10 @@ plat_vidapi_name(int api)
break;
#else
case 1:
#if 0
/* Direct3D is default. */
name = "d3d";
#endif
break;
case 2:
@@ -714,6 +777,17 @@ plat_vidsize(int x, int y)
}
void
plat_vidapi_enable(int enable)
{
if (!vid_api_inited || !vid_apis[video_fullscreen][vid_api].enable) return;
startblit();
video_wait_for_blit();
vid_apis[video_fullscreen][vid_api].enable(enable);
endblit();
}
int
get_vidpause(void)
{
@@ -768,6 +842,7 @@ take_screenshot(void)
struct tm *info;
time_t now;
if (!vid_api_inited || !vid_apis[video_fullscreen][vid_api].screenshot) return;
win_log("Screenshot: video API is: %i\n", vid_api);
if ((vid_api < 0) || (vid_api >= RENDERERS_NUM)) return;
@@ -786,44 +861,7 @@ take_screenshot(void)
wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info);
wcscat(path, fn);
switch(vid_api) {
case 0: /* ddraw */
ddraw_take_screenshot(path);
break;
#ifdef USE_D2D
case 1: /* d2d */
d2d_take_screenshot(path);
break;
case 2: /* d3d9 */
d3d_take_screenshot(path);
break;
case 3: /* sdl */
sdl_take_screenshot(path);
break;
#else
case 1: /* d3d9 */
d3d_take_screenshot(path);
break;
case 2: /* sdl */
sdl_take_screenshot(path);
break;
#endif
#ifdef USE_VNC
#ifdef USE_D2D
case 4: /* vnc */
#else
case 3: /* vnc */
#endif
vnc_take_screenshot(path);
break;
#endif
}
vid_apis[video_fullscreen][vid_api].screenshot((const wchar_t *) path);
}

View File

@@ -8,11 +8,11 @@
*
* Rendering module for Microsoft Direct2D.
*
* Version: @(#)win_d2d.cpp 1.0.2 2018/10/18
* Version: @(#)win_d2d.cpp 1.0.3 2019/03/09
*
* Authors: David Hrdlička, <hrdlickadavid@outlook.com>
*
* Copyright 2018 David Hrdlička.
* Copyright 2018,2019 David Hrdlička.
*/
#include <stdarg.h>
#include <stdio.h>
@@ -35,6 +35,7 @@
#include "../device.h"
#include "../video/video.h"
#include "../plat.h"
#include "../plat_dynld.h"
#include "../ui.h"
#include "win.h"
#include "win_d2d.h"
@@ -47,9 +48,24 @@ static ID2D1HwndRenderTarget *d2d_hwndRT;
static ID2D1BitmapRenderTarget *d2d_btmpRT;
static ID2D1Bitmap *d2d_bitmap;
static int d2d_width, d2d_height, d2d_screen_width, d2d_screen_height, d2d_fs;
static volatile int d2d_enabled = 0;
#endif
/* Pointers to the real functions. */
static HRESULT (*D2D1_CreateFactory)(D2D1_FACTORY_TYPE facType,
REFIID riid,
CONST D2D1_FACTORY_OPTIONS *pFacOptions,
void **ppIFactory);
static dllimp_t d2d_imports[] = {
{ "D2D1CreateFactory", &D2D1_CreateFactory },
{ NULL, NULL }
};
static volatile void *d2d_handle; /* handle to WinPcap DLL */
#ifdef ENABLE_D2D_LOG
int d2d_do_log = ENABLE_D2D_LOG;
@@ -76,7 +92,7 @@ d2d_stretch(float *w, float *h, float *x, float *y)
{
double dw, dh, dx, dy, temp, temp2, ratio_w, ratio_h, gsr, hsr;
switch (video_fullscreen_scale)
switch (video_fullscreen_scale)
{
case FULLSCR_SCALE_FULL:
*w = d2d_screen_width;
@@ -86,35 +102,34 @@ d2d_stretch(float *w, float *h, float *x, float *y)
break;
case FULLSCR_SCALE_43:
case FULLSCR_SCALE_KEEPRATIO:
dw = (double) d2d_screen_width;
dh = (double) d2d_screen_height;
temp = (dh / 3.0) * 4.0;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (float) dw;
*h = (float) dh;
*x = (float) dx;
*y = 0;
break;
case FULLSCR_SCALE_SQ:
dw = (double) d2d_screen_width;
dh = (double) d2d_screen_height;
temp = ((double) *w);
temp2 = ((double) *h);
dx = (dw / 2.0) - ((dh * temp) / (temp2 * 2.0));
dy = 0.0;
if (dx < 0.0)
hsr = dw / dh;
if (video_fullscreen_scale == FULLSCR_SCALE_43)
gsr = 4.0 / 3.0;
else
gsr = ((double) *w) / ((double) *h);
if (gsr <= hsr)
{
dx = 0.0;
dy = (dw / 2.0) - ((dh * temp2) / (temp * 2.0));
temp = dh * gsr;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (float) dw;
*h = (float) dh;
*x = (float) dx;
*y = 0;
}
else
{
temp = dw / gsr;
dy = (dh - temp) / 2.0;
dh = temp;
*w = (float) dw;
*h = (float) dh;
*x = 0;
*y = (float) dy;
}
dw -= (dx * 2.0);
dh -= (dy * 2.0);
*w = (float) dw;
*h = (float) dh;
*x = (float) dx;
*y = (float) dy;
break;
case FULLSCR_SCALE_INT:
@@ -137,33 +152,6 @@ d2d_stretch(float *w, float *h, float *x, float *y)
*x = (float) dx;
*y = (float) dy;
break;
case FULLSCR_SCALE_KEEPRATIO:
dw = (double) d2d_screen_width;
dh = (double) d2d_screen_height;
hsr = dw / dh;
gsr = ((double) *w) / ((double) *h);
if (gsr <= hsr)
{
temp = dh * gsr;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (float) dw;
*h = (float) dh;
*x = (float) dx;
*y = 0;
}
else
{
temp = dw / gsr;
dy = (dh - temp) / 2.0;
dh = temp;
*w = (float) dw;
*h = (float) dh;
*x = 0;
*y = (float) dy;
}
break;
}
}
#endif
@@ -179,7 +167,7 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h)
int yy;
D2D1_RECT_U rectU;
ID2D1Bitmap *fs_bitmap;
ID2D1Bitmap *fs_bitmap = 0;
ID2D1RenderTarget *RT;
float fs_x, fs_y;
@@ -188,6 +176,11 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h)
d2d_log("Direct2D: d2d_blit(x=%d, y=%d, y1=%d, y2=%d, w=%d, h=%d)\n", x, y, y1, y2, w, h);
if (!d2d_enabled) {
video_blit_complete();
return;
}
// TODO: Detect double scanned mode and resize render target
// appropriately for more clear picture
@@ -244,12 +237,12 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h)
if (video_grayscale || invert_display)
video_transform_copy(
(uint32_t *) &(((uint8_t *)srcdata)[yy * w * 4]),
&(((uint32_t *)buffer32->line[y + yy])[x]),
&(buffer32->line[y + yy][x]),
w);
else
memcpy(
(uint32_t *) &(((uint8_t *)srcdata)[yy * w * 4]),
&(((uint32_t *)buffer32->line[y + yy])[x]),
&(buffer32->line[y + yy][x]),
w * 4);
}
}
@@ -325,6 +318,12 @@ d2d_close(void)
{
d2d_log("Direct2D: d2d_close()\n");
/* Unregister our renderer! */
video_setblit(NULL);
if (d2d_enabled)
d2d_enabled = 0;
#ifdef USE_D2D
if (d2d_bitmap)
{
@@ -358,6 +357,12 @@ d2d_close(void)
d2d_hwnd = NULL;
old_hwndMain = NULL;
}
/* Unload the DLL if possible. */
if (d2d_handle != NULL) {
dynld_close((void *)d2d_handle);
d2d_handle = NULL;
}
#endif
}
@@ -372,7 +377,7 @@ d2d_init_common(int fs)
d2d_log("Direct2D: d2d_init_common(fs=%d)\n", fs);
cgapal_rebuild();
d2d_handle = dynld_module("d2d1.dll", d2d_imports);
if (fs)
{
@@ -404,10 +409,8 @@ d2d_init_common(int fs)
SetWindowPos(d2d_hwnd, HWND_TOPMOST, 0, 0, d2d_screen_width, d2d_screen_height, SWP_SHOWWINDOW);
}
if (SUCCEEDED(hr))
{
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, &d2d_factory);
}
hr = D2D1_CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, __uuidof(ID2D1Factory),
NULL, reinterpret_cast <void **>(&d2d_factory));
if (fs)
{
@@ -459,6 +462,8 @@ d2d_init_common(int fs)
return(0);
}
d2d_enabled = 1;
return(1);
}
#endif
@@ -501,7 +506,7 @@ d2d_pause(void)
void
d2d_take_screenshot(wchar_t *fn)
d2d_take_screenshot(const wchar_t *fn)
{
// Saving a screenshot of a Direct2D render target is harder than
// one would think. Keeping this stubbed for the moment
@@ -509,4 +514,11 @@ d2d_take_screenshot(wchar_t *fn)
d2d_log("Direct2D: d2d_take_screenshot(%s)\n", fn);
return;
}
}
void
d2d_enable(int enable)
{
d2d_enabled = enable;
}

View File

@@ -1,4 +1,4 @@
/*
/*
* 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
@@ -25,7 +25,8 @@ extern void d2d_close(void);
extern int d2d_init(HWND h);
extern int d2d_init_fs(HWND h);
extern int d2d_pause(void);
extern void d2d_take_screenshot(wchar_t *fn);
extern void d2d_take_screenshot(const wchar_t *fn);
extern void d2d_enable(int enable);
#ifdef __cplusplus
}

View File

@@ -8,15 +8,15 @@
*
* Rendering module for Microsoft Direct3D 9.
*
* Version: @(#)win_d3d.cpp 1.0.11 2018/05/26
* Version: @(#)win_d3d.cpp 1.0.12 2019/03/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
* Copyright 2017,2018 Fred N. van Kempen.
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
* Copyright 2017-2019 Fred N. van Kempen.
*/
#include <stdio.h>
#include <stdint.h>
@@ -45,6 +45,7 @@ static HWND d3d_hwnd;
static HWND d3d_device_window;
static int d3d_w,
d3d_h;
static volatile int d3d_enabled = 0;
static CUSTOMVERTEX d3d_verts[] = {
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
@@ -79,7 +80,12 @@ static void
d3d_size(RECT w_rect, double *l, double *t, double *r, double *b, int w, int h)
{
int ratio_w, ratio_h;
double hsr, gsr, ra, d;
double hsr, gsr, d, sh, sw, wh, ww, mh, mw;
sh = (double) (w_rect.bottom - w_rect.top);
sw = (double) (w_rect.right - w_rect.left);
wh = (double) h;
ww = (double) w;
switch (video_fullscreen_scale) {
case FULLSCR_SCALE_FULL:
@@ -87,28 +93,37 @@ d3d_size(RECT w_rect, double *l, double *t, double *r, double *b, int w, int h)
break;
case FULLSCR_SCALE_43:
*t = -0.5;
*b = (w_rect.bottom - w_rect.top) - 0.5;
*l = ((w_rect.right - w_rect.left) / 2) - (((w_rect.bottom - w_rect.top) * 4) / (3 * 2)) - 0.5;
*r = ((w_rect.right - w_rect.left) / 2) + (((w_rect.bottom - w_rect.top) * 4) / (3 * 2)) - 0.5;
if (*l < -0.5) {
*l = -0.5;
*r = (w_rect.right - w_rect.left) - 0.5;
*t = ((w_rect.bottom - w_rect.top) / 2) - (((w_rect.right - w_rect.left) * 3) / (4 * 2)) - 0.5;
*b = ((w_rect.bottom - w_rect.top) / 2) + (((w_rect.right - w_rect.left) * 3) / (4 * 2)) - 0.5;
case FULLSCR_SCALE_KEEPRATIO:
if (video_fullscreen_scale == FULLSCR_SCALE_43) {
mw = 4.0;
mh = 3.0;
} else {
mw = ww;
mh = wh;
}
break;
case FULLSCR_SCALE_SQ:
*t = -0.5;
*b = (w_rect.bottom - w_rect.top) - 0.5;
*l = ((w_rect.right - w_rect.left) / 2) - (((w_rect.bottom - w_rect.top) * w) / (h * 2)) - 0.5;
*r = ((w_rect.right - w_rect.left) / 2) + (((w_rect.bottom - w_rect.top) * w) / (h * 2)) - 0.5;
if (*l < -0.5) {
hsr = sw / sh;
gsr = mw / mh;
if (hsr > gsr) {
/* Host ratio is bigger than guest ratio. */
d = (sw - (mw * (sh / mh))) / 2.0;
*l = ((int) d) - 0.5;
*r = ((int) (sw - d)) - 0.5;
*t = -0.5;
*b = ((int) sh) - 0.5;
} else if (hsr < gsr) {
/* Host ratio is smaller or rqual than guest ratio. */
d = (sh - (mh * (sw / mw))) / 2.0;
*l = -0.5;
*r = (w_rect.right - w_rect.left) - 0.5;
*t = ((w_rect.bottom - w_rect.top) / 2) - (((w_rect.right - w_rect.left) * h) / (w * 2)) - 0.5;
*b = ((w_rect.bottom - w_rect.top) / 2) + (((w_rect.right - w_rect.left) * h) / (w * 2)) - 0.5;
*r = ((int) sw) - 0.5;
*t = ((int) d) - 0.5;
*b = ((int) (sh - d)) - 0.5;
} else {
/* Host ratio is equal to guest ratio. */
d3d_size_default(w_rect, l, t, r, b);
}
break;
@@ -123,37 +138,6 @@ d3d_size(RECT w_rect, double *l, double *t, double *r, double *b, int w, int h)
*b = ((w_rect.bottom - w_rect.top) / 2) + ((h * ratio_w) / 2) - 0.5;
break;
case FULLSCR_SCALE_KEEPRATIO:
hsr = ((double) (w_rect.right - w_rect.left)) / ((double) (w_rect.bottom - w_rect.top));
gsr = ((double) w) / ((double) h);
if (hsr > gsr) {
/* Host ratio is bigger than guest ratio. */
ra = ((double) (w_rect.bottom - w_rect.top)) / ((double) h);
d = ((double) w) * ra;
d = (((double) (w_rect.right - w_rect.left)) - d) / 2.0;
*l = ((int) d) - 0.5;
*r = (w_rect.right - w_rect.left) - ((int) d) - 0.5;
*t = -0.5;
*b = (w_rect.bottom - w_rect.top) - 0.5;
} else if (hsr < gsr) {
/* Host ratio is smaller or rqual than guest ratio. */
ra = ((double) (w_rect.right - w_rect.left)) / ((double) w);
d = ((double) h) * ra;
d = (((double) (w_rect.bottom - w_rect.top)) - d) / 2.0;
*l = -0.5;
*r = (w_rect.right - w_rect.left) - 0.5;
*t = ((int) d) - 0.5;
*b = (w_rect.bottom - w_rect.top) - ((int) d) - 0.5;
} else {
/* Host ratio is equal to guest ratio. */
d3d_size_default(w_rect, l, t, r, b);
}
break;
}
}
@@ -169,6 +153,11 @@ d3d_blit_fs(int x, int y, int y1, int y2, int w, int h)
int yy;
double l = 0, t = 0, r = 0, b = 0;
if (!d3d_enabled) {
video_blit_complete();
return;
}
if ((y1 == y2) || (h <= 0)) {
video_blit_complete();
return; /*Nothing to do*/
@@ -187,9 +176,9 @@ d3d_blit_fs(int x, int y, int y1, int y2, int w, int h)
for (yy = y1; yy < y2; yy++) {
if (buffer32) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w);
video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(buffer32->line[yy + y][x]), w);
else
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(buffer32->line[yy + y][x]), w * 4);
}
}
@@ -282,6 +271,11 @@ d3d_blit(int x, int y, int y1, int y2, int w, int h)
RECT r;
int yy;
if (!d3d_enabled) {
video_blit_complete();
return;
}
if ((y1 == y2) || (h <= 0)) {
video_blit_complete();
return; /*Nothing to do*/
@@ -298,9 +292,9 @@ d3d_blit(int x, int y, int y1, int y2, int w, int h)
if (buffer32) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w);
video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(buffer32->line[yy + y][x]), w);
else
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(buffer32->line[yy + y][x]), w * 4);
}
}
}
@@ -415,8 +409,6 @@ d3d_init(HWND h)
{
d3d_hwnd = h;
cgapal_rebuild();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
memset(&d3dpp, 0, sizeof(d3dpp));
@@ -444,6 +436,8 @@ d3d_init(HWND h)
video_setblit(d3d_blit);
d3d_enabled = 1;
return(1);
}
@@ -453,8 +447,6 @@ d3d_init_fs(HWND h)
{
WCHAR title[200];
cgapal_rebuild();
d3d_w = GetSystemMetrics(SM_CXSCREEN);
d3d_h = GetSystemMetrics(SM_CYSCREEN);
@@ -504,6 +496,8 @@ d3d_init_fs(HWND h)
video_setblit(d3d_blit_fs);
d3d_enabled = 1;
return(1);
}
@@ -527,6 +521,9 @@ d3d_close(void)
{
video_setblit(NULL);
if (d3d_enabled)
d3d_enabled = 0;
d3d_close_objects();
if (d3ddev) {
@@ -634,8 +631,130 @@ d3d_pause(void)
}
#ifndef USE_D3DX
static void
SavePNG(wchar_t *szFilename, D3DSURFACE_DESC *surfaceDesc, D3DLOCKED_RECT *d3dlr)
{
BITMAPINFO bmpInfo;
HDC hdc;
LPVOID pBuf = NULL;
LPVOID pBuf2 = NULL;
png_bytep *b_rgb = NULL;
int i;
/* create file */
FILE *fp = plat_fopen(szFilename, (wchar_t *) L"wb");
if (!fp) {
ddraw_log("[SavePNG] File %ls could not be opened for writing", szFilename);
return;
}
/* initialize stuff */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
ddraw_log("[SavePNG] png_create_write_struct failed");
fclose(fp);
return;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
ddraw_log("[SavePNG] png_create_info_struct failed");
fclose(fp);
return;
}
png_init_io(png_ptr, fp);
hdc = GetDC(NULL);
ZeroMemory(&bmpInfo, sizeof(BITMAPINFO));
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
GetDIBits(hdc, hBitmap, 0, 0, NULL, &bmpInfo, DIB_RGB_COLORS);
if (bmpInfo.bmiHeader.biSizeImage <= 0)
bmpInfo.bmiHeader.biSizeImage =
bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
pBuf = malloc(bmpInfo.bmiHeader.biSizeImage);
if (pBuf == NULL) {
ddraw_log("[SavePNG] Unable to Allocate Bitmap Memory");
fclose(fp);
return;
}
if (ys2 <= 250) {
pBuf2 = malloc(bmpInfo.bmiHeader.biSizeImage << 1);
if (pBuf2 == NULL) {
ddraw_log("[SavePNG] Unable to Allocate Secondary Bitmap Memory");
free(pBuf);
fclose(fp);
return;
}
}
ddraw_log("save png w=%i h=%i\n", bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight);
bmpInfo.bmiHeader.biCompression = BI_RGB;
GetDIBits(hdc, hBitmap, 0, bmpInfo.bmiHeader.biHeight, pBuf, &bmpInfo, DIB_RGB_COLORS);
if (pBuf2) {
bmpInfo.bmiHeader.biSizeImage <<= 1;
bmpInfo.bmiHeader.biHeight <<= 1;
}
png_set_IHDR(png_ptr, info_ptr, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight,
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
b_rgb = (png_bytep *) malloc(sizeof(png_bytep) * bmpInfo.bmiHeader.biHeight);
if (b_rgb == NULL) {
ddraw_log("[SavePNG] Unable to Allocate RGB Bitmap Memory");
free(pBuf2);
free(pBuf);
fclose(fp);
return;
}
for (i = 0; i < bmpInfo.bmiHeader.biHeight; i++) {
b_rgb[i] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr));
}
if (pBuf2) {
DoubleLines((uint8_t *) pBuf2, (uint8_t *) pBuf);
bgra_to_rgb(b_rgb, (uint8_t *) pBuf2, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight);
} else
bgra_to_rgb(b_rgb, (uint8_t *) pBuf, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight);
png_write_info(png_ptr, info_ptr);
png_write_image(png_ptr, b_rgb);
png_write_end(png_ptr, NULL);
/* cleanup heap allocation */
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 (pBuf2) free(pBuf2);
if (pBuf) free(pBuf);
if (fp) fclose(fp);
}
#endif
void
d3d_take_screenshot(wchar_t *fn)
d3d_take_screenshot(const wchar_t *fn)
{
#ifdef USE_D3DX
LPDIRECT3DSURFACE9 d3dSurface = NULL;
@@ -650,6 +769,28 @@ d3d_take_screenshot(wchar_t *fn)
#else
/* TODO: how to take screenshot without d3dx?
just a stub for now */
pclog("Direct3D: d3d_take_screenshot(%s)\n", fn);
LPDIRECT3DSURFACE9 d3dSurface = NULL;
D3DSURFACE_DESC surfaceDesc;
D3DLOCKED_RECT d3dlr;
BYTE *pSurfaceBuffer;
if (! d3dTexture) return;
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &d3dSurface);
d3dSurface->GetDesc(&surfaceDesc);
d3dSurface->LockRect(&d3dlr, 0, D3DLOCK_DONOTWAIT);
pSurfaceBuffer = (BYTE *) d3dlr.pBits + d3dlr.Pitch * (surfaceDesc.Height - 1);
D3DXSaveSurfaceToFile(fn, D3DXIFF_PNG, d3dSurface, NULL, NULL);
d3dSurface->Release();
d3dSurface = NULL;
#endif
}
void
d3d_enable(int enable)
{
d3d_enabled = enable;
}

View File

@@ -36,7 +36,8 @@ 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);
extern void d3d_take_screenshot(const wchar_t *fn);
extern void d3d_enable(int enable);
#ifdef __cplusplus
}

View File

@@ -11,15 +11,15 @@
* 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.13 2018/11/18
* Version: @(#)win_ddraw.cpp 1.0.14 2019/03/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
* Copyright 2017,2018 Fred N. van Kempen.
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
* Copyright 2017-2019 Fred N. van Kempen.
*/
#include <stdarg.h>
#include <stdint.h>
@@ -53,6 +53,7 @@ static HWND ddraw_hwnd;
static HBITMAP hbitmap;
static int ddraw_w, ddraw_h,
xs, ys, ys2;
static volatile int ddraw_enabled = 0;
static png_structp png_ptr;
static png_infop info_ptr;
@@ -133,7 +134,7 @@ DoubleLines(uint8_t *dst, uint8_t *src)
static void
SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
SavePNG(const wchar_t *szFilename, HBITMAP hBitmap)
{
BITMAPINFO bmpInfo;
HDC hdc;
@@ -143,7 +144,7 @@ SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
int i;
/* create file */
FILE *fp = plat_fopen(szFilename, (wchar_t *) L"wb");
FILE *fp = plat_fopen((wchar_t *) szFilename, (wchar_t *) L"wb");
if (!fp) {
ddraw_log("[SavePNG] File %ls could not be opened for writing", szFilename);
return;
@@ -266,38 +267,52 @@ static void
ddraw_fs_size(RECT w_rect, RECT *r_dest, int w, int h)
{
int ratio_w, ratio_h;
double hsr, gsr, ra, d;
double hsr, gsr, d, sh, sw, wh, ww, mh, mw;
ddraw_log("video_fullscreen_scale = %i\n", video_fullscreen_scale);
sh = (double) (w_rect.bottom - w_rect.top);
sw = (double) (w_rect.right - w_rect.left);
wh = (double) h;
ww = (double) w;
switch (video_fullscreen_scale) {
case FULLSCR_SCALE_FULL:
ddraw_fs_size_default(w_rect, r_dest);
break;
case FULLSCR_SCALE_43:
r_dest->top = 0;
r_dest->bottom = (w_rect.bottom - w_rect.top) - 1;
r_dest->left = ((w_rect.right - w_rect.left) / 2) - (((w_rect.bottom - w_rect.top) * 4) / (3 * 2));
r_dest->right = ((w_rect.right - w_rect.left) / 2) + (((w_rect.bottom - w_rect.top) * 4) / (3 * 2)) - 1;
if (r_dest->left < 0) {
r_dest->left = 0;
r_dest->right = (w_rect.right - w_rect.left) - 1;
r_dest->top = ((w_rect.bottom - w_rect.top) / 2) - (((w_rect.right - w_rect.left) * 3) / (4 * 2));
r_dest->bottom = ((w_rect.bottom - w_rect.top) / 2) + (((w_rect.right - w_rect.left) * 3) / (4 * 2)) - 1;
case FULLSCR_SCALE_KEEPRATIO:
if (video_fullscreen_scale == FULLSCR_SCALE_43) {
mw = 4.0;
mh = 3.0;
} else {
mw = ww;
mh = wh;
}
break;
case FULLSCR_SCALE_SQ:
r_dest->top = 0;
r_dest->bottom = (w_rect.bottom - w_rect.top) - 1;
r_dest->left = ((w_rect.right - w_rect.left) / 2) - (((w_rect.bottom - w_rect.top) * w) / (h * 2));
r_dest->right = ((w_rect.right - w_rect.left) / 2) + (((w_rect.bottom - w_rect.top) * w) / (h * 2)) - 1;
if (r_dest->left < 0) {
hsr = sw / sh;
gsr = mw / mh;
if (hsr > gsr) {
/* Host ratio is bigger than guest ratio. */
d = (sw - (mw * (sh / mh))) / 2.0;
r_dest->left = (int) d;
r_dest->right = (int) (sw - d - 1.0);
r_dest->top = 0;
r_dest->bottom = (int) (sh - 1.0);
} else if (hsr < gsr) {
/* Host ratio is smaller or rqual than guest ratio. */
d = (sh - (mh * (sw / mw))) / 2.0;
r_dest->left = 0;
r_dest->right = (w_rect.right - w_rect.left) - 1;
r_dest->top = ((w_rect.bottom - w_rect.top) / 2) - (((w_rect.right - w_rect.left) * h) / (w * 2));
r_dest->bottom = ((w_rect.bottom - w_rect.top) / 2) + (((w_rect.right - w_rect.left) * h) / (w * 2)) - 1;
r_dest->right = (int) (sw - 1.0);
r_dest->top = (int) d;
r_dest->bottom = (int) (sh - d - 1.0);
} else {
/* Host ratio is equal to guest ratio. */
ddraw_fs_size_default(w_rect, r_dest);
}
break;
@@ -311,38 +326,6 @@ ddraw_fs_size(RECT w_rect, RECT *r_dest, int w, int h)
r_dest->top = ((w_rect.bottom - w_rect.top) / 2) - ((h * ratio_w) / 2);
r_dest->bottom = ((w_rect.bottom - w_rect.top) / 2) + ((h * ratio_w) / 2) - 1;
break;
case FULLSCR_SCALE_KEEPRATIO:
hsr = ((double) (w_rect.right - w_rect.left)) / ((double) (w_rect.bottom - w_rect.top));
gsr = ((double) w) / ((double) h);
if (hsr > gsr) {
/* Host ratio is bigger than guest ratio. */
ra = ((double) (w_rect.bottom - w_rect.top)) / ((double) h);
d = ((double) w) * ra;
d = (((double) (w_rect.right - w_rect.left)) - d) / 2.0;
r_dest->left = ((int) d);
r_dest->right = (w_rect.right - w_rect.left) - ((int) d) - 1;
r_dest->top = 0;
r_dest->bottom = (w_rect.bottom - w_rect.top) - 1;
} else if (hsr < gsr) {
/* Host ratio is smaller or rqual than guest ratio. */
ra = ((double) (w_rect.right - w_rect.left)) / ((double) w);
d = ((double) h) * ra;
d = (((double) (w_rect.bottom - w_rect.top)) - d) / 2.0;
r_dest->left = 0;
r_dest->right = (w_rect.right - w_rect.left) - 1;
r_dest->top = ((int) d);
r_dest->bottom = (w_rect.bottom - w_rect.top) - ((int) d) - 1;
} else {
/* Host ratio is equal to guest ratio. */
ddraw_fs_size_default(w_rect, r_dest);
}
break;
}
}
@@ -357,6 +340,11 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
HRESULT hr;
DDBLTFX ddbltfx;
if (!ddraw_enabled) {
video_blit_complete();
return;
}
if (lpdds_back == NULL) {
video_blit_complete();
return; /*Nothing to do*/
@@ -386,9 +374,9 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
for (yy = y1; yy < y2; yy++) {
if (buffer32) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w);
video_transform_copy((uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(buffer32->line[y + yy][x]), w);
else
memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(buffer32->line[y + yy][x]), w * 4);
}
}
video_blit_complete();
@@ -434,6 +422,11 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
HRESULT hr;
int yy;
if (!ddraw_enabled) {
video_blit_complete();
return;
}
if (lpdds_back == NULL) {
video_blit_complete();
return; /*Nothing to do*/
@@ -465,9 +458,9 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
if (buffer32) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w);
video_transform_copy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(buffer32->line[y + yy][x]), w);
else
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(buffer32->line[y + yy][x]), w * 4);
}
}
}
@@ -503,7 +496,7 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
void
ddraw_take_screenshot(wchar_t *fn)
ddraw_take_screenshot(const wchar_t *fn)
{
#if 0
xs = xsize;
@@ -541,8 +534,6 @@ 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)))
@@ -600,6 +591,8 @@ ddraw_init(HWND h)
video_setblit(ddraw_blit);
ddraw_enabled = 1;
return(1);
}
@@ -610,8 +603,6 @@ 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;
@@ -658,6 +649,8 @@ ddraw_init_fs(HWND h)
video_setblit(ddraw_blit_fs);
ddraw_enabled = 1;
return(1);
}
@@ -667,6 +660,9 @@ ddraw_close(void)
{
video_setblit(NULL);
if (ddraw_enabled)
ddraw_enabled = 0;
if (lpdds_back2) {
lpdds_back2->Release();
lpdds_back2 = NULL;
@@ -695,3 +691,10 @@ ddraw_pause(void)
{
return(0);
}
void
ddraw_enable(int enable)
{
ddraw_enabled = enable;
}

View File

@@ -32,7 +32,8 @@ 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);
extern void ddraw_take_screenshot(const wchar_t *fn);
extern void ddraw_enable(int enable);
#ifdef __cplusplus
}

View File

@@ -126,8 +126,8 @@ void joystick_init()
memcpy(plat_joystick_state[c].button[7].name, XINPUT_NAME_RT, sizeof(XINPUT_NAME_RT));
memcpy(plat_joystick_state[c].button[8].name, XINPUT_NAME_BACK, sizeof(XINPUT_NAME_BACK));
memcpy(plat_joystick_state[c].button[9].name, XINPUT_NAME_START, sizeof(XINPUT_NAME_START));
memcpy(plat_joystick_state[c].button[10].name, XINPUT_NAME_LS, sizeof(XINPUT_NAME_RS));
memcpy(plat_joystick_state[c].button[11].name, XINPUT_NAME_RS, sizeof(XINPUT_NAME_LS));
memcpy(plat_joystick_state[c].button[10].name, XINPUT_NAME_LS, sizeof(XINPUT_NAME_LS));
memcpy(plat_joystick_state[c].button[11].name, XINPUT_NAME_RS, sizeof(XINPUT_NAME_RS));
plat_joystick_state[c].nr_povs = 0;

View File

@@ -39,17 +39,16 @@ static uint16_t scancode_map[768];
static UINT16
convert_scan_code(UINT16 scan_code)
{
if ((scan_code & 0xFF00) == 0xE000) {
scan_code &= 0x00FF;
scan_code |= 0x0100;
} else if (scan_code == 0xE11D)
scan_code = 0xE000;
if ((scan_code & 0xff00) == 0xe000)
scan_code = (scan_code & 0xff) | 0x0100;
if (scan_code == 0xE11D)
scan_code = 0x0100;
/* E0 00 is sent by some USB keyboards for their special keys, as it is an
invalid scan code (it has no untranslated set 2 equivalent), we mark it
appropriately so it does not get passed through. */
else if ((scan_code > 0x00FF) || (scan_code == 0xE000)) {
else if ((scan_code > 0x01FF) || (scan_code == 0x0100))
scan_code = 0xFFFF;
}
return scan_code;
}
@@ -138,12 +137,14 @@ keyboard_handle(LPARAM lParam, int infocus)
/* If it's not a scan code that starts with 0xE1 */
if (!(rawKB.Flags & RI_KEY_E1)) {
if (rawKB.Flags & RI_KEY_E0)
scancode |= (0xE0 << 8);
scancode |= 0x100;
/* Translate the scan code to 9-bit */
scancode = convert_scan_code(scancode);
/* Remap it according to the list from the Registry */
if (scancode != scancode_map[scancode])
pclog("Scan code remap: %03X -> %03X\n", scancode, scancode);
scancode = scancode_map[scancode];
/* If it's not 0xFFFF, send it to the emulated

View File

@@ -12,13 +12,13 @@
* we will not use that, but, instead, use a new window which
* coverrs the entire desktop.
*
* Version: @(#)win_sdl.c 1.0.5 2019/02/08
* Version: @(#)win_sdl.c 1.0.6 2019/03/09
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Michael Dr<44>ing, <michael@drueing.de>
*
* Copyright 2018 Fred N. van Kempen.
* Copyright 2018 Michael Dr<44>ing.
* Copyright 2018,2019 Fred N. van Kempen.
* Copyright 2018,2019 Michael Dr<44>ing.
*
* Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that the
@@ -87,9 +87,11 @@ static HWND sdl_hwnd = NULL;
static int sdl_w, sdl_h;
static int sdl_fs;
static int cur_w, cur_h;
static volatile int sdl_enabled = 0;
static SDL_mutex* sdl_mutex = NULL;
static png_structp png_ptr;
static png_infop info_ptr;
static png_structp png_ptr;
static png_infop info_ptr;
/* Pointers to the real functions. */
@@ -125,6 +127,11 @@ static int (*sdl_RenderReadPixels)(SDL_Renderer* renderer,
int pitch);
static SDL_bool (*sdl_SetHint)(const char* name,
const char* value);
static SDL_mutex* (*sdl_CreateMutex)(void);
static void (*sdl_DestroyMutex)(SDL_mutex* mutex);
static int (*sdl_LockMutex)(SDL_mutex* mutex);
static int (*sdl_UnlockMutex)(SDL_mutex* mutex);
static dllimp_t sdl_imports[] = {
{ "SDL_GetVersion", &sdl_GetVersion },
@@ -144,6 +151,10 @@ static dllimp_t sdl_imports[] = {
{ "SDL_GetWindowSize", &sdl_GetWindowSize },
{ "SDL_RenderReadPixels", &sdl_RenderReadPixels },
{ "SDL_SetHint", &sdl_SetHint },
{ "SDL_CreateMutex", &sdl_CreateMutex },
{ "SDL_DestroyMutex", &sdl_DestroyMutex },
{ "SDL_LockMutex", &sdl_LockMutex },
{ "SDL_UnlockMutex", &sdl_UnlockMutex },
{ NULL, NULL }
};
@@ -181,33 +192,31 @@ sdl_stretch(int *w, int *h, int *x, int *y)
*y = 0;
break;
case FULLSCR_SCALE_43:
case FULLSCR_SCALE_KEEPRATIO:
dw = (double) sdl_w;
dh = (double) sdl_h;
temp = (dh / 3.0) * 4.0;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = 0;
break;
case FULLSCR_SCALE_SQ:
dw = (double) sdl_w;
dh = (double) sdl_h;
temp = ((double) *w);
temp2 = ((double) *h);
dx = (dw / 2.0) - ((dh * temp) / (temp2 * 2.0));
dy = 0.0;
if (dx < 0.0) {
dx = 0.0;
dy = (dw / 2.0) - ((dh * temp2) / (temp * 2.0));
hsr = dw / dh;
if (video_fullscreen_scale == FULLSCR_SCALE_43)
gsr = 4.0 / 3.0;
else
gsr = ((double) *w) / ((double) *h);
if (gsr <= hsr) {
temp = dh * gsr;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = 0;
} else {
temp = dw / gsr;
dy = (dh - temp) / 2.0;
dh = temp;
*w = (int) dw;
*h = (int) dh;
*x = 0;
*y = (int) dy;
}
dw -= (dx * 2.0);
dh -= (dy * 2.0);
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = (int) dy;
break;
case FULLSCR_SCALE_INT:
dw = (double) sdl_w;
@@ -227,29 +236,6 @@ sdl_stretch(int *w, int *h, int *x, int *y)
*x = (int) dx;
*y = (int) dy;
break;
case FULLSCR_SCALE_KEEPRATIO:
dw = (double) sdl_w;
dh = (double) sdl_h;
hsr = dw / dh;
gsr = ((double) *w) / ((double) *h);
if (gsr <= hsr) {
temp = dh * gsr;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = 0;
} else {
temp = dw / gsr;
dy = (dh - temp) / 2.0;
dh = temp;
*w = (int) dw;
*h = (int) dh;
*x = 0;
*y = (int) dy;
}
break;
}
}
@@ -262,7 +248,12 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
int pitch;
int yy, ret;
if (y1 == y2) {
if (!sdl_enabled) {
video_blit_complete();
return;
}
if ((y1 == y2) || (h <= 0)) {
video_blit_complete();
return;
}
@@ -272,6 +263,8 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
return;
}
sdl_LockMutex(sdl_mutex);
/*
* TODO:
* SDL_UpdateTexture() might be better here, as it is
@@ -282,9 +275,9 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
for (yy = y1; yy < y2; yy++) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w);
video_transform_copy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(buffer32->line[y + yy][x]), w);
else
memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(buffer32->line[y + yy][x]), w * 4);
}
}
@@ -309,6 +302,8 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
sdl_log("SDL: unable to copy texture to renderer (%s)\n", sdl_GetError());
sdl_RenderPresent(sdl_render);
sdl_UnlockMutex(sdl_mutex);
}
@@ -318,6 +313,14 @@ sdl_close(void)
/* Unregister our renderer! */
video_setblit(NULL);
if (sdl_enabled)
sdl_enabled = 0;
if (sdl_mutex != NULL) {
sdl_DestroyMutex(sdl_mutex);
sdl_mutex = NULL;
}
if (sdl_tex != NULL) {
sdl_DestroyTexture(sdl_tex);
sdl_tex = NULL;
@@ -340,7 +343,8 @@ sdl_close(void)
SetFocus(hwndMain);
DestroyWindow(sdl_hwnd);
if (sdl_fs)
DestroyWindow(sdl_hwnd);
sdl_hwnd = NULL;
}
@@ -372,8 +376,6 @@ sdl_init_common(int fs)
sdl_log("SDL: init (fs=%d)\n", fs);
cgapal_rebuild();
/* Try loading the DLL. */
sdl_handle = dynld_module(PATH_SDL_DLL, sdl_imports);
if (sdl_handle == NULL) {
@@ -498,6 +500,10 @@ sdl_init_common(int fs)
sdl_fs = fs;
sdl_enabled = 1;
sdl_mutex = sdl_CreateMutex();
return(1);
}
@@ -619,13 +625,20 @@ sdl_resize(int x, int y)
if ((x == cur_w) && (y == cur_h))
return;
sdl_log("sdl_resize(%i, %i)\n", x, y);
ww = x;
wh = y;
sdl_stretch(&ww, &wh, &wx, &wy);
MoveWindow(sdl_hwnd, wx, wy, ww, wh, TRUE);
if (sdl_fs)
MoveWindow(sdl_hwnd, wx, wy, ww, wh, TRUE);
cur_w = x;
cur_h = y;
}
void
sdl_enable(int enable)
{
sdl_enabled = enable;
}

View File

@@ -55,6 +55,7 @@ extern int sdl_init(HWND h);
extern int sdl_init_fs(HWND h);
extern int sdl_pause(void);
extern void sdl_resize(int x, int y);
extern void sdl_enable(int enable);
extern void sdl_take_screenshot(const wchar_t *fn);

View File

@@ -1,571 +0,0 @@
/*
* 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.
*
* Implementation of host serial port services for Win32.
*
* This code is based on a universal serial port driver for
* Windows and UNIX systems, with support for FTDI and Prolific
* USB ports. Support for these has been removed.
*
* Version: @(#)win_serial.c 1.0.6 2017/10/16
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2017 Fred N. van Kempen.
*/
#include <windows.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define PLAT_SERIAL_C
#include "../86box.h"
#include "../plat.h"
#include "../plat_serial.h"
/* Handle the receiving of data from the host port. */
static void
bhtty_reader(void *arg)
{
BHTTY *pp = (BHTTY *)arg;
unsigned char b;
DWORD n;
pclog("%s: thread started\n", pp->name);
/* As long as the channel is open.. */
while (pp->tid != NULL) {
/* Post a READ on the device. */
n = 0;
if (ReadFile(pp->handle, &b, (DWORD)1, &n, &pp->rov) == FALSE) {
n = GetLastError();
if (n != ERROR_IO_PENDING) {
/* Not good, we got an error. */
pclog("%s: I/O error %d in read!\n", pp->name, n);
break;
}
/* The read is pending, wait for it.. */
if (GetOverlappedResult(pp->handle, &pp->rov, &n, TRUE) == FALSE) {
n = GetLastError();
pclog("%s: I/O error %d in read!\n", pp->name, n);
break;
}
}
pclog("%s: got %d bytes of data\n", pp->name, n);
if (n == 1) {
/* We got data, update stuff. */
if (pp->icnt < sizeof(pp->buff)) {
pclog("%s: queued byte %02x (%d)\n", pp->name, b, pp->icnt+1);
pp->buff[pp->ihead++] = b;
pp->ihead &= (sizeof(pp->buff)-1);
pp->icnt++;
/* Do a callback to let them know. */
if (pp->rd_done != NULL)
pp->rd_done(pp->rd_arg, n);
} else {
pclog("%s: RX buffer overrun!\n", pp->name);
}
}
}
/* Error or done, clean up. */
pp->tid = NULL;
pclog("%s: thread stopped.\n", pp->name);
}
/* Set the state of a port. */
int
bhtty_sstate(BHTTY *pp, void *arg)
{
/* Make sure we can do this. */
if (arg == NULL) {
pclog("%s: invalid argument\n", pp->name);
return(-1);
}
if (SetCommState(pp->handle, (DCB *)arg) == FALSE) {
/* Mark an error. */
pclog("%s: set state: %d\n", pp->name, GetLastError());
return(-1);
}
return(0);
}
/* Fetch the state of a port. */
int
bhtty_gstate(BHTTY *pp, void *arg)
{
/* Make sure we can do this. */
if (arg == NULL) {
pclog("%s: invalid argument\n", pp->name);
return(-1);
}
if (GetCommState(pp->handle, (DCB *)arg) == FALSE) {
/* Mark an error. */
pclog("%s: get state: %d\n", pp->name, GetLastError());
return(-1);
}
return(0);
}
/* Enable or disable RTS/CTS mode (hardware handshaking.) */
int
bhtty_crtscts(BHTTY *pp, char yesno)
{
/* Get the current mode. */
if (bhtty_gstate(pp, &pp->dcb) < 0) return(-1);
switch(yesno) {
case 0: /* disable CRTSCTS */
pp->dcb.fOutxDsrFlow = 0; /* disable DSR/DCD mode */
pp->dcb.fDsrSensitivity = 0;
pp->dcb.fOutxCtsFlow = 0; /* disable RTS/CTS mode */
pp->dcb.fTXContinueOnXoff = 0; /* disable XON/XOFF mode */
pp->dcb.fOutX = 0;
pp->dcb.fInX = 0;
break;
case 1: /* enable CRTSCTS */
pp->dcb.fOutxDsrFlow = 0; /* disable DSR/DCD mode */
pp->dcb.fDsrSensitivity = 0;
pp->dcb.fOutxCtsFlow = 1; /* enable RTS/CTS mode */
pp->dcb.fTXContinueOnXoff = 0; /* disable XON/XOFF mode */
pp->dcb.fOutX = 0;
pp->dcb.fInX = 0;
break;
default:
pclog("%s: invalid parameter '%d'!\n", pp->name, yesno);
return(-1);
}
/* Set new mode. */
if (bhtty_sstate(pp, &pp->dcb) < 0) return(-1);
return(0);
}
/* Set the port parameters. */
int
bhtty_params(BHTTY *pp, char dbit, char par, char sbit)
{
/* Get the current mode. */
if (bhtty_gstate(pp, &pp->dcb) < 0) return(-1);
/* Set the desired word length. */
switch((int)dbit) {
case -1: /* no change */
break;
case 5: /* FTDI doesnt like these */
case 6:
case 9:
break;
case 7:
case 8:
pp->dcb.ByteSize = dbit;
break;
default:
pclog("%s: invalid parameter '%d'!\n", pp->name, dbit);
return(-1);
}
/* Set the type of parity encoding. */
switch((int)par) {
case -1: /* no change */
case ' ':
break;
case 0:
case 'N':
pp->dcb.fParity = FALSE;
pp->dcb.Parity = NOPARITY;
break;
case 1:
case 'O':
pp->dcb.fParity = TRUE;
pp->dcb.Parity = ODDPARITY;
break;
case 2:
case 'E':
pp->dcb.fParity = TRUE;
pp->dcb.Parity = EVENPARITY;
break;
case 3:
case 'M':
case 4:
case 'S':
break;
default:
pclog("%s: invalid parameter '%c'!\n", pp->name, par);
return(-1);
}
/* Set the number of stop bits. */
switch((int)sbit) {
case -1: /* no change */
break;
case 1:
pp->dcb.StopBits = ONESTOPBIT;
break;
case 2:
pp->dcb.StopBits = TWOSTOPBITS;
break;
default:
pclog("%s: invalid parameter '%d'!\n", pp->name, sbit);
return(-1);
}
/* Set new mode. */
if (bhtty_sstate(pp, &pp->dcb) < 0) return(-1);
return(0);
}
/* Put a port in transparent ("raw") state. */
void
bhtty_raw(BHTTY *pp, void *arg)
{
DCB *dcb = (DCB *)arg;
/* Make sure we can do this. */
if (arg == NULL) {
pclog("%s: invalid parameter\n", pp->name);
return;
}
/* Enable BINARY transparent mode. */
dcb->fBinary = 1;
dcb->fErrorChar = 0; /* disable Error Replacement */
dcb->fNull = 0; /* disable NUL stripping */
/* Disable the DTR and RTS lines. */
dcb->fDtrControl = DTR_CONTROL_DISABLE; /* DTR line */
dcb->fRtsControl = RTS_CONTROL_DISABLE; /* RTS line */
/* Disable DSR/DCD handshaking. */
dcb->fOutxDsrFlow = 0; /* DSR handshaking */
dcb->fDsrSensitivity = 0; /* DSR Sensitivity */
/* Disable RTS/CTS handshaking. */
dcb->fOutxCtsFlow = 0; /* CTS handshaking */
/* Disable XON/XOFF handshaking. */
dcb->fTXContinueOnXoff = 0; /* continue TX after Xoff */
dcb->fOutX = 0; /* enable output X-ON/X-OFF */
dcb->fInX = 0; /* enable input X-ON/X-OFF */
dcb->XonChar = 0x11; /* ASCII XON */
dcb->XoffChar = 0x13; /* ASCII XOFF */
dcb->XonLim = 100;
dcb->XoffLim = 100;
dcb->fParity = FALSE;
dcb->Parity = NOPARITY;
dcb->StopBits = ONESTOPBIT;
dcb->BaudRate = CBR_1200;
}
/* Set the port speed. */
int
bhtty_speed(BHTTY *pp, long speed)
{
/* Get the current mode and speed. */
if (bhtty_gstate(pp, &pp->dcb) < 0) return(-1);
/*
* Set speed.
*
* This is not entirely correct, we should use a table
* with DCB_xxx speed values here, but we removed that
* and just hardcode the speed value into DCB. --FvK
*/
pp->dcb.BaudRate = speed;
/* Set new speed. */
if (bhtty_sstate(pp, &pp->dcb) < 0) return(-1);
return(0);
}
/* Clean up and flush. */
int
bhtty_flush(BHTTY *pp)
{
DWORD dwErrs;
COMSTAT cst;
/* First, clear any errors. */
(void)ClearCommError(pp->handle, &dwErrs, &cst);
/* Now flush all buffers. */
if (PurgeComm(pp->handle,
(PURGE_RXABORT | PURGE_TXABORT | \
PURGE_RXCLEAR | PURGE_TXCLEAR)) == FALSE) {
pclog("%s: flush: %d\n", pp->name, GetLastError());
return(-1);
}
/* Re-clear any errors. */
if (ClearCommError(pp->handle, &dwErrs, &cst) == FALSE) {
pclog("%s: clear errors: %d\n", pp->name, GetLastError());
return(-1);
}
return(0);
}
/* Close an open serial port. */
void
bhtty_close(BHTTY *pp)
{
/* If the polling thread is running, stop it. */
(void)bhtty_active(pp, 0);
/* Close the event handles. */
if (pp->rov.hEvent != INVALID_HANDLE_VALUE)
CloseHandle(pp->rov.hEvent);
if (pp->wov.hEvent != INVALID_HANDLE_VALUE)
CloseHandle(pp->wov.hEvent);
if (pp->handle != INVALID_HANDLE_VALUE) {
pclog("%s: closing host port\n", pp->name);
/* Restore the previous port state, if any. */
(void)bhtty_sstate(pp, &pp->odcb);
/* Close the port. */
CloseHandle(pp->handle);
pp->handle = INVALID_HANDLE_VALUE;
}
/* Release the control block. */
free(pp);
}
/* Open a host serial port for I/O. */
BHTTY *
bhtty_open(char *port, int tmo)
{
char temp[84];
COMMTIMEOUTS to;
COMMCONFIG conf;
BHTTY *pp;
DWORD d;
/* First things first... create a control block. */
if ((pp = (BHTTY *)malloc(sizeof(BHTTY))) == NULL) {
pclog("%s: out of memory!\n", port);
return(NULL);
}
memset(pp, 0x00, sizeof(BHTTY));
strncpy(pp->name, port, sizeof(pp->name)-1);
/* Try a regular Win32 serial port. */
sprintf(temp, "\\\\.\\%s", pp->name);
if ((pp->handle = CreateFile(temp,
(GENERIC_READ|GENERIC_WRITE),
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0)) == INVALID_HANDLE_VALUE) {
pclog("%s: open port: %d\n", pp->name, GetLastError());
free(pp);
return(NULL);
}
/* Create event handles. */
pp->rov.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
pp->wov.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
/* Set up buffer size of the port. */
if (SetupComm(pp->handle, 32768L, 32768L) == FALSE) {
/* This fails on FTDI-based devices. */
pclog("%s: set buffers: %d\n", pp->name, GetLastError());
#if 0
CloseHandle(pp->handle);
free(pp);
return(NULL);
#endif
}
/* Grab default config for the driver and set it. */
d = sizeof(COMMCONFIG);
memset(&conf, 0x00, d);
conf.dwSize = d;
if (GetDefaultCommConfig(temp, &conf, &d) == TRUE) {
/* Change config here... */
/* Set new configuration. */
if (SetCommConfig(pp->handle, &conf, d) == FALSE) {
/* This fails on FTDI-based devices. */
pclog("%s: set configuration: %d\n", pp->name, GetLastError());
#if 0
CloseHandle(pp->handle);
free(pp);
return(NULL);
#endif
}
}
pclog("%s: host port '%s' open\n", pp->name, temp);
/*
* We now have an open port. To allow for clean exit
* of the application, we first retrieve the port's
* current settings, and save these for later.
*/
if (bhtty_gstate(pp, &pp->odcb) < 0) {
(void)bhtty_close(pp);
return(NULL);
}
memcpy(&pp->dcb, &pp->odcb, sizeof(DCB));
/* Force the port to BINARY mode. */
bhtty_raw(pp, &pp->dcb);
/* Set new state of this port. */
if (bhtty_sstate(pp, &pp->dcb) < 0) {
(void)bhtty_close(pp);
return(NULL);
}
/* Just to make sure.. disable RTS/CTS mode. */
(void)bhtty_crtscts(pp, 0);
/* Set new timeout values. */
if (GetCommTimeouts(pp->handle, &to) == FALSE) {
pclog("%s: error %d while getting current TO\n",
pp->name, GetLastError());
(void)bhtty_close(pp);
return(NULL);
}
if (tmo < 0) {
/* No timeout, immediate return. */
to.ReadIntervalTimeout = MAXDWORD;
to.ReadTotalTimeoutMultiplier = 0;
to.ReadTotalTimeoutConstant = 0;
} else if (tmo == 0) {
/* No timeout, wait for data. */
memset(&to, 0x00, sizeof(to));
} else {
/* Timeout specified. */
to.ReadIntervalTimeout = MAXDWORD;
to.ReadTotalTimeoutMultiplier = MAXDWORD;
to.ReadTotalTimeoutConstant = tmo;
}
if (SetCommTimeouts(pp->handle, &to) == FALSE) {
pclog("%s: error %d while setting TO\n", pp->name, GetLastError());
(void)bhtty_close(pp);
return(NULL);
}
/* Clear all errors and flush all buffers. */
if (bhtty_flush(pp) < 0) {
(void)bhtty_close(pp);
return(NULL);
}
return(pp);
}
/* Activate the I/O for this port. */
int
bhtty_active(BHTTY *pp, int flg)
{
if (flg) {
pclog("%s: starting thread..\n", pp->name);
pp->tid = thread_create(bhtty_reader, pp);
} else {
if (pp->tid != NULL) {
pclog("%s: stopping thread..\n", pp->name);
thread_kill(pp->tid);
pp->tid = NULL;
}
}
return(0);
}
/* Try to write data to an open port. */
int
bhtty_write(BHTTY *pp, unsigned char val)
{
DWORD n = 0;
pclog("%s: writing byte %02x\n", pp->name, val);
if (WriteFile(pp->handle, &val, 1, &n, &pp->wov) == FALSE) {
n = GetLastError();
if (n != ERROR_IO_PENDING) {
/* Not good, we got an error. */
pclog("%s: I/O error %d in write!\n", pp->name, n);
return(-1);
}
/* The write is pending, wait for it.. */
if (GetOverlappedResult(pp->handle, &pp->wov, &n, TRUE) == FALSE) {
n = GetLastError();
pclog("%s: I/O error %d in write!\n", pp->name, n);
return(-1);
}
}
return((int)n);
}
/*
* Try to read data from an open port.
*
* For now, we will use one byte per call. Eventually,
* we should go back to loading a buffer full of data,
* just to speed things up a bit. --FvK
*/
int
bhtty_read(BHTTY *pp, unsigned char *bufp, int max)
{
if (pp->icnt == 0) return(0);
while (max-- > 0) {
*bufp++ = pp->buff[pp->itail++];
pclog("%s: dequeued byte %02x (%d)\n", pp->name, *(bufp-1), pp->icnt);
pp->itail &= (sizeof(pp->buff)-1);
if (--pp->icnt == 0) break;
}
return(max);
}

View File

@@ -8,13 +8,13 @@
*
* Windows 86Box Settings dialog handler.
*
* Version: @(#)win_settings.c 1.0.54 2019/02/11
* Version: @(#)win_settings.c 1.0.55 2019/03/03
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* David Hrdlička, <hrdlickadavid@outlook.com>
*
* Copyright 2016-2018 Miran Grca.
* Copyright 2018 David Hrdlička.
* Copyright 2016-2019 Miran Grca.
* Copyright 2018,2019 David Hrdlička.
*/
#define UNICODE
#define BITMAP WINDOWS_BITMAP
@@ -36,6 +36,7 @@
#include "../mem.h"
#include "../rom.h"
#include "../device.h"
#include "../timer.h"
#include "../nvr.h"
#include "../machine/machine.h"
#include "../game/gameport.h"
@@ -92,8 +93,8 @@ static int temp_net_type, temp_net_card;
static char temp_pcap_dev[522];
/* Ports category */
static char temp_lpt_device_names[3][16];
static int temp_serial[2], temp_lpt;
static int temp_lpt_devices[3];
static int temp_serial[2], temp_lpt[3];
/* Other peripherals category */
static int temp_hdc, temp_scsi_card, temp_ide_ter, temp_ide_qua;
@@ -120,7 +121,7 @@ static HWND hwndParentDialog, hwndChildDialog;
static uint32_t displayed_category = 0;
extern int is486;
static int romstolist[ROM_MAX], listtomachine[ROM_MAX], romstomachine[ROM_MAX], machinetolist[ROM_MAX];
static int listtomachine[256], machinetolist[256];
static int settings_device_to_list[2][20], settings_list_to_device[2][20];
static int settings_midi_to_list[20], settings_list_to_midi[20];
@@ -235,18 +236,12 @@ win_settings_init(void)
temp_net_card = network_card;
/* Ports category */
#ifdef ENABLE_SETTINGS_LOG
assert(sizeof(temp_lpt_device_names) == sizeof(lpt_device_names));
#endif
for (i = 0; i < 3; i++) {
#ifdef ENABLE_SETTINGS_LOG
assert(sizeof(temp_lpt_device_names[i]) == sizeof(lpt_device_names[i]));
#endif
memcpy(temp_lpt_device_names[i], lpt_device_names[i], sizeof(lpt_device_names[i]));
temp_lpt_devices[i] = lpt_ports[i].device;
temp_lpt[i] = lpt_ports[i].enabled;
}
temp_serial[0] = serial_enabled[0];
temp_serial[1] = serial_enabled[1];
temp_lpt = lpt_enabled;
for (i = 0; i < 2; i++)
temp_serial[i] = serial_enabled[i];
/* Other peripherals category */
temp_scsi_card = scsi_card_current;
@@ -291,7 +286,7 @@ win_settings_init(void)
for (i = 0; i < CDROM_NUM; i++) {
if (cdrom[i].bus_type == CDROM_BUS_ATAPI)
ide_tracking |= (2 << (cdrom[i].ide_channel << 3));
else if (cdrom[i].bus_type == CDROM_BUS_SCSI)
else if (cdrom[i].bus_type == CDROM_BUS_SCSI || cdrom[i].bus_type == CDROM_BUS_SCSI_CHINON)
scsi_tracking[cdrom[i].scsi_device_id >> 3] |= (1 << ((cdrom[i].scsi_device_id & 0x07) << 3));
}
memcpy(temp_zip_drives, zip_drives, ZIP_NUM * sizeof(zip_drive_t));
@@ -349,11 +344,12 @@ win_settings_changed(void)
i = i || (network_card != temp_net_card);
/* Ports category */
for (j = 0; j < 3; j++)
i = i || strncmp(temp_lpt_device_names[j], lpt_device_names[j], sizeof(temp_lpt_device_names[j]) - 1);
i = i || (temp_serial[0] != serial_enabled[0]);
i = i || (temp_serial[1] != serial_enabled[1]);
i = i || (temp_lpt != lpt_enabled);
for (j = 0; j < 3; j++) {
i = i || (temp_lpt_devices[j] != lpt_ports[j].device);
i = i || (temp_lpt[j] != lpt_ports[j].enabled);
}
for (j = 0; j < 2; j++)
i = i || (temp_serial[j] != serial_enabled[j]);
/* Peripherals category */
i = i || (scsi_card_current != temp_scsi_card);
@@ -417,7 +413,6 @@ win_settings_save(void)
/* Machine category */
machine = temp_machine;
romset = machine_getromset();
cpu_manufacturer = temp_cpu_m;
cpu_waitstates = temp_wait_states;
cpu = temp_cpu;
@@ -453,11 +448,12 @@ win_settings_save(void)
network_card = temp_net_card;
/* Ports category */
for (i = 0; i < 3; i++)
memcpy(lpt_device_names[i], temp_lpt_device_names[i], sizeof(temp_lpt_device_names[i]));
serial_enabled[0] = temp_serial[0];
serial_enabled[1] = temp_serial[1];
lpt_enabled = temp_lpt;
for (i = 0; i < 3; i++) {
lpt_ports[i].device = temp_lpt_devices[i];
lpt_ports[i].enabled = temp_lpt[i];
}
for (i = 0; i < 2; i++)
serial_enabled[i] = temp_serial[i];
/* Peripherals category */
scsi_card_current = temp_scsi_card;
@@ -512,15 +508,13 @@ static void
win_settings_machine_recalc_cpu(HWND hdlg)
{
HWND h;
int cpu_type, temp_romset;
int cpu_type;
#ifdef USE_DYNAREC
int cpu_flags;
#endif
temp_romset = machine_getromset_ex(temp_machine);
h = GetDlgItem(hdlg, IDC_COMBO_WS);
cpu_type = machines[romstomachine[temp_romset]].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
cpu_type = machines[temp_machine].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
if ((cpu_type >= CPU_286) && (cpu_type <= CPU_386DX))
EnableWindow(h, TRUE);
else
@@ -528,7 +522,7 @@ win_settings_machine_recalc_cpu(HWND hdlg)
#ifdef USE_DYNAREC
h=GetDlgItem(hdlg, IDC_CHECK_DYNAREC);
cpu_flags = machines[romstomachine[temp_romset]].cpu[temp_cpu_m].cpus[temp_cpu].cpu_flags;
cpu_flags = machines[temp_machine].cpu[temp_cpu_m].cpus[temp_cpu].cpu_flags;
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) && (cpu_flags & CPU_REQUIRES_DYNAREC))
fatal("Attempting to select a CPU that requires the recompiler and does not support it at the same time\n");
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) || (cpu_flags & CPU_REQUIRES_DYNAREC)) {
@@ -543,8 +537,9 @@ win_settings_machine_recalc_cpu(HWND hdlg)
#endif
h = GetDlgItem(hdlg, IDC_CHECK_FPU);
cpu_type = machines[romstomachine[temp_romset]].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
if ((cpu_type < CPU_i486DX) && (cpu_type >= CPU_286))
cpu_type = machines[temp_machine].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
// if ((cpu_type < CPU_i486DX) && (cpu_type >= CPU_286))
if (cpu_type < CPU_i486DX)
EnableWindow(h, TRUE);
else if (cpu_type < CPU_286) {
temp_fpu = 0;
@@ -561,18 +556,17 @@ static void
win_settings_machine_recalc_cpu_m(HWND hdlg)
{
HWND h;
int c, temp_romset;
int c;
LPTSTR lptsTemp;
char *stransi;
temp_romset = machine_getromset_ex(temp_machine);
lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR));
h = GetDlgItem(hdlg, IDC_COMBO_CPU);
SendMessage(h, CB_RESETCONTENT, 0, 0);
c = 0;
while (machines[romstomachine[temp_romset]].cpu[temp_cpu_m].cpus[c].cpu_type != -1) {
stransi = (char *) machines[romstomachine[temp_romset]].cpu[temp_cpu_m].cpus[c].name;
while (machines[temp_machine].cpu[temp_cpu_m].cpus[c].cpu_type != -1) {
stransi = (char *) machines[temp_machine].cpu[temp_cpu_m].cpus[c].name;
mbstowcs(lptsTemp, stransi, strlen(stransi) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
c++;
@@ -592,13 +586,12 @@ static void
win_settings_machine_recalc_machine(HWND hdlg)
{
HWND h;
int c, temp_romset;
int c;
LPTSTR lptsTemp;
const char *stransi;
UDACCEL accel;
device_t *d;
temp_romset = machine_getromset_ex(temp_machine);
lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR));
h = GetDlgItem(hdlg, IDC_CONFIGURE_MACHINE);
@@ -611,8 +604,8 @@ win_settings_machine_recalc_machine(HWND hdlg)
h = GetDlgItem(hdlg, IDC_COMBO_CPU_TYPE);
SendMessage(h, CB_RESETCONTENT, 0, 0);
c = 0;
while (machines[romstomachine[temp_romset]].cpu[c].cpus != NULL && c < 4) {
stransi = machines[romstomachine[temp_romset]].cpu[c].name;
while (machines[temp_machine].cpu[c].cpus != NULL && c < 4) {
stransi = machines[temp_machine].cpu[c].name;
mbstowcs(lptsTemp, stransi, strlen(stransi) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
c++;
@@ -626,11 +619,11 @@ win_settings_machine_recalc_machine(HWND hdlg)
win_settings_machine_recalc_cpu_m(hdlg);
h = GetDlgItem(hdlg, IDC_MEMSPIN);
SendMessage(h, UDM_SETRANGE, 0, (machines[romstomachine[temp_romset]].min_ram << 16) | machines[romstomachine[temp_romset]].max_ram);
SendMessage(h, UDM_SETRANGE, 0, (machines[temp_machine].min_ram << 16) | machines[temp_machine].max_ram);
accel.nSec = 0;
accel.nInc = machines[romstomachine[temp_romset]].ram_granularity;
accel.nInc = machines[temp_machine].ram_granularity;
SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel);
if (!(machines[romstomachine[temp_romset]].flags & MACHINE_AT) || (machines[romstomachine[temp_romset]].ram_granularity >= 128)) {
if (!(machines[temp_machine].flags & MACHINE_AT) || (machines[temp_machine].ram_granularity >= 128)) {
SendMessage(h, UDM_SETPOS, 0, temp_mem_size);
h = GetDlgItem(hdlg, IDC_TEXT_MB);
SendMessage(h, WM_SETTEXT, 0, win_get_string(IDS_2094));
@@ -661,18 +654,14 @@ win_settings_machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR));
h = GetDlgItem(hdlg, IDC_COMBO_MACHINE);
for (c = 0; c < ROM_MAX; c++)
romstolist[c] = 0;
c = d = 0;
while (machines[c].id != -1) {
if (romspresent[machines[c].id]) {
while (machine_get_internal_name_ex(c) != NULL) {
if (machine_available(c)) {
stransi = (char *)machines[c].name;
mbstowcs(lptsTemp, stransi, strlen(stransi) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
machinetolist[c] = d;
listtomachine[d] = c;
romstolist[machines[c].id] = d;
romstomachine[machines[c].id] = c;
d++;
}
c++;
@@ -848,7 +837,7 @@ recalc_vid_list(HWND hdlg)
}
if (!found_card)
SendMessage(h, CB_SETCURSEL, 0, 0);
EnableWindow(h, machines[temp_machine].fixed_gfxcard ? FALSE : TRUE);
EnableWindow(h, (machines[temp_machine].flags & MACHINE_VIDEO_FIXED) ? FALSE : TRUE);
h = GetDlgItem(hdlg, IDC_CHECK_VOODOO);
EnableWindow(h, (machines[temp_machine].flags & MACHINE_PCI) ? TRUE : FALSE);
@@ -1343,7 +1332,7 @@ static BOOL CALLBACK
win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND h;
int c, d, i;
int c, i;
char *s;
LPTSTR lptsTemp;
@@ -1353,7 +1342,7 @@ win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
for (i = 0; i < 3; i++) {
h = GetDlgItem(hdlg, IDC_COMBO_LPT1 + i);
c = d = 0;
c = 0;
while (1) {
s = lpt_device_get_name(c);
@@ -1367,22 +1356,18 @@ win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
if (!strcmp(temp_lpt_device_names[i], lpt_device_get_internal_name(c)))
d = c;
c++;
}
SendMessage(h, CB_SETCURSEL, d, 0);
SendMessage(h, CB_SETCURSEL, temp_lpt_devices[i], 0);
h=GetDlgItem(hdlg, IDC_CHECK_PARALLEL1 + i);
SendMessage(h, BM_SETCHECK, temp_lpt[i], 0);
}
h=GetDlgItem(hdlg, IDC_CHECK_SERIAL1);
SendMessage(h, BM_SETCHECK, temp_serial[0], 0);
h=GetDlgItem(hdlg, IDC_CHECK_SERIAL2);
SendMessage(h, BM_SETCHECK, temp_serial[1], 0);
h=GetDlgItem(hdlg, IDC_CHECK_PARALLEL);
SendMessage(h, BM_SETCHECK, temp_lpt, 0);
for (i = 0; i < 2; i++) {
h=GetDlgItem(hdlg, IDC_CHECK_SERIAL1 + i);
SendMessage(h, BM_SETCHECK, temp_serial[i], 0);
}
free(lptsTemp);
@@ -1391,18 +1376,16 @@ win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SAVESETTINGS:
for (i = 0; i < 3; i++) {
h = GetDlgItem(hdlg, IDC_COMBO_LPT1 + i);
c = SendMessage(h, CB_GETCURSEL, 0, 0);
strcpy(temp_lpt_device_names[i], lpt_device_get_internal_name(c));
temp_lpt_devices[i] = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECK_PARALLEL1 + i);
temp_lpt[i] = SendMessage(h, BM_GETCHECK, 0, 0);
}
h = GetDlgItem(hdlg, IDC_CHECK_SERIAL1);
temp_serial[0] = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECK_SERIAL2);
temp_serial[1] = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECK_PARALLEL);
temp_lpt = SendMessage(h, BM_GETCHECK, 0, 0);
for (i = 0; i < 2; i++) {
h = GetDlgItem(hdlg, IDC_CHECK_SERIAL1 + i);
temp_serial[i] = SendMessage(h, BM_GETCHECK, 0, 0);
}
default:
return FALSE;
@@ -3068,11 +3051,15 @@ hdd_add_file_open_error:
max_spt = max_hpc = max_tracks = 0;
break;
case HDD_BUS_MFM:
max_spt = 17;
max_spt = 26; /* 17 for MFM, 26 for RLL. */
max_hpc = 15;
max_tracks = 1023;
break;
case HDD_BUS_ESDI:
max_spt = 43; /* ESDI drives usually had 32 to 43 sectors per track. */
max_hpc = 16;
max_tracks = 1023;
break;
case HDD_BUS_XTA:
max_spt = 63;
max_hpc = 16;
@@ -3470,6 +3457,7 @@ win_settings_cdrom_drives_recalc_list(HWND hwndList)
lvI.iImage = 1;
break;
case CDROM_BUS_SCSI:
case CDROM_BUS_SCSI_CHINON:
wsprintf(szText, plat_get_string(fsid), temp_cdrom[i].scsi_device_id);
lvI.pszText = szText;
lvI.iImage = 1;
@@ -3732,6 +3720,7 @@ win_settings_cdrom_drives_update_item(HWND hwndList, int i)
lvI.iImage = 1;
break;
case CDROM_BUS_SCSI:
case CDROM_BUS_SCSI_CHINON:
wsprintf(szText, plat_get_string(fsid), temp_cdrom[i].scsi_device_id);
lvI.pszText = szText;
lvI.iImage = 1;
@@ -3812,7 +3801,7 @@ cdrom_add_locations(HWND hdlg)
lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR));
h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS);
for (i = CDROM_BUS_DISABLED; i <= CDROM_BUS_SCSI; i++) {
for (i = CDROM_BUS_DISABLED; i <= CDROM_BUS_SCSI_CHINON; i++) {
if ((i == CDROM_BUS_DISABLED) || (i >= CDROM_BUS_ATAPI))
SendMessage(h, CB_ADDSTRING, 0, win_get_string(combo_id_to_string_id(i)));
}
@@ -3894,6 +3883,7 @@ static void cdrom_recalc_location_controls(HWND hdlg, int assign_id)
SendMessage(h, CB_SETCURSEL, temp_cdrom[lv1_current_sel].ide_channel, 0);
break;
case CDROM_BUS_SCSI: /* SCSI */
case CDROM_BUS_SCSI_CHINON:
h = GetDlgItem(hdlg, IDT_1741);
ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE);
@@ -4009,7 +3999,7 @@ cdrom_track(uint8_t id)
{
if (temp_cdrom[id].bus_type == CDROM_BUS_ATAPI)
ide_tracking |= (2 << (temp_cdrom[id].ide_channel << 3));
else if (temp_cdrom[id].bus_type == CDROM_BUS_SCSI)
else if (temp_cdrom[id].bus_type == CDROM_BUS_SCSI || temp_cdrom[id].bus_type == CDROM_BUS_SCSI_CHINON)
scsi_tracking[temp_cdrom[id].scsi_device_id >> 3] |= (1 << (temp_cdrom[id].scsi_device_id & 0x07));
}
@@ -4019,7 +4009,7 @@ cdrom_untrack(uint8_t id)
{
if (temp_cdrom[id].bus_type == CDROM_BUS_ATAPI)
ide_tracking &= ~(2 << (temp_cdrom[id].ide_channel << 3));
else if (temp_cdrom[id].bus_type == CDROM_BUS_SCSI)
else if (temp_cdrom[id].bus_type == CDROM_BUS_SCSI || temp_cdrom[id].bus_type == CDROM_BUS_SCSI_CHINON)
scsi_tracking[temp_cdrom[id].scsi_device_id >> 3] &= ~(1 << (temp_cdrom[id].scsi_device_id & 0x07));
}
@@ -4188,6 +4178,9 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
case CDROM_BUS_SCSI:
b = 2;
break;
case CDROM_BUS_SCSI_CHINON:
b = 3;
break;
}
SendMessage(h, CB_SETCURSEL, b, 0);
@@ -4255,6 +4248,9 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
case CDROM_BUS_SCSI:
b = 2;
break;
case CDROM_BUS_SCSI_CHINON:
b = 3;
break;
}
SendMessage(h, CB_SETCURSEL, b, 0);
@@ -4317,6 +4313,9 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
case 2:
b2 = CDROM_BUS_SCSI;
break;
case 3:
b2 = CDROM_BUS_SCSI_CHINON;
break;
}
if (b2 == temp_cdrom[lv1_current_sel].bus_type)
break;

View File

@@ -8,13 +8,13 @@
*
* Implement the application's Status Bar.
*
* Version: @(#)win_stbar.c 1.0.24 2018/10/28
* Version: @(#)win_stbar.c 1.0.25 2019/03/15
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2016-2018 Miran Grca.
* Copyright 2017,2018 Fred N. van Kempen.
* Copyright 2016-2019 Miran Grca.
* Copyright 2017-2019 Fred N. van Kempen.
*/
#define UNICODE
#define BITMAP WINDOWS_BITMAP
@@ -33,6 +33,7 @@
#include "../cpu/cpu.h"
#include "../device.h"
#include "../machine/machine.h"
#include "../timer.h"
#include "../disk/hdd.h"
#include "../disk/hdc.h"
#include "../floppy/fdd.h"
@@ -190,6 +191,19 @@ StatusBarCreateZIPSubmenu(HMENU m, int id)
}
void
ui_sb_timer_callback(int pane)
{
sb_part_icons[pane] &= ~1;
if (sb_part_icons && sb_part_icons[pane]) {
SendMessage(hwndSBAR, SB_SETICON, pane,
(LPARAM)hIcon[sb_part_icons[pane]]);
}
}
/* API */
/* API: update one of the icons after activity. */
void
@@ -204,12 +218,13 @@ ui_sb_update_icon(int tag, int active)
return;
found = sb_map[tag];
if (found != 0xff) {
sb_part_icons[found] &= ~1;
sb_part_icons[found] |= (uint8_t) active;
if ((found != 0xff) && ((sb_part_icons[found] ^ active) & 1) && active) {
sb_part_icons[found] |= 1;
SendMessage(hwndSBAR, SB_SETICON, found,
(LPARAM)hIcon[sb_part_icons[found]]);
SetTimer(hwndMain, 0x8000 | found, 75, NULL);
}
}
@@ -487,6 +502,9 @@ ui_sb_update_panes(void)
int do_net;
char *hdc_name;
if (!config_changed)
return;
if (sb_ready) {
sb_ready = 0;
}
@@ -534,7 +552,7 @@ ui_sb_update_panes(void)
!(hdint || !memcmp(hdc_name, "ide", 3)))
continue;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) &&
if ((cdrom[i].bus_type == CDROM_BUS_SCSI || cdrom[i].bus_type == CDROM_BUS_SCSI_CHINON) &&
(scsi_card_current == 0))
continue;
if (cdrom[i].bus_type != 0)
@@ -552,7 +570,7 @@ ui_sb_update_panes(void)
if (zip_drives[i].bus_type != 0)
sb_parts++;
}
if (c_mfm && (hdint || !memcmp(hdc_name, "mfm", 3))) {
if (c_mfm && (hdint || !memcmp(hdc_name, "st506", 5))) {
/* MFM drives, and MFM or Internal controller. */
sb_parts++;
}
@@ -597,7 +615,7 @@ ui_sb_update_panes(void)
!(hdint || !memcmp(hdc_name, "ide", 3))) {
continue;
}
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && (scsi_card_current == 0))
if ((cdrom[i].bus_type == CDROM_BUS_SCSI || cdrom[i].bus_type == CDROM_BUS_SCSI_CHINON) && (scsi_card_current == 0))
continue;
if (cdrom[i].bus_type != 0) {
edge += SB_ICON_WIDTH;
@@ -622,7 +640,7 @@ ui_sb_update_panes(void)
sb_parts++;
}
}
if (c_mfm && (hdint || !memcmp(hdc_name, "mfm", 3))) {
if (c_mfm && (hdint || !memcmp(hdc_name, "st506", 5))) {
edge += SB_ICON_WIDTH;
iStatusWidths[sb_parts] = edge;
sb_part_meanings[sb_parts] = SB_HDD | HDD_BUS_MFM;

View File

@@ -8,7 +8,7 @@
*
* user Interface module for WinAPI on Windows.
*
* Version: @(#)win_ui.c 1.0.40 2019/7/28
* Version: @(#)win_ui.c 1.0.39 2019/3/20
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -51,7 +51,8 @@ HWND hwndMain, /* application main window */
HMENU menuMain; /* application main menu */
HICON hIcon[256]; /* icon data loaded from resources */
RECT oldclip; /* mouse rect */
int sbar_height = 23; /* statusbar height */
int sbar_height = 23; /* statusbar height */
int minimized = 0;
int infocus = 1;
int rctrl_is_lalt = 0;
int user_resize = 0;
@@ -348,6 +349,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
GetWindowRect(hwnd, &rect);
/* Main Window. */
if (GetSystemMetrics(SM_CXPADDEDBORDER) == 0) {
/* For platforms that subsystem version < 6.0 (default on mingw/msys2) */
@@ -428,9 +430,8 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_FS_FULL:
case IDM_VID_FS_43:
case IDM_VID_FS_SQ:
case IDM_VID_FS_KEEPRATIO:
case IDM_VID_FS_INT:
case IDM_VID_FS_KEEPRATIO:
CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_UNCHECKED);
video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL;
CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED);
@@ -569,7 +570,18 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
temp_x = (lParam & 0xFFFF);
temp_y = (lParam >> 16) - sbar_height;
temp_y = (lParam >> 16);
if ((temp_x <= 0) || (temp_y <= 0)) {
minimized = 1;
break;
} else if (minimized == 1) {
minimized = 0;
video_force_resize_set(1);
}
plat_vidapi_enable(0);
temp_y -= sbar_height;
if (temp_x < 1)
temp_x = 1;
if (temp_y < 1)
@@ -606,6 +618,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
window_h = rect.bottom - rect.top;
save_window_pos = 1;
}
plat_vidapi_enable(1);
config_save();
break;
@@ -622,9 +635,10 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_TIMER:
if (wParam == TIMER_1SEC) {
if (wParam == TIMER_1SEC)
pc_onesec();
}
else if ((wParam >= 0x8000) && (wParam <= 0x80ff))
ui_sb_timer_callback(wParam & 0xff);
break;
case WM_RESETD3D:
@@ -852,11 +866,11 @@ ui_init(int nCmdShow)
/* Create the status bar window. */
StatusBarCreate(hwndMain, IDC_STATUS, hinstance);
/* Get the actual height of the statusbar,
* since that is not something we can change.
*/
GetWindowRect(hwndSBAR, &sbar_rect);
sbar_height = sbar_rect.bottom - sbar_rect.top;
/* Get the actual height of the statusbar,
* since that is not something we can change.
*/
GetWindowRect(hwndSBAR, &sbar_rect);
sbar_height = sbar_rect.bottom - sbar_rect.top;
/*
* Before we can create the Render window, we first have
@@ -1031,7 +1045,7 @@ plat_resize(int x, int y)
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
GetWindowRect(hwndMain, &r);
if (GetSystemMetrics(SM_CXPADDEDBORDER) == 0) {
/* For platforms that subsystem version < 6.0 (gcc on mingw/msys2) */
/* In this case, border sizes are different between resizable and non-resizable window */