From c76e8ff06c79a0a0abcfc7e33395bedaf2369afc Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 9 Jun 2023 14:55:13 +0200 Subject: [PATCH 01/28] Replaced the codegen_ops_NULL table references with NULL pointers, as it has the same effect without requiring an extra table of opcodes, also made the new recompiler clear codegen_flags_changed after every interpreted instruction to prevent conditional jumps from occasionally taking the wrong turn (fixes CL-GD 54x6 driver glitches in 24bpp mode on Windows 98 SE), and added instruction length heuristics on fetching the instruction, fixes Jane's US Navy Fighters. --- src/codegen/codegen_ops.c | 48 ----------------------------------- src/codegen/codegen_ops.h | 1 - src/codegen/codegen_x86-64.c | 16 ++++++------ src/codegen/codegen_x86.c | 16 ++++++------ src/codegen_new/codegen.c | 17 +++++++------ src/codegen_new/codegen_ops.c | 48 ----------------------------------- src/codegen_new/codegen_ops.h | 1 - src/cpu/386.c | 38 ++++++++++++++++++++++++++- src/cpu/386_common.h | 45 ++++++++++++++++++++++++++++++++ src/cpu/386_dynarec.c | 6 ++--- src/cpu/x86_flags.h | 2 +- 11 files changed, 111 insertions(+), 127 deletions(-) diff --git a/src/codegen/codegen_ops.c b/src/codegen/codegen_ops.c index b5991c985..46a49f118 100644 --- a/src/codegen/codegen_ops.c +++ b/src/codegen/codegen_ops.c @@ -607,51 +607,3 @@ RecompOpFn recomp_opcodes_REPNE[512] = { /*f0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // clang-format on }; - -RecompOpFn recomp_opcodes_NULL[512] = { - // clang-format off - /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ -/*00*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*30*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*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, -/*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, - -/*80*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*90*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*a0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*b0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*c0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*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, - - /*32-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ -/*00*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*30*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*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, -/*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, - -/*80*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*90*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*a0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*b0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*c0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*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, - // clang-format on -}; diff --git a/src/codegen/codegen_ops.h b/src/codegen/codegen_ops.h index 937105f9e..f92ba4f6d 100644 --- a/src/codegen/codegen_ops.h +++ b/src/codegen/codegen_ops.h @@ -17,7 +17,6 @@ extern RecompOpFn recomp_opcodes_de[512]; extern RecompOpFn recomp_opcodes_df[512]; extern RecompOpFn recomp_opcodes_REPE[512]; extern RecompOpFn recomp_opcodes_REPNE[512]; -extern RecompOpFn recomp_opcodes_NULL[512]; #define REG_EAX 0 #define REG_ECX 1 diff --git a/src/codegen/codegen_x86-64.c b/src/codegen/codegen_x86-64.c index fc3618d91..c02e8a7c2 100644 --- a/src/codegen/codegen_x86-64.c +++ b/src/codegen/codegen_x86-64.c @@ -883,7 +883,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p case 0xd8: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d8; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d8; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -893,7 +893,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xd9: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d9_a32 : x86_dynarec_opcodes_d9_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d9; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d9; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -902,7 +902,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xda: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_da_a32 : x86_dynarec_opcodes_da_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_da; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_da; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -911,7 +911,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdb: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_db_a32 : x86_dynarec_opcodes_db_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_db; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_db; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -920,7 +920,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdc: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dc_a32 : x86_dynarec_opcodes_dc_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dc; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dc; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -930,7 +930,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdd: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dd_a32 : x86_dynarec_opcodes_dd_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dd; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dd; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -939,7 +939,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xde: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_de_a32 : x86_dynarec_opcodes_de_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_de; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_de; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -948,7 +948,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdf: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_df_a32 : x86_dynarec_opcodes_df_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_df; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_df; opcode_mask = 0xff; over = 1; pc_off = -1; diff --git a/src/codegen/codegen_x86.c b/src/codegen/codegen_x86.c index 0821d9d14..c4b32c8a2 100644 --- a/src/codegen/codegen_x86.c +++ b/src/codegen/codegen_x86.c @@ -1922,7 +1922,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p case 0xd8: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d8; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d8; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -1932,7 +1932,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xd9: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d9_a32 : x86_dynarec_opcodes_d9_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d9; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d9; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1941,7 +1941,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xda: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_da_a32 : x86_dynarec_opcodes_da_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_da; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_da; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1950,7 +1950,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdb: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_db_a32 : x86_dynarec_opcodes_db_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_db; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_db; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1959,7 +1959,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdc: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dc_a32 : x86_dynarec_opcodes_dc_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dc; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dc; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -1969,7 +1969,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdd: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dd_a32 : x86_dynarec_opcodes_dd_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dd; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dd; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1978,7 +1978,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xde: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_de_a32 : x86_dynarec_opcodes_de_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_de; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_de; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1987,7 +1987,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p break; case 0xdf: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_df_a32 : x86_dynarec_opcodes_df_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_df; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_df; opcode_mask = 0xff; over = 1; pc_off = -1; diff --git a/src/codegen_new/codegen.c b/src/codegen_new/codegen.c index d7aae234e..6270583dd 100644 --- a/src/codegen_new/codegen.c +++ b/src/codegen_new/codegen.c @@ -440,7 +440,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xd8; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d8; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d8; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -453,7 +453,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xd9; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d9_a32 : x86_dynarec_opcodes_d9_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d9; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d9; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -465,7 +465,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xda; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_da_a32 : x86_dynarec_opcodes_da_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_da; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_da; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -477,7 +477,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xdb; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_db_a32 : x86_dynarec_opcodes_db_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_db; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_db; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -489,7 +489,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xdc; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dc_a32 : x86_dynarec_opcodes_dc_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dc; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dc; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -502,7 +502,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xdd; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dd_a32 : x86_dynarec_opcodes_dd_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dd; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dd; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -514,7 +514,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xde; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_de_a32 : x86_dynarec_opcodes_de_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_de; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_de; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -526,7 +526,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p last_prefix = 0xdf; #endif op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_df_a32 : x86_dynarec_opcodes_df_a16; - recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_df; + recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_df; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -713,6 +713,7 @@ generate_call: uop_MOV_IMM(ir, IREG_ssegs, op_ssegs); uop_LOAD_FUNC_ARG_IMM(ir, 0, fetchdat); uop_CALL_INSTRUCTION_FUNC(ir, op); + codegen_flags_changed = 0; codegen_mark_code_present(block, cs + cpu_state.pc, 8); last_op_32 = op_32; diff --git a/src/codegen_new/codegen_ops.c b/src/codegen_new/codegen_ops.c index e611e6b29..698a7899b 100644 --- a/src/codegen_new/codegen_ops.c +++ b/src/codegen_new/codegen_ops.c @@ -557,51 +557,3 @@ RecompOpFn recomp_opcodes_df[512] = { // clang-format on }; -RecompOpFn recomp_opcodes_NULL[512] = { - // clang-format off - /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ -/*00*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*30*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*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, -/*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, - -/*80*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*90*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*a0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*b0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*c0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*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, - - /*32-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ -/*00*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*30*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*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, -/*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, - -/*80*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*90*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*a0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*b0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - -/*c0*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -/*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, - // clang-format on -}; - diff --git a/src/codegen_new/codegen_ops.h b/src/codegen_new/codegen_ops.h index 43bcf1b3f..9cef07e15 100644 --- a/src/codegen_new/codegen_ops.h +++ b/src/codegen_new/codegen_ops.h @@ -20,7 +20,6 @@ extern RecompOpFn recomp_opcodes_de[512]; extern RecompOpFn recomp_opcodes_df[512]; /*extern RecompOpFn recomp_opcodes_REPE[512]; extern RecompOpFn recomp_opcodes_REPNE[512];*/ -extern RecompOpFn recomp_opcodes_NULL[512]; #define REG_EAX 0 #define REG_ECX 1 diff --git a/src/cpu/386.c b/src/cpu/386.c index a5bae7de6..87d481e1f 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -46,6 +46,42 @@ uint32_t backupregs[16]; x86seg _oldds; +#if 1 +int opcode_length[256] = { 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 3, /* 0x0x */ + 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 1, /* 0x1x */ + 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 1, /* 0x2x */ + 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 1, /* 0x3x */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x4x */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x5x */ + 1, 1, 3, 3, 1, 1, 1, 1, 3, 3, 2, 3, 1, 1, 1, 1, /* 0x6x */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x7x */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x8x */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, /* 0x9x */ + 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, /* 0xax */ + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xbx */ + 3, 3, 3, 1, 3, 3, 3, 3, 3, 1, 3, 1, 1, 2, 1, 1, /* 0xcx */ + 3, 3, 3, 3, 2, 2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xdx */ + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 1, 1, 1, 1, /* 0xex */ + 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 3, 3 }; /* 0xfx */ +#else +int opcode_length[256] = { 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 3, /* 0x0x */ + 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 1, /* 0x1x */ + 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 1, /* 0x2x */ + 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 1, /* 0x3x */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x4x */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x5x */ + 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 1, 1, 1, 1, /* 0x6x */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x7x */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x8x */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, /* 0x9x */ + 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, /* 0xax */ + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xbx */ + 3, 3, 3, 1, 3, 3, 3, 3, 3, 1, 3, 1, 1, 2, 1, 1, /* 0xcx */ + 3, 3, 3, 3, 2, 2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xdx */ + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 1, 1, 1, 1, /* 0xex */ + 3, 1, 3, 3, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 3, 3 }; /* 0xfx */ +#endif + #ifdef ENABLE_386_LOG int x386_do_log = ENABLE_386_LOG; @@ -143,7 +179,7 @@ exec386(int cycs) cpu_state.ea_seg = &cpu_state.seg_ds; cpu_state.ssegs = 0; - fetchdat = fastreadl(cs + cpu_state.pc); + fetchdat = fastreadl_fetch(cs + cpu_state.pc); if (!cpu_state.abrt) { #ifdef ENABLE_386_LOG diff --git a/src/cpu/386_common.h b/src/cpu/386_common.h index ae71347b6..8b7fbbbd0 100644 --- a/src/cpu/386_common.h +++ b/src/cpu/386_common.h @@ -257,6 +257,51 @@ get_ram_ptr(uint32_t a) } } +extern int opcode_length[256]; + +static __inline uint16_t +fastreadw_fetch(uint32_t a) +{ + uint8_t *t; + uint16_t val; + if ((a & 0xFFF) > 0xFFE) { + val = fastreadb(a); + if (opcode_length[val & 0xff] > 1) + val |= (fastreadb(a + 1) << 8); + return val; + } + if ((a >> 12) == pccache) + return *((uint16_t *) &pccache2[a]); + t = getpccache(a); + if (cpu_state.abrt) + return 0; + + pccache = a >> 12; + pccache2 = t; + return *((uint16_t *) &pccache2[a]); +} + +static __inline uint32_t +fastreadl_fetch(uint32_t a) +{ + uint8_t *t; + uint32_t val; + if ((a & 0xFFF) < 0xFFD) { + if ((a >> 12) != pccache) { + t = getpccache(a); + if (cpu_state.abrt) + return 0; + pccache2 = t; + pccache = a >> 12; + } + return *((uint32_t *) &pccache2[a]); + } + val = fastreadw_fetch(a); + if (opcode_length[val & 0xff] > 2) + val |= (fastreadw(a + 2) << 16); + return val; +} + static __inline uint8_t getbyte(void) { diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index f2e04b54a..daeef5568 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -348,7 +348,7 @@ exec386_dynarec_int(void) cpu_state.ea_seg = &cpu_state.seg_ds; cpu_state.ssegs = 0; - fetchdat = fastreadl(cs + cpu_state.pc); + fetchdat = fastreadl_fetch(cs + cpu_state.pc); # ifdef ENABLE_386_DYNAREC_LOG if (in_smm) x386_dynarec_log("[%04X:%08X] fetchdat = %08X\n", CS, cpu_state.pc, fetchdat); @@ -572,7 +572,7 @@ exec386_dynarec_dyn(void) cpu_state.ea_seg = &cpu_state.seg_ds; cpu_state.ssegs = 0; - fetchdat = fastreadl(cs + cpu_state.pc); + fetchdat = fastreadl_fetch(cs + cpu_state.pc); # ifdef ENABLE_386_DYNAREC_LOG if (in_smm) x386_dynarec_log("[%04X:%08X] fetchdat = %08X\n", CS, cpu_state.pc, fetchdat); @@ -668,7 +668,7 @@ exec386_dynarec_dyn(void) cpu_state.ssegs = 0; codegen_endpc = (cs + cpu_state.pc) + 8; - fetchdat = fastreadl(cs + cpu_state.pc); + fetchdat = fastreadl_fetch(cs + cpu_state.pc); # ifdef ENABLE_386_DYNAREC_LOG if (in_smm) diff --git a/src/cpu/x86_flags.h b/src/cpu/x86_flags.h index b8b1a706a..e82041783 100644 --- a/src/cpu/x86_flags.h +++ b/src/cpu/x86_flags.h @@ -536,7 +536,7 @@ flags_rebuild_c(void) static __inline int flags_res_valid(void) { - if (cpu_state.flags_op == FLAGS_UNKNOWN || (cpu_state.flags_op >= FLAGS_ROL8 && cpu_state.flags_op <= FLAGS_ROR32)) + if ((cpu_state.flags_op == FLAGS_UNKNOWN) || ((cpu_state.flags_op >= FLAGS_ROL8) && (cpu_state.flags_op <= FLAGS_ROR32))) return 0; return 1; From 90d85af304d55fcc05abf8e1ae03a85f75efe4cb Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 9 Jun 2023 15:09:14 +0200 Subject: [PATCH 02/28] Fixed an accidentally introduced PIT timer mode 0 regression, fixes #3376. --- src/pit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pit.c b/src/pit.c index b39d565d3..cf339607d 100644 --- a/src/pit.c +++ b/src/pit.c @@ -307,7 +307,7 @@ static void ctr_set_state_1(ctr_t *ctr) { uint8_t mode = (ctr->m & 0x03); - int do_reload = !!ctr->incomplete || (ctr->state == 0); + int do_reload = !!ctr->incomplete || (mode == 0) || (ctr->state == 0); ctr->incomplete = 0; @@ -984,7 +984,7 @@ pit_set_clock(int clock) ISACONST = (uint64_t) ((cpuclock / (double) cpu_isa_speed) * (double) (1ULL << 32)); xt_cpu_multi = 1ULL; } else { - cpuclock = 14318184.0; + cpuclock = (157500000.0 / 11.0); PITCONSTD = 12.0; PITCONST = (12ULL << 32ULL); CGACONST = (8ULL << 32ULL); From 883b4c4be9c7e97fa0bbeccded30e5b44e24a397 Mon Sep 17 00:00:00 2001 From: cold-brewed <47337035+cold-brewed@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:37:05 -0400 Subject: [PATCH 03/28] macos: Update library bundling process, add vde to bundle (#3390) Co-authored-by: cold-brewed --- src/network/CMakeLists.txt | 9 ++++++-- src/qt/CMakeLists.txt | 42 ++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 94e066a19..54ec1edce 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -43,8 +43,13 @@ endif() if (UNIX) find_path(HAS_VDE "libvdeplug.h" PATHS ${VDE_INCLUDE_DIR} "/usr/include /usr/local/include" "/opt/homebrew/include" ) if(HAS_VDE) - add_compile_definitions(HAS_VDE) - list(APPEND net_sources net_vde.c) + find_library(VDE_LIB vdeplug) + if (NOT VDE_LIB) + message(WARNING "Could not find VDE. The library will not be bundled and any related features will be disabled.") + else() + add_compile_definitions(HAS_VDE) + list(APPEND net_sources net_vde.c) + endif() endif() endif() diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index d9c729d00..23e2c748e 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -239,7 +239,6 @@ if (APPLE) if (NOT MOLTENVK_LIB) message(FATAL_ERROR "Could not find MoltenVK library") endif() - target_link_libraries(ui PRIVATE "${MOLTENVK_LIB}") endif() endif() @@ -313,6 +312,20 @@ macro(install_qt5_plugin _qt_plugin_name _runtime_plugins_var _prefix) endif() endmacro() +macro(install_bundle_library _library_path _installed_name _runtime_plugins_var _prefix) + if(EXISTS "${_library_path}") + file(REAL_PATH "${_library_path}" _lib_resolved) + if(EXISTS "${_lib_resolved}") + install(FILES "${_lib_resolved}" DESTINATION "${_prefix}" RENAME "${_installed_name}") + list(APPEND ${_runtime_plugins_var} "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${_prefix}/${_installed_name}") + else() + message(WARNING "Library ${_installed_name} will not be bundled: The library was found but could not be resolved.") + endif() + else() + message(STATUS "Library ${_installed_name} was not found - skipping") + endif() +endmacro() + if (APPLE AND CMAKE_MACOSX_BUNDLE) set(prefix "86Box.app/Contents") set(INSTALL_RUNTIME_DIR "${prefix}/MacOS") @@ -326,19 +339,10 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE) install_qt5_plugin("Qt${QT_MAJOR}::QICNSPlugin" RUNTIME_PLUGINS ${prefix}) # Install libraries that are loaded at runtime and not linked - if (GHOSTSCRIPT_LIB) - set(GS_LIBRARY_NAME "libgs.dylib") - file(REAL_PATH ${GHOSTSCRIPT_LIB} GS_LIB_RESOLVED) - install(FILES ${GS_LIB_RESOLVED} DESTINATION ${INSTALL_LIB_DIR} RENAME ${GS_LIBRARY_NAME}) - list(APPEND RUNTIME_PLUGINS "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR}/${GS_LIBRARY_NAME}") - endif () - - if (FLUIDSYNTH_LIB) - set(FLUIDSYNTH_LIBRARY_NAME "libfluidsynth.dylib") - file(REAL_PATH ${FLUIDSYNTH_LIB} FLUIDSYNTH_LIB_RESOLVED) - install(FILES ${FLUIDSYNTH_LIB_RESOLVED} DESTINATION ${INSTALL_LIB_DIR} RENAME ${FLUIDSYNTH_LIBRARY_NAME}) - list(APPEND RUNTIME_PLUGINS "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR}/${FLUIDSYNTH_LIBRARY_NAME}") - endif () + install_bundle_library("${GHOSTSCRIPT_LIB}" "libgs.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) + install_bundle_library("${FLUIDSYNTH_LIB}" "libfluidsynth.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) + install_bundle_library("${VDE_LIB}" "libvdeplug.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) + install_bundle_library("${MOLTENVK_LIB}" "libVulkan.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins = PlugIns\n") @@ -365,16 +369,6 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE) COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\" \"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_RUNTIME_DIR}/86Box\") ") - if(MOLTENVK) - install(CODE " - execute_process( - COMMAND bash -c \"set -e - echo \\\"-- Creating vulkan dylib symlink for QT (libVulkan.dylib -> libMoltenVK.dylib)\\\" - cd \${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR} - ln -sf libMoltenVK.dylib libVulkan.dylib - \") - ") - endif() endif() if (UNIX AND NOT APPLE AND NOT HAIKU) From 8cdaaaee34a969d2ea518d75e2d91063020fa639 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 9 Jun 2023 12:20:30 -0300 Subject: [PATCH 04/28] win_serial_passthrough: Disable intermediate buffering on serial ports --- src/win/win_serial_passthrough.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/win_serial_passthrough.c b/src/win/win_serial_passthrough.c index cffa7c84b..fc1e49d6c 100644 --- a/src/win/win_serial_passthrough.c +++ b/src/win/win_serial_passthrough.c @@ -194,7 +194,7 @@ open_host_serial_port(serial_passthrough_t *dev) DCB *serialattr = calloc(1, sizeof(DCB)); if (!serialattr) return 0; - dev->master_fd = (intptr_t) CreateFileA(dev->host_serial_path, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + dev->master_fd = (intptr_t) CreateFileA(dev->host_serial_path, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL); if (dev->master_fd == (intptr_t) INVALID_HANDLE_VALUE) { free(serialattr); return 0; From d543c6a45dd2a2e2528f1d57d90a4407cdef8152 Mon Sep 17 00:00:00 2001 From: cold-brewed <47337035+cold-brewed@users.noreply.github.com> Date: Fri, 9 Jun 2023 11:21:12 -0400 Subject: [PATCH 05/28] Update the build system to add dependencies for vde (#3391) Co-authored-by: cold-brewed --- .ci/AppImageBuilder.yml | 1 + .ci/build.sh | 4 ++-- .ci/dependencies_macports.txt | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/AppImageBuilder.yml b/.ci/AppImageBuilder.yml index 39997a7a8..881f7b91e 100644 --- a/.ci/AppImageBuilder.yml +++ b/.ci/AppImageBuilder.yml @@ -59,6 +59,7 @@ AppDir: - libsixel1 # if CLI:BOOL=ON - libslirp0 # if SLIRP_EXTERNAL:BOOL=ON - libsndio7.0 # if OPENAL:BOOL=ON + - libvdeplug-dev # -dev also pulls in libvdeplug2. -dev is required to get the proper .so symlink to the library - libwayland-client0 # if QT:BOOL=ON - libx11-6 # if QT:BOOL=ON - libx11-xcb1 # if QT:BOOL=ON diff --git a/.ci/build.sh b/.ci/build.sh index fc7290f4a..145efb7dd 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -587,7 +587,7 @@ else # ...and the ones we do want listed. Non-dev packages fill missing spots on the list. libpkgs="" longest_libpkg=0 - for pkg in libc6-dev libstdc++6 libopenal-dev libfreetype6-dev libx11-dev libsdl2-dev libpng-dev librtmidi-dev qtdeclarative5-dev libwayland-dev libevdev-dev libxkbcommon-x11-dev libglib2.0-dev libslirp-dev libfaudio-dev libaudio-dev libjack-jackd2-dev libpipewire-0.3-dev libsamplerate0-dev libsndio-dev + for pkg in libc6-dev libstdc++6 libopenal-dev libfreetype6-dev libx11-dev libsdl2-dev libpng-dev librtmidi-dev qtdeclarative5-dev libwayland-dev libevdev-dev libxkbcommon-x11-dev libglib2.0-dev libslirp-dev libfaudio-dev libaudio-dev libjack-jackd2-dev libpipewire-0.3-dev libsamplerate0-dev libsndio-dev libvdeplug-dev do libpkgs="$libpkgs $pkg:$arch_deb" length=$(echo -n $pkg | sed 's/-dev$//' | sed "s/qtdeclarative/qt/" | wc -c) @@ -678,7 +678,7 @@ case $arch in 32 | x86) cmake_flags_extra="$cmake_flags_extra -D ARCH=i386";; 64 | x86_64*) cmake_flags_extra="$cmake_flags_extra -D ARCH=x86_64";; ARM32 | arm32) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm";; - ARM64 | arm64) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm64";; + ARM64 | arm64) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm64 -D NEW_DYNAREC=ON";; *) cmake_flags_extra="$cmake_flags_extra -D \"ARCH=$arch\"";; esac diff --git a/.ci/dependencies_macports.txt b/.ci/dependencies_macports.txt index d73ce7e17..e78d4a6da 100644 --- a/.ci/dependencies_macports.txt +++ b/.ci/dependencies_macports.txt @@ -13,3 +13,4 @@ qt5 wget fluidsynth ghostscript +vde2 From bd734d8d4a3d7ccf625934a607fa48e3025a8629 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 9 Jun 2023 12:21:48 -0300 Subject: [PATCH 06/28] win_serial_passthrough: Change pipe instance count to 1 for VMware compatibility --- src/win/win_serial_passthrough.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/win_serial_passthrough.c b/src/win/win_serial_passthrough.c index fc1e49d6c..78ed1a766 100644 --- a/src/win/win_serial_passthrough.c +++ b/src/win/win_serial_passthrough.c @@ -167,7 +167,7 @@ open_pseudo_terminal(serial_passthrough_t *dev) { char ascii_pipe_name[1024] = { 0 }; strncpy(ascii_pipe_name, dev->named_pipe, 1023); - dev->master_fd = (intptr_t) CreateNamedPipeA(ascii_pipe_name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 32, 65536, 65536, NMPWAIT_USE_DEFAULT_WAIT, NULL); + dev->master_fd = (intptr_t) CreateNamedPipeA(ascii_pipe_name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 65536, 65536, NMPWAIT_USE_DEFAULT_WAIT, NULL); if (dev->master_fd == (intptr_t) INVALID_HANDLE_VALUE) { wchar_t errorMsg[1024] = { 0 }; wchar_t finalMsg[1024] = { 0 }; From 4b326121b95c2993a8f75552fae364fbc0310d92 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 9 Jun 2023 12:23:23 -0300 Subject: [PATCH 07/28] Jenkins: Properly force new dynarec on architectures that require it --- .ci/build.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.ci/build.sh b/.ci/build.sh index 145efb7dd..448b99160 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -348,10 +348,6 @@ then # Run build for the architecture. args= [ $strip -ne 0 ] && args="-t $args" - case $arch_universal in # workaround: force new dynarec on for ARM - arm*) cmake_flags_extra="-D NEW_DYNAREC=ON";; - *) cmake_flags_extra=;; - esac zsh -lc 'exec "'"$0"'" -n -b "universal slice" "'"$arch_universal"'" '"$args""$cmake_flags"' '"$cmake_flags_extra" status=$? @@ -677,7 +673,7 @@ rm -rf build case $arch in 32 | x86) cmake_flags_extra="$cmake_flags_extra -D ARCH=i386";; 64 | x86_64*) cmake_flags_extra="$cmake_flags_extra -D ARCH=x86_64";; - ARM32 | arm32) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm";; + ARM32 | arm32) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm -D NEW_DYNAREC=ON";; ARM64 | arm64) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm64 -D NEW_DYNAREC=ON";; *) cmake_flags_extra="$cmake_flags_extra -D \"ARCH=$arch\"";; esac From 86aa72840b16bdea906e83d91619f91bd9d6fc74 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 9 Jun 2023 13:57:25 -0300 Subject: [PATCH 08/28] Jenkins: Add a missing AppImage ignore --- .ci/AppImageBuilder.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/AppImageBuilder.yml b/.ci/AppImageBuilder.yml index 881f7b91e..1ef99d612 100644 --- a/.ci/AppImageBuilder.yml +++ b/.ci/AppImageBuilder.yml @@ -74,6 +74,7 @@ AppDir: files: exclude: - etc + - lib/udev - usr/[!ls]* # * except lib, local, share - usr/lib/*/libasound.so.* # using our own ALSA can cause issues, and the API is pretty stable anyway - usr/lib/*.a # produced by library compilation From cf8a2aa50a5a96b2ef40edd0f3a3f6065abc56eb Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 10 Jun 2023 19:24:44 +0200 Subject: [PATCH 09/28] Added a sanity check to mem_invalidate_range() when compiled with the new recompiler, fixes segmentation fault on with OS/2 on IBM PS/2 Model 80. --- src/mem/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mem/mem.c b/src/mem/mem.c index c6010c8a1..6c994d156 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -2219,7 +2219,7 @@ mem_invalidate_range(uint32_t start_addr, uint32_t end_addr) if (p) { p->dirty_mask = 0xffffffffffffffffULL; - if (p->byte_dirty_mask) + if ((p->mem != page_ff) && p->byte_dirty_mask) memset(p->byte_dirty_mask, 0xff, 64 * sizeof(uint64_t)); if (!page_in_evict_list(p)) From c8486428452aa2962c05f54a50058060e11faa1a Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Sat, 10 Jun 2023 13:26:19 -0700 Subject: [PATCH 10/28] Add some defines to build succesfully on FreeBSD Tested on FreeBSD 13.2 only. FreeBSD is more similar to Mac OS X in system-level library support than it is to Linux. --- src/include/86box/plat_dir.h | 3 +++ src/unix/unix_serial_passthrough.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/include/86box/plat_dir.h b/src/include/86box/plat_dir.h index d55bc5046..899ff325e 100644 --- a/src/include/86box/plat_dir.h +++ b/src/include/86box/plat_dir.h @@ -66,6 +66,9 @@ extern void seekdir(DIR *, long); extern int closedir(DIR *); # define rewinddir(dirp) seekdir(dirp, 0L) +#elif defined(__FreeBSD__) +/* FreeBSD uses dirent.h instead of sys/dir.h */ +# include #else /* On linux and macOS, use the standard functions and types */ # include diff --git a/src/unix/unix_serial_passthrough.c b/src/unix/unix_serial_passthrough.c index b3a0080b7..033fc1e87 100644 --- a/src/unix/unix_serial_passthrough.c +++ b/src/unix/unix_serial_passthrough.c @@ -21,6 +21,9 @@ # define _DEFAULT_SOURCE 1 # define _BSD_SOURCE 1 #endif +#ifdef __FreeBSD__ +# define __BSD_VISIBLE 1 +#endif #include #include #include @@ -165,7 +168,7 @@ plat_serpt_set_params(void *p) term_attr.c_cflag &= CSTOPB; if (dev->serial->lcr & 0x04) term_attr.c_cflag |= CSTOPB; -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) term_attr.c_cflag &= PARENB | PARODD; #else term_attr.c_cflag &= PARENB | PARODD | CMSPAR; @@ -174,7 +177,7 @@ plat_serpt_set_params(void *p) term_attr.c_cflag |= PARENB; if (!(dev->serial->lcr & 0x10)) term_attr.c_cflag |= PARODD; -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) if ((dev->serial->lcr & 0x20)) term_attr.c_cflag |= CMSPAR; #endif From 078651d273a305596162a4ab51c5f20e865e0fd5 Mon Sep 17 00:00:00 2001 From: GreaseMonkey Date: Sun, 11 Jun 2023 13:28:13 +1200 Subject: [PATCH 11/28] (mostly) Fix EGA split screen - fix done by @cons-cinnabar Closes: #3386 --- src/video/vid_ega.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index d0434fd0e..8cfd51db6 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -582,10 +582,11 @@ ega_poll(void *p) ega->vc++; ega->vc &= 511; if (ega->vc == ega->split) { + // TODO: Implement the hardware bug where the first scanline is drawn twice when the split happens if (ega->interlace && ega->oddeven) - ega->ma = ega->maback = ega->ma_latch + (ega->rowoffset << 1); + ega->ma = ega->maback = ega->rowoffset << 1; else - ega->ma = ega->maback = ega->ma_latch; + ega->ma = ega->maback = 0; ega->ma <<= 2; ega->maback <<= 2; ega->sc = 0; From 5e40840d16315b978bd57684ae8634eb23e3a1c4 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 11 Jun 2023 11:41:49 +0600 Subject: [PATCH 12/28] Force 'page_in_evict_list' to be always inlined --- src/include/86box/mem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 8915b149c..102e9f449 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -229,7 +229,7 @@ typedef struct page_t { extern uint32_t purgable_page_list_head; static inline int -page_in_evict_list(page_t *p) +page_in_evict_list(page_t *p) __attribute__((always_inline)) { return (p->evict_prev != EVICT_NOT_IN_LIST); } From aac50535123b558cd272ca650c45f506ead8d9ff Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 13:44:12 +0200 Subject: [PATCH 13/28] Fixed attributes in mem.c. --- src/include/86box/mem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 102e9f449..0f4f0b62e 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -228,8 +228,8 @@ typedef struct page_t { } page_t; extern uint32_t purgable_page_list_head; -static inline int -page_in_evict_list(page_t *p) __attribute__((always_inline)) +__attribute__((always_inline)) static inline int +page_in_evict_list(page_t *p) { return (p->evict_prev != EVICT_NOT_IN_LIST); } From c10b05f35c20c61763b8a050ff595a6439ad77e3 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 13:48:03 +0200 Subject: [PATCH 14/28] Finally commented out the logging in the MOV TRx instructions. --- src/cpu/x86_ops_mov_ctrl.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cpu/x86_ops_mov_ctrl.h b/src/cpu/x86_ops_mov_ctrl.h index d28033d5d..d95116c93 100644 --- a/src/cpu/x86_ops_mov_ctrl.h +++ b/src/cpu/x86_ops_mov_ctrl.h @@ -251,12 +251,12 @@ opMOV_DRx_r_a32(uint32_t fetchdat) static void opMOV_r_TRx(void) { - uint32_t base; + // uint32_t base; - base = _tr[4] & 0xfffff800; + // base = _tr[4] & 0xfffff800; switch (cpu_reg) { case 3: - pclog("[R] %08X cache = %08X\n", base + cache_index, _tr[3]); + // pclog("[R] %08X cache = %08X\n", base + cache_index, _tr[3]); _tr[3] = *(uint32_t *) &(_cache[cache_index]); cache_index = (cache_index + 4) & 0xf; break; @@ -300,35 +300,35 @@ opMOV_TRx_r(void) ctl = _tr[5] & 3; switch (cpu_reg) { case 3: - pclog("[W] %08X cache = %08X\n", base + cache_index, _tr[3]); + // pclog("[W] %08X cache = %08X\n", base + cache_index, _tr[3]); *(uint32_t *) &(_cache[cache_index]) = _tr[3]; cache_index = (cache_index + 4) & 0xf; break; case 4: - if (!(cr0 & 1) && !(_tr[5] & (1 << 19))) - pclog("TAG = %08X, DEST = %08X\n", base, base + cache_index - 16); + // if (!(cr0 & 1) && !(_tr[5] & (1 << 19))) + // pclog("TAG = %08X, DEST = %08X\n", base, base + cache_index - 16); break; case 5: - pclog("[16] EXT = %i (%i), SET = %04X\n", !!(_tr[5] & (1 << 19)), _tr[5] & 0x03, _tr[5] & 0x7f0); + // pclog("[16] EXT = %i (%i), SET = %04X\n", !!(_tr[5] & (1 << 19)), _tr[5] & 0x03, _tr[5] & 0x7f0); if (!(_tr[5] & (1 << 19))) { switch (ctl) { case 0: - pclog(" Cache fill or read...\n", base); + // pclog(" Cache fill or read...\n", base); break; case 1: base += (_tr[5] & 0x7f0); - pclog(" Writing 16 bytes to %08X...\n", base); + // pclog(" Writing 16 bytes to %08X...\n", base); for (i = 0; i < 16; i += 4) mem_writel_phys(base + i, *(uint32_t *) &(_cache[i])); break; case 2: base += (_tr[5] & 0x7f0); - pclog(" Reading 16 bytes from %08X...\n", base); + // pclog(" Reading 16 bytes from %08X...\n", base); for (i = 0; i < 16; i += 4) *(uint32_t *) &(_cache[i]) = mem_readl_phys(base + i); break; case 3: - pclog(" Cache invalidate/flush...\n", base); + // pclog(" Cache invalidate/flush...\n", base); break; } } From 0968369acb10d8e7a621e0c1a0a32caae0418c06 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 13:49:47 +0200 Subject: [PATCH 15/28] Clarified a condition in softfloat-specialize.h to fix a warning. --- src/cpu/softfloat/softfloat-specialize.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpu/softfloat/softfloat-specialize.h b/src/cpu/softfloat/softfloat-specialize.h index 11326ecb6..302ce53e4 100644 --- a/src/cpu/softfloat/softfloat-specialize.h +++ b/src/cpu/softfloat/softfloat-specialize.h @@ -548,7 +548,8 @@ BX_CPP_INLINE floatx80 packFloatx80(int zSign, Bit32s zExp, Bit64u zSig) BX_CPP_INLINE int floatx80_is_nan(floatx80 a) { - return ((a.exp & 0x7FFF) == 0x7FFF) && (Bit64s) (a.fraction<<1); + // return ((a.exp & 0x7FFF) == 0x7FFF) && (Bit64s) (a.fraction<<1); + return ((a.exp & 0x7FFF) == 0x7FFF) && (((Bit64s) (a.fraction<<1)) != 0); } /*---------------------------------------------------------------------------- From 85afd38cab5c1fd3b60f0b8db39e28f9b1e9a3a6 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 13:52:25 +0200 Subject: [PATCH 16/28] Added casts to codegen_new/codegen.c. --- src/codegen_new/codegen.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/codegen_new/codegen.c b/src/codegen_new/codegen.c index 6270583dd..fb47981c3 100644 --- a/src/codegen_new/codegen.c +++ b/src/codegen_new/codegen.c @@ -439,7 +439,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xd8; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_d8_a32 : (OpFn *) x86_dynarec_opcodes_d8_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d8; opcode_shift = 3; opcode_mask = 0x1f; @@ -452,7 +452,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xd9; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d9_a32 : x86_dynarec_opcodes_d9_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_d9_a32 : (OpFn *) x86_dynarec_opcodes_d9_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d9; opcode_mask = 0xff; over = 1; @@ -464,7 +464,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xda; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_da_a32 : x86_dynarec_opcodes_da_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_da_a32 : (OpFn *) x86_dynarec_opcodes_da_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_da; opcode_mask = 0xff; over = 1; @@ -476,7 +476,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdb; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_db_a32 : x86_dynarec_opcodes_db_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_db_a32 : (OpFn *) x86_dynarec_opcodes_db_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_db; opcode_mask = 0xff; over = 1; @@ -488,7 +488,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdc; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dc_a32 : x86_dynarec_opcodes_dc_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_dc_a32 : (OpFn *) x86_dynarec_opcodes_dc_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dc; opcode_shift = 3; opcode_mask = 0x1f; @@ -501,7 +501,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdd; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dd_a32 : x86_dynarec_opcodes_dd_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_dd_a32 : (OpFn *) x86_dynarec_opcodes_dd_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dd; opcode_mask = 0xff; over = 1; @@ -513,7 +513,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xde; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_de_a32 : x86_dynarec_opcodes_de_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_de_a32 : (OpFn *) x86_dynarec_opcodes_de_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_de; opcode_mask = 0xff; over = 1; @@ -525,7 +525,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdf; #endif - op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_df_a32 : x86_dynarec_opcodes_df_a16; + op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_df_a32 : (OpFn *) x86_dynarec_opcodes_df_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_df; opcode_mask = 0xff; over = 1; From 058b15cc5edf00cc37547ea69d0506a9cbeb1f68 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 13:55:53 +0200 Subject: [PATCH 17/28] Fixed it properly. --- src/codegen_new/codegen.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/codegen_new/codegen.c b/src/codegen_new/codegen.c index fb47981c3..d49fcecbf 100644 --- a/src/codegen_new/codegen.c +++ b/src/codegen_new/codegen.c @@ -374,7 +374,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p codeblock_t *block = &codeblock[block_current]; ir_data_t *ir = codegen_get_ir_data(); uint32_t op_pc = new_pc; - OpFn *op_table = (OpFn *) x86_dynarec_opcodes; + const OpFn *op_table = (OpFn *) x86_dynarec_opcodes; RecompOpFn *recomp_op_table = recomp_opcodes; int opcode_shift = 0; int opcode_mask = 0x3ff; @@ -398,7 +398,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0x0f; #endif - op_table = (OpFn *) x86_dynarec_opcodes_0f; + op_table = x86_dynarec_opcodes_0f; recomp_op_table = recomp_opcodes_0f; over = 1; break; @@ -439,7 +439,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xd8; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_d8_a32 : (OpFn *) x86_dynarec_opcodes_d8_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d8; opcode_shift = 3; opcode_mask = 0x1f; @@ -452,7 +452,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xd9; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_d9_a32 : (OpFn *) x86_dynarec_opcodes_d9_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d9_a32 : x86_dynarec_opcodes_d9_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_d9; opcode_mask = 0xff; over = 1; @@ -464,7 +464,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xda; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_da_a32 : (OpFn *) x86_dynarec_opcodes_da_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_da_a32 : x86_dynarec_opcodes_da_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_da; opcode_mask = 0xff; over = 1; @@ -476,7 +476,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdb; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_db_a32 : (OpFn *) x86_dynarec_opcodes_db_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_db_a32 : x86_dynarec_opcodes_db_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_db; opcode_mask = 0xff; over = 1; @@ -488,7 +488,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdc; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_dc_a32 : (OpFn *) x86_dynarec_opcodes_dc_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dc_a32 : x86_dynarec_opcodes_dc_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dc; opcode_shift = 3; opcode_mask = 0x1f; @@ -501,7 +501,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdd; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_dd_a32 : (OpFn *) x86_dynarec_opcodes_dd_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dd_a32 : x86_dynarec_opcodes_dd_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_dd; opcode_mask = 0xff; over = 1; @@ -513,7 +513,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xde; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_de_a32 : (OpFn *) x86_dynarec_opcodes_de_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_de_a32 : x86_dynarec_opcodes_de_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_de; opcode_mask = 0xff; over = 1; @@ -525,7 +525,7 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xdf; #endif - op_table = (op_32 & 0x200) ? (OpFn *) x86_dynarec_opcodes_df_a32 : (OpFn *) x86_dynarec_opcodes_df_a16; + op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_df_a32 : x86_dynarec_opcodes_df_a16; recomp_op_table = fpu_softfloat ? NULL : recomp_opcodes_df; opcode_mask = 0xff; over = 1; @@ -541,14 +541,14 @@ codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_p #ifdef DEBUG_EXTRA last_prefix = 0xf2; #endif - op_table = (OpFn *) x86_dynarec_opcodes_REPNE; + op_table = x86_dynarec_opcodes_REPNE; recomp_op_table = NULL; // recomp_opcodes_REPNE; break; case 0xf3: /*REPE*/ #ifdef DEBUG_EXTRA last_prefix = 0xf3; #endif - op_table = (OpFn *) x86_dynarec_opcodes_REPE; + op_table = x86_dynarec_opcodes_REPE; recomp_op_table = NULL; // recomp_opcodes_REPE; break; From eb4c9f3e40ab6bf8063fb96b0d6353ab56ecfe54 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 14:00:18 +0200 Subject: [PATCH 18/28] Fixed warnings in the VISO and Wacom Tablet codes. --- src/cdrom/cdrom_image_viso.c | 6 +++++- src/device/mouse_wacom_tablet.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cdrom/cdrom_image_viso.c b/src/cdrom/cdrom_image_viso.c index 7d24a1c9e..2feff2aff 100644 --- a/src/cdrom/cdrom_image_viso.c +++ b/src/cdrom/cdrom_image_viso.c @@ -632,7 +632,11 @@ pad_susp: } if ((p - data) > 255) - fatal("VISO: Directory record overflow (%d) on entry %08X\n", p - data, entry); +#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64) + fatal("VISO: Directory record overflow (%d) on entry %016" PRIX64 "\n", (uint32_t) (uintptr_t) (p - data), (uint64_t) (uintptr_t) entry); +#else + fatal("VISO: Directory record overflow (%d) on entry %08X\n", (uint32_t) (uintptr_t) (p - data), (uint32_t) (uintptr_t) entry); +#endif data[0] = p - data; /* length */ return data[0]; diff --git a/src/device/mouse_wacom_tablet.c b/src/device/mouse_wacom_tablet.c index d9466146d..fa5c4651f 100644 --- a/src/device/mouse_wacom_tablet.c +++ b/src/device/mouse_wacom_tablet.c @@ -134,6 +134,8 @@ typedef struct { serial_t *serial; } mouse_wacom_t; +/* TODO: What is this needed for? */ +#if 0 static unsigned int reverse(register unsigned int x) { @@ -143,6 +145,7 @@ reverse(register unsigned int x) x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return ((x >> 16) | (x << 16)); } +#endif static double wacom_transmit_period(mouse_wacom_t *dev, int bps, int rps) From 3ec3dfa2213300c6d7e884c6eb494f480b8ec023 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 14:07:43 +0200 Subject: [PATCH 19/28] Fixed a warning in win/win_serial_passthrough.c. --- src/win/win_serial_passthrough.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/win/win_serial_passthrough.c b/src/win/win_serial_passthrough.c index 78ed1a766..cfe920aa7 100644 --- a/src/win/win_serial_passthrough.c +++ b/src/win/win_serial_passthrough.c @@ -166,7 +166,8 @@ static int open_pseudo_terminal(serial_passthrough_t *dev) { char ascii_pipe_name[1024] = { 0 }; - strncpy(ascii_pipe_name, dev->named_pipe, 1023); + strncpy(ascii_pipe_name, dev->named_pipe, sizeof(ascii_pipe_name)); + ascii_pipe_name[1023] = '\0'; dev->master_fd = (intptr_t) CreateNamedPipeA(ascii_pipe_name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 65536, 65536, NMPWAIT_USE_DEFAULT_WAIT, NULL); if (dev->master_fd == (intptr_t) INVALID_HANDLE_VALUE) { wchar_t errorMsg[1024] = { 0 }; From a62b484a8131c0810a26bc578ca39c6ef0f4d7e7 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 14:10:47 +0200 Subject: [PATCH 20/28] Fixed a warning in usb.c. --- src/usb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/usb.c b/src/usb.c index 9993193ce..5f2b95084 100644 --- a/src/usb.c +++ b/src/usb.c @@ -342,6 +342,8 @@ ohci_set_interrupt(usb_t *dev, uint8_t bit) ohci_update_irq(dev); } +/* TODO: Actually use this function somewhere. */ +#if 0 /* Next two functions ported over from QEMU. */ static int ohci_copy_td_input(usb_t* dev, usb_td_t *td, uint8_t *buf, int len) @@ -363,6 +365,7 @@ static int ohci_copy_td_input(usb_t* dev, usb_td_t *td, dma_bm_write(ptr, buf, len - n, 1); return 0; } +#endif static int ohci_copy_td_output(usb_t* dev, usb_td_t *td, uint8_t *buf, int len) From bf8e695d943e8350e6f5eb686e1d561ae6579bed Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Sun, 11 Jun 2023 11:54:01 -0400 Subject: [PATCH 21/28] qt: Clean up some warnings --- src/qt/qt_deviceconfig.cpp | 4 +--- src/qt/qt_rendererstack.cpp | 2 +- src/qt/qt_settingsnetwork.cpp | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/qt/qt_deviceconfig.cpp b/src/qt/qt_deviceconfig.cpp index 233a16851..eaa5e9566 100644 --- a/src/qt/qt_deviceconfig.cpp +++ b/src/qt/qt_deviceconfig.cpp @@ -109,7 +109,6 @@ DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *se { DeviceConfig dc(settings); dc.setWindowTitle(QString("%1 Device Configuration").arg(device->name)); - int c; int p; int q; @@ -216,7 +215,7 @@ DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *se char *selected; selected = config_get_string(device_context.name, const_cast(config->name), const_cast(config->default_string)); - c = q = 0; + q = 0; for (auto *bios = config->bios; (bios != nullptr) && (bios->name != nullptr) && (strlen(bios->name) > 0); ++bios) { p = 0; for (int d = 0; d < bios->files_no; d++) @@ -226,7 +225,6 @@ DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *se if (!strcmp(selected, bios->internal_name)) { currentIndex = row; } - c++; } q++; } diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index f2a7f38ec..ee87dccb8 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -327,7 +327,7 @@ RendererStack::switchRenderer(Renderer renderer) createRenderer(renderer); disconnect(this, &RendererStack::blit, this, &RendererStack::blitDummy); blitDummied = false; - QTimer::singleShot(1000, this, [this]() { blitDummied = false; }); + QTimer::singleShot(1000, this, []() { blitDummied = false; }); }); rendererWindow->hasBlitFunc() ? current.reset() : current.release()->deleteLater(); diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 30e296f05..5b5d1b1ee 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -64,7 +64,6 @@ SettingsNetwork::SettingsNetwork(QWidget *parent) auto *nic_cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); auto *net_type_cbox = findChild(QString("comboBoxNet%1").arg(i + 1)); auto *intf_cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); - auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); connect(nic_cbox, QOverload::of(&QComboBox::currentIndexChanged), this, &SettingsNetwork::on_comboIndexChanged); connect(net_type_cbox, QOverload::of(&QComboBox::currentIndexChanged), this, &SettingsNetwork::on_comboIndexChanged); connect(intf_cbox, QOverload::of(&QComboBox::currentIndexChanged), this, &SettingsNetwork::on_comboIndexChanged); From f4c59e907da2d1366ede222fba05bf0515979a01 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 22:07:32 +0200 Subject: [PATCH 22/28] Removed mmu_invalidate(). --- src/cpu/x86_ops_pmode.h | 2 +- src/include/86box/mem.h | 1 - src/mem/mem.c | 6 ------ src/video/vid_sigma.c | 4 ++-- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/cpu/x86_ops_pmode.h b/src/cpu/x86_ops_pmode.h index 4fee881ea..7e9f05a63 100644 --- a/src/cpu/x86_ops_pmode.h +++ b/src/cpu/x86_ops_pmode.h @@ -461,7 +461,7 @@ op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) break; } SEG_CHECK_READ(cpu_state.ea_seg); - mmu_invalidate(ds + cpu_state.eaaddr); + flushmmucache_cr3(); CLOCK_CYCLES(12); PREFETCH_RUN(12, 2, rmdat, 0, 0, 0, 0, ea32); break; diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 0f4f0b62e..4bdf185af 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -415,7 +415,6 @@ extern void mem_reset_page_blocks(void); extern void flushmmucache(void); extern void flushmmucache_nopc(void); -extern void mmu_invalidate(uint32_t addr); extern void mem_a20_init(void); extern void mem_a20_recalc(void); diff --git a/src/mem/mem.c b/src/mem/mem.c index 6c994d156..68a66922f 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -544,12 +544,6 @@ mmutranslate_noabrt(uint32_t addr, int rw) return mmutranslate_noabrt_normal(addr, rw); } -void -mmu_invalidate(uint32_t addr) -{ - flushmmucache_cr3(); -} - uint8_t mem_addr_range_match(uint32_t addr, uint32_t start, uint32_t len) { diff --git a/src/video/vid_sigma.c b/src/video/vid_sigma.c index a8f946e25..125626007 100644 --- a/src/video/vid_sigma.c +++ b/src/video/vid_sigma.c @@ -246,7 +246,7 @@ sigma_out(uint16_t addr, uint8_t val, void *p) return; case 0x2DD: /* Page in RAM at 0xC1800 */ if (sigma->rom_paged != 0) - mmu_invalidate(0xC0000); + flushmmucache_cr3(); sigma->rom_paged = 0x00; return; @@ -290,7 +290,7 @@ sigma_in(uint16_t addr, void *p) case 0x2DD: /* Page in ROM at 0xC1800 */ result = (sigma->rom_paged ? 0x80 : 0); if (sigma->rom_paged != 0x80) - mmu_invalidate(0xC0000); + flushmmucache_cr3(); sigma->rom_paged = 0x80; break; case 0x3D1: From e4d860c025e505dcf89fa9afa6b7a317a514b6ad Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 22:12:18 +0200 Subject: [PATCH 23/28] Replaced calls to flushmmucache_cr3() to direct calls to flushmmucache_nopc() and removed the #define. --- src/cpu/386_common.c | 4 ++-- src/cpu/x86_ops_misc.h | 2 +- src/cpu/x86_ops_pmode.h | 2 +- src/cpu/x86seg.c | 34 +++++++++++++++++----------------- src/include/86box/mem.h | 2 -- src/mem/mem.c | 2 +- src/video/vid_sigma.c | 4 ++-- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/cpu/386_common.c b/src/cpu/386_common.c index 25afccc95..760e41eaa 100644 --- a/src/cpu/386_common.c +++ b/src/cpu/386_common.c @@ -1683,7 +1683,7 @@ sysexit(uint32_t fetchdat) cpu_cur_status &= ~(CPU_STATUS_NOTFLATSS /* | CPU_STATUS_V86*/); cpu_cur_status |= (CPU_STATUS_USE32 | CPU_STATUS_STACK32 | CPU_STATUS_PMODE); - flushmmucache_cr3(); + flushmmucache_nopc(); set_use32(1); set_stack32(1); @@ -1804,7 +1804,7 @@ sysret(uint32_t fetchdat) cpu_cur_status &= ~(CPU_STATUS_NOTFLATSS /* | CPU_STATUS_V86*/); cpu_cur_status |= (CPU_STATUS_USE32 | CPU_STATUS_STACK32 | CPU_STATUS_PMODE); - flushmmucache_cr3(); + flushmmucache_nopc(); set_use32(1); set_stack32(1); diff --git a/src/cpu/x86_ops_misc.h b/src/cpu/x86_ops_misc.h index bd1139ba4..940e2ea8e 100644 --- a/src/cpu/x86_ops_misc.h +++ b/src/cpu/x86_ops_misc.h @@ -996,7 +996,7 @@ opLOADALL386(uint32_t fetchdat) loadall_load_segment(la_addr + 0xc0, &cpu_state.seg_es); if (CPL == 3 && oldcpl != 3) - flushmmucache_cr3(); + flushmmucache_nopc(); oldcpl = CPL; CLOCK_CYCLES(350); diff --git a/src/cpu/x86_ops_pmode.h b/src/cpu/x86_ops_pmode.h index 7e9f05a63..c8e146450 100644 --- a/src/cpu/x86_ops_pmode.h +++ b/src/cpu/x86_ops_pmode.h @@ -461,7 +461,7 @@ op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) break; } SEG_CHECK_READ(cpu_state.ea_seg); - flushmmucache_cr3(); + flushmmucache_nopc(); CLOCK_CYCLES(12); PREFETCH_RUN(12, 2, rmdat, 0, 0, 0, 0, ea32); break; diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index 5b0d8b73a..7f630275c 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -580,7 +580,7 @@ loadcs(uint16_t seg) do_seg_load(&cpu_state.seg_cs, segdat); use32 = (segdat[3] & 0x40) ? 0x300 : 0; if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -609,7 +609,7 @@ loadcs(uint16_t seg) cpu_state.seg_cs.access = (cpu_state.eflags & VM_FLAG) ? 0xe2 : 0x82; cpu_state.seg_cs.ar_high = 0x10; if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -673,7 +673,7 @@ loadcsjmp(uint16_t seg, uint32_t old_pc) do_seg_load(&cpu_state.seg_cs, segdat); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -751,7 +751,7 @@ loadcsjmp(uint16_t seg, uint32_t old_pc) CS = seg2; do_seg_load(&cpu_state.seg_cs, segdat); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -794,7 +794,7 @@ loadcsjmp(uint16_t seg, uint32_t old_pc) cpu_state.seg_cs.access = (cpu_state.eflags & VM_FLAG) ? 0xe2 : 0x82; cpu_state.seg_cs.ar_high = 0x10; if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -957,7 +957,7 @@ loadcscall(uint16_t seg) CS = seg; do_seg_load(&cpu_state.seg_cs, segdat); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1100,7 +1100,7 @@ loadcscall(uint16_t seg) CS = seg2; do_seg_load(&cpu_state.seg_cs, segdat); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1182,7 +1182,7 @@ loadcscall(uint16_t seg) CS = seg2; do_seg_load(&cpu_state.seg_cs, segdat); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1227,7 +1227,7 @@ loadcscall(uint16_t seg) cpu_state.seg_cs.access = (cpu_state.eflags & VM_FLAG) ? 0xe2 : 0x82; cpu_state.seg_cs.ar_high = 0x10; if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1332,7 +1332,7 @@ pmoderetf(int is32, uint16_t off) do_seg_load(&cpu_state.seg_cs, segdat); cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | ((CS & 3) << 5); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1445,7 +1445,7 @@ pmoderetf(int is32, uint16_t off) CS = seg; do_seg_load(&cpu_state.seg_cs, segdat); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1697,7 +1697,7 @@ pmodeint(int num, int soft) CS = (seg & 0xfffc) | new_cpl; cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~0x60) | (new_cpl << 5); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1863,7 +1863,7 @@ pmodeiret(int is32) cpu_state.seg_cs.access = 0xe2; cpu_state.seg_cs.ar_high = 0x10; if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -1948,7 +1948,7 @@ pmodeiret(int is32) do_seg_load(&cpu_state.seg_cs, segdat); cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~0x60) | ((CS & 0x0003) << 5); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -2037,7 +2037,7 @@ pmodeiret(int is32) do_seg_load(&cpu_state.seg_cs, segdat); cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~0x60) | ((CS & 3) << 5); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -2233,7 +2233,7 @@ taskswitch286(uint16_t seg, uint16_t *segdat, int is32) CS = new_cs; do_seg_load(&cpu_state.seg_cs, segdat2); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif @@ -2401,7 +2401,7 @@ taskswitch286(uint16_t seg, uint16_t *segdat, int is32) CS = new_cs; do_seg_load(&cpu_state.seg_cs, segdat2); if ((CPL == 3) && (oldcpl != 3)) - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef USE_NEW_DYNAREC oldcpl = CPL; #endif diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 4bdf185af..45520f709 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -157,8 +157,6 @@ mem_set_access((smm ? ACCESS_CPU_SMM : ACCESS_CPU), 1, base, size, is_smram) #define mem_set_access_smram_bus(smm, base, size, is_smram) \ mem_set_access((smm ? ACCESS_BUS_SMM : ACCESS_BUS), 1, base, size, is_smram) -#define flushmmucache_cr3 \ - flushmmucache_nopc typedef struct { uint16_t x : 5, diff --git a/src/mem/mem.c b/src/mem/mem.c index 68a66922f..98acd8c97 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -2319,7 +2319,7 @@ mem_mapping_recalc(uint64_t base, uint64_t size) map = map->next; } - flushmmucache_cr3(); + flushmmucache_nopc(); #ifdef ENABLE_MEM_LOG pclog("\nMemory map:\n"); diff --git a/src/video/vid_sigma.c b/src/video/vid_sigma.c index 125626007..148dcc81c 100644 --- a/src/video/vid_sigma.c +++ b/src/video/vid_sigma.c @@ -246,7 +246,7 @@ sigma_out(uint16_t addr, uint8_t val, void *p) return; case 0x2DD: /* Page in RAM at 0xC1800 */ if (sigma->rom_paged != 0) - flushmmucache_cr3(); + flushmmucache_nopc(); sigma->rom_paged = 0x00; return; @@ -290,7 +290,7 @@ sigma_in(uint16_t addr, void *p) case 0x2DD: /* Page in ROM at 0xC1800 */ result = (sigma->rom_paged ? 0x80 : 0); if (sigma->rom_paged != 0x80) - flushmmucache_cr3(); + flushmmucache_nopc(); sigma->rom_paged = 0x80; break; case 0x3D1: From 68e6d7eb4040f1e22fdaa1c1d84c82fda415190e Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 22:13:55 +0200 Subject: [PATCH 24/28] And the forgotten one in chipset/scat.c. --- src/chipset/scat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chipset/scat.c b/src/chipset/scat.c index fe3846d89..e2c1bf103 100644 --- a/src/chipset/scat.c +++ b/src/chipset/scat.c @@ -1007,7 +1007,7 @@ memmap_state_update(scat_t *dev) set_global_EMS_state(dev, dev->regs[SCAT_EMS_CONTROL] & 0x80); - flushmmucache_cr3(); + flushmmucache_nopc(); } static void From 68e970b9cd9dab812715642e5359e930959f339d Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 11 Jun 2023 22:58:16 +0200 Subject: [PATCH 25/28] Joystick Raw Input: Do not add the axis if the center is 0 - prevents malformed vJoy 2.0.5 axes from causing 86Box to crash with a division by zero. --- src/qt/win_joystick_rawinput.c | 7 ++++++- src/win/win_joystick_rawinput.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qt/win_joystick_rawinput.c b/src/qt/win_joystick_rawinput.c index c4424e484..e5d477296 100644 --- a/src/qt/win_joystick_rawinput.c +++ b/src/qt/win_joystick_rawinput.c @@ -98,6 +98,8 @@ joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage) void joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop) { + LONG center; + if (joy->nr_axes >= 8) return; @@ -141,7 +143,10 @@ joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS } rawjoy->axis[joy->nr_axes].min = prop->LogicalMin; - joy->nr_axes++; + center = (rawjoy->axis[joy->nr_axes].max - rawjoy->axis[joy->nr_axes].min + 1) / 2; + + if (center != 0x00) + joy->nr_axes++; } void diff --git a/src/win/win_joystick_rawinput.c b/src/win/win_joystick_rawinput.c index 0bdb99a7a..6f2a1e4c0 100644 --- a/src/win/win_joystick_rawinput.c +++ b/src/win/win_joystick_rawinput.c @@ -99,6 +99,8 @@ joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage) void joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop) { + LONG center; + if (joy->nr_axes >= 8) return; @@ -142,7 +144,10 @@ joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS } rawjoy->axis[joy->nr_axes].min = prop->LogicalMin; - joy->nr_axes++; + center = (rawjoy->axis[joy->nr_axes].max - rawjoy->axis[joy->nr_axes].min + 1) / 2; + + if (center != 0x00) + joy->nr_axes++; } void From bff479fc0fc3aff897abc5bc75dd1bf5ec25ff3b Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 12 Jun 2023 20:35:45 +0600 Subject: [PATCH 26/28] unix_serial_passthrough: Define cleanups and changes --- src/unix/unix_serial_passthrough.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/unix_serial_passthrough.c b/src/unix/unix_serial_passthrough.c index 033fc1e87..61f23c345 100644 --- a/src/unix/unix_serial_passthrough.c +++ b/src/unix/unix_serial_passthrough.c @@ -21,7 +21,7 @@ # define _DEFAULT_SOURCE 1 # define _BSD_SOURCE 1 #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) # define __BSD_VISIBLE 1 #endif #include @@ -168,7 +168,7 @@ plat_serpt_set_params(void *p) term_attr.c_cflag &= CSTOPB; if (dev->serial->lcr & 0x04) term_attr.c_cflag |= CSTOPB; -#if defined(__APPLE__) || defined(__FreeBSD__) +#if !defined(__linux__) term_attr.c_cflag &= PARENB | PARODD; #else term_attr.c_cflag &= PARENB | PARODD | CMSPAR; @@ -177,7 +177,7 @@ plat_serpt_set_params(void *p) term_attr.c_cflag |= PARENB; if (!(dev->serial->lcr & 0x10)) term_attr.c_cflag |= PARODD; -#if !defined(__APPLE__) && !defined(__FreeBSD__) +#if defined(__linux__) if ((dev->serial->lcr & 0x20)) term_attr.c_cflag |= CMSPAR; #endif From 491ee9de7e594008324f57a27bd6ca361ad8171e Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Tue, 13 Jun 2023 00:59:48 +0600 Subject: [PATCH 27/28] cmake: Include freetype directory properly on FreeBSD (#3403) --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77de8aad9..3809ead73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -109,6 +109,9 @@ endif() find_package(Freetype REQUIRED) include_directories(${FREETYPE_INCLUDE_DIRS}) +if(FREETYPE_INCLUDE_DIR_ft2build) + include_directories(${FREETYPE_INCLUDE_DIR_ft2build}) +endif() if(APPLE) # Freetype is dynamically loaded by the emulator, however, we link it # on macOS so it gets copied to the bundle by the installation process From 231e995434bf2837cccc4aef75b5500aa8915a8c Mon Sep 17 00:00:00 2001 From: richardg867 Date: Mon, 12 Jun 2023 16:07:28 -0300 Subject: [PATCH 28/28] Jenkins: Update AppImage openal-soft to 1.23.1 --- .ci/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.ci/build.sh b/.ci/build.sh index 448b99160..432599bd7 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -876,13 +876,13 @@ else if grep -q "OPENAL:BOOL=ON" build/CMakeCache.txt then - # Build openal-soft 1.22.2 manually to fix audio issues. This is a temporary + # Build openal-soft 1.23.1 manually to fix audio issues. This is a temporary # workaround until a newer version of openal-soft trickles down to Debian repos. - prefix="$cache_dir/openal-soft-1.22.2" + prefix="$cache_dir/openal-soft-1.23.1" if [ ! -d "$prefix" ] then rm -rf "$cache_dir/openal-soft-"* # remove old versions - wget -qO - https://github.com/kcat/openal-soft/archive/refs/tags/1.22.2.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix" + wget -qO - https://github.com/kcat/openal-soft/archive/refs/tags/1.23.1.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix" fi # Patches to build with the old PipeWire version in Debian. @@ -890,7 +890,7 @@ else sed -i -e 's/PW_KEY_CONFIG_NAME/"config.name"/g' "$prefix/alc/backends/pipewire.cpp" prefix_build="$prefix/build-$arch_deb" - cmake -G Ninja -D "CMAKE_TOOLCHAIN_FILE=$toolchain_file" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99 + cmake -G Ninja -D ALSOFT_UTILS=OFF -D ALSOFT_EXAMPLES=OFF -D "CMAKE_TOOLCHAIN_FILE=$toolchain_file" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99 cmake --build "$prefix_build" -j$(nproc) || exit 99 cmake --install "$prefix_build" || exit 99