From 984bfc8ad1ed19a1497dbd30b8957ab0afc98c66 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 00:45:20 -0300 Subject: [PATCH 01/28] Implement dynamic MTRRs --- src/cpu_common/cpu.c | 51 ++++-- src/cpu_common/cpu.h | 1 + src/cpu_common/x86_ops_misc.h | 2 + src/include/86box/mem.h | 4 + src/mem.c | 298 ++++++++++++++++++++++++++++++++-- 5 files changed, 328 insertions(+), 28 deletions(-) diff --git a/src/cpu_common/cpu.c b/src/cpu_common/cpu.c index 5005fd5e4..2eb9817bc 100644 --- a/src/cpu_common/cpu.c +++ b/src/cpu_common/cpu.c @@ -2854,7 +2854,7 @@ i686_invalid_rdmsr: void cpu_WRMSR() { - uint64_t temp; + uint64_t temp, temp2; cpu_log("WRMSR %08X %08X%08X\n", ECX, EDX, EAX); switch (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type) @@ -2923,10 +2923,23 @@ void cpu_WRMSR() break; case 0x200: case 0x201: case 0x202: case 0x203: case 0x204: case 0x205: case 0x206: case 0x207: case 0x208: case 0x209: case 0x20A: case 0x20B: case 0x20C: case 0x20D: case 0x20E: case 0x20F: - if (ECX & 1) - mtrr_physmask_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); - else - mtrr_physbase_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); + temp = EAX | ((uint64_t)EDX << 32); + temp2 = (ECX - 0x200) >> 1; + if (ECX & 1) { + cpu_log("MTRR physmask[%d] = %08llx\n", temp2, temp); + + if ((mtrr_physmask_msr[temp2] >> 11) & 0x1) + mem_del_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), mtrr_physmask_msr[temp2] & ~(0xFFF)); + + if ((temp >> 11) & 0x1) + mem_add_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), temp & ~(0xFFF), mtrr_physbase_msr[temp2] & 0xFF); + + mtrr_physmask_msr[temp2] = temp; + } else { + cpu_log("MTRR physbase[%d] = %08llx\n", temp2, temp); + + mtrr_physbase_msr[temp2] = temp; + } break; case 0x250: mtrr_fix64k_8000_msr = EAX | ((uint64_t)EDX << 32); @@ -3222,11 +3235,24 @@ void cpu_WRMSR() break; case 0x200: case 0x201: case 0x202: case 0x203: case 0x204: case 0x205: case 0x206: case 0x207: case 0x208: case 0x209: case 0x20A: case 0x20B: case 0x20C: case 0x20D: case 0x20E: case 0x20F: - if (ECX & 1) - mtrr_physmask_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); - else - mtrr_physbase_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); - break; + temp = EAX | ((uint64_t)EDX << 32); + temp2 = (ECX - 0x200) >> 1; + if (ECX & 1) { + cpu_log("MTRR physmask[%d] = %08llx\n", temp2, temp); + + if ((mtrr_physmask_msr[temp2] >> 11) & 0x1) + mem_del_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), mtrr_physmask_msr[temp2] & ~(0xFFF)); + + if ((temp >> 11) & 0x1) + mem_add_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), temp & ~(0xFFF), mtrr_physbase_msr[temp2] & 0xFF); + + mtrr_physmask_msr[temp2] = temp; + } else { + cpu_log("MTRR physbase[%d] = %08llx\n", temp2, temp); + + mtrr_physbase_msr[temp2] = temp; + } + break; case 0x250: mtrr_fix64k_8000_msr = EAX | ((uint64_t)EDX << 32); break; @@ -3258,6 +3284,11 @@ i686_invalid_wrmsr: } } +void cpu_INVD(uint8_t wb) +{ + mem_invalidate_mtrr(wb); +} + static int cyrix_addr; static void cpu_write(uint16_t addr, uint8_t val, void *priv) diff --git a/src/cpu_common/cpu.h b/src/cpu_common/cpu.h index 106815688..403457f60 100644 --- a/src/cpu_common/cpu.h +++ b/src/cpu_common/cpu.h @@ -515,6 +515,7 @@ extern void cpu_set(void); extern void cpu_CPUID(void); extern void cpu_RDMSR(void); extern void cpu_WRMSR(void); +extern void cpu_INVD(uint8_t wb); extern int checkio(int port); extern void codegen_block_end(void); diff --git a/src/cpu_common/x86_ops_misc.h b/src/cpu_common/x86_ops_misc.h index 16a628fd1..a5659595f 100644 --- a/src/cpu_common/x86_ops_misc.h +++ b/src/cpu_common/x86_ops_misc.h @@ -743,12 +743,14 @@ static int opCLTS(uint32_t fetchdat) static int opINVD(uint32_t fetchdat) { + cpu_INVD(0); CLOCK_CYCLES(1000); CPU_BLOCK_END(); return 0; } static int opWBINVD(uint32_t fetchdat) { + cpu_INVD(1); CLOCK_CYCLES(10000); CPU_BLOCK_END(); return 0; diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 429d98652..4a89f252c 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -330,6 +330,10 @@ extern void mem_init(void); extern void mem_reset(void); extern void mem_remap_top(int kb); +extern void mem_add_mtrr(uint64_t base, uint64_t mask, uint8_t type); +extern void mem_del_mtrr(uint64_t base, uint64_t mask); +extern void mem_invalidate_mtrr(uint8_t wb); + #ifdef EMU_CPU_H static __inline uint32_t get_phys(uint32_t addr) diff --git a/src/mem.c b/src/mem.c index 459f7f6e6..27335fb70 100644 --- a/src/mem.c +++ b/src/mem.c @@ -121,6 +121,8 @@ static mem_mapping_t *read_mapping[MEM_MAPPINGS_NO]; static mem_mapping_t *write_mapping[MEM_MAPPINGS_NO]; static uint8_t *_mem_exec[MEM_MAPPINGS_NO]; static int _mem_state[MEM_MAPPINGS_NO]; +static uint8_t *mtrr_areas[MEM_MAPPINGS_NO]; +static uint8_t mtrr_area_refcounts[MEM_MAPPINGS_NO]; #if FIXME #if (MEM_GRANULARITY_BITS >= 12) @@ -650,6 +652,8 @@ uint8_t readmembl(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -663,7 +667,12 @@ readmembl(uint32_t addr) } addr = (uint32_t) (addr64 & rammask); - map = read_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) + return mtrr[addr & MEM_GRANULARITY_MASK]; + + map = read_mapping[page]; if (map && map->read_b) return map->read_b(addr, map->p); @@ -675,6 +684,8 @@ void writemembl(uint32_t addr, uint8_t val) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -692,7 +703,14 @@ writemembl(uint32_t addr, uint8_t val) } addr = (uint32_t) (addr64 & rammask); - map = write_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) { + mtrr[addr & MEM_GRANULARITY_MASK] = val; + return; + } + + map = write_mapping[page]; if (map && map->write_b) map->write_b(addr, val, map->p); } @@ -703,6 +721,8 @@ uint16_t readmemwl(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -731,7 +751,12 @@ readmemwl(uint32_t addr) addr = (uint32_t) (addr64 & rammask); - map = read_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) + return mtrr[addr & MEM_GRANULARITY_MASK] | ((uint16_t) (mtrr[(addr + 1) & MEM_GRANULARITY_MASK]) << 8); + + map = read_mapping[page]; if (map && map->read_w) return map->read_w(addr, map->p); @@ -747,6 +772,8 @@ void writememwl(uint32_t addr, uint16_t val) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -784,7 +811,15 @@ writememwl(uint32_t addr, uint16_t val) addr = (uint32_t) (addr64 & rammask); - map = write_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) { + mtrr[addr & MEM_GRANULARITY_MASK] = val; + mtrr[(addr + 1) & MEM_GRANULARITY_MASK] = val >> 8; + return; + } + + map = write_mapping[page]; if (map) { if (map->write_w) map->write_w(addr, val, map->p); @@ -800,6 +835,8 @@ uint32_t readmemll(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -829,7 +866,12 @@ readmemll(uint32_t addr) addr = (uint32_t) (addr64 & rammask); - map = read_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) + return mtrr[addr & MEM_GRANULARITY_MASK] | ((uint32_t) (mtrr[(addr + 1) & MEM_GRANULARITY_MASK]) << 8) | ((uint32_t) (mtrr[(addr + 2) & MEM_GRANULARITY_MASK]) << 16) | ((uint32_t) (mtrr[(addr + 3) & MEM_GRANULARITY_MASK]) << 24); + + map = read_mapping[page]; if (map) { if (map->read_l) return map->read_l(addr, map->p); @@ -850,6 +892,8 @@ void writememll(uint32_t addr, uint32_t val) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -886,7 +930,17 @@ writememll(uint32_t addr, uint32_t val) addr = (uint32_t) (addr64 & rammask); - map = write_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) { + mtrr[addr & MEM_GRANULARITY_MASK] = val; + mtrr[(addr + 1) & MEM_GRANULARITY_MASK] = val >> 8; + mtrr[(addr + 2) & MEM_GRANULARITY_MASK] = val >> 16; + mtrr[(addr + 3) & MEM_GRANULARITY_MASK] = val >> 24; + return; + } + + map = write_mapping[page]; if (map) { if (map->write_l) map->write_l(addr, val, map->p); @@ -907,6 +961,8 @@ uint64_t readmemql(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -935,7 +991,12 @@ readmemql(uint32_t addr) addr = (uint32_t) (addr64 & rammask); - map = read_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) + return readmemll(addr) | ((uint64_t)readmemll(addr+4)<<32); + + map = read_mapping[page]; if (map && map->read_l) return map->read_l(addr, map->p) | ((uint64_t)map->read_l(addr + 4, map->p) << 32); @@ -947,6 +1008,8 @@ void writememql(uint32_t addr, uint64_t val) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -983,7 +1046,21 @@ writememql(uint32_t addr, uint64_t val) addr = (uint32_t) (addr64 & rammask); - map = write_mapping[addr >> MEM_GRANULARITY_BITS]; + page = (addr >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) { + mtrr[addr & MEM_GRANULARITY_MASK] = val; + mtrr[(addr + 1) & MEM_GRANULARITY_MASK] = val >> 8; + mtrr[(addr + 2) & MEM_GRANULARITY_MASK] = val >> 16; + mtrr[(addr + 3) & MEM_GRANULARITY_MASK] = val >> 24; + mtrr[(addr + 4) & MEM_GRANULARITY_MASK] = val >> 32; + mtrr[(addr + 5) & MEM_GRANULARITY_MASK] = val >> 40; + mtrr[(addr + 6) & MEM_GRANULARITY_MASK] = val >> 48; + mtrr[(addr + 7) & MEM_GRANULARITY_MASK] = val >> 56; + return; + } + + map = write_mapping[page]; if (map) { if (map->write_l) { map->write_l(addr, val, map->p); @@ -1024,6 +1101,8 @@ uint16_t readmemwl(uint32_t seg, uint32_t addr) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1055,7 +1134,12 @@ readmemwl(uint32_t seg, uint32_t addr) addr2 = (uint32_t) (addr64 & rammask); - map = read_mapping[addr2 >> MEM_GRANULARITY_BITS]; + page = (addr2 >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) + return mtrr[addr2 & MEM_GRANULARITY_MASK] | ((uint16_t) (mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK]) << 8); + + map = read_mapping[page]; if (map && map->read_w) return map->read_w(addr2, map->p); @@ -1077,6 +1161,8 @@ void writememwl(uint32_t seg, uint32_t addr, uint16_t val) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1118,7 +1204,15 @@ writememwl(uint32_t seg, uint32_t addr, uint16_t val) addr2 = (uint32_t) (addr64 & rammask); - map = write_mapping[addr2 >> MEM_GRANULARITY_BITS]; + page = (addr2 >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) { + mtrr[addr2 & MEM_GRANULARITY_MASK] = val; + mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK] = val >> 8; + return; + } + + map = write_mapping[page]; if (map && map->write_w) { map->write_w(addr2, val, map->p); @@ -1137,6 +1231,8 @@ uint32_t readmemll(uint32_t seg, uint32_t addr) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1164,7 +1260,12 @@ readmemll(uint32_t seg, uint32_t addr) addr2 = (uint32_t) (addr64 & rammask); - map = read_mapping[addr2 >> MEM_GRANULARITY_BITS]; + page = (addr2 >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) + return mtrr[addr2 & MEM_GRANULARITY_MASK] | ((uint32_t) (mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK]) << 8) | ((uint32_t) (mtrr[(addr2 + 2) & MEM_GRANULARITY_MASK]) << 16) | ((uint32_t) (mtrr[(addr2 + 3) & MEM_GRANULARITY_MASK]) << 24); + + map = read_mapping[page]; if (map && map->read_l) return map->read_l(addr2, map->p); @@ -1187,6 +1288,8 @@ void writememll(uint32_t seg, uint32_t addr, uint32_t val) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1223,7 +1326,17 @@ writememll(uint32_t seg, uint32_t addr, uint32_t val) addr2 = (uint32_t) (addr64 & rammask); - map = write_mapping[addr2 >> MEM_GRANULARITY_BITS]; + page = (addr2 >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) { + mtrr[addr2 & MEM_GRANULARITY_MASK] = val; + mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK] = val >> 8; + mtrr[(addr2 + 2) & MEM_GRANULARITY_MASK] = val >> 16; + mtrr[(addr2 + 3) & MEM_GRANULARITY_MASK] = val >> 24; + return; + } + + map = write_mapping[page]; if (map && map->write_l) { map->write_l(addr2, val, map->p); @@ -1248,6 +1361,8 @@ uint64_t readmemql(uint32_t seg, uint32_t addr) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1274,7 +1389,12 @@ readmemql(uint32_t seg, uint32_t addr) addr2 = (uint32_t) (addr64 & rammask); - map = read_mapping[addr2 >> MEM_GRANULARITY_BITS]; + page = (addr2 >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) + return readmemll(seg,addr) | ((uint64_t)readmemll(seg,addr+4)<<32); + + map = read_mapping[page]; if (map && map->read_l) return map->read_l(addr2, map->p) | ((uint64_t)map->read_l(addr2 + 4, map->p) << 32); @@ -1286,6 +1406,8 @@ void writememql(uint32_t seg, uint32_t addr, uint64_t val) { uint64_t addr64 = (uint64_t) addr; + uint32_t page; + uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1322,7 +1444,21 @@ writememql(uint32_t seg, uint32_t addr, uint64_t val) addr2 = (uint32_t) (addr64 & rammask); - map = write_mapping[addr2 >> MEM_GRANULARITY_BITS]; + page = (addr2 >> MEM_GRANULARITY_BITS); + mtrr = mtrr_areas[page]; + if (mtrr) { + mtrr[addr2 & MEM_GRANULARITY_MASK] = val; + mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK] = val >> 8; + mtrr[(addr2 + 2) & MEM_GRANULARITY_MASK] = val >> 16; + mtrr[(addr2 + 3) & MEM_GRANULARITY_MASK] = val >> 24; + mtrr[(addr2 + 4) & MEM_GRANULARITY_MASK] = val >> 32; + mtrr[(addr2 + 5) & MEM_GRANULARITY_MASK] = val >> 40; + mtrr[(addr2 + 6) & MEM_GRANULARITY_MASK] = val >> 48; + mtrr[(addr2 + 7) & MEM_GRANULARITY_MASK] = val >> 56; + return; + } + + map = write_mapping[page]; if (map && map->write_l) { map->write_l(addr2, val, map->p); @@ -2320,20 +2456,29 @@ mem_log("MEM: reset: new pages=%08lx, pages_sz=%i\n", pages, pages_sz); memset(pages, 0x00, pages_sz*sizeof(page_t)); + for (c = 0; c < MEM_MAPPINGS_NO; c++) { + if (mtrr_areas[c]) { + free(mtrr_areas[c]); + mtrr_areas[c] = 0; + } + mtrr_area_refcounts[c] = 0; + } + #ifdef USE_NEW_DYNAREC if (byte_dirty_mask) { free(byte_dirty_mask); byte_dirty_mask = NULL; } - byte_dirty_mask = malloc((mem_size * 1024) / 8); - memset(byte_dirty_mask, 0, (mem_size * 1024) / 8); + //if (m != 256) fatal("bdm %d\n", ((uint64_t) pages_sz * 4096) / 8); + byte_dirty_mask = malloc(((uint64_t) pages_sz * 4096) / 8); + memset(byte_dirty_mask, 0, ((uint64_t) pages_sz * 4096) / 8); if (byte_code_present_mask) { free(byte_code_present_mask); byte_code_present_mask = NULL; } - byte_code_present_mask = malloc((mem_size * 1024) / 8); - memset(byte_code_present_mask, 0, (mem_size * 1024) / 8); + byte_code_present_mask = malloc(((uint64_t) pages_sz * 4096) / 8); + memset(byte_code_present_mask, 0, ((uint64_t) pages_sz * 4096) / 8); #endif for (c = 0; c < pages_sz; c++) { @@ -2436,6 +2581,8 @@ mem_init(void) writelookup2 = malloc((1<<20)*sizeof(uintptr_t)); #endif + memset(mtrr_areas, 0x00, MEM_MAPPINGS_NO*sizeof(uint8_t *)); + #if FIXME memset(ff_array, 0xff, sizeof(ff_array)); #endif @@ -2533,3 +2680,118 @@ mem_a20_recalc(void) mem_a20_state = state; } + + +void +mem_add_mtrr(uint64_t base, uint64_t mask, uint8_t type) +{ + uint64_t size = ((~mask) & 0xffffffff) + 1; + uint64_t page_base, page, addr; + uint8_t *mtrr; + + mem_log("Adding MTRR base=%08llx mask=%08llx size=%08llx type=%d\n", base, mask, size, type); + + if (size > 0x8000) { + mem_log("Ignoring MTRR, size too big\n"); + return; + } + + if (mem_addr_is_ram(base)) { + mem_log("Ignoring MTRR, base is in RAM\n"); + return; + } + + for (page_base = base; page_base < base + size; page_base += MEM_GRANULARITY_SIZE) { + page = (page_base >> MEM_GRANULARITY_BITS); + if (mtrr_areas[page]) { + /* area already allocated, increase refcount and don't allocate it again */ + mtrr_area_refcounts[page]++; + continue; + } + + /* allocate area */ + mtrr = malloc(MEM_GRANULARITY_SIZE); + if (!mtrr) + fatal("Failed to allocate page for MTRR page %08llx (errno=%d)\n", page_base, errno); + + + /* populate area with data from RAM */ + for (addr = 0; addr < MEM_GRANULARITY_SIZE; addr++) { + mtrr[addr] = readmembl(page_base | addr); + } + + /* enable area */ + mtrr_areas[page] = mtrr; + } +} + + +void +mem_del_mtrr(uint64_t base, uint64_t mask) +{ + uint64_t size = ((~mask) & 0xffffffff) + 1; + uint64_t page_base, page; + + mem_log("Deleting MTRR base=%08llx mask=%08llx size=%08llx\n", base, mask, size); + + if (size > 0x8000) { + mem_log("Ignoring MTRR, size too big\n"); + return; + } + + if (mem_addr_is_ram(base)) { + mem_log("Ignoring MTRR, base is in RAM\n"); + return; + } + + for (page_base = base; page_base < base + size; page_base += MEM_GRANULARITY_SIZE) { + page = (page_base >> MEM_GRANULARITY_BITS); + if (mtrr_areas[page]) { + /* decrease reference count */ + if (mtrr_area_refcounts[page] > 0) + mtrr_area_refcounts[page]--; + + /* if no references are left, de-allocate area */ + if (mtrr_area_refcounts[page] == 0) { + free(mtrr_areas[page]); + mtrr_areas[page] = 0; + } + } + } +} + + +void +mem_invalidate_mtrr(uint8_t wb) +{ + uint64_t page, page_base, addr; + uint8_t *mtrr; + + mem_log("Invalidating cache (writeback=%d)\n", wb); + for (page = 0; page < MEM_MAPPINGS_NO; page++) { + mtrr = mtrr_areas[page]; + if (mtrr) { + page_base = (page << MEM_GRANULARITY_BITS); + if (!mem_addr_is_ram(page_base)) + continue; /* don't invalidate pages not backed by RAM */ + + /* temporarily set area aside */ + mtrr_areas[page] = 0; + + /* write data back to memory if requested */ + if (wb && write_mapping[page]) { /* don't write back to a page which can't be written to */ + for (addr = 0; addr < MEM_GRANULARITY_SIZE; addr++) { + writemembl(page_base | addr, mtrr[addr]); + } + } + + /* re-populate area with data from memory */ + for (addr = 0; addr < MEM_GRANULARITY_SIZE; addr++) { + mtrr[addr] = readmembl(page_base | addr); + } + + /* re-enable area */ + mtrr_areas[page] = mtrr; + } + } +} From 9db4beeffcb56b6172bf8f002b4d63422d35f5e1 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 00:46:02 -0300 Subject: [PATCH 02/28] Add P2B-LS and P3B-F coreboot boards --- src/machine/m_at_slot1.c | 16 ++++++++++++---- src/machine/machine_table.c | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index 800768ce8..b560654e0 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -105,8 +105,12 @@ machine_at_p2bls_init(const machine_t *model) { int ret; - ret = bios_load_linear(L"roms/machines/p2bls/1014ls.003", - 0x000c0000, 262144, 0); + if (strstr(model->internal_name, "_cb")) + ret = bios_load_linear(L"roms/machines/p2bls/coreboot.rom", + 0x000c0000, 262144, 0); + else + ret = bios_load_linear(L"roms/machines/p2bls/1014ls.003", + 0x000c0000, 262144, 0); if (bios_only || !ret) return ret; @@ -165,8 +169,12 @@ machine_at_p3bf_init(const machine_t *model) { int ret; - ret = bios_load_linear(L"roms/machines/p3bf/bx3f1006.awd", - 0x000c0000, 262144, 0); + if (strstr(model->internal_name, "_cb")) + ret = bios_load_linear(L"roms/machines/p3bf/coreboot.rom", + 0x000c0000, 262144, 0); + else + ret = bios_load_linear(L"roms/machines/p3bf/bx3f1006.awd", + 0x000c0000, 262144, 0); if (bios_only || !ret) return ret; diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 903f2bbe7..796429ccf 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -270,7 +270,9 @@ const machine_t machines[] = { { "[Slot 1 BX] Gigabyte GA-6BXC", "6bxc", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_6bxc_init, NULL }, { "[Slot 1 BX] ASUS P2B-LS", "p2bls", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, + { "[Slot 1 BX] ASUS P2B-LS (coreboot BIOS)","p2bls_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, { "[Slot 1 BX] ASUS P3B-F", "p3bf", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, + { "[Slot 1 BX] ASUS P3B-F (coreboot BIOS)", "p3bf_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, { "[Slot 1 BX] ABit BF6", "bf6", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_bf6_init, NULL }, { "[Slot 1 ZX] Packard Bell Bora Pro", "borapro", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 255, machine_at_borapro_init, NULL }, From d913c7f768bc25841a8417623b8cd117715f52d2 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 00:48:49 -0300 Subject: [PATCH 03/28] "Fix" the SPD manufacture date - most tools interpret it as 8-bit integers instead of hex-encoded decimal values. --- src/spd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spd.c b/src/spd.c index ed09c17f9..9de74836c 100644 --- a/src/spd.c +++ b/src/spd.c @@ -271,8 +271,8 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) sprintf(sdram_data->part_no, "86Box-SDR-%03dM", vslots[vslot]); for (i = strlen(sdram_data->part_no); i < sizeof(sdram_data->part_no); i++) sdram_data->part_no[i] = ' '; - sdram_data->mfg_year = 0x20; - sdram_data->mfg_week = 0x13; + sdram_data->mfg_year = 20; + sdram_data->mfg_week = 13; sdram_data->freq = 100; sdram_data->features = 0xFF; From be21301fdfa82fe2f53a58f9f2ef9690f7f8a2d2 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 14:36:00 -0300 Subject: [PATCH 04/28] Give coreboot machines their own flag --- src/include/86box/machine.h | 2 ++ src/machine/m_at_slot1.c | 4 ++-- src/machine/machine_table.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 8a3febc15..e765d6df7 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -39,6 +39,7 @@ #define MACHINE_VIDEO_FIXED 0x004000 /* sys has ONLY int video */ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_NONMI 0x010000 /* sys does not have NMI's */ +#define MACHINE_COREBOOT 0x020000 /* sys has coreboot BIOS */ #else #define MACHINE_PC 0x000000 /* PC architecture */ #define MACHINE_AT 0x000001 /* PC/AT architecture */ @@ -55,6 +56,7 @@ #define MACHINE_VIDEO_FIXED 0x004000 /* sys has ONLY int video */ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_NONMI 0x010000 /* sys does not have NMI's */ +#define MACHINE_COREBOOT 0x020000 /* sys has coreboot BIOS */ #endif #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index b560654e0..3c7d60e3d 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -105,7 +105,7 @@ machine_at_p2bls_init(const machine_t *model) { int ret; - if (strstr(model->internal_name, "_cb")) + if (model->flags & MACHINE_COREBOOT) ret = bios_load_linear(L"roms/machines/p2bls/coreboot.rom", 0x000c0000, 262144, 0); else @@ -169,7 +169,7 @@ machine_at_p3bf_init(const machine_t *model) { int ret; - if (strstr(model->internal_name, "_cb")) + if (model->flags & MACHINE_COREBOOT) ret = bios_load_linear(L"roms/machines/p3bf/coreboot.rom", 0x000c0000, 262144, 0); else diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 796429ccf..33fdb8fac 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -270,9 +270,9 @@ const machine_t machines[] = { { "[Slot 1 BX] Gigabyte GA-6BXC", "6bxc", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_6bxc_init, NULL }, { "[Slot 1 BX] ASUS P2B-LS", "p2bls", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, - { "[Slot 1 BX] ASUS P2B-LS (coreboot BIOS)","p2bls_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, + { "[Slot 1 BX] ASUS P2B-LS (coreboot BIOS)","p2bls_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_COREBOOT, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, { "[Slot 1 BX] ASUS P3B-F", "p3bf", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, - { "[Slot 1 BX] ASUS P3B-F (coreboot BIOS)", "p3bf_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, + { "[Slot 1 BX] ASUS P3B-F (coreboot BIOS)", "p3bf_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_COREBOOT, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, { "[Slot 1 BX] ABit BF6", "bf6", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_bf6_init, NULL }, { "[Slot 1 ZX] Packard Bell Bora Pro", "borapro", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 255, machine_at_borapro_init, NULL }, From f98dc1f79469dca98c6ff666ce6a5ba0fe280ad7 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 14:43:46 -0300 Subject: [PATCH 05/28] Sync floppy drive types to CMOS on coreboot machines --- src/floppy/fdd.c | 7 ++++++ src/include/86box/fdd.h | 1 + src/nvr_at.c | 49 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index 791c82abd..a2a5342af 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -407,6 +407,13 @@ fdd_is_dd(int drive) } +int +fdd_is_hd(int drive) +{ + return drive_types[fdd[drive].type].flags & FLAG_HOLE1; +} + + int fdd_is_ed(int drive) { diff --git a/src/include/86box/fdd.h b/src/include/86box/fdd.h index b486b617d..ccd420924 100644 --- a/src/include/86box/fdd.h +++ b/src/include/86box/fdd.h @@ -43,6 +43,7 @@ extern int fdd_can_read_medium(int drive); extern int fdd_doublestep_40(int drive); extern int fdd_is_525(int drive); extern int fdd_is_dd(int drive); +extern int fdd_is_hd(int drive); extern int fdd_is_ed(int drive); extern int fdd_is_double_sided(int drive); extern void fdd_set_head(int drive, int head); diff --git a/src/nvr_at.c b/src/nvr_at.c index d95a6d7c0..403fc62f7 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -237,6 +237,7 @@ #include <86box/rom.h> #include <86box/device.h> #include <86box/nvr.h> +#include <86box/fdd.h> /* RTC registers and bit definitions. */ @@ -279,6 +280,8 @@ # define REGC_UF 0x10 #define RTC_REGD 13 # define REGD_VRT 0x80 +#define RTC_FDD_TYPES 0x10 +#define RTC_INST_EQUIP 0x14 #define RTC_CENTURY_AT 0x32 /* century register for AT etc */ #define RTC_CENTURY_PS 0x37 /* century register for PS/1 PS/2 */ #define RTC_ALDAY 0x7D /* VIA VT82C586B - alarm day */ @@ -753,7 +756,7 @@ nvr_reset(nvr_t *nvr) static void nvr_start(nvr_t *nvr) { - int i; + int i, fdd; local_t *local = (local_t *) nvr->data; struct tm tm; @@ -768,6 +771,50 @@ nvr_start(nvr_t *nvr) nvr->regs[0x0e] = 0xff; /* If load failed or it loaded an uninitialized NVR, mark everything as bad. */ + if (machines[machine].flags & MACHINE_COREBOOT) { + /* Sync floppy drive types on coreboot machines, as SeaBIOS lacks a setup + utility and just leaves these untouched. */ + + nvr->regs[RTC_FDD_TYPES] = 0x00; + nvr->regs[RTC_INST_EQUIP] |= 0xc0; + + for (i = 0; i <= 1; i++) { + fdd = fdd_get_type(i); + if (fdd) { + if (fdd_is_525(i)) { + if (fdd_is_hd(i)) + fdd = 2; + else if (fdd_doublestep_40(i)) + fdd = 3; + else + fdd = 1; + } else { + if (fdd_is_hd(i)) + fdd = 4; + else if (fdd_is_double_sided(i)) + fdd = 3; + else + fdd = 1; + } + + nvr->regs[RTC_FDD_TYPES] |= (fdd << ((1 - i) * 4)); + nvr->regs[RTC_INST_EQUIP] &= 0x3f; /* At least one drive installed. */ + } + } + + if ((nvr->regs[RTC_FDD_TYPES] >> 4) && (nvr->regs[RTC_FDD_TYPES] & 0xf)) + nvr->regs[RTC_INST_EQUIP] |= 0x40; /* Two drives installed. */ + + /* Re-compute CMOS checksum. SeaBIOS also doesn't care about the checksum, + but Windows does. */ + uint16_t checksum = 0; + for (i = 0x10; i <= 0x2d; i++) { + checksum += nvr->regs[i]; + } + nvr->regs[0x2e] = checksum >> 8; + nvr->regs[0x2f] = checksum; + } + /* Initialize the internal and chip times. */ if (time_sync & TIME_SYNC_ENABLED) { /* Use the internal clock's time. */ From 1d366215076b31883b3c7f3ad334d438d652f250 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 14:44:17 -0300 Subject: [PATCH 06/28] Remove extraneous comment --- src/mem.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mem.c b/src/mem.c index 27335fb70..34e87c0f6 100644 --- a/src/mem.c +++ b/src/mem.c @@ -2469,7 +2469,6 @@ mem_log("MEM: reset: new pages=%08lx, pages_sz=%i\n", pages, pages_sz); free(byte_dirty_mask); byte_dirty_mask = NULL; } - //if (m != 256) fatal("bdm %d\n", ((uint64_t) pages_sz * 4096) / 8); byte_dirty_mask = malloc(((uint64_t) pages_sz * 4096) / 8); memset(byte_dirty_mask, 0, ((uint64_t) pages_sz * 4096) / 8); From f86dc3f27286027ad352d1ce7db355667903c18d Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 14:49:54 -0300 Subject: [PATCH 07/28] Only allocate byte_*_mask for the entire address space on coreboot machines --- src/mem.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mem.c b/src/mem.c index 34e87c0f6..b2b1bb88c 100644 --- a/src/mem.c +++ b/src/mem.c @@ -2465,19 +2465,28 @@ mem_log("MEM: reset: new pages=%08lx, pages_sz=%i\n", pages, pages_sz); } #ifdef USE_NEW_DYNAREC + if (machines[machine].flags & MACHINE_COREBOOT) { + /* coreboot executes code from the BIOS area, thus + requiring byte_*_mask for the entire address space, + which significantly increases memory usage. */ + c = ((uint64_t) (pages_sz) * MEM_GRANULARITY_SIZE) / 8; + } else { + c = (mem_size * 1024) / 8; + } + if (byte_dirty_mask) { free(byte_dirty_mask); byte_dirty_mask = NULL; } - byte_dirty_mask = malloc(((uint64_t) pages_sz * 4096) / 8); - memset(byte_dirty_mask, 0, ((uint64_t) pages_sz * 4096) / 8); + byte_dirty_mask = malloc(c); + memset(byte_dirty_mask, 0, c); if (byte_code_present_mask) { free(byte_code_present_mask); byte_code_present_mask = NULL; } - byte_code_present_mask = malloc(((uint64_t) pages_sz * 4096) / 8); - memset(byte_code_present_mask, 0, ((uint64_t) pages_sz * 4096) / 8); + byte_code_present_mask = malloc(c); + memset(byte_code_present_mask, 0, c); #endif for (c = 0; c < pages_sz; c++) { From a410ffe0ec6a92af1383253a9c2324719bcf4f24 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 14:53:01 -0300 Subject: [PATCH 08/28] Tiny indentation fix --- src/cpu_common/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpu_common/cpu.c b/src/cpu_common/cpu.c index d2c723044..286a1fe7a 100644 --- a/src/cpu_common/cpu.c +++ b/src/cpu_common/cpu.c @@ -2924,7 +2924,7 @@ void cpu_WRMSR() break; case 0x200: case 0x201: case 0x202: case 0x203: case 0x204: case 0x205: case 0x206: case 0x207: case 0x208: case 0x209: case 0x20A: case 0x20B: case 0x20C: case 0x20D: case 0x20E: case 0x20F: - temp = EAX | ((uint64_t)EDX << 32); + temp = EAX | ((uint64_t)EDX << 32); temp2 = (ECX - 0x200) >> 1; if (ECX & 1) { cpu_log("MTRR physmask[%d] = %08llx\n", temp2, temp); @@ -3236,7 +3236,7 @@ void cpu_WRMSR() break; case 0x200: case 0x201: case 0x202: case 0x203: case 0x204: case 0x205: case 0x206: case 0x207: case 0x208: case 0x209: case 0x20A: case 0x20B: case 0x20C: case 0x20D: case 0x20E: case 0x20F: - temp = EAX | ((uint64_t)EDX << 32); + temp = EAX | ((uint64_t)EDX << 32); temp2 = (ECX - 0x200) >> 1; if (ECX & 1) { cpu_log("MTRR physmask[%d] = %08llx\n", temp2, temp); From b9d6050600bfea8dc65bf7fcd59d273dfef91dcd Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 18 Apr 2020 16:07:28 -0300 Subject: [PATCH 09/28] Move MTRR feature away from master branch --- src/cpu_common/cpu.c | 51 ++---- src/cpu_common/cpu.h | 1 - src/cpu_common/x86_ops_misc.h | 2 - src/floppy/fdd.c | 7 - src/include/86box/fdd.h | 1 - src/include/86box/machine.h | 2 - src/include/86box/mem.h | 4 - src/machine/m_at_slot1.c | 16 +- src/machine/machine_table.c | 2 - src/mem.c | 306 ++-------------------------------- src/nvr_at.c | 49 +----- src/spd.c | 4 +- 12 files changed, 35 insertions(+), 410 deletions(-) diff --git a/src/cpu_common/cpu.c b/src/cpu_common/cpu.c index 286a1fe7a..bff70e6b1 100644 --- a/src/cpu_common/cpu.c +++ b/src/cpu_common/cpu.c @@ -2855,7 +2855,7 @@ i686_invalid_rdmsr: void cpu_WRMSR() { - uint64_t temp, temp2; + uint64_t temp; cpu_log("WRMSR %08X %08X%08X\n", ECX, EDX, EAX); switch (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type) @@ -2924,23 +2924,10 @@ void cpu_WRMSR() break; case 0x200: case 0x201: case 0x202: case 0x203: case 0x204: case 0x205: case 0x206: case 0x207: case 0x208: case 0x209: case 0x20A: case 0x20B: case 0x20C: case 0x20D: case 0x20E: case 0x20F: - temp = EAX | ((uint64_t)EDX << 32); - temp2 = (ECX - 0x200) >> 1; - if (ECX & 1) { - cpu_log("MTRR physmask[%d] = %08llx\n", temp2, temp); - - if ((mtrr_physmask_msr[temp2] >> 11) & 0x1) - mem_del_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), mtrr_physmask_msr[temp2] & ~(0xFFF)); - - if ((temp >> 11) & 0x1) - mem_add_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), temp & ~(0xFFF), mtrr_physbase_msr[temp2] & 0xFF); - - mtrr_physmask_msr[temp2] = temp; - } else { - cpu_log("MTRR physbase[%d] = %08llx\n", temp2, temp); - - mtrr_physbase_msr[temp2] = temp; - } + if (ECX & 1) + mtrr_physmask_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); + else + mtrr_physbase_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); break; case 0x250: mtrr_fix64k_8000_msr = EAX | ((uint64_t)EDX << 32); @@ -3236,24 +3223,11 @@ void cpu_WRMSR() break; case 0x200: case 0x201: case 0x202: case 0x203: case 0x204: case 0x205: case 0x206: case 0x207: case 0x208: case 0x209: case 0x20A: case 0x20B: case 0x20C: case 0x20D: case 0x20E: case 0x20F: - temp = EAX | ((uint64_t)EDX << 32); - temp2 = (ECX - 0x200) >> 1; - if (ECX & 1) { - cpu_log("MTRR physmask[%d] = %08llx\n", temp2, temp); - - if ((mtrr_physmask_msr[temp2] >> 11) & 0x1) - mem_del_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), mtrr_physmask_msr[temp2] & ~(0xFFF)); - - if ((temp >> 11) & 0x1) - mem_add_mtrr(mtrr_physbase_msr[temp2] & ~(0xFFF), temp & ~(0xFFF), mtrr_physbase_msr[temp2] & 0xFF); - - mtrr_physmask_msr[temp2] = temp; - } else { - cpu_log("MTRR physbase[%d] = %08llx\n", temp2, temp); - - mtrr_physbase_msr[temp2] = temp; - } - break; + if (ECX & 1) + mtrr_physmask_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); + else + mtrr_physbase_msr[(ECX - 0x200) >> 1] = EAX | ((uint64_t)EDX << 32); + break; case 0x250: mtrr_fix64k_8000_msr = EAX | ((uint64_t)EDX << 32); break; @@ -3285,11 +3259,6 @@ i686_invalid_wrmsr: } } -void cpu_INVD(uint8_t wb) -{ - mem_invalidate_mtrr(wb); -} - static int cyrix_addr; static void cpu_write(uint16_t addr, uint8_t val, void *priv) diff --git a/src/cpu_common/cpu.h b/src/cpu_common/cpu.h index 403457f60..106815688 100644 --- a/src/cpu_common/cpu.h +++ b/src/cpu_common/cpu.h @@ -515,7 +515,6 @@ extern void cpu_set(void); extern void cpu_CPUID(void); extern void cpu_RDMSR(void); extern void cpu_WRMSR(void); -extern void cpu_INVD(uint8_t wb); extern int checkio(int port); extern void codegen_block_end(void); diff --git a/src/cpu_common/x86_ops_misc.h b/src/cpu_common/x86_ops_misc.h index bb25b15d6..8f23e503a 100644 --- a/src/cpu_common/x86_ops_misc.h +++ b/src/cpu_common/x86_ops_misc.h @@ -743,14 +743,12 @@ static int opCLTS(uint32_t fetchdat) static int opINVD(uint32_t fetchdat) { - cpu_INVD(0); CLOCK_CYCLES(1000); CPU_BLOCK_END(); return 0; } static int opWBINVD(uint32_t fetchdat) { - cpu_INVD(1); CLOCK_CYCLES(10000); CPU_BLOCK_END(); return 0; diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index a2a5342af..791c82abd 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -407,13 +407,6 @@ fdd_is_dd(int drive) } -int -fdd_is_hd(int drive) -{ - return drive_types[fdd[drive].type].flags & FLAG_HOLE1; -} - - int fdd_is_ed(int drive) { diff --git a/src/include/86box/fdd.h b/src/include/86box/fdd.h index ccd420924..b486b617d 100644 --- a/src/include/86box/fdd.h +++ b/src/include/86box/fdd.h @@ -43,7 +43,6 @@ extern int fdd_can_read_medium(int drive); extern int fdd_doublestep_40(int drive); extern int fdd_is_525(int drive); extern int fdd_is_dd(int drive); -extern int fdd_is_hd(int drive); extern int fdd_is_ed(int drive); extern int fdd_is_double_sided(int drive); extern void fdd_set_head(int drive, int head); diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index e765d6df7..8a3febc15 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -39,7 +39,6 @@ #define MACHINE_VIDEO_FIXED 0x004000 /* sys has ONLY int video */ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_NONMI 0x010000 /* sys does not have NMI's */ -#define MACHINE_COREBOOT 0x020000 /* sys has coreboot BIOS */ #else #define MACHINE_PC 0x000000 /* PC architecture */ #define MACHINE_AT 0x000001 /* PC/AT architecture */ @@ -56,7 +55,6 @@ #define MACHINE_VIDEO_FIXED 0x004000 /* sys has ONLY int video */ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_NONMI 0x010000 /* sys does not have NMI's */ -#define MACHINE_COREBOOT 0x020000 /* sys has coreboot BIOS */ #endif #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 4a89f252c..429d98652 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -330,10 +330,6 @@ extern void mem_init(void); extern void mem_reset(void); extern void mem_remap_top(int kb); -extern void mem_add_mtrr(uint64_t base, uint64_t mask, uint8_t type); -extern void mem_del_mtrr(uint64_t base, uint64_t mask); -extern void mem_invalidate_mtrr(uint8_t wb); - #ifdef EMU_CPU_H static __inline uint32_t get_phys(uint32_t addr) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index 3c7d60e3d..800768ce8 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -105,12 +105,8 @@ machine_at_p2bls_init(const machine_t *model) { int ret; - if (model->flags & MACHINE_COREBOOT) - ret = bios_load_linear(L"roms/machines/p2bls/coreboot.rom", - 0x000c0000, 262144, 0); - else - ret = bios_load_linear(L"roms/machines/p2bls/1014ls.003", - 0x000c0000, 262144, 0); + ret = bios_load_linear(L"roms/machines/p2bls/1014ls.003", + 0x000c0000, 262144, 0); if (bios_only || !ret) return ret; @@ -169,12 +165,8 @@ machine_at_p3bf_init(const machine_t *model) { int ret; - if (model->flags & MACHINE_COREBOOT) - ret = bios_load_linear(L"roms/machines/p3bf/coreboot.rom", - 0x000c0000, 262144, 0); - else - ret = bios_load_linear(L"roms/machines/p3bf/bx3f1006.awd", - 0x000c0000, 262144, 0); + ret = bios_load_linear(L"roms/machines/p3bf/bx3f1006.awd", + 0x000c0000, 262144, 0); if (bios_only || !ret) return ret; diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 33fdb8fac..903f2bbe7 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -270,9 +270,7 @@ const machine_t machines[] = { { "[Slot 1 BX] Gigabyte GA-6BXC", "6bxc", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_6bxc_init, NULL }, { "[Slot 1 BX] ASUS P2B-LS", "p2bls", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, - { "[Slot 1 BX] ASUS P2B-LS (coreboot BIOS)","p2bls_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_COREBOOT, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, { "[Slot 1 BX] ASUS P3B-F", "p3bf", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, - { "[Slot 1 BX] ASUS P3B-F (coreboot BIOS)", "p3bf_cb", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_COREBOOT, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, { "[Slot 1 BX] ABit BF6", "bf6", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_bf6_init, NULL }, { "[Slot 1 ZX] Packard Bell Bora Pro", "borapro", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 255, machine_at_borapro_init, NULL }, diff --git a/src/mem.c b/src/mem.c index b2b1bb88c..459f7f6e6 100644 --- a/src/mem.c +++ b/src/mem.c @@ -121,8 +121,6 @@ static mem_mapping_t *read_mapping[MEM_MAPPINGS_NO]; static mem_mapping_t *write_mapping[MEM_MAPPINGS_NO]; static uint8_t *_mem_exec[MEM_MAPPINGS_NO]; static int _mem_state[MEM_MAPPINGS_NO]; -static uint8_t *mtrr_areas[MEM_MAPPINGS_NO]; -static uint8_t mtrr_area_refcounts[MEM_MAPPINGS_NO]; #if FIXME #if (MEM_GRANULARITY_BITS >= 12) @@ -652,8 +650,6 @@ uint8_t readmembl(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -667,12 +663,7 @@ readmembl(uint32_t addr) } addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) - return mtrr[addr & MEM_GRANULARITY_MASK]; - - map = read_mapping[page]; + map = read_mapping[addr >> MEM_GRANULARITY_BITS]; if (map && map->read_b) return map->read_b(addr, map->p); @@ -684,8 +675,6 @@ void writemembl(uint32_t addr, uint8_t val) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -703,14 +692,7 @@ writemembl(uint32_t addr, uint8_t val) } addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) { - mtrr[addr & MEM_GRANULARITY_MASK] = val; - return; - } - - map = write_mapping[page]; + map = write_mapping[addr >> MEM_GRANULARITY_BITS]; if (map && map->write_b) map->write_b(addr, val, map->p); } @@ -721,8 +703,6 @@ uint16_t readmemwl(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -751,12 +731,7 @@ readmemwl(uint32_t addr) addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) - return mtrr[addr & MEM_GRANULARITY_MASK] | ((uint16_t) (mtrr[(addr + 1) & MEM_GRANULARITY_MASK]) << 8); - - map = read_mapping[page]; + map = read_mapping[addr >> MEM_GRANULARITY_BITS]; if (map && map->read_w) return map->read_w(addr, map->p); @@ -772,8 +747,6 @@ void writememwl(uint32_t addr, uint16_t val) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -811,15 +784,7 @@ writememwl(uint32_t addr, uint16_t val) addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) { - mtrr[addr & MEM_GRANULARITY_MASK] = val; - mtrr[(addr + 1) & MEM_GRANULARITY_MASK] = val >> 8; - return; - } - - map = write_mapping[page]; + map = write_mapping[addr >> MEM_GRANULARITY_BITS]; if (map) { if (map->write_w) map->write_w(addr, val, map->p); @@ -835,8 +800,6 @@ uint32_t readmemll(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -866,12 +829,7 @@ readmemll(uint32_t addr) addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) - return mtrr[addr & MEM_GRANULARITY_MASK] | ((uint32_t) (mtrr[(addr + 1) & MEM_GRANULARITY_MASK]) << 8) | ((uint32_t) (mtrr[(addr + 2) & MEM_GRANULARITY_MASK]) << 16) | ((uint32_t) (mtrr[(addr + 3) & MEM_GRANULARITY_MASK]) << 24); - - map = read_mapping[page]; + map = read_mapping[addr >> MEM_GRANULARITY_BITS]; if (map) { if (map->read_l) return map->read_l(addr, map->p); @@ -892,8 +850,6 @@ void writememll(uint32_t addr, uint32_t val) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -930,17 +886,7 @@ writememll(uint32_t addr, uint32_t val) addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) { - mtrr[addr & MEM_GRANULARITY_MASK] = val; - mtrr[(addr + 1) & MEM_GRANULARITY_MASK] = val >> 8; - mtrr[(addr + 2) & MEM_GRANULARITY_MASK] = val >> 16; - mtrr[(addr + 3) & MEM_GRANULARITY_MASK] = val >> 24; - return; - } - - map = write_mapping[page]; + map = write_mapping[addr >> MEM_GRANULARITY_BITS]; if (map) { if (map->write_l) map->write_l(addr, val, map->p); @@ -961,8 +907,6 @@ uint64_t readmemql(uint32_t addr) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -991,12 +935,7 @@ readmemql(uint32_t addr) addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) - return readmemll(addr) | ((uint64_t)readmemll(addr+4)<<32); - - map = read_mapping[page]; + map = read_mapping[addr >> MEM_GRANULARITY_BITS]; if (map && map->read_l) return map->read_l(addr, map->p) | ((uint64_t)map->read_l(addr + 4, map->p) << 32); @@ -1008,8 +947,6 @@ void writememql(uint32_t addr, uint64_t val) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; mem_logical_addr = addr; @@ -1046,21 +983,7 @@ writememql(uint32_t addr, uint64_t val) addr = (uint32_t) (addr64 & rammask); - page = (addr >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) { - mtrr[addr & MEM_GRANULARITY_MASK] = val; - mtrr[(addr + 1) & MEM_GRANULARITY_MASK] = val >> 8; - mtrr[(addr + 2) & MEM_GRANULARITY_MASK] = val >> 16; - mtrr[(addr + 3) & MEM_GRANULARITY_MASK] = val >> 24; - mtrr[(addr + 4) & MEM_GRANULARITY_MASK] = val >> 32; - mtrr[(addr + 5) & MEM_GRANULARITY_MASK] = val >> 40; - mtrr[(addr + 6) & MEM_GRANULARITY_MASK] = val >> 48; - mtrr[(addr + 7) & MEM_GRANULARITY_MASK] = val >> 56; - return; - } - - map = write_mapping[page]; + map = write_mapping[addr >> MEM_GRANULARITY_BITS]; if (map) { if (map->write_l) { map->write_l(addr, val, map->p); @@ -1101,8 +1024,6 @@ uint16_t readmemwl(uint32_t seg, uint32_t addr) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1134,12 +1055,7 @@ readmemwl(uint32_t seg, uint32_t addr) addr2 = (uint32_t) (addr64 & rammask); - page = (addr2 >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) - return mtrr[addr2 & MEM_GRANULARITY_MASK] | ((uint16_t) (mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK]) << 8); - - map = read_mapping[page]; + map = read_mapping[addr2 >> MEM_GRANULARITY_BITS]; if (map && map->read_w) return map->read_w(addr2, map->p); @@ -1161,8 +1077,6 @@ void writememwl(uint32_t seg, uint32_t addr, uint16_t val) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1204,15 +1118,7 @@ writememwl(uint32_t seg, uint32_t addr, uint16_t val) addr2 = (uint32_t) (addr64 & rammask); - page = (addr2 >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) { - mtrr[addr2 & MEM_GRANULARITY_MASK] = val; - mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK] = val >> 8; - return; - } - - map = write_mapping[page]; + map = write_mapping[addr2 >> MEM_GRANULARITY_BITS]; if (map && map->write_w) { map->write_w(addr2, val, map->p); @@ -1231,8 +1137,6 @@ uint32_t readmemll(uint32_t seg, uint32_t addr) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1260,12 +1164,7 @@ readmemll(uint32_t seg, uint32_t addr) addr2 = (uint32_t) (addr64 & rammask); - page = (addr2 >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) - return mtrr[addr2 & MEM_GRANULARITY_MASK] | ((uint32_t) (mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK]) << 8) | ((uint32_t) (mtrr[(addr2 + 2) & MEM_GRANULARITY_MASK]) << 16) | ((uint32_t) (mtrr[(addr2 + 3) & MEM_GRANULARITY_MASK]) << 24); - - map = read_mapping[page]; + map = read_mapping[addr2 >> MEM_GRANULARITY_BITS]; if (map && map->read_l) return map->read_l(addr2, map->p); @@ -1288,8 +1187,6 @@ void writememll(uint32_t seg, uint32_t addr, uint32_t val) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1326,17 +1223,7 @@ writememll(uint32_t seg, uint32_t addr, uint32_t val) addr2 = (uint32_t) (addr64 & rammask); - page = (addr2 >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) { - mtrr[addr2 & MEM_GRANULARITY_MASK] = val; - mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK] = val >> 8; - mtrr[(addr2 + 2) & MEM_GRANULARITY_MASK] = val >> 16; - mtrr[(addr2 + 3) & MEM_GRANULARITY_MASK] = val >> 24; - return; - } - - map = write_mapping[page]; + map = write_mapping[addr2 >> MEM_GRANULARITY_BITS]; if (map && map->write_l) { map->write_l(addr2, val, map->p); @@ -1361,8 +1248,6 @@ uint64_t readmemql(uint32_t seg, uint32_t addr) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1389,12 +1274,7 @@ readmemql(uint32_t seg, uint32_t addr) addr2 = (uint32_t) (addr64 & rammask); - page = (addr2 >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) - return readmemll(seg,addr) | ((uint64_t)readmemll(seg,addr+4)<<32); - - map = read_mapping[page]; + map = read_mapping[addr2 >> MEM_GRANULARITY_BITS]; if (map && map->read_l) return map->read_l(addr2, map->p) | ((uint64_t)map->read_l(addr2 + 4, map->p) << 32); @@ -1406,8 +1286,6 @@ void writememql(uint32_t seg, uint32_t addr, uint64_t val) { uint64_t addr64 = (uint64_t) addr; - uint32_t page; - uint8_t *mtrr; mem_mapping_t *map; uint32_t addr2 = mem_logical_addr = seg + addr; @@ -1444,21 +1322,7 @@ writememql(uint32_t seg, uint32_t addr, uint64_t val) addr2 = (uint32_t) (addr64 & rammask); - page = (addr2 >> MEM_GRANULARITY_BITS); - mtrr = mtrr_areas[page]; - if (mtrr) { - mtrr[addr2 & MEM_GRANULARITY_MASK] = val; - mtrr[(addr2 + 1) & MEM_GRANULARITY_MASK] = val >> 8; - mtrr[(addr2 + 2) & MEM_GRANULARITY_MASK] = val >> 16; - mtrr[(addr2 + 3) & MEM_GRANULARITY_MASK] = val >> 24; - mtrr[(addr2 + 4) & MEM_GRANULARITY_MASK] = val >> 32; - mtrr[(addr2 + 5) & MEM_GRANULARITY_MASK] = val >> 40; - mtrr[(addr2 + 6) & MEM_GRANULARITY_MASK] = val >> 48; - mtrr[(addr2 + 7) & MEM_GRANULARITY_MASK] = val >> 56; - return; - } - - map = write_mapping[page]; + map = write_mapping[addr2 >> MEM_GRANULARITY_BITS]; if (map && map->write_l) { map->write_l(addr2, val, map->p); @@ -2456,37 +2320,20 @@ mem_log("MEM: reset: new pages=%08lx, pages_sz=%i\n", pages, pages_sz); memset(pages, 0x00, pages_sz*sizeof(page_t)); - for (c = 0; c < MEM_MAPPINGS_NO; c++) { - if (mtrr_areas[c]) { - free(mtrr_areas[c]); - mtrr_areas[c] = 0; - } - mtrr_area_refcounts[c] = 0; - } - #ifdef USE_NEW_DYNAREC - if (machines[machine].flags & MACHINE_COREBOOT) { - /* coreboot executes code from the BIOS area, thus - requiring byte_*_mask for the entire address space, - which significantly increases memory usage. */ - c = ((uint64_t) (pages_sz) * MEM_GRANULARITY_SIZE) / 8; - } else { - c = (mem_size * 1024) / 8; - } - if (byte_dirty_mask) { free(byte_dirty_mask); byte_dirty_mask = NULL; } - byte_dirty_mask = malloc(c); - memset(byte_dirty_mask, 0, c); + byte_dirty_mask = malloc((mem_size * 1024) / 8); + memset(byte_dirty_mask, 0, (mem_size * 1024) / 8); if (byte_code_present_mask) { free(byte_code_present_mask); byte_code_present_mask = NULL; } - byte_code_present_mask = malloc(c); - memset(byte_code_present_mask, 0, c); + byte_code_present_mask = malloc((mem_size * 1024) / 8); + memset(byte_code_present_mask, 0, (mem_size * 1024) / 8); #endif for (c = 0; c < pages_sz; c++) { @@ -2589,8 +2436,6 @@ mem_init(void) writelookup2 = malloc((1<<20)*sizeof(uintptr_t)); #endif - memset(mtrr_areas, 0x00, MEM_MAPPINGS_NO*sizeof(uint8_t *)); - #if FIXME memset(ff_array, 0xff, sizeof(ff_array)); #endif @@ -2688,118 +2533,3 @@ mem_a20_recalc(void) mem_a20_state = state; } - - -void -mem_add_mtrr(uint64_t base, uint64_t mask, uint8_t type) -{ - uint64_t size = ((~mask) & 0xffffffff) + 1; - uint64_t page_base, page, addr; - uint8_t *mtrr; - - mem_log("Adding MTRR base=%08llx mask=%08llx size=%08llx type=%d\n", base, mask, size, type); - - if (size > 0x8000) { - mem_log("Ignoring MTRR, size too big\n"); - return; - } - - if (mem_addr_is_ram(base)) { - mem_log("Ignoring MTRR, base is in RAM\n"); - return; - } - - for (page_base = base; page_base < base + size; page_base += MEM_GRANULARITY_SIZE) { - page = (page_base >> MEM_GRANULARITY_BITS); - if (mtrr_areas[page]) { - /* area already allocated, increase refcount and don't allocate it again */ - mtrr_area_refcounts[page]++; - continue; - } - - /* allocate area */ - mtrr = malloc(MEM_GRANULARITY_SIZE); - if (!mtrr) - fatal("Failed to allocate page for MTRR page %08llx (errno=%d)\n", page_base, errno); - - - /* populate area with data from RAM */ - for (addr = 0; addr < MEM_GRANULARITY_SIZE; addr++) { - mtrr[addr] = readmembl(page_base | addr); - } - - /* enable area */ - mtrr_areas[page] = mtrr; - } -} - - -void -mem_del_mtrr(uint64_t base, uint64_t mask) -{ - uint64_t size = ((~mask) & 0xffffffff) + 1; - uint64_t page_base, page; - - mem_log("Deleting MTRR base=%08llx mask=%08llx size=%08llx\n", base, mask, size); - - if (size > 0x8000) { - mem_log("Ignoring MTRR, size too big\n"); - return; - } - - if (mem_addr_is_ram(base)) { - mem_log("Ignoring MTRR, base is in RAM\n"); - return; - } - - for (page_base = base; page_base < base + size; page_base += MEM_GRANULARITY_SIZE) { - page = (page_base >> MEM_GRANULARITY_BITS); - if (mtrr_areas[page]) { - /* decrease reference count */ - if (mtrr_area_refcounts[page] > 0) - mtrr_area_refcounts[page]--; - - /* if no references are left, de-allocate area */ - if (mtrr_area_refcounts[page] == 0) { - free(mtrr_areas[page]); - mtrr_areas[page] = 0; - } - } - } -} - - -void -mem_invalidate_mtrr(uint8_t wb) -{ - uint64_t page, page_base, addr; - uint8_t *mtrr; - - mem_log("Invalidating cache (writeback=%d)\n", wb); - for (page = 0; page < MEM_MAPPINGS_NO; page++) { - mtrr = mtrr_areas[page]; - if (mtrr) { - page_base = (page << MEM_GRANULARITY_BITS); - if (!mem_addr_is_ram(page_base)) - continue; /* don't invalidate pages not backed by RAM */ - - /* temporarily set area aside */ - mtrr_areas[page] = 0; - - /* write data back to memory if requested */ - if (wb && write_mapping[page]) { /* don't write back to a page which can't be written to */ - for (addr = 0; addr < MEM_GRANULARITY_SIZE; addr++) { - writemembl(page_base | addr, mtrr[addr]); - } - } - - /* re-populate area with data from memory */ - for (addr = 0; addr < MEM_GRANULARITY_SIZE; addr++) { - mtrr[addr] = readmembl(page_base | addr); - } - - /* re-enable area */ - mtrr_areas[page] = mtrr; - } - } -} diff --git a/src/nvr_at.c b/src/nvr_at.c index 403fc62f7..d95a6d7c0 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -237,7 +237,6 @@ #include <86box/rom.h> #include <86box/device.h> #include <86box/nvr.h> -#include <86box/fdd.h> /* RTC registers and bit definitions. */ @@ -280,8 +279,6 @@ # define REGC_UF 0x10 #define RTC_REGD 13 # define REGD_VRT 0x80 -#define RTC_FDD_TYPES 0x10 -#define RTC_INST_EQUIP 0x14 #define RTC_CENTURY_AT 0x32 /* century register for AT etc */ #define RTC_CENTURY_PS 0x37 /* century register for PS/1 PS/2 */ #define RTC_ALDAY 0x7D /* VIA VT82C586B - alarm day */ @@ -756,7 +753,7 @@ nvr_reset(nvr_t *nvr) static void nvr_start(nvr_t *nvr) { - int i, fdd; + int i; local_t *local = (local_t *) nvr->data; struct tm tm; @@ -771,50 +768,6 @@ nvr_start(nvr_t *nvr) nvr->regs[0x0e] = 0xff; /* If load failed or it loaded an uninitialized NVR, mark everything as bad. */ - if (machines[machine].flags & MACHINE_COREBOOT) { - /* Sync floppy drive types on coreboot machines, as SeaBIOS lacks a setup - utility and just leaves these untouched. */ - - nvr->regs[RTC_FDD_TYPES] = 0x00; - nvr->regs[RTC_INST_EQUIP] |= 0xc0; - - for (i = 0; i <= 1; i++) { - fdd = fdd_get_type(i); - if (fdd) { - if (fdd_is_525(i)) { - if (fdd_is_hd(i)) - fdd = 2; - else if (fdd_doublestep_40(i)) - fdd = 3; - else - fdd = 1; - } else { - if (fdd_is_hd(i)) - fdd = 4; - else if (fdd_is_double_sided(i)) - fdd = 3; - else - fdd = 1; - } - - nvr->regs[RTC_FDD_TYPES] |= (fdd << ((1 - i) * 4)); - nvr->regs[RTC_INST_EQUIP] &= 0x3f; /* At least one drive installed. */ - } - } - - if ((nvr->regs[RTC_FDD_TYPES] >> 4) && (nvr->regs[RTC_FDD_TYPES] & 0xf)) - nvr->regs[RTC_INST_EQUIP] |= 0x40; /* Two drives installed. */ - - /* Re-compute CMOS checksum. SeaBIOS also doesn't care about the checksum, - but Windows does. */ - uint16_t checksum = 0; - for (i = 0x10; i <= 0x2d; i++) { - checksum += nvr->regs[i]; - } - nvr->regs[0x2e] = checksum >> 8; - nvr->regs[0x2f] = checksum; - } - /* Initialize the internal and chip times. */ if (time_sync & TIME_SYNC_ENABLED) { /* Use the internal clock's time. */ diff --git a/src/spd.c b/src/spd.c index 9de74836c..ed09c17f9 100644 --- a/src/spd.c +++ b/src/spd.c @@ -271,8 +271,8 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) sprintf(sdram_data->part_no, "86Box-SDR-%03dM", vslots[vslot]); for (i = strlen(sdram_data->part_no); i < sizeof(sdram_data->part_no); i++) sdram_data->part_no[i] = ' '; - sdram_data->mfg_year = 20; - sdram_data->mfg_week = 13; + sdram_data->mfg_year = 0x20; + sdram_data->mfg_week = 0x13; sdram_data->freq = 100; sdram_data->features = 0xFF; From 73b51bf5731257e16638b8a8447ded6e82183d2f Mon Sep 17 00:00:00 2001 From: tiseno100 <58827426+tiseno100@users.noreply.github.com> Date: Sat, 25 Apr 2020 18:59:37 +0300 Subject: [PATCH 10/28] Dev branch all machines with missing SIO chips + added the VS440FX This board returns D4 POST with no output. Needs further examination. Meant for the future PC87307 implementation. Also all boards that miss their SIO chips got Dev Branched just in case 2.10 gets released while some miss their SIO. --- src/machine/m_at_slot1.c | 6 +++++- src/machine/m_at_socket7_s7.c | 11 +++++++---- src/machine/m_at_socket8.c | 34 +++++++++++++++++++++++++++++++++- src/machine/machine_table.c | 13 ++++++++++++- src/win/Makefile.mingw | 10 ++++++++++ src/win/Makefile_ndr.mingw | 10 ++++++++++ 6 files changed, 77 insertions(+), 7 deletions(-) diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index 800768ce8..46ebe4727 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -33,12 +33,14 @@ #include <86box/intel_sio.h> #include <86box/piix.h> #include <86box/sio.h> +#include <86box/intel_sio.h> #include <86box/sst_flash.h> #include <86box/hwm.h> #include <86box/spd.h> #include <86box/video.h> #include "cpu.h" #include <86box/machine.h> + int machine_at_p6kfx_init(const machine_t *model) { @@ -69,6 +71,7 @@ machine_at_p6kfx_init(const machine_t *model) return ret; } +#if defined(DEV_BRANCH) && defined(NO_SIO) int machine_at_6bxc_init(const machine_t *model) { @@ -93,12 +96,13 @@ machine_at_6bxc_init(const machine_t *model) device_add(&i440bx_device); device_add(&piix4e_device); device_add(&keyboard_ps2_pci_device); - device_add(&um8669f_device); /*Placeholder for ITE 8671*/ + device_add(&um8669f_device); /*ITE 8671*/ device_add(&sst_flash_39sf020_device); spd_register(SPD_TYPE_SDRAM, 0xF, 256); return ret; } +#endif int machine_at_p2bls_init(const machine_t *model) diff --git a/src/machine/m_at_socket7_s7.c b/src/machine/m_at_socket7_s7.c index 4eb1f963b..3892109b9 100644 --- a/src/machine/m_at_socket7_s7.c +++ b/src/machine/m_at_socket7_s7.c @@ -549,6 +549,7 @@ machine_at_pb680_init(const machine_t *model) return ret; } +#if defined(DEV_BRANCH) && defined(NO_SIO) int machine_at_p55xb2_init(const machine_t *model) { @@ -577,7 +578,7 @@ machine_at_p55xb2_init(const machine_t *model) return ret; } - +#endif int machine_at_tx97_init(const machine_t *model) @@ -702,7 +703,7 @@ machine_at_ym430tx_init(const machine_t *model) return ret; } - +#if defined(DEV_BRANCH) && defined(NO_SIO) int machine_at_586t2_init(const machine_t *model) { @@ -796,7 +797,7 @@ machine_at_807ds_init(const machine_t *model) return ret; } - +#endif int machine_at_p5mms98_init(const machine_t *model) @@ -862,6 +863,7 @@ machine_at_p5mms98_init(const machine_t *model) return ret; } +#if defined(DEV_BRANCH) && defined(NO_SIO) int machine_at_tx100_init(const machine_t *model) { @@ -919,4 +921,5 @@ machine_at_advanceii_init(const machine_t *model) spd_register(SPD_TYPE_SDRAM, 0xF, 64); return ret; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/machine/m_at_socket8.c b/src/machine/m_at_socket8.c index 14b72dcc7..30c9f5c0a 100644 --- a/src/machine/m_at_socket8.c +++ b/src/machine/m_at_socket8.c @@ -156,4 +156,36 @@ machine_at_m6mi_init(const machine_t *model) device_add(&intel_flash_bxt_device); return ret; -} \ No newline at end of file +} + +#if defined(DEV_BRANCH) && defined(NO_SIO) +int +machine_at_vs440fx_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear_combined2(L"roms/machines/vs440fx/1011CS1_.BIO", + L"roms/machines/vs440fx/1011CS1_.BI1", + L"roms/machines/vs440fx/1011CS1_.BI2", + L"roms/machines/vs440fx/1011CS1_.BI3", + L"roms/machines/vs440fx/1011CS1_.RCV", + 0x3a000, 128); + + if (bios_only || !ret) + 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(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + device_add(&i440fx_device); + device_add(&piix3_device); + device_add(&keyboard_ps2_ami_pci_device); + //device_add(&pc87307_device); + device_add(&pc87306_device); + device_add(&intel_flash_bxt_ami_device); + + return ret; +} +#endif \ No newline at end of file diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 8cc0dbfaf..fc2eeab91 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -254,18 +254,24 @@ const machine_t machines[] = { /* 430TX */ { "[Socket 7 TX] ASUS TX97", "tx97", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 255, machine_at_tx97_init, NULL }, +#if defined(DEV_BRANCH) && defined(NO_SIO) { "[Socket 7 TX] Gigabyte GA-586T2", "586t2", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 255, machine_at_586t2_init, NULL }, +#endif { "[Socket 7 TX] Intel YM430TX", "ym430tx", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 255, machine_at_ym430tx_init, NULL }, +#if defined(DEV_BRANCH) && defined(NO_SIO) { "[Socket 7 TX] Iwill P55XB2", "p55xb2", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 255, machine_at_p55xb2_init, NULL }, { "[Socket 7 TX] PC Partner TXA807DS", "807ds", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 255, machine_at_807ds_init, NULL }, +#endif { "[Socket 7 TX] SuperMicro P5MMS98", "p5mms98", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 255, machine_at_p5mms98_init, NULL }, +#if defined(DEV_BRANCH) && defined(NO_SIO) /* Apollo VPX */ { "[Socket 7 VPX] Zida Tomato TX100", "tx100", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_tx100_init, NULL }, /* Apollo VP3 */ { "[Socket 7 VP3] QDI Advance II", "advanceii", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_advanceii_init, NULL }, - +#endif + /* Super Socket 7 machines */ /* Apollo MVP3 */ { "[Super 7 MVP3] AOpen AX59 Pro", "ax59pro", MACHINE_CPUS_PENTIUM_SS7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_ax59pro_init, NULL }, @@ -277,6 +283,9 @@ const machine_t machines[] = { { "[Socket 8 FX] PC Partner MB600N", "mb600n", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_mb600n_init, NULL }, { "[Socket 8 FX] Biostar MB-8500ttc", "8500ttc", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_8500ttc_init, NULL }, { "[Socket 8 FX] Micronics M6MI", "m6mi", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 384, 8, 127, machine_at_m6mi_init, NULL }, +#if defined(DEV_BRANCH) && defined(NO_SIO) + { "[Socket 8 FX] Intel Venus", "vs440fx", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 127, machine_at_vs440fx_init, NULL }, +#endif /* Slot 1 machines */ /* 440FX */ @@ -285,7 +294,9 @@ const machine_t machines[] = { /* 440LX */ /* 440BX */ +#if defined(DEV_BRANCH) && defined(NO_SIO) { "[Slot 1 BX] Gigabyte GA-6BXC", "6bxc", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_6bxc_init, NULL }, +#endif { "[Slot 1 BX] ASUS P2B-LS", "p2bls", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p2bls_init, NULL }, { "[Slot 1 BX] ASUS P3B-F", "p3bf", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 1024, 8, 255, machine_at_p3bf_init, NULL }, { "[Slot 1 BX] ABit BF6", "bf6", {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_bf6_init, NULL }, diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index f8044ddd5..4103f35c0 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -92,6 +92,9 @@ ifeq ($(DEV_BUILD), y) ifndef XL24 XL24 := y endif + ifndef NO_SIO + NO_SIO := y + endif else ifndef DEBUG DEBUG := n @@ -150,6 +153,9 @@ else ifndef XL24 XL24 := n endif + ifndef NO_SIO + NO_SIO := n + endif endif # Defaults for several build options (possibly defined in a chained file.) @@ -484,6 +490,10 @@ ifeq ($(XL24), y) OPTS += -DUSE_XL24 endif +ifeq ($(NO_SIO), y) +OPTS += -DNO_SIO +endif + endif diff --git a/src/win/Makefile_ndr.mingw b/src/win/Makefile_ndr.mingw index 1a15963e6..b1ec42759 100644 --- a/src/win/Makefile_ndr.mingw +++ b/src/win/Makefile_ndr.mingw @@ -92,6 +92,9 @@ ifeq ($(DEV_BUILD), y) ifndef XL24 XL24 := y endif + ifndef NO_SIO + NO_SIO := y + endif else ifndef DEBUG DEBUG := n @@ -153,6 +156,9 @@ else ifndef XL24 XL24 := n endif + ifndef NO_SIO + NO_SIO := n + endif endif # Defaults for several build options (possibly defined in a chained file.) @@ -493,6 +499,10 @@ ifeq ($(XL24), y) OPTS += -DUSE_XL24 endif +ifeq ($(NO_SIO), y) +OPTS += -DNO_SIO +endif + endif From 1a91d7c5787b029649ff10b5cd03f55ad2adc78d Mon Sep 17 00:00:00 2001 From: tiseno100 <58827426+tiseno100@users.noreply.github.com> Date: Sun, 26 Apr 2020 19:28:24 +0300 Subject: [PATCH 11/28] fix missing VS440FX decleration on machine.h --- src/include/86box/machine.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 7e51ab210..bc07c6829 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -319,6 +319,7 @@ extern int machine_at_686nx_init(const machine_t *); extern int machine_at_mb600n_init(const machine_t *); extern int machine_at_8500ttc_init(const machine_t *); extern int machine_at_m6mi_init(const machine_t *); +extern int machine_at_vs440fx_init(const machine_t *); /* m_at_slot1.c */ extern int machine_at_p6kfx_init(const machine_t *); From 3d5f9de060efe5e6a300d95d87ae4843b2942495 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 26 Apr 2020 13:43:06 -0300 Subject: [PATCH 12/28] ASUS P/I-P65UP5 --- src/include/86box/machine.h | 7 +++++++ src/machine/m_at_slot1.c | 18 ++++++++++++++++- src/machine/m_at_socket7_s7.c | 16 +++++++++++++++ src/machine/m_at_socket8.c | 38 ++++++++++++++++++++++++++++++++++- src/machine/machine_table.c | 10 ++++++--- 5 files changed, 84 insertions(+), 5 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 7e51ab210..5cf520dbf 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -289,6 +289,7 @@ extern int machine_at_p55t2s_init(const machine_t *); extern int machine_at_m7shi_init(const machine_t *); extern int machine_at_tc430hx_init(const machine_t *); extern int machine_at_equium5200_init(const machine_t *); +extern int machine_at_p65up5_cp55t2d_init(const machine_t *); extern int machine_at_p55tvp4_init(const machine_t *); extern int machine_at_p55va_init(const machine_t *); @@ -319,8 +320,14 @@ extern int machine_at_686nx_init(const machine_t *); extern int machine_at_mb600n_init(const machine_t *); extern int machine_at_8500ttc_init(const machine_t *); extern int machine_at_m6mi_init(const machine_t *); +extern int machine_at_vs440fx_init(const machine_t *); +#ifdef EMU_DEVICE_H +extern void machine_at_p65up5_common_init(const machine_t *, const device_t *northbridge); +#endif +extern int machine_at_p65up5_cp6nd_init(const machine_t *); /* m_at_slot1.c */ +extern int machine_at_p65up5_cpknd_init(const machine_t *); extern int machine_at_p6kfx_init(const machine_t *); extern int machine_at_6bxc_init(const machine_t *); diff --git a/src/machine/m_at_slot1.c b/src/machine/m_at_slot1.c index 46ebe4727..37c8868e6 100644 --- a/src/machine/m_at_slot1.c +++ b/src/machine/m_at_slot1.c @@ -41,6 +41,22 @@ #include "cpu.h" #include <86box/machine.h> +int +machine_at_p65up5_cpknd_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/p65up5/ndkn0218.awd", + 0x000e0000, 131072, 0); + + if (bios_only || !ret) + return ret; + + machine_at_p65up5_common_init(model, &i440fx_device); + + return ret; +} + int machine_at_p6kfx_init(const machine_t *model) { @@ -292,4 +308,4 @@ machine_at_borapro_init(const machine_t *model) spd_register(SPD_TYPE_SDRAM, 0x3, 256); return ret; -} \ No newline at end of file +} diff --git a/src/machine/m_at_socket7_s7.c b/src/machine/m_at_socket7_s7.c index 3892109b9..24a6d533c 100644 --- a/src/machine/m_at_socket7_s7.c +++ b/src/machine/m_at_socket7_s7.c @@ -400,6 +400,22 @@ machine_at_equium5200_init(const machine_t *model) // Information about that mac return ret; } +int +machine_at_p65up5_cp55t2d_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/p65up5/td5i0201.awd", + 0x000e0000, 131072, 0); + + if (bios_only || !ret) + return ret; + + machine_at_p65up5_common_init(model, &i430hx_device); + + return ret; +} + int machine_at_p55tvp4_init(const machine_t *model) { diff --git a/src/machine/m_at_socket8.c b/src/machine/m_at_socket8.c index 30c9f5c0a..dba53237b 100644 --- a/src/machine/m_at_socket8.c +++ b/src/machine/m_at_socket8.c @@ -188,4 +188,40 @@ machine_at_vs440fx_init(const machine_t *model) return ret; } -#endif \ No newline at end of file +#endif + +void +machine_at_p65up5_common_init(const machine_t *model, const device_t *northbridge) +{ + 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(0x01, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x09, PCI_CARD_NORMAL, 4, 1, 2, 3); + pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2); + pci_register_slot(0x0B, PCI_CARD_NORMAL, 2, 3, 4, 1); + pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4); + pci_register_slot(0x0D, PCI_CARD_NORMAL, 4, 1, 2, 3); + device_add(northbridge); + device_add(&piix3_device); + device_add(&keyboard_ps2_ami_pci_device); + device_add(&w83877f_device); + device_add(&intel_flash_bxt_device); +} + +int +machine_at_p65up5_cp6nd_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/p65up5/nd6i0218.awd", + 0x000e0000, 131072, 0); + + if (bios_only || !ret) + return ret; + + machine_at_p65up5_common_init(model, &i440fx_device); + + return ret; +} diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index fc2eeab91..2ce007f51 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -244,13 +244,14 @@ const machine_t machines[] = { { "[Socket 7 HX] Micronics M7S-Hi", "m7shi", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 511, machine_at_m7shi_init, NULL }, { "[Socket 7 HX] Intel TC430HX", "tc430hx", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 255, machine_at_tc430hx_init, NULL }, { "[Socket 7 HX] Toshiba Equium 5200D", "equium5200", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 192, 8, 127, machine_at_equium5200_init, NULL }, + { "[Socket 7 HX] ASUS P/I-P65UP5 (C-P55T2D)","p65up5_cp55t2d", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_p65up5_cp55t2d_init, NULL }, /* 430VX */ { "[Socket 7 VX] ASUS P/I-P55TVP4", "p55tvp4", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_p55tvp4_init, NULL }, { "[Socket 7 VX] Shuttle HOT-557", "430vx", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_i430vx_init, NULL }, { "[Socket 7 VX] Epox P55-VA", "p55va", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_p55va_init, NULL }, - { "[Socket 7 VX] HP Brio 80xx", "brio80xx", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_brio80xx_init, NULL }, - { "[Socket 7 VX] Packard Bell PB680", "pb680", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_pb680_init, NULL }, + { "[Socket 7 VX] HP Brio 80xx", "brio80xx", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_brio80xx_init, NULL }, + { "[Socket 7 VX] Packard Bell PB680", "pb680", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_pb680_init, NULL }, /* 430TX */ { "[Socket 7 TX] ASUS TX97", "tx97", MACHINE_CPUS_PENTIUM_S7, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 255, machine_at_tx97_init, NULL }, @@ -284,11 +285,14 @@ const machine_t machines[] = { { "[Socket 8 FX] Biostar MB-8500ttc", "8500ttc", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_8500ttc_init, NULL }, { "[Socket 8 FX] Micronics M6MI", "m6mi", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 384, 8, 127, machine_at_m6mi_init, NULL }, #if defined(DEV_BRANCH) && defined(NO_SIO) - { "[Socket 8 FX] Intel Venus", "vs440fx", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 127, machine_at_vs440fx_init, NULL }, + { "[Socket 8 FX] Intel VS440FX", "vs440fx", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 256, 8, 127, machine_at_vs440fx_init, NULL }, #endif + { "[Socket 8 FX] ASUS P/I-P65UP5 (C-P6ND)", "p65up5_cp6nd", {{"Intel", cpus_PentiumPro}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_p65up5_cp6nd_init, NULL }, + /* Slot 1 machines */ /* 440FX */ + { "[Slot 1 FX] ASUS P/I-P65UP5 (C-PKND)", "p65up5_cpknd", {{"Intel", cpus_PentiumII_28v},{"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 512, 8, 127, machine_at_p65up5_cpknd_init, NULL }, { "[Slot 1 FX] ECS P6KFX-A", "p6kfx", {{"Intel", cpus_PentiumII_28v},{"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 384, 8, 127, machine_at_p6kfx_init, NULL }, /* 440LX */ From aa5d9555f5a3766ee7689af19595974826e16efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Fri, 24 Apr 2020 21:24:32 +0200 Subject: [PATCH 13/28] win: Add menu resources for the drive menus --- src/include/86box/win.h | 5 ++++ src/win/86Box.rc | 56 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 5498d3f07..2271a5803 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -43,6 +43,11 @@ #define SB_MENU_NAME L"StatusBarMenu" #define FS_CLASS_NAME L"86BoxFullScreen" +#define FLOPPY_SUBMENU_NAME L"FloppySubmenu" +#define CDROM_SUBMENU_NAME L"CdromSubmenu" +#define ZIP_SUBMENU_NAME L"ZIPSubmenu" +#define MO_SUBMENU_NAME L"MOSubmenu" + /* Application-specific window messages. A dialog sends 0x8895 with WPARAM = 1 followed by 0x8896 with WPARAM = 1 on open, diff --git a/src/win/86Box.rc b/src/win/86Box.rc index c71fb8b43..5e2038059 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -172,6 +172,62 @@ BEGIN MENUITEM SEPARATOR END +FloppySubmenu MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "&New image...", IDM_FLOPPY_IMAGE_NEW + MENUITEM SEPARATOR + MENUITEM "&Existing image...", IDM_FLOPPY_IMAGE_EXISTING + MENUITEM "Existing image (&Write-protected)...", IDM_FLOPPY_IMAGE_EXISTING_WP + MENUITEM SEPARATOR + MENUITEM "E&xport to 86F...", IDM_FLOPPY_EXPORT_TO_86F + MENUITEM SEPARATOR + MENUITEM "E&ject", IDM_FLOPPY_EJECT + END +END + +CdromSubmenu MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "&Mute", IDM_CDROM_MUTE + MENUITEM SEPARATOR + MENUITEM "E&mpty", IDM_CDROM_EMPTY + MENUITEM "&Reload previous image", IDM_CDROM_RELOAD + MENUITEM SEPARATOR + MENUITEM "&Image", IDM_CDROM_IMAGE + END +END + +ZIPSubmenu MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "&New image...", IDM_ZIP_IMAGE_NEW + MENUITEM SEPARATOR + MENUITEM "&Existing image...", IDM_ZIP_IMAGE_EXISTING + MENUITEM "Existing image (&Write-protected)...", IDM_ZIP_IMAGE_EXISTING_WP + MENUITEM SEPARATOR + MENUITEM "E&ject", IDM_ZIP_EJECT + MENUITEM "&Reload previous image", IDM_ZIP_RELOAD + END +END + +MOSubmenu MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "&New image...", IDM_MO_IMAGE_NEW + MENUITEM SEPARATOR + MENUITEM "&Existing image...", IDM_MO_IMAGE_EXISTING + MENUITEM "Existing image (&Write-protected)...", IDM_MO_IMAGE_EXISTING_WP + MENUITEM SEPARATOR + MENUITEM "E&ject", IDM_MO_EJECT + MENUITEM "&Reload previous image", IDM_MO_RELOAD + END +END + ///////////////////////////////////////////////////////////////////////////// // From c728ece0ee96958d9e760b5993a2be7ca6d6381e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 00:12:11 +0200 Subject: [PATCH 14/28] win: Start splitting menu code from win_stbar.c --- src/win/Makefile.mingw | 2 +- src/win/Makefile_ndr.mingw | 2 +- src/win/win_media_menu.c | 265 +++++++++++++++++++++++++++++++++++++ 3 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 src/win/win_media_menu.c diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 4103f35c0..e57efc9bd 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -376,7 +376,7 @@ else win_sdl.o \ win_dialog.o win_about.o \ win_settings.o win_devconf.o win_snd_gain.o \ - win_new_floppy.o win_jsconf.o + win_new_floppy.o win_jsconf.o win_media_menu.o endif ifeq ($(OPENAL), y) diff --git a/src/win/Makefile_ndr.mingw b/src/win/Makefile_ndr.mingw index b1ec42759..1967963ea 100644 --- a/src/win/Makefile_ndr.mingw +++ b/src/win/Makefile_ndr.mingw @@ -385,7 +385,7 @@ else win_sdl.o \ win_dialog.o win_about.o \ win_settings.o win_devconf.o win_snd_gain.o \ - win_new_floppy.o win_jsconf.o + win_new_floppy.o win_jsconf.o win_media_menu.o endif ifeq ($(OPENAL), y) diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c new file mode 100644 index 000000000..af5d380eb --- /dev/null +++ b/src/win/win_media_menu.c @@ -0,0 +1,265 @@ +#define UNICODE +#include +#include +#include +#include +#include <86box/86box.h> +#include <86box/cdrom.h> +#include <86box/device.h> +#include <86box/timer.h> +#include <86box/fdd.h> +#include <86box/hdc.h> +#include <86box/language.h> +#include <86box/machine.h> +#include <86box/scsi_device.h> +#include <86box/mo.h> +#include <86box/scsi.h> +#include <86box/zip.h> +#include <86box/win.h> + +#define MACHINE_HAS_IDE ((machines[machine].flags & MACHINE_HDC) || !memcmp(hdc_get_internal_name(hdc_current), "ide", 3)) + +#define FDD_FIRST 0 +#define CDROM_FIRST FDD_FIRST + FDD_NUM +#define ZIP_FIRST CDROM_FIRST + CDROM_NUM +#define MO_FIRST ZIP_FIRST + ZIP_NUM + +static HMENU media_menu, stbar_menu; +static HMENU menus[FDD_NUM + CDROM_NUM + ZIP_NUM + MO_NUM]; +static char index_map[255]; + +static void +media_menu_set_ids(HMENU hMenu, int id) +{ + int c = GetMenuItemCount(hMenu); + + MENUITEMINFO mii; + mii.fMask = MIIM_ID; + + for(int i = 0; i < c; i++) + { + GetMenuItemInfo(hMenu, i, TRUE, &mii); + mii.wID |= id; + SetMenuItemInfo(hMenu, i, TRUE, &mii); + } +} + +/* Loads the submenu from resource by name */ +static HMENU +media_menu_load_resource(wchar_t *lpName) +{ + HMENU loaded = LoadMenu(NULL, lpName); + + /* The actual submenu is in a dummy popup menu item */ + HMENU actual = GetSubMenu(loaded, 0); + + /* Now that we have our submenu, we can destroy the parent menu */ + RemoveMenu(loaded, (UINT_PTR)actual, MF_BYCOMMAND); + DestroyMenu(loaded); + + return actual; +} + +static void +media_menu_update_floppy(int id) +{ + int i = FDD_FIRST + id; + + if (floppyfns[id][0] == 0x0000) { + EnableMenuItem(menus[i], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(menus[i], IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_GRAYED); + } +} + +static void +media_menu_update_cdrom(int id) +{ + int i = CDROM_FIRST + id; + + if (! cdrom[id].sound_on) + CheckMenuItem(menus[i], IDM_CDROM_MUTE | id, MF_CHECKED); + + if (cdrom[id].host_drive == 200) + CheckMenuItem(menus[i], IDM_CDROM_IMAGE | id, MF_CHECKED); + else { + cdrom[id].host_drive = 0; + CheckMenuItem(menus[i], IDM_CDROM_EMPTY | id, MF_CHECKED); + } +} + +static void +media_menu_update_zip(int id) +{ + int i = ZIP_FIRST + id; + + if (zip_drives[id].image_path[0] == 0x0000) { + EnableMenuItem(menus[i], IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); + } else { + EnableMenuItem(menus[i], IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); + } +} + +static void +media_menu_update_mo(int id) +{ + int i = MO_FIRST + id; + + if (mo_drives[id].image_path[0] == 0x0000) { + EnableMenuItem(menus[i], IDM_MO_EJECT | id, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); + } else { + EnableMenuItem(menus[i], IDM_MO_EJECT | id, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); + } +} + +static void +media_menu_load_submenus() +{ + memset(index_map, -1, sizeof(index_map)); + + int curr = 0; + + for(int i = 0; i < FDD_NUM; i++) { + menus[curr] = media_menu_load_resource(FLOPPY_SUBMENU_NAME); + media_menu_set_ids(menus[curr++], i); + } + + for(int i = 0; i < CDROM_NUM; i++) { + menus[curr] = media_menu_load_resource(CDROM_SUBMENU_NAME); + media_menu_set_ids(menus[curr++], i); + } + + for(int i = 0; i < ZIP_NUM; i++) { + menus[curr] = media_menu_load_resource(ZIP_SUBMENU_NAME); + media_menu_set_ids(menus[curr++], i); + } + + for(int i = 0; i < MO_NUM; i++) { + menus[curr] = media_menu_load_resource(MO_SUBMENU_NAME); + media_menu_set_ids(menus[curr++], i); + } +} + +static inline int +is_valid_fdd(int i) +{ + return fdd_get_type(i) != 0; +} + +static inline int +is_valid_cdrom(int i) +{ + if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !MACHINE_HAS_IDE) + return 0; + if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && (scsi_card_current == 0)) + return 0; + return cdrom[i].bus_type != 0; +} + +static inline int +is_valid_zip(int i) +{ + if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !MACHINE_HAS_IDE) + return 0; + if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && (scsi_card_current == 0)) + return 0; + return zip_drives[i].bus_type != 0; +} + +static inline int +is_valid_mo(int i) +{ + if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !MACHINE_HAS_IDE) + return 0; + if ((mo_drives[i].bus_type == MO_BUS_SCSI) && (scsi_card_current == 0)) + return 0; + return mo_drives[i].bus_type != 0; +} + +void +media_menu_reset() +{ + /* Remove existing entries. */ + int c = GetMenuItemCount(media_menu); + + for(int i = 0; i < c; i++) + RemoveMenu(media_menu, i, TRUE); + + /* Add new ones. */ + int curr = 0; + + for(int i = 0; i < FDD_NUM; i++) { + if(is_valid_fdd(i)) { + AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test"); + media_menu_update_floppy(i); + } + curr++; + } + + for(int i = 0; i < CDROM_NUM; i++) { + if(is_valid_cdrom(i)) { + AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test"); + media_menu_update_cdrom(i); + } + curr++; + } + + for(int i = 0; i < ZIP_NUM; i++) { + if(is_valid_zip(i)) { + AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test"); + media_menu_update_zip(i); + } + curr++; + } + + for(int i = 0; i < MO_NUM; i++) { + if(is_valid_mo(i)) { + AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test"); + media_menu_update_mo(i); + } + curr++; + } +} + +/* Initializes the Media menu in the main menu bar. */ +static void +media_menu_main_init() +{ + HMENU hMenu; + LPWSTR lpMenuName; + + hMenu = GetMenu(hwndMain); + media_menu = CreatePopupMenu(); + + /* Get the menu name */ + int len = GetMenuString(hMenu, IDM_MEDIA, NULL, 0, MF_BYCOMMAND); + lpMenuName = malloc((len + 1) * sizeof(WCHAR)); + GetMenuString(hMenu, IDM_MEDIA, lpMenuName, len + 1, MF_BYCOMMAND); + + /* Replace the placeholder menu item */ + ModifyMenu(hMenu, IDM_MEDIA, MF_BYCOMMAND | MF_STRING | MF_POPUP, (UINT_PTR)media_menu, lpMenuName); + + /* Clean up */ + DrawMenuBar(hwndMain); + free(lpMenuName); +} + +void +media_menu_init() +{ + /* Initialize the main menu bar menu */ + media_menu_main_init(); + + /* Initialize the dummy status bar menu. */ + stbar_menu = CreateMenu(); + AppendMenu(stbar_menu, MF_POPUP, (UINT_PTR)media_menu, NULL); + + /* Load the submenus for each drive type. */ + media_menu_load_submenus(); + + /* Populate the Media and status bar menus. */ + media_menu_reset(); +} \ No newline at end of file From 6838117fdd6fbcca29af33690dcce78f8d4fa88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 14:19:58 +0200 Subject: [PATCH 15/28] win: Add helper methods for mounting images --- src/win/win_cdrom.c | 28 ++++++++++++++++++++++++++++ src/win/win_media_menu.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/win/win_cdrom.c b/src/win/win_cdrom.c index 82f4adbe0..3a1eecf87 100644 --- a/src/win/win_cdrom.c +++ b/src/win/win_cdrom.c @@ -77,6 +77,20 @@ mo_eject(uint8_t id) } +void +mo_mount(uint8_t id, wchar_t *fn, uint8_t wp) +{ + mo_t *dev = (mo_t *) mo_drives[id].priv; + + mo_disk_close(dev); + mo_drives[id].read_only = wp; + mo_load(dev, fn); + mo_insert(dev); + + config_save(); +} + + void mo_reload(uint8_t id) { @@ -116,6 +130,20 @@ zip_eject(uint8_t id) } +void +zip_mount(uint8_t id, wchar_t *fn, uint8_t wp) +{ + zip_t *dev = (zip_t *) zip_drives[id].priv; + + zip_disk_close(dev); + zip_drives[id].read_only = wp; + zip_load(dev, fn); + zip_insert(dev); + + config_save(); +} + + void zip_reload(uint8_t id) { diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index af5d380eb..6250d42d7 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -262,4 +262,32 @@ media_menu_init() /* Populate the Media and status bar menus. */ media_menu_reset(); +} + +static void +fdd_mount(uint8_t id, wchar_t *fn, uint8_t wp) +{ + fdd_close(id); + ui_writeprot[id] = wp; + fdd_load(id, fn); + + config_save(); +} + +static void +cdrom_mount(uint8_t id, wchar_t *fn) +{ + cdrom[id].prev_host_drive = cdrom[id].host_drive; + wcscpy(cdrom[id].prev_image_path, cdrom[id].image_path); + if (cdrom[id].ops && cdrom[id].ops->exit) + cdrom[id].ops->exit(&(cdrom[id])); + cdrom[id].ops = NULL; + memset(cdrom[id].image_path, 0, sizeof(cdrom[id].image_path)); + cdrom_image_open(&(cdrom[id]), fn); + /* Signal media change to the emulated machine. */ + if (cdrom[id].insert) + cdrom[id].insert(cdrom[id].priv); + cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200; + + config_save(); } \ No newline at end of file From 70503973ebce871bf9cebe55c260af42df86179d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 15:43:33 +0200 Subject: [PATCH 16/28] win: Add the new Media menu handler --- src/include/86box/plat.h | 2 + src/include/86box/win.h | 9 +++ src/win/win_cdrom.c | 52 +++++++++---- src/win/win_media_menu.c | 153 +++++++++++++++++++++++++++++++++++++++ src/win/win_new_floppy.c | 6 +- src/win/win_stbar.c | 2 +- 6 files changed, 206 insertions(+), 18 deletions(-) diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 25e607e0b..8a892bf7b 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -121,8 +121,10 @@ extern void do_stop(void); /* Platform-specific device support. */ extern void plat_cdrom_ui_update(uint8_t id, uint8_t reload); extern void zip_eject(uint8_t id); +extern void zip_mount(uint8_t id, wchar_t *fn, uint8_t wp); extern void zip_reload(uint8_t id); extern void mo_eject(uint8_t id); +extern void mo_mount(uint8_t id, wchar_t *fn, uint8_t wp); extern void mo_reload(uint8_t id); extern int ioctl_open(uint8_t id, char d); extern void ioctl_reset(uint8_t id); diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 2271a5803..abeffac80 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -186,6 +186,15 @@ extern int file_dlg_st(HWND hwnd, int i, char *fn, int save); extern wchar_t *BrowseFolder(wchar_t *saved_path, wchar_t *title); +/* Functions in win_media_menu.c */ +extern void media_menu_init(); +extern void media_menu_reset(); +extern void media_menu_update_floppy(int id); +extern void media_menu_update_cdrom(int id); +extern void media_menu_update_zip(int id); +extern void media_menu_update_mo(int id); + + #ifdef __cplusplus } #endif diff --git a/src/win/win_cdrom.c b/src/win/win_cdrom.c index 3a1eecf87..40bc44611 100644 --- a/src/win/win_cdrom.c +++ b/src/win/win_cdrom.c @@ -45,19 +45,39 @@ plat_cdrom_ui_update(uint8_t id, uint8_t reload) cdrom_t *drv = &cdrom[id]; if (drv->host_drive == 0) { - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED); - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED); ui_sb_update_icon_state(SB_CDROM|id, 1); } else { - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED); - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_CHECKED); ui_sb_update_icon_state(SB_CDROM|id, 0); } - ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | (reload ? MF_GRAYED : MF_ENABLED)); + media_menu_update_cdrom(id); ui_sb_update_tip(SB_CDROM|id); } +void +cdrom_mount(uint8_t id, wchar_t *fn) +{ + cdrom[id].prev_host_drive = cdrom[id].host_drive; + wcscpy(cdrom[id].prev_image_path, cdrom[id].image_path); + if (cdrom[id].ops && cdrom[id].ops->exit) + cdrom[id].ops->exit(&(cdrom[id])); + cdrom[id].ops = NULL; + memset(cdrom[id].image_path, 0, sizeof(cdrom[id].image_path)); + cdrom_image_open(&(cdrom[id]), fn); + /* Signal media change to the emulated machine. */ + if (cdrom[id].insert) + cdrom[id].insert(cdrom[id].priv); + cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200; + if (cdrom[id].host_drive == 200) { + ui_sb_update_icon_state(SB_CDROM | id, 0); + } else { + ui_sb_update_icon_state(SB_CDROM | id, 1); + } + media_menu_update_cdrom(id); + ui_sb_update_tip(SB_CDROM | id); + config_save(); +} + void mo_eject(uint8_t id) { @@ -70,8 +90,7 @@ mo_eject(uint8_t id) } ui_sb_update_icon_state(SB_MO | id, 1); - ui_sb_enable_menu_item(SB_MO|id, IDM_MO_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_enable_menu_item(SB_MO|id, IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); + media_menu_update_mo(id); ui_sb_update_tip(SB_MO | id); config_save(); } @@ -87,6 +106,10 @@ mo_mount(uint8_t id, wchar_t *fn, uint8_t wp) mo_load(dev, fn); mo_insert(dev); + ui_sb_update_icon_state(SB_MO | id, wcslen(mo_drives[id].image_path) ? 0 : 1); + media_menu_update_mo(id); + ui_sb_update_tip(SB_MO | id); + config_save(); } @@ -98,14 +121,12 @@ mo_reload(uint8_t id) mo_disk_reload(dev); if (wcslen(mo_drives[id].image_path) == 0) { - ui_sb_enable_menu_item(SB_MO|id, IDM_MO_EJECT | id, MF_BYCOMMAND | MF_GRAYED); ui_sb_update_icon_state(SB_MO|id, 1); } else { - ui_sb_enable_menu_item(SB_MO|id, IDM_MO_EJECT | id, MF_BYCOMMAND | MF_ENABLED); ui_sb_update_icon_state(SB_MO|id, 0); } - ui_sb_enable_menu_item(SB_MO|id, IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); + media_menu_update_mo(id); ui_sb_update_tip(SB_MO|id); config_save(); @@ -123,8 +144,7 @@ zip_eject(uint8_t id) } ui_sb_update_icon_state(SB_ZIP | id, 1); - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); + media_menu_update_zip(id); ui_sb_update_tip(SB_ZIP | id); config_save(); } @@ -140,6 +160,10 @@ zip_mount(uint8_t id, wchar_t *fn, uint8_t wp) zip_load(dev, fn); zip_insert(dev); + ui_sb_update_icon_state(SB_ZIP | id, wcslen(zip_drives[id].image_path) ? 0 : 1); + media_menu_update_zip(id); + ui_sb_update_tip(SB_ZIP | id); + config_save(); } @@ -151,14 +175,12 @@ zip_reload(uint8_t id) zip_disk_reload(dev); if (wcslen(zip_drives[id].image_path) == 0) { - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); ui_sb_update_icon_state(SB_ZIP|id, 1); } else { - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED); ui_sb_update_icon_state(SB_ZIP|id, 0); } - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); + media_menu_update_zip(id); ui_sb_update_tip(SB_ZIP|id); config_save(); diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 6250d42d7..02fee1497 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -14,6 +14,7 @@ #include <86box/scsi_device.h> #include <86box/mo.h> #include <86box/scsi.h> +#include <86box/ui.h> #include <86box/zip.h> #include <86box/win.h> @@ -274,6 +275,13 @@ fdd_mount(uint8_t id, wchar_t *fn, uint8_t wp) config_save(); } +static void +fdd_eject(uint8_t id) +{ + fdd_close(id); + config_save(); +} + static void cdrom_mount(uint8_t id, wchar_t *fn) { @@ -290,4 +298,149 @@ cdrom_mount(uint8_t id, wchar_t *fn) cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200; config_save(); +} + +int +media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + int id = 0, ret = 0, wp = 0; + WCHAR temp_path[1024]; + + id = LOWORD(wParam) & 0x00ff; + + switch (LOWORD(wParam) & 0xff00) { + case IDM_FLOPPY_IMAGE_NEW: + if (menus == NULL) + break; + + NewFloppyDialogCreate(hwnd, id, 0); + break; + + case IDM_FLOPPY_IMAGE_EXISTING_WP: + wp = 1; + /* FALLTHROUGH */ + case IDM_FLOPPY_IMAGE_EXISTING: + if (menus == NULL) + break; + + ret = file_dlg_w_st(hwnd, IDS_2118, floppyfns[id], 0); + if (! ret) { + fdd_mount(id, wopenfilestring, wp); + media_menu_update_floppy(id); + // TODO: status bar update + } + break; + + case IDM_FLOPPY_EJECT: + if (menus == NULL) + break; + + fdd_eject(id); + media_menu_update_floppy(id); + // TODO: status bar update + break; + + case IDM_FLOPPY_EXPORT_TO_86F: + if (menus == NULL) + break; + + ret = file_dlg_w_st(hwnd, IDS_2076, floppyfns[id], 1); + if (! ret) { + plat_pause(1); + ret = d86f_export(id, wopenfilestring); + if (!ret) + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_4108); + plat_pause(0); + } + break; + + case IDM_CDROM_MUTE: + if (menus == NULL) + break; + + cdrom[id].sound_on ^= 1; + config_save(); + media_menu_update_cdrom(id); + // TODO: status bar update + sound_cd_thread_reset(); + break; + + case IDM_CDROM_EMPTY: + if (menus == NULL) + break; + + cdrom_eject(id); + break; + + case IDM_CDROM_RELOAD: + if (menus == NULL) + break; + + cdrom_reload(id); + break; + + case IDM_CDROM_IMAGE: + if (menus == NULL) + break; + + if (!file_dlg_w_st(hwnd, IDS_2075, cdrom[id].image_path, 0)) { + cdrom_mount(id, wopenfilestring); + media_menu_update_cdrom(id); + // TODO: status bar update + } + break; + + case IDM_ZIP_IMAGE_NEW: + NewFloppyDialogCreate(hwnd, id | 0x80, 0); /* NewZIPDialogCreate */ + break; + + case IDM_ZIP_IMAGE_EXISTING_WP: + wp = 1; + /* FALLTHROUGH */ + case IDM_ZIP_IMAGE_EXISTING: + if (menus == NULL) + break; + + ret = file_dlg_w_st(hwnd, IDS_2058, zip_drives[id].image_path, 0); + if (! ret) + zip_mount(id, wopenfilestring, wp); + break; + + case IDM_ZIP_EJECT: + zip_eject(id); + break; + + case IDM_ZIP_RELOAD: + zip_reload(id); + break; + + case IDM_MO_IMAGE_NEW: + NewFloppyDialogCreate(hwnd, id | 0x80, 0); /* NewZIPDialogCreate */ + break; + + case IDM_MO_IMAGE_EXISTING_WP: + wp = 1; + /* FALLTHROUGH */ + case IDM_MO_IMAGE_EXISTING: + if (menus == NULL) + break; + + ret = file_dlg_w_st(hwnd, IDS_2125, mo_drives[id].image_path, 0); + if (! ret) + mo_mount(id, wopenfilestring, wp); + break; + + case IDM_MO_EJECT: + mo_eject(id); + break; + + case IDM_MO_RELOAD: + mo_reload(id); + break; + + default: + return(0); + } + + return(1); } \ No newline at end of file diff --git a/src/win/win_new_floppy.c b/src/win/win_new_floppy.c index 1dd3aa2c1..78c51b497 100644 --- a/src/win/win_new_floppy.c +++ b/src/win/win_new_floppy.c @@ -601,9 +601,11 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } if (ret) { if (is_zip) - ui_sb_mount_zip_img(fdd_id, sb_part, 0, fd_file_name); + //ui_sb_mount_zip_img(fdd_id, sb_part, 0, fd_file_name); + zip_mount(fdd_id, fd_file_name, 0); else - ui_sb_mount_floppy_img(fdd_id, sb_part, 0, fd_file_name); + //ui_sb_mount_floppy_img(fdd_id, sb_part, 0, fd_file_name); + floppy_mount(fdd_id, fd_file_name, 0); } else { new_floppy_msgbox(hdlg, MBX_ERROR, (wchar_t *)IDS_4108); return TRUE; diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index bdbd13f87..9b2e36d68 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -1325,7 +1325,7 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)plat_get_string(IDS_2126)); - MediaMenuCreate(hwndParent, idStatus, hInst); + //MediaMenuCreate(hwndParent, idStatus, hInst); sb_ready = 1; } From aa5014a3cedd7620ed8426c4424bf80f07f1146f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 16:56:37 +0200 Subject: [PATCH 17/28] win: Move remaining mount helper functions We might want to consider renaming win_cdrom.c to something more fitting :P --- src/include/86box/plat.h | 3 +++ src/win/win_cdrom.c | 25 +++++++++++++++++++++++++ src/win/win_media_menu.c | 35 ----------------------------------- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 8a892bf7b..32af72c32 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -119,6 +119,9 @@ extern void do_stop(void); /* Platform-specific device support. */ +extern void floppy_mount(uint8_t id, wchar_t *fn, uint8_t wp); +extern void floppy_eject(uint8_t id); +extern void cdrom_mount(uint8_t id, wchar_t *fn); extern void plat_cdrom_ui_update(uint8_t id, uint8_t reload); extern void zip_eject(uint8_t id); extern void zip_mount(uint8_t id, wchar_t *fn, uint8_t wp); diff --git a/src/win/win_cdrom.c b/src/win/win_cdrom.c index 40bc44611..f470c0a57 100644 --- a/src/win/win_cdrom.c +++ b/src/win/win_cdrom.c @@ -28,6 +28,8 @@ #include #include #include <86box/config.h> +#include <86box/timer.h> +#include <86box/fdd.h> #include <86box/hdd.h> #include <86box/scsi_device.h> #include <86box/cdrom.h> @@ -39,6 +41,29 @@ #include <86box/win.h> +void +floppy_mount(uint8_t id, wchar_t *fn, uint8_t wp) +{ + fdd_close(id); + ui_writeprot[id] = wp; + fdd_load(id, fn); + ui_sb_update_icon_state(SB_FLOPPY | id, wcslen(floppyfns[id]) ? 0 : 1); + media_menu_update_floppy(id); + ui_sb_update_tip(SB_FLOPPY | id); + config_save(); +} + +void +floppy_eject(uint8_t id) +{ + fdd_close(id); + ui_sb_update_icon_state(SB_FLOPPY | id, 1); + media_menu_update_floppy(id); + ui_sb_update_tip(SB_FLOPPY | id); + config_save(); +} + + void plat_cdrom_ui_update(uint8_t id, uint8_t reload) { diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 02fee1497..99b150f8f 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -265,41 +265,6 @@ media_menu_init() media_menu_reset(); } -static void -fdd_mount(uint8_t id, wchar_t *fn, uint8_t wp) -{ - fdd_close(id); - ui_writeprot[id] = wp; - fdd_load(id, fn); - - config_save(); -} - -static void -fdd_eject(uint8_t id) -{ - fdd_close(id); - config_save(); -} - -static void -cdrom_mount(uint8_t id, wchar_t *fn) -{ - cdrom[id].prev_host_drive = cdrom[id].host_drive; - wcscpy(cdrom[id].prev_image_path, cdrom[id].image_path); - if (cdrom[id].ops && cdrom[id].ops->exit) - cdrom[id].ops->exit(&(cdrom[id])); - cdrom[id].ops = NULL; - memset(cdrom[id].image_path, 0, sizeof(cdrom[id].image_path)); - cdrom_image_open(&(cdrom[id]), fn); - /* Signal media change to the emulated machine. */ - if (cdrom[id].insert) - cdrom[id].insert(cdrom[id].priv); - cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200; - - config_save(); -} - int media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { From 39a0f4b9ca0406d800d12a923c36e57782f3fc57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 16:59:16 +0200 Subject: [PATCH 18/28] win: Fix build --- src/win/win_media_menu.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 99b150f8f..186adc875 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -5,15 +5,19 @@ #include #include <86box/86box.h> #include <86box/cdrom.h> +#include <86box/config.h> #include <86box/device.h> #include <86box/timer.h> #include <86box/fdd.h> +#include <86box/fdd_86f.h> #include <86box/hdc.h> #include <86box/language.h> #include <86box/machine.h> #include <86box/scsi_device.h> #include <86box/mo.h> +#include <86box/plat.h> #include <86box/scsi.h> +#include <86box/sound.h> #include <86box/ui.h> #include <86box/zip.h> #include <86box/win.h> @@ -34,8 +38,9 @@ media_menu_set_ids(HMENU hMenu, int id) { int c = GetMenuItemCount(hMenu); - MENUITEMINFO mii; + MENUITEMINFO mii = { 0 }; mii.fMask = MIIM_ID; + mii.cbSize = sizeof(mii); for(int i = 0; i < c; i++) { @@ -61,7 +66,7 @@ media_menu_load_resource(wchar_t *lpName) return actual; } -static void +void media_menu_update_floppy(int id) { int i = FDD_FIRST + id; @@ -72,7 +77,7 @@ media_menu_update_floppy(int id) } } -static void +void media_menu_update_cdrom(int id) { int i = CDROM_FIRST + id; @@ -88,7 +93,7 @@ media_menu_update_cdrom(int id) } } -static void +void media_menu_update_zip(int id) { int i = ZIP_FIRST + id; @@ -102,7 +107,7 @@ media_menu_update_zip(int id) } } -static void +void media_menu_update_mo(int id) { int i = MO_FIRST + id; @@ -187,7 +192,7 @@ media_menu_reset() int c = GetMenuItemCount(media_menu); for(int i = 0; i < c; i++) - RemoveMenu(media_menu, i, TRUE); + RemoveMenu(media_menu, 0, MF_BYPOSITION); /* Add new ones. */ int curr = 0; @@ -269,7 +274,6 @@ int media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { int id = 0, ret = 0, wp = 0; - WCHAR temp_path[1024]; id = LOWORD(wParam) & 0x00ff; @@ -290,7 +294,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ret = file_dlg_w_st(hwnd, IDS_2118, floppyfns[id], 0); if (! ret) { - fdd_mount(id, wopenfilestring, wp); + floppy_mount(id, wopenfilestring, wp); media_menu_update_floppy(id); // TODO: status bar update } @@ -300,7 +304,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (menus == NULL) break; - fdd_eject(id); + floppy_eject(id); media_menu_update_floppy(id); // TODO: status bar update break; From 3d723d9135e0a0407569a83fe73da94a51401ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 17:00:06 +0200 Subject: [PATCH 19/28] win: Fix Media menuitem checkboxes and graying out --- src/win/win_media_menu.c | 42 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 186adc875..7e95ddef4 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -74,6 +74,9 @@ media_menu_update_floppy(int id) if (floppyfns[id][0] == 0x0000) { EnableMenuItem(menus[i], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(menus[i], IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_GRAYED); + } else { + EnableMenuItem(menus[i], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(menus[i], IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_ENABLED); } } @@ -83,14 +86,23 @@ media_menu_update_cdrom(int id) int i = CDROM_FIRST + id; if (! cdrom[id].sound_on) - CheckMenuItem(menus[i], IDM_CDROM_MUTE | id, MF_CHECKED); + CheckMenuItem(menus[i], IDM_CDROM_MUTE | id, MF_BYCOMMAND | MF_CHECKED); + else + CheckMenuItem(menus[i], IDM_CDROM_MUTE | id, MF_BYCOMMAND | MF_UNCHECKED); - if (cdrom[id].host_drive == 200) - CheckMenuItem(menus[i], IDM_CDROM_IMAGE | id, MF_CHECKED); - else { + if (cdrom[id].host_drive == 200) { + CheckMenuItem(menus[i], IDM_CDROM_IMAGE | id, MF_BYCOMMAND | MF_CHECKED); + CheckMenuItem(menus[i], IDM_CDROM_EMPTY | id, MF_BYCOMMAND | MF_UNCHECKED); + } else { cdrom[id].host_drive = 0; - CheckMenuItem(menus[i], IDM_CDROM_EMPTY | id, MF_CHECKED); + CheckMenuItem(menus[i], IDM_CDROM_IMAGE | id, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menus[i], IDM_CDROM_EMPTY | id, MF_BYCOMMAND | MF_CHECKED); } + + if(cdrom[id].prev_host_drive == 0) + EnableMenuItem(menus[i], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); + else + EnableMenuItem(menus[i], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); } void @@ -98,13 +110,15 @@ media_menu_update_zip(int id) { int i = ZIP_FIRST + id; - if (zip_drives[id].image_path[0] == 0x0000) { + if (zip_drives[id].image_path[0] == 0x0000) EnableMenuItem(menus[i], IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - } else { + else EnableMenuItem(menus[i], IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED); + + if(zip_drives[id].prev_image_path[0] == 0x0000) EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - } + else + EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); } void @@ -112,13 +126,15 @@ media_menu_update_mo(int id) { int i = MO_FIRST + id; - if (mo_drives[id].image_path[0] == 0x0000) { + if (mo_drives[id].image_path[0] == 0x0000) EnableMenuItem(menus[i], IDM_MO_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - } else { + else EnableMenuItem(menus[i], IDM_MO_EJECT | id, MF_BYCOMMAND | MF_ENABLED); + + if(mo_drives[id].prev_image_path[0] == 0x0000) EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - } + else + EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); } static void From 03f82fdb99b20e2ffb2a4c53d34587c184423bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 17:00:45 +0200 Subject: [PATCH 20/28] win: Replace the main menubar Media menu handler --- src/include/86box/win.h | 1 + src/win/win_stbar.c | 2 ++ src/win/win_ui.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/include/86box/win.h b/src/include/86box/win.h index abeffac80..262bb1f8a 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -189,6 +189,7 @@ extern wchar_t *BrowseFolder(wchar_t *saved_path, wchar_t *title); /* Functions in win_media_menu.c */ extern void media_menu_init(); extern void media_menu_reset(); +extern int media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); extern void media_menu_update_floppy(int id); extern void media_menu_update_cdrom(int id); extern void media_menu_update_zip(int id); diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 9b2e36d68..33039f270 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -613,6 +613,8 @@ ui_sb_update_panes(void) c_scsi = hdd_count(HDD_BUS_SCSI); do_net = network_available(); + media_menu_reset(); + if (sb_parts > 0) { for (i = 0; i < sb_parts; i++) SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)NULL); diff --git a/src/win/win_ui.c b/src/win/win_ui.c index cc4240949..5fa549e8b 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -595,7 +595,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; #endif default: - MediaMenuHandler(hwnd, message, wParam, lParam); + media_menu_proc(hwnd, message, wParam, lParam); break; } return(0); @@ -913,6 +913,7 @@ ui_init(int nCmdShow) /* Reset all menus to their defaults. */ ResetAllMenus(); + media_menu_init(); /* Make the window visible on the screen. */ ShowWindow(hwnd, nCmdShow); From e85b5549d0448cb207f88e39bd06483dd8b95b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 17:06:25 +0200 Subject: [PATCH 21/28] win: Remove junk code --- src/win/win_media_menu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 7e95ddef4..02d15475e 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -311,8 +311,6 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ret = file_dlg_w_st(hwnd, IDS_2118, floppyfns[id], 0); if (! ret) { floppy_mount(id, wopenfilestring, wp); - media_menu_update_floppy(id); - // TODO: status bar update } break; @@ -321,8 +319,6 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; floppy_eject(id); - media_menu_update_floppy(id); - // TODO: status bar update break; case IDM_FLOPPY_EXPORT_TO_86F: @@ -346,7 +342,6 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) cdrom[id].sound_on ^= 1; config_save(); media_menu_update_cdrom(id); - // TODO: status bar update sound_cd_thread_reset(); break; @@ -370,8 +365,6 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (!file_dlg_w_st(hwnd, IDS_2075, cdrom[id].image_path, 0)) { cdrom_mount(id, wopenfilestring); - media_menu_update_cdrom(id); - // TODO: status bar update } break; From 2564b6f24d03c38d10490326712efd989d786800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 17:59:17 +0200 Subject: [PATCH 22/28] win: Switched status bar to the new media menus --- src/include/86box/win.h | 4 ++++ src/win/win_media_menu.c | 24 ++++++++++++++++++++++++ src/win/win_stbar.c | 24 ++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 262bb1f8a..f73956656 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -190,6 +190,10 @@ extern wchar_t *BrowseFolder(wchar_t *saved_path, wchar_t *title); extern void media_menu_init(); extern void media_menu_reset(); extern int media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern HMENU media_menu_get_floppy(int id); +extern HMENU media_menu_get_cdrom(int id); +extern HMENU media_menu_get_zip(int id); +extern HMENU media_menu_get_mo(int id); extern void media_menu_update_floppy(int id); extern void media_menu_update_cdrom(int id); extern void media_menu_update_zip(int id); diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 02d15475e..c71c28b59 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -421,4 +421,28 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } return(1); +} + +HMENU +media_menu_get_floppy(int id) +{ + return menus[FDD_FIRST + id]; +} + +HMENU +media_menu_get_cdrom(int id) +{ + return menus[CDROM_FIRST + id]; +} + +HMENU +media_menu_get_zip(int id) +{ + return menus[ZIP_FIRST + id]; +} + +HMENU +media_menu_get_mo(int id) +{ + return menus[MO_FIRST + id]; } \ No newline at end of file diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 33039f270..fd67edad2 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -917,12 +917,32 @@ ui_sb_update_panes(void) static VOID APIENTRY StatusBarPopupMenu(HWND hwnd, POINT pt, int id) { + HMENU menu; + if (id >= (sb_parts - 1)) return; pt.x = id * SB_ICON_WIDTH; /* Justify to the left. */ pt.y = 0; /* Justify to the top. */ ClientToScreen(hwnd, (LPPOINT) &pt); - TrackPopupMenu(sb_menu_handles[id], + + switch(sb_part_meanings[id] & 0xF0) { + case SB_FLOPPY: + menu = media_menu_get_floppy(sb_part_meanings[id] & 0x0F); + break; + case SB_CDROM: + menu = media_menu_get_cdrom(sb_part_meanings[id] & 0x0F); + break; + case SB_ZIP: + menu = media_menu_get_zip(sb_part_meanings[id] & 0x0F); + break; + case SB_MO: + menu = media_menu_get_mo(sb_part_meanings[id] & 0x0F); + break; + default: + return; + } + + TrackPopupMenu(menu, TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON, pt.x, pt.y, 0, hwndSBAR, NULL); } @@ -1185,7 +1205,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_COMMAND: - MediaMenuHandler(hwnd, message, wParam, lParam); + media_menu_proc(hwnd, message, wParam, lParam); return(0); case WM_LBUTTONDOWN: From aa8bc8d620e5217556ac71be2ed086554bf90551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 18:23:52 +0200 Subject: [PATCH 23/28] win: Remove menu code from win_stbar.c --- src/include/86box/ui.h | 4 - src/win/win_stbar.c | 527 ----------------------------------------- 2 files changed, 531 deletions(-) diff --git a/src/include/86box/ui.h b/src/include/86box/ui.h index 6d6cafcd1..ce9635cf1 100644 --- a/src/include/86box/ui.h +++ b/src/include/86box/ui.h @@ -58,16 +58,12 @@ extern int ui_sb_find_part(int tag); extern void ui_sb_set_ready(int ready); extern void ui_sb_update_panes(void); extern void ui_sb_update_tip(int meaning); -extern void ui_sb_check_menu_item(int tag, int id, int chk); -extern void ui_sb_enable_menu_item(int tag, int id, int val); extern void ui_sb_timer_callback(int pane); extern void ui_sb_update_icon(int tag, int val); extern void ui_sb_update_icon_state(int tag, int active); extern void ui_sb_set_text_w(wchar_t *wstr); extern void ui_sb_set_text(char *str); extern void ui_sb_bugui(char *str); -extern void ui_sb_mount_floppy_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name); -extern void ui_sb_mount_zip_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name); #ifdef __cplusplus } diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index fd67edad2..4dbdb6f9b 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -62,8 +62,6 @@ int update_icons = 1; static LONG_PTR OriginalProcedure; -static HMENU *sb_menu_handles; -static HMENU menuSBAR; static WCHAR **sbTips; static int *iStatusWidths; static int *sb_part_meanings; @@ -72,10 +70,6 @@ static int sb_parts = 0; static int sb_ready = 0; static uint8_t sb_map[256]; -static HMENU hmenuMedia; -static HMENU *media_menu_handles; - - /* Also used by win_settings.c */ intptr_t fdd_type_to_icon(int type) @@ -120,107 +114,6 @@ hdd_count(int bus) } -static void -StatusBarCreateFloppySubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_NEW | id, - plat_get_string(IDS_2096)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING | id, - plat_get_string(IDS_2097)); - AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING_WP | id, - plat_get_string(IDS_2098)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_FLOPPY_EXPORT_TO_86F | id, - plat_get_string(IDS_2080)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_FLOPPY_EJECT | id, - plat_get_string(IDS_2093)); - - if (floppyfns[id][0] == 0x0000) { - EnableMenuItem(m, IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(m, IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_GRAYED); - } -} - - -static void -StatusBarCreateCdromSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_CDROM_MUTE | id, - plat_get_string(IDS_2092)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_CDROM_EMPTY | id, - plat_get_string(IDS_2091)); - AppendMenu(m, MF_STRING, IDM_CDROM_RELOAD | id, - plat_get_string(IDS_2090)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_CDROM_IMAGE | id, - plat_get_string(IDS_2089)); - - if (! cdrom[id].sound_on) - CheckMenuItem(m, IDM_CDROM_MUTE | id, MF_CHECKED); - - if (cdrom[id].host_drive == 200) - CheckMenuItem(m, IDM_CDROM_IMAGE | id, MF_CHECKED); - else { - cdrom[id].host_drive = 0; - CheckMenuItem(m, IDM_CDROM_EMPTY | id, MF_CHECKED); - } -} - - -static void -StatusBarCreateZIPSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_NEW | id, - plat_get_string(IDS_2096)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING | id, - plat_get_string(IDS_2097)); - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING_WP | id, - plat_get_string(IDS_2098)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_ZIP_EJECT | id, - plat_get_string(IDS_2093)); - AppendMenu(m, MF_STRING, IDM_ZIP_RELOAD | id, - plat_get_string(IDS_2090)); - - if (zip_drives[id].image_path[0] == 0x0000) { - EnableMenuItem(m, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(m, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - } else { - EnableMenuItem(m, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(m, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - } -} - -static void -StatusBarCreateMOSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_MO_IMAGE_NEW | id, - plat_get_string(IDS_2096)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_MO_IMAGE_EXISTING | id, - plat_get_string(IDS_2097)); - AppendMenu(m, MF_STRING, IDM_MO_IMAGE_EXISTING_WP | id, - plat_get_string(IDS_2098)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_MO_EJECT | id, - plat_get_string(IDS_2093)); - AppendMenu(m, MF_STRING, IDM_MO_RELOAD | id, - plat_get_string(IDS_2090)); - - if (mo_drives[id].image_path[0] == 0x0000) { - EnableMenuItem(m, IDM_MO_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(m, IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - } else { - EnableMenuItem(m, IDM_MO_EJECT | id, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(m, IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - } -} - - void ui_sb_timer_callback(int pane) { @@ -486,54 +379,10 @@ ui_sb_update_tip(int meaning) } SendMessage(hwndSBAR, SB_SETTIPTEXT, part, (LPARAM)sbTips[part]); - ModifyMenu(hmenuMedia, part, MF_BYPOSITION, (UINT_PTR)media_menu_handles[part], sbTips[part]); } } -static void -MediaMenuDestroyMenus(void) -{ - int i; - - if (sb_parts == 0) return; - - if (! media_menu_handles) return; - - for (i=0; iexit) - cdrom[id].ops->exit(&(cdrom[id])); - cdrom[id].ops = NULL; - memset(cdrom[id].image_path, 0, sizeof(cdrom[id].image_path)); - cdrom_image_open(&(cdrom[id]), temp_path); - /* Signal media change to the emulated machine. */ - if (cdrom[id].insert) - cdrom[id].insert(cdrom[id].priv); - cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200; - if (cdrom[id].host_drive == 200) { - ui_sb_check_menu_item(SB_CDROM | id, IDM_CDROM_EMPTY | id, MF_UNCHECKED); - ui_sb_check_menu_item(SB_CDROM | id, IDM_CDROM_IMAGE | id, MF_CHECKED); - ui_sb_update_icon_state(SB_CDROM | id, 0); - } else { - ui_sb_check_menu_item(SB_CDROM | id, IDM_CDROM_IMAGE | id, MF_UNCHECKED); - ui_sb_check_menu_item(SB_CDROM | id, IDM_CDROM_EMPTY | id, MF_CHECKED); - ui_sb_update_icon_state(SB_CDROM | id, 1); - } - ui_sb_enable_menu_item(SB_CDROM | id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_update_tip(SB_CDROM | id); - config_save(); - } - break; - - case IDM_ZIP_IMAGE_NEW: - id = item_params & 0x0003; - part = sb_map[SB_ZIP | id]; - NewFloppyDialogCreate(hwnd, id | 0x80, part); /* NewZIPDialogCreate */ - break; - - case IDM_ZIP_IMAGE_EXISTING: - case IDM_ZIP_IMAGE_EXISTING_WP: - id = item_params & 0x0003; - part = sb_map[SB_ZIP | id]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - break; - - ret = file_dlg_w_st(hwnd, IDS_2058, zip_drives[id].image_path, 0); - if (! ret) - ui_sb_mount_zip_img(id, part, (item_id == IDM_ZIP_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring); - break; - - case IDM_ZIP_EJECT: - id = item_params & 0x0003; - zip_eject(id); - break; - - case IDM_ZIP_RELOAD: - id = item_params & 0x0003; - zip_reload(id); - break; - - case IDM_MO_IMAGE_NEW: - id = item_params & 0x0003; - part = sb_map[SB_MO | id]; - NewFloppyDialogCreate(hwnd, id | 0x80, part); /* NewZIPDialogCreate */ - break; - - case IDM_MO_IMAGE_EXISTING: - case IDM_MO_IMAGE_EXISTING_WP: - id = item_params & 0x0003; - part = sb_map[SB_MO | id]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - break; - - ret = file_dlg_w_st(hwnd, IDS_2125, mo_drives[id].image_path, 0); - if (! ret) - ui_sb_mount_mo_img(id, part, (item_id == IDM_MO_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring); - break; - - case IDM_MO_EJECT: - id = item_params & 0x0003; - mo_eject(id); - break; - - case IDM_MO_RELOAD: - id = item_params & 0x0003; - mo_reload(id); - break; - - default: - return(0); - } - - return(1); -} - - /* Handle messages for the Status Bar window. */ #if defined(__amd64__) || defined(__aarch64__) static LRESULT CALLBACK @@ -1237,27 +776,6 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } -void -MediaMenuCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) -{ - HMENU hmenu; - LPWSTR lpMenuName; - - hmenu = GetMenu(hwndParent); - hmenuMedia = CreatePopupMenu(); - - int len = GetMenuString(hmenu, IDM_MEDIA, NULL, 0, MF_BYCOMMAND); - lpMenuName = malloc((len + 1) * sizeof(WCHAR)); - GetMenuString(hmenu, IDM_MEDIA, lpMenuName, len + 1, MF_BYCOMMAND); - - InsertMenu(hmenu, IDM_MEDIA, MF_BYCOMMAND | MF_STRING | MF_POPUP, (UINT_PTR)hmenuMedia, lpMenuName); - RemoveMenu(hmenu, IDM_MEDIA, MF_BYCOMMAND); - DrawMenuBar(hwndParent); - - free(lpMenuName); -} - - /* API: Create and set up the Status Bar window. */ void StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) @@ -1321,9 +839,6 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) rectDialog.bottom-rectDialog.top, SWP_SHOWWINDOW); - /* Load the dummu menu for this window. */ - menuSBAR = LoadMenu(hInst, SB_MENU_NAME); - /* Initialize the status bar. This is clumsy. */ sb_parts = 1; iStatusWidths = (int *)malloc(sb_parts * sizeof(int)); @@ -1332,12 +847,8 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) memset(sb_part_meanings, 0, sb_parts * sizeof(int)); sb_part_icons = (uint8_t *)malloc(sb_parts * sizeof(uint8_t)); memset(sb_part_icons, 0, sb_parts * sizeof(uint8_t)); - sb_menu_handles = (HMENU *)malloc(sb_parts * sizeof(HMENU)); - memset(sb_menu_handles, 0, sb_parts * sizeof(HMENU)); sbTips = (WCHAR **)malloc(sb_parts * sizeof(WCHAR *)); memset(sbTips, 0, sb_parts * sizeof(WCHAR *)); - media_menu_handles = (HMENU *)malloc(sb_parts * sizeof(HMENU)); - memset(media_menu_handles, 0, sb_parts * sizeof(HMENU)); sb_parts = 0; iStatusWidths[sb_parts] = -1; sb_part_meanings[sb_parts] = SB_TEXT; @@ -1347,48 +858,10 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)plat_get_string(IDS_2126)); - //MediaMenuCreate(hwndParent, idStatus, hInst); - sb_ready = 1; } -/* API (Settings) */ -void -ui_sb_check_menu_item(int tag, int id, int chk) -{ - uint8_t part; - - if (!sb_ready) - return; - - part = sb_map[tag]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - return; - - CheckMenuItem(sb_menu_handles[part], id, chk); - CheckMenuItem(media_menu_handles[part], id, chk); -} - - -/* API (Settings) */ -void -ui_sb_enable_menu_item(int tag, int id, int flg) -{ - uint8_t part; - - if (!sb_ready) - return; - - part = sb_map[tag]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - return; - - EnableMenuItem(sb_menu_handles[part], id, flg); - EnableMenuItem(media_menu_handles[part], id, flg); -} - - /* API */ void ui_sb_set_text_w(wchar_t *wstr) From 0a31013feb5477512412a1d254f5a6a1135fa60a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 18:44:41 +0200 Subject: [PATCH 24/28] win: Add actual names to the Media submenus --- src/win/win_media_menu.c | 111 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index c71c28b59..415ff22f3 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -66,6 +66,109 @@ media_menu_load_resource(wchar_t *lpName) return actual; } +static void +media_menu_set_name_floppy(int drive) +{ + wchar_t name[512], temp[512]; + MENUITEMINFO mii = { 0 }; + + mbstowcs(temp, fdd_getname(fdd_get_type(drive)), + strlen(fdd_getname(fdd_get_type(drive))) + 1); + if (wcslen(floppyfns[drive]) == 0) { + _swprintf(name, plat_get_string(IDS_2117), + drive + 1, temp, plat_get_string(IDS_2057)); + } else { + _swprintf(name, plat_get_string(IDS_2117), + drive + 1, temp, floppyfns[drive]); + } + + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING; + mii.dwTypeData = name; + + SetMenuItemInfo(media_menu, (UINT_PTR)menus[FDD_FIRST + drive], FALSE, &mii); +} + +static void +media_menu_set_name_cdrom(int drive) +{ + wchar_t name[512], *temp; + MENUITEMINFO mii = { 0 }; + + int bus = cdrom[drive].bus_type; + int id = IDS_5377 + (bus - 1); + + temp = plat_get_string(id); + + if (cdrom[drive].host_drive == 200) { + if (wcslen(cdrom[drive].image_path) == 0) + _swprintf(name, plat_get_string(IDS_5120), drive+1, temp, plat_get_string(IDS_2057)); + else + _swprintf(name, plat_get_string(IDS_5120), drive+1, temp, cdrom[drive].image_path); + } else + _swprintf(name, plat_get_string(IDS_5120), drive+1, temp, plat_get_string(IDS_2057)); + + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING; + mii.dwTypeData = name; + + SetMenuItemInfo(media_menu, (UINT_PTR)menus[CDROM_FIRST + drive], FALSE, &mii); +} + +static void +media_menu_set_name_zip(int drive) +{ + wchar_t name[512], *temp; + MENUITEMINFO mii = { 0 }; + + int bus = zip_drives[drive].bus_type; + int id = IDS_5377 + (bus - 1); + + temp = plat_get_string(id); + + int type = zip_drives[drive].is_250 ? 250 : 100; + + if (wcslen(zip_drives[drive].image_path) == 0) { + _swprintf(name, plat_get_string(IDS_2054), + type, drive+1, temp, plat_get_string(IDS_2057)); + } else { + _swprintf(name, plat_get_string(IDS_2054), + type, drive+1, temp, zip_drives[drive].image_path); + } + + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING; + mii.dwTypeData = name; + + SetMenuItemInfo(media_menu, (UINT_PTR)menus[ZIP_FIRST + drive], FALSE, &mii); +} + +static void +media_menu_set_name_mo(int drive) +{ + wchar_t name[512], *temp; + MENUITEMINFO mii = { 0 }; + + int bus = mo_drives[drive].bus_type; + int id = IDS_5377 + (bus - 1); + + temp = plat_get_string(id); + + if (wcslen(mo_drives[drive].image_path) == 0) { + _swprintf(name, plat_get_string(IDS_2124), + drive+1, temp, plat_get_string(IDS_2057)); + } else { + _swprintf(name, plat_get_string(IDS_2124), + drive+1, temp, mo_drives[drive].image_path); + } + + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING; + mii.dwTypeData = name; + + SetMenuItemInfo(media_menu, (UINT_PTR)menus[MO_FIRST + drive], FALSE, &mii); +} + void media_menu_update_floppy(int id) { @@ -78,6 +181,8 @@ media_menu_update_floppy(int id) EnableMenuItem(menus[i], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_ENABLED); EnableMenuItem(menus[i], IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_ENABLED); } + + media_menu_set_name_floppy(id); } void @@ -103,6 +208,8 @@ media_menu_update_cdrom(int id) EnableMenuItem(menus[i], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); else EnableMenuItem(menus[i], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); + + media_menu_set_name_cdrom(id); } void @@ -119,6 +226,8 @@ media_menu_update_zip(int id) EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); else EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); + + media_menu_set_name_zip(id); } void @@ -135,6 +244,8 @@ media_menu_update_mo(int id) EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); else EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); + + media_menu_set_name_mo(id); } static void From fb8d6666a72d8f693fe22bfdb54fd758faf2785f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 19:03:33 +0200 Subject: [PATCH 25/28] win: Remove string table entries for the old menus --- src/include/86box/language.h | 9 --------- src/win/86Box.rc | 9 --------- 2 files changed, 18 deletions(-) diff --git a/src/include/86box/language.h b/src/include/86box/language.h index 9b3065be9..16e5e3080 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -53,7 +53,6 @@ #define IDS_2077 2077 // "Click to capture mouse" #define IDS_2078 2078 // "Press F12-F8 to release mouse" #define IDS_2079 2079 // "Press F12-F8 or middle button.." -#define IDS_2080 2080 // "E&xport to 86F..." #define IDS_2081 2081 // "Unable to initialize Flui.." #define IDS_2082 2082 // "Bus" #define IDS_2083 2083 // "File" @@ -62,16 +61,8 @@ #define IDS_2086 2086 // "S" #define IDS_2087 2087 // "MB" #define IDS_2088 2088 // "Check BPB" -#define IDS_2089 2089 // "&Image..." -#define IDS_2090 2090 // "&Reload previous image" -#define IDS_2091 2091 // "E&mpty" -#define IDS_2092 2092 // "&Mute" -#define IDS_2093 2093 // "E&ject" #define IDS_2094 2094 // "KB" #define IDS_2095 2095 // "Neither DirectDraw nor Dire.." -#define IDS_2096 2096 // "&New image..." -#define IDS_2097 2097 // "&Existing image..." -#define IDS_2098 2098 // "Existing image (&Write-pr..." #define IDS_2099 2099 // "Default" #define IDS_2100 2100 // "%i Wait state(s)" #define IDS_2101 2101 // "Type" diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 5e2038059..fdff75044 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -926,7 +926,6 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_2080 "E&xport to 86F..." IDS_2081 "Unable to initialize FluidSynth, libfluidsynth.dll is required" IDS_2082 "Bus" IDS_2083 "File" @@ -935,16 +934,8 @@ BEGIN IDS_2086 "S" IDS_2087 "MB" IDS_2088 "Check BPB" - IDS_2089 "&Image..." - IDS_2090 "&Reload previous image" - IDS_2091 "E&mpty" - IDS_2092 "&Mute" - IDS_2093 "E&ject" IDS_2094 "KB" IDS_2095 "86Box could not initialize the video renderer." - IDS_2096 "&New image..." - IDS_2097 "&Existing image..." - IDS_2098 "Existing image (&Write-protected)..." IDS_2099 "Default" IDS_2100 "%i Wait state(s)" IDS_2101 "Type" From 7d2f9189d33bfe24e2a1e92b49190372f601178b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 19:22:13 +0200 Subject: [PATCH 26/28] win: Re-number string table entries --- src/config.c | 4 +- src/include/86box/language.h | 76 ++++++++++++++++++------------------ src/network/network.c | 2 +- src/printer/prt_escp.c | 4 +- src/printer/prt_ps.c | 2 +- src/sound/midi_fluidsynth.c | 2 +- src/win/86Box.rc | 76 ++++++++++++++++++------------------ src/win/win_media_menu.c | 12 +++--- src/win/win_settings.c | 40 +++++++++---------- src/win/win_stbar.c | 10 ++--- src/win/win_ui.c | 16 ++++---- 11 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/config.c b/src/config.c index 0d3b13a29..1267cd91c 100644 --- a/src/config.c +++ b/src/config.c @@ -709,9 +709,9 @@ load_network(void) if (p != NULL) { if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) { if ((network_ndev == 1) && strcmp(network_host, "none")) { - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2103); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2094); } else if (network_dev_to_id(p) == -1) { - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2104); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2095); } strcpy(network_host, "none"); diff --git a/src/include/86box/language.h b/src/include/86box/language.h index 16e5e3080..582aa0b70 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -53,44 +53,44 @@ #define IDS_2077 2077 // "Click to capture mouse" #define IDS_2078 2078 // "Press F12-F8 to release mouse" #define IDS_2079 2079 // "Press F12-F8 or middle button.." -#define IDS_2081 2081 // "Unable to initialize Flui.." -#define IDS_2082 2082 // "Bus" -#define IDS_2083 2083 // "File" -#define IDS_2084 2084 // "C" -#define IDS_2085 2085 // "H" -#define IDS_2086 2086 // "S" -#define IDS_2087 2087 // "MB" -#define IDS_2088 2088 // "Check BPB" -#define IDS_2094 2094 // "KB" -#define IDS_2095 2095 // "Neither DirectDraw nor Dire.." -#define IDS_2099 2099 // "Default" -#define IDS_2100 2100 // "%i Wait state(s)" -#define IDS_2101 2101 // "Type" -#define IDS_2102 2102 // "PCap failed to set up.." -#define IDS_2103 2103 // "No PCap devices found" -#define IDS_2104 2104 // "Invalid PCap device" -#define IDS_2105 2105 // "Standard 2-button joystick(s)" -#define IDS_2106 2106 // "Standard 4-button joystick" -#define IDS_2107 2107 // "Standard 6-button joystick" -#define IDS_2108 2108 // "Standard 8-button joystick" -#define IDS_2109 2109 // "CH Flightstick Pro" -#define IDS_2110 2110 // "Microsoft SideWinder Pad" -#define IDS_2111 2111 // "Thrustmaster Flight Cont.." -#define IDS_2112 2112 // "None" -#define IDS_2113 2113 // "Unable to load Accelerators" -#define IDS_2114 2114 // "Unable to register Raw Input" -#define IDS_2115 2115 // "%u" -#define IDS_2116 2116 // "%u MB (CHS: %i, %i, %i)" -#define IDS_2117 2117 // "Floppy %i (%s): %ls" -#define IDS_2118 2118 // "All floppy images (*.0??;*.." -#define IDS_2119 2119 // "Unable to initialize Free.." -#define IDS_2120 2120 // "Unable to initialize SDL..." -#define IDS_2121 2121 // "Are you sure you want to..." -#define IDS_2122 2122 // "Are you sure you want to..." -#define IDS_2123 2123 // "Unable to initialize Ghostscript..." -#define IDS_2124 2124 // "MO %i (%03i): %ls" -#define IDS_2125 2125 // "MO images (*.IM?)\0*.IM..." -#define IDS_2126 2126 // "Welcome to 86Box!" +#define IDS_2080 2080 // "Unable to initialize Flui.." +#define IDS_2081 2081 // "Bus" +#define IDS_2082 2082 // "File" +#define IDS_2083 2083 // "C" +#define IDS_2084 2084 // "H" +#define IDS_2085 2085 // "S" +#define IDS_2086 2086 // "MB" +#define IDS_2087 2087 // "Check BPB" +#define IDS_2088 2088 // "KB" +#define IDS_2089 2089 // "Neither DirectDraw nor Dire.." +#define IDS_2090 2090 // "Default" +#define IDS_2091 2091 // "%i Wait state(s)" +#define IDS_2092 2092 // "Type" +#define IDS_2093 2093 // "PCap failed to set up.." +#define IDS_2094 2094 // "No PCap devices found" +#define IDS_2095 2095 // "Invalid PCap device" +#define IDS_2096 2096 // "Standard 2-button joystick(s)" +#define IDS_2097 2097 // "Standard 4-button joystick" +#define IDS_2098 2098 // "Standard 6-button joystick" +#define IDS_2099 2099 // "Standard 8-button joystick" +#define IDS_2100 2100 // "CH Flightstick Pro" +#define IDS_2101 2101 // "Microsoft SideWinder Pad" +#define IDS_2102 2102 // "Thrustmaster Flight Cont.." +#define IDS_2103 2103 // "None" +#define IDS_2104 2104 // "Unable to load Accelerators" +#define IDS_2105 2105 // "Unable to register Raw Input" +#define IDS_2106 2106 // "%u" +#define IDS_2107 2107 // "%u MB (CHS: %i, %i, %i)" +#define IDS_2108 2108 // "Floppy %i (%s): %ls" +#define IDS_2109 2109 // "All floppy images (*.0??;*.." +#define IDS_2110 2110 // "Unable to initialize Free.." +#define IDS_2111 2111 // "Unable to initialize SDL..." +#define IDS_2112 2112 // "Are you sure you want to..." +#define IDS_2113 2113 // "Are you sure you want to..." +#define IDS_2114 2114 // "Unable to initialize Ghostscript..." +#define IDS_2115 2115 // "MO %i (%03i): %ls" +#define IDS_2116 2116 // "MO images (*.IM?)\0*.IM..." +#define IDS_2117 2117 // "Welcome to 86Box!" #define IDS_4096 4096 // "Hard disk (%s)" #define IDS_4097 4097 // "%01i:%01i" diff --git a/src/network/network.c b/src/network/network.c index 4273cf6fb..eaf317f89 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -328,7 +328,7 @@ network_reset(void) if (i < 0) { /* Tell user we can't do this (at the moment.) */ - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2102); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2093); // FIXME: we should ask in the dialog if they want to // reconfigure or quit, and throw them into the diff --git a/src/printer/prt_escp.c b/src/printer/prt_escp.c index 93a628f5b..9cfc2a762 100644 --- a/src/printer/prt_escp.c +++ b/src/printer/prt_escp.c @@ -2036,7 +2036,7 @@ escp_init(void *lpt) if (ft_handle == NULL) { ft_handle = dynld_module(fn, ft_imports); if (ft_handle == NULL) { - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2119); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2110); return(NULL); } } @@ -2044,7 +2044,7 @@ escp_init(void *lpt) /* Initialize FreeType. */ if (ft_lib == NULL) { if (ft_Init_FreeType(&ft_lib)) { - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2119); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2110); dynld_close(ft_lib); ft_lib = NULL; return(NULL); diff --git a/src/printer/prt_ps.c b/src/printer/prt_ps.c index 8057213eb..b822ff17a 100644 --- a/src/printer/prt_ps.c +++ b/src/printer/prt_ps.c @@ -352,7 +352,7 @@ ps_init(void *lpt) /* Try loading the DLL. */ ghostscript_handle = dynld_module(PATH_GHOSTSCRIPT_DLL, ghostscript_imports); if (ghostscript_handle == NULL) { - ui_msgbox(MBX_ERROR, (wchar_t *) IDS_2123); + ui_msgbox(MBX_ERROR, (wchar_t *) IDS_2114); } else { if (gsapi_revision(&rev, sizeof(rev)) == 0) { pclog("Loaded %s, rev %ld (%ld)\n", rev.product, rev.revision, rev.revisiondate); diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index bc18027e6..11c4a8b57 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -230,7 +230,7 @@ void* fluidsynth_init(const device_t *info) #endif if (fluidsynth_handle == NULL) { - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2081); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2080); return NULL; } diff --git a/src/win/86Box.rc b/src/win/86Box.rc index fdff75044..068f8d6ed 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -926,44 +926,44 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_2081 "Unable to initialize FluidSynth, libfluidsynth.dll is required" - IDS_2082 "Bus" - IDS_2083 "File" - IDS_2084 "C" - IDS_2085 "H" - IDS_2086 "S" - IDS_2087 "MB" - IDS_2088 "Check BPB" - IDS_2094 "KB" - IDS_2095 "86Box could not initialize the video renderer." - IDS_2099 "Default" - IDS_2100 "%i Wait state(s)" - IDS_2101 "Type" - IDS_2102 "PCap failed to set up because it may not be initialized" - IDS_2103 "No PCap devices found" - IDS_2104 "Invalid PCap device" - IDS_2105 "Standard 2-button joystick(s)" - IDS_2106 "Standard 4-button joystick" - IDS_2107 "Standard 6-button joystick" - IDS_2108 "Standard 8-button joystick" - IDS_2109 "CH Flightstick Pro" - IDS_2110 "Microsoft SideWinder Pad" - IDS_2111 "Thrustmaster Flight Control System" - IDS_2112 "None" - IDS_2113 "Unable to load Keyboard Accelerators!" - IDS_2114 "Unable to register Raw Input!" - IDS_2115 "%u" - IDS_2116 "%u MB (CHS: %i, %i, %i)" - IDS_2117 "Floppy %i (%s): %ls" - IDS_2118 "All images (*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.MFM;*.XDF)\0*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.MFM;*.XDF\0Advanced sector images (*.IMD;*.JSON;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector images (*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?)\0*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?\0Flux images (*.FDI)\0*.FDI\0Surface images (*.86F;*.MFM)\0*.86F;*.MFM\0All files (*.*)\0*.*\0" - IDS_2119 "Unable to initialize FreeType, freetype.dll is required" - IDS_2120 "Unable to initialize SDL, SDL2.dll is required" - IDS_2121 "Are you sure you want to hard reset the emulated machine?" - IDS_2122 "Are you sure you want to quit 86Box?" - IDS_2123 "Unable to initialize Ghostscript, gsdll32.dll is required for automatic convertion of PostScript files to PDF.\n\nAny documents sent to the generic PostScript printer will be saved as PostScript files (.ps)." - IDS_2124 "MO %i (%03i): %ls" - IDS_2125 "MO images (*.IM?)\0*.IM?\0All files (*.*)\0*.*\0" - IDS_2126 "Welcome to 86Box!" + IDS_2080 "Unable to initialize FluidSynth, libfluidsynth.dll is required" + IDS_2081 "Bus" + IDS_2082 "File" + IDS_2083 "C" + IDS_2084 "H" + IDS_2085 "S" + IDS_2086 "MB" + IDS_2087 "Check BPB" + IDS_2088 "KB" + IDS_2089 "86Box could not initialize the video renderer." + IDS_2090 "Default" + IDS_2091 "%i Wait state(s)" + IDS_2092 "Type" + IDS_2093 "PCap failed to set up because it may not be initialized" + IDS_2094 "No PCap devices found" + IDS_2095 "Invalid PCap device" + IDS_2096 "Standard 2-button joystick(s)" + IDS_2097 "Standard 4-button joystick" + IDS_2098 "Standard 6-button joystick" + IDS_2099 "Standard 8-button joystick" + IDS_2100 "CH Flightstick Pro" + IDS_2101 "Microsoft SideWinder Pad" + IDS_2102 "Thrustmaster Flight Control System" + IDS_2103 "None" + IDS_2104 "Unable to load Keyboard Accelerators!" + IDS_2105 "Unable to register Raw Input!" + IDS_2106 "%u" + IDS_2107 "%u MB (CHS: %i, %i, %i)" + IDS_2108 "Floppy %i (%s): %ls" + IDS_2109 "All images (*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.MFM;*.XDF)\0*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.MFM;*.XDF\0Advanced sector images (*.IMD;*.JSON;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector images (*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?)\0*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.D??;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?\0Flux images (*.FDI)\0*.FDI\0Surface images (*.86F;*.MFM)\0*.86F;*.MFM\0All files (*.*)\0*.*\0" + IDS_2110 "Unable to initialize FreeType, freetype.dll is required" + IDS_2111 "Unable to initialize SDL, SDL2.dll is required" + IDS_2112 "Are you sure you want to hard reset the emulated machine?" + IDS_2113 "Are you sure you want to quit 86Box?" + IDS_2114 "Unable to initialize Ghostscript, gsdll32.dll is required for automatic convertion of PostScript files to PDF.\n\nAny documents sent to the generic PostScript printer will be saved as PostScript files (.ps)." + IDS_2115 "MO %i (%03i): %ls" + IDS_2116 "MO images (*.IM?)\0*.IM?\0All files (*.*)\0*.*\0" + IDS_2117 "Welcome to 86Box!" END STRINGTABLE DISCARDABLE diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 415ff22f3..cdd4b90ac 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -75,10 +75,10 @@ media_menu_set_name_floppy(int drive) mbstowcs(temp, fdd_getname(fdd_get_type(drive)), strlen(fdd_getname(fdd_get_type(drive))) + 1); if (wcslen(floppyfns[drive]) == 0) { - _swprintf(name, plat_get_string(IDS_2117), + _swprintf(name, plat_get_string(IDS_2108), drive + 1, temp, plat_get_string(IDS_2057)); } else { - _swprintf(name, plat_get_string(IDS_2117), + _swprintf(name, plat_get_string(IDS_2108), drive + 1, temp, floppyfns[drive]); } @@ -155,10 +155,10 @@ media_menu_set_name_mo(int drive) temp = plat_get_string(id); if (wcslen(mo_drives[drive].image_path) == 0) { - _swprintf(name, plat_get_string(IDS_2124), + _swprintf(name, plat_get_string(IDS_2115), drive+1, temp, plat_get_string(IDS_2057)); } else { - _swprintf(name, plat_get_string(IDS_2124), + _swprintf(name, plat_get_string(IDS_2115), drive+1, temp, mo_drives[drive].image_path); } @@ -419,7 +419,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (menus == NULL) break; - ret = file_dlg_w_st(hwnd, IDS_2118, floppyfns[id], 0); + ret = file_dlg_w_st(hwnd, IDS_2109, floppyfns[id], 0); if (! ret) { floppy_mount(id, wopenfilestring, wp); } @@ -514,7 +514,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (menus == NULL) break; - ret = file_dlg_w_st(hwnd, IDS_2125, mo_drives[id].image_path, 0); + ret = file_dlg_w_st(hwnd, IDS_2116, mo_drives[id].image_path, 0); if (! ret) mo_mount(id, wopenfilestring, wp); break; diff --git a/src/win/win_settings.c b/src/win/win_settings.c index b34afd943..27b415695 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -625,11 +625,11 @@ win_settings_machine_recalc_machine(HWND hdlg) if (!(machines[temp_machine].flags & MACHINE_AT) || (machines[temp_machine].ram_granularity >= 128)) { SendMessage(h, UDM_SETPOS, 0, temp_mem_size); h = GetDlgItem(hdlg, IDC_TEXT_MB); - SendMessage(h, WM_SETTEXT, 0, win_get_string(IDS_2094)); + SendMessage(h, WM_SETTEXT, 0, win_get_string(IDS_2088)); } else { SendMessage(h, UDM_SETPOS, 0, temp_mem_size / 1024); h = GetDlgItem(hdlg, IDC_TEXT_MB); - SendMessage(h, WM_SETTEXT, 0, win_get_string(IDS_2087)); + SendMessage(h, WM_SETTEXT, 0, win_get_string(IDS_2086)); } free(lptsTemp); @@ -668,7 +668,7 @@ win_settings_machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_SETCURSEL, machinetolist[temp_machine], 0); h = GetDlgItem(hdlg, IDC_COMBO_WS); - SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2099)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2090)); for (c = 0; c < 8; c++) { wsprintf(lptsTemp, plat_get_string(2100), c); @@ -1155,7 +1155,7 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (device_is_valid(sound_dev, machines[temp_machine].flags)) { if (c == 0) - SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2112)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2103)); else { mbstowcs(lptsTemp, s, strlen(s) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); @@ -1186,7 +1186,7 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (midi_device_available(c)) { if (c == 0) - SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2112)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2103)); else { mbstowcs(lptsTemp, s, strlen(s) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); @@ -1217,7 +1217,7 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (midi_in_device_available(c)) { if (c == 0) - SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2112)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2103)); else { mbstowcs(lptsTemp, s, strlen(s) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); @@ -1426,7 +1426,7 @@ win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) break; if (c == 0) - SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2112)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2103)); else { mbstowcs(lptsTemp, s, strlen(s) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); @@ -1582,7 +1582,7 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa if (device_is_valid(scsi_dev, machines[temp_machine].flags)) { if (c == 0) - SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2112)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2103)); else { mbstowcs(lptsTemp, s, strlen(s) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); @@ -1637,7 +1637,7 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa if (d == 0) { /* Translate "None". */ - SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2112)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2103)); } else { mbstowcs(lptsTemp, s, strlen(s) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); @@ -1664,7 +1664,7 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa if (d == 0) { /* Translate "None". */ SendMessage(h, CB_ADDSTRING, 0, - (LPARAM)win_get_string(IDS_2112)); + (LPARAM)win_get_string(IDS_2103)); } else { s = (char *) isamem_get_name(d); mbstowcs(lptsTemp, s, strlen(s) + 1); @@ -2491,7 +2491,7 @@ win_settings_hard_disks_init_columns(HWND hwndList) for (iCol = 0; iCol < C_COLUMNS_HARD_DISKS; iCol++) { lvc.iSubItem = iCol; - lvc.pszText = plat_get_string(IDS_2082 + iCol); + lvc.pszText = plat_get_string(IDS_2081 + iCol); switch(iCol) { case 0: /* Bus */ @@ -2556,7 +2556,7 @@ set_edit_box_contents(HWND hdlg, int id, uint32_t val) WCHAR szText[256]; h = GetDlgItem(hdlg, id); - wsprintf(szText, plat_get_string(IDS_2115), val); + wsprintf(szText, plat_get_string(IDS_2106), val); SendMessage(h, WM_SETTEXT, (WPARAM) wcslen(szText), (LPARAM) szText); } @@ -2575,7 +2575,7 @@ static int hdconf_initialize_hdt_combo(HWND hdlg) 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_2116), size_mb, hdd_table[i][0], hdd_table[i][1], hdd_table[i][2]); + wsprintf(szText, plat_get_string(IDS_2107), size_mb, hdd_table[i][0], hdd_table[i][1], hdd_table[i][2]); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) szText); if ((tracks == (int) hdd_table[i][0]) && (hpc == (int) hdd_table[i][1]) && (spt == (int) hdd_table[i][2])) @@ -3593,7 +3593,7 @@ win_settings_cdrom_drives_recalc_list(HWND hwndList) lvI.iSubItem = 1; if (temp_cdrom[i].bus_type == CDROM_BUS_DISABLED) - lvI.pszText = plat_get_string(IDS_2112); + lvI.pszText = plat_get_string(IDS_2103); else { wsprintf(szText, L"%ix", temp_cdrom[i].speed); lvI.pszText = szText; @@ -3667,7 +3667,7 @@ win_settings_floppy_drives_init_columns(HWND hwndList) lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.iSubItem = 0; - lvc.pszText = plat_get_string(IDS_2101); + lvc.pszText = plat_get_string(IDS_2092); lvc.cx = 292; lvc.fmt = LVCFMT_LEFT; @@ -3685,7 +3685,7 @@ win_settings_floppy_drives_init_columns(HWND hwndList) return FALSE; lvc.iSubItem = 2; - lvc.pszText = plat_get_string(IDS_2088); + lvc.pszText = plat_get_string(IDS_2087); lvc.cx = 75; lvc.fmt = LVCFMT_LEFT; @@ -3705,7 +3705,7 @@ win_settings_cdrom_drives_init_columns(HWND hwndList) lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.iSubItem = 0; - lvc.pszText = plat_get_string(IDS_2082); + lvc.pszText = plat_get_string(IDS_2081); lvc.cx = 342; lvc.fmt = LVCFMT_LEFT; @@ -3734,7 +3734,7 @@ win_settings_zip_drives_init_columns(HWND hwndList) lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.iSubItem = 0; - lvc.pszText = plat_get_string(IDS_2082); + lvc.pszText = plat_get_string(IDS_2081); lvc.cx = 342; lvc.fmt = LVCFMT_LEFT; @@ -3743,7 +3743,7 @@ win_settings_zip_drives_init_columns(HWND hwndList) return FALSE; lvc.iSubItem = 1; - lvc.pszText = plat_get_string(IDS_2101); + lvc.pszText = plat_get_string(IDS_2092); lvc.cx = 50; lvc.fmt = LVCFMT_LEFT; @@ -3857,7 +3857,7 @@ win_settings_cdrom_drives_update_item(HWND hwndList, int i) lvI.iSubItem = 1; if (temp_cdrom[i].bus_type == CDROM_BUS_DISABLED) - lvI.pszText = plat_get_string(IDS_2112); + lvI.pszText = plat_get_string(IDS_2103); else { wsprintf(szText, L"%ix", temp_cdrom[i].speed); lvI.pszText = szText; diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 4dbdb6f9b..f509b45a5 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -183,10 +183,10 @@ StatusBarCreateFloppyTip(int part) mbstowcs(wtext, fdd_getname(fdd_get_type(drive)), strlen(fdd_getname(fdd_get_type(drive))) + 1); if (wcslen(floppyfns[drive]) == 0) { - _swprintf(tempTip, plat_get_string(IDS_2117), + _swprintf(tempTip, plat_get_string(IDS_2108), drive+1, wtext, plat_get_string(IDS_2057)); } else { - _swprintf(tempTip, plat_get_string(IDS_2117), + _swprintf(tempTip, plat_get_string(IDS_2108), drive+1, wtext, floppyfns[drive]); } @@ -271,10 +271,10 @@ StatusBarCreateMOTip(int part) szText = plat_get_string(id); if (wcslen(mo_drives[drive].image_path) == 0) { - _swprintf(tempTip, plat_get_string(IDS_2124), + _swprintf(tempTip, plat_get_string(IDS_2115), drive+1, szText, plat_get_string(IDS_2057)); } else { - _swprintf(tempTip, plat_get_string(IDS_2124), + _swprintf(tempTip, plat_get_string(IDS_2115), drive+1, szText, mo_drives[drive].image_path); } @@ -856,7 +856,7 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) sb_parts++; SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)sb_parts, (LPARAM)iStatusWidths); SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS, - (LPARAM)plat_get_string(IDS_2126)); + (LPARAM)plat_get_string(IDS_2117)); sb_ready = 1; } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 5fa549e8b..4c2e46f3a 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -312,7 +312,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_ACTION_HRESET: win_notify_dlg_open(); - i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121); + i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2112); if (i == 0) pc_reset(1); win_notify_dlg_closed(); @@ -327,7 +327,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (no_quit_confirm) i = 0; else - i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); + i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2113); if (i == 0) { UnhookWindowsHookEx(hKeyboardHook); KillTimer(hwnd, TIMER_1SEC); @@ -695,7 +695,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (no_quit_confirm) i = 0; else - i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); + i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2113); if (i == 0) { UnhookWindowsHookEx(hKeyboardHook); KillTimer(hwnd, TIMER_1SEC); @@ -731,7 +731,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (manager_wm) break; win_notify_dlg_open(); - i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121); + i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2112); if (i == 0) pc_reset(1); win_notify_dlg_closed(); @@ -744,7 +744,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (no_quit_confirm) i = 0; else - i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); + i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2113); if (i == 0) { UnhookWindowsHookEx(hKeyboardHook); KillTimer(hwnd, TIMER_1SEC); @@ -926,7 +926,7 @@ ui_init(int nCmdShow) ridev.hwndTarget = NULL; /* current focus window */ if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) { MessageBox(hwndMain, - plat_get_string(IDS_2114), + plat_get_string(IDS_2105), plat_get_string(IDS_2050), MB_OK | MB_ICONERROR); return(4); @@ -940,7 +940,7 @@ ui_init(int nCmdShow) haccel = LoadAccelerators(hinstance, ACCEL_NAME); if (haccel == NULL) { MessageBox(hwndMain, - plat_get_string(IDS_2113), + plat_get_string(IDS_2104), plat_get_string(IDS_2050), MB_OK | MB_ICONERROR); return(3); @@ -982,7 +982,7 @@ ui_init(int nCmdShow) /* Initialize the configured Video API. */ if (! plat_setvid(vid_api)) { MessageBox(hwnd, - plat_get_string(IDS_2095), + plat_get_string(IDS_2089), plat_get_string(IDS_2050), MB_OK | MB_ICONERROR); return(5); From 66bf3e2f683d561620b755bc1bb849bf921609e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 19:27:33 +0200 Subject: [PATCH 27/28] win: Fix STR_NUM_2048 --- src/include/86box/language.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/86box/language.h b/src/include/86box/language.h index 582aa0b70..b95f692f7 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -169,7 +169,7 @@ #define IDS_LANG_ENUS IDS_7168 -#define STR_NUM_2048 79 +#define STR_NUM_2048 70 #define STR_NUM_3072 11 #define STR_NUM_4096 18 #define STR_NUM_4352 7 From fb8c96189e30840f4d1627885bd0b024c451e92d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 21:59:22 +0200 Subject: [PATCH 28/28] win: Fix hardcoded resource IDs --- src/win/win_settings.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 27b415695..413fe2daf 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -671,7 +671,7 @@ win_settings_machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2090)); for (c = 0; c < 8; c++) { - wsprintf(lptsTemp, plat_get_string(2100), c); + wsprintf(lptsTemp, plat_get_string(IDS_2091), c); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); } @@ -1009,7 +1009,7 @@ win_settings_input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) mbstowcs(str, joy_name, strlen(joy_name) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)str); - // SendMessage(h, CB_ADDSTRING, 0, win_get_string(2105 + c)); + // SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2096 + c)); c++; joy_name = joystick_get_name(c); } @@ -1663,8 +1663,7 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa if (d == 0) { /* Translate "None". */ - SendMessage(h, CB_ADDSTRING, 0, - (LPARAM)win_get_string(IDS_2103)); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_2103)); } else { s = (char *) isamem_get_name(d); mbstowcs(lptsTemp, s, strlen(s) + 1); @@ -1922,7 +1921,7 @@ win_settings_network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (network_card_available(c) && device_is_valid(network_card_getdevice(c), machines[temp_machine].flags)) { if (c == 0) - SendMessage(h, CB_ADDSTRING, 0, win_get_string(2112)); + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2103)); else { mbstowcs(lptsTemp, s, strlen(s) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);