From d31bca5279ec628577bd7bbbd058c11df0dda4d0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 12 Dec 2020 10:18:00 +0100 Subject: [PATCH 1/9] Removed two void returns (how that even valid?!) from the 808x code. --- src/cpu/808x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpu/808x.c b/src/cpu/808x.c index bb579f473..c14a2b604 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -462,9 +462,9 @@ static void writemem(uint32_t s, uint16_t v) { if (opcode & 1) - return writememw(s, cpu_state.eaaddr, v); + writememw(s, cpu_state.eaaddr, v); else - return writememb(s, cpu_state.eaaddr, (uint8_t) (v & 0xff)); + writememb(s, cpu_state.eaaddr, (uint8_t) (v & 0xff)); } From a55b9c6512669b456102e262d9f41c9728647ff4 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 12 Dec 2020 15:59:10 +0100 Subject: [PATCH 2/9] Fixed 8-bit XCHG instruction on the 64-bit old recompiler when both source and destination are a high 8-bit register (AH, CH, BH, or DH), fixes the longstanding Chicago 58s bug. --- src/codegen/codegen_ops_x86-64.h | 43 +++++++++++++------------------- src/codegen/codegen_ops_xchg.h | 4 --- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/codegen/codegen_ops_x86-64.h b/src/codegen/codegen_ops_x86-64.h index 7655c8d13..aa8feb8cc 100644 --- a/src/codegen/codegen_ops_x86-64.h +++ b/src/codegen/codegen_ops_x86-64.h @@ -297,33 +297,26 @@ static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) addbyte(0x44); addbyte(0x89); addbyte(0xc0 | ((host_reg & 3) << 3)); - if (host_reg & 0x10) - { - addbyte(0x66); /*AND AX, 0xff00*/ - addbyte(0x25); - addword(0xff00); - } - else - { - addbyte(0x66); /*SHL AX, 8*/ - addbyte(0xc1); - addbyte(0xe0); - addbyte(0x08); - } } - else - { - if (host_reg) - { - addbyte(0x66); /*MOV AX, host_reg*/ - addbyte(0x89); - addbyte(0xc0 | ((host_reg & 3) << 3)); - } - addbyte(0x66); /*SHL AX, 8*/ - addbyte(0xc1); - addbyte(0xe0); - addbyte(0x08); + else if (host_reg & 3) + { + addbyte(0x66); /*MOV AX, host_reg*/ + addbyte(0x89); + addbyte(0xc0 | ((host_reg & 3) << 3)); } + if (host_reg & 0x10) + { + addbyte(0x66); /*AND AX, 0xff00*/ + addbyte(0x25); + addword(0xff00); + } + else + { + addbyte(0x66); /*SHL AX, 8*/ + addbyte(0xc1); + addbyte(0xe0); + addbyte(0x08); + } addbyte(0x66); /*AND dest_reg, 0x00ff*/ addbyte(0x41); addbyte(0x81); diff --git a/src/codegen/codegen_ops_xchg.h b/src/codegen/codegen_ops_xchg.h index 597d26e1b..76cb9e437 100644 --- a/src/codegen/codegen_ops_xchg.h +++ b/src/codegen/codegen_ops_xchg.h @@ -44,9 +44,6 @@ OP_XCHG_EAX_(EBP) static uint32_t ropXCHG_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { -/* #ifdef __amd64__ - return 0; -#else */ int src_reg, dst_reg, temp_reg; if ((fetchdat & 0xc0) != 0xc0) @@ -59,7 +56,6 @@ static uint32_t ropXCHG_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin STORE_REG_TARGET_B_RELEASE(temp_reg, fetchdat & 7); return op_pc + 1; -/* #endif */ } static uint32_t ropXCHG_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { From 66ca9aa6aac32e8ca45dc491feba3c9aec838a0b Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 12 Dec 2020 16:11:06 +0100 Subject: [PATCH 3/9] Fixed two warnings on the old recompiler when compiling for 64-bit. --- src/codegen/codegen_ops_fpu.h | 2 +- src/codegen/codegen_ops_mmx.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen/codegen_ops_fpu.h b/src/codegen/codegen_ops_fpu.h index 481eadb8c..b15d41bff 100644 --- a/src/codegen/codegen_ops_fpu.h +++ b/src/codegen/codegen_ops_fpu.h @@ -146,7 +146,7 @@ static uint32_t ropFSTs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 static uint32_t ropFSTd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - int host_reg1, host_reg2; + int host_reg1, host_reg2 = 0; FP_ENTER(); op_pc--; diff --git a/src/codegen/codegen_ops_mmx.h b/src/codegen/codegen_ops_mmx.h index 14730cb93..b669567fd 100644 --- a/src/codegen/codegen_ops_mmx.h +++ b/src/codegen/codegen_ops_mmx.h @@ -1,6 +1,6 @@ static uint32_t ropMOVQ_q_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int host_reg1, host_reg2; + int host_reg1, host_reg2 = 0; MMX_ENTER(); From 12a78cb2f446643150a078101cf4d69e34ad56a0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 12 Dec 2020 16:25:04 +0100 Subject: [PATCH 4/9] Fixed a SLiRP warning when compiling for 64-bit. --- src/network/net_slirp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index 80161b4be..ddfeba6cf 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -150,7 +150,7 @@ net_slirp_notify(void *opaque) } -int +ssize_t net_slirp_send_packet(const void *qp, size_t pkt_len, void *opaque) { slirp_t *slirp = (slirp_t *) opaque; From 9d6f6b38ea87e42d5abeb329d2c20bbdde5c34c8 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 12 Dec 2020 16:28:04 +0100 Subject: [PATCH 5/9] Fixed a warning in cdrom/cdrom_image_backend.c. --- src/cdrom/cdrom_image_backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cdrom/cdrom_image_backend.c b/src/cdrom/cdrom_image_backend.c index 96f60ed61..3db993b8a 100644 --- a/src/cdrom/cdrom_image_backend.c +++ b/src/cdrom/cdrom_image_backend.c @@ -425,8 +425,8 @@ int cdi_read_sectors(cd_img_t *cdi, uint8_t *buffer, int raw, uint32_t sector, uint32_t num) { int sector_size, success = 1; - uint8_t buf_len, *buf; - uint32_t i; + uint8_t *buf; + uint32_t buf_len, i; /* TODO: This fails to account for Mode 2. Shouldn't we have a function to get sector size? */ From 101e78c33b95e1be07ac169ff931f629fef9aaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sat, 12 Dec 2020 20:31:00 +0100 Subject: [PATCH 6/9] workflows: x64 build --- .github/workflows/c-cpp.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 277acdaee..4734f1bc4 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -14,6 +14,7 @@ on: jobs: build: + name: Build (DEV_BUILD=${{ matrix.dev-build }}, NEW_DYNAREC=${{ matrix.new-dynarec }}, X64=${{ matrix.target-arch.x64 }}) runs-on: windows-latest @@ -25,14 +26,29 @@ jobs: matrix: dev-build: ['y', 'n'] new-dynarec: ['y', 'n'] + target-arch: + - x64: 'n' + msystem: MINGW32 + prefix: mingw-w64-i686 + - x64: 'y' + msystem: MINGW64 + prefix: mingw-w64-x86_64 steps: - uses: msys2/setup-msys2@v2 with: update: true - msystem: MINGW32 - install: 'make mingw-w64-i686-toolchain mingw-w64-i686-openal mingw-w64-i686-freetype mingw-w64-i686-SDL2 mingw-w64-i686-zlib mingw-w64-i686-libpng mingw-w64-i686-libvncserver' + msystem: ${{ matrix.target-arch.msystem }} + install: >- + make + ${{ matrix.target-arch.prefix }}-toolchain + ${{ matrix.target-arch.prefix }}-openal + ${{ matrix.target-arch.prefix }}-freetype + ${{ matrix.target-arch.prefix }}-SDL2 + ${{ matrix.target-arch.prefix }}-zlib + ${{ matrix.target-arch.prefix }}-libpng + ${{ matrix.target-arch.prefix }}-libvncserver - uses: actions/checkout@v2 - name: make - run: make -fwin/makefile.mingw -j DEV_BUILD=${{ matrix.dev-build }} NEW_DYNAREC=${{ matrix.new-dynarec }} VNC=n + run: make -fwin/makefile.mingw -j DEV_BUILD=${{ matrix.dev-build }} NEW_DYNAREC=${{ matrix.new-dynarec }} X64=${{ matrix.target-arch.x64 }} VNC=n working-directory: ./src From 3c23626eaf2420fc2e609bacad4c861fedad5c95 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 13 Dec 2020 13:35:58 +0100 Subject: [PATCH 7/9] Recorganized the cpu_state struct to be like PCem's, fixes MMX bugs on 64-bit old recompiler (possibly on the new one as well?). --- src/cpu/cpu.h | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 73f9524ad..f21c4822f 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -240,35 +240,22 @@ typedef struct { uint64_t fcr2, fcr3; } msr_t; -typedef union { - uint32_t l; - uint16_t w; -} cr0_t; - - typedef struct { x86reg regs[8]; uint8_t tag[8]; - int8_t ssegs, ismmx, - abrt, pad; - - uint16_t npxs, npxc, flags, eflags, - old_npxc, new_npxc; - - uint16_t MM_w4[8]; - - int _cycles, - flags_op, TOP; - - uint32_t flags_res, - flags_op1, flags_op2, - pc, oldpc, eaaddr, op32; - - cr0_t CR0; - x86seg *ea_seg; + uint32_t eaaddr; + + int flags_op; + uint32_t flags_res, + flags_op1, flags_op2; + + uint32_t pc, + oldpc, op32; + + int TOP; union { struct { @@ -279,10 +266,21 @@ typedef struct { int32_t rm_mod_reg_data; } rm_data; + int8_t ssegs, ismmx, + abrt, pad; + + int _cycles; + + uint16_t npxs, npxc; + double ST[8]; + uint16_t MM_w4[8]; + MMX_REG MM[8]; + uint16_t old_npxc, new_npxc; + #ifdef USE_NEW_DYNAREC uint32_t old_fp_control, new_fp_control; #if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _M_IX86 @@ -295,6 +293,13 @@ typedef struct { x86seg seg_cs, seg_ds, seg_es, seg_ss, seg_fs, seg_gs; + + union { + uint32_t l; + uint16_t w; + } CR0; + + uint16_t flags, eflags; } cpu_state_t; /*The cpu_state.flags below must match in both cpu_cur_status and block->status for a block From e5025d6f5c09a2b3494eb6414fc1d0ed4a592a29 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 13 Dec 2020 13:37:29 +0100 Subject: [PATCH 8/9] Increased the size of the (S)VGA CRTC array to 256 elements (was 128), required by the S3 ViRGE. --- src/include/86box/vid_svga.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index ca7ae4c21..4da5d924e 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -124,7 +124,7 @@ typedef struct svga_t int override; void *p; - uint8_t crtc[128], gdcreg[64], attrregs[32], seqregs[64], + uint8_t crtc[256], gdcreg[64], attrregs[32], seqregs[64], egapal[16], *vram, *changedvram; From 7a905168e282b109e8ed1bcc92b029a8f41e831f Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 13 Dec 2020 13:41:32 +0100 Subject: [PATCH 9/9] And the same goes for the sequencer registers. --- src/include/86box/vid_svga.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 4da5d924e..9fbe4c7fe 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -124,7 +124,7 @@ typedef struct svga_t int override; void *p; - uint8_t crtc[256], gdcreg[64], attrregs[32], seqregs[64], + uint8_t crtc[256], gdcreg[64], attrregs[32], seqregs[256], egapal[16], *vram, *changedvram;