Many more cleanups all over, renaming variables for consistency etc.

More cleanups in the keyboard drivers, especially the AT one (with new changes from 86Box.)
Small update to fix the CD sound volume when using SoundBlaster.
This commit is contained in:
waltje
2019-04-28 00:54:35 -05:00
parent 212d7aea98
commit 636fcfbacb
17 changed files with 841 additions and 721 deletions

View File

@@ -9,7 +9,7 @@
* Implementation of the NEC uPD-765 and compatible floppy disk
* controller.
*
* Version: @(#)fdc.c 1.0.21 2019/04/25
* Version: @(#)fdc.c 1.0.22 2019/04/27
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <tommowalker@tommowalker.co.uk>
@@ -132,23 +132,9 @@ fdc_log(int level, const char *fmt, ...)
uint8_t
fdc_ps1_525(void)
fdc_get_current_drive(void)
{
#if 1
return fdd_is_525(current_drive) ? 0x40 : 0x00;
#else
switch (romset) {
case ROM_IBMPS1_2011:
case ROM_IBMPS1_2121:
case ROM_IBMPS1_2121_ISA:
return fdd_is_525(current_drive) ? 0x40 : 0x00;
default:
break;
}
return(0x00);
#endif
return current_drive;
}

View File

@@ -9,7 +9,7 @@
* Implementation of the NEC uPD-765 and compatible floppy disk
* controller.
*
* Version: @(#)fdc.h 1.0.5 2018/10/19
* Version: @(#)fdc.h 1.0.6 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -193,7 +193,7 @@ extern void fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side,
extern uint8_t fdc_read(uint16_t addr, void *priv);
extern void fdc_reset(void *priv);
extern uint8_t fdc_ps1_525(void);
extern uint8_t fdc_get_current_drive(void);
#endif /*EMU_FDC_H*/

View File

@@ -8,7 +8,7 @@
*
* Definitions for the keyboard interface.
*
* Version: @(#)keyboard.h 1.0.13 2019/04/26
* Version: @(#)keyboard.h 1.0.14 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -94,14 +94,16 @@ extern const device_t keyboard_at_ami_device;
extern const device_t keyboard_at_toshiba_device;
extern const device_t keyboard_ps2_device;
extern const device_t keyboard_ps2_pci_device;
extern const device_t keyboard_ps2_ps1_device;
extern const device_t keyboard_ps2_ps2_device;
extern const device_t keyboard_ps2_acer_device;
extern const device_t keyboard_ps2_xi8088_device;
extern const device_t keyboard_ps2_ami_device;
extern const device_t keyboard_ps2_ami_pci_device;
extern const device_t keyboard_ps2_mca_device;
extern const device_t keyboard_ps2_mca_2_device;
extern const device_t keyboard_ps2_quadtel_device;
extern const device_t keyboard_ps2_pci_device;
extern const device_t keyboard_ps2_ami_pci_device;
extern const device_t keyboard_ps2_xi8088_device;
#endif
extern void (*keyboard_send)(uint16_t val);

File diff suppressed because it is too large Load Diff

View File

@@ -53,7 +53,7 @@
* Microsoft Windows NT 3.1
* Microsoft Windows 98 SE
*
* Version: @(#)mouse_bus.c 1.1.8 2019/04/25
* Version: @(#)mouse_bus.c 1.1.9 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -678,6 +678,7 @@ bm_init(const device_t *info, UNUSED(void *parent))
case 1: /* on-board controller, Logitech compatible */
dev->base = 0x023c;
dev->irq = -1;
dev->bn = 2;
break;
case 10: /* Microsoft InPort controller */
@@ -689,11 +690,13 @@ bm_init(const device_t *info, UNUSED(void *parent))
case 11: /* Microsoft InPort on-board controller */
dev->flags = FLAG_INPORT;
dev->base = 0x023c;
dev->bn = 2;
dev->irq = -1;
break;
}
dev->bn = device_get_config_int("buttons");
if (dev->bn == 0)
dev->bn = device_get_config_int("buttons");
mouse_set_buttons(dev->bn);
dev->timer_enabled = 0;

View File

@@ -8,11 +8,12 @@
*
* Sound Blaster emulation.
*
* Version: @(#)snd_sb.c 1.0.11 2019/04/11
* Version: @(#)snd_sb.c 1.0.12 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
* TheCollector1995, <mariogplayer@gmail.com>
* John Sirett, <notifications@github.com> //FIXME:
* Sarah Walker, <tommowalker@tommowalker.co.uk>
*
* Copyright 2017-2019 Fred N. van Kempen.
@@ -529,8 +530,8 @@ void sb_ct1335_mixer_write(uint16_t addr, uint8_t val, void *p)
mixer->cd = sb_att_4dbstep_3bits[(mixer->regs[0x08] >> 1)&0x7];
mixer->voice = sb_att_7dbstep_2bits[(mixer->regs[0x0A] >> 1)&0x3];
sound_cd_set_volume(((uint32_t)mixer->master * (uint32_t)mixer->cd) / 65535,
((uint32_t)mixer->master * (uint32_t)mixer->cd) / 65535);
sound_cd_set_volume(((uint32_t)mixer->master * (uint32_t)mixer->cd * 4) / 65535,
((uint32_t)mixer->master * (uint32_t)mixer->cd * 4) / 65535);
}
}
@@ -650,8 +651,8 @@ void sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p)
}
/* TODO: pcspeaker volume? Or is it not worth? */
sound_cd_set_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l) / 65535,
((uint32_t)mixer->master_r * (uint32_t)mixer->cd_r) / 65535);
sound_cd_set_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l * 4) / 65535,
((uint32_t)mixer->master_r * (uint32_t)mixer->cd_r * 4) / 65535);
}
}
@@ -816,8 +817,8 @@ void sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *p)
mixer->treble_r = mixer->regs[0x45] >> 4;
/*TODO: pcspeaker volume, with "output_selector" check? or better not? */
sound_cd_set_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l) / 65535,
((uint32_t)mixer->master_r * (uint32_t)mixer->cd_r) / 65535);
sound_cd_set_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l * 4) / 65535,
((uint32_t)mixer->master_r * (uint32_t)mixer->cd_r * 4) / 65535);
DEBUG("sb_ct1745: Received register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
}
}

