SDL renderer improvements and fixes and added SDL OpenGL option;

Various performance improvements;
Fixed USB UHCI HCHalt;
Cirrus Logic CL-GD 5422/24 fixes and removed them from the Dev branch;
The Storage controllers sections of Settings now has its own corresponding section of the configuration file;
Fixed the AT clock divisors for some Pentium OverDrive CPU's;
Added the ACPI RTC status (no ACPI RTC alarm event yet).
This commit is contained in:
OBattler
2020-11-26 18:20:24 +01:00
parent 21d6f2e9f1
commit 6e233f4ac8
53 changed files with 618 additions and 279 deletions

View File

@@ -66,7 +66,8 @@ BEGIN
POPUP "Re&nderer"
BEGIN
MENUITEM "&SDL (Software)", IDM_VID_SDL_SW
MENUITEM "&SDL (Hardware)", IDM_VID_SDL_HW
MENUITEM "SDL (&Hardware)", IDM_VID_SDL_HW
MENUITEM "SDL (&OpenGL)", IDM_VID_SDL_OPENGL
#ifdef USE_VNC
MENUITEM "&VNC", IDM_VID_VNC
#endif

View File

@@ -509,10 +509,6 @@ ifeq ($(AMD_K5), y)
OPTS += -DUSE_AMD_K5
endif
ifeq ($(CL5422), y)
OPTS += -DUSE_CL5422
endif
ifeq ($(CYRIX_6X86), y)
OPTS += -DUSE_CYRIX_6X86
endif

View File

@@ -89,14 +89,16 @@ static const struct {
} vid_apis[2][RENDERERS_NUM] = {
{
{ "SDL_Software", 1, (int(*)(void*))sdl_inits, sdl_close, NULL, sdl_pause, sdl_enable },
{ "SDL_Hardware", 1, (int(*)(void*))sdl_inith, sdl_close, NULL, sdl_pause, sdl_enable }
{ "SDL_Hardware", 1, (int(*)(void*))sdl_inith, sdl_close, NULL, sdl_pause, sdl_enable },
{ "SDL_OpenGL", 1, (int(*)(void*))sdl_initho, sdl_close, NULL, sdl_pause, sdl_enable }
#ifdef USE_VNC
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL }
#endif
},
{
{ "SDL_Software", 1, (int(*)(void*))sdl_inits_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable },
{ "SDL_Hardware", 1, (int(*)(void*))sdl_inith_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable }
{ "SDL_Hardware", 1, (int(*)(void*))sdl_inith_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable },
{ "SDL_OpenGL", 1, (int(*)(void*))sdl_initho_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable }
#ifdef USE_VNC
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL }
#endif
@@ -700,9 +702,12 @@ plat_vidapi_name(int api)
break;
case 1:
break;
case 2:
name = "sdl_opengl";
break;
#ifdef USE_VNC
case 2:
case 3:
name = "vnc";
break;
#endif
@@ -762,12 +767,21 @@ plat_vidsize(int x, int y)
void
plat_vidapi_enable(int enable)
{
int i = 1;
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);
vid_apis[video_fullscreen][vid_api].enable(enable & 1);
endblit();
if (! i) return;
if (enable)
device_force_redraw();
}
int

View File

