Merge pull request #1690 from 86Box/master

Bring the branch up to par with master.
This commit is contained in:
Miran Grča
2021-09-14 22:34:42 +02:00
committed by GitHub
15 changed files with 538 additions and 440 deletions

View File

@@ -15,7 +15,7 @@
enable_language(RC)
add_library(plat OBJECT win.c win_dynld.c win_thread.c win_cdrom.c
add_library(plat OBJECT win.c win_dynld.c win_cdrom.c
win_keyboard.c win_crashdump.c win_midi.c win_mouse.c)
add_library(ui OBJECT win_ui.c win_stbar.c win_sdl.c win_dialog.c win_about.c

View File

@@ -26,6 +26,10 @@ ifndef DEV_BUILD
DEV_BUILD := n
endif
ifneq ($(PTHREAD), n)
PTHREAD := y
endif
ifeq ($(DEV_BUILD), y)
ifndef DEBUG
DEBUG := y
@@ -595,6 +599,7 @@ MAINOBJ := 86box.o config.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \
nmi.o pic.o pit.o port_92.o ppi.o pci.o mca.o \
usb.o device.o nvr.o nvr_at.o nvr_ps2.o \
$(VNCOBJ)
endif
MEMOBJ := catalyst_flash.o i2c_eeprom.o intel_flash.o mem.o rom.o smram.o spd.o sst_flash.o
@@ -796,11 +801,19 @@ VOODOOOBJ := vid_voodoo.o vid_voodoo_banshee.o \
vid_voodoo_render.o vid_voodoo_setup.o \
vid_voodoo_texture.o
ifeq ($(PTHREAD), y)
PLATOBJ := win.o \
win_dynld.o \
win_cdrom.o win_keyboard.o \
win_crashdump.o win_midi.o \
win_mouse.o
else
PLATOBJ := win.o \
win_dynld.o win_thread.o \
win_cdrom.o win_keyboard.o \
win_crashdump.o win_midi.o \
win_mouse.o
endif
ifeq ($(DINPUT), y)
PLATOBJ += win_joystick.o
@@ -826,7 +839,11 @@ endif
ifneq ($(WX), n)
LIBS += $(WX_LIBS) -lm
endif
ifeq ($(PTHREAD), y)
LIBS += -lpng -lz -lwsock32 -lshell32 -liphlpapi -lpsapi -lSDL2 -limm32 -lhid -lsetupapi -loleaut32 -luxtheme -lversion -lwinmm -static -lstdc++ -lpthread
else
LIBS += -lpng -lz -lwsock32 -lshell32 -liphlpapi -lpsapi -lSDL2 -limm32 -lhid -lsetupapi -loleaut32 -luxtheme -lversion -lwinmm -static -lstdc++
endif
ifneq ($(X64), y)
ifneq ($(ARM64), y)
LIBS += -Wl,--large-address-aware

View File

@@ -1094,6 +1094,8 @@ plat_setfullscreen(int on)
ResizeWindowByClientArea(hwndMain, temp_x, temp_y);
else
ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height);
SetWindowPos(hwndMain, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE);
}
/* Render window. */

View File

@@ -64,6 +64,7 @@ static const int INIT_HEIGHT = 400;
static const int BUFFERPIXELS = 4460544; /* Same size as render_buffer, pow(2048+64,2). */
static const int BUFFERBYTES = 17842176; /* Pixel is 4 bytes. */
static const int BUFFERCOUNT = 3; /* How many buffers to use for pixel transfer (2-3 is commonly recommended). */
static const int ROW_LENGTH = 2112; /* Source buffer row lenght (including padding) */
/**
* @brief A dedicated OpenGL thread.
@@ -106,7 +107,7 @@ static union
*/
typedef struct
{
int y1, y2, w, h;
int w, h;
void* buffer; /* Buffer for pixel transfer, allocated by gpu driver. */
volatile atomic_flag in_use; /* Is buffer currently in use. */
GLsync sync; /* Fence sync object used by opengl thread to track pixel transfer completion. */
@@ -641,18 +642,16 @@ static void opengl_main(void* param)
SetEvent(sync_objects.resize);
}
/* Clip to height. y2 can be out-of-bounds. */
int sub_height = MIN(info->y2, info->h) - info->y1;
if (!GLAD_GL_ARB_buffer_storage)
{
/* Fallback method, copy data to pixel buffer. */
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, BUFFERBYTES * read_pos, info->w * sub_height * sizeof(uint32_t), info->buffer);
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, BUFFERBYTES * read_pos, info->h * ROW_LENGTH * sizeof(uint32_t), info->buffer);
}
/* Update texture from pixel buffer. */
glPixelStorei(GL_UNPACK_SKIP_PIXELS, BUFFERPIXELS * read_pos);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, info->y1, info->w, sub_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
glPixelStorei(GL_UNPACK_ROW_LENGTH, ROW_LENGTH);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, info->w, info->h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
/* Add fence to track when above gl commands are complete. */
info->sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
@@ -819,16 +818,10 @@ static void opengl_blit(int x, int y, int w, int h)
return;
}
for (yy = 0; yy < h; yy++) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy(blit_info[write_pos].buffer + (yy * w * sizeof(uint32_t)),
&(((uint32_t *) buffer32->line[y + yy])[x]), w * sizeof(uint32_t));
}
memcpy(blit_info[write_pos].buffer, &(buffer32->line[y][x]), h * ROW_LENGTH * sizeof(uint32_t));
video_blit_complete();
blit_info[write_pos].y1 = 0;
blit_info[write_pos].y2 = h - 1;
blit_info[write_pos].w = w;
blit_info[write_pos].h = h;

View File

@@ -140,11 +140,13 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
if (mouse_capture)
ClipCursor(&r);
if (!(vid_resize & 2) && window_remember) {
if (window_remember || (vid_resize & 2)) {
window_x = r.left;
window_y = r.top;
window_w = r.right - r.left;
window_h = r.bottom - r.top;
if (!(vid_resize & 2)) {
window_w = r.right - r.left;
window_h = r.bottom - r.top;
}
}
config_save();

View File

@@ -697,11 +697,13 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
window_remember = !window_remember;
CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
GetWindowRect(hwnd, &rect);
if (!(vid_resize & 2) && window_remember) {
if (window_remember || (vid_resize & 2)) {
window_x = rect.left;
window_y = rect.top;
window_w = rect.right - rect.left;
window_h = rect.bottom - rect.top;
if (!(vid_resize & 2)) {
window_w = rect.right - rect.left;
window_h = rect.bottom - rect.top;
}
}
config_save();
break;
@@ -978,11 +980,13 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
video_force_resize_set(1);
}
if (window_remember) {
if (window_remember || (vid_resize & 2)) {
window_x = pos->x;
window_y = pos->y;
window_w = pos->cx;
window_h = pos->cy;
if (!(vid_resize & 2)) {
window_w = pos->cx;
window_h = pos->cy;
}
save_window_pos = 1;
config_save();
}
@@ -1382,6 +1386,8 @@ ui_init(int nCmdShow)
ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y);
else
ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y + sbar_height);
SetWindowPos(hwndMain, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE);
}
/* Reset all menus to their defaults. */