diff --git a/.gitignore b/.gitignore index acb28baf7..48a5950b9 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ CMakeLists.txt.user /debian/debhelper-build-stamp /debian/files /obj-*-linux-gnu + +# MacOS Finder stuff +.DS_Store diff --git a/CMakePresets.json b/CMakePresets.json index d2980ed87..0dbaf1988 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -56,6 +56,72 @@ "NEW_DYNAREC": "ON" }, "inherits": "base" + }, + { + "name": "llvm-macos-aarch64.cmake", + "displayName": "MacOS clang regular", + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "cmake/llvm-macos-aarch64.cmake", + "NEW_DYNAREC": "ON", + "QT": "ON", + "USE_QT6": "OFF", + "Qt5_DIR": "/opt/homebrew/opt/qt@5/lib/cmake/Qt5", + "MOLTENVK_DIR": "/opt/homebrew/opt/molten-vk", + "Qt5LinguistTools_DIR": "/opt/homebrew/opt/qt@5/lib/cmake/Qt5LinguistTools", + "OpenAL_ROOT": "/opt/homebrew/opt/openal-soft" + }, + "inherits": "regular" + }, + { + "name": "llvm-macos-aarch64-debug", + "displayName": "MacOS clang debug", + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "cmake/llvm-macos-aarch64.cmake", + "NEW_DYNAREC": "ON", + "QT": "ON", + "USE_QT6": "OFF", + "Qt5_DIR": "/opt/homebrew/opt/qt@5/lib/cmake/Qt5", + "MOLTENVK_DIR": "/opt/homebrew/opt/molten-vk", + "Qt5LinguistTools_DIR": "/opt/homebrew/opt/qt@5/lib/cmake/Qt5LinguistTools", + "OpenAL_ROOT": "/opt/homebrew/opt/openal-soft", + "CMAKE_CXX_FLAGS_DEBUG": "-g -O0 -DENABLE_VDE_LOG", + "CMAKE_C_FLAGS_DEBUG": "-g -O0 -DENABLE_VDE_LOG" + }, + "inherits": "debug" + }, + { + "name": "flags-gcc-aarch64-debug", + "displayName": "Linux ARM 64 - Debug", + "description": "Linux ARM64 - Debug build", + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "cacheVariables": { + "NEW_DYNAREC": "ON", + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_TOOLCHAIN_FILE": "cmake/flags-gcc-aarch64.cmake", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_CXX_FLAGS_DEBUG": "-g -O0 -DENABLE_VDE_LOG", + "CMAKE_C_FLAGS_DEBUG": "-g -O0 -DENABLE_VDE_LOG" + }, + "inherits": "debug" + }, + { + "name": "flags-gcc-aarch64-regular", + "displayName": "Linux ARM 64 - Regular", + "description": "Linux ARM64 - Release build", + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "cacheVariables": { + "NEW_DYNAREC": "ON", + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_TOOLCHAIN_FILE": "cmake/flags-gcc-aarch64.cmake", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" + }, + "inherits": "regular" } ], "buildPresets": [], diff --git a/src/chipset/ali1543.c b/src/chipset/ali1543.c index b587f91b5..2e2f74305 100644 --- a/src/chipset/ali1543.c +++ b/src/chipset/ali1543.c @@ -59,6 +59,7 @@ typedef struct ali1543_t { sff8038i_t *ide_controller[2]; smbus_ali7101_t *smbus; usb_t *usb; + usb_params_t usb_params; } ali1543_t; @@ -905,7 +906,12 @@ ali5237_write(int func, int addr, uint8_t val, void *priv) case 0x0c: /* Cache Line Size */ case 0x0d: /* Latency Timer */ + dev->usb_conf[addr] = val; + break; + case 0x3c: /* Interrupt Line Register */ + dev->usb_conf[addr] = val; + break; case 0x42: /* Test Mode Register */ dev->usb_conf[addr] = val & 0x10; @@ -1424,6 +1430,17 @@ ali7101_read(int func, int addr, void *priv) return ret; } +static void +ali5237_usb_update_interrupt(usb_t* usb, void *priv) +{ + ali1543_t *dev = (ali1543_t *) priv; + + if (usb->irq_level) + pci_set_mirq(4, !!(dev->pci_conf[0x74] & 0x10)); + else + pci_clear_mirq(4, !!(dev->pci_conf[0x74] & 0x10)); +} + static void ali1543_reset(void *priv) { @@ -1574,7 +1591,10 @@ ali1543_init(const device_t *info) dev->smbus = device_add(&ali7101_smbus_device); /* USB */ - dev->usb = device_add(&usb_device); + dev->usb_params.parent_priv = dev; + dev->usb_params.smi_handle = NULL; + dev->usb_params.update_interrupt = ali5237_usb_update_interrupt; + dev->usb = device_add_parameters(&usb_device, &dev->usb_params); dev->type = info->local & 0xff; dev->offset = (info->local >> 8) & 0x7f; diff --git a/src/chipset/intel_piix.c b/src/chipset/intel_piix.c index 718df8344..470978611 100644 --- a/src/chipset/intel_piix.c +++ b/src/chipset/intel_piix.c @@ -77,6 +77,7 @@ typedef struct _piix_ { piix_io_trap_t io_traps[26]; port_92_t *port_92; pc_timer_t fast_off_timer; + usb_params_t usb_params; } piix_t; #ifdef ENABLE_PIIX_LOG @@ -1425,6 +1426,17 @@ piix_fast_off_count(void *priv) dev->regs[0][0xaa] |= 0x20; } +static void +piix_usb_update_interrupt(usb_t* usb, void *priv) +{ + piix_t *dev = (piix_t *) priv; + + if (usb->irq_level) + pci_set_irq(dev->pci_slot, PCI_INTD); + else + pci_clear_irq(dev->pci_slot, PCI_INTD); +} + static void piix_reset(void *p) { @@ -1569,8 +1581,12 @@ piix_init(const device_t *info) sff_set_irq_mode(dev->bm[1], 1, 2); } - if (dev->type >= 3) - dev->usb = device_add(&usb_device); + if (dev->type >= 3) { + dev->usb_params.parent_priv = dev; + dev->usb_params.smi_handle = NULL; + dev->usb_params.update_interrupt = piix_usb_update_interrupt; + dev->usb = device_add_parameters(&usb_device, &dev->usb_params); + } if (dev->type > 3) { dev->nvr = device_add(&piix4_nvr_device); diff --git a/src/chipset/sis_5571.c b/src/chipset/sis_5571.c index 0f77a1a07..c158e2d63 100644 --- a/src/chipset/sis_5571.c +++ b/src/chipset/sis_5571.c @@ -83,6 +83,8 @@ typedef struct sis_5571_t { smram_t *smram; usb_t *usb; + usb_params_t usb_params; + } sis_5571_t; static void @@ -638,6 +640,42 @@ pci_isa_bridge_read(int func, int addr, void *priv) } } +static void +sis_5571_usb_update_interrupt(usb_t* usb, void* priv) +{ + sis_5571_t *dev = (sis_5571_t *) priv; + + if (dev->pci_conf_sb[0][0x68] & 0x80) { + /* TODO: Is the normal PCI interrupt inhibited when USB IRQ remapping is enabled? */ + switch (dev->pci_conf_sb[0][0x68] & 0x0F) { + case 0x00: + case 0x01: + case 0x02: + case 0x08: + case 0x0d: + break; + default: + if (usb->irq_level) + picint(1 << dev->pci_conf_sb[0][0x68] & 0x0f); + else + picintc(1 << dev->pci_conf_sb[0][0x68] & 0x0f); + break; + } + } else { + if (usb->irq_level) + pci_set_irq(dev->sb_pci_slot, PCI_INTA); + else + pci_clear_irq(dev->sb_pci_slot, PCI_INTA); + } +} + +static uint8_t +sis_5571_usb_handle_smi(usb_t* usb, void* priv) +{ + /* Left unimplemented for now. */ + return 1; +} + static void sis_5571_reset(void *priv) { @@ -722,7 +760,10 @@ sis_5571_init(const device_t *info) dev->ide_drive[1] = device_add_inst(&sff8038i_device, 2); /* USB */ - dev->usb = device_add(&usb_device); + dev->usb_params.parent_priv = dev; + dev->usb_params.update_interrupt = sis_5571_usb_update_interrupt; + dev->usb_params.smi_handle = sis_5571_usb_handle_smi; + dev->usb = device_add_parameters(&usb_device, &dev->usb_params); sis_5571_reset(dev); diff --git a/src/chipset/stpc.c b/src/chipset/stpc.c index cd13af3f0..2e4b045f2 100644 --- a/src/chipset/stpc.c +++ b/src/chipset/stpc.c @@ -65,7 +65,11 @@ typedef struct stpc_t { smram_t *smram; usb_t *usb; int ide_slot; + int usb_slot; sff8038i_t *bm[2]; + + /* Miscellaneous */ + usb_params_t usb_params; } stpc_t; typedef struct stpc_serial_t { @@ -870,6 +874,17 @@ stpc_setup(stpc_t *dev) pci_set_irq_routing(PCI_INTD, PCI_IRQ_DISABLED); } +static void +stpc_usb_update_interrupt(usb_t* usb, void* priv) +{ + stpc_t *dev = (stpc_t *) priv; + + if (usb->irq_level) + pci_set_irq(dev->usb_slot, PCI_INTA); + else + pci_clear_irq(dev->usb_slot, PCI_INTA); +} + static void stpc_close(void *priv) { @@ -895,9 +910,13 @@ stpc_init(const device_t *info) pci_add_card(PCI_ADD_NORTHBRIDGE, stpc_nb_read, stpc_nb_write, dev); dev->ide_slot = pci_add_card(PCI_ADD_SOUTHBRIDGE, stpc_isab_read, stpc_isab_write, dev); if (dev->local == STPC_ATLAS) { + dev->usb_params.smi_handle = NULL; + dev->usb_params.update_interrupt = stpc_usb_update_interrupt; + dev->usb_params.parent_priv = dev; + dev->ide_slot = pci_add_card(PCI_ADD_SOUTHBRIDGE, stpc_ide_read, stpc_ide_write, dev); - dev->usb = device_add(&usb_device); - pci_add_card(PCI_ADD_SOUTHBRIDGE, stpc_usb_read, stpc_usb_write, dev); + dev->usb = device_add_parameters(&usb_device, &dev->usb_params); + dev->usb_slot = pci_add_card(PCI_ADD_SOUTHBRIDGE, stpc_usb_read, stpc_usb_write, dev); } dev->bm[0] = device_add_inst(&sff8038i_device, 1); diff --git a/src/codegen/codegen_ops.c b/src/codegen/codegen_ops.c index 46a49f118..b5991c985 100644 --- a/src/codegen/codegen_ops.c +++ b/src/codegen/codegen_ops.c @@ -607,3 +607,51 @@ 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 f92ba4f6d..937105f9e 100644 --- a/src/codegen/codegen_ops.h +++ b/src/codegen/codegen_ops.h @@ -17,6 +17,7 @@ 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 4a184b981..fc3618d91 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 = recomp_opcodes_d8; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 = recomp_opcodes_d9; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 = recomp_opcodes_da; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 = recomp_opcodes_db; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 = recomp_opcodes_dc; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 = recomp_opcodes_dd; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 = recomp_opcodes_de; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 = recomp_opcodes_df; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 dbf76c2e4..f9d1d1ba5 100644 --- a/src/codegen/codegen_x86.c +++ b/src/codegen/codegen_x86.c @@ -1921,7 +1921,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 = recomp_opcodes_d8; + recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d8; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -1931,7 +1931,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 = recomp_opcodes_d9; + recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_d9; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1940,7 +1940,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 = recomp_opcodes_da; + recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_da; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1949,7 +1949,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 = recomp_opcodes_db; + recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_db; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1958,7 +1958,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 = recomp_opcodes_dc; + recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dc; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -1968,7 +1968,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 = recomp_opcodes_dd; + recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_dd; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1977,7 +1977,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 = recomp_opcodes_de; + recomp_op_table = fpu_softfloat ? recomp_opcodes_NULL : recomp_opcodes_de; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -1986,7 +1986,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 = recomp_opcodes_df; + recomp_op_table = fpu_softfloat ? recomp_opcodes_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 bf6ad123c..58e5d8a06 100644 --- a/src/codegen_new/codegen.c +++ b/src/codegen_new/codegen.c @@ -439,8 +439,8 @@ 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; - recomp_op_table = recomp_opcodes_d8; + 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; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -452,8 +452,8 @@ 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; - recomp_op_table = recomp_opcodes_d9; + 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; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -464,8 +464,8 @@ 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; - recomp_op_table = recomp_opcodes_da; + 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; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -476,8 +476,8 @@ 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; - recomp_op_table = recomp_opcodes_db; + 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; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -488,8 +488,8 @@ 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; - recomp_op_table = recomp_opcodes_dc; + 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; opcode_shift = 3; opcode_mask = 0x1f; over = 1; @@ -501,8 +501,8 @@ 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; - recomp_op_table = recomp_opcodes_dd; + 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; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -513,8 +513,8 @@ 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; - recomp_op_table = recomp_opcodes_de; + 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; opcode_mask = 0xff; over = 1; pc_off = -1; @@ -525,8 +525,8 @@ 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; - recomp_op_table = recomp_opcodes_df; + 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; opcode_mask = 0xff; over = 1; pc_off = -1; diff --git a/src/codegen_new/codegen_ops.c b/src/codegen_new/codegen_ops.c index 3fadd4a13..e611e6b29 100644 --- a/src/codegen_new/codegen_ops.c +++ b/src/codegen_new/codegen_ops.c @@ -556,3 +556,52 @@ RecompOpFn recomp_opcodes_df[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_new/codegen_ops.h b/src/codegen_new/codegen_ops.h index 9cef07e15..43bcf1b3f 100644 --- a/src/codegen_new/codegen_ops.h +++ b/src/codegen_new/codegen_ops.h @@ -20,6 +20,7 @@ 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/config.c b/src/config.c index 75a3973e4..f9570442b 100644 --- a/src/config.c +++ b/src/config.c @@ -783,6 +783,8 @@ load_network(void) net_cards_conf[c].net_type = NET_TYPE_PCAP; else if (!strcmp(p, "slirp") || !strcmp(p, "2")) net_cards_conf[c].net_type = NET_TYPE_SLIRP; + else if (!strcmp(p, "vde") || !strcmp(p, "2")) + net_cards_conf[c].net_type = NET_TYPE_VDE; else net_cards_conf[c].net_type = NET_TYPE_NONE; } else { @@ -791,13 +793,17 @@ load_network(void) p = ini_section_get_string(cat, "net_host_device", NULL); if (p != NULL) { - if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) { - if (network_ndev == 1) { - ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2095, (wchar_t *) IDS_2130); - } else if (network_dev_to_id(p) == -1) { - ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2096, (wchar_t *) IDS_2130); + if (net_cards_conf[c].net_type == NET_TYPE_PCAP) { + if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) { + if (network_ndev == 1) { + ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2095, (wchar_t *) IDS_2130); + } else if (network_dev_to_id(p) == -1) { + ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2096, (wchar_t *) IDS_2130); + } + strcpy(net_cards_conf[c].host_dev_name, "none"); + } else { + strncpy(net_cards_conf[c].host_dev_name, p, sizeof(net_cards_conf[c].host_dev_name) - 1); } - strcpy(net_cards_conf[c].host_dev_name, "none"); } else { strncpy(net_cards_conf[c].host_dev_name, p, sizeof(net_cards_conf[c].host_dev_name) - 1); } @@ -828,6 +834,8 @@ load_network(void) net_cards_conf[c].net_type = NET_TYPE_PCAP; } else if (!strcmp(p, "slirp") || !strcmp(p, "2")) { net_cards_conf[c].net_type = NET_TYPE_SLIRP; + } else if (!strcmp(p, "vde") || !strcmp(p, "2")) { + net_cards_conf[c].net_type = NET_TYPE_VDE; } else { net_cards_conf[c].net_type = NET_TYPE_NONE; } @@ -838,13 +846,15 @@ load_network(void) sprintf(temp, "net_%02i_host_device", c + 1); p = ini_section_get_string(cat, temp, NULL); if (p != NULL) { - if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) { - if (network_ndev == 1) { - ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2095, (wchar_t *) IDS_2130); - } else if (network_dev_to_id(p) == -1) { - ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2096, (wchar_t *) IDS_2130); + if (net_cards_conf[c].net_type == NET_TYPE_PCAP) { + if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) { + if (network_ndev == 1) { + ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2095, (wchar_t *) IDS_2130); + } else if (network_dev_to_id(p) == -1) { + ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2096, (wchar_t *) IDS_2130); + } + strcpy(net_cards_conf[c].host_dev_name, "none"); } - strcpy(net_cards_conf[c].host_dev_name, "none"); } else { strncpy(net_cards_conf[c].host_dev_name, p, sizeof(net_cards_conf[c].host_dev_name) - 1); } @@ -2469,11 +2479,19 @@ save_network(void) } sprintf(temp, "net_%02i_net_type", c + 1); - if (net_cards_conf[c].net_type == NET_TYPE_NONE) { - ini_section_delete_var(cat, temp); - } else { - ini_section_set_string(cat, temp, - (net_cards_conf[c].net_type == NET_TYPE_SLIRP) ? "slirp" : "pcap"); + switch(net_cards_conf[c].net_type) { + case NET_TYPE_NONE: + ini_section_delete_var(cat, temp); + break; + case NET_TYPE_SLIRP: + ini_section_set_string(cat, temp, "slirp"); + break; + case NET_TYPE_PCAP: + ini_section_set_string(cat, temp, "pcap"); + break; + case NET_TYPE_VDE: + ini_section_set_string(cat, temp, "vde"); + break; } sprintf(temp, "net_%02i_host_device", c + 1); diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index d6708cd99..9822e7b2c 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -202,7 +202,7 @@ void cpu_set_edx(void) { EDX = cpu_s->edx_reset; - if (!cpu_use_dynarec && fpu_softfloat) + if (fpu_softfloat) SF_FPU_reset(); } @@ -457,22 +457,41 @@ cpu_set(void) if (hasfpu) { #ifdef USE_DYNAREC - x86_dynarec_opcodes_d8_a16 = dynarec_ops_fpu_d8_a16; - x86_dynarec_opcodes_d8_a32 = dynarec_ops_fpu_d8_a32; - x86_dynarec_opcodes_d9_a16 = dynarec_ops_fpu_d9_a16; - x86_dynarec_opcodes_d9_a32 = dynarec_ops_fpu_d9_a32; - x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_da_a16; - x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_da_a32; - x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_db_a16; - x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_db_a32; - x86_dynarec_opcodes_dc_a16 = dynarec_ops_fpu_dc_a16; - x86_dynarec_opcodes_dc_a32 = dynarec_ops_fpu_dc_a32; - x86_dynarec_opcodes_dd_a16 = dynarec_ops_fpu_dd_a16; - x86_dynarec_opcodes_dd_a32 = dynarec_ops_fpu_dd_a32; - x86_dynarec_opcodes_de_a16 = dynarec_ops_fpu_de_a16; - x86_dynarec_opcodes_de_a32 = dynarec_ops_fpu_de_a32; - x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_df_a16; - x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_df_a32; + if (fpu_softfloat) { + x86_dynarec_opcodes_d8_a16 = dynarec_ops_sf_fpu_d8_a16; + x86_dynarec_opcodes_d8_a32 = dynarec_ops_sf_fpu_d8_a32; + x86_dynarec_opcodes_d9_a16 = dynarec_ops_sf_fpu_d9_a16; + x86_dynarec_opcodes_d9_a32 = dynarec_ops_sf_fpu_d9_a32; + x86_dynarec_opcodes_da_a16 = dynarec_ops_sf_fpu_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_sf_fpu_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_sf_fpu_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_sf_fpu_db_a32; + x86_dynarec_opcodes_dc_a16 = dynarec_ops_sf_fpu_dc_a16; + x86_dynarec_opcodes_dc_a32 = dynarec_ops_sf_fpu_dc_a32; + x86_dynarec_opcodes_dd_a16 = dynarec_ops_sf_fpu_dd_a16; + x86_dynarec_opcodes_dd_a32 = dynarec_ops_sf_fpu_dd_a32; + x86_dynarec_opcodes_de_a16 = dynarec_ops_sf_fpu_de_a16; + x86_dynarec_opcodes_de_a32 = dynarec_ops_sf_fpu_de_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_sf_fpu_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_sf_fpu_df_a32; + } else { + x86_dynarec_opcodes_d8_a16 = dynarec_ops_fpu_d8_a16; + x86_dynarec_opcodes_d8_a32 = dynarec_ops_fpu_d8_a32; + x86_dynarec_opcodes_d9_a16 = dynarec_ops_fpu_d9_a16; + x86_dynarec_opcodes_d9_a32 = dynarec_ops_fpu_d9_a32; + x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_db_a32; + x86_dynarec_opcodes_dc_a16 = dynarec_ops_fpu_dc_a16; + x86_dynarec_opcodes_dc_a32 = dynarec_ops_fpu_dc_a32; + x86_dynarec_opcodes_dd_a16 = dynarec_ops_fpu_dd_a16; + x86_dynarec_opcodes_dd_a32 = dynarec_ops_fpu_dd_a32; + x86_dynarec_opcodes_de_a16 = dynarec_ops_fpu_de_a16; + x86_dynarec_opcodes_de_a32 = dynarec_ops_fpu_de_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_df_a32; + } #endif if (fpu_softfloat) { x86_opcodes_d8_a16 = ops_sf_fpu_d8_a16; @@ -581,20 +600,37 @@ cpu_set(void) if (fpu_type == FPU_287) { #ifdef USE_DYNAREC - x86_dynarec_opcodes_d9_a16 = dynarec_ops_fpu_287_d9_a16; - x86_dynarec_opcodes_d9_a32 = dynarec_ops_fpu_287_d9_a32; - x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_287_da_a16; - x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_287_da_a32; - x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_287_db_a16; - x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_287_db_a32; - x86_dynarec_opcodes_dc_a16 = dynarec_ops_fpu_287_dc_a16; - x86_dynarec_opcodes_dc_a32 = dynarec_ops_fpu_287_dc_a32; - x86_dynarec_opcodes_dd_a16 = dynarec_ops_fpu_287_dd_a16; - x86_dynarec_opcodes_dd_a32 = dynarec_ops_fpu_287_dd_a32; - x86_dynarec_opcodes_de_a16 = dynarec_ops_fpu_287_de_a16; - x86_dynarec_opcodes_de_a32 = dynarec_ops_fpu_287_de_a32; - x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_287_df_a16; - x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_287_df_a32; + if (fpu_softfloat) { + x86_dynarec_opcodes_d9_a16 = dynarec_ops_sf_fpu_287_d9_a16; + x86_dynarec_opcodes_d9_a32 = dynarec_ops_sf_fpu_287_d9_a32; + x86_dynarec_opcodes_da_a16 = dynarec_ops_sf_fpu_287_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_sf_fpu_287_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_sf_fpu_287_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_sf_fpu_287_db_a32; + x86_dynarec_opcodes_dc_a16 = dynarec_ops_sf_fpu_287_dc_a16; + x86_dynarec_opcodes_dc_a32 = dynarec_ops_sf_fpu_287_dc_a32; + x86_dynarec_opcodes_dd_a16 = dynarec_ops_sf_fpu_287_dd_a16; + x86_dynarec_opcodes_dd_a32 = dynarec_ops_sf_fpu_287_dd_a32; + x86_dynarec_opcodes_de_a16 = dynarec_ops_sf_fpu_287_de_a16; + x86_dynarec_opcodes_de_a32 = dynarec_ops_sf_fpu_287_de_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_sf_fpu_287_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_sf_fpu_287_df_a32; + } else { + x86_dynarec_opcodes_d9_a16 = dynarec_ops_fpu_287_d9_a16; + x86_dynarec_opcodes_d9_a32 = dynarec_ops_fpu_287_d9_a32; + x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_287_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_287_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_287_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_287_db_a32; + x86_dynarec_opcodes_dc_a16 = dynarec_ops_fpu_287_dc_a16; + x86_dynarec_opcodes_dc_a32 = dynarec_ops_fpu_287_dc_a32; + x86_dynarec_opcodes_dd_a16 = dynarec_ops_fpu_287_dd_a16; + x86_dynarec_opcodes_dd_a32 = dynarec_ops_fpu_287_dd_a32; + x86_dynarec_opcodes_de_a16 = dynarec_ops_fpu_287_de_a16; + x86_dynarec_opcodes_de_a32 = dynarec_ops_fpu_287_de_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_287_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_287_df_a32; + } #endif if (fpu_softfloat) { x86_opcodes_d9_a16 = ops_sf_fpu_287_d9_a16; @@ -674,20 +710,37 @@ cpu_set(void) case CPU_386DX: if (fpu_type == FPU_287) { /* In case we get Deskpro 386 emulation */ #ifdef USE_DYNAREC - x86_dynarec_opcodes_d9_a16 = dynarec_ops_fpu_287_d9_a16; - x86_dynarec_opcodes_d9_a32 = dynarec_ops_fpu_287_d9_a32; - x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_287_da_a16; - x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_287_da_a32; - x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_287_db_a16; - x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_287_db_a32; - x86_dynarec_opcodes_dc_a16 = dynarec_ops_fpu_287_dc_a16; - x86_dynarec_opcodes_dc_a32 = dynarec_ops_fpu_287_dc_a32; - x86_dynarec_opcodes_dd_a16 = dynarec_ops_fpu_287_dd_a16; - x86_dynarec_opcodes_dd_a32 = dynarec_ops_fpu_287_dd_a32; - x86_dynarec_opcodes_de_a16 = dynarec_ops_fpu_287_de_a16; - x86_dynarec_opcodes_de_a32 = dynarec_ops_fpu_287_de_a32; - x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_287_df_a16; - x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_287_df_a32; + if (fpu_softfloat) { + x86_dynarec_opcodes_d9_a16 = dynarec_ops_sf_fpu_287_d9_a16; + x86_dynarec_opcodes_d9_a32 = dynarec_ops_sf_fpu_287_d9_a32; + x86_dynarec_opcodes_da_a16 = dynarec_ops_sf_fpu_287_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_sf_fpu_287_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_sf_fpu_287_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_sf_fpu_287_db_a32; + x86_dynarec_opcodes_dc_a16 = dynarec_ops_sf_fpu_287_dc_a16; + x86_dynarec_opcodes_dc_a32 = dynarec_ops_sf_fpu_287_dc_a32; + x86_dynarec_opcodes_dd_a16 = dynarec_ops_sf_fpu_287_dd_a16; + x86_dynarec_opcodes_dd_a32 = dynarec_ops_sf_fpu_287_dd_a32; + x86_dynarec_opcodes_de_a16 = dynarec_ops_sf_fpu_287_de_a16; + x86_dynarec_opcodes_de_a32 = dynarec_ops_sf_fpu_287_de_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_sf_fpu_287_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_sf_fpu_287_df_a32; + } else { + x86_dynarec_opcodes_d9_a16 = dynarec_ops_fpu_287_d9_a16; + x86_dynarec_opcodes_d9_a32 = dynarec_ops_fpu_287_d9_a32; + x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_287_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_287_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_287_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_287_db_a32; + x86_dynarec_opcodes_dc_a16 = dynarec_ops_fpu_287_dc_a16; + x86_dynarec_opcodes_dc_a32 = dynarec_ops_fpu_287_dc_a32; + x86_dynarec_opcodes_dd_a16 = dynarec_ops_fpu_287_dd_a16; + x86_dynarec_opcodes_dd_a32 = dynarec_ops_fpu_287_dd_a32; + x86_dynarec_opcodes_de_a16 = dynarec_ops_fpu_287_de_a16; + x86_dynarec_opcodes_de_a32 = dynarec_ops_fpu_287_de_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_287_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_287_df_a32; + } #endif if (fpu_softfloat) { x86_opcodes_d9_a16 = ops_sf_fpu_287_d9_a16; @@ -1114,12 +1167,21 @@ cpu_set(void) case CPU_Cx6x86MX: if (cpu_s->cpu_type == CPU_Cx6x86MX) { # ifdef USE_DYNAREC - x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_686_da_a16; - x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_686_da_a32; - x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_686_db_a16; - x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_686_db_a32; - x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_686_df_a16; - x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_686_df_a32; + if (fpu_softfloat) { + x86_dynarec_opcodes_da_a16 = dynarec_ops_sf_fpu_686_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_sf_fpu_686_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_sf_fpu_686_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_sf_fpu_686_db_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_sf_fpu_686_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_sf_fpu_686_df_a32; + } else { + x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_686_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_686_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_686_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_686_db_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_686_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_686_df_a32; + } # endif if (fpu_softfloat) { x86_opcodes_da_a16 = ops_sf_fpu_686_da_a16; @@ -1152,7 +1214,8 @@ cpu_set(void) else if (cpu_s->cpu_type == CPU_Cx6x86L) x86_setopcodes(ops_386, ops_pentium_0f); else - x86_setopcodes(ops_386, ops_c6x86_0f); + x86_setopcodes(ops_386, ops_c6x86mx_0f); + // x86_setopcodes(ops_386, ops_c6x86_0f); # endif timing_rr = 1; /* register dest - register src */ @@ -1326,12 +1389,21 @@ cpu_set(void) x86_setopcodes(ops_386, ops_pentium2_0f, dynarec_ops_386, dynarec_ops_pentium2_0f); else x86_setopcodes(ops_386, ops_pentiumpro_0f, dynarec_ops_386, dynarec_ops_pentiumpro_0f); - x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_686_da_a16; - x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_686_da_a32; - x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_686_db_a16; - x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_686_db_a32; - x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_686_df_a16; - x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_686_df_a32; + if (fpu_softfloat) { + x86_dynarec_opcodes_da_a16 = dynarec_ops_sf_fpu_686_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_sf_fpu_686_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_sf_fpu_686_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_sf_fpu_686_db_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_sf_fpu_686_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_sf_fpu_686_df_a32; + } else { + x86_dynarec_opcodes_da_a16 = dynarec_ops_fpu_686_da_a16; + x86_dynarec_opcodes_da_a32 = dynarec_ops_fpu_686_da_a32; + x86_dynarec_opcodes_db_a16 = dynarec_ops_fpu_686_db_a16; + x86_dynarec_opcodes_db_a32 = dynarec_ops_fpu_686_db_a32; + x86_dynarec_opcodes_df_a16 = dynarec_ops_fpu_686_df_a16; + x86_dynarec_opcodes_df_a32 = dynarec_ops_fpu_686_df_a32; + } #else if (cpu_s->cpu_type == CPU_PENTIUM2D) x86_setopcodes(ops_386, ops_pentium2d_0f); diff --git a/src/cpu/x86_ops.h b/src/cpu/x86_ops.h index 9d34c71ec..0cd449236 100644 --- a/src/cpu/x86_ops.h +++ b/src/cpu/x86_ops.h @@ -102,6 +102,38 @@ extern const OpFn dynarec_ops_pentiumpro_0f[1024]; extern const OpFn dynarec_ops_pentium2_0f[1024]; extern const OpFn dynarec_ops_pentium2d_0f[1024]; +extern const OpFn dynarec_ops_sf_fpu_287_d9_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_287_d9_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_287_da_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_287_da_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_287_db_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_287_db_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_287_dc_a16[32]; +extern const OpFn dynarec_ops_sf_fpu_287_dc_a32[32]; +extern const OpFn dynarec_ops_sf_fpu_287_dd_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_287_dd_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_287_de_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_287_de_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_287_df_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_287_df_a32[256]; + +extern const OpFn dynarec_ops_sf_fpu_d8_a16[32]; +extern const OpFn dynarec_ops_sf_fpu_d8_a32[32]; +extern const OpFn dynarec_ops_sf_fpu_d9_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_d9_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_da_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_da_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_db_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_db_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_dc_a16[32]; +extern const OpFn dynarec_ops_sf_fpu_dc_a32[32]; +extern const OpFn dynarec_ops_sf_fpu_dd_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_dd_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_de_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_de_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_df_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_df_a32[256]; + extern const OpFn dynarec_ops_fpu_287_d9_a16[256]; extern const OpFn dynarec_ops_fpu_287_d9_a32[256]; extern const OpFn dynarec_ops_fpu_287_da_a16[256]; @@ -136,6 +168,13 @@ extern const OpFn dynarec_ops_fpu_df_a32[256]; extern const OpFn dynarec_ops_nofpu_a16[256]; extern const OpFn dynarec_ops_nofpu_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_686_da_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_686_da_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_686_db_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_686_db_a32[256]; +extern const OpFn dynarec_ops_sf_fpu_686_df_a16[256]; +extern const OpFn dynarec_ops_sf_fpu_686_df_a32[256]; + extern const OpFn dynarec_ops_fpu_686_da_a16[256]; extern const OpFn dynarec_ops_fpu_686_da_a32[256]; extern const OpFn dynarec_ops_fpu_686_db_a16[256]; diff --git a/src/cpu/x86_ops_fpu.h b/src/cpu/x86_ops_fpu.h index 502218be5..29e999941 100644 --- a/src/cpu/x86_ops_fpu.h +++ b/src/cpu/x86_ops_fpu.h @@ -97,7 +97,8 @@ opWAIT(uint32_t fetchdat) return 1; } - if (!cpu_use_dynarec && fpu_softfloat) { + // if (!cpu_use_dynarec && fpu_softfloat) { + if (fpu_softfloat) { if (fpu_state.swd & FPU_SW_Summary) { if (cr0 & 0x20) { x86_int(16); diff --git a/src/include/86box/cdrom.h b/src/include/86box/cdrom.h index d2f032280..a32177b05 100644 --- a/src/include/86box/cdrom.h +++ b/src/include/86box/cdrom.h @@ -165,7 +165,7 @@ typedef struct cdrom { char *image_history[CD_IMAGE_HISTORY]; uint32_t sound_on, cdrom_capacity, - early, seek_pos, + seek_pos, seek_diff, cd_end, type; int host_drive, prev_host_drive, diff --git a/src/include/86box/network.h b/src/include/86box/network.h index 0a396968f..4f514d1ac 100644 --- a/src/include/86box/network.h +++ b/src/include/86box/network.h @@ -51,6 +51,7 @@ #define NET_TYPE_NONE 0 /* networking disabled */ #define NET_TYPE_SLIRP 1 /* use the SLiRP port forwarder */ #define NET_TYPE_PCAP 2 /* use the (Win)Pcap API */ +#define NET_TYPE_VDE 3 /* use the VDE plug API */ #define NET_MAX_FRAME 1518 /* Queue size must be a power of 2 */ @@ -123,6 +124,7 @@ typedef struct netdrv_t { extern const netdrv_t net_pcap_drv; extern const netdrv_t net_slirp_drv; +extern const netdrv_t net_vde_drv; struct _netcard_t { const device_t *device; @@ -147,15 +149,27 @@ typedef struct { char description[128]; } netdev_t; +typedef struct { + int has_slirp: 1; + int has_pcap: 1; + int has_vde: 1; +} network_devmap_t; + + +#define HAS_NOSLIRP_NET(x) (x.has_pcap || x.has_vde) + #ifdef __cplusplus extern "C" { #endif /* Global variables. */ extern int nic_do_log; /* config */ -extern int network_ndev; +extern network_devmap_t network_devmap; +extern int network_ndev; // Number of pcap devices +extern network_devmap_t network_devmap; // Bitmap of available network types extern netdev_t network_devs[NET_HOST_INTF_MAX]; + /* Function prototypes. */ extern void network_init(void); extern netcard_t *network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_link_state); @@ -166,6 +180,8 @@ extern int network_available(void); extern void network_tx(netcard_t *card, uint8_t *, int); extern int net_pcap_prepare(netdev_t *); +extern int net_vde_prepare(void); + extern void network_connect(int id, int connect); extern int network_is_connected(int id); diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 431f42134..3a8a6b39c 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -142,26 +142,27 @@ #define IDT_CD_LUN 1766 /* LUN: */ #define IDT_CD_CHANNEL 1767 /* Channel: */ #define IDT_CD_SPEED 1768 /* Speed: */ +#define IDT_CD_TYPE 1769 /* Type: */ /* DLG_CFG_OTHER_REMOVABLE_DEVICES */ -#define IDT_MO_DRIVES 1769 /* MO drives: */ -#define IDT_MO_BUS 1770 /* Bus: */ -#define IDT_MO_ID 1771 /* ID: */ -#define IDT_MO_CHANNEL 1772 /* Channel */ -#define IDT_MO_TYPE 1773 /* Type: */ +#define IDT_MO_DRIVES 1770 /* MO drives: */ +#define IDT_MO_BUS 1771 /* Bus: */ +#define IDT_MO_ID 1772 /* ID: */ +#define IDT_MO_CHANNEL 1773 /* Channel */ +#define IDT_MO_TYPE 1774 /* Type: */ -#define IDT_ZIP_DRIVES 1774 /* ZIP drives: */ -#define IDT_ZIP_BUS 1775 /* Bus: */ -#define IDT_ZIP_ID 1776 /* ID: */ -#define IDT_ZIP_LUN 1777 /* LUN: */ -#define IDT_ZIP_CHANNEL 1778 /* Channel: */ +#define IDT_ZIP_DRIVES 1775 /* ZIP drives: */ +#define IDT_ZIP_BUS 1776 /* Bus: */ +#define IDT_ZIP_ID 1777 /* ID: */ +#define IDT_ZIP_LUN 1778 /* LUN: */ +#define IDT_ZIP_CHANNEL 1779 /* Channel: */ /* DLG_CFG_PERIPHERALS */ -#define IDT_ISARTC 1779 /* ISA RTC: */ -#define IDT_ISAMEM_1 1780 /* ISAMEM Board #1: */ -#define IDT_ISAMEM_2 1781 /* ISAMEM Board #2: */ -#define IDT_ISAMEM_3 1782 /* ISAMEM Board #3: */ -#define IDT_ISAMEM_4 1783 /* ISAMEM Board #4: */ +#define IDT_ISARTC 1780 /* ISA RTC: */ +#define IDT_ISAMEM_1 1781 /* ISAMEM Board #1: */ +#define IDT_ISAMEM_2 1782 /* ISAMEM Board #2: */ +#define IDT_ISAMEM_3 1783 /* ISAMEM Board #3: */ +#define IDT_ISAMEM_4 1784 /* ISAMEM Board #4: */ /* * To try to keep these organized, we now group the @@ -302,7 +303,7 @@ #define IDC_COMBO_CD_ID 1157 #define IDC_COMBO_CD_LUN 1158 #define IDC_COMBO_CD_CHANNEL_IDE 1159 -#define IDC_CHECKEARLY 1160 +#define IDC_COMBO_CD_TYPE 1160 #define IDC_LIST_ZIP_DRIVES 1170 /* other removable devices config */ #define IDC_COMBO_ZIP_BUS 1171 diff --git a/src/include/86box/usb.h b/src/include/86box/usb.h index a20f1b2a2..4c6fc289b 100644 --- a/src/include/86box/usb.h +++ b/src/include/86box/usb.h @@ -27,37 +27,92 @@ typedef struct usb_t usb_t; /* USB device creation parameters struct */ typedef struct { - void (*raise_interrupt)(usb_t*, void*); + void (*update_interrupt)(usb_t*, void*); + /* Handle (but do not raise) SMI. Returns 1 if SMI can be raised, 0 otherwise. */ + uint8_t (*smi_handle)(usb_t*, void*); void* parent_priv; } usb_params_t; +typedef union +{ + uint32_t l; + uint16_t w[2]; + uint8_t b[4]; +} ohci_mmio_t; + /* USB Host Controller device struct */ typedef struct usb_t { - uint8_t uhci_io[32], ohci_mmio[4096]; + uint8_t uhci_io[32]; + ohci_mmio_t ohci_mmio[1024]; uint16_t uhci_io_base; int uhci_enable, ohci_enable; - uint32_t ohci_mem_base; + uint32_t ohci_mem_base, irq_level; mem_mapping_t ohci_mmio_mapping; pc_timer_t ohci_frame_timer; pc_timer_t ohci_port_reset_timer[2]; + uint8_t ohci_interrupt_counter : 3; usb_params_t* usb_params; } usb_t; +#pragma pack(push, 1) + +/* Base USB descriptor struct. */ +typedef struct +{ + uint8_t bLength; + uint8_t bDescriptorType; +} usb_desc_base_t; + +typedef struct +{ + usb_desc_base_t base; + + uint16_t wTotalLength; + uint8_t bNumInterfaces; + uint8_t bConfigurationValue; + uint8_t iConfiguration; + uint8_t bmAttributes; + uint8_t bMaxPower; +} usb_desc_conf_t; + +#pragma pack(pop) + /* USB endpoint device struct. Incomplete and unused. */ typedef struct { uint16_t vendor_id; uint16_t device_id; + + /* Reads from endpoint. Non-zero value indicates error. */ + uint8_t (*device_in)(void* priv, uint8_t* data, uint32_t len); + /* Writes to endpoint. Non-zero value indicates error. */ + uint8_t (*device_out)(void* priv, uint8_t* data, uint32_t len); + /* Process setup packets. */ + uint8_t (*device_setup)(void* priv, uint8_t* data); + /* Device reset */ + void (*device_reset)(void* priv); + + void* priv; } usb_device_t; +enum usb_bus_types +{ + USB_BUS_OHCI = 0, + USB_BUS_UHCI = 1 +}; + /* Global variables. */ extern const device_t usb_device; /* Functions. */ extern void uhci_update_io_mapping(usb_t *dev, uint8_t base_l, uint8_t base_h, int enable); extern void ohci_update_mem_mapping(usb_t *dev, uint8_t base1, uint8_t base2, uint8_t base3, int enable); +/* Attach USB device to a port of a USB bus. Returns the port to which it got attached to. */ +extern uint8_t usb_attach_device(usb_t *dev, usb_device_t* device, uint8_t bus_type); +/* Detach USB device from a port. */ +extern void usb_detach_device(usb_t *dev, uint8_t port, uint8_t bus_type); #ifdef __cplusplus } diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 6463d0214..e6510e3f1 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -83,6 +83,7 @@ typedef struct ibm8514_t { } accel; uint16_t test; + int ibm_mode; int v_total, dispend, v_syncstart, split, h_disp, h_disp_old, h_total, h_disp_time, rowoffset, @@ -107,5 +108,6 @@ typedef struct ibm8514_t { int blitter_busy; uint64_t blitter_time; uint64_t status_time; + int pitch; } ibm8514_t; #endif /*VIDEO_8514A_H*/ diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 31eabc064..a18e136dd 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -184,6 +184,13 @@ extern int vga_on, ibm8514_on; extern void ibm8514_poll(ibm8514_t *dev, svga_t *svga); extern void ibm8514_recalctimings(svga_t *svga); +extern uint8_t ibm8514_ramdac_in(uint16_t port, void *p); +extern void ibm8514_ramdac_out(uint16_t port, uint8_t val, void *p); +extern int ibm8514_cpu_src(svga_t *svga); +extern int ibm8514_cpu_dest(svga_t *svga); +extern void ibm8514_accel_out_pixtrans(svga_t *svga, uint16_t port, uint16_t val, int len); +extern void ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, uint8_t ssv, int len); +extern void ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, int len); extern void xga_poll(xga_t *xga, svga_t *svga); extern void xga_recalctimings(svga_t *svga); diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index e14f979d3..c6178a790 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -12,8 +12,8 @@ # # Copyright 2020-2021 David Hrdlička. # - -add_library(net OBJECT network.c net_pcap.c net_slirp.c net_dp8390.c net_3c501.c +set(net_sources) +list(APPEND net_sources network.c net_pcap.c net_slirp.c net_dp8390.c net_3c501.c net_3c503.c net_ne2000.c net_pcnet.c net_wd8003.c net_plip.c net_event.c) option(SLIRP_EXTERNAL "Link against the system-provided libslirp library" OFF) @@ -39,3 +39,13 @@ endif() if(WIN32) target_link_libraries(86Box ws2_32) 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) + endif() +endif() + +add_library(net OBJECT ${net_sources}) diff --git a/src/network/net_vde.c b/src/network/net_vde.c new file mode 100644 index 000000000..904b2789a --- /dev/null +++ b/src/network/net_vde.c @@ -0,0 +1,310 @@ + /* + * 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. + * + * VDE networking for 86box + * See https://wiki.virtualsquare.org/#!tutorials/vdebasics.md + * for basic information about VDE. You can browse the source + * code at https://github.com/virtualsquare/vde-2 + * + * VDE support is only available in Linux and MacOS. It _should_ + * be available in BSD*, and if someday there is a BSD version of + * 86box this _could_ work out of the box. + * + * Authors: jguillaumes + * Copyright 2023 jguillaumes. + * + * See the COPYING file at the top of the 86box for license details. + * TL;DR: GPL version 2. + */ +#include +#include +#include +#include +#include + +#if !defined(_WIN32) +#include +#include +#else +#error VDE is not supported under windows +#endif + +#include + +#define HAVE_STDARG_H +#include <86box/86box.h> +#include <86box/device.h> +#include <86box/plat.h> +#include <86box/plat_dynld.h> +#include <86box/thread.h> +#include <86box/timer.h> +#include <86box/network.h> +#include <86box/net_event.h> + +#define VDE_PKT_BATCH NET_QUEUE_LEN +#define VDE_DESCRIPTION "86Box virtual card" + +enum { + NET_EVENT_STOP = 0, + NET_EVENT_TX, + NET_EVENT_RX, + NET_EVENT_VDE, + NET_EVENT_MAX +}; + +static volatile void *libvde_handle = NULL; + +//+ +// VDE connection structure +//- +typedef struct { + void *vdeconn; // VDEPLUG Connection + netcard_t *card; // NIC linked to + thread_t *poll_tid; // Polling thread + net_evt_t tx_event; // Packets to transmit event + net_evt_t stop_event; // Stop thread event + netpkt_t pkt; // Packet read/sent + netpkt_t pktv[VDE_PKT_BATCH]; // Packet queue + uint8_t mac_addr[6]; // MAC Address +} net_vde_t; + +//+ +// VDE libvdeplug function pointers +//- +static VDECONN *(*f_vde_open)(char *, char *, int, struct vde_open_args *); // This is vde_open_real() +static void (*f_vde_close)(VDECONN *); +static int (*f_vde_datafd)(VDECONN *); // Get the data (read/write) handle +static int (*f_vde_ctlfd)(VDECONN *); // Get the control handle +static ssize_t (*f_vde_recv)(VDECONN *, void *, size_t, int); // Receive a packet +static ssize_t (*f_vde_send)(VDECONN *, const void *, size_t, int); // Send a packet + +//+ +// VDE libvdeplug function table (for import) +//- +static dllimp_t vde_imports[] = { + {"vde_open_real", &f_vde_open}, + {"vde_close", &f_vde_close}, + {"vde_datafd", &f_vde_datafd}, + {"vde_ctlfd", &f_vde_ctlfd}, + {"vde_recv", &f_vde_recv}, + {"vde_send", &f_vde_send}, + { NULL, NULL} +}; + +#ifdef ENABLE_VDE_LOG +#include +int vde_do_log = ENABLE_VDE_LOG; + +static void +vde_log(const char *fmt, ...) { + va_list ap; + + if (vde_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +# define vde_log(fmt, ...) +#endif + +#ifdef _WIN32 +#error VDE networking is not supported under windows +#else + +//+ +// VDE thread +//- +static void net_vde_thread(void *priv) { + net_vde_t *vde = (net_vde_t *) priv; + vde_log("VDE: Polling started.\n"); + + struct pollfd pfd[NET_EVENT_MAX]; + pfd[NET_EVENT_STOP].fd = net_event_get_fd(&vde->stop_event); + pfd[NET_EVENT_STOP].events = POLLIN | POLLPRI; + + pfd[NET_EVENT_TX].fd = net_event_get_fd(&vde->tx_event); + pfd[NET_EVENT_TX].events = POLLIN | POLLPRI; + + pfd[NET_EVENT_RX].fd = f_vde_datafd(vde->vdeconn); + pfd[NET_EVENT_RX].events = POLLIN; + + pfd[NET_EVENT_VDE].fd = f_vde_ctlfd(vde->vdeconn); + pfd[NET_EVENT_VDE].events = POLLIN; + + while(1) { + poll(pfd, NET_EVENT_MAX, -1); + + // Acvity in the control handle means the link is closed + // We send ourselves a STOP event + if (pfd[NET_EVENT_VDE].revents & POLLIN) { + net_event_set(&vde->stop_event); + } + + // There are packets queued to transmit + if (pfd[NET_EVENT_TX].revents & POLLIN) { + net_event_clear(&vde->tx_event); + int packets = network_tx_popv(vde->card, vde->pktv, VDE_PKT_BATCH); + for (int i=0; ivdeconn, vde->pktv[i].data,vde->pktv[i].len, 0 ); + if (nc == 0) { + vde_log("VDE: Problem, no bytes sent.\n"); + } + } + } + + // Packets are available for reading. Read packet and queue it + if (pfd[NET_EVENT_RX].revents & POLLIN) { + int nc = f_vde_recv(vde->vdeconn, vde->pkt.data, NET_MAX_FRAME, 0); + vde->pkt.len = nc; + network_rx_put_pkt(vde->card, &vde->pkt); + } + + // We have been told to close + if (pfd[NET_EVENT_STOP].revents & POLLIN) { + net_event_clear(&vde->stop_event); + break; + } + } + vde_log("VDE: Polling stopped.\n"); +} +#endif + + +//+ +// Prepare the VDE libvdeplug interface. +// Load the dynamic library libvdeplug. +// Returns zero if the library has been loaded, -1 in case of error. +//- +int net_vde_prepare(void) { + +#if defined(_WIN32) + #error VDE is not supported in Windows +#elif defined(__APPLE__) + libvde_handle = dynld_module("libvdeplug.dylib", vde_imports); +#else + libvde_handle = dynld_module("libvdeplug.so", vde_imports); +#endif + + if (libvde_handle == NULL) { + vde_log("VDE: error loading VDEPLUG module\n"); + return -1; + } else { + network_devmap.has_vde = 1; + } + return 0; +} + +//+ +// Close a VDE socket connection +//- +void net_vde_close(void *priv) { + int i; + + if (!priv) return; + + net_vde_t *vde = (net_vde_t *) priv; + vde_log("VDE: closing.\n"); + net_event_set(&vde->stop_event); // Tell the thread to finish + vde_log("VDE: Waiting for the thread to finish...\n"); + thread_wait(vde->poll_tid); + vde_log("VDE: Thread finished.\n"); + + // Free all the mallocs! + for(i=0;ipktv[i].data); + } + free(vde->pkt.data); + f_vde_close((void *) vde->vdeconn); + net_event_close(&vde->tx_event); + net_event_close(&vde->stop_event); + free(vde); +} + +//+ +// Signal packets are available to be transmitted +//- +void net_vde_in_available(void *priv) { + net_vde_t *vde = (net_vde_t *) priv; + net_event_set(&vde->tx_event); +} + +//+ +// Initialize VDE for use +// At this point the vdeplug library is already loaded +// card: network card we are attaching +// mac_addr: MAC address we are using +// priv: Name of the VDE contol socket directory +//- +void *net_vde_init(const netcard_t *card, const uint8_t *mac_addr, void *priv) { + struct vde_open_args vde_args; + int i; + + char *socket_name = (char *) priv; + + if (libvde_handle == NULL) { + vde_log("VDE: net_vde_init without library handle!\n"); + return NULL; + } + + if ((socket_name[0] == '\0') || !strcmp(socket_name, "none")) { + vde_log("VDE: No socket name configured!\n"); + return NULL; + } + + vde_log("VDE: Attaching to virtual switch at %s\n", socket_name); + + net_vde_t *vde = calloc(1, sizeof(net_vde_t)); + vde->card = (netcard_t *) card; + memcpy(vde->mac_addr, mac_addr, sizeof(vde->mac_addr)); + + vde_args.group = 0; + vde_args.port = 0; + vde_args.mode = 0; + + // We are calling vde_open_real(), not the vde_open() macro... + if ((vde->vdeconn = f_vde_open(socket_name, VDE_DESCRIPTION, + LIBVDEPLUG_INTERFACE_VERSION, &vde_args)) == NULL) { + vde_log("VDE: Unable to open socket %s (%s)!\n", socket_name, strerror(errno)); + free(vde); + //+ + // There is a bug upstream that causes an uncontrolled crash if the network is not + // properly initialized. + // To avoid that crash, we tell the user we cannot continue and exit the program. + // TODO: Once there is a solution for the mentioned crash, this should be removed + // and/or replaced by proper error handling code. + //- + fatal("Could not open the specified VDE socket (%s). Please fix your networking configuration.", socket_name); + // It makes no sense to issue this warning since the program will crash anyway... + // ui_msgbox_header(MBX_WARNING, (wchar_t *) IDS_2167, (wchar_t *) IDS_2168); + return NULL; + } + vde_log("VDE: Socket opened (%s).\n", socket_name); + + for(i=0; i < VDE_PKT_BATCH; i++) { + vde->pktv[i].data = calloc(1, NET_MAX_FRAME); + } + vde->pkt.data = calloc(1,NET_MAX_FRAME); + net_event_init(&vde->tx_event); + net_event_init(&vde->stop_event); + vde->poll_tid = thread_create(net_vde_thread, vde); // Fire up the read-write thread! + + return vde; +} + +//+ +// VDE Driver structure +//- +const netdrv_t net_vde_drv = { + &net_vde_in_available, + &net_vde_init, + &net_vde_close, + NULL +}; + diff --git a/src/network/network.c b/src/network/network.c index f6e9eb565..ce81fcc93 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -123,7 +123,8 @@ netcard_conf_t net_cards_conf[NET_CARD_MAX]; uint16_t net_card_current = 0; /* Global variables. */ -int network_ndev; +network_devmap_t network_devmap; +int network_ndev; netdev_t network_devs[NET_HOST_INTF_MAX]; /* Local variables. */ @@ -214,9 +215,20 @@ network_init(void) network_ndev = 1; /* Initialize the Pcap system module, if present. */ + + network_devmap.has_slirp = 1; i = net_pcap_prepare(&network_devs[network_ndev]); - if (i > 0) + if (i > 0) { + network_devmap.has_pcap = 1; network_ndev += i; + } + +#ifdef HAS_VDE + // Try to load the VDE plug library + if(net_vde_prepare()==0) { + network_devmap.has_vde = 1; + } +#endif #if defined ENABLE_NETWORK_LOG && !defined(_WIN32) /* Start packet dump. */ @@ -286,6 +298,17 @@ int network_queue_put_swap(netqueue_t *queue, netpkt_t *src_pkt) { if (src_pkt->len == 0 || src_pkt->len > NET_MAX_FRAME || network_queue_full(queue)) { +#ifdef DEBUG + if (src_pkt->len == 0) { + network_log("Discarded zero length packet.\n"); + } else if (src_pkt->len > NET_MAX_FRAME) { + network_log("Discarded oversized packet of len=%d.\n", src_pkt->len); + network_dump_packet(src_pkt); + } else { + network_log("Discarded %d bytes packet because the queue is full.\n", src_pkt->len); + network_dump_packet(src_pkt); + } +#endif return 0; } @@ -434,6 +457,12 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin card->host_drv = net_pcap_drv; card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name); break; +#ifdef HAS_VDE + case NET_TYPE_VDE: + card->host_drv = net_vde_drv; + card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name); + break; +#endif } if (!card->host_drv.priv) { @@ -617,6 +646,8 @@ network_dev_available(int id) if ((net_cards_conf[id].net_type == NET_TYPE_PCAP && (network_dev_to_id(net_cards_conf[id].host_dev_name) <= 0))) available = 0; + // TODO: Handle VDE device + return available; } diff --git a/src/pic.c b/src/pic.c index a5867ce03..7855fbbb6 100644 --- a/src/pic.c +++ b/src/pic.c @@ -575,6 +575,9 @@ pic_reset_hard(void) { pic_reset(); + /* Explicitly reset the latches. */ + kbd_latch = mouse_latch = 0; + /* The situation is as follows: There is a giant mess when it comes to these latches on real hardware, to the point that there's even boards with board-level latched that get used in place of the latches on the chipset, therefore, I'm just doing this here for the sake of simplicity. */ diff --git a/src/qt/qt_mediamenu.cpp b/src/qt/qt_mediamenu.cpp index 3ab5f9b60..841cd3053 100644 --- a/src/qt/qt_mediamenu.cpp +++ b/src/qt/qt_mediamenu.cpp @@ -857,6 +857,9 @@ MediaMenu::nicUpdateMenu(int i) case NET_TYPE_PCAP: netType = "PCAP"; break; + case NET_TYPE_VDE: + netType = "VDE"; + break; } QString devName = DeviceConfig::DeviceName(network_card_getdevice(net_cards_conf[i].device_num), network_card_get_internal_name(net_cards_conf[i].device_num), 1); diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 014e82ab3..ceb4810bc 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -37,13 +37,17 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) auto *net_type_cbox = findChild(QString("comboBoxNet%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 *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); int netType = net_type_cbox->currentData().toInt(); - bool adaptersEnabled = netType == NET_TYPE_SLIRP || (netType == NET_TYPE_PCAP && intf_cbox->currentData().toInt() > 0); + bool adaptersEnabled = netType == NET_TYPE_SLIRP + || NET_TYPE_VDE + || (netType == NET_TYPE_PCAP && intf_cbox->currentData().toInt() > 0); intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP); nic_cbox->setEnabled(adaptersEnabled); conf_btn->setEnabled(adaptersEnabled && network_card_has_config(nic_cbox->currentData().toInt())); + socket_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_VDE); } } @@ -59,6 +63,7 @@ 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); @@ -75,12 +80,18 @@ SettingsNetwork::save() { for (int i = 0; i < NET_CARD_MAX; ++i) { auto *cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); + auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); net_cards_conf[i].device_num = cbox->currentData().toInt(); cbox = findChild(QString("comboBoxNet%1").arg(i + 1)); net_cards_conf[i].net_type = cbox->currentData().toInt(); cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); memset(net_cards_conf[i].host_dev_name, '\0', sizeof(net_cards_conf[i].host_dev_name)); - strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1); + if (net_cards_conf[i].net_type == NET_TYPE_PCAP) { + strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1); + } else if (net_cards_conf[i].net_type == NET_TYPE_VDE) { + const char *str_socket = socket_line->text().toStdString().c_str(); + strncpy(net_cards_conf[i].host_dev_name, str_socket, strlen(str_socket)); + } } } @@ -124,26 +135,38 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) removeRows = model->rowCount(); Models::AddEntry(model, tr("None"), NET_TYPE_NONE); Models::AddEntry(model, "SLiRP", NET_TYPE_SLIRP); + if (network_ndev > 1) { Models::AddEntry(model, "PCap", NET_TYPE_PCAP); } + if (network_devmap.has_vde) { + Models::AddEntry(model, "VDE", NET_TYPE_VDE); + } + model->removeRows(0, removeRows); cbox->setCurrentIndex(net_cards_conf[i].net_type); selectedRow = 0; - QString currentPcapDevice = net_cards_conf[i].host_dev_name; - cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); - model = cbox->model(); - removeRows = model->rowCount(); - for (int c = 0; c < network_ndev; c++) { - Models::AddEntry(model, tr(network_devs[c].description), c); - if (QString(network_devs[c].device) == currentPcapDevice) { - selectedRow = c; + if (network_ndev > 0) { + QString currentPcapDevice = net_cards_conf[i].host_dev_name; + cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); + model = cbox->model(); + removeRows = model->rowCount(); + for (int c = 0; c < network_ndev; c++) { + Models::AddEntry(model, tr(network_devs[c].description), c); + if (QString(network_devs[c].device) == currentPcapDevice) { + selectedRow = c; + } } + model->removeRows(0, removeRows); + cbox->setCurrentIndex(selectedRow); + } + if (net_cards_conf[i].net_type == NET_TYPE_VDE) { + QString currentVdeSocket = net_cards_conf[i].host_dev_name; + auto editline = findChild(QString("socketVDENIC%1").arg(i+1)); + editline->setText(currentVdeSocket); } - model->removeRows(0, removeRows); - cbox->setCurrentIndex(selectedRow); } } diff --git a/src/qt/qt_settingsnetwork.ui b/src/qt/qt_settingsnetwork.ui index d781a1beb..d6f77a0a2 100644 --- a/src/qt/qt_settingsnetwork.ui +++ b/src/qt/qt_settingsnetwork.ui @@ -36,19 +36,6 @@ Network Card #1 - - - - - 0 - 0 - - - - QComboBox::AdjustToContents - - - @@ -62,14 +49,17 @@ - - + + 0 0 + + QComboBox::AdjustToContents + @@ -98,17 +88,14 @@ - - + + - + 0 0 - - Mode - @@ -121,7 +108,7 @@ - + Qt::Vertical @@ -134,6 +121,33 @@ + + + + + 0 + 0 + + + + Mode + + + + + + + 127 + + + + + + + VDE Socket + + + @@ -141,6 +155,36 @@ Network Card #2 + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + + + + Configure + + + @@ -154,19 +198,6 @@ - - - - - 0 - 0 - - - - Mode - - - @@ -193,6 +224,19 @@ + + + + + 0 + 0 + + + + Mode + + + @@ -203,25 +247,28 @@ - - - - - 0 - 0 - - - - - - + + - Configure + VDE Socket - - + + + + + + + + Network Card #3 + + + + + + + Qt::Vertical @@ -233,23 +280,6 @@ - - - - - Network Card #3 - - - - - - - 0 - 0 - - - - @@ -263,17 +293,14 @@ - - + + - + 0 0 - - Mode - @@ -299,19 +326,6 @@ - - - - - 0 - 0 - - - - Configure - - - @@ -325,41 +339,8 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Network Card #4 - - - - - - - 0 - 0 - - - - QComboBox::AdjustToContents - - - - + 0 @@ -371,14 +352,44 @@ - - + + + + VDE Socket + + + + + - + 0 0 + + Mode + + + + + + + + Network Card #4 + + + + + + + 0 + 0 + + + + Adapter + @@ -394,29 +405,6 @@ - - - - - 0 - 0 - - - - Adapter - - - - - - - - 0 - 0 - - - - @@ -430,7 +418,43 @@ - + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Configure + + + + Qt::Vertical @@ -443,6 +467,26 @@ + + + + + 0 + 0 + + + + + + + + + + + VDE Socket + + + diff --git a/src/usb.c b/src/usb.c index 8ac16edd1..03b5f6546 100644 --- a/src/usb.c +++ b/src/usb.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #define HAVE_STDARG_H #include <86box/86box.h> @@ -28,6 +29,7 @@ #include <86box/mem.h> #include <86box/timer.h> #include <86box/usb.h> +#include <86box/dma.h> #ifdef ENABLE_USB_LOG int usb_do_log = ENABLE_USB_LOG; @@ -50,42 +52,94 @@ usb_log(const char *fmt, ...) /* OHCI registers */ enum { - OHCI_HcRevision = 0x00, - OHCI_HcControl = 0x04, - OHCI_HcCommandStatus = 0x08, - OHCI_HcInterruptStatus = 0x0C, - OHCI_HcInterruptEnable = 0x10, - OHCI_HcInterruptDisable = 0x14, - OHCI_HcHCCA = 0x18, - OHCI_HcPeriodCurrentED = 0x1C, - OHCI_HcControlHeadED = 0x20, - OHCI_HcControlCurrentED = 0x24, - OHCI_HcBulkHeadED = 0x28, - OHCI_HcBulkCurrentED = 0x2C, - OHCI_HcDoneHead = 0x30, - OHCI_HcFMInterval = 0x34, - OHCI_HcFmRemaining = 0x38, - OHCI_HcFmNumber = 0x3C, - OHCI_HcPeriodicStart = 0x40, - OHCI_HcLSThreshold = 0x44, - OHCI_HcRhDescriptorA = 0x48, - OHCI_HcRhDescriptorB = 0x4C, - OHCI_HcRhStatus = 0x50, - OHCI_HcRhPortStatus1 = 0x54, - OHCI_HcRhPortStatus2 = 0x58, - OHCI_HcRhPortStatus3 = 0x5C + OHCI_HcRevision = 0x00 /* 0x00 */, + OHCI_HcControl = 0x01 /* 0x04 */, + OHCI_HcCommandStatus = 0x02 /* 0x08 */, + OHCI_HcInterruptStatus = 0x03 /* 0x0c */, + OHCI_HcInterruptEnable = 0x04 /* 0x10 */, + OHCI_HcInterruptDisable = 0x05 /* 0x14 */, + OHCI_HcHCCA = 0x06 /* 0x18 */, + OHCI_HcPeriodCurrentED = 0x07 /* 0x1c */, + OHCI_HcControlHeadED = 0x08 /* 0x20 */, + OHCI_HcControlCurrentED = 0x09 /* 0x24 */, + OHCI_HcBulkHeadED = 0x0a /* 0x28 */, + OHCI_HcBulkCurrentED = 0x0b /* 0x2c */, + OHCI_HcDoneHead = 0x0c /* 0x30 */, + OHCI_HcFmInterval = 0x0d /* 0x34 */, + OHCI_HcFmRemaining = 0x0e /* 0x38 */, + OHCI_HcFmNumber = 0x0f /* 0x3c */, + OHCI_HcPeriodicStart = 0x10 /* 0x40 */, + OHCI_HcLSThreshold = 0x11 /* 0x44 */, + OHCI_HcRhDescriptorA = 0x12 /* 0x48 */, + OHCI_HcRhDescriptorB = 0x13 /* 0x4c */, + OHCI_HcRhStatus = 0x14 /* 0x50 */, + OHCI_HcRhPortStatus1 = 0x15 /* 0x54 */, + OHCI_HcRhPortStatus2 = 0x16 /* 0x58 */, + OHCI_HcRhPortStatus3 = 0x17 /* 0x5c */ +}; + +enum +{ + OHCI_aHcRevision = 0x00, + OHCI_aHcControl = 0x04, + OHCI_aHcCommandStatus = 0x08, + OHCI_aHcInterruptStatus = 0x0c, + OHCI_aHcInterruptEnable = 0x10, + OHCI_aHcInterruptDisable = 0x14, + OHCI_aHcHCCA = 0x18, + OHCI_aHcPeriodCurrentED = 0x1c, + OHCI_aHcControlHeadED = 0x20, + OHCI_aHcControlCurrentED = 0x24, + OHCI_aHcBulkHeadED = 0x28, + OHCI_aHcBulkCurrentED = 0x2c, + OHCI_aHcDoneHead = 0x30, + OHCI_aHcFmInterval = 0x34, + OHCI_aHcFmRemaining = 0x38, + OHCI_aHcFmNumber = 0x3c, + OHCI_aHcPeriodicStart = 0x40, + OHCI_aHcLSThreshold = 0x44, + OHCI_aHcRhDescriptorA = 0x48, + OHCI_aHcRhDescriptorB = 0x4c, + OHCI_aHcRhStatus = 0x50, + OHCI_aHcRhPortStatus1 = 0x54, + OHCI_aHcRhPortStatus2 = 0x58, + OHCI_aHcRhPortStatus3 = 0x5c +}; + +/* OHCI HcInterruptEnable/Disable bits */ +enum +{ + OHCI_HcInterruptEnable_SO = 1 << 0, + OHCI_HcInterruptEnable_WDH = 1 << 1, + OHCI_HcInterruptEnable_SF = 1 << 2, + OHCI_HcInterruptEnable_RD = 1 << 3, + OHCI_HcInterruptEnable_UE = 1 << 4, + OHCI_HcInterruptEnable_HNO = 1 << 5, + OHCI_HcInterruptEnable_RHSC = 1 << 6, +}; + +/* OHCI HcControl bits */ +enum +{ + OHCI_HcControl_ControlBulkServiceRatio = 1 << 0, + OHCI_HcControl_PeriodicListEnable = 1 << 1, + OHCI_HcControl_IsochronousEnable = 1 << 2, + OHCI_HcControl_ControlListEnable = 1 << 3, + OHCI_HcControl_BulkListEnable = 1 << 4 }; static void -usb_interrupt_ohci(usb_t* usb) +usb_interrupt_ohci(usb_t *dev, uint32_t level) { - if (usb->ohci_mmio[OHCI_HcControl + 1] & 1) { - smi_raise(); - } - else if (usb->usb_params != NULL) { - if (usb->usb_params->parent_priv != NULL && usb->usb_params->raise_interrupt != NULL) { - usb->usb_params->raise_interrupt(usb, usb->usb_params->parent_priv); - } + if (dev->ohci_mmio[OHCI_HcControl].b[1] & 1) { + if (dev->usb_params && dev->usb_params->smi_handle && !dev->usb_params->smi_handle(dev, dev->usb_params->parent_priv)) + return; + + if (level) + smi_raise(); + } else if (dev->usb_params != NULL) { + if ((dev->usb_params->parent_priv != NULL) && (dev->usb_params->update_interrupt != NULL)) + dev->usb_params->update_interrupt(dev, dev->usb_params->parent_priv); } } @@ -173,26 +227,235 @@ uhci_update_io_mapping(usb_t *dev, uint8_t base_l, uint8_t base_h, int enable) io_sethandler(dev->uhci_io_base, 0x20, uhci_reg_read, NULL, NULL, uhci_reg_write, uhci_reg_writew, NULL, dev); } +typedef struct +{ + uint32_t HccaInterrruptTable[32]; + uint16_t HccaFrameNumber; + uint16_t HccaPad1; + uint32_t HccaDoneHead; +} usb_hcca_t; + +/* Transfer descriptors */ +typedef struct +{ + union + { + uint32_t Control; + struct + { + uint32_t Reserved : 18; + uint8_t bufferRounding : 1; + uint8_t Direction : 2; + uint8_t DelayInterrupt : 3; + uint8_t DataToggle : 2; + uint8_t ErrorCount : 2; + uint8_t ConditionCode : 4; + } flags; + }; + uint32_t CBP; + uint32_t NextTD; + uint32_t BE; +} usb_td_t; + +/* Endpoint descriptors */ +typedef struct +{ + union + { + uint32_t Control; + struct + { + uint8_t FunctionAddress : 7; + uint8_t EndpointNumber : 4; + uint8_t Direction : 2; + bool Speed : 1; + bool Skip : 1; + bool Format : 1; + uint16_t MaximumPacketSize : 11; + uint8_t Reserved : 5; + } flags; + }; + uint32_t TailP; + union + { + uint32_t HeadP; + struct + { + bool Halted : 1; + bool toggleCarry : 1; + } flags_2; + }; + uint32_t NextED; +} usb_ed_t; + +#define ENDPOINT_DESC_LIMIT 32 + static uint8_t ohci_mmio_read(uint32_t addr, void *p) { usb_t *dev = (usb_t *) p; uint8_t ret = 0x00; +#ifdef ENABLE_USB_LOG + uint32_t old_addr = addr; +#endif addr &= 0x00000fff; - ret = dev->ohci_mmio[addr]; + ret = dev->ohci_mmio[addr >> 2].b[addr & 3]; + + switch (addr) { + case 0x101: + ret = (ret & 0xfe) | (!!mem_a20_key); + break; + case OHCI_aHcRhPortStatus1 + 1: + case OHCI_aHcRhPortStatus2 + 1: + case OHCI_aHcRhPortStatus3 + 1: + ret |= 0x1; + break; + case OHCI_aHcInterruptDisable: + case OHCI_aHcInterruptDisable + 1: + case OHCI_aHcInterruptDisable + 2: + case OHCI_aHcInterruptDisable + 3: + ret = dev->ohci_mmio[OHCI_HcInterruptEnable].b[addr & 3]; + default: + break; + } if (addr == 0x101) ret = (ret & 0xfe) | (!!mem_a20_key); +#ifdef ENABLE_USB_LOG + usb_log("[R] %08X = %04X\n", old_addr, ret); +#endif + return ret; } +static uint16_t +ohci_mmio_readw(uint32_t addr, void *p) +{ + return ohci_mmio_read(addr, p) | (ohci_mmio_read(addr + 1, p) << 8); +} + +static uint32_t +ohci_mmio_readl(uint32_t addr, void *p) +{ + return ohci_mmio_readw(addr, p) | (ohci_mmio_readw(addr + 2, p) << 16); +} + +static void +ohci_update_irq(usb_t *dev) +{ + uint32_t level = !!(dev->ohci_mmio[OHCI_HcInterruptStatus].l & dev->ohci_mmio[OHCI_HcInterruptEnable].l); + + if (level != dev->irq_level) { + dev->irq_level = level; + usb_interrupt_ohci(dev, level); + } +} + +void +ohci_set_interrupt(usb_t *dev, uint8_t bit) +{ + if (!(dev->ohci_mmio[OHCI_HcInterruptEnable].b[3] & 0x80)) + return; + + if (!(dev->ohci_mmio[OHCI_HcInterruptEnable].b[0] & bit)) + return; + + if (dev->ohci_mmio[OHCI_HcInterruptDisable].b[0] & bit) + return; + + dev->ohci_mmio[OHCI_HcInterruptStatus].b[0] |= bit; + + ohci_update_irq(dev); +} + +uint8_t +ohci_service_endpoint_desc(usb_t* dev, uint32_t head) +{ + usb_ed_t endpoint_desc; + + return 0; +} + +void +ohci_end_of_frame(usb_t* dev) +{ + usb_hcca_t hcca; + /* TODO: Put endpoint and transfer descriptor processing here. */ + dma_bm_read(dev->ohci_mmio[OHCI_HcHCCA].l, (uint8_t*)&hcca, sizeof(usb_hcca_t), 4); + + if (dev->ohci_mmio[OHCI_HcControl].l & OHCI_HcControl_PeriodicListEnable) { + ohci_service_endpoint_desc(dev, hcca.HccaInterrruptTable[dev->ohci_mmio[OHCI_HcFmNumber].l & 0x1f]); + } + + if ((dev->ohci_mmio[OHCI_HcControl].l & OHCI_HcControl_ControlListEnable) + && (dev->ohci_mmio[OHCI_HcCommandStatus].l & 0x2)) { + uint8_t result = ohci_service_endpoint_desc(dev, dev->ohci_mmio[OHCI_HcControlHeadED].l); + if (!result) { + dev->ohci_mmio[OHCI_HcControlHeadED].l = 0; + dev->ohci_mmio[OHCI_HcCommandStatus].l &= ~0x2; + } + } + + if ((dev->ohci_mmio[OHCI_HcControl].l & OHCI_HcControl_BulkListEnable) + && (dev->ohci_mmio[OHCI_HcCommandStatus].l & 0x4)) { + uint8_t result = ohci_service_endpoint_desc(dev, dev->ohci_mmio[OHCI_HcBulkHeadED].l); + if (!result) { + dev->ohci_mmio[OHCI_HcBulkHeadED].l = 0; + dev->ohci_mmio[OHCI_HcCommandStatus].l &= ~0x4; + } + } + + if (dev->ohci_interrupt_counter == 0 && !(dev->ohci_mmio[OHCI_HcInterruptStatus].l & OHCI_HcInterruptEnable_WDH)) { + if (dev->ohci_mmio[OHCI_HcDoneHead].l == 0) { + fatal("OHCI: HcDoneHead is still NULL!"); + } + + if (dev->ohci_mmio[OHCI_HcInterruptStatus].l & dev->ohci_mmio[OHCI_HcInterruptEnable].l) { + dev->ohci_mmio[OHCI_HcDoneHead].l |= 1; + } + + hcca.HccaDoneHead = dev->ohci_mmio[OHCI_HcDoneHead].l; + dev->ohci_mmio[OHCI_HcDoneHead].l = 0; + dev->ohci_interrupt_counter = 7; + ohci_set_interrupt(dev, OHCI_HcInterruptEnable_WDH); + } + + if (dev->ohci_interrupt_counter != 0 && dev->ohci_interrupt_counter != 7) { + dev->ohci_interrupt_counter--; + } + + dev->ohci_mmio[OHCI_HcFmNumber].w[0]++; + hcca.HccaFrameNumber = dev->ohci_mmio[OHCI_HcFmNumber].w[0]; + + dma_bm_write(dev->ohci_mmio[OHCI_HcHCCA].l, (uint8_t*)&hcca, sizeof(usb_hcca_t), 4); +} + +void +ohci_start_of_frame(usb_t* dev) +{ + ohci_set_interrupt(dev, OHCI_HcInterruptEnable_SO); +} + void ohci_update_frame_counter(void* priv) { usb_t *dev = (usb_t *) priv; + + dev->ohci_mmio[OHCI_HcFmRemaining].w[0] &= 0x3fff; + if (dev->ohci_mmio[OHCI_HcFmRemaining].w[0] == 0) { + ohci_end_of_frame(dev); + dev->ohci_mmio[OHCI_HcFmRemaining].w[0] = dev->ohci_mmio[OHCI_HcFmInterval].w[0] & 0x3fff; + dev->ohci_mmio[OHCI_HcFmRemaining].l &= ~(1 << 31); + dev->ohci_mmio[OHCI_HcFmRemaining].l |= dev->ohci_mmio[OHCI_HcFmInterval].l & (1 << 31); + ohci_start_of_frame(dev); + timer_on_auto(&dev->ohci_frame_timer, 1. / 12.); + return; + } + dev->ohci_mmio[OHCI_HcFmRemaining].w[0]--; + timer_on_auto(&dev->ohci_frame_timer, 1. / 12.); } void @@ -200,7 +463,8 @@ ohci_port_reset_callback(void* priv) { usb_t *dev = (usb_t *) priv; - dev->ohci_mmio[OHCI_HcRhPortStatus1] &= ~0x10; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[0] &= ~0x10; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[2] |= 0x10; } void @@ -208,7 +472,8 @@ ohci_port_reset_callback_2(void* priv) { usb_t *dev = (usb_t *) priv; - dev->ohci_mmio[OHCI_HcRhPortStatus2] &= ~0x10; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[0] &= ~0x10; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[2] |= 0x10; } static void @@ -217,198 +482,250 @@ ohci_mmio_write(uint32_t addr, uint8_t val, void *p) usb_t *dev = (usb_t *) p; uint8_t old; +#ifdef ENABLE_USB_LOG + usb_log("[W] %08X = %04X\n", addr, val); +#endif + addr &= 0x00000fff; switch (addr) { - case OHCI_HcControl: + case OHCI_aHcControl: if ((val & 0xc0) == 0x00) { /* UsbReset */ - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 2] = dev->ohci_mmio[OHCI_HcRhPortStatus2 + 2] = 0x16; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[2] = dev->ohci_mmio[OHCI_HcRhPortStatus2].b[2] = 0x16; } break; - case OHCI_HcCommandStatus: + case OHCI_aHcCommandStatus: /* bit OwnershipChangeRequest triggers an ownership change (SMM <-> OS) */ if (val & 0x08) { - dev->ohci_mmio[OHCI_HcInterruptStatus + 3] = 0x40; - if ((dev->ohci_mmio[OHCI_HcInterruptEnable + 3] & 0xc0) == 0xc0) + dev->ohci_mmio[OHCI_HcInterruptStatus].b[3] = 0x40; + if ((dev->ohci_mmio[OHCI_HcInterruptEnable].b[3] & 0xc0) == 0xc0) smi_raise(); } /* bit HostControllerReset must be cleared for the controller to be seen as initialized */ if (val & 0x01) { memset(dev->ohci_mmio, 0x00, 4096); - dev->ohci_mmio[OHCI_HcRevision] = 0x10; - dev->ohci_mmio[OHCI_HcRevision + 1] = 0x01; - dev->ohci_mmio[OHCI_HcRhDescriptorA] = 0x02; + dev->ohci_mmio[OHCI_HcRevision].b[0] = 0x10; + dev->ohci_mmio[OHCI_HcRevision].b[1] = 0x01; + dev->ohci_mmio[OHCI_HcRhDescriptorA].b[0] = 0x02; val &= ~0x01; } break; - case OHCI_HcHCCA: + case OHCI_aHcHCCA: return; - case OHCI_HcInterruptStatus: - dev->ohci_mmio[addr] &= ~(val & 0x7f); + case OHCI_aHcInterruptEnable: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x7f); + dev->ohci_mmio[OHCI_HcInterruptDisable].b[0] &= ~(val & 0x7f); + ohci_update_irq(dev); return; - case OHCI_HcInterruptStatus + 1: - case OHCI_HcInterruptStatus + 2: + case OHCI_aHcInterruptEnable + 1: + case OHCI_aHcInterruptEnable + 2: return; - case OHCI_HcInterruptStatus + 3: - dev->ohci_mmio[addr] &= ~(val & 0x40); + case OHCI_aHcInterruptEnable + 3: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0xc0); + dev->ohci_mmio[OHCI_HcInterruptDisable].b[3] &= ~(val & 0xc0); + ohci_update_irq(dev); return; - case OHCI_HcFmRemaining + 3: - dev->ohci_mmio[addr] = (val & 0x80); + case OHCI_aHcInterruptDisable: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x7f); + dev->ohci_mmio[OHCI_HcInterruptEnable].b[0] &= ~(val & 0x7f); + ohci_update_irq(dev); return; - case OHCI_HcFmRemaining + 1: - case OHCI_HcPeriodicStart + 1: - dev->ohci_mmio[addr] = (val & 0x3f); + case OHCI_aHcInterruptDisable + 1: + case OHCI_aHcInterruptDisable + 2: return; - case OHCI_HcLSThreshold + 1: - dev->ohci_mmio[addr] = (val & 0x0f); + case OHCI_aHcInterruptDisable + 3: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0xc0); + dev->ohci_mmio[OHCI_HcInterruptEnable].b[3] &= ~(val & 0xc0); + ohci_update_irq(dev); return; - case OHCI_HcFmRemaining + 2: - case OHCI_HcFmNumber + 2: - case OHCI_HcFmNumber + 3: - case OHCI_HcPeriodicStart + 2: - case OHCI_HcPeriodicStart + 3: - case OHCI_HcLSThreshold + 2: - case OHCI_HcLSThreshold + 3: - case OHCI_HcRhDescriptorA: - case OHCI_HcRhDescriptorA + 2: + case OHCI_aHcInterruptStatus: + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~(val & 0x7f); return; - case OHCI_HcRhDescriptorA + 1: - dev->ohci_mmio[addr] = (val & 0x1b); + case OHCI_aHcInterruptStatus + 1: + case OHCI_aHcInterruptStatus + 2: + return; + case OHCI_aHcInterruptStatus + 3: + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~(val & 0x40); + return; + case OHCI_aHcFmRemaining + 3: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x80); + return; + case OHCI_aHcFmRemaining + 1: + case OHCI_aHcPeriodicStart + 1: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x3f); + return; + case OHCI_aHcLSThreshold + 1: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x0f); + return; + case OHCI_aHcFmRemaining + 2: + case OHCI_aHcFmNumber + 2: + case OHCI_aHcFmNumber + 3: + case OHCI_aHcPeriodicStart + 2: + case OHCI_aHcPeriodicStart + 3: + case OHCI_aHcLSThreshold + 2: + case OHCI_aHcLSThreshold + 3: + case OHCI_aHcRhDescriptorA: + case OHCI_aHcRhDescriptorA + 2: + return; + case OHCI_aHcRhDescriptorA + 1: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x1b); if (val & 0x02) { - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 1] |= 0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 1] |= 0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[1] |= 0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[1] |= 0x01; } return; - case OHCI_HcRhDescriptorA + 3: - dev->ohci_mmio[addr] = (val & 0x03); + case OHCI_aHcRhDescriptorA + 3: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x03); return; - case OHCI_HcRhDescriptorB: - case OHCI_HcRhDescriptorB + 2: - dev->ohci_mmio[addr] = (val & 0x06); + case OHCI_aHcRhDescriptorB: + case OHCI_aHcRhDescriptorB + 2: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0x06); if ((addr == OHCI_HcRhDescriptorB) && !(val & 0x04)) { - if (!(dev->ohci_mmio[OHCI_HcRhPortStatus2] & 0x01)) - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 2] |= 0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus2] |= 0x01; + if (!(dev->ohci_mmio[OHCI_HcRhPortStatus2].b[0] & 0x01)) + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[2] |= 0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[0] |= 0x01; } if ((addr == OHCI_HcRhDescriptorB) && !(val & 0x02)) { - if (!(dev->ohci_mmio[OHCI_HcRhPortStatus1] & 0x01)) - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 2] |= 0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus1] |= 0x01; + if (!(dev->ohci_mmio[OHCI_HcRhPortStatus1].b[0] & 0x01)) + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[2] |= 0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[0] |= 0x01; } return; - case OHCI_HcRhDescriptorB + 1: - case OHCI_HcRhDescriptorB + 3: + case OHCI_aHcRhDescriptorB + 1: + case OHCI_aHcRhDescriptorB + 3: return; - case OHCI_HcRhStatus: + case OHCI_aHcRhStatus: if (val & 0x01) { - if ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x00) { - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 1] &= ~0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus1] &= ~0x17; - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 2] &= ~0x17; - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 1] &= ~0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus2] &= ~0x17; - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 2] &= ~0x17; - } else if ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x01) { - if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x02)) { - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 1] &= ~0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus1] &= ~0x17; - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 2] &= ~0x17; + if ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x00) { + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[1] &= ~0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[0] &= ~0x17; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[2] &= ~0x17; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[1] &= ~0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[0] &= ~0x17; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[2] &= ~0x17; + } else if ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x01) { + if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x02)) { + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[1] &= ~0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[0] &= ~0x17; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[2] &= ~0x17; } - if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x04)) { - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 1] &= ~0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus2] &= ~0x17; - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 2] &= ~0x17; + if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x04)) { + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[1] &= ~0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[0] &= ~0x17; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[2] &= ~0x17; } } } return; - case OHCI_HcRhStatus + 1: + case OHCI_aHcRhStatus + 1: if (val & 0x80) - dev->ohci_mmio[addr] |= 0x80; + dev->ohci_mmio[addr >> 2].b[addr & 3] |= 0x80; return; - case OHCI_HcRhStatus + 2: - dev->ohci_mmio[addr] &= ~(val & 0x02); + case OHCI_aHcRhStatus + 2: + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~(val & 0x02); if (val & 0x01) { - if ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x00) { - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 1] |= 0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 1] |= 0x01; - } else if ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x01) { - if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x02)) - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 1] |= 0x01; - if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x04)) - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 1] |= 0x01; + if ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x00) { + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[1] |= 0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[1] |= 0x01; + } else if ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x01) { + if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x02)) + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[1] |= 0x01; + if (!(dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x04)) + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[1] |= 0x01; } } return; - case OHCI_HcRhStatus + 3: + case OHCI_aHcRhStatus + 3: if (val & 0x80) - dev->ohci_mmio[OHCI_HcRhStatus + 1] &= ~0x80; + dev->ohci_mmio[OHCI_HcRhStatus].b[1] &= ~0x80; return; - case OHCI_HcRhPortStatus1: - case OHCI_HcRhPortStatus2: - old = dev->ohci_mmio[addr]; + case OHCI_aHcRhPortStatus1: + case OHCI_aHcRhPortStatus2: + old = dev->ohci_mmio[addr >> 2].b[addr & 3]; if (val & 0x10) { if (old & 0x01) { - dev->ohci_mmio[addr] |= 0x10; - timer_on_auto(&dev->ohci_port_reset_timer[(addr - OHCI_HcRhPortStatus1) / 4], 10000.); - dev->ohci_mmio[addr + 2] |= 0x10; + dev->ohci_mmio[addr >> 2].b[addr & 3] |= 0x10; + timer_on_auto(&dev->ohci_port_reset_timer[(addr - OHCI_aHcRhPortStatus1) / 4], 10000.); } else - dev->ohci_mmio[addr + 2] |= 0x01; + dev->ohci_mmio[(addr + 2) >> 2].b[(addr + 2) & 3] |= 0x01; } if (val & 0x08) - dev->ohci_mmio[addr] &= ~0x04; + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~0x04; if (val & 0x04) - dev->ohci_mmio[addr] |= 0x04; + dev->ohci_mmio[addr >> 2].b[addr & 3] |= 0x04; if (val & 0x02) { if (old & 0x01) - dev->ohci_mmio[addr] |= 0x02; + dev->ohci_mmio[addr >> 2].b[addr & 3] |= 0x02; else - dev->ohci_mmio[addr + 2] |= 0x01; + dev->ohci_mmio[(addr + 2) >> 2].b[(addr + 2) & 3] |= 0x01; } if (val & 0x01) { if (old & 0x01) - dev->ohci_mmio[addr] &= ~0x02; + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~0x02; else - dev->ohci_mmio[addr + 2] |= 0x01; + dev->ohci_mmio[(addr + 2) >> 2].b[(addr + 2) & 3] |= 0x01; } - if (!(dev->ohci_mmio[addr] & 0x04) && (old & 0x04)) - dev->ohci_mmio[addr + 2] |= 0x04; - /* if (!(dev->ohci_mmio[addr] & 0x02)) - dev->ohci_mmio[addr + 2] |= 0x02; */ + if (!(dev->ohci_mmio[addr >> 2].b[addr & 3] & 0x04) && (old & 0x04)) + dev->ohci_mmio[(addr + 2) >> 2].b[(addr + 2) & 3] |= 0x04; + /* if (!(dev->ohci_mmio[addr >> 2].b[addr & 3] & 0x02)) + dev->ohci_mmio[(addr + 2) >> 2].b[(addr + 2) & 3] |= 0x02; */ return; - case OHCI_HcRhPortStatus1 + 1: - if ((val & 0x02) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x02)) { - dev->ohci_mmio[addr] &= ~0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus1] &= ~0x17; - dev->ohci_mmio[OHCI_HcRhPortStatus1 + 2] &= ~0x17; + case OHCI_aHcRhPortStatus1 + 1: + if ((val & 0x02) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x02)) { + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[0] &= ~0x17; + dev->ohci_mmio[OHCI_HcRhPortStatus1].b[2] &= ~0x17; } - if ((val & 0x01) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x02)) { - dev->ohci_mmio[addr] |= 0x01; - dev->ohci_mmio[OHCI_HcRhPortStatus2] &= ~0x17; - dev->ohci_mmio[OHCI_HcRhPortStatus2 + 2] &= ~0x17; + if ((val & 0x01) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x02)) { + dev->ohci_mmio[addr >> 2].b[addr & 3] |= 0x01; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[0] &= ~0x17; + dev->ohci_mmio[OHCI_HcRhPortStatus2].b[2] &= ~0x17; } return; - case OHCI_HcRhPortStatus2 + 1: - if ((val & 0x02) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x04)) - dev->ohci_mmio[addr] &= ~0x01; - if ((val & 0x01) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA + 1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB + 2] & 0x04)) - dev->ohci_mmio[addr] |= 0x01; + case OHCI_aHcRhPortStatus2 + 1: + if ((val & 0x02) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x04)) + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~0x01; + if ((val & 0x01) && ((dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] & 0x03) == 0x00) && (dev->ohci_mmio[OHCI_HcRhDescriptorB].b[2] & 0x04)) + dev->ohci_mmio[addr >> 2].b[addr & 3] |= 0x01; return; - case OHCI_HcRhPortStatus1 + 2: - case OHCI_HcRhPortStatus2 + 2: - dev->ohci_mmio[addr] &= ~(val & 0x1f); + case OHCI_aHcRhPortStatus1 + 2: + case OHCI_aHcRhPortStatus2 + 2: + dev->ohci_mmio[addr >> 2].b[addr & 3] &= ~(val & 0x1f); return; - case OHCI_HcRhPortStatus1 + 3: - case OHCI_HcRhPortStatus2 + 3: + case OHCI_aHcRhPortStatus1 + 3: + case OHCI_aHcRhPortStatus2 + 3: + return; + case OHCI_aHcDoneHead: + case OHCI_aHcBulkCurrentED: + case OHCI_aHcBulkHeadED: + case OHCI_aHcControlCurrentED: + case OHCI_aHcControlHeadED: + case OHCI_aHcPeriodCurrentED: + dev->ohci_mmio[addr >> 2].b[addr & 3] = (val & 0xf0); return; } - dev->ohci_mmio[addr] = val; + dev->ohci_mmio[addr >> 2].b[addr & 3] = val; } + +static void +ohci_mmio_writew(uint32_t addr, uint16_t val, void *p) +{ + ohci_mmio_write(addr, val & 0xff, p); + ohci_mmio_write(addr + 1, val >> 8, p); +} + +static void +ohci_mmio_writel(uint32_t addr, uint32_t val, void *p) +{ + ohci_mmio_writew(addr, val & 0xffff, p); + ohci_mmio_writew(addr + 2, val >> 16, p); +} + void ohci_update_mem_mapping(usb_t *dev, uint8_t base1, uint8_t base2, uint8_t base3, int enable) { @@ -420,6 +737,20 @@ ohci_update_mem_mapping(usb_t *dev, uint8_t base1, uint8_t base2, uint8_t base3, if (dev->ohci_enable && (dev->ohci_mem_base != 0x00000000)) mem_mapping_set_addr(&dev->ohci_mmio_mapping, dev->ohci_mem_base, 0x1000); + + usb_log("ohci_update_mem_mapping(): OHCI %sabled at %08X\n", dev->ohci_enable ? "en" : "dis", dev->ohci_mem_base); +} + +uint8_t +usb_attach_device(usb_t *dev, usb_device_t* device, uint8_t bus_type) +{ + return 255; +} + +void +usb_detach_device(usb_t *dev, uint8_t port, uint8_t bus_type) +{ + /* Unused. */ } static void @@ -427,20 +758,24 @@ usb_reset(void *priv) { usb_t *dev = (usb_t *) priv; - memset(dev->uhci_io, 0x00, 128); + memset(dev->uhci_io, 0x00, sizeof(dev->uhci_io)); dev->uhci_io[0x0c] = 0x40; dev->uhci_io[0x10] = dev->uhci_io[0x12] = 0x80; - memset(dev->ohci_mmio, 0x00, 4096); - dev->ohci_mmio[OHCI_HcRevision] = 0x10; - dev->ohci_mmio[OHCI_HcRevision + 1] = 0x01; - dev->ohci_mmio[OHCI_HcRhDescriptorA] = 0x02; + memset(dev->ohci_mmio, 0x00, sizeof(dev->ohci_mmio)); + dev->ohci_mmio[OHCI_HcRevision].b[0] = 0x10; + dev->ohci_mmio[OHCI_HcRevision].b[1] = 0x01; + dev->ohci_mmio[OHCI_HcRhDescriptorA].b[0] = 0x02; + dev->ohci_mmio[OHCI_HcRhDescriptorA].b[1] = 0x02; io_removehandler(dev->uhci_io_base, 0x20, uhci_reg_read, NULL, NULL, uhci_reg_write, uhci_reg_writew, NULL, dev); dev->uhci_enable = 0; mem_mapping_disable(&dev->ohci_mmio_mapping); dev->ohci_enable = 0; + + usb_log("usb_reset(): OHCI %sabled at %08X\n", dev->ohci_enable ? "en" : "dis", dev->ohci_mem_base); + usb_log("usb_reset(): map = %08X\n", &dev->ohci_mmio_mapping); } static void @@ -452,7 +787,7 @@ usb_close(void *priv) } static void * -usb_init_ext(const device_t *info, void* params) +usb_init_ext(const device_t *info, void *params) { usb_t *dev; @@ -461,15 +796,19 @@ usb_init_ext(const device_t *info, void* params) return (NULL); memset(dev, 0x00, sizeof(usb_t)); - dev->usb_params = (usb_params_t*)params; + dev->usb_params = (usb_params_t *) params; - mem_mapping_add(&dev->ohci_mmio_mapping, 0, 0, - ohci_mmio_read, NULL, NULL, - ohci_mmio_write, NULL, NULL, + mem_mapping_add(&dev->ohci_mmio_mapping, 0, 0x1000, + ohci_mmio_read, ohci_mmio_readw, ohci_mmio_readl, + ohci_mmio_write, ohci_mmio_writew, ohci_mmio_writel, NULL, MEM_MAPPING_EXTERNAL, dev); + + mem_mapping_disable(&dev->ohci_mmio_mapping); + timer_add(&dev->ohci_frame_timer, ohci_update_frame_counter, dev, 0); /* Unused for now, to be used for frame counting. */ timer_add(&dev->ohci_port_reset_timer[0], ohci_port_reset_callback, dev, 0); timer_add(&dev->ohci_port_reset_timer[1], ohci_port_reset_callback_2, dev, 0); + usb_reset(dev); return dev; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index f7f3ce607..b82b116c6 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -37,19 +37,15 @@ #include <86box/vid_svga_render.h> #include "cpu.h" -static void ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len); static void ibm8514_accel_outb(uint16_t port, uint8_t val, void *p); static void ibm8514_accel_outw(uint16_t port, uint16_t val, void *p); static uint8_t ibm8514_accel_inb(uint16_t port, void *p); static uint16_t ibm8514_accel_inw(uint16_t port, void *p); -static void ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, ibm8514_t *dev, uint8_t ssv, int len); -static void ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, ibm8514_t *dev, int len); - #define READ_PIXTRANS_WORD(cx, n) \ - if (cmd <= 1 || (cmd == 5)) { \ - temp = dev->vram[((dev->accel.cy * dev->h_disp) + (cx) + (n)) & dev->vram_mask]; \ - temp |= (dev->vram[((dev->accel.cy * dev->h_disp) + (cx) + (n + 1)) & dev->vram_mask] << 8); \ + if ((cmd <= 1) || (cmd == 5)) { \ + temp = dev->vram[((dev->accel.cy * dev->pitch) + (cx) + (n)) & dev->vram_mask]; \ + temp |= (dev->vram[((dev->accel.cy * dev->pitch) + (cx) + (n + 1)) & dev->vram_mask] << 8); \ } else { \ temp = dev->vram[(dev->accel.dest + (cx) + (n)) & dev->vram_mask]; \ temp |= (dev->vram[(dev->accel.dest + (cx) + (n + 1)) & dev->vram_mask] << 8); \ @@ -164,9 +160,11 @@ static void ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint dev->vram[((addr)) & (dev->vram_mask)] = dat; \ dev->changedvram[(((addr)) & (dev->vram_mask)) >> 12] = changeframecount; -static int -ibm8514_cpu_src(ibm8514_t *dev) +int +ibm8514_cpu_src(svga_t *svga) { + ibm8514_t *dev = &svga->dev8514; + if (!(dev->accel.cmd & 0x100)) return 0; @@ -176,9 +174,11 @@ ibm8514_cpu_src(ibm8514_t *dev) return 0; } -static int -ibm8514_cpu_dest(ibm8514_t *dev) +int +ibm8514_cpu_dest(svga_t *svga) { + ibm8514_t *dev = &svga->dev8514; + if (!(dev->accel.cmd & 0x100)) return 0; @@ -188,9 +188,10 @@ ibm8514_cpu_dest(ibm8514_t *dev) return 1; } -static void -ibm8514_accel_out_pixtrans(ibm8514_t *dev, uint16_t port, uint16_t val, int len) +void +ibm8514_accel_out_pixtrans(svga_t *svga, uint16_t port, uint16_t val, int len) { + ibm8514_t *dev = &svga->dev8514; uint8_t nibble = 0; uint32_t pixelxfer = 0, monoxfer = 0xffffffff; int pixcnt = 0; @@ -295,12 +296,12 @@ regular_nibble: nibble |= 0x01; } - if ((and3 == 0) || (dev->accel.cmd & 0x1000) || ((dev->accel.cmd & 8) && ibm8514_cpu_src(dev))) { - if ((dev->accel.cmd & 8) && ibm8514_cpu_src(dev)) { + if ((and3 == 0) || (dev->accel.cmd & 0x1000) || ((dev->accel.cmd & 8) && ibm8514_cpu_src(svga))) { + if ((dev->accel.cmd & 8) && ibm8514_cpu_src(svga)) { monoxfer = val; } else monoxfer = nibble; - ibm8514_accel_start(pixcnt, 1, monoxfer, pixelxfer, dev, len); + ibm8514_accel_start(pixcnt, 1, monoxfer, pixelxfer, svga, len); if (dev->accel.nibbleset != NULL) { free(dev->accel.nibbleset); dev->accel.nibbleset = NULL; @@ -383,7 +384,7 @@ regular_nibble: for (int i = 0; i < dev->accel.x_count; i++) { dev->accel.writemono[i] &= ~dev->accel.nibbleset[i]; dev->accel.writemono[i] |= dev->accel.nibbleset[i + 1]; - ibm8514_accel_start(pixcnt, 1, dev->accel.writemono[i], pixelxfer, dev, len); + ibm8514_accel_start(pixcnt, 1, dev->accel.writemono[i], pixelxfer, svga, len); } dev->accel.x_count = 0; @@ -403,14 +404,16 @@ regular_nibble: } else { pixelxfer = val; } - ibm8514_accel_start(pixcnt, 1, monoxfer, pixelxfer, dev, len); + ibm8514_accel_start(pixcnt, 1, monoxfer, pixelxfer, svga, len); } } } static void -ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) +ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) { + ibm8514_t *dev = &svga->dev8514; + switch (port) { case 0x82e8: case 0xc2e8: @@ -527,7 +530,7 @@ ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) dev->accel.cmd = val; if (dev->accel.cmd & 0x100) dev->accel.cmd_back = 0; - ibm8514_accel_start(-1, 0, -1, 0, dev, len); + ibm8514_accel_start(-1, 0, -1, 0, svga, len); } break; case 0x9ae9: @@ -540,7 +543,7 @@ ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) if (dev->accel.cmd & 0x100) dev->accel.cmd_back = 0; } - ibm8514_accel_start(-1, 0, -1, 0, dev, len); + ibm8514_accel_start(-1, 0, -1, 0, svga, len); } break; @@ -557,12 +560,13 @@ ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) dev->accel.cx |= ~0x3ff; if (dev->accel.cur_y & 0x400) dev->accel.cy |= ~0x3ff; + if (dev->accel.cmd & 0x1000) { - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke & 0xff, len); - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke >> 8, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke & 0xff, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke >> 8, len); } else { - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke >> 8, len); - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke & 0xff, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke >> 8, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke & 0xff, len); } } break; @@ -578,11 +582,11 @@ ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) dev->accel.cy |= ~0x3ff; if (dev->accel.cmd & 0x1000) { - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke & 0xff, len); - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke >> 8, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke & 0xff, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke >> 8, len); } else { - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke >> 8, len); - ibm8514_short_stroke_start(-1, 0, -1, 0, dev, dev->accel.short_stroke & 0xff, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke >> 8, len); + ibm8514_short_stroke_start(-1, 0, -1, 0, svga, dev->accel.short_stroke & 0xff, len); } } break; @@ -596,9 +600,9 @@ ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) else dev->accel.bkgd_color = val; } else { - if (ibm8514_cpu_dest(dev)) + if (ibm8514_cpu_dest(svga)) break; - ibm8514_accel_out_pixtrans(dev, port, val, len); + ibm8514_accel_out_pixtrans(svga, port, val, len); } } else { if (len == 1) @@ -622,9 +626,9 @@ ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) else dev->accel.frgd_color = val; } else { - if (ibm8514_cpu_dest(dev)) + if (ibm8514_cpu_dest(svga)) break; - ibm8514_accel_out_pixtrans(dev, port, val, len); + ibm8514_accel_out_pixtrans(svga, port, val, len); } } else { if (len == 1) @@ -721,47 +725,21 @@ ibm8514_accel_out_fifo(ibm8514_t *dev, uint16_t port, uint32_t val, int len) } } -static void +void ibm8514_ramdac_out(uint16_t port, uint8_t val, void *p) { svga_t *svga = (svga_t *) p; - switch (port) { - case 0x2ea: - svga_out(0x3c6, val, svga); - break; - case 0x2eb: - svga_out(0x3c7, val, svga); - break; - case 0x2ec: - svga_out(0x3c8, val, svga); - break; - case 0x2ed: - svga_out(0x3c9, val, svga); - break; - } + svga_out(port, val, svga); } -static uint8_t +uint8_t ibm8514_ramdac_in(uint16_t port, void *p) { svga_t *svga = (svga_t *) p; - uint8_t ret = 0xff; + uint8_t ret; - switch (port) { - case 0x2ea: - ret = svga_in(0x3c6, svga); - break; - case 0x2eb: - ret = svga_in(0x3c7, svga); - break; - case 0x2ec: - ret = svga_in(0x3c8, svga); - break; - case 0x2ed: - ret = svga_in(0x3c9, svga); - break; - } + ret = svga_in(port, svga); return ret; } @@ -827,7 +805,7 @@ ibm8514_accel_out(uint16_t port, uint32_t val, svga_t *svga, int len) ibm8514_t *dev = &svga->dev8514; if (port & 0x8000) { - ibm8514_accel_out_fifo(dev, port, val, len); + ibm8514_accel_out_fifo(svga, port, val, len); } else { switch (port) { case 0x2e8: @@ -938,10 +916,12 @@ ibm8514_accel_out(uint16_t port, uint32_t val, svga_t *svga, int len) break; case 0x4ae8: + if (!val) + break; dev->accel.advfunc_cntl = val & 7; - vga_on = ((dev->accel.advfunc_cntl & 1) == 0) ? 1 : 0; - ibm8514_on = !vga_on; - // pclog("IBM 8514/A: VGA ON = %i, val = %02x\n", vga_on, val); + ibm8514_on = (dev->accel.advfunc_cntl & 1); + vga_on = !ibm8514_on; + //pclog("IBM 8514/A: VGA ON = %i, val = %02x\n", vga_on, val); svga_recalctimings(svga); break; } @@ -968,8 +948,22 @@ ibm8514_accel_in(uint16_t port, svga_t *svga, int len) ibm8514_t *dev = &svga->dev8514; uint32_t temp = 0; int cmd; + int vpos = dev->displine + svga->y_add; + int vblankend = svga->vblankstart + svga->crtc[0x16]; switch (port) { + case 0x2e8: + vpos = dev->displine + svga->y_add; + if (vblankend > dev->vtotal) { + vblankend -= dev->vtotal; + if (vpos >= svga->vblankstart || vpos <= vblankend) + temp |= 2; + } else { + if (vpos >= svga->vblankstart && vpos <= vblankend) + temp |= 2; + } + break; + case 0x6e8: temp = dev->hdisp; break; @@ -994,6 +988,15 @@ ibm8514_accel_in(uint16_t port, svga_t *svga, int len) break; case 0x42e8: + vpos = dev->displine + svga->y_add; + if (vblankend > dev->vtotal) { + vblankend -= dev->vtotal; + if (vpos >= svga->vblankstart || vpos <= vblankend) + dev->subsys_stat |= 1; + } else { + if (vpos >= svga->vblankstart && vpos <= vblankend) + dev->subsys_stat |= 1; + } if (len != 1) { temp = dev->subsys_stat | 0xa0 | 0x8000; } else @@ -1013,7 +1016,6 @@ ibm8514_accel_in(uint16_t port, svga_t *svga, int len) case 0x9ae8: case 0xdae8: - temp = 0; if (len != 1) { if (dev->force_busy) temp |= 0x200; /*Hardware busy*/ @@ -1026,7 +1028,6 @@ ibm8514_accel_in(uint16_t port, svga_t *svga, int len) break; case 0x9ae9: case 0xdae9: - temp = 0; if (len == 1) { if (dev->force_busy2) temp |= 2; /*Hardware busy*/ @@ -1040,7 +1041,7 @@ ibm8514_accel_in(uint16_t port, svga_t *svga, int len) case 0xe2e8: case 0xe6e8: - if (ibm8514_cpu_dest(dev)) { + if (ibm8514_cpu_dest(svga)) { if (len == 1) { ; // READ_PIXTRANS_BYTE_IO(0) } else { @@ -1051,15 +1052,15 @@ ibm8514_accel_in(uint16_t port, svga_t *svga, int len) temp |= (dev->vram[(dev->accel.newdest_in + dev->accel.cur_x) & dev->vram_mask] << 8); } } - ibm8514_accel_out_pixtrans(dev, port, temp, len); + ibm8514_accel_out_pixtrans(svga, port, temp, len); } break; case 0xe2e9: case 0xe6e9: - if (ibm8514_cpu_dest(dev)) { + if (ibm8514_cpu_dest(svga)) { if (len == 1) { ; // READ_PIXTRANS_BYTE_IO(1) - ibm8514_accel_out_pixtrans(dev, port, temp, len); + ibm8514_accel_out_pixtrans(svga, port, temp, len); } } break; @@ -1081,25 +1082,28 @@ ibm8514_accel_inw(uint16_t port, void *p) return ibm8514_accel_in(port, svga, 2); } -static void -ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, ibm8514_t *dev, uint8_t ssv, int len) +void +ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, uint8_t ssv, int len) { + ibm8514_t *dev = &svga->dev8514; + if (!cpu_input) { dev->accel.ssv_len = ssv & 0x0f; dev->accel.ssv_dir = ssv & 0xe0; dev->accel.ssv_draw = ssv & 0x10; - if (ibm8514_cpu_src(dev)) { + if (ibm8514_cpu_src(svga)) { return; /*Wait for data from CPU*/ } } - ibm8514_accel_start(count, cpu_input, mix_dat, cpu_dat, dev, len); + ibm8514_accel_start(count, cpu_input, mix_dat, cpu_dat, svga, len); } -static void -ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, ibm8514_t *dev, int len) +void +ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, int len) { + ibm8514_t *dev = &svga->dev8514; uint8_t src_dat = 0, dest_dat, old_dest_dat; int frgd_mix, bkgd_mix; uint16_t clip_b = dev->accel.multifunc[3] & 0x7ff; @@ -1145,75 +1149,75 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat mix_dat = 0; if (and3 == 3) { if (dev->accel.multifunc[8] & 0x02) - mix_dat |= 0x10; - if (dev->accel.multifunc[8] & 0x04) mix_dat |= 0x08; + if (dev->accel.multifunc[8] & 0x04) + mix_dat |= 0x10; if (dev->accel.multifunc[8] & 0x08) - mix_dat |= 0x04; - if (dev->accel.multifunc[8] & 0x10) - mix_dat |= 0x02; - if (dev->accel.multifunc[9] & 0x02) - mix_dat |= 0x01; - if (dev->accel.multifunc[9] & 0x04) - mix_dat |= 0x80; - if (dev->accel.multifunc[9] & 0x08) - mix_dat |= 0x40; - if (dev->accel.multifunc[9] & 0x10) mix_dat |= 0x20; + if (dev->accel.multifunc[8] & 0x10) + mix_dat |= 0x40; + if (dev->accel.multifunc[9] & 0x02) + mix_dat |= 0x80; + if (dev->accel.multifunc[9] & 0x04) + mix_dat |= 0x01; + if (dev->accel.multifunc[9] & 0x08) + mix_dat |= 0x02; + if (dev->accel.multifunc[9] & 0x10) + mix_dat |= 0x04; } if (and3 == 2) { if (dev->accel.multifunc[8] & 0x02) - mix_dat |= 0x20; - if (dev->accel.multifunc[8] & 0x04) - mix_dat |= 0x10; - if (dev->accel.multifunc[8] & 0x08) - mix_dat |= 0x08; - if (dev->accel.multifunc[8] & 0x10) mix_dat |= 0x04; + if (dev->accel.multifunc[8] & 0x04) + mix_dat |= 0x08; + if (dev->accel.multifunc[8] & 0x08) + mix_dat |= 0x10; + if (dev->accel.multifunc[8] & 0x10) + mix_dat |= 0x20; if (dev->accel.multifunc[9] & 0x02) - mix_dat |= 0x02; - if (dev->accel.multifunc[9] & 0x04) - mix_dat |= 0x01; - if (dev->accel.multifunc[9] & 0x08) - mix_dat |= 0x80; - if (dev->accel.multifunc[9] & 0x10) mix_dat |= 0x40; + if (dev->accel.multifunc[9] & 0x04) + mix_dat |= 0x80; + if (dev->accel.multifunc[9] & 0x08) + mix_dat |= 0x01; + if (dev->accel.multifunc[9] & 0x10) + mix_dat |= 0x02; } if (and3 == 1) { if (dev->accel.multifunc[8] & 0x02) - mix_dat |= 0x40; - if (dev->accel.multifunc[8] & 0x04) - mix_dat |= 0x20; - if (dev->accel.multifunc[8] & 0x08) - mix_dat |= 0x10; - if (dev->accel.multifunc[8] & 0x10) - mix_dat |= 0x08; - if (dev->accel.multifunc[9] & 0x02) - mix_dat |= 0x04; - if (dev->accel.multifunc[9] & 0x04) mix_dat |= 0x02; + if (dev->accel.multifunc[8] & 0x04) + mix_dat |= 0x04; + if (dev->accel.multifunc[8] & 0x08) + mix_dat |= 0x08; + if (dev->accel.multifunc[8] & 0x10) + mix_dat |= 0x10; + if (dev->accel.multifunc[9] & 0x02) + mix_dat |= 0x20; + if (dev->accel.multifunc[9] & 0x04) + mix_dat |= 0x40; if (dev->accel.multifunc[9] & 0x08) - mix_dat |= 0x01; - if (dev->accel.multifunc[9] & 0x10) mix_dat |= 0x80; + if (dev->accel.multifunc[9] & 0x10) + mix_dat |= 0x01; } if (and3 == 0) { if (dev->accel.multifunc[8] & 0x02) - mix_dat |= 0x80; - if (dev->accel.multifunc[8] & 0x04) - mix_dat |= 0x40; - if (dev->accel.multifunc[8] & 0x08) - mix_dat |= 0x20; - if (dev->accel.multifunc[8] & 0x10) - mix_dat |= 0x10; - if (dev->accel.multifunc[9] & 0x02) - mix_dat |= 0x08; - if (dev->accel.multifunc[9] & 0x04) - mix_dat |= 0x04; - if (dev->accel.multifunc[9] & 0x08) - mix_dat |= 0x02; - if (dev->accel.multifunc[9] & 0x10) mix_dat |= 0x01; + if (dev->accel.multifunc[8] & 0x04) + mix_dat |= 0x02; + if (dev->accel.multifunc[8] & 0x08) + mix_dat |= 0x04; + if (dev->accel.multifunc[8] & 0x10) + mix_dat |= 0x08; + if (dev->accel.multifunc[9] & 0x02) + mix_dat |= 0x10; + if (dev->accel.multifunc[9] & 0x04) + mix_dat |= 0x20; + if (dev->accel.multifunc[9] & 0x08) + mix_dat |= 0x40; + if (dev->accel.multifunc[9] & 0x10) + mix_dat |= 0x80; } } @@ -1244,13 +1248,13 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat src_dat = 0; break; } - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); if ((compare_mode == 0) || ((compare_mode == 0x10) && (dest_dat >= compare)) || ((compare_mode == 0x18) && (dest_dat < compare)) || ((compare_mode == 0x20) && (dest_dat != compare)) || ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { MIX(mix_dat & mix_mask, dest_dat, src_dat); if (dev->accel.ssv_draw) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } @@ -1316,7 +1320,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat dev->accel.sy = dev->accel.maj_axis_pcnt; - if (ibm8514_cpu_src(dev)) { + if (ibm8514_cpu_src(svga)) { if (dev->accel.cmd & 2) { if (dev->accel.cmd & 8) { if (and3 == 1) { @@ -1349,7 +1353,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat dev->data_available = 0; dev->data_available2 = 0; return; /*Wait for data from CPU*/ - } else if (ibm8514_cpu_dest(dev)) { + } else if (ibm8514_cpu_dest(svga)) { dev->data_available = 1; dev->data_available2 = 1; return; @@ -1357,22 +1361,22 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } if (dev->accel.cmd & 8) { /*Vector Line*/ - if (ibm8514_cpu_dest(dev) && cpu_input && (dev->accel.cmd & 2)) + if (ibm8514_cpu_dest(svga) && cpu_input && (dev->accel.cmd & 2)) count >>= 1; dev->accel.xx_count++; while (count-- && (dev->accel.sy >= 0)) { if ((dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b)) { - if (ibm8514_cpu_dest(dev) && (pixcntl == 0)) { + if (ibm8514_cpu_dest(svga) && (pixcntl == 0)) { mix_dat = mix_mask; /* Mix data = forced to foreground register. */ - } else if (ibm8514_cpu_dest(dev) && (pixcntl == 3)) { + } else if (ibm8514_cpu_dest(svga) && (pixcntl == 3)) { /* Mix data = current video memory value. */ - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, mix_dat); + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, mix_dat); mix_dat = ((mix_dat & rd_mask) == rd_mask); mix_dat = mix_dat ? mix_mask : 0; } - if (ibm8514_cpu_dest(dev)) { - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, src_dat); + if (ibm8514_cpu_dest(svga)) { + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, src_dat); if (pixcntl == 3) src_dat = ((src_dat & rd_mask) == rd_mask); } else @@ -1391,76 +1395,76 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat break; } - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); if ((compare_mode == 0) || ((compare_mode == 0x10) && (dest_dat >= compare)) || ((compare_mode == 0x18) && (dest_dat < compare)) || ((compare_mode == 0x20) && (dest_dat != compare)) || ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { old_dest_dat = dest_dat; MIX(mix_dat & mix_mask, dest_dat, src_dat); dest_dat = (dest_dat & wrt_mask) | (old_dest_dat & ~wrt_mask); - if ((dev->accel.cmd & 2) && ibm8514_cpu_src(dev)) { + if ((dev->accel.cmd & 2) && ibm8514_cpu_src(svga)) { if (and3 == 1) { if (dev->accel.xx_count >= 2) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } else if (and3 == 2) { if (dev->accel.xx_count == 2) { if (count <= 2) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } else if (dev->accel.xx_count >= 3) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } else if (and3 == 3) { if (dev->accel.xx_count == 2) { if (count <= 1) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } else if (dev->accel.xx_count >= 3) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } else { if (dev->accel.xx_count == 1) { if (!count) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } else if (dev->accel.xx_count >= 2) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } } else { - if (ibm8514_cpu_src(dev) || !cpu_input) { + if (ibm8514_cpu_src(svga) || !cpu_input) { if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } @@ -1519,8 +1523,8 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat mix_dat = old_mix_dat; } if ((dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b)) { - if (ibm8514_cpu_dest(dev)) { - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, src_dat); + if (ibm8514_cpu_dest(svga)) { + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, src_dat); } else switch ((mix_dat & 1) ? frgd_mix : bkgd_mix) { case 0: @@ -1537,16 +1541,16 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat break; } - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); if ((compare_mode == 0) || ((compare_mode == 0x10) && (dest_dat >= compare)) || ((compare_mode == 0x18) && (dest_dat < compare)) || ((compare_mode == 0x20) && (dest_dat != compare)) || ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { old_dest_dat = dest_dat; MIX(mix_dat & 1, dest_dat, src_dat); dest_dat = (dest_dat & wrt_mask) | (old_dest_dat & ~wrt_mask); if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } @@ -1624,17 +1628,17 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } else { while (count-- && (dev->accel.sy >= 0)) { if (((dev->accel.cx) >= dev->accel.clip_left && (dev->accel.cx) <= clip_r && (dev->accel.cy) >= dev->accel.clip_top && (dev->accel.cy) <= clip_b)) { - if (ibm8514_cpu_dest(dev) && (pixcntl == 0)) { + if (ibm8514_cpu_dest(svga) && (pixcntl == 0)) { mix_dat = mix_mask; /* Mix data = forced to foreground register. */ - } else if (ibm8514_cpu_dest(dev) && (pixcntl == 3)) { + } else if (ibm8514_cpu_dest(svga) && (pixcntl == 3)) { /* Mix data = current video memory value. */ - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, mix_dat); + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, mix_dat); mix_dat = ((mix_dat & rd_mask) == rd_mask); mix_dat = mix_dat ? mix_mask : 0; } - if (ibm8514_cpu_dest(dev)) { - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, src_dat); + if (ibm8514_cpu_dest(svga)) { + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, src_dat); if (pixcntl == 3) src_dat = ((src_dat & rd_mask) == rd_mask); } else @@ -1653,16 +1657,16 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat break; } - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); if ((compare_mode == 0) || ((compare_mode == 0x10) && (dest_dat >= compare)) || ((compare_mode == 0x18) && (dest_dat < compare)) || ((compare_mode == 0x20) && (dest_dat != compare)) || ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { old_dest_dat = dest_dat; MIX(mix_dat & mix_mask, dest_dat, src_dat); dest_dat = (dest_dat & wrt_mask) | (old_dest_dat & ~wrt_mask); if ((dev->accel.cmd & 4) && dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } else if (!(dev->accel.cmd & 4)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); } } } @@ -1766,7 +1770,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (dev->accel.cur_y & 0x400) dev->accel.cy |= ~0x3ff; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.fill_state = 0; if (cmd == 4) @@ -1774,7 +1778,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat else if (cmd == 3) dev->accel.cmd &= ~2; - if (ibm8514_cpu_src(dev)) { + if (ibm8514_cpu_src(svga)) { if (dev->accel.cmd & 2) { if (!(dev->accel.cmd & 0x1000)) { if (!(dev->accel.cmd & 8)) { @@ -1814,18 +1818,18 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!(dev->accel.cmd & 0x40) && (frgd_mix == 2) && (bkgd_mix == 2) && (pixcntl == 0) && (cmd == 2)) { if (!(dev->accel.sx & 1)) { dev->accel.output = 1; - dev->accel.newdest_out = (dev->accel.cy + 1) * dev->h_disp; + dev->accel.newdest_out = (dev->accel.cy + 1) * dev->pitch; } } } dev->data_available = 0; dev->data_available2 = 0; return; /*Wait for data from CPU*/ - } else if (ibm8514_cpu_dest(dev)) { + } else if (ibm8514_cpu_dest(svga)) { if (!(dev->accel.cmd & 2) && (frgd_mix == 2) && (pixcntl == 0) && (cmd == 2)) { if (!(dev->accel.sx & 1)) { dev->accel.input = 1; - dev->accel.newdest_in = (dev->accel.cy + 1) * dev->h_disp; + dev->accel.newdest_in = (dev->accel.cy + 1) * dev->pitch; } } else if (dev->accel.cmd & 2) { if (dev->accel.cmd & 8) { @@ -1844,7 +1848,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (dev->accel.cmd & 2) { if (cpu_input) { rect_fill_pix: - if ((dev->accel.cmd & 8) && ibm8514_cpu_src(dev)) { + if ((dev->accel.cmd & 8) && ibm8514_cpu_src(svga)) { dev->accel.xx_count++; while (count-- && (dev->accel.sy >= 0)) { if ((dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b)) { @@ -1993,7 +1997,7 @@ rect_fill_pix: break; } - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -2003,16 +2007,16 @@ rect_fill_pix: if (count < 8) { while (count-- && (dev->accel.sy >= 0)) { if ((dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b)) { - if (ibm8514_cpu_dest(dev) && (pixcntl == 0)) { + if (ibm8514_cpu_dest(svga) && (pixcntl == 0)) { mix_dat = mix_mask; /* Mix data = forced to foreground register. */ - } else if (ibm8514_cpu_dest(dev) && (pixcntl == 3)) { + } else if (ibm8514_cpu_dest(svga) && (pixcntl == 3)) { /* Mix data = current video memory value. */ READ(dev->accel.dest + dev->accel.cx, mix_dat); mix_dat = ((mix_dat & rd_mask) == rd_mask); mix_dat = mix_dat ? mix_mask : 0; } - if (ibm8514_cpu_dest(dev)) { + if (ibm8514_cpu_dest(svga)) { READ(dev->accel.dest + dev->accel.cx, src_dat); if (pixcntl == 3) src_dat = ((src_dat & rd_mask) == rd_mask); @@ -2069,7 +2073,7 @@ rect_fill_pix: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -2077,16 +2081,16 @@ rect_fill_pix: } else { while (count-- && (dev->accel.sy >= 0)) { if ((dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b)) { - if (ibm8514_cpu_dest(dev) && (pixcntl == 0)) { + if (ibm8514_cpu_dest(svga) && (pixcntl == 0)) { mix_dat = 1; /* Mix data = forced to foreground register. */ - } else if (ibm8514_cpu_dest(dev) && (pixcntl == 3)) { + } else if (ibm8514_cpu_dest(svga) && (pixcntl == 3)) { /* Mix data = current video memory value. */ READ(dev->accel.dest + dev->accel.cx, mix_dat); mix_dat = ((mix_dat & rd_mask) == rd_mask); mix_dat = mix_dat ? 1 : 0; } - if (ibm8514_cpu_dest(dev)) { + if (ibm8514_cpu_dest(svga)) { READ(dev->accel.dest + dev->accel.cx, src_dat); if (pixcntl == 3) src_dat = ((src_dat & rd_mask) == rd_mask); @@ -2151,7 +2155,7 @@ rect_fill_pix: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -2205,8 +2209,8 @@ rect_fill_pix: dev->accel.cy++; else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; - dev->accel.newdest_in = (dev->accel.cy + 1) * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; + dev->accel.newdest_in = (dev->accel.cy + 1) * dev->pitch; dev->accel.sy--; return; } @@ -2224,8 +2228,8 @@ rect_fill_pix: dev->accel.cy++; else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; - dev->accel.newdest_in = (dev->accel.cy + 1) * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; + dev->accel.newdest_in = (dev->accel.cy + 1) * dev->pitch; dev->accel.sy--; return; } @@ -2272,8 +2276,8 @@ rect_fill_pix: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; - dev->accel.newdest_out = (dev->accel.cy + 1) * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; + dev->accel.newdest_out = (dev->accel.cy + 1) * dev->pitch; dev->accel.sy--; return; } @@ -2292,8 +2296,8 @@ rect_fill_pix: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; - dev->accel.newdest_out = (dev->accel.cy + 1) * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; + dev->accel.newdest_out = (dev->accel.cy + 1) * dev->pitch; dev->accel.sy--; return; } @@ -2302,16 +2306,16 @@ rect_fill_pix: } else { while (count-- && (dev->accel.sy >= 0)) { if ((dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b)) { - if (ibm8514_cpu_dest(dev) && (pixcntl == 0)) { + if (ibm8514_cpu_dest(svga) && (pixcntl == 0)) { mix_dat = mix_mask; /* Mix data = forced to foreground register. */ - } else if (ibm8514_cpu_dest(dev) && (pixcntl == 3)) { + } else if (ibm8514_cpu_dest(svga) && (pixcntl == 3)) { /* Mix data = current video memory value. */ READ(dev->accel.dest + dev->accel.cx, mix_dat); mix_dat = ((mix_dat & rd_mask) == rd_mask); mix_dat = mix_dat ? mix_mask : 0; } - if (ibm8514_cpu_dest(dev)) { + if (ibm8514_cpu_dest(svga)) { READ(dev->accel.dest + dev->accel.cx, src_dat); if (pixcntl == 3) { src_dat = ((src_dat & rd_mask) == rd_mask); @@ -2336,7 +2340,7 @@ rect_fill_pix: if ((compare_mode == 0) || ((compare_mode == 0x10) && (dest_dat >= compare)) || ((compare_mode == 0x18) && (dest_dat < compare)) || ((compare_mode == 0x20) && (dest_dat != compare)) || ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { old_dest_dat = dest_dat; - if (ibm8514_cpu_dest(dev)) { + if (ibm8514_cpu_dest(svga)) { if (pixcntl == 3) { MIX(mix_dat & mix_mask, dest_dat, src_dat); } @@ -2371,7 +2375,7 @@ rect_fill_pix: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -2441,7 +2445,7 @@ rect_fill: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; dev->accel.cur_x = dev->accel.cx; @@ -2505,7 +2509,7 @@ rect_fill: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; if (dev->accel.sy < 0) { @@ -2583,7 +2587,7 @@ rect_fill: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; if (dev->accel.sy < 0) { @@ -2643,7 +2647,7 @@ rect_fill: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; if (dev->accel.sy < 0) { @@ -2665,16 +2669,13 @@ rect_fill: dev->accel.cy = dev->accel.cur_y; dev->accel.oldcy = dev->accel.cy; - dev->accel.xdir = (dev->accel.cmd & 0x20) ? 1 : -1; - dev->accel.ydir = (dev->accel.cmd & 0x80) ? 1 : -1; - dev->accel.sy = 0; - if (ibm8514_cpu_src(dev)) { + if (ibm8514_cpu_src(svga)) { dev->data_available = 0; dev->data_available2 = 0; return; /*Wait for data from CPU*/ - } else if (ibm8514_cpu_dest(dev)) { + } else if (ibm8514_cpu_dest(svga)) { dev->data_available = 1; dev->data_available2 = 1; return; @@ -2682,7 +2683,10 @@ rect_fill: } while (count-- && (dev->accel.sy >= 0)) { - if (((dev->accel.cx) >= dev->accel.clip_left && (dev->accel.cx <= clip_r) && (dev->accel.cy) >= dev->accel.clip_top && (dev->accel.cy) <= clip_b)) { + if (dev->accel.cur_x > 1023) + dev->accel.cx = 0; + + if (((dev->accel.cx) >= dev->accel.clip_left && ((dev->accel.cx) <= clip_r) && (dev->accel.cy) >= dev->accel.clip_top && (dev->accel.cy) <= clip_b)) { switch ((mix_dat & mix_mask) ? frgd_mix : bkgd_mix) { case 0: src_dat = bkgd_color; @@ -2698,7 +2702,7 @@ rect_fill: break; } - READ((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + READ((dev->accel.cy * dev->pitch) + dev->accel.cx, dest_dat); if ((compare_mode == 0) || ((compare_mode == 0x10) && (dest_dat >= compare)) || ((compare_mode == 0x18) && (dest_dat < compare)) || ((compare_mode == 0x20) && (dest_dat != compare)) || ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { old_dest_dat = dest_dat; @@ -2706,11 +2710,11 @@ rect_fill: dest_dat = (dest_dat & wrt_mask) | (old_dest_dat & ~wrt_mask); if ((dev->accel.cmd & 4) && (dev->accel.sy < dev->accel.maj_axis_pcnt)) { if (!dev->accel.sy) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); - } else if ((dev->accel.cmd & 0x40) && dev->accel.sy && (dev->accel.cy == dev->accel.oldcy + 1)) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + (dev->accel.cx), dest_dat); + } else if ((dev->accel.cmd & 0x40) && dev->accel.sy && (dev->accel.cy == (dev->accel.oldcy + 1))) { + WRITE((dev->accel.cy * dev->pitch) + (dev->accel.cx), dest_dat); } else if (!(dev->accel.cmd & 0x40) && dev->accel.sy && (dev->accel.err_term >= 0) && (dev->accel.cy == (dev->accel.oldcy + 1))) { - WRITE((dev->accel.cy * dev->h_disp) + dev->accel.cx, dest_dat); + WRITE((dev->accel.cy * dev->pitch) + (dev->accel.cx), dest_dat); } } } @@ -2721,27 +2725,75 @@ rect_fill: cpu_dat >>= 8; if (dev->accel.sy == dev->accel.maj_axis_pcnt) { - return; + break; } - if (dev->accel.cmd & 0x40) { - dev->accel.oldcy = dev->accel.cy; - dev->accel.cy += dev->accel.ydir; - if (dev->accel.err_term >= 0) { - dev->accel.err_term += dev->accel.destx_distp; - dev->accel.cx += dev->accel.xdir; - } else { - dev->accel.err_term += dev->accel.desty_axstp; + if (dev->accel.err_term >= dev->accel.maj_axis_pcnt) { + dev->accel.err_term += dev->accel.destx_distp; + /*Step minor axis*/ + switch (dev->accel.cmd & 0xe0) { + case 0x00: + dev->accel.oldcy = dev->accel.cy; + dev->accel.cy--; + break; + case 0x20: + dev->accel.oldcy = dev->accel.cy; + dev->accel.cy--; + break; + case 0x40: + dev->accel.cx--; + break; + case 0x60: + dev->accel.cx++; + break; + case 0x80: + dev->accel.oldcy = dev->accel.cy; + dev->accel.cy++; + break; + case 0xa0: + dev->accel.oldcy = dev->accel.cy; + dev->accel.cy++; + break; + case 0xc0: + dev->accel.cx--; + break; + case 0xe0: + dev->accel.cx++; + break; } - } else { - dev->accel.cx += dev->accel.xdir; - if (dev->accel.err_term >= 0) { - dev->accel.err_term += dev->accel.destx_distp; + } else + dev->accel.err_term += dev->accel.desty_axstp; + + /*Step major axis*/ + switch (dev->accel.cmd & 0xe0) { + case 0x00: + dev->accel.cx--; + break; + case 0x20: + dev->accel.cx++; + break; + case 0x40: dev->accel.oldcy = dev->accel.cy; - dev->accel.cy += dev->accel.ydir; - } else { - dev->accel.err_term += dev->accel.desty_axstp; - } + dev->accel.cy--; + break; + case 0x60: + dev->accel.oldcy = dev->accel.cy; + dev->accel.cy--; + break; + case 0x80: + dev->accel.cx--; + break; + case 0xa0: + dev->accel.cx++; + break; + case 0xc0: + dev->accel.oldcy = dev->accel.cy; + dev->accel.cy++; + break; + case 0xe0: + dev->accel.oldcy = dev->accel.cy; + dev->accel.cy++; + break; } dev->accel.sy++; @@ -2773,10 +2825,10 @@ rect_fill: if (dev->accel.cur_y & 0x400) dev->accel.cy |= ~0x3ff; - dev->accel.src = dev->accel.cy * dev->h_disp; - dev->accel.dest = dev->accel.dy * dev->h_disp; + dev->accel.src = dev->accel.cy * dev->pitch; + dev->accel.dest = dev->accel.dy * dev->pitch; - if (ibm8514_cpu_src(dev)) { + if (ibm8514_cpu_src(svga)) { if (dev->accel.cmd & 2) { if (!(dev->accel.cmd & 0x1000)) { dev->accel.sx += (dev->accel.cur_x & 3); @@ -2788,7 +2840,7 @@ rect_fill: dev->data_available = 0; dev->data_available2 = 0; return; /*Wait for data from CPU*/ - } else if (ibm8514_cpu_dest(dev)) { + } else if (ibm8514_cpu_dest(svga)) { dev->data_available = 1; dev->data_available2 = 1; return; /*Wait for data from CPU*/ @@ -2869,7 +2921,7 @@ bitblt_pix: else dev->accel.cy--; - dev->accel.dest = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -2964,8 +3016,8 @@ bitblt_pix: dev->accel.cy--; } - dev->accel.dest = dev->accel.dy * dev->h_disp; - dev->accel.src = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.dy * dev->pitch; + dev->accel.src = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -3053,8 +3105,8 @@ bitblt_pix: dev->accel.cy--; } - dev->accel.dest = dev->accel.dy * dev->h_disp; - dev->accel.src = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.dy * dev->pitch; + dev->accel.src = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -3132,8 +3184,8 @@ bitblt: dev->accel.cy--; } - dev->accel.dest = dev->accel.dy * dev->h_disp; - dev->accel.src = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.dy * dev->pitch; + dev->accel.src = dev->accel.cy * dev->pitch; dev->accel.sy--; return; } @@ -3202,8 +3254,8 @@ bitblt: dev->accel.cy--; } - dev->accel.dest = dev->accel.dy * dev->h_disp; - dev->accel.src = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.dy * dev->pitch; + dev->accel.src = dev->accel.cy * dev->pitch; dev->accel.sy--; if (dev->accel.sy < 0) { @@ -3287,8 +3339,8 @@ bitblt: dev->accel.cy--; } - dev->accel.dest = dev->accel.dy * dev->h_disp; - dev->accel.src = dev->accel.cy * dev->h_disp; + dev->accel.dest = dev->accel.dy * dev->pitch; + dev->accel.src = dev->accel.cy * dev->pitch; dev->accel.sy--; if (dev->accel.sy < 0) { @@ -3393,7 +3445,7 @@ ibm8514_poll(ibm8514_t *dev, svga_t *svga) video_wait_for_buffer(); } - ibm8514_render_8bpp(svga); + svga->render(svga); svga->x_add = (overscan_x >> 1); ibm8514_render_overscan_left(dev, svga); @@ -3416,16 +3468,13 @@ ibm8514_poll(ibm8514_t *dev, svga_t *svga) dev->linepos = 0; if (dev->dispon) { if (dev->sc == dev->rowcount) { - dev->linecountff = 0; dev->sc = 0; - dev->maback += (dev->rowoffset << 3); if (dev->interlace) dev->maback += (dev->rowoffset << 3); dev->maback &= dev->vram_mask; dev->ma = dev->maback; } else { - dev->linecountff = 0; dev->sc++; dev->sc &= 31; dev->ma = dev->maback; @@ -3471,7 +3520,7 @@ ibm8514_poll(ibm8514_t *dev, svga_t *svga) changeframecount = dev->interlace ? 3 : 2; if (dev->interlace && dev->oddeven) - dev->ma = dev->maback = 0 + (dev->rowoffset << 1); + dev->ma = dev->maback = (dev->rowoffset << 1); else dev->ma = dev->maback = 0; @@ -3485,8 +3534,6 @@ ibm8514_poll(ibm8514_t *dev, svga_t *svga) dev->displine = (dev->interlace && dev->oddeven) ? 1 : 0; svga->x_add = (overscan_x >> 1); - - dev->linecountff = 0; } } } @@ -3496,42 +3543,104 @@ ibm8514_recalctimings(svga_t *svga) { ibm8514_t *dev = &svga->dev8514; - dev->h_disp_time = dev->h_disp = (dev->hdisp + 1) << 3; - dev->rowoffset = (dev->hdisp + 1); - dev->h_total = (dev->htotal + 1); - dev->v_total = (dev->vtotal + 1); - dev->v_syncstart = (dev->vsyncstart + 1); - dev->rowcount = !!(dev->disp_cntl & 0x08); - - if (dev->accel.advfunc_cntl & 4) { - if (dev->hdisp == 0) { - dev->rowoffset = 128; - dev->h_disp = 1024; - } - - if (dev->vtotal == 0) - dev->v_total = 1632; - - if (dev->vsyncstart == 0) - dev->v_syncstart = 1536; - - if (dev->interlace) { - dev->dispend = 384; /*Interlaced*/ - dev->v_total >>= 2; - dev->v_syncstart >>= 2; - } else { + if (ibm8514_on) { + dev->h_disp = (dev->hdisp + 1) << 3; + dev->pitch = dev->h_disp; + dev->h_total = (dev->htotal + 1); + dev->v_total = (dev->vtotal + 1); + dev->v_syncstart = (dev->vsyncstart + 1); + dev->rowcount = !!(dev->disp_cntl & 0x08); + dev->dispend = ((dev->vdisp >> 1) + 1); + if (dev->dispend == 766) dev->dispend = 768; - dev->v_total >>= 1; - dev->v_syncstart >>= 1; + //pclog("HDISP = %d, VTOTAL = %d, DISPEND = %d, hires = %02x\n", dev->h_disp, dev->v_total, dev->dispend, dev->accel.advfunc_cntl & 4); + { +#if 0 + if (dev->dispend == 480) { + dev->h_disp = 640; + dev->rowoffset = 128; + dev->pitch = 1024; + } else if ((dev->dispend == 600) || (dev->dispend == 598)) { + dev->h_disp = 800; + dev->rowoffset = 128; + dev->dispend = 600; + dev->pitch = 1024; + if (!dev->vtotal) + dev->v_total = 816; + if (!dev->vsyncstart) + dev->v_syncstart = dev->dispend; + } else { + if (dev->accel.advfunc_cntl & 4) { + if (!dev->hdisp) { + dev->rowoffset = 128; + dev->h_disp = 1024; + dev->pitch = dev->h_disp; + } + if (!dev->vtotal) + dev->v_total = 816; + if (!dev->vsyncstart) + dev->v_syncstart = dev->dispend; + } else { + dev->rowoffset = 128; + dev->h_disp = 640; + dev->dispend = 480; + dev->pitch = 1024; + if (!dev->vtotal) + dev->v_total = 816; + if (!dev->vsyncstart) + dev->v_syncstart = dev->dispend; + } + } +#endif } - // pclog("1024x768 clock mode, hdisp = %d, htotal = %d, vtotal = %d, vsyncstart = %d, interlace = %02x\n", dev->h_disp, dev->h_total, dev->v_total, dev->v_syncstart, dev->interlace); - svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; - } else { - // pclog("640x480 clock mode\n"); - dev->dispend = 480; - dev->v_total >>= 1; - dev->v_syncstart >>= 1; - svga->clock = (cpuclock * (double) (1ull << 32)) / 25175000.0; + + if (dev->accel.advfunc_cntl & 4) { + if (!vga_on && dev->ibm_mode) { + if (dev->h_disp == 8) { + dev->h_disp = 1024; + dev->dispend = 768; + dev->v_total = 1536; + dev->v_syncstart = 1536; + } + } + + if (dev->dispend == 598) + dev->dispend = 600; + + if (dev->interlace) { + dev->dispend >>= 1; + dev->v_syncstart >>= 2; + dev->v_total >>= 2; + } else { + dev->v_syncstart >>= 1; + dev->v_total >>= 1; + } + dev->rowoffset = 0x80; + dev->pitch = 1024; + + // pclog("1024x768 clock mode, hdisp = %d, htotal = %d, vtotal = %d, vsyncstart = %d, interlace = %02x\n", dev->h_disp, dev->h_total, dev->v_total, dev->v_syncstart, dev->interlace); + svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; + } else { + if (!vga_on && dev->ibm_mode) { + dev->h_disp = 640; + dev->dispend = 480; + } + + if (dev->interlace) { + dev->dispend >>= 1; + dev->v_syncstart >>= 2; + dev->v_total >>= 2; + } else { + dev->v_syncstart >>= 1; + dev->v_total >>= 1; + } + dev->rowoffset = 0x80; + dev->pitch = 1024; + + svga->clock = (cpuclock * (double) (1ull << 32)) / 25175000.0; + } + svga->render = ibm8514_render_8bpp; + //pclog("Pitch = %d, mode = %d.\n", dev->pitch, dev->ibm_mode); } // pclog("8514 enabled, hdisp=%d, vtotal=%d, htotal=%d, dispend=%d, rowoffset=%d, split=%d, vsyncstart=%d, split=%08x\n", dev->hdisp, dev->vtotal, dev->htotal, dev->dispend, dev->rowoffset, dev->split, dev->vsyncstart, dev->split); } @@ -3572,6 +3681,9 @@ static void * ibm8514_init(const device_t *info) { + if (svga_get_pri() == NULL) + return NULL; + svga_t *svga = svga_get_pri(); ibm8514_t *dev = &svga->dev8514; @@ -3582,6 +3694,7 @@ static void dev->map8 = svga->pallook; dev->type = info->flags; + dev->ibm_mode = 1; ibm8514_io_set(svga); diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 6f8cc0448..ceeb9cf65 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -199,15 +199,19 @@ svga_out(uint16_t addr, uint8_t val, void *p) break; } break; + case 0x2ea: case 0x3c6: svga->dac_mask = val; break; + case 0x2eb: + case 0x2ec: case 0x3c7: case 0x3c8: svga->dac_pos = 0; svga->dac_status = addr & 0x03; svga->dac_addr = (val + (addr & 0x01)) & 255; break; + case 0x2ed: case 0x3c9: if (svga->adv_flags & FLAG_RAMDAC_SHIFT) val <<= 2; @@ -311,15 +315,19 @@ svga_in(uint16_t addr, void *p) case 0x3c5: ret = svga->seqregs[svga->seqaddr & 0x0f]; break; + case 0x2ea: case 0x3c6: ret = svga->dac_mask; break; + case 0x2eb: case 0x3c7: ret = svga->dac_status; break; + case 0x2ec: case 0x3c8: ret = svga->dac_addr; break; + case 0x2ed: case 0x3c9: index = (svga->dac_addr - 1) & 255; switch (svga->dac_pos) { @@ -572,7 +580,7 @@ svga_recalctimings(svga_t *svga) svga->recalctimings_ex(svga); } } else { - if (ibm8514_on && ibm8514_enabled) + if (ibm8514_enabled) ibm8514_recalctimings(svga); if (xga_enabled) xga_recalctimings(svga); @@ -872,7 +880,7 @@ svga_poll(void *p) svga->oddeven ^= 1; svga->monitor->mon_changeframecount = svga->interlace ? 3 : 2; - svga->vslines = 0; + svga->vslines = 0; if (svga->interlace && svga->oddeven) svga->ma = svga->maback = svga->ma_latch + (svga->rowoffset << 1) + ((svga->crtc[5] & 0x60) >> 5); @@ -893,22 +901,24 @@ svga_poll(void *p) 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) + if (!ibm8514_on) { + 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; + } + } 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->scrollcache &= 0x07; - else { - svga->scrollcache++; - if (svga->scrollcache > 8) - svga->scrollcache = 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->scrollcache &= 0x07; - else - svga->scrollcache = (svga->scrollcache & 0x06) >> 1; + else + svga->scrollcache = (svga->scrollcache & 0x06) >> 1; - if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) - svga->scrollcache <<= 1; + if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) + svga->scrollcache <<= 1; + } svga->x_add = (svga->monitor->mon_overscan_x >> 1) - svga->scrollcache; @@ -938,9 +948,9 @@ svga_init(const device_t *info, svga_t *svga, void *p, int memsize, { int c, d, e; - svga->p = p; + svga->p = p; svga->monitor_index = monitor_index_global; - svga->monitor = &monitors[svga->monitor_index]; + svga->monitor = &monitors[svga->monitor_index]; for (c = 0; c < 256; c++) { e = c; @@ -954,10 +964,10 @@ svga_init(const device_t *info, svga_t *svga, void *p, int memsize, svga->attrregs[0x11] = 0; svga->overscan_color = 0x000000; - svga->monitor->mon_overscan_x = 16; - svga->monitor->mon_overscan_y = 32; - svga->x_add = 8; - svga->y_add = 16; + svga->monitor->mon_overscan_x = 16; + svga->monitor->mon_overscan_y = 32; + svga->x_add = 8; + svga->y_add = 16; svga->crtc[0] = 63; svga->crtc[6] = 255; @@ -1096,8 +1106,10 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *p) svga->xga.linear_endian_reverse = 1; return; } - } else + } else { svga->xga.on = 0; + vga_on = !svga->xga.on; + } } addr = svga_decode_addr(svga, addr, 1); @@ -1286,16 +1298,20 @@ svga_read_common(uint32_t addr, uint8_t linear, void *p) if (((svga->xga.op_mode & 7) >= 4) && (svga->xga.aperture_cntl == 1)) { if (svga->xga.test == 0xa5) { /*Memory size test of XGA*/ svga->xga.on = 1; + vga_on = !svga->xga.on; return svga->xga.test; } else if (svga->xga.test == 0x5a) { svga->xga.on = 1; + vga_on = !svga->xga.on; return svga->xga.test; } else if (addr == 0xa0000 || addr == 0xa0010) { addr += svga->xga.read_bank; return svga->xga.vram[addr & svga->xga.vram_mask]; } - } else + } else { svga->xga.on = 0; + vga_on = !svga->xga.on; + } } addr = svga_decode_addr(svga, addr, 0); diff --git a/src/video/vid_xga.c b/src/video/vid_xga.c index 84c1805ff..11e94f531 100644 --- a/src/video/vid_xga.c +++ b/src/video/vid_xga.c @@ -1,18 +1,18 @@ /* - * 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. + * 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. + * This file is part of the 86Box distribution. * - * IBM XGA emulation. + * IBM XGA emulation. * * * - * Authors: TheCollector1995. + * Authors: TheCollector1995. * - * Copyright 2022 TheCollector1995. + * Copyright 2022 TheCollector1995. */ #include #include @@ -38,16 +38,19 @@ #define XGA_BIOS_PATH "roms/video/xga/XGA_37F9576_Ver200.BIN" #define XGA2_BIOS_PATH "roms/video/xga/xga2_v300.bin" +static video_timings_t timing_xga_isa = { .type = VIDEO_ISA, .write_b = 3, .write_w = 3, .write_l = 6, .read_b = 5, .read_w = 5, .read_l = 10 }; +static video_timings_t timing_xga_mca = { .type = VIDEO_MCA, .write_b = 4, .write_w = 5, .write_l = 10, .read_b = 5, .read_w = 5, .read_l = 10 }; + static void xga_ext_outb(uint16_t addr, uint8_t val, void *p); static uint8_t xga_ext_inb(uint16_t addr, void *p); -static void +void xga_updatemapping(svga_t *svga) { xga_t *xga = &svga->xga; - // pclog("OpMode = %x, linear base = %08x, aperture cntl = %d, opmodereset1 = %d, access mode = %x, map = %x.\n", xga->op_mode, xga->linear_base, xga->aperture_cntl, xga->op_mode_reset, xga->access_mode, svga->gdcreg[6] & 0x0c); - if ((xga->op_mode & 7) >= 4) { + //pclog("OpMode = %x, linear base = %08x, aperture cntl = %d, opmodereset1 = %d, access mode = %x, map = %x.\n", xga->op_mode, xga->linear_base, xga->aperture_cntl, xga->op_mode_reset, xga->access_mode, svga->gdcreg[6] & 0x0c); + if (((xga->op_mode & 7) >= 4) || ((xga->op_mode & 7) == 0)) { if (xga->aperture_cntl == 1) { mem_mapping_disable(&svga->mapping); mem_mapping_set_addr(&xga->video_mapping, 0xa0000, 0x10000); @@ -56,25 +59,22 @@ xga_updatemapping(svga_t *svga) if (!xga->linear_endian_reverse) mem_mapping_disable(&xga->linear_mapping); } else if (xga->aperture_cntl == 0) { -linear: mem_mapping_disable(&svga->mapping); mem_mapping_set_addr(&xga->video_mapping, 0xa0000, 0x10000); mem_mapping_enable(&xga->video_mapping); xga->banked_mask = 0xffff; - if ((xga->pos_regs[4] & 1) && !xga->base_addr_1mb) { - xga->linear_size = 0x400000; - mem_mapping_set_addr(&xga->linear_mapping, xga->linear_base, xga->linear_size); - } else { - if (xga->base_addr_1mb) { - xga->linear_size = 0x100000; - mem_mapping_set_addr(&xga->linear_mapping, xga->base_addr_1mb, xga->linear_size); - } else - mem_mapping_disable(&xga->linear_mapping); - } - xga->on = 0; - vga_on = 1; - if (((xga->op_mode & 7) == 4) && ((svga->gdcreg[6] & 0x0c) == 0x0c) && !xga->a5_test) + if (xga->pos_regs[4] & 1) + mem_mapping_set_addr(&xga->linear_mapping, xga->linear_base, 0x400000); + else if (xga->base_addr_1mb) + mem_mapping_set_addr(&xga->linear_mapping, xga->base_addr_1mb, 0x100000); + else + mem_mapping_set_addr(&xga->linear_mapping, xga->linear_base, 0x400000); + if (((xga->op_mode & 7) == 4) && ((svga->gdcreg[6] & 0x0c) == 0x0c) && !xga->a5_test && xga->on) xga->linear_endian_reverse = 1; + else if (((xga->op_mode & 7) == 0) && ((svga->gdcreg[6] & 0x0c) == 0x0c) && !xga->a5_test && !xga->on) + xga->linear_endian_reverse = 1; + xga->on = 0; + vga_on = !xga->on; } else { mem_mapping_disable(&svga->mapping); mem_mapping_set_addr(&xga->video_mapping, 0xb0000, 0x10000); @@ -83,23 +83,17 @@ linear: mem_mapping_disable(&xga->linear_mapping); } } else { - if (!(xga->op_mode & 7)) { - goto linear; - } - if (xga->aperture_cntl == 2) { - mem_mapping_disable(&svga->mapping); - mem_mapping_set_addr(&xga->video_mapping, 0xb0000, 0x10000); - mem_mapping_enable(&xga->video_mapping); - xga->banked_mask = 0xffff; - } else { - mem_mapping_disable(&svga->mapping); - mem_mapping_set_addr(&xga->video_mapping, 0xa0000, 0x10000); - mem_mapping_enable(&xga->video_mapping); - xga->banked_mask = 0xffff; - } - mem_mapping_disable(&xga->linear_mapping); xga->on = 0; - vga_on = 1; + vga_on = !xga->on; + mem_mapping_disable(&svga->mapping); + if (xga->aperture_cntl == 2) + mem_mapping_set_addr(&xga->video_mapping, 0xb0000, 0x10000); + else + mem_mapping_set_addr(&xga->video_mapping, 0xa0000, 0x10000); + mem_mapping_enable(&xga->video_mapping); + xga->banked_mask = 0xffff; + mem_mapping_disable(&xga->linear_mapping); + //pclog("XGA opmode (not extended) = %d, disp mode = %d, aperture = %d.\n", xga->op_mode & 7, xga->disp_cntl_2 & 7, xga->aperture_cntl); } } @@ -147,8 +141,6 @@ xga_recalctimings(svga_t *svga) svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; break; } - } else { - vga_on = 1; } } @@ -292,6 +284,8 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val) case 0x51: xga->disp_cntl_2 = val; + xga->on = ((val & 7) >= 3); + vga_on = !xga->on; svga_recalctimings(svga); break; @@ -318,7 +312,7 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val) else if (xga->sprite_pos >= 1) xga->cursor_data_on = 1; else if (xga->aperture_cntl == 0) { - if (xga->linear_endian_reverse) + if (xga->linear_endian_reverse && !(xga->access_mode & 8)) xga->cursor_data_on = 0; } } @@ -351,7 +345,7 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val) break; case 0x65: - svga->fullchange = changeframecount; + svga->fullchange = svga->monitor->mon_changeframecount; switch (svga->dac_pos) { case 0: svga->dac_r = val; @@ -406,7 +400,7 @@ xga_ext_outb(uint16_t addr, uint8_t val, void *p) svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; - // pclog("[%04X:%08X]: EXT OUTB = %02x, val = %02x\n", CS, cpu_state.pc, addr, val); + //pclog("[%04X:%08X]: EXT OUTB = %02x, val = %02x\n", CS, cpu_state.pc, addr, val); switch (addr & 0x0f) { case 0: xga->op_mode = val; @@ -421,12 +415,10 @@ xga_ext_outb(uint16_t addr, uint8_t val, void *p) xga->aperture_cntl = 0; break; case 6: - vga_on = 0; - xga->on = 1; break; case 8: xga->ap_idx = val; - // pclog("Aperture CNTL = %d, val = %02x, up to bit6 = %02x\n", xga->aperture_cntl, val, val & 0x3f); + //pclog("Aperture CNTL = %d, val = %02x, up to bit6 = %02x\n", xga->aperture_cntl, val, val & 0x3f); if ((xga->op_mode & 7) < 4) { xga->write_bank = xga->read_bank = 0; } else { @@ -586,10 +578,10 @@ xga_ext_inb(uint16_t addr, void *p) ret = xga->disp_cntl_2; break; case 0x52: - ret = 0x0b; + ret = xga->type ? 0xfa : 0xea; break; case 0x53: - ret = 0x70; + ret = xga->type ? 0x53 : 0x30; break; case 0x54: ret = xga->clk_sel_1; @@ -667,7 +659,7 @@ xga_ext_inb(uint16_t addr, void *p) break; } - // pclog("[%04X:%08X]: EXT INB = %02x, ret = %02x\n", CS, cpu_state.pc, addr, ret); + //pclog("[%04X:%08X]: EXT INB = %02x, ret = %02x\n", CS, cpu_state.pc, addr, ret); return ret; } @@ -676,7 +668,7 @@ xga_ext_inb(uint16_t addr, void *p) #define WRITE(addr, dat) \ xga->vram[((addr)) & (xga->vram_mask)] = dat; \ - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount; + xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; #define READW(addr, dat) \ dat = *(uint16_t *) &xga->vram[(addr) & (xga->vram_mask)]; @@ -687,12 +679,12 @@ xga_ext_inb(uint16_t addr, void *p) #define WRITEW(addr, dat) \ *(uint16_t *) &xga->vram[((addr)) & (xga->vram_mask)] = dat; \ - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount; + xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; #define WRITEW_REVERSE(addr, dat) \ xga->vram[((addr + 1)) & (xga->vram_mask - 1)] = dat & 0xff; \ xga->vram[((addr)) & (xga->vram_mask - 1)] = dat >> 8; \ - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount; + xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; #define ROP(mix, d, s) \ { \ @@ -908,12 +900,12 @@ xga_accel_write_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, ui if (pixel & 1) { if (!skip) { xga->vram[((addr)) & (xga->vram_mask)] |= mask; - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount; + xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; } } else { if (!skip) { xga->vram[((addr)) & (xga->vram_mask)] &= ~mask; - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount; + xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; } } mem_writeb_phys(addr, byte); @@ -2198,7 +2190,7 @@ xga_write(uint32_t addr, uint8_t val, void *p) cycles -= video_timing_write_b; - xga->changedvram[(addr & xga->vram_mask) >> 12] = changeframecount; + xga->changedvram[(addr & xga->vram_mask) >> 12] = svga->monitor->mon_changeframecount; xga->vram[addr & xga->vram_mask] = val; } @@ -2245,7 +2237,7 @@ xga_write_linear(uint32_t addr, uint8_t val, void *p) cycles -= video_timing_write_b; - xga->changedvram[(addr & xga->vram_mask) >> 12] = changeframecount; + xga->changedvram[(addr & xga->vram_mask) >> 12] = svga->monitor->mon_changeframecount; xga->vram[addr & xga->vram_mask] = val; } @@ -2559,7 +2551,7 @@ xga_poll(xga_t *xga, svga_t *svga) xga->oddeven ^= 1; - changeframecount = xga->interlace ? 3 : 2; + svga->monitor->mon_changeframecount = xga->interlace ? 3 : 2; if (xga->interlace && xga->oddeven) xga->ma = xga->maback = xga->ma_latch + (xga->rowoffset << 1); @@ -2588,9 +2580,13 @@ xga_mca_read(int port, void *priv) { svga_t *svga = (svga_t *) priv; xga_t *xga = &svga->xga; + uint8_t ret = xga->pos_regs[port & 7]; - // pclog("[%04X:%08X]: POS Read Port = %x, val = %02x\n", CS, cpu_state.pc, port & 7, xga->pos_regs[port & 7]); - return (xga->pos_regs[port & 7]); + if (((port & 7) == 3) && !(ret & 1)) /*Always enable the mapping.*/ + ret |= 1; + + //pclog("[%04X:%08X]: POS Read Port = %x, val = %02x\n", CS, cpu_state.pc, port & 7, xga->pos_regs[port & 7]); + return (ret); } static void @@ -2607,11 +2603,13 @@ xga_mca_write(int port, uint8_t val, void *priv) mem_mapping_disable(&xga->bios_rom.mapping); mem_mapping_disable(&xga->memio_mapping); xga->on = 0; - vga_on = 1; + vga_on = !xga->on; + xga->linear_endian_reverse = 0; + xga->a5_test = 0; /* Save the MCA register value. */ xga->pos_regs[port & 7] = val; - if (!(xga->pos_regs[4] & 1)) /*MCA 4MB addressing on systems with more than 16MB of memory*/ + if (!(xga->pos_regs[4] & 1) && (mem_size >= 16384)) /*MCA 4MB addressing on systems with more than 16MB of memory*/ xga->pos_regs[4] |= 1; if (xga->pos_regs[2] & 1) { @@ -2622,13 +2620,12 @@ xga_mca_write(int port, uint8_t val, void *priv) io_sethandler(0x2100 + (xga->instance << 4), 0x0010, xga_ext_inb, NULL, NULL, xga_ext_outb, NULL, NULL, svga); - if (xga->pos_regs[3] & 1) { + if (xga->pos_regs[3] & 1) mem_mapping_set_addr(&xga->bios_rom.mapping, xga->rom_addr, 0x2000); - } else { + else mem_mapping_set_addr(&xga->memio_mapping, xga->rom_addr + 0x1c00 + (xga->instance * 0x80), 0x80); - } } - // pclog("[%04X:%08X]: POS Write Port = %x, val = %02x, linear base = %08x, instance = %d, rom addr = %05x\n", CS, cpu_state.pc, port & 7, val, xga->linear_base, xga->instance, xga->rom_addr); + //pclog("[%04X:%08X]: POS Write Port = %x, val = %02x, linear base = %08x, instance = %d, rom addr = %05x\n", CS, cpu_state.pc, port & 7, val, xga->linear_base, xga->instance, xga->rom_addr); } static uint8_t @@ -2644,10 +2641,27 @@ static void xga_mca_reset(void *p) { svga_t *svga = (svga_t *) p; + xga_t *xga = &svga->xga; + xga->on = 0; + vga_on = !xga->on; xga_mca_write(0x102, 0, svga); } +static void +xga_reset(void *p) +{ + svga_t *svga = (svga_t *) p; + xga_t *xga = &svga->xga; + + mem_mapping_disable(&xga->bios_rom.mapping); + mem_mapping_disable(&xga->memio_mapping); + xga->on = 0; + vga_on = !xga->on; + xga->linear_endian_reverse = 0; + xga->a5_test = 0; +} + static uint8_t xga_pos_in(uint16_t addr, void *priv) { @@ -2660,10 +2674,13 @@ static void * xga_init(const device_t *info) { + if (svga_get_pri() == NULL) + return NULL; + svga_t *svga = svga_get_pri(); xga_t *xga = &svga->xga; FILE *f; - uint32_t initial_bios_addr = device_get_config_hex20("init_bios_addr"); + uint32_t temp; uint8_t *rom = NULL; xga->type = device_get_config_int("type"); @@ -2682,11 +2699,13 @@ static void f = rom_fopen(xga->type ? XGA2_BIOS_PATH : XGA_BIOS_PATH, "rb"); (void) fseek(f, 0L, SEEK_END); + temp = ftell(f); (void) fseek(f, 0L, SEEK_SET); rom = malloc(xga->bios_rom.sz); memset(rom, 0xff, xga->bios_rom.sz); - (void) !fread(rom, xga->bios_rom.sz, 1, f); + (void) fread(rom, xga->bios_rom.sz, 1, f); + temp -= xga->bios_rom.sz; (void) fclose(f); xga->bios_rom.rom = rom; @@ -2697,11 +2716,13 @@ static void xga->base_addr_1mb = 0; if (info->flags & DEVICE_MCA) { + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_xga_mca); xga->linear_base = 0; xga->instance = 0; xga->rom_addr = 0; - rom_init(&xga->bios_rom, xga->type ? XGA2_BIOS_PATH : XGA_BIOS_PATH, initial_bios_addr, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&xga->bios_rom, xga->type ? XGA2_BIOS_PATH : XGA_BIOS_PATH, 0xc0000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL); } else { + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_xga_isa); xga->pos_regs[2] = 1 | 0x0c | 0xf0; xga->instance = (xga->pos_regs[2] & 0x0e) >> 1; xga->pos_regs[4] = 1 | 2; @@ -2768,30 +2789,11 @@ xga_force_redraw(void *p) { svga_t *svga = (svga_t *) p; - svga->fullchange = changeframecount; + svga->fullchange = svga->monitor->mon_changeframecount; } static const device_config_t xga_configuration[] = { // clang-format off - { - .name = "init_bios_addr", - .description = "Initial MCA BIOS Address (before POS configuration)", - .type = CONFIG_HEX20, - .default_string = "", - .default_int = 0xc0000, - .file_filter = "", - .spinner = { 0 }, - .selection = { - { .description = "C000H", .value = 0xc0000 }, - { .description = "C800H", .value = 0xc8000 }, - { .description = "CC00H", .value = 0xcc000 }, - { .description = "D000H", .value = 0xd0000 }, - { .description = "D400H", .value = 0xd4000 }, - { .description = "D800H", .value = 0xd8000 }, - { .description = "DC00H", .value = 0xdc000 }, - { .description = "" } - }, - }, { .name = "type", .description = "XGA type", @@ -2813,7 +2815,7 @@ static const device_config_t xga_configuration[] = { } }, { .name = "", .description = "", .type = CONFIG_END } - // clang-format on +// clang-format on }; const device_t xga_device = { @@ -2823,7 +2825,7 @@ const device_t xga_device = { .local = 0, .init = xga_init, .close = xga_close, - .reset = NULL, + .reset = xga_reset, { .available = xga_available }, .speed_changed = xga_speed_changed, .force_redraw = xga_force_redraw, @@ -2837,7 +2839,7 @@ const device_t xga_isa_device = { .local = 0, .init = xga_init, .close = xga_close, - .reset = NULL, + .reset = xga_reset, { .available = xga_available }, .speed_changed = xga_speed_changed, .force_redraw = xga_force_redraw, diff --git a/src/win/languages/cs-CZ.rc b/src/win/languages/cs-CZ.rc index 262f059b0..238d31b07 100644 --- a/src/win/languages/cs-CZ.rc +++ b/src/win/languages/cs-CZ.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Kontrola BPB" #define STR_CDROM_DRIVES "Mechaniky CD-ROM:" #define STR_CD_SPEED "Rychlost:" -#define STR_EARLY "Časná mechanika" #define STR_MO_DRIVES "Magnetooptické mechaniky:" #define STR_ZIP_DRIVES "Mechaniky ZIP:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Resetovat" IDS_2160 "Vypnout skrze rozhraní ACPI" IDS_2161 "Nastavení" - IDS_2162 "Časná mechanika" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/de-DE.rc b/src/win/languages/de-DE.rc index b2e25e332..0af4a28b5 100644 --- a/src/win/languages/de-DE.rc +++ b/src/win/languages/de-DE.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "BPB überprüfen" #define STR_CDROM_DRIVES "CD-ROM-Laufwerke:" #define STR_CD_SPEED "Geschwindigkeit:" -#define STR_EARLY "Früheres Laufwerk" #define STR_MO_DRIVES "MO-Laufwerke:" #define STR_ZIP_DRIVES "ZIP-Laufwerke:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Hard-Reset" IDS_2160 "ACPI-basiertes Herunterfahren" IDS_2161 "Optionen" - IDS_2162 "Früheres Laufwerk" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/dialogs.rc b/src/win/languages/dialogs.rc index ef3b8ac62..3286ee2be 100644 --- a/src/win/languages/dialogs.rc +++ b/src/win/languages/dialogs.rc @@ -402,23 +402,67 @@ FONT FONT_SIZE, FONT_NAME BEGIN LTEXT STR_NET_TYPE, IDT_NET_TYPE, CFG_HMARGIN, CFG_VMARGIN, CFG_PANE_LTEXT_PRI_WIDTH, CFG_PANE_LTEXT_HEIGHT - COMBOBOX IDC_COMBO_NET1_TYPE, - CFG_COMBO_BOX_LEFT, 7, CFG_COMBO_NOBTN_WIDTH, CFG_COMBO_HEIGHT, - CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT STR_PCAP, IDT_PCAP, - CFG_HMARGIN, 28, CFG_PANE_LTEXT_PRI_WIDTH, CFG_PANE_LTEXT_HEIGHT - COMBOBOX IDC_COMBO_PCAP1, - CFG_COMBO_BOX_LEFT, 26, CFG_COMBO_NOBTN_WIDTH, CFG_COMBO_HEIGHT, + CFG_HMARGIN + CFG_PANE_LTEXT_PRI_WIDTH - 10, CFG_VMARGIN, CFG_PANE_LTEXT_PRI_WIDTH, CFG_PANE_LTEXT_HEIGHT + LTEXT STR_NET, IDT_NET, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 2) + 20, CFG_VMARGIN, CFG_PANE_LTEXT_PRI_WIDTH, CFG_PANE_LTEXT_HEIGHT + + COMBOBOX IDC_COMBO_NET1_TYPE, + CFG_HMARGIN, 28, 32, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + COMBOBOX IDC_COMBO_PCAP1, + CFG_HMARGIN + CFG_PANE_LTEXT_PRI_WIDTH - 10, 28, 110, CFG_COMBO_HEIGHT, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT STR_NET, IDT_NET, - CFG_HMARGIN, 47, CFG_PANE_LTEXT_PRI_WIDTH, CFG_PANE_LTEXT_HEIGHT COMBOBOX IDC_COMBO_NET1, - CFG_COMBO_BOX_LEFT, 45, CFG_COMBO_BTN_WIDTH, CFG_COMBO_HEIGHT, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 2) + 20, 28, 110, CFG_COMBO_HEIGHT, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON STR_CONFIGURE, IDC_CONFIGURE_NET1, - CFG_COMBO_BTN_LEFT, 44, CFG_BTN_WIDTH, CFG_BTN_HEIGHT + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 3) + 50, 27, CFG_BTN_WIDTH, CFG_BTN_HEIGHT + + COMBOBOX IDC_COMBO_NET2_TYPE, + CFG_HMARGIN, 49, 32, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + COMBOBOX IDC_COMBO_PCAP2, + CFG_HMARGIN + CFG_PANE_LTEXT_PRI_WIDTH - 10, 49, 110, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + COMBOBOX IDC_COMBO_NET2, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 2) + 20, 49, 110, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON STR_CONFIGURE, IDC_CONFIGURE_NET2, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 3) + 50, 48, CFG_BTN_WIDTH, CFG_BTN_HEIGHT + + COMBOBOX IDC_COMBO_NET3_TYPE, + CFG_HMARGIN, 70, 32, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + COMBOBOX IDC_COMBO_PCAP3, + CFG_HMARGIN + CFG_PANE_LTEXT_PRI_WIDTH - 10, 70, 110, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + COMBOBOX IDC_COMBO_NET3, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 2) + 20, 70, 110, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON STR_CONFIGURE, IDC_CONFIGURE_NET3, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 3) + 50, 69, CFG_BTN_WIDTH, CFG_BTN_HEIGHT + + COMBOBOX IDC_COMBO_NET4_TYPE, + CFG_HMARGIN, 91, 32, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + COMBOBOX IDC_COMBO_PCAP4, + CFG_HMARGIN + CFG_PANE_LTEXT_PRI_WIDTH - 10, 91, 110, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + COMBOBOX IDC_COMBO_NET4, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 2) + 20, 91, 110, CFG_COMBO_HEIGHT, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON STR_CONFIGURE, IDC_CONFIGURE_NET4, + CFG_HMARGIN + (CFG_PANE_LTEXT_PRI_WIDTH * 3) + 50, 90, CFG_BTN_WIDTH, CFG_BTN_HEIGHT + END DLG_CFG_PORTS DIALOG DISCARDABLE CFG_PANE_LEFT, CFG_PANE_TOP, CFG_PANE_WIDTH, CFG_PANE_HEIGHT @@ -789,10 +833,13 @@ BEGIN COMBOBOX IDC_COMBO_CD_SPEED, 33, 205, 140, 12, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - - CONTROL STR_EARLY, IDC_CHECKEARLY, - "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - 186, 206, 84, CFG_CHECKBOX_HEIGHT +/* + LTEXT STR_TYPE, IDT_CD_TYPE, + CFG_HMARGIN, 233, 34, CFG_PANE_LTEXT_HEIGHT + COMBOBOX IDC_COMBO_CD_SPEED, + 33, 231, 140, 12, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP +*/ END DLG_CFG_OTHER_REMOVABLE_DEVICES DIALOG DISCARDABLE CFG_PANE_LEFT, CFG_PANE_TOP, CFG_PANE_WIDTH, CFG_PANE_HEIGHT diff --git a/src/win/languages/en-GB.rc b/src/win/languages/en-GB.rc index a0ed1487e..f8dab3bd7 100644 --- a/src/win/languages/en-GB.rc +++ b/src/win/languages/en-GB.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Check BPB" #define STR_CDROM_DRIVES "CD-ROM drives:" #define STR_CD_SPEED "Speed:" -#define STR_EARLY "Earlier drive" #define STR_MO_DRIVES "MO drives:" #define STR_ZIP_DRIVES "ZIP drives:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Hard reset" IDS_2160 "ACPI shutdown" IDS_2161 "Settings" - IDS_2162 "Earlier drive" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/en-US.rc b/src/win/languages/en-US.rc index 9464c6d6b..66c9d60e2 100644 --- a/src/win/languages/en-US.rc +++ b/src/win/languages/en-US.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Check BPB" #define STR_CDROM_DRIVES "CD-ROM drives:" #define STR_CD_SPEED "Speed:" -#define STR_EARLY "Earlier drive" #define STR_MO_DRIVES "MO drives:" #define STR_ZIP_DRIVES "ZIP drives:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Hard reset" IDS_2160 "ACPI shutdown" IDS_2161 "Settings" - IDS_2162 "Earlier drive" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/es-ES.rc b/src/win/languages/es-ES.rc index 5f138c3c2..8ff91d891 100644 --- a/src/win/languages/es-ES.rc +++ b/src/win/languages/es-ES.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Chequear BPB" #define STR_CDROM_DRIVES "Unidades de CD-ROM:" #define STR_CD_SPEED "Velocidad:" -#define STR_EARLY "Unidad anterior" #define STR_MO_DRIVES "Unidades MO:" #define STR_ZIP_DRIVES "Unidades ZIP:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Hard reset" IDS_2160 "ACPI shutdown" IDS_2161 "Settings" - IDS_2162 "Unidad anterior" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/fi-FI.rc b/src/win/languages/fi-FI.rc index c32f94b41..31467afbf 100644 --- a/src/win/languages/fi-FI.rc +++ b/src/win/languages/fi-FI.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Tarkista BPB" #define STR_CDROM_DRIVES "CD-ROM-asemat:" #define STR_CD_SPEED "Nopeus:" -#define STR_EARLY "Aiemmat asemat" #define STR_MO_DRIVES "Magneettisoptiset asemat (MO):" #define STR_ZIP_DRIVES "ZIP-asemat:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Kylmä uudelleenkäynnistys" IDS_2160 "ACPI-sammutus" IDS_2161 "Asetukset" - IDS_2162 "Aiemmat asemat" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/fr-FR.rc b/src/win/languages/fr-FR.rc index bffedce44..73e36550d 100644 --- a/src/win/languages/fr-FR.rc +++ b/src/win/languages/fr-FR.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Vérifier BPB" #define STR_CDROM_DRIVES "Lecterus CD-ROM:" #define STR_CD_SPEED "Vitesse:" -#define STR_EARLY "Lecteur plus tôt" #define STR_MO_DRIVES "Lecteurs magnéto-optiques:" #define STR_ZIP_DRIVES "Lecteurs ZIP:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Hard reset" IDS_2160 "ACPI shutdown" IDS_2161 "Settings" - IDS_2162 "Lecteur plus tôt" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/hr-HR.rc b/src/win/languages/hr-HR.rc index b79defcbe..74e43ebb6 100644 --- a/src/win/languages/hr-HR.rc +++ b/src/win/languages/hr-HR.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Provjeraj BPB" #define STR_CDROM_DRIVES "CD-ROM pogoni:" #define STR_CD_SPEED "Brzina:" -#define STR_EARLY "Raniji pogon" #define STR_MO_DRIVES "MO pogoni:" #define STR_ZIP_DRIVES "ZIP pogoni:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Ponovno pokretanje" IDS_2160 "ACPI bazirano gašenje" IDS_2161 "Postavke" - IDS_2162 "Raniji pogon" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/hu-HU.rc b/src/win/languages/hu-HU.rc index 9486d8e61..bcebd91f0 100644 --- a/src/win/languages/hu-HU.rc +++ b/src/win/languages/hu-HU.rc @@ -373,7 +373,6 @@ END #define STR_CHECKBPB "BPB ellenőrzés" #define STR_CDROM_DRIVES "CD-ROM meghajtók:" #define STR_CD_SPEED "Seb.:" -#define STR_EARLY "Korábbi meghajtó" #define STR_MO_DRIVES "MO-meghajtók:" #define STR_ZIP_DRIVES "ZIP-meghajtók:" @@ -542,7 +541,7 @@ BEGIN IDS_2159 "Hard reset" IDS_2160 "ACPI shutdown" IDS_2161 "Settings" - IDS_2162 "Korábbi meghajtó" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/it-IT.rc b/src/win/languages/it-IT.rc index 02ca9bf9f..e81e07a6e 100644 --- a/src/win/languages/it-IT.rc +++ b/src/win/languages/it-IT.rc @@ -369,7 +369,6 @@ END #define STR_CHECKBPB "Verifica BPB" #define STR_CDROM_DRIVES "Unità CD-ROM:" #define STR_CD_SPEED "Veloc.:" -#define STR_EARLY "Unità anteriore" #define STR_MO_DRIVES "Unità magneto-ottiche:" #define STR_ZIP_DRIVES "Unità ZIP:" @@ -539,7 +538,7 @@ BEGIN IDS_2159 "Hard reset" IDS_2160 "ACPI shutdown" IDS_2161 "Settings" - IDS_2162 "Unità anteriore" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/ja-JP.rc b/src/win/languages/ja-JP.rc index 89cc42011..0b9efec12 100644 --- a/src/win/languages/ja-JP.rc +++ b/src/win/languages/ja-JP.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "BPBをチェック" #define STR_CDROM_DRIVES "CD-ROMドライブ:" #define STR_CD_SPEED "速度:" -#define STR_EARLY "アーリードライブ" #define STR_MO_DRIVES "光磁気ドライブ:" #define STR_ZIP_DRIVES "ZIPドライブ:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "ハードリセット" IDS_2160 "ACPIシャットダウン" IDS_2161 "設定" - IDS_2162 "アーリードライブ" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/ko-KR.rc b/src/win/languages/ko-KR.rc index cbe3e4752..1949eb6c9 100644 --- a/src/win/languages/ko-KR.rc +++ b/src/win/languages/ko-KR.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "BPB 확인" #define STR_CDROM_DRIVES "CD-ROM 드라이브:" #define STR_CD_SPEED "속도:" -#define STR_EARLY "이전 드라이브" #define STR_MO_DRIVES "광자기 드라이브:" #define STR_ZIP_DRIVES "ZIP 드라이브:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "재시작" IDS_2160 "ACPI 종료" IDS_2161 "설정" - IDS_2162 "이전 드라이브" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/pl-PL.rc b/src/win/languages/pl-PL.rc index 84fccb70d..98dc0c903 100644 --- a/src/win/languages/pl-PL.rc +++ b/src/win/languages/pl-PL.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Sprawdzaj BPB" #define STR_CDROM_DRIVES "Napędy CD-ROM:" #define STR_CD_SPEED "Szybkość:" -#define STR_EARLY "Wcześniejszy napęd" #define STR_MO_DRIVES "Napędy MO:" #define STR_ZIP_DRIVES "Napędy ZIP:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Twardy reset" IDS_2160 "Wyłączenie ACPI" IDS_2161 "Ustawienia" - IDS_2162 "Wcześniejszy napęd" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/pt-BR.rc b/src/win/languages/pt-BR.rc index b01a214ff..723e25685 100644 --- a/src/win/languages/pt-BR.rc +++ b/src/win/languages/pt-BR.rc @@ -371,7 +371,6 @@ END #define STR_CHECKBPB "Verificar BPB" #define STR_CDROM_DRIVES "Unidades de CD-ROM:" #define STR_CD_SPEED "Veloc.:" -#define STR_EARLY "Unidade anterior" #define STR_MO_DRIVES "Unidades magneto-ópticas:" #define STR_ZIP_DRIVES "Unidades ZIP:" @@ -541,7 +540,7 @@ BEGIN IDS_2159 "Reinicialização completa" IDS_2160 "Desligamento por ACPI" IDS_2161 "Configurações" - IDS_2162 "Unidade anterior" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/pt-PT.rc b/src/win/languages/pt-PT.rc index 6390453dd..b6a66a325 100644 --- a/src/win/languages/pt-PT.rc +++ b/src/win/languages/pt-PT.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Verificar BPB" #define STR_CDROM_DRIVES "Unidades CD-ROM:" #define STR_CD_SPEED "Velocidade:" -#define STR_EARLY "Unidade anterior" #define STR_MO_DRIVES "Unidades magneto-ópticas:" #define STR_ZIP_DRIVES "Unidades ZIP:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Reinicialização completa" IDS_2160 "Encerramento ACPI" IDS_2161 "Definições" - IDS_2162 "Unidade anterior" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/ru-RU.rc b/src/win/languages/ru-RU.rc index f49247894..552f8a0dc 100644 --- a/src/win/languages/ru-RU.rc +++ b/src/win/languages/ru-RU.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Проверять BPB" #define STR_CDROM_DRIVES "Дисководы CD-ROM:" #define STR_CD_SPEED "Скорость:" -#define STR_EARLY "Предыдущий дисковод" #define STR_MO_DRIVES "Магнитооптические дисководы:" #define STR_ZIP_DRIVES "ZIP дисководы:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Холодная перезагрузка" IDS_2160 "Сигнал завершения ACPI" IDS_2161 "Настройки машины" - IDS_2162 "Предыдущий дисковод" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/sl-SI.rc b/src/win/languages/sl-SI.rc index beeb9183b..ec080d7cb 100644 --- a/src/win/languages/sl-SI.rc +++ b/src/win/languages/sl-SI.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Preverjaj BPB" #define STR_CDROM_DRIVES "Pogoni CD-ROM:" #define STR_CD_SPEED "Hitrost:" -#define STR_EARLY "Zgodnejši pogon" #define STR_MO_DRIVES "Magnetno-optični pogoni:" #define STR_ZIP_DRIVES "Pogoni ZIP:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Ponovni zagon" IDS_2160 "Zaustavitev ACPI" IDS_2161 "Nastavitve" - IDS_2162 "Zgodnejši pogon" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/tr-TR.rc b/src/win/languages/tr-TR.rc index 04e00eb0d..cd6132ee0 100644 --- a/src/win/languages/tr-TR.rc +++ b/src/win/languages/tr-TR.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "BPB'yi denetle" #define STR_CDROM_DRIVES "CD-ROM sürücüleri:" #define STR_CD_SPEED "Hız:" -#define STR_EARLY "Daha erken sürüş" #define STR_MO_DRIVES "MO sürücüleri:" #define STR_ZIP_DRIVES "ZIP sürücüleri:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Makineyi yeniden başlat" IDS_2160 "ACPI kapatma" IDS_2161 "Ayarlar" - IDS_2162 "Daha erken sürüş" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/uk-UA.rc b/src/win/languages/uk-UA.rc index fc3b29c84..adc04e808 100644 --- a/src/win/languages/uk-UA.rc +++ b/src/win/languages/uk-UA.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "Перевіряти BPB" #define STR_CDROM_DRIVES "Дисководи CD-ROM:" #define STR_CD_SPEED "Швидкість:" -#define STR_EARLY "Більш ранній дисковод" #define STR_MO_DRIVES "Магнітооптичні дисководи:" #define STR_ZIP_DRIVES "ZIP дисководи:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "Холодне перезавантаження" IDS_2160 "Сигнал завершення ACPI" IDS_2161 "Налаштування машини" - IDS_2162 "Більш ранній дисковод" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/zh-CN.rc b/src/win/languages/zh-CN.rc index 40ed20210..cd47d64df 100644 --- a/src/win/languages/zh-CN.rc +++ b/src/win/languages/zh-CN.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "检查 BPB" #define STR_CDROM_DRIVES "光盘驱动器:" #define STR_CD_SPEED "速度:" -#define STR_EARLY "早先的驱动器" #define STR_MO_DRIVES "磁光盘驱动器:" #define STR_ZIP_DRIVES "ZIP 驱动器:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "硬重置" IDS_2160 "ACPI 关机" IDS_2161 "设置" - IDS_2162 "早先的驱动器" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/languages/zh-TW.rc b/src/win/languages/zh-TW.rc index d6922164b..8ed160f21 100644 --- a/src/win/languages/zh-TW.rc +++ b/src/win/languages/zh-TW.rc @@ -368,7 +368,6 @@ END #define STR_CHECKBPB "檢查 BPB" #define STR_CDROM_DRIVES "光碟機:" #define STR_CD_SPEED "速度:" -#define STR_EARLY "早先的光碟機" #define STR_MO_DRIVES "磁光碟機:" #define STR_ZIP_DRIVES "ZIP 磁碟機:" @@ -538,7 +537,7 @@ BEGIN IDS_2159 "硬重設" IDS_2160 "ACPI 關機" IDS_2161 "設定" - IDS_2162 "早先的光碟機" + IDS_2162 "Type" IDS_2163 "No Dynarec" IDS_2164 "Old Dynarec" IDS_2165 "New Dynarec" diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 104ae0078..333888a65 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -2037,16 +2037,12 @@ network_recalc_combos(HWND hdlg) { ignore_change = 1; -#if 0 for (uint8_t i = 0; i < NET_CARD_MAX; i++) { -#endif - settings_enable_window(hdlg, IDC_COMBO_PCAP1, temp_net_type[0] == NET_TYPE_PCAP); - settings_enable_window(hdlg, IDC_COMBO_NET1, - (temp_net_type[0] == NET_TYPE_SLIRP) || ((temp_net_type[0] == NET_TYPE_PCAP) && (network_dev_to_id(temp_pcap_dev[0]) > 0))); - settings_enable_window(hdlg, IDC_CONFIGURE_NET1, network_card_has_config(temp_net_card[0]) && ((temp_net_type[0] == NET_TYPE_SLIRP) || ((temp_net_type[0] == NET_TYPE_PCAP) && (network_dev_to_id(temp_pcap_dev[0]) > 0)))); -#if 0 + settings_enable_window(hdlg, IDC_COMBO_PCAP1 + i, temp_net_type[i] == NET_TYPE_PCAP); + settings_enable_window(hdlg, IDC_COMBO_NET1 + i, + (temp_net_type[i] == NET_TYPE_SLIRP) || ((temp_net_type[i] == NET_TYPE_PCAP) && (network_dev_to_id(temp_pcap_dev[i]) > 0))); + settings_enable_window(hdlg, IDC_CONFIGURE_NET1 + i, network_card_has_config(temp_net_card[i]) && ((temp_net_type[i] == NET_TYPE_SLIRP) || ((temp_net_type[i] == NET_TYPE_PCAP) && (network_dev_to_id(temp_pcap_dev[i]) > 0)))); } -#endif ignore_change = 0; } @@ -2065,73 +2061,80 @@ win_settings_network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); -#if 0 for (uint8_t i = 0; i < NET_CARD_MAX; i++) { -#endif - settings_add_string(hdlg, IDC_COMBO_NET1_TYPE, (LPARAM) L"None"); - settings_add_string(hdlg, IDC_COMBO_NET1_TYPE, (LPARAM) L"SLiRP"); - settings_add_string(hdlg, IDC_COMBO_NET1_TYPE, (LPARAM) L"PCap"); - settings_set_cur_sel(hdlg, IDC_COMBO_NET1_TYPE, temp_net_type[0]); - settings_enable_window(hdlg, IDC_COMBO_PCAP1, temp_net_type[0] == NET_TYPE_PCAP); + settings_add_string(hdlg, IDC_COMBO_NET1_TYPE + i, (LPARAM) L"None"); + settings_add_string(hdlg, IDC_COMBO_NET1_TYPE + i, (LPARAM) L"SLiRP"); + settings_add_string(hdlg, IDC_COMBO_NET1_TYPE + i, (LPARAM) L"PCap"); + settings_set_cur_sel(hdlg, IDC_COMBO_NET1_TYPE + i, temp_net_type[i]); + settings_enable_window(hdlg, IDC_COMBO_PCAP1 + i, temp_net_type[i] == NET_TYPE_PCAP); - for (c = 0; c < network_ndev; c++) { - mbstowcs(lptsTemp, network_devs[c].description, strlen(network_devs[c].description) + 1); - settings_add_string(hdlg, IDC_COMBO_PCAP1, (LPARAM) lptsTemp); - } - settings_set_cur_sel(hdlg, IDC_COMBO_PCAP1, network_dev_to_id(temp_pcap_dev[0])); + for (c = 0; c < network_ndev; c++) { + mbstowcs(lptsTemp, network_devs[c].description, strlen(network_devs[c].description) + 1); + settings_add_string(hdlg, IDC_COMBO_PCAP1 + i, (LPARAM) lptsTemp); + } + settings_set_cur_sel(hdlg, IDC_COMBO_PCAP1 + i, network_dev_to_id(temp_pcap_dev[i])); - /* NIC config */ - c = d = 0; - settings_reset_content(hdlg, IDC_COMBO_NET1); - while (1) { - generate_device_name(network_card_getdevice(c), network_card_get_internal_name(c), 1); + /* NIC config */ + c = d = 0; + settings_reset_content(hdlg, IDC_COMBO_NET1 + i); + while (1) { + generate_device_name(network_card_getdevice(c), network_card_get_internal_name(c), 1); - if (device_name[0] == L'\0') - break; + if (device_name[0] == L'\0') + break; - if (network_card_available(c) && device_is_valid(network_card_getdevice(c), temp_machine)) { - if (c == 0) - settings_add_string(hdlg, IDC_COMBO_NET1, win_get_string(IDS_2104)); - else - settings_add_string(hdlg, IDC_COMBO_NET1, (LPARAM) device_name); - settings_list_to_device[0][d] = c; - if ((c == 0) || (c == temp_net_card[0])) - settings_set_cur_sel(hdlg, IDC_COMBO_NET1, d); - d++; + if (network_card_available(c) && device_is_valid(network_card_getdevice(c), temp_machine)) { + if (c == 0) + settings_add_string(hdlg, IDC_COMBO_NET1 + i, win_get_string(IDS_2104)); + else + settings_add_string(hdlg, IDC_COMBO_NET1 + i, (LPARAM) device_name); + settings_list_to_device[0][d] = c; + if ((c == 0) || (c == temp_net_card[i])) + settings_set_cur_sel(hdlg, IDC_COMBO_NET1 + i, d); + d++; + } + + c++; } - c++; + settings_enable_window(hdlg, IDC_COMBO_NET1 + i, d); + network_recalc_combos(hdlg); } - - settings_enable_window(hdlg, IDC_COMBO_NET1, d); - network_recalc_combos(hdlg); free(lptsTemp); -#if 0 - } -#endif return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_COMBO_NET1_TYPE: -#if 0 - case IDC_COMBO_NET2_TYPE: - case IDC_COMBO_NET3_TYPE: - case IDC_COMBO_NET4_TYPE: -#endif if (ignore_change) return FALSE; temp_net_type[0] = settings_get_cur_sel(hdlg, IDC_COMBO_NET1_TYPE); network_recalc_combos(hdlg); break; + case IDC_COMBO_NET2_TYPE: + if (ignore_change) + return FALSE; + + temp_net_type[1] = settings_get_cur_sel(hdlg, IDC_COMBO_NET2_TYPE); + network_recalc_combos(hdlg); + break; + case IDC_COMBO_NET3_TYPE: + if (ignore_change) + return FALSE; + + temp_net_type[2] = settings_get_cur_sel(hdlg, IDC_COMBO_NET3_TYPE); + network_recalc_combos(hdlg); + break; + case IDC_COMBO_NET4_TYPE: + if (ignore_change) + return FALSE; + + temp_net_type[3] = settings_get_cur_sel(hdlg, IDC_COMBO_NET4_TYPE); + network_recalc_combos(hdlg); + break; case IDC_COMBO_PCAP1: -#if 0 - case IDC_COMBO_PCAP2: - case IDC_COMBO_PCAP3: - case IDC_COMBO_PCAP4: -#endif if (ignore_change) return FALSE; @@ -2139,46 +2142,98 @@ win_settings_network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) strcpy(temp_pcap_dev[0], network_devs[settings_get_cur_sel(hdlg, IDC_COMBO_PCAP1)].device); network_recalc_combos(hdlg); break; + case IDC_COMBO_PCAP2: + if (ignore_change) + return FALSE; + + memset(temp_pcap_dev[1], '\0', sizeof(temp_pcap_dev[1])); + strcpy(temp_pcap_dev[1], network_devs[settings_get_cur_sel(hdlg, IDC_COMBO_PCAP2)].device); + network_recalc_combos(hdlg); + break; + case IDC_COMBO_PCAP3: + if (ignore_change) + return FALSE; + + memset(temp_pcap_dev[2], '\0', sizeof(temp_pcap_dev[2])); + strcpy(temp_pcap_dev[2], network_devs[settings_get_cur_sel(hdlg, IDC_COMBO_PCAP3)].device); + network_recalc_combos(hdlg); + break; + case IDC_COMBO_PCAP4: + if (ignore_change) + return FALSE; + + memset(temp_pcap_dev[3], '\0', sizeof(temp_pcap_dev[3])); + strcpy(temp_pcap_dev[3], network_devs[settings_get_cur_sel(hdlg, IDC_COMBO_PCAP4)].device); + network_recalc_combos(hdlg); + break; case IDC_COMBO_NET1: -#if 0 - case IDC_COMBO_NET2: - case IDC_COMBO_NET3: - case IDC_COMBO_NET4: -#endif if (ignore_change) return FALSE; temp_net_card[0] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET1)]; network_recalc_combos(hdlg); break; + case IDC_COMBO_NET2: + if (ignore_change) + return FALSE; + + temp_net_card[1] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET2)]; + network_recalc_combos(hdlg); + break; + case IDC_COMBO_NET3: + if (ignore_change) + return FALSE; + + temp_net_card[2] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET3)]; + network_recalc_combos(hdlg); + break; + case IDC_COMBO_NET4: + if (ignore_change) + return FALSE; + + temp_net_card[3] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET4)]; + network_recalc_combos(hdlg); + break; case IDC_CONFIGURE_NET1: -#if 0 - case IDC_CONFIGURE_NET2: - case IDC_CONFIGURE_NET3: - case IDC_CONFIGURE_NET4: -#endif if (ignore_change) return FALSE; temp_net_card[0] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET1)]; temp_deviceconfig |= deviceconfig_open(hdlg, (void *) network_card_getdevice(temp_net_card[0])); break; + case IDC_CONFIGURE_NET2: + if (ignore_change) + return FALSE; + + temp_net_card[1] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET2)]; + temp_deviceconfig |= deviceconfig_open(hdlg, (void *) network_card_getdevice(temp_net_card[1])); + break; + case IDC_CONFIGURE_NET3: + if (ignore_change) + return FALSE; + + temp_net_card[2] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET3)]; + temp_deviceconfig |= deviceconfig_open(hdlg, (void *) network_card_getdevice(temp_net_card[2])); + break; + case IDC_CONFIGURE_NET4: + if (ignore_change) + return FALSE; + + temp_net_card[3] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET4)]; + temp_deviceconfig |= deviceconfig_open(hdlg, (void *) network_card_getdevice(temp_net_card[3])); + break; } return FALSE; case WM_SAVESETTINGS: -#if 0 for (uint8_t i = 0; i < NET_CARD_MAX; i++) { -#endif - temp_net_type[0] = settings_get_cur_sel(hdlg, IDC_COMBO_NET1_TYPE); - memset(temp_pcap_dev[0], '\0', sizeof(temp_pcap_dev[0])); - strcpy(temp_pcap_dev[0], network_devs[settings_get_cur_sel(hdlg, IDC_COMBO_PCAP1)].device); - temp_net_card[0] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET1)]; -#if 0 + temp_net_type[i] = settings_get_cur_sel(hdlg, IDC_COMBO_NET1_TYPE + i); + memset(temp_pcap_dev[i], '\0', sizeof(temp_pcap_dev[i])); + strcpy(temp_pcap_dev[i], network_devs[settings_get_cur_sel(hdlg, IDC_COMBO_PCAP1 + i)].device); + temp_net_card[i] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_NET1 + i)]; } -#endif default: return FALSE; } @@ -3959,6 +4014,7 @@ win_settings_cdrom_drives_recalc_list(HWND hdlg) if (ListView_SetItem(hwndList, &lvI) == -1) return FALSE; +/* lvI.iSubItem = 2; lvI.pszText = plat_get_string(temp_cdrom[i].early ? IDS_2060 : IDS_2061); lvI.iItem = i; @@ -3966,6 +4022,7 @@ win_settings_cdrom_drives_recalc_list(HWND hdlg) if (ListView_SetItem(hwndList, &lvI) == -1) return FALSE; +*/ } return TRUE; @@ -4206,7 +4263,7 @@ win_settings_cdrom_drives_init_columns(HWND hdlg) if (ListView_InsertColumn(hwndList, 1, &lvc) == -1) return FALSE; - /* Earlier drive */ + /* Type */ lvc.iSubItem = 2; lvc.pszText = plat_get_string(IDS_2162); @@ -4434,6 +4491,7 @@ win_settings_cdrom_drives_update_item(HWND hdlg, int i) if (ListView_SetItem(hwndList, &lvI) == -1) return; +/* lvI.iSubItem = 2; lvI.pszText = plat_get_string(temp_cdrom[i].early ? IDS_2060 : IDS_2061); lvI.iItem = i; @@ -4441,6 +4499,7 @@ win_settings_cdrom_drives_update_item(HWND hdlg, int i) if (ListView_SetItem(hwndList, &lvI) == -1) return; +*/ } static void @@ -4592,11 +4651,12 @@ cdrom_recalc_location_controls(HWND hdlg, int assign_id) settings_show_window(hdlg, IDC_COMBO_CD_CHANNEL_IDE, FALSE); settings_show_window(hdlg, IDC_COMBO_CD_SPEED, bus != CDROM_BUS_DISABLED); settings_show_window(hdlg, IDT_CD_SPEED, bus != CDROM_BUS_DISABLED); +/* settings_show_window(hdlg, IDC_CHECKEARLY, bus != CDROM_BUS_DISABLED); - +*/ if (bus != CDROM_BUS_DISABLED) { settings_set_cur_sel(hdlg, IDC_COMBO_CD_SPEED, temp_cdrom[lv2_current_sel].speed - 1); - settings_set_check(hdlg, IDC_CHECKEARLY, temp_cdrom[lv2_current_sel].early); +// settings_set_check(hdlg, IDC_CHECKEARLY, temp_cdrom[lv2_current_sel].early); } switch (bus) { @@ -4987,10 +5047,12 @@ win_settings_floppy_and_cdrom_drives_proc(HWND hdlg, UINT message, WPARAM wParam win_settings_cdrom_drives_update_item(hdlg, lv2_current_sel); break; +/* case IDC_CHECKEARLY: temp_cdrom[lv2_current_sel].early = settings_get_check(hdlg, IDC_CHECKEARLY); win_settings_cdrom_drives_update_item(hdlg, lv2_current_sel); break; +*/ } ignore_change = 0;