@@ -75,6 +75,7 @@
#define RENDERER_FULL_SCREEN 1
#define RENDERER_HARDWARE 2
#define RENDERER_OPENGL 4
static SDL_Window *sdl_win = NULL;
@@ -83,12 +84,55 @@ static SDL_Texture *sdl_tex = NULL;
static HWND sdl_parent_hwnd = NULL;
static HWND sdl_hwnd = NULL;
static int sdl_w, sdl_h;
static int sdl_fs;
static int sdl_fs, sdl_flags = -1;
static int cur_w, cur_h;
static int cur_wx = 0, cur_wy = 0, cur_ww =0, cur_wh = 0;
static volatile int sdl_enabled = 0;
static SDL_mutex* sdl_mutex = NULL;
typedef struct
{
const void *magic;
Uint32 id;
char *title;
SDL_Surface *icon;
int x, y;
int w, h;
int min_w, min_h;
int max_w, max_h;
Uint32 flags;
Uint32 last_fullscreen_flags;
/* Stored position and size for windowed mode */
SDL_Rect windowed;
SDL_DisplayMode fullscreen_mode;
float brightness;
Uint16 *gamma;
Uint16 *saved_gamma; /* (just offset into gamma) */
SDL_Surface *surface;
SDL_bool surface_valid;
SDL_bool is_hiding;
SDL_bool is_destroying;
void *shaper;
SDL_HitTest hit_test;
void *hit_test_data;
void *data;
void *driverdata;
SDL_Window *prev;
SDL_Window *next;
} SDL_Window_Ex;
#ifdef ENABLE_SDL_LOG
int sdl_do_log = ENABLE_SDL_LOG;
@@ -190,9 +234,7 @@ static void
sdl_blit(int x, int y, int y1, int y2, int w, int h)
{
SDL_Rect r_src;
void *pixeldata;
int pitch;
int yy, ret;
int ret;
if (!sdl_enabled) {
video_blit_complete();
@@ -211,22 +253,13 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
SDL_LockMutex(sdl_mutex);
/*
* TODO:
* SDL_UpdateTexture() might be better here, as it is
* (reportedly) slightly faster.
*/
SDL_LockTexture(sdl_tex, 0, &pixeldata, &pitch);
for (yy = y1; yy < y2; yy++) {
if ((y + yy) >= 0 && (y + yy) < render_buffer->h)
memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(render_buffer->line[y + yy][x]), w * 4);
}
r_src.x = 0;
r_src.y = y1;
r_src.w = w;
r_src.h = y2 - y1;
SDL_UpdateTexture(sdl_tex, &r_src, &(render_buffer->dat)[y1 * w], w * 4);
video_blit_complete();
SDL_UnlockTexture(sdl_tex);
if (sdl_fs) {
sdl_log("sdl_blit(%i, %i, %i, %i, %i, %i) (%i, %i)\n", x, y, y1, y2, w, h, unscaled_size_x, efscrnsz_y);
if (w == unscaled_size_x)
@@ -234,6 +267,8 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
sdl_log("(%08X, %08X, %08X)\n", sdl_win, sdl_render, sdl_tex);
}
SDL_RenderClear(sdl_render);
r_src.x = 0;
r_src.y = 0;
r_src.w = w;
@@ -252,6 +287,8 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
void
sdl_close(void)
{
SDL_LockMutex(sdl_mutex);
/* Unregister our renderer! */
video_setblit(NULL);
@@ -297,6 +334,8 @@ sdl_close(void)
/* Quit. */
SDL_Quit();
sdl_flags = -1;
}
@@ -340,8 +379,12 @@ sdl_init_common(int flags)
return(0);
}
if (flags & RENDERER_HARDWARE)
sdl_select_best_hw_driver();
if (flags & RENDERER_HARDWARE) {
if (flags & RENDERER_OPENGL)
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "OpenGL");
else
sdl_select_best_hw_driver();
}
if (flags & RENDERER_FULL_SCREEN) {
/* Get the size of the (current) desktop. */
@@ -461,6 +504,8 @@ sdl_init_common(int flags)
sdl_mutex = SDL_CreateMutex();
sdl_flags = flags;
return(1);
}
@@ -479,6 +524,13 @@ sdl_inith(HWND h)
}
int
sdl_initho(HWND h)
{
return sdl_init_common(RENDERER_HARDWARE | RENDERER_OPENGL);
}
int
sdl_inits_fs(HWND h)
{
@@ -493,15 +545,30 @@ sdl_inith_fs(HWND h)
}
int
sdl_initho_fs(HWND h)
{
return sdl_init_common(RENDERER_FULL_SCREEN | RENDERER_HARDWARE | RENDERER_OPENGL);
}
void
sdl_reinit_texture()
{
if (sdl_render == NULL)
if ((sdl_render == NULL) || (sdl_flags == -1))
return;
SDL_DestroyTexture(sdl_tex);
SDL_DestroyRenderer(sdl_render);
if (sdl_flags & RENDERER_HARDWARE) {
sdl_render = SDL_CreateRenderer(sdl_win, -1, SDL_RENDERER_ACCELERATED);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");
} else
sdl_render = SDL_CreateRenderer(sdl_win, -1, SDL_RENDERER_SOFTWARE);
sdl_tex = SDL_CreateTexture(sdl_render, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, 2048, 2048);
SDL_SetWindowSize(sdl_win, cur_ww, cur_wh);
SDL_SetWindowPosition(sdl_win, cur_wx, cur_wy);
}
@@ -520,6 +587,8 @@ sdl_resize(int x, int y)
if ((x == cur_w) && (y == cur_h))
return;
SDL_LockMutex(sdl_mutex);
ww = x;
wh = y;
@@ -531,12 +600,26 @@ sdl_resize(int x, int y)
cur_w = x;
cur_h = y;
cur_wx = wx;
cur_wy = wy;
cur_ww = ww;
cur_wh = wh;
sdl_reinit_texture();
SDL_UnlockMutex(sdl_mutex);
}
void
sdl_enable(int enable)
{
if (sdl_flags == -1)
return;
SDL_LockMutex(sdl_mutex);
sdl_enabled = enable;
if (enable)
sdl_reinit_texture();
SDL_UnlockMutex(sdl_mutex);
}

