Merge branch 'master' into experimental

This commit is contained in:
Melissa Goad
2017-06-14 13:49:30 -05:00
111 changed files with 1992 additions and 1280 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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];
}
}

View File

@@ -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, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
@@ -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 \

View File

@@ -1,4 +1,4 @@
/* Copyright holders: Sarah Walker
/* Copyright holders: neozeed
see COPYING for more details
*/
#ifndef BSWAP_H

View File

@@ -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, <decwiz@yahoo.com>
* Peter Grehan, grehan@iprg.nokia.com>
@@ -24,15 +24,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.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 "../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"

View File

@@ -17,12 +17,12 @@
#include <stdlib.h>
#include <string.h>
#include <pcap.h>
#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 */

View File

@@ -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, <decwiz@yahoo.com>
*/
@@ -18,11 +18,11 @@
#include <string.h>
#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 */

View File

@@ -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, <decwiz@yahoo.com>
*/
@@ -20,12 +20,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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[] = {

View File

@@ -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)

View File

@@ -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
}

View File

@@ -1,4 +1,4 @@
/* Copyright holders: The DOSBox Team, SA1988
/* Copyright holders: Sarah Walker, SA1988
see COPYING for more details
*/
#include "dbopl.h"

View File

@@ -1,4 +1,4 @@
/* Copyright holders: The DOSBox Team, SA1988
/* Copyright holders: Sarah Walker, SA1988
see COPYING for more details
*/
#ifdef __cplusplus

View File

@@ -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);

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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)
{

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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);

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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
{

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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) */

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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;

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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);

View File

@@ -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;

View File

@@ -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);

File diff suppressed because it is too large Load Diff

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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)

View File

@@ -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));

View File

@@ -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));

View File

@@ -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);

View File

@@ -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;

View File

@@ -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, <mgrca8@gmail.com>
* 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;
}

View File

@@ -1856,7 +1856,7 @@ int cdrom_read_blocks(uint8_t id, uint32_t *len, int first_batch)
}
else
{
type = 2;
type = 8;
flags = 0x10;
}

View File

@@ -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);

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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 */

View File

@@ -18,8 +18,10 @@
#include <stdlib.h>
#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);

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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*/

207
src/mouse_prot.txt Normal file
View File

@@ -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.

View File

@@ -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]);

185
src/nvr.c
View File

@@ -18,16 +18,22 @@
* Copyright 2016-2017 Mahod.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#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);
}

View File

@@ -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"

Some files were not shown because too many files have changed in this diff Show More