diff --git a/.ci/build.sh b/.ci/build.sh index a791521f5..493f42789 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -298,6 +298,9 @@ EOF # Link against the system libslirp instead of compiling ours. cmake_flags_extra="$cmake_flags_extra -D SLIRP_EXTERNAL=ON" + + # Use OpenAL for Linux builds before FAudio builds are set up. + cmake_flags_extra="$cmake_flags_extra -D OPENAL=ON" fi # Clean workspace. diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 4bc84e91c..2e4753927 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -252,7 +252,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install dependencies - run: sudo apt update && sudo apt install gcc-11 g++-11 libfreetype-dev libsdl2-dev libpng-dev libopenal-dev libc6-dev librtmidi-dev qtbase5-dev qttools5-dev + run: sudo apt update && sudo apt install gcc-11 g++-11 libfreetype-dev libsdl2-dev libpng-dev libopenal-dev libc6-dev librtmidi-dev qtbase5-dev qttools5-dev libfaudio-dev - name: Configure CMake run: >- cmake -S . -B build @@ -316,7 +316,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install dependencies - run: brew install freetype sdl2 libpng openal-soft rtmidi qt@5 + run: brew install freetype sdl2 libpng openal-soft rtmidi qt@5 faudio - name: Configure CMake run: >- cmake -S . -B build diff --git a/AUTHORS b/AUTHORS index cef4e3773..bea36a263 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,5 @@ -All authors of this emulator are documented in at the top of each file in the source code. - -They own portions of the code, or in cases, the entirety of it. - -resid-fp and slirp folders have their own exceptions. \ No newline at end of file +All authors of this emulator are documented in at the top of each file in the source code. + +They own portions of the code, or in cases, the entirety of it. + +resid-fp and slirp folders have their own exceptions. diff --git a/CMakeLists.txt b/CMakeLists.txt index ff59cbc6b..0aa4c7b56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,8 +114,7 @@ set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) # ------ ----------- ---- option(RELEASE "Release build" OFF) option(DYNAREC "Dynamic recompiler" ON) -option(OPENAL "OpenAL" ON) -option(FAUDIO "FAudio" OFF) +option(OPENAL "OpenAL" OFF) option(FLUIDSYNTH "FluidSynth" ON) option(MUNT "MUNT" ON) option(DINPUT "DirectInput" OFF) diff --git a/src/86box.c b/src/86box.c index 9647a8a6e..444fe1e81 100644 --- a/src/86box.c +++ b/src/86box.c @@ -405,7 +405,7 @@ pc_init(int argc, char *argv[]) int ng = 0, lvmp = 0; uint32_t *uid, *shwnd; uint32_t lang_init = 0; - + /* Grab the executable's full path. */ plat_get_exe_name(exe_path, sizeof(exe_path)-1); p = plat_get_filename(exe_path); @@ -421,7 +421,7 @@ pc_init(int argc, char *argv[]) */ plat_getcwd(usr_path, sizeof(usr_path) - 1); plat_getcwd(rom_path, sizeof(rom_path) - 1); - + memset(path, 0x00, sizeof(path)); memset(path2, 0x00, sizeof(path)); @@ -727,7 +727,7 @@ usage: /* Load the configuration file. */ config_load(); - + /* Load the desired language */ if (lang_init) lang_id = lang_init; @@ -941,9 +941,7 @@ pc_reset_hard_close(void) scsi_disk_close(); -#ifdef USE_OPENAL closeal(); -#endif video_reset_close(); @@ -1071,7 +1069,7 @@ pc_reset_hard_init(void) void update_mouse_msg() { wchar_t wcpufamily[2048], wcpu[2048], wmachine[2048], *wcp; - + mbstowcs(wmachine, machine_getname(), strlen(machine_getname())+1); if (!cpu_override) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba0cffc7d..8f1465d1e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,7 +43,7 @@ if(VNC) add_compile_definitions(USE_VNC) add_library(vnc OBJECT vnc.c vnc_keymap.c) target_link_libraries(86Box vnc vncserver) - if (WIN32) + if(WIN32) target_link_libraries(86Box ws2_32) endif() endif() @@ -86,28 +86,6 @@ if(APPLE) target_link_libraries(86Box Freetype::Freetype) endif() -if(FAUDIO) - find_package(FAudio REQUIRED) - target_link_libraries(86Box FAudio::FAudio) -endif() - -if(OPENAL AND NOT FAUDIO) - if(VCPKG_TOOLCHAIN) - find_package(OpenAL CONFIG REQUIRED) - elseif(MINGW) - find_package(OpenAL MODULE REQUIRED) - else() - find_package(OpenAL REQUIRED) - endif() - - if(TARGET OpenAL::OpenAL) - target_link_libraries(86Box OpenAL::OpenAL) - else() - include_directories(${OPENAL_INCLUDE_DIR}) - target_link_libraries(86Box ${OPENAL_LIBRARY}) - endif() -endif() - find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIRS}) if(STATIC_BUILD AND TARGET SDL2::SDL2-static) @@ -223,7 +201,7 @@ add_subdirectory(scsi) add_subdirectory(sound) add_subdirectory(video) if (APPLE) - add_subdirectory(mac) + add_subdirectory(mac) endif() if (QT) diff --git a/src/acpi.c b/src/acpi.c index af02aa692..bdb3ff7bc 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -1806,8 +1806,8 @@ const device_t acpi_ali_device = "acpi_ali", DEVICE_PCI, VEN_ALI, - acpi_init, - acpi_close, + acpi_init, + acpi_close, acpi_reset, { NULL }, acpi_speed_changed, @@ -1821,8 +1821,8 @@ const device_t acpi_intel_device = "acpi_intel", DEVICE_PCI, VEN_INTEL, - acpi_init, - acpi_close, + acpi_init, + acpi_close, acpi_reset, { NULL }, acpi_speed_changed, @@ -1836,8 +1836,8 @@ const device_t acpi_sis_device = "acpi_sis", DEVICE_PCI, VEN_SIS, - acpi_init, - acpi_close, + acpi_init, + acpi_close, acpi_reset, { NULL }, acpi_speed_changed, @@ -1851,8 +1851,8 @@ const device_t acpi_via_device = "acpi_via", DEVICE_PCI, VEN_VIA, - acpi_init, - acpi_close, + acpi_init, + acpi_close, acpi_reset, { NULL }, acpi_speed_changed, @@ -1867,8 +1867,8 @@ const device_t acpi_via_596b_device = "acpi_via_596b", DEVICE_PCI, VEN_VIA_596B, - acpi_init, - acpi_close, + acpi_init, + acpi_close, acpi_reset, { NULL }, acpi_speed_changed, @@ -1883,8 +1883,8 @@ const device_t acpi_smc_device = "acpi_smc", DEVICE_PCI, VEN_SMC, - acpi_init, - acpi_close, + acpi_init, + acpi_close, acpi_reset, { NULL }, acpi_speed_changed, diff --git a/src/apm.c b/src/apm.c index 35c9a2a3c..def8db7bc 100644 --- a/src/apm.c +++ b/src/apm.c @@ -130,7 +130,7 @@ const device_t apm_device = 0, 0, apm_init, - apm_close, + apm_close, NULL, { NULL }, NULL, @@ -146,7 +146,7 @@ const device_t apm_pci_device = DEVICE_PCI, 0, apm_init, - apm_close, + apm_close, apm_reset, { NULL }, NULL, @@ -162,7 +162,7 @@ const device_t apm_pci_acpi_device = DEVICE_PCI, 1, apm_init, - apm_close, + apm_close, apm_reset, { NULL }, NULL, diff --git a/src/cdrom/CMakeLists.txt b/src/cdrom/CMakeLists.txt index eaa50bf2c..ecd0d934e 100644 --- a/src/cdrom/CMakeLists.txt +++ b/src/cdrom/CMakeLists.txt @@ -13,4 +13,4 @@ # Copyright 2020,2021 David Hrdlička. # -add_library(cdrom OBJECT cdrom.c cdrom_image_backend.c cdrom_image.c) \ No newline at end of file +add_library(cdrom OBJECT cdrom.c cdrom_image_backend.c cdrom_image.c) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index c400fa953..0229bfd40 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -363,10 +363,10 @@ uint8_t cdrom_audio_track_search(cdrom_t *dev, uint32_t pos, int type, uint8_t playbit) { int m = 0, s = 0, f = 0; - + if (dev->cd_status == CD_STATUS_DATA_ONLY) - return 0; - + return 0; + switch (type) { case 0x40: cdrom_log("Audio Track Search: MSF = %06x, type = %02x\n", pos, type); @@ -376,7 +376,7 @@ cdrom_audio_track_search(cdrom_t *dev, uint32_t pos, int type, uint8_t playbit) pos = MSFtoLBA(m, s, f) - 150; break; } - + /* Do this at this point, since it's at this point that we know the actual LBA position to start playing from. */ if (!(dev->ops->track_type(dev, pos) & CD_TRACK_AUDIO)) { @@ -391,7 +391,7 @@ cdrom_audio_track_search(cdrom_t *dev, uint32_t pos, int type, uint8_t playbit) return 1; } -uint8_t +uint8_t cdrom_toshiba_audio_play(cdrom_t *dev, uint32_t pos, int type) { int m = 0, s = 0, f = 0; @@ -412,15 +412,15 @@ cdrom_toshiba_audio_play(cdrom_t *dev, uint32_t pos, int type) pos = MSFtoLBA(m, s, f) - 150; break; } - + /* Do this at this point, since it's at this point that we know the actual LBA position to start playing from. */ if (!(dev->ops->track_type(dev, pos) & CD_TRACK_AUDIO)) { cdrom_log("CD-ROM %i: LBA %08X not on an audio track\n", dev->id, pos); cdrom_stop(dev); return 0; - } - + } + dev->cd_end = pos; dev->cd_buflen = 0; return 1; @@ -496,7 +496,7 @@ cdrom_get_current_subcodeq_playstatus(cdrom_t *dev, uint8_t *b) subchannel_t subc; dev->ops->get_subchannel(dev, dev->seek_pos, &subc); - + if (dev->cd_status == CD_STATUS_PLAYING) ret = 0x00; else if (dev->cd_status == CD_STATUS_PAUSED) { @@ -505,7 +505,7 @@ cdrom_get_current_subcodeq_playstatus(cdrom_t *dev, uint8_t *b) else ret = 0x01; } - else + else ret = 0x03; b[0] = subc.attr; @@ -518,7 +518,7 @@ cdrom_get_current_subcodeq_playstatus(cdrom_t *dev, uint8_t *b) b[7] = CD_BCD(subc.abs_s); b[8] = CD_BCD(subc.abs_f); cdrom_log("CD-ROM %i: Returned subcode-q at %02i:%02i.%02i, track=%02x\n", dev->id, b[3], b[4], b[5], b[1]); - + return ret; } diff --git a/src/cdrom/cdrom_image.c b/src/cdrom/cdrom_image.c index 91e4992b4..cd72fbd87 100644 --- a/src/cdrom/cdrom_image.c +++ b/src/cdrom/cdrom_image.c @@ -177,7 +177,7 @@ image_is_track_pre(cdrom_t *dev, uint32_t lba) } -static int +static int image_sector_size(struct cdrom *dev, uint32_t lba) { cd_img_t *img = (cd_img_t *)dev->image; @@ -280,7 +280,7 @@ cdrom_image_open(cdrom_t *dev, const char *fn) /* This guarantees that if ops is not NULL, then neither is the image pointer. */ - if (!img) + if (!img) return image_open_abort(dev); memset(img, 0, sizeof(cd_img_t)); diff --git a/src/cdrom/cdrom_image_backend.c b/src/cdrom/cdrom_image_backend.c index ae6e4bb39..04e5b7db4 100644 --- a/src/cdrom/cdrom_image_backend.c +++ b/src/cdrom/cdrom_image_backend.c @@ -438,7 +438,7 @@ cdi_read_sectors(cd_img_t *cdi, uint8_t *buffer, int raw, uint32_t sector, uint3 uint8_t *buf; uint32_t buf_len, i; - /* TODO: This fails to account for Mode 2. Shouldn't we have a function + /* TODO: This fails to account for Mode 2. Shouldn't we have a function to get sector size? */ sector_size = raw ? RAW_SECTOR_SIZE : COOKED_SECTOR_SIZE; buf_len = num * sector_size; diff --git a/src/chipset/CMakeLists.txt b/src/chipset/CMakeLists.txt index 5be4490af..517630ae4 100644 --- a/src/chipset/CMakeLists.txt +++ b/src/chipset/CMakeLists.txt @@ -23,4 +23,4 @@ add_library(chipset OBJECT 82c100.c acc2168.c cs8230.c ali1429.c ali1489.c ali15 if(OLIVETTI) target_sources(chipset PRIVATE olivetti_eva.c) -endif() \ No newline at end of file +endif() diff --git a/src/chipset/ali6117.c b/src/chipset/ali6117.c index 52975671a..04869fe50 100644 --- a/src/chipset/ali6117.c +++ b/src/chipset/ali6117.c @@ -361,7 +361,7 @@ ali6117_init(const device_t *info) ali6117_t *dev = (ali6117_t *) malloc(sizeof(ali6117_t)); memset(dev, 0, sizeof(ali6117_t)); - + dev->local = info->local; device_add(&ide_isa_device); @@ -382,8 +382,8 @@ const device_t ali1217_device = "ali1217", DEVICE_AT, 0x8, - ali6117_init, - ali6117_close, + ali6117_init, + ali6117_close, ali6117_reset, { NULL }, NULL, @@ -398,8 +398,8 @@ const device_t ali6117d_device = "ali6117d", DEVICE_AT, 0x2, - ali6117_init, - ali6117_close, + ali6117_init, + ali6117_close, ali6117_reset, { NULL }, NULL, diff --git a/src/chipset/cs8230.c b/src/chipset/cs8230.c index e9e060138..3718a93ca 100644 --- a/src/chipset/cs8230.c +++ b/src/chipset/cs8230.c @@ -100,7 +100,7 @@ cs8230_read(uint16_t port, void *p) case 0x05: case 0x06: /* 82C301 registers */ case 0x09: case 0x0a: case 0x0b: case 0x0c: /* 82C302 registers */ - case 0x0d: case 0x0e: case 0x0f: + case 0x0d: case 0x0e: case 0x0f: case 0x10: case 0x11: case 0x12: case 0x13: case 0x28: case 0x29: case 0x2a: ret = cs8230->regs[cs8230->idx]; diff --git a/src/chipset/gc100.c b/src/chipset/gc100.c index 079f775e5..6618534af 100644 --- a/src/chipset/gc100.c +++ b/src/chipset/gc100.c @@ -8,7 +8,7 @@ * * Implementation of the G2 GC100/GC100A chipset. * NOTE: As documentation is currently available only for the - * CG100 chipset, the GC100A chipset has been reverese-engineered. + * CG100 chipset, the GC100A chipset has been reverese-engineered. * Thus, its behavior may not be fully accurate. * * Authors: EngiNerd, @@ -71,7 +71,7 @@ static uint8_t get_fdd_switch_settings(void) { int i, fdd_count = 0; - + for (i = 0; i < FDD_NUM; i++) { if (fdd_get_flags(i)) fdd_count++; @@ -80,7 +80,7 @@ get_fdd_switch_settings(void) if (!fdd_count) return 0x00; else - return ((fdd_count - 1) << 6) | 0x01; + return ((fdd_count - 1) << 6) | 0x01; } @@ -92,7 +92,7 @@ get_videomode_switch_settings(void) else if (video_is_cga()) return 0x20; /* 0x10 would be 40x25 */ else - return 0x00; + return 0x00; } @@ -124,7 +124,7 @@ gc100_write(uint16_t port, uint8_t val, void *priv) else cpu_dynamic_switch(cpu); break; - + /* addr 0x5 * programmable dip-switches * bits 6-7: floppy drive number @@ -216,7 +216,7 @@ gc100_init(const device_t *info) dev->reg[0x5] = 0x0; dev->reg[0x6] = 0x0; dev->reg[0x7] = 0x0; - + if (info->local) { /* GC100A */ io_sethandler(0x0c2, 0x02, gc100_read, NULL, NULL, gc100_write, NULL, NULL, dev); @@ -226,7 +226,7 @@ gc100_init(const device_t *info) io_sethandler(0x022, 0x02, gc100_read, NULL, NULL, gc100_write, NULL, NULL, dev); io_sethandler(0x025, 0x01, gc100_read, NULL, NULL, gc100_write, NULL, NULL, dev); } - + return dev; } diff --git a/src/chipset/intel_4x0.c b/src/chipset/intel_4x0.c index 1f7a29ede..b0e043613 100644 --- a/src/chipset/intel_4x0.c +++ b/src/chipset/intel_4x0.c @@ -718,7 +718,7 @@ i4x0_write(int func, int addr, uint8_t val, void *priv) break; } switch (dev->type) { - case INTEL_430NX: case INTEL_430HX: + case INTEL_430NX: case INTEL_430HX: case INTEL_440FX: case INTEL_440LX: case INTEL_440EX: case INTEL_440BX: case INTEL_440GX: @@ -1640,8 +1640,8 @@ const device_t i420tx_device = "i420tx", DEVICE_PCI, INTEL_420TX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1656,8 +1656,8 @@ const device_t i420zx_device = "i420zx", DEVICE_PCI, INTEL_420ZX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1672,8 +1672,8 @@ const device_t i430lx_device = "i430lx", DEVICE_PCI, INTEL_430LX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1688,8 +1688,8 @@ const device_t i430nx_device = "i430nx", DEVICE_PCI, INTEL_430NX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1704,8 +1704,8 @@ const device_t i430fx_device = "i430fx", DEVICE_PCI, INTEL_430FX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1720,8 +1720,8 @@ const device_t i430fx_rev02_device = "i430fx_rev02", DEVICE_PCI, 0x0200 | INTEL_430FX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1736,8 +1736,8 @@ const device_t i430hx_device = "i430hx", DEVICE_PCI, INTEL_430HX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1752,8 +1752,8 @@ const device_t i430vx_device = "i430vx", DEVICE_PCI, INTEL_430VX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1768,8 +1768,8 @@ const device_t i430tx_device = "i430tx", DEVICE_PCI, INTEL_430TX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1784,8 +1784,8 @@ const device_t i440fx_device = "i440fx", DEVICE_PCI, INTEL_440FX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1799,8 +1799,8 @@ const device_t i440lx_device = "i440lx", DEVICE_PCI, INTEL_440LX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1814,8 +1814,8 @@ const device_t i440ex_device = "i440ex", DEVICE_PCI, INTEL_440EX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1829,8 +1829,8 @@ const device_t i440bx_device = "i440bx", DEVICE_PCI, 0x8000 | INTEL_440BX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1844,8 +1844,8 @@ const device_t i440bx_no_agp_device = "i440bx_no_agp", DEVICE_PCI, 0x8200 | INTEL_440BX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1859,8 +1859,8 @@ const device_t i440gx_device = "i440gx", DEVICE_PCI, 0x8000 | INTEL_440GX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, @@ -1874,8 +1874,8 @@ const device_t i440zx_device = "i440zx", DEVICE_PCI, 0x8000 | INTEL_440ZX, - i4x0_init, - i4x0_close, + i4x0_init, + i4x0_close, i4x0_reset, { NULL }, NULL, diff --git a/src/chipset/intel_i450kx.c b/src/chipset/intel_i450kx.c index 38b2afc1d..315947108 100644 --- a/src/chipset/intel_i450kx.c +++ b/src/chipset/intel_i450kx.c @@ -98,7 +98,7 @@ i450kx_smram_recalc(i450kx_t *dev, int bus) addr = ((uint32_t) regs[0xb8] << 16) | ((uint32_t) regs[0xb9] << 24); size = (((uint32_t) ((regs[0xbb] >> 4) & 0x0f)) << 16) + 0x00010000; - + if ((addr != 0x00000000) && !!(regs[0x57] & 0x08)) { if (bus) smram_enable_ex(dev->smram[bus], addr, addr, size, 0, !!(regs[0x57] & 8), 0, 1); diff --git a/src/chipset/intel_piix.c b/src/chipset/intel_piix.c index 97280b06c..0a6204b19 100644 --- a/src/chipset/intel_piix.c +++ b/src/chipset/intel_piix.c @@ -1281,7 +1281,7 @@ piix_reset_hard(piix_t *dev) /* Function 3: Power Management */ if (dev->type > 3) { - fregs = (uint8_t *) dev->regs[3]; + fregs = (uint8_t *) dev->regs[3]; piix_log("PIIX Function 3: %02X%02X:%02X%02X\n", fregs[0x01], fregs[0x00], fregs[0x03], fregs[0x02]); fregs[0x06] = 0x80; fregs[0x07] = 0x02; if (dev->type > 4) @@ -1606,8 +1606,8 @@ const device_t piix_device = "piix", DEVICE_PCI, 0x122e0101, - piix_init, - piix_close, + piix_init, + piix_close, piix_reset, { NULL }, piix_speed_changed, @@ -1621,8 +1621,8 @@ const device_t piix_rev02_device = "piix_rev02", DEVICE_PCI, 0x122e0121, - piix_init, - piix_close, + piix_init, + piix_close, piix_reset, { NULL }, piix_speed_changed, @@ -1636,8 +1636,8 @@ const device_t piix3_device = "piix3", DEVICE_PCI, 0x70000403, - piix_init, - piix_close, + piix_init, + piix_close, piix_reset, { NULL }, piix_speed_changed, @@ -1651,8 +1651,8 @@ const device_t piix3_ioapic_device = "piix3_ioapic", DEVICE_PCI, 0x70001403, - piix_init, - piix_close, + piix_init, + piix_close, piix_reset, { NULL }, piix_speed_changed, @@ -1666,8 +1666,8 @@ const device_t piix4_device = "piix4", DEVICE_PCI, 0x71100004, - piix_init, - piix_close, + piix_init, + piix_close, piix_reset, { NULL }, piix_speed_changed, @@ -1681,8 +1681,8 @@ const device_t piix4e_device = "piix4e", DEVICE_PCI, 0x71100094, - piix_init, - piix_close, + piix_init, + piix_close, piix_reset, { NULL }, piix_speed_changed, @@ -1696,8 +1696,8 @@ const device_t slc90e66_device = "slc90e66", DEVICE_PCI, 0x94600005, - piix_init, - piix_close, + piix_init, + piix_close, piix_reset, { NULL }, piix_speed_changed, diff --git a/src/chipset/neat.c b/src/chipset/neat.c index 7badc0de8..258982ea7 100644 --- a/src/chipset/neat.c +++ b/src/chipset/neat.c @@ -480,7 +480,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB0: + case REG_RB0: val &= RB0_MASK; *reg = (*reg & ~RB0_MASK) | val | \ (RB0_REV_ID << RB0_REV_SH); @@ -489,7 +489,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB1: + case REG_RB1: val &= RB1_MASK; *reg = (*reg & ~RB1_MASK) | val; #if NEAT_DEBUG > 1 @@ -497,7 +497,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB2: + case REG_RB2: val &= RB2_MASK; *reg = (*reg & ~RB2_MASK) | val; #if NEAT_DEBUG > 1 @@ -505,7 +505,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB3: + case REG_RB3: val &= RB3_MASK; *reg = (*reg & ~RB3_MASK) | val; #if NEAT_DEBUG > 1 @@ -513,7 +513,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB4: + case REG_RB4: val &= RB4_MASK; *reg = (*reg & ~RB4_MASK) | val; #if NEAT_DEBUG > 1 @@ -521,7 +521,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB5: + case REG_RB5: val &= RB5_MASK; *reg = (*reg & ~RB5_MASK) | val; #if NEAT_DEBUG > 1 @@ -529,7 +529,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB6: + case REG_RB6: val &= RB6_MASK; *reg = (*reg & ~RB6_MASK) | val; #if NEAT_DEBUG > 1 @@ -537,7 +537,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB7: + case REG_RB7: val &= RB7_MASK; *reg = val; #if NEAT_DEBUG > 1 @@ -556,7 +556,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) } break; - case REG_RB8: + case REG_RB8: val &= RB8_MASK; *reg = (*reg & ~RB8_MASK) | val; #if NEAT_DEBUG > 1 @@ -564,7 +564,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) #endif break; - case REG_RB9: + case REG_RB9: val &= RB9_MASK; *reg = (*reg & ~RB9_MASK) | val; #if NEAT_DEBUG > 1 @@ -576,7 +576,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) } break; - case REG_RB10: + case REG_RB10: val &= RB10_MASK; *reg = (*reg & ~RB10_MASK) | val; #if NEAT_DEBUG > 1 @@ -591,7 +591,7 @@ neat_write(uint16_t port, uint8_t val, void *priv) ems_recalc(dev, &dev->ems[i]); break; - case REG_RB11: + case REG_RB11: val &= RB11_MASK; *reg = (*reg & ~RB11_MASK) | val; #if NEAT_DEBUG > 1 diff --git a/src/chipset/olivetti_eva.c b/src/chipset/olivetti_eva.c index 2858307d4..2f31458be 100644 --- a/src/chipset/olivetti_eva.c +++ b/src/chipset/olivetti_eva.c @@ -73,12 +73,12 @@ olivetti_eva_write(uint16_t addr, uint8_t val, void *priv) case 0x069: dev->reg_069 = val; /* - * Unfortunately, if triggered, the BIOS remapping function fails causing + * Unfortunately, if triggered, the BIOS remapping function fails causing * a fatal error. Therefore, this code section is currently commented. */ // if (val & 1){ - // /* - // * Set the register to 7 or above for the BIOS to trigger the + // /* + // * Set the register to 7 or above for the BIOS to trigger the // * memory remapping function if shadowing is active. // */ // dev->reg_069 = 0x7; @@ -129,24 +129,24 @@ olivetti_eva_init(const device_t *info) { olivetti_eva_t *dev = (olivetti_eva_t *) malloc(sizeof(olivetti_eva_t)); memset(dev, 0, sizeof(olivetti_eva_t)); - + /* GA98 registers */ dev->reg_065 = 0x00; - + /* RAM page registers: never read, only set */ dev->reg_067 = 0x00; - + /* RAM enable registers */ dev->reg_069 = 0x0; - + io_sethandler(0x0065, 0x0001, olivetti_eva_read, NULL, NULL, olivetti_eva_write, NULL, NULL, dev); io_sethandler(0x0067, 0x0001, olivetti_eva_read, NULL, NULL, olivetti_eva_write, NULL, NULL, dev); io_sethandler(0x0069, 0x0001, olivetti_eva_read, NULL, NULL, olivetti_eva_write, NULL, NULL, dev); - + /* When shadowing is not enabled in BIOS, all upper memory is available as XMS */ mem_remap_top(384); - - /* + + /* * Default settings when NVRAM is cleared activate shadowing. * Thus, to avoid boot errors, remap only 256k from UMB to XMS. * Remove this block once BIOS memory remapping works. diff --git a/src/chipset/opti291.c b/src/chipset/opti291.c index 3105d50d7..c981f6b36 100644 --- a/src/chipset/opti291.c +++ b/src/chipset/opti291.c @@ -7,7 +7,7 @@ * This file is part of the 86Box distribution. * * Implementation of the OPTi 82C291 chipset. - + * Authors: plant/nerd73, Tiseno100 * * Copyright 2020 plant/nerd73. diff --git a/src/chipset/opti5x7.c b/src/chipset/opti5x7.c index 483580803..54ecd6c76 100644 --- a/src/chipset/opti5x7.c +++ b/src/chipset/opti5x7.c @@ -7,7 +7,7 @@ * This file is part of the 86Box distribution. * * Implementation of the OPTi 82C546/82C547(Python) & 82C596/82C597(Cobra) chipsets. - + * Authors: plant/nerd73, * Miran Grca, * Tiseno100 diff --git a/src/chipset/scamp.c b/src/chipset/scamp.c index 57b0120b2..42f579dca 100644 --- a/src/chipset/scamp.c +++ b/src/chipset/scamp.c @@ -153,7 +153,7 @@ static const struct /* The column bits masked when using 256kbit DRAMs in 4Mbit mode aren't contiguous, so we use separate routines for that special case */ -static uint8_t +static uint8_t ram_mirrored_256k_in_4mi_read(uint32_t addr, void *priv) { ram_struct_t *rs = (ram_struct_t *) priv; @@ -183,7 +183,7 @@ ram_mirrored_256k_in_4mi_read(uint32_t addr, void *priv) } -static void +static void ram_mirrored_256k_in_4mi_write(uint32_t addr, uint8_t val, void *priv) { ram_struct_t *rs = (ram_struct_t *) priv; @@ -215,7 +215,7 @@ ram_mirrored_256k_in_4mi_write(uint32_t addr, uint8_t val, void *priv) /*Read/write handlers for interleaved memory banks. We must keep CPU and ram array mapping linear, otherwise we won't be able to execute code from interleaved banks*/ -static uint8_t +static uint8_t ram_mirrored_interleaved_read(uint32_t addr, void *priv) { ram_struct_t *rs = (ram_struct_t *) priv; @@ -245,7 +245,7 @@ ram_mirrored_interleaved_read(uint32_t addr, void *priv) } -static void +static void ram_mirrored_interleaved_write(uint32_t addr, uint8_t val, void *priv) { ram_struct_t *rs = (ram_struct_t *) priv; @@ -275,7 +275,7 @@ ram_mirrored_interleaved_write(uint32_t addr, uint8_t val, void *priv) } -static uint8_t +static uint8_t ram_mirrored_read(uint32_t addr, void *priv) { ram_struct_t *rs = (ram_struct_t *) priv; @@ -293,14 +293,14 @@ ram_mirrored_read(uint32_t addr, void *priv) } -static void +static void ram_mirrored_write(uint32_t addr, uint8_t val, void *priv) { ram_struct_t *rs = (ram_struct_t *) priv; scamp_t *dev = rs->parent; int bank = rs->bank, byte; int row, column; - + addr -= dev->ram_virt_base[bank]; byte = addr & 1; column = (addr >> 1) & dev->ram_mask[bank]; @@ -311,7 +311,7 @@ ram_mirrored_write(uint32_t addr, uint8_t val, void *priv) } -static void +static void recalc_mappings(void *priv) { scamp_t *dev = (scamp_t *) priv; @@ -346,7 +346,7 @@ recalc_mappings(void *priv) if (rammap[cur_rammap].bank[0] == BANK_NONE) bank_nr = 1; - + for (; bank_nr < 2; bank_nr++) { old_virt_base = virt_base; phys_bank = ram_configs[dev->ram_config].bank[bank_nr]; @@ -511,7 +511,7 @@ recalc_mappings(void *priv) ram_mirrored_interleaved_read, NULL, NULL, ram_mirrored_interleaved_write, NULL, NULL); break; - + case BANK_4M_INTERLEAVED: if (phys_bank == BANK_256K || phys_bank == BANK_256K_INTERLEAVED) { mem_mapping_set_handler(&dev->ram_mapping[bank_nr], @@ -577,14 +577,14 @@ scamp_ems_write(uint32_t addr, uint8_t val, void *priv) ems_struct_t *ems = (ems_struct_t *) priv; scamp_t *dev = ems->parent; int segment = ems->segment; - + addr = (addr & 0x3fff) | dev->mappings[segment]; ram[addr] = val; } static void recalc_ems(scamp_t *dev) -{ +{ int segment; const uint32_t ems_base[12] = { @@ -633,7 +633,7 @@ recalc_ems(scamp_t *dev) } } -static void +static void shadow_control(uint32_t addr, uint32_t size, int state, int ems_enable) { if (ems_enable) @@ -706,7 +706,7 @@ shadow_recalc(scamp_t *dev) shadow_control(0xf8000, 0x8000, (feaxs >> 6) & 3, 0); } -static void +static void scamp_write(uint16_t addr, uint8_t val, void *priv) { scamp_t *dev = (scamp_t *) priv; @@ -731,7 +731,7 @@ scamp_write(uint16_t addr, uint8_t val, void *priv) if (dev->ems_autoinc) dev->ems_index = (dev->ems_index + 1) & 0x3f; break; - + case 0xec: if (dev->cfg_enable) dev->cfg_index = val; @@ -778,7 +778,7 @@ scamp_write(uint16_t addr, uint8_t val, void *priv) } -static uint8_t +static uint8_t scamp_read(uint16_t addr, void *priv) { scamp_t *dev = (scamp_t *) priv; @@ -798,7 +798,7 @@ scamp_read(uint16_t addr, void *priv) ret = (dev->ems[dev->ems_index] >> 8) | 0xfc; if (dev->ems_autoinc) dev->ems_index = (dev->ems_index + 1) & 0x3f; - break; + break; case 0xed: if (dev->cfg_enable && (dev->cfg_index >= 0x00) && (dev->cfg_index <= 0x16)) @@ -839,7 +839,7 @@ scamp_init(const device_t *info) int c; scamp_t *dev = (scamp_t *)malloc(sizeof(scamp_t)); memset(dev, 0x00, sizeof(scamp_t)); - + dev->cfg_regs[CFG_ID] = ID_VL82C311; dev->cfg_enable = 1; @@ -852,7 +852,7 @@ scamp_init(const device_t *info) io_sethandler(0x00f9, 0x0001, scamp_read, NULL, NULL, scamp_write, NULL, NULL, dev); io_sethandler(0x00fb, 0x0001, - scamp_read, NULL, NULL, scamp_write, NULL, NULL, dev); + scamp_read, NULL, NULL, scamp_write, NULL, NULL, dev); dev->ram_config = 0; diff --git a/src/chipset/scat.c b/src/chipset/scat.c index 4a58d2a1f..0780ec507 100644 --- a/src/chipset/scat.c +++ b/src/chipset/scat.c @@ -384,7 +384,7 @@ get_addr(scat_t *dev, uint32_t addr, ems_page_t *p) if (mem_size <= ((dev->regs[SCAT_VERSION] & 0x0f) > 3 ? 2048 : 4096) && (((dev->regs[SCAT_DRAM_CONFIGURATION] & 0x0f) < 8) || dev->external_is_RAS)) { nbanks_2048k = 0; nbanks_512k = mem_size >> 9; - } else { + } else { nbanks_2048k = mem_size >> 11; nbanks_512k = (mem_size & 1536) >> 9; } diff --git a/src/chipset/sis_85c310.c b/src/chipset/sis_85c310.c index 6e31f8456..e1130b733 100644 --- a/src/chipset/sis_85c310.c +++ b/src/chipset/sis_85c310.c @@ -144,4 +144,4 @@ const device_t rabbit_device = { rabbit_init, rabbit_close, NULL, { NULL }, NULL, NULL, NULL -}; \ No newline at end of file +}; diff --git a/src/chipset/sis_85c496.c b/src/chipset/sis_85c496.c index 1c1ddb036..a649f5053 100644 --- a/src/chipset/sis_85c496.c +++ b/src/chipset/sis_85c496.c @@ -468,7 +468,7 @@ sis_85c49x_pci_read(int func, int addr, void *priv) return ret; } - + static void sis_85c496_rmsmiblk_count(void *priv) @@ -625,8 +625,8 @@ const device_t sis_85c496_device = "sis_85c496", DEVICE_PCI, 0, - sis_85c496_init, - sis_85c496_close, + sis_85c496_init, + sis_85c496_close, sis_85c496_reset, { NULL }, NULL, @@ -641,8 +641,8 @@ const device_t sis_85c496_ls486e_device = "sis_85c496_ls486e", DEVICE_PCI, 1, - sis_85c496_init, - sis_85c496_close, + sis_85c496_init, + sis_85c496_close, sis_85c496_reset, { NULL }, NULL, diff --git a/src/chipset/sis_85c50x.c b/src/chipset/sis_85c50x.c index 5bbe99f1d..93bbcb745 100644 --- a/src/chipset/sis_85c50x.c +++ b/src/chipset/sis_85c50x.c @@ -304,7 +304,7 @@ sis_85c50x_isa_read(uint16_t addr, void *priv) ret = dev->regs[dev->index]; break; } - + sis_85c50x_log("85C501-ISA: dev->regs[%02x] (%02x)\n", dev->index, ret); return ret; diff --git a/src/chipset/stpc.c b/src/chipset/stpc.c index 6e7067ebc..8dcfc2862 100644 --- a/src/chipset/stpc.c +++ b/src/chipset/stpc.c @@ -835,7 +835,7 @@ stpc_setup(stpc_t *dev) dev->pci_conf[3][0x01] = dev->local >> 24; dev->pci_conf[3][0x02] = 0x30; dev->pci_conf[3][0x03] = 0x02; - + dev->pci_conf[3][0x06] = 0x80; dev->pci_conf[3][0x07] = 0x02; @@ -877,7 +877,7 @@ stpc_init(const device_t *info) stpc_t *dev = (stpc_t *) malloc(sizeof(stpc_t)); memset(dev, 0, sizeof(stpc_t)); - + dev->local = info->local; pci_add_card(PCI_ADD_NORTHBRIDGE, stpc_nb_read, stpc_nb_write, dev); @@ -1002,7 +1002,7 @@ stpc_lpt_write(uint16_t addr, uint8_t val, void *priv) } else if (addr == 0x3f0) { if (val == 0xaa) dev->unlocked = 0; - else + else dev->offset = val; } else if (dev->offset == 1) { /* dev->reg1 is set by stpc_lpt_handlers */ @@ -1063,8 +1063,8 @@ const device_t stpc_client_device = "stpc_client", DEVICE_PCI, STPC_CLIENT, - stpc_init, - stpc_close, + stpc_init, + stpc_close, stpc_reset, { NULL }, NULL, @@ -1078,8 +1078,8 @@ const device_t stpc_consumer2_device = "stpc_consumer2", DEVICE_PCI, STPC_CONSUMER2, - stpc_init, - stpc_close, + stpc_init, + stpc_close, stpc_reset, { NULL }, NULL, @@ -1093,8 +1093,8 @@ const device_t stpc_elite_device = "stpc_elite", DEVICE_PCI, STPC_ELITE, - stpc_init, - stpc_close, + stpc_init, + stpc_close, stpc_reset, { NULL }, NULL, @@ -1108,8 +1108,8 @@ const device_t stpc_atlas_device = "stpc_atlas", DEVICE_PCI, STPC_ATLAS, - stpc_init, - stpc_close, + stpc_init, + stpc_close, stpc_reset, { NULL }, NULL, diff --git a/src/chipset/umc_8886.c b/src/chipset/umc_8886.c index a5206d678..ea99460d7 100644 --- a/src/chipset/umc_8886.c +++ b/src/chipset/umc_8886.c @@ -18,7 +18,7 @@ * Copyright 2021 Miran Grca. */ -/* +/* UMC 8886xx Configuration Registers Note: PMU functionality is quite basic. There may be Enable/Disable bits, IRQ/SMI picks and it also diff --git a/src/chipset/umc_hb4.c b/src/chipset/umc_hb4.c index 8294323ad..6bb7b13d3 100644 --- a/src/chipset/umc_hb4.c +++ b/src/chipset/umc_hb4.c @@ -10,7 +10,7 @@ * * Note: This chipset has no datasheet, everything were done via * reverse engineering the BIOS of various machines using it. - * + * * Note 2: Additional information were also used from all * around the web. * @@ -81,7 +81,7 @@ Register 56h & 57h: DRAM Bank 0 Configuration Register 58h & 59h: DRAM Bank 1 Configuration - + Register 60: Bit 5: If set and SMRAM is enabled, data cycles go to PCI and code cycles go to DRAM Bit 0: SMRAM Local Access Enable - if set, SMRAM is also enabled outside SMM diff --git a/src/chipset/via_apollo.c b/src/chipset/via_apollo.c index ea30c14c9..60aa83a47 100644 --- a/src/chipset/via_apollo.c +++ b/src/chipset/via_apollo.c @@ -232,7 +232,7 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv) via_apollo_t *dev = (via_apollo_t *) priv; if (func) return; - + /*Read-only addresses*/ if ((addr < 4) || ((addr > 5) && (addr < 7)) || ((addr >= 8) && (addr < 0xd)) || ((addr >= 0xe) && (addr != 0x0f) && (addr < 0x12)) || ((addr >= 0x14) && (addr < 0x50)) || @@ -259,7 +259,7 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv) else dev->pci_conf[0x05] = val; break; - + case 0x07: dev->pci_conf[0x07] &= ~(val & 0xb0); break; @@ -766,8 +766,8 @@ const device_t via_vpx_device = "via_vpx", DEVICE_PCI, VIA_585, /*VT82C585*/ - via_apollo_init, - via_apollo_close, + via_apollo_init, + via_apollo_close, via_apollo_reset, { NULL }, NULL, @@ -781,8 +781,8 @@ const device_t amd640_device = "amd640", DEVICE_PCI, VIA_595, /*VT82C595*/ - via_apollo_init, - via_apollo_close, + via_apollo_init, + via_apollo_close, via_apollo_reset, { NULL }, NULL, @@ -796,8 +796,8 @@ const device_t via_vp3_device = "via_vp3", DEVICE_PCI, VIA_597, /*VT82C597*/ - via_apollo_init, - via_apollo_close, + via_apollo_init, + via_apollo_close, via_apollo_reset, { NULL }, NULL, @@ -811,8 +811,8 @@ const device_t via_mvp3_device = "via_mvp3", DEVICE_PCI, VIA_598, /*VT82C598MVP*/ - via_apollo_init, - via_apollo_close, + via_apollo_init, + via_apollo_close, via_apollo_reset, { NULL }, NULL, diff --git a/src/chipset/via_pipc.c b/src/chipset/via_pipc.c index 1308d6cff..b985b2ba8 100644 --- a/src/chipset/via_pipc.c +++ b/src/chipset/via_pipc.c @@ -980,7 +980,7 @@ pipc_write(int func, int addr, uint8_t val, void *priv) if ((dev->local <= VIA_PIPC_586B) && (addr >= 0x74)) return; - if ((dev->local <= VIA_PIPC_596A) && ((addr == 0x51) || (addr == 0x52) || (addr == 0x5f) || (addr == 0x85) || + if ((dev->local <= VIA_PIPC_596A) && ((addr == 0x51) || (addr == 0x52) || (addr == 0x5f) || (addr == 0x85) || (addr == 0x86) || ((addr >= 0x8a) && (addr < 0x90)))) return; diff --git a/src/chipset/via_vt82c49x.c b/src/chipset/via_vt82c49x.c index bed86068b..80a00e606 100644 --- a/src/chipset/via_vt82c49x.c +++ b/src/chipset/via_vt82c49x.c @@ -354,7 +354,7 @@ vt82c49x_init(const device_t *info) pic_elcr_set_enabled(1); vt82c49x_recalc(dev); - + return dev; } diff --git a/src/chipset/vl82c480.c b/src/chipset/vl82c480.c index 7a0568a6c..455e8bf16 100644 --- a/src/chipset/vl82c480.c +++ b/src/chipset/vl82c480.c @@ -58,7 +58,7 @@ vl82c480_shflags(uint8_t access) } -static void +static void vl82c480_recalc(vl82c480_t *dev) { int i, j; @@ -127,7 +127,7 @@ vl82c480_write(uint16_t addr, uint8_t val, void *p) } -static uint8_t +static uint8_t vl82c480_read(uint16_t addr, void *p) { vl82c480_t *dev = (vl82c480_t *)p; diff --git a/src/codegen/CMakeLists.txt b/src/codegen/CMakeLists.txt index 68b13f24d..c5f3eef3d 100644 --- a/src/codegen/CMakeLists.txt +++ b/src/codegen/CMakeLists.txt @@ -28,4 +28,4 @@ if(DYNAREC) endif() target_link_libraries(86Box dynarec cgt) -endif() \ No newline at end of file +endif() diff --git a/src/codegen/codegen.h b/src/codegen/codegen.h index d3898b535..ac85d8662 100644 --- a/src/codegen/codegen.h +++ b/src/codegen/codegen.h @@ -56,18 +56,18 @@ added to the page_lookup for this purpose. When in the page_lookup, each write will go through the mem_write_ram*_page() functions and set the dirty mask appropriately. - + Each codeblock also contains a code mask (actually two masks, one for each page the block is/may be in), again with each bit representing 64 bytes. - + Each page has a list of codeblocks present in it. As each codeblock can span up to two pages, two lists are present. - + When a codeblock is about to be executed, the code masks are compared with the dirty masks for the relevant pages. If either intersect, then codegen_check_flush() is called on the affected page(s), and all affected blocks are evicted. - + The 64 byte granularity appears to work reasonably well for most cases, avoiding most unnecessary evictions (eg when code & data are stored in the same page). @@ -78,17 +78,17 @@ typedef struct codeblock_t uint64_t page_mask, page_mask2; uint64_t *dirty_mask, *dirty_mask2; uint64_t cmp; - + /*Previous and next pointers, for the codeblock list associated with each physical page. Two sets of pointers, as a codeblock can be present in two pages.*/ struct codeblock_t *prev, *next; struct codeblock_t *prev_2, *next_2; - + /*Pointers for codeblock tree, used to search for blocks when hash lookup fails.*/ struct codeblock_t *parent, *left, *right; - + int pnt; int ins; @@ -116,7 +116,7 @@ static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs) { codeblock_t *block = pages[phys >> 12].head; uint64_t a = _cs | ((uint64_t)phys << 32); - + while (block) { if (a == block->cmp) @@ -130,7 +130,7 @@ static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs) else block = block->right; } - + return block; } @@ -139,7 +139,7 @@ static inline void codeblock_tree_add(codeblock_t *new_block) codeblock_t *block = pages[new_block->phys >> 12].head; uint64_t a = new_block->_cs | ((uint64_t)new_block->phys << 32); new_block->cmp = a; - + if (!block) { pages[new_block->phys >> 12].head = new_block; @@ -148,7 +148,7 @@ static inline void codeblock_tree_add(codeblock_t *new_block) else { codeblock_t *old_block = NULL; - + while (block) { old_block = block; @@ -157,12 +157,12 @@ static inline void codeblock_tree_add(codeblock_t *new_block) else block = block->right; } - + if (a < old_block->cmp) old_block->left = new_block; else old_block->right = new_block; - + new_block->parent = old_block; new_block->left = new_block->right = NULL; } @@ -237,7 +237,7 @@ static inline void codeblock_tree_delete(codeblock_t *block) /*Difficult case - node has two children. Walk right child to find lowest node*/ codeblock_t *lowest = block->right, *highest; codeblock_t *old_parent; - + while (lowest->left) lowest = lowest->left; @@ -260,7 +260,7 @@ static inline void codeblock_tree_delete(codeblock_t *block) lowest->left->parent = lowest; old_parent->left = NULL; - + highest = lowest->right; if (!highest) { diff --git a/src/codegen/codegen_accumulate.h b/src/codegen/codegen_accumulate.h index 5aebf4c77..b1e64db18 100644 --- a/src/codegen/codegen_accumulate.h +++ b/src/codegen/codegen_accumulate.h @@ -1,7 +1,7 @@ enum { ACCREG_cycles = 0, - + ACCREG_COUNT }; diff --git a/src/codegen/codegen_ops.c b/src/codegen/codegen_ops.c index e398ad16a..aedeb88a9 100644 --- a/src/codegen/codegen_ops.c +++ b/src/codegen/codegen_ops.c @@ -35,7 +35,7 @@ RecompOpFn recomp_opcodes[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropADD_b_rmw, ropADD_w_rmw, ropADD_b_rm, ropADD_w_rm, ropADD_AL_imm, ropADD_AX_imm, ropPUSH_ES_16, ropPOP_ES_16, ropOR_b_rmw, ropOR_w_rmw, ropOR_b_rm, ropOR_w_rm, ropOR_AL_imm, ropOR_AX_imm, ropPUSH_CS_16, NULL, /*10*/ NULL, NULL, NULL, NULL, NULL, NULL, ropPUSH_SS_16, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropPUSH_DS_16, ropPOP_DS_16, /*20*/ ropAND_b_rmw, ropAND_w_rmw, ropAND_b_rm, ropAND_w_rm, ropAND_AL_imm, ropAND_AX_imm, NULL, NULL, ropSUB_b_rmw, ropSUB_w_rmw, ropSUB_b_rm, ropSUB_w_rm, ropSUB_AL_imm, ropSUB_AX_imm, NULL, NULL, @@ -57,7 +57,7 @@ RecompOpFn recomp_opcodes[512] = /*f0*/ NULL, NULL, NULL, NULL, NULL, NULL, ropF6, ropF7_w, NULL, NULL, ropCLI, ropSTI, ropCLD, ropSTD, ropFE, ropFF_16, /*32-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropADD_b_rmw, ropADD_l_rmw, ropADD_b_rm, ropADD_l_rm, ropADD_AL_imm, ropADD_EAX_imm, ropPUSH_ES_32, ropPOP_ES_32, ropOR_b_rmw, ropOR_l_rmw, ropOR_b_rm, ropOR_l_rm, ropOR_AL_imm, ropOR_EAX_imm, ropPUSH_CS_32, NULL, /*10*/ NULL, NULL, NULL, NULL, NULL, NULL, ropPUSH_SS_32, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropPUSH_DS_32, ropPOP_DS_32, /*20*/ ropAND_b_rmw, ropAND_l_rmw, ropAND_b_rm, ropAND_l_rm, ropAND_AL_imm, ropAND_EAX_imm, NULL, NULL, ropSUB_b_rmw, ropSUB_l_rmw, ropSUB_b_rm, ropSUB_l_rm, ropSUB_AL_imm, ropSUB_EAX_imm, NULL, NULL, @@ -82,7 +82,7 @@ RecompOpFn recomp_opcodes[512] = RecompOpFn recomp_opcodes_0f[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 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, @@ -104,7 +104,7 @@ RecompOpFn recomp_opcodes_0f[512] = /*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 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, @@ -130,7 +130,7 @@ RecompOpFn recomp_opcodes_0f[512] = RecompOpFn recomp_opcodes_d8[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, /*10*/ ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, /*20*/ ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, @@ -152,7 +152,7 @@ RecompOpFn recomp_opcodes_d8[512] = /*f0*/ ropFDIV, ropFDIV, ropFDIV, ropFDIV, ropFDIV, ropFDIV, ropFDIV, ropFDIV, ropFDIVR, ropFDIVR, ropFDIVR, ropFDIVR, ropFDIVR, ropFDIVR, ropFDIVR, ropFDIVR, /*32-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFADDs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, ropFMULs, /*10*/ ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, ropFCOMPs, /*20*/ ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, ropFSUBRs, @@ -177,7 +177,7 @@ RecompOpFn recomp_opcodes_d8[512] = RecompOpFn recomp_opcodes_d9[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, @@ -199,7 +199,7 @@ RecompOpFn recomp_opcodes_d9[512] = /*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 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, ropFLDs, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, ropFSTPs, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, ropFLDCW, @@ -224,7 +224,7 @@ RecompOpFn recomp_opcodes_d9[512] = RecompOpFn recomp_opcodes_da[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, /*10*/ ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, /*20*/ ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, @@ -246,7 +246,7 @@ RecompOpFn recomp_opcodes_da[512] = /*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 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFADDil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, ropFMULil, /*10*/ ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, ropFCOMPil, /*20*/ ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, ropFSUBRil, @@ -271,7 +271,7 @@ RecompOpFn recomp_opcodes_da[512] = RecompOpFn recomp_opcodes_db[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -293,7 +293,7 @@ RecompOpFn recomp_opcodes_db[512] = /*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 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*80*/ ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, ropFILDl, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, ropFISTPl, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -318,7 +318,7 @@ RecompOpFn recomp_opcodes_db[512] = RecompOpFn recomp_opcodes_dc[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, /*10*/ ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, /*20*/ ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, @@ -340,7 +340,7 @@ RecompOpFn recomp_opcodes_dc[512] = /*f0*/ ropFDIVRr, ropFDIVRr, ropFDIVRr, ropFDIVRr, ropFDIVRr, ropFDIVRr, ropFDIVRr, ropFDIVRr, ropFDIVr, ropFDIVr, ropFDIVr, ropFDIVr, ropFDIVr, ropFDIVr, ropFDIVr, ropFDIVr, /*32-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFADDd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, ropFMULd, /*10*/ ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, ropFCOMPd, /*20*/ ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, ropFSUBRd, @@ -365,7 +365,7 @@ RecompOpFn recomp_opcodes_dc[512] = RecompOpFn recomp_opcodes_dd[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -387,7 +387,7 @@ RecompOpFn recomp_opcodes_dd[512] = /*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 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, ropFLDd, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, ropFSTPd, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -412,7 +412,7 @@ RecompOpFn recomp_opcodes_dd[512] = RecompOpFn recomp_opcodes_de[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, /*10*/ ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, /*20*/ ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, @@ -434,7 +434,7 @@ RecompOpFn recomp_opcodes_de[512] = /*f0*/ ropFDIVRP, ropFDIVRP, ropFDIVRP, ropFDIVRP, ropFDIVRP, ropFDIVRP, ropFDIVRP, ropFDIVRP, ropFDIVP, ropFDIVP, ropFDIVP, ropFDIVP, ropFDIVP, ropFDIVP, ropFDIVP, ropFDIVP, /*32-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFADDiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, ropFMULiw, /*10*/ ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, ropFCOMPiw, /*20*/ ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, ropFSUBRiw, @@ -459,7 +459,7 @@ RecompOpFn recomp_opcodes_de[512] = RecompOpFn recomp_opcodes_df[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, @@ -481,7 +481,7 @@ RecompOpFn recomp_opcodes_df[512] = /*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 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, ropFILDw, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*10*/ ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, ropFISTPw, /*20*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, ropFILDq, @@ -506,7 +506,7 @@ RecompOpFn recomp_opcodes_df[512] = RecompOpFn recomp_opcodes_REPE[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 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, @@ -528,7 +528,7 @@ RecompOpFn recomp_opcodes_REPE[512] = /*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 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, @@ -553,7 +553,7 @@ RecompOpFn recomp_opcodes_REPE[512] = RecompOpFn recomp_opcodes_REPNE[512] = { /*16-bit data*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 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, @@ -575,7 +575,7 @@ RecompOpFn recomp_opcodes_REPNE[512] = /*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 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, diff --git a/src/codegen/codegen_ops_arith.h b/src/codegen/codegen_ops_arith.h index e2eb9baef..2e497f17c 100644 --- a/src/codegen/codegen_ops_arith.h +++ b/src/codegen/codegen_ops_arith.h @@ -1,11 +1,11 @@ static uint32_t ropINC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg; - + CALL_FUNC((uintptr_t)flags_rebuild_c); - + host_reg = LOAD_REG_W(opcode & 7); - + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); // ADD_HOST_REG_IMM_W(host_reg, 1); INC_HOST_REG_W(host_reg); @@ -13,7 +13,7 @@ static uint32_t ropINC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC16); STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); - + codegen_flags_changed = 1; return op_pc; @@ -23,9 +23,9 @@ static uint32_t ropINC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin int host_reg; CALL_FUNC((uintptr_t)flags_rebuild_c); - + host_reg = LOAD_REG_L(opcode & 7); - + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); // ADD_HOST_REG_IMM(host_reg, 1); INC_HOST_REG(host_reg); @@ -41,11 +41,11 @@ static uint32_t ropINC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin static uint32_t ropDEC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg; - + CALL_FUNC((uintptr_t)flags_rebuild_c); host_reg = LOAD_REG_W(opcode & 7); - + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); // SUB_HOST_REG_IMM_W(host_reg, 1); DEC_HOST_REG_W(host_reg); @@ -61,11 +61,11 @@ static uint32_t ropDEC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg; - + CALL_FUNC((uintptr_t)flags_rebuild_c); host_reg = LOAD_REG_L(opcode & 7); - + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg); // SUB_HOST_REG_IMM(host_reg, 1); DEC_HOST_REG(host_reg); @@ -474,10 +474,10 @@ static uint32_t ropADD_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ADD_HOST_REG_IMM_B(host_reg, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD8); - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_B_RELEASE(host_reg); - codegen_flags_changed = 1; + codegen_flags_changed = 1; return op_pc + 1; } static uint32_t ropADD_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -488,9 +488,9 @@ static uint32_t ropADD_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ADD_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD16); - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); - + codegen_flags_changed = 1; return op_pc + 2; } @@ -503,9 +503,9 @@ static uint32_t ropADD_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 ADD_HOST_REG_IMM(host_reg, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD32); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); - + codegen_flags_changed = 1; return op_pc + 4; } @@ -518,23 +518,23 @@ static uint32_t ropCMP_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, host_reg = CMP_HOST_REG_IMM_B(host_reg, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); - + codegen_flags_changed = 1; return op_pc + 1; } static uint32_t ropCMP_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg = LOAD_REG_W(REG_AX); - + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg); host_reg = CMP_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); - + codegen_flags_changed = 1; return op_pc + 2; } @@ -547,9 +547,9 @@ static uint32_t ropCMP_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 host_reg = CMP_HOST_REG_IMM_L(host_reg, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); - + codegen_flags_changed = 1; return op_pc + 4; } @@ -562,9 +562,9 @@ static uint32_t ropSUB_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, SUB_HOST_REG_IMM_B(host_reg, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_B_RELEASE(host_reg); - + codegen_flags_changed = 1; return op_pc + 1; } @@ -576,9 +576,9 @@ static uint32_t ropSUB_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, SUB_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); - + codegen_flags_changed = 1; return op_pc + 2; } @@ -591,9 +591,9 @@ static uint32_t ropSUB_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 SUB_HOST_REG_IMM(host_reg, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); - + codegen_flags_changed = 1; return op_pc + 4; } @@ -603,7 +603,7 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ int host_reg; uint32_t imm; x86seg *target_seg = NULL; - + if ((fetchdat & 0x30) == 0x10) return 0; @@ -629,7 +629,7 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ host_reg = LOAD_REG_B(fetchdat & 7); imm = (fetchdat >> 8) & 0xff; } - + switch (fetchdat & 0x38) { case 0x00: /*ADD*/ @@ -663,8 +663,8 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8); break; } - - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -679,7 +679,7 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ } else RELEASE_REG(host_reg); - + codegen_flags_changed = 1; return op_pc + 2; } @@ -689,10 +689,10 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 int host_reg; uint32_t imm; x86seg *target_seg = NULL; - + if ((fetchdat & 0x30) == 0x10) return 0; - + if ((fetchdat & 0xc0) != 0xc0) { target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); @@ -715,7 +715,7 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 host_reg = LOAD_REG_W(fetchdat & 7); imm = (fetchdat >> 8) & 0xffff; } - + switch (fetchdat & 0x38) { case 0x00: /*ADD*/ @@ -749,8 +749,8 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); break; } - - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -765,7 +765,7 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 } else RELEASE_REG(host_reg); - + codegen_flags_changed = 1; return op_pc + 3; } @@ -774,10 +774,10 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 int host_reg; uint32_t imm; x86seg *target_seg = NULL; - + if ((fetchdat & 0x30) == 0x10) return 0; - + if ((fetchdat & 0xc0) != 0xc0) { target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); @@ -799,7 +799,7 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 host_reg = LOAD_REG_L(fetchdat & 7); } imm = fastreadl(cs + op_pc + 1); - + switch (fetchdat & 0x38) { case 0x00: /*ADD*/ @@ -833,8 +833,8 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); break; } - - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -849,7 +849,7 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 } else RELEASE_REG(host_reg); - + codegen_flags_changed = 1; return op_pc + 5; } @@ -859,10 +859,10 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 int host_reg; uint32_t imm; x86seg *target_seg = NULL; - + if ((fetchdat & 0x30) == 0x10) return 0; - + if ((fetchdat & 0xc0) != 0xc0) { target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); @@ -888,7 +888,7 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 if (imm & 0x80) imm |= 0xff80; - + switch (fetchdat & 0x38) { case 0x00: /*ADD*/ @@ -922,8 +922,8 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16); break; } - - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) @@ -938,7 +938,7 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 } else RELEASE_REG(host_reg); - + codegen_flags_changed = 1; return op_pc + 2; } @@ -950,7 +950,7 @@ static uint32_t rop83_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 if ((fetchdat & 0x30) == 0x10) return 0; - + if ((fetchdat & 0xc0) != 0xc0) { target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); @@ -976,7 +976,7 @@ static uint32_t rop83_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 if (imm & 0x80) imm |= 0xffffff80; - + switch (fetchdat & 0x38) { case 0x00: /*ADD*/ @@ -1010,8 +1010,8 @@ static uint32_t rop83_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32); break; } - - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); if ((fetchdat & 0x38) != 0x38) { if ((fetchdat & 0xc0) != 0xc0) diff --git a/src/codegen/codegen_ops_fpu.h b/src/codegen/codegen_ops_fpu.h index b15d41bff..930e0182c 100644 --- a/src/codegen/codegen_ops_fpu.h +++ b/src/codegen/codegen_ops_fpu.h @@ -3,7 +3,7 @@ static uint32_t ropFXCH(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 FP_ENTER(); FP_FXCH(opcode & 7); - + return op_pc; } @@ -12,7 +12,7 @@ static uint32_t ropFLD(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32 FP_ENTER(); FP_FLD(opcode & 7); - + return op_pc; } @@ -21,7 +21,7 @@ static uint32_t ropFST(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32 FP_ENTER(); FP_FST(opcode & 7); - + return op_pc; } static uint32_t ropFSTP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -30,7 +30,7 @@ static uint32_t ropFSTP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 FP_FST(opcode & 7); FP_POP(); - + return op_pc; } @@ -38,13 +38,13 @@ static uint32_t ropFSTP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 static uint32_t ropFLDs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_L(target_seg); @@ -55,13 +55,13 @@ static uint32_t ropFLDs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 static uint32_t ropFLDd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_Q(target_seg); @@ -73,13 +73,13 @@ static uint32_t ropFLDd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 static uint32_t ropFILDw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_W(target_seg); @@ -90,13 +90,13 @@ static uint32_t ropFILDw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint static uint32_t ropFILDl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_L(target_seg); @@ -107,20 +107,20 @@ static uint32_t ropFILDl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint static uint32_t ropFILDq(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_Q(target_seg); FP_LOAD_IQ(); codegen_fpu_loaded_iq[(cpu_state.TOP - 1) & 7] = 1; - + return op_pc + 1; } @@ -128,7 +128,7 @@ static uint32_t ropFSTs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { x86seg *target_seg; int host_reg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); @@ -138,7 +138,7 @@ static uint32_t ropFSTs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); CHECK_SEG_WRITE(target_seg); - + MEM_STORE_ADDR_EA_L(target_seg, host_reg); return op_pc + 1; @@ -147,7 +147,7 @@ static uint32_t ropFSTd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { x86seg *target_seg; int host_reg1, host_reg2 = 0; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); @@ -158,7 +158,7 @@ static uint32_t ropFSTd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 CHECK_SEG_WRITE(target_seg); CHECK_SEG_LIMITS(target_seg, 7); - + MEM_STORE_ADDR_EA_Q(target_seg, host_reg1, host_reg2); return op_pc + 1; @@ -167,17 +167,17 @@ static uint32_t ropFSTd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 static uint32_t ropFSTPs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { uint32_t new_pc = ropFSTs(opcode, fetchdat, op_32, op_pc, block); - + FP_POP(); - + return new_pc; } static uint32_t ropFSTPd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { uint32_t new_pc = ropFSTd(opcode, fetchdat, op_32, op_pc, block); - + FP_POP(); - + return new_pc; } @@ -260,13 +260,13 @@ ropFcompare(COM, il, MEM_LOAD_ADDR_EA_L, FP_COMPARE_IL); /*static uint32_t ropFADDs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_L(target_seg); @@ -277,13 +277,13 @@ ropFcompare(COM, il, MEM_LOAD_ADDR_EA_L, FP_COMPARE_IL); static uint32_t ropFDIVs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_L(target_seg); @@ -294,13 +294,13 @@ static uint32_t ropFDIVs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint static uint32_t ropFMULs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_L(target_seg); @@ -311,13 +311,13 @@ static uint32_t ropFMULs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint static uint32_t ropFSUBs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - + FP_ENTER(); op_pc--; target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_L(target_seg); @@ -331,49 +331,49 @@ static uint32_t ropFADD(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { FP_ENTER(); FP_OP_REG(FPU_ADD, 0, opcode & 7); - + return op_pc; } static uint32_t ropFCOM(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_COMPARE_REG(0, opcode & 7); - + return op_pc; } static uint32_t ropFDIV(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_DIV, 0, opcode & 7); - + return op_pc; } static uint32_t ropFDIVR(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_DIVR, 0, opcode & 7); - + return op_pc; } static uint32_t ropFMUL(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_MUL, 0, opcode & 7); - + return op_pc; } static uint32_t ropFSUB(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_SUB, 0, opcode & 7); - + return op_pc; } static uint32_t ropFSUBR(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_SUBR, 0, opcode & 7); - + return op_pc; } @@ -381,42 +381,42 @@ static uint32_t ropFADDr(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint { FP_ENTER(); FP_OP_REG(FPU_ADD, opcode & 7, 0); - + return op_pc; } static uint32_t ropFDIVr(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_DIV, opcode & 7, 0); - + return op_pc; } static uint32_t ropFDIVRr(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_DIVR, opcode & 7, 0); - + return op_pc; } static uint32_t ropFMULr(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_MUL, opcode & 7, 0); - + return op_pc; } static uint32_t ropFSUBr(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_SUB, opcode & 7, 0); - + return op_pc; } static uint32_t ropFSUBRr(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); FP_OP_REG(FPU_SUBR, opcode & 7, 0); - + return op_pc; } @@ -425,7 +425,7 @@ static uint32_t ropFADDP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint FP_ENTER(); FP_OP_REG(FPU_ADD, opcode & 7, 0); FP_POP(); - + return op_pc; } static uint32_t ropFCOMP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -433,7 +433,7 @@ static uint32_t ropFCOMP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint FP_ENTER(); FP_COMPARE_REG(0, opcode & 7); FP_POP(); - + return op_pc; } static uint32_t ropFDIVP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -441,7 +441,7 @@ static uint32_t ropFDIVP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint FP_ENTER(); FP_OP_REG(FPU_DIV, opcode & 7, 0); FP_POP(); - + return op_pc; } static uint32_t ropFDIVRP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -449,7 +449,7 @@ static uint32_t ropFDIVRP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin FP_ENTER(); FP_OP_REG(FPU_DIVR, opcode & 7, 0); FP_POP(); - + return op_pc; } static uint32_t ropFMULP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -457,7 +457,7 @@ static uint32_t ropFMULP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint FP_ENTER(); FP_OP_REG(FPU_MUL, opcode & 7, 0); FP_POP(); - + return op_pc; } static uint32_t ropFSUBP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -465,7 +465,7 @@ static uint32_t ropFSUBP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint FP_ENTER(); FP_OP_REG(FPU_SUB, opcode & 7, 0); FP_POP(); - + return op_pc; } static uint32_t ropFSUBRP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -473,7 +473,7 @@ static uint32_t ropFSUBRP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin FP_ENTER(); FP_OP_REG(FPU_SUBR, opcode & 7, 0); FP_POP(); - + return op_pc; } @@ -482,18 +482,18 @@ static uint32_t ropFCOMPP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin FP_ENTER(); FP_COMPARE_REG(0, 1); FP_POP2(); - + return op_pc; } static uint32_t ropFSTSW_AX(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg; - + FP_ENTER(); host_reg = LOAD_VAR_W((uintptr_t)&cpu_state.npxs); STORE_REG_TARGET_W_RELEASE(host_reg, REG_AX); - + return op_pc; } @@ -512,7 +512,7 @@ static uint32_t ropFISTw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); CHECK_SEG_WRITE(target_seg); - + MEM_STORE_ADDR_EA_W(target_seg, host_reg); return op_pc + 1; @@ -531,7 +531,7 @@ static uint32_t ropFISTl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); CHECK_SEG_WRITE(target_seg); - + MEM_STORE_ADDR_EA_L(target_seg, host_reg); return op_pc + 1; @@ -540,17 +540,17 @@ static uint32_t ropFISTl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint static uint32_t ropFISTPw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { uint32_t new_pc = ropFISTw(opcode, fetchdat, op_32, op_pc, block); - + FP_POP(); - + return new_pc; } static uint32_t ropFISTPl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { uint32_t new_pc = ropFISTl(opcode, fetchdat, op_32, op_pc, block); - + FP_POP(); - + return new_pc; } static uint32_t ropFISTPq(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -567,11 +567,11 @@ static uint32_t ropFISTPq(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); CHECK_SEG_WRITE(target_seg); - + MEM_STORE_ADDR_EA_Q(target_seg, host_reg1, host_reg2); FP_POP(); - + return op_pc + 1; } @@ -585,11 +585,11 @@ static uint32_t ropFLDCW(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); CHECK_SEG_READ(target_seg); - + MEM_LOAD_ADDR_EA_W(target_seg); STORE_HOST_REG_ADDR_W((uintptr_t)&cpu_state.npxc, 0); UPDATE_NPXC(0); - + return op_pc + 1; } static uint32_t ropFSTCW(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -605,7 +605,7 @@ static uint32_t ropFSTCW(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint host_reg = LOAD_VAR_W((uintptr_t)&cpu_state.npxc); MEM_STORE_ADDR_EA_W(target_seg, host_reg); - + return op_pc + 1; } @@ -614,7 +614,7 @@ static uint32_t ropFCHS(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 { FP_ENTER(); FP_FCHS(); - + return op_pc; } diff --git a/src/codegen/codegen_ops_jump.h b/src/codegen/codegen_ops_jump.h index 0ad293744..54e51f150 100644 --- a/src/codegen/codegen_ops_jump.h +++ b/src/codegen/codegen_ops_jump.h @@ -6,7 +6,7 @@ static uint32_t ropJMP_r8(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin offset |= 0xffffff00; STORE_IMM_ADDR_L((uintptr_t)&cpu_state.pc, op_pc+1+offset); - + return -1; } @@ -15,7 +15,7 @@ static uint32_t ropJMP_r16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui uint16_t offset = fetchdat & 0xffff; STORE_IMM_ADDR_L((uintptr_t)&cpu_state.pc, (op_pc+2+offset) & 0xffff); - + return -1; } @@ -24,7 +24,7 @@ static uint32_t ropJMP_r32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui uint32_t offset = fastreadl(cs + op_pc); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.pc, op_pc+4+offset); - + return -1; } @@ -42,11 +42,11 @@ static uint32_t ropJCXZ(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 TEST_ZERO_JUMP_L(host_reg, op_pc+1+offset, 0); } else - { + { int host_reg = LOAD_REG_W(REG_CX); TEST_ZERO_JUMP_W(host_reg, op_pc+1+offset, 0); } - + return op_pc+1; } @@ -56,7 +56,7 @@ static uint32_t ropLOOP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 if (offset & 0x80) offset |= 0xffffff00; - + if (op_32 & 0x200) { int host_reg = LOAD_REG_L(REG_ECX); @@ -71,7 +71,7 @@ static uint32_t ropLOOP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_REG_W_RELEASE(host_reg); TEST_NONZERO_JUMP_W(host_reg, op_pc+1+offset, 0); } - + return op_pc+1; } @@ -87,10 +87,10 @@ static void BRANCH_COND_B(int pc_offset, uint32_t op_pc, uint32_t offset, int no static void BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { int host_reg; - + switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { - case FLAGS_ZN8: + case FLAGS_ZN8: case FLAGS_ZN16: case FLAGS_ZN32: case FLAGS_ADD8: @@ -120,7 +120,7 @@ static void BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int no else TEST_ZERO_JUMP_L(host_reg, op_pc+pc_offset+offset, timing_bt); break; - + case FLAGS_UNKNOWN: CALL_FUNC((uintptr_t)ZF_SET); if (not) @@ -152,10 +152,10 @@ static void BRANCH_COND_P(int pc_offset, uint32_t op_pc, uint32_t offset, int no static void BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { int host_reg; - + switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { - case FLAGS_ZN8: + case FLAGS_ZN8: case FLAGS_ADD8: case FLAGS_SUB8: case FLAGS_SHL8: @@ -186,7 +186,7 @@ static void BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int no else TEST_NONZERO_JUMP_L(host_reg, op_pc+pc_offset+offset, timing_bt); break; - + case FLAGS_ZN32: case FLAGS_ADD32: case FLAGS_SUB32: @@ -202,7 +202,7 @@ static void BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int no else TEST_NONZERO_JUMP_L(host_reg, op_pc+pc_offset+offset, timing_bt); break; - + case FLAGS_UNKNOWN: CALL_FUNC((uintptr_t)NF_SET); if (not) diff --git a/src/codegen/codegen_ops_logic.h b/src/codegen/codegen_ops_logic.h index c0ffa641a..117b19d97 100644 --- a/src/codegen/codegen_ops_logic.h +++ b/src/codegen/codegen_ops_logic.h @@ -275,9 +275,9 @@ static uint32_t ropAND_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, AND_HOST_REG_IMM(host_reg, (fetchdat & 0xff) | 0xffffff00); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); - STORE_REG_B_RELEASE(host_reg); - + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_REG_B_RELEASE(host_reg); + return op_pc + 1; } static uint32_t ropAND_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -286,9 +286,9 @@ static uint32_t ropAND_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, AND_HOST_REG_IMM(host_reg, (fetchdat & 0xffff) | 0xffff0000); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); - + return op_pc + 2; } static uint32_t ropAND_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -298,9 +298,9 @@ static uint32_t ropAND_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 fetchdat = fastreadl(cs + op_pc); AND_HOST_REG_IMM(host_reg, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); - + return op_pc + 4; } @@ -310,9 +310,9 @@ static uint32_t ropOR_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, OR_HOST_REG_IMM(host_reg, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); - STORE_REG_B_RELEASE(host_reg); - + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_REG_B_RELEASE(host_reg); + return op_pc + 1; } static uint32_t ropOR_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -321,9 +321,9 @@ static uint32_t ropOR_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, OR_HOST_REG_IMM(host_reg, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); - + return op_pc + 2; } static uint32_t ropOR_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -333,9 +333,9 @@ static uint32_t ropOR_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, fetchdat = fastreadl(cs + op_pc); OR_HOST_REG_IMM(host_reg, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); - + return op_pc + 4; } @@ -345,9 +345,9 @@ static uint32_t ropTEST_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 host_reg = TEST_HOST_REG_IMM(host_reg, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); - + return op_pc + 1; } static uint32_t ropTEST_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -356,9 +356,9 @@ static uint32_t ropTEST_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 host_reg = TEST_HOST_REG_IMM(host_reg, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); - + return op_pc + 2; } static uint32_t ropTEST_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -368,9 +368,9 @@ static uint32_t ropTEST_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_3 fetchdat = fastreadl(cs + op_pc); host_reg = TEST_HOST_REG_IMM(host_reg, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); - + return op_pc + 4; } @@ -380,9 +380,9 @@ static uint32_t ropXOR_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, XOR_HOST_REG_IMM(host_reg, fetchdat & 0xff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); - STORE_REG_B_RELEASE(host_reg); - + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_REG_B_RELEASE(host_reg); + return op_pc + 1; } static uint32_t ropXOR_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -391,9 +391,9 @@ static uint32_t ropXOR_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, XOR_HOST_REG_IMM(host_reg, fetchdat & 0xffff); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_W_RELEASE(host_reg); - + return op_pc + 2; } static uint32_t ropXOR_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -403,9 +403,9 @@ static uint32_t ropXOR_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 fetchdat = fastreadl(cs + op_pc); XOR_HOST_REG_IMM(host_reg, fetchdat); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); STORE_REG_L_RELEASE(host_reg); - + return op_pc + 4; } @@ -414,7 +414,7 @@ static uint32_t ropF6(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ x86seg *target_seg; int host_reg; uint8_t imm; - + switch (fetchdat & 0x38) { case 0x00: /*TEST b,#8*/ @@ -433,7 +433,7 @@ static uint32_t ropF6(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ } STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8); host_reg = TEST_HOST_REG_IMM(host_reg, imm); - STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); return op_pc + 2; @@ -457,7 +457,7 @@ static uint32_t ropF6(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg); return op_pc + 1; } - + return 0; } static uint32_t ropF7_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -465,7 +465,7 @@ static uint32_t ropF7_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 x86seg *target_seg; int host_reg; uint16_t imm; - + switch (fetchdat & 0x38) { case 0x00: /*TEST w,#*/ @@ -484,7 +484,7 @@ static uint32_t ropF7_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 } STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16); host_reg = TEST_HOST_REG_IMM(host_reg, imm); - STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); return op_pc + 3; @@ -508,7 +508,7 @@ static uint32_t ropF7_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg); return op_pc + 1; } - + return 0; } static uint32_t ropF7_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -516,7 +516,7 @@ static uint32_t ropF7_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 x86seg *target_seg; int host_reg; uint32_t imm; - + switch (fetchdat & 0x38) { case 0x00: /*TEST l,#*/ @@ -535,7 +535,7 @@ static uint32_t ropF7_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 } STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32); host_reg = TEST_HOST_REG_IMM(host_reg, imm); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); RELEASE_REG(host_reg); return op_pc + 5; @@ -559,6 +559,6 @@ static uint32_t ropF7_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg); return op_pc + 1; } - + return 0; } diff --git a/src/codegen/codegen_ops_misc.h b/src/codegen/codegen_ops_misc.h index bcafccfdb..9438da2d3 100644 --- a/src/codegen/codegen_ops_misc.h +++ b/src/codegen/codegen_ops_misc.h @@ -41,7 +41,7 @@ static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ return 0; CALL_FUNC((uintptr_t)flags_rebuild_c); - + if ((fetchdat & 0xc0) == 0xc0) host_reg = LOAD_REG_B(fetchdat & 7); else @@ -53,7 +53,7 @@ static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ MEM_CHECK_WRITE(target_seg); host_reg = MEM_LOAD_ADDR_EA_B_NO_ABRT(target_seg); } - + switch (fetchdat & 0x38) { case 0x00: /*INC*/ @@ -80,7 +80,7 @@ static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_ MEM_STORE_ADDR_EA_B_NO_ABRT(target_seg, host_reg); } codegen_flags_changed = 1; - + return op_pc + 1; } static uint32_t codegen_temp; @@ -88,7 +88,7 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint { x86seg *target_seg = NULL; int host_reg; - + if ((fetchdat & 0x30) != 0x00 && (fetchdat & 0x08)) return 0; @@ -114,7 +114,7 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint host_reg = MEM_LOAD_ADDR_EA_W_NO_ABRT(target_seg); } } - + switch (fetchdat & 0x38) { case 0x00: /*INC*/ @@ -159,7 +159,7 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint SP_MODIFY(-2); host_reg = LOAD_VAR_W((uintptr_t)&codegen_temp); - STORE_HOST_REG_ADDR_W((uintptr_t)&cpu_state.pc, host_reg); + STORE_HOST_REG_ADDR_W((uintptr_t)&cpu_state.pc, host_reg); return -1; case 0x20: /*JMP*/ @@ -181,13 +181,13 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint { x86seg *target_seg = NULL; int host_reg; - + if ((fetchdat & 0x30) != 0x00 && (fetchdat & 0x08)) return 0; if ((fetchdat & 0x30) == 0x00) CALL_FUNC((uintptr_t)flags_rebuild_c); - + if ((fetchdat & 0xc0) == 0xc0) host_reg = LOAD_REG_L(fetchdat & 7); else @@ -207,7 +207,7 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint host_reg = MEM_LOAD_ADDR_EA_L_NO_ABRT(target_seg); } } - + switch (fetchdat & 0x38) { case 0x00: /*INC*/ @@ -252,7 +252,7 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint SP_MODIFY(-4); host_reg = LOAD_VAR_L((uintptr_t)&codegen_temp); - STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.pc, host_reg); + STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.pc, host_reg); return -1; case 0x20: /*JMP*/ diff --git a/src/codegen/codegen_ops_mmx.h b/src/codegen/codegen_ops_mmx.h index b669567fd..4cdb080fb 100644 --- a/src/codegen/codegen_ops_mmx.h +++ b/src/codegen/codegen_ops_mmx.h @@ -3,9 +3,9 @@ static uint32_t ropMOVQ_q_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, int host_reg1, host_reg2 = 0; MMX_ENTER(); - + LOAD_MMX_Q((fetchdat >> 3) & 7, &host_reg1, &host_reg2); - + if ((fetchdat & 0xc0) == 0xc0) { STORE_MMX_Q(fetchdat & 7, host_reg1, host_reg2); @@ -15,10 +15,10 @@ static uint32_t ropMOVQ_q_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_WRITE(target_seg); CHECK_SEG_LIMITS(target_seg, 7); - + MEM_STORE_ADDR_EA_Q(target_seg, host_reg1, host_reg2); } @@ -28,11 +28,11 @@ static uint32_t ropMOVQ_q_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, static uint32_t ropMOVQ_mm_q(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { MMX_ENTER(); - + if ((fetchdat & 0xc0) == 0xc0) { int host_reg1, host_reg2; - + LOAD_MMX_Q(fetchdat & 7, &host_reg1, &host_reg2); STORE_MMX_Q((fetchdat >> 3) & 7, host_reg1, host_reg2); } @@ -56,9 +56,9 @@ static uint32_t ropMOVD_l_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, int host_reg; MMX_ENTER(); - + host_reg = LOAD_MMX_D((fetchdat >> 3) & 7); - + if ((fetchdat & 0xc0) == 0xc0) { STORE_REG_TARGET_L_RELEASE(host_reg, fetchdat & 7); @@ -68,10 +68,10 @@ static uint32_t ropMOVD_l_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_WRITE(target_seg); CHECK_SEG_LIMITS(target_seg, 3); - + MEM_STORE_ADDR_EA_L(target_seg, host_reg); } @@ -80,7 +80,7 @@ static uint32_t ropMOVD_l_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, static uint32_t ropMOVD_mm_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { MMX_ENTER(); - + if ((fetchdat & 0xc0) == 0xc0) { int host_reg = LOAD_REG_L(fetchdat & 7); @@ -192,9 +192,9 @@ static uint32_t ropPSxxW_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, return 0; if ((fetchdat & 0x08) || !(fetchdat & 0x30)) return 0; - + MMX_ENTER(); - + xmm_dst = LOAD_MMX_Q_MMX(fetchdat & 7); switch (fetchdat & 0x38) { @@ -209,7 +209,7 @@ static uint32_t ropPSxxW_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, break; } STORE_MMX_Q_MMX(fetchdat & 7, xmm_dst); - + return op_pc + 2; } static uint32_t ropPSxxD_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -220,9 +220,9 @@ static uint32_t ropPSxxD_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, return 0; if ((fetchdat & 0x08) || !(fetchdat & 0x30)) return 0; - + MMX_ENTER(); - + xmm_dst = LOAD_MMX_Q_MMX(fetchdat & 7); switch (fetchdat & 0x38) { @@ -237,7 +237,7 @@ static uint32_t ropPSxxD_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, break; } STORE_MMX_Q_MMX(fetchdat & 7, xmm_dst); - + return op_pc + 2; } static uint32_t ropPSxxQ_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -248,9 +248,9 @@ static uint32_t ropPSxxQ_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, return 0; if ((fetchdat & 0x08) || !(fetchdat & 0x30)) return 0; - + MMX_ENTER(); - + xmm_dst = LOAD_MMX_Q_MMX(fetchdat & 7); switch (fetchdat & 0x38) { @@ -265,13 +265,13 @@ static uint32_t ropPSxxQ_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, break; } STORE_MMX_Q_MMX(fetchdat & 7, xmm_dst); - + return op_pc + 2; } static uint32_t ropEMMS(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { codegen_mmx_entered = 0; - + return 0; } diff --git a/src/codegen/codegen_ops_mov.h b/src/codegen/codegen_ops_mov.h index fc4ec1637..df7a6a31b 100644 --- a/src/codegen/codegen_ops_mov.h +++ b/src/codegen/codegen_ops_mov.h @@ -1,7 +1,7 @@ static uint32_t ropMOV_rb_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { STORE_IMM_REG_B(opcode & 7, fetchdat & 0xff); - + return op_pc + 1; } static uint32_t ropMOV_rw_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -15,7 +15,7 @@ static uint32_t ropMOV_rl_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, fetchdat = fastreadl(cs + op_pc); STORE_IMM_REG_L(opcode & 7, fetchdat); - + return op_pc + 4; } @@ -23,7 +23,7 @@ static uint32_t ropMOV_rl_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, static uint32_t ropMOV_b_r(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg = LOAD_REG_B((fetchdat >> 3) & 7); - + if ((fetchdat & 0xc0) == 0xc0) { STORE_REG_TARGET_B_RELEASE(host_reg, fetchdat & 7); @@ -33,20 +33,20 @@ static uint32_t ropMOV_b_r(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_WRITE(target_seg); CHECK_SEG_LIMITS(target_seg, 0); MEM_STORE_ADDR_EA_B(target_seg, host_reg); RELEASE_REG(host_reg); } - + return op_pc + 1; } static uint32_t ropMOV_w_r(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg = LOAD_REG_W((fetchdat >> 3) & 7); - + if ((fetchdat & 0xc0) == 0xc0) { STORE_REG_TARGET_W_RELEASE(host_reg, fetchdat & 7); @@ -56,23 +56,23 @@ static uint32_t ropMOV_w_r(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_WRITE(target_seg); CHECK_SEG_LIMITS(target_seg, 1); MEM_STORE_ADDR_EA_W(target_seg, host_reg); RELEASE_REG(host_reg); } - + return op_pc + 1; } static uint32_t ropMOV_l_r(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int host_reg; - + host_reg = LOAD_REG_L((fetchdat >> 3) & 7); - + if ((fetchdat & 0xc0) == 0xc0) { STORE_REG_TARGET_L_RELEASE(host_reg, fetchdat & 7); @@ -82,13 +82,13 @@ static uint32_t ropMOV_l_r(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_WRITE(target_seg); CHECK_SEG_LIMITS(target_seg, 3); - + MEM_STORE_ADDR_EA_L(target_seg, host_reg); RELEASE_REG(host_reg); - + } return op_pc + 1; @@ -106,13 +106,13 @@ static uint32_t ropMOV_r_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_B(target_seg); STORE_REG_TARGET_B_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } static uint32_t ropMOV_r_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -133,7 +133,7 @@ static uint32_t ropMOV_r_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui MEM_LOAD_ADDR_EA_W(target_seg); STORE_REG_TARGET_W_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } static uint32_t ropMOV_r_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -154,7 +154,7 @@ static uint32_t ropMOV_r_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui MEM_LOAD_ADDR_EA_L(target_seg); STORE_REG_TARGET_L_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } @@ -220,7 +220,7 @@ static uint32_t ropMOV_l_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, MEM_STORE_ADDR_EA_L(target_seg, host_reg); RELEASE_REG(host_reg); } - + return op_pc + 5; } @@ -239,7 +239,7 @@ static uint32_t ropMOV_AL_a(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u MEM_LOAD_ADDR_IMM_B(op_ea_seg, addr); STORE_REG_TARGET_B_RELEASE(0, REG_AL); - + return op_pc + ((op_32 & 0x200) ? 4 : 2); } static uint32_t ropMOV_AX_a(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -256,7 +256,7 @@ static uint32_t ropMOV_AX_a(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u MEM_LOAD_ADDR_IMM_W(op_ea_seg, addr); STORE_REG_TARGET_W_RELEASE(0, REG_AX); - + return op_pc + ((op_32 & 0x200) ? 4 : 2); } static uint32_t ropMOV_EAX_a(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -273,7 +273,7 @@ static uint32_t ropMOV_EAX_a(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, MEM_LOAD_ADDR_IMM_L(op_ea_seg, addr); STORE_REG_TARGET_L_RELEASE(0, REG_EAX); - + return op_pc + ((op_32 & 0x200) ? 4 : 2); } @@ -289,12 +289,12 @@ static uint32_t ropMOV_a_AL(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u CHECK_SEG_WRITE(op_ea_seg); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + host_reg = LOAD_REG_B(REG_AL); MEM_STORE_ADDR_IMM_B(op_ea_seg, addr, host_reg); RELEASE_REG(host_reg); - + return op_pc + ((op_32 & 0x200) ? 4 : 2); } static uint32_t ropMOV_a_AX(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -309,12 +309,12 @@ static uint32_t ropMOV_a_AX(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u CHECK_SEG_WRITE(op_ea_seg); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + host_reg = LOAD_REG_W(REG_AX); MEM_STORE_ADDR_IMM_W(op_ea_seg, addr, host_reg); RELEASE_REG(host_reg); - + return op_pc + ((op_32 & 0x200) ? 4 : 2); } static uint32_t ropMOV_a_EAX(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -329,24 +329,24 @@ static uint32_t ropMOV_a_EAX(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, CHECK_SEG_WRITE(op_ea_seg); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + host_reg = LOAD_REG_L(REG_EAX); MEM_STORE_ADDR_IMM_L(op_ea_seg, addr, host_reg); RELEASE_REG(host_reg); - + return op_pc + ((op_32 & 0x200) ? 4 : 2); } static uint32_t ropLEA_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int dest_reg = (fetchdat >> 3) & 7; - + if ((fetchdat & 0xc0) == 0xc0) return 0; - + FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); - + STORE_REG_TARGET_W_RELEASE(0, dest_reg); return op_pc + 1; @@ -354,12 +354,12 @@ static uint32_t ropLEA_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint static uint32_t ropLEA_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { int dest_reg = (fetchdat >> 3) & 7; - + if ((fetchdat & 0xc0) == 0xc0) return 0; - + FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); - + STORE_REG_TARGET_L_RELEASE(0, dest_reg); return op_pc + 1; @@ -378,14 +378,14 @@ static uint32_t ropMOVZX_w_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_B(target_seg); ZERO_EXTEND_W_B(0); STORE_REG_TARGET_W_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } static uint32_t ropMOVZX_l_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -401,14 +401,14 @@ static uint32_t ropMOVZX_l_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_B(target_seg); ZERO_EXTEND_L_B(0); STORE_REG_TARGET_L_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } static uint32_t ropMOVZX_l_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -424,14 +424,14 @@ static uint32_t ropMOVZX_l_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_W(target_seg); ZERO_EXTEND_L_W(0); STORE_REG_TARGET_L_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } @@ -448,14 +448,14 @@ static uint32_t ropMOVSX_w_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_B(target_seg); SIGN_EXTEND_W_B(0); STORE_REG_TARGET_W_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } static uint32_t ropMOVSX_l_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -471,14 +471,14 @@ static uint32_t ropMOVSX_l_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_B(target_seg); SIGN_EXTEND_L_B(0); STORE_REG_TARGET_L_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } static uint32_t ropMOVSX_l_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -494,14 +494,14 @@ static uint32_t ropMOVSX_l_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_W(target_seg); SIGN_EXTEND_L_W(0); STORE_REG_TARGET_L_RELEASE(0, (fetchdat >> 3) & 7); } - + return op_pc + 1; } @@ -532,7 +532,7 @@ static uint32_t ropMOV_w_seg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, default: return 0; } - + if ((fetchdat & 0xc0) == 0xc0) { if (op_32 & 0x100) @@ -545,14 +545,14 @@ static uint32_t ropMOV_w_seg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, x86seg *target_seg = FETCH_EA(op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + CHECK_SEG_WRITE(target_seg); CHECK_SEG_LIMITS(target_seg, 1); MEM_STORE_ADDR_EA_W(target_seg, host_reg); RELEASE_REG(host_reg); } - + return op_pc + 1; } static uint32_t ropMOV_seg_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -572,7 +572,7 @@ static uint32_t ropMOV_seg_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, } STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc); - + if ((fetchdat & 0xc0) == 0xc0) host_reg = LOAD_REG_W(fetchdat & 7); else @@ -581,10 +581,10 @@ static uint32_t ropMOV_seg_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, CHECK_SEG_READ(target_seg); MEM_LOAD_ADDR_EA_W(target_seg); - + host_reg = 0; } - + switch (fetchdat & 0x38) { case 0x00: /*ES*/ @@ -600,7 +600,7 @@ static uint32_t ropMOV_seg_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, LOAD_SEG(host_reg, &cpu_state.seg_gs); break; } - + return op_pc + 1; } diff --git a/src/codegen/codegen_ops_shift.h b/src/codegen/codegen_ops_shift.h index b67c34544..57a828232 100644 --- a/src/codegen/codegen_ops_shift.h +++ b/src/codegen/codegen_ops_shift.h @@ -67,7 +67,7 @@ static uint32_t ropC1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 return 0; SHIFT(W, 16, STORE_HOST_REG_ADDR_WL, 1); - + return op_pc + 2; } static uint32_t ropC1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -80,7 +80,7 @@ static uint32_t ropC1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 return 0; SHIFT(L, 32, STORE_HOST_REG_ADDR, 1); - + return op_pc + 2; } @@ -107,7 +107,7 @@ static uint32_t ropD1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 return 0; SHIFT(W, 16, STORE_HOST_REG_ADDR_WL, 0); - + return op_pc + 1; } static uint32_t ropD1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -120,6 +120,6 @@ static uint32_t ropD1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3 return 0; SHIFT(L, 32, STORE_HOST_REG_ADDR, 0); - + return op_pc + 1; } diff --git a/src/codegen/codegen_ops_stack.h b/src/codegen/codegen_ops_stack.h index 288be2c6c..d2fc53aad 100644 --- a/src/codegen/codegen_ops_stack.h +++ b/src/codegen/codegen_ops_stack.h @@ -7,7 +7,7 @@ static uint32_t ropPUSH_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui host_reg = LOAD_REG_W(opcode & 7); MEM_STORE_ADDR_EA_W(&cpu_state.seg_ss, host_reg); SP_MODIFY(-2); - + return op_pc; } static uint32_t ropPUSH_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -33,7 +33,7 @@ static uint32_t ropPUSH_imm_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 host_reg = LOAD_REG_IMM(imm); MEM_STORE_ADDR_EA_W(&cpu_state.seg_ss, host_reg); SP_MODIFY(-2); - + return op_pc+2; } static uint32_t ropPUSH_imm_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -46,7 +46,7 @@ static uint32_t ropPUSH_imm_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32 host_reg = LOAD_REG_IMM(imm); MEM_STORE_ADDR_EA_L(&cpu_state.seg_ss, host_reg); SP_MODIFY(-4); - + return op_pc+4; } @@ -63,7 +63,7 @@ static uint32_t ropPUSH_imm_b16(uint8_t opcode, uint32_t fetchdat, uint32_t op_3 host_reg = LOAD_REG_IMM(imm); MEM_STORE_ADDR_EA_W(&cpu_state.seg_ss, host_reg); SP_MODIFY(-2); - + return op_pc+1; } static uint32_t ropPUSH_imm_b32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -79,7 +79,7 @@ static uint32_t ropPUSH_imm_b32(uint8_t opcode, uint32_t fetchdat, uint32_t op_3 host_reg = LOAD_REG_IMM(imm); MEM_STORE_ADDR_EA_L(&cpu_state.seg_ss, host_reg); SP_MODIFY(-4); - + return op_pc+1; } @@ -90,7 +90,7 @@ static uint32_t ropPOP_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin MEM_LOAD_ADDR_EA_W(&cpu_state.seg_ss); SP_MODIFY(2); STORE_REG_TARGET_W_RELEASE(0, opcode & 7); - + return op_pc; } static uint32_t ropPOP_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -100,7 +100,7 @@ static uint32_t ropPOP_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin MEM_LOAD_ADDR_EA_L(&cpu_state.seg_ss); SP_MODIFY(4); STORE_REG_TARGET_L_RELEASE(0, opcode & 7); - + return op_pc; } @@ -111,7 +111,7 @@ static uint32_t ropRET_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin MEM_LOAD_ADDR_EA_W(&cpu_state.seg_ss); STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.pc, 0); SP_MODIFY(2); - + return -1; } static uint32_t ropRET_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -121,7 +121,7 @@ static uint32_t ropRET_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin MEM_LOAD_ADDR_EA_L(&cpu_state.seg_ss); STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.pc, 0); SP_MODIFY(4); - + return -1; } @@ -134,7 +134,7 @@ static uint32_t ropRET_imm_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, MEM_LOAD_ADDR_EA_W(&cpu_state.seg_ss); STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.pc, 0); SP_MODIFY(2+offset); - + return -1; } static uint32_t ropRET_imm_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -146,7 +146,7 @@ static uint32_t ropRET_imm_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, MEM_LOAD_ADDR_EA_L(&cpu_state.seg_ss); STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.pc, 0); SP_MODIFY(4+offset); - + return -1; } @@ -161,7 +161,7 @@ static uint32_t ropCALL_r16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u MEM_STORE_ADDR_EA_W(&cpu_state.seg_ss, host_reg); SP_MODIFY(-2); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.pc, (op_pc+2+offset) & 0xffff); - + return -1; } static uint32_t ropCALL_r32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -175,7 +175,7 @@ static uint32_t ropCALL_r32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u MEM_STORE_ADDR_EA_L(&cpu_state.seg_ss, host_reg); SP_MODIFY(-4); STORE_IMM_ADDR_L((uintptr_t)&cpu_state.pc, op_pc+4+offset); - + return -1; } @@ -204,7 +204,7 @@ static uint32_t ropLEAVE_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u ADD_HOST_REG_IMM(host_reg, 4); STORE_REG_TARGET_L_RELEASE(host_reg, REG_ESP); STORE_REG_TARGET_L_RELEASE(0, REG_EBP); /*EBP = POP_L()*/ - + return op_pc; } diff --git a/src/codegen/codegen_ops_x86-64.h b/src/codegen/codegen_ops_x86-64.h index 9f3f844a4..08d4591ec 100644 --- a/src/codegen/codegen_ops_x86-64.h +++ b/src/codegen/codegen_ops_x86-64.h @@ -16,7 +16,7 @@ static inline int find_host_xmm_reg() if (host_reg_xmm_mapping[c] == -1) break; } - + if (c == HOST_REG_XMM_END) fatal("Out of host XMM regs!\n"); return c; @@ -236,10 +236,10 @@ static inline int LOAD_REG_B(int reg) } codegen_reg_loaded[reg & 3] = 1; - + if (reg & 4) return host_reg | 0x18; - + return host_reg | 8; } static inline int LOAD_REG_W(int reg) @@ -255,7 +255,7 @@ static inline int LOAD_REG_W(int reg) } codegen_reg_loaded[reg & 7] = 1; - + return host_reg | 8; } static inline int LOAD_REG_L(int reg) @@ -271,7 +271,7 @@ static inline int LOAD_REG_L(int reg) } codegen_reg_loaded[reg & 7] = 1; - + return host_reg | 8; } @@ -281,14 +281,14 @@ static inline int LOAD_REG_IMM(uint32_t imm) addbyte(0xb8 | REG_EBX); /*MOVL EBX, imm*/ addlong(imm); - + return host_reg; } static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) { int dest_reg = LOAD_REG_L(guest_reg & 3) & 7; - + if (guest_reg & 4) { if (host_reg & 8) @@ -305,7 +305,7 @@ static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) addbyte(0xc0 | ((host_reg & 3) << 3)); } if (host_reg & 0x10) - { + { addbyte(0x66); /*AND AX, 0xff00*/ addbyte(0x25); addword(0xff00); @@ -382,7 +382,7 @@ static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg) static inline void STORE_REG_TARGET_W_RELEASE(int host_reg, int guest_reg) { int dest_reg = LOAD_REG_L(guest_reg & 7) & 7; - + if (host_reg & 8) { addbyte(0x66); /*MOVW guest_reg, host_reg*/ @@ -555,8 +555,8 @@ static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u int mod = (fetchdat >> 6) & 3; int rm = fetchdat & 7; - if (!mod && rm == 6) - { + if (!mod && rm == 6) + { addbyte(0xb8); /*MOVL EAX, imm*/ addlong((fetchdat >> 8) & 0xffff); (*op_pc) += 2; @@ -564,7 +564,7 @@ static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u else { int base_reg = 0, index_reg = 0; - + switch (rm) { case 0: case 1: case 7: @@ -589,7 +589,7 @@ static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u } base_reg &= 7; index_reg &= 7; - + switch (mod) { case 0: @@ -658,7 +658,7 @@ static x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u } (*op_pc) += 2; break; - + } if (mod || !(rm & 4)) { @@ -745,7 +745,7 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u } } else - { + { switch (mod) { case 0: @@ -823,7 +823,7 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u int base_reg; if (!mod && rm == 5) - { + { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xb8); /*MOVL EAX, new_eaaddr*/ addlong(new_eaaddr); @@ -831,20 +831,20 @@ static x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, u return op_ea_seg; } base_reg = LOAD_REG_L(rm) & 7; - if (mod) + if (mod) { if (rm == 5 && !op_ssegs) op_ea_seg = &cpu_state.seg_ss; - if (mod == 1) + if (mod == 1) { addbyte(0x67); /*LEA EAX, base_reg+imm8*/ addbyte(0x41); addbyte(0x8d); addbyte(0x40 | base_reg); addbyte((fetchdat >> 8) & 0xff); - (*op_pc)++; + (*op_pc)++; } - else + else { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0x67); /*LEA EAX, base_reg+imm32*/ @@ -907,7 +907,7 @@ static inline void CHECK_SEG_READ(x86seg *seg) addbyte(0x0f); /*JE GPF_BLOCK_OFFSET*/ addbyte(0x84); addlong(BLOCK_GPF_OFFSET - (block_pos + 4)); - + seg->checked = 1; } static inline void CHECK_SEG_WRITE(x86seg *seg) @@ -922,7 +922,7 @@ static inline void CHECK_SEG_WRITE(x86seg *seg) return; if (seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) return; - + if (IS_32_ADDR(&seg->base)) { addbyte(0x83); /*CMP seg->base, -1*/ @@ -1740,14 +1740,14 @@ static inline void MEM_STORE_ADDR_IMM_L(x86seg *seg, uint32_t addr, int host_reg static inline void STORE_HOST_REG_ADDR_BL(uintptr_t addr, int host_reg) { int temp_reg = REG_ECX; - + if (host_reg_mapping[REG_ECX] != -1) temp_reg = REG_EBX; - + if (host_reg & 0x10) { if (host_reg & 8) - addbyte(0x41); + addbyte(0x41); addbyte(0x0f); /*MOVZX temp_reg, host_reg*/ addbyte(0xb7); addbyte(0xc0 | (temp_reg << 3) | (host_reg & 7)); @@ -1758,7 +1758,7 @@ static inline void STORE_HOST_REG_ADDR_BL(uintptr_t addr, int host_reg) else { if (host_reg & 8) - addbyte(0x41); + addbyte(0x41); addbyte(0x0f); /*MOVZX temp_reg, host_reg*/ addbyte(0xb6); addbyte(0xc0 | (temp_reg << 3) | (host_reg & 7)); @@ -1788,12 +1788,12 @@ static inline void STORE_HOST_REG_ADDR_BL(uintptr_t addr, int host_reg) static inline void STORE_HOST_REG_ADDR_WL(uintptr_t addr, int host_reg) { int temp_reg = REG_ECX; - + if (host_reg_mapping[REG_ECX] != -1) temp_reg = REG_EBX; - + if (host_reg & 8) - addbyte(0x41); + addbyte(0x41); addbyte(0x0f); /*MOVZX temp_reg, host_reg*/ addbyte(0xb7); addbyte(0xc0 | (temp_reg << 3) | (host_reg & 7)); @@ -1980,7 +1980,7 @@ static inline void AND_HOST_REG_B(int dst_reg, int src_reg) addbyte(0x44); /*ANDB dst_reg, src_reg*/ addbyte(0x20); addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } else { @@ -2005,7 +2005,7 @@ static inline void AND_HOST_REG_B(int dst_reg, int src_reg) { addbyte(0x20); /*ANDB dst_reg, src_reg*/ addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } } static inline void AND_HOST_REG_W(int dst_reg, int src_reg) @@ -2092,12 +2092,12 @@ static inline int TEST_HOST_REG_B(int dst_reg, int src_reg) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((dst_reg & 7) << 3) | REG_EDX); - + dst_reg = (dst_reg & 0x10) | REG_EDX; } - + AND_HOST_REG_B(dst_reg, src_reg); - + return dst_reg & ~0x10; } static inline int TEST_HOST_REG_W(int dst_reg, int src_reg) @@ -2107,12 +2107,12 @@ static inline int TEST_HOST_REG_W(int dst_reg, int src_reg) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((dst_reg & 7) << 3) | REG_EDX); - + dst_reg = REG_EDX; } - + AND_HOST_REG_W(dst_reg, src_reg); - + return dst_reg; } static inline int TEST_HOST_REG_L(int dst_reg, int src_reg) @@ -2122,12 +2122,12 @@ static inline int TEST_HOST_REG_L(int dst_reg, int src_reg) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((dst_reg & 7) << 3) | REG_EDX); - + dst_reg = REG_EDX; } - + AND_HOST_REG_L(dst_reg, src_reg); - + return dst_reg; } static inline int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) @@ -2152,7 +2152,7 @@ static inline int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) addbyte(0xe0 | (host_reg & 7)); addlong(imm); } - + return host_reg; } @@ -2250,7 +2250,7 @@ static inline void OR_HOST_REG_B(int dst_reg, int src_reg) addbyte(0x44); /*ORB dst_reg, src_reg*/ addbyte(0x08); addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } else { @@ -2275,7 +2275,7 @@ static inline void OR_HOST_REG_B(int dst_reg, int src_reg) { addbyte(0x08); /*ORB dst_reg, src_reg*/ addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } } static inline void OR_HOST_REG_W(int dst_reg, int src_reg) @@ -2453,7 +2453,7 @@ static inline void XOR_HOST_REG_B(int dst_reg, int src_reg) addbyte(0x44); /*XORB dst_reg, src_reg*/ addbyte(0x30); addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } else { @@ -2478,7 +2478,7 @@ static inline void XOR_HOST_REG_B(int dst_reg, int src_reg) { addbyte(0x30); /*XORB dst_reg, src_reg*/ addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } } static inline void XOR_HOST_REG_W(int dst_reg, int src_reg) @@ -2800,7 +2800,7 @@ static inline void SUB_HOST_REG_B(int dst_reg, int src_reg) addbyte(0x44); /*SUBB dst_reg, src_reg*/ addbyte(0x28); addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } else { @@ -2825,7 +2825,7 @@ static inline void SUB_HOST_REG_B(int dst_reg, int src_reg) { addbyte(0x28); /*SUBB dst_reg, src_reg*/ addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3)); - } + } } } static inline void SUB_HOST_REG_W(int dst_reg, int src_reg) @@ -2892,12 +2892,12 @@ static inline int CMP_HOST_REG_B(int dst_reg, int src_reg) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((dst_reg & 7) << 3) | REG_EDX); - + dst_reg = (dst_reg & 0x10) | REG_EDX; } - + SUB_HOST_REG_B(dst_reg, src_reg); - + return dst_reg & ~0x10; } static inline int CMP_HOST_REG_W(int dst_reg, int src_reg) @@ -2907,12 +2907,12 @@ static inline int CMP_HOST_REG_W(int dst_reg, int src_reg) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((dst_reg & 7) << 3) | REG_EDX); - + dst_reg = REG_EDX; } - + SUB_HOST_REG_W(dst_reg, src_reg); - + return dst_reg; } static inline int CMP_HOST_REG_L(int dst_reg, int src_reg) @@ -2922,12 +2922,12 @@ static inline int CMP_HOST_REG_L(int dst_reg, int src_reg) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((dst_reg & 7) << 3) | REG_EDX); - + dst_reg = REG_EDX; } - + SUB_HOST_REG_L(dst_reg, src_reg); - + return dst_reg; } @@ -3045,12 +3045,12 @@ static inline int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((host_reg & 7) << 3) | REG_EDX); - + host_reg = (host_reg & 0x10) | REG_EDX; } - + SUB_HOST_REG_IMM_B(host_reg, imm); - + return host_reg; } static inline int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) @@ -3060,12 +3060,12 @@ static inline int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((host_reg & 7) << 3) | REG_EDX); - + host_reg = REG_EDX; } - + SUB_HOST_REG_IMM_W(host_reg, imm); - + return host_reg; } static inline int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) @@ -3075,12 +3075,12 @@ static inline int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) addbyte(0x44); /*MOV EDX, dst_reg*/ addbyte(0x89); addbyte(0xc0 | ((host_reg & 7) << 3) | REG_EDX); - + host_reg = REG_EDX; } - + SUB_HOST_REG_IMM(host_reg, imm); - + return host_reg; } @@ -3280,7 +3280,7 @@ static inline void TEST_NONZERO_JUMP_L(int host_reg, uint32_t new_pc, int taken_ static inline void BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset, int not) { uint8_t *jump1; - + if (codegen_flags_changed && cpu_state.flags_op != FLAGS_UNKNOWN) { addbyte(0x83); /*CMP flags_res, 0*/ @@ -3305,7 +3305,7 @@ static inline void BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset addbyte(0x75); /*JNZ +*/ else addbyte(0x74); /*JZ +*/ - addbyte(7+5+(timing_bt ? 4 : 0)); + addbyte(7+5+(timing_bt ? 4 : 0)); if (!not) *jump1 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump1 - 1; @@ -3346,7 +3346,7 @@ static inline void BRANCH_COND_L(int pc_offset, uint32_t op_pc, uint32_t offset, addbyte(0x75); /*JNZ +*/ else addbyte(0x74); /*JZ +*/ - addbyte(7+5+(timing_bt ? 4 : 0)); + addbyte(7+5+(timing_bt ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(pc)); @@ -3400,7 +3400,7 @@ static inline void BRANCH_COND_LE(int pc_offset, uint32_t op_pc, uint32_t offset addbyte(0x75); /*JNZ +*/ else addbyte(0x74); /*JZ +*/ - addbyte(7+5+(timing_bt ? 4 : 0)); + addbyte(7+5+(timing_bt ? 4 : 0)); if (!not) *jump1 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump1 - 1; addbyte(0xC7); /*MOVL [pc], new_pc*/ @@ -3490,7 +3490,7 @@ static inline int COPY_REG(int src_reg) addbyte(0x44); addbyte(0x89); addbyte(0xc0 | REG_ECX | ((src_reg & 7) << 3)); - + return REG_ECX | (src_reg & 0x10); } @@ -3500,7 +3500,7 @@ static inline int LOAD_HOST_REG(int host_reg) addbyte(0x44); addbyte(0x89); addbyte(0xc0 | REG_EBX | ((host_reg & 7) << 3)); - + return REG_EBX | (host_reg & 0x10); } @@ -3514,16 +3514,16 @@ static inline int ZERO_EXTEND_W_B(int reg) addbyte(0x0f); /*MOVZX EAX, AH*/ addbyte(0xb6); addbyte(0xc4); - + return REG_EAX; } - + if (reg & 8) addbyte(0x41); addbyte(0x0f); /*MOVZX regl, regb*/ addbyte(0xb6); addbyte(0xc0 | (reg & 7)); - + return REG_EAX; } static inline int ZERO_EXTEND_L_B(int reg) @@ -3536,7 +3536,7 @@ static inline int ZERO_EXTEND_L_B(int reg) addbyte(0x0f); /*MOVZX EAX, AH*/ addbyte(0xb6); addbyte(0xc4); - + return REG_EAX; } @@ -3545,7 +3545,7 @@ static inline int ZERO_EXTEND_L_B(int reg) addbyte(0x0f); /*MOVZX regl, regb*/ addbyte(0xb6); addbyte(0xc0 | (reg & 7)); - + return REG_EAX; } static inline int ZERO_EXTEND_L_W(int reg) @@ -3555,7 +3555,7 @@ static inline int ZERO_EXTEND_L_W(int reg) addbyte(0x0f); /*MOVZX regl, regw*/ addbyte(0xb7); addbyte(0xc0 | (reg & 7)); - + return REG_EAX; } @@ -3569,7 +3569,7 @@ static inline int SIGN_EXTEND_W_B(int reg) addbyte(0x0f); /*MOVSX EAX, AH*/ addbyte(0xbe); addbyte(0xc4); - + return REG_EAX; } @@ -3578,7 +3578,7 @@ static inline int SIGN_EXTEND_W_B(int reg) addbyte(0x0f); /*MOVSX regl, regb*/ addbyte(0xbe); addbyte(0xc0 | (reg & 7)); - + return REG_EAX; } static inline int SIGN_EXTEND_L_B(int reg) @@ -3591,7 +3591,7 @@ static inline int SIGN_EXTEND_L_B(int reg) addbyte(0x0f); /*MOVSX EAX, AH*/ addbyte(0xbe); addbyte(0xc4); - + return REG_EAX; } @@ -3600,7 +3600,7 @@ static inline int SIGN_EXTEND_L_B(int reg) addbyte(0x0f); /*MOVSX regl, regb*/ addbyte(0xbe); addbyte(0xc0 | (reg & 7)); - + return REG_EAX; } static inline int SIGN_EXTEND_L_W(int reg) @@ -3610,7 +3610,7 @@ static inline int SIGN_EXTEND_L_W(int reg) addbyte(0x0f); /*MOVSX regl, regw*/ addbyte(0xbf); addbyte(0xc0 | (reg & 7)); - + return REG_EAX; } @@ -3773,7 +3773,7 @@ static inline void NEG_HOST_REG_L(int reg) addbyte(0xf7); addbyte(0xd8 | (reg & 7)); } - + static inline void FP_ENTER() { @@ -3806,7 +3806,7 @@ static inline void FP_ENTER() CALL_FUNC((uintptr_t)x86_int); addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); - + codegen_fpu_entered = 1; } @@ -3844,7 +3844,7 @@ static inline void FP_FXCH(int reg) addbyte(0x4c); addbyte(0xdd); addbyte((uint8_t)cpu_state_offset(ST)); - + addbyte(0x8a); /*MOV CL, tag[EAX]*/ addbyte(0x4c); addbyte(0x05); @@ -3910,7 +3910,7 @@ static inline void FP_FLD(int reg) addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(0x01); - } + } addbyte(0x48); /*MOV RCX, ST[EAX*8]*/ addbyte(0x8b); @@ -4288,8 +4288,8 @@ static inline int FP_LOAD_REG(int reg) addbyte(0x66); /*MOVD EBX, XMM0*/ addbyte(0x0f); addbyte(0x7e); - addbyte(0xc0 | REG_EBX); - + addbyte(0xc0 | REG_EBX); + return REG_EBX; } static inline void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) @@ -4311,13 +4311,13 @@ static inline void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) addbyte(0x5c); addbyte(0xdd); addbyte((uint8_t)cpu_state_offset(ST)); - + *host_reg1 = REG_EBX; } static inline int64_t x87_fround16_64(double b) { int16_t a, c; - + switch ((cpu_state.npxc >> 10) & 3) { case 0: /*Nearest*/ @@ -4336,13 +4336,13 @@ static inline int64_t x87_fround16_64(double b) case 3: /*Chop*/ return (int64_t)((int16_t)b); } - + return 0; } static inline int64_t x87_fround32_64(double b) { int32_t a, c; - + switch ((cpu_state.npxc >> 10) & 3) { case 0: /*Nearest*/ @@ -4361,13 +4361,13 @@ static inline int64_t x87_fround32_64(double b) case 3: /*Chop*/ return (int64_t)((int32_t)b); } - + return 0; } static inline int64_t x87_fround(double b) { int64_t a, c; - + switch ((cpu_state.npxc >> 10) & 3) { case 0: /*Nearest*/ @@ -4386,7 +4386,7 @@ static inline int64_t x87_fround(double b) case 3: /*Chop*/ return (int64_t)b; } - + return 0; } static inline int FP_LOAD_REG_INT_W(int reg) @@ -4414,9 +4414,9 @@ static inline int FP_LOAD_REG_INT_W(int reg) addbyte((uint8_t)cpu_state_offset(ST)); CALL_FUNC((uintptr_t)x87_fround16_64); - + addbyte(0x93); /*XCHG EBX, EAX*/ - + return REG_EBX; } static inline int FP_LOAD_REG_INT(int reg) @@ -4444,9 +4444,9 @@ static inline int FP_LOAD_REG_INT(int reg) addbyte((uint8_t)cpu_state_offset(ST)); CALL_FUNC((uintptr_t)x87_fround32_64); - + addbyte(0x93); /*XCHG EBX, EAX*/ - + return REG_EBX; } static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) @@ -4482,16 +4482,16 @@ static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x93); *host_reg1 = REG_EBX; - + return; } - + addbyte(0xf6); /*TEST TAG[EAX], TAG_UINT64*/ addbyte(0x44); addbyte(0x05); addbyte((uint8_t)cpu_state_offset(tag)); addbyte(TAG_UINT64); - + addbyte(0x74); /*JZ +*/ addbyte(5+2); @@ -4500,7 +4500,7 @@ static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x44); addbyte(0xc5); addbyte((uint8_t)cpu_state_offset(MM)); - + addbyte(0xeb); /*JMP done*/ addbyte(6+12); @@ -4512,10 +4512,10 @@ static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte((uint8_t)cpu_state_offset(ST)); CALL_FUNC((uintptr_t)x87_fround); - + addbyte(0x48); /*XCHG RBX, RAX*/ addbyte(0x93); - + *host_reg1 = REG_EBX; } @@ -5015,7 +5015,7 @@ static inline void MMX_ENTER() { if (codegen_mmx_entered) return; - + if (IS_32_ADDR(&cr0)) { addbyte(0xf6); /*TEST cr0, 0xc*/ @@ -5044,7 +5044,7 @@ static inline void MMX_ENTER() addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); - + addbyte(0x31); /*XOR EAX, EAX*/ addbyte(0xc0); addbyte(0xc6); /*MOV ISMMX, 1*/ @@ -5054,7 +5054,7 @@ static inline void MMX_ENTER() addbyte(0x89); /*MOV TOP, EAX*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(TOP)); - addbyte(0x89); /*MOV tag, EAX*/ + addbyte(0x89); /*MOV tag, EAX*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x89); /*MOV tag+4, EAX*/ @@ -5074,7 +5074,7 @@ static inline int LOAD_MMX_D(int guest_reg) addbyte(0x44 | (host_reg << 3)); addbyte(0x25); addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); - + return host_reg; } static inline void LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) @@ -5089,7 +5089,7 @@ static inline void LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) addbyte(0x44 | ((host_reg & 7) << 3)); addbyte(0x25); addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); - + *host_reg1 = host_reg; } static inline int LOAD_MMX_Q_MMX(int guest_reg) @@ -5103,7 +5103,7 @@ static inline int LOAD_MMX_Q_MMX(int guest_reg) addbyte(0x44 | ((dst_reg & 7) << 3)); addbyte(0x25); addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); - + return dst_reg; } @@ -5111,7 +5111,7 @@ static inline int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) { int dst_reg = find_host_xmm_reg(); host_reg_xmm_mapping[dst_reg] = 100; - + addbyte(0x66); /*MOVQ host_reg, src_reg1*/ if (src_reg1 & 8) addbyte(0x49); @@ -5120,7 +5120,7 @@ static inline int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) addbyte(0x0f); addbyte(0x6e); addbyte(0xc0 | (dst_reg << 3) | (src_reg1 & 7)); - + return dst_reg; } @@ -5382,7 +5382,7 @@ static inline void LOAD_EA() static inline void MEM_CHECK_WRITE(x86seg *seg) { uint8_t *jump1, *jump2, *jump3 = NULL; - + CHECK_SEG_WRITE(seg); if ((seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) || (seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS))) @@ -5408,7 +5408,7 @@ static inline void MEM_CHECK_WRITE(x86seg *seg) /*seg = ESI, addr = EAX*/ - + if (IS_32_ADDR(&cr0)) { addbyte(0x83); /*CMP cr0, 0*/ @@ -5468,7 +5468,7 @@ static inline void MEM_CHECK_WRITE(x86seg *seg) addbyte(0); if (!(seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) && !(seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS))) - *jump3 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump3 - 1; + *jump3 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump3 - 1; /*slowpath:*/ addbyte(0x67); /*LEA EDI, [EAX+ESI]*/ addbyte(0x8d); @@ -5497,7 +5497,7 @@ static inline void MEM_CHECK_WRITE_W(x86seg *seg) { uint8_t *jump1, *jump2, *jump3, *jump4 = NULL; int jump_pos; - + CHECK_SEG_WRITE(seg); if ((seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) || (seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS))) @@ -5523,7 +5523,7 @@ static inline void MEM_CHECK_WRITE_W(x86seg *seg) /*seg = ESI, addr = EAX*/ - + if (IS_32_ADDR(&cr0)) { addbyte(0x83); /*CMP cr0, 0*/ @@ -5610,7 +5610,7 @@ static inline void MEM_CHECK_WRITE_W(x86seg *seg) addbyte(0x75); /*JNE +*/ jump3 = &codeblock[block_current].data[block_pos]; addbyte(0); - + /*slowpath:*/ *jump2 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump2 - 1; if (!(seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) && !(seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS))) @@ -5646,7 +5646,7 @@ static inline void MEM_CHECK_WRITE_L(x86seg *seg) { uint8_t *jump1, *jump2, *jump3, *jump4 = NULL; int jump_pos; - + CHECK_SEG_WRITE(seg); if ((seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) || (seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS))) @@ -5672,7 +5672,7 @@ static inline void MEM_CHECK_WRITE_L(x86seg *seg) /*seg = ESI, addr = EAX*/ - + if (IS_32_ADDR(&cr0)) { addbyte(0x83); /*CMP cr0, 0*/ @@ -5759,7 +5759,7 @@ static inline void MEM_CHECK_WRITE_L(x86seg *seg) addbyte(0x75); /*JNE +*/ jump3 = &codeblock[block_current].data[block_pos]; addbyte(0); - + /*slowpath:*/ *jump2 = (uintptr_t)&codeblock[block_current].data[block_pos] - (uintptr_t)jump2 - 1; if (!(seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) && !(seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS))) @@ -5861,7 +5861,7 @@ static inline int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) /*done:*/ host_reg_mapping[REG_ECX] = 8; - + return REG_ECX; } static inline int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) @@ -5940,7 +5940,7 @@ static inline int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) /*done:*/ host_reg_mapping[REG_ECX] = 8; - + return REG_ECX; } static inline int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) @@ -6018,7 +6018,7 @@ static inline int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) /*done:*/ host_reg_mapping[REG_ECX] = 8; - + return REG_ECX; } diff --git a/src/codegen/codegen_ops_x86.h b/src/codegen/codegen_ops_x86.h index c4a9cbd47..35bdeb5ff 100644 --- a/src/codegen/codegen_ops_x86.h +++ b/src/codegen/codegen_ops_x86.h @@ -16,7 +16,7 @@ static inline int find_host_reg() if (host_reg_mapping[c] == -1) break; } - + if (c == NR_HOST_REGS) fatal("Out of host regs!\n"); return c; @@ -29,7 +29,7 @@ static inline int find_host_xmm_reg() if (host_reg_xmm_mapping[c] == -1) break; } - + if (c == HOST_REG_XMM_END) fatal("Out of host XMM regs!\n"); return c; @@ -151,12 +151,12 @@ static inline int LOAD_VAR_WL(uintptr_t addr) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = 0; - + addbyte(0x0f); /*MOVZX host_reg, [addr]*/ addbyte(0xb7); addbyte(0x05 | (host_reg << 3)); addlong((uint32_t)addr); - + return host_reg; } static inline int LOAD_VAR_L(uintptr_t addr) @@ -175,11 +175,11 @@ static inline int LOAD_REG_IMM(uint32_t imm) { int host_reg = find_host_reg(); host_reg_mapping[host_reg] = 0; - + addbyte(0xc7); /*MOVL host_reg, imm*/ addbyte(0xc0 | host_reg); addlong(imm); - + return host_reg; } @@ -187,10 +187,10 @@ static inline int LOAD_HOST_REG(int host_reg) { int new_host_reg = find_host_reg(); host_reg_mapping[new_host_reg] = 0; - + addbyte(0x89); /*MOV new_host_reg, host_reg*/ addbyte(0xc0 | (host_reg << 3) | new_host_reg); - + return new_host_reg; } @@ -366,25 +366,25 @@ static inline void AND_HOST_REG_IMM(int host_reg, uint32_t imm) static inline int TEST_HOST_REG_B(int dst_reg, int src_reg) { AND_HOST_REG_B(dst_reg, src_reg); - + return dst_reg; } static inline int TEST_HOST_REG_W(int dst_reg, int src_reg) { AND_HOST_REG_W(dst_reg, src_reg); - + return dst_reg; } static inline int TEST_HOST_REG_L(int dst_reg, int src_reg) { AND_HOST_REG_L(dst_reg, src_reg); - + return dst_reg; } static inline int TEST_HOST_REG_IMM(int host_reg, uint32_t imm) { AND_HOST_REG_IMM(host_reg, imm); - + return host_reg; } @@ -505,37 +505,37 @@ static inline void DEC_HOST_REG(int host_reg) static inline int CMP_HOST_REG_B(int dst_reg, int src_reg) { SUB_HOST_REG_B(dst_reg, src_reg); - + return dst_reg; } static inline int CMP_HOST_REG_W(int dst_reg, int src_reg) { SUB_HOST_REG_W(dst_reg, src_reg); - + return dst_reg; } static inline int CMP_HOST_REG_L(int dst_reg, int src_reg) { SUB_HOST_REG_L(dst_reg, src_reg); - + return dst_reg; } static inline int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm) { SUB_HOST_REG_IMM_B(host_reg, imm); - + return host_reg; } static inline int CMP_HOST_REG_IMM_W(int host_reg, uint16_t imm) { SUB_HOST_REG_IMM_W(host_reg, imm); - + return host_reg; } static inline int CMP_HOST_REG_IMM_L(int host_reg, uint32_t imm) { SUB_HOST_REG_IMM(host_reg, imm); - + return host_reg; } @@ -647,7 +647,7 @@ static inline void CHECK_SEG_READ(x86seg *seg) addbyte(0x0f); addbyte(0x84); /*JE BLOCK_GPF_OFFSET*/ addlong(BLOCK_GPF_OFFSET - (block_pos + 4)); - + seg->checked = 1; } static inline void CHECK_SEG_WRITE(x86seg *seg) @@ -662,7 +662,7 @@ static inline void CHECK_SEG_WRITE(x86seg *seg) return; if (seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) return; - + addbyte(0x83); /*CMP seg->base, -1*/ addbyte(0x05|0x38); addlong((uint32_t)&seg->base); @@ -736,7 +736,7 @@ static inline int MEM_LOAD_ADDR_EA_B_NO_ABRT(x86seg *seg) addlong(mem_load_addr_ea_b_no_abrt - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); host_reg_mapping[REG_ECX] = 8; - + return REG_ECX; } static inline void MEM_LOAD_ADDR_EA_W(x86seg *seg) @@ -795,7 +795,7 @@ static inline int MEM_LOAD_ADDR_EA_W_NO_ABRT(x86seg *seg) addlong(mem_load_addr_ea_w_no_abrt - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); host_reg_mapping[REG_ECX] = 8; - + return REG_ECX; } static inline void MEM_LOAD_ADDR_EA_L(x86seg *seg) @@ -834,7 +834,7 @@ static inline int MEM_LOAD_ADDR_EA_L_NO_ABRT(x86seg *seg) addlong(mem_load_addr_ea_l_no_abrt - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); host_reg_mapping[REG_ECX] = 8; - + return REG_ECX; } @@ -1053,8 +1053,8 @@ static inline x86seg *FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_s { int mod = (fetchdat >> 6) & 3; int rm = fetchdat & 7; - if (!mod && rm == 6) - { + if (!mod && rm == 6) + { addbyte(0xb8); /*MOVL EAX, imm16*/ addlong((fetchdat >> 8) & 0xffff); (*op_pc) += 2; @@ -1121,7 +1121,7 @@ static inline x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_s { uint8_t sib = fetchdat >> 8; (*op_pc)++; - + switch (mod) { case 0: @@ -1139,7 +1139,7 @@ static inline x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_s addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); } break; - case 1: + case 1: addbyte(0x8b); /*MOVL EAX, regs[sib&7].l*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); @@ -1204,7 +1204,7 @@ static inline x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_s else { if (!mod && rm == 5) - { + { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xb8); /*MOVL EAX, imm32*/ addlong(new_eaaddr); @@ -1215,22 +1215,22 @@ static inline x86seg *FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_s addbyte(0x45); addbyte((uint8_t)cpu_state_offset(regs[rm].l)); cpu_state.eaaddr = cpu_state.regs[rm].l; - if (mod) + if (mod) { if (rm == 5 && !op_ssegs) op_ea_seg = &cpu_state.seg_ss; - if (mod == 1) + if (mod == 1) { addbyte(0x83); /*ADD EAX, imm8*/ addbyte(0xc0 | REG_EAX); - addbyte((int8_t)(fetchdat >> 8)); - (*op_pc)++; + addbyte((int8_t)(fetchdat >> 8)); + (*op_pc)++; } - else + else { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0x05); /*ADD EAX, imm32*/ - addlong(new_eaaddr); + addlong(new_eaaddr); (*op_pc) += 4; } } @@ -1475,7 +1475,7 @@ static inline void BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset else addbyte(0x77); /*JNBE*/ break; - + default: if (codegen_flags_changed && cpu_state.flags_op != FLAGS_UNKNOWN) { @@ -1505,7 +1505,7 @@ static inline void BRANCH_COND_BE(int pc_offset, uint32_t op_pc, uint32_t offset addbyte(0x74); /*JZ +*/ break; } - addbyte(7+5+(timing_bt ? 4 : 0)); + addbyte(7+5+(timing_bt ? 4 : 0)); addbyte(0xC7); /*MOVL [pc], new_pc*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(pc)); @@ -1706,7 +1706,7 @@ static inline void FP_ENTER() { if (codegen_fpu_entered) return; - + addbyte(0xf6); /*TEST cr0, 0xc*/ addbyte(0x05); addlong((uintptr_t)&cr0); @@ -1725,7 +1725,7 @@ static inline void FP_ENTER() addlong((uint32_t)x86_int - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); - + codegen_fpu_entered = 1; } @@ -1788,7 +1788,7 @@ static inline void FP_FLD(int reg) addbyte(0x83); /*SUB EBX, 1*/ addbyte(0xeb); addbyte(0x01); - } + } addbyte(0xdd); /*FLD [ST+EAX*8]*/ addbyte(0x44); @@ -2425,7 +2425,7 @@ static inline int FP_LOAD_REG(int reg) addbyte(0x8b); /*MOV EAX, [ESP]*/ addbyte(0x04 | (REG_EBX << 3)); addbyte(0x24); - + return REG_EBX; } @@ -2466,7 +2466,7 @@ static inline void FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2) addbyte(0x44 | (REG_ECX << 3)); addbyte(0x24); addbyte(0x04); - + *host_reg1 = REG_EBX; *host_reg2 = REG_ECX; } @@ -2489,7 +2489,7 @@ static inline int FP_LOAD_REG_INT_W(int reg) addbyte(0x44); addbyte(0xdd); addbyte((uint8_t)cpu_state_offset(ST)); - + addbyte(0xd9); /*FLDCW cpu_state.new_npxc*/ addbyte(0x6d); addbyte((uint8_t)cpu_state_offset(new_npxc)); @@ -2566,10 +2566,10 @@ static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x5c); addbyte(0xdd); addbyte((uint8_t)cpu_state_offset(MM)); - + return; } - + addbyte(0xf6); /*TEST TAG[EBX], TAG_UINT64*/ addbyte(0x44); addbyte(0x1d); @@ -2586,10 +2586,10 @@ static inline void FP_LOAD_REG_INT_Q(int reg, int *host_reg1, int *host_reg2) addbyte(0x5c); addbyte(0xdd); addbyte((uint8_t)cpu_state_offset(MM)); - + addbyte(0xeb); /*JMP done*/ addbyte(4+3+3+3+3+4); - + addbyte(0xdd); /*FLD ST[EBX*8]*/ addbyte(0x44); addbyte(0xdd); @@ -2816,7 +2816,7 @@ static inline void FP_OP_D(int op) addbyte(0x6d); addbyte((uint8_t)cpu_state_offset(old_npxc)); } - } + } } static inline void FP_OP_IW(int op) { @@ -3576,7 +3576,7 @@ static inline void MMX_ENTER() { if (codegen_mmx_entered) return; - + addbyte(0xf6); /*TEST cr0, 0xc*/ addbyte(0x05); addlong((uintptr_t)&cr0); @@ -3595,7 +3595,7 @@ static inline void MMX_ENTER() addlong((uint32_t)x86_int - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); addbyte(0xe9); /*JMP end*/ addlong(BLOCK_EXIT_OFFSET - (block_pos + 4)); - + addbyte(0x31); /*XOR EAX, EAX*/ addbyte(0xc0); addbyte(0xc6); /*MOV ISMMX, 1*/ @@ -3605,7 +3605,7 @@ static inline void MMX_ENTER() addbyte(0x89); /*MOV TOP, EAX*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(TOP)); - addbyte(0x89); /*MOV tag, EAX*/ + addbyte(0x89); /*MOV tag, EAX*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(tag[0])); addbyte(0x89); /*MOV tag+4, EAX*/ @@ -3625,7 +3625,7 @@ static inline int LOAD_MMX_D(int guest_reg) addbyte(0x8b); /*MOV EBX, reg*/ addbyte(0x45 | (host_reg << 3)); addbyte((uint8_t)cpu_state_offset(MM[guest_reg].l[0])); - + return host_reg; } static inline void LOAD_MMX_Q(int guest_reg, int *host_reg1, int *host_reg2) @@ -3659,7 +3659,7 @@ static inline int LOAD_MMX_Q_MMX(int guest_reg) addbyte(0x7e); addbyte(0x45 | (dst_reg << 3)); addbyte((uint8_t)cpu_state_offset(MM[guest_reg].q)); - + return dst_reg; } @@ -3667,7 +3667,7 @@ static inline int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) { int dst_reg = find_host_xmm_reg(); host_reg_xmm_mapping[dst_reg] = 100; - + addbyte(0x66); /*MOVD dst_reg, src_reg1*/ addbyte(0x0f); addbyte(0x6e); @@ -3680,7 +3680,7 @@ static inline int LOAD_INT_TO_MMX(int src_reg1, int src_reg2) addbyte(0x0f); addbyte(0x62); addbyte(0xc0 | 7 | (dst_reg << 3)); - + return dst_reg; } diff --git a/src/codegen/codegen_ops_xchg.h b/src/codegen/codegen_ops_xchg.h index 76cb9e437..a51f42eda 100644 --- a/src/codegen/codegen_ops_xchg.h +++ b/src/codegen/codegen_ops_xchg.h @@ -54,7 +54,7 @@ static uint32_t ropXCHG_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin temp_reg = COPY_REG(src_reg); STORE_REG_TARGET_B_RELEASE(dst_reg, (fetchdat >> 3) & 7); STORE_REG_TARGET_B_RELEASE(temp_reg, fetchdat & 7); - + return op_pc + 1; } static uint32_t ropXCHG_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -69,7 +69,7 @@ static uint32_t ropXCHG_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin temp_reg = COPY_REG(src_reg); STORE_REG_TARGET_W_RELEASE(dst_reg, (fetchdat >> 3) & 7); STORE_REG_TARGET_W_RELEASE(temp_reg, fetchdat & 7); - + return op_pc + 1; } static uint32_t ropXCHG_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) @@ -84,6 +84,6 @@ static uint32_t ropXCHG_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin temp_reg = COPY_REG(src_reg); STORE_REG_TARGET_L_RELEASE(dst_reg, (fetchdat >> 3) & 7); STORE_REG_TARGET_L_RELEASE(temp_reg, fetchdat & 7); - + return op_pc + 1; } diff --git a/src/codegen/codegen_x86-64.c b/src/codegen/codegen_x86-64.c index ff1e1c682..a1d4ba07c 100644 --- a/src/codegen/codegen_x86-64.c +++ b/src/codegen/codegen_x86-64.c @@ -63,7 +63,7 @@ static int last_ssegs; void codegen_init() { int c; - + #if _WIN64 codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); #elif defined(__unix__) || defined(__APPLE__) @@ -83,7 +83,7 @@ void codegen_init() void codegen_reset() { int c; - + memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); mem_reset_page_blocks(); @@ -120,7 +120,7 @@ static void add_to_block_list(codeblock_t *block) if (block->next->valid == 0) fatal("block->next->valid=0 %p %p %x %x\n", (void *)block->next, (void *)codeblock, block_current, block_pos); } - + if (block->page_mask2) { block_prev = pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]; @@ -212,7 +212,7 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) } block = page->block_2[(phys_addr >> 10) & 3]; - + while (block) { if (mask & block->page_mask2) @@ -229,7 +229,7 @@ void codegen_block_init(uint32_t phys_addr) { codeblock_t *block; page_t *page = &pages[phys_addr >> 12]; - + if (!page->block[(phys_addr >> 10) & 3]) mem_flush_write_page(phys_addr, cs+cpu_state.pc); @@ -256,18 +256,18 @@ void codegen_block_init(uint32_t phys_addr) block->page_mask = 0; block->flags = 0; block->status = cpu_cur_status; - + block->was_recompiled = 0; recomp_page = block->phys & ~0xfff; - + codeblock_tree_add(block); } void codegen_block_start_recompile(codeblock_t *block) { page_t *page = &pages[block->phys >> 12]; - + if (!page->block[(block->phys >> 10) & 3]) mem_flush_write_page(block->phys, cs+cpu_state.pc); @@ -278,7 +278,7 @@ void codegen_block_start_recompile(codeblock_t *block) fatal("Recompile to used block!\n"); block->status = cpu_cur_status; - + block_pos = BLOCK_GPF_OFFSET; #ifdef OLD_GPF #if _WIN64 @@ -351,22 +351,22 @@ void codegen_block_start_recompile(codeblock_t *block) last_op32 = -1; last_ea_seg = NULL; last_ssegs = -1; - + codegen_block_cycles = 0; codegen_timing_block_start(); - + codegen_block_ins = 0; codegen_block_full_ins = 0; recomp_page = block->phys & ~0xfff; - + codegen_flags_changed = 0; codegen_fpu_entered = 0; codegen_mmx_entered = 0; - + codegen_fpu_loaded_iq[0] = codegen_fpu_loaded_iq[1] = codegen_fpu_loaded_iq[2] = codegen_fpu_loaded_iq[3] = codegen_fpu_loaded_iq[4] = codegen_fpu_loaded_iq[5] = codegen_fpu_loaded_iq[6] = codegen_fpu_loaded_iq[7] = 0; - + cpu_state.seg_ds.checked = cpu_state.seg_es.checked = cpu_state.seg_fs.checked = cpu_state.seg_gs.checked = (cr0 & 1) ? 0 : 1; codegen_reg_loaded[0] = codegen_reg_loaded[1] = codegen_reg_loaded[2] = codegen_reg_loaded[3] = @@ -426,7 +426,7 @@ void codegen_block_generate_end_mask() for (; start_pc <= end_pc; start_pc++) block->page_mask2 |= ((uint64_t)1 << start_pc); page_2->code_present_mask[(block->phys_2 >> 10) & 3] |= block->page_mask2; - + if (!pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]) mem_flush_write_page(block->phys_2, block->endpc); @@ -437,7 +437,7 @@ void codegen_block_generate_end_mask() if (block->next_2->valid == 0) fatal("block->next_2->valid=0 %p\n", (void *)block->next_2); } - + block->dirty_mask2 = &page_2->dirty_mask[(block->phys_2 >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK]; } } @@ -477,7 +477,7 @@ void codegen_block_end_recompile(codeblock_t *block) addbyte(0x5d); /*POP RBP*/ addbyte(0x5b); /*POP RDX*/ addbyte(0xC3); /*RET*/ - + if (block_pos > BLOCK_GPF_OFFSET) fatal("Over limit!\n"); @@ -537,15 +537,15 @@ int opcode_0f_modrm[256] = 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, /*e0*/ 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0 /*f0*/ }; - + void codegen_debug() { } static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc) { - if (!cpu_mod && cpu_rm == 6) - { + if (!cpu_mod && cpu_rm == 6) + { addbyte(0xC7); /*MOVL $0,(ssegs)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(eaaddr)); @@ -555,7 +555,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, else { int base_reg = 0, index_reg = 0; - + switch (cpu_rm) { case 0: case 1: case 7: @@ -580,7 +580,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, } base_reg &= 7; index_reg &= 7; - + switch (cpu_mod) { case 0: @@ -649,7 +649,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, } (*op_pc) += 2; break; - + } if (cpu_mod || !(cpu_rm & 4)) { @@ -738,7 +738,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, } } else - { + { switch (cpu_mod) { case 0: @@ -820,7 +820,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, int base_reg; if (!cpu_mod && cpu_rm == 5) - { + { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/ addbyte(0x45); @@ -830,20 +830,20 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, return op_ea_seg; } base_reg = LOAD_REG_L(cpu_rm) & 7; - if (cpu_mod) + if (cpu_mod) { if (cpu_rm == 5 && !op_ssegs) op_ea_seg = &cpu_state.seg_ss; - if (cpu_mod == 1) + if (cpu_mod == 1) { addbyte(0x67); /*LEA EAX, base_reg+imm8*/ addbyte(0x41); addbyte(0x8d); addbyte(0x40 | base_reg); addbyte((fetchdat >> 8) & 0xff); - (*op_pc)++; + (*op_pc)++; } - else + else { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0x67); /*LEA EAX, base_reg+imm32*/ @@ -881,16 +881,16 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t int pc_off = 0; int test_modrm = 1; int c; - + op_ea_seg = &cpu_state.seg_ds; op_ssegs = 0; op_old_pc = old_pc; - + for (c = 0; c < NR_HOST_REGS; c++) host_reg_mapping[c] = -1; for (c = 0; c < NR_HOST_XMM_REGS; c++) host_reg_xmm_mapping[c] = -1; - + codegen_timing_start(); while (!over) @@ -902,7 +902,7 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t recomp_op_table = recomp_opcodes_0f; over = 1; break; - + case 0x26: /*ES:*/ op_ea_seg = &cpu_state.seg_es; op_ssegs = 1; @@ -927,14 +927,14 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t op_ea_seg = &cpu_state.seg_gs; op_ssegs = 1; break; - + case 0x66: /*Data size select*/ op_32 = ((use32 & 0x100) ^ 0x100) | (op_32 & 0x200); break; case 0x67: /*Address size select*/ op_32 = ((use32 & 0x200) ^ 0x200) | (op_32 & 0x100); break; - + case 0xd8: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; recomp_op_table = recomp_opcodes_d8; @@ -1009,7 +1009,7 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; - + case 0xf0: /*LOCK*/ break; @@ -1034,13 +1034,13 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t fetchdat >>= 8; op_pc++; } - + generate_call: codegen_timing_opcode(opcode, fetchdat, op_32, op_pc); codegen_accumulate(ACCREG_cycles, -codegen_block_cycles); codegen_block_cycles = 0; - + if ((op_table == x86_dynarec_opcodes && ((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 || (opcode & 0xfe) == 0xca || (opcode & 0xfc) == 0xcc || (opcode & 0xfc) == 0xe8 || @@ -1112,7 +1112,7 @@ generate_call: (op_table == x86_dynarec_opcodes_0f && opcode_0f_modrm[opcode]))/* && !(op_32 & 0x200)*/) { int stack_offset = 0; - + if (op_table == x86_dynarec_opcodes && opcode == 0x8f) /*POP*/ stack_offset = (op_32 & 0x100) ? 4 : 2; @@ -1160,10 +1160,10 @@ generate_call: } load_param_1_32(block, fetchdat); - call(block, (uintptr_t)op); + call(block, (uintptr_t)op); codegen_block_ins++; - + block->ins++; #ifdef CHECK_INT diff --git a/src/codegen/codegen_x86.c b/src/codegen/codegen_x86.c index b4ba9bc9f..c104883ef 100644 --- a/src/codegen/codegen_x86.c +++ b/src/codegen/codegen_x86.c @@ -167,7 +167,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B() addbyte(0x85); addlong(mem_abrt_rout - ((uint32_t)(&codeblock[block_current].data[block_pos]) + 4)); addbyte(0xc3); /*RET*/ - + return addr; } @@ -223,7 +223,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W() addbyte(0x85); addlong(mem_abrt_rout - ((uint32_t)(&codeblock[block_current].data[block_pos]) + 4)); addbyte(0xc3); /*RET*/ - + return addr; } @@ -275,14 +275,14 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L() addbyte(0x85); addlong(mem_abrt_rout - ((uint32_t)(&codeblock[block_current].data[block_pos]) + 4)); addbyte(0xc3); /*RET*/ - + return addr; } static uint32_t gen_MEM_LOAD_ADDR_EA_Q() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + addbyte(0x89); /*MOV ESI, EDX*/ addbyte(0xd6); addbyte(0x01); /*ADDL EDX, EAX*/ @@ -331,14 +331,14 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_Q() addbyte(0x85); addlong(mem_abrt_rout - ((uint32_t)(&codeblock[block_current].data[block_pos]) + 4)); addbyte(0xc3); /*RET*/ - + return addr; } static uint32_t gen_MEM_STORE_ADDR_EA_B() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ addbyte(0xf3); @@ -387,7 +387,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B() static uint32_t gen_MEM_STORE_ADDR_EA_W() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ addbyte(0xf3); @@ -442,7 +442,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W() static uint32_t gen_MEM_STORE_ADDR_EA_L() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ addbyte(0xf3); @@ -496,7 +496,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L() static uint32_t gen_MEM_STORE_ADDR_EA_Q() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*dat = EBX/ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EDX, ESI*/ addbyte(0xf2); @@ -605,7 +605,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B_NO_ABRT() addbyte(1); #endif addbyte(0xc3); /*RET*/ -#ifndef RELEASE_BUILD +#ifndef RELEASE_BUILD addbyte(0xc7); /*MOV [ESP], gen_MEM_LOAD_ADDR_EA_B_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); @@ -613,7 +613,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B_NO_ABRT() addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ -#endif +#endif return addr; } @@ -752,7 +752,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L_NO_ABRT() addbyte(0xe8); /*CALL fatal*/ addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4])); /*Should not return!*/ -#endif +#endif return addr; } @@ -762,7 +762,7 @@ static char gen_MEM_STORE_ADDR_EA_B_NO_ABRT_err[] = "gen_MEM_STORE_ADDR_EA_B_NO_ static uint32_t gen_MEM_STORE_ADDR_EA_B_NO_ABRT() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ addbyte(0xf3); @@ -805,7 +805,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B_NO_ABRT() addbyte(1); #endif addbyte(0xc3); /*RET*/ -#ifndef RELEASE_BUILD +#ifndef RELEASE_BUILD addbyte(0xc7); /*MOV [ESP], gen_MEM_STORE_ADDR_EA_B_NO_ABRT_err*/ addbyte(0x04); addbyte(0x24); @@ -823,7 +823,7 @@ static char gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err[] = "gen_MEM_STORE_ADDR_EA_W_NO_ static uint32_t gen_MEM_STORE_ADDR_EA_W_NO_ABRT() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ addbyte(0xf3); @@ -890,7 +890,7 @@ static char gen_MEM_STORE_ADDR_EA_L_NO_ABRT_err[] = "gen_MEM_STORE_ADDR_EA_L_NO_ static uint32_t gen_MEM_STORE_ADDR_EA_L_NO_ABRT() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*dat = ECX, seg = ESI, addr = EAX*/ addbyte(0x89); /*MOV EBX, ESI*/ addbyte(0xf3); @@ -953,9 +953,9 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L_NO_ABRT() static uint32_t gen_MEM_CHECK_WRITE() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*seg = ESI, addr = EAX*/ - + addbyte(0x8d); /*LEA EDI, [EAX+ESI]*/ addbyte(0x3c); addbyte(0x30); @@ -982,7 +982,7 @@ static uint32_t gen_MEM_CHECK_WRITE() addbyte(0x74); /*JE +*/ addbyte(1); addbyte(0xc3); /*RET*/ - + /*slowpath:*/ addbyte(0x8d); /*LEA EDI, [EAX+ESI]*/ addbyte(0x3c); @@ -1010,9 +1010,9 @@ static uint32_t gen_MEM_CHECK_WRITE() static uint32_t gen_MEM_CHECK_WRITE_W() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*seg = ESI, addr = EAX*/ - + addbyte(0x8d); /*LEA EDI, [EAX+ESI]*/ addbyte(0x3c); addbyte(0x30); @@ -1054,7 +1054,7 @@ static uint32_t gen_MEM_CHECK_WRITE_W() addbyte(0x74); /*JE +*/ addbyte(1); addbyte(0xc3); /*RET*/ - + /*slowpath:*/ addbyte(0x89); /*MOV EDI, EAX*/ addbyte(0xc7); @@ -1092,9 +1092,9 @@ static uint32_t gen_MEM_CHECK_WRITE_W() static uint32_t gen_MEM_CHECK_WRITE_L() { uint32_t addr = (uint32_t)&codeblock[block_current].data[block_pos]; - + /*seg = ESI, addr = EAX*/ - + addbyte(0x8d); /*LEA EDI, [EAX+ESI]*/ addbyte(0x3c); addbyte(0x30); @@ -1136,7 +1136,7 @@ static uint32_t gen_MEM_CHECK_WRITE_L() addbyte(0x74); /*JE +*/ addbyte(1); addbyte(0xc3); /*RET*/ - + /*slowpath:*/ addbyte(0x89); /*MOV EDI, EAX*/ addbyte(0xc7); @@ -1187,7 +1187,7 @@ void codegen_init() block_current = BLOCK_SIZE; block_pos = 0; - mem_abrt_rout = (uint32_t)&codeblock[block_current].data[block_pos]; + mem_abrt_rout = (uint32_t)&codeblock[block_current].data[block_pos]; addbyte(0x83); /*ADDL $16+4,%esp*/ addbyte(0xC4); addbyte(0x10+4); @@ -1230,7 +1230,7 @@ void codegen_init() mem_check_write_w = (uint32_t)gen_MEM_CHECK_WRITE_W(); block_pos = (block_pos + 15) & ~15; mem_check_write_l = (uint32_t)gen_MEM_CHECK_WRITE_L(); - + #ifndef _MSC_VER asm( "fstcw %0\n" @@ -1279,7 +1279,7 @@ static void add_to_block_list(codeblock_t *block) if (!block->next->valid) fatal("block->next->valid=0 %p %p %x %x\n", (void *)block->next, (void *)codeblock, block_current, block_pos); } - + if (block->page_mask2) { block_prev = pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]; @@ -1371,7 +1371,7 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) } block = page->block_2[(phys_addr >> 10) & 3]; - + while (block) { if (mask & block->page_mask2) @@ -1388,7 +1388,7 @@ void codegen_block_init(uint32_t phys_addr) { codeblock_t *block; page_t *page = &pages[phys_addr >> 12]; - + if (!page->block[(phys_addr >> 10) & 3]) mem_flush_write_page(phys_addr, cs+cpu_state.pc); @@ -1415,18 +1415,18 @@ void codegen_block_init(uint32_t phys_addr) block->page_mask = 0; block->flags = CODEBLOCK_STATIC_TOP; block->status = cpu_cur_status; - + block->was_recompiled = 0; recomp_page = block->phys & ~0xfff; - + codeblock_tree_add(block); } void codegen_block_start_recompile(codeblock_t *block) { page_t *page = &pages[block->phys >> 12]; - + if (!page->block[(block->phys >> 10) & 3]) mem_flush_write_page(block->phys, cs+cpu_state.pc); @@ -1485,29 +1485,29 @@ void codegen_block_start_recompile(codeblock_t *block) last_op32 = -1; last_ea_seg = NULL; last_ssegs = -1; - + codegen_block_cycles = 0; codegen_timing_block_start(); - + codegen_block_ins = 0; codegen_block_full_ins = 0; recomp_page = block->phys & ~0xfff; - + codegen_flags_changed = 0; codegen_fpu_entered = 0; codegen_mmx_entered = 0; codegen_fpu_loaded_iq[0] = codegen_fpu_loaded_iq[1] = codegen_fpu_loaded_iq[2] = codegen_fpu_loaded_iq[3] = codegen_fpu_loaded_iq[4] = codegen_fpu_loaded_iq[5] = codegen_fpu_loaded_iq[6] = codegen_fpu_loaded_iq[7] = 0; - + cpu_state.seg_ds.checked = cpu_state.seg_es.checked = cpu_state.seg_fs.checked = cpu_state.seg_gs.checked = (cr0 & 1) ? 0 : 1; block->TOP = cpu_state.TOP & 7; block->was_recompiled = 1; codegen_flat_ds = !(cpu_cur_status & CPU_STATUS_NOTFLATDS); - codegen_flat_ss = !(cpu_cur_status & CPU_STATUS_NOTFLATSS); + codegen_flat_ss = !(cpu_cur_status & CPU_STATUS_NOTFLATSS); codegen_accumulate_reset(); } @@ -1539,12 +1539,12 @@ void codegen_block_generate_end_mask() end_pc = 0x3ff; start_pc >>= PAGE_MASK_SHIFT; end_pc >>= PAGE_MASK_SHIFT; - + for (; start_pc <= end_pc; start_pc++) - { + { block->page_mask |= ((uint64_t)1 << start_pc); } - + pages[block->phys >> 12].code_present_mask[(block->phys >> 10) & 3] |= block->page_mask; block->phys_2 = -1; @@ -1562,7 +1562,7 @@ void codegen_block_generate_end_mask() for (; start_pc <= end_pc; start_pc++) block->page_mask2 |= ((uint64_t)1 << start_pc); page_2->code_present_mask[(block->phys_2 >> 10) & 3] |= block->page_mask2; - + if (!pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]) mem_flush_write_page(block->phys_2, block->endpc); @@ -1604,7 +1604,7 @@ void codegen_block_end_recompile(codeblock_t *block) addbyte(0x5d); /*POP EBP*/ addbyte(0x5b); /*POP EDX*/ addbyte(0xC3); /*RET*/ - + if (block_pos > BLOCK_GPF_OFFSET) fatal("Over limit!\n"); @@ -1674,8 +1674,8 @@ void codegen_debug() static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc) { - if (!cpu_mod && cpu_rm == 6) - { + if (!cpu_mod && cpu_rm == 6) + { addbyte(0xC7); /*MOVL $0,(ssegs)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(eaaddr)); @@ -1735,7 +1735,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, { uint8_t sib = fetchdat >> 8; (*op_pc)++; - + switch (cpu_mod) { case 0: @@ -1753,7 +1753,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l)); } break; - case 1: + case 1: new_eaaddr = (uint32_t)(int8_t)((fetchdat >> 16) & 0xff); addbyte(0xb8); /*MOVL new_eaaddr, %eax*/ addlong(new_eaaddr); @@ -1811,7 +1811,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, else { if (!cpu_mod && cpu_rm == 5) - { + { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/ addbyte(0x45); @@ -1824,21 +1824,21 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, addbyte(0x45); addbyte((uint8_t)cpu_state_offset(regs[cpu_rm].l)); cpu_state.eaaddr = cpu_state.regs[cpu_rm].l; - if (cpu_mod) + if (cpu_mod) { if (cpu_rm == 5 && !op_ssegs) op_ea_seg = &cpu_state.seg_ss; - if (cpu_mod == 1) + if (cpu_mod == 1) { addbyte(0x05); - addlong((uint32_t)(int8_t)(fetchdat >> 8)); - (*op_pc)++; + addlong((uint32_t)(int8_t)(fetchdat >> 8)); + (*op_pc)++; } - else + else { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0x05); - addlong(new_eaaddr); + addlong(new_eaaddr); (*op_pc) += 4; } } @@ -1865,13 +1865,13 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t op_ea_seg = &cpu_state.seg_ds; op_ssegs = 0; op_old_pc = old_pc; - + for (c = 0; c < NR_HOST_REGS; c++) host_reg_mapping[c] = -1; mmx_ebx_ecx_loaded = 0; for (c = 0; c < NR_HOST_XMM_REGS; c++) host_reg_xmm_mapping[c] = -1; - + codegen_timing_start(); while (!over) @@ -1883,7 +1883,7 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t recomp_op_table = recomp_opcodes_0f; over = 1; break; - + case 0x26: /*ES:*/ op_ea_seg = &cpu_state.seg_es; op_ssegs = 1; @@ -1908,14 +1908,14 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t op_ea_seg = &cpu_state.seg_gs; op_ssegs = 1; break; - + case 0x66: /*Data size select*/ op_32 = ((use32 & 0x100) ^ 0x100) | (op_32 & 0x200); break; case 0x67: /*Address size select*/ op_32 = ((use32 & 0x200) ^ 0x200) | (op_32 & 0x100); break; - + case 0xd8: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; recomp_op_table = recomp_opcodes_d8; @@ -1990,10 +1990,10 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; - + case 0xf0: /*LOCK*/ break; - + case 0xf2: /*REPNE*/ op_table = x86_dynarec_opcodes_REPNE; recomp_op_table = recomp_opcodes_REPNE; @@ -2013,10 +2013,10 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t opcode = fetchdat & 0xff; if (!pc_off) fetchdat >>= 8; - + op_pc++; } - + generate_call: codegen_timing_opcode(opcode, fetchdat, op_32, op_pc); @@ -2078,7 +2078,7 @@ generate_call: return; } } - + op = op_table[((opcode >> opcode_shift) | op_32) & opcode_mask]; if (op_ssegs != last_ssegs) { @@ -2095,7 +2095,7 @@ generate_call: (op_table == x86_dynarec_opcodes_0f && opcode_0f_modrm[opcode])) { int stack_offset = 0; - + if (op_table == x86_dynarec_opcodes && opcode == 0x8f) /*POP*/ stack_offset = (op_32 & 0x100) ? 4 : 2; @@ -2150,12 +2150,12 @@ generate_call: addbyte(0x04); addbyte(0x24); addlong(fetchdat); - + addbyte(0xE8); /*CALL*/ addlong(((uint8_t *)op - (uint8_t *)(&block->data[block_pos + 4]))); codegen_block_ins++; - + block->ins++; #ifdef CHECK_INT diff --git a/src/codegen_new/CMakeLists.txt b/src/codegen_new/CMakeLists.txt index 54f3b3c6b..e9f53f4a6 100644 --- a/src/codegen_new/CMakeLists.txt +++ b/src/codegen_new/CMakeLists.txt @@ -48,4 +48,4 @@ if(DYNAREC) endif() target_link_libraries(86Box dynarec cgt) -endif() \ No newline at end of file +endif() diff --git a/src/codegen_new/codegen.c b/src/codegen_new/codegen.c index aa0791b3e..ef928dd51 100644 --- a/src/codegen_new/codegen.c +++ b/src/codegen_new/codegen.c @@ -31,7 +31,7 @@ static struct int codegen_get_instruction_uop(codeblock_t *block, uint32_t pc, int *first_instruction, int *TOP) { int c; - + for (c = 0; c <= block->ins; c++) { if (codegen_instructions[c].pc == pc) @@ -41,7 +41,7 @@ int codegen_get_instruction_uop(codeblock_t *block, uint32_t pc, int *first_inst return codegen_instructions[c].first_uop; } } - + *first_instruction = block->ins; return -1; } @@ -185,7 +185,7 @@ static x86seg *codegen_generate_ea_16_long(ir_data_t *ir, x86seg *op_ea_seg, uin op_ea_seg = &cpu_state.seg_ss; } } - + codegen_mark_code_present(ir->block, cs+old_pc, ((*op_pc)+1)-old_pc); return op_ea_seg; } @@ -290,7 +290,7 @@ static x86seg *codegen_generate_ea_32_long(ir_data_t *ir, x86seg *op_ea_seg, uin uop_MOV_IMM(ir, IREG_eaaddr, new_eaaddr); extra_bytes = 4; } - + (*op_pc) += 4; } else @@ -327,7 +327,7 @@ static x86seg *codegen_generate_ea_32_long(ir_data_t *ir, x86seg *op_ea_seg, uin if (extra_bytes) codegen_mark_code_present(ir->block, cs+old_pc, extra_bytes); - + return op_ea_seg; } @@ -617,7 +617,7 @@ generate_call: if (codegen_timing_jump_cycles) codegen_timing_jump_cycles(); - + if (jump_cycles) codegen_accumulate(ir, ACCREG_cycles, -jump_cycles); codegen_accumulate_flush(ir); @@ -673,7 +673,7 @@ generate_call: if (recomp_opcodes_3DNOW[opcode_3dnow]) { next_pc = opcode_pc + 1; - + op_table = (OpFn *) x86_dynarec_opcodes_3DNOW; recomp_op_table = recomp_opcodes_3DNOW; opcode = opcode_3dnow; @@ -765,14 +765,14 @@ generate_call: last_op_ea_seg = op_ea_seg; last_op_ssegs = op_ssegs; //codegen_block_ins++; - + block->ins++; if (block->ins >= MAX_INSTRUCTION_COUNT) CPU_BLOCK_END(); codegen_endpc = (cs + cpu_state.pc) + 8; - + // if (has_ea) // fatal("Has EA\n"); } diff --git a/src/codegen_new/codegen.h b/src/codegen_new/codegen.h index 8dd5222e7..082874f28 100644 --- a/src/codegen_new/codegen.h +++ b/src/codegen_new/codegen.h @@ -13,18 +13,18 @@ added to the page_lookup for this purpose. When in the page_lookup, each write will go through the mem_write_ram*_page() functions and set the dirty mask appropriately. - + Each codeblock also contains a code mask (actually two masks, one for each page the block is/may be in), again with each bit representing 64 bytes. - + Each page has a list of codeblocks present in it. As each codeblock can span up to two pages, two lists are present. - + When a codeblock is about to be executed, the code masks are compared with the dirty masks for the relevant pages. If either intersect, then codegen_check_flush() is called on the affected page(s), and all affected blocks are evicted. - + The 64 byte granularity appears to work reasonably well for most cases, avoiding most unnecessary evictions (eg when code & data are stored in the same page). @@ -45,7 +45,7 @@ typedef struct codeblock_t uint16_t parent, left, right; uint8_t *data; - + uint64_t page_mask, page_mask2; uint64_t *dirty_mask, *dirty_mask2; @@ -96,10 +96,10 @@ static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs) { codeblock_t *block; uint64_t a = _cs | ((uint64_t)phys << 32); - + if (!pages[phys >> 12].head) return NULL; - + block = &codeblock[pages[phys >> 12].head]; while (block) { @@ -115,7 +115,7 @@ static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs) else block = block->right ? &codeblock[block->right] : NULL; } - + return block; } @@ -133,23 +133,23 @@ static inline void codeblock_tree_add(codeblock_t *new_block) { codeblock_t *old_block = NULL; uint64_t old_block_cmp = 0; - + while (block) { old_block = block; old_block_cmp = old_block->_cs | ((uint64_t)old_block->phys << 32); - + if (a < old_block_cmp) block = block->left ? &codeblock[block->left] : NULL; else block = block->right ? &codeblock[block->right] : NULL; } - + if (a < old_block_cmp) old_block->left = get_block_nr(new_block); else old_block->right = get_block_nr(new_block); - + new_block->parent = get_block_nr(old_block); new_block->left = new_block->right = BLOCK_INVALID; } @@ -173,7 +173,7 @@ static inline void codeblock_tree_delete(codeblock_t *block) else { uint16_t block_nr = get_block_nr(block); - + if (parent->left == block_nr) parent->left = BLOCK_INVALID; if (parent->right == block_nr) @@ -237,11 +237,11 @@ static inline void codeblock_tree_delete(codeblock_t *block) codeblock_t *lowest = &codeblock[block->right], *highest; codeblock_t *old_parent; uint16_t lowest_nr; - + while (lowest->left) lowest = &codeblock[lowest->left]; lowest_nr = get_block_nr(lowest); - + old_parent = &codeblock[lowest->parent]; /*Replace deleted node with lowest node*/ @@ -263,7 +263,7 @@ static inline void codeblock_tree_delete(codeblock_t *block) codeblock[lowest->left].parent = lowest_nr; old_parent->left = BLOCK_INVALID; - + highest = &codeblock[lowest->right]; if (!lowest->right) { diff --git a/src/codegen_new/codegen_accumulate.h b/src/codegen_new/codegen_accumulate.h index a9ce2e871..908dba2e2 100644 --- a/src/codegen_new/codegen_accumulate.h +++ b/src/codegen_new/codegen_accumulate.h @@ -1,7 +1,7 @@ enum { ACCREG_cycles = 0, - + ACCREG_COUNT }; diff --git a/src/codegen_new/codegen_allocator.c b/src/codegen_new/codegen_allocator.c index 7b8b04323..e85271fef 100644 --- a/src/codegen_new/codegen_allocator.c +++ b/src/codegen_new/codegen_allocator.c @@ -60,13 +60,13 @@ mem_block_t *codegen_allocator_allocate(mem_block_t *parent, int code_block) { mem_block_t *block; uint32_t block_nr; - + while (!mem_block_free_list) { /*Pick a random memory block and free the owning code block*/ block_nr = rand() & MEM_BLOCK_MASK; block = &mem_blocks[block_nr]; - + if (block->code_block && block->code_block != code_block) codegen_delete_block(&codeblock[block->code_block]); } @@ -75,7 +75,7 @@ mem_block_t *codegen_allocator_allocate(mem_block_t *parent, int code_block) block_nr = mem_block_free_list; block = &mem_blocks[block_nr-1]; mem_block_free_list = block->next; - + block->code_block = code_block; if (parent) { @@ -97,12 +97,12 @@ void codegen_allocator_free(mem_block_t *block) { int next_block_nr = block->next; codegen_allocator_usage--; - + block->next = mem_block_free_list; block->code_block = BLOCK_INVALID; mem_block_free_list = block_nr; block_nr = next_block_nr; - + if (block_nr) block = &mem_blocks[block_nr - 1]; else diff --git a/src/codegen_new/codegen_allocator.h b/src/codegen_new/codegen_allocator.h index 6cd42258b..f9e70d248 100644 --- a/src/codegen_new/codegen_allocator.h +++ b/src/codegen_new/codegen_allocator.h @@ -4,12 +4,12 @@ /*The allocator handles all allocation of executable memory. Since the two-pass recompiler design makes applying hard limits to codeblock size difficult, the allocator allows memory to be provided as and when required. - + The allocator provides a block size of a little under 1 kB (slightly lower to limit cache aliasing). Each generated codeblock is allocated one block by default, and will allocate additional block(s) once the existing memory is sorted. Blocks are chained together by jump instructions. - + Due to the chaining, the total memory size is limited by the range of a jump instruction. ARMv7 is restricted to +/- 32 MB, ARMv8 to +/- 128 MB, x86 to +/- 2GB. As a result, total memory size is limited to 32 MB on ARMv7*/ diff --git a/src/codegen_new/codegen_backend_arm.c b/src/codegen_new/codegen_backend_arm.c index f423f72d8..ce5f788ce 100644 --- a/src/codegen_new/codegen_backend_arm.c +++ b/src/codegen_new/codegen_backend_arm.c @@ -283,7 +283,7 @@ static void build_fp_round_routine(codeblock_t *block) host_arm_VCVTR_IS_D(block, REG_D_TEMP, REG_D_TEMP); host_arm_VMSR_FPSCR(block, REG_TEMP); host_arm_MOV_REG(block, REG_PC, REG_LR); - + jump_table[X87_ROUNDING_CHOP] = (uint64_t)(uintptr_t)&block_write_data[block_pos]; //zero host_arm_VCVT_IS_D(block, REG_D_TEMP, REG_D_TEMP); host_arm_MOV_REG(block, REG_PC, REG_LR); diff --git a/src/codegen_new/codegen_backend_arm.h b/src/codegen_new/codegen_backend_arm.h index 87dc2d8a0..8b8936a98 100644 --- a/src/codegen_new/codegen_backend_arm.h +++ b/src/codegen_new/codegen_backend_arm.h @@ -21,4 +21,4 @@ void host_arm_SUB_IMM(codeblock_t *block, int dst_reg, int src_reg, uint32_t imm void host_arm_call(codeblock_t *block, void *dst_addr); void host_arm_nop(codeblock_t *block); -void codegen_alloc(codeblock_t *block, int size); \ No newline at end of file +void codegen_alloc(codeblock_t *block, int size); diff --git a/src/codegen_new/codegen_backend_arm64.c b/src/codegen_new/codegen_backend_arm64.c index 2ccdab3a2..4c77f8910 100644 --- a/src/codegen_new/codegen_backend_arm64.c +++ b/src/codegen_new/codegen_backend_arm64.c @@ -270,7 +270,7 @@ static void build_fp_round_routine(codeblock_t *block, int is_quad) else host_arm64_FCVTMS_W_D(block, REG_TEMP, REG_V_TEMP); host_arm64_RET(block, REG_X30); - + jump_table[X87_ROUNDING_CHOP] = (uint64_t)(uintptr_t)&block_write_data[block_pos]; //zero if (is_quad) host_arm64_FCVTZS_X_D(block, REG_TEMP, REG_V_TEMP); diff --git a/src/codegen_new/codegen_backend_arm64.h b/src/codegen_new/codegen_backend_arm64.h index b4888d38e..3e3d16575 100644 --- a/src/codegen_new/codegen_backend_arm64.h +++ b/src/codegen_new/codegen_backend_arm64.h @@ -28,4 +28,4 @@ void host_arm64_STRB_IMM_W(codeblock_t *block, int dest_reg, int base_reg, int o void host_arm64_call(codeblock_t *block, void *dst_addr); void host_arm64_mov_imm(codeblock_t *block, int reg, uint32_t imm_data); -uint32_t host_arm64_find_imm(uint32_t data); \ No newline at end of file +uint32_t host_arm64_find_imm(uint32_t data); diff --git a/src/codegen_new/codegen_backend_arm64_defs.h b/src/codegen_new/codegen_backend_arm64_defs.h index dabfe8ae8..ac2d238da 100644 --- a/src/codegen_new/codegen_backend_arm64_defs.h +++ b/src/codegen_new/codegen_backend_arm64_defs.h @@ -132,4 +132,4 @@ extern void *codegen_fp_round; extern void *codegen_fp_round_quad; extern void *codegen_gpf_rout; -extern void *codegen_exit_rout; \ No newline at end of file +extern void *codegen_exit_rout; diff --git a/src/codegen_new/codegen_backend_arm64_ops.h b/src/codegen_new/codegen_backend_arm64_ops.h index 2a514edbe..c89a02311 100644 --- a/src/codegen_new/codegen_backend_arm64_ops.h +++ b/src/codegen_new/codegen_backend_arm64_ops.h @@ -261,4 +261,4 @@ void host_arm64_mov_imm(codeblock_t *block, int reg, uint32_t imm_data); void codegen_direct_read_8(codeblock_t *block, int host_reg, void *p); -void codegen_alloc(codeblock_t *block, int size); \ No newline at end of file +void codegen_alloc(codeblock_t *block, int size); diff --git a/src/codegen_new/codegen_backend_arm64_uops.c b/src/codegen_new/codegen_backend_arm64_uops.c index 7e26cdcf1..10a07a4a2 100644 --- a/src/codegen_new/codegen_backend_arm64_uops.c +++ b/src/codegen_new/codegen_backend_arm64_uops.c @@ -1410,7 +1410,7 @@ static int codegen_MOV_INT_DOUBLE_64(codeblock_t *block, uop_t *uop) host_arm64_FMOV_D_D(block, REG_V_TEMP, src_reg); host_arm64_call(block, codegen_fp_round_quad); host_arm64_FMOV_D_Q(block, dest_reg, REG_TEMP); - + host_arm64_branch_set_offset(branch_offset, &block_write_data[block_pos]); } else diff --git a/src/codegen_new/codegen_backend_arm_uops.c b/src/codegen_new/codegen_backend_arm_uops.c index 6beab7232..8b0990016 100644 --- a/src/codegen_new/codegen_backend_arm_uops.c +++ b/src/codegen_new/codegen_backend_arm_uops.c @@ -416,7 +416,7 @@ static int codegen_CMP_JNBE(codeblock_t *block, uop_t *uop) jump_p = host_arm_BHI_(block); *jump_p |= ((((uintptr_t)uop->p - (uintptr_t)jump_p) - 8) & 0x3fffffc) >> 2; - + return 0; } @@ -1488,7 +1488,7 @@ static int codegen_MOV_INT_DOUBLE(codeblock_t *block, uop_t *uop) static int64_t x87_fround64(double b) { int64_t a, c; - + switch ((cpu_state.npxc >> 10) & 3) { case 0: /*Nearest*/ @@ -1507,7 +1507,7 @@ static int64_t x87_fround64(double b) case 3: /*Chop*/ return (int64_t)b; } - + return 0; } static int codegen_MOV_INT_DOUBLE_64(codeblock_t *block, uop_t *uop) @@ -1529,7 +1529,7 @@ static int codegen_MOV_INT_DOUBLE_64(codeblock_t *block, uop_t *uop) host_arm_VMOV_D_D(block, REG_D0, src_reg); host_arm_call(block, x87_fround64); host_arm_VMOV_D_64(block, REG_D_TEMP, REG_R0, REG_R1); - + *branch_offset |= ((((uintptr_t)&block_write_data[block_pos] - (uintptr_t)branch_offset) - 8) & 0x3fffffc) >> 2; } else diff --git a/src/codegen_new/codegen_backend_x86-64_ops.c b/src/codegen_new/codegen_backend_x86-64_ops.c index 784bfa03d..08079bf26 100644 --- a/src/codegen_new/codegen_backend_x86-64_ops.c +++ b/src/codegen_new/codegen_backend_x86-64_ops.c @@ -701,7 +701,7 @@ void host_x86_MOV8_REG_ABS(codeblock_t *block, int dst_reg, void *p) { int64_t offset = (uintptr_t)p - (((uintptr_t)&cpu_state) + 128); int64_t ram_offset = (uintptr_t)p - (uintptr_t)ram; - + if (dst_reg & 8) fatal("host_x86_MOV8_REG_ABS reg & 8\n"); @@ -767,7 +767,7 @@ void host_x86_MOV32_REG_ABS(codeblock_t *block, int dst_reg, void *p) { int64_t offset = (uintptr_t)p - (((uintptr_t)&cpu_state) + 128); int64_t ram_offset = (uintptr_t)p - (uintptr_t)ram; - + if (dst_reg & 8) fatal("host_x86_MOV32_REG_ABS reg & 8\n"); @@ -1139,7 +1139,7 @@ void host_x86_MOVZX_REG_ABS_16_8(codeblock_t *block, int dst_reg, void *p) { int64_t offset = (uintptr_t)p - (((uintptr_t)&cpu_state) + 128); int64_t ram_offset = (uintptr_t)p - (uintptr_t)ram; - + if (dst_reg & 8) fatal("host_x86_MOVZX_REG_ABS_16_8 - bad reg\n"); @@ -1170,7 +1170,7 @@ void host_x86_MOVZX_REG_ABS_32_8(codeblock_t *block, int dst_reg, void *p) { int64_t offset = (uintptr_t)p - (((uintptr_t)&cpu_state) + 128); int64_t ram_offset = (uintptr_t)p - (uintptr_t)ram; - + // if (dst_reg & 8) // fatal("host_x86_MOVZX_REG_ABS_32_8 - bad reg\n"); @@ -1214,7 +1214,7 @@ void host_x86_MOVZX_REG_ABS_32_16(codeblock_t *block, int dst_reg, void *p) { int64_t offset = (uintptr_t)p - (((uintptr_t)&cpu_state) + 128); int64_t ram_offset = (uintptr_t)p - (uintptr_t)ram; - + if (dst_reg & 8) fatal("host_x86_MOVZX_REG_ABS_32_16 - bad reg\n"); diff --git a/src/codegen_new/codegen_backend_x86-64_uops.c b/src/codegen_new/codegen_backend_x86-64_uops.c index 471f982e8..9997ea738 100644 --- a/src/codegen_new/codegen_backend_x86-64_uops.c +++ b/src/codegen_new/codegen_backend_x86-64_uops.c @@ -1449,7 +1449,7 @@ static int codegen_MOV_INT_DOUBLE_64(codeblock_t *block, uop_t *uop) host_x86_CVTSD2SI_REG64_XREG(block, REG_RCX, src_reg); host_x86_LDMXCSR(block, &cpu_state.old_fp_control); host_x86_MOVQ_XREG_REG(block, dest_reg, REG_RCX); - + *branch_offset = (uint32_t)((uintptr_t)&block_write_data[block_pos] - (uintptr_t)branch_offset) - 4; } #ifdef RECOMPILER_DEBUG diff --git a/src/codegen_new/codegen_backend_x86.c b/src/codegen_new/codegen_backend_x86.c index 8aa2a5975..8bbc950e6 100644 --- a/src/codegen_new/codegen_backend_x86.c +++ b/src/codegen_new/codegen_backend_x86.c @@ -66,7 +66,7 @@ static void build_load_routine(codeblock_t *block, int size, int is_float) { uint8_t *branch_offset; uint8_t *misaligned_offset = NULL; - + /*In - ESI = address Out - ECX = data, ESI = abrt*/ /*MOV ECX, ESI @@ -111,7 +111,7 @@ static void build_load_routine(codeblock_t *block, int size, int is_float) fatal("build_load_routine: size=%i\n", size); host_x86_XOR32_REG_REG(block, REG_ESI, REG_ESI); host_x86_RET(block); - + *branch_offset = (uint8_t)((uintptr_t)&block_write_data[block_pos] - (uintptr_t)branch_offset) - 1; if (size != 1) *misaligned_offset = (uint8_t)((uintptr_t)&block_write_data[block_pos] - (uintptr_t)misaligned_offset) - 1; @@ -155,7 +155,7 @@ static void build_store_routine(codeblock_t *block, int size, int is_float) { uint8_t *branch_offset; uint8_t *misaligned_offset = NULL; - + /*In - ECX = data, ESI = address Out - ESI = abrt Corrupts EDI*/ @@ -290,7 +290,7 @@ void codegen_backend_init() block->data = codeblock_allocator_get_ptr(block->head_mem_block); block_write_data = block->data; build_loadstore_routines(block); - + codegen_gpf_rout = &codeblock[block_current].data[block_pos]; host_x86_MOV32_STACK_IMM(block, STACK_ARG0, 0); host_x86_MOV32_STACK_IMM(block, STACK_ARG1, 0); diff --git a/src/codegen_new/codegen_backend_x86_uops.c b/src/codegen_new/codegen_backend_x86_uops.c index 9d423f772..3f7e2dd9a 100644 --- a/src/codegen_new/codegen_backend_x86_uops.c +++ b/src/codegen_new/codegen_backend_x86_uops.c @@ -66,7 +66,7 @@ static int codegen_ADD_IMM(codeblock_t *block, uop_t *uop) { int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); - + if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -280,7 +280,7 @@ static int codegen_CMP_IMM_JZ_DEST(codeblock_t *block, uop_t *uop) fatal("CMP_IMM_JZ_DEST %02x\n", uop->src_reg_a_real); #endif uop->p = host_x86_JZ_long(block); - + return 0; } @@ -319,7 +319,7 @@ static int codegen_CMP_JNBE(codeblock_t *block, uop_t *uop) #endif jump_p = host_x86_JNBE_long(block); *jump_p = (uintptr_t)uop->p - ((uintptr_t)jump_p + 4); - + return 0; } @@ -801,7 +801,7 @@ static int codegen_FSUB(codeblock_t *block, uop_t *uop) static int codegen_FP_ENTER(codeblock_t *block, uop_t *uop) { uint32_t *branch_offset; - + host_x86_MOV32_REG_ABS(block, REG_ECX, &cr0); host_x86_TEST32_REG_IMM(block, REG_ECX, 0xc); branch_offset = host_x86_JZ_long(block); @@ -830,7 +830,7 @@ static int codegen_MMX_ENTER(codeblock_t *block, uop_t *uop) host_x86_MOV32_ABS_IMM(block, &cpu_state.tag[4], 0x01010101); host_x86_MOV32_ABS_IMM(block, &cpu_state.TOP, 0); host_x86_MOV8_ABS_IMM(block, &cpu_state.ismmx, 1); - + return 0; } @@ -1047,7 +1047,7 @@ static int codegen_MEM_LOAD_DOUBLE(codeblock_t *block, uop_t *uop) host_x86_TEST32_REG(block, REG_ESI, REG_ESI); host_x86_JNZ(block, codegen_exit_rout); host_x86_MOVQ_XREG_XREG(block, dest_reg, REG_XMM_TEMP); - + return 0; } @@ -1266,7 +1266,7 @@ static int codegen_MOV_REG_PTR(codeblock_t *block, uop_t *uop) } else fatal("MOV_REG_PTR %02x\n", uop->dest_reg_a_real); - + return 0; } static int codegen_MOVZX_REG_PTR_8(codeblock_t *block, uop_t *uop) @@ -2830,7 +2830,7 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_JMP_DEST & UOP_MASK] = codegen_JMP_DEST, [UOP_LOAD_SEG & UOP_MASK] = codegen_LOAD_SEG, - + [UOP_LOAD_FUNC_ARG_0 & UOP_MASK] = codegen_LOAD_FUNC_ARG0, [UOP_LOAD_FUNC_ARG_1 & UOP_MASK] = codegen_LOAD_FUNC_ARG1, [UOP_LOAD_FUNC_ARG_2 & UOP_MASK] = codegen_LOAD_FUNC_ARG2, @@ -2844,12 +2844,12 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_STORE_P_IMM & UOP_MASK] = codegen_STORE_PTR_IMM, [UOP_STORE_P_IMM_8 & UOP_MASK] = codegen_STORE_PTR_IMM_8, [UOP_STORE_P_IMM_16 & UOP_MASK] = codegen_STORE_PTR_IMM_16, - + [UOP_MEM_LOAD_ABS & UOP_MASK] = codegen_MEM_LOAD_ABS, [UOP_MEM_LOAD_REG & UOP_MASK] = codegen_MEM_LOAD_REG, [UOP_MEM_LOAD_SINGLE & UOP_MASK] = codegen_MEM_LOAD_SINGLE, [UOP_MEM_LOAD_DOUBLE & UOP_MASK] = codegen_MEM_LOAD_DOUBLE, - + [UOP_MEM_STORE_ABS & UOP_MASK] = codegen_MEM_STORE_ABS, [UOP_MEM_STORE_REG & UOP_MASK] = codegen_MEM_STORE_REG, [UOP_MEM_STORE_IMM_8 & UOP_MASK] = codegen_MEM_STORE_IMM_8, @@ -2857,7 +2857,7 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_MEM_STORE_IMM_32 & UOP_MASK] = codegen_MEM_STORE_IMM_32, [UOP_MEM_STORE_SINGLE & UOP_MASK] = codegen_MEM_STORE_SINGLE, [UOP_MEM_STORE_DOUBLE & UOP_MASK] = codegen_MEM_STORE_DOUBLE, - + [UOP_MOV & UOP_MASK] = codegen_MOV, [UOP_MOV_PTR & UOP_MASK] = codegen_MOV_PTR, [UOP_MOV_IMM & UOP_MASK] = codegen_MOV_IMM, @@ -2917,16 +2917,16 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_TEST_JNS_DEST & UOP_MASK] = codegen_TEST_JNS_DEST, [UOP_TEST_JS_DEST & UOP_MASK] = codegen_TEST_JS_DEST, - + [UOP_FP_ENTER & UOP_MASK] = codegen_FP_ENTER, [UOP_MMX_ENTER & UOP_MASK] = codegen_MMX_ENTER, - + [UOP_FADD & UOP_MASK] = codegen_FADD, [UOP_FDIV & UOP_MASK] = codegen_FDIV, [UOP_FMUL & UOP_MASK] = codegen_FMUL, [UOP_FSUB & UOP_MASK] = codegen_FSUB, [UOP_FCOM & UOP_MASK] = codegen_FCOM, - + [UOP_FABS & UOP_MASK] = codegen_FABS, [UOP_FCHS & UOP_MASK] = codegen_FCHS, [UOP_FSQRT & UOP_MASK] = codegen_FSQRT, @@ -2963,11 +2963,11 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_PFRSQRT & UOP_MASK] = codegen_PFRSQRT, [UOP_PFSUB & UOP_MASK] = codegen_PFSUB, [UOP_PI2FD & UOP_MASK] = codegen_PI2FD, - + [UOP_PMADDWD & UOP_MASK] = codegen_PMADDWD, [UOP_PMULHW & UOP_MASK] = codegen_PMULHW, [UOP_PMULLW & UOP_MASK] = codegen_PMULLW, - + [UOP_PSLLW_IMM & UOP_MASK] = codegen_PSLLW_IMM, [UOP_PSLLD_IMM & UOP_MASK] = codegen_PSLLD_IMM, [UOP_PSLLQ_IMM & UOP_MASK] = codegen_PSLLQ_IMM, @@ -2977,7 +2977,7 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_PSRLW_IMM & UOP_MASK] = codegen_PSRLW_IMM, [UOP_PSRLD_IMM & UOP_MASK] = codegen_PSRLD_IMM, [UOP_PSRLQ_IMM & UOP_MASK] = codegen_PSRLQ_IMM, - + [UOP_PSUBB & UOP_MASK] = codegen_PSUBB, [UOP_PSUBW & UOP_MASK] = codegen_PSUBW, [UOP_PSUBD & UOP_MASK] = codegen_PSUBD, @@ -2985,7 +2985,7 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_PSUBSW & UOP_MASK] = codegen_PSUBSW, [UOP_PSUBUSB & UOP_MASK] = codegen_PSUBUSB, [UOP_PSUBUSW & UOP_MASK] = codegen_PSUBUSW, - + [UOP_PUNPCKHBW & UOP_MASK] = codegen_PUNPCKHBW, [UOP_PUNPCKHWD & UOP_MASK] = codegen_PUNPCKHWD, [UOP_PUNPCKHDQ & UOP_MASK] = codegen_PUNPCKHDQ, @@ -2994,7 +2994,7 @@ const uOpFn uop_handlers[UOP_MAX] = [UOP_PUNPCKLDQ & UOP_MASK] = codegen_PUNPCKLDQ, [UOP_NOP_BARRIER & UOP_MASK] = codegen_NOP, - + #ifdef DEBUG_EXTRA [UOP_LOG_INSTR & UOP_MASK] = codegen_LOG_INSTR #endif diff --git a/src/codegen_new/codegen_block.c b/src/codegen_new/codegen_block.c index 609d0927f..e2aaddb5c 100644 --- a/src/codegen_new/codegen_block.c +++ b/src/codegen_new/codegen_block.c @@ -58,7 +58,7 @@ static void delete_dirty_block(codeblock_t *block); /*Temporary list of code blocks that have recently been evicted. This allows for some historical state to be kept when a block is the target of self-modifying code. - + The size of this list is limited to DIRTY_LIST_MAX_SIZE blocks. When this is exceeded the oldest entry will be moved to the free list.*/ static uint16_t block_dirty_list_head, block_dirty_list_tail; @@ -88,7 +88,7 @@ static void block_dirty_list_add(codeblock_t *block) if (block_dirty_list_head != BLOCK_INVALID) { codeblock_t *old_head = &codeblock[block_dirty_list_head]; - + block->next = block_dirty_list_head; block->prev = BLOCK_INVALID; block_dirty_list_head = old_head->prev = get_block_nr(block); @@ -213,9 +213,9 @@ static codeblock_t *block_free_list_get() void codegen_init() { int c; - + codegen_allocator_init(); - + codegen_backend_init(); block_free_list = 0; for (c = 0; c < BLOCK_SIZE; c++) @@ -235,7 +235,7 @@ void codegen_close() { int c; uint32_t highest_num = 0, highest_idx = 0; - + for (c = 0; c < 256*256; c++) { if (instr_counts[c] > highest_num) @@ -263,7 +263,7 @@ void codegen_reset() for (c = 1; c < BLOCK_SIZE; c++) { codeblock_t *block = &codeblock[c]; - + if (block->pc != BLOCK_PC_INVALID) { block->phys = 0; @@ -296,7 +296,7 @@ void dump_block() pclog(" %p : %08x-%08x %08x-%08x %p %p\n", (void *)block, start_pc, end_pc, block->pc, block->endpc, (void *)block->prev, (void *)block->next); if (!block->pc) fatal("Dead PC=0\n"); - + block = block->next; } pclog("dump_block done\n");*/ @@ -331,11 +331,11 @@ static void add_to_block_list(codeblock_t *block) fatal("block->next->pc=BLOCK_PC_INVALID %p %p %x %x\n", (void *)&codeblock[block->next], (void *)codeblock, block_current, block_pos); #endif } - + if (block->page_mask2) { block->flags |= CODEBLOCK_HAS_PAGE2; - + block_prev_nr = pages[block->phys_2 >> 12].block_2; if (block_prev_nr) @@ -466,7 +466,7 @@ void codegen_delete_block(codeblock_t *block) void codegen_delete_random_block(int required_mem_block) { int block_nr = rand() & BLOCK_MASK; - + while (1) { if (block_nr && block_nr != block_current) @@ -493,7 +493,7 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) { codeblock_t *block = &codeblock[block_nr]; uint16_t next_block = block->next; - + if (*block->dirty_mask & block->page_mask) { invalidate_block(block); @@ -506,7 +506,7 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) } block_nr = page->block_2; - + while (block_nr) { codeblock_t *block = &codeblock[block_nr]; @@ -522,12 +522,12 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) #endif block_nr = next_block; } - + if (page->code_present_mask & page->dirty_mask) remove_from_evict_list = 1; page->code_present_mask &= ~page->dirty_mask; page->dirty_mask = 0; - + for (c = 0; c < 64; c++) { if (page->byte_code_present_mask[c] & page->byte_dirty_mask[c]) @@ -567,7 +567,7 @@ void codegen_block_init(uint32_t phys_addr) block->page_mask = block->page_mask2 = 0; block->flags = CODEBLOCK_STATIC_TOP; block->status = cpu_cur_status; - + recomp_page = block->phys & ~0xfff; codeblock_tree_add(block); } @@ -598,7 +598,7 @@ void codegen_block_start_recompile(codeblock_t *block) block->data = codeblock_allocator_get_ptr(block->head_mem_block); block->status = cpu_cur_status; - + block->page_mask = block->page_mask2 = 0; block->ins = 0; @@ -607,30 +607,30 @@ void codegen_block_start_recompile(codeblock_t *block) last_op32 = -1; last_ea_seg = NULL; last_ssegs = -1; - + codegen_block_cycles = 0; codegen_timing_block_start(); - + codegen_block_ins = 0; codegen_block_full_ins = 0; recomp_page = block->phys & ~0xfff; - + codegen_flags_changed = 0; codegen_fpu_entered = 0; codegen_mmx_entered = 0; codegen_fpu_loaded_iq[0] = codegen_fpu_loaded_iq[1] = codegen_fpu_loaded_iq[2] = codegen_fpu_loaded_iq[3] = codegen_fpu_loaded_iq[4] = codegen_fpu_loaded_iq[5] = codegen_fpu_loaded_iq[6] = codegen_fpu_loaded_iq[7] = 0; - + cpu_state.seg_ds.checked = cpu_state.seg_es.checked = cpu_state.seg_fs.checked = cpu_state.seg_gs.checked = (cr0 & 1) ? 0 : 1; block->TOP = cpu_state.TOP & 7; block->flags |= CODEBLOCK_WAS_RECOMPILED; codegen_flat_ds = !(cpu_cur_status & CPU_STATUS_NOTFLATDS); - codegen_flat_ss = !(cpu_cur_status & CPU_STATUS_NOTFLATSS); - + codegen_flat_ss = !(cpu_cur_status & CPU_STATUS_NOTFLATSS); + if (block->flags & CODEBLOCK_BYTE_MASK) { block->dirty_mask = &page->byte_dirty_mask[(block->phys >> PAGE_BYTE_MASK_SHIFT) & PAGE_BYTE_MASK_OFFSET_MASK]; @@ -684,7 +684,7 @@ void codegen_block_generate_end_mask_recompile() if (block->flags & CODEBLOCK_BYTE_MASK) { int offset = (block->phys_2 >> PAGE_BYTE_MASK_SHIFT) & PAGE_BYTE_MASK_OFFSET_MASK; - + page_2->byte_code_present_mask[offset] |= block->page_mask2; block->dirty_mask2 = &page_2->byte_dirty_mask[offset]; } diff --git a/src/codegen_new/codegen_ir.c b/src/codegen_new/codegen_ir.c index a949b7f86..49a7adac5 100644 --- a/src/codegen_new/codegen_ir.c +++ b/src/codegen_new/codegen_ir.c @@ -48,7 +48,7 @@ static void duplicate_uop(ir_data_t *ir, uop_t *uop, int offset) new_uop->imm_data = uop->imm_data; new_uop->p = uop->p; new_uop->pc = uop->pc; - + if (uop->jump_dest_uop != -1) { new_uop->jump_dest_uop = uop->jump_dest_uop + offset; @@ -64,10 +64,10 @@ void codegen_ir_compile(ir_data_t *ir, codeblock_t *block) { int unroll_count; int unroll_end; - + codegen_set_loop_start(ir, codegen_unroll_first_instruction); unroll_end = ir->wr_pos; - + for (unroll_count = 1; unroll_count < codegen_unroll_count; unroll_count++) { int offset = ir->wr_pos - codegen_unroll_start; @@ -89,7 +89,7 @@ void codegen_ir_compile(ir_data_t *ir, codeblock_t *block) for (c = 0; c < ir->wr_pos; c++) { uop_t *uop = &ir->uops[c]; - + // pclog("uOP %i : %08x\n", c, uop->type); if (uop->type & UOP_TYPE_BARRIER) @@ -184,7 +184,7 @@ void codegen_ir_compile(ir_data_t *ir, codeblock_t *block) else { uop_t *uop_dest = &ir->uops[uop->jump_dest_uop]; - + while (uop_dest->jump_list_next != -1) uop_dest = &ir->uops[uop_dest->jump_list_next]; @@ -195,7 +195,7 @@ void codegen_ir_compile(ir_data_t *ir, codeblock_t *block) } codegen_reg_flush_invalidate(ir, block); - + if (jump_target_at_end != -1) { uop_t *uop_dest = &ir->uops[jump_target_at_end]; diff --git a/src/codegen_new/codegen_ir_defs.h b/src/codegen_new/codegen_ir_defs.h index 86276a053..30bf44d98 100644 --- a/src/codegen_new/codegen_ir_defs.h +++ b/src/codegen_new/codegen_ir_defs.h @@ -9,7 +9,7 @@ All registers must have been written back or discarded. This should be used when calling external functions that may change any emulated registers.*/ -#define UOP_TYPE_BARRIER (1 << 31) +#define UOP_TYPE_BARRIER (1u << 31) /*uOP is a barrier. All previous uOPs must have completed before this one executes. All registers must have been written back, but do not have to be discarded. @@ -361,19 +361,19 @@ typedef struct ir_data_t static inline uop_t *uop_alloc(ir_data_t *ir, uint32_t uop_type) { uop_t *uop; - + if (ir->wr_pos >= UOP_NR_MAX) fatal("Exceeded uOP max\n"); - + uop = &ir->uops[ir->wr_pos++]; - + uop->dest_reg_a = invalid_ir_reg; uop->src_reg_a = invalid_ir_reg; uop->src_reg_b = invalid_ir_reg; uop->src_reg_c = invalid_ir_reg; - + uop->pc = cpu_state.oldpc; - + uop->jump_dest_uop = -1; uop->jump_list_next = -1; @@ -386,7 +386,7 @@ static inline uop_t *uop_alloc(ir_data_t *ir, uint32_t uop_type) static inline void uop_set_jump_dest(ir_data_t *ir, int jump_uop) { uop_t *uop = &ir->uops[jump_uop]; - + uop->jump_dest_uop = ir->wr_pos; } @@ -402,7 +402,7 @@ static inline int uop_gen(uint32_t uop_type, ir_data_t *ir) static inline int uop_gen_reg_src1(uint32_t uop_type, ir_data_t *ir, int src_reg_a) { uop_t *uop = uop_alloc(ir, uop_type); - + uop->type = uop_type; uop->src_reg_a = codegen_reg_read(src_reg_a); @@ -424,7 +424,7 @@ static inline int uop_gen_reg_src1_imm(uint32_t uop_type, ir_data_t *ir, int src uop->type = uop_type; uop->src_reg_a = codegen_reg_read(src_reg); uop->imm_data = imm; - + return ir->wr_pos-1; } @@ -514,7 +514,7 @@ static inline int uop_gen_reg_src2(uint32_t uop_type, ir_data_t *ir, int src_reg uop->type = uop_type; uop->src_reg_a = codegen_reg_read(src_reg_a); uop->src_reg_b = codegen_reg_read(src_reg_b); - + return ir->wr_pos-1; } @@ -552,7 +552,7 @@ static inline void uop_gen_reg_src3_imm(uint32_t uop_type, ir_data_t *ir, int sr static inline void uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uint32_t imm) { uop_t *uop = uop_alloc(ir, uop_type); - + uop->type = uop_type; uop->imm_data = imm; } @@ -560,7 +560,7 @@ static inline void uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uint32_t imm) static inline void uop_gen_pointer(uint32_t uop_type, ir_data_t *ir, void *p) { uop_t *uop = uop_alloc(ir, uop_type); - + uop->type = uop_type; uop->p = p; } @@ -568,7 +568,7 @@ static inline void uop_gen_pointer(uint32_t uop_type, ir_data_t *ir, void *p) static inline void uop_gen_pointer_imm(uint32_t uop_type, ir_data_t *ir, void *p, uint32_t imm) { uop_t *uop = uop_alloc(ir, uop_type); - + uop->type = uop_type; uop->p = p; uop->imm_data = imm; diff --git a/src/codegen_new/codegen_ops_arith.c b/src/codegen_new/codegen_ops_arith.c index 576cf7719..66715730d 100644 --- a/src/codegen_new/codegen_ops_arith.c +++ b/src/codegen_new/codegen_ops_arith.c @@ -309,7 +309,7 @@ uint32_t ropADD_AX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32 uint32_t ropADD_EAX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { uop_MOV(ir, IREG_flags_op1, IREG_EAX); - + if (block->flags & CODEBLOCK_NO_IMMEDIATES) { LOAD_IMMEDIATE_FROM_RAM_32(block, ir, IREG_temp0, cs + op_pc); @@ -337,7 +337,7 @@ uint32_t ropADD_b_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t if ((fetchdat & 0xc0) == 0xc0) { int src_reg = fetchdat & 7; - + uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg)); uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg)); uop_ADD(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_8(src_reg)); @@ -1283,7 +1283,7 @@ uint32_t rop80(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch { int dest_reg = fetchdat & 7; uint8_t imm = fastreadb(cs + op_pc + 1); - + if (block->flags & CODEBLOCK_NO_IMMEDIATES) { skip_immediate = 1; @@ -1779,7 +1779,7 @@ uint32_t rop81_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { int skip_immediate = 0; - + codegen_mark_code_present(block, cs+op_pc, 1); if ((fetchdat & 0xc0) == 0xc0) { @@ -1836,7 +1836,7 @@ uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32); uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg)); break; - + case 0x18: /*SBB*/ get_cf(ir, IREG_temp1); uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg)); @@ -1954,7 +1954,7 @@ uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uop_MOV(ir, IREG_flags_res, IREG_temp0); uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN32); break; - + case 0x10: /*ADC*/ get_cf(ir, IREG_temp3); if (block->flags & CODEBLOCK_NO_IMMEDIATES) @@ -2157,7 +2157,7 @@ uint32_t rop83_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uop_MOVZX(ir, IREG_flags_res, IREG_temp0_W); uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16); break; - + case 0x10: /*ADC*/ get_cf(ir, IREG_temp2); uop_ADD_IMM(ir, IREG_temp1_W, IREG_temp0_W, imm); @@ -2227,7 +2227,7 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet { int dest_reg = fetchdat & 7; uint32_t imm = (int32_t)(int8_t)fastreadb(cs + op_pc + 1); - + switch (fetchdat & 0x38) { case 0x00: /*ADD*/ @@ -2243,7 +2243,7 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN32); uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg)); break; - + case 0x10: /*ADC*/ get_cf(ir, IREG_temp1); uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg)); @@ -2299,7 +2299,7 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet { x86seg *target_seg; uint32_t imm; - + uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0); if ((fetchdat & 0x38) == 0x38) /*CMP*/ @@ -2326,7 +2326,7 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uop_MOV(ir, IREG_flags_res, IREG_temp0); uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN32); break; - + case 0x10: /*ADC*/ get_cf(ir, IREG_temp2); uop_ADD_IMM(ir, IREG_temp1, IREG_temp0, imm); @@ -2392,7 +2392,7 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet static void rebuild_c(ir_data_t *ir) { int needs_rebuild = 1; - + if (codegen_flags_changed) { switch (cpu_state.flags_op) @@ -2403,7 +2403,7 @@ static void rebuild_c(ir_data_t *ir) break; } } - + if (needs_rebuild) { uop_CALL_FUNC(ir, flags_rebuild_c); @@ -2426,7 +2426,7 @@ uint32_t ropINC_r16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t uint32_t ropINC_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { rebuild_c(ir); - + uop_MOV(ir, IREG_flags_op1, IREG_32(opcode & 7)); uop_ADD_IMM(ir, IREG_32(opcode & 7), IREG_32(opcode & 7), 1); uop_MOV(ir, IREG_flags_res, IREG_32(opcode & 7)); @@ -2468,7 +2468,7 @@ uint32_t ropINCDEC(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t f { codegen_mark_code_present(block, cs+op_pc, 1); rebuild_c(ir); - + if ((fetchdat & 0xc0) == 0xc0) { uop_MOVZX(ir, IREG_flags_op1, IREG_8(fetchdat & 7)); diff --git a/src/codegen_new/codegen_ops_branch.c b/src/codegen_new/codegen_ops_branch.c index 88c30f2af..b05ce5bac 100644 --- a/src/codegen_new/codegen_ops_branch.c +++ b/src/codegen_new/codegen_ops_branch.c @@ -622,7 +622,7 @@ static int ropJNL_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, { int jump_uop; int do_unroll = ((NF_SET() ? 1 : 0) == (VF_SET() ? 1 : 0) && codegen_can_unroll(block, ir, next_pc, dest_addr)); - + switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { case FLAGS_ZN8: diff --git a/src/codegen_new/codegen_ops_fpu_arith.c b/src/codegen_new/codegen_ops_fpu_arith.c index d4ba9aebb..598f63b80 100644 --- a/src/codegen_new/codegen_ops_fpu_arith.c +++ b/src/codegen_new/codegen_ops_fpu_arith.c @@ -21,7 +21,7 @@ uint32_t ropFADD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uop_FP_ENTER(ir); uop_FADD(ir, IREG_ST(0), IREG_ST(0), IREG_ST(src_reg)); uop_MOV_IMM(ir, IREG_tag(0), TAG_VALID); - + return op_pc; } uint32_t ropFADDr(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) @@ -42,7 +42,7 @@ uint32_t ropFADDP(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe uop_FADD(ir, IREG_ST(dest_reg), IREG_ST(dest_reg), IREG_ST(0)); uop_MOV_IMM(ir, IREG_tag(dest_reg), TAG_VALID); fpu_POP(block, ir); - + return op_pc; } @@ -128,7 +128,7 @@ uint32_t ropFDIVP(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe uop_FDIV(ir, IREG_ST(dest_reg), IREG_ST(dest_reg), IREG_ST(0)); uop_MOV_IMM(ir, IREG_tag(dest_reg), TAG_VALID); fpu_POP(block, ir); - + return op_pc; } uint32_t ropFDIVRP(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) @@ -234,7 +234,7 @@ uint32_t ropFSUBRP(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t f uop_FSUB(ir, IREG_ST(dest_reg), IREG_ST(0), IREG_ST(dest_reg)); uop_MOV_IMM(ir, IREG_tag(dest_reg), TAG_VALID); fpu_POP(block, ir); - + return op_pc; } diff --git a/src/codegen_new/codegen_ops_fpu_constant.c b/src/codegen_new/codegen_ops_fpu_constant.c index a9888f9b3..fc59ae784 100644 --- a/src/codegen_new/codegen_ops_fpu_constant.c +++ b/src/codegen_new/codegen_ops_fpu_constant.c @@ -31,6 +31,6 @@ uint32_t ropFLDZ(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet uop_MOV_DOUBLE_INT(ir, IREG_ST(-1), IREG_temp0); uop_MOV_IMM(ir, IREG_tag(-1), TAG_VALID); fpu_PUSH(block, ir); - + return op_pc; } diff --git a/src/codegen_new/codegen_ops_fpu_misc.c b/src/codegen_new/codegen_ops_fpu_misc.c index 2aea3678b..cfe2ff698 100644 --- a/src/codegen_new/codegen_ops_fpu_misc.c +++ b/src/codegen_new/codegen_ops_fpu_misc.c @@ -91,7 +91,7 @@ uint32_t ropFSTSW_AX(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t { uop_FP_ENTER(ir); uop_MOV(ir, IREG_AX, IREG_NPXS); - + return op_pc; } diff --git a/src/codegen_new/codegen_ops_helpers.c b/src/codegen_new/codegen_ops_helpers.c index 6d8cbfd3a..9c2280f07 100644 --- a/src/codegen_new/codegen_ops_helpers.c +++ b/src/codegen_new/codegen_ops_helpers.c @@ -57,7 +57,7 @@ int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, TOP = cpu_state.TOP; } } - + if (TOP != cpu_state.TOP) return 0; diff --git a/src/codegen_new/codegen_ops_jump.c b/src/codegen_new/codegen_ops_jump.c index f7a5145a0..f672b40ca 100644 --- a/src/codegen_new/codegen_ops_jump.c +++ b/src/codegen_new/codegen_ops_jump.c @@ -28,7 +28,7 @@ uint32_t ropJMP_r16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t { uint32_t offset = (int32_t)(int16_t)fastreadw(cs + op_pc); uint32_t dest_addr = op_pc+2+offset; - + dest_addr &= 0xffff; if (offset < 0) @@ -40,7 +40,7 @@ uint32_t ropJMP_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t { uint32_t offset = fastreadl(cs + op_pc); uint32_t dest_addr = op_pc+4+offset; - + if (offset < 0) codegen_can_unroll(block, ir, op_pc+1, dest_addr); codegen_mark_code_present(block, cs+op_pc, 4); @@ -100,13 +100,13 @@ uint32_t ropCALL_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t uint32_t ret_addr = op_pc + 4; uint32_t dest_addr = ret_addr + offset; int sp_reg; - + uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); sp_reg = LOAD_SP_WITH_OFFSET(ir, -4); uop_MEM_STORE_IMM_32(ir, IREG_SS_base, sp_reg, ret_addr); SUB_SP(ir, 4); uop_MOV_IMM(ir, IREG_pc, dest_addr); - + codegen_mark_code_present(block, cs+op_pc, 4); return -1; } @@ -114,7 +114,7 @@ uint32_t ropCALL_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t uint32_t ropRET_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); - + if (stack32) uop_MEM_LOAD_REG(ir, IREG_temp0_W, IREG_SS_base, IREG_ESP); else @@ -130,7 +130,7 @@ uint32_t ropRET_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t f uint32_t ropRET_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); - + if (stack32) uop_MEM_LOAD_REG(ir, IREG_pc, IREG_SS_base, IREG_ESP); else @@ -146,7 +146,7 @@ uint32_t ropRET_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t f uint32_t ropRET_imm_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { uint16_t offset = fastreadw(cs + op_pc); - + uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); if (stack32) @@ -267,7 +267,7 @@ uint32_t ropRETF_imm_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3 if ((msw&1) && !(cpu_state.eflags&VM_FLAG)) return 0; - + offset = fastreadw(cs + op_pc); uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); diff --git a/src/codegen_new/codegen_ops_logic.c b/src/codegen_new/codegen_ops_logic.c index 5d50423c1..dd02bd3f9 100644 --- a/src/codegen_new/codegen_ops_logic.c +++ b/src/codegen_new/codegen_ops_logic.c @@ -64,7 +64,7 @@ uint32_t ropAND_b_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t if ((fetchdat & 0xc0) == 0xc0) { int src_reg = fetchdat & 7; - + uop_AND(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_8(src_reg)); } else diff --git a/src/codegen_new/codegen_ops_misc.c b/src/codegen_new/codegen_ops_misc.c index c4aae7598..adb478d13 100644 --- a/src/codegen_new/codegen_ops_misc.c +++ b/src/codegen_new/codegen_ops_misc.c @@ -22,13 +22,13 @@ uint32_t ropLEA_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t f codegen_mark_code_present(block, cs+op_pc, 1); codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0); uop_MOV(ir, IREG_16(dest_reg), IREG_eaaddr_W); - + return op_pc + 1; } uint32_t ropLEA_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { int dest_reg = (fetchdat >> 3) & 7; - + if ((fetchdat & 0xc0) == 0xc0) return 0; @@ -44,7 +44,7 @@ uint32_t ropF6(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch x86seg *target_seg = NULL; uint8_t imm_data; int reg; - + if (fetchdat & 0x20) return 0; @@ -67,7 +67,7 @@ uint32_t ropF6(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch { case 0x00: case 0x08: /*TEST*/ imm_data = fastreadb(cs + op_pc + 1); - + uop_AND_IMM(ir, IREG_flags_res_B, reg, imm_data); uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_B); uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN8); @@ -75,7 +75,7 @@ uint32_t ropF6(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch codegen_flags_changed = 1; codegen_mark_code_present(block, cs+op_pc+1, 1); return op_pc+2; - + case 0x10: /*NOT*/ uop_XOR_IMM(ir, reg, reg, 0xff); if ((fetchdat & 0xc0) != 0xc0) @@ -321,7 +321,7 @@ uint32_t ropFF_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe uop_MOV_IMM(ir, IREG_flags_op, FLAGS_INC16); } return op_pc+1; - + case 0x08: /*DEC*/ rebuild_c(ir); codegen_flags_changed = 1; @@ -357,7 +357,7 @@ uint32_t ropFF_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe case 0x20: /*JMP*/ uop_MOVZX(ir, IREG_pc, src_reg); return -1; - + case 0x28: /*JMP far*/ uop_MOVZX(ir, IREG_pc, src_reg); uop_MEM_LOAD_REG_OFFSET(ir, IREG_temp1_W, ireg_seg_base(target_seg), IREG_eaaddr, 2); diff --git a/src/codegen_new/codegen_ops_mov.c b/src/codegen_new/codegen_ops_mov.c index a5618f354..eb748a027 100644 --- a/src/codegen_new/codegen_ops_mov.c +++ b/src/codegen_new/codegen_ops_mov.c @@ -242,7 +242,7 @@ uint32_t ropMOV_EAX_abs(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3 uop_MEM_LOAD_REG(ir, IREG_EAX, ireg_seg_base(op_ea_seg), IREG_eaaddr); else uop_MEM_LOAD_ABS(ir, IREG_EAX, ireg_seg_base(op_ea_seg), addr); - + return op_pc + ((op_32 & 0x200) ? 4 : 2); } @@ -421,7 +421,7 @@ uint32_t ropMOV_w_seg(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_ uint32_t ropMOV_l_seg(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { int src_reg; - + codegen_mark_code_present(block, cs+op_pc, 1); switch (fetchdat & 0x38) { @@ -490,7 +490,7 @@ uint32_t ropMOV_seg_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_ } uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); - + if ((fetchdat & 0xc0) == 0xc0) { uop_MOV(ir, IREG_temp0_W, IREG_16(fetchdat & 7)); @@ -655,11 +655,11 @@ uint32_t ropMOVZX_32_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3 uint32_t ropXCHG_AX(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { int reg2 = IREG_16(opcode & 7); - + uop_MOV(ir, IREG_temp0_W, IREG_AX); uop_MOV(ir, IREG_AX, reg2); uop_MOV(ir, reg2, IREG_temp0_W); - + return op_pc; } uint32_t ropXCHG_EAX(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) @@ -681,7 +681,7 @@ uint32_t ropXCHG_8(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t f if ((fetchdat & 0xc0) == 0xc0) { int reg2 = IREG_8(fetchdat & 7); - + uop_MOV(ir, IREG_temp0_B, reg1); uop_MOV(ir, reg1, reg2); uop_MOV(ir, reg2, IREG_temp0_B); @@ -693,7 +693,7 @@ uint32_t ropXCHG_8(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t f uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0); codegen_check_seg_write(block, ir, target_seg); - + uop_MEM_LOAD_REG(ir, IREG_temp0_B, ireg_seg_base(target_seg), IREG_eaaddr); uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, reg1); uop_MOV(ir, reg1, IREG_temp0_B); @@ -761,7 +761,7 @@ uint32_t ropXCHG_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t uint32_t ropXLAT(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); - + uop_MOVZX(ir, IREG_eaaddr, IREG_AL); uop_ADD(ir, IREG_eaaddr, IREG_eaaddr, IREG_EBX); if (!(op_32 & 0x200)) diff --git a/src/codegen_new/codegen_ops_shift.c b/src/codegen_new/codegen_ops_shift.c index de9a0fecf..370585bf2 100644 --- a/src/codegen_new/codegen_ops_shift.c +++ b/src/codegen_new/codegen_ops_shift.c @@ -58,7 +58,7 @@ static uint32_t shift_common_8(ir_data_t *ir, uint32_t fetchdat, uint32_t op_pc, uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SAR8); uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg)); break; - + default: return 0; } @@ -454,7 +454,7 @@ uint32_t ropC0(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch } imm = fastreadb(cs + op_pc + 1) & 0x1f; codegen_mark_code_present(block, cs+op_pc+1, 1); - + if (imm) return shift_common_8(ir, fetchdat, op_pc, target_seg, imm) + 1; return op_pc+1; @@ -477,7 +477,7 @@ uint32_t ropC1_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet } imm = fastreadb(cs + op_pc + 1) & 0x1f; codegen_mark_code_present(block, cs+op_pc+1, 1); - + if (imm) return shift_common_16(ir, fetchdat, op_pc, target_seg, imm) + 1; return op_pc+1; @@ -501,7 +501,7 @@ uint32_t ropC1_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet { uint32_t new_pc; int jump_uop; - + LOAD_IMMEDIATE_FROM_RAM_8(block, ir, IREG_temp2, cs + op_pc + 1); uop_AND_IMM(ir, IREG_temp2, IREG_temp2, 0x1f); jump_uop = uop_CMP_IMM_JZ_DEST(ir, IREG_temp2, 0); @@ -515,7 +515,7 @@ uint32_t ropC1_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet { uint8_t imm = fastreadb(cs + op_pc + 1) & 0x1f; codegen_mark_code_present(block, cs+op_pc+1, 1); - + if (imm) return shift_common_32(ir, fetchdat, op_pc, target_seg, imm) + 1; } @@ -584,7 +584,7 @@ uint32_t ropD2(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch if (!(CL & 0x1f) || !block->ins) return 0; - + uop_AND_IMM(ir, IREG_temp2, REG_ECX, 0x1f); uop_CMP_IMM_JZ(ir, IREG_temp2, 0, codegen_exit_rout); @@ -706,7 +706,7 @@ uint32_t ropD3_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet if (!(CL & 0x1f) || !block->ins) return 0; - + uop_AND_IMM(ir, IREG_temp2, REG_ECX, 0x1f); uop_CMP_IMM_JZ(ir, IREG_temp2, 0, codegen_exit_rout); @@ -958,7 +958,7 @@ uint32_t ropSHLD_16_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3 } imm = fastreadb(cs + op_pc + 1) & 0x1f; codegen_mark_code_present(block, cs+op_pc+1, 1); - + if (!imm) return op_pc+2; @@ -1006,7 +1006,7 @@ uint32_t ropSHLD_32_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3 } imm = fastreadb(cs + op_pc + 1) & 0x1f; codegen_mark_code_present(block, cs+op_pc+1, 1); - + if (!imm) return op_pc+2; @@ -1054,7 +1054,7 @@ uint32_t ropSHRD_16_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3 } imm = fastreadb(cs + op_pc + 1) & 0x1f; codegen_mark_code_present(block, cs+op_pc+1, 1); - + if (!imm) return op_pc+2; @@ -1102,7 +1102,7 @@ uint32_t ropSHRD_32_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3 } imm = fastreadb(cs + op_pc + 1) & 0x1f; codegen_mark_code_present(block, cs+op_pc+1, 1); - + if (!imm) return op_pc+2; diff --git a/src/codegen_new/codegen_ops_stack.c b/src/codegen_new/codegen_ops_stack.c index 1bb791a3b..ff421488e 100644 --- a/src/codegen_new/codegen_ops_stack.c +++ b/src/codegen_new/codegen_ops_stack.c @@ -141,7 +141,7 @@ uint32_t ropPOP_W(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe { x86seg *target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 2); codegen_check_seg_write(block, ir, target_seg); - + if (stack32) uop_MEM_LOAD_REG(ir, IREG_temp0_W, IREG_SS_base, IREG_ESP); else @@ -340,7 +340,7 @@ uint32_t ropPUSHA_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t uint32_t ropPOPA_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { int sp_reg; - + uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc); sp_reg = LOAD_SP(ir); uop_MEM_LOAD_REG(ir, IREG_DI, IREG_SS_base, sp_reg); diff --git a/src/codegen_new/codegen_reg.c b/src/codegen_new/codegen_reg.c index 04fd88ce8..c11d1ade5 100644 --- a/src/codegen_new/codegen_reg.c +++ b/src/codegen_new/codegen_reg.c @@ -92,14 +92,14 @@ struct [IREG_op32] = {REG_DWORD, &cpu_state.op32, REG_INTEGER, REG_PERMANENT}, [IREG_ssegsx] = {REG_BYTE, &cpu_state.ssegs, REG_INTEGER, REG_PERMANENT}, - + [IREG_rm_mod_reg] = {REG_DWORD, &cpu_state.rm_data.rm_mod_reg_data, REG_INTEGER, REG_PERMANENT}, #ifdef USE_ACYCS [IREG_acycs] = {REG_DWORD, &acycs, REG_INTEGER, REG_PERMANENT}, #endif [IREG_cycles] = {REG_DWORD, &cpu_state._cycles, REG_INTEGER, REG_PERMANENT}, - + [IREG_CS_base] = {REG_DWORD, &cpu_state.seg_cs.base, REG_INTEGER, REG_PERMANENT}, [IREG_DS_base] = {REG_DWORD, &cpu_state.seg_ds.base, REG_INTEGER, REG_PERMANENT}, [IREG_ES_base] = {REG_DWORD, &cpu_state.seg_es.base, REG_INTEGER, REG_PERMANENT}, @@ -113,7 +113,7 @@ struct [IREG_FS_seg] = {REG_WORD, &cpu_state.seg_fs.seg, REG_INTEGER, REG_PERMANENT}, [IREG_GS_seg] = {REG_WORD, &cpu_state.seg_gs.seg, REG_INTEGER, REG_PERMANENT}, [IREG_SS_seg] = {REG_WORD, &cpu_state.seg_ss.seg, REG_INTEGER, REG_PERMANENT}, - + [IREG_FPU_TOP] = {REG_DWORD, &cpu_state.TOP, REG_INTEGER, REG_PERMANENT}, [IREG_ST0] = {REG_FPU_ST_DOUBLE, &cpu_state.ST[0], REG_FP, REG_PERMANENT}, @@ -124,7 +124,7 @@ struct [IREG_ST5] = {REG_FPU_ST_DOUBLE, &cpu_state.ST[0], REG_FP, REG_PERMANENT}, [IREG_ST6] = {REG_FPU_ST_DOUBLE, &cpu_state.ST[0], REG_FP, REG_PERMANENT}, [IREG_ST7] = {REG_FPU_ST_DOUBLE, &cpu_state.ST[0], REG_FP, REG_PERMANENT}, - + [IREG_tag0] = {REG_FPU_ST_BYTE, &cpu_state.tag[0], REG_INTEGER, REG_PERMANENT}, [IREG_tag1] = {REG_FPU_ST_BYTE, &cpu_state.tag[0], REG_INTEGER, REG_PERMANENT}, [IREG_tag2] = {REG_FPU_ST_BYTE, &cpu_state.tag[0], REG_INTEGER, REG_PERMANENT}, @@ -151,7 +151,7 @@ struct [IREG_MM5x] = {REG_QWORD, &cpu_state.MM[5], REG_FP, REG_PERMANENT}, [IREG_MM6x] = {REG_QWORD, &cpu_state.MM[6], REG_FP, REG_PERMANENT}, [IREG_MM7x] = {REG_QWORD, &cpu_state.MM[7], REG_FP, REG_PERMANENT}, - + [IREG_NPXCx] = {REG_WORD, &cpu_state.npxc, REG_INTEGER, REG_PERMANENT}, [IREG_NPXSx] = {REG_WORD, &cpu_state.npxs, REG_INTEGER, REG_PERMANENT}, @@ -179,7 +179,7 @@ struct [IREG_temp1] = {REG_DWORD, (void *)20, REG_INTEGER, REG_VOLATILE}, [IREG_temp2] = {REG_DWORD, (void *)24, REG_INTEGER, REG_VOLATILE}, [IREG_temp3] = {REG_DWORD, (void *)28, REG_INTEGER, REG_VOLATILE}, - + [IREG_temp0d] = {REG_DOUBLE, (void *)40, REG_FP, REG_VOLATILE}, [IREG_temp1d] = {REG_DOUBLE, (void *)48, REG_FP, REG_VOLATILE}, }; @@ -187,11 +187,11 @@ struct void codegen_reg_mark_as_required() { int reg; - + for (reg = 0; reg < IREG_COUNT; reg++) { int last_version = reg_last_version[reg]; - + if (last_version > 0 && ireg_data[reg].is_volatile == REG_PERMANENT) reg_version[reg][last_version].flags |= REG_FLAGS_REQUIRED; } @@ -201,7 +201,7 @@ int reg_is_native_size(ir_reg_t ir_reg) { int native_size = ireg_data[IREG_GET_REG(ir_reg.reg)].native_size; int requested_size = IREG_GET_SIZE(ir_reg.reg); - + switch (native_size) { case REG_BYTE: case REG_FPU_ST_BYTE: @@ -216,11 +216,11 @@ int reg_is_native_size(ir_reg_t ir_reg) if (sizeof(void *) == 4) return (requested_size == IREG_SIZE_L); return (requested_size == IREG_SIZE_Q); - + default: fatal("get_reg_is_native_size: unknown native size %i\n", native_size); } - + return 0; } @@ -254,7 +254,7 @@ void codegen_reg_reset() host_fp_reg_set.regs[c] = invalid_ir_reg; host_fp_reg_set.dirty[c] = 0; } - + reg_dead_list = 0; max_version_refcount = 0; } @@ -308,7 +308,7 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c, else codegen_direct_read_64(block, reg_set->reg_list[c].reg, ireg_data[IREG_GET_REG(ir_reg.reg)].p); break; - + case REG_POINTER: #ifndef RELEASE_BUILD if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_INTEGER) @@ -330,7 +330,7 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c, else codegen_direct_read_double(block, reg_set->reg_list[c].reg, ireg_data[IREG_GET_REG(ir_reg.reg)].p); break; - + case REG_FPU_ST_BYTE: #ifndef RELEASE_BUILD if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_INTEGER) @@ -535,7 +535,7 @@ static void alloc_reg(ir_reg_t ir_reg) host_reg_set_t *reg_set = get_reg_set(ir_reg); int nr_regs = (reg_set == &host_reg_set) ? CODEGEN_HOST_REGS : CODEGEN_HOST_FP_REGS; int c; - + for (c = 0; c < nr_regs; c++) { if (IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg)) @@ -591,7 +591,7 @@ static void alloc_dest_reg(ir_reg_t ir_reg, int dest_reference) void codegen_reg_alloc_register(ir_reg_t dest_reg_a, ir_reg_t src_reg_a, ir_reg_t src_reg_b, ir_reg_t src_reg_c) { int dest_reference = 0; - + host_reg_set.locked = 0; host_fp_reg_set.locked = 0; @@ -680,16 +680,16 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg) { host_reg_set_t *reg_set = get_reg_set(ir_reg); int c; - + if (!reg_is_native_size(ir_reg)) { /*Read in parent register so we can do partial accesses to it*/ ir_reg_t parent_reg; - + parent_reg.reg = IREG_GET_REG(ir_reg.reg) | IREG_SIZE_L; parent_reg.version = ir_reg.version - 1; reg_version[IREG_GET_REG(ir_reg.reg)][ir_reg.version - 1].refcount++; - + codegen_reg_alloc_read_reg(block, parent_reg, &c); #ifndef RELEASE_BUILD @@ -704,7 +704,7 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg) reg_set->dirty[c] = 1; return reg_set->reg_list[c].reg | IREG_GET_SIZE(ir_reg.reg); } - + /*Search for previous version in host register*/ for (c = 0; c < reg_set->nr_regs; c++) { @@ -720,7 +720,7 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg) } } } - + if (c == reg_set->nr_regs) { /*Search for unused registers*/ @@ -729,7 +729,7 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg) if (ir_reg_is_invalid(reg_set->regs[c])) break; } - + if (c == reg_set->nr_regs) { /*No unused registers. Search for an unlocked register*/ @@ -746,7 +746,7 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg) codegen_reg_writeback(reg_set, block, c, 1); } } - + reg_set->regs[c].reg = ir_reg.reg; reg_set->regs[c].version = ir_reg.version; reg_set->dirty[c] = 1; @@ -819,7 +819,7 @@ void codegen_reg_flush(ir_data_t *ir, codeblock_t *block) { host_reg_set_t *reg_set; int c; - + reg_set = &host_reg_set; for (c = 0; c < reg_set->nr_regs; c++) { @@ -853,7 +853,7 @@ void codegen_reg_flush_invalidate(ir_data_t *ir, codeblock_t *block) { host_reg_set_t *reg_set; int c; - + reg_set = &host_reg_set; for (c = 0; c < reg_set->nr_regs; c++) { diff --git a/src/codegen_new/codegen_reg.h b/src/codegen_new/codegen_reg.h index 8bb84e5f9..d822a950f 100644 --- a/src/codegen_new/codegen_reg.h +++ b/src/codegen_new/codegen_reg.h @@ -38,9 +38,9 @@ enum IREG_ea_seg = 15, IREG_op32 = 16, IREG_ssegsx = 17, - + IREG_rm_mod_reg = 18, - + IREG_acycs = 19, IREG_cycles = 20, @@ -70,7 +70,7 @@ enum IREG_temp0d = 38, IREG_temp1d = 39, - + /*FPU stack registers are physical registers. Use IREG_ST() / IREG_tag() to access. When CODEBLOCK_STATIC_TOP is set, the physical register number will be @@ -85,7 +85,7 @@ enum IREG_ST5 = 45, IREG_ST6 = 46, IREG_ST7 = 47, - + IREG_tag0 = 48, IREG_tag1 = 49, IREG_tag2 = 50, @@ -103,7 +103,7 @@ enum IREG_ST5_i64 = 61, IREG_ST6_i64 = 62, IREG_ST7_i64 = 63, - + IREG_MM0x = 64, IREG_MM1x = 65, IREG_MM2x = 66, @@ -112,13 +112,13 @@ enum IREG_MM5x = 69, IREG_MM6x = 70, IREG_MM7x = 71, - + IREG_NPXCx = 72, IREG_NPXSx = 73, - + IREG_flagsx = 74, IREG_eflagsx = 75, - + IREG_CS_limit_low = 76, IREG_DS_limit_low = 77, IREG_ES_limit_low = 78, @@ -134,9 +134,9 @@ enum IREG_SS_limit_high = 87, IREG_COUNT = 88, - + IREG_INVALID = 255, - + IREG_AX = IREG_EAX + IREG_SIZE_W, IREG_CX = IREG_ECX + IREG_SIZE_W, IREG_DX = IREG_EDX + IREG_SIZE_W, @@ -155,7 +155,7 @@ enum IREG_CH = IREG_ECX + IREG_SIZE_BH, IREG_DH = IREG_EDX + IREG_SIZE_BH, IREG_BH = IREG_EBX + IREG_SIZE_BH, - + IREG_flags_res_W = IREG_flags_res + IREG_SIZE_W, IREG_flags_op1_W = IREG_flags_op1 + IREG_SIZE_W, IREG_flags_op2_W = IREG_flags_op2 + IREG_SIZE_W, @@ -168,7 +168,7 @@ enum IREG_temp1_W = IREG_temp1 + IREG_SIZE_W, IREG_temp2_W = IREG_temp2 + IREG_SIZE_W, IREG_temp3_W = IREG_temp3 + IREG_SIZE_W, - + IREG_temp0_B = IREG_temp0 + IREG_SIZE_B, IREG_temp1_B = IREG_temp1 + IREG_SIZE_B, IREG_temp2_B = IREG_temp2 + IREG_SIZE_B, @@ -181,14 +181,14 @@ enum IREG_temp1_Q = IREG_temp1d + IREG_SIZE_Q, IREG_eaaddr_W = IREG_eaaddr + IREG_SIZE_W, - + IREG_CS_seg_W = IREG_CS_seg + IREG_SIZE_W, IREG_DS_seg_W = IREG_DS_seg + IREG_SIZE_W, IREG_ES_seg_W = IREG_ES_seg + IREG_SIZE_W, IREG_FS_seg_W = IREG_FS_seg + IREG_SIZE_W, IREG_GS_seg_W = IREG_GS_seg + IREG_SIZE_W, IREG_SS_seg_W = IREG_SS_seg + IREG_SIZE_W, - + IREG_MM0 = IREG_MM0x + IREG_SIZE_Q, IREG_MM1 = IREG_MM1x + IREG_SIZE_Q, IREG_MM2 = IREG_MM2x + IREG_SIZE_Q, @@ -197,12 +197,12 @@ enum IREG_MM5 = IREG_MM5x + IREG_SIZE_Q, IREG_MM6 = IREG_MM6x + IREG_SIZE_Q, IREG_MM7 = IREG_MM7x + IREG_SIZE_Q, - + IREG_NPXC = IREG_NPXCx + IREG_SIZE_W, IREG_NPXS = IREG_NPXSx + IREG_SIZE_W, - + IREG_ssegs = IREG_ssegsx + IREG_SIZE_B, - + IREG_flags = IREG_flagsx + IREG_SIZE_W, IREG_eflags = IREG_eflagsx + IREG_SIZE_W }; @@ -324,7 +324,7 @@ static inline ir_reg_t codegen_reg_read(int reg) { ir_reg_t ireg; reg_version_t *version; - + #ifndef RELEASE_BUILD if (IREG_GET_REG(reg) == IREG_INVALID) fatal("codegen_reg_read - IREG_INVALID\n"); @@ -354,21 +354,21 @@ static inline ir_reg_t codegen_reg_write(int reg, int uop_nr) ir_reg_t ireg; int last_version = reg_last_version[IREG_GET_REG(reg)]; reg_version_t *version; - + #ifndef RELEASE_BUILD if (IREG_GET_REG(reg) == IREG_INVALID) fatal("codegen_reg_write - IREG_INVALID\n"); #endif ireg.reg = reg; ireg.version = last_version + 1; - + if (IREG_GET_REG(reg) > IREG_EBX && last_version && !reg_version[IREG_GET_REG(reg)][last_version].refcount && !(reg_version[IREG_GET_REG(reg)][last_version].flags & REG_FLAGS_REQUIRED)) { if (reg_is_native_size(ireg)) /*Non-native size registers have an implicit dependency on the previous version, so don't add to dead list*/ add_to_dead_list(®_version[IREG_GET_REG(reg)][last_version], IREG_GET_REG(reg), last_version); } - + reg_last_version[IREG_GET_REG(reg)]++; #ifndef RELEASE_BUILD if (!reg_last_version[IREG_GET_REG(reg)]) diff --git a/src/config.c b/src/config.c index 5f3503ea9..658e3be01 100644 --- a/src/config.c +++ b/src/config.c @@ -272,7 +272,7 @@ config_free(void) ent = nent; } - free(sec); + free(sec); sec = ns; } } @@ -318,7 +318,7 @@ config_read(char *fn) f = plat_fopen(fn, "rt, ccs=UTF-8"); #endif if (f == NULL) return(0); - + sec = malloc(sizeof(section_t)); memset(sec, 0x00, sizeof(section_t)); memset(&config_head, 0x00, sizeof(list_t)); @@ -365,7 +365,7 @@ config_read(char *fn) list_add(&ns->list, &config_head); /* New section is now the current one. */ - sec = ns; + sec = ns; continue; } @@ -464,7 +464,7 @@ config_write(char *fn) sec = (section_t *)sec->list.next; } - + (void)fclose(f); } @@ -571,14 +571,14 @@ load_general(void) if (p != NULL) { lang_id = plat_language_code(p); - } - + } + p = config_get_string(cat, "iconset", NULL); if (p != NULL) strcpy(icon_set, p); else strcpy(icon_set, ""); - + enable_discord = !!config_get_int(cat, "enable_discord", 0); video_framerate = config_get_int(cat, "video_gl_framerate", -1); @@ -677,7 +677,7 @@ load_machine(void) machine = machine_get_machine_from_internal_name(p); migrate_from = NULL; } - } else + } else machine = 0; /* This is for backwards compatibility. */ @@ -833,20 +833,20 @@ load_machine(void) p = (char *)config_get_string(cat, "fpu_type", "none"); fpu_type = fpu_get_type(cpu_f, cpu, p); - mem_size = config_get_int(cat, "mem_size", 64); + mem_size = config_get_int(cat, "mem_size", 64); #if 0 if (mem_size < ((machine_has_bus(machine, MACHINE_AT) && (machines[machine].ram_granularity < 128)) ? machines[machine].min_ram*1024 : machines[machine].min_ram)) mem_size = (((machine_has_bus(machine, MACHINE_AT) && (machines[machine].ram_granularity < 128)) ? machines[machine].min_ram*1024 : machines[machine].min_ram); #endif - + if (mem_size > 2097152) mem_size = 2097152; cpu_use_dynarec = !!config_get_int(cat, "cpu_use_dynarec", 0); p = config_get_string(cat, "time_sync", NULL); - if (p != NULL) { + if (p != NULL) { if (!strcmp(p, "disabled")) time_sync = TIME_SYNC_DISABLED; else @@ -977,7 +977,7 @@ load_input_devices(void) sprintf(temp, "joystick_%i_axis_%i", c, d); joystick_state[c].axis_mapping[d] = config_get_int(cat, temp, d); } - for (d=0; d 511) @@ -1139,7 +1139,7 @@ load_storage_controllers(void) /* TODO: Backwards compatibility, get rid of this when enough time has passed. */ backwards_compat2 = (find_section(cat) == NULL); - + /* TODO: Backwards compatibility, get rid of this when enough time has passed. */ p = config_get_string(cat, "scsicard", NULL); if (p != NULL) { @@ -1965,7 +1965,7 @@ load_other_removable_devices(void) sprintf(temp, "mo_%02i_iso_path", c+1); config_delete_var(cat, temp); - } + } } @@ -1978,7 +1978,7 @@ load_other_peripherals(void) char temp[512]; int c, free_p = 0; - if (backwards_compat2) { + if (backwards_compat2) { p = config_get_string(cat, "scsicard", NULL); if (p != NULL) scsi_card_current[0] = scsi_card_get_from_internal_name(p); @@ -2041,7 +2041,7 @@ load_other_peripherals(void) } p = config_get_string(cat, "isartc_type", "none"); - isartc_type = isartc_get_from_internal_name(p); + isartc_type = isartc_get_from_internal_name(p); } @@ -2258,7 +2258,7 @@ save_general(void) if (hide_tool_bar != 0) config_set_int(cat, "hide_tool_bar", hide_tool_bar); else - config_delete_var(cat, "hide_tool_bar"); + config_delete_var(cat, "hide_tool_bar"); if (confirm_reset != 1) config_set_int(cat, "confirm_reset", confirm_reset); @@ -2283,7 +2283,7 @@ save_general(void) plat_language_code_r(lang_id, buffer, 511); config_set_string(cat, "language", buffer); } - + if (!strcmp(icon_set, "")) config_delete_var(cat, "iconset"); else @@ -2354,7 +2354,7 @@ save_machine(void) /* Match the family name, speed and multiplier. */ if (!strcmp(cpu_f->internal_name, legacy_table_entry->family)) { - if ((legacy_table_entry->rspeed == cpu_f->cpus[cpu].rspeed) && + if ((legacy_table_entry->rspeed == cpu_f->cpus[cpu].rspeed) && (legacy_table_entry->multi == cpu_f->cpus[cpu].multi)) { /* exact speed/multiplier match */ legacy_cpu = i; break; @@ -2447,15 +2447,15 @@ save_input_devices(void) sprintf(tmp2, "joystick_%i_nr", c); config_delete_var(cat, tmp2); - for (d=0; d<16; d++) { + for (d=0; d<16; d++) { sprintf(tmp2, "joystick_%i_axis_%i", c, d); config_delete_var(cat, tmp2); } - for (d=0; d<16; d++) { + for (d=0; d<16; d++) { sprintf(tmp2, "joystick_%i_button_%i", c, d); config_delete_var(cat, tmp2); } - for (d=0; d<16; d++) { + for (d=0; d<16; d++) { sprintf(tmp2, "joystick_%i_pov_%i", c, d); config_delete_var(cat, tmp2); } @@ -2468,15 +2468,15 @@ save_input_devices(void) config_set_int(cat, tmp2, joystick_state[c].plat_joystick_nr); if (joystick_state[c].plat_joystick_nr) { - for (d=0; dname[0]) config_log("[%s]\n", sec->name); - + ent = (entry_t *)sec->entry_head.next; while (ent != NULL) { config_log("%s = %s\n", ent->name, ent->data); @@ -3072,7 +3072,7 @@ config_delete_var(char *head, char *name) section = find_section(head); if (section == NULL) return; - + entry = find_entry(section, name); if (entry != NULL) { list_delete(&entry->list, §ion->entry_head); @@ -3091,7 +3091,7 @@ config_get_int(char *head, char *name, int def) section = find_section(head); if (section == NULL) return(def); - + entry = find_entry(section, name); if (entry == NULL) return(def); @@ -3112,7 +3112,7 @@ config_get_double(char *head, char *name, double def) section = find_section(head); if (section == NULL) return(def); - + entry = find_entry(section, name); if (entry == NULL) return(def); @@ -3199,7 +3199,7 @@ config_get_string(char *head, char *name, char *def) entry = find_entry(section, name); if (entry == NULL) return(def); - + return(entry->data); } @@ -3217,7 +3217,7 @@ config_get_wstring(char *head, char *name, wchar_t *def) entry = find_entry(section, name); if (entry == NULL) return(def); - + return(entry->wdata); } diff --git a/src/cpu/386_common.c b/src/cpu/386_common.c index 4eb9530ba..73a06f553 100644 --- a/src/cpu/386_common.c +++ b/src/cpu/386_common.c @@ -1172,7 +1172,7 @@ enter_smm(int in_hlt) flushmmucache(); } - + oldcpl = 0; cpu_cur_status &= ~(CPU_STATUS_PMODE | CPU_STATUS_V86); @@ -1518,7 +1518,7 @@ idivl(int32_t val) int64_t num, quo; int32_t rem, quo32; - if (val == 0) { + if (val == 0) { divexcp(); return 1; } diff --git a/src/cpu/386_common.h b/src/cpu/386_common.h index d9201f997..28aab7450 100644 --- a/src/cpu/386_common.h +++ b/src/cpu/386_common.h @@ -161,8 +161,8 @@ int checkio(uint32_t port); static __inline uint8_t fastreadb(uint32_t a) { uint8_t *t; - - if ((a >> 12) == pccache) + + if ((a >> 12) == pccache) return *((uint8_t *)&pccache2[a]); t = getpccache(a); if (cpu_state.abrt) diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index 4371efd00..6e70c03ea 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -72,54 +72,54 @@ static __inline void fetch_ea_32_long(uint32_t rmdat) if (cpu_rm == 4) { uint8_t sib = rmdat >> 8; - + switch (cpu_mod) { - case 0: - cpu_state.eaaddr = cpu_state.regs[sib & 7].l; - cpu_state.pc++; - break; - case 1: + case 0: + cpu_state.eaaddr = cpu_state.regs[sib & 7].l; cpu_state.pc++; - cpu_state.eaaddr = ((uint32_t)(int8_t)getbyte()) + cpu_state.regs[sib & 7].l; break; - case 2: - cpu_state.eaaddr = (fastreadl(cs + cpu_state.pc + 1)) + cpu_state.regs[sib & 7].l; - cpu_state.pc += 5; + case 1: + cpu_state.pc++; + cpu_state.eaaddr = ((uint32_t)(int8_t)getbyte()) + cpu_state.regs[sib & 7].l; + break; + case 2: + cpu_state.eaaddr = (fastreadl(cs + cpu_state.pc + 1)) + cpu_state.regs[sib & 7].l; + cpu_state.pc += 5; break; } /*SIB byte present*/ - if ((sib & 7) == 5 && !cpu_mod) + if ((sib & 7) == 5 && !cpu_mod) cpu_state.eaaddr = getlong(); else if ((sib & 6) == 4 && !cpu_state.ssegs) { easeg = ss; cpu_state.ea_seg = &cpu_state.seg_ss; } - if (((sib >> 3) & 7) != 4) + if (((sib >> 3) & 7) != 4) cpu_state.eaaddr += cpu_state.regs[(sib >> 3) & 7].l << (sib >> 6); } else { cpu_state.eaaddr = cpu_state.regs[cpu_rm].l; - if (cpu_mod) + if (cpu_mod) { if (cpu_rm == 5 && !cpu_state.ssegs) { easeg = ss; cpu_state.ea_seg = &cpu_state.seg_ss; } - if (cpu_mod == 1) - { - cpu_state.eaaddr += ((uint32_t)(int8_t)(rmdat >> 8)); - cpu_state.pc++; - } - else + if (cpu_mod == 1) { - cpu_state.eaaddr += getlong(); + cpu_state.eaaddr += ((uint32_t)(int8_t)(rmdat >> 8)); + cpu_state.pc++; + } + else + { + cpu_state.eaaddr += getlong(); } } - else if (cpu_rm == 5) + else if (cpu_rm == 5) { cpu_state.eaaddr = getlong(); } @@ -138,8 +138,8 @@ static __inline void fetch_ea_16_long(uint32_t rmdat) { eal_r = eal_w = NULL; easeg = cpu_state.ea_seg->base; - if (!cpu_mod && cpu_rm == 6) - { + if (!cpu_mod && cpu_rm == 6) + { cpu_state.eaaddr = getword(); } else @@ -174,7 +174,7 @@ static __inline void fetch_ea_16_long(uint32_t rmdat) } } -#define fetch_ea_16(rmdat) cpu_state.pc++; cpu_mod=(rmdat >> 6) & 3; cpu_reg=(rmdat >> 3) & 7; cpu_rm = rmdat & 7; if (cpu_mod != 3) { fetch_ea_16_long(rmdat); if (cpu_state.abrt) return 1; } +#define fetch_ea_16(rmdat) cpu_state.pc++; cpu_mod=(rmdat >> 6) & 3; cpu_reg=(rmdat >> 3) & 7; cpu_rm = rmdat & 7; if (cpu_mod != 3) { fetch_ea_16_long(rmdat); if (cpu_state.abrt) return 1; } #define fetch_ea_32(rmdat) cpu_state.pc++; cpu_mod=(rmdat >> 6) & 3; cpu_reg=(rmdat >> 3) & 7; cpu_rm = rmdat & 7; if (cpu_mod != 3) { fetch_ea_32_long(rmdat); } if (cpu_state.abrt) return 1 #include "x86_flags.h" @@ -232,23 +232,23 @@ static void prefetch_run(int instr_cycles, int bytes, int modrm, int reads, int prefetch_bytes -= ((modrm & 0xc0) >> 6); } } - + /* Fill up prefetch queue */ while (prefetch_bytes < 0) { prefetch_bytes += cpu_prefetch_width; cycles -= cpu_prefetch_cycles; } - + /* Subtract cycles used for memory access by instruction */ instr_cycles -= mem_cycles; - + while (instr_cycles >= cpu_prefetch_cycles) { prefetch_bytes += cpu_prefetch_width; instr_cycles -= cpu_prefetch_cycles; } - + prefetch_prefixes = 0; if (prefetch_bytes > 16) prefetch_bytes = 16; diff --git a/src/cpu/386_ops.h b/src/cpu/386_ops.h index 8d2b9edf9..4518be9a9 100644 --- a/src/cpu/386_ops.h +++ b/src/cpu/386_ops.h @@ -334,7 +334,7 @@ static int op0F_l_a16(uint32_t fetchdat) int opcode = fetchdat & 0xff; fopcode = opcode; cpu_state.pc++; - + PREFETCH_PREFIX(); return x86_opcodes_0f[opcode | 0x100](fetchdat >> 8); @@ -344,7 +344,7 @@ static int op0F_w_a32(uint32_t fetchdat) int opcode = fetchdat & 0xff; fopcode = opcode; cpu_state.pc++; - + PREFETCH_PREFIX(); return x86_opcodes_0f[opcode | 0x200](fetchdat >> 8); @@ -354,17 +354,17 @@ static int op0F_l_a32(uint32_t fetchdat) int opcode = fetchdat & 0xff; fopcode = opcode; cpu_state.pc++; - + PREFETCH_PREFIX(); return x86_opcodes_0f[opcode | 0x300](fetchdat >> 8); } -const OpFn OP_TABLE(286_0f)[1024] = +const OpFn OP_TABLE(286_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_286, opLAR_w_a16, opLSL_w_a16, ILLEGAL, opLOADALL, opCLTS, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -386,7 +386,7 @@ const OpFn OP_TABLE(286_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_286, opLAR_w_a16, opLSL_w_a16, ILLEGAL, opLOADALL, opCLTS, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -408,7 +408,7 @@ const OpFn OP_TABLE(286_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_286, opLAR_w_a16, opLSL_w_a16, ILLEGAL, opLOADALL, opCLTS, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -430,7 +430,7 @@ const OpFn OP_TABLE(286_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_286, opLAR_w_a16, opLSL_w_a16, ILLEGAL, opLOADALL, opCLTS, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -452,10 +452,10 @@ const OpFn OP_TABLE(286_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, }; -const OpFn OP_TABLE(386_0f)[1024] = +const OpFn OP_TABLE(386_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_w_r_a16, opMOV_r_b_a16, opMOV_r_w_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -477,7 +477,7 @@ const OpFn OP_TABLE(386_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_l_r_a16, opMOV_r_b_a16, opMOV_r_l_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -499,7 +499,7 @@ const OpFn OP_TABLE(386_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_w_r_a32, opMOV_r_b_a32, opMOV_r_w_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -521,7 +521,7 @@ const OpFn OP_TABLE(386_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_l_r_a32, opMOV_r_b_a32, opMOV_r_l_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -543,10 +543,10 @@ const OpFn OP_TABLE(386_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, }; -const OpFn OP_TABLE(486_0f)[1024] = +const OpFn OP_TABLE(486_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_w_r_a16, opMOV_r_b_a16, opMOV_r_w_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -568,7 +568,7 @@ const OpFn OP_TABLE(486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_l_r_a16, opMOV_r_b_a16, opMOV_r_l_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -590,7 +590,7 @@ const OpFn OP_TABLE(486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_w_r_a32, opMOV_r_b_a32, opMOV_r_w_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -612,7 +612,7 @@ const OpFn OP_TABLE(486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_l_r_a32, opMOV_r_b_a32, opMOV_r_l_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -634,10 +634,10 @@ const OpFn OP_TABLE(486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, }; -const OpFn OP_TABLE(c486_0f)[1024] = +const OpFn OP_TABLE(c486_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -659,7 +659,7 @@ const OpFn OP_TABLE(c486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -681,7 +681,7 @@ const OpFn OP_TABLE(c486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -703,7 +703,7 @@ const OpFn OP_TABLE(c486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -725,10 +725,10 @@ const OpFn OP_TABLE(c486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, }; -const OpFn OP_TABLE(stpc_0f)[1024] = +const OpFn OP_TABLE(stpc_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -750,7 +750,7 @@ const OpFn OP_TABLE(stpc_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -772,7 +772,7 @@ const OpFn OP_TABLE(stpc_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -794,7 +794,7 @@ const OpFn OP_TABLE(stpc_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -816,10 +816,10 @@ const OpFn OP_TABLE(stpc_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, }; -const OpFn OP_TABLE(ibm486_0f)[1024] = +const OpFn OP_TABLE(ibm486_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_w_r_a16, opMOV_r_b_a16, opMOV_r_w_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -841,7 +841,7 @@ const OpFn OP_TABLE(ibm486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_l_r_a16, opMOV_r_b_a16, opMOV_r_l_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -863,7 +863,7 @@ const OpFn OP_TABLE(ibm486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_w_r_a32, opMOV_r_b_a32, opMOV_r_w_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -885,7 +885,7 @@ const OpFn OP_TABLE(ibm486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, opLOADALL386, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_l_r_a32, opMOV_r_b_a32, opMOV_r_l_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -907,10 +907,10 @@ const OpFn OP_TABLE(ibm486_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, }; -const OpFn OP_TABLE(winchip_0f)[1024] = +const OpFn OP_TABLE(winchip_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -932,7 +932,7 @@ const OpFn OP_TABLE(winchip_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -954,7 +954,7 @@ const OpFn OP_TABLE(winchip_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -976,7 +976,7 @@ const OpFn OP_TABLE(winchip_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1089,10 +1089,10 @@ const OpFn OP_TABLE(winchip2_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, }; -const OpFn OP_TABLE(pentium_0f)[1024] = +const OpFn OP_TABLE(pentium_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_w_r_a16, opMOV_r_b_a16, opMOV_r_w_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1114,7 +1114,7 @@ const OpFn OP_TABLE(pentium_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a16, opMOV_l_r_a16, opMOV_r_b_a16, opMOV_r_l_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1136,7 +1136,7 @@ const OpFn OP_TABLE(pentium_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_w_r_a32, opMOV_r_b_a32, opMOV_r_w_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1158,7 +1158,7 @@ const OpFn OP_TABLE(pentium_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ opMOV_b_r_a32, opMOV_l_r_a32, opMOV_r_b_a32, opMOV_r_l_a32, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1273,10 +1273,10 @@ const OpFn OP_TABLE(c6x86_0f)[1024] = }; #endif -const OpFn OP_TABLE(pentiummmx_0f)[1024] = +const OpFn OP_TABLE(pentiummmx_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1298,7 +1298,7 @@ const OpFn OP_TABLE(pentiummmx_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1320,7 +1320,7 @@ const OpFn OP_TABLE(pentiummmx_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1342,7 +1342,7 @@ const OpFn OP_TABLE(pentiummmx_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1364,10 +1364,10 @@ const OpFn OP_TABLE(pentiummmx_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, }; -const OpFn OP_TABLE(k6_0f)[1024] = +const OpFn OP_TABLE(k6_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1389,7 +1389,7 @@ const OpFn OP_TABLE(k6_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1411,7 +1411,7 @@ const OpFn OP_TABLE(k6_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1433,7 +1433,7 @@ const OpFn OP_TABLE(k6_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1455,10 +1455,10 @@ const OpFn OP_TABLE(k6_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, }; -const OpFn OP_TABLE(k62_0f)[1024] = +const OpFn OP_TABLE(k62_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opPREFETCH_a16, opFEMMS, op3DNOW_a16, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1480,7 +1480,7 @@ const OpFn OP_TABLE(k62_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opPREFETCH_a16, opFEMMS, op3DNOW_a16, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1502,7 +1502,7 @@ const OpFn OP_TABLE(k62_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opPREFETCH_a32, opFEMMS, op3DNOW_a32, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1524,7 +1524,7 @@ const OpFn OP_TABLE(k62_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, opSYSCALL, opCLTS, opSYSRET, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opPREFETCH_a32, opFEMMS, op3DNOW_a32, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1547,10 +1547,10 @@ const OpFn OP_TABLE(k62_0f)[1024] = }; #if defined(DEV_BRANCH) && defined(USE_CYRIX_6X86) -const OpFn OP_TABLE(c6x86mx_0f)[1024] = +const OpFn OP_TABLE(c6x86mx_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1572,7 +1572,7 @@ const OpFn OP_TABLE(c6x86mx_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1594,7 +1594,7 @@ const OpFn OP_TABLE(c6x86mx_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1616,7 +1616,7 @@ const OpFn OP_TABLE(c6x86mx_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1639,10 +1639,10 @@ const OpFn OP_TABLE(c6x86mx_0f)[1024] = }; #endif -const OpFn OP_TABLE(pentiumpro_0f)[1024] = +const OpFn OP_TABLE(pentiumpro_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1664,7 +1664,7 @@ const OpFn OP_TABLE(pentiumpro_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1686,7 +1686,7 @@ const OpFn OP_TABLE(pentiumpro_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1708,7 +1708,7 @@ const OpFn OP_TABLE(pentiumpro_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1730,10 +1730,10 @@ const OpFn OP_TABLE(pentiumpro_0f)[1024] = /*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, }; -const OpFn OP_TABLE(pentium2_0f)[1024] = +const OpFn OP_TABLE(pentium2_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1755,7 +1755,7 @@ const OpFn OP_TABLE(pentium2_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1777,7 +1777,7 @@ const OpFn OP_TABLE(pentium2_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1799,7 +1799,7 @@ const OpFn OP_TABLE(pentium2_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1821,10 +1821,10 @@ const OpFn OP_TABLE(pentium2_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, }; -const OpFn OP_TABLE(pentium2d_0f)[1024] = +const OpFn OP_TABLE(pentium2d_0f)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_w_a16, opLAR_w_a16, opLSL_w_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1846,7 +1846,7 @@ const OpFn OP_TABLE(pentium2d_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a16, op0F01_l_a16, opLAR_l_a16, opLSL_l_a16, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, opHINT_NOP_a16, /*20*/ opMOV_r_CRx_a16,opMOV_r_DRx_a16,opMOV_CRx_r_a16,opMOV_DRx_r_a16,opMOV_r_TRx_a16,ILLEGAL, opMOV_TRx_r_a16,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1868,7 +1868,7 @@ const OpFn OP_TABLE(pentium2d_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a16, opPSLLD_a16, opPSLLQ_a16, ILLEGAL, opPMADDWD_a16, ILLEGAL, ILLEGAL, opPSUBB_a16, opPSUBW_a16, opPSUBD_a16, ILLEGAL, opPADDB_a16, opPADDW_a16, opPADDD_a16, ILLEGAL, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_w_a32, opLAR_w_a32, opLSL_w_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1890,7 +1890,7 @@ const OpFn OP_TABLE(pentium2d_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ op0F00_a32, op0F01_l_a32, opLAR_l_a32, opLSL_l_a32, ILLEGAL, ILLEGAL, opCLTS, ILLEGAL, opINVD, opWBINVD, ILLEGAL, ILLEGAL, ILLEGAL, opNOP, ILLEGAL, ILLEGAL, /*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, opHINT_NOP_a32, /*20*/ opMOV_r_CRx_a32,opMOV_r_DRx_a32,opMOV_CRx_r_a32,opMOV_DRx_r_a32,opMOV_r_TRx_a32,ILLEGAL, opMOV_TRx_r_a32,ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, @@ -1912,17 +1912,17 @@ const OpFn OP_TABLE(pentium2d_0f)[1024] = /*f0*/ ILLEGAL, opPSLLW_a32, opPSLLD_a32, opPSLLQ_a32, ILLEGAL, opPMADDWD_a32, ILLEGAL, ILLEGAL, opPSUBB_a32, opPSUBW_a32, opPSUBD_a32, ILLEGAL, opPADDB_a32, opPADDW_a32, opPADDD_a32, ILLEGAL, }; -const OpFn OP_TABLE(286)[1024] = +const OpFn OP_TABLE(286)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ opADD_b_rmw_a16,opADD_w_rmw_a16,opADD_b_rm_a16, opADD_w_rm_a16, opADD_AL_imm, opADD_AX_imm, opPUSH_ES_w, opPOP_ES_w, opOR_b_rmw_a16, opOR_w_rmw_a16, opOR_b_rm_a16, opOR_w_rm_a16, opOR_AL_imm, opOR_AX_imm, opPUSH_CS_w, op0F_w_a16, /*10*/ opADC_b_rmw_a16,opADC_w_rmw_a16,opADC_b_rm_a16, opADC_w_rm_a16, opADC_AL_imm, opADC_AX_imm, opPUSH_SS_w, opPOP_SS_w, opSBB_b_rmw_a16,opSBB_w_rmw_a16,opSBB_b_rm_a16, opSBB_w_rm_a16, opSBB_AL_imm, opSBB_AX_imm, opPUSH_DS_w, opPOP_DS_w, /*20*/ opAND_b_rmw_a16,opAND_w_rmw_a16,opAND_b_rm_a16, opAND_w_rm_a16, opAND_AL_imm, opAND_AX_imm, opES_w_a16, opDAA, opSUB_b_rmw_a16,opSUB_w_rmw_a16,opSUB_b_rm_a16, opSUB_w_rm_a16, opSUB_AL_imm, opSUB_AX_imm, opCS_w_a16, opDAS, /*30*/ opXOR_b_rmw_a16,opXOR_w_rmw_a16,opXOR_b_rm_a16, opXOR_w_rm_a16, opXOR_AL_imm, opXOR_AX_imm, opSS_w_a16, opAAA, opCMP_b_rmw_a16,opCMP_w_rmw_a16,opCMP_b_rm_a16, opCMP_w_rm_a16, opCMP_AL_imm, opCMP_AX_imm, opDS_w_a16, opAAS, -/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, -/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, +/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, +/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, /*60*/ opPUSHA_w, opPOPA_w, opBOUND_w_a16, opARPL_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPUSH_imm_w, opIMUL_w_iw_a16,opPUSH_imm_bw, opIMUL_w_ib_a16,opINSB_a16, opINSW_a16, opOUTSB_a16, opOUTSW_a16, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -1937,14 +1937,14 @@ const OpFn OP_TABLE(286)[1024] = /*f0*/ opLOCK, opLOCK, opREPNE, opREPE, opHLT, opCMC, opF6_a16, opF7_w_a16, opCLC, opSTC, opCLI, opSTI, opCLD, opSTD, opINCDEC_b_a16, opFF_w_a16, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ opADD_b_rmw_a16,opADD_w_rmw_a16,opADD_b_rm_a16, opADD_w_rm_a16, opADD_AL_imm, opADD_AX_imm, opPUSH_ES_w, opPOP_ES_w, opOR_b_rmw_a16, opOR_w_rmw_a16, opOR_b_rm_a16, opOR_w_rm_a16, opOR_AL_imm, opOR_AX_imm, opPUSH_CS_w, op0F_w_a16, /*10*/ opADC_b_rmw_a16,opADC_w_rmw_a16,opADC_b_rm_a16, opADC_w_rm_a16, opADC_AL_imm, opADC_AX_imm, opPUSH_SS_w, opPOP_SS_w, opSBB_b_rmw_a16,opSBB_w_rmw_a16,opSBB_b_rm_a16, opSBB_w_rm_a16, opSBB_AL_imm, opSBB_AX_imm, opPUSH_DS_w, opPOP_DS_w, /*20*/ opAND_b_rmw_a16,opAND_w_rmw_a16,opAND_b_rm_a16, opAND_w_rm_a16, opAND_AL_imm, opAND_AX_imm, opES_w_a16, opDAA, opSUB_b_rmw_a16,opSUB_w_rmw_a16,opSUB_b_rm_a16, opSUB_w_rm_a16, opSUB_AL_imm, opSUB_AX_imm, opCS_w_a16, opDAS, /*30*/ opXOR_b_rmw_a16,opXOR_w_rmw_a16,opXOR_b_rm_a16, opXOR_w_rm_a16, opXOR_AL_imm, opXOR_AX_imm, opSS_w_a16, opAAA, opCMP_b_rmw_a16,opCMP_w_rmw_a16,opCMP_b_rm_a16, opCMP_w_rm_a16, opCMP_AL_imm, opCMP_AX_imm, opDS_w_a16, opAAS, -/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, -/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, +/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, +/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, /*60*/ opPUSHA_w, opPOPA_w, opBOUND_w_a16, opARPL_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPUSH_imm_w, opIMUL_w_iw_a16,opPUSH_imm_bw, opIMUL_w_ib_a16,opINSB_a16, opINSW_a16, opOUTSB_a16, opOUTSW_a16, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -1959,14 +1959,14 @@ const OpFn OP_TABLE(286)[1024] = /*f0*/ opLOCK, opLOCK, opREPNE, opREPE, opHLT, opCMC, opF6_a16, opF7_w_a16, opCLC, opSTC, opCLI, opSTI, opCLD, opSTD, opINCDEC_b_a16, opFF_w_a16, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ opADD_b_rmw_a16,opADD_w_rmw_a16,opADD_b_rm_a16, opADD_w_rm_a16, opADD_AL_imm, opADD_AX_imm, opPUSH_ES_w, opPOP_ES_w, opOR_b_rmw_a16, opOR_w_rmw_a16, opOR_b_rm_a16, opOR_w_rm_a16, opOR_AL_imm, opOR_AX_imm, opPUSH_CS_w, op0F_w_a16, /*10*/ opADC_b_rmw_a16,opADC_w_rmw_a16,opADC_b_rm_a16, opADC_w_rm_a16, opADC_AL_imm, opADC_AX_imm, opPUSH_SS_w, opPOP_SS_w, opSBB_b_rmw_a16,opSBB_w_rmw_a16,opSBB_b_rm_a16, opSBB_w_rm_a16, opSBB_AL_imm, opSBB_AX_imm, opPUSH_DS_w, opPOP_DS_w, /*20*/ opAND_b_rmw_a16,opAND_w_rmw_a16,opAND_b_rm_a16, opAND_w_rm_a16, opAND_AL_imm, opAND_AX_imm, opES_w_a16, opDAA, opSUB_b_rmw_a16,opSUB_w_rmw_a16,opSUB_b_rm_a16, opSUB_w_rm_a16, opSUB_AL_imm, opSUB_AX_imm, opCS_w_a16, opDAS, /*30*/ opXOR_b_rmw_a16,opXOR_w_rmw_a16,opXOR_b_rm_a16, opXOR_w_rm_a16, opXOR_AL_imm, opXOR_AX_imm, opSS_w_a16, opAAA, opCMP_b_rmw_a16,opCMP_w_rmw_a16,opCMP_b_rm_a16, opCMP_w_rm_a16, opCMP_AL_imm, opCMP_AX_imm, opDS_w_a16, opAAS, -/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, -/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, +/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, +/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, /*60*/ opPUSHA_w, opPOPA_w, opBOUND_w_a16, opARPL_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPUSH_imm_w, opIMUL_w_iw_a16,opPUSH_imm_bw, opIMUL_w_ib_a16,opINSB_a16, opINSW_a16, opOUTSB_a16, opOUTSW_a16, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -1981,14 +1981,14 @@ const OpFn OP_TABLE(286)[1024] = /*f0*/ opLOCK, opLOCK, opREPNE, opREPE, opHLT, opCMC, opF6_a16, opF7_w_a16, opCLC, opSTC, opCLI, opSTI, opCLD, opSTD, opINCDEC_b_a16, opFF_w_a16, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ opADD_b_rmw_a16,opADD_w_rmw_a16,opADD_b_rm_a16, opADD_w_rm_a16, opADD_AL_imm, opADD_AX_imm, opPUSH_ES_w, opPOP_ES_w, opOR_b_rmw_a16, opOR_w_rmw_a16, opOR_b_rm_a16, opOR_w_rm_a16, opOR_AL_imm, opOR_AX_imm, opPUSH_CS_w, op0F_w_a16, /*10*/ opADC_b_rmw_a16,opADC_w_rmw_a16,opADC_b_rm_a16, opADC_w_rm_a16, opADC_AL_imm, opADC_AX_imm, opPUSH_SS_w, opPOP_SS_w, opSBB_b_rmw_a16,opSBB_w_rmw_a16,opSBB_b_rm_a16, opSBB_w_rm_a16, opSBB_AL_imm, opSBB_AX_imm, opPUSH_DS_w, opPOP_DS_w, /*20*/ opAND_b_rmw_a16,opAND_w_rmw_a16,opAND_b_rm_a16, opAND_w_rm_a16, opAND_AL_imm, opAND_AX_imm, opES_w_a16, opDAA, opSUB_b_rmw_a16,opSUB_w_rmw_a16,opSUB_b_rm_a16, opSUB_w_rm_a16, opSUB_AL_imm, opSUB_AX_imm, opCS_w_a16, opDAS, /*30*/ opXOR_b_rmw_a16,opXOR_w_rmw_a16,opXOR_b_rm_a16, opXOR_w_rm_a16, opXOR_AL_imm, opXOR_AX_imm, opSS_w_a16, opAAA, opCMP_b_rmw_a16,opCMP_w_rmw_a16,opCMP_b_rm_a16, opCMP_w_rm_a16, opCMP_AL_imm, opCMP_AX_imm, opDS_w_a16, opAAS, -/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, -/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, +/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, +/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, /*60*/ opPUSHA_w, opPOPA_w, opBOUND_w_a16, opARPL_a16, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPUSH_imm_w, opIMUL_w_iw_a16,opPUSH_imm_bw, opIMUL_w_ib_a16,opINSB_a16, opINSW_a16, opOUTSB_a16, opOUTSW_a16, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -2003,17 +2003,17 @@ const OpFn OP_TABLE(286)[1024] = /*f0*/ opLOCK, opLOCK, opREPNE, opREPE, opHLT, opCMC, opF6_a16, opF7_w_a16, opCLC, opSTC, opCLI, opSTI, opCLD, opSTD, opINCDEC_b_a16, opFF_w_a16, }; -const OpFn OP_TABLE(386)[1024] = +const OpFn OP_TABLE(386)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ opADD_b_rmw_a16,opADD_w_rmw_a16,opADD_b_rm_a16, opADD_w_rm_a16, opADD_AL_imm, opADD_AX_imm, opPUSH_ES_w, opPOP_ES_w, opOR_b_rmw_a16, opOR_w_rmw_a16, opOR_b_rm_a16, opOR_w_rm_a16, opOR_AL_imm, opOR_AX_imm, opPUSH_CS_w, op0F_w_a16, /*10*/ opADC_b_rmw_a16,opADC_w_rmw_a16,opADC_b_rm_a16, opADC_w_rm_a16, opADC_AL_imm, opADC_AX_imm, opPUSH_SS_w, opPOP_SS_w, opSBB_b_rmw_a16,opSBB_w_rmw_a16,opSBB_b_rm_a16, opSBB_w_rm_a16, opSBB_AL_imm, opSBB_AX_imm, opPUSH_DS_w, opPOP_DS_w, /*20*/ opAND_b_rmw_a16,opAND_w_rmw_a16,opAND_b_rm_a16, opAND_w_rm_a16, opAND_AL_imm, opAND_AX_imm, opES_w_a16, opDAA, opSUB_b_rmw_a16,opSUB_w_rmw_a16,opSUB_b_rm_a16, opSUB_w_rm_a16, opSUB_AL_imm, opSUB_AX_imm, opCS_w_a16, opDAS, /*30*/ opXOR_b_rmw_a16,opXOR_w_rmw_a16,opXOR_b_rm_a16, opXOR_w_rm_a16, opXOR_AL_imm, opXOR_AX_imm, opSS_w_a16, opAAA, opCMP_b_rmw_a16,opCMP_w_rmw_a16,opCMP_b_rm_a16, opCMP_w_rm_a16, opCMP_AL_imm, opCMP_AX_imm, opDS_w_a16, opAAS, -/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, -/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, +/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, +/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, /*60*/ opPUSHA_w, opPOPA_w, opBOUND_w_a16, opARPL_a16, opFS_w_a16, opGS_w_a16, op_66, op_67, opPUSH_imm_w, opIMUL_w_iw_a16,opPUSH_imm_bw, opIMUL_w_ib_a16,opINSB_a16, opINSW_a16, opOUTSB_a16, opOUTSW_a16, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -2035,7 +2035,7 @@ const OpFn OP_TABLE(386)[1024] = /*30*/ opXOR_b_rmw_a16,opXOR_l_rmw_a16,opXOR_b_rm_a16, opXOR_l_rm_a16, opXOR_AL_imm, opXOR_EAX_imm, opSS_l_a16, opAAA, opCMP_b_rmw_a16,opCMP_l_rmw_a16,opCMP_b_rm_a16, opCMP_l_rm_a16, opCMP_AL_imm, opCMP_EAX_imm, opDS_l_a16, opAAS, /*40*/ opINC_EAX, opINC_ECX, opINC_EDX, opINC_EBX, opINC_ESP, opINC_EBP, opINC_ESI, opINC_EDI, opDEC_EAX, opDEC_ECX, opDEC_EDX, opDEC_EBX, opDEC_ESP, opDEC_EBP, opDEC_ESI, opDEC_EDI, -/*50*/ opPUSH_EAX, opPUSH_ECX, opPUSH_EDX, opPUSH_EBX, opPUSH_ESP, opPUSH_EBP, opPUSH_ESI, opPUSH_EDI, opPOP_EAX, opPOP_ECX, opPOP_EDX, opPOP_EBX, opPOP_ESP, opPOP_EBP, opPOP_ESI, opPOP_EDI, +/*50*/ opPUSH_EAX, opPUSH_ECX, opPUSH_EDX, opPUSH_EBX, opPUSH_ESP, opPUSH_EBP, opPUSH_ESI, opPUSH_EDI, opPOP_EAX, opPOP_ECX, opPOP_EDX, opPOP_EBX, opPOP_ESP, opPOP_EBP, opPOP_ESI, opPOP_EDI, /*60*/ opPUSHA_l, opPOPA_l, opBOUND_l_a16, opARPL_a16, opFS_l_a16, opGS_l_a16, op_66, op_67, opPUSH_imm_l, opIMUL_l_il_a16,opPUSH_imm_bl, opIMUL_l_ib_a16,opINSB_a16, opINSL_a16, opOUTSB_a16, opOUTSL_a16, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -2056,8 +2056,8 @@ const OpFn OP_TABLE(386)[1024] = /*20*/ opAND_b_rmw_a32,opAND_w_rmw_a32,opAND_b_rm_a32, opAND_w_rm_a32, opAND_AL_imm, opAND_AX_imm, opES_w_a32, opDAA, opSUB_b_rmw_a32,opSUB_w_rmw_a32,opSUB_b_rm_a32, opSUB_w_rm_a32, opSUB_AL_imm, opSUB_AX_imm, opCS_w_a32, opDAS, /*30*/ opXOR_b_rmw_a32,opXOR_w_rmw_a32,opXOR_b_rm_a32, opXOR_w_rm_a32, opXOR_AL_imm, opXOR_AX_imm, opSS_w_a32, opAAA, opCMP_b_rmw_a32,opCMP_w_rmw_a32,opCMP_b_rm_a32, opCMP_w_rm_a32, opCMP_AL_imm, opCMP_AX_imm, opDS_w_a32, opAAS, -/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, -/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, +/*40*/ opINC_AX, opINC_CX, opINC_DX, opINC_BX, opINC_SP, opINC_BP, opINC_SI, opINC_DI, opDEC_AX, opDEC_CX, opDEC_DX, opDEC_BX, opDEC_SP, opDEC_BP, opDEC_SI, opDEC_DI, +/*50*/ opPUSH_AX, opPUSH_CX, opPUSH_DX, opPUSH_BX, opPUSH_SP, opPUSH_BP, opPUSH_SI, opPUSH_DI, opPOP_AX, opPOP_CX, opPOP_DX, opPOP_BX, opPOP_SP, opPOP_BP, opPOP_SI, opPOP_DI, /*60*/ opPUSHA_w, opPOPA_w, opBOUND_w_a32, opARPL_a32, opFS_w_a32, opGS_w_a32, op_66, op_67, opPUSH_imm_w, opIMUL_w_iw_a32,opPUSH_imm_bw, opIMUL_w_ib_a32,opINSB_a32, opINSW_a32, opOUTSB_a32, opOUTSW_a32, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -2079,7 +2079,7 @@ const OpFn OP_TABLE(386)[1024] = /*30*/ opXOR_b_rmw_a32,opXOR_l_rmw_a32,opXOR_b_rm_a32, opXOR_l_rm_a32, opXOR_AL_imm, opXOR_EAX_imm, opSS_l_a32, opAAA, opCMP_b_rmw_a32,opCMP_l_rmw_a32,opCMP_b_rm_a32, opCMP_l_rm_a32, opCMP_AL_imm, opCMP_EAX_imm, opDS_l_a32, opAAS, /*40*/ opINC_EAX, opINC_ECX, opINC_EDX, opINC_EBX, opINC_ESP, opINC_EBP, opINC_ESI, opINC_EDI, opDEC_EAX, opDEC_ECX, opDEC_EDX, opDEC_EBX, opDEC_ESP, opDEC_EBP, opDEC_ESI, opDEC_EDI, -/*50*/ opPUSH_EAX, opPUSH_ECX, opPUSH_EDX, opPUSH_EBX, opPUSH_ESP, opPUSH_EBP, opPUSH_ESI, opPUSH_EDI, opPOP_EAX, opPOP_ECX, opPOP_EDX, opPOP_EBX, opPOP_ESP, opPOP_EBP, opPOP_ESI, opPOP_EDI, +/*50*/ opPUSH_EAX, opPUSH_ECX, opPUSH_EDX, opPUSH_EBX, opPUSH_ESP, opPUSH_EBP, opPUSH_ESI, opPUSH_EDI, opPOP_EAX, opPOP_ECX, opPOP_EDX, opPOP_EBX, opPOP_ESP, opPOP_EBP, opPOP_ESI, opPOP_EDI, /*60*/ opPUSHA_l, opPOPA_l, opBOUND_l_a32, opARPL_a32, opFS_l_a32, opGS_l_a32, op_66, op_67, opPUSH_imm_l, opIMUL_l_il_a32,opPUSH_imm_bl, opIMUL_l_ib_a32,opINSB_a32, opINSL_a32, opOUTSB_a32, opOUTSL_a32, /*70*/ opJO, opJNO, opJB, opJNB, opJE, opJNE, opJBE, opJNBE, opJS, opJNS, opJP, opJNP, opJL, opJNL, opJLE, opJNLE, @@ -2092,12 +2092,12 @@ const OpFn OP_TABLE(386)[1024] = /*d0*/ opD0_a32, opD1_l_a32, opD2_a32, opD3_l_a32, opAAM, opAAD, opSETALC, opXLAT_a32, opESCAPE_d8_a32,opESCAPE_d9_a32,opESCAPE_da_a32,opESCAPE_db_a32,opESCAPE_dc_a32,opESCAPE_dd_a32,opESCAPE_de_a32,opESCAPE_df_a32, /*e0*/ opLOOPNE_l, opLOOPE_l, opLOOP_l, opJECXZ, opIN_AL_imm, opIN_EAX_imm, opOUT_AL_imm, opOUT_EAX_imm, opCALL_r32, opJMP_r32, opJMP_far_a32, opJMP_r8, opIN_AL_DX, opIN_EAX_DX, opOUT_AL_DX, opOUT_EAX_DX, /*f0*/ opLOCK, opINT1, opREPNE, opREPE, opHLT, opCMC, opF6_a32, opF7_l_a32, opCLC, opSTC, opCLI, opSTI, opCLD, opSTD, opINCDEC_b_a32, opFF_l_a32, -}; +}; -const OpFn OP_TABLE(REPE)[1024] = +const OpFn OP_TABLE(REPE)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPE_w_a16,0, 0, 0, 0, 0, 0, 0, opCS_REPE_w_a16,0, @@ -2119,7 +2119,7 @@ const OpFn OP_TABLE(REPE)[1024] = /*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPE_l_a16,0, 0, 0, 0, 0, 0, 0, opCS_REPE_l_a16,0, @@ -2141,7 +2141,7 @@ const OpFn OP_TABLE(REPE)[1024] = /*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPE_w_a32,0, 0, 0, 0, 0, 0, 0, opCS_REPE_w_a32,0, @@ -2163,7 +2163,7 @@ const OpFn OP_TABLE(REPE)[1024] = /*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPE_l_a32,0, 0, 0, 0, 0, 0, 0, opCS_REPE_l_a32,0, @@ -2185,10 +2185,10 @@ const OpFn OP_TABLE(REPE)[1024] = /*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const OpFn OP_TABLE(REPNE)[1024] = +const OpFn OP_TABLE(REPNE)[1024] = { /*16-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPNE_w_a16,0, 0, 0, 0, 0, 0, 0, opCS_REPNE_w_a16,0, @@ -2210,7 +2210,7 @@ const OpFn OP_TABLE(REPNE)[1024] = /*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*32-bit data, 16-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPNE_l_a16,0, 0, 0, 0, 0, 0, 0, opCS_REPNE_l_a16,0, @@ -2232,7 +2232,7 @@ const OpFn OP_TABLE(REPNE)[1024] = /*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*16-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPNE_w_a32,0, 0, 0, 0, 0, 0, 0, opCS_REPNE_w_a32,0, @@ -2254,7 +2254,7 @@ const OpFn OP_TABLE(REPNE)[1024] = /*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*32-bit data, 32-bit addr*/ -/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ +/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, opES_REPNE_l_a32,0, 0, 0, 0, 0, 0, 0, opCS_REPNE_l_a32,0, diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 7f38ad6d3..239656361 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -1,4 +1,4 @@ -/* +/* * 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 diff --git a/src/cpu/codegen_timing_486.c b/src/cpu/codegen_timing_486.c index a3859ecce..ce451421d 100644 --- a/src/cpu/codegen_timing_486.c +++ b/src/cpu/codegen_timing_486.c @@ -306,14 +306,14 @@ void codegen_timing_486_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin uint64_t *deps; int mod3 = ((fetchdat & 0xc0) == 0xc0); int bit8 = !(opcode & 1); - + switch (last_prefix) { case 0x0f: timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f; deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f; break; - + case 0xd8: timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8; deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8; @@ -368,13 +368,13 @@ void codegen_timing_486_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81; opcode = (fetchdat >> 3) & 7; break; - + case 0xc0: case 0xc1: case 0xd0: case 0xd1: case 0xd2: case 0xd3: timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; opcode = (fetchdat >> 3) & 7; break; - + case 0xf6: timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6; deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6; @@ -397,12 +397,12 @@ void codegen_timing_486_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin break; } } - + timing_count += COUNT(timings[opcode], op_32); if (regmask_modified & get_addr_regmask(deps[opcode], fetchdat, op_32)) timing_count++; /*AGI stall*/ codegen_block_cycles += timing_count; - + regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8); } diff --git a/src/cpu/codegen_timing_686.c b/src/cpu/codegen_timing_686.c index ff7ff54d2..cde59d9cb 100644 --- a/src/cpu/codegen_timing_686.c +++ b/src/cpu/codegen_timing_686.c @@ -77,7 +77,7 @@ static uint32_t opcode_timings[256] = /*10*/ PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RM, PAIR_XY | CYCLES_RM, /* ADC ADC PUSH SS POP SS*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), -/* SBB SBB SBB SBB*/ +/* SBB SBB SBB SBB*/ PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RM, PAIR_XY | CYCLES_RM, /* SBB SBB PUSH DS POP DS*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), @@ -90,7 +90,7 @@ static uint32_t opcode_timings[256] = PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RM, PAIR_XY | CYCLES_RM, /* SUB SUB DAS*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, INVALID, PAIR_NP | CYCLES(7), - + /* XOR XOR XOR XOR*/ /*30*/ PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RM, PAIR_XY | CYCLES_RM, /* XOR XOR AAA*/ @@ -108,7 +108,7 @@ static uint32_t opcode_timings[256] = PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* DEC ESP DEC EBP DEC ESI DEC EDI*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, - + /* PUSH EAX PUSH ECX PUSH EDX PUSH EBX*/ /*50*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* PUSH ESP PUSH EBP PUSH ESI PUSH EDI*/ @@ -125,8 +125,8 @@ static uint32_t opcode_timings[256] = PAIR_XY | CYCLES_REG, PAIR_NP | CYCLES(10), PAIR_XY | CYCLES_REG, PAIR_NP | CYCLES(10), /* INSB INSW OUTSB OUTSW*/ PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(14), - -/* Jxx*/ + +/* Jxx*/ /*70*/ PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, @@ -139,7 +139,7 @@ static uint32_t opcode_timings[256] = PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* MOV from seg LEA MOV to seg POP*/ PAIR_XY | CYCLES(1), PAIR_XY | CYCLES_REG, CYCLES(3), PAIR_XY | CYCLES(1), - + /* NOP XCHG XCHG XCHG*/ /*90*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), /* XCHG XCHG XCHG XCHG*/ @@ -149,7 +149,7 @@ static uint32_t opcode_timings[256] = /* PUSHF POPF SAHF LAHF*/ PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(9), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(2), -/* MOV MOV MOV MOV*/ +/* MOV MOV MOV MOV*/ /*a0*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* MOVSB MOVSW CMPSB CMPSW*/ PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(5), PAIR_NP | CYCLES(5), @@ -177,7 +177,7 @@ static uint32_t opcode_timings[256] = /*d0*/ INVALID, INVALID, INVALID, INVALID, /* AAM AAD SETALC XLAT*/ PAIR_XY | CYCLES(18), PAIR_XY | CYCLES(7), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(4), - INVALID, INVALID, INVALID, INVALID, + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, /* LOOPNE LOOPE LOOP JCXZ*/ /*e0*/ PAIR_X_BRANCH| CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, @@ -213,7 +213,7 @@ static uint32_t opcode_timings_mod3[256] = /*10*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* ADC ADC PUSH SS POP SS*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), -/* SBB SBB SBB SBB*/ +/* SBB SBB SBB SBB*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* SBB SBB PUSH DS POP DS*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), @@ -226,7 +226,7 @@ static uint32_t opcode_timings_mod3[256] = PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* SUB SUB DAS*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, INVALID, PAIR_NP | CYCLES(7), - + /* XOR XOR XOR XOR*/ /*30*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* XOR XOR AAA*/ @@ -244,7 +244,7 @@ static uint32_t opcode_timings_mod3[256] = PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* DEC ESP DEC EBP DEC ESI DEC EDI*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, - + /* PUSH EAX PUSH ECX PUSH EDX PUSH EBX*/ /*50*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* PUSH ESP PUSH EBP PUSH ESI PUSH EDI*/ @@ -261,8 +261,8 @@ static uint32_t opcode_timings_mod3[256] = PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES(10), PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES(10), /* INSB INSW OUTSB OUTSW*/ PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(14), - -/* Jxx*/ + +/* Jxx*/ /*70*/ PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, @@ -275,7 +275,7 @@ static uint32_t opcode_timings_mod3[256] = PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* MOV from seg LEA MOV to seg POP*/ PAIR_XY | CYCLES(1), PAIR_XY | CYCLES_REG, PAIR_NP | CYCLES(3), PAIR_XY | CYCLES(1), - + /* NOP XCHG XCHG XCHG*/ /*90*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), /* XCHG XCHG XCHG XCHG*/ @@ -285,8 +285,8 @@ static uint32_t opcode_timings_mod3[256] = /* PUSHF POPF SAHF LAHF*/ PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(9), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(2), -/* MOV MOV MOV MOV*/ -/*a0*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, +/* MOV MOV MOV MOV*/ +/*a0*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, /* MOVSB MOVSW CMPSB CMPSW*/ PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(5), PAIR_NP | CYCLES(5), /* TEST TEST STOSB STOSW*/ @@ -313,7 +313,7 @@ static uint32_t opcode_timings_mod3[256] = /*d0*/ INVALID, INVALID, INVALID, INVALID, /* AAM AAD SETALC XLAT*/ PAIR_XY | CYCLES(18), PAIR_XY | CYCLES(7), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(4), - INVALID, INVALID, INVALID, INVALID, + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, /* LOOPNE LOOPE LOOP JCXZ*/ @@ -346,12 +346,12 @@ static uint32_t opcode_timings_0f[256] = INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*20*/ PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*30*/ PAIR_NP | CYCLES(9), CYCLES(1), PAIR_NP | CYCLES(9), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, @@ -361,17 +361,17 @@ static uint32_t opcode_timings_0f[256] = PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), - + /*50*/ INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*60*/ PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, - + /*70*/ INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES(1), INVALID, INVALID, INVALID, INVALID, @@ -381,17 +381,17 @@ static uint32_t opcode_timings_0f[256] = PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, - + /*90*/ PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), - + /*a0*/ PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(12), PAIR_XY | CYCLES(5), PAIR_XY | CYCLES(4), PAIR_XY | CYCLES(5), INVALID, INVALID, PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(1), INVALID, PAIR_XY | CYCLES(5), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(5), INVALID, PAIR_NP | CYCLES(10), - + /*b0*/ PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(4), PAIR_XY | CYCLES(5), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), INVALID, INVALID, PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(5), @@ -406,12 +406,12 @@ static uint32_t opcode_timings_0f[256] = INVALID, PAIR_X | CYCLES_RM, INVALID, INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, PAIR_X | CYCLES_RM, - + /*e0*/ INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, INVALID, PAIR_X | CYCLES_RM, INVALID, INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, PAIR_X | CYCLES_RM, - + /*f0*/ INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, PAIR_X | CYCLES_RM, INVALID, INVALID, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID, @@ -428,12 +428,12 @@ static uint32_t opcode_timings_0f_mod3[256] = INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*20*/ PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*30*/ PAIR_NP | CYCLES(9), CYCLES(1), PAIR_NP | CYCLES(9), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, @@ -443,17 +443,17 @@ static uint32_t opcode_timings_0f_mod3[256] = PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), - + /*50*/ INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*60*/ PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, - + /*70*/ INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES(1), INVALID, INVALID, INVALID, INVALID, @@ -463,17 +463,17 @@ static uint32_t opcode_timings_0f_mod3[256] = PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, PAIR_X_BRANCH | CYCLES_BRANCH, - + /*90*/ PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), - + /*a0*/ PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(12), PAIR_XY | CYCLES(5), PAIR_XY | CYCLES(4), PAIR_XY | CYCLES(5), INVALID, INVALID, PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(1), INVALID, PAIR_XY | CYCLES(5), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(5), INVALID, PAIR_NP | CYCLES(10), - + /*b0*/ PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(4), PAIR_XY | CYCLES(5), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), INVALID, INVALID, PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(5), @@ -482,17 +482,17 @@ static uint32_t opcode_timings_0f_mod3[256] = INVALID, INVALID, INVALID, INVALID, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), - + /*d0*/ INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, PAIR_X | CYCLES_REG, INVALID, INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, PAIR_X | CYCLES_REG, - + /*e0*/ INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, INVALID, PAIR_X | CYCLES_REG, INVALID, INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, PAIR_X | CYCLES_REG, - PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, PAIR_X | CYCLES_REG, - + PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, PAIR_X | CYCLES_REG, + /*f0*/ INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, PAIR_X | CYCLES_REG, INVALID, INVALID, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID, @@ -564,7 +564,7 @@ static uint32_t opcode_timings_ff[8] = PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_X_BRANCH | CYCLES(3), PAIR_NP | CYCLES(5), /* JMP JMP far PUSH*/ PAIR_X_BRANCH | CYCLES(3), PAIR_NP | CYCLES(5), PAIR_XY | CYCLES(1), INVALID -}; +}; static uint32_t opcode_timings_ff_mod3[8] = { /* INC DEC CALL CALL far*/ @@ -605,10 +605,10 @@ static uint32_t opcode_timings_d9_mod3[64] = PAIR_X | CYCLES(3), PAIR_X | CYCLES(3), PAIR_X | CYCLES(3), PAIR_X | CYCLES(3), /*FNOP*/ PAIR_X | CYCLES(2), INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, + INVALID, INVALID, INVALID, INVALID, /*FSTP*/ PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), - PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), + PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), /* opFCHS opFABS*/ PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), INVALID, INVALID, /* opFTST opFXAM (oddly low) */ @@ -652,27 +652,27 @@ static uint32_t opcode_timings_db_mod3[64] = { PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), - + PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), - + PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), - + PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), - + /* opFNOP opFCLEX opFINIT*/ INVALID, PAIR_X | CYCLES(2), PAIR_X | CYCLES(5), PAIR_X | CYCLES(8), /* opFNOP opFNOP*/ PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, }; @@ -822,7 +822,7 @@ static int check_agi(uint64_t *deps, uint8_t opcode, uint32_t fetchdat, int op_3 if (last_regmask_modified & addr_regmask) return 1; - + return 0; } @@ -839,7 +839,7 @@ void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f; deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f; break; - + case 0xd8: timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8; deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8; @@ -894,7 +894,7 @@ void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81; opcode = (fetchdat >> 3) & 7; break; - + case 0xc0: case 0xc1: timings = mod3 ? opcode_timings_shift_imm_mod3 : opcode_timings_shift_imm; deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; @@ -906,13 +906,13 @@ void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; opcode = (fetchdat >> 3) & 7; break; - + case 0xd2: case 0xd3: timings = mod3 ? opcode_timings_shift_cl_mod3 : opcode_timings_shift_cl; deps = mod3 ? opcode_deps_shift_cl_mod3 : opcode_deps_shift_cl; opcode = (fetchdat >> 3) & 7; break; - + case 0xf6: timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6; deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6; @@ -935,17 +935,17 @@ void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin break; } } - - /*One prefix per instruction is free*/ + + /*One prefix per instruction is free*/ decode_delay--; if (decode_delay < 0) decode_delay = 0; - + if (prev_full) { uint32_t regmask = get_srcdep_mask(deps[opcode], fetchdat, bit8, op_32); int agi_stall = 0; - + if (regmask & IMPL_ESP) regmask |= SRCDEP_ESP | DSTDEP_ESP; @@ -996,7 +996,7 @@ void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin codegen_block_cycles += t_pair + agi_stall; decode_delay = (-t_pair) + 1 + agi_stall; - + last_regmask_modified = regmask_modified; regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8) | prev_regmask; prev_full = 0; @@ -1013,7 +1013,7 @@ void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uin int agi_stall = 0; agi_stall = check_agi(deps, opcode, fetchdat, op_32); - + codegen_block_cycles += COUNT(timings[opcode], op_32) + decode_delay + agi_stall; decode_delay = (-COUNT(timings[opcode], op_32)) + 1 + agi_stall; last_regmask_modified = regmask_modified; diff --git a/src/cpu/codegen_timing_common.c b/src/cpu/codegen_timing_common.c index b6945cd0c..a1f1b6ce7 100644 --- a/src/cpu/codegen_timing_common.c +++ b/src/cpu/codegen_timing_common.c @@ -36,7 +36,7 @@ uint64_t opcode_deps[256] = SRCDEP_REG | MODRM, SRCDEP_REG | MODRM, SRCDEP_REG | DSTDEP_REG | MODRM, SRCDEP_REG | DSTDEP_REG | MODRM, /* SUB SUB DAS*/ SRCDEP_EAX | DSTDEP_EAX | HAS_IMM8, SRCDEP_EAX | DSTDEP_EAX | HAS_IMM1632, 0, SRCDEP_EAX | DSTDEP_EAX, - + /* XOR XOR XOR XOR*/ /*30*/ SRCDEP_REG | MODRM, SRCDEP_REG | MODRM, SRCDEP_REG | DSTDEP_REG | MODRM, SRCDEP_REG | DSTDEP_REG | MODRM, /* XOR XOR AAA*/ @@ -54,7 +54,7 @@ uint64_t opcode_deps[256] = SRCDEP_EAX | DSTDEP_EAX, SRCDEP_ECX | DSTDEP_ECX, SRCDEP_EDX | DSTDEP_EDX, SRCDEP_EBX | DSTDEP_EBX, /* DEC ESP DEC EBP DEC ESI DEC EDI*/ SRCDEP_ESP | DSTDEP_ESP, SRCDEP_EBP | DSTDEP_EBP, SRCDEP_ESI | DSTDEP_ESI, SRCDEP_EDI | DSTDEP_EDI, - + /* PUSH EAX PUSH ECX PUSH EDX PUSH EBX*/ /*50*/ SRCDEP_EAX | IMPL_ESP, SRCDEP_ECX | IMPL_ESP, SRCDEP_EDX | IMPL_ESP, SRCDEP_EBX | IMPL_ESP, /* PUSH ESP PUSH EBP PUSH ESI PUSH EDI*/ @@ -71,8 +71,8 @@ uint64_t opcode_deps[256] = IMPL_ESP | HAS_IMM1632,DSTDEP_REG | MODRM, IMPL_ESP | HAS_IMM8, DSTDEP_REG | MODRM, /* INSB INSW OUTSB OUTSW*/ 0, 0, 0, 0, - -/* Jxx*/ + +/* Jxx*/ /*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/ 0, 0, 0, 0, @@ -82,7 +82,7 @@ uint64_t opcode_deps[256] = SRCDEP_REG | MODRM, SRCDEP_REG | MODRM, DSTDEP_REG | MODRM, DSTDEP_REG | MODRM, /* MOV from seg LEA MOV to seg POP*/ MODRM, DSTDEP_REG | MODRM, MODRM, IMPL_ESP | MODRM, - + /* NOP XCHG XCHG XCHG*/ /*90*/ 0, SRCDEP_EAX | DSTDEP_EAX | SRCDEP_ECX | DSTDEP_ECX, SRCDEP_EAX | DSTDEP_EAX | SRCDEP_EDX | DSTDEP_EDX, SRCDEP_EAX | DSTDEP_EAX | SRCDEP_EBX | DSTDEP_EBX, /* XCHG XCHG XCHG XCHG*/ @@ -92,7 +92,7 @@ uint64_t opcode_deps[256] = /* PUSHF POPF SAHF LAHF*/ IMPL_ESP, IMPL_ESP, SRCDEP_EAX, DSTDEP_EAX, -/* MOV MOV MOV MOV*/ +/* MOV MOV MOV MOV*/ /*a0*/ DSTDEP_EAX, DSTDEP_EAX, SRCDEP_EAX, SRCDEP_EAX, /* MOVSB MOVSW CMPSB CMPSW*/ 0, 0, 0, 0, @@ -157,7 +157,7 @@ uint64_t opcode_deps_mod3[256] = /*10*/ SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, /* ADC ADC PUSH SS POP SS*/ SRCDEP_EAX | DSTDEP_EAX | HAS_IMM8, SRCDEP_EAX | DSTDEP_EAX | HAS_IMM1632, IMPL_ESP, IMPL_ESP, -/* SBB SBB SBB SBB*/ +/* SBB SBB SBB SBB*/ SRCDEP_REG |SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, /* SBB SBB PUSH DS POP DS*/ SRCDEP_EAX | DSTDEP_EAX | HAS_IMM8, SRCDEP_EAX | DSTDEP_EAX | HAS_IMM1632, IMPL_ESP, IMPL_ESP, @@ -170,7 +170,7 @@ uint64_t opcode_deps_mod3[256] = SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, /* SUB SUB DAS*/ SRCDEP_EAX | DSTDEP_EAX | HAS_IMM8, SRCDEP_EAX | DSTDEP_EAX | HAS_IMM1632, 0, SRCDEP_EAX | DSTDEP_EAX, - + /* XOR XOR XOR XOR*/ /*30*/ SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, /* XOR XOR AAA*/ @@ -188,7 +188,7 @@ uint64_t opcode_deps_mod3[256] = SRCDEP_EAX | DSTDEP_EAX, SRCDEP_ECX | DSTDEP_ECX, SRCDEP_EDX | DSTDEP_EDX, SRCDEP_EBX | DSTDEP_EBX, /* DEC ESP DEC EBP DEC ESI DEC EDI*/ SRCDEP_ESP | DSTDEP_ESP, SRCDEP_EBP | DSTDEP_EBP, SRCDEP_ESI | DSTDEP_ESI, SRCDEP_EDI | DSTDEP_EDI, - + /* PUSH EAX PUSH ECX PUSH EDX PUSH EBX*/ /*50*/ SRCDEP_EAX | IMPL_ESP, SRCDEP_ECX | IMPL_ESP, SRCDEP_EDX | IMPL_ESP, SRCDEP_EBX | IMPL_ESP, /* PUSH ESP PUSH EBP PUSH ESI PUSH EDI*/ @@ -205,8 +205,8 @@ uint64_t opcode_deps_mod3[256] = IMPL_ESP | HAS_IMM1632,DSTDEP_REG | SRCDEP_RM | MODRM, IMPL_ESP | HAS_IMM8, DSTDEP_REG | SRCDEP_RM | MODRM, /* INSB INSW OUTSB OUTSW*/ 0, 0, 0, 0, - -/* Jxx*/ + +/* Jxx*/ /*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/ 0, 0, 0, 0, @@ -216,7 +216,7 @@ uint64_t opcode_deps_mod3[256] = SRCDEP_REG | DSTDEP_RM | MODRM, SRCDEP_REG | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_REG | MODRM, SRCDEP_RM | DSTDEP_REG | MODRM, /* MOV from seg LEA MOV to seg POP*/ DSTDEP_RM | MODRM, DSTDEP_REG | MODRM, SRCDEP_RM | MODRM, IMPL_ESP | DSTDEP_RM | MODRM, - + /* NOP XCHG XCHG XCHG*/ /*90*/ 0, SRCDEP_EAX | DSTDEP_EAX | SRCDEP_ECX | DSTDEP_ECX, SRCDEP_EAX | DSTDEP_EAX | SRCDEP_EDX | DSTDEP_EDX, SRCDEP_EAX | DSTDEP_EAX | SRCDEP_EBX | DSTDEP_EBX, /* XCHG XCHG XCHG XCHG*/ @@ -226,7 +226,7 @@ uint64_t opcode_deps_mod3[256] = /* PUSHF POPF SAHF LAHF*/ IMPL_ESP, IMPL_ESP, SRCDEP_EAX, DSTDEP_EAX, -/* MOV MOV MOV MOV*/ +/* MOV MOV MOV MOV*/ /*a0*/ DSTDEP_EAX, DSTDEP_EAX, SRCDEP_EAX, SRCDEP_EAX, /* MOVSB MOVSW CMPSB CMPSW*/ 0, 0, 0, 0, @@ -287,12 +287,12 @@ uint64_t opcode_deps_0f[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*20*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*30*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -302,17 +302,17 @@ uint64_t opcode_deps_0f[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*50*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*60*/ MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM, MODRM, MODRM, MODRM, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, 0, 0, MODRM, MODRM, - + /*70*/ 0, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM, MODRM, MODRM, 0, 0, 0, 0, 0, @@ -322,17 +322,17 @@ uint64_t opcode_deps_0f[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*90*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, - + /*a0*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, 0, 0, MODRM, MODRM, 0, MODRM, MODRM, MODRM, MODRM, MODRM, - + /*b0*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, 0, 0, MODRM, MODRM, @@ -347,12 +347,12 @@ uint64_t opcode_deps_0f[256] = 0, MODRM | MMX_MULTIPLY, 0, 0, MODRM, MODRM, 0, MODRM, MODRM, MODRM, 0, MODRM, - + /*e0*/ 0, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, 0, 0, MODRM | MMX_MULTIPLY, 0, 0, MODRM, MODRM, 0, MODRM, MODRM, MODRM, 0, MODRM, - + /*f0*/ 0, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, 0, MODRM | MMX_MULTIPLY, 0, 0, MODRM, MODRM, MODRM, 0, @@ -369,12 +369,12 @@ uint64_t opcode_deps_0f_mod3[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*20*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*30*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -384,17 +384,17 @@ uint64_t opcode_deps_0f_mod3[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*50*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*60*/ MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM, MODRM, MODRM, MODRM, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, 0, 0, MODRM, MODRM, - + /*70*/ 0, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM, MODRM, MODRM, 0, 0, 0, 0, 0, @@ -404,17 +404,17 @@ uint64_t opcode_deps_0f_mod3[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - + /*90*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, - + /*a0*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, 0, 0, MODRM, MODRM, 0, MODRM, MODRM, MODRM, MODRM, MODRM, - + /*b0*/ MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, MODRM, 0, 0, MODRM, MODRM, @@ -429,12 +429,12 @@ uint64_t opcode_deps_0f_mod3[256] = 0, MODRM | MMX_MULTIPLY, 0, 0, MODRM, MODRM, 0, MODRM, MODRM, MODRM, 0, MODRM, - + /*e0*/ 0, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, 0, 0, MODRM | MMX_MULTIPLY, 0, 0, MODRM, MODRM, 0, MODRM, MODRM, MODRM, 0, MODRM, - + /*f0*/ 0, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, MODRM | MMX_SHIFTPACK, 0, MODRM | MMX_MULTIPLY, 0, 0, MODRM, MODRM, MODRM, 0, @@ -749,24 +749,24 @@ uint64_t opcode_deps_db[8] = uint64_t opcode_deps_db_mod3[64] = { 0, 0, 0, 0, 0, 0, 0, 0, - + 0, 0, 0, 0, 0, 0, 0, 0, - + 0, 0, 0, 0, 0, 0, 0, 0, - - + + 0, 0, 0, 0, 0, 0, 0, 0, - + /* opFNOP opFCLEX opFINIT*/ 0, 0, 0, 0, /* opFNOP opFNOP*/ 0, 0, 0, 0, - + 0, 0, 0, 0, 0, 0, 0, 0, - + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, }; uint64_t opcode_deps_dc[8] = diff --git a/src/cpu/codegen_timing_common.h b/src/cpu/codegen_timing_common.h index 71daf80ef..a3faca27d 100644 --- a/src/cpu/codegen_timing_common.h +++ b/src/cpu/codegen_timing_common.h @@ -171,7 +171,7 @@ static inline uint32_t get_addr_regmask(uint64_t data, uint32_t fetchdat, int op if (data & IMPL_ESP) addr_regmask |= REGMASK_IMPL_ESP; - + return addr_regmask; } diff --git a/src/cpu/codegen_timing_k6.c b/src/cpu/codegen_timing_k6.c index 69c960b6e..66ec33052 100644 --- a/src/cpu/codegen_timing_k6.c +++ b/src/cpu/codegen_timing_k6.c @@ -1780,7 +1780,7 @@ static int uop_run(const risc86_uop_t *uop, int decode_time) int c; k6_unit_t *best_unit = NULL; int best_start_cycle = 99999; - + /*UOP_LIMM does not require execution*/ if (uop->type == UOP_LIMM) return decode_time; @@ -1876,12 +1876,12 @@ void decode_flush() for (c = 0; c < decode_buffer.nr_uops; c++) { int start_timestamp; - + if (decode_buffer.earliest_start[c] == -1) start_timestamp = last_uop_timestamp; else start_timestamp = decode_buffer.earliest_start[c]; - + last_uop_timestamp = uop_run(decode_buffer.uops[c], start_timestamp); if (last_uop_timestamp > uop_timestamp) uop_timestamp = last_uop_timestamp; @@ -2023,11 +2023,11 @@ static void decode_instruction(const risc86_instruction_t *ins, uint64_t deps, u } } break; - + case DECODE_LONG: if (decode_buffer.nr_uops) decode_flush(); - + decode_buffer.nr_uops = ins->nr_uops; for (c = 0; c < ins->nr_uops; c++) { @@ -2039,11 +2039,11 @@ static void decode_instruction(const risc86_instruction_t *ins, uint64_t deps, u } decode_flush(); break; - + case DECODE_VECTOR: if (decode_buffer.nr_uops) decode_flush(); - + decode_timestamp++; d = 0; @@ -2055,7 +2055,7 @@ static void decode_instruction(const risc86_instruction_t *ins, uint64_t deps, u else decode_buffer.earliest_start[d] = -1; d++; - + if (d == 4) { d = 0; @@ -2125,11 +2125,11 @@ void codegen_timing_k6_block_start() decode_timestamp = 0; last_complete_timestamp = 0; - + for (c = 0; c < NR_OPQUADS; c++) opquad_completion_timestamp[c] = 0; next_opquad = 0; - + for (c = 0; c < NR_REGS; c++) reg_available_timestamp[c] = 0; for (c = 0; c < 8; c++) @@ -2214,7 +2214,7 @@ void codegen_timing_k6_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uint opcode_pc += 2; } } - + opcode = fastreadb(cs + opcode_pc); ins_table = mod3 ? opcode_timings_0f0f_mod3 : opcode_timings_0f0f; @@ -2287,7 +2287,7 @@ void codegen_timing_k6_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uint deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; opcode = (fetchdat >> 3) & 7; break; - + case 0xc1: case 0xd1: case 0xd3: ins_table = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; diff --git a/src/cpu/codegen_timing_p6.c b/src/cpu/codegen_timing_p6.c index 47b502ba0..0fb5359fe 100644 --- a/src/cpu/codegen_timing_p6.c +++ b/src/cpu/codegen_timing_p6.c @@ -92,7 +92,7 @@ static const macro_op_t alu_store_op = .uop[0] = {.type = UOP_LOAD, .latency = 1}, .uop[1] = {.type = UOP_ALU, .latency = 1}, .uop[2] = {.type = UOP_STORED, .latency = 1}, - .uop[3] = {.type = UOP_STOREA, .latency = 1} + .uop[3] = {.type = UOP_STOREA, .latency = 1} }; static const macro_op_t alup0_store_op = { @@ -101,7 +101,7 @@ static const macro_op_t alup0_store_op = .uop[0] = {.type = UOP_LOAD, .latency = 1}, .uop[1] = {.type = UOP_ALUP0, .latency = 1}, .uop[2] = {.type = UOP_STORED, .latency = 1}, - .uop[3] = {.type = UOP_STOREA, .latency = 1} + .uop[3] = {.type = UOP_STOREA, .latency = 1} }; static const macro_op_t branch_op = @@ -130,7 +130,7 @@ static const macro_op_t store_op = .nr_uops = 2, .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_STORED, .latency = 1}, - .uop[1] = {.type = UOP_STOREA, .latency = 1} + .uop[1] = {.type = UOP_STOREA, .latency = 1} }; @@ -139,7 +139,7 @@ static const macro_op_t bswap_op = .nr_uops = 2, .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_ALU, .latency = 1}, - .uop[1] = {.type = UOP_ALU, .latency = 1}, + .uop[1] = {.type = UOP_ALU, .latency = 1}, }; static const macro_op_t leave_op = { @@ -175,7 +175,7 @@ static const macro_op_t movs_op = .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_LOAD, .latency = 1}, .uop[1] = {.type = UOP_STORED, .latency = 1}, - .uop[2] = {.type = UOP_STOREA, .latency = 1}, + .uop[2] = {.type = UOP_STOREA, .latency = 1}, .uop[3] = {.type = UOP_ALU, .latency = 1} }; static const macro_op_t pop_reg_op = @@ -191,7 +191,7 @@ static const macro_op_t pop_mem_op = .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_LOAD, .latency = 1}, .uop[1] = {.type = UOP_STORED, .latency = 1}, - .uop[2] = {.type = UOP_STOREA, .latency = 1}, + .uop[2] = {.type = UOP_STOREA, .latency = 1}, .uop[3] = {.type = UOP_ALU, .latency = 1} }; static const macro_op_t push_imm_op = @@ -199,7 +199,7 @@ static const macro_op_t push_imm_op = .nr_uops = 2, .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_STORED, .latency = 1}, - .uop[1] = {.type = UOP_STOREA, .latency = 1}, + .uop[1] = {.type = UOP_STOREA, .latency = 1}, }; static const macro_op_t push_mem_op = { @@ -223,7 +223,7 @@ static const macro_op_t stos_op = .nr_uops = 3, .decode_type = DECODE_COMPLEX, .uop[1] = {.type = UOP_STORED, .latency = 1}, - .uop[2] = {.type = UOP_STOREA, .latency = 1}, + .uop[2] = {.type = UOP_STOREA, .latency = 1}, .uop[3] = {.type = UOP_ALU, .latency = 1} }; static const macro_op_t test_reg_op = @@ -359,7 +359,7 @@ static const macro_op_t fchs_op = .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_FLOAT, .latency = 2}, .uop[1] = {.type = UOP_FLOAT, .latency = 2}, - .uop[2] = {.type = UOP_FLOAT, .latency = 2} + .uop[2] = {.type = UOP_FLOAT, .latency = 2} }; static const macro_op_t load_float_op = { @@ -399,7 +399,7 @@ static const macro_op_t load_fiadd_op = .uop[3] = {.type = UOP_FLOAT, .latency = 1}, .uop[4] = {.type = UOP_FLOAT, .latency = 1}, .uop[5] = {.type = UOP_FLOAT, .latency = 1}, - .uop[6] = {.type = UOP_FLOAT, .latency = 1} + .uop[6] = {.type = UOP_FLOAT, .latency = 1} }; static const macro_op_t fdiv_op = { @@ -547,7 +547,7 @@ static const macro_op_t call_far_op = .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_ALU, .latency = 3}, .uop[1] = {.type = UOP_STORED, .latency = 1}, - .uop[2] = {.type = UOP_STOREA, .latency = 1}, + .uop[2] = {.type = UOP_STOREA, .latency = 1}, .uop[3] = {.type = UOP_BRANCH, .latency = 1} }; static const macro_op_t cli_sti_op = @@ -675,7 +675,7 @@ static const macro_op_t int_op = .uop[3] = {.type = UOP_STORED, .latency = 1}, .uop[4] = {.type = UOP_STOREA, .latency = 1}, .uop[5] = {.type = UOP_STORED, .latency = 1}, - .uop[6] = {.type = UOP_STOREA, .latency = 1}, + .uop[6] = {.type = UOP_STOREA, .latency = 1}, .uop[7] = {.type = UOP_BRANCH, .latency = 1} }; static const macro_op_t iret_op = @@ -771,7 +771,7 @@ static const macro_op_t outs_op = .nr_uops = 3, .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_LOAD, .latency = 1}, - .uop[1] = {.type = UOP_ALU, .latency = 18} + .uop[1] = {.type = UOP_ALU, .latency = 18} }; static const macro_op_t pusha_op = { @@ -804,7 +804,7 @@ static const macro_op_t popf_op = .nr_uops = 3, .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_LOAD, .latency = 1}, - .uop[1] = {.type = UOP_ALU, .latency = 6}, + .uop[1] = {.type = UOP_ALU, .latency = 6}, .uop[2] = {.type = UOP_ALUP0, .latency = 10} }; static const macro_op_t pushf_op = @@ -881,7 +881,7 @@ static const macro_op_t xchg_mem_op = .decode_type = DECODE_COMPLEX, .uop[0] = {.type = UOP_LOAD, .latency = 1}, .uop[1] = {.type = UOP_STORED, .latency = 1}, - .uop[2] = {.type = UOP_STOREA, .latency = 1}, + .uop[2] = {.type = UOP_STOREA, .latency = 1}, .uop[3] = {.type = UOP_ALU, .latency = 1} }; static const macro_op_t xlat_op = @@ -1152,7 +1152,7 @@ static const macro_op_t *opcode_timings_mod3[256] = &alup0_6_op, &alup0_3_op, &complex_alup0_1_op, &xlat_op, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /* LOOPNE LOOPE LOOP JCXZ*/ /*e0*/ &loop_op, &loop_op, &loop_op, &loop_op, /* IN AL IN AX OUT_AL OUT_AX*/ @@ -1372,7 +1372,7 @@ static const macro_op_t *opcode_timings_8x[8] = { &alu_store_op, &alu_store_op, &alu_store_op, &alu_store_op, &alu_store_op, &alu_store_op, &alu_store_op, &alu_store_op, -}; +}; static const macro_op_t *opcode_timings_8x_mod3[8] = { &alu_op, &alu_op, &alu_store_op, &alu_store_op, @@ -1618,7 +1618,7 @@ static p6_unit_t p2_units[] = {.uop_mask = (1 << UOP_ALU) | (1 << UOP_ALUP0) | (1 << UOP_FLOAT) | /*Port 0*/ (1 << UOP_MMX) | (1 << UOP_MMX_MUL)}, {.uop_mask = (1 << UOP_ALU) | (1 << UOP_BRANCH) | /*Port 1*/ - (1 << UOP_MMX) | (1 << UOP_MMX_SHIFT)}, + (1 << UOP_MMX) | (1 << UOP_MMX_SHIFT)}, {.uop_mask = (1 << UOP_LOAD) | (1 << UOP_FLOAD) | (1 << UOP_MLOAD)}, /*Port 2*/ {.uop_mask = (1 << UOP_STORED) | (1 << UOP_FSTORED) | (1 << UOP_MSTORED)}, /*Port 3*/ {.uop_mask = (1 << UOP_STOREA) | (1 << UOP_FSTOREA) | (1 << UOP_MSTOREA)}, /*Port 4*/ @@ -1630,11 +1630,11 @@ static int uop_run(const p6_uop_t *uop, int decode_time) int c; p6_unit_t *best_unit = NULL; int best_start_cycle = 99999; - + /*UOP_FXCH does not require execution*/ if (uop->type == UOP_FXCH) return decode_time; - + /*Find execution unit for this uOP*/ for (c = 0; c < nr_units; c++) { @@ -1653,7 +1653,7 @@ static int uop_run(const p6_uop_t *uop, int decode_time) if (best_start_cycle < decode_time) best_start_cycle = decode_time; best_unit->first_available_cycle = best_start_cycle + uop->latency; - + return best_start_cycle + uop->latency; @@ -1692,7 +1692,7 @@ void decode_flush_p6() { int c; int start_timestamp, uop_timestamp = 0; - + /*Decoded opseq can not be submitted if there are no free spaces in the opseq buffer*/ if (decode_timestamp < opseq_completion_timestamp[next_opseq]) @@ -1709,7 +1709,7 @@ void decode_flush_p6() start_timestamp = last_uop_timestamp; else start_timestamp = decode_buffer.earliest_start[c]; - + last_uop_timestamp = uop_run(decode_buffer.uops[c], start_timestamp); if (last_uop_timestamp > uop_timestamp) uop_timestamp = last_uop_timestamp; @@ -1785,7 +1785,7 @@ static int codegen_timing_instr_length(uint64_t deps, uint32_t fetchdat, int op_ static void decode_instruction(const macro_op_t *ins, uint64_t deps, uint32_t fetchdat, int op_32, int bit8) { uint32_t regmask_required; - uint32_t regmask_modified; + uint32_t regmask_modified; int c; int d = 0; /*Complex decoder uOPs*/ int earliest_start = 0; @@ -1822,43 +1822,43 @@ static void decode_instruction(const macro_op_t *ins, uint64_t deps, uint32_t fe decode_type = DECODE_COMPLEX; switch (decode_type) - { - case DECODE_SIMPLE: + { + case DECODE_SIMPLE: if (decode_buffer.nr_uops - d == 2) { decode_buffer.uops[decode_buffer.nr_uops] = &ins->uop[0]; decode_buffer.earliest_start[decode_buffer.nr_uops] = earliest_start; decode_buffer.nr_uops = 3; decode_flush_p6(); - } + } else if (decode_buffer.nr_uops - d == 1) - { + { decode_buffer.uops[decode_buffer.nr_uops] = &ins->uop[0]; decode_buffer.earliest_start[decode_buffer.nr_uops] = earliest_start; decode_buffer.nr_uops = 2+d; if (d) decode_flush_p6(); - } + } else if (decode_buffer.nr_uops) { decode_buffer.uops[decode_buffer.nr_uops] = &ins->uop[0]; decode_buffer.earliest_start[decode_buffer.nr_uops] = earliest_start; - decode_buffer.nr_uops = 1+d; + decode_buffer.nr_uops = 1+d; } else { decode_buffer.nr_uops = 1; decode_buffer.uops[0] = &ins->uop[0]; decode_buffer.earliest_start[0] = earliest_start; - } + } break; - + case DECODE_COMPLEX: if (decode_buffer.nr_uops) decode_flush_p6(); /*The 4-1-1 arrangement implies that a complex ins. can't be decoded after a simple one*/ - + d = 0; - + for (c = 0; c < ins->nr_uops; c++) { decode_buffer.uops[d] = &ins->uop[c]; @@ -1867,7 +1867,7 @@ static void decode_instruction(const macro_op_t *ins, uint64_t deps, uint32_t fe else decode_buffer.earliest_start[d] = -1; d++; - + if ((d == 3) && (ins->nr_uops > 4)) /*Ins. with >4 uOPs require the use of special units only present on 3 translate PLAs*/ { d = 0; @@ -1877,9 +1877,9 @@ static void decode_instruction(const macro_op_t *ins, uint64_t deps, uint32_t fe } if (d) { - decode_buffer.nr_uops = d; - } - break; + decode_buffer.nr_uops = d; + } + break; } /*Update write timestamps for any output registers*/ @@ -1932,11 +1932,11 @@ void codegen_timing_p6_block_start() decode_timestamp = 0; last_complete_timestamp = 0; - + for (c = 0; c < NR_OPSEQS; c++) opseq_completion_timestamp[c] = 0; next_opseq = 0; - + for (c = 0; c < NR_REGS; c++) reg_available_timestamp[c] = 0; for (c = 0; c < 8; c++) @@ -2043,7 +2043,7 @@ void codegen_timing_p6_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uint deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; opcode = (fetchdat >> 3) & 7; break; - + case 0xc1: case 0xd1: case 0xd3: ins_table = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; diff --git a/src/cpu/codegen_timing_pentium.c b/src/cpu/codegen_timing_pentium.c index ec6b8f2a7..263608682 100644 --- a/src/cpu/codegen_timing_pentium.c +++ b/src/cpu/codegen_timing_pentium.c @@ -124,7 +124,7 @@ static uint64_t opcode_timings[256] = /*10*/ PAIR_U | CYCLES_RMW, PAIR_U | CYCLES_RMW, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, /* ADC ADC PUSH SS POP SS*/ PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), -/* SBB SBB SBB SBB*/ +/* SBB SBB SBB SBB*/ PAIR_U | CYCLES_RMW, PAIR_U | CYCLES_RMW, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, /* SBB SBB PUSH DS POP DS*/ PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), @@ -137,7 +137,7 @@ static uint64_t opcode_timings[256] = PAIR_UV | CYCLES_RMW, PAIR_UV | CYCLES_RMW, PAIR_UV | CYCLES_RM, PAIR_UV | CYCLES_RM, /* SUB SUB DAS*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_NP | CYCLES(3), - + /* XOR XOR XOR XOR*/ /*30*/ PAIR_UV | CYCLES_RMW, PAIR_UV | CYCLES_RMW, PAIR_UV | CYCLES_RM, PAIR_UV | CYCLES_RM, /* XOR XOR AAA*/ @@ -155,7 +155,7 @@ static uint64_t opcode_timings[256] = PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* DEC ESP DEC EBP DEC ESI DEC EDI*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, - + /* PUSH EAX PUSH ECX PUSH EDX PUSH EBX*/ /*50*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* PUSH ESP PUSH EBP PUSH ESI PUSH EDI*/ @@ -172,8 +172,8 @@ static uint64_t opcode_timings[256] = PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(10), PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(10), /* INSB INSW OUTSB OUTSW*/ PAIR_NP | CYCLES(9), PAIR_NP | CYCLES(9), PAIR_NP | CYCLES(13), PAIR_NP | CYCLES(13), - -/* Jxx*/ + +/* Jxx*/ /*70*/ PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, @@ -186,7 +186,7 @@ static uint64_t opcode_timings[256] = PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV, /* MOV from seg LEA MOV to seg POP*/ PAIR_NP | CYCLES(1), PAIR_UV | CYCLES_REG, CYCLES(3), PAIR_NP | CYCLES(3), - + /* NOP XCHG XCHG XCHG*/ /*90*/ PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), /* XCHG XCHG XCHG XCHG*/ @@ -196,7 +196,7 @@ static uint64_t opcode_timings[256] = /* PUSHF POPF SAHF LAHF*/ PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), -/* MOV MOV MOV MOV*/ +/* MOV MOV MOV MOV*/ /*a0*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* MOVSB MOVSW CMPSB CMPSW*/ PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(5), PAIR_NP | CYCLES(5), @@ -224,7 +224,7 @@ static uint64_t opcode_timings[256] = /*d0*/ INVALID, INVALID, INVALID, INVALID, /* AAM AAD SETALC XLAT*/ PAIR_NP | CYCLES(18), PAIR_NP | CYCLES(10), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(4), - INVALID, INVALID, INVALID, INVALID, + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, /* LOOPNE LOOPE LOOP JCXZ*/ /*e0*/ PAIR_NP | CYCLES(7), PAIR_NP | CYCLES(7), PAIR_NP | CYCLES(5), PAIR_NP | CYCLES(5), @@ -260,7 +260,7 @@ static uint64_t opcode_timings_mod3[256] = /*10*/ PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, /* ADC ADC PUSH SS POP SS*/ PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), -/* SBB SBB SBB SBB*/ +/* SBB SBB SBB SBB*/ PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, /* SBB SBB PUSH DS POP DS*/ PAIR_U | CYCLES_REG, PAIR_U | CYCLES_REG, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), @@ -273,7 +273,7 @@ static uint64_t opcode_timings_mod3[256] = PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* SUB SUB DAS*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_NP | CYCLES(3), - + /* XOR XOR XOR XOR*/ /*30*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* XOR XOR AAA*/ @@ -291,7 +291,7 @@ static uint64_t opcode_timings_mod3[256] = PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* DEC ESP DEC EBP DEC ESI DEC EDI*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, - + /* PUSH EAX PUSH ECX PUSH EDX PUSH EBX*/ /*50*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* PUSH ESP PUSH EBP PUSH ESI PUSH EDI*/ @@ -308,8 +308,8 @@ static uint64_t opcode_timings_mod3[256] = PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(10), PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(10), /* INSB INSW OUTSB OUTSW*/ PAIR_NP | CYCLES(9), PAIR_NP | CYCLES(9), PAIR_NP | CYCLES(13), PAIR_NP | CYCLES(13), - -/* Jxx*/ + +/* Jxx*/ /*70*/ PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, PAIR_V | CYCLES_BRANCH, @@ -322,7 +322,7 @@ static uint64_t opcode_timings_mod3[256] = PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* MOV from seg LEA MOV to seg POP*/ PAIR_NP | CYCLES(1), PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), - + /* NOP XCHG XCHG XCHG*/ /*90*/ PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), /* XCHG XCHG XCHG XCHG*/ @@ -332,7 +332,7 @@ static uint64_t opcode_timings_mod3[256] = /* PUSHF POPF SAHF LAHF*/ PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), -/* MOV MOV MOV MOV*/ +/* MOV MOV MOV MOV*/ /*a0*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, /* MOVSB MOVSW CMPSB CMPSW*/ PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(5), PAIR_NP | CYCLES(5), @@ -360,7 +360,7 @@ static uint64_t opcode_timings_mod3[256] = /*d0*/ INVALID, INVALID, INVALID, INVALID, /* AAM AAD SETALC XLAT*/ PAIR_NP | CYCLES(18), PAIR_NP | CYCLES(10), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(4), - INVALID, INVALID, INVALID, INVALID, + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, /* LOOPNE LOOPE LOOP JCXZ*/ @@ -393,32 +393,32 @@ static uint64_t opcode_timings_0f[256] = INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*20*/ PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*30*/ PAIR_NP | CYCLES(9), CYCLES(1), PAIR_NP | CYCLES(9), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, -/*40*/ INVALID, INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, +/*40*/ INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, + /*50*/ INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*60*/ PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, - + /*70*/ INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_NP | CYCLES(100), INVALID, INVALID, INVALID, INVALID, @@ -428,17 +428,17 @@ static uint64_t opcode_timings_0f[256] = PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), PAIR_NP | CYCLES(2), - + /*90*/ PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), - + /*a0*/ PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(8), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(4), INVALID, INVALID, PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), INVALID, PAIR_NP | CYCLES(13), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), INVALID, PAIR_NP | CYCLES(10), - + /*b0*/ PAIR_NP | CYCLES(10), PAIR_NP | CYCLES(10), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(13), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), INVALID, INVALID, PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(13), @@ -453,12 +453,12 @@ static uint64_t opcode_timings_0f[256] = INVALID, PAIR_U | CYCLES_RM, INVALID, INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, PAIR_U | CYCLES_RM, - + /*e0*/ INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, INVALID, PAIR_U | CYCLES_RM, INVALID, INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, PAIR_U | CYCLES_RM, - + /*f0*/ INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, PAIR_U | CYCLES_RM, INVALID, INVALID, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, PAIR_U | CYCLES_RM, INVALID, @@ -470,7 +470,7 @@ static uint64_t opcode_timings_0f_mod3[256] = INVALID, PAIR_NP | CYCLES(195), PAIR_NP | CYCLES(7), INVALID, PAIR_NP | CYCLES(1000), PAIR_NP | CYCLES(10000), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*10*/ INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, @@ -480,7 +480,7 @@ static uint64_t opcode_timings_0f_mod3[256] = PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*30*/ PAIR_NP | CYCLES(9), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(9), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, @@ -490,17 +490,17 @@ static uint64_t opcode_timings_0f_mod3[256] = INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*50*/ INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /*60*/ PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, - + /*70*/ INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_NP | CYCLES(100), INVALID, INVALID, INVALID, INVALID, @@ -515,12 +515,12 @@ static uint64_t opcode_timings_0f_mod3[256] = PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), - + /*a0*/ PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(14), PAIR_NP | CYCLES(8), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(4), INVALID, INVALID, PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), INVALID, PAIR_NP | CYCLES(13), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), INVALID, PAIR_NP | CYCLES(10), - + /*b0*/ PAIR_NP | CYCLES(10), PAIR_NP | CYCLES(10), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(13), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(3), PAIR_NP | CYCLES(3), INVALID, INVALID, PAIR_NP | CYCLES(6), PAIR_NP | CYCLES(13), @@ -530,17 +530,17 @@ static uint64_t opcode_timings_0f_mod3[256] = INVALID, INVALID, INVALID, INVALID, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(1), - + /*d0*/ INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_UV | CYCLES_REG, INVALID, INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_UV | CYCLES_REG, - + /*e0*/ INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, INVALID, PAIR_UV | CYCLES_REG, INVALID, INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_UV | CYCLES_REG, - PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_UV | CYCLES_REG, - + PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_UV | CYCLES_REG, + /*f0*/ INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, PAIR_UV | CYCLES_REG, INVALID, INVALID, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, PAIR_UV | CYCLES_REG, INVALID, @@ -633,7 +633,7 @@ static uint64_t opcode_timings_d9_mod3[64] = PAIR_FXCH | CYCLES(0), PAIR_FXCH | CYCLES(0), PAIR_FXCH | CYCLES(0), PAIR_FXCH | CYCLES(0), /*FNOP*/ PAIR_NP | FPU_CYCLES(3,0,0), INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, + INVALID, INVALID, INVALID, INVALID, /*FSTP*/ PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), @@ -681,27 +681,27 @@ static uint64_t opcode_timings_db_mod3[64] = { INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + /* opFNOP opFCLEX opFINIT*/ INVALID, PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(7,0,0), PAIR_NP | FPU_CYCLES(17,0,0), /* opFNOP opFNOP*/ PAIR_NP | FPU_CYCLES(1,0,0), PAIR_NP | FPU_CYCLES(1,0,0), INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, }; @@ -803,9 +803,9 @@ static inline int COUNT(uint64_t timings, uint64_t deps, int op_32) if (!(timings & PAIR_MASK)) return timings & 0xffff; if ((timings & PAIR_MASK) == PAIR_FX) - return timings & 0xffff; + return timings & 0xffff; if ((timings & PAIR_MASK) == PAIR_FXCH) - return timings & 0xffff; + return timings & 0xffff; if ((timings & PAIR_UV) && !(timings & PAIR_FPU)) timings &= 3; switch (timings & CYCLES_MASK) @@ -819,23 +819,23 @@ static inline int COUNT(uint64_t timings, uint64_t deps, int op_32) case CYCLES_BRANCH: return cpu_has_feature(CPU_FEATURE_MMX) ? 1 : 2; } - + fatal("Illegal COUNT %016llx\n", timings); - + return timings; } static int codegen_fpu_latencies(uint64_t deps, int reg) { int latency = fpu_latency; - + if ((deps & FPU_RW_ST0) && fpu_st_latency[0] && fpu_st_latency[0] > latency) latency = fpu_st_latency[0]; if ((deps & FPU_RW_ST1) && fpu_st_latency[1] && fpu_st_latency[1] > latency) latency = fpu_st_latency[1]; if ((deps & FPU_RW_STREG) && fpu_st_latency[reg] && fpu_st_latency[reg] > latency) latency = fpu_st_latency[reg]; - + return latency; } @@ -843,7 +843,7 @@ static int codegen_fpu_latencies(uint64_t deps, int reg) latency -= count; \ if (latency < 0) \ latency = 0 - + static void codegen_fpu_latency_clock(int count) { SUB_AND_CLAMP(fpu_latency, count); @@ -879,7 +879,7 @@ static inline int codegen_timing_has_displacement(uint32_t fetchdat, int op_32) return 1; } return 0; -} +} /*The instruction is only of interest here if it's longer than 7 bytes, as that's the limit on Pentium MMX parallel decoding*/ @@ -927,7 +927,7 @@ static inline int codegen_timing_instr_length(uint64_t timing, uint32_t fetchdat len += 2; } } - + return len; } @@ -1016,11 +1016,11 @@ static void codegen_instruction(uint64_t *timings, uint64_t *deps, uint8_t opcod codegen_block_cycles += instr_cycles; decode_delay = (-instr_cycles) + 1; - + if (deps[opcode] & FPU_POP) { int c; - + for (c = 0; c < 7; c++) fpu_st_latency[c] = fpu_st_latency[c+1]; fpu_st_latency[7] = 0; @@ -1028,7 +1028,7 @@ static void codegen_instruction(uint64_t *timings, uint64_t *deps, uint8_t opcod if (deps[opcode] & FPU_POP2) { int c; - + for (c = 0; c < 6; c++) fpu_st_latency[c] = fpu_st_latency[c+2]; fpu_st_latency[6] = fpu_st_latency[7] = 0; @@ -1041,7 +1041,7 @@ static void codegen_instruction(uint64_t *timings, uint64_t *deps, uint8_t opcod if (deps[opcode] & FPU_PUSH) { int c; - + for (c = 0; c < 7; c++) fpu_st_latency[c+1] = fpu_st_latency[c]; fpu_st_latency[0] = 0; @@ -1086,7 +1086,7 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f; deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f; break; - + case 0xd8: timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8; deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8; @@ -1141,19 +1141,19 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81; opcode = (fetchdat >> 3) & 7; break; - + case 0xc0: case 0xc1: case 0xd0: case 0xd1: timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; opcode = (fetchdat >> 3) & 7; break; - + case 0xd2: case 0xd3: timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; deps = mod3 ? opcode_deps_shift_cl_mod3 : opcode_deps_shift_cl; opcode = (fetchdat >> 3) & 7; break; - + case 0xf6: timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6; deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6; @@ -1176,7 +1176,7 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, break; } } - + if (u_pipe_full) { uint8_t regmask = get_srcdep_mask(deps[opcode], fetchdat, bit8, u_pipe_op_32); @@ -1190,7 +1190,7 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, goto nopair; if ((u_pipe_timings[u_pipe_opcode] & PAIR_MASK) == PAIR_FX && - (timings[opcode] & PAIR_MASK) == PAIR_FXCH) + (timings[opcode] & PAIR_MASK) == PAIR_FXCH) { int temp; @@ -1209,16 +1209,16 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, addr_regmask = 0; return; } - + if ((timings[opcode] & PAIR_V) && !(u_pipe_regmask & regmask) && (decode_delay+decode_delay_offset+u_pipe_decode_delay_offset) <= 0) { int has_displacement; - + if (timings[opcode] & CYCLES_HASIMM) has_displacement = codegen_timing_has_displacement(fetchdat, op_32); else has_displacement = 0; - + if (!has_displacement && (!cpu_has_feature(CPU_FEATURE_MMX) || codegen_timing_instr_length(timings[opcode], fetchdat, op_32) <= 7)) { int t1 = u_pipe_timings[u_pipe_opcode] & CYCLES_MASK; @@ -1226,15 +1226,15 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, int t_pair; uint64_t temp_timing; uint64_t temp_deps = 0; - + if (!(u_pipe_timings[u_pipe_opcode] & PAIR_FPU)) t1 &= 3; if (!(timings[opcode] & PAIR_FPU)) - t2 &= 3; + t2 &= 3; if (t1 < 0 || t2 < 0 || t1 > CYCLES_BRANCH || t2 > CYCLES_BRANCH) fatal("Pair out of range\n"); - + t_pair = pair_timings[t1][t2]; if (t_pair < 1) fatal("Illegal pair timings : t1=%i t2=%i u_opcode=%02x v_opcode=%02x\n", t1, t2, u_pipe_opcode, opcode); @@ -1246,7 +1246,7 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, codegen_instruction(&temp_timing, &temp_deps, 0, 0, 0, 0, agi_stall); u_pipe_full = 0; decode_delay_offset = 0; - + regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8) | u_pipe_regmask; addr_regmask = 0; return; @@ -1266,14 +1266,14 @@ nopair: if ((timings[opcode] & PAIR_U) && (decode_delay + decode_delay_offset) <= 0) { int has_displacement; - + if (timings[opcode] & CYCLES_HASIMM) has_displacement = codegen_timing_has_displacement(fetchdat, op_32); else has_displacement = 0; - + if ((!has_displacement || cpu_has_feature(CPU_FEATURE_MMX)) && (!cpu_has_feature(CPU_FEATURE_MMX) || codegen_timing_instr_length(timings[opcode], fetchdat, op_32) <= 7)) - { + { /*Instruction might pair with next*/ u_pipe_full = 1; u_pipe_opcode = opcode; diff --git a/src/cpu/codegen_timing_winchip.c b/src/cpu/codegen_timing_winchip.c index dd2123f49..c945d7f21 100644 --- a/src/cpu/codegen_timing_winchip.c +++ b/src/cpu/codegen_timing_winchip.c @@ -313,7 +313,7 @@ void codegen_timing_winchip_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f; deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f; break; - + case 0xd8: timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8; deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8; @@ -368,13 +368,13 @@ void codegen_timing_winchip_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81; opcode = (fetchdat >> 3) & 7; break; - + case 0xc0: case 0xc1: case 0xd0: case 0xd1: case 0xd2: case 0xd3: timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; opcode = (fetchdat >> 3) & 7; break; - + case 0xf6: timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6; deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6; @@ -397,12 +397,12 @@ void codegen_timing_winchip_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, break; } } - + timing_count += COUNT(timings[opcode], op_32); if (regmask_modified & get_addr_regmask(deps[opcode], fetchdat, op_32)) timing_count++; /*AGI stall*/ codegen_block_cycles += timing_count; - + regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8); } diff --git a/src/cpu/codegen_timing_winchip2.c b/src/cpu/codegen_timing_winchip2.c index 06cc06697..38c8924d4 100644 --- a/src/cpu/codegen_timing_winchip2.c +++ b/src/cpu/codegen_timing_winchip2.c @@ -582,7 +582,7 @@ static void codegen_timing_winchip2_opcode(uint8_t opcode, uint32_t fetchdat, in timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f; deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f; break; - + case 0xd8: timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8; deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8; @@ -637,13 +637,13 @@ static void codegen_timing_winchip2_opcode(uint8_t opcode, uint32_t fetchdat, in deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81; opcode = (fetchdat >> 3) & 7; break; - + case 0xc0: case 0xc1: case 0xd0: case 0xd1: case 0xd2: case 0xd3: timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift; opcode = (fetchdat >> 3) & 7; break; - + case 0xf6: timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6; deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6; @@ -666,11 +666,11 @@ static void codegen_timing_winchip2_opcode(uint8_t opcode, uint32_t fetchdat, in break; } } - + if (u_pipe_full) { uint8_t regmask = get_srcdep_mask(deps[opcode], fetchdat, bit8, u_pipe_op_32); - + if (can_pair(u_pipe_timings[u_pipe_opcode], timings[opcode], regmask)) { int cycles_a = u_pipe_timings[u_pipe_opcode] & 0xff; @@ -711,7 +711,7 @@ static void codegen_timing_winchip2_opcode(uint8_t opcode, uint32_t fetchdat, in decode_delay_offset = 0; return; } - + if (check_agi(deps, opcode, fetchdat, op_32)) agi_stall = 1; codegen_instruction(timings, deps, opcode, fetchdat, decode_delay_offset, op_32, agi_stall); @@ -724,7 +724,7 @@ static void codegen_timing_winchip2_block_end() if (u_pipe_full) { int agi_stall = 0; - + if (check_agi(u_pipe_deps, u_pipe_opcode, u_pipe_fetchdat, u_pipe_op_32)) agi_stall = 1; codegen_instruction(u_pipe_timings, u_pipe_deps, u_pipe_opcode, u_pipe_fetchdat, u_pipe_decode_delay_offset, u_pipe_op_32, agi_stall); diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index c956bee03..88fbd22fa 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -282,7 +282,7 @@ cpu_is_eligible(const cpu_family_t *cpu_family, int cpu, int machine) /* Don't care about multiplier compatibility on fixed multiplier CPUs. */ if (cpu_s->cpu_flags & CPU_FIXED_MULTIPLIER) - return 1; + return 1; else if (cpu_family->package & CPU_PKG_SOCKET5_7) { if ((multi == 1.5) && (cpu_s->cpu_type == CPU_5K86) && (machine_s->cpu_min_multi > 1.5)) /* K5 5k86 */ multi = 2.0; @@ -968,12 +968,12 @@ cpu_set(void) msr.fcr |= (1 << 18) | (1 << 20); cpu_CR4_mask = CR4_TSD | CR4_DE | CR4_MCE | CR4_PCE; -#ifdef USE_DYNAREC +#ifdef USE_DYNAREC if (cpu_s->cpu_type == CPU_WINCHIP2) codegen_timing_set(&codegen_timing_winchip2); else codegen_timing_set(&codegen_timing_winchip); -#endif +#endif break; case CPU_P24T: @@ -1518,7 +1518,7 @@ cpu_CPUID(void) } else EAX = EBX = ECX = EDX = 0; break; - + case CPU_ENH_Am486DX: if (!EAX) { EAX = 1; @@ -1542,7 +1542,7 @@ cpu_CPUID(void) EDX = msr.fcr2 >> 32; } else { EBX = 0x746e6543; /* CentaurHauls */ - ECX = 0x736c7561; + ECX = 0x736c7561; EDX = 0x48727561; } } else if (EAX == 1) { @@ -1567,7 +1567,7 @@ cpu_CPUID(void) EDX = msr.fcr2 >> 32; } else { EBX = 0x746e6543; /* CentaurHauls */ - ECX = 0x736c7561; + ECX = 0x736c7561; EDX = 0x48727561; } break; @@ -1576,7 +1576,7 @@ cpu_CPUID(void) EBX = ECX = 0; EDX = CPUID_FPU | CPUID_TSC | CPUID_MSR; if (cpu_has_feature(CPU_FEATURE_CX8)) - EDX |= CPUID_CMPXCHG8B; + EDX |= CPUID_CMPXCHG8B; if (msr.fcr & (1 << 9)) EDX |= CPUID_MMX; break; @@ -2003,7 +2003,7 @@ cpu_CPUID(void) EDX = msr.fcr2 >> 32; } else { EBX = 0x746e6543; /* CentaurHauls */ - ECX = 0x736c7561; + ECX = 0x736c7561; EDX = 0x48727561; } break; @@ -2012,7 +2012,7 @@ cpu_CPUID(void) EBX = ECX = 0; EDX = CPUID_FPU | CPUID_TSC | CPUID_MSR | CPUID_MCE | CPUID_MMX | CPUID_MTRR; if (cpu_has_feature(CPU_FEATURE_CX8)) - EDX |= CPUID_CMPXCHG8B; + EDX |= CPUID_CMPXCHG8B; break; case 0x80000000: EAX = 0x80000005; @@ -2022,7 +2022,7 @@ cpu_CPUID(void) EDX = CPUID_FPU | CPUID_TSC | CPUID_MSR | CPUID_MCE | CPUID_MMX | CPUID_MTRR | CPUID_3DNOW; if (cpu_has_feature(CPU_FEATURE_CX8)) EDX |= CPUID_CMPXCHG8B; - break; + break; case 0x80000002: /* Processor name string */ EAX = 0x20414956; /* VIA Samuel */ EBX = 0x756d6153; @@ -2095,7 +2095,7 @@ cpu_RDMSR(void) if ((cpu_s->cpu_type > CPU_IBM386SLC) && cpu_s->multi) EAX = msr.ibm_por2 & 0x3f000000; break; - } + } break; case CPU_WINCHIP: @@ -2159,7 +2159,7 @@ cpu_RDMSR(void) else if (cpu_dmulti == 7) EAX |= ((1 << 25) | (0 << 24) | (0 << 23) | (1 << 22)); else - EAX |= ((0 << 25) | (0 << 24) | (0 << 23) | (1 << 22)); + EAX |= ((0 << 25) | (0 << 24) | (0 << 23) | (1 << 22)); if (cpu_busspeed >= 84000000) EAX |= (1 << 19); break; @@ -2202,7 +2202,7 @@ cpu_RDMSR(void) case 0x2ff: EAX = msr.mtrr_deftype & 0xffffffff; EDX = msr.mtrr_deftype >> 32; - break; + break; } break; @@ -2289,7 +2289,7 @@ amd_k_invalid_rdmsr: } break; - case CPU_P24T: + case CPU_P24T: case CPU_PENTIUM: case CPU_PENTIUMMMX: #if defined(DEV_BRANCH) && defined(USE_CYRIX_6X86) @@ -2360,11 +2360,11 @@ amd_k_invalid_rdmsr: else if (cpu_dmulti == 7) EAX |= ((1 << 25) | (0 << 24) | (0 << 23) | (1 << 22)); else if (cpu_dmulti == 7.5) - EAX |= ((1 << 25) | (1 << 24) | (0 << 23) | (1 << 22)); + EAX |= ((1 << 25) | (1 << 24) | (0 << 23) | (1 << 22)); else if (cpu_dmulti == 8) - EAX |= ((1 << 25) | (0 << 24) | (1 << 23) | (0 << 22)); + EAX |= ((1 << 25) | (0 << 24) | (1 << 23) | (0 << 22)); else - EAX |= ((0 << 25) | (1 << 24) | (1 << 23) | (1 << 22)); + EAX |= ((0 << 25) | (1 << 24) | (1 << 23) | (1 << 22)); if (cpu_s->cpu_type != CPU_PENTIUMPRO) { if (cpu_busspeed >= 84000000) EAX |= (1 << 19); @@ -2532,12 +2532,12 @@ cpu_WRMSR(void) switch (cpu_s->cpu_type) { case CPU_IBM386SLC: case CPU_IBM486BL: - case CPU_IBM486SLC: + case CPU_IBM486SLC: switch (ECX) { case 0x1000: msr.ibm_por = EAX & ((cpu_s->cpu_type > CPU_IBM386SLC) ? 0xffeff : 0xfeff); cpu_cache_int_enabled = (EAX & (1 << 7)); - break; + break; case 0x1001: msr.ibm_crcr = EAX & 0xffffffffff; break; @@ -2589,7 +2589,7 @@ cpu_WRMSR(void) msr.fcr3 = EAX | ((uint64_t)EDX << 32); break; } - break; + break; case CPU_CYRIX3S: switch (ECX) { @@ -2634,7 +2634,7 @@ cpu_WRMSR(void) break; case 0x2ff: msr.mtrr_deftype = EAX | ((uint64_t)EDX << 32); - break; + break; } break; diff --git a/src/cpu/cpu_table.c b/src/cpu/cpu_table.c index 7931dffc7..e9433f76a 100644 --- a/src/cpu/cpu_table.c +++ b/src/cpu/cpu_table.c @@ -47,7 +47,7 @@ FPU fpus_80286[] = { {"None", "none", FPU_NONE}, {"287", "287", FPU_287}, - {"287XL","287xl", FPU_287XL}, + {"287XL","287xl", FPU_287XL}, {NULL, NULL, 0} }; FPU fpus_80386[] = @@ -435,7 +435,7 @@ const cpu_family_t cpu_families[] = { .name = "i486DX2 (SL-Enhanced)", .internal_name = "i486dx2_slenh", .cpus = (const CPU[]) { - {"40", CPU_i486DX_SLENH, fpus_internal, 40000000, 2, 5000, 0x435, 0x435, 0, CPU_SUPPORTS_DYNAREC, 7, 7,6,6, 5}, + {"40", CPU_i486DX_SLENH, fpus_internal, 40000000, 2, 5000, 0x435, 0x435, 0, CPU_SUPPORTS_DYNAREC, 7, 7,6,6, 5}, {"50", CPU_i486DX_SLENH, fpus_internal, 50000000, 2, 5000, 0x435, 0x435, 0, CPU_SUPPORTS_DYNAREC, 8, 8,6,6, 6}, {"66", CPU_i486DX_SLENH, fpus_internal, 66666666, 2, 5000, 0x435, 0x435, 0, CPU_SUPPORTS_DYNAREC, 12,12,6,6, 8}, {"", 0} @@ -456,7 +456,7 @@ const cpu_family_t cpu_families[] = { .name = "iDX4", .internal_name = "idx4", .cpus = (const CPU[]) { - {"75", CPU_i486DX_SLENH, fpus_internal, 75000000, 3.0, 5000, 0x480, 0x480, 0x0000, CPU_SUPPORTS_DYNAREC, 12,12, 9, 9, 9}, + {"75", CPU_i486DX_SLENH, fpus_internal, 75000000, 3.0, 5000, 0x480, 0x480, 0x0000, CPU_SUPPORTS_DYNAREC, 12,12, 9, 9, 9}, {"100", CPU_i486DX_SLENH, fpus_internal, 100000000, 3.0, 5000, 0x483, 0x483, 0x0000, CPU_SUPPORTS_DYNAREC, 18,18, 9, 9, 12}, {"", 0} } @@ -477,7 +477,7 @@ const cpu_family_t cpu_families[] = { .internal_name = "am486sx", .cpus = (const CPU[]) { {"33", CPU_Am486SX, fpus_486sx, 33333333, 1, 5000, 0x422, 0, 0, CPU_SUPPORTS_DYNAREC, 6, 6, 3, 3, 4}, - {"40", CPU_Am486SX, fpus_486sx, 40000000, 1, 5000, 0x422, 0, 0, CPU_SUPPORTS_DYNAREC, 7, 7, 3, 3, 5}, + {"40", CPU_Am486SX, fpus_486sx, 40000000, 1, 5000, 0x422, 0, 0, CPU_SUPPORTS_DYNAREC, 7, 7, 3, 3, 5}, {"", 0} } }, { @@ -486,8 +486,8 @@ const cpu_family_t cpu_families[] = { .name = "Am486SX2", .internal_name = "am486sx2", .cpus = (const CPU[]) { - {"50", CPU_Am486SX, fpus_486sx, 50000000, 2, 5000, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 8, 8, 6, 6, 6}, - {"66", CPU_Am486SX, fpus_486sx, 66666666, 2, 5000, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 12,12, 6, 6, 8}, + {"50", CPU_Am486SX, fpus_486sx, 50000000, 2, 5000, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 8, 8, 6, 6, 6}, + {"66", CPU_Am486SX, fpus_486sx, 66666666, 2, 5000, 0x45b, 0, 0, CPU_SUPPORTS_DYNAREC, 12,12, 6, 6, 8}, {"", 0} } }, { @@ -544,7 +544,7 @@ const cpu_family_t cpu_families[] = { {"120", CPU_Am486DX, fpus_internal, 120000000, 3.0, 5000, 0x432, 0, 0, CPU_SUPPORTS_DYNAREC, 21,21, 9, 9, 15}, {"", 0} } - }, + }, { .package = CPU_PKG_SOCKET3, .manufacturer = "AMD", @@ -574,7 +574,7 @@ const cpu_family_t cpu_families[] = { .cpus = (const CPU[]) { {"P75", CPU_ENH_Am486DX, fpus_internal, 133333333, 4.0, 5000, 0x4e0, 0x4e0, 0, CPU_SUPPORTS_DYNAREC, 24,24,12,12, 16}, {"P75+", CPU_ENH_Am486DX, fpus_internal, 150000000, 3.0, 5000, 0x482, 0x482, 0, CPU_SUPPORTS_DYNAREC, 28,28,12,12, 20},/*The rare P75+ was indeed a triple-clocked 150 MHz according to research*/ - {"P90", CPU_ENH_Am486DX, fpus_internal, 160000000, 4.0, 5000, 0x4e0, 0x4e0, 0, CPU_SUPPORTS_DYNAREC, 28,28,12,12, 20},/*160 MHz on a 40 MHz bus was a common overclock and "5x86/P90" was used by a number of BIOSes to refer to that configuration*/ + {"P90", CPU_ENH_Am486DX, fpus_internal, 160000000, 4.0, 5000, 0x4e0, 0x4e0, 0, CPU_SUPPORTS_DYNAREC, 28,28,12,12, 20},/*160 MHz on a 40 MHz bus was a common overclock and "5x86/P90" was used by a number of BIOSes to refer to that configuration*/ {"", 0} } }, { @@ -889,7 +889,7 @@ const cpu_family_t cpu_families[] = { {"380", CPU_K6_2P, fpus_internal, 380000000, 4.0, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 34, 34, 12, 12, 46}, /* out of spec */ {"400/66", CPU_K6_2P, fpus_internal, 400000000, 6.0, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 36, 36, 12, 12, 48}, /* out of spec */ {"400/100", CPU_K6_2P, fpus_internal, 400000000, 4.0, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 36, 36, 12, 12, 48}, /* out of spec */ - {"450", CPU_K6_2P, fpus_internal, 450000000, 4.5, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 41, 41, 14, 14, 54}, + {"450", CPU_K6_2P, fpus_internal, 450000000, 4.5, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 41, 41, 14, 14, 54}, {"475", CPU_K6_2P, fpus_internal, 475000000, 5.0, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 43, 43, 15, 15, 57}, {"500", CPU_K6_2P, fpus_internal, 500000000, 5.0, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 45, 45, 15, 15, 60}, {"533", CPU_K6_2P, fpus_internal, 533333333, 5.5, 2000, 0x5d4, 0x5d4, 0, CPU_SUPPORTS_DYNAREC | CPU_REQUIRES_DYNAREC, 48, 48, 17, 17, 64}, @@ -1280,7 +1280,7 @@ static const cpu_legacy_table_t cpus_IBM486SLC[] = { {NULL, 0, 0} }; -static const cpu_legacy_table_t cpus_IBM486BL[] = { +static const cpu_legacy_table_t cpus_IBM486BL[] = { {"ibm486bl2", 50000000, 2}, {"ibm486bl2", 66666666, 2}, {"ibm486bl3", 75000000, 3}, @@ -1313,13 +1313,13 @@ static const cpu_legacy_table_t cpus_i486S1[] = { {"i486dx2", 50000000, 2}, {"i486dx2", 66666666, 2}, {"idx4_od", 75000000, 3}, - {"idx4_od", 100000000, 3}, + {"idx4_od", 100000000, 3}, {NULL, 0, 0} }; static const cpu_legacy_table_t cpus_Am486S1[] = { {"am486sx", 33333333, 1}, - {"am486sx", 40000000, 1}, + {"am486sx", 40000000, 1}, {"am486sx2", 50000000, 2}, {"am486sx2", 66666666, 2}, {"am486dx", 33333333, 1}, @@ -1358,7 +1358,7 @@ static const cpu_legacy_table_t cpus_i486[] = { {"idx4", 75000000, 3.0}, {"idx4", 100000000, 3.0}, {"idx4_od", 75000000, 3.0}, - {"idx4_od", 100000000, 3.0}, + {"idx4_od", 100000000, 3.0}, {"pentium_p24t", 62500000, 2.5}, {"pentium_p24t", 83333333, 2.5}, {NULL, 0, 0} @@ -1376,7 +1376,7 @@ static const cpu_legacy_table_t cpus_i486_PC330[] = { static const cpu_legacy_table_t cpus_Am486[] = { {"am486sx", 33333333, 1.0}, - {"am486sx", 40000000, 1.0}, + {"am486sx", 40000000, 1.0}, {"am486sx2", 50000000, 2.0}, {"am486sx2", 66666666, 2.0}, {"am486dx", 33333333, 1.0}, @@ -1390,7 +1390,7 @@ static const cpu_legacy_table_t cpus_Am486[] = { {"am486dx4", 120000000, 3.0}, {"am5x86", 133333333, 4.0}, {"am5x86", 150000000, 3.0}, - {"am5x86", 160000000, 4.0}, + {"am5x86", 160000000, 4.0}, {NULL, 0, 0} }; @@ -1793,7 +1793,7 @@ static const cpu_legacy_table_t cpus_Xeon[] = { {"pentium2_xeon", 166666666, 2.5}, {"pentium2_xeon", 400000000, 4.0}, {"pentium2_xeon", 450000000, 4.5}, - {NULL, 0, 0} + {NULL, 0, 0} }; static const cpu_legacy_table_t cpus_Celeron[] = { @@ -1809,7 +1809,7 @@ static const cpu_legacy_table_t cpus_Celeron[] = { {"celeron_mendocino", 466666666, 7.0}, {"celeron_mendocino", 500000000, 7.5}, {"celeron_mendocino", 533333333, 8.0}, - {NULL, 0, 0} + {NULL, 0, 0} }; static const cpu_legacy_table_t cpus_PentiumIID[] = { diff --git a/src/cpu/x86.c b/src/cpu/x86.c index 94b2294dd..60bc33b9b 100644 --- a/src/cpu/x86.c +++ b/src/cpu/x86.c @@ -1,4 +1,4 @@ -/* +/* * 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 diff --git a/src/cpu/x86.h b/src/cpu/x86.h index c5e59551f..b9726dc57 100644 --- a/src/cpu/x86.h +++ b/src/cpu/x86.h @@ -3,7 +3,7 @@ of this code path; eg a GPF due to being in v86 mode. An 'unexpected' exception is one that would be unlikely to occur on the next exception, eg a page fault may be fixed up by the exception handler and the next execution would not hit it. - + This distinction is used by the dynarec; a block that hits an 'expected' exception would be compiled, a block that hits an 'unexpected' exception would be rejected so that we don't end up with an unnecessarily short block*/ diff --git a/src/cpu/x86_flags.h b/src/cpu/x86_flags.h index bf160390c..b46755e90 100644 --- a/src/cpu/x86_flags.h +++ b/src/cpu/x86_flags.h @@ -3,19 +3,19 @@ extern int tempc; enum { FLAGS_UNKNOWN, - + FLAGS_ZN8, FLAGS_ZN16, FLAGS_ZN32, - + FLAGS_ADD8, FLAGS_ADD16, FLAGS_ADD32, - + FLAGS_SUB8, FLAGS_SUB16, FLAGS_SUB32, - + FLAGS_SHL8, FLAGS_SHL16, FLAGS_SHL32, @@ -41,7 +41,7 @@ enum FLAGS_INC8, FLAGS_INC16, FLAGS_INC32, - + FLAGS_DEC8, FLAGS_DEC16, FLAGS_DEC32 @@ -62,7 +62,7 @@ static __inline int ZF_SET() { switch (cpu_state.flags_op) { - case FLAGS_ZN8: + case FLAGS_ZN8: case FLAGS_ZN16: case FLAGS_ZN32: case FLAGS_ADD8: @@ -95,7 +95,7 @@ static __inline int ZF_SET() case FLAGS_SBC32: #endif return !cpu_state.flags_res; - + #ifdef USE_NEW_DYNAREC case FLAGS_ROL8: case FLAGS_ROL16: @@ -121,7 +121,7 @@ static __inline int NF_SET() { switch (cpu_state.flags_op) { - case FLAGS_ZN8: + case FLAGS_ZN8: case FLAGS_ADD8: case FLAGS_SUB8: case FLAGS_SHL8: @@ -134,7 +134,7 @@ static __inline int NF_SET() case FLAGS_SBC8: #endif return cpu_state.flags_res & 0x80; - + case FLAGS_ZN16: case FLAGS_ADD16: case FLAGS_SUB16: @@ -148,7 +148,7 @@ static __inline int NF_SET() case FLAGS_SBC16: #endif return cpu_state.flags_res & 0x8000; - + case FLAGS_ZN32: case FLAGS_ADD32: case FLAGS_SUB32: @@ -162,7 +162,7 @@ static __inline int NF_SET() case FLAGS_SBC32: #endif return cpu_state.flags_res & 0x80000000; - + #ifdef USE_NEW_DYNAREC case FLAGS_ROL8: case FLAGS_ROL16: @@ -188,7 +188,7 @@ static __inline int PF_SET() { switch (cpu_state.flags_op) { - case FLAGS_ZN8: + case FLAGS_ZN8: case FLAGS_ZN16: case FLAGS_ZN32: case FLAGS_ADD8: @@ -221,7 +221,7 @@ static __inline int PF_SET() case FLAGS_SBC32: #endif return znptable8[cpu_state.flags_res & 0xff] & P_FLAG; - + #ifdef USE_NEW_DYNAREC case FLAGS_ROL8: case FLAGS_ROL16: @@ -254,7 +254,7 @@ static __inline int VF_SET() case FLAGS_SAR16: case FLAGS_SAR32: return 0; - + #ifdef USE_NEW_DYNAREC case FLAGS_ADC8: #endif @@ -299,7 +299,7 @@ static __inline int VF_SET() return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) & 0x8000); case FLAGS_SHL32: return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) & 0x80000000); - + case FLAGS_SHR8: return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x80)); case FLAGS_SHR16: @@ -340,7 +340,7 @@ static __inline int AF_SET() { switch (cpu_state.flags_op) { - case FLAGS_ZN8: + case FLAGS_ZN8: case FLAGS_ZN16: case FLAGS_ZN32: case FLAGS_SHL8: @@ -353,7 +353,7 @@ static __inline int AF_SET() case FLAGS_SAR16: case FLAGS_SAR32: return 0; - + case FLAGS_ADD8: case FLAGS_ADD16: case FLAGS_ADD32: @@ -388,7 +388,7 @@ static __inline int AF_SET() case FLAGS_SBC32: return ((cpu_state.flags_op1 & 0xf) < (cpu_state.flags_op2 & 0xf)) || ((cpu_state.flags_op1 & 0xf) == (cpu_state.flags_op2 & 0xf) && (cpu_state.flags_res & 0xf) != 0); - + case FLAGS_ROL8: case FLAGS_ROL16: case FLAGS_ROL32: @@ -464,7 +464,7 @@ static __inline int CF_SET() case FLAGS_SAR32: return ((int32_t)cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1; - case FLAGS_ZN8: + case FLAGS_ZN8: case FLAGS_ZN16: case FLAGS_ZN32: return 0; @@ -474,7 +474,7 @@ static __inline int CF_SET() case FLAGS_ROL16: case FLAGS_ROL32: return cpu_state.flags_res & 1; - + case FLAGS_ROR8: return (cpu_state.flags_res & 0x80) ? 1 : 0; case FLAGS_ROR16: @@ -510,7 +510,7 @@ static __inline void flags_rebuild() if (CF_SET()) tempf |= C_FLAG; if (PF_SET()) tempf |= P_FLAG; if (AF_SET()) tempf |= A_FLAG; - if (ZF_SET()) tempf |= Z_FLAG; + if (ZF_SET()) tempf |= Z_FLAG; if (NF_SET()) tempf |= N_FLAG; if (VF_SET()) tempf |= V_FLAG; cpu_state.flags = (cpu_state.flags & ~0x8d5) | tempf; diff --git a/src/cpu/x86_ops_3dnow.h b/src/cpu/x86_ops_3dnow.h index c578c400a..8131967ca 100644 --- a/src/cpu/x86_ops_3dnow.h +++ b/src/cpu/x86_ops_3dnow.h @@ -159,14 +159,14 @@ static int opPFRCP(uint32_t fetchdat) uint32_t i; float f; } src; - + if (cpu_mod == 3) { src.f = cpu_state.MM[cpu_rm].f[0]; - CLOCK_CYCLES(1); - } - else - { + CLOCK_CYCLES(1); + } + else + { SEG_CHECK_READ(cpu_state.ea_seg); src.i = readmeml(easeg, cpu_state.eaaddr); if (cpu_state.abrt) return 1; CLOCK_CYCLES(2); @@ -334,13 +334,13 @@ static int op3DNOW_a16(uint32_t fetchdat) static int op3DNOW_a32(uint32_t fetchdat) { uint8_t opcode; - + MMX_ENTER(); fetch_ea_32(fetchdat); opcode = fastreadb(cs + cpu_state.pc); if (cpu_state.abrt) return 1; cpu_state.pc++; - + return x86_opcodes_3DNOW[opcode](0); } diff --git a/src/cpu/x86_ops_arith.h b/src/cpu/x86_ops_arith.h index d837d3a64..b56abb26a 100644 --- a/src/cpu/x86_ops_arith.h +++ b/src/cpu/x86_ops_arith.h @@ -314,8 +314,8 @@ static int opCMP_b_rmw_a16(uint32_t fetchdat) PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0); return 0; } -static int opCMP_b_rmw_a32(uint32_t fetchdat) -{ +static int opCMP_b_rmw_a32(uint32_t fetchdat) +{ uint8_t dst; fetch_ea_32(fetchdat); if (cpu_mod != 3) @@ -326,10 +326,10 @@ static int opCMP_b_rmw_a32(uint32_t fetchdat) else { CLOCK_CYCLES((cpu_mod == 3) ? 2 : 5); } PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1); return 0; -} - -static int opCMP_w_rmw_a16(uint32_t fetchdat) -{ +} + +static int opCMP_w_rmw_a16(uint32_t fetchdat) +{ uint16_t dst; fetch_ea_16(fetchdat); if (cpu_mod != 3) @@ -340,9 +340,9 @@ static int opCMP_w_rmw_a16(uint32_t fetchdat) else { CLOCK_CYCLES((cpu_mod == 3) ? 2 : 5); } PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0); return 0; -} -static int opCMP_w_rmw_a32(uint32_t fetchdat) -{ +} +static int opCMP_w_rmw_a32(uint32_t fetchdat) +{ uint16_t dst; fetch_ea_32(fetchdat); if (cpu_mod != 3) @@ -353,10 +353,10 @@ static int opCMP_w_rmw_a32(uint32_t fetchdat) else { CLOCK_CYCLES((cpu_mod == 3) ? 2 : 5); } PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1); return 0; -} - -static int opCMP_l_rmw_a16(uint32_t fetchdat) -{ +} + +static int opCMP_l_rmw_a16(uint32_t fetchdat) +{ uint32_t dst; fetch_ea_16(fetchdat); if (cpu_mod != 3) @@ -367,9 +367,9 @@ static int opCMP_l_rmw_a16(uint32_t fetchdat) else { CLOCK_CYCLES((cpu_mod == 3) ? 2 : 5); } PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 0); return 0; -} -static int opCMP_l_rmw_a32(uint32_t fetchdat) -{ +} +static int opCMP_l_rmw_a32(uint32_t fetchdat) +{ uint32_t dst; fetch_ea_32(fetchdat); if (cpu_mod != 3) @@ -380,108 +380,108 @@ static int opCMP_l_rmw_a32(uint32_t fetchdat) else { CLOCK_CYCLES((cpu_mod == 3) ? 2 : 5); } PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 1); return 0; -} - -static int opCMP_b_rm_a16(uint32_t fetchdat) -{ - uint8_t src; +} + +static int opCMP_b_rm_a16(uint32_t fetchdat) +{ + uint8_t src; fetch_ea_16(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - src = geteab(); if (cpu_state.abrt) return 1; + SEG_CHECK_READ(cpu_state.ea_seg); + src = geteab(); if (cpu_state.abrt) return 1; setsub8(getr8(cpu_reg), src); CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0); - return 0; -} -static int opCMP_b_rm_a32(uint32_t fetchdat) -{ - uint8_t src; + return 0; +} +static int opCMP_b_rm_a32(uint32_t fetchdat) +{ + uint8_t src; fetch_ea_32(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - src = geteab(); if (cpu_state.abrt) return 1; + SEG_CHECK_READ(cpu_state.ea_seg); + src = geteab(); if (cpu_state.abrt) return 1; setsub8(getr8(cpu_reg), src); CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1); - return 0; -} - -static int opCMP_w_rm_a16(uint32_t fetchdat) -{ - uint16_t src; + return 0; +} + +static int opCMP_w_rm_a16(uint32_t fetchdat) +{ + uint16_t src; fetch_ea_16(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - src = geteaw(); if (cpu_state.abrt) return 1; + SEG_CHECK_READ(cpu_state.ea_seg); + src = geteaw(); if (cpu_state.abrt) return 1; setsub16(cpu_state.regs[cpu_reg].w, src); CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0); - return 0; -} -static int opCMP_w_rm_a32(uint32_t fetchdat) -{ - uint16_t src; + return 0; +} +static int opCMP_w_rm_a32(uint32_t fetchdat) +{ + uint16_t src; fetch_ea_32(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - src = geteaw(); if (cpu_state.abrt) return 1; + SEG_CHECK_READ(cpu_state.ea_seg); + src = geteaw(); if (cpu_state.abrt) return 1; setsub16(cpu_state.regs[cpu_reg].w, src); CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1); - return 0; -} - -static int opCMP_l_rm_a16(uint32_t fetchdat) + return 0; +} + +static int opCMP_l_rm_a16(uint32_t fetchdat) { uint32_t src; fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - src = geteal(); if (cpu_state.abrt) return 1; + src = geteal(); if (cpu_state.abrt) return 1; setsub32(cpu_state.regs[cpu_reg].l, src); CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml); PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 0); - return 0; -} -static int opCMP_l_rm_a32(uint32_t fetchdat) -{ + return 0; +} +static int opCMP_l_rm_a32(uint32_t fetchdat) +{ uint32_t src; fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - src = geteal(); if (cpu_state.abrt) return 1; + src = geteal(); if (cpu_state.abrt) return 1; setsub32(cpu_state.regs[cpu_reg].l, src); CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml); PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 1); - return 0; -} - -static int opCMP_AL_imm(uint32_t fetchdat) -{ - uint8_t src = getbytef(); + return 0; +} + +static int opCMP_AL_imm(uint32_t fetchdat) +{ + uint8_t src = getbytef(); setsub8(AL, src); CLOCK_CYCLES(timing_rr); PREFETCH_RUN(timing_rr, 2, -1, 0,0,0,0, 0); - return 0; -} - -static int opCMP_AX_imm(uint32_t fetchdat) -{ - uint16_t src = getwordf(); + return 0; +} + +static int opCMP_AX_imm(uint32_t fetchdat) +{ + uint16_t src = getwordf(); setsub16(AX, src); CLOCK_CYCLES(timing_rr); PREFETCH_RUN(timing_rr, 3, -1, 0,0,0,0, 0); - return 0; -} - -static int opCMP_EAX_imm(uint32_t fetchdat) -{ + return 0; +} + +static int opCMP_EAX_imm(uint32_t fetchdat) +{ uint32_t src = getlong(); if (cpu_state.abrt) return 1; setsub32(EAX, src); CLOCK_CYCLES(timing_rr); PREFETCH_RUN(timing_rr, 5, -1, 0,0,0,0, 0); - return 0; + return 0; } static int opTEST_b_a16(uint32_t fetchdat) @@ -652,7 +652,7 @@ static int opTEST_EAX(uint32_t fetchdat) static int op80_a16(uint32_t fetchdat) { uint8_t src, dst; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -663,13 +663,13 @@ static int op80_a16(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, 0); } - + return 0; } static int op80_a32(uint32_t fetchdat) { uint8_t src, dst; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -680,13 +680,13 @@ static int op80_a32(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, 1); } - + return 0; } static int op81_w_a16(uint32_t fetchdat) { uint16_t src, dst; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -697,13 +697,13 @@ static int op81_w_a16(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 4, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, 0); } - + return 0; } static int op81_w_a32(uint32_t fetchdat) { uint16_t src, dst; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -714,13 +714,13 @@ static int op81_w_a32(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 4, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, 1); } - + return 0; } static int op81_l_a16(uint32_t fetchdat) { uint32_t src, dst; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -731,13 +731,13 @@ static int op81_l_a16(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 6, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 0); } - + return 0; } static int op81_l_a32(uint32_t fetchdat) { uint32_t src, dst; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -748,14 +748,14 @@ static int op81_l_a32(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 6, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 1); } - + return 0; } static int op83_w_a16(uint32_t fetchdat) { uint16_t src, dst; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -767,13 +767,13 @@ static int op83_w_a16(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, 0); } - + return 0; } static int op83_w_a32(uint32_t fetchdat) { uint16_t src, dst; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -785,14 +785,14 @@ static int op83_w_a32(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, 1); } - + return 0; } static int op83_l_a16(uint32_t fetchdat) { uint32_t src, dst; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -804,13 +804,13 @@ static int op83_l_a16(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 0); } - + return 0; } static int op83_l_a32(uint32_t fetchdat) { uint32_t src, dst; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -822,7 +822,6 @@ static int op83_l_a32(uint32_t fetchdat) } else { PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 1); } - + return 0; } - diff --git a/src/cpu/x86_ops_bcd.h b/src/cpu/x86_ops_bcd.h index 7749e9f1b..385d63cd7 100644 --- a/src/cpu/x86_ops_bcd.h +++ b/src/cpu/x86_ops_bcd.h @@ -61,7 +61,7 @@ static int opAAS(uint32_t fetchdat) static int opDAA(uint32_t fetchdat) { uint16_t tempw, old_AL, old_CF; - + flags_rebuild(); old_AL = AL; old_CF = cpu_state.flags & C_FLAG; @@ -89,7 +89,7 @@ static int opDAA(uint32_t fetchdat) cpu_state.flags = (cpu_state.flags & ~(C_FLAG | A_FLAG)) | tempw; CLOCK_CYCLES(4); PREFETCH_RUN(4, 1, -1, 0,0,0,0, 0); - + return 0; } @@ -124,6 +124,6 @@ static int opDAS(uint32_t fetchdat) cpu_state.flags = (cpu_state.flags & ~(C_FLAG | A_FLAG)) | tempw; CLOCK_CYCLES(4); PREFETCH_RUN(4, 1, -1, 0,0,0,0, 0); - + return 0; } diff --git a/src/cpu/x86_ops_bit.h b/src/cpu/x86_ops_bit.h index df2d48619..4fc8ac0f7 100644 --- a/src/cpu/x86_ops_bit.h +++ b/src/cpu/x86_ops_bit.h @@ -1,7 +1,7 @@ static int opBT_w_r_a16(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_16(fetchdat); SEG_CHECK_READ(cpu_state.ea_seg); cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].w / 16) * 2); eal_r = 0; @@ -9,7 +9,7 @@ static int opBT_w_r_a16(uint32_t fetchdat) flags_rebuild(); if (temp & (1 << (cpu_state.regs[cpu_reg].w & 15))) cpu_state.flags |= C_FLAG; else cpu_state.flags &= ~C_FLAG; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, 1,0,0,0, 0); return 0; @@ -17,7 +17,7 @@ static int opBT_w_r_a16(uint32_t fetchdat) static int opBT_w_r_a32(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_32(fetchdat); SEG_CHECK_READ(cpu_state.ea_seg); cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].w / 16) * 2); eal_r = 0; @@ -25,7 +25,7 @@ static int opBT_w_r_a32(uint32_t fetchdat) flags_rebuild(); if (temp & (1 << (cpu_state.regs[cpu_reg].w & 15))) cpu_state.flags |= C_FLAG; else cpu_state.flags &= ~C_FLAG; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, 1,0,0,0, 1); return 0; @@ -33,7 +33,7 @@ static int opBT_w_r_a32(uint32_t fetchdat) static int opBT_l_r_a16(uint32_t fetchdat) { uint32_t temp; - + fetch_ea_16(fetchdat); SEG_CHECK_READ(cpu_state.ea_seg); cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].l / 32) * 4); eal_r = 0; @@ -41,7 +41,7 @@ static int opBT_l_r_a16(uint32_t fetchdat) flags_rebuild(); if (temp & (1 << (cpu_state.regs[cpu_reg].l & 31))) cpu_state.flags |= C_FLAG; else cpu_state.flags &= ~C_FLAG; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, 0,1,0,0, 0); return 0; @@ -49,7 +49,7 @@ static int opBT_l_r_a16(uint32_t fetchdat) static int opBT_l_r_a32(uint32_t fetchdat) { uint32_t temp; - + fetch_ea_32(fetchdat); SEG_CHECK_READ(cpu_state.ea_seg); cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].l / 32) * 4); eal_r = 0; @@ -57,7 +57,7 @@ static int opBT_l_r_a32(uint32_t fetchdat) flags_rebuild(); if (temp & (1 << (cpu_state.regs[cpu_reg].l & 31))) cpu_state.flags |= C_FLAG; else cpu_state.flags &= ~C_FLAG; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, 0,1,0,0, 1); return 0; diff --git a/src/cpu/x86_ops_bitscan.h b/src/cpu/x86_ops_bitscan.h index 46f0fc605..36ae1058e 100644 --- a/src/cpu/x86_ops_bitscan.h +++ b/src/cpu/x86_ops_bitscan.h @@ -23,14 +23,14 @@ static int opBSF_w_a16(uint32_t fetchdat) { uint16_t temp; int instr_cycles = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; - + BS_common(0, 16, 1, cpu_state.regs[cpu_reg].w, (is486) ? 1 : 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); @@ -40,14 +40,14 @@ static int opBSF_w_a32(uint32_t fetchdat) { uint16_t temp; int instr_cycles = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; - + BS_common(0, 16, 1, cpu_state.regs[cpu_reg].w, (is486) ? 1 : 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); @@ -57,14 +57,14 @@ static int opBSF_l_a16(uint32_t fetchdat) { uint32_t temp; int instr_cycles = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteal(); if (cpu_state.abrt) return 1; - + BS_common(0, 32, 1, cpu_state.regs[cpu_reg].l, (is486) ? 1 : 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 0); @@ -79,9 +79,9 @@ static int opBSF_l_a32(uint32_t fetchdat) if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteal(); if (cpu_state.abrt) return 1; - + BS_common(0, 32, 1, cpu_state.regs[cpu_reg].l, (is486) ? 1 : 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 1); @@ -92,14 +92,14 @@ static int opBSR_w_a16(uint32_t fetchdat) { uint16_t temp; int instr_cycles = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; - + BS_common(15, -1, -1, cpu_state.regs[cpu_reg].w, 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); @@ -109,14 +109,14 @@ static int opBSR_w_a32(uint32_t fetchdat) { uint16_t temp; int instr_cycles = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; - + BS_common(15, -1, -1, cpu_state.regs[cpu_reg].w, 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); @@ -126,14 +126,14 @@ static int opBSR_l_a16(uint32_t fetchdat) { uint32_t temp; int instr_cycles = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteal(); if (cpu_state.abrt) return 1; - + BS_common(31, -1, -1, cpu_state.regs[cpu_reg].l, 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 0); @@ -143,17 +143,16 @@ static int opBSR_l_a32(uint32_t fetchdat) { uint32_t temp; int instr_cycles = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteal(); if (cpu_state.abrt) return 1; - + BS_common(31, -1, -1, cpu_state.regs[cpu_reg].l, 3); - + CLOCK_CYCLES((is486) ? 6 : 10); instr_cycles += ((is486) ? 6 : 10); PREFETCH_RUN(instr_cycles, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 1); return 0; } - diff --git a/src/cpu/x86_ops_call.h b/src/cpu/x86_ops_call.h index 427d504fc..1c928a70b 100644 --- a/src/cpu/x86_ops_call.h +++ b/src/cpu/x86_ops_call.h @@ -26,7 +26,7 @@ PUSH_W(old_cs); if (cpu_state.abrt) { CS = old_cs; cgate16 = cgate32 = 0; return 1; } \ PUSH_W(old_pc); if (cpu_state.abrt) { CS = old_cs; ESP = old_esp; return 1; } \ } - + #define CALL_FAR_l(new_seg, new_pc) \ old_cs = CS; \ old_pc = cpu_state.pc; \ @@ -83,7 +83,7 @@ PUSH_W(old_cs); if (cpu_state.abrt) { cgate16 = cgate32 = 0; return 1; } \ PUSH_W(old_pc); if (cpu_state.abrt) { ESP = old_esp; return 1; } \ } - + #define CALL_FAR_l(new_seg, new_pc) \ old_cs = CS; \ old_pc = cpu_state.pc; \ @@ -113,22 +113,22 @@ PUSH_L(old_pc); if (cpu_state.abrt) { ESP = old_esp; return 1; } \ } #endif - - + + static int opCALL_far_w(uint32_t fetchdat) { uint32_t old_cs, old_pc; uint16_t new_cs, new_pc; int cycles_old = cycles; UN_USED(cycles_old); - + new_pc = getwordf(); new_cs = getword(); if (cpu_state.abrt) return 1; - + CALL_FAR_w(new_cs, new_pc); CPU_BLOCK_END(); PREFETCH_RUN(cycles_old-cycles, 5, -1, 0,0,cgate16 ? 2:0,cgate16 ? 0:2, 0); PREFETCH_FLUSH(); - + return 0; } static int opCALL_far_l(uint32_t fetchdat) @@ -136,15 +136,15 @@ static int opCALL_far_l(uint32_t fetchdat) uint32_t old_cs, old_pc; uint32_t new_cs, new_pc; int cycles_old = cycles; UN_USED(cycles_old); - + new_pc = getlong(); new_cs = getword(); if (cpu_state.abrt) return 1; - + CALL_FAR_l(new_cs, new_pc); CPU_BLOCK_END(); PREFETCH_RUN(cycles_old-cycles, 7, -1, 0,0,cgate16 ? 2:0,cgate16 ? 0:2, 0); PREFETCH_FLUSH(); - + return 0; } @@ -154,11 +154,11 @@ static int opFF_w_a16(uint32_t fetchdat) uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; int cycles_old = cycles; UN_USED(cycles_old); - + uint16_t temp; - + fetch_ea_16(fetchdat); - + switch (rmdat & 0x38) { case 0x00: /*INC w*/ @@ -196,7 +196,7 @@ static int opFF_w_a16(uint32_t fetchdat) SEG_CHECK_READ(cpu_state.ea_seg); new_pc = readmemw(easeg, cpu_state.eaaddr); new_cs = readmemw(easeg, (cpu_state.eaaddr + 2)); if (cpu_state.abrt) return 1; - + CALL_FAR_w(new_cs, new_pc); CPU_BLOCK_END(); PREFETCH_RUN(cycles_old-cycles, 2, rmdat, 2,0,cgate16 ? 2:0,cgate16 ? 0:2, 0); @@ -253,11 +253,11 @@ static int opFF_w_a32(uint32_t fetchdat) uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; int cycles_old = cycles; UN_USED(cycles_old); - + uint16_t temp; - + fetch_ea_32(fetchdat); - + switch (rmdat & 0x38) { case 0x00: /*INC w*/ @@ -295,7 +295,7 @@ static int opFF_w_a32(uint32_t fetchdat) SEG_CHECK_READ(cpu_state.ea_seg); new_pc = readmemw(easeg, cpu_state.eaaddr); new_cs = readmemw(easeg, (cpu_state.eaaddr + 2)); if (cpu_state.abrt) return 1; - + CALL_FAR_w(new_cs, new_pc); CPU_BLOCK_END(); PREFETCH_RUN(cycles_old-cycles, 2, rmdat, 2,0,cgate16 ? 2:0,cgate16 ? 0:2, 1); @@ -353,11 +353,11 @@ static int opFF_l_a16(uint32_t fetchdat) uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; int cycles_old = cycles; UN_USED(cycles_old); - + uint32_t temp; - + fetch_ea_16(fetchdat); - + switch (rmdat & 0x38) { case 0x00: /*INC l*/ @@ -395,7 +395,7 @@ static int opFF_l_a16(uint32_t fetchdat) SEG_CHECK_READ(cpu_state.ea_seg); new_pc = readmeml(easeg, cpu_state.eaaddr); new_cs = readmemw(easeg, (cpu_state.eaaddr + 4)); if (cpu_state.abrt) return 1; - + CALL_FAR_l(new_cs, new_pc); CPU_BLOCK_END(); PREFETCH_RUN(cycles_old-cycles, 2, rmdat, 1,1,cgate16 ? 2:0,cgate16 ? 0:2, 0); @@ -452,11 +452,11 @@ static int opFF_l_a32(uint32_t fetchdat) uint16_t old_cs, new_cs; uint32_t old_pc, new_pc; int cycles_old = cycles; UN_USED(cycles_old); - + uint32_t temp; - + fetch_ea_32(fetchdat); - + switch (rmdat & 0x38) { case 0x00: /*INC l*/ @@ -494,7 +494,7 @@ static int opFF_l_a32(uint32_t fetchdat) SEG_CHECK_READ(cpu_state.ea_seg); new_pc = readmeml(easeg, cpu_state.eaaddr); new_cs = readmemw(easeg, (cpu_state.eaaddr + 4)); if (cpu_state.abrt) return 1; - + CALL_FAR_l(new_cs, new_pc); CPU_BLOCK_END(); PREFETCH_RUN(cycles_old-cycles, 2, rmdat, 1,1,cgate16 ? 2:0,cgate16 ? 0:2, 1); diff --git a/src/cpu/x86_ops_flag.h b/src/cpu/x86_ops_flag.h index b5e16ee0e..24c97339e 100644 --- a/src/cpu/x86_ops_flag.h +++ b/src/cpu/x86_ops_flag.h @@ -27,7 +27,7 @@ static int opCLI(uint32_t fetchdat) { if (!IOPLp) { - if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) || + if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) || ((cpu_state.eflags & VM_FLAG) && (cr4 & CR4_VME))) { cpu_state.eflags &= ~VIF_FLAG; @@ -40,7 +40,7 @@ static int opCLI(uint32_t fetchdat) } else cpu_state.flags &= ~I_FLAG; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 1, -1, 0,0,0,0, 0); return 0; @@ -65,7 +65,7 @@ static int opSTI(uint32_t fetchdat) { if (!IOPLp) { - if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) || + if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) || ((cpu_state.eflags & VM_FLAG) && (cr4 & CR4_VME))) { if (cpu_state.eflags & VIP_FLAG) @@ -100,7 +100,7 @@ static int opSAHF(uint32_t fetchdat) cpu_state.flags = (cpu_state.flags & 0xff00) | (AH & 0xd5) | 2; CLOCK_CYCLES(3); PREFETCH_RUN(3, 1, -1, 0,0,0,0, 0); - + #if (defined(USE_DYNAREC) && defined(USE_NEW_DYNAREC)) codegen_flags_changed = 0; #endif @@ -166,13 +166,13 @@ static int opPUSHFD(uint32_t fetchdat) static int opPOPF_286(uint32_t fetchdat) { uint16_t tempw; - + if ((cpu_state.eflags & VM_FLAG) && (IOPL < 3)) { x86gpf(NULL, 0); return 1; } - + tempw = POP_W(); if (cpu_state.abrt) return 1; if (!(msw & 1)) cpu_state.flags = (cpu_state.flags & 0x7000) | (tempw & 0x0fd5) | 2; @@ -183,7 +183,7 @@ static int opPOPF_286(uint32_t fetchdat) CLOCK_CYCLES(5); PREFETCH_RUN(5, 1, -1, 1,0,0,0, 0); - + #if (defined(USE_DYNAREC) && defined(USE_NEW_DYNAREC)) codegen_flags_changed = 0; #endif @@ -193,7 +193,7 @@ static int opPOPF_286(uint32_t fetchdat) static int opPOPF(uint32_t fetchdat) { uint16_t tempw; - + if ((cpu_state.eflags & VM_FLAG) && (IOPL < 3)) { if (cr4 & CR4_VME) @@ -227,7 +227,7 @@ static int opPOPF(uint32_t fetchdat) } } else - { + { tempw = POP_W(); if (cpu_state.abrt) return 1; @@ -243,7 +243,7 @@ static int opPOPF(uint32_t fetchdat) CLOCK_CYCLES(5); PREFETCH_RUN(5, 1, -1, 1,0,0,0, 0); - + #if (defined(USE_DYNAREC) && defined(USE_NEW_DYNAREC)) codegen_flags_changed = 0; #endif @@ -253,31 +253,31 @@ static int opPOPF(uint32_t fetchdat) static int opPOPFD(uint32_t fetchdat) { uint32_t templ; - + if ((cpu_state.eflags & VM_FLAG) && (IOPL < 3)) { x86gpf(NULL, 0); return 1; } - + templ = POP_L(); if (cpu_state.abrt) return 1; if (!(CPL) || !(msw & 1)) cpu_state.flags = (templ & 0x7fd5) | 2; else if (IOPLp) cpu_state.flags = (cpu_state.flags & 0x3000) | (templ & 0x4fd5) | 2; else cpu_state.flags = (cpu_state.flags & 0x3200) | (templ & 0x4dd5) | 2; - + templ &= (is486 || isibm486) ? 0x3c0000 : 0; templ |= ((cpu_state.eflags&3) << 16); if (cpu_CR4_mask & CR4_VME) cpu_state.eflags = (templ >> 16) & 0x3f; else if (CPUID) cpu_state.eflags = (templ >> 16) & 0x27; else if (is486 || isibm486) cpu_state.eflags = (templ >> 16) & 7; else cpu_state.eflags = (templ >> 16) & 3; - + flags_extract(); CLOCK_CYCLES(5); PREFETCH_RUN(5, 1, -1, 0,1,0,0, 0); - + #if (defined(USE_DYNAREC) && defined(USE_NEW_DYNAREC)) codegen_flags_changed = 0; #endif diff --git a/src/cpu/x86_ops_inc_dec.h b/src/cpu/x86_ops_inc_dec.h index ff4a4ab73..682662851 100644 --- a/src/cpu/x86_ops_inc_dec.h +++ b/src/cpu/x86_ops_inc_dec.h @@ -48,7 +48,7 @@ INC_DEC_OP(DEC_ESP, ESP, -1, setsub32nc) static int opINCDEC_b_a16(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -71,7 +71,7 @@ static int opINCDEC_b_a16(uint32_t fetchdat) static int opINCDEC_b_a32(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); diff --git a/src/cpu/x86_ops_int.h b/src/cpu/x86_ops_int.h index 4e18e6f4b..f35e526a6 100644 --- a/src/cpu/x86_ops_int.h +++ b/src/cpu/x86_ops_int.h @@ -71,7 +71,7 @@ static int opINT(uint32_t fetchdat) static int opINTO(uint32_t fetchdat) { int cycles_old = cycles; UN_USED(cycles_old); - + if ((cr0 & 1) && (cpu_state.eflags & VM_FLAG) && (IOPL != 3)) { x86gpf(NULL,0); @@ -88,4 +88,3 @@ static int opINTO(uint32_t fetchdat) PREFETCH_RUN(3, 1, -1, 0,0,0,0, 0); return 0; } - diff --git a/src/cpu/x86_ops_io.h b/src/cpu/x86_ops_io.h index 9fa91a215..50d7d94d1 100644 --- a/src/cpu/x86_ops_io.h +++ b/src/cpu/x86_ops_io.h @@ -1,5 +1,5 @@ static int opIN_AL_imm(uint32_t fetchdat) -{ +{ uint16_t port = (uint16_t)getbytef(); check_io_perm(port); AL = inb(port); @@ -38,7 +38,7 @@ static int opIN_EAX_imm(uint32_t fetchdat) static int opOUT_AL_imm(uint32_t fetchdat) { - uint16_t port = (uint16_t)getbytef(); + uint16_t port = (uint16_t)getbytef(); check_io_perm(port); outb(port, AL); CLOCK_CYCLES(10); @@ -51,7 +51,7 @@ static int opOUT_AL_imm(uint32_t fetchdat) } static int opOUT_AX_imm(uint32_t fetchdat) { - uint16_t port = (uint16_t)getbytef(); + uint16_t port = (uint16_t)getbytef(); check_io_perm(port); check_io_perm(port + 1); outw(port, AX); @@ -63,7 +63,7 @@ static int opOUT_AX_imm(uint32_t fetchdat) } static int opOUT_EAX_imm(uint32_t fetchdat) { - uint16_t port = (uint16_t)getbytef(); + uint16_t port = (uint16_t)getbytef(); check_io_perm(port); check_io_perm(port + 1); check_io_perm(port + 2); @@ -77,7 +77,7 @@ static int opOUT_EAX_imm(uint32_t fetchdat) } static int opIN_AL_DX(uint32_t fetchdat) -{ +{ check_io_perm(DX); AL = inb(DX); CLOCK_CYCLES(12); diff --git a/src/cpu/x86_ops_jump.h b/src/cpu/x86_ops_jump.h index c227939a3..7f9df37d7 100644 --- a/src/cpu/x86_ops_jump.h +++ b/src/cpu/x86_ops_jump.h @@ -69,7 +69,7 @@ PREFETCH_RUN(timing_bnt, 5, -1, 0,0,0,0, 0); \ return 0; \ } \ - + opJ(O) opJ(NO) opJ(B) @@ -112,7 +112,7 @@ static int opLOOPNE_l(uint32_t fetchdat) ECX--; CLOCK_CYCLES((is486) ? 7 : 11); PREFETCH_RUN(11, 2, -1, 0,0,0,0, 0); - if (ECX && !ZF_SET()) + if (ECX && !ZF_SET()) { cpu_state.pc += offset; if (!(cpu_state.op32 & 0x100)) @@ -309,7 +309,7 @@ static int opCALL_r16(uint32_t fetchdat) } static int opCALL_r32(uint32_t fetchdat) { - int32_t addr = getlong(); if (cpu_state.abrt) return 1; + int32_t addr = getlong(); if (cpu_state.abrt) return 1; PUSH_L(cpu_state.pc); cpu_state.pc += addr; CPU_BLOCK_END(); @@ -322,11 +322,11 @@ static int opCALL_r32(uint32_t fetchdat) static int opRET_w(uint32_t fetchdat) { uint16_t ret; - + ret = POP_W(); if (cpu_state.abrt) return 1; cpu_state.pc = ret; CPU_BLOCK_END(); - + CLOCK_CYCLES((is486) ? 5 : 10); PREFETCH_RUN(10, 1, -1, 1,0,0,0, 0); PREFETCH_FLUSH(); @@ -339,7 +339,7 @@ static int opRET_l(uint32_t fetchdat) ret = POP_L(); if (cpu_state.abrt) return 1; cpu_state.pc = ret; CPU_BLOCK_END(); - + CLOCK_CYCLES((is486) ? 5 : 10); PREFETCH_RUN(10, 1, -1, 0,1,0,0, 0); PREFETCH_FLUSH(); @@ -353,10 +353,10 @@ static int opRET_w_imm(uint32_t fetchdat) ret = POP_W(); if (cpu_state.abrt) return 1; if (stack32) ESP += offset; - else SP += offset; + else SP += offset; cpu_state.pc = ret; CPU_BLOCK_END(); - + CLOCK_CYCLES((is486) ? 5 : 10); PREFETCH_RUN(10, 5, -1, 1,0,0,0, 0); PREFETCH_FLUSH(); @@ -369,13 +369,12 @@ static int opRET_l_imm(uint32_t fetchdat) ret = POP_L(); if (cpu_state.abrt) return 1; if (stack32) ESP += offset; - else SP += offset; + else SP += offset; cpu_state.pc = ret; CPU_BLOCK_END(); - + CLOCK_CYCLES((is486) ? 5 : 10); PREFETCH_RUN(10, 5, -1, 0,1,0,0, 0); PREFETCH_FLUSH(); return 0; } - diff --git a/src/cpu/x86_ops_misc.h b/src/cpu/x86_ops_misc.h index a6e7e9193..50da6f2a0 100644 --- a/src/cpu/x86_ops_misc.h +++ b/src/cpu/x86_ops_misc.h @@ -50,7 +50,7 @@ static int opF6_a16(uint32_t fetchdat) uint16_t tempw, src16; uint8_t src, dst; int8_t temps; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) { SEG_CHECK_READ(cpu_state.ea_seg); @@ -106,7 +106,7 @@ static int opF6_a16(uint32_t fetchdat) { AH = src16 % dst; AL = (src16 / dst) &0xff; - if (!cpu_iscyrix) + if (!cpu_iscyrix) { flags_rebuild(); cpu_state.flags |= 0x8D5; /*Not a Cyrix*/ @@ -129,7 +129,7 @@ static int opF6_a16(uint32_t fetchdat) { AH = (tempws % (int)((int8_t)dst)) & 0xff; AL = tempws2 & 0xff; - if (!cpu_iscyrix) + if (!cpu_iscyrix) { flags_rebuild(); cpu_state.flags|=0x8D5; /*Not a Cyrix*/ @@ -156,7 +156,7 @@ static int opF6_a32(uint32_t fetchdat) uint16_t tempw, src16; uint8_t src, dst; int8_t temps; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); @@ -210,7 +210,7 @@ static int opF6_a32(uint32_t fetchdat) { AH = src16 % dst; AL = (src16 / dst) &0xff; - if (!cpu_iscyrix) + if (!cpu_iscyrix) { flags_rebuild(); cpu_state.flags |= 0x8D5; /*Not a Cyrix*/ @@ -233,7 +233,7 @@ static int opF6_a32(uint32_t fetchdat) { AH = (tempws % (int)((int8_t)dst)) & 0xff; AL = tempws2 & 0xff; - if (!cpu_iscyrix) + if (!cpu_iscyrix) { flags_rebuild(); cpu_state.flags |= 0x8D5; /*Not a Cyrix*/ @@ -263,7 +263,7 @@ static int opF7_w_a16(uint32_t fetchdat) int tempws, tempws2 = 0; int16_t temps16; uint16_t src, dst; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); @@ -320,7 +320,7 @@ static int opF7_w_a16(uint32_t fetchdat) { DX = templ % dst; AX = (templ / dst) & 0xffff; - if (!cpu_iscyrix) setznp16(AX); /*Not a Cyrix*/ + if (!cpu_iscyrix) setznp16(AX); /*Not a Cyrix*/ } else { @@ -417,7 +417,7 @@ static int opF7_w_a32(uint32_t fetchdat) { DX = templ % dst; AX = (templ / dst) & 0xffff; - if (!cpu_iscyrix) setznp16(AX); /*Not a Cyrix*/ + if (!cpu_iscyrix) setznp16(AX); /*Not a Cyrix*/ } else { @@ -639,7 +639,7 @@ static int opLOCK(uint32_t fetchdat) fetchdat = fastreadl(cs + cpu_state.pc); if (cpu_state.abrt) return 0; cpu_state.pc++; - + ILLEGAL_ON((fetchdat & 0xff) == 0x90); CLOCK_CYCLES(4); @@ -650,82 +650,82 @@ static int opLOCK(uint32_t fetchdat) static int opBOUND_w_a16(uint32_t fetchdat) -{ +{ int16_t low, high; - + fetch_ea_16(fetchdat); ILLEGAL_ON(cpu_mod == 3); SEG_CHECK_READ(cpu_state.ea_seg); low = geteaw(); high = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; - + if (((int16_t)cpu_state.regs[cpu_reg].w < low) || ((int16_t)cpu_state.regs[cpu_reg].w > high)) { x86_int(5); return 1; } - + CLOCK_CYCLES(is486 ? 7 : 10); PREFETCH_RUN(is486 ? 7 : 10, 2, rmdat, 2,0,0,0, 0); return 0; } static int opBOUND_w_a32(uint32_t fetchdat) -{ +{ int16_t low, high; - + fetch_ea_32(fetchdat); ILLEGAL_ON(cpu_mod == 3); SEG_CHECK_READ(cpu_state.ea_seg); low = geteaw(); high = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; - + if (((int16_t)cpu_state.regs[cpu_reg].w < low) || ((int16_t)cpu_state.regs[cpu_reg].w > high)) { x86_int(5); return 1; } - + CLOCK_CYCLES(is486 ? 7 : 10); PREFETCH_RUN(is486 ? 7 : 10, 2, rmdat, 2,0,0,0, 1); return 0; } static int opBOUND_l_a16(uint32_t fetchdat) -{ +{ int32_t low, high; - + fetch_ea_16(fetchdat); ILLEGAL_ON(cpu_mod == 3); SEG_CHECK_READ(cpu_state.ea_seg); low = geteal(); high = readmeml(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; - + if (((int32_t)cpu_state.regs[cpu_reg].l < low) || ((int32_t)cpu_state.regs[cpu_reg].l > high)) { x86_int(5); return 1; } - + CLOCK_CYCLES(is486 ? 7 : 10); PREFETCH_RUN(is486 ? 7 : 10, 2, rmdat, 1,1,0,0, 0); return 0; } static int opBOUND_l_a32(uint32_t fetchdat) -{ +{ int32_t low, high; - + fetch_ea_32(fetchdat); ILLEGAL_ON(cpu_mod == 3); SEG_CHECK_READ(cpu_state.ea_seg); low = geteal(); high = readmeml(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; - + if (((int32_t)cpu_state.regs[cpu_reg].l < low) || ((int32_t)cpu_state.regs[cpu_reg].l > high)) { x86_int(5); return 1; } - + CLOCK_CYCLES(is486 ? 7 : 10); PREFETCH_RUN(is486 ? 7 : 10, 2, rmdat, 1,1,0,0, 1); return 0; @@ -816,7 +816,7 @@ static int opLOADALL(uint32_t fetchdat) CLOCK_CYCLES(195); PREFETCH_RUN(195, 1, -1, 51,0,0,0, 0); return 0; -} +} static void set_segment_limit(x86seg *s, uint8_t segdat3) { @@ -845,7 +845,7 @@ static void loadall_load_segment(uint32_t addr, x86seg *s) use32 = (segdat3 & 0x40) ? 0x300 : 0; if (s == &cpu_state.seg_ss) stack32 = (segdat3 & 0x40) ? 1 : 0; - + cpu_cur_status &= ~(CPU_STATUS_USE32 | CPU_STATUS_STACK32); if (use32) cpu_cur_status |= CPU_STATUS_USE32; @@ -914,7 +914,7 @@ static int opLOADALL386(uint32_t fetchdat) CLOCK_CYCLES(350); return 0; -} +} static int opCPUID(uint32_t fetchdat) { @@ -968,4 +968,4 @@ static int opRSM(uint32_t fetchdat) cpu_state.pc = cpu_state.oldpc; x86illegal(); return 1; -} \ No newline at end of file +} diff --git a/src/cpu/x86_ops_mmx_arith.h b/src/cpu/x86_ops_mmx_arith.h index 3b9e2066c..afa8aa383 100644 --- a/src/cpu/x86_ops_mmx_arith.h +++ b/src/cpu/x86_ops_mmx_arith.h @@ -2,10 +2,10 @@ static int opPADDB_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] += src.b[0]; cpu_state.MM[cpu_reg].b[1] += src.b[1]; cpu_state.MM[cpu_reg].b[2] += src.b[2]; @@ -21,10 +21,10 @@ static int opPADDB_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] += src.b[0]; cpu_state.MM[cpu_reg].b[1] += src.b[1]; cpu_state.MM[cpu_reg].b[2] += src.b[2]; @@ -41,10 +41,10 @@ static int opPADDW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] += src.w[0]; cpu_state.MM[cpu_reg].w[1] += src.w[1]; cpu_state.MM[cpu_reg].w[2] += src.w[2]; @@ -56,10 +56,10 @@ static int opPADDW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] += src.w[0]; cpu_state.MM[cpu_reg].w[1] += src.w[1]; cpu_state.MM[cpu_reg].w[2] += src.w[2]; @@ -72,10 +72,10 @@ static int opPADDD_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].l[0] += src.l[0]; cpu_state.MM[cpu_reg].l[1] += src.l[1]; @@ -85,7 +85,7 @@ static int opPADDD_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -99,10 +99,10 @@ static int opPADDSB_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].sb[0] = SSATB(cpu_state.MM[cpu_reg].sb[0] + src.sb[0]); cpu_state.MM[cpu_reg].sb[1] = SSATB(cpu_state.MM[cpu_reg].sb[1] + src.sb[1]); cpu_state.MM[cpu_reg].sb[2] = SSATB(cpu_state.MM[cpu_reg].sb[2] + src.sb[2]); @@ -118,7 +118,7 @@ static int opPADDSB_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -138,10 +138,10 @@ static int opPADDUSB_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] = USATB(cpu_state.MM[cpu_reg].b[0] + src.b[0]); cpu_state.MM[cpu_reg].b[1] = USATB(cpu_state.MM[cpu_reg].b[1] + src.b[1]); cpu_state.MM[cpu_reg].b[2] = USATB(cpu_state.MM[cpu_reg].b[2] + src.b[2]); @@ -157,10 +157,10 @@ static int opPADDUSB_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] = USATB(cpu_state.MM[cpu_reg].b[0] + src.b[0]); cpu_state.MM[cpu_reg].b[1] = USATB(cpu_state.MM[cpu_reg].b[1] + src.b[1]); cpu_state.MM[cpu_reg].b[2] = USATB(cpu_state.MM[cpu_reg].b[2] + src.b[2]); @@ -177,10 +177,10 @@ static int opPADDSW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].sw[0] = SSATW(cpu_state.MM[cpu_reg].sw[0] + src.sw[0]); cpu_state.MM[cpu_reg].sw[1] = SSATW(cpu_state.MM[cpu_reg].sw[1] + src.sw[1]); cpu_state.MM[cpu_reg].sw[2] = SSATW(cpu_state.MM[cpu_reg].sw[2] + src.sw[2]); @@ -192,7 +192,7 @@ static int opPADDSW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -208,10 +208,10 @@ static int opPADDUSW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] = USATW(cpu_state.MM[cpu_reg].w[0] + src.w[0]); cpu_state.MM[cpu_reg].w[1] = USATW(cpu_state.MM[cpu_reg].w[1] + src.w[1]); cpu_state.MM[cpu_reg].w[2] = USATW(cpu_state.MM[cpu_reg].w[2] + src.w[2]); @@ -223,10 +223,10 @@ static int opPADDUSW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] = USATW(cpu_state.MM[cpu_reg].w[0] + src.w[0]); cpu_state.MM[cpu_reg].w[1] = USATW(cpu_state.MM[cpu_reg].w[1] + src.w[1]); cpu_state.MM[cpu_reg].w[2] = USATW(cpu_state.MM[cpu_reg].w[2] + src.w[2]); @@ -239,7 +239,7 @@ static int opPMADDWD_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -252,14 +252,14 @@ static int opPMADDWD_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].l[1] = 0x80000000; else cpu_state.MM[cpu_reg].sl[1] = ((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)src.sw[2]) + ((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)src.sw[3]); - + return 0; } static int opPMADDWD_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -272,7 +272,7 @@ static int opPMADDWD_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].l[1] = 0x80000000; else cpu_state.MM[cpu_reg].sl[1] = ((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)src.sw[2]) + ((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)src.sw[3]); - + return 0; } @@ -280,7 +280,7 @@ static int opPMADDWD_a32(uint32_t fetchdat) static int opPMULLW_a16(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_16(fetchdat); if (cpu_mod == 3) { @@ -308,7 +308,7 @@ static int opPMULLW_a16(uint32_t fetchdat) static int opPMULLW_a32(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_32(fetchdat); if (cpu_mod == 3) { @@ -321,7 +321,7 @@ static int opPMULLW_a32(uint32_t fetchdat) else { MMX_REG src; - + SEG_CHECK_READ(cpu_state.ea_seg); src.l[0] = readmeml(easeg, cpu_state.eaaddr); src.l[1] = readmeml(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 0; @@ -337,7 +337,7 @@ static int opPMULLW_a32(uint32_t fetchdat) static int opPMULHW_a16(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_16(fetchdat); if (cpu_mod == 3) { @@ -350,7 +350,7 @@ static int opPMULHW_a16(uint32_t fetchdat) else { MMX_REG src; - + SEG_CHECK_READ(cpu_state.ea_seg); src.l[0] = readmeml(easeg, cpu_state.eaaddr); src.l[1] = readmeml(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 0; @@ -365,7 +365,7 @@ static int opPMULHW_a16(uint32_t fetchdat) static int opPMULHW_a32(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_32(fetchdat); if (cpu_mod == 3) { @@ -378,7 +378,7 @@ static int opPMULHW_a32(uint32_t fetchdat) else { MMX_REG src; - + SEG_CHECK_READ(cpu_state.ea_seg); src.l[0] = readmeml(easeg, cpu_state.eaaddr); src.l[1] = readmeml(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 0; @@ -395,10 +395,10 @@ static int opPSUBB_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] -= src.b[0]; cpu_state.MM[cpu_reg].b[1] -= src.b[1]; cpu_state.MM[cpu_reg].b[2] -= src.b[2]; @@ -414,10 +414,10 @@ static int opPSUBB_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] -= src.b[0]; cpu_state.MM[cpu_reg].b[1] -= src.b[1]; cpu_state.MM[cpu_reg].b[2] -= src.b[2]; @@ -434,10 +434,10 @@ static int opPSUBW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] -= src.w[0]; cpu_state.MM[cpu_reg].w[1] -= src.w[1]; cpu_state.MM[cpu_reg].w[2] -= src.w[2]; @@ -449,10 +449,10 @@ static int opPSUBW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] -= src.w[0]; cpu_state.MM[cpu_reg].w[1] -= src.w[1]; cpu_state.MM[cpu_reg].w[2] -= src.w[2]; @@ -465,10 +465,10 @@ static int opPSUBD_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].l[0] -= src.l[0]; cpu_state.MM[cpu_reg].l[1] -= src.l[1]; @@ -478,10 +478,10 @@ static int opPSUBD_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].l[0] -= src.l[0]; cpu_state.MM[cpu_reg].l[1] -= src.l[1]; @@ -493,10 +493,10 @@ static int opPSUBSB_a16(uint32_t fetchdat) MMX_REG src; pclog("opPSUBSB_a16(%08X)\n", fetchdat); MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].sb[0] = SSATB(cpu_state.MM[cpu_reg].sb[0] - src.sb[0]); cpu_state.MM[cpu_reg].sb[1] = SSATB(cpu_state.MM[cpu_reg].sb[1] - src.sb[1]); cpu_state.MM[cpu_reg].sb[2] = SSATB(cpu_state.MM[cpu_reg].sb[2] - src.sb[2]); @@ -513,10 +513,10 @@ static int opPSUBSB_a32(uint32_t fetchdat) MMX_REG src; pclog("opPSUBSB_a32(%08X)\n", fetchdat); MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].sb[0] = SSATB(cpu_state.MM[cpu_reg].sb[0] - src.sb[0]); cpu_state.MM[cpu_reg].sb[1] = SSATB(cpu_state.MM[cpu_reg].sb[1] - src.sb[1]); cpu_state.MM[cpu_reg].sb[2] = SSATB(cpu_state.MM[cpu_reg].sb[2] - src.sb[2]); @@ -533,10 +533,10 @@ static int opPSUBUSB_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] = USATB(cpu_state.MM[cpu_reg].b[0] - src.b[0]); cpu_state.MM[cpu_reg].b[1] = USATB(cpu_state.MM[cpu_reg].b[1] - src.b[1]); cpu_state.MM[cpu_reg].b[2] = USATB(cpu_state.MM[cpu_reg].b[2] - src.b[2]); @@ -552,10 +552,10 @@ static int opPSUBUSB_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].b[0] = USATB(cpu_state.MM[cpu_reg].b[0] - src.b[0]); cpu_state.MM[cpu_reg].b[1] = USATB(cpu_state.MM[cpu_reg].b[1] - src.b[1]); cpu_state.MM[cpu_reg].b[2] = USATB(cpu_state.MM[cpu_reg].b[2] - src.b[2]); @@ -572,10 +572,10 @@ static int opPSUBSW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].sw[0] = SSATW(cpu_state.MM[cpu_reg].sw[0] - src.sw[0]); cpu_state.MM[cpu_reg].sw[1] = SSATW(cpu_state.MM[cpu_reg].sw[1] - src.sw[1]); cpu_state.MM[cpu_reg].sw[2] = SSATW(cpu_state.MM[cpu_reg].sw[2] - src.sw[2]); @@ -587,10 +587,10 @@ static int opPSUBSW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].sw[0] = SSATW(cpu_state.MM[cpu_reg].sw[0] - src.sw[0]); cpu_state.MM[cpu_reg].sw[1] = SSATW(cpu_state.MM[cpu_reg].sw[1] - src.sw[1]); cpu_state.MM[cpu_reg].sw[2] = SSATW(cpu_state.MM[cpu_reg].sw[2] - src.sw[2]); @@ -603,10 +603,10 @@ static int opPSUBUSW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] = USATW(cpu_state.MM[cpu_reg].w[0] - src.w[0]); cpu_state.MM[cpu_reg].w[1] = USATW(cpu_state.MM[cpu_reg].w[1] - src.w[1]); cpu_state.MM[cpu_reg].w[2] = USATW(cpu_state.MM[cpu_reg].w[2] - src.w[2]); @@ -618,10 +618,10 @@ static int opPSUBUSW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].w[0] = USATW(cpu_state.MM[cpu_reg].w[0] - src.w[0]); cpu_state.MM[cpu_reg].w[1] = USATW(cpu_state.MM[cpu_reg].w[1] - src.w[1]); cpu_state.MM[cpu_reg].w[2] = USATW(cpu_state.MM[cpu_reg].w[2] - src.w[2]); diff --git a/src/cpu/x86_ops_mmx_cmp.h b/src/cpu/x86_ops_mmx_cmp.h index 0fee95923..a07d8d0a8 100644 --- a/src/cpu/x86_ops_mmx_cmp.h +++ b/src/cpu/x86_ops_mmx_cmp.h @@ -1,9 +1,9 @@ static int opPCMPEQB_a16(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -15,15 +15,15 @@ static int opPCMPEQB_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].b[5] = (cpu_state.MM[cpu_reg].b[5] == src.b[5]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[6] = (cpu_state.MM[cpu_reg].b[6] == src.b[6]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[7] = (cpu_state.MM[cpu_reg].b[7] == src.b[7]) ? 0xff : 0; - + return 0; } static int opPCMPEQB_a32(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -35,16 +35,16 @@ static int opPCMPEQB_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].b[5] = (cpu_state.MM[cpu_reg].b[5] == src.b[5]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[6] = (cpu_state.MM[cpu_reg].b[6] == src.b[6]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[7] = (cpu_state.MM[cpu_reg].b[7] == src.b[7]) ? 0xff : 0; - + return 0; } static int opPCMPGTB_a16(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -56,15 +56,15 @@ static int opPCMPGTB_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].b[5] = (cpu_state.MM[cpu_reg].sb[5] > src.sb[5]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[6] = (cpu_state.MM[cpu_reg].sb[6] > src.sb[6]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[7] = (cpu_state.MM[cpu_reg].sb[7] > src.sb[7]) ? 0xff : 0; - + return 0; } static int opPCMPGTB_a32(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -76,16 +76,16 @@ static int opPCMPGTB_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].b[5] = (cpu_state.MM[cpu_reg].sb[5] > src.sb[5]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[6] = (cpu_state.MM[cpu_reg].sb[6] > src.sb[6]) ? 0xff : 0; cpu_state.MM[cpu_reg].b[7] = (cpu_state.MM[cpu_reg].sb[7] > src.sb[7]) ? 0xff : 0; - + return 0; } static int opPCMPEQW_a16(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -93,15 +93,15 @@ static int opPCMPEQW_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].w[1] = (cpu_state.MM[cpu_reg].w[1] == src.w[1]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[2] = (cpu_state.MM[cpu_reg].w[2] == src.w[2]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[3] = (cpu_state.MM[cpu_reg].w[3] == src.w[3]) ? 0xffff : 0; - + return 0; } static int opPCMPEQW_a32(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -109,16 +109,16 @@ static int opPCMPEQW_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].w[1] = (cpu_state.MM[cpu_reg].w[1] == src.w[1]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[2] = (cpu_state.MM[cpu_reg].w[2] == src.w[2]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[3] = (cpu_state.MM[cpu_reg].w[3] == src.w[3]) ? 0xffff : 0; - + return 0; } static int opPCMPGTW_a16(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -126,15 +126,15 @@ static int opPCMPGTW_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].w[1] = (cpu_state.MM[cpu_reg].sw[1] > src.sw[1]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[2] = (cpu_state.MM[cpu_reg].sw[2] > src.sw[2]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[3] = (cpu_state.MM[cpu_reg].sw[3] > src.sw[3]) ? 0xffff : 0; - + return 0; } static int opPCMPGTW_a32(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -142,64 +142,64 @@ static int opPCMPGTW_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].w[1] = (cpu_state.MM[cpu_reg].sw[1] > src.sw[1]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[2] = (cpu_state.MM[cpu_reg].sw[2] > src.sw[2]) ? 0xffff : 0; cpu_state.MM[cpu_reg].w[3] = (cpu_state.MM[cpu_reg].sw[3] > src.sw[3]) ? 0xffff : 0; - + return 0; } static int opPCMPEQD_a16(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); cpu_state.MM[cpu_reg].l[0] = (cpu_state.MM[cpu_reg].l[0] == src.l[0]) ? 0xffffffff : 0; cpu_state.MM[cpu_reg].l[1] = (cpu_state.MM[cpu_reg].l[1] == src.l[1]) ? 0xffffffff : 0; - + return 0; } static int opPCMPEQD_a32(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); cpu_state.MM[cpu_reg].l[0] = (cpu_state.MM[cpu_reg].l[0] == src.l[0]) ? 0xffffffff : 0; cpu_state.MM[cpu_reg].l[1] = (cpu_state.MM[cpu_reg].l[1] == src.l[1]) ? 0xffffffff : 0; - + return 0; } static int opPCMPGTD_a16(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); cpu_state.MM[cpu_reg].l[0] = (cpu_state.MM[cpu_reg].sl[0] > src.sl[0]) ? 0xffffffff : 0; cpu_state.MM[cpu_reg].l[1] = (cpu_state.MM[cpu_reg].sl[1] > src.sl[1]) ? 0xffffffff : 0; - + return 0; } static int opPCMPGTD_a32(uint32_t fetchdat) { MMX_REG src; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); cpu_state.MM[cpu_reg].l[0] = (cpu_state.MM[cpu_reg].sl[0] > src.sl[0]) ? 0xffffffff : 0; cpu_state.MM[cpu_reg].l[1] = (cpu_state.MM[cpu_reg].sl[1] > src.sl[1]) ? 0xffffffff : 0; - + return 0; } diff --git a/src/cpu/x86_ops_mmx_logic.h b/src/cpu/x86_ops_mmx_logic.h index be5132e85..e3f1d9145 100644 --- a/src/cpu/x86_ops_mmx_logic.h +++ b/src/cpu/x86_ops_mmx_logic.h @@ -2,10 +2,10 @@ static int opPAND_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q &= src.q; return 0; } @@ -13,10 +13,10 @@ static int opPAND_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q &= src.q; return 0; } @@ -25,10 +25,10 @@ static int opPANDN_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q = ~cpu_state.MM[cpu_reg].q & src.q; return 0; } @@ -36,10 +36,10 @@ static int opPANDN_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q = ~cpu_state.MM[cpu_reg].q & src.q; return 0; } @@ -48,10 +48,10 @@ static int opPOR_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q |= src.q; return 0; } @@ -59,10 +59,10 @@ static int opPOR_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q |= src.q; return 0; } @@ -71,10 +71,10 @@ static int opPXOR_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q ^= src.q; return 0; } @@ -82,10 +82,10 @@ static int opPXOR_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].q ^= src.q; return 0; } diff --git a/src/cpu/x86_ops_mmx_mov.h b/src/cpu/x86_ops_mmx_mov.h index 07d21d418..fe06525b7 100644 --- a/src/cpu/x86_ops_mmx_mov.h +++ b/src/cpu/x86_ops_mmx_mov.h @@ -1,7 +1,7 @@ static int opMOVD_l_mm_a16(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_16(fetchdat); if (cpu_mod == 3) { @@ -25,7 +25,7 @@ static int opMOVD_l_mm_a16(uint32_t fetchdat) static int opMOVD_l_mm_a32(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_32(fetchdat); if (cpu_mod == 3) { @@ -116,7 +116,7 @@ static int opMOVD_mm_l_a32_cx(uint32_t fetchdat) return opSMINT(fetchdat); MMX_ENTER(); - + fetch_ea_32(fetchdat); if (cpu_mod == 3) { @@ -137,7 +137,7 @@ static int opMOVD_mm_l_a32_cx(uint32_t fetchdat) static int opMOVQ_q_mm_a16(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_16(fetchdat); if (cpu_mod == 3) { @@ -147,7 +147,7 @@ static int opMOVQ_q_mm_a16(uint32_t fetchdat) else { uint64_t dst; - + SEG_CHECK_READ(cpu_state.ea_seg); dst = readmemq(easeg, cpu_state.eaaddr); if (cpu_state.abrt) return 1; cpu_state.MM[cpu_reg].q = dst; @@ -158,7 +158,7 @@ static int opMOVQ_q_mm_a16(uint32_t fetchdat) static int opMOVQ_q_mm_a32(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_32(fetchdat); if (cpu_mod == 3) { @@ -168,7 +168,7 @@ static int opMOVQ_q_mm_a32(uint32_t fetchdat) else { uint64_t dst; - + SEG_CHECK_READ(cpu_state.ea_seg); dst = readmemq(easeg, cpu_state.eaaddr); if (cpu_state.abrt) return 1; cpu_state.MM[cpu_reg].q = dst; @@ -180,7 +180,7 @@ static int opMOVQ_q_mm_a32(uint32_t fetchdat) static int opMOVQ_mm_q_a16(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_16(fetchdat); if (cpu_mod == 3) { @@ -199,7 +199,7 @@ static int opMOVQ_mm_q_a16(uint32_t fetchdat) static int opMOVQ_mm_q_a32(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_32(fetchdat); if (cpu_mod == 3) { diff --git a/src/cpu/x86_ops_mmx_pack.h b/src/cpu/x86_ops_mmx_pack.h index b03ef842e..e12d1b448 100644 --- a/src/cpu/x86_ops_mmx_pack.h +++ b/src/cpu/x86_ops_mmx_pack.h @@ -1,7 +1,7 @@ static int opPUNPCKLDQ_a16(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_16(fetchdat); if (cpu_mod == 3) { @@ -11,7 +11,7 @@ static int opPUNPCKLDQ_a16(uint32_t fetchdat) else { uint32_t src; - + SEG_CHECK_READ(cpu_state.ea_seg); src = readmeml(easeg, cpu_state.eaaddr); if (cpu_state.abrt) return 0; cpu_state.MM[cpu_reg].l[1] = src; @@ -23,7 +23,7 @@ static int opPUNPCKLDQ_a16(uint32_t fetchdat) static int opPUNPCKLDQ_a32(uint32_t fetchdat) { MMX_ENTER(); - + fetch_ea_32(fetchdat); if (cpu_mod == 3) { @@ -47,10 +47,10 @@ static int opPUNPCKHDQ_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); - + cpu_state.MM[cpu_reg].l[0] = cpu_state.MM[cpu_reg].l[1]; cpu_state.MM[cpu_reg].l[1] = src.l[1]; @@ -60,7 +60,7 @@ static int opPUNPCKHDQ_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -74,7 +74,7 @@ static int opPUNPCKLBW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -93,7 +93,7 @@ static int opPUNPCKLBW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -113,7 +113,7 @@ static int opPUNPCKHBW_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -125,14 +125,14 @@ static int opPUNPCKHBW_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].b[5] = src.b[6]; cpu_state.MM[cpu_reg].b[6] = cpu_state.MM[cpu_reg].b[7]; cpu_state.MM[cpu_reg].b[7] = src.b[7]; - + return 0; } static int opPUNPCKHBW_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -144,7 +144,7 @@ static int opPUNPCKHBW_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].b[5] = src.b[6]; cpu_state.MM[cpu_reg].b[6] = cpu_state.MM[cpu_reg].b[7]; cpu_state.MM[cpu_reg].b[7] = src.b[7]; - + return 0; } @@ -152,7 +152,7 @@ static int opPUNPCKLWD_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -167,7 +167,7 @@ static int opPUNPCKLWD_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -183,7 +183,7 @@ static int opPUNPCKHWD_a16(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); @@ -198,7 +198,7 @@ static int opPUNPCKHWD_a32(uint32_t fetchdat) { MMX_REG src; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); @@ -214,7 +214,7 @@ static int opPACKSSWB_a16(uint32_t fetchdat) { MMX_REG src, dst; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); dst = cpu_state.MM[cpu_reg]; @@ -227,14 +227,14 @@ static int opPACKSSWB_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].sb[5] = SSATB(src.sw[1]); cpu_state.MM[cpu_reg].sb[6] = SSATB(src.sw[2]); cpu_state.MM[cpu_reg].sb[7] = SSATB(src.sw[3]); - + return 0; } static int opPACKSSWB_a32(uint32_t fetchdat) { MMX_REG src, dst; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); dst = cpu_state.MM[cpu_reg]; @@ -247,7 +247,7 @@ static int opPACKSSWB_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].sb[5] = SSATB(src.sw[1]); cpu_state.MM[cpu_reg].sb[6] = SSATB(src.sw[2]); cpu_state.MM[cpu_reg].sb[7] = SSATB(src.sw[3]); - + return 0; } @@ -255,7 +255,7 @@ static int opPACKUSWB_a16(uint32_t fetchdat) { MMX_REG src, dst; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); dst = cpu_state.MM[cpu_reg]; @@ -268,14 +268,14 @@ static int opPACKUSWB_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].b[5] = USATB(src.sw[1]); cpu_state.MM[cpu_reg].b[6] = USATB(src.sw[2]); cpu_state.MM[cpu_reg].b[7] = USATB(src.sw[3]); - + return 0; } static int opPACKUSWB_a32(uint32_t fetchdat) { MMX_REG src, dst; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); dst = cpu_state.MM[cpu_reg]; @@ -296,31 +296,31 @@ static int opPACKSSDW_a16(uint32_t fetchdat) { MMX_REG src, dst; MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSRC(); dst = cpu_state.MM[cpu_reg]; - + cpu_state.MM[cpu_reg].sw[0] = SSATW(dst.sl[0]); cpu_state.MM[cpu_reg].sw[1] = SSATW(dst.sl[1]); cpu_state.MM[cpu_reg].sw[2] = SSATW(src.sl[0]); cpu_state.MM[cpu_reg].sw[3] = SSATW(src.sl[1]); - + return 0; } static int opPACKSSDW_a32(uint32_t fetchdat) { MMX_REG src, dst; MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSRC(); dst = cpu_state.MM[cpu_reg]; - + cpu_state.MM[cpu_reg].sw[0] = SSATW(dst.sl[0]); cpu_state.MM[cpu_reg].sw[1] = SSATW(dst.sl[1]); cpu_state.MM[cpu_reg].sw[2] = SSATW(src.sl[0]); cpu_state.MM[cpu_reg].sw[3] = SSATW(src.sl[1]); - + return 0; } diff --git a/src/cpu/x86_ops_mmx_shift.h b/src/cpu/x86_ops_mmx_shift.h index a0a4d90c1..df8d75cf8 100644 --- a/src/cpu/x86_ops_mmx_shift.h +++ b/src/cpu/x86_ops_mmx_shift.h @@ -16,7 +16,7 @@ static int opPSxxW_imm(uint32_t fetchdat) int reg = fetchdat & 7; int op = fetchdat & 0x38; int shift = (fetchdat >> 8) & 0xff; - + cpu_state.pc += 2; MMX_ENTER(); @@ -65,9 +65,9 @@ static int opPSxxW_imm(uint32_t fetchdat) static int opPSLLW_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -86,9 +86,9 @@ static int opPSLLW_a16(uint32_t fetchdat) static int opPSLLW_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); @@ -108,9 +108,9 @@ static int opPSLLW_a32(uint32_t fetchdat) static int opPSRLW_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -129,9 +129,9 @@ static int opPSRLW_a16(uint32_t fetchdat) static int opPSRLW_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); @@ -151,9 +151,9 @@ static int opPSRLW_a32(uint32_t fetchdat) static int opPSRAW_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -164,15 +164,15 @@ static int opPSRAW_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].sw[1] >>= shift; cpu_state.MM[cpu_reg].sw[2] >>= shift; cpu_state.MM[cpu_reg].sw[3] >>= shift; - + return 0; } static int opPSRAW_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); @@ -183,7 +183,7 @@ static int opPSRAW_a32(uint32_t fetchdat) cpu_state.MM[cpu_reg].sw[1] >>= shift; cpu_state.MM[cpu_reg].sw[2] >>= shift; cpu_state.MM[cpu_reg].sw[3] >>= shift; - + return 0; } @@ -192,7 +192,7 @@ static int opPSxxD_imm(uint32_t fetchdat) int reg = fetchdat & 7; int op = fetchdat & 0x38; int shift = (fetchdat >> 8) & 0xff; - + cpu_state.pc += 2; MMX_ENTER(); @@ -235,9 +235,9 @@ static int opPSxxD_imm(uint32_t fetchdat) static int opPSLLD_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -254,9 +254,9 @@ static int opPSLLD_a16(uint32_t fetchdat) static int opPSLLD_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); @@ -274,9 +274,9 @@ static int opPSLLD_a32(uint32_t fetchdat) static int opPSRLD_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -293,9 +293,9 @@ static int opPSRLD_a16(uint32_t fetchdat) static int opPSRLD_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); @@ -313,9 +313,9 @@ static int opPSRLD_a32(uint32_t fetchdat) static int opPSRAD_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -324,15 +324,15 @@ static int opPSRAD_a16(uint32_t fetchdat) cpu_state.MM[cpu_reg].sl[0] >>= shift; cpu_state.MM[cpu_reg].sl[1] >>= shift; - + return 0; } static int opPSRAD_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); @@ -350,7 +350,7 @@ static int opPSxxQ_imm(uint32_t fetchdat) int reg = fetchdat & 7; int op = fetchdat & 0x38; int shift = (fetchdat >> 8) & 0xff; - + cpu_state.pc += 2; MMX_ENTER(); @@ -386,9 +386,9 @@ static int opPSxxQ_imm(uint32_t fetchdat) static int opPSLLQ_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -402,9 +402,9 @@ static int opPSLLQ_a16(uint32_t fetchdat) static int opPSLLQ_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); @@ -419,9 +419,9 @@ static int opPSLLQ_a32(uint32_t fetchdat) static int opPSRLQ_a16(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_16(fetchdat); MMX_GETSHIFT(); @@ -435,9 +435,9 @@ static int opPSRLQ_a16(uint32_t fetchdat) static int opPSRLQ_a32(uint32_t fetchdat) { int shift; - + MMX_ENTER(); - + fetch_ea_32(fetchdat); MMX_GETSHIFT(); diff --git a/src/cpu/x86_ops_mov.h b/src/cpu/x86_ops_mov.h index 8702578b1..e7d5247d1 100644 --- a/src/cpu/x86_ops_mov.h +++ b/src/cpu/x86_ops_mov.h @@ -262,7 +262,7 @@ static int opMOV_AL_a16(uint32_t fetchdat) AL = temp; CLOCK_CYCLES((is486) ? 1 : 4); PREFETCH_RUN(4, 3, -1, 1,0,0,0, 0); - return 0; + return 0; } static int opMOV_AL_a32(uint32_t fetchdat) { @@ -274,7 +274,7 @@ static int opMOV_AL_a32(uint32_t fetchdat) AL = temp; CLOCK_CYCLES((is486) ? 1 : 4); PREFETCH_RUN(4, 5, -1, 1,0,0,0, 1); - return 0; + return 0; } static int opMOV_AX_a16(uint32_t fetchdat) { @@ -286,7 +286,7 @@ static int opMOV_AX_a16(uint32_t fetchdat) AX = temp; CLOCK_CYCLES((is486) ? 1 : 4); PREFETCH_RUN(4, 3, -1, 1,0,0,0, 0); - return 0; + return 0; } static int opMOV_AX_a32(uint32_t fetchdat) { @@ -298,7 +298,7 @@ static int opMOV_AX_a32(uint32_t fetchdat) AX = temp; CLOCK_CYCLES((is486) ? 1 : 4); PREFETCH_RUN(4, 5, -1, 1,0,0,0, 1); - return 0; + return 0; } static int opMOV_EAX_a16(uint32_t fetchdat) { @@ -310,7 +310,7 @@ static int opMOV_EAX_a16(uint32_t fetchdat) EAX = temp; CLOCK_CYCLES((is486) ? 1 : 4); PREFETCH_RUN(4, 3, -1, 0,1,0,0, 0); - return 0; + return 0; } static int opMOV_EAX_a32(uint32_t fetchdat) { @@ -322,7 +322,7 @@ static int opMOV_EAX_a32(uint32_t fetchdat) EAX = temp; CLOCK_CYCLES((is486) ? 1 : 4); PREFETCH_RUN(4, 5, -1, 0,1,0,0, 1); - return 0; + return 0; } static int opMOV_a16_AL(uint32_t fetchdat) @@ -431,7 +431,7 @@ static int opXLAT_a16(uint32_t fetchdat) { uint32_t addr = (BX + AL)&0xFFFF; uint8_t temp; - + SEG_CHECK_READ(cpu_state.ea_seg); temp = readmemb(cpu_state.ea_seg->base, addr); if (cpu_state.abrt) return 1; AL = temp; @@ -443,7 +443,7 @@ static int opXLAT_a32(uint32_t fetchdat) { uint32_t addr = EBX + AL; uint8_t temp; - + SEG_CHECK_READ(cpu_state.ea_seg); temp = readmemb(cpu_state.ea_seg->base, addr); if (cpu_state.abrt) return 1; AL = temp; @@ -498,7 +498,7 @@ static int opMOV_w_r_a16(uint32_t fetchdat) PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 0); } else - { + { SEG_CHECK_WRITE(cpu_state.ea_seg); seteaw(cpu_state.regs[cpu_reg].w); CLOCK_CYCLES(is486 ? 1 : 2); @@ -516,7 +516,7 @@ static int opMOV_w_r_a32(uint32_t fetchdat) PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 1); } else - { + { SEG_CHECK_WRITE(cpu_state.ea_seg); seteaw(cpu_state.regs[cpu_reg].w); CLOCK_CYCLES(is486 ? 1 : 2); @@ -525,7 +525,7 @@ static int opMOV_w_r_a32(uint32_t fetchdat) return cpu_state.abrt; } static int opMOV_l_r_a16(uint32_t fetchdat) -{ +{ fetch_ea_16(fetchdat); if (cpu_mod == 3) { @@ -543,7 +543,7 @@ static int opMOV_l_r_a16(uint32_t fetchdat) return cpu_state.abrt; } static int opMOV_l_r_a32(uint32_t fetchdat) -{ +{ fetch_ea_32(fetchdat); if (cpu_mod == 3) { diff --git a/src/cpu/x86_ops_mov_ctrl.h b/src/cpu/x86_ops_mov_ctrl.h index 28504890c..667ea9d31 100644 --- a/src/cpu/x86_ops_mov_ctrl.h +++ b/src/cpu/x86_ops_mov_ctrl.h @@ -113,7 +113,7 @@ static int opMOV_r_DRx_a32(uint32_t fetchdat) static int opMOV_CRx_r_a16(uint32_t fetchdat) { uint32_t old_cr0 = cr0; - + if ((CPL || (cpu_state.eflags&VM_FLAG)) && (cr0&1)) { x86gpf(NULL,0); @@ -172,7 +172,7 @@ static int opMOV_CRx_r_a16(uint32_t fetchdat) static int opMOV_CRx_r_a32(uint32_t fetchdat) { uint32_t old_cr0 = cr0; - + if ((CPL || (cpu_state.eflags&VM_FLAG)) && (cr0&1)) { x86gpf(NULL,0); @@ -366,4 +366,3 @@ static int opMOV_TRx_r_a32(uint32_t fetchdat) PREFETCH_RUN(6, 2, rmdat, 0,0,0,0, 1); return 0; } - diff --git a/src/cpu/x86_ops_mov_seg.h b/src/cpu/x86_ops_mov_seg.h index 02a74eb9c..02e2d50de 100644 --- a/src/cpu/x86_ops_mov_seg.h +++ b/src/cpu/x86_ops_mov_seg.h @@ -25,7 +25,7 @@ static int opMOV_w_seg_a16(uint32_t fetchdat) seteaw(GS); break; } - + CLOCK_CYCLES((cpu_mod == 3) ? 2 : 3); PREFETCH_RUN((cpu_mod == 3) ? 2 : 3, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 0); return cpu_state.abrt; @@ -57,7 +57,7 @@ static int opMOV_w_seg_a32(uint32_t fetchdat) seteaw(GS); break; } - + CLOCK_CYCLES((cpu_mod == 3) ? 2 : 3); PREFETCH_RUN((cpu_mod == 3) ? 2 : 3, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 1); return cpu_state.abrt; @@ -96,7 +96,7 @@ static int opMOV_l_seg_a16(uint32_t fetchdat) else seteaw(GS); break; } - + CLOCK_CYCLES((cpu_mod == 3) ? 2 : 3); PREFETCH_RUN((cpu_mod == 3) ? 2 : 3, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 0); return cpu_state.abrt; @@ -134,7 +134,7 @@ static int opMOV_l_seg_a32(uint32_t fetchdat) else seteaw(GS); break; } - + CLOCK_CYCLES((cpu_mod == 3) ? 2 : 3); PREFETCH_RUN((cpu_mod == 3) ? 2 : 3, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 1); return cpu_state.abrt; @@ -143,12 +143,12 @@ static int opMOV_l_seg_a32(uint32_t fetchdat) static int opMOV_seg_w_a16(uint32_t fetchdat) { uint16_t new_seg; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); new_seg=geteaw(); if (cpu_state.abrt) return 1; - + switch (rmdat & 0x38) { case 0x00: /*ES*/ @@ -176,7 +176,7 @@ static int opMOV_seg_w_a16(uint32_t fetchdat) loadseg(new_seg, &cpu_state.seg_gs); break; } - + CLOCK_CYCLES((cpu_mod == 3) ? 2 : 5); PREFETCH_RUN((cpu_mod == 3) ? 2 : 5, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 0); return cpu_state.abrt; @@ -184,12 +184,12 @@ static int opMOV_seg_w_a16(uint32_t fetchdat) static int opMOV_seg_w_a32(uint32_t fetchdat) { uint16_t new_seg; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); new_seg=geteaw(); if (cpu_state.abrt) return 1; - + switch (rmdat & 0x38) { case 0x00: /*ES*/ @@ -217,7 +217,7 @@ static int opMOV_seg_w_a32(uint32_t fetchdat) loadseg(new_seg, &cpu_state.seg_gs); break; } - + CLOCK_CYCLES((cpu_mod == 3) ? 2 : 5); PREFETCH_RUN((cpu_mod == 3) ? 2 : 5, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,0, 1); return cpu_state.abrt; @@ -236,7 +236,7 @@ static int opLDS_w_a16(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ds); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 0); return 0; @@ -253,7 +253,7 @@ static int opLDS_w_a32(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ds); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 1); return 0; @@ -271,7 +271,7 @@ static int opLDS_l_a16(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ds); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 1,1,0,0, 0); return 0; @@ -289,7 +289,7 @@ static int opLDS_l_a32(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ds); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 1,1,0,0, 1); return 0; @@ -307,7 +307,7 @@ static int opLSS_w_a16(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ss); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 0); return 1; @@ -324,7 +324,7 @@ static int opLSS_w_a32(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ss); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 1); return 1; @@ -342,7 +342,7 @@ static int opLSS_l_a16(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ss); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 0); return 1; @@ -360,7 +360,7 @@ static int opLSS_l_a32(uint32_t fetchdat) seg = readmemw(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; loadseg(seg, &cpu_state.seg_ss); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = addr; - + CLOCK_CYCLES(7); PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 1); return 1; @@ -440,7 +440,7 @@ static int opLSS_l_a32(uint32_t fetchdat) PREFETCH_RUN(7, 2, rmdat, 1,1,0,0, 1); \ return 0; \ } - + opLsel(ES, cpu_state.seg_es) opLsel(FS, cpu_state.seg_fs) opLsel(GS, cpu_state.seg_gs) diff --git a/src/cpu/x86_ops_movx.h b/src/cpu/x86_ops_movx.h index 2e4fa2001..3ad89b7f0 100644 --- a/src/cpu/x86_ops_movx.h +++ b/src/cpu/x86_ops_movx.h @@ -1,13 +1,13 @@ static int opMOVZX_w_b_a16(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = (uint16_t)temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); return 0; @@ -15,13 +15,13 @@ static int opMOVZX_w_b_a16(uint32_t fetchdat) static int opMOVZX_w_b_a32(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = (uint16_t)temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); return 0; @@ -29,13 +29,13 @@ static int opMOVZX_w_b_a32(uint32_t fetchdat) static int opMOVZX_l_b_a16(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = (uint32_t)temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); return 0; @@ -43,13 +43,13 @@ static int opMOVZX_l_b_a16(uint32_t fetchdat) static int opMOVZX_l_b_a32(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = (uint32_t)temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); return 0; @@ -57,13 +57,13 @@ static int opMOVZX_l_b_a32(uint32_t fetchdat) static int opMOVZX_w_w_a16(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); return 0; @@ -71,13 +71,13 @@ static int opMOVZX_w_w_a16(uint32_t fetchdat) static int opMOVZX_w_w_a32(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); return 0; @@ -85,13 +85,13 @@ static int opMOVZX_w_w_a32(uint32_t fetchdat) static int opMOVZX_l_w_a16(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = (uint32_t)temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); return 0; @@ -99,13 +99,13 @@ static int opMOVZX_l_w_a16(uint32_t fetchdat) static int opMOVZX_l_w_a32(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteaw(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = (uint32_t)temp; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); return 0; @@ -114,15 +114,15 @@ static int opMOVZX_l_w_a32(uint32_t fetchdat) static int opMOVSX_w_b_a16(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = (uint16_t)temp; - if (temp & 0x80) + if (temp & 0x80) cpu_state.regs[cpu_reg].w |= 0xff00; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); return 0; @@ -130,15 +130,15 @@ static int opMOVSX_w_b_a16(uint32_t fetchdat) static int opMOVSX_w_b_a32(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = (uint16_t)temp; - if (temp & 0x80) + if (temp & 0x80) cpu_state.regs[cpu_reg].w |= 0xff00; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); return 0; @@ -146,15 +146,15 @@ static int opMOVSX_w_b_a32(uint32_t fetchdat) static int opMOVSX_l_b_a16(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = (uint32_t)temp; - if (temp & 0x80) + if (temp & 0x80) cpu_state.regs[cpu_reg].l |= 0xffffff00; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); return 0; @@ -162,15 +162,15 @@ static int opMOVSX_l_b_a16(uint32_t fetchdat) static int opMOVSX_l_b_a32(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); temp = geteab(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = (uint32_t)temp; - if (temp & 0x80) + if (temp & 0x80) cpu_state.regs[cpu_reg].l |= 0xffffff00; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); return 0; @@ -178,7 +178,7 @@ static int opMOVSX_l_b_a32(uint32_t fetchdat) static int opMOVSX_l_w_a16(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); @@ -186,7 +186,7 @@ static int opMOVSX_l_w_a16(uint32_t fetchdat) cpu_state.regs[cpu_reg].l = (uint32_t)temp; if (temp & 0x8000) cpu_state.regs[cpu_reg].l |= 0xffff0000; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 0); return 0; @@ -194,7 +194,7 @@ static int opMOVSX_l_w_a16(uint32_t fetchdat) static int opMOVSX_l_w_a32(uint32_t fetchdat) { uint16_t temp; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); @@ -202,7 +202,7 @@ static int opMOVSX_l_w_a32(uint32_t fetchdat) cpu_state.regs[cpu_reg].l = (uint32_t)temp; if (temp & 0x8000) cpu_state.regs[cpu_reg].l |= 0xffff0000; - + CLOCK_CYCLES(3); PREFETCH_RUN(3, 2, rmdat, (cpu_mod == 3) ? 0:1,0,0,0, 1); return 0; diff --git a/src/cpu/x86_ops_mul.h b/src/cpu/x86_ops_mul.h index a96ce54a2..ca12a9add 100644 --- a/src/cpu/x86_ops_mul.h +++ b/src/cpu/x86_ops_mul.h @@ -1,15 +1,15 @@ static int opIMUL_w_iw_a16(uint32_t fetchdat) { int32_t templ; - int16_t tempw, tempw2; - + int16_t tempw, tempw2; + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - + tempw = geteaw(); if (cpu_state.abrt) return 1; tempw2 = getword(); if (cpu_state.abrt) return 1; - + templ = ((int)tempw) * ((int)tempw2); flags_rebuild(); if ((templ >> 15) != 0 && (templ >> 15) != -1) cpu_state.flags |= C_FLAG | V_FLAG; @@ -24,14 +24,14 @@ static int opIMUL_w_iw_a32(uint32_t fetchdat) { int32_t templ; int16_t tempw, tempw2; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - + tempw = geteaw(); if (cpu_state.abrt) return 1; tempw2 = getword(); if (cpu_state.abrt) return 1; - + templ = ((int)tempw) * ((int)tempw2); flags_rebuild(); if ((templ >> 15) != 0 && (templ >> 15) != -1) cpu_state.flags |= C_FLAG | V_FLAG; @@ -47,20 +47,20 @@ static int opIMUL_l_il_a16(uint32_t fetchdat) { int64_t temp64; int32_t templ, templ2; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - + templ = geteal(); if (cpu_state.abrt) return 1; templ2 = getlong(); if (cpu_state.abrt) return 1; - + temp64 = ((int64_t)templ) * ((int64_t)templ2); flags_rebuild(); if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); cpu_state.regs[cpu_reg].l = temp64 & 0xffffffff; - + CLOCK_CYCLES(25); PREFETCH_RUN(25, 6, rmdat, 0,1,0,0, 0); return 0; @@ -69,20 +69,20 @@ static int opIMUL_l_il_a32(uint32_t fetchdat) { int64_t temp64; int32_t templ, templ2; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - + templ = geteal(); if (cpu_state.abrt) return 1; templ2 = getlong(); if (cpu_state.abrt) return 1; - + temp64 = ((int64_t)templ) * ((int64_t)templ2); flags_rebuild(); if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); cpu_state.regs[cpu_reg].l = temp64 & 0xffffffff; - + CLOCK_CYCLES(25); PREFETCH_RUN(25, 6, rmdat, 0,1,0,0, 1); return 0; @@ -92,21 +92,21 @@ static int opIMUL_w_ib_a16(uint32_t fetchdat) { int32_t templ; int16_t tempw, tempw2; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - + tempw = geteaw(); if (cpu_state.abrt) return 1; tempw2 = getbyte(); if (cpu_state.abrt) return 1; if (tempw2 & 0x80) tempw2 |= 0xff00; - + templ = ((int)tempw) * ((int)tempw2); flags_rebuild(); if ((templ >> 15) != 0 && (templ >> 15) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); cpu_state.regs[cpu_reg].w = templ & 0xffff; - + CLOCK_CYCLES((cpu_mod == 3) ? 14 : 17); PREFETCH_RUN((cpu_mod == 3) ? 14 : 17, 3, rmdat, 1,0,0,0, 0); return 0; @@ -115,21 +115,21 @@ static int opIMUL_w_ib_a32(uint32_t fetchdat) { int32_t templ; int16_t tempw, tempw2; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); - + tempw = geteaw(); if (cpu_state.abrt) return 1; tempw2 = getbyte(); if (cpu_state.abrt) return 1; if (tempw2 & 0x80) tempw2 |= 0xff00; - + templ = ((int)tempw) * ((int)tempw2); flags_rebuild(); if ((templ >> 15) != 0 && (templ >> 15) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); cpu_state.regs[cpu_reg].w = templ & 0xffff; - + CLOCK_CYCLES((cpu_mod == 3) ? 14 : 17); PREFETCH_RUN((cpu_mod == 3) ? 14 : 17, 3, rmdat, 1,0,0,0, 1); return 0; @@ -142,18 +142,18 @@ static int opIMUL_l_ib_a16(uint32_t fetchdat) fetch_ea_16(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - + SEG_CHECK_READ(cpu_state.ea_seg); + templ = geteal(); if (cpu_state.abrt) return 1; templ2 = getbyte(); if (cpu_state.abrt) return 1; if (templ2 & 0x80) templ2 |= 0xffffff00; - + temp64 = ((int64_t)templ)*((int64_t)templ2); flags_rebuild(); if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); cpu_state.regs[cpu_reg].l = temp64 & 0xffffffff; - + CLOCK_CYCLES(20); PREFETCH_RUN(20, 3, rmdat, 0,1,0,0, 0); return 0; @@ -165,18 +165,18 @@ static int opIMUL_l_ib_a32(uint32_t fetchdat) fetch_ea_32(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - + SEG_CHECK_READ(cpu_state.ea_seg); + templ = geteal(); if (cpu_state.abrt) return 1; templ2 = getbyte(); if (cpu_state.abrt) return 1; if (templ2 & 0x80) templ2 |= 0xffffff00; - + temp64 = ((int64_t)templ)*((int64_t)templ2); flags_rebuild(); if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); cpu_state.regs[cpu_reg].l = temp64 & 0xffffffff; - + CLOCK_CYCLES(20); PREFETCH_RUN(20, 3, rmdat, 0,1,0,0, 1); return 0; @@ -187,7 +187,7 @@ static int opIMUL_l_ib_a32(uint32_t fetchdat) static int opIMUL_w_w_a16(uint32_t fetchdat) { int32_t templ; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_READ(cpu_state.ea_seg); @@ -198,7 +198,7 @@ static int opIMUL_w_w_a16(uint32_t fetchdat) flags_rebuild(); if ((templ >> 15) != 0 && (templ >> 15) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); - + CLOCK_CYCLES(18); PREFETCH_RUN(18, 2, rmdat, 1,0,0,0, 0); return 0; @@ -206,18 +206,18 @@ static int opIMUL_w_w_a16(uint32_t fetchdat) static int opIMUL_w_w_a32(uint32_t fetchdat) { int32_t templ; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - + SEG_CHECK_READ(cpu_state.ea_seg); + templ = (int32_t)(int16_t)cpu_state.regs[cpu_reg].w * (int32_t)(int16_t)geteaw(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].w = templ & 0xFFFF; flags_rebuild(); if ((templ >> 15) != 0 && (templ >> 15) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); - + CLOCK_CYCLES(18); PREFETCH_RUN(18, 2, rmdat, 1,0,0,0, 1); return 0; @@ -229,15 +229,15 @@ static int opIMUL_l_l_a16(uint32_t fetchdat) fetch_ea_16(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - + SEG_CHECK_READ(cpu_state.ea_seg); + temp64 = (int64_t)(int32_t)cpu_state.regs[cpu_reg].l * (int64_t)(int32_t)geteal(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = temp64 & 0xFFFFFFFF; flags_rebuild(); if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); - + CLOCK_CYCLES(30); PREFETCH_RUN(30, 2, rmdat, 0,1,0,0, 0); return 0; @@ -248,17 +248,16 @@ static int opIMUL_l_l_a32(uint32_t fetchdat) fetch_ea_32(fetchdat); if (cpu_mod != 3) - SEG_CHECK_READ(cpu_state.ea_seg); - + SEG_CHECK_READ(cpu_state.ea_seg); + temp64 = (int64_t)(int32_t)cpu_state.regs[cpu_reg].l * (int64_t)(int32_t)geteal(); if (cpu_state.abrt) return 1; cpu_state.regs[cpu_reg].l = temp64 & 0xFFFFFFFF; flags_rebuild(); if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) cpu_state.flags |= C_FLAG | V_FLAG; else cpu_state.flags &= ~(C_FLAG | V_FLAG); - + CLOCK_CYCLES(30); PREFETCH_RUN(30, 2, rmdat, 0,1,0,0, 1); return 0; } - diff --git a/src/cpu/x86_ops_pmode.h b/src/cpu/x86_ops_pmode.h index b031fac22..698cfc838 100644 --- a/src/cpu/x86_ops_pmode.h +++ b/src/cpu/x86_ops_pmode.h @@ -1,13 +1,13 @@ static int opARPL_a16(uint32_t fetchdat) { uint16_t temp_seg; - + NOTRM fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); temp_seg = geteaw(); if (cpu_state.abrt) return 1; - + flags_rebuild(); if ((temp_seg & 3) < (cpu_state.regs[cpu_reg].w & 3)) { @@ -17,7 +17,7 @@ static int opARPL_a16(uint32_t fetchdat) } else cpu_state.flags &= ~Z_FLAG; - + CLOCK_CYCLES(is486 ? 9 : 20); PREFETCH_RUN(is486 ? 9 : 20, 2, rmdat, 1,0,1,0, 0); return 0; @@ -25,13 +25,13 @@ static int opARPL_a16(uint32_t fetchdat) static int opARPL_a32(uint32_t fetchdat) { uint16_t temp_seg; - + NOTRM fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); temp_seg = geteaw(); if (cpu_state.abrt) return 1; - + flags_rebuild(); if ((temp_seg & 3) < (cpu_state.regs[cpu_reg].w & 3)) { @@ -41,7 +41,7 @@ static int opARPL_a32(uint32_t fetchdat) } else cpu_state.flags &= ~Z_FLAG; - + CLOCK_CYCLES(is486 ? 9 : 20); PREFETCH_RUN(is486 ? 9 : 20, 2, rmdat, 1,0,1,0, 1); return 0; @@ -298,7 +298,7 @@ static int op0F00_a16(uint32_t fetchdat) NOTRM fetch_ea_16(fetchdat); - + return op0F00_common(fetchdat, 0); } static int op0F00_a32(uint32_t fetchdat) @@ -306,7 +306,7 @@ static int op0F00_a32(uint32_t fetchdat) NOTRM fetch_ea_32(fetchdat); - + return op0F00_common(fetchdat, 1); } @@ -430,31 +430,31 @@ static int op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) static int op0F01_w_a16(uint32_t fetchdat) { fetch_ea_16(fetchdat); - + return op0F01_common(fetchdat, 0, 0, 0); } static int op0F01_w_a32(uint32_t fetchdat) { fetch_ea_32(fetchdat); - + return op0F01_common(fetchdat, 0, 0, 1); } static int op0F01_l_a16(uint32_t fetchdat) { fetch_ea_16(fetchdat); - + return op0F01_common(fetchdat, 1, 0, 0); } static int op0F01_l_a32(uint32_t fetchdat) { fetch_ea_32(fetchdat); - + return op0F01_common(fetchdat, 1, 0, 1); } static int op0F01_286(uint32_t fetchdat) { fetch_ea_16(fetchdat); - + return op0F01_common(fetchdat, 0, 1, 0); } diff --git a/src/cpu/x86_ops_prefix.h b/src/cpu/x86_ops_prefix.h index 8d191103d..3029da30a 100644 --- a/src/cpu/x86_ops_prefix.h +++ b/src/cpu/x86_ops_prefix.h @@ -118,7 +118,7 @@ static int op_66_REPE(uint32_t fetchdat) /*Data size select*/ PREFETCH_PREFIX(); if (x86_opcodes_REPE[(fetchdat & 0xff) | cpu_state.op32]) return x86_opcodes_REPE[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); - return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); + return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); } static int op_67_REPE(uint32_t fetchdat) /*Address size select*/ { @@ -131,7 +131,7 @@ static int op_67_REPE(uint32_t fetchdat) /*Address size select*/ PREFETCH_PREFIX(); if (x86_opcodes_REPE[(fetchdat & 0xff) | cpu_state.op32]) return x86_opcodes_REPE[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); - return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); + return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); } static int op_66_REPNE(uint32_t fetchdat) /*Data size select*/ { @@ -144,7 +144,7 @@ static int op_66_REPNE(uint32_t fetchdat) /*Data size select*/ PREFETCH_PREFIX(); if (x86_opcodes_REPNE[(fetchdat & 0xff) | cpu_state.op32]) return x86_opcodes_REPNE[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); - return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); + return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); } static int op_67_REPNE(uint32_t fetchdat) /*Address size select*/ { @@ -157,5 +157,5 @@ static int op_67_REPNE(uint32_t fetchdat) /*Address size select*/ PREFETCH_PREFIX(); if (x86_opcodes_REPNE[(fetchdat & 0xff) | cpu_state.op32]) return x86_opcodes_REPNE[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); - return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); + return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); } diff --git a/src/cpu/x86_ops_rep.h b/src/cpu/x86_ops_rep.h index d76613151..ffae30e09 100644 --- a/src/cpu/x86_ops_rep.h +++ b/src/cpu/x86_ops_rep.h @@ -755,7 +755,7 @@ static int opREPNE(uint32_t fetchdat) return x86_opcodes[(fetchdat & 0xff) | cpu_state.op32](fetchdat >> 8); } static int opREPE(uint32_t fetchdat) -{ +{ fetchdat = fastreadl(cs + cpu_state.pc); if (cpu_state.abrt) return 1; cpu_state.pc++; diff --git a/src/cpu/x86_ops_ret.h b/src/cpu/x86_ops_ret.h index 3d6386956..222eb5243 100644 --- a/src/cpu/x86_ops_ret.h +++ b/src/cpu/x86_ops_ret.h @@ -51,10 +51,10 @@ static int opRETF_a16(uint32_t fetchdat) { int cycles_old = cycles; UN_USED(cycles_old); - + CPU_BLOCK_END(); RETF_a16(0); - + PREFETCH_RUN(cycles_old-cycles, 1, -1, 2,0,0,0, 0); PREFETCH_FLUSH(); return 0; @@ -62,7 +62,7 @@ static int opRETF_a16(uint32_t fetchdat) static int opRETF_a32(uint32_t fetchdat) { int cycles_old = cycles; UN_USED(cycles_old); - + CPU_BLOCK_END(); RETF_a32(0); @@ -99,7 +99,7 @@ static int opRETF_a32_imm(uint32_t fetchdat) static int opIRET_286(uint32_t fetchdat) { int cycles_old = cycles; UN_USED(cycles_old); - + if ((cr0 & 1) && (cpu_state.eflags & VM_FLAG) && (IOPL != 3)) { x86gpf(NULL,0); @@ -144,7 +144,7 @@ static int opIRET_286(uint32_t fetchdat) static int opIRET(uint32_t fetchdat) { int cycles_old = cycles; UN_USED(cycles_old); - + if ((cr0 & 1) && (cpu_state.eflags & VM_FLAG) && (IOPL != 3)) { if (cr4 & CR4_VME) @@ -221,7 +221,7 @@ static int opIRET(uint32_t fetchdat) static int opIRETD(uint32_t fetchdat) { int cycles_old = cycles; UN_USED(cycles_old); - + if ((cr0 & 1) && (cpu_state.eflags & VM_FLAG) && (IOPL != 3)) { x86gpf_expected(NULL,0); @@ -264,4 +264,3 @@ static int opIRETD(uint32_t fetchdat) PREFETCH_FLUSH(); return cpu_state.abrt; } - diff --git a/src/cpu/x86_ops_shift.h b/src/cpu/x86_ops_shift.h index b2812d8a7..5d03cb9a9 100644 --- a/src/cpu/x86_ops_shift.h +++ b/src/cpu/x86_ops_shift.h @@ -479,7 +479,7 @@ static int opC0_a16(uint32_t fetchdat) int c; int tempc; uint8_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -494,7 +494,7 @@ static int opC0_a32(uint32_t fetchdat) int c; int tempc; uint8_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -509,7 +509,7 @@ static int opC1_w_a16(uint32_t fetchdat) int c; int tempc; uint16_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -524,7 +524,7 @@ static int opC1_w_a32(uint32_t fetchdat) int c; int tempc; uint16_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -539,7 +539,7 @@ static int opC1_l_a16(uint32_t fetchdat) int c; int tempc; uint32_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -554,7 +554,7 @@ static int opC1_l_a32(uint32_t fetchdat) int c; int tempc; uint32_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -570,7 +570,7 @@ static int opD0_a16(uint32_t fetchdat) int c = 1; int tempc; uint8_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -583,7 +583,7 @@ static int opD0_a32(uint32_t fetchdat) int c = 1; int tempc; uint8_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -596,7 +596,7 @@ static int opD1_w_a16(uint32_t fetchdat) int c = 1; int tempc; uint16_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -609,7 +609,7 @@ static int opD1_w_a32(uint32_t fetchdat) int c = 1; int tempc; uint16_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -622,7 +622,7 @@ static int opD1_l_a16(uint32_t fetchdat) int c = 1; int tempc; uint32_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -635,7 +635,7 @@ static int opD1_l_a32(uint32_t fetchdat) int c = 1; int tempc; uint32_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -649,7 +649,7 @@ static int opD2_a16(uint32_t fetchdat) int c; int tempc; uint8_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -663,7 +663,7 @@ static int opD2_a32(uint32_t fetchdat) int c; int tempc; uint8_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -677,7 +677,7 @@ static int opD3_w_a16(uint32_t fetchdat) int c; int tempc; uint16_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -691,7 +691,7 @@ static int opD3_w_a32(uint32_t fetchdat) int c; int tempc; uint16_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -705,7 +705,7 @@ static int opD3_l_a16(uint32_t fetchdat) int c; int tempc; uint32_t temp, temp2 = 0; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -719,7 +719,7 @@ static int opD3_l_a32(uint32_t fetchdat) int c; int tempc; uint32_t temp, temp2 = 0; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -845,7 +845,7 @@ static int opD3_l_a32(uint32_t fetchdat) PREFETCH_RUN(3, 3, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 1); \ return 0; \ } - + opSHxD(SHLD_w) opSHxD(SHLD_l) opSHxD(SHRD_w) diff --git a/src/cpu/x86_ops_stack.h b/src/cpu/x86_ops_stack.h index 5bed0b741..76b74d393 100644 --- a/src/cpu/x86_ops_stack.h +++ b/src/cpu/x86_ops_stack.h @@ -191,7 +191,7 @@ static int opPOPA_l(uint32_t fetchdat) static int opPUSH_imm_w(uint32_t fetchdat) { - uint16_t val = getwordf(); + uint16_t val = getwordf(); PUSH_W(val); CLOCK_CYCLES(2); PREFETCH_RUN(2, 3, -1, 0,0,1,0, 0); @@ -212,7 +212,7 @@ static int opPUSH_imm_bw(uint32_t fetchdat) if (tempw & 0x80) tempw |= 0xFF00; PUSH_W(tempw); - + CLOCK_CYCLES(2); PREFETCH_RUN(2, 2, -1, 0,0,1,0, 0); return cpu_state.abrt; @@ -223,7 +223,7 @@ static int opPUSH_imm_bl(uint32_t fetchdat) if (templ & 0x80) templ |= 0xFFFFFF00; PUSH_L(templ); - + CLOCK_CYCLES(2); PREFETCH_RUN(2, 2, -1, 0,0,0,1, 0); return cpu_state.abrt; @@ -232,7 +232,7 @@ static int opPUSH_imm_bl(uint32_t fetchdat) static int opPOPW_a16(uint32_t fetchdat) { uint16_t temp; - + temp = POP_W(); if (cpu_state.abrt) return 1; fetch_ea_16(fetchdat); @@ -244,7 +244,7 @@ static int opPOPW_a16(uint32_t fetchdat) if (stack32) ESP -= 2; else SP -= 2; } - + if (is486) { CLOCK_CYCLES((cpu_mod == 3) ? 1 : 6); } else { CLOCK_CYCLES((cpu_mod == 3) ? 4 : 5); } PREFETCH_RUN((cpu_mod == 3) ? 4 : 5, 2, rmdat, 1,0,(cpu_mod == 3) ? 0:1,0, 0); @@ -253,9 +253,9 @@ static int opPOPW_a16(uint32_t fetchdat) static int opPOPW_a32(uint32_t fetchdat) { uint16_t temp; - + temp = POP_W(); if (cpu_state.abrt) return 1; - + fetch_ea_32(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); @@ -265,7 +265,7 @@ static int opPOPW_a32(uint32_t fetchdat) if (stack32) ESP -= 2; else SP -= 2; } - + if (is486) { CLOCK_CYCLES((cpu_mod == 3) ? 1 : 6); } else { CLOCK_CYCLES((cpu_mod == 3) ? 4 : 5); } PREFETCH_RUN((cpu_mod == 3) ? 4 : 5, 2, rmdat, 1,0,(cpu_mod == 3) ? 0:1,0, 1); @@ -278,7 +278,7 @@ static int opPOPL_a16(uint32_t fetchdat) temp = POP_L(); if (cpu_state.abrt) return 1; - fetch_ea_16(fetchdat); + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); seteal(temp); @@ -287,7 +287,7 @@ static int opPOPL_a16(uint32_t fetchdat) if (stack32) ESP -= 4; else SP -= 4; } - + if (is486) { CLOCK_CYCLES((cpu_mod == 3) ? 1 : 6); } else { CLOCK_CYCLES((cpu_mod == 3) ? 4 : 5); } PREFETCH_RUN((cpu_mod == 3) ? 4 : 5, 2, rmdat, 0,1,0,(cpu_mod == 3) ? 0:1, 0); @@ -328,10 +328,10 @@ static int opENTER_w(uint32_t fetchdat) count = (fetchdat >> 16) & 0xff; cpu_state.pc++; tempEBP = EBP; tempESP = ESP; - + PUSH_W(BP); if (cpu_state.abrt) return 1; frame_ptr = ESP; - + if (count > 0) { while (--count) @@ -350,7 +350,7 @@ static int opENTER_w(uint32_t fetchdat) writes++; instr_cycles += (is486) ? 3 : 5; } BP = frame_ptr; - + if (stack32) ESP -= offset; else SP -= offset; CLOCK_CYCLES((is486) ? 14 : 10); @@ -369,10 +369,10 @@ static int opENTER_l(uint32_t fetchdat) offset = getwordf(); count = (fetchdat >> 16) & 0xff; cpu_state.pc++; tempEBP = EBP; tempESP = ESP; - + PUSH_L(EBP); if (cpu_state.abrt) return 1; frame_ptr = ESP; - + if (count > 0) { while (--count) @@ -391,7 +391,7 @@ static int opENTER_l(uint32_t fetchdat) writes++; instr_cycles += (is486) ? 3 : 5; } EBP = frame_ptr; - + if (stack32) ESP -= offset; else SP -= offset; CLOCK_CYCLES((is486) ? 14 : 10); @@ -406,11 +406,11 @@ static int opLEAVE_w(uint32_t fetchdat) uint32_t tempESP = ESP; uint16_t temp; - SP = BP; + SP = BP; temp = POP_W(); if (cpu_state.abrt) { ESP = tempESP; return 1; } BP = temp; - + CLOCK_CYCLES(4); PREFETCH_RUN(4, 1, -1, 1,0,0,0, 0); return 0; @@ -420,12 +420,12 @@ static int opLEAVE_l(uint32_t fetchdat) uint32_t tempESP = ESP; uint32_t temp; - ESP = EBP; + ESP = EBP; temp = POP_L(); if (cpu_state.abrt) { ESP = tempESP; return 1; } EBP = temp; - - CLOCK_CYCLES(4); + + CLOCK_CYCLES(4); PREFETCH_RUN(4, 1, -1, 0,1,0,0, 0); return 0; } @@ -446,7 +446,7 @@ static int opLEAVE_l(uint32_t fetchdat) PREFETCH_RUN(2, 1, -1, 0,0,0,1, 0); \ return cpu_state.abrt; \ } - + #define POP_SEG_OPS(seg, realseg) \ static int opPOP_ ## seg ## _w(uint32_t fetchdat) \ { \ @@ -469,7 +469,7 @@ static int opLEAVE_l(uint32_t fetchdat) return cpu_state.abrt; \ } - + PUSH_SEG_OPS(CS) PUSH_SEG_OPS(DS) PUSH_SEG_OPS(ES) @@ -490,7 +490,7 @@ static int opPOP_SS_w(uint32_t fetchdat) loadseg(temp_seg, &cpu_state.seg_ss); if (cpu_state.abrt) { ESP = temp_esp; return 1; } CLOCK_CYCLES(is486 ? 3 : 7); PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0,0,1,0, 0); - + cpu_state.oldpc = cpu_state.pc; cpu_state.op32 = use32; cpu_state.ssegs = 0; diff --git a/src/cpu/x86_ops_xchg.h b/src/cpu/x86_ops_xchg.h index 6a787273e..300e97f25 100644 --- a/src/cpu/x86_ops_xchg.h +++ b/src/cpu/x86_ops_xchg.h @@ -1,7 +1,7 @@ static int opXCHG_b_a16(uint32_t fetchdat) { uint8_t temp; - + fetch_ea_16(fetchdat); if (cpu_mod != 3) SEG_CHECK_WRITE(cpu_state.ea_seg); diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index 7fab0869c..f4f343f4f 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -1516,7 +1516,7 @@ pmodeint(int num, int soft) if (cpu_state.abrt) return; oaddr = addr; - + if (DPL2 > CPL) { x86gpf("pmodeint(): Interrupt or trap gate DPL > CPL", seg & 0xfffc); return; @@ -2106,7 +2106,7 @@ taskswitch286(uint16_t seg, uint16_t *segdat, int is32) new_pc = readmeml(base, 0x20); new_flags = readmeml(base, 0x24); if ((optype == OPTYPE_INT) || (optype == CALL)) - new_flags |= NT_FLAG; + new_flags |= NT_FLAG; new_eax = readmeml(base, 0x28); new_ecx = readmeml(base, 0x2C); diff --git a/src/cpu/x87.c b/src/cpu/x87.c index 47ab0c844..cf92788fb 100644 --- a/src/cpu/x87.c +++ b/src/cpu/x87.c @@ -51,7 +51,7 @@ uint16_t x87_gettag() { uint16_t ret = 0; int c; - + for (c = 0; c < 8; c++) { if (cpu_state.tag[c] == TAG_EMPTY) @@ -70,11 +70,11 @@ uint16_t x87_gettag() void x87_settag(uint16_t new_tag) { int c; - + for (c = 0; c < 8; c++) { int tag = (new_tag >> (c * 2)) & 3; - + if (tag == X87_TAG_EMPTY) cpu_state.tag[c] = TAG_EMPTY; else if (tag == 2) @@ -88,7 +88,7 @@ uint16_t x87_gettag() { uint16_t ret = 0; int c; - + for (c = 0; c < 8; c++) { if (cpu_state.tag[c] & TAG_UINT64) diff --git a/src/cpu/x87_ops.h b/src/cpu/x87_ops.h index 9e06a343e..2f8927060 100644 --- a/src/cpu/x87_ops.h +++ b/src/cpu/x87_ops.h @@ -96,7 +96,7 @@ static int rounding_modes[4] = {FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZ dst = src1 / (double)src2; \ } while (0) #endif - + static __inline void x87_checkexceptions() { } @@ -123,7 +123,7 @@ static __inline void x87_push_u64(uint64_t i) double d; uint64_t ll; } td; - + td.ll = i; #ifdef USE_NEW_DYNAREC @@ -272,7 +272,7 @@ static __inline double x87_ld80() exp64final = 0x7ff; if ((test.begin & 0x7fff) == 0) exp64final = 0; - if (test.eind.ll & 0x400) + if (test.eind.ll & 0x400) mant64++; test.eind.ll = (sign <<63)|(exp64final << 52)| mant64; @@ -296,9 +296,9 @@ static __inline void x87_st80(double d) uint64_t ll; } eind; } test; - + test.eind.d=d; - + sign80 = (test.eind.ll&(0x8000000000000000ll))?1:0; exp80 = test.eind.ll&(0x7ff0000000000000ll); exp80final = (exp80>>52); @@ -327,7 +327,7 @@ static __inline void x87_st80(double d) static __inline void x87_st_fsave(int reg) { reg = (cpu_state.TOP + reg) & 7; - + if (cpu_state.tag[reg] & TAG_UINT64) { writememl(easeg, cpu_state.eaaddr, cpu_state.MM[reg].q & 0xffffffff); @@ -341,7 +341,7 @@ static __inline void x87_st_fsave(int reg) static __inline void x87_ld_frstor(int reg) { reg = (cpu_state.TOP + reg) & 7; - + cpu_state.MM[reg].q = readmemq(easeg, cpu_state.eaaddr); cpu_state.MM_w4[reg] = readmemw(easeg, cpu_state.eaaddr + 8); @@ -401,12 +401,12 @@ static __inline uint16_t x87_compare(double a, double b) /* Memory barrier, to force GCC to write to the input parameters * before the compare rather than after */ __asm volatile ("" : : : "memory"); - + __asm( "fldl %2\n" "fldl %1\n" "fclex\n" - "fcompp\n" + "fcompp\n" "fnstsw %0\n" : "=m" (result) : "m" (ea), "m" (eb) @@ -438,7 +438,7 @@ static __inline uint16_t x87_compare(double a, double b) result |= C3; else if (ea < eb) result |= C0; - + return result; #endif } @@ -447,17 +447,17 @@ static __inline uint16_t x87_ucompare(double a, double b) { #ifdef X87_INLINE_ASM uint32_t result; - + #if !defined(_MSC_VER) || defined(__clang__) /* Memory barrier, to force GCC to write to the input parameters * before the compare rather than after */ asm volatile ("" : : : "memory"); - + asm( "fldl %2\n" "fldl %1\n" "fclex\n" - "fucompp\n" + "fucompp\n" "fnstsw %0\n" : "=m" (result) : "m" (a), "m" (b) @@ -479,12 +479,12 @@ static __inline uint16_t x87_ucompare(double a, double b) /* Generic C version is known to give incorrect results in some * situations, eg comparison of infinity (Unreal) */ uint32_t result = 0; - + if (a == b) result |= C3; else if (a < b) result |= C0; - + return result; #endif } @@ -602,7 +602,7 @@ const OpFn OP_TABLE(fpu_8087_d9)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -611,7 +611,7 @@ const OpFn OP_TABLE(fpu_8087_d9)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -620,7 +620,7 @@ const OpFn OP_TABLE(fpu_8087_d9)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -861,7 +861,7 @@ const OpFn OP_TABLE(fpu_287_d9_a16)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -870,7 +870,7 @@ const OpFn OP_TABLE(fpu_287_d9_a16)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -879,7 +879,7 @@ const OpFn OP_TABLE(fpu_287_d9_a16)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -900,7 +900,7 @@ const OpFn OP_TABLE(fpu_287_d9_a32)[256] = ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, - opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, + opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, @@ -909,7 +909,7 @@ const OpFn OP_TABLE(fpu_287_d9_a32)[256] = ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, - opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, + opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, @@ -918,7 +918,7 @@ const OpFn OP_TABLE(fpu_287_d9_a32)[256] = ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, - opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, + opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, @@ -939,7 +939,7 @@ const OpFn OP_TABLE(fpu_d9_a16)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -948,7 +948,7 @@ const OpFn OP_TABLE(fpu_d9_a16)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -957,7 +957,7 @@ const OpFn OP_TABLE(fpu_d9_a16)[256] = ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, ILLEGAL_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, opFSTPs_a16, - opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, + opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDENV_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFLDCW_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTENV_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, opFSTCW_a16, @@ -978,7 +978,7 @@ const OpFn OP_TABLE(fpu_d9_a32)[256] = ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, - opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, + opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, @@ -987,7 +987,7 @@ const OpFn OP_TABLE(fpu_d9_a32)[256] = ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, - opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, + opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, @@ -996,7 +996,7 @@ const OpFn OP_TABLE(fpu_d9_a32)[256] = ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, ILLEGAL_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, opFSTPs_a32, - opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, + opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDENV_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFLDCW_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTENV_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, opFSTCW_a32, diff --git a/src/cpu/x87_ops_loadstore.h b/src/cpu/x87_ops_loadstore.h index 388e96011..9afa6815a 100644 --- a/src/cpu/x87_ops_loadstore.h +++ b/src/cpu/x87_ops_loadstore.h @@ -131,7 +131,7 @@ static int FBSTP_a16(uint32_t fetchdat) fetch_ea_16(fetchdat); SEG_CHECK_WRITE(cpu_state.ea_seg); tempd = ST(0); - if (tempd < 0.0) + if (tempd < 0.0) tempd = -tempd; for (c = 0; c < 9; c++) { @@ -148,7 +148,7 @@ static int FBSTP_a16(uint32_t fetchdat) writememb(easeg, cpu_state.eaaddr + 9, tempc); if (cpu_state.abrt) return 1; x87_pop(); CLOCK_CYCLES_FPU((fpu_type >= FPU_487SX) ? (x87_timings.fbstp) : (x87_timings.fbstp * cpu_multi)); - CONCURRENCY_CYCLES((fpu_type >= FPU_487SX) ? (x87_concurrency.fbstp) : (x87_concurrency.fbstp * cpu_multi)); + CONCURRENCY_CYCLES((fpu_type >= FPU_487SX) ? (x87_concurrency.fbstp) : (x87_concurrency.fbstp * cpu_multi)); return 0; } #ifndef FPU_8087 @@ -160,7 +160,7 @@ static int FBSTP_a32(uint32_t fetchdat) fetch_ea_32(fetchdat); SEG_CHECK_WRITE(cpu_state.ea_seg); tempd = ST(0); - if (tempd < 0.0) + if (tempd < 0.0) tempd = -tempd; for (c = 0; c < 9; c++) { diff --git a/src/cpu/x87_ops_misc.h b/src/cpu/x87_ops_misc.h index 7a6dee001..7e27cc287 100644 --- a/src/cpu/x87_ops_misc.h +++ b/src/cpu/x87_ops_misc.h @@ -152,7 +152,7 @@ static int FSTOR() x87_ld_frstor(5); cpu_state.eaaddr += 10; x87_ld_frstor(6); cpu_state.eaaddr += 10; x87_ld_frstor(7); - + cpu_state.ismmx = 0; /*Horrible hack, but as PCem doesn't keep the FPU stack in 80-bit precision at all times something like this is needed*/ @@ -390,7 +390,7 @@ static int opFLD(uint32_t fetchdat) { int old_tag; uint64_t old_i64; - + FP_ENTER(); cpu_state.pc++; old_tag = cpu_state.tag[(cpu_state.TOP + fetchdat) & 7]; @@ -419,7 +419,7 @@ static int opFXCH(uint32_t fetchdat) old_i64 = cpu_state.MM[cpu_state.TOP&7].q; cpu_state.MM[cpu_state.TOP&7].q = cpu_state.MM[(cpu_state.TOP + fetchdat) & 7].q; cpu_state.MM[(cpu_state.TOP + fetchdat) & 7].q = old_i64; - + CLOCK_CYCLES_FPU((fpu_type >= FPU_487SX) ? (x87_timings.fxch) : (x87_timings.fxch * cpu_multi)); CONCURRENCY_CYCLES((fpu_type >= FPU_487SX) ? (x87_concurrency.fxch) : (x87_concurrency.fxch * cpu_multi)); return 0; @@ -536,7 +536,7 @@ static int opFLDLN2(uint32_t fetchdat) CONCURRENCY_CYCLES((fpu_type >= FPU_487SX) ? (x87_concurrency.fld_const) : (x87_concurrency.fld_const * cpu_multi)); return 0; } - + static int opFLDZ(uint32_t fetchdat) { FP_ENTER(); @@ -832,7 +832,7 @@ static int FSTENV() { FP_ENTER(); cpu_state.npxs = (cpu_state.npxs & ~(7 << 11)) | ((cpu_state.TOP & 7) << 11); - + switch ((cr0 & 1) | (cpu_state.op32 & 0x100)) { case 0x000: /*16-bit real mode*/ diff --git a/src/cpu/x87_timings.c b/src/cpu/x87_timings.c index 905ff1c6a..ca207cc17 100644 --- a/src/cpu/x87_timings.c +++ b/src/cpu/x87_timings.c @@ -467,4 +467,4 @@ const x87_timings_t x87_concurrency_486 = .fxtract = 4, .fyl2x = 13, .fyl2xp1 = 13, -}; \ No newline at end of file +}; diff --git a/src/cpu/x87_timings.h b/src/cpu/x87_timings.h index c7dac8270..6396fcb06 100644 --- a/src/cpu/x87_timings.h +++ b/src/cpu/x87_timings.h @@ -56,4 +56,4 @@ extern const x87_timings_t x87_timings_486; extern const x87_timings_t x87_concurrency_486; extern x87_timings_t x87_timings; -extern x87_timings_t x87_concurrency; \ No newline at end of file +extern x87_timings_t x87_concurrency; diff --git a/src/ddma.c b/src/ddma.c index 1ce7f1997..c99225150 100644 --- a/src/ddma.c +++ b/src/ddma.c @@ -191,8 +191,8 @@ const device_t ddma_device = "ddma", DEVICE_PCI, 0, - ddma_init, - ddma_close, + ddma_init, + ddma_close, NULL, { NULL }, NULL, diff --git a/src/device/bugger.c b/src/device/bugger.c index 56ad119a1..6f2b64e65 100644 --- a/src/device/bugger.c +++ b/src/device/bugger.c @@ -268,7 +268,7 @@ bug_reset(void) /* Clear both 7SEG displays. */ bug_seg1 = 0x00; bug_seg2 = 0x00; - + /* Reset the control register (updates UI.) */ bug_wctrl(CTRL_RESET); } diff --git a/src/device/cassette.c b/src/device/cassette.c index 9c13c7dbb..2874971f5 100644 --- a/src/device/cassette.c +++ b/src/device/cassette.c @@ -625,7 +625,7 @@ void pc_cas_advance (pc_cassette_t *cas) if (cas->motor == 0) return; - if (cassette_cycles == -1) + if (cassette_cycles == -1) cassette_cycles = cycles; if (cycles <= cassette_cycles) ticks = (cassette_cycles - cycles); diff --git a/src/device/clock_ics9xxx.c b/src/device/clock_ics9xxx.c index 9f7e790af..da4de6c43 100644 --- a/src/device/clock_ics9xxx.c +++ b/src/device/clock_ics9xxx.c @@ -152,7 +152,7 @@ static const ics9xxx_model_t ics9xxx_models[] = { ICS9xxx_MODEL_END() ICS9xxx_MODEL(ICS9248_95) .max_reg = 5, - .regs = {0x82, 0xff, 0xff, 0xff, 0xd5, 0xff}, + .regs = {0x82, 0xff, 0xff, 0xff, 0xd5, 0xff}, .fs_regs = {{0, 4, -1, -1}, {0, 5, 4, 3}, {0, 6, -1, -1}, {0, 2, 4, 1}, {-1, -1, -1, -1}}, .hw_select = {0, 3}, .frequencies = (const ics9xxx_frequency_t[]) { @@ -1220,7 +1220,7 @@ ics9xxx_init(const device_t *info) dev->frequencies_ptr = (ics9xxx_frequency_t *) (dev->model->frequencies_ref ? ics9xxx_models[dev->model->frequencies_ref].frequencies : dev->model->frequencies); if (!dev->frequencies_ptr) fatal("ICS9xxx: NULL frequency table\n"); - + /* Determine which frequency bits cannot be strapped (register only). */ uint8_t register_only_bits = 0x00; for (i = 0; i < sizeof(dev->model->fs_regs) / sizeof(dev->model->fs_regs[0]); i++) { @@ -1229,11 +1229,11 @@ ics9xxx_init(const device_t *info) if ((dev->model->fs_regs[i].normal_reg == 7) && (dev->model->fs_regs[i].inv_reg == 7)) /* mark as register only */ register_only_bits |= 1 << i; } - + /* Mark the hardware select bit's register as relevant, if there's one. */ if (dev->model->hw_select.normal_reg < 7) dev->relevant_regs |= 1 << dev->model->hw_select.normal_reg; - + /* Find bus speed match and set default register bits accordingly. */ dev->bus_match = ics9xxx_find_bus_match(dev, cpu_busspeed, register_only_bits, 0x00); for (i = 0; i < sizeof(dev->model->fs_regs) / sizeof(dev->model->fs_regs[0]); i++) { diff --git a/src/device/hwm_gl518sm.c b/src/device/hwm_gl518sm.c index 67742679a..126ad182f 100644 --- a/src/device/hwm_gl518sm.c +++ b/src/device/hwm_gl518sm.c @@ -28,7 +28,7 @@ #include <86box/i2c.h> #include <86box/hwm.h> - + #define CLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a))) /* Formulas and factors derived from Linux's gl518sm.c driver. */ #define GL518SM_RPMDIV(r, d) (CLAMP((r), 1, 960000) * (d)) @@ -272,7 +272,7 @@ gl518sm_init(const device_t *info) memset(dev, 0, sizeof(gl518sm_t)); dev->local = info->local; - + /* Set default values. */ hwm_values_t defaults = { { /* fan speeds */ diff --git a/src/device/hwm_lm78.c b/src/device/hwm_lm78.c index b49807bff..87793bbac 100644 --- a/src/device/hwm_lm78.c +++ b/src/device/hwm_lm78.c @@ -115,7 +115,7 @@ lm78_nvram(lm78_t *dev, uint8_t save) fread(&dev->as99127f.nvram, sizeof(dev->as99127f.nvram), 1, f); fclose(f); } - + free(nvr_path); } @@ -494,7 +494,7 @@ lm78_write(lm78_t *dev, uint8_t reg, uint8_t val, uint8_t bank) return 0; } } - } + } /* regular registers */ switch (reg) { diff --git a/src/device/isamem.c b/src/device/isamem.c index a987cba77..70ef32024 100644 --- a/src/device/isamem.c +++ b/src/device/isamem.c @@ -525,7 +525,7 @@ dev->frame_addr = 0xE0000; ram_readb, (dev->flags&FLAG_WIDE) ? ram_readw : NULL, NULL, - ram_writeb, + ram_writeb, (dev->flags&FLAG_WIDE) ? ram_writew : NULL, NULL, ptr, MEM_MAPPING_EXTERNAL, &dev->ext_ram[EXTRAM_CONVENTIONAL]); @@ -635,7 +635,7 @@ dev->frame_addr = 0xE0000; ems_readb, (dev->flags&FLAG_WIDE) ? ems_readw : NULL, NULL, - ems_writeb, + ems_writeb, (dev->flags&FLAG_WIDE) ? ems_writew : NULL, NULL, ptr, MEM_MAPPING_EXTERNAL, diff --git a/src/device/keyboard_at.c b/src/device/keyboard_at.c index 06357e605..7d35a4046 100644 --- a/src/device/keyboard_at.c +++ b/src/device/keyboard_at.c @@ -1383,7 +1383,7 @@ write64_ami(void *priv, uint8_t val) add_data(dev, 0x28); add_data(dev, 0x00); break; - + case 0xa1: /* get controller version */ kbd_log("ATkbc: AMI - get controller version\n"); add_data(dev, 'H'); @@ -1873,7 +1873,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv) case 0xf3: /* set typematic rate/delay */ add_data_kbd_direct(dev, 0xfa); break; - + default: kbd_log("ATkbd: bad keyboard 0060 write %02X command %02X\n", val, dev->key_command); add_data_kbd_direct(dev, 0xfe); @@ -2182,7 +2182,7 @@ kbd_read(uint16_t port, void *priv) /* Only clear the transmit timeout flag on non-PS/2 controllers, as on PS/2 controller, it is the keyboard/mouse output source bit. */ // dev->status &= ~STAT_RTIMEOUT; - if (((dev->flags & KBC_TYPE_MASK) > KBC_TYPE_PS2_NOREF) && + if (((dev->flags & KBC_TYPE_MASK) > KBC_TYPE_PS2_NOREF) && (kbc_ven != KBC_VEN_IBM_MCA)) dev->status &= ~STAT_TTIMEOUT; break; @@ -2293,7 +2293,7 @@ kbd_init(const device_t *info) io_sethandler(0x0064, 1, kbd_read, NULL, NULL, kbd_write, NULL, NULL, dev); keyboard_send = add_data_kbd; - timer_add(&dev->send_delay_timer, kbd_poll, dev, 1); + timer_add(&dev->send_delay_timer, kbd_poll, dev, 1); timer_add(&dev->pulse_cb, pulse_poll, dev, 0); dev->write60_ven = NULL; diff --git a/src/device/keyboard_xt.c b/src/device/keyboard_xt.c index 9e0cf8ff7..b4e6c0e28 100644 --- a/src/device/keyboard_xt.c +++ b/src/device/keyboard_xt.c @@ -68,7 +68,7 @@ #define KBD_TYPE_ZENITH 9 typedef struct { - int want_irq; + int want_irq; int blocked; int tandy; @@ -371,7 +371,7 @@ static uint8_t get_fdd_switch_settings() { int i, fdd_count = 0; - + for (i = 0; i < FDD_NUM; i++) { if (fdd_get_flags(i)) fdd_count++; @@ -533,7 +533,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv) speaker_gated = val & 1; speaker_enable = val & 2; - if (speaker_enable) + if (speaker_enable) was_speaker_enable = 1; pit_ctr_set_gate(&pit->counters[2], val & 1); @@ -715,7 +715,7 @@ kbd_init(const device_t *info) /* DIP switch readout: bit set = OFF, clear = ON. */ if (kbd->type == KBD_TYPE_OLIVETTI) /* Olivetti M19 - * Jumpers J1, J2 - monitor type. + * Jumpers J1, J2 - monitor type. * 01 - mono (high-res) * 10 - color (low-res, disables 640x400x2 mode) * 00 - autoswitching diff --git a/src/device/mouse_ps2.c b/src/device/mouse_ps2.c index b1b1ba3ca..949875bbf 100644 --- a/src/device/mouse_ps2.c +++ b/src/device/mouse_ps2.c @@ -212,7 +212,7 @@ mouse_reset: } if (dev->flags & FLAG_INTELLI) { - for (temp = 0; temp < 5; temp++) + for (temp = 0; temp < 5; temp++) dev->last_data[temp] = dev->last_data[temp + 1]; dev->last_data[5] = val; diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index 3cb49439a..432aa1711 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -724,7 +724,7 @@ sermouse_speed_changed(void *priv) if (dev->report_enabled) { timer_stop(&dev->report_timer); - if (dev->report_phase == REPORT_PHASE_TRANSMIT) + if (dev->report_phase == REPORT_PHASE_TRANSMIT) sermouse_timer_on(dev, dev->transmit_period, 1); else sermouse_timer_on(dev, sermouse_report_period(dev), 1); diff --git a/src/device/serial.c b/src/device/serial.c index 65c919d1b..cf3a84f00 100644 --- a/src/device/serial.c +++ b/src/device/serial.c @@ -556,7 +556,7 @@ serial_read(uint16_t addr, void *p) else ret = dev->ier; break; - case 2: + case 2: ret = dev->iir; if ((ret & 0xe) == 2) { dev->int_status &= ~SERIAL_INT_TRANSMIT; diff --git a/src/disk/CMakeLists.txt b/src/disk/CMakeLists.txt index f1a101516..34c373752 100644 --- a/src/disk/CMakeLists.txt +++ b/src/disk/CMakeLists.txt @@ -22,4 +22,4 @@ add_library(zip OBJECT zip.c) add_library(mo OBJECT mo.c) add_subdirectory(minivhd) -target_link_libraries(86Box minivhd) \ No newline at end of file +target_link_libraries(86Box minivhd) diff --git a/src/disk/hdc_esdi_at.c b/src/disk/hdc_esdi_at.c index e6d2729fa..c68ec5cf3 100644 --- a/src/disk/hdc_esdi_at.c +++ b/src/disk/hdc_esdi_at.c @@ -192,7 +192,7 @@ get_sector(esdi_t *esdi, off64_t *addr) *addr = ((((off64_t)c * drive->real_hpc) + h) * drive->real_spt) + s; } - + return(0); } @@ -528,7 +528,7 @@ esdi_callback(void *priv) irq_raise(esdi); break; } - + hdd_image_read(drive->hdd_num, addr, 1, (uint8_t *)esdi->buffer); esdi->pos = 0; esdi->status = STAT_DRQ|STAT_READY|STAT_DSC; @@ -550,7 +550,7 @@ esdi_callback(void *priv) irq_raise(esdi); break; } - + hdd_image_write(drive->hdd_num, addr, 1, (uint8_t *)esdi->buffer); irq_raise(esdi); esdi->secount = (esdi->secount - 1) & 0xff; @@ -605,7 +605,7 @@ esdi_callback(void *priv) irq_raise(esdi); break; } - + hdd_image_zero(drive->hdd_num, addr, esdi->secount); esdi->status = STAT_READY|STAT_DSC; irq_raise(esdi); diff --git a/src/disk/hdc_esdi_mca.c b/src/disk/hdc_esdi_mca.c index f50a128f6..6a8de8075 100644 --- a/src/disk/hdc_esdi_mca.c +++ b/src/disk/hdc_esdi_mca.c @@ -107,7 +107,7 @@ typedef struct esdi { uint32_t bios; rom_t bios_rom; - + uint8_t basic_ctrl; uint8_t status; uint8_t irq_status; @@ -129,20 +129,20 @@ typedef struct esdi { int sector_pos; int sector_count; - + int command; int cmd_state; - + int in_reset; uint64_t callback; pc_timer_t timer; - + uint32_t rba; - + struct { int req_in_progress; } cmds[3]; - + drive_t drives[2]; uint8_t pos_regs[8]; @@ -279,8 +279,8 @@ device_not_present(esdi_t *dev) dev->status_data[3] = 0; dev->status_data[4] = 0; dev->status_data[5] = 0; - dev->status_data[6] = 0; - dev->status_data[7] = 0; + dev->status_data[6] = 0; + dev->status_data[7] = 0; dev->status_data[8] = 0; dev->status = STATUS_IRQ | STATUS_STATUS_OUT_FULL; @@ -300,8 +300,8 @@ rba_out_of_range(esdi_t *dev) dev->status_data[3] = 0; dev->status_data[4] = 0; dev->status_data[5] = 0; - dev->status_data[6] = 0; - dev->status_data[7] = 0; + dev->status_data[6] = 0; + dev->status_data[7] = 0; dev->status_data[8] = 0; dev->status = STATUS_IRQ | STATUS_STATUS_OUT_FULL; @@ -348,7 +348,7 @@ complete_command_status(esdi_t *dev) else \ drive = &dev->drives[1]; \ } while (0) - + static void esdi_callback(void *priv) @@ -393,12 +393,12 @@ esdi_callback(void *priv) dev->irq_status = dev->cmd_dev | IRQ_DATA_TRANSFER_READY; dev->irq_in_progress = 1; set_irq(dev); - + dev->cmd_state = 1; esdi_mca_set_callback(dev, ESDI_TIME); dev->data_pos = 0; break; - + case 1: if (!(dev->basic_ctrl & CTRL_DMA_ENA)) { esdi_mca_set_callback(dev, ESDI_TIME); @@ -415,7 +415,7 @@ esdi_callback(void *priv) while (dev->data_pos < 256) { val = dma_channel_write(dev->dma, dev->data[dev->data_pos]); - + if (val == DMA_NODATA) { esdi_mca_set_callback(dev, ESDI_TIME); return; @@ -451,7 +451,7 @@ esdi_callback(void *priv) device_not_present(dev); return; } - + switch (dev->cmd_state) { case 0: dev->rba = (dev->cmd_data[2] | (dev->cmd_data[3] << 16)) & 0x0fffffff; @@ -468,7 +468,7 @@ esdi_callback(void *priv) dev->irq_status = dev->cmd_dev | IRQ_DATA_TRANSFER_READY; dev->irq_in_progress = 1; set_irq(dev); - + dev->cmd_state = 1; esdi_mca_set_callback(dev, ESDI_TIME); dev->data_pos = 0; @@ -483,7 +483,7 @@ esdi_callback(void *priv) while (dev->sector_pos < dev->sector_count) { while (dev->data_pos < 256) { val = dma_channel_read(dev->dma); - + if (val == DMA_NODATA) { esdi_mca_set_callback(dev, ESDI_TIME); return; @@ -651,7 +651,7 @@ esdi_callback(void *priv) esdi_mca_set_callback(dev, ESDI_TIME); dev->data_pos = 0; break; - + case 1: if (! (dev->basic_ctrl & CTRL_DMA_ENA)) { esdi_mca_set_callback(dev, ESDI_TIME); @@ -660,7 +660,7 @@ esdi_callback(void *priv) while (dev->sector_pos < dev->sector_count) { while (dev->data_pos < 256) { val = dma_channel_read(dev->dma); - + if (val == DMA_NODATA) { esdi_mca_set_callback(dev, ESDI_TIME); return; @@ -717,7 +717,7 @@ esdi_callback(void *priv) memcpy(dev->data, dev->sector_buffer[dev->sector_pos++], 512); while (dev->data_pos < 256) { val = dma_channel_write(dev->dma, dev->data[dev->data_pos]); - + if (val == DMA_NODATA) { esdi_mca_set_callback(dev, ESDI_TIME); return; @@ -733,7 +733,7 @@ esdi_callback(void *priv) dev->cmd_state = 2; esdi_mca_set_callback(dev, ESDI_TIME); break; - + case 2: dev->status = STATUS_IRQ; dev->irq_status = IRQ_HOST_ADAPTER | IRQ_CMD_COMPLETE_SUCCESS; @@ -766,41 +766,41 @@ esdi_callback(void *priv) device_not_present(dev); return; } - + switch (dev->cmd_state) { case 0: dev->rba = (dev->cmd_data[2] | (dev->cmd_data[3] << 16)) & 0x0fffffff; - + dev->sector_count = dev->cmd_data[1]; - + if ((dev->rba + dev->sector_count) > hdd_image_get_last_sector(drive->hdd_num)) { rba_out_of_range(dev); return; } - + dev->status = STATUS_IRQ | STATUS_CMD_IN_PROGRESS | STATUS_TRANSFER_REQ; dev->irq_status = dev->cmd_dev | IRQ_DATA_TRANSFER_READY; dev->irq_in_progress = 1; set_irq(dev); - + dev->cmd_state = 1; esdi_mca_set_callback(dev, ESDI_TIME); break; - + case 1: if (!(dev->basic_ctrl & CTRL_DMA_ENA)) { esdi_mca_set_callback(dev, ESDI_TIME); return; } - + hdd_image_zero(drive->hdd_num, dev->rba, dev->sector_count); ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 1); - + dev->status = STATUS_CMD_IN_PROGRESS; dev->cmd_state = 2; esdi_mca_set_callback(dev, ESDI_TIME); break; - + case 2: complete_command_status(dev); dev->status = STATUS_IRQ | STATUS_STATUS_OUT_FULL; @@ -886,7 +886,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) esdi_mca_set_callback(dev, ESDI_TIME * 50); dev->status = STATUS_BUSY; break; - + default: fatal("Bad attention request %02x\n", val); } @@ -903,13 +903,13 @@ esdi_write(uint16_t port, uint8_t val, void *priv) dev->cmd_pos = 0; dev->status_pos = 0; break; - + case ATTN_EOI: dev->irq_in_progress = 0; dev->status &= ~STATUS_IRQ; clear_irq(dev); break; - + default: fatal("Bad attention request %02x\n", val); } @@ -932,7 +932,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) dev->status &= ~STATUS_IRQ; clear_irq(dev); break; - + default: fatal("Bad attention request %02x\n", val); } @@ -968,7 +968,7 @@ esdi_readw(uint16_t port, void *priv) default: fatal("esdi_readw port=%04x\n", port); } - + return(ret); } diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index 6db383cf0..babb5e1b6 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -308,7 +308,7 @@ double ide_atapi_get_period(uint8_t channel) { ide_t *ide = ide_drives[channel]; - + ide_log("ide_atapi_get_period(%i)\n", channel); if (!ide) { @@ -1357,7 +1357,7 @@ ide_write_devctl(uint16_t addr, uint8_t val, void *priv) return; dev->diag = 0; - + if ((val & 4) && !(ide->fdisk & 4)) { /* Reset toggled from 0 to 1, initiate reset procedure. */ if (ide->type == IDE_ATAPI) @@ -1575,7 +1575,7 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv) return; } } - + ide->head = val & 0xF; ide->lba = val & 0x40; ide_other->head = val & 0xF; @@ -1617,7 +1617,7 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv) ide->sc->callback = 100.0 * IDE_TIME; } else ide->atastat = DRDY_STAT; - + ide_set_callback(ide, 100.0 * IDE_TIME); return; @@ -2137,7 +2137,7 @@ ide_callback(void *priv) ide->atastat = DRDY_STAT | DSC_STAT; ide->error = 1; /*Device passed*/ ide->secount = 1; - ide->sector = 1; + ide->sector = 1; ide_set_signature(ide); @@ -2410,7 +2410,7 @@ ide_callback(void *priv) ide->cfg_spt = ide->secount; ide->cfg_hpc = ide->head + 1; } - ide->command = 0x00; + ide->command = 0x00; ide->atastat = DRDY_STAT | DSC_STAT; ide->error = 1; ide_irq_raise(ide); diff --git a/src/disk/hdc_ide_cmd640.c b/src/disk/hdc_ide_cmd640.c index a4e1c8ca6..f07caa0a8 100644 --- a/src/disk/hdc_ide_cmd640.c +++ b/src/disk/hdc_ide_cmd640.c @@ -177,7 +177,7 @@ cmd640_vlb_write(uint16_t addr, uint8_t val, void *priv) cmd640_t *dev = (cmd640_t *) priv; addr &= 0x00ff; - + switch (addr) { case 0x0078: if (dev->in_cfg) diff --git a/src/disk/hdc_ide_opti611.c b/src/disk/hdc_ide_opti611.c index 30b57249f..c8f5ac838 100644 --- a/src/disk/hdc_ide_opti611.c +++ b/src/disk/hdc_ide_opti611.c @@ -7,7 +7,7 @@ * This file is part of the 86Box distribution. * * Implementation of the OPTi 82C611/611A VLB IDE controller. - + * Authors: Miran Grca, * * Copyright 2020 Miran Grca. @@ -47,7 +47,7 @@ opti611_cfg_write(uint16_t addr, uint8_t val, void *priv) opti611_t *dev = (opti611_t *) priv; addr &= 0x0007; - + switch (addr) { case 0x0000: case 0x0001: diff --git a/src/disk/hdc_ide_sff8038i.c b/src/disk/hdc_ide_sff8038i.c index 516b8dcc7..82b417b3d 100644 --- a/src/disk/hdc_ide_sff8038i.c +++ b/src/disk/hdc_ide_sff8038i.c @@ -591,8 +591,8 @@ const device_t sff8038i_device = "sff8038i", DEVICE_PCI, 0, - sff_init, - sff_close, + sff_init, + sff_close, sff_reset, { NULL }, NULL, diff --git a/src/disk/hdc_st506_at.c b/src/disk/hdc_st506_at.c index e78871103..7177d37bd 100644 --- a/src/disk/hdc_st506_at.c +++ b/src/disk/hdc_st506_at.c @@ -742,7 +742,7 @@ mfm_init(const device_t *info) io_sethandler(0x03f6, 1, NULL, NULL, NULL, mfm_write, NULL, NULL, mfm); - timer_add(&mfm->callback_timer, do_callback, mfm, 0); + timer_add(&mfm->callback_timer, do_callback, mfm, 0); ui_sb_update_icon(SB_HDD|HDD_BUS_MFM, 0); @@ -759,7 +759,7 @@ mfm_close(void *priv) for (d=0; d<2; d++) { drive_t *drive = &mfm->drives[d]; - hdd_image_close(drive->hdd_num); + hdd_image_close(drive->hdd_num); } free(mfm); diff --git a/src/disk/hdc_st506_xt.c b/src/disk/hdc_st506_xt.c index 7d1f4ee20..814bd5c59 100644 --- a/src/disk/hdc_st506_xt.c +++ b/src/disk/hdc_st506_xt.c @@ -369,7 +369,7 @@ get_sector(hdc_t *dev, drive_t *drive, off64_t *addr) } *addr = ((((off64_t)dev->cylinder * drive->cfg_hpc) + dev->head) * drive->cfg_spt) + dev->sector; - + return(1); } @@ -619,7 +619,7 @@ st506_callback(void *priv) st506_complete(dev); break; } - break; + break; case CMD_GET_GEOMETRY_ST11: /* "Get geometry" is really "Read cylinder 0" */ if ((dev->type < 11) || (dev->type > 12)) { @@ -1115,7 +1115,7 @@ st506_read(uint16_t port, void *priv) dev->status = 0x00; dev->state = STATE_IDLE; break; - + case STATE_SEND_DATA: ret = dev->buff[dev->buff_pos++]; if (dev->buff_pos == dev->buff_cnt) { @@ -1357,7 +1357,7 @@ loadhd(hdc_t *dev, int c, int d, const char *fn) drive->present = 0; return; } - + /* Make sure we can do this. */ /* Allow 31 sectors per track on RLL controllers, for the ST225R, which is 667/2/31. */ diff --git a/src/disk/hdc_xta.c b/src/disk/hdc_xta.c index ee43461c1..31c6ada0e 100644 --- a/src/disk/hdc_xta.c +++ b/src/disk/hdc_xta.c @@ -23,7 +23,7 @@ * disk drives for this bus commonly have an 'A' suffix to * identify them as 'ATBUS'. * - * In XTA-IDE, which is slightly older, the programming + * In XTA-IDE, which is slightly older, the programming * interface of the IBM PC/XT (which used the MFM controller * from Xebec) was kept, and, so, it uses an 8bit data path. * Disk drives for this bus commonly have the 'X' suffix to @@ -38,7 +38,7 @@ * data byte per transfer. XTIDE uses regular IDE drives, * and uses the regular ATA/IDE programming interface, just * with the extra register. - * + * * NOTE: This driver implements both the 'standard' XTA interface, * sold by Western Digital as the WDXT-140 (no BIOS) and the * WDXT-150 (with BIOS), as well as some variants customized @@ -494,7 +494,7 @@ hdc_callback(void *priv) } set_intr(dev); break; - + case CMD_READ_SENSE: switch(dev->state) { case STATE_IDLE: @@ -514,7 +514,7 @@ hdc_callback(void *priv) case STATE_SDONE: set_intr(dev); } - break; + break; case CMD_READ_VERIFY: no_data = 1; @@ -584,7 +584,7 @@ do_send: } } break; - + case STATE_SDATA: if (! no_data) { /* Perform DMA. */ @@ -882,7 +882,7 @@ hdc_read(uint16_t port, void *priv) { hdc_t *dev = (hdc_t *)priv; uint8_t ret = 0xff; - + switch (port & 7) { case 0: /* DATA register */ dev->status &= ~STAT_IRQ; @@ -920,7 +920,7 @@ xta_log("DCB=%02X status=%02X comp=%02X\n", dev->dcb.cmd, dev->status, dev->com break; } - return(ret); + return(ret); } @@ -1072,7 +1072,7 @@ xta_init(const device_t *info) rom_init(&dev->bios_rom, fn, dev->rom_addr, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL); } - + /* Create a timer for command delays. */ timer_add(&dev->timer, hdc_callback, dev, 0); diff --git a/src/disk/hdd_image.c b/src/disk/hdd_image.c index 029ee03b1..5244bc638 100644 --- a/src/disk/hdd_image.c +++ b/src/disk/hdd_image.c @@ -42,7 +42,7 @@ typedef struct { - FILE *file; /* Used for HDD_IMAGE_RAW, HDD_IMAGE_HDI, and HDD_IMAGE_HDX. */ + FILE *file; /* Used for HDD_IMAGE_RAW, HDD_IMAGE_HDI, and HDD_IMAGE_HDX. */ MVHDMeta* vhd; /* Used for HDD_IMAGE_VHD. */ uint32_t base; uint32_t pos, last_sector; @@ -248,8 +248,8 @@ hdd_image_load(int id) uint64_t s = 0; char *fn = hdd[id].fn; int is_hdx[2] = { 0, 0 }; - int is_vhd[2] = { 0, 0 }; - int vhd_error = 0; + int is_vhd[2] = { 0, 0 }; + int vhd_error = 0; memset(empty_sector, 0, sizeof(empty_sector)); @@ -469,7 +469,7 @@ hdd_image_load(int id) hdd_images[id].last_sector = (uint32_t) (full_size >> 9) - 1; hdd_images[id].loaded = 1; ret = 1; - } + } return ret; } diff --git a/src/disk/hdd_table.c b/src/disk/hdd_table.c index 05eae6990..a851782f3 100644 --- a/src/disk/hdd_table.c +++ b/src/disk/hdd_table.c @@ -107,7 +107,7 @@ unsigned int hdd_table[128][3] = { { 751, 8, 26 }, { 1024, 9, 17 }, { 965, 10, 17 }, - + { 969, 5, 34 }, /* 072-079 */ { 980, 10, 17 }, { 960, 5, 35 }, diff --git a/src/disk/minivhd/CMakeLists.txt b/src/disk/minivhd/CMakeLists.txt index a96b871b8..0cba1fb39 100644 --- a/src/disk/minivhd/CMakeLists.txt +++ b/src/disk/minivhd/CMakeLists.txt @@ -15,4 +15,4 @@ add_library(minivhd STATIC cwalk.c libxml2_encoding.c minivhd_convert.c minivhd_create.c minivhd_io.c minivhd_manage.c minivhd_struct_rw.c - minivhd_util.c) \ No newline at end of file + minivhd_util.c) diff --git a/src/disk/minivhd/LICENSE b/src/disk/minivhd/LICENSE index 2997be44a..af7299185 100644 --- a/src/disk/minivhd/LICENSE +++ b/src/disk/minivhd/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/src/disk/minivhd/libxml2_encoding.c b/src/disk/minivhd/libxml2_encoding.c index cb881a89b..48c291f2f 100644 --- a/src/disk/minivhd/libxml2_encoding.c +++ b/src/disk/minivhd/libxml2_encoding.c @@ -18,7 +18,7 @@ * daniel@veillard.com * * Original code for IsoLatin1 and UTF-16 by "Martin J. Duerst" - * + * * Adapted and abridged for MiniVHD by Sherman Perry */ #include @@ -26,7 +26,7 @@ static int xmlLittleEndian = 1; /* Note: extracted from original 'void xmlInitCharEncodingHandlers(void)' function */ -void xmlEncodingInit(void) +void xmlEncodingInit(void) { unsigned short int tst = 0x1234; unsigned char *ptr = (unsigned char *) &tst; @@ -426,7 +426,7 @@ int UTF8ToUTF16BE(unsigned char* outb, int *outlen, return(*outlen); } -/* This file is licenced under the MIT licence as follows: +/* This file is licenced under the MIT licence as follows: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -444,4 +444,4 @@ NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ \ No newline at end of file +THE SOFTWARE. */ diff --git a/src/disk/minivhd/libxml2_encoding.h b/src/disk/minivhd/libxml2_encoding.h index 831aea4af..d86770b86 100644 --- a/src/disk/minivhd/libxml2_encoding.h +++ b/src/disk/minivhd/libxml2_encoding.h @@ -9,4 +9,4 @@ int UTF16LEToUTF8(unsigned char* out, int *outlen, const unsigned char* inb, int int UTF8ToUTF16LE(unsigned char* outb, int *outlen, const unsigned char* in, int *inlen); int UTF16BEToUTF8(unsigned char* out, int *outlen, const unsigned char* inb, int *inlenb); int UTF8ToUTF16BE(unsigned char* outb, int *outlen, const unsigned char* in, int *inlen); -#endif \ No newline at end of file +#endif diff --git a/src/disk/minivhd/minivhd.h b/src/disk/minivhd/minivhd.h index 0d925f71a..df3a24bb3 100644 --- a/src/disk/minivhd/minivhd.h +++ b/src/disk/minivhd/minivhd.h @@ -23,7 +23,7 @@ typedef enum MVHDError { MVHD_ERR_INVALID_GEOM, MVHD_ERR_INVALID_SIZE, MVHD_ERR_INVALID_BLOCK_SIZE, - MVHD_ERR_INVALID_PARAMS, + MVHD_ERR_INVALID_PARAMS, MVHD_ERR_CONV_SIZE, MVHD_ERR_TIMESTAMP } MVHDError; @@ -62,18 +62,18 @@ typedef struct MVHDMeta MVHDMeta; /** * \brief Output a string from a MiniVHD error number - * + * * \param [in] err is the error number to return string from - * + * * \return Error string */ const char* mvhd_strerr(MVHDError err); /** * \brief A simple test to see if a given file is a VHD - * + * * \param [in] f file to test - * + * * \retval true if f is a VHD * \retval false if f is not a VHD */ @@ -81,20 +81,20 @@ bool mvhd_file_is_vhd(FILE* f); /** * \brief Open a VHD image for reading and/or writing - * - * The returned pointer contains all required values and structures (and files) to + * + * The returned pointer contains all required values and structures (and files) to * read and write to a VHD file. - * + * * Remember to call mvhd_close() when you are finished. - * + * * \param [in] Absolute path to VHD file. Relative path will cause issues when opening * a differencing VHD file * \param [in] readonly set this to true to open the VHD in a read only manner - * \param [out] err will be set if the VHD fails to open. Value could be one of - * MVHD_ERR_MEM, MVHD_ERR_FILE, MVHD_ERR_NOT_VHD, MVHD_ERR_FOOTER_CHECKSUM, MVHD_ERR_SPARSE_CHECKSUM, + * \param [out] err will be set if the VHD fails to open. Value could be one of + * MVHD_ERR_MEM, MVHD_ERR_FILE, MVHD_ERR_NOT_VHD, MVHD_ERR_FOOTER_CHECKSUM, MVHD_ERR_SPARSE_CHECKSUM, * MVHD_ERR_TYPE, MVHD_ERR_TIMESTAMP * If MVHD_ERR_FILE is set, mvhd_errno will be set to the appropriate system errno value - * + * * \return MVHDMeta pointer. If NULL, check err. err may also be set to MVHD_ERR_TIMESTAMP if * opening a differencing VHD. */ @@ -102,52 +102,52 @@ MVHDMeta* mvhd_open(const char* path, bool readonly, int* err); /** * \brief Update the parent modified timestamp in the VHD file - * + * * Differencing VHD's use a parent last modified timestamp to try and detect if the * parent has been modified after the child has been created. However, this is rather * fragile and can be broken by moving/copying the parent. Also, MS DiskPart does not * set this timestamp in the child :( - * + * * Be careful when using this function that you don't update the timestamp after the * parent actually has been modified. - * + * * \param [in] vhdm Differencing VHD to update. * \param [out] err will be set if the timestamp could not be updated - * + * * \return non-zero on error, 0 on success */ int mvhd_diff_update_par_timestamp(MVHDMeta* vhdm, int* err); /** * \brief Create a fixed VHD image - * + * * \param [in] path is the absolute path to the image to create * \param [in] geom is the HDD geometry of the image to create. Determines final image size * \param [out] err indicates what error occurred, if any - * \param [out] progress_callback optional; if not NULL, gets called to indicate progress on the creation operation - * + * \param [out] progress_callback optional; if not NULL, gets called to indicate progress on the creation operation + * * \retval NULL if an error occurrs. Check value of *err for actual error. Otherwise returns pointer to a MVHDMeta struct */ MVHDMeta* mvhd_create_fixed(const char* path, MVHDGeom geom, int* err, mvhd_progress_callback progress_callback); /** * \brief Create sparse (dynamic) VHD image. - * + * * \param [in] path is the absolute path to the VHD file to create * \param [in] geom is the HDD geometry of the image to create. Determines final image size - * \param [out] err indicates what error occurred, if any - * + * \param [out] err indicates what error occurred, if any + * * \return NULL if an error occurrs. Check value of *err for actual error. Otherwise returns pointer to a MVHDMeta struct */ MVHDMeta* mvhd_create_sparse(const char* path, MVHDGeom geom, int* err); /** * \brief Create differencing VHD imagee. - * + * * \param [in] path is the absolute path to the VHD file to create * \param [in] par_path is the absolute path to a parent image. If NULL, a sparse image is created, otherwise create a differencing image * \param [out] err indicates what error occurred, if any - * + * * \return NULL if an error occurrs. Check value of *err for actual error. Otherwise returns pointer to a MVHDMeta struct */ MVHDMeta* mvhd_create_diff(const char* path, const char* par_path, int* err); @@ -166,104 +166,104 @@ MVHDMeta* mvhd_create_ex(MVHDCreationOptions options, int* err); /** * \brief Safely close a VHD image - * + * * \param [in] vhdm MiniVHD data structure to close */ void mvhd_close(MVHDMeta* vhdm); /** * \brief Calculate hard disk geometry from a provided size - * + * * The VHD format uses Cylinder, Heads, Sectors per Track (CHS) when accessing the disk. * The size of the disk can be determined from C * H * S * sector_size. - * + * * Note, maximum geometry size (in bytes) is 65535 * 16 * 255 * 512, which is 127GB. * However, the maximum VHD size is 2040GB. For VHDs larger than 127GB, the geometry size will be * smaller than the actual VHD size. - * + * * This function determines the appropriate CHS geometry from a provided size in bytes. - * The calculations used are those provided in "Appendix: CHS Calculation" from the document + * The calculations used are those provided in "Appendix: CHS Calculation" from the document * "Virtual Hard Disk Image Format Specification" provided by Microsoft. - * + * * \param [in] size the desired VHD image size, in bytes - * + * * \return MVHDGeom the calculated geometry. This can be used in the appropriate create functions. */ MVHDGeom mvhd_calculate_geometry(uint64_t size); /** * \brief Convert a raw disk image to a fixed VHD image - * + * * \param [in] utf8_raw_path is the path of the raw image to convert * \param [in] utf8_vhd_path is the path of the VHD to create * \param [out] err indicates what error occurred, if any - * + * * \return NULL if an error occurrs. Check value of *err for actual error. Otherwise returns pointer to a MVHDMeta struct */ MVHDMeta* mvhd_convert_to_vhd_fixed(const char* utf8_raw_path, const char* utf8_vhd_path, int* err); /** * \brief Convert a raw disk image to a sparse VHD image - * + * * \param [in] utf8_raw_path is the path of the raw image to convert * \param [in] utf8_vhd_path is the path of the VHD to create * \param [out] err indicates what error occurred, if any - * + * * \return NULL if an error occurrs. Check value of *err for actual error. Otherwise returns pointer to a MVHDMeta struct */ MVHDMeta* mvhd_convert_to_vhd_sparse(const char* utf8_raw_path, const char* utf8_vhd_path, int* err); /** * \brief Convert a VHD image to a raw disk image - * + * * \param [in] utf8_vhd_path is the path of the VHD to convert * \param [in] utf8_raw_path is the path of the raw image to create * \param [out] err indicates what error occurred, if any - * + * * \return NULL if an error occurrs. Check value of *err for actual error. Otherwise returns the raw disk image FILE pointer */ FILE* mvhd_convert_to_raw(const char* utf8_vhd_path, const char* utf8_raw_path, int *err); /** * \brief Read sectors from VHD file - * + * * Read num_sectors, beginning at offset from the VHD file into a buffer - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset the sector offset from which to start reading from * \param [in] num_sectors the number of sectors to read * \param [out] out_buff the buffer to write sector data to - * + * * \return the number of sectors that were not read, or zero */ int mvhd_read_sectors(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* out_buff); /** * \brief Write sectors to VHD file - * + * * Write num_sectors, beginning at offset from a buffer VHD file into the VHD file - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset the sector offset from which to start writing to * \param [in] num_sectors the number of sectors to write * \param [in] in_buffer the buffer to write sector data to - * + * * \return the number of sectors that were not written, or zero */ int mvhd_write_sectors(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* in_buff); /** * \brief Write zeroed sectors to VHD file - * - * Write num_sectors, beginning at offset, of zero data into the VHD file. - * We reuse the existing write functions, with a preallocated zero buffer as + * + * Write num_sectors, beginning at offset, of zero data into the VHD file. + * We reuse the existing write functions, with a preallocated zero buffer as * our source buffer. - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset the sector offset from which to start writing to * \param [in] num_sectors the number of sectors to write - * + * * \return the number of sectors that were not written, or zero */ int mvhd_format_sectors(MVHDMeta* vhdm, uint32_t offset, int num_sectors); -#endif \ No newline at end of file +#endif diff --git a/src/disk/minivhd/minivhd_convert.c b/src/disk/minivhd/minivhd_convert.c index 1de6f4613..01c430300 100644 --- a/src/disk/minivhd/minivhd_convert.c +++ b/src/disk/minivhd/minivhd_convert.c @@ -42,7 +42,7 @@ MVHDMeta* mvhd_convert_to_vhd_fixed(const char* utf8_raw_path, const char* utf8_ FILE *raw_img = mvhd_open_existing_raw_img(utf8_raw_path, &geom, err); if (raw_img == NULL) { return NULL; - } + } uint64_t size_in_bytes = mvhd_calc_size_bytes(&geom); MVHDMeta *vhdm = mvhd_create_fixed_raw(utf8_vhd_path, raw_img, size_in_bytes, &geom, err, NULL); if (vhdm == NULL) { @@ -105,4 +105,4 @@ FILE* mvhd_convert_to_raw(const char* utf8_vhd_path, const char* utf8_raw_path, mvhd_close(vhdm); mvhd_fseeko64(raw_img, 0, SEEK_SET); return raw_img; -} \ No newline at end of file +} diff --git a/src/disk/minivhd/minivhd_create.c b/src/disk/minivhd/minivhd_create.c index c47c7d82d..57f748a5c 100644 --- a/src/disk/minivhd/minivhd_create.c +++ b/src/disk/minivhd/minivhd_create.c @@ -17,10 +17,10 @@ static void mvhd_gen_footer(MVHDFooter* footer, uint64_t size_in_bytes, MVHDGeom* geom, MVHDType type, uint64_t sparse_header_off); static void mvhd_gen_sparse_header(MVHDSparseHeader* header, uint32_t num_blks, uint64_t bat_offset, uint32_t block_size_in_sectors); -static int mvhd_gen_par_loc(MVHDSparseHeader* header, - const char* child_path, - const char* par_path, - uint64_t start_offset, +static int mvhd_gen_par_loc(MVHDSparseHeader* header, + const char* child_path, + const char* par_path, + uint64_t start_offset, mvhd_utf16* w2ku_path_buff, mvhd_utf16* w2ru_path_buff, MVHDError* err); @@ -28,7 +28,7 @@ static MVHDMeta* mvhd_create_sparse_diff(const char* path, const char* par_path, /** * \brief Populate a VHD footer - * + * * \param [in] footer to populate * \param [in] size_in_bytes is the total size of the virtual hard disk in bytes * \param [in] geom to use @@ -55,7 +55,7 @@ static void mvhd_gen_footer(MVHDFooter* footer, uint64_t size_in_bytes, MVHDGeom /** * \brief Populate a VHD sparse header - * + * * \param [in] header for sparse and differencing images * \param [in] num_blks is the number of data blocks that the image contains * \param [in] bat_offset is the absolute file offset for start of the Block Allocation Table @@ -73,7 +73,7 @@ static void mvhd_gen_sparse_header(MVHDSparseHeader* header, uint32_t num_blks, /** * \brief Generate parent locators for differencing VHD images - * + * * \param [in] header the sparse header to populate with parent locator entries * \param [in] child_path is the full path to the VHD being created * \param [in] par_path is the full path to the parent image @@ -81,14 +81,14 @@ static void mvhd_gen_sparse_header(MVHDSparseHeader* header, uint32_t num_blks, * \param [out] w2ku_path_buff is a buffer containing the full path to the parent, encoded as UTF16-LE * \param [out] w2ru_path_buff is a buffer containing the relative path to the parent, encoded as UTF16-LE * \param [out] err indicates what error occurred, if any - * + * * \retval 0 if success * \retval < 0 if an error occurrs. Check value of *err for actual error */ -static int mvhd_gen_par_loc(MVHDSparseHeader* header, - const char* child_path, - const char* par_path, - uint64_t start_offset, +static int mvhd_gen_par_loc(MVHDSparseHeader* header, + const char* child_path, + const char* par_path, + uint64_t start_offset, mvhd_utf16* w2ku_path_buff, mvhd_utf16* w2ru_path_buff, MVHDError* err) { @@ -97,7 +97,7 @@ static int mvhd_gen_par_loc(MVHDSparseHeader* header, int rv = 0; char* par_filename; size_t par_fn_len; - char rel_path[MVHD_MAX_PATH_BYTES] = {0}; + char rel_path[MVHD_MAX_PATH_BYTES] = {0}; char child_dir[MVHD_MAX_PATH_BYTES] = {0}; size_t child_dir_len; if (strlen(child_path) < sizeof child_dir) { @@ -115,18 +115,18 @@ static int mvhd_gen_par_loc(MVHDSparseHeader* header, *err = MVHD_ERR_PATH_LEN; rv = -1; goto end; - } + } /* We have our paths, now store the parent filename directly in the sparse header. */ - int outlen = sizeof header->par_utf16_name; + int outlen = sizeof header->par_utf16_name; int utf_ret; - utf_ret = UTF8ToUTF16BE((unsigned char*)header->par_utf16_name, &outlen, (const unsigned char*)par_filename, (int*)&par_fn_len); + utf_ret = UTF8ToUTF16BE((unsigned char*)header->par_utf16_name, &outlen, (const unsigned char*)par_filename, (int*)&par_fn_len); if (utf_ret < 0) { mvhd_set_encoding_err(utf_ret, (int*)err); rv = -1; goto end; } - - /* And encode the paths to UTF16-LE */ + + /* And encode the paths to UTF16-LE */ size_t par_path_len = strlen(par_path); outlen = sizeof *w2ku_path_buff * MVHD_MAX_PATH_CHARS; utf_ret = UTF8ToUTF16LE((unsigned char*)w2ku_path_buff, &outlen, (const unsigned char*)par_path, (int*)&par_path_len); @@ -136,7 +136,7 @@ static int mvhd_gen_par_loc(MVHDSparseHeader* header, goto end; } int w2ku_len = utf_ret; - outlen = sizeof *w2ru_path_buff * MVHD_MAX_PATH_CHARS; + outlen = sizeof *w2ru_path_buff * MVHD_MAX_PATH_CHARS; utf_ret = UTF8ToUTF16LE((unsigned char*)w2ru_path_buff, &outlen, (const unsigned char*)rel_path, (int*)&rel_len); if (utf_ret < 0) { mvhd_set_encoding_err(utf_ret, (int*)err); @@ -144,16 +144,16 @@ static int mvhd_gen_par_loc(MVHDSparseHeader* header, goto end; } int w2ru_len = utf_ret; - /** + /** * Finally populate the parent locaters in the sparse header. * This is the information needed to find the paths saved elsewhere - * in the VHD image + * in the VHD image */ /* Note about the plat_data_space field: The VHD spec says this field stores the number of sectors needed to store the locator path. - * However, Hyper-V and VPC store the number of bytes, not the number of sectors, and will refuse to open VHDs which have the + * However, Hyper-V and VPC store the number of bytes, not the number of sectors, and will refuse to open VHDs which have the * number of sectors in this field. - * See https://stackoverflow.com/questions/40760181/mistake-in-virtual-hard-disk-image-format-specification + * See https://stackoverflow.com/questions/40760181/mistake-in-virtual-hard-disk-image-format-specification */ header->par_loc_entry[0].plat_code = MVHD_DIF_LOC_W2KU; header->par_loc_entry[0].plat_data_len = (uint32_t)w2ku_len; @@ -176,13 +176,13 @@ MVHDMeta* mvhd_create_fixed(const char* path, MVHDGeom geom, int* err, mvhd_prog /** * \brief internal function that implements public mvhd_create_fixed() functionality - * + * * Contains one more parameter than the public function, to allow using an existing * raw disk image as the data source for the new fixed VHD. - * + * * \param [in] raw_image file handle to a raw disk image to populate VHD */ -MVHDMeta* mvhd_create_fixed_raw(const char* path, FILE* raw_img, uint64_t size_in_bytes, MVHDGeom* geom, int* err, mvhd_progress_callback progress_callback) { +MVHDMeta* mvhd_create_fixed_raw(const char* path, FILE* raw_img, uint64_t size_in_bytes, MVHDGeom* geom, int* err, mvhd_progress_callback progress_callback) { uint8_t img_data[MVHD_SECTOR_SIZE] = {0}; uint8_t footer_buff[MVHD_FOOTER_SIZE] = {0}; MVHDMeta* vhdm = calloc(1, sizeof *vhdm); @@ -211,17 +211,17 @@ MVHDMeta* mvhd_create_fixed_raw(const char* path, FILE* raw_img, uint64_t size_i *err = MVHD_ERR_CONV_SIZE; goto cleanup_vhdm; } - mvhd_gen_footer(&vhdm->footer, raw_size, geom, MVHD_TYPE_FIXED, 0); + mvhd_gen_footer(&vhdm->footer, raw_size, geom, MVHD_TYPE_FIXED, 0); mvhd_fseeko64(raw_img, 0, SEEK_SET); - for (s = 0; s < size_sectors; s++) { + for (s = 0; s < size_sectors; s++) { fread(img_data, sizeof img_data, 1, raw_img); fwrite(img_data, sizeof img_data, 1, f); if (progress_callback) progress_callback(s + 1, size_sectors); } } else { - mvhd_gen_footer(&vhdm->footer, size_in_bytes, geom, MVHD_TYPE_FIXED, 0); - for (s = 0; s < size_sectors; s++) { + mvhd_gen_footer(&vhdm->footer, size_in_bytes, geom, MVHD_TYPE_FIXED, 0); + for (s = 0; s < size_sectors; s++) { fwrite(img_data, sizeof img_data, 1, f); if (progress_callback) progress_callback(s + 1, size_sectors); @@ -244,14 +244,14 @@ end: /** * \brief Create sparse or differencing VHD image. - * + * * \param [in] path is the absolute path to the VHD file to create * \param [in] par_path is the absolute path to a parent image. If NULL, a sparse image is created, otherwise create a differencing image * \param [in] size_in_bytes is the total size in bytes of the virtual hard disk image * \param [in] geom is the HDD geometry of the image to create. Determines final image size * \param [in] block_size_in_sectors is the block size in sectors * \param [out] err indicates what error occurred, if any - * + * * \return NULL if an error occurrs. Check value of *err for actual error. Otherwise returns pointer to a MVHDMeta struct */ static MVHDMeta* mvhd_create_sparse_diff(const char* path, const char* par_path, uint64_t size_in_bytes, MVHDGeom* geom, uint32_t block_size_in_sectors, int* err) { @@ -290,8 +290,8 @@ static MVHDMeta* mvhd_create_sparse_diff(const char* path, const char* par_path, } else if (geom == NULL || (geom->cyl == 0 || geom->heads == 0 || geom->spt == 0)) { *err = MVHD_ERR_INVALID_GEOM; goto cleanup_vhdm; - } - + } + FILE* f = mvhd_fopen(path, "wb+", err); if (f == NULL) { goto cleanup_vhdm; @@ -308,9 +308,9 @@ static MVHDMeta* mvhd_create_sparse_diff(const char* path, const char* par_path, fwrite(footer_buff, sizeof footer_buff, 1, f); /** * Calculate the number of (2MB or 512KB) data blocks required to store the entire - * contents of the disk image, followed by the number of sectors the + * contents of the disk image, followed by the number of sectors the * BAT occupies in the image. Note, the BAT is sector aligned, and is padded - * to the next sector boundary + * to the next sector boundary * */ uint32_t size_in_sectors = (uint32_t)(size_in_bytes / MVHD_SECTOR_SIZE); uint32_t num_blks = size_in_sectors / block_size_in_sectors; @@ -323,10 +323,10 @@ static MVHDMeta* mvhd_create_sparse_diff(const char* path, const char* par_path, } /* Storing the BAT directly following the footer and header */ uint64_t bat_offset = MVHD_FOOTER_SIZE + MVHD_SPARSE_SIZE; - uint64_t par_loc_offset = 0; + uint64_t par_loc_offset = 0; /** - * If creating a differencing VHD, populate the sparse header with additional + * If creating a differencing VHD, populate the sparse header with additional * data about the parent image, and where to find it, and it's last modified timestamp * */ if (par_vhdm != NULL) { @@ -337,12 +337,12 @@ static MVHDMeta* mvhd_create_sparse_diff(const char* path, const char* par_path, */ w2ku_path_buff = calloc(MVHD_MAX_PATH_CHARS, sizeof * w2ku_path_buff); if (w2ku_path_buff == NULL) { - *err = MVHD_ERR_MEM; + *err = MVHD_ERR_MEM; goto end; } w2ru_path_buff = calloc(MVHD_MAX_PATH_CHARS, sizeof * w2ru_path_buff); if (w2ru_path_buff == NULL) { - *err = MVHD_ERR_MEM; + *err = MVHD_ERR_MEM; goto end; } memcpy(vhdm->sparse.par_uuid, par_vhdm->footer.uuid, sizeof vhdm->sparse.par_uuid); @@ -362,7 +362,7 @@ static MVHDMeta* mvhd_create_sparse_diff(const char* path, const char* par_path, mvhd_write_empty_sectors(f, 5); /** * If creating a differencing VHD, the paths to the parent image need to be written - * tp the file. Both absolute and relative paths are written + * tp the file. Both absolute and relative paths are written * */ if (par_vhdm != NULL) { uint64_t curr_pos = (uint64_t)mvhd_ftello64(f); @@ -399,9 +399,9 @@ cleanup_par_vhdm: if (par_vhdm != NULL) { mvhd_close(par_vhdm); } -end: - free(w2ku_path_buff); - free(w2ru_path_buff); +end: + free(w2ku_path_buff); + free(w2ru_path_buff); return vhdm; } @@ -415,7 +415,7 @@ MVHDMeta* mvhd_create_diff(const char* path, const char* par_path, int* err) { } MVHDMeta* mvhd_create_ex(MVHDCreationOptions options, int* err) { - uint32_t geom_sector_size; + uint32_t geom_sector_size; switch (options.type) { case MVHD_TYPE_FIXED: @@ -482,4 +482,4 @@ MVHDMeta* mvhd_create_ex(MVHDCreationOptions options, int* err) { } return NULL; /* Make the compiler happy */ -} \ No newline at end of file +} diff --git a/src/disk/minivhd/minivhd_create.h b/src/disk/minivhd/minivhd_create.h index 9840d19ff..203834a71 100644 --- a/src/disk/minivhd/minivhd_create.h +++ b/src/disk/minivhd/minivhd_create.h @@ -5,4 +5,4 @@ MVHDMeta* mvhd_create_fixed_raw(const char* path, FILE* raw_img, uint64_t size_in_bytes, MVHDGeom* geom, int* err, mvhd_progress_callback progress_callback); -#endif \ No newline at end of file +#endif diff --git a/src/disk/minivhd/minivhd_internal.h b/src/disk/minivhd/minivhd_internal.h index ea75284f8..54b304830 100644 --- a/src/disk/minivhd/minivhd_internal.h +++ b/src/disk/minivhd/minivhd_internal.h @@ -13,7 +13,7 @@ #define MVHD_MAX_SIZE_IN_BYTES 0x1fe00000000 #define MVHD_SPARSE_BLK 0xffffffff -/* For simplicity, we don't handle paths longer than this +/* For simplicity, we don't handle paths longer than this * Note, this is the max path in characters, as that is what * Windows uses */ @@ -93,4 +93,4 @@ struct MVHDMeta { } format_buffer; }; -#endif \ No newline at end of file +#endif diff --git a/src/disk/minivhd/minivhd_io.c b/src/disk/minivhd/minivhd_io.c index 4169d66f1..74cc62883 100644 --- a/src/disk/minivhd/minivhd_io.c +++ b/src/disk/minivhd/minivhd_io.c @@ -11,7 +11,7 @@ #include "minivhd_internal.h" #include "minivhd_util.h" -/* The following bit array macros adapted from +/* The following bit array macros adapted from http://www.mathcs.emory.edu/~cheung/Courses/255/Syllabus/1-C-intro/bit-array.html */ #define VHD_SETBIT(A,k) ( A[(k/8)] |= (0x80 >> (k%8)) ) @@ -26,11 +26,11 @@ static void mvhd_write_curr_sect_bitmap(MVHDMeta* vhdm); /** * \brief Check that we will not be overflowing buffers - * + * * \param [in] offset The offset from which we are beginning from * \param [in] num_sectors The number of sectors which we desire to read/write * \param [in] total_sectors The total number of sectors available - * \param [out] transfer_sect The number of sectors to actually write. + * \param [out] transfer_sect The number of sectors to actually write. * This may be lower than num_sectors if offset + num_sectors >= total_sectors * \param [out] trunc_sectors The number of sectors truncated if transfer_sectors < num_sectors */ @@ -52,10 +52,10 @@ void mvhd_write_empty_sectors(FILE* f, int sector_count) { /** * \brief Read the sector bitmap for a block. - * - * If the block is sparse, the sector bitmap in memory will be + * + * If the block is sparse, the sector bitmap in memory will be * zeroed. Otherwise, the sector bitmap is read from the VHD file. - * + * * \param [in] vhdm MiniVHD data structure * \param [in] blk The block for which to read the sector bitmap from */ @@ -71,7 +71,7 @@ static void mvhd_read_sect_bitmap(MVHDMeta* vhdm, int blk) { /** * \brief Write the current sector bitmap in memory to file - * + * * \param [in] vhdm MiniVHD data structure */ static void mvhd_write_curr_sect_bitmap(MVHDMeta* vhdm) { @@ -84,7 +84,7 @@ static void mvhd_write_curr_sect_bitmap(MVHDMeta* vhdm) { /** * \brief Write block offset from memory into file - * + * * \param [in] vhdm MiniVHD data structure * \param [in] blk The block for which to write the offset for */ @@ -97,15 +97,15 @@ static void mvhd_write_bat_entry(MVHDMeta* vhdm, int blk) { /** * \brief Create an empty block in a sparse or differencing VHD image - * - * VHD images store data in blocks, which are typically 4096 sectors in size - * (~2MB). These blocks may be stored on disk in any order. Blocks are created + * + * VHD images store data in blocks, which are typically 4096 sectors in size + * (~2MB). These blocks may be stored on disk in any order. Blocks are created * on demand when required. - * - * This function creates new, empty blocks, by replacing the footer at the end of the file + * + * This function creates new, empty blocks, by replacing the footer at the end of the file * and then re-inserting the footer at the new file end. The BAT table entry for the * new block is updated with the new offset. - * + * * \param [in] vhdm MiniVHD data structure * \param [in] blk The block number to create */ @@ -176,7 +176,7 @@ int mvhd_sparse_read(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* out addr = ((int64_t)vhdm->block_offset[blk] + vhdm->bitmap.sector_count + sib) * MVHD_SECTOR_SIZE; mvhd_fseeko64(vhdm->f, addr, SEEK_SET); } - } + } if (VHD_TESTBIT(vhdm->bitmap.curr_bitmap, sib)) { fread(buff, MVHD_SECTOR_SIZE, 1, vhdm->f); } else { @@ -245,7 +245,7 @@ int mvhd_sparse_diff_write(MVHDMeta* vhdm, uint32_t offset, int num_sectors, voi for (s = offset; s < ls; s++) { blk = s / vhdm->sect_per_block; sib = s % vhdm->sect_per_block; - if (vhdm->bitmap.curr_block != blk && prev_blk >= 0) { + if (vhdm->bitmap.curr_block != blk && prev_blk >= 0) { /* Write the sector bitmap for the previous block, before we replace it. */ mvhd_write_curr_sect_bitmap(vhdm); } @@ -254,9 +254,9 @@ int mvhd_sparse_diff_write(MVHDMeta* vhdm, uint32_t offset, int num_sectors, voi zero either way */ mvhd_read_sect_bitmap(vhdm, blk); mvhd_create_block(vhdm, blk); - } + } if (blk != prev_blk) { - if (vhdm->bitmap.curr_block != blk) { + if (vhdm->bitmap.curr_block != blk) { mvhd_read_sect_bitmap(vhdm, blk); mvhd_fseeko64(vhdm->f, (uint64_t)sib * MVHD_SECTOR_SIZE, SEEK_CUR); } else { diff --git a/src/disk/minivhd/minivhd_io.h b/src/disk/minivhd/minivhd_io.h index cdbfa6d77..7ffd10f49 100644 --- a/src/disk/minivhd/minivhd_io.h +++ b/src/disk/minivhd/minivhd_io.h @@ -4,10 +4,10 @@ /** * \brief Write zero filled sectors to file. - * - * Note, the caller should set the file position before calling this + * + * Note, the caller should set the file position before calling this * function for correct operation. - * + * * \param [in] f File to write sectors to * \param [in] sector_count The number of sectors to write */ @@ -15,16 +15,16 @@ void mvhd_write_empty_sectors(FILE* f, int sector_count); /** * \brief Read a fixed VHD image - * - * Fixed VHD images are essentially raw image files with a footer tacked on + * + * Fixed VHD images are essentially raw image files with a footer tacked on * the end. They are therefore straightforward to write - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset Sector offset to read from * \param [in] num_sectors The desired number of sectors to read - * \param [out] out_buff An output buffer to store read sectors. Must be + * \param [out] out_buff An output buffer to store read sectors. Must be * large enough to hold num_sectors worth of sectors. - * + * * \retval 0 num_sectors were read from file * \retval >0 < num_sectors were read from file */ @@ -32,19 +32,19 @@ int mvhd_fixed_read(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* out_ /** * \brief Read a sparse VHD image - * - * Sparse, or dynamic images are VHD images that grow as data is written to them. - * - * This function implements the logic to read sectors from the file, taking into - * account the fact that blocks may be stored on disk in any order, and that the + * + * Sparse, or dynamic images are VHD images that grow as data is written to them. + * + * This function implements the logic to read sectors from the file, taking into + * account the fact that blocks may be stored on disk in any order, and that the * read could cross block boundaries. - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset Sector offset to read from * \param [in] num_sectors The desired number of sectors to read - * \param [out] out_buff An output buffer to store read sectors. Must be + * \param [out] out_buff An output buffer to store read sectors. Must be * large enough to hold num_sectors worth of sectors. - * + * * \retval 0 num_sectors were read from file * \retval >0 < num_sectors were read from file */ @@ -52,22 +52,22 @@ int mvhd_sparse_read(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* out /** * \brief Read a differencing VHD image - * - * Differencing images are a variant of a sparse image. They contain the grow-on-demand - * properties of sparse images, but also reference a parent image. Data is read from the + * + * Differencing images are a variant of a sparse image. They contain the grow-on-demand + * properties of sparse images, but also reference a parent image. Data is read from the * child image only if it is newer than the data stored in the parent image. - * - * This function implements the logic to read sectors from the child, or a parent image. - * Differencing images may have a differencing image as a parent, creating a chain of images. - * There is no theoretical chain length limit, although I do not consider long chains to be + * + * This function implements the logic to read sectors from the child, or a parent image. + * Differencing images may have a differencing image as a parent, creating a chain of images. + * There is no theoretical chain length limit, although I do not consider long chains to be * advisable. Verifying the parent-child relationship is not very robust. - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset Sector offset to read from * \param [in] num_sectors The desired number of sectors to read - * \param [out] out_buff An output buffer to store read sectors. Must be + * \param [out] out_buff An output buffer to store read sectors. Must be * large enough to hold num_sectors worth of sectors. - * + * * \retval 0 num_sectors were read from file * \retval >0 < num_sectors were read from file */ @@ -75,16 +75,16 @@ int mvhd_diff_read(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* out_b /** * \brief Write to a fixed VHD image - * - * Fixed VHD images are essentially raw image files with a footer tacked on + * + * Fixed VHD images are essentially raw image files with a footer tacked on * the end. They are therefore straightforward to write - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset Sector offset to write to * \param [in] num_sectors The desired number of sectors to write - * \param [in] in_buff A source buffer to write sectors from. Must be + * \param [in] in_buff A source buffer to write sectors from. Must be * large enough to hold num_sectors worth of sectors. - * + * * \retval 0 num_sectors were written to file * \retval >0 < num_sectors were written to file */ @@ -92,24 +92,24 @@ int mvhd_fixed_write(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* in_ /** * \brief Write to a sparse or differencing VHD image - * - * Sparse, or dynamic images are VHD images that grow as data is written to them. - * - * Differencing images are a variant of a sparse image. They contain the grow-on-demand - * properties of sparse images, but also reference a parent image. Data is always written - * to the child image. This makes writing to differencing images essentially identical to + * + * Sparse, or dynamic images are VHD images that grow as data is written to them. + * + * Differencing images are a variant of a sparse image. They contain the grow-on-demand + * properties of sparse images, but also reference a parent image. Data is always written + * to the child image. This makes writing to differencing images essentially identical to * writing to sparse images, hence they use the same function. - * - * This function implements the logic to write sectors to the file, taking into - * account the fact that blocks may be stored on disk in any order, and that the + * + * This function implements the logic to write sectors to the file, taking into + * account the fact that blocks may be stored on disk in any order, and that the * write operation could cross block boundaries. - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset Sector offset to write to * \param [in] num_sectors The desired number of sectors to write - * \param [in] in_buff A source buffer to write sectors from. Must be + * \param [in] in_buff A source buffer to write sectors from. Must be * large enough to hold num_sectors worth of sectors. - * + * * \retval 0 num_sectors were written to file * \retval >0 < num_sectors were written to file */ @@ -117,16 +117,16 @@ int mvhd_sparse_diff_write(MVHDMeta* vhdm, uint32_t offset, int num_sectors, voi /** * \brief A no-op function to "write" to read-only VHD images - * + * * \param [in] vhdm MiniVHD data structure * \param [in] offset Sector offset to write to * \param [in] num_sectors The desired number of sectors to write - * \param [in] in_buff A source buffer to write sectors from. Must be + * \param [in] in_buff A source buffer to write sectors from. Must be * large enough to hold num_sectors worth of sectors. - * + * * \retval 0 num_sectors were written to file * \retval >0 < num_sectors were written to file */ int mvhd_noop_write(MVHDMeta* vhdm, uint32_t offset, int num_sectors, void* in_buff); -#endif \ No newline at end of file +#endif diff --git a/src/disk/minivhd/minivhd_manage.c b/src/disk/minivhd/minivhd_manage.c index e9473c0e3..f76826566 100644 --- a/src/disk/minivhd/minivhd_manage.c +++ b/src/disk/minivhd/minivhd_manage.c @@ -39,7 +39,7 @@ static int mvhd_init_sector_bitmap(MVHDMeta* vhdm, MVHDError* err); /** * \brief Populate data stuctures with content from a VHD footer - * + * * \param [in] vhdm MiniVHD data structure */ static void mvhd_read_footer(MVHDMeta* vhdm) { @@ -51,7 +51,7 @@ static void mvhd_read_footer(MVHDMeta* vhdm) { /** * \brief Populate data stuctures with content from a VHD sparse header - * + * * \param [in] vhdm MiniVHD data structure */ static void mvhd_read_sparse_header(MVHDMeta* vhdm) { @@ -63,9 +63,9 @@ static void mvhd_read_sparse_header(MVHDMeta* vhdm) { /** * \brief Validate VHD footer checksum - * + * * This works by generating a checksum from the footer, and comparing it against the stored checksum. - * + * * \param [in] vhdm MiniVHD data structure */ static bool mvhd_footer_checksum_valid(MVHDMeta* vhdm) { @@ -74,9 +74,9 @@ static bool mvhd_footer_checksum_valid(MVHDMeta* vhdm) { /** * \brief Validate VHD sparse header checksum - * + * * This works by generating a checksum from the sparse header, and comparing it against the stored checksum. - * + * * \param [in] vhdm MiniVHD data structure */ static bool mvhd_sparse_checksum_valid(MVHDMeta* vhdm) { @@ -85,14 +85,14 @@ static bool mvhd_sparse_checksum_valid(MVHDMeta* vhdm) { /** * \brief Read BAT into MiniVHD data structure - * - * The Block Allocation Table (BAT) is the structure in a sparse and differencing VHD which stores + * + * The Block Allocation Table (BAT) is the structure in a sparse and differencing VHD which stores * the 4-byte sector offsets for each data block. This function allocates enough memory to contain * the entire BAT, and then reads the contents of the BAT into the buffer. - * + * * \param [in] vhdm MiniVHD data structure * \param [out] err this is populated with MVHD_ERR_MEM if the calloc fails - * + * * \retval -1 if an error occurrs. Check value of err in this case * \retval 0 if the function call succeeds */ @@ -112,7 +112,7 @@ static int mvhd_read_bat(MVHDMeta *vhdm, MVHDError* err) { /** * \brief Perform a one-time calculation of some sparse VHD values - * + * * \param [in] vhdm MiniVHD data structure */ static void mvhd_calc_sparse_values(MVHDMeta* vhdm) { @@ -126,14 +126,14 @@ static void mvhd_calc_sparse_values(MVHDMeta* vhdm) { /** * \brief Allocate memory for a sector bitmap. - * + * * Each data block is preceded by a sector bitmap. Each bit indicates whether the corresponding sector - * is considered 'clean' or 'dirty' (for sparse VHD images), or whether to read from the parent or current + * is considered 'clean' or 'dirty' (for sparse VHD images), or whether to read from the parent or current * image (for differencing images). - * + * * \param [in] vhdm MiniVHD data structure * \param [out] err this is populated with MVHD_ERR_MEM if the calloc fails - * + * * \retval -1 if an error occurrs. Check value of err in this case * \retval 0 if the function call succeeds */ @@ -149,17 +149,17 @@ static int mvhd_init_sector_bitmap(MVHDMeta* vhdm, MVHDError* err) { /** * \brief Check if the path for a given platform code exists - * - * From the available paths, both relative and absolute, construct a full path + * + * From the available paths, both relative and absolute, construct a full path * and attempt to open a file at that path. - * - * Note, this function makes no attempt to verify that the path is the correct + * + * Note, this function makes no attempt to verify that the path is the correct * VHD image, or even a VHD image at all. - * + * * \param [in] paths a struct containing all available paths to work with - * \param [in] the platform code to try and obtain a path for. Setting this to zero + * \param [in] the platform code to try and obtain a path for. Setting this to zero * will try using the directory of the child image - * + * * \retval true if a file is found * \retval false if a file is not found */ @@ -195,23 +195,23 @@ static bool mvhd_parent_path_exists(struct MVHDPaths* paths, uint32_t plat_code) /** * \brief attempt to obtain a file path to a file that may be a valid VHD image - * - * Differential VHD images store both a UTF-16BE file name (or path), and up to - * eight "parent locator" entries. Using this information, this function tries to + * + * Differential VHD images store both a UTF-16BE file name (or path), and up to + * eight "parent locator" entries. Using this information, this function tries to * find a parent image. - * + * * This function does not verify if the path returned is a valid parent image. - * + * * \param [in] vhdm current MiniVHD data structure * \param [out] err any errors that may occurr. Check this if NULL is returned - * - * \return a pointer to the global string `tmp_open_path`, or NULL if a path could + * + * \return a pointer to the global string `tmp_open_path`, or NULL if a path could * not be found, or some error occurred */ static char* mvhd_get_diff_parent_path(MVHDMeta* vhdm, int* err) { int utf_outlen, utf_inlen, utf_ret; char* par_fp = NULL; - /* We can't resolve relative paths if we don't have an absolute + /* We can't resolve relative paths if we don't have an absolute path to work with */ if (!cwk_path_is_absolute((const char*)vhdm->filename)) { *err = MVHD_ERR_PATH_REL; @@ -255,7 +255,7 @@ static char* mvhd_get_diff_parent_path(MVHDMeta* vhdm, int* err) { } mvhd_fseeko64(vhdm->f, vhdm->sparse.par_loc_entry[i].plat_data_offset, SEEK_SET); fread(paths->tmp_src_path, sizeof (uint8_t), utf_inlen, vhdm->f); - /* Note, the W2*u parent locators are UTF-16LE, unlike the filename field previously obtained, + /* Note, the W2*u parent locators are UTF-16LE, unlike the filename field previously obtained, which is UTF-16BE */ utf_ret = UTF16LEToUTF8(loc_path, &utf_outlen, (const unsigned char*)paths->tmp_src_path, &utf_inlen); if (utf_ret < 0) { @@ -282,7 +282,7 @@ static char* mvhd_get_diff_parent_path(MVHDMeta* vhdm, int* err) { /* If we reach this point, we could not find a path with a valid file */ par_fp = NULL; *err = MVHD_ERR_PAR_NOT_FOUND; - + paths_cleanup: free(paths); paths = NULL; @@ -292,10 +292,10 @@ end: /** * \brief Attach the read/write function pointers to read/write functions - * - * Depending on the VHD type, different sector reading and writing functions are used. + * + * Depending on the VHD type, different sector reading and writing functions are used. * The functions are called via function pointers stored in the vhdm struct. - * + * * \param [in] vhdm MiniVHD data structure */ static void mvhd_assign_io_funcs(MVHDMeta* vhdm) { @@ -336,7 +336,7 @@ MVHDGeom mvhd_calculate_geometry(uint64_t size) { if (ts > 65535 * 16 * 255) { ts = 65535 * 16 * 255; } - if (ts >= 65535 * 16 * 63) { + if (ts >= 65535 * 16 * 63) { spt = 255; heads = 16; cth = ts / spt; @@ -532,4 +532,4 @@ int mvhd_format_sectors(MVHDMeta* vhdm, uint32_t offset, int num_sectors) { } vhdm->write_sectors(vhdm, offset, remain, vhdm->format_buffer.zero_data); return 0; -} \ No newline at end of file +} diff --git a/src/disk/minivhd/minivhd_struct_rw.c b/src/disk/minivhd/minivhd_struct_rw.c index c77fa600a..5285f8a68 100644 --- a/src/disk/minivhd/minivhd_struct_rw.c +++ b/src/disk/minivhd/minivhd_struct_rw.c @@ -24,7 +24,7 @@ static void mvhd_next_struct_to_buffer(void* struct_memb, size_t memb_size, bool /** * \brief Get the next field from a buffer and store it in a struct member, converting endian if necessary - * + * * \param [out] struct_memb struct member to save the field to * \param [in] memb_size the size of struct_memb, in bytes * \param [in] req_endian is the field a value that requires endian conversion (eg: uint16, uint32) @@ -50,7 +50,7 @@ static void mvhd_next_buffer_to_struct(void* struct_memb, size_t memb_size, bool /** * \brief Save a struct member into a buffer, converting endian if necessary - * + * * \param [in] struct_memb struct member read from * \param [in] memb_size the size of struct_memb, in bytes * \param [in] req_endian is the field a value that requires endian conversion (eg: uint16, uint32) @@ -164,4 +164,4 @@ void mvhd_header_to_buffer(MVHDSparseHeader* header, uint8_t* buffer) { mvhd_next_struct_to_buffer(&header->par_loc_entry[i].plat_data_offset, sizeof header->par_loc_entry[i].plat_data_offset, true, &buff_ptr); } mvhd_next_struct_to_buffer(&header->reserved_2, sizeof header->reserved_2, false, &buff_ptr); -} \ No newline at end of file +} diff --git a/src/disk/minivhd/minivhd_struct_rw.h b/src/disk/minivhd/minivhd_struct_rw.h index ee49bb696..39441fb39 100644 --- a/src/disk/minivhd/minivhd_struct_rw.h +++ b/src/disk/minivhd/minivhd_struct_rw.h @@ -5,7 +5,7 @@ /** * \brief Save the contents of a VHD footer from a buffer to a struct - * + * * \param [out] footer save contents of buffer into footer * \param [in] buffer VHD footer in raw bytes */ @@ -13,7 +13,7 @@ void mvhd_buffer_to_footer(MVHDFooter* footer, uint8_t* buffer); /** * \brief Save the contents of a VHD sparse header from a buffer to a struct - * + * * \param [out] header save contents of buffer into header * \param [in] buffer VHD header in raw bytes */ @@ -21,7 +21,7 @@ void mvhd_buffer_to_header(MVHDSparseHeader* header, uint8_t* buffer); /** * \brief Save the contents of a VHD footer struct to a buffer - * + * * \param [in] footer save contents of struct into buffer * \param [out] buffer VHD footer in raw bytes */ @@ -29,10 +29,10 @@ void mvhd_footer_to_buffer(MVHDFooter* footer, uint8_t* buffer); /** * \brief Save the contents of a VHD sparse header struct to a buffer - * + * * \param [in] header save contents of struct into buffer * \param [out] buffer VHD sparse header in raw bytes */ void mvhd_header_to_buffer(MVHDSparseHeader* header, uint8_t* buffer); -#endif \ No newline at end of file +#endif diff --git a/src/disk/minivhd/minivhd_util.h b/src/disk/minivhd/minivhd_util.h index df6841009..227570ce2 100644 --- a/src/disk/minivhd/minivhd_util.h +++ b/src/disk/minivhd/minivhd_util.h @@ -20,9 +20,9 @@ uint64_t mvhd_to_be64(uint64_t val); /** * \brief Check if provided buffer begins with the string "conectix" - * + * * \param [in] buffer The buffer to compare. Must be at least 8 bytes in length - * + * * \return true if the buffer begins with "conectix" * \return false if the buffer does not begin with "conectix" */ @@ -30,7 +30,7 @@ bool mvhd_is_conectix_str(const void* buffer); /** * \brief Generate a raw 16 byte UUID - * + * * \param [out] uuid A 16 byte buffer in which the generated UUID will be stored to */ void mvhd_generate_uuid(uint8_t *uuid); @@ -42,9 +42,9 @@ uint32_t vhd_calc_timestamp(void); /** * \brief Convert an epoch timestamp to a VHD timestamp - * + * * \param [in] ts epoch timestamp to convert. - * + * * \return The adjusted timestamp, or 0 if the input timestamp is * earlier that 1 Janurary 2000 */ @@ -52,26 +52,26 @@ uint32_t mvhd_epoch_to_vhd_ts(time_t ts); /** * \brief Return the created time from a VHD image - * + * * \param [in] vhdm Pointer to the MiniVHD metadata structure - * + * * \return The created time, as a Unix timestamp */ time_t vhd_get_created_time(MVHDMeta *vhdm); /** * \brief Cross platform, unicode filepath opening - * - * This function accounts for the fact that fopen() handles file paths differently compared to other - * operating systems. Windows version of fopen() will not handle multi byte encoded text like UTF-8. - * - * Unicode filepath support on Windows requires using the _wfopen() function, which expects UTF-16LE + * + * This function accounts for the fact that fopen() handles file paths differently compared to other + * operating systems. Windows version of fopen() will not handle multi byte encoded text like UTF-8. + * + * Unicode filepath support on Windows requires using the _wfopen() function, which expects UTF-16LE * encoded path and modestring. - * + * * \param [in] path The filepath to open as a UTF-8 string * \param [in] mode The mode string to use (eg: "rb+"") * \param [out] err The error value, if an error occurrs - * + * * \return a FILE pointer if successful, NULL otherwise. If NULL, check the value of err */ FILE* mvhd_fopen(const char* path, const char* mode, int* err); @@ -83,52 +83,52 @@ MVHDGeom mvhd_get_geometry(MVHDMeta* vhdm); /** * \brief Generate VHD footer checksum - * + * * \param [in] vhdm MiniVHD data structure */ uint32_t mvhd_gen_footer_checksum(MVHDFooter* footer); /** * \brief Generate VHD sparse header checksum - * + * * \param [in] vhdm MiniVHD data structure */ uint32_t mvhd_gen_sparse_checksum(MVHDSparseHeader* header); /** * \brief Get current position in file stream - * - * This is a portable version of the POSIX ftello64(). * + * + * This is a portable version of the POSIX ftello64(). * */ int64_t mvhd_ftello64(FILE* stream); /** * \brief Reposition the file stream's position - * - * This is a portable version of the POSIX fseeko64(). * + * + * This is a portable version of the POSIX fseeko64(). * */ int mvhd_fseeko64(FILE* stream, int64_t offset, int origin); /** * \brief Calculate the CRC32 of a data buffer. - * + * * This function can be used for verifying data integrity. - * + * * \param [in] data The data buffer * \param [in] n_bytes The size of the data buffer in bytes - * + * * \return The CRC32 of the data buffer */ uint32_t mvhd_crc32(const void* data, size_t n_bytes); /** * \brief Calculate the file modification timestamp. - * + * * This function is primarily to help protect differencing VHD's - * + * * \param [in] path the UTF-8 file path * \param [out] err The error value, if an error occurrs - * + * * \return The file modified timestamp, in VHD compatible timestamp. * 'err' will be set to non-zero on error */ diff --git a/src/disk/mo.c b/src/disk/mo.c index d6924a438..a07349e59 100644 --- a/src/disk/mo.c +++ b/src/disk/mo.c @@ -104,7 +104,7 @@ const uint8_t mo_command_flags[0x100] = IMPLEMENTED | CHECK_READY, /* 0xA8 */ 0, IMPLEMENTED | CHECK_READY, /* 0xAA */ - 0, + 0, IMPLEMENTED | CHECK_READY | NONDATA, /* 0xAC */ 0, IMPLEMENTED | CHECK_READY, /* 0xAE */ @@ -377,7 +377,7 @@ mo_load(mo_t *dev, char *fn) break; } } - + if (!found) return mo_load_abort(dev); @@ -1141,7 +1141,7 @@ mo_erase(mo_t *dev) /*SCSI Sense Initialization*/ void mo_sense_code_ok(mo_t *dev) -{ +{ mo_sense_key = SENSE_NONE; mo_asc = 0; mo_ascq = 0; @@ -1260,7 +1260,7 @@ mo_reset(scsi_common_t *sc) static void mo_request_sense(mo_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc) -{ +{ /*Will return 18 bytes of 0*/ if (alloc_length != 0) { memset(buffer, 0, alloc_length); @@ -1527,7 +1527,7 @@ mo_command(scsi_common_t *sc, uint8_t *cdb) /*TODO: Implement*/ mo_invalid_field(dev); return; - + case GPCMD_WRITE_6: case GPCMD_WRITE_10: case GPCMD_WRITE_AND_VERIFY_10: diff --git a/src/disk/zip.c b/src/disk/zip.c index 38cbf2eda..1f45e4737 100644 --- a/src/disk/zip.c +++ b/src/disk/zip.c @@ -1215,7 +1215,7 @@ zip_insert(zip_t *dev) /*SCSI Sense Initialization*/ void zip_sense_code_ok(zip_t *dev) -{ +{ zip_sense_key = SENSE_NONE; zip_asc = 0; zip_ascq = 0; @@ -1334,7 +1334,7 @@ zip_reset(scsi_common_t *sc) static void zip_request_sense(zip_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc) -{ +{ /*Will return 18 bytes of 0*/ if (alloc_length != 0) { memset(buffer, 0, alloc_length); diff --git a/src/dma.c b/src/dma.c index 26fe1a6bf..876c34356 100644 --- a/src/dma.c +++ b/src/dma.c @@ -52,7 +52,7 @@ static uint16_t dma_sg_base; static uint16_t dma16_buffer[65536]; static uint32_t dma_mask; -static struct { +static struct { int xfr_command, xfr_channel; int byte_ptr; @@ -760,11 +760,11 @@ dma16_read(uint16_t addr, void *priv) case 6: /*Address registers*/ dma_wp[1] ^= 1; if (dma_ps2.is_ps2) { - if (dma_wp[1]) + if (dma_wp[1]) return(dma[channel].ac); return((dma[channel].ac >> 8) & 0xff); } - if (dma_wp[1]) + if (dma_wp[1]) return((dma[channel].ac >> 1) & 0xff); return((dma[channel].ac >> 9) & 0xff); @@ -1338,7 +1338,7 @@ _dma_writew(uint32_t addr, uint16_t val, dma_t *dma_c) dma_bm_write(addr, (uint8_t *) &val, 2, dma_transfer_size(dma_c)); } else { _dma_write(addr, val & 0xff, dma_c); - _dma_write(addr + 1, val >> 8, dma_c); + _dma_write(addr + 1, val >> 8, dma_c); } } diff --git a/src/fifo8.c b/src/fifo8.c index 34e90d591..a6f7f1e0e 100644 --- a/src/fifo8.c +++ b/src/fifo8.c @@ -113,4 +113,3 @@ uint32_t fifo8_num_used(Fifo8 *fifo) { return fifo->num; } - diff --git a/src/floppy/CMakeLists.txt b/src/floppy/CMakeLists.txt index 4517bc634..a30bebd71 100644 --- a/src/floppy/CMakeLists.txt +++ b/src/floppy/CMakeLists.txt @@ -14,4 +14,4 @@ # add_library(fdd OBJECT fdd.c fdc.c fdc_magitronic.c fdc_pii15xb.c fdi2raw.c fdd_common.c - fdd_86f.c fdd_fdi.c fdd_imd.c fdd_img.c fdd_json.c fdd_mfm.c fdd_td0.c) \ No newline at end of file + fdd_86f.c fdd_fdi.c fdd_imd.c fdd_img.c fdd_json.c fdd_mfm.c fdd_td0.c) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 0a8ecafc4..21c114d90 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -168,7 +168,7 @@ fdc_card_get_from_internal_name(char *s) return(c); c++; } - + return(0); } @@ -1098,7 +1098,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) } fdd_readsector(real_drive(fdc, fdc->drive), fdc->sector, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]); break; - + case 0x07: /* Recalibrate */ fdc->rw_drive = fdc->params[0] & 3; fdc->stat = (1 << real_drive(fdc, fdc->drive)); @@ -1133,7 +1133,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) break; case 0x0a: /* Read sector ID */ fdc_rate(fdc, fdc->drive); - fdc->head = (fdc->params[0] & 4) ? 1 : 0; + fdc->head = (fdc->params[0] & 4) ? 1 : 0; fdd_set_head(real_drive(fdc, fdc->drive), (fdc->params[0] & 4) ? 1 : 0); if ((real_drive(fdc, fdc->drive) != 1) || fdc->drv2en) { fdd_readaddress(real_drive(fdc, fdc->drive), fdc->head, fdc->rate); @@ -2512,7 +2512,7 @@ const device_t fdc_dp8473_device = { 0, FDC_FLAG_AT | FDC_FLAG_NSC, fdc_init, - fdc_close, + fdc_close, fdc_reset, { NULL }, NULL, NULL }; @@ -2523,7 +2523,7 @@ const device_t fdc_um8398_device = { 0, FDC_FLAG_UMC, fdc_init, - fdc_close, + fdc_close, fdc_reset, { NULL }, NULL, NULL }; diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index 3339aa6a1..661520e02 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -9,7 +9,7 @@ * Implementation of the DTK MiniMicro series of Floppy Disk Controllers. * Original code from VARCem. Fully rewritten, fixed and improved for 86Box. * - * Author: Fred N. van Kempen, , + * Author: Fred N. van Kempen, , * Tiseno100 * * Copyright 2019 Fred N. van Kempen. diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index 72f79940b..0c55471bc 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -493,7 +493,7 @@ fdd_load(int drive, char *fn) if (fseek(f, -1, SEEK_END) == -1) fatal("fdd_load(): Error seeking to the end of the file\n"); size = ftell(f) + 1; - fclose(f); + fclose(f); while (loaders[c].ext) { if (!strcasecmp(p, (char *) loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1)) { driveloaders[drive] = c; diff --git a/src/floppy/fdd_img.c b/src/floppy/fdd_img.c index aec27415f..a8704e7ff 100644 --- a/src/floppy/fdd_img.c +++ b/src/floppy/fdd_img.c @@ -398,7 +398,7 @@ write_back(int drive) if (dev->f == NULL) return; if (dev->disk_at_once) return; - + if (fseek(dev->f, dev->base + (dev->track * dev->sectors * ssize * dev->sides), SEEK_SET) == -1) pclog("IMG write_back(): Error seeking to the beginning of the file\n"); for (side = 0; side < dev->sides; side++) { diff --git a/src/floppy/fdi2raw.c b/src/floppy/fdi2raw.c index ffa722d74..04c422d21 100644 --- a/src/floppy/fdi2raw.c +++ b/src/floppy/fdi2raw.c @@ -2209,4 +2209,3 @@ int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int trac } return outlen; } - diff --git a/src/floppy/lzf/LICENSE b/src/floppy/lzf/LICENSE index ee54ff717..b3a284d08 100644 --- a/src/floppy/lzf/LICENSE +++ b/src/floppy/lzf/LICENSE @@ -24,4 +24,3 @@ OF THE POSSIBILITY OF SUCH DAMAGE. Alternatively, the following files carry an additional notice that explicitly allows relicensing under the GPLv2: lzf.c lzf.h lzfP.h lzf_c.c lzf_d.c - diff --git a/src/floppy/lzf/README b/src/floppy/lzf/README index 0734ebe06..ebfd97e07 100644 --- a/src/floppy/lzf/README +++ b/src/floppy/lzf/README @@ -25,5 +25,3 @@ DESCRIPTION AUTHOR This library was written by Marc Lehmann (See also http://software.schmorp.de/pkg/liblzf). - - diff --git a/src/floppy/lzf/crc32.h b/src/floppy/lzf/crc32.h index cf8f6d409..5a88cd5ff 100644 --- a/src/floppy/lzf/crc32.h +++ b/src/floppy/lzf/crc32.h @@ -62,4 +62,3 @@ static const u32 crc_32_tab[] = #define crc32(crc,byte) (crc_32_tab[(u8)(crc) ^ (u8)(byte)] ^ ((crc) >> 8)) #endif - diff --git a/src/floppy/lzf/lzf.c b/src/floppy/lzf/lzf.c index bedfdb6fe..657bc4b04 100644 --- a/src/floppy/lzf/lzf.c +++ b/src/floppy/lzf/lzf.c @@ -1,16 +1,16 @@ /* * Copyright (c) 2006 Stefan Traby - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -534,4 +534,3 @@ main (int argc, char *argv[]) exit (rc ? 1 : 0); } - diff --git a/src/floppy/lzf/lzf.h b/src/floppy/lzf/lzf.h index 919b6e6be..061d4cea9 100644 --- a/src/floppy/lzf/lzf.h +++ b/src/floppy/lzf/lzf.h @@ -1,16 +1,16 @@ /* * Copyright (c) 2000-2008 Marc Alexander Lehmann - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -73,7 +73,7 @@ * and lzf_c.c. * */ -unsigned int +unsigned int lzf_compress (const void *const in_data, unsigned int in_len, void *out_data, unsigned int out_len); @@ -92,9 +92,8 @@ lzf_compress (const void *const in_data, unsigned int in_len, * * This function is very fast, about as fast as a copying loop. */ -unsigned int +unsigned int lzf_decompress (const void *const in_data, unsigned int in_len, void *out_data, unsigned int out_len); #endif - diff --git a/src/floppy/lzf/lzfP.h b/src/floppy/lzf/lzfP.h index 11c965ca3..6bb81d562 100644 --- a/src/floppy/lzf/lzfP.h +++ b/src/floppy/lzf/lzfP.h @@ -1,16 +1,16 @@ /* * Copyright (c) 2000-2007 Marc Alexander Lehmann - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -182,4 +182,3 @@ typedef LZF_HSLOT LZF_STATE[1 << (HLOG)]; #endif #endif - diff --git a/src/floppy/lzf/lzf_c.c b/src/floppy/lzf/lzf_c.c index 8ba4d0b84..8a52d68c0 100644 --- a/src/floppy/lzf/lzf_c.c +++ b/src/floppy/lzf/lzf_c.c @@ -1,16 +1,16 @@ /* * Copyright (c) 2000-2010 Marc Alexander Lehmann - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -290,4 +290,3 @@ lzf_compress (const void *const in_data, unsigned int in_len, return op - (u8 *)out_data; } - diff --git a/src/floppy/lzf/lzf_d.c b/src/floppy/lzf/lzf_d.c index 8433b8f1f..f838ba674 100644 --- a/src/floppy/lzf/lzf_d.c +++ b/src/floppy/lzf/lzf_d.c @@ -1,16 +1,16 @@ /* * Copyright (c) 2000-2010 Marc Alexander Lehmann - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -52,7 +52,7 @@ #endif #endif -unsigned int +unsigned int lzf_decompress (const void *const in_data, unsigned int in_len, void *out_data, unsigned int out_len) { @@ -182,4 +182,3 @@ lzf_decompress (const void *const in_data, unsigned int in_len, return op - (u8 *)out_data; } - diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index c8fbb41ff..ee78c2650 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -14,4 +14,4 @@ # add_library(game OBJECT gameport.c joystick_standard.c - joystick_ch_flightstick_pro.c joystick_sw_pad.c joystick_tm_fcs.c) \ No newline at end of file + joystick_ch_flightstick_pro.c joystick_sw_pad.c joystick_tm_fcs.c) diff --git a/src/game/joystick_ch_flightstick_pro.c b/src/game/joystick_ch_flightstick_pro.c index b6cd8911f..5a44c2312 100644 --- a/src/game/joystick_ch_flightstick_pro.c +++ b/src/game/joystick_ch_flightstick_pro.c @@ -58,7 +58,7 @@ static void ch_flightstick_pro_close(void *p) static uint8_t ch_flightstick_pro_read(void *p) { uint8_t ret = 0xf0; - + if (JOYSTICK_PRESENT(0)) { if (joystick_state[0].button[0]) diff --git a/src/game/joystick_standard.c b/src/game/joystick_standard.c index c06540b15..f091841b0 100644 --- a/src/game/joystick_standard.c +++ b/src/game/joystick_standard.c @@ -58,7 +58,7 @@ static void joystick_standard_close(void *p) static uint8_t joystick_standard_read(void *p) { uint8_t ret = 0xf0; - + if (JOYSTICK_PRESENT(0)) { if (joystick_state[0].button[0]) @@ -73,14 +73,14 @@ static uint8_t joystick_standard_read(void *p) if (joystick_state[1].button[1]) ret &= ~0x80; } - + return ret; } static uint8_t joystick_standard_read_4button(void *p) { uint8_t ret = 0xf0; - + if (JOYSTICK_PRESENT(0)) { if (joystick_state[0].button[0]) @@ -92,7 +92,7 @@ static uint8_t joystick_standard_read_4button(void *p) if (joystick_state[0].button[3]) ret &= ~0x80; } - + return ret; } @@ -218,13 +218,13 @@ static int joystick_standard_read_axis_8button(void *p, int axis) case 2: if (joystick_state[0].button[4]) return -32767; - if (joystick_state[0].button[6]) + if (joystick_state[0].button[6]) return 32768; return 0; case 3: if (joystick_state[0].button[5]) return -32767; - if (joystick_state[0].button[7]) + if (joystick_state[0].button[7]) return 32768; return 0; default: diff --git a/src/game/joystick_sw_pad.c b/src/game/joystick_sw_pad.c index 31e0c8624..8c0235046 100644 --- a/src/game/joystick_sw_pad.c +++ b/src/game/joystick_sw_pad.c @@ -74,7 +74,7 @@ typedef struct int poll_clock; uint64_t poll_data; int poll_mode; - + pc_timer_t trigger_timer; int data_mode; } sw_data; @@ -82,7 +82,7 @@ typedef struct static void sw_timer_over(void *p) { sw_data *sw = (sw_data *)p; - + sw->poll_clock = !sw->poll_clock; if (sw->poll_clock) @@ -109,13 +109,13 @@ static void sw_trigger_timer_over(void *p) static int sw_parity(uint16_t data) { int bits_set = 0; - + while (data) { bits_set++; data &= (data - 1); } - + return bits_set & 1; } @@ -133,7 +133,7 @@ static void *sw_init(void) static void sw_close(void *p) { sw_data *sw = (sw_data *)p; - + free(sw); } @@ -146,10 +146,10 @@ static uint8_t sw_read(void *p) return 0xff; if (timer_is_enabled(&sw->poll_timer)) - { + { if (sw->poll_clock) temp |= 0x10; - + if (sw->poll_mode) temp |= (sw->poll_data & 7) << 5; else @@ -172,19 +172,19 @@ static void sw_write(void *p) if (!JOYSTICK_PRESENT(0)) return; - + timer_process(); if (!sw->poll_left) { sw->poll_clock = 1; timer_set_delay_u64(&sw->poll_timer, TIMER_USEC * 50); - + if (time_since_last > 9900 && time_since_last < 9940) { sw->poll_mode = 0; sw->poll_left = 49; - sw->poll_data = 0x2400ull | (0x1830ull << 15) | (0x19b0ull << 30); + sw->poll_data = 0x2400ull | (0x1830ull << 15) | (0x19b0ull << 30); } else { @@ -192,7 +192,7 @@ static void sw_write(void *p) sw->poll_mode = sw->data_mode; sw->data_mode = !sw->data_mode; - + if (sw->poll_mode) { sw->poll_left = 1; @@ -208,7 +208,7 @@ static void sw_write(void *p) { uint16_t data = 0x3fff; int b; - + if (!JOYSTICK_PRESENT(c)) break; @@ -243,7 +243,7 @@ static void sw_write(void *p) } } } - + timer_disable(&sw->trigger_timer); } @@ -251,7 +251,7 @@ static int sw_read_axis(void *p, int axis) { if (!JOYSTICK_PRESENT(0)) return AXIS_NOT_PRESENT; - + return 0; /*No analogue support on Sidewinder game pad*/ } @@ -261,7 +261,7 @@ static void sw_a0_over(void *p) timer_set_delay_u64(&sw->trigger_timer, TIMER_USEC * 10000); } - + const joystick_if_t joystick_sw_pad = { "Microsoft SideWinder Pad", diff --git a/src/game/joystick_tm_fcs.c b/src/game/joystick_tm_fcs.c index 2c6a7d90f..e3dbae1e3 100644 --- a/src/game/joystick_tm_fcs.c +++ b/src/game/joystick_tm_fcs.c @@ -58,7 +58,7 @@ static void tm_fcs_close(void *p) static uint8_t tm_fcs_read(void *p) { uint8_t ret = 0xf0; - + if (JOYSTICK_PRESENT(0)) { if (joystick_state[0].button[0]) diff --git a/src/include/86box/bswap.h b/src/include/86box/bswap.h index a49c4f1bc..cd5a71425 100644 --- a/src/include/86box/bswap.h +++ b/src/include/86box/bswap.h @@ -34,8 +34,9 @@ * Boston, MA 02111-1307 * USA. */ + #ifndef BSWAP_H -#define BSWAP_H +# define BSWAP_H #include @@ -228,4 +229,4 @@ static __inline void cpu_to_be32wu(uint32_t *p, uint32_t v) #undef le_bswaps #undef be_bswaps -#endif /* BSWAP_H */ +#endif /*BSWAP_H*/ diff --git a/src/include/86box/cassette.h b/src/include/86box/cassette.h index a22b4c41f..524c5d055 100644 --- a/src/include/86box/cassette.h +++ b/src/include/86box/cassette.h @@ -21,7 +21,7 @@ #ifndef PCE_IBMPC_CASSETTE_H -#define PCE_IBMPC_CASSETTE_H 1 +# define PCE_IBMPC_CASSETTE_H 1 #include @@ -170,4 +170,4 @@ extern int cassette_ui_writeprot; extern const device_t cassette_device; -#endif +#endif /*PCE_IBMPC_CASSETTE_H*/ diff --git a/src/include/86box/cdrom.h b/src/include/86box/cdrom.h index 4245a0a66..ad9b23886 100644 --- a/src/include/86box/cdrom.h +++ b/src/include/86box/cdrom.h @@ -15,7 +15,7 @@ * Copyright 2016-2019 Miran Grca. */ #ifndef EMU_CDROM_H -#define EMU_CDROM_H +# define EMU_CDROM_H #define CDROM_NUM 4 diff --git a/src/include/86box/cdrom_image.h b/src/include/86box/cdrom_image.h index 415956e56..db3e903f8 100644 --- a/src/include/86box/cdrom_image.h +++ b/src/include/86box/cdrom_image.h @@ -1,8 +1,9 @@ /* Copyright holders: RichardG867, Tenshi see COPYING for more details */ + #ifndef CDROM_IMAGE_H -#define CDROM_IMAGE_H +# define CDROM_IMAGE_H /* this header file lists the functions provided by various platform specific cdrom-ioctl files */ @@ -23,4 +24,4 @@ extern void cdrom_set_null_handler(uint8_t id); } #endif -#endif /* ! CDROM_IMAGE_H */ +#endif /*CDROM_IMAGE_H*/ diff --git a/src/include/86box/cdrom_image_backend.h b/src/include/86box/cdrom_image_backend.h index 74be1df69..d447dc559 100644 --- a/src/include/86box/cdrom_image_backend.h +++ b/src/include/86box/cdrom_image_backend.h @@ -19,8 +19,9 @@ * Copyright 2017-2020 Fred N. van Kempen. * Copyright 2002-2020 The DOSBox Team. */ + #ifndef CDROM_IMAGE_BACKEND_H -#define CDROM_IMAGE_BACKEND_H +# define CDROM_IMAGE_BACKEND_H #define RAW_SECTOR_SIZE 2352 #define COOKED_SECTOR_SIZE 2048 @@ -93,4 +94,4 @@ extern int cdi_has_audio_track(cd_img_t *cdi); -#endif /* ! CDROM_IMAGE_BACKEND_H */ +#endif /*CDROM_IMAGE_BACKEND_H*/ diff --git a/src/include/86box/device.h b/src/include/86box/device.h index eaae682f4..8c71a6ee3 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -40,17 +40,17 @@ # define EMU_DEVICE_H -#define CONFIG_STRING 0 -#define CONFIG_INT 1 -#define CONFIG_BINARY 2 -#define CONFIG_SELECTION 3 -#define CONFIG_MIDI 4 -#define CONFIG_FNAME 5 -#define CONFIG_SPINNER 6 -#define CONFIG_HEX16 7 -#define CONFIG_HEX20 8 -#define CONFIG_MAC 9 -#define CONFIG_MIDI_IN 10 +#define CONFIG_STRING 0 +#define CONFIG_INT 1 +#define CONFIG_BINARY 2 +#define CONFIG_SELECTION 3 +#define CONFIG_MIDI_OUT 4 +#define CONFIG_FNAME 5 +#define CONFIG_SPINNER 6 +#define CONFIG_HEX16 7 +#define CONFIG_HEX20 8 +#define CONFIG_MAC 9 +#define CONFIG_MIDI_IN 10 enum { diff --git a/src/include/86box/fdd_86f.h b/src/include/86box/fdd_86f.h index 81ac9ed0f..da7e7b819 100644 --- a/src/include/86box/fdd_86f.h +++ b/src/include/86box/fdd_86f.h @@ -43,7 +43,7 @@ #else #define pre_gap1 0 #endif - + #define pre_track pre_gap1 + length_gap1 #define pre_gap length_sync + length_am + 4 + length_crc #define pre_data length_sync + length_am diff --git a/src/include/86box/filters.h b/src/include/86box/filters.h index 98eff66e2..65885d4d7 100644 --- a/src/include/86box/filters.h +++ b/src/include/86box/filters.h @@ -1,3 +1,6 @@ +#ifndef EMU_FILTERS_H +# define EMU_FILTERS_H + #define NCoef 2 /* fc=150Hz */ @@ -29,7 +32,7 @@ static inline float adgold_highpass_iir(int i, float NewSample) { y[i][0] = ACoef[0] * x[i][0]; for(n=1; n<=NCoef; n++) y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n]; - + return y[i][0]; } @@ -62,7 +65,7 @@ static inline float adgold_lowpass_iir(int i, float NewSample) { y[i][0] = ACoef[0] * x[i][0]; for(n=1; n<=NCoef; n++) y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n]; - + return y[i][0]; } @@ -95,7 +98,7 @@ static inline float adgold_pseudo_stereo_iir(float NewSample) { y[0] = ACoef[0] * x[0]; for(n=1; n<=NCoef; n++) y[0] += ACoef[n] * x[n] - BCoef[n] * y[n]; - + return y[0]; } @@ -112,7 +115,7 @@ static inline float dss_iir(float NewSample) { -1.41898265221812010000, 0.55326988968868285000 }; - + static float y[NCoef+1]; /* output samples */ static float x[NCoef+1]; /* input samples */ int n; @@ -161,7 +164,7 @@ static inline float dac_iir(int i, float NewSample) { y[i][0] = ACoef[0] * x[i][0]; for(n=1; n<=NCoef; n++) y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n]; - + return y[i][0]; } @@ -347,7 +350,7 @@ static inline double sb_iir(int c, int i, double NewSample) { -1.41898265221812010000, 0.55326988968868285000 }; - + static double y[2][2][NCoef+1]; /* output samples */ static double x[2][2][NCoef+1]; /* input samples */ int n; @@ -396,6 +399,8 @@ static inline double low_fir_sb16(int c, int i, double NewSample) if (pos[c] > SB16_NCoef) pos[c] = 0; } - + return out; } + +#endif /*EMU_FILTERS_H*/ diff --git a/src/include/86box/flash.h b/src/include/86box/flash.h index d16814b75..531cc7037 100644 --- a/src/include/86box/flash.h +++ b/src/include/86box/flash.h @@ -14,6 +14,9 @@ * Copyright 2020 Miran Grca. */ +#ifndef EMU_FLASH_H +# define EMU_FLASH_H + extern const device_t catalyst_flash_device; extern const device_t intel_flash_bxt_ami_device; @@ -25,4 +28,6 @@ extern const device_t sst_flash_29ee020_device; extern const device_t winbond_flash_w29c020_device; extern const device_t sst_flash_39sf010_device; extern const device_t sst_flash_39sf020_device; -extern const device_t sst_flash_39sf040_device; \ No newline at end of file +extern const device_t sst_flash_39sf040_device; + +#endif /*EMU_FLASH_H*/ diff --git a/src/include/86box/hdc_ide_sff8038i.h b/src/include/86box/hdc_ide_sff8038i.h index 700684dae..1c058772c 100644 --- a/src/include/86box/hdc_ide_sff8038i.h +++ b/src/include/86box/hdc_ide_sff8038i.h @@ -16,6 +16,9 @@ * Copyright 2016-2020 Miran Grca. */ +#ifndef EMU_HDC_IDE_SFF8038I_H +# define EMU_HDC_IDE_SFF8038I_H + typedef struct { uint8_t command, status, @@ -56,3 +59,5 @@ extern void sff_set_irq_mode(sff8038i_t *dev, int channel, int irq_mode); extern void sff_set_irq_pin(sff8038i_t *dev, int irq_pin); extern void sff_set_irq_level(sff8038i_t *dev, int channel, int irq_level); + +#endif /*EMU_HDC_IDE_SFF8038I_H*/ diff --git a/src/include/86box/i82335.h b/src/include/86box/i82335.h index 7cb4c4ef3..705f1b085 100644 --- a/src/include/86box/i82335.h +++ b/src/include/86box/i82335.h @@ -1 +1,6 @@ +#ifndef EMU_I82335_H +# define EMU_I82335_H + extern void i82335_init(void); + +#endif /*EMU_I82335_H*/ diff --git a/src/include/86box/ibm_5161.h b/src/include/86box/ibm_5161.h index 69f9d23a8..858c18786 100644 --- a/src/include/86box/ibm_5161.h +++ b/src/include/86box/ibm_5161.h @@ -12,4 +12,9 @@ * Copyright 2016-2018 Miran Grca. */ +#ifndef EMU_IBM_5161_H +# define EMU_IBM_5161_H + extern const device_t ibm_5161_device; + +#endif /*EMU_IBM_5151_H*/ diff --git a/src/include/86box/isamem.h b/src/include/86box/isamem.h index 90d7666ec..b02c27374 100644 --- a/src/include/86box/isamem.h +++ b/src/include/86box/isamem.h @@ -44,8 +44,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ISAMEM_H -# define ISAMEM_H + +#ifndef EMU_ISAMEM_H +# define EMU_ISAMEM_H #define ISAMEM_MAX 4 /* max #cards in system */ @@ -74,4 +75,4 @@ extern const device_t *isamem_get_device(int t); #endif -#endif /*ISAMEM_H*/ +#endif /*EMU_ISAMEM_H*/ diff --git a/src/include/86box/isapnp.h b/src/include/86box/isapnp.h index 87272d86a..3b2aa1859 100644 --- a/src/include/86box/isapnp.h +++ b/src/include/86box/isapnp.h @@ -14,6 +14,7 @@ * * Copyright 2021 RichardG. */ + #ifndef EMU_ISAPNP_H # define EMU_ISAPNP_H # include diff --git a/src/include/86box/isartc.h b/src/include/86box/isartc.h index e2cb82b97..391b9f642 100644 --- a/src/include/86box/isartc.h +++ b/src/include/86box/isartc.h @@ -44,8 +44,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ISARTC_H -# define ISARTC_H + +#ifndef EMU_ISARTC_H +# define EMU_ISARTC_H #ifdef __cplusplus @@ -67,4 +68,4 @@ extern const device_t *isartc_get_device(int t); #endif -#endif /*ISARTC_H*/ +#endif /*EMU_ISARTC_H*/ diff --git a/src/include/86box/joystick_ch_flightstick_pro.h b/src/include/86box/joystick_ch_flightstick_pro.h index 1358f9d69..bd2984438 100644 --- a/src/include/86box/joystick_ch_flightstick_pro.h +++ b/src/include/86box/joystick_ch_flightstick_pro.h @@ -35,4 +35,9 @@ * USA. */ +#ifndef EMU_JOYSTICK_CH_FLIGHTSTICK_PRO_H +# define EMU_JOYSTICK_CH_FLIGHTSTICK_PRO_H + extern const joystick_if_t joystick_ch_flightstick_pro; + +#endif /*EMU_JOYSTICK_CH_FLIGHTSTICK_PRO_H*/ diff --git a/src/include/86box/joystick_standard.h b/src/include/86box/joystick_standard.h index 9bc86b204..c60828afb 100644 --- a/src/include/86box/joystick_standard.h +++ b/src/include/86box/joystick_standard.h @@ -35,6 +35,9 @@ * USA. */ +#ifndef EMU_JOYSTICK_STANDARD_H +# define EMU_JOYSTICK_STANDARD_H + extern const joystick_if_t joystick_2axis_2button; extern const joystick_if_t joystick_2axis_4button; extern const joystick_if_t joystick_3axis_2button; @@ -42,3 +45,5 @@ extern const joystick_if_t joystick_3axis_4button; extern const joystick_if_t joystick_4axis_4button; extern const joystick_if_t joystick_2axis_6button; extern const joystick_if_t joystick_2axis_8button; + +#endif /*EMU_JOYSTICK_STANDARD_H*/ diff --git a/src/include/86box/joystick_sw_pad.h b/src/include/86box/joystick_sw_pad.h index 2f62aab19..daa671028 100644 --- a/src/include/86box/joystick_sw_pad.h +++ b/src/include/86box/joystick_sw_pad.h @@ -35,4 +35,9 @@ * USA. */ +#ifndef EMU_JOYSTICK_SW_PAD_H +# define EMU_JOYSTICK_SW_PAD_H + extern const joystick_if_t joystick_sw_pad; + +#endif /*EMU_JOYSTICK_SW_PAD_H*/ diff --git a/src/include/86box/joystick_tm_fcs.h b/src/include/86box/joystick_tm_fcs.h index 60067d88a..78b85e9a0 100644 --- a/src/include/86box/joystick_tm_fcs.h +++ b/src/include/86box/joystick_tm_fcs.h @@ -35,4 +35,9 @@ * USA. */ +#ifndef EMU_JOYSTICK_TM_FCS_H +# define EMU_JOYSTICK_TM_FCS_H + extern const joystick_if_t joystick_tm_fcs; + +#endif /*EMU_JOYSTICK_TM_FCS_H*/ diff --git a/src/include/86box/keyboard.h b/src/include/86box/keyboard.h index 206feeefc..b87f2552a 100644 --- a/src/include/86box/keyboard.h +++ b/src/include/86box/keyboard.h @@ -18,6 +18,7 @@ * Copyright 2016-2019 Miran Grca. * Copyright 2017-2019 Fred N. van Kempen. */ + #ifndef EMU_KEYBOARD_H # define EMU_KEYBOARD_H diff --git a/src/include/86box/language.h b/src/include/86box/language.h index 9a5397c6b..6090ee611 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -16,6 +16,7 @@ * * Copyright 2017,2018 Fred N. van Kempen. */ + #ifndef LANG_UAGE_H # define LANG_UAGE_H diff --git a/src/include/86box/log.h b/src/include/86box/log.h index 210f2c5a7..3b4235b2c 100644 --- a/src/include/86box/log.h +++ b/src/include/86box/log.h @@ -16,6 +16,7 @@ * Copyright 2021 Miran Grca. * Copyright 2021 Fred N. van Kempen. */ + #ifndef EMU_LOG_H # define EMU_LOG_H diff --git a/src/include/86box/m_amstrad.h b/src/include/86box/m_amstrad.h index b190ab0a5..d498be6c3 100644 --- a/src/include/86box/m_amstrad.h +++ b/src/include/86box/m_amstrad.h @@ -16,6 +16,10 @@ * * Copyright 2008-2019 Sarah Walker. */ + +#ifndef MACHINE_AMSTRAD_H +# define MACHINE_AMSTRAD_H + extern int amstrad_latch; enum @@ -24,3 +28,5 @@ enum AMSTRAD_SW9, AMSTRAD_SW10 }; + +#endif /*MACHINE_AMSTRAD.H*/ diff --git a/src/include/86box/m_at_t3100e.h b/src/include/86box/m_at_t3100e.h index 216f490e2..8943f7f2f 100644 --- a/src/include/86box/m_at_t3100e.h +++ b/src/include/86box/m_at_t3100e.h @@ -36,6 +36,7 @@ * Boston, MA 02111-1307 * USA. */ + #ifndef MACHINE_T3100E_H # define MACHINE_T3100E_H diff --git a/src/include/86box/m_xt_t1000.h b/src/include/86box/m_xt_t1000.h index 8945b24e8..4220f1548 100644 --- a/src/include/86box/m_xt_t1000.h +++ b/src/include/86box/m_xt_t1000.h @@ -36,6 +36,7 @@ * Boston, MA 02111-1307 * USA. */ + #ifndef MACHINE_T1000_H # define MACHINE_T1000_H diff --git a/src/include/86box/m_xt_xi8088.h b/src/include/86box/m_xt_xi8088.h index f263e385d..e2421fa0a 100644 --- a/src/include/86box/m_xt_xi8088.h +++ b/src/include/86box/m_xt_xi8088.h @@ -1,3 +1,6 @@ +#ifndef MACHINE_XI80888_H +# define MACHINE_XI80888_H + #include <86box/device.h> extern const device_t xi8088_device; @@ -6,3 +9,5 @@ uint8_t xi8088_turbo_get(); void xi8088_turbo_set(uint8_t value); void xi8088_bios_128kb_set(int val); int xi8088_bios_128kb(); + +#endif /*MACHINE_XI80888_H*/ diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index f3fb0928f..7764f1347 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -18,6 +18,7 @@ * Copyright 2016-2020 Miran Grca. * Copyright 2017-2020 Fred N. van Kempen. */ + #ifndef EMU_MACHINE_H # define EMU_MACHINE_H @@ -702,6 +703,7 @@ extern int machine_xt_mpc1600_init(const machine_t *); extern int machine_xt_pcspirit_init(const machine_t *); extern int machine_xt_pc700_init(const machine_t *); extern int machine_xt_pc500_init(const machine_t *); +extern int machine_xt_znic_init(const machine_t *); extern int machine_xt_iskra3104_init(const machine_t *); diff --git a/src/include/86box/mca.h b/src/include/86box/mca.h index e0def3fe5..68aa2563f 100644 --- a/src/include/86box/mca.h +++ b/src/include/86box/mca.h @@ -1,3 +1,6 @@ +#ifndef EMU_MCA_H +# define EMU_MCA_H + extern void mca_init(int nr_cards); extern void mca_add(uint8_t (*read)(int addr, void *priv), void (*write)(int addr, uint8_t val, void *priv), uint8_t (*feedb)(void *priv), void (*reset)(void *priv), void *priv); extern void mca_set_index(int index); @@ -6,4 +9,6 @@ extern void mca_write(uint16_t port, uint8_t val); extern uint8_t mca_feedb(void); extern void mca_reset(void); -extern void ps2_cache_clean(void); \ No newline at end of file +extern void ps2_cache_clean(void); + +#endif /*EMU_MCA_H*/ diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 5d1f6848c..79d1963dc 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -18,6 +18,7 @@ * Copyright 2017-2020 Fred N. van Kempen. * Copyright 2016-2020 Miran Grca. */ + #ifndef EMU_MEM_H # define EMU_MEM_H @@ -332,8 +333,8 @@ extern void addreadlookup(uint32_t virt, uint32_t phys); extern void addwritelookup(uint32_t virt, uint32_t phys); extern void mem_mapping_set(mem_mapping_t *, - uint32_t base, - uint32_t size, + uint32_t base, + uint32_t size, uint8_t (*read_b)(uint32_t addr, void *p), uint16_t (*read_w)(uint32_t addr, void *p), uint32_t (*read_l)(uint32_t addr, void *p), @@ -344,8 +345,8 @@ extern void mem_mapping_set(mem_mapping_t *, uint32_t flags, void *p); extern void mem_mapping_add(mem_mapping_t *, - uint32_t base, - uint32_t size, + uint32_t base, + uint32_t size, uint8_t (*read_b)(uint32_t addr, void *p), uint16_t (*read_w)(uint32_t addr, void *p), uint32_t (*read_l)(uint32_t addr, void *p), @@ -433,7 +434,7 @@ static __inline uint32_t get_phys(uint32_t addr) return get_phys_phys | (addr & 0xfff); get_phys_virt = addr; - + if (!(cr0 >> 31)) { get_phys_phys = (addr & rammask) & ~0xfff; return addr & rammask; diff --git a/src/include/86box/midi_rtmidi.h b/src/include/86box/midi_rtmidi.h index beaccdf54..5224b83e9 100644 --- a/src/include/86box/midi_rtmidi.h +++ b/src/include/86box/midi_rtmidi.h @@ -1,3 +1,6 @@ +#ifndef EMU_SOUND_RTMIDI_H +# define EMU_SOUND_RTMIDI_H + #ifdef __cplusplus extern "C" { @@ -10,4 +13,6 @@ extern void rtmidi_in_get_dev_name(int num, char *s); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif + +#endif /*EMU_SOUND_RTMIDI*/ diff --git a/src/include/86box/mo.h b/src/include/86box/mo.h index caf5f2417..7d0eed904 100644 --- a/src/include/86box/mo.h +++ b/src/include/86box/mo.h @@ -17,9 +17,9 @@ * * Copyright 2020 Miran Grca. */ -#ifndef EMU_MO_H -#define EMU_MO_H +#ifndef EMU_MO_H +# define EMU_MO_H #define MO_NUM 4 diff --git a/src/include/86box/mouse.h b/src/include/86box/mouse.h index a3e192c46..a5519139a 100644 --- a/src/include/86box/mouse.h +++ b/src/include/86box/mouse.h @@ -16,10 +16,10 @@ * Copyright 2016-2019 Miran Grca. * Copyright 2017-2019 Fred N. van Kempen. */ + #ifndef EMU_MOUSE_H # define EMU_MOUSE_H - #define MOUSE_TYPE_NONE 0 /* no mouse configured */ #define MOUSE_TYPE_INTERNAL 1 /* machine has internal mouse */ #define MOUSE_TYPE_LOGIBUS 2 /* Logitech/ATI Bus Mouse */ diff --git a/src/include/86box/net_3c503.h b/src/include/86box/net_3c503.h index 6cc656b9f..4f3a2b20e 100644 --- a/src/include/86box/net_3c503.h +++ b/src/include/86box/net_3c503.h @@ -3,5 +3,4 @@ extern const device_t threec503_device; - #endif /*NET_3C503_H*/ diff --git a/src/include/86box/net_dp8390.h b/src/include/86box/net_dp8390.h index 1365f7ec8..027bce576 100644 --- a/src/include/86box/net_dp8390.h +++ b/src/include/86box/net_dp8390.h @@ -16,6 +16,7 @@ * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Bochs project. */ + #ifndef NET_DP8390_H # define NET_DP8390_H @@ -180,7 +181,7 @@ typedef struct { int mem_size, mem_start, mem_end; int tx_timer_index; - int tx_timer_active; + int tx_timer_active; void *priv; diff --git a/src/include/86box/net_ne2000.h b/src/include/86box/net_ne2000.h index b2581e98e..23870b989 100644 --- a/src/include/86box/net_ne2000.h +++ b/src/include/86box/net_ne2000.h @@ -32,6 +32,7 @@ * Boston, MA 02111-1307 * USA. */ + #ifndef NET_NE2000_H # define NET_NE2000_H diff --git a/src/include/86box/net_pcnet.h b/src/include/86box/net_pcnet.h index 651a62198..e6ae84eff 100644 --- a/src/include/86box/net_pcnet.h +++ b/src/include/86box/net_pcnet.h @@ -16,6 +16,7 @@ * Copyright 2004-2019 Antony T Curtis * Copyright 2016-2019 Miran Grca. */ + #ifndef NET_PCNET_H # define NET_PCNET_H diff --git a/src/include/86box/net_plip.h b/src/include/86box/net_plip.h index d45b80091..69cb80da0 100644 --- a/src/include/86box/net_plip.h +++ b/src/include/86box/net_plip.h @@ -13,6 +13,7 @@ * Author: RichardG, * Copyright 2020 RichardG. */ + #ifndef NET_PLIP_H # define NET_PLIP_H # include <86box/device.h> diff --git a/src/include/86box/net_wd8003.h b/src/include/86box/net_wd8003.h index 5b6e2113e..8fc89a88b 100644 --- a/src/include/86box/net_wd8003.h +++ b/src/include/86box/net_wd8003.h @@ -40,6 +40,7 @@ * Boston, MA 02111-1307 * USA. */ + #ifndef NET_WD8003_H # define NET_WD8003_H diff --git a/src/include/86box/network.h b/src/include/86box/network.h index 015eb6a34..8e23e671f 100644 --- a/src/include/86box/network.h +++ b/src/include/86box/network.h @@ -44,6 +44,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef EMU_NETWORK_H # define EMU_NETWORK_H # include @@ -105,9 +106,6 @@ extern netdev_t network_devs[32]; /* Function prototypes. */ extern void network_wait(uint8_t wait); -extern void network_poll(void); -extern void network_busy(uint8_t set); -extern void network_end(void); extern void network_init(void); extern void network_attach(void *, uint8_t *, NETRXCB, NETWAITCB, NETSETLINKSTATE); @@ -115,7 +113,6 @@ extern void network_close(void); extern void network_reset(void); extern int network_available(void); extern void network_tx(uint8_t *, int); -extern void network_do_tx(void); extern int network_tx_queue_check(void); extern int net_pcap_prepare(netdev_t *); diff --git a/src/include/86box/nmi.h b/src/include/86box/nmi.h index 72c2f507f..b2378af93 100644 --- a/src/include/86box/nmi.h +++ b/src/include/86box/nmi.h @@ -1,6 +1,10 @@ /* Copyright holders: Sarah Walker see COPYING for more details */ + +#ifndef EMU_NMI_H +# define EMU_NMI_H + extern int nmi_mask; extern int nmi; extern int nmi_auto_clear; @@ -9,3 +13,5 @@ extern int nmi_auto_clear; extern void nmi_init(void); extern void nmi_write(uint16_t port, uint8_t val, void *p); + +#endif /*EMU_NMI_H*/ diff --git a/src/include/86box/nvr.h b/src/include/86box/nvr.h index b841d7e6a..7fc445be3 100644 --- a/src/include/86box/nvr.h +++ b/src/include/86box/nvr.h @@ -1,130 +1,131 @@ -/* - * VARCem Virtual ARchaeological Computer EMulator. - * An emulator of (mostly) x86-based PC systems and devices, - * using the ISA,EISA,VLB,MCA and PCI system buses, roughly - * spanning the era between 1981 and 1995. - * - * This file is part of the VARCem Project. - * - * Definitions for the generic NVRAM/CMOS driver. - * - * - * - * Author: Fred N. van Kempen, , - * David Hrdlička, - * - * Copyright 2017-2020 Fred N. van Kempen. - * Copyright 2018-2020 David Hrdlička. - * - * Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the - * following conditions are met: - * - * 1. Redistributions of source code must retain the entire - * above notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names - * of its contributors may be used to endorse or promote - * products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef EMU_NVR_H -# define EMU_NVR_H - - -#define NVR_MAXSIZE 512 /* max size of NVR data */ - -/* Conversion from BCD to Binary and vice versa. */ -#define RTC_BCD(x) (((x) % 10) | (((x) / 10) << 4)) -#define RTC_DCB(x) ((((x) & 0xf0) >> 4) * 10 + ((x) & 0x0f)) -#define RTC_BCDINC(x,y) RTC_BCD(RTC_DCB(x) + y) - -/* Time sync options */ -#define TIME_SYNC_DISABLED 0 -#define TIME_SYNC_ENABLED 1 -#define TIME_SYNC_UTC 2 - - -/* Define a generic RTC/NVRAM device. */ -typedef struct _nvr_ { - char *fn; /* pathname of image file */ - uint16_t size; /* device configuration */ - int8_t irq, is_new; - - uint8_t onesec_cnt; - pc_timer_t onesec_time; - - void *data; /* local data */ - - /* Hooks to device functions. */ - void (*reset)(struct _nvr_ *); - void (*start)(struct _nvr_ *); - void (*tick)(struct _nvr_ *); - void (*ven_save)(void); - - uint8_t regs[NVR_MAXSIZE]; /* these are the registers */ -} nvr_t; - - -extern int nvr_dosave; -#ifdef EMU_DEVICE_H -extern const device_t at_nvr_old_device; -extern const device_t at_nvr_device; -extern const device_t ps_nvr_device; -extern const device_t amstrad_nvr_device; -extern const device_t ibmat_nvr_device; -extern const device_t piix4_nvr_device; -extern const device_t ami_1992_nvr_device; -extern const device_t ami_1994_nvr_device; -extern const device_t ami_1995_nvr_device; -extern const device_t via_nvr_device; -extern const device_t p6rp4_nvr_device; -#endif - - -extern void rtc_tick(void); - -extern void nvr_init(nvr_t *); -extern char *nvr_path(char *str); -extern FILE *nvr_fopen(char *str, char *mode); -extern int nvr_load(void); -extern void nvr_close(void); -extern void nvr_set_ven_save(void (*ven_save)(void)); -extern int nvr_save(void); - -extern int nvr_is_leap(int year); -extern int nvr_get_days(int month, int year); -extern void nvr_time_sync(); -extern void nvr_time_get(struct tm *); -extern void nvr_time_set(struct tm *); - -extern void nvr_reg_write(uint16_t reg, uint8_t val, void *priv); -extern void nvr_at_handler(int set, uint16_t base, nvr_t *nvr); -extern void nvr_at_sec_handler(int set, uint16_t base, nvr_t *nvr); -extern void nvr_read_addr_set(int set, nvr_t *nvr); -extern void nvr_wp_set(int set, int h, nvr_t *nvr); -extern void nvr_via_wp_set(int set, int reg, nvr_t *nvr); -extern void nvr_bank_set(int base, uint8_t bank, nvr_t *nvr); -extern void nvr_lock_set(int base, int size, int lock, nvr_t *nvr); -extern void nvr_irq_set(int irq, nvr_t *nvr); - - -#endif /*EMU_NVR_H*/ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Definitions for the generic NVRAM/CMOS driver. + * + * + * + * Author: Fred N. van Kempen, , + * David Hrdlička, + * + * Copyright 2017-2020 Fred N. van Kempen. + * Copyright 2018-2020 David Hrdlička. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the entire + * above notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names + * of its contributors may be used to endorse or promote + * products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EMU_NVR_H +# define EMU_NVR_H + + +#define NVR_MAXSIZE 512 /* max size of NVR data */ + +/* Conversion from BCD to Binary and vice versa. */ +#define RTC_BCD(x) (((x) % 10) | (((x) / 10) << 4)) +#define RTC_DCB(x) ((((x) & 0xf0) >> 4) * 10 + ((x) & 0x0f)) +#define RTC_BCDINC(x,y) RTC_BCD(RTC_DCB(x) + y) + +/* Time sync options */ +#define TIME_SYNC_DISABLED 0 +#define TIME_SYNC_ENABLED 1 +#define TIME_SYNC_UTC 2 + + +/* Define a generic RTC/NVRAM device. */ +typedef struct _nvr_ { + char *fn; /* pathname of image file */ + uint16_t size; /* device configuration */ + int8_t irq, is_new; + + uint8_t onesec_cnt; + pc_timer_t onesec_time; + + void *data; /* local data */ + + /* Hooks to device functions. */ + void (*reset)(struct _nvr_ *); + void (*start)(struct _nvr_ *); + void (*tick)(struct _nvr_ *); + void (*ven_save)(void); + + uint8_t regs[NVR_MAXSIZE]; /* these are the registers */ +} nvr_t; + + +extern int nvr_dosave; +#ifdef EMU_DEVICE_H +extern const device_t at_nvr_old_device; +extern const device_t at_nvr_device; +extern const device_t ps_nvr_device; +extern const device_t amstrad_nvr_device; +extern const device_t ibmat_nvr_device; +extern const device_t piix4_nvr_device; +extern const device_t ami_1992_nvr_device; +extern const device_t ami_1994_nvr_device; +extern const device_t ami_1995_nvr_device; +extern const device_t via_nvr_device; +extern const device_t p6rp4_nvr_device; +#endif + + +extern void rtc_tick(void); + +extern void nvr_init(nvr_t *); +extern char *nvr_path(char *str); +extern FILE *nvr_fopen(char *str, char *mode); +extern int nvr_load(void); +extern void nvr_close(void); +extern void nvr_set_ven_save(void (*ven_save)(void)); +extern int nvr_save(void); + +extern int nvr_is_leap(int year); +extern int nvr_get_days(int month, int year); +extern void nvr_time_sync(); +extern void nvr_time_get(struct tm *); +extern void nvr_time_set(struct tm *); + +extern void nvr_reg_write(uint16_t reg, uint8_t val, void *priv); +extern void nvr_at_handler(int set, uint16_t base, nvr_t *nvr); +extern void nvr_at_sec_handler(int set, uint16_t base, nvr_t *nvr); +extern void nvr_read_addr_set(int set, nvr_t *nvr); +extern void nvr_wp_set(int set, int h, nvr_t *nvr); +extern void nvr_via_wp_set(int set, int reg, nvr_t *nvr); +extern void nvr_bank_set(int base, uint8_t bank, nvr_t *nvr); +extern void nvr_lock_set(int base, int size, int lock, nvr_t *nvr); +extern void nvr_irq_set(int irq, nvr_t *nvr); + + +#endif /*EMU_NVR_H*/ diff --git a/src/include/86box/nvr_ps2.h b/src/include/86box/nvr_ps2.h index f0058d9b1..7cb37a625 100644 --- a/src/include/86box/nvr_ps2.h +++ b/src/include/86box/nvr_ps2.h @@ -34,6 +34,7 @@ * Boston, MA 02111-1307 * USA. */ + #ifndef EMU_NVRPS2_H # define EMU_NVRPS2_H diff --git a/src/include/86box/pci.h b/src/include/86box/pci.h index 919f14ac2..98aac3436 100644 --- a/src/include/86box/pci.h +++ b/src/include/86box/pci.h @@ -18,10 +18,10 @@ * Copyright 2017-2020 Fred N. van Kempen. * Copyright 2008-2020 Sarah Walker. */ + #ifndef EMU_PCI_H # define EMU_PCI_H - #define PCI_REG_COMMAND 0x04 #define PCI_COMMAND_IO 0x01 diff --git a/src/include/86box/pci_dummy.h b/src/include/86box/pci_dummy.h index 45e1299bc..a2ae4b8d0 100644 --- a/src/include/86box/pci_dummy.h +++ b/src/include/86box/pci_dummy.h @@ -1 +1,6 @@ +#ifndef EMU_PCI_DUMMY_H +# define EMU_PCI_DUMMY_H + extern void pci_dummy_init(void); + +#endif /*EMU_PCI_DUMMY_H*/ diff --git a/src/include/86box/pic.h b/src/include/86box/pic.h index 73b316f2e..3720f17d1 100644 --- a/src/include/86box/pic.h +++ b/src/include/86box/pic.h @@ -15,10 +15,10 @@ * Copyright 2015-2020 Andrew Jenner. * Copyright 2016-2020 Miran Grca. */ + #ifndef EMU_PIC_H # define EMU_PIC_H - typedef struct pic { uint8_t icw1, icw2, icw3, icw4, imr, isr, irr, ocw2, diff --git a/src/include/86box/pit.h b/src/include/86box/pit.h index bf8d71048..c560fae12 100644 --- a/src/include/86box/pit.h +++ b/src/include/86box/pit.h @@ -14,6 +14,7 @@ * Author: Miran Grca, * Copyright 2019,2020 Miran Grca. */ + #ifndef EMU_PIT_H # define EMU_PIT_H diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index c60e6d922..b09207c14 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -17,6 +17,7 @@ * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2021 Laci bá' */ + #ifndef EMU_PLAT_H # define EMU_PLAT_H @@ -203,6 +204,7 @@ extern void thread_destroy_event(event_t *arg); extern mutex_t *thread_create_mutex(void); extern void thread_close_mutex(mutex_t *arg); +extern int thread_test_mutex(mutex_t *arg); extern int thread_wait_mutex(mutex_t *arg); extern int thread_release_mutex(mutex_t *mutex); diff --git a/src/include/86box/plat_dir.h b/src/include/86box/plat_dir.h index b8280404c..41bd7fe62 100644 --- a/src/include/86box/plat_dir.h +++ b/src/include/86box/plat_dir.h @@ -13,10 +13,10 @@ * Author: Fred N. van Kempen, * Copyright 2017 Fred N. van Kempen. */ + #ifndef PLAT_DIR_H # define PLAT_DIR_H - #ifdef _MAX_FNAME # define MAXNAMLEN _MAX_FNAME #else diff --git a/src/include/86box/plat_dynld.h b/src/include/86box/plat_dynld.h index 0eb8f33c2..b4be8d09e 100644 --- a/src/include/86box/plat_dynld.h +++ b/src/include/86box/plat_dynld.h @@ -13,10 +13,10 @@ * Author: Fred N. van Kempen, * Copyright 2017 Fred N. van Kempen */ + #ifndef PLAT_DYNLD_H # define PLAT_DYNLD_H - typedef struct { const char *name; void *func; diff --git a/src/include/86box/png_struct.h b/src/include/86box/png_struct.h index 893cc5f64..0bb0e5e1b 100644 --- a/src/include/86box/png_struct.h +++ b/src/include/86box/png_struct.h @@ -44,6 +44,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef EMU_PNG_STRUCT_H # define EMU_PNG_STRUCT_H diff --git a/src/include/86box/port_6x.h b/src/include/86box/port_6x.h index 74172728a..a478e8390 100644 --- a/src/include/86box/port_6x.h +++ b/src/include/86box/port_6x.h @@ -15,10 +15,10 @@ * * Copyright 2021 Miran Grca. */ + #ifndef EMU_PORT_6X_H # define EMU_PORT_6X_H - #ifdef _TIMER_H_ typedef struct { diff --git a/src/include/86box/port_92.h b/src/include/86box/port_92.h index 52812edb8..78e0a0002 100644 --- a/src/include/86box/port_92.h +++ b/src/include/86box/port_92.h @@ -15,6 +15,7 @@ * * Copyright 2019 Miran Grca. */ + #ifndef EMU_PORT_92_H # define EMU_PORT_92_H diff --git a/src/include/86box/postcard.h b/src/include/86box/postcard.h index 8cf1d1c54..ee179eb3d 100644 --- a/src/include/86box/postcard.h +++ b/src/include/86box/postcard.h @@ -14,10 +14,10 @@ * * Copyright 2020 RichardG. */ + #ifndef POSTCARD_H # define POSTCARD_H - #ifdef __cplusplus extern "C" { #endif diff --git a/src/include/86box/printer.h b/src/include/86box/printer.h index 78193e18e..4cd5e898d 100644 --- a/src/include/86box/printer.h +++ b/src/include/86box/printer.h @@ -44,10 +44,10 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef PRINTER_H # define PRINTER_H - #define FONT_FILE_DOTMATRIX "dotmatrix.ttf" #define FONT_FILE_ROMAN "roman.ttf" diff --git a/src/include/86box/prt_devs.h b/src/include/86box/prt_devs.h index 7ef25e5cd..e8d56fe24 100644 --- a/src/include/86box/prt_devs.h +++ b/src/include/86box/prt_devs.h @@ -1,3 +1,8 @@ +#ifndef EMU_PRT_DEVS_H +# define EMU_PRT_DEVS_H + extern const lpt_device_t lpt_prt_text_device; extern const lpt_device_t lpt_prt_escp_device; -extern const lpt_device_t lpt_prt_ps_device; \ No newline at end of file +extern const lpt_device_t lpt_prt_ps_device; + +#endif /*EMU_PRT_DEVS_H*/ diff --git a/src/include/86box/random.h b/src/include/86box/random.h index 75ceb4c13..bf123375f 100644 --- a/src/include/86box/random.h +++ b/src/include/86box/random.h @@ -14,12 +14,11 @@ * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. */ + #ifndef EMU_RANDOM_H # define EMU_RANDOM_H - extern uint8_t random_generate(void); extern void random_init(void); - #endif /*EMU_RANDOM_H*/ diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 242b6c9b4..d6dec74a7 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -19,10 +19,10 @@ * Copyright 2016-2019 Miran Grca. * Copyright 2018,2019 David Hrdlička. */ + #ifndef WIN_RESOURCE_H # define WIN_RESOURCE_H - /* Dialog IDs. */ #define DLG_ABOUT 101 /* top-level dialog */ #define DLG_STATUS 102 /* top-level dialog */ @@ -308,7 +308,7 @@ #define IDC_COMBO_RPM_MODE 1202 #define IDC_COMBO_LANG 1009 /* change language dialog */ -#define IDC_COMBO_ICON 1010 +#define IDC_COMBO_ICON 1010 #define IDC_CHECKBOX_GLOBAL 1300 #define IDC_BUTTON_DEFAULT 1302 #define IDC_BUTTON_DEFICON 1304 diff --git a/src/include/86box/rom.h b/src/include/86box/rom.h index 08ab241cf..dfea9f0b5 100644 --- a/src/include/86box/rom.h +++ b/src/include/86box/rom.h @@ -13,10 +13,10 @@ * Author: Fred N. van Kempen, * Copyright 2018,2019 Fred N. van Kempen. */ + #ifndef EMU_ROM_H # define EMU_ROM_H - #define FLAG_INT 1 #define FLAG_INV 2 #define FLAG_AUX 4 diff --git a/src/include/86box/scsi.h b/src/include/86box/scsi.h index 16d10bb98..03de1a4ac 100644 --- a/src/include/86box/scsi.h +++ b/src/include/86box/scsi.h @@ -19,7 +19,7 @@ * Copyright 2017,2018 Fred N. van Kempen. */ #ifndef EMU_SCSI_H -#define EMU_SCSI_H +# define EMU_SCSI_H extern int scsi_card_current[4]; diff --git a/src/include/86box/scsi_aha154x.h b/src/include/86box/scsi_aha154x.h index ed9002ae7..6a98d100e 100644 --- a/src/include/86box/scsi_aha154x.h +++ b/src/include/86box/scsi_aha154x.h @@ -9,6 +9,5 @@ extern const device_t aha154xcp_device; extern const device_t aha1640_device; extern void aha_device_reset(void *p); - - + #endif /*SCSI_AHA154X_H*/ diff --git a/src/include/86box/scsi_buslogic.h b/src/include/86box/scsi_buslogic.h index 27ea5c10b..fa075d964 100644 --- a/src/include/86box/scsi_buslogic.h +++ b/src/include/86box/scsi_buslogic.h @@ -19,7 +19,6 @@ #ifndef SCSI_BUSLOGIC_H # define SCSI_BUSLOGIC_H - extern const device_t buslogic_542b_device; extern const device_t buslogic_545s_device; extern const device_t buslogic_542bh_device; @@ -30,6 +29,5 @@ extern const device_t buslogic_445c_device; extern const device_t buslogic_958d_pci_device; extern void BuslogicDeviceReset(void *p); - - + #endif /*SCSI_BUSLOGIC_H*/ diff --git a/src/include/86box/scsi_cdrom.h b/src/include/86box/scsi_cdrom.h index 95f3634bf..fac93eada 100644 --- a/src/include/86box/scsi_cdrom.h +++ b/src/include/86box/scsi_cdrom.h @@ -15,10 +15,10 @@ * * Copyright 2018,2019 Miran Grca. */ + #ifndef EMU_SCSI_CDROM_H #define EMU_SCSI_CDROM_H - #define CDROM_TIME 10.0 diff --git a/src/include/86box/scsi_device.h b/src/include/86box/scsi_device.h index 6e9223648..6b6600d8e 100644 --- a/src/include/86box/scsi_device.h +++ b/src/include/86box/scsi_device.h @@ -16,10 +16,10 @@ * Copyright 2016-2019 Miran Grca. * Copyright 2017-2019 Fred N. van Kempen. */ + #ifndef SCSI_DEVICE_H # define SCSI_DEVICE_H - /* Configuration. */ #define SCSI_BUS_MAX 4 /* currently we support up to 4 controllers */ @@ -197,8 +197,8 @@ #define CD_FRAMES 75 /* frames per second */ #define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ #define CD_MAX_BYTES (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE) -#define CD_MAX_SECTORS (CD_MAX_BYTES / 512) - +#define CD_MAX_SECTORS (CD_MAX_BYTES / 512) + /* Event notification classes for GET EVENT STATUS NOTIFICATION */ #define GESN_NO_EVENTS 0 #define GESN_OPERATIONAL_CHANGE 1 @@ -340,7 +340,7 @@ typedef struct scsi_common_s { double callback; } scsi_common_t; -typedef struct { +typedef struct { int32_t buffer_length; uint8_t status, phase; diff --git a/src/include/86box/scsi_disk.h b/src/include/86box/scsi_disk.h index 0caef4d26..bb782a098 100644 --- a/src/include/86box/scsi_disk.h +++ b/src/include/86box/scsi_disk.h @@ -12,6 +12,8 @@ * Copyright 2017,2018 Miran Grca. */ +#ifndef SCSI_DISK_H +# define SCSI_DISK_H typedef struct { mode_sense_pages_t ms_pages_saved; @@ -48,3 +50,5 @@ extern scsi_disk_t *scsi_disk[HDD_NUM]; extern void scsi_disk_hard_reset(void); extern void scsi_disk_close(void); + +#endif /*SCSI_DISK_H*/ diff --git a/src/include/86box/scsi_ncr5380.h b/src/include/86box/scsi_ncr5380.h index b939162fd..380f379e6 100644 --- a/src/include/86box/scsi_ncr5380.h +++ b/src/include/86box/scsi_ncr5380.h @@ -20,10 +20,10 @@ * Copyright 2017-2018 TheCollector1995. * Copyright 2017,2018 Fred N. van Kempen. */ + #ifndef SCSI_NCR5380_H # define SCSI_NCR5380_H - extern const device_t scsi_lcs6821n_device; extern const device_t scsi_rt1000b_device; extern const device_t scsi_t128_device; @@ -32,5 +32,4 @@ extern const device_t scsi_t130b_device; extern const device_t scsi_scsiat_device; #endif - #endif /*SCSI_NCR5380_H*/ diff --git a/src/include/86box/scsi_ncr53c8xx.h b/src/include/86box/scsi_ncr53c8xx.h index 730da5fed..ee5dcb58f 100644 --- a/src/include/86box/scsi_ncr53c8xx.h +++ b/src/include/86box/scsi_ncr53c8xx.h @@ -21,10 +21,10 @@ * Copyright 2009-2018 Artyom Tarasenko. * Copyright 2017,2018 Miran Grca. */ + #ifndef SCSI_NCR53C8XX_H # define SCSI_NCR53C8XX_H - extern const device_t ncr53c810_pci_device; extern const device_t ncr53c810_onboard_pci_device; extern const device_t ncr53c815_pci_device; @@ -33,5 +33,5 @@ extern const device_t ncr53c825a_pci_device; extern const device_t ncr53c860_pci_device; extern const device_t ncr53c875_pci_device; - + #endif /*SCSI_NCR53C8XX_H*/ diff --git a/src/include/86box/scsi_pcscsi.h b/src/include/86box/scsi_pcscsi.h index e21fa3801..e188f8f0e 100644 --- a/src/include/86box/scsi_pcscsi.h +++ b/src/include/86box/scsi_pcscsi.h @@ -25,9 +25,7 @@ #ifndef SCSI_PCSCSI_H # define SCSI_PCSCSI_H - extern const device_t dc390_pci_device; extern const device_t ncr53c90_mca_device; - - + #endif /*SCSI_BUSLOGIC_H*/ diff --git a/src/include/86box/scsi_spock.h b/src/include/86box/scsi_spock.h index 959fe3d04..7f9c24b78 100644 --- a/src/include/86box/scsi_spock.h +++ b/src/include/86box/scsi_spock.h @@ -17,9 +17,10 @@ * Copyright 2020 Sarah Walker. * Copyright 2020 TheCollector1995. */ + #ifndef SCSI_SPOCK_H # define SCSI_SPOCK_H extern const device_t spock_device; - -#endif /*SCSI_SPOCK_H*/ \ No newline at end of file + +#endif /*SCSI_SPOCK_H*/ diff --git a/src/include/86box/scsi_x54x.h b/src/include/86box/scsi_x54x.h index af91ee7d2..468436a34 100644 --- a/src/include/86box/scsi_x54x.h +++ b/src/include/86box/scsi_x54x.h @@ -20,9 +20,9 @@ * Copyright 2016-2018 Miran Grca. * Copyright 2017,2018 Fred N. van Kempen. */ -#ifndef SCSI_X54X_H -#define SCSI_X54X_H +#ifndef SCSI_X54X_H +# define SCSI_X54X_H #define SCSI_DELAY_TM 1 /* was 50 */ @@ -493,7 +493,7 @@ typedef struct { pc_timer_t timer, ResetCB; Req_t Req; - + fdc_t *fdc; } x54x_t; @@ -511,5 +511,4 @@ extern void *x54x_init(const device_t *info); extern void x54x_close(void *priv); extern void x54x_device_reset(void *priv); - #endif diff --git a/src/include/86box/serial.h b/src/include/86box/serial.h index 5203c17f8..7770ebb1b 100644 --- a/src/include/86box/serial.h +++ b/src/include/86box/serial.h @@ -19,10 +19,10 @@ * Copyright 2016-2020 Miran Grca. * Copyright 2017-2020 Fred N. van Kempen. */ + #ifndef EMU_SERIAL_H # define EMU_SERIAL_H - #define SERIAL_8250 0 #define SERIAL_8250_PCJR 1 #define SERIAL_16450 2 @@ -101,5 +101,4 @@ extern const device_t ns16750_device; extern const device_t ns16850_device; extern const device_t ns16950_device; - #endif /*EMU_SERIAL_H*/ diff --git a/src/include/86box/sio.h b/src/include/86box/sio.h index 667f39276..a9ee018cb 100644 --- a/src/include/86box/sio.h +++ b/src/include/86box/sio.h @@ -11,10 +11,10 @@ * Author: Fred N. van Kempen, * Copyright 2017-2020 Fred N. van Kempen. */ + #ifndef EMU_SIO_H # define EMU_SIO_H - extern void vt82c686_sio_write(uint8_t addr, uint8_t val, void *priv); @@ -83,5 +83,4 @@ extern const device_t w83977tf_device; extern const device_t w83977ef_device; extern const device_t w83977ef_370_device; - #endif /*EMU_SIO_H*/ diff --git a/src/include/86box/smbus.h b/src/include/86box/smbus.h index 6661a25c6..4c2c00c17 100644 --- a/src/include/86box/smbus.h +++ b/src/include/86box/smbus.h @@ -14,6 +14,7 @@ * * Copyright 2020 RichardG. */ + #ifndef EMU_SMBUS_PIIX4_H # define EMU_SMBUS_PIIX4_H @@ -66,5 +67,4 @@ extern const device_t via_smbus_device; extern const device_t ali7101_smbus_device; #endif - #endif /*EMU_SMBUS_PIIX4_H*/ diff --git a/src/include/86box/smbus_piix4.h b/src/include/86box/smbus_piix4.h deleted file mode 100644 index cf55dd210..000000000 --- a/src/include/86box/smbus_piix4.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - * - * Definitions for the generic PIIX4-compatible SMBus host controller. - * - * - * - * Authors: RichardG, - * - * Copyright 2020 RichardG. - */ -#ifndef EMU_SMBUS_PIIX4_H -# define EMU_SMBUS_PIIX4_H - - -#define SMBUS_PIIX4_BLOCK_DATA_SIZE 32 -#define SMBUS_PIIX4_BLOCK_DATA_MASK (SMBUS_PIIX4_BLOCK_DATA_SIZE - 1) - - -enum { - SMBUS_PIIX4 = 0, - SMBUS_VIA -}; - -typedef struct { - uint32_t local; - uint16_t io_base; - int clock; - double bit_period; - uint8_t stat, next_stat, ctl, cmd, addr, - data0, data1, - index, data[SMBUS_PIIX4_BLOCK_DATA_SIZE]; - pc_timer_t response_timer; - void *i2c; -} smbus_piix4_t; - - -extern void smbus_piix4_remap(smbus_piix4_t *dev, uint16_t new_io_base, uint8_t enable); -extern void smbus_piix4_setclock(smbus_piix4_t *dev, int clock); - - -#ifdef EMU_DEVICE_H -extern const device_t piix4_smbus_device; -extern const device_t via_smbus_device; -#endif - - -#endif /*EMU_SMBUS_PIIX4_H*/ diff --git a/src/include/86box/smram.h b/src/include/86box/smram.h index 996e5df30..7cc2e1a05 100644 --- a/src/include/86box/smram.h +++ b/src/include/86box/smram.h @@ -14,10 +14,10 @@ * * Copyright 2016-2020 Miran Grca. */ + #ifndef EMU_SMRAM_H # define EMU_SMRAM_H - typedef struct _smram_ { struct _smram_ *prev, *next; @@ -62,5 +62,4 @@ extern void smram_state_change(smram_t *smr, int smm, int flags); /* Enables or disables the use of a separate SMRAM for addresses below A0000. */ extern void smram_set_separate_smram(uint8_t set); - #endif /*EMU_SMRAM_H*/ diff --git a/src/include/86box/snd_ac97.h b/src/include/86box/snd_ac97.h index 0690cb52b..a9341f8ef 100644 --- a/src/include/86box/snd_ac97.h +++ b/src/include/86box/snd_ac97.h @@ -14,9 +14,8 @@ * * Copyright 2021 RichardG. */ -#ifndef EMU_SND_AC97_H -# define EMU_SND_AC97_H - +#ifndef SOUND_AC97_H +# define SOUND_AC97_H #define AC97_VENDOR_ID(f, s, t, dev) ((((f) & 0xff) << 24) | (((s) & 0xff) << 16) | (((t) & 0xff) << 8) | ((dev) & 0xff)) @@ -153,5 +152,4 @@ extern const device_t wm9701a_device; extern const device_t ac97_via_device; #endif - -#endif +#endif /*SOUND_AC97_H*/ diff --git a/src/include/86box/snd_ad1848.h b/src/include/86box/snd_ad1848.h index 17e7b5050..0e93f7533 100644 --- a/src/include/86box/snd_ad1848.h +++ b/src/include/86box/snd_ad1848.h @@ -19,6 +19,9 @@ * Copyright 2021 RichardG. */ +#ifndef SOUND_AD1848_H +# define SOUND_AD1848_H + enum { AD1848_TYPE_DEFAULT = 0, AD1848_TYPE_CS4248, @@ -33,7 +36,7 @@ typedef struct { int count; uint8_t trd, mce, wten: 1; - + int16_t out_l, out_r; double cd_vol_l, cd_vol_r; int fm_vol_l, fm_vol_r; @@ -66,3 +69,5 @@ extern void ad1848_speed_changed(ad1848_t *ad1848); extern void ad1848_filter_cd_audio(int channel, double *buffer, void *priv); extern void ad1848_init(ad1848_t *ad1848, uint8_t type); + +#endif /*SOUND_AD1848_H*/ diff --git a/src/include/86box/snd_azt2316a.h b/src/include/86box/snd_azt2316a.h index 852de6c92..9dafa13f9 100644 --- a/src/include/86box/snd_azt2316a.h +++ b/src/include/86box/snd_azt2316a.h @@ -1 +1,6 @@ -extern void azt2316a_enable_wss(uint8_t enable, void *p); \ No newline at end of file +#ifndef SOUND_AZT2316A_H +# define SOUND_AZT2316A_H + +extern void azt2316a_enable_wss(uint8_t enable, void *p); + +#endif /*SOUND_AZT2316A*/ diff --git a/src/include/86box/snd_cms.h b/src/include/86box/snd_cms.h index 8700bf873..a400a026c 100644 --- a/src/include/86box/snd_cms.h +++ b/src/include/86box/snd_cms.h @@ -1,5 +1,5 @@ -#ifndef SOUND_SND_CMS_H -# define SOUND_SND_CMS_H +#ifndef SOUND_CMS_H +# define SOUND_CMS_H #include #include <86box/sound.h> @@ -32,4 +32,4 @@ extern void cms_update(cms_t *cms); extern void cms_write(uint16_t addr, uint8_t val, void *p); extern uint8_t cms_read(uint16_t addr, void *p); -#endif /*SOUND_SND_CMS_H*/ +#endif /*SOUND_CMS_H*/ diff --git a/src/include/86box/snd_emu8k.h b/src/include/86box/snd_emu8k.h index effab0f79..9371826c6 100644 --- a/src/include/86box/snd_emu8k.h +++ b/src/include/86box/snd_emu8k.h @@ -1,9 +1,11 @@ +#ifndef SOUND_EMU8K_H +# define SOUND_EMU8K_H /* All these defines are in samples, not in bytes. */ #define EMU8K_MEM_ADDRESS_MASK 0xFFFFFF #define EMU8K_RAM_MEM_START 0x200000 #define EMU8K_FM_MEM_ADDRESS 0xFFFFE0 -#define EMU8K_RAM_POINTERS_MASK 0x3F +#define EMU8K_RAM_POINTERS_MASK 0x3F #define EMU8K_LFOCHORUS_SIZE 0x4000 /* * Everything in this file assumes little endian @@ -16,7 +18,7 @@ typedef struct emu8k_mem_internal_t { uint16_t fract_lw_address; uint16_t fract_address; uint32_t int_address; - }; + }; }; } emu8k_mem_internal_t; @@ -28,13 +30,13 @@ typedef struct emu8k_mem_pointers_t { uint16_t lw_address; uint8_t hb_address; uint8_t unused_address; - }; + }; }; } emu8k_mem_pointers_t; /* * From the Soundfount 2.0 fileformat Spec.: - * + * An envelope generates a control signal in six phases. When key-on occurs, a delay period begins during which the envelope value is zero. The envelope then rises in a convex curve to a value of one during the attack phase. @@ -44,25 +46,25 @@ typedef struct emu8k_mem_pointers_t { When a value of one is reached, the envelope enters a hold phase during which it remains at one. When the hold phase ends, the envelope enters a decay phase during which its value decreases linearly to a sustain level. " For the Volume Envelope, the decay phase linearly ramps toward the sustain level, causing a constant dB change for each time unit. " - When the sustain level is reached, the envelope enters sustain phase, during which the envelope stays at the sustain level. - + When the sustain level is reached, the envelope enters sustain phase, during which the envelope stays at the sustain level. + Whenever a key-off occurs, the envelope immediately enters a release phase during which the value linearly ramps from the current value to zero. " For the Volume Envelope, the release phase linearly ramps toward zero from the current level, causing a constant dB change for each time unit" When zero is reached, the envelope value remains at zero. - + Modulation of pitch and filter cutoff are in octaves, semitones, and cents. These parameters can be modulated to varying degree, either positively or negatively, by the modulation envelope. The degree of modulation is specified in cents for the full-scale attack peak. - + The volume envelope operates in dB, with the attack peak providing a full scale output, appropriately scaled by the initial volume. The zero value, however, is actually zero gain. The implementation in the EMU8000 provides for 96 dB of amplitude control. - When 96 dB of attenuation is reached in the final gain amplifier, an abrupt jump to zero gain + When 96 dB of attenuation is reached in the final gain amplifier, an abrupt jump to zero gain (infinite dB of attenuation) occurs. In a 16-bit system, this jump is inaudible */ /* It seems that the envelopes don't really have a decay/release stage, - * but instead they have a volume ramper that can be triggered + * but instead they have a volume ramper that can be triggered * automatically (after hold period), or manually (by activating release) * and the "sustain" value is the target of any of both cases. * Some programs like cubic player and AWEAmp use this, and it was @@ -75,9 +77,9 @@ typedef struct emu8k_mem_pointers_t { * contains the destination volume, and the lower byte contains the ramp time. */ -/* attack_amount is linear amplitude (added directly to value). +/* attack_amount is linear amplitude (added directly to value). * ramp_amount_db is linear dB (added directly to value too, but needs conversion to get linear amplitude). - * value range is 21bits for both, linear amplitude being 1<<21 = 0dBFS and 0 = -96dBFS (which is shortcut to silence), + * value range is 21bits for both, linear amplitude being 1<<21 = 0dBFS and 0 = -96dBFS (which is shortcut to silence), * and db amplutide being 0 = 0dBFS and -(1<<21) = -96dBFS (which is shortcut to silence). * This allows to operate db values by simply adding them. */ @@ -98,8 +100,8 @@ typedef struct emu8k_chorus_eng_t { double lfodepth_multip; double delay_offset_samples_right; emu8k_mem_internal_t lfo_inc; - emu8k_mem_internal_t lfo_pos; - + emu8k_mem_internal_t lfo_pos; + int32_t chorus_left_buffer[EMU8K_LFOCHORUS_SIZE]; int32_t chorus_right_buffer[EMU8K_LFOCHORUS_SIZE]; @@ -110,16 +112,16 @@ typedef struct emu8k_chorus_eng_t { /* Reverb parameters description, extracted from AST sources. - Mix level - Decay - Link return amp + Mix level + Decay + Link return amp Link type Switches between normal or panned Room reso ( ms) L&R (Ref 6 +1) - Ref 1 x2 (11 ms)R - Ref 2 x4 (22 ms)R - Ref 3 x8 (44 ms)L - Ref 4 x13(71 ms)R - Ref 5 x19(105ms)L + Ref 1 x2 (11 ms)R + Ref 2 x4 (22 ms)R + Ref 3 x8 (44 ms)L + Ref 4 x13(71 ms)R + Ref 5 x19(105ms)L Ref 6 x ( ms)R (multiplier changes with room reso) Ref 1-6 filter L&R Ref 1-6 amp L&R @@ -129,7 +131,7 @@ typedef struct emu8k_chorus_eng_t { Ref 4 feedback L&R Ref 5 feedback L&R Ref 6 feedback L&R -*/ +*/ typedef struct emu8k_reverb_combfilter_t { int read_pos; int32_t reflection[MAX_REFL_SIZE]; @@ -149,11 +151,11 @@ typedef struct emu8k_reverb_eng_t { uint8_t refl_in_amp; - emu8k_reverb_combfilter_t reflections[6]; + emu8k_reverb_combfilter_t reflections[6]; emu8k_reverb_combfilter_t allpass[8]; emu8k_reverb_combfilter_t tailL; emu8k_reverb_combfilter_t tailR; - + emu8k_reverb_combfilter_t damper; } emu8k_reverb_eng_t; @@ -202,7 +204,7 @@ typedef struct emu8k_voice_t uint32_t unknown_data0_5; union { uint32_t psst; - struct { + struct { uint16_t psst_lw_address; uint8_t psst_hw_address; uint8_t psst_pan; @@ -211,7 +213,7 @@ typedef struct emu8k_voice_t }; union { uint32_t csl; - struct { + struct { uint16_t csl_lw_address; uint8_t csl_hw_address; uint8_t csl_chor_send; @@ -232,12 +234,12 @@ typedef struct emu8k_voice_t #define CCCA_DMA_ACTIVE(ccca) (ccca&0x04000000) #define CCCA_DMA_WRITE_MODE(ccca) (ccca&0x02000000) #define CCCA_DMA_WRITE_RIGHT(ccca) (ccca&0x01000000) - + uint16_t envvol; #define ENVVOL_NODELAY(envol) (envvol&0x8000) /* Verified with a soundfont bank. 7FFF is the minimum delay time, and 0 is the max delay time */ #define ENVVOL_TO_EMU_SAMPLES(envvol) (envvol&0x8000) ? 0 : ((0x8000-(envvol&0x7FFF)) <<5) - + uint16_t dcysusv; #define DCYSUSV_IS_RELEASE(dcysusv) (dcysusv&0x8000) #define DCYSUSV_GENERATOR_ENGINE_ON(dcysusv) !(dcysusv&0x0080) @@ -245,39 +247,39 @@ typedef struct emu8k_voice_t /* Inverting the range compared to documentation because the envelope runs from 0dBFS = 0 to -96dBFS = (1 <<21) */ #define DCYSUSV_SUS_TO_ENV_RANGE(susvalue) (((0x7F-susvalue) << 21)/0x7F) #define DCYSUSV_DECAYRELEASE_GET(dcysusv) (dcysusv&0x7F) - + uint16_t envval; #define ENVVAL_NODELAY(enval) (envval&0x8000) /* Verified with a soundfont bank. 7FFF is the minimum delay time, and 0 is the max delay time */ #define ENVVAL_TO_EMU_SAMPLES(envval)(envval&0x8000) ? 0 : ((0x8000-(envval&0x7FFF)) <<5) - + uint16_t dcysus; #define DCYSUS_IS_RELEASE(dcysus) (dcysus&0x8000) #define DCYSUS_SUSVALUE_GET(dcysus) ((dcysus>>8)&0x7F) #define DCYSUS_SUS_TO_ENV_RANGE(susvalue) ((susvalue << 21)/0x7F) #define DCYSUS_DECAYRELEASE_GET(dcysus) (dcysus&0x7F) - + uint16_t atkhldv; #define ATKHLDV_TRIGGER(atkhldv) !(atkhldv&0x8000) #define ATKHLDV_HOLD(atkhldv) ((atkhldv>>8)&0x7F) #define ATKHLDV_HOLD_TO_EMU_SAMPLES(atkhldv) (4096*(0x7F-((atkhldv>>8)&0x7F))) #define ATKHLDV_ATTACK(atkhldv) (atkhldv&0x7F) - + uint16_t lfo1val, lfo2val; #define LFOxVAL_NODELAY(lfoxval) (lfoxval&0x8000) #define LFOxVAL_TO_EMU_SAMPLES(lfoxval) (lfoxval&0x8000) ? 0 : ((0x8000-(lfoxval&0x7FFF)) <<5) - + uint16_t atkhld; #define ATKHLD_TRIGGER(atkhld) !(atkhld&0x8000) #define ATKHLD_HOLD(atkhld) ((atkhld>>8)&0x7F) #define ATKHLD_HOLD_TO_EMU_SAMPLES(atkhld) (4096*(0x7F-((atkhld>>8)&0x7F))) #define ATKHLD_ATTACK(atkhld) (atkhld&0x7F) - - + + uint16_t ip; #define INTIAL_PITCH_CENTER 0xE000 #define INTIAL_PITCH_OCTAVE 0x1000 - + union { uint16_t ifatn; struct{ @@ -313,17 +315,17 @@ typedef struct emu8k_voice_t int8_t fm2frq2_lfo2_vibrato; }; }; - + int env_engine_on; - + emu8k_mem_internal_t addr, loop_start, loop_end; - + int32_t initial_att; int32_t initial_filter; emu8k_envelope_t vol_envelope; emu8k_envelope_t mod_envelope; - + int64_t lfo1_speed, lfo2_speed; emu8k_mem_internal_t lfo1_count, lfo2_count; int32_t lfo1_delay_samples, lfo2_delay_samples; @@ -351,12 +353,12 @@ typedef struct emu8k_t uint32_t hwcf4, hwcf5, hwcf6, hwcf7; uint16_t init1[32], init2[32], init3[32], init4[32]; - + uint32_t smalr, smarr, smalw, smarw; uint16_t smld_buffer, smrd_buffer; uint16_t wc; - + uint16_t id; /* The empty block is used to act as an unallocated memory returning zero. */ @@ -367,14 +369,14 @@ typedef struct emu8k_t uint32_t ram_end_addr; int cur_reg, cur_voice; - + int16_t out_l, out_r; - + emu8k_chorus_eng_t chorus_engine; int32_t chorus_in_buffer[SOUNDBUFLEN]; emu8k_reverb_eng_t reverb_engine; int32_t reverb_in_buffer[SOUNDBUFLEN]; - + int pos; int32_t buffer[SOUNDBUFLEN * 2]; @@ -448,7 +450,7 @@ Section E - Introduction to the EMU8000 Chip Amplifier The amplifier determines the loudness of an audio signal. - + LFO1 An LFO, or Low Frequency Oscillator, is normally used to periodically modulate, that is, change a sound parameter, @@ -457,11 +459,11 @@ Section E - Introduction to the EMU8000 Chip modulation). It operates at sub-audio frequency from 0.042 Hz to 10.71 Hz. The LFO1 in the EMU8000 modulates the pitch, volume and filter cutoff simultaneously. - + LFO2 The LFO2 is similar to the LFO1, except that it modulates the pitch of the audio signal only. - + Resonance A filter alone would be like an equalizer, making a bright audio signal duller, but the addition of resonance @@ -470,7 +472,7 @@ Section E - Introduction to the EMU8000 Chip signals at the cutoff frequency, giving the audio signal a subtle wah-wah, that is, imagine a siren sound going from bright to dull to bright again periodically. - + LFO1 to Volume (Tremolo) The LFO1's output is routed to the amplifier, with the depth of oscillation determined by LFO1 to Volume. LFO1 @@ -484,7 +486,7 @@ Section E - Introduction to the EMU8000 Chip oscillating). An example of a GM instrument that makes use of LFO1 to Volume is instrument number 45, Tremolo Strings. - + LFO1 to Filter Cutoff (Wah-Wah) The LFO1's output is routed to the filter, with the depth of oscillation determined by LFO1 to Filter. LFO1 to @@ -502,7 +504,7 @@ Section E - Introduction to the EMU8000 Chip oscillator, producing a vibrato effect. An example of a GM instrument that makes use of LFO1 to Pitch is instrument number 57, Trumpet. - + LFO2 to Pitch (Vibrato) The LFO1 in the EMU8000 can simultaneously modulate pitch, volume and filter. LFO2, on the other hand, @@ -511,7 +513,7 @@ Section E - Introduction to the EMU8000 Chip periodic fluctuation in the pitch of the oscillator, producing a vibrato effect. When this is coupled with LFO1 to Pitch, a complex vibrato effect can be achieved. - + Volume Envelope The character of a musical instrument is largely determined by its volume envelope, the way in which the @@ -537,7 +539,7 @@ Section E - Introduction to the EMU8000 Chip as a key is held down. Release The time it takes the envelope to fall to the zero level after the key is released. - + Using these six parameters can yield very realistic reproduction of the volume envelope characteristics of many musical instruments. @@ -558,14 +560,14 @@ Section E - Introduction to the EMU8000 Chip useful in creating synthetic sci-fi sound textures. An example of a GM instrument that makes use of the filter envelope is instrument number 86, Pad 8 (Sweep). - + Pitch/Filter Envelope Modulation These two parameters determine the modulation depth of the pitch and filter envelope. In the wind instrument example above, a small amount of pitch envelope modulation is desirable to simulate its natural pitch characteristics. - + This rich modulation capability of the EMU8000 is fully exploited by the SB AWE32 MIDI drivers. The driver also provides you with a means to change these parameters over @@ -619,9 +621,9 @@ Section E - Introduction to the EMU8000 Chip Short Delay (feed back) This chorus variation simulates a short delay repeated (feedback) many times. - - - + + + Registers to write the Chorus Parameters to (all are 16-bit, unless noted): (codified as in register,port,voice. port 0=0x620, 2=0x622, 4=0xA20, 6=0xA22, 8=0xE20) ( 3409 = register 3, port A20, voice 9) @@ -700,16 +702,16 @@ Hall 1: 0x7224,0x7224,0x7254,0x7284,0x4448,0x4548,0xA440,0xA540, 0x842B,0x852B,0x842B,0x852B,0x842A,0x852A,0x842A,0x852A, 0x8429,0x8529,0x8429,0x8529 - + Hall 2: - + 0xB488,0xA470,0x9570,0x84B5,0x383A,0x3EB5,0x7254,0x7234, 0x7224,0x7254,0x7264,0x7294,0x44C3,0x45C3,0xA404,0xA504, 0x842A,0x852A,0x842A,0x852A,0x8429,0x8529,0x8429,0x8529, -0x8428,0x8528,0x8428,0x8528 +0x8428,0x8528,0x8428,0x8528 Plate: - + 0xB4FF,0xA470,0x9570,0x84B5,0x383A,0x3EB5,0x7234,0x7234, 0x7234,0x7234,0x7234,0x7234,0x4448,0x4548,0xA440,0xA540, 0x842A,0x852A,0x842A,0x852A,0x8429,0x8529,0x8429,0x8529, @@ -776,3 +778,5 @@ Treble Parameters: 0xD308 0xD308 0xD308 0xD308 0xD308 0xD308 0xD3019 0xD32A 0xD34C 0xD36E 0xD36E 0xD36E 0x0001 0x0001 0x0001 0x0001 0x0001 0x0002 0x0002 0x0002 0x0002 0x0002 0x0002 0x0002 */ + +#endif /*SOUND_EMU8K_H*/ diff --git a/src/include/86box/snd_mpu401.h b/src/include/86box/snd_mpu401.h index 433bf09a1..8846ee2dd 100644 --- a/src/include/86box/snd_mpu401.h +++ b/src/include/86box/snd_mpu401.h @@ -19,6 +19,7 @@ * Copyright 2016-2020 Miran Grca. * Copyright 2016-2020 TheCollector1995. */ + #ifndef SOUND_MPU401_H # define SOUND_MPU401_H @@ -51,11 +52,11 @@ typedef enum MpuDataType T_COMMAND } MpuDataType; -typedef enum RecState -{ - M_RECOFF, +typedef enum RecState +{ + M_RECOFF, M_RECSTB, - M_RECON + M_RECON } RecState; /* Messages sent to MPU-401 from host */ @@ -83,7 +84,7 @@ typedef struct mpu_t uint8_t rec_queue[MPU401_INPUT_QUEUE]; int rec_queue_pos, rec_queue_used; uint32_t ch_toref[16]; - struct track + struct track { int counter; uint8_t value[3], sys_val, @@ -140,7 +141,7 @@ typedef struct mpu_t uint8_t chan, trmask; uint32_t key[4]; } chanref[5], inputref[16]; - pc_timer_t mpu401_event_callback, mpu401_eoi_callback, + pc_timer_t mpu401_event_callback, mpu401_eoi_callback, mpu401_reset_callback; void (*ext_irq_update)(void *priv, int set); int (*ext_irq_pending)(void *priv); @@ -163,5 +164,4 @@ extern void mpu401_irq_attach(mpu_t *mpu, void (*ext_irq_update)(void *priv, int extern int MPU401_InputSysex(void *p, uint8_t *buffer, uint32_t len, int abort); extern void MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len); - #endif /*SOUND_MPU401_H*/ diff --git a/src/include/86box/snd_opl.h b/src/include/86box/snd_opl.h index f6e533e4a..6145376ec 100644 --- a/src/include/86box/snd_opl.h +++ b/src/include/86box/snd_opl.h @@ -17,7 +17,6 @@ #ifndef SOUND_OPL_H # define SOUND_OPL_H - typedef void (*tmrfunc)(void *priv, int timer, uint64_t period); /* Define an OPLx chip. */ @@ -53,5 +52,4 @@ extern void opl3_write(uint16_t port, uint8_t val, void *); extern void opl3_init(opl_t *); extern void opl3_update(opl_t *); - #endif /*SOUND_OPL_H*/ diff --git a/src/include/86box/snd_opl_nuked.h b/src/include/86box/snd_opl_nuked.h index ff2e1db30..827b52fc2 100644 --- a/src/include/86box/snd_opl_nuked.h +++ b/src/include/86box/snd_opl_nuked.h @@ -16,6 +16,7 @@ * Copyright 2017-2020 Fred N. van Kempen. * Copyright 2016-2019 Miran Grca. */ + #ifndef SOUND_OPL_NUKED_H # define SOUND_OPL_NUKED_H @@ -31,5 +32,4 @@ extern void nuked_generate(void *, int32_t *buf); extern void nuked_generate_resampled(void *, int32_t *buf); extern void nuked_generate_stream(void *, int32_t *sndptr, uint32_t num); - #endif /*SOUND_OPL_NUKED_H*/ diff --git a/src/include/86box/snd_resid.h b/src/include/86box/snd_resid.h index 402ee0ceb..0a8b2edcd 100644 --- a/src/include/86box/snd_resid.h +++ b/src/include/86box/snd_resid.h @@ -1,3 +1,6 @@ +#ifndef SOUND_RESID_H +# define SOUND_RESID_H + #ifdef __cplusplus extern "C" { #endif @@ -10,3 +13,5 @@ extern "C" { #ifdef __cplusplus } #endif + +#endif /*SOUND_RESID_H*/ diff --git a/src/include/86box/snd_sb.h b/src/include/86box/snd_sb.h index 7291aa4d0..90e3e4355 100644 --- a/src/include/86box/snd_sb.h +++ b/src/include/86box/snd_sb.h @@ -15,6 +15,7 @@ * Copyright 2008-2018 Sarah Walker. * Copyright 2016-2018 Miran Grca. */ + #ifndef SOUND_SND_SB_H # define SOUND_SND_SB_H @@ -56,17 +57,17 @@ typedef struct sb_ct1345_mixer_t double mic; /*see sb_ct1745_mixer for values for input selector*/ int32_t input_selector; - + int input_filter; int in_filter_freq; int output_filter; - + int stereo; int stereo_isleft; - + uint8_t index; uint8_t regs[256]; - + } sb_ct1345_mixer_t; /* SB16 and AWE32 */ typedef struct sb_ct1745_mixer_t @@ -81,7 +82,7 @@ typedef struct sb_ct1745_mixer_t int bass_l, bass_r; int treble_l, treble_r; - + int output_selector; #define OUTPUT_MIC 1 #define OUTPUT_CD_R 2 @@ -100,12 +101,12 @@ typedef struct sb_ct1745_mixer_t #define INPUT_MIDI_L 64 int mic_agc; - + int32_t input_gain_L; int32_t input_gain_R; double output_gain_L; double output_gain_R; - + uint8_t index; uint8_t regs[256]; } sb_ct1745_mixer_t; @@ -126,7 +127,7 @@ typedef struct sb_t void *gameport; int pos; - + uint8_t pos_regs[8], pnp_rom[512]; uint16_t opl_pnp_addr; diff --git a/src/include/86box/snd_sb_dsp.h b/src/include/86box/snd_sb_dsp.h index 067e05b3e..740d05ca0 100644 --- a/src/include/86box/snd_sb_dsp.h +++ b/src/include/86box/snd_sb_dsp.h @@ -1,5 +1,5 @@ #ifndef SOUND_SND_SB_DSP_H -#define SOUND_SND_SB_DSP_H +# define SOUND_SND_SB_DSP_H /*Sound Blaster Clones, for quirks*/ #define SB_SUBTYPE_DEFAULT 0 /*Handle as a Creative card*/ @@ -125,4 +125,4 @@ void sb_dsp_set_stereo(sb_dsp_t *dsp, int stereo); void sb_dsp_update(sb_dsp_t *dsp); void sb_update_mask(sb_dsp_t *dsp, int irqm8, int irqm16, int irqm401); -#endif /* SOUND_SND_SB_DSP_H */ \ No newline at end of file +#endif /* SOUND_SND_SB_DSP_H */ diff --git a/src/include/86box/snd_sn76489.h b/src/include/86box/snd_sn76489.h index 01d19e0e5..0a30ae531 100644 --- a/src/include/86box/snd_sn76489.h +++ b/src/include/86box/snd_sn76489.h @@ -1,3 +1,6 @@ +#ifndef SOUND_SN76489_H +# define SOUND_SN76489_H + enum { SN76496, @@ -22,12 +25,14 @@ typedef struct sn76489_t uint8_t firstdat; int type; int extra_divide; - + int16_t buffer[SOUNDBUFLEN]; int pos; - + double psgconst; } sn76489_t; void sn76489_init(sn76489_t *sn76489, uint16_t base, uint16_t size, int type, int freq); void sn74689_set_extra_divide(sn76489_t *sn76489, int enable); + +#endif /*SOUND_SN76489_H*/ diff --git a/src/include/86box/snd_speaker.h b/src/include/86box/snd_speaker.h index 91e3edfe3..534696208 100644 --- a/src/include/86box/snd_speaker.h +++ b/src/include/86box/snd_speaker.h @@ -16,6 +16,10 @@ * Copyright 2008-2019 Sarah Walker. * Copyright 2016-2019 Miran Grca. */ + +#ifndef SOUND_SPEAKER_H +# define SOUND_SPEAKER_H + extern int speaker_mute; extern int speaker_gated; @@ -26,3 +30,5 @@ extern void speaker_init(); extern void speaker_set_count(uint8_t new_m, int new_count); extern void speaker_update(void); + +#endif /*SOUND_SPEAKER_H*/ diff --git a/src/include/86box/snd_ym7128.h b/src/include/86box/snd_ym7128.h index f71aa2f86..6957e9d30 100644 --- a/src/include/86box/snd_ym7128.h +++ b/src/include/86box/snd_ym7128.h @@ -1,25 +1,30 @@ +#ifndef SOUND_YM7128_H +# define SOUND_YM7128_H + typedef struct ym7128_t { int a0, sci; uint8_t dat; - + int reg_sel; uint8_t regs[32]; - + int gl[8], gr[8]; int vm, vc, vl, vr; int c0, c1; int t[9]; - + int16_t filter_dat; int16_t prev_l, prev_r; - + int16_t delay_buffer[2400]; int delay_pos; - + int16_t last_samp; } ym7128_t; void ym7128_init(ym7128_t *ym7128); void ym7128_write(ym7128_t *ym7128, uint8_t val); void ym7128_apply(ym7128_t *ym7128, int16_t *buffer, int len); + +#endif /*SOUND_YM7128_H*/ diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index cd53a06a6..f4a80fd08 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -16,10 +16,10 @@ * Copyright 2008-2018 Sarah Walker. * Copyright 2016-2018 Miran Grca. */ + #ifndef EMU_SOUND_H # define EMU_SOUND_H - extern int sound_gain; #define SOUNDBUFLEN (48000/50) diff --git a/src/include/86box/spd.h b/src/include/86box/spd.h index 0e17d0da3..76a336d8b 100644 --- a/src/include/86box/spd.h +++ b/src/include/86box/spd.h @@ -14,10 +14,10 @@ * * Copyright 2020 RichardG. */ + #ifndef EMU_SPD_H # define EMU_SPD_H - #define SPD_BASE_ADDR 0x50 #define SPD_MAX_SLOTS 8 #define SPD_DATA_SIZE 256 @@ -110,5 +110,4 @@ extern void spd_write_drbs_with_ext(uint8_t *regs, uint8_t reg_min, uint8_t reg_ extern void spd_write_drbs_interleaved(uint8_t *regs, uint8_t reg_min, uint8_t reg_max, uint8_t drb_unit); extern void spd_write_drbs_ali1621(uint8_t *regs, uint8_t reg_min, uint8_t reg_max); - #endif /*EMU_SPD_H*/ diff --git a/src/include/86box/timer.h b/src/include/86box/timer.h index 6c5531bd9..63ca8965b 100644 --- a/src/include/86box/timer.h +++ b/src/include/86box/timer.h @@ -30,7 +30,7 @@ typedef union 32:32 fixed point format, with the integer part compared against the TSC. The fractional part is used when advancing the timestamp to ensure a more accurate period. - + As the timer only stores 32 bits of integer timestamp, and the TSC is 64 bits, the timer period can only be at most 0x7fffffff CPU cycles. To allow room for (optimistic) CPU frequency growth, timer period must be at most 1 second. diff --git a/src/include/86box/ui.h b/src/include/86box/ui.h index 61e251eeb..6d3946d1c 100644 --- a/src/include/86box/ui.h +++ b/src/include/86box/ui.h @@ -19,7 +19,6 @@ #ifndef EMU_UI_H # define EMU_UI_H - #ifdef __cplusplus extern "C" { #endif @@ -80,5 +79,4 @@ extern void ui_sb_mt32lcd(char *str); } #endif - #endif /*EMU_UI_H*/ diff --git a/src/include/86box/unix_sdl.h b/src/include/86box/unix_sdl.h index 7019f0b85..24214ec31 100644 --- a/src/include/86box/unix_sdl.h +++ b/src/include/86box/unix_sdl.h @@ -1,5 +1,6 @@ #ifndef _UNIX_SDL_H -#define _UNIX_SDL_H +# define _UNIX_SDL_H + extern void sdl_close(void); extern int sdl_inits(); extern int sdl_inith(); @@ -9,4 +10,5 @@ extern void sdl_resize(int x, int y); extern void sdl_enable(int enable); extern void sdl_set_fs(int fs); extern void sdl_reload(void); -#endif \ No newline at end of file + +#endif /*_UNIX_SDL_H*/ diff --git a/src/include/86box/usb.h b/src/include/86box/usb.h index 375fc89e7..68c1fc88a 100644 --- a/src/include/86box/usb.h +++ b/src/include/86box/usb.h @@ -14,6 +14,7 @@ * * Copyright 2020 Miran Grca. */ + #ifndef USB_H # define USB_H @@ -44,5 +45,4 @@ extern void ohci_update_mem_mapping(usb_t *dev, uint8_t base1, uint8_t base2, u } #endif - #endif /*USB_H*/ diff --git a/src/include/86box/vid_ati_eeprom.h b/src/include/86box/vid_ati_eeprom.h index 24e0bff96..bb2114739 100644 --- a/src/include/86box/vid_ati_eeprom.h +++ b/src/include/86box/vid_ati_eeprom.h @@ -1,3 +1,6 @@ +#ifndef VIDEO_ATI_EEPROM_H +# define VIDEO_ATI_EEPROM_H + /* Copyright holders: Sarah Walker see COPYING for more details */ @@ -17,7 +20,7 @@ enum EEPROM_OP_WRITE = 5, EEPROM_OP_READ = 6, EEPROM_OP_ERASE = 7, - + EEPROM_OP_WRALMAIN = -1 }; @@ -47,3 +50,5 @@ typedef struct ati_eeprom_t void ati_eeprom_load(ati_eeprom_t *eeprom, char *fn, int type); void ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat); int ati_eeprom_read(ati_eeprom_t *eeprom); + +#endif /*VIDEO_ATI_EEPROM_H*/ diff --git a/src/include/86box/vid_cga.h b/src/include/86box/vid_cga.h index c8b1cca8c..26fe2ea1a 100644 --- a/src/include/86box/vid_cga.h +++ b/src/include/86box/vid_cga.h @@ -15,18 +15,19 @@ * Copyright 2008-2018 Sarah Walker. * Copyright 2016-2018 Miran Grca. */ + #ifndef VIDEO_CGA_H # define VIDEO_CGA_H typedef struct cga_t { mem_mapping_t mapping; - + int crtcreg; uint8_t crtc[32]; - + uint8_t cgastat; - + uint8_t cgamode, cgacol; int fontbase; @@ -40,13 +41,13 @@ typedef struct cga_t uint64_t dispontime, dispofftime; pc_timer_t timer; - + int firstline, lastline; - + int drawcursor; - + uint8_t *vram; - + uint8_t charbuffer[256]; int revision; diff --git a/src/include/86box/vid_cga_comp.h b/src/include/86box/vid_cga_comp.h index 6b1dc4062..b221e96a4 100644 --- a/src/include/86box/vid_cga_comp.h +++ b/src/include/86box/vid_cga_comp.h @@ -16,6 +16,7 @@ * Copyright 2015-2018 reenigne. * Copyright 2015-2018 Miran Grca. */ + #ifndef VIDEO_CGA_COMP_H # define VIDEO_CGA_COMP_H diff --git a/src/include/86box/vid_colorplus.h b/src/include/86box/vid_colorplus.h index 07a96ff4f..8466a3e43 100644 --- a/src/include/86box/vid_colorplus.h +++ b/src/include/86box/vid_colorplus.h @@ -1,3 +1,6 @@ +#ifndef VIDEO_COLORPLUS_H +# define VIDEO_COLORPLUS_H + typedef struct colorplus_t { cga_t cga; @@ -13,3 +16,5 @@ void colorplus_recalctimings(colorplus_t *colorplus); void colorplus_poll(void *p); extern const device_t colorplus_device; + +#endif /*VIDEO_COLORPLUS_H*/ diff --git a/src/include/86box/vid_ddc.h b/src/include/86box/vid_ddc.h index 223861436..297ad65bf 100644 --- a/src/include/86box/vid_ddc.h +++ b/src/include/86box/vid_ddc.h @@ -16,6 +16,7 @@ * Copyright 2008-2020 Sarah Walker. * Copyright 2020 RichardG. */ + #ifndef EMU_VID_DDC_H # define EMU_VID_DDC_H diff --git a/src/include/86box/vid_ega.h b/src/include/86box/vid_ega.h index bc378704b..5c0cffd05 100644 --- a/src/include/86box/vid_ega.h +++ b/src/include/86box/vid_ega.h @@ -17,6 +17,7 @@ * Copyright 2008-2020 Sarah Walker. * Copyright 2016-2020 Miran Grca. */ + #ifndef VIDEO_EGA_H # define VIDEO_EGA_H @@ -129,5 +130,4 @@ void ega_render_4bpp_lowres(ega_t *ega); void ega_render_4bpp_highres(ega_t *ega); #endif - #endif /*VIDEO_EGA_H*/ diff --git a/src/include/86box/vid_hercules.h b/src/include/86box/vid_hercules.h index 8d44fdfe1..f97a8fa18 100644 --- a/src/include/86box/vid_hercules.h +++ b/src/include/86box/vid_hercules.h @@ -16,6 +16,7 @@ * Copyright 2016-2019 Miran Grca. * Copyright 2021 Jasmine Iwanek. */ + #ifndef VIDEO_HERCULES_H # define VIDEO_HERCULES_H diff --git a/src/include/86box/vid_mda.h b/src/include/86box/vid_mda.h index 82a8f5e19..13e2f76e3 100644 --- a/src/include/86box/vid_mda.h +++ b/src/include/86box/vid_mda.h @@ -1,18 +1,22 @@ /* Copyright holders: Sarah Walker see COPYING for more details */ + +#ifndef VIDEO_MDA_H +# define VIDEO_MDA_H + typedef struct mda_t { mem_mapping_t mapping; - + uint8_t crtc[32]; int crtcreg; - + uint8_t ctrl, stat; - + uint64_t dispontime, dispofftime; pc_timer_t timer; - + int firstline, lastline; int linepos, displine; @@ -38,3 +42,5 @@ void mda_poll(void *p); #ifdef EMU_DEVICE_H extern const device_t mda_device; #endif + +#endif /*VIDEO_MDA_H*/ diff --git a/src/include/86box/vid_nga.h b/src/include/86box/vid_nga.h index 1c8bd786e..8aa096604 100644 --- a/src/include/86box/vid_nga.h +++ b/src/include/86box/vid_nga.h @@ -6,7 +6,7 @@ * * This file is part of the 86Box distribution. * - * Emulation of the Olivetti OGC 8-bit ISA (GO708) and + * Emulation of the Olivetti OGC 8-bit ISA (GO708) and * M21/M24/M28 16-bit bus (GO317/318/380/709) video cards. * * @@ -22,6 +22,9 @@ * Copyright 2020 EngiNerd. */ +#ifndef VIDEO_NGA_H +# define VIDEO_NGA_H + typedef struct nga_t { cga_t cga; /* unused in OGC, required for M19 video card structure idiom */ @@ -46,3 +49,5 @@ void nga_mdaattr_rebuild(); extern const device_config_t nga_config[]; extern const device_t nga_device; #endif + +#endif /*VIDEO_NGA_H*/ diff --git a/src/include/86box/vid_ogc.h b/src/include/86box/vid_ogc.h index 2fffa65c3..20ac4996e 100644 --- a/src/include/86box/vid_ogc.h +++ b/src/include/86box/vid_ogc.h @@ -6,7 +6,7 @@ * * This file is part of the 86Box distribution. * - * Emulation of the Olivetti OGC 8-bit ISA (GO708) and + * Emulation of the Olivetti OGC 8-bit ISA (GO708) and * M21/M24/M28 16-bit bus (GO317/318/380/709) video cards. * * @@ -22,6 +22,9 @@ * Copyright 2020 EngiNerd. */ +#ifndef VIDEO_OGC_H +# define VIDEO_OGC_H + typedef struct ogc_t { cga_t cga; /* unused in OGC, required for M19 video card structure idiom */ @@ -46,3 +49,5 @@ void ogc_mdaattr_rebuild(); extern const device_config_t ogc_config[]; extern const device_t ogc_device; #endif + +#endif /*VIDEO_OGC_H*/ diff --git a/src/include/86box/vid_pgc.h b/src/include/86box/vid_pgc.h index ecfc61c2b..1bf0adf95 100644 --- a/src/include/86box/vid_pgc.h +++ b/src/include/86box/vid_pgc.h @@ -19,7 +19,6 @@ #ifndef VID_PGC_H # define VID_PGC_H - #define PGC_ERROR_RANGE 0x01 #define PGC_ERROR_INTEGER 0x02 #define PGC_ERROR_MEMORY 0x03 @@ -49,7 +48,7 @@ typedef struct pgc_cmd { uint8_t hex; void (*handler)(struct pgc *); int (*parser) (struct pgc *, pgc_cl_t *, int); - int p; + int p; } pgc_cmd_t; typedef struct pgc { @@ -99,7 +98,7 @@ typedef struct pgc { int waiting_error_fifo; int ascii_mode; int result_count; - + int fontbase; int linepos, displine; @@ -117,7 +116,7 @@ typedef struct pgc { int drawcursor; - int (*inputbyte)(struct pgc *, uint8_t *result); + int (*inputbyte)(struct pgc *, uint8_t *result); } pgc_t; @@ -181,5 +180,4 @@ extern int pgc_result_coord(pgc_t *, int32_t val); extern void pgc_hndl_lut8(pgc_t *); extern void pgc_hndl_lut8rd(pgc_t *); - #endif /*VID_PGC_H*/ diff --git a/src/include/86box/vid_pgc_palette.h b/src/include/86box/vid_pgc_palette.h index ccc9ac2bd..8f2a96a5a 100644 --- a/src/include/86box/vid_pgc_palette.h +++ b/src/include/86box/vid_pgc_palette.h @@ -16,6 +16,7 @@ * Copyright 2019 Fred N. van Kempen. * Copyright 2019 John Elliott. */ + #ifndef VID_PGC_PALETTE_H # define VID_PGC_PALETTE_H @@ -1575,5 +1576,4 @@ makecol(0x00,0x00,0x00), }, - #endif /*VID_PGC_PALETTE_H*/ diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 348677477..1e8cc2b91 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -16,10 +16,10 @@ * Copyright 2008-2020 Sarah Walker. * Copyright 2016-2020 Miran Grca. */ + #ifndef VIDEO_SVGA_H # define VIDEO_SVGA_H - #define FLAG_EXTRA_BANKS 1 #define FLAG_ADDR_BY8 2 #define FLAG_EXT_WRITE 4 @@ -120,7 +120,7 @@ typedef struct svga_t /* Called when VC=R18 and friends. If this returns zero then MA resetting is skipped. Matrox Mystique in Power mode reuses this counter for vertical line interrupt*/ - int (*line_compare)(struct svga_t *svga); + int (*line_compare)(struct svga_t *svga); /*Called at the start of vertical sync*/ void (*vsync_callback)(struct svga_t *svga); @@ -148,7 +148,7 @@ typedef struct svga_t uint16_t ksc5601_english_font_type; int vertical_linedbl; - + /*Used to implement CRTC[0x17] bit 2 hsync divisor*/ int hsync_divisor; @@ -167,7 +167,7 @@ typedef struct svga_t } svga_t; -extern int svga_init(const device_t *info, svga_t *svga, void *p, int memsize, +extern int svga_init(const device_t *info, svga_t *svga, void *p, int memsize, void (*recalctimings_ex)(struct svga_t *svga), uint8_t (*video_in) (uint16_t addr, void *p), void (*video_out)(uint16_t addr, uint8_t val, void *p), diff --git a/src/include/86box/vid_svga_render.h b/src/include/86box/vid_svga_render.h index 1bae05385..e480e81f7 100644 --- a/src/include/86box/vid_svga_render.h +++ b/src/include/86box/vid_svga_render.h @@ -16,6 +16,9 @@ * Copyright 2016-2018 Miran Grca. */ +#ifndef VIDEO_SVGA_RENDER_H +# define VIDEO_SVGA_RENDER_H + extern int firstline_draw, lastline_draw; extern int displine; extern int sc; @@ -66,3 +69,5 @@ void svga_render_RGBA8888_lowres(svga_t *svga); void svga_render_RGBA8888_highres(svga_t *svga); extern void (*svga_render)(svga_t *svga); + +#endif /*VID_SVGA_RENDER_H*/ diff --git a/src/include/86box/vid_svga_render_remap.h b/src/include/86box/vid_svga_render_remap.h index 5b7f0fe18..2602cc5c4 100644 --- a/src/include/86box/vid_svga_render_remap.h +++ b/src/include/86box/vid_svga_render_remap.h @@ -6,6 +6,9 @@ row 1 -> MA14 */ +#ifndef VIDEO_SVGA_RENDER_REMAP_H +# define VIDEO_SVGA_RENDER_REMAP_H + //S3 - enhanced mode mappings CR31.3 can force doubleword mode //Cirrus Logic handles SVGA writes seperately //S3, CL, TGUI blitters need checking @@ -100,7 +103,7 @@ static uint32_t (*address_remap_funcs[16])(svga_t *svga, uint32_t in_addr) = void svga_recalc_remap_func(svga_t *svga) { int func_nr; - + if (svga->fb_only || svga->force_byte_mode) func_nr = 0; else { @@ -114,7 +117,7 @@ void svga_recalc_remap_func(svga_t *svga) func_nr = VAR_WORD_MODE_MA15; else func_nr = VAR_WORD_MODE_MA13; - + if (!(svga->crtc[0x17] & 0x01)) func_nr |= VAR_ROW0_MA13; if (!(svga->crtc[0x17] & 0x02)) @@ -124,3 +127,5 @@ void svga_recalc_remap_func(svga_t *svga) svga->remap_required = (func_nr != 0); svga->remap_func = address_remap_funcs[func_nr]; } + +#endif /*VIDEO_RENDER_REMAP_H*/ diff --git a/src/include/86box/vid_vga.h b/src/include/86box/vid_vga.h index c8a9b132e..3ef627c43 100644 --- a/src/include/86box/vid_vga.h +++ b/src/include/86box/vid_vga.h @@ -16,13 +16,14 @@ * Copyright 2016-2018 Miran Grca. * Copyright 2021 Jasmine Iwanek. */ + #ifndef VIDEO_VGA_H # define VIDEO_VGA_H typedef struct vga_t { svga_t svga; - + rom_t bios_rom; } vga_t; diff --git a/src/include/86box/vid_voodoo_banshee.h b/src/include/86box/vid_voodoo_banshee.h index 808c861c8..b56caac88 100644 --- a/src/include/86box/vid_voodoo_banshee.h +++ b/src/include/86box/vid_voodoo_banshee.h @@ -15,4 +15,9 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_BANSHEE_H +# define VIDEO_VOODOO_BANSHEE_H + void banshee_set_overlay_addr(void *p, uint32_t addr); + +#endif /*VIDEO_VOODOO_BANSHEE_H*/ diff --git a/src/include/86box/vid_voodoo_banshee_blitter.h b/src/include/86box/vid_voodoo_banshee_blitter.h index 3d8c16a1b..ad4d68218 100644 --- a/src/include/86box/vid_voodoo_banshee_blitter.h +++ b/src/include/86box/vid_voodoo_banshee_blitter.h @@ -15,4 +15,9 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_BANSHEE_BLITTER_H +# define VIDEO_VOODOO_BANSHEE_BLITTER_H + void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val); + +#endif /*VIDEO_VOODOO_BANSHEE_BLITTER_H*/ diff --git a/src/include/86box/vid_voodoo_blitter.h b/src/include/86box/vid_voodoo_blitter.h index 63bd0a99e..20d845874 100644 --- a/src/include/86box/vid_voodoo_blitter.h +++ b/src/include/86box/vid_voodoo_blitter.h @@ -15,6 +15,11 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_BLITTER_H +# define VIDEO_VOODOO_BLITTER_H + void voodoo_v2_blit_start(voodoo_t *voodoo); void voodoo_v2_blit_data(voodoo_t *voodoo, uint32_t data); void voodoo_fastfill(voodoo_t *voodoo, voodoo_params_t *params); + +#endif /*VIDEO_VOODOO_BLITTER_H*/ diff --git a/src/include/86box/vid_voodoo_codegen_x86-64.h b/src/include/86box/vid_voodoo_codegen_x86-64.h index 443edc2cd..fa973c5ff 100644 --- a/src/include/86box/vid_voodoo_codegen_x86-64.h +++ b/src/include/86box/vid_voodoo_codegen_x86-64.h @@ -1,10 +1,13 @@ /*Registers : - + alphaMode fbzMode & 0x1f3fff fbzColorPath */ +#ifndef VIDEO_VOODOO_CODEGEN_X86_64_H +# define VIDEO_VOODOO_CODEGEN_X86_64_H + #ifdef _MSC_VER #include #else @@ -27,8 +30,8 @@ typedef struct voodoo_x86_data_t uint32_t fbzColorPath; uint32_t textureMode[2]; uint32_t tLOD[2]; - uint32_t trexInit1; - int is_tiled; + uint32_t trexInit1; + int is_tiled; } voodoo_x86_data_t; //static voodoo_x86_data_t voodoo_x86_data[2][BLOCK_NUM]; @@ -184,7 +187,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addlong(offsetof(voodoo_state_t, lod_max[tmu])); addbyte(0xc1); /*SHR EAX, 8*/ addbyte(0xe8); - addbyte(8); + addbyte(8); addbyte(0x89); /*MOV state->lod, EAX*/ addbyte(0x87); addlong(offsetof(voodoo_state_t, lod)); @@ -216,7 +219,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addlong(offsetof(voodoo_state_t, tex_s)); addbyte(0xc1); /*SHR EBX, 8*/ addbyte(0xeb); - addbyte(8); + addbyte(8); addbyte(0x48); /*MOV state->tex_t, RCX*/ addbyte(0x89); addbyte(0x8f); @@ -549,7 +552,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); addbyte(0x67); addbyte(0xc0); - + addbyte(0x4c); /*MOV RSI, R15*/ addbyte(0x89); addbyte(0xfe); @@ -557,7 +560,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x66); /*MOV EAX, XMM0*/ addbyte(0x0f); addbyte(0x7e); - addbyte(0xc0); + addbyte(0xc0); } else { @@ -674,7 +677,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v } static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int depthop) -{ +{ int block_pos = 0; int z_skip_pos = 0; int a_skip_pos = 0; @@ -712,7 +715,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x56); addbyte(0x41); /*PUSH R15*/ addbyte(0x57); - + addbyte(0x49); /*MOV R15, xmm_01_w*/ addbyte(0xbf); addquad((uint64_t)(uintptr_t)&xmm_01_w); @@ -877,7 +880,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo *(uint8_t *)&code_block[depth_jump_pos] = (block_pos - depth_jump_pos) - 1; if (depth_jump_pos) *(uint8_t *)&code_block[depth_jump_pos2] = (block_pos - depth_jump_pos2) - 1; - + if ((params->fogMode & (FOG_ENABLE|FOG_CONSTANT|FOG_Z|FOG_ALPHA)) == FOG_ENABLE) { addbyte(0x89); /*MOV state->w_depth[EDI], EAX*/ @@ -911,7 +914,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { addbyte(0x03); /*ADD EAX, params->zaColor[ESI]*/ addbyte(0x86); - addlong(offsetof(voodoo_params_t, zaColor)); + addlong(offsetof(voodoo_params_t, zaColor)); addbyte(0x25); /*AND EAX, 0xffff*/ addlong(0xffff); } @@ -997,14 +1000,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo /*XMM0 = colour*/ /*XMM2 = 0 (for unpacking*/ - + /*EDI = state, ESI = params*/ if ((params->textureMode[0] & TEXTUREMODE_LOCAL_MASK) == TEXTUREMODE_LOCAL || !voodoo->dual_tmus) { /*TMU0 only sampling local colour or only one TMU, only sample TMU0*/ block_pos = codegen_texture_fetch(code_block, voodoo, params, state, block_pos, 0); - + addbyte(0x66); /*MOVD XMM0, EAX*/ addbyte(0x0f); addbyte(0x6e); @@ -1020,7 +1023,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { /*TMU0 in pass-through mode, only sample TMU1*/ block_pos = codegen_texture_fetch(code_block, voodoo, params, state, block_pos, 1); - + addbyte(0x66); /*MOVD XMM0, EAX*/ addbyte(0x0f); addbyte(0x6e); @@ -1328,7 +1331,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd8); addbyte(3); } - + block_pos = codegen_texture_fetch(code_block, voodoo, params, state, block_pos, 0); addbyte(0x66); /*MOVD XMM0, EAX*/ @@ -1339,7 +1342,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x6e); addbyte(0xf8); - + if (params->textureMode[0] & TEXTUREMODE_TRILINEAR) { addbyte(0x8b); /*MOV EAX, state->lod*/ @@ -1564,7 +1567,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0xc9); } - + addbyte(0x66); /*PACKUSWB XMM0, XMM0*/ addbyte(0x0f); addbyte(0x67); @@ -1577,7 +1580,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x67); addbyte(0xc9); - + if (tca_zero_other) { addbyte(0x31); /*XOR EAX, EAX*/ @@ -1845,7 +1848,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x8f); addlong(offsetof(voodoo_state_t, ia)); addbyte(0x31); /*XOR EAX, EAX*/ - addbyte(0xc0); + addbyte(0xc0); addbyte(0xba); /*MOV EDX, 0xff*/ addlong(0xff); addbyte(0xc1);/*SAR ECX, 12*/ @@ -1874,7 +1877,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo if (a_sel != A_SEL_ITER_A) { addbyte(0x31); /*XOR EAX, EAX*/ - addbyte(0xc0); + addbyte(0xc0); addbyte(0xba); /*MOV EDX, 0xff*/ addlong(0xff); } @@ -1890,7 +1893,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x47); addbyte(0xca); break; - + default: addbyte(0xb9); /*MOV ECX, 0xff*/ addlong(0xff); @@ -1907,7 +1910,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x89); /*MOV EDX, EBX*/ addbyte(0xda); } - + if (cca_sub_clocal) { addbyte(0x29); /*SUB EDX, ECX*/ @@ -2124,7 +2127,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x31); /*XOR EAX, EAX*/ addbyte(0xc0); } - + if (!(cc_mselect == 0 && cc_reverse_blend == 0) && cc_mselect == CC_MSELECT_AOTHER) { /*Copy a_other to XMM3 before it gets modified*/ @@ -2138,7 +2141,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xdb); addbyte(0x00); } - + if (cca_add && (params->alphaMode & ((1 << 0) | (1 << 4)))) { addbyte(0x01); /*ADD EDX, ECX*/ @@ -2233,7 +2236,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0xdb); - break; + break; } addbyte(0xf3); /*MOV XMM4, XMM0*/ addbyte(0x0f); @@ -2274,7 +2277,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x6b); addbyte(0xc0); } - + if (cc_add == 1) { addbyte(0x66); /*PADDW XMM0, XMM1*/ @@ -2299,8 +2302,8 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo if (params->fogMode & FOG_ENABLE) { - if (params->fogMode & FOG_CONSTANT) - { + if (params->fogMode & FOG_CONSTANT) + { addbyte(0x66); /*MOVD XMM3, params->fogColor[ESI]*/ addbyte(0x0f); addbyte(0x6e); @@ -2310,15 +2313,15 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xdc); addbyte(0xc3); - } - else - { + } + else + { addbyte(0x66); /*PUNPCKLBW XMM0, XMM2*/ addbyte(0x0f); addbyte(0x60); addbyte(0xc2); - if (!(params->fogMode & FOG_ADD)) + if (!(params->fogMode & FOG_ADD)) { addbyte(0x66); /*MOVD XMM3, params->fogColor[ESI]*/ addbyte(0x0f); @@ -2329,7 +2332,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x60); addbyte(0xda); - } + } else { addbyte(0x66); /*PXOR XMM3, XMM3*/ @@ -2337,7 +2340,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0xdb); } - + if (!(params->fogMode & FOG_MULT)) { addbyte(0x66); /*PSUBW XMM3, XMM0*/ @@ -2391,7 +2394,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo fog_a = params->fogTable[fog_idx].fog; fog_a += (params->fogTable[fog_idx].dfog * ((w_depth >> 2) & 0xff)) >> 10;*/ break; - + case FOG_Z: addbyte(0x8b); /*MOV EAX, state->z[EDI]*/ addbyte(0x87); @@ -2403,7 +2406,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addlong(0xff); // fog_a = (z >> 20) & 0xff; break; - + case FOG_ALPHA: addbyte(0x8b); /*MOV EAX, state->ia[EDI]*/ addbyte(0x87); @@ -2425,7 +2428,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xc3); // fog_a = CLAMP(ia >> 12); break; - + case FOG_W: addbyte(0x8b); /*MOV EAX, state->w[EDI]+4*/ addbyte(0x87); @@ -2537,7 +2540,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { addbyte(0xC3); /*RET*/ } - + if (params->alphaMode & (1 << 4)) { addbyte(0x49); /*MOV R8, rgb565*/ @@ -2578,7 +2581,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x7e); addbyte(0xf4); - + switch (dest_afunc) { case AFUNC_AZERO: @@ -2916,7 +2919,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo case AFUNC_ACOLORBEFOREFOG: break; } - + addbyte(0x66); /*PADDW XMM0, XMM4*/ addbyte(0x0f); addbyte(0xfd); @@ -2939,7 +2942,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x7e); addbyte(0xc0); - + if (params->fbzMode & FBZ_RGB_WMASK) { if (dither) @@ -3139,7 +3142,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x6f); addbyte(0x86); - addlong(offsetof(voodoo_params_t, dBdX)); + addlong(offsetof(voodoo_params_t, dBdX)); addbyte(0x8b); /*MOV EAX, params->dZdX[ESI]*/ addbyte(0x86); addlong(offsetof(voodoo_params_t, dZdX)); @@ -3201,7 +3204,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xc7); addbyte(0x01); /*ADD state->z[EDI], EAX*/ addbyte(0x87); - addlong(offsetof(voodoo_state_t, z)); + addlong(offsetof(voodoo_state_t, z)); } else { @@ -3219,7 +3222,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xc7); addbyte(0x29); /*SUB state->z[EDI], EAX*/ addbyte(0x87); - addlong(offsetof(voodoo_state_t, z)); + addlong(offsetof(voodoo_state_t, z)); } if (voodoo->dual_tmus) @@ -3287,7 +3290,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfb); addbyte(0xe6); } - + addbyte(0xf3); /*MOVDQU state->tmu1_s, XMM3*/ addbyte(0x0f); addbyte(0x7f); @@ -3299,7 +3302,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xa7); addlong(offsetof(voodoo_state_t, tmu1_w)); } - + addbyte(0x83); /*ADD state->pixel_count[EDI], 1*/ addbyte(0x87); addlong(offsetof(voodoo_state_t, pixel_count)); @@ -3321,13 +3324,13 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x87); addlong(offsetof(voodoo_state_t, texel_count)); addbyte(2); - } + } } addbyte(0x8b); /*MOV EAX, state->x[EDI]*/ addbyte(0x87); addlong(offsetof(voodoo_state_t, x)); - + if (state->xdir > 0) { addbyte(0x83); /*ADD state->x[EDI], 1*/ @@ -3351,18 +3354,18 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addlong(loop_jump_pos - (block_pos + 4)); addbyte(0x41); /*POP R15*/ - addbyte(0x5f); + addbyte(0x5f); addbyte(0x41); /*POP R14*/ addbyte(0x5e); addbyte(0x41); /*POP R13*/ - addbyte(0x5d); + addbyte(0x5d); addbyte(0x41); /*POP R12*/ addbyte(0x5c); - addbyte(0x5b); /*POP RBX*/ + addbyte(0x5b); /*POP RBX*/ addbyte(0x5e); /*POP RSI*/ addbyte(0x5f); /*POP RDI*/ addbyte(0x5d); /*POP RBP*/ - + addbyte(0xC3); /*RET*/ } int voodoo_recomp = 0; @@ -3372,11 +3375,11 @@ static inline void *voodoo_get_block(voodoo_t *voodoo, voodoo_params_t *params, int b = last_block[odd_even]; voodoo_x86_data_t *voodoo_x86_data = voodoo->codegen_data; voodoo_x86_data_t *data; - + for (c = 0; c < 8; c++) { data = &voodoo_x86_data[odd_even + c*4]; //&voodoo_x86_data[odd_even][b]; - + if (state->xdir == data->xdir && params->alphaMode == data->alphaMode && params->fbzMode == data->fbzMode && @@ -3392,13 +3395,13 @@ static inline void *voodoo_get_block(voodoo_t *voodoo, voodoo_params_t *params, last_block[odd_even] = b; return data->code_block; } - + b = (b + 1) & 7; } voodoo_recomp++; data = &voodoo_x86_data[odd_even + next_block_to_write[odd_even]*4]; // code_block = data->code_block; - + voodoo_generate(data->code_block, voodoo, params, state, depth_op); data->xdir = state->xdir; @@ -3414,7 +3417,7 @@ voodoo_recomp++; data->is_tiled = (params->col_tiled || params->aux_tiled) ? 1 : 0; next_block_to_write[odd_even] = (next_block_to_write[odd_even] + 1) & 7; - + return data->code_block; } @@ -3429,7 +3432,7 @@ void voodoo_codegen_init(voodoo_t *voodoo) int d[4]; int _ds = c & 0xf; int dt = c >> 4; - + alookup[c] = _mm_set_epi32(0, 0, c | (c << 16), c | (c << 16)); aminuslookup[c] = _mm_set_epi32(0, 0, (255-c) | ((255-c) << 16), (255-c) | ((255-c) << 16)); @@ -3450,3 +3453,5 @@ void voodoo_codegen_close(voodoo_t *voodoo) { plat_munmap(voodoo->codegen_data, sizeof(voodoo_x86_data_t) * BLOCK_NUM*4); } + +#endif /*VIDEO_VOODOO_CODEGEN_X86_64_H*/ diff --git a/src/include/86box/vid_voodoo_codegen_x86.h b/src/include/86box/vid_voodoo_codegen_x86.h index b6d60e5ff..e1afdd163 100644 --- a/src/include/86box/vid_voodoo_codegen_x86.h +++ b/src/include/86box/vid_voodoo_codegen_x86.h @@ -1,10 +1,13 @@ /*Registers : - + alphaMode fbzMode & 0x1f3fff fbzColorPath */ +#ifndef VIDEO_VOODOO_CODEGEN_X86_H +# define VIDEO_VOODOO_CODEGEN_X86_H + #ifdef _MSC_VER #include #else @@ -199,7 +202,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0xd8); addbyte(0xc1); /*SHR EAX, 8*/ addbyte(0xe8); - addbyte(8); + addbyte(8); addbyte(0x66); /*MOVQ state->tex_s, XMM4*/ addbyte(0x0f); addbyte(0xd6); @@ -415,7 +418,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x7e); addbyte(0x0c); addbyte(0x82); - + if (state->clamp_s[tmu]) { addbyte(0xeb); /*JMP +*/ @@ -489,7 +492,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); addbyte(0x60); addbyte(0xca); - + addbyte(0x81); /*ADD ESI, bilinear_lookup*/ addbyte(0xc6); addlong((uint32_t)bilinear_lookup); @@ -529,7 +532,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); addbyte(0x67); addbyte(0xc0); - + addbyte(0x8b); /*MOV ESI, [ESP+8]*/ addbyte(0x74); addbyte(0x24); @@ -538,7 +541,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x66); /*MOV EAX, XMM0*/ addbyte(0x0f); addbyte(0x7e); - addbyte(0xc0); + addbyte(0xc0); } else { @@ -657,7 +660,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v } static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int depthop) -{ +{ int block_pos = 0; int z_skip_pos = 0; int a_skip_pos = 0; @@ -687,7 +690,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x57); /*PUSH EDI*/ addbyte(0x56); /*PUSH ESI*/ addbyte(0x53); /*PUSH EBX*/ - + addbyte(0x8b); /*MOV EDI, [ESP+4]*/ addbyte(0x7c); addbyte(0x24); @@ -788,7 +791,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo *(uint8_t *)&code_block[depth_jump_pos] = (block_pos - depth_jump_pos) - 1; if (depth_jump_pos) *(uint8_t *)&code_block[depth_jump_pos2] = (block_pos - depth_jump_pos2) - 1; - + if ((params->fogMode & (FOG_ENABLE|FOG_CONSTANT|FOG_Z|FOG_ALPHA)) == FOG_ENABLE) { addbyte(0x89); /*MOV state->w_depth[EDI], EAX*/ @@ -817,13 +820,13 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x47); addbyte(0xc3); } - + if (params->fbzMode & FBZ_DEPTH_BIAS) { addbyte(0x0f); /*MOVSX EDX, params->zaColor[ESI]*/ addbyte(0xbf); addbyte(0x96); - addlong(offsetof(voodoo_params_t, zaColor)); + addlong(offsetof(voodoo_params_t, zaColor)); if (params->fbzMode & FBZ_W_BUFFER) { addbyte(0xbb); /*MOV EBX, 0xffff*/ @@ -932,14 +935,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo // voodoo_combine = &code_block[block_pos]; /*XMM0 = colour*/ /*XMM2 = 0 (for unpacking*/ - + /*EDI = state, ESI = params*/ if ((params->textureMode[0] & TEXTUREMODE_LOCAL_MASK) == TEXTUREMODE_LOCAL || !voodoo->dual_tmus) { /*TMU0 only sampling local colour or only one TMU, only sample TMU0*/ block_pos = codegen_texture_fetch(code_block, voodoo, params, state, block_pos, 0); - + addbyte(0x66); /*MOVD XMM0, EAX*/ addbyte(0x0f); addbyte(0x6e); @@ -955,7 +958,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { /*TMU0 in pass-through mode, only sample TMU1*/ block_pos = codegen_texture_fetch(code_block, voodoo, params, state, block_pos, 1); - + addbyte(0x66); /*MOVD XMM0, EAX*/ addbyte(0x0f); addbyte(0x6e); @@ -1265,7 +1268,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd8); addbyte(3); } - + block_pos = codegen_texture_fetch(code_block, voodoo, params, state, block_pos, 0); addbyte(0x66); /*MOVD XMM0, EAX*/ @@ -1276,7 +1279,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x6e); addbyte(0xf8); - + if (params->textureMode[0] & TEXTUREMODE_TRILINEAR) { addbyte(0x8b); /*MOV EAX, state->lod*/ @@ -1472,7 +1475,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xeb); addbyte(24); } - + if (tc_add_clocal) { addbyte(0x66); /*PADDW XMM1, XMM0*/ @@ -1492,7 +1495,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0xcc); } - + addbyte(0x66); /*PACKUSWB XMM0, XMM0*/ addbyte(0x0f); addbyte(0x67); @@ -1513,7 +1516,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0d); addlong((uint32_t)&xmm_ff_b); } - + if (tca_zero_other) { addbyte(0x31); /*XOR EAX, EAX*/ @@ -1780,7 +1783,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x8f); addlong(offsetof(voodoo_state_t, ia)); addbyte(0x31); /*XOR EAX, EAX*/ - addbyte(0xc0); + addbyte(0xc0); addbyte(0xba); /*MOV EDX, 0xff*/ addlong(0xff); addbyte(0xc1);/*SAR ECX, 12*/ @@ -1809,7 +1812,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo if (a_sel != A_SEL_ITER_A) { addbyte(0x31); /*XOR EAX, EAX*/ - addbyte(0xc0); + addbyte(0xc0); addbyte(0xba); /*MOV EDX, 0xff*/ addlong(0xff); } @@ -1825,7 +1828,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x47); addbyte(0xca); break; - + default: addbyte(0xb9); /*MOV ECX, 0xff*/ addlong(0xff); @@ -1842,7 +1845,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x89); /*MOV EDX, EBX*/ addbyte(0xda); } - + if (cca_sub_clocal) { addbyte(0x29); /*SUB EDX, ECX*/ @@ -2058,7 +2061,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x31); /*XOR EAX, EAX*/ addbyte(0xc0); } - + if (!(cc_mselect == 0 && cc_reverse_blend == 0) && cc_mselect == CC_MSELECT_AOTHER) { /*Copy a_other to XMM3 before it gets modified*/ @@ -2072,13 +2075,13 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xdb); addbyte(0x00); } - + if (cca_add && (params->alphaMode & ((1 << 0) | (1 << 4)))) { addbyte(0x01); /*ADD EDX, ECX*/ addbyte(0xca); } - + if ((params->alphaMode & ((1 << 0) | (1 << 4)))) { addbyte(0x85); /*TEST EDX, EDX*/ @@ -2209,7 +2212,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x6b); addbyte(0xc0); } - + if (cc_add == 1) { addbyte(0x66); /*PADDW XMM0, XMM1*/ @@ -2239,8 +2242,8 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo // addlong(offsetof(voodoo_state_t, out)); if (params->fogMode & FOG_ENABLE) { - if (params->fogMode & FOG_CONSTANT) - { + if (params->fogMode & FOG_CONSTANT) + { addbyte(0x66); /*MOVD XMM3, params->fogColor[ESI]*/ addbyte(0x0f); addbyte(0x6e); @@ -2250,20 +2253,20 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xdc); addbyte(0xc3); -/* src_r += params->fogColor.r; - src_g += params->fogColor.g; +/* src_r += params->fogColor.r; + src_g += params->fogColor.g; src_b += params->fogColor.b; */ - } - else - { + } + else + { /*int fog_r, fog_g, fog_b, fog_a; */ - + addbyte(0x66); /*PUNPCKLBW XMM0, XMM2*/ addbyte(0x0f); addbyte(0x60); addbyte(0xc2); - if (!(params->fogMode & FOG_ADD)) + if (!(params->fogMode & FOG_ADD)) { addbyte(0x66); /*MOVD XMM3, params->fogColor[ESI]*/ addbyte(0x0f); @@ -2274,7 +2277,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x60); addbyte(0xda); - } + } else { addbyte(0x66); /*PXOR XMM3, XMM3*/ @@ -2282,7 +2285,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0xdb); } - + if (!(params->fogMode & FOG_MULT)) { addbyte(0x66); /*PSUBW XMM3, XMM0*/ @@ -2337,7 +2340,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo fog_a = params->fogTable[fog_idx].fog; fog_a += (params->fogTable[fog_idx].dfog * ((w_depth >> 2) & 0xff)) >> 10;*/ break; - + case FOG_Z: addbyte(0x8b); /*MOV EAX, state->z[EDI]*/ addbyte(0x87); @@ -2349,7 +2352,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addlong(0xff); // fog_a = (z >> 20) & 0xff; break; - + case FOG_ALPHA: addbyte(0x8b); /*MOV EAX, state->ia[EDI]*/ addbyte(0x87); @@ -2371,7 +2374,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xc3); // fog_a = CLAMP(ia >> 12); break; - + case FOG_W: addbyte(0x8b); /*MOV EAX, state->w[EDI]+4*/ addbyte(0x87); @@ -2493,7 +2496,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { addbyte(0xC3); /*RET*/ } - + if (params->alphaMode & (1 << 4)) { addbyte(0x8b); /*MOV EAX, state->x[EDI]*/ @@ -2530,7 +2533,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x7e); addbyte(0xf4); - + switch (dest_afunc) { case AFUNC_AZERO: @@ -2859,7 +2862,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo case AFUNC_ACOLORBEFOREFOG: break; } - + addbyte(0x66); /*PADDW XMM0, XMM4*/ addbyte(0x0f); addbyte(0xfd); @@ -2870,7 +2873,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x67); addbyte(0xc0); } -//#endif +//#endif // addbyte(0x8b); /*MOV EDX, x (ESP+12)*/ // addbyte(0x54); @@ -2889,13 +2892,13 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x7e); addbyte(0xc0); - + if (params->fbzMode & FBZ_RGB_WMASK) { // addbyte(0x89); /*MOV state->rgb_out[EDI], EAX*/ // addbyte(0x87); // addlong(offsetof(voodoo_state_t, rgb_out)); - + if (dither) { addbyte(0x8b); /*MOV ESI, real_y (ESP+16)*/ @@ -3146,7 +3149,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0x6f); addbyte(0x86); - addlong(offsetof(voodoo_params_t, dBdX)); + addlong(offsetof(voodoo_params_t, dBdX)); addbyte(0x8b); /*MOV EAX, params->dZdX[ESI]*/ addbyte(0x86); addlong(offsetof(voodoo_params_t, dZdX)); @@ -3208,7 +3211,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xc7); addbyte(0x01); /*ADD state->z[EDI], EAX*/ addbyte(0x87); - addlong(offsetof(voodoo_state_t, z)); + addlong(offsetof(voodoo_state_t, z)); } else { @@ -3226,7 +3229,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xc7); addbyte(0x29); /*SUB state->z[EDI], EAX*/ addbyte(0x87); - addlong(offsetof(voodoo_state_t, z)); + addlong(offsetof(voodoo_state_t, z)); } addbyte(0xf3); /*MOVDQU state->tmu0_s, XMM3*/ @@ -3244,7 +3247,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd6); addbyte(0x87); addlong(offsetof(voodoo_state_t, w)); - + addbyte(0x83); /*ADD state->pixel_count[EDI], 1*/ addbyte(0x87); addlong(offsetof(voodoo_state_t, pixel_count)); @@ -3266,12 +3269,12 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x87); addlong(offsetof(voodoo_state_t, texel_count)); addbyte(2); - } + } } addbyte(0x8b); /*MOV EAX, state->x[EDI]*/ addbyte(0x87); addlong(offsetof(voodoo_state_t, x)); - + if (state->xdir > 0) { addbyte(0x83); /*ADD state->x[EDI], 1*/ @@ -3293,14 +3296,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); /*JNZ loop_jump_pos*/ addbyte(0x85); addlong(loop_jump_pos - (block_pos + 4)); - - addbyte(0x5b); /*POP EBX*/ + + addbyte(0x5b); /*POP EBX*/ addbyte(0x5e); /*POP ESI*/ addbyte(0x5f); /*POP EDI*/ addbyte(0x5d); /*POP EBP*/ - + addbyte(0xC3); /*RET*/ - + if (params->textureMode[1] & TEXTUREMODE_TRILINEAR) cs = cs; } @@ -3312,11 +3315,11 @@ static inline void *voodoo_get_block(voodoo_t *voodoo, voodoo_params_t *params, int b = last_block[odd_even]; voodoo_x86_data_t *data; voodoo_x86_data_t *codegen_data = voodoo->codegen_data; - + for (c = 0; c < 8; c++) { data = &codegen_data[odd_even + b*4]; - + if (state->xdir == data->xdir && params->alphaMode == data->alphaMode && params->fbzMode == data->fbzMode && @@ -3332,13 +3335,13 @@ static inline void *voodoo_get_block(voodoo_t *voodoo, voodoo_params_t *params, last_block[odd_even] = b; return data->code_block; } - + b = (b + 1) & 7; } voodoo_recomp++; data = &codegen_data[odd_even + next_block_to_write[odd_even]*4]; // code_block = data->code_block; - + voodoo_generate(data->code_block, voodoo, params, state, depth_op); data->xdir = state->xdir; @@ -3354,7 +3357,7 @@ voodoo_recomp++; data->is_tiled = (params->col_tiled || params->aux_tiled) ? 1 : 0; next_block_to_write[odd_even] = (next_block_to_write[odd_even] + 1) & 7; - + return data->code_block; } @@ -3369,7 +3372,7 @@ void voodoo_codegen_init(voodoo_t *voodoo) int d[4]; int _ds = c & 0xf; int dt = c >> 4; - + alookup[c] = _mm_set_epi32(0, 0, c | (c << 16), c | (c << 16)); aminuslookup[c] = _mm_set_epi32(0, 0, (255-c) | ((255-c) << 16), (255-c) | ((255-c) << 16)); @@ -3390,3 +3393,5 @@ void voodoo_codegen_close(voodoo_t *voodoo) { plat_munmap(voodoo->codegen_data, sizeof(voodoo_x86_data_t) * BLOCK_NUM*4); } + +#endif /*VIDEO_VOODOO_CODEGEN_X86_H*/ diff --git a/src/include/86box/vid_voodoo_common.h b/src/include/86box/vid_voodoo_common.h index 8000f30c9..6af42e9ec 100644 --- a/src/include/86box/vid_voodoo_common.h +++ b/src/include/86box/vid_voodoo_common.h @@ -16,6 +16,9 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_COMMON_H +# define VIDEO_VOODOO_COMMON_H + #ifdef CLAMP #undef CLAMP #endif @@ -233,7 +236,7 @@ typedef struct voodoo_t int row_width, aux_row_width; int block_width; - + int col_tiled, aux_tiled; uint8_t *fb_mem, *tex_mem[2]; @@ -365,7 +368,7 @@ typedef struct voodoo_t uint32_t bltCommand; uint32_t leftOverlayBuf; - + struct { int dst_x, dst_y; @@ -393,7 +396,7 @@ typedef struct voodoo_t uint32_t srcFormat; uint32_t srcSize; uint32_t srcXY; - + uint32_t colorPattern[64]; int bres_error_0, bres_error_1; @@ -412,11 +415,11 @@ typedef struct voodoo_t int srcX, srcY; int src_stride; int old_srcX; - + /*Used for handling packed 24bpp host data*/ int host_data_remainder; uint32_t old_host_data; - + /*Polyfill coordinates*/ int lx[2], rx[2]; int ly[2], ry[2]; @@ -428,18 +431,18 @@ typedef struct voodoo_t int lx_cur, rx_cur; clip_t clip[2]; - + uint8_t host_data[16384]; int host_data_count; int host_data_size_src, host_data_size_dest; int src_stride_src, src_stride_dest; - + int src_bpp; int line_pix_pos, line_bit_pos; int line_rep_cnt, line_bit_mask_size; } banshee_blt; - + struct { uint32_t vidOverlayStartCoords; @@ -447,12 +450,12 @@ typedef struct voodoo_t uint32_t vidOverlayDudx, vidOverlayDudxOffsetSrcWidth; uint32_t vidOverlayDvdy, vidOverlayDvdyOffset; //uint32_t vidDesktopOverlayStride; - + int start_x, start_y; int end_x, end_y; int size_x, size_y; int overlay_bytes; - + unsigned int src_y; } overlay; @@ -466,7 +469,7 @@ typedef struct voodoo_t int fb_write_buffer, fb_draw_buffer; int buffer_cutoff; - + uint32_t tile_base, tile_stride; int tile_stride_shift, tile_x, tile_x_real; @@ -504,7 +507,7 @@ typedef struct voodoo_t uint8_t fifo_thread_run, render_thread_run[4]; uint8_t *vram, *changedvram; - + void *p; } voodoo_t; @@ -528,3 +531,5 @@ void voodoo_update_ncc(voodoo_t *voodoo, int tmu); void *voodoo_2d3d_card_init(int type); void voodoo_card_close(voodoo_t *voodoo); + +#endif /*VIDEO_VOODOO_COMMON_H*/ diff --git a/src/include/86box/vid_voodoo_display.h b/src/include/86box/vid_voodoo_display.h index 4768a2b62..522584e3f 100644 --- a/src/include/86box/vid_voodoo_display.h +++ b/src/include/86box/vid_voodoo_display.h @@ -16,9 +16,14 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_DISPLAY_H +# define VIDEO_VOODOO_DISPLAY_H + void voodoo_update_ncc(voodoo_t *voodoo, int tmu); void voodoo_pixelclock_update(voodoo_t *voodoo); void voodoo_generate_filter_v1(voodoo_t *voodoo); void voodoo_generate_filter_v2(voodoo_t *voodoo); void voodoo_threshold_check(voodoo_t *voodoo); void voodoo_callback(void *p); + +#endif /*VIDEO_VOODOO_DISPLAY_H*/ diff --git a/src/include/86box/vid_voodoo_dither.h b/src/include/86box/vid_voodoo_dither.h index 6457ac8c6..1b95e7e80 100644 --- a/src/include/86box/vid_voodoo_dither.h +++ b/src/include/86box/vid_voodoo_dither.h @@ -16,6 +16,9 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_DITHER_H +# define VIDEO_VOODOO_DITHER_H + static const uint8_t dither_rb[256][4][4] = { { @@ -10288,3 +10291,5 @@ static const uint8_t dithersub_rb2x2[256][2][2] = {253, 255}, }, }; + +#endif /* VIDEO_VOODOO_DITHER_H*/ diff --git a/src/include/86box/vid_voodoo_fb.h b/src/include/86box/vid_voodoo_fb.h index 95a223324..6acf624aa 100644 --- a/src/include/86box/vid_voodoo_fb.h +++ b/src/include/86box/vid_voodoo_fb.h @@ -16,7 +16,12 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_FB_H +# define VIDEO_VOODOO_FB_H + uint16_t voodoo_fb_readw(uint32_t addr, void *p); uint32_t voodoo_fb_readl(uint32_t addr, void *p); void voodoo_fb_writew(uint32_t addr, uint16_t val, void *p); void voodoo_fb_writel(uint32_t addr, uint32_t val, void *p); + +#endif /*VIDEO_VOODOO_FB_H*/ diff --git a/src/include/86box/vid_voodoo_fifo.h b/src/include/86box/vid_voodoo_fifo.h index 0ba2f6920..54b6567e8 100644 --- a/src/include/86box/vid_voodoo_fifo.h +++ b/src/include/86box/vid_voodoo_fifo.h @@ -16,6 +16,9 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_FIFO_H +# define VIDEO_VOODOO_FIFO_H + void voodoo_wake_fifo_thread(voodoo_t *voodoo); void voodoo_wake_fifo_thread_now(voodoo_t *voodoo); void voodoo_wake_timer(void *p); @@ -24,3 +27,5 @@ void voodoo_flush(voodoo_t *voodoo); void voodoo_wake_fifo_threads(voodoo_set_t *set, voodoo_t *voodoo); void voodoo_wait_for_swap_complete(voodoo_t *voodoo); void voodoo_fifo_thread(void *param); + +#endif /*VIDEO_VOODOO_FIFO_H*/ diff --git a/src/include/86box/vid_voodoo_reg.h b/src/include/86box/vid_voodoo_reg.h index 49fac4877..c535c7a18 100644 --- a/src/include/86box/vid_voodoo_reg.h +++ b/src/include/86box/vid_voodoo_reg.h @@ -16,4 +16,9 @@ * Copyright 2008-2020 Sarah Walker. */ +#ifndef VIDEO_VOODOO_REG_H +# define VIDEO_VOODOO_REG_H + void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p); + +#endif /*VIDEO_VOODOO_REG_H*/ diff --git a/src/include/86box/vid_voodoo_regs.h b/src/include/86box/vid_voodoo_regs.h index dfb924acf..2f488fabd 100644 --- a/src/include/86box/vid_voodoo_regs.h +++ b/src/include/86box/vid_voodoo_regs.h @@ -1,3 +1,6 @@ +#ifndef VIDEO_VOODOO_REGS_H +# define VIDEO_VOODOO_REGS_H + enum { SST_status = 0x000, @@ -144,7 +147,7 @@ enum SST_cmdFifoAMax = 0x1f0, SST_cmdFifoDepth = 0x1f4, SST_cmdFifoHoles = 0x1f8, - + SST_colBufferAddr = 0x1ec, /*Banshee*/ SST_colBufferStride = 0x1f0, /*Banshee*/ SST_auxBufferAddr = 0x1f4, /*Banshee*/ @@ -172,10 +175,10 @@ enum SST_fbiInit5 = 0x244, SST_fbiInit6 = 0x248, SST_fbiInit7 = 0x24c, - + SST_swapPending = 0x24c, /*Banshee*/ SST_leftOverlayBuf = 0x250, /*Banshee*/ - + SST_sSetupMode = 0x260, SST_sVx = 0x264, SST_sVy = 0x268, @@ -690,4 +693,6 @@ enum #define depth_op ( (params->fbzMode >> 5) & 7) #define dither ( params->fbzMode & FBZ_DITHER) #define dither2x2 (params->fbzMode & FBZ_DITHER_2x2) -#define dithersub (params->fbzMode & FBZ_DITHER_SUB) \ No newline at end of file +#define dithersub (params->fbzMode & FBZ_DITHER_SUB) + +#endif /*VIDEO_VOODOO_REGS_H*/ diff --git a/src/include/86box/vid_voodoo_render.h b/src/include/86box/vid_voodoo_render.h index 4596c59bb..5fb10d231 100644 --- a/src/include/86box/vid_voodoo_render.h +++ b/src/include/86box/vid_voodoo_render.h @@ -1,3 +1,6 @@ +#ifndef VIDEO_VOODOO_RENDER_H +# define VIDEO_VOODOO_RENDER_H + #if !(defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _M_IX86 || defined __amd64__ || defined _M_X64) #define NO_CODEGEN #endif @@ -336,3 +339,5 @@ static __inline void voodoo_wait_for_render_thread_idle(voodoo_t *voodoo) thread_wait_event(voodoo->render_not_full_event[3], 1); } } + +#endif /*VIDEO_VOODOO_RENDER_H*/ diff --git a/src/include/86box/vid_voodoo_setup.h b/src/include/86box/vid_voodoo_setup.h index 19056dd6b..047118701 100644 --- a/src/include/86box/vid_voodoo_setup.h +++ b/src/include/86box/vid_voodoo_setup.h @@ -15,4 +15,10 @@ * * Copyright 2008-2020 Sarah Walker. */ + +#ifndef VIDEO_VOODOO_SETUP_H +# define VIDEO_VOODOO_SETUP_H + void voodoo_triangle_setup(voodoo_t *voodoo); + +#endif /*VIDEO_VOODOO_SETUP_H*/ diff --git a/src/include/86box/vid_voodoo_texture.h b/src/include/86box/vid_voodoo_texture.h index 40c2b739a..cc2b13201 100644 --- a/src/include/86box/vid_voodoo_texture.h +++ b/src/include/86box/vid_voodoo_texture.h @@ -15,6 +15,10 @@ * * Copyright 2008-2020 Sarah Walker. */ + +#ifndef VIDEO_VOODOO_TEXTURE_H +# define VIDEO_VOODOO_TEXTURE_H + static const uint32_t texture_offset[LOD_MAX+3] = { 0, @@ -34,3 +38,5 @@ void voodoo_recalc_tex(voodoo_t *voodoo, int tmu); void voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu); void voodoo_tex_writel(uint32_t addr, uint32_t val, void *p); void flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu); + +#endif /* VIDEO_VOODOO_TEXTURE_H*/ diff --git a/src/include/86box/video.h b/src/include/86box/video.h index 05b7055b3..349d8f7b2 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -18,6 +18,7 @@ * Copyright 2016-2019 Miran Grca. * Copyright 2017-2019 Fred N. van Kempen. */ + #ifndef EMU_VIDEO_H # define EMU_VIDEO_H @@ -445,5 +446,4 @@ extern const device_t wy700_device; extern const device_t agpgart_device; #endif - #endif /*EMU_VIDEO_H*/ diff --git a/src/include/86box/vnc.h b/src/include/86box/vnc.h index 2d3dea3cd..1e0ddebba 100644 --- a/src/include/86box/vnc.h +++ b/src/include/86box/vnc.h @@ -14,6 +14,7 @@ * * Copyright 2017 Fred N. van Kempen. */ + #ifndef EMU_VNC_H # define EMU_VNC_H @@ -35,5 +36,4 @@ extern void vnc_take_screenshot(wchar_t *fn); } #endif - #endif /*EMU_VNC_H*/ diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 4fb6a7d00..5e9f67b36 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -19,6 +19,7 @@ * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2021 Laci bá' */ + #ifndef PLAT_WIN_H # define PLAT_WIN_H @@ -256,5 +257,4 @@ extern void ResetAllMenus(); } #endif - #endif /*PLAT_WIN_H*/ diff --git a/src/include/86box/win_opengl.h b/src/include/86box/win_opengl.h index 9e78c0aed..e05e99eb4 100644 --- a/src/include/86box/win_opengl.h +++ b/src/include/86box/win_opengl.h @@ -12,6 +12,7 @@ * * Copyright 2021 Teemu Korhonen */ + #ifndef WIN_OPENGL_H #define WIN_OPENGL_H @@ -25,4 +26,4 @@ extern void opengl_set_fs(int fs); extern void opengl_resize(int w, int h); extern void opengl_reload(void); -#endif /*!WIN_OPENGL_H*/ \ No newline at end of file +#endif /*!WIN_OPENGL_H*/ diff --git a/src/include/86box/win_opengl_glslp.h b/src/include/86box/win_opengl_glslp.h index dcc098635..9faf20705 100644 --- a/src/include/86box/win_opengl_glslp.h +++ b/src/include/86box/win_opengl_glslp.h @@ -12,6 +12,7 @@ * * Copyright 2021 Teemu Korhonen */ + #ifndef WIN_OPENGL_GLSLP_H #define WIN_OPENGL_GLSLP_H @@ -20,4 +21,4 @@ GLuint load_custom_shaders(const char* path); GLuint load_default_shaders(); -#endif /*!WIN_OPENGL_GLSLP_H*/ \ No newline at end of file +#endif /*!WIN_OPENGL_GLSLP_H*/ diff --git a/src/include/86box/win_sdl.h b/src/include/86box/win_sdl.h index aa082fe6c..bd510dbf1 100644 --- a/src/include/86box/win_sdl.h +++ b/src/include/86box/win_sdl.h @@ -46,6 +46,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef WIN_SDL_H # define WIN_SDL_H diff --git a/src/include/86box/zip.h b/src/include/86box/zip.h index 4a7c05cbd..722d51d91 100644 --- a/src/include/86box/zip.h +++ b/src/include/86box/zip.h @@ -15,10 +15,10 @@ * * Copyright 2018,2019 Miran Grca. */ + #ifndef EMU_ZIP_H #define EMU_ZIP_H - #define ZIP_NUM 4 #define BUF_SIZE 32768 @@ -123,5 +123,4 @@ extern void zip_close(); } #endif - #endif /*EMU_ZIP_H*/ diff --git a/src/include/FAudio_compat.h b/src/include/FAudio_compat.h new file mode 100644 index 000000000..dd76dea3d --- /dev/null +++ b/src/include/FAudio_compat.h @@ -0,0 +1,106 @@ +/* map xaudio2 API to faudio API */ +typedef uint32_t HRESULT; +typedef uint32_t UINT32; +typedef uint32_t DWORD; +typedef uint8_t BOOL; + +#define WINAPI FAUDIOCALL + +#define TRUE 1 +#define FALSE 0 + +#define S_OK 0 +#define XAUDIO2_E_INVALID_CALL FAUDIO_E_INVALID_CALL + +#define XAUDIO2_DEFAULT_PROCESSOR FAUDIO_DEFAULT_PROCESSOR +#define XAUDIO2_COMMIT_NOW FAUDIO_COMMIT_NOW +#define XAUDIO2_END_OF_STREAM FAUDIO_END_OF_STREAM + +#define WAVE_FORMAT_PCM FAUDIO_FORMAT_PCM +#define WAVE_FORMAT_IEEE_FLOAT FAUDIO_FORMAT_IEEE_FLOAT + +#define AudioCategory_GameEffects FAudioStreamCategory_GameEffects + +#define GlobalDefaultDevice FAudioGlobalDefaultDevice +#define NotDefaultDevice FAudioNotDefaultDevice + +#define XAudio2Create FAudioCreate + +typedef FAudioBuffer XAUDIO2_BUFFER; +typedef FAudioDeviceDetails XAUDIO2_DEVICE_DETAILS; +typedef FAudioEffectChain XAUDIO2_EFFECT_CHAIN; +typedef FAudioEffectDescriptor XAUDIO2_EFFECT_DESCRIPTOR; +typedef FAudioVoiceDetails XAUDIO2_VOICE_DETAILS; +typedef FAudioVoiceDetails XAUDIO27_VOICE_DETAILS; +typedef FAudioVoiceState XAUDIO2_VOICE_STATE; +typedef FAudioWaveFormatEx WAVEFORMATEX; +typedef FAudioPerformanceData XAUDIO2_PERFORMANCE_DATA; + +typedef FAudioEngineCallback IXAudio2EngineCallback; +typedef FAudioVoiceCallback IXAudio2VoiceCallback; + +typedef FAPO IXAPO; + +typedef FAudio IXAudio27; +#define IXAudio27_CreateMasteringVoice FAudio_CreateMasteringVoice +#define IXAudio27_CreateSourceVoice FAudio_CreateSourceVoice +#define IXAudio27_CreateSubmixVoice FAudio_CreateSubmixVoice +#define IXAudio27_GetDeviceCount FAudio_GetDeviceCount +#define IXAudio27_GetDeviceDetails FAudio_GetDeviceDetails +#define IXAudio27_GetPerformanceData FAudio_GetPerformanceData +#define IXAudio27_Initialize FAudio_Initialize +#define IXAudio27_RegisterForCallbacks FAudio_RegisterForCallbacks +#define IXAudio27_Release FAudio_Release +#define IXAudio27_StartEngine FAudio_StartEngine +#define IXAudio27_StopEngine FAudio_StopEngine +#define IXAudio27_UnregisterForCallbacks FAudio_UnregisterForCallbacks + +typedef FAudio IXAudio2; +#define IXAudio2_CreateMasteringVoice FAudio_CreateMasteringVoice8 +#define IXAudio2_CreateSourceVoice FAudio_CreateSourceVoice +#define IXAudio2_CreateSubmixVoice FAudio_CreateSubmixVoice +#define IXAudio2_GetPerformanceData FAudio_GetPerformanceData +#define IXAudio2_RegisterForCallbacks FAudio_RegisterForCallbacks +#define IXAudio2_Release FAudio_Release +#define IXAudio2_StartEngine FAudio_StartEngine +#define IXAudio2_StopEngine FAudio_StopEngine +#define IXAudio2_UnregisterForCallbacks FAudio_UnregisterForCallbacks + +typedef FAudioMasteringVoice IXAudio2MasteringVoice; +#define IXAudio2MasteringVoice_DestroyVoice FAudioVoice_DestroyVoice +#define IXAudio2MasteringVoice_GetChannelMask FAudioMasteringVoice_GetChannelMask +#define IXAudio2MasteringVoice_SetEffectChain FAudioVoice_SetEffectChain +#define IXAudio2MasteringVoice_SetVolume FAudioVoice_SetVolume + +typedef FAudioSourceVoice IXAudio27SourceVoice; +#define IXAudio27SourceVoice_DestroyVoice FAudioVoice_DestroyVoice +#define IXAudio27SourceVoice_ExitLoop FAudioSourceVoice_ExitLoop +#define IXAudio27SourceVoice_FlushSourceBuffers FAudioSourceVoice_FlushSourceBuffers +#define IXAudio27SourceVoice_GetState(a,b) FAudioSourceVoice_GetState(a,b,0) +#define IXAudio27SourceVoice_GetVoiceDetails FAudioVoice_GetVoiceDetails +#define IXAudio27SourceVoice_SetChannelVolumes FAudioVoice_SetChannelVolumes +#define IXAudio27SourceVoice_SetSourceSampleRate FAudioSourceVoice_SetSourceSampleRate +#define IXAudio27SourceVoice_Start FAudioSourceVoice_Start +#define IXAudio27SourceVoice_Stop FAudioSourceVoice_Stop +#define IXAudio27SourceVoice_SubmitSourceBuffer FAudioSourceVoice_SubmitSourceBuffer + +typedef FAudioSourceVoice IXAudio2SourceVoice; +#define IXAudio2SourceVoice_DestroyVoice FAudioVoice_DestroyVoice +#define IXAudio2SourceVoice_ExitLoop FAudioSourceVoice_ExitLoop +#define IXAudio2SourceVoice_FlushSourceBuffers FAudioSourceVoice_FlushSourceBuffers +#define IXAudio2SourceVoice_GetState FAudioSourceVoice_GetState +#define IXAudio2SourceVoice_GetVoiceDetails FAudioVoice_GetVoiceDetails +#define IXAudio2SourceVoice_SetChannelVolumes FAudioVoice_SetChannelVolumes +#define IXAudio2SourceVoice_SetSourceSampleRate FAudioSourceVoice_SetSourceSampleRate +#define IXAudio2SourceVoice_SetVolume FAudioVoice_SetVolume +#define IXAudio2SourceVoice_Start FAudioSourceVoice_Start +#define IXAudio2SourceVoice_Stop FAudioSourceVoice_Stop +#define IXAudio2SourceVoice_SubmitSourceBuffer FAudioSourceVoice_SubmitSourceBuffer + +typedef FAudioSubmixVoice IXAudio27SubmixVoice; +#define IXAudio27SubmixVoice_GetVoiceDetails FAudioVoice_GetVoiceDetails +#define IXAudio27SubmixVoice_DestroyVoice FAudioVoice_DestroyVoice + +typedef FAudioSubmixVoice IXAudio2SubmixVoice; +#define IXAudio2SubmixVoice_GetVoiceDetails FAudioVoice_GetVoiceDetails +#define IXAudio2SubmixVoice_DestroyVoice FAudioVoice_DestroyVoice diff --git a/src/include/KHR/khrplatform.h b/src/include/KHR/khrplatform.h index dd22d9270..01646449c 100644 --- a/src/include/KHR/khrplatform.h +++ b/src/include/KHR/khrplatform.h @@ -153,6 +153,20 @@ typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 +/* + * To support platform where unsigned long cannot be used interchangeably with + * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. + * Ideally, we could just use (u)intptr_t everywhere, but this could result in + * ABI breakage if khronos_uintptr_t is changed from unsigned long to + * unsigned long long or similar (this results in different C++ name mangling). + * To avoid changes for existing platforms, we restrict usage of intptr_t to + * platforms where the size of a pointer is larger than the size of long. + */ +#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) +#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ +#define KHRONOS_USE_INTPTR_T +#endif +#endif #elif defined(__VMS ) || defined(__sgi) @@ -235,14 +249,21 @@ typedef unsigned short int khronos_uint16_t; * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears * to be the only LLP64 architecture in current use. */ -#ifdef _WIN64 +#ifdef KHRONOS_USE_INTPTR_T +typedef intptr_t khronos_intptr_t; +typedef uintptr_t khronos_uintptr_t; +#elif defined(_WIN64) typedef signed long long int khronos_intptr_t; typedef unsigned long long int khronos_uintptr_t; -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; #else typedef signed long int khronos_intptr_t; typedef unsigned long int khronos_uintptr_t; +#endif + +#if defined(_WIN64) +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else typedef signed long int khronos_ssize_t; typedef unsigned long int khronos_usize_t; #endif diff --git a/src/include/discord_game_sdk.h b/src/include/discord_game_sdk.h index 50aa13736..e3779a7cc 100644 --- a/src/include/discord_game_sdk.h +++ b/src/include/discord_game_sdk.h @@ -1,4 +1,4 @@ -/* +/* * This file is distributed as a part of the Discord Game SDK. * Downloading, accessing, or using the API or SDK is bound by * the Discord Developer Terms of Service: @@ -650,4 +650,4 @@ enum EDiscordResult DiscordCreate(DiscordVersion version, struct DiscordCreatePa } #endif -#endif \ No newline at end of file +#endif diff --git a/src/include/lzf.h b/src/include/lzf.h index 919b6e6be..98e038f31 100644 --- a/src/include/lzf.h +++ b/src/include/lzf.h @@ -1,16 +1,16 @@ /* * Copyright (c) 2000-2008 Marc Alexander Lehmann - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -73,7 +73,7 @@ * and lzf_c.c. * */ -unsigned int +unsigned int lzf_compress (const void *const in_data, unsigned int in_len, void *out_data, unsigned int out_len); @@ -92,7 +92,7 @@ lzf_compress (const void *const in_data, unsigned int in_len, * * This function is very fast, about as fast as a copying loop. */ -unsigned int +unsigned int lzf_decompress (const void *const in_data, unsigned int in_len, void *out_data, unsigned int out_len); diff --git a/src/io.c b/src/io.c index 92b6b591c..9f9df62a4 100644 --- a/src/io.c +++ b/src/io.c @@ -193,7 +193,7 @@ io_removehandler_common(uint16_t base, int size, void -io_handler_common(int set, uint16_t base, int size, +io_handler_common(int set, uint16_t base, int size, uint8_t (*inb)(uint16_t addr, void *priv), uint16_t (*inw)(uint16_t addr, void *priv), uint32_t (*inl)(uint16_t addr, void *priv), @@ -210,7 +210,7 @@ io_handler_common(int set, uint16_t base, int size, void -io_sethandler(uint16_t base, int size, +io_sethandler(uint16_t base, int size, uint8_t (*inb)(uint16_t addr, void *priv), uint16_t (*inw)(uint16_t addr, void *priv), uint32_t (*inl)(uint16_t addr, void *priv), @@ -238,7 +238,7 @@ io_removehandler(uint16_t base, int size, void -io_handler(int set, uint16_t base, int size, +io_handler(int set, uint16_t base, int size, uint8_t (*inb)(uint16_t addr, void *priv), uint16_t (*inw)(uint16_t addr, void *priv), uint32_t (*inl)(uint16_t addr, void *priv), @@ -252,7 +252,7 @@ io_handler(int set, uint16_t base, int size, void -io_sethandler_interleaved(uint16_t base, int size, +io_sethandler_interleaved(uint16_t base, int size, uint8_t (*inb)(uint16_t addr, void *priv), uint16_t (*inw)(uint16_t addr, void *priv), uint32_t (*inl)(uint16_t addr, void *priv), @@ -280,7 +280,7 @@ io_removehandler_interleaved(uint16_t base, int size, void -io_handler_interleaved(int set, uint16_t base, int size, +io_handler_interleaved(int set, uint16_t base, int size, uint8_t (*inb)(uint16_t addr, void *priv), uint16_t (*inw)(uint16_t addr, void *priv), uint32_t (*inl)(uint16_t addr, void *priv), @@ -314,7 +314,7 @@ inb(uint16_t port) if (port & 0x80) amstrad_latch = AMSTRAD_NOLATCH; - else if (port & 0x4000) + else if (port & 0x4000) amstrad_latch = AMSTRAD_SW10; else amstrad_latch = AMSTRAD_SW9; @@ -403,7 +403,7 @@ inw(uint16_t port) if (port & 0x80) amstrad_latch = AMSTRAD_NOLATCH; - else if (port & 0x4000) + else if (port & 0x4000) amstrad_latch = AMSTRAD_SW10; else amstrad_latch = AMSTRAD_SW9; @@ -521,7 +521,7 @@ inl(uint16_t port) if (port & 0x80) amstrad_latch = AMSTRAD_NOLATCH; - else if (port & 0x4000) + else if (port & 0x4000) amstrad_latch = AMSTRAD_SW10; else amstrad_latch = AMSTRAD_SW9; diff --git a/src/mac/CMakeLists.txt b/src/mac/CMakeLists.txt index 6682d5bcd..ae3837f0e 100644 --- a/src/mac/CMakeLists.txt +++ b/src/mac/CMakeLists.txt @@ -51,4 +51,4 @@ set_target_properties(86Box set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed") set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES") set(XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-") -#set(XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/mac/codesign/dev/app.entitlements) \ No newline at end of file +#set(XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/mac/codesign/dev/app.entitlements) diff --git a/src/mac/macOSXGlue.m b/src/mac/macOSXGlue.m index 07b8c3552..d23c9abb8 100644 --- a/src/mac/macOSXGlue.m +++ b/src/mac/macOSXGlue.m @@ -41,5 +41,3 @@ void getDefaultROMPath(char* Path) strcpy(Path,[appDirectory fileSystemRepresentation]); // return appDirectory; } - - diff --git a/src/machine/CMakeLists.txt b/src/machine/CMakeLists.txt index a20c105fe..f642903ae 100644 --- a/src/machine/CMakeLists.txt +++ b/src/machine/CMakeLists.txt @@ -35,4 +35,4 @@ endif() if(OPEN_AT) target_compile_definitions(mch PRIVATE USE_OPEN_AT) -endif() \ No newline at end of file +endif() diff --git a/src/machine/m_amstrad.c b/src/machine/m_amstrad.c index 704933d0f..72cb73425 100644 --- a/src/machine/m_amstrad.c +++ b/src/machine/m_amstrad.c @@ -388,7 +388,7 @@ vid_poll_1512(void *priv) if (vid->cgamode & 0x20) { cols[1] = (attr & 15) + 16; cols[0] = ((attr >> 4) & 7) + 16; - if ((vid->blink & 16) && (attr & 0x80) && !drawcursor) + if ((vid->blink & 16) && (attr & 0x80) && !drawcursor) cols[1] = cols[0]; } else { cols[1] = (attr & 15) + 16; @@ -417,7 +417,7 @@ vid_poll_1512(void *priv) if (vid->cgamode & 0x20) { cols[1] = (attr & 15) + 16; cols[0] = ((attr >> 4) & 7) + 16; - if ((vid->blink & 16) && (attr & 0x80)) + if ((vid->blink & 16) && (attr & 0x80)) cols[1] = cols[0]; } else { cols[1] = (attr & 15) + 16; @@ -434,9 +434,9 @@ vid_poll_1512(void *priv) } } else { for (c = 0; c < 8; c++) { - buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = + buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = - buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = + buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[vid->fontbase + chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } @@ -504,13 +504,13 @@ vid_poll_1512(void *priv) if (vid->vsynctime) vid->stat |= 8; vid->displine++; - if (vid->displine >= 360) + if (vid->displine >= 360) vid->displine = 0; } else { timer_advance_u64(&vid->timer, vid->dispontime); - if ((vid->lastline - vid->firstline) == 199) + if ((vid->lastline - vid->firstline) == 199) vid->dispon = 0; /*Amstrad PC1512 always displays 200 lines, regardless of CRTC settings*/ - if (vid->dispon) + if (vid->dispon) vid->stat &= ~1; vid->linepos = 0; if (vid->vsynctime) { @@ -518,9 +518,9 @@ vid_poll_1512(void *priv) if (! vid->vsynctime) vid->stat &= ~8; } - if (vid->sc == (vid->crtc[11] & 31)) { - vid->con = 0; - vid->coff = 1; + if (vid->sc == (vid->crtc[11] & 31)) { + vid->con = 0; + vid->coff = 1; } if (vid->vadj) { vid->sc++; @@ -997,7 +997,7 @@ vid_speed_changed_200(void *priv) /* LCD colour mappings - * + * * 0 => solid green * 1 => blue on green * 2 => green on blue @@ -1059,13 +1059,13 @@ static void set_lcd_cols(uint8_t mode_reg) break; case 1: - lcdcols[c][0][0] = lcdcols[c][1][0] = + lcdcols[c][0][0] = lcdcols[c][1][0] = lcdcols[c][1][1] = green; lcdcols[c][0][1] = blue; break; case 2: - lcdcols[c][0][0] = lcdcols[c][1][0] = + lcdcols[c][0][0] = lcdcols[c][1][0] = lcdcols[c][1][1] = blue; lcdcols[c][0][1] = green; break; @@ -1090,7 +1090,7 @@ vid_in_200(uint16_t addr, void *priv) switch (addr) { case 0x03b8: return(mda->ctrl); - + case 0x03d8: return(cga->cgamode); @@ -1159,14 +1159,14 @@ vid_out_200(uint16_t addr, uint8_t val, void *priv) nmi = 1; return; -/* CGA writes ============================================================== */ +/* CGA writes ============================================================== */ case 0x03d1: case 0x03d3: case 0x03d5: case 0x03d7: if (!(vid->operation_ctrl & 0x40) && cga->crtcreg <= 11) { vid->crtc_index = 0x20 | (cga->crtcreg & 0x1f); - if (vid->operation_ctrl & 0x80) + if (vid->operation_ctrl & 0x80) nmi = 1; vid->reg_3df = val; return; @@ -1198,7 +1198,7 @@ vid_out_200(uint16_t addr, uint8_t val, void *priv) case 0x03de: vid->crtc_index = 0x1f; /* NMI only seems to be triggered if the value being written has the high - * bit set (enable NMI). So it only protects writes to this port if you + * bit set (enable NMI). So it only protects writes to this port if you * let it? */ if (val & 0x80) { vid->operation_ctrl = val; @@ -1226,12 +1226,12 @@ vid_out_200(uint16_t addr, uint8_t val, void *priv) timer_advance_u64(&vid->timer, 1); /* Bit 2 disables the IDA. We don't support dynamic enabling - * and disabling of the IDA (instead, PCEM disconnects the - * IDA from the bus altogether) so don't implement this */ + * and disabling of the IDA (instead, PCEM disconnects the + * IDA from the bus altogether) so don't implement this */ - /* Enable the appropriate memory ranges depending whether + /* Enable the appropriate memory ranges depending whether * the IDA is configured as MDA or CGA */ - if (vid->emulation == PC200_MDA || + if (vid->emulation == PC200_MDA || vid->emulation == PC200_LCDM) { mem_mapping_disable(&vid->cga.mapping); mem_mapping_enable(&vid->mda.mapping); @@ -1251,8 +1251,8 @@ vid_out_200(uint16_t addr, uint8_t val, void *priv) } -static void -lcd_draw_char_80(amsvid_t *vid, uint32_t *buffer, uint8_t chr, +static void +lcd_draw_char_80(amsvid_t *vid, uint32_t *buffer, uint8_t chr, uint8_t attr, int drawcursor, int blink, int sc, int mode160, uint8_t control) { @@ -1262,8 +1262,8 @@ lcd_draw_char_80(amsvid_t *vid, uint32_t *buffer, uint8_t chr, uint16_t mask; if (attr & 8) { /* bright */ - /* The brightness algorithm appears to be: replace any bit sequence 011 - * with 001 (assuming an extra 0 to the left of the byte). + /* The brightness algorithm appears to be: replace any bit sequence 011 + * with 001 (assuming an extra 0 to the left of the byte). */ bright = bits; for (c = 0, mask = 0x100; c < 7; c++, mask >>= 1) { @@ -1285,8 +1285,8 @@ lcd_draw_char_80(amsvid_t *vid, uint32_t *buffer, uint8_t chr, } -static void -lcd_draw_char_40(amsvid_t *vid, uint32_t *buffer, uint8_t chr, +static void +lcd_draw_char_40(amsvid_t *vid, uint32_t *buffer, uint8_t chr, uint8_t attr, int drawcursor, int blink, int sc, uint8_t control) { @@ -1310,7 +1310,7 @@ lcd_draw_char_40(amsvid_t *vid, uint32_t *buffer, uint8_t chr, } -static void +static void lcdm_poll(amsvid_t *vid) { mda_t *mda = &vid->mda; @@ -1327,7 +1327,7 @@ lcdm_poll(amsvid_t *vid) mda->stat |= 1; mda->linepos = 1; oldsc = mda->sc; - if ((mda->crtc[8] & 3) == 3) + if ((mda->crtc[8] & 3) == 3) mda->sc = (mda->sc << 1) & 7; if (mda->dispon) { if (mda->displine < mda->firstline) @@ -1347,7 +1347,7 @@ lcdm_poll(amsvid_t *vid) if (mda->vc == mda->crtc[7] && !mda->sc) mda->stat |= 8; mda->displine++; - if (mda->displine >= 500) + if (mda->displine >= 500) mda->displine=0; } else { timer_advance_u64(&vid->timer, mda->dispontime); @@ -1359,8 +1359,8 @@ lcdm_poll(amsvid_t *vid) mda->stat&=~8; } if (mda->sc == (mda->crtc[11] & 31) || ((mda->crtc[8] & 3) == 3 && mda->sc == ((mda->crtc[11] & 31) >> 1))) { - mda->con = 0; - mda->coff = 1; + mda->con = 0; + mda->coff = 1; } if (mda->vadj) { mda->sc++; @@ -1378,7 +1378,7 @@ lcdm_poll(amsvid_t *vid) oldvc = mda->vc; mda->vc++; mda->vc &= 127; - if (mda->vc == mda->crtc[6]) + if (mda->vc == mda->crtc[6]) mda->dispon=0; if (oldvc == mda->crtc[4]) { mda->vc = 0; @@ -1426,7 +1426,7 @@ lcdm_poll(amsvid_t *vid) } -static void +static void lcdc_poll(amsvid_t *vid) { cga_t *cga = &vid->cga; @@ -1446,7 +1446,7 @@ lcdc_poll(amsvid_t *vid) cga->cgastat |= 1; cga->linepos = 1; oldsc = cga->sc; - if ((cga->crtc[8] & 3) == 3) + if ((cga->crtc[8] & 3) == 3) cga->sc = ((cga->sc << 1) + cga->oddeven) & 7; if (cga->cgadispon) { if (cga->displine < cga->firstline) { @@ -1503,7 +1503,7 @@ lcdc_poll(amsvid_t *vid) if (cga->vc == cga->crtc[7] && !cga->sc) cga->cgastat |= 8; cga->displine++; - if (cga->displine >= 360) + if (cga->displine >= 360) cga->displine = 0; } else { timer_advance_u64(&vid->timer, cga->dispontime); @@ -1514,8 +1514,8 @@ lcdc_poll(amsvid_t *vid) cga->cgastat &= ~8; } if (cga->sc == (cga->crtc[11] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[11] & 31) >> 1))) { - cga->con = 0; - cga->coff = 1; + cga->con = 0; + cga->coff = 1; } if ((cga->crtc[8] & 3) == 3 && cga->sc == (cga->crtc[9] >> 1)) cga->maback = cga->ma; @@ -1536,7 +1536,7 @@ lcdc_poll(amsvid_t *vid) cga->vc++; cga->vc &= 127; - if (cga->vc == cga->crtc[6]) + if (cga->vc == cga->crtc[6]) cga->cgadispon = 0; if (oldvc == cga->crtc[4]) { @@ -1607,7 +1607,7 @@ lcdc_poll(amsvid_t *vid) } if (cga->cgadispon) cga->cgastat &= ~1; - if ((cga->sc == (cga->crtc[10] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[10] & 31) >> 1)))) + if ((cga->sc == (cga->crtc[10] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[10] & 31) >> 1)))) cga->con = 1; if (cga->cgadispon && (cga->cgamode & 1)) { for (x = 0; x < (cga->crtc[1] << 1); x++) @@ -1617,7 +1617,7 @@ lcdc_poll(amsvid_t *vid) } -static void +static void vid_poll_200(void *p) { amsvid_t *vid = (amsvid_t *)p; @@ -1626,7 +1626,7 @@ vid_poll_200(void *p) case PC200_LCDM: lcdm_poll(vid); return; - case PC200_LCDC: + case PC200_LCDC: lcdc_poll(vid); return; } @@ -1647,7 +1647,7 @@ vid_init_200(amstrad_t *ams) vid->emulation = device_get_config_int("video_emulation"); /* Default to CGA */ - vid->dipswitches = 0x10; + vid->dipswitches = 0x10; vid->type = ams->type; if (ams->type == AMS_PC200) switch (vid->emulation) { @@ -1685,12 +1685,12 @@ vid_init_200(amstrad_t *ams) mda_setcol(0x88, 0, 1, 15); /* Attribute 64 is black on black (on a real MDA it's white on black) */ mda_setcol(0x40, 0, 1, 0); - mda_setcol(0xC0, 0, 1, 0); + mda_setcol(0xC0, 0, 1, 0); cga->fontbase = (device_get_config_int("codepage") & 3) * 256; timer_add(&vid->timer, vid_poll_200, vid, 1); - mem_mapping_add(&vid->mda.mapping, 0xb0000, 0x08000, + mem_mapping_add(&vid->mda.mapping, 0xb0000, 0x08000, mda_read, NULL, NULL, mda_write, NULL, NULL, NULL, 0, mda); mem_mapping_add(&vid->cga.mapping, 0xb8000, 0x08000, cga_read, NULL, NULL, cga_write, NULL, NULL, NULL, 0, cga); @@ -2178,7 +2178,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv) speaker_update(); speaker_gated = val & 0x01; speaker_enable = val & 0x02; - if (speaker_enable) + if (speaker_enable) was_speaker_enable = 1; pit_ctr_set_gate(&pit->counters[2], val & 0x01); @@ -2249,9 +2249,9 @@ kbd_read(uint16_t port, void *priv) else { ams->key_waiting = key_queue[key_queue_start]; key_queue_start = (key_queue_start + 1) & 0xf; - ams->wantirq = 1; + ams->wantirq = 1; } - } + } break; case 0x61: @@ -2472,7 +2472,7 @@ machine_amstrad_init(const machine_t *model, int type) device_context_restore(); device_add_ex(&vid_1512_device, ams->vid); break; - + case AMS_PPC512: loadfont("roms/machines/ppc512/40109", 1); device_context(&vid_ppc512_device); @@ -2481,7 +2481,7 @@ machine_amstrad_init(const machine_t *model, int type) device_context_restore(); device_add_ex(&vid_ppc512_device, ams->vid); break; - + case AMS_PC1640: loadfont("roms/video/mda/mda.rom", 0); device_context(&vid_1640_device); diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index 05c700fb8..c853b153b 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -841,7 +841,7 @@ machine_at_prox1332_init(const machine_t *model) /* - * Current bugs: + * Current bugs: * - ctrl-alt-del produces an 8042 error */ int @@ -861,13 +861,13 @@ machine_at_pc8_init(const machine_t *model) if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); - + return ret; } /* - * Current bugs: + * Current bugs: * - ctrl-alt-del produces an 8042 error */ int @@ -896,13 +896,13 @@ machine_at_3302_init(const machine_t *model) device_add(¶dise_pvga1a_ncr3302_device); device_add(&keyboard_at_ncr_device); - + return ret; } /* - * Current bugs: + * Current bugs: * - soft-reboot after saving CMOS settings/pressing ctrl-alt-del produces an 8042 error */ int @@ -918,13 +918,13 @@ machine_at_pc916sx_init(const machine_t *model) return ret; machine_at_common_init(model); - + device_add(&keyboard_at_ncr_device); mem_remap_top(384); if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); - + return ret; } @@ -947,9 +947,9 @@ machine_at_m290_init(const machine_t *model) if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); - + device_add(&olivetti_eva_device); - + return ret; } #endif diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 9bb4ff21e..6fe53e5e2 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -685,11 +685,11 @@ machine_at_pc330_6573_init(const machine_t *model) /* doesn't like every CPU oth return ret; machine_at_common_init(model); - pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 2, 3, 4); pci_register_slot(0x12, PCI_CARD_NORMAL, 2, 3, 4, 1); pci_register_slot(0x13, PCI_CARD_NORMAL, 3, 4, 1, 2); - + device_add(&opti802g_device); device_add(&opti822_device); device_add(&keyboard_ps2_device); @@ -1347,7 +1347,7 @@ machine_at_abpb4_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CAN_SWITCH_TYPE); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x03, PCI_CARD_NORMAL, 1, 2, 3, 4); @@ -1376,7 +1376,7 @@ machine_at_win486pci_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x03, PCI_CARD_NORMAL, 1, 2, 3, 4); @@ -1403,7 +1403,7 @@ machine_at_ms4145_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x03, PCI_CARD_NORMAL, 1, 2, 3, 4); @@ -1432,7 +1432,7 @@ machine_at_sbc490_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x0F, PCI_CARD_NORMAL, 2, 3, 4, 1); @@ -1473,7 +1473,7 @@ machine_at_tf486_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4); @@ -1643,7 +1643,7 @@ machine_at_ecs486_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x12, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); @@ -1675,7 +1675,7 @@ machine_at_hot433_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x12, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); @@ -1708,7 +1708,7 @@ machine_at_atc1415_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x12, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); @@ -1740,7 +1740,7 @@ machine_at_actionpc2600_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x12, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); @@ -1771,7 +1771,7 @@ machine_at_m919_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x12, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); @@ -1801,7 +1801,7 @@ machine_at_spc7700plw_init(const machine_t *model) return ret; machine_at_common_init(model); - + pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x10, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x12, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); diff --git a/src/machine/m_at_compaq.c b/src/machine/m_at_compaq.c index 3c1db5ea6..72c29ec07 100644 --- a/src/machine/m_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -70,24 +70,24 @@ static uint32_t normcols[256][2]; * * Bit 3: Disable built-in video (for add-on card) * Bit 2: Thin font - * Bits 0,1: Font set (not currently implemented) - */ + * Bits 0,1: Font set (not currently implemented) + */ static int8_t cpq_st_display_internal = -1; -static void +static void compaq_plasma_display_set(uint8_t internal) { cpq_st_display_internal = internal; } -static uint8_t +static uint8_t compaq_plasma_display_get(void) { return cpq_st_display_internal; } -typedef struct compaq_plasma_t +typedef struct compaq_plasma_t { mem_mapping_t plasma_mapping; cga_t cga; @@ -100,7 +100,7 @@ typedef struct compaq_plasma_t int dispon; } compaq_plasma_t; -static uint8_t cga_crtcmask[32] = +static uint8_t cga_crtcmask[32] = { 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -112,7 +112,7 @@ static mem_mapping_t ram_mapping; static void compaq_plasma_recalcattrs(compaq_plasma_t *self); -static void +static void compaq_plasma_recalctimings(compaq_plasma_t *self) { double _dispontime, _dispofftime, disptime; @@ -150,7 +150,7 @@ compaq_plasma_read(uint32_t addr, void *priv) } /* Draw a row of text in 80-column mode */ -static void +static void compaq_plasma_text80(compaq_plasma_t *self) { uint32_t cols[2]; @@ -184,9 +184,9 @@ compaq_plasma_text80(compaq_plasma_t *self) (attr & 0x80) && !drawcursor); if (self->cga.cgamode & 0x20) { /* Blink */ - cols[1] = blinkcols[attr][1]; - cols[0] = blinkcols[attr][0]; - if (blink) + cols[1] = blinkcols[attr][1]; + cols[0] = blinkcols[attr][0]; + if (blink) cols[1] = cols[0]; } else { cols[1] = normcols[attr][1]; @@ -238,9 +238,9 @@ compaq_plasma_text40(compaq_plasma_t *self) (attr & 0x80) && !drawcursor); if (self->cga.cgamode & 0x20) { /* Blink */ - cols[1] = blinkcols[attr][1]; - cols[0] = blinkcols[attr][0]; - if (blink) + cols[1] = blinkcols[attr][1]; + cols[0] = blinkcols[attr][0]; + if (blink) cols[1] = cols[0]; } else { cols[1] = normcols[attr][1]; @@ -248,12 +248,12 @@ compaq_plasma_text40(compaq_plasma_t *self) } if (drawcursor) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[self->displine])[(x << 4) + c*2] = + ((uint32_t *)buffer32->line[self->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[self->displine])[(x << 4) + c*2 + 1] = cols[(fontdatm[chr][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (amber ^ black); } } else { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[self->displine])[(x << 4) + c*2] = + ((uint32_t *)buffer32->line[self->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[self->displine])[(x << 4) + c*2+1] = cols[(fontdatm[chr][sc] & (1 << (c ^ 7))) ? 1 : 0]; } } @@ -263,7 +263,7 @@ compaq_plasma_text40(compaq_plasma_t *self) /* Draw a line in CGA 640x200 or Compaq Plasma 640x400 mode */ -static void +static void compaq_plasma_cgaline6(compaq_plasma_t *self) { int x, c; @@ -300,7 +300,7 @@ compaq_plasma_cgaline6(compaq_plasma_t *self) /* Draw a line in CGA 320x200 mode. Here the CGA colours are converted to * dither patterns: colour 1 to 25% grey, colour 2 to 50% grey */ -static void +static void compaq_plasma_cgaline4(compaq_plasma_t *self) { int x, c; @@ -309,7 +309,7 @@ compaq_plasma_cgaline4(compaq_plasma_t *self) uint16_t addr; uint16_t ma = (self->cga.crtc[13] | (self->cga.crtc[12] << 8)) & 0x7fff; - + /* 320*200 */ addr = ((self->displine >> 1) & 1) * 0x2000 + (self->displine >> 2) * 80 + @@ -321,7 +321,7 @@ compaq_plasma_cgaline4(compaq_plasma_t *self) for (c = 0; c < 4; c++) { pattern = (dat & 0xC0) >> 6; - if (!(self->cga.cgamode & 8)) + if (!(self->cga.cgamode & 8)) pattern = 0; switch (pattern & 3) { @@ -366,13 +366,13 @@ compaq_plasma_out(uint16_t addr, uint8_t val, void *priv) self->cga.crtc[self->cga.crtcreg] = val & cga_crtcmask[self->cga.crtcreg]; /* Register 0x12 controls the attribute mappings for the - * plasma screen. */ + * plasma screen. */ if (self->cga.crtcreg == 0x12) { - self->attrmap = val; + self->attrmap = val; compaq_plasma_recalcattrs(self); break; } - + if (old != val) { if (self->cga.crtcreg < 0xe || self->cga.crtcreg > 0x10) { fullchange = changeframecount; @@ -380,7 +380,7 @@ compaq_plasma_out(uint16_t addr, uint8_t val, void *priv) } } break; - + case 0x3d8: self->cga.cgamode = val; break; @@ -395,7 +395,7 @@ compaq_plasma_out(uint16_t addr, uint8_t val, void *priv) else compaq_plasma_display_set(0); break; - + case 0x23c6: self->port_23c6 = val; if (val & 8) /* Disable internal CGA */ @@ -430,7 +430,7 @@ compaq_plasma_in(uint16_t addr, void *priv) case 0x3da: ret = self->cga.cgastat; break; - + case 0x13c6: if (compaq_plasma_display_get()) ret = 8; @@ -450,7 +450,7 @@ static void compaq_plasma_poll(void *p) { compaq_plasma_t *self = (compaq_plasma_t *)p; - + /* Switch between internal plasma and external CRT display. */ if (cpq_st_display_internal != -1 && cpq_st_display_internal != self->internal_monitor) { self->internal_monitor = cpq_st_display_internal; @@ -460,8 +460,8 @@ compaq_plasma_poll(void *p) if (!self->internal_monitor && !(self->port_23c6 & 1)) { cga_poll(&self->cga); return; - } - + } + if (!self->linepos) { timer_advance_u64(&self->cga.timer, self->dispofftime); self->cga.cgastat |= 1; @@ -474,7 +474,7 @@ compaq_plasma_poll(void *p) if (self->cga.cgamode & 0x02) { if (self->cga.cgamode & 0x10) compaq_plasma_cgaline6(self); - else + else compaq_plasma_cgaline4(self); } else if (self->cga.cgamode & 0x01) /* High-res text */ @@ -505,9 +505,9 @@ compaq_plasma_poll(void *p) if ((640 != xsize) || (400 != ysize) || video_force_resize_get()) { xsize = 640; ysize = 400; - if (xsize < 64) + if (xsize < 64) xsize = 656; - if (ysize < 32) + if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); @@ -524,26 +524,26 @@ compaq_plasma_poll(void *p) if (self->cga.cgamode & 0x02) { if (self->cga.cgamode & 0x10) video_bpp = 1; - else + else video_bpp = 2; - } else + } else video_bpp = 0; self->cga.cgablink++; } } } -static void +static void compaq_plasma_recalcattrs(compaq_plasma_t *self) { int n; /* val behaves as follows: - * Bit 0: Attributes 01-06, 08-0E are inverse video - * Bit 1: Attributes 01-06, 08-0E are bold + * Bit 0: Attributes 01-06, 08-0E are inverse video + * Bit 1: Attributes 01-06, 08-0E are bold * Bit 2: Attributes 11-16, 18-1F, 21-26, 28-2F ... F1-F6, F8-FF - * are inverse video + * are inverse video * Bit 3: Attributes 11-16, 18-1F, 21-26, 28-2F ... F1-F6, F8-FF * are bold */ @@ -554,15 +554,15 @@ compaq_plasma_recalcattrs(compaq_plasma_t *self) /* Initialise the attribute mapping. Start by defaulting everything * to black on amber, and with bold set by bit 3 */ for (n = 0; n < 256; n++) { - blinkcols[n][0] = normcols[n][0] = amber; + blinkcols[n][0] = normcols[n][0] = amber; blinkcols[n][1] = normcols[n][1] = black; } - /* Colours 0x11-0xFF are controlled by bits 2 and 3 of the - * passed value. Exclude x0 and x8, which are always black on + /* Colours 0x11-0xFF are controlled by bits 2 and 3 of the + * passed value. Exclude x0 and x8, which are always black on * amber. */ for (n = 0x11; n <= 0xFF; n++) { - if ((n & 7) == 0) + if ((n & 7) == 0) continue; if (self->attrmap & 4) { /* Inverse */ blinkcols[n][0] = normcols[n][0] = amber; @@ -572,10 +572,10 @@ compaq_plasma_recalcattrs(compaq_plasma_t *self) blinkcols[n][1] = normcols[n][1] = amber; } } - /* Set up the 01-0E range, controlled by bits 0 and 1 of the + /* Set up the 01-0E range, controlled by bits 0 and 1 of the * passed value. When blinking is enabled this also affects 81-8E. */ for (n = 0x01; n <= 0x0E; n++) { - if (n == 7) + if (n == 7) continue; if (self->attrmap & 1) { blinkcols[n][0] = normcols[n][0] = amber; @@ -589,7 +589,7 @@ compaq_plasma_recalcattrs(compaq_plasma_t *self) blinkcols[n+128][1] = amber; } } - /* Colours 07 and 0F are always amber on black. If blinking is + /* Colours 07 and 0F are always amber on black. If blinking is * enabled so are 87 and 8F. */ for (n = 0x07; n <= 0x0F; n += 8) { blinkcols[n][0] = normcols[n][0] = black; @@ -616,7 +616,7 @@ compaq_plasma_recalcattrs(compaq_plasma_t *self) } static void * -compaq_plasma_init(const device_t *info) +compaq_plasma_init(const device_t *info) { int display_type; compaq_plasma_t *self = malloc(sizeof(compaq_plasma_t)); @@ -648,7 +648,7 @@ compaq_plasma_init(const device_t *info) self->cga.rgb_type = device_get_config_int("rgb_type"); cga_palette = (self->cga.rgb_type << 1); cgapal_rebuild(); - + return self; } @@ -813,8 +813,8 @@ machine_at_compaq_init(const machine_t *model, int type) { if (type != COMPAQ_DESKPRO386) mem_remap_top(384); - - if (fdc_type == FDC_INTERNAL) + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); mem_mapping_add(&ram_mapping, 0xfa0000, 0x60000, diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index 0f34b0244..e0e341735 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -86,7 +86,7 @@ machine_at_kn97_init(const machine_t *model) device_add(&lm78_device); /* fans: Chassis, CPU, Power; temperature: MB */ for (uint8_t i = 0; i < 3; i++) hwm_values.fans[i] *= 2; /* BIOS reports fans with the wrong divisor for some reason */ - + return ret; } @@ -118,7 +118,7 @@ machine_at_lx6_init(const machine_t *model) device_add(&w83977tf_device); device_add(&sst_flash_29ee010_device); spd_register(SPD_TYPE_SDRAM, 0xF, 256); - + return ret; } @@ -293,7 +293,7 @@ machine_at_bf6_init(const machine_t *model) device_add(&keyboard_ps2_pci_device); device_add(&w83977ef_device); device_add(&sst_flash_39sf020_device); - spd_register(SPD_TYPE_SDRAM, 0x7, 256); + spd_register(SPD_TYPE_SDRAM, 0x7, 256); return ret; } @@ -362,7 +362,7 @@ machine_at_atc6310bxii_init(const machine_t *model) device_add(&sst_flash_39sf020_device); spd_register(SPD_TYPE_SDRAM, 0x7, 256); - return ret; + return ret; } @@ -637,7 +637,7 @@ machine_at_ms6168_common_init(const machine_t *model) pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x14, PCI_CARD_SOUND, 3, 4, 1, 2); pci_register_slot(0x0E, PCI_CARD_NORMAL, 1, 2, 3, 4); - pci_register_slot(0x10, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x10, PCI_CARD_NORMAL, 2, 3, 4, 1); pci_register_slot(0x12, PCI_CARD_NORMAL, 3, 4, 1, 2); pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4); pci_register_slot(0x01, PCI_CARD_AGPBRIDGE, 1, 2, 3, 4); diff --git a/src/machine/m_at_slot2.c b/src/machine/m_at_slot2.c index 4a1babf74..359b94f60 100644 --- a/src/machine/m_at_slot2.c +++ b/src/machine/m_at_slot2.c @@ -72,7 +72,7 @@ machine_at_6gxu_init(const machine_t *model) device_add(&w83782d_device); /* fans: CPU, Power, System; temperatures: System, CPU, unused */ hwm_values.temperatures[2] = 0; /* unused */ hwm_values.voltages[1] = 1500; /* VGTL */ - + return ret; } diff --git a/src/machine/m_at_socket370.c b/src/machine/m_at_socket370.c index c0a0224fb..ae8754f80 100644 --- a/src/machine/m_at_socket370.c +++ b/src/machine/m_at_socket370.c @@ -71,7 +71,7 @@ machine_at_s370slm_init(const machine_t *model) device_add(&w83781d_device); /* fans: CPU, Fan 2, Chassis; temperatures: unused, CPU, unused */ hwm_values.temperatures[0] = 0; /* unused */ hwm_values.temperatures[2] = 0; /* unused */ - + return ret; } @@ -214,7 +214,7 @@ machine_at_atc7020bxii_init(const machine_t *model) device_add(&sst_flash_39sf020_device); spd_register(SPD_TYPE_SDRAM, 0xF, 256); - return ret; + return ret; } diff --git a/src/machine/m_at_socket4.c b/src/machine/m_at_socket4.c index 0e526b448..d5873ad45 100644 --- a/src/machine/m_at_socket4.c +++ b/src/machine/m_at_socket4.c @@ -181,7 +181,7 @@ machine_at_dellxp60_init(const machine_t *model) ret = bios_load_linear_inverted("roms/machines/dellxp60/XP60-A08.ROM", 0x000e0000, 131072, 0); - + if (bios_only || !ret) return ret; diff --git a/src/machine/m_at_socket5.c b/src/machine/m_at_socket5.c index 4a1bb9802..4fc7441bb 100644 --- a/src/machine/m_at_socket5.c +++ b/src/machine/m_at_socket5.c @@ -327,7 +327,7 @@ machine_at_pat54pv_init(const machine_t *model) device_add(&opti5x7_device); device_add(&keyboard_ps2_intel_ami_pci_device); - + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); @@ -410,4 +410,4 @@ machine_at_sq588_init(const machine_t *model) device_add(&sst_flash_29ee010_device); return ret; -} \ No newline at end of file +} diff --git a/src/machine/m_at_socket7.c b/src/machine/m_at_socket7.c index 940cb82ba..39d872bd6 100644 --- a/src/machine/m_at_socket7.c +++ b/src/machine/m_at_socket7.c @@ -631,7 +631,7 @@ machine_at_nupro592_init(const machine_t *model) pci_register_slot(0x13, PCI_CARD_NORMAL, 3, 4, 1, 2); pci_register_slot(0x14, PCI_CARD_NORMAL, 2, 3, 4, 1); pci_register_slot(0x0B, PCI_CARD_NORMAL, 3, 4, 1, 2); /*Strongly suspect these are on-board slots*/ - pci_register_slot(0x0C, PCI_CARD_NORMAL, 4, 1, 2, 3); + pci_register_slot(0x0C, PCI_CARD_NORMAL, 4, 1, 2, 3); pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 4); /* PIIX4 */ device_add(&i430tx_device); device_add(&piix4_device); @@ -644,7 +644,7 @@ machine_at_nupro592_init(const machine_t *model) hwm_values.fans[1] = 0; /* unused */ hwm_values.fans[2] = 0; /* unused */ /* -5V is not reported by the BIOS, but leave it set */ - + return ret; } diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index 19b60bdbb..14d4f78c1 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -245,7 +245,7 @@ machine_at_ms5119_init(const machine_t *model) pci_register_slot(0x0d, PCI_CARD_NORMAL, 1, 2, 3, 4); pci_register_slot(0x0e, PCI_CARD_NORMAL, 2, 3, 4, 1); pci_register_slot(0x0f, PCI_CARD_NORMAL, 3, 4, 1, 2); - + device_add(&i430fx_device); device_add(&piix_device); device_add(&keyboard_ps2_ami_pci_device); @@ -317,7 +317,7 @@ machine_at_fmb_init(const machine_t *model) pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 3, 4, 1); pci_register_slot(0x12, PCI_CARD_NORMAL, 3, 4, 2, 1); pci_register_slot(0x11, PCI_CARD_NORMAL, 4, 3, 2, 1); - + device_add(&i430fx_device); device_add(&piix_device); device_add(&keyboard_ps2_ami_pci_device); @@ -536,7 +536,7 @@ machine_at_ap5s_init(const machine_t *model) pci_register_slot(0x0F, PCI_CARD_NORMAL, 2, 3, 4, 1); pci_register_slot(0x11, PCI_CARD_NORMAL, 3, 4, 2, 1); pci_register_slot(0x13, PCI_CARD_NORMAL, 4, 3, 2, 1); - + device_add(&sis_5511_device); device_add(&keyboard_ps2_ami_pci_device); device_add(&fdc37c665_device); diff --git a/src/machine/m_at_t3100e.c b/src/machine/m_at_t3100e.c index 6e84a5832..afeea0a57 100644 --- a/src/machine/m_at_t3100e.c +++ b/src/machine/m_at_t3100e.c @@ -15,7 +15,7 @@ * * Memory management * ~~~~~~~~~~~~~~~~~ - * + * * Motherboard memory is divided into: * - Conventional memory: Either 512k or 640k * - Upper memory: Either 512k or 384k, depending on @@ -25,7 +25,7 @@ * The BIOS setup screen allows some or * all of this to be used as EMS; the * remainder is XMS. - * + * * Additional memory (either EMS or XMS) can also be provided * by ISA expansion cards. * @@ -40,7 +40,7 @@ * Bit 6: Always 1 } These bits select which motherboard * Bit 5: Always 0 } function to access. * Bit 4: Set to treat upper RAM as XMS - * Bit 3: Enable external RAM boards? + * Bit 3: Enable external RAM boards? * Bit 2: Set for 640k conventional memory, clear for 512k * Bit 1: Enable RAM beyond 1Mb. * Bit 0: Enable EMS. @@ -69,7 +69,7 @@ * OUT 0x4208, 0x80 will page in the first 16k page at 0xD4000. * OUT 0x218, 0x80 will page in the 129th 16k page at 0xD0000. * etc. - * + * * To use EMS from DOS, you will need the Toshiba EMS driver * (TOSHEMM.ZIP). This supports the above system, plus further * ranges of ports at 0x_2A8, 0x_2B8, 0x_2C8. @@ -104,7 +104,7 @@ * 01 0 => 3, 4, 5 * 01 1 => 3, 5, 4 * 10 0 => 4, -, 3 - * 10 1 => 3, -, 4 + * 10 1 => 3, -, 4 * 010 => set memory mappings * bit 4 set if upper RAM is XMS * bit 3 enable add-on memory boards beyond 5Mb? @@ -237,7 +237,7 @@ t3100e_log(const char *fmt, ...) #endif -/* Given a memory address (which ought to be in the page frame at 0xD0000), +/* Given a memory address (which ought to be in the page frame at 0xD0000), * which page does it relate to? */ static int addr_to_page(uint32_t addr) { @@ -248,7 +248,7 @@ static int addr_to_page(uint32_t addr) return -1; } -/* And vice versa: Given a page slot, which memory address does it +/* And vice versa: Given a page slot, which memory address does it * correspond to? */ static uint32_t page_to_addr(int pg) { @@ -256,7 +256,7 @@ static uint32_t page_to_addr(int pg) } /* Given an EMS page ID, return its physical address in RAM. */ -uint32_t t3100e_ems_execaddr(struct t3100e_ems_regs *regs, +uint32_t t3100e_ems_execaddr(struct t3100e_ems_regs *regs, int pg, uint16_t val) { uint32_t addr; @@ -296,14 +296,14 @@ static int port_to_page(uint16_t addr) { switch (addr) { - case 0x208: return 0; - case 0x4208: return 1; - case 0x8208: return 2; - case 0xC208: return 3; - case 0x218: return 4; - case 0x4218: return 5; - case 0x8218: return 6; - case 0xC218: return 7; + case 0x208: return 0; + case 0x4208: return 1; + case 0x8208: return 2; + case 0xC208: return 3; + case 0x218: return 4; + case 0x4218: return 5; + case 0x8218: return 6; + case 0xC218: return 7; case 0x258: return 8; case 0x4258: return 9; case 0x8258: return 10; @@ -331,12 +331,12 @@ void dump_mappings() if (mm == &ram_mid_mapping ) name = "MID "; if (mm == &ram_high_mapping) name = "HIGH"; if (mm == &t3100e_ems.upper_mapping) name = "UPPR"; - if (mm == &t3100e_ems.mapping[0]) + if (mm == &t3100e_ems.mapping[0]) { name = "EMS0"; offset = t3100e_ems.page_exec[0]; } - if (mm == &t3100e_ems.mapping[1]) + if (mm == &t3100e_ems.mapping[1]) { name = "EMS1"; offset = t3100e_ems.page_exec[1]; @@ -346,14 +346,14 @@ void dump_mappings() name = "EMS2"; offset = t3100e_ems.page_exec[2]; } - if (mm == &t3100e_ems.mapping[3]) + if (mm == &t3100e_ems.mapping[3]) { name = "EMS3"; offset = t3100e_ems.page_exec[3]; } - t3100e_log(" %p | base=%05x size=%05x %c @ %06x %s\n", mm, - mm->base, mm->size, mm->enable ? 'Y' : 'N', + t3100e_log(" %p | base=%05x size=%05x %c @ %06x %s\n", mm, + mm->base, mm->size, mm->enable ? 'Y' : 'N', offset, name); mm = mm->next; @@ -366,7 +366,7 @@ void t3100e_map_ram(uint8_t val) int32_t upper_len; #ifdef ENABLE_T3100E_LOG - t3100e_log("OUT 0x8084, %02x [ set memory mapping :", val | 0x40); + t3100e_log("OUT 0x8084, %02x [ set memory mapping :", val | 0x40); if (val & 1) t3100e_log("ENABLE_EMS "); if (val & 2) t3100e_log("ENABLE_XMS "); if (val & 4) t3100e_log("640K "); @@ -376,12 +376,12 @@ void t3100e_map_ram(uint8_t val) #endif /* Bit 2 controls size of conventional memory */ - if (val & 4) + if (val & 4) { t3100e_ems.upper_base = 0xA0000; t3100e_ems.upper_pages = 24; } - else + else { t3100e_ems.upper_base = 0x80000; t3100e_ems.upper_pages = 32; @@ -402,7 +402,7 @@ void t3100e_map_ram(uint8_t val) mem_mapping_disable(&ram_high_mapping); } - /* Bit 4 set if upper RAM is mapped to high memory + /* Bit 4 set if upper RAM is mapped to high memory * (and bit 1 set if XMS enabled) */ if ((val & 0x12) == 0x12) { @@ -419,7 +419,7 @@ void t3100e_map_ram(uint8_t val) /* Recalculate EMS mappings */ for (n = 0; n < 4; n++) { - t3100e_ems_out(t3100e_ems_page_reg[n], t3100e_ems.page[n], + t3100e_ems_out(t3100e_ems_page_reg[n], t3100e_ems.page[n], &t3100e_ems); } @@ -461,7 +461,7 @@ uint8_t t3100e_sys_in(uint16_t addr, void *p) { struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)p; - /* The low 4 bits always seem to be 0x0C. The high 4 are a + /* The low 4 bits always seem to be 0x0C. The high 4 are a * notification sent by the keyboard controller when it detects * an [Fn] key combination */ t3100e_log("IN 0x8084\n"); @@ -478,10 +478,10 @@ void t3100e_sys_out(uint16_t addr, uint8_t val, void *p) switch (val & 0xE0) { case 0x00: /* Set serial port IRQs. Not implemented */ - t3100e_log("OUT 0x8084, %02x [ set serial port IRQs]\n", val); + t3100e_log("OUT 0x8084, %02x [ set serial port IRQs]\n", val); break; case 0x40: /* Set RAM mappings. */ - t3100e_map_ram(val & 0x1F); + t3100e_map_ram(val & 0x1F); break; case 0x80: /* Set video options. */ @@ -521,7 +521,7 @@ uint8_t t3100e_config_get(void) prt_switch = (type_b ? 2 : 0); switch(type_a) { -/* Since a T3100e cannot have an internal 5.25" drive, mark 5.25" A: drive as +/* Since a T3100e cannot have an internal 5.25" drive, mark 5.25" A: drive as * being external, and set the internal type based on type_b. */ case 1: /* 360k */ case 2: /* 1.2Mb */ @@ -536,7 +536,7 @@ uint8_t t3100e_config_get(void) } break; case 4: value |= 0x01; /* 720k */ - if (type_a == type_b) + if (type_a == type_b) { value &= (~8); /* Two internal drives */ prt_switch = 0; /* No external drive */ @@ -544,7 +544,7 @@ uint8_t t3100e_config_get(void) break; case 5: /* 1.4M */ case 7: /* 2.8M */ - if (type_a == type_b) + if (type_a == type_b) { value &= (~8); /* Two internal drives */ prt_switch = 0; /* No external drive */ @@ -552,7 +552,7 @@ uint8_t t3100e_config_get(void) break; case 6: /* 3-mode */ value |= 0x10; - if (type_a == type_b) + if (type_a == type_b) { value &= (~8); /* Two internal drives */ prt_switch = 0; /* No external drive */ @@ -573,7 +573,7 @@ uint8_t t3100e_config_get(void) uint8_t t3100e_ems_in(uint16_t addr, void *p) { struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)p; - + int page = port_to_page(addr); if (page >= 0) return regs->page[page]; @@ -623,7 +623,7 @@ static uint8_t ems_read_ram(uint32_t addr, void *priv) if (pg < 0) return 0xFF; addr = regs->page_exec[pg] + (addr & 0x3FFF); - return ram[addr]; + return ram[addr]; } @@ -637,8 +637,8 @@ static uint16_t ems_read_ramw(uint32_t addr, void *priv) if (pg < 0) return 0xFFFF; //t3100e_log("ems_read_ramw addr=%05x ", addr); addr = regs->page_exec[pg] + (addr & 0x3FFF); - //t3100e_log("-> %06x val=%04x\n", addr, *(uint16_t *)&ram[addr]); - return *(uint16_t *)&ram[addr]; + //t3100e_log("-> %06x val=%04x\n", addr, *(uint16_t *)&ram[addr]); + return *(uint16_t *)&ram[addr]; } @@ -649,7 +649,7 @@ static uint32_t ems_read_raml(uint32_t addr, void *priv) if (pg < 0) return 0xFFFFFFFF; addr = regs->page_exec[pg] + (addr & 0x3FFF); - return *(uint32_t *)&ram[addr]; + return *(uint32_t *)&ram[addr]; } /* Write RAM in the EMS page frame */ @@ -660,7 +660,7 @@ static void ems_write_ram(uint32_t addr, uint8_t val, void *priv) if (pg < 0) return; addr = regs->page_exec[pg] + (addr & 0x3FFF); - ram[addr] = val; + ram[addr] = val; } @@ -674,7 +674,7 @@ static void ems_write_ramw(uint32_t addr, uint16_t val, void *priv) addr = regs->page_exec[pg] + (addr & 0x3FFF); //t3100e_log("-> %06x val=%04x\n", addr, val); - *(uint16_t *)&ram[addr] = val; + *(uint16_t *)&ram[addr] = val; } @@ -685,19 +685,19 @@ static void ems_write_raml(uint32_t addr, uint32_t val, void *priv) if (pg < 0) return; addr = regs->page_exec[pg] + (addr & 0x3FFF); - *(uint32_t *)&ram[addr] = val; + *(uint32_t *)&ram[addr] = val; } -/* Read RAM in the upper area. This is basically what the 'remapped' +/* Read RAM in the upper area. This is basically what the 'remapped' * mapping in mem.c does, except that the upper area can move around */ static uint8_t upper_read_ram(uint32_t addr, void *priv) { struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)priv; addr = (addr - (1024 * mem_size)) + regs->upper_base; - return ram[addr]; + return ram[addr]; } static uint16_t upper_read_ramw(uint32_t addr, void *priv) @@ -705,7 +705,7 @@ static uint16_t upper_read_ramw(uint32_t addr, void *priv) struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)priv; addr = (addr - (1024 * mem_size)) + regs->upper_base; - return *(uint16_t *)&ram[addr]; + return *(uint16_t *)&ram[addr]; } static uint32_t upper_read_raml(uint32_t addr, void *priv) @@ -713,7 +713,7 @@ static uint32_t upper_read_raml(uint32_t addr, void *priv) struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)priv; addr = (addr - (1024 * mem_size)) + regs->upper_base; - return *(uint32_t *)&ram[addr]; + return *(uint32_t *)&ram[addr]; } @@ -722,7 +722,7 @@ static void upper_write_ram(uint32_t addr, uint8_t val, void *priv) struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)priv; addr = (addr - (1024 * mem_size)) + regs->upper_base; - ram[addr] = val; + ram[addr] = val; } @@ -731,7 +731,7 @@ static void upper_write_ramw(uint32_t addr, uint16_t val, void *priv) struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)priv; addr = (addr - (1024 * mem_size)) + regs->upper_base; - *(uint16_t *)&ram[addr] = val; + *(uint16_t *)&ram[addr] = val; } @@ -741,7 +741,7 @@ static void upper_write_raml(uint32_t addr, uint32_t val, void *priv) struct t3100e_ems_regs *regs = (struct t3100e_ems_regs *)priv; addr = (addr - (1024 * mem_size)) + regs->upper_base; - *(uint32_t *)&ram[addr] = val; + *(uint32_t *)&ram[addr] = val; } @@ -760,7 +760,7 @@ int machine_at_t3100e_init(const machine_t *model) int pg; memset(&t3100e_ems, 0, sizeof(t3100e_ems)); - + machine_at_common_ide_init(model); device_add(&keyboard_at_toshiba_device); @@ -769,29 +769,29 @@ int machine_at_t3100e_init(const machine_t *model) { device_add(&fdc_at_device); } - + /* Hook up system control port */ - io_sethandler(0x8084, 0x0001, + io_sethandler(0x8084, 0x0001, t3100e_sys_in, NULL, NULL, t3100e_sys_out, NULL, NULL, &t3100e_ems); /* Start monitoring all 16 EMS registers */ - for (pg = 0; pg < 16; pg++) + for (pg = 0; pg < 16; pg++) { - io_sethandler(t3100e_ems_page_reg[pg], 0x0001, + io_sethandler(t3100e_ems_page_reg[pg], 0x0001, t3100e_ems_in, NULL, NULL, - t3100e_ems_out, NULL, NULL, &t3100e_ems); + t3100e_ems_out, NULL, NULL, &t3100e_ems); } /* Map the EMS page frame */ for (pg = 0; pg < 4; pg++) { t3100e_log("Adding memory map at %x for page %d\n", page_to_addr(pg), pg); - mem_mapping_add(&t3100e_ems.mapping[pg], - page_to_addr(pg), 16384, + mem_mapping_add(&t3100e_ems.mapping[pg], + page_to_addr(pg), 16384, ems_read_ram, ems_read_ramw, ems_read_raml, ems_write_ram, ems_write_ramw, ems_write_raml, - NULL, MEM_MAPPING_EXTERNAL, + NULL, MEM_MAPPING_EXTERNAL, &t3100e_ems); /* Start them all off disabled */ mem_mapping_disable(&t3100e_ems.mapping[pg]); diff --git a/src/machine/m_at_t3100e_vid.c b/src/machine/m_at_t3100e_vid.c index 0367b28f2..045ad7d61 100644 --- a/src/machine/m_at_t3100e_vid.c +++ b/src/machine/m_at_t3100e_vid.c @@ -14,7 +14,7 @@ * Selecting a character height of 3 seems to be sufficient to * convert the 640x200 graphics mode to 640x400 (and, by * analogy, 320x200 to 320x400). - * + * * Horiz-----> Vert------> I ch * 38 28 2D 0A 1F 06 19 1C 02 07 06 07 CO40 * 71 50 5A 0A 1F 06 19 1C 02 07 06 07 CO80 @@ -86,7 +86,7 @@ static uint32_t normcols[256][2]; * * Bit 3: Disable built-in video (for add-on card) * Bit 2: Thin font - * Bits 0,1: Font set (not currently implemented) + * Bits 0,1: Font set (not currently implemented) */ static uint8_t st_video_options; static int8_t st_display_internal = -1; @@ -111,7 +111,7 @@ typedef struct t3100e_t { mem_mapping_t mapping; - cga_t cga; /* The CGA is used for the external + cga_t cga; /* The CGA is used for the external * display; most of its registers are * ignored by the plasma display. */ @@ -121,7 +121,7 @@ typedef struct t3100e_t uint8_t attrmap; /* Attribute mapping register */ uint64_t dispontime, dispofftime; - + int linepos, displine; int vc; int dispon; @@ -154,12 +154,12 @@ void t3100e_out(uint16_t addr, uint8_t val, void *p) case 0x3d1: case 0x3d3: case 0x3d5: case 0x3d7: /* Register 0x12 controls the attribute mappings for the * plasma screen. */ - if (t3100e->cga.crtcreg == 0x12) + if (t3100e->cga.crtcreg == 0x12) { - t3100e->attrmap = val; + t3100e->attrmap = val; t3100e_recalcattrs(t3100e); return; - } + } cga_out(addr, val, &t3100e->cga); t3100e_recalctimings(t3100e); @@ -191,7 +191,7 @@ uint8_t t3100e_in(uint16_t addr, void *p) return val; } } - + return cga_in(addr, &t3100e->cga); } @@ -205,7 +205,7 @@ void t3100e_write(uint32_t addr, uint8_t val, void *p) t3100e->vram[addr & 0x7fff] = val; cycles -= 4; } - + uint8_t t3100e_read(uint32_t addr, void *p) @@ -282,8 +282,8 @@ void t3100e_text_row80(t3100e_t *t3100e) if (t3100e->cga.cgamode & 0x20) /* Blink */ { - cols[1] = blinkcols[attr][1]; - cols[0] = blinkcols[attr][0]; + cols[1] = blinkcols[attr][1]; + cols[0] = blinkcols[attr][0]; if (blink) cols[1] = cols[0]; } else @@ -352,8 +352,8 @@ void t3100e_text_row40(t3100e_t *t3100e) if (t3100e->cga.cgamode & 0x20) /* Blink */ { - cols[1] = blinkcols[attr][1]; - cols[0] = blinkcols[attr][0]; + cols[1] = blinkcols[attr][1]; + cols[0] = blinkcols[attr][0]; if (blink) cols[1] = cols[0]; } else @@ -365,7 +365,7 @@ void t3100e_text_row40(t3100e_t *t3100e) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[t3100e->displine])[(x << 4) + c*2] = + ((uint32_t *)buffer32->line[t3100e->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[t3100e->displine])[(x << 4) + c*2 + 1] = cols[(fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (amber ^ black); } } @@ -373,7 +373,7 @@ void t3100e_text_row40(t3100e_t *t3100e) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[t3100e->displine])[(x << 4) + c*2] = + ((uint32_t *)buffer32->line[t3100e->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[t3100e->displine])[(x << 4) + c*2+1] = cols[(fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; } } @@ -461,7 +461,7 @@ void t3100e_cgaline4(t3100e_t *t3100e) switch (pattern & 3) { case 0: ink0 = ink1 = black; break; - case 1: if (t3100e->displine & 1) + case 1: if (t3100e->displine & 1) { ink0 = black; ink1 = black; } @@ -470,7 +470,7 @@ void t3100e_cgaline4(t3100e_t *t3100e) ink0 = amber; ink1 = black; } break; - case 2: if (t3100e->displine & 1) + case 2: if (t3100e->displine & 1) { ink0 = black; ink1 = amber; } @@ -537,20 +537,20 @@ void t3100e_poll(void *p) } /* Graphics */ - if (t3100e->cga.cgamode & 0x02) + if (t3100e->cga.cgamode & 0x02) { if (t3100e->cga.cgamode & 0x10) t3100e_cgaline6(t3100e); else t3100e_cgaline4(t3100e); } - else + else if (t3100e->cga.cgamode & 0x01) /* High-res text */ { - t3100e_text_row80(t3100e); + t3100e_text_row80(t3100e); } else { - t3100e_text_row40(t3100e); + t3100e_text_row40(t3100e); } } t3100e->displine++; @@ -597,7 +597,7 @@ void t3100e_poll(void *p) video_res_x = T3100E_XSIZE; video_res_y = T3100E_YSIZE; - if (t3100e->cga.cgamode & 0x02) + if (t3100e->cga.cgamode & 0x02) { if (t3100e->cga.cgamode & 0x10) video_bpp = 1; @@ -617,10 +617,10 @@ void t3100e_recalcattrs(t3100e_t *t3100e) int n; /* val behaves as follows: - * Bit 0: Attributes 01-06, 08-0E are inverse video - * Bit 1: Attributes 01-06, 08-0E are bold + * Bit 0: Attributes 01-06, 08-0E are inverse video + * Bit 1: Attributes 01-06, 08-0E are bold * Bit 2: Attributes 11-16, 18-1F, 21-26, 28-2F ... F1-F6, F8-FF - * are inverse video + * are inverse video * Bit 3: Attributes 11-16, 18-1F, 21-26, 28-2F ... F1-F6, F8-FF * are bold */ @@ -633,12 +633,12 @@ void t3100e_recalcattrs(t3100e_t *t3100e) for (n = 0; n < 256; n++) { boldcols[n] = (n & 8) != 0; - blinkcols[n][0] = normcols[n][0] = amber; + blinkcols[n][0] = normcols[n][0] = amber; blinkcols[n][1] = normcols[n][1] = black; } - /* Colours 0x11-0xFF are controlled by bits 2 and 3 of the - * passed value. Exclude x0 and x8, which are always black on + /* Colours 0x11-0xFF are controlled by bits 2 and 3 of the + * passed value. Exclude x0 and x8, which are always black on * amber. */ for (n = 0x11; n <= 0xFF; n++) { @@ -655,7 +655,7 @@ void t3100e_recalcattrs(t3100e_t *t3100e) } if (t3100e->attrmap & 8) boldcols[n] = 1; /* Bold */ } - /* Set up the 01-0E range, controlled by bits 0 and 1 of the + /* Set up the 01-0E range, controlled by bits 0 and 1 of the * passed value. When blinking is enabled this also affects 81-8E. */ for (n = 0x01; n <= 0x0E; n++) { @@ -676,7 +676,7 @@ void t3100e_recalcattrs(t3100e_t *t3100e) } if (t3100e->attrmap & 2) boldcols[n] = 1; } - /* Colours 07 and 0F are always amber on black. If blinking is + /* Colours 07 and 0F are always amber on black. If blinking is * enabled so are 87 and 8F. */ for (n = 0x07; n <= 0x0F; n += 8) { @@ -753,7 +753,7 @@ void t3100e_close(void *p) void t3100e_speed_changed(void *p) { t3100e_t *t3100e = (t3100e_t *)p; - + t3100e_recalctimings(t3100e); } diff --git a/src/machine/m_europc.c b/src/machine/m_europc.c index 29405024b..4c2f5f0b3 100644 --- a/src/machine/m_europc.c +++ b/src/machine/m_europc.c @@ -23,7 +23,7 @@ * f000:db3e 0x8..0xc * f000:d7f8 * f000:db5f - * f000:e172 + * f000:e172 * f000:ecc5 801a video setup error * f000:d6c9 copyright output * f000:e1b7 @@ -58,7 +58,7 @@ * read low 4 nibble at jim 0xa * read low 4 nibble at jim 0xa * return first nibble<<4|second nibble in ah - * f000:f046 seldom compares ret + * f000:f046 seldom compares ret * f000:fe87 0 -> ds * * Memory: @@ -67,7 +67,7 @@ * 0000:046a: 00 jim 250 01 jim 350 * * WARNING THIS IS A WORK-IN-PROGRESS MODULE. USE AT OWN RISK. - * + * * * * Author: Fred N. van Kempen, diff --git a/src/machine/m_pcjr.c b/src/machine/m_pcjr.c index e6cafb1ac..b38b70d44 100644 --- a/src/machine/m_pcjr.c +++ b/src/machine/m_pcjr.c @@ -233,7 +233,7 @@ vid_read(uint32_t addr, void *p) pcjr_t *pcjr = (pcjr_t *)p; if (pcjr->memctrl == -1) return(0xff); - + return(pcjr->b8000[addr & 0x3fff]); } @@ -256,7 +256,7 @@ vid_poll(void *p) pcjr->stat &= ~1; pcjr->linepos = 1; oldsc = pcjr->sc; - if ((pcjr->crtc[8] & 3) == 3) + if ((pcjr->crtc[8] & 3) == 3) pcjr->sc = (pcjr->sc << 1) & 7; if (pcjr->dispon) { uint16_t offset = 0; @@ -294,7 +294,7 @@ vid_poll(void *p) switch ((pcjr->array[0] & 0x13) | ((pcjr->array[3] & 0x08) << 5)) { case 0x13: /*320x200x16*/ for (x = 0; x < pcjr->crtc[1]; x++) { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; pcjr->ma++; buffer32->line[(pcjr->displine << 1)][(x << 3) + 8] = buffer32->line[(pcjr->displine << 1)][(x << 3) + 9] = @@ -313,7 +313,7 @@ vid_poll(void *p) break; case 0x12: /*160x200x16*/ for (x = 0; x < pcjr->crtc[1]; x++) { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; pcjr->ma++; buffer32->line[(pcjr->displine << 1)][(x << 4) + 8] = buffer32->line[(pcjr->displine << 1)][(x << 4) + 9] = @@ -360,7 +360,7 @@ vid_poll(void *p) if (pcjr->array[3] & 4) { cols[1] = pcjr->array[ ((attr & 15) & pcjr->array[1]) + 16] + 16; cols[0] = pcjr->array[(((attr >> 4) & 7) & pcjr->array[1]) + 16] + 16; - if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) + if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) cols[1] = cols[0]; } else { cols[1] = pcjr->array[((attr & 15) & pcjr->array[1]) + 16] + 16; @@ -395,7 +395,7 @@ vid_poll(void *p) if (pcjr->array[3] & 4) { cols[1] = pcjr->array[ ((attr & 15) & pcjr->array[1]) + 16] + 16; cols[0] = pcjr->array[(((attr >> 4) & 7) & pcjr->array[1]) + 16] + 16; - if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) + if ((pcjr->blink & 16) && (attr & 0x80) && !drawcursor) cols[1] = cols[0]; } else { cols[1] = pcjr->array[((attr & 15) & pcjr->array[1]) + 16] + 16; @@ -404,9 +404,9 @@ vid_poll(void *p) pcjr->ma++; if (pcjr->sc & 8) { for (c = 0; c < 8; c++) { - buffer32->line[(pcjr->displine << 1)][(x << 4) + (c << 1) + 8] = + buffer32->line[(pcjr->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(pcjr->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = - buffer32->line[(pcjr->displine << 1) + 1][(x << 4) + (c << 1) + 8] = + buffer32->line[(pcjr->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(pcjr->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[0]; } } else { @@ -432,7 +432,7 @@ vid_poll(void *p) cols[2] = pcjr->array[2 + 16] + 16; cols[3] = pcjr->array[3 + 16] + 16; for (x = 0; x < pcjr->crtc[1]; x++) { - dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | + dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; pcjr->ma++; for (c = 0; c < 8; c++) { @@ -491,11 +491,11 @@ vid_poll(void *p) pcjr->stat |= 8; } pcjr->displine++; - if (pcjr->displine >= 360) + if (pcjr->displine >= 360) pcjr->displine = 0; } else { timer_advance_u64(&pcjr->timer, pcjr->dispontime); - if (pcjr->dispon) + if (pcjr->dispon) pcjr->stat |= 1; pcjr->linepos = 0; if (pcjr->vsynctime) { @@ -504,9 +504,9 @@ vid_poll(void *p) pcjr->stat &= ~8; } } - if (pcjr->sc == (pcjr->crtc[11] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[11] & 31) >> 1))) { - pcjr->con = 0; - pcjr->coff = 1; + if (pcjr->sc == (pcjr->crtc[11] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[11] & 31) >> 1))) { + pcjr->con = 0; + pcjr->coff = 1; } if (pcjr->vadj) { pcjr->sc++; @@ -524,14 +524,14 @@ vid_poll(void *p) oldvc = pcjr->vc; pcjr->vc++; pcjr->vc &= 127; - if (pcjr->vc == pcjr->crtc[6]) + if (pcjr->vc == pcjr->crtc[6]) pcjr->dispon = 0; if (oldvc == pcjr->crtc[4]) { pcjr->vc = 0; pcjr->vadj = pcjr->crtc[5]; - if (!pcjr->vadj) + if (!pcjr->vadj) pcjr->dispon = 1; - if (!pcjr->vadj) + if (!pcjr->vadj) pcjr->ma = pcjr->maback = (pcjr->crtc[13] | (pcjr->crtc[12] << 8)) & 0x3fff; if ((pcjr->crtc[10] & 0x60) == 0x20) pcjr->cursoron = 0; else pcjr->cursoron = pcjr->blink & 16; @@ -565,14 +565,14 @@ vid_poll(void *p) } if (enable_overscan) { - if (pcjr->composite) + if (pcjr->composite) video_blit_memtoscreen(0, (pcjr->firstline - 4) << 1, xsize, ((pcjr->lastline - pcjr->firstline) + 8) << 1); else video_blit_memtoscreen_8(0, (pcjr->firstline - 4) << 1, xsize, ((pcjr->lastline - pcjr->firstline) + 8) << 1); } else { - if (pcjr->composite) + if (pcjr->composite) video_blit_memtoscreen(8, pcjr->firstline << 1, xsize, (pcjr->lastline - pcjr->firstline) << 1); else @@ -594,7 +594,7 @@ vid_poll(void *p) pcjr->sc &= 31; pcjr->ma = pcjr->maback; } - if ((pcjr->sc == (pcjr->crtc[10] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[10] & 31) >> 1)))) + if ((pcjr->sc == (pcjr->crtc[10] & 31) || ((pcjr->crtc[8] & 3) == 3 && pcjr->sc == ((pcjr->crtc[10] & 31) >> 1)))) pcjr->con = 1; } } @@ -624,7 +624,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv) speaker_update(); speaker_gated = val & 1; speaker_enable = val & 2; - if (speaker_enable) + if (speaker_enable) was_speaker_enable = 1; pit_ctr_set_gate(&pit->counters[2], val & 1); sn76489_mute = speaker_mute = 1; @@ -660,7 +660,7 @@ kbd_read(uint16_t port, void *priv) case 0x60: ret = pcjr->pa; break; - + case 0x61: ret = pcjr->pb; break; @@ -678,7 +678,7 @@ kbd_read(uint16_t port, void *priv) if (pcjr->data) ret |= 0x40; break; - + case 0xa0: pcjr->latched = 0; ret = 0; diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index 47b8121e0..e63ef6ff9 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -116,7 +116,7 @@ ps1_write(uint16_t port, uint8_t val, void *priv) } ps->ps1_92 = val & ~1; } else { - ps->ps1_92 = val; + ps->ps1_92 = val; } mem_a20_alt = val & 2; mem_a20_recalc(); @@ -293,7 +293,7 @@ ps1_setup(int model) ps1_hdc_inform(priv, &ps->ps1_91); } - + /* Enable the PS/1 VGA controller. */ device_add(&ps1vga_device); } else if (model == 2121) { @@ -371,4 +371,3 @@ machine_ps1_m2121_init(const machine_t *model) return ret; } - diff --git a/src/machine/m_ps1_hdc.c b/src/machine/m_ps1_hdc.c index e7547a681..e08e0e198 100644 --- a/src/machine/m_ps1_hdc.c +++ b/src/machine/m_ps1_hdc.c @@ -23,7 +23,7 @@ * disk drives for this bus commonly have an 'A' suffix to * identify them as 'ATBUS'. * - * In XTA-IDE, which is slightly older, the programming + * In XTA-IDE, which is slightly older, the programming * interface of the IBM PC/XT (which used the MFM controller * from Xebec) was kept, and, so, it uses an 8bit data path. * Disk drives for this bus commonly have the 'X' suffix to @@ -38,7 +38,7 @@ * data byte per transfer. XTIDE uses regular IDE drives, * and uses the regular ATA/IDE programming interface, just * with the extra register. - * + * * NOTE: We should probably find a nicer way to integrate our Disk * Type table with the main code, so the user can only select * items from that list... @@ -847,7 +847,7 @@ do_send: } } break; - + case STATE_SDATA: if (! no_data) { /* Perform DMA. */ @@ -1040,7 +1040,7 @@ do_recv: case CMD_FORMAT_TRACK: do_format(dev, drive, ccb); break; - + case CMD_SEEK: if (! drive->present) { dev->ssb.not_ready = 1; @@ -1150,7 +1150,7 @@ hdc_read(uint16_t port, void *priv) break; } - return(ret); + return(ret); } diff --git a/src/machine/m_ps2_isa.c b/src/machine/m_ps2_isa.c index 987b29f2e..2604327ab 100644 --- a/src/machine/m_ps2_isa.c +++ b/src/machine/m_ps2_isa.c @@ -73,7 +73,7 @@ static uint8_t ps2_read(uint16_t port, void *p) temp = 0xff; break; } - + return temp; } @@ -160,7 +160,7 @@ static void ps2board_init(void) ps2_uart = device_add_inst(&ns16450_device, 1); lpt1_init(0x3bc); - + memset(&ps2_hd, 0, sizeof(ps2_hd)); } diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index 549168ffb..36a0d7f0f 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -78,27 +78,27 @@ static struct uint8_t setup; uint8_t sys_ctrl_port_a; uint8_t subaddr_lo, subaddr_hi; - + uint8_t memory_bank[8]; - + uint8_t io_id; uint16_t planar_id; mem_mapping_t split_mapping; mem_mapping_t expansion_mapping; mem_mapping_t cache_mapping; - + uint8_t (*planar_read)(uint16_t port); void (*planar_write)(uint16_t port, uint8_t val); - + uint8_t mem_regs[3]; - + uint32_t split_addr, split_size; uint32_t split_phys; - + uint8_t mem_pos_regs[8]; uint8_t mem_2mb_pos_regs[8]; - + int pending_cache_miss; serial_t *uart; @@ -106,7 +106,7 @@ static struct /*The model 70 type 3/4 BIOS performs cache testing. Since 86Box doesn't have any proper cache emulation, it's faked a bit here. - + Port E2 is used for cache diagnostics. Bit 7 seems to be set on a cache miss, toggling bit 2 seems to clear this. The BIOS performs at least the following tests : @@ -124,7 +124,7 @@ static struct This behaviour is required to pass the timer interrupt test on the 486 version - the BIOS uses a fixed length loop that will terminate too early on a 486/25 if it executes from internal cache. - + To handle this, 86Box uses some basic heuristics : - If cache is enabled but RAM is disabled, accesses to low memory go directly to cache memory. @@ -741,7 +741,7 @@ uint8_t ps2_mca_read(uint16_t port, void *p) else temp = 0xff; break; - + default: temp = 0xff; break; @@ -831,7 +831,7 @@ static void ps2_mca_board_common_init() device_add(&port_92_device); ps2.setup = 0xff; - + lpt1_init(0x3bc); } @@ -945,7 +945,7 @@ static void ps2_mca_mem_d071_init(int start_mb) static void ps2_mca_board_model_50_init() -{ +{ ps2_mca_board_common_init(); mem_remap_top(384); @@ -961,18 +961,18 @@ static void ps2_mca_board_model_50_init() ps2_mca_mem_fffc_init(2); } - if (gfxcard == VID_INTERNAL) + if (gfxcard == VID_INTERNAL) device_add(&ps1vga_mca_device); } static void ps2_mca_board_model_55sx_init() -{ +{ ps2_mca_board_common_init(); ps2.option[1] = 0x00; ps2.option[2] = 0x00; ps2.option[3] = 0x10; - + memset(ps2.memory_bank, 0xf0, 8); switch (mem_size/1024) { @@ -1006,8 +1006,8 @@ static void ps2_mca_board_model_55sx_init() ps2.memory_bank[0] = 0x01; ps2.memory_bank[1] = 0x01; break; - } - + } + mca_init(4); device_add(&keyboard_ps2_mca_device); @@ -1028,11 +1028,11 @@ static void mem_encoding_update(void) mem_set_mem_state(ps2.split_addr, ps2.split_size << 10, MEM_READ_EXTANY | MEM_WRITE_EXTANY); if (((mem_size << 10) - (1 << 20)) > 0) mem_set_mem_state(1 << 20, (mem_size << 10) - (1 << 20), MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); - + ps2.split_addr = ((uint32_t) (ps2.mem_regs[0] & 0xf)) << 20; if (!ps2.split_addr) ps2.split_addr = 1 << 20; - + if (ps2.mem_regs[1] & 2) { mem_set_mem_state(0xe0000, 0x20000, MEM_READ_EXTANY | MEM_WRITE_INTERNAL); ps2_mca_log("PS/2 Model 80-111: ROM space enabled\n"); @@ -1114,7 +1114,7 @@ static uint8_t mem_encoding_read_cached(uint16_t addr, void *p) static void mem_encoding_write_cached(uint16_t addr, uint8_t val, void *p) { uint8_t old; - + switch (addr) { case 0xe0: @@ -1166,7 +1166,7 @@ static void mem_encoding_write_cached(uint16_t addr, uint8_t val, void *p) } static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) -{ +{ ps2_mca_board_common_init(); ps2.split_addr = mem_size * 1024; @@ -1175,9 +1175,9 @@ static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) ps2.planar_read = model_70_type3_read; ps2.planar_write = model_70_type3_write; - + device_add(&ps2_nvr_device); - + io_sethandler(0x00e0, 0x0003, mem_encoding_read_cached, NULL, NULL, mem_encoding_write_cached, NULL, NULL, NULL); ps2.mem_regs[1] = 2; @@ -1202,12 +1202,12 @@ static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) ps2.option[2] = 0x02; break; } - + if (is_type4) ps2.option[2] |= 0x04; /*486 CPU*/ mem_mapping_add(&ps2.split_mapping, - (mem_size+256) * 1024, + (mem_size+256) * 1024, 256*1024, ps2_read_split_ram, ps2_read_split_ramw, @@ -1221,7 +1221,7 @@ static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) mem_mapping_disable(&ps2.split_mapping); mem_mapping_add(&ps2.cache_mapping, - 0, + 0, (is_type4) ? (8 * 1024) : (64 * 1024), ps2_read_cache_ram, ps2_read_cache_ramw, @@ -1233,7 +1233,7 @@ static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) MEM_MAPPING_INTERNAL, NULL); mem_mapping_disable(&ps2.cache_mapping); - + if (ps2.planar_id == 0xfff9) { if (mem_size > 4096) { @@ -1243,7 +1243,7 @@ static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) } else { ps2_mca_mem_fffc_init(4); } - } + } } else { if (mem_size > 8192) { @@ -1256,25 +1256,25 @@ static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) } } - if (gfxcard == VID_INTERNAL) + if (gfxcard == VID_INTERNAL) device_add(&ps1vga_mca_device); } static void ps2_mca_board_model_80_type2_init(int is486) -{ +{ ps2_mca_board_common_init(); ps2.split_addr = mem_size * 1024; mca_init(8); device_add(&keyboard_ps2_mca_device); - + ps2.planar_read = model_80_read; ps2.planar_write = model_80_write; - + device_add(&ps2_nvr_device); - + io_sethandler(0x00e0, 0x0002, mem_encoding_read, NULL, NULL, mem_encoding_write, NULL, NULL, NULL); - + ps2.mem_regs[1] = 2; /* Note by Kotori: I rewrote this because the original code was using @@ -1308,7 +1308,7 @@ static void ps2_mca_board_model_80_type2_init(int is486) ps2.mem_regs[0] |= ((mem_size/1024) & 0x0f); mem_mapping_add(&ps2.split_mapping, - (mem_size+256) * 1024, + (mem_size+256) * 1024, 256*1024, ps2_read_split_ram, ps2_read_split_ramw, @@ -1320,7 +1320,7 @@ static void ps2_mca_board_model_80_type2_init(int is486) MEM_MAPPING_INTERNAL, NULL); mem_mapping_disable(&ps2.split_mapping); - + if ((mem_size > 4096) && !is486) { /* Only 4 MB supported on planar, create a memory expansion card for the rest */ @@ -1331,7 +1331,7 @@ static void ps2_mca_board_model_80_type2_init(int is486) } } - if (gfxcard == VID_INTERNAL) + if (gfxcard == VID_INTERNAL) device_add(&ps1vga_mca_device); ps2.split_size = 0; @@ -1415,7 +1415,7 @@ machine_ps2_model_70_type3_init(const machine_t *model) return ret; machine_ps2_common_init(model); - + ps2.planar_id = 0xf9ff; ps2_mca_board_model_70_type34_init(0, 4); @@ -1462,4 +1462,4 @@ machine_ps2_model_80_axx_init(const machine_t *model) ps2_mca_board_model_70_type34_init(0, 8); return ret; -} \ No newline at end of file +} diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index 1eaf93163..293919c50 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -557,7 +557,7 @@ vid_out(uint16_t addr, uint8_t val, void *priv) break; case 0x03de: - if (vid->array_index & 16) + if (vid->array_index & 16) val &= 0xf; vid->array[vid->array_index & 0x1f] = val; if (dev->is_sl2) { @@ -675,7 +675,7 @@ vid_poll(void *priv) vid->stat |= 1; vid->linepos = 1; oldsc = vid->sc; - if ((vid->crtc[8] & 3) == 3) + if ((vid->crtc[8] & 3) == 3) vid->sc = (vid->sc << 1) & 7; if (vid->dispon) { if (vid->displine < vid->firstline) { @@ -716,7 +716,7 @@ vid_poll(void *priv) } if (dev->is_sl2 && (vid->array[5] & 1)) { /*640x200x16*/ for (x = 0; x < vid->crtc[1]*2; x++) { - dat = (vid->vram[(vid->ma << 1) & 0xffff] << 8) | + dat = (vid->vram[(vid->ma << 1) & 0xffff] << 8) | vid->vram[((vid->ma << 1) + 1) & 0xffff]; vid->ma++; buffer32->line[(vid->displine << 1)][(x << 2) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 2) + 8] = @@ -730,7 +730,7 @@ vid_poll(void *priv) } } else if ((vid->array[3] & 0x10) && (vid->mode & 1)) { /*320x200x16*/ for (x = 0; x < vid->crtc[1]; x++) { - dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000)] << 8) | + dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000) + 1]; vid->ma++; buffer32->line[(vid->displine << 1)][(x << 3) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + 8] = @@ -749,10 +749,10 @@ vid_poll(void *priv) } else if (vid->array[3] & 0x10) { /*160x200x16*/ for (x = 0; x < vid->crtc[1]; x++) { if (dev->is_sl2) { - dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000)] << 8) | + dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; } else { - dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000)] << 8) | + dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000) + 1]; } vid->ma++; @@ -798,7 +798,7 @@ vid_poll(void *priv) if (vid->mode & 0x20) { cols[1] = vid->array[ ((attr & 15) & vid->array[1]) + 16] + 16; cols[0] = vid->array[(((attr >> 4) & 7) & vid->array[1]) + 16] + 16; - if ((vid->blink & 16) && (attr & 0x80) && !drawcursor) + if ((vid->blink & 16) && (attr & 0x80) && !drawcursor) cols[1] = cols[0]; } else { cols[1] = vid->array[((attr & 15) & vid->array[1]) + 16] + 16; @@ -836,7 +836,7 @@ vid_poll(void *priv) if (vid->mode & 0x20) { cols[1] = vid->array[ ((attr & 15) & vid->array[1]) + 16] + 16; cols[0] = vid->array[(((attr >> 4) & 7) & vid->array[1]) + 16] + 16; - if ((vid->blink & 16) && (attr & 0x80) && !drawcursor) + if ((vid->blink & 16) && (attr & 0x80) && !drawcursor) cols[1] = cols[0]; } else { cols[1] = vid->array[((attr & 15) & vid->array[1]) + 16] + 16; @@ -850,11 +850,11 @@ vid_poll(void *priv) } else { for (c = 0; c < 8; c++) { if (vid->sc == 8) { - buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = + buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0]; } else { - buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = + buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } @@ -888,7 +888,7 @@ vid_poll(void *priv) cols[2] = vid->array[(cols[2] & vid->array[1]) + 16] + 16; cols[3] = vid->array[(cols[3] & vid->array[1]) + 16] + 16; for (x = 0; x < vid->crtc[1]; x++) { - dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000)] << 8) | + dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; vid->ma++; for (c = 0; c < 8; c++) { @@ -899,7 +899,7 @@ vid_poll(void *priv) } } } else { - cols[0] = 0; + cols[0] = 0; cols[1] = vid->array[(vid->col & vid->array[1]) + 16] + 16; for (x = 0; x < vid->crtc[1]; x++) { dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000)] << 8) | @@ -945,11 +945,11 @@ vid_poll(void *priv) if (vid->vc == vid->crtc[7] && !vid->sc) vid->stat |= 8; vid->displine++; - if (vid->displine >= 360) + if (vid->displine >= 360) vid->displine = 0; } else { timer_advance_u64(&vid->timer, vid->dispontime); - if (vid->dispon) + if (vid->dispon) vid->stat &= ~1; vid->linepos = 0; if (vid->vsynctime) { @@ -957,9 +957,9 @@ vid_poll(void *priv) if (! vid->vsynctime) vid->stat &= ~8; } - if (vid->sc == (vid->crtc[11] & 31) || ((vid->crtc[8] & 3) == 3 && vid->sc == ((vid->crtc[11] & 31) >> 1))) { - vid->con = 0; - vid->coff = 1; + if (vid->sc == (vid->crtc[11] & 31) || ((vid->crtc[8] & 3) == 3 && vid->sc == ((vid->crtc[11] & 31) >> 1))) { + vid->con = 0; + vid->coff = 1; } if (vid->vadj) { vid->sc++; @@ -983,12 +983,12 @@ vid_poll(void *priv) vid->vc &= 255; else vid->vc &= 127; - if (vid->vc == vid->crtc[6]) + if (vid->vc == vid->crtc[6]) vid->dispon = 0; if (oldvc == vid->crtc[4]) { vid->vc = 0; vid->vadj = vid->crtc[5]; - if (! vid->vadj) + if (! vid->vadj) vid->dispon = 1; if (! vid->vadj) { if (dev->is_sl2 && (vid->array[5] & 1)) @@ -1031,14 +1031,14 @@ vid_poll(void *priv) } if (enable_overscan) { - if (!dev->is_sl2 && vid->composite) + if (!dev->is_sl2 && vid->composite) video_blit_memtoscreen(0, (vid->firstline - 4) << 1, xsize, ((vid->lastline - vid->firstline) + 8) << 1); else video_blit_memtoscreen_8(0, (vid->firstline - 4) << 1, xsize, ((vid->lastline - vid->firstline) + 8) << 1); } else { - if (!dev->is_sl2 && vid->composite) + if (!dev->is_sl2 && vid->composite) video_blit_memtoscreen(8, vid->firstline << 1, xsize, (vid->lastline - vid->firstline) << 1); else @@ -1083,7 +1083,7 @@ vid_poll(void *priv) vid->sc &= 31; vid->ma = vid->maback; } - if ((vid->sc == (vid->crtc[10] & 31) || ((vid->crtc[8] & 3) == 3 && vid->sc == ((vid->crtc[10] & 31) >> 1)))) + if ((vid->sc == (vid->crtc[10] & 31) || ((vid->crtc[8] & 3) == 3 && vid->sc == ((vid->crtc[10] & 31) >> 1)))) vid->con = 1; } } @@ -1522,7 +1522,7 @@ machine_tandy1k_init(const machine_t *model, int type) device_add(&keyboard_tandy_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_type == FDC_INTERNAL) device_add(&fdc_xt_tandy_device); video_reset(gfxcard); diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 1e4e7bd39..ae580c591 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -26,9 +26,9 @@ machine_xt_common_init(const machine_t *model) pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); - if (fdc_type == FDC_INTERNAL) + if (fdc_type == FDC_INTERNAL) device_add(&fdc_xt_device); - + nmi_init(); standalone_gameport_type = &gameport_device; } @@ -217,6 +217,22 @@ machine_xt_amixt_init(const machine_t *model) return ret; } +int +machine_xt_znic_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear("roms/machines/znic/ibmzen.rom", + 0x000fe000, 8192, 0); + + if (bios_only || !ret) + return ret; + + machine_xt_clone_init(model); + + return ret; +} + int machine_xt_dtk_init(const machine_t *model) @@ -349,7 +365,7 @@ machine_xt_mpc1600_init(const machine_t *model) ret = bios_load_linear("roms/machines/mpc1600/mpc4.34_merged.bin", 0x000fc000, 16384, 0); - + if (bios_only || !ret) return ret; @@ -368,7 +384,7 @@ machine_xt_pcspirit_init(const machine_t *model) ret = bios_load_linear("roms/machines/pcspirit/u1101.bin", 0x000fe000, 16384, 0); - + if (ret) { bios_load_aux_linear("roms/machines/pcspirit/u1103.bin", 0x000fc000, 8192, 0); diff --git a/src/machine/m_xt_olivetti.c b/src/machine/m_xt_olivetti.c index 9100bbe3b..bb6ae7db5 100644 --- a/src/machine/m_xt_olivetti.c +++ b/src/machine/m_xt_olivetti.c @@ -202,7 +202,7 @@ m24_kbd_write(uint16_t port, uint8_t val, void *priv) m24_kbd->scan[1] = m24_kbd->params[1]; m24_kbd->scan[2] = m24_kbd->params[2]; break; - + default: m24_log("M24: bad keyboard command complete %02X\n", m24_kbd->command); } @@ -239,7 +239,7 @@ m24_kbd_write(uint16_t port, uint8_t val, void *priv) speaker_update(); speaker_gated = val & 1; speaker_enable = val & 2; - if (speaker_enable) + if (speaker_enable) was_speaker_enable = 1; pit_ctr_set_gate(&pit->counters[2], val & 1); break; @@ -264,7 +264,7 @@ m24_kbd_read(uint16_t port, void *priv) key_queue_start = (key_queue_start + 1) & 0xf; m24_kbd->status |= STAT_OFULL; m24_kbd->status &= ~STAT_IFULL; - m24_kbd->wantirq = 1; + m24_kbd->wantirq = 1; } break; @@ -292,7 +292,7 @@ m24_kbd_close(void *priv) /* Stop the timer. */ timer_disable(&kbd->send_delay_timer); - + /* Disable scanning. */ keyboard_scan = 0; @@ -311,7 +311,7 @@ static void m24_kbd_reset(void *priv) { m24_kbd_t *m24_kbd = (m24_kbd_t *)priv; - + /* Initialize the keyboard. */ m24_kbd->status = STAT_LOCK | STAT_CD; m24_kbd->wantirq = 0; @@ -324,7 +324,7 @@ m24_kbd_reset(void *priv) m24_kbd->scan[3] = 0x4b; m24_kbd->scan[4] = 0x4d; m24_kbd->scan[5] = 0x48; - m24_kbd->scan[6] = 0x50; + m24_kbd->scan[6] = 0x50; } @@ -364,7 +364,7 @@ ms_poll(int x, int y, int z, int b, void *priv) if (((key_queue_end - key_queue_start) & 0xf) > 12) return(0xff); if (!m24_kbd->x && !m24_kbd->y) return(0xff); - + m24_kbd->y = -m24_kbd->y; if (m24_kbd->x < -127) m24_kbd->x = -127; @@ -414,7 +414,7 @@ ms_poll(int x, int y, int z, int b, void *priv) static void m24_kbd_init(m24_kbd_t *kbd) { - + /* Initialize the keyboard. */ io_sethandler(0x0060, 2, m24_kbd_read, NULL, NULL, m24_kbd_write, NULL, NULL, kbd); @@ -651,10 +651,10 @@ static uint8_t m24_read(uint16_t port, void *priv) { uint8_t ret = 0x00; - int i, fdd_count = 0; + int i, fdd_count = 0; switch (port) { - /* + /* * port 66: * DIPSW-0 on mainboard (off=present=1) * bit 7 - 2764 (off) / 2732 (on) ROM (BIOS < 1.36) @@ -668,8 +668,8 @@ m24_read(uint16_t port, void *priv) /* Switch 5 - 8087 present */ if (hasfpu) ret |= 0x10; - /* - * Switches 1, 2, 3, 4 - installed memory + /* + * Switches 1, 2, 3, 4 - installed memory * Switch 8 - Use memory bank 1 */ switch (mem_size) { @@ -690,7 +690,7 @@ m24_read(uint16_t port, void *priv) ret |= 0x1|0x8|0x80; break; } - /* + /* * port 67: * DIPSW-1 on mainboard (off=present=1) * bits 7-6 - number of drives @@ -699,7 +699,7 @@ m24_read(uint16_t port, void *priv) * bit 2 - BIOS HD on mainboard (on) / on controller (off) * bit 1 - FDD fast (off) / slow (on) start drive * bit 0 - 96 TPI (720 KB 3.5") (off) / 48 TPI (360 KB 5.25") FDD drive - * + * * Display adapter: * off off 80x25 mono * off on 40x25 color @@ -717,7 +717,7 @@ m24_read(uint16_t port, void *priv) ret |= 0x00; else ret |= ((fdd_count - 1) << 6); - + /* Switches 5, 6 - monitor type */ if (video_is_mda()) ret |= 0x30; @@ -725,10 +725,10 @@ m24_read(uint16_t port, void *priv) ret |= 0x20; /* 0x10 would be 40x25 */ else ret |= 0x0; - + /* Switch 3 - Disable internal BIOS HD */ ret |= 0x4; - + /* Switch 2 - Set fast startup */ ret |= 0x2; } @@ -788,7 +788,7 @@ machine_xt_m24_init(const machine_t *model) } /* - * Current bugs: + * Current bugs: * - handles only 360kb floppy drives (drive type and capacity selectable with jumpers mapped to unknown memory locations) */ int @@ -810,7 +810,7 @@ machine_xt_m240_init(const machine_t *model) /* Address 66-67 = mainboard dip-switch settings */ io_sethandler(0x0066, 2, m24_read, NULL, NULL, NULL, NULL, NULL, NULL); - /* + /* * port 60: should return jumper settings only under unknown conditions * SWB on mainboard (off=1) * bit 7 - use BIOS HD on mainboard (on) / on controller (off) @@ -835,7 +835,7 @@ machine_xt_m240_init(const machine_t *model) /* - * Current bugs: + * Current bugs: * - 640x400x2 graphics mode not supported (bit 0 of register 0x3de cannot be set) * - optional mouse emulation missing * - setting CPU speed at 4.77MHz sometimes throws a timer error. If the machine is hard-resetted, the error disappears. diff --git a/src/machine/m_xt_philips.c b/src/machine/m_xt_philips.c index 753d1300b..e3d23deb7 100644 --- a/src/machine/m_xt_philips.c +++ b/src/machine/m_xt_philips.c @@ -75,18 +75,18 @@ philips_write(uint16_t port, uint8_t val, void *priv) * bit 7: turbo * bits 4-5: rtc read/set (I2C Bus SDA/SCL?) * bit 2: parity disabled - */ + */ case 0xc0: dev->reg = val; if (val & 0x80) cpu_dynamic_switch(cpu); else cpu_dynamic_switch(0); - break; + break; } - + philips_log("Philips XT Mainboard: Write %02x at %02x\n", val, port); - + } static uint8_t @@ -170,7 +170,7 @@ machine_xt_p3105_init(const machine_t *model) ret = bios_load_linear("roms/machines/p3105/philipsnms9100.bin", 0x000fc000, 16384, 0); - + if (bios_only || !ret) return ret; @@ -189,16 +189,15 @@ machine_xt_p3120_init(const machine_t *model) ret = bios_load_linear("roms/machines/p3120/philips_p3120.bin", 0x000f8000, 32768, 0); - + if (bios_only || !ret) return ret; machine_xt_philips_common_init(model); - + device_add(&gc100a_device); device_add(&fdc_at_device); - + return ret; } - diff --git a/src/machine/m_xt_t1000.c b/src/machine/m_xt_t1000.c index ef4a09c42..a871c7a25 100644 --- a/src/machine/m_xt_t1000.c +++ b/src/machine/m_xt_t1000.c @@ -9,16 +9,16 @@ * Implementation of the Toshiba T1000 and T1200 portables. * * The T1000 is the T3100e's little brother -- a real laptop - * with a rechargeable battery. + * with a rechargeable battery. * * Features: 80C88 at 4.77MHz * - 512k system RAM * - 640x200 monochrome LCD - * - 82-key keyboard + * - 82-key keyboard * - Real-time clock. Not the normal 146818, but a TC8521, * which is a 4-bit chip. * - A ROM drive (128k, 256k or 512k) which acts as a mini - * hard drive and contains a copy of DOS 2.11. + * hard drive and contains a copy of DOS 2.11. * - 160 bytes of non-volatile RAM for the CONFIG.SYS used * when booting from the ROM drive. Possibly physically * located in the keyboard controller RAM. @@ -40,7 +40,7 @@ * and programming level. * * 01F2h: If hard drive is present, low 4 bits are 0Ch [20Mb] - * or 0Dh [10Mb]. + * or 0Dh [10Mb]. * * The hard drive is a 20MB (615/2/26) RLL 3.5" drive. * @@ -154,7 +154,7 @@ typedef struct { uint8_t turbo; /* NVRAM control */ - uint8_t nvr_c0; + uint8_t nvr_c0; uint8_t nvr_tick; int nvr_addr; uint8_t nvr_active; @@ -357,7 +357,7 @@ static uint32_t ems_execaddr(t1000_t *sys, int pg, uint16_t val) { if (!(val & 0x80)) return(0); /* Bit 7 reset => not mapped */ - if (!sys->ems_pages) return(0); /* No EMS available: all used by + if (!sys->ems_pages) return(0); /* No EMS available: all used by * HardRAM or conventional RAM */ val &= 0x7f; @@ -454,7 +454,7 @@ ems_set_port(t1000_t *sys, uint8_t val) #endif if (sys->ems_port) { for (n = 0; n <= 0xc000; n += 0x4000) { - io_removehandler(sys->ems_port+n, 1, + io_removehandler(sys->ems_port+n, 1, ems_in,NULL,NULL, ems_out,NULL,NULL, sys); } sys->ems_port = 0; @@ -468,7 +468,7 @@ ems_set_port(t1000_t *sys, uint8_t val) } else { sys->ems_port = 0x208 | (val << 4); for (n = 0; n <= 0xc000; n += 0x4000) { - io_sethandler(sys->ems_port+n, 1, + io_sethandler(sys->ems_port+n, 1, ems_in,NULL,NULL, ems_out,NULL,NULL, sys); } sys->ems_port = 0; @@ -497,7 +497,7 @@ ems_read_ram(uint32_t addr, void *priv) if (pg < 0) return(0xff); addr = sys->page_exec[pg] + (addr & 0x3fff); - return(ram[addr]); + return(ram[addr]); } @@ -568,7 +568,7 @@ ems_write_ramw(uint32_t addr, uint16_t val, void *priv) t1000_log("-> %06x val=%04x\n", addr, val); #endif - if (*(uint16_t *)&ram[addr] != val) nvr_dosave = 1; + if (*(uint16_t *)&ram[addr] != val) nvr_dosave = 1; *(uint16_t *)&ram[addr] = val; } @@ -583,7 +583,7 @@ ems_write_raml(uint32_t addr, uint32_t val, void *priv) if (pg < 0) return; addr = sys->page_exec[pg] + (addr & 0x3fff); - if (*(uint32_t *)&ram[addr] != val) nvr_dosave = 1; + if (*(uint32_t *)&ram[addr] != val) nvr_dosave = 1; *(uint32_t *)&ram[addr] = val; } @@ -620,7 +620,7 @@ read_ctl(uint16_t addr, void *priv) break; default: - ret = (sys->sys_ctl[addr & 0x0f]); + ret = (sys->sys_ctl[addr & 0x0f]); } return(ret); @@ -663,8 +663,8 @@ write_ctl(uint16_t addr, uint8_t val, void *priv) { t1000_video_enable(val & 0x01 ? 0 : 1); } - break; - + break; + case 0x0f: /* EMS control */ switch (sys->sys_ctl[0x0e]) { case 0x50: @@ -734,7 +734,7 @@ t1000_write_nvram(uint16_t addr, uint8_t val, void *priv) case 0xc1: /* Write next byte to NVRAM */ if (sys->nvr_addr >= 0 && sys->nvr_addr < 160) { - if (sys->t1000_nvram[sys->nvr_addr] != val) + if (sys->t1000_nvram[sys->nvr_addr] != val) nvr_dosave = 1; sys->t1000_nvram[sys->nvr_addr] = val; } @@ -773,7 +773,7 @@ static void write_t1200_nvram(uint32_t addr, uint8_t value, void *priv) { t1000_t *sys = (t1000_t *)priv; - if (sys->t1200_nvram[addr & 0x7FF] != value) + if (sys->t1200_nvram[addr & 0x7FF] != value) nvr_dosave = 1; sys->t1200_nvram[addr & 0x7FF] = value; @@ -801,9 +801,9 @@ t1000_write_rom_ctl(uint16_t addr, uint8_t val, void *priv) sys->rom_offset = ((val & 0x7f) * 0x10000) % T1000_ROMSIZE; mem_mapping_set_addr(&sys->rom_mapping, 0xa0000, 0x10000); mem_mapping_set_exec(&sys->rom_mapping, sys->romdrive + sys->rom_offset); - mem_mapping_enable(&sys->rom_mapping); + mem_mapping_enable(&sys->rom_mapping); } else { - mem_mapping_disable(&sys->rom_mapping); + mem_mapping_disable(&sys->rom_mapping); } } @@ -965,8 +965,8 @@ machine_xt_t1200_init(const machine_t *model) /* Map the EMS page frame */ for (pg = 0; pg < 4; pg++) { - mem_mapping_add(&t1000.mapping[pg], - 0xd0000 + (0x4000 * pg), 16384, + mem_mapping_add(&t1000.mapping[pg], + 0xd0000 + (0x4000 * pg), 16384, ems_read_ram,ems_read_ramw,ems_read_raml, ems_write_ram,ems_write_ramw,ems_write_raml, NULL, MEM_MAPPING_EXTERNAL, &t1000); @@ -984,7 +984,7 @@ machine_xt_t1200_init(const machine_t *model) mem_mapping_add(&t1000.nvr_mapping, 0x000f0000, 2048, read_t1200_nvram, NULL, NULL, - write_t1200_nvram, NULL, NULL, + write_t1200_nvram, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, &t1000); pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); diff --git a/src/machine/m_xt_t1000_vid.c b/src/machine/m_xt_t1000_vid.c index d5cd7b21e..158990984 100644 --- a/src/machine/m_xt_t1000_vid.c +++ b/src/machine/m_xt_t1000_vid.c @@ -103,7 +103,7 @@ typedef struct t1000_t { mem_mapping_t mapping; - cga_t cga; /* The CGA is used for the external + cga_t cga; /* The CGA is used for the external * display; most of its registers are * ignored by the plasma display. */ @@ -113,7 +113,7 @@ typedef struct t1000_t uint8_t attrmap; /* Attribute mapping register */ uint64_t dispontime, dispofftime; - + int linepos, displine; int vc; int dispon; @@ -145,12 +145,12 @@ static void t1000_out(uint16_t addr, uint8_t val, void *p) case 0x3d1: case 0x3d3: case 0x3d5: case 0x3d7: /* Register 0x12 controls the attribute mappings for the * LCD screen. */ - if (t1000->cga.crtcreg == 0x12) + if (t1000->cga.crtcreg == 0x12) { - t1000->attrmap = val; + t1000->attrmap = val; t1000_recalcattrs(t1000); return; - } + } cga_out(addr, val, &t1000->cga); t1000_recalctimings(t1000); @@ -182,7 +182,7 @@ static uint8_t t1000_in(uint16_t addr, void *p) return val; } } - + return cga_in(addr, &t1000->cga); } @@ -196,7 +196,7 @@ static void t1000_write(uint32_t addr, uint8_t val, void *p) t1000->vram[addr & 0x3fff] = val; cycles -= 4; } - + static uint8_t t1000_read(uint32_t addr, void *p) { t1000_t *t1000 = (t1000_t *)p; @@ -271,8 +271,8 @@ static void t1000_text_row80(t1000_t *t1000) if (t1000->cga.cgamode & 0x20) /* Blink */ { - cols[1] = blinkcols[attr][1]; - cols[0] = blinkcols[attr][0]; + cols[1] = blinkcols[attr][1]; + cols[0] = blinkcols[attr][0]; if (blink) cols[1] = cols[0]; } else @@ -343,8 +343,8 @@ static void t1000_text_row40(t1000_t *t1000) if (t1000->cga.cgamode & 0x20) /* Blink */ { - cols[1] = blinkcols[attr][1]; - cols[0] = blinkcols[attr][0]; + cols[1] = blinkcols[attr][1]; + cols[0] = blinkcols[attr][0]; if (blink) cols[1] = cols[0]; } else @@ -356,7 +356,7 @@ static void t1000_text_row40(t1000_t *t1000) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2] = + ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2 + 1] = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (blue ^ grey); } } @@ -364,7 +364,7 @@ static void t1000_text_row40(t1000_t *t1000) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2] = + ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2+1] = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; } } @@ -432,7 +432,7 @@ static void t1000_cgaline4(t1000_t *t1000) { default: case 0: ink0 = ink1 = grey; break; - case 1: if (t1000->displine & 1) + case 1: if (t1000->displine & 1) { ink0 = grey; ink1 = grey; } @@ -441,7 +441,7 @@ static void t1000_cgaline4(t1000_t *t1000) ink0 = blue; ink1 = grey; } break; - case 2: if (t1000->displine & 1) + case 2: if (t1000->displine & 1) { ink0 = grey; ink1 = blue; } @@ -472,10 +472,10 @@ static void t1000_poll(void *p) /* Set the font used for the external display */ t1000->cga.fontbase = ((t1000->video_options & 3) * 256); - + if (t1000->enabled) /* Disable internal chipset */ mem_mapping_enable(&t1000->mapping); - else + else mem_mapping_disable(&t1000->mapping); } /* Switch between internal plasma and external CRT display. */ @@ -503,20 +503,20 @@ static void t1000_poll(void *p) } /* Graphics */ - if (t1000->cga.cgamode & 0x02) + if (t1000->cga.cgamode & 0x02) { if (t1000->cga.cgamode & 0x10) t1000_cgaline6(t1000); else t1000_cgaline4(t1000); } - else + else if (t1000->cga.cgamode & 0x01) /* High-res text */ { - t1000_text_row80(t1000); + t1000_text_row80(t1000); } else { - t1000_text_row40(t1000); + t1000_text_row40(t1000); } } t1000->displine++; @@ -563,7 +563,7 @@ static void t1000_poll(void *p) video_res_x = T1000_XSIZE; video_res_y = T1000_YSIZE; - if (t1000->cga.cgamode & 0x02) + if (t1000->cga.cgamode & 0x02) { if (t1000->cga.cgamode & 0x10) video_bpp = 1; @@ -581,10 +581,10 @@ static void t1000_recalcattrs(t1000_t *t1000) int n; /* val behaves as follows: - * Bit 0: Attributes 01-06, 08-0E are inverse video - * Bit 1: Attributes 01-06, 08-0E are bold + * Bit 0: Attributes 01-06, 08-0E are inverse video + * Bit 1: Attributes 01-06, 08-0E are bold * Bit 2: Attributes 11-16, 18-1F, 21-26, 28-2F ... F1-F6, F8-FF - * are inverse video + * are inverse video * Bit 3: Attributes 11-16, 18-1F, 21-26, 28-2F ... F1-F6, F8-FF * are bold */ @@ -612,12 +612,12 @@ static void t1000_recalcattrs(t1000_t *t1000) for (n = 0; n < 256; n++) { boldcols[n] = (n & 8) != 0; - blinkcols[n][0] = normcols[n][0] = blue; + blinkcols[n][0] = normcols[n][0] = blue; blinkcols[n][1] = normcols[n][1] = grey; } - /* Colours 0x11-0xFF are controlled by bits 2 and 3 of the - * passed value. Exclude x0 and x8, which are always grey on + /* Colours 0x11-0xFF are controlled by bits 2 and 3 of the + * passed value. Exclude x0 and x8, which are always grey on * blue. */ for (n = 0x11; n <= 0xFF; n++) { @@ -634,7 +634,7 @@ static void t1000_recalcattrs(t1000_t *t1000) } if (t1000->attrmap & 8) boldcols[n] = 1; /* Bold */ } - /* Set up the 01-0E range, controlled by bits 0 and 1 of the + /* Set up the 01-0E range, controlled by bits 0 and 1 of the * passed value. When blinking is enabled this also affects 81-8E. */ for (n = 0x01; n <= 0x0E; n++) { @@ -655,7 +655,7 @@ static void t1000_recalcattrs(t1000_t *t1000) } if (t1000->attrmap & 2) boldcols[n] = 1; } - /* Colours 07 and 0F are always blue on grey. If blinking is + /* Colours 07 and 0F are always blue on grey. If blinking is * enabled so are 87 and 8F. */ for (n = 0x07; n <= 0x0F; n += 8) { @@ -736,19 +736,19 @@ static void t1000_close(void *p) static void t1000_speed_changed(void *p) { t1000_t *t1000 = (t1000_t *)p; - + t1000_recalctimings(t1000); } -static const device_config_t t1000_config[] = +static const device_config_t t1000_config[] = { { .name = "display_language", .description = "Language", .type = CONFIG_SELECTION, - .selection = + .selection = { - { + { .description = "USA", .value = 0 }, diff --git a/src/machine/m_xt_zenith.c b/src/machine/m_xt_zenith.c index 19f2bc748..138badafa 100644 --- a/src/machine/m_xt_zenith.c +++ b/src/machine/m_xt_zenith.c @@ -76,20 +76,20 @@ zenith_scratchpad_init(const device_t *info) zenith_t *dev; dev = (zenith_t *)malloc(sizeof(zenith_t)); - memset(dev, 0x00, sizeof(zenith_t)); - + memset(dev, 0x00, sizeof(zenith_t)); + dev->scratchpad_ram = malloc(0x4000); - + mem_mapping_add(&dev->scratchpad_mapping, 0xf0000, 0x4000, zenith_scratchpad_read, NULL, NULL, zenith_scratchpad_write, NULL, NULL, dev->scratchpad_ram, MEM_MAPPING_EXTERNAL, dev); - + return dev; } -static void +static void zenith_scratchpad_close(void *p) { zenith_t *dev = (zenith_t *)p; @@ -112,16 +112,16 @@ static const device_t zenith_scratchpad_device = { void machine_zenith_init(const machine_t *model){ - + machine_common_init(model); - + if (fdc_type == FDC_INTERNAL) device_add(&fdc_xt_device); device_add(&zenith_scratchpad_device); - + pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); - + device_add(&keyboard_xt_zenith_device); nmi_init(); @@ -140,7 +140,7 @@ z184_get_device(void) */ int machine_xt_z184_init(const machine_t *model) -{ +{ int ret; ret = bios_load_linear("roms/machines/zdsupers/z184m v3.1d.10d", @@ -150,15 +150,15 @@ machine_xt_z184_init(const machine_t *model) return ret; machine_zenith_init(model); - + lpt1_remove(); /* only one parallel port */ lpt2_remove(); lpt1_init(0x278); device_add(&ns8250_device); serial_set_next_inst(SERIAL_MAX); /* So that serial_standalone_init() won't do anything. */ - + device_add(&cga_device); - + return ret; } @@ -177,7 +177,7 @@ machine_xt_z151_init(const machine_t *model) return ret; machine_zenith_init(model); - + return ret; } @@ -197,11 +197,11 @@ machine_xt_z159_init(const machine_t *model) return ret; machine_zenith_init(model); - + /* parallel port is on the memory board */ lpt1_remove(); /* only one parallel port */ lpt2_remove(); lpt1_init(0x278); return ret; -} \ No newline at end of file +} diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index b8322fff9..0fc34e930 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -134,11 +134,12 @@ const machine_t machines[] = { #endif /* Has a standard PS/2 KBC (so, use IBM PS/2 Type 1). */ { "[8088] Xi8088", "xi8088", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2, 64, 1024, 128, 127, machine_xt_xi8088_init, xi8088_get_device }, + { "[8088] Z-NIX PC-1600", "znic", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 64, 640, 64, 0, machine_xt_znic_init, NULL }, { "[8088] Zenith Data Systems Z-151/152/161","zdsz151", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 640, 64, 0, machine_xt_z151_init, NULL }, { "[8088] Zenith Data Systems Z-159", "zdsz159", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 640, 64, 0, machine_xt_z159_init, NULL }, { "[8088] Zenith Data Systems SupersPort (Z-184)","zdsupers", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_xt_z184_init, z184_get_device }, { "[GC100A] Philips P3120", "p3120", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_XTA, 256, 768, 256, 0, machine_xt_p3120_init, NULL }, - + /* 8086 Machines */ { "[8086] Amstrad PC1512", "pc1512", MACHINE_TYPE_8086, CPU_PKG_8086, 0, 8000000, 8000000, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO_FIXED | MACHINE_MOUSE, 512, 640, 128, 63, machine_pc1512_init, pc1512_get_device }, { "[8086] Amstrad PC1640", "pc1640", MACHINE_TYPE_8086, CPU_PKG_8086, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO | MACHINE_MOUSE, 640, 640, 640, 63, machine_pc1640_init, pc1640_get_device }, @@ -154,7 +155,7 @@ const machine_t machines[] = { { "[8086] Tandy 1000 SL/2", "tandy1000sl2", MACHINE_TYPE_8086, CPU_PKG_8086, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO_FIXED, 512, 768, 128, 0, machine_tandy1000sl2_init, tandy1k_sl_get_device }, { "[8086] Victor V86P", "v86p", MACHINE_TYPE_8086, CPU_PKG_8086, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO, 512, 1024, 128, 127, machine_v86p_init, NULL }, { "[8086] Toshiba T1200", "t1200", MACHINE_TYPE_8086, CPU_PKG_8086, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO, 1024, 2048,1024, 63, machine_xt_t1200_init, t1200_get_device }, - + #if defined(DEV_BRANCH) && defined(USE_LASERXT) { "[8086] VTech Laser XT3", "lxt3", MACHINE_TYPE_8086, CPU_PKG_8086, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 256, 640, 256, 0, machine_xt_lxt3_init, NULL }, #endif @@ -223,7 +224,7 @@ const machine_t machines[] = { { "[SCAT] Samsung SPC-4620P", "spc4620p", MACHINE_TYPE_286, CPU_PKG_286, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_VIDEO, 1024, 5120,1024, 127, machine_at_spc4620p_init, NULL }, /* Has IBM AT KBC firmware. */ { "[SCAT] Samsung Deskmaster 286", "deskmaster286", MACHINE_TYPE_286, CPU_PKG_286, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 512, 16384, 128, 127, machine_at_deskmaster286_init, NULL }, - + /* 286 machines that utilize the MCA bus */ /* Has IBM PS/2 Type 2 KBC firmware. */ { "[MCA] IBM PS/2 model 50", "ibmps2_m50", MACHINE_TYPE_286, CPU_PKG_286 | CPU_PKG_486SLC_IBM, 0, 10000000, 0, 0, 0, 0, 0, MACHINE_MCA | MACHINE_BUS_PS2 | MACHINE_VIDEO, 1024, 10240,1024, 63, machine_ps2_model_50_init, NULL }, @@ -562,7 +563,7 @@ const machine_t machines[] = { PS/2 "Load Security" meaning), most likely MegaKey as it sends command AF (Set Extended Controller RAM) just like the later Intel AMI BIOS'es. */ { "[OPTi 597] TMC PAT54PV", "pat54pv", MACHINE_TYPE_SOCKET5, CPU_PKG_SOCKET5_7, CPU_BLOCK(CPU_K5, CPU_5K86), 50000000, 66666667, 3520, 3520, 1.5, 1.5, MACHINE_VLB, 2048, 65536, 2048, 127, machine_at_pat54pv_init, NULL }, - + /* OPTi 596/597/822 */ { "[OPTi 597] Shuttle HOT-543", "hot543", MACHINE_TYPE_SOCKET5, CPU_PKG_SOCKET5_7, 0, 50000000, 66666667, 3520, 3520, 1.5, 2.0, MACHINE_PCI | MACHINE_VLB, 8192, 131072, 8192, 127, machine_at_hot543_init, NULL }, @@ -827,7 +828,7 @@ const machine_t machines[] = { /* Has a Winbond W83977TF Super I/O chip with on-chip KBC with AMIKey-2 KBC firmware. */ { "[i440BX] Supermicro P6SBA", "p6sba", MACHINE_TYPE_SLOT1, CPU_PKG_SLOT1, 0, 66666667, 100000000, 1800, 3500, 1.5, 8.0, MACHINE_AGP | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8192, 786432, 8192, 255, machine_at_p6sba_init, NULL }, - + /* 440ZX */ /* Has a Winbond W83977EF Super I/O chip with on-chip KBC with AMIKey-2 KBC firmware. */ diff --git a/src/mca.c b/src/mca.c index f067d7cdc..5a9b355f8 100644 --- a/src/mca.c +++ b/src/mca.c @@ -26,7 +26,7 @@ void mca_init(int nr_cards) mca_card_reset[c] = NULL; mca_priv[c] = NULL; } - + mca_index = 0; mca_nr_cards = nr_cards; } diff --git a/src/mem/CMakeLists.txt b/src/mem/CMakeLists.txt index 4e9e7917d..9eae342fd 100644 --- a/src/mem/CMakeLists.txt +++ b/src/mem/CMakeLists.txt @@ -14,4 +14,4 @@ # add_library(mem OBJECT catalyst_flash.c i2c_eeprom.c intel_flash.c mem.c rom.c - smram.c spd.c sst_flash.c) \ No newline at end of file + smram.c spd.c sst_flash.c) diff --git a/src/mem/intel_flash.c b/src/mem/intel_flash.c index bc896631a..42da74e71 100644 --- a/src/mem/intel_flash.c +++ b/src/mem/intel_flash.c @@ -138,7 +138,7 @@ flash_readw(uint32_t addr, void *p) case CMD_IID: if (addr & 2) ret = dev->flash_id; - else + else ret = 0x0089; break; @@ -314,7 +314,7 @@ intel_flash_add_mappings(flash_t *dev) else base = 0xe0000 + (i << 16); - fbase = base & biosmask; + fbase = base & biosmask; if (dev->flags & FLAG_INV_A16) fbase ^= 0x10000; @@ -508,7 +508,7 @@ intel_flash_init(const device_t *info) dev->block_start[BLOCK_BOOT] = 0x1e000; /* BOOT BLOCK */ dev->block_end[BLOCK_BOOT] = 0x1ffff; } - break; + break; } intel_flash_add_mappings(dev); diff --git a/src/mem/mem.c b/src/mem/mem.c index ae6c9a0fc..fbc7d8f08 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -427,7 +427,7 @@ uint64_t mmutranslatereal(uint32_t addr, int rw) { /* Fast path to return invalid without any call if an exception has occurred beforehand. */ - if (cpu_state.abrt) + if (cpu_state.abrt) return 0xffffffffffffffffULL; if (cr4 & CR4_PAE) @@ -442,7 +442,7 @@ uint32_t mmutranslatereal32(uint32_t addr, int rw) { /* Fast path to return invalid without any call if an exception has occurred beforehand. */ - if (cpu_state.abrt) + if (cpu_state.abrt) return (uint32_t) 0xffffffffffffffffULL; return (uint32_t) mmutranslatereal(addr, rw); @@ -455,7 +455,7 @@ mmutranslate_noabrt_normal(uint32_t addr, int rw) uint32_t temp,temp2,temp3; uint32_t addr2; - if (cpu_state.abrt) + if (cpu_state.abrt) return 0xffffffffffffffffULL; addr2 = ((cr3 & ~0xfff) + ((addr >> 20) & 0xffc)); @@ -488,7 +488,7 @@ mmutranslate_noabrt_pae(uint32_t addr, int rw) uint64_t temp,temp2,temp3,temp4; uint64_t addr2,addr3,addr4; - if (cpu_state.abrt) + if (cpu_state.abrt) return 0xffffffffffffffffULL; addr2 = (cr3 & ~0x1f) + ((addr >> 27) & 0x18); @@ -527,7 +527,7 @@ uint64_t mmutranslate_noabrt(uint32_t addr, int rw) { /* Fast path to return invalid without any call if an exception has occurred beforehand. */ - if (cpu_state.abrt) + if (cpu_state.abrt) return 0xffffffffffffffffULL; if (cr4 & CR4_PAE) @@ -675,7 +675,7 @@ getpccache(uint32_t a) else cpu_prefetch_cycles = cpu_mem_prefetch_cycles; } - + return &_mem_exec[a64 >> MEM_GRANULARITY_BITS][(uintptr_t)(a64 & MEM_GRANULARITY_PAGE) - (uintptr_t)(a2 & ~0xfff)]; } @@ -2076,7 +2076,7 @@ mem_write_ram(uint32_t addr, uint8_t val, void *priv) if ((addr >= 0xa0000) && (addr <= 0xbffff)) mem_log("Write B %02X to %08X\n", val, addr); #endif - if (is286) { + if (is286) { addwritelookup(mem_logical_addr, addr); mem_write_ramb_page(addr, val, &pages[addr >> 12]); } else @@ -2192,7 +2192,7 @@ mem_invalidate_range(uint32_t start_addr, uint32_t end_addr) page_t *p; start_addr &= ~PAGE_MASK_MASK; - end_addr = (end_addr + PAGE_MASK_MASK) & ~PAGE_MASK_MASK; + end_addr = (end_addr + PAGE_MASK_MASK) & ~PAGE_MASK_MASK; for (; start_addr <= end_addr; start_addr += 0x1000) { if ((start_addr >> 12) >= pages_sz) @@ -2212,7 +2212,7 @@ mem_invalidate_range(uint32_t start_addr, uint32_t end_addr) #else uint32_t cur_addr; start_addr &= ~PAGE_MASK_MASK; - end_addr = (end_addr + PAGE_MASK_MASK) & ~PAGE_MASK_MASK; + end_addr = (end_addr + PAGE_MASK_MASK) & ~PAGE_MASK_MASK; for (; start_addr <= end_addr; start_addr += 0x1000) { /* Do nothing if the pages array is empty or DMA reads/writes to/from PCI device memory addresses @@ -2323,8 +2323,8 @@ mem_mapping_recalc(uint64_t base, uint64_t size) void mem_mapping_set(mem_mapping_t *map, - uint32_t base, - uint32_t size, + uint32_t base, + uint32_t size, uint8_t (*read_b)(uint32_t addr, void *p), uint16_t (*read_w)(uint32_t addr, void *p), uint32_t (*read_l)(uint32_t addr, void *p), @@ -2361,8 +2361,8 @@ mem_mapping_set(mem_mapping_t *map, void mem_mapping_add(mem_mapping_t *map, - uint32_t base, - uint32_t size, + uint32_t base, + uint32_t size, uint8_t (*read_b)(uint32_t addr, void *p), uint16_t (*read_w)(uint32_t addr, void *p), uint32_t (*read_l)(uint32_t addr, void *p), @@ -2811,7 +2811,7 @@ mem_remap_top(int kb) set = 0; } else old_kb = kb; - + if (size > kb) size = kb; diff --git a/src/mem/rom.c b/src/mem/rom.c index 8fbd7ff97..30e873a4e 100644 --- a/src/mem/rom.c +++ b/src/mem/rom.c @@ -71,7 +71,7 @@ rom_fopen(char *fn, char *mode) if (rom_path[0] != '\0') { memset(fn2, 0x00, strlen(fn) + 1); - memcpy(fn2, &(fn[5]), strlen(fn) - 4); + memcpy(fn2, &(fn[5]), strlen(fn) - 4); plat_append_filename(temp, rom_path, fn2); } else { @@ -185,7 +185,7 @@ rom_load_linear_oddeven(char *fn, uint32_t addr, int sz, int off, uint8_t *ptr) { FILE *f = rom_fopen(fn, "rb"); int i; - + if (f == NULL) { rom_log("ROM: image '%s' not found\n", fn); return(0); @@ -221,7 +221,7 @@ int rom_load_linear(char *fn, uint32_t addr, int sz, int off, uint8_t *ptr) { FILE *f = rom_fopen(fn, "rb"); - + if (f == NULL) { rom_log("ROM: image '%s' not found\n", fn); return(0); @@ -251,7 +251,7 @@ int rom_load_linear_inverted(char *fn, uint32_t addr, int sz, int off, uint8_t *ptr) { FILE *f = rom_fopen(fn, "rb"); - + if (f == NULL) { rom_log("ROM: image '%s' not found\n", fn); return(0); diff --git a/src/mem/smram.c b/src/mem/smram.c index 8b1f9fd40..9333264d9 100644 --- a/src/mem/smram.c +++ b/src/mem/smram.c @@ -259,7 +259,7 @@ smram_add(void) if (temp_smram == NULL) { fatal("smram_add(): temp_smram malloc failed\n"); return NULL; - } + } memset(temp_smram, 0x00, sizeof(smram_t)); memset(&(temp_smram->mapping), 0x00, sizeof(mem_mapping_t)); diff --git a/src/mem/spd.c b/src/mem/spd.c index 7c033fe8c..f65d72ae7 100644 --- a/src/mem/spd.c +++ b/src/mem/spd.c @@ -213,7 +213,7 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) rows[slot] = 0; if (slot_mask & (1 << slot)) slot_count++; - } + } /* Populate rows. */ spd_populate(rows, slot_count, (mem_size >> 10), min_module_size, max_module_size, 1); diff --git a/src/mem/sst_flash.c b/src/mem/sst_flash.c index bcc3c3aa9..8988b7e14 100644 --- a/src/mem/sst_flash.c +++ b/src/mem/sst_flash.c @@ -44,7 +44,7 @@ typedef struct sst_t uint32_t size, mask, page_mask, page_base, last_addr; - + uint8_t page_buffer[128], page_dirty[128]; uint8_t *array; @@ -304,7 +304,7 @@ sst_write(uint32_t addr, uint8_t val, void *p) } else { dev->command_state++; sst_buf_write(dev, addr, val); - } + } break; case 7: if (!dev->is_39) @@ -390,7 +390,7 @@ sst_add_mappings(sst_t *dev) for (i = 0; i < count; i++) { base = root_base + (i << 16); - fbase = base & biosmask; + fbase = base & biosmask; memcpy(&dev->array[fbase], &rom[base & biosmask], 0x10000); diff --git a/src/minitrace/minitrace.c b/src/minitrace/minitrace.c index 32d2ebcae..89f12d6a8 100644 --- a/src/minitrace/minitrace.c +++ b/src/minitrace/minitrace.c @@ -314,7 +314,7 @@ void mtr_stop() { // TODO: fwrite more than one line at a time. // Flushing is thread safe and process async // using double-buffering mechanism. -// Aware: only one flushing process may be +// Aware: only one flushing process may be // running at any point of time void mtr_flush_with_state(int is_last) { #ifndef MTR_ENABLED @@ -562,4 +562,3 @@ void internal_mtr_raw_event_arg(const char *category, const char *name, char ph, --events_in_progress; pthread_mutex_unlock(&event_mutex); } - diff --git a/src/network/net_3c503.c b/src/network/net_3c503.c index a79699b31..acbc1ec04 100644 --- a/src/network/net_3c503.c +++ b/src/network/net_3c503.c @@ -129,7 +129,7 @@ threec503_interrupt(void *priv, int set) case 5: dev->regs.idcfr = 0x80; break; - } + } if (set) picint(1 << dev->base_irq); @@ -177,7 +177,7 @@ threec503_set_drq(threec503_t *dev) case 3: dev->regs.idcfr = 4; break; - } + } } @@ -195,7 +195,7 @@ threec503_reset(void *priv) memset(&dev->regs, 0, sizeof(dev->regs)); - dev->regs.ctrl = 0x0a; + dev->regs.ctrl = 0x0a; } @@ -399,7 +399,7 @@ threec503_nic_hi_read(uint16_t addr, void *priv) if (!(dev->regs.ctrl & 0x80)) return 0xff; - threec503_set_drq(dev); + threec503_set_drq(dev); return dp8390_chipmem_read(dev->dp8390, dev->regs.da++, 1); } @@ -529,7 +529,7 @@ threec503_nic_hi_write(uint16_t addr, uint8_t val, void *priv) if (!(dev->regs.ctrl & 0x80)) return; - threec503_set_drq(dev); + threec503_set_drq(dev); dp8390_chipmem_write(dev->dp8390, dev->regs.da++, val, 1); break; @@ -542,7 +542,7 @@ threec503_nic_ioset(threec503_t *dev, uint16_t addr) { io_sethandler(addr, 0x10, threec503_nic_lo_read, NULL, NULL, - threec503_nic_lo_write, NULL, NULL, dev); + threec503_nic_lo_write, NULL, NULL, dev); io_sethandler(addr+0x400, 0x10, threec503_nic_hi_read, NULL, NULL, @@ -575,7 +575,7 @@ threec503_nic_init(const device_t *info) * PnP and PCI devices start with address spaces inactive. */ threec503_nic_ioset(dev, dev->base_address); - + /* Set up our BIA. */ if (mac & 0xff000000) { /* Generate new local MAC. */ @@ -597,7 +597,7 @@ threec503_nic_init(const device_t *info) dev->dp8390->interrupt = threec503_interrupt; dp8390_set_defaults(dev->dp8390, DP8390_FLAG_CHECK_CR | DP8390_FLAG_CLEAR_IRQ); dp8390_mem_alloc(dev->dp8390, 0x2000, 0x2000); - + memcpy(dev->dp8390->physaddr, dev->maclocal, sizeof(dev->maclocal)); threec503_log("I/O=%04x, IRQ=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", diff --git a/src/network/net_dp8390.c b/src/network/net_dp8390.c index d3d4aa46c..28b6fd4bd 100644 --- a/src/network/net_dp8390.c +++ b/src/network/net_dp8390.c @@ -224,7 +224,7 @@ dp8390_write_cr(dp8390_t *dev, uint32_t val) /* Send the packet to the system driver */ dev->CR.tx_packet = 1; - + network_tx(&dev->mem[(dev->tx_page_start * 256) - dev->mem_start], dev->tx_bytes); /* some more debug */ @@ -835,7 +835,7 @@ dp8390_page2_read(dp8390_t *dev, uint32_t off, unsigned int len) { dp8390_log("DP8390: Page2 read from register 0x%02x, len=%u\n", off, len); - + switch(off) { case 0x01: /* PSTART */ return(dev->page_start); diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index 6878e4f94..1f75d21fc 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -84,7 +84,7 @@ static uint8_t rtl8019as_pnp_rom[] = { 0x4a, 0x8c, 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, /* RTL8019, dummy checksum (filled in by isapnp_add_card) */ 0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */ 0x82, 0x22, 0x00, 'R', 'E', 'A', 'L', 'T', 'E', 'K', ' ', 'P', 'L', 'U', 'G', ' ', '&', ' ', 'P', 'L', 'A', 'Y', ' ', 'E', 'T', 'H', 'E', 'R', 'N', 'E', 'T', ' ', 'C', 'A', 'R', 'D', 0x00, /* ANSI identifier */ - + 0x16, 0x4a, 0x8c, 0x80, 0x19, 0x02, 0x00, /* logical device RTL8019 */ 0x1c, 0x41, 0xd0, 0x80, 0xd6, /* compatible device PNP80D6 */ 0x47, 0x00, 0x20, 0x02, 0x80, 0x03, 0x20, 0x20, /* I/O 0x220-0x380, decodes 10-bit, 32-byte alignment, 32 addresses */ @@ -303,8 +303,8 @@ asic_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) case 0x0f: /* Reset register */ /* end of reset pulse */ - break; - + break; + default: /* this is invalid, but happens under win95 device detection */ nelog(3, "%s: ASIC write invalid address %04x, ignoring\n", dev->name, (unsigned)off); @@ -316,7 +316,7 @@ asic_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) /* Writes to this page are illegal. */ static uint32_t page3_read(nic_t *dev, uint32_t off, unsigned int len) -{ +{ if (dev->board >= NE2K_RTL8019AS) switch(off) { case 0x1: /* 9346CR */ return(dev->_9346cr); @@ -573,7 +573,7 @@ nic_pnp_write_vendor_reg(uint8_t ld, uint8_t reg, uint8_t val, void *priv) static void nic_ioset(nic_t *dev, uint16_t addr) -{ +{ if (dev->is_pci) { io_sethandler(addr, 32, nic_readb, nic_readw, nic_readl, @@ -623,14 +623,14 @@ static void nic_update_bios(nic_t *dev) { int reg_bios_enable; - + reg_bios_enable = 1; if (! dev->has_bios) return; if (dev->is_pci) reg_bios_enable = dev->pci_bar[1].addr_regs[0] & 0x01; - + /* PCI BIOS stuff, just enable_disable. */ if (reg_bios_enable) { mem_mapping_set_addr(&dev->bios_rom.mapping, @@ -871,7 +871,7 @@ nic_mca_write(int port, uint8_t val, void *priv) /* Save the MCA register value. */ dev->pos_regs[port & 7] = val; - nic_ioremove(dev, dev->base_address); + nic_ioremove(dev, dev->base_address); /* This is always necessary so that the old handler doesn't remain. */ /* Get the new assigned I/O base address. */ @@ -894,13 +894,13 @@ nic_mca_write(int port, uint8_t val, void *priv) /* Initialize the device if fully configured. */ if (dev->pos_regs[2] & 0x01) { /* Card enabled; register (new) I/O handler. */ - + nic_ioset(dev, dev->base_address); - + nic_reset(dev); - + nelog(2, "EtherNext/MC: Port=%04x, IRQ=%d\n", dev->base_address, dev->base_irq); - + } } @@ -947,10 +947,10 @@ nic_init(const device_t *info) } else { dev->bios_addr = 0x00000; dev->has_bios = 0; - } + } } else { - mca_add(nic_mca_read, nic_mca_write, nic_mca_feedb, NULL, dev); + mca_add(nic_mca_read, nic_mca_write, nic_mca_feedb, NULL, dev); } } @@ -997,7 +997,7 @@ nic_init(const device_t *info) DP8390_FLAG_CLEAR_IRQ); dp8390_mem_alloc(dev->dp8390, 0x4000, 0x4000); break; - + case NE2K_ETHERNEXT_MC: dev->maclocal[0] = 0x00; /* 00:00:D8 (Networth Inc. OID) */ dev->maclocal[1] = 0x00; diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index 7008d1442..52573907b 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -58,8 +58,8 @@ #include <86box/network.h> -typedef int bpf_int32; -typedef unsigned int bpf_u_int32; +typedef int bpf_int32; +typedef unsigned int bpf_u_int32; /* * The instruction data structure. @@ -79,7 +79,7 @@ struct bpf_program { struct bpf_insn *bf_insns; }; -typedef struct pcap_if pcap_if_t; +typedef struct pcap_if pcap_if_t; typedef struct net_timeval { long tv_sec; @@ -95,11 +95,11 @@ struct pcap_pkthdr { }; struct pcap_if { - struct pcap_if *next; - char *name; - char *description; - void *addresses; - unsigned int flags; + struct pcap_if *next; + char *name; + char *description; + void *addresses; + unsigned int flags; }; @@ -180,11 +180,10 @@ poll_thread(void *arg) /* Request ownership of the device. */ network_wait(1); - /* Wait for a poll request. */ - network_poll(); - - if (pcap == NULL) + if (pcap == NULL) { + network_wait(0); break; + } if (network_get_wait() || (poll_card->set_link_state && poll_card->set_link_state(poll_card->priv)) || (poll_card->wait && poll_card->wait(poll_card->priv))) data = NULL; @@ -207,18 +206,15 @@ poll_thread(void *arg) } } - /* Wait for the next packet to arrive. */ + /* Wait for the next packet to arrive - network_do_tx() is called from there. */ tx = network_tx_queue_check(); - if (tx) - network_do_tx(); + /* Release ownership of the device. */ + network_wait(0); /* If we did not get anything, wait a while. */ if (!tx) thread_wait_event(evt, 10); - - /* Release ownership of the device. */ - network_wait(0); } /* No longer needed. */ @@ -342,8 +338,6 @@ net_pcap_close(void) /* Tell the thread to terminate. */ if (poll_tid != NULL) { - network_busy(0); - /* Wait for the thread to finish. */ pcap_log("PCAP: waiting for thread to end...\n"); thread_wait_event(poll_state, -1); diff --git a/src/network/net_pcnet.c b/src/network/net_pcnet.c index 441c50f67..6eee3d508 100644 --- a/src/network/net_pcnet.c +++ b/src/network/net_pcnet.c @@ -211,7 +211,7 @@ typedef struct { int board; int is_pci, is_vlb, is_isa; int PCIBase; - int MMIOBase; + int MMIOBase; uint32_t base_address; int base_irq; int dma_channel; @@ -426,7 +426,7 @@ pcnet_do_irq(nic_t *dev, int issue) picint(1<base_irq); else picintc(1<base_irq); - } + } } /** @@ -582,7 +582,7 @@ pcnetRmdLoad(nic_t *dev, RMD *rmd, uint32_t addr, int fRetIfNotOwn) /* Double check the own bit; guest drivers might be buggy and lock prefixes in the recompiler are ignored by other threads. */ if (rmd->rmd1.own == 1 && !(ownbyte & 0x80)) pcnetlog(3, "%s: pcnetRmdLoad: own bit flipped while reading!!\n", dev->name); - + if (!(ownbyte & 0x80)) rmd->rmd1.own = 0; @@ -660,7 +660,7 @@ struct ether_header /** @todo Use RTNETETHERHDR */ #define MULTICAST_FILTER_LEN 8 -static __inline uint32_t +static __inline uint32_t lnc_mchash(const uint8_t *ether_addr) { #define LNC_POLYNOMIAL 0xEDB88320UL @@ -774,7 +774,7 @@ padr_match(nic_t *dev, const uint8_t *buf, int size) hdr->ether_dhost[0],hdr->ether_dhost[1],hdr->ether_dhost[2], hdr->ether_dhost[3],hdr->ether_dhost[4],hdr->ether_dhost[5], padr[0],padr[1],padr[2],padr[3],padr[4],padr[5], result); - + return result; } @@ -790,7 +790,7 @@ padr_bcast(nic_t *dev, const uint8_t *buf, size_t size) } -static int +static int ladr_match(nic_t *dev, const uint8_t *buf, size_t size) { struct ether_header *hdr = (struct ether_header *)buf; @@ -815,7 +815,7 @@ ladr_match(nic_t *dev, const uint8_t *buf, size_t size) /** * Get the receive descriptor ring address with a given index. */ -static __inline uint32_t +static __inline uint32_t pcnetRdraAddr(nic_t *dev, int idx) { return dev->GCRDRA + ((CSR_RCVRL(dev) - idx) << dev->iLog2DescSize); @@ -825,23 +825,23 @@ pcnetRdraAddr(nic_t *dev, int idx) /** * Get the transmit descriptor ring address with a given index. */ -static __inline uint32_t +static __inline uint32_t pcnetTdraAddr(nic_t *dev, int idx) { return dev->GCTDRA + ((CSR_XMTRL(dev) - idx) << dev->iLog2DescSize); } -static void +static void pcnetSoftReset(nic_t *dev) { pcnetlog(3, "%s: pcnetSoftReset\n", dev->name); - + dev->u32Lnkst = 0x40; dev->GCRDRA = 0; dev->GCTDRA = 0; dev->u32RAP = 0; - + dev->aCSR[0] = 0x0004; dev->aCSR[3] = 0x0000; dev->aCSR[4] = 0x0115; @@ -893,10 +893,10 @@ static void pcnetUpdateIrq(nic_t *dev) { int iISR = 0; - uint16_t csr0; + uint16_t csr0; csr0 = dev->aCSR[0]; - + csr0 &= ~0x0080; /* clear INTR */ if (((csr0 & ~dev->aCSR[3]) & 0x5f00) || @@ -905,7 +905,7 @@ pcnetUpdateIrq(nic_t *dev) iISR = !!(csr0 & 0x0040); /* CSR_INEA */ csr0 |= 0x0080; /* set INTR */ } - + if (dev->aCSR[4] & 0x0080) { /* UINTCMD */ dev->aCSR[4] &= ~0x0080; /* clear UINTCMD */ dev->aCSR[4] |= 0x0040; /* set UINT */ @@ -916,25 +916,25 @@ pcnetUpdateIrq(nic_t *dev) csr0 |= 0x0080; /* set INTR */ iISR = 1; } - + if (((dev->aCSR[5]>>1) & dev->aCSR[5]) & 0x0500) { iISR = 1; csr0 |= 0x0080; /* set INTR */ } - + if ((dev->aCSR[7] & 0x0c00) == 0x0c00) /* STINT + STINTE */ iISR = 1; - + dev->aCSR[0] = csr0; - + pcnetlog(2, "%s: pcnetUpdateIrq: iISR=%d\n", dev->name, iISR); - + pcnet_do_irq(dev, iISR); dev->iISR = iISR; } -static void +static void pcnetInit(nic_t *dev) { int i; @@ -1023,7 +1023,7 @@ pcnetInit(nic_t *dev) /** * Start RX/TX operation. */ -static void +static void pcnetStart(nic_t *dev) { pcnetlog(3, "%s: pcnetStart: Poll timer\n", dev->name); @@ -1037,7 +1037,7 @@ pcnetStart(nic_t *dev) if (!CSR_DRX(dev)) dev->aCSR[0] |= 0x0020; /* set RXON */ dev->aCSR[0] &= ~0x0004; /* clear STOP bit */ - dev->aCSR[0] |= 0x0002; /* STRT */ + dev->aCSR[0] |= 0x0002; /* STRT */ pcnetPollTimer(dev); } @@ -1045,7 +1045,7 @@ pcnetStart(nic_t *dev) /** * Stop RX/TX operation. */ -static void +static void pcnetStop(nic_t *dev) { pcnetlog(3, "%s: pcnetStop: Poll timer\n", dev->name); @@ -1062,7 +1062,7 @@ pcnetStop(nic_t *dev) * by the host (the guest driver) anymore. Well, it could but the results are undefined by * definition. */ -static void +static void pcnetRdtePoll(nic_t *dev) { /* assume lack of a next receive descriptor */ @@ -1140,7 +1140,7 @@ pcnetRdtePoll(nic_t *dev) * Poll Transmit Descriptor Table Entry * @return true if transmit descriptors available */ -static int +static int pcnetTdtePoll(nic_t *dev, TMD *tmd) { if (dev->GCTDRA) { @@ -1178,7 +1178,7 @@ pcnetTdtePoll(nic_t *dev, TMD *tmd) * Poll Transmit Descriptor Table Entry * @return true if transmit descriptors available */ -static int +static int pcnetCalcPacketLen(nic_t *dev, int cb) { TMD tmd; @@ -1244,7 +1244,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) buf = buf1; size = 60; } - + /* * Drop packets if the cable is not connected */ @@ -1269,7 +1269,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) if (HOST_IS_OWNER(CSR_CRST(dev))) { /* Not owned by controller. This should not be possible as - * we already called pcnetCanReceive(). */ + * we already called pcnetCanReceive(). */ const unsigned cb = 1 << dev->iLog2DescSize; uint32_t GCPhys = dev->GCRDRA; iRxDesc = CSR_RCVRL(dev); @@ -1290,7 +1290,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) uint32_t crda = CSR_CRDA(dev); uint32_t next_crda; RMD rmd, next_rmd; - + /* * Ethernet framing considers these two octets to be * payload type; 802.3 framing considers them to be @@ -1304,7 +1304,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) if (len_802_3 < 46 && CSR_ASTRP_RCV(dev)) { size = MIN(sizeof(RTNETETHERHDR) + len_802_3, size); fStrip = 1; - } + } memcpy(src, buf, size); @@ -1315,7 +1315,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) if (!CSR_LOOP(dev)) while (size < 60) src[size++] = 0; - + uint32_t fcs = UINT32_MAX; uint8_t *p = src; @@ -1327,7 +1327,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) size += 4; } - cbPacket = (int)size; + cbPacket = (int)size; pcnetRmdLoad(dev, &rmd, PHYSADDR(dev, crda), 0); /* if (!CSR_LAPPEN(dev)) */ @@ -1351,7 +1351,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) */ dma_bm_write(rbadr, src, cbBuf, dev->transfer_size); - + /* RX disabled in the meantime? If so, abort RX. */ if (CSR_DRX(dev) || CSR_STOP(dev) || CSR_SPND(dev)) { pcnetlog(3, "%s: RX disabled 1\n", dev->name); @@ -1435,7 +1435,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size) dev->aCSR[0] |= 0x0400; pcnetlog(1, "%s: RINT set, RCVRC=%d CRDA=%#010x\n", dev->name, CSR_RCVRC(dev), PHYSADDR(dev, CSR_CRDA(dev))); - + /* guest driver is owner: force repoll of current and next RDTEs */ CSR_CRST(dev) = 0; } @@ -1474,7 +1474,7 @@ pcnetXmitFailTMDGeneric(nic_t *dev, TMD *pTmd) * * @threads TX or EMT. */ -static void +static void pcnetAsyncTransmit(nic_t *dev) { /* @@ -1502,7 +1502,7 @@ pcnetAsyncTransmit(nic_t *dev) break; pcnetlog(3, "%s: TMDLOAD %#010x\n", dev->name, PHYSADDR(dev, CSR_CXDA(dev))); - + int fLoopback = CSR_LOOP(dev); /* @@ -1510,10 +1510,10 @@ pcnetAsyncTransmit(nic_t *dev) */ if (tmd.tmd1.stp && tmd.tmd1.enp) { const int cb = 4096 - tmd.tmd1.bcnt; - pcnetlog("%s: pcnetAsyncTransmit: stp&enp: cb=%d xmtrc=%#x\n", dev->name, cb, CSR_XMTRC(dev)); + pcnetlog("%s: pcnetAsyncTransmit: stp&enp: cb=%d xmtrc=%#x\n", dev->name, cb, CSR_XMTRC(dev)); if ((pcnetIsLinkUp(dev) || fLoopback)) { - + /* From the manual: ``A zero length buffer is acceptable as * long as it is not the last buffer in a chain (STP = 0 and * ENP = 1).'' That means that the first buffer might have a @@ -1526,10 +1526,10 @@ pcnetAsyncTransmit(nic_t *dev) if (HOST_IS_OWNER(CSR_CRST(dev))) pcnetRdtePoll(dev); - pcnetReceiveNoSync(dev, dev->abLoopBuf, dev->xmit_pos); + pcnetReceiveNoSync(dev, dev->abLoopBuf, dev->xmit_pos); } else { pcnetlog(3, "%s: pcnetAsyncTransmit: transmit loopbuf stp and enp, xmit pos = %d\n", dev->name, dev->xmit_pos); - network_tx(dev->abLoopBuf, dev->xmit_pos); + network_tx(dev->abLoopBuf, dev->xmit_pos); } } else if (cb == 4096) { /* The Windows NT4 pcnet driver sometimes marks the first @@ -1537,13 +1537,13 @@ pcnetAsyncTransmit(nic_t *dev) * passing it back). Do not update the ring counter in this * case (otherwise that driver becomes even more confused, * which causes transmit to stall for about 10 seconds). - * This is just a workaround, not a final solution. + * This is just a workaround, not a final solution. */ /* r=frank: IMHO this is the correct implementation. The * manual says: ``If the OWN bit is set and the buffer * length is 0, the OWN bit will be cleared. In the C-LANCE * the buffer length of 0 is interpreted as a 4096-byte - * buffer.'' + * buffer.'' */ /* r=michaln: Perhaps not quite right. The C-LANCE (Am79C90) * datasheet explains that the old LANCE (Am7990) ignored @@ -1637,12 +1637,12 @@ pcnetAsyncTransmit(nic_t *dev) pcnetRdtePoll(dev); pcnetlog(3, "%s: pcnetAsyncTransmit: receive loopback enp\n", dev->name); - pcnetReceiveNoSync(dev, dev->abLoopBuf, dev->xmit_pos); + pcnetReceiveNoSync(dev, dev->abLoopBuf, dev->xmit_pos); } else { pcnetlog(3, "%s: pcnetAsyncTransmit: transmit loopbuf enp\n", dev->name); network_tx(dev->abLoopBuf, dev->xmit_pos); } - + /* Write back the TMD, pass it to the host */ pcnetTmdStorePassHost(dev, &tmd, PHYSADDR(dev, CSR_CXDA(dev))); @@ -1667,20 +1667,20 @@ pcnetAsyncTransmit(nic_t *dev) if (--cMax == 0) break; } while (CSR_TXON(dev)); /* transfer on */ - + if (cFlushIrq) { dev->aCSR[0] |= 0x0200; /* set TINT */ /* Don't allow the guest to clear TINT before reading it */ dev->u16CSR0LastSeenByGuest &= ~0x0200; pcnetUpdateIrq(dev); - } + } } /** * Poll for changes in RX and TX descriptor rings. */ -static void +static void pcnetPollRxTx(nic_t *dev) { if (CSR_RXON(dev)) { @@ -1742,13 +1742,13 @@ pcnetHardReset(nic_t *dev) dev->aBCR[BCR_PCISVID] = 0x1022; /* Reset the error counter. */ - dev->uCntBadRMD = 0; + dev->uCntBadRMD = 0; pcnetSoftReset(dev); } -static void +static void pcnet_csr_writew(nic_t *dev, uint16_t rap, uint16_t val) { pcnetlog(1, "%s: pcnet_csr_writew: rap=%d val=%#06x\n", dev->name, rap, val); @@ -1756,7 +1756,7 @@ pcnet_csr_writew(nic_t *dev, uint16_t rap, uint16_t val) case 0: { uint16_t csr0 = dev->aCSR[0]; - /* Clear any interrupt flags. + /* Clear any interrupt flags. * Don't clear an interrupt flag which was not seen by the guest yet. */ csr0 &= ~(val & 0x7f00 & dev->u16CSR0LastSeenByGuest); csr0 = (csr0 & ~0x0040) | (val & 0x0048); @@ -1839,12 +1839,12 @@ pcnet_csr_writew(nic_t *dev, uint16_t rap, uint16_t val) break; case 4: /* Test and Features Control */ dev->aCSR[4] &= ~(val & 0x026a); - val &= ~0x026a; + val &= ~0x026a; val |= dev->aCSR[4] & 0x026a; break; case 5: /* Extended Control and Interrupt 1 */ dev->aCSR[5] &= ~(val & 0x0a90); - val &= ~0x0a90; + val &= ~0x0a90; val |= dev->aCSR[5] & 0x0a90; break; case 7: /* Extended Control and Interrupt 2 */ @@ -1896,12 +1896,12 @@ pcnet_csr_writew(nic_t *dev, uint16_t rap, uint16_t val) dev->GCTDRA = (dev->GCTDRA & 0xffff0000) | (val & 0x0000ffff); else dev->GCTDRA = (dev->GCTDRA & 0x0000ffff) | ((val & 0x0000ffff) << 16); - + pcnetlog(3, "%s: WRITE CSR%d, %#06x => GCTDRA=%08x (alt init)\n", dev->name, rap, val, dev->GCTDRA); if (dev->GCTDRA & (dev->iLog2DescSize - 1)) pcnetlog(1, "%s: Warning: Misaligned TDRA (GCTDRA=%#010x)\n", dev->name, dev->GCTDRA); - break; + break; case 58: /* Software Style */ pcnet_bcr_writew(dev,BCR_SWS,val); break; @@ -1925,7 +1925,7 @@ pcnet_csr_writew(nic_t *dev, uint16_t rap, uint16_t val) * HACK ALERT! Set the counter registers too. */ dev->aCSR[rap - 4] = val; - break; + break; default: return; } @@ -2030,22 +2030,22 @@ pcnet_bcr_writew(nic_t *dev, uint16_t rap, uint16_t val) if (dev->board == DEV_AM79C973) timer_set_delay_u64(&dev->timer_soft_int, (12.8 * val) * TIMER_USEC); break; - + case BCR_MIIMDR: dev->aMII[dev->aBCR[BCR_MIIADDR] & 0x1f] = val; break; - + default: break; } } -static uint16_t +static uint16_t pcnet_mii_readw(nic_t *dev, uint16_t miiaddr) { uint16_t val; int autoneg, duplex, fast, isolate; - + /* If the DANAS (BCR32.7) bit is set, the MAC does not do any * auto-negotiation and the PHY must be set up explicitly. DANAS * effectively disables most other BCR32 bits. @@ -2059,10 +2059,10 @@ pcnet_mii_readw(nic_t *dev, uint16_t miiaddr) duplex = (dev->aBCR[BCR_MIICAS] & 0x10) != 0; fast = (dev->aBCR[BCR_MIICAS] & 0x08) != 0; } - + /* Electrically isolating the PHY mostly disables it. */ isolate = (dev->aMII[0] & 0x400) != 0; - + switch (miiaddr) { case 0: /* MII basic mode control register. */ @@ -2102,17 +2102,17 @@ pcnet_mii_readw(nic_t *dev, uint16_t miiaddr) val &= ~0x6000; /* 10 Mbps forced */ } break; - + case 2: /* PHY identifier 1. */ val = 0x22; /* Am79C874/AC101 PHY */ break; - + case 3: /* PHY identifier 2. */ val = 0x561b; /* Am79C874/AC101 PHY */ break; - + case 4: /* Advertisement control register. */ val = 0x01e0 /* Try 100mbps FD/HD and 10mbps FD/HD. */ @@ -2144,13 +2144,13 @@ pcnet_mii_readw(nic_t *dev, uint16_t miiaddr) dev->cLinkDownReported++; } break; - + case 18: /* Diagnostic Register (FreeBSD pcn/ac101 driver reads this). */ if (dev->fLinkUp && !dev->fLinkTempDown && !isolate) { val = 0x1000 /* Receive PLL locked. */ | 0x0200; /* Signal detected. */ - + if (autoneg) { val |= 0x0400 /* 100Mbps rate. */ | 0x0800; /* Full duplex. */ @@ -2165,16 +2165,16 @@ pcnet_mii_readw(nic_t *dev, uint16_t miiaddr) dev->cLinkDownReported++; } break; - + default: val = 0; break; } - + return val; } -static uint16_t +static uint16_t pcnet_bcr_readw(nic_t *dev, uint16_t rap) { uint16_t val; @@ -2192,7 +2192,7 @@ pcnet_bcr_readw(nic_t *dev, uint16_t rap) } val |= (val & 0x017f & dev->u32Lnkst) ? 0x8000 : 0; break; - + case BCR_MIIMDR: if ((dev->board == DEV_AM79C973) && (((dev->aBCR[BCR_MIIADDR] >> 5) & 0x1f) == 0)) { uint16_t miiaddr = dev->aBCR[BCR_MIIADDR] & 0x1f; @@ -2263,7 +2263,7 @@ pcnet_byte_read(nic_t *dev, uint32_t addr) static uint16_t pcnet_word_read(nic_t *dev, uint32_t addr) -{ +{ uint16_t val = 0xffff; if (!BCR_DWIO(dev)) { @@ -2273,7 +2273,7 @@ pcnet_word_read(nic_t *dev, uint32_t addr) /** Polling is then useless here and possibly expensive. */ if (!CSR_DPOLL(dev)) pcnetPollTimer(dev); - + val = pcnet_csr_readw(dev, dev->u32RAP); if (dev->u32RAP == 0) goto skip_update_irq; @@ -2300,7 +2300,7 @@ skip_update_irq: } -static void +static void pcnet_dword_write(nic_t *dev, uint32_t addr, uint32_t val) { if (BCR_DWIO(dev)) { @@ -2327,7 +2327,7 @@ pcnet_dword_write(nic_t *dev, uint32_t addr, uint32_t val) static uint32_t pcnet_dword_read(nic_t *dev, uint32_t addr) -{ +{ uint32_t val = 0xffffffff; if (BCR_DWIO(dev)) { @@ -2360,7 +2360,7 @@ skip_update_irq: } -static void +static void pcnet_aprom_writeb(nic_t *dev, uint32_t addr, uint32_t val) { /* Check APROMWE bit to enable write access */ @@ -2369,7 +2369,7 @@ pcnet_aprom_writeb(nic_t *dev, uint32_t addr, uint32_t val) } -static uint32_t +static uint32_t pcnet_aprom_readb(nic_t *dev, uint32_t addr) { uint32_t val = dev->aPROM[addr & 15]; @@ -2547,7 +2547,7 @@ pcnet_mem_disable(nic_t *dev) static void pcnet_ioremove(nic_t *dev, uint16_t addr, int len) -{ +{ if (dev->is_pci || dev->is_vlb) { io_removehandler(addr, len, pcnet_readb, pcnet_readw, pcnet_readl, @@ -2562,7 +2562,7 @@ pcnet_ioremove(nic_t *dev, uint16_t addr, int len) static void pcnet_ioset(nic_t *dev, uint16_t addr, int len) -{ +{ pcnet_ioremove(dev, addr, len); if (dev->is_pci || dev->is_vlb) { @@ -2572,7 +2572,7 @@ pcnet_ioset(nic_t *dev, uint16_t addr, int len) } else { io_sethandler(addr, len, pcnet_readb, pcnet_readw, NULL, - pcnet_writeb, pcnet_writew, NULL, dev); + pcnet_writeb, pcnet_writew, NULL, dev); } } @@ -2643,10 +2643,10 @@ pcnet_pci_write(int func, int addr, uint8_t val, void *p) if (dev->MMIOBase != 0) pcnet_mem_set_addr(dev, dev->MMIOBase); } - return; + return; case 0x3C: - dev->base_irq = val; + dev->base_irq = val; pcnet_pci_regs[addr] = val; return; } @@ -2796,7 +2796,7 @@ pcnet_pnp_write_vendor_reg(uint8_t ld, uint8_t reg, uint8_t val, void *priv) * * @param pThis The PCnet shared instance data. */ -static void +static void pcnetTempLinkDown(nic_t *dev) { if (dev->fLinkUp) { @@ -2852,12 +2852,12 @@ pcnetSetLinkState(void *priv) { nic_t *dev = (nic_t *) priv; int fLinkUp; - + if (dev->fLinkTempDown) { pcnetTempLinkDown(dev); return 1; } - + fLinkUp = (dev->fLinkUp && !dev->fLinkTempDown); if (dev->fLinkUp != fLinkUp) { dev->fLinkUp = fLinkUp; @@ -2871,7 +2871,7 @@ pcnetSetLinkState(void *priv) dev->aCSR[0] |= 0x8000 | 0x2000; /* ERR | CERR (this is probably wrong) */ } } - + return 0; } @@ -2889,7 +2889,7 @@ static void pcnetTimerRestore(void *priv) { nic_t *dev = (nic_t *) priv; - + if (dev->cLinkDownReported <= PCNET_MAX_LINKDOWN_REPORTED) { timer_advance_u64(&dev->timer_restore, 1500000 * TIMER_USEC); } else { @@ -2926,10 +2926,10 @@ pcnet_init(const device_t *info) pcnet_mem_init(dev, 0x0fffff00); pcnet_mem_disable(dev); } - + dev->fLinkUp = 1; dev->cMsLinkUpDelay = 5000; - + if (dev->board == DEV_AM79C960_EB) { dev->maclocal[0] = 0x02; /* 02:07:01 (Racal OID) */ dev->maclocal[1] = 0x07; @@ -2987,7 +2987,7 @@ pcnet_init(const device_t *info) } else { /* Must be ASCII W (57h) if compatibility to AMD driver software is desired */ - dev->aPROM[14] = dev->aPROM[15] = 0x57; + dev->aPROM[14] = dev->aPROM[15] = 0x57; } for (c = 0, checksum = 0; c < 16; c++) @@ -3065,14 +3065,14 @@ pcnet_close(void *priv) nic_t *dev = (nic_t *)priv; pcnetlog(1, "%s: closed\n", dev->name); - + /* Make sure the platform layer is shut down. */ network_close(); - + if (dev) { free(dev); dev = NULL; - + } } @@ -3118,7 +3118,7 @@ static const device_config_t pcnet_isa_config[] = }, { "IRQ 4", 4 - }, + }, { "IRQ 5", 5 }, @@ -3149,7 +3149,7 @@ static const device_config_t pcnet_isa_config[] = "" } }, - }, + }, { "mac", "MAC Address", CONFIG_MAC, "", -1 }, @@ -3188,7 +3188,7 @@ static const device_config_t pcnet_vlb_config[] = }, { "IRQ 4", 4 - }, + }, { "IRQ 5", 5 }, diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index b4b46bbe7..fc4afcf78 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -362,27 +362,24 @@ poll_thread(void *arg) /* Request ownership of the queue. */ network_wait(1); - /* Wait for a poll request. */ - network_poll(); - /* Stop processing if asked to. */ - if (slirp->stop) break; + if (slirp->stop) { + network_wait(0); + break; + } /* See if there is any work. */ slirp_tic(slirp); - /* Wait for the next packet to arrive. */ + /* Wait for the next packet to arrive - network_do_tx() is called from there. */ tx = network_tx_queue_check(); - if (tx) - network_do_tx(); + /* Release ownership of the queue. */ + network_wait(0); /* If we did not get anything, wait a while. */ if (!tx) thread_wait_event(evt, 10); - - /* Release ownership of the queue. */ - network_wait(0); } /* No longer needed. */ @@ -449,8 +446,6 @@ net_slirp_close(void) /* Tell the thread to terminate. */ if (slirp->poll_tid) { - network_busy(0); - /* Wait for the thread to finish. */ slirp_log("SLiRP: waiting for thread to end...\n"); thread_wait_event(slirp->poll_state, -1); diff --git a/src/network/net_wd8003.c b/src/network/net_wd8003.c index 33aa1578c..3c6a5a059 100644 --- a/src/network/net_wd8003.c +++ b/src/network/net_wd8003.c @@ -181,7 +181,7 @@ static uint8_t wd_ram_read(uint32_t addr, void *priv) { wd_t *dev = (wd_t *)priv; - + wdlog("WD80x3: RAM Read: addr=%06x, val=%02x\n", addr & (dev->ram_size - 1), dev->dp8390->mem[addr & (dev->ram_size - 1)]); return dev->dp8390->mem[addr & (dev->ram_size - 1)]; } @@ -190,7 +190,7 @@ static void wd_ram_write(uint32_t addr, uint8_t val, void *priv) { wd_t *dev = (wd_t *)priv; - + dev->dp8390->mem[addr & (dev->ram_size - 1)] = val; wdlog("WD80x3: RAM Write: addr=%06x, val=%02x\n", addr & (dev->ram_size - 1), val); } @@ -246,7 +246,7 @@ wd_smc_read(wd_t *dev, uint32_t off) if (dev->board_chip & WE_ID_SOFT_CONFIG) retval = dev->laar; break; - + case 0x07: if (dev->board_chip & WE_ID_SOFT_CONFIG) retval = dev->if_chip; @@ -254,32 +254,32 @@ wd_smc_read(wd_t *dev, uint32_t off) case 0x08: retval = dev->dp8390->physaddr[0]; - break; - + break; + case 0x09: retval = dev->dp8390->physaddr[1]; - break; - + break; + case 0x0a: retval = dev->dp8390->physaddr[2]; - break; - + break; + case 0x0b: retval = dev->dp8390->physaddr[3]; - break; - + break; + case 0x0c: retval = dev->dp8390->physaddr[4]; break; - + case 0x0d: retval = dev->dp8390->physaddr[5]; break; - + case 0x0e: retval = dev->board_chip; break; - + case 0x0f: /*This has to return the byte that adds up to 0xFF*/ checksum = (dev->dp8390->physaddr[0] + dev->dp8390->physaddr[1] + dev->dp8390->physaddr[2] + @@ -354,7 +354,7 @@ wd_smc_write(wd_t *dev, uint32_t off, uint32_t val) wdlog("WD80x3: Memory now %sabled (addr = %08X)\n", (val & WE_MSR_ENABLE_RAM) ? "en" : "dis", dev->ram_addr); } break; - + /* Bit 1: 0 = 8-bit slot, 1 = 16-bit slot; Bit 3: 0 = 8k RAM, 1 = 32k RAM (only on revision < 2). */ case 0x01: @@ -363,7 +363,7 @@ wd_smc_write(wd_t *dev, uint32_t off, uint32_t val) else dev->icr = val; break; - + /* Bit 5: Bit 0 of encoded IRQ; Bit 6: Bit 1 of encoded IRQ; Bit 7: Enable interrupts. */ @@ -390,7 +390,7 @@ wd_smc_write(wd_t *dev, uint32_t off, uint32_t val) if (dev->board_chip & WE_ID_SOFT_CONFIG) dev->if_chip = val; break; - + default: /* This is invalid, but happens under win95 device detection: maybe some clone cards implement writing for some other @@ -415,7 +415,7 @@ wd_read(uint16_t addr, void *priv, int len) if (off == 0x10) retval = dp8390_read_cr(dev->dp8390); else if ((off >= 0x00) && (off <= 0x0f)) - retval = wd_smc_read(dev, off); + retval = wd_smc_read(dev, off); else { switch(dev->dp8390->CR.pgsel) { case 0x00: @@ -431,7 +431,7 @@ wd_read(uint16_t addr, void *priv, int len) wdlog("%s: unknown value of pgsel in read - %d\n", dev->name, dev->dp8390->CR.pgsel); break; - } + } } return(retval); @@ -467,7 +467,7 @@ wd_write(uint16_t addr, uint8_t val, void *priv, unsigned int len) if (off == 0x10) dp8390_write_cr(dev->dp8390, val); else if ((off >= 0x00) && (off <= 0x0f)) - wd_smc_write(dev, off, val); + wd_smc_write(dev, off, val); else { switch(dev->dp8390->CR.pgsel) { case 0x00: @@ -480,7 +480,7 @@ wd_write(uint16_t addr, uint8_t val, void *priv, unsigned int len) wdlog("%s: unknown value of pgsel in write - %d\n", dev->name, dev->dp8390->CR.pgsel); break; - } + } } } @@ -501,7 +501,7 @@ wd_writew(uint16_t addr, uint16_t val, void *priv) static void wd_io_set(wd_t *dev, uint16_t addr) -{ +{ if (dev->bit16 & 1) { io_sethandler(addr, 0x20, wd_readb, wd_readw, NULL, @@ -516,7 +516,7 @@ wd_io_set(wd_t *dev, uint16_t addr) static void wd_io_remove(wd_t *dev, uint16_t addr) -{ +{ if (dev->bit16 & 1) { io_removehandler(addr, 0x20, wd_readb, wd_readw, NULL, @@ -711,14 +711,14 @@ wd_init(const device_t *info) wd_ram_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, dev); - mem_mapping_disable(&dev->ram_mapping); + mem_mapping_disable(&dev->ram_mapping); /* Attach ourselves to the network module. */ network_attach(dev->dp8390, dev->dp8390->physaddr, dp8390_rx, NULL, NULL); if (!(dev->board_chip & WE_ID_BUS_MCA)) { wdlog("%s: attached IO=0x%X IRQ=%d, RAM addr=0x%06x\n", dev->name, - dev->base_address, dev->irq, dev->ram_addr); + dev->base_address, dev->irq, dev->ram_addr); } return(dev); diff --git a/src/network/network.c b/src/network/network.c index fad9eacbc..8caf11067 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -120,18 +120,9 @@ static mutex_t *network_mutex; static uint8_t *network_mac; static uint8_t network_timer_active = 0; static pc_timer_t network_rx_queue_timer; -static netpkt_t *first_pkt[2] = { NULL, NULL }, - *last_pkt[2] = { NULL, NULL }; - - -static struct { - volatile int busy, - queue_in_use; - - event_t *wake_poll_thread, - *poll_complete, - *queue_not_in_use; -} poll_data; +static netpkt_t *first_pkt[3] = { NULL, NULL, NULL }, + *last_pkt[3] = { NULL, NULL, NULL }; +static netpkt_t queued_pkt; #ifdef ENABLE_NETWORK_LOG @@ -201,33 +192,6 @@ network_wait(uint8_t wait) } -void -network_poll(void) -{ - while (poll_data.busy) - thread_wait_event(poll_data.wake_poll_thread, -1); - - thread_reset_event(poll_data.wake_poll_thread); -} - - -void -network_busy(uint8_t set) -{ - poll_data.busy = !!set; - - if (! set) - thread_set_event(poll_data.wake_poll_thread); -} - - -void -network_end(void) -{ - thread_set_event(poll_data.poll_complete); -} - - /* * Initialize the configured network cards. * @@ -280,8 +244,7 @@ network_queue_put(int tx, void *priv, uint8_t *data, int len) { netpkt_t *temp; - temp = (netpkt_t *) malloc(sizeof(netpkt_t)); - memset(temp, 0, sizeof(netpkt_t)); + temp = (netpkt_t *) calloc(sizeof(netpkt_t), 1); temp->priv = priv; memcpy(temp->data, data, len); temp->len = len; @@ -298,17 +261,29 @@ network_queue_put(int tx, void *priv, uint8_t *data, int len) static void -network_queue_get(int tx, netpkt_t **pkt) +network_queue_get(int tx, netpkt_t *pkt) { + netpkt_t *temp; + + temp = first_pkt[tx]; + + if (temp == NULL) { + memset(pkt, 0x00, sizeof(netpkt_t)); + return; + } + + memcpy(pkt, temp, sizeof(netpkt_t)); + + first_pkt[tx] = temp->next; + free(temp); + if (first_pkt[tx] == NULL) - *pkt = NULL; - else - *pkt = first_pkt[tx]; + last_pkt[tx] = NULL; } static void -network_queue_advance(int tx) +network_queue_transmit(int tx) { netpkt_t *temp; @@ -317,6 +292,20 @@ network_queue_advance(int tx) if (temp == NULL) return; + if (temp->len > 0) { + network_dump_packet(temp); + /* Why on earth is this not a function pointer?! */ + switch(network_type) { + case NET_TYPE_PCAP: + net_pcap_in(temp->data, temp->len); + break; + + case NET_TYPE_SLIRP: + net_slirp_in(temp->data, temp->len); + break; + } + } + first_pkt[tx] = temp->next; free(temp); @@ -325,6 +314,38 @@ network_queue_advance(int tx) } +static void +network_queue_copy(int dest, int src) +{ + netpkt_t *temp, *temp2; + + temp = first_pkt[src]; + + if (temp == NULL) + return; + + temp2 = (netpkt_t *) calloc(sizeof(netpkt_t), 1); + temp2->priv = temp->priv; + memcpy(temp2->data, temp->data, temp->len); + temp2->len = temp->len; + temp2->prev = last_pkt[dest]; + temp2->next = NULL; + + if (last_pkt[dest] != NULL) + last_pkt[dest]->next = temp2; + last_pkt[dest] = temp2; + + if (first_pkt[dest] == NULL) + first_pkt[dest] = temp2; + + first_pkt[src] = temp->next; + free(temp); + + if (first_pkt[src] == NULL) + last_pkt[src] = NULL; +} + + static void network_queue_clear(int tx) { @@ -348,29 +369,25 @@ network_rx_queue(void *priv) { int ret = 1; - if (network_rx_pause) { + if (network_rx_pause || !thread_test_mutex(network_mutex)) { timer_on_auto(&network_rx_queue_timer, 0.762939453125 * 2.0 * 128.0); return; } - netpkt_t *pkt = NULL; - - network_busy(1); - - network_queue_get(0, &pkt); - if ((pkt != NULL) && (pkt->len > 0)) { - network_dump_packet(pkt); - ret = net_cards[network_card].rx(pkt->priv, pkt->data, pkt->len); - if (pkt->len >= 128) - timer_on_auto(&network_rx_queue_timer, 0.762939453125 * 2.0 * ((double) pkt->len)); - else - timer_on_auto(&network_rx_queue_timer, 0.762939453125 * 2.0 * 128.0); - } else - timer_on_auto(&network_rx_queue_timer, 0.762939453125 * 2.0 * 128.0); + if (queued_pkt.len == 0) + network_queue_get(0, &queued_pkt); + if (queued_pkt.len > 0) { + network_dump_packet(&queued_pkt); + ret = net_cards[network_card].rx(queued_pkt.priv, queued_pkt.data, queued_pkt.len); + } + timer_on_auto(&network_rx_queue_timer, 0.762939453125 * 2.0 * ((queued_pkt.len >= 128) ? ((double) queued_pkt.len) : 128.0)); if (ret) - network_queue_advance(0); + queued_pkt.len = 0; - network_busy(0); + /* Transmission. */ + network_queue_copy(1, 2); + + network_wait(0); } @@ -395,10 +412,6 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETLINKST network_set_wait(0); - /* Create the network events. */ - poll_data.poll_complete = thread_create_event(); - poll_data.wake_poll_thread = thread_create_event(); - /* Activate the platform module. */ switch(network_type) { case NET_TYPE_PCAP: @@ -410,8 +423,9 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETLINKST break; } - first_pkt[0] = first_pkt[1] = NULL; - last_pkt[0] = last_pkt[1] = NULL; + first_pkt[0] = first_pkt[1] = first_pkt[2] = NULL; + last_pkt[0] = last_pkt[1] = last_pkt[2] = NULL; + memset(&queued_pkt, 0x00, sizeof(netpkt_t)); memset(&network_rx_queue_timer, 0x00, sizeof(pc_timer_t)); timer_add(&network_rx_queue_timer, network_rx_queue, NULL, 0); /* 10 mbps. */ @@ -446,16 +460,6 @@ network_close(void) /* Force-close the SLIRP module. */ net_slirp_close(); - - /* Close the network events. */ - if (poll_data.wake_poll_thread != NULL) { - thread_destroy_event(poll_data.wake_poll_thread); - poll_data.wake_poll_thread = NULL; - } - if (poll_data.poll_complete != NULL) { - thread_destroy_event(poll_data.poll_complete); - poll_data.poll_complete = NULL; - } /* Close the network thread mutex. */ thread_close_mutex(network_mutex); @@ -545,50 +549,25 @@ network_reset(void) void network_tx(uint8_t *bufp, int len) { - network_busy(1); - ui_sb_update_icon(SB_NETWORK, 1); - network_queue_put(1, NULL, bufp, len); + network_queue_put(2, NULL, bufp, len); ui_sb_update_icon(SB_NETWORK, 0); - - network_busy(0); } /* Actually transmit the packet. */ -void -network_do_tx(void) -{ - netpkt_t *pkt = NULL; - - if (network_tx_pause) - return; - - network_queue_get(1, &pkt); - if ((pkt != NULL) && (pkt->len > 0)) { - network_dump_packet(pkt); - switch(network_type) { - case NET_TYPE_PCAP: - net_pcap_in(pkt->data, pkt->len); - break; - - case NET_TYPE_SLIRP: - net_slirp_in(pkt->data, pkt->len); - break; - } - } - network_queue_advance(1); -} - - int network_tx_queue_check(void) { if ((first_pkt[1] == NULL) && (last_pkt[1] == NULL)) return 0; + if (network_tx_pause) + return 1; + + network_queue_transmit(1); return 1; } @@ -661,13 +640,13 @@ int network_card_get_from_internal_name(char *s) { int c = 0; - + while (net_cards[c].device != NULL) { if (! strcmp((char *)net_cards[c].device->internal_name, s)) return(c); c++; } - + return 0; } diff --git a/src/network/pcap_if.c b/src/network/pcap_if.c index f168f7ae0..53b3d8882 100644 --- a/src/network/pcap_if.c +++ b/src/network/pcap_if.c @@ -210,7 +210,7 @@ start_cap(char *dev) now = hdr->ts.tv_sec; ltime = localtime(&now); strftime(temp, sizeof(temp), "%H:%M:%S", ltime); - + /* Process and print the packet. */ printf("\n<< %s,%.6ld len=%u\n", temp, hdr->ts.tv_usec, hdr->len); diff --git a/src/network/slirp/tinyglib.c b/src/network/slirp/tinyglib.c index 8baa576eb..9504ff3af 100644 --- a/src/network/slirp/tinyglib.c +++ b/src/network/slirp/tinyglib.c @@ -60,22 +60,22 @@ g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle) gsize haystack_len_unsigned = haystack_len; const gchar *end; gsize i; - + if (needle_len == 0) return (gchar *) haystack; - + if (haystack_len_unsigned < needle_len) return NULL; - + end = haystack + haystack_len - needle_len; - + while (p <= end && *p) { for (i = 0; i < needle_len; i++) if (p[i] != needle[i]) goto next; - + return (gchar *)p; - + next: p++; } @@ -104,10 +104,10 @@ g_strlcpy (gchar *dest, gchar *d = dest; const gchar *s = src; gsize n = dest_size; - + if (dest == NULL) return 0; if (src == NULL) return 0; - + /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) do @@ -119,7 +119,7 @@ g_strlcpy (gchar *dest, break; } while (--n != 0); - + /* If not enough room in dest, add NUL and traverse rest of src */ if (n == 0) { @@ -128,6 +128,6 @@ g_strlcpy (gchar *dest, while (*s++) ; } - + return s - src - 1; /* count does not include NUL */ } diff --git a/src/nvr.c b/src/nvr.c index 46e0f6c5a..7f44981c2 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -1,4 +1,4 @@ -/* +/* * VARCem Virtual ARchaeological Computer EMulator. * An emulator of (mostly) x86-based PC systems and devices, * using the ISA,EISA,VLB,MCA and PCI system buses, roughly diff --git a/src/nvr_at.c b/src/nvr_at.c index a7ee53c65..b3c6299b3 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -149,7 +149,7 @@ * This bit is set after each update cycle. When the UIE * bit is set to 1, the 1 in UF causes the IRQF bit to be * a 1, which asserts the !IRQ pin. This bit can be - * cleared by reading Register C or with a !RESET. + * cleared by reading Register C or with a !RESET. * * * Alarm Interrupt Flag (AF) * A 1 in the AF bit indicates that the current time has diff --git a/src/pci.c b/src/pci.c index b66882bde..7b4a7c6ed 100644 --- a/src/pci.c +++ b/src/pci.c @@ -124,9 +124,9 @@ pci_write(uint16_t port, uint8_t val, void *priv) switch (port) { case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff: - if (! pci_enable) + if (! pci_enable) return; - + pci_log("Writing %02X to PCI card on bus %i, slot %02X (pci_cards[%i]) (%02X:%02X)...\n", val, pci_bus, pci_card, slot, pci_func, pci_index | (port & 3)); slot = pci_card_to_slot_mapping[pci_bus_number_to_index_mapping[pci_bus]][pci_card]; if (slot != 0xff) { @@ -159,9 +159,9 @@ pci_writew(uint16_t port, uint16_t val, void *priv) switch (port) { case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff: - if (! pci_enable) + if (! pci_enable) return; - + pci_log("Writing %04X to PCI card on bus %i, slot %02X (pci_cards[%i]) (%02X:%02X)...\n", val, pci_bus, pci_card, slot, pci_func, pci_index | (port & 3)); slot = pci_card_to_slot_mapping[pci_bus_number_to_index_mapping[pci_bus]][pci_card]; if (slot != 0xff) { @@ -195,9 +195,9 @@ pci_writel(uint16_t port, uint32_t val, void *priv) switch (port) { case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff: - if (! pci_enable) + if (! pci_enable) return; - + pci_log("Writing %08X to PCI card on bus %i, slot %02X (pci_cards[%i]) (%02X:%02X)...\n", val, pci_bus, pci_card, slot, pci_func, pci_index | (port & 3)); slot = pci_card_to_slot_mapping[pci_bus_number_to_index_mapping[pci_bus]][pci_card]; if (slot != 0xff) { @@ -234,7 +234,7 @@ pci_read(uint16_t port, void *priv) switch (port) { case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff: - if (! pci_enable) + if (! pci_enable) return 0xff; slot = pci_card_to_slot_mapping[pci_bus_number_to_index_mapping[pci_bus]][pci_card]; @@ -269,7 +269,7 @@ pci_readw(uint16_t port, void *priv) switch (port) { case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff: - if (! pci_enable) + if (! pci_enable) return 0xff; slot = pci_card_to_slot_mapping[pci_bus_number_to_index_mapping[pci_bus]][pci_card]; @@ -305,8 +305,8 @@ pci_readl(uint16_t port, void *priv) pci_log("(%i) %03x read\n", pci_enable, port); switch (port) { - case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff: - if (! pci_enable) + case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff: + if (! pci_enable) return 0xff; slot = pci_card_to_slot_mapping[pci_bus_number_to_index_mapping[pci_bus]][pci_card]; diff --git a/src/pci_dummy.c b/src/pci_dummy.c index 066f18dcc..d843b9ee9 100644 --- a/src/pci_dummy.c +++ b/src/pci_dummy.c @@ -100,12 +100,12 @@ static void pci_dummy_writel(uint16_t Port, uint32_t Val, void *p) static void pci_dummy_io_remove(void) { - io_removehandler(pci_bar[0].addr, 0x0020, pci_dummy_read, pci_dummy_readw, pci_dummy_readl, pci_dummy_write, pci_dummy_writew, pci_dummy_writel, NULL); + io_removehandler(pci_bar[0].addr, 0x0020, pci_dummy_read, pci_dummy_readw, pci_dummy_readl, pci_dummy_write, pci_dummy_writew, pci_dummy_writel, NULL); } static void pci_dummy_io_set(void) { - io_sethandler(pci_bar[0].addr, 0x0020, pci_dummy_read, pci_dummy_readw, pci_dummy_readl, pci_dummy_write, pci_dummy_writew, pci_dummy_writel, NULL); + io_sethandler(pci_bar[0].addr, 0x0020, pci_dummy_read, pci_dummy_readw, pci_dummy_readl, pci_dummy_write, pci_dummy_writew, pci_dummy_writel, NULL); } diff --git a/src/pic.c b/src/pic.c index 899029c14..efe81f470 100644 --- a/src/pic.c +++ b/src/pic.c @@ -222,7 +222,7 @@ find_best_interrupt(pic_t *dev) if (dev == &pic2) intr += 8; - if (cpu_fast_off_flags & (1 << intr)) + if (cpu_fast_off_flags & (1u << intr)) cpu_fast_off_count = cpu_fast_off_val + 1; } diff --git a/src/pit.c b/src/pit.c index 5057b6efa..40927dea5 100644 --- a/src/pit.c +++ b/src/pit.c @@ -1038,7 +1038,7 @@ pit_set_clock(int clock) if (cpu_64bitbus) bus_timing = (cpuclock / ((double)cpu_busspeed / 2)); else - bus_timing = (cpuclock / (double)cpu_busspeed); + bus_timing = (cpuclock / (double)cpu_busspeed); pci_timing = (cpuclock / (double)cpu_pci_speed); agp_timing = (cpuclock / (double)cpu_agp_speed); diff --git a/src/port_6x.c b/src/port_6x.c index ef6c8365d..365b2aff9 100644 --- a/src/port_6x.c +++ b/src/port_6x.c @@ -61,7 +61,7 @@ port_6x_write(uint16_t port, uint8_t val, void *priv) speaker_update(); speaker_gated = val & 1; speaker_enable = val & 2; - if (speaker_enable) + if (speaker_enable) was_speaker_enable = 1; pit_ctr_set_gate(&pit->counters[2], val & 1); diff --git a/src/printer/CMakeLists.txt b/src/printer/CMakeLists.txt index 0f6c0e38d..5990789bb 100644 --- a/src/printer/CMakeLists.txt +++ b/src/printer/CMakeLists.txt @@ -13,4 +13,4 @@ # Copyright 2020,2021 David Hrdlička. # -add_library(print OBJECT png.c prt_cpmap.c prt_escp.c prt_text.c prt_ps.c) \ No newline at end of file +add_library(print OBJECT png.c prt_cpmap.c prt_escp.c prt_text.c prt_ps.c) diff --git a/src/printer/png.c b/src/printer/png.c index 22488a9ba..f23ce0949 100644 --- a/src/printer/png.c +++ b/src/printer/png.c @@ -234,8 +234,8 @@ error: PNGFUNC(set_compression_strategy)(png, PNG_Z_DEFAULT_STRATEGY); PNGFUNC(set_compression_window_bits)(png, 15); PNGFUNC(set_compression_method)(png, 8); - PNGFUNC(set_compression_buffer_size)(png, 8192); - + PNGFUNC(set_compression_buffer_size)(png, 8192); + PNGFUNC(set_IHDR)(png, info, w, h, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); @@ -247,7 +247,7 @@ error: } PNGFUNC(set_PLTE)(png, info, palette, 256); - + /* Create a buffer for scanlines of pixels. */ rows = (png_bytep *)malloc(sizeof(png_bytep) * h); for (i = 0; i < h; i++) { @@ -256,14 +256,14 @@ error: } PNGFUNC(set_rows)(png, info, rows); - + PNGFUNC(write_png)(png, info, 0, NULL); /* Clean up. */ - (void)fclose(fp); + (void)fclose(fp); PNGFUNC(destroy_write_struct)(&png, &info); - + /* No longer need the row buffers. */ free(rows); } diff --git a/src/printer/prt_cpmap.c b/src/printer/prt_cpmap.c index f5da0e91d..605fe9fdc 100644 --- a/src/printer/prt_cpmap.c +++ b/src/printer/prt_cpmap.c @@ -54,7 +54,7 @@ #include #include #include <86box/86box.h> -#include <86box/plat.h> +#include <86box/plat.h> #include <86box/printer.h> @@ -587,7 +587,7 @@ select_codepage(uint16_t code, uint16_t *curmap) } i++; } - + for (i = 0; i < 256; i++) curmap[i] = map_to_use[i]; } diff --git a/src/printer/prt_escp.c b/src/printer/prt_escp.c index 22bd86e06..b788c317f 100644 --- a/src/printer/prt_escp.c +++ b/src/printer/prt_escp.c @@ -61,7 +61,7 @@ #include <86box/machine.h> #include <86box/timer.h> #include <86box/mem.h> -#include <86box/rom.h> +#include <86box/rom.h> #include <86box/pit.h> #include <86box/plat.h> #include <86box/plat_dynld.h> @@ -99,7 +99,7 @@ void *ft_handle = NULL; static int (*ft_Init_FreeType)(FT_Library *alibrary); static int (*ft_Done_Face)(FT_Face face); -static int (*ft_New_Face)(FT_Library library, const char *filepathname, +static int (*ft_New_Face)(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface); static int (*ft_Set_Char_Size)(FT_Face face, FT_F26Dot6 char_width, FT_F26Dot6 char_height, @@ -207,12 +207,12 @@ typedef struct { char page_fn[260]; uint8_t color; - + /* page data (TODO: make configurable) */ double page_width, /* all in inches */ page_height, left_margin, - top_margin, + top_margin, right_margin, bottom_margin; uint16_t dpi; @@ -291,7 +291,7 @@ typedef struct { uint8_t msb; /* MSB mode, -1 = off */ uint8_t ctrl; - + PALETTE palcol; } escp_t; @@ -321,9 +321,9 @@ static const uint16_t codepages[15] = { }; -/* "patches" to the codepage for the international charsets +/* "patches" to the codepage for the international charsets * these bytes patch the following 12 positions of the char table, in order: - * 0x23 0x24 0x40 0x5b 0x5c 0x5d 0x5e 0x60 0x7b 0x7c 0x7d 0x7e + * 0x23 0x24 0x40 0x5b 0x5c 0x5d 0x5e 0x60 0x7b 0x7c 0x7d 0x7e * TODO: Implement the missing international charsets */ static const uint16_t intCharSets[15][12] = { @@ -395,7 +395,7 @@ escp_log(const char *fmt, ...) /* Dump the current page into a formatted file. */ -static void +static void dump_page(escp_t *dev) { char path[1024]; @@ -453,7 +453,7 @@ timeout_timer(void *priv) } -static void +static void fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID, escp_t *dev) { uint8_t colormask; @@ -499,7 +499,7 @@ reset_printer(escp_t *dev) dev->density_k = 0; dev->density_l = 1; dev->density_y = 2; - dev->density_z = 3; + dev->density_z = 3; dev->char_tables[0] = 0; /* italics */ dev->char_tables[1] = dev->char_tables[2] = dev->char_tables[3] = 437; /* all other tables use CP437 */ dev->defined_unit = -1.0; @@ -510,7 +510,7 @@ reset_printer(escp_t *dev) dev->msb = 255; dev->print_everything_count = 0; dev->lq_typeface = TYPEFACE_COURIER; - + init_codepage(dev, dev->char_tables[dev->curr_char_table]); update_font(dev); @@ -521,10 +521,10 @@ reset_printer(escp_t *dev) dev->horizontal_tabs[i] = i * 8.0 * (1.0 / dev->cpi); dev->num_horizontal_tabs = 32; dev->num_vertical_tabs = -1; - + if (dev->page != NULL) - dev->page->dirty = 0; - + dev->page->dirty = 0; + escp_log("ESC/P: width=%.1fin,height=%.1fin dpi=%i cpi=%i lpi=%i\n", dev->page_width, dev->page_height, (int)dev->dpi, (int)dev->cpi, (int)dev->lpi); @@ -690,7 +690,7 @@ process_char(escp_t *dev, uint8_t ch) case 0x02: // Undocumented case 0x0a: // Reverse line feed case 0x0c: // Return to top of current page - case 0x0e: // Select double-width printing (one line) (ESC SO) + case 0x0e: // Select double-width printing (one line) (ESC SO) case 0x0f: // Select condensed printing (ESC SI) case 0x23: // Cancel MSB control (ESC #) case 0x30: // Select 1/8-inch line spacing (ESC 0) @@ -711,7 +711,7 @@ process_char(escp_t *dev, uint8_t ch) case 0x47: // Select double-strike printing (ESC G) case 0x48: // Cancel double-strike printing (ESC H) case 0x4d: // Select 10.5-point, 12-cpi (ESC M) - case 0x4f: // Cancel bottom margin + case 0x4f: // Cancel bottom margin case 0x50: // Select 10.5-point, 10-cpi (ESC P) case 0x54: // Cancel superscript/subscript printing (ESC T) case 0x5e: // Enable printing of all character codes on next character @@ -723,7 +723,7 @@ process_char(escp_t *dev, uint8_t ch) case 0x852: // Select reverse feed mode (FS R) dev->esc_parms_req = 0; break; - + case 0x19: // Control paper loading/ejecting (ESC EM) case 0x20: // Set intercharacter space (ESC SP) case 0x21: // Master select (ESC !) @@ -787,7 +787,7 @@ process_char(escp_t *dev, uint8_t ch) case 0x5b: // Select character height, width, line spacing dev->esc_parms_req = 7; break; - + case 0x62: // Set vertical tabs in VFU channels (ESC b) case 0x42: // Set vertical tabs (ESC B) dev->num_vertical_tabs = 0; @@ -813,7 +813,7 @@ process_char(escp_t *dev, uint8_t ch) return 1; default: - escp_log("ESC/P: Unknown command ESC %c (0x%02x). Unable to skip parameters.\n", + escp_log("ESC/P: Unknown command ESC %c (0x%02x). Unable to skip parameters.\n", dev->esc_pending >= 0x20 ? dev->esc_pending : '?', dev->esc_pending); dev->esc_parms_req = 0; dev->esc_pending = 0; @@ -877,7 +877,7 @@ process_char(escp_t *dev, uint8_t ch) /* Collect vertical tabs. */ if (dev->esc_pending == 0x42) { /* check if we're done */ - if ((ch == 0) || + if ((ch == 0) || (dev->num_vertical_tabs > 0 && dev->vertical_tabs[dev->num_vertical_tabs - 1] > (double)ch * dev->linespacing)) { dev->esc_pending = 0; } else { @@ -889,7 +889,7 @@ process_char(escp_t *dev, uint8_t ch) /* Collect horizontal tabs. */ if (dev->esc_pending == 0x44) { /* check if we're done... */ - if ((ch == 0) || + if ((ch == 0) || (dev->num_horizontal_tabs > 0 && dev->horizontal_tabs[dev->num_horizontal_tabs - 1] > (double)ch * (1.0 / dev->cpi))) { dev->esc_pending = 0; } else { @@ -988,8 +988,8 @@ process_char(escp_t *dev, uint8_t ch) case 0x85a: /* Print 24-bit hex-density graphics (FS Z) */ setup_bit_image(dev, 40, PARAM16(0)); - break; - + break; + case 0x2a: /* select bit image (ESC *) */ setup_bit_image(dev, dev->esc_parms[0], PARAM16(1)); break; @@ -1258,9 +1258,9 @@ process_char(escp_t *dev, uint8_t ch) break; case 0x846: // Select forward feed mode (FS F) - set reverse not implemented yet - if (dev->linespacing < 0) + if (dev->linespacing < 0) dev->linespacing *= -1; - break; + break; case 0x6a: // Reverse paper feed (ESC j) reverse = (double)PARAM16(0) / (double)216.0; @@ -1455,7 +1455,7 @@ process_char(escp_t *dev, uint8_t ch) switch (ch) { case 0x00: return 1; - + case 0x07: /* Beeper (BEL) */ /* TODO: beep? */ return 1; @@ -1580,7 +1580,7 @@ process_char(escp_t *dev, uint8_t ch) case 0x1b: /* ESC */ dev->esc_seen = 1; return 1; - + case 0x1c: /* FS (IBM commands) */ dev->fss_seen = 1; return 1; @@ -1651,7 +1651,7 @@ handle_char(escp_t *dev, uint8_t ch) /* mark the page as dirty if anything is drawn */ if ((ch != 0x20) || (dev->font_score != SCORE_NONE)) dev->page->dirty = 1; - + /* draw the glyph */ blit_glyph(dev, pen_x, pen_y, 0); blit_glyph(dev, pen_x + 1, pen_y, 1); @@ -1687,20 +1687,20 @@ handle_char(escp_t *dev, uint8_t ch) if (dev->font_score != SCORE_NONE && (dev->font_style & (STYLE_UNDERLINE | STYLE_STRIKETHROUGH | STYLE_OVERSCORE))) { /* Find out where to put the line. */ line_y = PIXY; - + if (dev->font_style & STYLE_UNDERLINE) line_y = (PIXY + (uint16_t)(dev->fontface->size->metrics.height * 0.9)); if (dev->font_style & STYLE_STRIKETHROUGH) line_y = (PIXY + (uint16_t)(dev->fontface->size->metrics.height * 0.45)); if (dev->font_style & STYLE_OVERSCORE) line_y = PIXY - ((dev->font_score == SCORE_DOUBLE || dev->font_score == SCORE_DOUBLEBROKEN) ? 5 : 0); - + draw_hline(dev, pen_x, PIXX, line_y, dev->font_score == SCORE_SINGLEBROKEN || dev->font_score == SCORE_DOUBLEBROKEN); - + if (dev->font_score == SCORE_DOUBLE || dev->font_score == SCORE_DOUBLEBROKEN) draw_hline(dev, line_start, PIXX, line_y + 5, dev->font_score == SCORE_SINGLEBROKEN || dev->font_score == SCORE_DOUBLEBROKEN); } - + if ((dev->curr_x + x_advance) > dev->right_margin) { dev->curr_x = dev->left_margin; dev->curr_y += dev->linespacing; @@ -1735,7 +1735,7 @@ blit_glyph(escp_t *dev, unsigned destx, unsigned desty, int8_t add) *dst |= (dev->color | 0x1f); else { *dst += src; - *dst |= dev->color; + *dst |= dev->color; } } else *dst = src|dev->color; @@ -1899,7 +1899,7 @@ print_bit_graph(escp_t *dev, uint8_t ch) pixel_w = 1; pixel_h = 1; - + if (dev->bg_adjacent) { /* if page DPI is bigger than bitgraphics DPI, drawn pixels get "bigger" */ pixel_w = dev->dpi / dev->bg_h_density > 0 ? dev->dpi / dev->bg_h_density : 1; @@ -1983,7 +1983,7 @@ write_ctrl(uint8_t val, void *priv) } dev->ctrl = val; - + dev->autofeed = ((val & 0x02) > 0); } @@ -2071,7 +2071,7 @@ escp_init(void *lpt) dev->page_width = PAGE_WIDTH; dev->page_height = PAGE_HEIGHT; - dev->dpi = PAGE_DPI; + dev->dpi = PAGE_DPI; /* Create 8-bit grayscale buffer for the page. */ dev->page = (psurface_t *)malloc(sizeof(psurface_t)); @@ -2081,7 +2081,7 @@ escp_init(void *lpt) dev->page->pixels = (uint8_t *)malloc(dev->page->pitch * dev->page->h); memset(dev->page->pixels, 0x00, dev->page->pitch * dev->page->h); - /* Initialize parameters. */ + /* Initialize parameters. */ for (i = 0; i < 32; i++) { dev->palcol[i].r = 255; dev->palcol[i].g = 255; diff --git a/src/printer/prt_ps.c b/src/printer/prt_ps.c index 73bd56b63..efb6d104f 100644 --- a/src/printer/prt_ps.c +++ b/src/printer/prt_ps.c @@ -41,7 +41,7 @@ #define GS_ARG_ENCODING_UTF8 1 -#define gs_error_Quit -101 +#define gs_error_Quit -101 #ifdef _WIN32 #if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) diff --git a/src/printer/prt_text.c b/src/printer/prt_text.c index b0f0b5daa..070e1bd4c 100644 --- a/src/printer/prt_text.c +++ b/src/printer/prt_text.c @@ -60,7 +60,7 @@ #include <86box/device.h> #include <86box/timer.h> #include <86box/pit.h> -#include <86box/plat.h> +#include <86box/plat.h> #include <86box/lpt.h> #include <86box/printer.h> #include <86box/prt_devs.h> @@ -112,7 +112,7 @@ typedef struct { double page_width, /* all in inches */ page_height, left_margin, - top_margin, + top_margin, right_margin, bot_margin; @@ -140,7 +140,7 @@ typedef struct { /* Dump the current page into a formatted file. */ -static void +static void dump_page(prnt_t *dev) { char path[1024]; diff --git a/src/qt/qt_deviceconfig.cpp b/src/qt/qt_deviceconfig.cpp index ac967f678..9c5a6d9d2 100644 --- a/src/qt/qt_deviceconfig.cpp +++ b/src/qt/qt_deviceconfig.cpp @@ -67,7 +67,7 @@ void DeviceConfig::ConfigureDevice(const _device_* device, int instance, Setting dc.ui->formLayout->addRow(config->description, cbox); break; } - case CONFIG_MIDI: + case CONFIG_MIDI_OUT: { auto* cbox = new QComboBox(); cbox->setObjectName(config->name); @@ -178,7 +178,7 @@ void DeviceConfig::ConfigureDevice(const _device_* device, int instance, Setting config_set_int(device_context.name, const_cast(config->name), cbox->isChecked() ? 1 : 0); break; } - case CONFIG_MIDI: + case CONFIG_MIDI_OUT: case CONFIG_MIDI_IN: case CONFIG_SELECTION: { diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index 1a89b93be..2e38197de 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -200,7 +200,7 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { void HardwareRenderer::resizeEvent(QResizeEvent *event) { onResize(width(), height()); - + QOpenGLWindow::resizeEvent(event); } @@ -214,7 +214,7 @@ bool HardwareRenderer::event(QEvent *event) std::vector> HardwareRenderer::getBuffers() { std::vector> buffers; - + buffers.push_back(std::make_tuple(imagebufs[0].get(), &buf_usage[0])); buffers.push_back(std::make_tuple(imagebufs[1].get(), &buf_usage[1])); diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index cae6c6e5c..46cf9a5dd 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -114,7 +114,7 @@ main_thread_fn() } } else { /* Just so we dont overload the host OS. */ - if (drawits < -1) + if (drawits < -1 || dopause) std::this_thread::sleep_for(std::chrono::milliseconds(1)); else std::this_thread::yield(); @@ -235,7 +235,7 @@ int main(int argc, char* argv[]) { QObject::disconnect(main_window, &MainWindow::pollMouse, 0, 0); QObject::connect(main_window, &MainWindow::pollMouse, (WindowsRawInputFilter*)rawInputFilter.get(), &WindowsRawInputFilter::mousePoll, Qt::DirectConnection); main_window->setSendKeyboardInput(false); - } + } #endif pc_reset_hard_init(); diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 986151b7c..2f1b6ca6a 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -132,7 +132,7 @@ MainWindow::MainWindow(QWidget *parent) : return; } if (!hide_tool_bar) -#ifdef _WIN32 +#ifdef _WIN32 toolbar_label->setText(title); #else { @@ -187,12 +187,12 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, &MainWindow::resizeContents, this, [this](int w, int h) { if (!QApplication::platformName().contains("eglfs") && vid_resize == 0) { w = qRound(w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)); - + int modifiedHeight = qRound(h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)) + menuBar()->height() + (statusBar()->height() * !hide_status_bar) + (ui->toolBar->height() * !hide_tool_bar); - + ui->stackedWidget->resize(w, h); setFixedSize(w, modifiedHeight); } diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 3d5a6a02a..e6e7d3053 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -124,7 +124,7 @@ private: Ui::MainWindow *ui; std::unique_ptr status; std::shared_ptr mm; - + /* If main window should send keyboard input */ bool send_keyboard_input = true; bool shownonce = false; diff --git a/src/qt/qt_newfloppydialog.cpp b/src/qt/qt_newfloppydialog.cpp index 76fbb8aca..6c33c6003 100644 --- a/src/qt/qt_newfloppydialog.cpp +++ b/src/qt/qt_newfloppydialog.cpp @@ -130,7 +130,7 @@ NewFloppyDialog::NewFloppyDialog(MediaType type, QWidget *parent) : util::DlgFilter({ "dsk","flp","im?","img","*fd?" }) % tr("Surface images") % util::DlgFilter({ "86f" }, true)); - + break; case MediaType::Zip: for (int i = 0; i < zipTypes.size(); ++i) { diff --git a/src/qt/qt_progsettings.cpp b/src/qt/qt_progsettings.cpp index 08e972801..9e39c4844 100644 --- a/src/qt/qt_progsettings.cpp +++ b/src/qt/qt_progsettings.cpp @@ -193,4 +193,3 @@ void ProgSettings::on_pushButtonLanguage_released() { ui->comboBoxLanguage->setCurrentIndex(0); } - diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 541bb4cf6..4788fa4df 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -213,7 +213,7 @@ void RendererStack::switchRenderer(Renderer renderer) { switch (renderer) { case Renderer::Software: { - auto sw = new SoftwareRenderer(this); + auto sw = new SoftwareRenderer(this); rendererWindow = sw; connect(this, &RendererStack::blitToRenderer, sw, &SoftwareRenderer::onBlit, Qt::QueuedConnection); current.reset(this->createWindowContainer(sw, this)); diff --git a/src/qt/qt_settingsfloppycdrom.cpp b/src/qt/qt_settingsfloppycdrom.cpp index ba2c1d601..d567dd7c9 100644 --- a/src/qt/qt_settingsfloppycdrom.cpp +++ b/src/qt/qt_settingsfloppycdrom.cpp @@ -250,4 +250,3 @@ void SettingsFloppyCDROM::on_comboBoxChannel_activated(int) { ui->comboBoxChannel->currentData().toUInt()); Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt()); } - diff --git a/src/qt/qt_settingsharddisks.cpp b/src/qt/qt_settingsharddisks.cpp index 25fc06bfe..43cd3fc9c 100644 --- a/src/qt/qt_settingsharddisks.cpp +++ b/src/qt/qt_settingsharddisks.cpp @@ -294,4 +294,3 @@ void SettingsHarddisks::on_pushButtonRemove_clicked() { ui->pushButtonNew->setEnabled(true); ui->pushButtonExisting->setEnabled(true); } - diff --git a/src/qt/qt_settingsinput.cpp b/src/qt/qt_settingsinput.cpp index c735153d9..7408db5d4 100644 --- a/src/qt/qt_settingsinput.cpp +++ b/src/qt/qt_settingsinput.cpp @@ -200,4 +200,3 @@ void SettingsInput::on_pushButtonJoystick3_clicked() { void SettingsInput::on_pushButtonJoystick4_clicked() { updateJoystickConfig(ui->comboBoxJoystick->currentData().toInt(), 3, this); } - diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 98b1ac486..437ed3647 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -136,4 +136,3 @@ void SettingsNetwork::on_comboBoxPcap_currentIndexChanged(int index) enableElements(ui); } - diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index dbabae73c..6e0388ede 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -14,6 +14,7 @@ * Cacodemon345 * * Copyright 2022 Cacodemon345 + * Copyright 2022 Jasmine Iwanek * Copyright 2021 Joakim L. Gilje */ #include "qt_settingsports.hpp" @@ -36,7 +37,7 @@ SettingsPorts::SettingsPorts(QWidget *parent) : { ui->setupUi(this); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < PARALLEL_MAX; i++) { auto* cbox = findChild(QString("comboBoxLpt%1").arg(i+1)); auto* model = cbox->model(); int c = 0; @@ -60,7 +61,7 @@ SettingsPorts::SettingsPorts(QWidget *parent) : cbox->setEnabled(lpt_ports[i].enabled > 0); } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < SERIAL_MAX; i++) { auto* checkBox = findChild(QString("checkBoxSerial%1").arg(i+1)); checkBox->setChecked(serial_enabled[i] > 0); } @@ -72,14 +73,14 @@ SettingsPorts::~SettingsPorts() } void SettingsPorts::save() { - for (int i = 0; i < 3; i++) { + for (int i = 0; i < PARALLEL_MAX; i++) { auto* cbox = findChild(QString("comboBoxLpt%1").arg(i+1)); auto* checkBox = findChild(QString("checkBoxParallel%1").arg(i+1)); lpt_ports[i].device = cbox->currentData().toInt(); lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < SERIAL_MAX; i++) { auto* checkBox = findChild(QString("checkBoxSerial%1").arg(i+1)); serial_enabled[i] = checkBox->isChecked() ? 1 : 0; } @@ -97,8 +98,6 @@ void SettingsPorts::on_checkBoxParallel3_stateChanged(int state) { ui->comboBoxLpt3->setEnabled(state == Qt::Checked); } - void SettingsPorts::on_checkBoxParallel4_stateChanged(int state) { ui->comboBoxLpt4->setEnabled(state == Qt::Checked); } - diff --git a/src/qt/qt_softwarerenderer.cpp b/src/qt/qt_softwarerenderer.cpp index 13d727e83..3deeb1a9f 100644 --- a/src/qt/qt_softwarerenderer.cpp +++ b/src/qt/qt_softwarerenderer.cpp @@ -53,7 +53,7 @@ void SoftwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { cur_image = buf_idx; buf_usage[(buf_idx + 1) % 2].clear(); - + source.setRect(x, y, w, h), update(); } @@ -79,7 +79,7 @@ void SoftwareRenderer::onPaint(QPaintDevice* device) { #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) painter.fillRect(0, 0, device->width(), device->height(), QColorConstants::Black); #else - painter.fillRect(0,0, device->width(), device->height(), Qt::black); + painter.fillRect(0, 0, device->width(), device->height(), Qt::black); #endif painter.setCompositionMode(QPainter::CompositionMode_Plus); painter.drawImage(destination, *images[cur_image], source); diff --git a/src/qt/qt_soundgain.cpp b/src/qt/qt_soundgain.cpp index 7b3f7cc04..26ac3dd73 100644 --- a/src/qt/qt_soundgain.cpp +++ b/src/qt/qt_soundgain.cpp @@ -48,4 +48,3 @@ void SoundGain::on_SoundGain_rejected() { sound_gain = sound_gain_orig; } - diff --git a/src/qt/qt_specifydimensions.cpp b/src/qt/qt_specifydimensions.cpp index caf831466..9d8daac0f 100644 --- a/src/qt/qt_specifydimensions.cpp +++ b/src/qt/qt_specifydimensions.cpp @@ -67,7 +67,7 @@ void SpecifyDimensions::on_SpecifyDimensions_accepted() + (!hide_status_bar ? main_window->statusBar()->height() : 0) + (!hide_tool_bar ? main_window->ui->toolBar->height() : 0) + main_window->menuBar()->height()); - + emit main_window->updateMenuResizeOptions(); main_window->show(); main_window->ui->stackedWidget->switchRenderer((RendererStack::Renderer)vid_api); @@ -89,4 +89,3 @@ void SpecifyDimensions::on_SpecifyDimensions_accepted() main_window->show(); emit main_window->updateWindowRememberOption(); } - diff --git a/src/qt/qt_winmanagerfilter.cpp b/src/qt/qt_winmanagerfilter.cpp index 6eb6d9cd5..dd69127d0 100644 --- a/src/qt/qt_winmanagerfilter.cpp +++ b/src/qt/qt_winmanagerfilter.cpp @@ -7,10 +7,10 @@ * This file is part of the 86Box distribution. * * Windows VM-managers native messages filter - * + * * Authors: * Teemu Korhonen - * + * * Copyright 2022 Teemu Korhonen */ @@ -63,4 +63,4 @@ bool WindowsManagerFilter::eventFilter(QObject *obj, QEvent *event) } return QObject::eventFilter(obj, event); -} \ No newline at end of file +} diff --git a/src/qt/qt_winmanagerfilter.hpp b/src/qt/qt_winmanagerfilter.hpp index 924011e30..d715d9322 100644 --- a/src/qt/qt_winmanagerfilter.hpp +++ b/src/qt/qt_winmanagerfilter.hpp @@ -7,10 +7,10 @@ * This file is part of the 86Box distribution. * * Header file for Windows VM-managers native messages filter - * + * * Authors: * Teemu Korhonen - * + * * Copyright 2022 Teemu Korhonen */ @@ -24,7 +24,7 @@ #if QT_VERSION_MAJOR >= 6 #define result_t qintptr -#else +#else #define result_t long #endif diff --git a/src/qt/qt_winrawinputfilter.cpp b/src/qt/qt_winrawinputfilter.cpp index 59a808065..053dbbd6d 100644 --- a/src/qt/qt_winrawinputfilter.cpp +++ b/src/qt/qt_winrawinputfilter.cpp @@ -7,14 +7,14 @@ * This file is part of the 86Box distribution. * * Windows raw input native filter for QT - * + * * Authors: * Teemu Korhonen * Miran Grca, - * + * * Copyright 2021 Teemu Korhonen * Copyright 2016-2018 Miran Grca. - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -120,7 +120,7 @@ bool WindowsRawInputFilter::nativeEventFilter(const QByteArray &eventType, void { if (window->isActiveWindow() && menus_open == 0) handle_input((HRAWINPUT)msg->lParam); - + return true; } } @@ -370,7 +370,7 @@ void WindowsRawInputFilter::mouse_handle(PRAWINPUT raw) if (state.usFlags & MOUSE_MOVE_ABSOLUTE) { - /* absolute mouse, i.e. RDP or VNC + /* absolute mouse, i.e. RDP or VNC * seems to work fine for RDP on Windows 10 * Not sure about other environments. */ diff --git a/src/qt/qt_winrawinputfilter.hpp b/src/qt/qt_winrawinputfilter.hpp index 7a73a2eca..4255440ff 100644 --- a/src/qt/qt_winrawinputfilter.hpp +++ b/src/qt/qt_winrawinputfilter.hpp @@ -7,12 +7,12 @@ * This file is part of the 86Box distribution. * * Header file for windows raw input native filter for QT - * + * * Authors: * Teemu Korhonen - * + * * Copyright 2021 Teemu Korhonen - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -42,7 +42,7 @@ #if QT_VERSION_MAJOR >= 6 #define result_t qintptr -#else +#else #define result_t long #endif diff --git a/src/qt/win_joystick_rawinput.c b/src/qt/win_joystick_rawinput.c index be808fc47..d1fca0491 100644 --- a/src/qt/win_joystick_rawinput.c +++ b/src/qt/win_joystick_rawinput.c @@ -55,7 +55,7 @@ joystick_log(const char *fmt, ...) typedef struct { HANDLE hdevice; PHIDP_PREPARSED_DATA data; - + USAGE usage_button[256]; struct raw_axis_t { @@ -127,7 +127,7 @@ void joystick_add_axis(raw_joystick_t* rawjoy, plat_joystick_t* joy, PHIDP_VALUE } else { /* * Some joysticks will send -1 in LogicalMax, like Xbox Controllers - * so we need to mask that to appropriate value (instead of 0xFFFFFFFF) + * so we need to mask that to appropriate value (instead of 0xFFFFFFFF) */ rawjoy->axis[joy->nr_axes].max = prop->LogicalMax & ((1 << prop->BitSize) - 1); } @@ -158,7 +158,7 @@ void joystick_get_capabilities(raw_joystick_t* rawjoy, plat_joystick_t* joy) { rawjoy->data = malloc(size); if (GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_PREPARSEDDATA, rawjoy->data, &size) <= 0) fatal("joystick_get_capabilities: Failed to get preparsed data.\n"); - + HIDP_CAPS caps; HidP_GetCaps(rawjoy->data, &caps); @@ -213,7 +213,7 @@ void joystick_get_device_name(raw_joystick_t* rawjoy, plat_joystick_t* joy, PRID if (GetRawInputDeviceInfoA(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size) <= 0) fatal("joystick_get_capabilities: Failed to get device name.\n"); - HANDLE hDevObj = CreateFile(device_name, GENERIC_READ | GENERIC_WRITE, + HANDLE hDevObj = CreateFile(device_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDevObj) { HidD_GetProductString(hDevObj, device_desc_wide, sizeof(WCHAR) * 200); @@ -223,8 +223,8 @@ void joystick_get_device_name(raw_joystick_t* rawjoy, plat_joystick_t* joy, PRID int result = WideCharToMultiByte(CP_ACP, 0, device_desc_wide, 200, joy->name, 260, NULL, NULL); if (result == 0 || strlen(joy->name) == 0) - sprintf(joy->name, - "RawInput %s, VID:%04lX PID:%04lX", + sprintf(joy->name, + "RawInput %s, VID:%04lX PID:%04lX", info->hid.usUsage == HID_USAGE_GENERIC_JOYSTICK ? "Joystick" : "Gamepad", info->hid.dwVendorId, info->hid.dwProductId); @@ -248,8 +248,8 @@ void joystick_init() PRID_DEVICE_INFO info = NULL; if (joysticks_present >= MAX_PLAT_JOYSTICKS) break; - if (deviceList[i].dwType != RIM_TYPEHID) continue; - + if (deviceList[i].dwType != RIM_TYPEHID) continue; + /* Get device info: hardware IDs and usage IDs */ GetRawInputDeviceInfoA(deviceList[i].hDevice, RIDI_DEVICEINFO, NULL, &size); info = malloc(size); @@ -259,9 +259,9 @@ void joystick_init() /* If this is not a joystick/gamepad, skip */ if (info->hid.usUsagePage != HID_USAGE_PAGE_GENERIC) goto end_loop; - if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK && + if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK && info->hid.usUsage != HID_USAGE_GENERIC_GAMEPAD) goto end_loop; - + plat_joystick_t *joy = &plat_joystick_state[joysticks_present]; raw_joystick_t *rawjoy = &raw_joystick_state[joysticks_present]; rawjoy->hdevice = deviceList[i].hDevice; @@ -269,7 +269,7 @@ void joystick_init() joystick_get_capabilities(rawjoy, joy); joystick_get_device_name(rawjoy, joy, info); - joystick_log("joystick_init: %s - %d buttons, %d axes, %d POVs\n", + joystick_log("joystick_init: %s - %d buttons, %d axes, %d POVs\n", joy->name, joy->nr_buttons, joy->nr_axes, joy->nr_povs); joysticks_present++; @@ -277,7 +277,7 @@ void joystick_init() end_loop: free(info); } - + joystick_log("joystick_init: joysticks_present=%i\n", joysticks_present); /* Initialize the RawInput (joystick and gamepad) module. */ @@ -293,7 +293,7 @@ void joystick_init() ridev[1].usUsage = HID_USAGE_GENERIC_GAMEPAD; if (!RegisterRawInputDevices(ridev, 2, sizeof(RAWINPUTDEVICE))) - fatal("plat_joystick_init: RegisterRawInputDevices failed\n"); + fatal("plat_joystick_init: RegisterRawInputDevices failed\n"); } void joystick_close() @@ -326,7 +326,7 @@ void win_joystick_handle(PRAWINPUT raw) } } if (j == -1) return; - + /* Read buttons */ USAGE usage_list[128] = {0}; ULONG usage_length = plat_joystick_state[j].nr_buttons; @@ -334,7 +334,7 @@ void win_joystick_handle(PRAWINPUT raw) r = HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON, 0, usage_list, &usage_length, raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid); - + if (r == HIDP_STATUS_SUCCESS) { for (int i=0; imax - axis->min + 1) / 2; - r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, axis->link, axis->usage, &uvalue, + r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, axis->link, axis->usage, &uvalue, raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid); - + if (r == HIDP_STATUS_SUCCESS) { if (axis->min < 0) { /* extend signed uvalue to LONG */ @@ -371,7 +371,7 @@ void win_joystick_handle(PRAWINPUT raw) } plat_joystick_state[j].a[a] = value; - //joystick_log("%s %-06d ", plat_joystick_state[j].axis[a].name, plat_joystick_state[j].a[a]); + //joystick_log("%s %-06d ", plat_joystick_state[j].axis[a].name, plat_joystick_state[j].a[a]); } /* read povs */ @@ -379,10 +379,10 @@ void win_joystick_handle(PRAWINPUT raw) struct raw_pov_t* pov = &raw_joystick_state[j].pov[p]; ULONG uvalue = 0; LONG value = -1; - - r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, pov->link, pov->usage, &uvalue, + + r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, pov->link, pov->usage, &uvalue, raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid); - + if (r == HIDP_STATUS_SUCCESS && (uvalue >= pov->min && uvalue <= pov->max)) { value = (uvalue - pov->min) * 36000; value /= (pov->max - pov->min + 1); @@ -392,7 +392,7 @@ void win_joystick_handle(PRAWINPUT raw) plat_joystick_state[j].p[p] = value; //joystick_log("%s %-3d ", plat_joystick_state[j].pov[p].name, plat_joystick_state[j].p[p]); - + } //joystick_log("\n"); } @@ -405,13 +405,13 @@ static int joystick_get_axis(int joystick_nr, int mapping) int pov = plat_joystick_state[joystick_nr].p[mapping & 3]; if (LOWORD(pov) == 0xFFFF) return 0; - else + else return sin((2*M_PI * (double)pov) / 36000.0) * 32767; } else if (mapping & POV_Y) { int pov = plat_joystick_state[joystick_nr].p[mapping & 3]; - + if (LOWORD(pov) == 0xFFFF) return 0; else @@ -419,7 +419,7 @@ static int joystick_get_axis(int joystick_nr, int mapping) } else return plat_joystick_state[joystick_nr].a[plat_joystick_state[joystick_nr].axis[mapping].id]; - + } @@ -434,7 +434,7 @@ void joystick_process(void) if (joystick_state[c].plat_joystick_nr) { int joystick_nr = joystick_state[c].plat_joystick_nr - 1; - + for (d = 0; d < joystick_get_axis_count(joystick_type); d++) joystick_state[c].axis[d] = joystick_get_axis(joystick_nr, joystick_state[c].axis_mapping[d]); for (d = 0; d < joystick_get_button_count(joystick_type); d++) @@ -447,10 +447,10 @@ void joystick_process(void) x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]); y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]); - + angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI); magnitude = sqrt((double)x*(double)x + (double)y*(double)y); - + if (magnitude < 16384) joystick_state[c].pov[d] = -1; else @@ -468,4 +468,3 @@ void joystick_process(void) } } } - diff --git a/src/qt/wl_mouse.cpp b/src/qt/wl_mouse.cpp index 36a91b68e..420ddc486 100644 --- a/src/qt/wl_mouse.cpp +++ b/src/qt/wl_mouse.cpp @@ -51,7 +51,7 @@ void wl_mouse_poll() rel_mouse_y = 0; } -static struct zwp_relative_pointer_v1_listener rel_listener = +static struct zwp_relative_pointer_v1_listener rel_listener = { rel_mouse_event }; diff --git a/src/qt/wl_mouse.hpp b/src/qt/wl_mouse.hpp index 73e81c208..a62d70fee 100644 --- a/src/qt/wl_mouse.hpp +++ b/src/qt/wl_mouse.hpp @@ -2,4 +2,4 @@ class QWindow; void wl_mouse_capture(QWindow* window); void wl_mouse_uncapture(); void wl_mouse_poll(); -void wl_init(); \ No newline at end of file +void wl_init(); diff --git a/src/scsi/CMakeLists.txt b/src/scsi/CMakeLists.txt index 6b0ebd10e..4518e0aa8 100644 --- a/src/scsi/CMakeLists.txt +++ b/src/scsi/CMakeLists.txt @@ -15,4 +15,4 @@ add_library(scsi OBJECT scsi.c scsi_device.c scsi_cdrom.c scsi_disk.c scsi_x54x.c scsi_aha154x.c scsi_buslogic.c scsi_ncr5380.c - scsi_ncr53c8xx.c scsi_pcscsi.c scsi_spock.c) \ No newline at end of file + scsi_ncr53c8xx.c scsi_pcscsi.c scsi_spock.c) diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index 1eab6bf32..638c0bfaa 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -166,7 +166,7 @@ scsi_card_get_from_internal_name(char *s) return(c); c++; } - + return(0); } diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index d0c81a08d..1c78473f9 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -301,7 +301,7 @@ aha_param_len(void *p) case CMD_SHADOW_RAM: return 1; - break; + break; case CMD_WRITE_EEPROM: return 35; @@ -407,7 +407,7 @@ aha_cmds(void *p) dev->DataBuf[1] = dev->Lock; dev->DataReplyLeft = 2; break; - + case CMD_MBENABLE: /* Mailbox interface enable Command */ dev->DataReplyLeft = 0; if (dev->CmdBuf[1] == dev->Lock) { @@ -549,7 +549,7 @@ aha_mca_write(int port, uint8_t val, void *priv) /* Save the new IRQ and DMA channel values. */ dev->Irq = (dev->pos_regs[4] & 0x07) + 8; - dev->DmaChannel = dev->pos_regs[5] & 0x0f; + dev->DmaChannel = dev->pos_regs[5] & 0x0f; /* Extract the BIOS ROM address info. */ if (! (dev->pos_regs[2] & 0x80)) switch(dev->pos_regs[3] & 0x38) { @@ -1013,7 +1013,7 @@ aha_init(const device_t *info) dev->rom_shramsz = 128; /* size of shadow RAM */ dev->ha_bps = 5000000.0; /* normal SCSI */ break; - + case AHA_154xB: strcpy(dev->name, "AHA-154xB"); switch(dev->Base) { @@ -1107,11 +1107,11 @@ aha_init(const device_t *info) /* Enable MCA. */ dev->pos_regs[0] = 0x1F; /* MCA board ID */ - dev->pos_regs[1] = 0x0F; + dev->pos_regs[1] = 0x0F; mca_add(aha_mca_read, aha_mca_write, aha_mca_feedb, NULL, dev); dev->ha_bps = 5000000.0; /* normal SCSI */ break; - } + } /* Initialize ROM BIOS if needed. */ aha_setbios(dev); diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 5dd9003c1..d6c0b69b5 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -268,7 +268,7 @@ BuslogicGetNVRFileName(buslogic_data_t *bl) switch(bl->chip) { case CHIP_BUSLOGIC_ISA_542B_1991_12_14: - return "bt542b.nvr"; + return "bt542b.nvr"; case CHIP_BUSLOGIC_ISA_545S_1992_10_05: return "bt545s.nvr"; case CHIP_BUSLOGIC_ISA_542BH_1993_05_23: @@ -483,7 +483,7 @@ buslogic_get_host_id(void *p) HALocalRAM *HALR = &bl->LocalRAM; - if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || + if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || (bl->chip == CHIP_BUSLOGIC_ISA_545S_1992_10_05) || (bl->chip == CHIP_BUSLOGIC_ISA_542BH_1993_05_23) || (bl->chip == CHIP_BUSLOGIC_VLB_445S_1993_11_16)) @@ -503,8 +503,8 @@ buslogic_get_irq(void *p) HALocalRAM *HALR = &bl->LocalRAM; - if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || - (bl->chip == CHIP_BUSLOGIC_ISA_545S_1992_10_05) || + if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || + (bl->chip == CHIP_BUSLOGIC_ISA_545S_1992_10_05) || (bl->chip == CHIP_BUSLOGIC_ISA_542BH_1993_05_23) || (bl->chip == CHIP_BUSLOGIC_VLB_445S_1993_11_16) || (bl->chip == CHIP_BUSLOGIC_PCI_958D_1995_12_30)) @@ -526,8 +526,8 @@ buslogic_get_dma(void *p) if (bl->chip == CHIP_BUSLOGIC_PCI_958D_1995_12_30) return (dev->Base ? 7 : 0); - else if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || - (bl->chip == CHIP_BUSLOGIC_ISA_545S_1992_10_05) || + else if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || + (bl->chip == CHIP_BUSLOGIC_ISA_545S_1992_10_05) || (bl->chip == CHIP_BUSLOGIC_ISA_542BH_1993_05_23) || (bl->chip == CHIP_BUSLOGIC_VLB_445S_1993_11_16)) return dev->DmaChannel; @@ -557,7 +557,7 @@ buslogic_param_len(void *p) return sizeof(MailboxInitExtended_t); case 0x83: return 12; - case 0x90: + case 0x90: case 0x91: return 2; case 0x94: @@ -615,7 +615,7 @@ BuslogicSCSIBIOSDMATransfer(x54x_t *dev, ESCMD *ESCSICmd, uint8_t TargetID, int static void BuslogicSCSIBIOSRequestSetup(x54x_t *dev, uint8_t *CmdBuf, uint8_t *DataInBuf, uint8_t DataReply) -{ +{ ESCMD *ESCSICmd = (ESCMD *)CmdBuf; uint32_t i; uint8_t temp_cdb[12]; @@ -633,8 +633,8 @@ BuslogicSCSIBIOSRequestSetup(x54x_t *dev, uint8_t *CmdBuf, uint8_t *DataInBuf, u DataInBuf[3] = SCSI_STATUS_OK; return; } - - buslogic_log("Scanning SCSI Target ID %i\n", ESCSICmd->TargetId); + + buslogic_log("Scanning SCSI Target ID %i\n", ESCSICmd->TargetId); sd->status = SCSI_STATUS_OK; @@ -648,7 +648,7 @@ BuslogicSCSIBIOSRequestSetup(x54x_t *dev, uint8_t *CmdBuf, uint8_t *DataInBuf, u scsi_device_identify(sd, ESCSICmd->LogicalUnit); buslogic_log("Transfer Control %02X\n", ESCSICmd->DataDirection); - buslogic_log("CDB Length %i\n", ESCSICmd->CDBLength); + buslogic_log("CDB Length %i\n", ESCSICmd->CDBLength); } target_cdb_len = 12; @@ -687,7 +687,7 @@ BuslogicSCSIBIOSRequestSetup(x54x_t *dev, uint8_t *CmdBuf, uint8_t *DataInBuf, u DataInBuf[3] = SCSI_STATUS_OK; } else if (scsi_devices[dev->bus][ESCSICmd->TargetId].status == SCSI_STATUS_CHECK_CONDITION) { DataInBuf[2] = CCB_COMPLETE; - DataInBuf[3] = SCSI_STATUS_CHECK_CONDITION; + DataInBuf[3] = SCSI_STATUS_CHECK_CONDITION; } dev->DataReplyLeft = DataReply; @@ -732,7 +732,7 @@ buslogic_cmds(void *p) } dev->DataReplyLeft = 8; break; - case 0x24: + case 0x24: for (i = 0; i < 15; i++) { if (scsi_device_present(&scsi_devices[dev->bus][i]) && (i != buslogic_get_host_id(dev))) TargetsPresentMask |= (1 << i); @@ -771,7 +771,7 @@ buslogic_cmds(void *p) buslogic_log("Execute SCSI BIOS Command: %u more bytes follow\n", dev->CmdParamLeft); } else { buslogic_log("Execute SCSI BIOS Command: received %u bytes\n", dev->CmdBuf[0]); - BuslogicSCSIBIOSRequestSetup(dev, dev->CmdBuf, dev->DataBuf, 4); + BuslogicSCSIBIOSRequestSetup(dev, dev->CmdBuf, dev->DataBuf, 4); } break; case 0x84: @@ -817,7 +817,7 @@ buslogic_cmds(void *p) dev->DataReplyLeft = sizeof(BuslogicPCIInformation_t); } else { dev->DataReplyLeft = 0; - dev->Status |= STAT_INVCMD; + dev->Status |= STAT_INVCMD; } break; case 0x8B: @@ -862,7 +862,7 @@ buslogic_cmds(void *p) ReplyIESI->cMailbox = dev->MailboxCount; ReplyIESI->uMailboxAddressBase = dev->MailboxOutAddr; ReplyIESI->fHostWideSCSI = (bl->chip == CHIP_BUSLOGIC_PCI_958D_1995_12_30) ? 1 : 0; - if ((bl->chip != CHIP_BUSLOGIC_ISA_542B_1991_12_14) && (bl->chip != CHIP_BUSLOGIC_ISA_545S_1992_10_05) && + if ((bl->chip != CHIP_BUSLOGIC_ISA_542B_1991_12_14) && (bl->chip != CHIP_BUSLOGIC_ISA_545S_1992_10_05) && (bl->chip != CHIP_BUSLOGIC_ISA_542BH_1993_05_23) && (bl->chip != CHIP_BUSLOGIC_MCA_640A_1993_05_23) && (bl->chip != CHIP_BUSLOGIC_VLB_445S_1993_11_16)) ReplyIESI->fLevelSensitiveInterrupt = bl->LocalRAM.structured.autoSCSIData.fLevelSensitiveInterrupt; @@ -876,12 +876,12 @@ buslogic_cmds(void *p) buslogic_log("Aggressive Round Robin Mode = %d\n", bl->fAggressiveRoundRobinMode); dev->DataReplyLeft = 0; break; - case 0x90: + case 0x90: buslogic_log("Store Local RAM\n"); Offset = dev->CmdBuf[0]; dev->DataReplyLeft = 0; memcpy(&(bl->LocalRAM.u8View[Offset]), &(dev->CmdBuf[2]), dev->CmdBuf[1]); - + dev->DataReply = 0; break; case 0x91: @@ -899,9 +899,9 @@ buslogic_cmds(void *p) break; } case 0x92: - if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || - (bl->chip == CHIP_BUSLOGIC_ISA_545S_1992_10_05) || - (bl->chip == CHIP_BUSLOGIC_ISA_542BH_1993_05_23) || + if ((bl->chip == CHIP_BUSLOGIC_ISA_542B_1991_12_14) || + (bl->chip == CHIP_BUSLOGIC_ISA_545S_1992_10_05) || + (bl->chip == CHIP_BUSLOGIC_ISA_542BH_1993_05_23) || (bl->chip == CHIP_BUSLOGIC_MCA_640A_1993_05_23)) { dev->DataReplyLeft = 0; dev->Status |= STAT_INVCMD; @@ -980,7 +980,7 @@ buslogic_cmds(void *p) return 1; } else { dev->DataReplyLeft = 0; - dev->Status |= STAT_INVCMD; + dev->Status |= STAT_INVCMD; } break; case 0x96: @@ -988,7 +988,7 @@ buslogic_cmds(void *p) bl->ExtendedLUNCCBFormat = 0; else if (dev->CmdBuf[0] == 1) bl->ExtendedLUNCCBFormat = 1; - + dev->DataReplyLeft = 0; break; case 0x97: @@ -1309,7 +1309,7 @@ BuslogicPCIWrite(int func, int addr, uint8_t val, void *p) x54x_mem_set_addr(dev, bl->MMIOBase); } } - return; + return; case 0x30: /* PCI_ROMBAR */ case 0x31: /* PCI_ROMBAR */ @@ -1390,7 +1390,7 @@ buslogic_mca_write(int port, uint8_t val, void *priv) /* Save the new IRQ and DMA channel values. */ dev->Irq = ((dev->pos_regs[2] >> 1) & 0x07) + 8; - dev->DmaChannel = dev->pos_regs[5] & 0x0f; + dev->DmaChannel = dev->pos_regs[5] & 0x0f; /* Extract the BIOS ROM address info. */ if (dev->pos_regs[2] & 0xe0) switch(dev->pos_regs[2] & 0xe0) { @@ -1401,7 +1401,7 @@ buslogic_mca_write(int port, uint8_t val, void *priv) case 0x00: /* [0]=000x xxxx */ bl->bios_addr = 0; break; - + case 0xc0: /* [0]=110x xxxx */ bl->bios_addr = 0xD8000; break; @@ -1679,7 +1679,7 @@ buslogic_init(const device_t *info) dev->fw_rev = "BA335"; dev->flags |= X54X_32BIT; dev->pos_regs[0] = 0x08; /* MCA board ID */ - dev->pos_regs[1] = 0x07; + dev->pos_regs[1] = 0x07; mca_add(buslogic_mca_read, buslogic_mca_write, buslogic_mca_feedb, NULL, dev); dev->ha_bps = 5000000.0; /* normal SCSI */ dev->max_id = 7; /* narrow SCSI */ @@ -1788,9 +1788,9 @@ buslogic_init(const device_t *info) if ((bl->chip == CHIP_BUSLOGIC_MCA_640A_1993_05_23) || (bl->chip == CHIP_BUSLOGIC_PCI_958D_1995_12_30)) mem_mapping_disable(&bl->bios.mapping); - + buslogic_log("Buslogic on port 0x%04X\n", dev->Base); - + x54x_device_reset(dev); if ((bl->chip != CHIP_BUSLOGIC_ISA_542B_1991_12_14) && (bl->chip != CHIP_BUSLOGIC_ISA_545S_1992_10_05) && (bl->chip != CHIP_BUSLOGIC_ISA_542BH_1993_05_23) && diff --git a/src/scsi/scsi_cdrom.c b/src/scsi/scsi_cdrom.c index 8a443dd77..c7e9060e9 100644 --- a/src/scsi/scsi_cdrom.c +++ b/src/scsi/scsi_cdrom.c @@ -140,7 +140,7 @@ const uint8_t scsi_cdrom_command_flags[0x100] = IMPLEMENTED | CHECK_READY, /* 0xBE */ IMPLEMENTED | CHECK_READY, /* 0xBF */ IMPLEMENTED | CHECK_READY | SCSI_ONLY, /* 0xC0 */ - IMPLEMENTED | CHECK_READY | SCSI_ONLY, /* 0xC1 */ + IMPLEMENTED | CHECK_READY | SCSI_ONLY, /* 0xC1 */ IMPLEMENTED | CHECK_READY | SCSI_ONLY, /* 0xC2 */ 0, /* 0xC3 */ IMPLEMENTED | CHECK_READY | SCSI_ONLY, /* 0xC4 */ @@ -1127,7 +1127,7 @@ scsi_cdrom_read_dvd_structure(scsi_cdrom_t *dev, int format, const uint8_t *pack /* Size of buffer, not including 2 byte size field */ buf[0] = ((4 + 2) >> 8) & 0xff; - buf[1] = (4 + 2) & 0xff; + buf[1] = (4 + 2) & 0xff; /* 4 byte header + 4 byte data */ return (4 + 4); @@ -1564,16 +1564,16 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) scsi_cdrom_set_phase(dev, SCSI_PHASE_DATA_IN); scsi_cdrom_buf_alloc(dev, 65536); - + if ((!dev->drv->ops) && ((cdb[1] & 3) == 2)) { scsi_cdrom_not_ready(dev); return; - } - + } + memset(dev->buffer, 0, 4); - + cdrom_read_disc_info_toc(dev->drv, dev->buffer, cdb[2], cdb[1] & 3); - + len = 4; scsi_cdrom_set_buf_len(dev, BufLen, &len); @@ -1979,7 +1979,7 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) case GPCMD_READ_DISC_INFORMATION: scsi_cdrom_set_phase(dev, SCSI_PHASE_DATA_IN); - + max_len = cdb[7]; max_len <<= 8; max_len |= cdb[8]; @@ -2064,7 +2064,7 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) scsi_cdrom_illegal_mode(dev); break; - case GPCMD_TOSHIBA_PLAY_AUDIO: + case GPCMD_TOSHIBA_PLAY_AUDIO: scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS); if ((dev->drv->host_drive < 1) || (dev->drv->cd_status <= CD_STATUS_DATA_ONLY)) { scsi_cdrom_illegal_mode(dev); @@ -2072,7 +2072,7 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) } pos = (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; ret = cdrom_toshiba_audio_play(dev->drv, pos, cdb[9]); - + if (ret) scsi_cdrom_command_complete(dev); else @@ -2207,7 +2207,7 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) dev->buffer[1] = 0x13; break; } - + scsi_cdrom_log("Audio Status = %02x\n", dev->buffer[1]); } @@ -2246,7 +2246,7 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) scsi_cdrom_set_buf_len(dev, BufLen, &alloc_length); scsi_cdrom_data_command_finish(dev, len, len, len, 0); - break; + break; case GPCMD_READ_DVD_STRUCTURE: scsi_cdrom_set_phase(dev, SCSI_PHASE_DATA_IN); @@ -2306,7 +2306,7 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) scsi_cdrom_command_complete(dev); break; - + case GPCMD_CADDY_EJECT: scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS); scsi_cdrom_stop(sc); @@ -2384,22 +2384,22 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) memset(dev->buffer, 0, 8); dev->buffer[0] = 5; /*CD-ROM*/ dev->buffer[1] = 0x80; /*Removable*/ - + if (dev->drv->bus_type == CDROM_BUS_SCSI) { dev->buffer[2] = 0x02; dev->buffer[3] = 0x02; } else { dev->buffer[2] = 0x00; - dev->buffer[3] = 0x21; + dev->buffer[3] = 0x21; } - + dev->buffer[4] = 31; if (dev->drv->bus_type == CDROM_BUS_SCSI) { dev->buffer[6] = 1; /* 16-bit transfers supported */ dev->buffer[7] = 0x20; /* Wide bus supported */ } - + if (dev->drv->bus_type == CDROM_BUS_SCSI) { ide_padstr8(dev->buffer + 8, 8, "TOSHIBA"); /* Vendor */ ide_padstr8(dev->buffer + 16, 16, "XM6201TASUN32XCD"); /* Product */ @@ -2487,7 +2487,7 @@ atapi_out: case GPCMD_STOP_PLAY_SCAN: scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS); - if (dev->drv->cd_status <= CD_STATUS_DATA_ONLY) { + if (dev->drv->cd_status <= CD_STATUS_DATA_ONLY) { scsi_cdrom_illegal_mode(dev); break; } diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index 85cefaacb..d3e7b6f11 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -495,7 +495,7 @@ scsi_disk_reset(scsi_common_t *sc) void scsi_disk_request_sense(scsi_disk_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc) -{ +{ /*Will return 18 bytes of 0*/ if (alloc_length != 0) { memset(buffer, 0, alloc_length); @@ -922,7 +922,7 @@ scsi_disk_command(scsi_common_t *sc, uint8_t *cdb) dev->packet_status = PHASE_COMPLETE; dev->callback = 20.0 * SCSI_TIME; break; - } + } scsi_disk_buf_alloc(dev, 65536); diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index abedb885c..713e69f7b 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -94,7 +94,7 @@ #define STATUS_BUFFER_NOT_READY 0x04 #define STATUS_53C80_ACCESSIBLE 0x80 -typedef struct { +typedef struct { uint8_t icr, mode, tcr, data_wait; uint8_t isr, output_data, target_id, tx_data; uint8_t msglun; @@ -115,10 +115,10 @@ typedef struct { uint8_t buffer[512]; uint8_t ext_ram[0x80]; uint8_t block_count; - + int block_loaded; int pos, host_pos; - + int bios_enabled; } t128_t; @@ -154,7 +154,7 @@ typedef struct { pc_timer_t timer; double period; - int ncr_busy; + int ncr_busy; } ncr5380_t; #define STATE_IDLE 0 @@ -229,7 +229,7 @@ get_dev_id(uint8_t data) return(-1); } -static int +static int getmsglen(uint8_t *msgp, int len) { uint8_t msg = msgp[0]; @@ -247,9 +247,9 @@ ncr_reset(ncr5380_t *ncr_dev, ncr_t *ncr) { memset(ncr, 0x00, sizeof(ncr_t)); ncr_log("NCR reset\n"); - + timer_stop(&ncr_dev->timer); - + for (int i = 0; i < 8; i++) scsi_device_reset(&scsi_devices[ncr_dev->bus][i]); @@ -260,10 +260,10 @@ static void ncr_timer_on(ncr5380_t *ncr_dev, ncr_t *ncr, int callback) { double p = ncr_dev->period; - + if (ncr->data_wait & 2) ncr->data_wait &= ~2; - + if (callback) { if (ncr_dev->type == 3) p *= 512.0; @@ -272,7 +272,7 @@ ncr_timer_on(ncr5380_t *ncr_dev, ncr_t *ncr, int callback) } p += 1.0; - + ncr_log("P = %lf, command = %02x, callback = %i, period = %lf, t128 pos = %i\n", p, ncr->command[0], callback, ncr_dev->period, ncr_dev->t128.host_pos); timer_on_auto(&ncr_dev->timer, p); } @@ -338,7 +338,7 @@ ncr_bus_read(ncr5380_t *ncr_dev) ncr->wait_data--; if (!ncr->wait_data) { dev = &scsi_devices[ncr_dev->bus][ncr->target_id]; - SET_BUS_STATE(ncr, ncr->new_phase); + SET_BUS_STATE(ncr, ncr->new_phase); phase = (ncr->cur_bus & SCSI_PHASE_MESSAGE_IN); if (phase == SCSI_PHASE_DATA_IN) { @@ -538,7 +538,7 @@ ncr_bus_update(void *priv, int bus) ncr->cur_bus &= ~BUS_REQ; ncr->new_phase = SCSI_PHASE_MESSAGE_IN; ncr->wait_data = 4; - ncr->wait_complete = 8; + ncr->wait_complete = 8; } break; case STATE_MESSAGEIN: @@ -578,7 +578,7 @@ ncr_bus_update(void *priv, int bus) } -static void +static void ncr_write(uint16_t port, uint8_t val, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; @@ -611,7 +611,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) } ncr->mode = val; - + if (ncr_dev->type == 3) { /*Don't stop the timer until it finishes the transfer*/ if (ncr_dev->t128.block_loaded && (ncr->mode & MODE_DMA)) { @@ -632,7 +632,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) ncr_log("Continuing DMA mode\n"); ncr_timer_on(ncr_dev, ncr, 0); } - + /*When a pseudo-DMA transfer has completed (Send or Initiator Receive), mark it as complete and idle the status*/ if (!ncr_dev->block_count_loaded && !(ncr->mode & MODE_DMA)) { ncr_log("No DMA mode\n"); @@ -651,15 +651,15 @@ ncr_write(uint16_t port, uint8_t val, void *priv) case 4: /* Select Enable Register */ ncr_log("Write: Select Enable register\n"); break; - + case 5: /* start DMA Send */ ncr_log("Write: start DMA send register\n"); /*a Write 6/10 has occurred, start the timer when the block count is loaded*/ ncr->dma_mode = DMA_SEND; if (ncr_dev->type == 3) { - memset(ncr_dev->t128.buffer, 0, MIN(512, dev->buffer_length)); - - ncr_log("DMA send timer start, enabled? = %i\n", timer_is_enabled(&ncr_dev->timer)); + memset(ncr_dev->t128.buffer, 0, MIN(512, dev->buffer_length)); + + ncr_log("DMA send timer start, enabled? = %i\n", timer_is_enabled(&ncr_dev->timer)); ncr_dev->t128.block_count = dev->buffer_length >> 9; ncr_dev->t128.block_loaded = 1; @@ -668,7 +668,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) } else { if ((ncr->mode & MODE_DMA) && !timer_is_enabled(&ncr_dev->timer)) { memset(ncr_dev->buffer, 0, MIN(128, dev->buffer_length)); - + ncr_log("DMA send timer on\n"); ncr_timer_on(ncr_dev, ncr, 0); } @@ -682,12 +682,12 @@ ncr_write(uint16_t port, uint8_t val, void *priv) if (ncr_dev->type == 3) { ncr_log("DMA receive timer start, enabled? = %i, cdb[0] = %02x\n", timer_is_enabled(&ncr_dev->timer), ncr->command[0]); memset(ncr_dev->t128.buffer, 0, MIN(512, dev->buffer_length)); - + ncr_dev->t128.block_count = dev->buffer_length >> 9; if (dev->buffer_length < 512) ncr_dev->t128.block_count = 1; - + ncr_dev->t128.block_loaded = 1; ncr_dev->t128.host_pos = MIN(512, dev->buffer_length); @@ -696,7 +696,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) } else { if ((ncr->mode & MODE_DMA) && !timer_is_enabled(&ncr_dev->timer)) { memset(ncr_dev->buffer, 0, MIN(128, dev->buffer_length)); - + ncr_log("DMA receive timer start\n"); ncr_timer_on(ncr_dev, ncr, 0); } @@ -707,7 +707,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) ncr_log("NCR5380: bad write %04x %02x\n", port, val); break; } - + if (ncr->dma_mode == DMA_IDLE || ncr_dev->type == 0 || ncr_dev->type == 3) { bus_host = get_bus_host(ncr); ncr_bus_update(priv, bus_host); @@ -715,7 +715,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) } -static uint8_t +static uint8_t ncr_read(uint16_t port, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; @@ -763,11 +763,11 @@ ncr_read(uint16_t port, void *priv) case 5: /* Bus and Status register */ ncr_log("Read: Bus and Status register\n"); - ret = 0; + ret = 0; bus = get_bus_host(ncr); ncr_log("Get host from Interrupt\n"); - + /*Check if the phase in process matches with TCR's*/ if ((bus & SCSI_PHASE_MESSAGE_IN) == (ncr->cur_bus & SCSI_PHASE_MESSAGE_IN)) { ncr_log("Phase match\n"); @@ -781,13 +781,13 @@ ncr_read(uint16_t port, void *priv) ret |= STATUS_ACK; if (bus & BUS_ATN) ret |= 0x02; - + if ((bus & BUS_REQ) && (ncr->mode & MODE_DMA)) { ncr_log("Entering DMA mode\n"); ret |= STATUS_DRQ; - + bus_state = 0; - + if (bus & BUS_IO) bus_state |= TCR_IO; if (bus & BUS_CD) @@ -828,14 +828,14 @@ ncr_read(uint16_t port, void *priv) /* Memory-mapped I/O READ handler. */ -static uint8_t +static uint8_t memio_read(uint32_t addr, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; ncr_t *ncr = &ncr_dev->ncr; scsi_device_t *dev = &scsi_devices[ncr_dev->bus][ncr->target_id]; uint8_t ret = 0xff; - + addr &= 0x3fff; if (addr < 0x2000) @@ -858,14 +858,14 @@ memio_read(uint32_t addr, void *priv) #endif ret = ncr_read(addr, ncr_dev); break; - + case 0x3900: if (ncr_dev->buffer_host_pos >= MIN(128, dev->buffer_length) || !(ncr_dev->status_ctrl & CTRL_DATA_DIR)) { ret = 0xff; } else { ret = ncr_dev->buffer[ncr_dev->buffer_host_pos++]; - if (ncr_dev->buffer_host_pos == MIN(128, dev->buffer_length)) { + if (ncr_dev->buffer_host_pos == MIN(128, dev->buffer_length)) { ncr_dev->status_ctrl |= STATUS_BUFFER_NOT_READY; ncr_log("Transfer busy read, status = %02x\n", ncr_dev->status_ctrl); } @@ -893,7 +893,7 @@ memio_read(uint32_t addr, void *priv) ret = 0xff; break; } - break; + break; } #if ENABLE_NCR5380_LOG @@ -906,13 +906,13 @@ memio_read(uint32_t addr, void *priv) /* Memory-mapped I/O WRITE handler. */ -static void +static void memio_write(uint32_t addr, uint8_t val, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; ncr_t *ncr = &ncr_dev->ncr; scsi_device_t *dev = &scsi_devices[ncr_dev->bus][ncr->target_id]; - + addr &= 0x3fff; ncr_log("memio_write(%08x,%02x) %i %02x\n", addr, val, ncr_dev->buffer_host_pos, ncr_dev->status_ctrl); @@ -927,7 +927,7 @@ memio_write(uint32_t addr, uint8_t val, void *priv) case 0x3880: ncr_write(addr, val, ncr_dev); break; - + case 0x3900: if (!(ncr_dev->status_ctrl & CTRL_DATA_DIR) && ncr_dev->buffer_host_pos < MIN(128, dev->buffer_length)) { ncr_dev->buffer[ncr_dev->buffer_host_pos++] = val; @@ -962,7 +962,7 @@ memio_write(uint32_t addr, uint8_t val, void *priv) if (ncr->mode & MODE_DMA) ncr_timer_on(ncr_dev, ncr, 0); - + if (ncr_dev->status_ctrl & CTRL_DATA_DIR) { ncr_dev->buffer_host_pos = MIN(128, dev->buffer_length); ncr_dev->status_ctrl |= STATUS_BUFFER_NOT_READY; @@ -972,13 +972,13 @@ memio_write(uint32_t addr, uint8_t val, void *priv) } break; } - break; + break; } } /* Memory-mapped I/O READ handler for the Trantor T130B. */ -static uint8_t +static uint8_t t130b_read(uint32_t addr, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; @@ -996,7 +996,7 @@ t130b_read(uint32_t addr, void *priv) /* Memory-mapped I/O WRITE handler for the Trantor T130B. */ -static void +static void t130b_write(uint32_t addr, uint8_t val, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; @@ -1008,7 +1008,7 @@ t130b_write(uint32_t addr, uint8_t val, void *priv) } -static uint8_t +static uint8_t t130b_in(uint16_t port, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; @@ -1021,8 +1021,8 @@ t130b_in(uint16_t port, void *priv) case 0x04: case 0x05: ret = memio_read(0x3900, ncr_dev); - break; - + break; + case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: ret = ncr_read(port, ncr_dev); @@ -1034,7 +1034,7 @@ t130b_in(uint16_t port, void *priv) } -static void +static void t130b_out(uint16_t port, uint8_t val, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; @@ -1048,8 +1048,8 @@ t130b_out(uint16_t port, uint8_t val, void *priv) case 0x04: case 0x05: memio_write(0x3900, val, ncr_dev); - break; - + break; + case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: ncr_write(port, val, ncr_dev); @@ -1062,7 +1062,7 @@ ncr_dma_send(ncr5380_t *ncr_dev, ncr_t *ncr, scsi_device_t *dev) { int bus, c = 0; uint8_t data; - + if (scsi_device_get_callback(dev) > 0.0) ncr_timer_on(ncr_dev, ncr, 1); else @@ -1147,7 +1147,7 @@ ncr_dma_initiator_receive(ncr5380_t *ncr_dev, ncr_t *ncr, scsi_device_t *dev) } else { ncr_timer_on(ncr_dev, ncr, 0); } - + for (c = 0; c < 10; c++) { ncr_bus_read(ncr_dev); if (ncr->cur_bus & BUS_REQ) @@ -1162,9 +1162,9 @@ ncr_dma_initiator_receive(ncr5380_t *ncr_dev, ncr_t *ncr, scsi_device_t *dev) ncr_bus_update(ncr_dev, bus | BUS_ACK); ncr_bus_update(ncr_dev, bus & ~BUS_ACK); - + if (ncr_dev->type == 3) { - ncr_dev->t128.buffer[ncr_dev->t128.pos++] = temp; + ncr_dev->t128.buffer[ncr_dev->t128.pos++] = temp; ncr_log("Buffer pos for reading = %d, temp = %02x\n", ncr_dev->t128.pos, temp); if (ncr_dev->t128.pos == MIN(512, dev->buffer_length)) { @@ -1186,10 +1186,10 @@ ncr_dma_initiator_receive(ncr5380_t *ncr_dev, ncr_t *ncr, scsi_device_t *dev) return; } } else { - ncr_dev->buffer[ncr_dev->buffer_pos++] = temp; + ncr_dev->buffer[ncr_dev->buffer_pos++] = temp; ncr_log("Buffer pos for reading = %d\n", ncr_dev->buffer_pos); - - if (ncr_dev->buffer_pos == MIN(128, dev->buffer_length)) { + + if (ncr_dev->buffer_pos == MIN(128, dev->buffer_length)) { ncr_dev->buffer_pos = 0; ncr_dev->buffer_host_pos = 0; ncr_dev->status_ctrl &= ~STATUS_BUFFER_NOT_READY; @@ -1249,7 +1249,7 @@ ncr_callback(void *priv) ncr_log("DMA_SEND with DMA direction set wrong\n"); break; } - + if (!(ncr_dev->status_ctrl & STATUS_BUFFER_NOT_READY)) { ncr_log("Write buffer status ready\n"); break; @@ -1262,7 +1262,7 @@ ncr_callback(void *priv) ncr_log("Write status busy\n"); break; } - + if (!ncr_dev->t128.block_loaded) { ncr_log("Write block not loaded\n"); break; @@ -1293,12 +1293,12 @@ ncr_callback(void *priv) ncr_log("Read status busy, block count = %i, host pos = %i\n", ncr_dev->t128.block_count, ncr_dev->t128.host_pos); break; } - + if (!ncr_dev->t128.block_loaded) { ncr_log("Read block not loaded\n"); break; } - + if (ncr_dev->t128.host_pos < MIN(512, dev->buffer_length)) break; } @@ -1316,7 +1316,7 @@ ncr_callback(void *priv) } } -static uint8_t +static uint8_t t128_read(uint32_t addr, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; @@ -1329,7 +1329,7 @@ t128_read(uint32_t addr, void *priv) ret = ncr_dev->bios_rom.rom[addr & 0x1fff]; else if (addr >= 0x1800 && addr < 0x1880) ret = ncr_dev->t128.ext_ram[addr & 0x7f]; - else if (addr >= 0x1c00 && addr < 0x1c20) { + else if (addr >= 0x1c00 && addr < 0x1c20) { ret = ncr_dev->t128.ctrl; } else if (addr >= 0x1c20 && addr < 0x1c40) { ret = ncr_dev->t128.status; @@ -1358,7 +1358,7 @@ t128_read(uint32_t addr, void *priv) ret = ncr_dev->t128.buffer[ncr_dev->t128.host_pos++]; ncr_log("Read transfer, addr = %i, pos = %i\n", addr & 0x1ff, ncr_dev->t128.host_pos); - + if (ncr_dev->t128.host_pos == MIN(512, dev->buffer_length)) { ncr_dev->t128.status &= ~0x04; ncr_log("Transfer busy read, status = %02x, period = %lf\n", ncr_dev->t128.status, ncr_dev->period); @@ -1368,17 +1368,17 @@ t128_read(uint32_t addr, void *priv) cycles += 100; /*Needed to avoid timer de-syncing with transfers.*/ } } - + return(ret); } -static void +static void t128_write(uint32_t addr, uint8_t val, void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; ncr_t *ncr = &ncr_dev->ncr; scsi_device_t *dev = &scsi_devices[ncr_dev->bus][ncr->target_id]; - + addr &= 0x3fff; if (addr >= 0x1800 && addr < 0x1880) ncr_dev->t128.ext_ram[addr & 0x7f] = val; @@ -1444,7 +1444,7 @@ ncr_init(const device_t *info) rom_init(&ncr_dev->bios_rom, LCS6821N_ROM, ncr_dev->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); - mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, + mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, memio_read, NULL, NULL, memio_write, NULL, NULL, ncr_dev->bios_rom.rom, MEM_MAPPING_EXTERNAL, ncr_dev); @@ -1454,16 +1454,16 @@ ncr_init(const device_t *info) ncr_dev->rom_addr = device_get_config_hex20("bios_addr"); ncr_dev->irq = device_get_config_int("irq"); ncr_dev->bios_ver = device_get_config_int("bios_ver"); - + if (ncr_dev->bios_ver == 1) fn = RT1000B_820R_ROM; else fn = RT1000B_810R_ROM; - + rom_init(&ncr_dev->bios_rom, fn, ncr_dev->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); - mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, + mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, memio_read, NULL, NULL, memio_write, NULL, NULL, ncr_dev->bios_rom.rom, MEM_MAPPING_EXTERNAL, ncr_dev); @@ -1478,7 +1478,7 @@ ncr_init(const device_t *info) rom_init(&ncr_dev->bios_rom, T130B_ROM, ncr_dev->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); - mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, + mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, t130b_read, NULL, NULL, t130b_write, NULL, NULL, ncr_dev->bios_rom.rom, MEM_MAPPING_EXTERNAL, ncr_dev); @@ -1492,12 +1492,12 @@ ncr_init(const device_t *info) ncr_dev->rom_addr = device_get_config_hex20("bios_addr"); ncr_dev->irq = device_get_config_int("irq"); ncr_dev->t128.bios_enabled = device_get_config_int("boot"); - + if (ncr_dev->t128.bios_enabled) rom_init(&ncr_dev->bios_rom, T128_ROM, ncr_dev->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); - mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, + mem_mapping_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, t128_read, NULL, NULL, t128_write, NULL, NULL, ncr_dev->bios_rom.rom, MEM_MAPPING_EXTERNAL, ncr_dev); @@ -1518,7 +1518,7 @@ ncr_init(const device_t *info) } else { ncr_dev->t128.status = 0x04; ncr_dev->t128.host_pos = 512; - + if (!ncr_dev->t128.bios_enabled) ncr_dev->t128.status |= 0x80; } @@ -1528,7 +1528,7 @@ ncr_init(const device_t *info) } -static void +static void ncr_close(void *priv) { ncr5380_t *ncr_dev = (ncr5380_t *)priv; diff --git a/src/scsi/scsi_ncr53c8xx.c b/src/scsi/scsi_ncr53c8xx.c index fe7ebb558..919a4ef05 100644 --- a/src/scsi/scsi_ncr53c8xx.c +++ b/src/scsi/scsi_ncr53c8xx.c @@ -286,7 +286,7 @@ typedef struct { ncr53c8xx_request *current; int irq; - + uint32_t dsa; uint32_t temp; uint32_t dnad; @@ -640,11 +640,11 @@ ncr53c8xx_command_complete(void *priv, uint32_t status) { ncr53c8xx_t *dev = (ncr53c8xx_t *)priv; int out; - + out = (dev->sstat1 & PHASE_MASK) == PHASE_DO; ncr53c8xx_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: Command complete status=%d\n", dev->current->tag, dev->current_lun, dev->last_command, (int)status); dev->status = status; - dev->command_complete = 2; + dev->command_complete = 2; if (dev->waiting && dev->dbc != 0) { /* Raise phase mismatch for short transfers. */ ncr53c8xx_bad_phase(dev, out, PHASE_ST); @@ -667,7 +667,7 @@ ncr53c8xx_do_dma(ncr53c8xx_t *dev, int out, uint8_t id) ncr53c8xx_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: Device not present when attempting to do DMA\n", id, dev->current_lun, dev->last_command); return; } - + if (!dev->current->dma_len) { /* Wait until data is available. */ ncr53c8xx_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: DMA no data available\n", id, dev->current_lun, dev->last_command); @@ -758,7 +758,7 @@ ncr53c8xx_do_command(ncr53c8xx_t *dev, uint8_t id) ncr53c8xx_bad_selection(dev, id); return 0; } - + dev->current = (ncr53c8xx_request*)malloc(sizeof(ncr53c8xx_request)); dev->current->tag = id; @@ -1068,7 +1068,7 @@ again: dev->dsps = addr; dev->dcmd = insn >> 24; dev->dsp += 8; - + switch (insn >> 30) { case 0: /* Block move. */ ncr53c8xx_log("00: Block move\n"); @@ -2002,7 +2002,7 @@ ncr53c8xx_io_readw(uint16_t addr, void *p) { ncr53c8xx_t *dev = (ncr53c8xx_t *)p; uint16_t val; - + addr &= 0xff; val = ncr53c8xx_reg_readb(dev, addr); val |= ncr53c8xx_reg_readb(dev, addr + 1) << 8; @@ -2015,7 +2015,7 @@ ncr53c8xx_io_readl(uint16_t addr, void *p) { ncr53c8xx_t *dev = (ncr53c8xx_t *)p; uint32_t val; - + addr &= 0xff; val = ncr53c8xx_reg_readb(dev, addr); val |= ncr53c8xx_reg_readb(dev, addr + 1) << 8; @@ -2036,7 +2036,7 @@ ncr53c8xx_io_writeb(uint16_t addr, uint8_t val, void *p) static void ncr53c8xx_io_writew(uint16_t addr, uint16_t val, void *p) { - ncr53c8xx_t *dev = (ncr53c8xx_t *)p; + ncr53c8xx_t *dev = (ncr53c8xx_t *)p; addr &= 0xff; ncr53c8xx_reg_writeb(dev, addr, val & 0xff); ncr53c8xx_reg_writeb(dev, addr + 1, (val >> 8) & 0xff); @@ -2120,7 +2120,7 @@ ncr53c8xx_mmio_readl(uint32_t addr, void *p) val = ncr53c8xx_reg_readb(dev, addr); val |= ncr53c8xx_reg_readb(dev, addr + 1) << 8; val |= ncr53c8xx_reg_readb(dev, addr + 2) << 16; - val |= ncr53c8xx_reg_readb(dev, addr + 3) << 24; + val |= ncr53c8xx_reg_readb(dev, addr + 3) << 24; return val; } @@ -2182,7 +2182,7 @@ ncr53c8xx_ram_readl(uint32_t addr, void *p) val = ncr53c8xx_ram_readb(addr, p); val |= ncr53c8xx_ram_readb(addr + 1, p) << 8; val |= ncr53c8xx_ram_readb(addr + 2, p) << 16; - val |= ncr53c8xx_ram_readb(addr + 3, p) << 24; + val |= ncr53c8xx_ram_readb(addr + 3, p) << 24; return val; } @@ -2392,7 +2392,7 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) return; } - switch (addr) + switch (addr) { case 0x04: valxor = (val & 0x57) ^ ncr53c8xx_pci_regs[addr]; @@ -2458,7 +2458,7 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) if (dev->MMIOBase != 0) ncr53c8xx_mem_set_addr(dev, dev->MMIOBase); } - return; + return; case 0x19: case 0x1A: case 0x1B: if (!dev->wide) @@ -2478,7 +2478,7 @@ ncr53c8xx_pci_write(int func, int addr, uint8_t val, void *p) if (dev->RAMBase != 0) ncr53c8xx_ram_set_addr(dev, dev->RAMBase); } - return; + return; case 0x30: case 0x31: case 0x32: case 0x33: if (dev->has_bios == 0) @@ -2567,13 +2567,13 @@ ncr53c8xx_init(const device_t *info) dev->wide = 0; } else if (dev->chip == CHIP_815) { dev->chip_rev = 0x04; - dev->nvr_path = "ncr53c815.nvr"; + dev->nvr_path = "ncr53c815.nvr"; dev->wide = 0; } ncr53c8xx_pci_bar[0].addr_regs[0] = 1; - ncr53c8xx_pci_bar[1].addr_regs[0] = 0; - ncr53c8xx_pci_regs[0x04] = 3; + ncr53c8xx_pci_bar[1].addr_regs[0] = 0; + ncr53c8xx_pci_regs[0x04] = 3; if (dev->has_bios == 2) { ncr53c8xx_pci_bar[3].addr = 0xffff0000; @@ -2595,7 +2595,7 @@ ncr53c8xx_init(const device_t *info) ncr53c8xx_ram_init(dev, 0x0ffff000); ncr53c8xx_ram_disable(dev); } - + if (dev->has_bios) ncr53c8xx_bios_disable(dev); @@ -2613,7 +2613,7 @@ ncr53c8xx_init(const device_t *info) } -static void +static void ncr53c8xx_close(void *priv) { ncr53c8xx_t *dev = (ncr53c8xx_t *)priv; diff --git a/src/scsi/scsi_pcscsi.c b/src/scsi/scsi_pcscsi.c index cd0b7e426..41bbd65b9 100644 --- a/src/scsi/scsi_pcscsi.c +++ b/src/scsi/scsi_pcscsi.c @@ -178,7 +178,7 @@ typedef struct { int32_t xfer_counter; int dma_enabled; - + uint32_t buffer_pos; uint32_t dma_regs[8]; uint32_t sbac; @@ -186,18 +186,18 @@ typedef struct { double period; pc_timer_t timer; - + int mca; uint16_t Base; uint8_t HostID, DmaChannel; - + struct { uint8_t mode; uint8_t status; int pos; } dma_86c01; - + uint8_t pos_regs[8]; } esp_t; @@ -364,7 +364,7 @@ esp_get_cmd(esp_t *dev, uint32_t maxlen) { uint8_t buf[ESP_CMDFIFO_SZ]; uint32_t dmalen, n; - + dev->id = dev->wregs[ESP_WBUSID] & BUSID_DID; if (dev->dma) { dmalen = MIN(esp_get_tc(dev), maxlen); @@ -410,20 +410,20 @@ esp_do_command_phase(esp_t *dev) scsi_device_t *sd; sd = &scsi_devices[dev->bus][dev->id]; - + sd->buffer_length = -1; - + cmdlen = fifo8_num_used(&dev->cmdfifo); if (!cmdlen) return; - + esp_fifo_pop_buf(&dev->cmdfifo, buf, cmdlen); - + for (int i = 0; i < cmdlen; i++) esp_log("CDB[%i] = %02x\n", i, buf[i]); scsi_device_command_phase0(sd, buf); - + dev->buffer_pos = 0; dev->ti_size = sd->buffer_length; dev->xfer_counter = sd->buffer_length; @@ -445,7 +445,7 @@ esp_do_command_phase(esp_t *dev) dev->rregs[ESP_RSTAT] |= STAT_DO; esp_log("ESP Data Out\n"); dev->ti_size = -sd->buffer_length; - esp_timer_on(dev, sd, scsi_device_get_callback(sd)); + esp_timer_on(dev, sd, scsi_device_get_callback(sd)); } esp_log("ESP SCSI Start reading/writing\n"); esp_do_dma(dev, sd); @@ -461,9 +461,9 @@ esp_do_command_phase(esp_t *dev) } else esp_pci_command_complete(dev, sd->status); } - + scsi_device_identify(sd, SCSI_LUN_USE_CDB); - + dev->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; esp_raise_irq(dev); } @@ -473,13 +473,13 @@ esp_do_message_phase(esp_t *dev) { int len; uint8_t message; - + if (dev->cmdfifo_cdb_offset) { message = esp_fifo_pop(&dev->cmdfifo); - + dev->lun = message & 7; dev->cmdfifo_cdb_offset--; - + if (scsi_device_present(&scsi_devices[dev->bus][dev->id]) && (dev->lun > 0)) { /* We only support LUN 0 */ esp_log("LUN = %i\n", dev->lun); @@ -490,10 +490,10 @@ esp_do_message_phase(esp_t *dev) fifo8_reset(&dev->cmdfifo); return; } - + scsi_device_identify(&scsi_devices[dev->bus][dev->id], dev->lun); - } - + } + esp_log("CDB offset = %i\n", dev->cmdfifo_cdb_offset); if (dev->cmdfifo_cdb_offset) { @@ -557,13 +557,13 @@ esp_do_nodma(esp_t *dev, scsi_device_t *sd) if (dev->do_cmd) { esp_log("ESP Command on FIFO\n"); dev->ti_size = 0; - + if ((dev->rregs[ESP_RSTAT] & 7) == STAT_CD) { if (dev->cmdfifo_cdb_offset == fifo8_num_used(&dev->cmdfifo)) { esp_log("CDB offset = %i used return\n", dev->cmdfifo_cdb_offset); return; } - + dev->do_cmd = 0; esp_do_cmd(dev); } else { @@ -600,13 +600,13 @@ esp_do_nodma(esp_t *dev, scsi_device_t *sd) dev->ti_size += count; dev->xfer_counter -= count; } - + esp_log("ESP FIFO Transfer bytes = %d\n", dev->xfer_counter); if (dev->xfer_counter <= 0) { if (sd->phase == SCSI_PHASE_DATA_OUT) { if (dev->ti_size < 0) { esp_log("ESP FIFO Keep writing\n"); - esp_do_nodma(dev, sd); + esp_do_nodma(dev, sd); } else { esp_log("ESP FIFO Write finished\n"); scsi_device_command_phase1(sd); @@ -661,9 +661,9 @@ esp_do_dma(esp_t *dev, scsi_device_t *sd) } else { esp_log("ESP SCSI device found on ID %d, LUN %d\n", dev->id, dev->lun); } - + count = tdbc = esp_get_tc(dev); - + if (dev->mca) { /*See the comment in the esp_do_busid_cmd() function.*/ if (sd->buffer_length < 0) { if (dev->dma_enabled) @@ -686,11 +686,11 @@ esp_do_dma(esp_t *dev, scsi_device_t *sd) esp_pci_dma_memory_rw(dev, buf, count, READ_FROM_DEVICE); fifo8_push_all(&dev->cmdfifo, buf, count); dev->ti_size = 0; - + if ((dev->rregs[ESP_RSTAT] & 7) == STAT_CD) { if (dev->cmdfifo_cdb_offset == fifo8_num_used(&dev->cmdfifo)) return; - + dev->do_cmd = 0; esp_do_cmd(dev); } else { @@ -711,7 +711,7 @@ esp_do_dma(esp_t *dev, scsi_device_t *sd) } esp_log("ESP SCSI dmaleft = %d, async_len = %i, buffer length = %d\n", esp_get_tc(dev), sd->buffer_length); - + /* Make sure count is never bigger than buffer_length. */ if (count > dev->xfer_counter) count = dev->xfer_counter; @@ -739,7 +739,7 @@ esp_do_dma(esp_t *dev, scsi_device_t *sd) } dev->dma_86c01.pos = 0; } else - esp_pci_dma_memory_rw(dev, sd->sc->temp_buffer + dev->buffer_pos, count, WRITE_TO_DEVICE); + esp_pci_dma_memory_rw(dev, sd->sc->temp_buffer + dev->buffer_pos, count, WRITE_TO_DEVICE); } esp_set_tc(dev, esp_get_tc(dev) - count); dev->buffer_pos += count; @@ -749,13 +749,13 @@ esp_do_dma(esp_t *dev, scsi_device_t *sd) } else if (sd->phase == SCSI_PHASE_DATA_OUT) { dev->ti_size += count; } - + esp_log("ESP SCSI Transfer bytes = %d\n", dev->xfer_counter); if (dev->xfer_counter <= 0) { if (sd->phase == SCSI_PHASE_DATA_OUT) { if (dev->ti_size < 0) { esp_log("ESP SCSI Keep writing\n"); - esp_do_dma(dev, sd); + esp_do_dma(dev, sd); } else { esp_log("ESP SCSI Write finished\n"); scsi_device_command_phase1(sd); @@ -783,7 +783,7 @@ done: } } else { /* Partially filled a scsi buffer. Complete immediately. */ -partial: +partial: esp_log("ESP SCSI Partially filled the SCSI buffer\n"); esp_dma_done(dev); } @@ -794,7 +794,7 @@ static void esp_report_command_complete(esp_t *dev, uint32_t status) { esp_log("ESP Command complete\n"); - + dev->ti_size = 0; dev->status = status; dev->rregs[ESP_RSTAT] = STAT_TC | STAT_ST; @@ -814,7 +814,7 @@ static void esp_pci_command_complete(void *priv, uint32_t status) { esp_t *dev = (esp_t *)priv; - + esp_command_complete(dev, status); dev->dma_regs[DMA_WBC] = 0; dev->dma_regs[DMA_STAT] |= DMA_STAT_DONE; @@ -916,7 +916,7 @@ static void esp_write_response(esp_t *dev) { uint8_t buf[2]; - + buf[0] = dev->status; buf[1] = 0; @@ -927,7 +927,7 @@ esp_write_response(esp_t *dev) buf[dev->dma_86c01.pos++] = val & 0xff; } dev->dma_86c01.pos = 0; - } else + } else esp_pci_dma_memory_rw(dev, buf, 2, WRITE_TO_DEVICE); dev->rregs[ESP_RSTAT] = STAT_TC | STAT_ST; dev->rregs[ESP_RINTR] = INTR_BS | INTR_FC; @@ -952,7 +952,7 @@ esp_callback(void *p) handle_ti(dev); } } - + esp_log("ESP DMA activated = %d, CMD activated = %d\n", dev->dma_enabled, dev->do_cmd); } @@ -975,7 +975,7 @@ esp_reg_read(esp_t *dev, uint32_t saddr) dev->rregs[ESP_RSTAT] = STAT_TC | STAT_ST; } } - + dev->rregs[ESP_FIFO] = esp_fifo_pop(&dev->fifo); ret = dev->rregs[ESP_FIFO]; break; @@ -1003,7 +1003,7 @@ esp_reg_read(esp_t *dev, uint32_t saddr) default: ret = dev->rregs[saddr]; break; - + } esp_log("Read reg %02x = %02x\n", saddr, ret); return ret; @@ -1073,7 +1073,7 @@ esp_reg_write(esp_t *dev, uint32_t saddr, uint32_t val) break; case CMD_BUSRESET: if (!(dev->wregs[ESP_CFG1] & CFG1_RESREPT)) { - dev->rregs[ESP_RINTR] |= INTR_RST; + dev->rregs[ESP_RINTR] |= INTR_RST; esp_log("ESP Bus Reset with IRQ\n"); esp_raise_irq(dev); } @@ -1175,15 +1175,15 @@ esp_pci_dma_memory_rw(esp_t *dev, uint8_t *buf, uint32_t len, int dir) dev->dma_regs[DMA_WAC] += len; if (dev->dma_regs[DMA_WBC] == 0) dev->dma_regs[DMA_STAT] |= DMA_STAT_DONE; -} +} static uint32_t -esp_pci_dma_read(esp_t *dev, uint16_t saddr) +esp_pci_dma_read(esp_t *dev, uint16_t saddr) { uint32_t ret; - + ret = dev->dma_regs[saddr]; - + if (saddr == DMA_STAT) { if (dev->rregs[ESP_RSTAT] & STAT_INT) { ret |= DMA_STAT_SCSIINT; @@ -1195,7 +1195,7 @@ esp_pci_dma_read(esp_t *dev, uint16_t saddr) esp_log("ESP PCI DMA Read done cleared\n"); } } - + esp_log("ESP PCI DMA Read regs addr = %04x, temp = %06x\n", saddr, ret); return ret; } @@ -1203,8 +1203,8 @@ esp_pci_dma_read(esp_t *dev, uint16_t saddr) static void esp_pci_dma_write(esp_t *dev, uint16_t saddr, uint32_t val) { - uint32_t mask; - + uint32_t mask; + switch (saddr) { case DMA_CMD: dev->dma_regs[saddr] = val; @@ -1268,12 +1268,12 @@ esp_pci_hard_reset(esp_t *dev) } static uint32_t -esp_io_pci_read(esp_t *dev, uint32_t addr, unsigned int size) +esp_io_pci_read(esp_t *dev, uint32_t addr, unsigned int size) { uint32_t ret; - + addr &= 0x7f; - + if (addr < 0x40) { /* SCSI core reg */ ret = esp_reg_read(dev, addr >> 2); @@ -1289,18 +1289,18 @@ esp_io_pci_read(esp_t *dev, uint32_t addr, unsigned int size) /* Invalid region */ ret = 0; } - + /* give only requested data */ ret >>= (addr & 3) * 8; - ret &= ~(~(uint64_t)0 << (8 * size)); - + ret &= ~(~(uint64_t)0 << (8 * size)); + esp_log("ESP PCI I/O read: addr = %02x, val = %02x\n", addr, ret); return ret; } static void -esp_io_pci_write(esp_t *dev, uint32_t addr, uint32_t val, unsigned int size) -{ +esp_io_pci_write(esp_t *dev, uint32_t addr, uint32_t val, unsigned int size) +{ uint32_t current, mask; int shift; @@ -1450,10 +1450,10 @@ dc390_write_eeprom(esp_t *dev, int ena, int clk, int dat) uint8_t eedo = eeprom->out; uint16_t address = eeprom->address; uint8_t command = eeprom->opcode; - + esp_log("EEPROM CS=%02x,SK=%02x,DI=%02x,DO=%02x,tick=%d\n", ena, clk, dat, eedo, tick); - + if (!eeprom->oldena && ena) { esp_log("EEPROM Start chip select cycle\n"); tick = 0; @@ -1466,7 +1466,7 @@ dc390_write_eeprom(esp_t *dev, int ena, int clk, int dat) esp_log("EEPROM Erase All\n"); for (address = 0; address < 64; address++) eeprom->data[address] = 0xffff; - dc390_save_eeprom(dev); + dc390_save_eeprom(dev); } else if (command == 3) { esp_log("EEPROM Erase Word\n"); eeprom->data[address] = 0xffff; @@ -1480,7 +1480,7 @@ dc390_write_eeprom(esp_t *dev, int ena, int clk, int dat) esp_log("EEPROM Write All\n"); for (address = 0; address < 64; address++) eeprom->data[address] &= eeprom->dat; - dc390_save_eeprom(dev); + dc390_save_eeprom(dev); } } } @@ -1550,7 +1550,7 @@ dc390_write_eeprom(esp_t *dev, int ena, int clk, int dat) esp_log("EEPROM Additional unneeded tick, not processed\n"); } } - + eeprom->count = tick; eeprom->oldena = ena; eeprom->oldclk = clk; @@ -1582,9 +1582,9 @@ dc390_load_eeprom(esp_t *dev) nvr[i * 2] = 0x57; nvr[i * 2 + 1] = 0x00; } - + esp_log("EEPROM Defaults\n"); - + nvr[EE_ADAPT_SCSI_ID] = 7; nvr[EE_MODE2] = 0x0f; nvr[EE_TAG_CMD_NUM] = 0x04; @@ -1595,12 +1595,12 @@ dc390_load_eeprom(esp_t *dev) checksum += ((nvr[i] & 0xff) | (nvr[i + 1] << 8)); esp_log("Checksum calc = %04x, nvr = %02x\n", checksum, nvr[i]); } - + checksum = 0x1234 - checksum; nvr[EE_CHKSUM1] = checksum & 0xff; nvr[EE_CHKSUM2] = checksum >> 8; esp_log("EEPROM Checksum = %04x\n", checksum); - } + } } uint8_t esp_pci_regs[256]; @@ -1759,7 +1759,7 @@ esp_pci_write(int func, int addr, uint8_t val, void *p) dev->irq = val; esp_log("ESP IRQ now: %i\n", val); return; - + case 0x40 ... 0x4f: esp_pci_regs[addr] = val; return; @@ -1775,12 +1775,12 @@ dc390_init(const device_t *info) memset(dev, 0x00, sizeof(esp_t)); dev->bus = scsi_get_bus(); - + dev->mca = 0; - + fifo8_create(&dev->fifo, ESP_FIFO_SZ); - fifo8_create(&dev->cmdfifo, ESP_CMDFIFO_SZ); - + fifo8_create(&dev->cmdfifo, ESP_CMDFIFO_SZ); + dev->PCIBase = 0; dev->MMIOBase = 0; @@ -1820,9 +1820,9 @@ ncr53c90_in(uint16_t port, void *priv) { esp_t *dev = (esp_t *)priv; uint16_t ret = 0; - + port &= 0x1f; - + if (port >= 0x10) ret = esp_reg_read(dev, port - 0x10); else { @@ -1830,15 +1830,15 @@ ncr53c90_in(uint16_t port, void *priv) case 0x02: ret = dev->dma_86c01.mode; break; - + case 0x0c: ret = dev->dma_86c01.status; break; } } - - esp_log("[%04X:%08X]: NCR53c90 DMA read port = %02x, ret = %02x\n", CS, cpu_state.pc, port, ret); - + + esp_log("[%04X:%08X]: NCR53c90 DMA read port = %02x, ret = %02x\n", CS, cpu_state.pc, port, ret); + return ret; } @@ -1861,7 +1861,7 @@ ncr53c90_out(uint16_t port, uint16_t val, void *priv) port &= 0x1f; - esp_log("[%04X:%08X]: NCR53c90 DMA write port = %02x, val = %02x\n", CS, cpu_state.pc, port, val); + esp_log("[%04X:%08X]: NCR53c90 DMA write port = %02x, val = %02x\n", CS, cpu_state.pc, port, val); if (port >= 0x10) esp_reg_write(dev, port - 0x10, val); @@ -1909,7 +1909,7 @@ ncr53c90_mca_write(int port, uint8_t val, void *priv) dev->pos_regs[port & 7] = val; /* This is always necessary so that the old handler doesn't remain. */ - if (dev->Base != 0) { + if (dev->Base != 0) { io_removehandler(dev->Base, 0x20, ncr53c90_inb, ncr53c90_inw, NULL, ncr53c90_outb, ncr53c90_outw, NULL, dev); @@ -1922,8 +1922,8 @@ ncr53c90_mca_write(int port, uint8_t val, void *priv) dev->irq = 3 + (2 * ((dev->pos_regs[2] & 0x30) >> 4)); if (dev->irq == 9) dev->irq = 2; - - dev->DmaChannel = dev->pos_regs[3] & 0x0f; + + dev->DmaChannel = dev->pos_regs[3] & 0x0f; /* * Get misc SCSI config stuff. For now, we are only @@ -1967,14 +1967,14 @@ ncr53c90_mca_init(const device_t *info) memset(dev, 0x00, sizeof(esp_t)); dev->bus = scsi_get_bus(); - + dev->mca = 1; fifo8_create(&dev->fifo, ESP_FIFO_SZ); fifo8_create(&dev->cmdfifo, ESP_CMDFIFO_SZ); dev->pos_regs[0] = 0x4d; /* MCA board ID */ - dev->pos_regs[1] = 0x7f; + dev->pos_regs[1] = 0x7f; mca_add(ncr53c90_mca_read, ncr53c90_mca_write, ncr53c90_mca_feedb, NULL, dev); esp_hard_reset(dev); @@ -1984,15 +1984,15 @@ ncr53c90_mca_init(const device_t *info) return(dev); } -static void +static void esp_close(void *priv) { esp_t *dev = (esp_t *)priv; if (dev) { fifo8_destroy(&dev->fifo); - fifo8_destroy(&dev->cmdfifo); - + fifo8_destroy(&dev->cmdfifo); + free(dev); dev = NULL; } diff --git a/src/scsi/scsi_spock.c b/src/scsi/scsi_spock.c index 548cacf96..849b4c953 100644 --- a/src/scsi/scsi_spock.c +++ b/src/scsi/scsi_spock.c @@ -101,26 +101,26 @@ typedef struct { typedef struct { rom_t bios_rom; - + int bios_ver; int irq, irq_inactive; - + uint8_t pos_regs[8]; uint8_t basic_ctrl; uint32_t command; - + uint8_t attention, attention_pending; int attention_wait; - + uint8_t cir[4], cir_pending[4]; uint8_t irq_status; - + uint32_t scb_addr; - + uint8_t status; get_complete_stat_t get_complete_stat; @@ -153,16 +153,16 @@ typedef struct { int irq_requests[SCSI_ID_MAX]; pc_timer_t callback_timer; - + int cmd_timer; - + int scb_state; int in_reset; int in_invalid; uint64_t temp_period; double media_period; - + scsi_state_t scsi_state; } spock_t; @@ -265,7 +265,7 @@ spock_rethink_irqs(spock_t *scsi) } } -static __inline void +static __inline void spock_set_irq(spock_t *scsi, int id, int type) { spock_log("spock_set_irq id=%i type=%x %02x\n", id, type, scsi->irq_status); @@ -274,7 +274,7 @@ spock_set_irq(spock_t *scsi, int id, int type) spock_rethink_irqs(scsi); } -static __inline void +static __inline void spock_clear_irq(spock_t *scsi, int id) { spock_log("spock_clear_irq id=%i\n", id); @@ -294,7 +294,7 @@ spock_write(uint16_t port, uint8_t val, void *p) spock_t *scsi = (spock_t *)p; spock_log("spock_write: port=%04x val=%02x %04x:%04x\n", port, val, CS, cpu_state.pc); - + switch (port & 7) { case 0: case 1: case 2: case 3: /*Command Interface Register*/ scsi->cir_pending[port & 3] = val; @@ -309,7 +309,7 @@ spock_write(uint16_t port, uint8_t val, void *p) scsi->attention_wait = 2; scsi->status |= STATUS_BUSY; break; - + case 5: /*Basic Control Register*/ if ((scsi->basic_ctrl & CTRL_RESET) && !(val & CTRL_RESET)) { spock_log("Spock: SCSI reset and busy\n"); @@ -350,7 +350,7 @@ spock_read(uint16_t port, void *p) { spock_t *scsi = (spock_t *)p; uint8_t temp = 0xff; - + switch (port & 7) { case 0: case 1: case 2: case 3: /*Command Interface Register*/ temp = scsi->cir_pending[port & 3]; @@ -378,9 +378,9 @@ spock_read(uint16_t port, void *p) } break; } - + spock_log("spock_read: port=%04x val=%02x %04x(%05x):%04x %02x\n", port, temp, CS, cs, cpu_state.pc, BH); - return temp; + return temp; } static uint16_t @@ -397,9 +397,9 @@ spock_readw(uint16_t port, void *p) temp = scsi->cir_pending[2] | (scsi->cir_pending[3] << 8); break; } - + spock_log("spock_readw: port=%04x val=%04x\n", port, temp); - return temp; + return temp; } static void @@ -423,7 +423,7 @@ spock_get_len(spock_t *scsi, scb_t *scb) if (scb->enable & ENABLE_PT) { for (i = 0; i < scsi->data_len; i += 8) { spock_rd_sge(scsi, scsi->data_ptr + i, &scb->sge); - + DataToTransfer += scb->sge.sys_buf_byte_count; } return(DataToTransfer); @@ -437,13 +437,13 @@ spock_process_imm_cmd(spock_t *scsi) { int i; int adapter_id, phys_id, lun_id; - + switch (scsi->command & CMD_MASK) { case CMD_ASSIGN: adapter_id = (scsi->command >> 16) & 15; phys_id = (scsi->command >> 20) & 7; lun_id = (scsi->command >> 24) & 7; - + if (adapter_id == 15) { if (phys_id == 7) /*Device 15 always adapter*/ spock_set_irq(scsi, scsi->attention & 0x0f, IRQ_TYPE_IMM_CMD_COMPLETE); @@ -490,13 +490,13 @@ spock_process_imm_cmd(spock_t *scsi) for (i = 0; i < 8; i++) scsi_device_reset(&scsi_devices[scsi->bus][i]); spock_log("Adapter Reset\n"); - + if (!scsi->adapter_reset && scsi->bios_ver) /*The early 1990 bios must have its boot drive set to ID 6 according https://www.ardent-tool.com/IBM_SCSI/SCSI-A.html */ scsi->adapter_reset = 1; else scsi->adapter_reset = 0; - + scsi->scb_state = 0; } spock_set_irq(scsi, scsi->attention & 0x0f, IRQ_TYPE_IMM_CMD_COMPLETE); @@ -540,24 +540,24 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) scsi->in_reset = 0; return; } - + if (scsi->in_invalid) { spock_log("Invalid command\n"); spock_set_irq(scsi, scsi->attention & 0x0f, IRQ_TYPE_COMMAND_ERROR); scsi->in_invalid = 0; return; } - + spock_log("SCB State = %d\n", scsi->scb_state); - + do { old_scb_state = scsi->scb_state; - + switch (scsi->scb_state) { case 0: /* Idle */ break; - + case 1: /* Select */ if (scsi->dev_id[scsi->scb_id].phys_id == -1) { uint16_t term_stat_block_addr7 = (0xe << 8) | 0; @@ -570,7 +570,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) dma_bm_write(scb->term_status_block_addr + 0x8*2, (uint8_t *)&term_stat_block_addr8, 2, 2); break; } - + dma_bm_read(scsi->scb_addr, (uint8_t *)&scb->command, 2, 2); dma_bm_read(scsi->scb_addr + 2, (uint8_t *)&scb->enable, 2, 2); dma_bm_read(scsi->scb_addr + 4, (uint8_t *)&scb->lba_addr, 4, 2); @@ -596,13 +596,13 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) scb->sge.sys_buf_addr, scb->sge.sys_buf_byte_count, scb->term_status_block_addr, scb->scb_chain_addr, scb->block_count, scb->block_length, scsi->scb_id); - + switch (scb->command & CMD_MASK) { case CMD_GET_COMPLETE_STATUS: { spock_log("Get Complete Status\n"); get_complete_stat_t *get_complete_stat = &scsi->get_complete_stat; - + get_complete_stat->scb_status = 0x201; get_complete_stat->retry_count = 0; get_complete_stat->residual_byte_count = 0; @@ -644,7 +644,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) { spock_log("Get POS Info\n"); get_pos_info_t *get_pos_info = &scsi->get_pos_info; - + get_pos_info->pos = 0x8eff; get_pos_info->pos1 = scsi->pos_regs[3] | (scsi->pos_regs[2] << 8); get_pos_info->pos2 = 0x0e | (scsi->pos_regs[4] << 8); @@ -654,7 +654,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) get_pos_info->pos6 = (30 << 8) | 1; get_pos_info->pos7 = 0; get_pos_info->pos8 = 0; - + dma_bm_write(scb->sge.sys_buf_addr, (uint8_t *)&get_pos_info->pos, 2, 2); dma_bm_write(scb->sge.sys_buf_addr + 2, (uint8_t *)&get_pos_info->pos1, 2, 2); dma_bm_write(scb->sge.sys_buf_addr + 4, (uint8_t *)&get_pos_info->pos2, 2, 2); @@ -693,7 +693,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) scsi->cdb_id = scsi->scb_id; } else { scsi->cdb_id = scsi->dev_id[scsi->scb_id].phys_id; - } + } spock_log("Send Other SCSI, ID=%d\n", scsi->cdb_id); dma_bm_read(scsi->scb_addr + 0x18, scsi->cdb, 12, 2); scsi->cdb[1] = (scsi->cdb[1] & 0x1f) | (scsi->dev_id[scsi->scb_id].lun_id << 5); /*Patch correct LUN into command*/ @@ -758,7 +758,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) scsi->scsi_state = SCSI_STATE_SELECT; scsi->scb_state = 2; return; - + case CMD_VERIFY: spock_log("Device Verify\n"); scsi->cdb[0] = GPCMD_VERIFY_10; @@ -777,7 +777,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) scsi->scsi_state = SCSI_STATE_SELECT; scsi->scb_state = 2; return; - + case CMD_REQUEST_SENSE: if (scsi->adapter_reset) scsi->cdb_id = scsi->scb_id; @@ -796,7 +796,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) return; } break; - + case 2: /* Wait */ if (scsi->scsi_state == SCSI_STATE_IDLE && scsi_device_present(&scsi_devices[scsi->bus][scsi->cdb_id])) { if (scsi->last_status == SCSI_STATUS_OK) { @@ -807,7 +807,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) uint16_t term_stat_block_addr8 = 0x20; uint16_t term_stat_block_addrb = scsi->scb_addr & 0xffff; uint16_t term_stat_block_addrc = scsi->scb_addr >> 16; - + spock_set_irq(scsi, scsi->scb_id, IRQ_TYPE_COMMAND_FAIL); scsi->scb_state = 0; spock_log("Status Check Condition on device ID %d\n", scsi->cdb_id); @@ -825,7 +825,7 @@ spock_execute_cmd(spock_t *scsi, scb_t *scb) dma_bm_write(scb->term_status_block_addr + 0x8*2, (uint8_t *)&term_stat_block_addr8, 2, 2); } break; - + case 3: /* Complete */ if (scb->enable & 1) { scsi->scb_state = 1; @@ -851,7 +851,7 @@ spock_process_scsi(spock_t *scsi, scb_t *scb) switch (scsi->scsi_state) { case SCSI_STATE_IDLE: break; - + case SCSI_STATE_SELECT: spock_log("Selecting ID %d\n", scsi->cdb_id); if ((scsi->cdb_id != (uint8_t)-1) && scsi_device_present(&scsi_devices[scsi->bus][scsi->cdb_id])) { @@ -881,38 +881,38 @@ spock_process_scsi(spock_t *scsi, scb_t *scb) 12); spock_add_to_period(scsi, 12); } - + scsi->data_ptr = scb->sge.sys_buf_addr; scsi->data_len = scb->sge.sys_buf_byte_count; - + if (scb->enable & 0x400) sd->buffer_length = -1; else sd->buffer_length = spock_get_len(scsi, scb); - + scsi_device_command_phase0(sd, scsi->temp_cdb); spock_log("SCSI ID %i: Current CDB[0] = %02x, LUN = %i, data len = %i, max len = %i, phase val = %02x\n", scsi->cdb_id, scsi->temp_cdb[0], scsi->temp_cdb[1] >> 5, sd->buffer_length, spock_get_len(scsi, scb), sd->phase); - + if (sd->phase != SCSI_PHASE_STATUS && sd->buffer_length > 0) { p = scsi_device_get_callback(sd); if (p <= 0.0) spock_add_to_period(scsi, sd->buffer_length); else scsi->media_period += p; - + if (scb->enable & ENABLE_PT) { int32_t buflen = sd->buffer_length; int sg_pos = 0; uint32_t DataTx = 0; uint32_t Address; - + if (scb->sge.sys_buf_byte_count > 0) { for (c = 0; c < scsi->data_len; c += 8) { spock_rd_sge(scsi, scsi->data_ptr + c, &scb->sge); - + Address = scb->sge.sys_buf_addr; DataTx = MIN((int) scb->sge.sys_buf_byte_count, buflen); - + if ((sd->phase == SCSI_PHASE_DATA_IN) && DataTx) { spock_log("Writing S/G segment %i: length %i, pointer %08X\n", c, DataTx, Address); dma_bm_write(Address, &sd->sc->temp_buffer[sg_pos], DataTx, 2); @@ -920,10 +920,10 @@ spock_process_scsi(spock_t *scsi, scb_t *scb) spock_log("Reading S/G segment %i: length %i, pointer %08X\n", c, DataTx, Address); dma_bm_read(Address, &sd->sc->temp_buffer[sg_pos], DataTx, 2); } - + sg_pos += scb->sge.sys_buf_byte_count; buflen -= scb->sge.sys_buf_byte_count; - + if (buflen < 0) buflen = 0; } @@ -967,7 +967,7 @@ spock_callback(void *priv) if (scsi->cmd_timer) { scsi->cmd_timer--; if (!scsi->cmd_timer) { - spock_execute_cmd(scsi, scb); + spock_execute_cmd(scsi, scb); } } @@ -982,7 +982,7 @@ spock_callback(void *priv) scsi->cir[2] = scsi->cir_pending[2]; scsi->cir[3] = scsi->cir_pending[3]; scsi->cir_status = 0; - + switch (scsi->attention >> 4) { case 1: /*Immediate command*/ scsi->cmd_status = 0x0a; @@ -997,7 +997,7 @@ spock_callback(void *priv) break; } break; - + case 3: case 4: case 0x0f: /*Start SCB*/ scsi->cmd_status = 1; scsi->scb_addr = scsi->cir[0] | (scsi->cir[1] << 8) | (scsi->cir[2] << 16) | (scsi->cir[3] << 24); @@ -1006,7 +1006,7 @@ spock_callback(void *priv) spock_log("Start SCB at ID = %d\n", scsi->scb_id); scsi->scb_state = 1; break; - + case 5: /*Invalid*/ case 0x0a: /*Invalid*/ scsi->in_invalid = 1; @@ -1022,13 +1022,13 @@ spock_callback(void *priv) } spock_process_scsi(scsi, scb); - + period = 0.2 * ((double) scsi->temp_period); timer_on(&scsi->callback_timer, (scsi->media_period + period + 10.0), 0); spock_log("Temporary period: %lf us (%" PRIi64 " periods)\n", scsi->callback_timer.period, scsi->temp_period); } -static void +static void spock_mca_write(int port, uint8_t val, void *priv) { spock_t *scsi = (spock_t *)priv; @@ -1038,7 +1038,7 @@ spock_mca_write(int port, uint8_t val, void *priv) io_removehandler((((scsi->pos_regs[2] >> 1) & 7) * 8) + 0x3540, 0x0008, spock_read, spock_readw, NULL, spock_write, spock_writew, NULL, scsi); mem_mapping_disable(&scsi->bios_rom.mapping); - + scsi->pos_regs[port & 7] = val; scsi->adapter_id = (scsi->pos_regs[3] & 0xe0) >> 5; @@ -1053,7 +1053,7 @@ spock_mca_write(int port, uint8_t val, void *priv) } } -static uint8_t +static uint8_t spock_mca_read(int port, void *priv) { spock_t *scsi = (spock_t *)priv; @@ -1074,7 +1074,7 @@ spock_mca_reset(void *priv) { spock_t *scsi = (spock_t *)priv; int i; - + scsi->in_reset = 2; scsi->cmd_timer = SPOCK_TIME * 50; scsi->status = STATUS_BUSY; @@ -1087,7 +1087,7 @@ spock_mca_reset(void *priv) /* Reset all devices on controller reset. */ for (i = 0; i < 8; i++) scsi_device_reset(&scsi_devices[scsi->bus][i]); - + scsi->adapter_reset = 0; } @@ -1101,9 +1101,9 @@ spock_init(const device_t *info) scsi->bus = scsi_get_bus(); scsi->irq = 14; - + scsi->bios_ver = device_get_config_int("bios_ver"); - + switch (scsi->bios_ver) { case 1: rom_init_interleaved(&scsi->bios_rom, SPOCK_U68_1991_ROM, SPOCK_U69_1991_ROM, @@ -1128,28 +1128,28 @@ spock_init(const device_t *info) for (c = 0; c < (SCSI_ID_MAX-1); c++) { scsi->dev_id[c].phys_id = -1; } - + scsi->dev_id[SCSI_ID_MAX-1].phys_id = scsi->adapter_id; timer_add(&scsi->callback_timer, spock_callback, scsi, 1); scsi->callback_timer.period = 10.0; timer_set_delay_u64(&scsi->callback_timer, (uint64_t) (scsi->callback_timer.period * ((double) TIMER_USEC))); - + return scsi; } -static void +static void spock_close(void *p) { spock_t *scsi = (spock_t *)p; - + if (scsi) { free(scsi); scsi = NULL; } } -static int +static int spock_available(void) { return rom_present(SPOCK_U68_1991_ROM) && rom_present(SPOCK_U69_1991_ROM) && diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index c8dd945f5..5cd1f6d8f 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -545,7 +545,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) break; } - + x54x_log("BIOS Request %02X complete: %02X\n", cmd->command, ret); return(ret); } @@ -622,7 +622,7 @@ x54x_ccb(x54x_t *dev) static void x54x_mbi(x54x_t *dev) -{ +{ Req_t *req = &dev->Req; // uint32_t CCBPointer = req->CCBPointer; addr24 CCBPointer; @@ -1073,7 +1073,7 @@ x54x_notify(x54x_t *dev) static void x54x_req_setup(x54x_t *dev, uint32_t CCBPointer, Mailbox32_t *Mailbox32) -{ +{ Req_t *req = &dev->Req; uint8_t id, lun; scsi_device_t *sd; @@ -1112,8 +1112,8 @@ x54x_req_setup(x54x_t *dev, uint32_t CCBPointer, Mailbox32_t *Mailbox32) scsi_device_identify(sd, lun); x54x_log("Transfer Control %02X\n", req->CmdBlock.common.ControlByte); - x54x_log("CDB Length %i\n", req->CmdBlock.common.CdbLength); - x54x_log("CCB Opcode %x\n", req->CmdBlock.common.Opcode); + x54x_log("CDB Length %i\n", req->CmdBlock.common.CdbLength); + x54x_log("CCB Opcode %x\n", req->CmdBlock.common.Opcode); if ((req->CmdBlock.common.Opcode > 0x04) && (req->CmdBlock.common.Opcode != 0x81)) { x54x_log("Invalid opcode: %02X\n", req->CmdBlock.common.ControlByte); @@ -1152,7 +1152,7 @@ x54x_req_abort(x54x_t *dev, uint32_t CCBPointer) static uint32_t x54x_mbo(x54x_t *dev, Mailbox32_t *Mailbox32) -{ +{ Mailbox_t MailboxOut; uint32_t Outgoing; uint32_t ccbp; @@ -1569,7 +1569,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) case CMD_ECHO: case CMD_OPTIONS: dev->CmdParamLeft = 1; - break; + break; case CMD_SELTIMEOUT: dev->CmdParamLeft = 4; @@ -1593,7 +1593,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) if (dev->ven_cmd_phase1) dev->ven_cmd_phase1(dev); } - + if (! dev->CmdParamLeft) { x54x_log("Running Operation Code 0x%02X\n", dev->Command); switch (dev->Command) { @@ -1941,7 +1941,7 @@ x54x_init(const device_t *info) dev->card_bus = info->flags; dev->callback_phase = 0; - + timer_add(&dev->ResetCB, x54x_reset_poll, dev, 0); timer_add(&dev->timer, x54x_cmd_callback, dev, 1); dev->timer.period = 10.0; diff --git a/src/sio/CMakeLists.txt b/src/sio/CMakeLists.txt index 482c2c2d6..52677a544 100644 --- a/src/sio/CMakeLists.txt +++ b/src/sio/CMakeLists.txt @@ -23,4 +23,4 @@ add_library(sio OBJECT sio_acc3221.c sio_f82c710.c sio_82091aa.c sio_fdc37c6xx.c if(SIO_DETECT) target_sources(sio PRIVATE sio_detect.c) -endif() \ No newline at end of file +endif() diff --git a/src/sio/sio_acc3221.c b/src/sio/sio_acc3221.c index 17536690c..77928a313 100644 --- a/src/sio/sio_acc3221.c +++ b/src/sio/sio_acc3221.c @@ -349,10 +349,10 @@ acc3221_serial2_handler(acc3221_t *dev) } -static void +static void acc3221_write(uint16_t addr, uint8_t val, void *p) { - acc3221_t *dev = (acc3221_t *)p; + acc3221_t *dev = (acc3221_t *)p; uint8_t old; if (!(addr & 1)) @@ -416,10 +416,10 @@ acc3221_write(uint16_t addr, uint8_t val, void *p) } -static uint8_t +static uint8_t acc3221_read(uint16_t addr, void *p) { - acc3221_t *dev = (acc3221_t *)p; + acc3221_t *dev = (acc3221_t *)p; if (!(addr & 1)) return dev->reg_idx; @@ -439,7 +439,7 @@ acc3221_reset(acc3221_t *dev) serial_remove(dev->uart[1]); serial_setup(dev->uart[1], SERIAL2_ADDR, SERIAL2_IRQ); - + lpt1_remove(); lpt1_init(0x378); lpt1_irq(7); @@ -465,7 +465,7 @@ acc3221_init(const device_t *info) dev->fdc = device_add(&fdc_at_device); dev->uart[0] = device_add_inst(&ns16450_device, 1); - dev->uart[1] = device_add_inst(&ns16450_device, 2); + dev->uart[1] = device_add_inst(&ns16450_device, 2); io_sethandler(0x00f2, 0x0002, acc3221_read, NULL, NULL, acc3221_write, NULL, NULL, dev); diff --git a/src/sio/sio_f82c710.c b/src/sio/sio_f82c710.c index feb623a10..06d0bf800 100644 --- a/src/sio/sio_f82c710.c +++ b/src/sio/sio_f82c710.c @@ -63,7 +63,7 @@ typedef struct upc_t } upc_t; -static void +static void f82c710_update_ports(upc_t *dev, int set) { uint16_t com_addr = 0; @@ -176,7 +176,7 @@ f82c606_update_ports(upc_t *dev, int set) } -static uint8_t +static uint8_t f82c710_config_read(uint16_t port, void *priv) { upc_t *dev = (upc_t *) priv; @@ -197,7 +197,7 @@ f82c710_config_read(uint16_t port, void *priv) } -static void +static void f82c710_config_write(uint16_t port, uint8_t val, void *priv) { upc_t *dev = (upc_t *) priv; @@ -330,7 +330,7 @@ f82c710_init(const device_t *info) dev->fdc = device_add(&fdc_at_device); dev->uart[0] = device_add_inst(&ns16450_device, 1); - dev->uart[1] = device_add_inst(&ns16450_device, 2); + dev->uart[1] = device_add_inst(&ns16450_device, 2); io_sethandler(0x02fa, 0x0001, NULL, NULL, NULL, f82c710_config_write, NULL, NULL, dev); io_sethandler(0x03fa, 0x0001, NULL, NULL, NULL, f82c710_config_write, NULL, NULL, dev); diff --git a/src/sio/sio_fdc37c669.c b/src/sio/sio_fdc37c669.c index a365f0ede..689de9236 100644 --- a/src/sio/sio_fdc37c669.c +++ b/src/sio/sio_fdc37c669.c @@ -127,11 +127,11 @@ fdc37c669_write(uint16_t port, uint8_t val, void *priv) if (valxor & 4) { if (dev->id) { lpt2_remove(); - if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) + if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) lpt2_init(make_port(dev, 0x23)); } else { lpt1_remove(); - if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) + if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) lpt1_init(make_port(dev, 0x23)); } } @@ -177,11 +177,11 @@ fdc37c669_write(uint16_t port, uint8_t val, void *priv) if (valxor) { if (dev->id) { lpt2_remove(); - if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) + if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) lpt2_init(make_port(dev, 0x23)); } else { lpt1_remove(); - if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) + if ((dev->regs[1] & 4) && (dev->regs[0x23] >= 0x40)) lpt1_init(make_port(dev, 0x23)); } } diff --git a/src/sio/sio_pc87310.c b/src/sio/sio_pc87310.c index 424a9524b..30604cf03 100644 --- a/src/sio/sio_pc87310.c +++ b/src/sio/sio_pc87310.c @@ -13,7 +13,7 @@ * Author: Miran Grca, * Tiseno100 * EngiNerd - * + * * Copyright 2020 Miran Grca. * Copyright 2020 Tiseno100 * Copyright 2021 EngiNerd. @@ -147,7 +147,7 @@ pc87310_write(uint16_t port, uint8_t val, void *priv) } pc87310_log("SIO: written %01X\n", val); - + /* reconfigure parallel port */ if (valxor & 0x03) { lpt1_remove(); @@ -203,7 +203,7 @@ pc87310_read(uint16_t port, void *priv) ret = dev->reg; pc87310_log("SIO: read %01X\n", ret); - + return ret; } @@ -247,7 +247,7 @@ pc87310_init(const device_t *info) HAS_IDE_FUNCTIONALITY = info->local; dev->fdc = device_add(&fdc_at_nsc_device); - + dev->uart[0] = device_add_inst(&ns16550_device, 1); dev->uart[1] = device_add_inst(&ns16550_device, 2); @@ -258,7 +258,7 @@ pc87310_init(const device_t *info) io_sethandler(0x3f3, 0x0001, pc87310_read, NULL, NULL, pc87310_write, NULL, NULL, dev); - + return dev; } @@ -282,4 +282,4 @@ const device_t pc87310_ide_device = { pc87310_init, pc87310_close, NULL, { NULL }, NULL, NULL, NULL -}; \ No newline at end of file +}; diff --git a/src/sio/sio_w83787f.c b/src/sio/sio_w83787f.c index 5cd7017bc..a24e8695c 100644 --- a/src/sio/sio_w83787f.c +++ b/src/sio/sio_w83787f.c @@ -432,7 +432,7 @@ w83787f_init(const device_t *info) dev->uart[0] = device_add_inst(&ns16550_device, 1); dev->uart[1] = device_add_inst(&ns16550_device, 2); - + if ((dev->ide_function & 0x30) == 0x10) device_add(&ide_isa_device); diff --git a/src/sio/sio_w83877f.c b/src/sio/sio_w83877f.c index d1433cb1f..3867fec60 100644 --- a/src/sio/sio_w83877f.c +++ b/src/sio/sio_w83877f.c @@ -192,7 +192,7 @@ w83877f_serial_handler(w83877f_t *dev, int uart) if (dev->regs[0x19] & (0x02 >> uart)) { clock_src = 14769000.0; - } else if (dev->regs[0x03] & (0x02 >> uart)) { + } else if (dev->regs[0x03] & (0x02 >> uart)) { clock_src = 24000000.0 / 12.0; } else { clock_src = 24000000.0 / 13.0; diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index bddd1776e..ef753cd6f 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -19,12 +19,46 @@ add_library(snd OBJECT sound.c snd_opl.c snd_opl_nuked.c snd_resid.cc snd_azt2316a.c snd_cms.c snd_cs423x.c snd_gus.c snd_sb.c snd_sb_dsp.c snd_emu8k.c snd_mpu401.c snd_sn76489.c snd_ssi2001.c snd_wss.c snd_ym7128.c) -if(OPENAL OR FAUDIO) - target_compile_definitions(snd PRIVATE USE_OPENAL) - if (FAUDIO) - target_sources(snd PRIVATE faudio.cpp) +if(OPENAL) + if(VCPKG_TOOLCHAIN) + find_package(OpenAL CONFIG REQUIRED) + elseif(MINGW) + find_package(OpenAL MODULE REQUIRED) else() - target_sources(snd PRIVATE openal.c) + find_package(OpenAL REQUIRED) + endif() + + if(TARGET OpenAL::OpenAL) + target_link_libraries(86Box OpenAL::OpenAL) + else() + include_directories(${OPENAL_INCLUDE_DIR}) + target_link_libraries(86Box ${OPENAL_LIBRARY}) + endif() + + target_sources(snd PRIVATE openal.c) +else() + if(WIN32) + option(FAUDIO "Use FAudio instead of XAudio2" OFF) + endif() + + target_sources(snd PRIVATE xaudio2.c) + + if(NOT WIN32 OR FAUDIO) + find_package(PkgConfig REQUIRED) + + # Use FAudio, a reimplementation of XAudio2 + pkg_check_modules(FAUDIO IMPORTED_TARGET FAudio) + if(FAUDIO_FOUND) + target_link_libraries(86Box PkgConfig::FAUDIO) + else() + find_path(FAUDIO_INCLUDE_DIR NAMES "FAudio.h") + find_library(FAUDIO_LIBRARY FAudio) + + include_directories(${FAUDIO_INCLUDE_DIR}) + target_link_libraries(86Box ${FAUDIO_LIBRARY}) + endif() + + set_property(SOURCE xaudio2.c PROPERTY COMPILE_DEFINITIONS USE_FAUDIO) endif() endif() diff --git a/src/sound/faudio.cpp b/src/sound/faudio.cpp deleted file mode 100644 index 246ec0b67..000000000 --- a/src/sound/faudio.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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. - * - * Interface to the FAudio audio processing library. - * - * - * - * Authors: Cacodemon345 - * - * Copyright 2022 Cacodemon345. - */ -#include -#include -#include -#include -#include -#include -#include - -extern "C" -{ -#include <86box/86box.h> -#include <86box/sound.h> -#include <86box/midi.h> - -static int midi_freq = 44100; -static int midi_buf_size = 4410; -static int initialized = 0; -static FAudio* faudio = nullptr; -static FAudioMasteringVoice* mastervoice = nullptr; -static FAudioSourceVoice* srcvoice = nullptr; -static FAudioSourceVoice* srcvoicemidi = nullptr; -static FAudioSourceVoice* srcvoicecd = nullptr; - -#define FREQ 48000 -#define BUFLEN SOUNDBUFLEN - -static void FAUDIOCALL -onBufferFinished( - FAudioVoiceCallback *callback, - void *pBufferContext) -{ - if (sound_is_float) delete[] (float*)(pBufferContext); - else delete[] (int16_t*)(pBufferContext); - -} - -static FAudioVoiceCallback callbacks = -{ - onBufferFinished -}; - -void -inital() -{ - if (FAudioCreate(&faudio, 0, FAUDIO_DEFAULT_PROCESSOR)) - { - return; - } - - if (FAudio_CreateMasteringVoice(faudio, &mastervoice, 2, FREQ, 0, 0, nullptr)) - { - FAudio_Release(faudio); - faudio = nullptr; - return; - } - FAudioWaveFormatEx fmt; - fmt.nChannels = 2; - if (sound_is_float) - { - fmt.wFormatTag = FAUDIO_FORMAT_IEEE_FLOAT; - fmt.wBitsPerSample = 32; - } - else - { - fmt.wFormatTag = FAUDIO_FORMAT_PCM; - fmt.wBitsPerSample = 16; - } - fmt.nSamplesPerSec = FREQ; - fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; - fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; - fmt.cbSize = 0; - if (FAudio_CreateSourceVoice(faudio, &srcvoice, &fmt, 0, 2.0f, &callbacks, nullptr, nullptr)) - { - FAudioVoice_DestroyVoice(mastervoice); - FAudio_Release(faudio); - faudio = nullptr; - mastervoice = nullptr; - return; - } - fmt.nSamplesPerSec = CD_FREQ; - fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; - fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; - FAudio_CreateSourceVoice(faudio, &srcvoicecd, &fmt, 0, 2.0f, &callbacks, nullptr, nullptr); - FAudioVoice_SetVolume(srcvoice, 1, FAUDIO_COMMIT_NOW); - FAudioSourceVoice_Start(srcvoice, 0, FAUDIO_COMMIT_NOW); - FAudioSourceVoice_Start(srcvoicecd, 0, FAUDIO_COMMIT_NOW); - auto mdn = midi_device_get_internal_name(midi_device_current); - if (strcmp(mdn, "none") && strcmp(mdn, SYSTEM_MIDI_INTERNAL_NAME)) - { - fmt.nSamplesPerSec = midi_freq; - fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; - fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; - FAudio_CreateSourceVoice(faudio, &srcvoicemidi, &fmt, 0, 2.0f, &callbacks, nullptr, nullptr); - FAudioSourceVoice_Start(srcvoicemidi, 0, FAUDIO_COMMIT_NOW); - } - initialized = 1; -} - -void -closeal() -{ - if (!initialized) return; - initialized = 0; - FAudioSourceVoice_Stop(srcvoice, 0, FAUDIO_COMMIT_NOW); - FAudioSourceVoice_FlushSourceBuffers(srcvoice); - FAudioSourceVoice_Stop(srcvoicecd, 0, FAUDIO_COMMIT_NOW); - FAudioSourceVoice_FlushSourceBuffers(srcvoicecd); - if (srcvoicemidi) - { - FAudioSourceVoice_Stop(srcvoicemidi, 0, FAUDIO_COMMIT_NOW); - FAudioSourceVoice_FlushSourceBuffers(srcvoicemidi); - FAudioVoice_DestroyVoice(srcvoicemidi); - } - FAudioVoice_DestroyVoice(srcvoice); - FAudioVoice_DestroyVoice(srcvoicecd); - FAudioVoice_DestroyVoice(mastervoice); - FAudio_Release(faudio); - srcvoice = srcvoicecd = srcvoicemidi = nullptr; - mastervoice = nullptr; - faudio = nullptr; -} - -void -givealbuffer_common(void *buf, FAudioSourceVoice* sourcevoice, size_t buflen) -{ - if (!initialized) return; - - FAudioVoice_SetVolume(mastervoice, pow(10.0, (double)sound_gain / 20.0), FAUDIO_COMMIT_NOW); - FAudioBuffer buffer{}; - buffer.Flags = 0; - if (sound_is_float) - { - buffer.pAudioData = (uint8_t*)new float[buflen]; - buffer.AudioBytes = (buflen) * sizeof(float); - } - else - { - buffer.pAudioData = (uint8_t*)new int16_t[buflen]; - buffer.AudioBytes = (buflen) * sizeof(int16_t); - } - if (buffer.pAudioData == nullptr) - { - fatal("faudio: Out Of Memory!"); - } - memcpy((void*)buffer.pAudioData, buf, buffer.AudioBytes); - buffer.PlayBegin = buffer.PlayLength = 0; - buffer.PlayLength = buflen >> 1; - buffer.pContext = (void*)buffer.pAudioData; - FAudioSourceVoice_SubmitSourceBuffer(sourcevoice, &buffer, nullptr); -} - -void -givealbuffer(void *buf) -{ - givealbuffer_common(buf, srcvoice, BUFLEN << 1); -} - -void -givealbuffer_cd(void *buf) -{ - if (srcvoicecd) givealbuffer_common(buf, srcvoicecd, CD_BUFLEN << 1); -} - -void -al_set_midi(int freq, int buf_size) -{ - midi_freq = freq; - midi_buf_size = buf_size; - - if (initialized && srcvoicemidi) - { - FAudioSourceVoice_Stop(srcvoicemidi, 0, FAUDIO_COMMIT_NOW); - FAudioSourceVoice_FlushSourceBuffers(srcvoicemidi); - FAudioVoice_DestroyVoice(srcvoicemidi); - srcvoicemidi = nullptr; - FAudioWaveFormatEx fmt; - fmt.nChannels = 2; - if (sound_is_float) - { - fmt.wFormatTag = FAUDIO_FORMAT_IEEE_FLOAT; - fmt.wBitsPerSample = 32; - } - else - { - fmt.wFormatTag = FAUDIO_FORMAT_PCM; - fmt.wBitsPerSample = 16; - } - fmt.nSamplesPerSec = midi_freq; - fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; - fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; - fmt.cbSize = 0; - FAudio_CreateSourceVoice(faudio, &srcvoicemidi, &fmt, 0, 2.0f, &callbacks, nullptr, nullptr); - FAudioSourceVoice_Start(srcvoicemidi, 0, FAUDIO_COMMIT_NOW); - } -} - -void -givealbuffer_midi(void *buf, uint32_t size) -{ - givealbuffer_common(buf, srcvoicemidi, size); -} - -} \ No newline at end of file diff --git a/src/sound/midi.c b/src/sound/midi.c index 4ceb5fdb1..05ac861f8 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -399,7 +399,7 @@ midi_raw_out_byte(uint8_t val) } -void +void midi_clear_buffer(void) { if (!midi) diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index ed3e2d535..14093efb4 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -40,10 +40,8 @@ enum fluid_interp { }; -#ifdef USE_OPENAL extern void givealbuffer_midi(void *buf, uint32_t size); extern void al_set_midi(int freq, int buf_size); -#endif static void *fluidsynth_handle; /* handle to FluidSynth DLL */ @@ -152,9 +150,7 @@ static void fluidsynth_thread(void *param) buf_pos += buf_size; if (buf_pos >= data->buf_size) { -#ifdef USE_OPENAL givealbuffer_midi(data->buffer, data->buf_size / sizeof(float)); -#endif buf_pos = 0; } } @@ -167,9 +163,7 @@ static void fluidsynth_thread(void *param) buf_pos += buf_size; if (buf_pos >= data->buf_size) { -#ifdef USE_OPENAL givealbuffer_midi(data->buffer_int16, data->buf_size / sizeof(int16_t)); -#endif buf_pos = 0; } } @@ -322,9 +316,7 @@ void* fluidsynth_init(const device_t *info) data->buffer_int16 = malloc(data->buf_size); } -#ifdef USE_OPENAL al_set_midi(data->samplerate, data->buf_size); -#endif dev = malloc(sizeof(midi_device_t)); memset(dev, 0, sizeof(midi_device_t)); diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index 00c26b392..e1812a733 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -14,10 +14,8 @@ #include <86box/midi.h> -#ifdef USE_OPENAL extern void givealbuffer_midi(void *buf, uint32_t size); extern void al_set_midi(int freq, int buf_size); -#endif static void display_mt32_message(void *instance_data, const char *message); @@ -193,9 +191,7 @@ static void mt32_thread(void *param) buf_pos += bsize; if (buf_pos >= buf_size) { -#ifdef USE_OPENAL givealbuffer_midi(buffer, buf_size / sizeof(float)); -#endif buf_pos = 0; } } @@ -207,9 +203,7 @@ static void mt32_thread(void *param) buf_pos += bsize; if (buf_pos >= buf_size) { -#ifdef USE_OPENAL givealbuffer_midi(buffer_int16, buf_size / sizeof(int16_t)); -#endif buf_pos = 0; } } @@ -261,9 +255,7 @@ void* mt32emu_init(char *control_rom, char *pcm_rom) mt32emu_set_reversed_stereo_enabled(context, device_get_config_int("reversed_stereo")); mt32emu_set_nice_amp_ramp_enabled(context, device_get_config_int("nice_ramp")); -#ifdef USE_OPENAL al_set_midi(samplerate, buf_size); -#endif dev = malloc(sizeof(midi_device_t)); memset(dev, 0, sizeof(midi_device_t)); diff --git a/src/sound/midi_rtmidi.cpp b/src/sound/midi_rtmidi.cpp index 48877924c..ec943a43f 100644 --- a/src/sound/midi_rtmidi.cpp +++ b/src/sound/midi_rtmidi.cpp @@ -235,7 +235,7 @@ rtmidi_in_get_dev_name(int num, char *s) static const device_config_t system_midi_config[] = { { - "midi", "MIDI out device", CONFIG_MIDI, "", 0 + "midi", "MIDI out device", CONFIG_MIDI_OUT, "", 0 }, { "", "", -1 diff --git a/src/sound/openal.c b/src/sound/openal.c index 95619e79b..37ee211cd 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -60,7 +60,7 @@ al_set_midi(int freq, int buf_size) void closeal(void); -ALvoid alutInit(ALint *argc,ALbyte **argv) +ALvoid alutInit(ALint *argc,ALbyte **argv) { /* Open device */ Device = alcOpenDevice((ALCchar *)""); @@ -76,7 +76,7 @@ ALvoid alutInit(ALint *argc,ALbyte **argv) ALvoid -alutExit(ALvoid) +alutExit(ALvoid) { if (Context != NULL) { /* Disable context */ diff --git a/src/sound/resid-fp/envelope.h b/src/sound/resid-fp/envelope.h index 556e71a47..af0764ccd 100644 --- a/src/sound/resid-fp/envelope.h +++ b/src/sound/resid-fp/envelope.h @@ -130,7 +130,7 @@ void EnvelopeGeneratorFP::clock() --envelope_counter &= 0xff; break; } - + // Check for change of exponential counter period. switch (envelope_counter) { case 0xff: diff --git a/src/sound/resid-fp/filter.h b/src/sound/resid-fp/filter.h index 13e6aa67e..9ca254564 100644 --- a/src/sound/resid-fp/filter.h +++ b/src/sound/resid-fp/filter.h @@ -57,7 +57,7 @@ // // SID filter // ---------- -// +// // ----------------------------------------------- // | | // | ---Rq-- | @@ -66,15 +66,15 @@ // | | | | // | | ---C---| ---C---| // | | | | | | -// | --R1-- ---R1-- |---Rs--| |---Rs--| +// | --R1-- ---R1-- |---Rs--| |---Rs--| // | | | | | | | | // ----R1--|-----[A>--|--R-----[A>--|--R-----[A>--| // | | | | // vi -----R1-- | | | -// +// // vhp vbp vlp -// -// +// +// // vi - input voltage // vhp - highpass output // vbp - bandpass output @@ -85,14 +85,14 @@ // R - NMOS FET voltage controlled resistor controlling cutoff frequency // Rs - shunt resitor // C - capacitor -// -// -// +// +// +// // SID integrator // -------------- -// +// // V+ -// +// // | // | // -----| @@ -114,7 +114,7 @@ // R1 V- // | // | -// +// // Vw // // ---------------------------------------------------------------------------- @@ -312,7 +312,7 @@ float FilterFP::clock(float voice1, else if (! voice3off) Vnf += voice3; ((filt & 8) ? Vi : Vnf) += ext_in; - + if (! enabled) return (Vnf - Vi) * volf; @@ -322,7 +322,7 @@ float FilterFP::clock(float voice1, Vf += Vbp; if (hp_bp_lp & 4) Vf += Vhp; - + if (model == MOS6581FP) { float diff1, diff2; @@ -345,7 +345,7 @@ float FilterFP::clock(float voice1, Vbp += (Vf + Vnf - Vbp) * distortion_cf_threshold; if (hp_bp_lp & 4) Vhp += (Vf + Vnf - Vhp) * distortion_cf_threshold; - + /* Simulating the exponential VCR that the FET block is... */ Vlp -= Vbp * type3_w0(Vbp, type3_fc_distortion_offset_bp); Vbp -= Vhp * type3_w0(Vhp, type3_fc_distortion_offset_hp) * outputleveldifference_bp_hp; @@ -354,7 +354,7 @@ float FilterFP::clock(float voice1, * discontinuity but a saturation effect... */ if (Vnf > 3.2e6f) Vnf = 3.2e6f; - + Vf += Vnf + Vlp * (outputleveldifference_lp_bp - 1.f); } else { /* On the 8580, BP appears mixed in phase with the rest. */ @@ -364,7 +364,7 @@ float FilterFP::clock(float voice1, Vf += Vnf; } - + return Vf * volf; } diff --git a/src/sound/resid-fp/sid.h b/src/sound/resid-fp/sid.h index 6dad2e0c4..5180898fb 100644 --- a/src/sound/resid-fp/sid.h +++ b/src/sound/resid-fp/sid.h @@ -47,7 +47,7 @@ public: void clock(); int clock(cycle_count& delta_t, short* buf, int n, int interleave = 1); void reset(); - + // Read/write registers. reg8 read(reg8 offset); void write(reg8 offset, reg8 value); @@ -73,7 +73,7 @@ public: EnvelopeGeneratorFP::State envelope_state[3]; bool hold_zero[3]; }; - + State read_state(); void write_state(const State& state); @@ -114,7 +114,7 @@ protected: int sample_index; int fir_N; int fir_RES; - + // Linear interpolation helper float sample_prev; diff --git a/src/sound/resid-fp/wave.h b/src/sound/resid-fp/wave.h index 07d229ba0..64684228b 100644 --- a/src/sound/resid-fp/wave.h +++ b/src/sound/resid-fp/wave.h @@ -269,7 +269,7 @@ reg12 WaveformGeneratorFP::outputN___() // in the output. The reason for this has not been determined. // // Example: -// +// // 1 1 // Bit # 1 0 9 8 7 6 5 4 3 2 1 0 // ----------------------- @@ -303,14 +303,14 @@ reg12 WaveformGeneratorFP::outputN___() // // Sawtooth+Triangle: // The sawtooth output is used to look up an OSC3 sample. -// +// // Pulse+Triangle: // The triangle output is right-shifted and used to look up an OSC3 sample. // The sample is output if the pulse output is on. // The reason for using the triangle output as the index is to handle ring // modulation. Only the first half of the sample is used, which should be OK // since the triangle waveform has half the resolution of the accumulator. -// +// // Pulse+Sawtooth: // The sawtooth output is used to look up an OSC3 sample. // The sample is output if the pulse output is on. @@ -318,7 +318,7 @@ reg12 WaveformGeneratorFP::outputN___() // Pulse+Sawtooth+Triangle: // The sawtooth output is used to look up an OSC3 sample. // The sample is output if the pulse output is on. -// +// RESID_INLINE reg12 WaveformGeneratorFP::output__ST() { diff --git a/src/sound/snd_ad1848.c b/src/sound/snd_ad1848.c index 024242438..903bede5e 100644 --- a/src/sound/snd_ad1848.c +++ b/src/sound/snd_ad1848.c @@ -196,7 +196,7 @@ ad1848_write(uint16_t addr, uint8_t val, void *priv) case 8: updatefreq = 1; break; - + case 9: if (!ad1848->enable && (val & 0x41) == 0x01) { if (ad1848->timer_latch) @@ -213,7 +213,7 @@ ad1848_write(uint16_t addr, uint8_t val, void *priv) case 11: return; - + case 12: if (ad1848->type != AD1848_TYPE_DEFAULT) ad1848->regs[12] = ((ad1848->regs[12] & 0x0f) + (val & 0xf0)) | 0x80; @@ -404,7 +404,7 @@ ad1848_poll(void *priv) ad1848->out_l = (dma_channel_read(ad1848->dma) ^ 0x80) * 256; ad1848->out_r = (dma_channel_read(ad1848->dma) ^ 0x80) * 256; break; - + case 0x40: /* Mono, 16-bit PCM little endian */ temp = dma_channel_read(ad1848->dma); ad1848->out_l = ad1848->out_r = (dma_channel_read(ad1848->dma) << 8) | temp; diff --git a/src/sound/snd_adlib.c b/src/sound/snd_adlib.c index ca6916ad8..4ea851d6b 100644 --- a/src/sound/snd_adlib.c +++ b/src/sound/snd_adlib.c @@ -37,7 +37,7 @@ adlib_log(const char *fmt, ...) typedef struct adlib_t { opl_t opl; - + uint8_t pos_regs[8]; } adlib_t; @@ -48,7 +48,7 @@ static void adlib_get_buffer(int32_t *buffer, int len, void *p) int c; opl2_update(&adlib->opl); - + for (c = 0; c < len * 2; c++) buffer[c] += (int32_t)adlib->opl.buffer[c]; @@ -58,9 +58,9 @@ static void adlib_get_buffer(int32_t *buffer, int len, void *p) uint8_t adlib_mca_read(int port, void *p) { adlib_t *adlib = (adlib_t *)p; - + adlib_log("adlib_mca_read: port=%04x\n", port); - + return adlib->pos_regs[port & 7]; } @@ -70,9 +70,9 @@ void adlib_mca_write(int port, uint8_t val, void *p) if (port < 0x102) return; - + adlib_log("adlib_mca_write: port=%04x val=%02x\n", port, val); - + switch (port) { case 0x102: @@ -97,7 +97,7 @@ void *adlib_init(const device_t *info) { adlib_t *adlib = malloc(sizeof(adlib_t)); memset(adlib, 0, sizeof(adlib_t)); - + adlib_log("adlib_init\n"); opl2_init(&adlib->opl); io_sethandler(0x0388, 0x0002, opl2_read, NULL, NULL, opl2_write, NULL, NULL, &adlib->opl); @@ -108,7 +108,7 @@ void *adlib_init(const device_t *info) void *adlib_mca_init(const device_t *info) { adlib_t *adlib = adlib_init(info); - + io_removehandler(0x0388, 0x0002, opl2_read, NULL, NULL, opl2_write, NULL, NULL, &adlib->opl); mca_add(adlib_mca_read, adlib_mca_write, adlib_mca_feedb, NULL, adlib); adlib->pos_regs[0] = 0xd7; diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index 1c43adf0c..1c4c678b0 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -51,7 +51,7 @@ typedef struct adgold_t int timerbase_latch, timerbase_count; int timer1_latch, timer1_count; int timer2_latch, timer2_count, timer2_read; - + int voice_count[2], voice_latch[2]; } adgold_mma; @@ -159,12 +159,12 @@ void adgold_update_irq_status(adgold_t *adgold) if ((adgold->adgold_mma_status & 0x02) && !(adgold->adgold_mma_regs[1][0xc] & 2)) temp &= ~2; adgold->adgold_status = temp; - + if ((adgold->adgold_status ^ 0xf) && !adgold->adgold_irq_status) { picint(0x80); } - + adgold->adgold_irq_status = adgold->adgold_status ^ 0xf; } @@ -312,7 +312,7 @@ void adgold_write(uint16_t addr, uint8_t val, void *p) adgold->adgold_mma.timer2_latch = (adgold->adgold_mma.timer2_latch & 0xff) | (val << 8); break; - case 0x8: + case 0x8: if ((val & 1) && !(adgold->adgold_mma_regs[0][8] & 1)) /*Reload timer 0*/ adgold->adgold_mma.timer0_count = adgold->adgold_mma.timer0_latch; @@ -436,7 +436,7 @@ void adgold_write(uint16_t addr, uint8_t val, void *p) case 0xe: if (adgold->uart_out) { midi_raw_out_byte(val); - + adgold->adgold_mma_status &= ~0x08; adgold_update_irq_status(adgold); } @@ -466,7 +466,7 @@ void adgold_write(uint16_t addr, uint8_t val, void *p) } if ((val & 0x01)) /*Start playback*/ { - if (!(adgold->adgold_mma_regs[1][0x9] & 1)) + if (!(adgold->adgold_mma_regs[1][0x9] & 1)) adgold->adgold_mma.voice_count[1] = adgold->adgold_mma.voice_latch[1]; if (adgold->adgold_mma_regs[1][0xc] & 1) @@ -512,7 +512,7 @@ uint8_t adgold_read(uint16_t addr, void *p) case 0: case 1: temp = opl3_read(addr, &adgold->opl); break; - + case 2: if (adgold->adgold_38x_state) /*Read from control chip*/ temp = adgold->adgold_status; @@ -532,7 +532,7 @@ uint8_t adgold_read(uint16_t addr, void *p) else temp = 0x71; /*8-bit ISA, no telephone/surround/CD-ROM*/ break; - + default: temp = adgold->adgold_38x_regs[adgold->adgold_38x_addr]; } @@ -558,7 +558,7 @@ uint8_t adgold_read(uint16_t addr, void *p) case 7: /*Timer 2 high*/ temp = adgold->adgold_mma.timer2_read >> 8; break; - + case 0xe: temp = 0; if (adgold->uart_in) { @@ -571,7 +571,7 @@ uint8_t adgold_read(uint16_t addr, void *p) adgold_update_irq_status(adgold); } break; - + default: temp = adgold->adgold_mma_regs[0][adgold->adgold_mma_addr]; break; @@ -610,7 +610,7 @@ void adgold_mma_poll(adgold_t *adgold, int channel) int16_t dat; adgold_update(adgold); - + if (adgold->adgold_mma_fifo_start[channel] != adgold->adgold_mma_fifo_end[channel]) { switch (adgold->adgold_mma_regs[channel][0xc] & 0x60) @@ -664,7 +664,7 @@ void adgold_timer_poll(void *p) } adgold_update_irq_status(adgold); } - + if (adgold->adgold_mma_regs[0][8] & 0x01) /*Timer 0*/ { adgold->adgold_mma.timer0_count--; @@ -734,7 +734,7 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p) opl3_update(&adgold->opl); adgold_update(adgold); - + for (c = 0; c < len * 2; c += 2) { adgold_buffer[c] = ((adgold->opl.buffer[c] * adgold->fm_vol_l) >> 7) / 2; @@ -785,7 +785,7 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p) { int16_t l = adgold_buffer[c]; int16_t r = adgold_buffer[c+1]; - + adgold_buffer[c] += (r / 3) + ((l * 2) / 3); adgold_buffer[c+1] += (l / 3) + ((r * 2) / 3); } @@ -795,7 +795,7 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p) for (c = 0; c < len * 2; c += 2) { int32_t temp, lowpass, highpass; - + /*Output is deliberately halved to avoid clipping*/ temp = ((int32_t)adgold_buffer[c] * adgold->vol_l) >> 17; lowpass = adgold_lowpass_iir(0, temp); @@ -856,7 +856,7 @@ static void adgold_input_msg(void *p, uint8_t *msg, uint32_t len) adgold_t *adgold = (adgold_t *)p; uint8_t i; - if (adgold->sysex) + if (adgold->sysex) return; if (adgold->uart_in) { @@ -871,7 +871,7 @@ static void adgold_input_msg(void *p, uint8_t *msg, uint32_t len) } } -static int adgold_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) +static int adgold_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) { adgold_t *adgold = (adgold_t *)p; uint32_t i; @@ -985,7 +985,7 @@ void *adgold_init(const device_t *info) sound_set_cd_audio_filter(adgold_filter_cd_audio, adgold); if (device_get_config_int("receive_input")) - midi_in_handler(1, adgold_input_msg, adgold_input_sysex, adgold); + midi_in_handler(1, adgold_input_msg, adgold_input_sysex, adgold); return adgold; } diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index 6e88d401b..63f632ea7 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -509,7 +509,7 @@ es1371_read_frame_reg(es1371_t *dev, int frame, int page) if (page == 0x0e || page == 0x0f) { audiopci_log("Read frame = %02x, page = %02x, uart fifo valid = %02x, temp = %03x\n", frame, page, dev->valid, ret); } - + return ret; } @@ -675,7 +675,7 @@ es1371_inb(uint16_t port, void *p) case 0x0d ... 0x0e: ret = 0x00; break; - + /* Legacy Control/Status Register, Address 18H Addressable as byte, word, longword */ case 0x18: @@ -702,10 +702,10 @@ es1371_inb(uint16_t port, void *p) case 0x22: ret = (dev->si_cr >> 16) | 0x80; break; - case 0x23: + case 0x23: ret = 0xff; break; - + default: audiopci_log("Bad es1371_inb: port=%04x\n", port); } @@ -831,7 +831,7 @@ es1371_inl(uint16_t port, void *p) ret = dev->sr_cir & ~0xffff; ret |= dev->sr_ram[dev->sr_cir >> 25]; break; - + /* CODEC Read Register, Address 14H Addressable as longword only */ case 0x14: @@ -929,7 +929,7 @@ es1371_outb(uint16_t port, uint8_t val, void *p) case 0x09: audiopci_log("[W] UART CTRL = %02X\n", val); dev->uart_ctrl = val & 0xe3; - + if ((val & 0x03) == 0x03) { /* Reset TX */ es1371_set_tx_irq(dev, 1); @@ -1137,7 +1137,7 @@ es1371_outl(uint16_t port, uint32_t val, void *p) break; case 0x72: dev->dac[0].ac = (dev->dac[0].ac & ~0x7fff) | (val & 0x7fff); - break; + break; case 0x73: dev->dac[0].vf = (dev->dac[0].vf & ~0x7fff) | (val & 0x7fff); break; @@ -1237,7 +1237,7 @@ capture_event(es1371_t *dev, int type, int rw, uint16_t port) { dev->legacy_ctrl &= ~(LEGACY_EVENT_MASK | LEGACY_EVENT_ADDR_MASK); dev->legacy_ctrl |= type; - if (rw) + if (rw) dev->legacy_ctrl |= LEGACY_EVENT_TYPE_RW; else dev->legacy_ctrl &= ~LEGACY_EVENT_TYPE_RW; @@ -1839,7 +1839,7 @@ es1371_update(es1371_t *dev) else if (r > 32767) r = 32767; - for (; dev->pos < sound_pos_global; dev->pos++) { + for (; dev->pos < sound_pos_global; dev->pos++) { dev->buffer[dev->pos*2] = l; dev->buffer[dev->pos*2 + 1] = r; } @@ -1856,7 +1856,7 @@ es1371_poll(void *p) es1371_scan_fifo(dev); - es1371_update(dev); + es1371_update(dev); if (dev->int_ctrl & INT_DAC1_EN) { frac = dev->dac[0].ac & 0x7fff; @@ -1989,7 +1989,7 @@ es1371_input_msg(void *p, uint8_t *msg, uint32_t len) static int -es1371_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) +es1371_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) { es1371_t *dev = (es1371_t *)p; uint32_t i = -1; @@ -2030,7 +2030,7 @@ es1371_init(const device_t *info) dev->card = pci_add_card(info->local ? PCI_ADD_SOUND : PCI_ADD_NORMAL, es1371_pci_read, es1371_pci_write, dev); - timer_add(&dev->dac[1].timer, es1371_poll, dev, 1); + timer_add(&dev->dac[1].timer, es1371_poll, dev, 1); generate_es1371_filter(); @@ -2090,10 +2090,10 @@ static const device_config_t es1371_config[] = } }, .default_int = AC97_CODEC_CS4297A - }, + }, { "receive_input", "Receive input (MIDI)", CONFIG_BINARY, "", 1 - }, + }, { "", "", -1 } diff --git a/src/sound/snd_azt2316a.c b/src/sound/snd_azt2316a.c index fd8bf6555..b6e882013 100644 --- a/src/sound/snd_azt2316a.c +++ b/src/sound/snd_azt2316a.c @@ -136,7 +136,7 @@ #include #include #include -#include +#include #define HAVE_STDARG_H #include <86box/86box.h> #include <86box/io.h> @@ -187,11 +187,11 @@ typedef struct azt2316a_t ad1848_t ad1848; mpu_t *mpu; - + sb_t *sb; } azt2316a_t; -static uint8_t +static uint8_t azt2316a_wss_read(uint16_t addr, void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -206,9 +206,9 @@ azt2316a_wss_read(uint16_t addr, void *p) temp = 4 | (azt2316a->wss_config & 0xC0); return temp; -} - -static void +} + +static void azt2316a_wss_write(uint16_t addr, uint8_t val, void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -225,13 +225,13 @@ azt2316a_wss_write(uint16_t addr, uint8_t val, void *p) azt2316a->cur_wss_irq = azt2316a_wss_irq[(val >> 3) & 7]; ad1848_setdma(&azt2316a->ad1848, azt2316a_wss_dma[val & 3]); ad1848_setirq(&azt2316a->ad1848, azt2316a_wss_irq[(val >> 3) & 7]); - + if (interrupt) picint(1 << azt2316a->cur_wss_irq); } /* generate a config word based on current settings */ -static void +static void azt1605_create_config_word(void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -310,7 +310,7 @@ azt1605_create_config_word(void *p) if (azt2316a->cur_mpu401_enabled) temp += 1 << 3; - + switch (cd_type) { case 0: /* disabled do nothing @@ -354,7 +354,7 @@ azt1605_create_config_word(void *p) temp += 3 << 22; break; } - + switch (azt2316a->cur_mpu401_irq) { case 9: temp += 1 << 12; @@ -369,7 +369,7 @@ azt1605_create_config_word(void *p) temp += 1 << 15; break; } - + switch (cd_irq) { case 0: // disabled // do nothing @@ -386,9 +386,9 @@ azt1605_create_config_word(void *p) } azt2316a->config_word = temp; -} +} -static void +static void azt2316a_create_config_word(void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -424,7 +424,7 @@ azt2316a_create_config_word(void *p) break; */ } - + switch (azt2316a->cur_irq) { case 9: temp += 1 << 2; @@ -439,7 +439,7 @@ azt2316a_create_config_word(void *p) temp += 1 << 5; break; } - + switch (azt2316a->cur_dma) { /* // TODO: INVALID? @@ -458,7 +458,7 @@ azt2316a_create_config_word(void *p) temp += 3 << 6; break; } - + switch (azt2316a->cur_wss_addr) { case 0x530: @@ -489,10 +489,10 @@ azt2316a_create_config_word(void *p) temp += 1 << 12; break; } - + if (azt2316a->cur_mpu401_enabled) temp += 1 << 13; - + switch (cd_addr) { case 0x310: // do nothing @@ -535,7 +535,7 @@ azt2316a_create_config_word(void *p) temp += 7 << 16; break; } - + switch (cd_dma8) { case 0xFF: /* -1 do nothing @@ -553,7 +553,7 @@ azt2316a_create_config_word(void *p) temp += 3 << 20; break; } - + switch (cd_dma16) { case 0xFF: /* -1 do nothing @@ -569,7 +569,7 @@ azt2316a_create_config_word(void *p) temp += 3 << 22; break; } - + switch (azt2316a->cur_mpu401_irq) { case 9: temp += 1 << 24; @@ -584,7 +584,7 @@ azt2316a_create_config_word(void *p) temp += 1 << 27; break; } - + switch (cd_irq) { case 5: temp += 1 << 28; @@ -603,7 +603,7 @@ azt2316a_create_config_word(void *p) azt2316a->config_word = temp; } -static uint8_t +static uint8_t azt2316a_config_read(uint16_t addr, void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -646,7 +646,7 @@ azt2316a_config_read(uint16_t addr, void *p) } -static void +static void azt1605_config_write(uint16_t addr, uint8_t val, void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -680,7 +680,7 @@ azt1605_config_write(uint16_t addr, uint8_t val, void *p) azt2316a->cur_mpu401_addr = 0x330; else azt2316a->cur_mpu401_addr = 0x300; - + if (val & 0x8) azt2316a->cur_mpu401_enabled = 1; else @@ -741,13 +741,13 @@ azt1605_config_write(uint16_t addr, uint8_t val, void *p) sb_dsp_setaddr(&azt2316a->sb->dsp, azt2316a->cur_addr); sb_dsp_setirq(&azt2316a->sb->dsp, azt2316a->cur_irq); sb_dsp_setdma8(&azt2316a->sb->dsp, azt2316a->cur_dma); - + mpu401_change_addr(azt2316a->mpu, azt2316a->cur_mpu401_addr); mpu401_setirq(azt2316a->mpu, azt2316a->cur_mpu401_irq); } } -static void +static void azt2316a_config_write(uint16_t addr, uint8_t val, void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -770,7 +770,7 @@ azt2316a_config_write(uint16_t addr, uint8_t val, void *p) case 0: azt2316a->config_word = (azt2316a->config_word & 0xFFFFFF00) | val; temp = val & 3; - + if (temp == 0) azt2316a->cur_addr = 0x220; else if (temp == 1) @@ -795,7 +795,7 @@ azt2316a_config_write(uint16_t addr, uint8_t val, void *p) break; case 1: azt2316a->config_word = (azt2316a->config_word & 0xFFFF00FF) | (val << 8); - + io_removehandler(azt2316a->cur_wss_addr, 0x0004, azt2316a_wss_read, NULL, NULL, azt2316a_wss_write, NULL, NULL, azt2316a); io_removehandler(azt2316a->cur_wss_addr + 0x0004, 0x0004, ad1848_read, NULL, NULL, ad1848_write, NULL, NULL, &azt2316a->ad1848); @@ -826,7 +826,7 @@ azt2316a_config_write(uint16_t addr, uint8_t val, void *p) if (val & 0x20) azt2316a->cur_mpu401_enabled = 1; else - azt2316a->cur_mpu401_enabled = 0; + azt2316a->cur_mpu401_enabled = 0; break; case 2: azt2316a->config_word = (azt2316a->config_word & 0xFF00FFFF) | (val << 16); @@ -849,14 +849,14 @@ azt2316a_config_write(uint16_t addr, uint8_t val, void *p) sb_dsp_setaddr(&azt2316a->sb->dsp, azt2316a->cur_addr); sb_dsp_setirq(&azt2316a->sb->dsp, azt2316a->cur_irq); sb_dsp_setdma8(&azt2316a->sb->dsp, azt2316a->cur_dma); - + mpu401_change_addr(azt2316a->mpu, azt2316a->cur_mpu401_addr); mpu401_setirq(azt2316a->mpu, azt2316a->cur_mpu401_irq); } } /* How it behaves when one or another is activated may affect games auto-detecting (and will also use more of the limited system resources!) */ -void +void azt2316a_enable_wss(uint8_t enable, void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -867,7 +867,7 @@ azt2316a_enable_wss(uint8_t enable, void *p) azt2316a->cur_mode = 0; } -static void +static void azt2316a_get_buffer(int32_t *buffer, int len, void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -895,9 +895,9 @@ azt_init(const device_t *info) uint8_t read_eeprom[AZTECH_EEPROM_SIZE]; azt2316a_t *azt2316a = malloc(sizeof(azt2316a_t)); memset(azt2316a, 0, sizeof(azt2316a_t)); - + azt2316a->type = info->local; - + if (azt2316a->type == SB_SUBTYPE_CLONE_AZT1605_0X0C) { fn = "azt1605.nvr"; } else if (azt2316a->type == SB_SUBTYPE_CLONE_AZT2316A_0X11) { @@ -910,20 +910,20 @@ azt_init(const device_t *info) uint8_t checksum = 0x7f; uint8_t saved_checksum; size_t res; - + res = fread(read_eeprom, AZTECH_EEPROM_SIZE, 1, f); for (i = 0; i < AZTECH_EEPROM_SIZE; i++) checksum += read_eeprom[i]; - + res = fread(&saved_checksum, sizeof(saved_checksum), 1, f); (void)res; fclose(f); - + if (checksum == saved_checksum) loaded_from_eeprom = 1; } - + if (!loaded_from_eeprom) { if (azt2316a->type == SB_SUBTYPE_CLONE_AZT2316A_0X11) { read_eeprom[0] = 0x00; @@ -986,7 +986,7 @@ azt_init(const device_t *info) azt2316a->cur_irq = 10; else fatal("AZT2316A: invalid sb irq in config word %08X\n", azt2316a->config_word); - + switch (azt2316a->config_word & (3 << 6)) { case 1 << 6: azt2316a->cur_dma = 0; @@ -1000,7 +1000,7 @@ azt_init(const device_t *info) default: fatal("AZT2316A: invalid sb dma in config word %08X\n", azt2316a->config_word); } - + switch (azt2316a->config_word & (3 << 8)) { case 0: azt2316a->cur_wss_addr = 0x530; @@ -1022,7 +1022,7 @@ azt_init(const device_t *info) azt2316a->cur_wss_enabled = 1; else azt2316a->cur_wss_enabled = 0; - + if (azt2316a->config_word & (1 << 12)) azt2316a->cur_mpu401_addr = 0x330; else @@ -1032,7 +1032,7 @@ azt_init(const device_t *info) azt2316a->cur_mpu401_enabled = 1; else azt2316a->cur_mpu401_enabled = 0; - + if (azt2316a->config_word & (1 << 24)) azt2316a->cur_mpu401_irq = 9; else if (azt2316a->config_word & (1 << 25)) @@ -1043,14 +1043,14 @@ azt_init(const device_t *info) azt2316a->cur_mpu401_irq = 10; else fatal("AZT2316A: invalid mpu401 irq in config word %08X\n", azt2316a->config_word); - + /* these are not present on the EEPROM */ azt2316a->cur_wss_irq = device_get_config_int("wss_irq"); azt2316a->cur_wss_dma = device_get_config_int("wss_dma"); azt2316a->cur_mode = 0; } else if (azt2316a->type == SB_SUBTYPE_CLONE_AZT1605_0X0C) { azt2316a->config_word = read_eeprom[12] + (read_eeprom[13] << 8) + (read_eeprom[14] << 16); - + switch (azt2316a->config_word & (3 << 0)) { case 0: azt2316a->cur_addr = 0x220; @@ -1061,17 +1061,17 @@ azt_init(const device_t *info) default: fatal("AZT1605: invalid sb addr in config word %08X\n", azt2316a->config_word); } - + if (azt2316a->config_word & (1 << 2)) azt2316a->cur_mpu401_addr = 0x330; else azt2316a->cur_mpu401_addr = 0x300; - + if (azt2316a->config_word & (1 << 3)) azt2316a->cur_mpu401_enabled = 1; else azt2316a->cur_mpu401_enabled = 0; - + if (azt2316a->config_word & (1 << 8)) azt2316a->cur_irq = 9; else if (azt2316a->config_word & (1 << 9)) @@ -1093,7 +1093,7 @@ azt_init(const device_t *info) azt2316a->cur_mpu401_irq = 7; else fatal("AZT1605: invalid mpu401 irq in config word %08X\n", azt2316a->config_word); - + switch (azt2316a->config_word & (3 << 16)) { case 0: azt2316a->cur_wss_addr = 0x530; @@ -1115,7 +1115,7 @@ azt_init(const device_t *info) azt2316a->cur_wss_enabled = 1; else azt2316a->cur_wss_enabled = 0; - + // these are not present on the EEPROM azt2316a->cur_dma = device_get_config_int("sb_dma8"); // TODO: investigate TSR to make this work with it - there is no software configurable DMA8? azt2316a->cur_wss_irq = device_get_config_int("wss_irq"); @@ -1152,10 +1152,10 @@ azt_init(const device_t *info) for (i = 0; i < AZTECH_EEPROM_SIZE; i++) azt2316a->sb->dsp.azt_eeprom[i] = read_eeprom[i]; - + if (azt2316a->sb->opl_enabled) opl3_init(&azt2316a->sb->opl); - + sb_dsp_init(&azt2316a->sb->dsp, SBPRO2, azt2316a->type, azt2316a); sb_dsp_setaddr(&azt2316a->sb->dsp, azt2316a->cur_addr); sb_dsp_setirq(&azt2316a->sb->dsp, azt2316a->cur_irq); @@ -1167,7 +1167,7 @@ azt_init(const device_t *info) io_sethandler(azt2316a->cur_addr+8, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &azt2316a->sb->opl); io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &azt2316a->sb->opl); } - + io_sethandler(azt2316a->cur_addr+4, 0x0002, sb_ct1345_mixer_read, NULL, NULL, sb_ct1345_mixer_write, NULL, NULL, azt2316a->sb); azt2316a_create_config_word(azt2316a); @@ -1187,7 +1187,7 @@ azt_init(const device_t *info) return azt2316a; } -static void +static void azt_close(void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; @@ -1222,7 +1222,7 @@ azt_close(void *p) free(azt2316a); } -static void +static void azt_speed_changed(void *p) { azt2316a_t *azt2316a = (azt2316a_t *)p; diff --git a/src/sound/snd_cms.c b/src/sound/snd_cms.c index b0f979849..69481dd17 100644 --- a/src/sound/snd_cms.c +++ b/src/sound/snd_cms.c @@ -59,7 +59,7 @@ void cms_update(cms_t *cms) { cms->noisecount[c][d] -= 24000; cms->noise[c][d] <<= 1; - if (!(((cms->noise[c][d] & 0x4000) >> 8) ^ (cms->noise[c][d] & 0x40))) + if (!(((cms->noise[c][d] & 0x4000) >> 8) ^ (cms->noise[c][d] & 0x40))) cms->noise[c][d] |= 1; } } @@ -73,11 +73,11 @@ void cms_update(cms_t *cms) void cms_get_buffer(int32_t *buffer, int len, void *p) { cms_t *cms = (cms_t *)p; - + int c; cms_update(cms); - + for (c = 0; c < len * 2; c++) buffer[c] += cms->buffer[c]; @@ -89,7 +89,7 @@ void cms_write(uint16_t addr, uint8_t val, void *p) cms_t *cms = (cms_t *)p; int voice; int chip = (addr & 2) >> 1; - + switch (addr & 0xf) { case 1: @@ -98,7 +98,7 @@ void cms_write(uint16_t addr, uint8_t val, void *p) case 3: cms->addrs[1] = val & 31; break; - + case 0: case 2: cms_update(cms); cms->regs[chip][cms->addrs[chip] & 31] = val; @@ -167,7 +167,7 @@ void *cms_init(const device_t *info) void cms_close(void *p) { cms_t *cms = (cms_t *)p; - + free(cms); } diff --git a/src/sound/snd_emu8k.c b/src/sound/snd_emu8k.c index 8f324cfaa..a83a41cb1 100644 --- a/src/sound/snd_emu8k.c +++ b/src/sound/snd_emu8k.c @@ -42,25 +42,25 @@ char *PORT_NAMES[][8] = "Unk-620-5", "AWE_PSST", "AWE_CSL", - }, + }, /* Data 1 0xA20 */ { "AWE_CCCA", 0, /* - "AWE_HWCF4" - "AWE_HWCF5" - "AWE_HWCF6" - "AWE_HWCF7" - "AWE_SMALR" - "AWE_SMARR" - "AWE_SMALW" - "AWE_SMARW" - "AWE_SMLD" - "AWE_SMRD" - "AWE_WC" - "AWE_HWCF1" - "AWE_HWCF2" - "AWE_HWCF3" + "AWE_HWCF4" + "AWE_HWCF5" + "AWE_HWCF6" + "AWE_HWCF7" + "AWE_SMALR" + "AWE_SMARR" + "AWE_SMALW" + "AWE_SMARW" + "AWE_SMLD" + "AWE_SMRD" + "AWE_WC" + "AWE_HWCF1" + "AWE_HWCF2" + "AWE_HWCF3" */ 0,//"AWE_INIT1", 0,//"AWE_INIT3", @@ -123,7 +123,7 @@ static int32_t attentable[256]; /* Conversion from envelope dbs (once rigth shifted) (0 = 0dBFS, 65535 = -96dbFS and silence ) to 16 bit unsigned lineal amplitude, * to convert to current volume. (0 to 65536) */ static int32_t env_vol_db_to_vol_target[65537]; -/* Same as above, but to convert amplitude (once rigth shifted) (0 to 65536) to db (0 = 0dBFS, 65535 = -96dbFS and silence ). +/* Same as above, but to convert amplitude (once rigth shifted) (0 to 65536) to db (0 = 0dBFS, 65535 = -96dbFS and silence ). * it is needed so that the delay, attack and hold phase can be added to initial attenuation and tremolo */ static int32_t env_vol_amplitude_to_db[65537]; /* Conversion from envelope herts (once right shifted) to octave . it is needed so that the delay, attack and hold phase can be @@ -132,15 +132,15 @@ static int32_t env_mod_hertz_to_octave[65537]; /* Conversion from envelope amount to time in samples. */ static int32_t env_attack_to_samples[128]; /* This table has been generated using the following formula: - * Get the amount of dBs that have to be added each sample to reach 96dBs in the amount + * Get the amount of dBs that have to be added each sample to reach 96dBs in the amount * of time determined by the encoded value "i". * float d = 1.0/((env_decay_to_millis[i]/96.0)*44.1); * int result = round(d*21845); * The multiplication by 21845 gives a minimum value of 1, and a maximum accumulated value of 1<<21 - * The accumulated value has to be converted to amplitude, and that can be done with the + * The accumulated value has to be converted to amplitude, and that can be done with the * env_vol_db_to_vol_target and shifting by 8 * In other words, the unit of the table is the 1/21845th of a dB per sample frame, to be added or - * substracted to the accumulating value_db of the envelope. */ + * substracted to the accumulating value_db of the envelope. */ static int32_t env_decay_to_dbs_or_oct[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -188,9 +188,9 @@ static const int REV_BUFSIZE_STEP=242; * Filter cutoff from 100Hz to 8000Hz * This table comes from the awe32faq, describing the NRPN control for the filter Q. - * I don't know if is meant to be interpreted as the actual measured output of the + * I don't know if is meant to be interpreted as the actual measured output of the * filter or what. Especially, I don't understand the "low" and "high" ranges. - * What is otherwise documented is that the Q ranges from 0dB to 24dB and the attenuation + * What is otherwise documented is that the Q ranges from 0dB to 24dB and the attenuation * is half of the Q ( i.e. for 12dB Q, attenuate the input signal with -6dB) Coeff Low Fc(Hz)Low Q(dB)High Fc(kHz)High Q(dB)DC Attenuation(dB) * 0 92 5 Flat Flat -0.0 @@ -225,7 +225,7 @@ static int32_t filt_coeffs[16][256][3]; case 0: ret = (var) & 0xffff; break; \ case 2: ret = ((var) >> 16) & 0xffff; break; \ } - + #define WRITE16_SWITCH(addr, var, val) switch ((addr) & 2) \ { \ case 0: var = (var & 0xffff0000) | (val); break; \ @@ -289,9 +289,9 @@ uint32_t rep_count_w = 0; } #else -# define READ16(addr, var) READ16_SWITCH(addr, var) +# define READ16(addr, var) READ16_SWITCH(addr, var) # define WRITE16(addr, var, val) WRITE16_SWITCH(addr, var, val) -#endif //EMU8K_DEBUG_REGISTERS +#endif //EMU8K_DEBUG_REGISTERS #ifdef ENABLE_EMU8K_LOG @@ -326,7 +326,7 @@ static inline int16_t EMU8K_READ_INTERP_LINEAR(emu8k_t *emu8k, uint32_t int_addr /* The interpolation in AWE32 used a so-called patented 3-point interpolation * ( I guess some sort of spline having one point before and one point after). * Also, it has the consequence that the playback is delayed by one sample. - * I simulate the "one sample later" than the address with addr+1 and addr+2 + * I simulate the "one sample later" than the address with addr+1 and addr+2 * instead of +0 and +1 */ int16_t dat1 = EMU8K_READ(emu8k, int_addr+1); int32_t dat2 = EMU8K_READ(emu8k, int_addr+2); @@ -382,11 +382,11 @@ uint16_t emu8k_inw(uint16_t addr, void *p) { emu8k_t *emu8k = (emu8k_t *)p; uint16_t ret = 0xffff; - + #ifdef EMU8K_DEBUG_REGISTERS if (addr == 0xE22) { - emu8k_log("EMU8K READ POINTER: %d\n", + emu8k_log("EMU8K READ POINTER: %d\n", ((0x80 | ((random_helper + 1) & 0x1F)) << 8) | (emu8k->cur_reg << 5) | emu8k->cur_voice); } else if ((addr&0xF00) == 0x600) @@ -422,7 +422,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p) last_read=tmpz; emu8k_log("EMU8K READ RAM I/O or configuration or clock \n"); } - //emu8k_log("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice); + //emu8k_log("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice); } else if ((addr&0xF00) == 0xA00 && (emu8k->cur_reg == 2 || emu8k->cur_reg == 3)) { @@ -437,10 +437,10 @@ uint16_t emu8k_inw(uint16_t addr, void *p) last_read=tmpz; emu8k_log("EMU8K READ INIT \n"); } - //emu8k_log("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice); + //emu8k_log("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice); } else - { + { uint32_t tmpz = (addr << 16)|(emu8k->cur_reg<<5)| emu8k->cur_voice; if (tmpz != last_read) { @@ -492,12 +492,12 @@ uint16_t emu8k_inw(uint16_t addr, void *p) emu8k_log("EMU8K ...... for %d times\n", rep_count_r); } if (name == 0) - { - emu8k_log("EMU8K READ %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice,val); + { + emu8k_log("EMU8K READ %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice,val); } else - { - emu8k_log("EMU8K READ %s (%d): %04X\n",name,emu8k->cur_voice, val); + { + emu8k_log("EMU8K READ %s (%d): %04X\n",name,emu8k->cur_voice, val); } rep_count_r=0; @@ -516,31 +516,31 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 0: READ16(addr, emu8k->voice[emu8k->cur_voice].cpf); return ret; - + case 1: READ16(addr, emu8k->voice[emu8k->cur_voice].ptrx); return ret; - + case 2: READ16(addr, emu8k->voice[emu8k->cur_voice].cvcf); return ret; - + case 3: READ16(addr, emu8k->voice[emu8k->cur_voice].vtft); return ret; - - case 4: + + case 4: READ16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_4); return ret; case 5: READ16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_5); return ret; - + case 6: READ16(addr, emu8k->voice[emu8k->cur_voice].psst); return ret; - + case 7: READ16(addr, emu8k->voice[emu8k->cur_voice].csl); return ret; @@ -570,7 +570,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 14: READ16(addr, emu8k->hwcf7); return ret; - + case 20: READ16(addr, emu8k->smalr); return ret; @@ -583,7 +583,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 23: READ16(addr, emu8k->smarw); return ret; - + case 26: { uint16_t val = emu8k->smld_buffer; @@ -596,7 +596,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 29: /*Configuration Word 1*/ return (emu8k->hwcf1 & 0xfe) | (emu8k->hwcf3 & 0x01); case 30: /*Configuration Word 2*/ - return ((emu8k->hwcf2 >> 4) & 0x0e) | (emu8k->hwcf1 & 0x01) | ((emu8k->hwcf3 & 0x02) ? 0x10 : 0) | ((emu8k->hwcf3 & 0x04) ? 0x40 : 0) + return ((emu8k->hwcf2 >> 4) & 0x0e) | (emu8k->hwcf1 & 0x01) | ((emu8k->hwcf3 & 0x02) ? 0x10 : 0) | ((emu8k->hwcf3 & 0x04) ? 0x40 : 0) | ((emu8k->hwcf3 & 0x08) ? 0x20 : 0) | ((emu8k->hwcf3 & 0x10) ? 0x80 : 0); case 31: /*Configuration Word 3*/ return emu8k->hwcf2 & 0x1f; @@ -605,16 +605,16 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 2: return emu8k->init1[emu8k->cur_voice]; - + case 3: return emu8k->init3[emu8k->cur_voice]; - + case 4: return emu8k->voice[emu8k->cur_voice].envvol; case 5: return emu8k->voice[emu8k->cur_voice].dcysusv; - + case 6: return emu8k->voice[emu8k->cur_voice].envval; @@ -668,7 +668,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p) /*xor with itself to set to zero faster.*/ dmawritebit^=dmawritebit; return ret; - + case 26: { uint16_t val = emu8k->smrd_buffer; @@ -689,21 +689,21 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 3: return emu8k->init4[emu8k->cur_voice]; - - case 4: + + case 4: return emu8k->voice[emu8k->cur_voice].atkhldv; - case 5: + case 5: return emu8k->voice[emu8k->cur_voice].lfo1val; - case 6: + case 6: return emu8k->voice[emu8k->cur_voice].atkhld; - case 7: + case 7: return emu8k->voice[emu8k->cur_voice].lfo2val; } break; - + case 0xE00: /*Data3. also known as BLASTER+0xC00 and EMU+0x800 */ switch (emu8k->cur_reg) { @@ -727,7 +727,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 6: return 0xffff; - + case 7: /*ID?*/ return 0x1c | ((emu8k->id & 0x0002) ? 0xff02 : 0); } @@ -736,7 +736,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p) case 0xE02: /* Pointer. also known as BLASTER+0xC02 and EMU+0x802 */ /* LS five bits = channel number, next 3 bits = register number * and MS 8 bits = VLSI test register. - * Impulse tracker tests the non variability of the LS byte that it has set, and the variability + * Impulse tracker tests the non variability of the LS byte that it has set, and the variability * of the MS byte to determine that it really is an AWE32. * cubic player has a similar code, where it waits until value & 0x1000 is nonzero, and then waits again until it changes to zero.*/ random_helper = (random_helper + 1) & 0x1F; @@ -792,7 +792,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) last_write=tmpz; emu8k_log("EMU8K WRITE RAM I/O or configuration \n"); } - //emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val); + //emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val); } else if ((addr&0xF00) == 0xA00 && (emu8k->cur_reg == 2 || emu8k->cur_reg == 3)) { @@ -807,10 +807,10 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) last_write=tmpz; emu8k_log("EMU8K WRITE INIT \n"); } - //emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val); + //emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val); } else if (addr != 0xE22) - { + { uint32_t tmpz = (addr << 16)|(emu8k->cur_reg<<5)| emu8k->cur_voice; //if (tmpz != last_write) if(1) @@ -834,14 +834,14 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) emu8k_log("EMU8K ...... for %d times\n", rep_count_w); } if (name == 0) - { - emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val); + { + emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val); } else - { + { emu8k_log("EMU8K WRITE %s (%d): %04X\n",name,emu8k->cur_voice, val); } - + rep_count_w=0; last_write=tmpz; } @@ -859,28 +859,28 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) /* The docs says that this value is constantly updating, and it should have no actual effect. Actions should be done over ptrx */ WRITE16(addr, emu8k->voice[emu8k->cur_voice].cpf, val); return; - + case 1: WRITE16(addr, emu8k->voice[emu8k->cur_voice].ptrx, val); return; - + case 2: /* The docs says that this value is constantly updating, and it should have no actual effect. Actions should be done over vtft */ WRITE16(addr, emu8k->voice[emu8k->cur_voice].cvcf, val); return; - + case 3: WRITE16(addr, emu8k->voice[emu8k->cur_voice].vtft, val); return; - - case 4: + + case 4: WRITE16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_4, val); return; case 5: WRITE16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_5, val); return; - + case 6: { emu8k_voice_t *emu_voice = &emu8k->voice[emu8k->cur_voice]; @@ -894,7 +894,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) } } return; - + case 7: WRITE16(addr, emu8k->voice[emu8k->cur_voice].csl, val); /* TODO: Should we update only on MSB update, or this could be used as some sort of hack by applications? */ @@ -941,7 +941,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) case 23: WRITE16(addr, emu8k->smarw, val); return; - + case 26: EMU8K_WRITE(emu8k, emu8k->smalw, val); emu8k->smalw = (emu8k->smalw+1) & EMU8K_MEM_ADDRESS_MASK; @@ -968,7 +968,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) { case 0x3: emu8k->reverb_engine.out_mix = val&0xFF; break; - case 0x5: + case 0x5: { int c; for (c=0;c<8;c++) @@ -1015,27 +1015,27 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) /* Limiting this to a sane value given our buffer. */ emu8k->chorus_engine.delay_samples_central = (val&0x1FFF); break; - + case 1: emu8k->reverb_engine.refl_in_amp = val&0xFF; break; case 3: //emu8k->reverb_engine.refl_in_amp_r = val&0xFF; break; - } + } } - return; - + return; + case 4: emu8k->voice[emu8k->cur_voice].envvol = val; emu8k->voice[emu8k->cur_voice].vol_envelope.delay_samples = ENVVOL_TO_EMU_SAMPLES(val); return; - + case 5: { emu8k->voice[emu8k->cur_voice].dcysusv = val; emu8k_envelope_t * const vol_env = &emu8k->voice[emu8k->cur_voice].vol_envelope; int old_on=emu8k->voice[emu8k->cur_voice].env_engine_on; emu8k->voice[emu8k->cur_voice].env_engine_on = DCYSUSV_GENERATOR_ENGINE_ON(val); - + if (emu8k->voice[emu8k->cur_voice].env_engine_on && old_on != emu8k->voice[emu8k->cur_voice].env_engine_on) { @@ -1045,7 +1045,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) the hwcfg and init registers (doom does not init the card at all. only tests the cfg registers) */ emu8k->hwcf3 = 0x04; } - + //reset lfos. emu8k->voice[emu8k->cur_voice].lfo1_count.addr = 0; emu8k->voice[emu8k->cur_voice].lfo2_count.addr = 0; @@ -1073,7 +1073,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) }*/ } } - + if (ATKHLD_TRIGGER(emu8k->voice[emu8k->cur_voice].atkhld)) { emu8k_envelope_t* const mod_env = &emu8k->voice[emu8k->cur_voice].mod_envelope; @@ -1100,7 +1100,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) } } } - + /* Converting the input in dBs to envelope value range. */ vol_env->sustain_value_db_oct = DCYSUSV_SUS_TO_ENV_RANGE(DCYSUSV_SUSVALUE_GET(val)); @@ -1147,7 +1147,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) return; } break; - + case 0xA02: /*Data2. also known as BLASTER+0x802 and EMU+0x402 */ switch (emu8k->cur_reg) { @@ -1234,7 +1234,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) { switch(emu8k->cur_voice) { - case 0x14: + case 0x14: { int multip = ((val&0xF00)>>8)+18; emu8k->reverb_engine.reflections[5].bufsize = multip*REV_BUFSIZE_STEP; @@ -1258,7 +1258,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) break; case 0x17: emu8k->reverb_engine.reflections[5].output_gain = ((val&0xF0)>>4)/15.0; break; - case 0x1d: + case 0x1d: { int c; for (c=0;c<6;c++) @@ -1304,13 +1304,13 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) } break; - + case 0x1F: emu8k->reverb_engine.link_return_amp = val&0xFF; break; } } - return ; + return ; case 4: { @@ -1329,7 +1329,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) vol_env->hold_samples = ATKHLDV_HOLD_TO_EMU_SAMPLES(val); if (ATKHLDV_TRIGGER(val) && emu8k->voice[emu8k->cur_voice].env_engine_on) { - /*TODO: I assume that "envelope trigger" is the same as new note + /*TODO: I assume that "envelope trigger" is the same as new note * (since changing the IP can be done when modulating pitch too) */ emu8k->voice[emu8k->cur_voice].lfo1_count.addr = 0; emu8k->voice[emu8k->cur_voice].lfo2_count.addr = 0; @@ -1357,7 +1357,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) } } return; - + case 5: emu8k->voice[emu8k->cur_voice].lfo1val = val; /* TODO: verify if this is set once, or set every time. */ @@ -1405,7 +1405,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) } } return; - + case 7: emu8k->voice[emu8k->cur_voice].lfo2val = val; emu8k->voice[emu8k->cur_voice].lfo2_delay_samples = LFOxVAL_TO_EMU_SAMPLES(val); @@ -1413,7 +1413,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) return; } break; - + case 0xE00: /*Data3. also known as BLASTER+0xC00 and EMU+0x800 */ switch (emu8k->cur_reg) { @@ -1421,21 +1421,21 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) emu8k->voice[emu8k->cur_voice].ip = val; emu8k->voice[emu8k->cur_voice].ptrx_pit_target = freqtable[val] >> 18; return; - + case 1: { emu8k_voice_t * const the_voice = &emu8k->voice[emu8k->cur_voice]; - if ((val&0xFF) == 0 && the_voice->cvcf_curr_volume == 0 && the_voice->vtft_vol_target == 0 + if ((val&0xFF) == 0 && the_voice->cvcf_curr_volume == 0 && the_voice->vtft_vol_target == 0 && the_voice->dcysusv == 0x80 && the_voice->ip == 0) { - // Patch to avoid some clicking noises with Impulse tracker or other software that sets + // Patch to avoid some clicking noises with Impulse tracker or other software that sets // different values to 0 to set noteoff, but here, 0 means no attenuation = full volume. return; } the_voice->ifatn = val; the_voice->initial_att = (((int32_t)the_voice->ifatn_attenuation <<21)/0xFF); the_voice->vtft_vol_target = attentable[the_voice->ifatn_attenuation]; - + the_voice->initial_filter = (((int32_t)the_voice->ifatn_init_filter <<21)/0xFF); if (the_voice->ifatn_init_filter==0xFF) { @@ -1490,7 +1490,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) emu8k_voice_t * const the_voice = &emu8k->voice[emu8k->cur_voice]; the_voice->fm2frq2 = val; the_voice->lfo2_speed = lfofreqtospeed[the_voice->fm2frq2_lfo2_freq]; - + int divider = (the_voice->fm2frq2_lfo2_vibrato < 0) ? 0x80 : 0x7F; the_voice->fixed_lfo2_vibrato = ((int32_t)the_voice->fm2frq2_lfo2_vibrato)*0x4000/divider; } @@ -1501,7 +1501,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p) return; } break; - + case 0xE02: /* Pointer. also known as BLASTER+0xC02 and EMU+0x802 */ emu8k->cur_voice = (val & 31); emu8k->cur_reg = ((val >> 5) & 7); @@ -1536,7 +1536,7 @@ void emu8k_work_chorus(int32_t *inbuf, int32_t *outbuf, emu8k_chorus_eng_t *engi { int pos; for (pos = 0; pos < count; pos++) - { + { double lfo_inter1 = chortable[engine->lfo_pos.int_address]; // double lfo_inter2 = chortable[(engine->lfo_pos.int_address+1)&0xFFFF]; @@ -1561,10 +1561,10 @@ void emu8k_work_chorus(int32_t *inbuf, int32_t *outbuf, emu8k_chorus_eng_t *engi int32_t dat1 = engine->chorus_left_buffer[read]; int32_t dat2 = engine->chorus_left_buffer[next_value]; dat1 += ((dat2-dat1)* fraction_part) >> 16; - + engine->chorus_left_buffer[engine->write] = *inbuf + ((dat1 * engine->feedback)>>8); - - + + /* Work right */ readdouble = (double)engine->write - (double)engine->delay_samples_central - engine->delay_offset_samples_right - offset_lfo; read = (int32_t)floor(readdouble); @@ -1581,10 +1581,10 @@ void emu8k_work_chorus(int32_t *inbuf, int32_t *outbuf, emu8k_chorus_eng_t *engi } int32_t dat3 = engine->chorus_right_buffer[read]; int32_t dat4 = engine->chorus_right_buffer[next_value]; - dat3 += ((dat4-dat3)* fraction_part) >> 16; - + dat3 += ((dat4-dat3)* fraction_part) >> 16; + engine->chorus_right_buffer[engine->write] = *inbuf + ((dat3 * engine->feedback)>>8); - + ++engine->write; engine->write %= EMU8K_LFOCHORUS_SIZE; engine->lfo_pos.addr +=engine->lfo_inc.addr; @@ -1594,12 +1594,12 @@ void emu8k_work_chorus(int32_t *inbuf, int32_t *outbuf, emu8k_chorus_eng_t *engi (*outbuf++) += dat3; inbuf++; } - + } int32_t emu8k_reverb_comb_work(emu8k_reverb_combfilter_t* comb, int32_t in) { - + int32_t bufin; /* get echo */ int32_t output = comb->reflection[comb->read_pos]; @@ -1617,7 +1617,7 @@ int32_t emu8k_reverb_comb_work(emu8k_reverb_combfilter_t* comb, int32_t in) int32_t emu8k_reverb_diffuser_work(emu8k_reverb_combfilter_t* comb, int32_t in) { - + int32_t bufout = comb->reflection[comb->read_pos]; /*diffuse*/ int32_t bufin = -in + (bufout*comb->feedback); @@ -1635,14 +1635,14 @@ int32_t emu8k_reverb_tail_work(emu8k_reverb_combfilter_t* comb, emu8k_reverb_com int32_t output = comb->reflection[comb->read_pos]; /* store new value in delayed buffer */ comb->reflection[comb->read_pos] = in; - + //output = emu8k_reverb_allpass_work(&allpasses[0],output); output = emu8k_reverb_diffuser_work(&allpasses[1],output); output = emu8k_reverb_diffuser_work(&allpasses[2],output); //output = emu8k_reverb_allpass_work(&allpasses[3],output); - + if(++comb->read_pos>=comb->bufsize) comb->read_pos = 0; - + return output; } int32_t emu8k_reverb_damper_work(emu8k_reverb_combfilter_t* comb, int32_t in) @@ -1659,7 +1659,7 @@ void emu8k_work_reverb(int32_t *inbuf, int32_t *outbuf, emu8k_reverb_eng_t *engi if (engine->link_return_type) { for (pos = 0; pos < count; pos++) - { + { int32_t dat1, dat2, in, in2; in = emu8k_reverb_damper_work(&engine->damper, inbuf[pos]); in2 = (in * engine->refl_in_amp) >> 8; @@ -1669,18 +1669,18 @@ void emu8k_work_reverb(int32_t *inbuf, int32_t *outbuf, emu8k_reverb_eng_t *engi dat2 += emu8k_reverb_comb_work(&engine->reflections[3], in2); dat1 += emu8k_reverb_comb_work(&engine->reflections[4], in2); dat2 += emu8k_reverb_comb_work(&engine->reflections[5], in2); - + dat1 += (emu8k_reverb_tail_work(&engine->tailL,&engine->allpass[0], in+dat1)*engine->link_return_amp) >> 8; dat2 += (emu8k_reverb_tail_work(&engine->tailR,&engine->allpass[4], in+dat2)*engine->link_return_amp) >> 8; - + (*outbuf++) += (dat1 * engine->out_mix) >> 8; (*outbuf++) += (dat2 * engine->out_mix) >> 8; } } else - { + { for (pos = 0; pos < count; pos++) - { + { int32_t dat1, dat2, in, in2; in = emu8k_reverb_damper_work(&engine->damper, inbuf[pos]); in2 = (in * engine->refl_in_amp) >> 8; @@ -1691,10 +1691,10 @@ void emu8k_work_reverb(int32_t *inbuf, int32_t *outbuf, emu8k_reverb_eng_t *engi dat1 += emu8k_reverb_comb_work(&engine->reflections[4], in2); dat1 += emu8k_reverb_comb_work(&engine->reflections[5], in2); dat2 = dat1; - + dat1 += (emu8k_reverb_tail_work(&engine->tailL,&engine->allpass[0], in+dat1)*engine->link_return_amp) >> 8; dat2 += (emu8k_reverb_tail_work(&engine->tailR,&engine->allpass[4], in+dat2)*engine->link_return_amp) >> 8; - + (*outbuf++) += (dat1 * engine->out_mix) >> 8; (*outbuf++) += (dat2 * engine->out_mix) >> 8; } @@ -1746,7 +1746,7 @@ void emu8k_update(emu8k_t *emu8k) { emu_voice = &emu8k->voice[c]; buf = &emu8k->buffer[emu8k->pos*2]; - + for (pos = emu8k->pos; pos < new_pos; pos++) { int32_t dat; @@ -1779,7 +1779,7 @@ void emu8k_update(emu8k_t *emu8k) /* Apply expected attenuation. (FILTER_MOOG does it implicitly, but this one doesn't). * Work in 24bits. */ dat = (dat * emu_voice->filt_att) >> 8; - + int64_t vhp = ((-emu_voice->filt_buffer[0] * coef2) >> 24) - emu_voice->filt_buffer[1] - dat; emu_voice->filt_buffer[1] += (emu_voice->filt_buffer[0] * coef0) >> 24; emu_voice->filt_buffer[0] += (vhp * coef0) >> 24; @@ -1791,7 +1791,7 @@ void emu8k_update(emu8k_t *emu8k) /*move to 24bits*/ dat <<= 8; - + dat -= (coef2 * emu_voice->filt_buffer[4]) >> 24; /*feedback*/ int64_t t1 = emu_voice->filt_buffer[1]; emu_voice->filt_buffer[1] = ((dat + emu_voice->filt_buffer[0]) * coef0 - emu_voice->filt_buffer[1] * coef1) >> 24; @@ -1835,7 +1835,7 @@ void emu8k_update(emu8k_t *emu8k) else if (dat < -32768) { dat = -32768; } #endif - + } if (( emu8k->hwcf3 & 0x04) && !CCCA_DMA_ACTIVE(emu_voice->ccca)) { @@ -1875,7 +1875,7 @@ void emu8k_update(emu8k_t *emu8k) } attenuation = 0x1FFFFF; break; - + case ENV_ATTACK: /* Attack amount is in linear amplitude */ volenv->value_amp_hz += volenv->attack_amount_amp_hz; @@ -1895,7 +1895,7 @@ void emu8k_update(emu8k_t *emu8k) } attenuation += env_vol_amplitude_to_db[volenv->value_amp_hz >> 5] << 5; break; - + case ENV_HOLD: volenv->hold_samples--; if (volenv->hold_samples <=0) @@ -1926,11 +1926,11 @@ void emu8k_update(emu8k_t *emu8k) } attenuation += volenv->value_db_oct; break; - + case ENV_SUSTAIN: attenuation += volenv->value_db_oct; break; - + case ENV_STOPPED: attenuation = 0x1FFFFF; break; @@ -1947,7 +1947,7 @@ void emu8k_update(emu8k_t *emu8k) modenv->delay_samples=0; } break; - + case ENV_ATTACK: /* Attack amount is in linear amplitude */ modenv->value_amp_hz += modenv->attack_amount_amp_hz; @@ -1974,7 +1974,7 @@ void emu8k_update(emu8k_t *emu8k) modenv->state=ENV_RAMP_UP; } break; - + case ENV_RAMP_DOWN: /* Decay/release amount is in fraction of octave and is always positive */ modenv->value_db_oct -= modenv->ramp_amount_db_oct; @@ -2095,7 +2095,7 @@ I've recopilated these sentences to get an idea of how to loop emu_voice->cvcf_curr_volume = emu8k_vol_slide(&emu_voice->volumeslide,emu_voice->vtft_vol_target); emu_voice->cvcf_curr_filt_ctoff = emu_voice->vtft_filter_target; } - + /* Update EMU voice registers. */ emu_voice->ccca = (((uint32_t)emu_voice->ccca_qcontrol) << 24) | emu_voice->addr.int_address; emu_voice->cpf_curr_frac_addr = emu_voice->addr.fract_address; @@ -2107,20 +2107,20 @@ I've recopilated these sentences to get an idea of how to loop //pclog("EMUFILT :%d\n", emu_voice->cvcf_curr_filt_ctoff); } - + buf = &emu8k->buffer[emu8k->pos*2]; emu8k_work_reverb(&emu8k->reverb_in_buffer[emu8k->pos], buf, &emu8k->reverb_engine, new_pos-emu8k->pos); emu8k_work_chorus(&emu8k->chorus_in_buffer[emu8k->pos], buf, &emu8k->chorus_engine, new_pos-emu8k->pos); emu8k_work_eq(buf, new_pos-emu8k->pos); - + // Clip signal - for (pos = emu8k->pos; pos < new_pos; pos++) + for (pos = emu8k->pos; pos < new_pos; pos++) { if (buf[0] < -32768) buf[0] = -32768; else if (buf[0] > 32767) buf[0] = 32767; - + if (buf[1] < -32768) buf[1] = -32768; else if (buf[1] > 32767) @@ -2131,7 +2131,7 @@ I've recopilated these sentences to get an idea of how to loop /* Update EMU clock. */ emu8k->wc += (new_pos - emu8k->pos); - + emu8k->pos = new_pos; } @@ -2159,12 +2159,12 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) FILE *f; int c; double out; - + f = rom_fopen("roms/sound/awe32.raw", "rb"); if (!f) fatal("AWE32.RAW not found\n"); - - emu8k->rom = malloc(1024 * 1024); + + emu8k->rom = malloc(1024 * 1024); if (fread(emu8k->rom, 1, 1048576, f) != 1048576) fatal("emu8k_init(): Error reading data\n"); fclose(f); @@ -2176,7 +2176,7 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) emu8k->rom[0x7ffff] = 0; } - emu8k->empty = malloc(2*BLOCK_SIZE_WORDS); + emu8k->empty = malloc(2*BLOCK_SIZE_WORDS); memset(emu8k->empty, 0, 2*BLOCK_SIZE_WORDS); int j=0; @@ -2211,7 +2211,7 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) for (;j < 0x100;j++) { emu8k->ram_pointers[j]=emu8k->empty; - + } emu8k_change_addr(emu8k, emu_addr); @@ -2234,12 +2234,12 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) out = 65535.0; for (c = 0; c < 256; c++) { - attentable[c] = (int32_t)out; + attentable[c] = (int32_t)out; out /= sqrt(1.09018); /*0.375 dB steps*/ } /* Shortcut: max attenuation is silent, not -96dB. */ attentable[255]=0; - + /* Note: these two tables have "db" inverted: 0 dB is max volume, 65535 "db" (-96.32dBFS) is silence. * Important: Using 65535 as max output value because this is intended to be used with the volume target register! */ out = 65535.0; @@ -2266,7 +2266,7 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) /* One more position to accept max value being 65536. */ env_vol_amplitude_to_db[0x10000]=0; - + for (c = 1; c < 0x10000; c++) { out = log2((((double)c)/0x10000)+1.0) *65536.0; @@ -2277,7 +2277,7 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) /* One more position to accept max value being 65536. */ env_mod_hertz_to_octave[0x10000]=65536; - + /* This formula comes from vince vu/judge dredd's awe32p10 and corresponds to what the freebsd/linux AWE32 driver has. */ float millis; for (c=0;c<128;c++) @@ -2290,10 +2290,10 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) millis = 360*exp((c - 32) / (16.0/log(1.0/2.0))); env_attack_to_samples[c] = 44.1*millis; - /* This is an alternate formula with linear increments, but probably incorrect: + /* This is an alternate formula with linear increments, but probably incorrect: * millis = (256+4096*(0x7F-c)) */ } - + /* The LFOs use a triangular waveform starting at zero and going 1/-1/1/-1. * This table is stored in signed 16bits precision, with a period of 65536 samples */ for (c = 0; c < 65536; c++) @@ -2311,13 +2311,13 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) lfofreqtospeed[c] = (uint64_t)(out *65536.0/44100.0 * 65536.0 * 65536.0); out += 0.042; } - + for (c = 0; c < 65536; c++) { chortable[c] = sin(c*M_PI/32768.0); - } - - + } + + /* Filter coefficients tables. Note: Values are multiplied by *16777216 to left shift 24 bits. (i.e. 8.24 fixed point) */ int qidx; for (qidx = 0; qidx < 16; qidx++) @@ -2334,7 +2334,7 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) filt_coeffs[qidx][c][0] = (int32_t)(w0 * 16777216.0); filt_coeffs[qidx][c][1] = 16777216.0; filt_coeffs[qidx][c][2] = (int32_t)((1.0f / (0.7071f + q)) * 16777216.0); -#elif defined FILTER_MOOG +#elif defined FILTER_MOOG float w0 = sin(2.0*M_PI*out / 44100.0); float q_factor = 1.0f - w0; float p = w0 + 0.8f * w0 * q_factor; @@ -2349,7 +2349,7 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) float coef0 = sin(2.0*M_PI*out / 44100.0); float coef1 = 1.0 - coef0; float coef2 = q * (1.0 + 1.0 / coef1); - filt_coeffs[qidx][c][0] = (int32_t)(coef0 * 16777216.0); + filt_coeffs[qidx][c][0] = (int32_t)(coef0 * 16777216.0); filt_coeffs[qidx][c][1] = (int32_t)(coef1 * 16777216.0); filt_coeffs[qidx][c][2] = (int32_t)(coef2 * 16777216.0); #endif //FILTER_TYPE @@ -2377,9 +2377,9 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) emu8k->reverb_engine.allpass[7-c].feedback=0.5; emu8k->reverb_engine.allpass[7-c].bufsize=(4*c)*REV_BUFSIZE_STEP+55; } - - + + /* Cubic Resampling ( 4point cubic spline) */ double const resdouble = 1.0/(double)CUBIC_RESOLUTION; for (c = 0; c < CUBIC_RESOLUTION; c++) @@ -2391,7 +2391,7 @@ void emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) cubic_table[c*4+2] = (-1.5 * x * x * x + 2.0 * x * x + 0.5 * x) ; cubic_table[c*4+3] = ( 0.5 * x * x * x - 0.5 * x * x) ; } - /* Even when the documentation says that this has to be written by applications to initialize the card, + /* Even when the documentation says that this has to be written by applications to initialize the card, * several applications and drivers ( aweman on windows, linux oss driver..) read it to detect an AWE card. */ emu8k->hwcf1 = 0x59; emu8k->hwcf2 = 0x20; @@ -2404,4 +2404,3 @@ void emu8k_close(emu8k_t *emu8k) free(emu8k->rom); free(emu8k->ram); } - diff --git a/src/sound/snd_gus.c b/src/sound/snd_gus.c index a20d7fd50..9c18b964e 100644 --- a/src/sound/snd_gus.c +++ b/src/sound/snd_gus.c @@ -51,7 +51,7 @@ enum typedef struct gus_t { int reset; - + int global; uint32_t addr,dmaaddr; int voice; @@ -75,40 +75,40 @@ typedef struct gus_t uint8_t dmactrl; int32_t out_l, out_r; - + int16_t buffer[2][SOUNDBUFLEN]; int pos; - - pc_timer_t samp_timer; + + pc_timer_t samp_timer; uint64_t samp_latch; - + uint8_t *ram; uint32_t gus_end_ram; - + int irqnext; - + pc_timer_t timer_1, timer_2; - + int irq, dma, irq_midi; uint16_t base; int latch_enable; - + uint8_t sb_2xa, sb_2xc, sb_2xe; uint8_t sb_ctrl; int sb_nmi; - + uint8_t reg_ctrl; - + uint8_t ad_status, ad_data; uint8_t ad_timer_ctrl; - + uint8_t midi_ctrl, midi_status, midi_queue[64], midi_data; int midi_r, midi_w; int uart_in, uart_out, sysex; - + uint8_t gp1, gp2; uint16_t gp1_addr, gp2_addr; - + uint8_t usrr; uint8_t max_ctrl; @@ -143,7 +143,7 @@ void gus_update_int_status(gus_t *gus) if (gus->waveirqs[c]) { gus->irqstatus2=0x60|c; - if (gus->rampirqs[c]) + if (gus->rampirqs[c]) gus->irqstatus2 |= 0x80; gus->irqstatus|=0x20; irq_pending = 1; @@ -202,7 +202,7 @@ void gus_midi_update_int_status(gus_t *gus) } else gus->irqstatus &= ~GUS_INT_MIDI_TRANSMIT; - + if ((gus->midi_ctrl & MIDI_CTRL_RECEIVE) && (gus->midi_status & MIDI_INT_RECEIVE)) { gus->midi_status |= MIDI_INT_MASTER; @@ -223,19 +223,19 @@ void writegus(uint16_t addr, uint8_t val, void *p) #if defined(DEV_BRANCH) && defined(USE_GUSMAX) uint16_t csioport; #endif - + if ((addr == 0x388) || (addr == 0x389)) port = addr; else port = addr & 0xf0f; - + switch (port) { case 0x300: /*MIDI control*/ old = gus->midi_ctrl; gus->midi_ctrl = val; gus->uart_out = 1; - + if ((val & 3) == 3) { /*Master reset*/ gus->uart_in = 0; gus->midi_status = 0; @@ -245,7 +245,7 @@ void writegus(uint16_t addr, uint8_t val, void *p) gus->midi_status |= MIDI_INT_TRANSMIT; } else if (gus->midi_ctrl & MIDI_CTRL_RECEIVE) { gus->uart_in = 1; - } + } gus_midi_update_int_status(gus); break; case 0x301: /*MIDI data*/ @@ -255,7 +255,7 @@ void writegus(uint16_t addr, uint8_t val, void *p) } if (gus->latch_enable & 0x20) { gus->midi_status |= MIDI_INT_RECEIVE; - } else + } else gus->midi_status |= MIDI_INT_TRANSMIT; break; case 0x302: /*Voice select*/ @@ -323,9 +323,9 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xF807F00)|((val<<7)<<8); case 0: /*Voice control*/ gus->ctrl[gus->voice] = val & 0x7f; - old = gus->waveirqs[gus->voice]; - gus->waveirqs[gus->voice] = ((val & 0xa0) == 0xa0) ? 1 : 0; - if (gus->waveirqs[gus->voice] != old) + old = gus->waveirqs[gus->voice]; + gus->waveirqs[gus->voice] = ((val & 0xa0) == 0xa0) ? 1 : 0; + if (gus->waveirqs[gus->voice] != old) gus_update_int_status(gus); break; case 1: /*Frequency control*/ @@ -376,7 +376,7 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); case 0xD: /*Ramp control*/ old = gus->rampirqs[gus->voice]; gus->rctrl[gus->voice] = val & 0x7F; - gus->rampirqs[gus->voice] = ((val & 0xa0) == 0xa0) ? 1 : 0; + gus->rampirqs[gus->voice] = ((val & 0xa0) == 0xa0) ? 1 : 0; if (gus->rampirqs[gus->voice] != old) gus_update_int_status(gus); break; @@ -498,7 +498,7 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); gus->t2 = gus->t2l = val; gus->t2on = 1; break; - + case 0x4c: /*Reset*/ gus->reset = val; break; @@ -509,10 +509,10 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); gus->ram[gus->addr]=val; gus->addr&=0xFFFFF; break; - case 0x208: case 0x388: - gus->adcommand = val; + case 0x208: case 0x388: + gus->adcommand = val; break; - + case 0x389: if ((gus->tctrl & GUS_TIMER_CTRL_AUTO) || gus->adcommand != 4) { @@ -535,7 +535,7 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); else { gus->ad_timer_ctrl = val; - + if (val & 0x01) gus->t1on = 1; else @@ -548,18 +548,18 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); } } break; - + case 0x200: gus->latch_enable = val; break; - + case 0x20b: switch (gus->reg_ctrl & 0x07) { case 0: if (gus->latch_enable & 0x40) { gus->irq = gus_gf1_irqs[val & 7]; - + if (val & 0x40) { if (gus->irq == -1) @@ -569,16 +569,16 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); } else gus->irq_midi = gus_midi_irqs[(val >> 3) & 7]; -#if defined(DEV_BRANCH) && defined(USE_GUSMAX) +#if defined(DEV_BRANCH) && defined(USE_GUSMAX) ad1848_setirq(&gus->ad1848, gus->irq); #endif - - gus->sb_nmi = val & 0x80; + + gus->sb_nmi = val & 0x80; } else { gus->dma = gus_dmas[val & 7]; #if defined(DEV_BRANCH) && defined(USE_GUSMAX) ad1848_setdma(&gus->ad1848, gus->dma); -#endif +#endif } break; case 1: @@ -597,10 +597,10 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); gus->usrr = 0; break; case 6: - break; - } + break; + } break; - + case 0x206: gus->ad_status |= 0x08; if (gus->sb_ctrl & 0x20) @@ -661,12 +661,12 @@ uint8_t readgus(uint16_t addr, void *p) gus_t *gus = (gus_t *)p; uint8_t val = 0xff; uint16_t port; - + if ((addr == 0x388) || (addr == 0x389)) port = addr; else port = addr & 0xf0f; - + switch (port) { case 0x300: /*MIDI status*/ @@ -689,10 +689,10 @@ uint8_t readgus(uint16_t addr, void *p) gus_midi_update_int_status(gus); } break; - + case 0x200: return 0; - + case 0x206: /*IRQ status*/ val = gus->irqstatus & ~0x10; if (gus->ad_status & 0x19) @@ -705,13 +705,13 @@ uint8_t readgus(uint16_t addr, void *p) else val = 0x00; break; - - case 0x302: + + case 0x302: return gus->voice; - - case 0x303: + + case 0x303: return gus->global; - + case 0x304: /*Global low*/ switch (gus->global) { @@ -733,7 +733,7 @@ uint8_t readgus(uint16_t addr, void *p) gus->waveirqs[gus->irqstatus2&0x1F]=0; gus_update_int_status(gus); return val; - + case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0a: case 0x0b: @@ -789,7 +789,7 @@ uint8_t readgus(uint16_t addr, void *p) case 0x0c: case 0x0d: case 0x0e: case 0x0f: val = 0xff; break; - } + } break; case 0x306: case 0x706: if (gus->max_ctrl) @@ -824,7 +824,7 @@ uint8_t readgus(uint16_t addr, void *p) case 4: val = gus->gp2_addr; break; - } + } break; case 0x20c: @@ -834,7 +834,7 @@ uint8_t readgus(uint16_t addr, void *p) break; case 0x20e: return gus->sb_2xe; - + case 0x208: case 0x388: if (gus->tctrl & GUS_TIMER_CTRL_AUTO) val = gus->sb_2xa; @@ -846,14 +846,14 @@ uint8_t readgus(uint16_t addr, void *p) } break; - case 0x209: + case 0x209: gus->ad_status &= ~0x01; nmi = 0; /*FALLTHROUGH*/ case 0x389: val = gus->ad_data; break; - + case 0x20A: val = gus->adcommand; break; @@ -865,13 +865,13 @@ uint8_t readgus(uint16_t addr, void *p) void gus_poll_timer_1(void *p) { gus_t *gus = (gus_t *)p; - + timer_advance_u64(&gus->timer_1, (uint64_t)(TIMER_USEC * 80)); if (gus->t1on) { gus->t1++; if (gus->t1 > 0xFF) - { + { gus->t1=gus->t1l; gus->ad_status |= 0x40; if (gus->tctrl&4) @@ -894,13 +894,13 @@ void gus_poll_timer_1(void *p) void gus_poll_timer_2(void *p) { gus_t *gus = (gus_t *)p; - + timer_advance_u64(&gus->timer_2, (uint64_t)(TIMER_USEC * 320)); if (gus->t2on) { gus->t2++; if (gus->t2 > 0xFF) - { + { gus->t2=gus->t2l; gus->ad_status |= 0x20; if (gus->tctrl&8) @@ -945,11 +945,11 @@ void gus_poll_wave(void *p) int16_t v; int32_t vl; int update_irqs = 0; - + gus_update(gus); - + timer_advance_u64(&gus->samp_timer, gus->samp_latch); - + gus->out_l = gus->out_r = 0; if ((gus->reset & 3) != 3) @@ -1005,8 +1005,8 @@ void gus_poll_wave(void *p) { gus->ctrl[d] |= 1; gus->cur[d] = (gus->ctrl[d] & 0x40) ? gus->end[d] : gus->start[d]; - } - + } + if ((gus->ctrl[d] & 0x20) && !gus->waveirqs[d]) { gus->waveirqs[d] = 1; @@ -1031,9 +1031,9 @@ void gus_poll_wave(void *p) { gus->ctrl[d] |= 1; gus->cur[d] = (gus->ctrl[d] & 0x40) ? gus->end[d] : gus->start[d]; - } + } - if ((gus->ctrl[d] & 0x20) && !gus->waveirqs[d]) + if ((gus->ctrl[d] & 0x20) && !gus->waveirqs[d]) { gus->waveirqs[d] = 1; update_irqs = 1; @@ -1049,12 +1049,12 @@ void gus_poll_wave(void *p) if (gus->rcur[d] <= gus->rstart[d]) { int diff = gus->rstart[d] - gus->rcur[d]; - if (!(gus->rctrl[d] & 8)) + if (!(gus->rctrl[d] & 8)) { gus->rctrl[d] |= 1; gus->rcur[d] = (gus->rctrl[d] & 0x40) ? gus->rstart[d] : gus->rend[d]; - } - else + } + else { if (gus->rctrl[d] & 0x10) gus->rctrl[d] ^= 0x40; gus->rcur[d] = (gus->rctrl[d] & 0x40) ? (gus->rend[d] - diff) : (gus->rstart[d] + diff); @@ -1073,12 +1073,12 @@ void gus_poll_wave(void *p) if (gus->rcur[d] >= gus->rend[d]) { int diff = gus->rcur[d] - gus->rend[d]; - if (!(gus->rctrl[d] & 8)) + if (!(gus->rctrl[d] & 8)) { gus->rctrl[d] |= 1; gus->rcur[d] = (gus->rctrl[d] & 0x40) ? gus->rstart[d] : gus->rend[d]; - } - else + } + else { if (gus->rctrl[d] & 0x10) gus->rctrl[d] ^= 0x40; gus->rcur[d] = (gus->rctrl[d] & 0x40) ? (gus->rend[d] - diff) : (gus->rstart[d] + diff); @@ -1103,25 +1103,25 @@ static void gus_get_buffer(int32_t *buffer, int len, void *p) gus_t *gus = (gus_t *)p; int c; -#if defined(DEV_BRANCH) && defined(USE_GUSMAX) +#if defined(DEV_BRANCH) && defined(USE_GUSMAX) if (gus->max_ctrl) ad1848_update(&gus->ad1848); -#endif +#endif gus_update(gus); - + for (c = 0; c < len * 2; c++) { -#if defined(DEV_BRANCH) && defined(USE_GUSMAX) +#if defined(DEV_BRANCH) && defined(USE_GUSMAX) if (gus->max_ctrl) buffer[c] += (int32_t)(gus->ad1848.buffer[c] / 2); -#endif +#endif buffer[c] += (int32_t)gus->buffer[c & 1][c >> 1]; } -#if defined(DEV_BRANCH) && defined(USE_GUSMAX) +#if defined(DEV_BRANCH) && defined(USE_GUSMAX) if (gus->max_ctrl) gus->ad1848.pos = 0; -#endif +#endif gus->pos = 0; } @@ -1129,10 +1129,10 @@ static void gus_input_msg(void *p, uint8_t *msg, uint32_t len) { gus_t *gus = (gus_t *)p; uint8_t i; - - if (gus->sysex) + + if (gus->sysex) return; - + if (gus->uart_in) { gus->midi_status |= MIDI_INT_RECEIVE; @@ -1140,16 +1140,16 @@ static void gus_input_msg(void *p, uint8_t *msg, uint32_t len) gus->midi_queue[gus->midi_w++] = msg[i]; gus->midi_w &= 63; } - + gus_midi_update_int_status(gus); } } -static int gus_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) +static int gus_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) { gus_t *gus = (gus_t *)p; uint32_t i; - + if (abort) { gus->sysex = 0; return 0; @@ -1176,7 +1176,7 @@ void *gus_init(const device_t *info) gus->gus_end_ram = 1 << (18 + gus_ram); gus->ram = (uint8_t *)malloc(gus->gus_end_ram); memset(gus->ram, 0x00, (gus->gus_end_ram)); - + for (c=0;c<32;c++) { gus->ctrl[c]=1; @@ -1194,11 +1194,11 @@ void *gus_init(const device_t *info) gus->samp_latch = (uint64_t)(TIMER_USEC * (1000000.0 / 44100.0)); gus->t1l = gus->t2l = 0xff; - + gus->uart_out = 1; - + gus->base = device_get_config_hex16("base"); - + io_sethandler(gus->base, 0x0010, readgus, NULL, NULL, writegus, NULL, NULL, gus); io_sethandler(0x0100+gus->base, 0x0010, readgus, NULL, NULL, writegus, NULL, NULL, gus); io_sethandler(0x0506+gus->base, 0x0001, readgus, NULL, NULL, writegus, NULL, NULL, gus); @@ -1217,7 +1217,7 @@ void *gus_init(const device_t *info) timer_add(&gus->timer_2, gus_poll_timer_2, gus, 1); sound_add_handler(gus_get_buffer, gus); - + if (device_get_config_int("receive_input")) midi_in_handler(1, gus_input_msg, gus_input_sysex, gus); @@ -1227,7 +1227,7 @@ void *gus_init(const device_t *info) void gus_close(void *p) { gus_t *gus = (gus_t *)p; - + free(gus->ram); free(gus); } @@ -1320,7 +1320,7 @@ const device_t gus_device = 0, gus_init, gus_close, NULL, { NULL }, - gus_speed_changed, + gus_speed_changed, NULL, gus_config }; diff --git a/src/sound/snd_lpt_dac.c b/src/sound/snd_lpt_dac.c index 5781a9880..a743ff7e2 100644 --- a/src/sound/snd_lpt_dac.c +++ b/src/sound/snd_lpt_dac.c @@ -16,10 +16,10 @@ typedef struct lpt_dac_t void *lpt; uint8_t dac_val_l, dac_val_r; - + int is_stereo; int channel; - + int16_t buffer[2][SOUNDBUFLEN]; int pos; } lpt_dac_t; @@ -45,7 +45,7 @@ static void dac_write_data(uint8_t val, void *p) else lpt_dac->dac_val_l = val; } - else + else lpt_dac->dac_val_l = lpt_dac->dac_val_r = val; dac_update(lpt_dac); } @@ -68,9 +68,9 @@ static void dac_get_buffer(int32_t *buffer, int len, void *p) { lpt_dac_t *lpt_dac = (lpt_dac_t *)p; int c; - + dac_update(lpt_dac); - + for (c = 0; c < len; c++) { buffer[c*2] += dac_iir(0, lpt_dac->buffer[0][c]); @@ -87,21 +87,21 @@ static void *dac_init(void *lpt) lpt_dac->lpt = lpt; sound_add_handler(dac_get_buffer, lpt_dac); - + return lpt_dac; } static void *dac_stereo_init(void *lpt) { lpt_dac_t *lpt_dac = dac_init(lpt); - + lpt_dac->is_stereo = 1; - + return lpt_dac; } static void dac_close(void *p) { lpt_dac_t *lpt_dac = (lpt_dac_t *)p; - + free(lpt_dac); } diff --git a/src/sound/snd_lpt_dss.c b/src/sound/snd_lpt_dss.c index 3c735298c..e534c76d2 100644 --- a/src/sound/snd_lpt_dss.c +++ b/src/sound/snd_lpt_dss.c @@ -17,12 +17,12 @@ typedef struct dss_t uint8_t fifo[16]; int read_idx, write_idx; - + uint8_t dac_val, status; - + pc_timer_t timer; - + int16_t buffer[SOUNDBUFLEN]; int pos; } dss_t; @@ -78,14 +78,14 @@ static void dss_get_buffer(int32_t *buffer, int len, void *p) int c; int16_t val; float fval; - + dss_update(dss); - + for (c = 0; c < len*2; c += 2) { fval = dss_iir((float)dss->buffer[c >> 1]); val = (float) fval; - + buffer[c] += val; buffer[c+1] += val; } @@ -124,7 +124,7 @@ static void *dss_init(void *lpt) static void dss_close(void *p) { dss_t *dss = (dss_t *)p; - + free(dss); } diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index 7183195d6..0922ab21c 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -108,7 +108,7 @@ MPU401_ReCalcClock(mpu_t *mpu) freq = (int32_t)((float)(mpu->clock.freq) * mpu->clock.freq_mod); if ((freq > (mpu->clock.timebase * mintempo)) && (freq < (mpu->clock.timebase * maxtempo))) mpu->clock.freq = freq; - } + } } @@ -167,9 +167,9 @@ MPU401_QueueByteEx(mpu_t *mpu, uint8_t data, int irq) if (mpu->queue_used < MPU401_QUEUE) { int pos = mpu->queue_used+mpu->queue_pos; - if (mpu->queue_pos >= MPU401_QUEUE) + if (mpu->queue_pos >= MPU401_QUEUE) mpu->queue_pos -= MPU401_QUEUE; - if (pos>=MPU401_QUEUE) + if (pos>=MPU401_QUEUE) pos-=MPU401_QUEUE; mpu->queue_used++; @@ -179,7 +179,7 @@ MPU401_QueueByteEx(mpu_t *mpu, uint8_t data, int irq) static void -MPU401_QueueByte(mpu_t *mpu, uint8_t data) +MPU401_QueueByte(mpu_t *mpu, uint8_t data) { MPU401_QueueByteEx(mpu, data, 1); } @@ -244,7 +244,7 @@ MPU401_RecQueueBuffer(mpu_t *mpu, uint8_t *buf, uint32_t len, int block) static void -MPU401_ClrQueue(mpu_t *mpu) +MPU401_ClrQueue(mpu_t *mpu) { mpu->queue_used = 0; mpu->queue_pos = 0; @@ -261,7 +261,7 @@ MPU401_ClrQueue(mpu_t *mpu) static void -MPU401_Reset(mpu_t *mpu) +MPU401_Reset(mpu_t *mpu) { uint8_t i; @@ -359,7 +359,7 @@ MPU401_Reset(mpu_t *mpu) static void -MPU401_ResetDone(void *priv) +MPU401_ResetDone(void *priv) { mpu_t *mpu = (mpu_t *)priv; @@ -368,7 +368,7 @@ MPU401_ResetDone(void *priv) timer_disable(&mpu->mpu401_reset_callback); mpu->state.reset = 0; - + if (mpu->state.cmd_pending) { MPU401_WriteCommand(mpu, mpu->state.cmd_pending - 1); mpu->state.cmd_pending = 0; @@ -378,7 +378,7 @@ MPU401_ResetDone(void *priv) static void MPU401_WriteCommand(mpu_t *mpu, uint8_t val) -{ +{ uint8_t i, j, was_uart, recmsg[3]; if (mpu->state.reset) @@ -472,7 +472,7 @@ MPU401_WriteCommand(mpu_t *mpu, uint8_t val) uint8_t rec_cnt = mpu->clock.rec_counter; if (((val == 0x20) || (val == 0x26)) && (mpu->state.rec == M_RECON)) MPU401_RecQueueBuffer(mpu, &rec_cnt, 1, 0); - + if (send_prchg) { for (i = 0; i < 16; i++) { if (mpu->filter.prchg_mask & (1 << i)) { @@ -590,7 +590,7 @@ MPU401_WriteCommand(mpu_t *mpu, uint8_t val) if (val & 1) mpu->filter.sysex_thru = 0; break; - case 0x98: case 0x99: case 0x9a: case 0x9b: /* Reference tables on/off */ + case 0x98: case 0x99: case 0x9a: case 0x9b: /* Reference tables on/off */ case 0x9c: case 0x9d: case 0x9e: case 0x9f: mpu->chanref[(val - 0x98) / 2].on = !!(val & 1); break; @@ -653,7 +653,7 @@ MPU401_WriteCommand(mpu_t *mpu, uint8_t val) mpu->state.wsd_start = 1; break; /* Commands with data byte */ - case 0xe0: case 0xe1: case 0xe2: case 0xe4: case 0xe6: + case 0xe0: case 0xe1: case 0xe2: case 0xe4: case 0xe6: case 0xe7: case 0xec: case 0xed: case 0xee: case 0xef: mpu->state.command_byte = val; break; @@ -676,7 +676,7 @@ MPU401_WriteCommand(mpu_t *mpu, uint8_t val) static void -MPU401_WriteData(mpu_t *mpu, uint8_t val) +MPU401_WriteData(mpu_t *mpu, uint8_t val) { static int length, cnt; uint8_t i; @@ -697,7 +697,7 @@ MPU401_WriteData(mpu_t *mpu, uint8_t val) return; } #endif - + switch (mpu->state.command_byte) { /* 0xe# command data */ case 0x00: break; @@ -728,7 +728,7 @@ MPU401_WriteData(mpu_t *mpu, uint8_t val) case 0xe6: /* Set metronome ticks per measure */ mpu->state.command_byte = 0; mpu->clock.metromeas = val; - return; + return; case 0xe7: /* Set internal clock to host interval */ mpu->state.command_byte = 0; if (!val) @@ -924,7 +924,7 @@ MPU401_WriteData(mpu_t *mpu, uint8_t val) mpu->clock.measure_counter = 0; } else { /* mpu401_log("MPU-401:Illegal message"); */ - mpu->playbuf[mpu->state.track].type = T_OVERFLOW; + mpu->playbuf[mpu->state.track].type = T_OVERFLOW; } mpu->state.data_onoff = -1; MPU401_EOIHandler(mpu); @@ -949,13 +949,13 @@ MPU401_WriteData(mpu_t *mpu, uint8_t val) } break; } - + return; } static void -MPU401_IntelligentOut(mpu_t *mpu, uint8_t track) +MPU401_IntelligentOut(mpu_t *mpu, uint8_t track) { uint8_t chan, chrefnum, key, msg; int send, retrigger; @@ -1010,7 +1010,7 @@ MPU401_IntelligentOut(mpu_t *mpu, uint8_t track) midi_raw_out_byte(mpu->playbuf[track].value[i]); } break; - + default: break; } @@ -1018,7 +1018,7 @@ MPU401_IntelligentOut(mpu_t *mpu, uint8_t track) static void -UpdateTrack(mpu_t *mpu, uint8_t track) +UpdateTrack(mpu_t *mpu, uint8_t track) { MPU401_IntelligentOut(mpu, track); @@ -1035,7 +1035,7 @@ UpdateTrack(mpu_t *mpu, uint8_t track) #if 0 static void -UpdateConductor(mpu_t *mpu) +UpdateConductor(mpu_t *mpu) { if (mpu->condbuf.value[0] == 0xfc) { mpu->condbuf.value[0] = 0; @@ -1061,7 +1061,7 @@ MPU401_EOIHandler(void *priv) uint8_t i; mpu401_log("MPU-401 end of input callback\n"); - + timer_disable(&mpu->mpu401_eoi_callback); mpu->state.eoi_scheduled = 0; if (mpu->state.send_now) { @@ -1072,7 +1072,7 @@ MPU401_EOIHandler(void *priv) } else UpdateTrack(mpu, mpu->state.track); } - if (mpu->state.rec_copy || !mpu->state.sysex_in_finished) + if (mpu->state.rec_copy || !mpu->state.sysex_in_finished) return; if (mpu->ext_irq_update) @@ -1097,7 +1097,7 @@ MPU401_EOIHandler(void *priv) static void -MPU401_EOIHandlerDispatch(void *priv) +MPU401_EOIHandlerDispatch(void *priv) { mpu_t *mpu = (mpu_t *)priv; @@ -1105,7 +1105,7 @@ MPU401_EOIHandlerDispatch(void *priv) if (mpu->state.send_now) { mpu->state.eoi_scheduled = 1; timer_advance_u64(&mpu->mpu401_eoi_callback, 60LL * TIMER_USEC); /* Possibly a bit longer */ - } else if (!mpu->state.eoi_scheduled) + } else if (!mpu->state.eoi_scheduled) MPU401_EOIHandler(mpu); } @@ -1144,7 +1144,7 @@ uint8_t MPU401_ReadData(mpu_t *mpu) { uint8_t ret; - + ret = MSG_MPU_ACK; if (mpu->queue_used) { @@ -1217,7 +1217,7 @@ static void mpu401_write(uint16_t addr, uint8_t val, void *priv) { mpu_t *mpu = (mpu_t *)priv; - + /* mpu401_log("MPU401 Write Port %04X, val %x\n", addr, val); */ switch (addr & 1) { case 0: /*Data*/ @@ -1239,7 +1239,7 @@ mpu401_read(uint16_t addr, void *priv) mpu_t *mpu = (mpu_t *)priv; uint8_t ret = 0; - switch (addr & 1) { + switch (addr & 1) { case 0: /* Read Data */ ret = MPU401_ReadData(mpu); mpu401_log("Read Data (0x330) %X\n", ret); @@ -1262,7 +1262,7 @@ mpu401_read(uint16_t addr, void *priv) static void -MPU401_Event(void *priv) +MPU401_Event(void *priv) { mpu_t *mpu = (mpu_t *)priv; uint8_t i; @@ -1347,8 +1347,8 @@ next_event: } -static void -MPU401_NotesOff(mpu_t *mpu, int i) +static void +MPU401_NotesOff(mpu_t *mpu, int i) { int j; uint8_t key; @@ -1356,7 +1356,7 @@ MPU401_NotesOff(mpu_t *mpu, int i) if (mpu->filter.allnotesoff_out && !(mpu->inputref[i].on && (mpu->inputref[i].key[0] | mpu->inputref[i].key[1] | mpu->inputref[i].key[2] | mpu->inputref[i].key[3]))) { - for (j=0;j<4;j++) + for (j=0;j<4;j++) mpu->chanref[mpu->ch_toref[i]].key[j]=0; midi_raw_out_byte(0xb0 | i); midi_raw_out_byte(123); @@ -1403,13 +1403,13 @@ MPU401_InputSysex(void *p, uint8_t *buffer, uint32_t len, int abort) return 0; } if (mpu->state.sysex_in_finished) { - if (mpu->rec_queue_used>=MPU401_INPUT_QUEUE) + if (mpu->rec_queue_used>=MPU401_INPUT_QUEUE) return len; MPU401_RecQueueBuffer(mpu, &val_ff, 1, 1); mpu->state.sysex_in_finished=0; mpu->clock.rec_counter=0; } - if (mpu->rec_queue_used>=MPU401_INPUT_QUEUE) + if (mpu->rec_queue_used>=MPU401_INPUT_QUEUE) return len; int available = MPU401_INPUT_QUEUE - mpu->rec_queue_used; @@ -1418,7 +1418,7 @@ MPU401_InputSysex(void *p, uint8_t *buffer, uint32_t len, int abort) return 0; } else { MPU401_RecQueueBuffer(mpu,buffer, available, 1); - if (mpu->state.sysex_in_finished) + if (mpu->state.sysex_in_finished) return 0; return (len - available); } @@ -1468,18 +1468,18 @@ MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len) key = msg[1] & 0x7f; if (msg[0] < 0xf0) { /* If non-system msg. */ - if (!(mpu->state.midi_mask & (1 << chan)) && mpu->filter.all_thru) + if (!(mpu->state.midi_mask & (1 << chan)) && mpu->filter.all_thru) send_thru = 1; - else if (mpu->filter.midi_thru) + else if (mpu->filter.midi_thru) send_thru = 1; switch (msg[0] & 0xf0) { case 0x80: /* Note off. */ if (send_thru) { if (mpu->chanref[chrefnum].on && (mpu->chanref[chrefnum].M_GETKEY)) send_thru = 0; - if (!mpu->filter.midi_thru) + if (!mpu->filter.midi_thru) break; - if (!(mpu->inputref[chan].M_GETKEY)) + if (!(mpu->inputref[chan].M_GETKEY)) send_thru = 0; mpu->inputref[chan].M_DELKEY; } @@ -1488,9 +1488,9 @@ MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len) if (send_thru) { if (mpu->chanref[chrefnum].on && (mpu->chanref[chrefnum].M_GETKEY)) retrigger_thru = 1; - if (!mpu->filter.midi_thru) + if (!mpu->filter.midi_thru) break; - if (mpu->inputref[chan].M_GETKEY) + if (mpu->inputref[chan].M_GETKEY) retrigger_thru = 1; mpu->inputref[chan].M_SETKEY; } @@ -1518,14 +1518,14 @@ MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len) if ((msg[0] >= 0xf0) || (mpu->state.midi_mask & (1 << chan))) { switch (msg[0] & 0xf0) { case 0xa0: /* Aftertouch. */ - if (!mpu->filter.bender_in) + if (!mpu->filter.bender_in) send = 0; break; case 0xb0: /* Control change. */ if (!mpu->filter.bender_in && (msg[1] < 64)) send = 0; - if (msg[1] >= 120) { - if (mpu->filter.modemsgs_in) + if (msg[1] >= 120) { + if (mpu->filter.modemsgs_in) send = 1; } break; @@ -1537,7 +1537,7 @@ MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len) break; case 0xd0: /* Ch pressure. */ case 0xe0: /* Pitch wheel. */ - if (!mpu->filter.bender_in) + if (!mpu->filter.bender_in) send = 0; break; case 0xf0: /* System message. */ @@ -1547,7 +1547,7 @@ MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len) send = 0; /* Don't pass to host in this mode? */ tick = mpu->clock.timebase / 24; if (mpu->clock.ticks_in != tick) { - if (!mpu->clock.ticks_in || (mpu->clock.ticks_in > (tick * 2))) + if (!mpu->clock.ticks_in || (mpu->clock.ticks_in > (tick * 2))) mpu->clock.freq_mod *= 2.0; else { if (ABS(mpu->clock.ticks_in-tick) == 1) @@ -1569,10 +1569,10 @@ MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len) } else { /* Common or system. */ send = 0; if ((msg[0] == 0xf2) || (msg[0] == 0xf3) || (msg[0] == 0xf6)) { - if (mpu->filter.commonmsgs_in) + if (mpu->filter.commonmsgs_in) send = 1; - if (mpu->filter.commonmsgs_thru) - for (i = 0; i < len; i++) + if (mpu->filter.commonmsgs_thru) + for (i = 0; i < len; i++) midi_raw_out_byte(msg[i]); } } @@ -1618,7 +1618,7 @@ MPU401_InputMsg(void *p, uint8_t *msg, uint32_t len) midi_raw_out_byte(msg[1]); midi_raw_out_byte(msg[2]); } - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) midi_raw_out_byte(msg[i]); } if (send) { @@ -1797,7 +1797,7 @@ mpu401_standalone_init(const device_t *info) } mpu401_init(mpu, base, irq, M_INTELLIGENT, device_get_config_int("receive_input")); - + return(mpu); } diff --git a/src/sound/snd_opl.c b/src/sound/snd_opl.c index 6cd31f608..6e6afe7b5 100644 --- a/src/sound/snd_opl.c +++ b/src/sound/snd_opl.c @@ -239,7 +239,7 @@ opl2_read(uint16_t port, void *priv) opl2_update(dev); opl_log("OPL2 port read = %04x\n", port); - + return(opl_read(dev, port)); } @@ -299,7 +299,7 @@ void opl3_write(uint16_t port, uint8_t val, void *priv) { opl_t *dev = (opl_t *)priv; - + opl3_update(dev); opl_write(dev, port, val); diff --git a/src/sound/snd_opl_nuked.c b/src/sound/snd_opl_nuked.c index 5bde0d2dd..2ac17c75e 100644 --- a/src/sound/snd_opl_nuked.c +++ b/src/sound/snd_opl_nuked.c @@ -1071,7 +1071,7 @@ channel_set_4op(nuked_t *dev, uint8_t data) uint16_t -nuked_write_addr(void *priv, uint16_t port, uint8_t val) +nuked_write_addr(void *priv, uint16_t port, uint8_t val) { nuked_t *dev = (nuked_t *)priv; uint16_t addr; diff --git a/src/sound/snd_pas16.c b/src/sound/snd_pas16.c index 65a0026fb..c99bd5248 100644 --- a/src/sound/snd_pas16.c +++ b/src/sound/snd_pas16.c @@ -26,70 +26,70 @@ PIT - sample rate/count LMC835N/LMC1982 - mixer YM3802 - MIDI Control System - + 9A01 - IO base base >> 2 - + All below + IO base B89 - interrupt status / clear bit 2 - sample rate bit 3 - PCM bit 4 - MIDI - + B88 - Audio mixer control register - + B8A - Audio filter control bit 5 - mute? - + B8B - interrupt mask / board ID bits 5-7 - board ID (read only on PAS16) F88 - PCM data (low) - + F89 - PCM data (high) - + F8A - PCM control? bit 4 - input/output select (1 = output) bit 5 - mono/stereo select bit 6 - PCM enable - + 1388-138b - PIT clocked at 1193180 Hz 1388 - sample rate 1389 - sample count - - 178b - + + 178b - 2789 - board revision - + 8389 - bit 2 - 8/16 bit - + BF88 - wait states - + EF8B - bit 3 - 16 bits okay ? - - F388 - + + F388 - bit 6 - joystick enable - + F389 - bits 0-2 - DMA - + F38A - bits 0-3 - IRQ F788 - bit 1 - SB emulation bit 0 - MPU401 emulation - + F789 - SB base addr bits 0-3 - addr bits 4-7 - + FB8A - SB IRQ/DMA bits 3-5 - IRQ bits 6-7 - DMA - + FF88 - board model 3 = PAS16 */ @@ -97,32 +97,32 @@ typedef struct pas16_t { uint16_t base; - + int irq, dma; - + uint8_t audiofilt; - + uint8_t audio_mixer; - + uint8_t compat, compat_base; - + uint8_t enhancedscsi; - + uint8_t io_conf_1, io_conf_2, io_conf_3, io_conf_4; - + uint8_t irq_stat, irq_ena; - + uint8_t pcm_ctrl; uint16_t pcm_dat; uint16_t pcm_dat_l, pcm_dat_r; - + uint8_t sb_irqdma; - + int stereo_lr; - + uint8_t sys_conf_1, sys_conf_2, sys_conf_3, sys_conf_4; - + struct { uint32_t l[3]; @@ -208,27 +208,27 @@ static uint8_t pas16_in(uint16_t port, void *p) case 0x388: case 0x389: case 0x38a: case 0x38b: temp = opl3_read((port - pas16->base) + 0x388, &pas16->opl); break; - + case 0xb88: temp = pas16->audio_mixer; break; - + case 0xb89: temp = pas16->irq_stat; break; - + case 0xb8a: temp = pas16->audiofilt; break; - + case 0xb8b: temp = (pas16->irq_ena & ~0xe0) | 0x20; break; - + case 0xf8a: temp = pas16->pcm_ctrl; break; - + case 0x1388: case 0x1389: case 0x138a: case 0x138b: temp = pas16_pit_in(port, pas16); break; @@ -236,11 +236,11 @@ static uint8_t pas16_in(uint16_t port, void *p) case 0x2789: /*Board revision*/ temp = 0; break; - + case 0x7f89: temp = pas16->enhancedscsi & ~1; break; - + case 0x8388: temp = pas16->sys_conf_1; break; @@ -253,7 +253,7 @@ static uint8_t pas16_in(uint16_t port, void *p) case 0x838c: temp = pas16->sys_conf_4; break; - + case 0xef8b: temp = 0x0c; break; @@ -277,7 +277,7 @@ static uint8_t pas16_in(uint16_t port, void *p) case 0xf789: temp = pas16->compat_base; break; - + case 0xfb8a: temp = pas16->sb_irqdma; break; @@ -302,7 +302,7 @@ static void pas16_out(uint16_t port, uint8_t val, void *p) case 0x388: case 0x389: case 0x38a: case 0x38b: opl3_write((port - pas16->base) + 0x388, val, &pas16->opl); break; - + case 0xb88: pas16->audio_mixer = val; break; @@ -327,13 +327,13 @@ static void pas16_out(uint16_t port, uint8_t val, void *p) case 0xf89: pas16_update(pas16); pas16->pcm_dat = (pas16->pcm_dat & 0x00ff) | (val << 8); - break; + break; case 0xf8a: if ((val & PAS16_PCM_ENA) && !(pas16->pcm_ctrl & PAS16_PCM_ENA)) /*Guess*/ pas16->stereo_lr = 0; pas16->pcm_ctrl = val; break; - + case 0x1388: case 0x1389: case 0x138a: case 0x138b: pas16_pit_out(port, val, pas16); break; @@ -384,14 +384,14 @@ static void pas16_out(uint16_t port, uint8_t val, void *p) if (pas16->compat & 0x02) sb_dsp_setaddr(&pas16->dsp, ((pas16->compat_base & 0xf) << 4) | 0x200); break; - + case 0xfb8a: pas16->sb_irqdma = val; sb_dsp_setirq(&pas16->dsp, pas16_sb_irqs[(val >> 3) & 7]); sb_dsp_setdma8(&pas16->dsp, pas16_sb_dmas[(val >> 6) & 3]); pas16_log("pas16_out : set SB IRQ %i DMA %i\n", pas16_sb_irqs[(val >> 3) & 7], pas16_sb_dmas[(val >> 6) & 3]); break; - + default: pas16_log("pas16_out : unknown %04X\n", port); } @@ -493,7 +493,7 @@ static void pas16_pit_out(uint16_t port, uint8_t val, void *p) case 3: pas16->pit.l[t] &= 0xFF00; pas16->pit.l[t] |= val; - pas16->pit.wm[t] = 0; + pas16->pit.wm[t] = 0; break; } if (!pas16->pit.l[t]) @@ -521,13 +521,13 @@ static uint8_t pas16_pit_in(uint16_t port, void *p) if (!t) { pas16->pit.rl[t] = timer_get_remaining_u64(&pas16->pit.timer[t]) / PITCONST; - if ((timer_get_remaining_u64(&pas16->pit.timer[t]) / PITCONST) > 65536) + if ((timer_get_remaining_u64(&pas16->pit.timer[t]) / PITCONST) > 65536) pas16->pit.rl[t] = 0xFFFF; } else { pas16->pit.rl[t] = pas16->pit.c[t]; - if (pas16->pit.c[t] > 65536) + if (pas16->pit.c[t] > 65536) pas16->pit.rl[t] = 0xFFFF; } } @@ -568,13 +568,13 @@ static uint8_t pas16_readdma(pas16_t *pas16) static void pas16_pcm_poll(void *p) { pas16_t *pas16 = (pas16_t *)p; - + pas16_update(pas16); if (pas16->pit.m[0] & 2) { - if (pas16->pit.l[0]) + if (pas16->pit.l[0]) timer_advance_u64(&pas16->pit.timer[0], pas16->pit.l[0] * PITCONST); - else + else timer_advance_u64(&pas16->pit.timer[0], 0x10000 * PITCONST); } else @@ -585,14 +585,14 @@ static void pas16_pcm_poll(void *p) pas16->irq_stat |= PAS16_INT_SAMP; if (pas16->irq_ena & PAS16_INT_SAMP) picint(1 << pas16->irq); - + /*Update sample rate counter*/ if (pas16->pit.enable[1]) - { + { if (pas16->pcm_ctrl & PAS16_PCM_ENA) { uint16_t temp; - + if (pas16->sys_conf_2 & PAS16_SC2_16BIT) { temp = pas16_readdma(pas16) << 8; @@ -600,7 +600,7 @@ static void pas16_pcm_poll(void *p) } else temp = (pas16_readdma(pas16) ^ 0x80) << 8; - + if (pas16->sys_conf_2 & PAS16_SC2_MSBINV) temp ^= 0x8000; if (pas16->pcm_ctrl & PAS16_PCM_MONO) @@ -611,7 +611,7 @@ static void pas16_pcm_poll(void *p) pas16->pcm_dat_r = temp; else pas16->pcm_dat_l = temp; - + pas16->stereo_lr = !pas16->stereo_lr; } } @@ -623,9 +623,9 @@ static void pas16_pcm_poll(void *p) { if (pas16->pit.m[1] & 2) { - if (pas16->pit.l[1]) + if (pas16->pit.l[1]) pas16->pit.c[1] += pas16->pit.l[1]; - else + else pas16->pit.c[1] += 0x10000; } else @@ -633,7 +633,7 @@ static void pas16_pcm_poll(void *p) pas16->pit.c[1] = -1; pas16->pit.enable[1] = 0; } - + pas16->irq_stat |= PAS16_INT_PCM; if (pas16->irq_ena & PAS16_INT_PCM) { @@ -666,7 +666,7 @@ static void pas16_out_base(uint16_t port, uint8_t val, void *p) io_removehandler((pas16->base - 0x388) + 0xf788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16); io_removehandler((pas16->base - 0x388) + 0xfb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16); io_removehandler((pas16->base - 0x388) + 0xff88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16); - + pas16->base = val << 2; pas16_log("pas16_write_base : PAS16 base now at %04X\n", pas16->base); @@ -741,18 +741,18 @@ static void *pas16_init(const device_t *info) sb_dsp_init(&pas16->dsp, SB2, SB_SUBTYPE_DEFAULT, pas16); io_sethandler(0x9a01, 0x0001, NULL, NULL, NULL, pas16_out_base, NULL, NULL, pas16); - + timer_add(&pas16->pit.timer[0], pas16_pcm_poll, pas16, 0); - + sound_add_handler(pas16_get_buffer, pas16); - + return pas16; } static void pas16_close(void *p) { pas16_t *pas16 = (pas16_t *)p; - + free(pas16); } diff --git a/src/sound/snd_ps1.c b/src/sound/snd_ps1.c index dbca48e79..b26e6c65e 100644 --- a/src/sound/snd_ps1.c +++ b/src/sound/snd_ps1.c @@ -119,7 +119,7 @@ ps1snd_write(uint16_t port, uint8_t val, void *priv) static void ps1snd_update(ps1snd_t *ps1snd) { - for (; ps1snd->pos < sound_pos_global; ps1snd->pos++) + for (; ps1snd->pos < sound_pos_global; ps1snd->pos++) ps1snd->buffer[ps1snd->pos] = (int8_t)(ps1snd->dac_val ^ 0x80) * 0x20; } diff --git a/src/sound/snd_pssj.c b/src/sound/snd_pssj.c index cd5f274fe..e7bdcf85c 100644 --- a/src/sound/snd_pssj.c +++ b/src/sound/snd_pssj.c @@ -22,11 +22,11 @@ typedef struct pssj_t uint8_t dac_val; uint16_t freq; int amplitude; - + int irq; pc_timer_t timer_count; int enable; - + int wave_pos; int pulse_width; @@ -43,7 +43,7 @@ static void pssj_update_irq(pssj_t *pssj) static void pssj_write(uint16_t port, uint8_t val, void *p) { pssj_t *pssj = (pssj_t *)p; - + switch (port & 3) { case 0: @@ -77,7 +77,7 @@ static void pssj_write(uint16_t port, uint8_t val, void *p) pssj->freq = (pssj->freq & 0x0ff) | ((val & 0xf) << 8); pssj->amplitude = val >> 4; break; - } + } } static uint8_t pssj_read(uint16_t port, void *p) { @@ -113,7 +113,7 @@ static uint8_t pssj_read(uint16_t port, void *p) static void pssj_update(pssj_t *pssj) { - for (; pssj->pos < sound_pos_global; pssj->pos++) + for (; pssj->pos < sound_pos_global; pssj->pos++) pssj->buffer[pssj->pos] = (((int8_t)(pssj->dac_val ^ 0x80) * 0x20) * pssj->amplitude) / 15; } @@ -121,7 +121,7 @@ static void pssj_callback(void *p) { pssj_t *pssj = (pssj_t *)p; int data; - + pssj_update(pssj); if (pssj->ctrl & 2) { @@ -146,7 +146,7 @@ static void pssj_callback(void *p) pssj->irq = 1; pssj_update_irq(pssj); } - } + } } else { @@ -237,7 +237,7 @@ void pssj_close(void *p) { pssj_t *pssj = (pssj_t *)p; - free(pssj); + free(pssj); } #if defined(DEV_BRANCH) && defined(USE_TANDY_ISA) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index fd0e0a929..56e34bbb9 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -45,11 +45,11 @@ /* 0 to 7 -> -14dB to 0dB i 2dB steps. 8 to 15 -> 0 to +14dB in 2dB steps. Note that for positive dB values, this is not amplitude, it is amplitude-1. */ static const double sb_bass_treble_4bits[]= { - 0.199526231, 0.25, 0.316227766, 0.398107170, 0.5, 0.63095734, 0.794328234, 1, + 0.199526231, 0.25, 0.316227766, 0.398107170, 0.5, 0.63095734, 0.794328234, 1, 0, 0.25892541, 0.584893192, 1, 1.511886431, 2.16227766, 3, 4.011872336 }; -/* Attenuation tables for the mixer. Max volume = 32767 in order to give 6dB of +/* Attenuation tables for the mixer. Max volume = 32767 in order to give 6dB of * headroom and avoid integer overflow */ static const double sb_att_2dbstep_5bits[]= { @@ -184,7 +184,7 @@ static void sb_get_buffer_sb2(int32_t *buffer, int len, void *p) { sb_t *sb = (sb_t *) p; - sb_ct1335_mixer_t *mixer = &sb->mixer_sb2; + sb_ct1335_mixer_t *mixer = &sb->mixer_sb2; int c; double out_mono = 0.0, out_l = 0.0, out_r = 0.0; @@ -881,7 +881,7 @@ sb_ct1745_mixer_read(uint16_t addr, void *p) ret = mixer->regs[mixer->index]; break; - /*SB Pro compatibility*/ + /*SB Pro compatibility*/ case 0x04: ret = ((mixer->regs[0x33] >> 4) & 0x0f) | (mixer->regs[0x32] & 0xf0); break; @@ -913,7 +913,7 @@ sb_ct1745_mixer_read(uint16_t addr, void *p) ret = ((mixer->regs[0x39] >> 4) & 0x0f) | (mixer->regs[0x38] & 0xf0); break; - case 0x48: + case 0x48: /* Undocumented. The Creative Windows Mixer calls this after calling 3C (input selector), even when writing. Also, the version I have (5.17), does not use the MIDI.L/R input selectors, it uses @@ -951,7 +951,7 @@ sb_ct1745_mixer_read(uint16_t addr, void *p) case 5: ret |= 0x20; break; case 6: ret |= 0x40; break; case 7: ret |= 0x80; break; - } + } break; case 0x82: @@ -1612,7 +1612,7 @@ sb_pro_compat_init(const device_t *info) sb_dsp_init(&sb->dsp, SBPRO2, SB_SUBTYPE_DEFAULT, sb); sb_ct1345_mixer_reset(sb); - + sb->mixer_enabled = 1; sound_add_handler(sb_get_buffer_sbpro, sb); diff --git a/src/sound/snd_sb_dsp.c b/src/sound/snd_sb_dsp.c index f2797431b..17f7ae979 100644 --- a/src/sound/snd_sb_dsp.c +++ b/src/sound/snd_sb_dsp.c @@ -573,7 +573,7 @@ sb_exec_command(sb_dsp_t *dsp) break; case 0x38: /* Write to SB MIDI Output (Raw) */ dsp->onebyte_midi = 1; - break; + break; case 0x40: /* Set time constant */ dsp->sb_timei = dsp->sb_timeo = dsp->sb_data[0]; dsp->sblatcho = dsp->sblatchi = TIMER_USEC * (256 - dsp->sb_data[0]); @@ -1045,7 +1045,7 @@ sb_read(uint16_t a, void *priv) } -void +void sb_dsp_input_msg(void *p, uint8_t *msg, uint32_t len) { sb_dsp_t *dsp = (sb_dsp_t *) p; @@ -1065,15 +1065,15 @@ sb_dsp_input_msg(void *p, uint8_t *msg, uint32_t len) for (i = 0; i < len; i++) sb_add_data(dsp, msg[i]); sb_irq(dsp, 1); - } else if (dsp->midi_in_poll) { - for (i = 0; i < len; i++) + } else if (dsp->midi_in_poll) { + for (i = 0; i < len; i++) sb_add_data(dsp, msg[i]); } } -int -sb_dsp_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) +int +sb_dsp_input_sysex(void *p, uint8_t *buffer, uint32_t len, int abort) { sb_dsp_t *dsp = (sb_dsp_t *) p; uint32_t i; diff --git a/src/sound/snd_sn76489.c b/src/sound/snd_sn76489.c index e4ba68742..a1cc66a40 100644 --- a/src/sound/snd_sn76489.c +++ b/src/sound/snd_sn76489.c @@ -28,7 +28,7 @@ void sn76489_update(sn76489_t *sn76489) { int c; int16_t result = 0; - + for (c = 1; c < 4; c++) { if (sn76489->latch[c] > 256) result += (int16_t) (volslog[sn76489->vol[c]] * sn76489->stat[c]); @@ -49,18 +49,18 @@ void sn76489_update(sn76489_t *sn76489) sn76489->count[0] += (sn76489->latch[0] * 4); if (!(sn76489->noise & 4)) { - if (sn76489->shift & 1) + if (sn76489->shift & 1) sn76489->shift |= 0x8000; sn76489->shift >>= 1; } else { - if ((sn76489->shift & 1) ^ ((sn76489->shift >> 1) & 1)) + if ((sn76489->shift & 1) ^ ((sn76489->shift >> 1) & 1)) sn76489->shift |= 0x8000; sn76489->shift >>= 1; } } - + sn76489->buffer[sn76489->pos] = result; } } @@ -68,11 +68,11 @@ void sn76489_update(sn76489_t *sn76489) void sn76489_get_buffer(int32_t *buffer, int len, void *p) { sn76489_t *sn76489 = (sn76489_t *)p; - + int c; - + sn76489_update(sn76489); - + if (!sn76489_mute) { for (c = 0; c < len * 2; c++) @@ -88,7 +88,7 @@ void sn76489_write(uint16_t addr, uint8_t data, void *p) int freq; sn76489_update(sn76489); - + if (data & 0x80) { sn76489->firstdat = data; @@ -242,7 +242,7 @@ void sn76489_device_close(void *p) { sn76489_t *sn76489 = (sn76489_t *)p; - free(sn76489); + free(sn76489); } #if defined(DEV_BRANCH) && defined(USE_TANDY_ISA) diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index 1aba2210a..c44471467 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -18,14 +18,14 @@ typedef struct ssi2001_t void *psid; int16_t buffer[SOUNDBUFLEN * 2]; int pos; - int gameport_enabled; + int gameport_enabled; } ssi2001_t; static void ssi2001_update(ssi2001_t *ssi2001) { if (ssi2001->pos >= sound_pos_global) return; - + sid_fillbuf(&ssi2001->buffer[ssi2001->pos], sound_pos_global - ssi2001->pos, ssi2001->psid); ssi2001->pos = sound_pos_global; } @@ -36,7 +36,7 @@ static void ssi2001_get_buffer(int32_t *buffer, int len, void *p) int c; ssi2001_update(ssi2001); - + for (c = 0; c < len * 2; c++) buffer[c] += ssi2001->buffer[c >> 1] / 2; @@ -46,17 +46,17 @@ static void ssi2001_get_buffer(int32_t *buffer, int len, void *p) static uint8_t ssi2001_read(uint16_t addr, void *p) { ssi2001_t *ssi2001 = (ssi2001_t *)p; - + ssi2001_update(ssi2001); - + return sid_read(addr, p); } static void ssi2001_write(uint16_t addr, uint8_t val, void *p) { ssi2001_t *ssi2001 = (ssi2001_t *)p; - - ssi2001_update(ssi2001); + + ssi2001_update(ssi2001); sid_write(addr, val, p); } @@ -68,7 +68,7 @@ void *ssi2001_init(const device_t *info) ssi2001->psid = sid_init(); sid_reset(ssi2001->psid); uint16_t addr = device_get_config_hex16("base"); - ssi2001->gameport_enabled = device_get_config_int("gameport"); + ssi2001->gameport_enabled = device_get_config_int("gameport"); io_sethandler(addr, 0x0020, ssi2001_read, NULL, NULL, ssi2001_write, NULL, NULL, ssi2001); if (ssi2001->gameport_enabled) gameport_remap(gameport_add(&gameport_201_device), 0x201); @@ -79,7 +79,7 @@ void *ssi2001_init(const device_t *info) void ssi2001_close(void *p) { ssi2001_t *ssi2001 = (ssi2001_t *)p; - + sid_close(ssi2001->psid); free(ssi2001); diff --git a/src/sound/snd_wss.c b/src/sound/snd_wss.c index d9739958c..b3e06cf94 100644 --- a/src/sound/snd_wss.c +++ b/src/sound/snd_wss.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include <86box/86box.h> #include <86box/io.h> #include <86box/timer.h> @@ -158,7 +158,7 @@ ncr_audio_mca_write(int port, uint8_t val, void *priv) if (wss->opl_enabled) io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &wss->opl); - + io_sethandler(addr, 0x0004, wss_read, NULL, NULL, wss_write, NULL, NULL, wss); io_sethandler(addr+4, 0x0004, ad1848_read, NULL, NULL, ad1848_write, NULL, NULL, &wss->ad1848); } diff --git a/src/sound/snd_ym7128.c b/src/sound/snd_ym7128.c index 42d21ba63..7b89fedff 100644 --- a/src/sound/snd_ym7128.c +++ b/src/sound/snd_ym7128.c @@ -14,7 +14,7 @@ void ym7128_init(ym7128_t *ym7128) { int c; double out = 65536.0; - + for (c = 0; c < 32; c++) tap_position[c] = c * (2400 / 31); @@ -35,7 +35,7 @@ void ym7128_write(ym7128_t *ym7128, uint8_t val) int new_a0 = val & 4; if (!ym7128->sci && new_sci) ym7128->dat = (ym7128->dat << 1) | new_dat; - + if (ym7128->a0 != new_a0) { if (!ym7128->a0) @@ -52,7 +52,7 @@ void ym7128_write(ym7128_t *ym7128, uint8_t val) case 0x0c: case 0x0d: case 0x0e: case 0x0f: ym7128->gr[ym7128->reg_sel & 7] = GET_ATTENUATION(ym7128->dat); break; - + case 0x10: ym7128->vm = GET_ATTENUATION(ym7128->dat); break; @@ -96,7 +96,7 @@ void ym7128_write(ym7128_t *ym7128, uint8_t val) void ym7128_apply(ym7128_t *ym7128, int16_t *buffer, int len) { int c, d; - + for (c = 0; c < len*2; c += 4) { /*YM7128 samples a mono stream at ~24 kHz, so downsample*/ @@ -110,27 +110,27 @@ void ym7128_apply(ym7128_t *ym7128, int16_t *buffer, int len) samp = (samp * ym7128->vm) >> 16; samp += filter_out; - + ym7128->delay_buffer[ym7128->delay_pos] = samp; - + for (d = 0; d < 8; d++) { samp_l += (GET_DELAY_SAMPLE(ym7128, ym7128->t[d+1]) * ym7128->gl[d]) >> 16; samp_r += (GET_DELAY_SAMPLE(ym7128, ym7128->t[d+1]) * ym7128->gr[d]) >> 16; } - + samp_l = (samp_l * ym7128->vl*2) >> 16; samp_r = (samp_r * ym7128->vr*2) >> 16; - + buffer[c] += ((int32_t)samp_l + (int32_t)ym7128->prev_l) / 2; buffer[c+1] += ((int32_t)samp_r + (int32_t)ym7128->prev_r) / 2; buffer[c+2] += samp_l; buffer[c+3] += samp_r; - + ym7128->delay_pos++; if (ym7128->delay_pos >= 2400) ym7128->delay_pos = 0; - + ym7128->filter_dat = filter_temp; ym7128->prev_l = samp_l; ym7128->prev_r = samp_r; diff --git a/src/sound/sound.c b/src/sound/sound.c index e12b38bcb..4beab94ba 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -347,12 +347,10 @@ sound_cd_thread(void *param) } } -#ifdef USE_OPENAL if (sound_is_float) givealbuffer_cd(cd_out_buffer); else givealbuffer_cd(cd_out_buffer_int16); -#endif } } @@ -465,12 +463,10 @@ sound_poll(void *priv) } } -#ifdef USE_OPENAL if (sound_is_float) givealbuffer(outbuffer_ex); else givealbuffer(outbuffer_ex_int16); -#endif if (cd_thread_enable) { cd_buf_update--; @@ -499,9 +495,8 @@ sound_reset(void) midi_device_init(); midi_in_device_init(); -#ifdef USE_OPENAL + inital(); -#endif timer_add(&sound_poll_timer, sound_poll, NULL, 1); diff --git a/src/sound/xaudio2.c b/src/sound/xaudio2.c new file mode 100644 index 000000000..c82c45403 --- /dev/null +++ b/src/sound/xaudio2.c @@ -0,0 +1,279 @@ +/* + * 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. + * + * Interface to the XAudio2 audio processing library. + * + * + * + * Authors: Cacodemon345 + * + * Copyright 2022 Cacodemon345. + */ +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) && !defined(USE_FAUDIO) +#define COBJMACROS +#include +#else +#include +#include +#endif + +#include <86box/86box.h> +#include <86box/sound.h> +#include <86box/midi.h> +#include <86box/plat_dynld.h> + +#if defined(_WIN32) && !defined(USE_FAUDIO) +static void *xaudio2_handle = NULL; +static HRESULT (WINAPI *pXAudio2Create)(IXAudio2** ppXAudio2, uint32_t Flags, XAUDIO2_PROCESSOR XAudio2Processor); +static dllimp_t xaudio2_imports[] = { + { "XAudio2Create", &pXAudio2Create }, + { NULL, NULL }, +}; +#define XAudio2Create pXAudio2Create +#endif + +static int midi_freq = 44100; +static int midi_buf_size = 4410; +static int initialized = 0; +static IXAudio2 *xaudio2 = NULL; +static IXAudio2MasteringVoice *mastervoice = NULL; +static IXAudio2SourceVoice *srcvoice = NULL; +static IXAudio2SourceVoice *srcvoicemidi = NULL; +static IXAudio2SourceVoice *srcvoicecd = NULL; + +#define FREQ 48000 +#define BUFLEN SOUNDBUFLEN + +static void WINAPI OnVoiceProcessingPassStart(IXAudio2VoiceCallback *callback, uint32_t bytesRequired) {} +static void WINAPI OnVoiceProcessingPassEnd(IXAudio2VoiceCallback *callback) {} +static void WINAPI OnStreamEnd(IXAudio2VoiceCallback *callback) {} +static void WINAPI OnBufferStart(IXAudio2VoiceCallback *callback, void *pBufferContext) {} +static void WINAPI OnLoopEnd(IXAudio2VoiceCallback *callback, void *pBufferContext) {} +static void WINAPI OnVoiceError(IXAudio2VoiceCallback *callback, void *pBufferContext, HRESULT error) {} + +static void WINAPI +OnBufferEnd(IXAudio2VoiceCallback *callback, void *pBufferContext) +{ + free(pBufferContext); +} + +#if defined(_WIN32) && !defined(USE_FAUDIO) +static IXAudio2VoiceCallbackVtbl callbacksVtbl = +#else +static FAudioVoiceCallback callbacks = +#endif +{ + .OnVoiceProcessingPassStart = OnVoiceProcessingPassStart, + .OnVoiceProcessingPassEnd = OnVoiceProcessingPassEnd, + .OnStreamEnd = OnStreamEnd, + .OnBufferStart = OnBufferStart, + .OnBufferEnd = OnBufferEnd, + .OnLoopEnd = OnLoopEnd, + .OnVoiceError = OnVoiceError +}; + +#if defined(_WIN32) && !defined(USE_FAUDIO) +static IXAudio2VoiceCallback callbacks = { &callbacksVtbl }; +#endif + +void +inital() +{ +#if defined(_WIN32) && !defined(USE_FAUDIO) + if (xaudio2_handle == NULL) { + xaudio2_handle = dynld_module("xaudio2_9.dll", xaudio2_imports); + } + + if (xaudio2_handle == NULL) { + xaudio2_handle = dynld_module("xaudio2_9redist.dll", xaudio2_imports); + } + + if (xaudio2_handle == NULL) { + return; + } +#endif + + if (XAudio2Create(&xaudio2, 0, XAUDIO2_DEFAULT_PROCESSOR)) + { + return; + } + + if (IXAudio2_CreateMasteringVoice(xaudio2, &mastervoice, 2, FREQ, 0, 0, NULL, 0)) + { + IXAudio2_Release(xaudio2); + xaudio2 = NULL; + return; + } + + WAVEFORMATEX fmt; + fmt.nChannels = 2; + + if (sound_is_float) + { + fmt.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; + fmt.wBitsPerSample = 32; + } + else + { + fmt.wFormatTag = WAVE_FORMAT_PCM; + fmt.wBitsPerSample = 16; + } + + fmt.nSamplesPerSec = FREQ; + fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; + fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; + fmt.cbSize = 0; + + if (IXAudio2_CreateSourceVoice(xaudio2, &srcvoice, &fmt, 0, 2.0f, &callbacks, NULL, NULL)) + { + IXAudio2MasteringVoice_DestroyVoice(mastervoice); + IXAudio2_Release(xaudio2); + xaudio2 = NULL; + mastervoice = NULL; + return; + } + + fmt.nSamplesPerSec = CD_FREQ; + fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; + fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; + + IXAudio2_CreateSourceVoice(xaudio2, &srcvoicecd, &fmt, 0, 2.0f, &callbacks, NULL, NULL); + + IXAudio2SourceVoice_SetVolume(srcvoice, 1, XAUDIO2_COMMIT_NOW); + IXAudio2SourceVoice_Start(srcvoice, 0, XAUDIO2_COMMIT_NOW); + IXAudio2SourceVoice_Start(srcvoicecd, 0, XAUDIO2_COMMIT_NOW); + + char *mdn = midi_device_get_internal_name(midi_device_current); + + if (strcmp(mdn, "none") && strcmp(mdn, SYSTEM_MIDI_INTERNAL_NAME)) + { + fmt.nSamplesPerSec = midi_freq; + fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; + fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; + IXAudio2_CreateSourceVoice(xaudio2, &srcvoicemidi, &fmt, 0, 2.0f, &callbacks, NULL, NULL); + IXAudio2SourceVoice_Start(srcvoicemidi, 0, XAUDIO2_COMMIT_NOW); + } + + initialized = 1; +} + +void +closeal() +{ + if (!initialized) return; + initialized = 0; + IXAudio2SourceVoice_Stop(srcvoice, 0, XAUDIO2_COMMIT_NOW); + IXAudio2SourceVoice_FlushSourceBuffers(srcvoice); + IXAudio2SourceVoice_Stop(srcvoicecd, 0, XAUDIO2_COMMIT_NOW); + IXAudio2SourceVoice_FlushSourceBuffers(srcvoicecd); + if (srcvoicemidi) + { + IXAudio2SourceVoice_Stop(srcvoicemidi, 0, XAUDIO2_COMMIT_NOW); + IXAudio2SourceVoice_FlushSourceBuffers(srcvoicemidi); + IXAudio2SourceVoice_DestroyVoice(srcvoicemidi); + } + IXAudio2SourceVoice_DestroyVoice(srcvoice); + IXAudio2SourceVoice_DestroyVoice(srcvoicecd); + IXAudio2MasteringVoice_DestroyVoice(mastervoice); + IXAudio2_Release(xaudio2); + srcvoice = srcvoicecd = srcvoicemidi = NULL; + mastervoice = NULL; + xaudio2 = NULL; + +#if defined(_WIN32) && !defined(USE_FAUDIO) + dynld_close(xaudio2_handle); + xaudio2_handle = NULL; +#endif +} + +void +givealbuffer_common(void *buf, IXAudio2SourceVoice* sourcevoice, size_t buflen) +{ + if (!initialized) return; + + IXAudio2MasteringVoice_SetVolume(mastervoice, pow(10.0, (double)sound_gain / 20.0), XAUDIO2_COMMIT_NOW); + XAUDIO2_BUFFER buffer = {0}; + buffer.Flags = 0; + if (sound_is_float) + { + buffer.pAudioData = calloc(buflen, sizeof(float)); + buffer.AudioBytes = (buflen) * sizeof(float); + } + else + { + buffer.pAudioData = calloc(buflen, sizeof(int16_t)); + buffer.AudioBytes = (buflen) * sizeof(int16_t); + } + if (buffer.pAudioData == NULL) + { + fatal("xaudio2: Out Of Memory!"); + } + memcpy((void*)buffer.pAudioData, buf, buffer.AudioBytes); + buffer.PlayBegin = buffer.PlayLength = 0; + buffer.PlayLength = buflen >> 1; + buffer.pContext = (void*)buffer.pAudioData; + IXAudio2SourceVoice_SubmitSourceBuffer(sourcevoice, &buffer, NULL); +} + +void +givealbuffer(void *buf) +{ + givealbuffer_common(buf, srcvoice, BUFLEN << 1); +} + +void +givealbuffer_cd(void *buf) +{ + if (srcvoicecd) givealbuffer_common(buf, srcvoicecd, CD_BUFLEN << 1); +} + +void +al_set_midi(int freq, int buf_size) +{ + midi_freq = freq; + midi_buf_size = buf_size; + + if (initialized && srcvoicemidi) + { + IXAudio2SourceVoice_Stop(srcvoicemidi, 0, XAUDIO2_COMMIT_NOW); + IXAudio2SourceVoice_FlushSourceBuffers(srcvoicemidi); + IXAudio2SourceVoice_DestroyVoice(srcvoicemidi); + srcvoicemidi = NULL; + WAVEFORMATEX fmt; + fmt.nChannels = 2; + if (sound_is_float) + { + fmt.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; + fmt.wBitsPerSample = 32; + } + else + { + fmt.wFormatTag = WAVE_FORMAT_PCM; + fmt.wBitsPerSample = 16; + } + fmt.nSamplesPerSec = midi_freq; + fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; + fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; + fmt.cbSize = 0; + IXAudio2_CreateSourceVoice(xaudio2, &srcvoicemidi, &fmt, 0, 2.0f, &callbacks, NULL, NULL); + IXAudio2SourceVoice_Start(srcvoicemidi, 0, XAUDIO2_COMMIT_NOW); + } +} + +void +givealbuffer_midi(void *buf, uint32_t size) +{ + givealbuffer_common(buf, srcvoicemidi, size); +} diff --git a/src/thread.cpp b/src/thread.cpp index 4134befba..1003dd871 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -37,6 +37,16 @@ thread_create_mutex(void) return mutex; } +int +thread_test_mutex(mutex_t *_mutex) +{ + if (_mutex == nullptr) + return 0; + + auto mutex = reinterpret_cast(_mutex); + return mutex->try_lock() ? 1 : 0; +} + int thread_wait_mutex(mutex_t *_mutex) { diff --git a/src/unix/unix.c b/src/unix/unix.c index 21418697a..9eb2b2c35 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -53,7 +53,7 @@ SDL_threadID eventthread; static int exit_event = 0; static int fullscreen_pending = 0; uint32_t lang_id = 0x0409, lang_sys = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US -char icon_set[256] = ""; /* name of the iconset to be used */ +char icon_set[256] = ""; /* name of the iconset to be used */ static const uint16_t sdl_to_xt[0x200] = { @@ -663,7 +663,7 @@ plat_power_off(void) void ui_sb_bugui(char *str) { - + } extern void sdl_blit(int x, int y, int w, int h); @@ -814,7 +814,7 @@ void monitor_thread(void* param) } if (f_add_history) f_add_history(line); memset(xargv, 0, sizeof(xargv)); - while(1) + while(1) { xargv[cmdargc++] = local_strsep(&linecpy, " "); if (xargv[cmdargc - 1] == NULL || cmdargc >= 512) break; @@ -861,7 +861,7 @@ void monitor_thread(void* param) uint8_t id; bool err = false; char fn[PATH_MAX]; - + if (!xargv[2] || !xargv[1]) { free(line); @@ -1039,7 +1039,7 @@ int main(int argc, char** argv) SDL_Quit(); return 6; } - + eventthread = SDL_ThreadID(); blitmtx = SDL_CreateMutex(); if (!blitmtx) @@ -1160,7 +1160,7 @@ int main(int argc, char** argv) } case SDL_RENDER_DEVICE_RESET: case SDL_RENDER_TARGETS_RESET: - { + { extern void sdl_reinit_texture(); sdl_reinit_texture(); break; @@ -1194,7 +1194,7 @@ int main(int argc, char** argv) if (mouse_capture && keyboard_ismsexit()) { plat_mouse_capture(0); - } + } if (blitreq) { extern void sdl_blit(int x, int y, int w, int h); @@ -1243,7 +1243,7 @@ set_language(uint32_t id) /* Sets up the program language before initialization. */ uint32_t plat_language_code(char* langcode) { - /* or maybe not */ + /* or maybe not */ return 0; } @@ -1251,7 +1251,7 @@ uint32_t plat_language_code(char* langcode) void plat_language_code_r(uint32_t lcid, char* outbuf, int len) { - /* or maybe not */ + /* or maybe not */ return; } diff --git a/src/unix/unix_sdl.c b/src/unix/unix_sdl.c index 356305d1c..d86b5f72c 100644 --- a/src/unix/unix_sdl.c +++ b/src/unix/unix_sdl.c @@ -153,7 +153,7 @@ sdl_real_blit(SDL_Rect* r_src) r_dst = *r_src; r_dst.x = r_dst.y = 0; - + if (sdl_fs) { sdl_stretch(&r_dst.w, &r_dst.h, &r_dst.x, &r_dst.y); diff --git a/src/usb.c b/src/usb.c index 784f8f151..d1424023e 100644 --- a/src/usb.c +++ b/src/usb.c @@ -416,8 +416,8 @@ const device_t usb_device = "usb", DEVICE_PCI, 0, - usb_init, - usb_close, + usb_init, + usb_close, usb_reset, { NULL }, NULL, diff --git a/src/video/CMakeLists.txt b/src/video/CMakeLists.txt index c58b2f054..b3182afe8 100644 --- a/src/video/CMakeLists.txt +++ b/src/video/CMakeLists.txt @@ -52,4 +52,4 @@ endif() # that cause ~3000 lines to be output into the logs each time if(CMAKE_C_COMPILER_ID STREQUAL "GNU") target_compile_options(voodoo PRIVATE "-Wstringop-overflow=0") -endif() \ No newline at end of file +endif() diff --git a/src/video/vid_ati18800.c b/src/video/vid_ati18800.c index ec63b1dea..1629dc0e5 100644 --- a/src/video/vid_ati18800.c +++ b/src/video/vid_ati18800.c @@ -57,7 +57,7 @@ typedef struct ati18800_t ati_eeprom_t eeprom; rom_t bios_rom; - + uint8_t regs[256]; int index; } ati18800_t; @@ -101,7 +101,7 @@ static void ati18800_out(uint16_t addr, uint8_t val, void *p) break; } break; - + case 0x3D4: svga->crtcreg = val & 0x3f; return; @@ -137,7 +137,7 @@ static uint8_t ati18800_in(uint16_t addr, void *p) uint8_t temp = 0xff; if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout&1)) addr ^= 0x60; - + switch (addr) { case 0x1ce: @@ -262,14 +262,14 @@ static void ati18800_close(void *p) ati18800_t *ati18800 = (ati18800_t *)p; svga_close(&ati18800->svga); - + free(ati18800); } static void ati18800_speed_changed(void *p) { ati18800_t *ati18800 = (ati18800_t *)p; - + svga_recalctimings(&ati18800->svga); } diff --git a/src/video/vid_ati28800.c b/src/video/vid_ati28800.c index dcabd636a..2fac97885 100644 --- a/src/video/vid_ati28800.c +++ b/src/video/vid_ati28800.c @@ -83,7 +83,7 @@ typedef struct ati28800_t int get_korean_font_index; uint16_t get_korean_font_base; int ksc5601_mode_enabled; - + int type, type_korean; } ati28800_t; @@ -169,7 +169,7 @@ ati28800_out(uint16_t addr, uint8_t val, void *p) svga_recalctimings(svga); break; case 0xb8: - if ((old ^ val) & 0x40) + if ((old ^ val) & 0x40) svga_recalctimings(svga); break; case 0xb9: @@ -180,11 +180,11 @@ ati28800_out(uint16_t addr, uint8_t val, void *p) break; case 0x3C6: case 0x3C7: case 0x3C8: case 0x3C9: - if (ati28800->type == 1) + if (ati28800->type == 1) sc1148x_ramdac_out(addr, 0, val, svga->ramdac, svga); else svga_out(addr, val, svga); - return; + return; case 0x3D4: svga->crtcreg = val & 0x3f; @@ -223,9 +223,9 @@ ati28800k_out(uint16_t addr, uint8_t val, void *p) svga_t *svga = &ati28800->svga; uint16_t oldaddr = addr; - if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout&1)) + if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout&1)) addr ^= 0x60; - + switch (addr) { case 0x1CF: if (ati28800->index == 0xBF && ((ati28800->regs[0xBF] ^ val) & 0x20)) { @@ -287,7 +287,7 @@ ati28800_in(uint16_t addr, void *p) if (addr != 0x3da) ati28800_log("ati28800_in : %04X ", addr); - + if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout&1)) addr ^= 0x60; @@ -307,7 +307,7 @@ ati28800_in(uint16_t addr, void *p) temp |= 0x08; } else if (ati28800->memory == 512) { temp |= 0x10; - temp &= ~0x08; + temp &= ~0x08; } else { temp &= ~0x18; } @@ -407,7 +407,7 @@ ati28800_recalctimings(svga_t *svga) if (ati28800->regs[0xb0] & 0x40) svga->ma_latch |= 0x20000; - + switch (((ati28800->regs[0xbe] & 0x10) >> 1) | ((ati28800->regs[0xb9] & 2) << 1) | ((svga->miscout & 0x0C) >> 2)) { case 0x00: svga->clock = (cpuclock * (double)(1ull << 32)) / 42954000.0; break; @@ -429,10 +429,10 @@ ati28800_recalctimings(svga_t *svga) default: break; } - if (ati28800->regs[0xb8] & 0x40) + if (ati28800->regs[0xb8] & 0x40) svga->clock *= 2; - if (ati28800->regs[0xa7] & 0x80) + if (ati28800->regs[0xa7] & 0x80) svga->clock *= 3; if (ati28800->regs[0xb6] & 0x10) { @@ -441,7 +441,7 @@ ati28800_recalctimings(svga_t *svga) svga->rowoffset <<= 1; svga->gdcreg[5] &= ~0x40; } - + if (ati28800->regs[0xb0] & 0x20) { svga->gdcreg[5] |= 0x40; } @@ -449,7 +449,7 @@ ati28800_recalctimings(svga_t *svga) if (!svga->scrblank && svga->attr_palette_enable) { if ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1)) { switch (svga->gdcreg[5] & 0x60) { - case 0x00: + case 0x00: if (svga->seqregs[1] & 8) /*Low res (320)*/ svga->render = svga_render_4bpp_lowres; else @@ -615,7 +615,7 @@ ati28800_init(const device_t *info) ati28800_in, ati28800_out, NULL, NULL); - + io_sethandler(0x01ce, 2, ati28800_in, NULL, NULL, ati28800_out, NULL, NULL, ati28800); @@ -641,7 +641,7 @@ ati28800_init(const device_t *info) default: ati_eeprom_load(&ati28800->eeprom, "ati28800.nvr", 0); break; - } + } return(ati28800); } @@ -692,7 +692,7 @@ static void ati28800_speed_changed(void *p) { ati28800_t *ati28800 = (ati28800_t *)p; - + svga_recalctimings(&ati28800->svga); } diff --git a/src/video/vid_ati68860_ramdac.c b/src/video/vid_ati68860_ramdac.c index 2a7299d00..d9c47955f 100644 --- a/src/video/vid_ati68860_ramdac.c +++ b/src/video/vid_ati68860_ramdac.c @@ -19,7 +19,7 @@ * bit 0-7 Mode. 82h: 4bpp, 83h: 8bpp, * A0h: 15bpp, A1h: 16bpp, C0h: 24bpp, * E3h: 32bpp (80h for VGA modes ?) - * + * * REG0C (R/W): Device Setup Register A * bit 0 Controls 6/8bit DAC. 0: 8bit DAC/LUT, 1: 6bit DAC/LUT * 2-3 Depends on Video memory (= VRAM width ?) . @@ -70,17 +70,17 @@ ati68860_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga) ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) p; switch (addr) { - case 0: + case 0: svga_out(0x3c8, val, svga); break; - case 1: - svga_out(0x3c9, val, svga); + case 1: + svga_out(0x3c9, val, svga); break; - case 2: - svga_out(0x3c6, val, svga); + case 2: + svga_out(0x3c6, val, svga); break; - case 3: - svga_out(0x3c7, val, svga); + case 3: + svga_out(0x3c7, val, svga); break; default: ramdac->regs[addr & 0xf] = val; @@ -93,18 +93,18 @@ ati68860_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga) switch (ramdac->dac_pos) { case 0: ramdac->dac_r = val; - ramdac->dac_pos++; + ramdac->dac_pos++; break; case 1: ramdac->dac_g = val; - ramdac->dac_pos++; + ramdac->dac_pos++; break; case 2: if (ramdac->dac_addr > 1) break; - ramdac->pal[ramdac->dac_addr].r = ramdac->dac_r; + ramdac->pal[ramdac->dac_addr].r = ramdac->dac_r; ramdac->pal[ramdac->dac_addr].g = ramdac->dac_g; - ramdac->pal[ramdac->dac_addr].b = val; + ramdac->pal[ramdac->dac_addr].b = val; if (ramdac->ramdac_type == RAMDAC_8BIT) ramdac->pallook[ramdac->dac_addr] = makecol32(ramdac->pal[ramdac->dac_addr].r, ramdac->pal[ramdac->dac_addr].g, @@ -114,7 +114,7 @@ ati68860_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga) video_6to8[ramdac->pal[ramdac->dac_addr].g & 0x3f], video_6to8[ramdac->pal[ramdac->dac_addr].b & 0x3f]); ramdac->dac_pos = 0; - ramdac->dac_addr = (ramdac->dac_addr + 1) & 255; + ramdac->dac_addr = (ramdac->dac_addr + 1) & 255; break; } break; @@ -177,7 +177,7 @@ ati68860_ramdac_in(uint16_t addr, void *p, svga_t *svga) temp = svga_in(0x3c7, svga); break; case 4: case 8: - temp = 2; + temp = 2; break; case 6: case 0xa: temp = 0x1d; @@ -210,7 +210,7 @@ ati68860_set_ramdac_type(void *p, int type) ramdac->pal[c].b); else ramdac->pallook[c] = makecol32(video_6to8[ramdac->pal[c].r & 0x3f], video_6to8[ramdac->pal[c].g & 0x3f], - video_6to8[ramdac->pal[c].b & 0x3f]); + video_6to8[ramdac->pal[c].b & 0x3f]); } } } diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index 3d14474f2..561f6229b 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -108,7 +108,7 @@ void ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) } } break; - + case EEPROM_INPUT: eeprom->dat = (eeprom->dat << 1) | (dat ? 1 : 0); eeprom->count--; @@ -180,7 +180,7 @@ void ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) } break; } - } + } eeprom->oldena = ena; } else if (!clk && eeprom->oldclk) @@ -208,4 +208,3 @@ int ati_eeprom_read(ati_eeprom_t *eeprom) { return eeprom->out; } - diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 72493dc82..1838ef5a7 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -88,15 +88,15 @@ typedef struct mach64_t ati_eeprom_t eeprom; svga_t svga; - + rom_t bios_rom; - + uint8_t regs[256]; int index; int type, pci, bit32; - + uint8_t pci_regs[256]; uint8_t int_line; int card; @@ -106,12 +106,12 @@ typedef struct mach64_t uint32_t vram_size; uint32_t vram_mask; - + uint32_t config_cntl; uint32_t context_load_cntl; uint32_t context_mask; - + uint32_t crtc_gen_cntl; uint8_t crtc_int_cntl; uint32_t crtc_h_total_disp; @@ -125,45 +125,45 @@ typedef struct mach64_t uint32_t clr_cmp_cntl; uint32_t clr_cmp_mask; - uint32_t cur_horz_vert_off; + uint32_t cur_horz_vert_off; uint32_t cur_horz_vert_posn; uint32_t cur_offset; - + uint32_t dac_cntl; - + uint32_t dp_bkgd_clr; uint32_t dp_frgd_clr; uint32_t dp_mix; uint32_t dp_pix_width; uint32_t dp_src; - + uint32_t dst_bres_lnth; uint32_t dst_bres_dec; uint32_t dst_bres_err; uint32_t dst_bres_inc; - + uint32_t dst_cntl; uint32_t dst_height_width; uint32_t dst_off_pitch; uint32_t dst_y_x; uint32_t gen_test_cntl; - + uint32_t gui_traj_cntl; uint32_t host_cntl; - + uint32_t mem_cntl; uint32_t ovr_clr; uint32_t ovr_wid_left_right; uint32_t ovr_wid_top_bottom; - - uint32_t pat_cntl; + + uint32_t pat_cntl; uint32_t pat_reg0, pat_reg1; - + uint32_t sc_left_right, sc_top_bottom; - + uint32_t scratch_reg0, scratch_reg1; uint32_t src_cntl; @@ -179,7 +179,7 @@ typedef struct mach64_t struct { int op; - + int dst_x, dst_y; int dst_x_start, dst_y_start; int src_x, src_y; @@ -190,10 +190,10 @@ typedef struct mach64_t int src_width1, src_height1; int src_width2, src_height2; uint32_t src_offset, src_pitch; - uint32_t dst_offset, dst_pitch; + uint32_t dst_offset, dst_pitch; int mix_bg, mix_fg; int source_bg, source_fg, source_mix; - int source_host; + int source_host; int dst_width, dst_height; int busy; int pattern[8][8]; @@ -210,7 +210,7 @@ typedef struct mach64_t uint32_t clr_cmp_mask; int clr_cmp_fn; int clr_cmp_src; - + int err; int poly_draw; } accel; @@ -218,20 +218,20 @@ typedef struct mach64_t int blitter_busy; uint64_t blitter_time; uint64_t status_time; - + uint16_t pci_id; uint32_t config_chip_id; uint32_t block_decoded_io; int use_block_decoded_io; - + int pll_addr; uint8_t pll_regs[16]; double pll_freq[4]; - + uint32_t config_stat0; - + uint32_t cur_clr0, cur_clr1; - + uint32_t overlay_dat[1024]; uint32_t overlay_graphics_key_clr, overlay_graphics_key_msk; uint32_t overlay_video_key_clr, overlay_video_key_msk; @@ -239,13 +239,13 @@ typedef struct mach64_t uint32_t overlay_scale_inc; uint32_t overlay_scale_cntl; uint32_t overlay_y_x_start, overlay_y_x_end; - + uint32_t scaler_height_width; int scaler_format; int scaler_update; - + uint32_t buf_offset[2], buf_pitch[2]; - + int overlay_v_acc; uint8_t thread_run; @@ -368,8 +368,8 @@ void mach64_out(uint16_t addr, uint8_t val, void *p) mach64_t *mach64 = p; svga_t *svga = &mach64->svga; uint8_t old; - - if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout & 1)) + + if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) @@ -382,14 +382,14 @@ void mach64_out(uint16_t addr, uint8_t val, void *p) if ((mach64->index & 0x3f) == 0x36) svga_recalctimings(svga); break; - + case 0x3C6: case 0x3C7: case 0x3C8: case 0x3C9: if (mach64->type == MACH64_GX) ati68860_ramdac_out((addr & 3) | ((mach64->dac_cntl & 3) << 2), val, mach64->svga.ramdac, svga); else svga_out(addr, val, svga); return; - + case 0x3cf: if (svga->gdcaddr == 6) { @@ -400,7 +400,7 @@ void mach64_out(uint16_t addr, uint8_t val, void *p) return; } break; - + case 0x3D4: svga->crtcreg = val & 0x3f; return; @@ -437,9 +437,9 @@ uint8_t mach64_in(uint16_t addr, void *p) mach64_t *mach64 = p; svga_t *svga = &mach64->svga; - if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout&1)) + if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout&1)) addr ^= 0x60; - + switch (addr) { case 0x1ce: @@ -451,7 +451,7 @@ uint8_t mach64_in(uint16_t addr, void *p) if (mach64->type == MACH64_GX) return ati68860_ramdac_in((addr & 3) | ((mach64->dac_cntl & 3) << 2), mach64->svga.ramdac, svga); return svga_in(addr, svga); - + case 0x3D4: return svga->crtcreg; case 0x3D5: @@ -485,36 +485,36 @@ void mach64_recalctimings(svga_t *svga) ati68860_ramdac_set_render(svga->ramdac, svga); switch ((mach64->crtc_gen_cntl >> 8) & 7) { - case 1: + case 1: if (mach64->type != MACH64_GX) - svga->render = svga_render_4bpp_highres; + svga->render = svga_render_4bpp_highres; svga->hdisp *= 8; break; - case 2: + case 2: if (mach64->type != MACH64_GX) - svga->render = svga_render_8bpp_highres; + svga->render = svga_render_8bpp_highres; svga->hdisp *= 8; svga->rowoffset /= 2; break; - case 3: + case 3: if (mach64->type != MACH64_GX) - svga->render = svga_render_15bpp_highres; + svga->render = svga_render_15bpp_highres; svga->hdisp *= 8; break; - case 4: + case 4: if (mach64->type != MACH64_GX) - svga->render = svga_render_16bpp_highres; + svga->render = svga_render_16bpp_highres; svga->hdisp *= 8; break; - case 5: + case 5: if (mach64->type != MACH64_GX) - svga->render = svga_render_24bpp_highres; + svga->render = svga_render_24bpp_highres; svga->hdisp *= 8; svga->rowoffset = (svga->rowoffset * 3) / 2; break; - case 6: + case 6: if (mach64->type != MACH64_GX) - svga->render = svga_render_32bpp_highres; + svga->render = svga_render_32bpp_highres; svga->hdisp *= 8; svga->rowoffset *= 2; break; @@ -641,7 +641,7 @@ static void mach64_wait_fifo_idle(mach64_t *mach64) case 2: ret = ((var) >> 16) & 0xff; break; \ case 3: ret = ((var) >> 24) & 0xff; break; \ } - + #define WRITE8(addr, var, val) switch ((addr) & 3) \ { \ case 0: var = (var & 0xffffff00) | (val); break; \ @@ -682,8 +682,8 @@ static void mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val mach64_log("%i %i %i %i %i %08x\n", (mach64->dst_height_width & 0x7ff), (mach64->dst_height_width & 0x7ff0000), ((mach64->dp_src & 7) != SRC_HOST), (((mach64->dp_src >> 8) & 7) != SRC_HOST), (((mach64->dp_src >> 16) & 3) != MONO_SRC_HOST), mach64->dp_src); - if ((mach64->dst_height_width & 0x7ff) && (mach64->dst_height_width & 0x7ff0000) && - ((mach64->dp_src & 7) != SRC_HOST) && (((mach64->dp_src >> 8) & 7) != SRC_HOST) && + if ((mach64->dst_height_width & 0x7ff) && (mach64->dst_height_width & 0x7ff0000) && + ((mach64->dp_src & 7) != SRC_HOST) && (((mach64->dp_src >> 8) & 7) != SRC_HOST) && (((mach64->dp_src >> 16) & 3) != MONO_SRC_HOST)) mach64_blit(0, -1, mach64); } @@ -696,7 +696,7 @@ static void mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val mach64_start_line(mach64); if ((mach64->dst_bres_lnth & 0x7fff) && - ((mach64->dp_src & 7) != SRC_HOST) && (((mach64->dp_src >> 8) & 7) != SRC_HOST) && + ((mach64->dp_src & 7) != SRC_HOST) && (((mach64->dp_src >> 8) & 7) != SRC_HOST) && (((mach64->dp_src >> 16) & 3) != MONO_SRC_HOST)) mach64_blit(0, -1, mach64); } @@ -777,7 +777,7 @@ static void mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val case 0x23c: case 0x23d: case 0x23e: case 0x23f: mach64_blit(val, 8, mach64); break; - + case 0x240: case 0x241: case 0x242: case 0x243: WRITE8(addr, mach64->host_cntl, val); break; @@ -799,7 +799,7 @@ static void mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val case 0x2a4: case 0x2a5: addr += 2; /*FALLTHROUGH*/ - case 0x2aa: case 0x2ab: + case 0x2aa: case 0x2ab: WRITE8(addr, mach64->sc_left_right, val); break; @@ -899,7 +899,7 @@ static void mach64_accel_write_fifo_l(mach64_t *mach64, uint32_t addr, uint32_t if (val & 0x30000) mach64_load_context(mach64); break; - + case 0x200: case 0x204: case 0x208: case 0x20c: case 0x210: case 0x214: case 0x218: case 0x21c: case 0x220: case 0x224: case 0x228: case 0x22c: @@ -921,7 +921,7 @@ static void mach64_accel_write_fifo_l(mach64_t *mach64, uint32_t addr, uint32_t static void fifo_thread(void *param) { mach64_t *mach64 = (mach64_t *)param; - + while (mach64->thread_run) { thread_set_event(mach64->fifo_not_full_event); @@ -946,7 +946,7 @@ static void fifo_thread(void *param) mach64_accel_write_fifo_l(mach64, fifo->addr_type & FIFO_ADDR, fifo->val); break; } - + mach64->fifo_read_idx++; fifo->addr_type = FIFO_INVALID; @@ -977,7 +977,7 @@ static void mach64_queue(mach64_t *mach64, uint32_t addr, uint32_t val, uint32_t fifo->addr_type = (addr & FIFO_ADDR) | type; mach64->fifo_write_idx++; - + if (FIFO_ENTRIES > 0xe000 || FIFO_ENTRIES < 8) wake_fifo_thread(mach64); } @@ -991,14 +991,14 @@ void mach64_cursor_dump(mach64_t *mach64) void mach64_start_fill(mach64_t *mach64) { int x, y; - + mach64->accel.dst_x = 0; mach64->accel.dst_y = 0; mach64->accel.dst_x_start = (mach64->dst_y_x >> 16) & 0xfff; mach64->accel.dst_y_start = mach64->dst_y_x & 0xfff; mach64->accel.dst_width = (mach64->dst_height_width >> 16) & 0x1fff; - mach64->accel.dst_height = mach64->dst_height_width & 0x1fff; + mach64->accel.dst_height = mach64->dst_height_width & 0x1fff; if (((mach64->dp_src >> 16) & 7) == MONO_SRC_BLITSRC) { @@ -1007,7 +1007,7 @@ void mach64_start_fill(mach64_t *mach64) } mach64->accel.x_count = mach64->accel.dst_width; - + mach64->accel.src_x = 0; mach64->accel.src_y = 0; mach64->accel.src_x_start = (mach64->src_y_x >> 16) & 0xfff; @@ -1022,9 +1022,9 @@ void mach64_start_fill(mach64_t *mach64) mach64->accel.src_y_count = mach64->src_height1_width1 & 0x1fff; mach64->accel.src_width1 = (mach64->src_height1_width1 >> 16) & 0x7fff; - mach64->accel.src_height1 = mach64->src_height1_width1 & 0x1fff; + mach64->accel.src_height1 = mach64->src_height1_width1 & 0x1fff; mach64->accel.src_width2 = (mach64->src_height2_width2 >> 16) & 0x7fff; - mach64->accel.src_height2 = mach64->src_height2_width2 & 0x1fff; + mach64->accel.src_height2 = mach64->src_height2_width2 & 0x1fff; mach64_log("src %i %i %i %i %08X %08X\n", mach64->accel.src_x_count, mach64->accel.src_y_count, @@ -1032,24 +1032,24 @@ void mach64_start_fill(mach64_t *mach64) mach64->accel.src_height1, mach64->src_height1_width1, mach64->src_height2_width2); - + mach64->accel.src_pitch = (mach64->src_off_pitch >> 22) * 8; mach64->accel.src_offset = (mach64->src_off_pitch & 0xfffff) * 8; mach64->accel.dst_pitch = (mach64->dst_off_pitch >> 22) * 8; mach64->accel.dst_offset = (mach64->dst_off_pitch & 0xfffff) * 8; - + mach64->accel.mix_fg = (mach64->dp_mix >> 16) & 0x1f; mach64->accel.mix_bg = mach64->dp_mix & 0x1f; - + mach64->accel.source_bg = mach64->dp_src & 7; mach64->accel.source_fg = (mach64->dp_src >> 8) & 7; mach64->accel.source_mix = (mach64->dp_src >> 16) & 7; - + mach64->accel.dst_pix_width = mach64->dp_pix_width & 7; mach64->accel.src_pix_width = (mach64->dp_pix_width >> 8) & 7; mach64->accel.host_pix_width = (mach64->dp_pix_width >> 16) & 7; - + mach64->accel.dst_size = mach64_width[mach64->accel.dst_pix_width]; mach64->accel.src_size = mach64_width[mach64->accel.src_pix_width]; mach64->accel.host_size = mach64_width[mach64->accel.host_pix_width]; @@ -1058,18 +1058,18 @@ void mach64_start_fill(mach64_t *mach64) mach64->accel.src_offset <<= 3; else mach64->accel.src_offset >>= mach64->accel.src_size; - + if (mach64->accel.dst_size == WIDTH_1BIT) mach64->accel.dst_offset <<= 3; else mach64->accel.dst_offset >>= mach64->accel.dst_size; - + mach64->accel.xinc = (mach64->dst_cntl & DST_X_DIR) ? 1 : -1; - mach64->accel.yinc = (mach64->dst_cntl & DST_Y_DIR) ? 1 : -1; - + mach64->accel.yinc = (mach64->dst_cntl & DST_Y_DIR) ? 1 : -1; + mach64->accel.source_host = ((mach64->dp_src & 7) == SRC_HOST) || (((mach64->dp_src >> 8) & 7) == SRC_HOST); - - + + for (y = 0; y < 8; y++) { for (x = 0; x < 8; x++) @@ -1098,7 +1098,7 @@ void mach64_start_fill(mach64_t *mach64) mach64->accel.pattern_clr8x1[6] = ((mach64->pat_reg1 >> 16) & 0xff); mach64->accel.pattern_clr8x1[7] = ((mach64->pat_reg1 >> 24) & 0xff); } - + mach64->accel.sc_left = mach64->sc_left_right & 0x1fff; mach64->accel.sc_right = (mach64->sc_left_right >> 16) & 0x1fff; mach64->accel.sc_top = mach64->sc_top_bottom & 0x7fff; @@ -1111,9 +1111,9 @@ void mach64_start_fill(mach64_t *mach64) mach64->accel.clr_cmp_mask = mach64->clr_cmp_mask; mach64->accel.clr_cmp_fn = mach64->clr_cmp_cntl & 7; mach64->accel.clr_cmp_src = mach64->clr_cmp_cntl & (1 << 24); - + mach64->accel.poly_draw = 0; - + mach64->accel.busy = 1; mach64_log("mach64_start_fill : dst %i, %i src %i, %i size %i, %i src pitch %i offset %X dst pitch %i offset %X scissor %i %i %i %i src_fg %i mix %02X %02X\n", mach64->accel.dst_x_start, mach64->accel.dst_y_start, mach64->accel.src_x_start, mach64->accel.src_y_start, mach64->accel.dst_width, mach64->accel.dst_height, mach64->accel.src_pitch, mach64->accel.src_offset, mach64->accel.dst_pitch, mach64->accel.dst_offset, mach64->accel.sc_left, mach64->accel.sc_right, mach64->accel.sc_top, mach64->accel.sc_bottom, mach64->accel.source_fg, mach64->accel.mix_fg, mach64->accel.mix_bg); @@ -1123,7 +1123,7 @@ void mach64_start_fill(mach64_t *mach64) void mach64_start_line(mach64_t *mach64) { int x, y; - + mach64->accel.dst_x = (mach64->dst_y_x >> 16) & 0xfff; mach64->accel.dst_y = mach64->dst_y_x & 0xfff; @@ -1135,27 +1135,27 @@ void mach64_start_line(mach64_t *mach64) mach64->accel.dst_pitch = (mach64->dst_off_pitch >> 22) * 8; mach64->accel.dst_offset = (mach64->dst_off_pitch & 0xfffff) * 8; - + mach64->accel.mix_fg = (mach64->dp_mix >> 16) & 0x1f; mach64->accel.mix_bg = mach64->dp_mix & 0x1f; - + mach64->accel.source_bg = mach64->dp_src & 7; mach64->accel.source_fg = (mach64->dp_src >> 8) & 7; mach64->accel.source_mix = (mach64->dp_src >> 16) & 7; - + mach64->accel.dst_pix_width = mach64->dp_pix_width & 7; mach64->accel.src_pix_width = (mach64->dp_pix_width >> 8) & 7; mach64->accel.host_pix_width = (mach64->dp_pix_width >> 16) & 7; - + mach64->accel.dst_size = mach64_width[mach64->accel.dst_pix_width]; mach64->accel.src_size = mach64_width[mach64->accel.src_pix_width]; mach64->accel.host_size = mach64_width[mach64->accel.host_pix_width]; - + if (mach64->accel.src_size == WIDTH_1BIT) mach64->accel.src_offset <<= 3; else mach64->accel.src_offset >>= mach64->accel.src_size; - + if (mach64->accel.dst_size == WIDTH_1BIT) mach64->accel.dst_offset <<= 3; else @@ -1163,9 +1163,9 @@ void mach64_start_line(mach64_t *mach64) /* mach64->accel.src_pitch *= mach64_inc[mach64->accel.src_pix_width]; mach64->accel.dst_pitch *= mach64_inc[mach64->accel.dst_pix_width];*/ - + mach64->accel.source_host = ((mach64->dp_src & 7) == SRC_HOST) || (((mach64->dp_src >> 8) & 7) == SRC_HOST); - + for (y = 0; y < 8; y++) { for (x = 0; x < 8; x++) @@ -1174,18 +1174,18 @@ void mach64_start_line(mach64_t *mach64) mach64->accel.pattern[y][7 - x] = (temp >> (x + ((y & 3) * 8))) & 1; } } - + mach64->accel.sc_left = mach64->sc_left_right & 0x1fff; mach64->accel.sc_right = (mach64->sc_left_right >> 16) & 0x1fff; mach64->accel.sc_top = mach64->sc_top_bottom & 0x7fff; mach64->accel.sc_bottom = (mach64->sc_top_bottom >> 16) & 0x7fff; - + mach64->accel.dp_frgd_clr = mach64->dp_frgd_clr; - mach64->accel.dp_bkgd_clr = mach64->dp_bkgd_clr; - + mach64->accel.dp_bkgd_clr = mach64->dp_bkgd_clr; + mach64->accel.x_count = mach64->dst_bres_lnth & 0x7fff; mach64->accel.err = (mach64->dst_bres_err & 0x3ffff) | ((mach64->dst_bres_err & 0x40000) ? 0xfffc0000 : 0); - + mach64->accel.clr_cmp_clr = mach64->clr_cmp_clr & mach64->clr_cmp_mask; mach64->accel.clr_cmp_mask = mach64->clr_cmp_mask; mach64->accel.clr_cmp_fn = mach64->clr_cmp_cntl & 7; @@ -1202,7 +1202,7 @@ void mach64_start_line(mach64_t *mach64) else if (width == 2) dat = *(uint32_t *)&svga->vram[((addr) << 2) & mach64->vram_mask]; \ else if (mach64->dp_pix_width & DP_BYTE_PIX_ORDER) dat = (svga->vram[((addr) >> 3) & mach64->vram_mask] >> ((addr) & 7)) & 1; \ else dat = (svga->vram[((addr) >> 3) & mach64->vram_mask] >> (7 - ((addr) & 7))) & 1; - + #define MIX switch (mix ? mach64->accel.mix_fg : mach64->accel.mix_bg) \ { \ case 0x0: dest_dat = ~dest_dat; break; \ @@ -1222,7 +1222,7 @@ void mach64_start_line(mach64_t *mach64) case 0xe: dest_dat = ~src_dat & dest_dat; break; \ case 0xf: dest_dat = ~(src_dat | dest_dat); break; \ } - + #define WRITE(addr, width) if (width == 0) \ { \ svga->vram[(addr) & mach64->vram_mask] = dest_dat; \ @@ -1258,7 +1258,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) { svga_t *svga = &mach64->svga; int cmp_clr = 0; - + if (!mach64->accel.busy) { mach64_log("mach64_blit : return as not busy\n"); @@ -1276,7 +1276,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) int dst_y = (mach64->accel.dst_y + mach64->accel.dst_y_start) & 0xfff; int src_x; int src_y = (mach64->accel.src_y + mach64->accel.src_y_start) & 0xfff; - + if (mach64->src_cntl & SRC_LINEAR_EN) src_x = mach64->accel.src_x; else @@ -1337,7 +1337,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) if (dst_x >= mach64->accel.sc_left && dst_x <= mach64->accel.sc_right && dst_y >= mach64->accel.sc_top && dst_y <= mach64->accel.sc_bottom) - { + { switch (mix ? mach64->accel.source_fg : mach64->accel.source_bg) { case SRC_HOST: @@ -1387,20 +1387,20 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) cmp_clr = (((mach64->accel.clr_cmp_src) ? src_dat : dest_dat) & mach64->accel.clr_cmp_mask) == mach64->accel.clr_cmp_clr; break; } - + if (!cmp_clr) MIX WRITE(mach64->accel.dst_offset + (dst_y * mach64->accel.dst_pitch) + dst_x, mach64->accel.dst_size); } } - + if (mach64->dst_cntl & DST_24_ROT_EN) { mach64->accel.dp_frgd_clr = ((mach64->accel.dp_frgd_clr >> 8) & 0xffff) | (mach64->accel.dp_frgd_clr << 16); mach64->accel.dp_bkgd_clr = ((mach64->accel.dp_bkgd_clr >> 8) & 0xffff) | (mach64->accel.dp_bkgd_clr << 16); } - + mach64->accel.src_x += mach64->accel.xinc; mach64->accel.dst_x += mach64->accel.xinc; if (!(mach64->src_cntl & SRC_LINEAR_EN)) @@ -1418,9 +1418,9 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) mach64->accel.src_x_count = mach64->accel.src_width1; } } - + mach64->accel.x_count--; - + if (mach64->accel.x_count <= 0) { mach64->accel.x_count = mach64->accel.dst_width; @@ -1432,7 +1432,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) if (!(mach64->src_cntl & SRC_LINEAR_EN)) { mach64->accel.src_x = 0; - mach64->accel.src_y += mach64->accel.yinc; + mach64->accel.src_y += mach64->accel.yinc; mach64->accel.src_y_count--; if (mach64->accel.src_y_count <= 0) { @@ -1448,9 +1448,9 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) } mach64->accel.poly_draw = 0; - + mach64->accel.dst_height--; - + if (mach64->accel.dst_height <= 0) { /*Blit finished*/ @@ -1474,9 +1474,9 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) } } } - } + } break; - + case OP_LINE: while (count) { @@ -1484,7 +1484,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) uint32_t host_dat = 0; int mix = 0; int draw_pixel = !(mach64->dst_cntl & DST_POLYGON_EN); - + if (mach64->accel.source_host) { host_dat = cpu_dat; @@ -1520,7 +1520,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) mix = 1; break; } - + if (mach64->dst_cntl & DST_POLYGON_EN) { if (mach64->dst_cntl & DST_Y_MAJOR) @@ -1555,7 +1555,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) src_dat = 0; break; } - + READ(mach64->accel.dst_offset + (mach64->accel.dst_y * mach64->accel.dst_pitch) + mach64->accel.dst_x, dest_dat, mach64->accel.dst_size); switch (mach64->accel.clr_cmp_fn) @@ -1570,14 +1570,14 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) cmp_clr = (((mach64->accel.clr_cmp_src) ? src_dat : dest_dat) & mach64->accel.clr_cmp_mask) == mach64->accel.clr_cmp_clr; break; } - + if (!cmp_clr) MIX WRITE(mach64->accel.dst_offset + (mach64->accel.dst_y * mach64->accel.dst_pitch) + mach64->accel.dst_x, mach64->accel.dst_size); } - - mach64->accel.x_count--; + + mach64->accel.x_count--; if (mach64->accel.x_count <= 0) { /*Blit finished*/ @@ -1585,10 +1585,10 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) mach64->accel.busy = 0; return; } - + switch (mach64->dst_cntl & 7) { - case 0: case 2: + case 0: case 2: mach64->accel.src_x--; mach64->accel.dst_x--; break; @@ -1596,7 +1596,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) mach64->accel.src_x++; mach64->accel.dst_x++; break; - case 4: case 5: + case 4: case 5: mach64->accel.src_y--; mach64->accel.dst_y--; break; @@ -1609,10 +1609,10 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) if (mach64->accel.err >= 0) { mach64->accel.err += mach64->dst_bres_dec; - + switch (mach64->dst_cntl & 7) { - case 0: case 1: + case 0: case 1: mach64->accel.src_y--; mach64->accel.dst_y--; break; @@ -1620,7 +1620,7 @@ void mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64) mach64->accel.src_y++; mach64->accel.dst_y++; break; - case 4: case 6: + case 4: case 6: mach64->accel.src_x--; mach64->accel.dst_x--; break; @@ -1641,7 +1641,7 @@ void mach64_load_context(mach64_t *mach64) { svga_t *svga = &mach64->svga; uint32_t addr; - + while (mach64->context_load_cntl & 0x30000) { addr = ((0x3fff - (mach64->context_load_cntl & 0x3fff)) * 256) & mach64->vram_mask; @@ -1700,7 +1700,7 @@ void mach64_load_context(mach64_t *mach64) mach64_accel_write_fifo_l(mach64, 0x308, *(uint32_t *)&svga->vram[addr + 0x68]); if (mach64->context_mask & (1 << 27)) mach64_accel_write_fifo_l(mach64, 0x330, *(uint32_t *)&svga->vram[addr + 0x6c]); - + mach64->context_load_cntl = *(uint32_t *)&svga->vram[addr + 0x70]; } } @@ -1712,7 +1712,7 @@ void mach64_load_context(mach64_t *mach64) static void pll_write(mach64_t *mach64, uint32_t addr, uint8_t val) { int c; - + switch (addr & 3) { case 0: /*Clock sel*/ @@ -1725,12 +1725,12 @@ static void pll_write(mach64_t *mach64, uint32_t addr, uint8_t val) mach64_log("pll_write %02x,%02x\n", mach64->pll_addr, val); for (c = 0; c < 4; c++) - { + { double m = (double)mach64->pll_regs[PLL_REF_DIV]; double n = (double)mach64->pll_regs[VCLK0_FB_DIV+c]; double r = 14318184.0; double p = (double)(1 << ((mach64->pll_regs[VCLK_POST_DIV] >> (c*2)) & 3)); - + mach64_log("PLLfreq %i = %g %g m=%02x n=%02x p=%02x\n", c, (2.0 * r * n) / (m * p), p, mach64->pll_regs[PLL_REF_DIV], mach64->pll_regs[VCLK0_FB_DIV+c], mach64->pll_regs[VCLK_POST_DIV]); mach64->pll_freq[c] = (2.0 * r * n) / (m * p); mach64_log(" %g\n", mach64->pll_freq[c]); @@ -1744,21 +1744,21 @@ static void mach64_vblank_start(svga_t *svga) { mach64_t *mach64 = (mach64_t *)svga->p; int overlay_cmp_mix = (mach64->overlay_key_cntl >> 8) & 0xf; - + mach64->crtc_int_cntl |= 4; mach64_update_irqs(mach64); - + svga->overlay.x = (mach64->overlay_y_x_start >> 16) & 0x7ff; svga->overlay.y = mach64->overlay_y_x_start & 0x7ff; - + svga->overlay.xsize = ((mach64->overlay_y_x_end >> 16) & 0x7ff) - svga->overlay.x; svga->overlay.ysize = (mach64->overlay_y_x_end & 0x7ff) - svga->overlay.y; - + svga->overlay.addr = mach64->buf_offset[0] & 0x3ffff8; svga->overlay.pitch = mach64->buf_pitch[0] & 0xfff; - + svga->overlay.ena = (mach64->overlay_scale_cntl & OVERLAY_EN) && (overlay_cmp_mix != 1); - + mach64->overlay_v_acc = 0; mach64->scaler_update = 1; } @@ -1804,11 +1804,11 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0x28: case 0x29: case 0x2a: case 0x2b: READ8(addr, mach64->scaler_height_width); break; - + case 0x4a: ret = mach64->scaler_format; break; - + default: ret = 0xff; break; @@ -1829,11 +1829,11 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0x12: case 0x13: READ8(addr - 2, mach64->svga.vc); break; - + case 0x14: case 0x15: case 0x16: case 0x17: READ8(addr, mach64->crtc_off_pitch); break; - + case 0x18: ret = mach64->crtc_int_cntl & ~1; if (mach64->svga.cgastat & 8) @@ -1873,7 +1873,7 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0x79: ret = 0x30; break; - + case 0x80: case 0x81: case 0x82: case 0x83: READ8(addr, mach64->scratch_reg0); break; @@ -1898,7 +1898,7 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0xc4: case 0xc5: case 0xc6: READ8(addr, mach64->dac_cntl); break; - + case 0xc7: READ8(addr, mach64->dac_cntl); if (mach64->type == MACH64_VT2) { @@ -1927,7 +1927,7 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0xe4: case 0xe5: case 0xe6: case 0xe7: READ8(addr, mach64->config_stat0); break; - + case 0x100: case 0x101: case 0x102: case 0x103: READ8(addr, mach64->dst_off_pitch); break; @@ -2020,7 +2020,7 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0x284: case 0x285: case 0x286: case 0x287: READ8(addr, mach64->pat_reg1); break; - + case 0x288: case 0x289: case 0x28a: case 0x28b: READ8(addr, mach64->pat_cntl); break; @@ -2051,7 +2051,7 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0x2c4: case 0x2c5: case 0x2c6: case 0x2c7: READ8(addr, mach64->dp_frgd_clr); break; - + case 0x2d0: case 0x2d1: case 0x2d2: case 0x2d3: READ8(addr, mach64->dp_pix_width); break; @@ -2071,11 +2071,11 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0x308: case 0x309: case 0x30a: case 0x30b: READ8(addr, mach64->clr_cmp_cntl); break; - + case 0x310: case 0x311: ret = 0; break; - + case 0x320: case 0x321: case 0x322: case 0x323: READ8(addr, mach64->context_mask); break; @@ -2089,7 +2089,7 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) case 0x333: READ8(addr - 3, mach64->pat_cntl); break; - + case 0x338: ret = 0; break; @@ -2125,7 +2125,7 @@ uint16_t mach64_ext_readw(uint32_t addr, void *p) break; } if ((addr & 0x3fc) != 0x018) mach64_log("mach64_ext_readw : addr %08X ret %04X\n", addr, ret); - return ret; + return ret; } uint32_t mach64_ext_readl(uint32_t addr, void *p) { @@ -2250,7 +2250,7 @@ void mach64_ext_writeb(uint32_t addr, uint8_t val, void *p) svga_recalctimings(&mach64->svga); svga->fullchange = changeframecount; break; - + case 0x18: mach64->crtc_int_cntl = (mach64->crtc_int_cntl & 0x75) | (val & ~0x75); if (val & 4) @@ -2428,7 +2428,7 @@ void mach64_ext_writel(uint32_t addr, uint32_t val, void *p) uint8_t mach64_ext_inb(uint16_t port, void *p) { - mach64_t *mach64 = (mach64_t *)p; + mach64_t *mach64 = (mach64_t *)p; uint8_t ret; switch (port) @@ -2499,7 +2499,7 @@ uint8_t mach64_ext_inb(uint16_t port, void *p) case 0x52ec: case 0x52ed: case 0x52ee: case 0x52ef: ret = mach64_ext_readb(0x400 | 0xb0 | (port & 3), p); break; - + case 0x56ec: ret = mach64_ext_readb(0x400 | 0xb4, p); break; @@ -2519,11 +2519,11 @@ uint8_t mach64_ext_inb(uint16_t port, void *p) else ret = ati68860_ramdac_in(port & 3, mach64->svga.ramdac, &mach64->svga); break; - + case 0x62ec: case 0x62ed: case 0x62ee: case 0x62ef: ret = mach64_ext_readb(0x400 | 0xc4 | (port & 3), p); break; - + case 0x66ec: case 0x66ed: case 0x66ee: case 0x66ef: ret = mach64_ext_readb(0x400 | 0xd0 | (port & 3), p); break; @@ -2532,7 +2532,7 @@ uint8_t mach64_ext_inb(uint16_t port, void *p) mach64->config_cntl = (mach64->config_cntl & ~0x3ff0) | ((mach64->linear_base >> 22) << 4); READ8(port, mach64->config_cntl); break; - + case 0x6eec: case 0x6eed: case 0x6eee: case 0x6eef: ret = mach64_ext_readb(0x400 | 0xe0 | (port & 3), p); break; @@ -2559,7 +2559,7 @@ uint16_t mach64_ext_inw(uint16_t port, void *p) break; } mach64_log("mach64_ext_inw : port %04X ret %04X\n", port, ret); - return ret; + return ret; } uint32_t mach64_ext_inl(uint16_t port, void *p) { @@ -2603,7 +2603,7 @@ void mach64_ext_outb(uint16_t port, uint8_t val, void *p) case 0x16ec: case 0x16ed: case 0x16ee: case 0x16ef: mach64_ext_writeb(0x400 | 0x14 | (port & 3), val, p); break; - + case 0x1aec: mach64_ext_writeb(0x400 | 0x18, val, p); break; @@ -2713,7 +2713,7 @@ static uint8_t mach64_block_inb(uint16_t port, void *p) { mach64_t *mach64 = (mach64_t *)p; uint8_t ret; - + ret = mach64_ext_readb(0x400 | (port & 0x3ff), mach64); mach64_log("mach64_block_inb : port %04X ret %02X\n", port, ret); return ret; @@ -2722,7 +2722,7 @@ static uint16_t mach64_block_inw(uint16_t port, void *p) { mach64_t *mach64 = (mach64_t *)p; uint16_t ret; - + ret = mach64_ext_readw(0x400 | (port & 0x3ff), mach64); mach64_log("mach64_block_inw : port %04X ret %04X\n", port, ret); return ret; @@ -2731,7 +2731,7 @@ static uint32_t mach64_block_inl(uint16_t port, void *p) { mach64_t *mach64 = (mach64_t *)p; uint32_t ret; - + ret = mach64_ext_readl(0x400 | (port & 0x3ff), mach64); mach64_log("mach64_block_inl : port %04X ret %08X\n", port, ret); return ret; @@ -2740,21 +2740,21 @@ static uint32_t mach64_block_inl(uint16_t port, void *p) static void mach64_block_outb(uint16_t port, uint8_t val, void *p) { mach64_t *mach64 = (mach64_t *)p; - + mach64_log("mach64_block_outb : port %04X val %02X\n ", port, val); mach64_ext_writeb(0x400 | (port & 0x3ff), val, mach64); } static void mach64_block_outw(uint16_t port, uint16_t val, void *p) { mach64_t *mach64 = (mach64_t *)p; - + mach64_log("mach64_block_outw : port %04X val %04X\n ", port, val); mach64_ext_writew(0x400 | (port & 0x3ff), val, mach64); } static void mach64_block_outl(uint16_t port, uint32_t val, void *p) { mach64_t *mach64 = (mach64_t *)p; - + mach64_log("mach64_block_outl : port %04X val %08X\n ", port, val); mach64_ext_writel(0x400 | (port & 0x3ff), val, mach64); } @@ -2790,7 +2790,7 @@ uint8_t mach64_read(uint32_t addr, void *p) uint8_t ret; addr = (addr & 0x7fff) + mach64->bank_r[(addr >> 15) & 1]; ret = svga_read_linear(addr, svga); - return ret; + return ret; } uint16_t mach64_readw(uint32_t addr, void *p) { @@ -2983,7 +2983,7 @@ void mach64_overlay_draw(svga_t *svga, int displine) case 0xc: DECODE_YVYU422(); break; - + default: mach64_log("Unknown Mach64 scaler format %x\n", mach64->scaler_format); /*Fill buffer with something recognisably wrong*/ @@ -3030,7 +3030,7 @@ void mach64_overlay_draw(svga_t *svga, int displine) } vid_cmp = vid_cmp ? -1 : 0; gr_cmp = gr_cmp ? -1 : 0; - + switch (overlay_cmp_mix) { case 0x0: use_video = gr_cmp; break; @@ -3059,18 +3059,18 @@ void mach64_overlay_draw(svga_t *svga, int displine) h_acc = (h_max << 12); } } - + mach64->overlay_v_acc += v_inc; if (mach64->overlay_v_acc > (v_max << 12)) mach64->overlay_v_acc = v_max << 12; - + y_diff = (mach64->overlay_v_acc >> 12) - (old_y >> 12); if (mach64->scaler_format == 6) svga->overlay.addr += svga->overlay.pitch*4*y_diff; else svga->overlay.addr += svga->overlay.pitch*2*y_diff; - + mach64->scaler_update = y_diff; } @@ -3097,7 +3097,7 @@ static void mach64_io_remove(mach64_t *mach64) } io_removehandler(0x03c0, 0x0020, mach64_in, NULL, NULL, mach64_out, NULL, NULL, mach64); - + for (c = 0; c < 8; c++) { io_removehandler((c * 0x1000) + 0x0000 + io_base, 0x0004, mach64_ext_inb, mach64_ext_inw, mach64_ext_inl, mach64_ext_outb, mach64_ext_outw, mach64_ext_outl, mach64); @@ -3115,11 +3115,11 @@ static void mach64_io_remove(mach64_t *mach64) static void mach64_io_set(mach64_t *mach64) { int c; - + mach64_io_remove(mach64); - + io_sethandler(0x03c0, 0x0020, mach64_in, NULL, NULL, mach64_out, NULL, NULL, mach64); - + if (!mach64->use_block_decoded_io) { for (c = 0; c < 8; c++) @@ -3145,25 +3145,25 @@ uint8_t mach64_pci_read(int func, int addr, void *p) { case 0x00: return 0x02; /*ATi*/ case 0x01: return 0x10; - + case 0x02: return mach64->pci_id & 0xff; case 0x03: return mach64->pci_id >> 8; - + case PCI_REG_COMMAND: return mach64->pci_regs[PCI_REG_COMMAND]; /*Respond to IO and memory accesses*/ case 0x07: return 1 << 1; /*Medium DEVSEL timing*/ - + case 0x08: /*Revision ID*/ if (mach64->type == MACH64_GX) return 0; return 0x40; - + case 0x09: return 0; /*Programming interface*/ - + case 0x0a: return 0x01; /*Supports VGA interface, XGA compatible*/ case 0x0b: return 0x03; - + case 0x10: return 0x00; /*Linear frame buffer address*/ case 0x11: return 0x00; case 0x12: return mach64->linear_base >> 16; @@ -3190,10 +3190,10 @@ uint8_t mach64_pci_read(int func, int addr, void *p) case 0x31: return 0x00; case 0x32: return mach64->pci_regs[0x32]; case 0x33: return mach64->pci_regs[0x33]; - + case 0x3c: return mach64->int_line; case 0x3d: return PCI_INTA; - + case 0x40: return mach64->use_block_decoded_io | mach64->io_base; } return 0; @@ -3274,7 +3274,7 @@ void mach64_pci_write(int func, int addr, uint8_t val, void *p) case 0x3c: mach64->int_line = val; break; - + case 0x40: if (mach64->pci_regs[PCI_REG_COMMAND] & PCI_COMMAND_IO) mach64_io_remove(mach64); @@ -3291,10 +3291,10 @@ static void *mach64_common_init(const device_t *info) { mach64_t *mach64 = malloc(sizeof(mach64_t)); memset(mach64, 0, sizeof(mach64_t)); - + mach64->vram_size = device_get_config_int("memory"); mach64->vram_mask = (mach64->vram_size << 20) - 1; - + svga_init(info, &mach64->svga, mach64, mach64->vram_size << 20, mach64_recalctimings, mach64_in, mach64_out, @@ -3332,7 +3332,7 @@ static void *mach64_common_init(const device_t *info) mach64->i2c = i2c_gpio_init("ddc_ati_mach64"); mach64->ddc = ddc_init(i2c_gpio_get_bus(mach64->i2c)); - + return mach64; } @@ -3368,7 +3368,7 @@ static void *mach64gx_init(const device_t *info) rom_init(&mach64->bios_rom, BIOS_VLB_ROM_PATH, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); else if (info->flags & DEVICE_ISA) rom_init(&mach64->bios_rom, BIOS_ISA_ROM_PATH, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + return mach64; } static void *mach64vt2_init(const device_t *info) @@ -3388,13 +3388,13 @@ static void *mach64vt2_init(const device_t *info) mach64->dac_cntl = 1 << 16; /*Internal 24-bit DAC*/ mach64->config_stat0 = 4; mach64->use_block_decoded_io = 4; - + ati_eeprom_load(&mach64->eeprom, "mach64vt.nvr", 1); rom_init(&mach64->bios_rom, BIOS_ROMVT2_PATH, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + svga->vblank_start = mach64_vblank_start; - + return mach64; } @@ -3430,7 +3430,7 @@ void mach64_close(void *p) void mach64_speed_changed(void *p) { mach64_t *mach64 = (mach64_t *)p; - + svga_recalctimings(&mach64->svga); } diff --git a/src/video/vid_att20c49x_ramdac.c b/src/video/vid_att20c49x_ramdac.c index e533015b0..4c09b6b2f 100644 --- a/src/video/vid_att20c49x_ramdac.c +++ b/src/video/vid_att20c49x_ramdac.c @@ -160,7 +160,7 @@ att49x_ramdac_init(const device_t *info) memset(ramdac, 0, sizeof(att49x_ramdac_t)); ramdac->type = info->local; - + return ramdac; } @@ -200,4 +200,4 @@ const device_t att492_ramdac_device = 0, ATT_492, att49x_ramdac_init, att49x_ramdac_close, NULL, { NULL }, NULL, NULL -}; \ No newline at end of file +}; diff --git a/src/video/vid_att2xc498_ramdac.c b/src/video/vid_att2xc498_ramdac.c index 122a97d2c..14e4fe639 100644 --- a/src/video/vid_att2xc498_ramdac.c +++ b/src/video/vid_att2xc498_ramdac.c @@ -162,7 +162,7 @@ att498_ramdac_init(const device_t *info) memset(ramdac, 0, sizeof(att498_ramdac_t)); ramdac->type = info->local; - + return ramdac; } @@ -184,4 +184,4 @@ const device_t att498_ramdac_device = 0, 0, att498_ramdac_init, att498_ramdac_close, NULL, { NULL }, NULL, NULL -}; \ No newline at end of file +}; diff --git a/src/video/vid_av9194.c b/src/video/vid_av9194.c index a2e208621..f6cc3407f 100644 --- a/src/video/vid_av9194.c +++ b/src/video/vid_av9194.c @@ -33,7 +33,7 @@ float av9194_getclock(int clock, void *p) { float ret = 0.0; - + switch (clock & 0x0f) { case 0: @@ -82,7 +82,7 @@ av9194_getclock(int clock, void *p) ret = 94500000.0; break; } - + return ret; } @@ -103,4 +103,3 @@ const device_t av9194_device = av9194_init, NULL, NULL, { NULL }, NULL, NULL }; - diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 651039517..e022e1a67 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -41,7 +41,7 @@ #define COMPOSITE_OLD 0 #define COMPOSITE_NEW 1 -static uint8_t crtcmask[32] = +static uint8_t crtcmask[32] = { 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -204,7 +204,7 @@ cga_poll(void *p) cga->cgastat |= 1; cga->linepos = 1; oldsc = cga->sc; - if ((cga->crtc[8] & 3) == 3) + if ((cga->crtc[8] & 3) == 3) cga->sc = ((cga->sc << 1) + cga->oddeven) & 7; if (cga->cgadispon) { if (cga->displine < cga->firstline) { @@ -237,7 +237,7 @@ cga_poll(void *p) } if (cga->cgamode & 1) { for (x = 0; x < cga->crtc[1]; x++) { - if (cga->cgamode & 8) { + if (cga->cgamode & 8) { chr = cga->charbuffer[x << 1]; attr = cga->charbuffer[(x << 1) + 1]; } else @@ -246,7 +246,7 @@ cga_poll(void *p) cols[1] = (attr & 15) + 16; if (cga->cgamode & 0x20) { cols[0] = ((attr >> 4) & 7) + 16; - if ((cga->cgablink & 8) && (attr & 0x80) && !cga->drawcursor) + if ((cga->cgablink & 8) && (attr & 0x80) && !cga->drawcursor) cols[1] = cols[0]; } else cols[0] = (attr >> 4) + 16; @@ -333,7 +333,7 @@ cga_poll(void *p) } else { cols[0] = 0; cols[1] = (cga->cgacol & 15) + 16; for (x = 0; x < cga->crtc[1]; x++) { - if (cga->cgamode & 8) + if (cga->cgamode & 8) dat = (cga->vram[((cga->ma << 1) & 0x1fff) + ((cga->sc & 1) * 0x2000)] << 8) | cga->vram[((cga->ma << 1) & 0x1fff) + ((cga->sc & 1) * 0x2000) + 1]; else dat = 0; @@ -376,7 +376,7 @@ cga_poll(void *p) if (cga->vc == cga->crtc[7] && !cga->sc) cga->cgastat |= 8; cga->displine++; - if (cga->displine >= 360) + if (cga->displine >= 360) cga->displine = 0; } else { timer_advance_u64(&cga->timer, cga->dispontime); @@ -387,8 +387,8 @@ cga_poll(void *p) cga->cgastat &= ~8; } if (cga->sc == (cga->crtc[11] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[11] & 31) >> 1))) { - cga->con = 0; - cga->coff = 1; + cga->con = 0; + cga->coff = 1; } if ((cga->crtc[8] & 3) == 3 && cga->sc == (cga->crtc[9] >> 1)) cga->maback = cga->ma; @@ -409,7 +409,7 @@ cga_poll(void *p) cga->vc++; cga->vc &= 127; - if (cga->vc == cga->crtc[6]) + if (cga->vc == cga->crtc[6]) cga->cgadispon = 0; if (oldvc == cga->crtc[4]) { @@ -462,14 +462,14 @@ cga_poll(void *p) } if (enable_overscan) { - if (cga->composite) + if (cga->composite) video_blit_memtoscreen(0, (cga->firstline - 4) << 1, xsize, ((cga->lastline - cga->firstline) + 8) << 1); else video_blit_memtoscreen_8(0, (cga->firstline - 4) << 1, xsize, ((cga->lastline - cga->firstline) + 8) << 1); } else { - if (cga->composite) + if (cga->composite) video_blit_memtoscreen(8, cga->firstline << 1, xsize, (cga->lastline - cga->firstline) << 1); else @@ -508,7 +508,7 @@ cga_poll(void *p) } if (cga->cgadispon) cga->cgastat &= ~1; - if ((cga->sc == (cga->crtc[10] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[10] & 31) >> 1)))) + if ((cga->sc == (cga->crtc[10] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[10] & 31) >> 1)))) cga->con = 1; if (cga->cgadispon && (cga->cgamode & 1)) { for (x = 0; x < (cga->crtc[1] << 1); x++) diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index ff543cfa0..99fb61980 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -163,16 +163,16 @@ typedef struct gd54xx_t uint32_t vram_mask; uint8_t vclk_n[4]; - uint8_t vclk_d[4]; + uint8_t vclk_d[4]; struct { uint8_t state; int ctrl; - } ramdac; - + } ramdac; + struct { uint16_t width, height; - uint16_t dst_pitch, src_pitch; + uint16_t dst_pitch, src_pitch; uint16_t trans_col, trans_mask; uint16_t height_internal; uint16_t msd_buf_pos, msd_buf_cnt; @@ -215,7 +215,7 @@ typedef struct gd54xx_t uint8_t fc; /* Feature Connector */ int card, id; - + uint8_t pos_regs[8]; uint32_t lfb_base, vgablt_base; @@ -234,13 +234,13 @@ static video_timings_t timing_gd54xx_vlb = {VIDEO_BUS, 4, 4, 8, 10, 10, 20}; static video_timings_t timing_gd54xx_pci = {VIDEO_PCI, 4, 4, 8, 10, 10, 20}; -static void +static void gd543x_mmio_write(uint32_t addr, uint8_t val, void *p); -static void +static void gd543x_mmio_writeb(uint32_t addr, uint8_t val, void *p); -static void +static void gd543x_mmio_writew(uint32_t addr, uint16_t val, void *p); -static void +static void gd543x_mmio_writel(uint32_t addr, uint32_t val, void *p); static uint8_t gd543x_mmio_read(uint32_t addr, void *p); @@ -249,15 +249,15 @@ gd543x_mmio_readw(uint32_t addr, void *p); static uint32_t gd543x_mmio_readl(uint32_t addr, void *p); -static void +static void gd54xx_recalc_banking(gd54xx_t *gd54xx); -static void +static void gd543x_recalc_mapping(gd54xx_t *gd54xx); static void gd54xx_reset_blit(gd54xx_t *gd54xx); -static void +static void gd54xx_start_blit(uint32_t cpu_dat, uint32_t count, gd54xx_t *gd54xx, svga_t *svga); @@ -653,7 +653,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) uint8_t o, index; uint32_t o32; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -669,7 +669,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) } else { o = svga->attrregs[svga->attraddr & 31]; svga->attrregs[svga->attraddr & 31] = val; - if (svga->attraddr < 16) + if (svga->attraddr < 16) svga->fullchange = changeframecount; if (svga->attraddr == 0x10 || svga->attraddr == 0x14 || svga->attraddr < 0x10) { for (c = 0; c < 16; c++) { @@ -693,8 +693,8 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) } } svga->attrff ^= 1; - return; - + return; + case 0x3c4: svga->seqaddr = val; break; @@ -804,11 +804,11 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) switch (svga->dac_pos) { case 0: svga->dac_r = val; - svga->dac_pos++; + svga->dac_pos++; break; case 1: svga->dac_g = val; - svga->dac_pos++; + svga->dac_pos++; break; case 2: index = svga->dac_addr & 0xff; @@ -816,7 +816,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) index &= 0x0f; gd54xx->extpal[index].r = svga->dac_r; gd54xx->extpal[index].g = svga->dac_g; - gd54xx->extpal[index].b = val; + gd54xx->extpal[index].b = val; gd54xx->extpallook[index] = makecol32(video_6to8[gd54xx->extpal[index].r & 0x3f], video_6to8[gd54xx->extpal[index].g & 0x3f], video_6to8[gd54xx->extpal[index].b & 0x3f]); if (svga->ext_overscan && (index == 2)) { o32 = svga->overscan_color; @@ -827,11 +827,11 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) } else { svga->vgapal[index].r = svga->dac_r; svga->vgapal[index].g = svga->dac_g; - svga->vgapal[index].b = val; + svga->vgapal[index].b = val; svga->pallook[index] = makecol32(video_6to8[svga->vgapal[index].r & 0x3f], video_6to8[svga->vgapal[index].g & 0x3f], video_6to8[svga->vgapal[index].b & 0x3f]); } svga->dac_addr = (svga->dac_addr + 1) & 255; - svga->dac_pos = 0; + svga->dac_pos = 0; break; } return; @@ -853,7 +853,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) if (svga->gdcaddr <= 8) { switch (svga->gdcaddr) { - case 0: + case 0: gd543x_mmio_write(0xb8000, val, gd54xx); break; case 1: @@ -1169,7 +1169,7 @@ gd54xx_in(uint16_t addr, void *p) uint8_t index, ret = 0xff; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -1226,7 +1226,7 @@ gd54xx_in(uint16_t addr, void *p) case 2048: ret |= 0x18; break; - } + } } break; case 0x0b: case 0x0c: case 0x0d: case 0x0e: @@ -1335,14 +1335,14 @@ gd54xx_in(uint16_t addr, void *p) else ret = svga->vgapal[index].r & 0x3f; break; - case 1: + case 1: svga->dac_pos++; if (svga->seqregs[0x12] & 2) ret = gd54xx->extpal[index].g & 0x3f; else ret = svga->vgapal[index].g & 0x3f; break; - case 2: + case 2: svga->dac_pos=0; svga->dac_addr = (svga->dac_addr + 1) & 255; if (svga->seqregs[0x12] & 2) @@ -1500,7 +1500,7 @@ gd54xx_in(uint16_t addr, void *p) ret = svga->attrff << 7; break; case 0x26: /*Attribute controller index readback (R)*/ - ret = svga->attraddr & 0x3f; + ret = svga->attraddr & 0x3f; break; case 0x27: /*ID*/ ret = svga->crtc[0x27]; /*GD542x/GD543x*/ @@ -1553,7 +1553,7 @@ gd54xx_recalc_banking(gd54xx_t *gd54xx) } -static void +static void gd543x_recalc_mapping(gd54xx_t *gd54xx) { svga_t *svga = &gd54xx->svga; @@ -1566,7 +1566,7 @@ gd543x_recalc_mapping(gd54xx_t *gd54xx) mem_mapping_disable(&gd54xx->mmio_mapping); return; } - + gd54xx->mmio_vram_overlap = 0; if (!gd54xx_is_5422(svga) || !(svga->seqregs[7] & 0xf0) || !(svga->seqregs[0x07] & 0x01)) { @@ -1652,7 +1652,7 @@ gd543x_recalc_mapping(gd54xx_t *gd54xx) static void gd54xx_recalctimings(svga_t *svga) { - gd54xx_t *gd54xx = (gd54xx_t *)svga->p; + gd54xx_t *gd54xx = (gd54xx_t *)svga->p; uint8_t clocksel, rdmask; uint8_t linedbl = svga->dispend * 9 / 10 >= svga->hdisp; @@ -1744,53 +1744,53 @@ gd54xx_recalctimings(svga_t *svga) svga->render = svga_render_8bpp_highres; break; - case 0xf: - switch (svga->seqregs[7] & CIRRUS_SR7_BPP_MASK) { - case CIRRUS_SR7_BPP_32: - if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5430) { - svga->bpp = 32; + case 0xf: + switch (svga->seqregs[7] & CIRRUS_SR7_BPP_MASK) { + case CIRRUS_SR7_BPP_32: + if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5430) { + svga->bpp = 32; if (linedbl) svga->render = svga_render_32bpp_lowres; else svga->render = svga_render_32bpp_highres; - svga->rowoffset *= 2; - } - break; + svga->rowoffset *= 2; + } + break; - case CIRRUS_SR7_BPP_24: - svga->bpp = 24; + case CIRRUS_SR7_BPP_24: + svga->bpp = 24; if (linedbl) svga->render = svga_render_24bpp_lowres; else svga->render = svga_render_24bpp_highres; - break; + break; - case CIRRUS_SR7_BPP_16: - if ((svga->crtc[0x27] >= CIRRUS_ID_CLGD5428) || (svga->crtc[0x27] == CIRRUS_ID_CLGD5426)) { - svga->bpp = 16; + case CIRRUS_SR7_BPP_16: + if ((svga->crtc[0x27] >= CIRRUS_ID_CLGD5428) || (svga->crtc[0x27] == CIRRUS_ID_CLGD5426)) { + svga->bpp = 16; if (linedbl) svga->render = svga_render_16bpp_lowres; else svga->render = svga_render_16bpp_highres; - } - break; + } + break; - case CIRRUS_SR7_BPP_16_DOUBLEVCLK: - svga->bpp = 16; + case CIRRUS_SR7_BPP_16_DOUBLEVCLK: + svga->bpp = 16; if (linedbl) svga->render = svga_render_16bpp_lowres; else svga->render = svga_render_16bpp_highres; - break; + break; - case CIRRUS_SR7_BPP_8: - svga->bpp = 8; + case CIRRUS_SR7_BPP_8: + svga->bpp = 8; if (linedbl) svga->render = svga_render_8bpp_lowres; else svga->render = svga_render_8bpp_highres; - break; - } + break; + } break; } } else { @@ -1825,7 +1825,7 @@ gd54xx_recalctimings(svga_t *svga) break; case 4: if (!gd54xx_is_5434(svga)) - freq /= 3.0; + freq /= 3.0; break; } } @@ -1839,7 +1839,7 @@ gd54xx_recalctimings(svga_t *svga) static void gd54xx_hwcursor_draw(svga_t *svga, int displine) { - gd54xx_t *gd54xx = (gd54xx_t *)svga->p; + gd54xx_t *gd54xx = (gd54xx_t *)svga->p; int x, xx, comb, b0, b1; uint8_t dat[2]; int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff; @@ -1883,7 +1883,7 @@ void gd54xx_hwcursor_draw(svga_t *svga, int displine) break; } } - + offset++; } svga->hwcursor_latch.addr++; @@ -1970,7 +1970,7 @@ static void gd54xx_write(uint32_t addr, uint8_t val, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; - svga_t *svga = &gd54xx->svga; + svga_t *svga = &gd54xx->svga; if (gd54xx->countminusone && !gd54xx->blt.ms_is_dest && !(gd54xx->blt.status & CIRRUS_BLT_PAUSED)) { @@ -1989,7 +1989,7 @@ gd54xx_write(uint32_t addr, uint8_t val, void *p) } -static void +static void gd54xx_writew(uint32_t addr, uint16_t val, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; @@ -2009,7 +2009,7 @@ gd54xx_writew(uint32_t addr, uint16_t val, void *p) addr = (addr & 0x7fff) + svga->extra_banks[(addr >> 15) & 1]; - if (svga->writemode < 4) + if (svga->writemode < 4) svga_writew_linear(addr, val, svga); else { svga_write_linear(addr, val, svga); @@ -2159,7 +2159,7 @@ gd54xx_readb_linear(uint32_t addr, void *p) switch (ap) { case 0: - default: + default: break; case 1: /* 0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2 */ @@ -2208,7 +2208,7 @@ gd54xx_readw_linear(uint32_t addr, void *p) switch (ap) { case 0: - default: + default: return svga_readw_linear(addr, svga); case 2: /* 0 -> 3, 1 -> 2, 2 -> 1, 3 -> 0 */ @@ -2260,7 +2260,7 @@ gd54xx_readl_linear(uint32_t addr, void *p) switch (ap) { case 0: - default: + default: return svga_readl_linear(addr, svga); case 1: temp = svga_readb_linear(addr + 1, svga); @@ -2425,7 +2425,7 @@ gd54xx_writeb_linear(uint32_t addr, uint8_t val, void *p) } -static void +static void gd54xx_writew_linear(uint32_t addr, uint16_t val, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; @@ -2491,7 +2491,7 @@ gd54xx_writew_linear(uint32_t addr, uint16_t val, void *p) } -static void +static void gd54xx_writel_linear(uint32_t addr, uint32_t val, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; @@ -2777,14 +2777,14 @@ gd543x_mmio_write(uint32_t addr, uint8_t val, void *p) break; case 0x1b: - if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) + if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) gd54xx->blt.modeext = val; break; case 0x1c: gd54xx->blt.trans_col = (gd54xx->blt.trans_col & 0xff00) | val; break; - case 0x1d: + case 0x1d: gd54xx->blt.trans_col = (gd54xx->blt.trans_col & 0x00ff) | (val << 8); break; @@ -2860,14 +2860,14 @@ gd543x_mmio_writel(uint32_t addr, uint32_t val, void *p) gd543x_mmio_write(addr, val & 0xff, gd54xx); gd543x_mmio_write(addr+1, val >> 8, gd54xx); gd543x_mmio_write(addr+2, val >> 16, gd54xx); - gd543x_mmio_write(addr+3, val >> 24, gd54xx); + gd543x_mmio_write(addr+3, val >> 24, gd54xx); } else if (gd54xx->mmio_vram_overlap) { if (gd54xx->countminusone && !gd54xx->blt.ms_is_dest && !(gd54xx->blt.status & CIRRUS_BLT_PAUSED)) { gd543x_mmio_write(addr, val & 0xff, gd54xx); gd543x_mmio_write(addr+1, val >> 8, gd54xx); gd543x_mmio_write(addr+2, val >> 16, gd54xx); - gd543x_mmio_write(addr+3, val >> 24, gd54xx); + gd543x_mmio_write(addr+3, val >> 24, gd54xx); } else { gd54xx_write(addr, val, gd54xx); gd54xx_write(addr+1, val >> 8, gd54xx); @@ -2986,21 +2986,21 @@ gd543x_mmio_read(uint32_t addr, void *p) break; case 0x1b: - if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) + if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) ret = gd54xx->blt.modeext; break; case 0x1c: ret = gd54xx->blt.trans_col & 0xff; break; - case 0x1d: + case 0x1d: ret = (gd54xx->blt.trans_col >> 8) & 0xff; break; case 0x20: ret = gd54xx->blt.trans_mask & 0xff; break; - case 0x21: + case 0x21: ret = (gd54xx->blt.trans_mask >> 8) & 0xff; break; @@ -3564,7 +3564,7 @@ request_more_data: } -static void +static void gd54xx_start_blit(uint32_t cpu_dat, uint32_t count, gd54xx_t *gd54xx, svga_t *svga) { if ((gd54xx->blt.mode & CIRRUS_BLTMODE_BACKWARDS) && @@ -3596,7 +3596,7 @@ gd54xx_start_blit(uint32_t cpu_dat, uint32_t count, gd54xx_t *gd54xx, svga_t *sv } -static uint8_t +static uint8_t cl_pci_read(int func, int addr, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; @@ -3619,7 +3619,7 @@ cl_pci_read(int func, int addr, void *p) case 0x03: ret = 0x00; break; - + case PCI_REG_COMMAND: ret = gd54xx->pci_regs[PCI_REG_COMMAND]; /*Respond to IO and memory accesses*/ break; @@ -3695,7 +3695,7 @@ cl_pci_read(int func, int addr, void *p) } -static void +static void cl_pci_write(int func, int addr, uint8_t val, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; @@ -3724,7 +3724,7 @@ cl_pci_write(int func, int addr, uint8_t val, void *p) val &= 0xfe; gd54xx->lfb_base = val << 24; gd543x_recalc_mapping(gd54xx); - break; + break; case 0x15: case 0x16: case 0x17: if (svga->crtc[0x27] != CIRRUS_ID_CLGD5480) @@ -3754,27 +3754,27 @@ cl_pci_write(int func, int addr, uint8_t val, void *p) } } -static uint8_t +static uint8_t gd5428_mca_read(int port, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; - + return gd54xx->pos_regs[port & 7]; } -static void +static void gd5428_mca_write(int port, uint8_t val, void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; if (port < 0x102) return; - + gd54xx->pos_regs[port & 7] = val; gd543x_recalc_mapping(gd54xx); } -static uint8_t +static uint8_t gd5428_mca_feedb(void *p) { return 1; @@ -3863,7 +3863,7 @@ static void char *romfn = NULL; memset(gd54xx, 0, sizeof(gd54xx_t)); - gd54xx->pci = !!(info->flags & DEVICE_PCI); + gd54xx->pci = !!(info->flags & DEVICE_PCI); gd54xx->vlb = !!(info->flags & DEVICE_VLB); gd54xx->mca = !!(info->flags & DEVICE_MCA); gd54xx->bit32 = gd54xx->pci || gd54xx->vlb; @@ -3873,11 +3873,11 @@ static void gd54xx->id = id; - switch (id) { + switch (id) { case CIRRUS_ID_CLGD5401: romfn = BIOS_GD5401_PATH; break; - + case CIRRUS_ID_CLGD5402: if (info->local & 0x200) romfn = BIOS_GD5402_ONBOARD_PATH; @@ -3892,7 +3892,7 @@ static void case CIRRUS_ID_CLGD5422: case CIRRUS_ID_CLGD5424: romfn = BIOS_GD5422_PATH; - break; + break; case CIRRUS_ID_CLGD5426: if (info->local & 0x200) @@ -3982,7 +3982,7 @@ static void romfn = BIOS_GD5480_PATH; break; } - + if (info->flags & DEVICE_MCA) { vram = 1024; gd54xx->vram_size = vram << 10; @@ -4066,7 +4066,7 @@ static void NULL, MEM_MAPPING_EXTERNAL, gd54xx); } io_sethandler(0x03c0, 0x0020, gd54xx_in, NULL, NULL, gd54xx_out, NULL, NULL, gd54xx); - + if (gd54xx->pci && id >= CIRRUS_ID_CLGD5430) pci_add_card(PCI_ADD_VIDEO, cl_pci_read, cl_pci_write, gd54xx); @@ -4109,14 +4109,14 @@ static void svga->crtc[0x27] = id; svga->seqregs[6] = 0x0f; - + if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5429) gd54xx->unlocked = 1; if (gd54xx->mca) { gd54xx->pos_regs[0] = 0x7b; gd54xx->pos_regs[1] = 0x91; - mca_add(gd5428_mca_read, gd5428_mca_write, gd5428_mca_feedb, NULL, gd54xx); + mca_add(gd5428_mca_read, gd5428_mca_write, gd5428_mca_feedb, NULL, gd54xx); io_sethandler(0x46e8, 0x0001, gd54xx_in, NULL, NULL, gd54xx_out, NULL, NULL, gd54xx); } @@ -4260,7 +4260,7 @@ gd54xx_close(void *p) ddc_close(gd54xx->ddc); i2c_gpio_close(gd54xx->i2c); } - + free(gd54xx); } @@ -4269,7 +4269,7 @@ void gd54xx_speed_changed(void *p) { gd54xx_t *gd54xx = (gd54xx_t *)p; - + svga_recalctimings(&gd54xx->svga); } @@ -4602,8 +4602,8 @@ const device_t gd5426_isa_device = "cl_gd5426_isa", DEVICE_AT | DEVICE_ISA, CIRRUS_ID_CLGD5426, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5428_isa_available }, gd54xx_speed_changed, @@ -4619,8 +4619,8 @@ const device_t gd5426_diamond_speedstar_pro_a1_isa_device = "cl_gd5426_diamond_a1_isa", DEVICE_AT | DEVICE_ISA, CIRRUS_ID_CLGD5426 | 0x100, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5426_diamond_a1_available }, gd54xx_speed_changed, @@ -4634,8 +4634,8 @@ const device_t gd5426_vlb_device = "cl_gd5426_vlb", DEVICE_VLB, CIRRUS_ID_CLGD5426, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5428_available }, gd54xx_speed_changed, @@ -4650,8 +4650,8 @@ const device_t gd5426_onboard_device = "cl_gd5426_onboard", DEVICE_VLB, CIRRUS_ID_CLGD5426 | 0x200, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { NULL }, gd54xx_speed_changed, @@ -4665,8 +4665,8 @@ const device_t gd5428_isa_device = "cl_gd5428_isa", DEVICE_AT | DEVICE_ISA, CIRRUS_ID_CLGD5428, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5428_isa_available }, gd54xx_speed_changed, @@ -4680,8 +4680,8 @@ const device_t gd5428_vlb_device = "cl_gd5428_vlb", DEVICE_VLB, CIRRUS_ID_CLGD5428, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5428_available }, gd54xx_speed_changed, @@ -4696,8 +4696,8 @@ const device_t gd5428_diamond_speedstar_pro_b1_vlb_device = "cl_gd5428_diamond_b1_vlb", DEVICE_VLB, CIRRUS_ID_CLGD5428 | 0x100, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5428_diamond_b1_available }, gd54xx_speed_changed, @@ -4711,8 +4711,8 @@ const device_t gd5428_mca_device = "ibm1mbsvga", DEVICE_MCA, CIRRUS_ID_CLGD5428, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5428_mca_available }, gd54xx_speed_changed, @@ -4726,8 +4726,8 @@ const device_t gd5428_onboard_device = "cl_gd5428_onboard", DEVICE_AT | DEVICE_ISA, CIRRUS_ID_CLGD5428, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5428_isa_available }, gd54xx_speed_changed, @@ -4741,8 +4741,8 @@ const device_t gd5429_isa_device = "cl_gd5429_isa", DEVICE_AT | DEVICE_ISA, CIRRUS_ID_CLGD5429, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5429_available }, gd54xx_speed_changed, @@ -4756,8 +4756,8 @@ const device_t gd5429_vlb_device = "cl_gd5429_vlb", DEVICE_VLB, CIRRUS_ID_CLGD5429, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5429_available }, gd54xx_speed_changed, @@ -4772,8 +4772,8 @@ const device_t gd5430_diamond_speedstar_pro_se_a8_vlb_device = "cl_gd5430_vlb", DEVICE_VLB, CIRRUS_ID_CLGD5430, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5430_diamond_a8_available }, gd54xx_speed_changed, @@ -4787,8 +4787,8 @@ const device_t gd5430_pci_device = "cl_gd5430_pci", DEVICE_PCI, CIRRUS_ID_CLGD5430, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5430_available }, gd54xx_speed_changed, @@ -4802,7 +4802,7 @@ const device_t gd5434_isa_device = "cl_gd5434_isa", DEVICE_AT | DEVICE_ISA, CIRRUS_ID_CLGD5434, - gd54xx_init, + gd54xx_init, gd54xx_close, gd54xx_reset, { gd5434_available }, @@ -4818,7 +4818,7 @@ const device_t gd5434_diamond_speedstar_64_a3_isa_device = "cl_gd5434_diamond_a3_isa", DEVICE_AT | DEVICE_ISA, CIRRUS_ID_CLGD5434 | 0x100, - gd54xx_init, + gd54xx_init, gd54xx_close, gd54xx_reset, { gd5434_diamond_a3_available }, @@ -4833,8 +4833,8 @@ const device_t gd5434_onboard_pci_device = "cl_gd5434_onboard_pci", DEVICE_PCI, CIRRUS_ID_CLGD5434 | 0x200, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { NULL }, gd54xx_speed_changed, @@ -4848,8 +4848,8 @@ const device_t gd5434_vlb_device = "cl_gd5434_vlb", DEVICE_VLB, CIRRUS_ID_CLGD5434, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5434_available }, gd54xx_speed_changed, @@ -4863,8 +4863,8 @@ const device_t gd5434_pci_device = "cl_gd5434_pci", DEVICE_PCI, CIRRUS_ID_CLGD5434, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5434_available }, gd54xx_speed_changed, @@ -4878,8 +4878,8 @@ const device_t gd5436_pci_device = "cl_gd5436_pci", DEVICE_PCI, CIRRUS_ID_CLGD5436, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5436_available }, gd54xx_speed_changed, @@ -4894,7 +4894,7 @@ const device_t gd5440_onboard_pci_device = DEVICE_PCI, CIRRUS_ID_CLGD5440 | 0x600, gd54xx_init, - gd54xx_close, + gd54xx_close, gd54xx_reset, { NULL }, gd54xx_speed_changed, @@ -4909,7 +4909,7 @@ const device_t gd5440_pci_device = DEVICE_PCI, CIRRUS_ID_CLGD5440 | 0x400, gd54xx_init, - gd54xx_close, + gd54xx_close, gd54xx_reset, { gd5440_available }, gd54xx_speed_changed, @@ -4924,7 +4924,7 @@ const device_t gd5446_pci_device = DEVICE_PCI, CIRRUS_ID_CLGD5446, gd54xx_init, - gd54xx_close, + gd54xx_close, gd54xx_reset, { gd5446_available }, gd54xx_speed_changed, @@ -4939,7 +4939,7 @@ const device_t gd5446_stb_pci_device = DEVICE_PCI, CIRRUS_ID_CLGD5446 | 0x100, gd54xx_init, - gd54xx_close, + gd54xx_close, gd54xx_reset, { gd5446_stb_available }, gd54xx_speed_changed, @@ -4953,8 +4953,8 @@ const device_t gd5480_pci_device = "cl_gd5480_pci", DEVICE_PCI, CIRRUS_ID_CLGD5480, - gd54xx_init, - gd54xx_close, + gd54xx_init, + gd54xx_close, gd54xx_reset, { gd5480_available }, gd54xx_speed_changed, diff --git a/src/video/vid_colorplus.c b/src/video/vid_colorplus.c index 7f2a4e004..3b51beb60 100644 --- a/src/video/vid_colorplus.c +++ b/src/video/vid_colorplus.c @@ -111,12 +111,12 @@ uint8_t colorplus_read(uint32_t addr, void *p) (colorplus->cga.cgamode & CGA_GRAPHICS_MODE)) { addr ^= 0x4000; - } + } else if (!(colorplus->control & COLORPLUS_EITHER_MODE)) { addr &= 0x3FFF; } - cycles -= 4; + cycles -= 4; if (colorplus->cga.snow_enabled) { int offset = ((timer_get_remaining_u64(&colorplus->cga.timer) / CGACONST) * 2) & 0xfc; @@ -162,7 +162,7 @@ void colorplus_poll(void *p) colorplus->cga.cgastat |= 1; colorplus->cga.linepos = 1; oldsc = colorplus->cga.sc; - if ((colorplus->cga.crtc[8] & 3) == 3) + if ((colorplus->cga.crtc[8] & 3) == 3) colorplus->cga.sc = ((colorplus->cga.sc << 1) + colorplus->cga.oddeven) & 7; if (colorplus->cga.cgadispon) { @@ -191,7 +191,7 @@ void colorplus_poll(void *p) for (c = 0; c < 8; c++) { buffer32->line[colorplus->cga.displine][(x << 4) + (c << 1) + 8] = - buffer32->line[colorplus->cga.displine][(x << 4) + (c << 1) + 1 + 8] = + buffer32->line[colorplus->cga.displine][(x << 4) + (c << 1) + 1 + 8] = cols16[(dat0 >> 14) | ((dat1 >> 14) << 2)]; dat0 <<= 2; dat1 <<= 2; @@ -252,7 +252,7 @@ void colorplus_poll(void *p) if (colorplus->cga.vc == colorplus->cga.crtc[7] && !colorplus->cga.sc) colorplus->cga.cgastat |= 8; colorplus->cga.displine++; - if (colorplus->cga.displine >= 360) + if (colorplus->cga.displine >= 360) colorplus->cga.displine = 0; } else @@ -265,10 +265,10 @@ void colorplus_poll(void *p) if (!colorplus->cga.vsynctime) colorplus->cga.cgastat &= ~8; } - if (colorplus->cga.sc == (colorplus->cga.crtc[11] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[11] & 31) >> 1))) - { - colorplus->cga.con = 0; - colorplus->cga.coff = 1; + if (colorplus->cga.sc == (colorplus->cga.crtc[11] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[11] & 31) >> 1))) + { + colorplus->cga.con = 0; + colorplus->cga.coff = 1; } if ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == (colorplus->cga.crtc[9] >> 1)) colorplus->cga.maback = colorplus->cga.ma; @@ -293,7 +293,7 @@ void colorplus_poll(void *p) colorplus->cga.vc++; colorplus->cga.vc &= 127; - if (colorplus->cga.vc == colorplus->cga.crtc[6]) + if (colorplus->cga.vc == colorplus->cga.crtc[6]) colorplus->cga.cgadispon = 0; if (oldvc == colorplus->cga.crtc[4]) @@ -324,10 +324,10 @@ void colorplus_poll(void *p) if (ysize < 32) ysize = 200; set_screen_size(xsize, (ysize << 1) + 16); } - - if (colorplus->cga.composite) + + if (colorplus->cga.composite) video_blit_memtoscreen(0, colorplus->cga.firstline - 4, xsize, (colorplus->cga.lastline - colorplus->cga.firstline) + 8); - else + else video_blit_memtoscreen_8(0, colorplus->cga.firstline - 4, xsize, (colorplus->cga.lastline - colorplus->cga.firstline) + 8); frames++; @@ -369,7 +369,7 @@ void colorplus_poll(void *p) } if (colorplus->cga.cgadispon) colorplus->cga.cgastat &= ~1; - if ((colorplus->cga.sc == (colorplus->cga.crtc[10] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[10] & 31) >> 1)))) + if ((colorplus->cga.sc == (colorplus->cga.crtc[10] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[10] & 31) >> 1)))) colorplus->cga.con = 1; if (colorplus->cga.cgadispon && (colorplus->cga.cgamode & 1)) { @@ -393,7 +393,7 @@ void *colorplus_standalone_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_CGA, &timing_colorplus); - /* Copied from the CGA init. Ideally this would be done by + /* Copied from the CGA init. Ideally this would be done by * calling a helper function rather than duplicating code */ display_type = device_get_config_int("display_type"); colorplus->cga.composite = (display_type != CGA_RGB); @@ -401,12 +401,12 @@ void *colorplus_standalone_init(const device_t *info) colorplus->cga.snow_enabled = device_get_config_int("snow_enabled"); colorplus->cga.vram = malloc(0x8000); - + cga_comp_init(colorplus->cga.revision); timer_add(&colorplus->cga.timer, colorplus_poll, colorplus, 1); mem_mapping_add(&colorplus->cga.mapping, 0xb8000, 0x08000, colorplus_read, NULL, NULL, colorplus_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, colorplus); io_sethandler(0x03d0, 0x0010, colorplus_in, NULL, NULL, colorplus_out, NULL, NULL, colorplus); - + lpt3_init(0x3BC); return colorplus; @@ -423,7 +423,7 @@ void colorplus_close(void *p) void colorplus_speed_changed(void *p) { colorplus_t *colorplus = (colorplus_t *)p; - + cga_recalctimings(&colorplus->cga); } diff --git a/src/video/vid_compaq_cga.c b/src/video/vid_compaq_cga.c index 821b4c4a9..59d6cad51 100644 --- a/src/video/vid_compaq_cga.c +++ b/src/video/vid_compaq_cga.c @@ -45,7 +45,7 @@ static uint32_t vflags; static uint8_t mdaattr[256][2][2]; -typedef struct compaq_cga_t +typedef struct compaq_cga_t { cga_t cga; } compaq_cga_t; @@ -115,7 +115,7 @@ compaq_cga_poll(void *p) self->cga.cgastat |= 1; self->cga.linepos = 1; oldsc = self->cga.sc; - if ((self->cga.crtc[8] & 3) == 3) + if ((self->cga.crtc[8] & 3) == 3) self->cga.sc = ((self->cga.sc << 1) + self->cga.oddeven) & 7; if (self->cga.cgadispon) { if (self->cga.displine < self->cga.firstline) { @@ -160,7 +160,7 @@ compaq_cga_poll(void *p) if (blink) cols[1] = cols[0]; } else { - if ((self->cga.cgablink & 8) && (attr & 0x80) && !self->cga.drawcursor) + if ((self->cga.cgablink & 8) && (attr & 0x80) && !self->cga.drawcursor) cols[1] = cols[0]; } } else { @@ -203,7 +203,7 @@ compaq_cga_poll(void *p) if (blink) cols[1] = cols[0]; } else { - if ((self->cga.cgablink & 8) && (attr & 0x80) && !self->cga.drawcursor) + if ((self->cga.cgablink & 8) && (attr & 0x80) && !self->cga.drawcursor) cols[1] = cols[0]; } } else { @@ -255,7 +255,7 @@ compaq_cga_poll(void *p) if (self->cga.vc == self->cga.crtc[7] && !self->cga.sc) self->cga.cgastat |= 8; self->cga.displine++; - if (self->cga.displine >= 500) + if (self->cga.displine >= 500) self->cga.displine = 0; } else { timer_advance_u64(&self->cga.timer, self->cga.dispontime); @@ -266,9 +266,9 @@ compaq_cga_poll(void *p) self->cga.cgastat &= ~8; } - if (self->cga.sc == (self->cga.crtc[11] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[11] & 31) >> 1))) { - self->cga.con = 0; - self->cga.coff = 1; + if (self->cga.sc == (self->cga.crtc[11] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[11] & 31) >> 1))) { + self->cga.con = 0; + self->cga.coff = 1; } if ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == (self->cga.crtc[9] >> 1)) self->cga.maback = self->cga.ma; @@ -289,7 +289,7 @@ compaq_cga_poll(void *p) self->cga.vc++; self->cga.vc &= 127; - if (self->cga.vc == self->cga.crtc[6]) + if (self->cga.vc == self->cga.crtc[6]) self->cga.cgadispon = 0; if (oldvc == self->cga.crtc[4]) { @@ -339,14 +339,14 @@ compaq_cga_poll(void *p) } if (enable_overscan) { - if (self->cga.composite) + if (self->cga.composite) video_blit_memtoscreen(0, self->cga.firstline - 8, xsize, (self->cga.lastline - self->cga.firstline) + 16); - else + else video_blit_memtoscreen_8(0, self->cga.firstline - 8, xsize, (self->cga.lastline - self->cga.firstline) + 16); } else { - if (self->cga.composite) + if (self->cga.composite) video_blit_memtoscreen(8, self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); - else + else video_blit_memtoscreen_8(8, self->cga.firstline, xsize, self->cga.lastline - self->cga.firstline); } } @@ -386,7 +386,7 @@ compaq_cga_poll(void *p) if (self->cga.cgadispon) self->cga.cgastat &= ~1; - if ((self->cga.sc == (self->cga.crtc[10] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[10] & 31) >> 1)))) + if ((self->cga.sc == (self->cga.crtc[10] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[10] & 31) >> 1)))) self->cga.con = 1; if (self->cga.cgadispon && (self->cga.cgamode & 1)) { diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 74892ae04..b6ed063e9 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -79,7 +79,7 @@ ega_out(uint16_t addr, uint8_t val, void *p) int c; uint8_t o, old; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(ega->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(ega->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -118,7 +118,7 @@ ega_out(uint16_t addr, uint8_t val, void *p) } else { o = ega->attrregs[ega->attraddr & 31]; ega->attrregs[ega->attraddr & 31] = val; - if (ega->attraddr < 16) + if (ega->attraddr < 16) fullchange = changeframecount; if (ega->attraddr == 0x10 || ega->attraddr == 0x14 || ega->attraddr < 0x10) { for (c = 0; c < 16; c++) { @@ -155,19 +155,19 @@ ega_out(uint16_t addr, uint8_t val, void *p) if ((o ^ val) & 0x80) ega_recalctimings(ega); break; - case 0x3c4: - ega->seqaddr = val; + case 0x3c4: + ega->seqaddr = val; break; case 0x3c5: o = ega->seqregs[ega->seqaddr & 0xf]; ega->seqregs[ega->seqaddr & 0xf] = val; - if (o != val && (ega->seqaddr & 0xf) == 1) + if (o != val && (ega->seqaddr & 0xf) == 1) ega_recalctimings(ega); switch (ega->seqaddr & 0xf) { case 1: - if (ega->scrblank && !(val & 0x20)) - fullchange = 3; - ega->scrblank = (ega->scrblank & ~0x20) | (val & 0x20); + if (ega->scrblank && !(val & 0x20)) + fullchange = 3; + ega->scrblank = (ega->scrblank & ~0x20) | (val & 0x20); break; case 2: ega->writemask = val & 0xf; @@ -181,21 +181,21 @@ ega_out(uint16_t addr, uint8_t val, void *p) break; } break; - case 0x3ce: - ega->gdcaddr = val; + case 0x3ce: + ega->gdcaddr = val; break; case 0x3cf: ega->gdcreg[ega->gdcaddr & 15] = val; switch (ega->gdcaddr & 15) { case 2: - ega->colourcompare = val; + ega->colourcompare = val; break; case 4: - ega->readplane = val & 3; + ega->readplane = val & 3; break; case 5: ega->writemode = val & 3; - ega->readmode = val & 8; + ega->readmode = val & 8; ega->chain2_read = val & 0x10; break; case 6: @@ -214,8 +214,8 @@ ega_out(uint16_t addr, uint8_t val, void *p) break; } break; - case 7: - ega->colournocare = val; + case 7: + ega->colournocare = val; break; } break; @@ -251,7 +251,7 @@ ega_in(uint16_t addr, void *p) ega_t *ega = (ega_t *)p; uint8_t ret = 0xff; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(ega->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(ega->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -271,18 +271,18 @@ ega_in(uint16_t addr, void *p) } break; - case 0x3c0: + case 0x3c0: if (ega_type) ret = ega->attraddr | ega->attr_palette_enable; break; - case 0x3c1: + case 0x3c1: if (ega_type) ret = ega->attrregs[ega->attraddr]; break; case 0x3c2: ret = (egaswitches & (8 >> egaswitchread)) ? 0x10 : 0x00; break; - case 0x3c4: + case 0x3c4: if (ega_type) ret = ega->seqaddr; break; @@ -294,11 +294,11 @@ ega_in(uint16_t addr, void *p) if (ega_type) ret = 2; break; - case 0x3cc: + case 0x3cc: if (ega_type) ret = ega->miscout; break; - case 0x3ce: + case 0x3ce: if (ega_type) ret = ega->gdcaddr; break; @@ -438,7 +438,7 @@ ega_recalctimings(ega_t *ega) overscan_x = (ega->seqregs[1] & 1) ? 16 : 18; - if (ega->seqregs[1] & 8) + if (ega->seqregs[1] & 8) overscan_x <<= 1; ega->y_add = (overscan_y >> 1) - (ega->crtc[8] & 0x1f); @@ -518,7 +518,7 @@ ega_poll(void *p) ega_render_overscan_right(ega); } - if (ega->lastline < ega->displine) + if (ega->lastline < ega->displine) ega->lastline = ega->displine; } @@ -528,18 +528,18 @@ ega_poll(void *p) if ((ega->stat & 8) && ((ega->displine & 15) == (ega->crtc[0x11] & 15)) && ega->vslines) ega->stat &= ~8; ega->vslines++; - if (ega->displine > 500) + if (ega->displine > 500) ega->displine = 0; } else { timer_advance_u64(&ega->timer, ega->dispontime); - if (ega->dispon) + if (ega->dispon) ega->stat &= ~1; ega->hdisp_on = 0; ega->linepos = 0; if ((ega->sc == (ega->crtc[11] & 31)) || (ega->sc == ega->rowcount)) - ega->con = 0; + ega->con = 0; if (ega->dispon) { if (ega->linedbl && !ega->linecountff) { ega->linecountff = 1; @@ -585,11 +585,11 @@ ega_poll(void *p) else ega->cursoron = ega->blink & (16 + (16 * blink_delay)); - if (!(ega->gdcreg[6] & 1) && !(ega->blink & 15)) + if (!(ega->gdcreg[6] & 1) && !(ega->blink & 15)) fullchange = 2; ega->blink = (ega->blink + 1) & 0x7f; - if (fullchange) + if (fullchange) fullchange--; } if (ega->vc == ega->vsyncstart) { @@ -660,7 +660,7 @@ ega_poll(void *p) ega->linecountff = 0; } - if (ega->sc == (ega->crtc[10] & 31)) + if (ega->sc == (ega->crtc[10] & 31)) ega->con = 1; } } @@ -770,7 +770,7 @@ ega_write(uint32_t addr, uint8_t val, void *p) if (addr >= ega->vram_limit) return; - if (!(ega->gdcreg[6] & 1)) + if (!(ega->gdcreg[6] & 1)) fullchange = 2; switch (ega->writemode) { @@ -781,7 +781,7 @@ ega_write(uint32_t addr, uint8_t val, void *p) if (writemask2 & 8) ega->vram[addr | 0x3] = ega->ld; break; case 0: - if (ega->gdcreg[3] & 7) + if (ega->gdcreg[3] & 7) val = ega_rotate[ega->gdcreg[3] & 7][val]; if ((ega->gdcreg[8] == 0xff) && !(ega->gdcreg[3] & 0x18) && !ega->gdcreg[1]) { @@ -996,7 +996,7 @@ ega_init(ega_t *ega, int monitor_type, int is_mono) pallook64[c] += makecol32(((c >> 5) & 1) * 0x55, ((c >> 4) & 1) * 0x55, ((c >> 3) & 1) * 0x55); pallook16[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); pallook16[c] += makecol32(((c >> 4) & 1) * 0x55, ((c >> 4) & 1) * 0x55, ((c >> 4) & 1) * 0x55); - if ((c & 0x17) == 6) + if ((c & 0x17) == 6) pallook16[c] = makecol32(0xaa, 0x55, 0); } diff --git a/src/video/vid_ega_render.c b/src/video/vid_ega_render.c index 9ea2a7bd3..290d4c8eb 100644 --- a/src/video/vid_ega_render.c +++ b/src/video/vid_ega_render.c @@ -106,7 +106,7 @@ ega_render_overscan_right(ega_t *ega) void ega_render_text_40(ega_t *ega) -{ +{ uint32_t *p; int x, xx; int drawcursor, xinc; @@ -117,7 +117,7 @@ ega_render_text_40(ega_t *ega) if ((ega->displine + ega->y_add) < 0) return; - if (ega->firstline_draw == 2000) + if (ega->firstline_draw == 2000) ega->firstline_draw = ega->displine; ega->lastline_draw = ega->displine; @@ -138,32 +138,32 @@ ega_render_text_40(ega_t *ega) else charaddr = ega->charseta + (chr * 128); if (drawcursor) { - bg = ega->pallook[ega->egapal[attr & 15]]; - fg = ega->pallook[ega->egapal[attr >> 4]]; + bg = ega->pallook[ega->egapal[attr & 15]]; + fg = ega->pallook[ega->egapal[attr >> 4]]; } else { fg = ega->pallook[ega->egapal[attr & 15]]; bg = ega->pallook[ega->egapal[attr >> 4]]; if (attr & 0x80 && ega->attrregs[0x10] & 8) { bg = ega->pallook[ega->egapal[(attr >> 4) & 7]]; - if (ega->blink & 16) + if (ega->blink & 16) fg = bg; } } dat = ega->vram[charaddr + (ega->sc << 2)]; if (ega->seqregs[1] & 1) { - for (xx = 0; xx < 16; xx += 2) + for (xx = 0; xx < 16; xx += 2) p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg; } else { for (xx = 0; xx < 16; xx += 2) p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg; - if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) + if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) p[16] = p[17] = bg; else p[16] = p[17] = (dat & 1) ? fg : bg; } - ega->ma += 4; + ega->ma += 4; p += xinc; } ega->ma &= ega->vrammask; @@ -184,7 +184,7 @@ ega_render_text_80(ega_t *ega) if ((ega->displine + ega->y_add) < 0) return; - if (ega->firstline_draw == 2000) + if (ega->firstline_draw == 2000) ega->firstline_draw = ega->displine; ega->lastline_draw = ega->displine; @@ -205,31 +205,31 @@ ega_render_text_80(ega_t *ega) else charaddr = ega->charseta + (chr * 128); if (drawcursor) { - bg = ega->pallook[ega->egapal[attr & 15]]; - fg = ega->pallook[ega->egapal[attr >> 4]]; + bg = ega->pallook[ega->egapal[attr & 15]]; + fg = ega->pallook[ega->egapal[attr >> 4]]; } else { fg = ega->pallook[ega->egapal[attr & 15]]; bg = ega->pallook[ega->egapal[attr >> 4]]; if (attr & 0x80 && ega->attrregs[0x10] & 8) { bg = ega->pallook[ega->egapal[(attr >> 4) & 7]]; - if (ega->blink & 16) + if (ega->blink & 16) fg = bg; } } dat = ega->vram[charaddr + (ega->sc << 2)]; - if (ega->seqregs[1] & 1) { - for (xx = 0; xx < 8; xx++) + if (ega->seqregs[1] & 1) { + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; } else { - for (xx = 0; xx < 8; xx++) + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; - if ((chr & ~0x1F) != 0xC0 || !(ega->attrregs[0x10] & 4)) + if ((chr & ~0x1F) != 0xC0 || !(ega->attrregs[0x10] & 4)) p[8] = bg; - else + else p[8] = (dat & 1) ? fg : bg; } - ega->ma += 4; + ega->ma += 4; p += xinc; } ega->ma &= ega->vrammask; diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index 529cca4bf..0254a8509 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -54,7 +54,7 @@ #include <86box/vid_svga_render.h> -#define BIOS_ROM_PATH "roms/video/et4000/ET4000.BIN" +#define BIOS_ROM_PATH "roms/video/et4000/ET4000.BIN" #define KOREAN_BIOS_ROM_PATH "roms/video/et4000/tgkorvga.bin" #define KOREAN_FONT_ROM_PATH "roms/video/et4000/tg_ksc5601.rom" #define KASAN_BIOS_ROM_PATH "roms/video/et4000/et4000_kasan16.bin" @@ -79,7 +79,7 @@ typedef struct { int get_korean_font_enabled; int get_korean_font_index; uint16_t get_korean_font_base; - + uint8_t kasan_cfg_index; uint8_t kasan_cfg_regs[16]; uint16_t kasan_access_addr; @@ -119,7 +119,7 @@ et4000_in(uint16_t addr, void *priv) if ((svga->vgapal[0].r + svga->vgapal[0].g + svga->vgapal[0].b) >= 0x4e) return 0; else - return 0x10; + return 0x10; } break; @@ -153,7 +153,7 @@ et4000k_in(uint16_t addr, void *priv) { et4000_t *dev = (et4000_t *)priv; uint8_t val = 0xff; - + switch (addr) { case 0x22cb: return dev->port_22cb_val; @@ -245,7 +245,7 @@ et4000_out(uint16_t addr, uint8_t val, void *priv) svga->read_bank = ((dev->banking >> 4) & 0x0f) * 0x10000; } else svga->write_bank = svga->read_bank = 0; - + old = svga->gdcreg[6]; svga_out(addr, val, svga); if ((old & 0xc) != 0 && (val & 0xc) == 0) @@ -253,7 +253,7 @@ et4000_out(uint16_t addr, uint8_t val, void *priv) /*override mask - ET4000 supports linear 128k at A0000*/ svga->banked_mask = 0x1ffff; } - return; + return; } break; @@ -291,7 +291,7 @@ et4000_out(uint16_t addr, uint8_t val, void *priv) svga_recalctimings(svga); } } - } + } break; } @@ -398,7 +398,7 @@ et4000_kasan_in(uint16_t addr, void *priv) } } else val = et4000_in(addr, priv); - + return val; } @@ -571,7 +571,7 @@ et4000_recalctimings(svga_t *svga) svga->clock = (cpuclock * (double)(1ull << 32)) / 36000000.0; break; } - + switch (svga->bpp) { case 15: case 16: @@ -674,7 +674,7 @@ et4000_init(const device_t *info) io_sethandler(0x03c0, 32, et4000_in,NULL,NULL, et4000_out,NULL,NULL, dev); dev->pos_regs[0] = 0xf2; /* ET4000 MCA board ID */ - dev->pos_regs[1] = 0x80; + dev->pos_regs[1] = 0x80; mca_add(et4000_mca_read, et4000_mca_write, et4000_mca_feedb, NULL, dev); break; @@ -729,14 +729,14 @@ et4000_init(const device_t *info) NULL, NULL); io_sethandler(0x03c0, 32, et4000_in,NULL,NULL, et4000_out,NULL,NULL, dev); - io_sethandler(0x0250, 8, + io_sethandler(0x0250, 8, et4000_kasan_in, NULL, NULL, et4000_kasan_out, NULL, NULL, dev); - io_sethandler(0x0258, 2, + io_sethandler(0x0258, 2, et4000_kasan_in, NULL, NULL, et4000_kasan_out, NULL, NULL, dev); loadfont(KASAN_FONT_ROM_PATH, 6); fn = KASAN_BIOS_ROM_PATH; break; - + } dev->svga.ramdac = device_add(&sc1502x_ramdac_device); diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index df2eab5a2..043d9a4ac 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -116,7 +116,7 @@ typedef struct et4000w32p_t uint32_t base[3]; uint8_t ctrl; } mmu; - + volatile int busy; } et4000w32p_t; @@ -172,7 +172,7 @@ et4000w32p_out(uint16_t addr, uint8_t val, void *p) uint8_t old; uint32_t add2addr = 0; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -314,12 +314,12 @@ et4000w32p_in(uint16_t addr, void *p) et4000w32p_t *et4000 = (et4000w32p_t *)p; svga_t *svga = &et4000->svga; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { case 0x3c5: - if ((svga->seqaddr & 0xf) == 7) + if ((svga->seqaddr & 0xf) == 7) return svga->seqregs[svga->seqaddr & 0xf] | 4; break; @@ -459,7 +459,7 @@ et4000w32p_recalctimings(svga_t *svga) } et4000->adjust_cursor = 0; - + switch (svga->bpp) { case 15: case 16: svga->hdisp >>= 1; @@ -493,7 +493,7 @@ et4000w32p_recalctimings(svga_t *svga) svga->ma_latch--; switch (svga->gdcreg[5] & 0x60) { - case 0x00: + case 0x00: if (svga->seqregs[1] & 8) /* Low res (320) */ svga->render = svga_render_4bpp_lowres; else @@ -663,7 +663,7 @@ et4000w32p_accel_write_fifo(et4000w32p_t *et4000, uint32_t addr, uint8_t val) et4000->acl.queued.dest_off = (et4000->acl.queued.dest_off & 0x00ff) | ((val & 0x0f) << 8); break; case 0x8e: - if (et4000->type >= ET4000W32P_REVC) + if (et4000->type >= ET4000W32P_REVC) et4000->acl.queued.pixel_depth = val & 0x30; else et4000->acl.queued.vbus = val & 0x03; @@ -735,7 +735,7 @@ et4000w32p_accel_write_fifo(et4000w32p_t *et4000, uint32_t addr, uint8_t val) } } break; - case 0xa4: + case 0xa4: et4000->acl.queued.mix_addr = (et4000->acl.queued.mix_addr & 0xFFFFFF00) | val; break; case 0xa5: @@ -816,7 +816,7 @@ et4000w32p_accel_write_mmu(et4000w32p_t *et4000, uint32_t addr, uint8_t val, uin et4000->acl.cpu_input_num = 0; } - + if ((et4000->acl.internal.ctrl_routing & 7) == 4) /*CPU data is X Count*/ et4000w32_blit(val | (et4000->acl.queued.count_x << 8), 0, 0, 0xffffffff, et4000); if ((et4000->acl.internal.ctrl_routing & 7) == 5) /*CPU data is Y Count*/ @@ -850,7 +850,7 @@ et4000w32p_mmu_write(uint32_t addr, uint8_t val, void *p) et4000w32p_accel_write_fifo(et4000, addr & 0x7fff, val); } else { switch (addr & 0xff) { - case 0x00: + case 0x00: et4000->mmu.base[0] = (et4000->mmu.base[0] & 0x3fff00) | val; break; case 0x01: @@ -898,7 +898,7 @@ et4000w32p_mmu_read(uint32_t addr, void *p) et4000w32p_t *et4000 = (et4000w32p_t *)p; svga_t *svga = &et4000->svga; uint8_t temp; - + switch (addr & 0x6000) { case 0x0000: /* MMU 0 */ case 0x2000: /* MMU 1 */ @@ -920,7 +920,7 @@ et4000w32p_mmu_read(uint32_t addr, void *p) if ((addr & 0x1fff) + et4000->mmu.base[et4000->bank] >= svga->vram_max) return 0xff; - + return svga->vram[(addr & 0x1fff) + et4000->mmu.base[et4000->bank]]; case 0x6000: @@ -988,8 +988,8 @@ et4000w32p_mmu_read(uint32_t addr, void *p) return et4000->acl.internal.dest_off & 0xff; case 0x8d: return et4000->acl.internal.dest_off >> 8; - case 0x8e: - if (et4000->type >= ET4000W32P_REVC) + case 0x8e: + if (et4000->type >= ET4000W32P_REVC) return et4000->acl.internal.pixel_depth; else return et4000->acl.internal.vbus; @@ -1023,7 +1023,7 @@ et4000w32_blit_start(et4000w32p_t *et4000) { et4000->acl.x_count = et4000->acl.internal.count_x; et4000->acl.y_count = et4000->acl.internal.count_y; - + et4000->acl.pattern_addr = et4000->acl.internal.pattern_addr; et4000->acl.source_addr = et4000->acl.internal.source_addr; et4000->acl.dest_addr = et4000->acl.internal.dest_addr; @@ -1085,9 +1085,9 @@ et4000w32p_blit_start(et4000w32p_t *et4000) et4000->acl.internal.pos_x = et4000->acl.internal.pos_y = 0; et4000->acl.pattern_x = et4000->acl.source_x = et4000->acl.pattern_y = et4000->acl.source_y = 0; et4000->acl.status |= ACL_XYST; - + et4000w32_log("ACL status XYST set\n"); - if ((!(et4000->acl.internal.ctrl_routing & 7) || (et4000->acl.internal.ctrl_routing & 4)) && !(et4000->acl.internal.ctrl_routing & 0x40)) + if ((!(et4000->acl.internal.ctrl_routing & 7) || (et4000->acl.internal.ctrl_routing & 4)) && !(et4000->acl.internal.ctrl_routing & 0x40)) et4000->acl.status |= ACL_SSO; if (et4000w32_wrap_x[et4000->acl.internal.pattern_wrap & 7]) { @@ -1501,7 +1501,7 @@ et4000w32_blit(int count, int cpu_input, uint32_t src_dat, uint32_t mix_dat, et4 if (et4000->acl.source_x >= (et4000w32_wrap_x[et4000->acl.internal.source_wrap & 7] + 1)) et4000->acl.source_x -= (et4000w32_wrap_x[et4000->acl.internal.source_wrap & 7] + 1); } - + et4000->acl.x_count--; if (et4000->acl.x_count == 0xffff) { et4000->acl.x_count = et4000->acl.internal.count_x; @@ -1590,14 +1590,14 @@ et4000w32p_blit(int count, uint32_t mix, uint32_t sdat, int cpu_input, et4000w32 et4000w32_log("%06X %02X ", et4000->acl.mix_addr, svga->vram[(et4000->acl.mix_addr >> 3) & et4000->vram_mask]); } else { mixdat = mix & 1; - mix >>= 1; + mix >>= 1; mix |= 0x80000000; } et4000->acl.mix_addr++; rop = mixdat ? et4000->acl.internal.rop_fg : et4000->acl.internal.rop_bg; - + ROPMIX(rop, dest, pattern, source, out); - + et4000w32_log("%06X = %02X\n", et4000->acl.dest_addr & et4000->vram_mask, out); if (!(et4000->acl.internal.ctrl_routing & 0x40)) { svga->vram[et4000->acl.dest_addr & et4000->vram_mask] = out; @@ -1613,9 +1613,9 @@ et4000w32p_blit(int count, uint32_t mix, uint32_t sdat, int cpu_input, et4000w32 if (et4000->acl.internal.xy_dir & 1) et4000w32_decx(1, et4000); else et4000w32_incx(1, et4000); } else { - if (et4000->acl.internal.xy_dir & 1) + if (et4000->acl.internal.xy_dir & 1) et4000w32_incx((et4000->acl.internal.pixel_depth >> 4) & 3, et4000); - else + else et4000w32_decx((et4000->acl.internal.pixel_depth >> 4) & 3, et4000); et4000->acl.pix_pos = 0; @@ -1678,15 +1678,15 @@ et4000w32p_blit(int count, uint32_t mix, uint32_t sdat, int cpu_input, et4000w32 sdat >>= 8; } else source = svga->vram[(et4000->acl.source_addr + et4000->acl.source_x) & et4000->vram_mask]; - + dest = svga->vram[et4000->acl.dest_addr & et4000->vram_mask]; out = 0; - + if ((et4000->acl.internal.ctrl_routing & 0xa) == 8) { mixdat = svga->vram[(et4000->acl.mix_addr >> 3) & et4000->vram_mask] & (1 << (et4000->acl.mix_addr & 7)); } else { mixdat = mix & 1; - mix >>= 1; + mix >>= 1; mix |= 0x80000000; } @@ -1694,7 +1694,7 @@ et4000w32p_blit(int count, uint32_t mix, uint32_t sdat, int cpu_input, et4000w32 ROPMIX(rop, dest, pattern, source, out); - if (!(et4000->acl.internal.ctrl_routing & 0x40)) { + if (!(et4000->acl.internal.ctrl_routing & 0x40)) { svga->vram[et4000->acl.dest_addr & et4000->vram_mask] = out; svga->changedvram[(et4000->acl.dest_addr & et4000->vram_mask) >> 12] = changeframecount; } else { @@ -1706,7 +1706,7 @@ et4000w32p_blit(int count, uint32_t mix, uint32_t sdat, int cpu_input, et4000w32 et4000w32_decx(1, et4000); else et4000w32_incx(1, et4000); - + et4000->acl.x_count--; if (et4000->acl.x_count == 0xffff) { if (et4000->acl.internal.xy_dir & 2) { @@ -1734,7 +1734,7 @@ et4000w32p_blit(int count, uint32_t mix, uint32_t sdat, int cpu_input, et4000w32 return; if (et4000->acl.internal.ctrl_routing & 0x40) { - if (et4000->acl.cpu_dat_pos & 3) + if (et4000->acl.cpu_dat_pos & 3) et4000->acl.cpu_dat_pos += 4 - (et4000->acl.cpu_dat_pos & 3); return; } @@ -1756,7 +1756,7 @@ et4000w32p_hwcursor_draw(svga_t *svga, int displine) int minus_width = 0; uint8_t dat; offset = svga->hwcursor_latch.xoff; - + if (et4000->type == ET4000W32) { switch (svga->bpp) { case 8: @@ -1902,12 +1902,12 @@ et4000w32p_pci_write(int func, int addr, uint8_t val, void *p) et4000w32p_recalcmapping(et4000); break; - case 0x13: - et4000->linearbase &= 0x00c00000; + case 0x13: + et4000->linearbase &= 0x00c00000; et4000->linearbase |= (et4000->pci_regs[0x13] << 24); svga->crtc[0x30] &= 3; svga->crtc[0x30] |= ((et4000->linearbase & 0x3f000000) >> 22); - et4000w32p_recalcmapping(et4000); + et4000w32p_recalcmapping(et4000); break; case 0x30: case 0x31: case 0x32: case 0x33: @@ -1940,7 +1940,7 @@ et4000w32p_init(const device_t *info) et4000->pci = (info->flags & DEVICE_PCI) ? 0x80 : 0x00; et4000->vlb = (info->flags & DEVICE_VLB) ? 0x40 : 0x00; - + /*The ET4000/W32i ISA BIOS seems to not support 2MB of VRAM*/ if ((info->local == ET4000W32) || ((info->local == ET4000W32I) && !(et4000->vlb))) vram_size = 1; @@ -1972,14 +1972,14 @@ et4000w32p_init(const device_t *info) case ET4000W32: /* ET4000/W32 */ et4000->rev = 0; - + rom_init(&et4000->bios_rom, BIOS_ROM_PATH_W32, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); et4000->svga.ramdac = device_add(&tseng_ics5301_ramdac_device); et4000->svga.clock_gen = et4000->svga.ramdac; et4000->svga.getclock = sdac_getclock; - break; + break; case ET4000W32I: /* ET4000/W32i rev B */ @@ -1987,7 +1987,7 @@ et4000w32p_init(const device_t *info) if (et4000->vlb) { rom_init(&et4000->bios_rom, BIOS_ROM_PATH_W32I_VLB, 0xc0000, 0x8000, 0x7fff, 0, - MEM_MAPPING_EXTERNAL); + MEM_MAPPING_EXTERNAL); } else { rom_init(&et4000->bios_rom, BIOS_ROM_PATH_W32I_ISA, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); diff --git a/src/video/vid_genius.c b/src/video/vid_genius.c index 820331d8b..847730ac8 100644 --- a/src/video/vid_genius.c +++ b/src/video/vid_genius.c @@ -46,9 +46,9 @@ static video_timings_t timing_genius = {VIDEO_ISA, 8, 16, 32, 8, 16, 32}; /* I'm at something of a disadvantage writing this emulation: I don't have an - * MDSI Genius card, nor do I have the BIOS extension (VHRBIOS.SYS) that came + * MDSI Genius card, nor do I have the BIOS extension (VHRBIOS.SYS) that came * with it. What I do have are the GEM and Windows 1.04 drivers, plus a driver - * for a later MCA version of the card. The latter can be found at + * for a later MCA version of the card. The latter can be found at * and is necessary if you * want the Windows driver to work. * @@ -57,9 +57,9 @@ static video_timings_t timing_genius = {VIDEO_ISA, 8, 16, 32, 8, 16, 32}; * The GEM driver SDGEN9.VGA * The Windows 1.04 driver GENIUS.DRV * - * As far as I can see, the card uses a fixed resolution of 728x1008 pixels. + * As far as I can see, the card uses a fixed resolution of 728x1008 pixels. * It has the following modes of operation: - * + * * > MDA-compatible: 80x25 text, each character 9x15 pixels. * > CGA-compatible: 640x200 mono graphics * > Dual: MDA text in the top half, CGA graphics in the bottom @@ -67,16 +67,16 @@ static video_timings_t timing_genius = {VIDEO_ISA, 8, 16, 32, 8, 16, 32}; * > Native graphics: 728x1008 mono graphics. * * Under the covers, this seems to translate to: - * > Text framebuffer. At B000:0000, 16k. Displayed if enable bit is set + * > Text framebuffer. At B000:0000, 16k. Displayed if enable bit is set * in the MDA control register. * > Graphics framebuffer. In native modes goes from A000:0000 to A000:FFFF - * and B800:0000 to B800:FFFF. In CGA-compatible + * and B800:0000 to B800:FFFF. In CGA-compatible * mode only the section at B800:0000 to B800:7FFF * is visible. Displayed if enable bit is set in the * CGA control register. - * + * * Two card-specific registers control text and graphics display: - * + * * 03B0: Control register. * Bit 0: Map all graphics framebuffer into memory. * Bit 2: Unknown. Set by GMC /M; cleared by mode set or GMC /T. @@ -88,14 +88,14 @@ static video_timings_t timing_genius = {VIDEO_ISA, 8, 16, 32, 8, 16, 32}; * Bit 4: Set to double character cell height (scanlines are doubled) * Bit 7: Unknown, seems to be set for all modes except 80x66 * - * Not having the card also means I don't have its font. According to the - * card brochure the font is an 8x12 bitmap in a 9x15 character cell. I - * therefore generated it by taking the MDA font, increasing graphics to + * Not having the card also means I don't have its font. According to the + * card brochure the font is an 8x12 bitmap in a 9x15 character cell. I + * therefore generated it by taking the MDA font, increasing graphics to * 16 pixels in height and reducing the height of characters so they fit * in an 8x12 cell if necessary. */ - + typedef struct genius_t { @@ -105,14 +105,14 @@ typedef struct genius_t int mda_crtcreg; /* Current CRTC register */ uint8_t cga_crtc[32]; /* The 'CRTC' as the host PC sees it */ int cga_crtcreg; /* Current CRTC register */ - uint8_t genius_control; /* Native control register - * I think bit 0 enables the full - * framebuffer. + uint8_t genius_control; /* Native control register + * I think bit 0 enables the full + * framebuffer. */ - uint8_t genius_charh; /* Native character height register: - * 00h => chars are 15 pixels high + uint8_t genius_charh; /* Native character height register: + * 00h => chars are 15 pixels high * 81h => chars are 14 pixels high - * 83h => chars are 12 pixels high + * 83h => chars are 12 pixels high * 90h => chars are 30 pixels high [15 x 2] * 93h => chars are 24 pixels high [12 x 2] */ @@ -130,7 +130,7 @@ typedef struct genius_t uint64_t dispontime, dispofftime; pc_timer_t timer; - + int linepos, displine; int vc; int dispon, blink; @@ -179,7 +179,7 @@ genius_out(uint16_t addr, uint8_t val, void *p) return; /* Emulated MDA control register */ - case 0x3b8: + case 0x3b8: genius->mda_ctrl = val; return; @@ -219,10 +219,10 @@ genius_in(uint16_t addr, void *p) case 0x3b1: case 0x3b3: case 0x3b5: case 0x3b7: ret = genius->mda_crtc[genius->mda_crtcreg]; break; - case 0x3b8: + case 0x3b8: ret = genius->mda_ctrl; break; - case 0x3ba: + case 0x3ba: ret = genius->mda_stat; break; case 0x3d0: case 0x3d2: case 0x3d4: case 0x3d6: @@ -388,15 +388,15 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80) #if 0 if (genius->genius_charh & 0x10) { - row = ((dl >> 1) / charh); - sc = ((dl >> 1) % charh); + row = ((dl >> 1) / charh); + sc = ((dl >> 1) % charh); } else { - row = (dl / charh); - sc = (dl % charh); + row = (dl / charh); + sc = (dl % charh); } #else - row = (dl / charh); - sc = (dl % charh); + row = (dl / charh); + sc = (dl % charh); #endif } else { if ((genius->displine < 512) || (genius->displine >= 912)) @@ -411,8 +411,8 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80) cw = 8; charh = crtc[9] + 1; - row = ((dl >> 1) / charh); - sc = ((dl >> 1) % charh); + row = ((dl >> 1) / charh); + sc = ((dl >> 1) % charh); } ma = (crtc[13] | (crtc[12] << 8)) & 0x3fff; @@ -507,7 +507,7 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80) buffer32->line[dl][((x * cw) << 1) + 17] = col; } } - } else { /* Otherwise fill with background */ + } else { /* Otherwise fill with background */ col = mdaattr[attr][blink][0]; if (genius->genius_control & 0x20) col ^= 15; @@ -733,7 +733,7 @@ void genius_pal[3] = 15 + 16; /* F */ /* MDA attributes */ - /* I don't know if the Genius's MDA emulation actually does + /* I don't know if the Genius's MDA emulation actually does * emulate bright / non-bright. For the time being pretend it does. */ for (c = 0; c < 256; c++) { mdaattr[c][0][0] = mdaattr[c][1][0] = mdaattr[c][1][1] = genius_pal[0]; diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 293732908..ce9cf0349 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -54,7 +54,7 @@ recalc_timings(hercules_t *dev) } -static uint8_t crtcmask[32] = +static uint8_t crtcmask[32] = { 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -303,7 +303,7 @@ hercules_poll(void *priv) dev->linepos = 1; oldsc = dev->sc; - if ((dev->crtc[8] & 3) == 3) + if ((dev->crtc[8] & 3) == 3) dev->sc = (dev->sc << 1) & 7; if (dev->dispon) { @@ -374,7 +374,7 @@ hercules_poll(void *priv) if (dev->vc == dev->crtc[7] && !dev->sc) dev->stat |= 8; dev->displine++; - if (dev->displine >= 500) + if (dev->displine >= 500) dev->displine = 0; } else { timer_advance_u64(&dev->timer, dev->dispontime); @@ -391,8 +391,8 @@ hercules_poll(void *priv) if (dev->sc == (dev->crtc[11] & 31) || ((dev->crtc[8] & 3)==3 && dev->sc == ((dev->crtc[11] & 31) >> 1))) { - dev->con = 0; - dev->coff = 1; + dev->con = 0; + dev->coff = 1; } if (dev->vadj) { @@ -412,7 +412,7 @@ hercules_poll(void *priv) dev->vc++; dev->vc &= 127; - if (dev->vc == dev->crtc[6]) + if (dev->vc == dev->crtc[6]) dev->dispon = 0; if (oldvc == dev->crtc[4]) { @@ -604,7 +604,7 @@ static void speed_changed(void *priv) { hercules_t *dev = (hercules_t *)priv; - + recalc_timings(dev); } diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index 81f436441..8c95c6734 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -217,7 +217,7 @@ draw_char_rom(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) blk = 0; if (dev->ctrl & HERCULESPLUS_CTRL_BLINK) { - if (attr & 0x80) + if (attr & 0x80) blk = (dev->blink & 16); attr &= 0x7f; } @@ -228,18 +228,18 @@ draw_char_rom(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) if ((attr & 0x77) == 0x70) { /* Invert */ ifg = 0; ibg = 7; - } - if (attr & 8) + } + if (attr & 8) ifg |= 8; /* High intensity FG */ - if (attr & 0x80) + if (attr & 0x80) ibg |= 8; /* High intensity BG */ if ((attr & 0x77) == 0) /* Blank */ ifg = ibg; ull = ((attr & 0x07) == 1) ? 13 : 0xffff; - if (dev->crtc[HERCULESPLUS_CRTC_XMODE] & HERCULESPLUS_XMODE_90COL) + if (dev->crtc[HERCULESPLUS_CRTC_XMODE] & HERCULESPLUS_XMODE_90COL) elg = 0; - else + else elg = ((chr >= 0xc0) && (chr <= 0xdf)); fnt = &(fontdatm[chr][dev->sc]); @@ -250,8 +250,8 @@ draw_char_rom(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) val = 0x1ff; /* Underscore, draw all foreground */ } else { val = fnt[0] << 1; - - if (elg) + + if (elg) val |= (val >> 1) & 1; } @@ -273,7 +273,7 @@ draw_char_ram4(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) blk = 0; if (blink) { - if (attr & 0x80) + if (attr & 0x80) blk = (dev->blink & 16); attr &= 0x7f; } @@ -284,30 +284,30 @@ draw_char_ram4(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) if ((attr & 0x77) == 0x70) { /* Invert */ ifg = 0; ibg = 7; - } - if (attr & 8) + } + if (attr & 8) ifg |= 8; /* High intensity FG */ - if (attr & 0x80) + if (attr & 0x80) ibg |= 8; /* High intensity BG */ if ((attr & 0x77) == 0) /* Blank */ ifg = ibg; ull = ((attr & 0x07) == 1) ? 13 : 0xffff; - if (dev->crtc[HERCULESPLUS_CRTC_XMODE] & HERCULESPLUS_XMODE_90COL) + if (dev->crtc[HERCULESPLUS_CRTC_XMODE] & HERCULESPLUS_XMODE_90COL) elg = 0; - else + else elg = ((chr >= 0xc0) && (chr <= 0xdf)); fnt = dev->vram + 0x4000 + 16 * chr + dev->sc; if (blk) { /* Blinking, draw all background */ - val = 0x000; + val = 0x000; } else if (dev->sc == ull) { /* Underscore, draw all foreground */ val = 0x1ff; } else { val = fnt[0x00000] << 1; - - if (elg) + + if (elg) val |= (val >> 1) & 1; } @@ -340,7 +340,7 @@ draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) blk = 0; if (blink) { - if (attr & 0x40) + if (attr & 0x40) blk = (dev->blink & 16); attr &= 0x7f; } @@ -358,7 +358,7 @@ draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) ul = (attr & 0x10) ? 1 : 0; } - if (ul) { + if (ul) { ull = dev->crtc[HERCULESPLUS_CRTC_UNDER] & 0x0F; ulc = (dev->crtc[HERCULESPLUS_CRTC_UNDER] >> 4) & 0x0F; if (ulc == 0) ulc = 7; @@ -366,7 +366,7 @@ draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) ull = 0xFFFF; } - if (ol) { + if (ol) { oll = dev->crtc[HERCULESPLUS_CRTC_OVER] & 0x0F; olc = (dev->crtc[HERCULESPLUS_CRTC_OVER] >> 4) & 0x0F; if (olc == 0) olc = 7; @@ -374,23 +374,23 @@ draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) oll = 0xFFFF; } - if (dev->crtc[HERCULESPLUS_CRTC_XMODE] & HERCULESPLUS_XMODE_90COL) + if (dev->crtc[HERCULESPLUS_CRTC_XMODE] & HERCULESPLUS_XMODE_90COL) elg = 0; - else + else elg = ((chr >= 0xc0) && (chr <= 0xdf)); fnt = dev->vram + 0x4000 + 16 * chr + 4096 * font + dev->sc; if (blk) { /* Blinking, draw all background */ - val = 0x000; + val = 0x000; } else if (dev->sc == ull) { /* Underscore, draw all foreground */ val = 0x1ff; } else { val = fnt[0x00000] << 1; - - if (elg) + + if (elg) val |= (val >> 1) & 1; - if (bld) + if (bld) val |= (val >> 1); } @@ -403,7 +403,7 @@ draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) cfg = ulc ^ ibg; /* Underline */ else cfg |= ibg; - + buffer32->line[dev->displine][(x * cw) + i] = dev->cols[attr][blink][cfg]; val = val << 1; } @@ -498,7 +498,7 @@ herculesplus_poll(void *priv) dev->stat |= 1; dev->linepos = 1; oldsc = dev->sc; - if ((dev->crtc[8] & 3) == 3) + if ((dev->crtc[8] & 3) == 3) dev->sc = (dev->sc << 1) & 7; if (dev->dispon) { if (dev->displine < dev->firstline) { @@ -515,11 +515,11 @@ herculesplus_poll(void *priv) if (dev->vc == dev->crtc[7] && !dev->sc) dev->stat |= 8; dev->displine++; - if (dev->displine >= 500) + if (dev->displine >= 500) dev->displine = 0; } else { timer_advance_u64(&dev->timer, dev->dispontime); - if (dev->dispon) + if (dev->dispon) dev->stat &= ~1; dev->linepos = 0; if (dev->vsynctime) { @@ -528,9 +528,9 @@ herculesplus_poll(void *priv) dev->stat &= ~8; } - if (dev->sc == (dev->crtc[11] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[11] & 31) >> 1))) { - dev->con = 0; - dev->coff = 1; + if (dev->sc == (dev->crtc[11] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[11] & 31) >> 1))) { + dev->con = 0; + dev->coff = 1; } if (dev->vadj) { dev->sc++; @@ -548,7 +548,7 @@ herculesplus_poll(void *priv) oldvc = dev->vc; dev->vc++; dev->vc &= 127; - if (dev->vc == dev->crtc[6]) + if (dev->vc == dev->crtc[6]) dev->dispon = 0; if (oldvc == dev->crtc[4]) { dev->vc = 0; @@ -565,7 +565,7 @@ herculesplus_poll(void *priv) dev->displine = 0; dev->vsynctime = 16; if (dev->crtc[7]) { - if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) + if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) x = dev->crtc[1] << 4; else x = dev->crtc[1] * 9; diff --git a/src/video/vid_ht216.c b/src/video/vid_ht216.c index 2b179ba7e..c65cde149 100644 --- a/src/video/vid_ht216.c +++ b/src/video/vid_ht216.c @@ -49,18 +49,18 @@ typedef struct ht216_t int ext_reg_enable; int isabus; int mca; - + uint8_t read_bank_reg[2], write_bank_reg[2]; uint16_t id, misc; uint32_t read_banks[2], write_banks[2]; - + uint8_t bg_latch[8]; uint8_t fg_latch[4]; uint8_t bg_plane_sel, fg_plane_sel; - + uint8_t ht_regs[256]; uint8_t extensions, reg_3cb; - + uint8_t pos_regs[8]; } ht216_t; @@ -140,7 +140,7 @@ static void ht216_recalc_bank_regs(ht216_t *ht216, int mode) { svga_t *svga = &ht216->svga; - + if (mode) { ht216->read_bank_reg[0] = ht216->ht_regs[0xe8]; ht216->write_bank_reg[0] = ht216->ht_regs[0xe8]; @@ -329,7 +329,7 @@ ht216_out(uint16_t addr, uint8_t val, void *p) ht216_recalc_bank_regs(ht216, 1); ht216_remap(ht216); break; - + case 0xec: ht216->fg_latch[0] = val; break; @@ -346,13 +346,13 @@ ht216_out(uint16_t addr, uint8_t val, void *p) case 0xf0: ht216->fg_latch[ht216->fg_plane_sel] = val; ht216->fg_plane_sel = (ht216->fg_plane_sel + 1) & 3; - break; - + break; + case 0xf1: ht216->bg_plane_sel = val & 3; ht216->fg_plane_sel = (val & 0x30) >> 4; break; - + case 0xf2: svga->latch.b[ht216->bg_plane_sel] = val; ht216->bg_plane_sel = (ht216->bg_plane_sel + 1) & 3; @@ -366,14 +366,14 @@ ht216_out(uint16_t addr, uint8_t val, void *p) svga->fullchange = changeframecount; svga_recalctimings(svga); break; - + case 0xf9: /*Bit 16 of the display memory address, only active when in chain4 mode and 256 color mode.*/ - ht216_log("HT216 reg 0xf9 write = %02x, mode = 0, chain4 = %x\n", val & HT_REG_F9_XPSEL, svga->chain4); + ht216_log("HT216 reg 0xf9 write = %02x, mode = 0, chain4 = %x\n", val & HT_REG_F9_XPSEL, svga->chain4); ht216_recalc_bank_regs(ht216, 0); ht216_remap(ht216); break; - + case 0xfc: ht216_log("HT216 reg 0xfc write = %02x, mode = 0, chain4 = %x, bit 7 = %02x, packedchain = %02x\n", val, svga->chain4, val & 0x80, val & 0x20); svga->packed_chain4 = !!(val & 0x20); @@ -521,7 +521,7 @@ ht216_in(uint16_t addr, void *p) ret = ht216->fg_latch[ht216->fg_plane_sel]; ht216->fg_plane_sel = 0; break; - + case 0xf2: ret = svga->latch.b[ht216->bg_plane_sel]; ht216->bg_plane_sel = 0; @@ -607,8 +607,8 @@ ht216_recalctimings(svga_t *svga) { ht216_t *ht216 = (ht216_t *)svga->p; int high_res_256 = 0; - - switch ((((((svga->miscout >> 2) & 3) || ((ht216->ht_regs[0xa4] >> 2) & 3)) | + + switch ((((((svga->miscout >> 2) & 3) || ((ht216->ht_regs[0xa4] >> 2) & 3)) | ((ht216->ht_regs[0xa4] >> 2) & 4)) || ((ht216->ht_regs[0xf8] >> 5) & 0x0f)) | ((ht216->ht_regs[0xf8] << 1) & 8)) { case 0: @@ -638,7 +638,7 @@ ht216_recalctimings(svga_t *svga) high_res_256 = (svga->htotal * 8) > (svga->vtotal * 2); ht216->adjust_cursor = 0; - + if (!svga->scrblank && svga->attr_palette_enable) { if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /*Text mode*/ if (svga->seqregs[1] & 8) /*40 column*/ { @@ -691,7 +691,7 @@ ht216_recalctimings(svga_t *svga) } } } - + svga->ma_latch |= ((ht216->ht_regs[0xf6] & 0x30) << 14); if (svga->crtc[0x17] == 0xeb) /*Looks like 1024x768 mono mode expects 512K of video memory*/ @@ -842,7 +842,7 @@ ht216_dm_write(ht216_t *ht216, uint32_t addr, uint8_t cpu_dat, uint8_t cpu_dat_u } else { if (writemask2 & (1 << i)) svga->vram[addr | i] = fg_data[i]; - } + } } return; } else { @@ -873,7 +873,7 @@ ht216_dm_write(ht216_t *ht216, uint32_t addr, uint8_t cpu_dat, uint8_t cpu_dat_u for (i = 0; i < count; i++) { if (ht216->ht_regs[0xcd] & HT_REG_CD_P8PCEXP) { if (writemask2 & (0x80 >> i)) - svga->vram[addr | i] = (vall.b[i] & svga->gdcreg[8]) | (svga->latch.b[i] & ~svga->gdcreg[8]); + svga->vram[addr | i] = (vall.b[i] & svga->gdcreg[8]) | (svga->latch.b[i] & ~svga->gdcreg[8]); } else { if (writemask2 & (1 << i)) svga->vram[addr | i] = (vall.b[i] & svga->gdcreg[8]) | (svga->latch.b[i] & ~svga->gdcreg[8]); @@ -998,7 +998,7 @@ ht216_dm_extalu_write(ht216_t *ht216, uint32_t addr, uint8_t cpu_dat, uint8_t bi static void ht216_dm_masked_write(ht216_t *ht216, uint32_t addr, uint8_t val, uint8_t bit_mask) -{ +{ svga_t *svga = &ht216->svga; int writemask2 = svga->writemask; uint8_t count = 4, i; @@ -1108,7 +1108,7 @@ ht216_write_common(ht216_t *ht216, uint32_t addr, uint8_t val) bit_mask = ht216->ht_regs[0xf5]; break; } - + if (ht216->ht_regs[0xcd] & HT_REG_CD_FP8PCEXP) { /*1->8 bit expansion*/ addr = (addr << 3) & 0xfffff; for (i = 0; i < 8; i++) @@ -1149,7 +1149,7 @@ ht216_write(uint32_t addr, uint8_t val, void *p) addr = (addr & 0xfffeffff) | (prev_addr & 0x10000); if (!ht216->ht_regs[0xcd] && !ht216->ht_regs[0xfe] && !ht216->ht_regs[0xf3] && svga->crtc[0x17] != 0xeb) { - svga_write_linear(addr, val, svga); + svga_write_linear(addr, val, svga); } else ht216_write_common(ht216, addr, val); } @@ -1321,11 +1321,11 @@ ht216_read_common(ht216_t *ht216, uint32_t addr) for (i = 0; i < 8; i++) ht216->bg_latch[i] = svga->vram[latch_addr | i]; } - + or = addr & 4; for (i = 0; i < 4; i++) svga->latch.b[i] = ht216->bg_latch[i | or]; - + if (svga->readmode) { temp = 0xff; @@ -1356,9 +1356,9 @@ ht216_read(uint32_t addr, void *p) addr &= svga->banked_mask; addr = (addr & 0x7fff) + ht216->read_banks[(addr >> 15) & 1]; - + if (svga->crtc[0x17] == 0xeb && !(svga->gdcreg[6] & 0xc) && prev_addr >= 0xb0000) - addr += 0x10000; + addr += 0x10000; else if (svga->chain4 && ((ht216->ht_regs[0xfc] & 0x06) == 0x06)) addr = (addr & 0xfffeffff) | (prev_addr & 0x10000); @@ -1423,7 +1423,7 @@ void video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_v7vga_mca); else video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_v7vga_isa); - + svga_init(info, svga, ht216, mem_size, ht216_recalctimings, ht216_in, ht216_out, @@ -1473,7 +1473,7 @@ void else if ((info->local == 0x7152) && (info->flags & DEVICE_MCA)) { ht216->pos_regs[0] = 0xb7; ht216->pos_regs[1] = 0x80; - mca_add(radius_mca_read, radius_mca_write, radius_mca_feedb, NULL, ht216); + mca_add(radius_mca_read, radius_mca_write, radius_mca_feedb, NULL, ht216); } rom_init(&ht216->bios_rom, BIOS_RADIUS_SVGA_MULTIVIEW_PATH, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); break; @@ -1504,8 +1504,8 @@ void io_sethandler(0x46e8, 0x0001, ht216_in, NULL, NULL, ht216_out, NULL, NULL, ht216); svga->bpp = 8; - svga->miscout = 1; - + svga->miscout = 1; + if (ht216->id == 0x7861) ht216->ht_regs[0xb4] = 0x08; /*32-bit DRAM bus*/ diff --git a/src/video/vid_ibm_rgb528_ramdac.c b/src/video/vid_ibm_rgb528_ramdac.c index 8b2e11621..8dae60f23 100644 --- a/src/video/vid_ibm_rgb528_ramdac.c +++ b/src/video/vid_ibm_rgb528_ramdac.c @@ -95,8 +95,8 @@ ibm_rgb528_render_4bpp(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -178,8 +178,8 @@ ibm_rgb528_render_8bpp(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -262,8 +262,8 @@ ibm_rgb528_render_15_16bpp(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -382,8 +382,8 @@ ibm_rgb528_render_24bpp(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -476,8 +476,8 @@ ibm_rgb528_render_32bpp(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; diff --git a/src/video/vid_icd2061.c b/src/video/vid_icd2061.c index eb7b4e61e..e22265b03 100644 --- a/src/video/vid_icd2061.c +++ b/src/video/vid_icd2061.c @@ -98,7 +98,7 @@ icd2061_write(void *p, int val) if (icd2061->bit_count == 26) { icd2061_log("26 bits received, data = %08X\n", icd2061->data); - + a = ((icd2061->data >> 22) & 0x07); /* A */ icd2061_log("A = %01X\n", a); diff --git a/src/video/vid_ics2595.c b/src/video/vid_ics2595.c index dde720d6f..ef5de2aac 100644 --- a/src/video/vid_ics2595.c +++ b/src/video/vid_ics2595.c @@ -74,7 +74,7 @@ ics2595_write(void *p, int strobe, int dat) ics2595->clocks[l] = (14318181.8 * ((double)n / 46.0)) / (double)d; ics2595->state = ICS2595_IDLE; } - break; + break; } } diff --git a/src/video/vid_im1024.c b/src/video/vid_im1024.c index 4e6453b31..a680d6657 100644 --- a/src/video/vid_im1024.c +++ b/src/video/vid_im1024.c @@ -22,12 +22,12 @@ * As well as the usual PGC ring buffer at 0xC6000, the IM1024 * appears to have an alternate method of passing commands. This * is enabled by setting 0xC6330 to 1, and then: - * + * * CX = count to write * SI -> bytes to write - * + * * Set pending bytes to 0 - * Read [C6331]. This gives number of bytes that can be written: + * Read [C6331]. This gives number of bytes that can be written: * 0xFF => 0, 0xFE => 1, 0xFD => 2 etc. * Write that number of bytes to C6000. * If there are more to come, go back to reading [C6331]. @@ -129,7 +129,7 @@ fifo_write(im1024_t *dev, uint8_t val) dev->fifo_len *= 2; } - /* Append to the queue. */ + /* Append to the queue. */ dev->fifo[dev->fifo_wrptr++] = val; /* Wrap if end of buffer reached. */ @@ -171,7 +171,7 @@ input_byte(pgc_t *pgc, uint8_t *result) while (!pgc->stopped && (dev->fifo_wrptr == dev->fifo_rdptr) && (pgc->mapram[0x300] == pgc->mapram[0x301])) { pgc->waiting_input_fifo = 1; - pgc_sleep(pgc); + pgc_sleep(pgc); } if (pgc->stopped) @@ -205,13 +205,13 @@ input_byte(pgc_t *pgc, uint8_t *result) pgc->vp_x2 = pgc->maxw - 1; \ pgc->vp_y2 = pgc->maxh - 1; \ -/* And to restore clip state */ +/* And to restore clip state */ #define POPCLIP \ pgc->vp_x1 = vp_x1; \ pgc->vp_y1 = vp_y1; \ pgc->vp_x2 = vp_x2; \ pgc->vp_y2 = vp_y2; \ - } + } /* Override memory read to return FIFO space. */ @@ -296,8 +296,8 @@ hndl_iprec(pgc_t *pgc) /* - * Set drawing mode. - * + * Set drawing mode. + * * 0 => Draw * 1 => Invert * 2 => XOR (IM-1024) @@ -539,8 +539,8 @@ hndl_poly(pgc_t *pgc) } if (count + realcount >= as) { - nx = (int32_t *)realloc(x, 2 * as * sizeof(int32_t)); - ny = (int32_t *)realloc(y, 2 * as * sizeof(int32_t)); + nx = (int32_t *)realloc(x, 2 * as * sizeof(int32_t)); + ny = (int32_t *)realloc(y, 2 * as * sizeof(int32_t)); if (!x || !y) { #ifdef ENABLE_IM1024_LOG im1024_log("IM1024: poly: realloc failed\n"); @@ -569,7 +569,7 @@ hndl_poly(pgc_t *pgc) } /* Skip degenerate line segments. */ - if (realcount > 0 && + if (realcount > 0 && (xw << 16) == x[realcount - 1] && (yw << 16) == y[realcount - 1]) continue; @@ -631,7 +631,7 @@ parse_poly(pgc_t *pgc, pgc_cl_t *cl, int c) im1024_log("IM1024: parse_poly: count=%02x\n", count); if (! pgc_cl_append(cl, count)) { pgc_error(pgc, PGC_ERROR_OVERFLOW); - return 0; + return 0; } im1024_log("IM1024: parse_poly: parse %i words\n", 2 * count); @@ -669,10 +669,10 @@ hndl_rect(pgc_t *pgc) } else { /* Outline: 4 lines. */ p = pgc->line_pattern; - p = pgc_draw_line_r(pgc, x0, y0, x1, y0, p); - p = pgc_draw_line_r(pgc, x1, y0, x1, y1, p); - p = pgc_draw_line_r(pgc, x1, y1, x0, y1, p); - p = pgc_draw_line_r(pgc, x0, y1, x0, y0, p); + p = pgc_draw_line_r(pgc, x0, y0, x1, y0, p); + p = pgc_draw_line_r(pgc, x1, y0, x1, y1, p); + p = pgc_draw_line_r(pgc, x1, y1, x0, y1, p); + p = pgc_draw_line_r(pgc, x0, y1, x0, y0, p); } } @@ -746,7 +746,7 @@ hndl_twrite(pgc_t *pgc) for (n = 0; n < count; n++) { wb = (dev->fontx[buf[n]] + 7) / 8; - im1024_log("IM1024: ch=0x%02x w=%i h=%i wb=%i\n", + im1024_log("IM1024: ch=0x%02x w=%i h=%i wb=%i\n", buf[n], dev->fontx[buf[n]], dev->fonty[buf[n]], wb); for (y = 0; y < dev->fonty[buf[n]]; y++) { @@ -851,7 +851,7 @@ hndl_imagew(pgc_t *pgc) if (v1 & 0x80) { /* Literal run. */ v1 -= 0x7f; - while (col1 <= col2 && v1 != 0) { + while (col1 <= col2 && v1 != 0) { if (! pgc_param_byte(pgc, &v2)) return; pgc_write_pixel(pgc, col1, row1, v2); col1++; @@ -862,12 +862,12 @@ hndl_imagew(pgc_t *pgc) if (! pgc_param_byte(pgc, &v2)) return; v1++; - while (col1 <= col2 && v1 != 0) { + while (col1 <= col2 && v1 != 0) { pgc_write_pixel(pgc, col1, row1, v2); col1++; v1--; } - } + } } } @@ -890,7 +890,7 @@ hndl_dot(pgc_t *pgc) int16_t x = pgc->x >> 16, y = pgc->y >> 16; - pgc_sto_raster(pgc, &x, &y); + pgc_sto_raster(pgc, &x, &y); im1024_log("IM1024: DOT @ %i,%i ink=%i mode=%i\n", x, y, pgc->color, pgc->draw_mode); @@ -900,9 +900,9 @@ hndl_dot(pgc_t *pgc) /* - * This command (which I have called IMAGEX, since I don't know its real + * This command (which I have called IMAGEX, since I don't know its real * name) is a screen-to-memory blit. It reads a rectangle of bytes, rather - * than the single row read by IMAGER, and does not attempt to compress + * than the single row read by IMAGER, and does not attempt to compress * the result. */ static void diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index d1de4a8c3..b135caa1c 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -225,7 +225,7 @@ incolor_out(uint16_t port, uint8_t val, void *priv) if (dev->crtcreg == INCOLOR_CRTC_PALETTE) { dev->palette[dev->palette_idx % 16] = val; ++dev->palette_idx; - } + } old = dev->crtc[dev->crtcreg]; dev->crtc[dev->crtcreg] = val; @@ -320,7 +320,7 @@ incolor_write(uint32_t addr, uint8_t val, void *priv) * 0: 1 => foreground, 0 => background * 1: 1 => foreground, 0 => source latch * 2: 1 => source latch, 0 => background - * 3: 1 => source latch, 0 => ~source latch + * 3: 1 => source latch, 0 => ~source latch */ pmask = 1; for (plane = 0; plane < 4; pmask <<= 1, wmask >>= 1, addr += 0x10000, plane++) { @@ -354,7 +354,7 @@ incolor_write(uint32_t addr, uint8_t val, void *priv) /* w is nonzero to write a 1, zero to write a 0 */ if (w) dev->vram[addr] |= vmask; - else dev->vram[addr] &= ~vmask; + else dev->vram[addr] &= ~vmask; } } } @@ -394,15 +394,15 @@ incolor_read(uint32_t addr, void *priv) bg = (dev->crtc[INCOLOR_CRTC_RWCOL] >> 4) & 0x0F; for (plane = 0, pmask = 1; plane < 4; plane++, pmask <<= 1) { if (dc & pmask) { - fg |= (bg & pmask); + fg |= (bg & pmask); } else if (dev->latch[plane] & mask) { fg |= pmask; } - } + } if (bg == fg) value |= mask; - } + } - if (dev->crtc[INCOLOR_CRTC_RWCTRL] & INCOLOR_RWCTRL_POLARITY) + if (dev->crtc[INCOLOR_CRTC_RWCTRL] & INCOLOR_RWCTRL_POLARITY) value = ~value; return value; @@ -422,16 +422,16 @@ draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) int cw = INCOLOR_CW; blk = 0; - if (dev->ctrl & INCOLOR_CTRL_BLINK) + if (dev->ctrl & INCOLOR_CTRL_BLINK) { - if (attr & 0x80) + if (attr & 0x80) { blk = (dev->blink & 16); } attr &= 0x7f; } - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) { /* MDA-compatible attributes */ ibg = 0; @@ -440,12 +440,12 @@ draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { ifg = 0; ibg = 7; - } - if (attr & 8) + } + if (attr & 8) { ifg |= 8; /* High intensity FG */ } - if (attr & 0x80) + if (attr & 0x80) { ibg |= 8; /* High intensity BG */ } @@ -454,31 +454,31 @@ draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) ifg = ibg; } ull = ((attr & 0x07) == 1) ? 13 : 0xffff; - } - else + } + else { /* CGA-compatible attributes */ ull = 0xffff; ifg = attr & 0x0F; ibg = (attr >> 4) & 0x0F; } - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) { fg = dev->rgb[dev->palette[ifg]]; bg = dev->rgb[dev->palette[ibg]]; - } - else + } + else { fg = dev->rgb[defpal[ifg]]; bg = dev->rgb[defpal[ibg]]; } /* ELG set to stretch 8px character to 9px */ - if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) + if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) { elg = 0; - } - else + } + else { elg = ((chr >= 0xc0) && (chr <= 0xdf)); } @@ -489,20 +489,20 @@ draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { val = 0x000; /* Blinking, draw all background */ } - else if (dev->sc == ull) + else if (dev->sc == ull) { val = 0x1ff; /* Underscore, draw all foreground */ } - else + else { val = fnt[0] << 1; - - if (elg) + + if (elg) { val |= (val >> 1) & 1; } } - for (i = 0; i < cw; i++) + for (i = 0; i < cw; i++) { buffer32->line[dev->displine][x * cw + i] = (val & 0x100) ? fg : bg; val = val << 1; @@ -528,7 +528,7 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) blk = 0; if (blink) { - if (attr & 0x80) + if (attr & 0x80) { blk = (dev->blink & 16); } @@ -544,12 +544,12 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { ifg = 0; ibg = 7; - } - if (attr & 8) + } + if (attr & 8) { ifg |= 8; /* High intensity FG */ } - if (attr & 0x80) + if (attr & 0x80) { ibg |= 8; /* High intensity BG */ } @@ -558,19 +558,19 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) ifg = ibg; } ull = ((attr & 0x07) == 1) ? 13 : 0xffff; - } - else + } + else { /* CGA-compatible attributes */ ull = 0xffff; ifg = attr & 0x0F; ibg = (attr >> 4) & 0x0F; } - if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) + if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) { elg = 0; - } - else + } + else { elg = ((chr >= 0xc0) && (chr <= 0xdf)); } @@ -579,21 +579,21 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) if (blk) { /* Blinking, draw all background */ - val[0] = val[1] = val[2] = val[3] = 0x000; + val[0] = val[1] = val[2] = val[3] = 0x000; } - else if (dev->sc == ull) + else if (dev->sc == ull) { /* Underscore, draw all foreground */ val[0] = val[1] = val[2] = val[3] = 0x1ff; } - else + else { val[0] = fnt[0x00000] << 1; val[1] = fnt[0x10000] << 1; val[2] = fnt[0x20000] << 1; val[3] = fnt[0x30000] << 1; - - if (elg) + + if (elg) { val[0] |= (val[0] >> 1) & 1; val[1] |= (val[1] >> 1) & 1; @@ -601,7 +601,7 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) val[3] |= (val[3] >> 1) & 1; } } - for (i = 0; i < cw; i++) + for (i = 0; i < cw; i++) { /* Generate pixel colour */ cfg = 0; @@ -616,12 +616,12 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) if (palette) { fg = dev->rgb[dev->palette[cfg]]; - } - else + } + else { fg = dev->rgb[defpal[cfg]]; } - + buffer32->line[dev->displine][x * cw + i] = fg; val[0] = val[0] << 1; val[1] = val[1] << 1; @@ -652,31 +652,31 @@ draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) blk = 0; if (blink && altattr) { - if (attr & 0x40) + if (attr & 0x40) { blk = (dev->blink & 16); } attr &= 0x7f; } - if (altattr) + if (altattr) { /* MDA-compatible attributes */ - if (blink) + if (blink) { ibg = (attr & 0x80) ? 8 : 0; bld = 0; ol = (attr & 0x20) ? 1 : 0; ul = (attr & 0x10) ? 1 : 0; - } - else + } + else { bld = (attr & 0x80) ? 1 : 0; ibg = (attr & 0x40) ? 0x0F : 0; ol = (attr & 0x20) ? 1 : 0; ul = (attr & 0x10) ? 1 : 0; } - } - else + } + else { /* CGA-compatible attributes */ ibg = 0; @@ -685,32 +685,32 @@ draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) ul = 0; bld = 0; } - if (ul) - { + if (ul) + { ull = dev->crtc[INCOLOR_CRTC_UNDER] & 0x0F; ulc = (dev->crtc[INCOLOR_CRTC_UNDER] >> 4) & 0x0F; if (ulc == 0) ulc = 7; - } - else + } + else { ull = 0xFFFF; } - if (ol) - { + if (ol) + { oll = dev->crtc[INCOLOR_CRTC_OVER] & 0x0F; olc = (dev->crtc[INCOLOR_CRTC_OVER] >> 4) & 0x0F; if (olc == 0) olc = 7; - } - else + } + else { oll = 0xFFFF; } - if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) + if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) { elg = 0; - } - else + } + else { elg = ((chr >= 0xc0) && (chr <= 0xdf)); } @@ -719,28 +719,28 @@ draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) if (blk) { /* Blinking, draw all background */ - val[0] = val[1] = val[2] = val[3] = 0x000; + val[0] = val[1] = val[2] = val[3] = 0x000; } - else if (dev->sc == ull) + else if (dev->sc == ull) { /* Underscore, draw all foreground */ val[0] = val[1] = val[2] = val[3] = 0x1ff; } - else + else { val[0] = fnt[0x00000] << 1; val[1] = fnt[0x10000] << 1; val[2] = fnt[0x20000] << 1; val[3] = fnt[0x30000] << 1; - - if (elg) + + if (elg) { val[0] |= (val[0] >> 1) & 1; val[1] |= (val[1] >> 1) & 1; val[2] |= (val[2] >> 1) & 1; val[3] |= (val[3] >> 1) & 1; } - if (bld) + if (bld) { val[0] |= (val[0] >> 1); val[1] |= (val[1] >> 1); @@ -748,7 +748,7 @@ draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) val[3] |= (val[3] >> 1); } } - for (i = 0; i < cw; i++) + for (i = 0; i < cw; i++) { /* Generate pixel colour */ cfg = 0; @@ -776,12 +776,12 @@ draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) if (palette) { fg = dev->rgb[dev->palette[cfg]]; - } - else + } + else { fg = dev->rgb[defpal[cfg]]; } - + buffer32->line[dev->displine][x * cw + i] = fg; val[0] = val[0] << 1; val[1] = val[1] << 1; @@ -829,17 +829,17 @@ text_line(incolor_t *dev, uint16_t ca) uint8_t ink = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_CURSOR; if (ink == 0) ink = (attr & 0x08) | 7; - /* In MDA-compatible mode, cursor brightness comes from + /* In MDA-compatible mode, cursor brightness comes from * background */ - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) { ink = (attr & 0x08) | (ink & 7); } - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) { col = dev->rgb[dev->palette[ink]]; - } - else + } + else { col = dev->rgb[defpal[ink]]; } @@ -871,8 +871,8 @@ graphics_line(incolor_t *dev) for (plane = 0; plane < 4; plane++, mask = mask >> 1) { if (dev->ctrl & 8) { - if (mask & 1) - val[plane] = (dev->vram[((dev->ma << 1) & 0x1fff) + ca + 0x10000 * plane] << 8) | + if (mask & 1) + val[plane] = (dev->vram[((dev->ma << 1) & 0x1fff) + ca + 0x10000 * plane] << 8) | dev->vram[((dev->ma << 1) & 0x1fff) + ca + 0x10000 * plane + 1]; else val[plane] = 0; } else @@ -914,7 +914,7 @@ incolor_poll(void *priv) dev->stat |= 1; dev->linepos = 1; oldsc = dev->sc; - if ((dev->crtc[8] & 3) == 3) + if ((dev->crtc[8] & 3) == 3) dev->sc = (dev->sc << 1) & 7; if (dev->dispon) { @@ -932,11 +932,11 @@ incolor_poll(void *priv) if (dev->vc == dev->crtc[7] && !dev->sc) dev->stat |= 8; dev->displine++; - if (dev->displine >= 500) + if (dev->displine >= 500) dev->displine = 0; } else { timer_advance_u64(&dev->timer, dev->dispontime); - if (dev->dispon) + if (dev->dispon) dev->stat &= ~1; dev->linepos = 0; if (dev->vsynctime) { @@ -945,9 +945,9 @@ incolor_poll(void *priv) dev->stat &= ~8; } - if (dev->sc == (dev->crtc[11] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[11] & 31) >> 1))) { - dev->con = 0; - dev->coff = 1; + if (dev->sc == (dev->crtc[11] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[11] & 31) >> 1))) { + dev->con = 0; + dev->coff = 1; } if (dev->vadj) { @@ -966,7 +966,7 @@ incolor_poll(void *priv) oldvc = dev->vc; dev->vc++; dev->vc &= 127; - if (dev->vc == dev->crtc[6]) + if (dev->vc == dev->crtc[6]) dev->dispon = 0; if (oldvc == dev->crtc[4]) { dev->vc = 0; @@ -982,7 +982,7 @@ incolor_poll(void *priv) dev->displine = 0; dev->vsynctime = 16; if (dev->crtc[7]) { - if ((dev->ctrl & INCOLOR_CTRL_GRAPH) && (dev->ctrl2 & INCOLOR_CTRL2_GRAPH)) + if ((dev->ctrl & INCOLOR_CTRL_GRAPH) && (dev->ctrl2 & INCOLOR_CTRL2_GRAPH)) x = dev->crtc[1] << 4; else x = dev->crtc[1] * 9; @@ -1055,7 +1055,7 @@ incolor_init(const device_t *info) dev->crtc[INCOLOR_CRTC_RWCTRL] = INCOLOR_RWCTRL_POLARITY; dev->crtc[INCOLOR_CRTC_RWCOL ] = 0x0F; /* White on black */ dev->crtc[INCOLOR_CRTC_EXCEPT] = INCOLOR_EXCEPT_ALTATTR; - for (c = 0; c < 16; c++) + for (c = 0; c < 16; c++) dev->palette[c] = defpal[c]; dev->palette_idx = 0; @@ -1087,7 +1087,7 @@ static void speed_changed(void *priv) { incolor_t *dev = (incolor_t *)priv; - + recalc_timings(dev); } diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index ba95c9b81..fed92c1f5 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -116,7 +116,7 @@ void mda_poll(void *p) mda->stat |= 1; mda->linepos = 1; oldsc = mda->sc; - if ((mda->crtc[8] & 3) == 3) + if ((mda->crtc[8] & 3) == 3) mda->sc = (mda->sc << 1) & 7; if (mda->dispon) { @@ -158,7 +158,7 @@ void mda_poll(void *p) mda->stat |= 8; } mda->displine++; - if (mda->displine >= 500) + if (mda->displine >= 500) mda->displine=0; } else @@ -174,10 +174,10 @@ void mda_poll(void *p) mda->stat&=~8; } } - if (mda->sc == (mda->crtc[11] & 31) || ((mda->crtc[8] & 3) == 3 && mda->sc == ((mda->crtc[11] & 31) >> 1))) - { - mda->con = 0; - mda->coff = 1; + if (mda->sc == (mda->crtc[11] & 31) || ((mda->crtc[8] & 3) == 3 && mda->sc == ((mda->crtc[11] & 31) >> 1))) + { + mda->con = 0; + mda->coff = 1; } if (mda->vadj) { @@ -199,7 +199,7 @@ void mda_poll(void *p) oldvc = mda->vc; mda->vc++; mda->vc &= 127; - if (mda->vc == mda->crtc[6]) + if (mda->vc == mda->crtc[6]) mda->dispon=0; if (oldvc == mda->crtc[4]) { @@ -284,7 +284,7 @@ void mda_init(mda_t *mda) { cga_palette = 0; } - cgapal_rebuild(); + cgapal_rebuild(); timer_add(&mda->timer, mda_poll, mda, 1); } @@ -323,7 +323,7 @@ void mda_close(void *p) void mda_speed_changed(void *p) { mda_t *mda = (mda_t *)p; - + mda_recalctimings(mda); } diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index fe93f0d98..f81baf596 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -410,7 +410,7 @@ typedef struct mystique_t svga_t svga; rom_t bios_rom; - + int type; mem_mapping_t lfb_mapping, ctrl_mapping, @@ -435,7 +435,7 @@ typedef struct mystique_t pixel_count, trap_count; volatile int busy, blitter_submit_refcount, - blitter_submit_dma_refcount, blitter_complete_refcount, + blitter_submit_dma_refcount, blitter_complete_refcount, endprdmasts_pending, softrap_pending, fifo_read_idx, fifo_write_idx; @@ -663,7 +663,7 @@ mystique_out(uint16_t addr, uint8_t val, void *p) svga_t *svga = &mystique->svga; uint8_t old; - if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) + if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -699,10 +699,10 @@ mystique_out(uint16_t addr, uint8_t val, void *p) if ((svga->crtcreg & 0x3f) < 0xE || (svga->crtcreg & 0x3f) > 0x10) { if (((svga->crtcreg & 0x3f) == 0xc) || ((svga->crtcreg & 0x3f) == 0xd)) { svga->fullchange = 3; - svga->ma_latch = ((svga->crtc[0xc] << 8) | svga->crtc[0xd]) + ((svga->crtc[8] & 0x60) >> 5); + svga->ma_latch = ((svga->crtc[0xc] << 8) | svga->crtc[0xd]) + ((svga->crtc[8] & 0x60) >> 5); } else { svga->fullchange = changeframecount; - svga_recalctimings(svga); + svga_recalctimings(svga); } } if (svga->crtcreg == 0x11) { @@ -757,7 +757,7 @@ mystique_in(uint16_t addr, void *p) svga_t *svga = &mystique->svga; uint8_t temp = 0xff; - if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) + if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -773,8 +773,8 @@ mystique_in(uint16_t addr, void *p) temp = tvp3026_ramdac_in(addr, 0, 0, svga->ramdac, svga); else temp = svga_in(addr, svga); - break; - + break; + case 0x3D4: temp = svga->crtcreg; break; @@ -815,7 +815,7 @@ mystique_line_compare(svga_t *svga) return 0; } -static void +static void mystique_vsync_callback(svga_t *svga) { mystique_t *mystique = (mystique_t *)svga->p; @@ -823,17 +823,17 @@ mystique_vsync_callback(svga_t *svga) if (svga->crtc[0x11] & 0x10) { mystique->status |= STATUS_VSYNCPEN; mystique_update_irqs(mystique); - } + } } static float mystique_getclock(int clock, void *p) { mystique_t *mystique = (mystique_t *)p; - + if (clock == 0) return 25175000.0; - if (clock == 1) return 28322000.0; - + if (clock == 1) return 28322000.0; + int m = mystique->xpixpll[2].m; int n = mystique->xpixpll[2].n; int pl = mystique->xpixpll[2].p; @@ -948,7 +948,7 @@ mystique_recalctimings(svga_t *svga) } svga->line_compare = mystique_line_compare; } else { - svga->packed_chain4 = 0; + svga->packed_chain4 = 0; svga->line_compare = NULL; if (mystique->type >= MGA_1064SG) svga->bpp = 8; @@ -1134,7 +1134,7 @@ mystique_read_xreg(mystique_t *mystique, int reg) if (mystique->svga.vgapal[0].r < 0x80) ret |= 4; break; - + case XREG_XCRCREML: /*CRC not implemented*/ ret = 0; break; @@ -1334,10 +1334,10 @@ mystique_ctrl_read_b(uint32_t addr, void *p) int rs2 = 0, rs3 = 0; if ((mystique->type == MGA_2064W) && (addr & 0x3e00) == 0x3c00) - { + { /*RAMDAC*/ addr_0x0f = addr & 0x0f; - + if ((addr_0x0f & 3) == 0) addr_0x03 = 0x3c8; else if ((addr_0x0f & 3) == 1) @@ -1346,7 +1346,7 @@ mystique_ctrl_read_b(uint32_t addr, void *p) addr_0x03 = 0x3c6; else if ((addr_0x0f & 3) == 3) addr_0x03 = 0x3c7; - + if ((addr_0x0f >= 0x04) && (addr_0x0f <= 0x07)) { rs2 = 1; rs3 = 0; @@ -1357,7 +1357,7 @@ mystique_ctrl_read_b(uint32_t addr, void *p) rs2 = 1; rs3 = 1; } - + ret = tvp3026_ramdac_in(addr_0x03, rs2, rs3, svga->ramdac, svga); } else switch (addr & 0x3fff) { case REG_FIFOSTATUS: @@ -1499,12 +1499,12 @@ mystique_ctrl_read_b(uint32_t addr, void *p) case 0x1e50: case 0x1e51: case 0x1e52: case 0x1e53: case REG_ICLEAR: case REG_ICLEAR+1: case REG_ICLEAR+2: case REG_ICLEAR+3: case 0x2c30: case 0x2c31: case 0x2c32: case 0x2c33: - case 0x3e08: + case 0x3e08: break; case 0x3c08: case 0x3c09: case 0x3c0b: break; - + default: if ((addr & 0x3fff) >= 0x2c00 && (addr & 0x3fff) < 0x2c40) @@ -1759,10 +1759,10 @@ mystique_ctrl_write_b(uint32_t addr, uint8_t val, void *p) int rs2 = 0, rs3 = 0; if ((mystique->type == MGA_2064W) && (addr & 0x3e00) == 0x3c00) - { + { /*RAMDAC*/ addr_0x0f = addr & 0x0f; - + if ((addr & 3) == 0) addr_0x03 = 0x3c8; else if ((addr & 3) == 1) @@ -1771,7 +1771,7 @@ mystique_ctrl_write_b(uint32_t addr, uint8_t val, void *p) addr_0x03 = 0x3c6; else if ((addr & 3) == 3) addr_0x03 = 0x3c7; - + if ((addr_0x0f >= 0x04) && (addr_0x0f <= 0x07)) { rs2 = 1; rs3 = 0; @@ -1782,7 +1782,7 @@ mystique_ctrl_write_b(uint32_t addr, uint8_t val, void *p) rs2 = 1; rs3 = 1; } - + tvp3026_ramdac_out(addr_0x03, rs2, rs3, val, svga->ramdac, svga); return; } @@ -2657,19 +2657,19 @@ bitop(uint32_t src, uint32_t dst, uint32_t dwgctrl) case BOP(0x0): return 0; case BOP(0x1): return ~(dst | src); case BOP(0x2): return dst & ~src; - case BOP(0x3): return ~src; + case BOP(0x3): return ~src; case BOP(0x4): return ~dst & src; - case BOP(0x5): return ~dst; - case BOP(0x6): return dst ^ src; + case BOP(0x5): return ~dst; + case BOP(0x6): return dst ^ src; case BOP(0x7): return ~(dst & src); - case BOP(0x8): return dst & src; + case BOP(0x8): return dst & src; case BOP(0x9): return ~(dst ^ src); - case BOP(0xa): return dst; + case BOP(0xa): return dst; case BOP(0xb): return dst | ~src; - case BOP(0xc): return src; + case BOP(0xc): return src; case BOP(0xd): return ~dst | src; - case BOP(0xe): return dst | src; - case BOP(0xf): return ~0; + case BOP(0xe): return dst | src; + case BOP(0xf): return ~0; } return 0; @@ -2782,7 +2782,7 @@ blit_idump_idump(mystique_t *mystique) while ((count < 32) && !mystique->dwgreg.idump_end_of_line) { val64 |= (uint64_t)((*(uint32_t *)&svga->vram[(mystique->dwgreg.src_addr * 3) & mystique->vram_mask]) & 0xffffff) << count; - + if (mystique->dwgreg.src_addr == mystique->dwgreg.ar[0]) { mystique->dwgreg.ar[0] += mystique->dwgreg.ar[5]; mystique->dwgreg.ar[3] += mystique->dwgreg.ar[5]; @@ -3122,7 +3122,7 @@ blit_iload_iload(mystique_t *mystique, uint32_t data, int size) case DWGCTRL_BLTMOD_BMONOWF: data = (data >> 24) | ((data & 0x00ff0000) >> 8) | ((data & 0x0000ff00) << 8) | (data << 24); data_mask = (1 << 31); - case DWGCTRL_BLTMOD_BMONOLEF: + case DWGCTRL_BLTMOD_BMONOLEF: while (size) { if (mystique->dwgreg.xdst >= mystique->dwgreg.cxleft && mystique->dwgreg.xdst <= mystique->dwgreg.cxright && mystique->dwgreg.ydst_lin >= mystique->dwgreg.ytop && mystique->dwgreg.ydst_lin <= mystique->dwgreg.ybot && @@ -3411,7 +3411,7 @@ blit_iload_iload_scale(mystique_t *mystique, uint32_t data, int size) data >>= 16; size -= 16; } - + mystique->dwgreg.xdst = (mystique->dwgreg.xdst + 1) & 0xffff; if (mystique->dwgreg.xdst == mystique->dwgreg.fxright) { @@ -3447,7 +3447,7 @@ blit_iload_iload_scale(mystique_t *mystique, uint32_t data, int size) data64 >>= 32; size -= 32; } - + mystique->dwgreg.xdst = (mystique->dwgreg.xdst + 1) & 0xffff; if (mystique->dwgreg.xdst == mystique->dwgreg.fxright) { @@ -4551,7 +4551,7 @@ blit_bitblt(mystique_t *mystique) dst = svga->vram[(mystique->dwgreg.ydst_lin + x) & mystique->vram_mask]; dst = bitop(src, dst, mystique->dwgreg.dwgctrl_running); - + svga->vram[(mystique->dwgreg.ydst_lin + x) & mystique->vram_mask] = dst; svga->changedvram[((mystique->dwgreg.ydst_lin + x) & mystique->vram_mask) >> 12] = changeframecount; break; @@ -4715,7 +4715,7 @@ blit_bitblt(mystique_t *mystique) static void blit_iload(mystique_t *mystique) -{ +{ switch (mystique->dwgreg.dwgctrl_running & DWGCTRL_ATYPE_MASK) { case DWGCTRL_ATYPE_RPL: case DWGCTRL_ATYPE_RSTR: @@ -4876,10 +4876,10 @@ mystique_start_blit(mystique_t *mystique) case DWGCTRL_OPCODE_AUTOLINE_OPEN: blit_autoline(mystique, 0); break; - + case DWGCTRL_OPCODE_LINE_CLOSE: blit_line(mystique, 1); - break; + break; case DWGCTRL_OPCODE_AUTOLINE_CLOSE: blit_autoline(mystique, 1); @@ -5161,7 +5161,7 @@ mystique_init(const device_t *info) memset(mystique, 0, sizeof(mystique_t)); mystique->type = info->local; - + if (mystique->type == MGA_2064W) romfn = ROM_MILLENNIUM; else if (mystique->type == MGA_1064SG) diff --git a/src/video/vid_nga.c b/src/video/vid_nga.c index 9037d550a..927a63c12 100644 --- a/src/video/vid_nga.c +++ b/src/video/vid_nga.c @@ -6,7 +6,7 @@ * * This file is part of the 86Box distribution. * - * Emulation of the NCR NGA (K511, K201) video cards. + * Emulation of the NCR NGA (K511, K201) video cards. * * * @@ -109,9 +109,9 @@ nga_write(uint32_t addr, uint8_t val, void *priv) if(!(addr & 0x10000)) nga->vram_64k[addr & 0x7FFF]=val; /* b8000-bffff */ - else + else nga->cga.vram[addr & 0x7FFF]=val; - + if (nga->cga.snow_enabled) { /* recreate snow effect */ offset = ((timer_get_remaining_u64(&nga->cga.timer) / CGACONST) * 4) & 0xfc; @@ -124,14 +124,14 @@ nga_write(uint32_t addr, uint8_t val, void *priv) uint8_t nga_read(uint32_t addr, void *priv) { - + nga_t *nga = (nga_t *)priv; int offset; uint8_t ret; /* a8000-affff */ if(!(addr & 0x10000)) ret = nga->vram_64k[addr & 0x7FFF]; - else + else ret = nga->cga.vram[addr & 0x7FFF]; nga_waitstates(&nga->cga); @@ -142,7 +142,7 @@ nga_read(uint32_t addr, void *priv) nga->cga.charbuffer[offset] = nga->cga.vram[addr & 0x7fff]; nga->cga.charbuffer[offset | 1] = nga->cga.vram[addr & 0x7fff]; } - + return(ret); } @@ -160,7 +160,7 @@ nga_poll(void *priv) int cols[4]; int col; int oldsc; - + /* graphic mode and not high-res modes */ if ((nga->cga.cgamode & 2) && !(nga->cga.cgamode & 0x40)) { /* standard cga mode */ @@ -174,7 +174,7 @@ nga_poll(void *priv) nga->cga.linepos = 1; oldsc = nga->cga.sc; /* if interlaced */ - if ((nga->cga.crtc[8] & 3) == 3) + if ((nga->cga.crtc[8] & 3) == 3) nga->cga.sc = ((nga->cga.sc << 1) + nga->cga.oddeven) & 7; if (nga->cga.cgadispon) { if (nga->cga.displine < nga->cga.firstline) { @@ -187,7 +187,7 @@ nga_poll(void *priv) /* for each text column */ for (x = 0; x < nga->cga.crtc[1]; x++) { /* video output enabled */ - if (nga->cga.cgamode & 8) { + if (nga->cga.cgamode & 8) { /* character */ chr = nga->cga.charbuffer[x << 1]; /* text attributes */ @@ -211,16 +211,16 @@ nga_poll(void *priv) cols[0] = (attr >> 4) + 16; } if (drawcursor) { - for (c = 0; c < 8; c++) + for (c = 0; c < 8; c++) buffer32->line[nga->cga.displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((nga->cga.sc & 7) << 1) | nga->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { - for (c = 0; c < 8; c++) + for (c = 0; c < 8; c++) buffer32->line[nga->cga.displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((nga->cga.sc & 7) << 1) | nga->lineff] & (1 << (c ^ 7))) ? 1 : 0]; } - + nga->cga.ma++; } - } + } /* 40-col */ else if (!(nga->cga.cgamode & 2)) { /* for each text column */ @@ -248,16 +248,16 @@ nga_poll(void *priv) if (drawcursor) { for (c = 0; c < 8; c++) - buffer32->line[nga->cga.displine][(x << 4) + (c << 1) + 8] = + buffer32->line[nga->cga.displine][(x << 4) + (c << 1) + 8] = buffer32->line[nga->cga.displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((nga->cga.sc & 7) << 1) | nga->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { for (c = 0; c < 8; c++) - buffer32->line[nga->cga.displine][(x << 4) + (c << 1) + 8] = + buffer32->line[nga->cga.displine][(x << 4) + (c << 1) + 8] = buffer32->line[nga->cga.displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((nga->cga.sc & 7) << 1) | nga->lineff] & (1 << (c ^ 7))) ? 1 : 0]; } - + nga->cga.ma++; - + } } else { /* high res modes */ @@ -299,12 +299,12 @@ nga_poll(void *priv) */ dat2 = (nga->cga.sc & 1) * 0x4000; } - } + } else { dat2 = (nga->cga.sc & 1) * 0x2000; cols[0] = 0; cols[1] = (nga->cga.cgacol & 15) + 16; } - + /* for each text column */ for (x = 0; x < nga->cga.crtc[1]; x++) { /* video out */ @@ -343,7 +343,7 @@ nga_poll(void *priv) } } } else { - + /* nga specific */ cols[0] = ((nga->cga.cgamode & 0x12) == 0x12) ? 0 : (nga->cga.cgacol & 15) + 16; /* 80-col */ @@ -354,7 +354,7 @@ nga_poll(void *priv) hline(buffer32, 0, (nga->cga.displine << 1), ((nga->cga.crtc[1] << 4) + 16) << 2, cols[0]); hline(buffer32, 0, (nga->cga.displine << 1) + 1, ((nga->cga.crtc[1] << 4) + 16) << 2, cols[0]); } - + } nga->cga.sc = oldsc; @@ -362,7 +362,7 @@ nga_poll(void *priv) if (nga->cga.vc == nga->cga.crtc[7] && !nga->cga.sc) nga->cga.cgastat |= 8; nga->cga.displine++; - if (nga->cga.displine >= 720) + if (nga->cga.displine >= 720) nga->cga.displine = 0; } else { timer_advance_u64(&nga->cga.timer, nga->cga.dispontime); @@ -370,7 +370,7 @@ nga_poll(void *priv) nga->cga.linepos = 0; /* nga specific */ nga->lineff ^= 1; - + /* text mode or 640x400x2 */ if (nga->lineff && !((nga->cga.cgamode & 1) && (nga->cga.cgamode & 0x40))) { nga->cga.ma = nga->cga.maback; @@ -382,14 +382,14 @@ nga_poll(void *priv) nga->cga.cgastat &= ~8; } /* cursor stop scanline */ - if (nga->cga.sc == (nga->cga.crtc[11] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[11] & 31) >> 1))) { - nga->cga.con = 0; - nga->cga.coff = 1; + if (nga->cga.sc == (nga->cga.crtc[11] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[11] & 31) >> 1))) { + nga->cga.con = 0; + nga->cga.coff = 1; } /* interlaced and max scanline per char reached */ if ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == (nga->cga.crtc[9] >> 1)) nga->cga.maback = nga->cga.ma; - + if (nga->cga.vadj) { nga->cga.sc++; nga->cga.sc &= 31; @@ -411,7 +411,7 @@ nga_poll(void *priv) nga->cga.vc &= 127; /* lines of character displayed */ - if (nga->cga.vc == nga->cga.crtc[6]) + if (nga->cga.vc == nga->cga.crtc[6]) nga->cga.cgadispon=0; /* total vertical lines */ @@ -462,7 +462,7 @@ nga_poll(void *priv) if (!enable_overscan) xs_temp -= 16; - + if ((nga->cga.cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) { xsize = xs_temp; ysize = ys_temp; @@ -473,14 +473,14 @@ nga_poll(void *priv) } /* nga specific */ if (enable_overscan) { - if (nga->cga.composite) + if (nga->cga.composite) video_blit_memtoscreen(0, (nga->cga.firstline - 8), xsize, (nga->cga.lastline - nga->cga.firstline) + 16); else video_blit_memtoscreen_8(0, (nga->cga.firstline - 8), xsize, (nga->cga.lastline - nga->cga.firstline) + 16); } else { - if (nga->cga.composite) + if (nga->cga.composite) video_blit_memtoscreen(8, nga->cga.firstline, xsize, (nga->cga.lastline - nga->cga.firstline)); else @@ -502,7 +502,7 @@ nga_poll(void *priv) video_res_x /= 16; video_res_y /= (nga->cga.crtc[9] + 1) * 2; video_bpp = 0; - } + } else if (nga->cga.cgamode & 0x40) { video_res_x /= 8; video_res_y /= 2; @@ -522,9 +522,9 @@ nga_poll(void *priv) if (nga->cga.cgadispon) nga->cga.cgastat &= ~1; - + /* enable cursor if its scanline was reached */ - if ((nga->cga.sc == (nga->cga.crtc[10] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[10] & 31) >> 1)))) + if ((nga->cga.sc == (nga->cga.crtc[10] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[10] & 31) >> 1)))) nga->cga.con = 1; } /* 80-columns */ @@ -567,10 +567,10 @@ nga_init(const device_t *info) charset = device_get_config_int("charset"); loadfont_ex("roms/video/nga/ncr_nga_35122.bin", 1, 4096 * charset); - - nga->cga.composite = 0; + + nga->cga.composite = 0; nga->cga.snow_enabled = device_get_config_int("snow_enabled"); - + nga->cga.vram = malloc(0x8000); nga->vram_64k = malloc(0x8000); @@ -578,7 +578,7 @@ nga_init(const device_t *info) mem_mapping_add(&nga->cga.mapping, 0xb8000, 0x8000, nga_read, NULL, NULL, nga_write, NULL, NULL, NULL, 0, nga); - + mem = device_get_config_int("memory"); if (mem > 32) { @@ -589,12 +589,12 @@ nga_init(const device_t *info) } io_sethandler(0x03d0, 16, nga_in, NULL, NULL, nga_out, NULL, NULL, nga); - + overscan_x = overscan_y = 16; nga->cga.rgb_type = device_get_config_int("rgb_type"); cga_palette = (nga->cga.rgb_type << 1); cgapal_rebuild(); - + return nga; } diff --git a/src/video/vid_oak_oti.c b/src/video/vid_oak_oti.c index ed67d34aa..0902d33ee 100644 --- a/src/video/vid_oak_oti.c +++ b/src/video/vid_oak_oti.c @@ -30,11 +30,11 @@ #include <86box/vid_svga.h> #include <86box/vid_svga_render.h> -#define BIOS_037C_PATH "roms/video/oti/bios.bin" +#define BIOS_037C_PATH "roms/video/oti/bios.bin" #define BIOS_067_AMA932J_PATH "roms/machines/ama932j/OTI067.BIN" #define BIOS_067_M300_08_PATH "roms/machines/m30008/EVC_BIOS.ROM" #define BIOS_067_M300_15_PATH "roms/machines/m30015/EVC_BIOS.ROM" -#define BIOS_077_PATH "roms/video/oti/oti077.vbi" +#define BIOS_077_PATH "roms/video/oti/oti077.vbi" enum { @@ -57,7 +57,7 @@ typedef struct { uint8_t pos; uint8_t enable_register; uint8_t dipswitch_val; - + uint32_t vram_size; uint32_t vram_mask; } oti_t; @@ -87,7 +87,7 @@ oti_out(uint16_t addr, uint8_t val, void *p) } else break; break; - + case 0x3c6: case 0x3c7: case 0x3c8: case 0x3c9: if (oti->chip_id == OTI_077) sc1148x_ramdac_out(addr, 0, val, svga->ramdac, svga); @@ -127,7 +127,7 @@ oti_out(uint16_t addr, uint8_t val, void *p) } break; - case 0x3DE: + case 0x3DE: if (oti->chip_id) oti->index = val & 0x1f; else @@ -203,13 +203,13 @@ oti_in(uint16_t addr, void *p) oti_t *oti = (oti_t *)p; svga_t *svga = &oti->svga; uint8_t idx, temp; - + if (!oti->chip_id && !(oti->enable_register & 1) && (addr != 0x3C3)) return 0xff; if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) addr ^= 0x60; - + switch (addr) { case 0x3C2: if ((svga->vgapal[0].r + svga->vgapal[0].g + svga->vgapal[0].b) >= 0x50) @@ -294,12 +294,12 @@ oti_in(uint16_t addr, void *p) temp = oti->index; if (oti->chip_id) temp |= (oti->chip_id << 5); - break; + break; case 0x3DF: idx = oti->index; if (!oti->chip_id) - idx &= 0x1f; + idx &= 0x1f; if (idx == 0x10) temp = oti->dipswitch_val; else @@ -339,7 +339,7 @@ oti_pos_in(uint16_t addr, void *p) oti_t *oti = (oti_t *)p; return(oti->pos); -} +} static void @@ -357,7 +357,7 @@ oti_recalctimings(svga_t *svga) if ((oti->regs[0x0d] & 0x0c) && !(oti->regs[0x0d] & 0x10)) svga->rowoffset <<= 1; svga->interlace = oti->regs[0x14] & 0x80; - + if (svga->bpp == 16) { svga->render = svga_render_16bpp_highres; svga->hdisp >>= 1; @@ -386,7 +386,7 @@ oti_init(const device_t *info) oti->regs[0] = 0x08; /* FIXME: The BIOS wants to read this at index 0? This index is undocumented. */ /* io_sethandler(0x03c0, 32, oti_in, NULL, NULL, oti_out, NULL, NULL, oti); */ - break; + break; case OTI_067_AMA932J: romfn = BIOS_067_AMA932J_PATH; @@ -459,7 +459,7 @@ oti_speed_changed(void *p) svga_recalctimings(&oti->svga); } - + static void oti_force_redraw(void *p) @@ -476,18 +476,21 @@ oti037c_available(void) return(rom_present(BIOS_037C_PATH)); } + static int oti067_ama932j_available(void) { return(rom_present(BIOS_067_AMA932J_PATH)); } + static int oti067_077_available(void) { return(rom_present(BIOS_077_PATH)); } + static int oti067_m300_available(void) { diff --git a/src/video/vid_ogc.c b/src/video/vid_ogc.c index ca22f6d5f..8da375ef2 100644 --- a/src/video/vid_ogc.c +++ b/src/video/vid_ogc.c @@ -6,7 +6,7 @@ * * This file is part of the 86Box distribution. * - * Emulation of the Olivetti OGC 8-bit ISA (GO708) and + * Emulation of the Olivetti OGC 8-bit ISA (GO708) and * M21/M24/M28 16-bit bus (GO317/318/380/709) video cards. * * @@ -43,7 +43,7 @@ /* - * Current bugs: + * Current bugs: * - Olivetti diagnostics fail with errors: 6845 crtc write / read error out 0000 in 00ff * - Dark blue (almost black) picture in composite mode */ @@ -121,7 +121,7 @@ ogc_in(uint16_t addr, void *priv) case 0x3d4: case 0x3d5: case 0x3da: - /* + /* * bits 6-7: 3 = no DEB expansion board installed * bits 4-5: 2 color, 3 mono * bit 3: high during 1st half of vertical retrace in character mode (CCA standard) @@ -172,7 +172,7 @@ ogc_write(uint32_t addr, uint8_t val, void *priv) uint8_t ogc_read(uint32_t addr, void *priv) { - + ogc_t *ogc = (ogc_t *)priv; int offset; @@ -184,7 +184,7 @@ ogc_read(uint32_t addr, void *priv) ogc->cga.charbuffer[offset] = ogc->cga.vram[addr & 0x7fff]; ogc->cga.charbuffer[offset | 1] = ogc->cga.vram[addr & 0x7fff]; } - + return(ogc->cga.vram[addr & 0x7FFF]); } @@ -203,7 +203,7 @@ ogc_poll(void *priv) int blink = 0; int underline = 0; uint8_t border; - + //composito colore appare blu scuro /* graphic mode and not mode 40h */ @@ -218,7 +218,7 @@ ogc_poll(void *priv) ogc->cga.cgastat |= 1; ogc->cga.linepos = 1; oldsc = ogc->cga.sc; - if ((ogc->cga.crtc[8] & 3) == 3) + if ((ogc->cga.crtc[8] & 3) == 3) ogc->cga.sc = ((ogc->cga.sc << 1) + ogc->cga.oddeven) & 7; if (ogc->cga.cgadispon) { if (ogc->cga.displine < ogc->cga.firstline) { @@ -231,7 +231,7 @@ ogc_poll(void *priv) /* for each text column */ for (x = 0; x < ogc->cga.crtc[1]; x++) { /* video output enabled */ - if (ogc->cga.cgamode & 8) { + if (ogc->cga.cgamode & 8) { /* character */ chr = ogc->cga.charbuffer[x << 1]; /* text attributes */ @@ -266,19 +266,19 @@ ogc_poll(void *priv) /* character underline active and 7th row of pixels in character height being drawn */ if (underline && (ogc->cga.sc == 7)) { /* for each pixel in character width */ - for (c = 0; c < 8; c++) + for (c = 0; c < 8; c++) buffer32->line[ogc->cga.displine][(x << 3) + c + 8] = mdaattr[attr][blink][1]; } else if (drawcursor) { - for (c = 0; c < 8; c++) + for (c = 0; c < 8; c++) buffer32->line[ogc->cga.displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((ogc->cga.sc & 7) << 1) | ogc->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { - for (c = 0; c < 8; c++) + for (c = 0; c < 8; c++) buffer32->line[ogc->cga.displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((ogc->cga.sc & 7) << 1) | ogc->lineff] & (1 << (c ^ 7))) ? 1 : 0]; } - + ogc->cga.ma++; } - } + } /* 40-col */ else if (!(ogc->cga.cgamode & 2)) { for (x = 0; x < ogc->cga.crtc[1]; x++) { @@ -312,37 +312,37 @@ ogc_poll(void *priv) blink = (attr & 0x80) * 8 + 7 + 16; } - + /* character underline active and 7th row of pixels in character height being drawn */ if (underline && (ogc->cga.sc == 7)) { /* for each pixel in character width */ - for (c = 0; c < 8; c++) - buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 8] = + for (c = 0; c < 8; c++) + buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 8] = buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 1 + 8] = mdaattr[attr][blink][1]; } else if (drawcursor) { for (c = 0; c < 8; c++) - buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 8] = + buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 8] = buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((ogc->cga.sc & 7) << 1) | ogc->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { for (c = 0; c < 8; c++) - buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 8] = + buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 8] = buffer32->line[ogc->cga.displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((ogc->cga.sc & 7) << 1) | ogc->lineff] & (1 << (c ^ 7))) ? 1 : 0]; } - + ogc->cga.ma++; - + } } else { /* 640x400 mode */ if (ogc->ctrl_3de & 1 ) { dat2 = ((ogc->cga.sc & 1) * 0x4000) | (ogc->lineff * 0x2000); cols[0] = 0; cols[1] = 15 + 16; - } + } else { dat2 = (ogc->cga.sc & 1) * 0x2000; cols[0] = 0; cols[1] = (ogc->cga.cgacol & 15) + 16; } - + for (x = 0; x < ogc->cga.crtc[1]; x++) { /* video out */ if (ogc->cga.cgamode & 8) { @@ -351,7 +351,7 @@ ogc_poll(void *priv) dat = 0; } ogc->cga.ma++; - + for (c = 0; c < 16; c++) { buffer32->line[ogc->cga.displine][(x << 4) + c + 8] = cols[dat >> 15]; dat <<= 1; @@ -359,7 +359,7 @@ ogc_poll(void *priv) } } } else { - + /* ogc specific */ cols[0] = ((ogc->cga.cgamode & 0x12) == 0x12) ? 0 : (ogc->cga.cgacol & 15) + 16; if (ogc->cga.cgamode & 1) { @@ -369,7 +369,7 @@ ogc_poll(void *priv) hline(buffer32, 0, (ogc->cga.displine << 1), ((ogc->cga.crtc[1] << 4) + 16) << 2, cols[0]); hline(buffer32, 0, (ogc->cga.displine << 1) + 1, ((ogc->cga.crtc[1] << 4) + 16) << 2, cols[0]); } - + } /* 80 columns */ @@ -393,7 +393,7 @@ ogc_poll(void *priv) if (ogc->cga.vc == ogc->cga.crtc[7] && !ogc->cga.sc) ogc->cga.cgastat |= 8; ogc->cga.displine++; - if (ogc->cga.displine >= 720) + if (ogc->cga.displine >= 720) ogc->cga.displine = 0; } else { timer_advance_u64(&ogc->cga.timer, ogc->cga.dispontime); @@ -409,9 +409,9 @@ ogc_poll(void *priv) if (!ogc->cga.vsynctime) ogc->cga.cgastat &= ~8; } - if (ogc->cga.sc == (ogc->cga.crtc[11] & 31) || ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[11] & 31) >> 1))) { - ogc->cga.con = 0; - ogc->cga.coff = 1; + if (ogc->cga.sc == (ogc->cga.crtc[11] & 31) || ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[11] & 31) >> 1))) { + ogc->cga.con = 0; + ogc->cga.coff = 1; } if ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == (ogc->cga.crtc[9] >> 1)) ogc->cga.maback = ogc->cga.ma; @@ -433,7 +433,7 @@ ogc_poll(void *priv) ogc->cga.vc++; ogc->cga.vc &= 127; - if (ogc->cga.vc == ogc->cga.crtc[6]) + if (ogc->cga.vc == ogc->cga.crtc[6]) ogc->cga.cgadispon=0; if (oldvc == ogc->cga.crtc[4]) { @@ -477,7 +477,7 @@ ogc_poll(void *priv) if (!enable_overscan) xs_temp -= 16; - + if ((ogc->cga.cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) { xsize = xs_temp; ysize = ys_temp; @@ -488,14 +488,14 @@ ogc_poll(void *priv) } /* ogc specific */ if (enable_overscan) { - if (ogc->cga.composite) + if (ogc->cga.composite) video_blit_memtoscreen(0, (ogc->cga.firstline - 8), xsize, (ogc->cga.lastline - ogc->cga.firstline) + 16); else video_blit_memtoscreen_8(0, (ogc->cga.firstline - 8), xsize, (ogc->cga.lastline - ogc->cga.firstline) + 16); } else { - if (ogc->cga.composite) + if (ogc->cga.composite) video_blit_memtoscreen(8, ogc->cga.firstline, xsize, (ogc->cga.lastline - ogc->cga.firstline)); else @@ -535,8 +535,8 @@ ogc_poll(void *priv) if (ogc->cga.cgadispon) ogc->cga.cgastat &= ~1; - - if ((ogc->cga.sc == (ogc->cga.crtc[10] & 31) || ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[10] & 31) >> 1)))) + + if ((ogc->cga.sc == (ogc->cga.crtc[10] & 31) || ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[10] & 31) >> 1)))) ogc->cga.con = 1; } /* 80-columns */ @@ -568,7 +568,7 @@ ogc_speed_changed(void *priv) void ogc_mdaattr_rebuild(){ int c; - + for (c = 0; c < 256; c++) { mdaattr[c][0][0] = mdaattr[c][1][0] = mdaattr[c][1][1] = 16; if (c & 8) mdaattr[c][0][1] = 15 + 16; @@ -589,7 +589,7 @@ ogc_mdaattr_rebuild(){ mdaattr[0x88][0][1] = mdaattr[0x88][1][1] = 16; } -/* +/* * Missing features * - Composite video mode not working * - Optional EGC expansion board (which handles 640x400x16) not implemented @@ -604,13 +604,13 @@ ogc_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_CGA, &timing_ogc); loadfont("roms/video/ogc/ogc graphics board go380 258 pqbq.bin", 1); - + /* composite is not working yet */ // display_type = device_get_config_int("display_type"); ogc->cga.composite = 0; // (display_type != CGA_RGB); ogc->cga.revision = device_get_config_int("composite_type"); ogc->cga.snow_enabled = device_get_config_int("snow_enabled"); - + ogc->cga.vram = malloc(0x8000); cga_comp_init(ogc->cga.revision); @@ -619,18 +619,18 @@ ogc_init(const device_t *info) ogc_read, NULL, NULL, ogc_write, NULL, NULL, NULL, 0, ogc); io_sethandler(0x03d0, 16, ogc_in, NULL, NULL, ogc_out, NULL, NULL, ogc); - + overscan_x = overscan_y = 16; ogc->cga.rgb_type = device_get_config_int("rgb_type"); cga_palette = (ogc->cga.rgb_type << 1); cgapal_rebuild(); ogc_mdaattr_rebuild(); - + /* color display */ - if (device_get_config_int("rgb_type")==0 || device_get_config_int("rgb_type") == 4) + if (device_get_config_int("rgb_type")==0 || device_get_config_int("rgb_type") == 4) ogc->mono_display = 0; else - ogc->mono_display = 1; + ogc->mono_display = 1; return ogc; } diff --git a/src/video/vid_paradise.c b/src/video/vid_paradise.c index bb8cd0394..1042440b6 100644 --- a/src/video/vid_paradise.c +++ b/src/video/vid_paradise.c @@ -37,11 +37,11 @@ typedef struct paradise_t { svga_t svga; - + rom_t bios_rom; - - uint8_t bank_mask; - + + uint8_t bank_mask; + enum { PVGA1A = 0, @@ -52,22 +52,22 @@ typedef struct paradise_t uint32_t vram_mask; uint32_t read_bank[4], write_bank[4]; - + int interlace; int check, check2; - + struct { uint8_t reg_block_ptr; uint8_t reg_idx; uint8_t disable_autoinc; - + uint16_t int_status; uint16_t blt_ctrl1, blt_ctrl2; uint16_t srclow, srchigh; uint16_t dstlow, dsthigh; uint32_t srcaddr, dstaddr; - + int invalid_block; } accel; } paradise_t; @@ -82,20 +82,20 @@ void paradise_out(uint16_t addr, uint8_t val, void *p) paradise_t *paradise = (paradise_t *)p; svga_t *svga = ¶dise->svga; uint8_t old; - + if (paradise->vram_mask <= ((512 << 10) - 1)) paradise->bank_mask = 0x7f; else paradise->bank_mask = 0xff; - - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) { case 0x3c5: if (svga->seqaddr > 7) { - if (paradise->type < WD90C11 || svga->seqregs[6] != 0x48) + if (paradise->type < WD90C11 || svga->seqregs[6] != 0x48) return; svga->seqregs[svga->seqaddr & 0x1f] = val; if (svga->seqaddr == 0x11) { @@ -143,7 +143,7 @@ void paradise_out(uint16_t addr, uint8_t val, void *p) svga->gdcreg[6] = val; paradise_remap(paradise); return; - + case 9: case 0x0a: svga->gdcreg[svga->gdcaddr] = val & paradise->bank_mask; @@ -155,7 +155,7 @@ void paradise_out(uint16_t addr, uint8_t val, void *p) return; } break; - + case 0x3D4: svga->crtcreg = val & 0x3f; return; @@ -172,7 +172,7 @@ void paradise_out(uint16_t addr, uint8_t val, void *p) return; old = svga->crtc[svga->crtcreg]; svga->crtc[svga->crtcreg] = val; - + if (old != val) { if (svga->crtcreg < 0xe || svga->crtcreg > 0x10) @@ -188,7 +188,7 @@ void paradise_out(uint16_t addr, uint8_t val, void *p) } break; } - + svga_out(addr, val, svga); } @@ -196,18 +196,18 @@ uint8_t paradise_in(uint16_t addr, void *p) { paradise_t *paradise = (paradise_t *)p; svga_t *svga = ¶dise->svga; - + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; - + switch (addr) { case 0x3c5: if (svga->seqaddr > 7) { - if (paradise->type < WD90C11 || svga->seqregs[6] != 0x48) + if (paradise->type < WD90C11 || svga->seqregs[6] != 0x48) return 0xff; - if (svga->seqaddr > 0x12) + if (svga->seqaddr > 0x12) return 0xff; return svga->seqregs[svga->seqaddr & 0x1f]; } @@ -232,7 +232,7 @@ uint8_t paradise_in(uint16_t addr, void *p) } } return svga->gdcreg[0x0b]; - + case 0x0f: return (svga->gdcreg[0x0f] & 0x17) | 0x80; } @@ -242,7 +242,7 @@ uint8_t paradise_in(uint16_t addr, void *p) return svga->crtcreg; case 0x3D5: if ((paradise->type == PVGA1A) && (svga->crtcreg & 0x20)) - return 0xff; + return 0xff; if (svga->crtcreg > 0x29 && svga->crtcreg < 0x30 && (svga->crtc[0x29] & 0x88) != 0x80) return 0xff; return svga->crtc[svga->crtcreg]; @@ -278,10 +278,10 @@ void paradise_remap(paradise_t *paradise) paradise->write_bank[0] = paradise->write_bank[2] = svga->gdcreg[9] << 12; paradise->write_bank[1] = paradise->write_bank[3] = (svga->gdcreg[9] << 12) + ((svga->gdcreg[6] & 0x08) ? 0 : 0x8000); } - + if ((((svga->gdcreg[0x0b] & 0xc0) == 0xc0) && !svga->chain4 && (svga->crtc[0x14] & 0x40) && ((svga->gdcreg[6] >> 2) & 3) == 1)) paradise->check = 1; - + if (paradise->bank_mask == 0x7f) { paradise->read_bank[1] &= 0x7ffff; paradise->write_bank[1] &= 0x7ffff; @@ -302,16 +302,16 @@ void paradise_recalctimings(svga_t *svga) if (svga->crtc[0x3e] & 0x10) svga->split |= 0x400; svga->interlace = !!(svga->crtc[0x2d] & 0x20); - - if (!svga->interlace && svga->lowres && (svga->hdisp >= 1024) && - ((svga->gdcreg[5] & 0x60) == 0) && (svga->miscout >= 0x27) && - (svga->miscout <= 0x2f) && ((svga->gdcreg[6] & 1) || + + if (!svga->interlace && svga->lowres && (svga->hdisp >= 1024) && + ((svga->gdcreg[5] & 0x60) == 0) && (svga->miscout >= 0x27) && + (svga->miscout <= 0x2f) && ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1))) { /*Horrible tweak to re-enable the interlace after returning to a windowed DOS box in Win3.x*/ svga->interlace = 1; } } - + if (paradise->type < WD90C30) { if (svga->bpp >= 8 && !svga->lowres) { svga->render = svga_render_8bpp_highres; @@ -337,8 +337,8 @@ static void paradise_write(uint32_t addr, uint8_t val, void *p) svga_t *svga = ¶dise->svga; uint32_t prev_addr, prev_addr2; - addr = (addr & 0x7fff) + paradise->write_bank[(addr >> 15) & 3]; - + addr = (addr & 0x7fff) + paradise->write_bank[(addr >> 15) & 3]; + /*Could be done in a better way but it works.*/ if (!svga->lowres) { if (paradise->check) { @@ -375,7 +375,7 @@ static void paradise_write(uint32_t addr, uint8_t val, void *p) } } } - + svga_write_linear(addr, val, svga); } static void paradise_writew(uint32_t addr, uint16_t val, void *p) @@ -385,7 +385,7 @@ static void paradise_writew(uint32_t addr, uint16_t val, void *p) uint32_t prev_addr, prev_addr2; addr = (addr & 0x7fff) + paradise->write_bank[(addr >> 15) & 3]; - + /*Could be done in a better way but it works.*/ if (!svga->lowres) { if (paradise->check) { @@ -422,7 +422,7 @@ static void paradise_writew(uint32_t addr, uint16_t val, void *p) } } } - + svga_writew_linear(addr, val, svga); } @@ -431,9 +431,9 @@ static uint8_t paradise_read(uint32_t addr, void *p) paradise_t *paradise = (paradise_t *)p; svga_t *svga = ¶dise->svga; uint32_t prev_addr, prev_addr2; - + addr = (addr & 0x7fff) + paradise->read_bank[(addr >> 15) & 3]; - + /*Could be done in a better way but it works.*/ if (!svga->lowres) { if (paradise->check) { @@ -478,9 +478,9 @@ static uint16_t paradise_readw(uint32_t addr, void *p) paradise_t *paradise = (paradise_t *)p; svga_t *svga = ¶dise->svga; uint32_t prev_addr, prev_addr2; - + addr = (addr & 0x7fff) + paradise->read_bank[(addr >> 15) & 3]; - + /*Could be done in a better way but it works.*/ if (!svga->lowres) { if (paradise->check) { @@ -562,7 +562,7 @@ void *paradise_init(const device_t *info, uint32_t memsize) svga->ramdac = device_add(&sc11487_ramdac_device); /*Actually a Winbond W82c487-80, probably a clone.*/ break; } - + mem_mapping_set_handler(&svga->mapping, paradise_read, paradise_readw, NULL, paradise_write, paradise_writew, NULL); mem_mapping_set_p(&svga->mapping, paradise); @@ -590,27 +590,27 @@ void *paradise_init(const device_t *info, uint32_t memsize) svga->miscout = 1; paradise->type = info->local; - + return paradise; } static void *paradise_pvga1a_ncr3302_init(const device_t *info) { paradise_t *paradise = paradise_init(info, 1 << 18); - + if (paradise) rom_init(¶dise->bios_rom, "roms/machines/3302/c000-wd_1987-1989-740011-003058-019c.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + return paradise; } static void *paradise_pvga1a_pc2086_init(const device_t *info) { paradise_t *paradise = paradise_init(info, 1 << 18); - + if (paradise) rom_init(¶dise->bios_rom, "roms/machines/pc2086/40186.ic171", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + return paradise; } @@ -620,7 +620,7 @@ static void *paradise_pvga1a_pc3086_init(const device_t *info) if (paradise) rom_init(¶dise->bios_rom, "roms/machines/pc3086/c000.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + return paradise; } @@ -633,10 +633,10 @@ static void *paradise_pvga1a_standalone_init(const device_t *info) memory <<= 10; paradise = paradise_init(info, memory); - + if (paradise) rom_init(¶dise->bios_rom, "roms/video/pvga1a/BIOS.BIN", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + return paradise; } @@ -648,23 +648,23 @@ static int paradise_pvga1a_standalone_available(void) static void *paradise_wd90c11_megapc_init(const device_t *info) { paradise_t *paradise = paradise_init(info, 0); - + if (paradise) rom_init_interleaved(¶dise->bios_rom, "roms/machines/megapc/41651-bios lo.u18", "roms/machines/megapc/211253-bios hi.u19", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + return paradise; } static void *paradise_wd90c11_standalone_init(const device_t *info) { paradise_t *paradise = paradise_init(info, 0); - + if (paradise) rom_init(¶dise->bios_rom, "roms/video/wd90c11/WD90C11.VBI", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + return paradise; } @@ -682,7 +682,7 @@ static void *paradise_wd90c30_standalone_init(const device_t *info) memory <<= 10; paradise = paradise_init(info, memory); - + if (paradise) rom_init(¶dise->bios_rom, "roms/video/wd90c30/90C30-LR.VBI", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); @@ -699,14 +699,14 @@ void paradise_close(void *p) paradise_t *paradise = (paradise_t *)p; svga_close(¶dise->svga); - + free(paradise); } void paradise_speed_changed(void *p) { paradise_t *paradise = (paradise_t *)p; - + svga_recalctimings(¶dise->svga); } diff --git a/src/video/vid_pgc.c b/src/video/vid_pgc.c index 6c23ab7df..fa017693b 100644 --- a/src/video/vid_pgc.c +++ b/src/video/vid_pgc.c @@ -8,13 +8,13 @@ * * This implements just enough of the Professional Graphics * Controller to act as a basis for the Vermont Microsystems - * IM-1024. + * IM-1024. * * PGC features implemented include: * > The CGA-compatible display modes * > Switching to and from native mode * > Communicating with the host PC - * + * * Numerous features are implemented partially or not at all, * such as: * > 2D drawing @@ -113,7 +113,7 @@ static const char *pgc_err_msgs[] = { "Too long\r", "Area \r", "Missing \r", - "Unknown \r" + "Unknown \r" }; @@ -167,7 +167,7 @@ output_byte(pgc_t *dev, uint8_t val) pgc_log("PGC: output buffer state: %02x %02x Sleeping\n", dev->mapram[0x302], dev->mapram[0x303]); dev->waiting_output_fifo = 1; - pgc_sleep(dev); + pgc_sleep(dev); } if (dev->mapram[0x3ff]) { @@ -206,7 +206,7 @@ error_byte(pgc_t *dev, uint8_t val) /* If error buffer full, wait for it to empty. */ while (!dev->stopped && dev->mapram[0x304] == dev->mapram[0x305] - 1) { dev->waiting_error_fifo = 1; - pgc_sleep(dev); + pgc_sleep(dev); } if (dev->mapram[0x3ff]) { @@ -238,7 +238,7 @@ error_string(pgc_t *dev, const char *s) /* * Read next byte from the input buffer. * - * If no byte available will sleep until one is. Returns 0 if + * If no byte available will sleep until one is. Returns 0 if * a PGC reset has been triggered by a write to 0xC63FF. */ static int @@ -247,7 +247,7 @@ input_byte(pgc_t *dev, uint8_t *result) /* If input buffer empty, wait for it to fill. */ while (!dev->stopped && (dev->mapram[0x300] == dev->mapram[0x301])) { dev->waiting_input_fifo = 1; - pgc_sleep(dev); + pgc_sleep(dev); } if (dev->stopped) @@ -303,7 +303,7 @@ read_command(pgc_t *dev) return pgc_clist_byte(dev, &dev->hex_command); if (dev->ascii_mode) { - char ch; + char ch; int count = 0; while (count < 7) { @@ -359,7 +359,7 @@ parse_command(pgc_t *dev, const pgc_cmd_t **pcmd) /* If in ASCII mode match on the ASCII command. */ if (dev->ascii_mode && !dev->clcur) { - sprintf(match, "%-6.6s", cmd->ascii); + sprintf(match, "%-6.6s", cmd->ascii); if (! strncmp(match, dev->asc_command, 6)) { *pcmd = cmd; dev->hex_command = cmd->hex; @@ -400,20 +400,20 @@ hndl_clbeg(pgc_t *dev) while (1) { if (! parse_command(dev, &cmd)) { /* PGC has been reset. */ - return; - } + return; + } if (!cmd) { pgc_error(dev, PGC_ERROR_OPCODE); - return; + return; } else if (dev->hex_command == 0x71) { /* CLEND */ dev->clist[param] = cl; return; - } else { + } else { if (! pgc_cl_append(&cl, dev->hex_command)) { pgc_error(dev, PGC_ERROR_OVERFLOW); return; - } + } if (cmd->parser) { if (! (*cmd->parser)(dev, &cl, cmd->p)) @@ -526,8 +526,8 @@ hndl_color(pgc_t *dev) /* - * Set drawing mode. - * + * Set drawing mode. + * * 0 => Draw * 1 => Invert */ @@ -667,7 +667,7 @@ pgc_write_pixel(pgc_t *dev, uint16_t x, uint16_t y, uint8_t ink) uint8_t *vram; /* Suppress out-of-range writes; clip to viewport. */ - if (x < dev->vp_x1 || x > dev->vp_x2 || x >= dev->maxw || + if (x < dev->vp_x1 || x > dev->vp_x2 || x >= dev->maxw || y < dev->vp_y1 || y > dev->vp_y2 || y >= dev->maxh) { pgc_log("PGC: write_pixel clipped: (%i,%i) " "vp_x1=%i vp_y1=%i vp_x2=%i vp_y2=%i " @@ -689,7 +689,7 @@ pgc_read_pixel(pgc_t *dev, uint16_t x, uint16_t y) uint8_t *vram; /* Suppress out-of-range reads. */ - if (x >= dev->maxw || y >= dev->maxh) + if (x >= dev->maxw || y >= dev->maxh) return 0; vram = pgc_vram_addr(dev, x, y); @@ -712,10 +712,10 @@ pgc_plot(pgc_t *dev, uint16_t x, uint16_t y) uint8_t *vram; /* Only allow plotting within the current viewport. */ - if (x < dev->vp_x1 || x > dev->vp_x2 || x >= dev->maxw || + if (x < dev->vp_x1 || x > dev->vp_x2 || x >= dev->maxw || y < dev->vp_y1 || y > dev->vp_y2 || y >= dev->maxh) { pgc_log("PGC: plot clipped: (%i,%i) %i <= x <= %i; %i <= y <= %i; " - "mode=%i ink=0x%02x\n", x, y, + "mode=%i ink=0x%02x\n", x, y, dev->vp_x1, dev->vp_x2, dev->vp_y1, dev->vp_y2, dev->draw_mode, dev->color); return; @@ -752,7 +752,7 @@ pgc_plot(pgc_t *dev, uint16_t x, uint16_t y) * Draw a line (using raster coordinates). * * Bresenham's Algorithm from: - * + * * * The line pattern mask to use is passed in. Return value is the * line pattern mask, rotated by the number of points drawn. @@ -813,7 +813,7 @@ pgc_draw_line(pgc_t *dev, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint16 /* - * Draw a horizontal line in the current fill pattern + * Draw a horizontal line in the current fill pattern * (using raster coordinates). */ void @@ -832,8 +832,8 @@ pgc_fill_line_r(pgc_t *dev, int32_t x0, int32_t x1, int32_t y0) if (dev->fill_pattern[y0 & 0x0F] & mask) pgc_plot(dev, x, y0); mask = mask >> 1; - if (mask == 0) mask = 0x8000; - } + if (mask == 0) mask = 0x8000; + } } @@ -896,8 +896,8 @@ pgc_fill_polygon(pgc_t *dev, unsigned corners, int32_t *x, int32_t *y) } /* Polygon fill. Based on */ - /* For each row, work out where the polygon lines intersect with - * that row. */ + /* For each row, work out where the polygon lines intersect with + * that row. */ for (ypos = ymin; ypos <= ymax; ypos++) { nodes = 0; j = corners - 1; @@ -907,7 +907,7 @@ pgc_fill_polygon(pgc_t *dev, unsigned corners, int32_t *x, int32_t *y) nodex[nodes++] = dx[i] + (ypos-dy[i])/(dy[j]-dy[i]) * (dx[j] - dx[i]); } j = i; - } + } /* Sort the intersections. */ if (nodes) @@ -1041,14 +1041,14 @@ parse_poly(pgc_t *dev, pgc_cl_t *cl, int c) if (! pgc_cl_append(cl, count)) { pgc_error(dev, PGC_ERROR_OVERFLOW); - return 0; + return 0; } pgc_log("PCG: parse_poly: parse %i coords\n", 2 * count); return pgc_parse_coords(dev, cl, 2 * count); } - + /* Handle the DISPLAY command. */ static void hndl_display(pgc_t *dev) @@ -1059,7 +1059,7 @@ hndl_display(pgc_t *dev) pgc_log("PGC: DISPLAY(%i)\n", param); - if (param > 1) + if (param > 1) pgc_error(dev, PGC_ERROR_RANGE); else pgc_setdisplay(dev, param); @@ -1101,7 +1101,7 @@ hndl_imagew(pgc_t *dev) if (v1 & 0x80) { /* Literal run. */ v1 -= 0x7f; - while (col1 <= col2 && v1 != 0) { + while (col1 <= col2 && v1 != 0) { if (! pgc_param_byte(dev, &v2)) return; pgc_write_pixel(dev, col1, row, v2); col1++; @@ -1110,14 +1110,14 @@ hndl_imagew(pgc_t *dev) } else { /* Repeated run. */ if (! pgc_param_byte(dev, &v2)) return; - + v1++; - while (col1 <= col2 && v1 != 0) { + while (col1 <= col2 && v1 != 0) { pgc_write_pixel(dev, col1, row, v2); col1++; v1--; } - } + } } } @@ -1166,9 +1166,9 @@ hndl_lutrd(pgc_t *dev) col = dev->palette[param]; - pgc_result_byte(dev, (col >> 20) & 0x0f); - pgc_result_byte(dev, (col >> 12) & 0x0f); - pgc_result_byte(dev, (col >> 4) & 0x0f); + pgc_result_byte(dev, (col >> 20) & 0x0f); + pgc_result_byte(dev, (col >> 12) & 0x0f); + pgc_result_byte(dev, (col >> 4) & 0x0f); } @@ -1195,7 +1195,7 @@ hndl_lut(pgc_t *dev) /* * LUT8RD and LUT8 are extensions implemented by several PGC clones, - * so here are functions that implement them even though they aren't + * so here are functions that implement them even though they aren't * used by the PGC. */ void @@ -1208,8 +1208,8 @@ pgc_hndl_lut8rd(pgc_t *dev) col = dev->palette[param]; - pgc_result_byte(dev, (col >> 16) & 0xff); - pgc_result_byte(dev, (col >> 8) & 0xff); + pgc_result_byte(dev, (col >> 16) & 0xff); + pgc_result_byte(dev, (col >> 8) & 0xff); pgc_result_byte(dev, col & 0xff); } @@ -1363,7 +1363,7 @@ hndl_window(pgc_t *dev) * * In order to support the original PGC and clones, we support two lists; * core commands (listed below) and subclass commands (listed in the clone). - * + * * Each row has five parameters: * ASCII-mode command * Hex-mode command @@ -1373,7 +1373,7 @@ hndl_window(pgc_t *dev) * * TODO: This list omits numerous commands present in a genuine PGC * (ARC, AREA, AREABC, BUFFER, CIRCLE etc etc). - * TODO: Some commands don't have a parse function (for example, IMAGEW) + * TODO: Some commands don't have a parse function (for example, IMAGEW) * * The following ASCII entries have special meaning: * ~~~~~~ command is valid only in hex mode @@ -1438,7 +1438,7 @@ static const pgc_cmd_t pgc_commands[] = { { "VWPORT", 0xb2, hndl_vwport, pgc_parse_words, 4 }, { "VWP", 0xb2, hndl_vwport, pgc_parse_words, 4 }, { "WINDOW", 0xb3, hndl_window, pgc_parse_words, 4 }, - { "WI", 0xb3, hndl_window, pgc_parse_words, 4 }, + { "WI", 0xb3, hndl_window, pgc_parse_words, 4 }, { "@@@@@@", 0x00, NULL, NULL, 0 } }; @@ -1452,7 +1452,7 @@ wake_timer(void *priv) pgc_t *dev = (pgc_t *)priv; #ifdef ENABLE_PGC_LOG - pgc_log("PGC: woke up\n"); + pgc_log("PGC: woke up\n"); #endif thread_set_event(dev->pgc_wake_thread); @@ -1487,9 +1487,9 @@ pgc_thread(void *priv) /* Nope, just a reset. */ continue; - } + } - pgc_log("PGC: Command: [%02x] '%s' found = %i\n", + pgc_log("PGC: Command: [%02x] '%s' found = %i\n", dev->hex_command, dev->asc_command, (cmd != NULL)); if (cmd) { @@ -1514,7 +1514,7 @@ err_digit(pgc_t *dev) do { /* Swallow everything until the next separator */ if (! dev->inputbyte(dev, &asc)) return 0; - } while (! is_whitespace(asc)); + } while (! is_whitespace(asc)); pgc_error(dev, PGC_ERROR_DIGIT); @@ -1537,7 +1537,7 @@ pgc_result_byte(pgc_t *dev, uint8_t val) sprintf(buf, "%i", val); dev->result_count++; - return output_string(dev, buf); + return output_string(dev, buf); } @@ -1558,7 +1558,7 @@ pgc_result_word(pgc_t *dev, int16_t val) sprintf(buf, "%i", val); dev->result_count++; - return output_string(dev, buf); + return output_string(dev, buf); } @@ -1665,7 +1665,7 @@ pgc_setdisplay(pgc_t *dev, int cga) /* * When idle, the PGC drawing thread sleeps. pgc_wake() awakens it - but - * not immediately. Like the Voodoo, it has a short delay so that writes + * not immediately. Like the Voodoo, it has a short delay so that writes * can be batched. */ void @@ -1683,7 +1683,7 @@ pgc_sleep(pgc_t *dev) pgc_log("PGC: sleeping on %i %i %i %i 0x%02x 0x%02x\n", dev->stopped, dev->waiting_input_fifo, dev->waiting_output_fifo, - dev->waiting_error_fifo, dev->mapram[0x300], dev->mapram[0x301]); + dev->waiting_error_fifo, dev->mapram[0x300], dev->mapram[0x301]); /* Avoid entering waiting state. */ if (dev->stopped) { @@ -1720,7 +1720,7 @@ pgc_clist_byte(pgc_t *dev, uint8_t *val) if (dev->clcur->rdptr < dev->clcur->wrptr) *val = dev->clcur->list[dev->clcur->rdptr++]; - else + else *val = 0; /* If we've reached the end, reset to the beginning and @@ -1844,7 +1844,7 @@ pgc_param_coord(pgc_t *dev, int32_t *value) return 1; } - /* If in hex mode, read in the encoded integer and fraction parts + /* If in hex mode, read in the encoded integer and fraction parts * from the hex stream */ if (! dev->ascii_mode) { for (n = 0; n < 4; n++) @@ -1860,7 +1860,7 @@ pgc_param_coord(pgc_t *dev, int32_t *value) do { if (! dev->inputbyte(dev, &asc)) return 0; if (asc == '-') sign = -1; - } while (is_whitespace(asc)); + } while (is_whitespace(asc)); /* There had better be a digit next. */ if (! isdigit(asc)) { @@ -1888,7 +1888,7 @@ pgc_param_coord(pgc_t *dev, int32_t *value) case 'D': case 'e': case 'E': - esign = 1; + esign = 1; if (! dev->inputbyte(dev, &asc)) return 0; if (asc == '-') { sign = -1; @@ -1907,12 +1907,12 @@ pgc_param_coord(pgc_t *dev, int32_t *value) asc -= '0'; /* asc is digit */ switch (state) { - case PS_MAIN: + case PS_MAIN: integer = (integer * 10)+asc; if (integer & 0x8000) { /* Overflow */ pgc_error(dev, PGC_ERROR_RANGE); - integer = 0x7fff; + integer = 0x7fff; } break; @@ -1925,11 +1925,11 @@ pgc_param_coord(pgc_t *dev, int32_t *value) exponent = (exponent * 10)+asc; break; } - + } if (! dev->inputbyte(dev, &asc)) return 0; - } while (! is_whitespace(asc)); + } while (! is_whitespace(asc)); res = (frac << 16) / dp; pgc_log("PGC: integer=%u frac=%u exponent=%u dp=%i res=0x%08lx\n", @@ -1944,7 +1944,7 @@ pgc_param_coord(pgc_t *dev, int32_t *value) res /= 10; } } - *value = sign*res; + *value = sign*res; return 1; } @@ -1998,7 +1998,7 @@ pgc_parse_bytes(pgc_t *dev, pgc_cl_t *cl, int count) if (! param) { pgc_error(dev, PGC_ERROR_OVERFLOW); - return 0; + return 0; } for (n = 0; n < count; n++) { @@ -2010,7 +2010,7 @@ pgc_parse_bytes(pgc_t *dev, pgc_cl_t *cl, int count) if (! pgc_cl_append(cl, param[n])) { pgc_error(dev, PGC_ERROR_OVERFLOW); free(param); - return 0; + return 0; } } @@ -2029,7 +2029,7 @@ pgc_parse_words(pgc_t *dev, pgc_cl_t *cl, int count) if (! param) { pgc_error(dev, PGC_ERROR_OVERFLOW); - return 0; + return 0; } for (n = 0; n < count; n++) { @@ -2042,7 +2042,7 @@ pgc_parse_words(pgc_t *dev, pgc_cl_t *cl, int count) !pgc_cl_append(cl, param[n] >> 8)) { pgc_error(dev, PGC_ERROR_OVERFLOW); free(param); - return 0; + return 0; } } @@ -2061,7 +2061,7 @@ pgc_parse_coords(pgc_t *dev, pgc_cl_t *cl, int count) if (! param) { pgc_error(dev, PGC_ERROR_OVERFLOW); - return 0; + return 0; } for (n = 0; n < count; n++) { @@ -2073,7 +2073,7 @@ pgc_parse_coords(pgc_t *dev, pgc_cl_t *cl, int count) /* Here is how the real PGC serializes coords: * - * 100.5 -> 64 00 00 80 ie 0064.8000 + * 100.5 -> 64 00 00 80 ie 0064.8000 * 100.3 -> 64 00 CD 4C ie 0064.4CCD */ for (n = 0; n < count; n++) { @@ -2086,7 +2086,7 @@ pgc_parse_coords(pgc_t *dev, pgc_cl_t *cl, int count) !pgc_cl_append(cl, (param[n] >> 8) & 0xff)) { pgc_error(dev, PGC_ERROR_OVERFLOW); free(param); - return 0; + return 0; } } @@ -2096,7 +2096,7 @@ pgc_parse_coords(pgc_t *dev, pgc_cl_t *cl, int count) } -/* Convert coordinates based on the current window / viewport to raster +/* Convert coordinates based on the current window / viewport to raster * coordinates. */ void pgc_dto_raster(pgc_t *dev, double *x, double *y) @@ -2171,7 +2171,7 @@ pgc_out(uint16_t addr, uint8_t val, void *priv) case 0x03d5: case 0x03d7: if (dev->mapram[0x03d0] < 18) - dev->mapram[0x03e0 + dev->mapram[0x03d0]] = val; + dev->mapram[0x03e0 + dev->mapram[0x03d0]] = val; break; case 0x03d8: /* CRTC Mode Control register */ @@ -2235,7 +2235,7 @@ pgc_write(uint32_t addr, uint8_t val, void *priv) pgc_t *dev = (pgc_t *)priv; /* - * It seems variable whether the PGC maps 1K or 2K at 0xc6000. + * It seems variable whether the PGC maps 1K or 2K at 0xc6000. * * Map 2K here in case a clone requires it. */ @@ -2264,7 +2264,7 @@ pgc_write(uint32_t addr, uint8_t val, void *priv) pgc_wake(dev); } break; - + case 0x305: /* error read pointer */ if (dev->waiting_error_fifo && dev->mapram[0x304] != (uint8_t)(dev->mapram[0x305] - 1)) { @@ -2333,13 +2333,13 @@ pgc_cga_text(pgc_t *dev, int w) int cw = (w == 80) ? 8 : 16; addr = &dev->cga_vram[((ma + ((dev->displine / pitch) * w)) * 2) & 0x3ffe]; - ma += (dev->displine / pitch) * w; + ma += (dev->displine / pitch) * w; for (x = 0; x < w; x++) { chr = *addr++; attr = *addr++; - /* Cursor enabled? */ + /* Cursor enabled? */ if (ma == ca && (dev->cgablink & 8) && (dev->mapram[0x3ea] & 0x60) != 0x20) { drawcursor = ((dev->mapram[0x3ea] & 0x1f) <= (sc >> 1)) && @@ -2350,14 +2350,14 @@ pgc_cga_text(pgc_t *dev, int w) if (dev->mapram[0x3d8] & 0x20) { cols[1] = (attr & 15) + 16; cols[0] = ((attr >> 4) & 7) + 16; - if ((dev->cgablink & 8) && (attr & 0x80) && !drawcursor) + if ((dev->cgablink & 8) && (attr & 0x80) && !drawcursor) cols[1] = cols[0]; - } else { + } else { cols[1] = (attr & 15) + 16; cols[0] = (attr >> 4) + 16; } - for (c = 0; c < cw; c++) { + for (c = 0; c < cw; c++) { if (drawcursor) val = cols[(fontdatm[chr + dev->fontbase][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; else @@ -2390,26 +2390,26 @@ pgc_cga_gfx40(pgc_t *dev) magenta/cyan/white. You still get red/cyan/white if bit 5 of port 03D9h is not set. This is a firmware issue rather than hardware. */ if (dev->mapram[0x3d9] & 32) { - cols[1] = col | 3; - cols[2] = col | 5; - cols[3] = col | 7; - } else if (dev->mapram[0x3d8] & 4) { - cols[1] = col | 3; - cols[2] = col | 4; + cols[1] = col | 3; + cols[2] = col | 5; cols[3] = col | 7; - } else { - cols[1] = col | 2; - cols[2] = col | 4; - cols[3] = col | 6; + } else if (dev->mapram[0x3d8] & 4) { + cols[1] = col | 3; + cols[2] = col | 4; + cols[3] = col | 7; + } else { + cols[1] = col | 2; + cols[2] = col | 4; + cols[3] = col | 6; } for (x = 0; x < 40; x++) { addr = &dev->cga_vram[(ma + 2 * x + 80 * (dev->displine >> 2) + 0x2000 * ((dev->displine >> 1) & 1)) & 0x3fff]; dat = (addr[0] << 8) | addr[1]; dev->ma++; - for (c = 0; c < 8; c++) { - buffer32->line[dev->displine][(x << 4) + (c << 1)] = - buffer32->line[dev->displine][(x << 4) + (c << 1) + 1] = cols[dat >> 14]; + for (c = 0; c < 8; c++) { + buffer32->line[dev->displine][(x << 4) + (c << 1)] = + buffer32->line[dev->displine][(x << 4) + (c << 1) + 1] = cols[dat >> 14]; dat <<= 2; } } @@ -2433,8 +2433,8 @@ pgc_cga_gfx80(pgc_t *dev) addr = &dev->cga_vram[(ma + 2 * x + 80 * (dev->displine >> 2) + 0x2000 * ((dev->displine >> 1) & 1)) & 0x3fff]; dat = (addr[0] << 8) | addr[1]; dev->ma++; - for (c = 0; c < 16; c++) { - buffer32->line[dev->displine][(x << 4) + c] = cols[dat >> 15]; + for (c = 0; c < 16; c++) { + buffer32->line[dev->displine][(x << 4) + c] = cols[dat >> 15]; dat <<= 1; } } @@ -2457,12 +2457,12 @@ pgc_cga_poll(pgc_t *dev) video_wait_for_buffer(); if ((dev->mapram[0x03d8] & 0x12) == 0x12) - pgc_cga_gfx80(dev); + pgc_cga_gfx80(dev); else if (dev->mapram[0x03d8] & 0x02) pgc_cga_gfx40(dev); else if (dev->mapram[0x03d8] & 0x01) pgc_cga_text(dev, 80); - else + else pgc_cga_text(dev, 40); } else { cols[0] = ((dev->mapram[0x03d8] & 0x12) == 0x12) ? 0 : ((dev->mapram[0x03d9] & 15) + 16); @@ -2492,13 +2492,13 @@ pgc_cga_poll(pgc_t *dev) if (video_force_resize_get()) video_force_resize_set(0); - } + } video_blit_memtoscreen_8(0, 0, xsize, ysize); frames++; /* We have a fixed 640x400 screen for CGA modes. */ - video_res_x = PGC_CGA_WIDTH; - video_res_y = PGC_CGA_HEIGHT; + video_res_x = PGC_CGA_WIDTH; + video_res_y = PGC_CGA_HEIGHT; switch (dev->mapram[0x3d8] & 0x12) { case 0x12: video_bpp = 1; @@ -2540,7 +2540,7 @@ pgc_poll(void *priv) video_wait_for_buffer(); /* Don't know why pan needs to be multiplied by -2, but - * the IM1024 driver uses PAN -112 for an offset of + * the IM1024 driver uses PAN -112 for an offset of * 224. */ y = dev->displine - 2 * dev->pan_y; for (x = 0; x < dev->screenw; x++) { @@ -2577,7 +2577,7 @@ pgc_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); - } + } video_blit_memtoscreen(0, 0, xsize, ysize); frames++; @@ -2648,10 +2648,10 @@ pgc_close(void *priv) /* - * Initialization code common to the PGC and its subclasses. + * Initialization code common to the PGC and its subclasses. * - * Pass the 'input byte' function in since this is overridden in - * the IM-1024, and needs to be set before the drawing thread is + * Pass the 'input byte' function in since this is overridden in + * the IM-1024, and needs to be set before the drawing thread is * launched. */ void @@ -2666,7 +2666,7 @@ pgc_init(pgc_t *dev, int maxw, int maxh, int visw, int vish, mem_mapping_add(&dev->mapping, 0xc4000, 16384, pgc_read,NULL,NULL, pgc_write,NULL,NULL, NULL, MEM_MAPPING_EXTERNAL, dev); - mem_mapping_add(&dev->cga_mapping, 0xb8000, 32768, + mem_mapping_add(&dev->cga_mapping, 0xb8000, 32768, pgc_read,NULL,NULL, pgc_write,NULL,NULL, NULL, MEM_MAPPING_EXTERNAL, dev); @@ -2705,7 +2705,7 @@ pgc_init(pgc_t *dev, int maxw, int maxh, int visw, int vish, dev->pgc_thread = thread_create(pgc_thread, dev); timer_add(&dev->timer, pgc_poll, dev, 1); - + timer_add(&dev->wake_timer, wake_timer, dev, 0); } diff --git a/src/video/vid_rtg310x.c b/src/video/vid_rtg310x.c index 4ab0a2d8b..18f577719 100644 --- a/src/video/vid_rtg310x.c +++ b/src/video/vid_rtg310x.c @@ -42,8 +42,8 @@ typedef struct { uint8_t bank3d6, bank3d7; - - uint32_t vram_size, + + uint32_t vram_size, vram_mask; } rtg_t; @@ -53,7 +53,7 @@ static video_timings_t timing_rtg_isa = {VIDEO_ISA, 3, 3, 6, 5, 5, 10}; static void rtg_recalcbanking(rtg_t *dev) { svga_t *svga = &dev->svga; - + svga->write_bank = (dev->bank3d7 & 0x0f) * 65536; if (svga->gdcreg[0x0f] & 4) @@ -76,14 +76,14 @@ rtg_in(uint16_t addr, void *priv) switch (addr) { case 0x3ce: return svga->gdcaddr; - + case 0x3cf: if (svga->gdcaddr == 0x0c) return svga->gdcreg[0x0c] | 4; else if ((svga->gdcaddr > 8) && (svga->gdcaddr != 0x0c)) return svga->gdcreg[svga->gdcaddr]; break; - + case 0x3d4: return svga->crtcreg; @@ -102,10 +102,10 @@ rtg_in(uint16_t addr, void *priv) return svga->crtc[0x1e] | ret; } return svga->crtc[svga->crtcreg]; - + case 0x3d6: return dev->bank3d6; - + case 0x3d7: return dev->bank3d7; } @@ -127,7 +127,7 @@ rtg_out(uint16_t addr, uint8_t val, void *priv) case 0x3ce: svga->gdcaddr = val; return; - + case 0x3cf: if (svga->gdcaddr > 8) { svga->gdcreg[svga->gdcaddr] = val; @@ -138,7 +138,7 @@ rtg_out(uint16_t addr, uint8_t val, void *priv) svga->fullchange = changeframecount; svga_recalctimings(svga); break; - + case 0x0f: rtg_recalcbanking(dev); return; @@ -157,7 +157,7 @@ rtg_out(uint16_t addr, uint8_t val, void *priv) val = (svga->crtc[7] & ~0x10) | (val & 0x10); old = svga->crtc[svga->crtcreg]; svga->crtc[svga->crtcreg] = val; - + if (svga->crtc[0x1e] & 0x80) { switch (svga->crtcreg) { case 0x19: @@ -181,12 +181,12 @@ rtg_out(uint16_t addr, uint8_t val, void *priv) } } break; - + case 0x3d6: dev->bank3d6 = val; rtg_recalcbanking(dev); return; - + case 0x3d7: dev->bank3d7 = val; rtg_recalcbanking(dev); @@ -203,7 +203,7 @@ rtg_recalctimings(svga_t *svga) svga->ma_latch |= ((svga->crtc[0x19] & 0x10) << 16) | ((svga->crtc[0x19] & 0x40) << 17); svga->interlace = (svga->crtc[0x19] & 1); - + svga->lowres = svga->attrregs[0x10] & 0x40; /*Clock table not available, currently a guesswork*/ @@ -230,7 +230,7 @@ rtg_recalctimings(svga_t *svga) svga->clock = (cpuclock * (double)(1ull << 32)) / 75000000.0; break; } - + switch (svga->gdcreg[0x0c] & 3) { case 1: svga->clock /= 1.5; @@ -245,7 +245,7 @@ rtg_recalctimings(svga_t *svga) if ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1)) { switch (svga->gdcreg[5] & 0x60) { - case 0x00: + case 0x00: if (svga->seqregs[1] & 8) /*Low res (320)*/ svga->render = svga_render_4bpp_lowres; else { @@ -254,7 +254,7 @@ rtg_recalctimings(svga_t *svga) svga->hdisp *= 8; if (svga->hdisp == 1280) - svga->rowoffset >>= 1; + svga->rowoffset >>= 1; svga->render = svga_render_4bpp_highres; } @@ -274,7 +274,7 @@ rtg_recalctimings(svga_t *svga) svga->hdisp >>= 1; } else svga->rowoffset <<= 1; - + svga->render = svga_render_8bpp_highres; } else { if (svga->lowres) @@ -392,4 +392,4 @@ const device_t realtek_rtg3106_device = { rtg_speed_changed, rtg_force_redraw, rtg_config -}; \ No newline at end of file +}; diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index 13eb1ad1e..08bfe4aa6 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -190,7 +190,7 @@ typedef struct s3_t mem_mapping_t linear_mapping; mem_mapping_t mmio_mapping; mem_mapping_t new_mmio_mapping; - + uint8_t has_bios; rom_t bios_rom; @@ -203,23 +203,23 @@ typedef struct s3_t int chip; int pci, vlb; int atbus; - + uint8_t id, id_ext, id_ext_pci; - + uint8_t int_line; - + int packed_mmio; - + uint32_t linear_base, linear_size; - + uint8_t pci_regs[256]; int card; uint32_t vram_mask; uint8_t data_available; - + int card_type; - + struct { uint16_t subsys_cntl; @@ -268,14 +268,14 @@ typedef struct s3_t int ssv_len; uint8_t ssv_dir; uint8_t ssv_draw; - + /*For non-threaded FIFO*/ int setup_fifo_slot; int draw_fifo_slot; int setup_fifo, setup_fifo2; int draw_fifo, draw_fifo2; } accel; - + struct { uint32_t nop; uint32_t cntl; @@ -305,7 +305,7 @@ typedef struct s3_t int odf, idf, yuv; volatile int busy; } videoengine; - + struct { uint32_t pri_ctrl; @@ -331,28 +331,28 @@ typedef struct s3_t uint32_t pri_size; uint32_t sec_start; uint32_t sec_size; - + int sdif; - + int pri_x, pri_y, pri_w, pri_h; int sec_x, sec_y, sec_w, sec_h; - } streams; + } streams; fifo_entry_t fifo[FIFO_SIZE]; volatile int fifo_read_idx, fifo_write_idx; uint8_t fifo_thread_run; - + thread_t *fifo_thread; event_t *wake_fifo_thread; event_t *fifo_not_full_event; - + int blitter_busy; uint64_t blitter_time; uint64_t status_time; - + uint8_t subsys_cntl, subsys_stat; - + uint32_t hwc_fg_col, hwc_bg_col; int hwc_col_stack_pos; @@ -406,7 +406,7 @@ dword_remap(svga_t *svga, uint32_t in_addr) { if (svga->packed_chain4) return in_addr; - + return ((in_addr << 2) & 0x3fff0) | ((in_addr >> 14) & 0xc) | (in_addr & ~0x3fffc); @@ -415,18 +415,18 @@ static __inline uint32_t dword_remap_w(svga_t *svga, uint32_t in_addr) { if (svga->packed_chain4) - return in_addr; - + return in_addr; + return ((in_addr << 2) & 0x1fff8) | ((in_addr >> 14) & 0x6) | (in_addr & ~0x1fffe); } -static __inline uint32_t +static __inline uint32_t dword_remap_l(svga_t *svga, uint32_t in_addr) { if (svga->packed_chain4) - return in_addr; - + return in_addr; + return ((in_addr << 2) & 0xfffc) | ((in_addr >> 14) & 0x3) | (in_addr & ~0xffff); @@ -463,7 +463,7 @@ s3_queue(s3_t *s3, uint32_t addr, uint32_t val, uint32_t type) fifo->addr_type = (addr & FIFO_ADDR) | type; s3->fifo_write_idx++; - + if (FIFO_ENTRIES > 0xe000 || FIFO_ENTRIES < 8) wake_fifo_thread(s3); } @@ -473,7 +473,7 @@ s3_update_irqs(s3_t *s3) { if (!s3->pci) return; - + if (s3->subsys_cntl & s3->subsys_stat & INT_MASK) { pci_set_irq(s3->card, PCI_INTA); } else { @@ -507,7 +507,7 @@ static void s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3); } else { \ temp = vram_w[dword_remap_w(svga, (s3->accel.dest + s3->accel.cx)) & (s3->vram_mask >> 1)]; \ } - + #define READ_PIXTRANS_LONG \ if (s3->bpp == 0 && !s3->color_16bit) { \ temp = svga->vram[dword_remap(svga, (s3->accel.dest + s3->accel.cx)) & s3->vram_mask]; \ @@ -524,28 +524,28 @@ s3_cpu_src(s3_t *s3) { if (!(s3->accel.cmd & 0x100)) return 0; - + if (s3->chip >= S3_VISION964) return 1; - + if (s3->accel.cmd & 1) return 1; - + return 0; } - + static int s3_cpu_dest(s3_t *s3) { if (!(s3->accel.cmd & 0x100)) return 0; - + if (s3->chip >= S3_VISION964) return 0; - + if (s3->accel.cmd & 1) return 0; - + return 1; } @@ -553,10 +553,10 @@ static int s3_enable_fifo(s3_t *s3) { svga_t *svga = &s3->svga; - + if ((s3->chip == S3_TRIO32) || (s3->chip == S3_TRIO64) || (s3->chip == S3_TRIO64V) || (s3->chip == S3_TRIO64V2) || - (s3->chip == S3_VISION864) || (s3->chip == S3_VISION964) || + (s3->chip == S3_VISION864) || (s3->chip == S3_VISION964) || (s3->chip == S3_VISION968) || (s3->chip == S3_VISION868)) return 1; /* FIFO always enabled on these chips. */ @@ -646,11 +646,11 @@ s3_accel_out_pixtrans_l(s3_t *s3, uint32_t val) if (((s3->accel.frgd_mix & 0x60) != 0x40) || ((s3->accel.bkgd_mix & 0x60) != 0x40)) { if (s3->accel.cmd & 0x1000) val = ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8); - s3_accel_start(8, 1, val, 0, s3); - s3_accel_start(8, 1, val >> 16, 0, s3); + s3_accel_start(8, 1, val, 0, s3); + s3_accel_start(8, 1, val >> 16, 0, s3); } else { s3_accel_start(1, 1, 0xffffffff, val, s3); - s3_accel_start(1, 1, 0xffffffff, val >> 16, s3); + s3_accel_start(1, 1, 0xffffffff, val >> 16, s3); } } else { s3_accel_start(1, 1, 0xffffffff, val, s3); @@ -662,11 +662,11 @@ s3_accel_out_pixtrans_l(s3_t *s3, uint32_t val) if (((s3->accel.frgd_mix & 0x60) != 0x40) || ((s3->accel.bkgd_mix & 0x60) != 0x40)) { if (s3->accel.cmd & 0x1000) val = ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8); - s3_accel_start(16, 1, val, 0, s3); - s3_accel_start(16, 1, val >> 16, 0, s3); + s3_accel_start(16, 1, val, 0, s3); + s3_accel_start(16, 1, val >> 16, 0, s3); } else { s3_accel_start(2, 1, 0xffffffff, val, s3); - s3_accel_start(2, 1, 0xffffffff, val >> 16, s3); + s3_accel_start(2, 1, 0xffffffff, val >> 16, s3); } } else { s3_accel_start(2, 1, 0xffffffff, val, s3); @@ -704,7 +704,7 @@ s3_accel_out_pixtrans_l(s3_t *s3, uint32_t val) static void s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) -{ +{ svga_t *svga = &s3->svga; switch (port) { @@ -727,7 +727,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) s3->accel.cur_y2 = (s3->accel.cur_y2 & 0xff) | ((val & 0x0f) << 8); s3->accel.poly_cy2 = s3->accel.cur_y2; break; - + case 0x8548: case 0x86e8: s3->accel.cur_x_bitres = (s3->accel.cur_x_bitres & 0xff00) | val; s3->accel.cur_x = (s3->accel.cur_x & 0xf00) | val; @@ -749,7 +749,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) s3->accel.cur_x2 = (s3->accel.cur_x2 & 0xff) | ((val & 0x0f) << 8); s3->accel.poly_cx2 = s3->accel.cur_x2 << 20; break; - + case 0xcae8: case 0x8948: case 0x8ae8: s3->accel.desty_axstp = (s3->accel.desty_axstp & 0x3f00) | val; @@ -772,7 +772,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) s3->accel.desty_axstp2 |= ~0x3fff; s3->accel.point_2_updated = 1; break; - + case 0x8d48: case 0x8ee8: s3->accel.destx_distp = (s3->accel.destx_distp & 0x3f00) | val; s3->accel.point_1_updated = 1; @@ -791,7 +791,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) s3->accel.x2 = (s3->accel.x2 & 0xff) | ((val & 0x0f) << 8); s3->accel.point_2_updated = 1; break; - + case 0x9148: case 0x92e8: s3->accel.err_term = (s3->accel.err_term & 0x3f00) | val; break; @@ -842,7 +842,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) s3->accel.cmd2 = (s3->accel.cmd2 & 0xff00) | val; break; case 0x994b: case 0x9aeb: - s3->accel.cmd2 = (s3->accel.cmd2 & 0xff) | (val << 8); + s3->accel.cmd2 = (s3->accel.cmd2 & 0xff) | (val << 8); break; case 0x9d48: case 0x9ee8: @@ -1053,7 +1053,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) case 0xb948: case 0xbae8: s3->accel.frgd_mix = val; break; - + case 0xbd48: case 0xbee8: s3->accel.multifunc_cntl = (s3->accel.multifunc_cntl & 0xff00) | val; break; @@ -1229,7 +1229,7 @@ s3_accel_out_fifo(s3_t *s3, uint16_t port, uint8_t val) s3_accel_start(2, 1, 0xffffffff, s3->accel.pix_trans[1] | (s3->accel.pix_trans[0] << 8), s3); else s3_accel_start(2, 1, 0xffffffff, s3->accel.pix_trans[0] | (s3->accel.pix_trans[1] << 8), s3); - } + } } break; case 0x400: @@ -1385,17 +1385,17 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) if ((addr >= 0x08000) && (addr <= 0x0803f)) s3_pci_write(0, addr & 0xff, val, s3); } - + switch (addr & 0x1fffe) { case 0x8100: addr = 0x82e8; break; /*ALT_CURXY*/ case 0x8102: addr = 0x86e8; break; - + case 0x8104: addr = 0x82ea; break; /*ALT_CURXY2*/ case 0x8106: addr = 0x86ea; break; - + case 0x8108: addr = 0x8ae8; break; /*ALT_STEP*/ case 0x810a: addr = 0x8ee8; break; - + case 0x810c: addr = 0x8aea; break; /*ALT_STEP2*/ case 0x810e: addr = 0x8eea; break; @@ -1404,13 +1404,13 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) case 0x8118: addr = 0x9ae8; break; /*ALT_CMD*/ case 0x811a: addr = 0x9aea; break; - + case 0x811c: addr = 0x9ee8; break; case 0x8120: case 0x8122: /*BKGD_COLOR*/ WRITE8(addr, s3->accel.bkgd_color, val); return; - + case 0x8124: case 0x8126: /*FRGD_COLOR*/ WRITE8(addr, s3->accel.frgd_color, val); return; @@ -1429,7 +1429,7 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) case 0x8134: addr = 0xb6e8; break; /*ALT_MIX*/ case 0x8136: addr = 0xbae8; break; - + case 0x8138: /*SCISSORS_T*/ WRITE8(addr & 1, s3->accel.multifunc[1], val); return; @@ -1473,10 +1473,10 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) case 0x8168: addr = 0xeae8; break; case 0x816a: addr = 0xeaea; break; - + case 0x816c: case 0x816e: WRITE8(addr, s3->accel.pat_fg_color, val); - return; + return; } addr |= addr_lo; } @@ -1515,7 +1515,7 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) case 0x8505: s3->subsys_cntl = val; s3_update_irqs(s3); - break; + break; case 0x850c: s3->accel.advfunc_cntl = val; s3_updatemapping(s3); @@ -1558,7 +1558,7 @@ s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) static void s3_accel_write_fifo_w(s3_t *s3, uint32_t addr, uint16_t val) -{ +{ svga_t *svga = &s3->svga; if (svga->crtc[0x53] & 0x08) { @@ -1706,28 +1706,28 @@ s3_accel_write_fifo_l(s3_t *s3, uint32_t addr, uint32_t val) case 0x81f0: s3->streams.pri_start = val; s3->streams.pri_x = (val >> 16) & 0x7ff; - s3->streams.pri_y = val & 0x7ff; + s3->streams.pri_y = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; case 0x81f4: s3->streams.pri_size = val; s3->streams.pri_w = (val >> 16) & 0x7ff; - s3->streams.pri_h = val & 0x7ff; + s3->streams.pri_h = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; case 0x81f8: s3->streams.sec_start = val; s3->streams.sec_x = (val >> 16) & 0x7ff; - s3->streams.sec_y = val & 0x7ff; + s3->streams.sec_y = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; case 0x81fc: s3->streams.sec_size = val; s3->streams.sec_w = (val >> 16) & 0x7ff; - s3->streams.sec_h = val & 0x7ff; + s3->streams.sec_h = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; @@ -1737,7 +1737,7 @@ s3_accel_write_fifo_l(s3_t *s3, uint32_t addr, uint32_t val) s3->subsys_cntl = (val >> 8); s3_update_irqs(s3); break; - + case 0x850c: s3->accel.advfunc_cntl = val & 0xff; s3_updatemapping(s3); @@ -1763,33 +1763,33 @@ s3_accel_write_fifo_l(s3_t *s3, uint32_t addr, uint32_t val) case 0x1808c: s3->videoengine.stretch_filt_const = val; - s3->videoengine.k2 = val & 0x7ff; + s3->videoengine.k2 = val & 0x7ff; s3->videoengine.k1 = (val >> 16) & 0x7ff; s3->videoengine.host_data = !!(val & (1 << 30)); s3->videoengine.scale_down = !!(val & (1 << 31)); break; - + case 0x18090: s3->videoengine.src_dst_step = val; s3->videoengine.dst_step = val & 0x1fff; s3->videoengine.src_step = (val >> 16) & 0x1fff; break; - + case 0x18094: s3->videoengine.crop = val; s3->videoengine.len = val & 0xfff; s3->videoengine.start = (val >> 16) & 0xfff; s3->videoengine.input = 1; break; - + case 0x18098: s3->videoengine.src_base = val & 0xffffff; break; - + case 0x1809c: s3->videoengine.dest_base = val & 0xffffff; break; - + default: s3_accel_write_fifo(s3, addr, val); s3_accel_write_fifo(s3, addr + 1, val >> 8); @@ -1862,7 +1862,7 @@ s3_hwcursor_draw(svga_t *svga, int displine) uint32_t remapped_addr; switch (svga->bpp) - { + { case 15: fg = video_15to32[s3->hwc_fg_col & 0xffff]; bg = video_15to32[s3->hwc_bg_col & 0xffff]; @@ -1875,7 +1875,7 @@ s3_hwcursor_draw(svga_t *svga, int displine) } } break; - + case 16: fg = video_16to32[s3->hwc_fg_col & 0xffff]; bg = video_16to32[s3->hwc_bg_col & 0xffff]; @@ -1892,12 +1892,12 @@ s3_hwcursor_draw(svga_t *svga, int displine) } } break; - + case 24: fg = s3->hwc_fg_col; bg = s3->hwc_bg_col; - break; - + break; + case 32: fg = s3->hwc_fg_col; bg = s3->hwc_bg_col; @@ -1925,7 +1925,7 @@ s3_hwcursor_draw(svga_t *svga, int displine) for (x = 0; x < 64; x += 16) { remapped_addr = dword_remap(svga, real_addr); - + dat[0] = (svga->vram[remapped_addr & s3->vram_mask] << 8) | svga->vram[(remapped_addr + 1) & s3->vram_mask]; dat[1] = (svga->vram[(remapped_addr + 2) & s3->vram_mask] << 8) | svga->vram[(remapped_addr + 3) & s3->vram_mask]; @@ -1943,7 +1943,7 @@ s3_hwcursor_draw(svga_t *svga, int displine) } } else { /*Windows*/ - for (xx = 0; xx < width; xx++) { + for (xx = 0; xx < width; xx++) { if (offset >= 0) { if (!(dat[0] & 0x8000)) buffer32->line[displine][offset + svga->x_add] = (dat[1] & 0x8000) ? fg : bg; @@ -2217,7 +2217,7 @@ static void s3_trio64v_overlay_draw(svga_t *svga, int displine) x_size = s3->streams.sec_w + 1; OVERLAY_SAMPLE(); - + for (x = 0; x < x_size; x++) { *p++ = r[x_read] | (g[x_read] << 8) | (b[x_read] << 16); @@ -2318,7 +2318,7 @@ static void s3_io_set_alt(s3_t *s3) { svga_t *svga = &s3->svga; - + if (!s3->translate) return; @@ -2376,7 +2376,7 @@ static void s3_io_set(s3_t *s3) { svga_t *svga = &s3->svga; - + s3_io_remove(s3); io_sethandler(0x03c0, 0x0020, s3_in, NULL, NULL, s3_out, NULL, NULL, s3); @@ -2431,7 +2431,7 @@ s3_io_set(s3_t *s3) io_sethandler(0xeee8, 0x0004, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); } io_sethandler(0xfee8, 0x0002, s3_accel_in, NULL, NULL, s3_accel_out, NULL, NULL, s3); - + s3_io_set_alt(s3); } @@ -2443,7 +2443,7 @@ s3_out(uint16_t addr, uint8_t val, void *p) uint8_t old, mask; int rs2, rs3; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) @@ -2493,7 +2493,7 @@ s3_out(uint16_t addr, uint8_t val, void *p) } } break; - + case 0x3C6: case 0x3C7: case 0x3C8: case 0x3C9: if ((svga->crtc[0x55] & 0x03) == 0x00) rs2 = !!(svga->crtc[0x43] & 0x02); @@ -2579,7 +2579,7 @@ s3_out(uint16_t addr, uint8_t val, void *p) } s3->bpp = (svga->crtc[0x50] >> 4) & 3; break; - + case 0x5c: if ((val & 0xa0) == 0x80) i2c_gpio_set(s3->i2c, !!(val & 0x40), !!(val & 0x10)); @@ -2591,7 +2591,7 @@ s3_out(uint16_t addr, uint8_t val, void *p) svga->dac_addr |= 0x02; } break; - + case 0x69: if (s3->chip >= S3_VISION964) s3->ma_ext = val & 0x1f; @@ -2764,7 +2764,7 @@ s3_in(uint16_t addr, void *p) int rs2, rs3; uint8_t temp; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) @@ -2773,7 +2773,7 @@ s3_in(uint16_t addr, void *p) if (svga->attraddr > 0x14) return 0xff; break; - + case 0x3c2: if (s3->chip <= S3_86C924) return svga_in(addr, svga) | 0x10; @@ -2789,7 +2789,7 @@ s3_in(uint16_t addr, void *p) return temp; } break; - + case 0x3c6: case 0x3c7: case 0x3c8: case 0x3c9: rs2 = (svga->crtc[0x55] & 0x01) || !!(svga->crtc[0x43] & 2); if (s3->chip >= S3_TRIO32) @@ -2797,7 +2797,7 @@ s3_in(uint16_t addr, void *p) else if ((s3->chip == S3_VISION964 && s3->card_type != S3_ELSAWIN2KPROX_964) || (s3->chip == S3_86C928)) { rs3 = !!(svga->crtc[0x55] & 0x02); return bt48x_ramdac_in(addr, rs2, rs3, svga->ramdac, svga); - } else if ((s3->chip == S3_VISION964 && s3->card_type == S3_ELSAWIN2KPROX_964) || (s3->chip == S3_VISION968 && (s3->card_type == S3_ELSAWIN2KPROX || + } else if ((s3->chip == S3_VISION964 && s3->card_type == S3_ELSAWIN2KPROX_964) || (s3->chip == S3_VISION968 && (s3->card_type == S3_ELSAWIN2KPROX || s3->card_type == S3_PHOENIX_VISION968 || s3->card_type == S3_NUMBER9_9FX_771))) return ibm_rgb528_ramdac_in(addr, rs2, svga->ramdac, svga); else if ((s3->chip == S3_VISION968 && (s3->card_type == S3_SPEA_MERCURY_P64V || s3->card_type == S3_MIROVIDEO40SV_ERGO_968))) { @@ -2808,7 +2808,7 @@ s3_in(uint16_t addr, void *p) else if (s3->chip <= S3_86C924) return sc1148x_ramdac_in(addr, rs2, svga->ramdac, svga); else if (s3->card_type == S3_NUMBER9_9FX_531) - return att498_ramdac_in(addr, rs2, svga->ramdac, svga); + return att498_ramdac_in(addr, rs2, svga->ramdac, svga); else if ((s3->chip == S3_86C928PCI) && (s3->card_type == S3_SPEA_MERCURY_LITE_PCI)) return sc1502x_ramdac_in(addr, svga->ramdac, svga); else @@ -2882,7 +2882,7 @@ static void s3_recalctimings(svga_t *svga) } } } - + svga->ma_latch |= (s3->ma_ext << 16); if (s3->chip >= S3_86C928) { svga->hdisp = svga->hdisp_old; @@ -2919,15 +2919,15 @@ static void s3_recalctimings(svga_t *svga) clk_sel = svga->crtc[0x42] & 0x0f; svga->clock = (cpuclock * (double)(1ull << 32)) / svga->getclock(clk_sel, svga->clock_gen); - + switch (svga->crtc[0x67] >> 4) { case 3: case 5: case 7: svga->clock /= 2; break; } - + svga->lowres = !((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)); - + if (s3->card_type == S3_MIROCRYSTAL10SD_805 || s3->card_type == S3_MIROCRYSTAL20SD_864 || s3->card_type == S3_MIROCRYSTAL20SV_964 || s3->card_type == S3_SPEA_MIRAGE_86C801 || s3->card_type == S3_SPEA_MIRAGE_86C805 || s3->card_type == S3_MIROCRYSTAL8S_805 || @@ -2956,7 +2956,7 @@ static void s3_recalctimings(svga_t *svga) s3->width = 1024; } } - + if ((svga->crtc[0x43] & 0x08) && (s3->color_16bit == 0) && (s3->chip <= S3_86C805)) { s3->color_16bit = 1; s3->width = 1024; @@ -2988,7 +2988,7 @@ static void s3_recalctimings(svga_t *svga) svga->hdisp <<= 1; } else if (s3->card_type == S3_NUMBER9_9FX_771) svga->hdisp <<= 1; - + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_MIROCRYSTAL20SD_864 || s3->card_type == S3_PHOENIX_VISION968 || s3->card_type == S3_SPEA_MERCURY_P64V) { if (svga->hdisp != 1408) @@ -3000,25 +3000,25 @@ static void s3_recalctimings(svga_t *svga) case 480: svga->hdisp = 640; break; - + case 576: svga->hdisp = 768; break; - + case 600: if (s3->width == 1600) s3->width = 800; svga->hdisp = 800; break; - + case 768: svga->hdisp = 1024; break; - + case 864: svga->hdisp = 1152; break; - + case 1024: if (svga->vtotal == 1066) svga->hdisp = 1280; @@ -3035,7 +3035,7 @@ static void s3_recalctimings(svga_t *svga) break; case 15: svga->render = svga_render_15bpp_highres; - if ((s3->chip != S3_VISION964) && (s3->card_type != S3_SPEA_MIRAGE_86C801) && + if ((s3->chip != S3_VISION964) && (s3->card_type != S3_SPEA_MIRAGE_86C801) && (s3->card_type != S3_SPEA_MIRAGE_86C805)) { if (s3->chip == S3_86C928) svga->hdisp <<= 1; @@ -3049,21 +3049,21 @@ static void s3_recalctimings(svga_t *svga) else if (s3->card_type == S3_NUMBER9_9FX_771) svga->hdisp <<= 1; } - if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_PHOENIX_VISION968 || + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_PHOENIX_VISION968 || s3->card_type == S3_SPEA_MERCURY_P64V) { if (svga->hdisp == (1408*2)) svga->hdisp >>= 1; else svga->hdisp = s3->width; } - - if (s3->card_type == S3_SPEA_MIRAGE_86C801 || s3->card_type == S3_SPEA_MIRAGE_86C805 || + + if (s3->card_type == S3_SPEA_MIRAGE_86C801 || s3->card_type == S3_SPEA_MIRAGE_86C805 || s3->card_type == S3_SPEA_MERCURY_LITE_PCI) svga->hdisp = s3->width; break; case 16: svga->render = svga_render_16bpp_highres; - if ((s3->chip != S3_VISION964) && (s3->card_type != S3_SPEA_MIRAGE_86C801) && + if ((s3->chip != S3_VISION964) && (s3->card_type != S3_SPEA_MIRAGE_86C801) && (s3->card_type != S3_SPEA_MIRAGE_86C805)) { if (s3->chip == S3_86C928) svga->hdisp <<= 1; @@ -3085,8 +3085,8 @@ static void s3_recalctimings(svga_t *svga) else svga->hdisp = s3->width; } - - if (s3->card_type == S3_SPEA_MIRAGE_86C801 || s3->card_type == S3_SPEA_MIRAGE_86C805 || + + if (s3->card_type == S3_SPEA_MIRAGE_86C801 || s3->card_type == S3_SPEA_MIRAGE_86C805 || s3->card_type == S3_SPEA_MERCURY_LITE_PCI) svga->hdisp = s3->width; break; @@ -3097,7 +3097,7 @@ static void s3_recalctimings(svga_t *svga) svga->hdisp /= 3; else svga->hdisp = (svga->hdisp * 2) / 3; - + if (s3->card_type == S3_SPEA_MERCURY_LITE_PCI) { if (s3->width == 2048) switch (svga->dispend) { @@ -3107,7 +3107,7 @@ static void s3_recalctimings(svga_t *svga) } } } else { - if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_PHOENIX_VISION968 || + if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_PHOENIX_VISION968 || s3->card_type == S3_SPEA_MERCURY_P64V) svga->hdisp = s3->width; } @@ -3121,11 +3121,11 @@ static void s3_recalctimings(svga_t *svga) else svga->hdisp >>= 2; } - if (s3->width == 1280 || s3->width == 1600 || (s3->card_type == S3_SPEA_MERCURY_P64V || + if (s3->width == 1280 || s3->width == 1600 || (s3->card_type == S3_SPEA_MERCURY_P64V || s3->card_type == S3_NUMBER9_9FX_771)) svga->hdisp <<= 1; if (s3->card_type == S3_MIROVIDEO40SV_ERGO_968 || s3->card_type == S3_MIROCRYSTAL20SV_964 || - s3->card_type == S3_MIROCRYSTAL20SD_864 || s3->card_type == S3_PHOENIX_VISION968 || + s3->card_type == S3_MIROCRYSTAL20SD_864 || s3->card_type == S3_PHOENIX_VISION968 || s3->card_type == S3_SPEA_MERCURY_P64V) { svga->hdisp = s3->width; if (s3->card_type == S3_MIROCRYSTAL20SD_864 || s3->card_type == S3_MIROCRYSTAL20SV_964) { @@ -3135,16 +3135,16 @@ static void s3_recalctimings(svga_t *svga) case 480: svga->hdisp = 640; break; - + case 576: if (s3->width == 1600) s3->width = 800; svga->hdisp = 768; break; - + case 600: if (s3->width == 1600) - s3->width = 800; + s3->width = 800; svga->hdisp = 800; break; } @@ -3195,7 +3195,7 @@ static void s3_trio64v_recalctimings(svga_t *svga) if (svga->crtc[0x5e] & 0x10) svga->vsyncstart |= 0x400; if (svga->crtc[0x5e] & 0x40) svga->split |= 0x400; svga->interlace = svga->crtc[0x42] & 0x20; - + svga->clock = (cpuclock * (double)(1ull << 32)) / svga->getclock(clk_sel, svga->clock_gen); if ((svga->crtc[0x67] & 0xc) != 0xc) /*VGA mode*/ @@ -3204,7 +3204,7 @@ static void s3_trio64v_recalctimings(svga_t *svga) if (svga->crtc[0x51] & 0x30) svga->rowoffset |= (svga->crtc[0x51] & 0x30) << 4; else if (svga->crtc[0x43] & 0x04) svga->rowoffset |= 0x100; if (!svga->rowoffset) svga->rowoffset = 256; - + svga->lowres = !((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)); if ((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)) { @@ -3217,7 +3217,7 @@ static void s3_trio64v_recalctimings(svga_t *svga) svga->render = svga_render_15bpp_highres; svga->hdisp >>= 1; break; - case 16: + case 16: svga->render = svga_render_16bpp_highres; svga->hdisp >>= 1; break; @@ -3235,16 +3235,16 @@ static void s3_trio64v_recalctimings(svga_t *svga) else /*Streams mode*/ { svga->fb_only = 1; - + if (s3->streams.buffer_ctrl & 1) svga->ma_latch = s3->streams.pri_fb1 >> 2; else svga->ma_latch = s3->streams.pri_fb0 >> 2; - + svga->hdisp = s3->streams.pri_w + 1; if (s3->streams.pri_h < svga->dispend) svga->dispend = s3->streams.pri_h; - + svga->overlay.x = s3->streams.sec_x - s3->streams.pri_x; svga->overlay.y = s3->streams.sec_y - s3->streams.pri_y; svga->overlay.ysize = s3->streams.sec_h; @@ -3261,18 +3261,18 @@ static void s3_trio64v_recalctimings(svga_t *svga) switch ((s3->streams.pri_ctrl >> 24) & 0x7) { case 0: /*RGB-8 (CLUT)*/ - svga->render = svga_render_8bpp_highres; + svga->render = svga_render_8bpp_highres; break; - case 3: /*KRGB-16 (1.5.5.5)*/ + case 3: /*KRGB-16 (1.5.5.5)*/ svga->htotal >>= 1; - svga->render = svga_render_15bpp_highres; + svga->render = svga_render_15bpp_highres; break; - case 5: /*RGB-16 (5.6.5)*/ + case 5: /*RGB-16 (5.6.5)*/ svga->htotal >>= 1; - svga->render = svga_render_16bpp_highres; + svga->render = svga_render_16bpp_highres; break; - case 6: /*RGB-24 (8.8.8)*/ - svga->render = svga_render_24bpp_highres; + case 6: /*RGB-24 (8.8.8)*/ + svga->render = svga_render_24bpp_highres; break; case 7: /*XRGB-32 (X.8.8.8)*/ svga->render = svga_render_32bpp_highres; @@ -3376,7 +3376,7 @@ s3_updatemapping(s3_t *s3) } else if (s3->chip == S3_VISION968 || s3->chip == S3_VISION868) { s3->linear_base &= 0xfe000000; } - + mem_mapping_set_addr(&s3->linear_mapping, s3->linear_base, s3->linear_size); } } else { @@ -3397,7 +3397,7 @@ s3_updatemapping(s3_t *s3) } else { mem_mapping_disable(&s3->mmio_mapping); } - + /* New MMIO. */ if (svga->crtc[0x53] & 0x08) mem_mapping_set_addr(&s3->new_mmio_mapping, s3->linear_base + 0x1000000, 0x20000); @@ -3458,7 +3458,7 @@ s3_accel_out(uint16_t port, uint8_t val, void *p) svga_recalctimings(svga); } else if (s3->chip <= S3_86C805) { svga->fullchange = changeframecount; - svga_recalctimings(svga); + svga_recalctimings(svga); } if (s3->chip > S3_86C924) s3_updatemapping(s3); @@ -3473,7 +3473,7 @@ s3_accel_out_w(uint16_t port, uint16_t val, void *p) s3_t *s3 = (s3_t *)p; if (!s3->enable_8514) - return; + return; if (s3_enable_fifo(s3)) s3_queue(s3, port, val, FIFO_OUT_WORD); @@ -3487,7 +3487,7 @@ s3_accel_out_l(uint16_t port, uint32_t val, void *p) s3_t *s3 = (s3_t *)p; if (!s3->enable_8514) - return; + return; if (s3_enable_fifo(s3)) s3_queue(s3, port, val, FIFO_OUT_DWORD); @@ -3543,7 +3543,7 @@ s3_accel_in(uint16_t port, void *p) return s3->accel.desty_axstp >> 8; } break; - + case 0x8d48: case 0x8ee8: if (s3->chip >= S3_86C928) { if (s3_enable_fifo(s3)) @@ -3596,8 +3596,8 @@ s3_accel_in(uint16_t port, void *p) temp = 0; if (s3_enable_fifo(s3)) { if (!s3->blitter_busy) - wake_fifo_thread(s3); - + wake_fifo_thread(s3); + if (!FIFO_EMPTY || s3->force_busy) temp |= 0x02; /*Hardware busy*/ else @@ -3838,7 +3838,7 @@ s3_accel_in(uint16_t port, void *p) if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); return s3->accel.pat_bg_color >> 16; - + case 0xe54b: case 0xe6eb: if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); @@ -3853,12 +3853,12 @@ s3_accel_in(uint16_t port, void *p) if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); return s3->accel.pat_y >> 8; - + case 0xe94a: case 0xeaea: if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); return s3->accel.pat_x & 0xff; - + case 0xe94b: case 0xeaeb: if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); @@ -3878,7 +3878,7 @@ s3_accel_in(uint16_t port, void *p) if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); return s3->accel.pat_fg_color >> 16; - + case 0xed4b: case 0xeeeb: if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); @@ -3886,7 +3886,7 @@ s3_accel_in(uint16_t port, void *p) case 0xe148: case 0xe2e8: if (!s3_cpu_dest(s3)) - break; + break; READ_PIXTRANS_BYTE_IO(0) if (s3->accel.cmd & 0x100) { switch (s3->accel.cmd & 0x600) { @@ -3912,7 +3912,7 @@ s3_accel_in(uint16_t port, void *p) } } return s3->accel.pix_trans[0]; - + case 0xe149: case 0xe2e9: if (!s3_cpu_dest(s3)) break; @@ -3951,13 +3951,13 @@ s3_accel_in(uint16_t port, void *p) } } return s3->accel.pix_trans[1]; - + case 0xe14a: case 0xe2ea: if (!s3_cpu_dest(s3)) break; READ_PIXTRANS_BYTE_IO(2); return s3->accel.pix_trans[2]; - + case 0xe14b: case 0xe2eb: if (!s3_cpu_dest(s3)) break; @@ -3994,7 +3994,7 @@ s3_accel_in(uint16_t port, void *p) temp |= SERIAL_PORT_SDR; return temp; } - + return 0xff; } @@ -4008,7 +4008,7 @@ s3_accel_in_w(uint16_t port, void *p) if (!s3->enable_8514) return 0xffff; - + if (port != 0x9ee8 && port != 0x9d48) { if (s3_cpu_dest(s3)) { READ_PIXTRANS_WORD @@ -4078,7 +4078,7 @@ s3_accel_in_l(uint16_t port, void *p) s3_accel_start(8, 1, temp >> 16, 0, s3); } else { s3_accel_start(1, 1, 0xffffffff, temp, s3); - s3_accel_start(1, 1, 0xffffffff, temp >> 16, s3); + s3_accel_start(1, 1, 0xffffffff, temp >> 16, s3); } } else { s3_accel_start(1, 1, 0xffffffff, temp, s3); @@ -4094,7 +4094,7 @@ s3_accel_in_l(uint16_t port, void *p) s3_accel_start(16, 1, temp >> 16, 0, s3); } else { s3_accel_start(2, 1, 0xffffffff, temp, s3); - s3_accel_start(2, 1, 0xffffffff, temp >> 16, s3); + s3_accel_start(2, 1, 0xffffffff, temp >> 16, s3); } } else { s3_accel_start(2, 1, 0xffffffff, temp, s3); @@ -4103,7 +4103,7 @@ s3_accel_in_l(uint16_t port, void *p) break; } } - + return temp; } @@ -4116,7 +4116,7 @@ s3_accel_write(uint32_t addr, uint8_t val, void *p) if (!s3->enable_8514) return; - + if (s3_enable_fifo(s3)) { if (svga->crtc[0x53] & 0x08) s3_queue(s3, addr & 0x1ffff, val, FIFO_WRITE_BYTE); @@ -4239,14 +4239,14 @@ s3_accel_read_w(uint32_t addr, void *p) if (!s3->enable_8514) return 0xffff; - + if (svga->crtc[0x53] & 0x08) { switch (addr & 0x1fffe) { case 0x811c: if (s3_enable_fifo(s3)) s3_wait_fifo_idle(s3); return s3->accel.short_stroke; - + default: return s3_accel_read(addr, p) | s3_accel_read(addr + 1, p) << 8; @@ -4445,7 +4445,7 @@ s3_accel_read_l(uint32_t addr, void *p) s3_accel_start(8, 1, temp >> 16, 0, s3); } else { s3_accel_start(1, 1, 0xffffffff, temp, s3); - s3_accel_start(1, 1, 0xffffffff, temp >> 16, s3); + s3_accel_start(1, 1, 0xffffffff, temp >> 16, s3); } } else { s3_accel_start(1, 1, 0xffffffff, temp, s3); @@ -4456,10 +4456,10 @@ s3_accel_read_l(uint32_t addr, void *p) if (((s3->accel.multifunc[0xa] & 0xc0) == 0x80) || (s3->accel.cmd & 2)) { if (((s3->accel.frgd_mix & 0x60) != 0x40) || ((s3->accel.bkgd_mix & 0x60) != 0x40)) { s3_accel_start(16, 1, temp, 0, s3); - s3_accel_start(16, 1, temp >> 16, 0, s3); + s3_accel_start(16, 1, temp >> 16, 0, s3); } else { s3_accel_start(2, 1, 0xffffffff, temp, s3); - s3_accel_start(2, 1, 0xffffffff, temp >> 16, s3); + s3_accel_start(2, 1, 0xffffffff, temp >> 16, s3); } } else { s3_accel_start(2, 1, 0xffffffff, temp, s3); @@ -4482,12 +4482,12 @@ polygon_setup(s3_t *s3) int start_y = s3->accel.poly_cy; int end_x = s3->accel.destx_distp << 20; int end_y = s3->accel.desty_axstp; - + if (end_y - start_y) s3->accel.poly_dx1 = (end_x - start_x) / (end_y - start_y); else s3->accel.poly_dx1 = 0; - + s3->accel.point_1_updated = 0; if (end_y == s3->accel.poly_cy) @@ -4503,13 +4503,13 @@ polygon_setup(s3_t *s3) int end_x = s3->accel.x2 << 20; int end_y = s3->accel.desty_axstp2; - if (end_y - start_y) + if (end_y - start_y) s3->accel.poly_dx2 = (end_x - start_x) / (end_y - start_y); else s3->accel.poly_dx2 = 0; s3->accel.point_2_updated = 0; - + if (end_y == s3->accel.poly_cy) s3->accel.poly_cx2 = end_x; } @@ -4849,7 +4849,7 @@ convert_to_rgb32(int idf, int is_yuv, uint32_t val, uint8_t *r, uint8_t *g, uint static double dr = 0.0, dg = 0.0, db = 0.0; static double dY1 = 0.0, dCr = 0.0, dY2 = 0.0, dCb = 0.0; static double dU = 0.0, dV = 0.0; - + switch (idf) { case 0: /* 8 bpp, RGB 3-3-2 */ dr = (double) ((val >> 5) & 0x07); @@ -4872,7 +4872,7 @@ convert_to_rgb32(int idf, int is_yuv, uint32_t val, uint8_t *r, uint8_t *g, uint dV = ((double) ((val >> 16) & 0xff)) - 128.0; dY2 = (double) ((val >> 24) & 0xff); dY2 = (298.0 * (dY2 - 16.0)) / 256.0; - + dr = (309.0 * dV) / 256.0; dg = ((100.0 * dU) + (208.0 * dV)) / 256.0; db = (516.0 * dU) / 256.0; @@ -4881,19 +4881,19 @@ convert_to_rgb32(int idf, int is_yuv, uint32_t val, uint8_t *r, uint8_t *g, uint dCr = ((double) ((val >> 8) & 0xff)) - 128.0; dY2 = (double) ((val >> 16) & 0xff); dCb = ((double) ((val >> 24) & 0xff)) - 128.0; - + dr = (359.0 * dCr) / 256.0; dg = ((88.0 * dCb) + (183.0 * dCr)) / 2560.0; db = (453.0 * dCr) / 256.0; } - + *r = (uint8_t) round(dY1 + dr); CLAMP(*r); *g = (uint8_t) round(dY1 - dg); CLAMP(*g); *b = (uint8_t) round(dY1 + db); CLAMP(*b); - + *r2 = (uint8_t) round(dY2 + dr); CLAMP(*r2); *g2 = (uint8_t) round(dY2 - dg); @@ -4919,13 +4919,13 @@ convert_to_rgb32(int idf, int is_yuv, uint32_t val, uint8_t *r, uint8_t *g, uint db = (db / 31.0) * 255.0; break; } - + *r = (uint8_t) round(dr); *g = (uint8_t) round(dg); *b = (uint8_t) round(db); } - - + + static __inline void convert_from_rgb32(int idf, int odf, int is_yuv, uint32_t *val, uint8_t r, uint8_t g, uint8_t b, uint8_t r2, uint8_t g2, uint8_t b2) { @@ -4933,11 +4933,11 @@ convert_from_rgb32(int idf, int odf, int is_yuv, uint32_t *val, uint8_t r, uint8 static double dr2 = 0.0, dg2 = 0.0, db2 = 0.0; static double dY1 = 0.0, dCr = 0.0, dY2 = 0.0, dCb = 0.0; static double dU = 0.0, dV = 0.0; - + dr = (double) r; dg = (double) g; db = (double) b; - + switch (odf) { case 0: /* 8 bpp, RGB 3-3-2 */ switch (idf) { @@ -4955,7 +4955,7 @@ convert_from_rgb32(int idf, int odf, int is_yuv, uint32_t *val, uint8_t r, uint8 dr = (dr / 255.0) * 31.0; dg = (dg / 255.0) * 31.0; db = (db / 255.0) * 31.0; - *val = (((uint32_t) round(dr)) << 10) + (((uint32_t) round(dg)) << 5) + ((uint32_t) round(db)); + *val = (((uint32_t) round(dr)) << 10) + (((uint32_t) round(dg)) << 5) + ((uint32_t) round(db)); break; case 0: default: @@ -4973,20 +4973,20 @@ convert_from_rgb32(int idf, int odf, int is_yuv, uint32_t *val, uint8_t r, uint8 dr2 = (double) r2; dg2 = (double) g2; db2 = (double) b2; - + if (is_yuv) { dU = ((113046.0 * dg2) - (71552.0 * dr2) - (69488.0 * db2)) / 28509.0; dV = ((3328.0 * dr2) + (800.0 * db2) - (4128.0 * dg2)) / 663.0; dY1 = dr - ((309 * dV) / 256.0); dY2 = dr2 - ((309 * dV) / 256.0); - + *val = ((uint32_t) round(dU)) + (((uint32_t) round(dY1)) << 8) + (((uint32_t) round(dV)) << 16) + (((uint32_t) round(dY2)) << 24); } else { dCr = ((128.0 * db2) - (128.0 * dr2)) / 47.0; dCb = ((128.0 * dr2) - (128.0 * dg2) - (271.0 * dCr)) / 44.0; dY1 = dr - ((359.0 * dCr) / 256.0); dY2 = dr2 - ((359.0 * dCr) / 256.0); - + *val = ((uint32_t) round(dY1)) + (((uint32_t) round(dCr)) << 8) + (((uint32_t) round(dY2)) << 16) + (((uint32_t) round(dCb)) << 24); } return; @@ -5030,7 +5030,7 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) diff = 0xff - k2; s3->videoengine.busy = 1; - + if (host) { if (idf == 0 && odf == 0) { if (s3->bpp == 0) @@ -5068,7 +5068,7 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) s3->videoengine.sx_scale++; } } - + if (s3->bpp == 0) { s3->videoengine.dest = s3->videoengine.dest_base + s3->width; s3->videoengine.src = s3->videoengine.src_base + s3->width; @@ -5090,14 +5090,14 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) } else { /*Source data is display memory*/ READ(s3->videoengine.src + lround(s3->videoengine.cx), src); } - + convert_to_rgb32(idf, is_yuv, src, &r, &g, &b, &r2, &g2, &b2); convert_from_rgb32(idf, odf, is_yuv, &dest, r, g, b, r2, g2, b2); - + WRITE(s3->videoengine.dest + lround(s3->videoengine.dx), dest); - - if (s3->videoengine.scale_down) { /*Data shrink*/ + + if (s3->videoengine.scale_down) { /*Data shrink*/ s3->videoengine.dx += s3->videoengine.sx_scale_inc; if (!host) s3->videoengine.cx += s3->videoengine.sx_scale_inc; @@ -5123,7 +5123,7 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) } s3->videoengine.sx_scale_inc = (double)((s3->videoengine.sx_backup >> 1)); s3->videoengine.sx_scale_inc = s3->videoengine.sx_scale_inc / (double)((s3->videoengine.sx >> 1)); - + s3->videoengine.cx = 0.0; s3->videoengine.dx = 0.0; @@ -5137,7 +5137,7 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) s3->videoengine.dest = (s3->videoengine.dest_base >> 2) + s3->width; s3->videoengine.src = (s3->videoengine.src_base >> 2) + s3->width; } - + if (s3->videoengine.input >= 1) { s3->videoengine.busy = 0; return; @@ -5145,16 +5145,16 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) } } else { /*Data stretch*/ s3->videoengine.dx++; - + s3->videoengine.sx_scale -= s3->videoengine.sx_scale_dec; s3->videoengine.sx_scale_backup = (s3->videoengine.sx_scale - s3->videoengine.sx_scale_dec); s3->videoengine.sx = lround(s3->videoengine.sx_scale); s3->videoengine.sx_scale_int = lround(s3->videoengine.sx_scale_backup); - + if (s3->videoengine.sx > s3->videoengine.sx_scale_int) { if (host) { - if (s3->bpp == 0) + if (s3->bpp == 0) cpu_dat >>= 8; else cpu_dat >>= 16; @@ -5167,11 +5167,11 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) if (s3->videoengine.sx < 0) { s3->videoengine.sx_scale = (double)(s3->videoengine.k1 - 2); s3->videoengine.sx_scale_dec = (s3->videoengine.sx_scale / (double)(s3->videoengine.len - s3->videoengine.start - 2)); - + if (s3->videoengine.sx_scale_dec >= 0.5) { s3->videoengine.sx_scale++; } - + s3->videoengine.cx = 0.0; s3->videoengine.dx = 0.0; @@ -5185,7 +5185,7 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) s3->videoengine.dest = (s3->videoengine.dest_base >> 2) + s3->width; s3->videoengine.src = (s3->videoengine.src_base >> 2) + s3->width; } - + if (s3->videoengine.input >= 1) { s3->videoengine.busy = 0; return; @@ -5197,7 +5197,7 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) void s3_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_t *s3, uint8_t ssv) -{ +{ if (!cpu_input) { s3->accel.ssv_len = ssv & 0x0f; s3->accel.ssv_dir = ssv & 0xe0; @@ -5207,7 +5207,7 @@ s3_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_d return; /*Wait for data from CPU*/ } } - + s3_accel_start(count, cpu_input, mix_dat, cpu_dat, s3); } @@ -5232,7 +5232,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ uint32_t rd_mask = s3->accel.rd_mask; int cmd = s3->accel.cmd >> 13; uint32_t srcbase, dstbase; - + if ((s3->chip >= S3_TRIO64 || s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (s3->accel.cmd & (1 << 11))) { cmd |= 8; } @@ -5297,7 +5297,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ } /*Bit 4 of the Command register is the draw yes bit, which enables writing to memory/reading from memory when enabled. - When this bit is disabled, no writing to memory/reading from memory is allowed. (This bit is almost meaningless on + When this bit is disabled, no writing to memory/reading from memory is allowed. (This bit is almost meaningless on the NOP command)*/ switch (cmd) { @@ -5309,7 +5309,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ bkgd_mix = (s3->accel.bkgd_mix >> 5) & 3; if (s3->accel.cmd & 8) /*Radial*/ - { + { while (count-- && s3->accel.ssv_len >= 0) { if ((s3->accel.cx & 0xfff) >= clip_l && (s3->accel.cx & 0xfff) <= clip_r && @@ -5328,7 +5328,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ compare_mode < 2) { READ((s3->accel.cy * s3->width) + s3->accel.cx, dest_dat); - + MIX if (s3->accel.ssv_draw) { @@ -5363,7 +5363,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.cur_y = s3->accel.cy; } break; - + case 1: /*Draw line*/ if (!cpu_input) { s3->accel.cx = s3->accel.cur_x; @@ -5414,7 +5414,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ else { cpu_dat >>= 16; } - + if (!s3->accel.sy) { break; } @@ -5441,14 +5441,14 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ count = s3->accel.maj_axis_pcnt + 1; s3->accel.temp_cnt = 16; } - + while (count-- && s3->accel.sy >= 0) { if (s3->accel.b2e8_pix && s3_cpu_src(s3) && s3->accel.temp_cnt == 0) { mix_dat >>= 16; s3->accel.temp_cnt = 16; } - + if ((s3->accel.cx & 0xfff) >= clip_l && (s3->accel.cx & 0xfff) <= clip_r && (s3->accel.cy & 0xfff) >= clip_t && (s3->accel.cy & 0xfff) <= clip_b) { @@ -5468,7 +5468,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ MIX - WRITE((s3->accel.cy * s3->width) + s3->accel.cx, dest_dat); + WRITE((s3->accel.cy * s3->width) + s3->accel.cx, dest_dat); } } @@ -5491,7 +5491,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ if (!s3->accel.sy) { break; } - + if (s3->accel.err_term >= s3->accel.maj_axis_pcnt) { s3->accel.err_term += s3->accel.destx_distp; /*Step minor axis*/ @@ -5509,7 +5509,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ } else { s3->accel.err_term += s3->accel.desty_axstp; } - + /*Step major axis*/ switch (s3->accel.cmd & 0xe0) { @@ -5528,7 +5528,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.cur_y = s3->accel.cy; } break; - + case 2: /*Rectangle fill*/ if (!cpu_input) /*!cpu_input is trigger to start operation*/ { @@ -5536,7 +5536,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.sy = s3->accel.multifunc[0] & 0xfff; s3->accel.cx = s3->accel.cur_x; s3->accel.cy = s3->accel.cur_y; - + if (s3->accel.cur_x_bit12) { if (s3->accel.cx <= 0x7ff) { s3->accel.cx = s3->accel.cur_x_bitres & 0xfff; @@ -5550,7 +5550,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ } else { s3->accel.cy |= ~0xfff; } - } + } s3->accel.dest = dstbase + s3->accel.cy * s3->width; @@ -5609,7 +5609,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ READ(s3->accel.dest + s3->accel.cx, dest_dat); MIX - + if (s3->accel.cmd & 0x10) { WRITE(s3->accel.dest + s3->accel.cx, dest_dat); } @@ -5626,13 +5626,13 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ mix_dat <<= 1; mix_dat |= 1; } - + if (s3->bpp == 0 && !s3->color_16bit) cpu_dat >>= 8; else { cpu_dat >>= 16; } - + if (s3->accel.cmd & 0x20) s3->accel.cx++; else @@ -5649,7 +5649,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ if (s3->accel.cmd & 0x80) s3->accel.cy++; - else + else s3->accel.cy--; s3->accel.dest = dstbase + s3->accel.cy * s3->width; @@ -5673,16 +5673,16 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ case 3: /*Polygon Fill Solid (Vision868/968 and Trio64 only)*/ - { + { int end_y1, end_y2; - + if (s3->chip != S3_TRIO64 && s3->chip != S3_VISION968 && s3->chip != S3_VISION868) break; polygon_setup(s3); if ((s3->accel.cmd & 0x100) && !cpu_input) return; /*Wait for data from CPU*/ - + end_y1 = s3->accel.desty_axstp; end_y2 = s3->accel.desty_axstp2; @@ -5694,7 +5694,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ int x_count = ABS((s3->accel.poly_cx2 >> 20) - s3->accel.poly_x) + 1; s3->accel.dest = dstbase + y * s3->width; - + while (x_count-- && count--) { if ((s3->accel.poly_x & 0xfff) >= clip_l && (s3->accel.poly_x & 0xfff) <= clip_r && @@ -5713,7 +5713,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ compare_mode < 2)) { READ(s3->accel.dest + s3->accel.poly_x, dest_dat); - + MIX if (s3->accel.cmd & 0x10) { @@ -5729,18 +5729,18 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ else s3->accel.poly_x--; } - + s3->accel.poly_cx += s3->accel.poly_dx1; s3->accel.poly_cx2 += s3->accel.poly_dx2; s3->accel.poly_x = s3->accel.poly_cx >> 20; - + s3->accel.poly_cy++; s3->accel.poly_cy2++; - + if (!count) break; } - + s3->accel.cur_x = s3->accel.poly_cx & 0xfff; s3->accel.cur_y = s3->accel.poly_cy & 0xfff; s3->accel.cur_x2 = s3->accel.poly_cx2 & 0xfff; @@ -5762,7 +5762,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.cx = s3->accel.cur_x; s3->accel.cy = s3->accel.cur_y; - + if (s3->accel.destx_distp >= 0xfffff000) { /* avoid overflow */ s3->accel.dx = s3->accel.destx_distp & 0xfff; if (s3->accel.cur_x_bit12) { @@ -5812,7 +5812,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ (s3->accel.dy & 0xfff) >= clip_t && (s3->accel.dy & 0xfff) <= clip_b)) { READ(s3->accel.src + s3->accel.cx, src_dat); - READ(s3->accel.dest + s3->accel.dx, dest_dat); + READ(s3->accel.dest + s3->accel.dx, dest_dat); dest_dat = (src_dat & s3->accel.wrt_mask) | (dest_dat & ~s3->accel.wrt_mask); @@ -5832,12 +5832,12 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.cy++; s3->accel.dy++; - + s3->accel.src = srcbase + s3->accel.cy * s3->width; s3->accel.dest = dstbase + s3->accel.dy * s3->width; - + s3->accel.sy--; - + if (s3->accel.sy < 0) { return; } @@ -5848,7 +5848,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ { while (count-- && s3->accel.sy >= 0) { - /*This is almost required by OS/2's software cursor or we will risk writing/reading garbage around it.*/ + /*This is almost required by OS/2's software cursor or we will risk writing/reading garbage around it.*/ if ((s3->accel.dx) >= clip_l && (s3->accel.dx) <= clip_r && ((s3->accel.dy) >= clip_t && (s3->accel.dy) <= clip_b)) { @@ -5904,7 +5904,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ } s3->accel.sx--; if (s3->accel.sx < 0) - { + { if (s3->accel.cmd & 0x20) { s3->accel.cx -= (s3->accel.maj_axis_pcnt & 0xfff) + 1; @@ -5914,8 +5914,8 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ { s3->accel.cx += (s3->accel.maj_axis_pcnt & 0xfff) + 1; s3->accel.dx += (s3->accel.maj_axis_pcnt & 0xfff) + 1; - } - + } + s3->accel.sx = s3->accel.maj_axis_pcnt & 0xfff; if (s3->accel.cmd & 0x80) @@ -5934,7 +5934,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.sy--; - if (cpu_input) { + if (cpu_input) { return; } @@ -5965,10 +5965,10 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ /*Align source with destination*/ s3->accel.pattern = (s3->accel.cy * s3->width) + s3->accel.cx; s3->accel.dest = dstbase + s3->accel.dy * s3->width; - + s3->accel.cx = s3->accel.dx & 7; s3->accel.cy = s3->accel.dy & 7; - + s3->accel.src = srcbase + s3->accel.pattern + (s3->accel.cy * s3->width); } @@ -5995,7 +5995,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ case 0: src_dat = s3->accel.bkgd_color; break; case 1: src_dat = s3->accel.frgd_color; break; case 2: src_dat = cpu_dat; break; - case 3: READ(s3->accel.src + s3->accel.cx, src_dat); + case 3: READ(s3->accel.src + s3->accel.cx, src_dat); if (vram_mask) src_dat = ((src_dat & rd_mask) == rd_mask); break; @@ -6070,32 +6070,32 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ } } break; - + case 9: /*Polyline/2-Point Line (Vision868/968 and Trio64 only)*/ { int error; - + if (s3->chip != S3_TRIO64 && s3->chip != S3_VISION968 && s3->chip != S3_VISION868) break; if (!cpu_input) { s3->accel.dx = ABS(s3->accel.destx_distp - s3->accel.cur_x); - if (s3->accel.destx_distp & 0x1000) + if (s3->accel.destx_distp & 0x1000) s3->accel.dx |= ~0xfff; s3->accel.dy = ABS(s3->accel.desty_axstp - s3->accel.cur_y); - if (s3->accel.desty_axstp & 0x1000) + if (s3->accel.desty_axstp & 0x1000) s3->accel.dy |= ~0xfff; - + s3->accel.cx = s3->accel.cur_x; - if (s3->accel.cur_x_bit12) + if (s3->accel.cur_x_bit12) s3->accel.cx |= ~0xfff; s3->accel.cy = s3->accel.cur_y; - if (s3->accel.cur_y_bit12) + if (s3->accel.cur_y_bit12) s3->accel.cy |= ~0xfff; } - if ((s3->accel.cmd & 0x100) && !cpu_input) return; /*Wait for data from CPU*/ - + if ((s3->accel.cmd & 0x100) && !cpu_input) return; /*Wait for data from CPU*/ + if (s3->accel.dx > s3->accel.dy) { error = s3->accel.dx / 2; while (s3->accel.cx != s3->accel.destx_distp && count--) { @@ -6147,7 +6147,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ READ((s3->accel.cy * s3->width) + s3->accel.cx, dest_dat); MIX - + if (s3->accel.cmd & 0x10) { WRITE((s3->accel.cy * s3->width) + s3->accel.cx, dest_dat); } @@ -6167,25 +6167,25 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ else s3->accel.cy--; - } + } } s3->accel.cur_x = s3->accel.cx; s3->accel.cur_y = s3->accel.cy; } - break; - + break; + case 11: /*Polygon Fill Pattern (Vision868/968 and Trio64 only)*/ - { + { int end_y1, end_y2; - + if (s3->chip != S3_TRIO64 && s3->chip != S3_VISION968 && s3->chip != S3_VISION868) break; polygon_setup(s3); if ((s3->accel.cmd & 0x100) && !cpu_input) return; /*Wait for data from CPU*/ - + end_y1 = s3->accel.desty_axstp; end_y2 = s3->accel.desty_axstp2; @@ -6199,11 +6199,11 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.src = srcbase + s3->accel.pattern + ((y & 7) * s3->width); s3->accel.dest = dstbase + y * s3->width; - + while (x_count-- && count--) { int pat_x = s3->accel.poly_x & 7; - + if ((s3->accel.poly_x & 0xfff) >= clip_l && (s3->accel.poly_x & 0xfff) <= clip_r && (s3->accel.poly_cy & 0xfff) >= clip_t && (s3->accel.poly_cy & 0xfff) <= clip_b) { @@ -6217,7 +6217,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ case 0: src_dat = s3->accel.bkgd_color; break; case 1: src_dat = s3->accel.frgd_color; break; case 2: src_dat = cpu_dat; break; - case 3: READ(s3->accel.src + pat_x, src_dat); + case 3: READ(s3->accel.src + pat_x, src_dat); if (vram_mask) src_dat = ((src_dat & rd_mask) == rd_mask); break; @@ -6228,9 +6228,9 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ compare_mode < 2)) { READ(s3->accel.dest + s3->accel.poly_x, dest_dat); - + MIX - + if (s3->accel.cmd & 0x10) { WRITE(s3->accel.dest + s3->accel.poly_x, dest_dat); } @@ -6247,18 +6247,18 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ else s3->accel.poly_x--; } - + s3->accel.poly_cx += s3->accel.poly_dx1; s3->accel.poly_cx2 += s3->accel.poly_dx2; s3->accel.poly_x = s3->accel.poly_cx >> 20; - + s3->accel.poly_cy++; s3->accel.poly_cy2++; - + if (!count) break; } - + s3->accel.cur_x = s3->accel.poly_cx & 0xfff; s3->accel.cur_y = s3->accel.poly_cy & 0xfff; s3->accel.cur_x2 = s3->accel.poly_cx2 & 0xfff; @@ -6294,7 +6294,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.src = srcbase + (s3->accel.cy * s3->width); s3->accel.pattern = (s3->accel.py * s3->width); } - + if ((s3->accel.cmd & 0x100) && !cpu_input) return; /*Wait for data from CPU*/ frgd_mix = (s3->accel.frgd_mix >> 5) & 3; @@ -6312,7 +6312,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ case 2: src_dat = cpu_dat; break; case 3: READ(s3->accel.src + s3->accel.cx, src_dat); break; } - + if (s3->accel.ropmix & 0x100) { switch ((mix_dat & mix_mask) ? frgd_mix : bkgd_mix) { @@ -6418,10 +6418,10 @@ s3_pci_read(int func, int addr, void *p) { case 0x00: return 0x33; /*'S3'*/ case 0x01: return 0x53; - + case 0x02: return s3->id_ext_pci; case 0x03: return (s3->chip == S3_TRIO64V2) ? 0x89 : 0x88; - + case PCI_REG_COMMAND: if (s3->chip == S3_VISION968 || s3->chip == S3_VISION868) return s3->pci_regs[PCI_REG_COMMAND] | 0x80; /*Respond to IO and memory accesses*/ @@ -6430,10 +6430,10 @@ s3_pci_read(int func, int addr, void *p) break; case 0x07: return (s3->chip == S3_TRIO64V2) ? (s3->pci_regs[0x07] & 0x36) : (1 << 1); /*Medium DEVSEL timing*/ - + case 0x08: return (s3->chip == S3_TRIO64V) ? 0x40 : 0; /*Revision ID*/ case 0x09: return 0; /*Programming interface*/ - + case 0x0a: if (s3->chip >= S3_TRIO32 || s3->chip == S3_VISION968 || s3->chip == S3_VISION868) return 0x00; /*Supports VGA interface*/ @@ -6446,19 +6446,19 @@ s3_pci_read(int func, int addr, void *p) else return 0x00; break; - + case 0x0d: return (s3->chip == S3_TRIO64V2) ? (s3->pci_regs[0x0d] & 0xf8) : 0x00; break; - + case 0x10: return 0x00; /*Linear frame buffer address*/ case 0x11: return 0x00; - case 0x12: + case 0x12: if (svga->crtc[0x53] & 0x08) return 0x00; else return (svga->crtc[0x5a] & 0x80); break; - - case 0x13: + + case 0x13: if (svga->crtc[0x53] & 0x08) { return (s3->chip >= S3_TRIO64V) ? (svga->crtc[0x59] & 0xfc) : (svga->crtc[0x59] & 0xfe); } else { @@ -6470,10 +6470,10 @@ s3_pci_read(int func, int addr, void *p) case 0x31: return 0x00; case 0x32: return s3->has_bios ? s3->pci_regs[0x32] : 0x00; case 0x33: return s3->has_bios ? s3->pci_regs[0x33] : 0x00; - + case 0x3c: return s3->int_line; case 0x3d: return PCI_INTA; - + case 0x3e: return (s3->chip == S3_TRIO64V2) ? 0x04 : 0x00; break; case 0x3f: return (s3->chip == S3_TRIO64V2) ? 0xff : 0x00; break; } @@ -6494,7 +6494,7 @@ s3_pci_write(int func, int addr, uint8_t val, void *p) if (s3->chip == S3_TRIO64V2) return; break; - + case PCI_REG_COMMAND: if (val & PCI_COMMAND_IO) s3_io_set(s3); @@ -6503,28 +6503,28 @@ s3_pci_write(int func, int addr, uint8_t val, void *p) s3->pci_regs[PCI_REG_COMMAND] = (val & 0x23); s3_updatemapping(s3); break; - + case 0x07: if (s3->chip == S3_TRIO64V2) { s3->pci_regs[0x07] = val & 0x3e; return; } break; - - case 0x0d: + + case 0x0d: if (s3->chip == S3_TRIO64V2) { s3->pci_regs[0x0d] = val & 0xf8; return; } break; - + case 0x12: if (!(svga->crtc[0x53] & 0x08)) { svga->crtc[0x5a] = (svga->crtc[0x5a] & 0x7f) | (val & 0x80); s3_updatemapping(s3); } break; - + case 0x13: if (svga->crtc[0x53] & 0x08) { svga->crtc[0x59] = (s3->chip >= S3_TRIO64V) ? (val & 0xfc) : (val & 0xfe); @@ -6548,7 +6548,7 @@ s3_pci_write(int func, int addr, uint8_t val, void *p) mem_mapping_disable(&s3->bios_rom.mapping); } return; - + case 0x3c: s3->int_line = val; return; @@ -6560,7 +6560,7 @@ fifo_thread(void *param) { s3_t *s3 = (s3_t *)param; uint64_t start_time, end_time; - + while (s3->fifo_thread_run) { thread_set_event(s3->fifo_not_full_event); thread_wait_event(s3->wake_fifo_thread, -1); @@ -6590,7 +6590,7 @@ fifo_thread(void *param) s3_accel_out_fifo_l(s3, fifo->addr_type & FIFO_ADDR, fifo->val); break; } - + s3->fifo_read_idx++; fifo->addr_type = FIFO_INVALID; @@ -6678,7 +6678,7 @@ static void s3_reset(void *priv) case S3_METHEUS_86C928: case S3_SPEA_MERCURY_LITE_PCI: svga->crtc[0x5a] = 0x0a; - break; + break; case S3_PARADISE_BAHAMAS64: case S3_PHOENIX_VISION864: @@ -6744,7 +6744,7 @@ static void s3_reset(void *priv) s3->pci_regs[0x05] = 0; s3->pci_regs[0x06] = 0; s3->pci_regs[0x07] = 2; - s3->pci_regs[0x3d] = 1; + s3->pci_regs[0x3d] = 1; s3->pci_regs[0x3e] = 4; s3->pci_regs[0x3f] = 0xff; break; @@ -6801,7 +6801,7 @@ static void *s3_init(const device_t *info) bios_fn = ROM_MIROCRYSTAL8S_805; chip = S3_86C805; video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_86c805); - break; + break; case S3_MIROCRYSTAL10SD_805: bios_fn = ROM_MIROCRYSTAL10SD_805; chip = S3_86C805; @@ -6904,7 +6904,7 @@ static void *s3_init(const device_t *info) bios_fn = ROM_ELSAWIN2KPROX_964; chip = S3_VISION964; video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_vision964_pci); - break; + break; case S3_ELSAWIN2KPROX: bios_fn = ROM_ELSAWIN2KPROX; chip = S3_VISION968; @@ -6967,7 +6967,7 @@ static void *s3_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_trio64_pci); else video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_s3_trio64_vlb); - break; + break; case S3_DIAMOND_STEALTH64_764: bios_fn = ROM_DIAMOND_STEALTH64_764; chip = S3_TRIO64; @@ -7002,7 +7002,7 @@ static void *s3_init(const device_t *info) memset(s3, 0, sizeof(s3_t)); vram = device_get_config_int("memory"); - + if (vram) vram_size = vram << 20; else @@ -7019,7 +7019,7 @@ static void *s3_init(const device_t *info) s3->pci = !!(info->flags & DEVICE_PCI); s3->vlb = !!(info->flags & DEVICE_VLB); - + mem_mapping_add(&s3->linear_mapping, 0, 0, svga_read_linear, svga_readw_linear, svga_readl_linear, svga_write_linear, svga_writew_linear, svga_writel_linear, @@ -7034,14 +7034,14 @@ static void *s3_init(const device_t *info) mem_mapping_add(&s3->mmio_mapping, 0xa0000, 0x10000, s3_accel_read, s3_accel_read_w, s3_accel_read_l, s3_accel_write, s3_accel_write_w, s3_accel_write_l, - NULL, MEM_MAPPING_EXTERNAL, s3); + NULL, MEM_MAPPING_EXTERNAL, s3); mem_mapping_add(&s3->new_mmio_mapping, 0, 0, s3_accel_read, s3_accel_read_w, s3_accel_read_l, s3_accel_write, s3_accel_write_w, s3_accel_write_l, NULL, MEM_MAPPING_EXTERNAL, s3); mem_mapping_disable(&s3->mmio_mapping); mem_mapping_disable(&s3->new_mmio_mapping); - + if (chip == S3_VISION964 || chip == S3_VISION968) svga_init(info, &s3->svga, s3, vram_size, s3_recalctimings, @@ -7068,7 +7068,7 @@ static void *s3_init(const device_t *info) if (chip == S3_VISION964 && info->local != S3_ELSAWIN2KPROX_964) svga->dac_hwcursor_draw = bt48x_hwcursor_draw; - else if ((chip == S3_VISION964 && info->local == S3_ELSAWIN2KPROX_964) || (chip == S3_VISION968 && (info->local == S3_ELSAWIN2KPROX || + else if ((chip == S3_VISION964 && info->local == S3_ELSAWIN2KPROX_964) || (chip == S3_VISION968 && (info->local == S3_ELSAWIN2KPROX || info->local == S3_PHOENIX_VISION968 || info->local == S3_NUMBER9_9FX_771))) svga->dac_hwcursor_draw = ibm_rgb528_hwcursor_draw; else if (chip == S3_VISION968 && (info->local == S3_SPEA_MERCURY_P64V || info->local == S3_MIROVIDEO40SV_ERGO_968)) @@ -7104,30 +7104,30 @@ static void *s3_init(const device_t *info) break; } } - + if (s3->pci) svga->crtc[0x36] = 2 | (3 << 2) | (1 << 4); else if (s3->vlb) svga->crtc[0x36] = 1 | (3 << 2) | (1 << 4); else svga->crtc[0x36] = 3 | (1 << 4); - + if (chip >= S3_86C928) svga->crtc[0x36] |= (vram_sizes[vram] << 5); else { svga->crtc[0x36] |= ((vram == 1) ? 0x00 : 0x20) | 0x98; svga->crtc[0x41] = (vram == 1) ? 0x10 : 0x00; } - + svga->crtc[0x37] = 1 | (7 << 5); - + if (chip >= S3_86C928) svga->crtc[0x37] |= 0x04; svga->vblank_start = s3_vblank_start; s3_io_set(s3); - + s3->pci_regs[PCI_REG_COMMAND] = 7; s3->pci_regs[0x30] = 0x00; @@ -7137,7 +7137,7 @@ static void *s3_init(const device_t *info) s3->chip = chip; s3->int_line = 0; - + s3->card_type = info->local; switch(s3->card_type) { @@ -7150,7 +7150,7 @@ static void *s3_init(const device_t *info) s3->id_ext_pci = 0; s3->packed_mmio = 0; s3->width = 1024; - + svga->ramdac = device_add(&sc11483_ramdac_device); svga->clock_gen = device_add(&av9194_device); svga->getclock = av9194_getclock; @@ -7164,7 +7164,7 @@ static void *s3_init(const device_t *info) s3->id_ext_pci = 0; s3->packed_mmio = 0; s3->width = 1024; - + svga->ramdac = device_add(&sc11487_ramdac_device); svga->clock_gen = device_add(&ics2494an_305_device); svga->getclock = ics2494_getclock; @@ -7179,7 +7179,7 @@ static void *s3_init(const device_t *info) s3->id_ext_pci = 0; s3->packed_mmio = 0; svga->crtc[0x5a] = 0x0a; - + svga->ramdac = device_add(&gendac_ramdac_device); svga->clock_gen = svga->ramdac; svga->getclock = sdac_getclock; @@ -7194,7 +7194,7 @@ static void *s3_init(const device_t *info) s3->id_ext_pci = 0; s3->packed_mmio = 0; svga->crtc[0x5a] = 0x0a; - + svga->ramdac = device_add(&att490_ramdac_device); svga->clock_gen = device_add(&av9194_device); svga->getclock = av9194_getclock; @@ -7209,12 +7209,12 @@ static void *s3_init(const device_t *info) s3->id_ext_pci = 0; s3->packed_mmio = 0; svga->crtc[0x5a] = 0x0a; - + svga->ramdac = device_add(&att492_ramdac_device); svga->clock_gen = device_add(&av9194_device); svga->getclock = av9194_getclock; break; - + case S3_METHEUS_86C928: svga->decode_mask = (4 << 20) - 1; stepping = 0x91; /*86C928*/ @@ -7239,8 +7239,8 @@ static void *s3_init(const device_t *info) svga->ramdac = device_add(&sc1502x_ramdac_device); svga->clock_gen = device_add(&av9194_device); svga->getclock = av9194_getclock; - break; - + break; + case S3_PARADISE_BAHAMAS64: case S3_PHOENIX_VISION864: case S3_MIROCRYSTAL20SD_864: /*BIOS 3.xx has a SDAC ramdac.*/ @@ -7328,7 +7328,7 @@ static void *s3_init(const device_t *info) svga->crtc[0x59] = 0x00; svga->crtc[0x5a] = 0x0a; } - + if (info->local == S3_NUMBER9_9FX_531) { svga->ramdac = device_add(&att498_ramdac_device); svga->clock_gen = device_add(&icd2061_device); @@ -7389,7 +7389,7 @@ static void *s3_init(const device_t *info) s3->pci_regs[0x05] = 0; s3->pci_regs[0x06] = 0; s3->pci_regs[0x07] = 2; - s3->pci_regs[0x3d] = 1; + s3->pci_regs[0x3d] = 1; s3->pci_regs[0x3e] = 4; s3->pci_regs[0x3f] = 0xff; @@ -7400,7 +7400,7 @@ static void *s3_init(const device_t *info) default: return NULL; } - + svga->packed_chain4 = 1; if (s3->pci) @@ -7598,7 +7598,7 @@ static void s3_close(void *p) static void s3_speed_changed(void *p) { s3_t *s3 = (s3_t *)p; - + svga_recalctimings(&s3->svga); } diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index f0b22805a..7f2a37253 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -117,10 +117,10 @@ typedef struct s3d_t { uint32_t cmd_set; int clip_l, clip_r, clip_t, clip_b; - + uint32_t dest_base; uint32_t dest_str; - + uint32_t z_base; uint32_t z_str; @@ -136,14 +136,14 @@ typedef struct s3d_t int32_t TdWdX, TdWdY; uint32_t tws; - + int32_t TdDdX, TdDdY; uint32_t tds; - + int16_t TdGdX, TdBdX, TdRdX, TdAdX; int16_t TdGdY, TdBdY, TdRdY, TdAdY; uint32_t tgs, tbs, trs, tas; - + uint32_t TdXdY12; uint32_t txend12; uint32_t TdXdY01; @@ -161,9 +161,9 @@ typedef struct virge_t mem_mapping_t linear_mapping; mem_mapping_t mmio_mapping; mem_mapping_t new_mmio_mapping; - + rom_t bios_rom; - + svga_t svga; uint8_t bank; @@ -195,7 +195,7 @@ typedef struct virge_t uint32_t hwc_fg_col, hwc_bg_col; int hwc_col_stack_pos; - + struct { uint32_t src_base; @@ -212,21 +212,21 @@ typedef struct virge_t int r_width, r_height; int rsrc_x, rsrc_y; int rdest_x, rdest_y; - + int lxend0, lxend1; int32_t ldx; uint32_t lxstart, lystart; int lycnt; int line_dir; - + int src_x, src_y; int dest_x, dest_y; int w, h; uint8_t rop; - + int data_left_count; uint32_t data_left; - + uint32_t pattern_8[8*8]; uint32_t pattern_16[8*8]; uint32_t pattern_24[8*8]; @@ -240,14 +240,14 @@ typedef struct virge_t uint32_t pycnt; uint32_t dest_l, dest_r; } s3d; - + s3d_t s3d_tri; s3d_t s3d_buffer[RB_SIZE]; int s3d_read_idx, s3d_write_idx; int s3d_busy; int render_idx; - + struct { uint32_t pri_ctrl; @@ -273,9 +273,9 @@ typedef struct virge_t uint32_t pri_size; uint32_t sec_start; uint32_t sec_size; - + int sdif; - + int pri_x, pri_y, pri_w, pri_h; int sec_x, sec_y, sec_w, sec_h; } streams; @@ -285,7 +285,7 @@ typedef struct virge_t uint32_t dma_ptr; uint64_t blitter_time; volatile int fifo_slot; - + pc_timer_t tri_timer; int virge_busy, local; @@ -297,7 +297,7 @@ typedef struct virge_t uint8_t serialport; void *i2c, *ddc; - + int waiting; } virge_t; @@ -324,29 +324,29 @@ enum { CMD_SET_AE = 1, CMD_SET_HC = (1 << 1), - + CMD_SET_FORMAT_MASK = (7 << 2), CMD_SET_FORMAT_8 = (0 << 2), CMD_SET_FORMAT_16 = (1 << 2), CMD_SET_FORMAT_24 = (2 << 2), - + CMD_SET_MS = (1 << 6), CMD_SET_IDS = (1 << 7), CMD_SET_MP = (1 << 8), CMD_SET_TP = (1 << 9), - + CMD_SET_ITA_MASK = (3 << 10), CMD_SET_ITA_BYTE = (0 << 10), CMD_SET_ITA_WORD = (1 << 10), CMD_SET_ITA_DWORD = (2 << 10), - + CMD_SET_ZUP = (1 << 23), - + CMD_SET_ZB_MODE = (3 << 24), CMD_SET_XP = (1 << 25), CMD_SET_YP = (1 << 26), - + CMD_SET_COMMAND_MASK = (15 << 27) }; @@ -440,7 +440,7 @@ static void render_thread(void *param) { virge_t *virge = (virge_t *)param; - + while (virge->render_thread_run) { thread_wait_event(virge->wake_render_thread, -1); thread_reset_event(virge->wake_render_thread); @@ -467,9 +467,9 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) uint8_t old; uint32_t cursoraddr; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; - + switch (addr) { case 0x3c5: @@ -495,7 +495,7 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) return; } break; - + case 0x3d4: svga->crtcreg = val; return; @@ -503,7 +503,7 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) if ((svga->crtcreg < 7) && (svga->crtc[0x11] & 0x80)) return; if ((svga->crtcreg == 7) && (svga->crtc[0x11] & 0x80)) - val = (svga->crtc[7] & ~0x10) | (val & 0x10); + val = (svga->crtc[7] & ~0x10) | (val & 0x10); if ((svga->crtcreg >= 0x20) && (svga->crtcreg < 0x40) && (svga->crtcreg != 0x36) && (svga->crtcreg != 0x38) && (svga->crtcreg != 0x39) && ((svga->crtc[0x38] & 0xcc) != 0x48)) @@ -516,10 +516,10 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) return; old = svga->crtc[svga->crtcreg]; svga->crtc[svga->crtcreg] = val; - + if (svga->crtcreg > 0x18) s3_virge_log("OUTB VGA reg = %02x, val = %02x\n", svga->crtcreg, val); - + switch (svga->crtcreg) { case 0x31: @@ -528,11 +528,11 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) case 0x32: s3_virge_update_irqs(virge); break; - + case 0x69: virge->ma_ext = val & 0x1f; break; - + case 0x35: virge->bank = (virge->bank & 0x70) | (val & 0xf); if (svga->chain4) @@ -555,12 +555,12 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) else svga->write_bank = svga->read_bank = virge->bank << 14; break; - + case 0x3a: if (val & 0x10) svga->gdcreg[5] |= 0x40; /*Horrible cheat*/ break; - + case 0x45: svga->hwcursor.ena = val & 1; break; @@ -573,7 +573,7 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) cursoraddr = (virge->memory_size == 8) ? 0x1fff : 0x0fff; svga->hwcursor.addr = ((((svga->crtc[0x4c] << 8) | svga->crtc[0x4d]) & cursoraddr) * 1024) + (svga->hwcursor.yoff * 16); break; - + case 0x4a: switch (virge->hwc_col_stack_pos) { @@ -614,12 +614,12 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) svga->dpms = (svga->seqregs[0x0d] & 0x50) || (svga->crtc[0x56] & 0x06); old = ~val; /* force recalc */ break; - + case 0x5c: if ((val & 0xa0) == 0x80) i2c_gpio_set(virge->i2c, !!(val & 0x40), !!(val & 0x10)); break; - + case 0x67: switch (val >> 4) { @@ -630,7 +630,7 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) default: svga->bpp = 8; break; } break; - + case 0xaa: i2c_gpio_set(virge->i2c, !!(val & SERIAL_PORT_SCW), !!(val & SERIAL_PORT_SDW)); break; @@ -660,8 +660,8 @@ static uint8_t s3_virge_in(uint16_t addr, void *p) virge_t *virge = (virge_t *)p; svga_t *svga = &virge->svga; uint8_t ret; - - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) @@ -671,7 +671,7 @@ static uint8_t s3_virge_in(uint16_t addr, void *p) ret = 0xff; else ret = svga_in(addr, svga); - break; + break; case 0x3c5: if (svga->seqaddr >= 8) @@ -690,7 +690,7 @@ static uint8_t s3_virge_in(uint16_t addr, void *p) { case 0x2d: ret = virge->virge_id_high; break; /*Extended chip ID*/ case 0x2e: ret = virge->virge_id_low; break; /*New chip ID*/ - case 0x2f: ret = virge->virge_rev; break; + case 0x2f: ret = virge->virge_rev; break; case 0x30: ret = virge->virge_id; break; /*Chip ID*/ case 0x31: ret = (svga->crtc[0x31] & 0xcf) | ((virge->ma_ext & 3) << 4); break; case 0x33: ret = (svga->crtc[0x33] | 0x04); break; @@ -724,16 +724,16 @@ static uint8_t s3_virge_in(uint16_t addr, void *p) } else ret = svga->crtc[0xaa]; break; - + default: ret = svga->crtc[svga->crtcreg]; break; } break; - + default: ret = svga_in(addr, svga); - break; + break; } return ret; } @@ -741,7 +741,7 @@ static uint8_t s3_virge_in(uint16_t addr, void *p) static void s3_virge_recalctimings(svga_t *svga) { virge_t *virge = (virge_t *)svga->p; - + svga->hdisp = svga->hdisp_old; if (svga->crtc[0x5d] & 0x01) svga->htotal += 0x100; @@ -759,36 +759,36 @@ static void s3_virge_recalctimings(svga_t *svga) if (((svga->miscout >> 2) & 3) == 3) { int n = svga->seqregs[0x12] & 0x1f; int r = (svga->seqregs[0x12] >> 5); - - if (virge->chip == S3_VIRGEVX || virge->chip == S3_VIRGEDX) + + if (virge->chip == S3_VIRGEVX || virge->chip == S3_VIRGEDX) r &= 7; else if (virge->chip >= S3_VIRGEGX2) r &= 10; else r &= 3; - + int m = svga->seqregs[0x13] & 0x7f; double freq = (((double)m + 2) / (((double)n + 2) * (double)(1 << r))) * 14318184.0; svga->clock = (cpuclock * (float)(1ull << 32)) / freq; } - + if ((svga->crtc[0x67] & 0xc) != 0xc) /*VGA mode*/ { svga->ma_latch |= (virge->ma_ext << 16); if (svga->crtc[0x51] & 0x30) svga->rowoffset += (svga->crtc[0x51] & 0x30) << 4; else if (svga->crtc[0x43] & 0x04) svga->rowoffset += 0x100; if (!svga->rowoffset) svga->rowoffset = 256; - + svga->lowres = !((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)); if ((svga->gdcreg[5] & 0x40) && (svga->crtc[0x3a] & 0x10)) { svga->fb_only = 1; switch (svga->bpp) { - case 8: - svga->render = svga_render_8bpp_highres; + case 8: + svga->render = svga_render_8bpp_highres; break; - case 15: + case 15: svga->render = svga_render_15bpp_highres; if (virge->chip != S3_VIRGEVX && virge->chip < S3_VIRGEGX2) { @@ -796,12 +796,12 @@ static void s3_virge_recalctimings(svga_t *svga) svga->hdisp >>= 1; } break; - case 16: + case 16: svga->render = svga_render_16bpp_highres; if (virge->chip != S3_VIRGEVX && virge->chip < S3_VIRGEGX2) { svga->htotal >>= 1; - svga->hdisp >>= 1; + svga->hdisp >>= 1; } break; case 24: @@ -809,7 +809,7 @@ static void s3_virge_recalctimings(svga_t *svga) if (virge->chip != S3_VIRGEVX && virge->chip < S3_VIRGEGX2) svga->rowoffset = (svga->rowoffset * 3) / 4; /*Hack*/ break; - case 32: + case 32: svga->render = svga_render_32bpp_highres; break; } @@ -821,16 +821,16 @@ static void s3_virge_recalctimings(svga_t *svga) else /*Streams mode*/ { svga->fb_only = 1; - + if (virge->streams.buffer_ctrl & 1) svga->ma_latch = virge->streams.pri_fb1 >> 2; else svga->ma_latch = virge->streams.pri_fb0 >> 2; - + svga->hdisp = virge->streams.pri_w + 1; if (virge->streams.pri_h < svga->dispend) svga->dispend = virge->streams.pri_h; - + svga->overlay.x = virge->streams.sec_x - virge->streams.pri_x; svga->overlay.y = virge->streams.sec_y - virge->streams.pri_y; svga->overlay.ysize = virge->streams.sec_h; @@ -847,21 +847,21 @@ static void s3_virge_recalctimings(svga_t *svga) switch ((virge->streams.pri_ctrl >> 24) & 0x7) { case 0: /*RGB-8 (CLUT)*/ - svga->render = svga_render_8bpp_highres; + svga->render = svga_render_8bpp_highres; break; - case 3: /*KRGB-16 (1.5.5.5)*/ + case 3: /*KRGB-16 (1.5.5.5)*/ svga->htotal >>= 1; - svga->render = svga_render_15bpp_highres; + svga->render = svga_render_15bpp_highres; break; - case 5: /*RGB-16 (5.6.5)*/ + case 5: /*RGB-16 (5.6.5)*/ svga->htotal >>= 1; - svga->render = svga_render_16bpp_highres; + svga->render = svga_render_16bpp_highres; break; - case 6: /*RGB-24 (8.8.8)*/ - svga->render = svga_render_24bpp_highres; + case 6: /*RGB-24 (8.8.8)*/ + svga->render = svga_render_24bpp_highres; break; case 7: /*XRGB-32 (X.8.8.8)*/ - svga->render = svga_render_32bpp_highres; + svga->render = svga_render_32bpp_highres; break; } svga->vram_display_mask = virge->vram_mask; @@ -881,7 +881,7 @@ static void s3_virge_updatemapping(virge_t *virge) return; } - s3_virge_log("Update mapping - bank %02X ", svga->gdcreg[6] & 0xc); + s3_virge_log("Update mapping - bank %02X ", svga->gdcreg[6] & 0xc); /*Banked framebuffer*/ switch (svga->gdcreg[6] & 0xc) { /*VGA mapping*/ case 0x0: /*128k at A0000*/ @@ -901,7 +901,7 @@ static void s3_virge_updatemapping(virge_t *virge) svga->banked_mask = 0x7fff; break; } - + virge->linear_base = (svga->crtc[0x5a] << 16) | (svga->crtc[0x59] << 24); s3_virge_log("Linear framebuffer %02X, linear base = %08x, display mask = %08x\n", svga->crtc[0x58] & 0x17, virge->linear_base, svga->vram_display_mask); @@ -937,13 +937,13 @@ static void s3_virge_updatemapping(virge_t *virge) } else { virge->linear_base &= 0xfc000000; } - + mem_mapping_set_addr(&virge->linear_mapping, virge->linear_base, virge->linear_size); } } else { mem_mapping_disable(&virge->linear_mapping); } - + s3_virge_log("Memory mapped IO %02X\n", svga->crtc[0x53] & 0x38); /* Memory mapped I/O. */ @@ -983,8 +983,8 @@ s3_virge_mmio_fifo_write(uint32_t addr, uint8_t val, virge_t *virge) case 0x859c: virge->cmd_dma = val; break; - } - } + } + } } static void @@ -1003,7 +1003,7 @@ s3_virge_mmio_fifo_write_w(uint32_t addr, uint16_t val, virge_t *virge) static void s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) -{ +{ if ((addr & 0xfffc) < 0x8000) { if (virge->s3d.cmd_set & CMD_SET_MS) s3_virge_bitblt(virge, 32, ((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24)); @@ -1015,7 +1015,7 @@ s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) case 0x8590: virge->cmd_dma_base = val; break; - + case 0x8594: virge->dma_ptr = val; break; @@ -1026,7 +1026,7 @@ s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) case 0x859c: virge->cmd_dma = val; break; - + case 0xa000: case 0xa004: case 0xa008: case 0xa00c: case 0xa010: case 0xa014: case 0xa018: case 0xa01c: case 0xa020: case 0xa024: case 0xa028: case 0xa02c: @@ -1068,7 +1068,7 @@ s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) virge->s3d.pattern_8[y*8 + x + 1] = val >> 8; virge->s3d.pattern_8[y*8 + x + 2] = val >> 16; virge->s3d.pattern_8[y*8 + x + 3] = val >> 24; - + x = (addr >> 1) & 6; y = (addr >> 4) & 7; virge->s3d.pattern_16[y*8 + x] = val & 0xffff; @@ -1194,7 +1194,7 @@ s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) if (virge->s3d.cmd_set & CMD_SET_AE) s3_virge_bitblt(virge, -1, 0); break; - + case 0xb0f4: case 0xb4f4: virge->s3d_tri.fog_b = val & 0xff; virge->s3d_tri.fog_g = (val >> 8) & 0xff; @@ -1298,7 +1298,7 @@ s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) virge->s3d_tri.tas = (val >> 16) & 0xffff; virge->s3d_tri.trs = val & 0xffff; break; - + case 0xb554: virge->s3d_tri.TdZdX = val; break; @@ -1361,7 +1361,7 @@ s3_virge_mmio_read(uint32_t addr, void *p) if (virge->fifo_slot) virge->fifo_slot--; return ret; - + case 0x83b0: case 0x83b1: case 0x83b2: case 0x83b3: case 0x83b4: case 0x83b5: case 0x83b6: case 0x83b7: case 0x83b8: case 0x83b9: case 0x83ba: case 0x83bb: @@ -1375,10 +1375,10 @@ s3_virge_mmio_read(uint32_t addr, void *p) case 0x83d8: case 0x83d9: case 0x83da: case 0x83db: case 0x83dc: case 0x83dd: case 0x83de: case 0x83df: return s3_virge_in(addr & 0x3ff, virge); - + case 0x859c: return virge->cmd_dma; - + case 0xff20: case 0xff21: ret = virge->serialport & ~(SERIAL_PORT_SCR | SERIAL_PORT_SDR); if ((virge->serialport & SERIAL_PORT_SCW) && i2c_gpio_get_scl(virge->i2c)) @@ -1394,9 +1394,9 @@ s3_virge_mmio_read_w(uint32_t addr, void *p) { virge_t *virge = (virge_t *)p; uint16_t ret = 0xffff; - + s3_virge_log("[%04X:%08X]: MMIO ReadW addr = %04x\n", CS, cpu_state.pc, addr & 0xfffe); - + switch (addr & 0xfffe) { case 0x8504: if (!virge->fifo_slot) @@ -1407,10 +1407,10 @@ s3_virge_mmio_read_w(uint32_t addr, void *p) ret |= 0x30; /*A bit of a workaround at the moment.*/ s3_virge_update_irqs(virge); return ret; - + case 0x859c: return virge->cmd_dma; - + default: return s3_virge_mmio_read(addr, virge) | (s3_virge_mmio_read(addr + 1, virge) << 8); @@ -1493,7 +1493,7 @@ s3_virge_mmio_read_l(uint32_t addr, void *p) break; case 0x81fc: ret = virge->streams.sec_size; - break; + break; case 0x8504: if (virge->s3d_busy || virge->fifo_slot) { @@ -1510,7 +1510,7 @@ s3_virge_mmio_read_l(uint32_t addr, void *p) virge->fifo_slot--; s3_virge_update_irqs(virge); break; - + case 0x8590: ret = virge->cmd_dma_base; break; @@ -1522,7 +1522,7 @@ s3_virge_mmio_read_l(uint32_t addr, void *p) case 0x859c: ret = virge->cmd_dma; break; - + case 0xa4d4: ret = virge->s3d.src_base; break; @@ -1568,11 +1568,11 @@ s3_virge_mmio_read_l(uint32_t addr, void *p) case 0xa50c: ret = (virge->s3d.rdest_x << 16) | virge->s3d.rdest_y; break; - + default: ret = s3_virge_mmio_read(addr, virge) | (s3_virge_mmio_read(addr + 1, virge) << 8) | - (s3_virge_mmio_read(addr + 2, virge) << 16) | + (s3_virge_mmio_read(addr + 2, virge) << 16) | (s3_virge_mmio_read(addr + 3, virge) << 24); break; } @@ -1626,7 +1626,7 @@ s3_virge_mmio_write_w(uint32_t addr, uint16_t val, void *p) if ((addr & 0xfffe) == 0x83d4) { s3_virge_mmio_write(addr, val, virge); s3_virge_mmio_write(addr + 1, val >> 8, virge); - } + } } } @@ -1634,12 +1634,12 @@ static void s3_virge_mmio_write_l(uint32_t addr, uint32_t val, void *p) { virge_t *virge = (virge_t *)p; - svga_t *svga = &virge->svga; - + svga_t *svga = &virge->svga; + s3_virge_log("[%04X:%08X]: MMIO WriteL addr = %04x, val = %04x\n", CS, cpu_state.pc, addr & 0xfffc, val); if (((addr & 0xfffc) >= 0x8590) || ((addr & 0xfffc) < 0x8000)) if ((addr & 0xfffc) == 0xff20) - s3_virge_mmio_write(addr, val, virge); + s3_virge_mmio_write(addr, val, virge); else { s3_virge_mmio_fifo_write_l(addr, val, virge); } @@ -1734,38 +1734,38 @@ s3_virge_mmio_write_l(uint32_t addr, uint32_t val, void *p) case 0x81f0: virge->streams.pri_start = val; virge->streams.pri_x = (val >> 16) & 0x7ff; - virge->streams.pri_y = val & 0x7ff; + virge->streams.pri_y = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; case 0x81f4: virge->streams.pri_size = val; virge->streams.pri_w = (val >> 16) & 0x7ff; - virge->streams.pri_h = val & 0x7ff; + virge->streams.pri_h = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; case 0x81f8: virge->streams.sec_start = val; virge->streams.sec_x = (val >> 16) & 0x7ff; - virge->streams.sec_y = val & 0x7ff; + virge->streams.sec_y = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; case 0x81fc: virge->streams.sec_size = val; virge->streams.sec_w = (val >> 16) & 0x7ff; - virge->streams.sec_h = val & 0x7ff; + virge->streams.sec_h = val & 0x7ff; svga_recalctimings(svga); svga->fullchange = changeframecount; break; - + case 0x8504: virge->subsys_stat &= ~(val & 0xff); virge->subsys_cntl = (val >> 8); s3_virge_update_irqs(virge); break; - + case 0x850c: virge->advfunc_cntl = val & 0xff; s3_virge_updatemapping(virge); @@ -1809,7 +1809,7 @@ s3_virge_mmio_write_l(uint32_t addr, uint32_t val, void *p) y > s3d_tri->clip_b)) \ update = 0; \ } - + #define MIX() \ { \ @@ -1861,7 +1861,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) uint32_t source = 0, dest = 0, pattern; uint32_t out = 0; int update; - + switch (virge->s3d.cmd_set & CMD_SET_FORMAT_MASK) { case CMD_SET_FORMAT_8: @@ -1892,7 +1892,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) } if (virge->s3d.cmd_set & CMD_SET_MP) pattern_data = mono_pattern; - + switch (virge->s3d.cmd_set & CMD_SET_ITA_MASK) { case CMD_SET_ITA_BYTE: @@ -1937,7 +1937,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) virge->s3d.h = virge->s3d.r_height; virge->s3d.rop = (virge->s3d.cmd_set >> 17) & 0xff; virge->s3d.data_left_count = 0; - + s3_virge_log("BitBlt start src_x=%i,src_y=%i,dest_x=%i,dest_y=%i,w=%i,h=%i,rop=%02X,src_base=%x,dest_base=%x\n", virge->s3d.src_x, virge->s3d.src_y, @@ -1948,7 +1948,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) virge->s3d.rop, virge->s3d.src_base, virge->s3d.dest_base); - + if (virge->s3d.cmd_set & CMD_SET_IDS) return; } @@ -2019,7 +2019,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) WRITE(dest_addr, out); } - + virge->s3d.src_x += x_inc; virge->s3d.src_x &= 0x7ff; virge->s3d.dest_x += x_inc; @@ -2033,7 +2033,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) virge->s3d.src_y += y_inc; virge->s3d.dest_y += y_inc; virge->s3d.h--; - + switch (virge->s3d.cmd_set & (CMD_SET_MS | CMD_SET_IDS)) { case CMD_SET_IDS: @@ -2053,10 +2053,10 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) } } else - virge->s3d.w--; + virge->s3d.w--; } break; - + case CMD_SET_COMMAND_RECTFILL: /*No source, pattern = pat_fg_clr*/ if (count == -1) @@ -2068,7 +2068,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) virge->s3d.w = virge->s3d.r_width; virge->s3d.h = virge->s3d.r_height; virge->s3d.rop = (virge->s3d.cmd_set >> 17) & 0xff; - + s3_virge_log("RctFll start %i,%i %i,%i %02X %08x\n", virge->s3d.dest_x, virge->s3d.dest_y, virge->s3d.w, @@ -2114,11 +2114,11 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) } } else - virge->s3d.w--; + virge->s3d.w--; count--; } break; - + case CMD_SET_COMMAND_LINE: if (count == -1) { @@ -2132,7 +2132,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) int x; int new_x; int first_pixel = 1; - + x = virge->s3d.dest_x >> 20; if (virge->s3d.h == virge->s3d.lycnt && @@ -2145,11 +2145,11 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) else new_x = (virge->s3d.dest_x + virge->s3d.ldx) >> 20; - + if ((virge->s3d.line_dir && x > new_x) || (!virge->s3d.line_dir && x < new_x)) goto skip_line; - + do { uint32_t dest_addr = virge->s3d.dest_base + (x * x_mul) + (virge->s3d.dest_y * virge->s3d.dest_str); @@ -2178,7 +2178,7 @@ static void s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) WRITE(dest_addr, out); } - + if (x < new_x) x++; else if (x > new_x) @@ -2224,7 +2224,7 @@ skip_line: WRITE(dest_addr, out); } - + x = (x + xdir) & 0x7ff; } while (x != (xend + xdir)); @@ -2273,21 +2273,21 @@ typedef struct s3d_state_t int32_t r, g, b, a, u, v, d, w; int32_t base_r, base_g, base_b, base_a, base_u, base_v, base_d, base_w; - + uint32_t base_z; uint32_t tbu, tbv; uint32_t cmd_set; int max_d; - + uint16_t *texture[10]; - + uint32_t tex_bdr_clr; - + int32_t x1, x2; int y; - + rgba_t dest_rgba; } s3d_state_t; @@ -2295,7 +2295,7 @@ typedef struct s3d_texture_state_t { int level; int texture_shift; - + int32_t u, v; } s3d_texture_state_t; @@ -2391,7 +2391,7 @@ static void tex_ARGB8888_nowrap(s3d_state_t *state, s3d_texture_state_t *texture static void tex_sample_normal(s3d_state_t *state) { s3d_texture_state_t texture_state; - + texture_state.level = state->max_d; texture_state.texture_shift = 18 + (9 - texture_state.level); texture_state.u = state->u + state->tbu; @@ -2429,12 +2429,12 @@ static void tex_sample_normal_filter(s3d_state_t *state) texture_state.u = state->u + state->tbu + tex_offset; texture_state.v = state->v + state->tbv + tex_offset; tex_read(state, &texture_state, &tex_samples[3]); - + d[0] = (256 - du) * (256 - dv); d[1] = du * (256 - dv); d[2] = (256 - du) * dv; d[3] = du * dv; - + state->dest_rgba.r = (tex_samples[0].r * d[0] + tex_samples[1].r * d[1] + tex_samples[2].r * d[2] + tex_samples[3].r * d[3]) >> 16; state->dest_rgba.g = (tex_samples[0].g * d[0] + tex_samples[1].g * d[1] + tex_samples[2].g * d[2] + tex_samples[3].g * d[3]) >> 16; state->dest_rgba.b = (tex_samples[0].b * d[0] + tex_samples[1].b * d[1] + tex_samples[2].b * d[2] + tex_samples[3].b * d[3]) >> 16; @@ -2468,7 +2468,7 @@ static void tex_sample_mipmap_filter(s3d_state_t *state) texture_state.level = 0; texture_state.texture_shift = 18 + (9 - texture_state.level); tex_offset = 1 << texture_state.texture_shift; - + texture_state.u = state->u + state->tbu; texture_state.v = state->v + state->tbv; tex_read(state, &texture_state, &tex_samples[0]); @@ -2491,7 +2491,7 @@ static void tex_sample_mipmap_filter(s3d_state_t *state) d[1] = du * (256 - dv); d[2] = (256 - du) * dv; d[3] = du * dv; - + state->dest_rgba.r = (tex_samples[0].r * d[0] + tex_samples[1].r * d[1] + tex_samples[2].r * d[2] + tex_samples[3].r * d[3]) >> 16; state->dest_rgba.g = (tex_samples[0].g * d[0] + tex_samples[1].g * d[1] + tex_samples[2].g * d[2] + tex_samples[3].g * d[3]) >> 16; state->dest_rgba.b = (tex_samples[0].b * d[0] + tex_samples[1].b * d[1] + tex_samples[2].b * d[2] + tex_samples[3].b * d[3]) >> 16; @@ -2505,9 +2505,9 @@ static void tex_sample_persp_normal(s3d_state_t *state) if (state->w) w = (int32_t)(((1ULL << 27) << 19) / (int64_t)state->w); - + texture_state.level = state->max_d; - texture_state.texture_shift = 18 + (9 - texture_state.level); + texture_state.texture_shift = 18 + (9 - texture_state.level); texture_state.u = (int32_t)(((int64_t)state->u * (int64_t)w) >> (12 + state->max_d)) + state->tbu; texture_state.v = (int32_t)(((int64_t)state->v * (int64_t)w) >> (12 + state->max_d)) + state->tbv; @@ -2532,7 +2532,7 @@ static void tex_sample_persp_normal_filter(s3d_state_t *state) texture_state.level = state->max_d; texture_state.texture_shift = 18 + (9 - texture_state.level); tex_offset = 1 << texture_state.texture_shift; - + texture_state.u = u; texture_state.v = v; tex_read(state, &texture_state, &tex_samples[0]); @@ -2555,7 +2555,7 @@ static void tex_sample_persp_normal_filter(s3d_state_t *state) d[1] = du * (256 - dv); d[2] = (256 - du) * dv; d[3] = du * dv; - + state->dest_rgba.r = (tex_samples[0].r * d[0] + tex_samples[1].r * d[1] + tex_samples[2].r * d[2] + tex_samples[3].r * d[3]) >> 16; state->dest_rgba.g = (tex_samples[0].g * d[0] + tex_samples[1].g * d[1] + tex_samples[2].g * d[2] + tex_samples[3].g * d[3]) >> 16; state->dest_rgba.b = (tex_samples[0].b * d[0] + tex_samples[1].b * d[1] + tex_samples[2].b * d[2] + tex_samples[3].b * d[3]) >> 16; @@ -2569,9 +2569,9 @@ static void tex_sample_persp_normal_375(s3d_state_t *state) if (state->w) w = (int32_t)(((1ULL << 27) << 19) / (int64_t)state->w); - + texture_state.level = state->max_d; - texture_state.texture_shift = 18 + (9 - texture_state.level); + texture_state.texture_shift = 18 + (9 - texture_state.level); texture_state.u = (int32_t)(((int64_t)state->u * (int64_t)w) >> (8 + state->max_d)) + state->tbu; texture_state.v = (int32_t)(((int64_t)state->v * (int64_t)w) >> (8 + state->max_d)) + state->tbv; @@ -2592,7 +2592,7 @@ static void tex_sample_persp_normal_filter_375(s3d_state_t *state) u = (int32_t)(((int64_t)state->u * (int64_t)w) >> (8 + state->max_d)) + state->tbu; v = (int32_t)(((int64_t)state->v * (int64_t)w) >> (8 + state->max_d)) + state->tbv; - + texture_state.level = state->max_d; texture_state.texture_shift = 18 + (9 - texture_state.level); tex_offset = 1 << texture_state.texture_shift; @@ -2619,7 +2619,7 @@ static void tex_sample_persp_normal_filter_375(s3d_state_t *state) d[1] = du * (256 - dv); d[2] = (256 - du) * dv; d[3] = du * dv; - + state->dest_rgba.r = (tex_samples[0].r * d[0] + tex_samples[1].r * d[1] + tex_samples[2].r * d[2] + tex_samples[3].r * d[3]) >> 16; state->dest_rgba.g = (tex_samples[0].g * d[0] + tex_samples[1].g * d[1] + tex_samples[2].g * d[2] + tex_samples[3].g * d[3]) >> 16; state->dest_rgba.b = (tex_samples[0].b * d[0] + tex_samples[1].b * d[1] + tex_samples[2].b * d[2] + tex_samples[3].b * d[3]) >> 16; @@ -2634,7 +2634,7 @@ static void tex_sample_persp_mipmap(s3d_state_t *state) if (state->w) w = (int32_t)(((1ULL << 27) << 19) / (int64_t)state->w); - + texture_state.level = (state->d < 0) ? state->max_d : state->max_d - ((state->d >> 27) & 0xf); if (texture_state.level < 0) texture_state.level = 0; @@ -2659,7 +2659,7 @@ static void tex_sample_persp_mipmap_filter(s3d_state_t *state) u = (int32_t)(((int64_t)state->u * (int64_t)w) >> (12 + state->max_d)) + state->tbu; v = (int32_t)(((int64_t)state->v * (int64_t)w) >> (12 + state->max_d)) + state->tbv; - + texture_state.level = (state->d < 0) ? state->max_d : state->max_d - ((state->d >> 27) & 0xf); if (texture_state.level < 0) texture_state.level = 0; @@ -2688,7 +2688,7 @@ static void tex_sample_persp_mipmap_filter(s3d_state_t *state) d[1] = du * (256 - dv); d[2] = (256 - du) * dv; d[3] = du * dv; - + state->dest_rgba.r = (tex_samples[0].r * d[0] + tex_samples[1].r * d[1] + tex_samples[2].r * d[2] + tex_samples[3].r * d[3]) >> 16; state->dest_rgba.g = (tex_samples[0].g * d[0] + tex_samples[1].g * d[1] + tex_samples[2].g * d[2] + tex_samples[3].g * d[3]) >> 16; state->dest_rgba.b = (tex_samples[0].b * d[0] + tex_samples[1].b * d[1] + tex_samples[2].b * d[2] + tex_samples[3].b * d[3]) >> 16; @@ -2702,7 +2702,7 @@ static void tex_sample_persp_mipmap_375(s3d_state_t *state) if (state->w) w = (int32_t)(((1ULL << 27) << 19) / (int64_t)state->w); - + texture_state.level = (state->d < 0) ? state->max_d : state->max_d - ((state->d >> 27) & 0xf); if (texture_state.level < 0) texture_state.level = 0; @@ -2727,13 +2727,13 @@ static void tex_sample_persp_mipmap_filter_375(s3d_state_t *state) u = (int32_t)(((int64_t)state->u * (int64_t)w) >> (8 + state->max_d)) + state->tbu; v = (int32_t)(((int64_t)state->v * (int64_t)w) >> (8 + state->max_d)) + state->tbv; - + texture_state.level = (state->d < 0) ? state->max_d : state->max_d - ((state->d >> 27) & 0xf); if (texture_state.level < 0) texture_state.level = 0; texture_state.texture_shift = 18 + (9 - texture_state.level); tex_offset = 1 << texture_state.texture_shift; - + texture_state.u = u; texture_state.v = v; tex_read(state, &texture_state, &tex_samples[0]); @@ -2756,7 +2756,7 @@ static void tex_sample_persp_mipmap_filter_375(s3d_state_t *state) d[1] = du * (256 - dv); d[2] = (256 - du) * dv; d[3] = du * dv; - + state->dest_rgba.r = (tex_samples[0].r * d[0] + tex_samples[1].r * d[1] + tex_samples[2].r * d[2] + tex_samples[3].r * d[3]) >> 16; state->dest_rgba.g = (tex_samples[0].g * d[0] + tex_samples[1].g * d[1] + tex_samples[2].g * d[2] + tex_samples[3].g * d[3]) >> 16; state->dest_rgba.b = (tex_samples[0].b * d[0] + tex_samples[1].b * d[1] + tex_samples[2].b * d[2] + tex_samples[3].b * d[3]) >> 16; @@ -2780,7 +2780,7 @@ static void tex_sample_persp_mipmap_filter_375(s3d_state_t *state) b = ((b) < 0) ? 0 : 0xff; \ if ((a) & ~0xff) \ a = ((a) < 0) ? 0 : 0xff; - + #define CLAMP_RGB(r, g, b) do \ { \ if ((r) < 0) \ @@ -2845,11 +2845,11 @@ static void dest_pixel_lit_texture_reflection(s3d_state_t *state) static void dest_pixel_lit_texture_modulate(s3d_state_t *state) { int r = state->r >> 7, g = state->g >> 7, b = state->b >> 7, a = state->a >> 7; - + tex_sample(state); - + CLAMP_RGBA(r, g, b, a); - + state->dest_rgba.r = ((state->dest_rgba.r) * r) >> 8; state->dest_rgba.g = ((state->dest_rgba.g) * g) >> 8; state->dest_rgba.b = ((state->dest_rgba.b) * b) >> 8; @@ -2864,13 +2864,13 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 uint8_t *vram = (uint8_t *)svga->vram; int x_dir = s3d_tri->tlr ? 1 : -1; - + int use_z = !(s3d_tri->cmd_set & CMD_SET_ZB_MODE); int y_count = yc; - + int bpp = (s3d_tri->cmd_set >> 2) & 7; - + uint32_t dest_offset = 0, z_offset = 0; uint32_t src_col; @@ -2888,7 +2888,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 int update; uint16_t src_z = 0; - + if (s3d_tri->cmd_set & CMD_SET_HC) { if (state->y < s3d_tri->clip_t) @@ -2896,10 +2896,10 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 if (state->y > s3d_tri->clip_b) { int diff_y = state->y - s3d_tri->clip_b; - + if (diff_y > y_count) diff_y = y_count; - + state->base_u += (s3d_tri->TdUdY * diff_y); state->base_v += (s3d_tri->TdVdY * diff_y); state->base_z += (s3d_tri->TdZdY * diff_y); @@ -2922,7 +2922,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 dest_offset = s3d_tri->dest_base + (state->y * s3d_tri->dest_str); z_offset = s3d_tri->z_base + (state->y * s3d_tri->z_str); - + while (y_count > 0) { x = (state->x1 + ((1 << 20) - 1)) >> 20; @@ -2964,7 +2964,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 if (x < s3d_tri->clip_l) { int diff_x = s3d_tri->clip_l - x; - + z += (s3d_tri->TdZdX * diff_x); state->u += (s3d_tri->TdUdX * diff_x); state->v += (s3d_tri->TdVdX * diff_x); @@ -2974,7 +2974,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 state->a += (s3d_tri->TdAdX * diff_x); state->d += (s3d_tri->TdDdX * diff_x); state->w += (s3d_tri->TdWdX * diff_x); - + x = s3d_tri->clip_l; } } @@ -2989,7 +2989,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 if (x > s3d_tri->clip_r) { int diff_x = x - s3d_tri->clip_r; - + z += (s3d_tri->TdZdX * diff_x); state->u += (s3d_tri->TdUdX * diff_x); state->v += (s3d_tri->TdVdX * diff_x); @@ -2999,7 +2999,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 state->a += (s3d_tri->TdAdX * diff_x); state->d += (s3d_tri->TdDdX * diff_x); state->w += (s3d_tri->TdWdX * diff_x); - + x = s3d_tri->clip_r; } } @@ -3012,7 +3012,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 x &= 0xfff; xe &= 0xfff; - + while (x != xe) { update = 1; _x = x; _y = state->y; @@ -3104,7 +3104,7 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 switch (bpp) { - case 0: /*8 bpp*/ + case 0: /*8 bpp*/ /*Not implemented yet*/ break; case 1: /*16 bpp*/ @@ -3138,13 +3138,13 @@ static void tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int3 state->w += s3d_tri->TdWdX; dest_addr += x_offset; z_addr += xz_offset; - + x = (x + x_dir) & 0xfff; } } y_count--; - + tri_skip_line: state->x1 += dx1; state->x2 += dx2; @@ -3187,11 +3187,11 @@ static void s3_virge_triangle(virge_t *virge, s3d_t *s3d_tri) state.tbu = s3d_tri->tbu << 11; state.tbv = s3d_tri->tbv << 11; - + state.max_d = (s3d_tri->cmd_set >> 8) & 15; - + state.tex_bdr_clr = s3d_tri->tex_bdr_clr; - + state.cmd_set = s3d_tri->cmd_set; state.base_u = s3d_tri->tus; @@ -3203,7 +3203,7 @@ static void s3_virge_triangle(virge_t *virge, s3d_t *s3d_tri) state.base_a = (int32_t)s3d_tri->tas; state.base_d = s3d_tri->tds; state.base_w = s3d_tri->tws; - + tex_base = s3d_tri->tex_base; for (c = 9; c >= 0; c--) { @@ -3242,8 +3242,8 @@ static void s3_virge_triangle(virge_t *virge, s3d_t *s3d_tri) default: s3_virge_log("bad triangle type %x\n", (s3d_tri->cmd_set >> 27) & 0xf); return; - } - + } + switch (((s3d_tri->cmd_set >> 12) & 7) | ((s3d_tri->cmd_set & (1 << 29)) ? 8 : 0)) { case 0: case 1: @@ -3283,7 +3283,7 @@ static void s3_virge_triangle(virge_t *virge, s3d_t *s3d_tri) tex_sample = virge->bilinear_enabled ? tex_sample_persp_normal_filter : tex_sample_persp_normal; break; } - + switch ((s3d_tri->cmd_set >> 5) & 7) { case 0: @@ -3307,9 +3307,9 @@ static void s3_virge_triangle(virge_t *virge, s3d_t *s3d_tri) tri(virge, s3d_tri, &state, s3d_tri->ty01, s3d_tri->TdXdY02, s3d_tri->TdXdY01); state.x2 = s3d_tri->txend12; tri(virge, s3d_tri, &state, s3d_tri->ty12, s3d_tri->TdXdY02, s3d_tri->TdXdY12); - + end_time = plat_timer_read(); - + virge->blitter_time += end_time - start_time; } @@ -3327,17 +3327,17 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine) svga->hwcursor_latch.addr += 16; switch (svga->bpp) - { + { case 15: fg = video_15to32[virge->hwc_fg_col & 0xffff]; bg = video_15to32[virge->hwc_bg_col & 0xffff]; break; - + case 16: fg = video_16to32[virge->hwc_fg_col & 0xffff]; bg = video_16to32[virge->hwc_bg_col & 0xffff]; break; - + case 24: case 32: fg = virge->hwc_fg_col; bg = virge->hwc_bg_col; @@ -3363,7 +3363,7 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine) if (dat[0] & 0x8000) buffer32->line[displine][offset + svga->x_add] = (dat[1] & 0x8000) ? fg : bg; } - + offset++; dat[0] <<= 1; dat[1] <<= 1; @@ -3381,7 +3381,7 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine) else if (dat[1] & 0x8000) buffer32->line[displine][offset + svga->x_add] ^= 0xffffff; } - + offset++; dat[0] <<= 1; dat[1] <<= 1; @@ -3630,7 +3630,7 @@ static void s3_virge_overlay_draw(svga_t *svga, int displine) int x; uint32_t *p; uint8_t *src = &svga->vram[svga->overlay_latch.addr]; - + p = &(buffer32->line[displine][offset + svga->x_add]); if ((offset + virge->streams.sec_w) > virge->streams.pri_w) @@ -3639,7 +3639,7 @@ static void s3_virge_overlay_draw(svga_t *svga, int displine) x_size = virge->streams.sec_w + 1; OVERLAY_SAMPLE(); - + for (x = 0; x < x_size; x++) { *p++ = r[x_read] | (g[x_read] << 8) | (b[x_read] << 16); @@ -3672,22 +3672,22 @@ static uint8_t s3_virge_pci_read(int func, int addr, void *p) switch (addr) { case 0x00: ret = 0x33; break; /*'S3'*/ case 0x01: ret = 0x53; break; - + case 0x02: ret = virge->virge_id_low; break; case 0x03: ret = virge->virge_id_high; break; case PCI_REG_COMMAND: ret = virge->pci_regs[PCI_REG_COMMAND] & 0x27; break; - + case 0x07: ret = virge->pci_regs[0x07] & 0x36; break; - + case 0x08: ret = virge->virge_rev; break; /*Revision ID*/ case 0x09: ret = 0; break; /*Programming interface*/ - + case 0x0a: ret = 0x00; break; /*Supports VGA interface*/ case 0x0b: ret = 0x03; break; case 0x0d: ret = virge->pci_regs[0x0d] & 0xf8; break; - + case 0x10: ret = 0x00; break;/*Linear frame buffer address*/ case 0x11: ret = 0x00; break; case 0x12: ret = 0x00; break; @@ -3706,12 +3706,12 @@ static uint8_t s3_virge_pci_read(int func, int addr, void *p) case 0x34: ret = (virge->chip >= S3_VIRGEGX2) ? 0xdc : 0x00; break; case 0x3c: ret = virge->pci_regs[0x3c]; break; - + case 0x3d: ret = PCI_INTA; break; /*INTA*/ - + case 0x3e: ret = 0x04; break; case 0x3f: ret = 0xff; break; - + case 0x80: ret = 0x02; break; /* AGP capability */ case 0x81: ret = 0x00; break; case 0x82: ret = 0x10; break; /* assumed AGP 1.0 */ @@ -3745,8 +3745,8 @@ static void s3_virge_pci_write(int func, int addr, uint8_t val, void *p) case 0x00: case 0x01: case 0x02: case 0x03: case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x3d: case 0x3e: case 0x3f: - return; - + return; + case PCI_REG_COMMAND: if (val & PCI_COMMAND_IO) { @@ -3756,12 +3756,12 @@ static void s3_virge_pci_write(int func, int addr, uint8_t val, void *p) else io_removehandler(0x03c0, 0x0020, s3_virge_in, NULL, NULL, s3_virge_out, NULL, NULL, virge); virge->pci_regs[PCI_REG_COMMAND] = val & 0x27; - s3_virge_updatemapping(virge); + s3_virge_updatemapping(virge); return; case 0x07: virge->pci_regs[0x07] = val & 0x3e; return; - case 0x0d: + case 0x0d: virge->pci_regs[0x0d] = val & 0xf8; return; @@ -3785,7 +3785,7 @@ static void s3_virge_pci_write(int func, int addr, uint8_t val, void *p) mem_mapping_disable(&virge->bios_rom.mapping); } return; - case 0x3c: + case 0x3c: virge->pci_regs[0x3c] = val; return; @@ -3833,7 +3833,7 @@ static void s3_virge_reset(void *priv) virge->pci_regs[0x06] = 0; virge->pci_regs[0x07] = 2; virge->pci_regs[0x32] = 0x0c; - virge->pci_regs[0x3d] = 1; + virge->pci_regs[0x3d] = 1; virge->pci_regs[0x3e] = 4; virge->pci_regs[0x3f] = 0xff; @@ -3887,7 +3887,7 @@ static void s3_virge_reset(void *priv) else virge->svga.crtc[0x36] = 2 | (0 << 2) | (1 << 4) | (0 << 5); break; - } + } if (virge->local == S3_VIRGE_GX) virge->svga.crtc[0x36] |= (1 << 2); } @@ -3916,8 +3916,8 @@ static void *s3_virge_init(const device_t *info) virge->memory_size = 4; else virge->memory_size = device_get_config_int("memory"); - - + + switch(info->local) { case S3_VIRGE_325: bios_fn = ROM_VIRGE_325; @@ -3965,7 +3965,7 @@ static void *s3_virge_init(const device_t *info) rom_init(&virge->bios_rom, (char *) bios_fn, 0xc0000, 0x10000, 0xffff, 0, MEM_MAPPING_EXTERNAL); else rom_init(&virge->bios_rom, (char *) bios_fn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + mem_mapping_disable(&virge->bios_rom.mapping); mem_mapping_add(&virge->linear_mapping, 0, 0, svga_read_linear, @@ -4003,10 +4003,10 @@ static void *s3_virge_init(const device_t *info) virge->pci_regs[0x06] = 0; virge->pci_regs[0x07] = 2; virge->pci_regs[0x32] = 0x0c; - virge->pci_regs[0x3d] = 1; + virge->pci_regs[0x3d] = 1; virge->pci_regs[0x3e] = 4; virge->pci_regs[0x3f] = 0xff; - + virge->virge_rev = 0; virge->virge_id = 0xe1; virge->is_agp = !!(info->flags & DEVICE_AGP); @@ -4105,11 +4105,11 @@ static void *s3_virge_init(const device_t *info) else virge->svga.crtc[0x36] = 2 | (0 << 2) | (1 << 4) | (0 << 5); break; - } + } if (info->local == S3_VIRGE_GX) virge->svga.crtc[0x36] |= (1 << 2); } - + virge->svga.crtc[0x37] = 1 | (7 << 5); virge->svga.crtc[0x53] = 8; @@ -4117,7 +4117,7 @@ static void *s3_virge_init(const device_t *info) virge->i2c = i2c_gpio_init("ddc_s3_virge"); virge->ddc = ddc_init(i2c_gpio_get_bus(virge->i2c)); - + virge->svga.packed_chain4 = 1; virge->wake_render_thread = thread_create_event(); @@ -4127,9 +4127,9 @@ static void *s3_virge_init(const device_t *info) virge->render_thread = thread_create(render_thread, virge); timer_add(&virge->tri_timer, s3_virge_tri_timer, virge, 0); - + virge->local = info->local; - + return virge; } @@ -4148,7 +4148,7 @@ static void s3_virge_close(void *p) ddc_close(virge->ddc); i2c_gpio_close(virge->i2c); - + free(virge); } @@ -4205,7 +4205,7 @@ static int s3_trio3d2x_available(void) static void s3_virge_speed_changed(void *p) { virge_t *virge = (virge_t *)p; - + svga_recalctimings(&virge->svga); } diff --git a/src/video/vid_sc1148x_ramdac.c b/src/video/vid_sc1148x_ramdac.c index 0134c31d7..502690ade 100644 --- a/src/video/vid_sc1148x_ramdac.c +++ b/src/video/vid_sc1148x_ramdac.c @@ -99,7 +99,7 @@ sc1148x_ramdac_in(uint16_t addr, int rs2, void *p, svga_t *svga) sc1148x_ramdac_t *ramdac = (sc1148x_ramdac_t *) p; uint8_t ret = 0xff; uint8_t rs = (addr & 0x03); - rs |= ((!!rs2) << 2); + rs |= ((!!rs2) << 2); switch (addr) { case 0x3c6: @@ -186,4 +186,4 @@ const device_t sc11486_ramdac_device = 0, 3, sc1148x_ramdac_init, sc1148x_ramdac_close, NULL, { NULL }, NULL, NULL -}; \ No newline at end of file +}; diff --git a/src/video/vid_sigma.c b/src/video/vid_sigma.c index 08ac011d3..e7b154ba4 100644 --- a/src/video/vid_sigma.c +++ b/src/video/vid_sigma.c @@ -36,30 +36,30 @@ /* The Sigma Designs Color 400 is a video card from 1985, presumably intended * as an EGA competitor. - * - * The hardware seems to have gone through various iterations; I've seen + * + * The hardware seems to have gone through various iterations; I've seen * pictures of full-length and half-length versions. - * TH99 describes the jumpers / switches: + * TH99 describes the jumpers / switches: * * - * The card is CGA-compatible at BIOS level, but to improve compatibility - * attempts to write to the CGA I/O ports at 0x3D0-0x3DF trigger an NMI. The + * The card is CGA-compatible at BIOS level, but to improve compatibility + * attempts to write to the CGA I/O ports at 0x3D0-0x3DF trigger an NMI. The * card's BIOS handles the NMI and translates the CGA writes into commands * to its own hardware at 0x2D0-0x2DF. (DIP switches on the card allow the * base address to be changed, but since the BIOS dump I have doesn't support * this I haven't emulated it. Likewise the BIOS ROM address can be changed, * but I'm going with the default of 0xC0000). * - * The BIOS still functions if the NMI system isn't operational. There + * The BIOS still functions if the NMI system isn't operational. There * doesn't seem to be a jumper or DIP switch to lock it out, but at startup * the BIOS tests for its presence and configures itself to work or not * as required. I've therefore added a configuration option to handle this. * - * The card's real CRTC at 0x2D0/0x2D1 appears to be a 6845. One oddity is - * that all its horizontal counts are halved compared to what a real CGA - * uses; 40-column modes have a width of 20, and 80-column modes have a + * The card's real CRTC at 0x2D0/0x2D1 appears to be a 6845. One oddity is + * that all its horizontal counts are halved compared to what a real CGA + * uses; 40-column modes have a width of 20, and 80-column modes have a * width of 40. This means that the CRTC cursor position (registers 14/15) can - * only address even-numbered columns, so the top bit of the control + * only address even-numbered columns, so the top bit of the control * register at 0x2D9 is used to adjust the position. * * Apart from the CRTC, registers are: @@ -72,7 +72,7 @@ * Graphics 320x200: 0x0F * Graphics 640x200: 0x1F * Graphics 640x400: 0x7F - * + * * I have assumed this is a bitmap with the following meaning: */ #define MODE_80COLS 0x01 /* For text modes, 80 columns across */ #define MODE_GRAPHICS 0x02 /* Graphics mode */ @@ -89,7 +89,7 @@ #define CTL_SET_LPEN 0x04 /* Strobe 0 to set lightpen latch */ #define CTL_PALETTE 0x01 /* 0x2DE writes to palette (1) or plane (0) */ /* - * The card BIOS seems to support two variants of the hardware: One where + * The card BIOS seems to support two variants of the hardware: One where * bits 2 and 3 are normally 1 and are set to 0 to set/clear the latch, and * one where they are normally 0 and are set to 1. Behaviour is selected by * whether the byte at C000:17FFh is greater than 2Fh. @@ -103,9 +103,9 @@ #define STATUS_LPEN_A 0x02 /* Edge from lightpen has set trigger */ #define STATUS_RETR_H 0x01 /* Horizontal retrace */ /* - * 0x2DB: On read: Byte written to the card that triggered NMI + * 0x2DB: On read: Byte written to the card that triggered NMI * 0x2DB: On write: Resets the 'card raised NMI' flag. - * 0x2DC: On read: Bit 7 set if the card raised NMI. If so, bits 0-3 + * 0x2DC: On read: Bit 7 set if the card raised NMI. If so, bits 0-3 * give the low 4 bits of the I/O port address. * 0x2DC: On write: Resets the NMI. * 0x2DD: Memory paging. The memory from 0xC1800 to 0xC1FFF can be either: @@ -120,28 +120,28 @@ * Writing port 2DD switches to RAM. * * 0x2DE: Meaning depends on bottom bit of value written to port 0x2D9. - * Bit 0 set: Write to palette. High 4 bits of value = register, + * Bit 0 set: Write to palette. High 4 bits of value = register, * low 4 bits = RGBI values (active low) * Bit 0 clear: Write to plane select. Low 2 bits of value select - * plane 0-3 + * plane 0-3 */ - + typedef struct sigma_t { mem_mapping_t mapping, bios_ram; - rom_t bios_rom; + rom_t bios_rom; uint8_t crtc[32]; /* CRTC: Real values */ uint8_t lastport; /* Last I/O port written */ uint8_t lastwrite; /* Value written to that port */ uint8_t sigma_ctl; /* Controls register: - * Bit 7 is low bit of cursor position + * Bit 7 is low bit of cursor position * Bit 5 set if writes to CGA ports trigger NMI * Bit 3 clears lightpen latch * Bit 2 sets lightpen latch - * Bit 1 controls meaning of port 2DE + * Bit 1 controls meaning of port 2DE */ uint8_t enable_nmi; /* Enable the NMI mechanism for CGA emulation?*/ uint8_t rom_paged; /* Is ROM paged in at 0xC1800? */ @@ -155,7 +155,7 @@ typedef struct sigma_t uint16_t ma, maback; - int crtcreg; /* CRTC: Real selected register */ + int crtcreg; /* CRTC: Real selected register */ int linepos, displine; int sc, vc; @@ -173,7 +173,7 @@ typedef struct sigma_t pc_timer_t timer; uint8_t *vram; - uint8_t bram[2048]; + uint8_t bram[2048]; uint8_t palette[16]; @@ -184,7 +184,7 @@ typedef struct sigma_t #define COMPOSITE_OLD 0 #define COMPOSITE_NEW 1 -static uint8_t crtcmask[32] = +static uint8_t crtcmask[32] = { 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -230,7 +230,7 @@ sigma_out(uint16_t addr, uint8_t val, void *p) if (sigma->crtcreg < 0xe || sigma->crtcreg > 0x10) { fullchange = changeframecount; sigma_recalctimings(sigma); - } + } } return; @@ -283,13 +283,13 @@ sigma_in(uint16_t addr, void *p) result = sigma->crtc[sigma->crtcreg & 0x1F]; break; case 0x2DA: - result = (sigma->sigma_ctl & 0xE0) | + result = (sigma->sigma_ctl & 0xE0) | (sigma->sigmastat & 0x1F); break; - case 0x2DB: + case 0x2DB: result = sigma->lastwrite; /* Value that triggered NMI */ break; - case 0x2DC: + case 0x2DC: result = sigma->lastport; /* Port that triggered NMI */ break; case 0x2DD: /* Page in ROM at 0xC1800 */ @@ -436,7 +436,7 @@ static void sigma_text80(sigma_t *sigma) if (!(sigma->sigmamode & MODE_NOBLINK)) { cols[1] = (attr & 15) | 16; cols[0] = ((attr >> 4) & 7) | 16; - if ((sigma->cgablink & 8) && (attr & 0x80) && !sigma->drawcursor) + if ((sigma->cgablink & 8) && (attr & 0x80) && !sigma->drawcursor) cols[1] = cols[0]; } else { /* No blink */ cols[1] = (attr & 15) | 16; @@ -492,7 +492,7 @@ sigma_text40(sigma_t *sigma) if (!(sigma->sigmamode & MODE_NOBLINK)) { cols[1] = (attr & 15) | 16; cols[0] = ((attr >> 4) & 7) | 16; - if ((sigma->cgablink & 8) && (attr & 0x80) && !sigma->drawcursor) + if ((sigma->cgablink & 8) && (attr & 0x80) && !sigma->drawcursor) cols[1] = cols[0]; } else { /* No blink */ cols[1] = (attr & 15) | 16; @@ -500,13 +500,13 @@ sigma_text40(sigma_t *sigma) } if (drawcursor) { - for (c = 0; c < 8; c++) { - buffer32->line[sigma->displine][(x << 4) + 2*c + 8] = + for (c = 0; c < 8; c++) { + buffer32->line[sigma->displine][(x << 4) + 2*c + 8] = buffer32->line[sigma->displine][(x << 4) + 2*c + 9] = cols[(fontdatm[chr][sigma->sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0xf; } } else { for (c = 0; c < 8; c++) { - buffer32->line[sigma->displine][(x << 4) + 2*c + 8] = + buffer32->line[sigma->displine][(x << 4) + 2*c + 8] = buffer32->line[sigma->displine][(x << 4) + 2*c + 9] = cols[(fontdatm[chr][sigma->sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; } } @@ -525,18 +525,18 @@ sigma_gfx400(sigma_t *sigma) unsigned char *vram = &sigma->vram[((sigma->ma << 1) & 0x1FFF) + (sigma->sc & 3) * 0x2000]; uint8_t plane[4]; - uint8_t mask, col, c; + uint8_t mask, col, c; for (x = 0; x < (sigma->crtc[1] << 1); x++) { - plane[0] = vram[x]; - plane[1] = vram[0x8000 + x]; - plane[2] = vram[0x10000 + x]; - plane[3] = vram[0x18000 + x]; + plane[0] = vram[x]; + plane[1] = vram[0x8000 + x]; + plane[2] = vram[0x10000 + x]; + plane[3] = vram[0x18000 + x]; for (c = 0, mask = 0x80; c < 8; c++, mask >>= 1) { - col = ((plane[3] & mask) ? 8 : 0) | - ((plane[2] & mask) ? 4 : 0) | - ((plane[1] & mask) ? 2 : 0) | + col = ((plane[3] & mask) ? 8 : 0) | + ((plane[2] & mask) ? 4 : 0) | + ((plane[1] & mask) ? 2 : 0) | ((plane[0] & mask) ? 1 : 0); col |= 16; buffer32->line[sigma->displine][(x << 3) + c + 8] = col; @@ -558,18 +558,18 @@ sigma_gfx200(sigma_t *sigma) unsigned char *vram = &sigma->vram[((sigma->ma << 1) & 0x1FFF) + (sigma->sc & 2) * 0x1000]; uint8_t plane[4]; - uint8_t mask, col, c; + uint8_t mask, col, c; for (x = 0; x < (sigma->crtc[1] << 1); x++) { - plane[0] = vram[x]; - plane[1] = vram[0x8000 + x]; - plane[2] = vram[0x10000 + x]; - plane[3] = vram[0x18000 + x]; + plane[0] = vram[x]; + plane[1] = vram[0x8000 + x]; + plane[2] = vram[0x10000 + x]; + plane[3] = vram[0x18000 + x]; for (c = 0, mask = 0x80; c < 8; c++, mask >>= 1) { - col = ((plane[3] & mask) ? 8 : 0) | - ((plane[2] & mask) ? 4 : 0) | - ((plane[1] & mask) ? 2 : 0) | + col = ((plane[3] & mask) ? 8 : 0) | + ((plane[2] & mask) ? 4 : 0) | + ((plane[1] & mask) ? 2 : 0) | ((plane[0] & mask) ? 1 : 0); col |= 16; buffer32->line[sigma->displine][(x << 3) + c + 8] = col; @@ -589,25 +589,25 @@ sigma_gfx4col(sigma_t *sigma) unsigned char *vram = &sigma->vram[((sigma->ma << 1) & 0x1FFF) + (sigma->sc & 2) * 0x1000]; uint8_t plane[4]; - uint8_t mask, col, c; + uint8_t mask, col, c; for (x = 0; x < (sigma->crtc[1] << 1); x++) { - plane[0] = vram[x]; - plane[1] = vram[0x8000 + x]; - plane[2] = vram[0x10000 + x]; - plane[3] = vram[0x18000 + x]; + plane[0] = vram[x]; + plane[1] = vram[0x8000 + x]; + plane[2] = vram[0x10000 + x]; + plane[3] = vram[0x18000 + x]; mask = 0x80; for (c = 0; c < 4; c++) { - col = ((plane[3] & mask) ? 2 : 0) | + col = ((plane[3] & mask) ? 2 : 0) | ((plane[2] & mask) ? 1 : 0); mask = mask >> 1; - col |= ((plane[3] & mask) ? 8 : 0) | + col |= ((plane[3] & mask) ? 8 : 0) | ((plane[2] & mask) ? 4 : 0); col |= 16; mask = mask >> 1; - buffer32->line[sigma->displine][(x << 3) + (c << 1) + 8] = + buffer32->line[sigma->displine][(x << 3) + (c << 1) + 8] = buffer32->line[sigma->displine][(x << 3) + (c << 1) + 9] = col; } @@ -631,7 +631,7 @@ sigma_poll(void *p) sigma->sigmastat |= STATUS_RETR_H; sigma->linepos = 1; oldsc = sigma->sc; - if ((sigma->crtc[8] & 3) == 3) + if ((sigma->crtc[8] & 3) == 3) sigma->sc = ((sigma->sc << 1) + sigma->oddeven) & 7; if (sigma->cgadispon) { if (sigma->displine < sigma->firstline) { @@ -664,13 +664,13 @@ sigma_poll(void *p) } } else { cols[0] = 16; - if (sigma->sigmamode & MODE_80COLS) + if (sigma->sigmamode & MODE_80COLS) hline(buffer32, 0, sigma->displine, (sigma->crtc[1] << 4) + 16, cols[0]); else hline(buffer32, 0, sigma->displine, (sigma->crtc[1] << 5) + 16, cols[0]); } - if (sigma->sigmamode & MODE_80COLS) + if (sigma->sigmamode & MODE_80COLS) x = (sigma->crtc[1] << 4) + 16; else x = (sigma->crtc[1] << 5) + 16; @@ -682,7 +682,7 @@ sigma_poll(void *p) if (sigma->vc == sigma->crtc[7] && !sigma->sc) sigma->sigmastat |= STATUS_RETR_V; sigma->displine++; - if (sigma->displine >= 560) + if (sigma->displine >= 560) sigma->displine = 0; } else { timer_advance_u64(&sigma->timer, sigma->dispontime); @@ -693,9 +693,9 @@ sigma_poll(void *p) sigma->sigmastat &= ~STATUS_RETR_V; } if (sigma->sc == (sigma->crtc[11] & 31) || - ((sigma->crtc[8] & 3) == 3 && sigma->sc == ((sigma->crtc[11] & 31) >> 1))) { - sigma->con = 0; - sigma->coff = 1; + ((sigma->crtc[8] & 3) == 3 && sigma->sc == ((sigma->crtc[11] & 31) >> 1))) { + sigma->con = 0; + sigma->coff = 1; } if ((sigma->crtc[8] & 3) == 3 && sigma->sc == (sigma->crtc[9] >> 1)) sigma->maback = sigma->ma; @@ -716,7 +716,7 @@ sigma_poll(void *p) sigma->vc++; sigma->vc &= 127; - if (sigma->vc == sigma->crtc[6]) + if (sigma->vc == sigma->crtc[6]) sigma->cgadispon = 0; if (oldvc == sigma->crtc[4]) { @@ -736,7 +736,7 @@ sigma_poll(void *p) sigma->displine = 0; sigma->vsynctime = 16; if (sigma->crtc[7]) { - if (sigma->sigmamode & MODE_80COLS) + if (sigma->sigmamode & MODE_80COLS) x = (sigma->crtc[1] << 4) + 16; else x = (sigma->crtc[1] << 5) + 16; @@ -795,7 +795,7 @@ sigma_poll(void *p) if (sigma->cgadispon) sigma->sigmastat &= ~STATUS_RETR_H; if ((sigma->sc == (sigma->crtc[10] & 31) || - ((sigma->crtc[8] & 3) == 3 && sigma->sc == ((sigma->crtc[10] & 31) >> 1)))) + ((sigma->crtc[8] & 3) == 3 && sigma->sc == ((sigma->crtc[10] & 31) >> 1)))) sigma->con = 1; } } @@ -815,7 +815,7 @@ static void sigma->enable_nmi = device_get_config_int("enable_nmi"); loadfont(ROM_SIGMA_FONT, 7); - rom_init(&sigma->bios_rom, ROM_SIGMA_BIOS, bios_addr, 0x2000, + rom_init(&sigma->bios_rom, ROM_SIGMA_BIOS, bios_addr, 0x2000, 0x1FFF, 0, MEM_MAPPING_EXTERNAL); /* The BIOS ROM is overlaid by RAM, so remove its default mapping and access it through sigma_bread() / sigma_bwrite() below */ @@ -825,19 +825,19 @@ static void sigma->vram = malloc(0x8000 * 4); timer_add(&sigma->timer, sigma_poll, sigma, 1); - mem_mapping_add(&sigma->mapping, 0xb8000, 0x08000, - sigma_read, NULL, NULL, - sigma_write, NULL, NULL, + mem_mapping_add(&sigma->mapping, 0xb8000, 0x08000, + sigma_read, NULL, NULL, + sigma_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, sigma); mem_mapping_add(&sigma->bios_ram, bios_addr, 0x2000, - sigma_bread, NULL, NULL, - sigma_bwrite, NULL, NULL, + sigma_bread, NULL, NULL, + sigma_bwrite, NULL, NULL, sigma->bios_rom.rom, MEM_MAPPING_EXTERNAL, sigma); - io_sethandler(0x03d0, 0x0010, - sigma_in, NULL, NULL, + io_sethandler(0x03d0, 0x0010, + sigma_in, NULL, NULL, sigma_out, NULL, NULL, sigma); - io_sethandler(0x02d0, 0x0010, - sigma_in, NULL, NULL, + io_sethandler(0x02d0, 0x0010, + sigma_in, NULL, NULL, sigma_out, NULL, NULL, sigma); /* Start with ROM paged in, BIOS RAM paged out */ diff --git a/src/video/vid_stg_ramdac.c b/src/video/vid_stg_ramdac.c index 9f216056b..fd242b487 100644 --- a/src/video/vid_stg_ramdac.c +++ b/src/video/vid_stg_ramdac.c @@ -102,11 +102,11 @@ stg_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga) case 0: case 1: case 2: - case 3: + case 3: break; case 4: /* REG06 */ old = ramdac->command; - ramdac->command = val; + ramdac->command = val; if ((old ^ val) & 8) stg_ramdac_set_bpp(svga, ramdac); else { @@ -114,11 +114,11 @@ stg_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga) stg_ramdac_set_bpp(svga, ramdac); } break; - case 5: - ramdac->index = (ramdac->index & 0xff00) | val; + case 5: + ramdac->index = (ramdac->index & 0xff00) | val; break; case 6: - ramdac->index = (ramdac->index & 0xff) | (val << 8); + ramdac->index = (ramdac->index & 0xff) | (val << 8); break; case 7: if (ramdac->index < 0x100) @@ -160,13 +160,13 @@ stg_ramdac_in(uint16_t addr, void *p, svga_t *svga) temp = 0xff; break; case 4: - temp = ramdac->command; + temp = ramdac->command; break; case 5: - temp = ramdac->index & 0xff; + temp = ramdac->index & 0xff; break; case 6: - temp = ramdac->index >> 8; + temp = ramdac->index >> 8; break; case 7: switch (ramdac->index) { diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index c5ff2ed43..9640b5540 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -78,7 +78,7 @@ svga_set_override(svga_t *svga, int val) overscan_x = (svga->seqregs[1] & 1) ? 16 : 18; - if (svga->seqregs[1] & 8) + if (svga->seqregs[1] & 8) overscan_x <<= 1; } else overscan_x = overscan_y = 16; @@ -108,7 +108,7 @@ svga_out(uint16_t addr, uint8_t val, void *p) svga->fullchange = changeframecount; o = svga->attrregs[svga->attraddr & 31]; svga->attrregs[svga->attraddr & 31] = val; - if (svga->attraddr < 16) + if (svga->attraddr < 16) svga->fullchange = changeframecount; if (svga->attraddr == 0x10 || svga->attraddr == 0x14 || svga->attraddr < 0x10) { for (c = 0; c < 16; c++) { @@ -147,8 +147,8 @@ svga_out(uint16_t addr, uint8_t val, void *p) io_sethandler(0x03a0, 0x0020, svga->video_in, NULL, NULL, svga->video_out, NULL, NULL, svga->p); svga_recalctimings(svga); break; - case 0x3c4: - svga->seqaddr = val; + case 0x3c4: + svga->seqaddr = val; break; case 0x3c5: if (svga->seqaddr > 0xf) @@ -159,9 +159,9 @@ svga_out(uint16_t addr, uint8_t val, void *p) svga_recalctimings(svga); switch (svga->seqaddr & 0xf) { case 1: - if (svga->scrblank && !(val & 0x20)) - svga->fullchange = 3; - svga->scrblank = (svga->scrblank & ~0x20) | (val & 0x20); + if (svga->scrblank && !(val & 0x20)) + svga->fullchange = 3; + svga->scrblank = (svga->scrblank & ~0x20) | (val & 0x20); svga_recalctimings(svga); break; case 2: @@ -175,7 +175,7 @@ svga_out(uint16_t addr, uint8_t val, void *p) if (val & 0x20) svga->charsetb += 0x8000; break; - case 4: + case 4: svga->chain2_write = !(val & 4); svga->chain4 = val & 8; svga->fast = (svga->gdcreg[8] == 0xff && !(svga->gdcreg[3] & 0x18) && @@ -183,8 +183,8 @@ svga_out(uint16_t addr, uint8_t val, void *p) break; } break; - case 0x3c6: - svga->dac_mask = val; + case 0x3c6: + svga->dac_mask = val; break; case 0x3c7: case 0x3c8: @@ -199,28 +199,28 @@ svga_out(uint16_t addr, uint8_t val, void *p) switch (svga->dac_pos) { case 0: svga->dac_r = val; - svga->dac_pos++; + svga->dac_pos++; break; case 1: svga->dac_g = val; - svga->dac_pos++; + svga->dac_pos++; break; case 2: index = svga->dac_addr & 255; svga->vgapal[index].r = svga->dac_r; svga->vgapal[index].g = svga->dac_g; - svga->vgapal[index].b = val; + svga->vgapal[index].b = val; if (svga->ramdac_type == RAMDAC_8BIT) svga->pallook[index] = makecol32(svga->vgapal[index].r, svga->vgapal[index].g, svga->vgapal[index].b); else svga->pallook[index] = makecol32(video_6to8[svga->vgapal[index].r & 0x3f], video_6to8[svga->vgapal[index].g & 0x3f], video_6to8[svga->vgapal[index].b & 0x3f]); - svga->dac_pos = 0; - svga->dac_addr = (svga->dac_addr + 1) & 255; + svga->dac_pos = 0; + svga->dac_addr = (svga->dac_addr + 1) & 255; break; } break; case 0x3ce: - svga->gdcaddr = val; + svga->gdcaddr = val; break; case 0x3cf: o = svga->gdcreg[svga->gdcaddr & 15]; @@ -262,7 +262,7 @@ svga_out(uint16_t addr, uint8_t val, void *p) svga->colournocare = val; break; } - svga->gdcreg[svga->gdcaddr & 15] = val; + svga->gdcreg[svga->gdcaddr & 15] = val; svga->fast = (svga->gdcreg[8] == 0xff && !(svga->gdcreg[3] & 0x18) && !svga->gdcreg[1]) && ((svga->chain4 && svga->packed_chain4) || svga->fb_only); if (((svga->gdcaddr & 15) == 5 && (val ^ o) & 0x70) || @@ -311,22 +311,22 @@ svga_in(uint16_t addr, void *p) index = (svga->dac_addr - 1) & 255; switch (svga->dac_pos) { case 0: - svga->dac_pos++; + svga->dac_pos++; if (svga->ramdac_type == RAMDAC_8BIT) ret = svga->vgapal[index].r; else ret = svga->vgapal[index].r & 0x3f; break; case 1: - svga->dac_pos++; + svga->dac_pos++; if (svga->ramdac_type == RAMDAC_8BIT) ret = svga->vgapal[index].g; else ret = svga->vgapal[index].g & 0x3f; break; case 2: - svga->dac_pos=0; - svga->dac_addr = (svga->dac_addr + 1) & 255; + svga->dac_pos=0; + svga->dac_addr = (svga->dac_addr + 1) & 255; if (svga->ramdac_type == RAMDAC_8BIT) ret = svga->vgapal[index].b; else @@ -454,8 +454,8 @@ svga_recalctimings(svga_t *svga) svga->ma_latch = ((svga->crtc[0xc] << 8) | svga->crtc[0xd]) + ((svga->crtc[8] & 0x60) >> 5); svga->ca_adj = 0; - - svga->rowcount = svga->crtc[9] & 31; + + svga->rowcount = svga->crtc[9] & 31; svga->hdisp_time = svga->hdisp; svga->render = svga_render_blank; @@ -474,10 +474,10 @@ svga_recalctimings(svga_t *svga) svga->hdisp_old = svga->hdisp; } else { svga->hdisp *= (svga->seqregs[1] & 8) ? 16 : 8; - svga->hdisp_old = svga->hdisp; + svga->hdisp_old = svga->hdisp; switch (svga->gdcreg[5] & 0x60) { - case 0x00: + case 0x00: if (svga->seqregs[1] & 8) /*Low res (320)*/ svga->render = svga_render_4bpp_lowres; else @@ -547,12 +547,12 @@ svga_recalctimings(svga_t *svga) if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { overscan_x = (svga->seqregs[1] & 1) ? 16 : 18; - if (svga->seqregs[1] & 8) + if (svga->seqregs[1] & 8) overscan_x <<= 1; } else overscan_x = 16; - if (svga->recalctimings_ex) + if (svga->recalctimings_ex) svga->recalctimings_ex(svga); svga->y_add = (overscan_y >> 1) - (svga->crtc[8] & 0x1f); @@ -719,12 +719,12 @@ svga_poll(void *p) } else svga_do_render(svga); - if (svga->lastline < svga->displine) + if (svga->lastline < svga->displine) svga->lastline = svga->displine; } svga->displine++; - if (svga->interlace) + if (svga->interlace) svga->displine++; if ((svga->cgastat & 8) && ((svga->displine & 15) == (svga->crtc[0x11] & 15)) && svga->vslines) svga->cgastat &= ~8; @@ -734,7 +734,7 @@ svga_poll(void *p) } else { timer_advance_u64(&svga->timer, svga->dispontime); - if (svga->dispon) + if (svga->dispon) svga->cgastat &= ~1; svga->hdisp_on = 0; @@ -772,10 +772,10 @@ svga_poll(void *p) if (svga->vc == svga->split) { ret = 1; - + if (svga->line_compare) ret = svga->line_compare(svga); - + if (ret) { if (svga->interlace && svga->oddeven) svga->ma = svga->maback = (svga->rowoffset << 1) + ((svga->crtc[5] & 0x60) >> 5); @@ -783,6 +783,7 @@ svga_poll(void *p) svga->ma = svga->maback = ((svga->crtc[5] & 0x60) >> 5); svga->ma = (svga->ma << 2); svga->maback = (svga->maback << 2); + svga->sc = 0; if (svga->attrregs[0x10] & 0x20) { svga->scrollcache = 0; @@ -802,15 +803,15 @@ svga_poll(void *p) else svga->cursoron = svga->blink & (16 + (16 * blink_delay)); - if (!(svga->gdcreg[6] & 1) && !(svga->blink & 15)) + if (!(svga->gdcreg[6] & 1) && !(svga->blink & 15)) svga->fullchange = 2; svga->blink = (svga->blink + 1) & 0x7f; for (x = 0; x < ((svga->vram_mask + 1) >> 12); x++) { - if (svga->changedvram[x]) + if (svga->changedvram[x]) svga->changedvram[x]--; } - if (svga->fullchange) + if (svga->fullchange) svga->fullchange--; } if (svga->vc == svga->vsyncstart) { @@ -896,14 +897,14 @@ svga_poll(void *p) svga->overlay_on = 0; svga->overlay_latch = svga->overlay; } - if (svga->sc == (svga->crtc[10] & 31)) + if (svga->sc == (svga->crtc[10] & 31)) svga->con = 1; } } int -svga_init(const device_t *info, svga_t *svga, void *p, int memsize, +svga_init(const device_t *info, svga_t *svga, void *p, int memsize, void (*recalctimings_ex)(struct svga_t *svga), uint8_t (*video_in) (uint16_t addr, void *p), void (*video_out)(uint16_t addr, uint8_t val, void *p), @@ -936,11 +937,11 @@ svga_init(const device_t *info, svga_t *svga, void *p, int memsize, svga->dispontime = 1000ull << 32; svga->dispofftime = 1000ull << 32; svga->bpp = 8; - svga->vram = malloc(memsize); + svga->vram = calloc(memsize, 1); svga->vram_max = memsize; svga->vram_display_mask = svga->vram_mask = memsize - 1; svga->decode_mask = 0x7fffff; - svga->changedvram = malloc(memsize >> 12); + svga->changedvram = calloc(memsize >> 12, 1); svga->recalctimings_ex = recalctimings_ex; svga->video_in = video_in; svga->video_out = video_out; @@ -950,9 +951,9 @@ svga_init(const device_t *info, svga_t *svga, void *p, int memsize, svga->hwcursor.xsize = svga->hwcursor.ysize = 32; svga->dac_hwcursor.xsize = svga->dac_hwcursor.ysize = 32; - + svga->translate_address = NULL; - svga->ksc5601_english_font_type = 0; + svga->ksc5601_english_font_type = 0; if ((info->flags & DEVICE_PCI) || (info->flags & DEVICE_VLB) || (info->flags & DEVICE_MCA)) { mem_mapping_add(&svga->mapping, 0xa0000, 0x20000, diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 7cd9fa8b1..ddd3ad0eb 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -35,9 +35,9 @@ svga_render_null(svga_t *svga) if ((svga->displine + svga->y_add) < 0) return; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; - svga->lastline_draw = svga->displine; + svga->lastline_draw = svga->displine; } void @@ -48,7 +48,7 @@ svga_render_blank(svga_t *svga) if ((svga->displine + svga->y_add) < 0) return; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -110,7 +110,7 @@ svga_render_overscan_right(svga_t *svga) void svga_render_text_40(svga_t *svga) -{ +{ uint32_t *p; int x, xx; int drawcursor, xinc; @@ -121,7 +121,7 @@ svga_render_text_40(svga_t *svga) if ((svga->displine + svga->y_add) < 0) return; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -130,8 +130,8 @@ svga_render_text_40(svga_t *svga) xinc = (svga->seqregs[1] & 1) ? 16 : 18; for (x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { - uint32_t addr = svga->remap_func(svga, svga->ma) & svga->vram_display_mask; - + uint32_t addr = svga->remap_func(svga, svga->ma) & svga->vram_display_mask; + drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron); if (svga->crtc[0x17] & 0x80) { @@ -144,32 +144,32 @@ svga_render_text_40(svga_t *svga) else charaddr = svga->charseta + (chr * 128); if (drawcursor) { - bg = svga->pallook[svga->egapal[attr & 15]]; - fg = svga->pallook[svga->egapal[attr >> 4]]; + bg = svga->pallook[svga->egapal[attr & 15]]; + fg = svga->pallook[svga->egapal[attr >> 4]]; } else { fg = svga->pallook[svga->egapal[attr & 15]]; bg = svga->pallook[svga->egapal[attr >> 4]]; if (attr & 0x80 && svga->attrregs[0x10] & 8) { bg = svga->pallook[svga->egapal[(attr >> 4) & 7]]; - if (svga->blink & 16) + if (svga->blink & 16) fg = bg; } } dat = svga->vram[charaddr + (svga->sc << 2)]; if (svga->seqregs[1] & 1) { - for (xx = 0; xx < 16; xx += 2) + for (xx = 0; xx < 16; xx += 2) p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg; } else { for (xx = 0; xx < 16; xx += 2) p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg; - if ((chr & ~0x1f) != 0xc0 || !(svga->attrregs[0x10] & 4)) + if ((chr & ~0x1f) != 0xc0 || !(svga->attrregs[0x10] & 4)) p[16] = p[17] = bg; else p[16] = p[17] = (dat & 1) ? fg : bg; } - svga->ma += 4; + svga->ma += 4; p += xinc; } svga->ma &= svga->vram_display_mask; @@ -190,7 +190,7 @@ svga_render_text_80(svga_t *svga) if ((svga->displine + svga->y_add) < 0) return; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -199,8 +199,8 @@ svga_render_text_80(svga_t *svga) xinc = (svga->seqregs[1] & 1) ? 8 : 9; for (x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { - uint32_t addr = svga->remap_func(svga, svga->ma) & svga->vram_display_mask; - + uint32_t addr = svga->remap_func(svga, svga->ma) & svga->vram_display_mask; + drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron); if (svga->crtc[0x17] & 0x80) { @@ -213,31 +213,31 @@ svga_render_text_80(svga_t *svga) else charaddr = svga->charseta + (chr * 128); if (drawcursor) { - bg = svga->pallook[svga->egapal[attr & 15]]; - fg = svga->pallook[svga->egapal[attr >> 4]]; + bg = svga->pallook[svga->egapal[attr & 15]]; + fg = svga->pallook[svga->egapal[attr >> 4]]; } else { fg = svga->pallook[svga->egapal[attr & 15]]; bg = svga->pallook[svga->egapal[attr >> 4]]; if (attr & 0x80 && svga->attrregs[0x10] & 8) { bg = svga->pallook[svga->egapal[(attr >> 4) & 7]]; - if (svga->blink & 16) + if (svga->blink & 16) fg = bg; } } dat = svga->vram[charaddr + (svga->sc << 2)]; - if (svga->seqregs[1] & 1) { - for (xx = 0; xx < 8; xx++) + if (svga->seqregs[1] & 1) { + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; } else { - for (xx = 0; xx < 8; xx++) + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; - if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4)) + if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4)) p[8] = bg; - else + else p[8] = (dat & 1) ? fg : bg; } - svga->ma += 4; + svga->ma += 4; p += xinc; } svga->ma &= svga->vram_display_mask; @@ -258,7 +258,7 @@ svga_render_text_80_ksc5601(svga_t *svga) if ((svga->displine + svga->y_add) < 0) return; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -277,15 +277,15 @@ svga_render_text_80_ksc5601(svga_t *svga) else attr = 0; - if (drawcursor) { - bg = svga->pallook[svga->egapal[attr & 15]]; - fg = svga->pallook[svga->egapal[attr >> 4]]; + if (drawcursor) { + bg = svga->pallook[svga->egapal[attr & 15]]; + fg = svga->pallook[svga->egapal[attr >> 4]]; } else { fg = svga->pallook[svga->egapal[attr & 15]]; bg = svga->pallook[svga->egapal[attr >> 4]]; if (attr & 0x80 && svga->attrregs[0x10] & 8) { bg = svga->pallook[svga->egapal[(attr >> 4) & 7]]; - if (svga->blink & 16) + if (svga->blink & 16) fg = bg; } } @@ -305,38 +305,38 @@ svga_render_text_80_ksc5601(svga_t *svga) if (attr & 8) charaddr = svga->charsetb + (chr * 128); else charaddr = svga->charseta + (chr * 128); - if ((svga->ksc5601_english_font_type >> 8) == 1) + if ((svga->ksc5601_english_font_type >> 8) == 1) dat = fontdatksc5601[((svga->ksc5601_english_font_type & 0x7F) << 7) | (chr >> 1)].chr[((chr & 1) << 4) | svga->sc]; - else + else dat = svga->vram[charaddr + (svga->sc << 2)]; } if (svga->seqregs[1] & 1) { - for (xx = 0; xx < 8; xx++) + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; } else { - for (xx = 0; xx < 8; xx++) + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; - if (((chr & ~0x1f) != 0xc0) || !(svga->attrregs[0x10] & 4)) + if (((chr & ~0x1f) != 0xc0) || !(svga->attrregs[0x10] & 4)) p[8] = bg; - else + else p[8] = (dat & 1) ? fg : bg; } - svga->ma += 4; + svga->ma += 4; p += xinc; if ((x + xinc) < svga->hdisp && (chr & (nextchr | svga->ksc5601_sbyte_mask) & 0x80)) { attr = svga->vram[((svga->ma << 1) + 1) & svga->vram_display_mask]; - if (drawcursor) { - bg = svga->pallook[svga->egapal[attr & 15]]; - fg = svga->pallook[svga->egapal[attr >> 4]]; + if (drawcursor) { + bg = svga->pallook[svga->egapal[attr & 15]]; + fg = svga->pallook[svga->egapal[attr >> 4]]; } else { fg = svga->pallook[svga->egapal[attr & 15]]; bg = svga->pallook[svga->egapal[attr >> 4]]; if (attr & 0x80 && svga->attrregs[0x10] & 8) { bg = svga->pallook[svga->egapal[(attr >> 4) & 7]]; - if (svga->blink & 16) + if (svga->blink & 16) fg = bg; } } @@ -348,19 +348,19 @@ svga_render_text_80_ksc5601(svga_t *svga) else dat = 0xff; - if (svga->seqregs[1] & 1) { - for (xx = 0; xx < 8; xx++) + if (svga->seqregs[1] & 1) { + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; } else { - for (xx = 0; xx < 8; xx++) + for (xx = 0; xx < 8; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; - if (((chr & ~0x1f) != 0xc0) || !(svga->attrregs[0x10] & 4)) + if (((chr & ~0x1f) != 0xc0) || !(svga->attrregs[0x10] & 4)) p[8] = bg; - else + else p[8] = (dat & 1) ? fg : bg; } - svga->ma += 4; + svga->ma += 4; p += xinc; x += xinc; } @@ -488,7 +488,7 @@ svga_render_2bpp_headland_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -545,7 +545,7 @@ svga_render_4bpp_lowres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -604,7 +604,7 @@ svga_render_4bpp_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -663,10 +663,10 @@ svga_render_8bpp_lowres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]); @@ -713,10 +713,10 @@ svga_render_8bpp_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp/* + svga->scrollcache*/); x += 8) { dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]); @@ -764,7 +764,7 @@ svga_render_8bpp_tseng_lowres(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -810,7 +810,7 @@ svga_render_8bpp_tseng_highres(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -876,10 +876,10 @@ svga_render_15bpp_lowres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 4) { if (svga->crtc[0x17] & 0x80) { @@ -930,10 +930,10 @@ svga_render_15bpp_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { if (svga->crtc[0x17] & 0x80) { @@ -987,7 +987,7 @@ svga_render_15bpp_mix_lowres(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -1026,7 +1026,7 @@ svga_render_15bpp_mix_highres(svga_t *svga) if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -1054,7 +1054,7 @@ svga_render_15bpp_mix_highres(svga_t *svga) } else memset(&(p[x]), 0x00, 8 * sizeof(uint32_t)); } - svga->ma += x << 1; + svga->ma += x << 1; svga->ma &= svga->vram_display_mask; } } @@ -1079,7 +1079,7 @@ svga_render_16bpp_lowres(svga_t *svga) if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 4) { if (svga->crtc[0x17] & 0x80) { @@ -1130,10 +1130,10 @@ svga_render_16bpp_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { if (svga->crtc[0x17] & 0x80) { @@ -1166,7 +1166,7 @@ svga_render_16bpp_highres(svga_t *svga) *p++ = video_16to32[dat >> 16]; } else memset(&(p[x]), 0x00, 2 * sizeof(uint32_t)); - + svga->ma += 4; } } @@ -1187,14 +1187,14 @@ svga_render_24bpp_lowres(svga_t *svga) return; changed_addr = svga->remap_func(svga, svga->ma); - + if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (svga->crtc[0x17] & 0x80) { @@ -1226,10 +1226,10 @@ svga_render_24bpp_lowres(svga_t *svga) p[0] = p[1] = dat0 & 0xffffff; p[2] = p[3] = (dat0 >> 24) | ((dat1 & 0xffff) << 8); p[4] = p[5] = (dat1 >> 16) | ((dat2 & 0xff) << 16); - p[6] = p[7] = dat2 >> 8; - + p[6] = p[7] = dat2 >> 8; + svga->ma += 12; - } + } } svga->ma &= svga->vram_display_mask; } @@ -1252,10 +1252,10 @@ svga_render_24bpp_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - if (svga->firstline_draw == 2000) + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 4) { if (svga->crtc[0x17] & 0x80) { @@ -1290,7 +1290,7 @@ svga_render_24bpp_highres(svga_t *svga) memset(&(p[x]), 0x0, 4 * sizeof(uint32_t)); svga->ma += 12; - } + } } svga->ma &= svga->vram_display_mask; } @@ -1311,12 +1311,12 @@ svga_render_32bpp_lowres(svga_t *svga) changed_addr = svga->remap_func(svga, svga->ma); if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { - p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (svga->crtc[0x17] & 0x80) @@ -1359,11 +1359,11 @@ svga_render_32bpp_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (svga->crtc[0x17] & 0x80) { @@ -1405,11 +1405,11 @@ svga_render_ABGR8888_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (svga->crtc[0x17] & 0x80) { @@ -1427,9 +1427,9 @@ svga_render_ABGR8888_highres(svga_t *svga) *p++ = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); } else memset(&(p[x]), 0x0, 1 * sizeof(uint32_t)); - + svga->ma += 4; - } + } } svga->ma &= svga->vram_display_mask; } @@ -1451,11 +1451,11 @@ svga_render_RGBA8888_highres(svga_t *svga) if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { p = &buffer32->line[svga->displine + svga->y_add][svga->x_add]; - - if (svga->firstline_draw == 2000) + + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - + if (!svga->remap_required) { for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (svga->crtc[0x17] & 0x80) { diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index 529cc6460..a59a479b3 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -101,12 +101,12 @@ typedef struct tgui_t mem_mapping_t mmio_mapping; rom_t bios_rom; - + svga_t svga; int pci; - + int type, card; - + uint8_t int_line; uint8_t pci_regs[256]; @@ -127,13 +127,13 @@ typedef struct tgui_t int command; int offset; uint16_t ger22; - + int16_t err, top, left, bottom, right; int x, y, dx, dy; uint32_t src, dst, src_old, dst_old; int pat_x, pat_y; int use_src; - + int pitch, bpp; uint32_t fill_pattern[8*8]; uint32_t mono_pattern[8*8]; @@ -151,17 +151,17 @@ typedef struct tgui_t uint8_t oldctrl2, newctrl2; uint8_t oldgr0e, newgr0e; - uint32_t linear_base, linear_size, ge_base, + uint32_t linear_base, linear_size, ge_base, mmio_base; uint32_t hwc_fg_col, hwc_bg_col; - + int ramdac_state; uint8_t ramdac_ctrl; - + int clock_m, clock_n, clock_k; - + uint32_t vram_size, vram_mask; - + volatile int write_blitter; void *i2c, *ddc; @@ -212,7 +212,7 @@ dword_remap(svga_t *svga, uint32_t in_addr) { if (svga->packed_chain4) return in_addr; - + return ((in_addr << 2) & 0x3fff0) | ((in_addr >> 14) & 0xc) | (in_addr & ~0x3fffc); @@ -223,7 +223,7 @@ tgui_update_irqs(tgui_t *tgui) { if (!tgui->pci) return; - + if (!(tgui->oldctrl1 & 0x40)) { pci_set_irq(tgui->card, PCI_INTA); } else { @@ -265,7 +265,7 @@ static void tgui_set_io(tgui_t *tgui) { tgui_remove_io(tgui); - + io_sethandler(0x03c0, 0x0020, tgui_in, NULL, NULL, tgui_out, NULL, NULL, tgui); if (tgui->type >= TGUI_9440) { io_sethandler(0x43c6, 0x0004, tgui_in, NULL, NULL, tgui_out, NULL, NULL, tgui); @@ -307,18 +307,18 @@ tgui_out(uint16_t addr, uint8_t val, void *p) case 0x3C5: switch (svga->seqaddr) { - case 0xB: - tgui->oldmode = 1; + case 0xB: + tgui->oldmode = 1; break; - case 0xC: + case 0xC: if (svga->seqregs[0x0e] & 0x80) - svga->seqregs[0x0c] = val; + svga->seqregs[0x0c] = val; break; - case 0xd: + case 0xd: if (tgui->oldmode) - tgui->oldctrl2 = val; - else - tgui->newctrl2 = val; + tgui->oldctrl2 = val; + else + tgui->newctrl2 = val; break; case 0xE: if (tgui->oldmode) { @@ -329,12 +329,12 @@ tgui_out(uint16_t addr, uint8_t val, void *p) svga->seqregs[0xe] = val ^ 2; svga->write_bank = (svga->seqregs[0xe]) * 65536; } - if (!(svga->gdcreg[0xf] & 1)) + if (!(svga->gdcreg[0xf] & 1)) svga->read_bank = svga->write_bank; return; } break; - + case 0x3C6: if (tgui->type == TGUI_9400CXI) { @@ -364,7 +364,7 @@ tgui_out(uint16_t addr, uint8_t val, void *p) return; } break; - + case 0x3C7: case 0x3C8: case 0x3C9: if (tgui->type == TGUI_9400CXI) { @@ -397,7 +397,7 @@ tgui_out(uint16_t addr, uint8_t val, void *p) tgui_recalcmapping(tgui); } return; - + case 0x0e: svga->gdcreg[0xe] = val ^ 2; if ((svga->gdcreg[0xf] & 1) == 1) @@ -412,13 +412,13 @@ tgui_out(uint16_t addr, uint8_t val, void *p) else svga->read_bank = (svga->seqregs[0xe]) * 65536; } - + if (tgui->oldmode) svga->write_bank = (tgui->oldctrl1) * 65536; else svga->write_bank = (svga->seqregs[0xe]) * 65536; break; - + case 0x5a: case 0x5b: case 0x5c: @@ -439,7 +439,7 @@ tgui_out(uint16_t addr, uint8_t val, void *p) val = (svga->crtc[7] & ~0x10) | (val & 0x10); old = svga->crtc[svga->crtcreg]; svga->crtc[svga->crtcreg] = val; - + if (old != val) { if (svga->crtcreg < 0xe || svga->crtcreg > 0x10) @@ -508,7 +508,7 @@ tgui_out(uint16_t addr, uint8_t val, void *p) break; } return; - + case 0x3D8: tgui->tgui_3d8 = val; if (svga->gdcreg[0xf] & 4) { @@ -544,7 +544,7 @@ tgui_in(uint16_t addr, void *p) uint8_t temp; if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout & 1)) addr ^= 0x60; - + switch (addr) { case 0x3C5: @@ -634,8 +634,8 @@ void tgui_recalctimings(svga_t *svga) { tgui_t *tgui = (tgui_t *)svga->p; - if (!svga->rowoffset) - svga->rowoffset = 0x100; + if (!svga->rowoffset) + svga->rowoffset = 0x100; if (svga->crtc[0x29] & 0x10) svga->rowoffset |= 0x100; @@ -647,9 +647,9 @@ void tgui_recalctimings(svga_t *svga) svga->rowoffset <<= 1; } - - if ((svga->crtc[0x1e] & 0xA0) == 0xA0) + + if ((svga->crtc[0x1e] & 0xA0) == 0xA0) svga->ma_latch |= 0x10000; if ((svga->crtc[0x27] & 0x01) == 0x01) svga->ma_latch |= 0x20000; @@ -657,13 +657,13 @@ void tgui_recalctimings(svga_t *svga) svga->ma_latch |= 0x40000; if ((svga->crtc[0x27] & 0x04) == 0x04) svga->ma_latch |= 0x80000; - + if (svga->crtc[0x27] & 0x08) svga->split |= 0x400; if (svga->crtc[0x27] & 0x10) svga->dispend |= 0x400; if (svga->crtc[0x27] & 0x20) - svga->vsyncstart |= 0x400; + svga->vsyncstart |= 0x400; if (svga->crtc[0x27] & 0x40) svga->vblankstart |= 0x400; if (svga->crtc[0x27] & 0x80) @@ -672,22 +672,22 @@ void tgui_recalctimings(svga_t *svga) if (tgui->oldctrl2 & 0x10) { svga->rowoffset <<= 1; svga->lowres = 0; - } - + } + if ((tgui->oldctrl2 & 0x10) || (svga->crtc[0x2a] & 0x40)) svga->ma_latch <<= 1; - svga->lowres = !(svga->crtc[0x2a] & 0x40); + svga->lowres = !(svga->crtc[0x2a] & 0x40); svga->interlace = !!(svga->crtc[0x1e] & 4); if (svga->interlace && tgui->type < TGUI_9440) svga->rowoffset >>= 1; - + if (tgui->type >= TGUI_9440) { if (svga->miscout & 8) svga->clock = (cpuclock * (double)(1ull << 32)) / (((tgui->clock_n + 8) * 14318180.0) / ((tgui->clock_m + 2) * (1 << tgui->clock_k))); - + if (svga->gdcreg[0xf] & 0x08) svga->clock *= 2; else if (svga->gdcreg[0xf] & 0x40) @@ -719,7 +719,7 @@ void tgui_recalctimings(svga_t *svga) svga->hdisp_time <<= 1; } } - + if ((tgui->oldctrl2 & 0x10) || (svga->crtc[0x2a] & 0x40)) { switch (svga->bpp) @@ -733,17 +733,17 @@ void tgui_recalctimings(svga_t *svga) svga->hdisp = 1600; } break; - case 15: + case 15: svga->render = svga_render_15bpp_highres; if (tgui->type < TGUI_9440) svga->hdisp >>= 1; break; - case 16: - svga->render = svga_render_16bpp_highres; + case 16: + svga->render = svga_render_16bpp_highres; if (tgui->type < TGUI_9440) svga->hdisp >>= 1; break; - case 24: + case 24: svga->render = svga_render_24bpp_highres; if (tgui->type < TGUI_9440) svga->hdisp = (svga->hdisp << 1) / 3; @@ -872,7 +872,7 @@ tgui_recalcmapping(tgui_t *tgui) break; } } - + if (tgui->type >= TGUI_9440) { if ((tgui->mmio_base != 0x00000000) && (svga->crtc[0x39] & 1)) mem_mapping_set_addr(&tgui->mmio_mapping, tgui->mmio_base, 0x10000); @@ -909,13 +909,13 @@ tgui_hwcursor_draw(svga_t *svga, int displine) else if (dat[1] & 0x80000000) ((uint32_t *)buffer32->line[displine])[svga->x_add + offset] ^= 0xffffff; } - } + } offset++; dat[0] <<= 1; dat[1] <<= 1; } svga->hwcursor_latch.addr += pitch; - + if (svga->interlace && !svga->hwcursor_oddeven) svga->hwcursor_latch.addr += pitch; } @@ -928,29 +928,29 @@ uint8_t tgui_pci_read(int func, int addr, void *p) { case 0x00: return 0x23; /*Trident*/ case 0x01: return 0x10; - + case 0x02: return (tgui->type == TGUI_9440) ? 0x40 : 0x60; /*TGUI9440AGi or TGUI9660XGi*/ case 0x03: return (tgui->type == TGUI_9440) ? 0x94 : 0x96; - + case PCI_REG_COMMAND: return tgui->pci_regs[PCI_REG_COMMAND]; /*Respond to IO and memory accesses*/ case 0x07: return 1 << 1; /*Medium DEVSEL timing*/ - + case 0x08: return 0; /*Revision ID*/ case 0x09: return 0; /*Programming interface*/ - + case 0x0a: return 0x01; /*Supports VGA interface, XGA compatible*/ case 0x0b: return 0x03; - + case 0x10: return 0x00; /*Linear frame buffer address*/ case 0x11: return 0x00; case 0x12: return tgui->linear_base >> 16; case 0x13: return tgui->linear_base >> 24; - + case 0x14: return 0x00; /*MMIO address*/ case 0x15: return 0x00; case 0x16: return tgui->mmio_base >> 16; - case 0x17: return tgui->mmio_base >> 24; + case 0x17: return tgui->mmio_base >> 24; case 0x30: return tgui->has_bios ? (tgui->pci_regs[0x30] & 0x01) : 0x00; /*BIOS ROM address*/ case 0x31: return 0x00; @@ -978,7 +978,7 @@ void tgui_pci_write(int func, int addr, uint8_t val, void *p) tgui_remove_io(tgui); tgui_recalcmapping(tgui); break; - + case 0x12: if (tgui->type >= TGUI_9660) tgui->linear_base = (tgui->linear_base & 0xff000000) | ((val & 0xc0) << 16); @@ -1011,7 +1011,7 @@ void tgui_pci_write(int func, int addr, uint8_t val, void *p) else tgui->mmio_base = (tgui->mmio_base & 0x00e00000) | (val << 24); tgui_recalcmapping(tgui); - break; + break; case 0x30: case 0x32: case 0x33: if (tgui->has_bios) { @@ -1045,7 +1045,7 @@ static uint8_t tgui_ext_linear_read(uint32_t addr, void *p) addr &= svga->decode_mask; if (addr >= svga->vram_max) return 0xff; - + addr &= ~0xf; addr = dword_remap(svga, addr); @@ -1053,16 +1053,16 @@ static uint8_t tgui_ext_linear_read(uint32_t addr, void *p) tgui->copy_latch[c] = svga->vram[addr+c]; addr += ((c & 3) == 3) ? 13 : 1; } - - return svga->vram[addr & svga->vram_mask]; + + return svga->vram[addr & svga->vram_mask]; } static uint8_t tgui_ext_read(uint32_t addr, void *p) { svga_t *svga = (svga_t *)p; - + addr = (addr & svga->banked_mask) + svga->read_bank; - + return tgui_ext_linear_read(addr, svga); } @@ -1085,7 +1085,7 @@ static void tgui_ext_linear_write(uint32_t addr, uint8_t val, void *p) addr = dword_remap(svga, addr); svga->changedvram[addr >> 12] = changeframecount; - + switch (tgui->ext_gdc_regs[0] & 0xf) { /*8-bit mono->colour expansion, unmasked*/ @@ -1117,7 +1117,7 @@ static void tgui_ext_linear_write(uint32_t addr, uint8_t val, void *p) addr += (c == 4) ? 13 : 1; } break; - + /*16-bit mono->colour expansion, masked*/ case 7: for (c = 7; c >= 0; c--) @@ -1146,7 +1146,7 @@ static void tgui_ext_linear_writew(uint32_t addr, uint16_t val, void *p) uint8_t fg[2] = {tgui->ext_gdc_regs[4], tgui->ext_gdc_regs[5]}; uint8_t bg[2] = {tgui->ext_gdc_regs[1], tgui->ext_gdc_regs[2]}; uint16_t mask = (tgui->ext_gdc_regs[7] << 8) | tgui->ext_gdc_regs[8]; - + cycles -= video_timing_write_w; addr &= svga->decode_mask; @@ -1154,10 +1154,10 @@ static void tgui_ext_linear_writew(uint32_t addr, uint16_t val, void *p) return; addr &= svga->vram_mask; addr &= ~0xf; - + addr = dword_remap(svga, addr); svga->changedvram[addr >> 12] = changeframecount; - + val = (val >> 8) | (val << 8); switch (tgui->ext_gdc_regs[0] & 0xf) @@ -1201,7 +1201,7 @@ static void tgui_ext_linear_writew(uint32_t addr, uint16_t val, void *p) addr += (c & 3) ? 1 : 13; } break; - + case 0x8: case 0x9: case 0xa: case 0xb: case 0xc: case 0xd: case 0xe: case 0xf: for (c = 0; c < 16; c++) { @@ -1221,7 +1221,7 @@ static void tgui_ext_linear_writel(uint32_t addr, uint32_t val, void *p) static void tgui_ext_write(uint32_t addr, uint8_t val, void *p) { svga_t *svga = (svga_t *)p; - + addr = (addr & svga->banked_mask) + svga->read_bank; tgui_ext_linear_write(addr, val, svga); @@ -1229,7 +1229,7 @@ static void tgui_ext_write(uint32_t addr, uint8_t val, void *p) static void tgui_ext_writew(uint32_t addr, uint16_t val, void *p) { svga_t *svga = (svga_t *)p; - + addr = (addr & svga->banked_mask) + svga->read_bank; tgui_ext_linear_writew(addr, val, svga); @@ -1237,7 +1237,7 @@ static void tgui_ext_writew(uint32_t addr, uint16_t val, void *p) static void tgui_ext_writel(uint32_t addr, uint32_t val, void *p) { svga_t *svga = (svga_t *)p; - + addr = (addr & svga->banked_mask) + svga->read_bank; tgui_ext_linear_writel(addr, val, svga); @@ -1269,7 +1269,7 @@ enum #define READ(addr, dat) if (tgui->accel.bpp == 0) dat = svga->vram[(addr) & tgui->vram_mask]; \ else if (tgui->accel.bpp == 1) dat = vram_w[(addr) & (tgui->vram_mask >> 1)]; \ else dat = vram_l[(addr) & (tgui->vram_mask >> 2)]; \ - + #define MIX() do \ { \ out = 0; \ @@ -1297,7 +1297,7 @@ enum vram_l[(addr) & (tgui->vram_mask >> 2)] = dat; \ svga->changedvram[((addr) & (tgui->vram_mask >> 2)) >> 10] = changeframecount; \ } - + static void tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) { @@ -1324,10 +1324,10 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) count -= (tgui->accel.flags >> 24) & 7; cpu_dat <<= (tgui->accel.flags >> 24) & 7; } - + if (count == -1) tgui->accel.x = tgui->accel.y = 0; - + if (tgui->accel.flags & TGUI_SOLIDFILL) { for (y = 0; y < 8; y++) { @@ -1336,7 +1336,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.fill_pattern[(y*8) + (7 - x)] = tgui->accel.fg_col; } } - pattern_data = tgui->accel.fill_pattern; + pattern_data = tgui->accel.fill_pattern; } else if (tgui->accel.flags & TGUI_PATMONO) { for (y = 0; y < 8; y++) { @@ -1386,8 +1386,8 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.pitch = 640; break; } - break; - + break; + case 4: switch (tgui->accel.ger22 >> 8) { case 0: @@ -1458,21 +1458,21 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) if (count == -1) { tgui->accel.src_old = tgui->accel.src_x + (tgui->accel.src_y * tgui->accel.pitch); tgui->accel.src = tgui->accel.src_old; - + tgui->accel.dst_old = tgui->accel.dst_x + (tgui->accel.dst_y * tgui->accel.pitch); tgui->accel.dst = tgui->accel.dst_old; - + tgui->accel.pat_x = tgui->accel.dst_x; tgui->accel.pat_y = tgui->accel.dst_y; - + tgui->accel.dx = tgui->accel.dst_x & 0xfff; tgui->accel.dy = tgui->accel.dst_y & 0xfff; - + tgui->accel.left = tgui->accel.src_x_clip & 0xfff; tgui->accel.right = tgui->accel.dst_x_clip & 0xfff; tgui->accel.top = tgui->accel.src_y_clip & 0xfff; tgui->accel.bottom = tgui->accel.dst_y_clip & 0xfff; - + if (tgui->accel.bpp == 1) { tgui->accel.left >>= 1; tgui->accel.right >>= 1; @@ -1481,7 +1481,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.right >>= 2; } } - + switch (tgui->accel.flags & (TGUI_SRCMONO|TGUI_SRCDISP)) { case TGUI_SRCCPU: @@ -1508,17 +1508,17 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) cpu_dat <<= 16; count -= 3; } - + READ(tgui->accel.dst, dst_dat); pat_dat = pattern_data[((tgui->accel.pat_y & 7)*8) + (tgui->accel.pat_x & 7)]; - + if (tgui->accel.bpp == 0) pat_dat &= 0xff; else if (tgui->accel.bpp == 1) pat_dat &= 0xffff; - - if ((((tgui->accel.flags & (TGUI_PATMONO|TGUI_TRANSENA)) == (TGUI_TRANSENA|TGUI_PATMONO)) && (pat_dat != trans_col)) || !(tgui->accel.flags & TGUI_PATMONO) || + + if ((((tgui->accel.flags & (TGUI_PATMONO|TGUI_TRANSENA)) == (TGUI_TRANSENA|TGUI_PATMONO)) && (pat_dat != trans_col)) || !(tgui->accel.flags & TGUI_PATMONO) || ((tgui->accel.flags & (TGUI_PATMONO|TGUI_TRANSENA)) == TGUI_PATMONO) || (tgui->accel.ger22 & 0x200)) { MIX(); @@ -1531,14 +1531,14 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.pat_x += xdir; if (tgui->type >= TGUI_9660) tgui->accel.dx += xdir; - + tgui->accel.x++; if (tgui->accel.x > tgui->accel.size_x) { tgui->accel.x = 0; - + tgui->accel.pat_x = tgui->accel.dst_x; tgui->accel.pat_y += ydir; - + if (tgui->type >= TGUI_9660) { tgui->accel.dx = tgui->accel.dst_x & 0xfff; tgui->accel.dy += ydir; @@ -1546,12 +1546,12 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.src_old += (ydir * tgui->accel.pitch); tgui->accel.dst_old += (ydir * tgui->accel.pitch); - + tgui->accel.src = tgui->accel.src_old; tgui->accel.dst = tgui->accel.dst_old; - + tgui->accel.y++; - + if (tgui->accel.y > tgui->accel.size_y) { if (svga->crtc[0x21] & 0x20) tgui->write_blitter = 0; @@ -1563,7 +1563,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) count--; } break; - + case TGUI_SRCMONO | TGUI_SRCCPU: if (count == -1) { if (svga->crtc[0x21] & 0x20) @@ -1603,7 +1603,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.pat_x += xdir; if (tgui->type >= TGUI_9660) tgui->accel.dx += xdir; - + tgui->accel.x++; if (tgui->accel.x > tgui->accel.size_x) { tgui->accel.x = 0; @@ -1618,9 +1618,9 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.src = tgui->accel.src_old = tgui->accel.src_old + (ydir * tgui->accel.pitch); tgui->accel.dst = tgui->accel.dst_old = tgui->accel.dst_old + (ydir * tgui->accel.pitch); - + tgui->accel.y++; - + if (tgui->accel.y > tgui->accel.size_y) { if (svga->crtc[0x21] & 0x20) tgui->write_blitter = 0; @@ -1631,7 +1631,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) } } break; - + default: while (count--) { READ(tgui->accel.src, src_dat); @@ -1653,19 +1653,19 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.src += xdir; tgui->accel.dst += xdir; tgui->accel.pat_x += xdir; - + tgui->accel.x++; if (tgui->accel.x > tgui->accel.size_x) { tgui->accel.x = 0; tgui->accel.y++; - + tgui->accel.pat_x = tgui->accel.dst_x; tgui->accel.pat_y += ydir; tgui->accel.src = tgui->accel.src_old = tgui->accel.src_old + (ydir * tgui->accel.pitch); tgui->accel.dst = tgui->accel.dst_old = tgui->accel.dst_old + (ydir * tgui->accel.pitch); - + if (tgui->accel.y > tgui->accel.size_y) return; } @@ -1673,16 +1673,16 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) break; } break; - + case TGUI_SCANLINE: { if (count == -1) { tgui->accel.src_old = tgui->accel.src_x + (tgui->accel.src_y * tgui->accel.pitch); - tgui->accel.src = tgui->accel.src_old; - + tgui->accel.src = tgui->accel.src_old; + tgui->accel.dst_old = tgui->accel.dst_x + (tgui->accel.dst_y * tgui->accel.pitch); tgui->accel.dst = tgui->accel.dst_old; - + tgui->accel.pat_x = tgui->accel.dst_x; tgui->accel.pat_y = tgui->accel.dst_y; } @@ -1707,12 +1707,12 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.src += xdir; tgui->accel.dst += xdir; tgui->accel.pat_x += xdir; - + tgui->accel.x++; if (tgui->accel.x > tgui->accel.size_x) { tgui->accel.x = 0; - + tgui->accel.pat_x = tgui->accel.dst_x; tgui->accel.src = tgui->accel.src_old = tgui->accel.src_old + (ydir * tgui->accel.pitch); tgui->accel.dst = tgui->accel.dst_old = tgui->accel.dst_old + (ydir * tgui->accel.pitch); @@ -1734,25 +1734,25 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) dminor = tgui->accel.src_y; if (tgui->accel.src_y & 0x1000) dminor |= ~0xfff; - dminor >>= 1; - + dminor >>= 1; + destxtmp = tgui->accel.src_x; if (tgui->accel.src_x & 0x1000) destxtmp |= ~0xfff; - + dmajor = -(destxtmp - (dminor << 1)) >> 1; cx = dmajor; cy = dminor; - + dx = tgui->accel.dst_x & 0xfff; dy = tgui->accel.dst_y & 0xfff; - + tgui->accel.left = tgui->accel.src_x_clip & 0xfff; tgui->accel.right = tgui->accel.dst_x_clip & 0xfff; tgui->accel.top = tgui->accel.src_y_clip & 0xfff; tgui->accel.bottom = tgui->accel.dst_y_clip & 0xfff; - + if (tgui->accel.bpp == 1) { tgui->accel.left >>= 1; tgui->accel.right >>= 1; @@ -1760,11 +1760,11 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) tgui->accel.left >>= 2; tgui->accel.right >>= 2; } - + err = tgui->accel.size_x + tgui->accel.src_y; if ((tgui->accel.size_x + tgui->accel.src_y) & 0x1000) err |= ~0xfff; - + if (tgui->accel.flags & 0x400) { steep = 0; SWAP(dx, dy); @@ -1773,7 +1773,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) while (count--) { READ(tgui->accel.src_x + (tgui->accel.src_y * tgui->accel.pitch), src_dat); - + /*Note by TC1995: I suppose the x/y clipping max is always more than 0 in the TGUI 96xx, but the TGUI 9440 lacks clipping*/ if (steep) { if ((tgui->type == TGUI_9440) || ((tgui->type >= TGUI_9660) && dx >= tgui->accel.left && dx <= tgui->accel.right && @@ -1781,14 +1781,14 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) READ(dx + (dy * tgui->accel.pitch), dst_dat); pat_dat = tgui->accel.fg_col; - + if (tgui->accel.bpp == 0) pat_dat &= 0xff; else if (tgui->accel.bpp == 1) pat_dat &= 0xffff; - + MIX(); - + WRITE(dx + (dy * tgui->accel.pitch), out); } } else { @@ -1797,14 +1797,14 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) READ(dy + (dx * tgui->accel.pitch), dst_dat); pat_dat = tgui->accel.fg_col; - + if (tgui->accel.bpp == 0) pat_dat &= 0xff; else if (tgui->accel.bpp == 1) pat_dat &= 0xffff; - + MIX(); - + WRITE(dy + (dx * tgui->accel.pitch), out); } } @@ -1823,19 +1823,19 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) } } break; - + case TGUI_SHORTVECTOR: { int16_t dx, dy; - + dx = tgui->accel.dst_x & 0xfff; dy = tgui->accel.dst_y & 0xfff; - + tgui->accel.left = tgui->accel.src_x_clip & 0xfff; tgui->accel.right = tgui->accel.dst_x_clip & 0xfff; tgui->accel.top = tgui->accel.src_y_clip & 0xfff; tgui->accel.bottom = tgui->accel.dst_y_clip & 0xfff; - + if (tgui->accel.bpp == 1) { tgui->accel.left >>= 1; tgui->accel.right >>= 1; @@ -1846,21 +1846,21 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) while (count--) { READ(tgui->accel.src_x + (tgui->accel.src_y * tgui->accel.pitch), src_dat); - + /*Note by TC1995: I suppose the x/y clipping max is always more than 0 in the TGUI 96xx, but the TGUI 9440 lacks clipping*/ if ((tgui->type == TGUI_9440) || ((tgui->type >= TGUI_9660) && dx >= tgui->accel.left && dx <= tgui->accel.right && dy >= tgui->accel.top && dy <= tgui->accel.bottom)) { READ(dx + (dy * tgui->accel.pitch), dst_dat); pat_dat = tgui->accel.fg_col; - + if (tgui->accel.bpp == 0) pat_dat &= 0xff; else if (tgui->accel.bpp == 1) pat_dat &= 0xffff; - + MIX(); - + WRITE(dx + (dy * tgui->accel.pitch), out); } @@ -1897,27 +1897,27 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) dy++; break; } - + tgui->accel.y++; } } break; - + case TGUI_FASTLINE: { if (tgui->type < TGUI_9660) break; - + int16_t dx, dy; - + dx = tgui->accel.dst_x & 0xfff; dy = tgui->accel.dst_y & 0xfff; - + tgui->accel.left = tgui->accel.src_x_clip & 0xfff; tgui->accel.right = tgui->accel.dst_x_clip & 0xfff; tgui->accel.top = tgui->accel.src_y_clip & 0xfff; tgui->accel.bottom = tgui->accel.dst_y_clip & 0xfff; - + if (tgui->accel.bpp == 1) { tgui->accel.left >>= 1; tgui->accel.right >>= 1; @@ -1928,21 +1928,21 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) while (count--) { READ(tgui->accel.src_x + (tgui->accel.src_y * tgui->accel.pitch), src_dat); - + /*Note by TC1995: I suppose the x/y clipping max is always more than 0 in the TGUI 96xx, but the TGUI 9440 lacks clipping*/ if ((tgui->type == TGUI_9440) || ((tgui->type >= TGUI_9660) && dx >= tgui->accel.left && dx <= tgui->accel.right && dy >= tgui->accel.top && dy <= tgui->accel.bottom)) { READ(dx + (dy * tgui->accel.pitch), dst_dat); pat_dat = tgui->accel.fg_col; - + if (tgui->accel.bpp == 0) pat_dat &= 0xff; else if (tgui->accel.bpp == 1) pat_dat &= 0xffff; - + MIX(); - + WRITE(dx + (dy * tgui->accel.pitch), out); } @@ -1979,7 +1979,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) dy++; break; } - + tgui->accel.y++; } } @@ -2001,11 +2001,11 @@ tgui_accel_out(uint16_t addr, uint8_t val, void *p) case 8: tgui->accel.bpp = 0; break; - + case 9: tgui->accel.bpp = 1; break; - + case 13: case 14: switch (tgui->svga.bpp) { @@ -2013,11 +2013,11 @@ tgui_accel_out(uint16_t addr, uint8_t val, void *p) case 16: tgui->accel.bpp = 1; break; - + case 24: tgui->accel.bpp = 0; break; - + case 32: tgui->accel.bpp = 3; break; @@ -2034,12 +2034,12 @@ tgui_accel_out(uint16_t addr, uint8_t val, void *p) tgui->accel.command = val; tgui_accel_command(-1, 0, tgui); break; - + case 0x2127: /*ROP*/ tgui->accel.rop = val; tgui->accel.use_src = (val & 0x33) ^ ((val >> 2) & 0x33); break; - + case 0x2128: /*Flags*/ tgui->accel.flags = (tgui->accel.flags & 0xffffff00) | val; break; @@ -2048,11 +2048,11 @@ tgui_accel_out(uint16_t addr, uint8_t val, void *p) break; case 0x212a: /*Flags*/ tgui->accel.flags = (tgui->accel.flags & 0xff00ffff) | (val << 16); - break; + break; case 0x212b: /*Flags*/ tgui->accel.flags = (tgui->accel.flags & 0x0000ffff) | (val << 24); break; - + case 0x212c: /*Foreground colour*/ case 0x2178: tgui->accel.fg_col = (tgui->accel.fg_col & 0xffffff00) | val; @@ -2083,7 +2083,7 @@ tgui_accel_out(uint16_t addr, uint8_t val, void *p) tgui->accel.bg_col = (tgui->accel.bg_col & 0xff00ffff) | (val << 16); break; case 0x2133: /*Background colour*/ - case 0x217f: + case 0x217f: tgui->accel.bg_col = (tgui->accel.bg_col & 0x00ffffff) | (val << 24); break; @@ -2232,11 +2232,11 @@ tgui_accel_out_w(uint16_t addr, uint16_t val, void *p) tgui_accel_out(addr + 1, val >> 8, tgui); } -static void +static void tgui_accel_out_l(uint16_t addr, uint32_t val, void *p) { tgui_t *tgui = (tgui_t *)p; - + switch (addr) { case 0x2124: /*Long version of Command and ROP together*/ tgui->accel.command = val & 0xff; @@ -2244,7 +2244,7 @@ tgui_accel_out_l(uint16_t addr, uint32_t val, void *p) tgui->accel.use_src = (tgui->accel.rop & 0x33) ^ ((tgui->accel.rop >> 2) & 0x33); tgui_accel_command(-1, 0, tgui); break; - + default: tgui_accel_out(addr, val, tgui); tgui_accel_out(addr + 1, val >> 8, tgui); @@ -2263,16 +2263,16 @@ tgui_accel_in(uint16_t addr, void *p) { case 0x2120: /*Status*/ return 0; - + case 0x2122: return tgui->accel.ger22 & 0xff; - + case 0x2123: return tgui->accel.ger22 >> 8; - + case 0x2127: /*ROP*/ return tgui->accel.rop; - + case 0x2128: /*Flags*/ return tgui->accel.flags & 0xff; case 0x2129: /*Flags*/ @@ -2281,7 +2281,7 @@ tgui_accel_in(uint16_t addr, void *p) return tgui->accel.flags >> 16; case 0x212b: return tgui->accel.flags >> 24; - + case 0x212c: /*Foreground colour*/ case 0x2178: return tgui->accel.fg_col & 0xff; @@ -2451,11 +2451,11 @@ tgui_accel_write(uint32_t addr, uint8_t val, void *p) case 8: tgui->accel.bpp = 0; break; - + case 9: tgui->accel.bpp = 1; break; - + case 13: case 14: switch (tgui->svga.bpp) { @@ -2463,11 +2463,11 @@ tgui_accel_write(uint32_t addr, uint8_t val, void *p) case 16: tgui->accel.bpp = 1; break; - + case 24: tgui->accel.bpp = 0; break; - + case 32: tgui->accel.bpp = 3; break; @@ -2484,12 +2484,12 @@ tgui_accel_write(uint32_t addr, uint8_t val, void *p) tgui->accel.command = val; tgui_accel_command(-1, 0, tgui); break; - + case 0x27: /*ROP*/ tgui->accel.rop = val; tgui->accel.use_src = (val & 0x33) ^ ((val >> 2) & 0x33); break; - + case 0x28: /*Flags*/ tgui->accel.flags = (tgui->accel.flags & 0xffffff00) | val; break; @@ -2498,11 +2498,11 @@ tgui_accel_write(uint32_t addr, uint8_t val, void *p) break; case 0x2a: /*Flags*/ tgui->accel.flags = (tgui->accel.flags & 0xff00ffff) | (val << 16); - break; + break; case 0x2b: /*Flags*/ tgui->accel.flags = (tgui->accel.flags & 0x0000ffff) | (val << 24); break; - + case 0x2c: /*Foreground colour*/ case 0x78: tgui->accel.fg_col = (tgui->accel.fg_col & 0xffffff00) | val; @@ -2533,7 +2533,7 @@ tgui_accel_write(uint32_t addr, uint8_t val, void *p) tgui->accel.bg_col = (tgui->accel.bg_col & 0xff00ffff) | (val << 16); break; case 0x33: /*Background colour*/ - case 0x7f: + case 0x7f: tgui->accel.bg_col = (tgui->accel.bg_col & 0x00ffffff) | (val << 24); break; @@ -2694,7 +2694,7 @@ tgui_accel_write_l(uint32_t addr, uint32_t val, void *p) if ((svga->crtc[0x36] & 0x03) == 0x02) { if ((addr & ~0xff) != 0xbff00) return; - } else if ((svga->crtc[0x36] & 0x03) == 0x01) { + } else if ((svga->crtc[0x36] & 0x03) == 0x01) { if ((addr & ~0xff) != 0xb7f00) return; } @@ -2703,7 +2703,7 @@ tgui_accel_write_l(uint32_t addr, uint32_t val, void *p) tgui->accel.use_src = ((val >> 24) & 0x33) ^ (((val >> 24) >> 2) & 0x33); tgui_accel_command(-1, 0, tgui); break; - + default: tgui_accel_write_w(addr, val, tgui); tgui_accel_write_w(addr + 2, val >> 16, tgui); @@ -2715,7 +2715,7 @@ static uint8_t tgui_accel_read(uint32_t addr, void *p) { tgui_t *tgui = (tgui_t *)p; - svga_t *svga = &tgui->svga; + svga_t *svga = &tgui->svga; if ((svga->crtc[0x36] & 0x03) == 0x02) { if ((addr & ~0xff) != 0xbff00) @@ -2724,21 +2724,21 @@ tgui_accel_read(uint32_t addr, void *p) if ((addr & ~0xff) != 0xb7f00) return 0xff; } - + switch (addr & 0xff) { case 0x20: /*Status*/ return 0; - + case 0x22: return tgui->accel.ger22 & 0xff; - + case 0x23: - return tgui->accel.ger22 >> 8; - + return tgui->accel.ger22 >> 8; + case 0x27: /*ROP*/ return tgui->accel.rop; - + case 0x28: /*Flags*/ return tgui->accel.flags & 0xff; case 0x29: /*Flags*/ @@ -2747,7 +2747,7 @@ tgui_accel_read(uint32_t addr, void *p) return tgui->accel.flags >> 16; case 0x2b: return tgui->accel.flags >> 24; - + case 0x2c: /*Foreground colour*/ case 0x78: return tgui->accel.fg_col & 0xff; @@ -2893,7 +2893,7 @@ tgui_accel_read_l(uint32_t addr, void *p) return tgui_accel_read_w(addr, tgui) | (tgui_accel_read_w(addr + 2, tgui) << 16); } -static void +static void tgui_accel_write_fb_b(uint32_t addr, uint8_t val, void *p) { svga_t *svga = (svga_t *)p; @@ -2934,12 +2934,12 @@ tgui_mmio_write(uint32_t addr, uint8_t val, void *p) { tgui_t *tgui = (tgui_t *)p; svga_t *svga = &tgui->svga; - + addr &= 0x0000ffff; if (((svga->crtc[0x36] & 0x03) == 0x00) && (addr >= 0x2100 && addr <= 0x21ff)) tgui_accel_out(addr, val, p); - else if (((svga->crtc[0x36] & 0x03) > 0x00) && (addr <= 0xff)) + else if (((svga->crtc[0x36] & 0x03) > 0x00) && (addr <= 0xff)) tgui_accel_write(addr, val, p); else tgui_out(addr, val, p); @@ -2950,13 +2950,13 @@ static void tgui_mmio_write_w(uint32_t addr, uint16_t val, void *p) { tgui_t *tgui = (tgui_t *)p; - svga_t *svga = &tgui->svga; - + svga_t *svga = &tgui->svga; + addr &= 0x0000ffff; - + if (((svga->crtc[0x36] & 0x03) == 0x00) && (addr >= 0x2100 && addr <= 0x21ff)) tgui_accel_out_w(addr, val, p); - else if (((svga->crtc[0x36] & 0x03) > 0x00) && (addr <= 0xff)) + else if (((svga->crtc[0x36] & 0x03) > 0x00) && (addr <= 0xff)) tgui_accel_write_w(addr, val, p); else { tgui_out(addr, val & 0xff, p); @@ -2969,13 +2969,13 @@ static void tgui_mmio_write_l(uint32_t addr, uint32_t val, void *p) { tgui_t *tgui = (tgui_t *)p; - svga_t *svga = &tgui->svga; - + svga_t *svga = &tgui->svga; + addr &= 0x0000ffff; if (((svga->crtc[0x36] & 0x03) == 0x00) && (addr >= 0x2100 && addr <= 0x21ff)) tgui_accel_out_l(addr, val, p); - else if (((svga->crtc[0x36] & 0x03) > 0x00) && (addr <= 0xff)) + else if (((svga->crtc[0x36] & 0x03) > 0x00) && (addr <= 0xff)) tgui_accel_write_l(addr, val, p); else { tgui_out(addr, val & 0xff, p); @@ -2991,7 +2991,7 @@ tgui_mmio_read(uint32_t addr, void *p) { tgui_t *tgui = (tgui_t *)p; svga_t *svga = &tgui->svga; - + uint8_t ret = 0xff; addr &= 0x0000ffff; @@ -3031,7 +3031,7 @@ static uint32_t tgui_mmio_read_l(uint32_t addr, void *p) { tgui_t *tgui = (tgui_t *)p; - svga_t *svga = &tgui->svga; + svga_t *svga = &tgui->svga; uint32_t ret = 0xffffffff; addr &= 0x0000ffff; @@ -3053,10 +3053,10 @@ static void *tgui_init(const device_t *info) tgui_t *tgui = malloc(sizeof(tgui_t)); svga_t *svga = &tgui->svga; memset(tgui, 0, sizeof(tgui_t)); - + tgui->vram_size = device_get_config_int("memory") << 20; tgui->vram_mask = tgui->vram_size - 1; - + tgui->type = info->local & 0xff; tgui->pci = !!(info->flags & DEVICE_PCI); @@ -3124,7 +3124,7 @@ static void *tgui_init(const device_t *info) svga->packed_chain4 = 1; tgui->i2c = i2c_gpio_init("ddc_tgui"); - tgui->ddc = ddc_init(i2c_gpio_get_bus(tgui->i2c)); + tgui->ddc = ddc_init(i2c_gpio_get_bus(tgui->i2c)); } return tgui; @@ -3148,7 +3148,7 @@ static int tgui96xx_available(void) void tgui_close(void *p) { tgui_t *tgui = (tgui_t *)p; - + svga_close(&tgui->svga); ddc_close(tgui->ddc); @@ -3160,7 +3160,7 @@ void tgui_close(void *p) void tgui_speed_changed(void *p) { tgui_t *tgui = (tgui_t *)p; - + svga_recalctimings(&tgui->svga); } diff --git a/src/video/vid_ti_cf62011.c b/src/video/vid_ti_cf62011.c index f9f499ce1..ac43a5a24 100644 --- a/src/video/vid_ti_cf62011.c +++ b/src/video/vid_ti_cf62011.c @@ -1,4 +1,4 @@ -/* +/* * 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 diff --git a/src/video/vid_tvga.c b/src/video/vid_tvga.c index 55dccf9c6..9f4cae6f4 100644 --- a/src/video/vid_tvga.c +++ b/src/video/vid_tvga.c @@ -53,7 +53,7 @@ typedef struct tvga_t int oldmode; uint8_t oldctrl1; uint8_t oldctrl2, newctrl2; - + int vram_size; uint32_t vram_mask; } tvga_t; @@ -88,16 +88,16 @@ void tvga_out(uint16_t addr, uint8_t val, void *p) case 0x3C5: switch (svga->seqaddr & 0xf) { - case 0xB: - tvga->oldmode=1; + case 0xB: + tvga->oldmode=1; break; - case 0xC: - if (svga->seqregs[0xe] & 0x80) - svga->seqregs[0xc] = val; + case 0xC: + if (svga->seqregs[0xe] & 0x80) + svga->seqregs[0xc] = val; break; - case 0xd: - if (tvga->oldmode) - tvga->oldctrl2 = val; + case 0xd: + if (tvga->oldmode) + tvga->oldctrl2 = val; else { tvga->newctrl2 = val; @@ -105,9 +105,9 @@ void tvga_out(uint16_t addr, uint8_t val, void *p) } break; case 0xE: - if (tvga->oldmode) - tvga->oldctrl1 = val; - else + if (tvga->oldmode) + tvga->oldctrl1 = val; + else { svga->seqregs[0xe] = val ^ 2; tvga->tvga_3d8 = svga->seqregs[0xe] & 0xf; @@ -118,7 +118,7 @@ void tvga_out(uint16_t addr, uint8_t val, void *p) break; case 0x3C6: case 0x3C7: case 0x3C8: case 0x3C9: - if (tvga->card_id != TVGA9000B_ID) { + if (tvga->card_id != TVGA9000B_ID) { tkd8001_ramdac_out(addr, val, svga->ramdac, svga); return; } @@ -135,7 +135,7 @@ void tvga_out(uint16_t addr, uint8_t val, void *p) /*override mask - TVGA supports linear 128k at A0000*/ svga->banked_mask = 0x1ffff; } - return; + return; case 0xE: svga->gdcreg[0xe] = val ^ 2; tvga->tvga_3d9 = svga->gdcreg[0xe] & 0xf; @@ -207,7 +207,7 @@ uint8_t tvga_in(uint16_t addr, void *p) svga_t *svga = &tvga->svga; if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout & 1)) addr ^= 0x60; - + switch (addr) { case 0x3C5: @@ -223,8 +223,8 @@ uint8_t tvga_in(uint16_t addr, void *p) } if ((svga->seqaddr & 0xf) == 0xe) { - if (tvga->oldmode) - return tvga->oldctrl1; + if (tvga->oldmode) + return tvga->oldctrl1; } break; case 0x3C6: case 0x3C7: case 0x3C8: case 0x3C9: @@ -249,7 +249,7 @@ uint8_t tvga_in(uint16_t addr, void *p) static void tvga_recalcbanking(tvga_t *tvga) { svga_t *svga = &tvga->svga; - + svga->write_bank = (tvga->tvga_3d8 & 0x1f) * 65536; if (svga->gdcreg[0xf] & 1) @@ -263,7 +263,7 @@ void tvga_recalctimings(svga_t *svga) tvga_t *tvga = (tvga_t *)svga->p; int clksel; int high_res_256 = 0; - + if (!svga->rowoffset) svga->rowoffset = 0x100; /*This is the only sensible way I can see this being handled, given that TVGA8900D has no overflow bits. Some sort of overflow is required for 320x200x24 and 1024x768x16*/ @@ -272,26 +272,26 @@ void tvga_recalctimings(svga_t *svga) if (svga->bpp == 24) svga->hdisp = (svga->crtc[1] + 1) * 8; - + if ((svga->crtc[0x1e] & 0xA0) == 0xA0) svga->ma_latch |= 0x10000; if ((svga->crtc[0x27] & 0x01) == 0x01) svga->ma_latch |= 0x20000; if ((svga->crtc[0x27] & 0x02) == 0x02) svga->ma_latch |= 0x40000; - + if (tvga->oldctrl2 & 0x10) { svga->rowoffset <<= 1; svga->ma_latch <<= 1; } - + if (svga->gdcreg[0xf] & 0x08) { svga->htotal *= 2; svga->hdisp *= 2; svga->hdisp_time *= 2; } - + svga->interlace = (svga->crtc[0x1e] & 4); - + if (svga->interlace) svga->rowoffset >>= 1; @@ -325,27 +325,27 @@ void tvga_recalctimings(svga_t *svga) if (svga->interlace) high_res_256 = (svga->htotal * 8) > (svga->vtotal * 4); else - high_res_256 = (svga->htotal * 8) > (svga->vtotal * 2); + high_res_256 = (svga->htotal * 8) > (svga->vtotal * 2); } if ((tvga->oldctrl2 & 0x10) || high_res_256) { if (high_res_256) - svga->hdisp /= 2; + svga->hdisp /= 2; switch (svga->bpp) { - case 8: + case 8: svga->render = svga_render_8bpp_highres; break; - case 15: - svga->render = svga_render_15bpp_highres; + case 15: + svga->render = svga_render_15bpp_highres; svga->hdisp /= 2; break; - case 16: - svga->render = svga_render_16bpp_highres; + case 16: + svga->render = svga_render_16bpp_highres; svga->hdisp /= 2; break; - case 24: + case 24: svga->render = svga_render_24bpp_highres; svga->hdisp /= 3; break; @@ -360,7 +360,7 @@ static void *tvga_init(const device_t *info) const char *bios_fn; tvga_t *tvga = malloc(sizeof(tvga_t)); memset(tvga, 0, sizeof(tvga_t)); - + if (info->local == TVGA9000B_ID) { video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_tvga9000); tvga->vram_size = 512 << 10; @@ -368,11 +368,11 @@ static void *tvga_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_tvga8900); tvga->vram_size = device_get_config_int("memory") << 10; } - + tvga->vram_mask = tvga->vram_size - 1; tvga->card_id = info->local; - + switch (info->local) { case TVGA8900B_ID: @@ -388,9 +388,9 @@ static void *tvga_init(const device_t *info) free(tvga); return NULL; } - + rom_init(&tvga->bios_rom, (char *) bios_fn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - + svga_init(info, &tvga->svga, tvga, tvga->vram_size, tvga_recalctimings, tvga_in, tvga_out, @@ -399,7 +399,7 @@ static void *tvga_init(const device_t *info) if (info->local != TVGA9000B_ID) tvga->svga.ramdac = device_add(&tkd8001_ramdac_device); - + io_sethandler(0x03c0, 0x0020, tvga_in, NULL, NULL, tvga_out, NULL, NULL, tvga); return tvga; @@ -423,16 +423,16 @@ static int tvga9000b_available(void) void tvga_close(void *p) { tvga_t *tvga = (tvga_t *)p; - + svga_close(&tvga->svga); - + free(tvga); } void tvga_speed_changed(void *p) { tvga_t *tvga = (tvga_t *)p; - + svga_recalctimings(&tvga->svga); } diff --git a/src/video/vid_tvp3026_ramdac.c b/src/video/vid_tvp3026_ramdac.c index ace0792e0..3858b9edf 100644 --- a/src/video/vid_tvp3026_ramdac.c +++ b/src/video/vid_tvp3026_ramdac.c @@ -243,7 +243,7 @@ tvp3026_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *p, svga_t case 0x39: /* MCLK/Loop Clock Control */ ramdac->mclk = val; break; - + } break; case 0x0b: /* Cursor RAM Data Register (RS value = 1011) */ @@ -474,7 +474,7 @@ tvp3026_hwcursor_draw(svga_t *svga, int displine) svga->dac_hwcursor_latch.addr += pitch; cd = (uint8_t *) ramdac->cursor64_data; - + for (x = 0; x < svga->dac_hwcursor_latch.xsize; x += 16) { dat[0] = (cd[svga->dac_hwcursor_latch.addr] << 8) | cd[svga->dac_hwcursor_latch.addr + 1]; @@ -540,18 +540,18 @@ tvp3026_hwcursor_draw(svga_t *svga, int displine) } -float +float tvp3026_getclock(int clock, void *p) { tvp3026_ramdac_t *ramdac = (tvp3026_ramdac_t *) p; int n, m, pl; float f_vco, f_pll; - + if (clock == 0) return 25175000.0; if (clock == 1) - return 28322000.0; - + return 28322000.0; + /*Fvco = 8 x Fref x (65 - M) / (65 - N)*/ /*Fpll = Fvco / 2^P*/ n = ramdac->pix.n & 0x3f; diff --git a/src/video/vid_vga.c b/src/video/vid_vga.c index c4cffef03..90aff23e2 100644 --- a/src/video/vid_vga.c +++ b/src/video/vid_vga.c @@ -41,7 +41,7 @@ void vga_out(uint16_t addr, uint8_t val, void *p) svga_t *svga = &vga->svga; uint8_t old; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) @@ -82,9 +82,9 @@ uint8_t vga_in(uint16_t addr, void *p) svga_t *svga = &vga->svga; uint8_t temp; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; - + switch (addr) { case 0x3D4: @@ -123,7 +123,7 @@ static void *vga_init(const device_t *info) vga->svga.bpp = 8; vga->svga.miscout = 1; - + return vga; } @@ -133,7 +133,7 @@ void *ps1vga_init(const device_t *info) { vga_t *vga = malloc(sizeof(vga_t)); memset(vga, 0, sizeof(vga_t)); - + if (info->flags & DEVICE_MCA) video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_ps1_svga_mca); else @@ -149,7 +149,7 @@ void *ps1vga_init(const device_t *info) vga->svga.bpp = 8; vga->svga.miscout = 1; - + return vga; } @@ -163,14 +163,14 @@ void vga_close(void *p) vga_t *vga = (vga_t *)p; svga_close(&vga->svga); - + free(vga); } void vga_speed_changed(void *p) { vga_t *vga = (vga_t *)p; - + svga_recalctimings(&vga->svga); } diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index d9c5dc437..43d389353 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -148,18 +148,18 @@ void voodoo_recalc(voodoo_t *voodoo) static uint16_t voodoo_readw(uint32_t addr, void *p) { voodoo_t *voodoo = (voodoo_t *)p; - + addr &= 0xffffff; cycles -= voodoo->read_time; - + if ((addr & 0xc00000) == 0x400000) /*Framebuffer*/ { if (SLI_ENABLED) { voodoo_set_t *set = voodoo->set; int y = (addr >> 11) & 0x3ff; - + if (y & 1) voodoo = set->voodoos[1]; else @@ -174,7 +174,7 @@ static uint16_t voodoo_readw(uint32_t addr, void *p) } voodoo_wait_for_render_thread_idle(voodoo); voodoo->flush = 0; - + return voodoo_fb_readw(addr, voodoo); } @@ -189,7 +189,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) int fifo_size; voodoo->rd_count++; addr &= 0xffffff; - + cycles -= voodoo->read_time; if (addr & 0x800000) /*Texture*/ @@ -201,7 +201,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) { voodoo_set_t *set = voodoo->set; int y = (addr >> 11) & 0x3ff; - + if (y & 1) voodoo = set->voodoos[1]; else @@ -216,7 +216,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) } voodoo_wait_for_render_thread_idle(voodoo); voodoo->flush = 0; - + temp = voodoo_fb_readl(addr, voodoo); } else switch (addr & 0x3fc) @@ -232,7 +232,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) { voodoo_t *voodoo_other = (voodoo == voodoo->set->voodoos[0]) ? voodoo->set->voodoos[1] : voodoo->set->voodoos[0]; int other_written = voodoo_other->cmd_written + voodoo_other->cmd_written_fifo; - + if (voodoo_other->swap_count > swap_count) swap_count = voodoo_other->swap_count; if ((voodoo_other->fifo_write_idx - voodoo_other->fifo_read_idx) > fifo_entries) @@ -243,7 +243,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) if (!voodoo_other->voodoo_busy) voodoo_wake_fifo_thread(voodoo_other); } - + fifo_size = 0xffff - fifo_entries; temp = fifo_size << 12; if (fifo_size < 0x40) @@ -280,7 +280,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) case SST_fbzMode: voodoo_flush(voodoo); temp = voodoo->params.fbzMode; - break; + break; case SST_lfbMode: voodoo_flush(voodoo); temp = voodoo->lfbMode; @@ -306,7 +306,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) voodoo_flush(voodoo); temp = voodoo->params.color1; break; - + case SST_fbiPixelsIn: temp = voodoo->fbiPixelsIn & 0xffffff; break; @@ -331,7 +331,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) break; case SST_fbiInit1: temp = voodoo->fbiInit1; - break; + break; case SST_fbiInit2: if (voodoo->initEnable & 0x04) temp = voodoo->dac_readdata; @@ -352,10 +352,10 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) uint32_t pre_div = diff * voodoo->h_total; uint32_t post_div = pre_div / line_time; uint32_t h_pos = (voodoo->h_total - 1) - post_div; - + if (h_pos >= voodoo->h_total) h_pos = 0; - + temp = voodoo->line & 0x1fff; temp |= (h_pos << 16); } @@ -375,7 +375,7 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) temp = voodoo->cmdfifo_base >> 12; temp |= (voodoo->cmdfifo_end >> 12) << 16; break; - + case SST_cmdFifoRdPtr: temp = voodoo->cmdfifo_rp; break; @@ -388,12 +388,12 @@ static uint32_t voodoo_readl(uint32_t addr, void *p) case SST_cmdFifoDepth: temp = voodoo->cmdfifo_depth_wr - voodoo->cmdfifo_depth_rd; break; - + default: voodoo_log("voodoo_readl : bad addr %08X\n", addr); temp = 0xffffffff; } - + return temp; } @@ -402,7 +402,7 @@ static void voodoo_writew(uint32_t addr, uint16_t val, void *p) voodoo_t *voodoo = (voodoo_t *)p; voodoo->wr_count++; addr &= 0xffffff; - + cycles -= voodoo->write_time; if ((addr & 0xc00000) == 0x400000) /*Framebuffer*/ @@ -416,7 +416,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) voodoo->wr_count++; addr &= 0xffffff; - + if (addr == voodoo->last_write_addr+4) cycles -= voodoo->burst_time; else @@ -449,7 +449,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) case SST_userIntrCMD: fatal("userIntrCMD write %08x\n", val); break; - + case SST_swapbufferCMD: voodoo->cmd_written++; thread_wait_mutex(voodoo->swap_mutex); @@ -493,7 +493,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) if (!voodoo->voodoo_busy) voodoo_wake_fifo_threads(voodoo->set, voodoo); break; - + case SST_fbiInit4: if (voodoo->initEnable & 0x01) { @@ -573,7 +573,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) voodoo->vSync = val; voodoo->v_total = (val & 0xffff) + (val >> 16); break; - + case SST_clutData: voodoo->clutData[(val >> 24) & 0x3f].b = val & 0xff; voodoo->clutData[(val >> 24) & 0x3f].g = (val >> 8) & 0xff; @@ -633,10 +633,10 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) { voodoo->scrfilterEnabled = 1; voodoo->scrfilterThreshold = val; /* update the threshold values and generate a new lookup table if necessary */ - - if (val < 1) + + if (val < 1) voodoo->scrfilterEnabled = 0; - voodoo_threshold_check(voodoo); + voodoo_threshold_check(voodoo); voodoo_log("Voodoo Filter: %06x\n", val); } break; @@ -693,13 +693,13 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) static uint16_t voodoo_snoop_readw(uint32_t addr, void *p) { voodoo_set_t *set = (voodoo_set_t *)p; - + return voodoo_readw(addr, set->voodoos[0]); } static uint32_t voodoo_snoop_readl(uint32_t addr, void *p) { voodoo_set_t *set = (voodoo_set_t *)p; - + return voodoo_readl(addr, set->voodoos[0]); } @@ -765,7 +765,7 @@ static void voodoo_recalcmapping(voodoo_set_t *set) else { voodoo_t *voodoo = set->voodoos[0]; - + if (voodoo->pci_enable && voodoo->memBaseAddr) { voodoo_log("voodoo_recalcmapping : memBaseAddr %08X\n", voodoo->memBaseAddr); @@ -792,21 +792,21 @@ uint8_t voodoo_pci_read(int func, int addr, void *p) { case 0x00: return 0x1a; /*3dfx*/ case 0x01: return 0x12; - + case 0x02: if (voodoo->type == VOODOO_2) return 0x02; /*Voodoo 2*/ else return 0x01; /*SST-1 (Voodoo Graphics)*/ case 0x03: return 0x00; - + case 0x04: return voodoo->pci_enable ? 0x02 : 0x00; /*Respond to memory accesses*/ case 0x08: return 2; /*Revision ID*/ case 0x09: return 0; /*Programming interface*/ case 0x0a: return 0; case 0x0b: return 0x04; - + case 0x10: return 0x00; /*memBaseAddr*/ case 0x11: return 0x00; case 0x12: return 0x00; @@ -829,7 +829,7 @@ uint8_t voodoo_pci_read(int func, int addr, void *p) void voodoo_pci_write(int func, int addr, uint8_t val, void *p) { voodoo_t *voodoo = (voodoo_t *)p; - + if (func) return; @@ -841,12 +841,12 @@ void voodoo_pci_write(int func, int addr, uint8_t val, void *p) voodoo->pci_enable = val & 2; voodoo_recalcmapping(voodoo->set); break; - + case 0x13: voodoo->memBaseAddr = val << 24; voodoo_recalcmapping(voodoo->set); break; - + case 0x40: voodoo->initEnable = (voodoo->initEnable & ~0x000000ff) | val; break; @@ -868,7 +868,7 @@ void voodoo_pci_write(int func, int addr, uint8_t val, void *p) static void voodoo_speed_changed(void *p) { voodoo_set_t *voodoo_set = (voodoo_set_t *)p; - + voodoo_pixelclock_update(voodoo_set->voodoos[0]); voodoo_set->voodoos[0]->read_time = pci_nonburst_time + pci_burst_time * ((voodoo_set->voodoos[0]->fbiInit4 & 1) ? 2 : 1); voodoo_set->voodoos[0]->write_time = pci_nonburst_time + pci_burst_time * ((voodoo_set->voodoos[0]->fbiInit1 & 2) ? 1 : 0); @@ -918,7 +918,7 @@ void *voodoo_card_init() voodoo->odd_even_mask = voodoo->render_threads - 1; #ifndef NO_CODEGEN voodoo->use_recompiler = device_get_config_int("recompiler"); -#endif +#endif voodoo->type = device_get_config_int("type"); switch (voodoo->type) { case VOODOO_1: @@ -931,12 +931,12 @@ void *voodoo_card_init() voodoo->dual_tmus = 1; break; } - + if (voodoo->type == VOODOO_2) /*generate filter lookup tables*/ voodoo_generate_filter_v2(voodoo); else voodoo_generate_filter_v1(voodoo); - + pci_add_card(PCI_ADD_NORMAL, voodoo_pci_read, voodoo_pci_write, voodoo); mem_mapping_add(&voodoo->mapping, 0, 0, NULL, voodoo_readw, voodoo_readl, NULL, voodoo_writew, voodoo_writel, NULL, MEM_MAPPING_EXTERNAL, voodoo); @@ -947,7 +947,7 @@ void *voodoo_card_init() voodoo->tex_mem[1] = malloc(voodoo->texture_size * 1024 * 1024); voodoo->tex_mem_w[0] = (uint16_t *)voodoo->tex_mem[0]; voodoo->tex_mem_w[1] = (uint16_t *)voodoo->tex_mem[1]; - + for (c = 0; c < TEX_CACHE_MAX; c++) { voodoo->texture_cache[0][c].data = malloc((256*256 + 256*256 + 128*128 + 64*64 + 32*32 + 16*16 + 8*8 + 4*4 + 2*2) * 4); voodoo->texture_cache[0][c].base = -1; /*invalid*/ @@ -961,7 +961,7 @@ void *voodoo_card_init() } timer_add(&voodoo->timer, voodoo_callback, voodoo, 1); - + voodoo->svga = svga_get_pri(); voodoo->fbiInit0 = 0; @@ -992,7 +992,7 @@ void *voodoo_card_init() } voodoo->swap_mutex = thread_create_mutex(); timer_add(&voodoo->wake_timer, voodoo_wake_timer, (void *)voodoo, 0); - + for (c = 0; c < 0x100; c++) { rgb332[c].r = c & 0xe0; rgb332[c].g = (c << 3) & 0xe0; @@ -1002,12 +1002,12 @@ void *voodoo_card_init() rgb332[c].b = rgb332[c].b | (rgb332[c].b >> 2); rgb332[c].b = rgb332[c].b | (rgb332[c].b >> 4); rgb332[c].a = 0xff; - + ai44[c].a = (c & 0xf0) | ((c & 0xf0) >> 4); ai44[c].r = (c & 0x0f) | ((c & 0x0f) << 4); ai44[c].g = ai44[c].b = ai44[c].r; } - + for (c = 0; c < 0x10000; c++) { rgb565[c].r = (c >> 8) & 0xf8; rgb565[c].g = (c >> 3) & 0xfc; @@ -1033,7 +1033,7 @@ void *voodoo_card_init() argb4444[c].r |= (argb4444[c].r >> 4); argb4444[c].g |= (argb4444[c].g >> 4); argb4444[c].b |= (argb4444[c].b >> 4); - + ai88[c].a = (c >> 8); ai88[c].r = c & 0xff; ai88[c].g = c & 0xff; @@ -1049,7 +1049,7 @@ void *voodoo_card_init() voodoo->force_blit_count = 0; voodoo->can_blit = 0; voodoo->force_blit_mutex = thread_create_mutex(); - + return voodoo; } @@ -1183,16 +1183,16 @@ void *voodoo_init() uint32_t tmuConfig = 1; int type; memset(voodoo_set, 0, sizeof(voodoo_set_t)); - + type = device_get_config_int("type"); - + voodoo_set->nr_cards = device_get_config_int("sli") ? 2 : 1; voodoo_set->voodoos[0] = voodoo_card_init(); voodoo_set->voodoos[0]->set = voodoo_set; if (voodoo_set->nr_cards == 2) { voodoo_set->voodoos[1] = voodoo_card_init(); - + voodoo_set->voodoos[1]->set = voodoo_set; if (type == VOODOO_2) @@ -1225,13 +1225,13 @@ void *voodoo_init() tmuConfig = 1 | (3 << 6); break; } - + voodoo_set->voodoos[0]->tmuConfig = tmuConfig; if (voodoo_set->nr_cards == 2) voodoo_set->voodoos[1]->tmuConfig = tmuConfig; mem_mapping_add(&voodoo_set->snoop_mapping, 0, 0, NULL, voodoo_snoop_readw, voodoo_snoop_readl, NULL, voodoo_snoop_writew, voodoo_snoop_writel, NULL, MEM_MAPPING_EXTERNAL, voodoo_set); - + return voodoo_set; } @@ -1291,11 +1291,11 @@ void voodoo_card_close(voodoo_t *voodoo) void voodoo_close(void *p) { voodoo_set_t *voodoo_set = (voodoo_set_t *)p; - + if (voodoo_set->nr_cards == 2) voodoo_card_close(voodoo_set->voodoos[1]); voodoo_card_close(voodoo_set->voodoos[0]); - + free(voodoo_set); } diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 64f2b2b1b..933f521a0 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -69,11 +69,11 @@ enum typedef struct banshee_t { svga_t svga; - + rom_t bios_rom; - + uint8_t pci_regs[256]; - + uint32_t memBaseAddr0; uint32_t memBaseAddr1; uint32_t ioBaseAddr; @@ -84,12 +84,12 @@ typedef struct banshee_t uint32_t miscInit0, miscInit1; uint32_t pciInit0; uint32_t vgaInit0, vgaInit1; - + uint32_t command_2d; uint32_t srcBaseAddr_2d; - + uint32_t pllCtrl0, pllCtrl1, pllCtrl2; - + uint32_t dacMode; int dacAddr; @@ -98,22 +98,22 @@ typedef struct banshee_t uint32_t vidProcCfg; uint32_t vidScreenSize; uint32_t vidSerialParallelPort; - + int overlay_pix_fmt; - + uint32_t hwCurPatAddr, hwCurLoc, hwCurC0, hwCurC1; uint32_t intrCtrl; - + uint32_t overlay_buffer[2][4096]; mem_mapping_t linear_mapping; mem_mapping_t reg_mapping_low; /*0000000-07fffff*/ mem_mapping_t reg_mapping_high; /*0c00000-1ffffff - Windows 2000 puts the BIOS ROM in between these two areas*/ - + voodoo_t *voodoo; - + uint32_t desktop_addr; int desktop_y; uint32_t desktop_stride_tiled; @@ -139,15 +139,15 @@ enum Init_2dCommand = 0x30, Init_2dSrcBaseAddr = 0x34, Init_strapInfo = 0x38, - + PLL_pllCtrl0 = 0x40, PLL_pllCtrl1 = 0x44, PLL_pllCtrl2 = 0x48, - + DAC_dacMode = 0x4c, DAC_dacAddr = 0x50, DAC_dacData = 0x54, - + Video_vidProcCfg = 0x5c, Video_maxRgbDelta = 0x58, Video_hwCurPatAddr = 0x60, @@ -297,10 +297,10 @@ static void banshee_out(uint16_t addr, uint8_t val, void *p) banshee_t *banshee = (banshee_t *)p; svga_t *svga = &banshee->svga; uint8_t old; - + // /*if (addr != 0x3c9) */banshee_log("banshee_out : %04X %02X %04X:%04X\n", addr, val, CS,cpu_state.pc); - - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; switch (addr) @@ -351,10 +351,10 @@ static uint8_t banshee_in(uint16_t addr, void *p) uint8_t temp; // if (addr != 0x3da) banshee_log("banshee_in : %04X ", addr); - - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) + + if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; - + switch (addr) { case 0x3c2: @@ -393,7 +393,7 @@ static void banshee_updatemapping(banshee_t *banshee) return; } - banshee_log("Update mapping - bank %02X ", svga->gdcreg[6] & 0xc); + banshee_log("Update mapping - bank %02X ", svga->gdcreg[6] & 0xc); switch (svga->gdcreg[6] & 0xc) /*Banked framebuffer*/ { case 0x0: /*128k at A0000*/ @@ -413,7 +413,7 @@ static void banshee_updatemapping(banshee_t *banshee) svga->banked_mask = 0x7fff; break; } - + banshee_log("Linear framebuffer %08X ", banshee->memBaseAddr1); mem_mapping_set_addr(&banshee->linear_mapping, banshee->memBaseAddr1, 32 << 20); banshee_log("registers %08X\n", banshee->memBaseAddr0); @@ -470,7 +470,7 @@ static void banshee_recalctimings(svga_t *svga) { banshee_t *banshee = (banshee_t *)svga->p; voodoo_t *voodoo = banshee->voodoo; - + /*7 R/W Horizontal Retrace End bit 5. - 6 R/W Horizontal Retrace Start bit 8 0x4 5 R/W Horizontal Blank End bit 6. - @@ -587,7 +587,7 @@ static void banshee_recalctimings(svga_t *svga) svga->clock = (cpuclock * (float)(1ull << 32)) / freq; // svga->clock = cpuclock / freq; - + // banshee_log("svga->clock = %g %g m=%i k=%i n=%i\n", freq, freq / 1000000.0, m, k, n); } } @@ -598,7 +598,7 @@ static void banshee_ext_out(uint16_t addr, uint8_t val, void *p) // svga_t *svga = &banshee->svga; // banshee_log("banshee_ext_out: addr=%04x val=%02x\n", addr, val); - + switch (addr & 0xff) { case 0xb0: case 0xb1: case 0xb2: case 0xb3: @@ -615,7 +615,7 @@ static void banshee_ext_out(uint16_t addr, uint8_t val, void *p) case 0xdc: case 0xdd: case 0xde: case 0xdf: banshee_out((addr & 0xff)+0x300, val, p); break; - + default: banshee_log("bad banshee_ext_out: addr=%04x val=%02x\n", addr, val); } @@ -627,7 +627,7 @@ static void banshee_ext_outl(uint16_t addr, uint32_t val, void *p) svga_t *svga = &banshee->svga; // banshee_log("banshee_ext_outl: addr=%04x val=%08x %04x(%08x):%08x\n", addr, val, CS,cs,cpu_state.pc); - + switch (addr & 0xff) { case Init_pciInit0: @@ -636,7 +636,7 @@ static void banshee_ext_outl(uint16_t addr, uint32_t val, void *p) voodoo->burst_time = (banshee->agp ? agp_burst_time : pci_burst_time) * ((val & 0x200) ? 1 : 0); voodoo->write_time = (banshee->agp ? agp_nonburst_time : pci_nonburst_time) + voodoo->burst_time; break; - + case Init_lfbMemoryConfig: banshee->lfbMemoryConfig = val; // banshee_log("lfbMemoryConfig=%08x\n", val); @@ -703,7 +703,7 @@ static void banshee_ext_outl(uint16_t addr, uint32_t val, void *p) svga->fullchange = changeframecount; break; - case Video_vidProcCfg: + case Video_vidProcCfg: banshee->vidProcCfg = val; // banshee_log("vidProcCfg=%08x\n", val); banshee->overlay_pix_fmt = (val & VIDPROCCFG_OVERLAY_PIX_FORMAT_MASK) >> VIDPROCCFG_OVERLAY_PIX_FORMAT_SHIFT; @@ -817,7 +817,7 @@ static uint8_t banshee_ext_in(uint16_t addr, void *p) banshee_t *banshee = (banshee_t *)p; // svga_t *svga = &banshee->svga; uint8_t ret = 0xff; - + switch (addr & 0xff) { case Init_status: case Init_status+1: case Init_status+2: case Init_status+3: @@ -846,7 +846,7 @@ static uint8_t banshee_ext_in(uint16_t addr, void *p) } // banshee_log("banshee_ext_in: addr=%04x val=%02x\n", addr, ret); - + return ret; } @@ -899,7 +899,7 @@ static uint32_t banshee_ext_inl(uint16_t addr, void *p) uint32_t ret = 0xffffffff; cycles -= voodoo->read_time; - + switch (addr & 0xff) { case Init_status: @@ -912,7 +912,7 @@ static uint32_t banshee_ext_inl(uint16_t addr, void *p) case Init_lfbMemoryConfig: ret = banshee->lfbMemoryConfig; break; - + case Init_miscInit0: ret = banshee->miscInit0; break; @@ -955,7 +955,7 @@ static uint32_t banshee_ext_inl(uint16_t addr, void *p) case PLL_pllCtrl2: ret = banshee->pllCtrl2; break; - + case DAC_dacMode: ret = banshee->dacMode; break; @@ -966,7 +966,7 @@ static uint32_t banshee_ext_inl(uint16_t addr, void *p) ret = svga->pallook[banshee->dacAddr]; break; - case Video_vidProcCfg: + case Video_vidProcCfg: ret = banshee->vidProcCfg; break; @@ -1035,7 +1035,7 @@ static uint32_t banshee_ext_inl(uint16_t addr, void *p) } // /*if (addr) */banshee_log("banshee_ext_inl: addr=%04x val=%08x\n", addr, ret); - + return ret; } @@ -1065,12 +1065,12 @@ static uint32_t banshee_cmd_read(banshee_t *banshee, uint32_t addr) ret = voodoo->cmdfifo_base >> 12; // banshee_log("Read cmdfifo_base %08x\n", ret); break; - + case cmdRdPtrL0: ret = voodoo->cmdfifo_rp; // banshee_log("Read cmdfifo_rp %08x\n", ret); break; - + case cmdFifoDepth0: ret = voodoo->cmdfifo_depth_wr - voodoo->cmdfifo_depth_rd; // banshee_log("Read cmdfifo_depth %08x\n", ret); @@ -1078,11 +1078,11 @@ static uint32_t banshee_cmd_read(banshee_t *banshee, uint32_t addr) case 0x108: break; - + default: fatal("Unknown banshee_cmd_read %08x\n", addr); } - + return ret; } @@ -1091,7 +1091,7 @@ static uint32_t banshee_reg_readl(uint32_t addr, void *p) banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; uint32_t ret = 0xffffffff; - + cycles -= voodoo->read_time; switch (addr & 0x1f00000) @@ -1102,7 +1102,7 @@ static uint32_t banshee_reg_readl(uint32_t addr, void *p) else ret = banshee_cmd_read(banshee, addr); break; - + case 0x0100000: /*2D registers*/ voodoo_flush(voodoo); switch (addr & 0x1fc) @@ -1166,7 +1166,7 @@ static uint32_t banshee_reg_readl(uint32_t addr, void *p) case SST_intrCtrl: ret = banshee->intrCtrl & 0x0030003f; break; - + case SST_fbzColorPath: voodoo_flush(voodoo); ret = voodoo->params.fbzColorPath; @@ -1248,12 +1248,12 @@ static void banshee_reg_write(uint32_t addr, uint8_t val, void *p) } static void banshee_reg_writew(uint32_t addr, uint16_t val, void *p) -{ +{ banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; cycles -= voodoo->write_time; - + // banshee_log("banshee_reg_writew: addr=%08x val=%04x\n", addr, val); switch (addr & 0x1f00000) { @@ -1277,7 +1277,7 @@ static void banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val) voodoo->cmdfifo_end = voodoo->cmdfifo_base + (((voodoo->cmdfifo_size & 0xff) + 1) << 12); // banshee_log("cmdfifo_base=%08x cmdfifo_end=%08x %08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end, val); break; - + case cmdBaseSize0: voodoo->cmdfifo_size = val; voodoo->cmdfifo_end = voodoo->cmdfifo_base + (((voodoo->cmdfifo_size & 0xff) + 1) << 12); @@ -1286,7 +1286,7 @@ static void banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val) voodoo->cmdfifo_in_sub = 0; /*Not sure exactly when this should be reset*/ // banshee_log("cmdfifo_base=%08x cmdfifo_end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); break; - + // voodoo->cmdfifo_end = ((val >> 16) & 0x3ff) << 12; // banshee_log("CMDFIFO base=%08x end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); // break; @@ -1304,7 +1304,7 @@ static void banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val) voodoo->cmdfifo_depth_rd = 0; voodoo->cmdfifo_depth_wr = val & 0xffff; break; - + default: banshee_log("Unknown banshee_cmd_write: addr=%08x val=%08x\n", addr, val); break; @@ -1325,7 +1325,7 @@ static void banshee_reg_writel(uint32_t addr, uint32_t val, void *p) { banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; - + if (addr == voodoo->last_write_addr+4) cycles -= voodoo->burst_time; else @@ -1333,7 +1333,7 @@ static void banshee_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo->last_write_addr = addr; // banshee_log("banshee_reg_writel: addr=%08x val=%08x\n", addr, val); - + switch (addr & 0x1f00000) { case 0x0000000: /*IO remap*/ @@ -1351,7 +1351,7 @@ static void banshee_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo_queue_command(voodoo, (addr & 0x1fc) | FIFO_WRITEL_2DREG, val); } break; - + case 0x0200000: case 0x0300000: case 0x0400000: case 0x0500000: /*3D registers*/ switch (addr & 0x3fc) { @@ -1395,25 +1395,25 @@ static void banshee_reg_writel(uint32_t addr, uint32_t val, void *p) if (!voodoo->voodoo_busy) voodoo_wake_fifo_threads(voodoo->set, voodoo); break; - + case SST_swapPending: thread_wait_mutex(voodoo->swap_mutex); voodoo->swap_count++; thread_release_mutex(voodoo->swap_mutex); // voodoo->cmd_written++; break; - + default: voodoo_queue_command(voodoo, (addr & 0x3ffffc) | FIFO_WRITEL_REG, val); break; } break; - + case 0x0600000: case 0x0700000: /*Texture download*/ voodoo->tex_count++; voodoo_queue_command(voodoo, (addr & 0x1ffffc) | FIFO_WRITEL_TEX, val); break; - + case 0x1000000: case 0x1100000: case 0x1200000: case 0x1300000: /*3D LFB*/ case 0x1400000: case 0x1500000: case 0x1600000: case 0x1700000: case 0x1800000: case 0x1900000: case 0x1a00000: case 0x1b00000: @@ -1428,7 +1428,7 @@ static uint8_t banshee_read_linear(uint32_t addr, void *p) banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; svga_t *svga = &banshee->svga; - + cycles -= voodoo->read_time; addr &= svga->decode_mask; @@ -1447,7 +1447,7 @@ static uint8_t banshee_read_linear(uint32_t addr, void *p) return 0xff; cycles -= video_timing_read_b; - + // banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); return svga->vram[addr & svga->vram_mask]; @@ -1458,10 +1458,10 @@ static uint16_t banshee_read_linear_w(uint32_t addr, void *p) banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; svga_t *svga = &banshee->svga; - + if (addr & 1) - return banshee_read_linear(addr, p) | (banshee_read_linear(addr+1, p) << 8); - + return banshee_read_linear(addr, p) | (banshee_read_linear(addr+1, p) << 8); + cycles -= voodoo->read_time; addr &= svga->decode_mask; if (addr >= voodoo->tile_base) @@ -1479,7 +1479,7 @@ static uint16_t banshee_read_linear_w(uint32_t addr, void *p) return 0xff; cycles -= video_timing_read_w; - + // banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); return *(uint16_t *)&svga->vram[addr & svga->vram_mask]; @@ -1490,10 +1490,10 @@ static uint32_t banshee_read_linear_l(uint32_t addr, void *p) banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; svga_t *svga = &banshee->svga; - + if (addr & 3) - return banshee_read_linear_w(addr, p) | (banshee_read_linear_w(addr+2, p) << 16); - + return banshee_read_linear_w(addr, p) | (banshee_read_linear_w(addr+2, p) << 16); + cycles -= voodoo->read_time; addr &= svga->decode_mask; @@ -1523,7 +1523,7 @@ static void banshee_write_linear(uint32_t addr, uint8_t val, void *p) banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; svga_t *svga = &banshee->svga; - + cycles -= voodoo->write_time; // banshee_log("write_linear: addr=%08x val=%02x\n", addr, val); @@ -1553,14 +1553,14 @@ static void banshee_write_linear_w(uint32_t addr, uint16_t val, void *p) banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; svga_t *svga = &banshee->svga; - + if (addr & 1) { banshee_write_linear(addr, val, p); banshee_write_linear(addr + 1, val >> 8, p); return; - } - + } + cycles -= voodoo->write_time; // banshee_log("write_linear: addr=%08x val=%02x\n", addr, val); addr &= svga->decode_mask; @@ -1614,7 +1614,7 @@ static void banshee_write_linear_l(uint32_t addr, uint32_t val, void *p) addr -= voodoo->tile_base; x = addr & (voodoo->tile_stride-1); y = addr >> voodoo->tile_stride_shift; - + addr = voodoo->tile_base + (x & 127) + ((x >> 7) * 128*32) + ((y & 31) * 128) + (y >> 5)*voodoo->tile_x_real; // banshee_log(" Tile %08x->%08x->%08x->%08x %i %i tile_x=%i\n", old_addr, addr_off, addr2, addr, x, y, voodoo->tile_x_real); } @@ -1695,9 +1695,9 @@ void banshee_hwcursor_draw(svga_t *svga, int displine) for (c = 0; c < 8; c++) plane1[c] = svga->vram[svga->hwcursor_latch.addr + c + 8]; svga->hwcursor_latch.addr += 16; - + x_off = svga->hwcursor_latch.x; - + if (banshee->vidProcCfg & VIDPROCCFG_CURSOR_MODE) { /*X11 mode*/ @@ -2148,7 +2148,7 @@ static void banshee_overlay_draw(svga_t *svga, int displine) } } break; - + case VIDPROCCFG_FILTER_MODE_DITHER_4X4: if (banshee->voodoo->scrfilter && banshee->voodoo->scrfilterEnabled) { @@ -2348,7 +2348,7 @@ static void banshee_overlay_draw(svga_t *svga, int displine) break; } } - + if (banshee->vidProcCfg & VIDPROCCFG_V_SCALE_ENABLE) voodoo->overlay.src_y += voodoo->overlay.vidOverlayDvdy; else @@ -2359,7 +2359,7 @@ void banshee_set_overlay_addr(void *p, uint32_t addr) { banshee_t *banshee = (banshee_t *)p; voodoo_t *voodoo = banshee->voodoo; - + banshee->svga.overlay.addr = banshee->voodoo->leftOverlayBuf & 0xfffffff; banshee->svga.overlay_latch.addr = banshee->voodoo->leftOverlayBuf & 0xfffffff; memset(voodoo->dirty_line, 1, sizeof(voodoo->dirty_line)); @@ -2406,22 +2406,22 @@ static uint8_t banshee_pci_read(int func, int addr, void *p) { case 0x00: ret = 0x1a; break; /*3DFX*/ case 0x01: ret = 0x12; break; - + case 0x02: ret = (banshee->type == TYPE_BANSHEE) ? 0x03 : 0x05; break; case 0x03: ret = 0x00; break; case 0x04: ret = banshee->pci_regs[0x04] & 0x27; break; - + case 0x07: ret = banshee->pci_regs[0x07] & 0x36; break; - + case 0x08: ret = (banshee->type == TYPE_BANSHEE) ? 3 : 1; break; /*Revision ID*/ case 0x09: ret = 0; break; /*Programming interface*/ - + case 0x0a: ret = 0x00; break; /*Supports VGA interface*/ case 0x0b: ret = 0x03; break; case 0x0d: ret = banshee->pci_regs[0x0d] & 0xf8; break; - + case 0x10: ret = 0x00; break; /*memBaseAddr0*/ case 0x11: ret = 0x00; break; case 0x12: ret = 0x00; break; @@ -2431,7 +2431,7 @@ static uint8_t banshee_pci_read(int func, int addr, void *p) case 0x15: ret = 0x00; break; case 0x16: ret = 0x00; break; case 0x17: ret = banshee->memBaseAddr1 >> 24; break; - + case 0x18: ret = 0x01; break; /*ioBaseAddr*/ case 0x19: ret = banshee->ioBaseAddr >> 8; break; case 0x1a: ret = banshee->ioBaseAddr >> 16; break; @@ -2451,9 +2451,9 @@ static uint8_t banshee_pci_read(int func, int addr, void *p) case 0x34: ret = banshee->agp ? 0x54 : 0x60; break; case 0x3c: ret = banshee->pci_regs[0x3c]; break; - + case 0x3d: ret = 0x01; break; /*INTA*/ - + case 0x3e: ret = 0x04; break; case 0x3f: ret = 0xff; break; @@ -2500,7 +2500,7 @@ static void banshee_pci_write(int func, int addr, uint8_t val, void *p) case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x3d: case 0x3e: case 0x3f: return; - + case PCI_REG_COMMAND: if (val & PCI_COMMAND_IO) { @@ -2523,10 +2523,10 @@ static void banshee_pci_write(int func, int addr, uint8_t val, void *p) case 0x07: banshee->pci_regs[0x07] = val & 0x3e; return; - case 0x0d: + case 0x0d: banshee->pci_regs[0x0d] = val & 0xf8; return; - + case 0x13: banshee->memBaseAddr0 = (val & 0xfe) << 24; banshee_updatemapping(banshee); @@ -2551,7 +2551,7 @@ static void banshee_pci_write(int func, int addr, uint8_t val, void *p) banshee->ioBaseAddr &= 0xff00ffff; banshee->ioBaseAddr |= val << 16; break; - + case 0x1b: banshee->ioBaseAddr &= 0x00ffffff; banshee->ioBaseAddr |= val << 24; @@ -2739,7 +2739,7 @@ static void *banshee_init_common(const device_t *info, char *fn, int has_sgram, int mem_size; banshee_t *banshee = malloc(sizeof(banshee_t)); memset(banshee, 0, sizeof(banshee_t)); - + banshee->type = type; banshee->agp = agp; banshee->has_bios = !!fn; @@ -2800,7 +2800,7 @@ static void *banshee_init_common(const device_t *info, char *fn, int has_sgram, banshee->svga.bpp = 8; banshee->svga.miscout = 1; - + banshee->dramInit0 = 1 << 27; if (has_sgram && mem_size == 16) banshee->dramInit0 |= (1 << 26); /*2xSGRAM = 16 MB*/ @@ -2809,7 +2809,7 @@ static void *banshee_init_common(const device_t *info, char *fn, int has_sgram, banshee->svga.decode_mask = 0x1ffffff; banshee->card = pci_add_card(banshee->agp ? PCI_ADD_AGP : PCI_ADD_VIDEO, banshee_pci_read, banshee_pci_write, banshee); - + banshee->voodoo = voodoo_2d3d_card_init(voodoo_type); banshee->voodoo->p = banshee; banshee->voodoo->vram = banshee->svga.vram; @@ -2858,13 +2858,13 @@ static void *banshee_init_common(const device_t *info, char *fn, int has_sgram, banshee->pci_regs[0x2e] = 0x3a; banshee->pci_regs[0x2f] = 0x00; break; - + case TYPE_VELOCITY100: banshee->pci_regs[0x2c] = 0x1a; banshee->pci_regs[0x2d] = 0x12; banshee->pci_regs[0x2e] = 0x4b; banshee->pci_regs[0x2f] = 0x00; - break; + break; } video_inform(VIDEO_FLAG_TYPE_SPECIAL, banshee->agp ? &timing_banshee_agp : &timing_banshee); @@ -2937,14 +2937,14 @@ static void banshee_close(void *p) ddc_close(banshee->ddc); i2c_gpio_close(banshee->i2c_ddc); i2c_gpio_close(banshee->i2c); - + free(banshee); } static void banshee_speed_changed(void *p) { banshee_t *banshee = (banshee_t *)p; - + svga_recalctimings(&banshee->svga); } @@ -3074,4 +3074,4 @@ const device_t velocity_100_agp_device = banshee_speed_changed, banshee_force_redraw, banshee_sdram_config -}; \ No newline at end of file +}; diff --git a/src/video/vid_voodoo_banshee_blitter.c b/src/video/vid_voodoo_banshee_blitter.c index 13ed8edbd..4d8ba2518 100644 --- a/src/video/vid_voodoo_banshee_blitter.c +++ b/src/video/vid_voodoo_banshee_blitter.c @@ -114,21 +114,21 @@ static int colorkey(voodoo_t *voodoo, uint32_t src, int src_notdst, int color_fo { uint32_t min = src_notdst ? voodoo->banshee_blt.srcColorkeyMin : voodoo->banshee_blt.dstColorkeyMin; uint32_t max = src_notdst ? voodoo->banshee_blt.srcColorkeyMax : voodoo->banshee_blt.dstColorkeyMax; - + if (!(voodoo->banshee_blt.commandExtra & (src_notdst ? CMDEXTRA_SRC_COLORKEY : CMDEXTRA_DST_COLORKEY))) return 0; - + switch (color_format) { case COLORKEY_8: return ((src & 0xff) >= (min & 0xff)) && ((src & 0xff) <= (max & 0xff)); - + case COLORKEY_16: { int r = (src >> 11) & 0x1f, r_min = (min >> 11) & 0x1f, r_max = (max >> 11) & 0x1f; int g = (src >> 5) & 0x3f, g_min = (min >> 5) & 0x3f, g_max = (max >> 5) & 0x3f; int b = src & 0x1f, b_min = min & 0x1f, b_max = max & 0x1f; - + return (r >= r_min) && (r <= r_max) && (g >= g_min) && (g <= g_max) && (b >= b_min) && (b <= b_max); } @@ -138,11 +138,11 @@ static int colorkey(voodoo_t *voodoo, uint32_t src, int src_notdst, int color_fo int r = (src >> 16) & 0xff, r_min = (min >> 16) & 0xff, r_max = (max >> 16) & 0xff; int g = (src >> 8) & 0xff, g_min = (min >> 8) & 0xff, g_max = (max >> 8) & 0xff; int b = src & 0xff, b_min = min & 0xff, b_max = max & 0xff; - + return (r >= r_min) && (r <= r_max) && (g >= g_min) && (g <= g_max) && (b >= b_min) && (b <= b_max); } - + default: return 0; } @@ -153,12 +153,12 @@ static uint32_t MIX(voodoo_t *voodoo, uint32_t dest, uint32_t src, uint32_t patt int rop_nr = 0; uint32_t result = 0; uint32_t rop; - + if (colorkey(voodoo, src, 1, colour_format_src)) rop_nr |= 2; if (colorkey(voodoo, dest, 0, colour_format_dest)) rop_nr |= 1; - + rop = voodoo->banshee_blt.rops[rop_nr]; if (rop & 0x01) @@ -185,7 +185,7 @@ static uint32_t get_addr(voodoo_t *voodoo, int x, int y, int src_notdst, uint32_ { uint32_t stride = src_notdst ? src_stride : voodoo->banshee_blt.dst_stride; uint32_t base_addr = src_notdst ? voodoo->banshee_blt.srcBaseAddr : voodoo->banshee_blt.dstBaseAddr; - + if (src_notdst ? voodoo->banshee_blt.srcBaseAddr_tiled : voodoo->banshee_blt.dstBaseAddr_tiled) return (base_addr + (x & 127) + ((x >> 7) * 128*32) + ((y & 31) * 128) + (y >> 5)*stride) & voodoo->fb_mask; else @@ -391,7 +391,7 @@ static void banshee_do_rectfill(voodoo_t *voodoo) { int pat_x = voodoo->banshee_blt.patoff_x + voodoo->banshee_blt.dstX; uint8_t pattern_mask = pattern_mono[pat_y & 7]; - + for (voodoo->banshee_blt.cur_x = 0; voodoo->banshee_blt.cur_x < voodoo->banshee_blt.dstSizeX; voodoo->banshee_blt.cur_x++) { int pattern_trans = use_pattern_trans ? (pattern_mask & (1 << (7-(pat_x & 7)))) : 1; @@ -421,7 +421,7 @@ static void do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO); uint8_t rop = voodoo->banshee_blt.command >> 24; int src_colorkey; - + switch (voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) { case SRC_FORMAT_COL_8_BPP: @@ -449,7 +449,7 @@ static void do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x { int pattern_trans = use_pattern_trans ? (pattern_mask & (1 << (7-(pat_x & 7)))) : 1; int src_x_real = (src_x * voodoo->banshee_blt.src_bpp) >> 3; - + if (src_tiled) src_x_real = (src_x_real & 127) + ((src_x_real >> 7) * 128*32); @@ -675,12 +675,12 @@ static void banshee_do_host_to_screen_blt(voodoo_t *voodoo, int count, uint32_t if (voodoo->banshee_blt.cur_y == voodoo->banshee_blt.dstSizeY) end_command(voodoo); } - + if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == SRC_FORMAT_COL_1_BPP) voodoo->banshee_blt.srcX += (voodoo->banshee_blt.srcFormat & SRC_FORMAT_STRIDE_MASK) << 3; else voodoo->banshee_blt.srcX += (voodoo->banshee_blt.srcFormat & SRC_FORMAT_STRIDE_MASK); - + voodoo->banshee_blt.host_data_count = 0; } } @@ -722,7 +722,7 @@ static void do_screen_to_screen_stretch_line(voodoo_t *voodoo,uint8_t *src_p, in uint32_t *colorPattern = voodoo->banshee_blt.colorPattern; //int error_y = voodoo->banshee_blt.dstSizeY / 2; - + /* bansheeblt_log("banshee_do_screen_to_screen_stretch_blt:\n"); bansheeblt_log(" srcXY=%i,%i srcsizeXY=%i,%i\n", voodoo->banshee_blt.srcX, voodoo->banshee_blt.srcY, voodoo->banshee_blt.srcSizeX, voodoo->banshee_blt.srcSizeY); bansheeblt_log(" dstXY=%i,%i dstsizeXY=%i,%i\n", voodoo->banshee_blt.dstX, voodoo->banshee_blt.dstY, voodoo->banshee_blt.dstSizeX, voodoo->banshee_blt.dstSizeY);*/ @@ -733,7 +733,7 @@ static void do_screen_to_screen_stretch_line(voodoo_t *voodoo,uint8_t *src_p, in int pat_x = voodoo->banshee_blt.patoff_x + voodoo->banshee_blt.dstX; uint8_t pattern_mask = pattern_mono[pat_y & 7]; int error_x = voodoo->banshee_blt.dstSizeX / 2; - + // bansheeblt_log(" Plot dest line %03i : src line %03i\n", dst_y, src_y); for (voodoo->banshee_blt.cur_x = 0; voodoo->banshee_blt.cur_x < voodoo->banshee_blt.dstSizeX; voodoo->banshee_blt.cur_x++) { @@ -812,7 +812,7 @@ static void do_screen_to_screen_stretch_line(voodoo_t *voodoo,uint8_t *src_p, in pat_x++; } } - + voodoo->banshee_blt.bres_error_0 -= voodoo->banshee_blt.srcSizeY; while (voodoo->banshee_blt.bres_error_0 < 0) { @@ -939,7 +939,7 @@ static void banshee_do_line(voodoo_t *voodoo, int draw_last_pixel) { int mask = stipple & (1 << voodoo->banshee_blt.line_bit_pos); int pattern_trans = (voodoo->banshee_blt.command & COMMAND_TRANS_MONO) ? mask : 1; - + if (y >= clip->y_min && y < clip->y_max && x >= clip->x_min && x < clip->x_max && pattern_trans) PLOT_LINE(voodoo, x, y, rop, mask ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack, COLORKEY_32); @@ -1012,7 +1012,7 @@ static void banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data) uint8_t rop = voodoo->banshee_blt.command >> 24; int y = MAX(voodoo->banshee_blt.ly[0], voodoo->banshee_blt.ry[0]); int y_end; - + // bansheeblt_log("Polyfill : data %08x\n", data); /*if r1.y>=l1.y, next vertex is left*/ @@ -1034,7 +1034,7 @@ static void banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data) voodoo->banshee_blt.x_inc[1] = (voodoo->banshee_blt.rx[1] > voodoo->banshee_blt.rx[0]) ? 1 : -1; voodoo->banshee_blt.error[1] = voodoo->banshee_blt.dy[1] / 2; } - + /* bansheeblt_log(" verts now : %03i,%03i %03i,%03i\n", voodoo->banshee_blt.lx[0], voodoo->banshee_blt.ly[0], voodoo->banshee_blt.rx[0], voodoo->banshee_blt.ry[0]); bansheeblt_log(" %03i,%03i %03i,%03i\n", voodoo->banshee_blt.lx[1], voodoo->banshee_blt.ly[1], voodoo->banshee_blt.rx[1], voodoo->banshee_blt.ry[1]); bansheeblt_log(" left dx=%i dy=%i x_inc=%i error=%i\n", voodoo->banshee_blt.dx[0],voodoo->banshee_blt.dy[0],voodoo->banshee_blt.x_inc[0],voodoo->banshee_blt.error[0]); @@ -1050,7 +1050,7 @@ static void banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data) int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + y); uint8_t pattern_mask = pattern_mono[pat_y & 7]; int x; - + for (x = voodoo->banshee_blt.lx_cur; x < voodoo->banshee_blt.rx_cur; x++) { int pat_x = voodoo->banshee_blt.patoff_x + x; @@ -1060,7 +1060,7 @@ static void banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data) PLOT(voodoo, x, y, pat_x, pat_y, pattern_mask, rop, voodoo->banshee_blt.colorFore, COLORKEY_32); } } - + voodoo->banshee_blt.error[0] -= voodoo->banshee_blt.dx[0]; while (voodoo->banshee_blt.error[0] < 0) { @@ -1100,11 +1100,11 @@ static void banshee_do_2d_blit(voodoo_t *voodoo, int count, uint32_t data) { case COMMAND_CMD_NOP: break; - + case COMMAND_CMD_SCREEN_TO_SCREEN_BLT: banshee_do_screen_to_screen_blt(voodoo); break; - + case COMMAND_CMD_SCREEN_TO_SCREEN_STRETCH_BLT: banshee_do_screen_to_screen_stretch_blt(voodoo); break; @@ -1112,7 +1112,7 @@ static void banshee_do_2d_blit(voodoo_t *voodoo, int count, uint32_t data) case COMMAND_CMD_HOST_TO_SCREEN_BLT: banshee_do_host_to_screen_blt(voodoo, count, data); break; - + case COMMAND_CMD_HOST_TO_SCREEN_STRETCH_BLT: banshee_do_host_to_screen_stretch_blt(voodoo, count, data); break; @@ -1166,7 +1166,7 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.dst_stride = voodoo->banshee_blt.dstFormat & DST_FORMAT_STRIDE_MASK; // bansheeblt_log("dstFormat=%08x\n", val); break; - + case 0x18: voodoo->banshee_blt.srcColorkeyMin = val & 0xffffff; break; @@ -1179,7 +1179,7 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) case 0x24: voodoo->banshee_blt.dstColorkeyMax = val & 0xffffff; break; - + case 0x28: voodoo->banshee_blt.bresError0 = val; voodoo->banshee_blt.bres_error_0 = val & 0xffff; @@ -1188,7 +1188,7 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.bresError1 = val; voodoo->banshee_blt.bres_error_1 = val & 0xffff; break; - + case 0x30: voodoo->banshee_blt.rop = val; voodoo->banshee_blt.rops[1] = val & 0xff; @@ -1345,7 +1345,7 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) if (val & COMMAND_INITIATE) banshee_do_2d_blit(voodoo, -1, 0); break;*/ - + case COMMAND_CMD_POLYFILL: if (val & COMMAND_INITIATE) { @@ -1365,7 +1365,7 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) break; } break; - + case 0x80: case 0x84: case 0x88: case 0x8c: case 0x90: case 0x94: case 0x98: case 0x9c: case 0xa0: case 0xa4: case 0xa8: case 0xac: @@ -1387,7 +1387,7 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) case COMMAND_CMD_HOST_TO_SCREEN_BLT: banshee_do_2d_blit(voodoo, 32, val); break; - + case COMMAND_CMD_HOST_TO_SCREEN_STRETCH_BLT: banshee_do_2d_blit(voodoo, 32, val); break; @@ -1412,7 +1412,7 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.dstY = ((int32_t)(val << 3)) >> 19; banshee_do_line(voodoo, 0); break; - + case COMMAND_CMD_POLYFILL: banshee_polyfill_continue(voodoo, val); break; diff --git a/src/video/vid_voodoo_fifo.c b/src/video/vid_voodoo_fifo.c index f36bd18d4..fcc87af11 100644 --- a/src/video/vid_voodoo_fifo.c +++ b/src/video/vid_voodoo_fifo.c @@ -155,7 +155,7 @@ void voodoo_wait_for_swap_complete(voodoo_t *voodoo) static uint32_t cmdfifo_get(voodoo_t *voodoo) { uint32_t val; - + if (!voodoo->cmdfifo_in_sub) { while (voodoo->cmdfifo_depth_rd == voodoo->cmdfifo_depth_wr) { @@ -381,7 +381,7 @@ void voodoo_fifo_thread(void *param) mask >>= 1; } break; - + case 3: num = (header >> 29) & 7; mask = header;//(header >> 10) & 0xff; diff --git a/src/video/vid_voodoo_reg.c b/src/video/vid_voodoo_reg.c index 2f3460e65..796f0aac7 100644 --- a/src/video/vid_voodoo_reg.c +++ b/src/video/vid_voodoo_reg.c @@ -583,7 +583,7 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo->params.fogTable[addr+1].dfog = (val >> 16) & 0xff; voodoo->params.fogTable[addr+1].fog = (val >> 24) & 0xff; break; - + case SST_clipLeftRight1: if (voodoo->type >= VOODOO_BANSHEE) { diff --git a/src/video/vid_voodoo_setup.c b/src/video/vid_voodoo_setup.c index 74f312fd4..e8722608f 100644 --- a/src/video/vid_voodoo_setup.c +++ b/src/video/vid_voodoo_setup.c @@ -137,7 +137,7 @@ void voodoo_triangle_setup(voodoo_t *voodoo) { int cull_sign = voodoo->sSetupMode & SETUPMODE_CULLING_SIGN; int sign = (area < 0.0); - + if ((voodoo->sSetupMode & (SETUPMODE_CULLING_ENABLE | SETUPMODE_DISABLE_PINGPONG)) == SETUPMODE_CULLING_ENABLE && voodoo->cull_pingpong) cull_sign = !cull_sign; diff --git a/src/video/vid_voodoo_texture.c b/src/video/vid_voodoo_texture.c index 9f6e59b33..80bf53d23 100644 --- a/src/video/vid_voodoo_texture.c +++ b/src/video/vid_voodoo_texture.c @@ -204,7 +204,7 @@ void voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) return; } } - + /*Texture not found, search for unused texture*/ do { diff --git a/src/video/vid_wy700.c b/src/video/vid_wy700.c index 0b5f1dd83..75a78b3c1 100644 --- a/src/video/vid_wy700.c +++ b/src/video/vid_wy700.c @@ -39,16 +39,16 @@ void updatewindowsize(int x, int y); /* The Wyse 700 is an unusual video card. Though it has an MC6845 CRTC, this * is not exposed directly to the host PC. Instead, the CRTC is controlled by - * an MC68705P3 microcontroller. + * an MC68705P3 microcontroller. * - * Rather than emulate the real CRTC, I'm writing this as more or less a + * Rather than emulate the real CRTC, I'm writing this as more or less a * fixed-frequency card with a 1280x800 display, and scaling its selection * of modes to that window. * - * By default, the card responds to both the CGA and MDA I/O and memory + * By default, the card responds to both the CGA and MDA I/O and memory * ranges. Either range can be disabled by means of jumpers; this allows - * the Wy700 to coexist with a CGA or MDA. - * + * the Wy700 to coexist with a CGA or MDA. + * * wy700->wy700_mode indicates which of the supported video modes is in use: * * 0x00: 40x 25 text (CGA compatible) [32x32 character cell] @@ -67,9 +67,9 @@ void updatewindowsize(int x, int y); /* What works (or appears to) : * MDA/CGA 80x25 text mode - * CGA 40x25 text mode - * CGA 640x200 graphics mode - * CGA 320x200 graphics mode + * CGA 40x25 text mode + * CGA 640x200 graphics mode + * CGA 320x200 graphics mode * Hi-res graphics modes * Font selection * Display enable / disable @@ -83,11 +83,11 @@ void updatewindowsize(int x, int y); /* The microcontroller sets up the real CRTC with one of five fixed mode - * definitions. As written, this is a fairly simplistic emulation that - * doesn't attempt to closely follow the actual working of the CRTC; but I've + * definitions. As written, this is a fairly simplistic emulation that + * doesn't attempt to closely follow the actual working of the CRTC; but I've * included the definitions here for information. */ -static uint8_t mode_1280x800[] = +static uint8_t mode_1280x800[] = { 0x31, /* Horizontal total */ 0x28, /* Horizontal displayed */ @@ -101,7 +101,7 @@ static uint8_t mode_1280x800[] = 0x0f, /* Maximum raster address */ }; -static uint8_t mode_1280x400[] = +static uint8_t mode_1280x400[] = { 0x31, /* Horizontal total */ 0x28, /* Horizontal displayed */ @@ -115,7 +115,7 @@ static uint8_t mode_1280x400[] = 0x0f, /* Maximum raster address */ }; -static uint8_t mode_640x400[] = +static uint8_t mode_640x400[] = { 0x18, /* Horizontal total */ 0x14, /* Horizontal displayed */ @@ -129,7 +129,7 @@ static uint8_t mode_640x400[] = 0x0f, /* Maximum raster address */ }; -static uint8_t mode_640x200[] = +static uint8_t mode_640x200[] = { 0x18, /* Horizontal total */ 0x14, /* Horizontal displayed */ @@ -143,7 +143,7 @@ static uint8_t mode_640x200[] = 0x07, /* Maximum raster address */ }; -static uint8_t mode_80x24[] = +static uint8_t mode_80x24[] = { 0x31, /* Horizontal total */ 0x28, /* Horizontal displayed */ @@ -157,7 +157,7 @@ static uint8_t mode_80x24[] = 0x0f, /* Maximum raster address */ }; -static uint8_t mode_40x24[] = +static uint8_t mode_40x24[] = { 0x18, /* Horizontal total */ 0x14, /* Horizontal displayed */ @@ -179,16 +179,16 @@ typedef struct wy700_t { mem_mapping_t mapping; - /* The microcontroller works by watching four ports: - * 0x3D8 / 0x3B8 (mode control register) + /* The microcontroller works by watching four ports: + * 0x3D8 / 0x3B8 (mode control register) * 0x3DD (top scanline address) * 0x3DF (Wy700 control register) * CRTC reg 14 (cursor location high) - * + * * It will do nothing until one of these registers is touched. When * one is, it then reconfigures the internal 6845 based on what it * sees. - */ + */ uint8_t last_03D8; /* Copies of values written to the listed */ uint8_t last_03DD; /* I/O ports */ uint8_t last_03DF; @@ -213,7 +213,7 @@ typedef struct wy700_t uint64_t dispontime, dispofftime; pc_timer_t timer; - + int linepos, displine; int vc; int dispon, blink; @@ -240,7 +240,7 @@ void wy700_out(uint16_t addr, uint8_t val, void *p) wy700_t *wy700 = (wy700_t *)p; switch (addr) { - /* These three registers are only mapped in the 3Dx range, + /* These three registers are only mapped in the 3Dx range, * not the 3Bx range. */ case 0x3DD: /* Base address (low) */ wy700->wy700_base &= 0xFF00; @@ -258,7 +258,7 @@ void wy700_out(uint16_t addr, uint8_t val, void *p) wy700->wy700_control = val; wy700_checkchanges(wy700); break; - + /* Emulated CRTC, register select */ case 0x3b0: case 0x3b2: case 0x3b4: case 0x3b6: case 0x3d0: case 0x3d2: case 0x3d4: case 0x3d6: @@ -301,7 +301,7 @@ uint8_t wy700_in(uint16_t addr, void *p) return wy700->cga_ctrl; case 0x3d9: return wy700->cga_colour; - case 0x3ba: + case 0x3ba: return wy700->mda_stat; case 0x3da: return wy700->cga_stat; @@ -310,7 +310,7 @@ uint8_t wy700_in(uint16_t addr, void *p) } -/* Check if any of the four key registers has changed. If so, check for a +/* Check if any of the four key registers has changed. If so, check for a * mode change or cursor size change */ void wy700_checkchanges(wy700_t *wy700) { @@ -336,18 +336,18 @@ void wy700_checkchanges(wy700_t *wy700) wy700->enabled = 1; wy700->detach = 0; break; - + case 2: /* Font 1 */ wy700->font = 0; break; - + case 3: /* Font 2 */ wy700->font = 1; break; - -/* Even with the microprogram from an original card, I can't really work out + +/* Even with the microprogram from an original card, I can't really work out * what commands 4 and 5 (which I've called 'cursor detach' / 'cursor attach') - * do. Command 4 sets a flag in microcontroller RAM, and command 5 clears + * do. Command 4 sets a flag in microcontroller RAM, and command 5 clears * it. When the flag is set, the real cursor doesn't track the cursor in the * emulated CRTC, and its blink rate increases. Possibly it's a self-test * function of some kind. @@ -358,21 +358,21 @@ void wy700_checkchanges(wy700_t *wy700) case 4: /* Detach cursor */ wy700->detach = 1; break; - + case 5: /* Attach cursor */ wy700->detach = 0; break; - + case 6: /* Disable display */ wy700->enabled = 0; break; - + case 7: /* Enable display */ wy700->enabled = 1; break; } /* A control write with the top bit set selects graphics mode */ - if (wy700->wy700_control & 0x80) + if (wy700->wy700_control & 0x80) { /* Select hi-res graphics mode; map framebuffer at A0000 */ mem_mapping_set_addr(&wy700->mapping, 0xa0000, 0x20000); @@ -381,17 +381,17 @@ void wy700_checkchanges(wy700_t *wy700) /* Select appropriate preset timings */ if (wy700->wy700_mode & 0x40) { - memcpy(wy700->real_crtc, mode_1280x800, + memcpy(wy700->real_crtc, mode_1280x800, sizeof(mode_1280x800)); } else if (wy700->wy700_mode & 0x20) { - memcpy(wy700->real_crtc, mode_1280x400, + memcpy(wy700->real_crtc, mode_1280x400, sizeof(mode_1280x400)); } else { - memcpy(wy700->real_crtc, mode_640x400, + memcpy(wy700->real_crtc, mode_640x400, sizeof(mode_640x400)); } } @@ -400,15 +400,15 @@ void wy700_checkchanges(wy700_t *wy700) else if (wy700->last_03D8 != wy700->cga_ctrl) { wy700->last_03D8 = wy700->cga_ctrl; - /* Set lo-res text or graphics mode. - * (Strictly speaking, when not in hi-res mode the card - * should be mapped at B0000-B3FFF and B8000-BBFFF, leaving + /* Set lo-res text or graphics mode. + * (Strictly speaking, when not in hi-res mode the card + * should be mapped at B0000-B3FFF and B8000-BBFFF, leaving * a 16k hole between the two ranges) */ mem_mapping_set_addr(&wy700->mapping, 0xb0000, 0x0C000); if (wy700->cga_ctrl & 2) /* Graphics mode */ { wy700->wy700_mode = (wy700->cga_ctrl & 0x10) ? 6 : 4; - memcpy(wy700->real_crtc, mode_640x200, + memcpy(wy700->real_crtc, mode_640x200, sizeof(mode_640x200)); } else if (wy700->cga_ctrl & 1) /* Text mode 80x24 */ @@ -465,10 +465,10 @@ void wy700_write(uint32_t addr, uint8_t val, void *p) addr &= 0xFFFF; /* In 800-line modes, bit 1 of the control register sets the high bit of the * write address. */ - if ((wy700->wy700_mode & 0x42) == 0x42) + if ((wy700->wy700_mode & 0x42) == 0x42) { - addr |= 0x10000; - } + addr |= 0x10000; + } wy700->vram[addr] = val; } else @@ -487,10 +487,10 @@ uint8_t wy700_read(uint32_t addr, void *p) addr &= 0xFFFF; /* In 800-line modes, bit 0 of the control register sets the high bit of the * read address. */ - if ((wy700->wy700_mode & 0x41) == 0x41) + if ((wy700->wy700_mode & 0x41) == 0x41) { - addr |= 0x10000; - } + addr |= 0x10000; + } return wy700->vram[addr]; } else @@ -534,11 +534,11 @@ void wy700_textline(wy700_t *wy700) uint16_t ca = (wy700->cga_crtc[15] | (wy700->cga_crtc[14] << 8)) & 0x3fff; -/* The fake CRTC character height register selects whether MDA or CGA +/* The fake CRTC character height register selects whether MDA or CGA * attributes are used */ if (wy700->cga_crtc[9] == 0 || wy700->cga_crtc[9] == 13) { - mda = 1; + mda = 1; } if (wy700->font) @@ -566,8 +566,8 @@ void wy700_textline(wy700_t *wy700) attr = wy700->vram[(addr + 2 * x + 1) & 0x3FFF]; drawcursor = ((ma == ca) && cursorline && wy700->enabled && (wy700->cga_ctrl & 8) && (wy700->blink & 16)); - blink = ((wy700->blink & 16) && - (wy700->cga_ctrl & 0x20) && + blink = ((wy700->blink & 16) && + (wy700->cga_ctrl & 0x20) && (attr & 0x80) && !drawcursor); if (wy700->cga_ctrl & 0x20) attr &= 0x7F; @@ -590,7 +590,7 @@ void wy700_textline(wy700_t *wy700) else col = (mda ? mdacols : cgacols)[attr][blink][(bitmap[1] & (1 << ((c & 7) ^ 7))) ? 1 : 0]; if (!(wy700->enabled) || !(wy700->cga_ctrl & 8)) col = mdacols[0][0][0]; - if (w == 40) + if (w == 40) { buffer32->line[wy700->displine][(x * cw) + 2*c] = col; buffer32->line[wy700->displine][(x * cw) + 2*c + 1] = col; @@ -622,11 +622,11 @@ void wy700_cgaline(wy700_t *wy700) (wy700->displine >> 3) * 80 + ((ma & ~1) << 1); - /* The fixed mode setting here programs the real CRTC with a screen + /* The fixed mode setting here programs the real CRTC with a screen * width to 20, so draw in 20 fixed chunks of 4 bytes each */ for (x = 0; x < 20; x++) { - dat = ((wy700->vram[addr & 0x3FFF] << 24) | + dat = ((wy700->vram[addr & 0x3FFF] << 24) | (wy700->vram[(addr+1) & 0x3FFF] << 16) | (wy700->vram[(addr+2) & 0x3FFF] << 8) | (wy700->vram[(addr+3) & 0x3FFF])); @@ -681,7 +681,7 @@ void wy700_medresline(wy700_t *wy700) for (x = 0; x < 20; x++) { - dat = ((wy700->vram[addr & 0x1FFFF] << 24) | + dat = ((wy700->vram[addr & 0x1FFFF] << 24) | (wy700->vram[(addr+1) & 0x1FFFF] << 16) | (wy700->vram[(addr+2) & 0x1FFFF] << 8) | (wy700->vram[(addr+3) & 0x1FFFF])); @@ -715,8 +715,8 @@ void wy700_medresline(wy700_t *wy700) ink = (dat & 0x80000000) ? 16 + 15: 16 + 0; /* Display disabled? */ if (!(wy700->wy700_mode & 8)) ink = 16; - buffer32->line[wy700->displine][x*64 + 2*c] = - buffer32->line[wy700->displine][x*64 + 2*c+1] = + buffer32->line[wy700->displine][x*64 + 2*c] = + buffer32->line[wy700->displine][x*64 + 2*c+1] = ink; dat = dat << 1; } @@ -738,12 +738,12 @@ void wy700_hiresline(wy700_t *wy700) addr = (wy700->displine >> 1) * 160 + 4 * wy700->wy700_base; if (wy700->wy700_mode & 0x40) /* 800-line interleaved modes */ - { + { if (wy700->displine & 1) addr += 0x10000; } for (x = 0; x < 40; x++) { - dat = ((wy700->vram[addr & 0x1FFFF] << 24) | + dat = ((wy700->vram[addr & 0x1FFFF] << 24) | (wy700->vram[(addr+1) & 0x1FFFF] << 16) | (wy700->vram[(addr+2) & 0x1FFFF] << 8) | (wy700->vram[(addr+3) & 0x1FFFF])); @@ -802,8 +802,8 @@ void wy700_poll(void *p) { video_wait_for_buffer(); } - - if (wy700->wy700_mode & 0x80) + + if (wy700->wy700_mode & 0x80) mode = wy700->wy700_mode & 0xF0; else mode = wy700->wy700_mode & 0x0F; @@ -876,19 +876,19 @@ void wy700_poll(void *p) /* Fixed 1280x800 resolution */ video_res_x = WY700_XSIZE; video_res_y = WY700_YSIZE; - if (wy700->wy700_mode & 0x80) + if (wy700->wy700_mode & 0x80) mode = wy700->wy700_mode & 0xF0; else mode = wy700->wy700_mode & 0x0F; switch(mode) { - case 0x00: + case 0x00: case 0x02: video_bpp = 0; break; - case 0x04: - case 0x90: + case 0x04: + case 0x90: case 0xB0: case 0xD0: case 0xF0: video_bpp = 2; break; - default: video_bpp = 1; break; + default: video_bpp = 1; break; } wy700->blink++; } @@ -917,7 +917,7 @@ void *wy700_init(const device_t *info) io_sethandler(0x03b0, 0x000C, wy700_in, NULL, NULL, wy700_out, NULL, NULL, wy700); io_sethandler(0x03d0, 0x0010, wy700_in, NULL, NULL, wy700_out, NULL, NULL, wy700); - /* Set up the emulated attributes. + /* Set up the emulated attributes. * CGA is done in four groups: 00-0F, 10-7F, 80-8F, 90-FF */ for (c = 0; c < 0x10; c++) { @@ -1003,7 +1003,7 @@ void wy700_close(void *p) void wy700_speed_changed(void *p) { wy700_t *wy700 = (wy700_t *)p; - + wy700_recalctimings(wy700); } diff --git a/src/video/video.c b/src/video/video.c index 532995cb3..a950369c4 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -136,7 +136,7 @@ PALETTE cgapal = { {42,0,21}, {21,10,21}, {42,0,42}, {42,0,63}, {21,21,21}, {21,63,21}, {42,21,42}, {21,63,63}, {63,0,0}, {42,42,0}, {63,21,42}, {41,41,41}, - + {0,0,0}, {0,42,42}, {42,0,0}, {42,42,42}, {0,0,0}, {0,42,42}, {42,0,0}, {42,42,42}, {0,0,0}, {0,63,63}, {63,0,0}, {63,63,63}, @@ -837,7 +837,7 @@ video_init(void) cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; cgapal[c + 64].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; cgapal[c + 64].b = (((c & 1) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; - if ((c & 0x17) == 6) + if ((c & 0x17) == 6) cgapal[c + 64].g >>= 1; } for (c = 0; c < 64; c++) { @@ -931,7 +931,7 @@ void loadfont_common(FILE *f, int format) { int c, d; - + switch (format) { case 0: /* MDA */ for (c=0; c<256; c++) @@ -1045,7 +1045,7 @@ loadfont_common(FILE *f, int format) for (c = 0; c < 256; c++) fread(&fontdat12x18[c][0], 1, 36, f); break; - + } (void)fclose(f); @@ -1055,7 +1055,7 @@ void loadfont_ex(char *s, int format, int offset) { FILE *f; - + f = rom_fopen(s, "rb"); if (f == NULL) return; diff --git a/src/vnc.c b/src/vnc.c index 440542652..768b08b57 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -184,7 +184,7 @@ vnc_blit(int x, int y, int w, int h) if (screenshots) video_screenshot((uint32_t *) rfb->frameBuffer, 0, 0, VNC_MAX_X); - + video_blit_complete(); if (! updatingSize) @@ -217,7 +217,7 @@ vnc_init(UNUSED(void *arg)) updatingSize = 0; allowedX = scrnsz_x; allowedY = scrnsz_y; - + rfb = rfbGetScreen(0, NULL, VNC_MAX_X, VNC_MAX_Y, 8, 3, 4); rfb->desktopName = title; rfb->frameBuffer = (char *)malloc(VNC_MAX_X*VNC_MAX_Y*4); @@ -228,16 +228,16 @@ vnc_init(UNUSED(void *arg)) rfb->ptrAddEvent = vnc_ptrevent; rfb->kbdAddEvent = vnc_kbdevent; rfb->newClientHook = vnc_newclient; - + /* Set up our current resolution. */ rfb->width = allowedX; rfb->height = allowedY; - + rfbInitServer(rfb); rfbRunEventLoop(rfb, -1, TRUE); } - + /* Set up our BLIT handlers. */ video_setblit(vnc_blit); @@ -280,13 +280,13 @@ vnc_resize(int x, int y) if ((x != rfb->width || y != rfb->height) && x > 160 && y > 0) { vnc_log("VNC: updating resolution: %dx%d\n", x, y); - + allowedX = (rfb->width < x) ? rfb->width : x; allowedY = (rfb->width < y) ? rfb->width : y; - + rfb->width = x; rfb->height = y; - + iterator = rfbGetClientIterator(rfb); while ((cl = rfbClientIteratorNext(iterator)) != NULL) { LOCK(cl->updateMutex); @@ -295,7 +295,7 @@ vnc_resize(int x, int y) } } } - + /* Tell them to pause if we have no clients. */ int diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 3f0b3a3b6..6c5b92114 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -1,4 +1,5 @@ # +# # 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 @@ -173,7 +174,7 @@ ifndef DINPUT DINPUT := n endif ifndef OPENAL -OPENAL := y +OPENAL := n endif ifndef FLUIDSYNTH FLUIDSYNTH := y @@ -373,9 +374,6 @@ else endif endif -ifeq ($(OPENAL), y) -OPTS += -DUSE_OPENAL -endif ifeq ($(FLUIDSYNTH), y) OPTS += -DUSE_FLUIDSYNTH FSYNTHOBJ := midi_fluidsynth.o @@ -645,7 +643,6 @@ PRINTOBJ := png.o prt_cpmap.o \ prt_escp.o prt_text.o prt_ps.o SNDOBJ := sound.o \ - openal.o \ snd_opl.o snd_opl_nuked.o \ snd_resid.o \ convolve.o convolve-sse.o envelope.o extfilt.o \ @@ -736,6 +733,12 @@ else PLATOBJ += win_joystick_rawinput.o endif +ifeq ($(OPENAL), y) + SNDOBJ += openal.o +else + SNDOBJ += xaudio2.o +endif + OBJ := $(MAINOBJ) $(CPUOBJ) $(CHIPSETOBJ) $(MCHOBJ) $(DEVOBJ) $(MEMOBJ) \ $(FDDOBJ) $(GAMEOBJ) $(CDROMOBJ) $(ZIPOBJ) $(MOOBJ) $(HDDOBJ) $(MINIVHDOBJ) \ $(NETOBJ) $(PRINTOBJ) $(SCSIOBJ) $(SIOOBJ) $(SNDOBJ) $(VIDOBJ) $(VOODOOOBJ) \ @@ -744,13 +747,12 @@ ifdef EXOBJ OBJ += $(EXOBJ) endif -LIBS := -mwindows -lcomctl32 \ - -lopenal -lole32 +LIBS := -mwindows -lcomctl32 -lSDL2 -lrtmidi -limagehlp -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid ifeq ($(VNC), y) LIBS += $(VNCLIB) -lws2_32 endif -LIBS += -lpng -lz -lwsock32 -lshell32 -liphlpapi -lpsapi -lSDL2 -limm32 -lhid -lsetupapi -loleaut32 -luxtheme -lversion -lrtmidi -lwinmm -static -lstdc++ +LIBS += -lpng -lz -lwsock32 -liphlpapi -lpsapi -lhid -lsetupapi -luxtheme -static -lstdc++ ifneq ($(X64), y) ifneq ($(ARM64), y) LIBS += -Wl,--large-address-aware diff --git a/src/win/glad.c b/src/win/glad.c index 8e2e4ce13..8e0da2f36 100644 --- a/src/win/glad.c +++ b/src/win/glad.c @@ -981,4 +981,3 @@ int gladLoadGLLoader(GLADloadproc load) { load_GL_ARB_sync(load); return GLVersion.major != 0 || GLVersion.minor != 0; } - diff --git a/src/win/win.c b/src/win/win.c index 66cf8a85e..e54f4d243 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -259,10 +259,10 @@ set_language(uint32_t id) /* Set our new language ID. */ lang_id = id; SetThreadUILanguage(lang_id); - + /* Load the strings table for this ID. */ LoadCommonStrings(); - + /* Reload main menu */ menuMain = LoadMenu(hinstance, L"MainMenu"); if (hwndMain != NULL) @@ -271,7 +271,7 @@ set_language(uint32_t id) /* Re-init all the menus */ ResetAllMenus(); media_menu_init(); - } + } } @@ -468,7 +468,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) /* Set the application version ID string. */ sprintf(emu_version, "%s v%s", EMU_NAME, EMU_VERSION_FULL); - + /* First, set our (default) language. */ lang_sys = GetThreadUILanguage(); set_language(DEFAULT_LANGUAGE); @@ -852,8 +852,8 @@ plat_dir_check(char *path) DWORD dwAttrib; int len; wchar_t *temp; - - if (acp_utf8) + + if (acp_utf8) dwAttrib = GetFileAttributesA(path); else { len = mbstoc16s(NULL, path, 0) + 1; @@ -875,7 +875,7 @@ plat_dir_create(char *path) { int ret, len; wchar_t *temp; - + if (acp_utf8) return (int)SHCreateDirectoryExA(NULL, path, NULL); else { @@ -1197,12 +1197,12 @@ plat_vidapi_reload(void) /* Sets up the program language before initialization. */ -uint32_t +uint32_t plat_language_code(char* langcode) { if (!strcmp(langcode, "system")) return 0xFFFF; - + int len = mbstoc16s(NULL, langcode, 0) + 1; wchar_t *temp = malloc(len * sizeof(wchar_t)); mbstoc16s(temp, langcode, len); @@ -1222,10 +1222,10 @@ plat_language_code_r(uint32_t lcid, char* outbuf, int len) strcpy(outbuf, "system"); return; } - + wchar_t buffer[LOCALE_NAME_MAX_LENGTH + 1]; LCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0); - + c16stombs(outbuf, buffer, len); } diff --git a/src/win/win_crashdump.c b/src/win/win_crashdump.c index e1123c1e5..1da7a49b1 100644 --- a/src/win/win_crashdump.c +++ b/src/win/win_crashdump.c @@ -87,7 +87,7 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; } - + /* * What would a good filename be? * @@ -118,13 +118,13 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) // creates a new file if it doesn't. FILE_ATTRIBUTE_NORMAL, // File attributes / etc don't matter. NULL); // A template file is not being used. - + /* Check to make sure the file was actually created. */ if (hDumpFile == INVALID_HANDLE_VALUE) { /* CreateFile() failed, so just do nothing more. */ return(EXCEPTION_CONTINUE_SEARCH); } - + /* * Write the data we were passed out in a human-readable format. * @@ -152,7 +152,7 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) } } } - + /* Start to put the crash-dump string into the buffer. */ sprintf(ExceptionHandlerBuffer, "#\r\n# %s\r\n#\r\n" @@ -182,11 +182,11 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) BufPtr += 1; } } - + sprintf(BufPtr, "\r\nNumber of parameters: %lu\r\nException parameters: ", ExceptionInfo->ExceptionRecord->NumberParameters); - + for (int i = 0; i < ExceptionInfo->ExceptionRecord->NumberParameters; i++) { BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; sprintf(BufPtr,"0x%p ", @@ -196,7 +196,7 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) #if defined(__i386__) && !defined(__x86_64) PCONTEXT Registers = ExceptionInfo->ContextRecord; - + /* This binary is being compiled for x86, include a register dump. */ sprintf(BufPtr, "\r\n\r\nRegister dump:\r\n\r\n" @@ -211,7 +211,7 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) /* (MinGW headers seem to lack the x64 CONTEXT structure definition) */ sprintf(BufPtr, "\r\n"); #endif - + /* Write the string to disk. */ WriteFile(hDumpFile, ExceptionHandlerBuffer, strlen(ExceptionHandlerBuffer), NULL, NULL); diff --git a/src/win/win_devconf.c b/src/win/win_devconf.c index c4de7d90b..3c30924f7 100644 --- a/src/win/win_devconf.c +++ b/src/win/win_devconf.c @@ -93,7 +93,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) id += 2; break; - case CONFIG_MIDI: + case CONFIG_MIDI_OUT: val_int = config_get_int((char *) config_device.name, (char *) config->name, config->default_int); @@ -122,7 +122,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } id += 2; - break; + break; case CONFIG_SPINNER: val_int = config_get_int((char *) config_device.name, (char *) config->name, config->default_int); @@ -214,7 +214,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) id += 2; break; - case CONFIG_MIDI: + case CONFIG_MIDI_OUT: val_int = config_get_int((char *) config_device.name, (char *) config->name, config->default_int); @@ -324,7 +324,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) id += 2; break; - case CONFIG_MIDI: + case CONFIG_MIDI_OUT: c = SendMessage(h, CB_GETCURSEL, 0, 0); config_set_int((char *) config_device.name, (char *) config->name, c); @@ -389,7 +389,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) id++; break; case CONFIG_SELECTION: - case CONFIG_MIDI: + case CONFIG_MIDI_OUT: case CONFIG_MIDI_IN: case CONFIG_SPINNER: id += 2; @@ -487,7 +487,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst) break; case CONFIG_SELECTION: - case CONFIG_MIDI: + case CONFIG_MIDI_OUT: case CONFIG_MIDI_IN: case CONFIG_HEX16: case CONFIG_HEX20: diff --git a/src/win/win_dialog.c b/src/win/win_dialog.c index 9ae3edb1a..3bf8f1662 100644 --- a/src/win/win_dialog.c +++ b/src/win/win_dialog.c @@ -183,7 +183,7 @@ file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, WCHAR *title, int save) ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST; if (! save) - ofn.Flags |= OFN_FILEMUSTEXIST; + ofn.Flags |= OFN_FILEMUSTEXIST; if (title) ofn.lpstrTitle = title; @@ -248,6 +248,6 @@ file_dlg_w_st(HWND hwnd, int id, WCHAR *fn, char *title, int save) int file_dlg_st(HWND hwnd, int id, char *fn, char *title, int save) -{ +{ return(file_dlg(hwnd, plat_get_string(id), fn, title, save)); } diff --git a/src/win/win_icon.c b/src/win/win_icon.c index 33a5932ef..e118276f1 100644 --- a/src/win/win_icon.c +++ b/src/win/win_icon.c @@ -13,7 +13,7 @@ * * Copyright 2021 Laci bá'. */ - + #include #include #include @@ -26,15 +26,15 @@ #include <86box/plat.h> #include <86box/ui.h> #include <86box/win.h> - + HICON hIcon[256]; /* icon data loaded from resources */ -char icon_set[256] = ""; /* name of the iconset to be used */ +char icon_set[256] = ""; /* name of the iconset to be used */ void win_clear_icon_set() { int i; - - for (i = 0; i < 256; i++) + + for (i = 0; i < 256; i++) if (hIcon[i] != 0) { DestroyIcon(hIcon[i]); @@ -117,7 +117,7 @@ void win_get_icons_path(char* path_root) strcpy(roms_root, rom_path); else plat_append_filename(roms_root, exe_path, "roms"); - + plat_append_filename(path_root, roms_root, "icons"); plat_path_slash(path_root); } @@ -126,7 +126,7 @@ void win_load_icon_set() { win_clear_icon_set(); win_system_icon_set(); - + if (strlen(icon_set) == 0) { ToolBarLoadIcons(); return; @@ -134,31 +134,31 @@ void win_load_icon_set() char path_root[2048] = {0}, temp[2048] = {0}; wchar_t wtemp[2048] = {0}; - + win_get_icons_path(path_root); strcat(path_root, icon_set); plat_path_slash(path_root); - + int i, count = sizeof(icon_files) / sizeof(_ICON_DATA), x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi); for (i = 0; i < count; i++) { plat_append_filename(temp, path_root, icon_files[i].filename); mbstoc16s(wtemp, temp, strlen(temp) + 1); - + HICON ictemp; - ictemp = LoadImageW(NULL, (LPWSTR)wtemp, IMAGE_ICON, x, y, LR_LOADFROMFILE | LR_DEFAULTCOLOR); + ictemp = LoadImageW(NULL, (LPWSTR)wtemp, IMAGE_ICON, x, y, LR_LOADFROMFILE | LR_DEFAULTCOLOR); if (ictemp) { if (hIcon[icon_files[i].id]) DestroyIcon(hIcon[icon_files[i].id]); - hIcon[icon_files[i].id] = ictemp; + hIcon[icon_files[i].id] = ictemp; } } - + uint32_t curr_lang = lang_id; lang_id = 0; set_language(curr_lang); ToolBarLoadIcons(); -} \ No newline at end of file +} diff --git a/src/win/win_joystick.cpp b/src/win/win_joystick.cpp index 2615092d3..a48538eec 100644 --- a/src/win/win_joystick.cpp +++ b/src/win/win_joystick.cpp @@ -67,23 +67,23 @@ static BOOL CALLBACK joystick_enum_callback(LPCDIDEVICEINSTANCE lpddi, UNUSED(LP { if (joysticks_present >= MAX_JOYSTICKS) return DIENUM_STOP; - + joystick_log("joystick_enum_callback : found joystick %i : %s\n", joysticks_present, lpddi->tszProductName); - + joystick_guids[joysticks_present++] = lpddi->guidInstance; if (joysticks_present >= MAX_JOYSTICKS) return DIENUM_STOP; - + return DIENUM_CONTINUE; } -BOOL CALLBACK DIEnumDeviceObjectsCallback( +BOOL CALLBACK DIEnumDeviceObjectsCallback( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { plat_joystick_t *state = (plat_joystick_t *)pvRef; - + if (lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis || lpddoi->guidType == GUID_ZAxis || lpddoi->guidType == GUID_RxAxis || lpddoi->guidType == GUID_RyAxis || lpddoi->guidType == GUID_RzAxis) { @@ -122,7 +122,7 @@ BOOL CALLBACK DIEnumDeviceObjectsCallback( joystick_log("POV %i : %s %x %x\n", state->nr_povs, state->pov[state->nr_povs].name, lpddoi->dwOfs, lpddoi->dwType); state->nr_povs++; } - } + } else if (lpddoi->guidType == GUID_Slider) { if (state->nr_sliders < 2) @@ -133,7 +133,7 @@ BOOL CALLBACK DIEnumDeviceObjectsCallback( state->nr_sliders++; } } - + return DIENUM_CONTINUE; } @@ -142,30 +142,30 @@ void joystick_init() int c; atexit(joystick_close); - + joysticks_present = 0; - + if (FAILED(DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8A, (void **) &lpdi, NULL))) - fatal("joystick_init : DirectInputCreate failed\n"); + fatal("joystick_init : DirectInputCreate failed\n"); if (FAILED(lpdi->EnumDevices(DIDEVTYPE_JOYSTICK, joystick_enum_callback, NULL, DIEDFL_ATTACHEDONLY))) fatal("joystick_init : EnumDevices failed\n"); joystick_log("joystick_init: joysticks_present=%i\n", joysticks_present); - + for (c = 0; c < joysticks_present; c++) - { + { LPDIRECTINPUTDEVICE8 lpdi_joystick_temp = NULL; DIPROPRANGE joy_axis_range; DIDEVICEINSTANCE device_instance; DIDEVCAPS devcaps; - + if (FAILED(lpdi->CreateDevice(joystick_guids[c], &lpdi_joystick_temp, NULL))) fatal("joystick_init : CreateDevice failed\n"); if (FAILED(lpdi_joystick_temp->QueryInterface(IID_IDirectInputDevice8, (void **)&lpdi_joystick[c]))) fatal("joystick_init : CreateDevice failed\n"); lpdi_joystick_temp->Release(); - + memset(&device_instance, 0, sizeof(device_instance)); device_instance.dwSize = sizeof(device_instance); if (FAILED(lpdi_joystick[c]->GetDeviceInfo(&device_instance))) @@ -183,8 +183,8 @@ void joystick_init() joystick_log(" Buttons = %i\n", devcaps.dwButtons); joystick_log(" POVs = %i\n", devcaps.dwPOVs); - lpdi_joystick[c]->EnumObjects(DIEnumDeviceObjectsCallback, &plat_joystick_state[c], DIDFT_ALL); - + lpdi_joystick[c]->EnumObjects(DIEnumDeviceObjectsCallback, &plat_joystick_state[c], DIDFT_ALL); + if (FAILED(lpdi_joystick[c]->SetCooperativeLevel(hwndMain, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) fatal("joystick_init : SetCooperativeLevel failed\n"); if (FAILED(lpdi_joystick[c]->SetDataFormat(&c_dfDIJoystick))) @@ -211,7 +211,7 @@ void joystick_init() lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph); joy_axis_range.diph.dwObj = DIJOFS_SLIDER(1); lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph); - + if (FAILED(lpdi_joystick[c]->Acquire())) fatal("joystick_init : Acquire failed\n"); } @@ -266,10 +266,10 @@ void joystick_process(void) if (!joystick_type) return; for (c = 0; c < joysticks_present; c++) - { + { DIJOYSTATE joystate; int b; - + if (FAILED(lpdi_joystick[c]->Poll())) { lpdi_joystick[c]->Acquire(); @@ -281,7 +281,7 @@ void joystick_process(void) lpdi_joystick[c]->Poll(); lpdi_joystick[c]->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)&joystate); } - + plat_joystick_state[c].a[0] = joystate.lX; plat_joystick_state[c].a[1] = joystate.lY; plat_joystick_state[c].a[2] = joystate.lZ; @@ -290,7 +290,7 @@ void joystick_process(void) plat_joystick_state[c].a[5] = joystate.lRz; plat_joystick_state[c].s[0] = joystate.rglSlider[0]; plat_joystick_state[c].s[1] = joystate.rglSlider[1]; - + for (b = 0; b < 16; b++) plat_joystick_state[c].b[b] = joystate.rgbButtons[b] & 0x80; @@ -298,13 +298,13 @@ void joystick_process(void) plat_joystick_state[c].p[b] = joystate.rgdwPOV[b]; // joystick_log("joystick %i - x=%i y=%i b[0]=%i b[1]=%i %i\n", c, joystick_state[c].x, joystick_state[c].y, joystick_state[c].b[0], joystick_state[c].b[1], joysticks_present); } - + for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) { if (joystick_state[c].plat_joystick_nr) { int joystick_nr = joystick_state[c].plat_joystick_nr - 1; - + for (d = 0; d < joystick_get_axis_count(joystick_type); d++) joystick_state[c].axis[d] = joystick_get_axis(joystick_nr, joystick_state[c].axis_mapping[d]); for (d = 0; d < joystick_get_button_count(joystick_type); d++) @@ -317,10 +317,10 @@ void joystick_process(void) x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]); y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]); - + angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI); magnitude = sqrt((double)x*(double)x + (double)y*(double)y); - + if (magnitude < 16384) joystick_state[c].pov[d] = -1; else diff --git a/src/win/win_joystick_rawinput.c b/src/win/win_joystick_rawinput.c index be808fc47..d1fca0491 100644 --- a/src/win/win_joystick_rawinput.c +++ b/src/win/win_joystick_rawinput.c @@ -55,7 +55,7 @@ joystick_log(const char *fmt, ...) typedef struct { HANDLE hdevice; PHIDP_PREPARSED_DATA data; - + USAGE usage_button[256]; struct raw_axis_t { @@ -127,7 +127,7 @@ void joystick_add_axis(raw_joystick_t* rawjoy, plat_joystick_t* joy, PHIDP_VALUE } else { /* * Some joysticks will send -1 in LogicalMax, like Xbox Controllers - * so we need to mask that to appropriate value (instead of 0xFFFFFFFF) + * so we need to mask that to appropriate value (instead of 0xFFFFFFFF) */ rawjoy->axis[joy->nr_axes].max = prop->LogicalMax & ((1 << prop->BitSize) - 1); } @@ -158,7 +158,7 @@ void joystick_get_capabilities(raw_joystick_t* rawjoy, plat_joystick_t* joy) { rawjoy->data = malloc(size); if (GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_PREPARSEDDATA, rawjoy->data, &size) <= 0) fatal("joystick_get_capabilities: Failed to get preparsed data.\n"); - + HIDP_CAPS caps; HidP_GetCaps(rawjoy->data, &caps); @@ -213,7 +213,7 @@ void joystick_get_device_name(raw_joystick_t* rawjoy, plat_joystick_t* joy, PRID if (GetRawInputDeviceInfoA(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size) <= 0) fatal("joystick_get_capabilities: Failed to get device name.\n"); - HANDLE hDevObj = CreateFile(device_name, GENERIC_READ | GENERIC_WRITE, + HANDLE hDevObj = CreateFile(device_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDevObj) { HidD_GetProductString(hDevObj, device_desc_wide, sizeof(WCHAR) * 200); @@ -223,8 +223,8 @@ void joystick_get_device_name(raw_joystick_t* rawjoy, plat_joystick_t* joy, PRID int result = WideCharToMultiByte(CP_ACP, 0, device_desc_wide, 200, joy->name, 260, NULL, NULL); if (result == 0 || strlen(joy->name) == 0) - sprintf(joy->name, - "RawInput %s, VID:%04lX PID:%04lX", + sprintf(joy->name, + "RawInput %s, VID:%04lX PID:%04lX", info->hid.usUsage == HID_USAGE_GENERIC_JOYSTICK ? "Joystick" : "Gamepad", info->hid.dwVendorId, info->hid.dwProductId); @@ -248,8 +248,8 @@ void joystick_init() PRID_DEVICE_INFO info = NULL; if (joysticks_present >= MAX_PLAT_JOYSTICKS) break; - if (deviceList[i].dwType != RIM_TYPEHID) continue; - + if (deviceList[i].dwType != RIM_TYPEHID) continue; + /* Get device info: hardware IDs and usage IDs */ GetRawInputDeviceInfoA(deviceList[i].hDevice, RIDI_DEVICEINFO, NULL, &size); info = malloc(size); @@ -259,9 +259,9 @@ void joystick_init() /* If this is not a joystick/gamepad, skip */ if (info->hid.usUsagePage != HID_USAGE_PAGE_GENERIC) goto end_loop; - if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK && + if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK && info->hid.usUsage != HID_USAGE_GENERIC_GAMEPAD) goto end_loop; - + plat_joystick_t *joy = &plat_joystick_state[joysticks_present]; raw_joystick_t *rawjoy = &raw_joystick_state[joysticks_present]; rawjoy->hdevice = deviceList[i].hDevice; @@ -269,7 +269,7 @@ void joystick_init() joystick_get_capabilities(rawjoy, joy); joystick_get_device_name(rawjoy, joy, info); - joystick_log("joystick_init: %s - %d buttons, %d axes, %d POVs\n", + joystick_log("joystick_init: %s - %d buttons, %d axes, %d POVs\n", joy->name, joy->nr_buttons, joy->nr_axes, joy->nr_povs); joysticks_present++; @@ -277,7 +277,7 @@ void joystick_init() end_loop: free(info); } - + joystick_log("joystick_init: joysticks_present=%i\n", joysticks_present); /* Initialize the RawInput (joystick and gamepad) module. */ @@ -293,7 +293,7 @@ void joystick_init() ridev[1].usUsage = HID_USAGE_GENERIC_GAMEPAD; if (!RegisterRawInputDevices(ridev, 2, sizeof(RAWINPUTDEVICE))) - fatal("plat_joystick_init: RegisterRawInputDevices failed\n"); + fatal("plat_joystick_init: RegisterRawInputDevices failed\n"); } void joystick_close() @@ -326,7 +326,7 @@ void win_joystick_handle(PRAWINPUT raw) } } if (j == -1) return; - + /* Read buttons */ USAGE usage_list[128] = {0}; ULONG usage_length = plat_joystick_state[j].nr_buttons; @@ -334,7 +334,7 @@ void win_joystick_handle(PRAWINPUT raw) r = HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON, 0, usage_list, &usage_length, raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid); - + if (r == HIDP_STATUS_SUCCESS) { for (int i=0; imax - axis->min + 1) / 2; - r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, axis->link, axis->usage, &uvalue, + r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, axis->link, axis->usage, &uvalue, raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid); - + if (r == HIDP_STATUS_SUCCESS) { if (axis->min < 0) { /* extend signed uvalue to LONG */ @@ -371,7 +371,7 @@ void win_joystick_handle(PRAWINPUT raw) } plat_joystick_state[j].a[a] = value; - //joystick_log("%s %-06d ", plat_joystick_state[j].axis[a].name, plat_joystick_state[j].a[a]); + //joystick_log("%s %-06d ", plat_joystick_state[j].axis[a].name, plat_joystick_state[j].a[a]); } /* read povs */ @@ -379,10 +379,10 @@ void win_joystick_handle(PRAWINPUT raw) struct raw_pov_t* pov = &raw_joystick_state[j].pov[p]; ULONG uvalue = 0; LONG value = -1; - - r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, pov->link, pov->usage, &uvalue, + + r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, pov->link, pov->usage, &uvalue, raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid); - + if (r == HIDP_STATUS_SUCCESS && (uvalue >= pov->min && uvalue <= pov->max)) { value = (uvalue - pov->min) * 36000; value /= (pov->max - pov->min + 1); @@ -392,7 +392,7 @@ void win_joystick_handle(PRAWINPUT raw) plat_joystick_state[j].p[p] = value; //joystick_log("%s %-3d ", plat_joystick_state[j].pov[p].name, plat_joystick_state[j].p[p]); - + } //joystick_log("\n"); } @@ -405,13 +405,13 @@ static int joystick_get_axis(int joystick_nr, int mapping) int pov = plat_joystick_state[joystick_nr].p[mapping & 3]; if (LOWORD(pov) == 0xFFFF) return 0; - else + else return sin((2*M_PI * (double)pov) / 36000.0) * 32767; } else if (mapping & POV_Y) { int pov = plat_joystick_state[joystick_nr].p[mapping & 3]; - + if (LOWORD(pov) == 0xFFFF) return 0; else @@ -419,7 +419,7 @@ static int joystick_get_axis(int joystick_nr, int mapping) } else return plat_joystick_state[joystick_nr].a[plat_joystick_state[joystick_nr].axis[mapping].id]; - + } @@ -434,7 +434,7 @@ void joystick_process(void) if (joystick_state[c].plat_joystick_nr) { int joystick_nr = joystick_state[c].plat_joystick_nr - 1; - + for (d = 0; d < joystick_get_axis_count(joystick_type); d++) joystick_state[c].axis[d] = joystick_get_axis(joystick_nr, joystick_state[c].axis_mapping[d]); for (d = 0; d < joystick_get_button_count(joystick_type); d++) @@ -447,10 +447,10 @@ void joystick_process(void) x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]); y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]); - + angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI); magnitude = sqrt((double)x*(double)x + (double)y*(double)y); - + if (magnitude < 16384) joystick_state[c].pov[d] = -1; else @@ -468,4 +468,3 @@ void joystick_process(void) } } } - diff --git a/src/win/win_joystick_xinput.c b/src/win/win_joystick_xinput.c index 4b7643c43..325d87bd9 100644 --- a/src/win/win_joystick_xinput.c +++ b/src/win/win_joystick_xinput.c @@ -82,9 +82,9 @@ void joystick_init() int c; atexit(joystick_close); - + joysticks_present = 0; - + memset(controllers, 0, sizeof(XINPUT_STATE) * XINPUT_MAX_JOYSTICKS); for (c=0; c> 1); } - + return axis_sel - nr_povs; } @@ -188,31 +188,31 @@ joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) for (c = 0; c < joysticks_present; c++) SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[c].name); - + SendMessage(h, CB_SETCURSEL, joystick, 0); rebuild_axis_button_selections(hdlg); - + if (joystick_state[joystick_nr].plat_joystick_nr) { nr_axes = plat_joystick_state[joystick-1].nr_axes; nr_povs = plat_joystick_state[joystick-1].nr_povs; - + for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++) { int mapping = joystick_state[joystick_nr].axis_mapping[c]; - + h = GetDlgItem(hdlg, id); if (mapping & POV_X) SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2, 0); else if (mapping & POV_Y) SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2 + 1, 0); else if (mapping & SLIDER) - SendMessage(h, CB_SETCURSEL, nr_axes + nr_povs * 2 + (mapping & 3), 0); + SendMessage(h, CB_SETCURSEL, nr_axes + nr_povs * 2 + (mapping & 3), 0); else SendMessage(h, CB_SETCURSEL, mapping, 0); id += 2; - } + } for (c = 0; c < joystick_get_button_count(joystick_config_type); c++) { h = GetDlgItem(hdlg, id); @@ -243,7 +243,7 @@ joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } } return TRUE; - + case WM_COMMAND: switch (LOWORD(wParam)) { @@ -251,21 +251,21 @@ joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (HIWORD(wParam) == CBN_SELCHANGE) rebuild_axis_button_selections(hdlg); break; - + case IDOK: { id = IDC_CONFIG_BASE + 2; - + h = GetDlgItem(hdlg, IDC_CONFIG_BASE); joystick_state[joystick_nr].plat_joystick_nr = SendMessage(h, CB_GETCURSEL, 0, 0); - + if (joystick_state[joystick_nr].plat_joystick_nr) { for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++) { joystick_state[joystick_nr].axis_mapping[c] = get_axis(hdlg, id); id += 2; - } + } for (c = 0; c < joystick_get_button_count(joystick_config_type); c++) { h = GetDlgItem(hdlg, id); @@ -308,27 +308,27 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) char s[269]; joystickconfig_changed = 0; - + joystick_nr = joy_nr; joystick_config_type = type; memset(data_block, 0, 4096); - + dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU; dlg->x = 10; dlg->y = 10; dlg->cx = 220; dlg->cy = 70; - + data = (uint16_t *)(dlg + 1); - + *data++ = 0; /*no menu*/ *data++ = 0; /*predefined dialog box class*/ data += MultiByteToWideChar(CP_ACP, 0, "Joystick Configuration", -1, data, 50); *data++ = 9; /*Point*/ data += MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, data, 50); - + if (((uintptr_t)data) & 2) data++; @@ -338,7 +338,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 70; item->y = y; item->id = id++; - + item->cx = 140; item->cy = 150; @@ -350,7 +350,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, "Device", -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; @@ -359,7 +359,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 10; item->y = y + 2; item->id = id++; - + item->cx = 60; item->cy = 15; @@ -371,7 +371,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, "Device", -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; @@ -385,7 +385,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 70; item->y = y; item->id = id++; - + item->cx = 140; item->cy = 150; @@ -397,7 +397,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; @@ -406,7 +406,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 10; item->y = y + 2; item->id = id++; - + item->cx = 60; item->cy = 15; @@ -418,12 +418,12 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; y += 20; - } + } for (c = 0; c < joystick_get_button_count(type); c++) { @@ -432,7 +432,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 70; item->y = y; item->id = id++; - + item->cx = 140; item->cy = 150; @@ -444,7 +444,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; @@ -453,7 +453,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 10; item->y = y + 2; item->id = id++; - + item->cx = 60; item->cy = 15; @@ -465,13 +465,13 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; y += 20; - } - + } + for (c = 0; c < joystick_get_pov_count(type)*2; c++) { /*Combo box*/ @@ -479,7 +479,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 70; item->y = y; item->id = id++; - + item->cx = 140; item->cy = 150; @@ -495,7 +495,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) sprintf(s, "%s (X axis)", joystick_get_pov_name(type, c/2)); data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; @@ -504,7 +504,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) item->x = 10; item->y = y + 2; item->id = id++; - + item->cx = 60; item->cy = 15; @@ -516,7 +516,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256); *data++ = 0; /* no creation data */ - + if (((uintptr_t)data) & 2) data++; @@ -542,7 +542,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type) if (((uintptr_t)data) & 2) data++; - + item = (DLGITEMTEMPLATE *)data; item->x = 160; item->y = y + 5; diff --git a/src/win/win_mouse.c b/src/win/win_mouse.c index 2e91085ec..e5d1c229a 100644 --- a/src/win/win_mouse.c +++ b/src/win/win_mouse.c @@ -52,7 +52,7 @@ win_mouse_init(void) ridev.usUsagePage = 0x01; ridev.usUsage = 0x02; if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) - fatal("plat_mouse_init: RegisterRawInputDevices failed\n"); + fatal("plat_mouse_init: RegisterRawInputDevices failed\n"); memset(&mousestate, 0, sizeof(MOUSESTATE)); } @@ -85,13 +85,13 @@ win_mouse_handle(PRAWINPUT raw) if (state.usFlags & MOUSE_MOVE_ABSOLUTE) { - /* absolute mouse, i.e. RDP or VNC + /* absolute mouse, i.e. RDP or VNC * seems to work fine for RDP on Windows 10 * Not sure about other environments. */ mousestate.dx += (state.lLastX - x)/25; mousestate.dy += (state.lLastY - y)/25; - x=state.lLastX; + x=state.lLastX; y=state.lLastY; } else { /* relative mouse, i.e. regular mouse */ @@ -124,7 +124,7 @@ mouse_poll(void) mousestate.dx=0; mousestate.dy=0; mousestate.dwheel=0; - + //pclog("dx=%d, dy=%d, dwheel=%d\n", mouse_x, mouse_y, mouse_z); } diff --git a/src/win/win_new_floppy.c b/src/win/win_new_floppy.c index 0a4d0c5b6..12983bef8 100644 --- a/src/win/win_new_floppy.c +++ b/src/win/win_new_floppy.c @@ -195,7 +195,7 @@ create_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_fdi) uint32_t fat2_offs = 0; uint32_t zero_bytes = 0; uint16_t base = 0x1000; - + f = plat_fopen(file_name, "wb"); if (!f) return 0; @@ -305,7 +305,7 @@ create_zip_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_zdi, uint32_t pbar_max = 0; uint32_t i; MSG msg; - + f = plat_fopen(file_name, "wb"); if (!f) return 0; @@ -360,8 +360,8 @@ create_zip_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_zdi, SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } fwrite(&empty[0x0800], 1, 2048, f); @@ -370,8 +370,8 @@ create_zip_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_zdi, SendMessage(h, PBM_SETPOS, (WPARAM) 2, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } pbar_max -= 2; @@ -512,8 +512,8 @@ create_zip_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_zdi, SendMessage(h, PBM_SETPOS, (WPARAM) i + 2, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } } @@ -539,7 +539,7 @@ create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND h uint32_t pbar_max = 0, blocks_num; uint32_t i, j; MSG msg; - + f = plat_fopen(file_name, "wb"); if (!f) return 0; @@ -593,8 +593,8 @@ create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND h SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } fwrite(&empty[0x0800], 1, 2048, f); @@ -603,8 +603,8 @@ create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND h SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } } @@ -622,8 +622,8 @@ create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND h SendMessage(h, PBM_SETPOS, (WPARAM) i + j, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } } @@ -633,8 +633,8 @@ create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND h SendMessage(h, PBM_SETPOS, (WPARAM) pbar_max - 1, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } } diff --git a/src/win/win_opengl.c b/src/win/win_opengl.c index 9bb13561d..5670fafa2 100644 --- a/src/win/win_opengl.c +++ b/src/win/win_opengl.c @@ -7,18 +7,18 @@ * This file is part of the 86Box distribution. * * Rendering module for OpenGL - * + * * TODO: More shader features * - scaling * - multipass - * - previous frames + * - previous frames * (UI) options * More error handling - * + * * Authors: Teemu Korhonen - * + * * Copyright 2021 Teemu Korhonen - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -168,7 +168,7 @@ typedef struct /** * @brief Set or unset OpenGL context window as a child window. - * + * * Modifies the window style and sets the parent window. * WS_EX_NOACTIVATE keeps the window from stealing input focus. */ @@ -198,7 +198,7 @@ static void set_parent_binding(int enable) * @brief Windows message handler for our window. * @param message * @param wParam - * @param lParam + * @param lParam * @param fullscreen * @return Was message handled */ @@ -382,7 +382,7 @@ static int initialize_glcontext(gl_identifiers* gl) /* Create persistent buffer for pixel transfer. */ glBufferStorage(GL_PIXEL_UNPACK_BUFFER, BUFFERBYTES * BUFFERCOUNT, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); - buf_ptr = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, BUFFERBYTES * BUFFERCOUNT, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + buf_ptr = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, BUFFERBYTES * BUFFERCOUNT, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); } else { @@ -410,8 +410,8 @@ static int initialize_glcontext(gl_identifiers* gl) } /** - * @brief Clean up OpenGL context - * @param gl Identifiers from initialize + * @brief Clean up OpenGL context + * @param gl Identifiers from initialize */ static void finalize_glcontext(gl_identifiers* gl) { @@ -472,7 +472,7 @@ static void __stdcall opengl_debugmsg_callback(GLenum source, GLenum type, GLuin /** * @brief Main OpenGL thread proc. - * + * * OpenGL context should be accessed only from this single thread. * Events are used to synchronize communication. */ @@ -488,7 +488,7 @@ static void opengl_main(void* param) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - + if (GLAD_GL_ARB_debug_output && log_path[0] != '\0') SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); else @@ -515,7 +515,7 @@ static void opengl_main(void* param) pclog("OpenGL: subsystem is not SDL_SYSWM_WINDOWS.\n"); opengl_fail(); } - + window_hwnd = wmi.info.win.window; if (!fullscreen) @@ -580,7 +580,7 @@ static void opengl_main(void* param) } gl_identifiers gl = { 0 }; - + if (!initialize_glcontext(&gl)) { pclog("OpenGL: failed to initialize.\n"); @@ -616,7 +616,7 @@ static void opengl_main(void* param) uint32_t ticks = plat_get_micro_ticks(); uint32_t elapsed = ticks - last_swap; - + if (elapsed + 1000 > frametime) { /* Spin the remaining time (< 1ms) to next frame */ @@ -748,7 +748,7 @@ static void opengl_main(void* param) int width, height, pad_x = 0, pad_y = 0, px_size = 1; float ratio = 0; const float ratio43 = 4.f / 3.f; - + SDL_GetWindowSize(window, &width, &height); if (video_width > 0 && video_height > 0) @@ -919,7 +919,7 @@ int opengl_init(HWND hwnd) sync_objects.blit_waiting = CreateSemaphore(NULL, 0, BUFFERCOUNT * 2, NULL); parent = hwnd; - + RECT parent_size; GetWindowRect(parent, &parent_size); @@ -992,7 +992,7 @@ void opengl_set_fs(int fs) return; thread_wait_mutex(resize_info.mutex); - + resize_info.fullscreen = fs; resize_info.scaling_mode = video_fullscreen_scale; @@ -1026,7 +1026,7 @@ void opengl_reload(void) options.vsync = video_vsync; options.frametime = framerate_to_frametime(video_framerate); - + if (strcmp(video_shader, options.shaderfile) != 0) { strcpy_s(options.shaderfile, sizeof(options.shaderfile), video_shader); @@ -1042,4 +1042,4 @@ void opengl_reload(void) thread_release_mutex(options.mutex); SetEvent(sync_objects.reload); -} \ No newline at end of file +} diff --git a/src/win/win_opengl_glslp.c b/src/win/win_opengl_glslp.c index 0537da899..d8916bd83 100644 --- a/src/win/win_opengl_glslp.c +++ b/src/win/win_opengl_glslp.c @@ -86,9 +86,9 @@ static char* read_file_to_string(const char* path) { /* get file size */ fseek(file_handle, 0, SEEK_END); - + size_t file_size = (size_t)ftell(file_handle); - + fseek(file_handle, 0, SEEK_SET); /* read to buffer and close */ @@ -269,4 +269,4 @@ GLuint load_default_shaders() glDeleteShader(fragment_id); return prog_id; -} \ No newline at end of file +} diff --git a/src/win/win_preferences.c b/src/win/win_preferences.c index 0c3e95892..74b5a186a 100644 --- a/src/win/win_preferences.c +++ b/src/win/win_preferences.c @@ -41,7 +41,7 @@ int enum_helper, c; HWND hwndPreferences; -BOOL CALLBACK +BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) { wchar_t temp[LOCALE_NAME_MAX_LENGTH + 1]; @@ -50,11 +50,11 @@ EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLan GetLocaleInfoEx(temp, LOCALE_SENGLISHDISPLAYNAME, dispname, MAX_PATH); SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)dispname); SendMessage((HWND)lParam, CB_SETITEMDATA, c, (LPARAM)wIDLanguage); - + if (wIDLanguage == lang_id) enum_helper = c; c++; - + return 1; } @@ -63,17 +63,17 @@ static void preferences_fill_languages(HWND hdlg) { temp_language = GetThreadUILanguage(); - HWND lang_combo = GetDlgItem(hdlg, IDC_COMBO_LANG); - + HWND lang_combo = GetDlgItem(hdlg, IDC_COMBO_LANG); + SendMessage(lang_combo, CB_RESETCONTENT, 0, 0); SendMessage(lang_combo, CB_ADDSTRING, 0, win_get_string(IDS_7168)); SendMessage(lang_combo, CB_SETITEMDATA, 0, 0xFFFF); - - enum_helper = 0; c = 1; + + enum_helper = 0; c = 1; //if no one is selected, then it was 0xFFFF or unsupported language, in either case go with index enum_helper=0 //also start enum index from c=1 EnumResourceLanguages(hinstance, RT_MENU, L"MainMenu", &EnumResLangProc, (LPARAM)lang_combo); - + SendMessage(lang_combo, CB_SETCURSEL, enum_helper, 0); } @@ -81,42 +81,42 @@ preferences_fill_languages(HWND hdlg) static void preferences_fill_iconsets(HWND hdlg) { - HWND icon_combo = GetDlgItem(hdlg, IDC_COMBO_ICON); - + HWND icon_combo = GetDlgItem(hdlg, IDC_COMBO_ICON); + /* Add the default one */ wchar_t buffer[512] = L"("; wcscat(buffer, plat_get_string(IDS_2090)); wcscat(buffer, L")"); - + SendMessage(icon_combo, CB_RESETCONTENT, 0, 0); SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM)buffer); SendMessage(icon_combo, CB_SETITEMDATA, 0, (LPARAM)strdup("")); - + int combo_index = -1; - + /* Find for extra ones */ HANDLE hFind; WIN32_FIND_DATA data; - + char icon_path_root[512]; win_get_icons_path(icon_path_root); - + wchar_t search[512]; mbstoc16s(search, icon_path_root, strlen(icon_path_root) + 1); wcscat(search, L"*.*"); - + hFind = FindFirstFile((LPCWSTR)search, &data); - + if (hFind != INVALID_HANDLE_VALUE) { do { - if (wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..") && + if (wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..") && (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { wchar_t temp[512] = {0}, dispname[512] = {0}; mbstoc16s(temp, icon_path_root, strlen(icon_path_root) + 1); wcscat(temp, data.cFileName); wcscat(temp, L"\\iconinfo.txt"); - + wcscpy(dispname, data.cFileName); FILE *fp = _wfopen(temp, L"r"); if (fp) @@ -126,29 +126,29 @@ preferences_fill_iconsets(HWND hdlg) { mbstoc16s(dispname, line, strlen(line) + 1); } - + fclose(fp); } - + char filename[512]; c16stombs(filename, data.cFileName, 511); - + int index = SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM)dispname); SendMessage(icon_combo, CB_SETITEMDATA, index, (LPARAM)(strdup(filename))); - + if (!strcmp(filename, icon_set)) combo_index = index; } } while (FindNextFile(hFind, &data)); FindClose(hFind); } - + if (combo_index == -1) { combo_index = 0; strcpy(temp_icon_set, ""); } - + SendMessage(icon_combo, CB_SETCURSEL, combo_index, 0); } @@ -157,30 +157,30 @@ static int preferences_settings_changed(void) { int i = 0; - + /* Language */ i = i || has_language_changed(temp_language); i = i || strcmp(temp_icon_set, icon_set); - + return i; } /* IndexOf by ItemData */ -static int +static int preferences_indexof(HWND combo, LPARAM itemdata) { int i; for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) if (SendMessage(combo, CB_GETITEMDATA, i, 0) == itemdata) return i; - + return -1; } /* This saves the settings back to the global variables. */ static void preferences_settings_save(void) -{ +{ /* Language */ set_language(temp_language); @@ -190,13 +190,13 @@ preferences_settings_save(void) /* Update title bar */ update_mouse_msg(); - + /* Update status bar */ - config_changed = 1; + config_changed = 1; ui_sb_set_ready(-1); ui_sb_update_panes(); ui_sb_update_text(); - + /* Save the language changes */ config_save(); } @@ -220,8 +220,8 @@ PreferencesDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: switch (LOWORD(wParam)) { - case IDOK: - if (preferences_settings_changed()) + case IDOK: + if (preferences_settings_changed()) preferences_settings_save(); EndDialog(hdlg, 0); return TRUE; @@ -229,41 +229,41 @@ PreferencesDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDCANCEL: EndDialog(hdlg, 0); return TRUE; - + case IDC_COMBO_LANG: if (HIWORD(wParam) == CBN_SELCHANGE) { HWND combo = GetDlgItem(hdlg, IDC_COMBO_LANG); - int index = SendMessage(combo, CB_GETCURSEL, 0, 0); + int index = SendMessage(combo, CB_GETCURSEL, 0, 0); temp_language = SendMessage(combo, CB_GETITEMDATA, index, 0); } - break; - + break; + case IDC_COMBO_ICON: if (HIWORD(wParam) == CBN_SELCHANGE) { HWND combo = GetDlgItem(hdlg, IDC_COMBO_ICON); - int index = SendMessage(combo, CB_GETCURSEL, 0, 0); + int index = SendMessage(combo, CB_GETCURSEL, 0, 0); strcpy(temp_icon_set, (char*)SendMessage(combo, CB_GETITEMDATA, index, 0)); } - break; - + break; + case IDC_BUTTON_DEFAULT: { HWND combo = GetDlgItem(hdlg, IDC_COMBO_LANG); int index = preferences_indexof(combo, DEFAULT_LANGUAGE); - SendMessage(combo, CB_SETCURSEL, index, 0); + SendMessage(combo, CB_SETCURSEL, index, 0); temp_language = DEFAULT_LANGUAGE; - break; + break; } - + case IDC_BUTTON_DEFICON: { - SendMessage(GetDlgItem(hdlg, IDC_COMBO_ICON), CB_SETCURSEL, 0, 0); + SendMessage(GetDlgItem(hdlg, IDC_COMBO_ICON), CB_SETCURSEL, 0, 0); strcpy(temp_icon_set, ""); - break; + break; } default: break; } break; - + case WM_DESTROY: { int i; LRESULT temp; @@ -279,7 +279,7 @@ PreferencesDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } } break; - + } return(FALSE); diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 4c044c07c..dcd8d33ad 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -237,7 +237,7 @@ settings_process_messages() { MSG msg; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); + TranslateMessage(&msg); DispatchMessage(&msg); } } @@ -1710,8 +1710,8 @@ win_settings_storage_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_COMBO_FDC: temp_fdc_card = settings_list_to_fdc[settings_get_cur_sel(hdlg, IDC_COMBO_FDC)]; settings_enable_window(hdlg, IDC_CONFIGURE_FDC, fdc_card_has_config(temp_fdc_card)); - break; - + break; + case IDC_CONFIGURE_HDC: temp_hdc = settings_list_to_hdc[settings_get_cur_sel(hdlg, IDC_COMBO_HDC)]; temp_deviceconfig |= deviceconfig_open(hdlg, (void *)hdc_get_device(temp_hdc)); @@ -2427,7 +2427,7 @@ static int hdconf_initialize_hdt_combo(HWND hdlg) selection = 127; - for (i = 0; i < 127; i++) { + for (i = 0; i < 127; i++) { temp_size = ((uint64_t) hdd_table[i][0]) * hdd_table[i][1] * hdd_table[i][2]; size_mb = (uint32_t) (temp_size >> 11LL); wsprintf(szText, plat_get_string(IDS_2107), size_mb, hdd_table[i][0], hdd_table[i][1], hdd_table[i][2]); @@ -2449,7 +2449,7 @@ recalc_selection(HWND hdlg) int i = 0; selection = 127; - for (i = 0; i < 127; i++) { + for (i = 0; i < 127; i++) { if ((tracks == (int) hdd_table[i][0]) && (hpc == (int) hdd_table[i][1]) && (spt == (int) hdd_table[i][2])) @@ -2468,7 +2468,7 @@ static void vhd_progress_callback(uint32_t current_sector, uint32_t total_sector HWND h = GetDlgItem(vhd_progress_hdlg, IDC_PBAR_IMG_CREATE); SendMessage(h, PBM_SETPOS, (WPARAM) current_sector, (LPARAM) 0); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { - TranslateMessage(&msg); + TranslateMessage(&msg); DispatchMessage(&msg); } } @@ -2506,7 +2506,7 @@ static void adjust_86box_geometry_for_vhd(MVHDGeom *_86box_geometry, MVHDGeom *v static void adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry) { - if (vhd_geometry->spt <= 63) + if (vhd_geometry->spt <= 63) return; int desired_sectors = vhd_geometry->cyl * vhd_geometry->heads * vhd_geometry->spt; @@ -2636,7 +2636,7 @@ win_settings_hard_disks_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM case WM_INITDIALOG: memset(hd_file_name, 0, sizeof(hd_file_name)); - hdd_ptr = &(temp_hdd[next_free_id]); + hdd_ptr = &(temp_hdd[next_free_id]); SetWindowText(hdlg, plat_get_string((existing & 1) ? IDS_4103 : IDS_4102)); @@ -2832,7 +2832,7 @@ win_settings_hard_disks_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM hdd_ptr->tracks = _86box_geometry.cyl; hdd_ptr->hpc = _86box_geometry.heads; - hdd_ptr->spt = _86box_geometry.spt; + hdd_ptr->spt = _86box_geometry.spt; hard_disk_added = 1; EndDialog(hdlg, 0); @@ -3300,10 +3300,10 @@ hdd_add_file_open_error: settings_enable_window(hdlg, IDC_EDIT_HD_SIZE, TRUE); set_edit_box_contents(hdlg, IDC_EDIT_HD_SIZE, (uint32_t) ((uint64_t)17 * 15 * 1023 * 512 >> 20)); size = (uint64_t)17 * 15 * 1023 * 512; - + settings_reset_content(hdlg, IDC_COMBO_HD_TYPE); hdconf_initialize_hdt_combo(hdlg); - settings_enable_window(hdlg, IDC_COMBO_HD_TYPE, TRUE); + settings_enable_window(hdlg, IDC_COMBO_HD_TYPE, TRUE); } } no_update = 0; @@ -3671,7 +3671,7 @@ win_settings_mo_drives_recalc_list(HWND hdlg) for (i = 0; i < MO_NUM; i++) { fsid = combo_id_to_format_string_id(temp_mo_drives[i].bus_type); - + lvI.iSubItem = 0; switch (temp_mo_drives[i].bus_type) { case MO_BUS_DISABLED: diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index bf2830456..406ae4f0f 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -482,7 +482,7 @@ StatusBarDestroyTips(void) /* API: mark the status bar as not ready. */ /* Values: -1 - not ready, but don't clear POST text - 0 - not ready + 0 - not ready 1 - ready */ void ui_sb_set_ready(int ready) @@ -494,7 +494,7 @@ ui_sb_set_ready(int ready) if (ready == -1) ready = 0; - + sb_ready = ready; } @@ -709,7 +709,7 @@ ui_sb_update_panes(void) sb_map[SB_MO | i] = sb_parts; sb_parts++; } - } + } if (c_mfm && (mfm_int || !memcmp(hdc_name, "st506", 5))) { edge += icon_width; iStatusWidths[sb_parts] = edge; @@ -803,8 +803,8 @@ ui_sb_update_panes(void) sb_part_icons[i] |= 48; StatusBarCreateZIPTip(i); break; - - case SB_MO: /* Magneto-Optical disk */ + + case SB_MO: /* Magneto-Optical disk */ sb_part_icons[i] = (strlen(mo_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 128 : 0; sb_part_icons[i] |= 56; StatusBarCreateMOTip(i); @@ -979,7 +979,7 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) /* Create the window, and make sure it's using the STATUS class. */ hwndSBAR = CreateWindowEx(0, - STATUSCLASSNAME, + STATUSCLASSNAME, (LPCTSTR)NULL, SBARS_SIZEGRIP|WS_CHILD|WS_VISIBLE|SBT_TOOLTIPS, 0, dh-17, dw, 17, diff --git a/src/win/win_thread.c b/src/win/win_thread.c index 5a0fc4be8..2bb8a6cf5 100644 --- a/src/win/win_thread.c +++ b/src/win/win_thread.c @@ -121,7 +121,7 @@ thread_destroy_event(event_t *arg) mutex_t * thread_create_mutex(void) -{ +{ mutex_t *mutex = malloc(sizeof(CRITICAL_SECTION)); InitializeCriticalSection(mutex); diff --git a/src/win/win_toolbar.c b/src/win/win_toolbar.c index a0291672f..e3480bc06 100644 --- a/src/win/win_toolbar.c +++ b/src/win/win_toolbar.c @@ -62,23 +62,23 @@ ToolBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_NOTIFY: switch (((LPNMHDR) lParam)->code) { - case TTN_GETDISPINFO: { - LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam; - + case TTN_GETDISPINFO: { + LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam; + // Set the instance of the module that contains the resource. lpttt->hinst = hinstance; - + uintptr_t idButton = lpttt->hdr.idFrom; - - switch (idButton) { + + switch (idButton) { case IDM_ACTION_PAUSE: if (dopause) lpttt->lpszText = MAKEINTRESOURCE(IDS_2154); else lpttt->lpszText = MAKEINTRESOURCE(IDS_2155); - break; - - case IDM_ACTION_RESET_CAD: + break; + + case IDM_ACTION_RESET_CAD: lpttt->lpszText = MAKEINTRESOURCE(IDS_2156); break; @@ -89,14 +89,14 @@ ToolBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_ACTION_HRESET: lpttt->lpszText = MAKEINTRESOURCE(IDS_2158); break; - - case IDM_CONFIG: + + case IDM_CONFIG: lpttt->lpszText = MAKEINTRESOURCE(IDS_2160); - break; + break; } - - return TRUE; - } + + return TRUE; + } } } @@ -141,7 +141,7 @@ ToolBarCreate(HWND hwndParent, HINSTANCE hInst) WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | - CCS_NOPARENTALIGN | CCS_NORESIZE | + CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER, 0, 0, 0, 0, hwndParent, NULL, hInst, NULL); @@ -164,7 +164,7 @@ ToolBarCreate(HWND hwndParent, HINSTANCE hInst) // Create the containing Rebar. hwndRebar = CreateWindowEx(0, REBARCLASSNAME, NULL, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT | CCS_NODIVIDER | CCS_NOPARENTALIGN, 0, 0, scrnsz_x, 0, diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 2070616a0..1a9ad961a 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -205,13 +205,13 @@ show_render_options_menu() { if (vid_api == menu_vidapi) return; - + if (cur_menu != NULL) { if (delete_submenu(menuMain, cur_menu)) cur_menu = NULL; } - + if (cur_menu == NULL) { switch (IDM_VID_SDL_SW + vid_api) @@ -235,7 +235,7 @@ show_render_options_menu() } static void -video_set_filter_menu(HMENU menu) +video_set_filter_menu(HMENU menu) { CheckMenuItem(menu, IDM_VID_FILTER_NEAREST, vid_api == 0 || video_filter_method == 0 ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(menu, IDM_VID_FILTER_LINEAR, vid_api != 0 && video_filter_method == 1 ? MF_CHECKED : MF_UNCHECKED); @@ -262,7 +262,7 @@ ResetAllMenus(void) CheckMenuItem(menuMain, IDM_VID_SDL_HW, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_SDL_OPENGL, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_OPENGL_CORE, MF_UNCHECKED); - + menu_vidapi = -1; cur_menu = NULL; show_render_options_menu(); @@ -750,7 +750,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_VID_FILTER_NEAREST: - case IDM_VID_FILTER_LINEAR: + case IDM_VID_FILTER_LINEAR: video_filter_method = LOWORD(wParam) - IDM_VID_FILTER_NEAREST; video_set_filter_menu(hmenu); plat_vid_reload_options(); @@ -763,7 +763,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) atomic_flag_clear(&doresize); config_save(); break; - + case IDM_PREFERENCES: PreferencesDlgCreate(hwnd); break; @@ -1331,7 +1331,7 @@ ui_init(int nCmdShow) helper_lang = lang_id; lang_id = 0; set_language(helper_lang); - + /* Make the window visible on the screen. */ ShowWindow(hwnd, nCmdShow);