View File

@@ -2232,10 +2232,18 @@ win_settings_hard_disks_resize_columns(HWND hdlg)
{
/* Bus, File, Cylinders, Heads, Sectors, Size */
int iCol, width[C_COLUMNS_HARD_DISKS] = {104, 177, 50, 26, 32, 50};
int total = 0;
HWND hwndList = GetDlgItem(hdlg, IDC_LIST_HARD_DISKS);
RECT r;
for (iCol = 0; iCol < C_COLUMNS_HARD_DISKS; iCol++)
GetWindowRect(hwndList, &r);
for (iCol = 0; iCol < (C_COLUMNS_HARD_DISKS - 1); iCol++) {
width[iCol] = MulDiv(width[iCol], dpi, 96);
total += width[iCol];
ListView_SetColumnWidth(hwndList, iCol, MulDiv(width[iCol], dpi, 96));
}
width[C_COLUMNS_HARD_DISKS - 1] = (r.right - r.left) - 4 - total;
ListView_SetColumnWidth(hwndList, C_COLUMNS_HARD_DISKS - 1, width[C_COLUMNS_HARD_DISKS - 1]);
}
@@ -3678,11 +3686,19 @@ win_settings_zip_drives_recalc_list(HWND hdlg)
static void
win_settings_floppy_drives_resize_columns(HWND hdlg)
{
int iCol, width[3] = {292, 58, 89};
int total = 0;
HWND hwndList = GetDlgItem(hdlg, IDC_LIST_FLOPPY_DRIVES);
RECT r;
ListView_SetColumnWidth(hwndList, 0, MulDiv(292, dpi, 96));
ListView_SetColumnWidth(hwndList, 1, MulDiv(58, dpi, 96));
ListView_SetColumnWidth(hwndList, 2, MulDiv(89, dpi, 96));
GetWindowRect(hwndList, &r);
for (iCol = 0; iCol < 2; iCol++) {
width[iCol] = MulDiv(width[iCol], dpi, 96);
total += width[iCol];
ListView_SetColumnWidth(hwndList, iCol, MulDiv(width[iCol], dpi, 96));
}
width[2] = (r.right - r.left) - 4 - total;
ListView_SetColumnWidth(hwndList, 2, width[2]);
}
@@ -3729,10 +3745,15 @@ win_settings_floppy_drives_init_columns(HWND hdlg)
static void
win_settings_cdrom_drives_resize_columns(HWND hdlg)
{
int width[2] = {292, 147};
HWND hwndList = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES);
RECT r;
ListView_SetColumnWidth(hwndList, 0, MulDiv(292, dpi, 96));
ListView_SetColumnWidth(hwndList, 1, MulDiv(147, dpi, 96));
GetWindowRect(hwndList, &r);
width[0] = MulDiv(width[0], dpi, 96);
ListView_SetColumnWidth(hwndList, 0, MulDiv(width[0], dpi, 96));
width[1] = (r.right - r.left) - 4 - width[0];
ListView_SetColumnWidth(hwndList, 1, width[1]);
}
@@ -3770,10 +3791,15 @@ win_settings_cdrom_drives_init_columns(HWND hdlg)
static void
win_settings_mo_drives_resize_columns(HWND hdlg)
{
int width[2] = {292, 147};
HWND hwndList = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
RECT r;
ListView_SetColumnWidth(hwndList, 0, MulDiv(292, dpi, 96));
ListView_SetColumnWidth(hwndList, 1, MulDiv(147, dpi, 96));
GetWindowRect(hwndList, &r);
width[0] = MulDiv(width[0], dpi, 96);
ListView_SetColumnWidth(hwndList, 0, MulDiv(width[0], dpi, 96));
width[1] = (r.right - r.left) - 4 - width[0];
ListView_SetColumnWidth(hwndList, 1, width[1]);
}
@@ -3811,10 +3837,15 @@ win_settings_mo_drives_init_columns(HWND hdlg)
static void
win_settings_zip_drives_resize_columns(HWND hdlg)
{
int width[2] = {292, 147};
HWND hwndList = GetDlgItem(hdlg, IDC_LIST_ZIP_DRIVES);
RECT r;
ListView_SetColumnWidth(hwndList, 0, MulDiv(292, dpi, 96));
ListView_SetColumnWidth(hwndList, 1, MulDiv(147, dpi, 96));
GetWindowRect(hwndList, &r);
width[0] = MulDiv(width[0], dpi, 96);
ListView_SetColumnWidth(hwndList, 0, MulDiv(width[0], dpi, 96));
width[1] = (r.right - r.left) - 4 - width[0];
ListView_SetColumnWidth(hwndList, 1, width[1]);
}
@@ -4981,6 +5012,17 @@ win_settings_confirm(HWND hdlg)
}
static void
win_settings_categories_resize_columns(HWND hdlg)
{
HWND hwndList = GetDlgItem(hdlg, IDC_SETTINGSCATLIST);
RECT r;
GetWindowRect(hwndList, &r);
ListView_SetColumnWidth(hwndList, 0, (r.right - r.left) + 1 - 5);
}
static BOOL
win_settings_categories_init_columns(HWND hdlg)
{
@@ -4999,20 +5041,11 @@ win_settings_categories_init_columns(HWND hdlg)
if (ListView_InsertColumn(hwndList, iCol, &lvc) == -1)
return FALSE;
win_settings_hard_disks_resize_columns(hdlg);
win_settings_categories_resize_columns(hdlg);
return TRUE;
}
static void
win_settings_categories_resize_columns(HWND hdlg)
{
HWND hwndList = GetDlgItem(hdlg, IDC_SETTINGSCATLIST);
ListView_SetColumnWidth(hwndList, 0, MulDiv(171, dpi, 96));
}
#if defined(__amd64__) || defined(__aarch64__)
static LRESULT CALLBACK
#else

