From 91d9ed5cb57ae006e5e80dd3ac314f728873435a Mon Sep 17 00:00:00 2001 From: Verloren50000 <110334428+Verloren50000@users.noreply.github.com> Date: Sat, 1 Nov 2025 13:13:00 +0800 Subject: [PATCH 01/89] Added the AwardBIOS v4.51PG variant of MS-5124 --- src/include/86box/machine.h | 3 ++ src/machine/m_at_socket7_3v.c | 65 ++++++++++++++++++++++++++++++++--- src/machine/machine_table.c | 2 +- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 628e388e8..48e7dc781 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1025,6 +1025,9 @@ extern const device_t ap5s_device; #endif extern int machine_at_ap5s_init(const machine_t *); extern int machine_at_pc140_6260_init(const machine_t *); +#ifdef EMU_DEVICE_H +extern const device_t ms5124_device; +#endif extern int machine_at_ms5124_init(const machine_t *); /* VLSI Wildcat */ diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index 7336c36d0..28c75bacb 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -1556,17 +1556,72 @@ machine_at_pc140_6260_init(const machine_t *model) return ret; } +static const device_config_t ms5124_config[] = { + // clang-format off + { + .name = "bios", + .description = "BIOS Version", + .type = CONFIG_BIOS, + .default_string = "ms5124", + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { + { + .name = "AMI WinBIOS (101094) - Revision AG77", + .internal_name = "ms5124", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 131072, + .files = { "roms/machines/ms5124/AG77.ROM", "" } + }, + { + .name = "Award Modular BIOS v4.51PG - Revision WG72P", + .internal_name = "ms5124_451pg", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 131072, + .files = { "roms/machines/ms5124/WG72P.BIN", "" } + }, + { .files_no = 0 } + } + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + +const device_t ms5124_device = { + .name = "MSI MS-5124", + .internal_name = "ms5124_device", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = ms5124_config +}; + int machine_at_ms5124_init(const machine_t *model) { - int ret; + int ret = 0; + const char *fn; - ret = bios_load_linear("roms/machines/ms5124/AG77.ROM", - 0x000e0000, 131072, 0); - - if (bios_only || !ret) + /* No ROMs available */ + if (!device_available(model->device)) return ret; + device_context(model->device); + fn = device_get_bios_file(machine_get_device(machine), device_get_config_bios("bios"), 0); + ret = bios_load_linear(fn, 0x000e0000, 131072, 0); + device_context_restore(); + machine_at_common_init_ex(model, 2); pci_init(PCI_CONFIG_TYPE_1 | FLAG_TRC_CONTROLS_CPURST); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index bd68734c7..9e7c86056 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14268,7 +14268,7 @@ const machine_t machines[] = { .kbc_p1 = 0x00000cf0, .gpio = 0xffffffff, .gpio_acpi = 0xffffffff, - .device = NULL, + .device = &ms5124_device, .kbd_device = NULL, .fdc_device = NULL, .sio_device = NULL, From c490e3e14ce67fb8249251d9bff9e1a727003386 Mon Sep 17 00:00:00 2001 From: pixel-jupiter <180155003+pixel-jupiter@users.noreply.github.com> Date: Tue, 4 Nov 2025 07:43:51 +0300 Subject: [PATCH 02/89] PCjr: Fix inverted horizontal screen movement --- src/video/vid_pcjr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vid_pcjr.c b/src/video/vid_pcjr.c index fe982980c..d9259d53a 100644 --- a/src/video/vid_pcjr.c +++ b/src/video/vid_pcjr.c @@ -269,7 +269,7 @@ vid_get_h_overscan_delta(pcjr_t *pcjr) break; } - ret = pcjr->crtc[0x02] - def; + ret = def - pcjr->crtc[0x02]; if (ret < -8) ret = -8; From c00a82c58c380a6f721243e421fedd2fc213fdbc Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Tue, 4 Nov 2025 17:03:27 +0600 Subject: [PATCH 03/89] Reapply "Merge pull request #6172 from Cacodemon345/armfixes-2" This reverts commit 5577efe301aa8babdc32602470b2b73b0c7bbc4d. --- src/codegen_new/codegen_backend_arm64_ops.c | 28 ++++++++++++++++-- src/codegen_new/codegen_backend_arm64_ops.h | 3 ++ src/codegen_new/codegen_backend_arm64_uops.c | 29 ++++++++++--------- src/codegen_new/codegen_backend_x86-64_uops.c | 12 ++++---- src/codegen_new/codegen_ir.c | 1 + src/codegen_new/codegen_ir_defs.h | 4 +-- src/codegen_new/codegen_ops.c | 26 ++++------------- src/codegen_new/codegen_ops_helpers.h | 4 +++ src/codegen_new/codegen_reg.c | 2 +- 9 files changed, 64 insertions(+), 45 deletions(-) diff --git a/src/codegen_new/codegen_backend_arm64_ops.c b/src/codegen_new/codegen_backend_arm64_ops.c index 915cae93d..9d5806edf 100644 --- a/src/codegen_new/codegen_backend_arm64_ops.c +++ b/src/codegen_new/codegen_backend_arm64_ops.c @@ -102,6 +102,10 @@ # define OPCODE_SUB_LSR (0x25a << 21) # define OPCODE_SUBX_LSL (0x658 << 21) +# define OPCODE_INS_B (0x6e010400) +# define OPCODE_INS_H (0x6e020400) +# define OPCODE_INS_S (0x6e040400) +# define OPCODE_INS_D (0x6e080400) # define OPCODE_ADD_V8B (0x0e208400) # define OPCODE_ADD_V4H (0x0e608400) # define OPCODE_ADD_V2S (0x0ea08400) @@ -180,6 +184,7 @@ # define OPCODE_SQSUB_V8B (0x0e202c00) # define OPCODE_SQSUB_V4H (0x0e602c00) # define OPCODE_SQXTN_V8B_8H (0x0e214800) +# define OPCODE_SQXTUN_V8B_8H (0x2e212800) # define OPCODE_SQXTN_V4H_4S (0x0e614800) # define OPCODE_SHL_VD (0x0f005400) # define OPCODE_SHL_VQ (0x4f005400) @@ -207,6 +212,7 @@ # define OPCODE_ZIP1_V8B (0x0e003800) # define OPCODE_ZIP1_V4H (0x0e403800) # define OPCODE_ZIP1_V2S (0x0e803800) +# define OPCODE_ZIP1_V2D (0x4ec03800) # define OPCODE_ZIP2_V8B (0x0e007800) # define OPCODE_ZIP2_V4H (0x0e407800) # define OPCODE_ZIP2_V2S (0x0e807800) @@ -225,11 +231,11 @@ # define IMM_LOGICAL(imm) ((imm) << 10) -# define BIT_TBxZ(bit) ((((bit) &0x1f) << 19) | (((bit) &0x20) ? (1 << 31) : 0)) +# define BIT_TBxZ(bit) ((((bit) & 0x1f) << 19) | (((bit) & 0x20) ? (1 << 31) : 0)) # define OFFSET14(offset) (((offset >> 2) << 5) & 0x0007ffe0) # define OFFSET19(offset) (((offset >> 2) << 5) & 0x00ffffe0) -# define OFFSET20(offset) (((offset & 3) << 29) | ((((offset) &0x1fffff) >> 2) << 5)) +# define OFFSET20(offset) (((offset & 3) << 29) | ((((offset) & 0x1fffff) >> 2) << 5)) # define OFFSET26(offset) ((offset >> 2) & 0x03ffffff) # define OFFSET12_B(offset) (offset << 10) @@ -716,6 +722,12 @@ host_arm64_DUP_V2S(codeblock_t *block, int dst_reg, int src_n_reg, int element) codegen_addlong(block, OPCODE_DUP_V2S | Rd(dst_reg) | Rn(src_n_reg) | DUP_ELEMENT(element)); } +void +host_arm64_INS_D(codeblock_t *block, int dst_reg, int src_reg, int dst_index, int src_index) +{ + codegen_addlong(block, OPCODE_INS_D | Rd(dst_reg) | Rn(src_reg) | ((dst_index & 1) << 20) | ((src_index & 1) << 14)); +} + void host_arm64_EOR_IMM(codeblock_t *block, int dst_reg, int src_n_reg, uint32_t imm_data) { @@ -1225,6 +1237,13 @@ host_arm64_SQXTN_V8B_8H(codeblock_t *block, int dst_reg, int src_reg) { codegen_addlong(block, OPCODE_SQXTN_V8B_8H | Rd(dst_reg) | Rn(src_reg)); } + +void +host_arm64_SQXTUN_V8B_8H(codeblock_t *block, int dst_reg, int src_reg) +{ + codegen_addlong(block, OPCODE_SQXTUN_V8B_8H | Rd(dst_reg) | Rn(src_reg)); +} + void host_arm64_SQXTN_V4H_4S(codeblock_t *block, int dst_reg, int src_reg) { @@ -1475,6 +1494,11 @@ host_arm64_ZIP1_V2S(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_re codegen_addlong(block, OPCODE_ZIP1_V2S | Rd(dst_reg) | Rn(src_n_reg) | Rm(src_m_reg)); } void +host_arm64_ZIP1_V2D(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg) +{ + codegen_addlong(block, OPCODE_ZIP1_V2D | Rd(dst_reg) | Rn(src_n_reg) | Rm(src_m_reg)); +} +void host_arm64_ZIP2_V8B(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg) { codegen_addlong(block, OPCODE_ZIP2_V8B | Rd(dst_reg) | Rn(src_n_reg) | Rm(src_m_reg)); diff --git a/src/codegen_new/codegen_backend_arm64_ops.h b/src/codegen_new/codegen_backend_arm64_ops.h index df751b4aa..129c2b2a3 100644 --- a/src/codegen_new/codegen_backend_arm64_ops.h +++ b/src/codegen_new/codegen_backend_arm64_ops.h @@ -72,6 +72,7 @@ void host_arm64_CSEL_EQ(codeblock_t *block, int dst_reg, int src_n_reg, int src_ void host_arm64_CSEL_VS(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); void host_arm64_DUP_V2S(codeblock_t *block, int dst_reg, int src_n_reg, int element); +void host_arm64_INS_D(codeblock_t *block, int dst_reg, int src_reg, int dst_index, int src_index); void host_arm64_EOR_IMM(codeblock_t *block, int dst_reg, int src_n_reg, uint32_t imm_data); void host_arm64_EOR_REG(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg, int shift); @@ -184,6 +185,7 @@ void host_arm64_SQSUB_V8B(codeblock_t *block, int dst_reg, int src_n_reg, int sr void host_arm64_SQSUB_V4H(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); void host_arm64_SQXTN_V8B_8H(codeblock_t *block, int dst_reg, int src_reg); +void host_arm64_SQXTUN_V8B_8H(codeblock_t *block, int dst_reg, int src_reg); void host_arm64_SQXTN_V4H_4S(codeblock_t *block, int dst_reg, int src_reg); void host_arm64_SHL_V4H(codeblock_t *block, int dst_reg, int src_reg, int shift); @@ -243,6 +245,7 @@ void host_arm64_USHR_V2D(codeblock_t *block, int dst_reg, int src_reg, int shift void host_arm64_ZIP1_V8B(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); void host_arm64_ZIP1_V4H(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); void host_arm64_ZIP1_V2S(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); +void host_arm64_ZIP1_V2D(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); void host_arm64_ZIP2_V8B(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); void host_arm64_ZIP2_V4H(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); void host_arm64_ZIP2_V2S(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg); diff --git a/src/codegen_new/codegen_backend_arm64_uops.c b/src/codegen_new/codegen_backend_arm64_uops.c index 2bb6281ff..d06685cb2 100644 --- a/src/codegen_new/codegen_backend_arm64_uops.c +++ b/src/codegen_new/codegen_backend_arm64_uops.c @@ -801,7 +801,8 @@ codegen_MMX_ENTER(codeblock_t *block, uop_t *uop) host_arm64_STR_IMM_W(block, REG_TEMP, REG_CPUSTATE, (uintptr_t) &cpu_state.tag[0] - (uintptr_t) &cpu_state); host_arm64_STR_IMM_W(block, REG_TEMP, REG_CPUSTATE, (uintptr_t) &cpu_state.tag[4] - (uintptr_t) &cpu_state); host_arm64_STR_IMM_W(block, REG_WZR, REG_CPUSTATE, (uintptr_t) &cpu_state.TOP - (uintptr_t) &cpu_state); - host_arm64_STRB_IMM(block, REG_WZR, REG_CPUSTATE, (uintptr_t) &cpu_state.ismmx - (uintptr_t) &cpu_state); + host_arm64_AND_IMM(block, REG_TEMP, REG_TEMP, 1); + host_arm64_STRB_IMM(block, REG_TEMP, REG_CPUSTATE, (uintptr_t) &cpu_state.ismmx - (uintptr_t) &cpu_state); return 0; } @@ -849,28 +850,28 @@ codegen_LOAD_FUNC_ARG3(codeblock_t *block, uop_t *uop) static int codegen_LOAD_FUNC_ARG0_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG0, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG0, uop->imm_data); return 0; } static int codegen_LOAD_FUNC_ARG1_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG1, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG1, uop->imm_data); return 0; } static int codegen_LOAD_FUNC_ARG2_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG2, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG2, uop->imm_data); return 0; } static int codegen_LOAD_FUNC_ARG3_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG3, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG3, uop->imm_data); return 0; } @@ -1448,9 +1449,9 @@ codegen_PACKSSWB(codeblock_t *block, uop_t *uop) int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { - host_arm64_SQXTN_V8B_8H(block, REG_V_TEMP, src_reg_b); - host_arm64_SQXTN_V8B_8H(block, dest_reg, dest_reg); - host_arm64_ZIP1_V2S(block, dest_reg, dest_reg, REG_V_TEMP); + host_arm64_INS_D(block, REG_V_TEMP, dest_reg, 0, 0); + host_arm64_INS_D(block, REG_V_TEMP, src_reg_b, 1, 0); + host_arm64_SQXTN_V8B_8H(block, dest_reg, REG_V_TEMP); } else fatal("PACKSSWB %02x %02x %02x\n", uop->dest_reg_a_real, uop->src_reg_a_real, uop->src_reg_b_real); @@ -1465,9 +1466,9 @@ codegen_PACKSSDW(codeblock_t *block, uop_t *uop) int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { - host_arm64_SQXTN_V4H_4S(block, REG_V_TEMP, src_reg_b); - host_arm64_SQXTN_V4H_4S(block, dest_reg, dest_reg); - host_arm64_ZIP1_V2S(block, dest_reg, dest_reg, REG_V_TEMP); + host_arm64_INS_D(block, REG_V_TEMP, dest_reg, 0, 0); + host_arm64_INS_D(block, REG_V_TEMP, src_reg_b, 1, 0); + host_arm64_SQXTN_V4H_4S(block, dest_reg, REG_V_TEMP); } else fatal("PACKSSDW %02x %02x %02x\n", uop->dest_reg_a_real, uop->src_reg_a_real, uop->src_reg_b_real); @@ -1480,9 +1481,9 @@ codegen_PACKUSWB(codeblock_t *block, uop_t *uop) int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { - host_arm64_UQXTN_V8B_8H(block, REG_V_TEMP, src_reg_b); - host_arm64_UQXTN_V8B_8H(block, dest_reg, dest_reg); - host_arm64_ZIP1_V2S(block, dest_reg, dest_reg, REG_V_TEMP); + host_arm64_INS_D(block, REG_V_TEMP, dest_reg, 0, 0); + host_arm64_INS_D(block, REG_V_TEMP, src_reg_b, 1, 0); + host_arm64_SQXTUN_V8B_8H(block, dest_reg, REG_V_TEMP); } else fatal("PACKUSWB %02x %02x %02x\n", uop->dest_reg_a_real, uop->src_reg_a_real, uop->src_reg_b_real); diff --git a/src/codegen_new/codegen_backend_x86-64_uops.c b/src/codegen_new/codegen_backend_x86-64_uops.c index 356c8bcde..6b206d5b5 100644 --- a/src/codegen_new/codegen_backend_x86-64_uops.c +++ b/src/codegen_new/codegen_backend_x86-64_uops.c @@ -220,9 +220,9 @@ static int codegen_CALL_INSTRUCTION_FUNC(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV32_REG_IMM(block, REG_ECX, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RCX, uop->imm_data); # else - host_x86_MOV32_REG_IMM(block, REG_EDI, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RDI, uop->imm_data); # endif host_x86_CALL(block, uop->p); host_x86_TEST32_REG(block, REG_EAX, REG_EAX); @@ -906,9 +906,9 @@ static int codegen_LOAD_FUNC_ARG0_IMM(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV32_REG_IMM(block, REG_ECX, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RCX, uop->imm_data); # else - host_x86_MOV32_REG_IMM(block, REG_EDI, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RDI, uop->imm_data); # endif return 0; } @@ -916,9 +916,9 @@ static int codegen_LOAD_FUNC_ARG1_IMM(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV32_REG_IMM(block, REG_EDX, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RDX, uop->imm_data); # else - host_x86_MOV32_REG_IMM(block, REG_ESI, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RSI, uop->imm_data); # endif return 0; } diff --git a/src/codegen_new/codegen_ir.c b/src/codegen_new/codegen_ir.c index d14fa0f23..dfd136289 100644 --- a/src/codegen_new/codegen_ir.c +++ b/src/codegen_new/codegen_ir.c @@ -53,6 +53,7 @@ duplicate_uop(ir_data_t *ir, uop_t *uop, int offset) new_uop->imm_data = uop->imm_data; new_uop->p = uop->p; new_uop->pc = uop->pc; + new_uop->is_a16 = uop->is_a16; if (uop->jump_dest_uop != -1) { new_uop->jump_dest_uop = uop->jump_dest_uop + offset; diff --git a/src/codegen_new/codegen_ir_defs.h b/src/codegen_new/codegen_ir_defs.h index 60f7badea..bfc19373b 100644 --- a/src/codegen_new/codegen_ir_defs.h +++ b/src/codegen_new/codegen_ir_defs.h @@ -336,7 +336,7 @@ typedef struct uop_t { ir_reg_t src_reg_a; ir_reg_t src_reg_b; ir_reg_t src_reg_c; - uint32_t imm_data; + uintptr_t imm_data; void *p; ir_host_reg_t dest_reg_a_real; ir_host_reg_t src_reg_a_real, src_reg_b_real, src_reg_c_real; @@ -601,7 +601,7 @@ uop_gen_reg_src3_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_re } static inline void -uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uint32_t imm) +uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uintptr_t imm) { uop_t *uop = uop_alloc(ir, uop_type); diff --git a/src/codegen_new/codegen_ops.c b/src/codegen_new/codegen_ops.c index bb7d1f3ee..68861ff52 100644 --- a/src/codegen_new/codegen_ops.c +++ b/src/codegen_new/codegen_ops.c @@ -86,13 +86,8 @@ RecompOpFn recomp_opcodes_0f[512] = { /*40*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*50*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 -/*60*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*70*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#else /*60*/ ropPUNPCKLBW, ropPUNPCKLWD, ropPUNPCKLDQ, ropPACKSSWB, ropPCMPGTB, ropPCMPGTW, ropPCMPGTD, ropPACKUSWB, ropPUNPCKHBW, ropPUNPCKHWD, ropPUNPCKHDQ, ropPACKSSDW, NULL, NULL, ropMOVD_r_d, ropMOVQ_r_q, /*70*/ NULL, ropPSxxW_imm, ropPSxxD_imm, ropPSxxQ_imm, ropPCMPEQB, ropPCMPEQW, ropPCMPEQD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropMOVD_d_r, ropMOVQ_q_r, -#endif /*80*/ ropJO_16, ropJNO_16, ropJB_16, ropJNB_16, ropJE_16, ropJNE_16, ropJBE_16, ropJNBE_16, ropJS_16, ropJNS_16, ropJP_16, ropJNP_16, ropJL_16, ropJNL_16, ropJLE_16, ropJNLE_16, /*90*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -100,13 +95,11 @@ RecompOpFn recomp_opcodes_0f[512] = { /*b0*/ NULL, NULL, ropLSS_16, NULL, ropLFS_16, ropLGS_16, ropMOVZX_16_8, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropMOVSX_16_8, NULL, /*c0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 -/*d0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*e0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*f0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#else /*d0*/ NULL, NULL, NULL, NULL, NULL, ropPMULLW, NULL, NULL, ropPSUBUSB, ropPSUBUSW, NULL, ropPAND, ropPADDUSB, ropPADDUSW, NULL, ropPANDN, /*e0*/ NULL, NULL, NULL, NULL, NULL, ropPMULHW, NULL, NULL, ropPSUBSB, ropPSUBSW, NULL, ropPOR, ropPADDSB, ropPADDSW, NULL, ropPXOR, +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 +/*f0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropPSUBB, ropPSUBW, ropPSUBD, NULL, ropPADDB, ropPADDW, ropPADDD, NULL, +#else /*f0*/ NULL, NULL, NULL, NULL, NULL, ropPMADDWD, NULL, NULL, ropPSUBB, ropPSUBW, ropPSUBD, NULL, ropPADDB, ropPADDW, ropPADDD, NULL, #endif @@ -119,13 +112,8 @@ RecompOpFn recomp_opcodes_0f[512] = { /*40*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*50*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 -/*60*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*70*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#else /*60*/ ropPUNPCKLBW, ropPUNPCKLWD, ropPUNPCKLDQ, ropPACKSSWB, ropPCMPGTB, ropPCMPGTW, ropPCMPGTD, ropPACKUSWB, ropPUNPCKHBW, ropPUNPCKHWD, ropPUNPCKHDQ, ropPACKSSDW, NULL, NULL, ropMOVD_r_d, ropMOVQ_r_q, /*70*/ NULL, ropPSxxW_imm, ropPSxxD_imm, ropPSxxQ_imm, ropPCMPEQB, ropPCMPEQW, ropPCMPEQD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropMOVD_d_r, ropMOVQ_q_r, -#endif /*80*/ ropJO_32, ropJNO_32, ropJB_32, ropJNB_32, ropJE_32, ropJNE_32, ropJBE_32, ropJNBE_32, ropJS_32, ropJNS_32, ropJP_32, ropJNP_32, ropJL_32, ropJNL_32, ropJLE_32, ropJNLE_32, /*90*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -133,13 +121,11 @@ RecompOpFn recomp_opcodes_0f[512] = { /*b0*/ NULL, NULL, ropLSS_32, NULL, ropLFS_32, ropLGS_32, ropMOVZX_32_8, ropMOVZX_32_16, NULL, NULL, NULL, NULL, NULL, NULL, ropMOVSX_32_8, ropMOVSX_32_16, /*c0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 -/*d0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*e0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*f0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -#else /*d0*/ NULL, NULL, NULL, NULL, NULL, ropPMULLW, NULL, NULL, ropPSUBUSB, ropPSUBUSW, NULL, ropPAND, ropPADDUSB, ropPADDUSW, NULL, ropPANDN, /*e0*/ NULL, NULL, NULL, NULL, NULL, ropPMULHW, NULL, NULL, ropPSUBSB, ropPSUBSW, NULL, ropPOR, ropPADDSB, ropPADDSW, NULL, ropPXOR, +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 +/*f0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropPSUBB, ropPSUBW, ropPSUBD, NULL, ropPADDB, ropPADDW, ropPADDD, NULL, +#else /*f0*/ NULL, NULL, NULL, NULL, NULL, ropPMADDWD, NULL, NULL, ropPSUBB, ropPSUBW, ropPSUBD, NULL, ropPADDB, ropPADDW, ropPADDD, NULL, #endif // clang-format on diff --git a/src/codegen_new/codegen_ops_helpers.h b/src/codegen_new/codegen_ops_helpers.h index 92b721099..05928bd2f 100644 --- a/src/codegen_new/codegen_ops_helpers.h +++ b/src/codegen_new/codegen_ops_helpers.h @@ -114,6 +114,10 @@ int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, static inline int codegen_can_unroll(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, uint32_t dest_addr) { + /* TODO: Re-enable this again after fixing mysterious crashes on ARM64 with MMX instructions used. */ +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 + return 0; +#endif if (block->flags & CODEBLOCK_BYTE_MASK) return 0; diff --git a/src/codegen_new/codegen_reg.c b/src/codegen_new/codegen_reg.c index f91377df8..b678bd6ac 100644 --- a/src/codegen_new/codegen_reg.c +++ b/src/codegen_new/codegen_reg.c @@ -201,7 +201,7 @@ static const uint8_t native_requested_sizes[9][8] = [REG_DOUBLE][IREG_SIZE_Q >> IREG_SIZE_SHIFT] = 1, [REG_FPU_ST_DOUBLE][IREG_SIZE_Q >> IREG_SIZE_SHIFT] = 1, - [REG_POINTER][(sizeof(void *) == 4) ? (IREG_SIZE_L >> IREG_SIZE_SHIFT) : (IREG_SIZE_Q >> IREG_SIZE_SHIFT)] = 1 + [REG_POINTER][IREG_SIZE_Q >> IREG_SIZE_SHIFT] = 1 }; void From 93d478691fb8992a3e3ea0f86a7ed644b36b7922 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Tue, 4 Nov 2025 17:05:16 +0600 Subject: [PATCH 04/89] Second take on fixing ARM64 MMX opcodes --- src/codegen_new/codegen_ir_defs.h | 15 +++++++++++---- src/codegen_new/codegen_ops_helpers.h | 4 ---- src/cpu/386_dynarec.c | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/codegen_new/codegen_ir_defs.h b/src/codegen_new/codegen_ir_defs.h index bfc19373b..da404e49e 100644 --- a/src/codegen_new/codegen_ir_defs.h +++ b/src/codegen_new/codegen_ir_defs.h @@ -660,6 +660,9 @@ uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int sr uop->p = p; } +extern int codegen_mmx_enter(void); +extern int codegen_fp_enter(void); + #define uop_LOAD_FUNC_ARG_REG(ir, arg, reg) uop_gen_reg_src1(UOP_LOAD_FUNC_ARG_0 + arg, ir, reg) #define uop_LOAD_FUNC_ARG_IMM(ir, arg, imm) uop_gen_imm(UOP_LOAD_FUNC_ARG_0_IMM + arg, ir, imm) @@ -726,15 +729,19 @@ uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int sr #define uop_FP_ENTER(ir) \ do { \ - if (!codegen_fpu_entered) \ - uop_gen_imm(UOP_FP_ENTER, ir, cpu_state.oldpc); \ + if (!codegen_fpu_entered) { \ + uop_CALL_FUNC_RESULT(ir, IREG_temp0, codegen_fp_enter); \ + uop_CMP_IMM_JZ(ir, IREG_temp0, 1, codegen_exit_rout); \ + } \ codegen_fpu_entered = 1; \ codegen_mmx_entered = 0; \ } while (0) #define uop_MMX_ENTER(ir) \ do { \ - if (!codegen_mmx_entered) \ - uop_gen_imm(UOP_MMX_ENTER, ir, cpu_state.oldpc); \ + if (!codegen_mmx_entered) { \ + uop_CALL_FUNC_RESULT(ir, IREG_temp0, codegen_mmx_enter); \ + uop_CMP_IMM_JZ(ir, IREG_temp0, 1, codegen_exit_rout); \ + } \ codegen_mmx_entered = 1; \ codegen_fpu_entered = 0; \ } while (0) diff --git a/src/codegen_new/codegen_ops_helpers.h b/src/codegen_new/codegen_ops_helpers.h index 05928bd2f..92b721099 100644 --- a/src/codegen_new/codegen_ops_helpers.h +++ b/src/codegen_new/codegen_ops_helpers.h @@ -114,10 +114,6 @@ int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, static inline int codegen_can_unroll(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, uint32_t dest_addr) { - /* TODO: Re-enable this again after fixing mysterious crashes on ARM64 with MMX instructions used. */ -#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 - return 0; -#endif if (block->flags & CODEBLOCK_BYTE_MASK) return 0; diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index 41a61495e..ff729e4cf 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -242,6 +242,20 @@ static uint64_t tsc_old = 0; int32_t acycs = 0; # endif +int +codegen_mmx_enter(void) +{ + MMX_ENTER(); + return 0; +} + +int +codegen_fp_enter(void) +{ + FP_ENTER(); + return 0; +} + void update_tsc(void) { From 3749b25c830972ec46470757390123cedbb004e1 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 4 Nov 2025 19:11:55 +0100 Subject: [PATCH 05/89] Revert the x64 changes. --- src/codegen_new/codegen_backend_x86-64_uops.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/codegen_new/codegen_backend_x86-64_uops.c b/src/codegen_new/codegen_backend_x86-64_uops.c index 6b206d5b5..356c8bcde 100644 --- a/src/codegen_new/codegen_backend_x86-64_uops.c +++ b/src/codegen_new/codegen_backend_x86-64_uops.c @@ -220,9 +220,9 @@ static int codegen_CALL_INSTRUCTION_FUNC(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV64_REG_IMM(block, REG_RCX, uop->imm_data); + host_x86_MOV32_REG_IMM(block, REG_ECX, uop->imm_data); # else - host_x86_MOV64_REG_IMM(block, REG_RDI, uop->imm_data); + host_x86_MOV32_REG_IMM(block, REG_EDI, uop->imm_data); # endif host_x86_CALL(block, uop->p); host_x86_TEST32_REG(block, REG_EAX, REG_EAX); @@ -906,9 +906,9 @@ static int codegen_LOAD_FUNC_ARG0_IMM(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV64_REG_IMM(block, REG_RCX, uop->imm_data); + host_x86_MOV32_REG_IMM(block, REG_ECX, uop->imm_data); # else - host_x86_MOV64_REG_IMM(block, REG_RDI, uop->imm_data); + host_x86_MOV32_REG_IMM(block, REG_EDI, uop->imm_data); # endif return 0; } @@ -916,9 +916,9 @@ static int codegen_LOAD_FUNC_ARG1_IMM(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV64_REG_IMM(block, REG_RDX, uop->imm_data); + host_x86_MOV32_REG_IMM(block, REG_EDX, uop->imm_data); # else - host_x86_MOV64_REG_IMM(block, REG_RSI, uop->imm_data); + host_x86_MOV32_REG_IMM(block, REG_ESI, uop->imm_data); # endif return 0; } From 98bb4950f84aece7c86778fd587ee301a629184f Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 4 Nov 2025 19:17:00 +0100 Subject: [PATCH 06/89] Revert back to the old code on x64. --- src/codegen_new/codegen_ir.c | 2 ++ src/codegen_new/codegen_ir_defs.h | 25 +++++++++++++++++++++++++ src/codegen_new/codegen_reg.c | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/src/codegen_new/codegen_ir.c b/src/codegen_new/codegen_ir.c index dfd136289..7c34a69e5 100644 --- a/src/codegen_new/codegen_ir.c +++ b/src/codegen_new/codegen_ir.c @@ -53,7 +53,9 @@ duplicate_uop(ir_data_t *ir, uop_t *uop, int offset) new_uop->imm_data = uop->imm_data; new_uop->p = uop->p; new_uop->pc = uop->pc; +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 new_uop->is_a16 = uop->is_a16; +#endif if (uop->jump_dest_uop != -1) { new_uop->jump_dest_uop = uop->jump_dest_uop + offset; diff --git a/src/codegen_new/codegen_ir_defs.h b/src/codegen_new/codegen_ir_defs.h index da404e49e..88923b5bf 100644 --- a/src/codegen_new/codegen_ir_defs.h +++ b/src/codegen_new/codegen_ir_defs.h @@ -336,7 +336,11 @@ typedef struct uop_t { ir_reg_t src_reg_a; ir_reg_t src_reg_b; ir_reg_t src_reg_c; +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 uintptr_t imm_data; +#else + uint32_t imm_data; +#endif void *p; ir_host_reg_t dest_reg_a_real; ir_host_reg_t src_reg_a_real, src_reg_b_real, src_reg_c_real; @@ -601,7 +605,11 @@ uop_gen_reg_src3_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_re } static inline void +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uintptr_t imm) +#else +uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uint32_t imm) +#endif { uop_t *uop = uop_alloc(ir, uop_type); @@ -727,6 +735,7 @@ extern int codegen_fp_enter(void); #define uop_FSQRT(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_FSQRT, ir, dst_reg, src_reg) #define uop_FTST(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_FTST, ir, dst_reg, src_reg) +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 #define uop_FP_ENTER(ir) \ do { \ if (!codegen_fpu_entered) { \ @@ -745,6 +754,22 @@ extern int codegen_fp_enter(void); codegen_mmx_entered = 1; \ codegen_fpu_entered = 0; \ } while (0) +#else +#define uop_FP_ENTER(ir) \ + do { \ + if (!codegen_fpu_entered) \ + uop_gen_imm(UOP_FP_ENTER, ir, cpu_state.oldpc); \ + codegen_fpu_entered = 1; \ + codegen_mmx_entered = 0; \ + } while (0) +#define uop_MMX_ENTER(ir) \ + do { \ + if (!codegen_mmx_entered) \ + uop_gen_imm(UOP_MMX_ENTER, ir, cpu_state.oldpc); \ + codegen_mmx_entered = 1; \ + codegen_fpu_entered = 0; \ + } while (0) +#endif #define uop_JMP(ir, p) uop_gen_pointer(UOP_JMP, ir, p) #define uop_JMP_DEST(ir) uop_gen(UOP_JMP_DEST, ir) diff --git a/src/codegen_new/codegen_reg.c b/src/codegen_new/codegen_reg.c index b678bd6ac..234cfe3a2 100644 --- a/src/codegen_new/codegen_reg.c +++ b/src/codegen_new/codegen_reg.c @@ -201,7 +201,11 @@ static const uint8_t native_requested_sizes[9][8] = [REG_DOUBLE][IREG_SIZE_Q >> IREG_SIZE_SHIFT] = 1, [REG_FPU_ST_DOUBLE][IREG_SIZE_Q >> IREG_SIZE_SHIFT] = 1, +#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 [REG_POINTER][IREG_SIZE_Q >> IREG_SIZE_SHIFT] = 1 +#else + [REG_POINTER][(sizeof(void *) == 4) ? (IREG_SIZE_L >> IREG_SIZE_SHIFT) : (IREG_SIZE_Q >> IREG_SIZE_SHIFT)] = 1 +#endif }; void From 215c5719ad5e4572cbf43b62cb4642112945047a Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 5 Nov 2025 00:30:11 +0600 Subject: [PATCH 07/89] Add some stuff that got missed in ARM64 NDR changes --- src/codegen_new/codegen_ir_defs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/codegen_new/codegen_ir_defs.h b/src/codegen_new/codegen_ir_defs.h index 88923b5bf..bec1607e0 100644 --- a/src/codegen_new/codegen_ir_defs.h +++ b/src/codegen_new/codegen_ir_defs.h @@ -739,6 +739,7 @@ extern int codegen_fp_enter(void); #define uop_FP_ENTER(ir) \ do { \ if (!codegen_fpu_entered) { \ + uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); \ uop_CALL_FUNC_RESULT(ir, IREG_temp0, codegen_fp_enter); \ uop_CMP_IMM_JZ(ir, IREG_temp0, 1, codegen_exit_rout); \ } \ @@ -748,6 +749,7 @@ extern int codegen_fp_enter(void); #define uop_MMX_ENTER(ir) \ do { \ if (!codegen_mmx_entered) { \ + uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); \ uop_CALL_FUNC_RESULT(ir, IREG_temp0, codegen_mmx_enter); \ uop_CMP_IMM_JZ(ir, IREG_temp0, 1, codegen_exit_rout); \ } \ From daf34f3dcd77c01bc348041af5abc5fe9ca83616 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 02:54:51 +0100 Subject: [PATCH 08/89] (S)VGA: Bring back specific pel panning behavior for some ATi and Tseng graphics cards, closes #6437. --- src/video/vid_ati_mach64.c | 2 + src/video/vid_et4000w32.c | 1 + src/video/vid_svga.c | 96 ++++++++++++++++++++++++++++---------- 3 files changed, 74 insertions(+), 25 deletions(-) diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 95a32dabe..e464ec7a5 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -5027,6 +5027,7 @@ mach64vt_init(const device_t *info) mem_mapping_disable(&mach64->bios_rom.mapping); svga->vblank_start = mach64_vblank_start; + svga->adv_flags |= FLAG_PANNING_ATI; return mach64; } @@ -5058,6 +5059,7 @@ mach64vt2_init(const device_t *info) mem_mapping_disable(&mach64->bios_rom.mapping); svga->vblank_start = mach64_vblank_start; + svga->adv_flags |= FLAG_PANNING_ATI; return mach64; } diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index cd78c555e..54154fb93 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -2966,6 +2966,7 @@ et4000w32p_init(const device_t *info) et4000->pci_regs[0x33] = 0xf0; et4000->svga.packed_chain4 = 1; + et4000->svga.adv_flags |= FLAG_PANNING_ATI; return et4000; } diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 03f829e74..af15fe178 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1421,6 +1421,41 @@ svga_poll(void *priv) } else { timer_advance_u64(&svga->timer, svga->dispontime); + if (svga->adv_flags & FLAG_PANNING_ATI) { + if (svga->panning_blank) { + svga->scrollcache = 0; + svga->half_pixel = 0; + + svga->x_add = svga->left_overscan; + } else { + svga->scrollcache = (svga->attrregs[0x13] & 0x0f); + if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /*Text mode*/ + if (svga->seqregs[1] & 1) + svga->scrollcache &= 0x07; + else { + svga->scrollcache++; + if (svga->scrollcache > 8) + svga->scrollcache = 0; + } + svga->half_pixel = 0; + } else if ((svga->render == svga_render_2bpp_lowres) || (svga->render == svga_render_2bpp_highres) || + (svga->render == svga_render_4bpp_lowres) || (svga->render == svga_render_4bpp_highres)) { + svga->half_pixel = 0; + svga->scrollcache &= 0x07; + } else { + if (svga->scrollcache > 7) + svga->scrollcache = 7; + svga->half_pixel = svga->scrollcache & 0x01; + svga->scrollcache = (svga->scrollcache & 0x06) >> 1; + } + + if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) + svga->scrollcache <<= 1; + + svga->x_add = svga->left_overscan - svga->scrollcache; + } + } + if (svga->dispon) svga->cgastat &= ~1; svga->hdisp_on = 0; @@ -1477,9 +1512,13 @@ svga_poll(void *priv) svga->scanline = 0; if (svga->attrregs[0x10] & 0x20) { - svga->scrollcache = 0; - svga->half_pixel = 0; - svga->x_add = svga->left_overscan; + if (svga->adv_flags & FLAG_PANNING_ATI) + svga->panning_blank = 1; + else { + svga->scrollcache = 0; + svga->half_pixel = 0; + svga->x_add = svga->left_overscan; + } } } } @@ -1570,32 +1609,39 @@ svga_poll(void *priv) svga->dispon = 1; svga->displine = (svga->interlace && svga->oddeven) ? 1 : 0; - svga->scrollcache = (svga->attrregs[0x13] & 0x0f); - if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /*Text mode*/ - if (svga->seqregs[1] & 1) - svga->scrollcache &= 0x07; - else { - svga->scrollcache++; - if (svga->scrollcache > 8) - svga->scrollcache = 0; - } + if ((svga->adv_flags & FLAG_PANNING_ATI) && svga->panning_blank) { + svga->scrollcache = 0; svga->half_pixel = 0; - } else if ((svga->render == svga_render_2bpp_lowres) || (svga->render == svga_render_2bpp_highres) || - (svga->render == svga_render_4bpp_lowres) || (svga->render == svga_render_4bpp_highres)) { - svga->half_pixel = 0; - svga->scrollcache &= 0x07; + + svga->x_add = svga->left_overscan; } else { - if (svga->scrollcache > 7) - svga->scrollcache = 7; - svga->half_pixel = svga->scrollcache & 0x01; - svga->scrollcache = (svga->scrollcache & 0x06) >> 1; + svga->scrollcache = (svga->attrregs[0x13] & 0x0f); + if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /*Text mode*/ + if (svga->seqregs[1] & 1) + svga->scrollcache &= 0x07; + else { + svga->scrollcache++; + if (svga->scrollcache > 8) + svga->scrollcache = 0; + } + svga->half_pixel = 0; + } else if ((svga->render == svga_render_2bpp_lowres) || (svga->render == svga_render_2bpp_highres) || + (svga->render == svga_render_4bpp_lowres) || (svga->render == svga_render_4bpp_highres)) { + svga->half_pixel = 0; + svga->scrollcache &= 0x07; + } else { + if (svga->scrollcache > 7) + svga->scrollcache = 7; + svga->half_pixel = svga->scrollcache & 0x01; + svga->scrollcache = (svga->scrollcache & 0x06) >> 1; + } + + if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) + svga->scrollcache <<= 1; + + svga->x_add = svga->left_overscan - svga->scrollcache; } - if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) - svga->scrollcache <<= 1; - - svga->x_add = svga->left_overscan - svga->scrollcache; - svga->linecountff = 0; svga->hwcursor_on = 0; From f81c293485a509d4abec4871baa3167d5a5de163 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 03:04:49 +0100 Subject: [PATCH 09/89] And I forgot a missing fraction (and vid_svga.h). --- src/86box.c | 2 +- src/include/86box/vid_svga.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/86box.c b/src/86box.c index 8b2dddc7f..fae30ca5e 100644 --- a/src/86box.c +++ b/src/86box.c @@ -1744,7 +1744,7 @@ update_mouse_msg(void) plat_get_string(STRING_MOUSE_CAPTURE)); swprintf(mouse_msg[1], sizeof_w(mouse_msg[1]), L"%%i%%%% - %ls", (mouse_get_buttons() > 2) ? plat_get_string(STRING_MOUSE_RELEASE) : plat_get_string(STRING_MOUSE_RELEASE_MMB)); - wcsncpy(mouse_msg[2], L"%i.%i%%", sizeof_w(mouse_msg[2])); + wcsncpy(mouse_msg[2], L"%i%%", sizeof_w(mouse_msg[2])); #else swprintf(mouse_msg[0], sizeof_w(mouse_msg[0]), L"%ls v%ls - %%i%%%% - %ls - %ls/%ls - %ls", EMU_NAME_W, EMU_VERSION_FULL_W, wmachine, wcpufamily, wcpu, diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 814a986c3..252463af7 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -29,6 +29,7 @@ # define FLAG_512K_MASK 512 # define FLAG_NO_SHIFT3 1024 /* Needed for Bochs VBE. */ # define FLAG_PRECISETIME 2048 /* Needed for Copper demo if on dynarec. */ +# define FLAG_PANNING_ATI 4096 struct monitor_t; typedef struct hwcursor_t { @@ -136,6 +137,7 @@ typedef struct svga_t { int ps_bit_bug; int ati_4color; int vblankend; + int panning_blank; int render_line_offset; int start_retrace_latch; int vga_mode; From 872ad63c1265ed7ec755e60683be8da496d1108a Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 04:11:37 +0100 Subject: [PATCH 10/89] PC87306 Super I/O chip fixes, fixes #6428. --- src/sio/sio_pc87306.c | 172 ++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 105 deletions(-) diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index f9e066b1f..38e695727 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -38,6 +38,7 @@ typedef struct pc87306_t { uint8_t tries; + uint8_t cfg_lock; uint8_t regs[29]; uint8_t gpio[2]; uint16_t gpioba; @@ -125,6 +126,7 @@ lpt_handler(pc87306_t *dev) uint8_t lpt_irq = LPT2_IRQ; uint8_t cnfgb_readout = 0x08; + pclog("Removing LPT port...\n"); lpt_port_remove(dev->lpt); temp = dev->regs[0x01] & 3; @@ -155,6 +157,9 @@ lpt_handler(pc87306_t *dev) break; } + if (!(dev->regs[0x00] & 0x01)) + lpt_port = 0x000; + if (dev->regs[0x1b] & 0x10) lpt_irq = (dev->regs[0x1b] & 0x20) ? 7 : 5; @@ -167,8 +172,10 @@ lpt_handler(pc87306_t *dev) lpt_set_epp(dev->lpt, !!(dev->regs[0x04] & 0x01)); lpt_set_ecp(dev->lpt, !!(dev->regs[0x04] & 0x04)); - if (lpt_port) + if (lpt_port) { + pclog("Setting up LPT port at %04X...\n", lpt_port); lpt_port_setup(dev->lpt, lpt_port); + } lpt_port_irq(dev->lpt, lpt_irq); @@ -187,18 +194,20 @@ serial_handler(pc87306_t *dev, int uart) uint8_t pnp_shift; uint8_t irq; - temp = (dev->regs[0x01] >> (2 << uart)) & 3; + serial_remove(dev->uart[uart]); fer_shift = 2 << uart; /* 2 for UART 1, 4 for UART 2 */ pnp_shift = 2 + (uart << 2); /* 2 for UART 1, 6 for UART 2 */ + temp = (dev->regs[0x01] >> fer_shift) & 3; + /* 0 = COM1 (IRQ 4), 1 = COM2 (IRQ 3), 2 = COM3 (IRQ 4), 3 = COM4 (IRQ 3) */ fer_irq = ((dev->regs[1] >> fer_shift) & 1) ? 3 : 4; pnp1_irq = ((dev->regs[0x1c] >> pnp_shift) & 1) ? 4 : 3; irq = (dev->regs[0x1c] & 1) ? pnp1_irq : fer_irq; - switch (temp) { + if (dev->regs[0x00] & fer_shift) switch (temp) { case 0: serial_setup(dev->uart[uart], COM1_ADDR, irq); break; @@ -273,13 +282,15 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) return; } else { if (dev->tries) { - if ((dev->cur_reg == 0) && (val == 8)) - val = 0x4b; + if (dev->cfg_lock) + return; + valxor = val ^ dev->regs[dev->cur_reg]; dev->tries = 0; - if ((dev->cur_reg <= 28) && (dev->cur_reg != 8)) { - if (dev->cur_reg == 0) - val &= 0x5f; + if ((dev->cur_reg <= 0x1c) && (dev->cur_reg != 0x08)) { + if ((dev->cur_reg == 0x00) && (val == 0x08)) + val = 0x4f; + dev->regs[dev->cur_reg] = val; } else return; @@ -291,21 +302,12 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) switch (dev->cur_reg) { case 0x00: - if (valxor & 0x01) { - lpt_port_remove(dev->lpt); - if ((val & 1) && !(dev->regs[0x02] & 1)) - lpt_handler(dev); - } - if (valxor & 0x02) { - serial_remove(dev->uart[0x00]); - if ((val & 2) && !(dev->regs[0x02] & 1)) - serial_handler(dev, 0); - } - if (valxor & 0x04) { - serial_remove(dev->uart[0x01]); - if ((val & 4) && !(dev->regs[0x02] & 1)) - serial_handler(dev, 1); - } + if (valxor & 0x01) + lpt_handler(dev); + if (valxor & 0x02) + serial_handler(dev, 0); + if (valxor & 0x04) + serial_handler(dev, 1); if (valxor & 0x28) { fdc_remove(dev->fdc); if ((val & 8) && !(dev->regs[0x02] & 1)) @@ -313,52 +315,24 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) } break; case 0x01: - if (valxor & 0x03) { - lpt_port_remove(dev->lpt); - if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1)) - lpt_handler(dev); - } - if (valxor & 0xcc) { - serial_remove(dev->uart[0x00]); - if ((dev->regs[0x00] & 2) && !(dev->regs[0x02] & 1)) - serial_handler(dev, 0); - } - if (valxor & 0xf0) { - serial_remove(dev->uart[0x01]); - if ((dev->regs[0x00] & 4) && !(dev->regs[0x02] & 1)) - serial_handler(dev, 1); - } + if (valxor & 0x03) + lpt_handler(dev); + if (valxor & 0xcc) + serial_handler(dev, 0); + if (valxor & 0xf0) + serial_handler(dev, 1); break; case 0x02: - if (valxor & 0x01) { - lpt_port_remove(dev->lpt); - serial_remove(dev->uart[0x00]); - serial_remove(dev->uart[0x01]); - fdc_remove(dev->fdc); - - if (!(val & 1)) { - if (dev->regs[0x00] & 0x01) - lpt_handler(dev); - if (dev->regs[0x00] & 0x02) - serial_handler(dev, 0); - if (dev->regs[0x00] & 0x04) - serial_handler(dev, 1); - if (dev->regs[0x00] & 0x08) - fdc_set_base(dev->fdc, (dev->regs[0x00] & 0x20) ? FDC_SECONDARY_ADDR : FDC_PRIMARY_ADDR); - } - } - if (valxor & 0x88) { - lpt_port_remove(dev->lpt); - if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1)) - lpt_handler(dev); - } + if (valxor & 0x01) + fdc_set_power_down(dev->fdc, val & 0x01); + if (valxor & 0x40) + dev->cfg_lock = val & 0x40; + if (valxor & 0x88) + lpt_handler(dev); break; case 0x04: - if (valxor & (0x05)) { - lpt_port_remove(dev->lpt); - if ((dev->regs[0x00] & 0x01) && !(dev->regs[0x02] & 0x01)) - lpt_handler(dev); - } + if (valxor & (0x05)) + lpt_handler(dev); if (valxor & 0x80) nvr_lock_set(0x00, 256, !!(val & 0x80), dev->nvr); break; @@ -389,37 +363,24 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) pc87306_gpio_handler(dev); break; case 0x18: - if (valxor & (0x0e)) { - lpt_port_remove(dev->lpt); - if ((dev->regs[0x00] & 0x01) && !(dev->regs[0x02] & 0x01)) - lpt_handler(dev); - } + if (valxor & (0x0e)) + lpt_handler(dev); break; case 0x19: - if (valxor) { - lpt_port_remove(dev->lpt); - if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1)) - lpt_handler(dev); - } + if (valxor) + lpt_handler(dev); break; case 0x1b: if (valxor & 0x70) { - lpt_port_remove(dev->lpt); if (!(val & 0x40)) dev->regs[0x19] = 0xef; - if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1)) - lpt_handler(dev); + lpt_handler(dev); } break; case 0x1c: if (valxor) { - serial_remove(dev->uart[0x00]); - serial_remove(dev->uart[0x01]); - - if ((dev->regs[0x00] & 2) && !(dev->regs[0x02] & 1)) - serial_handler(dev, 0); - if ((dev->regs[0x00] & 4) && !(dev->regs[0x02] & 1)) - serial_handler(dev, 1); + serial_handler(dev, 0); + serial_handler(dev, 1); } break; @@ -437,15 +398,17 @@ pc87306_read(uint16_t port, void *priv) index = (port & 1) ? 0 : 1; - if (dev->tries == 0xff) { - ret = 0x88; - dev->tries = 0xfe; - } else if (dev->tries == 0xfe) { - ret = 0x00; - dev->tries = 0; - } else if (index) { - ret = dev->cur_reg & 0x1f; - dev->tries = 0; + if (index) { + if (dev->tries == 0xff) { + ret = 0x88; + dev->tries = 0xfe; + } else if (dev->tries == 0xfe) { + ret = 0x00; + dev->tries = 0; + } else { + ret = dev->cur_reg & 0x1f; + dev->tries = 0; + } } else { if (dev->cur_reg == 8) ret = 0x70; @@ -462,30 +425,27 @@ pc87306_reset_common(void *priv) { pc87306_t *dev = (pc87306_t *) priv; - memset(dev->regs, 0, 29); - + memset(dev->regs, 0x00, 29); dev->tries = 0xff; - dev->regs[0x00] = 0x0B; - dev->regs[0x01] = 0x01; + dev->regs[0x00] = 0x00; + dev->regs[0x01] = 0x10; + dev->regs[0x02] = 0x08; dev->regs[0x03] = 0x01; - dev->regs[0x05] = 0x0D; + dev->regs[0x05] = 0x0d; dev->regs[0x08] = 0x70; - dev->regs[0x09] = 0xC0; + dev->regs[0x09] = 0xc0; dev->regs[0x0b] = 0x80; - dev->regs[0x0f] = 0x1E; + dev->regs[0x0f] = 0x1e; dev->regs[0x12] = 0x30; - dev->regs[0x19] = 0xEF; + dev->regs[0x19] = 0xef; /* 0 = 360 rpm @ 500 kbps for 3.5" 1 = Default, 300 rpm @ 500, 300, 250, 1000 kbps for 3.5" */ lpt_set_cnfga_readout(dev->lpt, 0x10); - lpt_port_remove(dev->lpt); lpt_handler(dev); - serial_remove(dev->uart[0x00]); - serial_remove(dev->uart[0x01]); serial_handler(dev, 0); serial_handler(dev, 1); fdc_reset(dev->fdc); @@ -495,6 +455,8 @@ pc87306_reset_common(void *priv) nvr_at_handler(1, 0x0070, dev->nvr); nvr_bank_set(0, 0, dev->nvr); nvr_wp_set(0, 0, dev->nvr); + + dev->cfg_lock = 0; } void From e0a3509a119169af65e3b1cdca862252c515b09f Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 04:12:50 +0100 Subject: [PATCH 11/89] PC87306: Remove some excess logging. --- src/sio/sio_pc87306.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index 38e695727..d347048bb 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -126,7 +126,6 @@ lpt_handler(pc87306_t *dev) uint8_t lpt_irq = LPT2_IRQ; uint8_t cnfgb_readout = 0x08; - pclog("Removing LPT port...\n"); lpt_port_remove(dev->lpt); temp = dev->regs[0x01] & 3; @@ -172,10 +171,8 @@ lpt_handler(pc87306_t *dev) lpt_set_epp(dev->lpt, !!(dev->regs[0x04] & 0x01)); lpt_set_ecp(dev->lpt, !!(dev->regs[0x04] & 0x04)); - if (lpt_port) { - pclog("Setting up LPT port at %04X...\n", lpt_port); + if (lpt_port) lpt_port_setup(dev->lpt, lpt_port); - } lpt_port_irq(dev->lpt, lpt_irq); From 6e4b62d24f2060b43d317cb1f7b3050b217d6a7c Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 06:03:59 +0100 Subject: [PATCH 12/89] PC87306: More fixes. --- src/sio/sio_pc87306.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index d347048bb..5b9cafa37 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -425,12 +425,12 @@ pc87306_reset_common(void *priv) memset(dev->regs, 0x00, 29); dev->tries = 0xff; - dev->regs[0x00] = 0x00; - dev->regs[0x01] = 0x10; + dev->regs[0x00] = 0x0b; + dev->regs[0x01] = 0x01; dev->regs[0x02] = 0x08; dev->regs[0x03] = 0x01; dev->regs[0x05] = 0x0d; - dev->regs[0x08] = 0x70; + dev->regs[0x08] = 0x71; dev->regs[0x09] = 0xc0; dev->regs[0x0b] = 0x80; dev->regs[0x0f] = 0x1e; From 031c382c3eca5427436433875f51f9fabc143599 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 06:12:09 +0100 Subject: [PATCH 13/89] PC87306: Properly fix the ID readout, now it works on the Thor & Co. even without the register 0x00 hack. --- src/sio/sio_pc87306.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index 5b9cafa37..7fdf6d2d6 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -284,12 +284,9 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) valxor = val ^ dev->regs[dev->cur_reg]; dev->tries = 0; - if ((dev->cur_reg <= 0x1c) && (dev->cur_reg != 0x08)) { - if ((dev->cur_reg == 0x00) && (val == 0x08)) - val = 0x4f; - + if ((dev->cur_reg <= 0x1c) && (dev->cur_reg != 0x08)) dev->regs[dev->cur_reg] = val; - } else + else return; } else { dev->tries++; @@ -407,8 +404,8 @@ pc87306_read(uint16_t port, void *priv) dev->tries = 0; } } else { - if (dev->cur_reg == 8) - ret = 0x70; + if (dev->cur_reg == 0x08) + ret = 0x71; else if (dev->cur_reg < 28) ret = dev->regs[dev->cur_reg]; dev->tries = 0; @@ -427,7 +424,6 @@ pc87306_reset_common(void *priv) dev->regs[0x00] = 0x0b; dev->regs[0x01] = 0x01; - dev->regs[0x02] = 0x08; dev->regs[0x03] = 0x01; dev->regs[0x05] = 0x0d; dev->regs[0x08] = 0x71; From 33bca0521c366921a329ab80962ffbff8184418c Mon Sep 17 00:00:00 2001 From: Bozo Scum Date: Wed, 5 Nov 2025 17:52:15 +0800 Subject: [PATCH 14/89] new machine: Thomson TO16 --- src/include/86box/machine.h | 4 ++ src/machine/m_xt.c | 100 ++++++++++++++++++++++++++++++++++++ src/machine/machine_table.c | 43 ++++++++++++++++ 3 files changed, 147 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 628e388e8..11992f764 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1446,6 +1446,10 @@ extern int machine_xt_pb8810_init(const machine_t *); extern int machine_xt_sansx16_init(const machine_t *); extern int machine_xt_pcxt_init(const machine_t *); #ifdef EMU_DEVICE_H +extern const device_t to16_device; +#endif +extern int machine_xt_to16_init(const machine_t *); +#ifdef EMU_DEVICE_H extern const device_t vendex_device; #endif extern int machine_xt_vendex_init(const machine_t *); diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 007e8c7c4..f0b5d37a6 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -1704,6 +1704,106 @@ machine_xt_pcxt_init(const machine_t *model) return ret; } +static const device_config_t to16_config[] = { + // clang-format off + { + .name = "bios", + .description = "BIOS Version", + .type = CONFIG_BIOS, + .default_string = "to16", + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .bios = { + { + .name = "1.03", + .internal_name = "to16", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 32768, + .files = { "roms/machines/to16/TO16_103.bin", "" } + }, + { .files_no = 0 } + }, + }, + { + .name = "rtc_port", + .description = "Onboard RTC", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "Uninstalled", .value = 0 }, + { .description = "RTC0", .value = 0x300 }, + { .description = "RTC1", .value = 0x2c0 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "rtc_irq", + .description = "RTC IRQ2", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = -1, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "Disabled", .value = -1 }, + { .description = "Enabled", .value = 2 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + +const device_t to16_device = { + .name = "Thomson TO16", + .internal_name = "to16_device", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = to16_config +}; + +int +machine_xt_to16_init(const machine_t *model) +{ + int ret = 0; + int rtc_port = 0; + const char *fn; + + /* No ROMs available. */ + if (!device_available(model->device)) + return ret; + + device_context(model->device); + rtc_port = machine_get_config_int("rtc_port"); + fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 0); + ret = bios_load_linear(fn, 0x000f8000, 32768, 0); + device_context_restore(); + + if (bios_only || !ret) + return ret; + + machine_xt_clone_init(model, 0); + + if (rtc_port != 0) + device_add(&rtc58167_device); + + return ret; +} + static const device_config_t vendex_config[] = { // clang-format off { diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index bd68734c7..72806d9d8 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -1784,6 +1784,49 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + { + .name = "[8088] Thomson TO16", + .internal_name = "to16", + .type = MACHINE_TYPE_8088, + .chipset = MACHINE_CHIPSET_DISCRETE, + .init = machine_xt_to16_init, + .p1_handler = NULL, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_8088, + .block = CPU_BLOCK_NONE, + .min_bus = 0, + .max_bus = 0, + .min_voltage = 0, + .max_voltage = 0, + .min_multi = 0, + .max_multi = 0 + }, + .bus_flags = MACHINE_PC, + .flags = MACHINE_FLAGS_NONE, + .ram = { + .min = 64, + .max = 768, + .step = 64 + }, + .nvrmask = 0, + .jumpered_ecp_dma = 0, + .default_jumpered_ecp_dma = -1, + .kbc_device = &kbc_xtclone_device, + .kbc_params = 0x00000000, + .kbc_p1 = 0xff, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = &to16_device, + .kbd_device = &keyboard_pc_xt_device, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = NULL, + .net_device = NULL + }, { .name = "[8088] Toshiba T1000", .internal_name = "t1000", From 138929caec75ecd0ee528b87639fedf178cd9c1c Mon Sep 17 00:00:00 2001 From: Vitaly Orekhov Date: Wed, 5 Nov 2025 15:59:43 +0300 Subject: [PATCH 15/89] 8514/A: Fix first NVRAM initialization on MCA bus version made by ATI Prior to this change it was not possible to start the emulated machine with this graphics adapter installed on any operating system different from Windows, causing crash with exit code 11. --- src/video/vid_ati_eeprom.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index 84cbffedb..3f9d707ca 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -56,7 +56,6 @@ ati_eeprom_load_mach8(ati_eeprom_t *eeprom, char *fn, int mca) size = 128; if (!fp) { if (mca) { - (void) fseek(fp, 2L, SEEK_SET); memset(eeprom->data + 2, 0xff, size - 2); fp = nvr_fopen(eeprom->fn, "wb"); fwrite(eeprom->data, 1, size, fp); From 3dc3cfc00de58b6f3ffb03973de4cd1825ea66ba Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 15:03:32 +0100 Subject: [PATCH 16/89] ATi Mach8 EEPROM: Remove superfluous (and emulator-crashing!) fseek(). --- src/video/vid_ati_eeprom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index 84cbffedb..8baa72351 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -54,9 +54,8 @@ ati_eeprom_load_mach8(ati_eeprom_t *eeprom, char *fn, int mca) strncpy(eeprom->fn, fn, sizeof(eeprom->fn) - 1); fp = nvr_fopen(eeprom->fn, "rb"); size = 128; - if (!fp) { + if (fp == NULL) { if (mca) { - (void) fseek(fp, 2L, SEEK_SET); memset(eeprom->data + 2, 0xff, size - 2); fp = nvr_fopen(eeprom->fn, "wb"); fwrite(eeprom->data, 1, size, fp); From 6afc72b86038ff2b6fadb8a8f78169ee69f5123a Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 17:36:54 +0100 Subject: [PATCH 17/89] IBM PS/ValuePoint 433: Fix on-board ET4000/W32. --- src/machine/m_at_socket2.c | 12 +++++++++++- src/video/vid_et4000w32.c | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/machine/m_at_socket2.c b/src/machine/m_at_socket2.c index b7cf93d92..8ea151f53 100644 --- a/src/machine/m_at_socket2.c +++ b/src/machine/m_at_socket2.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #define HAVE_STDARG_H @@ -333,11 +334,13 @@ machine_at_valuepoint433_init(const machine_t *model) // hangs without the PS/2 int ret; ret = bios_load_linear("roms/machines/valuepoint433/$IMAGEP.FLH", - 0x000e0000, 131072, 0); + 0x000c0000, 262144, 0); if (bios_only || !ret) return ret; + memcpy(&rom[0x00020000], rom, 131072); + machine_at_common_ide_init(model); device_add(&sis_85c461_device); if (gfxcard[0] == VID_INTERNAL) @@ -350,6 +353,13 @@ machine_at_valuepoint433_init(const machine_t *model) // hangs without the PS/2 if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); + if (gfxcard[0] != VID_INTERNAL) { + for (uint16_t i = 0; i < 32768; i++) + rom[i] = mem_readb_phys(0x000c0000 + i); + } + mem_mapping_set_addr(&bios_mapping, 0x0c0000, 0x40000); + mem_mapping_set_exec(&bios_mapping, rom); + return ret; } diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index 54154fb93..c0d802fe4 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -2825,8 +2825,9 @@ et4000w32p_init(const device_t *info) et4000->rev = ET4000W32; et4000->ramdac_type = ET4K_SDAC; - rom_init(&et4000->bios_rom, BIOS_ROM_PATH_W32_MACHSPEED_VGA_GUI_2400S, 0xc0000, 0x8000, 0x7fff, 0, - MEM_MAPPING_EXTERNAL); + if (!(info->local & 0x100)) + rom_init(&et4000->bios_rom, BIOS_ROM_PATH_W32_MACHSPEED_VGA_GUI_2400S, 0xc0000, 0x8000, 0x7fff, 0, + MEM_MAPPING_EXTERNAL); et4000->svga.ramdac = device_add(&tseng_ics5301_ramdac_device); et4000->svga.clock_gen = et4000->svga.ramdac; From ae5a34d31cada09eddab437e89d97410b3b8508b Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 5 Nov 2025 17:39:55 +0100 Subject: [PATCH 18/89] VIA Apollo: Fix all the improper VT8601 checks. --- src/chipset/via_apollo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chipset/via_apollo.c b/src/chipset/via_apollo.c index 974f4e274..3236bbbbe 100644 --- a/src/chipset/via_apollo.c +++ b/src/chipset/via_apollo.c @@ -348,7 +348,7 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv) break; case 0x58: - if ((dev->id >= VIA_585) || (dev->id < VIA_597) || (dev->id == VIA_597) || ((dev->id >= VIA_693A) || (dev->id < VIA_8601))) + if ((dev->id >= VIA_585) || (dev->id < VIA_597) || (dev->id == VIA_597) || ((dev->id >= VIA_693A) && (dev->id < VIA_8601))) dev->pci_conf[0x58] = (dev->pci_conf[0x58] & ~0xee) | (val & 0xee); else dev->pci_conf[0x58] = val; @@ -501,14 +501,14 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv) break; case 0x69: if ((dev->id != VIA_585) || (dev->id != VIA_595)) { - if ((dev->id == VIA_693A) || (dev->id < VIA_8601)) + if ((dev->id == VIA_693A) && (dev->id < VIA_8601)) dev->pci_conf[0x69] = (dev->pci_conf[0x69] & ~0xfe) | (val & 0xfe); else dev->pci_conf[0x69] = val; } break; case 0x6b: - if ((dev->id == VIA_693A) || (dev->id < VIA_8601)) + if ((dev->id == VIA_693A) && (dev->id < VIA_8601)) dev->pci_conf[0x6b] = val; else if (dev->id == VIA_691) dev->pci_conf[0x6b] = (dev->pci_conf[0x6b] & ~0xcf) | (val & 0xcf); @@ -520,7 +520,7 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv) dev->pci_conf[0x6b] = (dev->pci_conf[0x6b] & ~0xc1) | (val & 0xc1); break; case 0x6c: - if ((dev->id == VIA_597) || ((dev->id == VIA_693A) || (dev->id < VIA_8601))) + if ((dev->id == VIA_597) || ((dev->id == VIA_693A) && (dev->id < VIA_8601))) dev->pci_conf[0x6c] = (dev->pci_conf[0x6c] & ~0x1f) | (val & 0x1f); else if (dev->id == VIA_598) dev->pci_conf[0x6c] = (dev->pci_conf[0x6c] & ~0x7f) | (val & 0x7f); From 494f7cbb025ebee987513de6f5fac7aa6b5d745a Mon Sep 17 00:00:00 2001 From: usergithub64 <58270614+usergithub64@users.noreply.github.com> Date: Thu, 6 Nov 2025 14:50:58 +0200 Subject: [PATCH 19/89] Update 86box.pot Update 86box.pot --- src/qt/languages/86box.pot | 15 +++++++++++++++ src/qt/languages/ru-RU.po | 19 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/qt/languages/86box.pot b/src/qt/languages/86box.pot index 54b328aa1..110eaab1d 100644 --- a/src/qt/languages/86box.pot +++ b/src/qt/languages/86box.pot @@ -2253,6 +2253,21 @@ msgstr "" msgid "WSS DMA" msgstr "" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC IRQ2" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Uninstalled" +msgstr "" + msgid "Enable OPL" msgstr "" diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index 9ea4a6a0e..c2a646c50 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -973,7 +973,7 @@ msgid "Thrustmaster Flight Control System" msgstr "Система управления полётом Thrustmaster" msgid "Thrustmaster FCS + Rudder Control System" -msgstr "Thrustmaster FCS + Система управления рулем" +msgstr "Thrustmaster FCS + Система управления рулём" msgid "Thrustmaster Formula T1/T2 with adapter" msgstr "Thrustmaster Formula T1/T2 с адаптером" @@ -2221,7 +2221,7 @@ msgid "Enable Game port" msgstr "Включить игровой порт" msgid "Enable Adlib ports" -msgstr "Включить порты Adlib" +msgstr "Включить порты AdLib" msgid "SID Model" msgstr "Модель SID" @@ -2253,6 +2253,21 @@ msgstr "IRQ WSS" msgid "WSS DMA" msgstr "DMA WSS" +msgid "RTC IRQ" +msgstr "IRQ RTC" + +msgid "RTC IRQ2" +msgstr "IRQ2 RTC" + +msgid "RTC Port Address" +msgstr "Адрес порта RTC" + +msgid "Onboard RTC" +msgstr "Встроенный RTC" + +msgid "Uninstalled" +msgstr "Удалено" + msgid "Enable OPL" msgstr "Включить OPL" From 40123bb7fd35d3cc5428f60869281fdecdf1ce38 Mon Sep 17 00:00:00 2001 From: usergithub64 <58270614+usergithub64@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:26:18 +0200 Subject: [PATCH 20/89] Update ru-RU.po --- src/qt/languages/ru-RU.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index c2a646c50..eda3ac17e 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -2256,8 +2256,8 @@ msgstr "DMA WSS" msgid "RTC IRQ" msgstr "IRQ RTC" -msgid "RTC IRQ2" -msgstr "IRQ2 RTC" +msgid "RTC IRQ 2" +msgstr "IRQ 2 RTC" msgid "RTC Port Address" msgstr "Адрес порта RTC" @@ -2266,7 +2266,7 @@ msgid "Onboard RTC" msgstr "Встроенный RTC" msgid "Uninstalled" -msgstr "Удалено" +msgstr "Не установлен" msgid "Enable OPL" msgstr "Включить OPL" From 8baae269cde0321520cb39db9bb8ab94fe818cf0 Mon Sep 17 00:00:00 2001 From: usergithub64 <58270614+usergithub64@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:43:35 +0200 Subject: [PATCH 21/89] Update ru-RU.po --- src/qt/languages/ru-RU.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index eda3ac17e..7c1755d9e 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -2265,7 +2265,7 @@ msgstr "Адрес порта RTC" msgid "Onboard RTC" msgstr "Встроенный RTC" -msgid "Uninstalled" +msgid "Not installed" msgstr "Не установлен" msgid "Enable OPL" From 364a19aaaf2d6fc0e42e5dd2e41ffe89013da05a Mon Sep 17 00:00:00 2001 From: usergithub64 <58270614+usergithub64@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:44:31 +0200 Subject: [PATCH 22/89] Update 86box.pot --- src/qt/languages/86box.pot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/languages/86box.pot b/src/qt/languages/86box.pot index 110eaab1d..e5334a13f 100644 --- a/src/qt/languages/86box.pot +++ b/src/qt/languages/86box.pot @@ -2256,7 +2256,7 @@ msgstr "" msgid "RTC IRQ" msgstr "" -msgid "RTC IRQ2" +msgid "RTC IRQ 2" msgstr "" msgid "RTC Port Address" @@ -2265,7 +2265,7 @@ msgstr "" msgid "Onboard RTC" msgstr "" -msgid "Uninstalled" +msgid "Not installed" msgstr "" msgid "Enable OPL" From 7bf1ea49bcd8de7b2655b7a5e288963ad40c5ff1 Mon Sep 17 00:00:00 2001 From: usergithub64 <58270614+usergithub64@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:46:39 +0200 Subject: [PATCH 23/89] Update m_xt.c --- src/machine/m_xt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index f0b5d37a6..a5dc921b2 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -1736,7 +1736,7 @@ static const device_config_t to16_config[] = { .file_filter = NULL, .spinner = { 0 }, .selection = { - { .description = "Uninstalled", .value = 0 }, + { .description = "Not installed", .value = 0 }, { .description = "RTC0", .value = 0x300 }, { .description = "RTC1", .value = 0x2c0 }, { .description = "" } @@ -1745,7 +1745,7 @@ static const device_config_t to16_config[] = { }, { .name = "rtc_irq", - .description = "RTC IRQ2", + .description = "RTC IRQ 2", .type = CONFIG_SELECTION, .default_string = NULL, .default_int = -1, From 49e7850f5a163b18034ef94de794328d650ac33a Mon Sep 17 00:00:00 2001 From: mw308 <34479591+mw308@users.noreply.github.com> Date: Fri, 7 Nov 2025 09:23:09 +0000 Subject: [PATCH 24/89] Add RM Accelerator as a BIOS option for the AX6BC --- src/machine/m_at_slot1.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index eb5c0e90b..0c777c349 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -593,6 +593,15 @@ static const device_config_t ax6bc_config[] = { .size = 262144, .files = { "roms/machines/ax6bc/ax6bc110.bin", "" } }, + { + .name = "RM Accelerator 350P2XB/450P3XB (BIOS R2.20)", + .internal_name = "ax6bc_rm", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ax6bc/ax6bc220.bin", "" } + }, { .name = "Award Modular BIOS v4.60PGM - Revision R2.59", .internal_name = "ax6bc", From 4b85c5ade5415a8cb0539f4deb65634b65225e33 Mon Sep 17 00:00:00 2001 From: mw308 <34479591+mw308@users.noreply.github.com> Date: Fri, 7 Nov 2025 09:24:17 +0000 Subject: [PATCH 25/89] Add Hitachi CDR-8435 Found in RM Accelerator PCs --- src/include/86box/cdrom.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/cdrom.h b/src/include/86box/cdrom.h index 5ddb2400f..5a6c0914d 100644 --- a/src/include/86box/cdrom.h +++ b/src/include/86box/cdrom.h @@ -142,6 +142,7 @@ static const struct cdrom_drive_types_s { /* TODO: Find an IDENTIFY and/or INQUIRY dump. */ { "GOLDSTAR", "GCD-R560B", "1.00", "goldstar_r560b", BUS_TYPE_IDE, 0, 6, 36, 0, 0, { 4, 2, 2, -1 } }, { "HITACHI", "CDR-8130", "0020", "hitachi_r8130", BUS_TYPE_IDE, 0, 16, 36, 0, 0, { 4, 2, 2, -1 } }, + { "HITACHI", "CDR-8435", "0010", "hitachi_r8435", BUS_TYPE_IDE, 0, 32, 36, 0, 0, { 4, 2, 2, -1 } }, { "HITACHI", "GD-7500", "A1 ", "hitachi_7500", BUS_TYPE_IDE, 0, 40, 36, 0, 0, { 4, 2, 2, 2 } }, /* DVD. */ { "HL-DT-ST", "CD-ROM GCR-8526B", "1.01", "hldtst_8526b", BUS_TYPE_IDE, 0, 52, 36, 0, 0, { 4, 2, 2, 2 } }, { "HL-DT-ST", "DVDRAM GSA-4160", "A302", "hldtst_4160", BUS_TYPE_IDE, 0, 40, 36, 0, 0, { 4, 2, 2, 2 } }, From 2039d9f0e717700ccd613fa2f7be8d09bf6cb2a2 Mon Sep 17 00:00:00 2001 From: Kotochi <185547947+rushieda@users.noreply.github.com> Date: Fri, 7 Nov 2025 23:32:50 +0300 Subject: [PATCH 26/89] Add the MSI MS-6318 and its OEM versions --- src/include/86box/machine.h | 4 + src/machine/m_at_socket370.c | 155 +++++++++++++++++++++++++++++++++++ src/machine/machine_table.c | 45 ++++++++++ 3 files changed, 204 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 11992f764..bec679f23 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1302,6 +1302,10 @@ extern int machine_at_p6bap_init(const machine_t *); /* VIA Apollo Pro 133A */ extern int machine_at_6via90ap_init(const machine_t *); extern int machine_at_cuv4xls_init(const machine_t *); +#ifdef EMU_DEVICE_H +extern const device_t ms6318_device; +#endif +extern int machine_at_ms6318_init(const machine_t *); /* SiS 600 */ extern int machine_at_7sbb_init(const machine_t *); diff --git a/src/machine/m_at_socket370.c b/src/machine/m_at_socket370.c index f902a7fa9..88bb8752f 100644 --- a/src/machine/m_at_socket370.c +++ b/src/machine/m_at_socket370.c @@ -434,6 +434,161 @@ machine_at_cuv4xls_init(const machine_t *model) return ret; } +static const device_config_t ms6318_config[] = { + // clang-format off + { + .name = "bios", + .description = "BIOS Version", + .type = CONFIG_BIOS, + .default_string = "ms6318", + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { + { + .name = "Award Modular BIOS v6.00PG - Revision 1.1", + .internal_name = "ms6318_110", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/w6318vms.110", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 1.2", + .internal_name = "ms6318", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/w6318vms.120", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 7.1B5E (Elonex OEM)", + .internal_name = "ms6318_715", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/w6318ve1.715", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 1.0B9 (Fujitsu-Siemens OEM)", + .internal_name = "ms6318_109", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/ms-6318-ver5.bin", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 1.8 (HP OEM)", + .internal_name = "ms6318_180", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/med2000v2.bin", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 1.9 (HP OEM)", + .internal_name = "ms6318_190", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/med2000.bin", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 2.02 (HP OEM)", + .internal_name = "ms6318_202", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/ms6318hp.bin", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 1.3 (Medion OEM)", + .internal_name = "ms6318_130", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/ms6318.bin", "" } + }, + { + .name = "Award Modular BIOS v6.00PG - Revision 7.51 (Medion OEM)", + .internal_name = "ms6318_751", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6318/bios.rom", "" } + }, + { .files_no = 0 } + } + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + +const device_t ms6318_device = { + .name = "MSI MS-6318", + .internal_name = "ms6318_device", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = ms6318_config +}; + +int +machine_at_ms6318_init(const machine_t *model) +{ + int ret = 0; + const char *fn; + + /* No ROMs available */ + if (!device_available(model->device)) + return ret; + + device_context(model->device); + fn = device_get_bios_file(machine_get_device(machine), device_get_config_bios("bios"), 0); + ret = bios_load_linear(fn, 0x000c0000, 262144, 0); + device_context_restore(); + + machine_at_common_init_ex(model, 2); + + pci_init(PCI_CONFIG_TYPE_1); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); + pci_register_slot(0x0C, PCI_CARD_SOUND, 3, 4, 1, 2); + pci_register_slot(0x0E, PCI_CARD_NORMAL, 1, 2, 3, 4); + pci_register_slot(0x0F, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x10, PCI_CARD_NORMAL, 3, 4, 1, 2); + pci_register_slot(0x01, PCI_CARD_AGPBRIDGE, 1, 2, 3, 4); + + device_add(&via_apro133a_device); + device_add(&via_vt82c686b_device); /* fans: CPU1, CPU2; temperatures: CPU, System, unused */ + device_add(&sst_flash_39sf020_device); /* assumed */ + spd_register(SPD_TYPE_SDRAM, 0x7, 1024); + hwm_values.temperatures[0] += 2; /* CPU offset */ + hwm_values.temperatures[1] += 2; /* System offset */ + hwm_values.temperatures[2] = 0; /* unused */ + + if (sound_card_current[0] == SOUND_INTERNAL) + device_add(machine_get_snd_device(machine)); + device_add(&stac9708_device); + + return ret; +} + /* SiS 600 */ int machine_at_7sbb_init(const machine_t *model) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 72806d9d8..66d3130e0 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -19821,6 +19821,51 @@ const machine_t machines[] = { .snd_device = &cmi8738_onboard_device, .net_device = NULL }, + /* Has the VIA VT82C686B southbridge with on-chip KBC identical to the VIA + VT82C42N. */ + { + .name = "[VIA Apollo Pro 133A] MSI MS-6318", + .internal_name = "ms6318", + .type = MACHINE_TYPE_SOCKET370, + .chipset = MACHINE_CHIPSET_VIA_APOLLO_PRO_133A, + .init = machine_at_ms6318_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET370, + .block = CPU_BLOCK_NONE, + .min_bus = 66666667, + .max_bus = 150000000, + .min_voltage = 1300, + .max_voltage = 3500, + .min_multi = MACHINE_MULTIPLIER_FIXED, + .max_multi = MACHINE_MULTIPLIER_FIXED + }, + .bus_flags = MACHINE_PS2_A97 | MACHINE_BUS_USB, + .flags = MACHINE_IDE_DUAL | MACHINE_AG | MACHINE_APM | MACHINE_ACPI | MACHINE_GAMEPORT | MACHINE_USB, + .ram = { + .min = 16384, + .max = 2097152, + .step = 8192 + }, + .nvrmask = 255, + .jumpered_ecp_dma = 0, + .default_jumpered_ecp_dma = -1, + .kbc_device = NULL, + .kbc_params = 0x00000000, + .kbc_p1 = 0x00000cf0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = &ms6318_device, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = &ct5880_onboard_device, + .net_device = NULL + }, /* Miscellaneous/Fake/Hypervisor machines */ /* Has a Winbond W83977F Super I/O chip with on-chip KBC with AMIKey-2 KBC From ca424aed323bead50be08c06cf67e87c004797b0 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Fri, 3 Oct 2025 22:42:29 -0400 Subject: [PATCH 27/89] clang-format in src/qt --- src/qt/be_keyboard.hpp | 218 +++---- src/qt/cocoa_keyboard.hpp | 7 +- src/qt/evdev_keyboard.cpp | 232 +++---- src/qt/qt_cgasettingsdialog.cpp | 47 +- src/qt/qt_deviceconfig.cpp | 368 +++++------ src/qt/qt_deviceconfig.hpp | 2 +- src/qt/qt_downloader.cpp | 12 +- src/qt/qt_downloader.hpp | 11 +- src/qt/qt_glsl_parser.cpp | 724 ++++++++++++---------- src/qt/qt_harddiskdialog.cpp | 19 +- src/qt/qt_harddrive_common.cpp | 22 +- src/qt/qt_iconindicators.cpp | 2 +- src/qt/qt_iconindicators.hpp | 2 +- src/qt/qt_keybind.cpp | 46 +- src/qt/qt_keybind.hpp | 6 +- src/qt/qt_machinestatus.cpp | 38 +- src/qt/qt_machinestatus.hpp | 2 +- src/qt/qt_main.cpp | 323 +++++----- src/qt/qt_mainwindow.cpp | 498 +++++++-------- src/qt/qt_mainwindow.hpp | 43 +- src/qt/qt_mediahistorymanager.cpp | 4 +- src/qt/qt_mediamenu.cpp | 84 ++- src/qt/qt_midi.cpp | 1 - src/qt/qt_models_common.hpp | 2 +- src/qt/qt_newfloppydialog.cpp | 8 +- src/qt/qt_openglrenderer.cpp | 184 +++--- src/qt/qt_openglrenderer.hpp | 24 +- src/qt/qt_openglshaderconfig.cpp | 26 +- src/qt/qt_openglshaderconfig.hpp | 7 +- src/qt/qt_openglshadermanagerdialog.cpp | 90 +-- src/qt/qt_platform.cpp | 101 ++- src/qt/qt_progsettings.cpp | 2 +- src/qt/qt_progsettings.hpp | 18 +- src/qt/qt_renderercommon.cpp | 18 +- src/qt/qt_renderercommon.hpp | 8 +- src/qt/qt_rendererstack.cpp | 360 ++++++----- src/qt/qt_rendererstack.hpp | 27 +- src/qt/qt_settings.cpp | 9 +- src/qt/qt_settings_bus_tracking.cpp | 16 +- src/qt/qt_settingsdisplay.cpp | 33 +- src/qt/qt_settingsdisplay.hpp | 2 +- src/qt/qt_settingsfloppycdrom.cpp | 108 ++-- src/qt/qt_settingsfloppycdrom.hpp | 7 +- src/qt/qt_settingsharddisks.cpp | 26 +- src/qt/qt_settingsinput.cpp | 27 +- src/qt/qt_settingsinput.hpp | 2 +- src/qt/qt_settingsmachine.cpp | 43 +- src/qt/qt_settingsnetwork.cpp | 60 +- src/qt/qt_settingsotherperipherals.cpp | 16 +- src/qt/qt_settingsotherremovable.cpp | 75 +-- src/qt/qt_settingsotherremovable.hpp | 1 + src/qt/qt_settingsports.cpp | 23 +- src/qt/qt_settingssound.cpp | 15 +- src/qt/qt_settingsstoragecontrollers.cpp | 14 +- src/qt/qt_singlekeyseqedit.cpp | 19 +- src/qt/qt_singlekeyseqedit.hpp | 3 +- src/qt/qt_softwarerenderer.cpp | 7 +- src/qt/qt_softwarerenderer.hpp | 2 +- src/qt/qt_styleoverride.cpp | 11 +- src/qt/qt_styleoverride.hpp | 2 +- src/qt/qt_ui.cpp | 31 +- src/qt/qt_updatecheck.cpp | 73 ++- src/qt/qt_updatecheck.hpp | 37 +- src/qt/qt_updatecheckdialog.cpp | 10 +- src/qt/qt_updatedetails.cpp | 26 +- src/qt/qt_updatedetails.hpp | 6 +- src/qt/qt_util.cpp | 26 +- src/qt/qt_util.hpp | 8 +- src/qt/qt_vmmanager_addmachine.cpp | 59 +- src/qt/qt_vmmanager_addmachine.hpp | 21 +- src/qt/qt_vmmanager_clientsocket.cpp | 18 +- src/qt/qt_vmmanager_clientsocket.hpp | 15 +- src/qt/qt_vmmanager_config.cpp | 12 +- src/qt/qt_vmmanager_config.hpp | 10 +- src/qt/qt_vmmanager_details.cpp | 59 +- src/qt/qt_vmmanager_details.hpp | 33 +- src/qt/qt_vmmanager_detailsection.cpp | 60 +- src/qt/qt_vmmanager_detailsection.hpp | 17 +- src/qt/qt_vmmanager_listviewdelegate.cpp | 145 +++-- src/qt/qt_vmmanager_listviewdelegate.hpp | 26 +- src/qt/qt_vmmanager_main.cpp | 160 +++-- src/qt/qt_vmmanager_main.hpp | 44 +- src/qt/qt_vmmanager_mainwindow.cpp | 39 +- src/qt/qt_vmmanager_mainwindow.hpp | 11 +- src/qt/qt_vmmanager_model.cpp | 38 +- src/qt/qt_vmmanager_model.hpp | 36 +- src/qt/qt_vmmanager_preferences.cpp | 18 +- src/qt/qt_vmmanager_preferences.hpp | 38 +- src/qt/qt_vmmanager_protocol.cpp | 58 +- src/qt/qt_vmmanager_serversocket.cpp | 42 +- src/qt/qt_vmmanager_serversocket.hpp | 26 +- src/qt/qt_vmmanager_system.cpp | 561 +++++++++-------- src/qt/qt_vmmanager_system.hpp | 112 ++-- src/qt/qt_vmmanager_windarkmodefilter.cpp | 10 +- src/qt/qt_vulkanrenderer.cpp | 40 +- src/qt/qt_vulkanrenderer.hpp | 12 +- src/qt/qt_vulkanwindowrenderer.cpp | 2 +- src/qt/qt_winrawinputfilter.cpp | 236 ++++--- src/qt/qt_winrawinputfilter.hpp | 16 +- src/qt/xinput2_mouse.cpp | 6 +- src/qt/xkbcommon_keyboard.cpp | 312 +++++----- src/qt/xkbcommon_keyboard.hpp | 6 +- src/qt/xkbcommon_wl_keyboard.cpp | 18 +- src/qt/xkbcommon_x11_keyboard.cpp | 12 +- 104 files changed, 3358 insertions(+), 3294 deletions(-) diff --git a/src/qt/be_keyboard.hpp b/src/qt/be_keyboard.hpp index cc2bbabac..cd5303e64 100644 --- a/src/qt/be_keyboard.hpp +++ b/src/qt/be_keyboard.hpp @@ -1,112 +1,112 @@ static std::unordered_map be_keycodes = { - {B_F1_KEY, 0x3b}, - {B_F2_KEY, 0x3c}, - {B_F3_KEY, 0x3d}, - {B_F4_KEY, 0x3e}, - {B_F5_KEY, 0x3f}, - {B_F6_KEY, 0x40}, - {B_F7_KEY, 0x41}, - {B_F8_KEY, 0x42}, - {B_F9_KEY, 0x43}, - {B_F10_KEY, 0x44}, - {B_F11_KEY, 0x57}, - {B_F12_KEY, 0x58}, - {B_PRINT_KEY, 0x137}, - {B_SCROLL_KEY, 0x46}, - {B_PAUSE_KEY, 0x145}, - {B_KATAKANA_HIRAGANA, 0x70}, - {B_HANKAKU_ZENKAKU, 0x76}, + { B_F1_KEY, 0x3b }, + { B_F2_KEY, 0x3c }, + { B_F3_KEY, 0x3d }, + { B_F4_KEY, 0x3e }, + { B_F5_KEY, 0x3f }, + { B_F6_KEY, 0x40 }, + { B_F7_KEY, 0x41 }, + { B_F8_KEY, 0x42 }, + { B_F9_KEY, 0x43 }, + { B_F10_KEY, 0x44 }, + { B_F11_KEY, 0x57 }, + { B_F12_KEY, 0x58 }, + { B_PRINT_KEY, 0x137 }, + { B_SCROLL_KEY, 0x46 }, + { B_PAUSE_KEY, 0x145 }, + { B_KATAKANA_HIRAGANA, 0x70 }, + { B_HANKAKU_ZENKAKU, 0x76 }, - {0x01, 0x01}, /* Escape */ - {0x11, 0x29}, - {0x12, 0x02}, - {0x13, 0x03}, - {0x14, 0x04}, - {0x15, 0x05}, - {0x16, 0x06}, - {0x17, 0x07}, - {0x18, 0x08}, - {0x19, 0x09}, - {0x1a, 0x0a}, - {0x1b, 0x0b}, - {0x1c, 0x0c}, - {0x1d, 0x0d}, - {0x1e, 0x0e}, /* Backspace */ - {0x1f, 0x152}, /* Insert */ - {0x20, 0x147}, /* Home */ - {0x21, 0x149}, /* Page Up */ - {0x22, 0x45}, - {0x23, 0x135}, - {0x24, 0x37}, - {0x25, 0x4a}, - {0x26, 0x0f}, /* Tab */ - {0x27, 0x10}, - {0x28, 0x11}, - {0x29, 0x12}, - {0x2a, 0x13}, - {0x2b, 0x14}, - {0x2c, 0x15}, - {0x2d, 0x16}, - {0x2e, 0x17}, - {0x2f, 0x18}, - {0x30, 0x19}, - {0x31, 0x1a}, - {0x32, 0x1b}, - {0x33, 0x2b}, - {0x34, 0x153}, /* Delete */ - {0x35, 0x14f}, /* End */ - {0x36, 0x151}, /* Page Down */ - {0x37, 0x47}, - {0x38, 0x48}, - {0x39, 0x49}, - {0x3a, 0x4e}, - {0x3b, 0x3a}, - {0x3c, 0x1e}, - {0x3d, 0x1f}, - {0x3e, 0x20}, - {0x3f, 0x21}, - {0x40, 0x22}, - {0x41, 0x23}, - {0x42, 0x24}, - {0x43, 0x25}, - {0x44, 0x26}, - {0x45, 0x27}, - {0x46, 0x28}, - {0x47, 0x1c}, /* Enter */ - {0x48, 0x4b}, - {0x49, 0x4c}, - {0x4a, 0x4d}, - {0x4b, 0x2a}, - {0x4c, 0x2c}, - {0x4d, 0x2d}, - {0x4e, 0x2e}, - {0x4f, 0x2f}, - {0x50, 0x30}, - {0x51, 0x31}, - {0x52, 0x32}, - {0x53, 0x33}, - {0x54, 0x34}, - {0x55, 0x35}, - {0x56, 0x36}, - {0x57, 0x148}, /* up arrow */ - {0x58, 0x51}, - {0x59, 0x50}, - {0x5a, 0x4f}, - {0x5b, 0x11c}, - {0x5c, 0x1d}, - {0x5d, 0x38}, - {0x5e, 0x39}, /* space bar */ - {0x5f, 0x138}, - {0x60, 0x11d}, - {0x61, 0x14b}, /* left arrow */ - {0x62, 0x150}, /* down arrow */ - {0x63, 0x14d}, /* right arrow */ - {0x64, 0x52}, - {0x65, 0x53}, - {0x66, 0x15b}, - {0x67, 0x15c}, - {0x68, 0x15d}, - {0x69, 0x56}, - {0x7e, 0x137}, /* System Request */ - {0x7f, 0x145}, /* Break */ + { 0x01, 0x01 }, /* Escape */ + { 0x11, 0x29 }, + { 0x12, 0x02 }, + { 0x13, 0x03 }, + { 0x14, 0x04 }, + { 0x15, 0x05 }, + { 0x16, 0x06 }, + { 0x17, 0x07 }, + { 0x18, 0x08 }, + { 0x19, 0x09 }, + { 0x1a, 0x0a }, + { 0x1b, 0x0b }, + { 0x1c, 0x0c }, + { 0x1d, 0x0d }, + { 0x1e, 0x0e }, /* Backspace */ + { 0x1f, 0x152 }, /* Insert */ + { 0x20, 0x147 }, /* Home */ + { 0x21, 0x149 }, /* Page Up */ + { 0x22, 0x45 }, + { 0x23, 0x135 }, + { 0x24, 0x37 }, + { 0x25, 0x4a }, + { 0x26, 0x0f }, /* Tab */ + { 0x27, 0x10 }, + { 0x28, 0x11 }, + { 0x29, 0x12 }, + { 0x2a, 0x13 }, + { 0x2b, 0x14 }, + { 0x2c, 0x15 }, + { 0x2d, 0x16 }, + { 0x2e, 0x17 }, + { 0x2f, 0x18 }, + { 0x30, 0x19 }, + { 0x31, 0x1a }, + { 0x32, 0x1b }, + { 0x33, 0x2b }, + { 0x34, 0x153 }, /* Delete */ + { 0x35, 0x14f }, /* End */ + { 0x36, 0x151 }, /* Page Down */ + { 0x37, 0x47 }, + { 0x38, 0x48 }, + { 0x39, 0x49 }, + { 0x3a, 0x4e }, + { 0x3b, 0x3a }, + { 0x3c, 0x1e }, + { 0x3d, 0x1f }, + { 0x3e, 0x20 }, + { 0x3f, 0x21 }, + { 0x40, 0x22 }, + { 0x41, 0x23 }, + { 0x42, 0x24 }, + { 0x43, 0x25 }, + { 0x44, 0x26 }, + { 0x45, 0x27 }, + { 0x46, 0x28 }, + { 0x47, 0x1c }, /* Enter */ + { 0x48, 0x4b }, + { 0x49, 0x4c }, + { 0x4a, 0x4d }, + { 0x4b, 0x2a }, + { 0x4c, 0x2c }, + { 0x4d, 0x2d }, + { 0x4e, 0x2e }, + { 0x4f, 0x2f }, + { 0x50, 0x30 }, + { 0x51, 0x31 }, + { 0x52, 0x32 }, + { 0x53, 0x33 }, + { 0x54, 0x34 }, + { 0x55, 0x35 }, + { 0x56, 0x36 }, + { 0x57, 0x148 }, /* up arrow */ + { 0x58, 0x51 }, + { 0x59, 0x50 }, + { 0x5a, 0x4f }, + { 0x5b, 0x11c }, + { 0x5c, 0x1d }, + { 0x5d, 0x38 }, + { 0x5e, 0x39 }, /* space bar */ + { 0x5f, 0x138 }, + { 0x60, 0x11d }, + { 0x61, 0x14b }, /* left arrow */ + { 0x62, 0x150 }, /* down arrow */ + { 0x63, 0x14d }, /* right arrow */ + { 0x64, 0x52 }, + { 0x65, 0x53 }, + { 0x66, 0x15b }, + { 0x67, 0x15c }, + { 0x68, 0x15d }, + { 0x69, 0x56 }, + { 0x7e, 0x137 }, /* System Request */ + { 0x7f, 0x145 }, /* Break */ }; diff --git a/src/qt/cocoa_keyboard.hpp b/src/qt/cocoa_keyboard.hpp index da3161bb2..136dd9a65 100644 --- a/src/qt/cocoa_keyboard.hpp +++ b/src/qt/cocoa_keyboard.hpp @@ -1,4 +1,5 @@ -static std::array cocoa_keycodes = { /* key names in parentheses are not declared by Apple headers */ +static std::array cocoa_keycodes = { + /* key names in parentheses are not declared by Apple headers */ 0x1e, /* ANSI_A */ 0x1f, /* ANSI_S */ 0x20, /* ANSI_D */ @@ -66,9 +67,9 @@ static std::array cocoa_keycodes = { /* key names in parentheses 0x5e, /* F17 => F14 */ 0x53, /* ANSI_KeypadDecimal */ 0, - 0x37, /* ANSI_KeypadMultiply */ + 0x37, /* ANSI_KeypadMultiply */ 0, - 0x4e, /* ANSI_KeypadPlus */ + 0x4e, /* ANSI_KeypadPlus */ 0, 0x45, /* ANSI_KeypadClear => Num Lock (location equivalent) */ 0x130, /* VolumeUp */ diff --git a/src/qt/evdev_keyboard.cpp b/src/qt/evdev_keyboard.cpp index 0f54775ba..e0fcea3d0 100644 --- a/src/qt/evdev_keyboard.cpp +++ b/src/qt/evdev_keyboard.cpp @@ -16,132 +16,132 @@ #include static std::unordered_map evdev_keycodes = { - {184, 0x46}, /* F14 => Scroll Lock (for Apple keyboards) */ - {86, 0x56}, /* 102ND */ - {87, 0x57}, /* F11 */ - {88, 0x58}, /* F12 */ - {186, 0x5d}, /* F16 => F13 */ - {187, 0x5e}, /* F17 => F14 */ - {188, 0x5f}, /* F18 => F15 */ + { 184, 0x46 }, /* F14 => Scroll Lock (for Apple keyboards) */ + { 86, 0x56 }, /* 102ND */ + { 87, 0x57 }, /* F11 */ + { 88, 0x58 }, /* F12 */ + { 186, 0x5d }, /* F16 => F13 */ + { 187, 0x5e }, /* F17 => F14 */ + { 188, 0x5f }, /* F18 => F15 */ /* Japanese keys. */ - {95, 0x5c}, /* KPJPCOMMA */ - {93, 0x70}, /* KATAKANAHIRAGANA */ - {89, 0x73}, /* RO */ - {85, 0x76}, /* ZENKAKUHANKAKU */ - {91, 0x77}, /* HIRAGANA */ - {90, 0x78}, /* KATAKANA */ - {92, 0x79}, /* HENKAN */ - {94, 0x7b}, /* MUHENKAN */ - {124, 0x7d}, /* YEN */ - {121, 0x7e}, /* KPCOMMA */ + { 95, 0x5c }, /* KPJPCOMMA */ + { 93, 0x70 }, /* KATAKANAHIRAGANA */ + { 89, 0x73 }, /* RO */ + { 85, 0x76 }, /* ZENKAKUHANKAKU */ + { 91, 0x77 }, /* HIRAGANA */ + { 90, 0x78 }, /* KATAKANA */ + { 92, 0x79 }, /* HENKAN */ + { 94, 0x7b }, /* MUHENKAN */ + { 124, 0x7d }, /* YEN */ + { 121, 0x7e }, /* KPCOMMA */ /* Korean keys. */ - {123, 0xf1}, /* HANJA */ - {122, 0xf2}, /* HANGUL */ + { 123, 0xf1 }, /* HANJA */ + { 122, 0xf2 }, /* HANGUL */ - {96, 0x11c}, /* KPENTER */ - {97, 0x11d}, /* RIGHTCTRL */ - {98, 0x135}, /* KPSLASH */ - {99, 0x137}, /* SYSRQ */ - {183, 0x137}, /* F13 => SysRq (for Apple keyboards) */ - {100, 0x138}, /* RIGHTALT */ - {119, 0x145}, /* PAUSE */ - {411, 0x145}, /* BREAK */ - {185, 0x145}, /* F15 => Pause (for Apple keyboards) */ - {102, 0x147}, /* HOME */ - {103, 0x148}, /* UP */ - {104, 0x149}, /* PAGEUP */ - {105, 0x14b}, /* LEFT */ - {106, 0x14d}, /* RIGHT */ - {107, 0x14f}, /* END */ - {108, 0x150}, /* DOWN */ - {109, 0x151}, /* PAGEDOWN */ - {110, 0x152}, /* INSERT */ - {111, 0x153}, /* DELETE */ + { 96, 0x11c }, /* KPENTER */ + { 97, 0x11d }, /* RIGHTCTRL */ + { 98, 0x135 }, /* KPSLASH */ + { 99, 0x137 }, /* SYSRQ */ + { 183, 0x137 }, /* F13 => SysRq (for Apple keyboards) */ + { 100, 0x138 }, /* RIGHTALT */ + { 119, 0x145 }, /* PAUSE */ + { 411, 0x145 }, /* BREAK */ + { 185, 0x145 }, /* F15 => Pause (for Apple keyboards) */ + { 102, 0x147 }, /* HOME */ + { 103, 0x148 }, /* UP */ + { 104, 0x149 }, /* PAGEUP */ + { 105, 0x14b }, /* LEFT */ + { 106, 0x14d }, /* RIGHT */ + { 107, 0x14f }, /* END */ + { 108, 0x150 }, /* DOWN */ + { 109, 0x151 }, /* PAGEDOWN */ + { 110, 0x152 }, /* INSERT */ + { 111, 0x153 }, /* DELETE */ - {125, 0x15b}, /* LEFTMETA */ - {126, 0x15c}, /* RIGHTMETA */ - {127, 0x15d}, /* COMPOSE => Menu */ + { 125, 0x15b }, /* LEFTMETA */ + { 126, 0x15c }, /* RIGHTMETA */ + { 127, 0x15d }, /* COMPOSE => Menu */ /* Multimedia keys. Guideline is to try and follow the Microsoft standard, then fill in remaining scancodes with OEM-specific keys for redundancy sake. Keys marked with # are not translated into evdev codes by the standard atkbd driver. */ - {634, 0x54}, /* SELECTIVE_SCREENSHOT# => Alt+SysRq */ - {117, 0x59}, /* KPEQUAL */ - {418, 0x6a}, /* ZOOMIN# => Logitech */ - {420, 0x6b}, /* ZOOMRESET# => Logitech */ - {223, 0x6d}, /* CANCEL# => Logitech */ - {132, 0x101}, /* # Logitech Task Select */ - {148, 0x102}, /* PROG1# => Samsung */ - {149, 0x103}, /* PROG2# => Samsung */ - {419, 0x104}, /* ZOOMOUT# => Logitech */ - {144, 0x105}, /* FILE# => Messenger/Files */ - {216, 0x105}, /* CHAT# => Messenger/Files */ - {430, 0x105}, /* MESSENGER# */ - {182, 0x107}, /* REDO# */ - {131, 0x108}, /* UNDO# */ - {135, 0x10a}, /* PASTE# */ - {177, 0x10b}, /* SCROLLUP# => normal speed */ - {165, 0x110}, /* PREVIOUSSONG */ - {136, 0x112}, /* FIND# => Logitech */ - {421, 0x113}, /* WORDPROCESSOR# => Word */ - {423, 0x114}, /* SPREADSHEET# => Excel */ - {397, 0x115}, /* CALENDAR# */ - {433, 0x116}, /* LOGOFF# */ - {137, 0x117}, /* CUT# */ - {133, 0x118}, /* COPY# */ - {163, 0x119}, /* NEXTSONG */ - {154, 0x11e}, /* CYCLEWINDOWS => Application Right (no left counterpart) */ - {113, 0x120}, /* MUTE */ - {140, 0x121}, /* CALC */ - {164, 0x122}, /* PLAYPAUSE */ - {432, 0x123}, /* SPELLCHECK# */ - {166, 0x124}, /* STOPCD */ - {139, 0x126}, /* MENU# => Shortcut/Menu/Help for a few OEMs */ - {114, 0x12e}, /* VOL- */ - {160, 0x12f}, /* CLOSECD# => Logitech Eject */ - {161, 0x12f}, /* EJECTCD# => Logitech */ - {162, 0x12f}, /* EJECTCLOSECD# => Logitech */ - {115, 0x130}, /* VOL+ */ - {150, 0x132}, /* WWW# */ - {172, 0x132}, /* HOMEPAGE */ - {138, 0x13b}, /* HELP# */ - {213, 0x13c}, /* SOUND# => My Music/Office Home */ - {360, 0x13c}, /* VENDOR# => My Music/Office Home */ - {204, 0x13d}, /* DASHBOARD# => Task Pane */ - {181, 0x13e}, /* NEW# */ - {134, 0x13f}, /* OPEN# */ - {206, 0x140}, /* CLOSE# */ - {232, 0x141}, /* REPLY# */ - {233, 0x142}, /* FORWARDMAIL# */ - {231, 0x143}, /* SEND# */ - {151, 0x144}, /* MSDOS# */ - {112, 0x14c}, /* MACRO */ - {179, 0x14c}, /* KPLEFTPAREN# */ - {118, 0x14e}, /* KPPLUSMINUS */ - {235, 0x155}, /* DOCUMENTS# => Logitech */ - {234, 0x157}, /* SAVE# */ - {210, 0x158}, /* PRINT# */ - {116, 0x15e}, /* POWER */ - {142, 0x15f}, /* SLEEP */ - {143, 0x163}, /* WAKEUP */ - {180, 0x164}, /* KPRIGHTPAREN# */ - {212, 0x164}, /* CAMERA# => My Pictures */ - {217, 0x165}, /* SEARCH */ - {156, 0x166}, /* BOOKMARKS => Favorites */ - {364, 0x166}, /* FAVORITES# */ - {173, 0x167}, /* REFRESH */ - {128, 0x168}, /* STOP */ - {159, 0x169}, /* FORWARD */ - {158, 0x16a}, /* BACK */ - {157, 0x16b}, /* COMPUTER */ - {155, 0x16c}, /* MAIL */ - {215, 0x16c}, /* EMAIL# */ - {226, 0x16d}, /* MEDIA */ - {167, 0x178}, /* RECORD# => Logitech */ - {152, 0x17a}, /* COFFEE/SCREENLOCK# */ - {178, 0x18b}, /* SCROLLDOWN# => normal speed */ + { 634, 0x54 }, /* SELECTIVE_SCREENSHOT# => Alt+SysRq */ + { 117, 0x59 }, /* KPEQUAL */ + { 418, 0x6a }, /* ZOOMIN# => Logitech */ + { 420, 0x6b }, /* ZOOMRESET# => Logitech */ + { 223, 0x6d }, /* CANCEL# => Logitech */ + { 132, 0x101 }, /* # Logitech Task Select */ + { 148, 0x102 }, /* PROG1# => Samsung */ + { 149, 0x103 }, /* PROG2# => Samsung */ + { 419, 0x104 }, /* ZOOMOUT# => Logitech */ + { 144, 0x105 }, /* FILE# => Messenger/Files */ + { 216, 0x105 }, /* CHAT# => Messenger/Files */ + { 430, 0x105 }, /* MESSENGER# */ + { 182, 0x107 }, /* REDO# */ + { 131, 0x108 }, /* UNDO# */ + { 135, 0x10a }, /* PASTE# */ + { 177, 0x10b }, /* SCROLLUP# => normal speed */ + { 165, 0x110 }, /* PREVIOUSSONG */ + { 136, 0x112 }, /* FIND# => Logitech */ + { 421, 0x113 }, /* WORDPROCESSOR# => Word */ + { 423, 0x114 }, /* SPREADSHEET# => Excel */ + { 397, 0x115 }, /* CALENDAR# */ + { 433, 0x116 }, /* LOGOFF# */ + { 137, 0x117 }, /* CUT# */ + { 133, 0x118 }, /* COPY# */ + { 163, 0x119 }, /* NEXTSONG */ + { 154, 0x11e }, /* CYCLEWINDOWS => Application Right (no left counterpart) */ + { 113, 0x120 }, /* MUTE */ + { 140, 0x121 }, /* CALC */ + { 164, 0x122 }, /* PLAYPAUSE */ + { 432, 0x123 }, /* SPELLCHECK# */ + { 166, 0x124 }, /* STOPCD */ + { 139, 0x126 }, /* MENU# => Shortcut/Menu/Help for a few OEMs */ + { 114, 0x12e }, /* VOL- */ + { 160, 0x12f }, /* CLOSECD# => Logitech Eject */ + { 161, 0x12f }, /* EJECTCD# => Logitech */ + { 162, 0x12f }, /* EJECTCLOSECD# => Logitech */ + { 115, 0x130 }, /* VOL+ */ + { 150, 0x132 }, /* WWW# */ + { 172, 0x132 }, /* HOMEPAGE */ + { 138, 0x13b }, /* HELP# */ + { 213, 0x13c }, /* SOUND# => My Music/Office Home */ + { 360, 0x13c }, /* VENDOR# => My Music/Office Home */ + { 204, 0x13d }, /* DASHBOARD# => Task Pane */ + { 181, 0x13e }, /* NEW# */ + { 134, 0x13f }, /* OPEN# */ + { 206, 0x140 }, /* CLOSE# */ + { 232, 0x141 }, /* REPLY# */ + { 233, 0x142 }, /* FORWARDMAIL# */ + { 231, 0x143 }, /* SEND# */ + { 151, 0x144 }, /* MSDOS# */ + { 112, 0x14c }, /* MACRO */ + { 179, 0x14c }, /* KPLEFTPAREN# */ + { 118, 0x14e }, /* KPPLUSMINUS */ + { 235, 0x155 }, /* DOCUMENTS# => Logitech */ + { 234, 0x157 }, /* SAVE# */ + { 210, 0x158 }, /* PRINT# */ + { 116, 0x15e }, /* POWER */ + { 142, 0x15f }, /* SLEEP */ + { 143, 0x163 }, /* WAKEUP */ + { 180, 0x164 }, /* KPRIGHTPAREN# */ + { 212, 0x164 }, /* CAMERA# => My Pictures */ + { 217, 0x165 }, /* SEARCH */ + { 156, 0x166 }, /* BOOKMARKS => Favorites */ + { 364, 0x166 }, /* FAVORITES# */ + { 173, 0x167 }, /* REFRESH */ + { 128, 0x168 }, /* STOP */ + { 159, 0x169 }, /* FORWARD */ + { 158, 0x16a }, /* BACK */ + { 157, 0x16b }, /* COMPUTER */ + { 155, 0x16c }, /* MAIL */ + { 215, 0x16c }, /* EMAIL# */ + { 226, 0x16d }, /* MEDIA */ + { 167, 0x178 }, /* RECORD# => Logitech */ + { 152, 0x17a }, /* COFFEE/SCREENLOCK# */ + { 178, 0x18b }, /* SCROLLDOWN# => normal speed */ }; uint16_t diff --git a/src/qt/qt_cgasettingsdialog.cpp b/src/qt/qt_cgasettingsdialog.cpp index ee9aa86b6..5357c905a 100644 --- a/src/qt/qt_cgasettingsdialog.cpp +++ b/src/qt/qt_cgasettingsdialog.cpp @@ -3,8 +3,7 @@ #include -extern "C" -{ +extern "C" { #include <86box/86box.h> #include <86box/plat.h> #include <86box/vid_cga_comp.h> @@ -16,11 +15,11 @@ CGASettingsDialog::CGASettingsDialog(QWidget *parent) { ui->setupUi(this); - cga_hue = vid_cga_comp_hue; + cga_hue = vid_cga_comp_hue; cga_saturation = vid_cga_comp_saturation; cga_brightness = vid_cga_comp_brightness; - cga_contrast = vid_cga_comp_contrast; - cga_sharpness = vid_cga_comp_sharpness; + cga_contrast = vid_cga_comp_contrast; + cga_sharpness = vid_cga_comp_sharpness; ui->horizontalSliderHue->setValue(vid_cga_comp_hue); ui->horizontalSliderSaturation->setValue(vid_cga_comp_saturation); @@ -29,8 +28,7 @@ CGASettingsDialog::CGASettingsDialog(QWidget *parent) ui->horizontalSliderSharpness->setValue(vid_cga_comp_sharpness); connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &CGASettingsDialog::applySettings); - connect(ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, [this] - { + connect(ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, [this] { ui->horizontalSliderHue->setValue(0); ui->horizontalSliderSaturation->setValue(100); ui->horizontalSliderBrightness->setValue(0); @@ -38,11 +36,11 @@ CGASettingsDialog::CGASettingsDialog(QWidget *parent) ui->horizontalSliderSharpness->setValue(0); }); - connect(ui->horizontalSliderHue, &QSlider::valueChanged, this, [this] { updateDisplay(); } ); - connect(ui->horizontalSliderSaturation, &QSlider::valueChanged, this, [this] { updateDisplay(); } ); - connect(ui->horizontalSliderBrightness, &QSlider::valueChanged, this, [this] { updateDisplay(); } ); - connect(ui->horizontalSliderContrast, &QSlider::valueChanged, this, [this] { updateDisplay(); } ); - connect(ui->horizontalSliderSharpness, &QSlider::valueChanged, this, [this] { updateDisplay(); } ); + connect(ui->horizontalSliderHue, &QSlider::valueChanged, this, [this] { updateDisplay(); }); + connect(ui->horizontalSliderSaturation, &QSlider::valueChanged, this, [this] { updateDisplay(); }); + connect(ui->horizontalSliderBrightness, &QSlider::valueChanged, this, [this] { updateDisplay(); }); + connect(ui->horizontalSliderContrast, &QSlider::valueChanged, this, [this] { updateDisplay(); }); + connect(ui->horizontalSliderSharpness, &QSlider::valueChanged, this, [this] { updateDisplay(); }); } CGASettingsDialog::~CGASettingsDialog() @@ -50,7 +48,8 @@ CGASettingsDialog::~CGASettingsDialog() delete ui; } -void CGASettingsDialog::updateDisplay() +void +CGASettingsDialog::updateDisplay() { auto temp_cga_comp_hue = ui->horizontalSliderHue->value(); auto temp_cga_comp_saturation = ui->horizontalSliderSaturation->value(); @@ -60,7 +59,8 @@ void CGASettingsDialog::updateDisplay() cga_comp_reload(temp_cga_comp_brightness, temp_cga_comp_saturation, temp_cga_comp_sharpness, temp_cga_comp_hue, temp_cga_comp_contrast); } -void CGASettingsDialog::applySettings() +void +CGASettingsDialog::applySettings() { vid_cga_comp_hue = ui->horizontalSliderHue->value(); vid_cga_comp_saturation = ui->horizontalSliderSaturation->value(); @@ -69,26 +69,27 @@ void CGASettingsDialog::applySettings() vid_cga_comp_sharpness = ui->horizontalSliderSharpness->value(); cga_comp_reload(vid_cga_comp_brightness, vid_cga_comp_saturation, vid_cga_comp_sharpness, vid_cga_comp_hue, vid_cga_comp_contrast); - cga_hue = vid_cga_comp_hue; + cga_hue = vid_cga_comp_hue; cga_saturation = vid_cga_comp_saturation; cga_brightness = vid_cga_comp_brightness; - cga_contrast = vid_cga_comp_contrast; - cga_sharpness = vid_cga_comp_sharpness; + cga_contrast = vid_cga_comp_contrast; + cga_sharpness = vid_cga_comp_sharpness; } -void CGASettingsDialog::on_buttonBox_accepted() +void +CGASettingsDialog::on_buttonBox_accepted() { applySettings(); } -void CGASettingsDialog::on_buttonBox_rejected() +void +CGASettingsDialog::on_buttonBox_rejected() { - vid_cga_comp_hue = cga_hue; + vid_cga_comp_hue = cga_hue; vid_cga_comp_saturation = cga_saturation; vid_cga_comp_brightness = cga_brightness; - vid_cga_comp_contrast = cga_contrast; - vid_cga_comp_sharpness = cga_sharpness; + vid_cga_comp_contrast = cga_contrast; + vid_cga_comp_sharpness = cga_sharpness; cga_comp_reload(vid_cga_comp_brightness, vid_cga_comp_saturation, vid_cga_comp_sharpness, vid_cga_comp_hue, vid_cga_comp_contrast); } - diff --git a/src/qt/qt_deviceconfig.cpp b/src/qt/qt_deviceconfig.cpp index 880539fe4..7cc398988 100644 --- a/src/qt/qt_deviceconfig.cpp +++ b/src/qt/qt_deviceconfig.cpp @@ -50,7 +50,7 @@ extern "C" { # include #endif #ifdef Q_OS_WINDOWS -#include +# include #endif DeviceConfig::DeviceConfig(QWidget *parent) @@ -87,15 +87,16 @@ EnumerateSerialDevices() for (int i = 1; i < 256; i++) { devstr[0] = 0; snprintf(devstr.data(), 1024, R"(\\.\COM%d)", i); - const auto handle = CreateFileA(devstr.data(), - GENERIC_READ | GENERIC_WRITE, 0, - nullptr, OPEN_EXISTING, - 0, nullptr); + const auto handle = CreateFileA(devstr.data(), + GENERIC_READ | GENERIC_WRITE, 0, + nullptr, OPEN_EXISTING, + 0, nullptr); const auto dwError = GetLastError(); if ((handle != INVALID_HANDLE_VALUE) || (dwError == ERROR_ACCESS_DENIED) || (dwError == ERROR_GEN_FAILURE) || (dwError == ERROR_SHARING_VIOLATION) || (dwError == ERROR_SEM_TIMEOUT)) { - if (handle != INVALID_HANDLE_VALUE) CloseHandle(handle); + if (handle != INVALID_HANDLE_VALUE) + CloseHandle(handle); serialDevices.push_back(QString(devstr)); } } @@ -114,8 +115,8 @@ EnumerateSerialDevices() void DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep) { - auto * device_context = static_cast(dc); - const auto * config = static_cast(c); + auto *device_context = static_cast(dc); + const auto *config = static_cast(c); const QString blank = ""; int p; int q; @@ -136,7 +137,7 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep) const int config_major_type = (config_type >> CONFIG_SHIFT) << CONFIG_SHIFT; - int value = 0; + int value = 0; auto selected = blank; switch (config_major_type) { @@ -164,210 +165,211 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep) default: break; case CONFIG_BINARY: - { - auto *cbox = new QCheckBox(); - cbox->setObjectName(config->name); - cbox->setChecked(value > 0); - this->ui->formLayout->addRow(tr(config->description), cbox); - break; - } + { + auto *cbox = new QCheckBox(); + cbox->setObjectName(config->name); + cbox->setChecked(value > 0); + this->ui->formLayout->addRow(tr(config->description), cbox); + break; + } #ifdef USE_RTMIDI case CONFIG_MIDI_OUT: - { - auto *cbox = new QComboBox(); - cbox->setObjectName(config->name); - cbox->setMaxVisibleItems(30); - auto *model = cbox->model(); - int currentIndex = -1; - for (int i = 0; i < rtmidi_out_get_num_devs(); i++) { - char midiName[512] = { 0 }; - rtmidi_out_get_dev_name(i, midiName); + { + auto *cbox = new QComboBox(); + cbox->setObjectName(config->name); + cbox->setMaxVisibleItems(30); + auto *model = cbox->model(); + int currentIndex = -1; + for (int i = 0; i < rtmidi_out_get_num_devs(); i++) { + char midiName[512] = { 0 }; + rtmidi_out_get_dev_name(i, midiName); - Models::AddEntry(model, midiName, i); - if (i == value) - currentIndex = i; + Models::AddEntry(model, midiName, i); + if (i == value) + currentIndex = i; + } + this->ui->formLayout->addRow(tr(config->description), cbox); + cbox->setCurrentIndex(currentIndex); + break; } - this->ui->formLayout->addRow(tr(config->description), cbox); - cbox->setCurrentIndex(currentIndex); - break; - } case CONFIG_MIDI_IN: - { - auto *cbox = new QComboBox(); - cbox->setObjectName(config->name); - cbox->setMaxVisibleItems(30); - auto *model = cbox->model(); - int currentIndex = -1; - for (int i = 0; i < rtmidi_in_get_num_devs(); i++) { - char midiName[512] = { 0 }; - rtmidi_in_get_dev_name(i, midiName); + { + auto *cbox = new QComboBox(); + cbox->setObjectName(config->name); + cbox->setMaxVisibleItems(30); + auto *model = cbox->model(); + int currentIndex = -1; + for (int i = 0; i < rtmidi_in_get_num_devs(); i++) { + char midiName[512] = { 0 }; + rtmidi_in_get_dev_name(i, midiName); - Models::AddEntry(model, midiName, i); - if (i == value) - currentIndex = i; + Models::AddEntry(model, midiName, i); + if (i == value) + currentIndex = i; + } + this->ui->formLayout->addRow(tr(config->description), cbox); + cbox->setCurrentIndex(currentIndex); + break; } - this->ui->formLayout->addRow(tr(config->description), cbox); - cbox->setCurrentIndex(currentIndex); - break; - } #endif case CONFIG_INT: case CONFIG_SELECTION: case CONFIG_HEX16: case CONFIG_HEX20: - { - auto *cbox = new QComboBox(); - cbox->setObjectName(config->name); - cbox->setMaxVisibleItems(30); - auto *model = cbox->model(); - int currentIndex = -1; + { + auto *cbox = new QComboBox(); + cbox->setObjectName(config->name); + cbox->setMaxVisibleItems(30); + auto *model = cbox->model(); + int currentIndex = -1; - for (auto *sel = config->selection; (sel != nullptr) && (sel->description != nullptr) && - (strlen(sel->description) > 0); ++sel) { - int row = Models::AddEntry(model, tr(sel->description), sel->value); + for (auto *sel = config->selection; (sel != nullptr) && (sel->description != nullptr) && + (strlen(sel->description) > 0); ++sel) { + int row = Models::AddEntry(model, tr(sel->description), sel->value); - if (sel->value == value) - currentIndex = row; - } - this->ui->formLayout->addRow(tr(config->description), cbox); - cbox->setCurrentIndex(currentIndex); - break; - } - case CONFIG_BIOS: - { - auto *cbox = new QComboBox(); - cbox->setObjectName(config->name); - cbox->setMaxVisibleItems(30); - auto *model = cbox->model(); - int currentIndex = -1; - - q = 0; - for (auto *bios = config->bios; (bios != nullptr) && - (bios->name != nullptr) && - (bios->internal_name != nullptr) && - (strlen(bios->name) > 0) && - (strlen(bios->internal_name) > 0) && - (bios->files_no > 0); ++bios) { - p = 0; - for (int d = 0; d < bios->files_no; d++) - p += !!rom_present(const_cast(bios->files[d])); - if (p == bios->files_no) { - const int row = Models::AddEntry(model, tr(bios->name), q); - if (!strcmp(selected.toUtf8().constData(), bios->internal_name)) + if (sel->value == value) currentIndex = row; } - q++; + this->ui->formLayout->addRow(tr(config->description), cbox); + cbox->setCurrentIndex(currentIndex); + break; + } + case CONFIG_BIOS: + { + auto *cbox = new QComboBox(); + cbox->setObjectName(config->name); + cbox->setMaxVisibleItems(30); + auto *model = cbox->model(); + int currentIndex = -1; + + q = 0; + for (auto *bios = config->bios; (bios != nullptr) && + (bios->name != nullptr) && + (bios->internal_name != nullptr) && + (strlen(bios->name) > 0) && + (strlen(bios->internal_name) > 0) && + (bios->files_no > 0); ++bios) { + p = 0; + for (int d = 0; d < bios->files_no; d++) + p += !!rom_present(const_cast(bios->files[d])); + if (p == bios->files_no) { + const int row = Models::AddEntry(model, tr(bios->name), q); + if (!strcmp(selected.toUtf8().constData(), bios->internal_name)) + currentIndex = row; + } + q++; + } + this->ui->formLayout->addRow(tr(config->description), cbox); + cbox->setCurrentIndex(currentIndex); + break; } - this->ui->formLayout->addRow(tr(config->description), cbox); - cbox->setCurrentIndex(currentIndex); - break; - } case CONFIG_SPINNER: - { - auto *spinBox = new QSpinBox(); - spinBox->setObjectName(config->name); - spinBox->setMaximum(config->spinner.max); - spinBox->setMinimum(config->spinner.min); - if (config->spinner.step > 0) - spinBox->setSingleStep(config->spinner.step); - spinBox->setValue(value); - this->ui->formLayout->addRow(tr(config->description), spinBox); - break; - } + { + auto *spinBox = new QSpinBox(); + spinBox->setObjectName(config->name); + spinBox->setMaximum(config->spinner.max); + spinBox->setMinimum(config->spinner.min); + if (config->spinner.step > 0) + spinBox->setSingleStep(config->spinner.step); + spinBox->setValue(value); + this->ui->formLayout->addRow(tr(config->description), spinBox); + break; + } case CONFIG_FNAME: - { - auto *fileField = new FileField(this); - fileField->setObjectName(config->name); - fileField->setFileName(selected); - /* Get the actually used part of the filter */ + { + auto *fileField = new FileField(this); + fileField->setObjectName(config->name); + fileField->setFileName(selected); + /* Get the actually used part of the filter */ #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - QString filter = QString(config->file_filter).left(static_cast(strcspn(config->file_filter, "|"))); + QString filter = QString(config->file_filter).left(static_cast(strcspn(config->file_filter, "|"))); #else - QString filter = QString(config->file_filter).split("|").at(0); + QString filter = QString(config->file_filter).split("|").at(0); #endif - /* Extract the description and the extension list */ - QRegularExpressionMatch match = QRegularExpression("(.+) \\((.+)\\)$").match(filter); - QString description = match.captured(1); - QString extensions = match.captured(2); - /* Split the extension list up and strip the filename globs */ - QRegularExpression re("\\*\\.(.*)"); + /* Extract the description and the extension list */ + QRegularExpressionMatch match = QRegularExpression("(.+) \\((.+)\\)$").match(filter); + QString description = match.captured(1); + QString extensions = match.captured(2); + /* Split the extension list up and strip the filename globs */ + QRegularExpression re("\\*\\.(.*)"); #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - QStringList extensionList; - int i = 0; - while (extensions.section(' ', i, i) != "") { - QString extension = re.match(extensions.section(' ', i, i)).captured(1); - extensionList.append(extension); - i++; + QStringList extensionList; + int i = 0; + while (extensions.section(' ', i, i) != "") { + QString extension = re.match(extensions.section(' ', i, i)).captured(1); + extensionList.append(extension); + i++; + } +#else + QStringList extensionList = extensions.split(" "); + for (int i = 0; i < extensionList.count(); i++) + extensionList[i] = re.match(extensionList[i]).captured(1); +#endif + fileField->setFilter(tr(description.toUtf8().constData()) % util::DlgFilter(extensionList) % tr("All files") % util::DlgFilter({ "*" }, true)); + this->ui->formLayout->addRow(tr(config->description), fileField); + break; } -#else - QStringList extensionList = extensions.split(" "); - for (int i = 0; i < extensionList.count(); i++) - extensionList[i] = re.match(extensionList[i]).captured(1); -#endif - fileField->setFilter(tr(description.toUtf8().constData()) % util::DlgFilter(extensionList) % tr("All files") % util::DlgFilter({ "*" }, true)); - this->ui->formLayout->addRow(tr(config->description), fileField); - break; - } case CONFIG_STRING: - { - const auto lineEdit = new QLineEdit; - lineEdit->setObjectName(config->name); - lineEdit->setCursor(Qt::IBeamCursor); - lineEdit->setText(selected); - this->ui->formLayout->addRow(tr(config->description), lineEdit); - break; - } + { + const auto lineEdit = new QLineEdit; + lineEdit->setObjectName(config->name); + lineEdit->setCursor(Qt::IBeamCursor); + lineEdit->setText(selected); + this->ui->formLayout->addRow(tr(config->description), lineEdit); + break; + } case CONFIG_SERPORT: - { - auto *cbox = new QComboBox(); - cbox->setObjectName(config->name); - cbox->setMaxVisibleItems(30); - auto *model = cbox->model(); - int currentIndex = 0; - auto serialDevices = EnumerateSerialDevices(); + { + auto *cbox = new QComboBox(); + cbox->setObjectName(config->name); + cbox->setMaxVisibleItems(30); + auto *model = cbox->model(); + int currentIndex = 0; + auto serialDevices = EnumerateSerialDevices(); - Models::AddEntry(model, tr("None"), -1); - for (int i = 0; i < serialDevices.size(); i++) { - const int row = Models::AddEntry(model, serialDevices[i], i); - if (selected == serialDevices[i]) - currentIndex = row; + Models::AddEntry(model, tr("None"), -1); + for (int i = 0; i < serialDevices.size(); i++) { + const int row = Models::AddEntry(model, serialDevices[i], i); + if (selected == serialDevices[i]) + currentIndex = row; + } + + this->ui->formLayout->addRow(tr(config->description), cbox); + cbox->setCurrentIndex(currentIndex); + break; } - - this->ui->formLayout->addRow(tr(config->description), cbox); - cbox->setCurrentIndex(currentIndex); - break; - } case CONFIG_MAC: - { - // QHBoxLayout for the line edit widget and the generate button - const auto hboxLayout = new QHBoxLayout(); - const auto generateButton = new QPushButton(tr("Generate")); - const auto lineEdit = new QLineEdit; - // Allow the line edit to expand and fill available space - lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred); - lineEdit->setInputMask("HH:HH:HH;0"); - lineEdit->setObjectName(config->name); - // Display the current or generated MAC in uppercase - // When stored it will be converted to lowercase - if (config_get_mac(device_context->name, config->name, - config->default_int) & 0xFF000000) { - lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(), - random_generate(), random_generate())); - } else { - auto current_mac = QString(config_get_string(device_context->name, config->name, - const_cast(config->default_string))); - lineEdit->setText(current_mac.toUpper()); + { + // QHBoxLayout for the line edit widget and the generate button + const auto hboxLayout = new QHBoxLayout(); + const auto generateButton = new QPushButton(tr("Generate")); + const auto lineEdit = new QLineEdit; + // Allow the line edit to expand and fill available space + lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); + lineEdit->setInputMask("HH:HH:HH;0"); + lineEdit->setObjectName(config->name); + // Display the current or generated MAC in uppercase + // When stored it will be converted to lowercase + if (config_get_mac(device_context->name, config->name, + config->default_int) + & 0xFF000000) { + lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(), + random_generate(), random_generate())); + } else { + auto current_mac = QString(config_get_string(device_context->name, config->name, + const_cast(config->default_string))); + lineEdit->setText(current_mac.toUpper()); + } + // Action for the generate button + connect(generateButton, &QPushButton::clicked, [lineEdit] { + lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(), + random_generate(), random_generate())); + }); + hboxLayout->addWidget(lineEdit); + hboxLayout->addWidget(generateButton); + this->ui->formLayout->addRow(tr(config->description), hboxLayout); + break; } - // Action for the generate button - connect(generateButton, &QPushButton::clicked, [lineEdit] { - lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(), - random_generate(), random_generate())); - }); - hboxLayout->addWidget(lineEdit); - hboxLayout->addWidget(generateButton); - this->ui->formLayout->addRow(tr(config->description), hboxLayout); - break; - } } ++config; } diff --git a/src/qt/qt_deviceconfig.hpp b/src/qt/qt_deviceconfig.hpp index a5214111f..2e9241623 100644 --- a/src/qt/qt_deviceconfig.hpp +++ b/src/qt/qt_deviceconfig.hpp @@ -28,7 +28,7 @@ public: private: Ui::DeviceConfig *ui; - void ProcessConfig(void *dc, const void *c, bool is_dep); + void ProcessConfig(void *dc, const void *c, bool is_dep); }; #endif // QT_DEVICECONFIG_HPP diff --git a/src/qt/qt_downloader.cpp b/src/qt/qt_downloader.cpp index d88eca57a..f6366e8ce 100644 --- a/src/qt/qt_downloader.cpp +++ b/src/qt/qt_downloader.cpp @@ -23,8 +23,7 @@ extern "C" { #include <86box/plat.h> } -Downloader:: -Downloader(const DownloadLocation downloadLocation, QObject *parent) +Downloader::Downloader(const DownloadLocation downloadLocation, QObject *parent) : QObject(parent) , file(nullptr) , reply(nullptr) @@ -51,7 +50,9 @@ Downloader(const DownloadLocation downloadLocation, QObject *parent) Downloader::~Downloader() { delete file; } -void Downloader::download(const QUrl &url, const QString &filepath, const QVariant &varData) { +void +Downloader::download(const QUrl &url, const QString &filepath, const QVariant &varData) +{ variantData = varData; // temporary until I get the plat stuff fixed @@ -62,7 +63,7 @@ void Downloader::download(const QUrl &url, const QString &filepath, const QVaria const auto final_path = downloadDirectory.filePath(filepath); file = new QFile(final_path); - if(!file->open(QIODevice::WriteOnly)) { + if (!file->open(QIODevice::WriteOnly)) { qWarning() << "Unable to open file " << final_path; return; } @@ -70,7 +71,7 @@ void Downloader::download(const QUrl &url, const QString &filepath, const QVaria const auto nam = new QNetworkAccessManager(this); // Create the network request and execute const auto request = QNetworkRequest(url); - reply = nam->get(request); + reply = nam->get(request); // Connect to the finished signal connect(reply, &QNetworkReply::finished, this, &Downloader::onResult); } @@ -93,4 +94,3 @@ Downloader::onResult() qDebug() << Q_FUNC_INFO << "Downloaded complete: file written to " << file->fileName(); emit downloadCompleted(file->fileName(), variantData); } - diff --git a/src/qt/qt_downloader.hpp b/src/qt/qt_downloader.hpp index 942da3c49..82b4229d7 100644 --- a/src/qt/qt_downloader.hpp +++ b/src/qt/qt_downloader.hpp @@ -20,7 +20,6 @@ #include #include - class Downloader final : public QObject { Q_OBJECT public: @@ -38,17 +37,17 @@ signals: // Signal emitted when the download is successful void downloadCompleted(QString filename, QVariant varData); // Signal emitted when an error occurs - void errorOccurred(const QString&); + void errorOccurred(const QString &); private slots: void onResult(); private: - QFile *file; + QFile *file; QNetworkAccessManager nam; - QNetworkReply *reply; - QVariant variantData; - QDir downloadDirectory; + QNetworkReply *reply; + QVariant variantData; + QDir downloadDirectory; }; #endif diff --git a/src/qt/qt_glsl_parser.cpp b/src/qt/qt_glsl_parser.cpp index 0bd35ca25..4dbddd1c0 100644 --- a/src/qt/qt_glsl_parser.cpp +++ b/src/qt/qt_glsl_parser.cpp @@ -3,15 +3,14 @@ #include #include -extern MainWindow* main_window; +extern MainWindow *main_window; #include #include #include #include #include -extern "C" -{ +extern "C" { #include <86box/86box.h> #include <86box/ini.h> #include <86box/config.h> @@ -19,25 +18,32 @@ extern "C" #include <86box/path.h> #include <86box/plat.h> -extern void startblit(); -extern void endblit(); +extern void startblit(); +extern void endblit(); extern ssize_t local_getline(char **buf, size_t *bufsiz, FILE *fp); -extern char* trim(char* str); +extern char *trim(char *str); } -#define safe_strncpy(a, b, n) \ - do { \ - strncpy((a), (b), (n)-1); \ - (a)[(n)-1] = 0; \ - } while (0) +#define safe_strncpy(a, b, n) \ + do { \ + strncpy((a), (b), (n) - 1); \ + (a)[(n) - 1] = 0; \ + } while (0) +static inline void * +wx_config_load(const char *path) +{ + ini_t ini = ini_read(path); + if (ini) + ini_strip_quotes(ini); + return (void *) ini; +} - -static inline void *wx_config_load(const char *path) { ini_t ini = ini_read(path); if (ini) ini_strip_quotes(ini); return (void*)ini; } - -static inline int wx_config_get_string(void *config, const char *name, char *dst, int size, const char *defVal) { - int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name); - char* str = ini_get_string((ini_t)config, "", name, (char*)defVal); +static inline int +wx_config_get_string(void *config, const char *name, char *dst, int size, const char *defVal) +{ + int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name); + char *str = ini_get_string((ini_t) config, "", name, (char *) defVal); if (size == 0) return res; if (str != NULL) @@ -47,40 +53,56 @@ static inline int wx_config_get_string(void *config, const char *name, char *dst return res; } -static inline int wx_config_get_int(void *config, const char *name, int *dst, int defVal) { - int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name); - *dst = ini_get_int((ini_t)config, "", name, defVal); +static inline int +wx_config_get_int(void *config, const char *name, int *dst, int defVal) +{ + int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name); + *dst = ini_get_int((ini_t) config, "", name, defVal); return res; } -static inline int wx_config_get_float(void *config, const char *name, float *dst, float defVal) { - int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name); - *dst = (float)ini_get_double((ini_t)config, "", name, defVal); +static inline int +wx_config_get_float(void *config, const char *name, float *dst, float defVal) +{ + int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name); + *dst = (float) ini_get_double((ini_t) config, "", name, defVal); return res; } -static inline int wx_config_get_bool(void *config, const char *name, int *dst, int defVal) { - int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name); - *dst = !!ini_get_int((ini_t)config, "", name, defVal); +static inline int +wx_config_get_bool(void *config, const char *name, int *dst, int defVal) +{ + int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name); + *dst = !!ini_get_int((ini_t) config, "", name, defVal); return res; } -static inline int wx_config_has_entry(void *config, const char *name) { return ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name); } -static inline void wx_config_free(void *config) { ini_close(config); }; +static inline int +wx_config_has_entry(void *config, const char *name) +{ + return ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name); +} +static inline void +wx_config_free(void *config) +{ + ini_close(config); +}; -static int endswith(const char *str, const char *ext) { - const char *p; - int elen = strlen(ext); - int slen = strlen(str); - if (slen >= elen) { - p = &str[slen - elen]; - for (int i = 0; i < elen; ++i) { - if (tolower(p[i]) != tolower(ext[i])) - return 0; - } - return 1; +static int +endswith(const char *str, const char *ext) +{ + const char *p; + int elen = strlen(ext); + int slen = strlen(str); + if (slen >= elen) { + p = &str[slen - elen]; + for (int i = 0; i < elen; ++i) { + if (tolower(p[i]) != tolower(ext[i])) + return 0; } - return 0; + return 1; + } + return 0; } static int @@ -101,326 +123,355 @@ glsl_detect_bom(const char *fn) return 0; } -static char *load_file(const char *fn) { - int bom = glsl_detect_bom(fn); - FILE *fp = plat_fopen(fn, "rb"); - if (!fp) - return 0; - fseek(fp, 0, SEEK_END); - long fsize = ftell(fp); - fseek(fp, 0, SEEK_SET); +static char * +load_file(const char *fn) +{ + int bom = glsl_detect_bom(fn); + FILE *fp = plat_fopen(fn, "rb"); + if (!fp) + return 0; + fseek(fp, 0, SEEK_END); + long fsize = ftell(fp); + fseek(fp, 0, SEEK_SET); + if (bom) { + fsize -= 3; + fseek(fp, 3, SEEK_SET); + } + + char *data = (char *) malloc(fsize + 1); + + size_t read_bytes = fread(data, fsize, 1, fp); + if (read_bytes != 1) { + fclose(fp); + free(data); + return nullptr; + } else { + fclose(fp); + + data[fsize] = 0; + + return data; + } +} + +static void +strip_lines(const char *program, const char *starts_with) +{ + /* strip parameters */ + char *ptr = (char *) strstr(program, starts_with); + while (ptr != nullptr) { + while (*ptr != '\n' && *ptr != '\0') + *ptr++ = ' '; + ptr = (char *) strstr(program, starts_with); + } +} + +static void +strip_parameters(const char *program) +{ + /* strip parameters */ + strip_lines(program, "#pragma parameter"); +} + +static void +strip_defines(const char *program) +{ + /* strip texture define */ + strip_lines(program, "#define texture"); +} + +static int +has_parameter(glslp_t *glsl, char *id) +{ + for (int i = 0; i < glsl->num_parameters; ++i) + if (!strcmp(glsl->parameters[i].id, id)) + return 1; + return 0; +} + +static int +get_parameters(glslp_t *glsl) +{ + struct parameter p; + for (int i = 0; i < glsl->num_shaders; ++i) { + size_t size = 0; + char *line = NULL; + struct shader *shader = &glsl->shaders[i]; + int bom = glsl_detect_bom(shader->shader_fn); + FILE *f = plat_fopen(shader->shader_fn, "rb"); + if (!f) + return 0; if (bom) { - fsize -= 3; - fseek(fp, 3, SEEK_SET); + fseek(f, 3, SEEK_SET); + } + while (local_getline(&line, &size, f) != -1 && glsl->num_parameters < MAX_PARAMETERS) { + line[strcspn(line, "\r\n")] = '\0'; + trim(line); + int num = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", p.id, p.description, + &p.default_value, &p.min, &p.max, &p.step); + if (num < 5) + continue; + p.id[63] = 0; + p.description[63] = 0; + + if (num == 5) + p.step = 0.1f * (p.max - p.min); + + p.value = p.default_value; + + if (!has_parameter(glsl, p.id)) { + memcpy(&glsl->parameters[glsl->num_parameters++], &p, sizeof(struct parameter)); + pclog("Read parameter: %s (%s) %f, %f -> %f (%f)\n", p.id, p.description, p.default_value, p.min, + p.max, p.step); + } } - char *data = (char*)malloc(fsize + 1); + fclose(f); + } - size_t read_bytes = fread(data, fsize, 1, fp); - if (read_bytes != 1) { - fclose(fp); - free(data); - return nullptr; - } else { - fclose(fp); + return 1; +} - data[fsize] = 0; - - return data; +static struct parameter * +get_parameter(glslp_t *glslp, const char *id) +{ + for (int i = 0; i < glslp->num_parameters; ++i) { + if (!strcmp(glslp->parameters[i].id, id)) { + return &glslp->parameters[i]; } + } + return 0; } -static void strip_lines(const char *program, const char *starts_with) { - /* strip parameters */ - char *ptr = (char *) strstr(program, starts_with); - while (ptr != nullptr) { - while (*ptr != '\n' && *ptr != '\0') - *ptr++ = ' '; - ptr = (char *) strstr(program, starts_with); - } -} - -static void strip_parameters(const char *program) { - /* strip parameters */ - strip_lines(program, "#pragma parameter"); -} - -static void strip_defines(const char *program) { - /* strip texture define */ - strip_lines(program, "#define texture"); -} - -static int has_parameter(glslp_t *glsl, char *id) { - for (int i = 0; i < glsl->num_parameters; ++i) - if (!strcmp(glsl->parameters[i].id, id)) - return 1; +static glslp_t * +glsl_parse(const char *f) +{ + glslp_t *glslp = (glslp_t *) calloc(1, sizeof(glslp_t)); + glslp->num_shaders = 1; + struct shader *shader = &glslp->shaders[0]; + strcpy(shader->shader_fn, f); + shader->shader_program = load_file(f); + if (!shader->shader_program) { + QMessageBox::critical((QWidget *) qApp->findChild(), QObject::tr("GLSL error"), QObject::tr("Could not load shader: %1").arg(shader->shader_fn)); + // wx_simple_messagebox("GLSL error", "Could not load shader %s\n", shader->shader_fn); + glslp_free(glslp); return 0; -} - -static int get_parameters(glslp_t *glsl) { - struct parameter p; - for (int i = 0; i < glsl->num_shaders; ++i) { - size_t size = 0; - char* line = NULL; - struct shader *shader = &glsl->shaders[i]; - int bom = glsl_detect_bom(shader->shader_fn); - FILE *f = plat_fopen(shader->shader_fn, "rb"); - if (!f) - return 0; - if (bom) { - fseek(f, 3, SEEK_SET); - } - while (local_getline(&line, &size, f) != -1 && glsl->num_parameters < MAX_PARAMETERS) { - line[strcspn(line, "\r\n")] = '\0'; - trim(line); - int num = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", p.id, p.description, - &p.default_value, &p.min, &p.max, &p.step); - if (num < 5) - continue; - p.id[63] = 0; - p.description[63] = 0; - - if (num == 5) - p.step = 0.1f * (p.max - p.min); - - p.value = p.default_value; - - if (!has_parameter(glsl, p.id)) { - memcpy(&glsl->parameters[glsl->num_parameters++], &p, sizeof(struct parameter)); - pclog("Read parameter: %s (%s) %f, %f -> %f (%f)\n", p.id, p.description, p.default_value, p.min, - p.max, p.step); - } - } - - fclose(f); - } - - return 1; -} - -static struct parameter *get_parameter(glslp_t *glslp, const char *id) { - for (int i = 0; i < glslp->num_parameters; ++i) { - if (!strcmp(glslp->parameters[i].id, id)) { - return &glslp->parameters[i]; - } - } - return 0; -} - -static glslp_t *glsl_parse(const char *f) { - glslp_t *glslp = (glslp_t*) calloc(1, sizeof(glslp_t)); - glslp->num_shaders = 1; - struct shader *shader = &glslp->shaders[0]; - strcpy(shader->shader_fn, f); - shader->shader_program = load_file(f); - if (!shader->shader_program) { - QMessageBox::critical((QWidget *) qApp->findChild(), QObject::tr("GLSL error"), QObject::tr("Could not load shader: %1").arg(shader->shader_fn)); - //wx_simple_messagebox("GLSL error", "Could not load shader %s\n", shader->shader_fn); - glslp_free(glslp); - return 0; - } - strip_parameters(shader->shader_program); - strip_defines(shader->shader_program); - shader->scale_x = shader->scale_y = 1.0f; - strcpy(shader->scale_type_x, "source"); - strcpy(shader->scale_type_y, "source"); - get_parameters(glslp); - return glslp; + } + strip_parameters(shader->shader_program); + strip_defines(shader->shader_program); + shader->scale_x = shader->scale_y = 1.0f; + strcpy(shader->scale_type_x, "source"); + strcpy(shader->scale_type_y, "source"); + get_parameters(glslp); + return glslp; } extern "C" { -void get_glslp_name(const char *f, char *s, int size) { safe_strncpy(s, path_get_filename((char *)f), size); } - -glslp_t *glslp_parse(const char *f) { - int j; - int len; - int sublen; - char s[2049], t[2049], z[2076]; - - memset(s, 0, sizeof(s)); - if (endswith(f, ".glsl")) - return glsl_parse(f); - - void *cfg = wx_config_load(f); - - if (!cfg) { - fprintf(stderr, "GLSLP Error: Could not load GLSLP-file %s\n", f); - return 0; - } - - glslp_t *glslp = (glslp_t*) calloc(1, sizeof(glslp_t)); - - get_glslp_name(f, glslp->name, sizeof(glslp->name)); - - wx_config_get_int(cfg, "shaders", &glslp->num_shaders, 0); - - wx_config_get_bool(cfg, "filter_linear0", &glslp->input_filter_linear, -1); - - for (int i = 0; i < glslp->num_shaders; ++i) { - struct shader *shader = &glslp->shaders[i]; - - snprintf(s, sizeof(s) - 1, "shader%d", i); - if (!wx_config_get_string(cfg, s, t, sizeof(t), 0)) { - /* shader doesn't exist, lets break here */ - glslp->num_shaders = i; - break; - } - strcpy(s, f); - *path_get_filename(s) = 0; - - size_t max_len = sizeof(shader->shader_fn); - size_t s_len = strlen(s); - - if (s_len >= max_len) { - // s alone fills or overflows the buffer, truncate and null-terminate - size_t copy_len = max_len - 1 < s_len ? max_len - 1 : s_len; - memcpy(shader->shader_fn, s, copy_len); - shader->shader_fn[copy_len] = '\0'; - } else { - // Copy s fully - memcpy(shader->shader_fn, s, s_len); - // Copy as much of t as fits after s - size_t avail = max_len - 1 - s_len; // space left for t + null terminator - // Copy as much of t as fits into the remaining space - memcpy(shader->shader_fn + s_len, t, avail); - // Null-terminate - shader->shader_fn[s_len + avail] = '\0'; - } - - shader->shader_program = load_file(shader->shader_fn); - if (!shader->shader_program) { - fprintf(stderr, "GLSLP Error: Could not load shader %s\n", shader->shader_fn); - glslp_free(glslp); - return 0; - } - strip_parameters(shader->shader_program); - strip_defines(shader->shader_program); - - snprintf(s, sizeof(s) - 1, "alias%d", i); - wx_config_get_string(cfg, s, shader->alias, sizeof(shader->alias), 0); - - snprintf(s, sizeof(s) - 1, "filter_linear%d", i + 1); - wx_config_get_bool(cfg, s, &shader->filter_linear, 0); - - snprintf(s, sizeof(s) - 1, "wrap_mode%d", i); - wx_config_get_string(cfg, s, shader->wrap_mode, sizeof(shader->wrap_mode), 0); - - snprintf(s, sizeof(s) - 1, "float_framebuffer%d", i); - wx_config_get_bool(cfg, s, &shader->float_framebuffer, 0); - snprintf(s, sizeof(s) - 1, "srgb_framebuffer%d", i); - wx_config_get_bool(cfg, s, &shader->srgb_framebuffer, 0); - - snprintf(s, sizeof(s) - 1, "mipmap_input%d", i); - wx_config_get_bool(cfg, s, &shader->mipmap_input, 0); - - strcpy(shader->scale_type_x, "source"); - snprintf(s, sizeof(s) - 1, "scale_type_x%d", i); - wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0); - strcpy(shader->scale_type_y, "source"); - snprintf(s, sizeof(s) - 1, "scale_type_y%d", i); - wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0); - snprintf(s, sizeof(s) - 1, "scale_type%d", i); - if (wx_config_has_entry(cfg, s)) { - wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0); - wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0); - } - - snprintf(s, sizeof(s) - 1, "scale_x%d", i); - wx_config_get_float(cfg, s, &shader->scale_x, 1.0f); - snprintf(s, sizeof(s) - 1, "scale_y%d", i); - wx_config_get_float(cfg, s, &shader->scale_y, 1.0f); - snprintf(s, sizeof(s) - 1, "scale%d", i); - if (wx_config_has_entry(cfg, s)) { - wx_config_get_float(cfg, s, &shader->scale_x, 1.0f); - wx_config_get_float(cfg, s, &shader->scale_y, 1.0f); - } - - snprintf(s, sizeof(s) - 1, "frame_count_mod%d", i); - wx_config_get_int(cfg, s, &shader->frame_count_mod, 0); - } - - /* textures */ - glslp->num_textures = 0; - wx_config_get_string(cfg, "textures", t, sizeof(t), 0); - - len = strlen(t); - j = 0; - sublen = 0; - for (int i = 0; i < len; ++i) { - if (t[i] == ';' || i == len - 1) { - sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1; - safe_strncpy(s, t + j, sublen); - s[511 < sublen ? 511 : sublen] = 0; - - if (s[strlen(s) - 1] == ';') s[strlen(s) - 1] = 0; - - struct texture *tex = &glslp->textures[glslp->num_textures++]; - - strcpy(tex->name, s); - wx_config_get_string(cfg, s, tex->path, sizeof(tex->path), 0); - - snprintf(z, sizeof(z) - 1, "%s_linear", s); - wx_config_get_bool(cfg, z, &tex->linear, 0); - - snprintf(z, sizeof(z) - 1, "%s_mipmap", s); - wx_config_get_bool(cfg, z, &tex->mipmap, 0); - - snprintf(z, sizeof(z) - 1, "%s_wrap_mode", s); - wx_config_get_string(cfg, z, tex->wrap_mode, sizeof(tex->wrap_mode), 0); - - j = i + 1; - } - } - - /* parameters */ - get_parameters(glslp); - - wx_config_get_string(cfg, "parameters", t, sizeof(t), 0); - - len = strlen(t); - j = 0; - sublen = 0; - for (int i = 0; i < len; ++i) { - if (t[i] == ';' || i == len - 1) { - sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1; - safe_strncpy(s, t + j, sublen); - s[511 < sublen ? 511 : sublen] = 0; - - struct parameter *p = get_parameter(glslp, s); - - if (p) - wx_config_get_float(cfg, s, &p->default_value, 0); - - j = i + 1; - } - } - - wx_config_free(cfg); - - return glslp; +void +get_glslp_name(const char *f, char *s, int size) +{ + safe_strncpy(s, path_get_filename((char *) f), size); } -void glslp_free(glslp_t *p) { - for (int i = 0; i < p->num_shaders; ++i) - if (p->shaders[i].shader_program) - free(p->shaders[i].shader_program); - free(p); +glslp_t * +glslp_parse(const char *f) +{ + int j; + int len; + int sublen; + char s[2049], t[2049], z[2076]; + + memset(s, 0, sizeof(s)); + if (endswith(f, ".glsl")) + return glsl_parse(f); + + void *cfg = wx_config_load(f); + + if (!cfg) { + fprintf(stderr, "GLSLP Error: Could not load GLSLP-file %s\n", f); + return 0; + } + + glslp_t *glslp = (glslp_t *) calloc(1, sizeof(glslp_t)); + + get_glslp_name(f, glslp->name, sizeof(glslp->name)); + + wx_config_get_int(cfg, "shaders", &glslp->num_shaders, 0); + + wx_config_get_bool(cfg, "filter_linear0", &glslp->input_filter_linear, -1); + + for (int i = 0; i < glslp->num_shaders; ++i) { + struct shader *shader = &glslp->shaders[i]; + + snprintf(s, sizeof(s) - 1, "shader%d", i); + if (!wx_config_get_string(cfg, s, t, sizeof(t), 0)) { + /* shader doesn't exist, lets break here */ + glslp->num_shaders = i; + break; + } + strcpy(s, f); + *path_get_filename(s) = 0; + + size_t max_len = sizeof(shader->shader_fn); + size_t s_len = strlen(s); + + if (s_len >= max_len) { + // s alone fills or overflows the buffer, truncate and null-terminate + size_t copy_len = max_len - 1 < s_len ? max_len - 1 : s_len; + memcpy(shader->shader_fn, s, copy_len); + shader->shader_fn[copy_len] = '\0'; + } else { + // Copy s fully + memcpy(shader->shader_fn, s, s_len); + // Copy as much of t as fits after s + size_t avail = max_len - 1 - s_len; // space left for t + null terminator + // Copy as much of t as fits into the remaining space + memcpy(shader->shader_fn + s_len, t, avail); + // Null-terminate + shader->shader_fn[s_len + avail] = '\0'; + } + + shader->shader_program = load_file(shader->shader_fn); + if (!shader->shader_program) { + fprintf(stderr, "GLSLP Error: Could not load shader %s\n", shader->shader_fn); + glslp_free(glslp); + return 0; + } + strip_parameters(shader->shader_program); + strip_defines(shader->shader_program); + + snprintf(s, sizeof(s) - 1, "alias%d", i); + wx_config_get_string(cfg, s, shader->alias, sizeof(shader->alias), 0); + + snprintf(s, sizeof(s) - 1, "filter_linear%d", i + 1); + wx_config_get_bool(cfg, s, &shader->filter_linear, 0); + + snprintf(s, sizeof(s) - 1, "wrap_mode%d", i); + wx_config_get_string(cfg, s, shader->wrap_mode, sizeof(shader->wrap_mode), 0); + + snprintf(s, sizeof(s) - 1, "float_framebuffer%d", i); + wx_config_get_bool(cfg, s, &shader->float_framebuffer, 0); + snprintf(s, sizeof(s) - 1, "srgb_framebuffer%d", i); + wx_config_get_bool(cfg, s, &shader->srgb_framebuffer, 0); + + snprintf(s, sizeof(s) - 1, "mipmap_input%d", i); + wx_config_get_bool(cfg, s, &shader->mipmap_input, 0); + + strcpy(shader->scale_type_x, "source"); + snprintf(s, sizeof(s) - 1, "scale_type_x%d", i); + wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0); + strcpy(shader->scale_type_y, "source"); + snprintf(s, sizeof(s) - 1, "scale_type_y%d", i); + wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0); + snprintf(s, sizeof(s) - 1, "scale_type%d", i); + if (wx_config_has_entry(cfg, s)) { + wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0); + wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0); + } + + snprintf(s, sizeof(s) - 1, "scale_x%d", i); + wx_config_get_float(cfg, s, &shader->scale_x, 1.0f); + snprintf(s, sizeof(s) - 1, "scale_y%d", i); + wx_config_get_float(cfg, s, &shader->scale_y, 1.0f); + snprintf(s, sizeof(s) - 1, "scale%d", i); + if (wx_config_has_entry(cfg, s)) { + wx_config_get_float(cfg, s, &shader->scale_x, 1.0f); + wx_config_get_float(cfg, s, &shader->scale_y, 1.0f); + } + + snprintf(s, sizeof(s) - 1, "frame_count_mod%d", i); + wx_config_get_int(cfg, s, &shader->frame_count_mod, 0); + } + + /* textures */ + glslp->num_textures = 0; + wx_config_get_string(cfg, "textures", t, sizeof(t), 0); + + len = strlen(t); + j = 0; + sublen = 0; + for (int i = 0; i < len; ++i) { + if (t[i] == ';' || i == len - 1) { + sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1; + safe_strncpy(s, t + j, sublen); + s[511 < sublen ? 511 : sublen] = 0; + + if (s[strlen(s) - 1] == ';') + s[strlen(s) - 1] = 0; + + struct texture *tex = &glslp->textures[glslp->num_textures++]; + + strcpy(tex->name, s); + wx_config_get_string(cfg, s, tex->path, sizeof(tex->path), 0); + + snprintf(z, sizeof(z) - 1, "%s_linear", s); + wx_config_get_bool(cfg, z, &tex->linear, 0); + + snprintf(z, sizeof(z) - 1, "%s_mipmap", s); + wx_config_get_bool(cfg, z, &tex->mipmap, 0); + + snprintf(z, sizeof(z) - 1, "%s_wrap_mode", s); + wx_config_get_string(cfg, z, tex->wrap_mode, sizeof(tex->wrap_mode), 0); + + j = i + 1; + } + } + + /* parameters */ + get_parameters(glslp); + + wx_config_get_string(cfg, "parameters", t, sizeof(t), 0); + + len = strlen(t); + j = 0; + sublen = 0; + for (int i = 0; i < len; ++i) { + if (t[i] == ';' || i == len - 1) { + sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1; + safe_strncpy(s, t + j, sublen); + s[511 < sublen ? 511 : sublen] = 0; + + struct parameter *p = get_parameter(glslp, s); + + if (p) + wx_config_get_float(cfg, s, &p->default_value, 0); + + j = i + 1; + } + } + + wx_config_free(cfg); + + return glslp; } -void glslp_read_shader_config(glslp_t *shader) { - char s[512]; +void +glslp_free(glslp_t *p) +{ + for (int i = 0; i < p->num_shaders; ++i) + if (p->shaders[i].shader_program) + free(p->shaders[i].shader_program); + free(p); +} + +void +glslp_read_shader_config(glslp_t *shader) +{ + char s[512]; char *name = shader->name; - snprintf(s, sizeof(s) -1, "GL3 Shaders - %s", name); + snprintf(s, sizeof(s) - 1, "GL3 Shaders - %s", name); for (int i = 0; i < shader->num_parameters; ++i) { struct parameter *param = &shader->parameters[i]; - param->value = config_get_double(s, param->id, param->default_value); + param->value = config_get_double(s, param->id, param->default_value); } } -void glslp_write_shader_config(glslp_t *shader) { - char s[512]; +void +glslp_write_shader_config(glslp_t *shader) +{ + char s[512]; char *name = shader->name; startblit(); @@ -431,5 +482,4 @@ void glslp_write_shader_config(glslp_t *shader) { } endblit(); } - } diff --git a/src/qt/qt_harddiskdialog.cpp b/src/qt/qt_harddiskdialog.cpp index 66ab3e59b..fbb6a4768 100644 --- a/src/qt/qt_harddiskdialog.cpp +++ b/src/qt/qt_harddiskdialog.cpp @@ -19,7 +19,7 @@ extern "C" { #ifdef __unix__ -#include +# include #endif #include <86box/86box.h> #include <86box/hdd.h> @@ -75,7 +75,7 @@ HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent) for (int i = 0; i < 127; i++) { uint64_t size = ((uint64_t) hdd_table[i][0]) * hdd_table[i][1] * hdd_table[i][2]; uint32_t size_mb = size >> 11LL; - QString text = tr("%1 MB (CHS: %2, %3, %4)").arg(size_mb).arg(hdd_table[i][0]).arg(hdd_table[i][1]).arg(hdd_table[i][2]); + QString text = tr("%1 MB (CHS: %2, %3, %4)").arg(size_mb).arg(hdd_table[i][0]).arg(hdd_table[i][1]).arg(hdd_table[i][2]); Models::AddEntry(model, text, i); } Models::AddEntry(model, tr("Custom..."), 127); @@ -85,11 +85,11 @@ HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent) ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); filters = QStringList({ tr("Raw image") % util::DlgFilter({ "img" }, true), - tr("HDI image") % util::DlgFilter({ "hdi" }, true), - tr("HDX image") % util::DlgFilter({ "hdx" }, true), - tr("Fixed-size VHD") % util::DlgFilter({ "vhd" }, true), - tr("Dynamic-size VHD") % util::DlgFilter({ "vhd" }, true), - tr("Differencing VHD") % util::DlgFilter({ "vhd" }, true) }); + tr("HDI image") % util::DlgFilter({ "hdi" }, true), + tr("HDX image") % util::DlgFilter({ "hdx" }, true), + tr("Fixed-size VHD") % util::DlgFilter({ "vhd" }, true), + tr("Dynamic-size VHD") % util::DlgFilter({ "vhd" }, true), + tr("Differencing VHD") % util::DlgFilter({ "vhd" }, true) }); if (existing) { ui->fileField->setFilter(tr("Hard disk images") % util::DlgFilter({ "hd?", "im?", "vhd" }) % tr("All files") % util::DlgFilter({ "*" }, true)); @@ -317,7 +317,6 @@ create_drive_vhd_diff(const QString &fileName, const QString &parentFileName, in _86box_geometry.spt = vhd_geometry.spt; } - mvhd_close(vhd); } @@ -414,7 +413,7 @@ HarddiskDialog::onCreateNewFile() file.close(); _86BoxGeom _86box_geometry {}; - int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL; + int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL; switch (img_format) { case IMG_FMT_VHD_FIXED: { @@ -568,7 +567,7 @@ HarddiskDialog::onExistingFileSelected(const QString &fileName, bool precheck) if (!file.open(QIODevice::ReadOnly)) { // No message box during precheck (performed when the file input loses focus and this function is called) // If precheck is false, the file has been chosen from a file dialog and the alert should display. - if(!precheck) { + if (!precheck) { QMessageBox::critical(this, tr("Unable to read file"), tr("Make sure the file exists and is readable.")); } return; diff --git a/src/qt/qt_harddrive_common.cpp b/src/qt/qt_harddrive_common.cpp index 9e48a627e..1c07e5f3f 100644 --- a/src/qt/qt_harddrive_common.cpp +++ b/src/qt/qt_harddrive_common.cpp @@ -123,10 +123,10 @@ Harddrives::populateBusChannels(QAbstractItemModel *model, int bus, SettingsBusT { model->removeRows(0, model->rowCount()); - int busRows = 0; - int shifter = 1; - int orer = 1; - int subChannelWidth = 1; + int busRows = 0; + int shifter = 1; + int orer = 1; + int subChannelWidth = 1; QList busesToCheck; QList channelsInUse; switch (bus) { @@ -160,15 +160,15 @@ Harddrives::populateBusChannels(QAbstractItemModel *model, int bus, SettingsBusT busesToCheck.append(HDD_BUS_SCSI); break; case CDROM_BUS_MKE: - shifter = 2; - orer = 3; - busRows = 4; + shifter = 2; + orer = 3; + busRows = 4; busesToCheck.append(CDROM_BUS_MKE); break; default: break; } - if(sbt != nullptr && !busesToCheck.empty()) { + if (sbt != nullptr && !busesToCheck.empty()) { for (auto const &checkBus : busesToCheck) { channelsInUse.append(sbt->busChannelsInUse(checkBus)); } @@ -179,9 +179,9 @@ Harddrives::populateBusChannels(QAbstractItemModel *model, int bus, SettingsBusT auto idx = model->index(i, 0); model->setData(idx, QString("%1:%2").arg(i >> shifter).arg(i & orer, subChannelWidth, 10, QChar('0'))); model->setData(idx, ((i >> shifter) << shifter) | (i & orer), Qt::UserRole); - const auto *channelModel = qobject_cast(model); - auto *channelItem = channelModel->item(i); - if(channelItem) { + const auto *channelModel = qobject_cast(model); + auto *channelItem = channelModel->item(i); + if (channelItem) { channelItem->setEnabled(!channelsInUse.contains(i)); } } diff --git a/src/qt/qt_iconindicators.cpp b/src/qt/qt_iconindicators.cpp index 169910b21..b93c375b7 100644 --- a/src/qt/qt_iconindicators.cpp +++ b/src/qt/qt_iconindicators.cpp @@ -35,7 +35,7 @@ getIconWithIndicator(const QIcon &icon, const QSize &size, QIcon::Mode iconMode, if (indicator == None) return iconPixmap; - auto painter = QPainter(&iconPixmap); + auto painter = QPainter(&iconPixmap); auto indicatorPixmap = getIndicatorIcon((indicator == ReadWriteActive || indicator == WriteProtectedActive) ? Active : indicator).pixmap(size); if (indicator == WriteProtectedBrowse) diff --git a/src/qt/qt_iconindicators.hpp b/src/qt/qt_iconindicators.hpp index c3c8946ad..24ce80ad3 100644 --- a/src/qt/qt_iconindicators.hpp +++ b/src/qt/qt_iconindicators.hpp @@ -1,5 +1,5 @@ #ifndef QT_ICONINDICATORS_HPP -# define QT_ICONINDICATORS_HPP +#define QT_ICONINDICATORS_HPP #include #include diff --git a/src/qt/qt_keybind.cpp b/src/qt/qt_keybind.cpp index 1862f4aa8..78845a733 100644 --- a/src/qt/qt_keybind.cpp +++ b/src/qt/qt_keybind.cpp @@ -52,7 +52,7 @@ extern "C" { # include #endif #ifdef Q_OS_WINDOWS -#include +# include #endif KeyBinder::KeyBinder(QWidget *parent) @@ -60,10 +60,10 @@ KeyBinder::KeyBinder(QWidget *parent) , ui(new Ui::KeyBinder) { ui->setupUi(this); - singleKeySequenceEdit *seq = new singleKeySequenceEdit(); - ui->formLayout->addRow(seq); - seq->setObjectName("keySequence"); - this->setTabOrder(seq, ui->buttonBox); + singleKeySequenceEdit *seq = new singleKeySequenceEdit(); + ui->formLayout->addRow(seq); + seq->setObjectName("keySequence"); + this->setTabOrder(seq, ui->buttonBox); } KeyBinder::~KeyBinder() @@ -72,29 +72,31 @@ KeyBinder::~KeyBinder() } void -KeyBinder::showEvent( QShowEvent* event ) { - QWidget::showEvent( event ); - this->findChild()->setFocus(); -} - -bool KeyBinder::eventFilter(QObject *obj, QEvent *event) +KeyBinder::showEvent(QShowEvent *event) { - return QObject::eventFilter(obj, event); + QWidget::showEvent(event); + this->findChild()->setFocus(); +} + +bool +KeyBinder::eventFilter(QObject *obj, QEvent *event) +{ + return QObject::eventFilter(obj, event); } QKeySequence -KeyBinder::BindKey(QWidget* widget, QString CurValue) +KeyBinder::BindKey(QWidget *widget, QString CurValue) { - KeyBinder kb(widget); - kb.setWindowTitle(tr("Bind Key")); + KeyBinder kb(widget); + kb.setWindowTitle(tr("Bind Key")); kb.setFixedSize(kb.minimumSizeHint()); - kb.findChild()->setKeySequence(QKeySequence::fromString(CurValue, QKeySequence::NativeText)); - kb.setEnabled(true); - + kb.findChild()->setKeySequence(QKeySequence::fromString(CurValue, QKeySequence::NativeText)); + kb.setEnabled(true); + if (kb.exec() == QDialog::Accepted) { - QKeySequenceEdit *seq = kb.findChild(); - return (seq->keySequence()); + QKeySequenceEdit *seq = kb.findChild(); + return (seq->keySequence()); } else { - return (false); - } + return (false); + } } \ No newline at end of file diff --git a/src/qt/qt_keybind.hpp b/src/qt/qt_keybind.hpp index 25f4a9168..055dacce4 100644 --- a/src/qt/qt_keybind.hpp +++ b/src/qt/qt_keybind.hpp @@ -22,12 +22,12 @@ public: explicit KeyBinder(QWidget *parent = nullptr); ~KeyBinder() override; - static QKeySequence BindKey(QWidget* widget, QString CurValue); + static QKeySequence BindKey(QWidget *widget, QString CurValue); private: Ui::KeyBinder *ui; - bool eventFilter(QObject *obj, QEvent *event) override; - void showEvent( QShowEvent* event ) override; + bool eventFilter(QObject *obj, QEvent *event) override; + void showEvent(QShowEvent *event) override; }; #endif // QT_KeyBinder_HPP diff --git a/src/qt/qt_machinestatus.cpp b/src/qt/qt_machinestatus.cpp index b9d4c4385..2e6203f24 100644 --- a/src/qt/qt_machinestatus.cpp +++ b/src/qt/qt_machinestatus.cpp @@ -109,9 +109,9 @@ struct Pixmaps { struct StateActive { std::unique_ptr label; - PixmapSetActive *pixmaps = nullptr; - bool active = false; - bool write_active = false; + PixmapSetActive *pixmaps = nullptr; + bool active = false; + bool write_active = false; void setActive(bool b) { @@ -164,11 +164,11 @@ struct StateEmpty { }; struct StateEmptyActive { std::unique_ptr label; - PixmapSetEmptyActive *pixmaps = nullptr; - bool empty = false; - bool active = false; - bool write_active = false; - bool wp = false; + PixmapSetEmptyActive *pixmaps = nullptr; + bool empty = false; + bool active = false; + bool write_active = false; + bool wp = false; void setActive(bool b) { @@ -222,7 +222,7 @@ struct StateEmptyActive { } }; -static QSize pixmap_size(16, 16); +static QSize pixmap_size(16, 16); void PixmapSetEmpty::load(const QIcon &icon) @@ -236,8 +236,8 @@ PixmapSetActive::load(const QIcon &icon) { normal = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, None); active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, Active); - - write_active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, WriteActive); + + write_active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, WriteActive); read_write_active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, ReadWriteActive); } @@ -326,7 +326,7 @@ MachineStatus::MachineStatus(QObject *parent) : QObject(parent) , refreshTimer(new QTimer(this)) { - d = std::make_unique(this); + d = std::make_unique(this); soundMenu = nullptr; connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons); refreshTimer->start(75); @@ -335,7 +335,7 @@ MachineStatus::MachineStatus(QObject *parent) MachineStatus::~MachineStatus() = default; void -MachineStatus::setSoundMenu(QMenu* menu) +MachineStatus::setSoundMenu(QMenu *menu) { soundMenu = menu; } @@ -768,7 +768,7 @@ MachineStatus::refresh(QStatusBar *sbar) tooltip.append("\n"); for (int i = 0; i < HDD_NUM; i++) { if (hdd[i].bus_type == HDD_BUS_MFM && hdd[i].fn[0] != 0) { - tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); + tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); } } d->hdds[HDD_BUS_MFM].label->setToolTip(tooltip); @@ -784,7 +784,7 @@ MachineStatus::refresh(QStatusBar *sbar) tooltip.append("\n"); for (int i = 0; i < HDD_NUM; i++) { if (hdd[i].bus_type == HDD_BUS_ESDI && hdd[i].fn[0] != 0) { - tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); + tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); } } d->hdds[HDD_BUS_ESDI].label->setToolTip(tooltip); @@ -800,7 +800,7 @@ MachineStatus::refresh(QStatusBar *sbar) tooltip.append("\n"); for (int i = 0; i < HDD_NUM; i++) { if (hdd[i].bus_type == HDD_BUS_XTA && hdd[i].fn[0] != 0) { - tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); + tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); } } d->hdds[HDD_BUS_XTA].label->setToolTip(tooltip); @@ -819,7 +819,7 @@ MachineStatus::refresh(QStatusBar *sbar) tooltip.append("\n"); for (int i = 0; i < HDD_NUM; i++) { if (hdd[i].bus_type == HDD_BUS_IDE && hdd[i].fn[0] != 0) { - tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); + tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); } } d->hdds[HDD_BUS_IDE].label->setToolTip(tooltip); @@ -835,7 +835,7 @@ MachineStatus::refresh(QStatusBar *sbar) tooltip.append("\n"); for (int i = 0; i < HDD_NUM; i++) { if (hdd[i].bus_type == HDD_BUS_ATAPI && hdd[i].fn[0] != 0) { - tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); + tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); } } d->hdds[HDD_BUS_ATAPI].label->setToolTip(tooltip); @@ -855,7 +855,7 @@ MachineStatus::refresh(QStatusBar *sbar) tooltip.append("\n"); for (int i = 0; i < HDD_NUM; i++) { if (hdd[i].bus_type == HDD_BUS_SCSI && hdd[i].fn[0] != 0) { - tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 4), QString::asprintf("%02d", hdd[i].channel & 15), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); + tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 4), QString::asprintf("%02d", hdd[i].channel & 15), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB"))); } } d->hdds[HDD_BUS_SCSI].label->setToolTip(tooltip); diff --git a/src/qt/qt_machinestatus.hpp b/src/qt/qt_machinestatus.hpp index bb5058265..2e270ec84 100644 --- a/src/qt/qt_machinestatus.hpp +++ b/src/qt/qt_machinestatus.hpp @@ -78,7 +78,7 @@ public: QString getMessage(); void clearActivity(); - void setSoundMenu(QMenu* menu); + void setSoundMenu(QMenu *menu); public slots: void refresh(QStatusBar *sbar); void message(const QString &msg); diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 90b4b6e59..5526eee37 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -50,14 +50,14 @@ extern "C" { #include <86box/ui.h> #include <86box/video.h> #ifdef DISCORD -# include <86box/discord.h> +# include <86box/discord.h> #endif #include <86box/gdbstub.h> #include <86box/version.h> #include <86box/renderdefs.h> #ifdef Q_OS_LINUX -#define GAMEMODE_AUTO -#include "../unix/gamemode/gamemode_client.h" +# define GAMEMODE_AUTO +# include "../unix/gamemode/gamemode_client.h" #endif } @@ -96,7 +96,7 @@ extern "C" { #include "cpu.h" #include <86box/timer.h> #include <86box/nvr.h> -extern int qt_nvr_save(void); +extern int qt_nvr_save(void); extern void exit_pause(void); bool cpu_thread_running = false; @@ -210,19 +210,19 @@ win_keyboard_handle(uint32_t scancode, int up, int e0, int e1) static LRESULT CALLBACK emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { - LPKBDLLHOOKSTRUCT lpKdhs = (LPKBDLLHOOKSTRUCT) lParam; + LPKBDLLHOOKSTRUCT lpKdhs = (LPKBDLLHOOKSTRUCT) lParam; /* Checks if CTRL was pressed. */ - BOOL bCtrlDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1); - BOOL is_over_window = (GetForegroundWindow() == ((HWND) main_window->winId())); - BOOL ret = TRUE; + BOOL bCtrlDown = GetAsyncKeyState(VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1); + BOOL is_over_window = (GetForegroundWindow() == ((HWND) main_window->winId())); + BOOL ret = TRUE; - static int last = 0; + static int last = 0; - if (show_second_monitors) for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) { - const auto &secondaryRenderer = main_window->renderers[monitor_index]; - is_over_window = is_over_window || ((secondaryRenderer != nullptr) && - (GetForegroundWindow() == ((HWND) secondaryRenderer->winId()))); - } + if (show_second_monitors) + for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) { + const auto &secondaryRenderer = main_window->renderers[monitor_index]; + is_over_window = is_over_window || ((secondaryRenderer != nullptr) && (GetForegroundWindow() == ((HWND) secondaryRenderer->winId()))); + } bool skip = ((nCode < 0) || (nCode != HC_ACTION) || !is_over_window || (kbd_req_capture && !mouse_capture)); @@ -235,179 +235,173 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) 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); + bool up = !!(lpKdhs->flags & LLKHF_UP); - if (inhibit_multimedia_keys - && (lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE - || lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK - || lpKdhs->vkCode == VK_MEDIA_PREV_TRACK - || lpKdhs->vkCode == VK_VOLUME_DOWN - || lpKdhs->vkCode == VK_VOLUME_UP - || lpKdhs->vkCode == VK_VOLUME_MUTE - || lpKdhs->vkCode == VK_MEDIA_STOP - || lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT - || lpKdhs->vkCode == VK_LAUNCH_MAIL - || lpKdhs->vkCode == VK_LAUNCH_APP1 - || lpKdhs->vkCode == VK_LAUNCH_APP2 - || lpKdhs->vkCode == VK_HELP - || lpKdhs->vkCode == VK_BROWSER_BACK - || lpKdhs->vkCode == VK_BROWSER_FORWARD - || lpKdhs->vkCode == VK_BROWSER_FAVORITES - || lpKdhs->vkCode == VK_BROWSER_HOME - || lpKdhs->vkCode == VK_BROWSER_REFRESH - || lpKdhs->vkCode == VK_BROWSER_SEARCH - || lpKdhs->vkCode == VK_BROWSER_STOP)) + if (inhibit_multimedia_keys && + (lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE || + lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK || + lpKdhs->vkCode == VK_MEDIA_PREV_TRACK || + lpKdhs->vkCode == VK_VOLUME_DOWN || + lpKdhs->vkCode == VK_VOLUME_UP || + lpKdhs->vkCode == VK_VOLUME_MUTE || + lpKdhs->vkCode == VK_MEDIA_STOP || + lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT || + lpKdhs->vkCode == VK_LAUNCH_MAIL || + lpKdhs->vkCode == VK_LAUNCH_APP1 || + lpKdhs->vkCode == VK_LAUNCH_APP2 || + lpKdhs->vkCode == VK_HELP || + lpKdhs->vkCode == VK_BROWSER_BACK || + lpKdhs->vkCode == VK_BROWSER_FORWARD || + lpKdhs->vkCode == VK_BROWSER_FAVORITES || + lpKdhs->vkCode == VK_BROWSER_HOME || + lpKdhs->vkCode == VK_BROWSER_REFRESH || + lpKdhs->vkCode == VK_BROWSER_SEARCH || + lpKdhs->vkCode == VK_BROWSER_STOP)) ret = TRUE; else ret = CallNextHookEx(NULL, nCode, wParam, lParam); - switch (vkCode) - { + switch (vkCode) { case VK_MEDIA_PLAY_PAUSE: - { - win_keyboard_handle(0x22, up, 1, 0); - break; - } + { + win_keyboard_handle(0x22, up, 1, 0); + break; + } case VK_MEDIA_STOP: - { - win_keyboard_handle(0x24, up, 1, 0); - break; - } + { + win_keyboard_handle(0x24, up, 1, 0); + break; + } case VK_VOLUME_UP: - { - win_keyboard_handle(0x30, up, 1, 0); - break; - } + { + win_keyboard_handle(0x30, up, 1, 0); + break; + } case VK_VOLUME_DOWN: - { - win_keyboard_handle(0x2E, up, 1, 0); - break; - } + { + win_keyboard_handle(0x2E, up, 1, 0); + break; + } case VK_VOLUME_MUTE: - { - win_keyboard_handle(0x20, up, 1, 0); - break; - } + { + win_keyboard_handle(0x20, up, 1, 0); + break; + } case VK_MEDIA_NEXT_TRACK: - { - win_keyboard_handle(0x19, up, 1, 0); - break; - } + { + win_keyboard_handle(0x19, up, 1, 0); + break; + } case VK_MEDIA_PREV_TRACK: - { - win_keyboard_handle(0x10, up, 1, 0); - break; - } + { + win_keyboard_handle(0x10, up, 1, 0); + break; + } case VK_LAUNCH_MEDIA_SELECT: - { - win_keyboard_handle(0x6D, up, 1, 0); - break; - } + { + win_keyboard_handle(0x6D, up, 1, 0); + break; + } case VK_LAUNCH_MAIL: - { - win_keyboard_handle(0x6C, up, 1, 0); - break; - } + { + win_keyboard_handle(0x6C, up, 1, 0); + break; + } case VK_LAUNCH_APP1: - { - win_keyboard_handle(0x6B, up, 1, 0); - break; - } + { + win_keyboard_handle(0x6B, up, 1, 0); + break; + } case VK_LAUNCH_APP2: - { - win_keyboard_handle(0x21, up, 1, 0); - break; - } + { + win_keyboard_handle(0x21, up, 1, 0); + break; + } case VK_BROWSER_BACK: - { - win_keyboard_handle(0x6A, up, 1, 0); - break; - } + { + win_keyboard_handle(0x6A, up, 1, 0); + break; + } case VK_BROWSER_FORWARD: - { - win_keyboard_handle(0x69, up, 1, 0); - break; - } + { + win_keyboard_handle(0x69, up, 1, 0); + break; + } case VK_BROWSER_STOP: - { - win_keyboard_handle(0x68, up, 1, 0); - break; - } + { + win_keyboard_handle(0x68, up, 1, 0); + break; + } case VK_BROWSER_HOME: - { - win_keyboard_handle(0x32, up, 1, 0); - break; - } + { + win_keyboard_handle(0x32, up, 1, 0); + break; + } case VK_BROWSER_SEARCH: - { - win_keyboard_handle(0x65, up, 1, 0); - break; - } + { + win_keyboard_handle(0x65, up, 1, 0); + break; + } case VK_BROWSER_REFRESH: - { - win_keyboard_handle(0x67, up, 1, 0); - break; - } + { + win_keyboard_handle(0x67, up, 1, 0); + break; + } case VK_BROWSER_FAVORITES: - { - win_keyboard_handle(0x66, up, 1, 0); - break; - } + { + win_keyboard_handle(0x66, up, 1, 0); + break; + } case VK_HELP: - { - win_keyboard_handle(0x3b, up, 1, 0); - break; - } + { + 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))) + } else if ((lpKdhs->scanCode == 0x01) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) ret = TRUE; else if ((lpKdhs->scanCode == 0x01) && bCtrlDown && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) ret = TRUE; - else if ((lpKdhs->scanCode == 0x0f) && (lpKdhs->flags & LLKHF_ALTDOWN) && - !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) + else if ((lpKdhs->scanCode == 0x0f) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) ret = TRUE; else if ((lpKdhs->scanCode == 0x0f) && bCtrlDown && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) ret = TRUE; - else if ((lpKdhs->scanCode == 0x39) && (lpKdhs->flags & LLKHF_ALTDOWN) && - !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) + else if ((lpKdhs->scanCode == 0x39) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) ret = TRUE; - else if ((lpKdhs->scanCode == 0x3e) && (lpKdhs->flags & LLKHF_ALTDOWN) && - !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) + else if ((lpKdhs->scanCode == 0x3e) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED))) ret = TRUE; else if ((lpKdhs->scanCode >= 0x5b) && (lpKdhs->scanCode <= 0x5d) && (lpKdhs->flags & LLKHF_EXTENDED)) ret = TRUE; - else if (inhibit_multimedia_keys - && (lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE - || lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK - || lpKdhs->vkCode == VK_MEDIA_PREV_TRACK - || lpKdhs->vkCode == VK_VOLUME_DOWN - || lpKdhs->vkCode == VK_VOLUME_UP - || lpKdhs->vkCode == VK_VOLUME_MUTE - || lpKdhs->vkCode == VK_MEDIA_STOP - || lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT - || lpKdhs->vkCode == VK_LAUNCH_MAIL - || lpKdhs->vkCode == VK_LAUNCH_APP1 - || lpKdhs->vkCode == VK_LAUNCH_APP2 - || lpKdhs->vkCode == VK_HELP - || lpKdhs->vkCode == VK_BROWSER_BACK - || lpKdhs->vkCode == VK_BROWSER_FORWARD - || lpKdhs->vkCode == VK_BROWSER_FAVORITES - || lpKdhs->vkCode == VK_BROWSER_HOME - || lpKdhs->vkCode == VK_BROWSER_REFRESH - || lpKdhs->vkCode == VK_BROWSER_SEARCH - || lpKdhs->vkCode == VK_BROWSER_STOP)) + else if (inhibit_multimedia_keys && + (lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE || + lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK || + lpKdhs->vkCode == VK_MEDIA_PREV_TRACK || + lpKdhs->vkCode == VK_VOLUME_DOWN || + lpKdhs->vkCode == VK_VOLUME_UP || + lpKdhs->vkCode == VK_VOLUME_MUTE || + lpKdhs->vkCode == VK_MEDIA_STOP || + lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT || + lpKdhs->vkCode == VK_LAUNCH_MAIL || + lpKdhs->vkCode == VK_LAUNCH_APP1 || + lpKdhs->vkCode == VK_LAUNCH_APP2 || + lpKdhs->vkCode == VK_HELP || + lpKdhs->vkCode == VK_BROWSER_BACK || + lpKdhs->vkCode == VK_BROWSER_FORWARD || + lpKdhs->vkCode == VK_BROWSER_FAVORITES || + lpKdhs->vkCode == VK_BROWSER_HOME || + lpKdhs->vkCode == VK_BROWSER_REFRESH || + lpKdhs->vkCode == VK_BROWSER_SEARCH || + lpKdhs->vkCode == VK_BROWSER_STOP)) ret = TRUE; else ret = CallNextHookEx(NULL, nCode, wParam, lParam); if (lpKdhs->scanCode == 0x00000045) { if ((lpKdhs->flags & LLKHF_EXTENDED) && (lpKdhs->vkCode == 0x00000090)) { - /* NumLock. */ - lpKdhs->flags &= ~LLKHF_EXTENDED; + /* NumLock. */ + lpKdhs->flags &= ~LLKHF_EXTENDED; } else if (!(lpKdhs->flags & LLKHF_EXTENDED) && (lpKdhs->vkCode == 0x00000013)) { /* Pause - send E1 1D. */ win_keyboard_handle(0xe1, 0, 0, 0); @@ -433,21 +427,21 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) #endif #ifdef Q_OS_WINDOWS -static HHOOK llhook = NULL; +static HHOOK llhook = NULL; #endif void main_thread_fn() { - int frames; + int frames; QThread::currentThread()->setPriority(QThread::HighestPriority); plat_set_thread_name(nullptr, "main_thread"); framecountx = 0; // title_update = 1; uint64_t old_time = elapsed_timer.elapsed(); - int drawits = frames = 0; - is_cpu_thread = 1; + int drawits = frames = 0; + is_cpu_thread = 1; while (!is_quit && cpu_thread_run) { /* See if it is time to run a frame of code. */ const uint64_t new_time = elapsed_timer.elapsed(); @@ -505,8 +499,8 @@ main_thread_fn() } cpu_thread_running = false; - is_quit = 1; - for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + is_quit = 1; + for (uint8_t i = 1; i < GFXCARD_MAX; i++) { if (gfxcard[i]) { ui_deinit_monitor(i); plat_delay_ms(500); @@ -520,7 +514,7 @@ static std::thread *main_thread; QTimer discordupdate; #ifdef Q_OS_WINDOWS -WindowsDarkModeFilter* vmm_dark_mode_filter = nullptr; +WindowsDarkModeFilter *vmm_dark_mode_filter = nullptr; #endif int @@ -530,9 +524,9 @@ main(int argc, char *argv[]) bool wasDarkTheme = false; /* Check if Windows supports UTF-8 */ if (GetACP() == CP_UTF8) - acp_utf8 = 1; + acp_utf8 = 1; else - acp_utf8 = 0; + acp_utf8 = 0; #endif #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false); @@ -568,9 +562,9 @@ main(int argc, char *argv[]) if (!util::isWindowsLightTheme()) { QFile f(":qdarkstyle/dark/darkstyle.qss"); - if (!f.exists()) { + if (!f.exists()) { printf("Unable to set stylesheet, file not found\n"); - } else { + } else { f.open(QFile::ReadOnly | QFile::Text); QTextStream ts(&f); qApp->setStyleSheet(ts.readAll()); @@ -685,7 +679,7 @@ main(int argc, char *argv[]) pc_init_modules(); // UUID / copy / move detection - if(!util::compareUuid()) { + if (!util::compareUuid()) { QMessageBox movewarnbox; movewarnbox.setIcon(QMessageBox::Icon::Warning); movewarnbox.setText(QObject::tr("This machine might have been moved or copied.")); @@ -721,7 +715,7 @@ main(int argc, char *argv[]) warningbox.addButton(QObject::tr("Exit"), QMessageBox::RejectRole); warningbox.exec(); if (warningbox.result() == QDialog::Accepted) - return 0; + return 0; } #endif @@ -748,7 +742,7 @@ main(int argc, char *argv[]) warningbox.addButton(QObject::tr("Exit"), QMessageBox::RejectRole); warningbox.exec(); if (warningbox.result() == QDialog::Accepted) - return 0; + return 0; } #ifdef DISCORD @@ -760,7 +754,7 @@ main(int argc, char *argv[]) // https://learn.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timebeginperiod exit_pause(); timeBeginPeriod(1); - atexit([] () -> void { timeEndPeriod(1); }); + atexit([]() -> void { timeEndPeriod(1); }); #endif main_window = new MainWindow(); @@ -772,13 +766,12 @@ main(int argc, char *argv[]) #ifdef WAYLAND if (QApplication::platformName().contains("wayland")) { /* Force a sync. */ - (void)main_window->winId(); + (void) main_window->winId(); QApplication::sync(); - extern void wl_keyboard_grab(QWindow *window); + extern void wl_keyboard_grab(QWindow * window); wl_keyboard_grab(main_window->windowHandle()); } #endif - app.installEventFilter(main_window); @@ -826,7 +819,7 @@ main(int argc, char *argv[]) if (hook_enabled) { /* Yes, low-level hooks *DO* work with raw input, at least global ones. */ llhook = SetWindowsHookEx(WH_KEYBOARD_LL, emu_LowLevelKeyboardProc, NULL, 0); - atexit([] () -> void { + atexit([]() -> void { if (llhook) UnhookWindowsHookEx(llhook); }); @@ -920,10 +913,10 @@ main(int argc, char *argv[]) plat_pause(0); cpu_thread_running = true; - main_thread = new std::thread(main_thread_fn); + main_thread = new std::thread(main_thread_fn); }); - const auto ret = app.exec(); + const auto ret = app.exec(); cpu_thread_run = 0; main_thread->join(); pc_close(nullptr); diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index e41f36c57..1dfae0920 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -40,7 +40,7 @@ extern "C" { #include <86box/plat.h> #include <86box/ui.h> #ifdef DISCORD -# include <86box/discord.h> +# include <86box/discord.h> #endif #include <86box/device.h> #include <86box/video.h> @@ -124,8 +124,8 @@ void qt_set_sequence_auto_mnemonic(bool b); #endif #if defined Q_OS_UNIX && !defined Q_OS_HAIKU && !defined Q_OS_MACOS -#include -#include "x11_util.h" +# include +# include "x11_util.h" #endif #ifdef Q_OS_MACOS @@ -143,7 +143,7 @@ namespace IOKit { # include "be_keyboard.hpp" extern MainWindow *main_window; -QShortcut *windowedShortcut; +QShortcut *windowedShortcut; filter_result keyb_filter(BMessage *message, BHandler **target, BMessageFilter *filter) @@ -191,8 +191,8 @@ MainWindow::MainWindow(QWidget *parent) ui->stackedWidget->setMouseTracking(true); statusBar()->setVisible(!hide_status_bar); - auto hertz_label = new QLabel; - QTimer* frameRateTimer = new QTimer(this); + auto hertz_label = new QLabel; + QTimer *frameRateTimer = new QTimer(this); frameRateTimer->setInterval(1000); frameRateTimer->setSingleShot(false); connect(frameRateTimer, &QTimer::timeout, [hertz_label] { @@ -205,14 +205,14 @@ MainWindow::MainWindow(QWidget *parent) statusBar()->addPermanentWidget(hertz_label); frameRateTimer->start(1000); - num_icon = QIcon(":/settings/qt/icons/num_lock_on.ico"); - num_icon_off = QIcon(":/settings/qt/icons/num_lock_off.ico"); - scroll_icon = QIcon(":/settings/qt/icons/scroll_lock_on.ico"); + num_icon = QIcon(":/settings/qt/icons/num_lock_on.ico"); + num_icon_off = QIcon(":/settings/qt/icons/num_lock_off.ico"); + scroll_icon = QIcon(":/settings/qt/icons/scroll_lock_on.ico"); scroll_icon_off = QIcon(":/settings/qt/icons/scroll_lock_off.ico"); - caps_icon = QIcon(":/settings/qt/icons/caps_lock_on.ico"); - caps_icon_off = QIcon(":/settings/qt/icons/caps_lock_off.ico"); - kana_icon = QIcon(":/settings/qt/icons/kana_lock_on.ico"); - kana_icon_off = QIcon(":/settings/qt/icons/kana_lock_off.ico"); + caps_icon = QIcon(":/settings/qt/icons/caps_lock_on.ico"); + caps_icon_off = QIcon(":/settings/qt/icons/caps_lock_off.ico"); + kana_icon = QIcon(":/settings/qt/icons/kana_lock_on.ico"); + kana_icon_off = QIcon(":/settings/qt/icons/kana_lock_off.ico"); num_label = new QLabel; num_label->setPixmap(num_icon_off.pixmap(QSize(16, 16))); @@ -234,10 +234,10 @@ MainWindow::MainWindow(QWidget *parent) kana_label->setToolTip(QShortcut::tr("Kana Lock")); statusBar()->addPermanentWidget(kana_label); - QTimer* ledKeyboardTimer = new QTimer(this); + QTimer *ledKeyboardTimer = new QTimer(this); ledKeyboardTimer->setTimerType(Qt::CoarseTimer); ledKeyboardTimer->setInterval(1); - connect(ledKeyboardTimer, &QTimer::timeout, this, [this] () { + connect(ledKeyboardTimer, &QTimer::timeout, this, [this]() { uint8_t caps, num, scroll, kana; keyboard_get_states(&caps, &num, &scroll, &kana); @@ -246,12 +246,10 @@ MainWindow::MainWindow(QWidget *parent) if (caps_label->isVisible()) caps_label->setPixmap(caps ? this->caps_icon.pixmap(QSize(16, 16)) : this->caps_icon_off.pixmap(QSize(16, 16))); if (scroll_label->isVisible()) - scroll_label->setPixmap(scroll ? this->scroll_icon.pixmap(QSize(16, 16)) : - this->scroll_icon_off.pixmap(QSize(16, 16))); + scroll_label->setPixmap(scroll ? this->scroll_icon.pixmap(QSize(16, 16)) : this->scroll_icon_off.pixmap(QSize(16, 16))); if (kana_label->isVisible()) - kana_label->setPixmap(kana ? this->kana_icon.pixmap(QSize(16, 16)) : - this->kana_icon_off.pixmap(QSize(16, 16))); + kana_label->setPixmap(kana ? this->kana_icon.pixmap(QSize(16, 16)) : this->kana_icon_off.pixmap(QSize(16, 16))); }); ledKeyboardTimer->start(); @@ -285,10 +283,8 @@ MainWindow::MainWindow(QWidget *parent) num_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); scroll_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); caps_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); - int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && - (keyboard_type == KEYBOARD_TYPE_AX); - int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) && - !machine_has_bus(machine, MACHINE_BUS_PS2_PORTS); + int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && (keyboard_type == KEYBOARD_TYPE_AX); + int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) && !machine_has_bus(machine, MACHINE_BUS_PS2_PORTS); kana_label->setVisible(ext_ax_kbd || int_ax_kbd); while (QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); @@ -300,7 +296,10 @@ MainWindow::MainWindow(QWidget *parent) bool enable_comp_option = false; for (int i = 0; i < MONITORS_NUM; i++) { - if (monitors[i].mon_composite) { enable_comp_option = true; break; } + if (monitors[i].mon_composite) { + enable_comp_option = true; + break; + } } ui->actionCGA_composite_settings->setEnabled(enable_comp_option); @@ -398,8 +397,7 @@ MainWindow::MainWindow(QWidget *parent) if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) { w = static_cast(w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)); - const int modifiedHeight = - static_cast(h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)) + const int modifiedHeight = static_cast(h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)) + menuBar()->height() + (statusBar()->height() * !hide_status_bar) + (ui->toolBar->height() * !hide_tool_bar); @@ -576,17 +574,27 @@ MainWindow::MainWindow(QWidget *parent) actGroup->addAction(ui->action_6x_2); actGroup->addAction(ui->action_7x_2); actGroup->addAction(ui->action_8x_2); - connect(actGroup, &QActionGroup::triggered, this, [this](QAction* action) { - if (action == ui->action_0_5x_2) video_gl_input_scale = 0.5; - if (action == ui->action_1x_2) video_gl_input_scale = 1; - if (action == ui->action1_5x_2) video_gl_input_scale = 1.5; - if (action == ui->action_2x_2) video_gl_input_scale = 2; - if (action == ui->action_3x_2) video_gl_input_scale = 3; - if (action == ui->action_4x_2) video_gl_input_scale = 4; - if (action == ui->action_5x_2) video_gl_input_scale = 5; - if (action == ui->action_6x_2) video_gl_input_scale = 6; - if (action == ui->action_7x_2) video_gl_input_scale = 7; - if (action == ui->action_8x_2) video_gl_input_scale = 8; + connect(actGroup, &QActionGroup::triggered, this, [this](QAction *action) { + if (action == ui->action_0_5x_2) + video_gl_input_scale = 0.5; + if (action == ui->action_1x_2) + video_gl_input_scale = 1; + if (action == ui->action1_5x_2) + video_gl_input_scale = 1.5; + if (action == ui->action_2x_2) + video_gl_input_scale = 2; + if (action == ui->action_3x_2) + video_gl_input_scale = 3; + if (action == ui->action_4x_2) + video_gl_input_scale = 4; + if (action == ui->action_5x_2) + video_gl_input_scale = 5; + if (action == ui->action_6x_2) + video_gl_input_scale = 6; + if (action == ui->action_7x_2) + video_gl_input_scale = 7; + if (action == ui->action_8x_2) + video_gl_input_scale = 8; }); switch (scale) { @@ -697,12 +705,17 @@ MainWindow::MainWindow(QWidget *parent) actGroup->addAction(ui->action_Square_pixels_keep_ratio_gl); actGroup->addAction(ui->action_Integer_scale_gl); actGroup->addAction(ui->action4_3_Integer_scale_gl); - connect(actGroup, &QActionGroup::triggered, this, [this](QAction* action) { - if (action == ui->action_Full_screen_stretch_gl) video_gl_input_scale_mode = FULLSCR_SCALE_FULL; - if (action == ui->action_4_3_gl) video_gl_input_scale_mode = FULLSCR_SCALE_43; - if (action == ui->action_Square_pixels_keep_ratio_gl) video_gl_input_scale_mode = FULLSCR_SCALE_KEEPRATIO; - if (action == ui->action_Integer_scale_gl) video_gl_input_scale_mode = FULLSCR_SCALE_INT; - if (action == ui->action4_3_Integer_scale_gl) video_gl_input_scale_mode = FULLSCR_SCALE_INT43; + connect(actGroup, &QActionGroup::triggered, this, [this](QAction *action) { + if (action == ui->action_Full_screen_stretch_gl) + video_gl_input_scale_mode = FULLSCR_SCALE_FULL; + if (action == ui->action_4_3_gl) + video_gl_input_scale_mode = FULLSCR_SCALE_43; + if (action == ui->action_Square_pixels_keep_ratio_gl) + video_gl_input_scale_mode = FULLSCR_SCALE_KEEPRATIO; + if (action == ui->action_Integer_scale_gl) + video_gl_input_scale_mode = FULLSCR_SCALE_INT; + if (action == ui->action4_3_Integer_scale_gl) + video_gl_input_scale_mode = FULLSCR_SCALE_INT43; }); switch (video_grayscale) { default: @@ -770,7 +783,7 @@ MainWindow::MainWindow(QWidget *parent) video_setblit(qt_blit); if (start_in_fullscreen) { - connect(ui->stackedWidget, &RendererStack::blitToRenderer, this, [this] () { + connect(ui->stackedWidget, &RendererStack::blitToRenderer, this, [this]() { if (start_in_fullscreen) { QTimer::singleShot(100, ui->actionFullscreen, &QAction::trigger); start_in_fullscreen = 0; @@ -820,9 +833,9 @@ MainWindow::MainWindow(QWidget *parent) setContextMenuPolicy(Qt::PreventContextMenu); /* Remove default Shift+F10 handler, which unfocuses keyboard input even with no context menu. */ #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - connect(new QShortcut(QKeySequence(Qt::SHIFT | Qt::Key_F10), this), &QShortcut::activated, this, [](){}); + connect(new QShortcut(QKeySequence(Qt::SHIFT | Qt::Key_F10), this), &QShortcut::activated, this, []() {}); #else - connect(new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F10), this), &QShortcut::activated, this, [](){}); + connect(new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F10), this), &QShortcut::activated, this, []() {}); #endif connect(this, &MainWindow::initRendererMonitor, this, &MainWindow::initRendererMonitorSlot); @@ -880,18 +893,19 @@ MainWindow::MainWindow(QWidget *parent) else # endif # ifdef WAYLAND - if (QApplication::platformName().contains("wayland")) + if (QApplication::platformName().contains("wayland")) xkbcommon_wl_init(); else # endif - {} + { + } #endif #if defined Q_OS_UNIX && !defined Q_OS_MACOS && !defined Q_OS_HAIKU if (QApplication::platformName().contains("xcb")) { QTimer::singleShot(0, this, [this] { auto whandle = windowHandle(); - if (! whandle) { + if (!whandle) { qWarning() << "No window handle"; } else { QPlatformWindow *window = whandle->handle(); @@ -901,7 +915,7 @@ MainWindow::MainWindow(QWidget *parent) } #endif - updateShortcuts(); + updateShortcuts(); } void @@ -914,7 +928,7 @@ MainWindow::closeEvent(QCloseEvent *event) if (confirm_exit && confirm_exit_cmdl && cpu_thread_run) { QMessageBox questionbox(QMessageBox::Icon::Question, "86Box", tr("Are you sure you want to exit 86Box?"), QMessageBox::Yes | QMessageBox::No, this); - auto chkbox = new QCheckBox(tr("Don't show this message again")); + auto chkbox = new QCheckBox(tr("Don't show this message again")); questionbox.setCheckBox(chkbox); chkbox->setChecked(!confirm_exit); @@ -967,57 +981,57 @@ MainWindow::closeEvent(QCloseEvent *event) event->accept(); } - -void MainWindow::updateShortcuts() +void +MainWindow::updateShortcuts() { - /* - Update menu shortcuts from accelerator table - - Note that these only work in windowed mode. If you add any new shortcuts, - you have to go duplicate them in MainWindow::eventFilter() - */ - - // First we need to wipe all existing accelerators, otherwise Qt will - // run into conflicts with old ones. - ui->actionTake_screenshot->setShortcut(QKeySequence()); - ui->actionCtrl_Alt_Del->setShortcut(QKeySequence()); - ui->actionCtrl_Alt_Esc->setShortcut(QKeySequence()); - ui->actionHard_Reset->setShortcut(QKeySequence()); - ui->actionPause->setShortcut(QKeySequence()); - ui->actionMute_Unmute->setShortcut(QKeySequence()); - - int accID; - QKeySequence seq; - - accID = FindAccelerator("screenshot"); - seq = QKeySequence::fromString(acc_keys[accID].seq); - ui->actionTake_screenshot->setShortcut(seq); - - accID = FindAccelerator("send_ctrl_alt_del"); - seq = QKeySequence::fromString(acc_keys[accID].seq); - ui->actionCtrl_Alt_Del->setShortcut(seq); - - accID = FindAccelerator("send_ctrl_alt_esc"); - seq = QKeySequence::fromString(acc_keys[accID].seq); - ui->actionCtrl_Alt_Esc->setShortcut(seq); - - accID = FindAccelerator("hard_reset"); - seq = QKeySequence::fromString(acc_keys[accID].seq); - ui->actionHard_Reset->setShortcut(seq); - - accID = FindAccelerator("fullscreen"); - seq = QKeySequence::fromString(acc_keys[accID].seq); - ui->actionFullscreen->setShortcut(seq); - - accID = FindAccelerator("pause"); - seq = QKeySequence::fromString(acc_keys[accID].seq); - ui->actionPause->setShortcut(seq); - - accID = FindAccelerator("mute"); - seq = QKeySequence::fromString(acc_keys[accID].seq); - ui->actionMute_Unmute->setShortcut(seq); + /* + Update menu shortcuts from accelerator table + + Note that these only work in windowed mode. If you add any new shortcuts, + you have to go duplicate them in MainWindow::eventFilter() + */ + + // First we need to wipe all existing accelerators, otherwise Qt will + // run into conflicts with old ones. + ui->actionTake_screenshot->setShortcut(QKeySequence()); + ui->actionCtrl_Alt_Del->setShortcut(QKeySequence()); + ui->actionCtrl_Alt_Esc->setShortcut(QKeySequence()); + ui->actionHard_Reset->setShortcut(QKeySequence()); + ui->actionPause->setShortcut(QKeySequence()); + ui->actionMute_Unmute->setShortcut(QKeySequence()); + + int accID; + QKeySequence seq; + + accID = FindAccelerator("screenshot"); + seq = QKeySequence::fromString(acc_keys[accID].seq); + ui->actionTake_screenshot->setShortcut(seq); + + accID = FindAccelerator("send_ctrl_alt_del"); + seq = QKeySequence::fromString(acc_keys[accID].seq); + ui->actionCtrl_Alt_Del->setShortcut(seq); + + accID = FindAccelerator("send_ctrl_alt_esc"); + seq = QKeySequence::fromString(acc_keys[accID].seq); + ui->actionCtrl_Alt_Esc->setShortcut(seq); + + accID = FindAccelerator("hard_reset"); + seq = QKeySequence::fromString(acc_keys[accID].seq); + ui->actionHard_Reset->setShortcut(seq); + + accID = FindAccelerator("fullscreen"); + seq = QKeySequence::fromString(acc_keys[accID].seq); + ui->actionFullscreen->setShortcut(seq); + + accID = FindAccelerator("pause"); + seq = QKeySequence::fromString(acc_keys[accID].seq); + ui->actionPause->setShortcut(seq); + + accID = FindAccelerator("mute"); + seq = QKeySequence::fromString(acc_keys[accID].seq); + ui->actionMute_Unmute->setShortcut(seq); } - + void MainWindow::resizeEvent(QResizeEvent *event) { @@ -1031,24 +1045,26 @@ MainWindow::resizeEvent(QResizeEvent *event) int newY = pos().y(); if (((frameGeometry().x() + event->size().width() + 1) > util::screenOfWidget(this)->availableGeometry().right())) { - //move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y()); + // move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y()); newX = util::screenOfWidget(this)->availableGeometry().right() - frameGeometry().width() - 1; - if (newX < 1) newX = 1; + if (newX < 1) + newX = 1; } if (((frameGeometry().y() + event->size().height() + 1) > util::screenOfWidget(this)->availableGeometry().bottom())) { newY = util::screenOfWidget(this)->availableGeometry().bottom() - frameGeometry().height() - 1; - if (newY < 1) newY = 1; + if (newY < 1) + newY = 1; } move(newX, newY); -#endif +#endif /*MOVE_WINDOW*/ } void MainWindow::initRendererMonitorSlot(int monitor_index) { auto &secondaryRenderer = this->renderers[monitor_index]; - secondaryRenderer = std::make_unique(nullptr, monitor_index); + secondaryRenderer = std::make_unique(nullptr, monitor_index); if (secondaryRenderer) { connect(secondaryRenderer.get(), &RendererStack::rendererChanged, this, [this, monitor_index] { this->renderers[monitor_index]->show(); @@ -1083,7 +1099,7 @@ MainWindow::initRendererMonitorSlot(int monitor_index) if (monitor_settings[monitor_index].mon_window_maximized) { if (renderers[monitor_index]) renderers[monitor_index]->onResize(renderers[monitor_index]->width(), - renderers[monitor_index]->height()); + renderers[monitor_index]->height()); device_force_redraw(); } @@ -1258,7 +1274,7 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode) # ifdef EVDEV_KEYBOARD_HPP keycode = evdev_translate(keycode - 8); # else - keycode = 0; + keycode = 0; # endif #endif @@ -1277,8 +1293,8 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode) } break; - case 0x80 ... 0xff: /* regular break codes */ - case 0x10b: /* Microsoft scroll up normal */ + case 0x80 ... 0xff: /* regular break codes */ + case 0x10b: /* Microsoft scroll up normal */ case 0x180 ... 0x1ff: /* E0 break codes (including Microsoft scroll down normal) */ /* This key uses a break code as make. Send it manually, only on press. */ if (down && (mouse_capture || !kbd_req_capture || video_fullscreen)) { @@ -1293,7 +1309,7 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode) keycode = 0x38; /* map to Left Alt */ break; - case 0x137: /* Print Screen */ + case 0x137: /* Print Screen */ if (keyboard_recv_ui(0x38) || keyboard_recv_ui(0x138)) { /* Alt+ */ keycode = 0x54; } else if (down) { @@ -1304,7 +1320,7 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode) } break; - case 0x145: /* Pause */ + case 0x145: /* Pause */ if (keyboard_recv_ui(0x1d) || keyboard_recv_ui(0x11d)) { /* Ctrl+ */ keycode = 0x146; } else { @@ -1322,15 +1338,15 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode) // that's followed up with "(really?)". It's the only way to distinguish // left and right modifiers with Qt 6 on macOS, so let's just roll with it. static std::unordered_map mac_modifiers_to_xt = { - {NX_DEVICELCTLKEYMASK, 0x1D }, - { NX_DEVICELSHIFTKEYMASK, 0x2A }, - { NX_DEVICERSHIFTKEYMASK, 0x36 }, - { NX_DEVICELCMDKEYMASK, 0x15B}, - { NX_DEVICERCMDKEYMASK, 0x15C}, - { NX_DEVICELALTKEYMASK, 0x38 }, - { NX_DEVICERALTKEYMASK, 0x138}, - { NX_DEVICE_ALPHASHIFT_STATELESS_MASK, 0x3A }, - { NX_DEVICERCTLKEYMASK, 0x11D}, + { NX_DEVICELCTLKEYMASK, 0x1D }, + { NX_DEVICELSHIFTKEYMASK, 0x2A }, + { NX_DEVICERSHIFTKEYMASK, 0x36 }, + { NX_DEVICELCMDKEYMASK, 0x15B }, + { NX_DEVICERCMDKEYMASK, 0x15C }, + { NX_DEVICELALTKEYMASK, 0x38 }, + { NX_DEVICERALTKEYMASK, 0x138 }, + { NX_DEVICE_ALPHASHIFT_STATELESS_MASK, 0x3A }, + { NX_DEVICERCTLKEYMASK, 0x11D }, }; static bool mac_iso_swap = false; @@ -1391,45 +1407,44 @@ MainWindow::processMacKeyboardInput(bool down, const QKeyEvent *event) - Romanian third level ANSI_Grave is unknown - Russian clusters <>, plusminus and paragraph into a four-level ANSI_Grave, with the aforementioned `~ on ISO_Section */ auto key = event->key(); - if ((nvk == 0x32) && ( /* system reports ANSI_Grave for ISO_Section keys: */ - (key == Qt::Key_Less) || (key == Qt::Key_Greater) || /* Croatian, French, German, Icelandic, Italian, Norwegian, Portuguese, Spanish, Spanish Latin America, Turkish Q */ - (key == Qt::Key_Ugrave) || /* French Canadian */ - (key == Qt::Key_Icircumflex) || /* Romanian */ - (key == Qt::Key_Iacute) || /* Hungarian */ - (key == Qt::Key_BracketLeft) || (key == Qt::Key_BracketRight) || /* Russian upper two levels */ - (key == Qt::Key_W) /* Turkish F */ - )) + if ((nvk == 0x32) && ( /* system reports ANSI_Grave for ISO_Section keys: */ + (key == Qt::Key_Less) || (key == Qt::Key_Greater) || /* Croatian, French, German, Icelandic, Italian, Norwegian, Portuguese, Spanish, Spanish Latin America, Turkish Q */ + (key == Qt::Key_Ugrave) || /* French Canadian */ + (key == Qt::Key_Icircumflex) || /* Romanian */ + (key == Qt::Key_Iacute) || /* Hungarian */ + (key == Qt::Key_BracketLeft) || (key == Qt::Key_BracketRight) || /* Russian upper two levels */ + (key == Qt::Key_W) /* Turkish F */ + )) mac_iso_swap = true; - else if ((nvk == 0x0a) && ( /* system reports ISO_Section for ANSI_Grave keys: */ - (key == Qt::Key_paragraph) || (key == Qt::Key_plusminus) || /* Arabic, British, Bulgarian, Danish shifted, Dutch, Greek, Hebrew, Hungarian shifted, International English, Norwegian shifted, Portuguese, Russian lower two levels, Swiss unshifted, Swedish unshifted, Turkish F */ - (key == Qt::Key_At) || (key == Qt::Key_NumberSign) || /* Belgian, French */ - (key == Qt::Key_Apostrophe) || /* Brazilian unshifted */ - (key == Qt::Key_QuoteDbl) || /* Brazilian shifted, Turkish Q unshifted */ - (key == Qt::Key_QuoteLeft) || /* Croatian (right quote unknown) */ - (key == Qt::Key_Dollar) || /* Danish unshifted */ - (key == Qt::Key_AsciiCircum) || (key == 0x1ffffff) || /* German unshifted (0x1ffffff according to one tester), Polish unshifted */ - (key == Qt::Key_degree) || /* German shifted, Icelandic unshifted, Spanish Latin America shifted, Swiss shifted, Swedish shifted */ - (key == Qt::Key_0) || /* Hungarian unshifted */ - (key == Qt::Key_diaeresis) || /* Icelandic shifted */ - (key == Qt::Key_acute) || /* Norwegian unshifted */ - (key == Qt::Key_Asterisk) || /* Polish shifted */ - (key == Qt::Key_masculine) || (key == Qt::Key_ordfeminine) || /* Spanish (masculine unconfirmed) */ - (key == Qt::Key_Eacute) || /* Turkish Q shifted */ - (key == Qt::Key_Slash) /* French Canadian unshifted, Ukrainian shifted */ - )) + else if ((nvk == 0x0a) && ( /* system reports ISO_Section for ANSI_Grave keys: */ + (key == Qt::Key_paragraph) || (key == Qt::Key_plusminus) || /* Arabic, British, Bulgarian, Danish shifted, Dutch, Greek, Hebrew, Hungarian shifted, International English, Norwegian shifted, Portuguese, Russian lower two levels, Swiss unshifted, Swedish unshifted, Turkish F */ + (key == Qt::Key_At) || (key == Qt::Key_NumberSign) || /* Belgian, French */ + (key == Qt::Key_Apostrophe) || /* Brazilian unshifted */ + (key == Qt::Key_QuoteDbl) || /* Brazilian shifted, Turkish Q unshifted */ + (key == Qt::Key_QuoteLeft) || /* Croatian (right quote unknown) */ + (key == Qt::Key_Dollar) || /* Danish unshifted */ + (key == Qt::Key_AsciiCircum) || (key == 0x1ffffff) || /* German unshifted (0x1ffffff according to one tester), Polish unshifted */ + (key == Qt::Key_degree) || /* German shifted, Icelandic unshifted, Spanish Latin America shifted, Swiss shifted, Swedish shifted */ + (key == Qt::Key_0) || /* Hungarian unshifted */ + (key == Qt::Key_diaeresis) || /* Icelandic shifted */ + (key == Qt::Key_acute) || /* Norwegian unshifted */ + (key == Qt::Key_Asterisk) || /* Polish shifted */ + (key == Qt::Key_masculine) || (key == Qt::Key_ordfeminine) || /* Spanish (masculine unconfirmed) */ + (key == Qt::Key_Eacute) || /* Turkish Q shifted */ + (key == Qt::Key_Slash) /* French Canadian unshifted, Ukrainian shifted */ + )) mac_iso_swap = true; -#if 0 +# if 0 if (down) { QMessageBox questionbox(QMessageBox::Icon::Information, QString("Mac key swap test"), QString("nativeVirtualKey 0x%1\nnativeScanCode 0x%2\nkey 0x%3\nmac_iso_swap %4").arg(nvk, 0, 16).arg(event->nativeScanCode(), 0, 16).arg(key, 0, 16).arg(mac_iso_swap ? "yes" : "no"), QMessageBox::Ok, this); questionbox.exec(); } -#endif +# endif if (mac_iso_swap) nvk = (nvk == 0x0a) ? 0x32 : 0x0a; } // Special case for command + forward delete to send insert. - if ((event->nativeModifiers() & NSEventModifierFlagCommand) && - ((event->nativeVirtualKey() == nvk_Delete) || event->key() == Qt::Key_Delete)) { + if ((event->nativeModifiers() & NSEventModifierFlagCommand) && ((event->nativeVirtualKey() == nvk_Delete) || event->key() == Qt::Key_Delete)) { nvk = nvk_Insert; // Qt::Key_Help according to event->key() } @@ -1461,7 +1476,7 @@ MainWindow::on_actionFullscreen_triggered() ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); showFullScreen(); } - fs_on_signal = false; + fs_on_signal = false; fs_off_signal = false; ui->stackedWidget->onResize(width(), height()); } @@ -1482,85 +1497,71 @@ MainWindow::getTitle(wchar_t *title) } } - // Helper to find an accelerator key and return it's sequence // TODO: Is there a more central place to put this? QKeySequence MainWindow::FindAcceleratorSeq(const char *name) { - int accID = FindAccelerator(name); - if(accID == -1) - return false; - - return(QKeySequence::fromString(acc_keys[accID].seq)); + int accID = FindAccelerator(name); + if (accID == -1) + return false; + + return (QKeySequence::fromString(acc_keys[accID].seq)); } bool MainWindow::eventFilter(QObject *receiver, QEvent *event) { - // Detect shortcuts when menubar is hidden - // TODO: Could this be simplified by proxying the event and manually - // shoving it into the menubar? - if (event->type() == QEvent::KeyPress) - { - this->keyPressEvent((QKeyEvent *) event); + // Detect shortcuts when menubar is hidden + // TODO: Could this be simplified by proxying the event and manually + // shoving it into the menubar? + if (event->type() == QEvent::KeyPress) { + this->keyPressEvent((QKeyEvent *) event); - // We check for mouse release even if we aren't fullscreen, - // because it's not a menu accelerator. - if (event->type() == QEvent::KeyPress) - { - QKeyEvent *ke = (QKeyEvent *) event; - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("release_mouse") || - (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("release_mouse")) - { - plat_mouse_capture(0); - } - } + // We check for mouse release even if we aren't fullscreen, + // because it's not a menu accelerator. + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *) event; + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("release_mouse") || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("release_mouse")) { + plat_mouse_capture(0); + } + } - if (event->type() == QEvent::KeyPress && video_fullscreen != 0) - { - QKeyEvent *ke = (QKeyEvent *) event; - - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("screenshot") - || (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("screenshot")) - { - ui->actionTake_screenshot->trigger(); - } - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("fullscreen") - || (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("fullscreen")) - { - ui->actionFullscreen->trigger(); - } - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("hard_reset") - || (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("hard_reset")) - { - ui->actionHard_Reset->trigger(); - } - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_del") - || (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_del")) - { - ui->actionCtrl_Alt_Del->trigger(); - } - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_esc") - || (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_esc")) - { - ui->actionCtrl_Alt_Esc->trigger(); - } - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("pause") - || (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("pause")) - { - ui->actionPause->trigger(); - } - if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("mute") - || (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("mute")) - { - ui->actionMute_Unmute->trigger(); - } + if (event->type() == QEvent::KeyPress && video_fullscreen != 0) { + QKeyEvent *ke = (QKeyEvent *) event; - return true; - } - } - + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("screenshot") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("screenshot")) { + ui->actionTake_screenshot->trigger(); + } + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("fullscreen") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("fullscreen")) { + ui->actionFullscreen->trigger(); + } + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("hard_reset") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("hard_reset")) { + ui->actionHard_Reset->trigger(); + } + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_del") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_del")) { + ui->actionCtrl_Alt_Del->trigger(); + } + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_esc") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_esc")) { + ui->actionCtrl_Alt_Esc->trigger(); + } + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("pause") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("pause")) { + ui->actionPause->trigger(); + } + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("mute") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("mute")) { + ui->actionMute_Unmute->trigger(); + } + + return true; + } + } if (!dopause && (!kbd_req_capture || mouse_capture)) { if (event->type() == QEvent::Shortcut) { @@ -1571,8 +1572,8 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event) } } if (event->type() == QEvent::KeyPress) { - event->accept(); - + event->accept(); + return true; } if (event->type() == QEvent::KeyRelease) { @@ -1586,7 +1587,7 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event) static auto curdopause = dopause; if (event->type() == QEvent::WindowBlocked) { window_blocked = true; - curdopause = dopause; + curdopause = dopause; plat_pause(isNonPause ? dopause : (isShowMessage ? 2 : 1)); emit setMouseCapture(false); releaseKeyboard(); @@ -1595,7 +1596,7 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event) plat_pause(curdopause); } } - + return QMainWindow::eventFilter(receiver, event); } @@ -1615,15 +1616,16 @@ MainWindow::refreshMediaMenu() caps_label->setToolTip(QShortcut::tr("Caps Lock")); caps_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); kana_label->setToolTip(QShortcut::tr("Kana Lock")); - int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && - (keyboard_type == KEYBOARD_TYPE_AX); - int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) && - !machine_has_bus(machine, MACHINE_BUS_PS2_PORTS); + int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && (keyboard_type == KEYBOARD_TYPE_AX); + int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) && !machine_has_bus(machine, MACHINE_BUS_PS2_PORTS); kana_label->setVisible(ext_ax_kbd || int_ax_kbd); bool enable_comp_option = false; for (int i = 0; i < MONITORS_NUM; i++) { - if (monitors[i].mon_composite) { enable_comp_option = true; break; } + if (monitors[i].mon_composite) { + enable_comp_option = true; + break; + } } ui->actionCGA_composite_settings->setEnabled(enable_comp_option); @@ -1635,12 +1637,11 @@ MainWindow::showMessage(int flags, const QString &header, const QString &message if (QThread::currentThread() == this->thread()) { if (!cpu_thread_running) { showMessageForNonQtThread(flags, header, message, richText, nullptr); - } - else + } else showMessage_(flags, header, message, richText); } else { std::atomic_bool done = false; - emit showMessageForNonQtThread(flags, header, message, richText, &done); + emit showMessageForNonQtThread(flags, header, message, richText, &done); while (!done) { QThread::msleep(1); } @@ -1681,7 +1682,7 @@ MainWindow::keyPressEvent(QKeyEvent *event) processKeyboardInput(true, event->nativeScanCode()); #endif } - + event->accept(); } @@ -1724,13 +1725,13 @@ MainWindow::getRenderWidgetSize() void MainWindow::focusInEvent(QFocusEvent *event) { - //this->grabKeyboard(); + // this->grabKeyboard(); } void MainWindow::focusOutEvent(QFocusEvent *event) { - //this->releaseKeyboard(); + // this->releaseKeyboard(); } void @@ -2209,7 +2210,7 @@ void MainWindow::on_actionTake_screenshot_triggered() { startblit(); - for (auto & monitor : monitors) + for (auto &monitor : monitors) ++monitor.mon_screenshots; endblit(); device_force_redraw(); @@ -2240,16 +2241,13 @@ MainWindow::setSendKeyboardInput(bool enabled) void MainWindow::updateUiPauseState() { - const auto pause_icon = dopause ? QIcon(":/menuicons/qt/icons/run.ico") : - QIcon(":/menuicons/qt/icons/pause.ico"); - const auto tooltip_text = dopause ? QString(tr("Resume execution")) : - QString(tr("Pause execution")); - const auto menu_text = dopause ? QString(tr("Re&sume")) : - QString(tr("&Pause")); + const auto pause_icon = dopause ? QIcon(":/menuicons/qt/icons/run.ico") : QIcon(":/menuicons/qt/icons/pause.ico"); + const auto tooltip_text = dopause ? QString(tr("Resume execution")) : QString(tr("Pause execution")); + const auto menu_text = dopause ? QString(tr("Re&sume")) : QString(tr("&Pause")); ui->actionPause->setIcon(pause_icon); ui->actionPause->setToolTip(tooltip_text); ui->actionPause->setText(menu_text); - emit vmmRunningStateChanged(static_cast(window_blocked ? (dopause ? VMManagerProtocol::RunningState::PausedWaiting : VMManagerProtocol::RunningState::RunningWaiting) : (VMManagerProtocol::RunningState)dopause)); + emit vmmRunningStateChanged(static_cast(window_blocked ? (dopause ? VMManagerProtocol::RunningState::PausedWaiting : VMManagerProtocol::RunningState::RunningWaiting) : (VMManagerProtocol::RunningState) dopause)); } void @@ -2345,10 +2343,11 @@ MainWindow::on_actionRenderer_options_triggered() } } } - } else for (int i = 1; i < MONITORS_NUM; i++) { - if (renderers[i] && renderers[i]->hasOptions()) - renderers[i]->reloadOptions(); - } + } else + for (int i = 1; i < MONITORS_NUM; i++) { + if (renderers[i] && renderers[i]->hasOptions()) + renderers[i]->reloadOptions(); + } } else if (reload_renderers && ui->stackedWidget->reloadRendererOption()) { reload_renderers = false; ui->stackedWidget->switchRenderer(static_cast(vid_api)); @@ -2437,24 +2436,28 @@ MainWindow::on_actionApply_fullscreen_stretch_mode_when_maximized_triggered(bool config_save(); } -void MainWindow::on_actionCursor_Puck_triggered() +void +MainWindow::on_actionCursor_Puck_triggered() { tablet_tool_type = 0; config_save(); } -void MainWindow::on_actionPen_triggered() +void +MainWindow::on_actionPen_triggered() { tablet_tool_type = 1; config_save(); } -void MainWindow::on_actionACPI_Shutdown_triggered() +void +MainWindow::on_actionACPI_Shutdown_triggered() { acpi_pwrbut_pressed = 1; } -void MainWindow::on_actionCGA_composite_settings_triggered() +void +MainWindow::on_actionCGA_composite_settings_triggered() { isNonPause = true; CGASettingsDialog dialog; @@ -2463,4 +2466,3 @@ void MainWindow::on_actionCGA_composite_settings_triggered() isNonPause = false; config_save(); } - diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 26585ddaf..916a254d0 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -33,16 +33,15 @@ public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); - void showMessage(int flags, const QString &header, const QString &message, bool richText); - void getTitle(wchar_t *title); - void blitToWidget(int x, int y, int w, int h, int monitor_index); - QSize getRenderWidgetSize(); - void setSendKeyboardInput(bool enabled); - void reloadAllRenderers(); - QShortcut *windowedShortcut; - QKeySequence FindAcceleratorSeq(const char *name); - - + void showMessage(int flags, const QString &header, const QString &message, bool richText); + void getTitle(wchar_t *title); + void blitToWidget(int x, int y, int w, int h, int monitor_index); + QSize getRenderWidgetSize(); + void setSendKeyboardInput(bool enabled); + void reloadAllRenderers(); + QShortcut *windowedShortcut; + QKeySequence FindAcceleratorSeq(const char *name); + std::array, 8> renderers; signals: void paint(const QImage &image); @@ -65,7 +64,7 @@ signals: void setFullscreen(bool state); void setMouseCapture(bool state); - void showMessageForNonQtThread(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done); + void showMessageForNonQtThread(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool *done); void getTitleForNonQtThread(wchar_t *title); void vmmRunningStateChanged(VMManagerProtocol::RunningState state); @@ -138,7 +137,7 @@ private slots: void on_actionRenderer_options_triggered(); void refreshMediaMenu(); - void showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done = nullptr); + void showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool *done = nullptr); void getTitle_(wchar_t *title); void on_actionMCA_devices_triggered(); @@ -178,8 +177,8 @@ private: std::unique_ptr status; std::shared_ptr mm; - void updateShortcuts(); - void processKeyboardInput(bool down, uint32_t keycode); + void updateShortcuts(); + void processKeyboardInput(bool down, uint32_t keycode); #ifdef Q_OS_MACOS uint32_t last_modifiers = 0; void processMacKeyboardInput(bool down, const QKeyEvent *event); @@ -192,24 +191,24 @@ private: bool vnc_enabled = false; /* Full screen ON and OFF signals */ - bool fs_on_signal = false; - bool fs_off_signal = false; + bool fs_on_signal = false; + bool fs_off_signal = false; /* Reload the renderers after closing renderer options dialog. */ - bool reload_renderers = false; + bool reload_renderers = false; friend class SpecifyDimensions; friend class ProgSettings; friend class RendererCommon; - friend class RendererStack; // For UI variable access by non-primary renderer windows. + friend class RendererStack; // For UI variable access by non-primary renderer windows. friend class WindowsRawInputFilter; // Needed to reload renderers on style sheet changes. QLabel *caps_label, *scroll_label, *num_label, *kana_label; - QIcon caps_icon, scroll_icon, num_icon, kana_icon; - QIcon caps_icon_off, scroll_icon_off, num_icon_off, kana_icon_off; + QIcon caps_icon, scroll_icon, num_icon, kana_icon; + QIcon caps_icon_off, scroll_icon_off, num_icon_off, kana_icon_off; - bool isShowMessage = false; - bool isNonPause = false; + bool isShowMessage = false; + bool isNonPause = false; bool window_blocked = false; }; diff --git a/src/qt/qt_mediahistorymanager.cpp b/src/qt/qt_mediahistorymanager.cpp index a7892af31..c75c05f9b 100644 --- a/src/qt/qt_mediahistorymanager.cpp +++ b/src/qt/qt_mediahistorymanager.cpp @@ -19,7 +19,7 @@ #include #include "qt_mediahistorymanager.hpp" #ifdef Q_OS_WINDOWS -#include +# include #endif extern "C" { @@ -371,7 +371,7 @@ MediaHistoryManager::removeMissingImages(device_index_list_t &device_history) path_normalize(temp); } - QString qstr = QString::fromUtf8(temp); + QString qstr = QString::fromUtf8(temp); QFileInfo new_fi(qstr); bool file_exists = new_fi.exists(); diff --git a/src/qt/qt_mediamenu.cpp b/src/qt/qt_mediamenu.cpp index e63327fd8..75b2e2b97 100644 --- a/src/qt/qt_mediamenu.cpp +++ b/src/qt/qt_mediamenu.cpp @@ -28,10 +28,10 @@ extern "C" { #ifdef Q_OS_WINDOWS -#define BITMAP WINDOWS_BITMAP -#include -#include -#undef BITMAP +# define BITMAP WINDOWS_BITMAP +# include +# include +# undef BITMAP #endif #include #include @@ -70,7 +70,7 @@ extern "C" { std::shared_ptr MediaMenu::ptr; -static QSize pixmap_size(16, 16); +static QSize pixmap_size(16, 16); MediaMenu::MediaMenu(QWidget *parent) : QObject(parent) @@ -85,7 +85,7 @@ MediaMenu::refresh(QMenu *parentMenu) parentMenu->clear(); if (MachineStatus::hasCassette()) { - cassetteMenu = parentMenu->addMenu(""); + cassetteMenu = parentMenu->addMenu(""); QIcon img_icon = QIcon(":/settings/qt/icons/cassette_image.ico"); cassetteMenu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this]() { cassetteNewImage(); }); cassetteMenu->addSeparator(); @@ -114,7 +114,7 @@ MediaMenu::refresh(QMenu *parentMenu) cartridgeMenus.clear(); if (machine_has_cartridge(machine)) { for (int i = 0; i < 2; i++) { - auto *menu = parentMenu->addMenu(""); + auto *menu = parentMenu->addMenu(""); QIcon img_icon = QIcon(":/settings/qt/icons/cartridge_image.ico"); menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Image..."), [this, i]() { cartridgeSelectImage(i); }); menu->addSeparator(); @@ -132,9 +132,8 @@ MediaMenu::refresh(QMenu *parentMenu) floppyMenus.clear(); MachineStatus::iterateFDD([this, parentMenu](int i) { - auto *menu = parentMenu->addMenu(""); - QIcon img_icon = fdd_is_525(i) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") : - QIcon(":/settings/qt/icons/floppy_35_image.ico"); + auto *menu = parentMenu->addMenu(""); + QIcon img_icon = fdd_is_525(i) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") : QIcon(":/settings/qt/icons/floppy_35_image.ico"); menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { floppyNewImage(i); }); menu->addSeparator(); menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Existing image..."), [this, i]() { floppySelectImage(i, false); }); @@ -186,7 +185,7 @@ MediaMenu::refresh(QMenu *parentMenu) rdiskMenus.clear(); MachineStatus::iterateRDisk([this, parentMenu](int i) { - auto *menu = parentMenu->addMenu(""); + auto *menu = parentMenu->addMenu(""); QIcon img_icon = QIcon(":/settings/qt/icons/rdisk_image.ico"); menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { rdiskNewImage(i); }); menu->addSeparator(); @@ -206,7 +205,7 @@ MediaMenu::refresh(QMenu *parentMenu) moMenus.clear(); MachineStatus::iterateMO([this, parentMenu](int i) { - auto *menu = parentMenu->addMenu(""); + auto *menu = parentMenu->addMenu(""); QIcon img_icon = QIcon(":/settings/qt/icons/mo_image.ico"); menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { moNewImage(i); }); menu->addSeparator(); @@ -316,15 +315,15 @@ MediaMenu::cassetteEject() void MediaMenu::cassetteUpdateMenu() { - QString name = cassette_fname; - QFileInfo fi(cassette_fname); - const QString mode = cassette_mode; - auto childs = cassetteMenu->children(); - auto *recordMenu = dynamic_cast(childs[cassetteRecordPos]); - auto *playMenu = dynamic_cast(childs[cassettePlayPos]); - auto *rewindMenu = dynamic_cast(childs[cassetteRewindPos]); - auto *fastFwdMenu = dynamic_cast(childs[cassetteFastFwdPos]); - auto *ejectMenu = dynamic_cast(childs[cassetteEjectPos]); + QString name = cassette_fname; + QFileInfo fi(cassette_fname); + const QString mode = cassette_mode; + auto childs = cassetteMenu->children(); + auto *recordMenu = dynamic_cast(childs[cassetteRecordPos]); + auto *playMenu = dynamic_cast(childs[cassettePlayPos]); + auto *rewindMenu = dynamic_cast(childs[cassetteRewindPos]); + auto *fastFwdMenu = dynamic_cast(childs[cassetteFastFwdPos]); + auto *ejectMenu = dynamic_cast(childs[cassetteEjectPos]); recordMenu->setEnabled(!name.isEmpty()); playMenu->setEnabled(!name.isEmpty()); @@ -400,9 +399,9 @@ MediaMenu::cartridgeUpdateMenu(int i) { const QString name = cart_fns[i]; QFileInfo fi(cart_fns[i]); - auto *menu = cartridgeMenus[i]; - auto childs = menu->children(); - auto *ejectMenu = dynamic_cast(childs[cartridgeEjectPos]); + auto *menu = cartridgeMenus[i]; + auto childs = menu->children(); + auto *ejectMenu = dynamic_cast(childs[cartridgeEjectPos]); ejectMenu->setEnabled(!name.isEmpty()); ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(fi.fileName())); menu->setTitle(tr("Car&tridge %1: %2").arg(QString::number(i + 1), name.isEmpty() ? tr("(empty)") : name)); @@ -447,7 +446,8 @@ MediaMenu::floppySelectImage(int i, bool wp) tr("All files") % util::DlgFilter({ "*" }, true)); - if (!filename.isEmpty()) floppyMount(i, filename, wp); + if (!filename.isEmpty()) + floppyMount(i, filename, wp); } void @@ -525,7 +525,6 @@ MediaMenu::floppyUpdateMenu(int i) int type = fdd_get_type(i); floppyMenus[i]->setTitle(tr("&Floppy %1 (%2): %3").arg(QString::number(i + 1), fdd_getname(type), name.isEmpty() ? tr("(empty)") : name)); floppyMenus[i]->setToolTip(tr("Floppy %1 (%2): %3").arg(QString::number(i + 1), fdd_getname(type), name.isEmpty() ? tr("(empty)") : name)); - } void @@ -597,7 +596,7 @@ MediaMenu::cdromMount(int i, int dir, const QString &arg) else { filename = QFileDialog::getOpenFileName(parentWidget, QString(), QString(), - tr("CD-ROM images") % util::DlgFilter({ "iso", "cue", "mds" }) % tr("All files") % util::DlgFilter({ "*" }, true)); + tr("CD-ROM images") % util::DlgFilter({ "iso", "cue", "mds" }) % tr("All files") % util::DlgFilter({ "*" }, true)); } if (filename.isEmpty()) @@ -649,7 +648,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type) QObjectList children; QFileInfo fi; QIcon menu_icon; - const auto fn = mhm.getImageForSlot(index, slot, type); + const auto fn = mhm.getImageForSlot(index, slot, type); QString menu_item_name; @@ -691,8 +690,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type) menu = floppyMenus[index]; children = menu->children(); imageHistoryUpdatePos = dynamic_cast(children[floppyImageHistoryPos[slot]]); - menu_icon = fdd_is_525(index) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") : - QIcon(":/settings/qt/icons/floppy_35_image.ico"); + menu_icon = fdd_is_525(index) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") : QIcon(":/settings/qt/icons/floppy_35_image.ico"); if (fn.left(5) == "wp://") fi.setFile(fn.right(fn.length() - 5)); else @@ -720,7 +718,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type) #endif } else { fi.setFile(fn); - menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico"); + menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico"); menu_item_name = fn.isEmpty() ? tr("Reload previous image") : fn; } imageHistoryUpdatePos->setIcon(menu_icon); @@ -770,7 +768,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type) imageHistoryUpdatePos->setText(menu_item_name.prepend("&%1 ").arg((slot == 9) ? 0 : (slot + 1))); else #endif - imageHistoryUpdatePos->setText(menu_item_name); + imageHistoryUpdatePos->setText(menu_item_name); if (fn.left(8) == "ioctl://") imageHistoryUpdatePos->setVisible(true); @@ -788,9 +786,9 @@ MediaMenu::clearImageHistory() void MediaMenu::cdromUpdateMenu(int i) { - QString name = cdrom[i].image_path; - QString name2; - QIcon menu_icon; + QString name = cdrom[i].image_path; + QString name2; + QIcon menu_icon; if (!cdromMenus.contains(i)) return; @@ -810,17 +808,17 @@ MediaMenu::cdromUpdateMenu(int i) #else menu_item_name = tr("Host CD/DVD Drive (%1)").arg(name.right(name.length() - 8)); #endif - name2 = menu_item_name; - menu_icon = QIcon(":/settings/qt/icons/cdrom_host.ico"); + name2 = menu_item_name; + menu_icon = QIcon(":/settings/qt/icons/cdrom_host.ico"); } else { QFileInfo fi(cdrom[i].image_path); menu_item_name = name.isEmpty() ? QString() : fi.fileName(); name2 = name; if (name.isEmpty()) - menu_icon = QIcon(":/settings/qt/icons/cdrom.ico"); + menu_icon = QIcon(":/settings/qt/icons/cdrom.ico"); else - menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico"); + menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico"); } ejectMenu->setIcon(getIconWithIndicator(menu_icon, pixmap_size, QIcon::Normal, Eject)); ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(menu_item_name)); @@ -846,8 +844,8 @@ MediaMenu::cdromUpdateMenu(int i) break; } - menu->setTitle(tr("&CD-ROM %1 (%2): %3").arg(QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name2)); - menu->setToolTip(tr("CD-ROM %1 (%2): %3").arg(QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name2)); + menu->setTitle(tr("&CD-ROM %1 (%2): %3").arg(QString::number(i + 1), busName, name.isEmpty() ? tr("(empty)") : name2)); + menu->setToolTip(tr("CD-ROM %1 (%2): %3").arg(QString::number(i + 1), busName, name.isEmpty() ? tr("(empty)") : name2)); } void @@ -970,7 +968,7 @@ MediaMenu::moUpdateMenu(int i) auto *menu = moMenus[i]; auto childs = menu->children(); - auto *ejectMenu = dynamic_cast(childs[moEjectPos]); + auto *ejectMenu = dynamic_cast(childs[moEjectPos]); ejectMenu->setEnabled(!name.isEmpty()); ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(fi.fileName())); @@ -1004,7 +1002,7 @@ MediaMenu::rdiskUpdateMenu(int i) auto *menu = rdiskMenus[i]; auto childs = menu->children(); - auto *ejectMenu = dynamic_cast(childs[rdiskEjectPos]); + auto *ejectMenu = dynamic_cast(childs[rdiskEjectPos]); ejectMenu->setEnabled(!name.isEmpty()); ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(fi.fileName())); diff --git a/src/qt/qt_midi.cpp b/src/qt/qt_midi.cpp index 40fbfb460..0d1b17066 100644 --- a/src/qt/qt_midi.cpp +++ b/src/qt/qt_midi.cpp @@ -69,5 +69,4 @@ plat_midi_in_get_dev_name(int num, char *s) s[0] = ' '; s[1] = 0; } - } diff --git a/src/qt/qt_models_common.hpp b/src/qt/qt_models_common.hpp index 7e116523f..98674a68f 100644 --- a/src/qt/qt_models_common.hpp +++ b/src/qt/qt_models_common.hpp @@ -3,5 +3,5 @@ class QString; class QAbstractItemModel; namespace Models { - int AddEntry(QAbstractItemModel *model, const QString &displayRole, int userRole); +int AddEntry(QAbstractItemModel *model, const QString &displayRole, int userRole); }; diff --git a/src/qt/qt_newfloppydialog.cpp b/src/qt/qt_newfloppydialog.cpp index 6712b22f3..98078004a 100644 --- a/src/qt/qt_newfloppydialog.cpp +++ b/src/qt/qt_newfloppydialog.cpp @@ -83,7 +83,7 @@ static const disk_size_t disk_sizes[14] = { { 0, 8, 0, 0, 0, 963, 32, 2, 0, 0, 0, 0, 0 }, /* LS-120 */ { 0, 32, 0, 0, 0, 262, 56, 2, 0, 0, 0, 0, 0 } /* LS-240 */ #endif -// clang-format on + // clang-format on }; static const QStringList rpmModes = { @@ -198,7 +198,7 @@ NewFloppyDialog::onCreate() QFileInfo fi(filename); filename = (fi.isRelative() && !fi.filePath().isEmpty()) ? (usr_path + fi.filePath()) : fi.filePath(); ui->fileField->setFileName(filename); - FileType fileType; + FileType fileType; QProgressDialog progress("Creating floppy image", QString(), 0, 100, this); connect(this, &NewFloppyDialog::fileProgress, &progress, &QProgressDialog::setValue); @@ -646,8 +646,8 @@ NewFloppyDialog::createRDiskSectorImage(const QString &filename, const disk_size bool NewFloppyDialog::createMoSectorImage(const QString &filename, int8_t disk_size, FileType type, QProgressDialog &pbar) { - const mo_type_t *dp = &mo_types[disk_size]; - uint64_t total_size = 0; + const mo_type_t *dp = &mo_types[disk_size]; + uint64_t total_size = 0; uint64_t total_size2; uint32_t total_sectors = 0; uint32_t sector_bytes = 0; diff --git a/src/qt/qt_openglrenderer.cpp b/src/qt/qt_openglrenderer.cpp index c5d1d0484..dc7c22941 100644 --- a/src/qt/qt_openglrenderer.cpp +++ b/src/qt/qt_openglrenderer.cpp @@ -21,7 +21,7 @@ #include "qt_renderercommon.hpp" #include "qt_mainwindow.hpp" -extern MainWindow* main_window; +extern MainWindow *main_window; #include #include @@ -58,7 +58,7 @@ extern "C" { #include <86box/config.h> #include <86box/qt-glslp-parser.h> -char gl3_shader_file[MAX_USER_SHADERS][512]; +char gl3_shader_file[MAX_USER_SHADERS][512]; extern bool cpu_thread_running; } @@ -73,76 +73,76 @@ extern int video_vsync; extern int video_focus_dim; extern int video_refresh_rate; -const char* vertex_shader_default_tex_src = +const char *vertex_shader_default_tex_src = #ifdef __APPLE__ - "#version 150\n" + "#version 150\n" #else - "#version 130\n" + "#version 130\n" #endif - "\n" - "in vec4 VertexCoord;\n" - "in vec2 TexCoord;\n" - "\n" - "out vec2 texCoord;\n" - "\n" - "void main()\n" - "{\n" - " gl_Position = VertexCoord;\n" - " texCoord = TexCoord;\n" - "}\n"; + "\n" + "in vec4 VertexCoord;\n" + "in vec2 TexCoord;\n" + "\n" + "out vec2 texCoord;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = VertexCoord;\n" + " texCoord = TexCoord;\n" + "}\n"; -const char* fragment_shader_default_tex_src = +const char *fragment_shader_default_tex_src = #ifdef __APPLE__ - "#version 150\n" + "#version 150\n" #else - "#version 130\n" + "#version 130\n" #endif - "\n" - "in vec2 texCoord;\n" - "uniform sampler2D Texture;\n" - "\n" - "out vec4 color;" - "\n" - "void main()\n" - "{\n" - " color = texture(Texture, texCoord);\n" - " color.a = 1.0;\n" - "}\n"; + "\n" + "in vec2 texCoord;\n" + "uniform sampler2D Texture;\n" + "\n" + "out vec4 color;" + "\n" + "void main()\n" + "{\n" + " color = texture(Texture, texCoord);\n" + " color.a = 1.0;\n" + "}\n"; -const char* vertex_shader_default_color_src = +const char *vertex_shader_default_color_src = #ifdef __APPLE__ - "#version 150\n" + "#version 150\n" #else - "#version 130\n" + "#version 130\n" #endif - "\n" - "in vec4 VertexCoord;\n" - "in vec4 Color;\n" - "\n" - "out vec4 color;\n" - "\n" - "void main()\n" - "{\n" - " gl_Position = VertexCoord;\n" - " color = Color;\n" - "}\n"; + "\n" + "in vec4 VertexCoord;\n" + "in vec4 Color;\n" + "\n" + "out vec4 color;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = VertexCoord;\n" + " color = Color;\n" + "}\n"; -const char* fragment_shader_default_color_src = +const char *fragment_shader_default_color_src = #ifdef __APPLE__ - "#version 150\n" + "#version 150\n" #else - "#version 130\n" + "#version 130\n" #endif - "\n" - "in vec4 color;\n" - "\n" - "out vec4 outColor;" - "\n" - "void main()\n" - "{\n" - " outColor = color;\n" - " outColor.a = 1.0;\n" - "}\n"; + "\n" + "in vec4 color;\n" + "\n" + "out vec4 outColor;" + "\n" + "void main()\n" + "{\n" + " outColor = color;\n" + " outColor.a = 1.0;\n" + "}\n"; #ifdef ENABLE_OGL3_LOG int ogl3_do_log = ENABLE_OGL3_LOG; @@ -212,11 +212,11 @@ int OpenGLRenderer::compile_shader(GLenum shader_type, const char *prepend, const char *program, int *dst) { QRegularExpression versionRegex("^\\s*(#version\\s+\\w+)", QRegularExpression::MultilineOption); - QString progSource = QString(program); - QByteArray finalSource = nullptr; - const char *source[5]; - char version[50]; - char *version_loc = (char *) strstr(program, "#version"); + QString progSource = QString(program); + QByteArray finalSource = nullptr; + const char *source[5]; + char version[50]; + char *version_loc = (char *) strstr(program, "#version"); if (version_loc) { snprintf(version, 49, "%s\n", versionRegex.match(progSource).captured(1).toLatin1().data()); progSource.remove(versionRegex); @@ -230,7 +230,7 @@ OpenGLRenderer::compile_shader(GLenum shader_type, const char *prepend, const ch ver = 150; snprintf(version, 49, "#version %d\n", ver); } - + /* Remove parameter lines. */ progSource.remove(QRegularExpression("^\\s*#pragma parameter.*?\\n", QRegularExpression::MultilineOption)); @@ -309,27 +309,27 @@ OpenGLRenderer::find_uniforms(struct glsl_shader *glsl, int num_pass) u->orig.texture_size = get_uniform(p, "OrigTextureSize"); for (i = 0; i < glsl->num_passes; ++i) { - snprintf(s, sizeof(s) -1, "Pass%dTexture", (i + 1)); + snprintf(s, sizeof(s) - 1, "Pass%dTexture", (i + 1)); u->pass[i].texture = get_uniform(p, s); - snprintf(s, sizeof(s) -1, "Pass%dInputSize", (i + 1)); + snprintf(s, sizeof(s) - 1, "Pass%dInputSize", (i + 1)); u->pass[i].input_size = get_uniform(p, s); - snprintf(s, sizeof(s) -1, "Pass%dTextureSize", (i + 1)); + snprintf(s, sizeof(s) - 1, "Pass%dTextureSize", (i + 1)); u->pass[i].texture_size = get_uniform(p, s); - snprintf(s, sizeof(s) -1, "PassPrev%dTexture", num_pass - i); + snprintf(s, sizeof(s) - 1, "PassPrev%dTexture", num_pass - i); u->prev_pass[i].texture = get_uniform(p, s); - snprintf(s, sizeof(s) -1, "PassPrev%dInputSize", num_pass - i); + snprintf(s, sizeof(s) - 1, "PassPrev%dInputSize", num_pass - i); u->prev_pass[i].input_size = get_uniform(p, s); - snprintf(s, sizeof(s) -1, "PassPrev%dTextureSize", num_pass - i); + snprintf(s, sizeof(s) - 1, "PassPrev%dTextureSize", num_pass - i); u->prev_pass[i].texture_size = get_uniform(p, s); } u->prev[0].texture = get_uniform(p, "PrevTexture"); u->prev[0].tex_coord = get_attrib(p, "PrevTexCoord"); for (i = 1; i < MAX_PREV; ++i) { - snprintf(s, sizeof(s) -1, "Prev%dTexture", i); + snprintf(s, sizeof(s) - 1, "Prev%dTexture", i); u->prev[i].texture = get_uniform(p, s); - snprintf(s, sizeof(s) -1, "Prev%dTexCoord", i); + snprintf(s, sizeof(s) - 1, "Prev%dTexCoord", i); u->prev[i].tex_coord = get_attrib(p, s); } for (i = 0; i < MAX_PREV; ++i) @@ -653,7 +653,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f) ogl3_log("Load texture %s...\n", file); if (!load_texture(file, &tex->texture)) { - //QMessageBox::critical(main_window, tr("GLSL Error"), tr("Could not load texture: %s").arg(file)); + // QMessageBox::critical(main_window, tr("GLSL Error"), tr("Could not load texture: %s").arg(file)); main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load texture: %1").arg(file), false); ogl3_log("Could not load texture %s!\n", file); failed = 1; @@ -805,7 +805,7 @@ OpenGLRenderer::read_shader_config() for (int i = 0; i < active_shader->num_shaders; ++i) { struct glsl_shader *shader = &active_shader->shaders[i]; char *name = shader->name; - snprintf(s, sizeof(s) -1, "GL3 Shaders - %s", name); + snprintf(s, sizeof(s) - 1, "GL3 Shaders - %s", name); // shader->shader_refresh_rate = config_get_float(CFG_MACHINE, s, "shader_refresh_rate", -1); for (int j = 0; j < shader->num_parameters; ++j) { struct shader_parameter *param = &shader->parameters[j]; @@ -818,7 +818,7 @@ OpenGLRenderer::OpenGLRenderer(QWidget *parent) : QWindow((QWindow*)nullptr) , renderTimer(new QTimer(this)) { - connect(renderTimer, &QTimer::timeout, this, [this]() { this->render(); } ); + connect(renderTimer, &QTimer::timeout, this, [this]() { this->render(); }); imagebufs[0] = std::unique_ptr(new uint8_t[2048 * 2048 * 4]); imagebufs[1] = std::unique_ptr(new uint8_t[2048 * 2048 * 4]); @@ -846,8 +846,8 @@ OpenGLRenderer::OpenGLRenderer(QWidget *parent) source.setRect(0, 0, 100, 100); isInitialized = false; - isFinalized = false; - context = nullptr; + isFinalized = false; + context = nullptr; } OpenGLRenderer::~OpenGLRenderer() { finalize(); } @@ -897,9 +897,9 @@ OpenGLRenderer::initialize() glw.glEnable(GL_TEXTURE_2D); - //renderTimer->start(75); + // renderTimer->start(75); if (video_framerate != -1) { - renderTimer->start(ceilf(1000.f / (float)video_framerate)); + renderTimer->start(ceilf(1000.f / (float) video_framerate)); } scene_texture.data = NULL; @@ -1105,7 +1105,7 @@ OpenGLRenderer::initialize() emit initialized(); glw.glClearColor(0, 0, 0, 1); - + glw.glClear(GL_COLOR_BUFFER_BIT); context->swapBuffers(this); @@ -1227,7 +1227,7 @@ OpenGLRenderer::resizeEvent(QResizeEvent *event) destination.y(), destination.width(), destination.height()); - + if (video_framerate == -1) render(); } @@ -1387,7 +1387,7 @@ OpenGLRenderer::event(QEvent *event) return res; } -QDialog* +QDialog * OpenGLRenderer::getOptions(QWidget *parent) { return new OpenGLShaderManagerDialog(parent); @@ -1426,7 +1426,7 @@ OpenGLRenderer::render() glw.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, video_filter_method ? GL_LINEAR : GL_NEAREST); glw.glBindTexture(GL_TEXTURE_2D, 0); - GLfloat orig_output_size[] = { (GLfloat)window_rect.w, (GLfloat)window_rect.h }; + GLfloat orig_output_size[] = { (GLfloat) window_rect.w, (GLfloat) window_rect.h }; if (active_shader->srgb) glw.glEnable(GL_FRAMEBUFFER_SRGB); @@ -1507,8 +1507,8 @@ OpenGLRenderer::render() /* loop through each pass */ for (int i = 0; i < shader->num_passes; ++i) { - bool resetFiltering = false; - struct shader_pass *pass = &shader->passes[i]; + bool resetFiltering = false; + struct shader_pass *pass = &shader->passes[i]; memcpy(pass->state.input_size, input->state.output_size, 2 * sizeof(GLfloat)); memcpy(pass->state.input_texture_size, input->state.output_texture_size, 2 * sizeof(GLfloat)); @@ -1696,27 +1696,27 @@ OpenGLRenderer::render() } if (monitors[r_monitor_index].mon_screenshots) { - int width = destination.width(), height = destination.height(); + int width = destination.width(), height = destination.height(); char path[1024]; char fn[256]; - + memset(fn, 0, sizeof(fn)); memset(path, 0, sizeof(path)); - + path_append_filename(path, usr_path, SCREENSHOT_PATH); - + if (!plat_dir_check(path)) plat_dir_create(path); - + path_slash(path); strcat(path, "Monitor_"); snprintf(&path[strlen(path)], 42, "%d_", r_monitor_index + 1); - - plat_tempfile(fn, NULL, (char*)".png"); + + plat_tempfile(fn, NULL, (char *) ".png"); strcat(path, fn); unsigned char *rgb = (unsigned char *) calloc(1, (size_t) width * height * 4); - + glw.glFinish(); glw.glReadPixels(window_rect.x, window_rect.y, width, height, GL_RGB, GL_UNSIGNED_BYTE, rgb); diff --git a/src/qt/qt_openglrenderer.hpp b/src/qt/qt_openglrenderer.hpp index 22a8a17d3..f99d7384e 100644 --- a/src/qt/qt_openglrenderer.hpp +++ b/src/qt/qt_openglrenderer.hpp @@ -39,8 +39,7 @@ #include "qt_renderercommon.hpp" -extern "C" -{ +extern "C" { #include <86box/qt-glslp-parser.h> } @@ -83,10 +82,9 @@ protected: bool event(QEvent *event) override; private: - std::array, 2> imagebufs; - QTimer *renderTimer; + QTimer *renderTimer; QString glslVersion = ""; @@ -98,7 +96,7 @@ private: QOpenGLExtraFunctions glw; struct shader_texture scene_texture; - glsl_t *active_shader; + glsl_t *active_shader; void *unpackBuffer = nullptr; @@ -108,20 +106,20 @@ private: void initializeExtensions(); void initializeBuffers(); void applyOptions(); - + void create_scene_shader(); void create_texture(struct shader_texture *tex); void create_fbo(struct shader_fbo *fbo); void recreate_fbo(struct shader_fbo *fbo, int width, int height); void setup_fbo(struct shader *shader, struct shader_fbo *fbo); - bool notReady() const { return !isInitialized || isFinalized; } - glsl_t* load_glslp(glsl_t *glsl, int num_shader, const char *f); - glsl_t* load_shaders(int num, char shaders[MAX_USER_SHADERS][512]); - int compile_shader(GLenum shader_type, const char *prepend, const char *program, int *dst); - int create_default_shader_tex(struct shader_pass *pass); - int create_default_shader_color(struct shader_pass *pass); - int create_program(struct shader_program *program); + bool notReady() const { return !isInitialized || isFinalized; } + glsl_t *load_glslp(glsl_t *glsl, int num_shader, const char *f); + glsl_t *load_shaders(int num, char shaders[MAX_USER_SHADERS][512]); + int compile_shader(GLenum shader_type, const char *prepend, const char *program, int *dst); + int create_default_shader_tex(struct shader_pass *pass); + int create_default_shader_color(struct shader_pass *pass); + int create_program(struct shader_program *program); GLuint get_uniform(GLuint program, const char *name); GLuint get_attrib(GLuint program, const char *name); diff --git a/src/qt/qt_openglshaderconfig.cpp b/src/qt/qt_openglshaderconfig.cpp index 66bd9eb52..096f27407 100644 --- a/src/qt/qt_openglshaderconfig.cpp +++ b/src/qt/qt_openglshaderconfig.cpp @@ -3,16 +3,15 @@ #include "qt_mainwindow.hpp" -extern MainWindow* main_window; +extern MainWindow *main_window; -extern "C" -{ +extern "C" { #include <86box/86box.h> #include <86box/plat.h> #include <86box/config.h> } -OpenGLShaderConfig::OpenGLShaderConfig(QWidget *parent, glslp_t* shader) +OpenGLShaderConfig::OpenGLShaderConfig(QWidget *parent, glslp_t *shader) : QDialog(parent) , ui(new Ui::OpenGLShaderConfig) { @@ -32,7 +31,7 @@ OpenGLShaderConfig::OpenGLShaderConfig(QWidget *parent, glslp_t* shader) spinBox->setRange(currentShader->parameters[i].min, currentShader->parameters[i].max); spinBox->setValue(currentShader->parameters[i].value); spinBox->setSingleStep(currentShader->parameters[i].step); - QFormLayout* layout = (QFormLayout*)ui->scrollAreaWidgetContents->layout(); + QFormLayout *layout = (QFormLayout *) ui->scrollAreaWidgetContents->layout(); layout->addRow(currentShader->parameters[i].description, spinBox); } } @@ -42,11 +41,12 @@ OpenGLShaderConfig::~OpenGLShaderConfig() delete ui; } -void OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button) +void +OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button) { if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::ResetRole) { for (int i = 0; i < currentShader->num_parameters; i++) { - QDoubleSpinBox* box = this->findChild(QString(currentShader->parameters[i].id)); + QDoubleSpinBox *box = this->findChild(QString(currentShader->parameters[i].id)); if (box) { box->setValue(currentShader->parameters[i].default_value); } @@ -54,9 +54,9 @@ void OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button) } else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) { startblit(); for (int i = 0; i < currentShader->num_parameters; i++) { - QDoubleSpinBox* box = this->findChild(QString(currentShader->parameters[i].id)); + QDoubleSpinBox *box = this->findChild(QString(currentShader->parameters[i].id)); if (box) { - float val = (float)box->value(); + float val = (float) box->value(); currentShader->parameters[i].value = val; } } @@ -67,14 +67,14 @@ void OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button) } } - -void OpenGLShaderConfig::on_OpenGLShaderConfig_accepted() +void +OpenGLShaderConfig::on_OpenGLShaderConfig_accepted() { startblit(); for (int i = 0; i < currentShader->num_parameters; i++) { - QDoubleSpinBox* box = (QDoubleSpinBox*)this->findChild(QString(currentShader->parameters[i].id)); + QDoubleSpinBox *box = (QDoubleSpinBox *) this->findChild(QString(currentShader->parameters[i].id)); if (box) { - float val = (float)box->value(); + float val = (float) box->value(); currentShader->parameters[i].value = val; } } diff --git a/src/qt/qt_openglshaderconfig.hpp b/src/qt/qt_openglshaderconfig.hpp index f71299d38..307aae402 100644 --- a/src/qt/qt_openglshaderconfig.hpp +++ b/src/qt/qt_openglshaderconfig.hpp @@ -9,8 +9,7 @@ #include #include -extern "C" -{ +extern "C" { #include <86box/qt-glslp-parser.h> } @@ -22,7 +21,7 @@ class OpenGLShaderConfig : public QDialog { Q_OBJECT public: - explicit OpenGLShaderConfig(QWidget *parent = nullptr, glslp_t* shader = nullptr); + explicit OpenGLShaderConfig(QWidget *parent = nullptr, glslp_t *shader = nullptr); ~OpenGLShaderConfig(); private slots: @@ -32,7 +31,7 @@ private slots: private: Ui::OpenGLShaderConfig *ui; - glslp_t* currentShader; + glslp_t *currentShader; std::map defaultValues; }; diff --git a/src/qt/qt_openglshadermanagerdialog.cpp b/src/qt/qt_openglshadermanagerdialog.cpp index ac252c092..f9678c6da 100644 --- a/src/qt/qt_openglshadermanagerdialog.cpp +++ b/src/qt/qt_openglshadermanagerdialog.cpp @@ -3,7 +3,7 @@ #include "qt_mainwindow.hpp" #include "qt_util.hpp" -extern MainWindow* main_window; +extern MainWindow *main_window; #include "qt_openglshaderconfig.hpp" @@ -41,14 +41,14 @@ OpenGLShaderManagerDialog::OpenGLShaderManagerDialog(QWidget *parent) for (int i = 0; i < MAX_USER_SHADERS; i++) { if (gl3_shader_file[i][0] != 0) { - char* filename = path_get_filename(gl3_shader_file[i]); + char *filename = path_get_filename(gl3_shader_file[i]); if (filename[0] != 0) { - glslp_t* shaderfile = glslp_parse(gl3_shader_file[i]); + glslp_t *shaderfile = glslp_parse(gl3_shader_file[i]); if (shaderfile) { - QListWidgetItem* item = new QListWidgetItem(ui->shaderListWidget); + QListWidgetItem *item = new QListWidgetItem(ui->shaderListWidget); item->setText(filename); item->setData(Qt::UserRole + 1, QString(gl3_shader_file[i])); - item->setData(Qt::UserRole + 2, (qulonglong)(uintptr_t)shaderfile); + item->setData(Qt::UserRole + 2, (qulonglong) (uintptr_t) shaderfile); } } } @@ -57,7 +57,7 @@ OpenGLShaderManagerDialog::OpenGLShaderManagerDialog(QWidget *parent) ui->shaderListWidget->setCurrentRow(ui->shaderListWidget->count() - 1); auto current = ui->shaderListWidget->currentItem(); if (current) { - glslp_t* shader = (glslp_t*)current->data(Qt::UserRole + 2).toULongLong(); + glslp_t *shader = (glslp_t *) current->data(Qt::UserRole + 2).toULongLong(); if (shader->num_parameters > 0) ui->buttonConfigure->setEnabled(true); else @@ -78,13 +78,14 @@ OpenGLShaderManagerDialog::~OpenGLShaderManagerDialog() { for (int i = 0; i < ui->shaderListWidget->count(); i++) { if (ui->shaderListWidget->item(i) && ui->shaderListWidget->item(i)->data(Qt::UserRole + 2).toULongLong()) { - glslp_free((glslp_t*)ui->shaderListWidget->item(i)->data(Qt::UserRole + 2).toULongLong()); + glslp_free((glslp_t *) ui->shaderListWidget->item(i)->data(Qt::UserRole + 2).toULongLong()); } } delete ui; } -void OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button) +void +OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button) { if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) { accept(); @@ -96,20 +97,20 @@ void OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button) } } - -void OpenGLShaderManagerDialog::on_buttonMoveUp_clicked() +void +OpenGLShaderManagerDialog::on_buttonMoveUp_clicked() { if (ui->shaderListWidget->currentRow() == 0) return; - int row = ui->shaderListWidget->currentRow(); + int row = ui->shaderListWidget->currentRow(); auto item = ui->shaderListWidget->takeItem(row); ui->shaderListWidget->insertItem(row - 1, item); ui->shaderListWidget->setCurrentItem(item); } - -void OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) +void +OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) { if (current == nullptr) { ui->buttonRemove->setDisabled(true); @@ -121,7 +122,7 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidg ui->buttonRemove->setDisabled(false); ui->buttonConfigure->setDisabled(true); if (current) { - glslp_t* shader = (glslp_t*)current->data(Qt::UserRole + 2).toULongLong(); + glslp_t *shader = (glslp_t *) current->data(Qt::UserRole + 2).toULongLong(); if (shader->num_parameters > 0) ui->buttonConfigure->setEnabled(true); } @@ -130,8 +131,8 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidg ui->buttonMoveDown->setDisabled(ui->shaderListWidget->currentRow() == (ui->shaderListWidget->count() - 1)); } - -void OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int currentRow) +void +OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int currentRow) { auto current = ui->shaderListWidget->currentItem(); if (current == nullptr) { @@ -144,7 +145,7 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int curren ui->buttonRemove->setDisabled(false); ui->buttonConfigure->setDisabled(true); if (current) { - glslp_t* shader = (glslp_t*)current->data(Qt::UserRole + 2).toULongLong(); + glslp_t *shader = (glslp_t *) current->data(Qt::UserRole + 2).toULongLong(); if (shader->num_parameters > 0) ui->buttonConfigure->setEnabled(true); } @@ -153,32 +154,32 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int curren ui->buttonMoveDown->setDisabled(ui->shaderListWidget->currentRow() == (ui->shaderListWidget->count() - 1)); } - -void OpenGLShaderManagerDialog::on_buttonMoveDown_clicked() +void +OpenGLShaderManagerDialog::on_buttonMoveDown_clicked() { if (ui->shaderListWidget->currentRow() == (ui->shaderListWidget->count() - 1)) return; - int row = ui->shaderListWidget->currentRow(); + int row = ui->shaderListWidget->currentRow(); auto item = ui->shaderListWidget->takeItem(row); ui->shaderListWidget->insertItem(row + 1, item); ui->shaderListWidget->setCurrentItem(item); } - -void OpenGLShaderManagerDialog::on_buttonAdd_clicked() +void +OpenGLShaderManagerDialog::on_buttonAdd_clicked() { auto res = QFileDialog::getOpenFileName(this, QString(), QString(), tr("GLSL shaders") % util::DlgFilter({ "glslp", "glsl" }) % tr("All files") % util::DlgFilter({ "*" }, true)); if (!res.isEmpty()) { - auto glslp_file = res.toUtf8(); - glslp_t* shaderfile = glslp_parse(glslp_file.data()); + auto glslp_file = res.toUtf8(); + glslp_t *shaderfile = glslp_parse(glslp_file.data()); if (shaderfile) { - auto filename = path_get_filename(glslp_file.data()); - QListWidgetItem* item = new QListWidgetItem(ui->shaderListWidget); + auto filename = path_get_filename(glslp_file.data()); + QListWidgetItem *item = new QListWidgetItem(ui->shaderListWidget); item->setText(filename); item->setData(Qt::UserRole + 1, res); - item->setData(Qt::UserRole + 2, (qulonglong)(uintptr_t)shaderfile); + item->setData(Qt::UserRole + 2, (qulonglong) (uintptr_t) shaderfile); if (ui->shaderListWidget->count()) { ui->shaderListWidget->setCurrentRow(ui->shaderListWidget->count() - 1); ui->buttonAdd->setDisabled(ui->shaderListWidget->count() >= MAX_USER_SHADERS); @@ -189,14 +190,14 @@ void OpenGLShaderManagerDialog::on_buttonAdd_clicked() } } - -void OpenGLShaderManagerDialog::on_buttonRemove_clicked() +void +OpenGLShaderManagerDialog::on_buttonRemove_clicked() { if (ui->shaderListWidget->currentItem()) { auto item = ui->shaderListWidget->takeItem(ui->shaderListWidget->currentRow()); if (item->data(Qt::UserRole + 2).toULongLong()) { - glslp_free((glslp_t*)item->data(Qt::UserRole + 2).toULongLong()); + glslp_free((glslp_t *) item->data(Qt::UserRole + 2).toULongLong()); } delete item; @@ -205,7 +206,8 @@ void OpenGLShaderManagerDialog::on_buttonRemove_clicked() ui->buttonAdd->setDisabled(ui->shaderListWidget->count() >= MAX_USER_SHADERS); } -void OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted() +void +OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted() { memset(gl3_shader_file, 0, sizeof(gl3_shader_file)); for (int i = 0; i < ui->shaderListWidget->count(); i++) { @@ -222,43 +224,43 @@ void OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted() endblit(); } - -void OpenGLShaderManagerDialog::on_buttonConfigure_clicked() +void +OpenGLShaderManagerDialog::on_buttonConfigure_clicked() { auto item = ui->shaderListWidget->currentItem(); if (item) { - glslp_t* shader = (glslp_t*)item->data(Qt::UserRole + 2).toULongLong(); + glslp_t *shader = (glslp_t *) item->data(Qt::UserRole + 2).toULongLong(); auto configDialog = new OpenGLShaderConfig(this, shader); configDialog->exec(); } } - -void OpenGLShaderManagerDialog::on_radioButtonVideoSync_clicked() +void +OpenGLShaderManagerDialog::on_radioButtonVideoSync_clicked() { ui->targetFrameRate->setDisabled(true); } - -void OpenGLShaderManagerDialog::on_radioButtonTargetFramerate_clicked() +void +OpenGLShaderManagerDialog::on_radioButtonTargetFramerate_clicked() { ui->targetFrameRate->setDisabled(false); } - -void OpenGLShaderManagerDialog::on_horizontalSliderFramerate_sliderMoved(int position) +void +OpenGLShaderManagerDialog::on_horizontalSliderFramerate_sliderMoved(int position) { - (void)position; + (void) position; if (ui->horizontalSliderFramerate->value() != ui->targetFrameRate->value()) ui->targetFrameRate->setValue(ui->horizontalSliderFramerate->value()); } - -void OpenGLShaderManagerDialog::on_targetFrameRate_valueChanged(int arg1) +void +OpenGLShaderManagerDialog::on_targetFrameRate_valueChanged(int arg1) { - (void)arg1; + (void) arg1; if (ui->horizontalSliderFramerate->value() != ui->targetFrameRate->value()) ui->horizontalSliderFramerate->setValue(ui->targetFrameRate->value()); diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index d276dc8bd..31eb09e56 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -17,7 +17,7 @@ * Copyright 2021-2022 Teemu Korhonen */ #ifdef __HAIKU__ -#include +# include #endif #include @@ -125,7 +125,7 @@ extern "C" { #include <86box/config.h> #include <86box/ui.h> #ifdef DISCORD -# include <86box/discord.h> +# include <86box/discord.h> #endif #include "../cpu/cpu.h" @@ -186,9 +186,9 @@ plat_get_exe_name(char *s, int size) if (acp_utf8) GetModuleFileNameA(NULL, s, size); else { - temp = (wchar_t*)calloc(size, sizeof(wchar_t)); + temp = (wchar_t *) calloc(size, sizeof(wchar_t)); GetModuleFileNameW(NULL, temp, size); - c16stombs(s, (uint16_t*)temp, size); + c16stombs(s, (uint16_t *) temp, size); free(temp); } #else @@ -254,7 +254,7 @@ plat_file_check(const char *path) { #ifdef _WIN32 auto data = QString::fromUtf8(path).toStdWString(); - auto res = GetFileAttributesW(data.c_str()); + auto res = GetFileAttributesW(data.c_str()); return (res != INVALID_FILE_ATTRIBUTES) && !(res & FILE_ATTRIBUTE_DIRECTORY); #else struct stat stats; @@ -269,12 +269,12 @@ plat_getcwd(char *bufp, int max) { #ifdef __APPLE__ /* Working directory for .app bundles is undefined. */ -#ifdef USE_EXE_PATH +# ifdef USE_EXE_PATH strncpy(bufp, exe_path, max); -#else +# else CharPointer(bufp, max) = QDir::homePath().toUtf8(); path_append_filename(bufp, bufp, "Library/86Box"); -#endif +# endif #else CharPointer(bufp, max) = QDir::currentPath().toUtf8(); #endif @@ -320,7 +320,7 @@ path_get_filename(char *s) return s; #else - auto idx = QByteArray::fromRawData(s, strlen(s)).lastIndexOf(QDir::separator().toLatin1()); + auto idx = QByteArray::fromRawData(s, strlen(s)).lastIndexOf(QDir::separator().toLatin1()); if (idx >= 0) { return s + idx + 1; } @@ -390,7 +390,7 @@ path_append_filename(char *dest, const char *s1, const char *s2) if (len > 0 && dest[len - 1] != '/' && dest[len - 1] != '\\') { if (len + 1 < dest_size) { dest[len++] = '/'; - dest[len] = '\0'; + dest[len] = '\0'; } } @@ -453,58 +453,58 @@ extern bool cpu_thread_running; #ifdef Q_OS_WINDOWS /* SetThreadDescription was added in 14393 and SetProcessInformation in 8. Revisit if we ever start requiring 10. */ -static void *kernel32_handle = NULL; -static HRESULT(WINAPI *pSetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription) = NULL; +static void *kernel32_handle = NULL; +static HRESULT(WINAPI *pSetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription) = NULL; static HRESULT(WINAPI *pSetProcessInformation)(HANDLE hProcess, PROCESS_INFORMATION_CLASS ProcessInformationClass, LPVOID ProcessInformation, DWORD ProcessInformationSize) = NULL; -static dllimp_t kernel32_imports[] = { - // clang-format off +static dllimp_t kernel32_imports[] = { + // clang-format off { "SetThreadDescription", &pSetThreadDescription }, { "SetProcessInformation", &pSetProcessInformation }, { NULL, NULL } - // clang-format on + // clang-format on }; static void enter_pause(void) { - PROCESS_POWER_THROTTLING_STATE state{}; - state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION; + PROCESS_POWER_THROTTLING_STATE state {}; + state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION; state.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION; - state.StateMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION; + state.StateMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION; if (!kernel32_handle) { kernel32_handle = dynld_module("kernel32.dll", kernel32_imports); if (!kernel32_handle) { - kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */ - pSetThreadDescription = NULL; + kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */ + pSetThreadDescription = NULL; pSetProcessInformation = NULL; } } if (pSetProcessInformation) { - pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID)&state, sizeof(state)); + pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID) &state, sizeof(state)); } } void exit_pause(void) { - PROCESS_POWER_THROTTLING_STATE state{}; - state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION; + PROCESS_POWER_THROTTLING_STATE state {}; + state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION; state.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION; - state.StateMask = 0; + state.StateMask = 0; if (!kernel32_handle) { kernel32_handle = dynld_module("kernel32.dll", kernel32_imports); if (!kernel32_handle) { - kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */ - pSetThreadDescription = NULL; + kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */ + pSetThreadDescription = NULL; pSetProcessInformation = NULL; } } if (pSetProcessInformation) { - pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID)&state, sizeof(state)); + pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID) &state, sizeof(state)); } } #endif @@ -695,13 +695,13 @@ c16stombs(char dst[], const uint16_t src[], int len) #endif #ifdef _WIN32 -# define LIB_NAME_GS "gsdll64.dll" -# define LIB_NAME_GPCL "gpcl6dll64.dll" -# define LIB_NAME_PCAP "Npcap" +# define LIB_NAME_GS "gsdll64.dll" +# define LIB_NAME_GPCL "gpcl6dll64.dll" +# define LIB_NAME_PCAP "Npcap" #else -# define LIB_NAME_GS "libgs" -# define LIB_NAME_GPCL "libgpcl6" -# define LIB_NAME_PCAP "libpcap" +# define LIB_NAME_GS "libgs" +# define LIB_NAME_GPCL "libgpcl6" +# define LIB_NAME_PCAP "libpcap" #endif QMap ProgSettings::translatedstrings; @@ -837,15 +837,16 @@ plat_init_rom_paths(void) } void -plat_get_cpu_string(char *outbuf, uint8_t len) { +plat_get_cpu_string(char *outbuf, uint8_t len) +{ auto cpu_string = QString("Unknown"); /* Write the default string now in case we have to exit early from an error */ qstrncpy(outbuf, cpu_string.toUtf8().constData(), len); #if defined(Q_OS_MACOS) - auto *process = new QProcess(nullptr); + auto *process = new QProcess(nullptr); QStringList arguments; - QString program = "/usr/sbin/sysctl"; + QString program = "/usr/sbin/sysctl"; arguments << "machdep.cpu.brand_string"; process->start(program, arguments); if (!process->waitForStarted()) { @@ -854,9 +855,9 @@ plat_get_cpu_string(char *outbuf, uint8_t len) { if (!process->waitForFinished()) { return; } - QByteArray result = process->readAll(); - auto command_result = QString(result).split(": ").last().trimmed(); - if(!command_result.isEmpty()) { + QByteArray result = process->readAll(); + auto command_result = QString(result).split(": ").last().trimmed(); + if (!command_result.isEmpty()) { cpu_string = command_result; } #elif defined(Q_OS_WINDOWS) @@ -868,38 +869,36 @@ plat_get_cpu_string(char *outbuf, uint8_t len) { bufSize = 32768; if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, 1, &hKey) == ERROR_SUCCESS) { if (RegQueryValueExA(hKey, valueName, NULL, NULL, buf, &bufSize) == ERROR_SUCCESS) { - cpu_string = reinterpret_cast(buf); + cpu_string = reinterpret_cast(buf); } RegCloseKey(hKey); } #elif defined(Q_OS_LINUX) - auto cpuinfo = QString("/proc/cpuinfo"); + auto cpuinfo = QString("/proc/cpuinfo"); auto cpuinfo_fi = QFileInfo(cpuinfo); - if(!cpuinfo_fi.isReadable()) { + if (!cpuinfo_fi.isReadable()) { return; } QFile file(cpuinfo); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream textStream(&file); - while(true) { + while (true) { QString line = textStream.readLine(); if (line.isNull()) { break; } - if(QRegularExpression("model name.*:").match(line).hasMatch()) { + if (QRegularExpression("model name.*:").match(line).hasMatch()) { auto list = line.split(": "); - if(!list.last().isEmpty()) { + if (!list.last().isEmpty()) { cpu_string = list.last(); break; } } - } } #endif qstrncpy(outbuf, cpu_string.toUtf8().constData(), len); - } void @@ -909,14 +908,14 @@ plat_set_thread_name(void *thread, const char *name) if (!kernel32_handle) { kernel32_handle = dynld_module("kernel32.dll", kernel32_imports); if (!kernel32_handle) { - kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */ - pSetThreadDescription = NULL; + kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */ + pSetThreadDescription = NULL; pSetProcessInformation = NULL; } } if (pSetThreadDescription) { - size_t len = strlen(name) + 1; + size_t len = strlen(name) + 1; wchar_t wname[2048]; mbstowcs(wname, name, (len >= 1024) ? 1024 : len); pSetThreadDescription(thread ? (HANDLE) thread : GetCurrentThread(), wname); @@ -935,7 +934,7 @@ plat_set_thread_name(void *thread, const char *name) # if defined(Q_OS_DARWIN) pthread_setname_np(truncated); # elif defined(Q_OS_NETBSD) - pthread_setname_np(thread ? *((pthread_t *) thread) : pthread_self(), truncated, (void*)"%s"); + pthread_setname_np(thread ? *((pthread_t *) thread) : pthread_self(), truncated, (void *) "%s"); # elif defined(__HAIKU__) rename_thread(find_thread(NULL), truncated); # elif defined(Q_OS_OPENBSD) diff --git a/src/qt/qt_progsettings.cpp b/src/qt/qt_progsettings.cpp index ac1d6478f..268cec894 100644 --- a/src/qt/qt_progsettings.cpp +++ b/src/qt/qt_progsettings.cpp @@ -40,7 +40,7 @@ extern "C" { #include <86box/video.h> } -extern MainWindow *main_window; +extern MainWindow *main_window; ProgSettings::CustomTranslator *ProgSettings::translator = nullptr; QTranslator *ProgSettings::qtTranslator = nullptr; diff --git a/src/qt/qt_progsettings.hpp b/src/qt/qt_progsettings.hpp index 9445d2f86..2ada8c2bf 100644 --- a/src/qt/qt_progsettings.hpp +++ b/src/qt/qt_progsettings.hpp @@ -17,10 +17,10 @@ public: #ifdef Q_OS_WINDOWS static QString getFontName(int langId); #endif - static int languageCodeToId(QString langCode); - static QString languageIdToCode(int id); - static void loadTranslators(QObject *parent = nullptr); - static void reloadStrings(); + static int languageCodeToId(QString langCode); + static QString languageIdToCode(int id); + static void loadTranslators(QObject *parent = nullptr); + static void reloadStrings(); class CustomTranslator : public QTranslator { public: CustomTranslator(QObject *parent = nullptr) @@ -33,10 +33,10 @@ public: return QTranslator::translate("", sourceText, disambiguation, n); } }; - static CustomTranslator *translator; - static QTranslator *qtTranslator; - static QVector> languages; - static QMap translatedstrings; + static CustomTranslator *translator; + static QTranslator *qtTranslator; + static QVector> languages; + static QMap translatedstrings; protected slots: void accept() override; @@ -49,7 +49,7 @@ private slots: private: Ui::ProgSettings *ui; - static bool loadQtTranslations(const QString name); + static bool loadQtTranslations(const QString name); friend class MainWindow; double mouseSensitivity; diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index 25d3a5c28..944f21349 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -117,13 +117,13 @@ void RendererCommon::onResize(int width, int height) { /* This is needed so that the if below does not take like, 5 lines. */ - bool is_fs = (video_fullscreen == 0); - bool parent_max = (parentWidget->isMaximized() == false); + bool is_fs = (video_fullscreen == 0); + bool parent_max = (parentWidget->isMaximized() == false); bool main_is_ancestor = main_window->isAncestorOf(parentWidget); - bool main_max = main_window->isMaximized(); - bool main_is_max = (main_is_ancestor && main_max == false); + bool main_max = main_window->isMaximized(); + bool main_is_max = (main_is_ancestor && main_max == false); - width = round(pixelRatio * width); + width = round(pixelRatio * width); height = round(pixelRatio * height); if (is_fs && (video_fullscreen_scale_maximized ? (parent_max && main_is_max) : 1) && !(force_43 && vid_resize)) @@ -142,7 +142,7 @@ RendererCommon::onResize(int width, int height) double gh = source.height(); double hsr = hw / hh; double r43 = 4.0 / 3.0; - + if (force_43 && is_fs && vid_resize) { if (!video_fullscreen_scale_maximized || (video_fullscreen_scale_maximized && parent_max && main_is_max)) temp_fullscreen_scale = FULLSCR_SCALE_43; @@ -155,7 +155,7 @@ RendererCommon::onResize(int width, int height) if (temp_fullscreen_scale == FULLSCR_SCALE_INT43) { gh = gw / r43; -// gw = gw; + // gw = gw; gsr = r43; } @@ -203,8 +203,8 @@ RendererCommon::onResize(int width, int height) monitors[r_monitor_index].mon_res_x = (double) destination.width(); monitors[r_monitor_index].mon_res_y = (double) destination.height(); - destinationF.setRect((double)destination.x() / (double)width, (double)destination.y() / (double)height, - (double)destination.width() / (double)width, (double)destination.height() / (double)height); + destinationF.setRect((double) destination.x() / (double) width, (double) destination.y() / (double) height, + (double) destination.width() / (double) width, (double) destination.height() / (double) height); } bool diff --git a/src/qt/qt_renderercommon.hpp b/src/qt/qt_renderercommon.hpp index 6bfa51a8d..827646bab 100644 --- a/src/qt/qt_renderercommon.hpp +++ b/src/qt/qt_renderercommon.hpp @@ -40,12 +40,12 @@ public: /* Should the renderer take screenshots itself? */ virtual bool rendererTakeScreenshot() { return false; } - int r_monitor_index = 0; - QRectF destinationF = QRectF(0, 0, 1, 1); /* normalized to 0.0-1.0 range. */ + int r_monitor_index = 0; + QRectF destinationF = QRectF(0, 0, 1, 1); /* normalized to 0.0-1.0 range. */ protected: - bool eventDelegate(QEvent *event, bool &result); - void drawStatusBarIcons(QPainter* painter); + bool eventDelegate(QEvent *event, bool &result); + void drawStatusBarIcons(QPainter *painter); QRect source { 0, 0, 0, 0 }; QRect destination; diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index b95fe3b73..85a0bb096 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -77,14 +77,14 @@ extern "C" { struct mouseinputdata { atomic_bool mouse_tablet_in_proximity; - char *mouse_type; + char *mouse_type; }; static mouseinputdata mousedata; extern MainWindow *main_window; #ifdef Q_OS_WINDOWS -HWND rw_hwnd; +HWND rw_hwnd; #endif RendererStack::RendererStack(QWidget *parent, int monitor_index) @@ -98,7 +98,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index) #endif #ifdef Q_OS_WINDOWS setAttribute(Qt::WA_NativeWindow, true); - (void)winId(); + (void) winId(); #endif rendererTakesScreenshots = false; #ifdef Q_OS_WINDOWS @@ -111,9 +111,8 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index) m_monitor_index = monitor_index; - if (monitor_index >= 1) { - QTimer* frameRateTimer = new QTimer(this); + QTimer *frameRateTimer = new QTimer(this); frameRateTimer->setSingleShot(false); frameRateTimer->setInterval(1000); connect(frameRateTimer, &QTimer::timeout, [this] { @@ -122,7 +121,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index) frameRateTimer->start(1000); } #if defined __unix__ && !defined __HAIKU__ - memset(auto_mouse_type, 0, sizeof (auto_mouse_type)); + memset(auto_mouse_type, 0, sizeof(auto_mouse_type)); mousedata.mouse_type = getenv("EMU86BOX_MOUSE"); if (!mousedata.mouse_type || (mousedata.mouse_type[0] == '\0') || !stricmp(mousedata.mouse_type, "auto")) { if (QApplication::platformName().contains("wayland")) @@ -163,7 +162,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index) RendererStack::~RendererStack() { - while (QApplication::overrideCursor()) + while (QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); delete ui; } @@ -173,7 +172,8 @@ qt_mouse_capture(int on) { if (!on) { mouse_capture = 0; - while (QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); + while (QApplication::overrideCursor()) + QApplication::restoreOverrideCursor(); #ifdef __APPLE__ CGAssociateMouseAndMouseCursorPosition(true); #endif @@ -192,7 +192,7 @@ void RendererStack::mouseReleaseEvent(QMouseEvent *event) { #ifdef Q_OS_WINDOWS - rw_hwnd = (HWND) this->winId(); + rw_hwnd = (HWND) this->winId(); #endif event->accept(); @@ -201,9 +201,7 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event) #else if (!dopause && this->geometry().contains(m_monitor_index >= 1 ? event->globalPos() : event->pos()) && #endif - (event->button() == Qt::LeftButton) && !mouse_capture && - (isMouseDown & 1) && (kbd_req_capture || (mouse_get_buttons() != 0)) && - (mouse_input_mode == 0)) { + (event->button() == Qt::LeftButton) && !mouse_capture && (isMouseDown & 1) && (kbd_req_capture || (mouse_get_buttons() != 0)) && (mouse_input_mode == 0)) { plat_mouse_capture(1); this->setCursor(Qt::BlankCursor); if (!ignoreNextMouseEvent) @@ -219,15 +217,13 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event) } if (mouse_capture || (mouse_input_mode >= 1)) { #ifdef Q_OS_WINDOWS - if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || - ((m_monitor_index < 1) && (mouse_input_mode >= 1))) -#else -#ifndef __APPLE__ - if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || - (m_monitor_index < 1)) + if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || ((m_monitor_index < 1) && (mouse_input_mode >= 1))) #else +# ifndef __APPLE__ + if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || (m_monitor_index < 1)) +# else if ((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) -#endif +# endif #endif mouse_set_buttons_ex(mouse_get_buttons_ex() & ~event->button()); } @@ -240,15 +236,13 @@ RendererStack::mousePressEvent(QMouseEvent *event) isMouseDown |= 1; if (mouse_capture || (mouse_input_mode >= 1)) { #ifdef Q_OS_WINDOWS - if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || - ((m_monitor_index < 1) && (mouse_input_mode >= 1))) -#else -#ifndef __APPLE__ - if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || - (m_monitor_index < 1)) + if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || ((m_monitor_index < 1) && (mouse_input_mode >= 1))) #else +# ifndef __APPLE__ + if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || (m_monitor_index < 1)) +# else if ((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) -#endif +# endif #endif mouse_set_buttons_ex(mouse_get_buttons_ex() | event->button()); } @@ -264,7 +258,7 @@ RendererStack::wheelEvent(QWheelEvent *event) } #if !defined(Q_OS_WINDOWS) && !defined(__APPLE__) - double numSteps = (double) event->angleDelta().y() / 120.0; + double numSteps = (double) event->angleDelta().y() / 120.0; double numStepsW = (double) event->angleDelta().x() / 120.0; mouse_set_z((int) numSteps); @@ -296,18 +290,18 @@ RendererStack::mouseMoveEvent(QMouseEvent *event) return; } -#if defined __unix__ && !defined __HAIKU__ +# if defined __unix__ && !defined __HAIKU__ if (!stricmp(mousedata.mouse_type, "wayland")) mouse_scale(event->pos().x() - oldPos.x(), event->pos().y() - oldPos.y()); -#endif +# endif if (QApplication::platformName() == "eglfs") { leaveEvent((QEvent *) event); ignoreNextMouseEvent--; } -#if !defined _WIN32 +# if !defined _WIN32 QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2))); -#endif +# endif ignoreNextMouseEvent = 2; oldPos = event->pos(); #endif @@ -351,7 +345,7 @@ RendererStack::leaveEvent(QEvent *event) void RendererStack::switchRenderer(Renderer renderer) { - //startblit(); + // startblit(); switchInProgress = true; if (current) { rendererWindow->finalize(); @@ -389,12 +383,12 @@ RendererStack::createRenderer(Renderer renderer) { this->createWinId(); this->rendererTakesScreenshots = true; - auto hw = new OpenGLRenderer(this); - rendererWindow = hw; + auto hw = new OpenGLRenderer(this); + rendererWindow = hw; connect(this, &RendererStack::blitToRenderer, hw, &OpenGLRenderer::onBlit, Qt::QueuedConnection); connect(hw, &OpenGLRenderer::initialized, [=]() { /* Buffers are available only after initialization. */ - imagebufs = rendererWindow->getBuffers(); + imagebufs = rendererWindow->getBuffers(); switchInProgress = false; emit rendererChanged(); }); @@ -426,7 +420,7 @@ RendererStack::createRenderer(Renderer renderer) connect(this, &RendererStack::blitToRenderer, hw, &VulkanWindowRenderer::onBlit, Qt::QueuedConnection); connect(hw, &VulkanWindowRenderer::rendererInitialized, [=]() { /* Buffers are available only after initialization. */ - imagebufs = rendererWindow->getBuffers(); + imagebufs = rendererWindow->getBuffers(); switchInProgress = false; emit rendererChanged(); }); @@ -460,7 +454,7 @@ RendererStack::createRenderer(Renderer renderer) currentBuf = 0; if (renderer != Renderer::OpenGL3 && renderer != Renderer::Vulkan) { - imagebufs = rendererWindow->getBuffers(); + imagebufs = rendererWindow->getBuffers(); switchInProgress = false; emit rendererChanged(); } @@ -470,10 +464,7 @@ RendererStack::createRenderer(Renderer renderer) void RendererStack::blit(int x, int y, int w, int h) { - if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || - (w > 2048) || (h > 2048) || (switchInProgress) || - (monitors[m_monitor_index].target_buffer == NULL) || imagebufs.empty() || - std::get(imagebufs[currentBuf])->test_and_set()) { + if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (switchInProgress) || (monitors[m_monitor_index].target_buffer == NULL) || imagebufs.empty() || std::get(imagebufs[currentBuf])->test_and_set()) { video_blit_complete_monitor(m_monitor_index); return; } @@ -517,20 +508,20 @@ RendererStack::changeEvent(QEvent *event) } bool -RendererStack::event(QEvent* event) +RendererStack::event(QEvent *event) { if (event->type() == QEvent::MouseMove) { - QMouseEvent* mouse_event = (QMouseEvent*)event; + QMouseEvent *mouse_event = (QMouseEvent *) event; if (m_monitor_index >= 1) { if (mouse_input_mode >= 1) { #ifdef TOUCH_PR #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - mouse_x_abs = (mouse_event->position().x()) / (double)width(); - mouse_y_abs = (mouse_event->position().y()) / (double)height(); + mouse_x_abs = (mouse_event->position().x()) / (double) width(); + mouse_y_abs = (mouse_event->position().y()) / (double) height(); #else - mouse_x_abs = (mouse_event->localPos().x()) / (double)width(); - mouse_y_abs = (mouse_event->localPos().y()) / (double)height(); + mouse_x_abs = (mouse_event->localPos().x()) / (double) width(); + mouse_y_abs = (mouse_event->localPos().y()) / (double) height(); #endif #else #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -546,14 +537,18 @@ RendererStack::event(QEvent* event) mouse_x_abs -= rendererWindow->destinationF.left(); mouse_y_abs -= rendererWindow->destinationF.top(); - if (mouse_x_abs < 0) mouse_x_abs = 0; - if (mouse_y_abs < 0) mouse_y_abs = 0; + if (mouse_x_abs < 0) + mouse_x_abs = 0; + if (mouse_y_abs < 0) + mouse_y_abs = 0; mouse_x_abs /= rendererWindow->destinationF.width(); mouse_y_abs /= rendererWindow->destinationF.height(); - if (mouse_x_abs > 1) mouse_x_abs = 1; - if (mouse_y_abs > 1) mouse_y_abs = 1; + if (mouse_x_abs > 1) + mouse_x_abs = 1; + if (mouse_y_abs > 1) + mouse_y_abs = 1; } return QWidget::event(event); } @@ -561,47 +556,51 @@ RendererStack::event(QEvent* event) #ifdef TOUCH_PR #ifdef Q_OS_WINDOWS if (mouse_input_mode == 0) { -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - mouse_x_abs = (mouse_event->position().x()) / (double)width(); - mouse_y_abs = (mouse_event->position().y()) / (double)height(); -#else - mouse_x_abs = (mouse_event->localPos().x()) / (double)width(); - mouse_y_abs = (mouse_event->localPos().y()) / (double)height(); -#endif - mouse_x_abs -= rendererWindow->destinationF.left(); - mouse_y_abs -= rendererWindow->destinationF.top(); +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + mouse_x_abs = (mouse_event->position().x()) / (double) width(); + mouse_y_abs = (mouse_event->position().y()) / (double) height(); +# else + mouse_x_abs = (mouse_event->localPos().x()) / (double) width(); + mouse_y_abs = (mouse_event->localPos().y()) / (double) height(); +# endif + mouse_x_abs -= rendererWindow->destinationF.left(); + mouse_y_abs -= rendererWindow->destinationF.top(); - if (mouse_x_abs < 0) mouse_x_abs = 0; - if (mouse_y_abs < 0) mouse_y_abs = 0; + if (mouse_x_abs < 0) + mouse_x_abs = 0; + if (mouse_y_abs < 0) + mouse_y_abs = 0; mouse_x_abs /= rendererWindow->destinationF.width(); mouse_y_abs /= rendererWindow->destinationF.height(); - if (mouse_x_abs > 1) mouse_x_abs = 1; - if (mouse_y_abs > 1) mouse_y_abs = 1; + if (mouse_x_abs > 1) + mouse_x_abs = 1; + if (mouse_y_abs > 1) + mouse_y_abs = 1; return QWidget::event(event); } #endif #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - mouse_x_abs = (mouse_event->position().x()) / (double)width(); - mouse_y_abs = (mouse_event->position().y()) / (double)height(); + mouse_x_abs = (mouse_event->position().x()) / (double) width(); + mouse_y_abs = (mouse_event->position().y()) / (double) height(); #else - mouse_x_abs = (mouse_event->localPos().x()) / (double)width(); - mouse_y_abs = (mouse_event->localPos().y()) / (double)height(); + mouse_x_abs = (mouse_event->localPos().x()) / (double) width(); + mouse_y_abs = (mouse_event->localPos().y()) / (double) height(); #endif #else #ifdef Q_OS_WINDOWS if (mouse_input_mode == 0) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - mouse_x_abs = (mouse_event->position().x()) / (long double)width(); - mouse_y_abs = (mouse_event->position().y()) / (long double)height(); + mouse_x_abs = (mouse_event->position().x()) / (long double)width(); + mouse_y_abs = (mouse_event->position().y()) / (long double)height(); #else - mouse_x_abs = (mouse_event->localPos().x()) / (long double)width(); - mouse_y_abs = (mouse_event->localPos().y()) / (long double)height(); + mouse_x_abs = (mouse_event->localPos().x()) / (long double)width(); + mouse_y_abs = (mouse_event->localPos().y()) / (long double)height(); #endif - mouse_x_abs -= rendererWindow->destinationF.left(); - mouse_y_abs -= rendererWindow->destinationF.top(); + mouse_x_abs -= rendererWindow->destinationF.left(); + mouse_y_abs -= rendererWindow->destinationF.top(); if (mouse_x_abs < 0) mouse_x_abs = 0; if (mouse_y_abs < 0) mouse_y_abs = 0; @@ -626,117 +625,142 @@ RendererStack::event(QEvent* event) mouse_x_abs -= rendererWindow->destinationF.left(); mouse_y_abs -= rendererWindow->destinationF.top(); - if (mouse_x_abs < 0) mouse_x_abs = 0; - if (mouse_y_abs < 0) mouse_y_abs = 0; + if (mouse_x_abs < 0) + mouse_x_abs = 0; + if (mouse_y_abs < 0) + mouse_y_abs = 0; mouse_x_abs /= rendererWindow->destinationF.width(); mouse_y_abs /= rendererWindow->destinationF.height(); - if (mouse_x_abs > 1) mouse_x_abs = 1; - if (mouse_y_abs > 1) mouse_y_abs = 1; + if (mouse_x_abs > 1) + mouse_x_abs = 1; + if (mouse_y_abs > 1) + mouse_y_abs = 1; mouse_tablet_in_proximity = mousedata.mouse_tablet_in_proximity; #ifdef TOUCH_PR - } else switch (event->type()) { - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - { + } else + switch (event->type()) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QTouchEvent* touchevent = (QTouchEvent*)event; - if (mouse_input_mode == 0) break; - if (touchevent->touchPoints().count()) { - mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double)width(); - mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double)height(); - mouse_x_abs -= rendererWindow->destinationF.left(); - mouse_y_abs -= rendererWindow->destinationF.top(); - - if (mouse_x_abs < 0) mouse_x_abs = 0; - if (mouse_y_abs < 0) mouse_y_abs = 0; - - mouse_x_abs /= rendererWindow->destinationF.width(); - mouse_y_abs /= rendererWindow->destinationF.height(); + QTouchEvent *touchevent = (QTouchEvent *) event; + if (mouse_input_mode == 0) + break; + if (touchevent->touchPoints().count()) { + mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double) width(); + mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double) height(); + mouse_x_abs -= rendererWindow->destinationF.left(); + mouse_y_abs -= rendererWindow->destinationF.top(); - if (mouse_x_abs > 1) mouse_x_abs = 1; - if (mouse_y_abs > 1) mouse_y_abs = 1; - } - mouse_set_buttons_ex(mouse_get_buttons_ex() | 1); - touchevent->accept(); - return true; + if (mouse_x_abs < 0) + mouse_x_abs = 0; + if (mouse_y_abs < 0) + mouse_y_abs = 0; + + mouse_x_abs /= rendererWindow->destinationF.width(); + mouse_y_abs /= rendererWindow->destinationF.height(); + + if (mouse_x_abs > 1) + mouse_x_abs = 1; + if (mouse_y_abs > 1) + mouse_y_abs = 1; + } + mouse_set_buttons_ex(mouse_get_buttons_ex() | 1); + touchevent->accept(); + return true; #else - QTouchEvent* touchevent = (QTouchEvent*)event; - if (mouse_input_mode == 0) break; - if (touchevent->pointCount()) { - mouse_x_abs = (touchevent->point(0).position().x()) / (double)width(); - mouse_y_abs = (touchevent->point(0).position().y()) / (double)height(); - mouse_x_abs -= rendererWindow->destinationF.left(); - mouse_y_abs -= rendererWindow->destinationF.top(); - - if (mouse_x_abs < 0) mouse_x_abs = 0; - if (mouse_y_abs < 0) mouse_y_abs = 0; - - mouse_x_abs /= rendererWindow->destinationF.width(); - mouse_y_abs /= rendererWindow->destinationF.height(); + QTouchEvent *touchevent = (QTouchEvent *) event; + if (mouse_input_mode == 0) + break; + if (touchevent->pointCount()) { + mouse_x_abs = (touchevent->point(0).position().x()) / (double) width(); + mouse_y_abs = (touchevent->point(0).position().y()) / (double) height(); + mouse_x_abs -= rendererWindow->destinationF.left(); + mouse_y_abs -= rendererWindow->destinationF.top(); - if (mouse_x_abs > 1) mouse_x_abs = 1; - if (mouse_y_abs > 1) mouse_y_abs = 1; - } - mouse_set_buttons_ex(mouse_get_buttons_ex() | 1); - touchevent->accept(); - return true; + if (mouse_x_abs < 0) + mouse_x_abs = 0; + if (mouse_y_abs < 0) + mouse_y_abs = 0; + + mouse_x_abs /= rendererWindow->destinationF.width(); + mouse_y_abs /= rendererWindow->destinationF.height(); + + if (mouse_x_abs > 1) + mouse_x_abs = 1; + if (mouse_y_abs > 1) + mouse_y_abs = 1; + } + mouse_set_buttons_ex(mouse_get_buttons_ex() | 1); + touchevent->accept(); + return true; #endif - } - case QEvent::TouchEnd: - case QEvent::TouchCancel: - { + } + case QEvent::TouchEnd: + case QEvent::TouchCancel: + { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QTouchEvent* touchevent = (QTouchEvent*)event; - if (mouse_input_mode == 0) break; - if (touchevent->touchPoints().count()) { - mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double)width(); - mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double)height(); - mouse_x_abs -= rendererWindow->destinationF.left(); - mouse_y_abs -= rendererWindow->destinationF.top(); - - if (mouse_x_abs < 0) mouse_x_abs = 0; - if (mouse_y_abs < 0) mouse_y_abs = 0; - - mouse_x_abs /= rendererWindow->destinationF.width(); - mouse_y_abs /= rendererWindow->destinationF.height(); + QTouchEvent *touchevent = (QTouchEvent *) event; + if (mouse_input_mode == 0) + break; + if (touchevent->touchPoints().count()) { + mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double) width(); + mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double) height(); + mouse_x_abs -= rendererWindow->destinationF.left(); + mouse_y_abs -= rendererWindow->destinationF.top(); - if (mouse_x_abs > 1) mouse_x_abs = 1; - if (mouse_y_abs > 1) mouse_y_abs = 1; - } - mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1); - touchevent->accept(); - return true; + if (mouse_x_abs < 0) + mouse_x_abs = 0; + if (mouse_y_abs < 0) + mouse_y_abs = 0; + + mouse_x_abs /= rendererWindow->destinationF.width(); + mouse_y_abs /= rendererWindow->destinationF.height(); + + if (mouse_x_abs > 1) + mouse_x_abs = 1; + if (mouse_y_abs > 1) + mouse_y_abs = 1; + } + mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1); + touchevent->accept(); + return true; #else - QTouchEvent* touchevent = (QTouchEvent*)event; - if (mouse_input_mode == 0) break; - if (touchevent->pointCount()) { - mouse_x_abs = (touchevent->point(0).position().x()) / (double)width(); - mouse_y_abs = (touchevent->point(0).position().y()) / (double)height(); - mouse_x_abs -= rendererWindow->destinationF.left(); - mouse_y_abs -= rendererWindow->destinationF.top(); - - if (mouse_x_abs < 0) mouse_x_abs = 0; - if (mouse_y_abs < 0) mouse_y_abs = 0; - - mouse_x_abs /= rendererWindow->destinationF.width(); - mouse_y_abs /= rendererWindow->destinationF.height(); + QTouchEvent *touchevent = (QTouchEvent *) event; + if (mouse_input_mode == 0) + break; + if (touchevent->pointCount()) { + mouse_x_abs = (touchevent->point(0).position().x()) / (double) width(); + mouse_y_abs = (touchevent->point(0).position().y()) / (double) height(); + mouse_x_abs -= rendererWindow->destinationF.left(); + mouse_y_abs -= rendererWindow->destinationF.top(); - if (mouse_x_abs > 1) mouse_x_abs = 1; - if (mouse_y_abs > 1) mouse_y_abs = 1; - } - mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1); - touchevent->accept(); - return true; + if (mouse_x_abs < 0) + mouse_x_abs = 0; + if (mouse_y_abs < 0) + mouse_y_abs = 0; + + mouse_x_abs /= rendererWindow->destinationF.width(); + mouse_y_abs /= rendererWindow->destinationF.height(); + + if (mouse_x_abs > 1) + mouse_x_abs = 1; + if (mouse_y_abs > 1) + mouse_y_abs = 1; + } + mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1); + touchevent->accept(); + return true; #endif + } + + default: + return QWidget::event(event); +#endif /*TOUCH_PR*/ } - default: - return QWidget::event(event); -#endif - } - return QWidget::event(event); } @@ -753,7 +777,7 @@ RendererStack::onResize(int width, int height) #ifdef Q_OS_WINDOWS if (mouse_capture) { RECT rect; - if (GetWindowRect((HWND)this->winId(), &rect)) { + if (GetWindowRect((HWND) this->winId(), &rect)) { ClipCursor(&rect); } } diff --git a/src/qt/qt_rendererstack.hpp b/src/qt/qt_rendererstack.hpp index a3a8d47f7..02bf85a85 100644 --- a/src/qt/qt_rendererstack.hpp +++ b/src/qt/qt_rendererstack.hpp @@ -24,9 +24,8 @@ namespace Ui { class RendererStack; } -extern "C" -{ - extern int vid_resize; +extern "C" { +extern int vid_resize; } class RendererCommon; @@ -54,16 +53,18 @@ public: if (this->m_monitor_index != 0 && vid_resize != 1) { int newX = pos().x(); int newY = pos().y(); - + if (((frameGeometry().x() + event->size().width() + 1) > util::screenOfWidget(this)->availableGeometry().right())) { - //move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y()); + // move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y()); newX = util::screenOfWidget(this)->availableGeometry().right() - frameGeometry().width() - 1; - if (newX < 1) newX = 1; + if (newX < 1) + newX = 1; } - + if (((frameGeometry().y() + event->size().height() + 1) > util::screenOfWidget(this)->availableGeometry().bottom())) { newY = util::screenOfWidget(this)->availableGeometry().bottom() - frameGeometry().height() - 1; - if (newY < 1) newY = 1; + if (newY < 1) + newY = 1; } move(newX, newY); } @@ -77,7 +78,7 @@ public: { event->ignore(); } - bool event(QEvent* event) override; + bool event(QEvent *event) override; enum class Renderer { Software, @@ -99,12 +100,12 @@ public: void setFocusRenderer(); void onResize(int width, int height); - QWidget* currentWidget() { return current.get(); } + QWidget *currentWidget() { return current.get(); } void (*mouse_capture_func)(QWindow *window) = nullptr; void (*mouse_uncapture_func)() = nullptr; - void (*mouse_exit_func)() = nullptr; + void (*mouse_exit_func)() = nullptr; signals: void blitToRenderer(int buf_idx, int x, int y, int w, int h); @@ -116,7 +117,7 @@ public slots: private: void createRenderer(Renderer renderer); - QBoxLayout* boxLayout = nullptr; + QBoxLayout *boxLayout = nullptr; Ui::RendererStack *ui; @@ -139,7 +140,7 @@ private: std::unique_ptr current; std::atomic_bool rendererTakesScreenshots; - std::atomic_bool switchInProgress{false}; + std::atomic_bool switchInProgress { false }; char auto_mouse_type[16]; }; diff --git a/src/qt/qt_settings.cpp b/src/qt/qt_settings.cpp index d892053f8..3920aaeb2 100644 --- a/src/qt/qt_settings.cpp +++ b/src/qt/qt_settings.cpp @@ -187,8 +187,7 @@ Settings::Settings(QWidget *parent) &SettingsOtherRemovable::reloadBusChannels_MO); connect(ui->listView->selectionModel(), &QItemSelectionModel::currentChanged, this, - [this](const QModelIndex ¤t, const QModelIndex &previous) { - ui->stackedWidget->setCurrentIndex(current.row()); }); + [this](const QModelIndex ¤t, const QModelIndex &previous) { ui->stackedWidget->setCurrentIndex(current.row()); }); ui->listView->setCurrentIndex(model->index(0, 0)); @@ -224,14 +223,12 @@ Settings::accept() { if (confirm_save && !settings_only) { QMessageBox questionbox(QMessageBox::Icon::Question, "86Box", - QStringLiteral("%1\n\n%2").arg(tr("Do you want to save the settings?"), - tr("This will hard reset the emulated machine.")), + QStringLiteral("%1\n\n%2").arg(tr("Do you want to save the settings?"), tr("This will hard reset the emulated machine.")), QMessageBox::Save | QMessageBox::Cancel, this); QCheckBox *chkbox = new QCheckBox(tr("Don't show this message again")); questionbox.setCheckBox(chkbox); chkbox->setChecked(!confirm_save); - QObject::connect(chkbox, &QCheckBox::stateChanged, [](int state) { - confirm_save = (state == Qt::CheckState::Unchecked); }); + QObject::connect(chkbox, &QCheckBox::stateChanged, [](int state) { confirm_save = (state == Qt::CheckState::Unchecked); }); questionbox.exec(); if (questionbox.result() == QMessageBox::Cancel) { confirm_save = true; diff --git a/src/qt/qt_settings_bus_tracking.cpp b/src/qt/qt_settings_bus_tracking.cpp index 9cfe6c8ac..aee57da1b 100644 --- a/src/qt/qt_settings_bus_tracking.cpp +++ b/src/qt/qt_settings_bus_tracking.cpp @@ -47,7 +47,7 @@ SettingsBusTracking::next_free_mke_channel() uint8_t ret = CHANNEL_NONE; for (uint8_t i = 0; i < 4; i++) { - mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); + mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); if (!(mke_tracking & mask)) { ret = (uint8_t) i; @@ -65,7 +65,7 @@ SettingsBusTracking::next_free_mfm_channel() uint8_t ret = CHANNEL_NONE; for (uint8_t i = 0; i < 2; i++) { - mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); + mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); if (!(mfm_tracking & mask)) { ret = (uint8_t) i; @@ -83,7 +83,7 @@ SettingsBusTracking::next_free_esdi_channel() uint8_t ret = CHANNEL_NONE; for (uint8_t i = 0; i < 2; i++) { - mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); + mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); if (!(esdi_tracking & mask)) { ret = (uint8_t) i; @@ -101,7 +101,7 @@ SettingsBusTracking::next_free_xta_channel() uint8_t ret = CHANNEL_NONE; for (uint8_t i = 0; i < 2; i++) { - mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); + mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f)); if (!(xta_tracking & mask)) { ret = (uint8_t) i; @@ -236,7 +236,9 @@ SettingsBusTracking::scsi_bus_full() return (count == 64); } -QList SettingsBusTracking::busChannelsInUse(const int bus) { +QList +SettingsBusTracking::busChannelsInUse(const int bus) +{ QList channelsInUse; int element; @@ -277,7 +279,7 @@ QList SettingsBusTracking::busChannelsInUse(const int bus) { case HDD_BUS_IDE: for (uint8_t i = 0; i < 32; i++) { element = ((i << 3) >> 6); - mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f)); + mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f)); if (ide_tracking[element] & mask) channelsInUse.append(i); } @@ -285,7 +287,7 @@ QList SettingsBusTracking::busChannelsInUse(const int bus) { case HDD_BUS_ATAPI: for (uint8_t i = 0; i < 32; i++) { element = ((i << 3) >> 6); - mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f)); + mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f)); if (ide_tracking[element] & mask) channelsInUse.append(i); } diff --git a/src/qt/qt_settingsdisplay.cpp b/src/qt/qt_settingsdisplay.cpp index 89a2530be..6df4d5edc 100644 --- a/src/qt/qt_settingsdisplay.cpp +++ b/src/qt/qt_settingsdisplay.cpp @@ -43,7 +43,7 @@ SettingsDisplay::SettingsDisplay(QWidget *parent) { ui->setupUi(this); - for (uint8_t i = 0; i < GFXCARD_MAX; i ++) + for (uint8_t i = 0; i < GFXCARD_MAX; i++) videoCard[i] = gfxcard[i]; ui->lineEditCustomEDID->setFilter(tr("EDID") % util::DlgFilter({ "bin", "dat", "edid", "txt" }) % tr("All files") % util::DlgFilter({ "*" }, true)); @@ -67,7 +67,7 @@ SettingsDisplay::save() } #else gfxcard[0] = ui->comboBoxVideo->currentData().toInt(); - for (uint8_t i = 1; i < GFXCARD_MAX; i ++) + for (uint8_t i = 1; i < GFXCARD_MAX; i++) gfxcard[i] = ui->comboBoxVideoSecondary->currentData().toInt(); #endif @@ -129,7 +129,7 @@ SettingsDisplay::onCurrentMachineChanged(int machineId) } ui->comboBoxVideo->setCurrentIndex(selectedRow); // TODO - for (uint8_t i = 1; i < GFXCARD_MAX; i ++) + for (uint8_t i = 1; i < GFXCARD_MAX; i++) if (gfxcard[i] == 0) ui->pushButtonConfigureVideoSecondary->setEnabled(false); @@ -142,8 +142,8 @@ SettingsDisplay::onCurrentMachineChanged(int machineId) void SettingsDisplay::on_pushButtonConfigureVideo_clicked() { - int videoCard = ui->comboBoxVideo->currentData().toInt(); - auto *device = video_card_getdevice(videoCard); + int videoCard = ui->comboBoxVideo->currentData().toInt(); + auto *device = video_card_getdevice(videoCard); if (videoCard == VID_INTERNAL) device = machine_get_vid_device(machineId); DeviceConfig::ConfigureDevice(device); @@ -185,11 +185,10 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) return; static QRegularExpression voodooRegex("3dfx|voodoo|banshee|raven", QRegularExpression::CaseInsensitiveOption); - auto curVideoCard_2 = videoCard[1]; - videoCard[0] = ui->comboBoxVideo->currentData().toInt(); + auto curVideoCard_2 = videoCard[1]; + videoCard[0] = ui->comboBoxVideo->currentData().toInt(); if (videoCard[0] == VID_INTERNAL) - ui->pushButtonConfigureVideo->setEnabled(machine_has_flags(machineId, MACHINE_VIDEO) && - device_has_config(machine_get_vid_device(machineId))); + ui->pushButtonConfigureVideo->setEnabled(machine_has_flags(machineId, MACHINE_VIDEO) && device_has_config(machine_get_vid_device(machineId))); else ui->pushButtonConfigureVideo->setEnabled(video_card_has_config(videoCard[0]) > 0); bool machineHasPci = machine_has_bus(machineId, MACHINE_BUS_PCI) > 0; @@ -203,7 +202,7 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) bool machineSupports8514 = ((machineHasIsa16 || machineHasMca) && !videoCardHas8514); bool machineSupportsXga = ((machineHasMca && device_available(&xga_device)) && !videoCardHasXga); - bool machineSupportsDa2 = machineHasMca && device_available(&ps55da2_device); + bool machineSupportsDa2 = machineHasMca && device_available(&ps55da2_device); ui->checkBox8514->setEnabled(machineSupports8514); ui->checkBox8514->setChecked(ibm8514_standalone_enabled && machineSupports8514); @@ -322,30 +321,32 @@ SettingsDisplay::on_pushButtonConfigureVideoSecondary_clicked() DeviceConfig::ConfigureDevice(device); } -void SettingsDisplay::on_radioButtonDefault_clicked() +void +SettingsDisplay::on_radioButtonDefault_clicked() { ui->radioButtonDefault->setChecked(true); ui->radioButtonCustom->setChecked(false); ui->lineEditCustomEDID->setEnabled(false); } - -void SettingsDisplay::on_radioButtonCustom_clicked() +void +SettingsDisplay::on_radioButtonCustom_clicked() { ui->radioButtonDefault->setChecked(false); ui->radioButtonCustom->setChecked(true); ui->lineEditCustomEDID->setEnabled(true); } -void SettingsDisplay::on_pushButtonExportDefault_clicked() +void +SettingsDisplay::on_pushButtonExportDefault_clicked() { auto str = QFileDialog::getSaveFileName(this, tr("Export EDID")); if (!str.isEmpty()) { QFile file(str); if (file.open(QFile::WriteOnly)) { uint8_t *bytes = nullptr; - auto size = ddc_create_default_edid(&bytes); - file.write((char*)bytes, size); + auto size = ddc_create_default_edid(&bytes); + file.write((char *) bytes, size); file.close(); } } diff --git a/src/qt/qt_settingsdisplay.hpp b/src/qt/qt_settingsdisplay.hpp index 8854b0373..d74aabfff 100644 --- a/src/qt/qt_settingsdisplay.hpp +++ b/src/qt/qt_settingsdisplay.hpp @@ -48,7 +48,7 @@ private slots: private: Ui::SettingsDisplay *ui; - int machineId = 0; + int machineId = 0; int videoCard[VIDEOCARD_MAX] = { 0, 0 }; }; diff --git a/src/qt/qt_settingsfloppycdrom.cpp b/src/qt/qt_settingsfloppycdrom.cpp index b1b099b62..a262d4eff 100644 --- a/src/qt/qt_settingsfloppycdrom.cpp +++ b/src/qt/qt_settingsfloppycdrom.cpp @@ -114,8 +114,8 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent) ui->setupUi(this); floppy_disabled_icon = QIcon(":/settings/qt/icons/floppy_disabled.ico"); - floppy_525_icon = QIcon(":/settings/qt/icons/floppy_525.ico"); - floppy_35_icon = QIcon(":/settings/qt/icons/floppy_35.ico"); + floppy_525_icon = QIcon(":/settings/qt/icons/floppy_525.ico"); + floppy_35_icon = QIcon(":/settings/qt/icons/floppy_35.ico"); auto *model = ui->comboBoxFloppyType->model(); int i = 0; @@ -135,7 +135,7 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent) model->setHeaderData(2, Qt::Horizontal, tr("Check BPB")); model->setHeaderData(3, Qt::Horizontal, tr("Audio")); -model->insertRows(0, FDD_NUM); + model->insertRows(0, FDD_NUM); /* Floppy drives category */ for (int i = 0; i < FDD_NUM; i++) { auto idx = model->index(i, 0); @@ -169,7 +169,7 @@ model->insertRows(0, FDD_NUM); connect(ui->tableViewFloppy->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &SettingsFloppyCDROM::onFloppyRowChanged); - + #ifndef DISABLE_FDD_AUDIO ui->comboBoxFloppyAudio->setVisible(true); int profile_count = fdd_audio_get_profile_count(); @@ -190,7 +190,7 @@ model->insertRows(0, FDD_NUM); onFloppyRowChanged(model->index(0, 0)); cdrom_disabled_icon = QIcon(":/settings/qt/icons/cdrom_disabled.ico"); - cdrom_icon = QIcon(":/settings/qt/icons/cdrom.ico"); + cdrom_icon = QIcon(":/settings/qt/icons/cdrom.ico"); Harddrives::populateCDROMBuses(ui->comboBoxBus->model()); model = ui->comboBoxSpeed->model(); @@ -204,8 +204,8 @@ model->insertRows(0, FDD_NUM); model->setHeaderData(2, Qt::Horizontal, tr("Type")); model->insertRows(0, CDROM_NUM); for (int i = 0; i < CDROM_NUM; i++) { - auto idx = model->index(i, 0); - int type = cdrom_get_type(i); + auto idx = model->index(i, 0); + int type = cdrom_get_type(i); setCDROMBus(model, idx, cdrom[i].bus_type, cdrom[i].res); setCDROMType(model, idx.siblingAtColumn(2), type); int speed = cdrom_get_speed(type); @@ -230,19 +230,16 @@ model->insertRows(0, FDD_NUM); ui->tableViewCDROM->setCurrentIndex(model->index(0, 0)); uint8_t bus_type = ui->comboBoxBus->currentData().toUInt(); - int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt(); + int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt(); auto *modelType = ui->comboBoxCDROMType->model(); int removeRows = modelType->rowCount(); uint32_t j = 0; - int selectedTypeRow = 0; - int eligibleRows = 0; + int selectedTypeRow = 0; + int eligibleRows = 0; while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) { - if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) || - (bus_type == CDROM_BUS_SCSI)) && - ((cdrom_drive_types[j].bus_type == bus_type) || - ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) { + if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) || (bus_type == CDROM_BUS_SCSI)) && ((cdrom_drive_types[j].bus_type == bus_type) || ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) { QString name = CDROMName(j); Models::AddEntry(modelType, name, j); if (cdrom[cdromIdx].type == j) @@ -278,16 +275,16 @@ SettingsFloppyCDROM::save() /* Removable devices category */ model = ui->tableViewCDROM->model(); for (int i = 0; i < CDROM_NUM; i++) { - cdrom[i].priv = NULL; - cdrom[i].ops = NULL; - cdrom[i].local = NULL; - cdrom[i].insert = NULL; - cdrom[i].close = NULL; - cdrom[i].get_volume = NULL; + cdrom[i].priv = NULL; + cdrom[i].ops = NULL; + cdrom[i].local = NULL; + cdrom[i].insert = NULL; + cdrom[i].close = NULL; + cdrom[i].get_volume = NULL; cdrom[i].get_channel = NULL; - cdrom[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt(); - cdrom[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt(); - cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt(); + cdrom[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt(); + cdrom[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt(); + cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt(); cdrom_set_type(i, model->index(i, 2).data(Qt::UserRole).toInt()); } @@ -306,7 +303,7 @@ SettingsFloppyCDROM::onFloppyRowChanged(const QModelIndex ¤t) ui->checkBoxTurboTimings->setChecked(current.siblingAtColumn(1).data() == tr("On")); ui->checkBoxCheckBPB->setChecked(current.siblingAtColumn(2).data() == tr("On")); - int prof = current.siblingAtColumn(3).data(Qt::UserRole).toInt(); + int prof = current.siblingAtColumn(3).data(Qt::UserRole).toInt(); int comboIndex = ui->comboBoxFloppyAudio->findData(prof); ui->comboBoxFloppyAudio->setCurrentIndex(comboIndex); } @@ -319,9 +316,9 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t) uint32_t type = current.siblingAtColumn(2).data(Qt::UserRole).toUInt(); ui->comboBoxBus->setCurrentIndex(-1); - auto* model = ui->comboBoxBus->model(); - auto match = model->match(model->index(0, 0), Qt::UserRole, bus); - if (! match.isEmpty()) + auto *model = ui->comboBoxBus->model(); + auto match = model->match(model->index(0, 0), Qt::UserRole, bus); + if (!match.isEmpty()) ui->comboBoxBus->setCurrentIndex(match.first().row()); model = ui->comboBoxChannel->model(); @@ -329,9 +326,9 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t) if (!match.isEmpty()) ui->comboBoxChannel->setCurrentIndex(match.first().row()); - int speed = cdrom_get_speed(type); + int speed = cdrom_get_speed(type); if (speed == -1) { - speed = current.siblingAtColumn(1).data(Qt::UserRole).toUInt(); + speed = current.siblingAtColumn(1).data(Qt::UserRole).toUInt(); ui->comboBoxSpeed->setEnabled((bus == CDROM_BUS_DISABLED) ? false : true); } else ui->comboBoxSpeed->setEnabled(false); @@ -341,13 +338,10 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t) int removeRows = modelType->rowCount(); uint32_t j = 0; - int selectedTypeRow = 0; - int eligibleRows = 0; + int selectedTypeRow = 0; + int eligibleRows = 0; while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) { - if (((bus == CDROM_BUS_MKE) || (bus == CDROM_BUS_ATAPI) || - (bus == CDROM_BUS_SCSI)) && - ((cdrom_drive_types[j].bus_type == bus) || - ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus != BUS_TYPE_MKE)))) { + if (((bus == CDROM_BUS_MKE) || (bus == CDROM_BUS_ATAPI) || (bus == CDROM_BUS_SCSI)) && ((cdrom_drive_types[j].bus_type == bus) || ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus != BUS_TYPE_MKE)))) { QString name = CDROMName(j); Models::AddEntry(modelType, name, j); if (type == j) @@ -368,19 +362,16 @@ void SettingsFloppyCDROM::on_checkBoxTurboTimings_stateChanged(int arg1) { auto idx = ui->tableViewFloppy->selectionModel()->currentIndex(); - ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(1), arg1 == Qt::Checked ? - tr("On") : tr("Off")); + ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(1), arg1 == Qt::Checked ? tr("On") : tr("Off")); } void SettingsFloppyCDROM::on_checkBoxCheckBPB_stateChanged(int arg1) { auto idx = ui->tableViewFloppy->selectionModel()->currentIndex(); - ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(2), arg1 == Qt::Checked ? - tr("On") : tr("Off")); + ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(2), arg1 == Qt::Checked ? tr("On") : tr("Off")); } - void SettingsFloppyCDROM::on_comboBoxFloppyType_activated(int index) { @@ -412,7 +403,9 @@ SettingsFloppyCDROM::on_comboBoxFloppyAudio_activated(int) ui->tableViewFloppy->model()->setData(audioIdx, prof, Qt::UserRole); } -void SettingsFloppyCDROM::reloadBusChannels() { +void +SettingsFloppyCDROM::reloadBusChannels() +{ auto selected = ui->comboBoxChannel->currentIndex(); Harddrives::populateBusChannels(ui->comboBoxChannel->model(), ui->comboBoxBus->currentData().toInt(), Harddrives::busTrackClass); ui->comboBoxChannel->setCurrentIndex(selected); @@ -447,9 +440,7 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int) uint8_t bus_type = ui->comboBoxBus->currentData().toUInt(); int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt(); - Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt()); if (bus_type == CDROM_BUS_MKE) ui->comboBoxChannel->setCurrentIndex(Harddrives::busTrackClass->next_free_mke_channel()); else if (bus_type == CDROM_BUS_ATAPI) @@ -463,21 +454,16 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int) ui->tableViewCDROM->selectionModel()->currentIndex(), bus_type, ui->comboBoxChannel->currentData().toUInt()); - Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt()); auto *modelType = ui->comboBoxCDROMType->model(); int removeRows = modelType->rowCount(); - uint32_t j = 0; - int selectedTypeRow = 0; - int eligibleRows = 0; + uint32_t j = 0; + int selectedTypeRow = 0; + int eligibleRows = 0; while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) { - if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) || - (bus_type == CDROM_BUS_SCSI)) && - ((cdrom_drive_types[j].bus_type == bus_type) || - ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) { + if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) || (bus_type == CDROM_BUS_SCSI)) && ((cdrom_drive_types[j].bus_type == bus_type) || ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) { QString name = CDROMName(j); Models::AddEntry(modelType, name, j); if (cdrom[cdromIdx].type == j) @@ -502,7 +488,7 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int) } else { ui->comboBoxSpeed->setEnabled(false); if (bus_type == CDROM_BUS_MITSUMI) // temp hack - speed = 0; + speed = 0; } ui->comboBoxSpeed->setCurrentIndex(speed == 0 ? 7 : speed - 1); setCDROMSpeed(ui->tableViewCDROM->model(), @@ -514,10 +500,10 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int) void SettingsFloppyCDROM::enableCurrentlySelectedChannel() { - const auto *item_model = qobject_cast(ui->comboBoxChannel->model()); + const auto *item_model = qobject_cast(ui->comboBoxChannel->model()); const auto index = ui->comboBoxChannel->currentIndex(); auto *item = item_model->item(index); - if(item) + if (item) item->setEnabled(true); } @@ -525,16 +511,12 @@ void SettingsFloppyCDROM::on_comboBoxChannel_activated(int) { auto i = ui->tableViewCDROM->selectionModel()->currentIndex().siblingAtColumn(0); - Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt()); setCDROMBus(ui->tableViewCDROM->model(), ui->tableViewCDROM->selectionModel()->currentIndex(), ui->comboBoxBus->currentData().toUInt(), ui->comboBoxChannel->currentData().toUInt()); - Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt()); emit cdromChannelChanged(); } diff --git a/src/qt/qt_settingsfloppycdrom.hpp b/src/qt/qt_settingsfloppycdrom.hpp index 9a53dd88f..98ca73c2c 100644 --- a/src/qt/qt_settingsfloppycdrom.hpp +++ b/src/qt/qt_settingsfloppycdrom.hpp @@ -35,12 +35,11 @@ private slots: void on_comboBoxSpeed_activated(int index); void on_comboBoxCDROMType_activated(int index); - private: Ui::SettingsFloppyCDROM *ui; - void setFloppyType(QAbstractItemModel *model, const QModelIndex &idx, int type); - void setCDROMBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel); - void enableCurrentlySelectedChannel(); + void setFloppyType(QAbstractItemModel *model, const QModelIndex &idx, int type); + void setCDROMBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel); + void enableCurrentlySelectedChannel(); QIcon floppy_disabled_icon; QIcon floppy_525_icon; diff --git a/src/qt/qt_settingsharddisks.cpp b/src/qt/qt_settingsharddisks.cpp index 3f0447dff..0f12c8e6f 100644 --- a/src/qt/qt_settingsharddisks.cpp +++ b/src/qt/qt_settingsharddisks.cpp @@ -74,12 +74,12 @@ static void addRow(QAbstractItemModel *model, hard_disk_t *hd) { const QString userPath = usr_path; - int row = model->rowCount(); + int row = model->rowCount(); model->insertRow(row); - auto busIndex = model->index(row, ColumnBus); - QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel); + auto busIndex = model->index(row, ColumnBus); + QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel); model->setData(busIndex, busName); model->setData(busIndex, hard_disk_icon, Qt::DecorationRole); model->setData(busIndex, hd->bus_type, DataBus); @@ -87,8 +87,8 @@ addRow(QAbstractItemModel *model, hard_disk_t *hd) model->setData(busIndex, hd->channel, DataBusChannel); model->setData(busIndex, hd->channel, DataBusChannelPrevious); Harddrives::busTrackClass->device_track(1, DEV_HDD, hd->bus_type, hd->channel); - auto filenameIndex = model->index(row, ColumnFilename); - QString fileName = hd->fn; + auto filenameIndex = model->index(row, ColumnFilename); + QString fileName = hd->fn; if (fileName.startsWith(userPath, Qt::CaseInsensitive)) model->setData(filenameIndex, fileName.mid(userPath.size())); else @@ -169,7 +169,9 @@ SettingsHarddisks::save() } } -void SettingsHarddisks::reloadBusChannels() { +void +SettingsHarddisks::reloadBusChannels() +{ const auto selected = ui->comboBoxChannel->currentIndex(); Harddrives::populateBusChannels(ui->comboBoxChannel->model(), ui->comboBoxBus->currentData().toInt(), Harddrives::busTrackClass); ui->comboBoxChannel->setCurrentIndex(selected); @@ -248,10 +250,10 @@ SettingsHarddisks::on_comboBoxChannel_currentIndexChanged(int index) void SettingsHarddisks::enableCurrentlySelectedChannel() { - const auto *item_model = qobject_cast(ui->comboBoxChannel->model()); - const auto index = ui->comboBoxChannel->currentIndex(); - auto *item = item_model->item(index); - if(item) + const auto *item_model = qobject_cast(ui->comboBoxChannel->model()); + const auto index = ui->comboBoxChannel->currentIndex(); + auto *item = item_model->item(index); + if (item) item->setEnabled(true); } @@ -359,8 +361,8 @@ SettingsHarddisks::on_pushButtonRemove_clicked() if (!idx.isValid()) return; - auto *model = ui->tableView->model(); - const auto col = idx.siblingAtColumn(ColumnBus); + auto *model = ui->tableView->model(); + const auto col = idx.siblingAtColumn(ColumnBus); Harddrives::busTrackClass->device_track(0, DEV_HDD, model->data(col, DataBus).toInt(), model->data(col, DataBusChannel).toInt()); model->removeRow(idx.row()); ui->pushButtonNew->setEnabled(true); diff --git a/src/qt/qt_settingsinput.cpp b/src/qt/qt_settingsinput.cpp index 1bee01df6..3ba74d372 100644 --- a/src/qt/qt_settingsinput.cpp +++ b/src/qt/qt_settingsinput.cpp @@ -61,7 +61,7 @@ SettingsInput::SettingsInput(QWidget *parent) keyTable->setColumnWidth(0, 200); keyTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); QStringList headers; - //headers << "Action" << "Bound key"; + // headers << "Action" << "Bound key"; keyTable->setHorizontalHeaderLabels(horizontalHeader); keyTable->verticalHeader()->setVisible(false); keyTable->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -71,7 +71,7 @@ SettingsInput::SettingsInput(QWidget *parent) // Make a working copy of acc_keys so we can check for dupes later without getting // confused - for(int x = 0; x < NUM_ACCELS; x++) { + for (int x = 0; x < NUM_ACCELS; x++) { strcpy(acc_keys_t[x].name, acc_keys[x].name); strcpy(acc_keys_t[x].desc, acc_keys[x].desc); strcpy(acc_keys_t[x].seq, acc_keys[x].seq); @@ -96,7 +96,7 @@ SettingsInput::save() joystick_type[0] = ui->comboBoxJoystick0->currentData().toInt(); // Copy accelerators from working set to global set - for(int x = 0; x < NUM_ACCELS; x++) { + for (int x = 0; x < NUM_ACCELS; x++) { strcpy(acc_keys[x].name, acc_keys_t[x].name); strcpy(acc_keys[x].desc, acc_keys_t[x].desc); strcpy(acc_keys[x].seq, acc_keys_t[x].seq); @@ -111,7 +111,7 @@ SettingsInput::onCurrentMachineChanged(int machineId) this->machineId = machineId; auto *keyboardModel = ui->comboBoxKeyboard->model(); - auto removeRows = keyboardModel->rowCount(); + auto removeRows = keyboardModel->rowCount(); int selectedRow = 0; @@ -119,11 +119,10 @@ SettingsInput::onCurrentMachineChanged(int machineId) int has_int_kbd = !!machine_has_flags(machineId, MACHINE_KEYBOARD); for (int i = 0; i < keyboard_get_ndev(); ++i) { - const auto *dev = keyboard_get_device(i); - int ikbd = (i == KEYBOARD_TYPE_INTERNAL); + const auto *dev = keyboard_get_device(i); + int ikbd = (i == KEYBOARD_TYPE_INTERNAL); - int pc5086_filter = (strstr(keyboard_get_internal_name(i), "ps") && - machines[machineId].init == machine_xt_pc5086_init); + int pc5086_filter = (strstr(keyboard_get_internal_name(i), "ps") && machines[machineId].init == machine_xt_pc5086_init); if ((ikbd != has_int_kbd) || !device_is_valid(dev, machineId) || pc5086_filter) continue; @@ -209,7 +208,7 @@ void SettingsInput::on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) { // Enable/disable bind/clear buttons if user clicked valid row - QTableWidgetItem *cell = ui->tableKeys->item(currentRow,1); + QTableWidgetItem *cell = ui->tableKeys->item(currentRow, 1); if (!cell) { ui->pushButtonBind->setEnabled(false); ui->pushButtonClearBind->setEnabled(false); @@ -223,7 +222,7 @@ void SettingsInput::on_tableKeys_cellDoubleClicked(int row, int col) { // Edit bind - QTableWidgetItem *cell = ui->tableKeys->item(row,1); + QTableWidgetItem *cell = ui->tableKeys->item(row, 1); if (!cell) return; @@ -236,8 +235,8 @@ SettingsInput::on_tableKeys_cellDoubleClicked(int row, int col) // Otherwise, check for conflicts. // Check against the *working* copy - NOT the one in use by the app, // so we don't test against shortcuts the user already changed. - for(int x = 0; x < NUM_ACCELS; x++) { - if(QString::fromStdString(acc_keys_t[x].seq) == keyseq.toString(QKeySequence::PortableText)) { + for (int x = 0; x < NUM_ACCELS; x++) { + if (QString::fromStdString(acc_keys_t[x].seq) == keyseq.toString(QKeySequence::PortableText)) { // That key is already in use QMessageBox::warning(this, tr("Bind conflict"), tr("This key combo is already in use."), QMessageBox::StandardButton::Ok); return; @@ -247,7 +246,7 @@ SettingsInput::on_tableKeys_cellDoubleClicked(int row, int col) // Go ahead and apply the bind. // Find the correct accelerator key entry - int accKeyID = FindAccelerator(ui->tableKeys->item(row,2)->text().toUtf8().constData()); + int accKeyID = FindAccelerator(ui->tableKeys->item(row, 2)->text().toUtf8().constData()); if (accKeyID < 0) return; // this should never happen @@ -280,7 +279,7 @@ SettingsInput::on_pushButtonClearBind_clicked() cell->setText(""); // Find the correct accelerator key entry - int accKeyID = FindAccelerator(ui->tableKeys->item(cell->row(),2)->text().toUtf8().constData()); + int accKeyID = FindAccelerator(ui->tableKeys->item(cell->row(), 2)->text().toUtf8().constData()); if (accKeyID < 0) return; // this should never happen diff --git a/src/qt/qt_settingsinput.hpp b/src/qt/qt_settingsinput.hpp index 68748fa36..d75c94432 100644 --- a/src/qt/qt_settingsinput.hpp +++ b/src/qt/qt_settingsinput.hpp @@ -47,7 +47,7 @@ private slots: private: Ui::SettingsInput *ui; int machineId = 0; - void refreshInputList(); + void refreshInputList(); }; #endif // QT_SETTINGSINPUT_HPP diff --git a/src/qt/qt_settingsmachine.cpp b/src/qt/qt_settingsmachine.cpp index ae03f4d38..e4faeb5ce 100644 --- a/src/qt/qt_settingsmachine.cpp +++ b/src/qt/qt_settingsmachine.cpp @@ -60,10 +60,10 @@ SettingsMachine::SettingsMachine(QWidget *parent) } auto machineListCompleter = new QCompleter(ui->lineEditSearch); - auto machineListModel = new QStandardItemModel(machineListCompleter); + auto machineListModel = new QStandardItemModel(machineListCompleter); machineListCompleter->setModel(machineListModel); ui->lineEditSearch->setCompleter(machineListCompleter); - connect(ui->lineEditSearch, &QLineEdit::editingFinished, this, [this] () { ui->lineEditSearch->setText("");} ); + connect(ui->lineEditSearch, &QLineEdit::editingFinished, this, [this]() { ui->lineEditSearch->setText(""); }); machineListCompleter->setCompletionMode(QCompleter::PopupCompletion); machineListCompleter->setFilterMode(Qt::MatchContains); machineListCompleter->setCompletionRole(Qt::DisplayRole); @@ -101,7 +101,7 @@ SettingsMachine::SettingsMachine(QWidget *parent) ui->comboBoxPitMode->setCurrentIndex(pit_mode + 1); int selectedMachineType = 0; - auto * machineTypesModel = ui->comboBoxMachineType->model(); + auto *machineTypesModel = ui->comboBoxMachineType->model(); int i = -1; int j = 0; int cur_j = 0; @@ -116,12 +116,12 @@ SettingsMachine::SettingsMachine(QWidget *parent) selectedMachineType = row; } - i = machine_get_type(j); + i = machine_get_type(j); cur_j = 0; } if (machine_available(j)) { - QStandardItem* item = new QStandardItem(machines[j].name); + QStandardItem *item = new QStandardItem(machines[j].name); item->setData(machine_types[machine_get_type(j)].id); machineListModel->appendRow(item); @@ -137,10 +137,10 @@ SettingsMachine::SettingsMachine(QWidget *parent) ui->radioButtonLargerFrames->setChecked(force_10ms); ui->radioButtonSmallerFrames->setChecked(!force_10ms); - connect(machineListCompleter, QOverload::of(&QCompleter::activated), this, [this] (const QModelIndex& idx) { + connect(machineListCompleter, QOverload::of(&QCompleter::activated), this, [this](const QModelIndex &idx) { ui->lineEditSearch->setText(""); - int machineIdType = idx.model()->data(idx, Qt::UserRole + 1).toInt(); - auto name = idx.model()->data(idx, Qt::DisplayRole).toString(); + int machineIdType = idx.model()->data(idx, Qt::UserRole + 1).toInt(); + auto name = idx.model()->data(idx, Qt::DisplayRole).toString(); for (int i = 0; i < ui->comboBoxMachineType->model()->rowCount(); i++) { if (ui->comboBoxMachineType->model()->data(ui->comboBoxMachineType->model()->index(i, 0), Qt::UserRole).toInt() == machineIdType) { ui->comboBoxMachineType->setCurrentIndex(i); @@ -215,8 +215,7 @@ SettingsMachine::on_comboBoxMachineType_currentIndexChanged(int index) int selectedMachineRow = 0; for (int i = 0; i < machine_count(); ++i) { - if ((machine_get_type(i) == ui->comboBoxMachineType->currentData().toInt()) && - machine_available(i)) { + if ((machine_get_type(i) == ui->comboBoxMachineType->currentData().toInt()) && machine_available(i)) { int row = Models::AddEntry(model, machines[i].name, i); if (i == machine) selectedMachineRow = row - removeRows; @@ -246,8 +245,7 @@ SettingsMachine::on_comboBoxMachine_currentIndexChanged(int index) int selectedCpuFamilyRow = 0; while (cpu_families[i].package != 0) { if (cpu_family_is_eligible(&cpu_families[i], machineId)) { - Models::AddEntry(modelCpu, QString("%1 %2").arg(cpu_families[i].manufacturer, - cpu_families[i].name), i); + Models::AddEntry(modelCpu, QString("%1 %2").arg(cpu_families[i].manufacturer, cpu_families[i].name), i); if (&cpu_families[i] == cpu_f) selectedCpuFamilyRow = eligibleRows; ++eligibleRows; @@ -346,7 +344,7 @@ SettingsMachine::on_comboBoxSpeed_currentIndexChanged(int index) int i = 0; int selectedFpuRow = 0; - for (const char *fpuName = fpu_get_name_from_index(cpuFamily, cpuId, i); + for (const char *fpuName = fpu_get_name_from_index(cpuFamily, cpuId, i); fpuName != nullptr; fpuName = fpu_get_name_from_index(cpuFamily, cpuId, ++i)) { auto fpuType = fpu_get_type_from_index(cpuFamily, cpuId, i); Models::AddEntry(modelFpu, tr(QString("%1").arg(fpuName).toUtf8().data()), fpuType); @@ -374,10 +372,8 @@ SettingsMachine::on_comboBoxFPU_currentIndexChanged(int index) ui->checkBoxFPUSoftfloat->setChecked(false); ui->checkBoxFPUSoftfloat->setEnabled(false); } else { - ui->checkBoxFPUSoftfloat->setChecked(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ? - true : fpu_softfloat); - ui->checkBoxFPUSoftfloat->setEnabled(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ? - false : true); + ui->checkBoxFPUSoftfloat->setChecked(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ? true : fpu_softfloat); + ui->checkBoxFPUSoftfloat->setEnabled(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ? false : true); } } } @@ -391,8 +387,10 @@ SettingsMachine::on_pushButtonConfigure_clicked() DeviceConfig::ConfigureDevice(device); } -void SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state) { - if(state == Qt::Checked) { +void +SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state) +{ + if (state == Qt::Checked) { ui->softFloatWarningIcon->setVisible(true); ui->softFloatWarningText->setVisible(true); } else { @@ -401,13 +399,14 @@ void SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state) { } } -void SettingsMachine::on_radioButtonSmallerFrames_clicked() +void +SettingsMachine::on_radioButtonSmallerFrames_clicked() { ui->radioButtonLargerFrames->setChecked(false); } - -void SettingsMachine::on_radioButtonLargerFrames_clicked() +void +SettingsMachine::on_radioButtonLargerFrames_clicked() { ui->radioButtonSmallerFrames->setChecked(false); } diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 16a885411..fec607b97 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -37,8 +37,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) auto *intf_label = findChild(QString("labelIntf%1").arg(i + 1)); auto *intf_cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); - auto *conf_btn = findChild(QString("pushButtonConf%1").arg(i + 1)); -// auto *net_type_conf_btn = findChild(QString("pushButtonNetTypeConf%1").arg(i + 1)); + auto *conf_btn = findChild(QString("pushButtonConf%1").arg(i + 1)); + // auto *net_type_conf_btn = findChild(QString("pushButtonNetTypeConf%1").arg(i + 1)); auto *vde_socket_label = findChild(QString("labelSocketVDENIC%1").arg(i + 1)); auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); @@ -51,14 +51,14 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) // Switch group auto *switch_group_label = findChild(QString("labelSwitch%1").arg(i + 1)); -// auto *switch_group_hlayout = findChild(QString("HLayoutSwitch%1").arg(i + 1)); -// auto *switch_group_hspacer = findChild(QString("horizontalSpacerSwitch%1").arg(i + 1)); + // auto *switch_group_hlayout = findChild(QString("HLayoutSwitch%1").arg(i + 1)); + // auto *switch_group_hspacer = findChild(QString("horizontalSpacerSwitch%1").arg(i + 1)); auto *switch_group_value = findChild(QString("spinnerSwitch%1").arg(i + 1)); switch_group_value->setMinimum(1); switch_group_value->setMaximum(10); // Promiscuous option - auto *promisc_label = findChild(QString("labelPromisc%1").arg(i + 1)); + auto *promisc_label = findChild(QString("labelPromisc%1").arg(i + 1)); auto *promisc_value = findChild(QString("boxPromisc%1").arg(i + 1)); // Remote switch hostname @@ -68,7 +68,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) bridge_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_TAP); intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP); conf_btn->setEnabled(network_card_has_config(nic_cbox->currentData().toInt())); -// net_type_conf_btn->setEnabled(network_type_has_config(netType)); + // net_type_conf_btn->setEnabled(network_type_has_config(netType)); // NEW STUFF // Make all options invisible by default @@ -76,7 +76,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) // Switch group switch_group_label->setVisible(false); switch_group_value->setVisible(false); -// switch_group_hspacer->setVisible(false); + // switch_group_hspacer->setVisible(false); // Promiscuous options promisc_label->setVisible(false); @@ -103,7 +103,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) intf_label->setVisible(false); // Don't enable anything unless there's a nic selected - if(nic_cbox->currentData().toInt() != 0) { + if (nic_cbox->currentData().toInt() != 0) { // Then only enable as needed based on network type switch (net_type_cbox->currentData().toInt()) { #ifdef HAS_VDE @@ -138,15 +138,15 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) #endif #ifdef USE_NETSWITCH - case NET_TYPE_NMSWITCH: -// option_list_label->setText("Local Switch Options"); + case NET_TYPE_NMSWITCH: + // option_list_label->setText("Local Switch Options"); option_list_label->setVisible(true); option_list_line->setVisible(true); // Switch group switch_group_label->setVisible(true); switch_group_value->setVisible(true); -// switch_group_hspacer->setVisible(false); + // switch_group_hspacer->setVisible(false); // Promiscuous options promisc_label->setVisible(true); @@ -154,14 +154,14 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) break; case NET_TYPE_NRSWITCH: -// option_list_label->setText("Remote Switch Options"); + // option_list_label->setText("Remote Switch Options"); option_list_label->setVisible(true); option_list_line->setVisible(true); // Switch group switch_group_label->setVisible(true); switch_group_value->setVisible(true); -// switch_group_hspacer->setVisible(false); + // switch_group_hspacer->setVisible(false); // Hostname hostname_label->setVisible(true); @@ -204,12 +204,12 @@ void SettingsNetwork::save() { for (int i = 0; i < NET_CARD_MAX; ++i) { - auto *cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); + auto *cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); #ifdef HAS_VDE - auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); + auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); #endif #if defined(__unix__) || defined(__APPLE__) - auto *bridge_line = findChild(QString("bridgeTAPNIC%1").arg(i + 1)); + auto *bridge_line = findChild(QString("bridgeTAPNIC%1").arg(i + 1)); #endif net_cards_conf[i].device_num = cbox->currentData().toInt(); cbox = findChild(QString("comboBoxNet%1").arg(i + 1)); @@ -249,15 +249,15 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) { this->machineId = machineId; - int c = 0; - int selectedRow = 0; + int c = 0; + int selectedRow = 0; // Network Card - QComboBox *cbox_[NET_CARD_MAX] = { 0 }; - QAbstractItemModel *models[NET_CARD_MAX] = { 0 }; - int removeRows_[NET_CARD_MAX] = { 0 }; - int selectedRows[NET_CARD_MAX] = { 0 }; - int m_has_net = machine_has_flags(machineId, MACHINE_NIC); + QComboBox *cbox_[NET_CARD_MAX] = { 0 }; + QAbstractItemModel *models[NET_CARD_MAX] = { 0 }; + int removeRows_[NET_CARD_MAX] = { 0 }; + int selectedRows[NET_CARD_MAX] = { 0 }; + int m_has_net = machine_has_flags(machineId, MACHINE_NIC); for (uint8_t i = 0; i < NET_CARD_MAX; ++i) { cbox_[i] = findChild(QString("comboBoxNIC%1").arg(i + 1)); @@ -286,7 +286,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) } } - c++; + c++; } for (uint8_t i = 0; i < NET_CARD_MAX; ++i) { @@ -308,17 +308,17 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) if (network_devmap.has_vde) Models::AddEntry(model, "VDE", NET_TYPE_VDE); #endif - + #if defined(__unix__) || defined(__APPLE__) Models::AddEntry(model, "TAP", NET_TYPE_TAP); #endif #ifdef USE_NETSWITCH Models::AddEntry(model, "Local Switch", NET_TYPE_NMSWITCH); -#ifdef ENABLE_NET_NRSWITCH +# ifdef ENABLE_NET_NRSWITCH Models::AddEntry(model, "Remote Switch", NET_TYPE_NRSWITCH); -#endif /* ENABLE_NET_NRSWITCH */ -#endif /* USE_NETSWITCH */ +# endif /* ENABLE_NET_NRSWITCH */ +#endif /* USE_NETSWITCH */ model->removeRows(0, removeRows); cbox->setCurrentIndex(cbox->findData(net_cards_conf[i].net_type)); @@ -343,7 +343,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) if (net_cards_conf[i].net_type == NET_TYPE_VDE) { #ifdef HAS_VDE QString currentVdeSocket = net_cards_conf[i].host_dev_name; - auto editline = findChild(QString("socketVDENIC%1").arg(i+1)); + auto editline = findChild(QString("socketVDENIC%1").arg(i + 1)); editline->setText(currentVdeSocket); #else ; @@ -351,7 +351,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) #if defined(__unix__) || defined(__APPLE__) } else if (net_cards_conf[i].net_type == NET_TYPE_TAP) { QString currentTapDevice = net_cards_conf[i].host_dev_name; - auto editline = findChild(QString("bridgeTAPNIC%1").arg(i+1)); + auto editline = findChild(QString("bridgeTAPNIC%1").arg(i + 1)); editline->setText(currentTapDevice); #endif #ifdef USE_NETSWITCH diff --git a/src/qt/qt_settingsotherperipherals.cpp b/src/qt/qt_settingsotherperipherals.cpp index 89254b8ee..f408bda95 100644 --- a/src/qt/qt_settingsotherperipherals.cpp +++ b/src/qt/qt_settingsotherperipherals.cpp @@ -68,8 +68,8 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId) if (auto *cb = findChild(QString("comboBoxIsaRomCard%1").arg(i + 1))) cb->clear(); - int c = 0; - int selectedRow = 0; + int c = 0; + int selectedRow = 0; // ISA RTC Cards auto *model = ui->comboBoxRTC->model(); @@ -127,8 +127,7 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId) isamem_cbox[i]->setEnabled(isamem_models[i]->rowCount() > 1); isamem_cbox[i]->setCurrentIndex(-1); isamem_cbox[i]->setCurrentIndex(isamem_selectedRows[i]); - findChild(QString("pushButtonConfigureIsaMemCard%1").arg(i + 1))->setEnabled((isamem_type[i] != 0) && - isamem_has_config(isamem_type[i]) && machineHasIsa); + findChild(QString("pushButtonConfigureIsaMemCard%1").arg(i + 1))->setEnabled((isamem_type[i] != 0) && isamem_has_config(isamem_type[i]) && machineHasIsa); } // ISA ROM Expansion Cards @@ -168,8 +167,7 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId) isarom_cbox[i]->setEnabled(isarom_models[i]->rowCount() > 1); isarom_cbox[i]->setCurrentIndex(-1); isarom_cbox[i]->setCurrentIndex(isarom_selectedRows[i]); - findChild(QString("pushButtonConfigureIsaRomCard%1").arg(i + 1))->setEnabled((isarom_type[i] != 0) && - isarom_has_config(isarom_type[i]) && machineHasIsa); + findChild(QString("pushButtonConfigureIsaRomCard%1").arg(i + 1))->setEnabled((isarom_type[i] != 0) && isarom_has_config(isarom_type[i]) && machineHasIsa); } } @@ -348,12 +346,14 @@ SettingsOtherPeripherals::on_pushButtonConfigureUT_clicked() DeviceConfig::ConfigureDevice(&unittester_device); } -void SettingsOtherPeripherals::on_checkBoxKeyCard_stateChanged(int arg1) +void +SettingsOtherPeripherals::on_checkBoxKeyCard_stateChanged(int arg1) { ui->pushButtonConfigureKeyCard->setEnabled(arg1 != 0); } -void SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked() +void +SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked() { DeviceConfig::ConfigureDevice(&novell_keycard_device); } diff --git a/src/qt/qt_settingsotherremovable.cpp b/src/qt/qt_settingsotherremovable.cpp index dde8e9bb6..7b3bb89f6 100644 --- a/src/qt/qt_settingsotherremovable.cpp +++ b/src/qt/qt_settingsotherremovable.cpp @@ -32,15 +32,13 @@ extern "C" { static QString moDriveTypeName(int i) { - return QString("%1 %2 %3").arg(mo_drive_types[i].vendor, mo_drive_types[i].model, - mo_drive_types[i].revision); + return QString("%1 %2 %3").arg(mo_drive_types[i].vendor, mo_drive_types[i].model, mo_drive_types[i].revision); } static QString rdiskDriveTypeName(int i) { - return QString("%1 %2 %3").arg(rdisk_drive_types[i].vendor, rdisk_drive_types[i].model, - rdisk_drive_types[i].revision); + return QString("%1 %2 %3").arg(rdisk_drive_types[i].vendor, rdisk_drive_types[i].model, rdisk_drive_types[i].revision); } void @@ -120,7 +118,7 @@ SettingsOtherRemovable::SettingsOtherRemovable(QWidget *parent) ui->setupUi(this); mo_disabled_icon = QIcon(":/settings/qt/icons/mo_disabled.ico"); - mo_icon = QIcon(":/settings/qt/icons/mo.ico"); + mo_icon = QIcon(":/settings/qt/icons/mo.ico"); Harddrives::populateRemovableBuses(ui->comboBoxMOBus->model()); ui->comboBoxMOBus->model()->removeRows(3, ui->comboBoxMOBus->model()->rowCount() - 3); @@ -147,11 +145,11 @@ SettingsOtherRemovable::SettingsOtherRemovable(QWidget *parent) ui->tableViewMO->setCurrentIndex(model->index(0, 0)); rdisk_disabled_icon = QIcon(":/settings/qt/icons/rdisk_disabled.ico"); - rdisk_icon = QIcon(":/settings/qt/icons/rdisk.ico"); + rdisk_icon = QIcon(":/settings/qt/icons/rdisk.ico"); Harddrives::populateRemovableBuses(ui->comboBoxRDiskBus->model()); if ((ui->comboBoxRDiskBus->model()->rowCount() - 3) > 0) - ui->comboBoxRDiskBus->model()->removeRows(3, ui->comboBoxRDiskBus->model()->rowCount() - 3); + ui->comboBoxRDiskBus->model()->removeRows(3, ui->comboBoxRDiskBus->model()->rowCount() - 3); model = ui->comboBoxRDiskType->model(); for (uint32_t i = 0; i < KNOWN_RDISK_DRIVE_TYPES; i++) { Models::AddEntry(model, rdiskDriveTypeName(i), i); @@ -245,7 +243,8 @@ SettingsOtherRemovable::onRDiskRowChanged(const QModelIndex ¤t) } void -SettingsOtherRemovable::reloadBusChannels_MO() { +SettingsOtherRemovable::reloadBusChannels_MO() +{ auto selected = ui->comboBoxMOChannel->currentIndex(); Harddrives::populateBusChannels(ui->comboBoxMOChannel->model(), ui->comboBoxMOBus->currentData().toInt(), Harddrives::busTrackClass); @@ -254,7 +253,8 @@ SettingsOtherRemovable::reloadBusChannels_MO() { } void -SettingsOtherRemovable::reloadBusChannels_RDisk() { +SettingsOtherRemovable::reloadBusChannels_RDisk() +{ auto selected = ui->comboBoxRDiskChannel->currentIndex(); Harddrives::populateBusChannels(ui->comboBoxRDiskChannel->model(), ui->comboBoxRDiskBus->currentData().toInt(), Harddrives::busTrackClass); @@ -290,12 +290,8 @@ void SettingsOtherRemovable::on_comboBoxMOBus_activated(int) { auto i = ui->tableViewMO->selectionModel()->currentIndex().siblingAtColumn(0); - Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, - Qt::UserRole + 1).toInt()); - ui->comboBoxMOChannel->setCurrentIndex(ui->comboBoxMOBus->currentData().toUInt() == MO_BUS_ATAPI ? - Harddrives::busTrackClass->next_free_ide_channel() : - Harddrives::busTrackClass->next_free_scsi_id()); + Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt()); + ui->comboBoxMOChannel->setCurrentIndex(ui->comboBoxMOBus->currentData().toUInt() == MO_BUS_ATAPI ? Harddrives::busTrackClass->next_free_ide_channel() : Harddrives::busTrackClass->next_free_scsi_id()); ui->tableViewMO->model()->data(i, Qt::UserRole + 1); setMOBus(ui->tableViewMO->model(), ui->tableViewMO->selectionModel()->currentIndex(), @@ -306,9 +302,7 @@ SettingsOtherRemovable::on_comboBoxMOBus_activated(int) ui->comboBoxMOType->currentData().toUInt()); ui->tableViewMO->resizeColumnsToContents(); ui->tableViewMO->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); - Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt()); emit moChannelChanged(); } @@ -316,12 +310,8 @@ void SettingsOtherRemovable::on_comboBoxRDiskBus_activated(int) { auto i = ui->tableViewRDisk->selectionModel()->currentIndex().siblingAtColumn(0); - Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, - Qt::UserRole + 1).toInt()); - ui->comboBoxRDiskChannel->setCurrentIndex(ui->comboBoxRDiskBus->currentData().toUInt() == RDISK_BUS_ATAPI ? - Harddrives::busTrackClass->next_free_ide_channel() : - Harddrives::busTrackClass->next_free_scsi_id()); + Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt()); + ui->comboBoxRDiskChannel->setCurrentIndex(ui->comboBoxRDiskBus->currentData().toUInt() == RDISK_BUS_ATAPI ? Harddrives::busTrackClass->next_free_ide_channel() : Harddrives::busTrackClass->next_free_scsi_id()); ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1); setRDiskBus(ui->tableViewRDisk->model(), ui->tableViewRDisk->selectionModel()->currentIndex(), @@ -332,18 +322,16 @@ SettingsOtherRemovable::on_comboBoxRDiskBus_activated(int) ui->comboBoxRDiskType->currentData().toUInt()); ui->tableViewRDisk->resizeColumnsToContents(); ui->tableViewRDisk->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); - Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt()); emit rdiskChannelChanged(); } void SettingsOtherRemovable::enableCurrentlySelectedChannel_MO() { - const auto *item_model = qobject_cast(ui->comboBoxMOChannel->model()); - const auto index = ui->comboBoxMOChannel->currentIndex(); - auto *item = item_model->item(index); + const auto *item_model = qobject_cast(ui->comboBoxMOChannel->model()); + const auto index = ui->comboBoxMOChannel->currentIndex(); + auto *item = item_model->item(index); if (item) item->setEnabled(true); } @@ -351,9 +339,9 @@ SettingsOtherRemovable::enableCurrentlySelectedChannel_MO() void SettingsOtherRemovable::enableCurrentlySelectedChannel_RDisk() { - const auto *item_model = qobject_cast(ui->comboBoxRDiskChannel->model()); - const auto index = ui->comboBoxRDiskChannel->currentIndex(); - auto *item = item_model->item(index); + const auto *item_model = qobject_cast(ui->comboBoxRDiskChannel->model()); + const auto index = ui->comboBoxRDiskChannel->currentIndex(); + auto *item = item_model->item(index); if (item) item->setEnabled(true); } @@ -361,16 +349,12 @@ void SettingsOtherRemovable::on_comboBoxMOChannel_activated(int) { auto i = ui->tableViewMO->selectionModel()->currentIndex().siblingAtColumn(0); - Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt()); setMOBus(ui->tableViewMO->model(), ui->tableViewMO->selectionModel()->currentIndex(), ui->comboBoxMOBus->currentData().toUInt(), ui->comboBoxMOChannel->currentData().toUInt()); - Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt()); emit moChannelChanged(); } @@ -378,15 +362,12 @@ void SettingsOtherRemovable::on_comboBoxRDiskChannel_activated(int) { auto i = ui->tableViewRDisk->selectionModel()->currentIndex().siblingAtColumn(0); - Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i, - Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, - Qt::UserRole + 1).toInt()); + Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt()); setRDiskBus(ui->tableViewRDisk->model(), - ui->tableViewRDisk->selectionModel()->currentIndex(), - ui->comboBoxRDiskBus->currentData().toUInt(), - ui->comboBoxRDiskChannel->currentData().toUInt()); - Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i, - Qt::UserRole).toInt(), + ui->tableViewRDisk->selectionModel()->currentIndex(), + ui->comboBoxRDiskBus->currentData().toUInt(), + ui->comboBoxRDiskChannel->currentData().toUInt()); + Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt()); emit rdiskChannelChanged(); } diff --git a/src/qt/qt_settingsotherremovable.hpp b/src/qt/qt_settingsotherremovable.hpp index 2c7a4e80e..794939589 100644 --- a/src/qt/qt_settingsotherremovable.hpp +++ b/src/qt/qt_settingsotherremovable.hpp @@ -38,6 +38,7 @@ private slots: private: Ui::SettingsOtherRemovable *ui; + void setMOBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel); void setRDiskBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel); void enableCurrentlySelectedChannel_MO(); diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index eec896839..b1155629d 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -53,7 +53,7 @@ SettingsPorts::save() auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); if (cbox != NULL) - lpt_ports[i].device = cbox->currentData().toInt(); + lpt_ports[i].device = cbox->currentData().toInt(); if (checkBox != NULL) lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; } @@ -73,21 +73,20 @@ SettingsPorts::onCurrentMachineChanged(int machineId) { this->machineId = machineId; - int c = 0; + int c = 0; auto *lptEcpDmaModel = ui->comboBoxLptECPDMA->model(); auto removeRowsEcpDma = lptEcpDmaModel->rowCount(); - int has_jumpers = !!machine_has_jumpered_ecp_dma(machineId, DMA_ANY); + int has_jumpers = !!machine_has_jumpered_ecp_dma(machineId, DMA_ANY); - int selectedRow = -2; - int first = -2; + int selectedRow = -2; + int first = -2; for (int i = 0; i < 9; ++i) { - int j = machine_map_jumpered_ecp_dma(i); + int j = machine_map_jumpered_ecp_dma(i); - if ((has_jumpers && ((j == DMA_NONE) || !machine_has_jumpered_ecp_dma(machineId, j))) || - (!has_jumpers && (j != DMA_NONE))) + if ((has_jumpers && ((j == DMA_NONE) || !machine_has_jumpered_ecp_dma(machineId, j))) || (!has_jumpers && (j != DMA_NONE))) continue; if (first == -2) @@ -122,7 +121,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId) c = 0; // LPT Device - QComboBox * cbox[PARALLEL_MAX] = { 0 }; + QComboBox *cbox[PARALLEL_MAX] = { 0 }; QAbstractItemModel *models[PARALLEL_MAX] = { 0 }; int removeRows_[PARALLEL_MAX] = { 0 }; int selectedRows[PARALLEL_MAX] = { 0 }; @@ -134,12 +133,12 @@ SettingsPorts::onCurrentMachineChanged(int machineId) } while (true) { - const char *lptName = lpt_device_get_name(c); + const char *lptName = lpt_device_get_name(c); if (lptName == nullptr) break; - const QString name = tr(lptName); + const QString name = tr(lptName); for (uint8_t i = 0; i < PARALLEL_MAX; ++i) { int row = Models::AddEntry(models[i], name, c); @@ -148,7 +147,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId) selectedRows[i] = row - removeRows_[i]; } - c++; + c++; } for (uint8_t i = 0; i < PARALLEL_MAX; ++i) { diff --git a/src/qt/qt_settingssound.cpp b/src/qt/qt_settingssound.cpp index 38038f97f..6307451a5 100644 --- a/src/qt/qt_settingssound.cpp +++ b/src/qt/qt_settingssound.cpp @@ -71,8 +71,8 @@ SettingsSound::onCurrentMachineChanged(const int machineId) { this->machineId = machineId; - int c; - int selectedRow; + int c; + int selectedRow; // Sound Cards QComboBox *cbox[SOUND_CARD_MAX] = { 0 }; @@ -119,10 +119,10 @@ SettingsSound::onCurrentMachineChanged(const int machineId) } // Midi Out - c = 0; - auto *model = ui->comboBoxMidiOut->model(); - auto removeRows = model->rowCount(); - selectedRow = 0; + c = 0; + auto *model = ui->comboBoxMidiOut->model(); + auto removeRows = model->rowCount(); + selectedRow = 0; while (true) { const QString name = DeviceConfig::DeviceName(midi_out_device_getdevice(c), midi_out_device_get_internal_name(c), 0); @@ -210,8 +210,7 @@ SettingsSound::on_comboBoxSoundCard1_currentIndexChanged(int index) int sndCard = ui->comboBoxSoundCard1->currentData().toInt(); if (sndCard == SOUND_INTERNAL) - ui->pushButtonConfigureSoundCard1->setEnabled(machine_has_flags(machineId, MACHINE_SOUND) && - device_has_config(machine_get_snd_device(machineId))); + ui->pushButtonConfigureSoundCard1->setEnabled(machine_has_flags(machineId, MACHINE_SOUND) && device_has_config(machine_get_snd_device(machineId))); else ui->pushButtonConfigureSoundCard1->setEnabled(sound_card_has_config(sndCard)); } diff --git a/src/qt/qt_settingsstoragecontrollers.cpp b/src/qt/qt_settingsstoragecontrollers.cpp index 254aadc86..ede180d9f 100644 --- a/src/qt/qt_settingsstoragecontrollers.cpp +++ b/src/qt/qt_settingsstoragecontrollers.cpp @@ -51,8 +51,8 @@ SettingsStorageControllers::save() { /* Storage devices category */ for (uint8_t i = 0; i < HDC_MAX; ++i) { - QComboBox *cbox = findChild(QString("comboBoxHD%1").arg(i + 1)); - hdc_current[i] = cbox->currentData().toInt(); + QComboBox *cbox = findChild(QString("comboBoxHD%1").arg(i + 1)); + hdc_current[i] = cbox->currentData().toInt(); } for (uint8_t i = 0; i < SCSI_CARD_MAX; ++i) { QComboBox *cbox = findChild(QString("comboBoxSCSI%1").arg(i + 1)); @@ -140,10 +140,10 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId) ui->comboBoxCDInterface->setCurrentIndex(selectedRow); // HD Controller - QComboBox * hd_cbox[HDC_MAX] = { 0 }; - QAbstractItemModel *hd_models[HDC_MAX] = { 0 }; - int hd_removeRows_[HDC_MAX] = { 0 }; - int hd_selectedRows[HDC_MAX] = { 0 }; + QComboBox *hd_cbox[HDC_MAX] = { 0 }; + QAbstractItemModel *hd_models[HDC_MAX] = { 0 }; + int hd_removeRows_[HDC_MAX] = { 0 }; + int hd_selectedRows[HDC_MAX] = { 0 }; for (uint8_t i = 0; i < HDC_MAX; ++i) { hd_cbox[i] = findChild(QString("comboBoxHD%1").arg(i + 1)); @@ -185,7 +185,7 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId) } // SCSI Card - QComboBox * cbox[SCSI_CARD_MAX] = { 0 }; + QComboBox *cbox[SCSI_CARD_MAX] = { 0 }; QAbstractItemModel *models[SCSI_CARD_MAX] = { 0 }; int removeRows_[SCSI_CARD_MAX] = { 0 }; int selectedRows[SCSI_CARD_MAX] = { 0 }; diff --git a/src/qt/qt_singlekeyseqedit.cpp b/src/qt/qt_singlekeyseqedit.cpp index f17d2164f..feb8dc6d4 100644 --- a/src/qt/qt_singlekeyseqedit.cpp +++ b/src/qt/qt_singlekeyseqedit.cpp @@ -1,20 +1,25 @@ #include "qt_singlekeyseqedit.hpp" /* - This subclass of QKeySequenceEdit restricts the input to only a single - shortcut instead of an unlimited number with a fixed timeout. + This subclass of QKeySequenceEdit restricts the input to only a single + shortcut instead of an unlimited number with a fixed timeout. */ -singleKeySequenceEdit::singleKeySequenceEdit(QWidget *parent) : QKeySequenceEdit(parent) {} +singleKeySequenceEdit::singleKeySequenceEdit(QWidget *parent) + : QKeySequenceEdit(parent) +{ + // +} -void singleKeySequenceEdit::keyPressEvent(QKeyEvent *event) +void +singleKeySequenceEdit::keyPressEvent(QKeyEvent *event) { QKeySequenceEdit::keyPressEvent(event); if (this->keySequence().count() > 0) { QKeySequenceEdit::setKeySequence(this->keySequence()); - - // This could have unintended consequences since it will happen - // every single time the user presses a key. + + // This could have unintended consequences since it will happen + // every single time the user presses a key. emit editingFinished(); } } \ No newline at end of file diff --git a/src/qt/qt_singlekeyseqedit.hpp b/src/qt/qt_singlekeyseqedit.hpp index 43ebe70b2..5b5eb96ba 100644 --- a/src/qt/qt_singlekeyseqedit.hpp +++ b/src/qt/qt_singlekeyseqedit.hpp @@ -4,8 +4,7 @@ #include #include -class singleKeySequenceEdit : public QKeySequenceEdit -{ +class singleKeySequenceEdit : public QKeySequenceEdit { Q_OBJECT public: singleKeySequenceEdit(QWidget *parent = nullptr); diff --git a/src/qt/qt_softwarerenderer.cpp b/src/qt/qt_softwarerenderer.cpp index 16e331378..0a4492a3e 100644 --- a/src/qt/qt_softwarerenderer.cpp +++ b/src/qt/qt_softwarerenderer.cpp @@ -30,7 +30,8 @@ SoftwareRenderer::SoftwareRenderer(QWidget *parent) #ifdef __HAIKU__ : QWidget(parent) #else - : QWindow(parent->windowHandle()), m_backingStore(new QBackingStore(this)) + : QWindow(parent->windowHandle()) + , m_backingStore(new QBackingStore(this)) #endif { RendererCommon::parentWidget = parent; @@ -72,7 +73,7 @@ SoftwareRenderer::render() } void -SoftwareRenderer::exposeEvent(QExposeEvent* event) +SoftwareRenderer::exposeEvent(QExposeEvent *event) { render(); } @@ -81,7 +82,7 @@ void SoftwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { /* TODO: should look into deleteLater() */ - auto tval = this; + auto tval = this; if ((void *) tval == nullptr) return; auto origSource = source; diff --git a/src/qt/qt_softwarerenderer.hpp b/src/qt/qt_softwarerenderer.hpp index c9c2706cd..e80410956 100644 --- a/src/qt/qt_softwarerenderer.hpp +++ b/src/qt/qt_softwarerenderer.hpp @@ -25,7 +25,7 @@ public: void paintEvent(QPaintEvent *event) override; #endif - void exposeEvent(QExposeEvent* event) override; + void exposeEvent(QExposeEvent *event) override; std::vector> getBuffers() override; diff --git a/src/qt/qt_styleoverride.cpp b/src/qt/qt_styleoverride.cpp index 33480d7c3..bd1c02526 100644 --- a/src/qt/qt_styleoverride.cpp +++ b/src/qt/qt_styleoverride.cpp @@ -28,10 +28,10 @@ extern "C" { } #ifdef Q_OS_WINDOWS -#include -#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 -#endif +# include +# ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +# define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +# endif #endif int @@ -72,7 +72,7 @@ StyleOverride::polish(QWidget *widget) widget->setWindowFlag(Qt::WindowContextHelpButtonHint, false); #ifdef Q_OS_WINDOWS BOOL DarkMode = !util::isWindowsLightTheme(); - DwmSetWindowAttribute((HWND)widget->winId(), DWMWA_USE_IMMERSIVE_DARK_MODE, (LPCVOID)&DarkMode, sizeof(DarkMode)); + DwmSetWindowAttribute((HWND) widget->winId(), DWMWA_USE_IMMERSIVE_DARK_MODE, (LPCVOID) &DarkMode, sizeof(DarkMode)); #endif } @@ -111,7 +111,6 @@ StyleOverride::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, color.setBlueF(avg); image.setPixelColor(x, y, color); - } } diff --git a/src/qt/qt_styleoverride.hpp b/src/qt/qt_styleoverride.hpp index 994271f15..37d339e5e 100644 --- a/src/qt/qt_styleoverride.hpp +++ b/src/qt/qt_styleoverride.hpp @@ -18,7 +18,7 @@ public: const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override; - void polish(QWidget *widget) override; + void polish(QWidget *widget) override; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const override; }; diff --git a/src/qt/qt_ui.cpp b/src/qt/qt_ui.cpp index cebc5a216..59204de56 100644 --- a/src/qt/qt_ui.cpp +++ b/src/qt/qt_ui.cpp @@ -153,10 +153,8 @@ plat_mouse_capture(int on) int ui_msgbox_header(int flags, void *header, void *message) { - const auto hdr = (flags & MBX_ANSI) ? QString(static_cast(header)) : - QString::fromWCharArray(static_cast(header)); - const auto msg = (flags & MBX_ANSI) ? QString(static_cast(message)) : - QString::fromWCharArray(static_cast(message)); + const auto hdr = (flags & MBX_ANSI) ? QString(static_cast(header)) : QString::fromWCharArray(static_cast(header)); + const auto msg = (flags & MBX_ANSI) ? QString(static_cast(message)) : QString::fromWCharArray(static_cast(message)); // any error in early init if (main_window == nullptr) { @@ -259,9 +257,9 @@ ui_sb_set_ready(int ready) void ui_sb_update_icon_wp(int tag, int state) { - const auto temp = static_cast(tag); - const int category = static_cast(temp & 0xfffffff0); - const int item = tag & 0xf; + const auto temp = static_cast(tag); + const int category = static_cast(temp & 0xfffffff0); + const int item = tag & 0xf; switch (category) { default: @@ -287,9 +285,9 @@ ui_sb_update_icon_wp(int tag, int state) void ui_sb_update_icon_state(int tag, int state) { - const auto temp = static_cast(tag); - const int category = static_cast(temp & 0xfffffff0); - const int item = tag & 0xf; + const auto temp = static_cast(tag); + const int category = static_cast(temp & 0xfffffff0); + const int item = tag & 0xf; switch (category) { default: @@ -329,9 +327,9 @@ ui_sb_update_icon_state(int tag, int state) void ui_sb_update_icon(int tag, int active) { - const auto temp = static_cast(tag); - const int category = static_cast(temp & 0xfffffff0); - const int item = tag & 0xf; + const auto temp = static_cast(tag); + const int category = static_cast(temp & 0xfffffff0); + const int item = tag & 0xf; switch (category) { default: @@ -365,9 +363,9 @@ ui_sb_update_icon(int tag, int active) void ui_sb_update_icon_write(int tag, int write) { - const auto temp = static_cast(tag); - const int category = static_cast(temp & 0xfffffff0); - const int item = tag & 0xf; + const auto temp = static_cast(tag); + const int category = static_cast(temp & 0xfffffff0); + const int item = tag & 0xf; switch (category) { default: @@ -397,5 +395,4 @@ ui_sb_update_icon_write(int tag, int write) break; } } - } diff --git a/src/qt/qt_updatecheck.cpp b/src/qt/qt_updatecheck.cpp index 4b9d1e4c5..cffb054b3 100644 --- a/src/qt/qt_updatecheck.cpp +++ b/src/qt/qt_updatecheck.cpp @@ -27,14 +27,14 @@ extern "C" { } UpdateCheck:: -UpdateCheck(const UpdateChannel channel, QObject *parent) : QObject(parent) + UpdateCheck(const UpdateChannel channel, QObject *parent) + : QObject(parent) { - updateChannel = channel; + updateChannel = channel; currentVersion = getCurrentVersion(channel); } -UpdateCheck::~ -UpdateCheck() +UpdateCheck::~UpdateCheck() = default; void @@ -56,35 +56,35 @@ UpdateCheck::checkForUpdates() void UpdateCheck::jenkinsDownloadComplete(const QString &filename, const QVariant &varData) { - auto generalError = tr("Unable to determine release information"); + auto generalError = tr("Unable to determine release information"); auto jenkinsReleaseListResult = parseJenkinsJson(filename); - auto latestVersion = 0; // NOLINT (Default value as a fallback) + auto latestVersion = 0; // NOLINT (Default value as a fallback) - if(!jenkinsReleaseListResult.has_value() || jenkinsReleaseListResult.value().isEmpty()) { + if (!jenkinsReleaseListResult.has_value() || jenkinsReleaseListResult.value().isEmpty()) { generalDownloadError(generalError); return; } const auto jenkinsReleaseList = jenkinsReleaseListResult.value(); - latestVersion = jenkinsReleaseListResult->first().buildNumber; + latestVersion = jenkinsReleaseListResult->first().buildNumber; // If we can't determine the local build (blank current version), always show an update as available. // Callers can adjust accordingly. // Otherwise, do a comparison with EMU_BUILD_NUM bool updateAvailable = false; - bool upToDate = true; - if(currentVersion.isEmpty() || EMU_BUILD_NUM < latestVersion) { + bool upToDate = true; + if (currentVersion.isEmpty() || EMU_BUILD_NUM < latestVersion) { updateAvailable = true; - upToDate = false; + upToDate = false; } const auto updateResult = UpdateResult { - .channel = updateChannel, + .channel = updateChannel, .updateAvailable = updateAvailable, - .upToDate = upToDate, - .currentVersion = currentVersion, - .latestVersion = QString::number(latestVersion), - .githubInfo = {}, - .jenkinsInfo = jenkinsReleaseList, + .upToDate = upToDate, + .currentVersion = currentVersion, + .latestVersion = QString::number(latestVersion), + .githubInfo = {}, + .jenkinsInfo = jenkinsReleaseList, }; emit updateCheckComplete(updateResult); @@ -101,8 +101,8 @@ UpdateCheck::githubDownloadComplete(const QString &filename, const QVariant &var { const auto generalError = tr("Unable to determine release information"); const auto githubReleaseListResult = parseGithubJson(filename); - QString latestVersion = "0.0"; - if(!githubReleaseListResult.has_value() || githubReleaseListResult.value().isEmpty()) { + QString latestVersion = "0.0"; + if (!githubReleaseListResult.has_value() || githubReleaseListResult.value().isEmpty()) { generalDownloadError(generalError); } auto githubReleaseList = githubReleaseListResult.value(); @@ -111,30 +111,29 @@ UpdateCheck::githubDownloadComplete(const QString &filename, const QVariant &var // Another option would be parsing the name field which is generally "86Box " but // either option requires a consistent naming scheme. latestVersion = githubReleaseList.first().tag_name.replace("v", ""); - for (const auto &release: githubReleaseList) { + for (const auto &release : githubReleaseList) { qDebug().noquote().nospace() << release.name << ": " << release.html_url << " (" << release.created_at << ")"; } // const auto updateDetails = new UpdateDetails(githubReleaseList, currentVersion); bool updateAvailable = false; - bool upToDate = true; - if(currentVersion.isEmpty() || (versionCompare(currentVersion, latestVersion) < 0)) { + bool upToDate = true; + if (currentVersion.isEmpty() || (versionCompare(currentVersion, latestVersion) < 0)) { updateAvailable = true; - upToDate = false; + upToDate = false; } const auto updateResult = UpdateResult { - .channel = updateChannel, + .channel = updateChannel, .updateAvailable = updateAvailable, - .upToDate = upToDate, - .currentVersion = currentVersion, - .latestVersion = latestVersion, - .githubInfo = githubReleaseList, - .jenkinsInfo = {}, + .upToDate = upToDate, + .currentVersion = currentVersion, + .latestVersion = latestVersion, + .githubInfo = githubReleaseList, + .jenkinsInfo = {}, }; emit updateCheckComplete(updateResult); - } QUrl @@ -148,7 +147,7 @@ QString UpdateCheck::getCurrentVersion(const UpdateChannel &updateChannel) { if (updateChannel == UpdateChannel::Stable) { - return {EMU_VERSION}; + return { EMU_VERSION }; } // If EMU_BUILD_NUM is anything other than the default of zero it was set by the build process if constexpr (EMU_BUILD_NUM != 0) { @@ -162,7 +161,7 @@ std::optional> UpdateCheck::parseJenkinsJson(const QString &filename) { QList releaseInfoList; - QFile json_file(filename); + QFile json_file(filename); if (!json_file.open(QIODevice::ReadOnly | QIODevice::Text)) { qWarning() << "Couldn't open the json file: error" << json_file.error(); return std::nullopt; @@ -186,15 +185,15 @@ UpdateCheck::parseJenkinsJson(const QString &filename) auto json_object = json_doc.object(); // The json contains multiple release - if(json_object.contains("builds") && json_object["builds"].isArray()) { + if (json_object.contains("builds") && json_object["builds"].isArray()) { QJsonArray builds = json_object["builds"].toArray(); - for (const auto &each_build: builds) { + for (const auto &each_build : builds) { if (auto build = parseJenkinsRelease(each_build.toObject()); build.has_value() && build.value().result == "SUCCESS") { releaseInfoList.append(build.value()); } } - } else if(json_object.contains("changeSets") && json_object["changeSets"].isArray()) { + } else if (json_object.contains("changeSets") && json_object["changeSets"].isArray()) { // The json contains only one release, as obtained by the lastSuccessfulBuild api if (const auto build = parseJenkinsRelease(json_object); build.has_value()) { releaseInfoList.append(build.value()); @@ -268,7 +267,7 @@ std::optional> UpdateCheck::parseGithubJson(const QString &filename) { QList releaseInfoList; - QFile json_file(filename); + QFile json_file(filename); if (!json_file.open(QIODevice::ReadOnly | QIODevice::Text)) { qWarning("Couldn't open the json file: error %d", json_file.error()); return std::nullopt; @@ -291,7 +290,7 @@ UpdateCheck::parseGithubJson(const QString &filename) auto release_array = json_doc.array(); - for (const auto &each_release: release_array) { + for (const auto &each_release : release_array) { if (auto release = parseGithubRelease(each_release.toObject()); release.has_value()) { releaseInfoList.append(release.value()); } diff --git a/src/qt/qt_updatecheck.hpp b/src/qt/qt_updatecheck.hpp index 32732a9be..c2a4ed690 100644 --- a/src/qt/qt_updatecheck.hpp +++ b/src/qt/qt_updatecheck.hpp @@ -31,16 +31,16 @@ public: }; struct JenkinsChangeSetItem { - QString buildId; // sha hash - QString author; // github username - QString message; // commit message + QString buildId; // sha hash + QString author; // github username + QString message; // commit message QStringList affectedPaths; // list of files in the change }; struct JenkinsReleaseInfo { - int buildNumber = 0; - QString result; - qint64 timestamp = 0; + int buildNumber = 0; + QString result; + qint64 timestamp = 0; QList changeSetItems; }; @@ -55,19 +55,19 @@ public: }; struct UpdateResult { - UpdateChannel channel; - bool updateAvailable = false; - bool upToDate = false; - QString currentVersion; - QString latestVersion; - QList githubInfo; + UpdateChannel channel; + bool updateAvailable = false; + bool upToDate = false; + QString currentVersion; + QString latestVersion; + QList githubInfo; QList jenkinsInfo; }; explicit UpdateCheck(UpdateChannel channel, QObject *parent = nullptr); ~UpdateCheck() override; - void checkForUpdates(); - static int versionCompare(const QString &version1, const QString &version2); + void checkForUpdates(); + static int versionCompare(const QString &version1, const QString &version2); [[nodiscard]] static QString getCurrentVersion(const UpdateChannel &updateChannel = UpdateChannel::Stable); signals: @@ -86,15 +86,14 @@ private: static QUrl jenkinsLatestNReleasesUrl(const int &count); static std::optional> parseJenkinsJson(const QString &filename); - static std::optional parseJenkinsRelease(const QJsonObject &json); + static std::optional parseJenkinsRelease(const QJsonObject &json); static std::optional> parseGithubJson(const QString &filename); - static std::optional parseGithubRelease(const QJsonObject &json); - + static std::optional parseGithubRelease(const QJsonObject &json); private slots: - void jenkinsDownloadComplete(const QString &filename, const QVariant& varData); - void githubDownloadComplete(const QString &filename, const QVariant& varData); + void jenkinsDownloadComplete(const QString &filename, const QVariant &varData); + void githubDownloadComplete(const QString &filename, const QVariant &varData); void generalDownloadError(const QString &error); }; diff --git a/src/qt/qt_updatecheckdialog.cpp b/src/qt/qt_updatecheckdialog.cpp index 7400f40ae..468cdb63e 100644 --- a/src/qt/qt_updatecheckdialog.cpp +++ b/src/qt/qt_updatecheckdialog.cpp @@ -24,11 +24,14 @@ extern "C" { } UpdateCheckDialog:: -UpdateCheckDialog(const UpdateCheck::UpdateChannel channel, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateCheckDialog), updateCheck(new UpdateCheck(channel)) + UpdateCheckDialog(const UpdateCheck::UpdateChannel channel, QWidget *parent) + : QDialog(parent) + , ui(new Ui::UpdateCheckDialog) + , updateCheck(new UpdateCheck(channel)) { ui->setupUi(this); ui->statusLabel->setHidden(true); - updateChannel = channel; + updateChannel = channel; currentVersion = UpdateCheck::getCurrentVersion(updateChannel); connect(updateCheck, &UpdateCheck::updateCheckError, [=](const QString &errorMsg) { generalDownloadError(errorMsg); @@ -40,8 +43,7 @@ UpdateCheckDialog(const UpdateCheck::UpdateChannel channel, QWidget *parent) : Q }); } -UpdateCheckDialog::~ -UpdateCheckDialog() +UpdateCheckDialog::~UpdateCheckDialog() = default; void diff --git a/src/qt/qt_updatedetails.cpp b/src/qt/qt_updatedetails.cpp index 386e33fae..1d5b910d1 100644 --- a/src/qt/qt_updatedetails.cpp +++ b/src/qt/qt_updatedetails.cpp @@ -18,9 +18,10 @@ #include #include - UpdateDetails:: -UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateDetails) + UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) + : QDialog(parent) + , ui(new Ui::UpdateDetails) { ui->setupUi(this); ui->updateTitle->setText(tr("An update to 86Box is available!")); @@ -39,7 +40,7 @@ UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) : const auto updateDetailsText = QString("%1 %2%3").arg(latestVersionText, currentVersionText.append(' '), tr("Would you like to visit the download page?")); ui->updateDetails->setText(updateDetailsText); - if(updateResult.channel == UpdateCheck::UpdateChannel::Stable) { + if (updateResult.channel == UpdateCheck::UpdateChannel::Stable) { ui->updateText->setMarkdown(githubUpdateToMarkdown(updateResult.githubInfo)); } else { ui->updateText->setMarkdown(jenkinsUpdateToMarkdown(updateResult.jenkinsInfo)); @@ -56,8 +57,7 @@ UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) : ui->icon->setPixmap(logo); } -UpdateDetails::~ -UpdateDetails() +UpdateDetails::~UpdateDetails() = default; QString @@ -109,25 +109,25 @@ UpdateDetails::visitDownloadPage(const UpdateCheck::UpdateChannel &channel) case UpdateCheck::UpdateChannel::CI: QDesktopServices::openUrl(QUrl("https://86box.net/builds#" #ifdef Q_OS_WINDOWS - "win" + "win" #elif defined(Q_OS_MACOS) - "mac" + "mac" #elif defined(Q_OS_LINUX) - "lin" + "lin" #endif #if defined(__aarch64__) || defined(_M_ARM64) - "arm64" + "arm64" #elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) - "64" + "64" #endif #ifdef USE_NEW_DYNAREC - "ndr" + "ndr" #else - "odr" + "odr" #endif - )); + )); break; } } diff --git a/src/qt/qt_updatedetails.hpp b/src/qt/qt_updatedetails.hpp index c11dd8f43..28ee74b60 100644 --- a/src/qt/qt_updatedetails.hpp +++ b/src/qt/qt_updatedetails.hpp @@ -28,13 +28,13 @@ class UpdateDetails final : public QDialog { public: explicit UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent = nullptr); ~UpdateDetails() override; + private: Ui::UpdateDetails *ui; - static QString jenkinsUpdateToMarkdown(const QList &releaseInfoList); - static QString githubUpdateToMarkdown(const QList &releaseInfoList); + static QString jenkinsUpdateToMarkdown(const QList &releaseInfoList); + static QString githubUpdateToMarkdown(const QList &releaseInfoList); private slots: static void visitDownloadPage(const UpdateCheck::UpdateChannel &channel); }; - #endif // QT_UPDATEDETAILS_HPP diff --git a/src/qt/qt_util.cpp b/src/qt/qt_util.cpp index 02d33af9b..ef2293343 100644 --- a/src/qt/qt_util.cpp +++ b/src/qt/qt_util.cpp @@ -63,7 +63,8 @@ screenOfWidget(QWidget *widget) #ifdef Q_OS_WINDOWS bool -isWindowsLightTheme(void) { +isWindowsLightTheme(void) +{ if (color_scheme != 0) { return (color_scheme == 1); } @@ -73,7 +74,7 @@ isWindowsLightTheme(void) { // The value is expected to be a REG_DWORD, which is a signed 32-bit little-endian auto buffer = std::vector(4); auto cbData = static_cast(buffer.size() * sizeof(char)); - auto res = RegGetValueW( + auto res = RegGetValueW( HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", L"AppsUseLightTheme", @@ -87,10 +88,7 @@ isWindowsLightTheme(void) { } // convert bytes written to our buffer to an int, assuming little-endian - auto i = int(buffer[3] << 24 | - buffer[2] << 16 | - buffer[1] << 8 | - buffer[0]); + auto i = int(buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]); return i == 1; } @@ -147,22 +145,24 @@ DlgFilter(QStringList extensions, bool last) return " (" % temp.join(' ') % ")" % (!last ? ";;" : ""); } - -QString currentUuid() +QString +currentUuid() { return generateUuid(QString(cfg_path)); } -QString generateUuid(const QString &path) +QString +generateUuid(const QString &path) { auto dirPath = QFileInfo(path).dir().canonicalPath(); - if(!dirPath.endsWith("/")) { + if (!dirPath.endsWith("/")) { dirPath.append("/"); } - return QUuid::createUuidV5(QUuid{}, dirPath).toString(QUuid::WithoutBraces); + return QUuid::createUuidV5(QUuid {}, dirPath).toString(QUuid::WithoutBraces); } -bool compareUuid() +bool +compareUuid() { // A uuid not set in the config file will have a zero length. // Any uuid that is lower than the minimum length will be considered invalid @@ -172,7 +172,7 @@ bool compareUuid() return true; } // Do not prompt on mismatch if the system does not have any configured NICs. Just update the uuid - if(!hasConfiguredNICs() && uuid != currentUuid()) { + if (!hasConfiguredNICs() && uuid != currentUuid()) { storeCurrentUuid(); return true; } diff --git a/src/qt/qt_util.hpp b/src/qt/qt_util.hpp index a2ca44425..ab93784c4 100644 --- a/src/qt/qt_util.hpp +++ b/src/qt/qt_util.hpp @@ -20,10 +20,10 @@ void setWin11RoundedCorners(WId hwnd, bool enable); #endif QString currentUuid(); QString generateUuid(const QString &path); -void storeCurrentUuid(); -bool compareUuid(); -void generateNewMacAdresses(); -bool hasConfiguredNICs(); +void storeCurrentUuid(); +bool compareUuid(); +void generateNewMacAdresses(); +bool hasConfiguredNICs(); }; #endif diff --git a/src/qt/qt_vmmanager_addmachine.cpp b/src/qt/qt_vmmanager_addmachine.cpp index 81bb47110..b8bed2fe5 100644 --- a/src/qt/qt_vmmanager_addmachine.cpp +++ b/src/qt/qt_vmmanager_addmachine.cpp @@ -30,7 +30,8 @@ extern "C" { // One for the main Wizard class and one for each page of the wizard VMManagerAddMachine:: -VMManagerAddMachine(QWidget *parent) : QWizard(parent) + VMManagerAddMachine(QWidget *parent) + : QWizard(parent) { setPage(Page_Intro, new IntroPage); setPage(Page_WithExistingConfig, new WithExistingConfigPage); @@ -64,7 +65,7 @@ VMManagerAddMachine(QWidget *parent) : QWizard(parent) } IntroPage:: -IntroPage(QWidget *parent) + IntroPage(QWidget *parent) { setTitle(tr("Introduction")); @@ -74,7 +75,7 @@ IntroPage(QWidget *parent) // topLabel = new QLabel(tr("This will help you add a new system to 86Box.\n\n Choose \"New configuration\" if you'd like to create a new machine.\n\nChoose \"Use existing configuration\" if you'd like to paste in an existing configuration from elsewhere.")); topLabel->setWordWrap(true); - newConfigRadioButton = new QRadioButton(tr("New configuration")); + newConfigRadioButton = new QRadioButton(tr("New configuration")); // auto newDescription = new QLabel(tr("Choose this option to start with a fresh configuration.")); existingConfigRadioButton = new QRadioButton(tr("Use existing configuration")); // auto existingDescription = new QLabel(tr("Use this option if you'd like to paste in the configuration file from an existing system.")); @@ -101,12 +102,12 @@ IntroPage::nextId() const } WithExistingConfigPage:: -WithExistingConfigPage(QWidget *parent) + WithExistingConfigPage(QWidget *parent) { setTitle(tr("Use existing configuration")); setSubTitle(tr("Paste the contents of the existing configuration file into the box below.")); - existingConfiguration = new QPlainTextEdit(); + existingConfiguration = new QPlainTextEdit(); const auto monospaceFont = new QFont(); #ifdef Q_OS_WINDOWS monospaceFont->setFamily("Consolas"); @@ -124,8 +125,8 @@ WithExistingConfigPage(QWidget *parent) const auto layout = new QVBoxLayout(); layout->addWidget(existingConfiguration); const auto loadFileButton = new QPushButton(); - const auto loadFileLabel = new QLabel(tr("Load configuration from file")); - const auto hLayout = new QHBoxLayout(); + const auto loadFileLabel = new QLabel(tr("Load configuration from file")); + const auto hLayout = new QHBoxLayout(); loadFileButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_FileIcon)); loadFileButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); connect(loadFileButton, &QPushButton::clicked, this, &WithExistingConfigPage::chooseExistingConfigFile); @@ -138,10 +139,10 @@ WithExistingConfigPage(QWidget *parent) void WithExistingConfigPage::chooseExistingConfigFile() { - const auto startDirectory = QString(vmm_path); + const auto startDirectory = QString(vmm_path); const auto selectedConfigFile = QFileDialog::getOpenFileName(this, tr("Choose configuration file"), - startDirectory, - tr("86Box configuration files (86box.cfg)")); + startDirectory, + tr("86Box configuration files (86box.cfg)")); // Empty value means the dialog was canceled if (!selectedConfigFile.isEmpty()) { QFile configFile(selectedConfigFile); @@ -183,18 +184,18 @@ WithExistingConfigPage::isComplete() const } NameAndLocationPage:: -NameAndLocationPage(QWidget *parent) + NameAndLocationPage(QWidget *parent) { #ifdef CUSTOM_SYSTEM_LOCATION setTitle(tr("System name and location")); -#if defined(_WIN32) +# if defined(_WIN32) dirValidate = QRegularExpression(R"(^[^\\/:*?"<>|]+$)"); -#elif defined(__APPLE__) +# elif defined(__APPLE__) dirValidate = QRegularExpression(R"(^[^/:]+$)"); -#else +# else dirValidate = QRegularExpression(R"(^[^/]+$)"); -#endif +# endif setSubTitle(tr("Enter the name of the system and choose the location")); #else @@ -206,7 +207,7 @@ NameAndLocationPage(QWidget *parent) chooseDirectoryButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon)); const auto systemNameLabel = new QLabel(tr("System name:")); - systemName = new QLineEdit(); + systemName = new QLineEdit(); // Special event filter to override enter key systemName->installEventFilter(this); registerField("systemName*", systemName); @@ -214,7 +215,7 @@ NameAndLocationPage(QWidget *parent) #ifdef CUSTOM_SYSTEM_LOCATION const auto systemLocationLabel = new QLabel(tr("System location:")); - systemLocation = new QLineEdit(); + systemLocation = new QLineEdit(); systemLocation->setText(QDir::toNativeSeparators(vmm_path)); registerField("systemLocation*", systemLocation); systemLocationValidation = new QLabel(); @@ -222,7 +223,7 @@ NameAndLocationPage(QWidget *parent) #endif const auto displayNameLabel = new QLabel(tr("Display name (optional):")); - displayName = new QLineEdit(); + displayName = new QLineEdit(); // Special event filter to override enter key displayName->installEventFilter(this); registerField("displayName*", displayName); @@ -278,7 +279,7 @@ NameAndLocationPage::chooseDirectoryLocation() bool NameAndLocationPage::isComplete() const { - bool nameValid = false; + bool nameValid = false; #ifdef CUSTOM_SYSTEM_LOCATION bool locationValid = false; #endif @@ -319,10 +320,10 @@ NameAndLocationPage::eventFilter(QObject *watched, QEvent *event) // Override the enter key to hit the next wizard button // if the validator (isComplete) is satisfied if (event->type() == QEvent::KeyPress) { - const auto keyEvent = dynamic_cast(event); + const auto keyEvent = dynamic_cast(event); if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { // Only advance if the validator is satisfied (isComplete) - if(const auto wizard = qobject_cast(this->wizard())) { + if (const auto wizard = qobject_cast(this->wizard())) { if (wizard->currentPage()->isComplete()) { wizard->next(); } @@ -335,7 +336,7 @@ NameAndLocationPage::eventFilter(QObject *watched, QEvent *event) } ConclusionPage:: -ConclusionPage(QWidget *parent) + ConclusionPage(QWidget *parent) { setTitle(tr("Complete")); @@ -344,20 +345,20 @@ ConclusionPage(QWidget *parent) topLabel = new QLabel(tr("The wizard will now launch the configuration for the new system.")); topLabel->setWordWrap(true); - const auto systemNameLabel = new QLabel(tr("System name:")); + const auto systemNameLabel = new QLabel(tr("System name:")); systemNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); - systemName = new QLabel(); + systemName = new QLabel(); systemName->setWordWrap(true); #ifdef CUSTOM_SYSTEM_LOCATION const auto systemLocationLabel = new QLabel(tr("System location:")); systemLocationLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); - systemLocation = new QLabel(); + systemLocation = new QLabel(); systemLocation->setWordWrap(true); #endif - displayNameLabel = new QLabel(tr("Display name:")); + displayNameLabel = new QLabel(tr("Display name:")); displayNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); - displayName = new QLabel(); + displayName = new QLabel(); displayName->setWordWrap(true); const auto layout = new QGridLayout(); @@ -380,10 +381,10 @@ void ConclusionPage::initializePage() { #ifdef CUSTOM_SYSTEM_LOCATION - const auto finalPath = QDir::cleanPath(field("systemLocation").toString() + "/" + field("systemName").toString()); + const auto finalPath = QDir::cleanPath(field("systemLocation").toString() + "/" + field("systemName").toString()); const auto nativePath = QDir::toNativeSeparators(finalPath); #endif - const auto systemNameDisplay = field("systemName").toString(); + const auto systemNameDisplay = field("systemName").toString(); const auto displayNameDisplay = field("displayName").toString(); systemName->setText(systemNameDisplay); diff --git a/src/qt/qt_vmmanager_addmachine.hpp b/src/qt/qt_vmmanager_addmachine.hpp index 7a640a70d..e2b7c213e 100644 --- a/src/qt/qt_vmmanager_addmachine.hpp +++ b/src/qt/qt_vmmanager_addmachine.hpp @@ -48,7 +48,7 @@ public: [[nodiscard]] int nextId() const override; private: - QLabel *topLabel; + QLabel *topLabel; QRadioButton *newConfigRadioButton; QRadioButton *existingConfigRadioButton; }; @@ -61,17 +61,18 @@ public: explicit WithExistingConfigPage(QWidget *parent = nullptr); // These extra functions are required to register QPlainTextEdit fields [[nodiscard]] QString configuration() const; - void setConfiguration(const QString &configuration); + void setConfiguration(const QString &configuration); signals: void configurationChanged(const QString &configuration); + private: QPlainTextEdit *existingConfiguration; private slots: - void chooseExistingConfigFile(); -protected: - [[nodiscard]] int nextId() const override; - [[nodiscard]] bool isComplete() const override; + void chooseExistingConfigFile(); +protected: + [[nodiscard]] int nextId() const override; + [[nodiscard]] bool isComplete() const override; }; class NameAndLocationPage final : public QWizardPage { @@ -80,6 +81,7 @@ class NameAndLocationPage final : public QWizardPage { public: explicit NameAndLocationPage(QWidget *parent = nullptr); [[nodiscard]] int nextId() const override; + private: QLineEdit *systemName; #ifdef CUSTOM_SYSTEM_LOCATION @@ -88,21 +90,21 @@ private: QLineEdit *displayName; QLabel *systemNameValidation; #ifdef CUSTOM_SYSTEM_LOCATION - QLabel *systemLocationValidation; + QLabel *systemLocationValidation; QRegularExpression dirValidate; private slots: void chooseDirectoryLocation(); #endif protected: [[nodiscard]] bool isComplete() const override; - bool eventFilter(QObject *watched, QEvent *event) override; - + bool eventFilter(QObject *watched, QEvent *event) override; }; class ConclusionPage final : public QWizardPage { Q_OBJECT public: explicit ConclusionPage(QWidget *parent = nullptr); + private: QLabel *topLabel; QLabel *systemName; @@ -111,6 +113,7 @@ private: #endif QLabel *displayNameLabel; QLabel *displayName; + protected: void initializePage() override; }; diff --git a/src/qt/qt_vmmanager_clientsocket.cpp b/src/qt/qt_vmmanager_clientsocket.cpp index c8e5cbefe..65db5db4a 100644 --- a/src/qt/qt_vmmanager_clientsocket.cpp +++ b/src/qt/qt_vmmanager_clientsocket.cpp @@ -23,10 +23,10 @@ extern "C" { #include "86box/config.h" } -VMManagerClientSocket::VMManagerClientSocket(QObject* obj) : server_connected(false) +VMManagerClientSocket::VMManagerClientSocket(QObject *obj) + : server_connected(false) { socket = new QLocalSocket; - } void @@ -44,7 +44,7 @@ VMManagerClientSocket::dataReady() if (stream.commitTransaction()) { // first try to successfully read some data // need to also make sure it's valid json - QJsonParseError parse_error{}; + QJsonParseError parse_error {}; // try to create a document with the data received const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &parse_error); if (parse_error.error == QJsonParseError::NoError) { @@ -63,7 +63,6 @@ VMManagerClientSocket::dataReady() break; } } - } bool @@ -77,7 +76,7 @@ VMManagerClientSocket::IPCConnect(const QString &server) socket->connectToServer(server_name); - if(!socket->isValid()) { + if (!socket->isValid()) { qInfo("Could not connect to server: %s", qPrintable(socket->errorString())); return false; } @@ -123,13 +122,13 @@ VMManagerClientSocket::sendMessageFull(const VMManagerProtocol::ClientMessage pr { QDataStream clientStream(socket); clientStream.setVersion(QDataStream::Qt_5_7); - auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Client); + auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Client); auto jsonMessage = packet->protocolClientMessage(protocol_message); if (!list.isEmpty()) { jsonMessage["list"] = QJsonArray::fromStringList(list); } // TODO: Add the logic for including objects - if(!json.isEmpty()) { + if (!json.isEmpty()) { jsonMessage["params"] = json; } clientStream << QJsonDocument(jsonMessage).toJson(QJsonDocument::Compact); @@ -228,7 +227,7 @@ VMManagerClientSocket::eventFilter(QObject *obj, QEvent *event) window_blocked = true; } else if (event->type() == QEvent::WindowUnblocked) { window_blocked = false; - running_state = dopause ? VMManagerProtocol::RunningState::Paused : VMManagerProtocol::RunningState::Running; + running_state = dopause ? VMManagerProtocol::RunningState::Paused : VMManagerProtocol::RunningState::Running; clientRunningStateChanged(running_state); } } @@ -248,7 +247,8 @@ VMManagerClientSocket::clientRunningStateChanged(VMManagerProtocol::RunningState { QJsonObject extra_object; if ((state == VMManagerProtocol::RunningState::Paused - || state == VMManagerProtocol::RunningState::Running) && window_blocked) { + || state == VMManagerProtocol::RunningState::Running) + && window_blocked) { state = (state == VMManagerProtocol::RunningState::Paused) ? VMManagerProtocol::RunningState::PausedWaiting : VMManagerProtocol::RunningState::RunningWaiting; } extra_object["status"] = static_cast(state); diff --git a/src/qt/qt_vmmanager_clientsocket.hpp b/src/qt/qt_vmmanager_clientsocket.hpp index 8e063a79e..53a7d8f88 100644 --- a/src/qt/qt_vmmanager_clientsocket.hpp +++ b/src/qt/qt_vmmanager_clientsocket.hpp @@ -25,7 +25,7 @@ class VMManagerClientSocket final : public QObject { Q_OBJECT public: - explicit VMManagerClientSocket(QObject* object = nullptr); + explicit VMManagerClientSocket(QObject *object = nullptr); bool IPCConnect(const QString &server); void sendWinIdMessage(WId id); @@ -45,13 +45,13 @@ public slots: void globalConfigurationChanged() const; private: - QString server_name; + QString server_name; QLocalSocket *socket; - bool server_connected; - bool window_blocked = false; - void connected() const; - void disconnected() const; - static void connectionError(QLocalSocket::LocalSocketError socketError); + bool server_connected; + bool window_blocked = false; + void connected() const; + void disconnected() const; + static void connectionError(QLocalSocket::LocalSocketError socketError); // Main convenience send function void sendMessage(VMManagerProtocol::ClientMessage protocol_message) const; @@ -67,7 +67,6 @@ private: protected: bool eventFilter(QObject *obj, QEvent *event) override; - }; #endif // QT_VMMANAGER_CLIENTSOCKET_HPP diff --git a/src/qt/qt_vmmanager_config.cpp b/src/qt/qt_vmmanager_config.cpp index 5690ea91a..70fcdcc6c 100644 --- a/src/qt/qt_vmmanager_config.cpp +++ b/src/qt/qt_vmmanager_config.cpp @@ -20,11 +20,11 @@ extern "C" { #include <86box/plat.h> } -VMManagerConfig::VMManagerConfig(const ConfigType type, const QString& section) +VMManagerConfig::VMManagerConfig(const ConfigType type, const QString §ion) { char BUF[256]; plat_get_global_config_dir(BUF, 255); - const auto configDir = QString(BUF); + const auto configDir = QString(BUF); const auto configFile = QDir::cleanPath(configDir + "/" + "vmm.ini"); config_type = type; @@ -34,17 +34,18 @@ VMManagerConfig::VMManagerConfig(const ConfigType type, const QString& section) settings->setIniCodec("UTF-8"); #endif settings->setFallbacksEnabled(false); - if(type == ConfigType::System && !section.isEmpty()) { + if (type == ConfigType::System && !section.isEmpty()) { settings->beginGroup(section); } } -VMManagerConfig::~VMManagerConfig() { +VMManagerConfig::~VMManagerConfig() +{ settings->endGroup(); } QString -VMManagerConfig::getStringValue(const QString& key) const +VMManagerConfig::getStringValue(const QString &key) const { const auto value = settings->value(key); // An invalid QVariant with toString will give a default QString value which is blank. @@ -73,4 +74,3 @@ VMManagerConfig::sync() const { settings->sync(); } - diff --git a/src/qt/qt_vmmanager_config.hpp b/src/qt/qt_vmmanager_config.hpp index 51ad3ecfe..814b3c70f 100644 --- a/src/qt/qt_vmmanager_config.hpp +++ b/src/qt/qt_vmmanager_config.hpp @@ -27,17 +27,17 @@ public: }; Q_ENUM(ConfigType); - explicit VMManagerConfig(ConfigType type, const QString& section = {}); + explicit VMManagerConfig(ConfigType type, const QString §ion = {}); ~VMManagerConfig() override; - [[nodiscard]] QString getStringValue(const QString& key) const; - void setStringValue(const QString& key, const QString& value) const; - void remove(const QString &key) const; + [[nodiscard]] QString getStringValue(const QString &key) const; + void setStringValue(const QString &key, const QString &value) const; + void remove(const QString &key) const; void sync() const; QSettings *settings; ConfigType config_type; - QString system_name; + QString system_name; }; #endif // QT_VMMANAGER_CONFIG_H \ No newline at end of file diff --git a/src/qt/qt_vmmanager_details.cpp b/src/qt/qt_vmmanager_details.cpp index 2b36e3967..e0cabc53c 100644 --- a/src/qt/qt_vmmanager_details.cpp +++ b/src/qt/qt_vmmanager_details.cpp @@ -22,21 +22,23 @@ #define TOOLBUTTON_STYLESHEET_LIGHT "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(midlight)} QToolButton:pressed {background: palette(mid)}" #ifdef Q_OS_WINDOWS -# define TOOLBUTTON_STYLESHEET_DARK "QToolButton {padding: 5px}" +# define TOOLBUTTON_STYLESHEET_DARK "QToolButton {padding: 5px}" # define SCREENSHOTBORDER_STYLESHEET_DARK "QLabel { border: 1px solid gray }" #else # define TOOLBUTTON_STYLESHEET_DARK "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(dark)} QToolButton:pressed {background: palette(mid)}" #endif -#define SCROLLAREA_STYLESHEET_LIGHT "QWidget {background-color: palette(light)} QScrollBar{ background-color: none }" +#define SCROLLAREA_STYLESHEET_LIGHT "QWidget {background-color: palette(light)} QScrollBar{ background-color: none }" #define SYSTEMLABEL_STYLESHEET_LIGHT "background-color: palette(midlight);" using namespace VMManager; -VMManagerDetails::VMManagerDetails(QWidget *parent) : - QWidget(parent), ui(new Ui::VMManagerDetails) { +VMManagerDetails::VMManagerDetails(QWidget *parent) + : QWidget(parent) + , ui(new Ui::VMManagerDetails) +{ ui->setupUi(this); - const auto leftColumnLayout = qobject_cast(ui->leftColumn->layout()); + const auto leftColumnLayout = qobject_cast(ui->leftColumn->layout()); // Each section here gets its own VMManagerDetailSection, named in the constructor. // When a system is selected in the list view it is updated through this object @@ -116,7 +118,7 @@ VMManagerDetails::VMManagerDetails(QWidget *parent) : ui->ssNavTBHolder->setStyleSheet(toolButtonStyleSheet); pauseIcon = QIcon(":/menuicons/qt/icons/pause.ico"); - runIcon = QIcon(":/menuicons/qt/icons/run.ico"); + runIcon = QIcon(":/menuicons/qt/icons/run.ico"); // Experimenting startPauseButton = new QToolButton(); @@ -164,12 +166,14 @@ VMManagerDetails::VMManagerDetails(QWidget *parent) : sysconfig = new VMManagerSystem(); } -VMManagerDetails::~VMManagerDetails() { +VMManagerDetails::~VMManagerDetails() +{ delete ui; } void -VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) { +VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) +{ // Set the scrollarea background but also set the scroll bar to none. Otherwise it will also // set the scrollbar background to the same. @@ -202,9 +206,8 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) { connect(cadButton, &QToolButton::clicked, sysconfig, &VMManagerSystem::cadButtonPressed); cadButton->setEnabled(true); - bool running = sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running || - sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::RunningWaiting; - if(running) { + bool running = sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running || sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::RunningWaiting; + if (running) { startPauseButton->setIcon(pauseIcon); connect(startPauseButton, &QToolButton::clicked, sysconfig, &VMManagerSystem::pauseButtonPressed); } else { @@ -218,9 +221,7 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) { updateScreenshots(passed_sysconfig); ui->systemLabel->setText(passed_sysconfig->displayName); - ui->statusLabel->setText(sysconfig->process->processId() == 0 ? - tr("Not running") : - QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId()))); + ui->statusLabel->setText(sysconfig->process->processId() == 0 ? tr("Not running") : QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId()))); ui->notesTextEdit->setPlainText(passed_sysconfig->notes); ui->notesTextEdit->setEnabled(true); @@ -237,7 +238,8 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) { } void -VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) { +VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) +{ // Each detail section here has its own VMManagerDetailSection. // When a system is selected in the list view it is updated here, through this object: // * First you clear it with VMManagerDetailSection::clear() @@ -252,7 +254,7 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) { // Video videoSection->clear(); videoSection->addSection("Video", passed_sysconfig->getDisplayValue(VMManager::Display::Name::Video)); - if(!passed_sysconfig->getDisplayValue(VMManager::Display::Name::Voodoo).isEmpty()) { + if (!passed_sysconfig->getDisplayValue(VMManager::Display::Name::Voodoo).isEmpty()) { videoSection->addSection("Voodoo", passed_sysconfig->getDisplayValue(VMManager::Display::Name::Voodoo)); } @@ -303,7 +305,8 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) { } void -VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) { +VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) +{ // Disable screenshot navigation buttons by default ui->screenshotNext->setEnabled(false); ui->screenshotPrevious->setEnabled(false); @@ -315,7 +318,7 @@ VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) { if (!screenshots.empty()) { ui->screenshot->setFrameStyle(QFrame::NoFrame); ui->screenshot->setEnabled(true); - if(screenshots.size() > 1) { + if (screenshots.size() > 1) { ui->screenshotNext->setEnabled(true); ui->screenshotPrevious->setEnabled(true); ui->screenshotNextTB->setEnabled(true); @@ -324,7 +327,7 @@ VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) { #ifdef Q_OS_WINDOWS ui->screenshot->setStyleSheet(""); #endif - if(QFileInfo::exists(screenshots.last().filePath())) { + if (QFileInfo::exists(screenshots.last().filePath())) { screenshotIndex = screenshots.size() - 1; const QPixmap pic(screenshots.at(screenshotIndex).filePath()); ui->screenshot->setPixmap(pic.scaled(240, 160, Qt::KeepAspectRatio, Qt::SmoothTransformation)); @@ -351,18 +354,17 @@ VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) { } void -VMManagerDetails::updateProcessStatus() { - const bool running = sysconfig->process->state() == QProcess::ProcessState::Running; - QString status_text = running ? - QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())) : - tr("Not running"); +VMManagerDetails::updateProcessStatus() +{ + const bool running = sysconfig->process->state() == QProcess::ProcessState::Running; + QString status_text = running ? QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())) : tr("Not running"); status_text.append(sysconfig->window_obscured ? QString(" (%1)").arg(tr("Waiting")) : ""); ui->statusLabel->setText(status_text); resetButton->setEnabled(running); stopButton->setEnabled(running); cadButton->setEnabled(running); - if(running) { - if(sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running) { + if (running) { + if (sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running) { startPauseButton->setIcon(pauseIcon); startPauseButton->setToolTip(tr("Pause")); } else { @@ -404,7 +406,7 @@ VMManagerDetails::updateWindowStatus() void VMManagerDetails::updateStyle() { - QString toolButtonStyleSheet; + QString toolButtonStyleSheet; const bool lightMode = util::isWindowsLightTheme(); if (lightMode) { toolButtonStyleSheet = TOOLBUTTON_STYLESHEET_LIGHT; @@ -472,10 +474,9 @@ VMManagerDetails::eventFilter(QObject *watched, QEvent *event) { if (watched->isWidgetType() && event->type() == QEvent::FocusOut) { // Make sure it's the textedit - if (const auto *textEdit = qobject_cast(watched); textEdit) { + if (const auto *textEdit = qobject_cast(watched); textEdit) { saveNotes(); } } return QWidget::eventFilter(watched, event); } - diff --git a/src/qt/qt_vmmanager_details.hpp b/src/qt/qt_vmmanager_details.hpp index 3ef868f03..ec71d4cd8 100644 --- a/src/qt/qt_vmmanager_details.hpp +++ b/src/qt/qt_vmmanager_details.hpp @@ -20,10 +20,11 @@ // #include "qt_vmmanager_details_section.hpp" #include "qt_vmmanager_detailsection.hpp" - QT_BEGIN_NAMESPACE -//namespace Ui { class VMManagerDetails; class CollapseButton;} -namespace Ui { class VMManagerDetails;} +// namespace Ui { class VMManagerDetails; class CollapseButton;} +namespace Ui { +class VMManagerDetails; +} QT_END_NAMESPACE class VMManagerDetails : public QWidget { @@ -44,7 +45,7 @@ public: void updateStyle(); #endif -// CollapseButton *systemCollapseButton; + // CollapseButton *systemCollapseButton; #ifdef Q_OS_WINDOWS signals: @@ -53,7 +54,7 @@ signals: private: Ui::VMManagerDetails *ui; - VMManagerSystem *sysconfig; + VMManagerSystem *sysconfig; VMManagerDetailSection *systemSection; VMManagerDetailSection *videoSection; @@ -78,9 +79,9 @@ private: QIcon pauseIcon; QIcon runIcon; - void updateConfig(VMManagerSystem *passed_sysconfig); - void updateScreenshots(VMManagerSystem *passed_sysconfig); - static QWidget* createHorizontalLine(int leftSpacing = 25, int rightSpacing = 25); + void updateConfig(VMManagerSystem *passed_sysconfig); + void updateScreenshots(VMManagerSystem *passed_sysconfig); + static QWidget *createHorizontalLine(int leftSpacing = 25, int rightSpacing = 25); // QVBoxLayout *detailsLayout; private slots: void saveNotes() const; @@ -90,12 +91,14 @@ private slots: protected: bool eventFilter(QObject *watched, QEvent *event) override; -// CollapseButton *systemCollapseButton; -// QFrame *systemFrame; -// CollapseButton *displayCollapseButton; -// QFrame *displayFrame; -// CollapseButton *storageCollapseButton; -// QFrame *storageFrame; +#if 0 + CollapseButton *systemCollapseButton; + QFrame *systemFrame; + CollapseButton *displayCollapseButton; + QFrame *displayFrame; + CollapseButton *storageCollapseButton; + QFrame *storageFrame; +#endif }; -#endif //QT_VMMANAGER_DETAILS_H +#endif // QT_VMMANAGER_DETAILS_H diff --git a/src/qt/qt_vmmanager_detailsection.cpp b/src/qt/qt_vmmanager_detailsection.cpp index ffd8668b4..0b19f77cd 100644 --- a/src/qt/qt_vmmanager_detailsection.cpp +++ b/src/qt/qt_vmmanager_detailsection.cpp @@ -20,7 +20,7 @@ #define HEADER_STYLESHEET_LIGHT "background-color: palette(midlight);" #ifdef Q_OS_WINDOWS -# define HEADER_STYLESHEET_DARK "background-color: #616161;" +# define HEADER_STYLESHEET_DARK "background-color: #616161;" # define BACKGROUND_STYLESHEET_DARK "background-color: #272727;" #else # define HEADER_STYLESHEET_DARK "background-color: palette(mid);" @@ -30,7 +30,7 @@ const QString VMManagerDetailSection::sectionSeparator = ";"; using namespace VMManager; VMManagerDetailSection:: -VMManagerDetailSection(const QString §ionName) + VMManagerDetailSection(const QString §ionName) : mainLayout(new QVBoxLayout()) , buttonLayout(new QHBoxLayout()) , frame(new QFrame()) @@ -80,7 +80,8 @@ VMManagerDetailSection(const QString §ionName) } VMManagerDetailSection:: -VMManagerDetailSection(const QVariant &varSectionName) : ui(new Ui::DetailSection) + VMManagerDetailSection(const QVariant &varSectionName) + : ui(new Ui::DetailSection) { const auto sectionName = varSectionName.toString(); @@ -100,7 +101,7 @@ VMManagerDetailSection(const QVariant &varSectionName) : ui(new Ui::DetailSectio const auto buttonWidget = new QWidget(this); - mainLayout = new QVBoxLayout(); + mainLayout = new QVBoxLayout(); buttonLayout = new QHBoxLayout(); buttonWidget->setLayout(buttonLayout); @@ -130,7 +131,7 @@ VMManagerDetailSection(const QVariant &varSectionName) : ui(new Ui::DetailSectio } VMManagerDetailSection::~VMManagerDetailSection() -= default; + = default; void VMManagerDetailSection::setSectionName(const QString &name) @@ -144,7 +145,7 @@ VMManagerDetailSection::setSectionName(const QString &name) void VMManagerDetailSection::addSection(const QString &name, const QString &value, VMManager::Display::Name displayField) { - const auto new_section = DetailSection { name, value}; + const auto new_section = DetailSection { name, value }; sections.push_back(new_section); } @@ -158,14 +159,14 @@ VMManagerDetailSection::setupMainLayout() void VMManagerDetailSection::setSections() { - int row = 0; + int row = 0; bool empty = true; - for (const auto& section : sections) { + for (const auto §ion : sections) { QStringList sectionsToAdd = section.value.split(sectionSeparator); - QLabel *labelKey = nullptr; + QLabel *labelKey = nullptr; - for (const auto& line : sectionsToAdd) { + for (const auto &line : sectionsToAdd) { if (line.isEmpty()) { // Don't bother adding entries if the values are blank continue; @@ -203,10 +204,10 @@ VMManagerDetailSection::clear() setVisible(false); // Clear everything out - if(frameGridLayout) { - while(frameGridLayout->count()) { - QLayoutItem * cur_item = frameGridLayout->takeAt(0); - if(cur_item->widget()) + if (frameGridLayout) { + while (frameGridLayout->count()) { + QLayoutItem *cur_item = frameGridLayout->takeAt(0); + if (cur_item->widget()) delete cur_item->widget(); delete cur_item; } @@ -242,15 +243,15 @@ VMManagerDetailSection::getMargins(const MarginSection section) switch (section) { case MarginSection::ToolButton: #if defined(Q_OS_WINDOWS) or defined(Q_OS_LINUX) - return {10, 0, 5, 0}; + return { 10, 0, 5, 0 }; #else - return {0, 0, 5, 0}; + return { 0, 0, 5, 0 }; #endif case MarginSection::DisplayGrid: #if defined(Q_OS_WINDOWS) or defined(Q_OS_LINUX) - return {10, 0, 0, 10}; + return { 10, 0, 0, 10 }; #else - return {0, 0, 0, 10}; + return { 0, 0, 0, 10 }; #endif default: return {}; @@ -259,7 +260,10 @@ VMManagerDetailSection::getMargins(const MarginSection section) // CollapseButton Class -CollapseButton::CollapseButton(QWidget *parent) : QToolButton(parent), content_(nullptr) { +CollapseButton::CollapseButton(QWidget *parent) + : QToolButton(parent) + , content_(nullptr) +{ setCheckable(true); setStyleSheet("background:none; border:none;"); setIconSize(QSize(8, 8)); @@ -267,16 +271,20 @@ CollapseButton::CollapseButton(QWidget *parent) : QToolButton(parent), content_( setToolButtonStyle(Qt::ToolButtonTextBesideIcon); connect(this, &QToolButton::toggled, [=](const bool checked) { setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow); - content_ != nullptr && checked ? showContent() : hideContent(); + content_ != nullptr &&checked ? showContent() : hideContent(); }); setChecked(true); } -void CollapseButton::setButtonText(const QString &text) { +void +CollapseButton::setButtonText(const QString &text) +{ setText(" " + text); } -void CollapseButton::setContent(QWidget *content) { +void +CollapseButton::setContent(QWidget *content) +{ assert(content != nullptr); content_ = content; const auto animation_ = new QPropertyAnimation(content_, "maximumHeight"); // QObject with auto delete @@ -292,12 +300,16 @@ void CollapseButton::setContent(QWidget *content) { } } -void CollapseButton::hideContent() { +void +CollapseButton::hideContent() +{ animator_.setDirection(QAbstractAnimation::Backward); animator_.start(); } -void CollapseButton::showContent() { +void +CollapseButton::showContent() +{ animator_.setDirection(QAbstractAnimation::Forward); animator_.start(); } diff --git a/src/qt/qt_vmmanager_detailsection.hpp b/src/qt/qt_vmmanager_detailsection.hpp index bca245275..71a3c992e 100644 --- a/src/qt/qt_vmmanager_detailsection.hpp +++ b/src/qt/qt_vmmanager_detailsection.hpp @@ -24,7 +24,9 @@ #include "qt_vmmanager_system.hpp" QT_BEGIN_NAMESPACE -namespace Ui { class DetailSection; } +namespace Ui { +class DetailSection; +} QT_END_NAMESPACE class CollapseButton final : public QToolButton { @@ -42,8 +44,8 @@ public: void showContent(); private: - QWidget *content_; - QString text_; + QWidget *content_; + QString text_; QParallelAnimationGroup animator_; }; @@ -61,13 +63,13 @@ public: void setSections(); void clear(); - QLabel *tableLabel; + QLabel *tableLabel; CollapseButton *collapseButton; -// QGridLayout *buttonGridLayout; + // QGridLayout *buttonGridLayout; QGridLayout *frameGridLayout; QVBoxLayout *mainLayout; QHBoxLayout *buttonLayout; - QFrame *frame; + QFrame *frame; static const QString sectionSeparator; @@ -96,8 +98,7 @@ private: }; QVector sections; - Ui::DetailSection *ui; - + Ui::DetailSection *ui; }; #endif // QT_VMMANAGER_DETAILSECTION_H diff --git a/src/qt/qt_vmmanager_listviewdelegate.cpp b/src/qt/qt_vmmanager_listviewdelegate.cpp index 67fb80bb7..88d123ce9 100644 --- a/src/qt/qt_vmmanager_listviewdelegate.cpp +++ b/src/qt/qt_vmmanager_listviewdelegate.cpp @@ -1,17 +1,17 @@ /* -* 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. -* -* 86Box VM manager list view delegate module -* -* Authors: cold-brewed -* -* Copyright 2024 cold-brewed -*/ + * 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. + * + * 86Box VM manager list view delegate module + * + * Authors: cold-brewed + * + * Copyright 2024 cold-brewed + */ #include #include "qt_util.hpp" @@ -22,25 +22,27 @@ // from https://stackoverflow.com/questions/53105343/is-it-possible-to-add-a-custom-widget-into-a-qlistview VMManagerListViewDelegate::VMManagerListViewDelegate(QObject *parent) - : QStyledItemDelegate(parent), - m_ptr(new VMManagerListViewDelegateStyle) + : QStyledItemDelegate(parent) + , m_ptr(new VMManagerListViewDelegateStyle) { default_icon = QIcon(":/settings/qt/icons/86Box-gray.ico"); - stop_icon = QApplication::style()->standardIcon(QStyle::SP_MediaStop); + stop_icon = QApplication::style()->standardIcon(QStyle::SP_MediaStop); running_icon = QIcon(":/menuicons/qt/icons/run.ico"); stopped_icon = QIcon(":/menuicons/qt/icons/acpi_shutdown.ico"); - paused_icon = QIcon(":/menuicons/qt/icons/pause.ico"); + paused_icon = QIcon(":/menuicons/qt/icons/pause.ico"); unknown_icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion); highlight_color = QColor("#616161"); - bg_color = QColor("#272727"); + bg_color = QColor("#272727"); } VMManagerListViewDelegate::~VMManagerListViewDelegate() -= default; + = default; -void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const { +void +VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ bool windows_light_mode = true; #ifdef Q_OS_WINDOWS windows_light_mode = util::isWindowsLightTheme(); @@ -51,16 +53,16 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI // opt.rect = opt.rect.adjusted(0, 0, 0, 20); const QRect &rect(opt.rect); const QRect &contentRect(rect.adjusted(m_ptr->margins.left(), - m_ptr->margins.top(), - -m_ptr->margins.right(), - -m_ptr->margins.bottom())); + m_ptr->margins.top(), + -m_ptr->margins.right(), + -m_ptr->margins.bottom())); // The status icon represents the current state of the vm. Initially set to a default state. auto process_variant = index.data(VMManagerModel::Roles::ProcessStatus); - auto process_status = process_variant.value(); + auto process_status = process_variant.value(); // The main icon, configurable. Falls back to default if it cannot be loaded. auto customIcon = index.data(VMManagerModel::Roles::Icon).toString(); - opt.icon = default_icon; + opt.icon = default_icon; if (!customIcon.isEmpty()) { const auto customPixmap = QPixmap(customIcon); if (!customPixmap.isNull()) @@ -69,7 +71,7 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI // Set the status icon based on the process status QIcon status_icon; - switch(process_status) { + switch (process_status) { case VMManagerSystem::ProcessStatus::Running: status_icon = running_icon; break; @@ -85,12 +87,11 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI status_icon = unknown_icon; } - // Used to determine if the horizontal separator should be drawn - const bool lastIndex = (index.model()->rowCount() - 1) == index.row(); - const bool hasIcon = !opt.icon.isNull(); - const int bottomEdge = rect.bottom(); - QFont f(opt.font); + const bool lastIndex = (index.model()->rowCount() - 1) == index.row(); + const bool hasIcon = !opt.icon.isNull(); + const int bottomEdge = rect.bottom(); + QFont f(opt.font); f.setPointSizeF(m_ptr->statusFontPointSize(opt.font)); @@ -102,11 +103,11 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI // Draw the background if (opt.state & QStyle::State_Selected) { // When selected, only draw the highlighted part until the horizontal separator - int offset = 2; + int offset = 2; auto highlightRect = rect.adjusted(0, 0, 0, -offset); painter->fillRect(highlightRect, windows_light_mode ? palette.highlight().color() : highlight_color); // Then fill the remainder with the normal color - auto regularRect = rect.adjusted(0, rect.height()-offset, 0, 0); + auto regularRect = rect.adjusted(0, rect.height() - offset, 0, 0); painter->fillRect(regularRect, windows_light_mode ? palette.light().color() : bg_color); } else { // Otherwise just draw the background color as usual @@ -129,16 +130,16 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI QRect systemNameRect(m_ptr->systemNameBox(opt, index)); systemNameRect.moveTo(m_ptr->margins.left() + m_ptr->iconSize.width() - + m_ptr->spacingHorizontal, contentRect.top()); + + m_ptr->spacingHorizontal, + contentRect.top()); // If desired, font can be changed here -// painter->setFont(f); + // painter->setFont(f); painter->setFont(opt.font); painter->setPen(palette.text().color()); painter->drawText(systemNameRect, Qt::TextSingleLine, opt.text); // Draw status icon - painter->drawPixmap(systemNameRect.left(), systemNameRect.bottom() - + m_ptr->spacingVertical, + painter->drawPixmap(systemNameRect.left(), systemNameRect.bottom() + m_ptr->spacingVertical, status_icon.pixmap(m_ptr->smallIconSize)); // This rectangle is around the status icon @@ -150,53 +151,58 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI // Draw status text QRect statusRect(m_ptr->statusBox(opt, index)); - int extraaa = 2; + int extraaa = 2; statusRect.moveTo(systemNameRect.left() + m_ptr->margins.left() + m_ptr->smallIconSize.width(), - systemNameRect.bottom() + m_ptr->spacingVertical + extraaa + (m_ptr->smallIconSize.height() - systemNameRect.height() )); + systemNameRect.bottom() + m_ptr->spacingVertical + extraaa + (m_ptr->smallIconSize.height() - systemNameRect.height())); -// painter->setFont(opt.font); + // painter->setFont(opt.font); painter->setFont(f); painter->setPen(palette.windowText().color()); painter->drawText(statusRect, Qt::TextSingleLine, index.data(VMManagerModel::Roles::ProcessStatusString).toString()); painter->restore(); - } -QMargins VMManagerListViewDelegate::contentsMargins() const +QMargins +VMManagerListViewDelegate::contentsMargins() const { return m_ptr->margins; } -void VMManagerListViewDelegate::setContentsMargins(const int left, const int top, const int right, const int bottom) const +void +VMManagerListViewDelegate::setContentsMargins(const int left, const int top, const int right, const int bottom) const { m_ptr->margins = QMargins(left, top, right, bottom); } -int VMManagerListViewDelegate::horizontalSpacing() const +int +VMManagerListViewDelegate::horizontalSpacing() const { return m_ptr->spacingHorizontal; } -void VMManagerListViewDelegate::setHorizontalSpacing(const int spacing) const +void +VMManagerListViewDelegate::setHorizontalSpacing(const int spacing) const { m_ptr->spacingHorizontal = spacing; } -int VMManagerListViewDelegate::verticalSpacing() const +int +VMManagerListViewDelegate::verticalSpacing() const { return m_ptr->spacingVertical; } -void VMManagerListViewDelegate::setVerticalSpacing(const int spacing) const +void +VMManagerListViewDelegate::setVerticalSpacing(const int spacing) const { m_ptr->spacingVertical = spacing; } - -QSize VMManagerListViewDelegate::sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const +QSize +VMManagerListViewDelegate::sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const { QStyleOptionViewItem opt(option); initStyleOption(&opt, index); @@ -204,45 +210,48 @@ QSize VMManagerListViewDelegate::sizeHint(const QStyleOptionViewItem &option, const int textHeight = m_ptr->systemNameBox(opt, index).height() + m_ptr->spacingVertical + m_ptr->statusBox(opt, index).height(); const int iconHeight = m_ptr->iconSize.height(); - const int h = textHeight > iconHeight ? textHeight : iconHeight; + const int h = textHeight > iconHeight ? textHeight : iconHeight; // return the same width // for height, add margins on top and bottom *plus* either the text or icon height, whichever is greater // Note: text height is the combined value of the system name and the status just below the name - return {opt.rect.width(), m_ptr->margins.top() + h - + m_ptr->margins.bottom()}; + return { opt.rect.width(), m_ptr->margins.top() + h + m_ptr->margins.bottom() }; } -VMManagerListViewDelegateStyle::VMManagerListViewDelegateStyle() : - iconSize(32, 32), - smallIconSize(16, 16), +VMManagerListViewDelegateStyle::VMManagerListViewDelegateStyle() + : iconSize(32, 32) + , smallIconSize(16, 16) + , // bottom gets a little more than the top because of the custom separator - margins(4, 10, 8, 12), + margins(4, 10, 8, 12) + , // Spacing between icon and text - spacingHorizontal(8), - spacingVertical(4) + spacingHorizontal(8) + , spacingVertical(4) { // } -QRect VMManagerListViewDelegateStyle::statusBox(const QStyleOptionViewItem &option, - const QModelIndex &index) const +QRect +VMManagerListViewDelegateStyle::statusBox(const QStyleOptionViewItem &option, + const QModelIndex &index) const { QFont f(option.font); f.setPointSizeF(statusFontPointSize(option.font)); - return QFontMetrics(f).boundingRect(index.data(VMManagerModel::Roles::ProcessStatusString).toString()) - .adjusted(0, 0, 1, 1); + return QFontMetrics(f).boundingRect(index.data(VMManagerModel::Roles::ProcessStatusString).toString()).adjusted(0, 0, 1, 1); } -qreal VMManagerListViewDelegateStyle::statusFontPointSize(const QFont &f) const +qreal +VMManagerListViewDelegateStyle::statusFontPointSize(const QFont &f) const { - return 0.75*f.pointSize(); -// return 1*f.pointSize(); + return 0.75 * f.pointSize(); + // return 1*f.pointSize(); } -QRect VMManagerListViewDelegateStyle::systemNameBox(const QStyleOptionViewItem &option, const QModelIndex &index) const +QRect +VMManagerListViewDelegateStyle::systemNameBox(const QStyleOptionViewItem &option, const QModelIndex &index) const { return option.fontMetrics.boundingRect(option.text).adjusted(0, 0, 1, 1); } diff --git a/src/qt/qt_vmmanager_listviewdelegate.hpp b/src/qt/qt_vmmanager_listviewdelegate.hpp index a561c89d2..db86824d4 100644 --- a/src/qt/qt_vmmanager_listviewdelegate.hpp +++ b/src/qt/qt_vmmanager_listviewdelegate.hpp @@ -19,20 +19,19 @@ #include #include "qt_vmmanager_system.hpp" -class VMManagerListViewDelegateStyle -{ +class VMManagerListViewDelegateStyle { VMManagerListViewDelegateStyle(); [[nodiscard]] inline QRect systemNameBox(const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const; [[nodiscard]] inline qreal statusFontPointSize(const QFont &f) const; [[nodiscard]] inline QRect statusBox(const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize iconSize; - QSize smallIconSize; + QSize iconSize; + QSize smallIconSize; QMargins margins; - int spacingHorizontal; - int spacingVertical; + int spacingHorizontal; + int spacingVertical; friend class VMManagerListViewDelegate; }; @@ -46,18 +45,19 @@ public: using QStyledItemDelegate::QStyledItemDelegate; [[nodiscard]] QMargins contentsMargins() const; - void setContentsMargins(int left, int top, int right, int bottom) const; + void setContentsMargins(int left, int top, int right, int bottom) const; [[nodiscard]] int horizontalSpacing() const; - void setHorizontalSpacing(int spacing) const; + void setHorizontalSpacing(int spacing) const; [[nodiscard]] int verticalSpacing() const; - void setVerticalSpacing(int spacing) const; + void setVerticalSpacing(int spacing) const; - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; [[nodiscard]] QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + const QModelIndex &index) const override; + private: VMManagerListViewDelegateStyle *m_ptr; diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 5bc936268..54e0c619f 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -33,41 +33,33 @@ #include "qt_vmmanager_model.hpp" #include "qt_vmmanager_addmachine.hpp" -extern VMManagerMainWindow* vmm_main_window; +extern VMManagerMainWindow *vmm_main_window; // https://stackoverflow.com/a/36460740 -bool copyPath(QString sourceDir, QString destinationDir, bool overWriteDirectory) +bool +copyPath(QString sourceDir, QString destinationDir, bool overWriteDirectory) { QDir originDirectory(sourceDir); - if (! originDirectory.exists()) - { + if (!originDirectory.exists()) return false; - } QDir destinationDirectory(destinationDir); - if(destinationDirectory.exists() && !overWriteDirectory) - { + if (destinationDirectory.exists() && !overWriteDirectory) return false; - } - else if(destinationDirectory.exists() && overWriteDirectory) - { + else if (destinationDirectory.exists() && overWriteDirectory) destinationDirectory.removeRecursively(); - } originDirectory.mkpath(destinationDir); - foreach (QString directoryName, originDirectory.entryList(QDir::Dirs | \ - QDir::NoDotAndDotDot)) - { + foreach (QString directoryName, originDirectory.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { QString destinationPath = destinationDir + "/" + directoryName; originDirectory.mkpath(destinationPath); copyPath(sourceDir + "/" + directoryName, destinationPath, overWriteDirectory); } - foreach (QString fileName, originDirectory.entryList(QDir::Files)) - { + foreach (QString fileName, originDirectory.entryList(QDir::Files)) { QFile::copy(sourceDir + "/" + fileName, destinationDir + "/" + fileName); } @@ -75,21 +67,22 @@ bool copyPath(QString sourceDir, QString destinationDir, bool overWriteDirectory QDir finalDestination(destinationDir); finalDestination.refresh(); - if(finalDestination.exists()) - { + if (finalDestination.exists()) return true; - } return false; } -VMManagerMain::VMManagerMain(QWidget *parent) : - QWidget(parent), ui(new Ui::VMManagerMain), selected_sysconfig(new VMManagerSystem) { +VMManagerMain::VMManagerMain(QWidget *parent) + : QWidget(parent) + , ui(new Ui::VMManagerMain) + , selected_sysconfig(new VMManagerSystem) +{ ui->setupUi(this); // Set up the main listView ui->listView->setItemDelegate(new VMManagerListViewDelegate); - vm_model = new VMManagerModel; + vm_model = new VMManagerModel; proxy_model = new StringListProxyModel(this); proxy_model->setSourceModel(vm_model); ui->listView->setModel(proxy_model); @@ -157,16 +150,15 @@ VMManagerMain::VMManagerMain(QWidget *parent) : contextMenu.addAction(&nameChangeAction); // Use a lambda to call a function so indexAt can be passed connect(&nameChangeAction, &QAction::triggered, ui->listView, [this, indexAt] { - updateDisplayName(indexAt); + updateDisplayName(indexAt); }); nameChangeAction.setEnabled(!selected_sysconfig->window_obscured); - QAction setSystemIcon(tr("Set &icon...")); contextMenu.addAction(&setSystemIcon); connect(&setSystemIcon, &QAction::triggered, [this] { IconSelectionDialog dialog(":/systemicons/"); - if(dialog.exec() == QDialog::Accepted) { + if (dialog.exec() == QDialog::Accepted) { const QString iconName = dialog.getSelectedIconName(); // A Blank iconName will cause setIcon to reset to the default selected_sysconfig->setIcon(iconName); @@ -180,28 +172,28 @@ VMManagerMain::VMManagerMain(QWidget *parent) : contextMenu.addAction(&cloneMachine); connect(&cloneMachine, &QAction::triggered, [this] { QDialog dialog = QDialog(this); - auto layout = new QVBoxLayout(&dialog); + auto layout = new QVBoxLayout(&dialog); layout->setSizeConstraint(QLayout::SetFixedSize); layout->addWidget(new QLabel(tr("Virtual machine \"%1\" (%2) will be cloned into:").arg(selected_sysconfig->displayName, selected_sysconfig->config_dir))); - QLineEdit* edit = new QLineEdit(&dialog); + QLineEdit *edit = new QLineEdit(&dialog); layout->addWidget(edit); - QLabel* errLabel = new QLabel(&dialog); + QLabel *errLabel = new QLabel(&dialog); layout->addWidget(errLabel); errLabel->setVisible(false); - QDialogButtonBox* buttonBox = new QDialogButtonBox(&dialog); + QDialogButtonBox *buttonBox = new QDialogButtonBox(&dialog); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true); connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); layout->addWidget(buttonBox); - connect(edit, &QLineEdit::textChanged, this, [errLabel, buttonBox] (const QString& text) { + connect(edit, &QLineEdit::textChanged, this, [errLabel, buttonBox](const QString &text) { bool isSpaceOnly = true; #ifdef Q_OS_WINDOWS const char illegalChars[] = "<>:\"|?*\\/"; #else const char illegalChars[] = "\\/"; #endif - for (const auto& curChar : text) { + for (const auto &curChar : text) { for (size_t i = 0; i < sizeof(illegalChars) - 1; i++) { if (illegalChars[i] == curChar) { goto illegal_chars; @@ -236,9 +228,9 @@ illegal_chars: }); if (dialog.exec() > 0) { - std::atomic_bool finished{false}; + std::atomic_bool finished { false }; std::atomic_bool errCode; - auto vmDir = QDir(vmm_path).canonicalPath(); + auto vmDir = QDir(vmm_path).canonicalPath(); vmDir.append("/"); vmDir.append(edit->text()); vmDir.append("/"); @@ -248,7 +240,7 @@ illegal_chars: return; } - QProgressDialog* progDialog = new QProgressDialog(this); + QProgressDialog *progDialog = new QProgressDialog(this); progDialog->setMaximum(0); progDialog->setMinimum(0); progDialog->setWindowFlags(progDialog->windowFlags() & ~Qt::WindowCloseButtonHint); @@ -266,7 +258,7 @@ illegal_chars: QString dstPath = vmDir; std::thread copyThread([&finished, srcPath, dstPath, &errCode] { - errCode = copyPath(srcPath, dstPath, true); + errCode = copyPath(srcPath, dstPath, true); finished = true; }); while (!finished) { @@ -346,7 +338,7 @@ illegal_chars: QDir dir(configDir); if (!dir.exists()) dir.mkpath("."); - + QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath())); } }); @@ -358,7 +350,7 @@ illegal_chars: QDir dir(printerDir); if (!dir.exists()) dir.mkpath("."); - + QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath())); } }); @@ -370,7 +362,7 @@ illegal_chars: QDir dir(screenshotsDir); if (!dir.exists()) dir.mkpath("."); - + QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath())); } }); @@ -395,7 +387,7 @@ illegal_chars: } }); - connect(vm_model, &VMManagerModel::globalConfigurationChanged, this, [] () { + connect(vm_model, &VMManagerModel::globalConfigurationChanged, this, []() { vmm_main_window->updateSettings(); }); @@ -416,7 +408,7 @@ illegal_chars: // Load and apply settings loadSettings(); - ui->splitter->setSizes({ui->detailsArea->width(), (ui->listView->minimumWidth() * 2)}); + ui->splitter->setSizes({ ui->detailsArea->width(), (ui->listView->minimumWidth() * 2) }); // Set up search bar connect(ui->searchBar, &QLineEdit::textChanged, this, &VMManagerMain::searchSystems); @@ -439,14 +431,14 @@ illegal_chars: #if EMU_BUILD_NUM != 0 // Start update check after a slight delay QTimer::singleShot(1000, this, [this] { - if(updateCheck) { - backgroundUpdateCheckStart(); - } + if (updateCheck) + backgroundUpdateCheckStart(); }); #endif } -VMManagerMain::~VMManagerMain() { +VMManagerMain::~VMManagerMain() +{ delete ui; delete vm_model; } @@ -459,11 +451,10 @@ VMManagerMain::updateGlobalSettings() void VMManagerMain::currentSelectionChanged(const QModelIndex ¤t, - const QModelIndex &previous) + const QModelIndex &previous) { - if(!current.isValid()) { + if (!current.isValid()) return; - } /* hack to prevent strange segfaults when adding a machine after removing all machines previously */ @@ -472,7 +463,7 @@ VMManagerMain::currentSelectionChanged(const QModelIndex ¤t, selected_sysconfig->config_signal_connected = false; } const auto mapped_index = proxy_model->mapToSource(current); - selected_sysconfig = vm_model->getConfigObjectForIndex(mapped_index); + selected_sysconfig = vm_model->getConfigObjectForIndex(mapped_index); vm_details->updateData(selected_sysconfig); if (selected_sysconfig->config_signal_connected == false) { connect(selected_sysconfig, &VMManagerSystem::configurationChanged, this, &VMManagerMain::onConfigUpdated); @@ -481,60 +472,59 @@ VMManagerMain::currentSelectionChanged(const QModelIndex ¤t, // Emit that the selection changed, include with the process state emit selectionChanged(current, selected_sysconfig->process->state()); - } void -VMManagerMain::settingsButtonPressed() { - if(!currentSelectionIsValid()) { +VMManagerMain::settingsButtonPressed() +{ + if (!currentSelectionIsValid()) return; - } + selected_sysconfig->launchSettings(); } void VMManagerMain::startButtonPressed() const { - if(!currentSelectionIsValid()) { + if (!currentSelectionIsValid()) return; - } + selected_sysconfig->startButtonPressed(); } void VMManagerMain::restartButtonPressed() const { - if(!currentSelectionIsValid()) { + if (!currentSelectionIsValid()) return; - } - selected_sysconfig->restartButtonPressed(); + selected_sysconfig->restartButtonPressed(); } void VMManagerMain::pauseButtonPressed() const { - if(!currentSelectionIsValid()) { + if (!currentSelectionIsValid()) return; - } + selected_sysconfig->pauseButtonPressed(); } void VMManagerMain::shutdownRequestButtonPressed() const { - if (!currentSelectionIsValid()) { + if (!currentSelectionIsValid()) return; - } + selected_sysconfig->shutdownRequestButtonPressed(); } void VMManagerMain::shutdownForceButtonPressed() const { - if (!currentSelectionIsValid()) { + if (!currentSelectionIsValid()) return; - } + selected_sysconfig->shutdownForceButtonPressed(); } @@ -543,10 +533,10 @@ void VMManagerMain::refresh() { const auto current_index = ui->listView->currentIndex(); - emit selectionChanged(current_index, selected_sysconfig->process->state()); + emit selectionChanged(current_index, selected_sysconfig->process->state()); // if(!selected_sysconfig->config_file.path().isEmpty()) { - if(!selected_sysconfig->isValid()) { + if (!selected_sysconfig->isValid()) { // what was happening here? } } @@ -621,7 +611,7 @@ VMManagerMain::searchSystems(const QString &text) const { // Escape the search text string unless regular expression searching is enabled. // When escaped, the search string functions as a plain text match. - const auto searchText = regexSearch ? text : QRegularExpression::escape(text); + const auto searchText = regexSearch ? text : QRegularExpression::escape(text); const QRegularExpression regex(searchText, QRegularExpression::CaseInsensitiveOption); if (!regex.isValid()) { qDebug() << "Skipping, invalid regex"; @@ -640,11 +630,11 @@ VMManagerMain::newMachineWizard() { const auto wizard = new VMManagerAddMachine(this); if (wizard->exec() == QDialog::Accepted) { - const auto newName = wizard->field("systemName").toString(); + const auto newName = wizard->field("systemName").toString(); #ifdef CUSTOM_SYSTEM_LOCATION - const auto systemDir = wizard->field("systemLocation").toString(); + const auto systemDir = wizard->field("systemLocation").toString(); #else - const auto systemDir = QDir(vmm_path).path(); + const auto systemDir = QDir(vmm_path).path(); #endif const auto existingConfiguration = wizard->field("existingConfiguration").toString(); const auto displayName = wizard->field("displayName").toString(); @@ -693,8 +683,7 @@ VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QStri if (exitCode != 0 || exitStatus != QProcess::NormalExit) { qInfo().nospace().noquote() << "Abnormal program termination while creating new system: exit code " << exitCode << ", exit status " << exitStatus; qInfo() << "Not adding system due to errors"; - QString errMsg = tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg( - (!displayName.isEmpty() ? displayName : name), QString::number(exitCode)); + QString errMsg = tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg((!displayName.isEmpty() ? displayName : name), QString::number(exitCode)); QMessageBox::critical(this, tr("Error adding system"), QString("%1\n\n%2").arg(errMsg, tr("The system will not be added."))); fail = true; @@ -731,7 +720,6 @@ VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QStri }); } - void VMManagerMain::deleteSystem(VMManagerSystem *sysconfig) { @@ -804,8 +792,8 @@ VMManagerMain::modelDataChange() auto modelStats = vm_model->getProcessStats(); QStringList stats; for (auto it = modelStats.constBegin(); it != modelStats.constEnd(); ++it) { - const auto &key = it.key(); - QString text = ""; + const auto &key = it.key(); + QString text = ""; switch (key) { case VMManagerSystem::ProcessStatus::Running: text = tr("%n running", "", modelStats[key]); @@ -820,7 +808,7 @@ VMManagerMain::modelDataChange() default: break; } - if(!text.isEmpty()) + if (!text.isEmpty()) stats.append(text); } auto states = stats.join(", "); @@ -831,16 +819,14 @@ void VMManagerMain::onPreferencesUpdated() { // Only reload values that we care about - const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); + const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); const auto oldRegexSearch = regexSearch; - regexSearch = config->getStringValue("regex_search").toInt(); - if (oldRegexSearch != regexSearch) { + regexSearch = config->getStringValue("regex_search").toInt(); + if (oldRegexSearch != regexSearch) ui->searchBar->clear(); - } - if (vm_model) { + if (vm_model) vm_model->sendGlobalConfigurationChanged(); - } } void @@ -877,9 +863,9 @@ void VMManagerMain::backgroundUpdateCheckStart() const { auto updateChannel = UpdateCheck::UpdateChannel::CI; -#ifdef RELEASE_BUILD +# ifdef RELEASE_BUILD updateChannel = UpdateCheck::UpdateChannel::Stable; -#endif +# endif const auto updateCheck = new UpdateCheck(updateChannel); connect(updateCheck, &UpdateCheck::updateCheckComplete, this, &VMManagerMain::backgroundUpdateCheckComplete); connect(updateCheck, &UpdateCheck::updateCheckError, this, &VMManagerMain::backgroundUpdateCheckError); @@ -891,9 +877,9 @@ VMManagerMain::backgroundUpdateCheckComplete(const UpdateCheck::UpdateResult &re { qDebug() << "Check complete: update available?" << result.updateAvailable; if (result.updateAvailable) { - auto type = result.channel == UpdateCheck::UpdateChannel::CI ? tr("build") : tr("version"); + auto type = result.channel == UpdateCheck::UpdateChannel::CI ? tr("build") : tr("version"); const auto updateMessage = tr("An update to 86Box is available: %1 %2").arg(type, result.latestVersion); - emit updateStatusLeft(updateMessage); + emit updateStatusLeft(updateMessage); } } @@ -910,7 +896,7 @@ VMManagerMain::showTextFileContents(const QString &title, const QString &path) { // Make sure we can open the file const auto fi = QFileInfo(path); - if(!fi.exists()) { + if (!fi.exists()) { qWarning("Requested file does not exist: %s", path.toUtf8().constData()); return; } @@ -927,7 +913,7 @@ VMManagerMain::showTextFileContents(const QString &title, const QString &path) textDisplayDialog->setMinimumSize(QSize(540, 360)); textDisplayDialog->setWindowTitle(QString("%1 - %2").arg(title, fi.fileName())); - const auto textEdit = new QPlainTextEdit(); + const auto textEdit = new QPlainTextEdit(); const auto monospaceFont = new QFont(); #ifdef Q_OS_WINDOWS monospaceFont->setFamily("Consolas"); diff --git a/src/qt/qt_vmmanager_main.hpp b/src/qt/qt_vmmanager_main.hpp index 07d1ff0c1..b08939d1c 100644 --- a/src/qt/qt_vmmanager_main.hpp +++ b/src/qt/qt_vmmanager_main.hpp @@ -32,7 +32,9 @@ extern "C" { #endif QT_BEGIN_NAMESPACE -namespace Ui { class VMManagerMain; } +namespace Ui { +class VMManagerMain; +} QT_END_NAMESPACE class VMManagerMain final : public QWidget { @@ -90,24 +92,24 @@ public slots: private: Ui::VMManagerMain *ui; - VMManagerModel *vm_model; - VMManagerDetails *vm_details; - VMManagerSystem *selected_sysconfig; + VMManagerModel *vm_model; + VMManagerDetails *vm_details; + VMManagerSystem *selected_sysconfig; // VMManagerConfig *config; QSortFilterProxyModel *proxy_model; #if EMU_BUILD_NUM != 0 - bool updateCheck = false; + bool updateCheck = false; #endif - bool regexSearch = false; + bool regexSearch = false; // void updateSelection(const QItemSelection &selected, // const QItemSelection &deselected); - void currentSelectionChanged(const QModelIndex ¤t, - const QModelIndex &previous); - void refresh(); - void updateDisplayName(const QModelIndex &index); - void loadSettings(); - [[nodiscard]] bool currentSelectionIsValid() const; + void currentSelectionChanged(const QModelIndex ¤t, + const QModelIndex &previous); + void refresh(); + void updateDisplayName(const QModelIndex &index); + void loadSettings(); + [[nodiscard]] bool currentSelectionIsValid() const; [[nodiscard]] QString machineCountString(QString states = "") const; #if EMU_BUILD_NUM != 0 void backgroundUpdateCheckStart() const; @@ -129,7 +131,10 @@ class IconSelectionDialog final : public QDialog { Q_OBJECT public: - explicit IconSelectionDialog(QString assetPath, QWidget *parent = nullptr) : QDialog(parent), listWidget(new QListWidget) { + explicit IconSelectionDialog(QString assetPath, QWidget *parent = nullptr) + : QDialog(parent) + , listWidget(new QListWidget) + { // Set the list widget to icon mode listWidget->setViewMode(QListWidget::IconMode); setFixedSize(QSize(540, 360)); @@ -143,7 +148,7 @@ public: setWindowTitle(tr("Select an icon")); // Loop on all files and add them as items (icons) in QListWidget - for(const QString& iconName : iconsDir.entryList()) { + for (const QString &iconName : iconsDir.entryList()) { const auto item = new QListWidgetItem(QIcon(assetPath + iconName), iconName); // Set the UserRole to the resource bundle path item->setData(Qt::UserRole, assetPath + iconName); @@ -153,7 +158,7 @@ public: // Dialog buttons const auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset); // Use the reset button for resetting the icon to the default - const QPushButton* resetButton = buttonBox->button(QDialogButtonBox::Reset); + const QPushButton *resetButton = buttonBox->button(QDialogButtonBox::Reset); // Connect the buttons signals connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); @@ -171,8 +176,9 @@ public: layout->addWidget(buttonBox); } - public slots: - [[nodiscard]] QString getSelectedIconName() const { +public slots: + [[nodiscard]] QString getSelectedIconName() const + { if (listWidget->currentIndex().isValid()) { return listWidget->currentItem()->data(Qt::UserRole).toString(); } @@ -181,7 +187,7 @@ public: } private: - QListWidget* listWidget; + QListWidget *listWidget; }; -#endif //QT_VMMANAGER_MAIN_H +#endif // QT_VMMANAGER_MAIN_H diff --git a/src/qt/qt_vmmanager_mainwindow.cpp b/src/qt/qt_vmmanager_mainwindow.cpp index 864a2b17a..0e44e6a8c 100644 --- a/src/qt/qt_vmmanager_mainwindow.cpp +++ b/src/qt/qt_vmmanager_mainwindow.cpp @@ -30,17 +30,16 @@ #include #include -extern "C" -{ +extern "C" { extern void config_load_global(); extern void config_save_global(); } -VMManagerMainWindow* vmm_main_window = nullptr; -extern WindowsDarkModeFilter* vmm_dark_mode_filter; +VMManagerMainWindow *vmm_main_window = nullptr; +extern WindowsDarkModeFilter *vmm_dark_mode_filter; VMManagerMainWindow:: -VMManagerMainWindow(QWidget *parent) + VMManagerMainWindow(QWidget *parent) : ui(new Ui::VMManagerMainWindow) , vmm(new VMManagerMain(this)) , statusLeft(new QLabel) @@ -63,14 +62,14 @@ VMManagerMainWindow(QWidget *parent) connect(ui->actionHard_Reset, &QAction::triggered, vmm, &VMManagerMain::restartButtonPressed); connect(ui->actionForce_Shutdown, &QAction::triggered, vmm, &VMManagerMain::shutdownForceButtonPressed); - // Set up menu actions - // (Disable this if the EMU_BUILD_NUM == 0) - #if EMU_BUILD_NUM == 0 - ui->actionCheck_for_updates->setVisible(false); - #else - connect(ui->actionCheck_for_updates, &QAction::triggered, this, &VMManagerMainWindow::checkForUpdatesTriggered); - #endif - +// Set up menu actions +// (Disable this if the EMU_BUILD_NUM == 0) +#if EMU_BUILD_NUM == 0 + ui->actionCheck_for_updates->setVisible(false); +#else + connect(ui->actionCheck_for_updates, &QAction::triggered, this, &VMManagerMainWindow::checkForUpdatesTriggered); +#endif + // TODO: Remove all of this (all the way to END REMOVE) once certain the search will no longer be in the toolbar. // BEGIN REMOVE // Everything is still setup here for it but it is all hidden. None of it will be @@ -90,7 +89,7 @@ VMManagerMainWindow(QWidget *parent) searchBar->setClearButtonEnabled(true); // Spacer to make the search go all the way to the right const auto spacer = new QWidget(); - spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); ui->toolBar->addWidget(spacer); ui->toolBar->addWidget(searchBar); // Connect signal for search @@ -127,7 +126,7 @@ VMManagerMainWindow(QWidget *parent) connect(this, &VMManagerMainWindow::languageUpdated, vmm, &VMManagerMain::onLanguageUpdated); #ifdef Q_OS_WINDOWS connect(this, &VMManagerMainWindow::darkModeUpdated, vmm, &VMManagerMain::onDarkModeUpdated); - connect(this, &VMManagerMainWindow::preferencesUpdated, [] () { vmm_dark_mode_filter->reselectDarkMode(); }); + connect(this, &VMManagerMainWindow::preferencesUpdated, []() { vmm_dark_mode_filter->reselectDarkMode(); }); #endif { @@ -136,7 +135,7 @@ VMManagerMainWindow(QWidget *parent) QString coords = config->getStringValue("window_coordinates"); if (!coords.isEmpty()) { QStringList list = coords.split(','); - for (auto& cur : list) { + for (auto &cur : list) { cur = cur.trimmed(); } QRect geom; @@ -155,7 +154,7 @@ VMManagerMainWindow(QWidget *parent) QString splitter = config->getStringValue("window_splitter"); if (!splitter.isEmpty()) { QStringList list = splitter.split(','); - for (auto& cur : list) { + for (auto &cur : list) { cur = cur.trimmed(); } QList paneSizes; @@ -173,8 +172,7 @@ VMManagerMainWindow(QWidget *parent) } } -VMManagerMainWindow::~ -VMManagerMainWindow() +VMManagerMainWindow::~VMManagerMainWindow() = default; void @@ -224,7 +222,7 @@ void VMManagerMainWindow::saveSettings() const { const auto currentSelection = vmm->getCurrentSelection(); - const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); + const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); config->setStringValue("last_selection", currentSelection); if (!!config->getStringValue("window_remember").toInt()) { config->setStringValue("window_coordinates", QString::asprintf("%i, %i, %i, %i", this->geometry().x(), this->geometry().y(), this->geometry().width(), this->geometry().height())); @@ -249,7 +247,6 @@ VMManagerMainWindow::updateLanguage() emit languageUpdated(); } - #ifdef Q_OS_WINDOWS void VMManagerMainWindow::updateDarkMode() diff --git a/src/qt/qt_vmmanager_mainwindow.hpp b/src/qt/qt_vmmanager_mainwindow.hpp index 055e61808..c0e06f551 100644 --- a/src/qt/qt_vmmanager_mainwindow.hpp +++ b/src/qt/qt_vmmanager_mainwindow.hpp @@ -25,8 +25,7 @@ namespace Ui { class VMManagerMainWindow; } -class VMManagerMainWindow final : public QMainWindow -{ +class VMManagerMainWindow final : public QMainWindow { Q_OBJECT public: explicit VMManagerMainWindow(QWidget *parent = nullptr); @@ -41,10 +40,12 @@ signals: private: Ui::VMManagerMainWindow *ui; + VMManagerMain *vmm; - void saveSettings() const; - QLabel *statusLeft; - QLabel *statusRight; + void saveSettings() const; + QLabel *statusLeft; + QLabel *statusRight; + public slots: void setStatusLeft(const QString &text) const; void setStatusRight(const QString &text) const; diff --git a/src/qt/qt_vmmanager_model.cpp b/src/qt/qt_vmmanager_model.cpp index bd66862fd..8c631a2f2 100644 --- a/src/qt/qt_vmmanager_model.cpp +++ b/src/qt/qt_vmmanager_model.cpp @@ -15,28 +15,32 @@ #include #include "qt_vmmanager_model.hpp" -VMManagerModel::VMManagerModel() { +VMManagerModel::VMManagerModel() +{ auto machines_vec = VMManagerSystem::scanForConfigs(); - for ( const auto& each_config : machines_vec) { + for (const auto &each_config : machines_vec) { machines.append(each_config); connect(each_config, &VMManagerSystem::itemDataChanged, this, &VMManagerModel::modelDataChanged); connect(each_config, &VMManagerSystem::globalConfigurationChanged, this, &VMManagerModel::globalConfigurationChanged); } } -VMManagerModel::~VMManagerModel() { - for ( auto machine : machines) { +VMManagerModel::~VMManagerModel() +{ + for (auto machine : machines) { delete machine; } } int -VMManagerModel::rowCount(const QModelIndex &parent) const { +VMManagerModel::rowCount(const QModelIndex &parent) const +{ return machines.size(); } QVariant -VMManagerModel::data(const QModelIndex &index, int role) const { +VMManagerModel::data(const QModelIndex &index, int role) const +{ if (!index.isValid()) return {}; @@ -76,7 +80,8 @@ VMManagerModel::data(const QModelIndex &index, int role) const { } QVariant -VMManagerModel::headerData(int section, Qt::Orientation orientation, int role) const { +VMManagerModel::headerData(int section, Qt::Orientation orientation, int role) const +{ if (role != Qt::DisplayRole) return {}; @@ -93,7 +98,7 @@ VMManagerModel::getConfigObjectForIndex(const QModelIndex &index) const return machines.at(index.row()); } void -VMManagerModel::reload(QWidget* parent) +VMManagerModel::reload(QWidget *parent) { // Scan for configs auto machines_vec = VMManagerSystem::scanForConfigs(parent); @@ -112,16 +117,17 @@ VMManagerModel::reload(QWidget* parent) } void -VMManagerModel::refreshConfigs() { - for ( const auto& each_config : machines) +VMManagerModel::refreshConfigs() +{ + for (const auto &each_config : machines) each_config->reloadConfig(); } QModelIndex -VMManagerModel::getIndexForConfigFile(const QFileInfo& config_file) +VMManagerModel::getIndexForConfigFile(const QFileInfo &config_file) { int object_index = 0; - for (const auto& config_object: machines) { + for (const auto &config_object : machines) { if (config_object->config_file == config_file) { return this->index(object_index); } @@ -155,7 +161,7 @@ void VMManagerModel::modelDataChanged() { // Inform the model - emit dataChanged(this->index(0), this->index(machines.size()-1)); + emit dataChanged(this->index(0), this->index(machines.size() - 1)); // Inform any interested observers emit systemDataChanged(); } @@ -170,7 +176,7 @@ QMap VMManagerModel::getProcessStats() { QMap stats; - for (const auto& system: machines) { + for (const auto &system : machines) { stats[system->getProcessStatus()] += 1; } return stats; @@ -179,7 +185,7 @@ VMManagerModel::getProcessStats() void VMManagerModel::sendGlobalConfigurationChanged() { - for (auto& system: machines) { + for (auto &system : machines) { if (system->getProcessStatus() != VMManagerSystem::ProcessStatus::Stopped) { system->sendGlobalConfigurationChanged(); } @@ -190,7 +196,7 @@ int VMManagerModel::getActiveMachineCount() { int running = 0; - for (const auto& system: machines) { + for (const auto &system : machines) { if (system->getProcessStatus() != VMManagerSystem::ProcessStatus::Stopped) running++; } diff --git a/src/qt/qt_vmmanager_model.hpp b/src/qt/qt_vmmanager_model.hpp index 4e57dfd95..289892d91 100644 --- a/src/qt/qt_vmmanager_model.hpp +++ b/src/qt/qt_vmmanager_model.hpp @@ -42,29 +42,29 @@ public: Icon }; - [[nodiscard]] int rowCount(const QModelIndex &parent) const override; + [[nodiscard]] int rowCount(const QModelIndex &parent) const override; [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override; [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, - int role) const override; - void addConfigToModel(VMManagerSystem *system_config); - void removeConfigFromModel(VMManagerSystem *system_config); + int role) const override; + void addConfigToModel(VMManagerSystem *system_config); + void removeConfigFromModel(VMManagerSystem *system_config); - [[nodiscard]] VMManagerSystem * getConfigObjectForIndex(const QModelIndex &index) const; - QModelIndex getIndexForConfigFile(const QFileInfo& config_file); - void reload(QWidget* parent = nullptr); - void updateDisplayName(const QModelIndex &index, const QString &newDisplayName); + [[nodiscard]] VMManagerSystem *getConfigObjectForIndex(const QModelIndex &index) const; + QModelIndex getIndexForConfigFile(const QFileInfo &config_file); + void reload(QWidget *parent = nullptr); + void updateDisplayName(const QModelIndex &index, const QString &newDisplayName); QMap getProcessStats(); - int getActiveMachineCount(); - void refreshConfigs(); - void sendGlobalConfigurationChanged(); + int getActiveMachineCount(); + void refreshConfigs(); + void sendGlobalConfigurationChanged(); + signals: void systemDataChanged(); void globalConfigurationChanged(); private: QVector machines; - void modelDataChanged(); - + void modelDataChanged(); }; // Note: Custom QSortFilterProxyModel is included here instead of its own file as @@ -72,10 +72,14 @@ private: class StringListProxyModel final : public QSortFilterProxyModel { public: - explicit StringListProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) {} + explicit StringListProxyModel(QObject *parent = nullptr) + : QSortFilterProxyModel(parent) + { + } protected: - [[nodiscard]] bool filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const override { + [[nodiscard]] bool filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const override + { const QModelIndex index = sourceModel()->index(sourceRow, filterKeyColumn(), sourceParent); QStringList stringList = sourceModel()->data(index, VMManagerModel::Roles::SearchList).toStringList(); @@ -89,4 +93,4 @@ protected: } }; -#endif //QT_VMMANAGER_MODEL_H +#endif // QT_VMMANAGER_MODEL_H diff --git a/src/qt/qt_vmmanager_preferences.cpp b/src/qt/qt_vmmanager_preferences.cpp index d13fd8cdd..eb4f20d33 100644 --- a/src/qt/qt_vmmanager_preferences.cpp +++ b/src/qt/qt_vmmanager_preferences.cpp @@ -22,8 +22,8 @@ #include "ui_qt_vmmanager_preferences.h" #ifdef Q_OS_WINDOWS -#include "qt_vmmanager_windarkmodefilter.hpp" -extern WindowsDarkModeFilter* vmm_dark_mode_filter; +# include "qt_vmmanager_windarkmodefilter.hpp" +extern WindowsDarkModeFilter *vmm_dark_mode_filter; #endif extern "C" { @@ -33,18 +33,19 @@ extern "C" { } VMManagerPreferences:: -VMManagerPreferences(QWidget *parent) : ui(new Ui::VMManagerPreferences) + VMManagerPreferences(QWidget *parent) + : ui(new Ui::VMManagerPreferences) { ui->setupUi(this); ui->dirSelectButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon)); connect(ui->dirSelectButton, &QPushButton::clicked, this, &VMManagerPreferences::chooseDirectoryLocation); - const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); + const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); const auto configSystemDir = QString(vmm_path_cfg); - if(!configSystemDir.isEmpty()) { + if (!configSystemDir.isEmpty()) { // Prefer this one ui->systemDirectory->setText(QDir::toNativeSeparators(configSystemDir)); - } else if(!QString(vmm_path).isEmpty()) { + } else if (!QString(vmm_path).isEmpty()) { // If specified on command line ui->systemDirectory->setText(QDir::toNativeSeparators(QDir(vmm_path).path())); } @@ -79,8 +80,7 @@ VMManagerPreferences(QWidget *parent) : ui(new Ui::VMManagerPreferences) #endif } -VMManagerPreferences::~ -VMManagerPreferences() +VMManagerPreferences::~VMManagerPreferences() = default; // Bad copy pasta from machine add @@ -104,7 +104,7 @@ VMManagerPreferences::accept() const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); strncpy(vmm_path_cfg, QDir::cleanPath(ui->systemDirectory->text()).toUtf8().constData(), sizeof(vmm_path_cfg) - 1); - lang_id = ui->comboBoxLanguage->currentData().toInt(); + lang_id = ui->comboBoxLanguage->currentData().toInt(); color_scheme = (ui->radioButtonSystem->isChecked()) ? 0 : (ui->radioButtonLight->isChecked() ? 1 : 2); config_save_global(); diff --git a/src/qt/qt_vmmanager_preferences.hpp b/src/qt/qt_vmmanager_preferences.hpp index ee5cf1fe8..4215eb768 100644 --- a/src/qt/qt_vmmanager_preferences.hpp +++ b/src/qt/qt_vmmanager_preferences.hpp @@ -1,29 +1,29 @@ /* -* 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. -* -* Header for 86Box VM manager preferences module -* -* Authors: cold-brewed -* -* Copyright 2024 cold-brewed -*/ + * 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. + * + * Header for 86Box VM manager preferences module + * + * Authors: cold-brewed + * + * Copyright 2024 cold-brewed + */ #ifndef VMMANAGER_PREFERENCES_H #define VMMANAGER_PREFERENCES_H #include QT_BEGIN_NAMESPACE -namespace Ui { class VMManagerPreferences; } +namespace Ui { +class VMManagerPreferences; +} QT_END_NAMESPACE - -class VMManagerPreferences final : public QDialog -{ +class VMManagerPreferences final : public QDialog { Q_OBJECT public: explicit VMManagerPreferences(QWidget *parent = nullptr); @@ -31,14 +31,14 @@ public: private: Ui::VMManagerPreferences *ui; - QString settingsFile; + QString settingsFile; private slots: void chooseDirectoryLocation(); void on_pushButtonLanguage_released(); + protected: void accept() override; void reject() override; - }; #endif // VMMANAGER_PREFERENCES_H diff --git a/src/qt/qt_vmmanager_protocol.cpp b/src/qt/qt_vmmanager_protocol.cpp index 3091b0254..a389c96de 100644 --- a/src/qt/qt_vmmanager_protocol.cpp +++ b/src/qt/qt_vmmanager_protocol.cpp @@ -22,12 +22,12 @@ VMManagerProtocol::VMManagerProtocol(VMManagerProtocol::Sender sender) } VMManagerProtocol::~VMManagerProtocol() -= default; + = default; QJsonObject VMManagerProtocol::protocolManagerMessage(VMManagerProtocol::ManagerMessage message_type) { - auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Manager); + auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Manager); json_message["message"] = managerMessageTypeToString(message_type); return json_message; } @@ -35,7 +35,7 @@ VMManagerProtocol::protocolManagerMessage(VMManagerProtocol::ManagerMessage mess QJsonObject VMManagerProtocol::protocolClientMessage(VMManagerProtocol::ClientMessage message_type) { - auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Client); + auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Client); json_message["message"] = clientMessageTypeToString(message_type); return json_message; } @@ -58,16 +58,16 @@ QJsonObject VMManagerProtocol::constructDefaultObject(VMManagerProtocol::Sender type) { QJsonObject json_message; - QString sender_type = ( type == VMManagerProtocol::Sender::Client ) ? "Client" : "VMManager"; - json_message["type"] = QString(sender_type); + QString sender_type = (type == VMManagerProtocol::Sender::Client) ? "Client" : "VMManager"; + json_message["type"] = QString(sender_type); json_message["version"] = QStringLiteral(EMU_VERSION); return json_message; } bool -VMManagerProtocol::hasRequiredFields(const QJsonObject& json_document) +VMManagerProtocol::hasRequiredFields(const QJsonObject &json_document) { - for (const auto& field : ProtocolRequiredFields) { + for (const auto &field : ProtocolRequiredFields) { if (!json_document.contains(field)) { qDebug("Received json missing field \"%s\"", qPrintable(field)); return false; @@ -83,21 +83,21 @@ VMManagerProtocol::getClientMessageType(const QJsonObject &json_document) // required values. QString message_type = json_document.value("message").toString(); // Can't use switch with strings, manual compare - if (message_type == "Status") { + if (message_type == "Status") return VMManagerProtocol::ClientMessage::Status; - } else if (message_type == "WindowBlocked") { + else if (message_type == "WindowBlocked") return VMManagerProtocol::ClientMessage::WindowBlocked; - } else if (message_type == "WindowUnblocked") { + else if (message_type == "WindowUnblocked") return VMManagerProtocol::ClientMessage::WindowUnblocked; - } else if (message_type == "RunningStateChanged") { + else if (message_type == "RunningStateChanged") return VMManagerProtocol::ClientMessage::RunningStateChanged; - } else if (message_type == "ConfigurationChanged") { + else if (message_type == "ConfigurationChanged") return VMManagerProtocol::ClientMessage::ConfigurationChanged; - } else if (message_type == "WinIdMessage") { + else if (message_type == "WinIdMessage") return VMManagerProtocol::ClientMessage::WinIdMessage; - } else if (message_type == "GlobalConfigurationChanged") { + else if (message_type == "GlobalConfigurationChanged") return VMManagerProtocol::ClientMessage::GlobalConfigurationChanged; - } + return VMManagerProtocol::ClientMessage::UnknownMessage; } @@ -108,23 +108,29 @@ VMManagerProtocol::getManagerMessageType(const QJsonObject &json_document) // required values. QString message_type = json_document.value("message").toString(); // Can't use switch with strings, manual compare - if (message_type == "RequestStatus") { + if (message_type == "RequestStatus") return VMManagerProtocol::ManagerMessage::RequestStatus; - } else if (message_type == "Pause") { + else if (message_type == "Pause") return VMManagerProtocol::ManagerMessage::Pause; - } if (message_type == "CtrlAltDel") { + + if (message_type == "CtrlAltDel") return VMManagerProtocol::ManagerMessage::CtrlAltDel; - } if (message_type == "ShowSettings") { + + if (message_type == "ShowSettings") return VMManagerProtocol::ManagerMessage::ShowSettings; - } if (message_type == "ResetVM") { + + if (message_type == "ResetVM") return VMManagerProtocol::ManagerMessage::ResetVM; - } if (message_type == "RequestShutdown") { + + if (message_type == "RequestShutdown") return VMManagerProtocol::ManagerMessage::RequestShutdown; - } if (message_type == "ForceShutdown") { + + if (message_type == "ForceShutdown") return VMManagerProtocol::ManagerMessage::ForceShutdown; - } if (message_type == "GlobalConfigurationChanged") { + + if (message_type == "GlobalConfigurationChanged") return VMManagerProtocol::ManagerMessage::GlobalConfigurationChanged; - } + return VMManagerProtocol::ManagerMessage::UnknownMessage; } @@ -134,8 +140,8 @@ VMManagerProtocol::getParams(const QJsonObject &json_document) // FIXME: This key ("params") is hardcoded here. Make a hash which maps these // required values. auto params_object = json_document.value("params"); - if (params_object.type() != QJsonValue::Object) { + if (params_object.type() != QJsonValue::Object) return {}; - } + return params_object.toObject(); } diff --git a/src/qt/qt_vmmanager_serversocket.cpp b/src/qt/qt_vmmanager_serversocket.cpp index 36234feec..877a8a962 100644 --- a/src/qt/qt_vmmanager_serversocket.cpp +++ b/src/qt/qt_vmmanager_serversocket.cpp @@ -22,11 +22,11 @@ VMManagerServerSocket::VMManagerServerSocket(const QFileInfo &config_path, const ServerType type) { - server_type = type; - config_file = config_path; + server_type = type; + config_file = config_path; serverIsRunning = false; - socket = nullptr; - server = new QLocalServer; + socket = nullptr; + server = new QLocalServer; setupVars(); } @@ -36,7 +36,8 @@ VMManagerServerSocket::~VMManagerServerSocket() } bool -VMManagerServerSocket::startServer() { +VMManagerServerSocket::startServer() +{ // Remove socket file (if it exists) in order to start a new one qInfo("Socket path is %s", qPrintable(socket_path.filePath())); @@ -60,10 +61,11 @@ VMManagerServerSocket::startServer() { } void -VMManagerServerSocket::serverConnectionReceived() { +VMManagerServerSocket::serverConnectionReceived() +{ qDebug("Connection received on %s", qPrintable(socket_path.fileName())); socket = server->nextPendingConnection(); - if(!socket) { + if (!socket) { qInfo("Invalid socket when trying to receive the connection"); return; } @@ -72,14 +74,15 @@ VMManagerServerSocket::serverConnectionReceived() { } void -VMManagerServerSocket::serverReceivedMessage() { +VMManagerServerSocket::serverReceivedMessage() +{ // Handle legacy socket connections first. These connections only receive // information on window status - if(server_type == VMManagerServerSocket::ServerType::Legacy) { - QByteArray tempString = socket->read(1); - int window_obscured = tempString.toInt(); - emit windowStatusChanged(window_obscured); + if (server_type == VMManagerServerSocket::ServerType::Legacy) { + QByteArray tempString = socket->read(1); + int window_obscured = tempString.toInt(); + emit windowStatusChanged(window_obscured); return; } @@ -93,7 +96,7 @@ VMManagerServerSocket::serverReceivedMessage() { // Try to read the data stream >> jsonData; if (stream.commitTransaction()) { - QJsonParseError parse_error{}; + QJsonParseError parse_error {}; // Validate the received data to make sure it's valid json const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &parse_error); if (parse_error.error == QJsonParseError::NoError) { @@ -115,8 +118,9 @@ VMManagerServerSocket::serverReceivedMessage() { } void -VMManagerServerSocket::serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList& arguments) const { - if(!socket) { +VMManagerServerSocket::serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList &arguments) const +{ + if (!socket) { qInfo("Cannot send message: Invalid socket"); return; } @@ -124,7 +128,7 @@ VMManagerServerSocket::serverSendMessage(VMManagerProtocol::ManagerMessage proto // Regular connection QDataStream stream(socket); stream.setVersion(QDataStream::Qt_5_7); - auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Manager); + auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Manager); auto jsonMessage = packet->protocolManagerMessage(protocol_message); stream << QJsonDocument(jsonMessage).toJson(QJsonDocument::Compact); } @@ -145,7 +149,7 @@ VMManagerServerSocket::jsonReceived(const QJsonObject &json) qDebug() << json; return; } -// qDebug().noquote() << Q_FUNC_INFO << json; + // qDebug().noquote() << Q_FUNC_INFO << json; QJsonObject params_object; auto message_type = VMManagerProtocol::getClientMessageType(json); @@ -155,7 +159,7 @@ VMManagerServerSocket::jsonReceived(const QJsonObject &json) params_object = VMManagerProtocol::getParams(json); if (!params_object.isEmpty()) { // valid object - if(params_object.value("params").type() == QJsonValue::Double) { + if (params_object.value("params").type() == QJsonValue::Double) { emit winIdReceived(params_object.value("params").toVariant().toULongLong()); } } @@ -176,7 +180,7 @@ VMManagerServerSocket::jsonReceived(const QJsonObject &json) params_object = VMManagerProtocol::getParams(json); if (!params_object.isEmpty()) { // valid object - if(params_object.value("status").type() == QJsonValue::Double) { + if (params_object.value("status").type() == QJsonValue::Double) { // has status key, value is an int (qt assigns it as Double) emit runningStatusChanged(static_cast(params_object.value("status").toInt())); } diff --git a/src/qt/qt_vmmanager_serversocket.hpp b/src/qt/qt_vmmanager_serversocket.hpp index 87baa1027..71d0a124e 100644 --- a/src/qt/qt_vmmanager_serversocket.hpp +++ b/src/qt/qt_vmmanager_serversocket.hpp @@ -24,17 +24,17 @@ // This macro helps give us the required `qHash()` function in order to use the // enum as a hash key -#define QHASH_FOR_CLASS_ENUM(T) \ -inline uint qHash(const T &t, uint seed) { \ - return ::qHash(static_cast::type>(t), seed); \ -} +#define QHASH_FOR_CLASS_ENUM(T) \ + inline uint qHash(const T &t, uint seed) \ + { \ + return ::qHash(static_cast::type>(t), seed); \ + } class VMManagerServerSocket : public QWidget { Q_OBJECT public: - enum class ServerType { Standard, Legacy, @@ -53,16 +53,16 @@ public: QLocalServer *server; QLocalSocket *socket; ServerType server_type; - bool serverIsRunning; + bool serverIsRunning; // Server functions - bool startServer(); - void serverConnectionReceived(); - void serverReceivedMessage(); - void serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList& arguments = QStringList()) const; + bool startServer(); + void serverConnectionReceived(); + void serverReceivedMessage(); + void serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList &arguments = QStringList()) const; static void serverDisconnected(); - void jsonReceived(const QJsonObject &json); - QString getSocketPath() const; + void jsonReceived(const QJsonObject &json); + QString getSocketPath() const; static QString serverTypeToString(ServerType server_type_lookup); @@ -75,8 +75,6 @@ signals: void configurationChanged(); void globalConfigurationChanged(); void winIdReceived(WId id); - - }; #endif // QT_VMMANAGER_SERVERSOCKET_H diff --git a/src/qt/qt_vmmanager_system.cpp b/src/qt/qt_vmmanager_system.cpp index d3dfa2866..0a5039b12 100644 --- a/src/qt/qt_vmmanager_system.cpp +++ b/src/qt/qt_vmmanager_system.cpp @@ -31,7 +31,7 @@ #include "qt_vmmanager_detailsection.hpp" #ifdef Q_OS_WINDOWS -#include +# include #endif extern "C" { @@ -43,8 +43,8 @@ extern "C" { #include <86box/plat.h> #include <86box/sound.h> #include -#include <86box/thread.h> // required for network.h -#include <86box/timer.h> // required for network.h and fdd.h +#include <86box/thread.h> // required for network.h +#include <86box/timer.h> // required for network.h and fdd.h #include <86box/cdrom.h> #include <86box/cdrom_interface.h> #include <86box/scsi.h> @@ -67,7 +67,8 @@ extern "C" { using namespace VMManager; -VMManagerSystem::VMManagerSystem(const QString &sysconfig_file) { +VMManagerSystem::VMManagerSystem(const QString &sysconfig_file) +{ // The 86Box configuration file config_file = QFileInfo(sysconfig_file); @@ -76,7 +77,7 @@ VMManagerSystem::VMManagerSystem(const QString &sysconfig_file) { config_name = config_file.dir().dirName(); // The full path of the directory that contains the 86box configuration file config_dir = shortened_dir = config_file.dir().absolutePath(); - process_status = ProcessStatus::Stopped; + process_status = ProcessStatus::Stopped; // In the configuration file the UUID is used as a unique value uuid = util::generateUuid(sysconfig_file); // That unique value is used to map the information to each individual system. @@ -99,12 +100,12 @@ VMManagerSystem::VMManagerSystem(const QString &sysconfig_file) { find86BoxBinary(); platform = QApplication::platformName(); - process = new QProcess(); + process = new QProcess(); connect(process, &QProcess::stateChanged, this, &VMManagerSystem::processStatusChanged); // Server type for this instance (Standard should always be used instead of Legacy) socket_server_type = VMManagerServerSocket::ServerType::Standard; - socket_server = new VMManagerServerSocket(config_file, socket_server_type); + socket_server = new VMManagerServerSocket(config_file, socket_server_type); // NOTE: When unique names or UUIDs are written to the individual VM config file, use that // here instead of the auto-generated unique_name @@ -112,15 +113,16 @@ VMManagerSystem::VMManagerSystem(const QString &sysconfig_file) { saveSettings(); } -VMManagerSystem::~VMManagerSystem() { +VMManagerSystem::~VMManagerSystem() +{ delete socket_server; } QVector -VMManagerSystem::scanForConfigs(QWidget* parent, const QString &searchPath) +VMManagerSystem::scanForConfigs(QWidget *parent, const QString &searchPath) { QProgressDialog progDialog(parent); - unsigned int found = 0; + unsigned int found = 0; progDialog.setCancelButton(nullptr); progDialog.setWindowTitle(tr("Searching for VMs...")); progDialog.setMinimumDuration(0); @@ -134,17 +136,17 @@ VMManagerSystem::scanForConfigs(QWidget* parent, const QString &searchPath) scanTimer.start(); QVector system_configs; - const auto config_file_name = QString(CONFIG_FILE); - const QStringList filters = {config_file_name}; - QStringList matches; - QString search_directory; + const auto config_file_name = QString(CONFIG_FILE); + const QStringList filters = { config_file_name }; + QStringList matches; + QString search_directory; - search_directory = searchPath.isEmpty()? vmm_path : searchPath; + search_directory = searchPath.isEmpty() ? vmm_path : searchPath; - if(!QDir(search_directory).exists()) { - //qWarning() << "Path" << search_directory << "does not exist. Cannot continue"; + if (!QDir(search_directory).exists()) { + // qWarning() << "Path" << search_directory << "does not exist. Cannot continue"; QDir(search_directory).mkpath("."); - //return {}; + // return {}; } QDirIterator dir_iterator(search_directory, filters, QDir::Files, QDirIterator::Subdirectories); @@ -157,12 +159,12 @@ VMManagerSystem::scanForConfigs(QWidget* parent, const QString &searchPath) found++; progDialog.setLabelText(tr("Found %1").arg(QString::number(found))); QApplication::processEvents(); - QString filename = dir_iterator.next(); + QString filename = dir_iterator.next(); matches.append(filename); } const auto scanElapsed = timer.elapsed(); - qDebug().noquote().nospace() << "Found " << matches.size() << " configs in " << search_directory <<". Scan took " << scanElapsed << " ms"; + qDebug().noquote().nospace() << "Found " << matches.size() << " configs in " << search_directory << ". Scan took " << scanElapsed << " ms"; timer.restart(); // foreach (QFileInfo hit, matches) { @@ -197,14 +199,15 @@ VMManagerSystem::generateTemporaryFilename() } QFileInfoList -VMManagerSystem::getScreenshots() { +VMManagerSystem::getScreenshots() +{ // Don't bother unless the directory exists - if(!screenshot_directory.exists()) { + if (!screenshot_directory.exists()) { return {}; } - auto screen_scan_dir = QDir(screenshot_directory.path(), "Monitor_1*", QDir::SortFlag::LocaleAware | QDir::SortFlag::IgnoreCase, QDir::Files); + auto screen_scan_dir = QDir(screenshot_directory.path(), "Monitor_1*", QDir::SortFlag::LocaleAware | QDir::SortFlag::IgnoreCase, QDir::Files); auto screenshot_files = screen_scan_dir.entryInfoList(); return screenshot_files; } @@ -214,9 +217,9 @@ VMManagerSystem::loadSettings() { // First, load the information from the 86box.cfg QSettings settings(config_file.filePath(), QSettings::IniFormat); - if (settings.status() != QSettings::NoError) { + if (settings.status() != QSettings::NoError) qWarning() << "Error loading" << config_file.path() << " status:" << settings.status(); - } + // qInfo() << "Loaded "<< config_file.filePath() << "status:" << settings.status(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -239,14 +242,14 @@ VMManagerSystem::loadSettings() // QSettings will interpret lines with commas as QStringList. // Check for it and join them back to a string. #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (settings.value(key_name).typeId() == QMetaType::QStringList) { + if (settings.value(key_name).typeId() == QMetaType::QStringList) #else - if (settings.value(key_name).type() == QVariant::StringList) { + if (settings.value(key_name).type() == QVariant::StringList) #endif setting_value = settings.value(key_name).toStringList().join(", "); - } else { + else setting_value = settings.value(key_name).toString(); - } + config_hash[group_name][key_name] = setting_value; } settings.endGroup(); @@ -255,49 +258,46 @@ VMManagerSystem::loadSettings() // Next, load the information from the vmm config for this system // Display name auto loadedDisplayName = config_settings->getStringValue("display_name"); - if (!loadedDisplayName.isEmpty()) { + if (!loadedDisplayName.isEmpty()) displayName = loadedDisplayName; - } else { + else displayName = config_name; - } + // Notes auto loadedNotes = config_settings->getStringValue("notes"); - if (!loadedNotes.isEmpty()) { + if (!loadedNotes.isEmpty()) notes = loadedNotes; - } + // Timestamp auto loadedTimestamp = config_settings->getStringValue("timestamp"); if (!loadedTimestamp.isEmpty()) { // Make sure it is valid - if (auto newTimestamp = QDateTime::fromString(loadedTimestamp, Qt::ISODate); newTimestamp.isValid()) { + if (auto newTimestamp = QDateTime::fromString(loadedTimestamp, Qt::ISODate); newTimestamp.isValid()) lastUsedTimestamp = newTimestamp; - } } // Icon auto loadedIcon = config_settings->getStringValue("icon"); - if (!loadedIcon.isEmpty()) { + if (!loadedIcon.isEmpty()) icon = loadedIcon; - } } void VMManagerSystem::saveSettings() { - if(!isValid()) { + if (!isValid()) return; - } + config_settings->setStringValue("system_name", config_name); config_settings->setStringValue("config_file", config_file.canonicalFilePath()); config_settings->setStringValue("config_dir", config_file.canonicalPath()); - if (displayName != config_name) { + if (displayName != config_name) config_settings->setStringValue("display_name", displayName); - } else { + else config_settings->remove("display_name"); - } config_settings->setStringValue("notes", notes); - if(lastUsedTimestamp.isValid()) { + if (lastUsedTimestamp.isValid()) config_settings->setStringValue("timestamp", lastUsedTimestamp.toString(Qt::ISODate)); - } + config_settings->setStringValue("icon", icon); generateSearchTerms(); } @@ -308,10 +308,9 @@ VMManagerSystem::generateSearchTerms() for (const auto &config_key : config_hash.keys()) { // searchTerms.append(config_hash[config_key].values()); // brute force temporarily don't add paths - for(const auto &value: config_hash[config_key].values()) { - if(!value.startsWith("/")) { + for (const auto &value : config_hash[config_key].values()) { + if (!value.startsWith("/")) searchTerms.append(value); - } } } searchTerms.append(display_table.values()); @@ -328,7 +327,8 @@ VMManagerSystem::updateTimestamp() } QString -VMManagerSystem::getAll(const QString& category) const { +VMManagerSystem::getAll(const QString &category) const +{ auto value = config_hash[category].keys().join(", "); return value; } @@ -343,11 +343,11 @@ void VMManagerSystem::setDisplayName(const QString &newDisplayName) { // If blank, reset to the default - if (newDisplayName.isEmpty()) { + if (newDisplayName.isEmpty()) displayName = config_name; - } else { + else displayName = newDisplayName; - } + saveSettings(); } void @@ -375,32 +375,36 @@ VMManagerSystem::processId() const } QHash -VMManagerSystem::getCategory(const QString &category) const { +VMManagerSystem::getCategory(const QString &category) const +{ return config_hash[category]; } void -VMManagerSystem::find86BoxBinary() { +VMManagerSystem::find86BoxBinary() +{ // We'll use our own self to launch the VMs main_binary = QFileInfo(QCoreApplication::applicationFilePath()); } bool -VMManagerSystem::has86BoxBinary() { +VMManagerSystem::has86BoxBinary() +{ return main_binary.exists(); } void -VMManagerSystem::launchMainProcess() { +VMManagerSystem::launchMainProcess() +{ - if(!has86BoxBinary()) { + if (!has86BoxBinary()) { qWarning("No binary found! returning"); return; } // start the server first to get the socket name if (!serverIsRunning) { - if(!startServer()) { + if (!startServer()) { // FIXME: Better error handling qInfo("Failed to start VM Manager server"); return; @@ -410,13 +414,13 @@ VMManagerSystem::launchMainProcess() { if (process->processId() != 0) { #ifdef Q_OS_WINDOWS if (this->id) { - SetForegroundWindow((HWND)this->id); + SetForegroundWindow((HWND) this->id); } #endif return; } setProcessEnvVars(); - QString program = main_binary.filePath(); + QString program = main_binary.filePath(); QStringList args; args << "--vmpath" << config_dir; args << "--vmname" << displayName; @@ -437,31 +441,33 @@ VMManagerSystem::launchMainProcess() { updateTimestamp(); connect(process, QOverload::of(&QProcess::finished), - [=](const int exitCode, const QProcess::ExitStatus exitStatus){ - if (exitCode != 0 || exitStatus != QProcess::NormalExit) { - qInfo().nospace().noquote() << "Abnormal program termination while launching main process: exit code " << exitCode << ", exit status " << exitStatus; - QMessageBox::critical(this, tr("Virtual machine crash"), - tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString::number(exitCode))); - return; - } - }); + [=](const int exitCode, const QProcess::ExitStatus exitStatus) { + if (exitCode != 0 || exitStatus != QProcess::NormalExit) { + qInfo().nospace().noquote() << "Abnormal program termination while launching main process: exit code " << exitCode << ", exit status " << exitStatus; + QMessageBox::critical(this, tr("Virtual machine crash"), + tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString::number(exitCode))); + return; + } + }); } void -VMManagerSystem::startButtonPressed() { +VMManagerSystem::startButtonPressed() +{ launchMainProcess(); } void -VMManagerSystem::launchSettings() { - if(!has86BoxBinary()) { +VMManagerSystem::launchSettings() +{ + if (!has86BoxBinary()) { qWarning("No binary found! returning"); return; } // start the server first to get the socket name if (!serverIsRunning) { - if(!startServer()) { + if (!startServer()) { // FIXME: Better error handling qInfo("Failed to start VM Manager server"); return; @@ -472,7 +478,7 @@ VMManagerSystem::launchSettings() { if (process->processId() != 0) { #ifdef Q_OS_WINDOWS if (this->id) { - SetForegroundWindow((HWND)this->id); + SetForegroundWindow((HWND) this->id); } #endif socket_server->serverSendMessage(VMManagerProtocol::ManagerMessage::ShowSettings); @@ -481,8 +487,8 @@ VMManagerSystem::launchSettings() { // Otherwise, launch the system with the settings parameter setProcessEnvVars(); - window_obscured = true; - QString program = main_binary.filePath(); + window_obscured = true; + QString program = main_binary.filePath(); QStringList open_command_args; QStringList args; args << "--vmpath" << config_dir << "--settings"; @@ -496,20 +502,21 @@ VMManagerSystem::launchSettings() { process->start(); connect(process, QOverload::of(&QProcess::finished), - [=](const int exitCode, const QProcess::ExitStatus exitStatus){ - if (exitCode != 0 || exitStatus != QProcess::NormalExit) { - qInfo().nospace().noquote() << "Abnormal program termination while launching settings: exit code " << exitCode << ", exit status " << exitStatus; - QMessageBox::critical(this, tr("Virtual machine crash"), - tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString("%1 (0x%2)").arg(QString::number(exitCode), QString::number(exitCode, 16)))); - return; - } + [=](const int exitCode, const QProcess::ExitStatus exitStatus) { + if (exitCode != 0 || exitStatus != QProcess::NormalExit) { + qInfo().nospace().noquote() << "Abnormal program termination while launching settings: exit code " << exitCode << ", exit status " << exitStatus; + QMessageBox::critical(this, tr("Virtual machine crash"), + tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString("%1 (0x%2)").arg(QString::number(exitCode), QString::number(exitCode, 16)))); + return; + } - configurationChangeReceived(); - }); + configurationChangeReceived(); + }); } void -VMManagerSystem::setupPaths() { +VMManagerSystem::setupPaths() +{ // application_temp_directory.setPath(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); // standard_temp_directory.setPath(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); // QString temp_subdir = QApplication::applicationName(); @@ -529,7 +536,8 @@ VMManagerSystem::setupPaths() { } void -VMManagerSystem::setupVars() { +VMManagerSystem::setupVars() +{ unique_name = QCryptographicHash::hash(config_file.path().toUtf8().constData(), QCryptographicHash::Algorithm::Sha256).toHex().right(9); // unique_name = "aaaaaa"; // Set up the display vars @@ -554,16 +562,16 @@ VMManagerSystem::setupVars() { // } // qDebug() << "Generated UUID:" << uuid; // qDebug() << "Config file UUID:" << config_uuid; - auto machine_name = QString(); - int i = 0; - int ram_granularity = 0; + auto machine_name = QString(); + int i = 0; + int ram_granularity = 0; // Machine for (int ci = 0; ci < machine_count(); ++ci) { if (machine_available(ci)) { - if (machines[ci].internal_name == machine_config["machine"]) { - machine_name = machines[ci].name; - ram_granularity = machines[ci].ram.step; - } + if (machines[ci].internal_name == machine_config["machine"]) { + machine_name = machines[ci].name; + ram_granularity = machines[ci].ram.step; + } } } display_table[VMManager::Display::Name::Machine] = machine_name; @@ -572,7 +580,7 @@ VMManagerSystem::setupVars() { QString cpu_name = "Unknown"; while (cpu_families[i].package != 0) { if (cpu_families[i].internal_name == machine_config["cpu_family"]) { - int j = 0; + int j = 0; cpu_name = QString("%1 %2").arg(cpu_families[i].manufacturer, cpu_families[i].name); while (cpu_families[i].cpus[j].cpu_type != 0) { if (cpu_families[i].cpus[j].rspeed == machine_config["cpu_speed"].toUInt()) { @@ -598,27 +606,27 @@ VMManagerSystem::setupVars() { } i++; } -// int speed_display = machine_config["cpu_speed"].toInt() / 1000000; -// cpu_name.append(QString::number(speed_display).prepend(" / ")); -// cpu_name.append(QCoreApplication::translate("", "MHz").prepend(' ')); + // int speed_display = machine_config["cpu_speed"].toInt() / 1000000; + // cpu_name.append(QString::number(speed_display).prepend(" / ")); + // cpu_name.append(QCoreApplication::translate("", "MHz").prepend(' ')); display_table[VMManager::Display::Name::CPU] = cpu_name; // Memory - int divisor = (ram_granularity < 1024) ? 1 : 1024; + int divisor = (ram_granularity < 1024) ? 1 : 1024; QString display_unit = (divisor == 1) ? "KB" : "MB"; - auto mem_display = QString::number(machine_config["mem_size"].toInt() / divisor); + auto mem_display = QString::number(machine_config["mem_size"].toInt() / divisor); mem_display.append(QCoreApplication::translate("", display_unit.toUtf8().constData()).prepend(' ')); display_table[VMManager::Display::Name::Memory] = mem_display; // Video card - int video_int = video_get_video_from_internal_name(video_config["gfxcard"].toUtf8().data()); - const device_t* video_dev = video_card_getdevice(video_int); + int video_int = video_get_video_from_internal_name(video_config["gfxcard"].toUtf8().data()); + const device_t *video_dev = video_card_getdevice(video_int); display_table[VMManager::Display::Name::Video] = DeviceConfig::DeviceName(video_dev, video_get_internal_name(video_int), 1); // Secondary video if (video_config.contains("gfxcard_2")) { - int video2_int = video_get_video_from_internal_name(video_config["gfxcard_2"].toUtf8().data()); - const device_t* video2_dev = video_card_getdevice(video2_int); + int video2_int = video_get_video_from_internal_name(video_config["gfxcard_2"].toUtf8().data()); + const device_t *video2_dev = video_card_getdevice(video2_int); display_table[VMManager::Display::Name::Video].append(DeviceConfig::DeviceName(video2_dev, video_get_internal_name(video2_int), 1).prepend(VMManagerDetailSection::sectionSeparator)); } @@ -636,7 +644,7 @@ VMManagerSystem::setupVars() { char temp[512]; device_get_name(&voodoo_device, 0, temp); auto voodoo_config = getCategory(QString(temp)); - int voodoo_type = voodoo_config["type"].toInt(); + int voodoo_type = voodoo_config["type"].toInt(); switch (voodoo_type) { case 0: default: @@ -658,48 +666,48 @@ VMManagerSystem::setupVars() { // Drives // First the number of disks QMap disks; - for(const auto& key: disk_config.keys()) { + for (const auto &key : disk_config.keys()) { // Assuming the format hdd_NN_* QStringList pieces = key.split('_'); - QString disk = QString("%1_%2").arg(pieces.at(0), pieces.at(1)); - if(!disk.isEmpty()) { + QString disk = QString("%1_%2").arg(pieces.at(0), pieces.at(1)); + if (!disk.isEmpty()) { disks[disk] = 1; } } // Next, the types QHash bus_types; - for (const auto& key: disks.keys()) { + for (const auto &key : disks.keys()) { auto disk_parameter_key = QString("%1_parameters").arg(key); - QStringList pieces = disk_config[disk_parameter_key].split(","); - QString bus_type = pieces.value(pieces.length() - 1).trimmed(); - bus_types[bus_type] = 1; + QStringList pieces = disk_config[disk_parameter_key].split(","); + QString bus_type = pieces.value(pieces.length() - 1).trimmed(); + bus_types[bus_type] = 1; } QString disks_display = tr("%n disk(s)", "", disks.count()); if (disks.count()) { disks_display.append(" / ").append(bus_types.keys().join(", ").toUpper()); } -// display_table[VMManager::Display::Name::Disks] = disks_display; + // display_table[VMManager::Display::Name::Disks] = disks_display; // Drives QString new_disk_display; - for (const auto& key: disks.keys()) { - auto disk_parameter_key = QString("%1_parameters").arg(key); + for (const auto &key : disks.keys()) { + auto disk_parameter_key = QString("%1_parameters").arg(key); // Converting a string to an int back to a string to remove the zero (e.g. 01 to 1) - auto disk_number = QString::number(key.split("_").last().toInt()); - QStringList pieces = disk_config[disk_parameter_key].split(","); - QString sectors = pieces.value(0).trimmed(); - QString heads = pieces.value(1).trimmed(); - QString cylinders = pieces.value(2).trimmed(); - QString bus_type = pieces.value(pieces.length() - 1).trimmed(); + auto disk_number = QString::number(key.split("_").last().toInt()); + QStringList pieces = disk_config[disk_parameter_key].split(","); + QString sectors = pieces.value(0).trimmed(); + QString heads = pieces.value(1).trimmed(); + QString cylinders = pieces.value(2).trimmed(); + QString bus_type = pieces.value(pieces.length() - 1).trimmed(); // Add separator for each subsequent value, skipping the first - if(!new_disk_display.isEmpty()) { + if (!new_disk_display.isEmpty()) { new_disk_display.append(QString("%1").arg(VMManagerDetailSection::sectionSeparator)); } - int diskSizeRaw = (cylinders.toInt() * heads.toInt() * sectors.toInt()) >> 11; + int diskSizeRaw = (cylinders.toInt() * heads.toInt() * sectors.toInt()) >> 11; QString diskSizeFinal; QString unit = tr("MiB"); - if(diskSizeRaw > 1000) { - unit = tr("GiB"); + if (diskSizeRaw > 1000) { + unit = tr("GiB"); diskSizeFinal = QString::number(diskSizeRaw * 1.0 / 1000, 'f', 1); } else { diskSizeFinal = QString::number(diskSizeRaw); @@ -708,7 +716,7 @@ VMManagerSystem::setupVars() { QString diskNumberDisplay = disks.count() > 1 ? tr("Disk %1: ").arg(disk_number) : ""; new_disk_display.append(QString("%1%2 %3 (%4)").arg(diskNumberDisplay, diskSizeFinal, unit, bus_type.toUpper())); } - if(new_disk_display.isEmpty()) { + if (new_disk_display.isEmpty()) { new_disk_display = tr("No disks"); } display_table[VMManager::Display::Name::Disks] = new_disk_display; @@ -724,38 +732,37 @@ VMManagerSystem::setupVars() { static auto floppy_match = QRegularExpression("fdd_\\d\\d_type", QRegularExpression::CaseInsensitiveOption); static auto cdrom_match = QRegularExpression("cdrom_\\d\\d_parameters", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: floppy_cdrom_config.keys()) { - if(key.contains(floppy_match)) { + for (const auto &key : floppy_cdrom_config.keys()) { + if (key.contains(floppy_match)) { // auto device_number = key.split("_").at(1); auto floppy_internal_name = QString(floppy_cdrom_config[key]); // Not interested in the nones - if(floppy_internal_name == "none") { + if (floppy_internal_name == "none") continue; - } - auto floppy_type = fdd_get_from_internal_name(floppy_internal_name.toUtf8().data()); - if(auto fddName = QString(fdd_getname(floppy_type)); !fddName.isEmpty()) { - floppyDevices.append(fddName); - } - } - if(key.contains(cdrom_match)) { - auto device_number = key.split("_").at(1); - auto cdrom_parameters = QString(floppy_cdrom_config[key]); - auto cdrom_bus = cdrom_parameters.split(",").at(1).trimmed().toUpper(); - auto cdrom_type_key = QString("cdrom_%1_type").arg(device_number); + auto floppy_type = fdd_get_from_internal_name(floppy_internal_name.toUtf8().data()); + if (auto fddName = QString(fdd_getname(floppy_type)); !fddName.isEmpty()) + floppyDevices.append(fddName); + } + if (key.contains(cdrom_match)) { + auto device_number = key.split("_").at(1); + auto cdrom_parameters = QString(floppy_cdrom_config[key]); + auto cdrom_bus = cdrom_parameters.split(",").at(1).trimmed().toUpper(); + + auto cdrom_type_key = QString("cdrom_%1_type").arg(device_number); auto cdrom_internal_name = QString(floppy_cdrom_config[cdrom_type_key]); if (cdrom_internal_name.isEmpty()) cdrom_internal_name = "86cd"; auto cdrom_type = cdrom_get_from_internal_name(cdrom_internal_name.toUtf8().data()); auto cdrom_speed_key = QString("cdrom_%1_speed").arg(device_number); - auto cdrom_speed = QString(floppy_cdrom_config[cdrom_speed_key]); + auto cdrom_speed = QString(floppy_cdrom_config[cdrom_speed_key]); if (cdrom_speed.isEmpty()) cdrom_speed = "8"; if ((cdrom_bus != "NONE") && (cdrom_type != -1)) { cdrom_speed = QString("%1x ").arg(cdrom_speed); - cdrom_bus = QString(" (%1)").arg(cdrom_bus); + cdrom_bus = QString(" (%1)").arg(cdrom_bus); cdromDevices.append(QString("%1%2 %3 %4%5").arg(cdrom_speed, cdrom_drive_types[cdrom_type].vendor, cdrom_drive_types[cdrom_type].model, cdrom_drive_types[cdrom_type].revision, cdrom_bus)); } } @@ -770,29 +777,29 @@ VMManagerSystem::setupVars() { static auto rdisk_match = QRegularExpression("rdisk_\\d\\d_parameters", QRegularExpression::CaseInsensitiveOption); static auto zip_match = QRegularExpression("zip_\\d\\d_parameters", QRegularExpression::CaseInsensitiveOption); // Legacy ZIP drive entries static auto mo_match = QRegularExpression("mo_\\d\\d_parameters", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: rdisk_mo_config.keys()) { - if(key.contains(rdisk_match) || key.contains(zip_match)) { - auto device_number = key.split("_").at(1); + for (const auto &key : rdisk_mo_config.keys()) { + if (key.contains(rdisk_match) || key.contains(zip_match)) { + auto device_number = key.split("_").at(1); auto rdisk_parameters = QString(rdisk_mo_config[key]); - auto rdisk_type = rdisk_parameters.split(",").at(0).toInt(); + auto rdisk_type = rdisk_parameters.split(",").at(0).toInt(); if (key.contains(zip_match)) rdisk_type++; - auto rdisk_bus = rdisk_parameters.split(",").at(1).trimmed().toUpper(); + auto rdisk_bus = rdisk_parameters.split(",").at(1).trimmed().toUpper(); - if((rdisk_type >= 0) && (rdisk_type < KNOWN_RDISK_DRIVE_TYPES)) { - if(!rdisk_bus.isEmpty()) + if ((rdisk_type >= 0) && (rdisk_type < KNOWN_RDISK_DRIVE_TYPES)) { + if (!rdisk_bus.isEmpty()) rdisk_bus = QString(" (%1)").arg(rdisk_bus); rdiskDevices.append(QString("%1 %2%3").arg(rdisk_drive_types[rdisk_type].vendor, rdisk_drive_types[rdisk_type].model, rdisk_bus)); } } - if(key.contains(mo_match)) { + if (key.contains(mo_match)) { auto device_number = key.split("_").at(1); auto mo_parameters = QString(rdisk_mo_config[key]); - auto mo_type = mo_parameters.split(",").at(0).toInt(); - auto mo_bus = mo_parameters.split(",").at(1).trimmed().toUpper(); + auto mo_type = mo_parameters.split(",").at(0).toInt(); + auto mo_bus = mo_parameters.split(",").at(1).trimmed().toUpper(); - if((mo_type >= 0) && (mo_type < KNOWN_MO_DRIVE_TYPES)) { - if(!mo_bus.isEmpty()) + if ((mo_type >= 0) && (mo_type < KNOWN_MO_DRIVE_TYPES)) { + if (!mo_bus.isEmpty()) mo_bus = QString(" (%1)").arg(mo_bus); moDevices.append(QString("%1 %2%3").arg(mo_drive_types[mo_type].vendor, mo_drive_types[mo_type].model, mo_bus)); } @@ -802,18 +809,17 @@ VMManagerSystem::setupVars() { display_table[VMManager::Display::Name::RDisk] = rdiskDevices.join(VMManagerDetailSection::sectionSeparator); display_table[VMManager::Display::Name::MO] = moDevices.join(VMManagerDetailSection::sectionSeparator); - // SCSI controllers QStringList scsiControllers; static auto scsi_match = QRegularExpression("scsicard_\\d", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: storage_config.keys()) { - if(key.contains(scsi_match)) { - auto device_number = key.split("_").at(1); + for (const auto &key : storage_config.keys()) { + if (key.contains(scsi_match)) { + auto device_number = key.split("_").at(1); auto scsi_internal_name = QString(storage_config[key]); - auto scsi_id = scsi_card_get_from_internal_name(scsi_internal_name.toUtf8().data()); - auto scsi_device = scsi_card_getdevice(scsi_id); - auto scsi_name = DeviceConfig::DeviceName(scsi_device, scsi_card_get_internal_name(scsi_id), 1); - if(!scsi_name.isEmpty()) { + auto scsi_id = scsi_card_get_from_internal_name(scsi_internal_name.toUtf8().data()); + auto scsi_device = scsi_card_getdevice(scsi_id); + auto scsi_name = DeviceConfig::DeviceName(scsi_device, scsi_card_get_internal_name(scsi_id), 1); + if (!scsi_name.isEmpty()) { scsiControllers.append(scsi_name); } } @@ -824,37 +830,35 @@ VMManagerSystem::setupVars() { QStringList storageControllers; static auto fdc_match = QRegularExpression("fdc(_\\d)?", QRegularExpression::CaseInsensitiveOption); // futureproofing static auto hdc_match = QRegularExpression("hdc(_\\d)?", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: storage_config.keys()) { - if(key.contains(fdc_match)) { + for (const auto &key : storage_config.keys()) { + if (key.contains(fdc_match)) { QString device_number; if (!key.contains('_')) device_number = "1"; else // futureproofing - device_number = key.split("_").at(1); + device_number = key.split("_").at(1); auto fdc_internal_name = QString(storage_config[key]); if (!fdc_internal_name.isEmpty() && (fdc_internal_name != "none") && (fdc_internal_name != "internal")) { - auto fdc_id = fdc_card_get_from_internal_name(fdc_internal_name.toUtf8().data()); + auto fdc_id = fdc_card_get_from_internal_name(fdc_internal_name.toUtf8().data()); auto fdc_device = fdc_card_getdevice(fdc_id); - auto fdc_name = DeviceConfig::DeviceName(fdc_device, fdc_card_get_internal_name(fdc_id), 1); - if(!fdc_name.isEmpty()) { + auto fdc_name = DeviceConfig::DeviceName(fdc_device, fdc_card_get_internal_name(fdc_id), 1); + if (!fdc_name.isEmpty()) storageControllers.append(fdc_name); - } } } - if(key.contains(hdc_match)) { + if (key.contains(hdc_match)) { QString device_number; if (!key.contains('_')) // legacy hdc entry device_number = "1"; else - device_number = key.split("_").at(1); + device_number = key.split("_").at(1); auto hdc_internal_name = QString(storage_config[key]); if (!hdc_internal_name.isEmpty() && (hdc_internal_name != "none") && (hdc_internal_name != "internal")) { - auto hdc_id = hdc_get_from_internal_name(hdc_internal_name.toUtf8().data()); + auto hdc_id = hdc_get_from_internal_name(hdc_internal_name.toUtf8().data()); auto hdc_device = hdc_get_device(hdc_id); - auto hdc_name = DeviceConfig::DeviceName(hdc_device, hdc_get_internal_name(hdc_id), 1); - if(!hdc_name.isEmpty()) { + auto hdc_name = DeviceConfig::DeviceName(hdc_device, hdc_get_internal_name(hdc_id), 1); + if (!hdc_name.isEmpty()) storageControllers.append(hdc_name); - } } } } @@ -863,7 +867,7 @@ VMManagerSystem::setupVars() { if (storage_config.contains("cdrom_interface")) { auto cdrom_intf_internal_name = storage_config["cdrom_interface"]; if (!cdrom_intf_internal_name.isEmpty() && (cdrom_intf_internal_name != "none") && (cdrom_intf_internal_name != "internal")) { - auto cdrom_intf_dev = cdrom_interface_get_from_internal_name(cdrom_intf_internal_name.toUtf8().data()); + auto cdrom_intf_dev = cdrom_interface_get_from_internal_name(cdrom_intf_internal_name.toUtf8().data()); auto cdrom_intf_dev_name = DeviceConfig::DeviceName(cdrom_interface_get_device(cdrom_intf_dev), cdrom_interface_get_internal_name(cdrom_intf_dev), 1); storageControllers.append(cdrom_intf_dev_name); } @@ -882,26 +886,25 @@ VMManagerSystem::setupVars() { // Audio QStringList sndCards; static auto sndcard_match = QRegularExpression("sndcard\\d?", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: audio_config.keys()) { - if(key.contains(sndcard_match)) { + for (const auto &key : audio_config.keys()) { + if (key.contains(sndcard_match)) { auto device_number = key.right(1); - if(device_number == "d") // card #1 has no number + if (device_number == "d") // card #1 has no number device_number = "1"; auto audio_internal_name = QString(audio_config[key]); - auto audio_id = sound_card_get_from_internal_name(audio_internal_name.toUtf8().data()); - auto audio_device = sound_card_getdevice(audio_id); - auto audio_name = DeviceConfig::DeviceName(audio_device, sound_card_get_internal_name(audio_id), 1); - if(!audio_name.isEmpty()) { + auto audio_id = sound_card_get_from_internal_name(audio_internal_name.toUtf8().data()); + auto audio_device = sound_card_getdevice(audio_id); + auto audio_name = DeviceConfig::DeviceName(audio_device, sound_card_get_internal_name(audio_id), 1); + if (!audio_name.isEmpty()) sndCards.append(audio_name); - } } } - if(audio_config.contains("mpu401_standalone")) { + if (audio_config.contains("mpu401_standalone")) { sndCards.append(tr("Standalone MPU-401")); } - if(sndCards.isEmpty()) { + if (sndCards.isEmpty()) sndCards.append(tr("None")); - } + display_table[VMManager::Display::Name::Audio] = sndCards.join(VMManagerDetailSection::sectionSeparator); // MIDI @@ -909,10 +912,9 @@ VMManagerSystem::setupVars() { if (audio_config.contains("midi_device")) { auto midi_out_device = QString(audio_config["midi_device"]); auto midi_device_int = midi_out_device_get_from_internal_name(midi_out_device.toUtf8().data()); - auto midi_out = midi_out_device_getdevice(midi_device_int); - if(auto midiDevName = QString(midi_out->name); !midiDevName.isEmpty()) { + auto midi_out = midi_out_device_getdevice(midi_device_int); + if (auto midiDevName = QString(midi_out->name); !midiDevName.isEmpty()) midiOutDev = midiDevName; - } } display_table[VMManager::Display::Name::MidiOut] = midiOutDev; @@ -923,15 +925,15 @@ VMManagerSystem::setupVars() { // Network QStringList nicList; static auto nic_match = QRegularExpression("net_\\d\\d_card", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: network_config.keys()) { - if(key.contains(nic_match)) { - auto device_number = key.split("_").at(1); + for (const auto &key : network_config.keys()) { + if (key.contains(nic_match)) { + auto device_number = key.split("_").at(1); auto nic_internal_name = QString(network_config[key]); - auto nic_id = network_card_get_from_internal_name(nic_internal_name.toUtf8().data()); - auto nic = network_card_getdevice(nic_id); - auto nic_name = DeviceConfig::DeviceName(nic, network_card_get_internal_name(nic_id), 1); - auto net_type_key = QString("net_%1_net_type").arg(device_number); - auto net_type = network_config[net_type_key]; + auto nic_id = network_card_get_from_internal_name(nic_internal_name.toUtf8().data()); + auto nic = network_card_getdevice(nic_id); + auto nic_name = DeviceConfig::DeviceName(nic, network_card_get_internal_name(nic_id), 1); + auto net_type_key = QString("net_%1_net_type").arg(device_number); + auto net_type = network_config[net_type_key]; if (!net_type.isEmpty()) { if (net_type == "slirp") net_type = "SLiRP"; @@ -944,57 +946,54 @@ VMManagerSystem::setupVars() { else net_type = net_type.toUpper(); nicList.append(nic_name + " (" + net_type + ")"); - } else { + } else nicList.append(nic_name); - } - } } - if(nicList.isEmpty()) { + if (nicList.isEmpty()) nicList.append(tr("None")); - } + display_table[VMManager::Display::Name::NIC] = nicList.join(VMManagerDetailSection::sectionSeparator); // Input (Keyboard) if (input_config.contains("keyboard_type")) { - auto keyboard_internal_name = input_config["keyboard_type"]; - auto keyboard_dev = keyboard_get_from_internal_name(keyboard_internal_name.toUtf8().data()); - auto keyboard_dev_name = DeviceConfig::DeviceName(keyboard_get_device(keyboard_dev), keyboard_get_internal_name(keyboard_dev), 0); + auto keyboard_internal_name = input_config["keyboard_type"]; + auto keyboard_dev = keyboard_get_from_internal_name(keyboard_internal_name.toUtf8().data()); + auto keyboard_dev_name = DeviceConfig::DeviceName(keyboard_get_device(keyboard_dev), keyboard_get_internal_name(keyboard_dev), 0); display_table[VMManager::Display::Name::Keyboard] = keyboard_dev_name; } // Input (Mouse) - auto mouse_internal_name = input_config["mouse_type"]; - auto mouse_dev = mouse_get_from_internal_name(mouse_internal_name.toUtf8().data()); - auto mouse_dev_name = DeviceConfig::DeviceName(mouse_get_device(mouse_dev), mouse_get_internal_name(mouse_dev), 0); + auto mouse_internal_name = input_config["mouse_type"]; + auto mouse_dev = mouse_get_from_internal_name(mouse_internal_name.toUtf8().data()); + auto mouse_dev_name = DeviceConfig::DeviceName(mouse_get_device(mouse_dev), mouse_get_internal_name(mouse_dev), 0); display_table[VMManager::Display::Name::Mouse] = mouse_dev_name; // Input (joystick) QString joystickDevice; - if(input_config.contains("joystick_type")) { + if (input_config.contains("joystick_type")) { auto joystick_internal = QString(input_config["joystick_type"]); - auto joystick_dev = joystick_get_from_internal_name(joystick_internal.toUtf8().data()); - if (auto joystickName = tr(joystick_get_name(joystick_dev)); !joystickName.isEmpty()) { + auto joystick_dev = joystick_get_from_internal_name(joystick_internal.toUtf8().data()); + if (auto joystickName = tr(joystick_get_name(joystick_dev)); !joystickName.isEmpty()) joystickDevice = joystickName; - } } display_table[VMManager::Display::Name::Joystick] = joystickDevice; // # Ports // Serial // By default serial 1 and 2 are enabled unless otherwise specified - static auto serial_match = QRegularExpression("serial\\d_enabled", QRegularExpression::CaseInsensitiveOption); - QList serial_enabled = {true, true, false, false, false, false, false, false}; + static auto serial_match = QRegularExpression("serial\\d_enabled", QRegularExpression::CaseInsensitiveOption); + QList serial_enabled = { true, true, false, false, false, false, false, false }; // Parallel // By default lpt 1 is enabled unless otherwise specified - static auto lpt_match = QRegularExpression("lpt\\d_enabled", QRegularExpression::CaseInsensitiveOption); - QList lpt_enabled = {true, false, false, false}; - for (const auto &key: ports_config.keys()) { + static auto lpt_match = QRegularExpression("lpt\\d_enabled", QRegularExpression::CaseInsensitiveOption); + QList lpt_enabled = { true, false, false, false }; + for (const auto &key : ports_config.keys()) { if (key.contains(serial_match)) { if (auto serial_dev = key.split("_").at(0); !serial_dev.isEmpty()) { auto serial_num = serial_dev.at(serial_dev.size() - 1); // qDebug() << "serial is set" << key << ":" << ports_config[key]; - if(serial_num.isDigit() && serial_num.digitValue() >= 1 && serial_num.digitValue() <= 4) { + if (serial_num.isDigit() && serial_num.digitValue() >= 1 && serial_num.digitValue() <= 4) { // Already verified that it is a digit with isDigit() serial_enabled[serial_num.digitValue() - 1] = ports_config[key].toInt() == 1; } @@ -1004,16 +1003,15 @@ VMManagerSystem::setupVars() { if (auto lpt_dev = key.split("_").at(0); !lpt_dev.isEmpty()) { auto lpt_num = lpt_dev.at(lpt_dev.size() - 1); // qDebug() << "lpt is set" << key << ":" << ports_config[key]; - if (lpt_num.isDigit() && lpt_num.digitValue() >= 1 && lpt_num.digitValue() <= 4) { + if (lpt_num.isDigit() && lpt_num.digitValue() >= 1 && lpt_num.digitValue() <= 4) lpt_enabled[lpt_num.digitValue() - 1] = ports_config[key].toInt() == 1; - } } } } // qDebug() << "ports final" << serial_enabled << lpt_enabled; QStringList serialFinal; QStringList lptFinal; - int portIndex = 0; + int portIndex = 0; while (true) { if (serial_enabled[portIndex]) serialFinal.append(QString("COM%1").arg(portIndex + 1)); @@ -1021,17 +1019,17 @@ VMManagerSystem::setupVars() { if (portIndex == SERIAL_MAX) break; } - portIndex = 0; + portIndex = 0; bool hasLptDevices = false; while (true) { if (lpt_enabled[portIndex]) { - auto lpt_device_key = QString("lpt%1_device").arg(portIndex + 1); + auto lpt_device_key = QString("lpt%1_device").arg(portIndex + 1); QString lpt_device_name = ""; if (ports_config.contains(lpt_device_key)) { auto lpt_internal_name = QString(ports_config[lpt_device_key]); - auto lpt_id = lpt_device_get_from_internal_name(lpt_internal_name.toUtf8().data()); - lpt_device_name = " (" + tr(lpt_device_get_name(lpt_id)) + ")"; - hasLptDevices = true; + auto lpt_id = lpt_device_get_from_internal_name(lpt_internal_name.toUtf8().data()); + lpt_device_name = " (" + tr(lpt_device_get_name(lpt_id)) + ")"; + hasLptDevices = true; } lptFinal.append(QString("LPT%1%2").arg(portIndex + 1).arg(lpt_device_name)); } @@ -1039,31 +1037,30 @@ VMManagerSystem::setupVars() { if (portIndex == PARALLEL_MAX) break; } - display_table[VMManager::Display::Name::Serial] = (serialFinal.empty() ? tr("None") : serialFinal.join(", ")); - display_table[VMManager::Display::Name::Parallel] = (lptFinal.empty() ? tr("None") : lptFinal.join((hasLptDevices ? VMManagerDetailSection::sectionSeparator : ", "))); + display_table[VMManager::Display::Name::Serial] = (serialFinal.empty() ? tr("None") : serialFinal.join(", ")); + display_table[VMManager::Display::Name::Parallel] = (lptFinal.empty() ? tr("None") : lptFinal.join((hasLptDevices ? VMManagerDetailSection::sectionSeparator : ", "))); // ISA RTC QString isartc_dev_name = ""; if (other_config.contains("isartc_type")) { auto isartc_internal_name = other_config["isartc_type"]; - auto isartc_dev = isartc_get_from_internal_name(isartc_internal_name.toUtf8().data()); - isartc_dev_name = DeviceConfig::DeviceName(isartc_get_device(isartc_dev), isartc_get_internal_name(isartc_dev), 0); + auto isartc_dev = isartc_get_from_internal_name(isartc_internal_name.toUtf8().data()); + isartc_dev_name = DeviceConfig::DeviceName(isartc_get_device(isartc_dev), isartc_get_internal_name(isartc_dev), 0); } display_table[VMManager::Display::Name::IsaRtc] = isartc_dev_name; // ISA RAM QStringList IsaMemCards; static auto isamem_match = QRegularExpression("isamem\\d_type", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: other_config.keys()) { - if(key.contains(isamem_match)) { - auto device_number = QString("%1").arg(key.split("_").at(0).right(1).toInt() + 1); + for (const auto &key : other_config.keys()) { + if (key.contains(isamem_match)) { + auto device_number = QString("%1").arg(key.split("_").at(0).right(1).toInt() + 1); auto isamem_internal_name = QString(other_config[key]); - auto isamem_id = isamem_get_from_internal_name(isamem_internal_name.toUtf8().data()); - auto isamem_device = isamem_get_device(isamem_id); - auto isamem_name = DeviceConfig::DeviceName(isamem_device, isamem_get_internal_name(isamem_id), 0); - if(!isamem_name.isEmpty()) { + auto isamem_id = isamem_get_from_internal_name(isamem_internal_name.toUtf8().data()); + auto isamem_device = isamem_get_device(isamem_id); + auto isamem_name = DeviceConfig::DeviceName(isamem_device, isamem_get_internal_name(isamem_id), 0); + if (!isamem_name.isEmpty()) IsaMemCards.append(isamem_name); - } } } display_table[VMManager::Display::Name::IsaMem] = IsaMemCards.join(VMManagerDetailSection::sectionSeparator); @@ -1071,23 +1068,23 @@ VMManagerSystem::setupVars() { // ISA ROM QStringList IsaRomCards; static auto isarom_match = QRegularExpression("isarom\\d_type", QRegularExpression::CaseInsensitiveOption); - for(const auto& key: other_config.keys()) { - if(key.contains(isarom_match)) { - auto device_number = QString("%1").arg(key.split("_").at(0).right(1).toInt() + 1); + for (const auto &key : other_config.keys()) { + if (key.contains(isarom_match)) { + auto device_number = QString("%1").arg(key.split("_").at(0).right(1).toInt() + 1); auto isarom_internal_name = QString(other_config[key]); - auto isarom_id = isarom_get_from_internal_name(isarom_internal_name.toUtf8().data()); - auto isarom_device = isarom_get_device(isarom_id); - auto isarom_name = DeviceConfig::DeviceName(isarom_device, isarom_get_internal_name(isarom_id), 0); - if(!isarom_name.isEmpty()) { + auto isarom_id = isarom_get_from_internal_name(isarom_internal_name.toUtf8().data()); + auto isarom_device = isarom_get_device(isarom_id); + auto isarom_name = DeviceConfig::DeviceName(isarom_device, isarom_get_internal_name(isarom_id), 0); + if (!isarom_name.isEmpty()) IsaRomCards.append(isarom_name); - } } } display_table[VMManager::Display::Name::IsaRom] = IsaRomCards.join(VMManagerDetailSection::sectionSeparator); } bool -VMManagerSystem::startServer() { +VMManagerSystem::startServer() +{ if (socket_server->startServer()) { serverIsRunning = true; connect(socket_server, &VMManagerServerSocket::dataReceived, this, &VMManagerSystem::dataReceived); @@ -1095,29 +1092,30 @@ VMManagerSystem::startServer() { connect(socket_server, &VMManagerServerSocket::runningStatusChanged, this, &VMManagerSystem::runningStatusChangeReceived); connect(socket_server, &VMManagerServerSocket::configurationChanged, this, &VMManagerSystem::configurationChangeReceived); connect(socket_server, &VMManagerServerSocket::globalConfigurationChanged, this, &VMManagerSystem::globalConfigurationChanged); - connect(socket_server, &VMManagerServerSocket::winIdReceived, this, [this] (WId id) { this->id = id; }); + connect(socket_server, &VMManagerServerSocket::winIdReceived, this, [this](WId id) { this->id = id; }); return true; - } else { + } else return false; - } } void -VMManagerSystem::setProcessEnvVars() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - QString env_var_name = (socket_server_type == VMManagerServerSocket::ServerType::Standard) ? "VMM_86BOX_SOCKET" : "86BOX_MANAGER_SOCKET"; +VMManagerSystem::setProcessEnvVars() +{ + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + QString env_var_name = (socket_server_type == VMManagerServerSocket::ServerType::Standard) ? "VMM_86BOX_SOCKET" : "86BOX_MANAGER_SOCKET"; env.insert(env_var_name, socket_server->getSocketPath()); process->setProcessEnvironment(env); } void -VMManagerSystem::restartButtonPressed() { +VMManagerSystem::restartButtonPressed() +{ socket_server->serverSendMessage(VMManagerProtocol::ManagerMessage::ResetVM); - } void -VMManagerSystem::pauseButtonPressed() { +VMManagerSystem::pauseButtonPressed() +{ socket_server->serverSendMessage(VMManagerProtocol::ManagerMessage::Pause); } void @@ -1167,11 +1165,10 @@ VMManagerSystem::processStatusChanged() { // set to running if the process is running and the state is stopped if (process->state() == QProcess::ProcessState::Running) { - if (process_status == VMManagerSystem::ProcessStatus::Stopped) { + if (process_status == VMManagerSystem::ProcessStatus::Stopped) process_status = VMManagerSystem::ProcessStatus::Running; - } } else if (process->state() == QProcess::ProcessState::NotRunning) { - process_status = VMManagerSystem::ProcessStatus::Stopped; + process_status = VMManagerSystem::ProcessStatus::Stopped; window_obscured = false; } emit itemDataChanged(); @@ -1185,21 +1182,21 @@ VMManagerSystem::statusRefresh() QString VMManagerSystem::processStatusToString(VMManagerSystem::ProcessStatus status) { -// QMetaEnum qme = QMetaEnum::fromType(); -// return qme.valueToKey(static_cast(status)); - switch (status) { - case VMManagerSystem::ProcessStatus::Stopped: - return tr("Powered Off"); - case VMManagerSystem::ProcessStatus::Running: - return tr("Running"); - case VMManagerSystem::ProcessStatus::Paused: - return tr("Paused"); - case VMManagerSystem::ProcessStatus::PausedWaiting: - case VMManagerSystem::ProcessStatus::RunningWaiting: - return QString("%1 (%2)").arg(tr("Paused"), tr("Waiting")); - default: - return tr("Unknown Status"); - } + // QMetaEnum qme = QMetaEnum::fromType(); + // return qme.valueToKey(static_cast(status)); + switch (status) { + case VMManagerSystem::ProcessStatus::Stopped: + return tr("Powered Off"); + case VMManagerSystem::ProcessStatus::Running: + return tr("Running"); + case VMManagerSystem::ProcessStatus::Paused: + return tr("Paused"); + case VMManagerSystem::ProcessStatus::PausedWaiting: + case VMManagerSystem::ProcessStatus::RunningWaiting: + return QString("%1 (%2)").arg(tr("Paused"), tr("Waiting")); + default: + return tr("Unknown Status"); + } } QString @@ -1217,20 +1214,20 @@ VMManagerSystem::getProcessStatus() const void VMManagerSystem::runningStatusChangeReceived(VMManagerProtocol::RunningState state) { - if(state == VMManagerProtocol::RunningState::Running) { - process_status = VMManagerSystem::ProcessStatus::Running; + if (state == VMManagerProtocol::RunningState::Running) { + process_status = VMManagerSystem::ProcessStatus::Running; window_obscured = false; windowStatusChanged(); - } else if(state == VMManagerProtocol::RunningState::Paused) { - process_status = VMManagerSystem::ProcessStatus::Paused; + } else if (state == VMManagerProtocol::RunningState::Paused) { + process_status = VMManagerSystem::ProcessStatus::Paused; window_obscured = false; windowStatusChanged(); - } else if(state == VMManagerProtocol::RunningState::RunningWaiting) { - process_status = VMManagerSystem::ProcessStatus::RunningWaiting; + } else if (state == VMManagerProtocol::RunningState::RunningWaiting) { + process_status = VMManagerSystem::ProcessStatus::RunningWaiting; window_obscured = true; windowStatusChanged(); - } else if(state == VMManagerProtocol::RunningState::PausedWaiting) { - process_status = VMManagerSystem::ProcessStatus::PausedWaiting; + } else if (state == VMManagerProtocol::RunningState::PausedWaiting) { + process_status = VMManagerSystem::ProcessStatus::PausedWaiting; window_obscured = true; windowStatusChanged(); } else { diff --git a/src/qt/qt_vmmanager_system.hpp b/src/qt/qt_vmmanager_system.hpp index af6b30016..96c794df3 100644 --- a/src/qt/qt_vmmanager_system.hpp +++ b/src/qt/qt_vmmanager_system.hpp @@ -26,43 +26,44 @@ // This macro helps give us the required `qHash()` function in order to use the // enum as a hash key -#define QHASH_FOR_CLASS_ENUM(T) \ -inline uint qHash(const T &t, uint seed) { \ - return ::qHash(static_cast::type>(t), seed); \ -} +#define QHASH_FOR_CLASS_ENUM(T) \ + inline uint qHash(const T &t, uint seed) \ + { \ + return ::qHash(static_cast::type>(t), seed); \ + } namespace VMManager { Q_NAMESPACE namespace Display { -Q_NAMESPACE -enum class Name { - Machine, - CPU, - Memory, - Video, - Disks, - Floppy, - CD, - RDisk, - MO, - SCSIController, - StorageController, - MidiOut, - Joystick, - Serial, - Parallel, - Audio, - Voodoo, - NIC, - Keyboard, - Mouse, - IsaRtc, - IsaMem, - IsaRom, - Unknown -}; -Q_ENUM_NS(Name) -QHASH_FOR_CLASS_ENUM(Name) + Q_NAMESPACE + enum class Name { + Machine, + CPU, + Memory, + Video, + Disks, + Floppy, + CD, + RDisk, + MO, + SCSIController, + StorageController, + MidiOut, + Joystick, + Serial, + Parallel, + Audio, + Voodoo, + NIC, + Keyboard, + Mouse, + IsaRtc, + IsaMem, + IsaRom, + Unknown + }; + Q_ENUM_NS(Name) + QHASH_FOR_CLASS_ENUM(Name) } } @@ -70,10 +71,9 @@ class VMManagerSystem : public QWidget { Q_OBJECT typedef QHash display_table_t; - typedef QHash > config_hash_t; + typedef QHash> config_hash_t; public: - enum class ProcessStatus { Stopped, Running, @@ -87,12 +87,15 @@ public: explicit VMManagerSystem(const QString &sysconfig_file); // Default constructor will generate a temporary filename as the config file // but it will not be valid (isValid() will return false) - VMManagerSystem() : VMManagerSystem(generateTemporaryFilename()) {} + VMManagerSystem() + : VMManagerSystem(generateTemporaryFilename()) + { + } ~VMManagerSystem() override; - static QVector scanForConfigs(QWidget* parent = nullptr, const QString &searchPath = {}); - static QString generateTemporaryFilename(); + static QVector scanForConfigs(QWidget *parent = nullptr, const QString &searchPath = {}); + static QString generateTemporaryFilename(); QFileInfo config_file; QString config_name; @@ -106,15 +109,15 @@ public: config_hash_t config_hash; - [[nodiscard]] QString getAll(const QString& category) const; - [[nodiscard]] QHash getCategory(const QString& category) const; - [[nodiscard]] QHash > getConfigHash() const; + [[nodiscard]] QString getAll(const QString &category) const; + [[nodiscard]] QHash getCategory(const QString &category) const; + [[nodiscard]] QHash> getConfigHash() const; - void setDisplayName(const QString& newDisplayName); - void setNotes(const QString& newNotes); + void setDisplayName(const QString &newDisplayName); + void setNotes(const QString &newNotes); - [[nodiscard]] bool isValid() const; - [[nodiscard]] bool isProcessRunning() const; + [[nodiscard]] bool isValid() const; + [[nodiscard]] bool isProcessRunning() const; [[nodiscard]] qint64 processId() const; public slots: void launchMainProcess(); @@ -127,16 +130,17 @@ public slots: void cadButtonPressed(); void reloadConfig(); void sendGlobalConfigurationChanged(); + public: QDateTime timestamp(); - void setIcon(const QString &newIcon); + void setIcon(const QString &newIcon); QProcess *process = new QProcess(); bool window_obscured; bool config_signal_connected = false; - QString getDisplayValue(VMManager::Display::Name key); + QString getDisplayValue(VMManager::Display::Name key); QFileInfoList getScreenshots(); inline bool operator==(const VMManagerSystem &rhs) const @@ -145,9 +149,9 @@ public: } static QString - processStatusToString(VMManagerSystem::ProcessStatus status) ; - ProcessStatus process_status; - [[nodiscard]] QString getProcessStatusString() const; + processStatusToString(VMManagerSystem::ProcessStatus status); + ProcessStatus process_status; + [[nodiscard]] QString getProcessStatusString() const; [[nodiscard]] ProcessStatus getProcessStatus() const; signals: @@ -166,15 +170,15 @@ private: display_table_t display_table; QFileInfo main_binary; - QString platform; + QString platform; // QDir application_temp_directory; // QDir standard_temp_directory; // QDir app_data_directory; QDir screenshot_directory; - QString unique_name; - QDateTime lastUsedTimestamp; + QString unique_name; + QDateTime lastUsedTimestamp; VMManagerServerSocket *socket_server; VMManagerServerSocket::ServerType socket_server_type; @@ -201,4 +205,4 @@ private: void statusRefresh(); }; -#endif //QT_VMMANAGER_SYSTEM_H +#endif // QT_VMMANAGER_SYSTEM_H diff --git a/src/qt/qt_vmmanager_windarkmodefilter.cpp b/src/qt/qt_vmmanager_windarkmodefilter.cpp index 4cba78b50..ac1fb4fae 100644 --- a/src/qt/qt_vmmanager_windarkmodefilter.cpp +++ b/src/qt/qt_vmmanager_windarkmodefilter.cpp @@ -25,7 +25,7 @@ #include #include #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +# define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif #include <86box/86box.h> @@ -68,7 +68,8 @@ WindowsDarkModeFilter::reselectDarkMode() } window->updateDarkMode(); - if (NewDarkMode != OldDarkMode) QTimer::singleShot(1000, [this] () { + if (NewDarkMode != OldDarkMode) + QTimer::singleShot(1000, [this]() { BOOL DarkMode = NewDarkMode; DwmSetWindowAttribute((HWND) window->winId(), DWMWA_USE_IMMERSIVE_DARK_MODE, @@ -90,11 +91,8 @@ WindowsDarkModeFilter::nativeEventFilter(const QByteArray &eventType, void *mess MSG *msg = static_cast(message); if ((msg != nullptr) && (msg->message == WM_SETTINGCHANGE)) { - if ((((void *) msg->lParam) != nullptr) && - (wcscmp(L"ImmersiveColorSet", (wchar_t*)msg->lParam) == 0) && - color_scheme == 0) { + if ((((void *) msg->lParam) != nullptr) && (wcscmp(L"ImmersiveColorSet", (wchar_t *) msg->lParam) == 0) && color_scheme == 0) reselectDarkMode(); - } } } diff --git a/src/qt/qt_vulkanrenderer.cpp b/src/qt/qt_vulkanrenderer.cpp index 2306661ec..be588a8d2 100644 --- a/src/qt/qt_vulkanrenderer.cpp +++ b/src/qt/qt_vulkanrenderer.cpp @@ -502,16 +502,16 @@ VulkanRenderer2::initResources() VK_VERTEX_INPUT_RATE_VERTEX }; VkVertexInputAttributeDescription vertexAttrDesc[] = { - {// position + { // position 0, // location 0, // binding VK_FORMAT_R32G32B32_SFLOAT, - 0 }, + 0 }, { // texcoord 1, 0, VK_FORMAT_R32G32_SFLOAT, - 3 * sizeof(float)} + 3 * sizeof(float) } }; VkPipelineVertexInputStateCreateInfo vertexInputInfo; @@ -556,8 +556,8 @@ VulkanRenderer2::initResources() // Set up descriptor set and its layout. VkDescriptorPoolSize descPoolSizes[2] = { - {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, uint32_t(concurrentFrameCount)}, - { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, uint32_t(concurrentFrameCount)} + { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, uint32_t(concurrentFrameCount) }, + { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, uint32_t(concurrentFrameCount) } }; VkDescriptorPoolCreateInfo descPoolInfo; memset(&descPoolInfo, 0, sizeof(descPoolInfo)); @@ -572,16 +572,16 @@ VulkanRenderer2::initResources() } VkDescriptorSetLayoutBinding layoutBinding[2] = { - {0, // binding + { 0, // binding VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, // descriptorCount VK_SHADER_STAGE_VERTEX_BIT, - nullptr}, + nullptr }, { 1, // binding VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, // descriptorCount VK_SHADER_STAGE_FRAGMENT_BIT, - nullptr} + nullptr } }; VkDescriptorSetLayoutCreateInfo descLayoutInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, @@ -658,8 +658,8 @@ VulkanRenderer2::initResources() } // Shaders -#if 0 - #version 440 +# if 0 +# version 440 layout(location = 0) in vec4 position; layout(location = 1) in vec2 texcoord; @@ -677,10 +677,10 @@ VulkanRenderer2::initResources() v_texcoord = texcoord; gl_Position = ubuf.mvp * position; } -#endif /* 0 */ +# endif /* 0 */ VkShaderModule vertShaderModule = createShader(QStringLiteral(":/texture_vert.spv")); -#if 0 - #version 440 +# if 0 +# version 440 layout(location = 0) in vec2 v_texcoord; @@ -692,7 +692,7 @@ VulkanRenderer2::initResources() { fragColor = texture(tex, v_texcoord); } -#endif /* 0 */ +# endif /* 0 */ VkShaderModule fragShaderModule = createShader(QStringLiteral(":/texture_frag.spv")); // Graphics pipeline @@ -913,7 +913,7 @@ VulkanRenderer2::startNextFrame() ensureTexture(); VkClearColorValue clearColor = { - {0, 0, 0, 1} + { 0, 0, 0, 1 } }; VkClearDepthStencilValue clearDS = { 1, 0 }; VkClearValue clearValues[2]; @@ -970,11 +970,11 @@ VulkanRenderer2::startNextFrame() m_devFuncs->vkCmdBindVertexBuffers(cb, 0, 1, &m_buf, &vbOffset); VkViewport viewport; - viewport.x = destination.x(); - viewport.y = destination.y(); - viewport.width = destination.width(); - viewport.height = destination.height(); - + viewport.x = destination.x(); + viewport.y = destination.y(); + viewport.width = destination.width(); + viewport.height = destination.height(); + viewport.minDepth = 0; viewport.maxDepth = 1; m_devFuncs->vkCmdSetViewport(cb, 0, 1, &viewport); diff --git a/src/qt/qt_vulkanrenderer.hpp b/src/qt/qt_vulkanrenderer.hpp index 2c131e5d7..6037e7c38 100644 --- a/src/qt/qt_vulkanrenderer.hpp +++ b/src/qt/qt_vulkanrenderer.hpp @@ -32,13 +32,13 @@ ** ****************************************************************************/ #ifndef VULKANRENDERER_HPP -#define VULKANRENDERER_HPP +# define VULKANRENDERER_HPP -#include -#include +# include +# include -#if QT_CONFIG(vulkan) -# include "qt_vulkanwindowrenderer.hpp" +# if QT_CONFIG(vulkan) +# include "qt_vulkanwindowrenderer.hpp" class VulkanRenderer2 : public QVulkanWindowRenderer { public: @@ -92,6 +92,6 @@ private: QMatrix4x4 m_proj; }; -#endif // QT_CONFIG(vulkan) +# endif // QT_CONFIG(vulkan) #endif // VULKANRENDERER_HPP diff --git a/src/qt/qt_vulkanwindowrenderer.cpp b/src/qt/qt_vulkanwindowrenderer.cpp index 005f39b1f..79dbc8f87 100644 --- a/src/qt/qt_vulkanwindowrenderer.cpp +++ b/src/qt/qt_vulkanwindowrenderer.cpp @@ -820,7 +820,7 @@ public: m_devFuncs->vkDeviceWaitIdle(m_window->device()); } }; -# endif /* 0*/ +# endif /* 0*/ VulkanWindowRenderer::VulkanWindowRenderer(QWidget *parent) : QVulkanWindow(NULL) diff --git a/src/qt/qt_winrawinputfilter.cpp b/src/qt/qt_winrawinputfilter.cpp index 90d85e474..d40f4cdd6 100644 --- a/src/qt/qt_winrawinputfilter.cpp +++ b/src/qt/qt_winrawinputfilter.cpp @@ -51,7 +51,7 @@ #include #include #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +# define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif #include <86box/keyboard.h> @@ -63,7 +63,7 @@ #include #include -extern void win_keyboard_handle(uint32_t scancode, int up, int e0, int e1); +extern void win_keyboard_handle(uint32_t scancode, int up, int e0, int e1); #include #include @@ -74,15 +74,15 @@ extern void win_keyboard_handle(uint32_t scancode, int up, int e0, int e1); bool NewDarkMode = FALSE; -extern MainWindow* main_window; +extern MainWindow *main_window; struct { - HANDLE done_event = 0, ready_event = 0; - std::atomic_bool done{false}; + HANDLE done_event = 0, ready_event = 0; + std::atomic_bool done { false }; - size_t rawinput_offset = 0, rawinput_size = 0; - uint8_t* rawinput = nullptr; + size_t rawinput_offset = 0, rawinput_size = 0; + uint8_t *rawinput = nullptr; HANDLE thread = 0; } win_rawinput_data; @@ -91,11 +91,11 @@ static void win_poll_mouse(void) { // Yes, this is a thing in C++. - auto* data = &win_rawinput_data; - uint32_t size, i, count, total = 0; + auto *data = &win_rawinput_data; + uint32_t size, i, count, total = 0; RAWINPUT *input; - //static int64_t ms_time = plat_get_ticks(); - + // static int64_t ms_time = plat_get_ticks(); + if (data->rawinput_offset == 0) { BOOL isWow64; @@ -106,18 +106,18 @@ win_poll_mouse(void) } } - input = (RAWINPUT *)data->rawinput; + input = (RAWINPUT *) data->rawinput; for (;;) { - size = data->rawinput_size - (UINT)((BYTE *)input - data->rawinput); + size = data->rawinput_size - (UINT) ((BYTE *) input - data->rawinput); count = GetRawInputBuffer(input, &size, sizeof(RAWINPUTHEADER)); - if (count == 0 || count == (UINT)-1) { - if (!data->rawinput || (count == (UINT)-1 && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) { - const UINT RAWINPUT_BUFFER_SIZE_INCREMENT = 96; // 2 64-bit raw mouse packets - BYTE *rawinput = (BYTE *)realloc(data->rawinput, data->rawinput_size + RAWINPUT_BUFFER_SIZE_INCREMENT); + if (count == 0 || count == (UINT) -1) { + if (!data->rawinput || (count == (UINT) -1 && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) { + const UINT RAWINPUT_BUFFER_SIZE_INCREMENT = 96; // 2 64-bit raw mouse packets + BYTE *rawinput = (BYTE *) realloc(data->rawinput, data->rawinput_size + RAWINPUT_BUFFER_SIZE_INCREMENT); if (!rawinput) { break; } - input = (RAWINPUT *)(rawinput + ((BYTE *)input - data->rawinput)); + input = (RAWINPUT *) (rawinput + ((BYTE *) input - data->rawinput)); data->rawinput = rawinput; data->rawinput_size += RAWINPUT_BUFFER_SIZE_INCREMENT; } else { @@ -134,21 +134,21 @@ win_poll_mouse(void) } if (total > 0) { - for (i = 0, input = (RAWINPUT *)data->rawinput; i < total; ++i, input = NEXTRAWINPUTBLOCK(input)) { + for (i = 0, input = (RAWINPUT *) data->rawinput; i < total; ++i, input = NEXTRAWINPUTBLOCK(input)) { if (input->header.dwType == RIM_TYPEMOUSE) { - RAWMOUSE *rawmouse = (RAWMOUSE *)((BYTE *)input + data->rawinput_offset); + RAWMOUSE *rawmouse = (RAWMOUSE *) ((BYTE *) input + data->rawinput_offset); if (mouse_capture) WindowsRawInputFilter::mouse_handle(rawmouse); } } } - //qDebug() << "Mouse delay: " << (plat_get_ticks() - ms_time); - //ms_time = plat_get_ticks(); + // qDebug() << "Mouse delay: " << (plat_get_ticks() - ms_time); + // ms_time = plat_get_ticks(); } static DWORD -win_rawinput_thread(void* param) +win_rawinput_thread(void *param) { RAWINPUTDEVICE rid = { .usUsagePage = 0x01, @@ -179,14 +179,14 @@ win_rawinput_thread(void* param) } // Clear the queue status so MsgWaitForMultipleObjects() will wait again - (void)GetQueueStatus(QS_RAWINPUT); + (void) GetQueueStatus(QS_RAWINPUT); win_poll_mouse(); } rid.dwFlags |= RIDEV_REMOVE; rid.hwndTarget = NULL; - + RegisterRawInputDevices(&rid, 1, sizeof(rid)); DestroyWindow(window); return 0; @@ -197,19 +197,17 @@ std::unique_ptr WindowsRawInputFilter::Register(MainWindow *window) { RAWINPUTDEVICE rid[1] = { - { - .usUsagePage = 0x01, - .usUsage = 0x06, - .dwFlags = RIDEV_NOHOTKEYS, - .hwndTarget = nullptr - } + { .usUsagePage = 0x01, + .usUsage = 0x06, + .dwFlags = RIDEV_NOHOTKEYS, + .hwndTarget = nullptr } }; if (!hook_enabled) { RegisterRawInputDevices(rid, 1, sizeof(rid[0])); } - win_rawinput_data.done_event = CreateEvent(nullptr, FALSE, FALSE, nullptr); + win_rawinput_data.done_event = CreateEvent(nullptr, FALSE, FALSE, nullptr); win_rawinput_data.ready_event = CreateEvent(nullptr, FALSE, FALSE, nullptr); if (!win_rawinput_data.done_event || !win_rawinput_data.ready_event) { @@ -250,13 +248,12 @@ WindowsRawInputFilter::~WindowsRawInputFilter() SetEvent(win_rawinput_data.done_event); if (win_rawinput_data.thread) WaitForSingleObject(win_rawinput_data.thread, INFINITE); - RAWINPUTDEVICE rid = - { - .usUsagePage = 0x01, - .usUsage = 0x06, - .dwFlags = RIDEV_REMOVE, - .hwndTarget = NULL - }; + RAWINPUTDEVICE rid = { + .usUsagePage = 0x01, + .usUsage = 0x06, + .dwFlags = RIDEV_REMOVE, + .hwndTarget = NULL + }; if (!hook_enabled) RegisterRawInputDevices(&rid, 1, sizeof(rid)); @@ -267,25 +264,25 @@ WindowsRawInputFilter::~WindowsRawInputFilter() static void notify_drives(ULONG unitmask, int empty) { - if (unitmask & cdrom_assigned_letters) for (int i = 0; i < CDROM_NUM; i++) { - cdrom_t *dev = &(cdrom[i]); + if (unitmask & cdrom_assigned_letters) + for (int i = 0; i < CDROM_NUM; i++) { + cdrom_t *dev = &(cdrom[i]); - if ((dev->host_letter != 0xff) && - (unitmask & (1 << dev->host_letter))) { - if (empty) - cdrom_set_empty(dev); - else - cdrom_update_status(dev); + if ((dev->host_letter != 0xff) && (unitmask & (1 << dev->host_letter))) { + if (empty) + cdrom_set_empty(dev); + else + cdrom_update_status(dev); + } } - } } static void device_change(WPARAM wParam, LPARAM lParam) { - PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR) lParam; + PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR) lParam; - switch(wParam) { + switch (wParam) { case DBT_DEVICEARRIVAL: case DBT_DEVICEREMOVECOMPLETE: /* Check whether a CD or DVD was inserted into a drive. */ @@ -300,9 +297,9 @@ device_change(WPARAM wParam, LPARAM lParam) default: /* - Process other WM_DEVICECHANGE notifications for other + Process other WM_DEVICECHANGE notifications for other devices or reasons. - */ + */ break; } } @@ -363,25 +360,24 @@ WindowsRawInputFilter::nativeEventFilter(const QByteArray &eventType, void *mess if (eventType == "windows_generic_MSG") { MSG *msg = static_cast(message); - if (msg != nullptr) switch(msg->message) { - case WM_INPUT: - if (window->isActiveWindow() && (menus_open == 0)) - handle_input((HRAWINPUT) msg->lParam); - else { - for (auto &w : window->renderers) { - if (w && w->isActiveWindow()) { - handle_input((HRAWINPUT) msg->lParam); - break; + if (msg != nullptr) + switch (msg->message) { + case WM_INPUT: + if (window->isActiveWindow() && (menus_open == 0)) + handle_input((HRAWINPUT) msg->lParam); + else { + for (auto &w : window->renderers) { + if (w && w->isActiveWindow()) { + handle_input((HRAWINPUT) msg->lParam); + break; + } } } - } - return true; - case WM_SETTINGCHANGE: - if ((((void *) msg->lParam) != nullptr) && - (wcscmp(L"ImmersiveColorSet", (wchar_t*)msg->lParam) == 0) && - color_scheme == 0) { + return true; + case WM_SETTINGCHANGE: + if ((((void *) msg->lParam) != nullptr) && (wcscmp(L"ImmersiveColorSet", (wchar_t *) msg->lParam) == 0) && color_scheme == 0) { - bool OldDarkMode = NewDarkMode; + bool OldDarkMode = NewDarkMode; #if 0 if (do_auto_pause && !dopause) { auto_paused = 1; @@ -389,48 +385,48 @@ WindowsRawInputFilter::nativeEventFilter(const QByteArray &eventType, void *mess } #endif - if (!util::isWindowsLightTheme()) { - QFile f(":qdarkstyle/dark/darkstyle.qss"); + if (!util::isWindowsLightTheme()) { + QFile f(":qdarkstyle/dark/darkstyle.qss"); - if (!f.exists()) - printf("Unable to set stylesheet, file not found\n"); - else { - f.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&f); - qApp->setStyleSheet(ts.readAll()); + if (!f.exists()) + printf("Unable to set stylesheet, file not found\n"); + else { + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); + qApp->setStyleSheet(ts.readAll()); + } + QPalette palette(qApp->palette()); + palette.setColor(QPalette::Link, Qt::white); + palette.setColor(QPalette::LinkVisited, Qt::lightGray); + qApp->setPalette(palette); + NewDarkMode = TRUE; + } else { + qApp->setStyleSheet(""); + QPalette palette(qApp->palette()); + palette.setColor(QPalette::Link, Qt::blue); + palette.setColor(QPalette::LinkVisited, Qt::magenta); + qApp->setPalette(palette); + NewDarkMode = FALSE; } - QPalette palette(qApp->palette()); - palette.setColor(QPalette::Link, Qt::white); - palette.setColor(QPalette::LinkVisited, Qt::lightGray); - qApp->setPalette(palette); - NewDarkMode = TRUE; - } else { - qApp->setStyleSheet(""); - QPalette palette(qApp->palette()); - palette.setColor(QPalette::Link, Qt::blue); - palette.setColor(QPalette::LinkVisited, Qt::magenta); - qApp->setPalette(palette); - NewDarkMode = FALSE; - } - if (NewDarkMode != OldDarkMode) QTimer::singleShot(1000, [this] () { - BOOL DarkMode = NewDarkMode; - DwmSetWindowAttribute((HWND) window->winId(), - DWMWA_USE_IMMERSIVE_DARK_MODE, - (LPCVOID) &DarkMode, - sizeof(DarkMode)); + if (NewDarkMode != OldDarkMode) + QTimer::singleShot(1000, [this]() { + BOOL DarkMode = NewDarkMode; + DwmSetWindowAttribute((HWND) window->winId(), + DWMWA_USE_IMMERSIVE_DARK_MODE, + (LPCVOID) &DarkMode, + sizeof(DarkMode)); - window->resizeContents(monitors[0].mon_scrnsz_x, - monitors[0].mon_scrnsz_y); + window->resizeContents(monitors[0].mon_scrnsz_x, + monitors[0].mon_scrnsz_y); - for (int i = 1; i < MONITORS_NUM; i++) { - auto mon = &(monitors[i]); + for (int i = 1; i < MONITORS_NUM; i++) { + auto mon = &(monitors[i]); - if ((window->renderers[i] != nullptr) && - !window->renderers[i]->isHidden()) - window->resizeContentsMonitor(mon->mon_scrnsz_x, - mon->mon_scrnsz_y, i); - } + if ((window->renderers[i] != nullptr) && !window->renderers[i]->isHidden()) + window->resizeContentsMonitor(mon->mon_scrnsz_x, + mon->mon_scrnsz_y, i); + } #if 0 if (auto_paused) { @@ -438,19 +434,19 @@ WindowsRawInputFilter::nativeEventFilter(const QByteArray &eventType, void *mess auto_paused = 0; } #endif - }); - } - break; - case WM_SYSKEYDOWN: - /* Stop processing of Alt-F4 */ - if (msg->wParam == 0x73) - return true; - break; - case WM_DEVICECHANGE: - if (msg->hwnd == (HWND) window->winId()) - device_change(msg->wParam, msg->lParam); - break; - } + }); + } + break; + case WM_SYSKEYDOWN: + /* Stop processing of Alt-F4 */ + if (msg->wParam == 0x73) + return true; + break; + case WM_DEVICECHANGE: + if (msg->hwnd == (HWND) window->winId()) + device_change(msg->wParam, msg->lParam); + break; + } } return false; @@ -491,7 +487,7 @@ WindowsRawInputFilter::keyboard_handle(PRAWINPUT raw) } void -WindowsRawInputFilter::mouse_handle(RAWMOUSE* raw) +WindowsRawInputFilter::mouse_handle(RAWMOUSE *raw) { RAWMOUSE state = *raw; static int x, delta_x; @@ -548,8 +544,8 @@ WindowsRawInputFilter::mouse_handle(RAWMOUSE* raw) */ delta_x = (state.lLastX - x) / 25; delta_y = (state.lLastY - y) / 25; - x = state.lLastX; - y = state.lLastY; + x = state.lLastX; + y = state.lLastY; } else { /* relative mouse, i.e. regular mouse */ delta_x = state.lLastX; diff --git a/src/qt/qt_winrawinputfilter.hpp b/src/qt/qt_winrawinputfilter.hpp index 28b061ac0..c70fadc3c 100644 --- a/src/qt/qt_winrawinputfilter.hpp +++ b/src/qt/qt_winrawinputfilter.hpp @@ -57,20 +57,20 @@ public: ~WindowsRawInputFilter(); - static void mouse_handle(RAWMOUSE* raw); + static void mouse_handle(RAWMOUSE *raw); private: MainWindow *window; - int buttons = 0; - int dx = 0; - int dy = 0; - int dwheel = 0; - int menus_open = 0; + int buttons = 0; + int dx = 0; + int dy = 0; + int dwheel = 0; + int menus_open = 0; WindowsRawInputFilter(MainWindow *window); - void handle_input(HRAWINPUT input); - void keyboard_handle(PRAWINPUT raw); + void handle_input(HRAWINPUT input); + void keyboard_handle(PRAWINPUT raw); }; #endif diff --git a/src/qt/xinput2_mouse.cpp b/src/qt/xinput2_mouse.cpp index b901e7338..5643df4d4 100644 --- a/src/qt/xinput2_mouse.cpp +++ b/src/qt/xinput2_mouse.cpp @@ -44,7 +44,7 @@ extern "C" { static Display *disp = nullptr; static QThread *procThread = nullptr; static XIEventMask ximask; -static std::atomic exitfromthread = false; +static std::atomic exitfromthread = false; static std::atomic xi2_mouse_abs_x = 0, xi2_mouse_abs_y = 0; static int xi2opcode = 0; static double prev_coords[2] = { 0.0 }; @@ -56,8 +56,8 @@ parse_valuators(const double *input_values, const unsigned char *mask, int mask_len, double *output_values, int output_values_len) { - int i = 0; - int z = 0; + int i = 0; + int z = 0; int top = mask_len * 8; if (top > 16) top = 16; diff --git a/src/qt/xkbcommon_keyboard.cpp b/src/qt/xkbcommon_keyboard.cpp index f1a43621d..6f358a9c3 100644 --- a/src/qt/xkbcommon_keyboard.cpp +++ b/src/qt/xkbcommon_keyboard.cpp @@ -24,175 +24,175 @@ extern "C" { #define IS_HEX_DIGIT(c) (IS_DEC_DIGIT(c) || (((c) >= 'A') && ((c) <= 'F')) || (((c) >= 'a') && ((c) <= 'f'))) static std::unordered_map xkb_keycodes = { - {"ESC", 0x01}, - {"AE01", 0x02}, - {"AE02", 0x03}, - {"AE03", 0x04}, - {"AE04", 0x05}, - {"AE05", 0x06}, - {"AE06", 0x07}, - {"AE07", 0x08}, - {"AE08", 0x09}, - {"AE09", 0x0a}, - {"AE10", 0x0b}, - {"AE11", 0x0c}, - {"AE12", 0x0d}, - {"BKSP", 0x0e}, + { "ESC", 0x01 }, + { "AE01", 0x02 }, + { "AE02", 0x03 }, + { "AE03", 0x04 }, + { "AE04", 0x05 }, + { "AE05", 0x06 }, + { "AE06", 0x07 }, + { "AE07", 0x08 }, + { "AE08", 0x09 }, + { "AE09", 0x0a }, + { "AE10", 0x0b }, + { "AE11", 0x0c }, + { "AE12", 0x0d }, + { "BKSP", 0x0e }, - {"TAB", 0x0f}, - {"AD01", 0x10}, - {"AD02", 0x11}, - {"AD03", 0x12}, - {"AD04", 0x13}, - {"AD05", 0x14}, - {"AD06", 0x15}, - {"AD07", 0x16}, - {"AD08", 0x17}, - {"AD09", 0x18}, - {"AD10", 0x19}, - {"AD11", 0x1a}, - {"AD12", 0x1b}, - {"RTRN", 0x1c}, - {"LNFD", 0x1c}, /* linefeed => Enter */ + { "TAB", 0x0f }, + { "AD01", 0x10 }, + { "AD02", 0x11 }, + { "AD03", 0x12 }, + { "AD04", 0x13 }, + { "AD05", 0x14 }, + { "AD06", 0x15 }, + { "AD07", 0x16 }, + { "AD08", 0x17 }, + { "AD09", 0x18 }, + { "AD10", 0x19 }, + { "AD11", 0x1a }, + { "AD12", 0x1b }, + { "RTRN", 0x1c }, + { "LNFD", 0x1c }, /* linefeed => Enter */ - {"LCTL", 0x1d}, - {"CTRL", 0x1d}, - {"AC01", 0x1e}, - {"AC02", 0x1f}, - {"AC03", 0x20}, - {"AC04", 0x21}, - {"AC05", 0x22}, - {"AC06", 0x23}, - {"AC07", 0x24}, - {"AC08", 0x25}, - {"AC09", 0x26}, - {"AC10", 0x27}, - {"AC11", 0x28}, + { "LCTL", 0x1d }, + { "CTRL", 0x1d }, + { "AC01", 0x1e }, + { "AC02", 0x1f }, + { "AC03", 0x20 }, + { "AC04", 0x21 }, + { "AC05", 0x22 }, + { "AC06", 0x23 }, + { "AC07", 0x24 }, + { "AC08", 0x25 }, + { "AC09", 0x26 }, + { "AC10", 0x27 }, + { "AC11", 0x28 }, - {"TLDE", 0x29}, - {"AE00", 0x29}, /* alias of TLDE on keycodes/xfree86 (i.e. X11 forwarding) */ - {"LFSH", 0x2a}, - {"BKSL", 0x2b}, - {"AC12", 0x2b}, - {"AB01", 0x2c}, - {"AB02", 0x2d}, - {"AB03", 0x2e}, - {"AB04", 0x2f}, - {"AB05", 0x30}, - {"AB06", 0x31}, - {"AB07", 0x32}, - {"AB08", 0x33}, - {"AB09", 0x34}, - {"AB10", 0x35}, - {"RTSH", 0x36}, + { "TLDE", 0x29 }, + { "AE00", 0x29 }, /* alias of TLDE on keycodes/xfree86 (i.e. X11 forwarding) */ + { "LFSH", 0x2a }, + { "BKSL", 0x2b }, + { "AC12", 0x2b }, + { "AB01", 0x2c }, + { "AB02", 0x2d }, + { "AB03", 0x2e }, + { "AB04", 0x2f }, + { "AB05", 0x30 }, + { "AB06", 0x31 }, + { "AB07", 0x32 }, + { "AB08", 0x33 }, + { "AB09", 0x34 }, + { "AB10", 0x35 }, + { "RTSH", 0x36 }, - {"KPMU", 0x37}, - {"LALT", 0x38}, - {"ALT", 0x38}, - {"SPCE", 0x39}, - {"CAPS", 0x3a}, - {"FK01", 0x3b}, - {"FK02", 0x3c}, - {"FK03", 0x3d}, - {"FK04", 0x3e}, - {"FK05", 0x3f}, - {"FK06", 0x40}, - {"FK07", 0x41}, - {"FK08", 0x42}, - {"FK09", 0x43}, - {"FK10", 0x44}, + { "KPMU", 0x37 }, + { "LALT", 0x38 }, + { "ALT", 0x38 }, + { "SPCE", 0x39 }, + { "CAPS", 0x3a }, + { "FK01", 0x3b }, + { "FK02", 0x3c }, + { "FK03", 0x3d }, + { "FK04", 0x3e }, + { "FK05", 0x3f }, + { "FK06", 0x40 }, + { "FK07", 0x41 }, + { "FK08", 0x42 }, + { "FK09", 0x43 }, + { "FK10", 0x44 }, - {"NMLK", 0x45}, - {"SCLK", 0x46}, - {"FK14", 0x46}, /* F14 => Scroll Lock (for Apple keyboards) */ - {"KP7", 0x47}, - {"KP8", 0x48}, - {"KP9", 0x49}, - {"KPSU", 0x4a}, - {"KP4", 0x4b}, - {"KP5", 0x4c}, - {"KP6", 0x4d}, - {"KPAD", 0x4e}, - {"KP1", 0x4f}, - {"KP2", 0x50}, - {"KP3", 0x51}, - {"KP0", 0x52}, - {"KPDL", 0x53}, + { "NMLK", 0x45 }, + { "SCLK", 0x46 }, + { "FK14", 0x46 }, /* F14 => Scroll Lock (for Apple keyboards) */ + { "KP7", 0x47 }, + { "KP8", 0x48 }, + { "KP9", 0x49 }, + { "KPSU", 0x4a }, + { "KP4", 0x4b }, + { "KP5", 0x4c }, + { "KP6", 0x4d }, + { "KPAD", 0x4e }, + { "KP1", 0x4f }, + { "KP2", 0x50 }, + { "KP3", 0x51 }, + { "KP0", 0x52 }, + { "KPDL", 0x53 }, - {"LSGT", 0x56}, - {"FK11", 0x57}, - {"FK12", 0x58}, - {"FK16", 0x5d}, /* F16 => F13 */ - {"FK17", 0x5e}, /* F17 => F14 */ - {"FK18", 0x5f}, /* F18 => F15 */ + { "LSGT", 0x56 }, + { "FK11", 0x57 }, + { "FK12", 0x58 }, + { "FK16", 0x5d }, /* F16 => F13 */ + { "FK17", 0x5e }, /* F17 => F14 */ + { "FK18", 0x5f }, /* F18 => F15 */ /* Japanese keys. */ - {"JPCM", 0x5c}, /* Num, */ - {"KPDC", 0x5c}, - {"HKTG", 0x70}, /* hiragana-katakana toggle */ - {"AB11", 0x73}, /* \_ and Brazilian /? */ - {"HZTG", 0x76}, /* hankaku-zenkaku toggle */ - {"HIRA", 0x77}, - {"KATA", 0x78}, - {"HENK", 0x79}, - {"KANA", 0x79}, /* kana => henkan (for Apple keyboards) */ - {"MUHE", 0x7b}, - {"EISU", 0x7b}, /* eisu => muhenkan (for Apple keyboards) */ - {"AE13", 0x7d}, /* \| */ - {"KPPT", 0x7e}, /* Brazilian Num. */ - {"I06", 0x7e}, /* alias of KPPT on keycodes/xfree86 (i.e. X11 forwarding) */ + { "JPCM", 0x5c }, /* Num, */ + { "KPDC", 0x5c }, + { "HKTG", 0x70 }, /* hiragana-katakana toggle */ + { "AB11", 0x73 }, /* \_ and Brazilian /? */ + { "HZTG", 0x76 }, /* hankaku-zenkaku toggle */ + { "HIRA", 0x77 }, + { "KATA", 0x78 }, + { "HENK", 0x79 }, + { "KANA", 0x79 }, /* kana => henkan (for Apple keyboards) */ + { "MUHE", 0x7b }, + { "EISU", 0x7b }, /* eisu => muhenkan (for Apple keyboards) */ + { "AE13", 0x7d }, /* \| */ + { "KPPT", 0x7e }, /* Brazilian Num. */ + { "I06", 0x7e }, /* alias of KPPT on keycodes/xfree86 (i.e. X11 forwarding) */ /* Korean keys. */ - {"HJCV", 0xf1}, /* hancha toggle */ - {"HNGL", 0xf2}, /* latin toggle */ + { "HJCV", 0xf1 }, /* hancha toggle */ + { "HNGL", 0xf2 }, /* latin toggle */ - {"KPEN", 0x11c}, - {"RCTL", 0x11d}, - {"KPDV", 0x135}, - {"PRSC", 0x137}, - {"SYRQ", 0x137}, - {"FK13", 0x137}, /* F13 => SysRq (for Apple keyboards) */ - {"RALT", 0x138}, - {"ALGR", 0x138}, - {"LVL3", 0x138}, /* observed on TigerVNC with AltGr-enabled layout */ - {"PAUS", 0x145}, - {"FK15", 0x145}, /* F15 => Pause (for Apple keyboards) */ - {"BRK", 0x145}, - {"HOME", 0x147}, - {"UP", 0x148}, - {"PGUP", 0x149}, - {"LEFT", 0x14b}, - {"RGHT", 0x14d}, - {"END", 0x14f}, - {"DOWN", 0x150}, - {"PGDN", 0x151}, - {"INS", 0x152}, - {"DELE", 0x153}, + { "KPEN", 0x11c }, + { "RCTL", 0x11d }, + { "KPDV", 0x135 }, + { "PRSC", 0x137 }, + { "SYRQ", 0x137 }, + { "FK13", 0x137 }, /* F13 => SysRq (for Apple keyboards) */ + { "RALT", 0x138 }, + { "ALGR", 0x138 }, + { "LVL3", 0x138 }, /* observed on TigerVNC with AltGr-enabled layout */ + { "PAUS", 0x145 }, + { "FK15", 0x145 }, /* F15 => Pause (for Apple keyboards) */ + { "BRK", 0x145 }, + { "HOME", 0x147 }, + { "UP", 0x148 }, + { "PGUP", 0x149 }, + { "LEFT", 0x14b }, + { "RGHT", 0x14d }, + { "END", 0x14f }, + { "DOWN", 0x150 }, + { "PGDN", 0x151 }, + { "INS", 0x152 }, + { "DELE", 0x153 }, - {"LWIN", 0x15b}, - {"WIN", 0x15b}, - {"LMTA", 0x15b}, - {"META", 0x15b}, - {"RWIN", 0x15c}, - {"RMTA", 0x15c}, - {"MENU", 0x15d}, - {"COMP", 0x15d}, /* Compose as Menu */ + { "LWIN", 0x15b }, + { "WIN", 0x15b }, + { "LMTA", 0x15b }, + { "META", 0x15b }, + { "RWIN", 0x15c }, + { "RMTA", 0x15c }, + { "MENU", 0x15d }, + { "COMP", 0x15d }, /* Compose as Menu */ /* Multimedia keys. Same notes as evdev_keyboard apply here. */ - {"KPEQ", 0x59}, /* Num= */ - {"FRNT", 0x101}, /* # Logitech Task Select */ - {"UNDO", 0x108}, /* # */ - {"PAST", 0x10a}, /* # Paste */ - {"FIND", 0x112}, /* # Logitech */ - {"CUT", 0x117}, /* # */ - {"COPY", 0x118}, /* # */ - {"MUTE", 0x120}, - {"VOL-", 0x12e}, - {"VOL+", 0x130}, - {"HELP", 0x13b}, - {"OPEN", 0x13f}, - {"POWR", 0x15e}, - {"STOP", 0x168}, + { "KPEQ", 0x59 }, /* Num= */ + { "FRNT", 0x101 }, /* # Logitech Task Select */ + { "UNDO", 0x108 }, /* # */ + { "PAST", 0x10a }, /* # Paste */ + { "FIND", 0x112 }, /* # Logitech */ + { "CUT", 0x117 }, /* # */ + { "COPY", 0x118 }, /* # */ + { "MUTE", 0x120 }, + { "VOL-", 0x12e }, + { "VOL+", 0x130 }, + { "HELP", 0x13b }, + { "OPEN", 0x13f }, + { "POWR", 0x15e }, + { "STOP", 0x168 }, }; struct xkb_keymap *xkbcommon_keymap = nullptr; @@ -217,7 +217,7 @@ xkbcommon_translate(uint32_t keycode) /* If XKB doesn't know the key name for this keycode, assume an unnamed Ixxx key. This is useful for older XKB versions with an incomplete evdev keycode map. */ auto key_name_s = key_name ? std::string(key_name) : QString("I%1").arg(keycode).toStdString(); - auto ret = xkb_keycodes[key_name_s]; + auto ret = xkb_keycodes[key_name_s]; /* Observed with multimedia keys on Windows VcXsrv. */ if (!ret && (key_name_s.length() == 3) && (key_name_s[0] == 'I') && IS_HEX_DIGIT(key_name_s[1]) && IS_HEX_DIGIT(key_name_s[2])) diff --git a/src/qt/xkbcommon_keyboard.hpp b/src/qt/xkbcommon_keyboard.hpp index 221a72228..9648eb287 100644 --- a/src/qt/xkbcommon_keyboard.hpp +++ b/src/qt/xkbcommon_keyboard.hpp @@ -13,6 +13,6 @@ * Copyright 2023 RichardG. */ extern void *xkbcommon_keymap; -void xkbcommon_init(struct xkb_keymap *keymap); -void xkbcommon_close(); -uint16_t xkbcommon_translate(uint32_t keycode); +void xkbcommon_init(struct xkb_keymap *keymap); +void xkbcommon_close(); +uint16_t xkbcommon_translate(uint32_t keycode); diff --git a/src/qt/xkbcommon_wl_keyboard.cpp b/src/qt/xkbcommon_wl_keyboard.cpp index 6158476e1..d5076a0b9 100644 --- a/src/qt/xkbcommon_wl_keyboard.cpp +++ b/src/qt/xkbcommon_wl_keyboard.cpp @@ -29,17 +29,17 @@ extern "C" { #include typedef struct { - struct wl_seat *wl_seat; + struct wl_seat *wl_seat; struct wl_keyboard *wl_kbd; - uint32_t version; + uint32_t version; struct xkb_keymap *keymap; struct wl_list link; } seat_t; -static bool wl_init_ok = false; -static struct wl_list seats; +static bool wl_init_ok = false; +static struct wl_list seats; static struct xkb_context *ctx; static void @@ -48,7 +48,8 @@ xkbcommon_wl_set_keymap() /* Grab keymap from the first seat with one. */ seat_t *seat; seat_t *tmp; - wl_list_for_each_safe(seat, tmp, &seats, link) { + wl_list_for_each_safe(seat, tmp, &seats, link) + { if (seat->keymap) { xkbcommon_init(seat->keymap); return; @@ -71,7 +72,7 @@ kbd_keymap(void *data, struct wl_keyboard *wl_kbd, uint32_t format, if (seat->keymap) { struct xkb_keymap *keymap = seat->keymap; - seat->keymap = NULL; + seat->keymap = NULL; xkbcommon_wl_set_keymap(); xkb_keymap_unref(keymap); } @@ -142,7 +143,7 @@ seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t caps) wl_keyboard_destroy(seat->wl_kbd); struct xkb_keymap *keymap = seat->keymap; - seat->keymap = NULL; + seat->keymap = NULL; xkbcommon_wl_set_keymap(); xkb_keymap_unref(keymap); @@ -181,7 +182,8 @@ display_global_remove(void *data, struct wl_registry *wl_registry, uint32_t id) seat_t *seat; seat_t *tmp; - wl_list_for_each_safe(seat, tmp, &seats, link) { + wl_list_for_each_safe(seat, tmp, &seats, link) + { if (seat->wl_kbd) { if (seat->version >= WL_SEAT_RELEASE_SINCE_VERSION) wl_keyboard_release(seat->wl_kbd); diff --git a/src/qt/xkbcommon_x11_keyboard.cpp b/src/qt/xkbcommon_x11_keyboard.cpp index fc39ad8a2..471e50cf4 100644 --- a/src/qt/xkbcommon_x11_keyboard.cpp +++ b/src/qt/xkbcommon_x11_keyboard.cpp @@ -17,12 +17,12 @@ extern "C" { /* xkb.h has identifiers named "explicit", which is a C++ keyword now... */ #ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wkeyword-macro" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wkeyword-macro" #endif #define explicit explicit_ #ifdef __clang__ -#pragma clang diagnostic pop +# pragma clang diagnostic pop #endif #include #undef explicit @@ -38,10 +38,10 @@ extern "C" { void xkbcommon_x11_init() { - xcb_connection_t *conn; + xcb_connection_t *conn; struct xkb_context *ctx; - int32_t core_kbd_device_id; - struct xkb_keymap *keymap; + int32_t core_kbd_device_id; + struct xkb_keymap *keymap; conn = (xcb_connection_t *) QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("connection"); if (!conn) { From d69591da50b7d980c0c4fe5965ac84c3cc2da6a5 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 02:27:05 +0100 Subject: [PATCH 28/89] CS8220: Fix base memory in 1024 kB mode, closes #6444. --- src/chipset/cs8220.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/chipset/cs8220.c b/src/chipset/cs8220.c index 3c3c23767..d66ac5246 100644 --- a/src/chipset/cs8220.c +++ b/src/chipset/cs8220.c @@ -242,9 +242,13 @@ cs8220_init(UNUSED(const device_t *info)) dev->ram_banks[0].virt = 0x00000000; dev->ram_banks[0].phys = 0x00000000; dev->ram_banks[0].size = 0x00080000; - dev->ram_banks[1].virt = 0x00100000; + dev->ram_banks[1].virt = 0x00080000; dev->ram_banks[1].phys = 0x00080000; - dev->ram_banks[1].size = 0x00080000; + dev->ram_banks[1].size = 0x00020000; + /* Pretend there's a 384k expansion. */ + dev->ram_banks[2].virt = 0x00100000; + dev->ram_banks[2].phys = 0x00080000; + dev->ram_banks[2].size = 0x00060000; break; } From 5f2d9f1fdb3c67ae91e572210db285d92d8ae149 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 02:32:52 +0100 Subject: [PATCH 29/89] Fix some machine warnings. --- src/include/86box/machine.h | 6 ++-- src/machine/m_at_socket370.c | 61 ++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index a50947ef5..878683217 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1292,6 +1292,9 @@ extern int machine_at_cubx_init(const machine_t *); /* i440ZX */ extern int machine_at_63a1_init(const machine_t *); +/* SiS 600 */ +extern int machine_at_7sbb_init(const machine_t *); + /* SMSC VictoryBX-66 */ extern int machine_at_atc7020bxii_init(const machine_t *); extern int machine_at_m773_init(const machine_t *); @@ -1310,9 +1313,6 @@ extern const device_t ms6318_device; #endif extern int machine_at_ms6318_init(const machine_t *); -/* SiS 600 */ -extern int machine_at_7sbb_init(const machine_t *); - /* m_at_misc.c */ extern int machine_at_vpc2007_init(const machine_t *); diff --git a/src/machine/m_at_socket370.c b/src/machine/m_at_socket370.c index 88bb8752f..2beca3eac 100644 --- a/src/machine/m_at_socket370.c +++ b/src/machine/m_at_socket370.c @@ -215,6 +215,35 @@ machine_at_63a1_init(const machine_t *model) return ret; } +/* SiS 600 */ +int +machine_at_7sbb_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear("roms/machines/7sbb/sbb12aa2.bin", + 0x000c0000, 262144, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init_ex(model, 2); + + pci_init(PCI_CONFIG_TYPE_1 | FLAG_TRC_CONTROLS_CPURST); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x01, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x0F, PCI_CARD_NORMAL, 1, 2, 3, 4); + pci_register_slot(0x10, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x11, PCI_CARD_NORMAL, 3, 4, 1, 2); + pci_register_slot(0x02, PCI_CARD_AGPBRIDGE, 1, 2, 3, 4); + + device_add(&sis_5600_device); + device_add(&it8661f_device); + device_add(&sst_flash_29ee020_device); /* assumed */ + + return ret; +} + /* SMSC VictoryBX-66 */ int machine_at_atc7020bxii_init(const machine_t *model) @@ -584,36 +613,8 @@ machine_at_ms6318_init(const machine_t *model) if (sound_card_current[0] == SOUND_INTERNAL) device_add(machine_get_snd_device(machine)); - device_add(&stac9708_device); - - return ret; -} - -/* SiS 600 */ -int -machine_at_7sbb_init(const machine_t *model) -{ - int ret; - - ret = bios_load_linear("roms/machines/7sbb/sbb12aa2.bin", - 0x000c0000, 262144, 0); - - if (bios_only || !ret) - return ret; - - machine_at_common_init_ex(model, 2); - - pci_init(PCI_CONFIG_TYPE_1 | FLAG_TRC_CONTROLS_CPURST); - pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); - pci_register_slot(0x01, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); - pci_register_slot(0x0F, PCI_CARD_NORMAL, 1, 2, 3, 4); - pci_register_slot(0x10, PCI_CARD_NORMAL, 2, 3, 4, 1); - pci_register_slot(0x11, PCI_CARD_NORMAL, 3, 4, 1, 2); - pci_register_slot(0x02, PCI_CARD_AGPBRIDGE, 1, 2, 3, 4); - - device_add(&sis_5600_device); - device_add(&it8661f_device); - device_add(&sst_flash_29ee020_device); /* assumed */ + + device_add(&stac9708_device); return ret; } From 3da005639fe463c021b0185f29fb53b0437e5eb6 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 03:23:51 +0100 Subject: [PATCH 30/89] VLSI SCAMP: Remove the unused implementation of optional card memory. --- src/chipset/scamp.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/chipset/scamp.c b/src/chipset/scamp.c index 9019809b5..ba33bea39 100644 --- a/src/chipset/scamp.c +++ b/src/chipset/scamp.c @@ -92,7 +92,7 @@ typedef struct ram_struct_t { int bank; } ram_struct_t; -typedef struct card_mem_t { +typedef struct mem_page_t { int in_ram; uint32_t virt_addr; uint32_t phys_addr; @@ -124,10 +124,6 @@ typedef struct scamp_t { mem_mapping_t mem_mappings[64]; /* The entire first 1 MB of memory space. */ mem_page_t mem_pages[64]; - uint32_t card_mem_size; - uint8_t *card_mem; - mem_page_t card_pages[4]; - port_92_t *port_92; } scamp_t; @@ -1180,14 +1176,6 @@ scamp_init(UNUSED(const device_t *info)) } } - dev->card_mem = NULL; - - for (uint8_t i = 0; i < 4; i++) { - dev->card_pages[i].virt_addr = i * EMS_PGSIZE; - dev->card_pages[i].phys_addr = dev->card_pages[i].virt_addr; - dev->card_pages[i].mem = dev->card_mem + dev->card_pages[i].phys_addr; - } - dev->port_92 = device_add(&port_92_device); return dev; From 59ccb2292473ea8f76ed24f688d3112da43c9964 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 03:28:26 +0100 Subject: [PATCH 31/89] PIIX 3/4: Put USB PCI register 60h to the proper place. --- src/chipset/intel_piix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/chipset/intel_piix.c b/src/chipset/intel_piix.c index f48950cdc..32df44098 100644 --- a/src/chipset/intel_piix.c +++ b/src/chipset/intel_piix.c @@ -1376,13 +1376,12 @@ piix_reset_hard(piix_t *dev) if (dev->type < 5) fregs[0x20] = 0x01; fregs[0x3d] = 0x04; - if (dev->type > 4) - fregs[0x60] = (dev->type > 3) ? 0x10 : 0x00; if (dev->type < 5) { + fregs[0x60] = (dev->type > 3) ? 0x10 : 0x00; fregs[0x6a] = (dev->type == 3) ? 0x01 : 0x00; fregs[0xc1] = 0x20; fregs[0xff] = (dev->type > 3) ? 0x10 : 0x00; - } + } else dev->max_func = 2; /* It starts with USB disabled, then enables it. */ } From 158718836eb565148a5850a28a2fe984def69e39 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 03:30:05 +0100 Subject: [PATCH 32/89] SiS 5571 Host to PCI bridge: only initialize register 93h once on reset. --- src/chipset/sis_5571_h2p.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/chipset/sis_5571_h2p.c b/src/chipset/sis_5571_h2p.c index a28553487..3ebb5f240 100644 --- a/src/chipset/sis_5571_h2p.c +++ b/src/chipset/sis_5571_h2p.c @@ -392,7 +392,6 @@ sis_5571_host_to_pci_reset(void *priv) dev->pci_conf[0x91] = 0x00; dev->pci_conf[0x92] = 0x00; dev->pci_conf[0x93] = 0x00; - dev->pci_conf[0x93] = 0x00; dev->pci_conf[0x94] = 0x00; dev->pci_conf[0x95] = 0x00; dev->pci_conf[0x96] = 0x00; From e0aa4c74d49526496ba89de5fb82cc19f4763fef Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 03:30:57 +0100 Subject: [PATCH 33/89] Bochs VBE: Simplify horizontal blank end calculation. --- src/video/vid_bochs_vbe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vid_bochs_vbe.c b/src/video/vid_bochs_vbe.c index ea0b8872b..0a41bec2d 100644 --- a/src/video/vid_bochs_vbe.c +++ b/src/video/vid_bochs_vbe.c @@ -319,7 +319,7 @@ bochs_vbe_recalctimings(svga_t* svga) svga->vtotal = mode.vtotal; svga->htotal = mode.htotal; svga->hblankstart = mode.hdisplay; - svga->hblankend = mode.hdisplay + (mode.htotal - mode.hdisplay - 1); + svga->hblankend = mode.htotal - 1; svga->vblankstart = svga->dispend; /* no vertical overscan. */ svga->rowcount = 0; svga->hoverride = 1; From f71da53ee8ccd8074b7984bca1a9214569fb14ce Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 03:33:26 +0100 Subject: [PATCH 34/89] Matrox: Simplify some transc checks. --- src/video/vid_mga.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index 5aadd71f6..68de89767 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -4492,7 +4492,7 @@ blit_line(mystique_t *mystique, int closed, int autoline) if (x >= mystique->dwgreg.cxleft && x <= mystique->dwgreg.cxright && mystique->dwgreg.ydst_lin >= mystique->dwgreg.ytop && mystique->dwgreg.ydst_lin <= mystique->dwgreg.ybot) { pattern_y = ((mystique->dwgreg.funcnt % (mystique->dwgreg.stylelen + 1)) >> 4) & 0x7; pattern_x = (mystique->dwgreg.funcnt % (mystique->dwgreg.stylelen + 1)) & 0xf; - if (!transc || (transc && (mystique->dwgreg.pattern[pattern_y][pattern_x]))) + if (!transc || (mystique->dwgreg.pattern[pattern_y][pattern_x])) switch (mystique->maccess_running & MACCESS_PWIDTH_MASK) { case MACCESS_PWIDTH_8: src = mystique->dwgreg.pattern[pattern_y][pattern_x] ? mystique->dwgreg.fcol : mystique->dwgreg.bcol; @@ -4813,7 +4813,7 @@ blit_trap(mystique_t *mystique) int pattern = mystique->dwgreg.pattern[yoff][xoff]; uint32_t dst; - if (!transc || (transc && pattern)) + if (!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; @@ -4885,7 +4885,7 @@ blit_trap(mystique_t *mystique) uint32_t dst; uint32_t old_dst; - if (!transc || (transc && pattern)) + if (!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]; From ec1271fd5b5687c07319757a144ae84a0816bd00 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 03:34:28 +0100 Subject: [PATCH 35/89] CPU: Fix the Cyrix 6x86 check ijn cpu_set(). --- src/cpu/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index bdd93ec5b..8d00da512 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1550,7 +1550,7 @@ cpu_set(void) if ((cpu_s->cpu_type == CPU_Cx6x86L) || (cpu_s->cpu_type == CPU_Cx6x86MX)) ccr4 = 0x80; - else if (CPU_Cx6x86) + else if (cpu_s->cpu_type == CPU_Cx6x86) CPUID = 0; /* Disabled on powerup by default */ break; From 3ff20c7899c05b74c022cb3ada79866561526d56 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 03:36:21 +0100 Subject: [PATCH 36/89] ISA PnP: Add the missing else in isapnp_enable_card(). --- src/device/isapnp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device/isapnp.c b/src/device/isapnp.c index 3129cd1c8..561367003 100644 --- a/src/device/isapnp.c +++ b/src/device/isapnp.c @@ -1196,7 +1196,7 @@ isapnp_enable_card(void *priv, uint8_t enable) if ((card->enable) && (dev->current_ld_card != NULL) && (dev->current_ld_card != card)) { dev->current_ld = NULL; dev->current_ld_card = NULL; - } if (!card->enable) { + } else if (!card->enable) { if (dev->isolated_card == card) dev->isolated_card = NULL; if ((dev->current_ld_card == card) && (old_enable != ISAPNP_CARD_FORCE_CONFIG)) { From a1c29154aea03871ce56b459588d3c8e446c5e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Gonz=C3=A1lez=20Amestoy?= Date: Sat, 8 Nov 2025 11:57:19 +0100 Subject: [PATCH 37/89] Fix color value in the IBM 8153 palette --- src/video/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/video.c b/src/video/video.c index a999748b7..81fe3a26b 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -612,7 +612,7 @@ cgapal_rebuild_monitor(int monitor_index) palette_lookup[0x15] = 0xffc400c4; palette_lookup[0x16] = 0xffc47e00; palette_lookup[0x17] = 0xffc4c4c4; - palette_lookup[0x18] = 0x0ffe4e4e; + palette_lookup[0x18] = 0xff4e4e4e; palette_lookup[0x19] = 0xff4e4edc; palette_lookup[0x1a] = 0xff4edc4e; palette_lookup[0x1b] = 0xff4ef3f3; From bf1fbd570321aaef6eec8d34d013cd7ca206b955 Mon Sep 17 00:00:00 2001 From: Kotochi <185547947+rushieda@users.noreply.github.com> Date: Sat, 8 Nov 2025 21:27:59 +0300 Subject: [PATCH 38/89] Add the MSI MS-6199VA and fix a mistake with the MS-6318 --- src/include/86box/machine.h | 4 ++ src/machine/m_at_slot1.c | 113 +++++++++++++++++++++++++++++++++++ src/machine/m_at_socket370.c | 6 +- src/machine/machine_table.c | 49 +++++++++++++++ 4 files changed, 169 insertions(+), 3 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 878683217..6834334f3 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1251,6 +1251,10 @@ extern int machine_at_ficka6130_init(const machine_t *); /* VIA Apollo Pro 133 */ extern int machine_at_p3v133_init(const machine_t *); +#ifdef EMU_DEVICE_H +extern const device_t ms6199va_device; +#endif +extern int machine_at_ms6199va_init(const machine_t *); /* VIA Apollo Pro 133A */ extern int machine_at_p3v4x_init(const machine_t *); diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index 0c777c349..e040265e3 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -1399,6 +1399,119 @@ machine_at_p3v133_init(const machine_t *model) return ret; } +static const device_config_t ms6199va_config[] = { + // clang-format off + { + .name = "bios", + .description = "BIOS Version", + .type = CONFIG_BIOS, + .default_string = "ms6199va", + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { + { + .name = "Award Modular BIOS v4.51PG - Revision 3.5", + .internal_name = "ms6199va", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6199va/w6199vms.350", "" } + }, + { + .name = "Award Modular BIOS v4.51PG - Revision 2.0 (Compaq OEM)", + .internal_name = "ms6199va_200", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6199va/W6199VC8.BIN", "" } + }, + { + .name = "Award Modular BIOS v4.51PG - Revision 2.0 (Compaq OEM) [patched for large drives]", + .internal_name = "ms6199va_200p", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6199va/W6199VC8.PCD", "" } + }, + { + .name = "Award Modular BIOS v4.51PG - Revision 3.7 (Packard Bell OEM)", + .internal_name = "ms6199va_370", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6199va/w6199VP2.370", "" } + }, + { .files_no = 0 } + } + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + +const device_t ms6199va_device = { + .name = "MSI MS-6199VA", + .internal_name = "ms6199va_device", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = ms6199va_config +}; + +int +machine_at_ms6199va_init(const machine_t *model) +{ + int ret = 0; + const char *fn; + + /* No ROMs available */ + if (!device_available(model->device)) + return ret; + + device_context(model->device); + fn = device_get_bios_file(machine_get_device(machine), device_get_config_bios("bios"), 0); + ret = bios_load_linear(fn, 0x000c0000, 262144, 0); + device_context_restore(); + + machine_at_common_init_ex(model, 2); + + pci_init(PCI_CONFIG_TYPE_1); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 3, 4); + pci_register_slot(0x0C, PCI_CARD_SOUND, 3, 4, 1, 2); + pci_register_slot(0x0E, PCI_CARD_NORMAL, 1, 2, 3, 4); + pci_register_slot(0x10, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x12, PCI_CARD_NORMAL, 3, 4, 1, 2); + pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 1, 4, 3); + pci_register_slot(0x14, PCI_CARD_NORMAL, 2, 1, 4, 3); + pci_register_slot(0x01, PCI_CARD_AGPBRIDGE, 1, 2, 3, 4); + + device_add(&via_apro133a_device); + device_add(&via_vt82c596b_device); + device_add_params(&w83977_device, (void *) (W83977EF | W83977_AMI | W83977_NO_NVR)); + device_add(&winbond_flash_w29c020_device); + spd_register(SPD_TYPE_SDRAM, 0x7, 512); + device_add(&w83782d_device); /* fans: Chassis, Power, CPU; temperatures: System, CPU, unused */ + hwm_values.temperatures[2] = 0; /* unused */ + + if (sound_card_current[0] == SOUND_INTERNAL) { + device_add(machine_get_snd_device(machine)); + device_add(&w83971d_device); + } + + return ret; +} + /* VIA Apollo Pro 133A */ int machine_at_p3v4x_init(const machine_t *model) diff --git a/src/machine/m_at_socket370.c b/src/machine/m_at_socket370.c index 2beca3eac..dafca0104 100644 --- a/src/machine/m_at_socket370.c +++ b/src/machine/m_at_socket370.c @@ -611,10 +611,10 @@ machine_at_ms6318_init(const machine_t *model) hwm_values.temperatures[1] += 2; /* System offset */ hwm_values.temperatures[2] = 0; /* unused */ - if (sound_card_current[0] == SOUND_INTERNAL) + if (sound_card_current[0] == SOUND_INTERNAL) { device_add(machine_get_snd_device(machine)); - - device_add(&stac9708_device); + device_add(&stac9708_device); + } return ret; } diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 4c782f0aa..e0c3bd3b0 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -18853,6 +18853,8 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + + /* VIA Apollo Pro 133 */ /* Has a Winbond W83977EF Super I/O chip with on-chip KBC with AMIKey-2 KBC firmware. */ { @@ -18898,6 +18900,53 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + /* Has a Winbond W83977EF Super I/O chip with on-chip KBC with AMIKey-2 KBC + firmware. */ + { + .name = "[VIA Apollo Pro 133] MSI MS-6199VA", + .internal_name = "ms6199va", + .type = MACHINE_TYPE_SLOT1, + .chipset = MACHINE_CHIPSET_VIA_APOLLO_PRO_133, + .init = machine_at_ms6199va_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SLOT1, + .block = CPU_BLOCK_NONE, + .min_bus = 66666667, + .max_bus = 150000000, + .min_voltage = 1300, + .max_voltage = 3500, + .min_multi = 1.5, + .max_multi = 8.0 + }, + .bus_flags = MACHINE_PS2_AGP | MACHINE_BUS_USB, + .flags = MACHINE_IDE_DUAL | MACHINE_SOUND | MACHINE_APM | MACHINE_ACPI | MACHINE_USB, + .ram = { + .min = 8192, + .max = 1572864, + .step = 8192 + }, + .nvrmask = 255, + .jumpered_ecp_dma = 0, + .default_jumpered_ecp_dma = -1, + .kbc_device = NULL, + .kbc_params = 0x00000000, + .kbc_p1 = 0x00000cf0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = &ms6199va_device, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = &es1373_onboard_device, + .net_device = NULL + }, + + /* VIA Apollo Pro 133A */ /* Has a Winbond W83977EF Super I/O chip with on-chip KBC with AMIKey-2 KBC firmware. */ { From e9b1d10a547ebd73b6ae0ef90fbce7d88ba0be0b Mon Sep 17 00:00:00 2001 From: Kotochi <185547947+rushieda@users.noreply.github.com> Date: Sat, 8 Nov 2025 21:30:25 +0300 Subject: [PATCH 39/89] Small fix for the MS-6199VA --- src/machine/machine_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index e0c3bd3b0..fb024c2b0 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -18916,7 +18916,7 @@ const machine_t machines[] = { .package = CPU_PKG_SLOT1, .block = CPU_BLOCK_NONE, .min_bus = 66666667, - .max_bus = 150000000, + .max_bus = 155000000, .min_voltage = 1300, .max_voltage = 3500, .min_multi = 1.5, From b17927a64ecf5f157fd13415da3db37c0eaf449d Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 19:42:09 +0100 Subject: [PATCH 40/89] DEC Tulip: Allow broadcast packets once again. --- src/network/net_tulip.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/network/net_tulip.c b/src/network/net_tulip.c index 113af5cd4..7e94332d0 100644 --- a/src/network/net_tulip.c +++ b/src/network/net_tulip.c @@ -463,15 +463,9 @@ tulip_filter_address(TULIPState *s, const uint8_t *addr) } } -/* - Do not block broadcast packets - needed for connections to the guest - to succeed when using SLiRP. - */ -#ifdef BLOCK_BROADCAST if (!memcmp(addr, broadcast, ETH_ALEN)) { return true; } -#endif if (s->csr[6] & (CSR6_PR | CSR6_RA)) { /* Promiscuous mode enabled */ From c06fa6af228d3f31fc1864efd44891545a7557ce Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 8 Nov 2025 19:54:48 +0100 Subject: [PATCH 41/89] DEC Tulip: Fix the compile-breaking mistake. --- src/network/net_tulip.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/network/net_tulip.c b/src/network/net_tulip.c index 7e94332d0..a575a4cfb 100644 --- a/src/network/net_tulip.c +++ b/src/network/net_tulip.c @@ -452,9 +452,7 @@ tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc) static bool tulip_filter_address(TULIPState *s, const uint8_t *addr) { -#ifdef BLOCK_BROADCAST static const char broadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -#endif bool ret = false; for (uint8_t i = 0; i < 16 && ret == false; i++) { From 6237f784f65f14a61a629b1a48691f8bbc21e77b Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sun, 9 Nov 2025 00:02:50 +0500 Subject: [PATCH 42/89] Move `extern`s of onboard RTC `device_t`'s to isartc.h --- src/include/86box/isartc.h | 4 ++++ src/machine/m_xt.c | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/include/86box/isartc.h b/src/include/86box/isartc.h index ef2d7a921..65309c625 100644 --- a/src/include/86box/isartc.h +++ b/src/include/86box/isartc.h @@ -55,6 +55,10 @@ extern int isartc_get_from_internal_name(const char *str); extern const device_t *isartc_get_device(int t); extern int isartc_has_config(int board); +/* On-board RTC devices */ +extern const device_t vendex_xt_rtc_onboard_device; +extern const device_t rtc58167_device; + #ifdef __cplusplus } #endif diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index a5dc921b2..6b5db1e37 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -37,6 +37,7 @@ #include <86box/serial.h> #include <86box/sio.h> #include <86box/ibm_5161.h> +#include <86box/isartc.h> #include <86box/keyboard.h> #include <86box/rom.h> #include <86box/machine.h> @@ -45,9 +46,6 @@ #include <86box/port_6x.h> #include <86box/video.h> -extern const device_t vendex_xt_rtc_onboard_device; -extern const device_t rtc58167_device; - /* 8088 */ static void machine_xt_common_init(const machine_t *model, int fixed_floppy) From db71903db6a4efeef659fa0ae41b8c0e00bfb13b Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sun, 9 Nov 2025 00:17:06 +0500 Subject: [PATCH 43/89] 86box.pot: fix two incorrect source strings --- src/qt/languages/86box.pot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/languages/86box.pot b/src/qt/languages/86box.pot index e5334a13f..e26b444b2 100644 --- a/src/qt/languages/86box.pot +++ b/src/qt/languages/86box.pot @@ -975,10 +975,10 @@ msgstr "" msgid "Thrustmaster FCS + Rudder Control System" msgstr "" -msgid "Thrustmaster Formula T1/T2 with Adaptor" +msgid "Thrustmaster Formula T1/T2 with adapter" msgstr "" -msgid "Thrustmaster Formula T1/T2 without Adaptor" +msgid "Thrustmaster Formula T1/T2 without adapter" msgstr "" msgid "None" From caa0880d598326bb125213b6bb8c30993c8f7fb9 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sun, 9 Nov 2025 00:38:07 +0500 Subject: [PATCH 44/89] PC-500(+)/TO16: Move RTC IRQ number indication to the "Enabled" option --- src/machine/m_xt.c | 14 +++++++------- src/qt/languages/86box.pot | 3 --- src/qt/languages/ru-RU.po | 3 --- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 6b5db1e37..e5906030c 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -1249,7 +1249,7 @@ static const device_config_t pc500_config[] = { .spinner = { 0 }, .selection = { { .description = "Disabled", .value = -1 }, - { .description = "Enabled", .value = 2 }, + { .description = "IRQ 2", .value = 2 }, { .description = "" } }, .bios = { { 0 } } @@ -1369,7 +1369,7 @@ static const device_config_t pc500plus_config[] = { .spinner = { 0 }, .selection = { { .description = "Disabled", .value = -1 }, - { .description = "Enabled", .value = 2 }, + { .description = "IRQ 2", .value = 2 }, { .description = "" } }, .bios = { { 0 } } @@ -1735,15 +1735,15 @@ static const device_config_t to16_config[] = { .spinner = { 0 }, .selection = { { .description = "Not installed", .value = 0 }, - { .description = "RTC0", .value = 0x300 }, - { .description = "RTC1", .value = 0x2c0 }, - { .description = "" } + { .description = "RTC0", .value = 0x300 }, + { .description = "RTC1", .value = 0x2c0 }, + { .description = "" } }, .bios = { { 0 } } }, { .name = "rtc_irq", - .description = "RTC IRQ 2", + .description = "RTC IRQ", .type = CONFIG_SELECTION, .default_string = NULL, .default_int = -1, @@ -1751,7 +1751,7 @@ static const device_config_t to16_config[] = { .spinner = { 0 }, .selection = { { .description = "Disabled", .value = -1 }, - { .description = "Enabled", .value = 2 }, + { .description = "IRQ 2", .value = 2 }, { .description = "" } }, .bios = { { 0 } } diff --git a/src/qt/languages/86box.pot b/src/qt/languages/86box.pot index e26b444b2..910108069 100644 --- a/src/qt/languages/86box.pot +++ b/src/qt/languages/86box.pot @@ -2256,9 +2256,6 @@ msgstr "" msgid "RTC IRQ" msgstr "" -msgid "RTC IRQ 2" -msgstr "" - msgid "RTC Port Address" msgstr "" diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index 7c1755d9e..f0d183b03 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -2256,9 +2256,6 @@ msgstr "DMA WSS" msgid "RTC IRQ" msgstr "IRQ RTC" -msgid "RTC IRQ 2" -msgstr "IRQ 2 RTC" - msgid "RTC Port Address" msgstr "Адрес порта RTC" From 1cf363f1c0e73851a7fd85886f02474bc5d1c639 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sun, 9 Nov 2025 00:38:23 +0500 Subject: [PATCH 45/89] Add new strings to other files --- src/qt/languages/cs-CZ.po | 12 ++++++++++++ src/qt/languages/de-DE.po | 12 ++++++++++++ src/qt/languages/es-ES.po | 12 ++++++++++++ src/qt/languages/fi-FI.po | 12 ++++++++++++ src/qt/languages/fr-FR.po | 12 ++++++++++++ src/qt/languages/hr-HR.po | 12 ++++++++++++ src/qt/languages/it-IT.po | 12 ++++++++++++ src/qt/languages/ja-JP.po | 12 ++++++++++++ src/qt/languages/ko-KR.po | 12 ++++++++++++ src/qt/languages/nb-NO.po | 12 ++++++++++++ src/qt/languages/nl-NL.po | 12 ++++++++++++ src/qt/languages/pl-PL.po | 12 ++++++++++++ src/qt/languages/pt-BR.po | 12 ++++++++++++ src/qt/languages/pt-PT.po | 12 ++++++++++++ src/qt/languages/sk-SK.po | 12 ++++++++++++ src/qt/languages/sl-SI.po | 12 ++++++++++++ src/qt/languages/sv-SE.po | 12 ++++++++++++ src/qt/languages/tr-TR.po | 12 ++++++++++++ src/qt/languages/uk-UA.po | 12 ++++++++++++ src/qt/languages/vi-VN.po | 12 ++++++++++++ src/qt/languages/zh-CN.po | 12 ++++++++++++ src/qt/languages/zh-TW.po | 12 ++++++++++++ 22 files changed, 264 insertions(+) diff --git a/src/qt/languages/cs-CZ.po b/src/qt/languages/cs-CZ.po index 7dd1e5d7a..92443a67f 100644 --- a/src/qt/languages/cs-CZ.po +++ b/src/qt/languages/cs-CZ.po @@ -2253,6 +2253,18 @@ msgstr "IRQ WSS" msgid "WSS DMA" msgstr "DMA kanál WSS" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Povolit OPL" diff --git a/src/qt/languages/de-DE.po b/src/qt/languages/de-DE.po index fef11a6f5..94d330984 100644 --- a/src/qt/languages/de-DE.po +++ b/src/qt/languages/de-DE.po @@ -2253,6 +2253,18 @@ msgstr "WSS-IRQ" msgid "WSS DMA" msgstr "WSS-DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "OPL einschalten" diff --git a/src/qt/languages/es-ES.po b/src/qt/languages/es-ES.po index 6fc268772..6a86432a3 100644 --- a/src/qt/languages/es-ES.po +++ b/src/qt/languages/es-ES.po @@ -2253,6 +2253,18 @@ msgstr "IRQ de WSS" msgid "WSS DMA" msgstr "DMA de WSS" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Habilitar OPL" diff --git a/src/qt/languages/fi-FI.po b/src/qt/languages/fi-FI.po index db85cedb5..78b502a8c 100644 --- a/src/qt/languages/fi-FI.po +++ b/src/qt/languages/fi-FI.po @@ -2253,6 +2253,18 @@ msgstr "WSS-IRQ" msgid "WSS DMA" msgstr "WSS-DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "OPL" diff --git a/src/qt/languages/fr-FR.po b/src/qt/languages/fr-FR.po index 90cfcffda..8f782f6ec 100644 --- a/src/qt/languages/fr-FR.po +++ b/src/qt/languages/fr-FR.po @@ -2253,6 +2253,18 @@ msgstr "IRQ WSS" msgid "WSS DMA" msgstr "DMA WSS" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Activer OPL" diff --git a/src/qt/languages/hr-HR.po b/src/qt/languages/hr-HR.po index 4b100612f..f9807ed51 100644 --- a/src/qt/languages/hr-HR.po +++ b/src/qt/languages/hr-HR.po @@ -2253,6 +2253,18 @@ msgstr "IRQ WSS-a" msgid "WSS DMA" msgstr "DMA WSS-a" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Omogući OPL" diff --git a/src/qt/languages/it-IT.po b/src/qt/languages/it-IT.po index fcefaad62..b32b54782 100644 --- a/src/qt/languages/it-IT.po +++ b/src/qt/languages/it-IT.po @@ -2253,6 +2253,18 @@ msgstr "IRQ WSS" msgid "WSS DMA" msgstr "DMA WSS" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Abilita OPL" diff --git a/src/qt/languages/ja-JP.po b/src/qt/languages/ja-JP.po index 169e4e220..c229db8c0 100644 --- a/src/qt/languages/ja-JP.po +++ b/src/qt/languages/ja-JP.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "OPLを有効にする" diff --git a/src/qt/languages/ko-KR.po b/src/qt/languages/ko-KR.po index 9747390c6..b7d9aaf35 100644 --- a/src/qt/languages/ko-KR.po +++ b/src/qt/languages/ko-KR.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "OPL 사용" diff --git a/src/qt/languages/nb-NO.po b/src/qt/languages/nb-NO.po index 4cb843dd3..3f7e4aa27 100644 --- a/src/qt/languages/nb-NO.po +++ b/src/qt/languages/nb-NO.po @@ -2253,6 +2253,18 @@ msgstr "WSS-IRQ" msgid "WSS DMA" msgstr "WSS-DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Aktiver OPL" diff --git a/src/qt/languages/nl-NL.po b/src/qt/languages/nl-NL.po index e3c5879ec..204e0021d 100644 --- a/src/qt/languages/nl-NL.po +++ b/src/qt/languages/nl-NL.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "OPL inschakelen" diff --git a/src/qt/languages/pl-PL.po b/src/qt/languages/pl-PL.po index 2383a1c1b..295b1f044 100644 --- a/src/qt/languages/pl-PL.po +++ b/src/qt/languages/pl-PL.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Włącz OPL" diff --git a/src/qt/languages/pt-BR.po b/src/qt/languages/pt-BR.po index f7f9dee2e..57fc2972c 100644 --- a/src/qt/languages/pt-BR.po +++ b/src/qt/languages/pt-BR.po @@ -2253,6 +2253,18 @@ msgstr "IRQ WSS" msgid "WSS DMA" msgstr "DMA WSS" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Ativar OPL" diff --git a/src/qt/languages/pt-PT.po b/src/qt/languages/pt-PT.po index 7f2e56d64..66fb7badb 100644 --- a/src/qt/languages/pt-PT.po +++ b/src/qt/languages/pt-PT.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Ativar OPL" diff --git a/src/qt/languages/sk-SK.po b/src/qt/languages/sk-SK.po index f8d53d19c..bab4f6b3c 100644 --- a/src/qt/languages/sk-SK.po +++ b/src/qt/languages/sk-SK.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Povolenie OPL" diff --git a/src/qt/languages/sl-SI.po b/src/qt/languages/sl-SI.po index fcd12d638..a7b433dc8 100644 --- a/src/qt/languages/sl-SI.po +++ b/src/qt/languages/sl-SI.po @@ -2253,6 +2253,18 @@ msgstr "IRQ WSS" msgid "WSS DMA" msgstr "DMA WSS" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Omogoči OPL" diff --git a/src/qt/languages/sv-SE.po b/src/qt/languages/sv-SE.po index ce701efbb..3d1335d47 100644 --- a/src/qt/languages/sv-SE.po +++ b/src/qt/languages/sv-SE.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Aktivera OPL" diff --git a/src/qt/languages/tr-TR.po b/src/qt/languages/tr-TR.po index 8dda1d362..8bf5870c0 100644 --- a/src/qt/languages/tr-TR.po +++ b/src/qt/languages/tr-TR.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "OPL'yi etkinleştir" diff --git a/src/qt/languages/uk-UA.po b/src/qt/languages/uk-UA.po index 1c6017b51..cda5f3741 100644 --- a/src/qt/languages/uk-UA.po +++ b/src/qt/languages/uk-UA.po @@ -2253,6 +2253,18 @@ msgstr "IRQ WSS" msgid "WSS DMA" msgstr "DMA WSS" +msgid "RTC IRQ" +msgstr "IRQ RTC" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Ввімкнути OPL" diff --git a/src/qt/languages/vi-VN.po b/src/qt/languages/vi-VN.po index 7edddb94d..0ee966a2c 100644 --- a/src/qt/languages/vi-VN.po +++ b/src/qt/languages/vi-VN.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "Bật OPL" diff --git a/src/qt/languages/zh-CN.po b/src/qt/languages/zh-CN.po index 58a98fc0c..3db6c0835 100644 --- a/src/qt/languages/zh-CN.po +++ b/src/qt/languages/zh-CN.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "启用 OPL" diff --git a/src/qt/languages/zh-TW.po b/src/qt/languages/zh-TW.po index 69055e9f0..bc4ae604e 100644 --- a/src/qt/languages/zh-TW.po +++ b/src/qt/languages/zh-TW.po @@ -2253,6 +2253,18 @@ msgstr "WSS IRQ" msgid "WSS DMA" msgstr "WSS DMA" +msgid "RTC IRQ" +msgstr "" + +msgid "RTC Port Address" +msgstr "" + +msgid "Onboard RTC" +msgstr "" + +msgid "Not installed" +msgstr "" + msgid "Enable OPL" msgstr "啟用 OPL" From 7960cb4cfe17f7dbf01a4fc8b100c7860d68864b Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 9 Nov 2025 06:22:21 +0100 Subject: [PATCH 46/89] CS8220: Actually update the memory state at initialization, makes the entirety of RAM accessible. --- src/chipset/cs8220.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/chipset/cs8220.c b/src/chipset/cs8220.c index d66ac5246..3050b069a 100644 --- a/src/chipset/cs8220.c +++ b/src/chipset/cs8220.c @@ -252,23 +252,31 @@ cs8220_init(UNUSED(const device_t *info)) break; } - if (dev->ram_banks[0].size > 0x00000000) + mem_set_mem_state(0x00000000, (mem_size << 10) + 0x00060000, MEM_READ_EXTANY | MEM_WRITE_EXTANY); + + if (dev->ram_banks[0].size > 0x00000000) { mem_mapping_add(&dev->ram_banks[0].mapping, dev->ram_banks[0].virt, dev->ram_banks[0].size, cs8220_mem_read, cs8220_mem_readw, NULL, cs8220_mem_write, cs8220_mem_writew, NULL, ram + dev->ram_banks[0].phys, MEM_MAPPING_INTERNAL, &(dev->ram_banks[0])); + mem_set_mem_state(dev->ram_banks[0].virt, dev->ram_banks[0].size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); + } - if (dev->ram_banks[1].size > 0x00000000) + if (dev->ram_banks[1].size > 0x00000000) { mem_mapping_add(&dev->ram_banks[1].mapping, dev->ram_banks[1].virt, dev->ram_banks[1].size, cs8220_mem_read, cs8220_mem_readw, NULL, cs8220_mem_write, cs8220_mem_writew, NULL, ram + dev->ram_banks[1].phys, MEM_MAPPING_INTERNAL, &(dev->ram_banks[1])); + mem_set_mem_state(dev->ram_banks[1].virt, dev->ram_banks[2].size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); + } - if (dev->ram_banks[2].size > 0x00000000) + if (dev->ram_banks[2].size > 0x00000000) { mem_mapping_add(&dev->ram_banks[2].mapping, dev->ram_banks[2].virt, dev->ram_banks[2].size, cs8220_mem_read, cs8220_mem_readw, NULL, cs8220_mem_write, cs8220_mem_writew, NULL, ram + dev->ram_banks[2].phys, MEM_MAPPING_INTERNAL, &(dev->ram_banks[2])); + mem_set_mem_state(dev->ram_banks[2].virt, dev->ram_banks[2].size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); + } io_sethandler(0x00a4, 0x0002, cs8220_in, NULL, NULL, cs8220_out, NULL, NULL, dev); From 39e0fef5de7c86fa53a0071dc54e08344fba258b Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 9 Nov 2025 07:21:05 +0100 Subject: [PATCH 47/89] CS8220: Fix an array index. --- src/chipset/cs8220.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chipset/cs8220.c b/src/chipset/cs8220.c index 3050b069a..18161c90b 100644 --- a/src/chipset/cs8220.c +++ b/src/chipset/cs8220.c @@ -267,7 +267,7 @@ cs8220_init(UNUSED(const device_t *info)) cs8220_mem_read, cs8220_mem_readw, NULL, cs8220_mem_write, cs8220_mem_writew, NULL, ram + dev->ram_banks[1].phys, MEM_MAPPING_INTERNAL, &(dev->ram_banks[1])); - mem_set_mem_state(dev->ram_banks[1].virt, dev->ram_banks[2].size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); + mem_set_mem_state(dev->ram_banks[1].virt, dev->ram_banks[1].size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); } if (dev->ram_banks[2].size > 0x00000000) { From 860739f8bddeda83b01afc07fb3362a35166c5d7 Mon Sep 17 00:00:00 2001 From: WNT50 <173389620+WNT50@users.noreply.github.com> Date: Sun, 9 Nov 2025 17:24:49 +0800 Subject: [PATCH 48/89] Use 512k+512k memory spilt for CS8220 chipset Use 512k base memory for CS8220 chipset if memory larger than 640k, fix some BIOS not recognizing extended memory. --- src/chipset/cs8220.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/chipset/cs8220.c b/src/chipset/cs8220.c index 18161c90b..34229d536 100644 --- a/src/chipset/cs8220.c +++ b/src/chipset/cs8220.c @@ -218,38 +218,28 @@ cs8220_init(UNUSED(const device_t *info)) dev->ram_banks[0].virt = 0x00000000; dev->ram_banks[0].phys = 0x00000000; dev->ram_banks[0].size = 0x00080000; - dev->ram_banks[1].virt = 0x00080000; - dev->ram_banks[1].phys = 0x00080000; - dev->ram_banks[1].size = 0x00020000; - /* Pretend there's a 128k expansion. */ - dev->ram_banks[2].virt = 0x00100000; - dev->ram_banks[2].phys = 0x00080000; - dev->ram_banks[2].size = 0x00020000; - break; - case 896: - dev->ram_banks[0].virt = 0x00000000; - dev->ram_banks[0].phys = 0x00000000; - dev->ram_banks[0].size = 0x00080000; - dev->ram_banks[1].virt = 0x00080000; - dev->ram_banks[1].phys = 0x00080000; - dev->ram_banks[1].size = 0x00020000; /* Pretend there's a 256k expansion. */ dev->ram_banks[2].virt = 0x00100000; dev->ram_banks[2].phys = 0x00080000; dev->ram_banks[2].size = 0x00040000; break; - case 1024: + case 896: dev->ram_banks[0].virt = 0x00000000; dev->ram_banks[0].phys = 0x00000000; dev->ram_banks[0].size = 0x00080000; - dev->ram_banks[1].virt = 0x00080000; - dev->ram_banks[1].phys = 0x00080000; - dev->ram_banks[1].size = 0x00020000; /* Pretend there's a 384k expansion. */ dev->ram_banks[2].virt = 0x00100000; dev->ram_banks[2].phys = 0x00080000; dev->ram_banks[2].size = 0x00060000; break; + case 1024: + dev->ram_banks[0].virt = 0x00000000; + dev->ram_banks[0].phys = 0x00000000; + dev->ram_banks[0].size = 0x00080000; + dev->ram_banks[1].virt = 0x00100000; + dev->ram_banks[1].phys = 0x00080000; + dev->ram_banks[1].size = 0x00080000; + break; } mem_set_mem_state(0x00000000, (mem_size << 10) + 0x00060000, MEM_READ_EXTANY | MEM_WRITE_EXTANY); From 3444080d97443eeb7e002eeb8939a4d9a6e6d61a Mon Sep 17 00:00:00 2001 From: WNT50 <173389620+WNT50@users.noreply.github.com> Date: Mon, 10 Nov 2025 05:29:08 +0800 Subject: [PATCH 49/89] Add base memory backfill for Everex EV-159 Add standard base memory backfill and special CS8220 mode backfill for Everex EV-159 --- src/device/isamem.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/device/isamem.c b/src/device/isamem.c index f89512779..0cd5fddea 100644 --- a/src/device/isamem.c +++ b/src/device/isamem.c @@ -115,6 +115,10 @@ #define RAM_UMAMEM (384 << 10) /* upper memory block */ #define RAM_EXTMEM (1024 << 10) /* start of high memory */ +#define EV159_BASE_MEM (128 << 10) /* size of EV-159 base memory in cs8220 mode*/ +#define EV159_EXT_1536 (1536 << 10) /* start of EV-159 high memory in cs8220 mode*/ +#define EV159_EXT_1024 (1024 << 10) /* start of EV-159 high memory in backfill mode*/ + #define EMS_MAXSIZE (2048 << 10) /* max EMS memory size */ #define EMS_EV159_MAXSIZE (3072 << 10) /* max EMS memory size for EV-159 cards */ #define EMS_LOTECH_MAXSIZE (4096 << 10) /* max EMS memory size for lotech cards */ @@ -635,6 +639,14 @@ isamem_init(const device_t *info) * so check this first. */ t = (addr < RAM_TOPMEM) ? RAM_TOPMEM - addr : 0; + + /* Check for Everex EV-159 cards in CS8220 backfill mode. */ + if ((addr == RAM_TOPMEM) && (dev->board == ISAMEM_EV159_CARD)) { + /* Reserve 128K RAM for base memory. */ + t = EV159_BASE_MEM; + addr -= t; + } + if (t > 0) { /* * We need T bytes to extend that area. @@ -669,6 +681,15 @@ isamem_init(const device_t *info) addr += t; } + /* Assign high memory address for EV-159 in backfill modes. */ + if ((addr == RAM_TOPMEM) && (dev->board == ISAMEM_EV159_CARD)) { + if (dev->start_addr == RAM_TOPMEM) { + addr = EV159_EXT_1536; + } else { + addr = EV159_EXT_1024; + } + } + /* Skip to high memory if needed. */ if ((addr == RAM_TOPMEM) && (tot >= RAM_UMAMEM)) { /* From 70545ec25d502e39ab42b280696eecf7f8e5b3ee Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 11 Nov 2025 00:22:34 +0100 Subject: [PATCH 50/89] Refresh rate and acceleration fixes and cleanups for displays. 1. Some fixes to the S3 refresh rates using the bt48x ramdac as well as 32bpp acceleration (actually pixtrans reads) fixes, which are actually one single dword rather than two words. (This fixes some graphical bugs in 32bpp mode using OS/2 Warp with the Elsa 928 drivers). 2. Add undocumented ports 0x82ec and 0x82ed, needed by the Elsa OS/2 928/805i cards to operate correctly and not getting stuck at a blank screen. 3. Workaround a read select register issue when reading back the accelerated height (0xbee8 index 0x0f bits 3-0 returning a non-height index, in this case, 0x0e) so that the height is not zeroed on writes after the first reads, allowing text and fonts to be displayed on OS/2 Warp 3's built-in S3 864 drivers in every bpp. 4. Don't run the mach8/32 specific clock if we're in plain VGA text mode. 5. Some cleanups to the et4000w32 chip series, including a clock (refresh rate) fix for OS/2's built-in drivers and the extended crtc parameters to be run only on graphics modes. --- src/video/vid_ati_mach8.c | 57 +++++++---- src/video/vid_et4000w32.c | 200 ++++++++++++++++++-------------------- src/video/vid_s3.c | 194 +++++++++++++++++++++++++++--------- 3 files changed, 279 insertions(+), 172 deletions(-) diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index b0642c0de..e57675bb5 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -3322,29 +3322,28 @@ mach_recalctimings(svga_t *svga) if (!svga->scrblank && svga->attr_palette_enable) { mach_log("GDCREG5=%02x, ATTR10=%02x, ATI B0 bit 5=%02x, ON=%d.\n", svga->gdcreg[5] & 0x60, svga->attrregs[0x10] & 0x40, mach->regs[0xb0] & 0x20, dev->on); - if (ATI_MACH32) - svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clock_sel, svga->clock_gen); - else - svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clock_sel ^ 0x08, svga->clock_gen); - - switch ((mach->regs[0xb8] >> 6) & 3) { - case 0: - default: - break; - case 1: - svga->clock *= 2.0; - break; - case 2: - svga->clock *= 3.0; - break; - case 3: - svga->clock *= 4.0; - break; - } mach_log("VGA clock sel=%02x, divide reg=%02x, miscout bits2-3=%x, machregbe bit4=%02x, machregb9 bit1=%02x, charwidth=%d, htotal=%02x, hdisptime=%02x, seqregs1 bit 3=%02x.\n", clock_sel, (mach->regs[0xb8] >> 6) & 3, svga->miscout & 0x0c, mach->regs[0xbe] & 0x10, mach->regs[0xb9] & 0x02, svga->char_width, svga->htotal, svga->hdisp_time, svga->seqregs[1] & 8); if ((svga->gdcreg[6] & 0x01) || (svga->attrregs[0x10] & 0x01)) { if ((svga->gdcreg[5] & 0x40) || (svga->attrregs[0x10] & 0x40) || (mach->regs[0xb0] & 0x20)) { + if (ATI_MACH32) + svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clock_sel, svga->clock_gen); + else + svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clock_sel ^ 0x08, svga->clock_gen); + + switch ((mach->regs[0xb8] >> 6) & 3) { + case 1: + svga->clock *= 2.0; + break; + case 2: + svga->clock *= 3.0; + break; + case 3: + svga->clock *= 4.0; + break; + default: + break; + } svga->map8 = svga->pallook; mach_log("Lowres=%x, seqreg[1]bit3=%x.\n", svga->lowres, svga->seqregs[1] & 8); if (svga->lowres) @@ -3357,6 +3356,26 @@ mach_recalctimings(svga_t *svga) } } } + } else { + if (ATI_MACH32) + svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clock_sel, svga->clock_gen); + else + svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clock_sel ^ 0x08, svga->clock_gen); + + switch ((mach->regs[0xb8] >> 6) & 3) { + case 0: + default: + break; + case 1: + svga->clock *= 2.0; + break; + case 2: + svga->clock *= 3.0; + break; + case 3: + svga->clock *= 4.0; + break; + } } } } diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index c0d802fe4..e7538d6a7 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -93,6 +93,7 @@ typedef struct et4000w32p_t { int index, vlb, pci, interleaved, bank; + int onboard_vid; int vram_size; uint32_t linearbase; uint32_t vram_mask; @@ -513,7 +514,8 @@ et4000w32p_recalctimings(svga_t *svga) svga->memaddr_latch |= (svga->crtc[0x33] & 0x7) << 16; - svga->hblankstart = (((svga->crtc[0x3f] & 0x4) >> 2) << 8) + svga->crtc[2]; + if ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1)) + svga->hblankstart = (((svga->crtc[0x3f] & 0x4) >> 2) << 8) + svga->crtc[2]; if (svga->crtc[0x35] & 0x01) svga->vblankstart |= 0x400; @@ -527,7 +529,7 @@ et4000w32p_recalctimings(svga_t *svga) svga->split |= 0x400; if (svga->crtc[0x3F] & 0x80) svga->rowoffset |= 0x100; - if (svga->crtc[0x3F] & 0x01) + if ((svga->crtc[0x3F] & 0x01) && ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1))) svga->htotal |= 0x100; if (svga->attrregs[0x16] & 0x20) { svga->hdisp <<= 1; @@ -539,30 +541,38 @@ et4000w32p_recalctimings(svga_t *svga) svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clk_sel, svga->clock_gen); if (svga->getclock == ics2494_getclock) { - if (et4000->card_type == HERCULES_DYNAMITE_PRO_VLB) { - if (clk_sel < 2) - svga->clock *= 2.0; - } + if (clk_sel < 2) + svga->clock *= 2.0; } if ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1)) { - if (et4000->card_type != HERCULES_DYNAMITE_PRO_VLB) { + et4000w32_log("Graphics Mode clk_sel=%d, cr35 bit7=%02x, seq7=%02x, clksel=%d, htotal=%03x.\n", clk_sel, svga->crtc[0x35] & 0x80, svga->seqregs[7] & 0x41, clk_sel, svga->htotal); + if (svga->getclock != ics2494_getclock) { if (!(svga->crtc[0x35] & 0x80)) { if (clk_sel >= 2) { if (svga->seqregs[7] & 0x01) svga->clock *= 4.0; else if (svga->seqregs[7] & 0x40) svga->clock *= 2.0; + } else { + if (svga->getclock == sdac_getclock) { + if ((svga->gdcreg[5] & 0x60) >= 0x40) + svga->clock /= 2.0; + } } } } - if (svga->gdcreg[5] & 0x40) { + if ((svga->gdcreg[5] & 0x60) >= 0x40) { if (et4000->rev == ET4000W32) { switch (svga->bpp) { case 8: if ((svga->hdisp == 640) || (svga->hdisp == 800) || (svga->hdisp == 1024)) break; svga->hdisp -= 24; + if (svga->hdisp == 632) + svga->hdisp += 8; + else if (svga->hdisp == 1256) + svga->hdisp += 24; break; default: @@ -572,6 +582,7 @@ et4000w32p_recalctimings(svga_t *svga) switch (svga->bpp) { case 15: case 16: + et4000w32_log("ClkSel=%d, bpp=%d, seq7=%02x, cr35=%02x.\n", clk_sel, svga->bpp, svga->seqregs[7] & 0x41, svga->crtc[0x35] & 0x80); svga->hdisp >>= 1; svga->dots_per_clock >>= 1; if (et4000->rev <= ET4000W32P_REVC) { @@ -604,81 +615,56 @@ et4000w32p_recalctimings(svga_t *svga) default: break; } - //pclog("ClkSel=%d, crtc34 bits 0-1=%02x, crtc31 bits 6-7=%02x, seq7=%02x, interlace=%02x.\n", clk_sel, svga->crtc[0x34] & 0x03, svga->crtc[0x31] & 0xc0, svga->seqregs[7], svga->crtc[0x35] & 0x80); + et4000w32_log("ClkSel=%d, crtc34 bits 0-1=%02x, crtc31 bits 6-7=%02x, seq7=%02x, interlace=%02x.\n", clk_sel, svga->crtc[0x34] & 0x03, svga->crtc[0x31] & 0xc0, svga->seqregs[7], svga->crtc[0x35] & 0x80); } - }//else - // pclog("CLOCK translate=%02x, EGA VGA=%02x, clk=%d.\n", svga->crtc[0x34], svga->seqregs[7] & 0x80, clk_sel); + } else + et4000w32_log("CLOCK text clk=%d, htotal=%03x.\n", clk_sel, svga->htotal); - svga->render = svga_render_blank; if (!svga->scrblank && svga->attr_palette_enable) { - if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /* Text mode */ - if (svga->seqregs[1] & 8) /* 40 column */ - svga->render = svga_render_text_40; - else - svga->render = svga_render_text_80; - } else { - switch (svga->gdcreg[5] & 0x60) { - case 0x00: - if (svga->seqregs[1] & 8) /* Low res (320) */ - svga->render = svga_render_4bpp_lowres; - else - svga->render = svga_render_4bpp_highres; - break; - case 0x20: /* 4 colours */ - if (svga->seqregs[1] & 8) /*Low res (320)*/ - svga->render = svga_render_2bpp_lowres; - else - svga->render = svga_render_2bpp_highres; - break; - case 0x40: - case 0x60: /* 256+ colours */ - //pclog("BPP=%d.\n", svga->bpp); - switch (svga->bpp) { - case 8: - svga->map8 = svga->pallook; - if (svga->lowres) - svga->render = svga_render_8bpp_lowres; - else - svga->render = svga_render_8bpp_highres; - break; - case 15: - if (svga->lowres || (svga->seqregs[1] & 8)) - svga->render = svga_render_15bpp_lowres; - else - svga->render = svga_render_15bpp_highres; - break; - case 16: - if (svga->lowres || (svga->seqregs[1] & 8)) - svga->render = svga_render_16bpp_lowres; - else - svga->render = svga_render_16bpp_highres; - break; - case 17: - if (svga->lowres || (svga->seqregs[1] & 8)) - svga->render = svga_render_15bpp_mix_lowres; - else - svga->render = svga_render_15bpp_mix_highres; - break; - case 24: - if (svga->lowres || (svga->seqregs[1] & 8)) - svga->render = svga_render_24bpp_lowres; - else - svga->render = svga_render_24bpp_highres; - break; - case 32: - if (svga->lowres || (svga->seqregs[1] & 8)) - svga->render = svga_render_32bpp_lowres; - else - svga->render = svga_render_32bpp_highres; - break; + if ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1)) { + if (svga->gdcreg[5] & 0x40) { + switch (svga->bpp) { + case 8: + svga->map8 = svga->pallook; + if (svga->lowres) + svga->render = svga_render_8bpp_lowres; + else + svga->render = svga_render_8bpp_highres; + break; + case 15: + if (svga->lowres || (svga->seqregs[1] & 8)) + svga->render = svga_render_15bpp_lowres; + else + svga->render = svga_render_15bpp_highres; + break; + case 16: + if (svga->lowres || (svga->seqregs[1] & 8)) + svga->render = svga_render_16bpp_lowres; + else + svga->render = svga_render_16bpp_highres; + break; + case 17: + if (svga->lowres || (svga->seqregs[1] & 8)) + svga->render = svga_render_15bpp_mix_lowres; + else + svga->render = svga_render_15bpp_mix_highres; + break; + case 24: + if (svga->lowres || (svga->seqregs[1] & 8)) + svga->render = svga_render_24bpp_lowres; + else + svga->render = svga_render_24bpp_highres; + break; + case 32: + if (svga->lowres || (svga->seqregs[1] & 8)) + svga->render = svga_render_32bpp_lowres; + else + svga->render = svga_render_32bpp_highres; + break; - default: - break; - } - break; - - default: - break; + default: + break; + } } } } @@ -2680,11 +2666,6 @@ et4000w32p_pci_read(UNUSED(int func), int addr, void *priv) { const et4000w32p_t *et4000 = (et4000w32p_t *) priv; - if (func > 0) - return 0xff; - - addr &= 0xff; - switch (addr) { case 0x00: return 0x0c; /* Tseng Labs */ @@ -2722,13 +2703,13 @@ et4000w32p_pci_read(UNUSED(int func), int addr, void *priv) return (et4000->linearbase >> 24); case 0x30: - return et4000->pci_regs[0x30] & 0x01; /* BIOS ROM address */ + return et4000->onboard_vid ? 0x00 : (et4000->pci_regs[0x30] & 0x01); /* BIOS ROM address */ case 0x31: return 0x00; case 0x32: - return et4000->pci_regs[0x32]; + return et4000->onboard_vid ? 0x00 : et4000->pci_regs[0x32]; case 0x33: - return et4000->pci_regs[0x33]; + return et4000->onboard_vid ? 0x00 : et4000->pci_regs[0x33]; default: break; @@ -2743,11 +2724,6 @@ et4000w32p_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv) et4000w32p_t *et4000 = (et4000w32p_t *) priv; svga_t *svga = &et4000->svga; - if (func > 0) - return; - - addr &= 0xff; - switch (addr) { case PCI_REG_COMMAND: et4000->pci_regs[PCI_REG_COMMAND] = (val & 0x23) | 0x80; @@ -2770,6 +2746,9 @@ et4000w32p_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv) case 0x30: case 0x32: case 0x33: + if (et4000->onboard_vid) + return; + et4000->pci_regs[addr] = val; if (et4000->pci_regs[0x30] & 0x01) { uint32_t biosaddr = (et4000->pci_regs[0x32] << 16) | (et4000->pci_regs[0x33] << 24); @@ -2795,6 +2774,9 @@ et4000w32p_init(const device_t *info) et4000->pci = (info->flags & DEVICE_PCI) ? 0x80 : 0x00; et4000->vlb = (info->flags & DEVICE_VLB) ? 0x40 : 0x00; + et4000->card_type = info->local & 0xff; + et4000->onboard_vid = (info->local >> 8) & 0xff; + et4000->vram_size = device_get_config_int("memory"); if (info->flags & DEVICE_PCI) @@ -2813,7 +2795,6 @@ et4000w32p_init(const device_t *info) et4000->vram_mask = (et4000->vram_size << 20) - 1; et4000->svga.decode_mask = (et4000->vram_size << 20) - 1; - et4000->card_type = info->local & 0xff; et4000->ramdac_type = BUILT_IN; et4000->svga.crtc[0x31] = 0x40; et4000->svga.miscout = 0x01; @@ -2823,17 +2804,23 @@ et4000w32p_init(const device_t *info) case MACHSPEED_VGA_GUI_2400S: /* ET4000/W32 */ et4000->rev = ET4000W32; - et4000->ramdac_type = ET4K_SDAC; + if (et4000->onboard_vid) { + et4000->ramdac_type = ATT49X; + et4000->svga.ramdac = device_add(&att490_ramdac_device); + et4000->svga.clock_gen = device_add(&ics2494an_324_device); + et4000->svga.getclock = ics2494_getclock; + } else { + et4000->ramdac_type = ET4K_SDAC; - if (!(info->local & 0x100)) rom_init(&et4000->bios_rom, BIOS_ROM_PATH_W32_MACHSPEED_VGA_GUI_2400S, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - et4000->svga.ramdac = device_add(&tseng_ics5301_ramdac_device); - et4000->svga.clock_gen = et4000->svga.ramdac; - et4000->svga.getclock = sdac_getclock; - sdac_set_ref_clock(et4000->svga.ramdac, 14318184.0f); - svga_recalctimings(&et4000->svga); + et4000->svga.ramdac = device_add(&tseng_ics5301_ramdac_device); + et4000->svga.clock_gen = et4000->svga.ramdac; + et4000->svga.getclock = sdac_getclock; + sdac_set_ref_clock(et4000->svga.ramdac, 14318184.0f); + svga_recalctimings(&et4000->svga); + } break; case AXIS_MICRODEVICE_ET4W32_5: @@ -2940,16 +2927,17 @@ et4000w32p_init(const device_t *info) /*The interleaved VRAM was introduced by the ET4000/W32i*/ et4000->interleaved = ((et4000->vram_size == 2) && (et4000->rev != ET4000W32)) ? 1 : 0; - if (info->flags & DEVICE_PCI) - mem_mapping_disable(&et4000->bios_rom.mapping); - + if (info->flags & DEVICE_PCI) { + if (!et4000->onboard_vid) + mem_mapping_disable(&et4000->bios_rom.mapping); + } mem_mapping_add(&et4000->linear_mapping, 0, 0, svga_read_linear, svga_readw_linear, svga_readl_linear, svga_write_linear, svga_writew_linear, svga_writel_linear, NULL, MEM_MAPPING_EXTERNAL, &et4000->svga); mem_mapping_add(&et4000->mmu_mapping, 0, 0, et4000w32p_mmu_read, NULL, NULL, et4000w32p_mmu_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, et4000); et4000w32p_io_set(et4000); if (info->flags & DEVICE_PCI) - pci_add_card(PCI_ADD_NORMAL, et4000w32p_pci_read, et4000w32p_pci_write, et4000, &et4000->pci_slot); + pci_add_card(et4000->onboard_vid ? PCI_ADD_VIDEO : PCI_ADD_NORMAL, et4000w32p_pci_read, et4000w32p_pci_write, et4000, &et4000->pci_slot); /* Hardwired bits: 00000000 1xx0x0xx */ /* R/W bits: xx xxxx */ @@ -2967,7 +2955,7 @@ et4000w32p_init(const device_t *info) et4000->pci_regs[0x33] = 0xf0; et4000->svga.packed_chain4 = 1; - et4000->svga.adv_flags |= FLAG_PANNING_ATI; + et4000->svga.adv_flags |= FLAG_PANNING_ATI; return et4000; } @@ -3103,7 +3091,7 @@ const device_t et4000w32_onboard_device = { .init = et4000w32p_init, .close = et4000w32p_close, .reset = NULL, - .available = et4000w32_machspeed_vga_gui_2400s_available, + .available = NULL, .speed_changed = et4000w32p_speed_changed, .force_redraw = et4000w32p_force_redraw, .config = et4000w32p_config diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index e03ef71ba..1ffed47cd 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -251,6 +251,7 @@ typedef struct s3_t { uint32_t vram_mask; uint8_t data_available; + uint16_t port_82ec; int card_type; @@ -283,10 +284,13 @@ typedef struct s3_t { uint8_t frgd_mix; uint16_t multifunc_cntl; uint16_t multifunc[16]; + uint16_t height; uint8_t pix_trans[4]; uint8_t pix_trans_val[2048][2048]; int pix_trans_inc; int ssv_state; + int read_sel_reg; + int multifunc_phase; int16_t cx, cy; int16_t px, py; @@ -321,12 +325,6 @@ typedef struct s3_t { int start; int mix_dat_upper; int overflow; - - /*For non-threaded FIFO*/ - int setup_fifo_slot; - int draw_fifo_slot; - int setup_fifo, setup_fifo2; - int draw_fifo, draw_fifo2; } accel; struct { @@ -595,10 +593,11 @@ static void s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3); temp |= (svga->vram[dword_remap(svga, (s3->accel.dest + s3->accel.cx + 1)) & s3->vram_mask] << 8); \ temp |= (svga->vram[dword_remap(svga, (s3->accel.dest + s3->accel.cx + 2)) & s3->vram_mask] << 16); \ temp |= (svga->vram[dword_remap(svga, (s3->accel.dest + s3->accel.cx + 3)) & s3->vram_mask] << 24); \ - } else { \ + } else if ((s3->bpp == 1) || s3->color_16bit) { \ temp = vram_w[dword_remap_w(svga, (s3->accel.dest + s3->accel.cx)) & (s3->vram_mask >> 1)]; \ temp |= (vram_w[dword_remap_w(svga, (s3->accel.dest + s3->accel.cx + 2)) & (s3->vram_mask >> 1)] << 16); \ - } + } else \ + temp = vram_l[dword_remap_w(svga, (s3->accel.dest + s3->accel.cx)) & (s3->vram_mask >> 2)]; static int s3_cpu_src(s3_t *s3) @@ -834,7 +833,6 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) { svga_t *svga = &s3->svga; - s3_log("OUTB FIFO=%04x, val=%02x.\n", port, val); switch (port) { case 0x8148: case 0x82e8: @@ -1358,7 +1356,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) case 0xb148: case 0xb2e8: s3_log("[%04X:%08X] OUT PORTB=%04x, val=%02x, CMD=%04x, C(%d,%d).\n", CS, cpu_state.pc, port, val, s3->accel.cmd, s3->accel.cur_x, s3->accel.cur_y); - if ((s3->accel.multifunc[0xe] & 0x100) || (s3->chip >= S3_VISION964)) { + if ((s3->accel.multifunc[0xe] & 0x100) || (s3->chip >= S3_86C928)) { s3->accel.b2e8_pix = 0; if (s3->bpp == 3) { if ((s3->chip >= S3_86C928) && (s3->chip < S3_VISION964)) { @@ -1400,7 +1398,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) case 0xb149: case 0xb2e9: s3_log("[%04X:%08X] OUT PORTB=%04x, val=%02x, CMD=%04x, C(%d,%d).\n", CS, cpu_state.pc, port, val, s3->accel.cmd, s3->accel.cur_x, s3->accel.cur_y); - if ((s3->accel.multifunc[0xe] & 0x100) || (s3->chip >= S3_VISION964)) { + if ((s3->accel.multifunc[0xe] & 0x100) || (s3->chip >= S3_86C928)) { s3->accel.b2e8_pix = 0; if (s3->bpp == 3) { if ((s3->chip >= S3_86C928) && (s3->chip < S3_VISION964)) { @@ -1554,14 +1552,28 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) case 0xbd48: case 0xbee8: + if ((s3->accel.multifunc_cntl >> 12) == 0x00) { + s3->accel.multifunc_phase = 1; + s3->accel.height = s3->accel.multifunc[0]; + } s3->accel.multifunc_cntl = (s3->accel.multifunc_cntl & 0xff00) | val; break; case 0xbd49: case 0xbee9: - s3->accel.multifunc_cntl = (s3->accel.multifunc_cntl & 0xff) | (val << 8); - s3->accel.multifunc[s3->accel.multifunc_cntl >> 12] = s3->accel.multifunc_cntl & 0xfff; - if ((s3->accel.multifunc_cntl >> 12) == 5) - s3_log("S3 multifunc_cntl = %d, val = %03x.\n", s3->accel.multifunc_cntl >> 12, s3->accel.multifunc_cntl & 0xfff); + s3->accel.multifunc_cntl = (s3->accel.multifunc_cntl & 0xff) | (val << 8); + if ((val >> 4) == 0x0f) { + s3->accel.read_sel_reg = s3->accel.multifunc_cntl & 0xfff; + s3_log("[%04X:%08X] OUT PORTB=%04x, val=%x, multifunc idx=%x, multifunc_val=%03x.\n", CS, cpu_state.pc, port - 1, val >> 4, s3->accel.multifunc_cntl >> 12, s3->accel.multifunc_cntl & 0xfff); + } else { + s3->accel.multifunc[s3->accel.multifunc_cntl >> 12] = s3->accel.multifunc_cntl & 0xfff; + if (s3->accel.multifunc_phase == 2) { + if (s3->accel.height != s3->accel.multifunc[0]) + s3->accel.multifunc[0] = s3->accel.height; + + s3->accel.multifunc_phase = 0; + } + s3_log("[%04X:%08X] OUT PORTB=%04x, val=%x, multifunc idx=%x, multifunc_val=%03x.\n", CS, cpu_state.pc, port - 1, val >> 4, s3->accel.multifunc_cntl >> 12, s3->accel.multifunc_cntl & 0xfff); + } break; case 0xd148: @@ -1708,7 +1720,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) if (s3->accel.cmd & 0x100) { switch (s3->accel.cmd & 0x600) { case 0x000: - if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { + if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 0x02)) { if (((s3->accel.frgd_mix & 0x60) != 0x40) || ((s3->accel.bkgd_mix & 0x60) != 0x40)) s3->accel_start(8, 1, s3->accel.pix_trans[0], 0, s3); else @@ -2869,6 +2881,7 @@ static void s3_io_remove(s3_t *s3) { io_removehandler(0x03c0, 0x0020, s3_in, NULL, NULL, s3_out, NULL, NULL, s3); + io_removehandler(0x82ec, 0x0002, s3_in, NULL, NULL, s3_out, NULL, NULL, s3); io_removehandler(0x42e8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); io_removehandler(0x46e8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); @@ -2911,12 +2924,11 @@ s3_io_set_alt(s3_t *s3) if (!s3->translate) return; - if ((s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (svga->seqregs[9] & 0x80)) { + if ((s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (svga->seqregs[9] & 0x80)) return; - } io_sethandler(0x4148, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); - io_sethandler(0x4548, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); + io_sethandler(0x46e8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); io_sethandler(0x4948, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); if (s3->chip == S3_TRIO64 || s3->chip >= S3_TRIO64V || s3->chip == S3_VISION968 || s3->chip == S3_VISION868) { io_sethandler(0x8148, 0x0004, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); @@ -2971,6 +2983,7 @@ s3_io_set(s3_t *s3) return; } + io_sethandler(0x82ec, 0x0002, s3_in, NULL, NULL, s3_out, NULL, NULL, s3); io_sethandler(0x42e8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); io_sethandler(0x46e8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); io_sethandler(0x4ae8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); @@ -3030,6 +3043,8 @@ s3_out(uint16_t addr, uint8_t val, void *priv) if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; + s3_log("%04X:%08X: %03X: s3_out: val=%02x.\n", CS, cpu_state.pc, addr, val); + switch (addr) { case 0x3c2: if (svga->getclock == icd2061_getclock) { @@ -3164,6 +3179,7 @@ s3_out(uint16_t addr, uint8_t val, void *priv) case 0x40: s3->enable_8514 = val & 0x01; + s3_log("Enable 8514/A functions=%02x.\n", val & 0x01); break; case 0x50: @@ -3338,6 +3354,7 @@ s3_out(uint16_t addr, uint8_t val, void *priv) s3_io_remove_alt(s3); s3->translate = !!(val & 0x10); + s3_log("Translate=%02x.\n", s3->translate); s3_io_set_alt(s3); } break; @@ -3387,6 +3404,12 @@ s3_out(uint16_t addr, uint8_t val, void *priv) } break; + case 0x82ec: + s3->port_82ec = (s3->port_82ec & 0xff00) | val; + break; + case 0x82ed: + s3->port_82ec = (s3->port_82ec & 0xff) | (val << 8); + break; default: break; } @@ -3401,10 +3424,13 @@ s3_in(uint16_t addr, void *priv) int rs2; int rs3; uint8_t temp; + uint8_t temp2; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; + s3_log("%04X:%08X: %03X: s3_in.\n", CS, cpu_state.pc, addr); + switch (addr) { case 0x3c1: if (svga->attraddr > 0x14) @@ -3414,7 +3440,8 @@ s3_in(uint16_t addr, void *priv) case 0x3c2: if (s3->elsa_eeprom) { temp = nmc93cxx_eeprom_read(s3->eeprom) ? 0x10 : 0x00; - return (svga_in(addr, svga) & 0xef) | temp; + temp2 = (svga_in(addr, svga) & 0xef) | temp; + return temp2; } if (s3->chip <= S3_86C924) return svga_in(addr, svga) | 0x10; @@ -3484,6 +3511,7 @@ s3_in(uint16_t addr, void *priv) case 0x3d4: return svga->crtcreg; case 0x3d5: + s3_log("%04X:%08X: s3_in: crtc=%02x.\n", CS, cpu_state.pc, svga->crtcreg); switch (svga->crtcreg) { case 0x2d: return (s3->chip == S3_TRIO64V2) ? 0x89 : 0x88; /*Extended chip ID*/ @@ -3553,6 +3581,11 @@ s3_in(uint16_t addr, void *priv) } return svga->crtc[svga->crtcreg]; + case 0x82ec: + return s3->port_82ec & 0xff; + case 0x82ed: + return s3->port_82ec >> 8; + default: break; } @@ -3865,9 +3898,9 @@ s3_recalctimings(svga_t *svga) if (enhanced_8bpp_modes) { s3_log("BPP=%d, pitch=%d, width=%02x, double?=%x, 16bit?=%d, highres?=%d, " - "attr=%02x, hdisp=%d, dotsperclock=%x, clksel=%x, clockmultiplier=%d, multiplexingrate=%d, xadd=%d, overscanx=%d.\n", svga->bpp, s3->width, svga->crtc[0x50], + "attr=%02x, hdisp=%d, dotsperclock=%x, clksel=%x, clockmultiplier=%d, multiplexingrate=%d, mapenable=%x.\n", svga->bpp, s3->width, svga->crtc[0x50], svga->crtc[0x31] & 0x02, s3->color_16bit, s3->accel.advfunc_cntl & 0x04, - svga->attrregs[0x10] & 0x40, svga->hdisp, svga->dots_per_clock, clk_sel, svga->clock_multiplier, svga->multiplexing_rate, svga->x_add, svga->monitor->mon_overscan_x); + svga->attrregs[0x10] & 0x40, svga->hdisp, svga->dots_per_clock, clk_sel, svga->clock_multiplier, svga->multiplexing_rate, svga->mapping.enable); switch (svga->bpp) { case 8: svga->render = svga_render_8bpp_highres; @@ -3883,14 +3916,21 @@ s3_recalctimings(svga_t *svga) if (svga->clock_multiplier == 1) { svga->hdisp <<= 2; svga->dots_per_clock <<= 2; + svga->clock *= 2.0; + } else { + if (clk_sel > 2) { + svga->hdisp <<= 2; + svga->dots_per_clock <<= 2; + svga->clock *= 4.0; + } } } else { if (!svga->clock_multiplier) { svga->hdisp <<= 1; svga->dots_per_clock <<= 1; + svga->clock *= 2.0; } } - svga->clock *= 2.0; } else { if (svga->multiplexing_rate == 0) { svga->hdisp <<= 1; @@ -4899,7 +4939,7 @@ s3_updatemapping(s3_t *s3) /*Banked framebuffer*/ if (svga->crtc[0x31] & 0x08) /*Enhanced mode mappings*/ { - s3_log("Enhanced Mode Mapping.\n"); + s3_log("Enhanced Mode Mapping, gdc6=%02x.\n", svga->gdcreg[6] & 0xc); /* Enhanced mode forces 64kb at 0xa0000*/ mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x10000); svga->banked_mask = 0xffff; @@ -4937,6 +4977,7 @@ s3_updatemapping(s3_t *s3) if (s3->chip >= S3_86C928) { s3->linear_base = (svga->crtc[0x5a] << 16) | (svga->crtc[0x59] << 24); + s3_log("Initial linear base=%08x, crtc58=%02x, crtc53=%02x.\n", s3->linear_base, svga->crtc[0x58], svga->crtc[0x53]); if (s3->chip <= S3_86C805I) { if (s3->vlb) s3->linear_base &= 0x03ffffff; @@ -4977,11 +5018,13 @@ s3_updatemapping(s3_t *s3) break; } s3->linear_base &= ~(s3->linear_size - 1); + s3_log("First LinearBase update=%x, size=%x, mmio1=%02x, mmio2=%02x, mapenable=%x.\n", s3->linear_base, s3->linear_size, svga->crtc[0x53] & 0x10, s3->accel.advfunc_cntl & 0x20, svga->mapping.enable); if ((s3->linear_base == 0xa0000) || (s3->linear_size == 0x10000)) { mem_mapping_disable(&s3->linear_mapping); if (!(svga->crtc[0x53] & 0x10)) { mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x10000); svga->banked_mask = 0xffff; + s3_log("Actually enable banked mapping=%d.\n", svga->mapping.enable); } } else { if (s3->chip >= S3_TRIO64V) @@ -4989,7 +5032,7 @@ s3_updatemapping(s3_t *s3) else if ((s3->chip == S3_VISION968) || (s3->chip == S3_VISION868)) s3->linear_base &= 0xfe000000; - s3_log("LinearBase update=%x, size=%x.\n", s3->linear_base, s3->linear_size); + s3_log("Update LinearBase update=%x, size=%x.\n", s3->linear_base, s3->linear_size); if (s3->linear_base) mem_mapping_set_addr(&s3->linear_mapping, s3->linear_base, s3->linear_size); else @@ -5055,6 +5098,8 @@ s3_accel_out(uint16_t port, uint8_t val, void *priv) s3_t *s3 = (s3_t *) priv; svga_t *svga = &s3->svga; + s3_log("%04X:%08X: OUTB FIFO=%04x, val=%02x.\n", CS, cpu_state.pc, port, val); + if (port >= 0x8000) { if (!s3->enable_8514) return; @@ -5076,9 +5121,11 @@ s3_accel_out(uint16_t port, uint8_t val, void *priv) s3->accel.subsys_cntl = (s3->accel.subsys_cntl & 0xff) | (val << 8); s3_update_irqs(s3); break; - case 0x4548: case 0x46e8: - s3->accel.setup_md = val; + s3->accel.setup_md = (s3->accel.setup_md & 0xff00) | val; + break; + case 0x46e9: + s3->accel.setup_md = (s3->accel.setup_md & 0xff) | (val << 8); break; case 0x4948: case 0x4ae8: @@ -5104,6 +5151,8 @@ s3_accel_out_w(uint16_t port, uint16_t val, void *priv) { s3_t *s3 = (s3_t *) priv; + s3_log("%04X:%08X: OUTW FIFO=%04x, val=%04x.\n", CS, cpu_state.pc, port, val); + if (!s3->enable_8514) return; @@ -5118,6 +5167,8 @@ s3_accel_out_l(uint16_t port, uint32_t val, void *priv) { s3_t *s3 = (s3_t *) priv; + s3_log("%04X:%08X: OUTL FIFO=%04x, val=%08x.\n", CS, cpu_state.pc, port, val); + if (!s3->enable_8514) return; @@ -5135,6 +5186,8 @@ s3_accel_in(uint16_t port, void *priv) int temp; uint8_t temp2 = 0x00; + s3_log("%04X:%08X: INB=%04x.\n", CS, cpu_state.pc, port); + if (!s3->enable_8514) return 0xff; @@ -5146,6 +5199,13 @@ s3_accel_in(uint16_t port, void *priv) case 0x42e9: return s3->accel.subsys_cntl >> 8; + case 0x4948: + case 0x4ae8: + return s3->accel.advfunc_cntl; + case 0x4949: + case 0x4ae9: + return 0x00; + case 0x8148: case 0x82e8: if (s3_enable_fifo(s3)) @@ -5686,9 +5746,20 @@ s3_accel_in(uint16_t port, void *priv) if (s3->chip >= S3_86C928) { if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); - if ((s3->bpp == 3) && (s3->accel.multifunc[0xe] & 0x10) && !(s3->accel.multifunc[0xe] & 0x200)) - temp2 = s3->accel.color_cmp >> 16; - else + + if (s3->bpp == 3) { + if (s3->chip < S3_VISION964) { + if (s3->accel.multifunc[0xe] & 0x10) + temp2 = s3->accel.color_cmp >> 16; + else + temp2 = s3->accel.color_cmp & 0xff; + } else { + if ((s3->accel.multifunc[0xe] & 0x10) && !(s3->accel.multifunc[0xe] & 0x200)) + temp2 = s3->accel.color_cmp >> 16; + else + temp2 = s3->accel.color_cmp & 0xff; + } + } else temp2 = s3->accel.color_cmp & 0xff; return temp2; @@ -5699,13 +5770,34 @@ s3_accel_in(uint16_t port, void *priv) if (s3->chip >= S3_86C928) { if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); - if ((s3->bpp == 3) && (s3->accel.multifunc[0xe] & 0x10) && !(s3->accel.multifunc[0xe] & 0x200)) - temp2 = s3->accel.color_cmp >> 24; - else + + if (s3->bpp == 3) { + if (s3->chip < S3_VISION964) { + if (s3->accel.multifunc[0xe] & 0x10) + temp2 = s3->accel.color_cmp >> 24; + else + temp2 = s3->accel.color_cmp >> 8; + + s3->accel.multifunc[0xe] ^= 0x10; + } else { + if ((s3->accel.multifunc[0xe] & 0x10) && !(s3->accel.multifunc[0xe] & 0x200)) + temp2 = s3->accel.color_cmp >> 24; + else + temp2 = s3->accel.color_cmp >> 8; + + if (!(s3->accel.multifunc[0xe] & 0x200)) + s3->accel.multifunc[0xe] ^= 0x10; + } + } else { temp2 = s3->accel.color_cmp >> 8; - if (!(s3->accel.multifunc[0xe] & 0x200)) - s3->accel.multifunc[0xe] ^= 0x10; + if (s3->chip < S3_VISION964) + s3->accel.multifunc[0xe] ^= 0x10; + else { + if (!(s3->accel.multifunc[0xe] & 0x200)) + s3->accel.multifunc[0xe] ^= 0x10; + } + } return temp2; } break; @@ -5756,7 +5848,11 @@ s3_accel_in(uint16_t port, void *priv) if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); if (s3->chip >= S3_VISION964) { - temp = s3->accel.multifunc[0xf] & 0xf; + temp = s3->accel.read_sel_reg & 0xf; + s3_log("964 and up: ReadSelReg=%x.\n", temp); + if (s3->accel.multifunc_phase == 1) + s3->accel.multifunc_phase = 2; + switch (temp) { case 0x0: return s3->accel.multifunc[0x0] & 0xff; @@ -5785,7 +5881,7 @@ s3_accel_in(uint16_t port, void *priv) break; } } else { - temp = s3->accel.multifunc[0xf] & 7; + temp = s3->accel.read_sel_reg & 7; switch (temp) { case 0x0: return s3->accel.multifunc[0x0] & 0xff; @@ -5817,8 +5913,8 @@ s3_accel_in(uint16_t port, void *priv) if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); if (s3->chip >= S3_VISION964) { - temp = s3->accel.multifunc[0xf] & 0xf; - s3->accel.multifunc[0xf] = (s3->accel.multifunc[0xf] + 1) & 0xf; + temp = s3->accel.read_sel_reg & 0xf; + s3->accel.read_sel_reg = (s3->accel.read_sel_reg + 1) & 0xf; switch (temp) { case 0x0: return s3->accel.multifunc[0x0] >> 8; @@ -5835,11 +5931,11 @@ s3_accel_in(uint16_t port, void *priv) case 0x6: return s3->accel.multifunc[0xe] >> 8; case 0x7: - return s3->accel.cmd >> 8; + return (s3->accel.cmd >> 8) & ~0xf0; case 0x8: - return (s3->accel.subsys_cntl >> 8) & ~0xe000; + return (s3->accel.subsys_cntl >> 8) & ~0xe0; case 0x9: - return (s3->accel.setup_md >> 8) & ~0xf000; + return s3->accel.setup_md >> 8; case 0xa: return s3->accel.multifunc[0xd] >> 8; @@ -5847,8 +5943,8 @@ s3_accel_in(uint16_t port, void *priv) break; } } else { - temp = s3->accel.multifunc[0xf] & 7; - s3->accel.multifunc[0xf] = (s3->accel.multifunc[0xf] + 1) & 7; + temp = s3->accel.read_sel_reg & 7; + s3->accel.read_sel_reg = (s3->accel.read_sel_reg + 1) & 7; switch (temp) { case 0x0: return s3->accel.multifunc[0x0] >> 8; @@ -5865,7 +5961,7 @@ s3_accel_in(uint16_t port, void *priv) case 0x6: return s3->accel.multifunc[0xe] >> 8; case 0x7: - return s3->accel.cmd >> 8; + return (s3->accel.cmd >> 8) & ~0xf0; default: break; @@ -6207,6 +6303,7 @@ s3_accel_in_w(uint16_t port, void *priv) if (s3_cpu_dest(s3)) { READ_PIXTRANS_WORD + s3_log("PIXTRANS WORD READ=%04x.\n", s3->accel.cmd); switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 0x02)) { @@ -6286,6 +6383,7 @@ s3_accel_in_l(UNUSED(uint16_t port), void *priv) svga_t *svga = &s3->svga; uint32_t temp = 0x00000000; const uint16_t *vram_w = (uint16_t *) svga->vram; + const uint32_t *vram_l = (uint32_t *) svga->vram; if (!s3->enable_8514) return 0xffffffff; @@ -6293,6 +6391,7 @@ s3_accel_in_l(UNUSED(uint16_t port), void *priv) if (s3_cpu_dest(s3)) { READ_PIXTRANS_LONG + s3_log("PIXTRANS LONG READ=%04x.\n", s3->accel.cmd); switch (s3->accel.cmd & 0x600) { case 0x000: if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { @@ -6707,6 +6806,7 @@ s3_accel_read_l(uint32_t addr, void *priv) svga_t *svga = &s3->svga; uint32_t temp = 0x00000000; const uint16_t *vram_w = (uint16_t *) svga->vram; + const uint32_t *vram_l = (uint32_t *) svga->vram; if (!s3->enable_8514) return 0xffffffff; @@ -8291,7 +8391,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, voi /*Bit 4 of the Command register is the draw yes bit, which enables writing to memory/reading from memory when enabled. When this bit is disabled, no writing to memory/reading from memory is allowed. (This bit is almost meaningless on the NOP command)*/ - s3_log("CMD=%d, full=%04x, cnt=%d, s3bpp=%x, clr=%d, clb=%d, sourcedisplay=%02x, mmio=%02x, srcbase=%08x, dstbase=%08x, cpu=%08x, mix=%08x, count=%d, rd_mask=%08x, wrt_mask=%08x, width=%d, s=%d,%d, c=%d,%d, d=%d,%d, 16bitcolor=%x, frgdcolor=%08x, bkgdcolor=%08x, frgdsel=%d, bkgdsel=%d, frgdmix=%02x, curx=%d, cury=%d, cll=%d, b2e8pix=%x.\n", cmd, s3->accel.cmd, count, s3->bpp, clip_r, clip_b, s3->accel.multifunc[0x0a] & 0xc4, svga->crtc[0x53] & 0x18, srcbase, dstbase, cpu_dat & 0xffffffff, mix_dat & 0xffffffff, count, rd_mask, wrt_mask, s3->width, s3->accel.sx, s3->accel.sy, s3->accel.cx, s3->accel.cy, s3->accel.destx_distp, s3->accel.desty_axstp, s3->color_16bit, frgd_color, bkgd_color, frgd_mix, bkgd_mix, s3->accel.frgd_mix & 0x0f, s3->accel.cur_x, s3->accel.cur_y, clip_l, s3->accel.b2e8_pix); + s3_log("CMD=%d, full=%04x, cnt=%d, s3bpp=%x, clr=%d, clb=%d, sourcedisplay=%02x, mmio=%02x, srcbase=%08x, dstbase=%08x, cpu=%08x, mix=%08x, count=%d, rd_mask=%08x, wrt_mask=%08x, width=%d, s=%d,%d, c=%d,%d, d=%d,%d, 16bitcolor=%x, frgdcolor=%08x, bkgdcolor=%08x, frgdsel=%d, bkgdsel=%d, frgdmix=%02x, curx=%d, cury=%d, cll=%d, b2e8pix=%x, multifuncE=%03x.\n", cmd, s3->accel.cmd, count, s3->bpp, clip_r, clip_b, s3->accel.multifunc[0x0a] & 0xc4, svga->crtc[0x53] & 0x18, srcbase, dstbase, cpu_dat & 0xffffffff, mix_dat & 0xffffffff, count, rd_mask, wrt_mask, s3->width, s3->accel.sx, s3->accel.sy, s3->accel.cx, s3->accel.cy, s3->accel.destx_distp, s3->accel.desty_axstp, s3->color_16bit, frgd_color, bkgd_color, frgd_mix, bkgd_mix, s3->accel.frgd_mix & 0x0f, s3->accel.cur_x, s3->accel.cur_y, clip_l, s3->accel.b2e8_pix, s3->accel.multifunc[0xe]); switch (cmd) { case 0: /*NOP (Short Stroke Vectors)*/ @@ -9225,7 +9325,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, voi } } } - break; + return; } while (count-- && (s3->accel.sy >= 0)) { From 55d804c4930fbbc27488121330a92f30e38e2c21 Mon Sep 17 00:00:00 2001 From: win2kgamer <47463859+win2kgamer@users.noreply.github.com> Date: Mon, 10 Nov 2025 20:00:39 -0600 Subject: [PATCH 51/89] Aztech: Make WSS Config bit 6 changes set/clear the WSS IRQ based on its value This behavior satisfies all tested AZT1605/Clinton and AZT2316/Washington drivers allowing the device config "Raise CODEC interrupt" checkbox to be removed --- src/sound/snd_azt2316a.c | 44 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/src/sound/snd_azt2316a.c b/src/sound/snd_azt2316a.c index 226adad15..1b8eb14d0 100644 --- a/src/sound/snd_azt2316a.c +++ b/src/sound/snd_azt2316a.c @@ -189,7 +189,6 @@ static uint16_t azt2316a_wss_addr[4] = {0x530, 0x604, 0xe80, 0xf40}; typedef struct azt2316a_t { int type; - int wss_interrupt_after_config; uint8_t wss_config; @@ -248,13 +247,13 @@ azt2316a_wss_write(uint16_t addr, uint8_t val, void *priv) { azt2316a_t *azt2316a = (azt2316a_t *) priv; int interrupt = 0; + uint8_t oldconfig = azt2316a->wss_config; aztech_log(azt2316a->log, "Aztech WSS: [W] (%04X) = %02X\n", addr, val); - if (azt2316a->wss_interrupt_after_config) { - if ((azt2316a->wss_config & 0x40) && !(val & 0x40)) { // TODO: is this the right edge? - interrupt = 1; - } + if ((oldconfig & 0x40) != (val & 0x40)) { + aztech_log(azt2316a->log, "Aztech WSS: Config IRQ bit changed\n"); + interrupt = 1; } azt2316a->wss_config = val; @@ -263,8 +262,15 @@ azt2316a_wss_write(uint16_t addr, uint8_t val, void *priv) ad1848_setdma(&azt2316a->ad1848, azt2316a_wss_dma[val & 3]); ad1848_setirq(&azt2316a->ad1848, azt2316a_wss_irq[(val >> 3) & 7]); - if (interrupt) - picint(1 << azt2316a->cur_wss_irq); + if (interrupt) { + if (azt2316a->wss_config & 0x40) { + aztech_log(azt2316a->log, "Aztech WSS: Firing config change IRQ\n"); + picint(1 << azt2316a->cur_wss_irq); + } else { + aztech_log(azt2316a->log, "Aztech WSS: Clearing config change IRQ\n"); + picintc(1 << azt2316a->cur_wss_irq); + } + } } /* generate a config word based on current settings */ @@ -1316,8 +1322,6 @@ azt_init(const device_t *info) if (addr_setting) azt2316a->cur_addr = addr_setting; - azt2316a->wss_interrupt_after_config = device_get_config_int("wss_interrupt_after_config"); - /* wss part */ ad1848_init(&azt2316a->ad1848, device_get_config_int("codec")); if (azt2316a->type == SB_SUBTYPE_CLONE_AZT2316A_0X11) @@ -1476,17 +1480,6 @@ static const device_config_t azt1605_config[] = { }, .bios = { { 0 } } }, - { - .name = "wss_interrupt_after_config", - .description = "Raise CODEC interrupt on CODEC setup (needed by some drivers)", - .type = CONFIG_BINARY, - .default_string = NULL, - .default_int = 0, - .file_filter = NULL, - .spinner = { 0 }, - .selection = { { 0 } }, - .bios = { { 0 } } - }, { .name = "addr", .description = "SB Address", @@ -1605,17 +1598,6 @@ static const device_config_t azt2316a_config[] = { }, .bios = { { 0 } } }, - { - .name = "wss_interrupt_after_config", - .description = "Raise CODEC interrupt on CODEC setup (needed by some drivers)", - .type = CONFIG_BINARY, - .default_string = NULL, - .default_int = 0, - .file_filter = NULL, - .spinner = { 0 }, - .selection = { { 0 } }, - .bios = { { 0 } } - }, { .name = "addr", .description = "SB Address", From 02fac15d31352633f159ff6c3c72e17d90e2ca62 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 11 Nov 2025 16:48:41 +0100 Subject: [PATCH 52/89] Render stack: Add checks adjusted width and height in addition to unadjusted, mitigates crashes. --- src/qt/qt_rendererstack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 85a0bb096..a65f056b6 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -464,7 +464,7 @@ RendererStack::createRenderer(Renderer renderer) void RendererStack::blit(int x, int y, int w, int h) { - if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (switchInProgress) || (monitors[m_monitor_index].target_buffer == NULL) || imagebufs.empty() || std::get(imagebufs[currentBuf])->test_and_set()) { + if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || ((w + y) > 2048) || ((h + x) > 2048) || (switchInProgress) || (monitors[m_monitor_index].target_buffer == NULL) || imagebufs.empty() || std::get(imagebufs[currentBuf])->test_and_set()) { video_blit_complete_monitor(m_monitor_index); return; } From 0181fd29f1274368b6d46b8c3ee25f5f440e8592 Mon Sep 17 00:00:00 2001 From: Kotochi <185547947+rushieda@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:00:25 +0300 Subject: [PATCH 53/89] Add the Samsung CAIRO-5 machine --- src/include/86box/machine.h | 1 + src/machine/m_at_socket370.c | 31 +++++++++++++++++++++++++ src/machine/machine_table.c | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 6834334f3..0ba5b6f9c 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1316,6 +1316,7 @@ extern int machine_at_cuv4xls_init(const machine_t *); extern const device_t ms6318_device; #endif extern int machine_at_ms6318_init(const machine_t *); +extern int machine_at_cairo5_init(const machine_t *); /* m_at_misc.c */ extern int machine_at_vpc2007_init(const machine_t *); diff --git a/src/machine/m_at_socket370.c b/src/machine/m_at_socket370.c index dafca0104..ee75752db 100644 --- a/src/machine/m_at_socket370.c +++ b/src/machine/m_at_socket370.c @@ -618,3 +618,34 @@ machine_at_ms6318_init(const machine_t *model) return ret; } + +int +machine_at_cairo5_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear("roms/machines/cairo5/08BV.BIN", + 0x000c0000, 262144, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init_ex(model, 2); + + pci_init(PCI_CONFIG_TYPE_1); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); + pci_register_slot(0x0E, PCI_CARD_NORMAL, 1, 2, 3, 0); + pci_register_slot(0x0F, PCI_CARD_NORMAL, 2, 3, 0, 1); + pci_register_slot(0x10, PCI_CARD_NORMAL, 3, 0, 1, 2); + pci_register_slot(0x11, PCI_CARD_NORMAL, 0, 1, 2, 3); + pci_register_slot(0x12, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x01, PCI_CARD_AGPBRIDGE, 1, 2, 3, 4); + + device_add(&via_apro133a_device); + device_add(&via_vt82c686b_device); + device_add(&winbond_flash_w29c020_device); + spd_register(SPD_TYPE_SDRAM, 0x7, 1024); + + return ret; +} \ No newline at end of file diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index fb024c2b0..a60acfdc8 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -19915,6 +19915,51 @@ const machine_t machines[] = { .snd_device = &ct5880_onboard_device, .net_device = NULL }, + /* Has the VIA VT82C686B southbridge with on-chip KBC identical to the VIA + VT82C42N. */ + { + .name = "[VIA Apollo Pro 133A] Samsung CAIRO-5 (MSI MS-6309)", + .internal_name = "cairo5", + .type = MACHINE_TYPE_SOCKET370, + .chipset = MACHINE_CHIPSET_VIA_APOLLO_PRO_133A, + .init = machine_at_cairo5_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET370, + .block = CPU_BLOCK_NONE, + .min_bus = 66666667, + .max_bus = 150000000, + .min_voltage = 1300, + .max_voltage = 3500, + .min_multi = MACHINE_MULTIPLIER_FIXED, + .max_multi = MACHINE_MULTIPLIER_FIXED + }, + .bus_flags = MACHINE_PS2_A97 | MACHINE_BUS_USB, + .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_ACPI | MACHINE_USB, + .ram = { + .min = 16384, + .max = 3145728, + .step = 8192 + }, + .nvrmask = 255, + .jumpered_ecp_dma = 0, + .default_jumpered_ecp_dma = -1, + .kbc_device = NULL, + .kbc_params = 0x00000000, + .kbc_p1 = 0x00000cf0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = NULL, + .net_device = NULL + }, /* Miscellaneous/Fake/Hypervisor machines */ /* Has a Winbond W83977F Super I/O chip with on-chip KBC with AMIKey-2 KBC From c6c8385486cdef0ec80fadb61e5507ce93b2f24f Mon Sep 17 00:00:00 2001 From: MaxwellS04 Date: Fri, 14 Nov 2025 16:55:28 +0700 Subject: [PATCH 54/89] Added ErgoPro e368 BIOS for MS-6147 Also correct RM BIOS name for AX6BC --- src/machine/m_at_slot1.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index e040265e3..c85c20711 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -594,7 +594,7 @@ static const device_config_t ax6bc_config[] = { .files = { "roms/machines/ax6bc/ax6bc110.bin", "" } }, { - .name = "RM Accelerator 350P2XB/450P3XB (BIOS R2.20)", + .name = "Award Modular BIOS v4.60PGMA - Revision R2.20 (RM Accelerator 350P2XB/450P3XB)", .internal_name = "ax6bc_rm", .bios_type = BIOS_NORMAL, .files_no = 1, @@ -603,7 +603,7 @@ static const device_config_t ax6bc_config[] = { .files = { "roms/machines/ax6bc/ax6bc220.bin", "" } }, { - .name = "Award Modular BIOS v4.60PGM - Revision R2.59", + .name = "Award Modular BIOS v4.60PGMA - Revision R2.59", .internal_name = "ax6bc", .bios_type = BIOS_NORMAL, .files_no = 1, @@ -886,6 +886,15 @@ static const device_config_t ms6147_config[] = { .spinner = { 0 }, .selection = { { 0 } }, .bios = { + { + .name = "Award Modular BIOS v4.51PG - Revision 1.2 (Fujitsu ErgoPro e368)", + .internal_name = "ergopro_e368", + .bios_type = BIOS_NORMAL, + .files_no = 1, + .local = 0, + .size = 262144, + .files = { "roms/machines/ms6147/W647F412.BIN", "" } + }, { .name = "Award Modular BIOS v4.51PG - Revision 1.8", .internal_name = "ms6147", From 2d3958b0fe4f5d3cfe31e53534e8428abb3d3449 Mon Sep 17 00:00:00 2001 From: mw308 <34479591+mw308@users.noreply.github.com> Date: Fri, 14 Nov 2025 12:27:32 +0000 Subject: [PATCH 55/89] Changed BIOS label to match others --- src/machine/m_at_slot1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index e040265e3..55e80fe2b 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -594,7 +594,7 @@ static const device_config_t ax6bc_config[] = { .files = { "roms/machines/ax6bc/ax6bc110.bin", "" } }, { - .name = "RM Accelerator 350P2XB/450P3XB (BIOS R2.20)", + .name = "RM Accelerator 350P2XB/450P3XB - Revision R2.20", .internal_name = "ax6bc_rm", .bios_type = BIOS_NORMAL, .files_no = 1, From 363960fc240c065a88a4490d2e1a4ecf99238458 Mon Sep 17 00:00:00 2001 From: mw308 <34479591+mw308@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:03:24 +0000 Subject: [PATCH 56/89] Add the Toshiba XM-6102B --- src/include/86box/cdrom.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/cdrom.h b/src/include/86box/cdrom.h index 5a6c0914d..3fadfeb42 100644 --- a/src/include/86box/cdrom.h +++ b/src/include/86box/cdrom.h @@ -183,6 +183,7 @@ static const struct cdrom_drive_types_s { { "TEAC", "CD-532E", "2.0A", "teac_532e", BUS_TYPE_IDE, 0, 32, 36, 0, 0, { 3, 2, 2, -1 } }, { "TOSHIBA", "CD-ROM XM-5302TA", "0305", "toshiba_5302ta", BUS_TYPE_IDE, 0, 4, 96, 0, 0, { 0, -1, -1, -1 } }, { "TOSHIBA", "CD-ROM XM-5702B", "TA70", "toshiba_5702b", BUS_TYPE_IDE, 0, 12, 96, 0, 0, { 3, 2, 1, -1 } }, + { "TOSHIBA", "CD-ROM XM-6102B", "WA70", "toshiba_6102b", BUS_TYPE_IDE, 0, 24, 96, 0, 0, { 4, 2, 2, -1 } }, { "TOSHIBA", "CD-ROM XM-6202B", "1512", "toshiba_6202b", BUS_TYPE_IDE, 0, 32, 96, 0, 0, { 4, 2, 2, -1 } }, { "TOSHIBA", "CD-ROM XM-6402B", "1008", "toshiba_6402b", BUS_TYPE_IDE, 0, 32, 96, 0, 0, { 4, 2, 2, 2 } }, { "TOSHIBA", "CD-ROM XM-6702B", "1007", "toshiba_6720b", BUS_TYPE_IDE, 0, 48, 96, 0, 0, { 4, 2, 2, 2 } }, From b1b9583e2ecb2a82e546dc00e9075436d3619e37 Mon Sep 17 00:00:00 2001 From: mw308 <34479591+mw308@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:11:16 +0000 Subject: [PATCH 57/89] Corrected again the name --- src/machine/m_at_slot1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index 55e80fe2b..8016e3291 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -594,7 +594,7 @@ static const device_config_t ax6bc_config[] = { .files = { "roms/machines/ax6bc/ax6bc110.bin", "" } }, { - .name = "RM Accelerator 350P2XB/450P3XB - Revision R2.20", + .name = "Award Modular BIOS v4.60PGMA - Revision R2.20 (RM Accelerator 350P2XB/450P3XB)", .internal_name = "ax6bc_rm", .bios_type = BIOS_NORMAL, .files_no = 1, @@ -603,7 +603,7 @@ static const device_config_t ax6bc_config[] = { .files = { "roms/machines/ax6bc/ax6bc220.bin", "" } }, { - .name = "Award Modular BIOS v4.60PGM - Revision R2.59", + .name = "Award Modular BIOS v4.60PGMA - Revision R2.59", .internal_name = "ax6bc", .bios_type = BIOS_NORMAL, .files_no = 1, From d81146d0eb9fa3c203fe65f3891591a39d6727c5 Mon Sep 17 00:00:00 2001 From: MaxwellS04 Date: Fri, 14 Nov 2025 21:27:49 +0700 Subject: [PATCH 58/89] Revert BIOS label names for AX6BC This avoids conflicts with a recently pull request. --- src/machine/m_at_slot1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index c85c20711..4f8f50b88 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -594,7 +594,7 @@ static const device_config_t ax6bc_config[] = { .files = { "roms/machines/ax6bc/ax6bc110.bin", "" } }, { - .name = "Award Modular BIOS v4.60PGMA - Revision R2.20 (RM Accelerator 350P2XB/450P3XB)", + .name = "RM Accelerator 350P2XB/450P3XB (BIOS R2.20)", .internal_name = "ax6bc_rm", .bios_type = BIOS_NORMAL, .files_no = 1, @@ -603,7 +603,7 @@ static const device_config_t ax6bc_config[] = { .files = { "roms/machines/ax6bc/ax6bc220.bin", "" } }, { - .name = "Award Modular BIOS v4.60PGMA - Revision R2.59", + .name = "Award Modular BIOS v4.60PGM - Revision R2.59", .internal_name = "ax6bc", .bios_type = BIOS_NORMAL, .files_no = 1, From 571855319e4a12f10deb667e14647ddab67b5018 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 14 Nov 2025 21:40:42 -0300 Subject: [PATCH 59/89] Switch Windows builds to UCRT --- .ci/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/build.sh b/.ci/build.sh index e18aa4837..fb360b826 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -338,7 +338,8 @@ strip_binary=strip if is_windows then # Switch into the correct MSYSTEM if required. - msys=MINGW$arch + msys=UCRT$arch + [ ! -d "/$msys" ] && msys=MINGW$arch [ ! -d "/$msys" ] && msys=CLANG$arch if [ -d "/$msys" ] then From b36b0c4ea008bd6cf8b69b97b6e5be8955fed428 Mon Sep 17 00:00:00 2001 From: win2kgamer <47463859+win2kgamer@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:17:19 -0600 Subject: [PATCH 60/89] Add the HP Pavilion 50x0/70xx (Morrison32) --- src/include/86box/machine.h | 1 + src/machine/m_at_socket5.c | 73 +++++++++++++++++++++++++++++++++++++ src/machine/machine_table.c | 46 +++++++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 0ba5b6f9c..4003ce81e 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -926,6 +926,7 @@ extern int machine_at_optiplexgxl_init(const machine_t *); extern const device_t pt2000_device; #endif extern int machine_at_pt2000_init(const machine_t *); +extern int machine_at_morrison32_init(const machine_t *); extern int machine_at_pc330_65x6_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t zappa_device; diff --git a/src/machine/m_at_socket5.c b/src/machine/m_at_socket5.c index 50a28a9c8..a049600e3 100644 --- a/src/machine/m_at_socket5.c +++ b/src/machine/m_at_socket5.c @@ -427,6 +427,79 @@ machine_at_optiplexgxl_init(const machine_t *model) return ret; } + +static void +machine_at_morrison32_gpio_init(void) +{ + uint32_t gpio = 0xffffe2ff; + + /* Register 0x0079: */ + /* Bit 7: 0 = Clear password, 1 = Keep password. */ + /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ + /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ + /* Bit 4: External CPU clock (Switch 8). */ + /* Bit 3: External CPU clock (Switch 7). */ + /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ + /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ + /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ + /* Bit 2: 0 = No onboard audio, 1 = Onboard audio present. */ + /* Bit 1: 0 = Soft Off capable power supply, 1 = Standard power supply. */ + /* Bit 0: 2x multiplier, 1 = 1.5x multiplier (Switch 6). */ + /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ + if (cpu_busspeed <= 50000000) + gpio |= 0xffff00ff; + else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) + gpio |= 0xffff08ff; + else if (cpu_busspeed > 60000000) + gpio |= 0xffff10ff; + + if (cpu_dmulti <= 1.5) + gpio |= 0xffff01ff; + else + gpio |= 0xffff00ff; + + if (sound_card_current[0] == SOUND_INTERNAL) + gpio |= 0xffff04ff; + + machine_set_gpio_default(gpio); +} + +int +machine_at_morrison32_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear_combined("roms/machines/morrison32/1011BT0L.BIO", + "roms/machines/morrison32/1011BT0L.BI1", + 0x20000, 128); + + if (bios_only || !ret) + return ret; + + machine_at_common_init_ex(model, 2); + machine_at_morrison32_gpio_init(); + + pci_init(PCI_CONFIG_TYPE_1); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x08, PCI_CARD_VIDEO, 4, 0, 0, 0); + pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 2, 3, 4); + pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + + if (sound_card_current[0] == SOUND_INTERNAL) + machine_snd = device_add(machine_get_snd_device(machine)); + + device_add(&i430fx_device); + device_add(&piix_device); + device_add_params(&pc87306_device, (void *) PCX730X_AMI); + device_add(&intel_flash_bxt_ami_device); + + return ret; +} + /* Some stuff taken from Monaco */ static void machine_at_morrison64_gpio_init(void) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index a60acfdc8..98ec1cc7e 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -12474,6 +12474,52 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the + PC87306 Super I/O chip, command 0xA1 returns '5'. + Command 0xA0 copyright string: (C)1994 AMI . */ + { + .name = "[i430FX] HP Pavilion 50x0/70xx (Morrison32)", + .internal_name = "morrison32", + .type = MACHINE_TYPE_SOCKET5, + .chipset = MACHINE_CHIPSET_INTEL_430FX, + .init = machine_at_morrison32_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET5_7, + .block = CPU_BLOCK(CPU_K5, CPU_5K86, CPU_Cx6x86), + .min_bus = 50000000, + .max_bus = 66666667, + .min_voltage = 3380, + .max_voltage = 3520, + .min_multi = 1.5, + .max_multi = 2.0 + }, + .bus_flags = MACHINE_PS2_PCI, + .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_SOUND | MACHINE_GAMEPORT | MACHINE_APM, + .ram = { + .min = 8192, + .max = 131072, + .step = 8192 + }, + .nvrmask = 255, + .jumpered_ecp_dma = MACHINE_DMA_DISABLED | MACHINE_DMA_1 | MACHINE_DMA_3, + .default_jumpered_ecp_dma = 3, + .kbc_device = NULL, + .kbc_params = 0x00000000, + .kbc_p1 = 0x000044f0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = &s3_phoenix_trio32_onboard_pci_device, + .snd_device = &cs4232_onboard_device, + .net_device = NULL + }, { .name = "[i430FX] IBM PC 3x0 (type 65x6) (Morrison64)", .internal_name = "pc330_65x6", From 4a2b0753aa995181b8bb7e78870eb75d2b07b5d1 Mon Sep 17 00:00:00 2001 From: win2kgamer <47463859+win2kgamer@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:30:34 -0600 Subject: [PATCH 61/89] Add the HP Pavilion 51xx/7070/7090/71xx (Holly) --- src/include/86box/machine.h | 1 + src/machine/m_at_socket7_3v.c | 71 +++++++++++++++++++++++++++++++++++ src/machine/machine_table.c | 56 ++++++++++++++++++++++++--- 3 files changed, 123 insertions(+), 5 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 4003ce81e..d4ba99f51 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -971,6 +971,7 @@ extern const device_t p54tp4xe_device; #endif extern int machine_at_p54tp4xe_init(const machine_t *); extern int machine_at_exp8551_init(const machine_t *); +extern int machine_at_hpholly_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t vectra52_device; #endif diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index 28c75bacb..b85025cc9 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -157,6 +157,77 @@ machine_at_exp8551_init(const machine_t *model) return ret; } +static void +machine_at_hpholly_gpio_init(void) +{ + uint32_t gpio = 0xffffe2ff; + + /* Register 0x0079: */ + /* Bit 7: 0 = Clear password, 1 = Keep password. */ + /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ + /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ + /* Bit 4: External CPU clock (Switch 8). */ + /* Bit 3: External CPU clock (Switch 7). */ + /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ + /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ + /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ + /* Bit 2: 0 = 2.5x multiplier, 1 = 1.5x/2x multiplier. */ + /* Bit 1: 0 = Soft Off capable power supply, 1 = Standard power supply. */ + /* Bit 0: 2x multiplier, 1 = 1.5x multiplier (Switch 6). */ + /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ + if (cpu_busspeed <= 50000000) + gpio |= 0xffff00ff; + else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) + gpio |= 0xffff08ff; + else if (cpu_busspeed > 60000000) + gpio |= 0xffff10ff; + + if (cpu_dmulti <= 1.5) + gpio |= 0xffff0500; + else if ((cpu_dmulti > 1.5) && (cpu_dmulti <= 2.0)) + gpio |= 0xffff0400; + else + gpio |= 0xffff0000; + + machine_set_gpio_default(gpio); +} + +int +machine_at_hpholly_init(const machine_t *model) /* HP Pavilion Holly, 7070/7090/5100/7100 */ +{ + int ret; + + ret = bios_load_linear_combined("roms/machines/hpholly/1005CA2L.BIO", + "roms/machines/hpholly/1005CA2L.BI1", + 0x20000, 128); + + if (bios_only || !ret) + return ret; + + machine_at_common_init_ex(model, 2); + machine_at_hpholly_gpio_init(); + + pci_init(PCI_CONFIG_TYPE_1); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x08, PCI_CARD_VIDEO, 4, 0, 0, 0); + pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 2, 3, 4); + pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + + if (sound_card_current[0] == SOUND_INTERNAL) + machine_snd = device_add(machine_get_snd_device(machine)); + + device_add(&i430fx_device); + device_add(&piix_device); + device_add_params(&pc87306_device, (void *) PCX730X_AMI); + device_add(&intel_flash_bxt_ami_device); + + return ret; +} + static void machine_at_vectra52_gpio_init(void) { diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 98ec1cc7e..3d66fa9fc 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -13422,7 +13422,53 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, - { + /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the + PC87306 Super I/O chip, command 0xA1 returns '5'. + Command 0xA0 copyright string: (C)1994 AMI . */ + { + .name = "[i430FX] HP Pavilion 51xx/7070/7090/71xx (Holly)", + .internal_name = "hpholly", + .type = MACHINE_TYPE_SOCKET7_3V, + .chipset = MACHINE_CHIPSET_INTEL_430FX, + .init = machine_at_hpholly_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET5_7, + .block = CPU_BLOCK(CPU_K5, CPU_5K86, CPU_Cx6x86), + .min_bus = 50000000, + .max_bus = 66666667, + .min_voltage = 3380, + .max_voltage = 3520, + .min_multi = 1.5, + .max_multi = 2.5 + }, + .bus_flags = MACHINE_PS2_PCI, + .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_SOUND | MACHINE_GAMEPORT | MACHINE_APM, + .ram = { + .min = 8192, + .max = 131072, + .step = 8192 + }, + .nvrmask = 255, + .jumpered_ecp_dma = MACHINE_DMA_DISABLED | MACHINE_DMA_1 | MACHINE_DMA_3, + .default_jumpered_ecp_dma = 3, + .kbc_device = NULL, + .kbc_params = 0x00000000, + .kbc_p1 = 0x000044f0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = &s3_phoenix_trio64vplus_onboard_pci_device, + .snd_device = &cs4232_onboard_device, + .net_device = NULL + }, + { .name = "[i430FX] HP Vectra 500 Series xxx/MT", .internal_name = "vectra500mt", .type = MACHINE_TYPE_SOCKET7_3V, @@ -13450,7 +13496,7 @@ const machine_t machines[] = { .step = 8192 }, .nvrmask = 511, - .jumpered_ecp_dma = 0, + .jumpered_ecp_dma = 0, .default_jumpered_ecp_dma = -1, .kbc_device = NULL, .kbc_params = 0x00000000, @@ -13458,7 +13504,7 @@ const machine_t machines[] = { .gpio = 0xffffffff, .gpio_acpi = 0xffffffff, .device = NULL, - .kbd_device = NULL, + .kbd_device = NULL, .fdc_device = NULL, .sio_device = NULL, .vid_device = &s3_phoenix_trio64_onboard_pci_device, @@ -13493,7 +13539,7 @@ const machine_t machines[] = { .step = 8192 }, .nvrmask = 255, - .jumpered_ecp_dma = 0, + .jumpered_ecp_dma = 0, .default_jumpered_ecp_dma = -1, .kbc_device = NULL, .kbc_params = 0x00000000, @@ -13501,7 +13547,7 @@ const machine_t machines[] = { .gpio = 0xffffffff, .gpio_acpi = 0xffffffff, .device = &vectra52_device, - .kbd_device = NULL, + .kbd_device = NULL, .fdc_device = NULL, .sio_device = NULL, .vid_device = &gd5436_onboard_pci_device, From c9e0a3c942c2f2d8847f086e86eb241e3c5fd440 Mon Sep 17 00:00:00 2001 From: win2kgamer <47463859+win2kgamer@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:37:41 -0600 Subject: [PATCH 62/89] Add the HP Pavilion 72xx (Ruby) --- src/include/86box/machine.h | 1 + src/machine/m_at_socket7_3v.c | 67 +++++++++++++++++++++++++++++++++++ src/machine/machine_table.c | 46 ++++++++++++++++++++++++ 3 files changed, 114 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index d4ba99f51..1dc5fecbd 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1006,6 +1006,7 @@ extern int machine_at_fmb_init(const machine_t *); extern int machine_at_acerv35n_init(const machine_t *); extern int machine_at_ap53_init(const machine_t *); extern int machine_at_8500tuc_init(const machine_t *); +extern int machine_at_hpruby_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t d943_device; #endif diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index b85025cc9..d14e529a9 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -1229,6 +1229,73 @@ machine_at_8500tuc_init(const machine_t *model) return ret; } +static void +machine_at_ruby_gpio_init(void) +{ + uint32_t gpio = 0xffffe3ff; + + /* Register 0x0079: */ + /* Bit 7: 0 = Clear password, 1 = Keep password. */ + /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ + /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ + /* Bit 4: External CPU clock (Switch 8). */ + /* Bit 3: External CPU clock (Switch 7). */ + /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ + /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ + /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ + /* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */ + /* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */ + /* Bit 0: 0 = Reserved. */ + /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ + if (cpu_busspeed <= 50000000) + gpio |= 0xffff10ff; + else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) + gpio |= 0xffff18ff; + else if (cpu_busspeed > 60000000) + gpio |= 0xffff00ff; + + if (sound_card_current[0] == SOUND_INTERNAL) + gpio |= 0xffff04ff; + + machine_set_gpio_default(gpio); +} + +int +machine_at_hpruby_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear_combined("roms/machines/hpruby/1007DC0L.BIO", + "roms/machines/hpruby/1007DC0L.BI1", + 0x20000, 128); + + if (bios_only || !ret) + return ret; + + machine_at_common_init_ex(model, 2); + machine_at_ruby_gpio_init(); + + pci_init(PCI_CONFIG_TYPE_1); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x08, PCI_CARD_VIDEO, 4, 0, 0, 0); + pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 3, 2, 4); + pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 1, 3, 4); + pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + + if (sound_card_current[0] == SOUND_INTERNAL) + machine_snd = device_add(machine_get_snd_device(machine)); + + device_add(&i430hx_device); + device_add(&piix3_device); + device_add_params(&pc87306_device, (void *) PCX730X_AMI); + device_add(&intel_flash_bxt_ami_device); + + return ret; +} + static const device_config_t d943_config[] = { // clang-format off { diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 3d66fa9fc..0b8aacbd4 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14096,6 +14096,52 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the + PC87306 Super I/O chip, command 0xA1 returns '5'. + Command 0xA0 copyright string: (C)1994 AMI . */ + { + .name = "[i430HX] HP Pavilion 72xx (Ruby)", + .internal_name = "hpruby", + .type = MACHINE_TYPE_SOCKET7_3V, + .chipset = MACHINE_CHIPSET_INTEL_430HX, + .init = machine_at_hpruby_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET5_7, + .block = CPU_BLOCK(CPU_K5, CPU_5K86, CPU_Cx6x86), + .min_bus = 50000000, + .max_bus = 66666667, + .min_voltage = 3380, + .max_voltage = 3520, + .min_multi = 1.5, + .max_multi = 3.0 + }, + .bus_flags = MACHINE_PS2_PCI, + .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_SOUND | MACHINE_GAMEPORT | MACHINE_APM, + .ram = { + .min = 8192, + .max = 131072, + .step = 8192 + }, + .nvrmask = 255, + .jumpered_ecp_dma = MACHINE_DMA_DISABLED | MACHINE_DMA_1 | MACHINE_DMA_3, + .default_jumpered_ecp_dma = 3, + .kbc_device = NULL, + .kbc_params = 0x00000000, + .kbc_p1 = 0x000044f0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = &s3_virge_325_onboard_pci_device, + .snd_device = &ymf701_device, + .net_device = NULL + }, /* It possible has AMIKEY-2 'H' KBC firmware. */ { .name = "[i430HX] Siemens-Nixdorf D943", From 8324650f14270426cc85f4daa653dd37ac61d6ea Mon Sep 17 00:00:00 2001 From: win2kgamer <47463859+win2kgamer@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:42:27 -0600 Subject: [PATCH 63/89] Add the HP Pavilion 73xx/74xx (Ruby USB) --- src/include/86box/machine.h | 1 + src/machine/m_at_socket7.c | 71 +++++++++++++++++++++++++++++++++++++ src/machine/machine_table.c | 46 ++++++++++++++++++++++++ 3 files changed, 118 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 1dc5fecbd..08f060849 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1044,6 +1044,7 @@ extern int machine_at_p55t2p4_init(const machine_t *); extern void machine_at_p65up5_common_init(const machine_t *, const device_t *northbridge); #endif extern int machine_at_p65up5_cp55t2d_init(const machine_t *); +extern int machine_at_rubyusb_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t cu430hx_device; #endif diff --git a/src/machine/m_at_socket7.c b/src/machine/m_at_socket7.c index e185632af..4715e72eb 100644 --- a/src/machine/m_at_socket7.c +++ b/src/machine/m_at_socket7.c @@ -143,6 +143,77 @@ machine_at_p65up5_cp55t2d_init(const machine_t *model) return ret; } +static void +machine_at_rubyusb_gpio_init(void) +{ + uint32_t gpio = 0xffffe3ff; + + /* Register 0x0079: */ + /* Bit 7: 0 = Clear password, 1 = Keep password. */ + /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ + /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ + /* Bit 4: External CPU clock (Switch 8). */ + /* Bit 3: External CPU clock (Switch 7). */ + /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ + /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ + /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ + /* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */ + /* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */ + /* Bit 0: 0 = Reserved. */ + /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ + if (cpu_busspeed <= 50000000) + gpio |= 0xffff10ff; + else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) + gpio |= 0xffff18ff; + else if (cpu_busspeed > 60000000) + gpio |= 0xffff00ff; + + if (sound_card_current[0] == SOUND_INTERNAL) + gpio |= 0xffff04ff; + + machine_set_gpio_default(gpio); +} + +int +machine_at_rubyusb_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear_combined2("roms/machines/rubyusb/1005DL0L.BIO", + "roms/machines/rubyusb/1005DL0L.BI1", + "roms/machines/rubyusb/1005DL0L.BI2", + "roms/machines/rubyusb/1005DL0L.BI3", + "roms/machines/rubyusb/1005DL0L.RCV", + /*NULL,*/ + 0x3a000, 128); + + if (bios_only || !ret) + return ret; + + machine_at_common_init_ex(model, 2); + machine_at_rubyusb_gpio_init(); + + pci_init(PCI_CONFIG_TYPE_1); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x08, PCI_CARD_VIDEO, 4, 0, 0, 0); + pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 2, 3, 4); + pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + + if (sound_card_current[0] == SOUND_INTERNAL) + machine_snd = device_add(machine_get_snd_device(machine)); + + device_add(&i430hx_device); + device_add(&piix3_device); + device_add_params(&pc87306_device, (void *) PCX730X_AMI); + device_add(&intel_flash_bxt_ami_device); + + return ret; +} + static const device_config_t cu430hx_config[] = { // clang-format off { diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 0b8aacbd4..3328adf31 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14774,6 +14774,52 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the + PC87306 Super I/O chip, command 0xA1 returns '5'. + Command 0xA0 copyright string: (C)1994 AMI . */ + { + .name = "[i430HX] HP Pavilion 73xx/74xx (Ruby USB)", + .internal_name = "rubyusb", + .type = MACHINE_TYPE_SOCKET7, + .chipset = MACHINE_CHIPSET_INTEL_430HX, + .init = machine_at_rubyusb_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET5_7, + .block = CPU_BLOCK(CPU_K5, CPU_5K86, CPU_Cx6x86), + .min_bus = 50000000, + .max_bus = 66666667, + .min_voltage = 2800, + .max_voltage = 3520, + .min_multi = 1.5, + .max_multi = 3.0 + }, + .bus_flags = MACHINE_PS2_PCI | MACHINE_BUS_USB, + .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_SOUND | MACHINE_GAMEPORT | MACHINE_APM | MACHINE_USB, + .ram = { + .min = 8192, + .max = 131072, + .step = 8192 + }, + .nvrmask = 255, + .jumpered_ecp_dma = MACHINE_DMA_DISABLED | MACHINE_DMA_1 | MACHINE_DMA_3, + .default_jumpered_ecp_dma = 3, + .kbc_device = NULL, + .kbc_params = 0x00000000, + .kbc_p1 = 0x000044f0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = &s3_virge_325_onboard_pci_device, + .snd_device = &ymf701_device, + .net_device = NULL + }, /* OEM-only Intel CU430HX, has AMI MegaKey KBC firmware on the PC87306 Super I/O chip. */ { .name = "[i430HX] Intel CU430HX (Cumberland)", From 64b1406318ca0f40984749719e3ac855a74cf896 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sat, 15 Nov 2025 12:42:09 +0500 Subject: [PATCH 64/89] workflows: Switch Windows builds to UCRT --- .github/workflows/cmake_windows_msys2.yml | 20 ++++++++++---------- .github/workflows/codeql_windows_msys2.yml | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/cmake_windows_msys2.yml b/.github/workflows/cmake_windows_msys2.yml index 8959395eb..986d63a0b 100644 --- a/.github/workflows/cmake_windows_msys2.yml +++ b/.github/workflows/cmake_windows_msys2.yml @@ -69,21 +69,21 @@ jobs: # - msystem: MSYS # toolchain: ./cmake/flags-gcc-x86_64.cmake # slug: "-MSYS64" - - msystem: MINGW64 - prefix: mingw-w64-x86_64 - toolchain: ./cmake/flags-gcc-x86_64.cmake - slug: "-64" - runner: windows-2022 +# - msystem: MINGW64 +# prefix: mingw-w64-x86_64 +# toolchain: ./cmake/flags-gcc-x86_64.cmake +# slug: "MINGW64" +# runner: windows-2022 # - msystem: CLANG64 # prefix: mingw-w64-clang-x86_64 # toolchain: ./cmake/llvm-win32-x86_64.cmake # slug: "CLANG64" # runner: windows-2022 -# - msystem: UCRT64 -# prefix: mingw-w64-ucrt-x86_64 -# toolchain: ./cmake/flags-gcc-x86_64.cmake -# slug: "UCRT64" -# runner: windows-2022 + - msystem: UCRT64 + prefix: mingw-w64-ucrt-x86_64 + toolchain: ./cmake/flags-gcc-x86_64.cmake + slug: "-64" + runner: windows-2022 - msystem: CLANGARM64 toolchain: ./cmake/flags-gcc-aarch64.cmake slug: -arm64 diff --git a/.github/workflows/codeql_windows_msys2.yml b/.github/workflows/codeql_windows_msys2.yml index 9673ab650..2982c2734 100644 --- a/.github/workflows/codeql_windows_msys2.yml +++ b/.github/workflows/codeql_windows_msys2.yml @@ -83,21 +83,21 @@ jobs: # - msystem: MSYS # toolchain: ./cmake/flags-gcc-x86_64.cmake # slug: "-MSYS64" - - msystem: MINGW64 - prefix: mingw-w64-x86_64 - toolchain: ./cmake/flags-gcc-x86_64.cmake - slug: "-64" - runner: windows-2022 +# - msystem: MINGW64 +# prefix: mingw-w64-x86_64 +# toolchain: ./cmake/flags-gcc-x86_64.cmake +# slug: "MINGW64" +# runner: windows-2022 # - msystem: CLANG64 # prefix: mingw-w64-clang-x86_64 # toolchain: ./cmake/llvm-win32-x86_64.cmake # slug: "CLANG64" # runner: windows-2022 -# - msystem: UCRT64 -# prefix: mingw-w64-ucrt-x86_64 -# toolchain: ./cmake/flags-gcc-x86_64.cmake -# slug: "UCRT64" -# runner: windows-2022 + - msystem: UCRT64 + prefix: mingw-w64-ucrt-x86_64 + toolchain: ./cmake/flags-gcc-x86_64.cmake + slug: "-64" + runner: windows-2022 # - msystem: CLANGARM64 # toolchain: ./cmake/flags-gcc-aarch64.cmake # slug: -arm64 From e10de727eb11645c147585b14614c03051d30528 Mon Sep 17 00:00:00 2001 From: win2kgamer <47463859+win2kgamer@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:11:06 -0600 Subject: [PATCH 65/89] Remove the HP Pavilion 72xx machine due to VBIOS issues Machine has an integrated S3 ViRGE VBIOS that fails to detect a color display on some CPU clock and PIT mode combinations --- src/include/86box/machine.h | 1 - src/machine/m_at_socket7_3v.c | 67 ----------------------------------- src/machine/machine_table.c | 46 ------------------------ 3 files changed, 114 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 08f060849..c8271c674 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1006,7 +1006,6 @@ extern int machine_at_fmb_init(const machine_t *); extern int machine_at_acerv35n_init(const machine_t *); extern int machine_at_ap53_init(const machine_t *); extern int machine_at_8500tuc_init(const machine_t *); -extern int machine_at_hpruby_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t d943_device; #endif diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index d14e529a9..b85025cc9 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -1229,73 +1229,6 @@ machine_at_8500tuc_init(const machine_t *model) return ret; } -static void -machine_at_ruby_gpio_init(void) -{ - uint32_t gpio = 0xffffe3ff; - - /* Register 0x0079: */ - /* Bit 7: 0 = Clear password, 1 = Keep password. */ - /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ - /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ - /* Bit 4: External CPU clock (Switch 8). */ - /* Bit 3: External CPU clock (Switch 7). */ - /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ - /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ - /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ - /* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */ - /* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */ - /* Bit 0: 0 = Reserved. */ - /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ - if (cpu_busspeed <= 50000000) - gpio |= 0xffff10ff; - else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) - gpio |= 0xffff18ff; - else if (cpu_busspeed > 60000000) - gpio |= 0xffff00ff; - - if (sound_card_current[0] == SOUND_INTERNAL) - gpio |= 0xffff04ff; - - machine_set_gpio_default(gpio); -} - -int -machine_at_hpruby_init(const machine_t *model) -{ - int ret; - - ret = bios_load_linear_combined("roms/machines/hpruby/1007DC0L.BIO", - "roms/machines/hpruby/1007DC0L.BI1", - 0x20000, 128); - - if (bios_only || !ret) - return ret; - - machine_at_common_init_ex(model, 2); - machine_at_ruby_gpio_init(); - - pci_init(PCI_CONFIG_TYPE_1); - pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); - pci_register_slot(0x08, PCI_CARD_VIDEO, 4, 0, 0, 0); - pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 3, 2, 4); - pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 1, 3, 4); - pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); - - if (gfxcard[0] == VID_INTERNAL) - device_add(machine_get_vid_device(machine)); - - if (sound_card_current[0] == SOUND_INTERNAL) - machine_snd = device_add(machine_get_snd_device(machine)); - - device_add(&i430hx_device); - device_add(&piix3_device); - device_add_params(&pc87306_device, (void *) PCX730X_AMI); - device_add(&intel_flash_bxt_ami_device); - - return ret; -} - static const device_config_t d943_config[] = { // clang-format off { diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 3328adf31..70222f7d4 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14096,52 +14096,6 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, - /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the - PC87306 Super I/O chip, command 0xA1 returns '5'. - Command 0xA0 copyright string: (C)1994 AMI . */ - { - .name = "[i430HX] HP Pavilion 72xx (Ruby)", - .internal_name = "hpruby", - .type = MACHINE_TYPE_SOCKET7_3V, - .chipset = MACHINE_CHIPSET_INTEL_430HX, - .init = machine_at_hpruby_init, - .p1_handler = machine_generic_p1_handler, - .gpio_handler = NULL, - .available_flag = MACHINE_AVAILABLE, - .gpio_acpi_handler = NULL, - .cpu = { - .package = CPU_PKG_SOCKET5_7, - .block = CPU_BLOCK(CPU_K5, CPU_5K86, CPU_Cx6x86), - .min_bus = 50000000, - .max_bus = 66666667, - .min_voltage = 3380, - .max_voltage = 3520, - .min_multi = 1.5, - .max_multi = 3.0 - }, - .bus_flags = MACHINE_PS2_PCI, - .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_SOUND | MACHINE_GAMEPORT | MACHINE_APM, - .ram = { - .min = 8192, - .max = 131072, - .step = 8192 - }, - .nvrmask = 255, - .jumpered_ecp_dma = MACHINE_DMA_DISABLED | MACHINE_DMA_1 | MACHINE_DMA_3, - .default_jumpered_ecp_dma = 3, - .kbc_device = NULL, - .kbc_params = 0x00000000, - .kbc_p1 = 0x000044f0, - .gpio = 0xffffffff, - .gpio_acpi = 0xffffffff, - .device = NULL, - .kbd_device = NULL, - .fdc_device = NULL, - .sio_device = NULL, - .vid_device = &s3_virge_325_onboard_pci_device, - .snd_device = &ymf701_device, - .net_device = NULL - }, /* It possible has AMIKEY-2 'H' KBC firmware. */ { .name = "[i430HX] Siemens-Nixdorf D943", From e82331eeb14f13fa6db7bb6444cec4a3a3eb4c3a Mon Sep 17 00:00:00 2001 From: win2kgamer <47463859+win2kgamer@users.noreply.github.com> Date: Sat, 15 Nov 2025 20:35:21 -0600 Subject: [PATCH 66/89] Block incompatible K6 and Cyrix CPUs on the HP Pavilion 73xx/74xx --- src/machine/machine_table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 70222f7d4..6fddc784c 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14743,7 +14743,8 @@ const machine_t machines[] = { .gpio_acpi_handler = NULL, .cpu = { .package = CPU_PKG_SOCKET5_7, - .block = CPU_BLOCK(CPU_K5, CPU_5K86, CPU_Cx6x86), + .block = CPU_BLOCK(CPU_K5, CPU_5K86, CPU_K6, CPU_K6_2, CPU_K6_2C, CPU_K6_3, CPU_K6_2P, + CPU_K6_3P, CPU_Cx6x86, CPU_Cx6x86MX, CPU_Cx6x86L), .min_bus = 50000000, .max_bus = 66666667, .min_voltage = 2800, From fd4d8dc8a04a63f65232cdcb1c8713a7796019c4 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 15 Nov 2025 23:37:27 -0300 Subject: [PATCH 67/89] VIA AC97: Big rework, with proper sharing of audio/modem registers (again) and codec buses --- src/chipset/via_pipc.c | 4 +- src/include/86box/snd_ac97.h | 4 +- src/sound/snd_ac97_via.c | 374 +++++++++++++++++++---------------- 3 files changed, 210 insertions(+), 172 deletions(-) diff --git a/src/chipset/via_pipc.c b/src/chipset/via_pipc.c index a4d83220b..a476b9b99 100644 --- a/src/chipset/via_pipc.c +++ b/src/chipset/via_pipc.c @@ -987,7 +987,7 @@ pipc_read(int func, int addr, void *priv) } } else if ((func <= (pm_func + 2)) && !(dev->pci_isa_regs[0x85] & ((func == (pm_func + 1)) ? 0x04 : 0x08))) { /* AC97 / MC97 */ if (addr == 0x40) - ret = ac97_via_read_status(dev->ac97, func - pm_func - 1); + ret = ac97_via_read_status(dev->ac97); else ret = dev->ac97_regs[func - pm_func - 1][addr]; } @@ -1583,7 +1583,7 @@ pipc_write(int func, int addr, uint8_t val, void *priv) case 0x41: dev->ac97_regs[func][addr] = val; - ac97_via_write_control(dev->ac97, func, val); + ac97_via_write_control(dev->ac97, val); break; case 0x42: diff --git a/src/include/86box/snd_ac97.h b/src/include/86box/snd_ac97.h index 3af68d2c8..5f639d31e 100644 --- a/src/include/86box/snd_ac97.h +++ b/src/include/86box/snd_ac97.h @@ -125,8 +125,8 @@ extern uint32_t ac97_codec_getrate(void *priv, uint8_t reg); extern const device_t *ac97_codec_get(uint32_t id); extern void ac97_via_set_slot(void *priv, int slot, int irq_pin); -extern uint8_t ac97_via_read_status(void *priv, uint8_t modem); -extern void ac97_via_write_control(void *priv, uint8_t modem, uint8_t val); +extern uint8_t ac97_via_read_status(void *priv); +extern void ac97_via_write_control(void *priv, uint8_t val); extern void ac97_via_remap_audio_sgd(void *priv, uint16_t new_io_base, uint8_t enable); extern void ac97_via_remap_modem_sgd(void *priv, uint16_t new_io_base, uint8_t enable); extern void ac97_via_remap_audio_codec(void *priv, uint16_t new_io_base, uint8_t enable); diff --git a/src/sound/snd_ac97_via.c b/src/sound/snd_ac97_via.c index 28b802a6f..469e27717 100644 --- a/src/sound/snd_ac97_via.c +++ b/src/sound/snd_ac97_via.c @@ -10,7 +10,7 @@ * * Authors: RichardG, * - * Copyright 2021 RichardG. + * Copyright 2021-2025 RichardG. */ #include #include @@ -35,8 +35,6 @@ typedef struct ac97_via_sgd_t { uint8_t id; uint8_t always_run; - uint8_t modem; - uint8_t pad; struct _ac97_via_ *dev; uint32_t entry_ptr; @@ -65,22 +63,17 @@ typedef struct _ac97_via_ { uint16_t audio_codec_base; uint16_t modem_sgd_base; uint16_t modem_codec_base; - uint8_t sgd_regs[2][256]; + uint8_t sgd_regs[256]; uint8_t pcm_enabled : 1; uint8_t fm_enabled : 1; uint8_t vsr_enabled : 1; - struct { - union { - uint8_t regs_codec[2][128]; - uint8_t regs_linear[256]; - }; - } codec_shadow[2]; - uint8_t pci_slot; - uint8_t irq_state; - int irq_pin; + uint8_t codec_shadow[256]; + uint8_t pci_slot; + uint8_t irq_state; + int irq_pin; - ac97_codec_t *codec[2][2]; - ac97_via_sgd_t sgd[2][6]; + ac97_codec_t *codec[2]; + ac97_via_sgd_t sgd[6]; int master_vol_l; int master_vol_r; @@ -107,7 +100,7 @@ ac97_via_log(const char *fmt, ...) #endif static void ac97_via_sgd_process(void *priv); -static void ac97_via_update_codec(ac97_via_t *dev, int modem); +static void ac97_via_update_codec(ac97_via_t *dev); static void ac97_via_speed_changed(void *priv); static void ac97_via_filter_cd_audio(int channel, double *buffer, void *priv); @@ -118,73 +111,70 @@ ac97_via_set_slot(void *priv, int slot, int irq_pin) ac97_via_log("AC97 VIA: set_slot(%d, %d)\n", slot, irq_pin); - dev->pci_slot = slot; - dev->irq_pin = irq_pin; + dev->pci_slot = slot; + dev->irq_pin = irq_pin; } uint8_t -ac97_via_read_status(void *priv, uint8_t modem) +ac97_via_read_status(void *priv) { const ac97_via_t *dev = (ac97_via_t *) priv; uint8_t ret = 0x00; /* Flag each codec as ready if present. */ - for (uint8_t i = 0; i <= 1; i++) { - if (dev->codec[modem][i]) + for (uint8_t i = 0; i < (sizeof(dev->codec) / sizeof(dev->codec[0])); i++) { + if (dev->codec[i]) ret |= 0x01 << (i << 1); } - ac97_via_log("AC97 VIA %d: read_status() = %02X\n", modem, ret); + ac97_via_log("AC97 VIA: read_status() = %02X\n", ret); return ret; } void -ac97_via_write_control(void *priv, uint8_t modem, uint8_t val) +ac97_via_write_control(void *priv, uint8_t val) { ac97_via_t *dev = (ac97_via_t *) priv; uint8_t i; - ac97_via_log("AC97 VIA %d: write_control(%02X)\n", modem, val); + ac97_via_log("AC97 VIA: write_control(%02X)\n", val); /* Reset codecs if requested. */ if (!(val & 0x40)) { - for (i = 0; i <= 1; i++) { - if (dev->codec[modem][i]) - ac97_codec_reset(dev->codec[modem][i]); + for (i = 0; i < (sizeof(dev->codec) / sizeof(dev->codec[0])); i++) { + if (dev->codec[i]) + ac97_codec_reset(dev->codec[i]); } } - if (!modem) { - /* Set the variable sample rate flag. */ - dev->vsr_enabled = (val & 0xf8) == 0xc8; + /* Set the variable sample rate flag. */ + dev->vsr_enabled = (val & 0xf8) == 0xc8; - /* Start or stop PCM playback. */ - i = (val & 0xf4) == 0xc4; - if (i && !dev->pcm_enabled) - timer_advance_u64(&dev->sgd[0][0].poll_timer, dev->sgd[0][0].timer_latch); - dev->pcm_enabled = i; + /* Start or stop PCM playback. */ + i = (val & 0xf4) == 0xc4; + if (i && !dev->pcm_enabled) + timer_advance_u64(&dev->sgd[0].poll_timer, dev->sgd[0].timer_latch); + dev->pcm_enabled = i; - /* Start or stop FM playback. */ - i = (val & 0xf2) == 0xc2; - if (i && !dev->fm_enabled) - timer_advance_u64(&dev->sgd[0][2].poll_timer, dev->sgd[0][2].timer_latch); - dev->fm_enabled = i; + /* Start or stop FM playback. */ + i = (val & 0xf2) == 0xc2; + if (i && !dev->fm_enabled) + timer_advance_u64(&dev->sgd[2].poll_timer, dev->sgd[2].timer_latch); + dev->fm_enabled = i; - /* Update primary audio codec state. */ - if (dev->codec[0][0]) - ac97_via_update_codec(dev, 0); - } + /* Update audio codec state. */ + ac97_via_update_codec(dev); } static void -ac97_via_update_irqs(ac97_via_t *dev, int modem) +ac97_via_update_irqs(ac97_via_t *dev) { /* Check interrupt flags in all SGDs. */ for (uint8_t i = 0x00; i < ((sizeof(dev->sgd) / sizeof(dev->sgd[0])) << 4); i += 0x10) { /* Stop immediately if any flag is set. Doing it this way optimizes rising edges for the playback SGD (0 - first to be checked). */ - if (dev->sgd_regs[modem][i] & (dev->sgd_regs[modem][i | 0x2] & 0x03)) { + if (dev->sgd_regs[i] & (dev->sgd_regs[i | 0x2] & 0x03)) { pci_set_irq(dev->pci_slot, dev->irq_pin, &dev->irq_state); return; } @@ -194,28 +184,26 @@ ac97_via_update_irqs(ac97_via_t *dev, int modem) } static void -ac97_via_update_codec(ac97_via_t *dev, int modem) +ac97_via_update_codec(ac97_via_t *dev) { - /* Get primary audio codec. */ - ac97_codec_t *codec = dev->codec[modem][0]; - /* Update volumes according to codec registers. */ + ac97_codec_t *codec = dev->codec[0]; /* assume primary codec */ ac97_codec_getattn(codec, 0x02, &dev->master_vol_l, &dev->master_vol_r); - ac97_codec_getattn(codec, 0x18, &dev->sgd[modem][0].vol_l, &dev->sgd[modem][0].vol_r); - ac97_codec_getattn(codec, 0x18, &dev->sgd[modem][2].vol_l, &dev->sgd[modem][2].vol_r); /* VIAFMTSR sets Master, CD and PCM volumes to 0 dB */ + ac97_codec_getattn(codec, 0x18, &dev->sgd[0].vol_l, &dev->sgd[0].vol_r); + ac97_codec_getattn(codec, 0x18, &dev->sgd[2].vol_l, &dev->sgd[2].vol_r); /* VIAFMTSR sets Master, CD and PCM volumes to 0 dB */ ac97_codec_getattn(codec, 0x12, &dev->cd_vol_l, &dev->cd_vol_r); /* Update sample rate according to codec registers and the variable sample rate flag. */ ac97_via_speed_changed(dev); } -uint8_t +static uint8_t ac97_via_sgd_read(uint16_t addr, void *priv) { const ac97_via_t *dev = (ac97_via_t *) priv; -// #ifdef ENABLE_AC97_VIA_LOG - uint8_t modem = (addr & 0xff00) == dev->modem_sgd_base; -// #endif +#ifdef ENABLE_AC97_VIA_LOG + uint8_t modem = (addr & 0xff00) == dev->modem_sgd_base; +#endif addr &= 0xff; uint8_t ret; @@ -223,78 +211,78 @@ ac97_via_sgd_read(uint16_t addr, void *priv) /* Process SGD channel registers. */ switch (addr & 0xf) { case 0x4: - ret = dev->sgd[modem][addr >> 4].entry_ptr; + ret = dev->sgd[addr >> 4].entry_ptr; break; case 0x5: - ret = dev->sgd[modem][addr >> 4].entry_ptr >> 8; + ret = dev->sgd[addr >> 4].entry_ptr >> 8; break; case 0x6: - ret = dev->sgd[modem][addr >> 4].entry_ptr >> 16; + ret = dev->sgd[addr >> 4].entry_ptr >> 16; break; case 0x7: - ret = dev->sgd[modem][addr >> 4].entry_ptr >> 24; + ret = dev->sgd[addr >> 4].entry_ptr >> 24; break; case 0xc: - ret = dev->sgd[modem][addr >> 4].sample_count; + ret = dev->sgd[addr >> 4].sample_count; break; case 0xd: - ret = dev->sgd[modem][addr >> 4].sample_count >> 8; + ret = dev->sgd[addr >> 4].sample_count >> 8; break; case 0xe: - ret = dev->sgd[modem][addr >> 4].sample_count >> 16; + ret = dev->sgd[addr >> 4].sample_count >> 16; break; default: - ret = dev->sgd_regs[modem][addr]; + ret = dev->sgd_regs[addr]; break; } } else { /* Process regular registers. */ switch (addr) { case 0x84: - ret = (dev->sgd_regs[modem][0x00] & 0x01); - ret |= (dev->sgd_regs[modem][0x10] & 0x01) << 1; - ret |= (dev->sgd_regs[modem][0x20] & 0x01) << 2; + ret = (dev->sgd_regs[0x00] & 0x01); + ret |= (dev->sgd_regs[0x10] & 0x01) << 1; + ret |= (dev->sgd_regs[0x20] & 0x01) << 2; - ret |= (dev->sgd_regs[modem][0x00] & 0x02) << 3; - ret |= (dev->sgd_regs[modem][0x10] & 0x02) << 4; - ret |= (dev->sgd_regs[modem][0x20] & 0x02) << 5; + ret |= (dev->sgd_regs[0x00] & 0x02) << 3; + ret |= (dev->sgd_regs[0x10] & 0x02) << 4; + ret |= (dev->sgd_regs[0x20] & 0x02) << 5; break; case 0x85: - ret = (dev->sgd_regs[modem][0x00] & 0x04) >> 2; - ret |= (dev->sgd_regs[modem][0x10] & 0x04) >> 1; - ret |= (dev->sgd_regs[modem][0x20] & 0x04); + ret = (dev->sgd_regs[0x00] & 0x04) >> 2; + ret |= (dev->sgd_regs[0x10] & 0x04) >> 1; + ret |= (dev->sgd_regs[0x20] & 0x04); - ret |= (dev->sgd_regs[modem][0x00] & 0x80) >> 3; - ret |= (dev->sgd_regs[modem][0x10] & 0x80) >> 2; - ret |= (dev->sgd_regs[modem][0x20] & 0x80) >> 1; + ret |= (dev->sgd_regs[0x00] & 0x80) >> 3; + ret |= (dev->sgd_regs[0x10] & 0x80) >> 2; + ret |= (dev->sgd_regs[0x20] & 0x80) >> 1; break; case 0x86: - ret = (dev->sgd_regs[modem][0x40] & 0x01); - ret |= (dev->sgd_regs[modem][0x50] & 0x01) << 1; + ret = (dev->sgd_regs[0x40] & 0x01); + ret |= (dev->sgd_regs[0x50] & 0x01) << 1; - ret |= (dev->sgd_regs[modem][0x40] & 0x02) << 3; - ret |= (dev->sgd_regs[modem][0x50] & 0x02) << 4; + ret |= (dev->sgd_regs[0x40] & 0x02) << 3; + ret |= (dev->sgd_regs[0x50] & 0x02) << 4; break; case 0x87: - ret = (dev->sgd_regs[modem][0x40] & 0x04) >> 2; - ret |= (dev->sgd_regs[modem][0x50] & 0x04) >> 1; + ret = (dev->sgd_regs[0x40] & 0x04) >> 2; + ret |= (dev->sgd_regs[0x50] & 0x04) >> 1; - ret |= (dev->sgd_regs[modem][0x40] & 0x80) >> 3; - ret |= (dev->sgd_regs[modem][0x50] & 0x80) >> 2; + ret |= (dev->sgd_regs[0x40] & 0x80) >> 3; + ret |= (dev->sgd_regs[0x50] & 0x80) >> 2; break; default: - ret = dev->sgd_regs[modem][addr]; + ret = dev->sgd_regs[addr]; break; } } @@ -304,7 +292,7 @@ ac97_via_sgd_read(uint16_t addr, void *priv) return ret; } -void +static void ac97_via_sgd_write(uint16_t addr, uint8_t val, void *priv) { ac97_via_t *dev = (ac97_via_t *) priv; @@ -328,42 +316,42 @@ ac97_via_sgd_write(uint16_t addr, uint8_t val, void *priv) switch (addr & 0xf) { case 0x0: /* Clear RWC status bits. */ - dev->sgd_regs[modem][addr] &= ~(val & 0x07); + dev->sgd_regs[addr] &= ~(val & 0x07); /* Update status interrupts. */ - ac97_via_update_irqs(dev, modem); + ac97_via_update_irqs(dev); return; case 0x1: /* Start SGD if requested. */ if (val & 0x80) { - if (dev->sgd_regs[modem][addr & 0xf0] & 0x80) { + if (dev->sgd_regs[addr & 0xf0] & 0x80) { /* Queue SGD trigger if already running. */ - dev->sgd_regs[modem][addr & 0xf0] |= 0x08; + dev->sgd_regs[addr & 0xf0] |= 0x08; } else { /* Start SGD immediately. */ - dev->sgd_regs[modem][addr & 0xf0] = (dev->sgd_regs[modem][addr & 0xf0] & ~0x47) | 0x80; + dev->sgd_regs[addr & 0xf0] = (dev->sgd_regs[addr & 0xf0] & ~0x47) | 0x80; /* Start at the specified entry pointer. */ - dev->sgd[modem][addr >> 4].entry_ptr = AS_U32(dev->sgd_regs[modem][(addr & 0xf0) | 0x4]) & 0xfffffffe; - dev->sgd[modem][addr >> 4].restart = 2; + dev->sgd[addr >> 4].entry_ptr = AS_U32(dev->sgd_regs[(addr & 0xf0) | 0x4]) & 0xfffffffe; + dev->sgd[addr >> 4].restart = 2; /* Start the actual SGD process. */ - ac97_via_sgd_process(&dev->sgd[modem][addr >> 4]); + ac97_via_sgd_process(&dev->sgd[addr >> 4]); } } /* Stop SGD if requested. */ if (val & 0x40) - dev->sgd_regs[modem][addr & 0xf0] &= ~0x88; + dev->sgd_regs[addr & 0xf0] &= ~0x88; val &= 0x08; /* (Un)pause SGD if requested. */ if (val & 0x08) - dev->sgd_regs[modem][addr & 0xf0] |= 0x40; + dev->sgd_regs[addr & 0xf0] |= 0x40; else - dev->sgd_regs[modem][addr & 0xf0] &= ~0x40; + dev->sgd_regs[addr & 0xf0] &= ~0x40; break; @@ -391,55 +379,95 @@ ac97_via_sgd_write(uint16_t addr, uint8_t val, void *priv) case 0x82: /* Determine the selected codec. */ - i = !!(dev->sgd_regs[modem][0x83] & 0x40); - codec = dev->codec[modem][i]; + i = !!(dev->sgd_regs[0x83] & 0x40); + codec = dev->codec[i]; /* Keep value in register if this codec is not present. */ if (codec) { /* Read from or write to codec. */ if (val & 0x80) { - if (val & 1) { /* return 0x0000 on unaligned reads (real 686B behavior) */ - dev->sgd_regs[modem][0x80] = dev->sgd_regs[modem][0x81] = 0x00; - } else { - AS_U16(dev->codec_shadow[modem].regs_codec[i][val & 0x7f]) = AS_U16(dev->sgd_regs[modem][0x80]) = ac97_codec_readw(codec, val); - } + if (val & 1) /* return 0x0000 on unaligned reads (real 686B behavior) */ + AS_U16(dev->sgd_regs[0x80]) = 0x0000; + else + AS_U16(dev->codec_shadow[(i << 7) | (val & 0x7f)]) = AS_U16(dev->sgd_regs[0x80]) = ac97_codec_readw(codec, val); /* Flag data/status/index for this codec as valid. */ - dev->sgd_regs[modem][0x83] |= 0x02 << (i << 1); + dev->sgd_regs[0x83] |= 0x02 << (i << 1); } else if (!(val & 1)) { /* do nothing on unaligned writes */ ac97_codec_writew(codec, val, - AS_U16(dev->codec_shadow[modem].regs_codec[i][val & 0x7f]) = AS_U16(dev->sgd_regs[modem][0x80])); + AS_U16(dev->codec_shadow[(i << 7) | val]) = AS_U16(dev->sgd_regs[0x80])); - /* Update primary audio codec state if that codec was written to. */ - if (!modem && !i) { - ac97_via_update_codec(dev, 0); + /* Update audio codec state. */ + ac97_via_update_codec(dev); - /* Set up CD audio filter if CD volume was written to. Setting it - up at init prevents CD audio from working on other cards, but - this works as the CD channel is muted by default per AC97 spec. */ - if (val == 0x12) - sound_set_cd_audio_filter(ac97_via_filter_cd_audio, dev); - } + /* Set up CD audio filter if CD volume was written to. Setting it + up at init prevents CD audio from working on other cards, but + this works as the CD channel is muted by default per AC97 spec. */ + if (!i && (val == 0x12)) + sound_set_cd_audio_filter(ac97_via_filter_cd_audio, dev); } } - break; case 0x83: /* Clear RWC status bits. */ -#if 0 /* race condition with Linux accessing a register and clearing status bits on the same dword write */ - val = ((dev->sgd_regs[modem][addr] & 0x3f) & ~(val & 0x0a)) | (val & 0xc0); -#else - val = (dev->sgd_regs[modem][addr] & 0x3f) | (val & 0xc0); -#endif + val = ((dev->sgd_regs[addr] & 0x3f) & ~(val & 0x0a)) | (val & 0xc0); break; + case 0x88 ... 0x89: + dev->sgd_regs[addr] = val; + + /* Send GPO to codec. */ + /*for (uint8_t i = 0; i < (sizeof(dev->codec) / sizeof(dev->codec[0])); i++) { + if (dev->codec[i]) + ac97_codec_setgpo(dev->codec[i], AS_U16(dev->sgd_regs[0x88])); + }*/ + return; + + case 0x8a ... 0x8b: + /* Clear RWC status bits. */ + val = dev->sgd_regs[addr] & ~val; + break; + + case 0x8c ... 0x8d: + return; + default: break; } } - dev->sgd_regs[modem][addr] = val; + dev->sgd_regs[addr] = val; +} + +static void +ac97_via_sgd_writew(uint16_t addr, uint16_t val, void *priv) +{ + if ((addr & 0xfe) == 0x82) { + /* Invert order on writes to 82-83 to ensure the correct codec ID is set and + any status bits are cleared before performing the codec register operation. */ + ac97_via_sgd_write(addr + 1, val >> 8, priv); + ac97_via_sgd_write(addr, val & 0xff, priv); + } else { + ac97_via_sgd_write(addr, val & 0xff, priv); + ac97_via_sgd_write(addr + 1, val >> 8, priv); + } +} + +static void +ac97_via_sgd_writel(uint16_t addr, uint32_t val, void *priv) +{ + ac97_via_sgd_write(addr, val & 0xff, priv); + ac97_via_sgd_write(addr + 1, val >> 8, priv); + if ((addr & 0xfc) == 0x80) { + /* Invert order on writes to 82-83 to ensure the correct codec ID is set and + any status bits are cleared before performing the codec register operation. */ + ac97_via_sgd_write(addr + 3, val >> 24, priv); + ac97_via_sgd_write(addr + 2, val >> 16, priv); + } else { + ac97_via_sgd_write(addr + 2, val >> 16, priv); + ac97_via_sgd_write(addr + 3, val >> 24, priv); + } } void @@ -448,12 +476,12 @@ ac97_via_remap_audio_sgd(void *priv, uint16_t new_io_base, uint8_t enable) ac97_via_t *dev = (ac97_via_t *) priv; if (dev->audio_sgd_base) - io_removehandler(dev->audio_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, NULL, NULL, dev); + io_removehandler(dev->audio_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, ac97_via_sgd_writew, ac97_via_sgd_writel, dev); dev->audio_sgd_base = new_io_base; if (dev->audio_sgd_base && enable) - io_sethandler(dev->audio_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, NULL, NULL, dev); + io_sethandler(dev->audio_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, ac97_via_sgd_writew, ac97_via_sgd_writel, dev); } void @@ -462,24 +490,26 @@ ac97_via_remap_modem_sgd(void *priv, uint16_t new_io_base, uint8_t enable) ac97_via_t *dev = (ac97_via_t *) priv; if (dev->modem_sgd_base) - io_removehandler(dev->modem_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, NULL, NULL, dev); + io_removehandler(dev->modem_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, ac97_via_sgd_writew, ac97_via_sgd_writel, dev); dev->modem_sgd_base = new_io_base; if (dev->modem_sgd_base && enable) - io_sethandler(dev->modem_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, NULL, NULL, dev); + io_sethandler(dev->modem_sgd_base, 256, ac97_via_sgd_read, NULL, NULL, ac97_via_sgd_write, ac97_via_sgd_writew, ac97_via_sgd_writel, dev); } uint8_t ac97_via_codec_read(uint16_t addr, void *priv) { const ac97_via_t *dev = (ac97_via_t *) priv; +#ifdef ENABLE_AC97_VIA_LOG uint8_t modem = (addr & 0xff00) == dev->modem_codec_base; +#endif uint8_t ret = 0xff; addr &= 0xff; - ret = dev->codec_shadow[modem].regs_linear[addr]; + ret = dev->codec_shadow[addr]; ac97_via_log("AC97 VIA %d: codec_read(%02X) = %02X\n", modem, addr, ret); @@ -492,7 +522,9 @@ void ac97_via_codec_write(uint16_t addr, uint8_t val, void *priv) { ac97_via_t *dev = (ac97_via_t *) priv; +#ifdef ENABLE_AC97_VIA_LOG uint8_t modem = (addr & 0xff00) == dev->modem_codec_base; +#endif addr &= 0xff; ac97_via_log("[%04X:%08X] [%i] AC97 VIA %d: codec_write(%02X, %02X)\n", CS, cpu_state.pc, msw & 1, modem, addr, val); @@ -500,7 +532,7 @@ ac97_via_codec_write(uint16_t addr, uint8_t val, void *priv) ac97_via_log("AC97 VIA %d: codec_write(%02X, %02X)\n", modem, addr, val); /* Unknown behavior, maybe it does write to the shadow registers? */ - dev->codec_shadow[modem].regs_linear[addr] = val; + dev->codec_shadow[addr] = val; } void @@ -564,7 +596,7 @@ ac97_via_sgd_process(void *priv) ac97_via_t *dev = sgd->dev; /* Stop if this SGD is not active. */ - uint8_t sgd_status = dev->sgd_regs[sgd->modem][sgd->id] & 0xc4; + uint8_t sgd_status = dev->sgd_regs[sgd->id] & 0xc4; if (!(sgd_status & 0x80)) return; @@ -577,7 +609,7 @@ ac97_via_sgd_process(void *priv) if (sgd->restart) { /* (Re)load entry pointer if required. */ if (sgd->restart & 2) - sgd->entry_ptr = AS_U32(dev->sgd_regs[sgd->modem][sgd->id | 0x4]) & 0xfffffffe; /* TODO: probe real hardware - does "even addr" actually mean dword aligned? */ + sgd->entry_ptr = AS_U32(dev->sgd_regs[sgd->id | 0x4]) & 0xfffffffe; /* TODO: probe real hardware - does "even addr" actually mean dword aligned? */ sgd->restart = 0; /* Read entry. */ @@ -625,17 +657,17 @@ ac97_via_sgd_process(void *priv) ac97_via_log(" with STOP"); /* Raise STOP to pause SGD. */ - dev->sgd_regs[sgd->modem][sgd->id] |= 0x04; + dev->sgd_regs[sgd->id] |= 0x04; } if (sgd->entry_flags & 0x40) { ac97_via_log(" with FLAG"); /* Raise FLAG to pause SGD. */ - dev->sgd_regs[sgd->modem][sgd->id] |= 0x01; + dev->sgd_regs[sgd->id] |= 0x01; #ifdef ENABLE_AC97_VIA_LOG - if (dev->sgd_regs[sgd->modem][sgd->id | 0x2] & 0x01) + if (dev->sgd_regs[sgd->id | 0x2] & 0x01) ac97_via_log(" interrupt"); #endif } @@ -644,19 +676,19 @@ ac97_via_sgd_process(void *priv) ac97_via_log(" with EOL"); /* Raise EOL. */ - dev->sgd_regs[sgd->modem][sgd->id] |= 0x02; + dev->sgd_regs[sgd->id] |= 0x02; #ifdef ENABLE_AC97_VIA_LOG - if (dev->sgd_regs[sgd->modem][sgd->id | 0x2] & 0x02) + if (dev->sgd_regs[sgd->id | 0x2] & 0x02) ac97_via_log(" interrupt"); #endif /* Restart SGD if a trigger is queued or auto-start is enabled. */ - if ((dev->sgd_regs[sgd->modem][sgd->id] & 0x08) || (dev->sgd_regs[sgd->modem][sgd->id | 0x2] & 0x80)) { + if ((dev->sgd_regs[sgd->id] & 0x08) || (dev->sgd_regs[sgd->id | 0x2] & 0x80)) { ac97_via_log(" restart"); /* Un-queue trigger. */ - dev->sgd_regs[sgd->modem][sgd->id] &= ~0x08; + dev->sgd_regs[sgd->id] &= ~0x08; /* Go back to the starting block on the next run. */ sgd->restart = 2; @@ -664,13 +696,13 @@ ac97_via_sgd_process(void *priv) ac97_via_log(" finish"); /* Terminate SGD. */ - dev->sgd_regs[sgd->modem][sgd->id] &= ~0x80; + dev->sgd_regs[sgd->id] &= ~0x80; } } ac97_via_log("\n"); /* Fire any requested status interrupts. */ - ac97_via_update_irqs(dev, sgd->modem); + ac97_via_update_irqs(dev); } } } @@ -678,8 +710,8 @@ ac97_via_sgd_process(void *priv) static void ac97_via_poll_stereo(void *priv) { - ac97_via_t *dev = (ac97_via_t *) priv; - ac97_via_sgd_t *sgd = &dev->sgd[0][0]; /* Audio Read */ + ac97_via_sgd_t *sgd = (ac97_via_sgd_t *) priv; + ac97_via_t *dev = sgd->dev; /* Schedule next run if PCM playback is enabled. */ if (dev->pcm_enabled) @@ -689,7 +721,7 @@ ac97_via_poll_stereo(void *priv) ac97_via_update_stereo(dev, sgd); /* Feed next sample from the FIFO. */ - switch (dev->sgd_regs[0][sgd->id | 0x2] & 0x30) { + switch (dev->sgd_regs[sgd->id | 0x2] & 0x30) { case 0x00: /* Mono, 8-bit PCM */ if ((sgd->fifo_end - sgd->fifo_pos) >= 1) { sgd->out_l = sgd->out_r = (sgd->fifo[sgd->fifo_pos++ & (sizeof(sgd->fifo) - 1)] ^ 0x80) << 8; @@ -734,8 +766,8 @@ ac97_via_poll_stereo(void *priv) static void ac97_via_poll_fm(void *priv) { - ac97_via_t *dev = (ac97_via_t *) priv; - ac97_via_sgd_t *sgd = &dev->sgd[0][2]; /* FM Read */ + ac97_via_sgd_t *sgd = (ac97_via_sgd_t *) priv; + ac97_via_t *dev = sgd->dev; /* Schedule next run if FM playback is enabled. */ if (dev->fm_enabled) @@ -763,15 +795,17 @@ ac97_via_get_buffer(int32_t *buffer, int len, void *priv) { ac97_via_t *dev = (ac97_via_t *) priv; - ac97_via_update_stereo(dev, &dev->sgd[0][0]); - ac97_via_update_stereo(dev, &dev->sgd[0][2]); + ac97_via_update_stereo(dev, &dev->sgd[0]); + ac97_via_update_stereo(dev, &dev->sgd[2]); + ac97_via_update_stereo(dev, &dev->sgd[4]); for (int c = 0; c < len * 2; c++) { - buffer[c] += dev->sgd[0][0].buffer[c] / 2; - buffer[c] += dev->sgd[0][2].buffer[c] / 2; + buffer[c] += dev->sgd[0].buffer[c] / 2; + buffer[c] += dev->sgd[2].buffer[c] / 2; + buffer[c] += dev->sgd[4].buffer[c] / 2; } - dev->sgd[0][0].pos = dev->sgd[0][2].pos = 0; + dev->sgd[0].pos = dev->sgd[2].pos = dev->sgd[4].pos = 0; } static void @@ -792,13 +826,20 @@ ac97_via_speed_changed(void *priv) double freq; /* Get variable sample rate if enabled. */ - if (dev->vsr_enabled && dev->codec[0][0]) - freq = ac97_codec_getrate(dev->codec[0][0], 0x2c); + if (dev->vsr_enabled && dev->codec[0]) + freq = ac97_codec_getrate(dev->codec[0], 0x2c); else freq = (double) SOUND_FREQ; - dev->sgd[0][0].timer_latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / freq)); - dev->sgd[0][2].timer_latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / 24000.0)); /* FM operates at a fixed 24 KHz */ + dev->sgd[0].timer_latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / freq)); + dev->sgd[2].timer_latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / 24000.0)); /* FM operates at a fixed 24 KHz */ + + if (dev->codec[1]) + freq = ac97_codec_getrate(dev->codec[1], 0x40); + else + freq = (double) SOUND_FREQ; + + dev->sgd[4].timer_latch = dev->sgd[5].timer_latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / freq)); } static void * @@ -809,30 +850,27 @@ ac97_via_init(UNUSED(const device_t *info)) ac97_via_log("AC97 VIA: init()\n"); /* Set up codecs. */ - ac97_codec = &dev->codec[0][0]; - ac97_modem_codec = &dev->codec[1][0]; - ac97_codec_count = ac97_modem_codec_count = sizeof(dev->codec[0]) / sizeof(dev->codec[0][0]); + ac97_codec = &dev->codec[0]; + ac97_modem_codec = &dev->codec[1]; + ac97_codec_count = sizeof(dev->codec) / sizeof(dev->codec[0]); + ac97_modem_codec_count = 1; ac97_codec_id = ac97_modem_codec_id = 0; /* Set up SGD channels. */ for (uint8_t i = 0; i < (sizeof(dev->sgd) / sizeof(dev->sgd[0])); i++) { - for (uint8_t j = 0; j < 2; j++) { - dev->sgd[j][i].id = i << 4; - dev->sgd[j][i].dev = dev; + dev->sgd[i].id = i << 4; + dev->sgd[i].dev = dev; - dev->sgd[j][i].modem = j; + /* Disable the FIFO on SGDs we don't care about. */ + if ((i != 0) && (i != 2)) + dev->sgd[i].always_run = 1; - /* Disable the FIFO on SGDs we don't care about. */ - if ((i != 0) && (i != 2)) - dev->sgd[j][i].always_run = 1; - - timer_add(&dev->sgd[j][i].dma_timer, ac97_via_sgd_process, &dev->sgd[j][i], 0); - } + timer_add(&dev->sgd[i].dma_timer, ac97_via_sgd_process, &dev->sgd[i], 0); } /* Set up playback pollers. */ - timer_add(&dev->sgd[0][0].poll_timer, ac97_via_poll_stereo, dev, 0); - timer_add(&dev->sgd[0][2].poll_timer, ac97_via_poll_fm, dev, 0); + timer_add(&dev->sgd[0].poll_timer, ac97_via_poll_stereo, &dev->sgd[0], 0); + timer_add(&dev->sgd[2].poll_timer, ac97_via_poll_fm, &dev->sgd[2], 0); ac97_via_speed_changed(dev); /* Set up playback handler. */ From 0a1464444af2240cb01a0503dbc6c00792f64667 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 15 Nov 2025 23:45:19 -0300 Subject: [PATCH 68/89] AC97 Codec: Rework with modem and proper multi-codec support --- src/include/86box/snd_ac97.h | 50 ++++--- src/sound/snd_ac97_codec.c | 283 +++++++++++++++++++++++++++-------- src/sound/snd_ac97_via.c | 8 +- 3 files changed, 254 insertions(+), 87 deletions(-) diff --git a/src/include/86box/snd_ac97.h b/src/include/86box/snd_ac97.h index 5f639d31e..4b0186889 100644 --- a/src/include/86box/snd_ac97.h +++ b/src/include/86box/snd_ac97.h @@ -8,9 +8,11 @@ * * Definitions for AC'97 audio emulation. * + * + * * Authors: RichardG, * - * Copyright 2021 RichardG. + * Copyright 2021-2025 RichardG. */ #ifndef SOUND_AC97_H #define SOUND_AC97_H @@ -19,23 +21,26 @@ /* Misc support bits (misc_flags). Most of these are not part of any registers, but control enabling/disabling of registers and bits. */ -#define AC97_MASTER_6B (1 << 0) /* register 02 bits [13,5] (ML5/MR5) */ -#define AC97_AUXOUT (1 << 1) /* register 04 */ -#define AC97_AUXOUT_6B (1 << 2) /* register 04 bits [13,5] (ML5/MR5) */ -#define AC97_MONOOUT (1 << 3) /* register 06 */ -#define AC97_MONOOUT_6B (1 << 4) /* register 06 bit 5 (MM5) */ -#define AC97_PCBEEP (1 << 5) /* register 0A */ -#define AC97_PCBEEP_GEN (1 << 6) /* register 0A bits [12:5] (F[7:0]) */ -#define AC97_PHONE (1 << 9) /* register 0C */ -#define AC97_VIDEO (1 << 10) /* register 14 */ -#define AC97_AUXIN (1 << 11) /* register 16 */ +#define AC97_AUDIO (1 << 0) /* audio codec */ +#define AC97_MODEM (1 << 1) /* modem codec */ +#define AC97_MASTER_6B (1 << 2) /* register 02 bits [13,5] (ML5/MR5) */ +#define AC97_AUXOUT (1 << 3) /* register 04 */ +#define AC97_AUXOUT_6B (1 << 4) /* register 04 bits [13,5] (ML5/MR5) */ +#define AC97_MONOOUT (1 << 5) /* register 06 */ +#define AC97_MONOOUT_6B (1 << 6) /* register 06 bit 5 (MM5) */ +#define AC97_PCBEEP (1 << 9) /* register 0A */ +#define AC97_PCBEEP_GEN (1 << 10) /* register 0A bits [12:5] (F[7:0]) */ +#define AC97_PHONE (1 << 11) /* register 0C */ +#define AC97_VIDEO (1 << 12) /* register 14 */ +#define AC97_AUXIN (1 << 13) /* register 16 */ #define AC97_POP (1 << 15) /* register 20 bit 15 (POP) - definition shared with General Purpose bits */ #define AC97_MS (1 << 8) /* register 20 bit 8 (MS) - definition shared with General Purpose bits */ #define AC97_LPBK (1 << 7) /* register 20 bit 7 (LPBK) - definition shared with General Purpose bits */ -#define AC97_DSA (1 << 12) /* register 28 bits [5:4] (DSA[1:0]) */ -#define AC97_LFE_6B (1 << 13) /* register 36 bit 13 (LFE5) */ -#define AC97_CENTER_6B (1 << 14) /* register 36 bit 5 (CNT5) */ -#define AC97_SURR_6B (1 << 16) /* register 38 bits [13,5] (LSR5/RSR5) */ +#define AC97_DSA (1 << 14) /* register 28 bits [5:4] (DSA[1:0]) */ +#define AC97_LFE_6B (1 << 16) /* register 36 bit 13 (LFE5) */ +#define AC97_CENTER_6B (1 << 17) /* register 36 bit 5 (CNT5) */ +#define AC97_SURR_6B (1 << 18) /* register 38 bits [13,5] (LSR5/RSR5) */ +#define AC97_GAIN_3B (1 << 19) /* registers [1C:1E] (audio) or [46:4A] (modem) bits [8,0] are always 0 (spec violation?) if this is set */ /* Reset bits (reset_flags), register 00. */ #define AC97_MICPCM (1 << 0) @@ -89,6 +94,14 @@ #define AC97_PRK (1 << 13) #define AC97_PRL (1 << 14) +/* Extended Modem ID bits, register 3C. */ +#define AC97_LIN1 (1 << 0) +#define AC97_LIN2 (1 << 1) +#define AC97_HSET (1 << 2) +#define AC97_CID1 (1 << 3) +#define AC97_CID2 (1 << 4) +#define AC97_CIDR (1 << 7) /* special case: not part of register 3C, but rather 56 bit 13 */ + /* Codec IDs. */ #define AC97_CODEC_AD1881 AC97_VENDOR_ID('A', 'D', 'S', 0x40) #define AC97_CODEC_AK4540 AC97_VENDOR_ID('A', 'D', 'S', 0x40) @@ -115,6 +128,8 @@ typedef struct ac97_codec_t { uint8_t vendor_reg_page_max; const ac97_vendor_reg_t *vendor_regs; uint16_t *vendor_reg_pages; + uint16_t gpi; + uint16_t gpo; } ac97_codec_t; extern uint16_t ac97_codec_readw(ac97_codec_t *dev, uint8_t reg); @@ -122,6 +137,8 @@ extern void ac97_codec_writew(ac97_codec_t *dev, uint8_t reg, uint16_ extern void ac97_codec_reset(void *priv); extern void ac97_codec_getattn(void *priv, uint8_t reg, int *l, int *r); extern uint32_t ac97_codec_getrate(void *priv, uint8_t reg); +extern void ac97_codec_setgpi(void *priv, uint16_t gpi); +extern void ac97_codec_setgpo(void *priv, uint16_t gpo); extern const device_t *ac97_codec_get(uint32_t id); extern void ac97_via_set_slot(void *priv, int slot, int irq_pin); @@ -133,11 +150,8 @@ extern void ac97_via_remap_audio_codec(void *priv, uint16_t new_io_base, uint extern void ac97_via_remap_modem_codec(void *priv, uint16_t new_io_base, uint8_t enable); extern ac97_codec_t **ac97_codec; -extern ac97_codec_t **ac97_modem_codec; extern int ac97_codec_count; -extern int ac97_modem_codec_count; extern int ac97_codec_id; -extern int ac97_modem_codec_id; #ifdef EMU_DEVICE_H extern const device_t ad1881_device; diff --git a/src/sound/snd_ac97_codec.c b/src/sound/snd_ac97_codec.c index 77e5825d9..05bba70cb 100644 --- a/src/sound/snd_ac97_codec.c +++ b/src/sound/snd_ac97_codec.c @@ -10,7 +10,7 @@ * * Authors: RichardG, * - * Copyright 2021 RichardG. + * Copyright 2021-2025 RichardG. */ #include #include @@ -35,7 +35,10 @@ static const struct { uint16_t reset_flags; uint16_t extid_flags; uint8_t pcsr_mask; /* register 26 bits [15:8] */ - uint8_t eascr_mask; /* register 2A bits [14:11] */ + uint8_t eascr_mask; /* register 2A bits [14:11] (audio) or 56 bits ... */ + uint8_t modem_flags; + uint16_t gpi_mask; /* modem GPIO input-capable bits */ + uint16_t gpo_mask; /* modem GPIO output-capable bits */ const ac97_vendor_reg_t *vendor_regs; } ac97_codecs[] = { @@ -44,7 +47,7 @@ static const struct { .device = &ad1881_device, .min_rate = 7000, .max_rate = 48000, - .misc_flags = AC97_MASTER_6B | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_POP | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_MASTER_6B | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_POP | AC97_MS | AC97_LPBK, .reset_flags = (1 << AC97_3D_SHIFT), /* datasheet contradicts itself on AC97_HPOUT */ .extid_flags = AC97_VRA, .pcsr_mask = 0xbf, @@ -52,26 +55,26 @@ static const struct { }, { .device = &ak4540_device, - .misc_flags = AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .pcsr_mask = 0x1f }, { .device = &alc100_device, - .misc_flags = AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_POP | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_POP | AC97_MS | AC97_LPBK, .reset_flags = (22 << AC97_3D_SHIFT), .extid_flags = AC97_AMAP, .pcsr_mask = 0xbf }, { .device = &cs4297_device, - .misc_flags = AC97_MASTER_6B | AC97_AUXOUT | AC97_AUXOUT_6B | AC97_MONOOUT | AC97_MONOOUT_6B | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_MASTER_6B | AC97_AUXOUT | AC97_AUXOUT_6B | AC97_MONOOUT | AC97_MONOOUT_6B | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .reset_flags = AC97_HPOUT | AC97_DAC_18B | AC97_ADC_18B, .pcsr_mask = 0x7f, .vendor_regs = (const ac97_vendor_reg_t[]) {{0, 0x5a, 0x0301, 0x0000}, {0}} }, { .device = &cs4297a_device, - .misc_flags = AC97_MASTER_6B | AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_MASTER_6B | AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .reset_flags = AC97_HPOUT | AC97_DAC_20B | AC97_ADC_18B | (6 << AC97_3D_SHIFT), .extid_flags = AC97_AMAP, .pcsr_mask = 0xff, @@ -79,7 +82,7 @@ static const struct { }, { .device = &stac9708_device, - .misc_flags = AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .reset_flags = (26 << AC97_3D_SHIFT) | AC97_DAC_18B | AC97_ADC_18B, .extid_flags = AC97_SDAC, .pcsr_mask = 0xff, @@ -88,7 +91,7 @@ static const struct { }, { .device = &stac9721_device, - .misc_flags = AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .reset_flags = (26 << AC97_3D_SHIFT) | AC97_DAC_18B | AC97_ADC_18B, .extid_flags = AC97_AMAP, .pcsr_mask = 0xff, @@ -96,18 +99,18 @@ static const struct { }, { .device = &tr28023_device, - .misc_flags = AC97_MASTER_6B | AC97_MONOOUT | AC97_MONOOUT_6B | AC97_PCBEEP | AC97_PHONE | AC97_POP | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_MASTER_6B | AC97_MONOOUT | AC97_MONOOUT_6B | AC97_PCBEEP | AC97_PHONE | AC97_POP | AC97_MS | AC97_LPBK, .pcsr_mask = 0x3f }, { .device = &w83971d_device, - .misc_flags = AC97_MASTER_6B | AC97_MONOOUT | AC97_MONOOUT_6B | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_MASTER_6B | AC97_MONOOUT | AC97_MONOOUT_6B | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .reset_flags = (27 << AC97_3D_SHIFT), .pcsr_mask = 0x3f }, { .device = &wm9701a_device, - .misc_flags = AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, + .misc_flags = AC97_AUDIO | AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .reset_flags = AC97_DAC_18B | AC97_ADC_18B, .pcsr_mask = 0x3f } @@ -143,11 +146,10 @@ static const int32_t codec_attn[] = { }; ac97_codec_t **ac97_codec = NULL; -ac97_codec_t **ac97_modem_codec = NULL; int ac97_codec_count = 0; -int ac97_modem_codec_count = 0; int ac97_codec_id = 0; -int ac97_modem_codec_id = 0; + +static void ac97_codec_reset_ex(ac97_codec_t *dev, uint8_t flags); uint16_t ac97_codec_readw(ac97_codec_t *dev, uint8_t reg) @@ -155,10 +157,15 @@ ac97_codec_readw(ac97_codec_t *dev, uint8_t reg) /* Redirect a read from extended pages 1+ to the right array. */ reg &= 0x7e; uint16_t ret = dev->regs[0x24 >> 1] & 0x000f; - if ((ret > 0) && (reg >= 0x60) && (reg < 0x6f)) + if ((ret > 0) && (reg >= 0x60) && (reg < 0x6f)) { /* Extended */ ret = (ret <= dev->vendor_reg_page_max) ? dev->vendor_reg_pages[(ret << 3) | ((reg & 0x0e) >> 1)] : 0; - else + } else if (reg == 0x54) { /* GPIO Status */ + ret = dev->gpo & ~dev->regs[0x4c >> 1]; /* outputs */ + ret |= dev->gpi & dev->regs[0x4c >> 1] & ~dev->regs[0x50 >> 1]; /* non-sticky inputs */ + ret |= dev->regs[reg >> 1] & dev->regs[0x4c >> 1] & dev->regs[0x50 >> 1]; /* sticky inputs */ + } else { ret = dev->regs[reg >> 1]; + } ac97_codec_log("AC97 Codec %d: readw(%02X) = %04X\n", dev->codec_id, reg, ret); @@ -175,9 +182,15 @@ ac97_codec_writew(ac97_codec_t *dev, uint8_t reg, uint16_t val) uint16_t prev = dev->regs[reg >> 1]; int j; + /* Initial filtering by codec type. */ + if (!(ac97_codecs[dev->model].misc_flags & AC97_AUDIO) && (reg <= 0x3a)) + return; + if (!(ac97_codecs[dev->model].misc_flags & AC97_MODEM) && (reg >= 0x3c) && (reg <= 0x58)) + return; + switch (reg) { case 0x00: /* Reset / ID code */ - ac97_codec_reset(dev); + ac97_codec_reset_ex(dev, AC97_AUDIO); return; case 0x02: /* Master Volume */ @@ -260,13 +273,13 @@ line_gain: break; case 0x1c: /* Record Gain */ - val &= 0x8f0f; + val &= (ac97_codecs[dev->model].misc_flags & AC97_GAIN_3B) ? 0x8e0e : 0x8f0f; break; case 0x1e: /* Record Gain Mic */ if (!(ac97_codecs[dev->model].reset_flags & AC97_MICPCM)) return; - val &= 0x800f; + val &= (ac97_codecs[dev->model].misc_flags & AC97_GAIN_3B) ? 0x800e : 0x800f; break; case 0x20: /* General Purpose */ @@ -350,11 +363,11 @@ line_gain: case 0x2c: /* PCM Front DAC Rate */ case 0x32: /* PCM L/R ADC Rate */ -rate: /* Writable only if VRA/VRM is set. */ +rate_vrx: /* Writable only if VRA/VRM is set. */ i = (reg >= 0x32) ? AC97_VRM : AC97_VRA; if (!(ac97_codecs[dev->model].extid_flags & i)) return; - +rate: /* Limit to supported sample rate range. */ if (val < ac97_codecs[dev->model].min_rate) val = ac97_codecs[dev->model].min_rate; @@ -365,17 +378,17 @@ rate: /* Writable only if VRA/VRM is set. */ case 0x2e: /* PCM Surround DAC Rate */ if (!(ac97_codecs[dev->model].extid_flags & AC97_SDAC)) return; - goto rate; + goto rate_vrx; case 0x30: /* PCM LFE DAC Rate */ if (!(ac97_codecs[dev->model].extid_flags & AC97_LDAC)) return; - goto rate; + goto rate_vrx; case 0x34: /* Mic ADC Rate */ if (!(ac97_codecs[dev->model].reset_flags & AC97_MICPCM)) return; - goto rate; + goto rate_vrx; case 0x36: /* Center/LFE Volume */ if (ac97_codecs[dev->model].extid_flags & AC97_LDAC) @@ -406,6 +419,86 @@ rate: /* Writable only if VRA/VRM is set. */ return; break; + case 0x3c: /* Reset / Extended Modem ID */ + ac97_codec_reset_ex(dev, AC97_MODEM); + return; + + case 0x3e: /* Extended Modem Control/Status */ + i = 0x0300; + if (ac97_codecs[dev->model].modem_flags & AC97_LIN1) + i |= 0x0c00; + if (ac97_codecs[dev->model].modem_flags & AC97_LIN2) + i |= 0x3000; + if (ac97_codecs[dev->model].modem_flags & AC97_HSET) + i |= 0xc000; + val &= i; + + /* Update status bits to reflect powerdowns. */ + val |= (~val & i) >> 8; + break; + + case 0x40: /* Line1 DAC/ADC Rate */ + if (!(ac97_codecs[dev->model].modem_flags & AC97_LIN1)) + return; + goto rate; + + case 0x42: /* Line2 DAC/ADC Rate */ + if (!(ac97_codecs[dev->model].modem_flags & AC97_LIN2)) + return; + goto rate; + + case 0x44: /* Handset DAC/ADC Rate */ + if (!(ac97_codecs[dev->model].modem_flags & AC97_HSET)) + return; + goto rate; + + case 0x46: /* Line 1 DAC/ADC Level */ + if (!(ac97_codecs[dev->model].modem_flags & AC97_LIN1)) + return; +modem_gain: + val &= (ac97_codecs[dev->model].misc_flags & AC97_GAIN_3B) ? 0x8e8e : 0x8f8f; + break; + + case 0x48: /* Line 2 DAC/ADC Level */ + if (!(ac97_codecs[dev->model].modem_flags & AC97_LIN2)) + return; + goto modem_gain; + + case 0x4a: /* Handset DAC/ADC Level */ + if (!(ac97_codecs[dev->model].modem_flags & AC97_HSET)) + return; + goto modem_gain; + + case 0x56: /* Miscellaneous Modem AFE Status/Control */ + if (ac97_codecs[dev->model].modem_flags & AC97_LIN1) + i |= 0x0007; + if (ac97_codecs[dev->model].modem_flags & AC97_LIN2) + i |= 0x0070; + if (ac97_codecs[dev->model].modem_flags & AC97_HSET) + i |= 0x0700; + val &= i; + break; + + case 0x4c: /* GPIO Pin Configuration */ + val &= ac97_codecs[dev->model].gpi_mask | ac97_codecs[dev->model].gpo_mask; + break; + + case 0x4e: /* GPIO Pin Polarity/Type */ + val |= ~(ac97_codecs[dev->model].gpi_mask | ac97_codecs[dev->model].gpo_mask); + break; + + case 0x50: /* GPIO Pin Sticky */ + dev->regs[0x54 >> 1] &= val; /* clear sticky inputs that are no longer sticky (assumed undefined behavior) */ + fallthrough; + + case 0x52: /* GPIO Pin Wake-up Mask */ + val &= ac97_codecs[dev->model].gpi_mask; + break; + + case 0x54: /* GPIO Pin Status */ + val = dev->regs[reg >> 1] & ~val; /* clear sticky inputs */ + break; + case 0x60 ... 0x6e: /* Extended */ /* Get extended register page. */ i = dev->regs[0x24 >> 1] & 0x000f; @@ -462,47 +555,83 @@ void ac97_codec_reset(void *priv) { ac97_codec_t *dev = (ac97_codec_t *) priv; - uint16_t i; + ac97_codec_reset_ex(dev, AC97_AUDIO | AC97_MODEM); +} - ac97_codec_log("AC97 Codec %d: reset()\n", dev->codec_id); +static void +ac97_codec_reset_ex(ac97_codec_t *dev, uint8_t flags) +{ + ac97_codec_log("AC97 Codec %d: reset(%02X)\n", dev->codec_id, flags); memset(dev->regs, 0, sizeof(dev->regs)); - /* Set default level and gain values. */ - dev->regs[0x02 >> 1] = AC97_MUTE; - if (ac97_codecs[dev->model].misc_flags & AC97_AUXOUT) - dev->regs[0x04 >> 1] = AC97_MUTE; - if (ac97_codecs[dev->model].misc_flags & AC97_MONOOUT) - dev->regs[0x06 >> 1] = AC97_MUTE; - if (ac97_codecs[dev->model].misc_flags & AC97_PHONE) - dev->regs[0x0c >> 1] = AC97_MUTE | 0x0008; - dev->regs[0x0e >> 1] = AC97_MUTE | 0x0008; /* mic */ - dev->regs[0x10 >> 1] = dev->regs[0x12 >> 1] = dev->regs[0x18 >> 1] = AC97_MUTE | 0x0808; /* line in, CD, PCM out */ - if (ac97_codecs[dev->model].misc_flags & AC97_VIDEO) - dev->regs[0x14 >> 1] = AC97_MUTE | 0x0808; - if (ac97_codecs[dev->model].misc_flags & AC97_AUXIN) - dev->regs[0x14 >> 1] = AC97_MUTE | 0x0808; - dev->regs[0x1c >> 1] = AC97_MUTE; /* record gain */ - if (ac97_codecs[dev->model].reset_flags & AC97_MICPCM) - dev->regs[0x1e >> 1] = AC97_MUTE; /* mic record gain */ - if (ac97_codecs[dev->model].misc_flags & AC97_LDAC) - dev->regs[0x36 >> 1] = AC97_MUTE_L; - if (ac97_codecs[dev->model].misc_flags & AC97_CDAC) - dev->regs[0x36 >> 1] |= AC97_MUTE_R; - if (ac97_codecs[dev->model].misc_flags & AC97_SDAC) - dev->regs[0x38 >> 1] = AC97_MUTE_L | AC97_MUTE_R; + if ((flags & AC97_AUDIO) && (ac97_codecs[dev->model].misc_flags & AC97_AUDIO)) { + /* Set default level and gain values. */ + dev->regs[0x02 >> 1] = AC97_MUTE; + if (ac97_codecs[dev->model].misc_flags & AC97_AUXOUT) + dev->regs[0x04 >> 1] = AC97_MUTE; + if (ac97_codecs[dev->model].misc_flags & AC97_MONOOUT) + dev->regs[0x06 >> 1] = AC97_MUTE; + if (ac97_codecs[dev->model].misc_flags & AC97_PHONE) + dev->regs[0x0c >> 1] = AC97_MUTE | 0x0008; + dev->regs[0x0e >> 1] = AC97_MUTE | 0x0008; /* mic */ + dev->regs[0x10 >> 1] = dev->regs[0x12 >> 1] = dev->regs[0x18 >> 1] = AC97_MUTE | 0x0808; /* line in, CD, PCM out */ + if (ac97_codecs[dev->model].misc_flags & AC97_VIDEO) + dev->regs[0x14 >> 1] = AC97_MUTE | 0x0808; + if (ac97_codecs[dev->model].misc_flags & AC97_AUXIN) + dev->regs[0x16 >> 1] = AC97_MUTE | 0x0808; + dev->regs[0x18 >> 1] = AC97_MUTE | 0x0808; /* PCM */ + dev->regs[0x1c >> 1] = AC97_MUTE; /* record gain */ + if (ac97_codecs[dev->model].reset_flags & AC97_MICPCM) + dev->regs[0x1e >> 1] = AC97_MUTE; /* mic record gain */ + if (ac97_codecs[dev->model].misc_flags & AC97_LDAC) + dev->regs[0x36 >> 1] = AC97_MUTE_L; + if (ac97_codecs[dev->model].misc_flags & AC97_CDAC) + dev->regs[0x36 >> 1] |= AC97_MUTE_R; + if (ac97_codecs[dev->model].misc_flags & AC97_SDAC) + dev->regs[0x38 >> 1] = AC97_MUTE_L | AC97_MUTE_R; - /* Set flags. */ - dev->regs[0x00 >> 1] = ac97_codecs[dev->model].reset_flags; - dev->regs[0x26 >> 1] = 0x000f; /* codec ready */ - dev->regs[0x28 >> 1] = (dev->codec_id << 14) | ac97_codecs[dev->model].extid_flags; - ac97_codec_writew(dev, 0x2a, 0x0000); /* reset variable DAC/ADC sample rates */ - i = ac97_codecs[dev->model].extid_flags & (AC97_CDAC | AC97_SDAC | AC97_LDAC); - dev->regs[0x2a >> 1] |= i | (i << 5); /* any additional DACs are ready but powered down */ - if (ac97_codecs[dev->model].extid_flags & AC97_SPDIF) - dev->regs[0x2a >> 1] |= AC97_SPCV; - if (ac97_codecs[dev->model].reset_flags & AC97_MICPCM) - dev->regs[0x2a >> 1] |= AC97_MADC | AC97_PRL; + /* Set flags. */ + dev->regs[0x00 >> 1] = ac97_codecs[dev->model].reset_flags; + dev->regs[0x26 >> 1] = 0x000f; /* codec ready */ + dev->regs[0x28 >> 1] = (dev->codec_id << 14) | ac97_codecs[dev->model].extid_flags; + ac97_codec_writew(dev, 0x2a, 0x0000); /* reset variable DAC/ADC sample rates */ + uint16_t i = ac97_codecs[dev->model].extid_flags & (AC97_CDAC | AC97_SDAC | AC97_LDAC); + dev->regs[0x2a >> 1] |= i | (i << 5); /* any additional DACs are ready but powered down */ + if (ac97_codecs[dev->model].extid_flags & AC97_SPDIF) + dev->regs[0x2a >> 1] |= AC97_SPCV; + if (ac97_codecs[dev->model].reset_flags & AC97_MICPCM) + dev->regs[0x2a >> 1] |= AC97_MADC | AC97_PRL; + } + + if ((flags & AC97_MODEM) && (ac97_codecs[dev->model].misc_flags & AC97_MODEM)) { + if (ac97_codecs[dev->model].modem_flags & AC97_LIN1) { + dev->regs[0x3e >> 1] |= 0x0c00; + dev->regs[0x40 >> 1] = /*4*/8000; + dev->regs[0x46 >> 1] = 0x8080; + } + if (ac97_codecs[dev->model].modem_flags & AC97_LIN2) { + dev->regs[0x3e >> 1] |= 0x3000; + dev->regs[0x42 >> 1] = /*4*/8000; + dev->regs[0x48 >> 1] = 0x8080; + } + if (ac97_codecs[dev->model].modem_flags & AC97_HSET) { + dev->regs[0x3e >> 1] |= 0xc000; + dev->regs[0x44 >> 1] = /*4*/8000; + dev->regs[0x4a >> 1] = 0x8080; + } + dev->regs[0x4c >> 1] = ac97_codecs[dev->model].gpi_mask | ac97_codecs[dev->model].gpo_mask; + dev->regs[0x4e >> 1] = 0xffff; + + /* Set flags. */ + dev->regs[0x3c >> 1] = (dev->codec_id << 14) | (ac97_codecs[dev->model].modem_flags & ~AC97_CIDR); + if (ac97_codecs[dev->model].modem_flags & AC97_CIDR) + dev->regs[0x56 >> 1] |= 0x2000; + if (ac97_codecs[dev->model].modem_flags & AC97_CID1) + dev->regs[0x56 >> 1] |= 0x4000; + if (ac97_codecs[dev->model].modem_flags & AC97_CID2) + dev->regs[0x56 >> 1] |= 0x8000; + } /* Set vendor ID. */ dev->regs[0x7c >> 1] = ac97_codecs[dev->model].device->local >> 16; @@ -510,13 +639,16 @@ ac97_codec_reset(void *priv) /* Set vendor-specific registers. */ if (ac97_codecs[dev->model].vendor_regs) { - for (i = 0; ac97_codecs[dev->model].vendor_regs[i].index; i++) { + for (int i = 0; ac97_codecs[dev->model].vendor_regs[i].index; i++) { if (ac97_codecs[dev->model].vendor_regs[i].page > 0) dev->vendor_reg_pages[(ac97_codecs[dev->model].vendor_regs[i].page << 3) | (ac97_codecs[dev->model].vendor_regs[i].index >> 1)] = ac97_codecs[dev->model].vendor_regs[i].value; else dev->regs[ac97_codecs[dev->model].vendor_regs[i].index >> 1] = ac97_codecs[dev->model].vendor_regs[i].value; } } + + if (flags & AC97_MODEM) + dev->gpi = dev->gpo = 0; } void @@ -561,7 +693,7 @@ ac97_codec_getattn(void *priv, uint8_t reg, int *l, int *r) uint32_t ac97_codec_getrate(void *priv, uint8_t reg) { - const ac97_codec_t *dev = (ac97_codec_t *) priv; + ac97_codec_t *dev = (ac97_codec_t *) priv; /* Get configured sample rate, which is always 48000 if VRA/VRM is not set. */ uint32_t ret = dev->regs[reg >> 1]; @@ -575,6 +707,29 @@ ac97_codec_getrate(void *priv, uint8_t reg) return ret; } +void +ac97_codec_setgpi(void *priv, uint16_t gpi) +{ + ac97_codec_t *dev = (ac97_codec_t *) priv; + + ac97_codec_log("AC97 Codec %d: setgpi(%04X)\n", dev->codec_id, gpi); + + /* Set status bits for sticky inputs. */ + gpi &= ac97_codecs[dev->model].gpi_mask; + dev->regs[0x54 >> 1] |= (dev->gpi ^ gpi) & dev->regs[0x4c >> 1] & dev->regs[0x50 >> 1]; /* set on (transition & input & sticky) */ + dev->gpi = gpi; +} + +void +ac97_codec_setgpo(void *priv, uint16_t gpo) +{ + ac97_codec_t *dev = (ac97_codec_t *) priv; + + ac97_codec_log("AC97 Codec %d: setgpo(%04X)\n", dev->codec_id, gpo); + + dev->gpo = gpo & ac97_codecs[dev->model].gpo_mask; +} + static void * ac97_codec_init(const device_t *info) { @@ -603,7 +758,7 @@ ac97_codec_init(const device_t *info) if (--ac97_codec_count == 0) ac97_codec = NULL; else - ac97_codec += sizeof(ac97_codec_t *); + ac97_codec++; dev->codec_id = ac97_codec_id++; /* Allocate vendor-specific register pages if required. */ diff --git a/src/sound/snd_ac97_via.c b/src/sound/snd_ac97_via.c index 469e27717..43a94a736 100644 --- a/src/sound/snd_ac97_via.c +++ b/src/sound/snd_ac97_via.c @@ -418,10 +418,10 @@ ac97_via_sgd_write(uint16_t addr, uint8_t val, void *priv) dev->sgd_regs[addr] = val; /* Send GPO to codec. */ - /*for (uint8_t i = 0; i < (sizeof(dev->codec) / sizeof(dev->codec[0])); i++) { + for (uint8_t i = 0; i < (sizeof(dev->codec) / sizeof(dev->codec[0])); i++) { if (dev->codec[i]) ac97_codec_setgpo(dev->codec[i], AS_U16(dev->sgd_regs[0x88])); - }*/ + } return; case 0x8a ... 0x8b: @@ -851,10 +851,8 @@ ac97_via_init(UNUSED(const device_t *info)) /* Set up codecs. */ ac97_codec = &dev->codec[0]; - ac97_modem_codec = &dev->codec[1]; ac97_codec_count = sizeof(dev->codec) / sizeof(dev->codec[0]); - ac97_modem_codec_count = 1; - ac97_codec_id = ac97_modem_codec_id = 0; + ac97_codec_id = 0; /* Set up SGD channels. */ for (uint8_t i = 0; i < (sizeof(dev->sgd) / sizeof(dev->sgd[0])); i++) { From a6b442bb6b7f5623eeeac1795f0be586a0996344 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 16 Nov 2025 00:50:30 -0300 Subject: [PATCH 69/89] AC97 Codec: Add Si3036 MC97 codec --- src/include/86box/snd_ac97.h | 2 ++ src/sound/snd_ac97_codec.c | 24 ++++++++++++++++++++++++ src/sound/sound.c | 1 + 3 files changed, 27 insertions(+) diff --git a/src/include/86box/snd_ac97.h b/src/include/86box/snd_ac97.h index 4b0186889..d8f2f6953 100644 --- a/src/include/86box/snd_ac97.h +++ b/src/include/86box/snd_ac97.h @@ -113,6 +113,7 @@ #define AC97_CODEC_TR28023 AC97_VENDOR_ID('T', 'R', 'A', 0x03) #define AC97_CODEC_W83971D AC97_VENDOR_ID('W', 'E', 'C', 0x01) #define AC97_CODEC_WM9701A AC97_VENDOR_ID('W', 'M', 'L', 0x00) +#define AC97_CODEC_SI3036 AC97_VENDOR_ID('S', 'I', 'L', 0x22) typedef struct ac97_vendor_reg_t { uint8_t page; /* for paged registers [60:6F], 0 otherwise */ @@ -165,6 +166,7 @@ extern const device_t stac9721_device; extern const device_t tr28023_device; extern const device_t w83971d_device; extern const device_t wm9701a_device; +extern const device_t si3036_device; extern const device_t ac97_via_device; #endif diff --git a/src/sound/snd_ac97_codec.c b/src/sound/snd_ac97_codec.c index 05bba70cb..3538ada8f 100644 --- a/src/sound/snd_ac97_codec.c +++ b/src/sound/snd_ac97_codec.c @@ -113,6 +113,16 @@ static const struct { .misc_flags = AC97_AUDIO | AC97_AUXOUT | AC97_MONOOUT | AC97_PCBEEP | AC97_PHONE | AC97_VIDEO | AC97_AUXIN | AC97_MS | AC97_LPBK, .reset_flags = AC97_DAC_18B | AC97_ADC_18B, .pcsr_mask = 0x3f + }, + { + .device = &si3036_device, + .misc_flags = AC97_MODEM | AC97_GAIN_3B, + .min_rate = 7200, + .max_rate = 13714, + .modem_flags = AC97_LIN1 | AC97_LIN2, + .gpi_mask = 0xe83a, + .gpo_mask = 0xfc3f, + .vendor_regs = (const ac97_vendor_reg_t[]) {{0, 0x5a, 0x0142, 0x0000}, {0, 0x5c, 0xf010, 0xfefd}, {0, 0x5e, 0x004c, 0x0000}, {0, 0x62, 0x0000, 0x01f8}, {0, 0x64, 0x0080, 0x0000}, {0}} } // clang-format on }; @@ -947,3 +957,17 @@ const device_t wm9701a_device = { .force_redraw = NULL, .config = NULL }; + +const device_t si3036_device = { + .name = "Silicon Laboratories Si3036 Modem", + .internal_name = "si3036", + .flags = DEVICE_AC97, + .local = AC97_CODEC_SI3036, + .init = ac97_codec_init, + .close = ac97_codec_close, + .reset = ac97_codec_reset, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; diff --git a/src/sound/sound.c b/src/sound/sound.c index 7b4141bd8..94a11ad00 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -187,6 +187,7 @@ static const SOUND_CARD sound_cards[] = { /* AC97 */ { &ad1881_device }, { &cs4297a_device }, + { &si3036_device }, { NULL } // clang-format on }; From e8a3057445855e9d044febee56d4afbbaac4913b Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 16 Nov 2025 00:56:44 -0300 Subject: [PATCH 70/89] AC97 Codec: Fix attenuation on mono controls --- src/sound/snd_ac97_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sound/snd_ac97_codec.c b/src/sound/snd_ac97_codec.c index 3538ada8f..04abab305 100644 --- a/src/sound/snd_ac97_codec.c +++ b/src/sound/snd_ac97_codec.c @@ -676,7 +676,7 @@ ac97_codec_getattn(void *priv, uint8_t reg, int *l, int *r) *r = 0; } else { /* per-channel mute */ /* Determine attenuation value. */ - uint8_t l_val = val >> 8; + uint8_t l_val = ((reg == 0x06) || (reg == 0x0c) || (reg == 0x0e)) ? val : (val >> 8); /* mono controls only have the right bits */ uint8_t r_val = val; if (reg <= 0x06) { /* 6-bit level */ *l = codec_attn[0x3f - (l_val & 0x3f)]; From 36544160ce8392022b2308c55d53beba3f9678f8 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 16 Nov 2025 01:21:41 -0300 Subject: [PATCH 71/89] VIA AC97: Implement modem and non-primary audio codec support --- src/sound/snd_ac97_via.c | 89 +++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/src/sound/snd_ac97_via.c b/src/sound/snd_ac97_via.c index 43a94a736..6947c222d 100644 --- a/src/sound/snd_ac97_via.c +++ b/src/sound/snd_ac97_via.c @@ -66,6 +66,7 @@ typedef struct _ac97_via_ { uint8_t sgd_regs[256]; uint8_t pcm_enabled : 1; uint8_t fm_enabled : 1; + uint8_t modem_enabled : 1; uint8_t vsr_enabled : 1; uint8_t codec_shadow[256]; uint8_t pci_slot; @@ -73,6 +74,8 @@ typedef struct _ac97_via_ { int irq_pin; ac97_codec_t *codec[2]; + ac97_codec_t *audio_codec; + ac97_codec_t *modem_codec; ac97_via_sgd_t sgd[6]; int master_vol_l; @@ -187,11 +190,13 @@ static void ac97_via_update_codec(ac97_via_t *dev) { /* Update volumes according to codec registers. */ - ac97_codec_t *codec = dev->codec[0]; /* assume primary codec */ - ac97_codec_getattn(codec, 0x02, &dev->master_vol_l, &dev->master_vol_r); - ac97_codec_getattn(codec, 0x18, &dev->sgd[0].vol_l, &dev->sgd[0].vol_r); - ac97_codec_getattn(codec, 0x18, &dev->sgd[2].vol_l, &dev->sgd[2].vol_r); /* VIAFMTSR sets Master, CD and PCM volumes to 0 dB */ - ac97_codec_getattn(codec, 0x12, &dev->cd_vol_l, &dev->cd_vol_r); + if (dev->audio_codec) { + ac97_codec_getattn(dev->audio_codec, 0x02, &dev->master_vol_l, &dev->master_vol_r); + ac97_codec_getattn(dev->audio_codec, 0x18, &dev->sgd[0].vol_l, &dev->sgd[0].vol_r); + ac97_codec_getattn(dev->audio_codec, 0x18, &dev->sgd[2].vol_l, &dev->sgd[2].vol_r); /* VIAFMTSR sets Master, CD and PCM volumes to 0 dB */ + ac97_codec_getattn(dev->audio_codec, 0x12, &dev->cd_vol_l, &dev->cd_vol_r); + ac97_codec_getattn(dev->audio_codec, 0x0c, &dev->sgd[4].vol_l, &dev->sgd[4].vol_r); + } /* Update sample rate according to codec registers and the variable sample rate flag. */ ac97_via_speed_changed(dev); @@ -384,6 +389,25 @@ ac97_via_sgd_write(uint16_t addr, uint8_t val, void *priv) /* Keep value in register if this codec is not present. */ if (codec) { + /* Set audio and modem codecs according to type. */ + if (codec->regs[0x3c >> 1]) { + if (!dev->modem_codec) { + dev->modem_codec = codec; + if (val & 0x80) + ac97_via_update_codec(dev); + } + /* Start modem pollers. */ + if (!dev->modem_enabled) { + dev->modem_enabled = 1; + timer_advance_u64(&dev->sgd[4].poll_timer, dev->sgd[4].timer_latch); + timer_advance_u64(&dev->sgd[5].poll_timer, dev->sgd[5].timer_latch); + } + } else if (!dev->audio_codec) { + dev->audio_codec = codec; + if (val & 0x80) + ac97_via_update_codec(dev); + } + /* Read from or write to codec. */ if (val & 0x80) { if (val & 1) /* return 0x0000 on unaligned reads (real 686B behavior) */ @@ -790,6 +814,49 @@ ac97_via_poll_fm(void *priv) sgd->out_l = sgd->out_r = 0; } +static void +ac97_via_poll_modem(void *priv) +{ + ac97_via_sgd_t *sgd = (ac97_via_sgd_t *) priv; + ac97_via_t *dev = sgd->dev; + + /* Schedule next run if modem playback/capture is enabled. */ + if (dev->modem_enabled) + timer_advance_u64(&sgd->poll_timer, sgd->timer_latch); + + /* Update modem audio buffer. */ + ac97_via_update_stereo(dev, sgd); + + /* Feed next sample from the FIFO. + The data format is not documented, but it probes as 16-bit mono at the codec sample rate. */ + if ((sgd->fifo_end - sgd->fifo_pos) >= 2) { + sgd->out_l = sgd->out_r = AS_I16(sgd->fifo[sgd->fifo_pos & (sizeof(sgd->fifo) - 1)]); + sgd->fifo_pos += 2; + return; + } + + /* Feed silence if the FIFO is empty. */ + sgd->out_l = sgd->out_r = 0; +} + +static void +ac97_via_poll_modem_capture(void *priv) +{ + ac97_via_sgd_t *sgd = (ac97_via_sgd_t *) priv; + ac97_via_t *dev = sgd->dev; + + /* Schedule next run if modem playback/capture is enabled. */ + if (dev->modem_enabled) + timer_advance_u64(&sgd->poll_timer, sgd->timer_latch); + + /* Feed next sample into the FIFO. + The data format is not documented, but it probes as 16-bit mono at the codec sample rate. */ + if ((sgd->fifo_end - sgd->fifo_pos) >= 2) { + AS_I16(sgd->fifo[sgd->fifo_pos & (sizeof(sgd->fifo) - 1)]) = 0; + sgd->fifo_pos += 2; + } +} + static void ac97_via_get_buffer(int32_t *buffer, int len, void *priv) { @@ -826,16 +893,16 @@ ac97_via_speed_changed(void *priv) double freq; /* Get variable sample rate if enabled. */ - if (dev->vsr_enabled && dev->codec[0]) - freq = ac97_codec_getrate(dev->codec[0], 0x2c); + if (dev->vsr_enabled && dev->audio_codec) + freq = ac97_codec_getrate(dev->audio_codec, 0x2c); else freq = (double) SOUND_FREQ; dev->sgd[0].timer_latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / freq)); dev->sgd[2].timer_latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / 24000.0)); /* FM operates at a fixed 24 KHz */ - if (dev->codec[1]) - freq = ac97_codec_getrate(dev->codec[1], 0x40); + if (dev->modem_codec) + freq = ac97_codec_getrate(dev->modem_codec, 0x40); else freq = (double) SOUND_FREQ; @@ -860,7 +927,7 @@ ac97_via_init(UNUSED(const device_t *info)) dev->sgd[i].dev = dev; /* Disable the FIFO on SGDs we don't care about. */ - if ((i != 0) && (i != 2)) + if ((i != 0) && (i != 2) && (i != 4) && (i != 5)) dev->sgd[i].always_run = 1; timer_add(&dev->sgd[i].dma_timer, ac97_via_sgd_process, &dev->sgd[i], 0); @@ -869,6 +936,8 @@ ac97_via_init(UNUSED(const device_t *info)) /* Set up playback pollers. */ timer_add(&dev->sgd[0].poll_timer, ac97_via_poll_stereo, &dev->sgd[0], 0); timer_add(&dev->sgd[2].poll_timer, ac97_via_poll_fm, &dev->sgd[2], 0); + timer_add(&dev->sgd[4].poll_timer, ac97_via_poll_modem, &dev->sgd[4], 0); + timer_add(&dev->sgd[5].poll_timer, ac97_via_poll_modem_capture, &dev->sgd[5], 0); ac97_via_speed_changed(dev); /* Set up playback handler. */ From 52874686e5bb14d72f122f1e07cfd3481e06789f Mon Sep 17 00:00:00 2001 From: MaxwellS04 Date: Sun, 16 Nov 2025 13:27:32 +0700 Subject: [PATCH 72/89] Correct memory step for HP Ruby --- src/machine/machine_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 6fddc784c..cb2a9db0b 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14757,7 +14757,7 @@ const machine_t machines[] = { .ram = { .min = 8192, .max = 131072, - .step = 8192 + .step = 4096 }, .nvrmask = 255, .jumpered_ecp_dma = MACHINE_DMA_DISABLED | MACHINE_DMA_1 | MACHINE_DMA_3, From 316e14d5de1fa1dbef40b34568bd760d21ae0edb Mon Sep 17 00:00:00 2001 From: Thraka Date: Sat, 15 Nov 2025 23:03:53 -0800 Subject: [PATCH 73/89] Add option to show UI while in fullscreen --- src/86box.c | 5 +++++ src/include/86box/86box.h | 2 +- src/qt/qt_mainwindow.cpp | 17 +++++++++++++++++ src/qt/qt_mainwindow.hpp | 4 ++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/86box.c b/src/86box.c index fae30ca5e..069aea60c 100644 --- a/src/86box.c +++ b/src/86box.c @@ -286,6 +286,11 @@ struct accelKey def_acc_keys[NUM_ACCELS] = { .name="mute", .desc="Toggle mute", .seq="Ctrl+Alt+M" + }, + { + .name="toggle_ui_fullscreen", + .desc="Toggle UI in fullscreen", + .seq="Ctrl+Alt+PgDown" } }; diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 6c924e031..88acf5209 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -288,7 +288,7 @@ struct accelKey { char desc[64]; char seq[64]; }; -#define NUM_ACCELS 8 +#define NUM_ACCELS 9 extern struct accelKey acc_keys[NUM_ACCELS]; extern struct accelKey def_acc_keys[NUM_ACCELS]; extern int FindAccelerator(const char *name); diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 1dfae0920..0d11a68ae 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -1464,6 +1464,7 @@ MainWindow::on_actionFullscreen_triggered() if (!hide_tool_bar) ui->toolBar->show(); video_fullscreen = 0; + fullscreen_ui_visible = false; if (vid_resize != 1) { emit resizeContents(vid_resize == 2 ? fixed_size_x : monitors[0].mon_scrnsz_x, vid_resize == 2 ? fixed_size_y : monitors[0].mon_scrnsz_y); } @@ -1558,6 +1559,10 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event) || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("mute")) { ui->actionMute_Unmute->trigger(); } + if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("toggle_ui_fullscreen") + || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("toggle_ui_fullscreen")) { + toggleFullscreenUI(); + } return true; } @@ -2206,6 +2211,18 @@ MainWindow::on_actionUpdate_status_bar_icons_triggered() status->clearActivity(); } +void +MainWindow::toggleFullscreenUI() +{ + if (video_fullscreen == 0) + return; + + fullscreen_ui_visible ^= 1; + ui->menubar->setVisible(fullscreen_ui_visible); + ui->statusbar->setVisible(fullscreen_ui_visible && !hide_status_bar); + ui->toolBar->setVisible(fullscreen_ui_visible && !hide_tool_bar); +} + void MainWindow::on_actionTake_screenshot_triggered() { diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 916a254d0..4a0d50659 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -130,6 +130,7 @@ private slots: void on_actionHide_tool_bar_triggered(); void on_actionUpdate_status_bar_icons_triggered(); void on_actionTake_screenshot_triggered(); + void toggleFullscreenUI(); void on_actionMute_Unmute_triggered(); void on_actionSound_gain_triggered(); void on_actionPreferences_triggered(); @@ -197,6 +198,9 @@ private: /* Reload the renderers after closing renderer options dialog. */ bool reload_renderers = false; + /* Fullscreen UI visibility state */ + bool fullscreen_ui_visible = false; + friend class SpecifyDimensions; friend class ProgSettings; friend class RendererCommon; From e80dc4a541857a193468956a40685e6c4e41474d Mon Sep 17 00:00:00 2001 From: Thraka Date: Sat, 15 Nov 2025 23:16:54 -0800 Subject: [PATCH 74/89] Automatically release mouse; recapture mouse --- src/qt/qt_mainwindow.cpp | 14 ++++++++++++++ src/qt/qt_mainwindow.hpp | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 0d11a68ae..d5c3f26c4 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -2218,6 +2218,20 @@ MainWindow::toggleFullscreenUI() return; fullscreen_ui_visible ^= 1; + + if (fullscreen_ui_visible) { + // UI is being shown - save mouse capture state and release if captured + mouse_was_captured = (mouse_capture != 0); + if (mouse_was_captured) { + plat_mouse_capture(0); + } + } else { + // UI is being hidden - restore previous mouse capture state + if (mouse_was_captured) { + plat_mouse_capture(1); + } + } + ui->menubar->setVisible(fullscreen_ui_visible); ui->statusbar->setVisible(fullscreen_ui_visible && !hide_status_bar); ui->toolBar->setVisible(fullscreen_ui_visible && !hide_tool_bar); diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 4a0d50659..9bec1a049 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -201,6 +201,9 @@ private: /* Fullscreen UI visibility state */ bool fullscreen_ui_visible = false; + /* Mouse capture state before showing fullscreen UI */ + bool mouse_was_captured = false; + friend class SpecifyDimensions; friend class ProgSettings; friend class RendererCommon; From 07dbe2dbb7999a4ae375afefccf5909f8d1c9a95 Mon Sep 17 00:00:00 2001 From: Kotochi <185547947+rushieda@users.noreply.github.com> Date: Sun, 16 Nov 2025 10:50:50 +0300 Subject: [PATCH 75/89] Change the max. RAM limit on HP Ruby USB and AOpen AP61 --- src/machine/machine_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index cb2a9db0b..b4a6a1aca 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14756,7 +14756,7 @@ const machine_t machines[] = { .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_SOUND | MACHINE_GAMEPORT | MACHINE_APM | MACHINE_USB, .ram = { .min = 8192, - .max = 131072, + .max = 524288, .step = 4096 }, .nvrmask = 255, @@ -17299,7 +17299,7 @@ const machine_t machines[] = { .flags = MACHINE_IDE_DUAL | MACHINE_APM, .ram = { .min = 8192, - .max = 524288, + .max = 262144, .step = 8192 }, .nvrmask = 127, From 99fc7ae5c895f61f877e02e6ce4878ec2b54cfdf Mon Sep 17 00:00:00 2001 From: Kotochi <185547947+rushieda@users.noreply.github.com> Date: Sun, 16 Nov 2025 22:10:47 +0300 Subject: [PATCH 76/89] Add the HP Pavilion 52xx/53xx/71xx/72xx (BCM FM562) --- src/include/86box/machine.h | 1 + src/machine/m_at_socket7_3v.c | 31 ++++++++++++++++++++++++ src/machine/machine_table.c | 44 +++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index c8271c674..941286e0f 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -1026,6 +1026,7 @@ extern int machine_at_amis727_init(const machine_t *); extern const device_t ap5s_device; #endif extern int machine_at_ap5s_init(const machine_t *); +extern int machine_at_fm562_init(const machine_t *); extern int machine_at_pc140_6260_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t ms5124_device; diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index b85025cc9..c3672c8e6 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -1596,6 +1596,37 @@ machine_at_ap5s_init(const machine_t *model) return ret; } +int +machine_at_fm562_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear("roms/machines/fm562/PR11_US.ROM", + 0x000e0000, 131072, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init_ex(model, 2); + + pci_init(PCI_CONFIG_TYPE_1 | FLAG_TRC_CONTROLS_CPURST); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 1, 2, 3, 4); + pci_register_slot(0x01, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 3, 2, 4); + pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 1, 3, 4); + pci_register_slot(0x0B, PCI_CARD_VIDEO, 0, 0, 0, 0); /* Onboard video */ + + if (sound_card_current[0] == SOUND_INTERNAL) + machine_snd = device_add(machine_get_snd_device(machine)); + + device_add(&sis_5511_device); + device_add_params(machine_get_kbc_device(machine), (void *) model->kbc_params); + device_add_params(&fdc37c669_device, (void *) 0); + device_add(&intel_flash_bxt_device); + + return ret; +} + int machine_at_pc140_6260_init(const machine_t *model) { diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index b4a6a1aca..ca1da6372 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14323,6 +14323,50 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + /* Has AMIKey H KBC firmware (AMIKey-2). */ + { + .name = "[SiS 5511] HP Pavilion 52xx/53xx/71xx/72xx (BCM FM562)", + .internal_name = "fm562", + .type = MACHINE_TYPE_SOCKET7_3V, + .chipset = MACHINE_CHIPSET_SIS_5511, + .init = machine_at_fm562_init, + .p1_handler = machine_generic_p1_handler, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET5_7, + .block = CPU_BLOCK(CPU_Cx6x86, CPU_Cx6x86L, CPU_Cx6x86MX), + .min_bus = 50000000, + .max_bus = 66666667, + .min_voltage = 3380, + .max_voltage = 3520, + .min_multi = 1.5, + .max_multi = 2.5 + }, + .bus_flags = MACHINE_PS2_PCI, + .flags = MACHINE_IDE_DUAL | MACHINE_SOUND | MACHINE_GAMEPORT | MACHINE_APM, /* Machine has internal sound: Crystal CS4232-KQ, and video: SiS 6205 (not yet emulated) */ + .ram = { + .min = 8192, + .max = 524288, + .step = 8192 + }, + .nvrmask = 127, + .jumpered_ecp_dma = 0, + .default_jumpered_ecp_dma = -1, + .kbc_device = &kbc_at_device, + .kbc_params = KBC_VEN_AMI | 0x00004800, + .kbc_p1 = 0x00000cf0, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .kbd_device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = &cs4232_onboard_device, + .net_device = NULL + }, /* Has an SMC FDC37C669QF Super I/O. */ { .name = "[SiS 5511] IBM PC 140 (type 6260)", From 3d9f31e85f05c1c54716cf37678fac52be9a0a96 Mon Sep 17 00:00:00 2001 From: Thraka Date: Sun, 16 Nov 2025 12:02:27 -0800 Subject: [PATCH 77/89] Move to C var; handle keyboard/mouse fullscreen conditions --- src/device/keyboard.c | 2 +- src/device/mouse_bus.c | 4 ++-- src/device/mouse_ps2.c | 2 +- src/include/86box/plat.h | 1 + src/qt/qt_mainwindow.cpp | 6 ++++-- src/qt/qt_mainwindow.hpp | 3 --- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/device/keyboard.c b/src/device/keyboard.c index 7806418dd..e77a5fc1d 100644 --- a/src/device/keyboard.c +++ b/src/device/keyboard.c @@ -372,7 +372,7 @@ keyboard_input(int down, uint16_t scan) /* kbc_at_log("Received scan code: %03X (%s)\n", scan & 0x1ff, down ? "down" : "up"); */ recv_key_ui[scan & 0x1ff] = down; - if (mouse_capture || !kbd_req_capture || video_fullscreen) { + if (mouse_capture || !kbd_req_capture || (video_fullscreen && !fullscreen_ui_visible)) { recv_key[scan & 0x1ff] = down; key_process(scan & 0x1ff, down); } diff --git a/src/device/mouse_bus.c b/src/device/mouse_bus.c index cd54f981a..52f7154a0 100644 --- a/src/device/mouse_bus.c +++ b/src/device/mouse_bus.c @@ -481,7 +481,7 @@ bm_poll(void *priv) int xor; int b = mouse_get_buttons_ex(); - if (!mouse_capture && !video_fullscreen) + if (!mouse_capture && !(video_fullscreen && !fullscreen_ui_visible)) return 1; if (!(dev->flags & FLAG_ENABLED)) @@ -543,7 +543,7 @@ bm_update_data(mouse_t *dev) int xor; /* If the counters are not frozen, update them. */ - if ((mouse_capture || video_fullscreen) && !(dev->flags & FLAG_HOLD)) { + if ((mouse_capture || (video_fullscreen && !fullscreen_ui_visible)) && !(dev->flags & FLAG_HOLD)) { /* Update the deltas and the delays. */ mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0); diff --git a/src/device/mouse_ps2.c b/src/device/mouse_ps2.c index 80d9f3876..9034d9322 100644 --- a/src/device/mouse_ps2.c +++ b/src/device/mouse_ps2.c @@ -332,7 +332,7 @@ ps2_poll(void *priv) atkbc_dev_t *dev = (atkbc_dev_t *) priv; int packet_size = (dev->flags & FLAG_INTMODE) ? 4 : 3; - int cond = (mouse_capture || video_fullscreen) && mouse_scan && (dev->mode == MODE_STREAM) && + int cond = (mouse_capture || (video_fullscreen && !fullscreen_ui_visible)) && mouse_scan && (dev->mode == MODE_STREAM) && mouse_state_changed() && (kbc_at_dev_queue_pos(dev, 1) < (FIFO_SIZE - packet_size)); if (cond) diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index e18aa707b..7835fe3a2 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -132,6 +132,7 @@ extern int update_icons; extern int kbd_req_capture; extern int hide_status_bar; extern int hide_tool_bar; +extern int fullscreen_ui_visible; /* System-related functions. */ extern FILE *plat_fopen(const char *path, const char *mode); diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index d5c3f26c4..44bf1269e 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -67,6 +67,8 @@ extern int qt_nvr_save(void); extern bool cpu_thread_running; }; +int fullscreen_ui_visible = 0; + #include #include #include @@ -1297,7 +1299,7 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode) case 0x10b: /* Microsoft scroll up normal */ case 0x180 ... 0x1ff: /* E0 break codes (including Microsoft scroll down normal) */ /* This key uses a break code as make. Send it manually, only on press. */ - if (down && (mouse_capture || !kbd_req_capture || video_fullscreen)) { + if (down && (mouse_capture || !kbd_req_capture || (video_fullscreen && !fullscreen_ui_visible))) { if (keycode & 0x100) keyboard_send(0xe0); keyboard_send(keycode & 0xff); @@ -1464,7 +1466,7 @@ MainWindow::on_actionFullscreen_triggered() if (!hide_tool_bar) ui->toolBar->show(); video_fullscreen = 0; - fullscreen_ui_visible = false; + fullscreen_ui_visible = 0; if (vid_resize != 1) { emit resizeContents(vid_resize == 2 ? fixed_size_x : monitors[0].mon_scrnsz_x, vid_resize == 2 ? fixed_size_y : monitors[0].mon_scrnsz_y); } diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 9bec1a049..1a1cf4f20 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -198,9 +198,6 @@ private: /* Reload the renderers after closing renderer options dialog. */ bool reload_renderers = false; - /* Fullscreen UI visibility state */ - bool fullscreen_ui_visible = false; - /* Mouse capture state before showing fullscreen UI */ bool mouse_was_captured = false; From 48b696581a3d8e1e2f36892a4d55b32ddfc5ec2d Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 16 Nov 2025 18:18:29 -0300 Subject: [PATCH 78/89] VIA AC97: Remove some redundant logging --- src/sound/snd_ac97_via.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/sound/snd_ac97_via.c b/src/sound/snd_ac97_via.c index 6947c222d..f1ddc5f92 100644 --- a/src/sound/snd_ac97_via.c +++ b/src/sound/snd_ac97_via.c @@ -535,8 +535,6 @@ ac97_via_codec_read(uint16_t addr, void *priv) ret = dev->codec_shadow[addr]; - ac97_via_log("AC97 VIA %d: codec_read(%02X) = %02X\n", modem, addr, ret); - ac97_via_log("[%04X:%08X] [%i] AC97 VIA %d: codec_read(%02X) = %02X\n", CS, cpu_state.pc, msw & 1, modem, addr, ret); return ret; @@ -553,8 +551,6 @@ ac97_via_codec_write(uint16_t addr, uint8_t val, void *priv) ac97_via_log("[%04X:%08X] [%i] AC97 VIA %d: codec_write(%02X, %02X)\n", CS, cpu_state.pc, msw & 1, modem, addr, val); - ac97_via_log("AC97 VIA %d: codec_write(%02X, %02X)\n", modem, addr, val); - /* Unknown behavior, maybe it does write to the shadow registers? */ dev->codec_shadow[addr] = val; } From 8d8d5708f57f8ff7929318e91203a109af4abb34 Mon Sep 17 00:00:00 2001 From: Thraka Date: Sun, 16 Nov 2025 17:51:24 -0800 Subject: [PATCH 79/89] Move variable declaration out of plat to general --- src/86box.c | 1 + src/qt/qt_mainwindow.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/86box.c b/src/86box.c index 069aea60c..fa7be14fe 100644 --- a/src/86box.c +++ b/src/86box.c @@ -171,6 +171,7 @@ int vid_api = 0; /* (C) video r int vid_cga_contrast = 0; /* (C) video */ int video_fullscreen = 0; /* (C) video */ int video_fullscreen_scale = 0; /* (C) video */ +int fullscreen_ui_visible = 0; /* (C) video */ int enable_overscan = 0; /* (C) video */ int force_43 = 0; /* (C) video */ int video_filter_method = 1; /* (C) video */ diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 44bf1269e..87415ba07 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -67,8 +67,6 @@ extern int qt_nvr_save(void); extern bool cpu_thread_running; }; -int fullscreen_ui_visible = 0; - #include #include #include From 03bbc3ed41bcafe8d3c98c62355da9d1ebc12140 Mon Sep 17 00:00:00 2001 From: MaxwellS04 Date: Tue, 18 Nov 2025 14:30:29 +0700 Subject: [PATCH 80/89] Make GD-7500 and GSA-4160 support DVD --- src/include/86box/cdrom.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/86box/cdrom.h b/src/include/86box/cdrom.h index 5a6c0914d..89fb5806d 100644 --- a/src/include/86box/cdrom.h +++ b/src/include/86box/cdrom.h @@ -143,9 +143,9 @@ static const struct cdrom_drive_types_s { { "GOLDSTAR", "GCD-R560B", "1.00", "goldstar_r560b", BUS_TYPE_IDE, 0, 6, 36, 0, 0, { 4, 2, 2, -1 } }, { "HITACHI", "CDR-8130", "0020", "hitachi_r8130", BUS_TYPE_IDE, 0, 16, 36, 0, 0, { 4, 2, 2, -1 } }, { "HITACHI", "CDR-8435", "0010", "hitachi_r8435", BUS_TYPE_IDE, 0, 32, 36, 0, 0, { 4, 2, 2, -1 } }, - { "HITACHI", "GD-7500", "A1 ", "hitachi_7500", BUS_TYPE_IDE, 0, 40, 36, 0, 0, { 4, 2, 2, 2 } }, /* DVD. */ + { "HITACHI", "GD-7500", "A1 ", "hitachi_7500", BUS_TYPE_IDE, 0, 40, 36, 0, 1, { 4, 2, 2, 2 } }, /* DVD. */ { "HL-DT-ST", "CD-ROM GCR-8526B", "1.01", "hldtst_8526b", BUS_TYPE_IDE, 0, 52, 36, 0, 0, { 4, 2, 2, 2 } }, - { "HL-DT-ST", "DVDRAM GSA-4160", "A302", "hldtst_4160", BUS_TYPE_IDE, 0, 40, 36, 0, 0, { 4, 2, 2, 2 } }, + { "HL-DT-ST", "DVDRAM GSA-4160", "A302", "hldtst_4160", BUS_TYPE_IDE, 0, 40, 36, 0, 1, { 4, 2, 2, 2 } }, { "KENWOOD", "CD-ROM UCR-421", "208E", "kenwood_421", BUS_TYPE_IDE, 0, 72, 36, 0, 0, { 4, 2, 2, 4 } }, /* This is a laptop/notebook drive, as is also evident from the name: From db5bccd97b21c9f7af121d2ef6457fc50a4d3304 Mon Sep 17 00:00:00 2001 From: richardg867 Date: Tue, 18 Nov 2025 13:52:16 -0300 Subject: [PATCH 81/89] Fix a couple internal names on MS-6147 --- src/machine/m_at_slot1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index c85c20711..0c4be2249 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -888,7 +888,7 @@ static const device_config_t ms6147_config[] = { .bios = { { .name = "Award Modular BIOS v4.51PG - Revision 1.2 (Fujitsu ErgoPro e368)", - .internal_name = "ergopro_e368", + .internal_name = "ergoproe368", .bios_type = BIOS_NORMAL, .files_no = 1, .local = 0, @@ -922,7 +922,7 @@ static const device_config_t ms6147_config[] = { const device_t ms6147_device = { .name = "MSI MS-6147", - .internal_name = "ms6147_device", + .internal_name = "ms6147", .flags = 0, .local = 0, .init = NULL, From 43ca65bf04d052608a527d4678e85ef215232ad2 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 19 Nov 2025 17:15:45 -0300 Subject: [PATCH 82/89] AC97 Codec: Devbranch some non-working stuff --- CMakeLists.txt | 1 + src/include/86box/snd_ac97.h | 2 ++ src/sound/CMakeLists.txt | 4 ++++ src/sound/snd_ac97_codec.c | 4 ++++ src/sound/sound.c | 2 ++ 5 files changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f6c18af0..3004b3711 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,7 @@ cmake_dependent_option(WACOM "Wacom Input Devices" cmake_dependent_option(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF) cmake_dependent_option(NETSWITCH "Network Switch Support" ON "DEV_BRANCH" OFF) cmake_dependent_option(VFIO "Virtual Function I/O" ON "DEV_BRANCH" OFF) +cmake_dependent_option(SOFTMODEM "AC'97 Softmodem" ON "DEV_BRANCH" OFF) # Ditto but for Qt if(QT) diff --git a/src/include/86box/snd_ac97.h b/src/include/86box/snd_ac97.h index d8f2f6953..0bad4efa0 100644 --- a/src/include/86box/snd_ac97.h +++ b/src/include/86box/snd_ac97.h @@ -166,7 +166,9 @@ extern const device_t stac9721_device; extern const device_t tr28023_device; extern const device_t w83971d_device; extern const device_t wm9701a_device; +#ifdef USE_SOFTMODEM extern const device_t si3036_device; +#endif extern const device_t ac97_via_device; #endif diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index ccb54ab19..a6a9b691a 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -192,6 +192,10 @@ if(OPL4ML) target_compile_definitions(snd PRIVATE USE_OPL4ML) target_sources(snd PRIVATE midi_opl4.c midi_opl4_yrw801.c) endif() + +if(SOFTMODEM) + target_compile_definitions(snd PRIVATE USE_SOFTMODEM) +endif() find_package(PkgConfig) pkg_check_modules(SERIALPORT libserialport) diff --git a/src/sound/snd_ac97_codec.c b/src/sound/snd_ac97_codec.c index 04abab305..071356873 100644 --- a/src/sound/snd_ac97_codec.c +++ b/src/sound/snd_ac97_codec.c @@ -114,6 +114,7 @@ static const struct { .reset_flags = AC97_DAC_18B | AC97_ADC_18B, .pcsr_mask = 0x3f }, +#ifdef USE_SOFTMODEM { .device = &si3036_device, .misc_flags = AC97_MODEM | AC97_GAIN_3B, @@ -124,6 +125,7 @@ static const struct { .gpo_mask = 0xfc3f, .vendor_regs = (const ac97_vendor_reg_t[]) {{0, 0x5a, 0x0142, 0x0000}, {0, 0x5c, 0xf010, 0xfefd}, {0, 0x5e, 0x004c, 0x0000}, {0, 0x62, 0x0000, 0x01f8}, {0, 0x64, 0x0080, 0x0000}, {0}} } +#endif // clang-format on }; @@ -958,6 +960,7 @@ const device_t wm9701a_device = { .config = NULL }; +#ifdef USE_SOFTMODEM const device_t si3036_device = { .name = "Silicon Laboratories Si3036 Modem", .internal_name = "si3036", @@ -971,3 +974,4 @@ const device_t si3036_device = { .force_redraw = NULL, .config = NULL }; +#endif diff --git a/src/sound/sound.c b/src/sound/sound.c index 94a11ad00..4d9675441 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -187,7 +187,9 @@ static const SOUND_CARD sound_cards[] = { /* AC97 */ { &ad1881_device }, { &cs4297a_device }, +#ifdef USE_SOFTMODEM { &si3036_device }, +#endif { NULL } // clang-format on }; From c7687ae7a9985c38f6f07879b73c11cc79a2c9dc Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 21 Nov 2025 00:09:57 +0100 Subject: [PATCH 83/89] All image paths in 86box.cfg within exe_path but outside usr_path (VM path) are now stored relative with "" prefix to indicate what they are relative to, making configurations more portable. --- src/config.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index a0ef1c9e7..79de627b9 100644 --- a/src/config.c +++ b/src/config.c @@ -961,7 +961,14 @@ load_image_file(char *dest, char *p, uint8_t *ui_wp) } else if ((ui_wp != NULL) && *ui_wp) prefix = "wp://"; - if (path_abs(p)) { + if (memcmp(p, "/", strlen("/")) == 0) { + if ((strlen(prefix) + strlen(exe_path) + strlen(path_get_slash(exe_path)) + strlen(p + strlen("/"))) > + (MAX_IMAGE_PATH_LEN - 11)) + ret = 1; + else + snprintf(dest, MAX_IMAGE_PATH_LEN, "%s%s%s%s", prefix, exe_path, path_get_slash(exe_path), + p + strlen("/")); + } else if (path_abs(p)) { if ((strlen(prefix) + strlen(p)) > (MAX_IMAGE_PATH_LEN - 11)) ret = 1; else @@ -3063,6 +3070,8 @@ save_image_file(char *cat, char *var, char *src) if (!strnicmp(src, usr_path, strlen(usr_path))) sprintf(temp, "%s%s", prefix, &src[strlen(usr_path)]); + else if (!strnicmp(src, exe_path, strlen(exe_path))) + sprintf(temp, "/%s%s", prefix, &src[strlen(exe_path)]); else sprintf(temp, "%s%s", prefix, src); From 3d9f34bd29bd8c3d7b498f0387dfafc08b5b0da8 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 21 Nov 2025 00:51:00 +0100 Subject: [PATCH 84/89] Configuration: Added support for .. indicating path relative to path one level above the VM path. --- src/config.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/config.c b/src/config.c index 79de627b9..63e7fb3fa 100644 --- a/src/config.c +++ b/src/config.c @@ -947,11 +947,35 @@ load_ports(void) #endif } +static char * +memrmem(char *src, char *start, char *what) +{ + if ((src == NULL) || (what == NULL)) + return NULL; + + while (1) { + if (memcmp(src, what, strlen(what)) == 0) + return src; + src--; + if (src < start) + return NULL; + } +} + static int load_image_file(char *dest, char *p, uint8_t *ui_wp) { char *prefix = ""; int ret = 0; + char *slash = NULL; + char *above = NULL; + char *use = NULL; + + if ((slash = memrmem(usr_path + strlen(usr_path) - 2, usr_path, "/")) != NULL) { + slash++; + above = (char *) calloc(1, slash - usr_path + 1); + memcpy(above, usr_path, slash - usr_path); + } if (strstr(p, "wp://") == p) { p += 5; @@ -968,6 +992,13 @@ load_image_file(char *dest, char *p, uint8_t *ui_wp) else snprintf(dest, MAX_IMAGE_PATH_LEN, "%s%s%s%s", prefix, exe_path, path_get_slash(exe_path), p + strlen("/")); + } else if (memcmp(p, "../", strlen("../")) == 0) { + use = (above == NULL) ? usr_path : above; + if ((strlen(prefix) + strlen(use) + strlen(path_get_slash(use)) + strlen(p + strlen("../"))) > + (MAX_IMAGE_PATH_LEN - 11)) + ret = 1; + else + snprintf(dest, MAX_IMAGE_PATH_LEN, "%s%s%s%s", prefix, use, path_get_slash(use), p + strlen("../")); } else if (path_abs(p)) { if ((strlen(prefix) + strlen(p)) > (MAX_IMAGE_PATH_LEN - 11)) ret = 1; @@ -982,6 +1013,9 @@ load_image_file(char *dest, char *p, uint8_t *ui_wp) path_normalize(dest); + if (above != NULL) + free(above); + return ret; } @@ -3060,6 +3094,14 @@ save_image_file(char *cat, char *var, char *src) { char temp[2048] = { 0 }; char *prefix = ""; + char *slash = NULL; + char *above = NULL; + + if ((slash = memrmem(usr_path + strlen(usr_path) - 2, usr_path, "/")) != NULL) { + slash++; + above = (char *) calloc(1, slash - usr_path + 1); + memcpy(above, usr_path, slash - usr_path); + } path_normalize(src); @@ -3070,12 +3112,17 @@ save_image_file(char *cat, char *var, char *src) if (!strnicmp(src, usr_path, strlen(usr_path))) sprintf(temp, "%s%s", prefix, &src[strlen(usr_path)]); + else if ((above != NULL) && !strnicmp(src, above, strlen(above))) + sprintf(temp, "../%s%s", prefix, &src[strlen(above)]); else if (!strnicmp(src, exe_path, strlen(exe_path))) sprintf(temp, "/%s%s", prefix, &src[strlen(exe_path)]); else sprintf(temp, "%s%s", prefix, src); ini_section_set_string(cat, var, temp); + + if (above != NULL) + free(above); } /* Save "Storage Controllers" section. */ From 642b2e161d68a583fd5253c5515625062c6e9a11 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 21 Nov 2025 01:11:59 +0100 Subject: [PATCH 85/89] Config: Use the correct path relativization for hard disk and CD-ROM image as well. --- src/config.c | 89 +++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 49 deletions(-) diff --git a/src/config.c b/src/config.c index 63e7fb3fa..6e6791f8d 100644 --- a/src/config.c +++ b/src/config.c @@ -985,6 +985,18 @@ load_image_file(char *dest, char *p, uint8_t *ui_wp) } else if ((ui_wp != NULL) && *ui_wp) prefix = "wp://"; + if (strstr(p, "ioctl://") == p) { + if (strlen(p) > (MAX_IMAGE_PATH_LEN - 11)) + ret = 1; + else + snprintf(dest, MAX_IMAGE_PATH_LEN, "%s", p); + + if (above != NULL) + free(above); + + return ret; + } + if (memcmp(p, "/", strlen("/")) == 0) { if ((strlen(prefix) + strlen(exe_path) + strlen(path_get_slash(exe_path)) + strlen(p + strlen("/"))) > (MAX_IMAGE_PATH_LEN - 11)) @@ -1374,17 +1386,15 @@ load_hard_disks(void) p[0] = 0x00; if (p[0] != 0x00) { - if (path_abs(p)) { - if (strlen(p) > 511) - fatal("Configuration: Length of hdd_%02i_fn is more " - "than 511\n", c + 1); - else - strncpy(hdd[c].fn, p, 511); - } else - path_append_filename(hdd[c].fn, usr_path, p); - path_normalize(hdd[c].fn); + if (load_image_file(hdd[c].fn, p, NULL)) + fatal("Configuration: Length of hdd_%02i_fn is more than 511\n", c + 1); } +#if defined(ENABLE_CONFIG_LOG) && (ENABLE_CONFIG_LOG == 2) + if (*p != '\0') + config_log("HDD%d: %ls\n", c, hdd[c].fn); +#endif + sprintf(temp, "hdd_%02i_vhd_blocksize", c + 1); hdd[c].vhd_blocksize = ini_section_get_int(cat, temp, 0); @@ -1472,6 +1482,7 @@ load_floppy_and_cdrom_drives(void) if (*p != '\0') config_log("Floppy%d: %ls\n", c, floppyfns[c]); #endif + sprintf(temp, "fdd_%02i_turbo", c + 1); fdd_set_turbo(c, !!ini_section_get_int(cat, temp, 0)); sprintf(temp, "fdd_%02i_check_bpb", c + 1); @@ -1627,31 +1638,23 @@ load_floppy_and_cdrom_drives(void) p[0] = 0x00; if (p[0] != 0x00) { - if (path_abs(p)) { - if (strlen(p) > 511) - fatal("Configuration: Length of cdrom_%02i_image_path is more than 511\n", c + 1); - else - strncpy(cdrom[c].image_path, p, 511); - } else - path_append_filename(cdrom[c].image_path, usr_path, p); - path_normalize(cdrom[c].image_path); + if (load_image_file(cdrom[c].image_path, p, NULL)) + fatal("Configuration: Length of cdrom_%02i_image_path is more than 511\n", c + 1); } +#if defined(ENABLE_CONFIG_LOG) && (ENABLE_CONFIG_LOG == 2) + if (*p != '\0') + config_log("CD-ROM%d: %ls\n", c, cdrom[c].image_path); +#endif + for (int i = 0; i < MAX_PREV_IMAGES; i++) { cdrom[c].image_history[i] = (char *) calloc((MAX_IMAGE_PATH_LEN + 1) << 1, sizeof(char)); sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1); p = ini_section_get_string(cat, temp, NULL); if (p) { - if (path_abs(p)) { - if (strlen(p) > (MAX_IMAGE_PATH_LEN - 1)) - fatal("Configuration: Length of cdrom_%02i_image_history_%02i is more " - "than %i\n", c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1); - else - snprintf(cdrom[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s", p); - } else - snprintf(cdrom[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, - path_get_slash(usr_path), p); - path_normalize(cdrom[c].image_history[i]); + if (load_image_file(cdrom[c].image_history[i], p, NULL)) + fatal("Configuration: Length of cdrom_%02i_image_history_%02i is more " + "than %i\n", c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1); } } @@ -3110,7 +3113,9 @@ save_image_file(char *cat, char *var, char *src) prefix = "wp://"; } - if (!strnicmp(src, usr_path, strlen(usr_path))) + if (strstr(src, "ioctl://") == src) + sprintf(temp, "%s", src); + else if (!strnicmp(src, usr_path, strlen(usr_path))) sprintf(temp, "%s%s", prefix, &src[strlen(usr_path)]); else if ((above != NULL) && !strnicmp(src, above, strlen(above))) sprintf(temp, "../%s%s", prefix, &src[strlen(above)]); @@ -3431,13 +3436,9 @@ save_hard_disks(void) } sprintf(temp, "hdd_%02i_fn", c + 1); - if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0)) { - path_normalize(hdd[c].fn); - if (!strnicmp(hdd[c].fn, usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &hdd[c].fn[strlen(usr_path)]); - else - ini_section_set_string(cat, temp, hdd[c].fn); - } else + if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0)) + save_image_file(cat, temp, hdd[c].fn); + else ini_section_delete_var(cat, temp); sprintf(temp, "hdd_%02i_vhd_blocksize", c + 1); @@ -3598,25 +3599,15 @@ save_floppy_and_cdrom_drives(void) sprintf(temp, "cdrom_%02i_image_path", c + 1); if ((cdrom[c].bus_type == 0) || (strlen(cdrom[c].image_path) == 0)) ini_section_delete_var(cat, temp); - else { - path_normalize(cdrom[c].image_path); - if (!strnicmp(cdrom[c].image_path, usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &cdrom[c].image_path[strlen(usr_path)]); - else - ini_section_set_string(cat, temp, cdrom[c].image_path); - } + else + save_image_file(cat, temp, cdrom[c].image_path); for (int i = 0; i < MAX_PREV_IMAGES; i++) { sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1); if ((cdrom[c].image_history[i] == 0) || strlen(cdrom[c].image_history[i]) == 0) ini_section_delete_var(cat, temp); - else { - path_normalize(cdrom[c].image_history[i]); - if (!strnicmp(cdrom[c].image_history[i], usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &cdrom[c].image_history[i][strlen(usr_path)]); - else - ini_section_set_string(cat, temp, cdrom[c].image_history[i]); - } + else + save_image_file(cat, temp, cdrom[c].image_history[i]); } } From de4aa4aaf42adb2432161aac4e5f8ce242110e90 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 21 Nov 2025 01:15:33 +0100 Subject: [PATCH 86/89] And cartridge as well. --- src/config.c | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/config.c b/src/config.c index 6e6791f8d..86dc95cca 100644 --- a/src/config.c +++ b/src/config.c @@ -1197,15 +1197,8 @@ load_storage_controllers(void) p[0] = 0x00; if (p[0] != 0x00) { - if (path_abs(p)) { - if (strlen(p) > 511) - fatal("Configuration: Length of cartridge_%02i_fn is more than 511\n", - c + 1); - else - strncpy(cart_fns[c], p, 511); - } else - path_append_filename(cart_fns[c], usr_path, p); - path_normalize(cart_fns[c]); + if (load_image_file(cart_fns[c], p, NULL)) + fatal("Configuration: Length of cartridge_%02i_fn is more than 511\n", c + 1); } for (int i = 0; i < MAX_PREV_IMAGES; i++) { @@ -1213,16 +1206,9 @@ load_storage_controllers(void) sprintf(temp, "cartridge_%02i_image_history_%02i", c + 1, i + 1); p = ini_section_get_string(cat, temp, NULL); if (p) { - if (path_abs(p)) { - if (strlen(p) > (MAX_IMAGE_PATH_LEN - 1)) - fatal("Configuration: Length of cartridge_%02i_image_history_%02i " - "is more than %i\n", c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1); - else - snprintf(cart_image_history[c][i], MAX_IMAGE_PATH_LEN, "%s", p); - } else - snprintf(cart_image_history[c][i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, - path_get_slash(usr_path), p); - path_normalize(cart_image_history[c][i]); + if (load_image_file(cart_image_history[c][i], p, NULL)) + fatal("Configuration: Length of cartridge_%02i_image_history_%02i " + "is more than %i\n", c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1); } } } @@ -3247,25 +3233,15 @@ save_storage_controllers(void) if (strlen(cart_fns[c]) == 0) ini_section_delete_var(cat, temp); - else { - path_normalize(cart_fns[c]); - if (!strnicmp(cart_fns[c], usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &cart_fns[c][strlen(usr_path)]); - else - ini_section_set_string(cat, temp, cart_fns[c]); - } + else + save_image_file(cat, temp, cart_fns[c]); for (int i = 0; i < MAX_PREV_IMAGES; i++) { sprintf(temp, "cartridge_%02i_image_history_%02i", c + 1, i + 1); if ((cart_image_history[c][i] == 0) || strlen(cart_image_history[c][i]) == 0) ini_section_delete_var(cat, temp); - else { - path_normalize(cart_image_history[c][i]); - if (!strnicmp(cart_image_history[c][i], usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &cart_image_history[c][i][strlen(usr_path)]); - else - ini_section_set_string(cat, temp, cart_image_history[c][i]); - } + else + save_image_file(cat, temp, cart_image_history[c][i]); } } From c4f97f453a8a483e5b218e3b57b99aaf8ba05747 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 21 Nov 2025 03:16:12 +0100 Subject: [PATCH 87/89] DEC Tulip and L80225 MII: Some improvements. --- src/network/net_l80225.c | 11 ++++++++++- src/network/net_tulip.c | 39 ++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/network/net_l80225.c b/src/network/net_l80225.c index 6493edec6..341799e57 100644 --- a/src/network/net_l80225.c +++ b/src/network/net_l80225.c @@ -34,8 +34,17 @@ l80225_mii_readw(uint16_t *regs, uint16_t addr) return 0; } +/* Readonly mask for MDI (PHY) registers */ +static const uint16_t tulip_mdi_mask[] = { + 0x0000, 0xffff, 0xffff, 0xffff, 0xc01f, 0xffff, 0xffff, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0fff, 0x0000, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + +}; + void l80225_mii_writew(uint16_t *regs, uint16_t addr, uint16_t val) { - regs[addr] = val; + regs[addr] = val & tulip_mdi_mask[addr]; } diff --git a/src/network/net_tulip.c b/src/network/net_tulip.c index a575a4cfb..f93ac8767 100644 --- a/src/network/net_tulip.c +++ b/src/network/net_tulip.c @@ -346,10 +346,10 @@ static void tulip_desc_read(TULIPState *s, uint32_t p, struct tulip_descriptor *desc) { - desc->status = mem_readl_phys(p); - desc->control = mem_readl_phys(p + 4); - desc->buf_addr1 = mem_readl_phys(p + 8); - desc->buf_addr2 = mem_readl_phys(p + 12); + dma_bm_read(p , (uint8_t *) &(desc->status) , 4, 4); + dma_bm_read(p + 4, (uint8_t *) &(desc->control) , 4, 4); + dma_bm_read(p + 8, (uint8_t *) &(desc->buf_addr1), 4, 4); + dma_bm_read(p + 12, (uint8_t *) &(desc->buf_addr2), 4, 4); if (s->csr[0] & CSR0_DBO) { bswap32s(&desc->status); @@ -364,15 +364,20 @@ tulip_desc_write(TULIPState *s, uint32_t p, struct tulip_descriptor *desc) { if (s->csr[0] & CSR0_DBO) { - mem_writel_phys(p, bswap32(desc->status)); - mem_writel_phys(p + 4, bswap32(desc->control)); - mem_writel_phys(p + 8, bswap32(desc->buf_addr1)); - mem_writel_phys(p + 12, bswap32(desc->buf_addr2)); + uint32_t status = bswap32(desc->status); + uint32_t control = bswap32(desc->control); + uint32_t buf_addr1 = bswap32(desc->buf_addr1); + uint32_t buf_addr2 = bswap32(desc->buf_addr2); + + dma_bm_write(p , (uint8_t *) &status , 4, 4); + dma_bm_write(p + 4, (uint8_t *) &control , 4, 4); + dma_bm_write(p + 8, (uint8_t *) &buf_addr1, 4, 4); + dma_bm_write(p + 12, (uint8_t *) &buf_addr2, 4, 4); } else { - mem_writel_phys(p, desc->status); - mem_writel_phys(p + 4, desc->control); - mem_writel_phys(p + 8, desc->buf_addr1); - mem_writel_phys(p + 12, desc->buf_addr2); + dma_bm_write(p , (uint8_t *) &(desc->status) , 4, 4); + dma_bm_write(p + 4, (uint8_t *) &(desc->control) , 4, 4); + dma_bm_write(p + 8, (uint8_t *) &(desc->buf_addr1), 4, 4); + dma_bm_write(p + 12, (uint8_t *) &(desc->buf_addr2), 4, 4); } } @@ -433,6 +438,10 @@ tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc) len = s->rx_frame_len; } + if (s->rx_frame_len + len > sizeof(s->rx_frame)) { + return; + } + dma_bm_write(desc->buf_addr1, s->rx_frame + (s->rx_frame_size - s->rx_frame_len), len, 4); s->rx_frame_len -= len; } @@ -444,6 +453,10 @@ tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc) len = s->rx_frame_len; } + if (s->rx_frame_len + len > sizeof(s->rx_frame)) { + return; + } + dma_bm_write(desc->buf_addr2, s->rx_frame + (s->rx_frame_size - s->rx_frame_len), len, 4); s->rx_frame_len -= len; } @@ -568,7 +581,7 @@ static const uint16_t tulip_mdi_default[] = { 0x0600, 0x0001, 0x0000, - 0x0000, + 0x3b40, 0x0000, 0x0000, 0x0000, From 63f565c821910a5e218016b3121188e5b69b9755 Mon Sep 17 00:00:00 2001 From: nelsonhef Date: Fri, 21 Nov 2025 11:29:43 -0300 Subject: [PATCH 88/89] Change the order of "Toggle UI in fullscreen" keybind and add it to POT and PO files --- src/86box.c | 10 +++++----- src/qt/languages/86box.pot | 3 +++ src/qt/languages/cs-CZ.po | 3 +++ src/qt/languages/de-DE.po | 3 +++ src/qt/languages/es-ES.po | 3 +++ src/qt/languages/fi-FI.po | 3 +++ src/qt/languages/fr-FR.po | 3 +++ src/qt/languages/hr-HR.po | 3 +++ src/qt/languages/it-IT.po | 3 +++ src/qt/languages/ja-JP.po | 3 +++ src/qt/languages/ko-KR.po | 3 +++ src/qt/languages/nb-NO.po | 3 +++ src/qt/languages/nl-NL.po | 3 +++ src/qt/languages/pl-PL.po | 3 +++ src/qt/languages/pt-BR.po | 3 +++ src/qt/languages/pt-PT.po | 3 +++ src/qt/languages/ru-RU.po | 3 +++ src/qt/languages/sk-SK.po | 3 +++ src/qt/languages/sl-SI.po | 3 +++ src/qt/languages/sv-SE.po | 3 +++ src/qt/languages/tr-TR.po | 3 +++ src/qt/languages/uk-UA.po | 3 +++ src/qt/languages/vi-VN.po | 3 +++ src/qt/languages/zh-CN.po | 3 +++ src/qt/languages/zh-TW.po | 5 ++++- 25 files changed, 78 insertions(+), 6 deletions(-) diff --git a/src/86box.c b/src/86box.c index fa7be14fe..e44b57595 100644 --- a/src/86box.c +++ b/src/86box.c @@ -263,6 +263,11 @@ struct accelKey def_acc_keys[NUM_ACCELS] = { .desc="Toggle fullscreen", .seq="Ctrl+Alt+PgUp" }, + { + .name="toggle_ui_fullscreen", + .desc="Toggle UI in fullscreen", + .seq="Ctrl+Alt+PgDown" + }, { .name="screenshot", .desc="Screenshot", @@ -287,11 +292,6 @@ struct accelKey def_acc_keys[NUM_ACCELS] = { .name="mute", .desc="Toggle mute", .seq="Ctrl+Alt+M" - }, - { - .name="toggle_ui_fullscreen", - .desc="Toggle UI in fullscreen", - .seq="Ctrl+Alt+PgDown" } }; diff --git a/src/qt/languages/86box.pot b/src/qt/languages/86box.pot index 910108069..9c3d59b68 100644 --- a/src/qt/languages/86box.pot +++ b/src/qt/languages/86box.pot @@ -2892,6 +2892,9 @@ msgstr "" msgid "Toggle fullscreen" msgstr "" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "" diff --git a/src/qt/languages/cs-CZ.po b/src/qt/languages/cs-CZ.po index 92443a67f..7ae3ecacf 100644 --- a/src/qt/languages/cs-CZ.po +++ b/src/qt/languages/cs-CZ.po @@ -2892,6 +2892,9 @@ msgstr "Stisknout Ctrl+Alt+Esc" msgid "Toggle fullscreen" msgstr "Přepnout režim celé obrazovky" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Pořídit snímek obrazovky" diff --git a/src/qt/languages/de-DE.po b/src/qt/languages/de-DE.po index 94d330984..f348d0c2e 100644 --- a/src/qt/languages/de-DE.po +++ b/src/qt/languages/de-DE.po @@ -2892,6 +2892,9 @@ msgstr "Strg+Alt+Esc senden" msgid "Toggle fullscreen" msgstr "Vollbild umschalten" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Bildschirmaufnahme" diff --git a/src/qt/languages/es-ES.po b/src/qt/languages/es-ES.po index 6a86432a3..f35c31386 100644 --- a/src/qt/languages/es-ES.po +++ b/src/qt/languages/es-ES.po @@ -2892,6 +2892,9 @@ msgstr "Enviar Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Alternar pantalla completa" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Captura de pantalla" diff --git a/src/qt/languages/fi-FI.po b/src/qt/languages/fi-FI.po index 78b502a8c..1a586816b 100644 --- a/src/qt/languages/fi-FI.po +++ b/src/qt/languages/fi-FI.po @@ -2892,6 +2892,9 @@ msgstr "Lähetä Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Koko näyttö" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Kuvakaappaus" diff --git a/src/qt/languages/fr-FR.po b/src/qt/languages/fr-FR.po index 8f782f6ec..f93289db1 100644 --- a/src/qt/languages/fr-FR.po +++ b/src/qt/languages/fr-FR.po @@ -2892,6 +2892,9 @@ msgstr "Envoyer Ctrl+Alt+Échap" msgid "Toggle fullscreen" msgstr "Activer/désactiver le mode plein écran" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Capture d'écran" diff --git a/src/qt/languages/hr-HR.po b/src/qt/languages/hr-HR.po index f9807ed51..f24e9f8bf 100644 --- a/src/qt/languages/hr-HR.po +++ b/src/qt/languages/hr-HR.po @@ -2892,6 +2892,9 @@ msgstr "Pošalji Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Uključi/isključi cijelozaslonski način" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Snimka zaslona" diff --git a/src/qt/languages/it-IT.po b/src/qt/languages/it-IT.po index b32b54782..d8933a426 100644 --- a/src/qt/languages/it-IT.po +++ b/src/qt/languages/it-IT.po @@ -2892,6 +2892,9 @@ msgstr "Invia Ctrl+Alt+Esc" msgid "Toggle fullscreen" msgstr "Attiva/disattiva schermo intero" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Istantanea dello schermo" diff --git a/src/qt/languages/ja-JP.po b/src/qt/languages/ja-JP.po index c229db8c0..9b6f7bcb2 100644 --- a/src/qt/languages/ja-JP.po +++ b/src/qt/languages/ja-JP.po @@ -2892,6 +2892,9 @@ msgstr "Ctrl+Alt+Escを送信" msgid "Toggle fullscreen" msgstr "フルスクリーン表示を切り替える" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "スクリーンショット" diff --git a/src/qt/languages/ko-KR.po b/src/qt/languages/ko-KR.po index b7d9aaf35..8ec5c817c 100644 --- a/src/qt/languages/ko-KR.po +++ b/src/qt/languages/ko-KR.po @@ -2892,6 +2892,9 @@ msgstr "Ctrl+Alt+Esc 보내기" msgid "Toggle fullscreen" msgstr "전체 화면 모드 전환" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "스크린샷" diff --git a/src/qt/languages/nb-NO.po b/src/qt/languages/nb-NO.po index 3f7e4aa27..806388ebc 100644 --- a/src/qt/languages/nb-NO.po +++ b/src/qt/languages/nb-NO.po @@ -2892,6 +2892,9 @@ msgstr "Send Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Veksle fullskjerm" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Skjermbilde" diff --git a/src/qt/languages/nl-NL.po b/src/qt/languages/nl-NL.po index 204e0021d..baafccf84 100644 --- a/src/qt/languages/nl-NL.po +++ b/src/qt/languages/nl-NL.po @@ -2892,6 +2892,9 @@ msgstr "Stuur Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Volledig scherm omschakelen" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Schermafbeelding" diff --git a/src/qt/languages/pl-PL.po b/src/qt/languages/pl-PL.po index 295b1f044..7dfba8dbe 100644 --- a/src/qt/languages/pl-PL.po +++ b/src/qt/languages/pl-PL.po @@ -2892,6 +2892,9 @@ msgstr "Wyślij Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Przełącz pełny ekran" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Zrzut ekranu" diff --git a/src/qt/languages/pt-BR.po b/src/qt/languages/pt-BR.po index 57fc2972c..433e44667 100644 --- a/src/qt/languages/pt-BR.po +++ b/src/qt/languages/pt-BR.po @@ -2892,6 +2892,9 @@ msgstr "Enviar Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Alternar tela cheia" +msgid "Toggle UI in fullscreen" +msgstr "Alternar UI em tela cheia" + msgid "Screenshot" msgstr "Captura de tela" diff --git a/src/qt/languages/pt-PT.po b/src/qt/languages/pt-PT.po index 66fb7badb..2528d580d 100644 --- a/src/qt/languages/pt-PT.po +++ b/src/qt/languages/pt-PT.po @@ -2892,6 +2892,9 @@ msgstr "Enviar Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Alternar o modo em ecrã cheio" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Captura de ecrã" diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index f0d183b03..156c04efa 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -2892,6 +2892,9 @@ msgstr "Отправить Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Переключить полноэкранный режим" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Скриншот" diff --git a/src/qt/languages/sk-SK.po b/src/qt/languages/sk-SK.po index bab4f6b3c..e9c81620c 100644 --- a/src/qt/languages/sk-SK.po +++ b/src/qt/languages/sk-SK.po @@ -2892,6 +2892,9 @@ msgstr "Stlačte Ctrl+Alt+Esc" msgid "Toggle fullscreen" msgstr "Prepnúť režim celej obrazovky" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Zhotoviť snímku obrazovky" diff --git a/src/qt/languages/sl-SI.po b/src/qt/languages/sl-SI.po index a7b433dc8..3a9442912 100644 --- a/src/qt/languages/sl-SI.po +++ b/src/qt/languages/sl-SI.po @@ -2892,6 +2892,9 @@ msgstr "Pošlji Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Preklopi celozaslonski način" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Zajem zaslona" diff --git a/src/qt/languages/sv-SE.po b/src/qt/languages/sv-SE.po index 3d1335d47..b5c2c380f 100644 --- a/src/qt/languages/sv-SE.po +++ b/src/qt/languages/sv-SE.po @@ -2892,6 +2892,9 @@ msgstr "Skicka Ctrl+Alt+Esc" msgid "Toggle fullscreen" msgstr "Helskärm" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Skärmbild" diff --git a/src/qt/languages/tr-TR.po b/src/qt/languages/tr-TR.po index 8bf5870c0..b3f5804c3 100644 --- a/src/qt/languages/tr-TR.po +++ b/src/qt/languages/tr-TR.po @@ -2892,6 +2892,9 @@ msgstr "Control+Alt+Escape gönder" msgid "Toggle fullscreen" msgstr "Tam ekran modunu ayarla" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Ekran görüntüsü" diff --git a/src/qt/languages/uk-UA.po b/src/qt/languages/uk-UA.po index cda5f3741..183816e83 100644 --- a/src/qt/languages/uk-UA.po +++ b/src/qt/languages/uk-UA.po @@ -2892,6 +2892,9 @@ msgstr "Надіслати Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Переключити повноекранний режим" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Скріншот" diff --git a/src/qt/languages/vi-VN.po b/src/qt/languages/vi-VN.po index 0ee966a2c..d45a7538b 100644 --- a/src/qt/languages/vi-VN.po +++ b/src/qt/languages/vi-VN.po @@ -2892,6 +2892,9 @@ msgstr "Gửi Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "Bật/tắt toàn màn hình" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "Chụp màn hình" diff --git a/src/qt/languages/zh-CN.po b/src/qt/languages/zh-CN.po index 3db6c0835..41bfaad9f 100644 --- a/src/qt/languages/zh-CN.po +++ b/src/qt/languages/zh-CN.po @@ -2892,6 +2892,9 @@ msgstr "发送 Ctrl+Alt+Esc" msgid "Toggle fullscreen" msgstr "切换全屏" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "截图" diff --git a/src/qt/languages/zh-TW.po b/src/qt/languages/zh-TW.po index bc4ae604e..2bf733b31 100644 --- a/src/qt/languages/zh-TW.po +++ b/src/qt/languages/zh-TW.po @@ -2892,6 +2892,9 @@ msgstr "傳送 Control+Alt+Escape" msgid "Toggle fullscreen" msgstr "切換全螢幕" +msgid "Toggle UI in fullscreen" +msgstr "" + msgid "Screenshot" msgstr "螢幕截圖" @@ -2968,7 +2971,7 @@ msgid "Unable to determine release information" msgstr "無法確定釋放資訊" msgid "There was an error checking for updates:\n\n%1\n\nPlease try again later." -msgstr "檢查更新時出錯:\n'\n%1\n\n請稍後再試。" +msgstr "檢查更新時出錯:\n\n%1\n\n請稍後再試。" msgid "Update check complete" msgstr "更新檢查完成" From eb1fc4fa2254aa7b2a69d0294af2f301150df6a7 Mon Sep 17 00:00:00 2001 From: nelsonhef Date: Fri, 21 Nov 2025 11:45:15 -0300 Subject: [PATCH 89/89] Update pt-BR translations --- src/qt/languages/pt-BR.po | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qt/languages/pt-BR.po b/src/qt/languages/pt-BR.po index 433e44667..756f0141d 100644 --- a/src/qt/languages/pt-BR.po +++ b/src/qt/languages/pt-BR.po @@ -850,7 +850,7 @@ msgid "Invalid PCap device" msgstr "Dispositivo PCap inválido" msgid "Generic paddle controller(s)" -msgstr "Controlador(es) genérico(s) de pá" +msgstr "Controlador(es) genérico(s) de raquete" msgid "2-axis, 1-button joystick(s)" msgstr "Joystick(s) de 2 eixos, 1 botões" @@ -901,7 +901,7 @@ msgid "6-button gamepad" msgstr "Gamepad de 6 botões" msgid "Gravis PC GamePad" -msgstr "Gravis PC GamePad" +msgstr "GamePad Gravis PC" msgid "2-button flight yoke" msgstr "Manche de voo de 2 botões" @@ -934,10 +934,10 @@ msgid "CH Flightstick" msgstr "CH Flightstick" msgid "CH Flightstick + CH Pedals" -msgstr "CH Flightstick + CH Pedals" +msgstr "CH Flightstick + Pedais CH" msgid "CH Flightstick + CH Pedals Pro" -msgstr "CH Flightstick + CH Pedals Pro" +msgstr "CH Flightstick + Pedais CH Pro" msgid "CH Flightstick Pro" msgstr "CH Flightstick Pro" @@ -1855,7 +1855,7 @@ msgid "VDE Socket:" msgstr "Soquete VDE:" msgid "TAP Bridge Device:" -msgstr "" +msgstr "Dispositivo Ponte TAP" msgid "86Box Unit Tester" msgstr "Testador de unidade 86Box" @@ -2254,16 +2254,16 @@ msgid "WSS DMA" msgstr "DMA WSS" msgid "RTC IRQ" -msgstr "" +msgstr "IRQ RTC" msgid "RTC Port Address" -msgstr "" +msgstr "Endereço Porta RTC" msgid "Onboard RTC" -msgstr "" +msgstr "RTC Integrado" msgid "Not installed" -msgstr "" +msgstr "Não instalado" msgid "Enable OPL" msgstr "Ativar OPL" @@ -2893,7 +2893,7 @@ msgid "Toggle fullscreen" msgstr "Alternar tela cheia" msgid "Toggle UI in fullscreen" -msgstr "Alternar UI em tela cheia" +msgstr "Alternar interface em tela cheia" msgid "Screenshot" msgstr "Captura de tela"