diff --git a/src/CPU/386_dynarec.c b/src/CPU/386_dynarec.c index a362f50da..c59110cd6 100644 --- a/src/CPU/386_dynarec.c +++ b/src/CPU/386_dynarec.c @@ -1426,7 +1426,7 @@ void exec386_dynarec(int cycs) { uint64_t mask = (uint64_t)1 << ((phys_addr >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK); - if (page->code_present_mask & mask) + if (page->code_present_mask[(phys_addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK] & mask) { /*Walk page tree to see if we find the correct block*/ codeblock_t *new_block = codeblock_tree_find(phys_addr, cs); @@ -1439,10 +1439,11 @@ void exec386_dynarec(int cycs) } } } - if (valid_block && (block->page_mask & page->dirty_mask)) + + if (valid_block && (block->page_mask & *block->dirty_mask)) { - codegen_check_flush(page, page->dirty_mask, phys_addr); - page->dirty_mask = 0; + codegen_check_flush(page, page->dirty_mask[(phys_addr >> 10) & 3], phys_addr); + page->dirty_mask[(phys_addr >> 10) & 3] = 0; if (!block->pc) valid_block = 0; } @@ -1455,15 +1456,15 @@ void exec386_dynarec(int cycs) allow the first page to be interpreted and for the page fault to occur when the page boundary is actually crossed.*/ - uint32_t phys_addr_2 = get_phys_noabrt(block->endpc) & ~0xfff; + uint32_t phys_addr_2 = get_phys_noabrt(block->endpc); page_t *page_2 = &pages[phys_addr_2 >> 12]; if ((block->phys_2 ^ phys_addr_2) & ~0xfff) valid_block = 0; - else if (block->page_mask2 & page_2->dirty_mask) + else if (block->page_mask2 & *block->dirty_mask2) { - codegen_check_flush(page_2, page_2->dirty_mask, phys_addr_2); - page_2->dirty_mask = 0; + codegen_check_flush(page_2, page_2->dirty_mask[(phys_addr_2 >> 10) & 3], phys_addr_2); + page_2->dirty_mask[(phys_addr_2 >> 10) & 3] = 0; if (!block->pc) valid_block = 0; } @@ -1537,7 +1538,7 @@ inrecomp=0; will prevent any block from spanning more than 2 pages. In practice this limit will never be hit, as host block size is only 2kB*/ - if ((cpu_state.pc - start_pc) > 4000) + if ((cpu_state.pc - start_pc) > 1000) CPU_BLOCK_END(); if (trap) @@ -1605,7 +1606,7 @@ inrecomp=0; will prevent any block from spanning more than 2 pages. In practice this limit will never be hit, as host block size is only 2kB*/ - if ((cpu_state.pc - start_pc) > 4000) + if ((cpu_state.pc - start_pc) > 1000) CPU_BLOCK_END(); if (trap) diff --git a/src/CPU/808x.c b/src/CPU/808x.c index 32a52e955..faa951409 100644 --- a/src/CPU/808x.c +++ b/src/CPU/808x.c @@ -34,6 +34,7 @@ #include "../mem.h" #include "../nmi.h" #include "../pic.h" +#include "../scsi.h" #include "../timer.h" int xt_cpu_multi; @@ -599,6 +600,7 @@ void resetx86() codegen_reset(); x86_was_reset = 1; port_92_clear_reset(); + scsi_card_reset(); } void softresetx86() @@ -618,6 +620,7 @@ void softresetx86() x86seg_reset(); x86_was_reset = 1; port_92_clear_reset(); + scsi_card_reset(); } static void setznp8(uint8_t val) diff --git a/src/CPU/codegen.h b/src/CPU/codegen.h index 5a076db8f..e86919c3a 100644 --- a/src/CPU/codegen.h +++ b/src/CPU/codegen.h @@ -1,4 +1,4 @@ -#include "mem.h" +#include "../mem.h" #ifdef __amd64__ #include "codegen_x86-64.h" @@ -36,6 +36,7 @@ typedef struct codeblock_t { uint64_t page_mask, page_mask2; + uint64_t *dirty_mask, *dirty_mask2; uint64_t cmp; /*Previous and next pointers, for the codeblock list associated with @@ -236,8 +237,10 @@ static __inline void codeblock_tree_delete(codeblock_t *block) } } +#define PAGE_MASK_INDEX_MASK 3 +#define PAGE_MASK_INDEX_SHIFT 10 #define PAGE_MASK_MASK 63 -#define PAGE_MASK_SHIFT 6 +#define PAGE_MASK_SHIFT 4 extern codeblock_t *codeblock; diff --git a/src/CPU/codegen_ops_x86-64.h b/src/CPU/codegen_ops_x86-64.h index e85f5315f..4805be498 100644 --- a/src/CPU/codegen_ops_x86-64.h +++ b/src/CPU/codegen_ops_x86-64.h @@ -5504,7 +5504,7 @@ static void MEM_CHECK_WRITE_W(x86seg *seg) { addbyte(0x83); /*CMP writelookup2[RSI*8],-1*/ addbyte(0x3c); - addbyte(0xfd); + addbyte(0xf5); addlong((uint32_t)writelookup2); addbyte(-1); } @@ -5653,7 +5653,7 @@ static void MEM_CHECK_WRITE_L(x86seg *seg) { addbyte(0x83); /*CMP writelookup2[RSI*8],-1*/ addbyte(0x3c); - addbyte(0xfd); + addbyte(0xf5); addlong((uint32_t)writelookup2); addbyte(-1); } diff --git a/src/CPU/codegen_x86-64.c b/src/CPU/codegen_x86-64.c index c5214bd4b..3ce22d95e 100644 --- a/src/CPU/codegen_x86-64.c +++ b/src/CPU/codegen_x86-64.c @@ -87,7 +87,6 @@ void codegen_init() exit(-1); } #endif -// pclog("Codegen is %p\n", (void *)pages[0xfab12 >> 12].block); } void codegen_reset() @@ -99,25 +98,11 @@ void codegen_reset() void dump_block() { - codeblock_t *block = pages[0x119000 >> 12].block; - - pclog("dump_block:\n"); - while (block) - { - uint32_t start_pc = (block->pc & 0xffc) | (block->phys & ~0xfff); - uint32_t end_pc = (block->endpc & 0xffc) | (block->phys & ~0xfff); - pclog(" %p : %08x-%08x %08x-%08x %p %p\n", (void *)block, start_pc, end_pc, block->pc, block->endpc, (void *)block->prev, (void *)block->next); - if (!block->pc) - fatal("Dead PC=0\n"); - - block = block->next; - } - pclog("dump_block done\n"); } static void add_to_block_list(codeblock_t *block) { - codeblock_t *block_prev = pages[block->phys >> 12].block; + codeblock_t *block_prev = pages[block->phys >> 12].block[(block->phys >> 10) & 3]; if (!block->page_mask) fatal("add_to_block_list - mask = 0\n"); @@ -126,12 +111,12 @@ static void add_to_block_list(codeblock_t *block) { block->next = block_prev; block_prev->prev = block; - pages[block->phys >> 12].block = block; + pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block; } else { block->next = NULL; - pages[block->phys >> 12].block = block; + pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block; } if (block->next) @@ -142,18 +127,18 @@ static void add_to_block_list(codeblock_t *block) if (block->page_mask2) { - block_prev = pages[block->phys_2 >> 12].block_2; + block_prev = pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]; if (block_prev) { block->next_2 = block_prev; block_prev->prev_2 = block; - pages[block->phys_2 >> 12].block_2 = block; + pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block; } else { block->next_2 = NULL; - pages[block->phys_2 >> 12].block_2 = block; + pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block; } } } @@ -171,7 +156,7 @@ static void remove_from_block_list(codeblock_t *block, uint32_t pc) } else { - pages[block->phys >> 12].block = block->next; + pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block->next; if (block->next) block->next->prev = NULL; else @@ -192,8 +177,7 @@ static void remove_from_block_list(codeblock_t *block, uint32_t pc) } else { -// pclog(" pages.block_2=%p 3 %p %p\n", (void *)block->next_2, (void *)block, (void *)pages[block->phys_2 >> 12].block_2); - pages[block->phys_2 >> 12].block_2 = block->next_2; + pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block->next_2; if (block->next_2) block->next_2->prev_2 = NULL; else @@ -218,7 +202,7 @@ static void delete_block(codeblock_t *block) void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) { - struct codeblock_t *block = page->block; + struct codeblock_t *block = page->block[(phys_addr >> 10) & 3]; while (block) { @@ -232,7 +216,7 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) block = block->next; } - block = page->block_2; + block = page->block_2[(phys_addr >> 10) & 3]; while (block) { @@ -253,17 +237,14 @@ void codegen_block_init(uint32_t phys_addr) int has_evicted = 0; page_t *page = &pages[phys_addr >> 12]; - if (!page->block) + if (!page->block[(phys_addr >> 10) & 3]) mem_flush_write_page(phys_addr, cs+cpu_state.pc); block_current = (block_current + 1) & BLOCK_MASK; block = &codeblock[block_current]; -// if (block->pc == 0xb00b4ff5) -// pclog("Init target block\n"); if (block->pc != 0) { -// pclog("Reuse block : was %08x now %08x\n", block->pc, cs+pc); delete_block(block); cpu_recomp_reuse++; } @@ -275,6 +256,8 @@ void codegen_block_init(uint32_t phys_addr) block->_cs = cs; block->pnt = block_current; block->phys = phys_addr; + block->dirty_mask = &page->dirty_mask[(phys_addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK]; + block->dirty_mask2 = NULL; block->next = block->prev = NULL; block->next_2 = block->prev_2 = NULL; block->page_mask = 0; @@ -294,7 +277,7 @@ void codegen_block_start_recompile(codeblock_t *block) int has_evicted = 0; page_t *page = &pages[block->phys >> 12]; - if (!page->block) + if (!page->block[(block->phys >> 10) & 3]) mem_flush_write_page(block->phys, cs+cpu_state.pc); block_num = HASH(block->phys); @@ -360,8 +343,6 @@ void codegen_block_start_recompile(codeblock_t *block) addbyte(0xBD); addquad(((uintptr_t)&cpu_state) + 128); -// pclog("New block %i for %08X %03x\n", block_current, cs+pc, block_num); - last_op32 = -1; last_ea_seg = NULL; last_ssegs = -1; @@ -405,59 +386,60 @@ void codegen_block_remove() void codegen_block_generate_end_mask() { codeblock_t *block = &codeblock[block_current]; - uint32_t start_pc = (block->pc & 0xffc) | (block->phys & ~0xfff); - uint32_t end_pc = ((codegen_endpc + 3) & 0xffc) | (block->phys & ~0xfff); + uint32_t start_pc; + uint32_t end_pc; block->endpc = codegen_endpc; block->page_mask = 0; - start_pc = block->pc & 0xffc; - start_pc &= ~PAGE_MASK_MASK; - end_pc = ((block->endpc & 0xffc) + PAGE_MASK_MASK) & ~PAGE_MASK_MASK; - if (end_pc > 0xfff || end_pc < start_pc) - end_pc = 0xfff; + start_pc = (block->pc & 0x3ff) & ~15; + if ((block->pc ^ block->endpc) & ~0x3ff) + end_pc = 0x3ff & ~15; + else + end_pc = (block->endpc & 0x3ff) & ~15; + if (end_pc < start_pc) + end_pc = 0x3ff; start_pc >>= PAGE_MASK_SHIFT; end_pc >>= PAGE_MASK_SHIFT; -// pclog("block_end: %08x %08x\n", start_pc, end_pc); for (; start_pc <= end_pc; start_pc++) { block->page_mask |= ((uint64_t)1 << start_pc); -// pclog(" %08x %llx\n", start_pc, block->page_mask); } - pages[block->phys >> 12].code_present_mask |= block->page_mask; + pages[block->phys >> 12].code_present_mask[(block->phys >> 10) & 3] |= block->page_mask; block->phys_2 = -1; block->page_mask2 = 0; block->next_2 = block->prev_2 = NULL; - if ((block->pc ^ block->endpc) & ~0xfff) + if ((block->pc ^ block->endpc) & ~0x3ff) { block->phys_2 = get_phys_noabrt(block->endpc); if (block->phys_2 != -1) { -// pclog("start block - %08x %08x %p %p %p %08x\n", block->pc, block->endpc, (void *)block, (void *)block->next_2, (void *)pages[block->phys_2 >> 12].block_2, block->phys_2); + page_t *page_2 = &pages[block->phys_2 >> 12]; start_pc = 0; - end_pc = (block->endpc & 0xfff) >> PAGE_MASK_SHIFT; + end_pc = (block->endpc & 0x3ff) >> PAGE_MASK_SHIFT; for (; start_pc <= end_pc; start_pc++) block->page_mask2 |= ((uint64_t)1 << start_pc); - - if (!pages[block->phys_2 >> 12].block_2) + page_2->code_present_mask[(block->phys_2 >> 10) & 3] |= block->page_mask2; + + if (!pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]) mem_flush_write_page(block->phys_2, block->endpc); -// pclog("New block - %08x %08x %p %p phys %08x %08x %016llx\n", block->pc, block->endpc, (void *)block, (void *)block->next_2, block->phys, block->phys_2, block->page_mask2); + if (!block->page_mask2) fatal("!page_mask2\n"); if (block->next_2) { -// pclog(" next_2->pc=%08x\n", block->next_2->pc); if (!block->next_2->pc) fatal("block->next_2->pc=0 %p\n", (void *)block->next_2); } + + block->dirty_mask2 = &page_2->dirty_mask[(block->phys_2 >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK]; } } -// pclog("block_end: %08x %08x %016llx\n", block->pc, block->endpc, block->page_mask); recomp_page = -1; } @@ -487,16 +469,6 @@ void codegen_block_end_recompile(codeblock_t *block) addbyte(cpu_state_offset(cpu_recomp_ins)); addlong(codegen_block_ins); } -#if 0 - if (codegen_block_full_ins) - { - addbyte(0x81); /*ADD $codegen_block_ins,ins*/ - addbyte(0x04); - addbyte(0x25); - addlong((uint32_t)&cpu_recomp_full_ins); - addlong(codegen_block_full_ins); - } -#endif addbyte(0x48); /*ADDL $40,%rsp*/ addbyte(0x83); addbyte(0xC4); @@ -523,7 +495,6 @@ void codegen_block_end_recompile(codeblock_t *block) block->next_2 = block->prev_2 = NULL; codegen_block_generate_end_mask(); add_to_block_list(block); -// pclog("End block %i\n", block_num); } void codegen_flush() @@ -730,7 +701,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, } return op_ea_seg; } -//#if 0 + static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, int stack_offset) { uint32_t new_eaaddr; @@ -932,7 +903,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, } return op_ea_seg; } -//#endif + void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_pc, uint32_t old_pc) { codeblock_t *block = &codeblock[block_current]; @@ -1117,17 +1088,6 @@ generate_call: addlong(codegen_block_ins); codegen_block_ins = 0; } -#if 0 - if (codegen_block_full_ins) - { - addbyte(0x81); /*ADD $codegen_block_ins,ins*/ - addbyte(0x04); - addbyte(0x25); - addlong((uint32_t)&cpu_recomp_full_ins); - addlong(codegen_block_full_ins); - codegen_block_full_ins = 0; - } -#endif } if (recomp_op_table && recomp_op_table[(opcode | op_32) & 0x1ff]) { @@ -1147,8 +1107,6 @@ generate_call: } op = op_table[((opcode >> opcode_shift) | op_32) & opcode_mask]; -// if (output) -// pclog("Generate call at %08X %02X %08X %02X %08X %08X %08X %08X %08X %02X %02X %02X %02X\n", &codeblock[block_current][block_pos], opcode, new_pc, ram[old_pc], EAX, EBX, ECX, EDX, ESI, ram[0x7bd2+6],ram[0x7bd2+7],ram[0x7bd2+8],ram[0x7bd2+9]); if (op_ssegs != last_ssegs) { last_ssegs = op_ssegs; @@ -1157,7 +1115,7 @@ generate_call: addbyte(cpu_state_offset(ssegs)); addbyte(op_ssegs); } -//#if 0 + if ((!test_modrm || (op_table == x86_dynarec_opcodes && opcode_modrm[opcode]) || (op_table == x86_dynarec_opcodes_0f && opcode_0f_modrm[opcode]))/* && !(op_32 & 0x200)*/) @@ -1183,10 +1141,9 @@ generate_call: op_ea_seg = codegen_generate_ea_32_long(op_ea_seg, fetchdat, op_ssegs, &op_pc, stack_offset); op_pc -= pc_off; } -//#endif + if (op_ea_seg != last_ea_seg) { -// last_ea_seg = op_ea_seg; addbyte(0xC7); /*MOVL $&_ds,(ea_seg)*/ addbyte(0x45); addbyte(cpu_state_offset(ea_seg)); @@ -1223,8 +1180,6 @@ generate_call: addbyte(0x0F); addbyte(0x85); /*JNZ 0*/ addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4])); -// call(block, codegen_debug); - codegen_endpc = (cs + cpu_state.pc) + 8; } diff --git a/src/CPU/codegen_x86.c b/src/CPU/codegen_x86.c index a4f0ffe59..50fa7bc35 100644 --- a/src/CPU/codegen_x86.c +++ b/src/CPU/codegen_x86.c @@ -1218,25 +1218,11 @@ void codegen_reset() void dump_block() { - codeblock_t *block = pages[0x119000 >> 12].block; - - pclog("dump_block:\n"); - while (block) - { - uint32_t start_pc = (block->pc & 0xffc) | (block->phys & ~0xfff); - uint32_t end_pc = (block->endpc & 0xffc) | (block->phys & ~0xfff); - pclog(" %p : %08x-%08x %08x-%08x %p %p\n", (void *)block, start_pc, end_pc, block->pc, block->endpc, (void *)block->prev, (void *)block->next); - if (!block->pc) - fatal("Dead PC=0\n"); - - block = block->next; - } - pclog("dump_block done\n"); } static void add_to_block_list(codeblock_t *block) { - codeblock_t *block_prev = pages[block->phys >> 12].block; + codeblock_t *block_prev = pages[block->phys >> 12].block[(block->phys >> 10) & 3]; if (!block->page_mask) fatal("add_to_block_list - mask = 0\n"); @@ -1245,12 +1231,12 @@ static void add_to_block_list(codeblock_t *block) { block->next = block_prev; block_prev->prev = block; - pages[block->phys >> 12].block = block; + pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block; } else { block->next = NULL; - pages[block->phys >> 12].block = block; + pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block; } if (block->next) @@ -1261,18 +1247,18 @@ static void add_to_block_list(codeblock_t *block) if (block->page_mask2) { - block_prev = pages[block->phys_2 >> 12].block_2; + block_prev = pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]; if (block_prev) { block->next_2 = block_prev; block_prev->prev_2 = block; - pages[block->phys_2 >> 12].block_2 = block; + pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block; } else { block->next_2 = NULL; - pages[block->phys_2 >> 12].block_2 = block; + pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block; } } } @@ -1290,7 +1276,7 @@ static void remove_from_block_list(codeblock_t *block, uint32_t pc) } else { - pages[block->phys >> 12].block = block->next; + pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block->next; if (block->next) block->next->prev = NULL; else @@ -1312,7 +1298,7 @@ static void remove_from_block_list(codeblock_t *block, uint32_t pc) else { /* pclog(" pages.block_2=%p 3 %p %p\n", (void *)block->next_2, (void *)block, (void *)pages[block->phys_2 >> 12].block_2); */ - pages[block->phys_2 >> 12].block_2 = block->next_2; + pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block->next_2; if (block->next_2) block->next_2->prev_2 = NULL; else @@ -1337,7 +1323,7 @@ static void delete_block(codeblock_t *block) void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) { - struct codeblock_t *block = page->block; + struct codeblock_t *block = page->block[(phys_addr >> 10) & 3]; while (block) { @@ -1351,7 +1337,7 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) block = block->next; } - block = page->block_2; + block = page->block_2[(phys_addr >> 10) & 3]; while (block) { @@ -1372,14 +1358,12 @@ void codegen_block_init(uint32_t phys_addr) int has_evicted = 0; page_t *page = &pages[phys_addr >> 12]; - if (!page->block) + if (!page->block[(phys_addr >> 10) & 3]) mem_flush_write_page(phys_addr, cs+cpu_state.pc); block_current = (block_current + 1) & BLOCK_MASK; block = &codeblock[block_current]; - /* if (block->pc == 0xb00b4ff5) - pclog("Init target block\n"); */ if (block->pc != 0) { /* pclog("Reuse block : was %08x now %08x\n", block->pc, cs+pc); */ @@ -1394,6 +1378,8 @@ void codegen_block_init(uint32_t phys_addr) block->_cs = cs; block->pnt = block_current; block->phys = phys_addr; + block->dirty_mask = &page->dirty_mask[(phys_addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK]; + block->dirty_mask2 = NULL; block->next = block->prev = NULL; block->next_2 = block->prev_2 = NULL; block->page_mask = 0; @@ -1412,7 +1398,7 @@ void codegen_block_start_recompile(codeblock_t *block) int has_evicted = 0; page_t *page = &pages[block->phys >> 12]; - if (!page->block) + if (!page->block[(block->phys >> 10) & 3]) mem_flush_write_page(block->phys, cs+cpu_state.pc); block_num = HASH(block->phys); @@ -1497,17 +1483,19 @@ void codegen_block_remove() void codegen_block_generate_end_mask() { codeblock_t *block = &codeblock[block_current]; - uint32_t start_pc = (block->pc & 0xffc) | (block->phys & ~0xfff); - uint32_t end_pc = ((codegen_endpc + 3) & 0xffc) | (block->phys & ~0xfff); + uint32_t start_pc; + uint32_t end_pc; block->endpc = codegen_endpc; block->page_mask = 0; - start_pc = block->pc & 0xffc; - start_pc &= ~PAGE_MASK_MASK; - end_pc = ((block->endpc & 0xffc) + PAGE_MASK_MASK) & ~PAGE_MASK_MASK; - if (end_pc > 0xfff || end_pc < start_pc) - end_pc = 0xfff; + start_pc = (block->pc & 0x3ff) & ~15; + if ((block->pc ^ block->endpc) & ~0x3ff) + end_pc = 0x3ff & ~15; + else + end_pc = (block->endpc & 0x3ff) & ~15; + if (end_pc < start_pc) + end_pc = 0x3ff; start_pc >>= PAGE_MASK_SHIFT; end_pc >>= PAGE_MASK_SHIFT; @@ -1518,26 +1506,27 @@ void codegen_block_generate_end_mask() /* pclog(" %08x %llx\n", start_pc, block->page_mask); */ } - pages[block->phys >> 12].code_present_mask |= block->page_mask; + pages[block->phys >> 12].code_present_mask[(block->phys >> 10) & 3] |= block->page_mask; block->phys_2 = -1; block->page_mask2 = 0; block->next_2 = block->prev_2 = NULL; - if ((block->pc ^ block->endpc) & ~0xfff) + if ((block->pc ^ block->endpc) & ~0x3ff) { block->phys_2 = get_phys_noabrt(block->endpc); if (block->phys_2 != -1) { - /* pclog("start block - %08x %08x %p %p %p %08x\n", block->pc, block->endpc, (void *)block, (void *)block->next_2, (void *)pages[block->phys_2 >> 12].block_2, block->phys_2); */ + page_t *page_2 = &pages[block->phys_2 >> 12]; start_pc = 0; - end_pc = (block->endpc & 0xfff) >> PAGE_MASK_SHIFT; + end_pc = (block->endpc & 0x3ff) >> PAGE_MASK_SHIFT; for (; start_pc <= end_pc; start_pc++) block->page_mask2 |= ((uint64_t)1 << start_pc); + page_2->code_present_mask[(block->phys_2 >> 10) & 3] |= block->page_mask2; - if (!pages[block->phys_2 >> 12].block_2) + if (!pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]) mem_flush_write_page(block->phys_2, block->endpc); - /* pclog("New block - %08x %08x %p %p phys %08x %08x %016llx\n", block->pc, block->endpc, (void *)block, (void *)block->next_2, block->phys, block->phys_2, block->page_mask2); */ + if (!block->page_mask2) fatal("!page_mask2\n"); if (block->next_2) @@ -1546,6 +1535,8 @@ void codegen_block_generate_end_mask() if (!block->next_2->pc) fatal("block->next_2->pc=0 %p\n", (void *)block->next_2); } + + block->dirty_mask2 = &page_2->dirty_mask[(block->phys_2 >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK]; } } diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 7e493882b..4da10181a 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -8,7 +8,7 @@ # # Modified Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.25 2017/06/04 +# Version: @(#)Makefile.mingw 1.0.27 2017/06/14 # # Authors: Miran Grca, # Fred N. van Kempen, @@ -41,7 +41,7 @@ ifndef EXTRAS EXTRAS = endif -# Do we want a debugging build? +# Defaults for several build options (possibly defined in a chained file.) ifndef DEBUG DEBUG = n endif @@ -62,58 +62,53 @@ endif ######################################################################### # Nothing should need changing from here on.. # ######################################################################### -VPATH = . cpu sound sound/resid-fp video lzf slirp win +VPATH = . cpu sound sound/resid-fp video lzf network network/slirp win PLAT = win/ -CPP = g++.exe -CC = gcc.exe +ifeq ($(X64), y) +CPP = g++.exe -m64 -U__unix +CC = gcc.exe -m64 -U__unix +else +CPP = g++.exe -m32 +CC = gcc.exe -m32 +endif WINDRES = windres.exe OPTS = -DWIN32 -I$(PLAT) $(EXTRAS) $(STUFF) -ifeq ($(DEBUG), y) -ifeq ($(VRAMDUMP), y) -DFLAGS = -march=i686 -ggdb -DDEBUG -DENABLE_VRAM_DUMP -else -DFLAGS = -march=i686 -ggdb -DDEBUG -endif -ifndef COPTIM -COPTIM = -Og -endif -else -ifeq ($(OPTIM), y) -DFLAGS = -march=native -ifndef COPTIM -COPTIM = -O6 -endif -else + ifeq ($(X64), y) -DFLAGS = + DFLAGS = else -DFLAGS = -march=i686 + DFLAGS = -march=i686 endif -ifndef COPTIM -COPTIM = -O3 -endif -endif -endif -ifeq ($(OPTIM), y) -AOPTIM = -mtune=native +ifeq ($(DEBUG), y) + DFLAGS += -ggdb -DDEBUG + AOPTIM = + ifndef COPTIM + COPTIM = -Og + endif else -AOPTIM = + ifeq ($(OPTIM), y) + AOPTIM = -mtune=native + ifndef COPTIM + COPTIM = -O6 + endif + else + ifndef COPTIM + COPTIM = -O3 + endif + endif endif -AFLAGS = -msse -msse2 \ - -mfpmath=sse +AFLAGS = -msse -msse2 -mfpmath=sse +CFLAGS = $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) $(AFLAGS) \ + -fomit-frame-pointer -mstackrealign +RFLAGS = --input-format=rc -O coff ifeq ($(RELEASE), y) -CFLAGS = $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) $(AFLAGS) \ - -fomit-frame-pointer -mstackrealign -DRELEASE_BUILD -RFLAGS = --input-format=rc -O coff -DRELEASE_BUILD -else -CFLAGS = $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) $(AFLAGS) \ - -fomit-frame-pointer -mstackrealign -ifeq ($(VRAMDUMP), y) -RFLAGS = --input-format=rc -O coff -DENABLE_VRAM_DUMP -else -RFLAGS = --input-format=rc -O coff +CFLAGS += -DRELEASE_BUILD +RFLAGS += -DRELEASE_BUILD endif +ifeq ($(VRAMDUMP), y) +CFLAGS += -DENABLE_VRAM_DUMP +RFLAGS += -DENABLE_VRAM_DUMP endif ifeq ($(X64), y) @@ -146,7 +141,7 @@ SYSOBJ = model.o \ olivetti_m24.o ps1.o ps2.o ps2_mca.o \ tandy_eeprom.o tandy_rom.o DEVOBJ = bugger.o lpt.o serial.o \ - um8669f.o pc87306.o sis85c471.o w83877f.o \ + pc87306.o sis85c471.o w83877f.o \ keyboard.o \ keyboard_xt.o keyboard_at.o keyboard_pcjr.o \ keyboard_amstrad.o keyboard_olim24.o \ diff --git a/src/bswap.h b/src/NETWORK/bswap.h similarity index 99% rename from src/bswap.h rename to src/NETWORK/bswap.h index a1f2f8052..81275a6e6 100644 --- a/src/bswap.h +++ b/src/NETWORK/bswap.h @@ -1,4 +1,4 @@ -/* Copyright holders: Sarah Walker +/* Copyright holders: neozeed see COPYING for more details */ #ifndef BSWAP_H diff --git a/src/net_ne2000.c b/src/NETWORK/net_ne2000.c similarity index 99% rename from src/net_ne2000.c rename to src/NETWORK/net_ne2000.c index 7194adf68..b9fb05a34 100644 --- a/src/net_ne2000.c +++ b/src/NETWORK/net_ne2000.c @@ -10,7 +10,7 @@ * * NOTE: The file will also implement an NE1000 for 8-bit ISA systems. * - * Version: @(#)net_ne2000.c 1.0.10 2017/06/03 + * Version: @(#)net_ne2000.c 1.0.11 2017/06/14 * * Authors: Fred N. van Kempen, * Peter Grehan, grehan@iprg.nokia.com> @@ -24,15 +24,15 @@ #include #include #include -#include "ibm.h" -#include "io.h" -#include "mem.h" -#include "rom.h" -#include "pci.h" -#include "pic.h" -#include "device.h" -#include "config.h" -#include "disc_random.h" +#include "../ibm.h" +#include "../io.h" +#include "../mem.h" +#include "../rom.h" +#include "../pci.h" +#include "../pic.h" +#include "../device.h" +#include "../config.h" +#include "../disc_random.h" #include "network.h" #include "net_ne2000.h" #include "bswap.h" diff --git a/src/net_ne2000.h b/src/NETWORK/net_ne2000.h similarity index 100% rename from src/net_ne2000.h rename to src/NETWORK/net_ne2000.h diff --git a/src/net_pcap.c b/src/NETWORK/net_pcap.c similarity index 98% rename from src/net_pcap.c rename to src/NETWORK/net_pcap.c index 8e2860be2..324b368b3 100644 --- a/src/net_pcap.c +++ b/src/NETWORK/net_pcap.c @@ -17,12 +17,12 @@ #include #include #include -#include "ibm.h" -#include "config.h" -#include "device.h" +#include "../ibm.h" +#include "../config.h" +#include "../device.h" #include "network.h" -#include "plat_dynld.h" -#include "plat_thread.h" +#include "../WIN/plat_dynld.h" +#include "../WIN/plat_thread.h" static void *pcap_handle; /* handle to WinPcap DLL */ diff --git a/src/net_slirp.c b/src/NETWORK/net_slirp.c similarity index 96% rename from src/net_slirp.c rename to src/NETWORK/net_slirp.c index f49167cbd..89c8eb1ac 100644 --- a/src/net_slirp.c +++ b/src/NETWORK/net_slirp.c @@ -8,7 +8,7 @@ * * Handle SLiRP library processing. * - * Version: @(#)net_slirp.c 1.0.3 2017/05/21 + * Version: @(#)net_slirp.c 1.0.4 2017/06/14 * * Author: Fred N. van Kempen, */ @@ -18,11 +18,11 @@ #include #include "slirp/slirp.h" #include "slirp/queue.h" -#include "ibm.h" -#include "config.h" -#include "device.h" +#include "../ibm.h" +#include "../config.h" +#include "../device.h" #include "network.h" -#include "plat_thread.h" +#include "../WIN/plat_thread.h" static queueADT slirpq; /* SLiRP library handle */ diff --git a/src/network.c b/src/NETWORK/network.c similarity index 97% rename from src/network.c rename to src/NETWORK/network.c index cd6cc3ea5..abac44263 100644 --- a/src/network.c +++ b/src/NETWORK/network.c @@ -12,7 +12,7 @@ * it should be malloc'ed and then linked to the NETCARD def. * Will be done later. * - * Version: @(#)network.c 1.0.9 2017/06/03 + * Version: @(#)network.c 1.0.10 2017/06/14 * * Author: Fred N. van Kempen, */ @@ -20,12 +20,12 @@ #include #include #include -#include "ibm.h" -#include "device.h" +#include "../ibm.h" +#include "../device.h" #include "network.h" #include "net_ne2000.h" -#include "win.h" -#include "win_language.h" +#include "../WIN/win.h" +#include "../WIN/win_language.h" static netcard_t net_cards[] = { diff --git a/src/network.h b/src/NETWORK/network.h similarity index 100% rename from src/network.h rename to src/NETWORK/network.h diff --git a/src/pcap_if.c b/src/NETWORK/pcap_if.c similarity index 100% rename from src/pcap_if.c rename to src/NETWORK/pcap_if.c diff --git a/src/slirp/COPYRIGHT.txt b/src/NETWORK/slirp/COPYRIGHT.txt similarity index 100% rename from src/slirp/COPYRIGHT.txt rename to src/NETWORK/slirp/COPYRIGHT.txt diff --git a/src/slirp/VERSION.txt b/src/NETWORK/slirp/VERSION.txt similarity index 100% rename from src/slirp/VERSION.txt rename to src/NETWORK/slirp/VERSION.txt diff --git a/src/slirp/bootp.c b/src/NETWORK/slirp/bootp.c similarity index 100% rename from src/slirp/bootp.c rename to src/NETWORK/slirp/bootp.c diff --git a/src/slirp/bootp.h b/src/NETWORK/slirp/bootp.h similarity index 100% rename from src/slirp/bootp.h rename to src/NETWORK/slirp/bootp.h diff --git a/src/slirp/cksum.c b/src/NETWORK/slirp/cksum.c similarity index 100% rename from src/slirp/cksum.c rename to src/NETWORK/slirp/cksum.c diff --git a/src/slirp/config-host.h b/src/NETWORK/slirp/config-host.h similarity index 100% rename from src/slirp/config-host.h rename to src/NETWORK/slirp/config-host.h diff --git a/src/slirp/config.h b/src/NETWORK/slirp/config.h similarity index 100% rename from src/slirp/config.h rename to src/NETWORK/slirp/config.h diff --git a/src/slirp/ctl.h b/src/NETWORK/slirp/ctl.h similarity index 100% rename from src/slirp/ctl.h rename to src/NETWORK/slirp/ctl.h diff --git a/src/slirp/debug.c b/src/NETWORK/slirp/debug.c similarity index 100% rename from src/slirp/debug.c rename to src/NETWORK/slirp/debug.c diff --git a/src/slirp/debug.h b/src/NETWORK/slirp/debug.h similarity index 100% rename from src/slirp/debug.h rename to src/NETWORK/slirp/debug.h diff --git a/src/slirp/icmp_var.h b/src/NETWORK/slirp/icmp_var.h similarity index 100% rename from src/slirp/icmp_var.h rename to src/NETWORK/slirp/icmp_var.h diff --git a/src/slirp/if.c b/src/NETWORK/slirp/if.c similarity index 100% rename from src/slirp/if.c rename to src/NETWORK/slirp/if.c diff --git a/src/slirp/if.h b/src/NETWORK/slirp/if.h similarity index 100% rename from src/slirp/if.h rename to src/NETWORK/slirp/if.h diff --git a/src/slirp/ip.h b/src/NETWORK/slirp/ip.h similarity index 100% rename from src/slirp/ip.h rename to src/NETWORK/slirp/ip.h diff --git a/src/slirp/ip_icmp.c b/src/NETWORK/slirp/ip_icmp.c similarity index 100% rename from src/slirp/ip_icmp.c rename to src/NETWORK/slirp/ip_icmp.c diff --git a/src/slirp/ip_icmp.h b/src/NETWORK/slirp/ip_icmp.h similarity index 100% rename from src/slirp/ip_icmp.h rename to src/NETWORK/slirp/ip_icmp.h diff --git a/src/slirp/ip_input.c b/src/NETWORK/slirp/ip_input.c similarity index 100% rename from src/slirp/ip_input.c rename to src/NETWORK/slirp/ip_input.c diff --git a/src/slirp/ip_output.c b/src/NETWORK/slirp/ip_output.c similarity index 100% rename from src/slirp/ip_output.c rename to src/NETWORK/slirp/ip_output.c diff --git a/src/slirp/libslirp.h b/src/NETWORK/slirp/libslirp.h similarity index 100% rename from src/slirp/libslirp.h rename to src/NETWORK/slirp/libslirp.h diff --git a/src/slirp/main.h b/src/NETWORK/slirp/main.h similarity index 100% rename from src/slirp/main.h rename to src/NETWORK/slirp/main.h diff --git a/src/slirp/mbuf.c b/src/NETWORK/slirp/mbuf.c similarity index 100% rename from src/slirp/mbuf.c rename to src/NETWORK/slirp/mbuf.c diff --git a/src/slirp/mbuf.h b/src/NETWORK/slirp/mbuf.h similarity index 100% rename from src/slirp/mbuf.h rename to src/NETWORK/slirp/mbuf.h diff --git a/src/slirp/misc.c b/src/NETWORK/slirp/misc.c similarity index 100% rename from src/slirp/misc.c rename to src/NETWORK/slirp/misc.c diff --git a/src/slirp/misc.h b/src/NETWORK/slirp/misc.h similarity index 100% rename from src/slirp/misc.h rename to src/NETWORK/slirp/misc.h diff --git a/src/slirp/queue.c b/src/NETWORK/slirp/queue.c similarity index 100% rename from src/slirp/queue.c rename to src/NETWORK/slirp/queue.c diff --git a/src/slirp/queue.h b/src/NETWORK/slirp/queue.h similarity index 100% rename from src/slirp/queue.h rename to src/NETWORK/slirp/queue.h diff --git a/src/slirp/sbuf.c b/src/NETWORK/slirp/sbuf.c similarity index 100% rename from src/slirp/sbuf.c rename to src/NETWORK/slirp/sbuf.c diff --git a/src/slirp/sbuf.h b/src/NETWORK/slirp/sbuf.h similarity index 100% rename from src/slirp/sbuf.h rename to src/NETWORK/slirp/sbuf.h diff --git a/src/slirp/slirp.c b/src/NETWORK/slirp/slirp.c similarity index 99% rename from src/slirp/slirp.c rename to src/NETWORK/slirp/slirp.c index 6a9670f12..3068dc72c 100644 --- a/src/slirp/slirp.c +++ b/src/NETWORK/slirp/slirp.c @@ -29,6 +29,8 @@ fd_set *global_readfds, *global_writefds, *global_xfds; extern void pclog(const char *, ...); extern int config_get_int(char *, char *, int); +#define printf pclog + #ifdef _WIN32 static int get_dns_addr(struct in_addr *pdns_addr) diff --git a/src/slirp/slirp.h b/src/NETWORK/slirp/slirp.h similarity index 100% rename from src/slirp/slirp.h rename to src/NETWORK/slirp/slirp.h diff --git a/src/slirp/slirp_config.h b/src/NETWORK/slirp/slirp_config.h similarity index 100% rename from src/slirp/slirp_config.h rename to src/NETWORK/slirp/slirp_config.h diff --git a/src/slirp/socket.c b/src/NETWORK/slirp/socket.c similarity index 100% rename from src/slirp/socket.c rename to src/NETWORK/slirp/socket.c diff --git a/src/slirp/socket.h b/src/NETWORK/slirp/socket.h similarity index 100% rename from src/slirp/socket.h rename to src/NETWORK/slirp/socket.h diff --git a/src/slirp/tcp.h b/src/NETWORK/slirp/tcp.h similarity index 100% rename from src/slirp/tcp.h rename to src/NETWORK/slirp/tcp.h diff --git a/src/slirp/tcp_input.c b/src/NETWORK/slirp/tcp_input.c similarity index 100% rename from src/slirp/tcp_input.c rename to src/NETWORK/slirp/tcp_input.c diff --git a/src/slirp/tcp_output.c b/src/NETWORK/slirp/tcp_output.c similarity index 100% rename from src/slirp/tcp_output.c rename to src/NETWORK/slirp/tcp_output.c diff --git a/src/slirp/tcp_subr.c b/src/NETWORK/slirp/tcp_subr.c similarity index 100% rename from src/slirp/tcp_subr.c rename to src/NETWORK/slirp/tcp_subr.c diff --git a/src/slirp/tcp_timer.c b/src/NETWORK/slirp/tcp_timer.c similarity index 100% rename from src/slirp/tcp_timer.c rename to src/NETWORK/slirp/tcp_timer.c diff --git a/src/slirp/tcp_timer.h b/src/NETWORK/slirp/tcp_timer.h similarity index 100% rename from src/slirp/tcp_timer.h rename to src/NETWORK/slirp/tcp_timer.h diff --git a/src/slirp/tcp_var.h b/src/NETWORK/slirp/tcp_var.h similarity index 100% rename from src/slirp/tcp_var.h rename to src/NETWORK/slirp/tcp_var.h diff --git a/src/slirp/tcpip.h b/src/NETWORK/slirp/tcpip.h similarity index 100% rename from src/slirp/tcpip.h rename to src/NETWORK/slirp/tcpip.h diff --git a/src/slirp/tftp.c b/src/NETWORK/slirp/tftp.c similarity index 100% rename from src/slirp/tftp.c rename to src/NETWORK/slirp/tftp.c diff --git a/src/slirp/tftp.h b/src/NETWORK/slirp/tftp.h similarity index 100% rename from src/slirp/tftp.h rename to src/NETWORK/slirp/tftp.h diff --git a/src/slirp/udp.c b/src/NETWORK/slirp/udp.c similarity index 100% rename from src/slirp/udp.c rename to src/NETWORK/slirp/udp.c diff --git a/src/slirp/udp.h b/src/NETWORK/slirp/udp.h similarity index 100% rename from src/slirp/udp.h rename to src/NETWORK/slirp/udp.h diff --git a/src/SOUND/openal.c b/src/SOUND/openal.c index 9f20b57de..b044c0e5a 100644 --- a/src/SOUND/openal.c +++ b/src/SOUND/openal.c @@ -21,7 +21,7 @@ static ALuint source[2]; /* audio source */ #define BUFLEN SOUNDBUFLEN -void closeal(ALvoid); +void closeal(void); ALvoid alutInit(ALint *argc,ALbyte **argv) { ALCcontext *Context; @@ -62,7 +62,7 @@ void initalmain(int argc, char *argv[]) #endif } -void closeal(ALvoid) +void closeal(void) { #ifdef USE_OPENAL alutExit(); @@ -73,10 +73,15 @@ void inital(ALvoid) { #ifdef USE_OPENAL int c; + float buf[BUFLEN*2]; float cd_buf[CD_BUFLEN*2]; + int16_t buf_int16[BUFLEN*2]; + + int16_t cd_buf_int16[CD_BUFLEN*2]; + alGenBuffers(4, buffers); alGenBuffers(4, buffers_cd); @@ -98,8 +103,16 @@ void inital(ALvoid) for (c = 0; c < 4; c++) { - alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); - alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); + if (sound_is_float) + { + alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); + alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); + } + else + { + alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ); + alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ); + } } alSourceQueueBuffers(source[0], 4, buffers); @@ -135,6 +148,32 @@ void givealbuffer(float *buf) #endif } +void givealbuffer_int16(int16_t *buf) +{ +#ifdef USE_OPENAL + int processed; + int state; + ALuint buffer; + + alGetSourcei(source[0], AL_SOURCE_STATE, &state); + + if (state==0x1014) + { + alSourcePlay(source[0]); + } + alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed); + + if (processed>=1) + { + alSourceUnqueueBuffers(source[0], 1, &buffer); + + alBufferData(buffer, AL_FORMAT_STEREO16, buf, BUFLEN*2*sizeof(int16_t), FREQ); + + alSourceQueueBuffers(source[0], 1, &buffer); + } +#endif +} + void givealbuffer_cd(float *buf) { #ifdef USE_OPENAL @@ -161,3 +200,30 @@ void givealbuffer_cd(float *buf) } #endif } + +void givealbuffer_cd_int16(int16_t *buf) +{ +#ifdef USE_OPENAL + int processed; + int state; + + alGetSourcei(source[1], AL_SOURCE_STATE, &state); + + if (state==0x1014) + { + alSourcePlay(source[1]); + } + alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed); + + if (processed>=1) + { + ALuint buffer; + + alSourceUnqueueBuffers(source[1], 1, &buffer); + + alBufferData(buffer, AL_FORMAT_STEREO16, buf, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ); + + alSourceQueueBuffers(source[1], 1, &buffer); + } +#endif +} diff --git a/src/SOUND/snd_dbopl.cc b/src/SOUND/snd_dbopl.cc index cf4bc1ebe..94480ad4f 100644 --- a/src/SOUND/snd_dbopl.cc +++ b/src/SOUND/snd_dbopl.cc @@ -1,4 +1,4 @@ -/* Copyright holders: The DOSBox Team, SA1988 +/* Copyright holders: Sarah Walker, SA1988 see COPYING for more details */ #include "dbopl.h" diff --git a/src/SOUND/snd_dbopl.h b/src/SOUND/snd_dbopl.h index 49b2aa095..6fd536f39 100644 --- a/src/SOUND/snd_dbopl.h +++ b/src/SOUND/snd_dbopl.h @@ -1,4 +1,4 @@ -/* Copyright holders: The DOSBox Team, SA1988 +/* Copyright holders: Sarah Walker, SA1988 see COPYING for more details */ #ifdef __cplusplus diff --git a/src/SOUND/snd_sb.c b/src/SOUND/snd_sb.c index 179a449ee..317d066e2 100644 --- a/src/SOUND/snd_sb.c +++ b/src/SOUND/snd_sb.c @@ -187,8 +187,8 @@ static void sb_get_buffer_emu8k(int32_t *buffer, int len, void *p) int c_emu8k = (((c/2) * 44100) / 48000)*2; int32_t out_l, out_r; - out_l = (((int32_t)sb->opl.buffer[c] * (int32_t)mixer->fm_l) >> 16); - out_r = (((int32_t)sb->opl.buffer[c + 1] * (int32_t)mixer->fm_r) >> 16); + out_l = ((((sb->opl.buffer[c] * mixer->fm_l) >> 16) * (opl3_type ? 47000 : 51000)) >> 16); + out_r = ((((sb->opl.buffer[c + 1] * mixer->fm_r) >> 16) * (opl3_type ? 47000 : 51000)) >> 16); out_l += ((sb->emu8k.buffer[c_emu8k] * mixer->fm_l) >> 16); out_r += ((sb->emu8k.buffer[c_emu8k + 1] * mixer->fm_l) >> 16); diff --git a/src/SOUND/sound.c b/src/SOUND/sound.c index c233c0966..369065411 100644 --- a/src/SOUND/sound.c +++ b/src/SOUND/sound.c @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.1 2017/06/04 + * Version: @(#)sound.c 1.0.2 2017/06/14 * * Authors: Sarah Walker, * Miran Grca, @@ -136,11 +136,14 @@ int soundon = 1; static int16_t cd_buffer[CDROM_NUM][CD_BUFLEN * 2]; static float cd_out_buffer[CD_BUFLEN * 2]; +static int16_t cd_out_buffer_int16[CD_BUFLEN * 2]; static thread_t *sound_cd_thread_h; static event_t *sound_cd_event; static unsigned int cd_vol_l, cd_vol_r; static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN; +int sound_is_float = 1; + void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r) { cd_vol_l = vol_l; @@ -151,10 +154,13 @@ static void sound_cd_thread(void *param) { int i = 0; + float cd_buffer_temp[2] = {0.0, 0.0}; + float cd_buffer_temp2[2] = {0.0, 0.0}; + + int c, has_audio; + while (1) { - int c, has_audio; - thread_wait_event(sound_cd_event, -1); if (!soundon) { @@ -162,8 +168,16 @@ static void sound_cd_thread(void *param) } for (c = 0; c < CD_BUFLEN*2; c += 2) { - cd_out_buffer[c] = 0.0; - cd_out_buffer[c+1] = 0.0; + if (sound_is_float) + { + cd_out_buffer[c] = 0.0; + cd_out_buffer[c+1] = 0.0; + } + else + { + cd_out_buffer_int16[c] = 0; + cd_out_buffer_int16[c+1] = 0; + } } for (i = 0; i < CDROM_NUM; i++) { @@ -184,9 +198,6 @@ static void sound_cd_thread(void *param) for (c = 0; c < CD_BUFLEN*2; c += 2) { - float cd_buffer_temp[2] = {0.0, 0.0}; - float cd_buffer_temp2[2] = {0.0, 0.0}; - /* First, transfer the CD audio data to the temporary buffer. */ cd_buffer_temp[0] = (float) cd_buffer[i][c]; cd_buffer_temp[1] = (float) cd_buffer[i][c+1]; @@ -223,20 +234,71 @@ static void sound_cd_thread(void *param) cd_buffer_temp2[1] *= (float) cd_vol_r; cd_buffer_temp2[1] /= 65535.0; - cd_out_buffer[c] += (cd_buffer_temp2[0] / 32768.0); - cd_out_buffer[c+1] += (cd_buffer_temp2[1] / 32768.0); + if (sound_is_float) + { + cd_out_buffer[c] += (cd_buffer_temp2[0] / 32768.0); + cd_out_buffer[c+1] += (cd_buffer_temp2[1] / 32768.0); + } + else + { + if (cd_buffer_temp2[0] > 32767) + cd_buffer_temp2[0] = 32767; + if (cd_buffer_temp2[0] < -32768) + cd_buffer_temp2[0] = -32768; + if (cd_buffer_temp2[1] > 32767) + cd_buffer_temp2[1] = 32767; + if (cd_buffer_temp2[1] < -32768) + cd_buffer_temp2[1] = -32768; + + cd_out_buffer_int16[c] += cd_buffer_temp2[0]; + cd_out_buffer_int16[c+1] += cd_buffer_temp2[1]; + } } } } - givealbuffer_cd(cd_out_buffer); + if (sound_is_float) + { + givealbuffer_cd(cd_out_buffer); + } + else + { + givealbuffer_cd_int16(cd_out_buffer_int16); + } } } static int32_t *outbuffer; static float *outbuffer_ex; +static int16_t *outbuffer_ex_int16; static int cd_thread_enable = 0; +void sound_realloc_buffers(void) +{ + closeal(); + initalmain(0,NULL); + inital(); + + if (outbuffer_ex != NULL) + { + free(outbuffer_ex); + } + + if (outbuffer_ex_int16 != NULL) + { + free(outbuffer_ex_int16); + } + + if (sound_is_float) + { + outbuffer_ex = malloc(SOUNDBUFLEN * 2 * sizeof(float)); + } + else + { + outbuffer_ex_int16 = malloc(SOUNDBUFLEN * 2 * sizeof(int16_t)); + } +} + void sound_init(void) { int i = 0; @@ -245,8 +307,12 @@ void sound_init(void) initalmain(0,NULL); inital(); + outbuffer_ex = NULL; + outbuffer_ex_int16 = NULL; + outbuffer = malloc(SOUNDBUFLEN * 2 * sizeof(int32_t)); - outbuffer_ex = malloc(SOUNDBUFLEN * 2 * sizeof(float)); + + sound_realloc_buffers(); for (i = 0; i < CDROM_NUM; i++) { @@ -289,10 +355,32 @@ void sound_poll(void *priv) for (c = 0; c < SOUNDBUFLEN * 2; c++) { - outbuffer_ex[c] = ((float) outbuffer[c]) / 32768.0; + if (sound_is_float) + { + outbuffer_ex[c] = ((float) outbuffer[c]) / 32768.0; + } + else + { + if (outbuffer[c] > 32767) + outbuffer[c] = 32767; + if (outbuffer[c] < -32768) + outbuffer[c] = -32768; + + outbuffer_ex_int16[c] = outbuffer[c]; + } } - if (soundon) givealbuffer(outbuffer_ex); + if (soundon) + { + if (sound_is_float) + { + givealbuffer(outbuffer_ex); + } + else + { + givealbuffer_int16(outbuffer_ex_int16); + } + } if (cd_thread_enable) { diff --git a/src/SOUND/sound.h b/src/SOUND/sound.h index 22d2d2afa..05540b403 100644 --- a/src/SOUND/sound.h +++ b/src/SOUND/sound.h @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.h 1.0.0 2017/05/30 + * Version: @(#)sound.h 1.0.1 2017/06/14 * * Author: Sarah Walker, * Miran Grca, @@ -35,12 +35,18 @@ void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r); extern int sound_pos_global; void sound_speed_changed(); +extern int sound_is_float; +void sound_realloc_buffers(void); + void sound_init(); void sound_reset(); void sound_cd_thread_reset(); +void closeal(void); void initalmain(int argc, char *argv[]); void inital(); void givealbuffer(float *buf); +void givealbuffer_int16(int16_t *buf); void givealbuffer_cd(float *buf); +void givealbuffer_cd_int16(int16_t *buf); diff --git a/src/VIDEO/vid_ega.c b/src/VIDEO/vid_ega.c index 55f46f17e..378db12e8 100644 --- a/src/VIDEO/vid_ega.c +++ b/src/VIDEO/vid_ega.c @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.1 2017/06/01 + * Version: @(#)vid_ega.c 1.0.2 2017/06/05 * * Author: Sarah Walker, * Miran Grca, @@ -45,15 +45,8 @@ static int old_overscan_color = 0; int update_overscan = 0; -#define SBCS 0 -#define DBCS 1 -#define ID_LEN 6 -#define NAME_LEN 8 -#define SBCS19_LEN 256 * 19 -#define DBCS16_LEN 65536 * 32 - -uint8_t jfont_sbcs_19[SBCS19_LEN];//256 * 19( * 8) -uint8_t jfont_dbcs_16[DBCS16_LEN];//65536 * 16 * 2 (* 8) +uint8_t jfont_sbcs_19[SBCS19_LEN]; /* 256 * 19( * 8) */ +uint8_t jfont_dbcs_16[DBCS16_LEN]; /* 65536 * 16 * 2 (* 8) */ typedef struct { char id[ID_LEN]; @@ -68,6 +61,16 @@ typedef struct { uint16_t end; } fontxTbl; +static __inline int ega_jega_enabled(ega_t *ega) +{ + if (!ega->is_jega) + { + return 0; + } + + return !(ega->RMOD1 & 0x40); +} + void ega_jega_write_font(ega_t *ega) { unsigned int chr = ega->RDFFB; @@ -529,7 +532,14 @@ void ega_poll(void *p) } else if (!(ega->gdcreg[6] & 1)) { - ega_render_text_standard(ega, drawcursor); + if (ega_jega_enabled(ega)) + { + ega_render_text_jega(ega, drawcursor); + } + else + { + ega_render_text_standard(ega, drawcursor); + } } else { diff --git a/src/VIDEO/vid_ega.h b/src/VIDEO/vid_ega.h index 2fef2c0ca..90ddf17a4 100644 --- a/src/VIDEO/vid_ega.h +++ b/src/VIDEO/vid_ega.h @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.h 1.0.0 2017/05/30 + * Version: @(#)vid_ega.h 1.0.1 2017/06/05 * * Author: Sarah Walker, * Miran Grca, @@ -110,3 +110,13 @@ void ega_init(ega_t *ega); extern device_t ega_device; extern device_t cpqega_device; extern device_t sega_device; + +#define SBCS 0 +#define DBCS 1 +#define ID_LEN 6 +#define NAME_LEN 8 +#define SBCS19_LEN 256 * 19 +#define DBCS16_LEN 65536 * 32 + +extern uint8_t jfont_sbcs_19[SBCS19_LEN]; /* 256 * 19( * 8) */ +extern uint8_t jfont_dbcs_16[DBCS16_LEN]; /* 65536 * 16 * 2 (* 8) */ diff --git a/src/VIDEO/vid_ega_render.c b/src/VIDEO/vid_ega_render.c index f100b3c64..bd4b6a358 100644 --- a/src/VIDEO/vid_ega_render.c +++ b/src/VIDEO/vid_ega_render.c @@ -8,7 +8,7 @@ * * EGA renderers. * - * Version: @(#)vid_ega_render.c 1.0.0 2017/05/30 + * Version: @(#)vid_ega_render.c 1.0.1 2017/06/05 * * Author: Sarah Walker, * Miran Grca, @@ -147,6 +147,237 @@ void ega_render_text_standard(ega_t *ega, int drawcursor) } } +static __inline int is_kanji1(uint8_t chr) +{ + return (chr >= 0x81 && chr <= 0x9f) || (chr >= 0xe0 && chr <= 0xfc); +} + +static __inline int is_kanji2(uint8_t chr) +{ + return (chr >= 0x40 && chr <= 0x7e) || (chr >= 0x80 && chr <= 0xfc); +} + +void ega_jega_render_blit_text(ega_t *ega, int x, int dl, int start, int width, uint16_t dat, int cw, uint32_t fg, uint32_t bg) +{ + int x_add = (enable_overscan) ? 8 : 0; + + int xx = 0; + int xxx = 0; + + if (ega->seqregs[1] & 8) + { + for (xx = start; xx < (start + width); xx++) + for (xxx = 0; xxx < cw; xxx++) + ((uint32_t *)buffer32->line[dl])[(((x * width) + 32 + (xxx << 1) + ((xx << 1) * cw)) & 2047) + x_add] = + ((uint32_t *)buffer32->line[dl])[(((x * width) + 33 + (xxx << 1) + ((xx << 1) * cw)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; + } + else + { + for (xx = start; xx < (start + width); xx++) + ((uint32_t *)buffer32->line[dl])[(((x * width) + 32 + xxx + (xx * cw)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; + } +} + +void ega_render_text_jega(ega_t *ega, int drawcursor) +{ + int x_add = (enable_overscan) ? 8 : 0; + int dl = ega_display_line(ega); + uint8_t chr, attr; + uint16_t dat, dat2; + uint32_t charaddr; + int x, xx; + uint32_t fg, bg; + + /* Temporary for DBCS. */ + unsigned int chr_left; + unsigned int bsattr; + int chr_wide = 0; + uint32_t bg_ex = 0; + uint32_t fg_ex = 0; + + int blocks = ega->hdisp; + int fline; + + unsigned int pad_y, exattr; + + if (fullchange) + { + for (x = 0; x < ega->hdisp; x++) + { + drawcursor = ((ega->ma == ega->ca) && ega->con && ega->cursoron); + chr = ega->vram[(ega->ma << 1) & ega->vrammask]; + attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask]; + + if (chr_wide = 0) + { + if (ega->RMOD2 & 0x80) + { + fg_ex = ega->pallook[ega->egapal[attr & 15]]; + + if (attr & 0x80 && ega->attrregs[0x10] & 8) + { + bg_ex = ega->pallook[ega->egapal[(attr >> 4) & 7]]; + } + else + { + bg_ex = ega->pallook[ega->egapal[attr >> 4]]; + } + } + else + { + if (attr & 0x40) + { + /* Reversed in JEGA mode */ + bg_ex = ega->pallook[ega->egapal[attr & 15]]; + fg_ex = ega->pallook[0]; + } + else + { + /* Reversed in JEGA mode */ + fg_ex = ega->pallook[ega->egapal[attr & 15]]; + bg_ex = ega->pallook[0]; + } + } + + if (drawcursor) + { + bg = fg_ex; + fg = bg_ex; + } + else + { + fg = fg_ex; + bg = bg_ex; + } + + if (attr & 0x80 && ega->attrregs[0x10] & 8) + { + if (ega->blink & 16) + fg = bg; + } + + /* Stay drawing if the char code is DBCS and not at last column. */ + if (is_kanji1(dat) && (blocks > 1)) + { + /* Set the present char/attr code to the next loop. */ + chr_left = chr; + chr_wide = 1; + } + else + { + /* The char code is ANK (8 dots width). */ + dat = jfont_sbcs_19[chr*19+(ega->sc)]; /* w8xh19 font */ + ega_jega_render_blit_text(ega, x, dl, 0, 8, dat, 1, fg, bg); + if (bsattr & 0x20) + { + /* Vertical line. */ + dat = 0x18; + ega_jega_render_blit_text(ega, x, fline, 0, 8, dat, 1, fg, bg); + } + if (ega->sc == 18 && bsattr & 0x10) + { + /* Underline. */ + dat = 0xff; + ega_jega_render_blit_text(ega, x, fline, 0, 8, dat, 1, fg, bg); + } + chr_wide = 0; + blocks--; + } + } + else + { + /* The char code may be in DBCS. */ + pad_y = ega->RPSSC; + exattr = 0; + + /* Note: The second column should be applied its basic attribute. */ + if (ega->RMOD2 & 0x40) + { + /* If JEGA Extended Attribute is enabled. */ + exattr = attr; + if ((exattr & 0x30) == 0x30) pad_y = ega->RPSSL; /* Set top padding of lower 2x character. */ + else if (exattr & 0x30) pad_y = ega->RPSSU; /* Set top padding of upper 2x character. */ + } + + if (ega->sc >= pad_y && ega->sc < 16 + pad_y) + { + /* Check the char code is in Wide charset of Shift-JIS. */ + if (is_kanji2(chr)) + { + fline = ega->sc - pad_y; + chr_left <<= 8; + /* Fix vertical position. */ + chr |= chr_left; + /* Horizontal wide font (Extended Attribute). */ + if (exattr & 0x20) + { + if (exattr & 0x10) fline = (fline >> 1) + 8; + else fline = fline >> 1; + } + /* Vertical wide font (Extended Attribute). */ + if (exattr & 0x40) + { + dat = jfont_dbcs_16[chr * 32 + fline * 2]; + if (!(exattr & 0x08)) + dat = jfont_dbcs_16[chr * 32 + fline * 2 + 1]; + /* Draw 8 dots. */ + ega_jega_render_blit_text(ega, x, dl, 0, 8, dat, 2, fg, bg); + } + else + { + /* Get the font pattern. */ + dat = jfont_dbcs_16[chr * 32 + fline * 2]; + dat <<= 8; + dat |= jfont_dbcs_16[chr * 32 + fline * 2 + 1]; + /* Bold (Extended Attribute). */ + if (exattr &= 0x80) + { + dat2 = dat; + dat2 >>= 1; + dat |= dat2; + /* Original JEGA colours the last row with the next column's attribute. */ + } + /* Draw 16 dots */ + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); + } + } + else + { + /* Ignore wide char mode, put blank. */ + dat = 0; + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); + } + } + else if (ega->sc == (17 + pad_y) && (bsattr & 0x10)) + { + /* Underline. */ + dat = 0xffff; + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); + } + else + { + /* Draw blank */ + dat = 0; + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); + } + + if (bsattr & 0x20) + { + /* Vertical line draw at last. */ + dat = 0x0180; + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); + } + + chr_wide = 0; + blocks -= 2; /* Move by 2 columns. */ + } + + ega->ma += 4; + ega->ma &= ega->vrammask; + } + } +} + void ega_render_2bpp_lowres(ega_t *ega) { int x_add = (enable_overscan) ? 8 : 0; diff --git a/src/VIDEO/vid_ega_render.h b/src/VIDEO/vid_ega_render.h index 0f7805751..b833128a9 100644 --- a/src/VIDEO/vid_ega_render.h +++ b/src/VIDEO/vid_ega_render.h @@ -8,7 +8,7 @@ * * EGA renderers. * - * Version: @(#)vid_ega_render.h 1.0.0 2017/05/30 + * Version: @(#)vid_ega_render.h 1.0.1 2017/06/05 * * Author: Sarah Walker, * Miran Grca, @@ -29,7 +29,7 @@ extern uint8_t edatlookup[4][4]; void ega_render_blank(ega_t *ega); void ega_render_text_standard(ega_t *ega, int drawcursor); -void ega_render_text_jega(ega_t *ega); +void ega_render_text_jega(ega_t *ega, int drawcursor); void ega_render_2bpp_lowres(ega_t *ega); void ega_render_2bpp_highres(ega_t *ega); diff --git a/src/VIDEO/vid_svga_render.c b/src/VIDEO/vid_svga_render.c index 0d09326e7..c942cf6ab 100644 --- a/src/VIDEO/vid_svga_render.c +++ b/src/VIDEO/vid_svga_render.c @@ -691,22 +691,36 @@ void svga_render_15bpp_lowres(svga_t *svga) int x; int offset = (8 - (svga->scrollcache & 6)) + 24; uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; - + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - - for (x = 0; x <= svga->hdisp; x += 4) + + for (x = 0; x <= svga->hdisp; x += 16) { - uint32_t dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + (x << 1), svga)]); - + uint32_t dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x, svga)]); p[x] = svga_color_transform(video_15to32[dat & 0xffff]); - p[x + 1] = svga_color_transform(video_15to32[dat >> 16]); + p[x + 1] = svga_color_transform(video_15to32[dat & 0xffff]); + p[x + 2] = svga_color_transform(video_15to32[dat >> 16]); + p[x + 3] = svga_color_transform(video_15to32[dat >> 16]); + + dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x + 4, svga)]); + p[x + 4] = svga_color_transform(video_15to32[dat & 0xffff]); + p[x + 5] = svga_color_transform(video_15to32[dat & 0xffff]); + p[x + 6] = svga_color_transform(video_15to32[dat >> 16]); + p[x + 7] = svga_color_transform(video_15to32[dat >> 16]); - dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + (x << 1) + 4, svga)]); + dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x + 8, svga)]); + p[x + 8] = svga_color_transform(video_15to32[dat & 0xffff]); + p[x + 9] = svga_color_transform(video_15to32[dat & 0xffff]); + p[x + 10] = svga_color_transform(video_15to32[dat >> 16]); + p[x + 11] = svga_color_transform(video_15to32[dat >> 16]); - p[x] = svga_color_transform(video_15to32[dat & 0xffff]); - p[x + 1] = svga_color_transform(video_15to32[dat >> 16]); + dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x + 12, svga)]); + p[x + 12] = svga_color_transform(video_15to32[dat & 0xffff]); + p[x + 13] = svga_color_transform(video_15to32[dat & 0xffff]); + p[x + 14] = svga_color_transform(video_15to32[dat >> 16]); + p[x + 15] = svga_color_transform(video_15to32[dat >> 16]); } svga->ma += x << 1; svga->ma = svga_mask_addr(svga->ma, svga); @@ -763,22 +777,36 @@ void svga_render_16bpp_lowres(svga_t *svga) int x; int offset = (8 - (svga->scrollcache & 6)) + 24; uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; - + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - - for (x = 0; x <= svga->hdisp; x += 4) + + for (x = 0; x <= svga->hdisp; x += 16) { - uint32_t dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + (x << 1), svga)]); - + uint32_t dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x, svga)]); p[x] = svga_color_transform(video_16to32[dat & 0xffff]); - p[x + 1] = svga_color_transform(video_16to32[dat >> 16]); + p[x + 1] = svga_color_transform(video_16to32[dat & 0xffff]); + p[x + 2] = svga_color_transform(video_16to32[dat >> 16]); + p[x + 3] = svga_color_transform(video_16to32[dat >> 16]); + + dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x + 4, svga)]); + p[x + 4] = svga_color_transform(video_16to32[dat & 0xffff]); + p[x + 5] = svga_color_transform(video_16to32[dat & 0xffff]); + p[x + 6] = svga_color_transform(video_16to32[dat >> 16]); + p[x + 7] = svga_color_transform(video_16to32[dat >> 16]); - dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + (x << 1) + 4, svga)]); + dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x + 8, svga)]); + p[x + 8] = svga_color_transform(video_16to32[dat & 0xffff]); + p[x + 9] = svga_color_transform(video_16to32[dat & 0xffff]); + p[x + 10] = svga_color_transform(video_16to32[dat >> 16]); + p[x + 11] = svga_color_transform(video_16to32[dat >> 16]); - p[x] = svga_color_transform(video_16to32[dat & 0xffff]); - p[x + 1] = svga_color_transform(video_16to32[dat >> 16]); + dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + x + 12, svga)]); + p[x + 12] = svga_color_transform(video_16to32[dat & 0xffff]); + p[x + 13] = svga_color_transform(video_16to32[dat & 0xffff]); + p[x + 14] = svga_color_transform(video_16to32[dat >> 16]); + p[x + 15] = svga_color_transform(video_16to32[dat >> 16]); } svga->ma += x << 1; svga->ma = svga_mask_addr(svga->ma, svga); @@ -940,6 +968,32 @@ void svga_render_32bpp_highres(svga_t *svga) } } +void svga_render_ABGR8888_lowres(svga_t *svga) +{ + int y_add = (enable_overscan) ? 16 : 0; + int x_add = y_add >> 1; + int dl = svga_display_line(svga); + + if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) + { + int x; + int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; + + if (svga->firstline_draw == 2000) + svga->firstline_draw = svga->displine; + svga->lastline_draw = svga->displine; + + for (x = 0; x <= svga->hdisp; x++) + { + uint32_t dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + (x << 2), svga)]); + p[x << 1] = p[(x << 1) + 1] = svga_color_transform(((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16)); + } + svga->ma += 4; + svga->ma = svga_mask_addr(svga->ma, svga); + } +} + void svga_render_ABGR8888_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; @@ -966,6 +1020,32 @@ void svga_render_ABGR8888_highres(svga_t *svga) } } +void svga_render_RGBA8888_lowres(svga_t *svga) +{ + int y_add = (enable_overscan) ? 16 : 0; + int x_add = y_add >> 1; + int dl = svga_display_line(svga); + + if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) + { + int x; + int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; + + if (svga->firstline_draw == 2000) + svga->firstline_draw = svga->displine; + svga->lastline_draw = svga->displine; + + for (x = 0; x <= svga->hdisp; x++) + { + uint32_t dat = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma + (x << 2), svga)]); + p[x << 1] = p[(x << 1) + 1] = svga_color_transform(dat >> 8); + } + svga->ma += 4; + svga->ma = svga_mask_addr(svga->ma, svga); + } +} + void svga_render_RGBA8888_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; diff --git a/src/VIDEO/vid_svga_render.h b/src/VIDEO/vid_svga_render.h index eb3715fdd..cfad3585d 100644 --- a/src/VIDEO/vid_svga_render.h +++ b/src/VIDEO/vid_svga_render.h @@ -47,7 +47,9 @@ void svga_render_24bpp_lowres(svga_t *svga); void svga_render_24bpp_highres(svga_t *svga); void svga_render_32bpp_lowres(svga_t *svga); void svga_render_32bpp_highres(svga_t *svga); +void svga_render_ABGR8888_lowres(svga_t *svga); void svga_render_ABGR8888_highres(svga_t *svga); +void svga_render_RGBA8888_lowres(svga_t *svga); void svga_render_RGBA8888_highres(svga_t *svga); extern void (*svga_render)(svga_t *svga); diff --git a/src/VIDEO/vid_voodoo.c b/src/VIDEO/vid_voodoo.c index 9b823e1a2..f033acdbb 100644 --- a/src/VIDEO/vid_voodoo.c +++ b/src/VIDEO/vid_voodoo.c @@ -14,6 +14,15 @@ #include "vid_voodoo.h" #include "vid_voodoo_dither.h" +#ifdef MIN +#undef MIN +#endif +#ifdef ABS +#undef ABS +#endif +#ifdef CLAMP +#undef CLAMP +#endif #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -53,7 +62,6 @@ static int tris = 0; static uint64_t status_time = 0; static uint64_t voodoo_time = 0; static int voodoo_render_time[2] = {0, 0}; -static int voodoo_render_time_old[2] = {0, 0}; typedef union int_float { @@ -384,9 +392,9 @@ typedef struct voodoo_t int wake_timer; - uint8_t thefilter[256][256]; /* pixel filter, feeding from one or two */ - uint8_t thefilterg[256][256]; /* for green */ - uint8_t thefilterb[256][256]; /* for blue */ + uint8_t thefilter[256][256]; // pixel filter, feeding from one or two + uint8_t thefilterg[256][256]; // for green + uint8_t thefilterb[256][256]; // for blue /* the voodoo adds purple lines for some reason */ uint16_t purpleline[256][3]; @@ -402,7 +410,7 @@ typedef struct voodoo_t void *codegen_data; } voodoo_t; -static __inline void wait_for_render_thread_idle(voodoo_t *voodoo); +static inline void wait_for_render_thread_idle(voodoo_t *voodoo); enum { @@ -552,7 +560,6 @@ enum SST_cmdFifoHoles = 0x1f8, SST_fbiInit4 = 0x200, - SST_vRetrace = 0x204, SST_backPorch = 0x208, SST_videoDimensions = 0x20c, @@ -715,7 +722,7 @@ enum SST_remap_fdAdY = 0x00d8 | 0x400, SST_remap_fdSdY = 0x00e4 | 0x400, SST_remap_fdTdY = 0x00f0 | 0x400, - SST_remap_fdWdY = 0x00fc | 0x400 + SST_remap_fdWdY = 0x00fc | 0x400, }; enum @@ -994,10 +1001,8 @@ static void voodoo_update_ncc(voodoo_t *voodoo, int tmu) for (col = 0; col < 256; col++) { int y = (col >> 4), i = (col >> 2) & 3, q = col & 3; - int _y = (col >> 4), _i = (col >> 2) & 3, _q = col & 3; int i_r, i_g, i_b; int q_r, q_g, q_b; - int r, g, b; y = (voodoo->nccTable[tmu][tbl].y[y >> 2] >> ((y & 3) * 8)) & 0xff; @@ -1108,8 +1113,6 @@ static void voodoo_recalc_tex(voodoo_t *voodoo, int tmu) int width = 256, height = 256; int shift = 8; int lod; - int lod_min = (voodoo->params.tLOD[tmu] >> 2) & 15; - int lod_max = (voodoo->params.tLOD[tmu] >> 8) & 15; uint32_t base = voodoo->params.texBaseAddr[tmu]; int tex_lod = 0; @@ -1243,6 +1246,7 @@ static void use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) lod_min = (params->tLOD[tmu] >> 2) & 15; lod_max = (params->tLOD[tmu] >> 8) & 15; +// pclog(" add new texture to %i tformat=%i %08x LOD=%i-%i\n", c, voodoo->params.tformat[tmu], params->texBaseAddr[tmu], lod_min, lod_max); for (lod = lod_min; lod <= lod_max; lod++) { @@ -1251,7 +1255,10 @@ static void use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) int x, y; int shift = 8 - params->tex_lod[tmu][lod]; rgba_u *pal; + + //pclog(" LOD %i : %08x - %08x %i %i,%i\n", lod, params->tex_base[tmu][lod] & voodoo->texture_mask, addr, voodoo->params.tformat[tmu], voodoo->params.tex_w_mask[tmu][lod],voodoo->params.tex_h_mask[tmu][lod]); + switch (params->tformat[tmu]) { case TEX_RGB332: @@ -1489,17 +1496,17 @@ static void flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu) int c; memset(voodoo->texture_present[tmu], 0, sizeof(voodoo->texture_present[0])); +// pclog("Evict %08x %i\n", dirty_addr, sizeof(voodoo->texture_present)); for (c = 0; c < TEX_CACHE_MAX; c++) { if (voodoo->texture_cache[tmu][c].base != -1) { - int lod_min = (voodoo->texture_cache[tmu][c].tLOD >> 2) & 15; - int lod_max = (voodoo->texture_cache[tmu][c].tLOD >> 8) & 15; int addr_start = voodoo->texture_cache[tmu][c].addr_start; int addr_end = voodoo->texture_cache[tmu][c].addr_end; if (dirty_addr >= (addr_start & voodoo->texture_mask & ~0x3ff) && dirty_addr < (((addr_end & voodoo->texture_mask) + 0x3ff) & ~0x3ff)) { +// pclog(" Evict texture %i %08x\n", c, voodoo->texture_cache[tmu][c].base); if (voodoo->texture_cache[tmu][c].refcount != voodoo->texture_cache[tmu][c].refcount_r[0] || (voodoo->render_threads == 2 && voodoo->texture_cache[tmu][c].refcount != voodoo->texture_cache[tmu][c].refcount_r[1])) @@ -1552,7 +1559,7 @@ typedef struct voodoo_state_t int32_t ib, ig, ir, ia; int32_t z; - int64_t new_depth; + int32_t new_depth; int64_t tmu0_s, tmu0_t; int64_t tmu0_w; @@ -1563,7 +1570,7 @@ typedef struct voodoo_state_t int pixel_count, texel_count; int x, x2; - uint64_t w_depth; + uint32_t w_depth; float log_temp; uint32_t ebp_store; @@ -1594,7 +1601,7 @@ static uint8_t logtable[256] = 0xf4,0xf5,0xf5,0xf6,0xf7,0xf7,0xf8,0xf9,0xfa,0xfa,0xfb,0xfc,0xfd,0xfd,0xfe,0xff }; -static __inline int fastlog(uint64_t val) +static inline int fastlog(uint64_t val) { uint64_t oldval = val; int exp = 63; @@ -1603,32 +1610,32 @@ static __inline int fastlog(uint64_t val) if (!val || val & (1ULL << 63)) return 0x80000000; - if (!(val & 0xffffffff00000000ll)) + if (!(val & 0xffffffff00000000)) { exp -= 32; val <<= 32; } - if (!(val & 0xffff000000000000ll)) + if (!(val & 0xffff000000000000)) { exp -= 16; val <<= 16; } - if (!(val & 0xff00000000000000ll)) + if (!(val & 0xff00000000000000)) { exp -= 8; val <<= 8; } - if (!(val & 0xf000000000000000ll)) + if (!(val & 0xf000000000000000)) { exp -= 4; val <<= 4; } - if (!(val & 0xc000000000000000ll)) + if (!(val & 0xc000000000000000)) { exp -= 2; val <<= 2; } - if (!(val & 0x8000000000000000ll)) + if (!(val & 0x8000000000000000)) { exp -= 1; val <<= 1; @@ -1642,10 +1649,11 @@ static __inline int fastlog(uint64_t val) return (exp << 8) | logtable[frac]; } -static __inline int fls(uint16_t val) +static inline int voodoo_fls(uint16_t val) { int num = 0; +//pclog("fls(%04x) = ", val); if (!(val & 0xff00)) { num += 8; @@ -1666,6 +1674,7 @@ static __inline int fls(uint16_t val) num += 1; val <<= 1; } +//pclog("%i %04x\n", num, val); return num; } @@ -1676,7 +1685,7 @@ typedef struct voodoo_texture_state_t int tex_shift; } voodoo_texture_state_t; -static __inline void tex_read(voodoo_state_t *state, voodoo_texture_state_t *texture_state, int tmu) +static inline void tex_read(voodoo_state_t *state, voodoo_texture_state_t *texture_state, int tmu) { uint32_t dat; @@ -1716,7 +1725,7 @@ static __inline void tex_read(voodoo_state_t *state, voodoo_texture_state_t *tex #define LOW4(x) ((x & 0x0f) | ((x & 0x0f) << 4)) #define HIGH4(x) ((x & 0xf0) | ((x & 0xf0) >> 4)) -static __inline void tex_read_4(voodoo_state_t *state, voodoo_texture_state_t *texture_state, int s, int t, int *d, int tmu, int x) +static inline void tex_read_4(voodoo_state_t *state, voodoo_texture_state_t *texture_state, int s, int t, int *d, int tmu, int x) { rgba_u dat[4]; @@ -1769,9 +1778,8 @@ static __inline void tex_read_4(voodoo_state_t *state, voodoo_texture_state_t *t state->tex_a[tmu] = (dat[0].rgba.a * d[0] + dat[1].rgba.a * d[1] + dat[2].rgba.a * d[2] + dat[3].rgba.a * d[3]) >> 8; } -static __inline void voodoo_get_texture(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int tmu, int x) +static inline void voodoo_get_texture(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int tmu, int x) { - rgba_u tex_samples[4]; voodoo_texture_state_t texture_state; int d[4]; int s, t; @@ -1807,26 +1815,54 @@ static __inline void voodoo_get_texture(voodoo_t *voodoo, voodoo_params_t *param s >>= 4; t >>= 4; - +//if (x == 80) +//if (voodoo_output) +// pclog("s=%08x t=%08x _ds=%02x _dt=%02x\n", s, t, _ds, dt); d[0] = (16 - _ds) * (16 - dt); d[1] = _ds * (16 - dt); d[2] = (16 - _ds) * dt; d[3] = _ds * dt; +// texture_state.s = s; +// texture_state.t = t; tex_read_4(state, &texture_state, s, t, d, tmu, x); + + +/* state->tex_r = (tex_samples[0].rgba.r * d[0] + tex_samples[1].rgba.r * d[1] + tex_samples[2].rgba.r * d[2] + tex_samples[3].rgba.r * d[3]) >> 8; + state->tex_g = (tex_samples[0].rgba.g * d[0] + tex_samples[1].rgba.g * d[1] + tex_samples[2].rgba.g * d[2] + tex_samples[3].rgba.g * d[3]) >> 8; + state->tex_b = (tex_samples[0].rgba.b * d[0] + tex_samples[1].rgba.b * d[1] + tex_samples[2].rgba.b * d[2] + tex_samples[3].rgba.b * d[3]) >> 8; + state->tex_a = (tex_samples[0].rgba.a * d[0] + tex_samples[1].rgba.a * d[1] + tex_samples[2].rgba.a * d[2] + tex_samples[3].rgba.a * d[3]) >> 8;*/ +/* state->tex_r = tex_samples[0].r; + state->tex_g = tex_samples[0].g; + state->tex_b = tex_samples[0].b; + state->tex_a = tex_samples[0].a;*/ } else { + // rgba_t tex_samples; + // voodoo_texture_state_t texture_state; +// int s = state->tex_s >> (18+state->lod); +// int t = state->tex_t >> (18+state->lod); + // int s, t; + +// state->tex_s -= 1 << (17+state->lod); +// state->tex_t -= 1 << (17+state->lod); + s = state->tex_s >> (4+tex_lod); t = state->tex_t >> (4+tex_lod); texture_state.s = s; texture_state.t = t; tex_read(state, &texture_state, tmu); + +/* state->tex_r = tex_samples[0].rgba.r; + state->tex_g = tex_samples[0].rgba.g; + state->tex_b = tex_samples[0].rgba.b; + state->tex_a = tex_samples[0].rgba.a;*/ } } -static __inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int tmu, int x) +static inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int tmu, int x) { if (params->textureMode[tmu] & 1) { @@ -1940,7 +1976,7 @@ static __inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, } \ else \ { \ - int fog_r, fog_g, fog_b, fog_a; \ + int fog_r, fog_g, fog_b, fog_a = 0; \ int fog_idx; \ \ if (!(params->fogMode & FOG_ADD)) \ @@ -2061,7 +2097,7 @@ static __inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, do \ { \ int _a; \ - int newdest_r, newdest_g, newdest_b; \ + int newdest_r = 0, newdest_g = 0, newdest_b = 0; \ \ switch (dest_afunc) \ { \ @@ -2216,12 +2252,12 @@ static __inline void voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, #define dither2x2 (params->fbzMode & FBZ_DITHER_2x2) /*Perform texture fetch and blending for both TMUs*/ -static __inline void voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int x) +static inline void voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int x) { int r,g,b,a; int c_reverse, a_reverse; - int c_reverse1, a_reverse1; - int factor_r, factor_g, factor_b, factor_a; +// int c_reverse1, a_reverse1; + int factor_r = 0, factor_g = 0, factor_b = 0, factor_a = 0; voodoo_tmu_fetch(voodoo, params, state, 1, x); @@ -2235,8 +2271,8 @@ static __inline void voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_ c_reverse = !tc_reverse_blend; a_reverse = !tca_reverse_blend; } - c_reverse1 = c_reverse; - a_reverse1 = a_reverse; +/* c_reverse1 = c_reverse; + a_reverse1 = a_reverse;*/ if (tc_sub_clocal_1) { switch (tc_mselect_1) @@ -2507,6 +2543,8 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood state->clamp_t[0] = params->textureMode[0] & TEXTUREMODE_TCLAMPT; state->clamp_s[1] = params->textureMode[1] & TEXTUREMODE_TCLAMPS; state->clamp_t[1] = params->textureMode[1] & TEXTUREMODE_TCLAMPT; +// int last_x; +// pclog("voodoo_triangle : bottom-half %X %X %X %X %X %i %i %i %i\n", xstart, xend, dx1, dx2, dx2 * 36, xdir, y, yend, ydir); for (c = 0; c <= LOD_MAX; c++) { @@ -2551,14 +2589,18 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood yend = params->clipHighY; state->y = ystart; +// yend--; #ifndef NO_CODEGEN if (voodoo->use_recompiler) voodoo_draw = voodoo_get_block(voodoo, params, state, odd_even); + else + voodoo_draw = NULL; #endif if (voodoo_output) pclog("dxAB=%08x dxBC=%08x dxAC=%08x\n", state->dxAB, state->dxBC, state->dxAC); +// pclog("Start %i %i\n", ystart, voodoo->fbzMode & (1 << 17)); for (; state->y < yend; state->y++) { int x, x2; @@ -2623,7 +2665,7 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood state->w += (params->dWdX * dx); if (voodoo_output) - pclog("%08llx %lli %lli\n", state->tmu0_t, state->tmu0_t >> (18+state->lod), (state->tmu0_t + (1 << 17+state->lod)) >> (18+state->lod)); + pclog("%08llx %lli %lli\n", state->tmu0_t, state->tmu0_t >> (18+state->lod), (state->tmu0_t + (1 << (17+state->lod))) >> (18+state->lod)); if (params->fbzMode & 1) { @@ -2682,8 +2724,8 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood if (x2 > x && state->xdir < 0) goto next_line; - state->fb_mem = fb_mem = &voodoo->fb_mem[params->draw_offset + (real_y * voodoo->row_width)]; - state->aux_mem = aux_mem = &voodoo->fb_mem[(params->aux_offset + (real_y * voodoo->row_width)) & voodoo->fb_mask]; + state->fb_mem = fb_mem = (uint16_t *)&voodoo->fb_mem[params->draw_offset + (real_y * voodoo->row_width)]; + state->aux_mem = aux_mem = (uint16_t *)&voodoo->fb_mem[(params->aux_offset + (real_y * voodoo->row_width)) & voodoo->fb_mask]; if (voodoo_output) pclog("%03i: x=%08x x2=%08x xstart=%08x xend=%08x dx=%08x start_x2=%08x\n", state->y, x, x2, state->xstart, state->xend, dx, start_x2); @@ -2710,17 +2752,17 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood if (voodoo_output) pclog(" X=%03i T=%08x\n", x, state->tmu0_t); +// if (voodoo->fbzMode & FBZ_RGB_WMASK) { int update = 1; uint8_t cother_r, cother_g, cother_b, aother; uint8_t clocal_r, clocal_g, clocal_b, alocal; - int src_r, src_g, src_b, src_a; + int src_r = 0, src_g = 0, src_b = 0, src_a = 0; int msel_r, msel_g, msel_b, msel_a; uint8_t dest_r, dest_g, dest_b, dest_a; uint16_t dat; - uint16_t aux_dat; int sel; - int64_t new_depth, w_depth; + int32_t new_depth, w_depth; if (state->w & 0xffff00000000) w_depth = 0; @@ -2728,13 +2770,15 @@ static void voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, vood w_depth = 0xf001; else { - int exp = fls((uint16_t)((uint32_t)state->w >> 16)); + int exp = voodoo_fls((uint16_t)((uint32_t)state->w >> 16)); int mant = ((~(uint32_t)state->w >> (19 - exp))) & 0xfff; w_depth = (exp << 12) + mant + 1; if (w_depth > 0xffff) w_depth = 0xffff; } +// w_depth = CLAMP16(w_depth); + if (params->fbzMode & FBZ_W_BUFFER) new_depth = w_depth; else @@ -3138,7 +3182,6 @@ static void voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_e { voodoo_state_t state; int vertexAy_adjusted; - int vertexBy_adjusted; int vertexCy_adjusted; int dx, dy; @@ -3214,7 +3257,6 @@ static void voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_e state.vertexCx |= 0xffff0000; vertexAy_adjusted = (state.vertexAy+7) >> 4; - vertexBy_adjusted = (state.vertexBy+7) >> 4; vertexCy_adjusted = (state.vertexCy+7) >> 4; if (state.vertexBy - state.vertexAy) @@ -3283,14 +3325,14 @@ static void voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_e voodoo_half_triangle(voodoo, params, &state, vertexAy_adjusted, vertexCy_adjusted, odd_even); } -static __inline void wake_render_thread(voodoo_t *voodoo) +static inline void wake_render_thread(voodoo_t *voodoo) { thread_set_event(voodoo->wake_render_thread[0]); /*Wake up render thread if moving from idle*/ if (voodoo->render_threads == 2) thread_set_event(voodoo->wake_render_thread[1]); /*Wake up render thread if moving from idle*/ } -static __inline void wait_for_render_thread_idle(voodoo_t *voodoo) +static inline void wait_for_render_thread_idle(voodoo_t *voodoo) { while (!PARAM_EMPTY_1 || (voodoo->render_threads == 2 && !PARAM_EMPTY_2) || voodoo->render_voodoo_busy[0] || (voodoo->render_threads == 2 && voodoo->render_voodoo_busy[1])) { @@ -3343,7 +3385,7 @@ static void render_thread_2(void *param) render_thread(param, 1); } -static __inline void queue_triangle(voodoo_t *voodoo, voodoo_params_t *params) +static inline void queue_triangle(voodoo_t *voodoo, voodoo_params_t *params) { voodoo_params_t *params_new = &voodoo->params_buffer[voodoo->params_write_idx & PARAM_MASK]; @@ -3709,7 +3751,7 @@ static void blit_start(voodoo_t *voodoo) int size_x = ABS(voodoo->bltSizeX), size_y = ABS(voodoo->bltSizeY); int x_dir = (voodoo->bltSizeX > 0) ? 1 : -1; int y_dir = (voodoo->bltSizeY > 0) ? 1 : -1; - int src_x, dst_x; + int dst_x; int src_y = voodoo->bltSrcY & 0x7ff, dst_y = voodoo->bltDstY & 0x7ff; int src_stride = (voodoo->bltCommand & BLTCMD_SRC_TILED) ? ((voodoo->bltSrcXYStride & 0x3f) * 32*2) : (voodoo->bltSrcXYStride & 0xff8); int dst_stride = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstXYStride & 0x3f) * 32*2) : (voodoo->bltDstXYStride & 0xff8); @@ -3818,7 +3860,7 @@ skip_pixel_fill: case BLIT_COMMAND_SGRAM_FILL: /*32x32 tiles - 2kb*/ dst_y = voodoo->bltDstY & 0x3ff; - size_x = voodoo->bltSizeX & 0x1ff; + size_x = voodoo->bltSizeX & 0x1ff; //512*8 = 4kb size_y = voodoo->bltSizeY & 0x3ff; dat64 = voodoo->bltColorFg | ((uint64_t)voodoo->bltColorFg << 16) | @@ -3861,7 +3903,6 @@ skip_pixel_fill: static void blit_data(voodoo_t *voodoo, uint32_t data) { - uint32_t data_orig = data; int src_bits = 32; uint32_t base_addr = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstBaseAddr & 0x3ff) << 12) : (voodoo->bltDstBaseAddr & 0x3ffff8); uint16_t *dst = (uint16_t *)&voodoo->fb_mem[base_addr + voodoo->blt.dst_y*voodoo->blt.dst_stride]; @@ -3871,8 +3912,8 @@ static void blit_data(voodoo_t *voodoo, uint32_t data) while (src_bits && voodoo->blt.cur_x <= voodoo->blt.size_x) { - int r, g, b; - uint16_t src_dat, dst_dat; + int r = 0, g = 0, b = 0; + uint16_t src_dat = 0, dst_dat; int x = (voodoo->blt.x_dir > 0) ? (voodoo->blt.dst_x + voodoo->blt.cur_x) : (voodoo->blt.dst_x - voodoo->blt.cur_x); int rop = 0; @@ -4033,6 +4074,7 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) chip = 0xf; tempif.i = val; +//pclog("voodoo_reg_write_l: addr=%08x val=%08x(%f) chip=%x\n", addr, val, tempif.f, chip); addr &= 0x3fc; if ((voodoo->fbiInit3 & FBIINIT3_REMAP) && addr < 0x100 && ad21) @@ -4040,6 +4082,7 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) switch (addr) { case SST_swapbufferCMD: +// pclog(" start swap buffer command\n"); if (TRIPLE_BUFFER) { @@ -4056,6 +4099,7 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo->params.swapbufferCMD = val; pclog("Swap buffer %08x %d %p\n", val, voodoo->swap_count, &voodoo->swap_count); +// voodoo->front_offset = params->front_offset; wait_for_render_thread_idle(voodoo); if (!(val & 1)) { @@ -4513,10 +4557,12 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) case SST_sVx: tempif.i = val; voodoo->verts[3].sVx = tempif.f; +// pclog("sVx[%i]=%f\n", voodoo->vertex_num, tempif.f); break; case SST_sVy: tempif.i = val; voodoo->verts[3].sVy = tempif.f; +// pclog("sVy[%i]=%f\n", voodoo->vertex_num, tempif.f); break; case SST_sARGB: voodoo->verts[3].sBlue = (float)(val & 0xff); @@ -4574,11 +4620,13 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) break; case SST_sBeginTriCMD: +// pclog("sBeginTriCMD %i %f\n", voodoo->vertex_num, voodoo->verts[4].sVx); voodoo->verts[0] = voodoo->verts[3]; voodoo->vertex_num = 1; voodoo->num_verticies = 1; break; case SST_sDrawTriCMD: +// pclog("sDrawTriCMD %i %i %i\n", voodoo->num_verticies, voodoo->vertex_num, voodoo->sSetupMode & SETUPMODE_STRIP_MODE); if (voodoo->vertex_num == 3) voodoo->vertex_num = (voodoo->sSetupMode & SETUPMODE_STRIP_MODE) ? 1 : 0; voodoo->verts[voodoo->vertex_num] = voodoo->verts[3]; @@ -4587,6 +4635,7 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo->vertex_num++; if (voodoo->num_verticies == 3) { +// pclog("triangle_setup\n"); triangle_setup(voodoo); voodoo->num_verticies = 2; @@ -4599,11 +4648,13 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo->bltSrcBaseAddr = val & 0x3fffff; break; case SST_bltDstBaseAddr: +// pclog("Write bltDstBaseAddr %08x\n", val); voodoo->bltDstBaseAddr = val & 0x3fffff; break; case SST_bltXYStrides: voodoo->bltSrcXYStride = val & 0xfff; voodoo->bltDstXYStride = (val >> 16) & 0xfff; +// pclog("Write bltXYStrides %08x\n", val); break; case SST_bltSrcChromaRange: voodoo->bltSrcChromaRange = val; @@ -4637,12 +4688,14 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo->bltSrcY = (val >> 16) & 0x7ff; break; case SST_bltDstXY: +// pclog("Write bltDstXY %08x\n", val); voodoo->bltDstX = val & 0x7ff; voodoo->bltDstY = (val >> 16) & 0x7ff; if (val & (1 << 31)) blit_start(voodoo); break; case SST_bltSize: +// pclog("Write bltSize %08x\n", val); voodoo->bltSizeX = val & 0xfff; if (voodoo->bltSizeX & 0x800) voodoo->bltSizeX |= 0xfffff000; @@ -4659,12 +4712,14 @@ static void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo->bltRop[3] = (val >> 12) & 0xf; break; case SST_bltColor: +// pclog("Write bltColor %08x\n", val); voodoo->bltColorFg = val & 0xffff; voodoo->bltColorBg = (val >> 16) & 0xffff; break; case SST_bltCommand: voodoo->bltCommand = val; +// pclog("Write bltCommand %08x\n", val); if (val & (1 << 31)) blit_start(voodoo); break; @@ -5135,6 +5190,7 @@ static uint16_t voodoo_fb_readw(uint32_t addr, void *p) temp = *(uint16_t *)(&voodoo->fb_mem[read_addr & voodoo->fb_mask]); +// pclog("voodoo_fb_readw : %08X %08X %i %i %08X %08X %08x:%08x %i\n", addr, temp, x, y, read_addr, *(uint32_t *)(&voodoo->fb_mem[4]), cs, pc, fb_reads++); return temp; } static uint32_t voodoo_fb_readl(uint32_t addr, void *p) @@ -5153,10 +5209,11 @@ static uint32_t voodoo_fb_readl(uint32_t addr, void *p) temp = *(uint32_t *)(&voodoo->fb_mem[read_addr & voodoo->fb_mask]); +// pclog("voodoo_fb_readl : %08X %08x %08X x=%i y=%i %08X %08X %08x:%08x %i ro=%08x rw=%i\n", addr, read_addr, temp, x, y, read_addr, *(uint32_t *)(&voodoo->fb_mem[4]), cs, pc, fb_reads++, voodoo->fb_read_offset, voodoo->row_width); return temp; } -static __inline uint16_t do_dither(voodoo_params_t *params, rgba8_t col, int x, int y) +static inline uint16_t do_dither(voodoo_params_t *params, rgba8_t col, int x, int y) { int r, g, b; @@ -5194,11 +5251,19 @@ static void voodoo_fb_writew(uint32_t addr, uint16_t val, void *p) rgba8_t colour_data; uint16_t depth_data; uint8_t alpha_data; - int write_mask; + int write_mask = 0; + + colour_data.r = colour_data.g = colour_data.b = colour_data.a = 0; depth_data = voodoo->params.zaColor & 0xffff; alpha_data = voodoo->params.zaColor >> 24; - + +// while (!RB_EMPTY) +// thread_reset_event(voodoo->not_full_event); + +// pclog("voodoo_fb_writew : %08X %04X\n", addr, val); + + switch (voodoo->lfbMode & LFB_FORMAT_MASK) { case LFB_FORMAT_RGB565: @@ -5233,6 +5298,8 @@ static void voodoo_fb_writew(uint32_t addr, uint16_t val, void *p) write_addr = voodoo->fb_write_offset + x + (y * voodoo->row_width); write_addr_aux = voodoo->params.aux_offset + x + (y * voodoo->row_width); + +// pclog("fb_writew %08x %i %i %i %08x\n", addr, x, y, voodoo->row_width, write_addr); if (voodoo->lfbMode & 0x100) { @@ -5256,7 +5323,7 @@ static void voodoo_fb_writew(uint32_t addr, uint16_t val, void *p) if (params->fogMode & FOG_ENABLE) { int32_t z = new_depth << 12; - int64_t w_depth = new_depth; + int64_t w_depth = (int64_t)(int32_t)new_depth; int32_t ia = alpha_data << 12; APPLY_FOG(write_data.r, write_data.g, write_data.b, z, ia, w_depth); @@ -5309,11 +5376,15 @@ static void voodoo_fb_writel(uint32_t addr, uint32_t val, void *p) rgba8_t colour_data[2]; uint16_t depth_data[2]; uint8_t alpha_data[2]; - int write_mask, count = 1; + int write_mask = 0, count = 1; depth_data[0] = depth_data[1] = voodoo->params.zaColor & 0xffff; alpha_data[0] = alpha_data[1] = voodoo->params.zaColor >> 24; - +// while (!RB_EMPTY) +// thread_reset_event(voodoo->not_full_event); + +// pclog("voodoo_fb_writel : %08X %08X\n", addr, val); + switch (voodoo->lfbMode & LFB_FORMAT_MASK) { case LFB_FORMAT_RGB565: @@ -5365,6 +5436,8 @@ static void voodoo_fb_writel(uint32_t addr, uint32_t val, void *p) write_addr = voodoo->fb_write_offset + x + (y * voodoo->row_width); write_addr_aux = voodoo->params.aux_offset + x + (y * voodoo->row_width); + +// pclog("fb_writel %08x x=%i y=%i rw=%i %08x wo=%08x\n", addr, x, y, voodoo->row_width, write_addr, voodoo->fb_write_offset); if (voodoo->lfbMode & 0x100) { @@ -5457,6 +5530,8 @@ static void voodoo_tex_writel(uint32_t addr, uint32_t val, void *p) if (tmu && !voodoo->dual_tmus) return; +// pclog("voodoo_tex_writel : %08X %08X %i\n", addr, val, voodoo->params.tformat); + lod = (addr >> 17) & 0xf; t = (addr >> 9) & 0xff; if (voodoo->params.tformat[tmu] & 8) @@ -5471,20 +5546,24 @@ static void voodoo_tex_writel(uint32_t addr, uint32_t val, void *p) if (lod > LOD_MAX) return; - + +// if (addr >= 0x200000) +// return; + if (voodoo->params.tformat[tmu] & 8) addr = voodoo->params.tex_base[tmu][lod] + s*2 + (t << voodoo->params.tex_shift[tmu][lod])*2; else addr = voodoo->params.tex_base[tmu][lod] + s + (t << voodoo->params.tex_shift[tmu][lod]); if (voodoo->texture_present[tmu][(addr & voodoo->texture_mask) >> TEX_DIRTY_SHIFT]) { +// pclog("texture_present at %08x %i\n", addr, (addr & voodoo->texture_mask) >> TEX_DIRTY_SHIFT); flush_texture_cache(voodoo, addr & voodoo->texture_mask, tmu); } *(uint32_t *)(&voodoo->tex_mem[tmu][addr & voodoo->texture_mask]) = val; } #define WAKE_DELAY (TIMER_USEC * 100) -static __inline void wake_fifo_thread(voodoo_t *voodoo) +static inline void wake_fifo_thread(voodoo_t *voodoo) { if (!voodoo->wake_timer) { @@ -5498,7 +5577,7 @@ static __inline void wake_fifo_thread(voodoo_t *voodoo) } } -static __inline void wake_fifo_thread_now(voodoo_t *voodoo) +static inline void wake_fifo_thread_now(voodoo_t *voodoo) { thread_set_event(voodoo->wake_fifo_thread); /*Wake up FIFO thread if moving from idle*/ } @@ -5512,10 +5591,9 @@ static void voodoo_wake_timer(void *p) thread_set_event(voodoo->wake_fifo_thread); /*Wake up FIFO thread if moving from idle*/ } -static __inline void queue_command(voodoo_t *voodoo, uint32_t addr_type, uint32_t val) +static inline void queue_command(voodoo_t *voodoo, uint32_t addr_type, uint32_t val) { fifo_entry_t *fifo = &voodoo->fifo[voodoo->fifo_write_idx & FIFO_MASK]; - int c; if (FIFO_FULL) { @@ -5772,7 +5850,9 @@ static void voodoo_pixelclock_update(voodoo_t *voodoo) t /= 2.0f; line_length = (voodoo->hSync & 0xff) + ((voodoo->hSync >> 16) & 0x3ff); - + +// pclog("Pixel clock %f MHz hsync %08x line_length %d\n", t, voodoo->hSync, line_length); + voodoo->pixel_clock = t; clock_const = cpuclock / t; @@ -5782,13 +5862,7 @@ static void voodoo_pixelclock_update(voodoo_t *voodoo) static void voodoo_writel(uint32_t addr, uint32_t val, void *p) { voodoo_t *voodoo = (voodoo_t *)p; - union - { - uint32_t i; - float f; - } tempif; - tempif.i = val; voodoo->wr_count++; addr &= 0xffffff; @@ -5810,6 +5884,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) } else if ((addr & 0x200000) && (voodoo->fbiInit7 & FBIINIT7_CMDFIFO_ENABLE)) { +// pclog("Write CMDFIFO %08x(%08x) %08x %08x\n", addr, voodoo->cmdfifo_base + (addr & 0x3fffc), val, (voodoo->cmdfifo_base + (addr & 0x3fffc)) & voodoo->fb_mask); *(uint32_t *)&voodoo->fb_mem[(voodoo->cmdfifo_base + (addr & 0x3fffc)) & voodoo->fb_mask] = val; voodoo->cmdfifo_depth_wr++; if ((voodoo->cmdfifo_depth_wr - voodoo->cmdfifo_depth_rd) < 20) @@ -5872,6 +5947,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) { voodoo->fbiInit4 = val; voodoo->read_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit4 & 1) ? 2 : 1); +// pclog("fbiInit4 write %08x - read_time=%i\n", val, voodoo->read_time); } break; case SST_backPorch: @@ -5904,6 +5980,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) voodoo->fbiInit1 = val; voodoo->write_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit1 & 2) ? 1 : 0); voodoo->burst_time = pci_burst_time * ((voodoo->fbiInit1 & 2) ? 2 : 1); +// pclog("fbiInit1 write %08x - write_time=%i burst_time=%i\n", val, voodoo->write_time, voodoo->burst_time); } break; case SST_fbiInit2: @@ -5946,6 +6023,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) voodoo->dac_readdata = 0xff; if (val & 0x800) { +// pclog(" dacData read %i %02X\n", voodoo->dac_reg, voodoo->dac_data[7]); if (voodoo->dac_reg == 5) { switch (voodoo->dac_data[7]) @@ -5956,7 +6034,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) } } else - voodoo->dac_readdata = voodoo->dac_data[voodoo->dac_readdata]; + voodoo->dac_readdata = voodoo->dac_data[voodoo->dac_readdata & 7]; } else { @@ -5966,6 +6044,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] = (voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] & 0xff00) | val; else voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] = (voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] & 0xff) | (val << 8); +// pclog("Write PLL reg %x %04x\n", voodoo->dac_data[4] & 0xf, voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf]); voodoo->dac_reg_ff = !voodoo->dac_reg_ff; if (!voodoo->dac_reg_ff) voodoo->dac_data[4]++; @@ -6009,6 +6088,7 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) case SST_cmdFifoBaseAddr: voodoo->cmdfifo_base = (val & 0x3ff) << 12; voodoo->cmdfifo_end = ((val >> 16) & 0x3ff) << 12; +// pclog("CMDFIFO base=%08x end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); break; case SST_cmdFifoRdPtr: @@ -6053,10 +6133,11 @@ static uint32_t cmdfifo_get(voodoo_t *voodoo) voodoo->cmdfifo_depth_rd++; voodoo->cmdfifo_rp += 4; +// pclog(" CMDFIFO get %08x\n", val); return val; } -static __inline float cmdfifo_get_f(voodoo_t *voodoo) +static inline float cmdfifo_get_f(voodoo_t *voodoo) { union { @@ -6137,10 +6218,13 @@ static void fifo_thread(void *param) int num; int num_verticies; int v_num; - + +// pclog(" CMDFIFO header %08x at %08x\n", header, voodoo->cmdfifo_rp); + switch (header & 7) { case 0: +// pclog("CMDFIFO0\n"); switch ((header >> 3) & 7) { case 0: /*NOP*/ @@ -6148,6 +6232,7 @@ static void fifo_thread(void *param) case 3: /*JMP local frame buffer*/ voodoo->cmdfifo_rp = (header >> 4) & 0xfffffc; +// pclog("JMP to %08x %04x\n", voodoo->cmdfifo_rp, header); break; default: @@ -6158,6 +6243,7 @@ static void fifo_thread(void *param) case 1: num = header >> 16; addr = (header & 0x7ff8) >> 1; +// pclog("CMDFIFO1 addr=%08x\n",addr); while (num--) { uint32_t val = cmdfifo_get(voodoo); @@ -6174,13 +6260,15 @@ static void fifo_thread(void *param) case 3: num = (header >> 29) & 7; - mask = header; + mask = header;//(header >> 10) & 0xff; smode = (header >> 22) & 0xf; voodoo_reg_writel(SST_sSetupMode, ((header >> 10) & 0xff) | (smode << 16), voodoo); num_verticies = (header >> 6) & 0xf; v_num = 0; if (((header >> 3) & 7) == 2) v_num = 1; +// pclog("CMDFIFO3: num=%i verts=%i mask=%02x\n", num, num_verticies, (header >> 10) & 0xff); +// pclog("CMDFIFO3 %02x %i\n", (header >> 10), (header >> 3) & 7); while (num_verticies--) { @@ -6237,6 +6325,7 @@ static void fifo_thread(void *param) num = (header >> 29) & 7; mask = (header >> 15) & 0x3fff; addr = (header & 0x7ff8) >> 1; +// pclog("CMDFIFO4 addr=%08x\n",addr); while (mask) { if (mask & 1) @@ -6261,6 +6350,7 @@ static void fifo_thread(void *param) fatal("CMDFIFO packet 5 has byte disables set %08x\n", header); num = (header >> 3) & 0x7ffff; addr = cmdfifo_get(voodoo) & 0xffffff; +// pclog("CMDFIFO5 addr=%08x num=%i\n", addr, num); switch (header >> 30) { case 2: /*Framebuffer*/ @@ -6318,6 +6408,8 @@ uint8_t voodoo_pci_read(int func, int addr, void *p) if (func) return 0; +// pclog("Voodoo PCI read %08X PC=%08x\n", addr, cpu_state.pc); + switch (addr) { case 0x00: return 0x1a; /*3dfx*/ @@ -6363,6 +6455,8 @@ void voodoo_pci_write(int func, int addr, uint8_t val, void *p) if (func) return; +// pclog("Voodoo PCI write %04X %02X PC=%08x\n", addr, val, cpu_state.pc); + switch (addr) { case 0x04: @@ -6409,7 +6503,10 @@ static void voodoo_calc_clutData(voodoo_t *voodoo) int r = (c >> 8) & 0xf8; int g = (c >> 3) & 0xfc; int b = (c << 3) & 0xf8; - +// r |= (r >> 5); +// g |= (g >> 6); +// b |= (b >> 5); + voodoo->video_16to32[c] = (voodoo->clutData256[r].r << 16) | (voodoo->clutData256[g].g << 8) | voodoo->clutData256[b].b; } } @@ -6431,9 +6528,9 @@ static void voodoo_generate_filter_v1(voodoo_t *voodoo) fcg = FILTCAPG * 6; fcb = FILTCAPB * 5; - for (g=0;g -fcr)) thiscol = g + (difference / 2); if ((diffg < fcg) || (-diffg > -fcg)) @@ -6504,7 +6606,7 @@ static void voodoo_generate_filter_v2(voodoo_t *voodoo) float clr, clg, clb = 0; float fcr, fcg, fcb = 0; - /* pre-clamping */ + // pre-clamping fcr = FILTCAP; fcg = FILTCAPG; @@ -6514,9 +6616,9 @@ static void voodoo_generate_filter_v2(voodoo_t *voodoo) if (fcg > 32) fcg = 32; if (fcb > 32) fcb = 32; - for (g=0;g<256;g++) /* pixel 1 - our target pixel we want to bleed into */ + for (g=0;g<256;g++) // pixel 1 - our target pixel we want to bleed into { - for (h=0;h<256;h++) /* pixel 2 - our main pixel */ + for (h=0;h<256;h++) // pixel 2 - our main pixel { float avg; float avgdiff; @@ -6529,7 +6631,7 @@ static void voodoo_generate_filter_v2(voodoo_t *voodoo) thiscol = thiscolg = thiscolb = g; - /* try lighten */ + // try lighten if (h > g) { clr = clg = clb = avgdiff; @@ -6567,7 +6669,7 @@ static void voodoo_generate_filter_v2(voodoo_t *voodoo) if (difference > FILTCAPB) thiscolb = g; - /* clamp */ + // clamp if (thiscol < 0) thiscol = 0; if (thiscolg < 0) thiscolg = 0; if (thiscolb < 0) thiscolb = 0; @@ -6576,10 +6678,14 @@ static void voodoo_generate_filter_v2(voodoo_t *voodoo) if (thiscolg > 255) thiscolg = 255; if (thiscolb > 255) thiscolb = 255; - /* add to the table */ + // add to the table voodoo->thefilter[g][h] = (thiscol); voodoo->thefilterg[g][h] = (thiscolg); voodoo->thefilterb[g][h] = (thiscolb); + + // debug the ones that don't give us much of a difference + //if (difference < FILTCAP) + //pclog("Voodoofilter: %ix%i - %f difference, %f average difference, R=%f, G=%f, B=%f\n", g, h, difference, avgdiff, thiscol, thiscolg, thiscolb); } lined = g + 3; @@ -6624,7 +6730,7 @@ static void voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uin { int x; - /* Scratchpad for avoiding feedback streaks */ + // Scratchpad for avoiding feedback streaks uint8_t fil3[(voodoo->h_disp) * 3]; /* 16 to 32-bit */ @@ -6634,7 +6740,7 @@ static void voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uin fil[x*3+1] = (((src[x] >> 5) & 63) << 2); fil[x*3+2] = (((src[x] >> 11) & 31) << 3); - /* Copy to our scratchpads */ + // Copy to our scratchpads fil3[x*3+0] = fil[x*3+0]; fil3[x*3+1] = fil[x*3+1]; fil3[x*3+2] = fil[x*3+2]; @@ -6690,13 +6796,13 @@ static void voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uin { int x; - /* Scratchpad for blending filter */ + // Scratchpad for blending filter uint8_t fil3[(voodoo->h_disp) * 3]; /* 16 to 32-bit */ for (x=0; x> 5) & 63) << 2); fil3[x*3+2] = fil[x*3+2] = (((src[x] >> 11) & 31) << 3); @@ -6723,7 +6829,7 @@ static void voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uin fil[(x-1)*3+2] = voodoo->thefilter [fil3[(x-1)*3+2]][(((src[x] >> 11) & 31) << 3)]; } - /* unroll for edge cases */ + // unroll for edge cases fil3[(column-3)*3] = voodoo->thefilterb [((src[column-3] & 31) << 3)] [((src[column] & 31) << 3)]; fil3[(column-3)*3+1] = voodoo->thefilterg [(((src[column-3] >> 5) & 63) << 2)] [(((src[column] >> 5) & 63) << 2)]; @@ -6779,7 +6885,6 @@ void voodoo_callback(void *p) if (voodoo->scrfilter && voodoo->scrfilterEnabled) { - int j, offset; uint8_t fil[(voodoo->h_disp) * 3]; /* interleaved 24-bit RGB */ if (voodoo->type == VOODOO_2) @@ -6804,6 +6909,7 @@ void voodoo_callback(void *p) } if (voodoo->line == voodoo->v_disp) { +// pclog("retrace %i %i %08x %i\n", voodoo->retrace_count, voodoo->swap_interval, voodoo->swap_offset, voodoo->swap_pending); voodoo->retrace_count++; if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval)) { @@ -6898,6 +7004,7 @@ static void voodoo_speed_changed(void *p) voodoo->read_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit4 & 1) ? 2 : 1); voodoo->write_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit1 & 2) ? 1 : 0); voodoo->burst_time = pci_burst_time * ((voodoo->fbiInit1 & 2) ? 2 : 1); +// pclog("Voodoo read_time=%i write_time=%i burst_time=%i %08x %08x\n", voodoo->read_time, voodoo->write_time, voodoo->burst_time, voodoo->fbiInit1, voodoo->fbiInit4); } void *voodoo_init() @@ -7039,7 +7146,9 @@ void *voodoo_init() void voodoo_close(void *p) { +#ifndef RELEASE_BUILD FILE *f; +#endif voodoo_t *voodoo = (voodoo_t *)p; int c; @@ -7086,77 +7195,111 @@ void voodoo_close(void *p) static device_config_t voodoo_config[] = { { - "type", "Voodoo type", CONFIG_SELECTION, "", 0, + .name = "type", + .description = "Voodoo type", + .type = CONFIG_SELECTION, + .selection = { { - "Voodoo Graphics", VOODOO_1 + .description = "Voodoo Graphics", + .value = VOODOO_1 }, { - "Obsidian SB50 + Amethyst (2 TMUs)", VOODOO_SB50 + .description = "Obsidian SB50 + Amethyst (2 TMUs)", + .value = VOODOO_SB50 }, { - "Voodoo 2", VOODOO_2 + .description = "Voodoo 2", + .value = VOODOO_2 }, { - "" + .description = "" } - } + }, + .default_int = 0 }, { - "framebuffer_memory", "Framebuffer memory size", CONFIG_SELECTION, "", 2, + .name = "framebuffer_memory", + .description = "Framebuffer memory size", + .type = CONFIG_SELECTION, + .selection = { { - "2 MB", 2 + .description = "2 MB", + .value = 2 }, { - "4 MB", 4 + .description = "4 MB", + .value = 4 }, { - "" + .description = "" } - } + }, + .default_int = 2 }, { - "texture_memory", "Texture memory size", CONFIG_SELECTION, "", 2, + .name = "texture_memory", + .description = "Texture memory size", + .type = CONFIG_SELECTION, + .selection = { { - "2 MB", 2 + .description = "2 MB", + .value = 2 }, { - "4 MB",4 + .description = "4 MB", + .value = 4 }, { - "" + .description = "" } - } + }, + .default_int = 2 }, { - "render_threads", "Render threads", CONFIG_SELECTION, "", 2, + .name = "bilinear", + .description = "Bilinear filtering", + .type = CONFIG_BINARY, + .default_int = 1 + }, + { + .name = "dacfilter", + .description = "Screen Filter", + .type = CONFIG_BINARY, + .default_int = 0 + }, + { + .name = "render_threads", + .description = "Render threads", + .type = CONFIG_SELECTION, + .selection = { { - "1", 1 + .description = "1", + .value = 1 }, { - "2", 2 + .description = "2", + .value = 2 }, { - "" + .description = "" } - } - }, - { - "bilinear", "Bilinear filtering", CONFIG_BINARY, "", 1 - }, - { - "dacfilter", "Screen Filter", CONFIG_BINARY, "", 0 + }, + .default_int = 2 }, #ifndef NO_CODEGEN { - "recompiler", "Recompiler", CONFIG_BINARY, "", 1 + .name = "recompiler", + .description = "Recompiler", + .type = CONFIG_BINARY, + .default_int = 1 }, #endif { - "", "", -1 + .type = -1 } }; diff --git a/src/VIDEO/vid_voodoo_codegen_x86-64.h b/src/VIDEO/vid_voodoo_codegen_x86-64.h index 1caa67311..160708b93 100644 --- a/src/VIDEO/vid_voodoo_codegen_x86-64.h +++ b/src/VIDEO/vid_voodoo_codegen_x86-64.h @@ -42,26 +42,26 @@ static int last_block[2] = {0, 0}; static int next_block_to_write[2] = {0, 0}; #define addbyte(val) \ - code_block[block_pos++] = (uint8_t)val; \ + code_block[block_pos++] = val; \ if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") -#define addword(val) \ - *(uint16_t *)&code_block[block_pos] = (uint16_t)val; \ - block_pos += 2; \ - if (block_pos >= BLOCK_SIZE) \ +#define addword(val) \ + *(uint16_t *)&code_block[block_pos] = val; \ + block_pos += 2; \ + if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") -#define addlong(val) \ - *(uint32_t *)&code_block[block_pos] = (uint32_t)val; \ - block_pos += 4; \ - if (block_pos >= BLOCK_SIZE) \ +#define addlong(val) \ + *(uint32_t *)&code_block[block_pos] = val; \ + block_pos += 4; \ + if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") -#define addquad(val) \ - *(uint64_t *)&code_block[block_pos] = (uint64_t)val; \ - block_pos += 8; \ - if (block_pos >= BLOCK_SIZE) \ +#define addquad(val) \ + *(uint64_t *)&code_block[block_pos] = val; \ + block_pos += 8; \ + if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") @@ -70,7 +70,6 @@ static __m128i xmm_ff_w;// = 0x00ff00ff00ff00ffull; static __m128i xmm_ff_b;// = 0x00000000ffffffffull; static uint32_t zero = 0; -static double const_1_48 = (double)(1ull << 4); static __m128i alookup[257], aminuslookup[256]; static __m128i minus_254;// = 0xff02ff02ff02ff02ull; @@ -161,7 +160,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x0f); /*MOVZX EAX, logtable[RAX]*/ addbyte(0xb6); addbyte(0x80); - addlong((uint32_t)logtable); + addlong((uint32_t)(uintptr_t)logtable); addbyte(0x09); /*OR EAX, EDX*/ addbyte(0xd0); addbyte(0x03); /*ADD EAX, state->lod*/ @@ -339,7 +338,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x14); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EDX, params->tex_h_mask[ESI]*/ addbyte(0x96); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -353,7 +352,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x1c); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI]*/ addbyte(0x9e); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -400,7 +399,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x04); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x78); /*JS + - clamp on 0*/ addbyte(2+3+2+ 5+5+2); addbyte(0x3b); /*CMP EAX, EBP*/ @@ -501,7 +500,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x49); /*MOV R8, bilinear_lookup*/ addbyte(0xb8); - addquad(bilinear_lookup); + addquad((uintptr_t)bilinear_lookup); addbyte(0x66); /*PUNPCKLBW XMM0, XMM2*/ addbyte(0x0f); @@ -615,7 +614,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x04); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EAX, params->tex_w_mask[ESI+ECX*4]*/ addbyte(0x84); addbyte(0x8e); @@ -642,7 +641,7 @@ static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, v addbyte(0x48); addbyte(0x1c); addbyte(0x25); - addlong(&zero); + addlong((uint32_t)(uintptr_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI+ECX*4]*/ addbyte(0x9c); addbyte(0x8e); @@ -1080,7 +1079,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x83); - addlong((uint32_t)&xmm_00_ff_w[0]); + addlong((uint32_t)(uintptr_t)&xmm_00_ff_w[0]); } else if (!tc_reverse_blend_1) { @@ -1089,14 +1088,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM0, xmm_01_w*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)&xmm_01_w); + addlong((uint32_t)(uintptr_t)&xmm_01_w); addbyte(0xf3); /*MOVQ XMM1, XMM2*/ addbyte(0x0f); addbyte(0x7e); @@ -1217,7 +1216,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x33); /*XOR EAX, i_00_ff_w[ECX*4]*/ addbyte(0x04); addbyte(0x8d); - addlong((uint32_t)i_00_ff_w); + addlong((uint32_t)(uintptr_t)i_00_ff_w); } else if (!tc_reverse_blend_1) { @@ -1404,7 +1403,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0xa3); - addlong((uint32_t)&xmm_00_ff_w[0]); + addlong((uint32_t)(uintptr_t)&xmm_00_ff_w[0]); } else if (!tc_reverse_blend) { @@ -1413,14 +1412,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x24); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM4, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong(&xmm_01_w); + addlong((uint32_t)(uintptr_t)&xmm_01_w); addbyte(0xf3); /*MOVQ XMM5, XMM1*/ addbyte(0x0f); addbyte(0x7e); @@ -1488,7 +1487,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x0f); addbyte(0xef); addbyte(0x0d); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PACKUSWB XMM0, XMM0*/ @@ -1585,7 +1584,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x33); /*XOR EBX, i_00_ff_w[ECX*4]*/ addbyte(0x1c); addbyte(0x8d); - addlong((uint32_t)i_00_ff_w); + addlong((uint32_t)(uintptr_t)i_00_ff_w); } else if (!tca_reverse_blend) { @@ -2143,14 +2142,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x1c); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM3, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x1c); addbyte(0x25); - addlong(&xmm_01_w); + addlong((uint32_t)(uintptr_t)&xmm_01_w); addbyte(0x66); /*PMULLW XMM0, XMM3*/ addbyte(0x0f); addbyte(0xd5); @@ -2194,7 +2193,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xef); addbyte(0x04); addbyte(0x25); - addlong(&xmm_ff_b); + addlong((uint32_t)(uintptr_t)&xmm_ff_b); } if (params->fogMode & FOG_ENABLE) @@ -2441,7 +2440,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { addbyte(0x49); /*MOV R8, rgb565*/ addbyte(0xb8); - addquad(rgb565); + addquad((uintptr_t)rgb565); addbyte(0x8b); /*MOV EAX, state->x[EDI]*/ addbyte(0x87); addlong(offsetof(voodoo_state_t, x)); @@ -2489,7 +2488,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)(uintptr_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2499,7 +2498,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2529,7 +2528,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2555,7 +2554,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)(uintptr_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2565,7 +2564,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2587,7 +2586,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x7e); addbyte(0x2c); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM0*/ addbyte(0x0f); addbyte(0xf9); @@ -2605,7 +2604,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2633,7 +2632,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(&minus_254); + addlong((uint32_t)(uintptr_t)&minus_254); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2643,7 +2642,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x24); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2674,7 +2673,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)(uintptr_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2684,7 +2683,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2714,7 +2713,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2740,7 +2739,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)(uintptr_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2750,7 +2749,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2772,7 +2771,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0x7e); addbyte(0x2c); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)(uintptr_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM6*/ addbyte(0x0f); addbyte(0xf9); @@ -2790,7 +2789,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo addbyte(0xfd); addbyte(0x04); addbyte(0x25); - addlong((uint32_t)alookup + 16); + addlong((uint32_t)(uintptr_t)alookup + 16); addbyte(0x66); /*PSRLW XMM5, 8*/ addbyte(0x0f); addbyte(0x71); @@ -2842,7 +2841,7 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo { addbyte(0x49); /*MOV R8, dither_rb*/ addbyte(0xb8); - addquad(dither2x2 ? dither_rb2x2 : dither_rb); + addquad(dither2x2 ? (uintptr_t)dither_rb2x2 : (uintptr_t)dither_rb); addbyte(0x4c); /*MOV ESI, real_y (R14)*/ addbyte(0x89); addbyte(0xf6); diff --git a/src/VIDEO/vid_voodoo_codegen_x86.h b/src/VIDEO/vid_voodoo_codegen_x86.h index 54c09a1bc..5a9f65e46 100644 --- a/src/VIDEO/vid_voodoo_codegen_x86.h +++ b/src/VIDEO/vid_voodoo_codegen_x86.h @@ -40,43 +40,43 @@ static int last_block[2] = {0, 0}; static int next_block_to_write[2] = {0, 0}; #define addbyte(val) \ - code_block[block_pos++] = (uint8_t)val; \ + code_block[block_pos++] = val; \ if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") -#define addword(val) \ - *(uint16_t *)&code_block[block_pos] = (uint16_t)val; \ - block_pos += 2; \ - if (block_pos >= BLOCK_SIZE) \ +#define addword(val) \ + *(uint16_t *)&code_block[block_pos] = val; \ + block_pos += 2; \ + if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") -#define addlong(val) \ - *(uint32_t *)&code_block[block_pos] = (uint32_t)val; \ - block_pos += 4; \ - if (block_pos >= BLOCK_SIZE) \ +#define addlong(val) \ + *(uint32_t *)&code_block[block_pos] = val; \ + block_pos += 4; \ + if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") -#define addquad(val) \ - *(uint64_t *)&code_block[block_pos] = (uint64_t)val; \ - block_pos += 8; \ - if (block_pos >= BLOCK_SIZE) \ +#define addquad(val) \ + *(uint64_t *)&code_block[block_pos] = val; \ + block_pos += 8; \ + if (block_pos >= BLOCK_SIZE) \ fatal("Over!\n") -static __m128i xmm_01_w; -static __m128i xmm_ff_w; -static __m128i xmm_ff_b; +static __m128i xmm_01_w;// = 0x0001000100010001ull; +static __m128i xmm_ff_w;// = 0x00ff00ff00ff00ffull; +static __m128i xmm_ff_b;// = 0x00000000ffffffffull; static uint32_t zero = 0; static double const_1_48 = (double)(1ull << 4); static __m128i alookup[257], aminuslookup[256]; -static __m128i minus_254; +static __m128i minus_254;// = 0xff02ff02ff02ff02ull; static __m128i bilinear_lookup[256*2]; static __m128i xmm_00_ff_w[2]; static uint32_t i_00_ff_w[2] = {0, 0xff}; -static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int block_pos, int tmu) +static inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int block_pos, int tmu) { if (params->textureMode[tmu] & 1) { @@ -85,7 +85,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addlong(tmu ? offsetof(voodoo_state_t, tmu1_w) : offsetof(voodoo_state_t, tmu0_w)); addbyte(0xdd); /*FLDq const_1_48*/ addbyte(0x05); - addlong(&const_1_48); + addlong((uint32_t)&const_1_48); addbyte(0xde); /*FDIV ST(1)*/ addbyte(0xf1); addbyte(0xdf); /*FILDq state->tmu0_s*/ @@ -129,7 +129,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addbyte(0x0f); /*MOVZX EBX, logtable[EBX]*/ addbyte(0xb6); addbyte(0x9b); - addlong(logtable); + addlong((uint32_t)logtable); addbyte(0x09); /*OR EAX, EBX*/ addbyte(0xd8); addbyte(0x03); /*ADD EAX, state->lod*/ @@ -322,7 +322,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addbyte(0x0f); /*CMOVS EDX, zero*/ addbyte(0x48); addbyte(0x15); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EDX, params->tex_h_mask[ESI]*/ addbyte(0x96); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -335,7 +335,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addbyte(0x0f); /*CMOVS EBX, zero*/ addbyte(0x48); addbyte(0x1d); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI]*/ addbyte(0x9e); addlong(offsetof(voodoo_params_t, tex_h_mask[tmu])); @@ -379,7 +379,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addbyte(0x0f); /*CMOVS EAX, zero*/ addbyte(0x48); addbyte(0x05); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x78); /*JS + - clamp on 0*/ addbyte(2+3+2+ 5+5+2); addbyte(0x3b); /*CMP EAX, EBP*/ @@ -489,7 +489,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addbyte(0x81); /*ADD ESI, bilinear_lookup*/ addbyte(0xc6); - addlong(bilinear_lookup); + addlong((uint32_t)bilinear_lookup); addbyte(0x66); /*PMULLW XMM0, bilinear_lookup[ESI]*/ addbyte(0x0f); @@ -592,7 +592,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addbyte(0x0f); /*CMOVS EAX, zero*/ addbyte(0x48); addbyte(0x05); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EAX, params->tex_w_mask[ESI+ECX*4]*/ addbyte(0x84); addbyte(0x8e); @@ -618,7 +618,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, addbyte(0x0f); /*CMOVS EBX, zero*/ addbyte(0x48); addbyte(0x1d); - addlong(&zero); + addlong((uint32_t)&zero); addbyte(0x3b); /*CMP EBX, params->tex_h_mask[ESI+ECX*4]*/ addbyte(0x9c); addbyte(0x8e); @@ -653,7 +653,7 @@ static __inline int codegen_texture_fetch(uint8_t *code_block, voodoo_t *voodoo, return block_pos; } -static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int depthop) +static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int depthop) { int block_pos = 0; int z_skip_pos = 0; @@ -662,10 +662,24 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood int depth_jump_pos = 0; int depth_jump_pos2 = 0; int loop_jump_pos = 0; +// xmm_01_w = (__m128i)0x0001000100010001ull; +// xmm_ff_w = (__m128i)0x00ff00ff00ff00ffull; +// xmm_ff_b = (__m128i)0x00000000ffffffffull; xmm_01_w = _mm_set_epi32(0, 0, 0x00010001, 0x00010001); xmm_ff_w = _mm_set_epi32(0, 0, 0x00ff00ff, 0x00ff00ff); xmm_ff_b = _mm_set_epi32(0, 0, 0, 0x00ffffff); minus_254 = _mm_set_epi32(0, 0, 0xff02ff02, 0xff02ff02); +// *(uint64_t *)&const_1_48 = 0x45b0000000000000ull; +// block_pos = 0; +// voodoo_get_depth = &code_block[block_pos]; + /*W at (%esp+4) + Z at (%esp+12) + new_depth at (%esp+16)*/ +// if ((params->fbzMode & FBZ_DEPTH_ENABLE) && (depth_op == DEPTHOP_NEVER)) +// { +// addbyte(0xC3); /*RET*/ +// return; +// } addbyte(0x55); /*PUSH EBP*/ addbyte(0x57); /*PUSH EDI*/ addbyte(0x56); /*PUSH ESI*/ @@ -697,6 +711,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x75); /*JNZ got_depth*/ depth_jump_pos = block_pos; addbyte(0); +// addbyte(4+5+2+3+2+5+5+3+2+2+2+/*3+*/3+2+6+4+5+2+3); addbyte(0x8b); /*MOV EDX, w*/ addbyte(0x97); addlong(offsetof(voodoo_state_t, w)); @@ -710,6 +725,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x74); /*JZ got_depth*/ depth_jump_pos2 = block_pos; addbyte(0); +// addbyte(5+5+3+2+2+2+/*3+*/3+2+6+4+5+2+3); addbyte(0xb9); /*MOV ECX, 19*/ addlong(19); addbyte(0x0f); /*BSR EAX, EDX*/ @@ -875,8 +891,17 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood else if ((params->fbzMode & FBZ_DEPTH_ENABLE) && (depthop == DEPTHOP_NEVER)) { addbyte(0xC3); /*RET*/ +// addbyte(0x30); /*XOR EAX, EAX*/ +// addbyte(0xc0); } +// else +// { +// addbyte(0xb0); /*MOV AL, 1*/ +// addbyte(1); +// } + +// voodoo_combine = &code_block[block_pos]; /*XMM0 = colour*/ /*XMM2 = 0 (for unpacking*/ @@ -1367,13 +1392,13 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); addbyte(0xef); addbyte(0x25); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM4, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x25); - addlong(&xmm_01_w); + addlong((uint32_t)&xmm_01_w); addbyte(0xf3); /*MOVQ XMM5, XMM1*/ addbyte(0x0f); addbyte(0x7e); @@ -1441,7 +1466,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); addbyte(0xef); addbyte(0x0d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); } addbyte(0x66); /*PACKUSWB XMM0, XMM0*/ @@ -2096,13 +2121,13 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); addbyte(0xef); addbyte(0x1d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); } addbyte(0x66); /*PADDW XMM3, 1*/ addbyte(0x0f); addbyte(0xfd); addbyte(0x1d); - addlong(&xmm_01_w); + addlong((uint32_t)&xmm_01_w); addbyte(0x66); /*PMULLW XMM0, XMM3*/ addbyte(0x0f); addbyte(0xd5); @@ -2145,8 +2170,14 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); addbyte(0xef); addbyte(0x05); - addlong(&xmm_ff_b); + addlong((uint32_t)&xmm_ff_b); } +//#if 0 +// addbyte(0x66); /*MOVD state->out[EDI], XMM0*/ +// addbyte(0x0f); +// addbyte(0x7e); +// addbyte(0x87); +// addlong(offsetof(voodoo_state_t, out)); if (params->fogMode & FOG_ENABLE) { if (params->fogMode & FOG_CONSTANT) @@ -2241,6 +2272,11 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(10); addbyte(0x01); /*ADD EAX, EBX*/ addbyte(0xd8); + +/* int fog_idx = (w_depth >> 10) & 0x3f; + + fog_a = params->fogTable[fog_idx].fog; + fog_a += (params->fogTable[fog_idx].dfog * ((w_depth >> 2) & 0xff)) >> 10;*/ break; case FOG_Z: @@ -2252,6 +2288,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(12); addbyte(0x25); /*AND EAX, 0xff*/ addlong(0xff); +// fog_a = (z >> 20) & 0xff; break; case FOG_ALPHA: @@ -2273,6 +2310,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); /*CMOVAE EAX, EBX*/ addbyte(0x43); addbyte(0xc3); +// fog_a = CLAMP(ia >> 12); break; case FOG_W: @@ -2293,10 +2331,12 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); /*CMOVAE EAX, EBX*/ addbyte(0x43); addbyte(0xc3); +// fog_a = CLAMP(w >> 32); break; } addbyte(0x01); /*ADD EAX, EAX*/ addbyte(0xc0); +// fog_a++; addbyte(0x66); /*PMULLW XMM3, alookup+4[EAX*8]*/ addbyte(0x0f); @@ -2419,7 +2459,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x6e); addbyte(0x24); addbyte(0x85); - addlong(rgb565); + addlong((uint32_t)rgb565); addbyte(0x66); /*PUNPCKLBW XMM4, XMM2*/ addbyte(0x0f); addbyte(0x60); @@ -2443,7 +2483,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2507,7 +2547,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0xd5); addbyte(0x24); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2537,7 +2577,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); addbyte(0x7e); addbyte(0x2d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM0*/ addbyte(0x0f); addbyte(0xf9); @@ -2581,7 +2621,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); addbyte(0xd5); addbyte(0x25); - addlong(&minus_254); + addlong((uint32_t)&minus_254); addbyte(0xf3); /*MOVQ XMM5, XMM4*/ addbyte(0x0f); addbyte(0x7e); @@ -2621,7 +2661,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(alookup); + addlong((uint32_t)alookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2685,7 +2725,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0xd5); addbyte(0x04); addbyte(0xd5); - addlong(aminuslookup); + addlong((uint32_t)aminuslookup); addbyte(0xf3); /*MOVQ XMM5, XMM0*/ addbyte(0x0f); addbyte(0x7e); @@ -2715,7 +2755,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x0f); addbyte(0x7e); addbyte(0x2d); - addlong(&xmm_ff_w); + addlong((uint32_t)&xmm_ff_w); addbyte(0x66); /*PSUBW XMM5, XMM6*/ addbyte(0x0f); addbyte(0xf9); @@ -2768,6 +2808,13 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0x67); addbyte(0xc0); } +//#endif + +// addbyte(0x8b); /*MOV EDX, x (ESP+12)*/ +// addbyte(0x54); +// addbyte(0x24); +// addbyte(12); + addbyte(0x8b); /*MOV EDX, state->x[EDI]*/ addbyte(0x97); @@ -2780,6 +2827,10 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood if (params->fbzMode & FBZ_RGB_WMASK) { +// addbyte(0x89); /*MOV state->rgb_out[EDI], EAX*/ +// addbyte(0x87); +// addlong(offsetof(voodoo_state_t, rgb_out)); + if (dither) { addbyte(0x8b); /*MOV ESI, real_y (ESP+16)*/ @@ -2857,17 +2908,17 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood addbyte(0xb6); addbyte(0x9c); addbyte(0x33); - addlong(dither2x2 ? dither_g2x2 : dither_g); + addlong(dither2x2 ? (uint32_t)dither_g2x2 : (uint32_t)dither_g); addbyte(0x0f); /*MOVZX ECX, dither_rb[ECX+ESI]*/ addbyte(0xb6); addbyte(0x8c); addbyte(0x31); - addlong(dither2x2 ? dither_rb2x2 : dither_rb); + addlong(dither2x2 ? (uint32_t)dither_rb2x2 : (uint32_t)dither_rb); addbyte(0x0f); /*MOVZX EAX, dither_rb[EAX+ESI]*/ addbyte(0xb6); addbyte(0x84); addbyte(0x30); - addlong(dither2x2 ? dither_rb2x2 : dither_rb); + addlong(dither2x2 ? (uint32_t)dither_rb2x2 : (uint32_t)dither_rb); addbyte(0xc1); /*SHL EBX, 5*/ addbyte(0xe3); addbyte(5); @@ -3181,7 +3232,7 @@ static __inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, vood } static int voodoo_recomp = 0; -static __inline void *voodoo_get_block(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int odd_even) +static inline void *voodoo_get_block(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int odd_even) { int c; int b = last_block[odd_even]; @@ -3211,6 +3262,7 @@ static __inline void *voodoo_get_block(voodoo_t *voodoo, voodoo_params_t *params } voodoo_recomp++; data = &codegen_data[odd_even + next_block_to_write[odd_even]*2]; +// code_block = data->code_block; voodoo_generate(data->code_block, voodoo, params, state, depth_op); diff --git a/src/WIN/86Box.rc b/src/WIN/86Box.rc index e5b19e765..0a64e8b42 100644 --- a/src/WIN/86Box.rc +++ b/src/WIN/86Box.rc @@ -279,7 +279,7 @@ BEGIN PUSHBUTTON "Joystick 4...",IDC_JOY4,209,44,50,14 END -DLG_CFG_SOUND DIALOG DISCARDABLE 97, 0, 267, 98 +DLG_CFG_SOUND DIALOG DISCARDABLE 97, 0, 267, 116 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN @@ -304,6 +304,9 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,7,81,94,10 CONTROL "Use Nuked OPL",IDC_CHECK_NUKEDOPL,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,147,81,94,10 + + CONTROL "Use FLOAT32 sound",IDC_CHECK_FLOAT,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,99,94,10 END DLG_CFG_NETWORK DIALOG DISCARDABLE 97, 0, 267, 63 @@ -668,7 +671,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 TOPMARGIN, 7 - BOTTOMMARGIN, 71 + BOTTOMMARGIN, 109 END CONFIGUREDLG_NETWORK, DIALOG diff --git a/src/WIN/resource.h b/src/WIN/resource.h index 47c92c31c..39feb0a5d 100644 --- a/src/WIN/resource.h +++ b/src/WIN/resource.h @@ -126,6 +126,7 @@ #define IDC_COMBO_MIDI 1076 #define IDC_CHECK_MPU401 1077 #define IDC_CONFIGURE_MPU401 1078 +#define IDC_CHECK_FLOAT 1079 #define IDC_COMBO_NET_TYPE 1090 /* network config */ #define IDC_COMBO_PCAP 1091 diff --git a/src/WIN/win.c b/src/WIN/win.c index 5a76bcc94..394a05e3b 100644 --- a/src/WIN/win.c +++ b/src/WIN/win.c @@ -8,7 +8,7 @@ * * The Emulator's Windows core. * - * Version: @(#)win.c 1.0.2 2017/06/04 + * Version: @(#)win.c 1.0.3 2017/06/12 * * Authors: Sarah Walker, * Miran Grca, @@ -240,12 +240,12 @@ void updatewindowsize(int x, int y) } } -void uws_natural() +void uws_natural(void) { updatewindowsize(unscaled_size_x, efwinsizey); } -void releasemouse() +void releasemouse(void) { if (mousecapture) { @@ -255,17 +255,17 @@ void releasemouse() } } -void startblit() +void startblit(void) { WaitForSingleObject(ghMutex, INFINITE); } -void endblit() +void endblit(void) { ReleaseMutex(ghMutex); } -void leave_fullscreen() +void leave_fullscreen(void) { leave_fullscreen_flag = 1; } @@ -362,7 +362,7 @@ void thread_sleep(int t) Sleep(t); } -event_t *thread_create_event() +event_t *thread_create_event(void) { win_event_t *event = malloc(sizeof(win_event_t)); @@ -486,7 +486,7 @@ void create_cdrom_submenu(HMENU m, int id) for (i = 0; i < 26; i++) { - wsprintf(s, L"Host CD/DVD Drive (%c:)", i + 0x41); + _swprintf(s, L"Host CD/DVD Drive (%c:)", i + 0x41); if (host_cdrom_drive_available[i]) { AppendMenu(m, MF_STRING, IDM_CDROM_HOST_DRIVE | (i << 3) | id, s); @@ -537,14 +537,14 @@ void set_window_title(WCHAR *s) SetWindowText(ghwnd, s); } -uint64_t timer_read() +uint64_t timer_read(void) { LARGE_INTEGER qpc_time; QueryPerformanceCounter(&qpc_time); return qpc_time.QuadPart; } -static void process_command_line() +static void process_command_line(void) { WCHAR *cmdline; int argc_max; @@ -693,7 +693,7 @@ int find_status_bar_part(int tag) return -1; } - for (i = 0; i < 12; i++) + for (i = 0; i < sb_parts; i++) { if (sb_part_meanings[i] == tag) { @@ -957,7 +957,7 @@ void status_settext(char *str) status_settextw(cwstr); } -void destroy_menu_handles() +void destroy_menu_handles(void) { int i = 0; @@ -974,7 +974,7 @@ void destroy_menu_handles() free(sb_menu_handles); } -void destroy_tips() +void destroy_tips(void) { int i = 0; @@ -1240,7 +1240,7 @@ void update_status_bar_panes(HWND hwnds) break; case SB_TEXT: /* Status text */ - SendMessage(hwnds, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) L"Welcome to Unicode 86Box! :p"); + SendMessage(hwnds, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) L""); sb_part_icons[i] = -1; break; } @@ -1344,7 +1344,7 @@ HWND EmulatorStatusBar(HWND hwndParent, int idStatus, HINSTANCE hinst) return hwndStatus; } -void win_menu_update() +void win_menu_update(void) { #if 0 menu = LoadMenu(hThisInstance, TEXT("MainMenu")); @@ -1794,6 +1794,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM { HMENU hmenu; RECT rect; + int i = 0; switch (message) { @@ -2022,10 +2023,57 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM if (msgbox_reset_yn(ghwnd) == IDYES) { config_save(config_file_default); + for (i = 0; i < FDD_NUM; i++) + { + disc_close(i); + } + for (i = 0; i < CDROM_NUM; i++) + { + cdrom_drives[i].handler->exit(i); + if (cdrom_drives[i].host_drive == 200) + { + image_close(i); + } + else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) + { + ioctl_close(i); + } + else + { + null_close(i); + } + } loadconfig(wopenfilestring); + for (i = 0; i < CDROM_NUM; i++) + { + if (cdrom_drives[i].bus_type) + { + SCSIReset(cdrom_drives[i].scsi_device_id, cdrom_drives[i].scsi_device_lun); + } + + if (cdrom_drives[i].host_drive == 200) + { + image_open(i, cdrom_image[i].image_path); + } + else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) + { + ioctl_open(i, cdrom_drives[i].host_drive); + } + else + { + cdrom_null_open(i, cdrom_drives[i].host_drive); + } + } + + disc_load(0, discfns[0]); + disc_load(1, discfns[1]); + disc_load(2, discfns[2]); + disc_load(3, discfns[3]); + /* pclog_w(L"NVR path: %s\n", nvr_path); */ mem_resize(); loadbios(); + update_status_bar_panes(hwndStatus); resetpchard(); } } @@ -2108,6 +2156,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM winsizex = (lParam & 0xFFFF); winsizey = (lParam >> 16) - (17 + 6); + if (winsizey < 0) + { + winsizey = 0; + } + MoveWindow(hwndRender, 0, 0, winsizex, winsizey, TRUE); if (vid_apis[video_fullscreen][vid_api].resize) diff --git a/src/WIN/win_d3d.cc b/src/WIN/win_d3d.cc index f090465b3..97953515f 100644 --- a/src/WIN/win_d3d.cc +++ b/src/WIN/win_d3d.cc @@ -45,33 +45,40 @@ static HWND d3d_hwnd; struct CUSTOMVERTEX { FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag + DWORD color; FLOAT tu, tv; }; static CUSTOMVERTEX d3d_verts[] = { - { 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f}, - { 0.0f, 2048.0f, 1.0f, 1.0f, 0.0f, 1.0f}, + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, + { 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f}, - { 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f}, - {2048.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f}, + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, + + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, + { 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f}, + + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f} }; int d3d_init(HWND h) { - HRESULT hr; + int c; + int ret; - cgapal_rebuild(); + for (c = 0; c < 256; c++) + pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2); d3d_hwnd = h; d3d = Direct3DCreate9(D3D_SDK_VERSION); - if (d3d == NULL) - { - return 0; - } memset(&d3dpp, 0, sizeof(d3dpp)); @@ -89,11 +96,7 @@ int d3d_init(HWND h) d3dpp.BackBufferWidth = 0; d3dpp.BackBufferHeight = 0; - hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); - if (FAILED(hr)) - { - return 0; - } + d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); d3d_init_objects(); @@ -103,7 +106,7 @@ int d3d_init(HWND h) return 1; } -void d3d_close_objects(void) +void d3d_close_objects() { if (d3dTexture) { @@ -117,31 +120,32 @@ void d3d_close_objects(void) } } -void d3d_init_objects(void) +void d3d_init_objects() { D3DLOCKED_RECT dr; + int y; RECT r; - d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX), + d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX), 0, - D3DFVF_XYZRHW | D3DFVF_TEX1, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_MANAGED, &v_buffer, NULL); d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL); - // r.top = r.left = 0; + r.top = r.left = 0; r.bottom = r.right = 2047; if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0))) fatal("LockRect failed\n"); - /* for (y = 0; y < 2048; y++) + for (y = 0; y < 2048; y++) { - uint32_t *p = (uint32_t *)(dr.pBits + (y * dr.Pitch)); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch)); memset(p, 0, 2048 * 4); - } */ + } d3dTexture->UnlockRect(0); @@ -161,10 +165,12 @@ void d3d_resize(int x, int y) d3d_reset(); } -void d3d_reset(void) +void d3d_reset() { HRESULT hr; - + + if (!d3ddev) + return; memset(&d3dpp, 0, sizeof(d3dpp)); d3dpp.Flags = 0; @@ -196,7 +202,7 @@ void d3d_reset(void) device_force_redraw(); } -void d3d_close(void) +void d3d_close() { if (d3dTexture) { @@ -228,10 +234,10 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) RECT r; int yy; - if ((w <= 0) || (w > 2048) || (h <= 0) || (h > 2048) || (y1 == y2) || (y1 < 0) || (y1 > 2048) || (y2 < 0) || (y2 > 2048) || (d3dTexture == NULL)) - { + if (y1 == y2) + { video_blit_complete(); - return; /*Nothing to do*/ + return; /*Nothing to do*/ } r.top = y1; @@ -245,7 +251,7 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) fatal("LockRect failed\n"); for (yy = y1; yy < y2; yy++) - memcpy((uint32_t *) &(((uint8_t *) dr.pBits)[(yy - y1) * dr.Pitch]), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); + memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); video_blit_complete(); d3dTexture->UnlockRect(0); @@ -257,12 +263,20 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;//0.5 / 2048.0; d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0; d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0; + d3d_verts[0].color = d3d_verts[1].color = d3d_verts[2].color = + d3d_verts[3].color = d3d_verts[4].color = d3d_verts[5].color = + d3d_verts[6].color = d3d_verts[7].color = d3d_verts[8].color = + d3d_verts[9].color = d3d_verts[10].color = d3d_verts[11].color = 0xffffff; GetClientRect(d3d_hwnd, &r); d3d_verts[0].x = d3d_verts[2].x = d3d_verts[3].x = -0.5; d3d_verts[0].y = d3d_verts[3].y = d3d_verts[4].y = -0.5; d3d_verts[1].x = d3d_verts[4].x = d3d_verts[5].x = (r.right - r.left) - 0.5; d3d_verts[1].y = d3d_verts[2].y = d3d_verts[5].y = (r.bottom - r.top) - 0.5; + d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = (r.right - r.left) - 40.5; + d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = 8.5; + d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = (r.right - r.left) - 8.5; + d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = 14.5; if (hr == D3D_OK) hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // lock the vertex buffer @@ -280,7 +294,7 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) hr = d3ddev->SetTexture(0, d3dTexture); if (hr == D3D_OK) - hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); + hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); if (hr == D3D_OK) hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); @@ -307,11 +321,10 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h) VOID* pVoid; D3DLOCKED_RECT dr; RECT r; - uint32_t *p; int yy, xx; HRESULT hr = D3D_OK; - if ((w <= 0) || (w > 2048) || (h <= 0) || (h > 2048) || (d3dTexture == NULL)) + if (h == 0) { video_blit_complete(); return; /*Nothing to do*/ @@ -326,10 +339,10 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h) { if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0))) fatal("LockRect failed\n"); - + for (yy = 0; yy < h; yy++) { - p = (uint32_t *) &((((uint8_t *) dr.pBits)[yy * dr.Pitch])); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (yy * dr.Pitch)); if ((y + yy) >= 0 && (y + yy) < buffer->h) { for (xx = 0; xx < w; xx++) @@ -347,12 +360,20 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h) d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;//0.5 / 2048.0; d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0; d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0; + d3d_verts[0].color = d3d_verts[1].color = d3d_verts[2].color = + d3d_verts[3].color = d3d_verts[4].color = d3d_verts[5].color = + d3d_verts[6].color = d3d_verts[7].color = d3d_verts[8].color = + d3d_verts[9].color = d3d_verts[10].color = d3d_verts[11].color = 0xffffff; GetClientRect(d3d_hwnd, &r); d3d_verts[0].x = d3d_verts[2].x = d3d_verts[3].x = -0.5; d3d_verts[0].y = d3d_verts[3].y = d3d_verts[4].y = -0.5; d3d_verts[1].x = d3d_verts[4].x = d3d_verts[5].x = (r.right - r.left) - 0.5; d3d_verts[1].y = d3d_verts[2].y = d3d_verts[5].y = (r.bottom - r.top) - 0.5; + d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = (r.right - r.left) - 40.5; + d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = 8.5; + d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = (r.right - r.left) - 8.5; + d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = 14.5; if (hr == D3D_OK) hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // lock the vertex buffer @@ -370,7 +391,7 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h) hr = d3ddev->SetTexture(0, d3dTexture); if (hr == D3D_OK) - hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); + hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); if (hr == D3D_OK) hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); diff --git a/src/WIN/win_d3d_fs.cc b/src/WIN/win_d3d_fs.cc index 0f894dc34..7a84bc77b 100644 --- a/src/WIN/win_d3d_fs.cc +++ b/src/WIN/win_d3d_fs.cc @@ -51,6 +51,7 @@ static int d3d_fs_w, d3d_fs_h; struct CUSTOMVERTEX { FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag + DWORD color; FLOAT tu, tv; }; @@ -109,13 +110,21 @@ uint32_t pal_lookup[256]; static CUSTOMVERTEX d3d_verts[] = { - { 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f}, - { 0.0f, 2048.0f, 1.0f, 1.0f, 0.0f, 1.0f}, + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, + { 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f}, - { 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f}, - {2048.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f}, + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, + + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, + { 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f}, + + { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, + {2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f}, + {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f} }; @@ -158,13 +167,14 @@ void cgapal_rebuild(void) int d3d_fs_init(HWND h) { - HRESULT hr; + int c; WCHAR emulator_title[200]; d3d_fs_w = GetSystemMetrics(SM_CXSCREEN); d3d_fs_h = GetSystemMetrics(SM_CYSCREEN); - cgapal_rebuild(); + for (c = 0; c < 256; c++) + pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2); d3d_hwnd = h; @@ -186,10 +196,6 @@ int d3d_fs_init(HWND h) ); d3d = Direct3DCreate9(D3D_SDK_VERSION); - if (d3d == NULL) - { - return 0; - } memset(&d3dpp, 0, sizeof(d3dpp)); @@ -207,11 +213,7 @@ int d3d_fs_init(HWND h) d3dpp.BackBufferWidth = d3d_fs_w; d3dpp.BackBufferHeight = d3d_fs_h; - hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); - if (FAILED(hr)) - { - return 0; - } + d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); d3d_fs_init_objects(); @@ -221,8 +223,7 @@ int d3d_fs_init(HWND h) return 1; } - -static void d3d_fs_close_objects(void) +static void d3d_fs_close_objects() { if (d3dTexture) { @@ -236,33 +237,32 @@ static void d3d_fs_close_objects(void) } } - -static void d3d_fs_init_objects(void) +static void d3d_fs_init_objects() { D3DLOCKED_RECT dr; + int y; RECT r; - d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX), + d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX), 0, - D3DFVF_XYZRHW | D3DFVF_TEX1, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_MANAGED, &v_buffer, NULL); d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL); - // r.top = r.left = 0; - r.bottom = 2047; - r.right = 2047; + r.top = r.left = 0; + r.bottom = r.right = 2047; if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0))) fatal("LockRect failed\n"); - /* for (y = 0; y < 2048; y++) + for (y = 0; y < 2048; y++) { - uint32_t *p = (uint32_t *)(dr.pBits + (y * dr.Pitch)); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch)); memset(p, 0, 2048 * 4); - } */ + } d3dTexture->UnlockRect(0); @@ -274,7 +274,6 @@ static void d3d_fs_init_objects(void) d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); } - /*void d3d_resize(int x, int y) { HRESULT hr; @@ -285,8 +284,7 @@ static void d3d_fs_init_objects(void) d3d_reset(); }*/ - -void d3d_fs_reset(void) +void d3d_fs_reset() { HRESULT hr; @@ -321,19 +319,9 @@ void d3d_fs_reset(void) device_force_redraw(); } - -void d3d_fs_close(void) +void d3d_fs_close() { - if (d3dTexture) - { - d3dTexture->Release(); - d3dTexture = NULL; - } - if (v_buffer) - { - v_buffer->Release(); - v_buffer = NULL; - } + d3d_fs_close_objects(); if (d3ddev) { d3ddev->Release(); @@ -347,7 +335,6 @@ void d3d_fs_close(void) DestroyWindow(d3d_device_window); } - static void d3d_fs_size(RECT window_rect, double *l, double *t, double *r, double *b, int w, int h) { int ratio_w, ratio_h; @@ -398,7 +385,6 @@ static void d3d_fs_size(RECT window_rect, double *l, double *t, double *r, doubl } } - static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) { HRESULT hr = D3D_OK; @@ -408,10 +394,10 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) int yy; double l, t, r, b; - if ((y1 == y2) || (d3dTexture == NULL)) + if (y1 == y2) { video_blit_complete(); - return; /*Nothing to do*/ + return; /*Nothing to do*/ } if (hr == D3D_OK && !(y1 == 0 && y2 == 0)) @@ -427,7 +413,7 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) fatal("LockRect failed\n"); for (yy = y1; yy < y2; yy++) - memcpy((uint32_t *) &(((uint8_t *) dr.pBits)[(yy - y1) * dr.Pitch]), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); + memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); video_blit_complete(); d3dTexture->UnlockRect(0); @@ -439,6 +425,10 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0; d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0; d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0; + d3d_verts[0].color = d3d_verts[1].color = d3d_verts[2].color = + d3d_verts[3].color = d3d_verts[4].color = d3d_verts[5].color = + d3d_verts[6].color = d3d_verts[7].color = d3d_verts[8].color = + d3d_verts[9].color = d3d_verts[10].color = d3d_verts[11].color = 0xffffff; GetClientRect(d3d_device_window, &window_rect); d3d_fs_size(window_rect, &l, &t, &r, &b, w, h); @@ -455,6 +445,10 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) d3d_verts[4].y = t; d3d_verts[5].x = r; d3d_verts[5].y = b; + d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = r - 40.5; + d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = t + 8.5; + d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = r - 8.5; + d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = t + 14.5; if (hr == D3D_OK) hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); @@ -475,7 +469,7 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) hr = d3ddev->SetTexture(0, d3dTexture); if (hr == D3D_OK) - hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); + hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); if (hr == D3D_OK) hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); @@ -497,23 +491,21 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) PostMessage(ghwnd, WM_RESETD3D, 0, 0); } - static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) { HRESULT hr = D3D_OK; VOID* pVoid; D3DLOCKED_RECT dr; RECT window_rect; - uint32_t *p; int xx, yy; double l, t, r, b; - if (!h || (d3dTexture == NULL)) + if (!h) { video_blit_complete(); - return; /*Nothing to do*/ + return; /*Nothing to do*/ } - + if (hr == D3D_OK) { RECT lock_rect; @@ -528,7 +520,7 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) for (yy = 0; yy < h; yy++) { - p = (uint32_t *) &(((uint8_t *) dr.pBits)[yy * dr.Pitch]); + uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (yy * dr.Pitch)); if ((y + yy) >= 0 && (y + yy) < buffer->h) { for (xx = 0; xx < w; xx++) @@ -542,11 +534,15 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) } else video_blit_complete(); - + d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0; d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0; d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0; d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0; + d3d_verts[0].color = d3d_verts[1].color = d3d_verts[2].color = + d3d_verts[3].color = d3d_verts[4].color = d3d_verts[5].color = + d3d_verts[6].color = d3d_verts[7].color = d3d_verts[8].color = + d3d_verts[9].color = d3d_verts[10].color = d3d_verts[11].color = 0xffffff; GetClientRect(d3d_device_window, &window_rect); d3d_fs_size(window_rect, &l, &t, &r, &b, w, h); @@ -563,6 +559,10 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) d3d_verts[4].y = t; d3d_verts[5].x = r; d3d_verts[5].y = b; + d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = r - 40.5; + d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = t + 8.5; + d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = r - 8.5; + d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = t + 14.5; if (hr == D3D_OK) hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); @@ -583,7 +583,7 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) hr = d3ddev->SetTexture(0, d3dTexture); if (hr == D3D_OK) - hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); + hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); if (hr == D3D_OK) hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); diff --git a/src/WIN/win_ddraw.cc b/src/WIN/win_ddraw.cc index dc111bab1..e87265f87 100644 --- a/src/WIN/win_ddraw.cc +++ b/src/WIN/win_ddraw.cc @@ -65,7 +65,14 @@ int ddraw_init(HWND h) ddsd.dwHeight = 2048; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL))) - return 0; + { + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.dwWidth = 2048; + ddsd.dwHeight = 2048; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL))) + fatal("CreateSurface back failed\n"); + } memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -75,7 +82,14 @@ int ddraw_init(HWND h) ddsd.dwHeight = 2048; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back2, NULL))) - return 0; + { + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.dwWidth = 2048; + ddsd.dwHeight = 2048; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back2, NULL))) + fatal("CreateSurface back failed\n"); + } if (FAILED(lpdd7->CreateClipper(0, &lpdd_clipper, NULL))) return 0; @@ -125,9 +139,8 @@ static void ddraw_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) { RECT r_src; RECT r_dest; - int xx, yy; + int yy; POINT po; - uint32_t *p; HRESULT hr; // pclog("Blit memtoscreen %i,%i %i %i %i,%i\n", x, y, y1, y2, w, h); diff --git a/src/WIN/win_ddraw_fs.cc b/src/WIN/win_ddraw_fs.cc index f29524d64..abb390093 100644 --- a/src/WIN/win_ddraw_fs.cc +++ b/src/WIN/win_ddraw_fs.cc @@ -78,7 +78,14 @@ int ddraw_fs_init(HWND h) ddsd.dwHeight = 2048; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL))) - return 0; + { + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.dwWidth = 2048; + ddsd.dwHeight = 2048; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL))) + return 0; + } pclog("DDRAW_INIT complete\n"); ddraw_hwnd = h; diff --git a/src/WIN/win_settings.c b/src/WIN/win_settings.c index 702b8b5d5..865bc39dd 100644 --- a/src/WIN/win_settings.c +++ b/src/WIN/win_settings.c @@ -8,7 +8,7 @@ * * Windows 86Box Settings dialog handler. * - * Version: @(#)win_settings.c 1.0.2 2017/06/04 + * Version: @(#)win_settings.c 1.0.3 2017/06/14 * * Author: Miran Grca, * Copyright 2016-2017 Miran Grca. @@ -34,7 +34,7 @@ #include "../ide.h" #include "../scsi.h" #include "../scsi_buslogic.h" -#include "../network.h" +#include "../network/network.h" #include "../sound/sound.h" #include "../sound/snd_dbopl.h" #include "../sound/snd_mpu401.h" @@ -58,6 +58,7 @@ static int temp_mouse, temp_joystick; /* Sound category */ static int temp_sound_card, temp_midi_id, temp_mpu401, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type; +static int temp_float; /* Network category */ static int temp_net_type, temp_net_card; @@ -124,6 +125,7 @@ static void win_settings_init(void) temp_GAMEBLASTER = GAMEBLASTER; temp_GUS = GUS; temp_opl3_type = opl3_type; + temp_float = sound_is_float; /* Network category */ temp_net_type = network_type; @@ -189,6 +191,7 @@ static int win_settings_changed(void) i = i || (GAMEBLASTER != temp_GAMEBLASTER); i = i || (GUS != temp_GUS); i = i || (opl3_type != temp_opl3_type); + i = i || (sound_is_float != temp_float); /* Network category */ i = i || (network_type != temp_net_type); @@ -286,6 +289,7 @@ static void win_settings_save(void) GAMEBLASTER = temp_GAMEBLASTER; GUS = temp_GUS; opl3_type = temp_opl3_type; + sound_is_float = temp_float; /* Network category */ network_type = temp_net_type; @@ -321,6 +325,8 @@ static void win_settings_save(void) update_status_bar_panes(hwndStatus); + sound_realloc_buffers(); + resetpchard(); cpu_set(); @@ -1235,6 +1241,9 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa h=GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL); SendMessage(h, BM_SETCHECK, temp_opl3_type, 0); + h=GetDlgItem(hdlg, IDC_CHECK_FLOAT); + SendMessage(h, BM_SETCHECK, temp_float, 0); + free(lptsTemp); return TRUE; @@ -1306,6 +1315,9 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL); temp_opl3_type = SendMessage(h, BM_GETCHECK, 0, 0); + h = GetDlgItem(hdlg, IDC_CHECK_FLOAT); + temp_float = SendMessage(h, BM_GETCHECK, 0, 0); + default: return FALSE; } diff --git a/src/cdrom.c b/src/cdrom.c index 2bcfc20cc..4f81e253c 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -1856,7 +1856,7 @@ int cdrom_read_blocks(uint8_t id, uint32_t *len, int first_batch) } else { - type = 2; + type = 8; flags = 0x10; } diff --git a/src/cdrom_dosbox.cpp b/src/cdrom_dosbox.cpp index be632fd38..7b621a710 100644 --- a/src/cdrom_dosbox.cpp +++ b/src/cdrom_dosbox.cpp @@ -68,6 +68,7 @@ bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, uint64_t seek, uint6 { uint64_t offs = 0; file = fopen64(fn, "rb"); + if (file == NULL) return 0; fseeko64(file, seek, SEEK_SET); offs = fread(buffer, 1, count, file); fclose(file); @@ -79,6 +80,7 @@ uint64_t CDROM_Interface_Image::BinaryFile::getLength() { uint64_t ret = 0; file = fopen64(fn, "rb"); + if (file == NULL) return 0; fseeko64(file, 0, SEEK_END); ret = ftello64(file); fclose(file); diff --git a/src/cdrom_image.cc b/src/cdrom_image.cc index 07380e79a..810601b24 100644 --- a/src/cdrom_image.cc +++ b/src/cdrom_image.cc @@ -447,7 +447,7 @@ static int image_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ism if (cdrom_image[id].image_is_iso) { audio = 0; - mode2 = 0; + mode2 = cdimg[id]->IsMode2(real_pos) ? 1 : 0; } else { @@ -464,7 +464,7 @@ static int image_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ism return 0; } - if ((cdrom_sector_type == 3) || (cdrom_sector_type > 4)) + if ((cdrom_sector_type == 3) || ((cdrom_sector_type > 4) && (cdrom_sector_type != 8))) { if (cdrom_sector_type == 3) { @@ -589,7 +589,7 @@ read_mode1: } else if (cdrom_sector_type == 4) { - if (audio || !mode2 || cdrom_image[id].image_is_iso) + if (audio || !mode2) { cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Attempting to read a non-XA Mode 2 Form 1 sector from an audio track\n", id); return 0; @@ -626,7 +626,31 @@ read_mode2: return 0; } - cdimg[id]->ReadSector(cdrom_sector_buffer.buffer, true, real_pos); + if (cdrom_image[id].image_is_iso) + { + cdimg[id]->ReadSector(raw_buffer + 24, false, real_pos); + + uint8_t *bb = raw_buffer; + + /* sync bytes */ + bb[0] = 0; + memset(bb + 1, 0xff, 10); + bb[11] = 0; + bb += 12; + + bb[0] = (real_pos >> 16) & 0xff; + bb[1] = (real_pos >> 8) & 0xff; + bb[2] = real_pos & 0xff; + + bb[3] = 1; /* mode 1 data */ + bb += 12; + bb += 2048; + memset(bb, 0, 280); + } + else + { + cdimg[id]->ReadSector(raw_buffer, true, real_pos); + } cdrom_sector_size = 0; @@ -671,6 +695,23 @@ read_mode2: temp_b += 280; } } + else if (cdrom_sector_type == 8) + { + if (audio) + { + cdrom_image_log("CD-ROM %i: [Any Data] Attempting to read a data sector from an audio track\n", id); + return 0; + } + + if (mode2) + { + goto read_mode2; + } + else + { + goto read_mode1; + } + } else { if (mode2) diff --git a/src/config.c b/src/config.c index 0b4dbce53..7a044a6c0 100644 --- a/src/config.c +++ b/src/config.c @@ -24,7 +24,7 @@ #include "hdd.h" #include "model.h" #include "mouse.h" -#include "network.h" +#include "network/network.h" #include "nvr.h" #include "scsi.h" #include "win/plat_joystick.h" @@ -773,7 +773,6 @@ static void loadconfig_general(void) { char *cat = "General"; char temps[512]; - wchar_t *wp; char *p; vid_resize = !!config_get_int(cat, "vid_resize", 0); @@ -824,6 +823,42 @@ static void loadconfig_general(void) window_w = window_h = window_x = window_y = 0; } +#ifndef __unix + /* Currently, 86Box is English (US) only, but in the future (version 1.30 at the earliest) other languages will be added, + therefore it is better to future-proof the code. */ + dwLanguage = config_get_hex16(cat, "language", 0x0409); +#endif +} + + +/* Machine */ +static void loadconfig_machine(void) +{ + char *cat = "Machine"; + wchar_t *wp; + char *p; + + p = config_get_string(cat, "model", NULL); + if (p != NULL) + model = model_get_model_from_internal_name(p); + else + model = 0; + if (model >= model_count()) + model = model_count() - 1; + + romset = model_getromset(); + cpu_manufacturer = config_get_int(cat, "cpu_manufacturer", 0); + cpu = config_get_int(cat, "cpu", 0); + cpu_waitstates = config_get_int(cat, "cpu_waitstates", 0); + + mem_size = config_get_int(cat, "mem_size", 4096); + if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram)) + mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram); + if (mem_size > 262144) + { + mem_size = 262144; + } + if (read_nvr_path != NULL) { free(read_nvr_path); @@ -857,41 +892,6 @@ static void loadconfig_general(void) path_len = wcslen(nvr_path); -#ifndef __unix - /* Currently, 86Box is English (US) only, but in the future (version 1.30 at the earliest) other languages will be added, - therefore it is better to future-proof the code. */ - dwLanguage = config_get_hex16(cat, "language", 0x0409); -#endif -} - - -/* Machine */ -static void loadconfig_machine(void) -{ - char *cat = "Machine"; - char *p; - - p = config_get_string(cat, "model", NULL); - if (p != NULL) - model = model_get_model_from_internal_name(p); - else - model = 0; - if (model >= model_count()) - model = model_count() - 1; - - romset = model_getromset(); - cpu_manufacturer = config_get_int(cat, "cpu_manufacturer", 0); - cpu = config_get_int(cat, "cpu", 0); - cpu_waitstates = config_get_int(cat, "cpu_waitstates", 0); - - mem_size = config_get_int(cat, "mem_size", 4096); - if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram)) - mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram); - if (mem_size > 262144) - { - mem_size = 262144; - } - cpu_use_dynarec = !!config_get_int(cat, "cpu_use_dynarec", 0); enable_external_fpu = !!config_get_int(cat, "cpu_enable_fpu", 0); @@ -997,6 +997,21 @@ static void loadconfig_sound(void) { opl3_type = 0; } + + memset(temps, '\0', sizeof(temps)); + p = config_get_string(cat, "sound_type", "float"); + if (p != NULL) + { + strcpy(temps, p); + } + if (!strcmp(temps, "float") || !strcmp(temps, "1")) + { + sound_is_float = 1; + } + else + { + sound_is_float = 0; + } } @@ -1793,15 +1808,6 @@ static void saveconfig_general(void) config_delete_var(cat, "window_coordinates"); } - if (read_nvr_path == NULL) - { - config_delete_var(cat, "nvr_path"); - } - else - { - config_set_wstring(cat, "nvr_path", nvr_path); - } - #ifndef __unix if (dwLanguage == 0x0409) { @@ -1860,6 +1866,15 @@ static void saveconfig_machine(void) config_set_int(cat, "mem_size", mem_size); } + if (read_nvr_path == NULL) + { + config_delete_var(cat, "nvr_path"); + } + else + { + config_set_wstring(cat, "nvr_path", nvr_path); + } + config_set_int(cat, "cpu_use_dynarec", cpu_use_dynarec); if (enable_external_fpu == 0) @@ -2059,6 +2074,15 @@ static void saveconfig_sound(void) config_set_string(cat, "opl3_type", (opl3_type == 1) ? "nukedopl" : "dbopl"); } + if (sound_is_float == 1) + { + config_delete_var(cat, "sound_type"); + } + else + { + config_set_string(cat, "sound_type", (sound_is_float == 1) ? "float" : "int16"); + } + config_delete_section_if_empty(cat); } diff --git a/src/device.c b/src/device.c index 9b90c9ea1..9d8968f82 100644 --- a/src/device.c +++ b/src/device.c @@ -73,6 +73,22 @@ void device_close_all() } } +void *device_get_priv(device_t *d) +{ + int c; + + for (c = 0; c < 256; c++) + { + if (devices[c] != NULL) + { + if (devices[c] == d) + return device_priv[c]; + } + } + + return NULL; +} + int device_available(device_t *d) { #ifdef RELEASE_BUILD diff --git a/src/device.h b/src/device.h index 5a2f9b17e..e5613f836 100644 --- a/src/device.h +++ b/src/device.h @@ -72,6 +72,7 @@ typedef struct device_t extern void device_init(void); extern void device_add(device_t *d); extern void device_close_all(void); +extern void *device_get_priv(device_t *d); extern int device_available(device_t *d); extern void device_speed_changed(void); extern void device_force_redraw(void); diff --git a/src/hdd_esdi.c b/src/hdd_esdi.c index 4772b2c48..4c3cc152d 100644 --- a/src/hdd_esdi.c +++ b/src/hdd_esdi.c @@ -54,7 +54,7 @@ typedef struct esdi_t int data_pos; uint16_t data[256]; - uint16_t sector_buffer[16][256]; + uint16_t sector_buffer[256][256]; int sector_pos; int sector_count; @@ -632,7 +632,7 @@ static void esdi_callback(void *p) case 0: esdi->sector_pos = 0; esdi->sector_count = esdi->cmd_data[1]; - if (esdi->sector_count > 16) + if (esdi->sector_count > 256) fatal("Read sector buffer count %04x\n", esdi->cmd_data[1]); esdi->status = STATUS_IRQ | STATUS_CMD_IN_PROGRESS | STATUS_TRANSFER_REQ; @@ -692,7 +692,7 @@ static void esdi_callback(void *p) case 0: esdi->sector_pos = 0; esdi->sector_count = esdi->cmd_data[1]; - if (esdi->sector_count > 16) + if (esdi->sector_count > 256) fatal("Write sector buffer count %04x\n", esdi->cmd_data[1]); esdi->status = STATUS_IRQ | STATUS_CMD_IN_PROGRESS | STATUS_TRANSFER_REQ; diff --git a/src/ide.c b/src/ide.c index 87822a628..d92ce13be 100644 --- a/src/ide.c +++ b/src/ide.c @@ -1252,21 +1252,28 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) case WIN_SETIDLE1: /* Idle */ case WIN_CHECKPOWERMODE1: case WIN_SLEEP1: - if (ide_drive_is_cdrom(ide)) + if (val == WIN_DRIVE_DIAGNOSTICS) { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + callbackide(ide_board); } else { - ide->atastat = BUSY_STAT; + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = BUSY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = ((val == WIN_DRIVE_DIAGNOSTICS) ? 200 : 30) * IDE_TIME; + } + idecallback[ide_board] = ((val == WIN_DRIVE_DIAGNOSTICS) ? 200 : 30) * IDE_TIME; + timer_update_outstanding(); } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 30*IDE_TIME; - } - idecallback[ide_board]=30*IDE_TIME; - timer_update_outstanding(); return; case WIN_IDENTIFY: /* Identify Device */ diff --git a/src/intel_flash.c b/src/intel_flash.c index 6ded787ef..d03e1de94 100644 --- a/src/intel_flash.c +++ b/src/intel_flash.c @@ -18,8 +18,10 @@ #include #include "ibm.h" +#include "CPU/cpu.h" #include "device.h" #include "mem.h" +#include "model.h" #include "rom.h" #define FLASH_IS_BXB 2 @@ -171,71 +173,23 @@ void *intel_flash_init(uint8_t type) FILE *f; int i; flash_t *flash; + wchar_t *model_name; + wchar_t *flash_name; + flash = malloc(sizeof(flash_t)); memset(flash, 0, sizeof(flash_t)); - switch(romset) - { - case ROM_REVENGE: - wcscpy(flash_path, L"revenge.bin"); - break; - case ROM_586MC1: - wcscpy(flash_path, L"586mc1.bin"); - break; - case ROM_PLATO: - wcscpy(flash_path, L"plato.bin"); - break; - case ROM_ENDEAVOR: - wcscpy(flash_path, L"endeavor.bin"); - break; - case ROM_MB500N: - wcscpy(flash_path, L"mb500n.bin"); - break; - case ROM_P54TP4XE: - wcscpy(flash_path, L"p54tp4xe.bin"); - break; - case ROM_AP53: - wcscpy(flash_path, L"ap53.bin"); - break; - case ROM_P55T2S: - wcscpy(flash_path, L"p55t2s.bin"); - break; - case ROM_ACERM3A: - wcscpy(flash_path, L"acerm3a.bin"); - break; - case ROM_ACERV35N: - wcscpy(flash_path, L"acerv35n.bin"); - break; - case ROM_430VX: - wcscpy(flash_path, L"430vx.bin"); - break; - case ROM_P55VA: - wcscpy(flash_path, L"p55va.bin"); - break; - case ROM_P55T2P4: - wcscpy(flash_path, L"p55t2p4.bin"); - break; - case ROM_P55TVP4: - wcscpy(flash_path, L"p55tvp4.bin"); - break; - case ROM_440FX: - wcscpy(flash_path, L"440fx.bin"); - break; - case ROM_THOR: - wcscpy(flash_path, L"thor.bin"); - break; - case ROM_MRTHOR: - wcscpy(flash_path, L"mrthor.bin"); - break; - case ROM_ZAPPA: - wcscpy(flash_path, L"zappa.bin"); - break; - case ROM_S1668: - wcscpy(flash_path, L"tpatx.bin"); - break; - default: - fatal("intel_flash_init on unsupported ROM set %i\n", romset); - } + model_name = (wchar_t *) malloc((strlen(model_get_internal_name_ex(model)) << 1) + 2); + mbstowcs(model_name, model_get_internal_name_ex(model), strlen(model_get_internal_name_ex(model)) + 1); + flash_name = (wchar_t *) malloc((wcslen(model_name) << 1) + 2 + 8); + _swprintf(flash_name, L"%s.bin", model_name); + + wcscpy(flash_path, flash_name); + + free(flash_name); + free(model_name); + + pclog_w(L"Flash path: %s\n", flash_name); flash->flash_id = (type & FLASH_IS_BXB) ? 0x95 : 0x94; flash->invert_high_pin = (type & FLASH_INVERT); diff --git a/src/mem.c b/src/mem.c index 17b564a9e..fd393e446 100644 --- a/src/mem.c +++ b/src/mem.c @@ -434,6 +434,7 @@ int loadbios() pclog("Load SIS496 %x %x\n", rom[0x1fff0], rom[0xfff0]); return 1; +#if 0 case ROM_430VX: f = romfopen(L"roms/430vx/55XWUQ0E.BIN", L"rb"); if (!f) break; @@ -441,6 +442,7 @@ int loadbios() fclose(f); biosmask = 0x1ffff; return 1; +#endif case ROM_REVENGE: f = romfopen(L"roms/revenge/1009AF2_.BIO", L"rb"); @@ -650,6 +652,7 @@ int loadbios() pclog("Load R418 %x %x\n", rom[0x1fff0], rom[0xfff0]); return 1; +#if 0 case ROM_586MC1: f = romfopen(L"roms/586mc1/IS.34", L"rb"); if (!f) break; @@ -657,6 +660,7 @@ int loadbios() fclose(f); biosmask = 0x1ffff; return 1; +#endif case ROM_PLATO: f = romfopen(L"roms/plato/1016AX1_.BIO", L"rb"); @@ -712,6 +716,7 @@ int loadbios() biosmask = 0x1ffff; return 1; +#if 0 case ROM_ACERV35N: f = romfopen(L"roms/acerv35n/V35ND1S1.BIN", L"rb"); if (!f) break; @@ -719,6 +724,7 @@ int loadbios() fclose(f); biosmask = 0x1ffff; return 1; +#endif case ROM_P55VA: f = romfopen(L"roms/p55va/VA021297.BIN", L"rb"); @@ -1125,7 +1131,7 @@ void addwritelookup(uint32_t virt, uint32_t phys) writelookup2[writelookup[writelnext]] = -1; } - if (pages[phys >> 12].block || (phys & ~0xfff) == recomp_page) + if (pages[phys >> 12].block[0] || pages[phys >> 12].block[1] || pages[phys >> 12].block[2] || pages[phys >> 12].block[3] || (phys & ~0xfff) == recomp_page) page_lookup[virt >> 12] = &pages[phys >> 12]; else writelookup2[virt>>12] = (uintptr_t)&ram[(uintptr_t)(phys & ~0xFFF) - (uintptr_t)(virt & ~0xfff)]; @@ -1707,7 +1713,7 @@ void mem_write_ramb_page(uint32_t addr, uint8_t val, page_t *p) if (val != p->mem[addr & 0xfff] || codegen_in_recompile) { uint64_t mask = (uint64_t)1 << ((addr >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK); - p->dirty_mask |= mask; + p->dirty_mask[(addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK] |= mask; p->mem[addr & 0xfff] = val; } } @@ -1716,9 +1722,9 @@ void mem_write_ramw_page(uint32_t addr, uint16_t val, page_t *p) if (val != *(uint16_t *)&p->mem[addr & 0xfff] || codegen_in_recompile) { uint64_t mask = (uint64_t)1 << ((addr >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK); - if ((addr & 0x3f) == 0x3f) + if ((addr & 0xf) == 0xf) mask |= (mask << 1); - p->dirty_mask |= mask; + p->dirty_mask[(addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK] |= mask; *(uint16_t *)&p->mem[addr & 0xfff] = val; } } @@ -1727,9 +1733,9 @@ void mem_write_raml_page(uint32_t addr, uint32_t val, page_t *p) if (val != *(uint32_t *)&p->mem[addr & 0xfff] || codegen_in_recompile) { uint64_t mask = (uint64_t)1 << ((addr >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK); - if ((addr & 0x3f) >= 0x3d) + if ((addr & 0xf) >= 0xd) mask |= (mask << 1); - p->dirty_mask |= mask; + p->dirty_mask[(addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK] |= mask; *(uint32_t *)&p->mem[addr & 0xfff] = val; } } @@ -1752,10 +1758,10 @@ void mem_write_raml(uint32_t addr, uint32_t val, void *priv) uint8_t mem_read_bios(uint32_t addr, void *priv) { - if (AMIBIOS && (addr&0xFFFFF)==0xF8281) /*This is read constantly during AMIBIOS POST, but is never written to. It's clearly a status register of some kind, but for what?*/ - { - return 0x40; - } + if (AMIBIOS && (addr&0xFFFFF)==0xF8281) /*This is read constantly during AMIBIOS POST, but is never written to. It's clearly a status register of some kind, but for what?*/ + { + return 0x40; + } return rom[addr & biosmask]; } uint16_t mem_read_biosw(uint32_t addr, void *priv) @@ -1798,8 +1804,8 @@ void mem_invalidate_range(uint32_t start_addr, uint32_t end_addr) for (; start_addr <= end_addr; start_addr += (1 << PAGE_MASK_SHIFT)) { uint64_t mask = (uint64_t)1 << ((start_addr >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK); - - pages[start_addr >> 12].dirty_mask |= mask; + + pages[start_addr >> 12].dirty_mask[(start_addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK] |= mask; } } @@ -2214,8 +2220,8 @@ void mem_reset_page_blocks() pages[c].write_b = mem_write_ramb_page; pages[c].write_w = mem_write_ramw_page; pages[c].write_l = mem_write_raml_page; - pages[c].block = NULL; - pages[c].block_2 = NULL; + pages[c].block[0] = pages[c].block[1] = pages[c].block[2] = pages[c].block[3] = NULL; + pages[c].block_2[0] = pages[c].block_2[1] = pages[c].block_2[2] = pages[c].block_2[3] = NULL; } } diff --git a/src/mem.h b/src/mem.h index 6bf127ecf..916e89995 100644 --- a/src/mem.h +++ b/src/mem.h @@ -122,12 +122,12 @@ typedef struct page_t uint8_t *mem; - struct codeblock_t *block, *block_2; + struct codeblock_t *block[4], *block_2[4]; /*Head of codeblock tree associated with this page*/ struct codeblock_t *head; - uint64_t code_present_mask, dirty_mask; + uint64_t code_present_mask[4], dirty_mask[4]; } page_t; extern page_t *pages; diff --git a/src/model.c b/src/model.c index 9e4dc6b7e..b45b89efc 100644 --- a/src/model.c +++ b/src/model.c @@ -84,7 +84,9 @@ #include "sound/snd_sn76489.h" #include "tandy_eeprom.h" #include "tandy_rom.h" +#if 0 #include "um8669f.h" +#endif #include "video/vid_pcjr.h" #include "video/vid_tandy.h" #include "w83877f.h" @@ -117,25 +119,17 @@ extern void at_wd76c10_init(void); extern void at_ali1429_init(void); extern void at_headland_init(void); extern void at_opti495_init(void); -extern void at_sis496_init(void); -extern void at_i430vx_init(void); extern void at_batman_init(void); extern void at_endeavor_init(void); extern void at_dtk486_init(void); extern void at_r418_init(void); -#if 0 -extern void at_586mc1_init(void); -#endif extern void at_plato_init(void); extern void at_mb500n_init(void); extern void at_p54tp4xe_init(void); extern void at_ap53_init(void); extern void at_p55t2s_init(void); extern void at_acerm3a_init(void); -#if 0 -extern void at_acerv35n_init(void); -#endif extern void at_p55t2p4_init(void); extern void at_p55tvp4_init(void); extern void at_p55va_init(void); @@ -157,81 +151,73 @@ int romset; MODEL models[] = { - {"IBM PC", ROM_IBMPC, "ibmpc", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"IBM XT", ROM_IBMXT, "ibmxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"Compaq Portable", ROM_PORTABLE, "portable", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 128, 640, 128, xt_init, NULL}, - {"IBM PCjr", ROM_IBMPCJR, "ibmpcjr", { "", cpus_pcjr, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 128, 640, 128, pcjr_init, &pcjr_device}, - {"Generic XT clone", ROM_GENXT, "genxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"AMI XT clone", ROM_AMIXT, "amixt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"DTK XT clone", ROM_DTKXT, "dtk", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"VTech Laser Turbo XT", ROM_LTXT, "ltxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_laserxt_init, NULL}, - {"VTech Laser XT3", ROM_LXT3, "lxt3", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_laserxt_init, NULL}, - {"Phoenix XT clone", ROM_PXXT, "pxxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"Juko XT clone", ROM_JUKOPC, "jukopc", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, xt_init, NULL}, - {"Tandy 1000", ROM_TANDY, "tandy", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 128, 640, 128, tandy1k_init, &tandy1000_device}, - {"Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 256, 640, 128, tandy1k_init, &tandy1000hx_device}, - {"Tandy 1000 SL/2", ROM_TANDY1000SL2, "tandy1000sl2", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 512, 768, 128, tandy1ksl2_init, NULL}, - {"Amstrad PC1512", ROM_PC1512, "pc1512", { "", cpus_pc1512, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, - {"Sinclair PC200", ROM_PC200, "pc200", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, - {"Schneider EuroPC", ROM_EUROPC, "europc", { "", cpus_europc, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 512, 640, 128, europc_init, NULL}, - {"Olivetti M24", ROM_OLIM24, "olivetti_m24", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_OLIM24, 128, 640, 128, olim24_init, NULL}, - {"Amstrad PC1640", ROM_PC1640, "pc1640", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, - {"Amstrad PC2086", ROM_PC2086, "pc2086", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, - {"Amstrad PC3086", ROM_PC3086, "pc3086", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, - {"IBM AT", ROM_IBMAT, "ibmat", { "", cpus_ibmat, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, ibm_at_init, NULL}, - {"Compaq Portable II", ROM_PORTABLEII, "portableii", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, at_init, NULL}, - {"Compaq Portable III", ROM_PORTABLEIII, "portableiii", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, at_init, NULL}, - {"Commodore PC 30 III", ROM_CMDPC30, "cmdpc30", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, at_ide_init, NULL}, - {"AMI 286 clone", ROM_AMI286, "ami286", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, at_neat_init, NULL}, - {"Award 286 clone", ROM_AWARD286, "award286", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, at_scat_init, NULL}, - {"Hyundai Super-286TR", ROM_SUPER286TR, "super286tr", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_scat_init, NULL}, - {"Samsung SPC-4200P", ROM_SPC4200P, "spc4200p", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_scat_init, NULL}, - {"IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibmps1es", { "", cpus_ps1_m2011, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD, 1, 16, 1, ps1_m2011_init, NULL}, - {"IBM PS/2 Model 30-286", ROM_IBMPS2_M30_286, "ibmps2_m30_286", { "", cpus_ps2_m30_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD, 1, 16, 1, ps2_m30_286_init, NULL}, - {"IBM PS/2 Model 50", ROM_IBMPS2_M50, "ibmps2_m50", { "", cpus_ps2_m30_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD | MODEL_MCA, 1, 16, 1, ps2_model_50_init, NULL}, - {"IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibmps1_2121", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, ps1_m2121_init, NULL}, - {"IBM PS/1 m.2121 + ISA", ROM_IBMPS1_2121_ISA, "ibmps1_2121_isa", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, ps1_m2121_init, NULL}, - {"IBM PS/2 Model 55SX", ROM_IBMPS2_M55SX, "ibmps2_m55sx", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD | MODEL_MCA, 1, 8, 1, ps2_model_55sx_init, NULL}, - {"Compaq Deskpro 386", ROM_DESKPRO_386, "dekspro386", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, deskpro386_init, NULL}, - {"Compaq Portable III 386", ROM_PORTABLEIII386, "portableiii386", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, at_init, NULL}, - {"DTK 386SX clone", ROM_DTK386, "dtk386", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, at_neat_init, NULL}, - {"Amstrad MegaPC", ROM_MEGAPC, "megapc", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, at_wd76c10_init, NULL}, - {"AMI 386SX clone", ROM_AMI386SX, "ami386", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, at_headland_init, NULL}, - {"IBM PS/2 Model 80", ROM_IBMPS2_M80, "ibmps2_m80", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD | MODEL_MCA, 1, 12, 1, ps2_model_80_init, NULL}, + {"IBM PC", ROM_IBMPC, "ibmpc", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, 0, xt_init, NULL}, + {"IBM XT", ROM_IBMXT, "ibmxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, 0, xt_init, NULL}, + {"Compaq Portable", ROM_PORTABLE, "portable", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 128, 640, 128, 0, xt_init, NULL}, + {"IBM PCjr", ROM_IBMPCJR, "ibmpcjr", { "", cpus_pcjr, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 128, 640, 128, 0, pcjr_init, &pcjr_device}, + {"Generic XT clone", ROM_GENXT, "genxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, 0, xt_init, NULL}, + {"AMI XT clone", ROM_AMIXT, "amixt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, 0, xt_init, NULL}, + {"DTK XT clone", ROM_DTKXT, "dtk", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, 0, xt_init, NULL}, + {"VTech Laser Turbo XT", ROM_LTXT, "ltxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 1152, 64, 0, xt_laserxt_init, NULL}, + {"VTech Laser XT3", ROM_LXT3, "lxt3", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 1152, 64, 0, xt_laserxt_init, NULL}, + {"Phoenix XT clone", ROM_PXXT, "pxxt", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, 0, xt_init, NULL}, + {"Juko XT clone", ROM_JUKOPC, "jukopc", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 64, 640, 64, 0, xt_init, NULL}, + {"Tandy 1000", ROM_TANDY, "tandy", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 128, 640, 128, 0, tandy1k_init, &tandy1000_device}, + {"Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", { "", cpus_8088, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 256, 640, 128, 0, tandy1k_init, &tandy1000hx_device}, + {"Tandy 1000 SL/2", ROM_TANDY1000SL2, "tandy1000sl2", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, 0, 512, 768, 128, 0, tandy1ksl2_init, NULL}, + {"Amstrad PC1512", ROM_PC1512, "pc1512", { "", cpus_pc1512, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, 63, ams_init, NULL}, + {"Sinclair PC200", ROM_PC200, "pc200", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, 63, ams_init, NULL}, + {"Schneider EuroPC", ROM_EUROPC, "europc", { "", cpus_europc, "", NULL, "", NULL, "", NULL, "", NULL}, 0, 0, 512, 640, 128, 0, europc_init, NULL}, + {"Olivetti M24", ROM_OLIM24, "olivetti_m24", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_OLIM24, 128, 640, 128, 0, olim24_init, NULL}, + {"Amstrad PC1640", ROM_PC1640, "pc1640", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, 63, ams_init, NULL}, + {"Amstrad PC2086", ROM_PC2086, "pc2086", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, 63, ams_init, NULL}, + {"Amstrad PC3086", ROM_PC3086, "pc3086", { "", cpus_8086, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, 63, ams_init, NULL}, + {"IBM AT", ROM_IBMAT, "ibmat", { "", cpus_ibmat, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, 63, ibm_at_init, NULL}, + {"Compaq Portable II", ROM_PORTABLEII, "portableii", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, 63, at_init, NULL}, + {"Compaq Portable III", ROM_PORTABLEIII, "portableiii", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, 63, at_init, NULL}, + {"Commodore PC 30 III", ROM_CMDPC30, "cmdpc30", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, 127, at_ide_init, NULL}, + {"AMI 286 clone", ROM_AMI286, "ami286", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, 127, at_neat_init, NULL}, + {"Award 286 clone", ROM_AWARD286, "award286", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, 127, at_scat_init, NULL}, + {"Hyundai Super-286TR", ROM_SUPER286TR, "super286tr", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, 127, at_scat_init, NULL}, + {"Samsung SPC-4200P", ROM_SPC4200P, "spc4200p", { "", cpus_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, 127, at_scat_init, NULL}, + {"IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibmps1es", { "", cpus_ps1_m2011, "", NULL, "", NULL, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD, 1, 16, 1, 127, ps1_m2011_init, NULL}, + {"IBM PS/2 Model 30-286", ROM_IBMPS2_M30_286, "ibmps2_m30_286", { "", cpus_ps2_m30_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD, 1, 16, 1, 127, ps2_m30_286_init, NULL}, + {"IBM PS/2 Model 50", ROM_IBMPS2_M50, "ibmps2_m50", { "", cpus_ps2_m30_286, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD | MODEL_MCA, 1, 16, 1, 63, ps2_model_50_init, NULL}, + {"IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibmps1_2121", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, 127, ps1_m2121_init, NULL}, + {"IBM PS/1 m.2121 + ISA", ROM_IBMPS1_2121_ISA, "ibmps1_2121_isa", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, 127, ps1_m2121_init, NULL}, + {"IBM PS/2 Model 55SX", ROM_IBMPS2_M55SX, "ibmps2_m55sx", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD | MODEL_MCA, 1, 8, 1, 63, ps2_model_55sx_init, NULL}, + {"Compaq Deskpro 386", ROM_DESKPRO_386, "dekspro386", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, 63, deskpro386_init, NULL}, + {"Compaq Portable III 386", ROM_PORTABLEIII386, "portableiii386", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT, 1, 15, 1, 63, at_init, NULL}, + {"DTK 386SX clone", ROM_DTK386, "dtk386", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 16, 1, 127, at_neat_init, NULL}, + {"Amstrad MegaPC", ROM_MEGAPC, "megapc", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, 127, at_wd76c10_init, NULL}, + {"AMI 386SX clone", ROM_AMI386SX, "ami386", { "Intel", cpus_i386SX, "AMD", cpus_Am386SX, "Cyrix", cpus_486SLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, 127, at_headland_init, NULL}, + {"IBM PS/2 Model 80", ROM_IBMPS2_M80, "ibmps2_m80", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_PS2_HDD | MODEL_MCA, 1, 12, 1, 63, ps2_model_80_init, NULL}, /* The MegaPC manual says 386DX model of the Amstrad PC70386 exists, but Sarah Walker just *had* to remove 386DX CPU's from some boards. */ - {"Amstrad MegaPC 386DX", ROM_MEGAPCDX, "megapcdx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, at_wd76c10_init, NULL}, - {"MR 386DX clone", ROM_MR386DX_OPTI495, "mr386dx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, at_opti495_init, NULL}, - {"AMI 386DX clone", ROM_AMI386DX_OPTI495, "ami386dx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, at_opti495_init, NULL}, - {"IBM PS/1 model 2133", ROM_IBMPS1_2133, "ibmps1_2133", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 64, 1, ps1_m2133_init, NULL}, - {"AMI 486 clone", ROM_AMI486, "ami486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, at_ali1429_init, NULL}, - {"AMI WinBIOS 486", ROM_WIN486, "win486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, at_ali1429_init, NULL}, - {"DTK PKM-0038S E-2", ROM_DTK486, "dtk486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, at_dtk486_init, NULL}, - {"Award SiS 496/497", ROM_SIS496, "sis496", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE | MODEL_PCI, 1, 64, 1, at_sis496_init, NULL}, - {"Rise Computer R418", ROM_R418, "r418", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE | MODEL_PCI, 1, 64, 1, at_r418_init, NULL}, - {"Intel Premiere/PCI", ROM_REVENGE, "revenge", { "Intel", cpus_Pentium5V, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, at_batman_init, NULL}, -#if 0 - {"Micro Star 586MC1", ROM_586MC1, "586mc1", { "Intel", cpus_Pentium5V50, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, at_586mc1_init, NULL}, -#endif - {"Intel Premiere/PCI II", ROM_PLATO, "plato", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, at_plato_init, NULL}, - {"Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, at_endeavor_init, NULL}, - {"Intel Advanced/ZP", ROM_ZAPPA, "zappa", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, at_endeavor_init, NULL}, - {"PC Partner MB500N", ROM_MB500N, "mb500n", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, at_mb500n_init, NULL}, - {"Intel Advanced/ATX", ROM_THOR, "thor", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_endeavor_init, NULL}, - {"MR Intel Advanced/ATX", ROM_MRTHOR, "mrthor", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_endeavor_init, NULL}, - {"ASUS P/I-P54TP4XE", ROM_P54TP4XE, "p54tp4xe", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_p54tp4xe_init, NULL}, - {"AOpen AP53", ROM_AP53, "ap53", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_ap53_init, NULL}, - {"ASUS P/I-P55T2S", ROM_P55T2S, "p55t2s", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_p55t2s_init, NULL}, - {"Acer M3a", ROM_ACERM3A, "acerm3a", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_acerm3a_init, NULL}, -#if 0 - {"Acer V35N", ROM_ACERV35N, "acerv3n", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_acerv35n_init, NULL}, -#endif - {"ASUS P/I-P55T2P4", ROM_P55T2P4, "p55r2p4", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_p55t2p4_init, NULL}, - {"Award 430VX PCI", ROM_430VX, "430vx", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_i430vx_init, NULL}, - {"Epox P55-VA", ROM_P55VA, "p55va", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_p55va_init, NULL}, - {"ASUS P/I-P55TVP4", ROM_P55TVP4, "p55tvp4", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_p55tvp4_init, NULL}, - {"Tyan Titan-Pro AT", ROM_440FX, "440fx", { "Intel", cpus_PentiumPro, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_i440fx_init, NULL}, - {"Tyan Titan-Pro ATX", ROM_S1668, "tpatx", { "Intel", cpus_PentiumPro, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, at_s1668_init, NULL}, - {"", -1, "", {"", 0, "", 0, "", 0}, 0,0,0, 0} + {"Amstrad MegaPC 386DX", ROM_MEGAPCDX, "megapcdx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 1, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 16, 1, 127, at_wd76c10_init, NULL}, + {"MR 386DX clone", ROM_MR386DX_OPTI495, "mr386dx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, 127, at_opti495_init, NULL}, + {"AMI 386DX clone", ROM_AMI386DX_OPTI495, "ami386dx", { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, 127, at_opti495_init, NULL}, + {"IBM PS/1 model 2133", ROM_IBMPS1_2133, "ibmps1_2133", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE, 1, 64, 1, 127, ps1_m2133_init, NULL}, + {"AMI 486 clone", ROM_AMI486, "ami486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, 127, at_ali1429_init, NULL}, + {"AMI WinBIOS 486", ROM_WIN486, "win486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, 127, at_ali1429_init, NULL}, + {"DTK PKM-0038S E-2", ROM_DTK486, "dtk486", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE, 1, 64, 1, 127, at_dtk486_init, NULL}, + {"Rise Computer R418", ROM_R418, "r418", { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_HAS_IDE | MODEL_PCI, 1, 64, 1, 127, at_r418_init, NULL}, + {"Intel Premiere/PCI", ROM_REVENGE, "revenge", { "Intel", cpus_Pentium5V, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, 127, at_batman_init, NULL}, + {"Intel Premiere/PCI II", ROM_PLATO, "plato", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, 127, at_plato_init, NULL}, + {"Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, 127, at_endeavor_init, NULL}, + {"Intel Advanced/ZP", ROM_ZAPPA, "zappa", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, 127, at_endeavor_init, NULL}, + {"PC Partner MB500N", ROM_MB500N, "mb500n", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, 127, at_mb500n_init, NULL}, + {"Intel Advanced/ATX", ROM_THOR, "thor", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_endeavor_init, NULL}, + {"MR Intel Advanced/ATX", ROM_MRTHOR, "mrthor", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_endeavor_init, NULL}, + {"ASUS P/I-P54TP4XE", ROM_P54TP4XE, "p54tp4xe", { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "AMD", cpus_K5, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_p54tp4xe_init, NULL}, + {"AOpen AP53", ROM_AP53, "ap53", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_ap53_init, NULL}, + {"ASUS P/I-P55T2S", ROM_P55T2S, "p55t2s", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_p55t2s_init, NULL}, + {"Acer M3a", ROM_ACERM3A, "acerm3a", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_acerm3a_init, NULL}, + {"ASUS P/I-P55T2P4", ROM_P55T2P4, "p55r2p4", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_p55t2p4_init, NULL}, + {"Epox P55-VA", ROM_P55VA, "p55va", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_p55va_init, NULL}, + {"ASUS P/I-P55TVP4", ROM_P55TVP4, "p55tvp4", { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "AMD", cpus_K56, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_p55tvp4_init, NULL}, + {"Tyan Titan-Pro AT", ROM_440FX, "440fx", { "Intel", cpus_PentiumPro, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_i440fx_init, NULL}, + {"Tyan Titan-Pro ATX", ROM_S1668, "tpatx", { "Intel", cpus_PentiumPro, "", NULL, "", NULL, "", NULL, "", NULL}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_s1668_init, NULL}, + {"", -1, "", {"", 0, "", 0, "", 0}, 0,0,0,0, 0} }; @@ -280,6 +266,16 @@ char *model_get_internal_name(void) return models[model].internal_name; } +char *model_get_internal_name_ex(int m) +{ + return models[m].internal_name; +} + +int model_get_nvrmask(int m) +{ + return models[m].nvrmask; +} + int model_get_model_from_internal_name(char *s) { int c = 0; @@ -818,6 +814,7 @@ void at_p55t2p4_init(void) device_add(&intel_flash_bxt_device); } +#if 0 void at_i430vx_init(void) { at_ide_init(); @@ -832,6 +829,7 @@ void at_i430vx_init(void) um8669f_init(); device_add(&intel_flash_bxt_device); } +#endif void at_p55tvp4_init(void) { diff --git a/src/model.h b/src/model.h index f483cd1aa..0fc8b6227 100644 --- a/src/model.h +++ b/src/model.h @@ -44,6 +44,7 @@ typedef struct { int flags; int min_ram, max_ram; int ram_granularity; + int nvrmask; void (*init)(void); device_t *device; } MODEL; @@ -62,6 +63,7 @@ extern int model_get_model_from_internal_name(char *s); extern void model_init(void); extern device_t *model_getdevice(int model); extern int model_getromset_ex(int m); - +extern char *model_get_internal_name_ex(int m); +extern int model_get_nvrmask(int m); #endif /*EMU_MODEL_H*/ diff --git a/src/mouse_prot.txt b/src/mouse_prot.txt new file mode 100644 index 000000000..e810e969a --- /dev/null +++ b/src/mouse_prot.txt @@ -0,0 +1,207 @@ +Serial mouse reset +------------------ + +1: Set UART to 'break line' state (set bit 6 in the LCR). +2: Clear the RTS and DTR (bits 0-1) in the MCR, wait a while. +3: Set the RTS and DTR bits again. + + +Serial mouse detection (identification bytes before optional PnP data) +---------------------------------------------------------------------- + +In Mouse Systems mode, mouse sends nothing. +In Microsoft mode, mouse sends 'M' after dropping and raising RTS. +In Logitech mode, mouse sends 'M3' after dropping and raising RTS. +In wheel mode, mouse sends 'MZ@',0,0,0 after dropping and raising RTS. + + +PS/2 pointing device ID (reported after 0F2h command) +----------------------------------------------------- + +In standard mode, the device reports 0. +In wheel mode, the device reports 3. This mode is enabled by sending a + Select Report Rate 200, a Rate 100 and finally a Rate 80 command sequence. +In extended mode, the device reports 4. This mode is enabled by sending a + Select Report Rate 200, a Rate 200 and finally a Rate 80 command sequence. + + +=========================================================================== +Serial Mouse Systems mode: 1200 bps, 8 data bits, 1 stop bit, no parity + + 1st byte 2nd byte 3rd byte + +---------------+ +---------------+ +---------------+ + |1|0|0|0|0|L|M|R| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| + +---------------+ +---------------+ +---------------+ + | | | Xa movement Ya movement + | | | + | | | 4th byte 5th byte + Left Button ------+ | | +---------------+ +---------------+ +Middle Button --------+ | |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| + Right Button ----------+ +---------------+ +---------------+ +(0 if pressed) Xb movement Yb movement + + +Xa/Ya - movement of the mouse since last packet. +Xb/Yb - movement of the mouse since Xa/Ya. +Movement values are 8-bit signed twos complement integers. +Positive movement value indicates motion to the right/upward. + + +=========================================================================== +Serial Microsoft mode: 1200 bps, 7 data bits, 1 stop bit, no parity + + 1st byte 2nd byte 3rd byte + +---------------+ +---------------+ +---------------+ + |0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y| + +---------------+ +---------------+ +---------------+ + | | \ / \ / \----+----/ \----+----/ + | | | | | | + | | +---|-------------|---------+ | + | | +-----+ | | | + | | / \ /----+----\ / \ /----+----\ + | | +---------------+ +---------------+ + Left Button -+ | | | | | | | | | | | | | | | | | | | +Right Button ---+ +---------------+ +---------------+ +(1 if pressed) X movement Y movement + + +Movement values are 8-bit signed twos complement integers. +Positive movement value indicates motion to the right/downward. + + +=========================================================================== +Serial Logitech mode: 1200 bps, 7 data bits, 1 stop bit, no parity + + 1st byte 2nd byte 3rd byte + +---------------+ +---------------+ +---------------+ + |0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y| + +---------------+ +---------------+ +---------------+ + | | \ / \ / \----+----/ \----+----/ + | | | | | | + | | +---|-------------|---------+ | + | | +-----+ | | | + | | / \ /----+----\ / \ /----+----\ + | | +---------------+ +---------------+ + Left Button -+ | | | | | | | | | | | | | | | | | | | +Right Button ---+ +---------------+ +---------------+ +(1 if pressed) X movement Y movement + + +The extra byte (only when middle button is pressed) +--------------------------------------------------- + + 4th byte + +---------------+ + |0|0|M|0|0|0|0|0| + +---------------+ + | + Middle Button (1 if pressed) + + +First three bytes are equal to Mouse mode packet. +Movement values are 8-bit signed twos complement integers. +Positive movement value indicates motion to the right/downward. + + +=========================================================================== +Serial Microsoft wheel mode: 1200 bps, 7 data bits, 1 stop bit, no parity + + 1st byte 2nd byte 3rd byte 4th byte + +---------------+ +---------------+ +---------------+ +---------------+ + |0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y| |0|0|0|M|w|w|w|w| + +---------------+ +---------------+ +---------------+ +---------------+ + | | \ / \ / \----+----/ \----+----/ | \--+--/ + | | | | | | | | + | | +---|-------------|---------+ | | | + | | +-----+ | | | | Wheel + | | / \ /----+----\ / \ /----+----\ | Movement + | | +---------------+ +---------------+ | + Left Button -+ | | | | | | | | | | | | | | | | | | | | +Right Button ---+ +---------------+ +---------------+ Middle Button +(1 if pressed) X movement Y movement (1 if pressed) + + +First three bytes are equal to Mouse mode packet. +Movement values are 8-bit signed twos complement integers. +Positive movement value indicates motion to the right/downward. +Wheel movement is a 4-bit signed twos complement integer. +Positive wheel movement value indicates rotation downward. + + +=========================================================================== +PS/2 standard mode protocol: + + 1st byte 2nd byte 3rd byte + +---------------+ +---------------+ +---------------+ + |?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| + +---------------+ +---------------+ +---------------+ + | | | | | \------+------/ \------+------/ + | | | | | | | + +-|---|-|-|----------|-----------+ | + +---|-|-|--+ | | | + | | | | /-----+-------\ | /---+---------\ +Middle Button ------+ | | +-----------------+ +-----------------+ + Right Button --------+ | | | | | | | | | | | | | | | | | | | | | + Left Button ----------+ +-----------------+ +-----------------+ +(1 if pressed) X movement Y movement + + +Two most significant bits in first byte indicate overflow (more than 9 bits + of movement) in each direction. Usually ignored. +Movement values are 9-bit signed twos complement integers. +Positive movement value indicates motion to the right/upward. + + +=========================================================================== +PS/2 wheel mode protocol: + + 1st byte 2nd byte 3rd byte 4th byte + +---------------+ +---------------+ +---------------+ +---------------+ + |?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| |w|w|w|w|W|W|W|W| + +---------------+ +---------------+ +---------------+ +---------------+ + | | | | | \------+------/ \------+------/ \-------+-----/ + | | | | | | | | + +-|---|-|-|----------|-----------+ | | + +---|-|-|--+ | | | | + | | | | /-----+-------\ | /---+---------\ | +Middle Button ------+ | | +-----------------+ +-----------------+ | + Right Button --------+ | | | | | | | | | | | | | | | | | | | | | | + Left Button ----------+ +-----------------+ +-----------------+ Wheel +(1 if pressed) X movement Y movement Movement + + +First three bytes are equal to PS/2 standard mode packet. +Two most significant bits in first byte indicate overflow (more than 9 bits + of movement) in each direction. Usually ignored. +Movement values are 9-bit signed twos complement integers. +Positive movement value indicates motion to the right/upward. +Wheel movement is a 8-bit signed twos complement integer and usually + limited by -8..+7 range (4-bit value). +Positive wheel movement value indicates rotation downward. + + +=========================================================================== +PS/2 extended mode protocol: + + 1st byte 2nd byte 3rd byte 4th byte + +---------------+ +---------------+ +---------------+ +---------------+ + |?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| |0|0|B|F|W|W|W|W| + +---------------+ +---------------+ +---------------+ +---------------+ + | | | | | \------+------/ \------+------/ | | \--+--/ + | | | | | | | | | | + +-|---|-|-|----------|-----------+ | | | | + +---|-|-|--+ | | | | | Wheel + | | | | /-----+-------\ | /---+---------\ | | Movement +Middle Button ------+ | | +-----------------+ +-----------------+ | | + Right Button --------+ | | | | | | | | | | | | | | | | | | | | | | +- Forward Button + Left Button ----------+ +-----------------+ +-----------------+ +--- Back Button +(1 if pressed) X movement Y movement (1 if pressed) + + +First three bytes are equal to PS/2 standard mode packet. +Two most significant bits in first byte indicate overflow (more than 9 bits + of movement) in each direction. Usually ignored. +Movement values are 9-bit signed twos complement integers. +Positive movement value indicates motion to the right/upward. +Wheel movement is a 4-bit signed twos complement integer. +Positive wheel movement value indicates rotation downward. diff --git a/src/mouse_serial.c b/src/mouse_serial.c index 6a2c9ef34..bb855ecc0 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -150,11 +150,14 @@ mssystems_mouse_poll(int x, int y, int z, int b, void *priv) if (x<-128) x = -128; if (y<-128) y = -128; - data[0] = 0x80 | ((((b & 0x04) >> 1) + ((b & 0x02) << 1) + (b & 0x01)) ^ 0x07); + data[0] = 0x80; + data[0] |= (b & 0x01 ? 0x00 : 0x04); /*Left button*/ + data[0] |= (b & 0x02 ? 0x00 : 0x01); /*Middle button*/ + data[0] |= (b & 0x04 ? 0x00 : 0x02); /*Right button*/ data[1] = x; data[2] = y; - data[3] = 0; - data[4] = 0; + data[3] = x;/*Same as byte 1*/ + data[4] = y;/*Same as byte 2*/ pclog("Mouse_Systems_Serial: data %02X %02X %02X\n", data[0], data[1], data[2]); diff --git a/src/nvr.c b/src/nvr.c index 8862ec08f..eacb4d664 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -18,16 +18,22 @@ * Copyright 2016-2017 Mahod. */ #include +#include +#include +#include #include "ibm.h" +#include "CPU/cpu.h" +#include "device.h" #include "io.h" #include "mem.h" +#include "model.h" #include "nvr.h" #include "pic.h" #include "rom.h" #include "timer.h" #include "rtc.h" -int oldromset; +int oldmodel; int nvrmask=63; char nvrram[128]; int nvraddr; @@ -205,70 +211,36 @@ uint8_t readnvr(uint16_t addr, void *priv) void loadnvr(void) { - FILE *f; + FILE *f = NULL; int c; nvrmask=63; - oldromset=romset; - switch (romset) - { - case ROM_PC1512: f = nvrfopen(L"pc1512.nvr", L"rb"); break; - case ROM_PC1640: f = nvrfopen(L"pc1640.nvr", L"rb"); break; - case ROM_PC200: f = nvrfopen(L"pc200.nvr", L"rb"); break; - case ROM_PC2086: f = nvrfopen(L"pc2086.nvr", L"rb"); break; - case ROM_PC3086: f = nvrfopen(L"pc3086.nvr", L"rb"); break; - case ROM_IBMAT: f = nvrfopen(L"at.nvr", L"rb"); break; - case ROM_IBMPS1_2011: f = nvrfopen(L"ibmps1_2011.nvr", L"rb"); nvrmask = 127; break; - case ROM_IBMPS1_2121: f = nvrfopen(L"ibmps1_2121.nvr", L"rb"); nvrmask = 127; break; - case ROM_IBMPS1_2121_ISA: f = nvrfopen(L"ibmps1_2121_isa.nvr", L"rb"); nvrmask = 127; break; - case ROM_IBMPS2_M30_286: f = nvrfopen(L"ibmps2_m30_286.nvr", L"rb"); nvrmask = 127; break; - case ROM_IBMPS2_M50: f = nvrfopen(L"ibmps2_m50.nvr", L"rb"); break; - case ROM_IBMPS2_M55SX: f = nvrfopen(L"ibmps2_m55sx.nvr", L"rb"); break; - case ROM_IBMPS2_M80: f = nvrfopen(L"ibmps2_m80.nvr", L"rb"); break; - case ROM_CMDPC30: f = nvrfopen(L"cmdpc30.nvr", L"rb"); nvrmask = 127; break; - case ROM_PORTABLEII: f = nvrfopen(L"portableii.nvr", L"rb"); break; - case ROM_PORTABLEIII: f = nvrfopen(L"portableiii.nvr", L"rb"); break; - case ROM_AMI286: f = nvrfopen(L"ami286.nvr", L"rb"); nvrmask = 127; break; - case ROM_AWARD286: f = nvrfopen(L"award286.nvr", L"rb"); nvrmask = 127; break; - case ROM_SUPER286TR: f = nvrfopen(L"super286tr.nvr", L"rb"); nvrmask = 127; break; - case ROM_SPC4200P: f = nvrfopen(L"spc4200p.nvr", L"rb"); nvrmask = 127; break; - case ROM_IBMAT386: f = nvrfopen(L"at386.nvr", L"rb"); nvrmask = 127; break; - case ROM_DESKPRO_386: f = nvrfopen(L"deskpro386.nvr", L"rb"); break; - case ROM_PORTABLEIII386: f = nvrfopen(L"portableiii386.nvr", L"rb"); break; - case ROM_MEGAPC: f = nvrfopen(L"megapc.nvr", L"rb"); nvrmask = 127; break; - case ROM_MEGAPCDX: f = nvrfopen(L"megapcdx.nvr", L"rb"); nvrmask = 127; break; - case ROM_AMI386SX: f = nvrfopen(L"ami386.nvr", L"rb"); nvrmask = 127; break; - case ROM_AMI486: f = nvrfopen(L"ami486.nvr", L"rb"); nvrmask = 127; break; - case ROM_WIN486: f = nvrfopen(L"win486.nvr", L"rb"); nvrmask = 127; break; - case ROM_SIS496: f = nvrfopen(L"sis496.nvr", L"rb"); nvrmask = 127; break; - case ROM_430VX: f = nvrfopen(L"430vx.nvr", L"rb"); nvrmask = 127; break; - case ROM_REVENGE: f = nvrfopen(L"revenge.nvr", L"rb"); nvrmask = 127; break; - case ROM_ENDEAVOR: f = nvrfopen(L"endeavor.nvr", L"rb"); nvrmask = 127; break; - case ROM_DTK386: f = nvrfopen(L"dtk386.nvr", L"rb"); nvrmask = 127; break; - case ROM_MR386DX_OPTI495: f = nvrfopen(L"mr386dx_opti495.nvr", L"rb"); nvrmask = 127; break; - case ROM_AMI386DX_OPTI495: f = nvrfopen(L"ami386dx_opti495.nvr", L"rb"); nvrmask = 127; break; - case ROM_DTK486: f = nvrfopen(L"dtk486.nvr", L"rb"); nvrmask = 127; break; - case ROM_R418: f = nvrfopen(L"r418.nvr", L"rb"); nvrmask = 127; break; - case ROM_586MC1: f = nvrfopen(L"586mc1.nvr", L"rb"); nvrmask = 127; break; - case ROM_PLATO: f = nvrfopen(L"plato.nvr", L"rb"); nvrmask = 127; break; - case ROM_MB500N: f = nvrfopen(L"mb500n.nvr", L"rb"); nvrmask = 127; break; - case ROM_P54TP4XE: f = nvrfopen(L"p54tp4xe.nvr", L"rb"); nvrmask = 127; break; - case ROM_AP53: f = nvrfopen(L"ap53.nvr", L"rb"); nvrmask = 127; break; - case ROM_P55T2S: f = nvrfopen(L"p55t2s.nvr", L"rb"); nvrmask = 127; break; - case ROM_ACERM3A: f = nvrfopen(L"acerm3a.nvr", L"rb"); nvrmask = 127; break; - case ROM_ACERV35N: f = nvrfopen(L"acerv35n.nvr", L"rb"); nvrmask = 127; break; - case ROM_P55VA: f = nvrfopen(L"p55va.nvr", L"rb"); nvrmask = 127; break; - case ROM_P55T2P4: f = nvrfopen(L"p55t2p4.nvr", L"rb"); nvrmask = 127; break; - case ROM_P55TVP4: f = nvrfopen(L"p55tvp4.nvr", L"rb"); nvrmask = 127; break; - case ROM_440FX: f = nvrfopen(L"440fx.nvr", L"rb"); nvrmask = 127; break; - case ROM_THOR: f = nvrfopen(L"thor.nvr", L"rb"); nvrmask = 127; break; - case ROM_MRTHOR: f = nvrfopen(L"mrthor.nvr", L"rb"); nvrmask = 127; break; - case ROM_ZAPPA: f = nvrfopen(L"zappa.nvr", L"rb"); nvrmask = 127; break; - case ROM_S1668: f = nvrfopen(L"tpatx.nvr", L"rb"); nvrmask = 127; break; - case ROM_IBMPS1_2133: f = nvrfopen(L"ibmps1_2133.nvr", L"rb"); nvrmask = 127; break; - default: return; - } - if (!f) + oldmodel = model; + + wchar_t *model_name; + wchar_t *nvr_name; + + model_name = (wchar_t *) malloc((strlen(model_get_internal_name_ex(model)) << 1) + 2); + mbstowcs(model_name, model_get_internal_name_ex(model), strlen(model_get_internal_name_ex(model)) + 1); + nvr_name = (wchar_t *) malloc((wcslen(model_name) << 1) + 2 + 8); + _swprintf(nvr_name, L"%s.nvr", model_name); + + pclog_w(L"Opening NVR file: %s...\n", nvr_name); + + if (model_get_nvrmask(model) != 0) + { + f = nvrfopen(nvr_name, L"rb"); + nvrmask = model_get_nvrmask(model); + } + + free(nvr_name); + free(model_name); + + if (!f || (model_get_nvrmask(model) == 0)) { + if (f) + { + fclose(f); + } memset(nvrram,0xFF,128); if (!enable_sync) { @@ -291,67 +263,38 @@ void loadnvr(void) c = 1 << ((nvrram[RTC_REGA] & RTC_RS) - 1); rtctime += (int)(RTCCONST * c * (1 << TIMER_SHIFT)); } + void savenvr(void) { - FILE *f; - switch (oldromset) - { - case ROM_PC1512: f = nvrfopen(L"pc1512.nvr", L"wb"); break; - case ROM_PC1640: f = nvrfopen(L"pc1640.nvr", L"wb"); break; - case ROM_PC200: f = nvrfopen(L"pc200.nvr", L"wb"); break; - case ROM_PC2086: f = nvrfopen(L"pc2086.nvr", L"wb"); break; - case ROM_PC3086: f = nvrfopen(L"pc3086.nvr", L"wb"); break; - case ROM_IBMAT: f = nvrfopen(L"at.nvr", L"wb"); break; - case ROM_IBMPS1_2011: f = nvrfopen(L"ibmps1_2011.nvr", L"wb"); break; - case ROM_IBMPS1_2121: f = nvrfopen(L"ibmps1_2121.nvr", L"wb"); break; - case ROM_IBMPS1_2121_ISA: f = nvrfopen(L"ibmps1_2121_isa.nvr", L"wb"); break; - case ROM_IBMPS2_M30_286: f = nvrfopen(L"ibmps2_m30_286.nvr", L"wb"); break; - case ROM_IBMPS2_M50: f = nvrfopen(L"ibmps2_m50.nvr", L"wb"); break; - case ROM_IBMPS2_M55SX: f = nvrfopen(L"ibmps2_m55sx.nvr", L"wb"); break; - case ROM_IBMPS2_M80: f = nvrfopen(L"ibmps2_m80.nvr", L"wb"); break; - case ROM_CMDPC30: f = nvrfopen(L"cmdpc30.nvr", L"wb"); break; - case ROM_PORTABLEII: f = nvrfopen(L"portableii.nvr", L"wb"); break; - case ROM_PORTABLEIII: f = nvrfopen(L"portableiii.nvr", L"wb"); break; - case ROM_AMI286: f = nvrfopen(L"ami286.nvr", L"wb"); break; - case ROM_AWARD286: f = nvrfopen(L"award286.nvr", L"wb"); break; - case ROM_SUPER286TR: f = nvrfopen(L"super286tr.nvr", L"wb"); break; - case ROM_SPC4200P: f = nvrfopen(L"spc4200p.nvr", L"wb"); break; - case ROM_IBMAT386: f = nvrfopen(L"at386.nvr", L"wb"); break; - case ROM_DESKPRO_386: f = nvrfopen(L"deskpro386.nvr", L"wb"); break; - case ROM_PORTABLEIII386: f = nvrfopen(L"portableiii386.nvr", L"wb"); break; - case ROM_MEGAPC: f = nvrfopen(L"megapc.nvr", L"wb"); break; - case ROM_MEGAPCDX: f = nvrfopen(L"megapcdx.nvr", L"wb"); break; - case ROM_AMI386SX: f = nvrfopen(L"ami386.nvr", L"wb"); break; - case ROM_AMI486: f = nvrfopen(L"ami486.nvr", L"wb"); break; - case ROM_WIN486: f = nvrfopen(L"win486.nvr", L"wb"); break; - case ROM_SIS496: f = nvrfopen(L"sis496.nvr", L"wb"); break; - case ROM_430VX: f = nvrfopen(L"430vx.nvr", L"wb"); break; - case ROM_REVENGE: f = nvrfopen(L"revenge.nvr", L"wb"); break; - case ROM_ENDEAVOR: f = nvrfopen(L"endeavor.nvr", L"wb"); break; - case ROM_DTK386: f = nvrfopen(L"dtk386.nvr", L"wb"); break; - case ROM_MR386DX_OPTI495: f = nvrfopen(L"mr386dx_opti495.nvr", L"wb"); break; - case ROM_AMI386DX_OPTI495: f = nvrfopen(L"ami386dx_opti495.nvr", L"wb"); break; - case ROM_DTK486: f = nvrfopen(L"dtk486.nvr", L"wb"); break; - case ROM_R418: f = nvrfopen(L"r418.nvr", L"wb"); break; - case ROM_586MC1: f = nvrfopen(L"586mc1.nvr", L"wb"); break; - case ROM_PLATO: f = nvrfopen(L"plato.nvr", L"wb"); break; - case ROM_MB500N: f = nvrfopen(L"mb500n.nvr", L"wb"); break; - case ROM_P54TP4XE: f = nvrfopen(L"p54tp4xe.nvr", L"wb"); break; - case ROM_AP53: f = nvrfopen(L"ap53.nvr", L"wb"); break; - case ROM_P55T2S: f = nvrfopen(L"p55t2s.nvr", L"wb"); break; - case ROM_ACERM3A: f = nvrfopen(L"acerm3a.nvr", L"wb"); break; - case ROM_ACERV35N: f = nvrfopen(L"acerv35n.nvr", L"wb"); break; - case ROM_P55VA: f = nvrfopen(L"p55va.nvr", L"wb"); break; - case ROM_P55T2P4: f = nvrfopen(L"p55t2p4.nvr", L"wb"); break; - case ROM_P55TVP4: f = nvrfopen(L"p55tvp4.nvr", L"wb"); break; - case ROM_440FX: f = nvrfopen(L"440fx.nvr", L"wb"); break; - case ROM_THOR: f = nvrfopen(L"thor.nvr", L"wb"); break; - case ROM_MRTHOR: f = nvrfopen(L"mrthor.nvr", L"wb"); break; - case ROM_ZAPPA: f = nvrfopen(L"zappa.nvr", L"wb"); break; - case ROM_S1668: f = nvrfopen(L"tpatx.nvr", L"wb"); break; - case ROM_IBMPS1_2133: f = nvrfopen(L"ibmps1_2133.nvr", L"wb"); break; - default: return; - } + FILE *f = NULL; + + wchar_t *model_name; + wchar_t *nvr_name; + + model_name = (wchar_t *) malloc((strlen(model_get_internal_name_ex(oldmodel)) << 1) + 2); + mbstowcs(model_name, model_get_internal_name_ex(oldmodel), strlen(model_get_internal_name_ex(oldmodel)) + 1); + nvr_name = (wchar_t *) malloc((wcslen(model_name) << 1) + 2 + 8); + _swprintf(nvr_name, L"%s.nvr", model_name); + + pclog_w(L"Saving NVR file: %s...\n", nvr_name); + + if (model_get_nvrmask(oldmodel) != 0) + { + f = nvrfopen(nvr_name, L"wb"); + } + + free(nvr_name); + free(model_name); + + if (!f || (model_get_nvrmask(oldmodel) == 0)) + { + if (f) + { + fclose(f); + } + return; + } + fwrite(nvrram,128,1,f); fclose(f); } diff --git a/src/pc.c b/src/pc.c index f60a03a3e..8ced5b20b 100644 --- a/src/pc.c +++ b/src/pc.c @@ -59,7 +59,7 @@ #include "model.h" #include "mouse.h" #include "plat_mouse.h" -#include "network.h" +#include "network/network.h" #include "serial.h" #include "sound/sound.h" #include "sound/snd_cms.h" diff --git a/src/scsi.c b/src/scsi.c index 4a2ce29fb..186a2495a 100644 --- a/src/scsi.c +++ b/src/scsi.c @@ -1,7 +1,21 @@ -/* Copyright holders: SA1988, Tenshi - see COPYING for more details -*/ -/*SCSI layer emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Handling of the SCSI controllers. + * + * NOTE: THIS IS CURRENTLY A MESS, but will be cleaned up as I go. + * + * Version: @(#)scsi.c 1.0.0 2017/06/14 + * + * Authors: Fred N. van Kempen, + * Original Buslogic version by SA1988 and Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ #include #include #include "86box.h" @@ -28,17 +42,18 @@ typedef struct { char name[64]; char internal_name[32]; device_t *device; + void (*reset)(void *p); } SCSI_CARD; static SCSI_CARD scsi_cards[] = { - { "None", "none", NULL }, - { "Adaptec AHA-1540B", "aha1540b", &aha1540b_device }, - { "Adaptec AHA-1542CF", "aha1542cf", &aha1542cf_device }, - { "Adaptec AHA-1640", "aha1640", &aha1640_device }, - { "BusLogic BT-542B", "bt542b", &buslogic_device }, - { "BusLogic BT-958D PCI", "bt958d", &buslogic_pci_device }, - { "", "", NULL } + { "None", "none", NULL, NULL }, + { "Adaptec AHA-1540B", "aha1540b", &aha1540b_device, aha_device_reset }, + { "Adaptec AHA-1542CF", "aha1542cf", &aha1542cf_device, aha_device_reset }, + { "Adaptec AHA-1640", "aha1640", &aha1640_device, aha_device_reset }, + { "BusLogic BT-542B", "bt542b", &buslogic_device, BuslogicDeviceReset }, + { "BusLogic BT-958D PCI", "bt958d", &buslogic_pci_device, BuslogicDeviceReset }, + { "", "", NULL, NULL }, }; @@ -100,6 +115,24 @@ void scsi_card_init() } +void scsi_card_reset(void) +{ + void *p = NULL; + + if (scsi_cards[scsi_card_current].device) + { + p = device_get_priv(scsi_cards[scsi_card_current].device); + if (p) + { + if (scsi_cards[scsi_card_current].reset) + { + scsi_cards[scsi_card_current].reset(p); + } + } + } +} + + /* Initialization function for the SCSI layer */ void SCSIReset(uint8_t id, uint8_t lun) { diff --git a/src/scsi.h b/src/scsi.h index 8c3efc3b5..d0e4bfb91 100644 --- a/src/scsi.h +++ b/src/scsi.h @@ -260,6 +260,7 @@ int scsi_card_has_config(int card); char *scsi_card_get_internal_name(int card); int scsi_card_get_from_internal_name(char *s); void scsi_card_init(); +void scsi_card_reset(void); extern uint8_t scsi_hard_disks[16][8]; diff --git a/src/scsi_aha154x.c b/src/scsi_aha154x.c index 72f615843..f37838cf1 100644 --- a/src/scsi_aha154x.c +++ b/src/scsi_aha154x.c @@ -12,7 +12,7 @@ * * NOTE: THIS IS CURRENTLY A MESS, but will be cleaned up as I go. * - * Version: @(#)scsi_aha154x.c 1.0.6 2017/05/06 + * Version: @(#)scsi_aha154x.c 1.0.7 2017/06/14 * * Authors: Fred N. van Kempen, * Original Buslogic version by SA1988 and Miran Grca. @@ -179,6 +179,32 @@ static uint16_t aha_ports[] = { 0x0130, 0x0134, 0x0000, 0x0000 }; + +#ifdef WALTJE +int aha_do_log = 1; +# define ENABLE_AHA154X_LOG +#else +int aha_do_log = 0; +#endif + + +static void +aha_log(const char *format, ...) +{ +#ifdef ENABLE_AHA154X_LOG + va_list ap; + + if (aha_do_log) { + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + fflush(stdout); + } +#endif +} +#define pclog aha_log + + /* * Write data to the BIOS space. * @@ -839,31 +865,6 @@ enum { }; -#ifdef WALTJE -int aha_do_log = 1; -# define ENABLE_AHA154X_LOG -#else -int aha_do_log = 0; -#endif - - -static void -aha_log(const char *format, ...) -{ -#ifdef ENABLE_AHA154X_LOG - va_list ap; - - if (aha_do_log) { - va_start(ap, format); - vprintf(format, ap); - va_end(ap); - fflush(stdout); - } -#endif -} -#define pclog aha_log - - static void ClearIntr(aha_t *dev) { @@ -2168,6 +2169,14 @@ void aha_mca_write(int port, uint8_t val, void *p) } +void +aha_device_reset(void *p) +{ + aha_t *dev = (aha_t *) p; + aha_reset_ctrl(dev, 1); +} + + static void * aha_init(int chip, int has_bios) { diff --git a/src/scsi_aha154x.h b/src/scsi_aha154x.h index 0e7db0d0d..d15de7c2d 100644 --- a/src/scsi_aha154x.h +++ b/src/scsi_aha154x.h @@ -13,6 +13,8 @@ typedef struct { extern device_t aha1540b_device; extern device_t aha1542cf_device; extern device_t aha1640_device; + +extern void aha_device_reset(void *p); #endif /*SCSI_AHA154X_H*/ diff --git a/src/scsi_buslogic.c b/src/scsi_buslogic.c index d5113e000..1b4c8794d 100644 --- a/src/scsi_buslogic.c +++ b/src/scsi_buslogic.c @@ -10,7 +10,7 @@ * 0 - BT-542B ISA; * 1 - BT-958 PCI (but BT-542B ISA on non-PCI machines) * - * Version: @(#)scsi_buslogic.c 1.0.3 2017/06/03 + * Version: @(#)scsi_buslogic.c 1.0.4 2017/06/14 * * Authors: TheCollector1995, * Miran Grca, @@ -2226,6 +2226,14 @@ BuslogicPCIWrite(int func, int addr, uint8_t val, void *p) } +void +BuslogicDeviceReset(void *p) +{ + Buslogic_t *dev = (Buslogic_t *) p; + BuslogicResetControl(dev, 1); +} + + static void * BuslogicInit(int chip) { diff --git a/src/scsi_buslogic.h b/src/scsi_buslogic.h index c952e06d1..e835ea989 100644 --- a/src/scsi_buslogic.h +++ b/src/scsi_buslogic.h @@ -23,6 +23,8 @@ extern device_t buslogic_device; extern device_t buslogic_pci_device; + +extern void BuslogicDeviceReset(void *p); #endif /*SCSI_BUSLOGIC_H*/ diff --git a/src/slirp/Makefile b/src/slirp/Makefile deleted file mode 100644 index 275c054d2..000000000 --- a/src/slirp/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CC=gcc -CFLAGS=-I. -O2 -Wall -DEPS = bootp.h config-host.h config.h ctl.h \ - debug.h icmp_var.h if.h ip.h \ - ip_icmp.h libslirp.h main.h mbuf.h \ - misc.h queue.h sbuf.h slirp.h \ - slirp_config.h socket.h tcp.h tcpip.h \ - tcp_timer.h tcp_var.h tftp.h udp.h - -OBJ = bootp.o cksum.o debug.o if.o ip_icmp.o \ - ip_input.o ip_output.o mbuf.o misc.o queue.o \ - sbuf.o slirp.o socket.o tcp_input.o tcp_output.o \ - tcp_subr.o tcp_timer.o tftp.o udp.o - -%.o: %.c $(DEPS) - $(CC) $(CFLAGS) -c $< -o $@ - -default: libslirp.a - -clean: - rm -f $(OBJ) - rm -f libslirp.a - -libslirp.a: $(OBJ) - ar rcs $@ $^ - ranlib $@ \ No newline at end of file diff --git a/src/um8669f.c b/src/um8669f.c deleted file mode 100644 index 964f2613a..000000000 --- a/src/um8669f.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Emulation of the UMC UM8669F Super I/O Chip. - * - * Version: @(#)um8669f.c 1.0.0 2017/05/30 - * - * Author: Sarah Walker, - * Miran Grca, - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016-2017 Miran Grca. - */ - -/*um8669f : - - aa to 108 unlocks - next 108 write is register select (Cx?) - data read/write to 109 - 55 to 108 locks - - - - -C0 -bit 3 = LPT1 enable -bit 2 = COM2 enable -bit 1 = COM1 enable -bit 0 = FDC enable - -C1 -bits 7-6 = LPT1 mode : 11 = ECP/EPP, 01 = EPP, 10 = SPP -bit 3 = clear when LPT1 = 278 - -Added by OBattler based on more sources: - C2 - bit 2 = I430FX: floppy drive swap (1 = swap, 0 = do not swap) - I430VX: DENSEL polarity - bits 3-6 = IR stuff - bits 3-4 = 00 = Normal, 01 = Infrared (HPSIR), 10 - Amplitude Shift Keyed IR (ASKIR), 11 - Reserved - -C3 -bits 7-6 = LPT1 DMA mode : 11 = ECP/EPP DMA1, 10 = ECP/EPP DMA3, 01 = EPP/SPP, 00 = ECP -bits 5-4 = LPT1 addr : 10 = 278/IRQ5, 01 = 3BC/IRQ7, 00 = 378/IRQ7 - -COM1 : -3f8, IRQ4 - C1 = BF, C3 = 00 -2f8, IRQ3 - C1 = BF, C3 = 03 -3e8, IRQ4 - C1 = BD, C3 = 00 -2e8, IRQ3 - B1 = BD, C3 = 03 - -COM2 : -3f8, IRQ4 - C1 = BF, C3 = 0C -2f8, IRQ3 - C1 = BF, C3 = 00 -3e8, IRQ4 - C1 = BB, C3 = 0C -2e8, IRQ3 - C1 = BB, C3 = 00 - - */ - -#include "ibm.h" - -#include "disc.h" -#include "fdc.h" -#include "fdd.h" -#include "io.h" -#include "lpt.h" -#include "serial.h" -#include "um8669f.h" - -static int um8669f_locked; -static int um8669f_curreg; -static uint8_t um8669f_regs[256]; - -void um8669f_write(uint16_t port, uint8_t val, void *priv) -{ - int temp; - if (um8669f_locked) - { - if (port == 0x108 && val == 0xaa) - um8669f_locked = 0; - } - else - { - if (port == 0x108) - { - if (val == 0x55) - um8669f_locked = 1; - else - um8669f_curreg = val; - } - else - { - um8669f_regs[um8669f_curreg] = val; - - fdc_remove(); - if (um8669f_regs[0xc0] & 1) - fdc_add(); - - if (um8669f_regs[0xc0] & 2) - { - temp = um8669f_regs[0xc3] & 1; /*might be & 2*/ - if (!(um8669f_regs[0xc1] & 2)) - temp |= 2; - switch (temp) - { - case 0: serial_setup(1, 0x3f8, 4); break; - case 1: serial_setup(1, 0x2f8, 4); break; - case 2: serial_setup(1, 0x3e8, 4); break; - case 3: serial_setup(1, 0x2e8, 4); break; - } - } - - if (um8669f_regs[0xc0] & 4) - { - temp = (um8669f_regs[0xc3] & 4) ? 0 : 1; /*might be & 8*/ - if (!(um8669f_regs[0xc1] & 4)) - temp |= 2; - switch (temp) - { - case 0: serial_setup(2, 0x3f8, 3); break; - case 1: serial_setup(2, 0x2f8, 3); break; - case 2: serial_setup(2, 0x3e8, 3); break; - case 3: serial_setup(2, 0x2e8, 3); break; - } - } - - if (um8669f_curreg == 0xC2) - { - /* Make sure to invert this. */ - if (romset == ROM_430VX) - { - fdc_update_densel_polarity(val & 4 ? 0 : 1); - } - else - { - fdd_setswap(val & 4 ? 1 : 0); - } - } - - lpt1_remove(); - lpt2_remove(); - temp = (um8669f_regs[0xc3] >> 4) & 3; - switch (temp) - { - case 0: lpt1_init(0x378); break; - case 1: lpt1_init(0x3bc); break; - case 2: lpt1_init(0x278); break; - } - } - } -} - -uint8_t um8669f_read(uint16_t port, void *priv) -{ - if (um8669f_locked) - return 0xff; - - if (port == 0x108) - return um8669f_curreg; /*???*/ - else - return um8669f_regs[um8669f_curreg]; -} - -void um8669f_init() -{ - io_sethandler(0x0108, 0x0002, um8669f_read, NULL, NULL, um8669f_write, NULL, NULL, NULL); - um8669f_locked = 1; -} diff --git a/src/um8669f.h b/src/um8669f.h deleted file mode 100644 index 92052a151..000000000 --- a/src/um8669f.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Emulation of the UMC UM8669F Super I/O Chip. - * - * Version: @(#)um8669f.h 1.0.0 2017/05/30 - * - * Author: Sarah Walker, - * Miran Grca, - * Copyright 2008-2017 Sarah Walker. - * Copyright 2016-2017 Miran Grca. - */ - -extern void um8669f_init(); diff --git a/src/um8881f.c b/src/um8881f.c deleted file mode 100644 index c39c21b11..000000000 --- a/src/um8881f.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include "ibm.h" -#include "io.h" -#include "mem.h" -#include "pci.h" - -#include "um8881f.h" - -static uint8_t card_16[256]; -static uint8_t card_18[256]; - -void um8881f_write(int func, int addr, uint8_t val, void *priv) -{ -// pclog("um8881f_write : addr=%02x val=%02x %04x:%04x\n", addr, val, CS, pc); - if (addr == 0x54) - { -/* if ((card_16[0x54] ^ val) & 0x01) - { - if (val & 1) - mem_bios_set_state(0xe0000, 0x10000, 1, 1); - else - mem_bios_set_state(0xe0000, 0x10000, 0, 0); - }*/ - flushmmucache_nopc(); - } - if (addr == 0x55) - { - if ((card_16[0x55] ^ val) & 0xc0) - { -/* switch (val & 0xc0) - { - case 0x00: mem_bios_set_state(0xf0000, 0x10000, 0, 1); break; - case 0x40: mem_bios_set_state(0xf0000, 0x10000, 0, 0); break; - case 0x80: mem_bios_set_state(0xf0000, 0x10000, 1, 1); break; - case 0xc0: mem_bios_set_state(0xf0000, 0x10000, 1, 0); break; - }*/ - shadowbios = val & 0x80; - shadowbios_write = !(val & 0x40); - flushmmucache_nopc(); - } - } - if (addr >= 4) - card_16[addr] = val; -} - -uint8_t um8881f_read(int func, int addr, void *priv) -{ - return card_16[addr]; -} - -void um8886f_write(int func, int addr, uint8_t val, void *priv) -{ - if (addr >= 4) - card_18[addr] = val; -} - -uint8_t um8886f_read(int func, int addr, void *priv) -{ - return card_18[addr]; -} - -void um8881f_init() -{ - pci_add_specific(16, um8881f_read, um8881f_write, NULL); - pci_add_specific(18, um8886f_read, um8886f_write, NULL); - - card_16[0] = card_18[0] = 0x60; /*UMC*/ - card_16[1] = card_18[1] = 0x10; - card_16[2] = 0x81; card_16[3] = 0x88; /*UM8881 Host - PCI bridge*/ - card_18[2] = 0x86; card_18[3] = 0x88; /*UM8886 PCI - ISA bridge*/ -} diff --git a/src/um8881f.h b/src/um8881f.h deleted file mode 100644 index 4ee34640d..000000000 --- a/src/um8881f.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -void um8881f_init();