View File

@@ -216,6 +216,7 @@ ResetAllMenus(void)
CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SDL_SW, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SDL_HW, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SDL_OPENGL, MF_UNCHECKED);
#ifdef USE_VNC
CheckMenuItem(menuMain, IDM_VID_VNC, MF_UNCHECKED);
#endif
@@ -418,7 +419,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case IDM_ACTION_RESET_CAD:
pclog("-\n");
pc_send_cad();
break;
@@ -538,6 +538,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_SDL_SW:
case IDM_VID_SDL_HW:
case IDM_VID_SDL_OPENGL:
#ifdef USE_VNC
case IDM_VID_VNC:
#endif
@@ -730,6 +731,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
temp_y = (lParam >> 16);
if ((temp_x <= 0) || (temp_y <= 0)) {
plat_vidapi_enable(0);
minimized = 1;
break;
} else if (minimized == 1) {
@@ -936,6 +938,14 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
#endif
break;
case WM_ACTIVATE:
if (wParam != WA_INACTIVE) {
video_force_resize_set(1);
plat_vidapi_enable(0);
plat_vidapi_enable(1);
}
break;
case WM_ENTERSIZEMOVE:
user_resize = 1;
break;
@@ -1071,18 +1081,18 @@ ui_init(int nCmdShow)
ui_window_title(title);
/* Get the current DPI */
dpi = win_get_dpi(hwndMain);
/* Get the current DPI */
dpi = win_get_dpi(hwndMain);
/* Check if we have a padded window frame */
padded_frame = (GetSystemMetrics(SM_CXPADDEDBORDER) != 0);
/* Check if we have a padded window frame */
padded_frame = (GetSystemMetrics(SM_CXPADDEDBORDER) != 0);
/* Create the status bar window. */
StatusBarCreate(hwndMain, IDC_STATUS, hinstance);
/* Get the actual height of the status bar */
GetWindowRect(hwndSBAR, &sbar_rect);
sbar_height = sbar_rect.bottom - sbar_rect.top;
/* Get the actual height of the status bar */
GetWindowRect(hwndSBAR, &sbar_rect);
sbar_height = sbar_rect.bottom - sbar_rect.top;
/* Set up main window for resizing if configured. */
if (vid_resize)