This commit is contained in:
starfrost013
2025-03-03 01:27:51 +00:00
7 changed files with 145 additions and 45 deletions

View File

@@ -509,6 +509,11 @@ host_x86_MOV8_ABS_IMM(codeblock_t *block, void *p, uint32_t imm_data)
codegen_alloc_bytes(block, 4);
codegen_addbyte3(block, 0xc6, 0x45, offset); /*MOVB offset[RBP], imm_data*/
codegen_addbyte(block, imm_data);
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 7);
codegen_addbyte2(block, 0xc6, 0x85); /*MOVB offset[RBP], imm_data*/
codegen_addlong(block, offset);
codegen_addbyte(block, imm_data);
} else {
if ((uintptr_t) p >> 32)
fatal("host_x86_MOV8_ABS_IMM - out of range %p\n", p);
@@ -527,6 +532,11 @@ host_x86_MOV16_ABS_IMM(codeblock_t *block, void *p, uint16_t imm_data)
codegen_alloc_bytes(block, 6);
codegen_addbyte4(block, 0x66, 0xc7, 0x45, offset); /*MOV offset[RBP], imm_data*/
codegen_addword(block, imm_data);
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 8);
codegen_addbyte3(block, 0x66, 0xc7, 0x85); /*MOV offset[RBP], imm_data*/
codegen_addlong(block, offset);
codegen_addword(block, imm_data);
} else {
if ((uintptr_t) p >> 32)
fatal("host_x86_MOV32_ABS_IMM - out of range %p\n", p);
@@ -545,6 +555,11 @@ host_x86_MOV32_ABS_IMM(codeblock_t *block, void *p, uint32_t imm_data)
codegen_alloc_bytes(block, 7);
codegen_addbyte3(block, 0xc7, 0x45, offset); /*MOV offset[RBP], imm_data*/
codegen_addlong(block, imm_data);
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 10);
codegen_addbyte2(block, 0xc7, 0x85); /*MOV offset[RBP], imm_data*/
codegen_addlong(block, offset);
codegen_addlong(block, imm_data);
} else {
if ((uintptr_t) p >> 32)
fatal("host_x86_MOV32_ABS_IMM - out of range %p\n", p);
@@ -566,6 +581,10 @@ host_x86_MOV8_ABS_REG(codeblock_t *block, void *p, int src_reg)
if (offset >= -128 && offset < 127) {
codegen_alloc_bytes(block, 3);
codegen_addbyte3(block, 0x88, 0x45 | ((src_reg & 7) << 3), offset); /*MOVB offset[RBP], src_reg*/
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 6);
codegen_addbyte2(block, 0x88, 0x85 | ((src_reg & 7) << 3)); /*MOVB offset[RBP], src_reg*/
codegen_addlong(block, offset);
} else {
if ((uintptr_t) p >> 32)
fatal("host_x86_MOV8_ABS_REG - out of range %p\n", p);
@@ -630,6 +649,10 @@ host_x86_MOV64_ABS_REG(codeblock_t *block, void *p, int src_reg)
if (offset >= -128 && offset < 127) {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x48, 0x89, 0x45 | ((src_reg & 7) << 3), offset); /*MOV offset[RBP], src_reg*/
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 7);
codegen_addbyte3(block, 0x48, 0x89, 0x85 | ((src_reg & 7) << 3)); /*MOV offset[RBP], src_reg*/
codegen_addlong(block, offset);
} else {
if ((uintptr_t) p >> 32)
fatal("host_x86_MOV64_ABS_REG - out of range %p\n", p);

View File

@@ -113,33 +113,12 @@ typedef union {
static __inline void
x87_push(double i)
{
#ifdef X87_INLINE_ASM
unsigned char buffer[10];
#else
x87_conv_t test;
#endif
#ifdef USE_NEW_DYNAREC
cpu_state.TOP--;
#else
cpu_state.TOP = (cpu_state.TOP - 1) & 7;
#endif
cpu_state.ST[cpu_state.TOP & 7] = i;
#ifdef X87_INLINE_ASM
__asm volatile(""
:
:
: "memory");
__asm volatile("fldl %1\n"
"fstpt %0\n" : "=m"(buffer) : "m"(i));
cpu_state.MM[cpu_state.TOP & 7].q = (*(uint64_t*)buffer);
#else
x87_to80(i, &test);
cpu_state.MM[cpu_state.TOP & 7].q = test.eind.ll;
#endif
#ifdef USE_NEW_DYNAREC
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID;
#else
@@ -150,11 +129,6 @@ x87_push(double i)
static __inline void
x87_push_u64(uint64_t i)
{
#ifdef X87_INLINE_ASM
unsigned char buffer[10];
#else
x87_conv_t test;
#endif
union {
double d;
uint64_t ll;
@@ -168,21 +142,6 @@ x87_push_u64(uint64_t i)
cpu_state.TOP = (cpu_state.TOP - 1) & 7;
#endif
cpu_state.ST[cpu_state.TOP & 7] = td.d;
#ifdef X87_INLINE_ASM
__asm volatile(""
:
:
: "memory");
__asm volatile("fldl %1\n"
"fstpt %0\n" : "=m"(buffer) : "m"(td.d));
cpu_state.MM[cpu_state.TOP & 7].q = (*(uint64_t*)buffer);
#else
x87_to80(td.d, &test);
cpu_state.MM[cpu_state.TOP & 7].q = test.eind.ll;
#endif
#ifdef USE_NEW_DYNAREC
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID;
#else

View File

@@ -2526,7 +2526,7 @@ static const scancode scancode_set82[512] = {
{ .mk = {0xe0, 0x17, 0 }, .brk = { 0xe0, 0xF0, 0x17, 0 } }, /* 15a */
{ .mk = { 0x67, 0 }, .brk = { 0xf0, 0x67, 0 } }, /* 15b 0x33 LGUI->Muhenkan (in emulator only) */
{ .mk = { 0x64, 0 }, .brk = { 0xf0, 0x64, 0 } }, /* 15c 0x35 RGUI->Henkan (in emulator only) */
{ .mk = {0xe0, 0x11, 0 }, .brk = { 0xe0, 0xf0, 0x11, 0 } }, /* 15d 0x36 APPLICATION->Kana (in emulator
{ .mk = {0xe0, 0x11, 0 }, .brk = { 0xe0, 0xf0, 0x11, 0 } }, /* 15d 0x36 APPLICATION->Kana (in emulator only) */
{ .mk = {0xe0, 0x37, 0 }, .brk = { 0xe0, 0xF0, 0x37, 0 } }, /* 15e */
{ .mk = {0xe0, 0x3F, 0 }, .brk = { 0xe0, 0xF0, 0x3F, 0 } }, /* 15f */
{ .mk = { 0 }, .brk = { 0 } }, /* 160 */

View File

@@ -211,8 +211,121 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
(GetForegroundWindow() == ((HWND) secondaryRenderer->winId())));
}
if ((nCode < 0) || (nCode != HC_ACTION) || !is_over_window)
bool skip = ((nCode < 0) || (nCode != HC_ACTION) || !is_over_window);
if (skip)
return CallNextHookEx(NULL, nCode, wParam, lParam);
/* USB keyboards send a scancode of 0x00 for multimedia keys. */
if (lpKdhs->scanCode == 0x00) {
/* Handle USB keyboard multimedia keys where possible.
Only a handful of keys can be handled via Virtual Key
detection; rest can't be reliably detected. */
DWORD vkCode = lpKdhs->vkCode;
bool up = !!(lpKdhs->flags & LLKHF_UP);
ret = CallNextHookEx(NULL, nCode, wParam, lParam);;
switch (vkCode)
{
case VK_MEDIA_PLAY_PAUSE:
{
win_keyboard_handle(0x22, up, 1, 0);
break;
}
case VK_MEDIA_STOP:
{
win_keyboard_handle(0x24, up, 1, 0);
break;
}
case VK_VOLUME_UP:
{
win_keyboard_handle(0x30, up, 1, 0);
break;
}
case VK_VOLUME_DOWN:
{
win_keyboard_handle(0x2E, up, 1, 0);
break;
}
case VK_VOLUME_MUTE:
{
win_keyboard_handle(0x20, up, 1, 0);
break;
}
case VK_MEDIA_NEXT_TRACK:
{
win_keyboard_handle(0x19, up, 1, 0);
break;
}
case VK_MEDIA_PREV_TRACK:
{
win_keyboard_handle(0x10, up, 1, 0);
break;
}
case VK_LAUNCH_MEDIA_SELECT:
{
win_keyboard_handle(0x6D, up, 1, 0);
break;
}
case VK_LAUNCH_MAIL:
{
win_keyboard_handle(0x6C, up, 1, 0);
break;
}
case VK_LAUNCH_APP1:
{
win_keyboard_handle(0x6B, up, 1, 0);
break;
}
case VK_LAUNCH_APP2:
{
win_keyboard_handle(0x21, up, 1, 0);
break;
}
case VK_BROWSER_BACK:
{
win_keyboard_handle(0x6A, up, 1, 0);
break;
}
case VK_BROWSER_FORWARD:
{
win_keyboard_handle(0x69, up, 1, 0);
break;
}
case VK_BROWSER_STOP:
{
win_keyboard_handle(0x68, up, 1, 0);
break;
}
case VK_BROWSER_HOME:
{
win_keyboard_handle(0x32, up, 1, 0);
break;
}
case VK_BROWSER_SEARCH:
{
win_keyboard_handle(0x65, up, 1, 0);
break;
}
case VK_BROWSER_REFRESH:
{
win_keyboard_handle(0x67, up, 1, 0);
break;
}
case VK_BROWSER_FAVORITES:
{
win_keyboard_handle(0x66, up, 1, 0);
break;
}
case VK_HELP:
{
win_keyboard_handle(0x3b, up, 1, 0);
break;
}
}
return ret;
}
else if ((lpKdhs->scanCode == 0x01) && (lpKdhs->flags & LLKHF_ALTDOWN) &&
!(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
ret = TRUE;

View File

@@ -262,8 +262,10 @@ MainWindow::MainWindow(QWidget *parent)
ui->stackedWidget->mouse_capture_func(this->windowHandle());
} else {
this->releaseKeyboard();
if (ui->stackedWidget->mouse_uncapture_func)
if (ui->stackedWidget->mouse_uncapture_func) {
ui->stackedWidget->mouse_uncapture_func();
}
ui->stackedWidget->unsetCursor();
}
});

View File

@@ -155,7 +155,7 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event)
}
if (mouse_capture && (event->button() == Qt::MiddleButton) && (mouse_get_buttons() < 3)) {
plat_mouse_capture(0);
this->setCursor(Qt::ArrowCursor);
this->unsetCursor();
isMouseDown &= ~1;
return;
}

View File

@@ -4677,6 +4677,7 @@ blit_trap(mystique_t *mystique)
int err_l = (int32_t)mystique->dwgreg.ar[1];
int err_r = (int32_t)mystique->dwgreg.ar[4];
const int trans_sel = (mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANS_MASK) >> DWGCTRL_TRANS_SHIFT;
bool transc = !!(mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANSC);
switch (mystique->dwgreg.dwgctrl_running & DWGCTRL_ATYPE_MASK) {
case DWGCTRL_ATYPE_BLK:
@@ -4699,6 +4700,7 @@ blit_trap(mystique_t *mystique)
int pattern = mystique->dwgreg.pattern[yoff][xoff];
uint32_t dst;
if (!transc || (transc && pattern))
switch (mystique->maccess_running & MACCESS_PWIDTH_MASK) {
case MACCESS_PWIDTH_8:
svga->vram[(mystique->dwgreg.ydst_lin + x_l) & mystique->vram_mask] = (pattern ? mystique->dwgreg.fcol : mystique->dwgreg.bcol) & 0xff;
@@ -4770,6 +4772,7 @@ blit_trap(mystique_t *mystique)
uint32_t dst;
uint32_t old_dst;
if (!transc || (transc && pattern))
switch (mystique->maccess_running & MACCESS_PWIDTH_MASK) {
case MACCESS_PWIDTH_8:
dst = svga->vram[(mystique->dwgreg.ydst_lin + x_l) & mystique->vram_mask];