View File

@@ -11,7 +11,7 @@
* This is intended to be used by another SVGA driver,
* and not as a card in it's own right.
*
* Version: @(#)vid_svga.c 1.0.19 2019/04/25
* Version: @(#)vid_svga.c 1.0.20 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -135,7 +135,7 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
if (o != val)
svga_recalctimings(svga);
} else if (svga->attraddr == 0x11) {
svga->overscan_color = svga->pallook[svga->attrregs[0x11]];
svga->overscan_color = svga->pallook[svga->attrregs[0x11] & 0x3f];
if (o != val)
svga_recalctimings(svga);
} else if (svga->attraddr == 0x12) {
@@ -1209,7 +1209,7 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga)
for (i = (y_add >> 1); i < (ysize + (y_add >> 1)); i ++) {
for (j = 0; j < 8; j++) {
screen->line[i & 0x7ff][32 + j].val = svga->pallook[svga->overscan_color];
screen->line[i & 0x7ff][32 + j].val = svga->overscan_color;
screen->line[i & 0x7ff][32 + xsize + (x_add >> 1) + j].val = svga->overscan_color;
}
}

View File

@@ -42,7 +42,7 @@
* which are the same as the XGA. It supports up to 1MB of VRAM,
* but we lock it down to 512K. The PS/1 2122 had 256K.
*
* Version: @(#)vid_ti_cf62011.c 1.0.9 2019/04/19
* Version: @(#)vid_ti_cf62011.c 1.0.10 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -326,7 +326,7 @@ const device_t ti_cf62011_device = {
#endif
const device_t ibm_ps1_2121_device = {
const device_t ti_ps1_device = {
"IBM PS/1 Model 2121 SVGA",
DEVICE_VIDEO(VID_TYPE_SPEC) | DEVICE_ISA,
512,

View File

@@ -8,7 +8,7 @@
*
* IBM VGA emulation.
*
* Version: @(#)vid_vga.c 1.0.9 2019/04/19
* Version: @(#)vid_vga.c 1.0.10 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -206,8 +206,8 @@ const device_t vga_device = {
static const video_timings_t ps1vga_timing = {VID_ISA,6,8,16,6,8,16};
const device_t ps1vga_device = {
"PS/1 VGA",
const device_t vga_ps1_device = {
"VGA (PS/1)",
DEVICE_VIDEO(VID_TYPE_SPEC) | DEVICE_ISA,
1,
NULL,
@@ -219,8 +219,8 @@ const device_t ps1vga_device = {
NULL
};
const device_t ps1vga_mca_device = {
"PS/1 VGA",
const device_t vga_ps1_mca_device = {
"VGA (PS/1, MCA)",
DEVICE_VIDEO(VID_TYPE_SPEC) | DEVICE_MCA,
1,
NULL,

View File

@@ -8,7 +8,7 @@
*
* Definitions for the video controller module.
*
* Version: @(#)video.h 1.0.32 2019/04/23
* Version: @(#)video.h 1.0.33 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -307,12 +307,12 @@ extern const device_t tgui9440_pci_device;
#if defined(DEV_BRANCH) && defined(USE_TI)
extern const device_t ti_cf62011_device;
#endif
extern const device_t ibm_ps1_2121_device;
extern const device_t ti_ps1_device;
/* IBM VGA and compatibles. */
extern const device_t vga_device;
extern const device_t ps1vga_device;
extern const device_t ps1vga_mca_device;
extern const device_t vga_ps1_device;
extern const device_t vga_ps1_mca_device;
/* 3Dfx VooDoo-series cards. */
extern const device_t voodoo_device;

View File

@@ -519,7 +519,7 @@ ps1_init(const device_t *info, void *arg)
}
/* Enable the PS/1 VGA controller. */
device_add(&ps1vga_device);
device_add(&vga_ps1_device);
/* Enable the builtin sound chip. */
device_add(&snd_device);
@@ -549,7 +549,7 @@ ps1_init(const device_t *info, void *arg)
}
/* Initialize the video controller. */
device_add(&ibm_ps1_2121_device);
device_add(&ti_ps1_device);
/* Enable the builtin sound chip. */
device_add(&snd_device);
@@ -599,7 +599,7 @@ ps1_init(const device_t *info, void *arg)
device_add(&ps_nvr_device);
device_add(&keyboard_ps2_device);
device_add(&keyboard_ps2_ps1_device);
device_add(&mouse_ps2_device);

View File

@@ -8,7 +8,7 @@
*
* Implementation of ISA-based PS/2 machines.
*
* Version: @(#)m_ps2_isa.c 1.0.17 2019/04/25
* Version: @(#)m_ps2_isa.c 1.0.18 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -243,13 +243,13 @@ ps2_init(const device_t *info, void *arg)
device_add(&ps_nvr_device);
device_add(&keyboard_ps2_device);
device_add(&keyboard_ps2_ps2_device);
device_add(&fdc_at_ps1_device);
switch(dev->type) {
case 0: /* Model 30/286 */
device_add(&ps1vga_device);
device_add(&vga_ps1_device);
break;
}

View File

@@ -48,7 +48,7 @@
*
* This works around the timing loop mentioned above.
*
* Version: @(#)m_ps2_mca.c 1.0.22 2019/04/25
* Version: @(#)m_ps2_mca.c 1.0.23 2019/04/27
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -555,7 +555,7 @@ model_50_init(ps2_t *dev)
}
if (video_card == VID_INTERNAL)
device_add(&ps1vga_device);
device_add(&vga_ps1_device);
}
@@ -743,7 +743,7 @@ model_55sx_init(ps2_t *dev)
dev->planar_write = model_55sx_write;
if (video_card == VID_INTERNAL)
device_add(&ps1vga_device);
device_add(&vga_ps1_device);
}
@@ -1069,7 +1069,7 @@ model_70_init(ps2_t *dev)
}
if (video_card == VID_INTERNAL)
device_add(&ps1vga_device);
device_add(&vga_ps1_device);
}
@@ -1236,7 +1236,7 @@ model_80_init(ps2_t *dev)
}
if (video_card == VID_INTERNAL)
device_add(&ps1vga_device);
device_add(&vga_ps1_device);
}
@@ -1443,8 +1443,6 @@ ps2_init(const device_t *info, void *arg)
device_add(&ps_nvr_device);
device_add(&keyboard_ps2_mca_device);
device_add(&fdc_at_device);
parallel_setup(0, 0x03bc);
@@ -1468,19 +1466,23 @@ ps2_init(const device_t *info, void *arg)
switch(dev->type) {
case 50: /* Model 50 */
device_add(&keyboard_ps2_mca_device);
model_50_init(dev);
break;
case 55: /* Model 55SX */
device_add(&keyboard_ps2_mca_device);
model_55sx_init(dev);
break;
case 73: /* Model 70, Type 3 */
case 74: /* Model 70, Type 4 */
device_add(&keyboard_ps2_mca_device);
model_70_init(dev);
break;
case 80: /* Model 80 */
device_add(&keyboard_ps2_mca_device);
model_80_init(dev);
break;
}

View File

@@ -8,7 +8,7 @@
*
* Define the various platform support functions.
*
* Version: @(#)plat.h 1.0.23 2019/03/05
* Version: @(#)plat.h 1.0.24 2019/04/26
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -160,7 +160,8 @@ extern uint64_t plat_timer_read(void);
extern uint32_t plat_get_ticks(void);
extern void plat_delay_ms(uint32_t count);
extern void plat_mouse_capture(int on);
extern int plat_kbd_state(void);
extern int plat_get_kbd_state(void);
extern void plat_set_kbd_state(int flags);
extern void plat_fullscreen(int on);
#ifdef EMU_UI_H
extern const string_t *plat_lang_load(lang_t *ptr);

View File

@@ -8,7 +8,7 @@
*
* Misc stuff for UI, doesn't fit anywhere else..
*
* Version: @(#)ui_misc.c 1.0.2 2019/04/26
* Version: @(#)ui_misc.c 1.0.3 2019/04/26
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -60,6 +60,9 @@ ui_set_kbd_state(int flags)
{
/* First of all, update our status bar. */
ui_sb_kbstate(flags);
/* Let the platform code try to update the host keyboard. */
plat_set_kbd_state(flags);
}

View File

@@ -57,16 +57,18 @@
#include "win_d2d.h"
#define PATH_D2D_DLL "d2d1.dll"
#if USE_D2D == 2
# define PATH_D2D_DLL "d2d1.dll"
# define DLLFUNC(x) D2D1_ ## x
/* Pointers to the real functions. */
static bool (*D2D1_CreateFactory)(D2D1_FACTORY_TYPE facType,
REFIID riid,
CONST D2D1_FACTORY_OPTIONS *pFacOptions,
void **ppIFactory);
static HRESULT (*D2D1_CreateFactory)(D2D1_FACTORY_TYPE facType,
REFIID riid,
CONST D2D1_FACTORY_OPTIONS *pFacOptions,
void **ppIFactory);
static const dllimp_t d2d_imports[] = {
{ "D2D1CreateFactory", &D2D1_CreateFactory },
@@ -350,7 +352,16 @@ d2d_init(int fs)
INFO("D2D: module '%s' loaded.\n", PATH_D2D_DLL);
#endif
/* Get and log the version of the DLL we are using. */
hr = DLLFUNC(CreateFactory)(D2D1_FACTORY_TYPE_MULTI_THREADED,
__uuidof(ID2D1Factory),
NULL,
reinterpret_cast <void **>(&d2d_factory));
if (FAILED(hr)) {
ERRLOG("D2D: unable to load factory, D2D not available.\n");
d2d_close();
return(0);
}
if (fs) {
/*
* Direct2D seems to lack any proper fullscreen mode,
@@ -377,19 +388,7 @@ d2d_init(int fs)
SetFocus(d2d_hwnd);
SetWindowPos(d2d_hwnd, HWND_TOPMOST,
0,0, d2d_screen_width,d2d_screen_height, SWP_SHOWWINDOW);
}
hr = DLLFUNC(CreateFactory)(D2D1_FACTORY_TYPE_MULTI_THREADED,
__uuidof(ID2D1Factory),
NULL,
reinterpret_cast <void **>(&d2d_factory));
if (FAILED(hr)) {
ERRLOG("D2D: unable to load factory, D2D not available.\n");
d2d_close();
return(0);
}
if (fs) {
props = D2D1::HwndRenderTargetProperties(d2d_hwnd,
D2D1::SizeU(d2d_screen_width, d2d_screen_height));
} else {

View File

@@ -8,7 +8,7 @@
*
* Implement the user Interface module.
*
* Version: @(#)win_ui.c 1.0.34 2019/03/07
* Version: @(#)win_ui.c 1.0.35 2019/04/26
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -92,6 +92,8 @@ static int save_window_pos = 0;
static int cruft_x = 0,
cruft_y = 0,
cruft_sb = 0;
static int kbd_flags, /* current keyboard flags */
win_kbd_flags; /* original host keyboard flags */
static VOID APIENTRY
@@ -581,6 +583,10 @@ input_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
0);
hook_enabled = 1;
}
/* Update host keyboard state if needed. */
if (kbd_flags != win_kbd_flags)
plat_set_kbd_state(kbd_flags);
break;
case WM_KILLFOCUS:
@@ -590,6 +596,10 @@ input_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
UnhookWindowsHookEx(hKeyboardHook);
hook_enabled = 0;
}
/* Update host keyboard state if needed. */
if (kbd_flags != win_kbd_flags)
plat_set_kbd_state(win_kbd_flags);
break;
case WM_LBUTTONUP:
@@ -770,6 +780,10 @@ ui_init(int nCmdShow)
/* Set up the main window for RawInput. */
plat_set_input(hwndMain);
/* Grab the current state of the (host) keyboard. */
win_kbd_flags = plat_get_kbd_state();
kbd_flags = win_kbd_flags;
/* Create the Machine Rendering window. */
hwndRender = CreateWindow(L"STATIC",
NULL,
@@ -910,6 +924,9 @@ again:
win_mouse_close();
/* Restore host keyboard state. */
plat_set_kbd_state(win_kbd_flags);
return((int)messages.wParam);
}
@@ -1015,7 +1032,7 @@ plat_pause(int paused)
/* Grab the current keyboard state. */
int
plat_kbd_state(void)
plat_get_kbd_state(void)
{
BYTE kbdata[256];
int ret = 0x00;
@@ -1034,6 +1051,60 @@ plat_kbd_state(void)
}
/* Set the active keyboard state. */
void
plat_set_kbd_state(int flags)
{
INPUT kbdata[2];
memset(kbdata, 0x00, sizeof(kbdata));
kbdata[0].type = kbdata[1].type = INPUT_KEYBOARD;
kbdata[1].ki.dwFlags = KEYEVENTF_KEYUP;
INFO("WIN kbd_state(%04x) [%04x] focus=%d\n" , flags, kbd_flags, infocus);
if (kbd_flags != flags) {
/* Save the new flags. */
kbd_flags = flags;
/* If we are active, update the host keyboard state. */
if (infocus) {
/* Pick out the keys we are interested in. */
if (flags & KBD_FLAG_NUM) {
kbdata[0].ki.wVk = kbdata[1].ki.wVk = VK_NUMLOCK;
if (SendInput(2, kbdata, sizeof(INPUT)) == 0) {
ERRLOG("WIN: cannot SendInput(%i): error %i\n",
kbdata[0].ki.wVk, GetLastError());
}
}
if (flags & KBD_FLAG_CAPS) {
kbdata[0].ki.wVk = kbdata[1].ki.wVk = VK_CAPITAL;
if (SendInput(2, kbdata, sizeof(INPUT)) == 0) {
ERRLOG("WIN: cannot SendInput(%i): error %i\n",
kbdata[0].ki.wVk, GetLastError());
}
}
if (flags & KBD_FLAG_SCROLL) {
kbdata[0].ki.wVk = kbdata[1].ki.wVk = VK_SCROLL;
if (SendInput(2, kbdata, sizeof(INPUT)) == 0) {
ERRLOG("WIN: cannot SendInput(%i): error %i\n",
kbdata[0].ki.wVk, GetLastError());
}
}
if (flags & KBD_FLAG_PAUSE) {
kbdata[0].ki.wVk = kbdata[1].ki.wVk = VK_PAUSE;
if (SendInput(2, kbdata, sizeof(INPUT)) == 0) {
ERRLOG("WIN: cannot SendInput(%i): error %i\n",
kbdata[0].ki.wVk, GetLastError());
}
}
}
}
}
/* UI support: enable or disable mouse clipping. */
void
plat_mouse_capture(int on)