mirror of
https://github.com/86Box/86Box.git
synced 2026-02-24 02:18:20 -07:00
Merge branch 'master' into experimental
This commit is contained in:
@@ -311,7 +311,8 @@ static __inline void addbyte(uint8_t val)
|
||||
|
||||
static __inline void addword(uint16_t val)
|
||||
{
|
||||
*(uint16_t *)&codeblock[block_current].data[block_pos] = val;
|
||||
uint16_t *p = (uint16_t *)&codeblock[block_current].data[block_pos];
|
||||
*p = val;
|
||||
block_pos += 2;
|
||||
if (block_pos >= BLOCK_MAX)
|
||||
{
|
||||
@@ -321,7 +322,8 @@ static __inline void addword(uint16_t val)
|
||||
|
||||
static __inline void addlong(uint32_t val)
|
||||
{
|
||||
*(uint32_t *)&codeblock[block_current].data[block_pos] = val;
|
||||
uint32_t *p = (uint32_t *)&codeblock[block_current].data[block_pos];
|
||||
*p = val;
|
||||
block_pos += 4;
|
||||
if (block_pos >= BLOCK_MAX)
|
||||
{
|
||||
@@ -331,7 +333,8 @@ static __inline void addlong(uint32_t val)
|
||||
|
||||
static __inline void addquad(uint64_t val)
|
||||
{
|
||||
*(uint64_t *)&codeblock[block_current].data[block_pos] = val;
|
||||
uint64_t *p = (uint64_t *)&codeblock[block_current].data[block_pos];
|
||||
*p = val;
|
||||
block_pos += 8;
|
||||
if (block_pos >= BLOCK_MAX)
|
||||
{
|
||||
|
||||
@@ -2,15 +2,15 @@ static uint32_t ropINC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
{
|
||||
int host_reg;
|
||||
|
||||
CALL_FUNC((void *) flags_rebuild_c);
|
||||
CALL_FUNC((uintptr_t)flags_rebuild_c);
|
||||
|
||||
host_reg = LOAD_REG_W(opcode & 7);
|
||||
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_W(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_W_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -21,15 +21,15 @@ static uint32_t ropINC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
{
|
||||
int host_reg;
|
||||
|
||||
CALL_FUNC((void *) flags_rebuild_c);
|
||||
CALL_FUNC((uintptr_t)flags_rebuild_c);
|
||||
|
||||
host_reg = LOAD_REG_L(opcode & 7);
|
||||
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_L_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -40,15 +40,15 @@ static uint32_t ropDEC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
{
|
||||
int host_reg;
|
||||
|
||||
CALL_FUNC((void *) flags_rebuild_c);
|
||||
CALL_FUNC((uintptr_t)flags_rebuild_c);
|
||||
|
||||
host_reg = LOAD_REG_W(opcode & 7);
|
||||
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_W(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_W_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -59,15 +59,15 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
{
|
||||
int host_reg;
|
||||
|
||||
CALL_FUNC((void *) flags_rebuild_c);
|
||||
CALL_FUNC((uintptr_t)flags_rebuild_c);
|
||||
|
||||
host_reg = LOAD_REG_L(opcode & 7);
|
||||
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_L_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -93,12 +93,12 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
MEM_CHECK_WRITE(target_seg); \
|
||||
dst_reg = MEM_LOAD_ADDR_EA_B_NO_ABRT(target_seg); \
|
||||
} \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \
|
||||
src_reg = LOAD_REG_B((fetchdat >> 3) & 7); \
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg); \
|
||||
op ## _HOST_REG_B(dst_reg, src_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg); \
|
||||
if (writeback) \
|
||||
{ \
|
||||
if ((fetchdat & 0xc0) == 0xc0) \
|
||||
@@ -133,12 +133,12 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
MEM_CHECK_WRITE_W(target_seg); \
|
||||
dst_reg = MEM_LOAD_ADDR_EA_W_NO_ABRT(target_seg); \
|
||||
} \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \
|
||||
src_reg = LOAD_REG_W((fetchdat >> 3) & 7); \
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg); \
|
||||
op ## _HOST_REG_W(dst_reg, src_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg); \
|
||||
if (writeback) \
|
||||
{ \
|
||||
if ((fetchdat & 0xc0) == 0xc0) \
|
||||
@@ -173,12 +173,12 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
MEM_CHECK_WRITE_L(target_seg); \
|
||||
dst_reg = MEM_LOAD_ADDR_EA_L_NO_ABRT(target_seg); \
|
||||
} \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \
|
||||
src_reg = LOAD_REG_L((fetchdat >> 3) & 7); \
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg); \
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg); \
|
||||
op ## _HOST_REG_L(dst_reg, src_reg); \
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg); \
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg); \
|
||||
if (writeback) \
|
||||
{ \
|
||||
if ((fetchdat & 0xc0) == 0xc0) \
|
||||
@@ -215,11 +215,11 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
} \
|
||||
\
|
||||
dst_reg = LOAD_REG_B((fetchdat >> 3) & 7); \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 8); \
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg); \
|
||||
op ## _HOST_REG_B(dst_reg, src_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg); \
|
||||
if (writeback) STORE_REG_B_RELEASE(dst_reg); \
|
||||
else RELEASE_REG(dst_reg); \
|
||||
RELEASE_REG(src_reg); \
|
||||
@@ -244,11 +244,11 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
} \
|
||||
\
|
||||
dst_reg = LOAD_REG_W((fetchdat >> 3) & 7); \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 16); \
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg); \
|
||||
op ## _HOST_REG_W(dst_reg, src_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg); \
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg); \
|
||||
if (writeback) STORE_REG_W_RELEASE(dst_reg); \
|
||||
else RELEASE_REG(dst_reg); \
|
||||
RELEASE_REG(src_reg); \
|
||||
@@ -273,11 +273,11 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
} \
|
||||
\
|
||||
dst_reg = LOAD_REG_L((fetchdat >> 3) & 7); \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ ## op ## 32); \
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg); \
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg); \
|
||||
op ## _HOST_REG_L(dst_reg, src_reg); \
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg); \
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg); \
|
||||
if (writeback) STORE_REG_L_RELEASE(dst_reg); \
|
||||
else RELEASE_REG(dst_reg); \
|
||||
RELEASE_REG(src_reg); \
|
||||
@@ -308,11 +308,11 @@ static uint32_t ropCMP_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u
|
||||
}
|
||||
|
||||
dst_reg = LOAD_REG_B((fetchdat >> 3) & 7);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg);
|
||||
dst_reg = CMP_HOST_REG_B(dst_reg, src_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg);
|
||||
RELEASE_REG(dst_reg);
|
||||
RELEASE_REG(src_reg);
|
||||
|
||||
@@ -336,11 +336,11 @@ static uint32_t ropCMP_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u
|
||||
}
|
||||
|
||||
dst_reg = LOAD_REG_W((fetchdat >> 3) & 7);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg);
|
||||
dst_reg = CMP_HOST_REG_W(dst_reg, src_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg);
|
||||
RELEASE_REG(dst_reg);
|
||||
RELEASE_REG(src_reg);
|
||||
|
||||
@@ -364,11 +364,11 @@ static uint32_t ropCMP_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u
|
||||
}
|
||||
|
||||
dst_reg = LOAD_REG_L((fetchdat >> 3) & 7);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg);
|
||||
dst_reg = CMP_HOST_REG_L(dst_reg, src_reg);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg);
|
||||
RELEASE_REG(dst_reg);
|
||||
RELEASE_REG(src_reg);
|
||||
|
||||
@@ -392,12 +392,12 @@ static uint32_t ropCMP_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
dst_reg = 0;
|
||||
}
|
||||
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
src_reg = LOAD_REG_B((fetchdat >> 3) & 7);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, dst_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, dst_reg);
|
||||
dst_reg = CMP_HOST_REG_B(dst_reg, src_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, dst_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, dst_reg);
|
||||
RELEASE_REG(dst_reg);
|
||||
RELEASE_REG(src_reg);
|
||||
|
||||
@@ -420,12 +420,12 @@ static uint32_t ropCMP_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
dst_reg = 0;
|
||||
} \
|
||||
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
src_reg = LOAD_REG_W((fetchdat >> 3) & 7);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, dst_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, dst_reg);
|
||||
dst_reg = CMP_HOST_REG_W(dst_reg, src_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, dst_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, dst_reg);
|
||||
RELEASE_REG(dst_reg);
|
||||
RELEASE_REG(src_reg);
|
||||
|
||||
@@ -448,12 +448,12 @@ static uint32_t ropCMP_l_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
dst_reg = 0;
|
||||
}
|
||||
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
src_reg = LOAD_REG_L((fetchdat >> 3) & 7);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, dst_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, dst_reg);
|
||||
dst_reg = CMP_HOST_REG_L(dst_reg, src_reg);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, dst_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op2, src_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, dst_reg);
|
||||
RELEASE_REG(dst_reg);
|
||||
RELEASE_REG(src_reg);
|
||||
|
||||
@@ -466,11 +466,11 @@ static uint32_t ropADD_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
{
|
||||
int host_reg = LOAD_REG_B(REG_AL);
|
||||
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_B(host_reg, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD8);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD8);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_B_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -480,11 +480,11 @@ static uint32_t ropADD_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
{
|
||||
int host_reg = LOAD_REG_W(REG_AX);
|
||||
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_W_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -494,12 +494,12 @@ static uint32_t ropADD_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32
|
||||
{
|
||||
int host_reg = LOAD_REG_L(REG_EAX);
|
||||
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
fetchdat = fastreadl(cs + op_pc);
|
||||
ADD_HOST_REG_IMM(host_reg, fetchdat);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_L_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -510,11 +510,11 @@ static uint32_t ropCMP_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
{
|
||||
int host_reg = LOAD_REG_B(REG_AL);
|
||||
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
host_reg = CMP_HOST_REG_IMM_B(host_reg, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
RELEASE_REG(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -524,11 +524,11 @@ static uint32_t ropCMP_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
{
|
||||
int host_reg = LOAD_REG_W(REG_AX);
|
||||
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
host_reg = CMP_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
RELEASE_REG(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -538,12 +538,12 @@ static uint32_t ropCMP_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32
|
||||
{
|
||||
int host_reg = LOAD_REG_L(REG_EAX);
|
||||
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
fetchdat = fastreadl(cs + op_pc);
|
||||
host_reg = CMP_HOST_REG_IMM_L(host_reg, fetchdat);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
RELEASE_REG(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -554,11 +554,11 @@ static uint32_t ropSUB_AL_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
{
|
||||
int host_reg = LOAD_REG_B(REG_AL);
|
||||
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_B(host_reg, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xff);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_B_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -568,11 +568,11 @@ static uint32_t ropSUB_AX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
{
|
||||
int host_reg = LOAD_REG_W(REG_AX);
|
||||
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_W(host_reg, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat & 0xffff);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_W_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -582,12 +582,12 @@ static uint32_t ropSUB_EAX_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32
|
||||
{
|
||||
int host_reg = LOAD_REG_L(REG_EAX);
|
||||
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
fetchdat = fastreadl(cs + op_pc);
|
||||
SUB_HOST_REG_IMM(host_reg, fetchdat);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, fetchdat);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, fetchdat);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_REG_L_RELEASE(host_reg);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
@@ -598,7 +598,7 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_
|
||||
{
|
||||
int host_reg;
|
||||
uint32_t imm;
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x10)
|
||||
return 0;
|
||||
@@ -629,38 +629,38 @@ static uint32_t rop80(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_B(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD8);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD8);
|
||||
break;
|
||||
case 0x08: /*OR*/
|
||||
OR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN8);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8);
|
||||
break;
|
||||
case 0x20: /*AND*/
|
||||
AND_HOST_REG_IMM(host_reg, imm | 0xffffff00);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN8);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8);
|
||||
break;
|
||||
case 0x28: /*SUB*/
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_B(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
break;
|
||||
case 0x30: /*XOR*/
|
||||
XOR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN8);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN8);
|
||||
break;
|
||||
case 0x38: /*CMP*/
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
host_reg = CMP_HOST_REG_IMM_B(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB8);
|
||||
break;
|
||||
}
|
||||
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0x38) != 0x38)
|
||||
{
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
@@ -684,7 +684,7 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
{
|
||||
int host_reg;
|
||||
uint32_t imm;
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x10)
|
||||
return 0;
|
||||
@@ -715,38 +715,38 @@ static uint32_t rop81_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_W(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD16);
|
||||
break;
|
||||
case 0x08: /*OR*/
|
||||
OR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
case 0x20: /*AND*/
|
||||
AND_HOST_REG_IMM(host_reg, imm | 0xffff0000);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
case 0x28: /*SUB*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_W(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
break;
|
||||
case 0x30: /*XOR*/
|
||||
XOR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
case 0x38: /*CMP*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
host_reg = CMP_HOST_REG_IMM_W(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
break;
|
||||
}
|
||||
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0x38) != 0x38)
|
||||
{
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
@@ -769,7 +769,7 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
{
|
||||
int host_reg;
|
||||
uint32_t imm;
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x10)
|
||||
return 0;
|
||||
@@ -799,38 +799,38 @@ static uint32_t rop81_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD32);
|
||||
break;
|
||||
case 0x08: /*OR*/
|
||||
OR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
case 0x20: /*AND*/
|
||||
AND_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
case 0x28: /*SUB*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
break;
|
||||
case 0x30: /*XOR*/
|
||||
XOR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
case 0x38: /*CMP*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
host_reg = CMP_HOST_REG_IMM_L(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
break;
|
||||
}
|
||||
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0x38) != 0x38)
|
||||
{
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
@@ -854,7 +854,7 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
{
|
||||
int host_reg;
|
||||
uint32_t imm;
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x10)
|
||||
return 0;
|
||||
@@ -888,38 +888,38 @@ static uint32_t rop83_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_W(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD16);
|
||||
break;
|
||||
case 0x08: /*OR*/
|
||||
OR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
case 0x20: /*AND*/
|
||||
AND_HOST_REG_IMM(host_reg, imm | 0xffff0000);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
case 0x28: /*SUB*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_W(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
break;
|
||||
case 0x30: /*XOR*/
|
||||
XOR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
case 0x38: /*CMP*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
host_reg = CMP_HOST_REG_IMM_W(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB16);
|
||||
break;
|
||||
}
|
||||
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0x38) != 0x38)
|
||||
{
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
@@ -942,7 +942,7 @@ static uint32_t rop83_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
{
|
||||
int host_reg;
|
||||
uint32_t imm;
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x10)
|
||||
return 0;
|
||||
@@ -976,38 +976,38 @@ static uint32_t rop83_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ADD32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ADD32);
|
||||
break;
|
||||
case 0x08: /*OR*/
|
||||
OR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
case 0x20: /*AND*/
|
||||
AND_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
case 0x28: /*SUB*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
break;
|
||||
case 0x30: /*XOR*/
|
||||
XOR_HOST_REG_IMM(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
case 0x38: /*CMP*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
host_reg = CMP_HOST_REG_IMM_L(host_reg, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, imm);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SUB32);
|
||||
break;
|
||||
}
|
||||
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0x38) != 0x38)
|
||||
{
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
|
||||
@@ -200,30 +200,30 @@ static uint32_t ropF ## name ## size(uint8_t opcode, uint32_t fetchdat, uint32_t
|
||||
return op_pc + 1; \
|
||||
}
|
||||
|
||||
ropFarith(ADD, s, MEM_LOAD_ADDR_EA_L, FP_OP_S)
|
||||
ropFarith(DIV, s, MEM_LOAD_ADDR_EA_L, FP_OP_S)
|
||||
ropFarith(DIVR, s, MEM_LOAD_ADDR_EA_L, FP_OP_S)
|
||||
ropFarith(MUL, s, MEM_LOAD_ADDR_EA_L, FP_OP_S)
|
||||
ropFarith(SUB, s, MEM_LOAD_ADDR_EA_L, FP_OP_S)
|
||||
ropFarith(SUBR, s, MEM_LOAD_ADDR_EA_L, FP_OP_S)
|
||||
ropFarith(ADD, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D)
|
||||
ropFarith(DIV, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D)
|
||||
ropFarith(DIVR, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D)
|
||||
ropFarith(MUL, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D)
|
||||
ropFarith(SUB, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D)
|
||||
ropFarith(SUBR, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D)
|
||||
ropFarith(ADD, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW)
|
||||
ropFarith(DIV, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW)
|
||||
ropFarith(DIVR, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW)
|
||||
ropFarith(MUL, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW)
|
||||
ropFarith(SUB, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW)
|
||||
ropFarith(SUBR, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW)
|
||||
ropFarith(ADD, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL)
|
||||
ropFarith(DIV, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL)
|
||||
ropFarith(DIVR, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL)
|
||||
ropFarith(MUL, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL)
|
||||
ropFarith(SUB, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL)
|
||||
ropFarith(SUBR, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL)
|
||||
ropFarith(ADD, s, MEM_LOAD_ADDR_EA_L, FP_OP_S);
|
||||
ropFarith(DIV, s, MEM_LOAD_ADDR_EA_L, FP_OP_S);
|
||||
ropFarith(DIVR, s, MEM_LOAD_ADDR_EA_L, FP_OP_S);
|
||||
ropFarith(MUL, s, MEM_LOAD_ADDR_EA_L, FP_OP_S);
|
||||
ropFarith(SUB, s, MEM_LOAD_ADDR_EA_L, FP_OP_S);
|
||||
ropFarith(SUBR, s, MEM_LOAD_ADDR_EA_L, FP_OP_S);
|
||||
ropFarith(ADD, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D);
|
||||
ropFarith(DIV, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D);
|
||||
ropFarith(DIVR, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D);
|
||||
ropFarith(MUL, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D);
|
||||
ropFarith(SUB, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D);
|
||||
ropFarith(SUBR, d, MEM_LOAD_ADDR_EA_Q, FP_OP_D);
|
||||
ropFarith(ADD, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW);
|
||||
ropFarith(DIV, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW);
|
||||
ropFarith(DIVR, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW);
|
||||
ropFarith(MUL, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW);
|
||||
ropFarith(SUB, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW);
|
||||
ropFarith(SUBR, iw, MEM_LOAD_ADDR_EA_W, FP_OP_IW);
|
||||
ropFarith(ADD, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
|
||||
ropFarith(DIV, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
|
||||
ropFarith(DIVR, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
|
||||
ropFarith(MUL, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
|
||||
ropFarith(SUB, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
|
||||
ropFarith(SUBR, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
|
||||
|
||||
#define ropFcompare(name, size, load, op) \
|
||||
static uint32_t ropF ## name ## size(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
|
||||
@@ -252,10 +252,10 @@ static uint32_t ropF ## name ## P ## size(uint8_t opcode, uint32_t fetchdat, uin
|
||||
return new_pc; \
|
||||
}
|
||||
|
||||
ropFcompare(COM, s, MEM_LOAD_ADDR_EA_L, FP_COMPARE_S)
|
||||
ropFcompare(COM, d, MEM_LOAD_ADDR_EA_Q, FP_COMPARE_D)
|
||||
ropFcompare(COM, iw, MEM_LOAD_ADDR_EA_W, FP_COMPARE_IW)
|
||||
ropFcompare(COM, il, MEM_LOAD_ADDR_EA_L, FP_COMPARE_IL)
|
||||
ropFcompare(COM, s, MEM_LOAD_ADDR_EA_L, FP_COMPARE_S);
|
||||
ropFcompare(COM, d, MEM_LOAD_ADDR_EA_Q, FP_COMPARE_D);
|
||||
ropFcompare(COM, iw, MEM_LOAD_ADDR_EA_W, FP_COMPARE_IW);
|
||||
ropFcompare(COM, il, MEM_LOAD_ADDR_EA_L, FP_COMPARE_IL);
|
||||
|
||||
/*static uint32_t ropFADDs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
@@ -491,7 +491,7 @@ static uint32_t ropFSTSW_AX(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, u
|
||||
int host_reg;
|
||||
|
||||
FP_ENTER();
|
||||
host_reg = LOAD_VAR_W((uintptr_t) &cpu_state.npxs);
|
||||
host_reg = LOAD_VAR_W((uintptr_t)&cpu_state.npxs);
|
||||
STORE_REG_TARGET_W_RELEASE(host_reg, REG_AX);
|
||||
|
||||
return op_pc;
|
||||
@@ -622,17 +622,19 @@ static uint32_t ropFCHS(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
static uint32_t ropFLD ## name(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
|
||||
{ \
|
||||
static double fp_imm = v; \
|
||||
static uint64_t *fpp; \
|
||||
\
|
||||
FP_ENTER(); \
|
||||
FP_LOAD_IMM_Q(*(uint64_t *)&fp_imm); \
|
||||
fpp = (uint64_t *)&fp_imm; \
|
||||
FP_LOAD_IMM_Q(*fpp); \
|
||||
\
|
||||
return op_pc; \
|
||||
}
|
||||
|
||||
opFLDimm(1, 1.0)
|
||||
opFLDimm(L2T, 3.3219280948873623)
|
||||
opFLDimm(L2E, 1.4426950408889634)
|
||||
opFLDimm(PI, 3.141592653589793)
|
||||
opFLDimm(EG2, 0.3010299956639812)
|
||||
opFLDimm(LN2, 0.693147180559945)
|
||||
opFLDimm(L2E, 1.4426950408889634);
|
||||
opFLDimm(PI, 3.141592653589793);
|
||||
opFLDimm(EG2, 0.3010299956639812);
|
||||
opFLDimm(LN2, 0.693147180559945);
|
||||
opFLDimm(Z, 0.0)
|
||||
|
||||
@@ -77,7 +77,7 @@ static uint32_t ropLOOP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
|
||||
static void BRANCH_COND_B(int pc_offset, uint32_t op_pc, uint32_t offset, int not)
|
||||
{
|
||||
CALL_FUNC((void *) CF_SET);
|
||||
CALL_FUNC((uintptr_t)CF_SET);
|
||||
if (not)
|
||||
TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt);
|
||||
else
|
||||
@@ -122,7 +122,7 @@ static void BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int no
|
||||
break;
|
||||
|
||||
case FLAGS_UNKNOWN:
|
||||
CALL_FUNC((void *) ZF_SET);
|
||||
CALL_FUNC((uintptr_t)ZF_SET);
|
||||
if (not)
|
||||
TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt);
|
||||
else
|
||||
@@ -133,7 +133,7 @@ static void BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int no
|
||||
|
||||
static void BRANCH_COND_O(int pc_offset, uint32_t op_pc, uint32_t offset, int not)
|
||||
{
|
||||
CALL_FUNC((void *) VF_SET);
|
||||
CALL_FUNC((uintptr_t)VF_SET);
|
||||
if (not)
|
||||
TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt);
|
||||
else
|
||||
@@ -142,7 +142,7 @@ static void BRANCH_COND_O(int pc_offset, uint32_t op_pc, uint32_t offset, int no
|
||||
|
||||
static void BRANCH_COND_P(int pc_offset, uint32_t op_pc, uint32_t offset, int not)
|
||||
{
|
||||
CALL_FUNC((void *) PF_SET);
|
||||
CALL_FUNC((uintptr_t)PF_SET);
|
||||
if (not)
|
||||
TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt);
|
||||
else
|
||||
@@ -204,7 +204,7 @@ static void BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int no
|
||||
break;
|
||||
|
||||
case FLAGS_UNKNOWN:
|
||||
CALL_FUNC((void *) NF_SET);
|
||||
CALL_FUNC((uintptr_t)NF_SET);
|
||||
if (not)
|
||||
TEST_ZERO_JUMP_L(0, op_pc+pc_offset+offset, timing_bt);
|
||||
else
|
||||
|
||||
@@ -27,13 +27,13 @@ static uint32_t ropSTI(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32
|
||||
|
||||
static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int host_reg;
|
||||
|
||||
if ((fetchdat & 0x30) != 0x00)
|
||||
return 0;
|
||||
|
||||
CALL_FUNC((void *) flags_rebuild_c);
|
||||
CALL_FUNC((uintptr_t)flags_rebuild_c);
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
host_reg = LOAD_REG_B(fetchdat & 7);
|
||||
@@ -50,18 +50,18 @@ static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*INC*/
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_B(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC8);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC8);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
break;
|
||||
case 0x08: /*DEC*/
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_B(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC8);
|
||||
STORE_HOST_REG_ADDR_BL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC8);
|
||||
STORE_HOST_REG_ADDR_BL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@ static uint32_t ropFE(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_
|
||||
static uint32_t codegen_temp;
|
||||
static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int host_reg;
|
||||
|
||||
if ((fetchdat & 0x30) != 0x00 && (fetchdat & 0x08))
|
||||
return 0;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x00)
|
||||
CALL_FUNC((void *) flags_rebuild_c);
|
||||
CALL_FUNC((uintptr_t)flags_rebuild_c);
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
host_reg = LOAD_REG_W(fetchdat & 7);
|
||||
@@ -111,11 +111,11 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*INC*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM_W(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
STORE_REG_W_RELEASE(host_reg);
|
||||
else
|
||||
@@ -126,11 +126,11 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
case 0x08: /*DEC*/
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM_W(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC16);
|
||||
STORE_HOST_REG_ADDR_WL((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC16);
|
||||
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
STORE_REG_W_RELEASE(host_reg);
|
||||
else
|
||||
@@ -167,21 +167,19 @@ static uint32_t ropFF_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
|
||||
MEM_STORE_ADDR_EA_W(&_ss, host_reg);
|
||||
SP_MODIFY(-2);
|
||||
return op_pc + 1;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int host_reg;
|
||||
|
||||
if ((fetchdat & 0x30) != 0x00 && (fetchdat & 0x08))
|
||||
return 0;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x00)
|
||||
CALL_FUNC((void *) flags_rebuild_c);
|
||||
CALL_FUNC((uintptr_t)flags_rebuild_c);
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
host_reg = LOAD_REG_L(fetchdat & 7);
|
||||
@@ -206,11 +204,11 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*INC*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
ADD_HOST_REG_IMM(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_INC32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
STORE_REG_L_RELEASE(host_reg);
|
||||
else
|
||||
@@ -221,11 +219,11 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
case 0x08: /*DEC*/
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_op1, host_reg);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
|
||||
SUB_HOST_REG_IMM(host_reg, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_DEC32);
|
||||
STORE_HOST_REG_ADDR((uint32_t)&cpu_state.flags_res, host_reg);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC32);
|
||||
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
STORE_REG_L_RELEASE(host_reg);
|
||||
else
|
||||
@@ -262,8 +260,6 @@ static uint32_t ropFF_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
|
||||
MEM_STORE_ADDR_EA_L(&_ss, host_reg);
|
||||
SP_MODIFY(-4);
|
||||
return op_pc + 1;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -154,22 +154,22 @@ MMX_OP(ropPSUBSW, MMX_SUBSW)
|
||||
MMX_OP(ropPSUBUSB, MMX_SUBUSB)
|
||||
MMX_OP(ropPSUBUSW, MMX_SUBUSW)
|
||||
|
||||
MMX_OP(ropPUNPCKLBW, MMX_PUNPCKLBW)
|
||||
MMX_OP(ropPUNPCKLWD, MMX_PUNPCKLWD)
|
||||
MMX_OP(ropPUNPCKLDQ, MMX_PUNPCKLDQ)
|
||||
MMX_OP(ropPACKSSWB, MMX_PACKSSWB)
|
||||
MMX_OP(ropPCMPGTB, MMX_PCMPGTB)
|
||||
MMX_OP(ropPCMPGTW, MMX_PCMPGTW)
|
||||
MMX_OP(ropPCMPGTD, MMX_PCMPGTD)
|
||||
MMX_OP(ropPACKUSWB, MMX_PACKUSWB)
|
||||
MMX_OP(ropPUNPCKHBW, MMX_PUNPCKHBW)
|
||||
MMX_OP(ropPUNPCKHWD, MMX_PUNPCKHWD)
|
||||
MMX_OP(ropPUNPCKHDQ, MMX_PUNPCKHDQ)
|
||||
MMX_OP(ropPACKSSDW, MMX_PACKSSDW)
|
||||
MMX_OP(ropPUNPCKLBW, MMX_PUNPCKLBW);
|
||||
MMX_OP(ropPUNPCKLWD, MMX_PUNPCKLWD);
|
||||
MMX_OP(ropPUNPCKLDQ, MMX_PUNPCKLDQ);
|
||||
MMX_OP(ropPACKSSWB, MMX_PACKSSWB);
|
||||
MMX_OP(ropPCMPGTB, MMX_PCMPGTB);
|
||||
MMX_OP(ropPCMPGTW, MMX_PCMPGTW);
|
||||
MMX_OP(ropPCMPGTD, MMX_PCMPGTD);
|
||||
MMX_OP(ropPACKUSWB, MMX_PACKUSWB);
|
||||
MMX_OP(ropPUNPCKHBW, MMX_PUNPCKHBW);
|
||||
MMX_OP(ropPUNPCKHWD, MMX_PUNPCKHWD);
|
||||
MMX_OP(ropPUNPCKHDQ, MMX_PUNPCKHDQ);
|
||||
MMX_OP(ropPACKSSDW, MMX_PACKSSDW);
|
||||
|
||||
MMX_OP(ropPCMPEQB, MMX_PCMPEQB)
|
||||
MMX_OP(ropPCMPEQW, MMX_PCMPEQW)
|
||||
MMX_OP(ropPCMPEQD, MMX_PCMPEQD)
|
||||
MMX_OP(ropPCMPEQB, MMX_PCMPEQB);
|
||||
MMX_OP(ropPCMPEQW, MMX_PCMPEQW);
|
||||
MMX_OP(ropPCMPEQD, MMX_PCMPEQD);
|
||||
|
||||
MMX_OP(ropPSRLW, MMX_PSRLW)
|
||||
MMX_OP(ropPSRLD, MMX_PSRLD)
|
||||
@@ -180,9 +180,9 @@ MMX_OP(ropPSLLW, MMX_PSLLW)
|
||||
MMX_OP(ropPSLLD, MMX_PSLLD)
|
||||
MMX_OP(ropPSLLQ, MMX_PSLLQ)
|
||||
|
||||
MMX_OP(ropPMULLW, MMX_PMULLW)
|
||||
MMX_OP(ropPMULHW, MMX_PMULHW)
|
||||
MMX_OP(ropPMADDWD, MMX_PMADDWD)
|
||||
MMX_OP(ropPMULLW, MMX_PMULLW);
|
||||
MMX_OP(ropPMULHW, MMX_PMULHW);
|
||||
MMX_OP(ropPMADDWD, MMX_PMADDWD);
|
||||
|
||||
static uint32_t ropPSxxW_imm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
|
||||
@@ -512,22 +512,22 @@ static uint32_t ropMOV_w_seg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ES*/
|
||||
host_reg = LOAD_VAR_WL((uintptr_t) &ES);
|
||||
host_reg = LOAD_VAR_WL((uintptr_t)&ES);
|
||||
break;
|
||||
case 0x08: /*CS*/
|
||||
host_reg = LOAD_VAR_WL((uintptr_t) &CS);
|
||||
host_reg = LOAD_VAR_WL((uintptr_t)&CS);
|
||||
break;
|
||||
case 0x18: /*DS*/
|
||||
host_reg = LOAD_VAR_WL((uintptr_t) &DS);
|
||||
host_reg = LOAD_VAR_WL((uintptr_t)&DS);
|
||||
break;
|
||||
case 0x10: /*SS*/
|
||||
host_reg = LOAD_VAR_WL((uintptr_t) &SS);
|
||||
host_reg = LOAD_VAR_WL((uintptr_t)&SS);
|
||||
break;
|
||||
case 0x20: /*FS*/
|
||||
host_reg = LOAD_VAR_WL((uintptr_t) &FS);
|
||||
host_reg = LOAD_VAR_WL((uintptr_t)&FS);
|
||||
break;
|
||||
case 0x28: /*GS*/
|
||||
host_reg = LOAD_VAR_WL((uintptr_t) &GS);
|
||||
host_reg = LOAD_VAR_WL((uintptr_t)&GS);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
@@ -13,29 +13,29 @@
|
||||
reg = MEM_LOAD_ADDR_EA_ ## size ## _NO_ABRT(target_seg); \
|
||||
if (immediate) count = fastreadb(cs + op_pc + 1) & 0x1f; \
|
||||
} \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op2, count); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, count); \
|
||||
\
|
||||
res_store((uint32_t)&cpu_state.flags_op1, reg); \
|
||||
res_store((uintptr_t)&cpu_state.flags_op1, reg); \
|
||||
\
|
||||
switch (fetchdat & 0x38) \
|
||||
{ \
|
||||
case 0x20: case 0x30: /*SHL*/ \
|
||||
SHL_ ## size ## _IMM(reg, count); \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SHL ## size2); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SHL ## size2); \
|
||||
break; \
|
||||
\
|
||||
case 0x28: /*SHR*/ \
|
||||
SHR_ ## size ## _IMM(reg, count); \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SHR ## size2); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SHR ## size2); \
|
||||
break; \
|
||||
\
|
||||
case 0x38: /*SAR*/ \
|
||||
SAR_ ## size ## _IMM(reg, count); \
|
||||
STORE_IMM_ADDR_L((uint32_t)&cpu_state.flags_op, FLAGS_SAR ## size2); \
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_SAR ## size2); \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
res_store((uint32_t)&cpu_state.flags_res, reg); \
|
||||
res_store((uintptr_t)&cpu_state.flags_res, reg); \
|
||||
if ((fetchdat & 0xc0) == 0xc0) \
|
||||
STORE_REG_ ## size ## _RELEASE(reg); \
|
||||
else \
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
static uint32_t ropC0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int count;
|
||||
int reg;
|
||||
|
||||
@@ -59,7 +59,7 @@ static uint32_t ropC0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_
|
||||
}
|
||||
static uint32_t ropC1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int count;
|
||||
int reg;
|
||||
|
||||
@@ -72,7 +72,7 @@ static uint32_t ropC1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
}
|
||||
static uint32_t ropC1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int count;
|
||||
int reg;
|
||||
|
||||
@@ -86,7 +86,7 @@ static uint32_t ropC1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
|
||||
static uint32_t ropD0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int count = 1;
|
||||
int reg;
|
||||
|
||||
@@ -99,7 +99,7 @@ static uint32_t ropD0(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_
|
||||
}
|
||||
static uint32_t ropD1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int count = 1;
|
||||
int reg;
|
||||
|
||||
@@ -112,7 +112,7 @@ static uint32_t ropD1_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
}
|
||||
static uint32_t ropD1_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
x86seg *target_seg = NULL;
|
||||
int count = 1;
|
||||
int reg;
|
||||
|
||||
|
||||
@@ -85,8 +85,6 @@ static uint32_t ropPUSH_imm_b32(uint8_t opcode, uint32_t fetchdat, uint32_t op_3
|
||||
|
||||
static uint32_t ropPOP_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
/* int host_reg; */
|
||||
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc);
|
||||
LOAD_STACK_TO_EA(0);
|
||||
MEM_LOAD_ADDR_EA_W(&_ss);
|
||||
@@ -97,8 +95,6 @@ static uint32_t ropPOP_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
}
|
||||
static uint32_t ropPOP_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
/* int host_reg; */
|
||||
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc);
|
||||
LOAD_STACK_TO_EA(0);
|
||||
MEM_LOAD_ADDR_EA_L(&_ss);
|
||||
@@ -110,8 +106,6 @@ static uint32_t ropPOP_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
|
||||
static uint32_t ropRET_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
/* int host_reg; */
|
||||
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc);
|
||||
LOAD_STACK_TO_EA(0);
|
||||
MEM_LOAD_ADDR_EA_W(&_ss);
|
||||
@@ -122,8 +116,6 @@ static uint32_t ropRET_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
}
|
||||
static uint32_t ropRET_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
/* int host_reg; */
|
||||
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc);
|
||||
LOAD_STACK_TO_EA(0);
|
||||
MEM_LOAD_ADDR_EA_L(&_ss);
|
||||
@@ -136,7 +128,6 @@ static uint32_t ropRET_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
static uint32_t ropRET_imm_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
uint16_t offset = fetchdat & 0xffff;
|
||||
/* int host_reg; */
|
||||
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc);
|
||||
LOAD_STACK_TO_EA(0);
|
||||
@@ -149,7 +140,6 @@ static uint32_t ropRET_imm_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||
static uint32_t ropRET_imm_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
uint16_t offset = fetchdat & 0xffff;
|
||||
/* int host_reg; */
|
||||
|
||||
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.oldpc, op_old_pc);
|
||||
LOAD_STACK_TO_EA(0);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,12 +7,13 @@
|
||||
- FPU queue
|
||||
- Out of order execution (beyond most simplistic approximation)
|
||||
*/
|
||||
|
||||
#include "../ibm.h"
|
||||
#include "../mem.h"
|
||||
#include "cpu.h"
|
||||
#include "x86.h"
|
||||
#include "x86_ops.h"
|
||||
#include "x87.h"
|
||||
#include "../mem.h"
|
||||
#include "codegen.h"
|
||||
|
||||
/*Instruction has different execution time for 16 and 32 bit data. Does not pair */
|
||||
@@ -818,7 +819,7 @@ static uint32_t opcode_timings_8x[8] =
|
||||
static int decode_delay;
|
||||
static uint8_t last_prefix;
|
||||
|
||||
static __inline int COUNT(uint32_t c, int op_32)
|
||||
static inline int COUNT(uint32_t c, int op_32)
|
||||
{
|
||||
if (c & CYCLES_HAS_MULTI)
|
||||
{
|
||||
@@ -854,7 +855,7 @@ void codegen_timing_686_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
|
||||
void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32)
|
||||
{
|
||||
int *timings;
|
||||
uint32_t *timings;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
- FPU latencies
|
||||
- MMX latencies
|
||||
*/
|
||||
|
||||
#include "../ibm.h"
|
||||
#include "../mem.h"
|
||||
#include "cpu.h"
|
||||
#include "x86.h"
|
||||
#include "x86_ops.h"
|
||||
#include "x87.h"
|
||||
#include "../mem.h"
|
||||
#include "codegen.h"
|
||||
|
||||
/*Instruction has different execution time for 16 and 32 bit data. Does not pair */
|
||||
@@ -818,7 +819,7 @@ static uint32_t opcode_timings_8x[8] =
|
||||
static int decode_delay;
|
||||
static uint8_t last_prefix;
|
||||
|
||||
static __inline int COUNT(uint32_t c, int op_32)
|
||||
static inline int COUNT(uint32_t c, int op_32)
|
||||
{
|
||||
if (c & CYCLES_HAS_MULTI)
|
||||
{
|
||||
@@ -886,7 +887,7 @@ void codegen_timing_pentium_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
|
||||
void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32)
|
||||
{
|
||||
int *timings;
|
||||
uint32_t *timings;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined WIN32 || defined _WIN32 || defined _WIN32
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "../ibm.h"
|
||||
#include "../mem.h"
|
||||
#include "cpu.h"
|
||||
#include "x86.h"
|
||||
#include "x86_flags.h"
|
||||
#include "x86_ops.h"
|
||||
#include "x87.h"
|
||||
#include "../mem.h"
|
||||
|
||||
#include "386_common.h"
|
||||
|
||||
@@ -115,7 +116,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B()
|
||||
addbyte(8);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*MOVZX EAX, AL*/
|
||||
addbyte(0xb6);
|
||||
@@ -170,7 +171,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W()
|
||||
addbyte(8);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*MOVZX EAX, AX*/
|
||||
addbyte(0xb7);
|
||||
@@ -224,7 +225,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L()
|
||||
addbyte(8);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -279,7 +280,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_Q()
|
||||
addbyte(8);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -327,7 +328,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B()
|
||||
addbyte(12);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -381,7 +382,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W()
|
||||
addbyte(12);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -434,7 +435,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L()
|
||||
addbyte(12);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -492,7 +493,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_Q()
|
||||
addbyte(16);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -543,7 +544,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_B_NO_ABRT()
|
||||
#ifndef RELEASE_BUILD
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
#endif
|
||||
addbyte(0x0f); /*MOVZX ECX, AL*/
|
||||
@@ -612,7 +613,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_W_NO_ABRT()
|
||||
#ifndef RELEASE_BUILD
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
#endif
|
||||
addbyte(0x0f); /*MOVZX ECX, AX*/
|
||||
@@ -658,7 +659,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L_NO_ABRT()
|
||||
addbyte(0x14);
|
||||
addbyte(0x95);
|
||||
addlong((uint32_t)readlookup2);
|
||||
addbyte(0x75); /*JNE slowpath*/
|
||||
addbyte(0x75); /*JE slowpath*/
|
||||
addbyte(3+2+3+1);
|
||||
addbyte(0x83); /*CMP EDX, -1*/
|
||||
addbyte(0xfa);
|
||||
@@ -682,7 +683,7 @@ static uint32_t gen_MEM_LOAD_ADDR_EA_L_NO_ABRT()
|
||||
#ifndef RELEASE_BUILD
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x75); /*JNE mem_abrt_rout*/
|
||||
addbyte(1);
|
||||
@@ -745,7 +746,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_B_NO_ABRT()
|
||||
#ifndef RELEASE_BUILD
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x75); /*JNE mem_abrt_rout*/
|
||||
addbyte(1);
|
||||
@@ -811,7 +812,7 @@ static uint32_t gen_MEM_STORE_ADDR_EA_W_NO_ABRT()
|
||||
#ifndef RELEASE_BUILD
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x75); /*JNE mem_abrt_rout*/
|
||||
addbyte(1);
|
||||
@@ -876,17 +877,17 @@ static uint32_t gen_MEM_STORE_ADDR_EA_L_NO_ABRT()
|
||||
#ifndef RELEASE_BUILD
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x75); /*JNE mem_abrt_rout*/
|
||||
addbyte(1);
|
||||
#endif
|
||||
addbyte(0xc3); /*RET*/
|
||||
#ifndef RELEASE_BUILD
|
||||
addbyte(0xc7); /*MOV [ESP], gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err*/
|
||||
addbyte(0xc7); /*MOV [ESP], gen_MEM_STORE_ADDR_EA_L_NO_ABRT_err*/
|
||||
addbyte(0x04);
|
||||
addbyte(0x24);
|
||||
addlong((uint32_t)gen_MEM_STORE_ADDR_EA_W_NO_ABRT_err);
|
||||
addlong((uint32_t)gen_MEM_STORE_ADDR_EA_L_NO_ABRT_err);
|
||||
addbyte(0xe8); /*CALL fatal*/
|
||||
addlong((uint32_t)fatal - (uint32_t)(&codeblock[block_current].data[block_pos + 4]));
|
||||
/*Should not return!*/
|
||||
@@ -941,7 +942,7 @@ static uint32_t gen_MEM_CHECK_WRITE()
|
||||
addbyte(8);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -1022,7 +1023,7 @@ static uint32_t gen_MEM_CHECK_WRITE_W()
|
||||
addbyte(1);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -1104,7 +1105,7 @@ static uint32_t gen_MEM_CHECK_WRITE_L()
|
||||
addbyte(3);
|
||||
addbyte(0x80); /*CMP abrt, 0*/
|
||||
addbyte(0x7d);
|
||||
addbyte(cpu_state_offset(abrt));
|
||||
addbyte((uint8_t)cpu_state_offset(abrt));
|
||||
addbyte(0);
|
||||
addbyte(0x0f); /*JNE mem_abrt_rout*/
|
||||
addbyte(0x85);
|
||||
@@ -1122,7 +1123,6 @@ static uint32_t gen_MEM_CHECK_WRITE_L()
|
||||
|
||||
void codegen_init()
|
||||
{
|
||||
int c;
|
||||
#ifdef __linux__
|
||||
void *start;
|
||||
size_t len;
|
||||
@@ -1149,7 +1149,6 @@ void codegen_init()
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
/* pclog("Codegen is %p\n", (void *)pages[0xfab12 >> 12].block); */
|
||||
|
||||
block_current = BLOCK_SIZE;
|
||||
block_pos = 0;
|
||||
@@ -1163,50 +1162,44 @@ void codegen_init()
|
||||
addbyte(0x5b); /*POP EDX*/
|
||||
addbyte(0xC3); /*RET*/
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_load_addr_ea_l = gen_MEM_LOAD_ADDR_EA_L();
|
||||
mem_load_addr_ea_l = (uint32_t)gen_MEM_LOAD_ADDR_EA_L();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_load_addr_ea_w = gen_MEM_LOAD_ADDR_EA_W();
|
||||
mem_load_addr_ea_w = (uint32_t)gen_MEM_LOAD_ADDR_EA_W();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_load_addr_ea_b = gen_MEM_LOAD_ADDR_EA_B();
|
||||
mem_load_addr_ea_b = (uint32_t)gen_MEM_LOAD_ADDR_EA_B();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_load_addr_ea_q = gen_MEM_LOAD_ADDR_EA_Q();
|
||||
mem_load_addr_ea_q = (uint32_t)gen_MEM_LOAD_ADDR_EA_Q();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_store_addr_ea_l = gen_MEM_STORE_ADDR_EA_L();
|
||||
mem_store_addr_ea_l = (uint32_t)gen_MEM_STORE_ADDR_EA_L();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_store_addr_ea_w = gen_MEM_STORE_ADDR_EA_W();
|
||||
mem_store_addr_ea_w = (uint32_t)gen_MEM_STORE_ADDR_EA_W();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_store_addr_ea_b = gen_MEM_STORE_ADDR_EA_B();
|
||||
mem_store_addr_ea_b = (uint32_t)gen_MEM_STORE_ADDR_EA_B();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_store_addr_ea_q = gen_MEM_STORE_ADDR_EA_Q();
|
||||
mem_store_addr_ea_q = (uint32_t)gen_MEM_STORE_ADDR_EA_Q();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_load_addr_ea_b_no_abrt = gen_MEM_LOAD_ADDR_EA_B_NO_ABRT();
|
||||
mem_load_addr_ea_b_no_abrt = (uint32_t)gen_MEM_LOAD_ADDR_EA_B_NO_ABRT();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_store_addr_ea_b_no_abrt = gen_MEM_STORE_ADDR_EA_B_NO_ABRT();
|
||||
mem_store_addr_ea_b_no_abrt = (uint32_t)gen_MEM_STORE_ADDR_EA_B_NO_ABRT();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_load_addr_ea_w_no_abrt = gen_MEM_LOAD_ADDR_EA_W_NO_ABRT();
|
||||
mem_load_addr_ea_w_no_abrt = (uint32_t)gen_MEM_LOAD_ADDR_EA_W_NO_ABRT();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_store_addr_ea_w_no_abrt = gen_MEM_STORE_ADDR_EA_W_NO_ABRT();
|
||||
mem_store_addr_ea_w_no_abrt = (uint32_t)gen_MEM_STORE_ADDR_EA_W_NO_ABRT();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_load_addr_ea_l_no_abrt = gen_MEM_LOAD_ADDR_EA_L_NO_ABRT();
|
||||
mem_load_addr_ea_l_no_abrt = (uint32_t)gen_MEM_LOAD_ADDR_EA_L_NO_ABRT();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_store_addr_ea_l_no_abrt = gen_MEM_STORE_ADDR_EA_L_NO_ABRT();
|
||||
mem_store_addr_ea_l_no_abrt = (uint32_t)gen_MEM_STORE_ADDR_EA_L_NO_ABRT();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_check_write = gen_MEM_CHECK_WRITE();
|
||||
mem_check_write = (uint32_t)gen_MEM_CHECK_WRITE();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_check_write_w = gen_MEM_CHECK_WRITE_W();
|
||||
mem_check_write_w = (uint32_t)gen_MEM_CHECK_WRITE_W();
|
||||
block_pos = (block_pos + 15) & ~15;
|
||||
mem_check_write_l = gen_MEM_CHECK_WRITE_L();
|
||||
mem_check_write_l = (uint32_t)gen_MEM_CHECK_WRITE_L();
|
||||
|
||||
#ifdef __MSC__
|
||||
__asm {
|
||||
fstcw cpu_state.old_npxc
|
||||
}
|
||||
#else
|
||||
__asm(
|
||||
asm(
|
||||
"fstcw %0\n"
|
||||
: "=m" (cpu_state.old_npxc)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void codegen_reset()
|
||||
@@ -1218,6 +1211,20 @@ 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)
|
||||
@@ -1297,7 +1304,6 @@ 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->phys_2 >> 10) & 3] = block->next_2;
|
||||
if (block->next_2)
|
||||
block->next_2->prev_2 = NULL;
|
||||
@@ -1355,7 +1361,6 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr)
|
||||
void codegen_block_init(uint32_t phys_addr)
|
||||
{
|
||||
codeblock_t *block;
|
||||
int has_evicted = 0;
|
||||
page_t *page = &pages[phys_addr >> 12];
|
||||
|
||||
if (!page->block[(phys_addr >> 10) & 3])
|
||||
@@ -1366,7 +1371,6 @@ void codegen_block_init(uint32_t phys_addr)
|
||||
|
||||
if (block->pc != 0)
|
||||
{
|
||||
/* pclog("Reuse block : was %08x now %08x\n", block->pc, cs+pc); */
|
||||
delete_block(block);
|
||||
cpu_recomp_reuse++;
|
||||
}
|
||||
@@ -1384,7 +1388,7 @@ void codegen_block_init(uint32_t phys_addr)
|
||||
block->next_2 = block->prev_2 = NULL;
|
||||
block->page_mask = 0;
|
||||
block->flags = CODEBLOCK_STATIC_TOP;
|
||||
block->status = cpu_cur_status;
|
||||
block->status = cpu_cur_status;
|
||||
|
||||
block->was_recompiled = 0;
|
||||
|
||||
@@ -1395,7 +1399,6 @@ void codegen_block_init(uint32_t phys_addr)
|
||||
|
||||
void codegen_block_start_recompile(codeblock_t *block)
|
||||
{
|
||||
int has_evicted = 0;
|
||||
page_t *page = &pages[block->phys >> 12];
|
||||
|
||||
if (!page->block[(block->phys >> 10) & 3])
|
||||
@@ -1440,8 +1443,6 @@ void codegen_block_start_recompile(codeblock_t *block)
|
||||
addbyte(0xBD); /*MOVL EBP, &cpu_state*/
|
||||
addlong(((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;
|
||||
@@ -1499,11 +1500,9 @@ void codegen_block_generate_end_mask()
|
||||
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->phys >> 10) & 3] |= block->page_mask;
|
||||
@@ -1531,7 +1530,6 @@ void codegen_block_generate_end_mask()
|
||||
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);
|
||||
}
|
||||
@@ -1540,7 +1538,6 @@ void codegen_block_generate_end_mask()
|
||||
}
|
||||
}
|
||||
|
||||
/* pclog("block_end: %08x %08x %016llx\n", block->pc, block->endpc, block->page_mask); */
|
||||
recomp_page = -1;
|
||||
}
|
||||
|
||||
@@ -1560,14 +1557,14 @@ void codegen_block_end_recompile(codeblock_t *block)
|
||||
{
|
||||
addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/
|
||||
addbyte(0x6d);
|
||||
addbyte(cpu_state_offset(_cycles));
|
||||
addbyte((uint8_t)cpu_state_offset(_cycles));
|
||||
addlong(codegen_block_cycles);
|
||||
}
|
||||
if (codegen_block_ins)
|
||||
{
|
||||
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(cpu_recomp_ins));
|
||||
addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins));
|
||||
addlong(codegen_block_ins);
|
||||
}
|
||||
#if 0
|
||||
@@ -1596,7 +1593,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); */
|
||||
|
||||
if (!(block->flags & CODEBLOCK_HAS_FPU))
|
||||
block->flags &= ~CODEBLOCK_STATIC_TOP;
|
||||
@@ -1607,29 +1603,6 @@ void codegen_flush()
|
||||
return;
|
||||
}
|
||||
|
||||
static int opcode_conditional_jump[256] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /*00*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*30*/
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*40*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*50*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*60*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*70*/
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*90*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*a0*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*b0*/
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*d0*/
|
||||
1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*e0*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*f0*/
|
||||
};
|
||||
|
||||
static int opcode_modrm[256] =
|
||||
{
|
||||
1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*00*/
|
||||
@@ -1666,7 +1639,7 @@ int opcode_0f_modrm[256] =
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*90*/
|
||||
0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /*a0*/
|
||||
0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, /*a0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, /*b0*/
|
||||
|
||||
1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/
|
||||
@@ -1689,7 +1662,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
{
|
||||
addbyte(0xC7); /*MOVL $0,(ssegs)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
addlong((fetchdat >> 8) & 0xffff);
|
||||
(*op_pc) += 2;
|
||||
}
|
||||
@@ -1706,7 +1679,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
break;
|
||||
case 1:
|
||||
addbyte(0xb8); /*MOVL ,%eax*/
|
||||
addlong((uint32_t)(int8_t)(rmdat >> 8)); /* pc++; */
|
||||
addlong((uint32_t)(int8_t)(rmdat >> 8));
|
||||
addbyte(0x03); /*ADDL *mod1add[0][cpu_rm], %eax*/
|
||||
addbyte(0x05);
|
||||
addlong((uint32_t)mod1add[0][cpu_rm]);
|
||||
@@ -1717,7 +1690,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
break;
|
||||
case 2:
|
||||
addbyte(0xb8); /*MOVL ,%eax*/
|
||||
addlong((fetchdat >> 8) & 0xffff); /* pc++; */
|
||||
addlong((fetchdat >> 8) & 0xffff);
|
||||
addbyte(0x03); /*ADDL *mod1add[0][cpu_rm], %eax*/
|
||||
addbyte(0x05);
|
||||
addlong((uint32_t)mod1add[0][cpu_rm]);
|
||||
@@ -1754,14 +1727,14 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
{
|
||||
new_eaaddr = fastreadl(cs + (*op_pc) + 1);
|
||||
addbyte(0xb8); /*MOVL ,%eax*/
|
||||
addlong(new_eaaddr); /* pc++; */
|
||||
addlong(new_eaaddr);
|
||||
(*op_pc) += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
addbyte(0x8b); /*MOVL regs[sib&7].l, %eax*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(regs[sib & 7].l));
|
||||
addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
@@ -1770,7 +1743,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
addlong(new_eaaddr);
|
||||
addbyte(0x03); /*ADDL regs[sib&7].l, %eax*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(regs[sib & 7].l));
|
||||
addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l));
|
||||
(*op_pc)++;
|
||||
break;
|
||||
case 2:
|
||||
@@ -1779,7 +1752,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
addlong(new_eaaddr);
|
||||
addbyte(0x03); /*ADDL regs[sib&7].l, %eax*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(regs[sib & 7].l));
|
||||
addbyte((uint8_t)cpu_state_offset(regs[sib & 7].l));
|
||||
(*op_pc) += 4;
|
||||
break;
|
||||
}
|
||||
@@ -1797,20 +1770,20 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
case 0:
|
||||
addbyte(0x03); /*ADDL regs[sib&7].l, %eax*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l));
|
||||
addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l));
|
||||
break;
|
||||
case 1:
|
||||
addbyte(0x8B); addbyte(0x5D); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/
|
||||
addbyte(0x8B); addbyte(0x5D); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/
|
||||
addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/
|
||||
addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/
|
||||
break;
|
||||
case 2:
|
||||
addbyte(0x8B); addbyte(0x5D); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/
|
||||
addbyte(0x8B); addbyte(0x5D); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/
|
||||
addbyte(0xC1); addbyte(0xE3); addbyte(2); /*SHL $2,%ebx*/
|
||||
addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/
|
||||
break;
|
||||
case 3:
|
||||
addbyte(0x8B); addbyte(0x5D); addbyte(cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/
|
||||
addbyte(0x8B); addbyte(0x5D); addbyte((uint8_t)cpu_state_offset(regs[(sib >> 3) & 7].l)); /*MOVL armregs[RD],%ebx*/
|
||||
addbyte(0xC1); addbyte(0xE3); addbyte(3); /*SHL $2,%ebx*/
|
||||
addbyte(0x01); addbyte(0xD8); /*ADDL %ebx,%eax*/
|
||||
break;
|
||||
@@ -1826,18 +1799,14 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
new_eaaddr = fastreadl(cs + (*op_pc) + 1);
|
||||
addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
addlong(new_eaaddr);
|
||||
(*op_pc) += 4;
|
||||
return op_ea_seg;
|
||||
}
|
||||
addbyte(0x8b); /*MOVL regs[sib&7].l, %eax*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(regs[cpu_rm].l));
|
||||
#if 0
|
||||
addbyte(0xa1); /*MOVL regs[cpu_rm].l, %eax*/
|
||||
addlong((uint32_t)&cpu_state.regs[cpu_rm].l);
|
||||
#endif
|
||||
addbyte((uint8_t)cpu_state_offset(regs[cpu_rm].l));
|
||||
cpu_state.eaaddr = cpu_state.regs[cpu_rm].l;
|
||||
if (cpu_mod)
|
||||
{
|
||||
@@ -2025,19 +1994,19 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t
|
||||
|
||||
generate_call:
|
||||
codegen_timing_opcode(opcode, fetchdat, op_32);
|
||||
|
||||
|
||||
if ((op_table == x86_dynarec_opcodes &&
|
||||
((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 ||
|
||||
((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 ||
|
||||
(opcode & 0xfe) == 0xca || (opcode & 0xfc) == 0xcc || (opcode & 0xfc) == 0xe8 ||
|
||||
(opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30))) ||
|
||||
(op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80))))
|
||||
(opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30)))) ||
|
||||
(op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80)))
|
||||
{
|
||||
/*Opcode is likely to cause block to exit, update cycle count*/
|
||||
if (codegen_block_cycles)
|
||||
{
|
||||
addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/
|
||||
addbyte(0x6d);
|
||||
addbyte(cpu_state_offset(_cycles));
|
||||
addbyte((uint8_t)cpu_state_offset(_cycles));
|
||||
addlong(codegen_block_cycles);
|
||||
codegen_block_cycles = 0;
|
||||
}
|
||||
@@ -2045,7 +2014,7 @@ generate_call:
|
||||
{
|
||||
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(cpu_recomp_ins));
|
||||
addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins));
|
||||
addlong(codegen_block_ins);
|
||||
codegen_block_ins = 0;
|
||||
}
|
||||
@@ -2079,17 +2048,13 @@ generate_call:
|
||||
}
|
||||
|
||||
op = op_table[((opcode >> opcode_shift) | op_32) & opcode_mask];
|
||||
#if 0
|
||||
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]);
|
||||
#endif
|
||||
if (op_ssegs != last_ssegs)
|
||||
{
|
||||
last_ssegs = op_ssegs;
|
||||
|
||||
addbyte(0xC6); /*MOVB [ssegs],op_ssegs*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(ssegs));
|
||||
addbyte((uint8_t)cpu_state_offset(ssegs));
|
||||
addbyte(op_pc + pc_off);
|
||||
}
|
||||
|
||||
@@ -2108,7 +2073,7 @@ generate_call:
|
||||
|
||||
addbyte(0xC7); /*MOVL $rm | mod | reg,(rm_mod_reg_data)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(rm_data.rm_mod_reg_data));
|
||||
addbyte((uint8_t)cpu_state_offset(rm_data.rm_mod_reg_data));
|
||||
addlong(cpu_rm | (cpu_mod << 8) | (cpu_reg << 16));
|
||||
|
||||
op_pc += pc_off;
|
||||
@@ -2124,18 +2089,18 @@ generate_call:
|
||||
last_ea_seg = op_ea_seg;
|
||||
addbyte(0xC7); /*MOVL $&_ds,(ea_seg)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(ea_seg));
|
||||
addbyte((uint8_t)cpu_state_offset(ea_seg));
|
||||
addlong((uint32_t)op_ea_seg);
|
||||
}
|
||||
|
||||
addbyte(0xC7); /*MOVL pc,new_pc*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(pc));
|
||||
addbyte((uint8_t)cpu_state_offset(pc));
|
||||
addlong(op_pc + pc_off);
|
||||
|
||||
addbyte(0xC7); /*MOVL $old_pc,(oldpc)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(oldpc));
|
||||
addbyte((uint8_t)cpu_state_offset(oldpc));
|
||||
addlong(old_pc);
|
||||
|
||||
if (op_32 != last_op32)
|
||||
@@ -2143,7 +2108,7 @@ generate_call:
|
||||
last_op32 = op_32;
|
||||
addbyte(0xC7); /*MOVL $use32,(op32)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(op32));
|
||||
addbyte((uint8_t)cpu_state_offset(op32));
|
||||
addlong(op_32);
|
||||
}
|
||||
|
||||
@@ -2164,11 +2129,6 @@ generate_call:
|
||||
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
|
||||
addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4]));
|
||||
|
||||
#if 0
|
||||
addbyte(0xE8); /*CALL*/
|
||||
addlong(((uint8_t *)codegen_debug - (uint8_t *)(&block->data[block_pos + 4])));
|
||||
#endif
|
||||
|
||||
codegen_endpc = (cs + cpu_state.pc) + 8;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ static int opCALL_far_w(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t old_cs, old_pc;
|
||||
uint16_t new_cs, new_pc;
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
new_pc = getwordf();
|
||||
new_cs = getword(); if (cpu_state.abrt) return 1;
|
||||
@@ -77,7 +77,7 @@ static int opCALL_far_l(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t old_cs, old_pc;
|
||||
uint32_t new_cs, new_pc;
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
new_pc = getlong();
|
||||
new_cs = getword(); if (cpu_state.abrt) return 1;
|
||||
@@ -95,7 +95,7 @@ static int opFF_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
uint16_t temp;
|
||||
|
||||
@@ -163,6 +163,7 @@ static int opFF_w_a16(uint32_t fetchdat)
|
||||
break;
|
||||
|
||||
default:
|
||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||
x86illegal();
|
||||
}
|
||||
return cpu_state.abrt;
|
||||
@@ -171,7 +172,7 @@ static int opFF_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
uint16_t temp;
|
||||
|
||||
@@ -239,6 +240,7 @@ static int opFF_w_a32(uint32_t fetchdat)
|
||||
break;
|
||||
|
||||
default:
|
||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||
x86illegal();
|
||||
}
|
||||
return cpu_state.abrt;
|
||||
@@ -248,7 +250,7 @@ static int opFF_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
uint32_t temp;
|
||||
|
||||
@@ -316,6 +318,7 @@ static int opFF_l_a16(uint32_t fetchdat)
|
||||
break;
|
||||
|
||||
default:
|
||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||
x86illegal();
|
||||
}
|
||||
return cpu_state.abrt;
|
||||
@@ -324,7 +327,7 @@ static int opFF_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
uint32_t temp;
|
||||
|
||||
@@ -391,6 +394,7 @@ static int opFF_l_a32(uint32_t fetchdat)
|
||||
break;
|
||||
|
||||
default:
|
||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||
x86illegal();
|
||||
}
|
||||
return cpu_state.abrt;
|
||||
|
||||
@@ -166,6 +166,7 @@ static int opFXSAVESTOR_a16(uint32_t fetchdat)
|
||||
uint8_t ftwb = 0;
|
||||
uint16_t rec_ftw = 0;
|
||||
uint16_t fpus = 0;
|
||||
uint64_t *p;
|
||||
|
||||
if (CPUID < 0x650) return ILLEGAL(fetchdat);
|
||||
|
||||
@@ -258,9 +259,10 @@ static int opFXSAVESTOR_a16(uint32_t fetchdat)
|
||||
cpu_state.ismmx = 0;
|
||||
/*Horrible hack, but as PCem doesn't keep the FPU stack in 80-bit precision at all times
|
||||
something like this is needed*/
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff &&
|
||||
cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff &&
|
||||
!cpu_state.TOP && !(*(uint64_t *)cpu_state.tag))
|
||||
!cpu_state.TOP && !(*p))
|
||||
cpu_state.ismmx = 1;
|
||||
|
||||
x87_settag(rec_ftw);
|
||||
@@ -321,7 +323,8 @@ static int opFXSAVESTOR_a16(uint32_t fetchdat)
|
||||
cpu_state.npxc = 0x37F;
|
||||
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00);
|
||||
cpu_state.npxs = 0;
|
||||
*(uint64_t *)cpu_state.tag = 0x0303030303030303ll;
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
*p = 0x0303030303030303ll;
|
||||
cpu_state.TOP = 0;
|
||||
cpu_state.ismmx = 0;
|
||||
|
||||
@@ -341,6 +344,7 @@ static int opFXSAVESTOR_a32(uint32_t fetchdat)
|
||||
uint8_t ftwb = 0;
|
||||
uint16_t rec_ftw = 0;
|
||||
uint16_t fpus = 0;
|
||||
uint64_t *p;
|
||||
|
||||
if (CPUID < 0x650) return ILLEGAL(fetchdat);
|
||||
|
||||
@@ -433,9 +437,10 @@ static int opFXSAVESTOR_a32(uint32_t fetchdat)
|
||||
cpu_state.ismmx = 0;
|
||||
/*Horrible hack, but as PCem doesn't keep the FPU stack in 80-bit precision at all times
|
||||
something like this is needed*/
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff &&
|
||||
cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff &&
|
||||
!cpu_state.TOP && !(*(uint64_t *)cpu_state.tag))
|
||||
!cpu_state.TOP && !(*p))
|
||||
cpu_state.ismmx = 1;
|
||||
|
||||
x87_settag(rec_ftw);
|
||||
@@ -496,7 +501,8 @@ static int opFXSAVESTOR_a32(uint32_t fetchdat)
|
||||
cpu_state.npxc = 0x37F;
|
||||
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00);
|
||||
cpu_state.npxs = 0;
|
||||
*(uint64_t *)cpu_state.tag = 0x0303030303030303ll;
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
*p = 0x0303030303030303ll;
|
||||
cpu_state.TOP = 0;
|
||||
cpu_state.ismmx = 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
static int opINT3(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3))
|
||||
{
|
||||
x86gpf(NULL,0);
|
||||
@@ -14,7 +14,7 @@ static int opINT3(uint32_t fetchdat)
|
||||
|
||||
static int opINT1(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3))
|
||||
{
|
||||
x86gpf(NULL,0);
|
||||
@@ -28,7 +28,7 @@ static int opINT1(uint32_t fetchdat)
|
||||
|
||||
static int opINT(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
uint8_t temp;
|
||||
|
||||
/*if (msw&1) pclog("INT %i %i %i\n",cr0&1,eflags&VM_FLAG,IOPL);*/
|
||||
@@ -38,6 +38,38 @@ static int opINT(uint32_t fetchdat)
|
||||
return 1;
|
||||
}
|
||||
temp = getbytef();
|
||||
// /*if (temp == 0x10 && AH == 0xe) */pclog("INT %02X : %04X %04X %04X %04X %c %04X:%04X\n", temp, AX, BX, CX, DX, (AL < 32) ? ' ' : AL, CS, pc);
|
||||
// if (CS == 0x0028 && pc == 0xC03813C0)
|
||||
// output = 3;
|
||||
/* if (pc == 0x8028009A)
|
||||
output = 3;
|
||||
if (pc == 0x80282B6F)
|
||||
{
|
||||
__times++;
|
||||
if (__times == 2)
|
||||
fatal("WRONG\n");
|
||||
}
|
||||
if (pc == 0x802809CE)
|
||||
fatal("RIGHT\n");*/
|
||||
// if (CS == 0x0028 && pc == 0x80037FE9)
|
||||
// output = 3;
|
||||
//if (CS == 0x9087 && pc == 0x3763)
|
||||
// fatal("Here\n");
|
||||
//if (CS==0x9087 && pc == 0x0850)
|
||||
// output = 1;
|
||||
|
||||
/* if (output && pc == 0x80033008)
|
||||
{
|
||||
__times++;
|
||||
if (__times == 2)
|
||||
fatal("WRONG\n");
|
||||
}*/
|
||||
/* if (output && pc == 0x80D8)
|
||||
{
|
||||
__times++;
|
||||
if (__times == 2)
|
||||
fatal("RIGHT\n");
|
||||
}*/
|
||||
|
||||
x86_int_sw(temp);
|
||||
PREFETCH_RUN(cycles_old-cycles, 2, -1, 0,0,0,0, 0);
|
||||
@@ -46,7 +78,7 @@ static int opINT(uint32_t fetchdat)
|
||||
|
||||
static int opINTO(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3))
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
static int opRETF_a16(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
CPU_BLOCK_END();
|
||||
RETF_a16(0);
|
||||
@@ -55,7 +55,7 @@ static int opRETF_a16(uint32_t fetchdat)
|
||||
}
|
||||
static int opRETF_a32(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
CPU_BLOCK_END();
|
||||
RETF_a32(0);
|
||||
@@ -67,8 +67,8 @@ static int opRETF_a32(uint32_t fetchdat)
|
||||
|
||||
static int opRETF_a16_imm(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
uint16_t offset = getwordf();
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
CPU_BLOCK_END();
|
||||
RETF_a16(offset);
|
||||
@@ -79,8 +79,8 @@ static int opRETF_a16_imm(uint32_t fetchdat)
|
||||
}
|
||||
static int opRETF_a32_imm(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
uint16_t offset = getwordf();
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
CPU_BLOCK_END();
|
||||
RETF_a32(offset);
|
||||
@@ -92,7 +92,7 @@ static int opRETF_a32_imm(uint32_t fetchdat)
|
||||
|
||||
static int opIRET_286(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3))
|
||||
{
|
||||
@@ -137,7 +137,7 @@ static int opIRET_286(uint32_t fetchdat)
|
||||
|
||||
static int opIRET(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3))
|
||||
{
|
||||
@@ -182,7 +182,7 @@ static int opIRET(uint32_t fetchdat)
|
||||
|
||||
static int opIRETD(uint32_t fetchdat)
|
||||
{
|
||||
int cycles_old = cycles;
|
||||
int cycles_old = cycles; UNUSED(cycles_old);
|
||||
|
||||
if ((cr0 & 1) && (eflags & VM_FLAG) && (IOPL != 3))
|
||||
{
|
||||
|
||||
@@ -54,14 +54,18 @@ static int rounding_modes[4] = {FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZ
|
||||
|
||||
static __inline void x87_set_mmx()
|
||||
{
|
||||
uint64_t *p;
|
||||
cpu_state.TOP = 0;
|
||||
*(uint64_t *)cpu_state.tag = 0;
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
*p = 0;
|
||||
cpu_state.ismmx = 1;
|
||||
}
|
||||
|
||||
static __inline void x87_emms()
|
||||
{
|
||||
*(uint64_t *)cpu_state.tag = 0x0303030303030303ll;
|
||||
uint64_t *p;
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
*p = 0x0303030303030303ll;
|
||||
cpu_state.ismmx = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,11 +165,14 @@ static int opFCOMP(uint32_t fetchdat)
|
||||
|
||||
static int opFCOMPP(uint32_t fetchdat)
|
||||
{
|
||||
uint64_t *p, *q;
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
if (fplog) pclog("FCOMPP\n");
|
||||
cpu_state.npxs &= ~(C0|C2|C3);
|
||||
if ((*(uint64_t *)&ST(0) == ((uint64_t)1 << 63) && *(uint64_t *)&ST(1) == 0) && is386)
|
||||
p = (uint64_t *)&ST(0);
|
||||
q = (uint64_t *)&ST(1);
|
||||
if ((*p == ((uint64_t)1 << 63) && *q == 0) && is386)
|
||||
cpu_state.npxs |= C0; /*Nasty hack to fix 80387 detection*/
|
||||
else
|
||||
cpu_state.npxs |= x87_compare(ST(0), ST(1));
|
||||
|
||||
@@ -29,12 +29,14 @@ static int opFCLEX(uint32_t fetchdat)
|
||||
|
||||
static int opFINIT(uint32_t fetchdat)
|
||||
{
|
||||
uint64_t *p;
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
cpu_state.npxc = 0x37F;
|
||||
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00);
|
||||
cpu_state.npxs = 0;
|
||||
*(uint64_t *)cpu_state.tag = 0x0303030303030303ll;
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
*p = 0x0303030303030303ll;
|
||||
cpu_state.TOP = 0;
|
||||
cpu_state.ismmx = 0;
|
||||
CLOCK_CYCLES(17);
|
||||
@@ -91,6 +93,7 @@ static int opFSTP(uint32_t fetchdat)
|
||||
|
||||
static int FSTOR()
|
||||
{
|
||||
uint64_t *p;
|
||||
FP_ENTER();
|
||||
switch ((cr0 & 1) | (cpu_state.op32 & 0x100))
|
||||
{
|
||||
@@ -125,9 +128,10 @@ static int FSTOR()
|
||||
cpu_state.ismmx = 0;
|
||||
/*Horrible hack, but as PCem doesn't keep the FPU stack in 80-bit precision at all times
|
||||
something like this is needed*/
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff &&
|
||||
cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff &&
|
||||
!cpu_state.TOP && !(*(uint64_t *)cpu_state.tag))
|
||||
!cpu_state.TOP && !(*p))
|
||||
cpu_state.ismmx = 1;
|
||||
|
||||
CLOCK_CYCLES((cr0 & 1) ? 34 : 44);
|
||||
@@ -151,6 +155,8 @@ static int opFSTOR_a32(uint32_t fetchdat)
|
||||
|
||||
static int FSAVE()
|
||||
{
|
||||
uint64_t *p;
|
||||
|
||||
FP_ENTER();
|
||||
if (fplog) pclog("FSAVE %08X:%08X %i\n", easeg, cpu_state.eaaddr, cpu_state.ismmx);
|
||||
cpu_state.npxs = (cpu_state.npxs & ~(7 << 11)) | (cpu_state.TOP << 11);
|
||||
@@ -287,7 +293,8 @@ static int FSAVE()
|
||||
cpu_state.npxc = 0x37F;
|
||||
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00);
|
||||
cpu_state.npxs = 0;
|
||||
*(uint64_t *)cpu_state.tag = 0x0303030303030303ll;
|
||||
p = (uint64_t *)cpu_state.tag;
|
||||
*p = 0x0303030303030303ll;
|
||||
cpu_state.TOP = 0;
|
||||
cpu_state.ismmx = 0;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#
|
||||
# Modified Makefile for Win32 (MinGW32) environment.
|
||||
#
|
||||
# Version: @(#)Makefile.mingw 1.0.27 2017/06/14
|
||||
# Version: @(#)Makefile.mingw 1.0.29 2017/06/16
|
||||
#
|
||||
# Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
# Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -65,8 +65,8 @@ endif
|
||||
VPATH = . cpu sound sound/resid-fp video lzf network network/slirp win
|
||||
PLAT = win/
|
||||
ifeq ($(X64), y)
|
||||
CPP = g++.exe -m64 -U__unix
|
||||
CC = gcc.exe -m64 -U__unix
|
||||
CPP = g++.exe -m64
|
||||
CC = gcc.exe -m64
|
||||
else
|
||||
CPP = g++.exe -m32
|
||||
CC = gcc.exe -m32
|
||||
@@ -100,7 +100,7 @@ else
|
||||
endif
|
||||
AFLAGS = -msse -msse2 -mfpmath=sse
|
||||
CFLAGS = $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) $(AFLAGS) \
|
||||
-fomit-frame-pointer -mstackrealign
|
||||
-fomit-frame-pointer -mstackrealign -Wall
|
||||
RFLAGS = --input-format=rc -O coff
|
||||
ifeq ($(RELEASE), y)
|
||||
CFLAGS += -DRELEASE_BUILD
|
||||
@@ -141,6 +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 \
|
||||
fdc37c665.o fdc37c669.o fdc37c932fr.o \
|
||||
pc87306.o sis85c471.o w83877f.o \
|
||||
keyboard.o \
|
||||
keyboard_xt.o keyboard_at.o keyboard_pcjr.o \
|
||||
@@ -149,9 +150,8 @@ DEVOBJ = bugger.o lpt.o serial.o \
|
||||
joystick_standard.o joystick_ch_flightstick_pro.o \
|
||||
joystick_sw_pad.o joystick_tm_fcs.o \
|
||||
mouse.o mouse_serial.o mouse_ps2.o mouse_bus.o \
|
||||
fdd.o fdc.o \
|
||||
fdc37c665.o fdc37c669.o fdc37c932fr.o fdi2raw.o \
|
||||
hdd.o \
|
||||
fdd.o fdc.o fdi2raw.o \
|
||||
hdd.o hdd_image.o \
|
||||
mfm_at.o mfm_xebec.o hdd_esdi.o ide.o xtide.o piix.o \
|
||||
disc.o \
|
||||
disc_86f.o disc_fdi.o disc_imd.o disc_img.o \
|
||||
@@ -162,7 +162,11 @@ ifdef USB
|
||||
USBOBJ = usb.o
|
||||
endif
|
||||
NETOBJ = network.o \
|
||||
net_pcap.o net_slirp.o \
|
||||
net_pcap.o \
|
||||
net_slirp.o \
|
||||
bootp.o ip_icmp.o misc.o socket.o tcp_timer.o cksum.o \
|
||||
ip_input.o queue.o tcp_input.o debug.o ip_output.o \
|
||||
sbuf.o tcp_output.o udp.o if.o mbuf.o slirp.o tcp_subr.o \
|
||||
net_ne2000.o
|
||||
SCSIOBJ = scsi.o scsi_disk.o scsi_buslogic.o scsi_aha154x.o
|
||||
SNDOBJ = sound.o \
|
||||
@@ -216,9 +220,6 @@ OBJ = $(MAINOBJ) $(CPUOBJ) $(SYSOBJ) $(DEVOBJ) $(USBOBJ) \
|
||||
$(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) $(WINOBJ)
|
||||
|
||||
LZFOBJ = lzf_c.o lzf_d.o
|
||||
SLIRPOBJ= bootp.o ip_icmp.o misc.o socket.o tcp_timer.o cksum.o \
|
||||
ip_input.o queue.o tcp_input.o debug.o ip_output.o \
|
||||
sbuf.o tcp_output.o udp.o if.o mbuf.o slirp.o tcp_subr.o
|
||||
|
||||
LIBS = -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 -lopenal.dll \
|
||||
-mwindows -lcomctl32 -lwinmm -lwsock32 -liphlpapi -lpsapi \
|
||||
@@ -241,9 +242,9 @@ LIBS = -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 -lopenal.dll \
|
||||
all: $(PROG).exe pcap_if.exe
|
||||
|
||||
|
||||
$(PROG).exe: $(OBJ) $(LZFOBJ) $(SLIRPOBJ)
|
||||
$(PROG).exe: $(OBJ) $(LZFOBJ)
|
||||
@echo Linking $(PROG).exe ..
|
||||
@$(CC) -o $(PROG).exe $(OBJ) $(LZFOBJ) $(SLIRPOBJ) $(LIBS)
|
||||
@$(CC) -o $(PROG).exe $(OBJ) $(LZFOBJ) $(LIBS)
|
||||
ifneq ($(DEBUG), y)
|
||||
@strip $(PROG).exe
|
||||
endif
|
||||
@@ -271,4 +272,259 @@ pcap_if.res: pcap_if.rc
|
||||
@$(WINDRES) $(RFLAGS) -i win/pcap_if.rc -o pcap_if.res
|
||||
|
||||
|
||||
# Module dependencies.
|
||||
acer386sx.o: ibm.h cpu/cpu.h io.h acer386sx.h
|
||||
|
||||
acerm3a.o: ibm.h io.h acerm3a.h
|
||||
|
||||
ali1429.o: ibm.h cpu/cpu.h io.h mem.h ali1429.h
|
||||
|
||||
amstrad.o: ibm.h io.h keyboard.h lpt.h mouse.h amstrad.h
|
||||
|
||||
bugger.o: ibm.h io.h bugger.h
|
||||
|
||||
cdrom.o: 86box.h cdrom.h ibm.h ide.h piix.h scsi.h timer.h \
|
||||
win/plat_iodev.h
|
||||
|
||||
cdrom_ioctl.o: ibm.h cdrom.h cdrom_ioctl.h scsi.h
|
||||
|
||||
cdrom_null.o: ibm.h cdrom.h cdrom_ioctl.h
|
||||
|
||||
compaq.o: ibm.h mem.h
|
||||
|
||||
config.o: cdrom.h config.h device.h disc.h fdc.h fdd.h ibm.h \
|
||||
cpu/cpu.h gameport.h ide.h hdd.h model.h mouse.h \
|
||||
network/network.h nvr.h scsi.h win/plat_joystick.h \
|
||||
win/plat_midi.h sound/snd_dbopl.h sound/snd_mpu401.h \
|
||||
sound/snd_opl.h sound/sound.h video/video.h win/win.h \
|
||||
win/win_language.h
|
||||
|
||||
device.o: ibm.h cpu/cpu.h config.h device.h model.h sound/sound.h
|
||||
|
||||
disc.o: ibm.h config.h disc.h disc_fdi.h disc_img.h disc_86f.h \
|
||||
disc_td0.h disc_imd.h fdc.h fdd.h timer.h
|
||||
|
||||
disc_86f.o: lzf/lzf.h config.h dma.h disc.h disc_86f.h disc_random.h \
|
||||
fdc.h fdd.h ibm.h
|
||||
|
||||
disc_fdi.o: ibm.h disc.h disc_img.h disc_fdi.h fdc.h fdd.h fdi2raw.h \
|
||||
ibm.h disc.h disc_imd.h fdc.h fdd.h ibm.h config.h disc.h \
|
||||
disc_img.h fdc.h fdd.h
|
||||
|
||||
disc_random.o: disc_random.h
|
||||
|
||||
disc_td0.o: ibm.h disc.h disc_td0.h fdc.h fdd.h
|
||||
|
||||
dma.o: ibm.h cpu/x86.h mem.h io.h dma.h
|
||||
|
||||
fdc.o: ibm.h disc.h dma.h fdc.h fdd.h io.h pic.h timer.h
|
||||
|
||||
fdc37c665.o: ibm.h disc.h fdc.h fdd.h ide.h io.h lpt.h serial.h \
|
||||
fdc37c665.h ibm.h disc.h fdc.h fdd.h io.h ide.h \
|
||||
lpt.h serial.h fdc37c669.h
|
||||
|
||||
fdc37c932fr.o: ibm.h disc.h fdc.h fdd.h ide.h io.h lpt.h serial.h \
|
||||
fdc37c932fr.h
|
||||
|
||||
fdd.o: ibm.h disc.h fdc.h fdd.h
|
||||
|
||||
fdi2raw.o: fdi2raw.h ibm.h
|
||||
|
||||
gameport.o: ibm.h cpu/cpu.h device.h io.h timer.h gameport.h \
|
||||
joystick_ch_flightstick_pro.h joystick_standard.h \
|
||||
joystick_sw_pad.h joystick_tm_fcs.h plat_joystick.h
|
||||
|
||||
hdd.o: ibm.h cpu/cpu.h device.h hdd.h model.h hdd_esdi.h \
|
||||
mfm_at.h mfm_xebec.h xtide.h
|
||||
|
||||
hdd_image.o: ibm.h ide.h hdd_image.h
|
||||
|
||||
hdd_esdi.o: ibm.h device.h dma.h hdd_image.h io.h mca.h mem.h \
|
||||
pic.h rom.h timer.h hdd_esdi.h
|
||||
|
||||
headland.o: ibm.h cpu/cpu.h io.h mem.h headland.h
|
||||
|
||||
i430fx.o: ibm.h mem.h pci.h i430fx.h
|
||||
|
||||
i430hx.o: ibm.h io.h mem.h pci.h i430hx.h
|
||||
|
||||
i430lx.o: ibm.h mem.h pci.h i430lx.h
|
||||
|
||||
i430nx.o: ibm.h mem.h pci.h i430nx.h
|
||||
|
||||
i430vx.o: ibm.h io.h mem.h pci.h i430vx.h
|
||||
|
||||
i440fx.o: ibm.h io.h mem.h pci.h i440fx.h
|
||||
|
||||
i82335.o: ibm.h io.h mem.h
|
||||
|
||||
ide.o: 86box.h cdrom.h hdd_image.h ibm.h io.h pic.h timer.h cdrom.h scsi.h ide.h
|
||||
|
||||
intel.o: ibm.h cpu/cpu.h io.h mem.h pit.h timer.h intel.h
|
||||
|
||||
intel_flash.o: ibm.h cpu/cpu.h device.h mem.h model.h rom.h
|
||||
|
||||
io.o: ibm.h io.h
|
||||
|
||||
jim.o: ibm.h io.h
|
||||
|
||||
joystick_ch_flightstick_pro.o: ibm.h device.h timer.h gameport.h \
|
||||
joystick_standard.h plat_joystick.h
|
||||
|
||||
joystick_standard.o: ibm.h device.h timer.h gameport.h \
|
||||
joystick_standard.h plat_joystick.h
|
||||
|
||||
joystick_sw_pad.o: ibm.h device.h timer.h gameport.h \
|
||||
joystick_sw_pad.h plat_joystick.h
|
||||
|
||||
joystick_tm_fcs.o: ibm.h device.h timer.h gameport.h \
|
||||
joystick_standard.h plat_joystick.h
|
||||
|
||||
keyboard.o: ibm.h plat_keyboard.h keyboard.h
|
||||
|
||||
keyboard_amstrad.o: ibm.h io.h mem.h pic.h pit.h timer.h sound/sound.h \
|
||||
sound/snd_speaker.h keyboard.h keyboard_amstrad.h
|
||||
|
||||
keyboard_at.o: ibm.h io.h mem.h pic.h pit.h timer.h disc.h fdc.h \
|
||||
sound/sound.h sound/snd_speaker.h keyboard.h keyboard_at.h
|
||||
|
||||
keyboard_olim24.o: ibm.h io.h mem.h pic.h pit.h timer.h mouse.h \
|
||||
sound/sound.h sound/snd_speaker.h keyboard.h keyboard_olim24.h
|
||||
|
||||
keyboard_pcjr.o: ibm.h io.h mem.h nmi.h pic.h pit.h timer.h \
|
||||
device.h sound/sound.h sound/snd_speaker.h \
|
||||
sound/snd_sn76489.h keyboard.h keyboard_pcjr.h
|
||||
|
||||
keyboard_xt.o: ibm.h io.h mem.h pic.h pit.h timer.h device.h tandy_eeprom.h \
|
||||
sound/sound.h sound/snd_speaker.h keyboard.h keyboard_xt.h
|
||||
|
||||
laserxt.o: ibm.h io.h mem.h
|
||||
|
||||
lpt.o: ibm.h io.h lpt.h
|
||||
|
||||
mca.o: ibm.h io.h mem.h mca.h
|
||||
|
||||
mcr.o: ibm.h
|
||||
|
||||
mem.o: ibm.h cpu/cpu.h cpu/x86_ops.h cpu/x86.h config.h \
|
||||
io.h mem.h rom.h cpu/codegen.h video/video.h
|
||||
|
||||
memregs.o: ibm.h io.h memregs.h
|
||||
|
||||
mfm_at.o: ibm.h device.h hdd_image.h io.h pic.h timer.h mfm_at.h
|
||||
|
||||
mfm_xebec.o: ibm.h device.h dma.h hdd_image.h io.h mem.h pic.h rom.h timer.h mfm_xebec.h
|
||||
|
||||
model.o: ibm.h cpu/cpu.h io.h mem.h rom.h device.h model.h mouse.h \
|
||||
mouse_ps2.h cdrom.h acerm3a.h ali1429.h amstrad.h compaq.h \
|
||||
disc.h dma.h fdc.h fdc37c665.h fdc37c669.h fdc37c932fr.h \
|
||||
gameport.h headland.h i430fx.h i430hx.h i430lx.h i430nx.h \
|
||||
i430vx.h i440fx.h i82335.h ide.h intel.h intel_flash.h jim.h \
|
||||
keyboard_amstrad.h keyboard_at.h keyboard_olim24.h \
|
||||
keyboard_pcjr.h keyboard_xt.h laserxt.h lpt.h mem.h memregs.h \
|
||||
neat.h nmi.h nvr.h olivetti_m24.h opti495.h pc87306.h pci.h \
|
||||
pic.h piix.h pit.h ps1.h ps2.h ps2_mca.h scat.h serial.h \
|
||||
sis496.h sis85c471.h sio.h sound/snd_ps1.h sound/snd_pssj.h \
|
||||
sound/snd_sn76489.h tandy_eeprom.h tandy_rom.h \
|
||||
video/vid_pcjr.h video/vid_tandy.h w83877f.h wd76c10.h \
|
||||
xtide.h bugger.h
|
||||
|
||||
mouse.o: ibm.h mouse.h mouse_serial.h mouse_ps2.h mouse_bus.h \
|
||||
amstrad.h keyboard_olim24.h
|
||||
|
||||
mouse_bus.o: ibm.h io.h pic.h mouse.h mouse_bus.h plat_mouse.h
|
||||
|
||||
mouse_ps2.o: ibm.h keyboard_at.h mouse.h mouse_ps2.h plat_mouse.h
|
||||
|
||||
mouse_serial.o: ibm.h timer.h serial.h mouse.h mouse_serial.h
|
||||
|
||||
neat.o: ibm.h io.h neat.h
|
||||
|
||||
nmi.o: ibm.h io.h nmi.h
|
||||
|
||||
nvr.o: ibm.h cpu/cpu.h device.h io.h mem.h model.h nvr.h \
|
||||
pic.h rom.h timer.h rtc.h
|
||||
|
||||
olivetti_m24.o: ibm.h io.h olivetti_m24.h
|
||||
|
||||
opti495.o: ibm.h cpu/cpu.h io.h mem.h
|
||||
|
||||
pc.o: 86box.h ibm.h mem.h cpu/cpu.h cpu/x86_ops.h cpu/codegen.h \
|
||||
dma.h nvr.h pic.h pit.h timer.h device.h ali1429.h disc.h \
|
||||
disc_86f.h disc_fdi.h disc_imd.h disc_img.h disc_td0.h \
|
||||
disc_random.h config.h fdc.h fdd.h gameport.h plat_joystick.h \
|
||||
plat_midi.h hdd.h ide.h cdrom.h cdrom_ioctl.h cdrom_image.h \
|
||||
cdrom_null.h scsi.h keyboard.h plat_keyboard.h keyboard_at.h \
|
||||
model.h mouse.h plat_mouse.h network/network.h serial.h \
|
||||
sound/sound.h sound/snd_cms.h sound/snd_dbopl.h \
|
||||
sound/snd_mpu401.h sound/snd_opl.h sound/snd_gus.h \
|
||||
sound/snd_sb.h sound/snd_speaker.h sound/snd_ssi2001.h \
|
||||
video/video.h video/vid_voodoo.h amstrad.h win/plat_ui.h
|
||||
|
||||
pc87306.o: ibm.h disc.h fdc.h fdd.h ide.h io.h lpt.h serial.h pc87306.h
|
||||
|
||||
pci.o: ibm.h io.h mem.h pic.h pci.h
|
||||
|
||||
pic.o: ibm.h io.h pic.h pit.h
|
||||
|
||||
piix.o: ibm.h dma.h ide.h io.h mem.h pci.h piix.h
|
||||
|
||||
pit.o: ibm.h cpu/cpu.h dma.h io.h pic.h pit.h device.h timer.h \
|
||||
model.h sound/snd_speaker.h video/video.h
|
||||
|
||||
ppi.o: ibm.h pit.h plat_keyboard.h plat_mouse.h
|
||||
|
||||
ps1.o: ibm.h io.h mem.h ps1.h rom.h lpt.h serial.h
|
||||
|
||||
ps2.o: ibm.h io.h mem.h ps2.h rom.h lpt.h serial.h
|
||||
|
||||
ps2_mca.o: ibm.h cpu/cpu.h cpu/x86.h io.h mca.h mem.h rom.h device.h \
|
||||
lpt.h ps2_mca.h ps2_nvr.h serial.h
|
||||
|
||||
ps2_nvr.o: ibm.h device.h io.h mem.h rom.h ps2_nvr.h
|
||||
|
||||
rom.o: config.h ibm.h mem.h rom.h
|
||||
|
||||
rtc.o: nvr.h rtc.h
|
||||
|
||||
scat.o: ibm.h io.h scat.h mem.h
|
||||
|
||||
scsi.o: 86box.h ibm.h timer.h device.h cdrom.h scsi.h \
|
||||
scsi_aha154x.h scsi_buslogic.h
|
||||
|
||||
scsi_aha154x.o: ibm.h io.h mca.h mem.h mca.h rom.h dma.h pic.h timer.h \
|
||||
device.h cdrom.h scsi.h scsi_disk.h scsi_aha154x.h \
|
||||
|
||||
scsi_buslogic.o: ibm.h io.h mem.h rom.h dma.h pic.h pci.h timer.h \
|
||||
device.h scsi.h scsi_disk.h cdrom.h scsi_buslogic.h
|
||||
|
||||
scsi_disk.o: 86box.h cdrom.h hdd_image.h ibm.h ide.h piix.h scsi.h \
|
||||
scsi_disk.h timer.h win/plat_iodev.h
|
||||
|
||||
serial.o: ibm.h io.h pic.h timer.h serial.h plat_serial.h
|
||||
|
||||
sio.o: ibm.h cdrom.h disc.h dma.h fdc.h keyboard_at.h ide.h \
|
||||
io.h mem.h pci.h sio.h
|
||||
|
||||
sis496.o: ibm.h device.h io.h mem.h pci.h sis496.h
|
||||
|
||||
sis50x.o: ibm.h device.h io.h mem.h pci.h sis50x.h
|
||||
|
||||
sis85c471.o: ibm.h ide.h disc.h fdc.h fdd.h io.h lpt.h serial.h sis85c471.h
|
||||
|
||||
tandy_eeprom.o: ibm.h device.h mem.h io.h rom.h tandy_eeprom.h
|
||||
|
||||
tandy_rom.o: ibm.h device.h io.h mem.h rom.h tandy_rom.h
|
||||
|
||||
timer.o: ibm.h timer.h
|
||||
|
||||
usb.o: ibm.h io.h mem.h usb.h
|
||||
|
||||
w83877f.o: ibm.h disc.h fdc.h fdd.h io.h lpt.h serial.h w83877f.h
|
||||
|
||||
wd76c10.o: ibm.h disc.h fdc.h io.h mem.h serial.h wd76c10.h
|
||||
|
||||
xtide.o: ibm.h io.h mem.h rom.h device.h ide.h xtide.h
|
||||
|
||||
|
||||
# End of Makefile.mingw.
|
||||
|
||||
@@ -1591,8 +1591,8 @@ nic_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
val |= 0x01; /* re-enable IOIN bit */
|
||||
/*FALLTHROUGH*/
|
||||
|
||||
case 0x11: /* PCI_BAR
|
||||
case 0x12: /* PCI_BAR
|
||||
case 0x11: /* PCI_BAR */
|
||||
case 0x12: /* PCI_BAR */
|
||||
case 0x13: /* PCI_BAR */
|
||||
/* Remove old I/O. */
|
||||
nic_ioremove(dev, dev->base_address);
|
||||
@@ -1819,6 +1819,11 @@ nic_rom_init(nic_t *dev, wchar_t *s)
|
||||
uint32_t temp;
|
||||
FILE *f;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dev->bios_addr > 0) {
|
||||
if ((f = romfopen(s, L"rb")) != NULL) {
|
||||
fseek(f, 0L, SEEK_END);
|
||||
@@ -1864,6 +1869,7 @@ nic_init(int board)
|
||||
dev = malloc(sizeof(nic_t));
|
||||
memset(dev, 0x00, sizeof(nic_t));
|
||||
dev->board = board;
|
||||
rom = NULL;
|
||||
switch(dev->board) {
|
||||
case NE2K_NE1000:
|
||||
strcpy(dev->name, "NE1000");
|
||||
|
||||
@@ -67,7 +67,6 @@ slirp_tic(void)
|
||||
static void
|
||||
poll_thread(void *arg)
|
||||
{
|
||||
uint8_t *mac = (uint8_t *)arg;
|
||||
struct queuepacket *qp;
|
||||
event_t *evt;
|
||||
|
||||
@@ -112,8 +111,6 @@ poll_thread(void *arg)
|
||||
int
|
||||
network_slirp_setup(uint8_t *mac, NETRXCB func, void *arg)
|
||||
{
|
||||
int rc;
|
||||
|
||||
pclog("SLiRP: initializing..\n");
|
||||
|
||||
if (slirp_init() != 0) {
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
#include "../device.h"
|
||||
#include "network.h"
|
||||
#include "net_ne2000.h"
|
||||
#include "../WIN/win.h"
|
||||
#include "../WIN/win_language.h"
|
||||
#include "../WIN/plat_ui.h"
|
||||
|
||||
|
||||
static netcard_t net_cards[] = {
|
||||
@@ -112,7 +111,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
|
||||
case NET_TYPE_PCAP:
|
||||
ret = network_pcap_setup(mac, rx, dev);
|
||||
if (ret < 0) {
|
||||
msgbox_error(ghwnd, IDS_2219);
|
||||
plat_msgbox_error(IDS_2219);
|
||||
network_type = NET_TYPE_NONE;
|
||||
}
|
||||
break;
|
||||
@@ -154,8 +153,6 @@ network_close(void)
|
||||
void
|
||||
network_reset(void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
pclog("NETWORK: reset (type=%d, card=%d)\n", network_type, network_card);
|
||||
|
||||
/* Just in case.. */
|
||||
|
||||
@@ -90,7 +90,7 @@ hex_dump(unsigned char *bufp, int len)
|
||||
while (len-- > 0) {
|
||||
c = bufp[addr];
|
||||
if ((addr % 16) == 0)
|
||||
printf("%04x %02x", addr, c);
|
||||
printf("%04lx %02x", addr, c);
|
||||
else
|
||||
printf(" %02x", c);
|
||||
asci[(addr & 15)] = (uint8_t)isprint(c) ? c : '.';
|
||||
@@ -175,7 +175,7 @@ start_cap(char *dev)
|
||||
strftime(temp, sizeof(temp), "%H:%M:%S", ltime);
|
||||
|
||||
/* Process and print the packet. */
|
||||
printf("\n<< %s,%.6d len=%d\n",
|
||||
printf("\n<< %s,%.6ld len=%u\n",
|
||||
temp, hdr->ts.tv_usec, hdr->len);
|
||||
rc = eth_prhdr((unsigned char *)pkt);
|
||||
hex_dump((unsigned char *)pkt+rc, hdr->len-rc);
|
||||
@@ -227,7 +227,6 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
dev_t interfaces[32];
|
||||
dev_t *dev = interfaces;
|
||||
int numdev, i;
|
||||
|
||||
/* Try loading the DLL. */
|
||||
|
||||
@@ -869,6 +869,9 @@ Channel* Channel::BlockTemplate( Chip* chip, Bit32u samples, Bit32s* output ) {
|
||||
return (this + 2);
|
||||
}
|
||||
break;
|
||||
case sm2Percussion:
|
||||
case sm3Percussion:
|
||||
break;
|
||||
}
|
||||
//Init the operators with the the current vibrato and tremolo values
|
||||
Op( 0 )->Prepare( chip );
|
||||
@@ -940,6 +943,9 @@ Channel* Channel::BlockTemplate( Chip* chip, Bit32u samples, Bit32s* output ) {
|
||||
output[ i * 2 + 0 ] += sample & maskLeft;
|
||||
output[ i * 2 + 1 ] += sample & maskRight;
|
||||
break;
|
||||
case sm2Percussion:
|
||||
case sm3Percussion:
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch( mode ) {
|
||||
|
||||
@@ -180,17 +180,15 @@ void ega_jega_render_blit_text(ega_t *ega, int x, int dl, int start, int width,
|
||||
|
||||
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;
|
||||
uint16_t dat = 0, dat2;
|
||||
int x;
|
||||
uint32_t fg = 0, bg = 0;
|
||||
|
||||
/* Temporary for DBCS. */
|
||||
unsigned int chr_left;
|
||||
unsigned int bsattr;
|
||||
unsigned int chr_left = 0;
|
||||
unsigned int bsattr = 0;
|
||||
int chr_wide = 0;
|
||||
uint32_t bg_ex = 0;
|
||||
uint32_t fg_ex = 0;
|
||||
@@ -208,7 +206,7 @@ void ega_render_text_jega(ega_t *ega, int drawcursor)
|
||||
chr = ega->vram[(ega->ma << 1) & ega->vrammask];
|
||||
attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask];
|
||||
|
||||
if (chr_wide = 0)
|
||||
if (chr_wide == 0)
|
||||
{
|
||||
if (ega->RMOD2 & 0x80)
|
||||
{
|
||||
|
||||
@@ -212,7 +212,6 @@ uint8_t et4000w32p_in(uint16_t addr, void *p)
|
||||
{
|
||||
et4000w32p_t *et4000 = (et4000w32p_t *)p;
|
||||
svga_t *svga = &et4000->svga;
|
||||
uint8_t temp;
|
||||
|
||||
if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1))
|
||||
addr ^= 0x60;
|
||||
|
||||
@@ -1464,7 +1464,7 @@ uint8_t s3_accel_read(uint32_t addr, void *p)
|
||||
void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_t *s3)
|
||||
{
|
||||
svga_t *svga = &s3->svga;
|
||||
uint32_t src_dat, dest_dat;
|
||||
uint32_t src_dat = 0, dest_dat;
|
||||
int frgd_mix, bkgd_mix;
|
||||
int clip_t = s3->accel.multifunc[1] & 0xfff;
|
||||
int clip_l = s3->accel.multifunc[2] & 0xfff;
|
||||
|
||||
@@ -22,10 +22,10 @@ static int reg_writes = 0, reg_reads = 0;
|
||||
|
||||
static int dither[4][4] =
|
||||
{
|
||||
0, 4, 1, 5,
|
||||
6, 2, 7, 3,
|
||||
1, 5, 0, 4,
|
||||
7, 3, 6, 2,
|
||||
{0, 4, 1, 5},
|
||||
{6, 2, 7, 3},
|
||||
{1, 5, 0, 4},
|
||||
{7, 3, 6, 2},
|
||||
};
|
||||
|
||||
#define RB_SIZE 256
|
||||
|
||||
@@ -511,15 +511,20 @@ void svga_render_2bpp_highres(svga_t *svga)
|
||||
|
||||
void svga_render_4bpp_lowres(svga_t *svga)
|
||||
{
|
||||
int x;
|
||||
int y_add = (enable_overscan) ? 16 : 0;
|
||||
int x_add = y_add >> 1;
|
||||
int dl = svga_display_line(svga);
|
||||
int offset;
|
||||
uint32_t *p;
|
||||
uint32_t *r, *q;
|
||||
uint8_t edat[4];
|
||||
uint8_t dat;
|
||||
|
||||
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
||||
{
|
||||
int x;
|
||||
int offset = ((8 - svga->scrollcache) << 1) + 16;
|
||||
uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add];
|
||||
offset = ((8 - svga->scrollcache) << 1) + 16;
|
||||
p = &((uint32_t *)buffer32->line[dl])[offset + x_add];
|
||||
|
||||
if (svga->firstline_draw == 2000)
|
||||
svga->firstline_draw = svga->displine;
|
||||
@@ -527,10 +532,9 @@ void svga_render_4bpp_lowres(svga_t *svga)
|
||||
|
||||
for (x = 0; x <= svga->hdisp; x += 16)
|
||||
{
|
||||
uint8_t edat[4];
|
||||
uint8_t dat;
|
||||
|
||||
*(uint32_t *)(&edat[0]) = *(uint32_t *)(&svga->vram[svga->ma]);
|
||||
r = (uint32_t *)(&edat[0]);
|
||||
q = (uint32_t *)(&svga->vram[svga->ma]);
|
||||
*r = *q;
|
||||
svga->ma += 4;
|
||||
svga->ma = svga_mask_addr(svga->ma, svga);
|
||||
|
||||
@@ -559,6 +563,12 @@ void svga_render_4bpp_highres(svga_t *svga)
|
||||
int y_add = (enable_overscan) ? 16 : 0;
|
||||
int x_add = y_add >> 1;
|
||||
int dl = svga_display_line(svga);
|
||||
int x;
|
||||
int offset;
|
||||
uint32_t *p;
|
||||
uint8_t edat[4];
|
||||
uint8_t dat;
|
||||
uint32_t *r, *q;
|
||||
|
||||
if (svga->sc & 1 && !(svga->crtc[0x17] & 1))
|
||||
changed_offset = svga_mask_addr(svga->ma | 0x8000, svga) >> 12;
|
||||
@@ -572,9 +582,8 @@ void svga_render_4bpp_highres(svga_t *svga)
|
||||
|
||||
if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset2] || svga->fullchange)
|
||||
{
|
||||
int x;
|
||||
int offset = (8 - svga->scrollcache) + 24;
|
||||
uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add];
|
||||
offset = (8 - svga->scrollcache) + 24;
|
||||
p = &((uint32_t *)buffer32->line[dl])[offset + x_add];
|
||||
|
||||
if (svga->firstline_draw == 2000)
|
||||
svga->firstline_draw = svga->displine;
|
||||
@@ -582,13 +591,12 @@ void svga_render_4bpp_highres(svga_t *svga)
|
||||
|
||||
for (x = 0; x <= svga->hdisp; x += 8)
|
||||
{
|
||||
uint8_t edat[4];
|
||||
uint8_t dat;
|
||||
|
||||
if (svga->sc & 1 && !(svga->crtc[0x17] & 1))
|
||||
*(uint32_t *)(&edat[0]) = *(uint32_t *)(&svga->vram[svga_mask_addr(svga->ma | 0x8000, svga)]);
|
||||
r = (uint32_t *)(&edat[0]);
|
||||
if (svga->sc & 1 && !(svga->crtc[0x17] & 1))
|
||||
q = (uint32_t *)(&svga->vram[svga_mask_addr(svga->ma | 0x8000, svga)]);
|
||||
else
|
||||
*(uint32_t *)(&edat[0]) = *(uint32_t *)(&svga->vram[svga->ma]);
|
||||
q = (uint32_t *)(&svga->vram[svga->ma]);
|
||||
*r = *q;
|
||||
svga->ma += 4;
|
||||
svga->ma = svga_mask_addr(svga->ma, svga);
|
||||
|
||||
|
||||
@@ -745,6 +745,7 @@ enum
|
||||
LFB_FORMAT_RGB565 = 0,
|
||||
LFB_FORMAT_RGB555 = 1,
|
||||
LFB_FORMAT_ARGB1555 = 2,
|
||||
LFB_FORMAT_XRGB8888 = 4,
|
||||
LFB_FORMAT_ARGB8888 = 5,
|
||||
LFB_FORMAT_DEPTH = 15,
|
||||
LFB_FORMAT_MASK = 15
|
||||
@@ -5408,6 +5409,13 @@ static void voodoo_fb_writel(uint32_t addr, uint32_t val, void *p)
|
||||
count = 2;
|
||||
break;
|
||||
|
||||
case LFB_FORMAT_XRGB8888:
|
||||
colour_data[0].b = val & 0xff;
|
||||
colour_data[0].g = (val >> 8) & 0xff;
|
||||
colour_data[0].r = (val >> 16) & 0xff;
|
||||
write_mask = LFB_WRITE_COLOUR;
|
||||
addr >>= 1;
|
||||
break;
|
||||
case LFB_FORMAT_ARGB8888:
|
||||
colour_data[0].b = val & 0xff;
|
||||
colour_data[0].g = (val >> 8) & 0xff;
|
||||
|
||||
@@ -759,10 +759,14 @@ static inline void voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo
|
||||
addbyte(0x47);
|
||||
addbyte(0xc3);
|
||||
|
||||
if (depth_jump_pos)
|
||||
*(uint8_t *)&code_block[depth_jump_pos] = (block_pos - depth_jump_pos) - 1;
|
||||
if (depth_jump_pos)
|
||||
*(uint8_t *)&code_block[depth_jump_pos2] = (block_pos - depth_jump_pos2) - 1;
|
||||
if (depth_jump_pos)
|
||||
{
|
||||
*(uint8_t *)&code_block[depth_jump_pos] = (block_pos - depth_jump_pos) - 1;
|
||||
}
|
||||
if (depth_jump_pos2)
|
||||
{
|
||||
*(uint8_t *)&code_block[depth_jump_pos2] = (block_pos - depth_jump_pos2) - 1;
|
||||
}
|
||||
|
||||
if ((params->fogMode & (FOG_ENABLE|FOG_CONSTANT|FOG_Z|FOG_ALPHA)) == FOG_ENABLE)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Windows resource script.
|
||||
*
|
||||
* Version: @(#)86Box.rc 1.0.2 2017/06/04
|
||||
* Version: @(#)86Box.rc 1.0.3 2017/06/16
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -384,7 +384,6 @@ BEGIN
|
||||
LTEXT "LUN:",IDT_1724,200,118,38,8
|
||||
COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,170,117,90,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",IDT_1725,131,118,38,8
|
||||
END
|
||||
|
||||
DLG_CFG_HARD_DISKS_ADD DIALOG DISCARDABLE 0, 0, 219, 111
|
||||
@@ -410,67 +409,20 @@ BEGIN
|
||||
LTEXT "File name:",IDT_1731,7,7,204,9
|
||||
COMBOBOX IDC_COMBO_HD_BUS,33,71,58,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Bus:",IDT_1732,7,72,24,8
|
||||
LTEXT "Bus:",IDT_1721,7,72,24,8
|
||||
COMBOBOX IDC_COMBO_HD_CHANNEL,134,71,77,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",IDT_1733,99,72,34,8
|
||||
LTEXT "Channel:",IDT_1722,99,72,34,8
|
||||
COMBOBOX IDC_COMBO_HD_ID,133,71,26,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "ID:",IDT_1734,117,72,15,8
|
||||
LTEXT "ID:",IDT_1723,117,72,15,8
|
||||
COMBOBOX IDC_COMBO_HD_LUN,185,71,26,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "LUN:",IDT_1735,168,72,15,8
|
||||
LTEXT "LUN:",IDT_1724,168,72,15,8
|
||||
COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,134,71,77,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",IDT_1736,99,72,34,8
|
||||
END
|
||||
|
||||
/* Static text label IDs. */
|
||||
#define IDT_1700 1700 // Language:
|
||||
#define IDT_1701 1701 // Machine:
|
||||
#define IDT_1702 1702 // CPU type:
|
||||
#define IDT_1703 1703 // Wait states:
|
||||
#define IDT_1704 1704 // CPU:
|
||||
#define IDT_1705 1705 // MB == IDC_TEXT_MB
|
||||
#define IDT_1706 1706 // Memory:
|
||||
#define IDT_1707 1707 // Video:
|
||||
#define IDT_1708 1708 // Video speed:
|
||||
#define IDT_1709 1709 // Mouse:
|
||||
#define IDT_1710 1710 // Joystick:
|
||||
#define IDT_1711 1711 // Sound card:
|
||||
#define IDT_1712 1712 // MIDI Out Device:
|
||||
#define IDT_1713 1713 // Network type:
|
||||
#define IDT_1714 1714 // PCap device:
|
||||
#define IDT_1715 1715 // Network adapter:
|
||||
#define IDT_1716 1716 // SCSI Controller:
|
||||
#define IDT_1717 1717 // HD Controller:
|
||||
#define IDT_1718 1718 // Tertiary IDE:
|
||||
#define IDT_1719 1719 // Quaternary IDE:
|
||||
#define IDT_1720 1720 // Hard disks:
|
||||
#define IDT_1721 1721 // Bus:
|
||||
#define IDT_1722 1722 // Channel:
|
||||
#define IDT_1723 1723 // ID:
|
||||
#define IDT_1724 1724 // LUN:
|
||||
#define IDT_1725 1725 // Channel:
|
||||
#define IDT_1726 1726 // Sectors:
|
||||
#define IDT_1727 1727 // Heads:
|
||||
#define IDT_1728 1728 // Cylinders:
|
||||
#define IDT_1729 1729 // Size (MB):
|
||||
#define IDT_1730 1730 // Type:
|
||||
#define IDT_1731 1731 // File name:
|
||||
#define IDT_1732 1732 // Bus:
|
||||
#define IDT_1733 1733 // Channel:
|
||||
#define IDT_1734 1734 // ID:
|
||||
#define IDT_1735 1735 // LUN:
|
||||
#define IDT_1736 1736 // Channel:
|
||||
#define IDT_1737 1737 // Floppy drives:
|
||||
#define IDT_1738 1738 // Type:
|
||||
#define IDT_1739 1739 // CD-ROM drives:
|
||||
#define IDT_1740 1740 // Bus:
|
||||
#define IDT_1741 1741 // ID:
|
||||
#define IDT_1742 1742 // LUN:
|
||||
#define IDT_1743 1743 // Channel:
|
||||
|
||||
DLG_CFG_REMOVABLE_DEVICES DIALOG DISCARDABLE 97, 0, 267, 202
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
|
||||
26
src/WIN/plat_ui.h
Normal file
26
src/WIN/plat_ui.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef __unix
|
||||
extern void plat_msgbox_error(int i);
|
||||
extern wchar_t *plat_get_string_from_id(int i);
|
||||
|
||||
#ifndef IDS_2219
|
||||
#define IDS_2219 2219
|
||||
#endif
|
||||
|
||||
#ifndef IDS_2077
|
||||
#define IDS_2077 2077
|
||||
#endif
|
||||
|
||||
#ifndef IDS_2078
|
||||
#define IDS_2078 2078
|
||||
#endif
|
||||
|
||||
#ifndef IDS_2079
|
||||
#define IDS_2079 2079
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern void plat_msgbox_fatal(char *string);
|
||||
extern void get_executable_name(wchar_t *s, int size);
|
||||
extern void set_window_title(wchar_t *s);
|
||||
extern void startblit(void);
|
||||
extern void endblit(void);
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
* NOTE: FIXME: Strings 2176 and 2193 are same.
|
||||
*
|
||||
* Version: @(#)resource.h 1.0.3 2017/06/04
|
||||
* Version: @(#)resource.h 1.0.4 2017/06/16
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -37,52 +37,46 @@
|
||||
#define DLG_CFG_REMOVABLE_DEVICES 119 /* sub-dialog of config */
|
||||
|
||||
/* Static text label IDs. */
|
||||
#define IDT_1700 1700 // Language:
|
||||
#define IDT_1701 1701 // Machine:
|
||||
#define IDT_1702 1702 // CPU type:
|
||||
#define IDT_1703 1703 // Wait states:
|
||||
#define IDT_1704 1704 // CPU:
|
||||
#define IDT_1705 1705 // MB == IDC_TEXT_MB
|
||||
#define IDT_1706 1706 // Memory:
|
||||
#define IDT_1707 1707 // Video:
|
||||
#define IDT_1708 1708 // Video speed:
|
||||
#define IDT_1709 1709 // Mouse:
|
||||
#define IDT_1710 1710 // Joystick:
|
||||
#define IDT_1711 1711 // Sound card:
|
||||
#define IDT_1712 1712 // MIDI Out Device:
|
||||
#define IDT_1713 1713 // Network type:
|
||||
#define IDT_1714 1714 // PCap device:
|
||||
#define IDT_1715 1715 // Network adapter:
|
||||
#define IDT_1716 1716 // SCSI Controller:
|
||||
#define IDT_1717 1717 // HD Controller:
|
||||
#define IDT_1718 1718 // Tertiary IDE:
|
||||
#define IDT_1719 1719 // Quaternary IDE:
|
||||
#define IDT_1720 1720 // Hard disks:
|
||||
#define IDT_1721 1721 // Bus:
|
||||
#define IDT_1722 1722 // Channel:
|
||||
#define IDT_1723 1723 // ID:
|
||||
#define IDT_1724 1724 // LUN:
|
||||
#define IDT_1725 1725 // Channel:
|
||||
#define IDT_1726 1726 // Sectors:
|
||||
#define IDT_1727 1727 // Heads:
|
||||
#define IDT_1728 1728 // Cylinders:
|
||||
#define IDT_1729 1729 // Size (MB):
|
||||
#define IDT_1730 1730 // Type:
|
||||
#define IDT_1731 1731 // File name:
|
||||
#define IDT_1732 1732 // Bus:
|
||||
#define IDT_1733 1733 // Channel:
|
||||
#define IDT_1734 1734 // ID:
|
||||
#define IDT_1735 1735 // LUN:
|
||||
#define IDT_1736 1736 // Channel:
|
||||
#define IDT_1737 1737 // Floppy drives:
|
||||
#define IDT_1738 1738 // Type:
|
||||
#define IDT_1739 1739 // CD-ROM drives:
|
||||
#define IDT_1740 1740 // Bus:
|
||||
#define IDT_1741 1741 // ID:
|
||||
#define IDT_1742 1742 // LUN:
|
||||
#define IDT_1743 1743 // Channel:
|
||||
#define IDT_STEXT 1744 // text in status window
|
||||
#define IDT_SDEVICE 1745 // text in status window
|
||||
#define IDT_1700 1700 /* Language: */
|
||||
#define IDT_1701 1701 /* Machine: */
|
||||
#define IDT_1702 1702 /* CPU type: */
|
||||
#define IDT_1703 1703 /* Wait states: */
|
||||
#define IDT_1704 1704 /* CPU: */
|
||||
#define IDT_1705 1705 /* MB == IDC_TEXT_MB */
|
||||
#define IDT_1706 1706 /* Memory: */
|
||||
#define IDT_1707 1707 /* Video: */
|
||||
#define IDT_1708 1708 /* Video speed: */
|
||||
#define IDT_1709 1709 /* Mouse: */
|
||||
#define IDT_1710 1710 /* Joystick: */
|
||||
#define IDT_1711 1711 /* Sound card: */
|
||||
#define IDT_1712 1712 /* MIDI Out Device: */
|
||||
#define IDT_1713 1713 /* Network type: */
|
||||
#define IDT_1714 1714 /* PCap device: */
|
||||
#define IDT_1715 1715 /* Network adapter: */
|
||||
#define IDT_1716 1716 /* SCSI Controller: */
|
||||
#define IDT_1717 1717 /* HD Controller: */
|
||||
#define IDT_1718 1718 /* Tertiary IDE: */
|
||||
#define IDT_1719 1719 /* Quaternary IDE: */
|
||||
#define IDT_1720 1720 /* Hard disks: */
|
||||
#define IDT_1721 1721 /* Bus: */
|
||||
#define IDT_1722 1722 /* Channel: */
|
||||
#define IDT_1723 1723 /* ID: */
|
||||
#define IDT_1724 1724 /* LUN: */
|
||||
#define IDT_1726 1726 /* Sectors: */
|
||||
#define IDT_1727 1727 /* Heads: */
|
||||
#define IDT_1728 1728 /* Cylinders: */
|
||||
#define IDT_1729 1729 /* Size (MB): */
|
||||
#define IDT_1730 1730 /* Type: */
|
||||
#define IDT_1731 1731 /* File name: */
|
||||
#define IDT_1737 1737 /* Floppy drives: */
|
||||
#define IDT_1738 1738 /* Type: */
|
||||
#define IDT_1739 1739 /* CD-ROM drives: */
|
||||
#define IDT_1740 1740 /* Bus: */
|
||||
#define IDT_1741 1741 /* ID: */
|
||||
#define IDT_1742 1742 /* LUN: */
|
||||
#define IDT_1743 1743 /* Channel: */
|
||||
#define IDT_STEXT 1744 /* text in status window */
|
||||
#define IDT_SDEVICE 1745 /* text in status window */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "plat_mouse.h"
|
||||
#include "plat_midi.h"
|
||||
#include "plat_thread.h"
|
||||
#include "plat_ui.h"
|
||||
|
||||
#include "win.h"
|
||||
#include "win_cgapal.h"
|
||||
@@ -525,12 +526,12 @@ void create_removable_disk_submenu(HMENU m, int id)
|
||||
AppendMenu(m, MF_STRING, IDM_RDISK_IMAGE_WP | id, win_language_get_string_from_id(2220));
|
||||
}
|
||||
|
||||
void get_executable_name(WCHAR *s, int size)
|
||||
void get_executable_name(wchar_t *s, int size)
|
||||
{
|
||||
GetModuleFileName(hinstance, s, size);
|
||||
}
|
||||
|
||||
void set_window_title(WCHAR *s)
|
||||
void set_window_title(wchar_t *s)
|
||||
{
|
||||
if (video_fullscreen)
|
||||
return;
|
||||
|
||||
@@ -83,8 +83,8 @@ extern void joystickconfig_open(HWND hwnd, int joy_nr, int type);
|
||||
extern int getfile(HWND hwnd, char *f, char *fn);
|
||||
extern int getsfile(HWND hwnd, char *f, char *fn);
|
||||
|
||||
extern void get_executable_name(WCHAR *s, int size);
|
||||
extern void set_window_title(WCHAR *s);
|
||||
extern void get_executable_name(wchar_t *s, int size);
|
||||
extern void set_window_title(wchar_t *s);
|
||||
|
||||
extern void startblit(void);
|
||||
extern void endblit(void);
|
||||
|
||||
@@ -71,7 +71,6 @@ static CUSTOMVERTEX d3d_verts[] =
|
||||
int d3d_init(HWND h)
|
||||
{
|
||||
int c;
|
||||
int ret;
|
||||
|
||||
for (c = 0; c < 256; c++)
|
||||
pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2);
|
||||
|
||||
@@ -30,8 +30,6 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
|
||||
{
|
||||
HWND h;
|
||||
int val_int;
|
||||
int num;
|
||||
char s[80];
|
||||
|
||||
switch (message)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ dynld_module(const char *name, dllimp_t *table)
|
||||
HMODULE h;
|
||||
dllimp_t *imp;
|
||||
void *func;
|
||||
char **foo;
|
||||
/* char **foo; */
|
||||
|
||||
/* See if we can load the desired module. */
|
||||
if ((h = LoadLibrary(name)) == NULL) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <shlobj.h>
|
||||
#undef BITMAP
|
||||
|
||||
#include <commdlg.h>
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "../ibm.h"
|
||||
#include "../device.h"
|
||||
#include "../ide.h"
|
||||
#include "plat_ui.h"
|
||||
#include "win.h"
|
||||
#include "win_language.h"
|
||||
|
||||
@@ -82,6 +84,11 @@ LPTSTR win_language_get_string_from_id(int i)
|
||||
return lpResourceString[i - 2048];
|
||||
}
|
||||
|
||||
wchar_t *plat_get_string_from_id(int i)
|
||||
{
|
||||
return (wchar_t *) win_language_get_string_from_id(i);
|
||||
}
|
||||
|
||||
LPTSTR win_language_get_string_from_string(char *str)
|
||||
{
|
||||
return lpResourceString[atoi(str) - 2048];
|
||||
@@ -117,6 +124,11 @@ void msgbox_error(HWND hwndParent, int i)
|
||||
MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[1], MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
void plat_msgbox_error(int i)
|
||||
{
|
||||
msgbox_error(ghwnd, i);
|
||||
}
|
||||
|
||||
void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr)
|
||||
{
|
||||
MessageBox(hwndParent, wstr, lpResourceString[1], MB_OK | MB_ICONWARNING);
|
||||
@@ -139,6 +151,11 @@ void msgbox_fatal(HWND hwndParent, char *string)
|
||||
free(lptsTemp);
|
||||
}
|
||||
|
||||
void plat_msgbox_fatal(char *string)
|
||||
{
|
||||
msgbox_fatal(ghwnd, string);
|
||||
}
|
||||
|
||||
int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save)
|
||||
{
|
||||
OPENFILENAME ofn; /* common dialog box structure */
|
||||
@@ -207,3 +224,47 @@ int file_dlg_st(HWND hwnd, int i, char *fn, int save)
|
||||
{
|
||||
return file_dlg(hwnd, win_language_get_string_from_id(i), fn, save);
|
||||
}
|
||||
|
||||
static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData)
|
||||
{
|
||||
if(uMsg == BFFM_INITIALIZED)
|
||||
{
|
||||
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
WCHAR path[MAX_PATH];
|
||||
|
||||
wchar_t *BrowseFolder(wchar_t *saved_path)
|
||||
{
|
||||
BROWSEINFO bi = { 0 };
|
||||
bi.lpszTitle = L"Browse for folder...";
|
||||
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
||||
bi.lpfn = BrowseCallbackProc;
|
||||
bi.lParam = (LPARAM) saved_path;
|
||||
|
||||
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
|
||||
|
||||
if (pidl != 0)
|
||||
{
|
||||
/* Get the name of the folder and put it in path. */
|
||||
SHGetPathFromIDList(pidl, path);
|
||||
|
||||
/* Free memory used. */
|
||||
#if 0
|
||||
IMalloc *imalloc = 0;
|
||||
if (SUCCEEDED(SHGetMalloc(&imalloc)))
|
||||
{
|
||||
imalloc->Free(pidl);
|
||||
imalloc->Release();
|
||||
}
|
||||
#endif
|
||||
free(pidl);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
@@ -113,25 +113,8 @@ void midi_get_dev_name(int num, char *s)
|
||||
strcpy(s, caps.szPname);
|
||||
}
|
||||
|
||||
static int midi_pos, midi_len;
|
||||
static uint32_t midi_command;
|
||||
static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 1};
|
||||
static int midi_insysex;
|
||||
static char midi_sysex_data[1024+2];
|
||||
|
||||
static void midi_send_sysex()
|
||||
{
|
||||
MIDIHDR hdr;
|
||||
|
||||
hdr.lpData = midi_sysex_data;
|
||||
hdr.dwBufferLength = midi_pos;
|
||||
hdr.dwFlags = 0;
|
||||
|
||||
midiOutPrepareHeader(midi_out_device, &hdr, sizeof(MIDIHDR));
|
||||
midiOutLongMsg(midi_out_device, &hdr, sizeof(MIDIHDR));
|
||||
|
||||
midi_insysex = 0;
|
||||
}
|
||||
static int midi_pos;
|
||||
static uint8_t midi_sysex_data[1024+2];
|
||||
|
||||
void PlayMsg(uint8_t *msg)
|
||||
{
|
||||
@@ -262,7 +245,7 @@ void midi_write(uint8_t val)
|
||||
|
||||
void midi_reset()
|
||||
{
|
||||
uint8_t buf[64], used;
|
||||
uint8_t buf[64];
|
||||
|
||||
/* Flush buffers */
|
||||
midiOutReset(midi_out_device);
|
||||
|
||||
@@ -87,8 +87,6 @@ pclog("%s: queued byte %02x (%d)\n", pp->name, b, pp->icnt+1);
|
||||
int
|
||||
bhtty_sstate(BHTTY *pp, void *arg)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (arg == NULL) {
|
||||
pclog("%s: invalid argument\n", pp->name);
|
||||
@@ -109,8 +107,6 @@ bhtty_sstate(BHTTY *pp, void *arg)
|
||||
int
|
||||
bhtty_gstate(BHTTY *pp, void *arg)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (arg == NULL) {
|
||||
pclog("%s: invalid argument\n", pp->name);
|
||||
@@ -304,8 +300,6 @@ bhtty_raw(BHTTY *pp, void *arg)
|
||||
int
|
||||
bhtty_speed(BHTTY *pp, long speed)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Get the current mode and speed. */
|
||||
if (bhtty_gstate(pp, &pp->dcb) < 0) return(-1);
|
||||
|
||||
@@ -331,7 +325,6 @@ bhtty_flush(BHTTY *pp)
|
||||
{
|
||||
DWORD dwErrs;
|
||||
COMSTAT cs;
|
||||
int i = 0;
|
||||
|
||||
/* First, clear any errors. */
|
||||
(void)ClearCommError(pp->handle, &dwErrs, &cs);
|
||||
|
||||
@@ -1860,7 +1860,7 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
|
||||
int bus = 0;
|
||||
|
||||
for (i = 1799; i < 1803; i++)
|
||||
for (i = IDT_1722; i <= IDT_1724; i++)
|
||||
{
|
||||
h = GetDlgItem(hdlg, i);
|
||||
EnableWindow(h, FALSE);
|
||||
@@ -1892,7 +1892,7 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
switch(bus)
|
||||
{
|
||||
case HDD_BUS_MFM: /* MFM */
|
||||
h = GetDlgItem(hdlg, 1799);
|
||||
h = GetDlgItem(hdlg, IDT_1722);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
@@ -1902,7 +1902,7 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
SendMessage(h, CB_SETCURSEL, is_add_dlg ? new_hdc.mfm_channel : temp_hdc[hdlv_current_sel].mfm_channel, 0);
|
||||
break;
|
||||
case HDD_BUS_RLL: /* RLL */
|
||||
h = GetDlgItem(hdlg, 1799);
|
||||
h = GetDlgItem(hdlg, IDT_1722);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
@@ -1912,7 +1912,7 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
SendMessage(h, CB_SETCURSEL, is_add_dlg ? new_hdc.rll_channel : temp_hdc[hdlv_current_sel].rll_channel, 0);
|
||||
break;
|
||||
case HDD_BUS_XTIDE: /* XT IDE */
|
||||
h = GetDlgItem(hdlg, 1799);
|
||||
h = GetDlgItem(hdlg, IDT_1722);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
@@ -1923,7 +1923,7 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
break;
|
||||
case HDD_BUS_IDE_PIO_ONLY: /* IDE (PIO-only) */
|
||||
case HDD_BUS_IDE_PIO_AND_DMA: /* IDE (PIO and DMA) */
|
||||
h = GetDlgItem(hdlg, 1802);
|
||||
h = GetDlgItem(hdlg, IDT_1722);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
@@ -1934,10 +1934,10 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
break;
|
||||
case HDD_BUS_SCSI: /* SCSI */
|
||||
case HDD_BUS_SCSI_REMOVABLE: /* SCSI (removable) */
|
||||
h = GetDlgItem(hdlg, 1800);
|
||||
h = GetDlgItem(hdlg, IDT_1723);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
h = GetDlgItem(hdlg, 1801);
|
||||
h = GetDlgItem(hdlg, IDT_1724);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
@@ -1956,7 +1956,7 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
|
||||
if ((hd_listview_items == 0) && !is_add_dlg)
|
||||
{
|
||||
h = GetDlgItem(hdlg, 1798);
|
||||
h = GetDlgItem(hdlg, IDT_1721);
|
||||
EnableWindow(h, FALSE);
|
||||
ShowWindow(h, SW_HIDE);
|
||||
|
||||
@@ -1965,7 +1965,7 @@ static void recalc_location_controls(HWND hdlg, int is_add_dlg)
|
||||
}
|
||||
else
|
||||
{
|
||||
h = GetDlgItem(hdlg, 1798);
|
||||
h = GetDlgItem(hdlg, IDT_1721);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
@@ -3130,12 +3130,9 @@ int hard_disk_was_added(void)
|
||||
|
||||
void hard_disk_add_open(HWND hwnd, int is_existing)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
existing = is_existing;
|
||||
hard_disk_added = 0;
|
||||
ret = DialogBox(hinstance, (LPCWSTR)DLG_CFG_HARD_DISKS_ADD,
|
||||
hwnd, win_settings_hard_disks_add_proc);
|
||||
DialogBox(hinstance, (LPCWSTR)DLG_CFG_HARD_DISKS_ADD, hwnd, win_settings_hard_disks_add_proc);
|
||||
}
|
||||
|
||||
int ignore_change = 0;
|
||||
@@ -3758,7 +3755,7 @@ static void cdrom_recalc_location_controls(HWND hdlg)
|
||||
|
||||
int bus = temp_cdrom_drives[cdlv_current_sel].bus_type;
|
||||
|
||||
for (i = 1800; i < 1803; i++)
|
||||
for (i = IDT_1741; i < (IDT_1743 + 1); i++)
|
||||
{
|
||||
h = GetDlgItem(hdlg, i);
|
||||
EnableWindow(h, FALSE);
|
||||
@@ -3779,9 +3776,9 @@ static void cdrom_recalc_location_controls(HWND hdlg)
|
||||
|
||||
switch(bus)
|
||||
{
|
||||
case CDROM_BUS_ATAPI_PIO_ONLY: /* ATAPI (PIO-only) */
|
||||
case CDROM_BUS_ATAPI_PIO_ONLY: /* ATAPI (PIO-only) */
|
||||
case CDROM_BUS_ATAPI_PIO_AND_DMA: /* ATAPI (PIO and DMA) */
|
||||
h = GetDlgItem(hdlg, 1802);
|
||||
h = GetDlgItem(hdlg, IDT_1743);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
@@ -3791,10 +3788,10 @@ static void cdrom_recalc_location_controls(HWND hdlg)
|
||||
SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].ide_channel, 0);
|
||||
break;
|
||||
case CDROM_BUS_SCSI: /* SCSI */
|
||||
h = GetDlgItem(hdlg, 1800);
|
||||
h = GetDlgItem(hdlg, IDT_1741);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
h = GetDlgItem(hdlg, 1801);
|
||||
h = GetDlgItem(hdlg, IDT_1742);
|
||||
ShowWindow(h, SW_SHOW);
|
||||
EnableWindow(h, TRUE);
|
||||
|
||||
|
||||
@@ -51,8 +51,6 @@ using namespace std;
|
||||
|
||||
CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
|
||||
{
|
||||
// file = fopen64(filename, "rb");
|
||||
// error = (file == NULL);
|
||||
memset(fn, 0, sizeof(fn));
|
||||
strcpy(fn, filename);
|
||||
error = false;
|
||||
@@ -60,19 +58,16 @@ CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
|
||||
|
||||
CDROM_Interface_Image::BinaryFile::~BinaryFile()
|
||||
{
|
||||
// delete file;
|
||||
memset(fn, 0, sizeof(fn));
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, uint64_t seek, uint64_t count)
|
||||
{
|
||||
uint64_t offs = 0;
|
||||
file = fopen64(fn, "rb");
|
||||
if (file == NULL) return 0;
|
||||
fseeko64(file, seek, SEEK_SET);
|
||||
offs = fread(buffer, 1, count, file);
|
||||
fread(buffer, 1, count, file);
|
||||
fclose(file);
|
||||
// return (offs == count);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -179,7 +174,7 @@ bool CDROM_Interface_Image::LoadUnloadMedia(bool unload)
|
||||
return true;
|
||||
}
|
||||
|
||||
int CDROM_Interface_Image::GetTrack(int sector)
|
||||
int CDROM_Interface_Image::GetTrack(unsigned int sector)
|
||||
{
|
||||
vector<Track>::iterator i = tracks.begin();
|
||||
vector<Track>::iterator end = tracks.end() - 1;
|
||||
@@ -225,9 +220,6 @@ bool CDROM_Interface_Image::IsMode2(unsigned long sector)
|
||||
|
||||
bool CDROM_Interface_Image::LoadIsoFile(char* filename)
|
||||
{
|
||||
int shift = 0;
|
||||
int totalPregap = 0;
|
||||
|
||||
tracks.clear();
|
||||
|
||||
// data track
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
bool HasDataTrack (void);
|
||||
bool HasAudioTracks (void);
|
||||
|
||||
int GetTrack (int sector);
|
||||
int GetTrack (unsigned int sector);
|
||||
|
||||
private:
|
||||
// player
|
||||
|
||||
@@ -108,7 +108,6 @@ static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf)
|
||||
unsigned char attr;
|
||||
TMSF tmsf;
|
||||
int m = 0, s = 0, f = 0;
|
||||
uint32_t start_msf = 0, end_msf = 0;
|
||||
cdimg[id]->GetAudioTrackInfo(cdimg[id]->GetTrack(pos), number, tmsf, attr);
|
||||
if (attr == DATA_TRACK)
|
||||
{
|
||||
@@ -185,13 +184,6 @@ static void image_stop(uint8_t id)
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
}
|
||||
|
||||
static void image_seek(uint8_t id, uint32_t pos)
|
||||
{
|
||||
if (!cdimg[id] || cdrom_image[id].image_is_iso) return;
|
||||
cdrom_image[id].cd_pos = pos;
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
}
|
||||
|
||||
static int image_ready(uint8_t id)
|
||||
{
|
||||
if (!cdimg[id])
|
||||
@@ -771,14 +763,6 @@ read_mode2:
|
||||
}
|
||||
|
||||
|
||||
static void lba_to_msf(uint8_t *buf, int lba)
|
||||
{
|
||||
lba += 150;
|
||||
buf[0] = (lba / 75) / 60;
|
||||
buf[1] = (lba / 75) % 60;
|
||||
buf[2] = lba % 75;
|
||||
}
|
||||
|
||||
static uint32_t image_size(uint8_t id)
|
||||
{
|
||||
return cdrom_image[id].cdrom_capacity;
|
||||
@@ -905,7 +889,6 @@ static int image_readtoc_raw(uint8_t id, unsigned char *b, int maxlen)
|
||||
int number;
|
||||
unsigned char attr;
|
||||
TMSF tmsf;
|
||||
int lb;
|
||||
|
||||
if (!cdimg[id]) return 0;
|
||||
|
||||
|
||||
@@ -1047,7 +1047,7 @@ split_block_read_iterate:
|
||||
static int ioctl_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack, int msf, int maxlen, int single)
|
||||
{
|
||||
int len=4;
|
||||
long size;
|
||||
DWORD size;
|
||||
int c,d;
|
||||
uint32_t temp;
|
||||
uint32_t last_block;
|
||||
@@ -1156,9 +1156,7 @@ static int ioctl_readtoc_raw(uint8_t id, uint8_t *b, int maxlen)
|
||||
{
|
||||
int len=4;
|
||||
int size;
|
||||
uint32_t temp;
|
||||
int i;
|
||||
int BytesRead = 0;
|
||||
CDROM_READ_TOC_EX toc_ex;
|
||||
CDROM_TOC_FULL_TOC_DATA toc;
|
||||
if (!cdrom_drives[id].host_drive)
|
||||
|
||||
@@ -109,6 +109,7 @@ void config_dump(void)
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void config_free(void)
|
||||
{
|
||||
section_t *current_section;
|
||||
@@ -133,6 +134,7 @@ static void config_free(void)
|
||||
current_section = next_section;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static wchar_t cfgbuffer[1024];
|
||||
@@ -477,7 +479,6 @@ void config_delete_var(char *head, char *name)
|
||||
void config_delete_section_if_empty(char *head)
|
||||
{
|
||||
section_t *section;
|
||||
entry_t *entry;
|
||||
|
||||
section = find_section(head);
|
||||
|
||||
|
||||
@@ -508,10 +508,10 @@ void imd_seek(int drive, int track)
|
||||
int real_sector = 0;
|
||||
int actual_sector = 0;
|
||||
|
||||
char *c_map;
|
||||
char *h_map;
|
||||
char *c_map = NULL;
|
||||
char *h_map = NULL;
|
||||
char *r_map;
|
||||
char *n_map;
|
||||
char *n_map = NULL;
|
||||
uint8_t *data;
|
||||
uint32_t track_buf_pos[2] = { 0, 0 };
|
||||
|
||||
|
||||
@@ -61,38 +61,38 @@ uint8_t xdf_gap3_sizes[2][2] = { { 60, 69 }, { 60, 50 } };
|
||||
uint16_t xdf_trackx_spos[2][8] = { { 0xA7F, 0xF02, 0x11B7, 0xB66, 0xE1B, 0x129E }, { 0x302, 0x7E2, 0xA52, 0x12DA, 0x572, 0xDFA, 0x106A, 0x154A } };
|
||||
|
||||
/* XDF: Layout of the sectors in the image. */
|
||||
xdf_sector_t xdf_img_layout[2][2][46] = { { { 0x8100, 0x8200, 0x8300, 0x8400, 0x8500, 0x8600, 0x8700, 0x8800,
|
||||
0x8101, 0x8201, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600,
|
||||
0x0700, 0x0800, 0,
|
||||
0x8301, 0x8401, 0x8501, 0x8601, 0x8701, 0x8801, 0x8901, 0x8A01,
|
||||
0x8B01, 0x8C01, 0x8D01, 0x8E01, 0x8F01, 0x9001, 0, 0,
|
||||
0, 0, 0 },
|
||||
{ 0x8300, 0x8600, 0x8201, 0x8200, 0x8601, 0x8301 }
|
||||
xdf_sector_t xdf_img_layout[2][2][46] = { { { {0x8100}, {0x8200}, {0x8300}, {0x8400}, {0x8500}, {0x8600}, {0x8700}, {0x8800},
|
||||
{0x8101}, {0x8201}, {0x0100}, {0x0200}, {0x0300}, {0x0400}, {0x0500}, {0x0600},
|
||||
{0x0700}, {0x0800}, { 0},
|
||||
{0x8301}, {0x8401}, {0x8501}, {0x8601}, {0x8701}, {0x8801}, {0x8901}, {0x8A01},
|
||||
{0x8B01}, {0x8C01}, {0x8D01}, {0x8E01}, {0x8F01}, {0x9001}, { 0}, { 0},
|
||||
{ 0}, { 0}, { 0} },
|
||||
{ {0x8300}, {0x8600}, {0x8201}, {0x8200}, {0x8601}, {0x8301} }
|
||||
}, /* 5.25" 2HD */
|
||||
{ { 0x8100, 0x8200, 0x8300, 0x8400, 0x8500, 0x8600, 0x8700, 0x8800,
|
||||
0x8900, 0x8A00, 0x8B00, 0x8101, 0x0100, 0x0200, 0x0300, 0x0400,
|
||||
0x0500, 0x0600, 0x0700, 0x0800, 0, 0, 0,
|
||||
0x8201, 0x8301, 0x8401, 0x8501, 0x8601, 0x8701, 0x8801, 0x8901,
|
||||
0x8A01, 0x8B01, 0x8C01, 0x8D01, 0x8E01, 0x8F01, 0, 0,
|
||||
0, 0, 0, 0x9001, 0x9101, 0x9201, 0x9301 },
|
||||
{ 0x8300, 0x8400, 0x8601, 0x8200, 0x8201, 0x8600, 0x8401, 0x8301 }
|
||||
{ { {0x8100}, {0x8200}, {0x8300}, {0x8400}, {0x8500}, {0x8600}, {0x8700}, {0x8800},
|
||||
{0x8900}, {0x8A00}, {0x8B00}, {0x8101}, {0x0100}, {0x0200}, {0x0300}, {0x0400},
|
||||
{0x0500}, {0x0600}, {0x0700}, {0x0800}, { 0}, { 0}, { 0},
|
||||
{0x8201}, {0x8301}, {0x8401}, {0x8501}, {0x8601}, {0x8701}, {0x8801}, {0x8901},
|
||||
{0x8A01}, {0x8B01}, {0x8C01}, {0x8D01}, {0x8E01}, {0x8F01}, { 0}, { 0},
|
||||
{ 0}, { 0}, { 0}, {0x9001}, {0x9101}, {0x9201}, {0x9301} },
|
||||
{ {0x8300}, {0x8400}, {0x8601}, {0x8200}, {0x8201}, {0x8600}, {0x8401}, {0x8301} }
|
||||
} /* 3.5" 2HD */
|
||||
};
|
||||
|
||||
/* XDF: Layout of the sectors on the disk's track. */
|
||||
xdf_sector_t xdf_disk_layout[2][2][38] = { { { 0x0100, 0x0200, 0x8100, 0x8800, 0x8200, 0x0300, 0x8300, 0x0400,
|
||||
0x8400, 0x0500, 0x8500, 0x0600, 0x8600, 0x0700, 0x8700, 0x0800,
|
||||
0x8D01, 0x8501, 0x8E01, 0x8601, 0x8F01, 0x8701, 0x9001, 0x8801,
|
||||
0x8101, 0x8901, 0x8201, 0x8A01, 0x8301, 0x8B01, 0x8401, 0x8C01 },
|
||||
{ 0x8300, 0x8200, 0x8600, 0x8201, 0x8301, 0x8601 }
|
||||
xdf_sector_t xdf_disk_layout[2][2][38] = { { { {0x0100}, {0x0200}, {0x8100}, {0x8800}, {0x8200}, {0x0300}, {0x8300}, {0x0400},
|
||||
{0x8400}, {0x0500}, {0x8500}, {0x0600}, {0x8600}, {0x0700}, {0x8700}, {0x0800},
|
||||
{0x8D01}, {0x8501}, {0x8E01}, {0x8601}, {0x8F01}, {0x8701}, {0x9001}, {0x8801},
|
||||
{0x8101}, {0x8901}, {0x8201}, {0x8A01}, {0x8301}, {0x8B01}, {0x8401}, {0x8C01} },
|
||||
{ {0x8300}, {0x8200}, {0x8600}, {0x8201}, {0x8301}, {0x8601} }
|
||||
}, /* 5.25" 2HD */
|
||||
{ { 0x0100, 0x8A00, 0x8100, 0x8B00, 0x8200, 0x0200, 0x8300, 0x0300,
|
||||
0x8400, 0x0400, 0x8500, 0x0500, 0x8600, 0x0600, 0x8700, 0x0700,
|
||||
0x8800, 0x0800, 0x8900,
|
||||
0x9001, 0x8701, 0x9101, 0x8801, 0x9201, 0x8901, 0x9301, 0x8A01,
|
||||
0x8101, 0x8B01, 0x8201, 0x8C01, 0x8301, 0x8D01, 0x8401, 0x8E01,
|
||||
0x8501, 0x8F01, 0x8601 },
|
||||
{ 0x8300, 0x8200, 0x8400, 0x8600, 0x8401, 0x8201, 0x8301, 0x8601 },
|
||||
{ { {0x0100}, {0x8A00}, {0x8100}, {0x8B00}, {0x8200}, {0x0200}, {0x8300}, {0x0300},
|
||||
{0x8400}, {0x0400}, {0x8500}, {0x0500}, {0x8600}, {0x0600}, {0x8700}, {0x0700},
|
||||
{0x8800}, {0x0800}, {0x8900},
|
||||
{0x9001}, {0x8701}, {0x9101}, {0x8801}, {0x9201}, {0x8901}, {0x9301}, {0x8A01},
|
||||
{0x8101}, {0x8B01}, {0x8201}, {0x8C01}, {0x8301}, {0x8D01}, {0x8401}, {0x8E01},
|
||||
{0x8501}, {0x8F01}, {0x8601} },
|
||||
{ {0x8300}, {0x8200}, {0x8400}, {0x8600}, {0x8401}, {0x8201}, {0x8301}, {0x8601} },
|
||||
}, /* 3.5" 2HD */
|
||||
};
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ static void write_lock(uint8_t val)
|
||||
|
||||
static void ide_handler()
|
||||
{
|
||||
#if 0
|
||||
uint16_t or_value = 0;
|
||||
if ((romset == ROM_440FX) || (romset == ROM_R418) || (romset == ROM_MB500N))
|
||||
{
|
||||
@@ -65,6 +66,7 @@ static void ide_handler()
|
||||
ide_set_side(0, 0x376 | or_value);
|
||||
ide_pri_enable_ex();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void set_com34_addr()
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <malloc.h>
|
||||
#include "ibm.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "dma.h"
|
||||
#include "hdd_image.h"
|
||||
#include "io.h"
|
||||
#include "mca.h"
|
||||
#include "mem.h"
|
||||
@@ -30,7 +22,8 @@ typedef struct esdi_drive_t
|
||||
int spt, hpc;
|
||||
int tracks;
|
||||
int sectors;
|
||||
FILE *hdfile;
|
||||
int present;
|
||||
int hdc_num;
|
||||
} esdi_drive_t;
|
||||
|
||||
typedef struct esdi_t
|
||||
@@ -395,7 +388,7 @@ static void esdi_callback(void *p)
|
||||
case CMD_READ:
|
||||
ESDI_DRIVE_ONLY();
|
||||
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
{
|
||||
device_not_present(esdi);
|
||||
return;
|
||||
@@ -431,8 +424,7 @@ static void esdi_callback(void *p)
|
||||
{
|
||||
if (esdi->rba >= drive->sectors)
|
||||
fatal("Read past end of drive\n");
|
||||
fseek(drive->hdfile, esdi->rba * 512, SEEK_SET);
|
||||
fread(esdi->data, 512, 1, drive->hdfile);
|
||||
hdd_image_read(drive->hdc_num, esdi->rba, 1, (uint8_t *) esdi->data);
|
||||
update_status_bar_icon(SB_HDD | HDD_BUS_RLL, 1);
|
||||
}
|
||||
while (esdi->data_pos < 256)
|
||||
@@ -471,7 +463,7 @@ static void esdi_callback(void *p)
|
||||
case CMD_WRITE_VERIFY:
|
||||
ESDI_DRIVE_ONLY();
|
||||
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
{
|
||||
device_not_present(esdi);
|
||||
return;
|
||||
@@ -518,8 +510,7 @@ static void esdi_callback(void *p)
|
||||
|
||||
if (esdi->rba >= drive->sectors)
|
||||
fatal("Write past end of drive\n");
|
||||
fseek(drive->hdfile, esdi->rba * 512, SEEK_SET);
|
||||
fwrite(esdi->data, 512, 1, drive->hdfile);
|
||||
hdd_image_write(drive->hdc_num, esdi->rba, 1, (uint8_t *) esdi->data);
|
||||
esdi->rba++;
|
||||
esdi->sector_pos++;
|
||||
update_status_bar_icon(SB_HDD | HDD_BUS_RLL, 1);
|
||||
@@ -545,7 +536,7 @@ static void esdi_callback(void *p)
|
||||
case CMD_READ_VERIFY:
|
||||
ESDI_DRIVE_ONLY();
|
||||
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
{
|
||||
device_not_present(esdi);
|
||||
return;
|
||||
@@ -560,7 +551,7 @@ static void esdi_callback(void *p)
|
||||
case CMD_SEEK:
|
||||
ESDI_DRIVE_ONLY();
|
||||
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
{
|
||||
device_not_present(esdi);
|
||||
return;
|
||||
@@ -575,7 +566,7 @@ static void esdi_callback(void *p)
|
||||
case CMD_GET_DEV_CONFIG:
|
||||
ESDI_DRIVE_ONLY();
|
||||
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
{
|
||||
device_not_present(esdi);
|
||||
return;
|
||||
@@ -799,40 +790,22 @@ static void esdi_mca_write(int port, uint8_t val, void *p)
|
||||
static void loadhd(esdi_t *esdi, int hdc_num, int d, const wchar_t *fn)
|
||||
{
|
||||
esdi_drive_t *drive = &esdi->drives[d];
|
||||
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
/* Try to open existing hard disk image */
|
||||
drive->hdfile = _wfopen(fn, L"rb+");
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
drive->hdfile = _wfopen(fn, L"wb+");
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
pclog("Cannot create file '%s': %s",
|
||||
fn, strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed for another reason */
|
||||
pclog("Cannot open file '%s': %s",
|
||||
fn, strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
int ret = 0;
|
||||
|
||||
ret = hdd_image_load(hdc_num);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
drive->present = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
drive->spt = hdc[hdc_num].spt;
|
||||
drive->hpc = hdc[hdc_num].hpc;
|
||||
drive->tracks = hdc[hdc_num].tracks;
|
||||
drive->sectors = hdc[hdc_num].spt * hdc[hdc_num].hpc * hdc[hdc_num].tracks;
|
||||
drive->hdc_num = hdc_num;
|
||||
drive->present = 1;
|
||||
}
|
||||
|
||||
static void *esdi_init()
|
||||
@@ -878,9 +851,8 @@ static void esdi_close(void *p)
|
||||
for (d = 0; d < 2; d++)
|
||||
{
|
||||
esdi_drive_t *drive = &esdi->drives[d];
|
||||
|
||||
if (drive->hdfile != NULL)
|
||||
fclose(drive->hdfile);
|
||||
|
||||
hdd_image_close(drive->hdc_num);
|
||||
}
|
||||
|
||||
free(esdi);
|
||||
|
||||
441
src/hdd_image.c
Normal file
441
src/hdd_image.c
Normal file
@@ -0,0 +1,441 @@
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ibm.h"
|
||||
#include "ide.h"
|
||||
#include "hdd_image.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FILE *file;
|
||||
uint32_t base;
|
||||
uint32_t last_sector;
|
||||
uint8_t type;
|
||||
uint8_t loaded;
|
||||
} hdd_image_t;
|
||||
|
||||
hdd_image_t hdd_images[HDC_NUM];
|
||||
|
||||
static char empty_sector[512];
|
||||
static char *empty_sector_1mb;
|
||||
|
||||
int hdd_image_do_log = 0;
|
||||
|
||||
void hdd_image_log(const char *format, ...)
|
||||
{
|
||||
#ifdef ENABLE_HDD_IMAGE_LOG
|
||||
if (hdd_image_do_log)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vprintf(format, ap);
|
||||
va_end(ap);
|
||||
fflush(stdout);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int image_is_hdi(const wchar_t *s)
|
||||
{
|
||||
int len;
|
||||
wchar_t ext[5] = { 0, 0, 0, 0, 0 };
|
||||
char *ws = (char *) s;
|
||||
len = wcslen(s);
|
||||
if ((len < 4) || (s[0] == L'.'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memcpy(ext, ws + ((len - 4) << 1), 8);
|
||||
if (wcsicmp(ext, L".HDI") == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int image_is_hdx(const wchar_t *s, int check_signature)
|
||||
{
|
||||
int len;
|
||||
FILE *f;
|
||||
uint64_t filelen;
|
||||
uint64_t signature;
|
||||
char *ws = (char *) s;
|
||||
wchar_t ext[5] = { 0, 0, 0, 0, 0 };
|
||||
len = wcslen(s);
|
||||
if ((len < 4) || (s[0] == L'.'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memcpy(ext, ws + ((len - 4) << 1), 8);
|
||||
if (wcsicmp(ext, L".HDX") == 0)
|
||||
{
|
||||
if (check_signature)
|
||||
{
|
||||
f = _wfopen(s, L"rb");
|
||||
if (!f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
fseeko64(f, 0, SEEK_END);
|
||||
filelen = ftello64(f);
|
||||
fseeko64(f, 0, SEEK_SET);
|
||||
if (filelen < 44)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
fread(&signature, 1, 8, f);
|
||||
fclose(f);
|
||||
if (signature == 0xD778A82044445459ll)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int hdd_image_load(int id)
|
||||
{
|
||||
uint32_t sector_size = 512;
|
||||
uint32_t zero = 0;
|
||||
uint64_t signature = 0xD778A82044445459ll;
|
||||
uint64_t full_size = 0;
|
||||
uint64_t spt = 0, hpc = 0, tracks = 0;
|
||||
int c;
|
||||
uint64_t i = 0, s = 0, t = 0;
|
||||
wchar_t *fn = hdc[id].fn;
|
||||
|
||||
memset(empty_sector, 0, sizeof(empty_sector));
|
||||
|
||||
hdd_images[id].base = 0;
|
||||
hdd_images[id].loaded = 0;
|
||||
|
||||
if (hdd_images[id].file != NULL)
|
||||
{
|
||||
fclose(hdd_images[id].file);
|
||||
hdd_images[id].file = NULL;
|
||||
}
|
||||
|
||||
/* Try to open existing hard disk image */
|
||||
if (fn[0] == '.')
|
||||
{
|
||||
hdd_image_log("File name starts with .\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
hdd_images[id].file = _wfopen(fn, L"rb+");
|
||||
if (hdd_images[id].file == NULL)
|
||||
{
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
if (hdc[id].wp)
|
||||
{
|
||||
hdd_image_log("A write-protected image must exist\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
|
||||
hdd_images[id].file = _wfopen(fn, L"wb+");
|
||||
if (hdd_images[id].file == NULL)
|
||||
{
|
||||
hdd_image_log("Unable to open image\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
hdd_images[id].base = 0x1000;
|
||||
fwrite(&zero, 1, 4, hdd_images[id].file);
|
||||
fwrite(&zero, 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdd_images[id].base), 1, 4, hdd_images[id].file);
|
||||
fwrite(&full_size, 1, 4, hdd_images[id].file);
|
||||
fwrite(§or_size, 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdc[id].spt), 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdc[id].hpc), 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdc[id].tracks), 1, 4, hdd_images[id].file);
|
||||
for (c = 0; c < 0x3f8; c++)
|
||||
{
|
||||
fwrite(&zero, 1, 4, hdd_images[id].file);
|
||||
}
|
||||
hdd_images[id].type = 1;
|
||||
}
|
||||
else if (image_is_hdx(fn, 0))
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
hdd_images[id].base = 0x28;
|
||||
fwrite(&signature, 1, 8, hdd_images[id].file);
|
||||
fwrite(&full_size, 1, 8, hdd_images[id].file);
|
||||
fwrite(§or_size, 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdc[id].spt), 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdc[id].hpc), 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdc[id].tracks), 1, 4, hdd_images[id].file);
|
||||
fwrite(&zero, 1, 4, hdd_images[id].file);
|
||||
fwrite(&zero, 1, 4, hdd_images[id].file);
|
||||
hdd_images[id].type = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
hdd_images[id].type = 0;
|
||||
}
|
||||
hdd_images[id].last_sector = 0;
|
||||
}
|
||||
|
||||
s = full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
|
||||
goto prepare_new_hard_disk;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed for another reason */
|
||||
hdd_image_log("Failed for another reason\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
fseeko64(hdd_images[id].file, 0x8, SEEK_SET);
|
||||
fread(&(hdd_images[id].base), 1, 4, hdd_images[id].file);
|
||||
fseeko64(hdd_images[id].file, 0xC, SEEK_SET);
|
||||
full_size = 0;
|
||||
fread(&full_size, 1, 4, hdd_images[id].file);
|
||||
fseeko64(hdd_images[id].file, 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, hdd_images[id].file);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
hdd_image_log("HDI: Sector size is not 512\n");
|
||||
fclose(hdd_images[id].file);
|
||||
hdd_images[id].file = NULL;
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
fread(&spt, 1, 4, hdd_images[id].file);
|
||||
fread(&hpc, 1, 4, hdd_images[id].file);
|
||||
fread(&tracks, 1, 4, hdd_images[id].file);
|
||||
if (hdc[id].bus == HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
if ((spt != hdc[id].spt) || (hpc != hdc[id].hpc) || (tracks != hdc[id].tracks))
|
||||
{
|
||||
hdd_image_log("HDI: Geometry mismatch\n");
|
||||
fclose(hdd_images[id].file);
|
||||
hdd_images[id].file = NULL;
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
hdc[id].spt = spt;
|
||||
hdc[id].hpc = hpc;
|
||||
hdc[id].tracks = tracks;
|
||||
hdd_images[id].type = 1;
|
||||
}
|
||||
else if (image_is_hdx(fn, 1))
|
||||
{
|
||||
hdd_images[id].base = 0x28;
|
||||
fseeko64(hdd_images[id].file, 8, SEEK_SET);
|
||||
fread(&full_size, 1, 8, hdd_images[id].file);
|
||||
fseeko64(hdd_images[id].file, 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, hdd_images[id].file);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
hdd_image_log("HDX: Sector size is not 512\n");
|
||||
fclose(hdd_images[id].file);
|
||||
hdd_images[id].file = NULL;
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
fread(&spt, 1, 4, hdd_images[id].file);
|
||||
fread(&hpc, 1, 4, hdd_images[id].file);
|
||||
fread(&tracks, 1, 4, hdd_images[id].file);
|
||||
if (hdc[id].bus == HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
if ((spt != hdc[id].spt) || (hpc != hdc[id].hpc) || (tracks != hdc[id].tracks))
|
||||
{
|
||||
hdd_image_log("HDX: Geometry mismatch\n");
|
||||
fclose(hdd_images[id].file);
|
||||
hdd_images[id].file = NULL;
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
hdc[id].spt = spt;
|
||||
hdc[id].hpc = hpc;
|
||||
hdc[id].tracks = tracks;
|
||||
fread(&(hdc[id].at_spt), 1, 4, hdd_images[id].file);
|
||||
fread(&(hdc[id].at_hpc), 1, 4, hdd_images[id].file);
|
||||
hdd_images[id].type = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
hdd_images[id].type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
fseeko64(hdd_images[id].file, 0, SEEK_END);
|
||||
if (ftello64(hdd_images[id].file) < (full_size + hdd_images[id].base))
|
||||
{
|
||||
s = (full_size + hdd_images[id].base) - ftello64(hdd_images[id].file);
|
||||
prepare_new_hard_disk:
|
||||
s >>= 9;
|
||||
t = (s >> 11) << 11;
|
||||
s -= t;
|
||||
t >>= 11;
|
||||
|
||||
empty_sector_1mb = (char *) malloc(1048576);
|
||||
memset(empty_sector_1mb, 0, 1048576);
|
||||
|
||||
if (s > 0)
|
||||
{
|
||||
for (i = 0; i < s; i++)
|
||||
{
|
||||
fwrite(empty_sector, 1, 512, hdd_images[id].file);
|
||||
}
|
||||
}
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
for (i = 0; i < t; i++)
|
||||
{
|
||||
fwrite(empty_sector_1mb, 1, 1045876, hdd_images[id].file);
|
||||
}
|
||||
}
|
||||
|
||||
free(empty_sector_1mb);
|
||||
}
|
||||
|
||||
hdd_images[id].last_sector = (uint32_t) (full_size >> 9) - 1;
|
||||
|
||||
return 1;
|
||||
hdd_images[id].loaded = 1;
|
||||
}
|
||||
|
||||
void hdd_image_seek(uint8_t id, uint32_t sector)
|
||||
{
|
||||
uint64_t addr = sector;
|
||||
addr <<= 9;
|
||||
addr += hdd_images[id].base;
|
||||
|
||||
fseeko64(hdd_images[id].file, addr, SEEK_SET);
|
||||
}
|
||||
|
||||
void hdd_image_read(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
|
||||
{
|
||||
count <<= 9;
|
||||
|
||||
hdd_image_seek(id, sector);
|
||||
memset(buffer, 0, count);
|
||||
fread(buffer, 1, count, hdd_images[id].file);
|
||||
}
|
||||
|
||||
void hdd_image_write(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
|
||||
{
|
||||
count <<= 9;
|
||||
|
||||
hdd_image_seek(id, sector);
|
||||
fwrite(buffer, 1, count, hdd_images[id].file);
|
||||
}
|
||||
|
||||
void hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count)
|
||||
{
|
||||
int i = 0;
|
||||
uint8_t *b;
|
||||
|
||||
b = (uint8_t *) malloc(512);
|
||||
memset(b, 0, 512);
|
||||
|
||||
hdd_image_seek(id, sector);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
fwrite(b, 1, 512, hdd_images[id].file);
|
||||
}
|
||||
|
||||
free(b);
|
||||
}
|
||||
|
||||
uint32_t hdd_image_get_last_sector(uint8_t id)
|
||||
{
|
||||
return hdd_images[id].last_sector;
|
||||
}
|
||||
|
||||
uint8_t hdd_image_get_type(uint8_t id)
|
||||
{
|
||||
return hdd_images[id].type;
|
||||
}
|
||||
|
||||
void hdd_image_specify(uint8_t id, uint64_t hpc, uint64_t spt)
|
||||
{
|
||||
if (hdd_images[id].type == 2)
|
||||
{
|
||||
hdc[id].at_hpc = hpc;
|
||||
hdc[id].at_spt = spt;
|
||||
fseeko64(hdd_images[id].file, 0x20, SEEK_SET);
|
||||
fwrite(&(hdc[id].at_spt), 1, 4, hdd_images[id].file);
|
||||
fwrite(&(hdc[id].at_hpc), 1, 4, hdd_images[id].file);
|
||||
}
|
||||
}
|
||||
|
||||
void hdd_image_unload(uint8_t id, int fn_preserve)
|
||||
{
|
||||
if (wcslen(hdc[id].fn) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hdd_images[id].loaded)
|
||||
{
|
||||
if (hdd_images[id].file != NULL)
|
||||
{
|
||||
fclose(hdd_images[id].file);
|
||||
hdd_images[id].file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
hdd_images[id].last_sector = -1;
|
||||
|
||||
memset(hdc[id].prev_fn, 0, sizeof(hdc[id].prev_fn));
|
||||
if (fn_preserve)
|
||||
{
|
||||
wcscpy(hdc[id].prev_fn, hdc[id].fn);
|
||||
}
|
||||
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
}
|
||||
|
||||
void hdd_image_close(uint8_t id)
|
||||
{
|
||||
if (hdd_images[id].file != NULL)
|
||||
{
|
||||
fclose(hdd_images[id].file);
|
||||
hdd_images[id].file = NULL;
|
||||
}
|
||||
}
|
||||
10
src/hdd_image.h
Normal file
10
src/hdd_image.h
Normal file
@@ -0,0 +1,10 @@
|
||||
extern int hdd_image_load(int id);
|
||||
extern void hdd_image_seek(uint8_t id, uint32_t sector);
|
||||
extern void hdd_image_read(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer);
|
||||
extern void hdd_image_write(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer);
|
||||
extern void hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count);
|
||||
extern uint32_t hdd_image_get_last_sector(uint8_t id);
|
||||
extern uint8_t hdd_image_get_type(uint8_t id);
|
||||
extern void hdd_image_specify(uint8_t id, uint64_t hpc, uint64_t spt);
|
||||
extern void hdd_image_unload(uint8_t id, int fn_preserve);
|
||||
extern void hdd_image_close(uint8_t id);
|
||||
@@ -471,6 +471,8 @@ enum
|
||||
ROM_S1668, /*Tyan Titan-Pro ATX / 440FX / AMI BIOS / SMC FDC37C669*/
|
||||
ROM_IBMPS1_2133,
|
||||
|
||||
ROM_PRESIDENT, /*President Award 430FX PCI / 430FX / Award BIOS / Unknown Super I/O chip*/
|
||||
|
||||
ROM_MAX
|
||||
};
|
||||
|
||||
@@ -793,3 +795,5 @@ extern void status_settext(char *str);
|
||||
#define SB_RDISK 0x20
|
||||
#define SB_HDD 0x40
|
||||
#define SB_TEXT 0x50
|
||||
|
||||
#define UNUSED(x) (void)x
|
||||
|
||||
275
src/ide.c
275
src/ide.c
@@ -9,7 +9,7 @@
|
||||
* Implementation of the IDE emulation for hard disks and ATAPI
|
||||
* CD-ROM devices.
|
||||
*
|
||||
* Version: @(#)ide.c 1.0.1 2017/06/03
|
||||
* Version: @(#)ide.c 1.0.2 2017/06/16
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -18,23 +18,14 @@
|
||||
* Copyright 2016-2017 Miran Grca.
|
||||
* Copyright 2016-2017 TheCollector1995.
|
||||
*/
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "86box.h"
|
||||
#include "cdrom.h"
|
||||
#include "ibm.h"
|
||||
#include "hdd_image.h"
|
||||
#include "io.h"
|
||||
#include "pic.h"
|
||||
#include "timer.h"
|
||||
@@ -163,79 +154,6 @@ int ide_drive_is_cdrom(IDE *ide)
|
||||
}
|
||||
}
|
||||
|
||||
int image_is_hdi(const wchar_t *s)
|
||||
{
|
||||
int len;
|
||||
wchar_t ext[5] = { 0, 0, 0, 0, 0 };
|
||||
char *ws = (char *) s;
|
||||
len = wcslen(s);
|
||||
if ((len < 4) || (s[0] == L'.'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memcpy(ext, ws + ((len - 4) << 1), 8);
|
||||
if (wcsicmp(ext, L".HDI") == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int image_is_hdx(const wchar_t *s, int check_signature)
|
||||
{
|
||||
int len;
|
||||
FILE *f;
|
||||
uint64_t filelen;
|
||||
uint64_t signature;
|
||||
char *ws = (char *) s;
|
||||
wchar_t ext[5] = { 0, 0, 0, 0, 0 };
|
||||
len = wcslen(s);
|
||||
if ((len < 4) || (s[0] == L'.'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memcpy(ext, ws + ((len - 4) << 1), 8);
|
||||
if (wcsicmp(ext, L".HDX") == 0)
|
||||
{
|
||||
if (check_signature)
|
||||
{
|
||||
f = _wfopen(s, L"rb");
|
||||
if (!f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
fseeko64(f, 0, SEEK_END);
|
||||
filelen = ftello64(f);
|
||||
fseeko64(f, 0, SEEK_SET);
|
||||
if (filelen < 44)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
fread(&signature, 1, 8, f);
|
||||
fclose(f);
|
||||
if (signature == 0xD778A82044445459ll)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ide_enable[5] = { 1, 1, 0, 0, 1 };
|
||||
int ide_irq[5] = { 14, 15, 10, 11, 0 };
|
||||
|
||||
@@ -371,7 +289,7 @@ static void ide_identify(IDE *ide)
|
||||
#if 0
|
||||
uint64_t full_size = (hdc[ide->hdc_num].tracks * hdc[ide->hdc_num].hpc * hdc[ide->hdc_num].spt);
|
||||
#endif
|
||||
|
||||
|
||||
device_identify[6] = (ide->hdc_num / 10) + 0x30;
|
||||
device_identify[7] = (ide->hdc_num % 10) + 0x30;
|
||||
ide_log("IDE Identify: %s\n", device_identify);
|
||||
@@ -525,126 +443,22 @@ static void ide_next_sector(IDE *ide)
|
||||
|
||||
static void loadhd(IDE *ide, int d, const wchar_t *fn)
|
||||
{
|
||||
uint32_t sector_size = 512;
|
||||
uint32_t zero = 0;
|
||||
uint64_t signature = 0xD778A82044445459ll;
|
||||
uint64_t full_size = 0;
|
||||
int c;
|
||||
ide->base = 0;
|
||||
ide->hdi = 0;
|
||||
if (ide->hdfile == NULL)
|
||||
int ret = 0;
|
||||
|
||||
ret = hdd_image_load(d);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
/* Try to open existing hard disk image */
|
||||
if (fn[0] == L'.')
|
||||
{
|
||||
ide->type = IDE_NONE;
|
||||
return;
|
||||
}
|
||||
ide->hdfile = _wfopen(fn, L"rb+");
|
||||
if (ide->hdfile == NULL)
|
||||
{
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
ide->hdfile = _wfopen(fn, L"wb+");
|
||||
if (ide->hdfile == NULL)
|
||||
{
|
||||
ide->type = IDE_NONE;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
full_size = hdc[d].spt * hdc[d].hpc * hdc[d].tracks * 512;
|
||||
ide->base = 0x1000;
|
||||
ide->hdi = 1;
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
fwrite(&(ide->base), 1, 4, ide->hdfile);
|
||||
fwrite(&full_size, 1, 4, ide->hdfile);
|
||||
fwrite(§or_size, 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].spt), 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].hpc), 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].tracks), 1, 4, ide->hdfile);
|
||||
for (c = 0; c < 0x3f8; c++)
|
||||
{
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
}
|
||||
}
|
||||
else if (image_is_hdx(fn, 0))
|
||||
{
|
||||
full_size = hdc[d].spt * hdc[d].hpc * hdc[d].tracks * 512;
|
||||
ide->base = 0x28;
|
||||
ide->hdi = 2;
|
||||
fwrite(&signature, 1, 8, ide->hdfile);
|
||||
fwrite(&full_size, 1, 8, ide->hdfile);
|
||||
fwrite(§or_size, 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].spt), 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].hpc), 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].tracks), 1, 4, ide->hdfile);
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
}
|
||||
ide->hdc_num = d;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed for another reason */
|
||||
ide->type = IDE_NONE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
fseeko64(ide->hdfile, 0x8, SEEK_SET);
|
||||
fread(&(ide->base), 1, 4, ide->hdfile);
|
||||
fseeko64(ide->hdfile, 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, ide->hdfile);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
fclose(ide->hdfile);
|
||||
ide->type = IDE_NONE;
|
||||
return;
|
||||
}
|
||||
fread(&(hdc[d].spt), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].hpc), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].tracks), 1, 4, ide->hdfile);
|
||||
ide->hdi = 1;
|
||||
}
|
||||
else if (image_is_hdx(fn, 1))
|
||||
{
|
||||
ide->base = 0x28;
|
||||
fseeko64(ide->hdfile, 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, ide->hdfile);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
fclose(ide->hdfile);
|
||||
ide->type = IDE_NONE;
|
||||
return;
|
||||
}
|
||||
fread(&(hdc[d].spt), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].hpc), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].tracks), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].at_spt), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].at_hpc), 1, 4, ide->hdfile);
|
||||
ide->hdi = 2;
|
||||
}
|
||||
}
|
||||
ide->type = IDE_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
ide->spt = hdc[d].spt;
|
||||
ide->hpc = hdc[d].hpc;
|
||||
ide->tracks = hdc[d].tracks;
|
||||
ide->type = IDE_HDD;
|
||||
|
||||
ide->spt = hdc[d].spt;
|
||||
ide->hpc = hdc[d].hpc;
|
||||
ide->tracks = hdc[d].tracks;
|
||||
ide->type = IDE_HDD;
|
||||
ide->hdc_num = d;
|
||||
ide->hdi = hdd_image_get_type(d);
|
||||
}
|
||||
|
||||
void ide_set_signature(IDE *ide)
|
||||
@@ -771,11 +585,7 @@ void resetide(void)
|
||||
{
|
||||
ide_drives[d].channel = d;
|
||||
ide_drives[d].type = IDE_NONE;
|
||||
if (ide_drives[d].hdfile != NULL)
|
||||
{
|
||||
fclose(ide_drives[d].hdfile);
|
||||
ide_drives[d].hdfile = NULL;
|
||||
}
|
||||
hdd_image_close(ide_drives[d].hdc_num);
|
||||
if (ide_drive_is_cdrom(&ide_drives[d]))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[d]].status = READY_STAT | DSC_STAT;
|
||||
@@ -856,13 +666,6 @@ void ide_write_data(int ide_board, uint32_t val, int length)
|
||||
uint16_t *idebufferw = ide->buffer;
|
||||
uint32_t *idebufferl = (uint32_t *) ide->buffer;
|
||||
|
||||
#if 0
|
||||
if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
ide_log("CD-ROM write data: %04X\n", val);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ide->command == WIN_PACKETCMD)
|
||||
{
|
||||
ide->pos = 0;
|
||||
@@ -1621,8 +1424,6 @@ int times30=0;
|
||||
void callbackide(int ide_board)
|
||||
{
|
||||
IDE *ide, *ide_other;
|
||||
off64_t addr;
|
||||
int c;
|
||||
int64_t snum;
|
||||
int cdrom_id;
|
||||
uint64_t full_size = 0;
|
||||
@@ -1760,10 +1561,8 @@ void callbackide(int ide_board)
|
||||
{
|
||||
goto id_not_found;
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fread(ide->buffer, 512, 1, ide->hdfile);
|
||||
hdd_image_read(ide->hdc_num, ide_get_sector(ide), 1, (uint8_t *) ide->buffer);
|
||||
ide->pos=0;
|
||||
ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT;
|
||||
|
||||
@@ -1781,9 +1580,7 @@ void callbackide(int ide_board)
|
||||
{
|
||||
goto id_not_found;
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fread(ide->buffer, 512, 1, ide->hdfile);
|
||||
hdd_image_read(ide->hdc_num, ide_get_sector(ide), 1, (uint8_t *) ide->buffer);
|
||||
ide->pos=0;
|
||||
|
||||
if (ide_bus_master_read)
|
||||
@@ -1831,9 +1628,7 @@ void callbackide(int ide_board)
|
||||
goto id_not_found;
|
||||
}
|
||||
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fread(ide->buffer, 512, 1, ide->hdfile);
|
||||
hdd_image_read(ide->hdc_num, ide_get_sector(ide), 1, (uint8_t *) ide->buffer);
|
||||
ide->pos=0;
|
||||
ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT;
|
||||
if (!ide->blockcount)
|
||||
@@ -1859,9 +1654,7 @@ void callbackide(int ide_board)
|
||||
{
|
||||
goto id_not_found;
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fwrite(ide->buffer, 512, 1, ide->hdfile);
|
||||
hdd_image_write(ide->hdc_num, ide_get_sector(ide), 1, (uint8_t *) ide->buffer);
|
||||
ide_irq_raise(ide);
|
||||
ide->secount = (ide->secount - 1) & 0xff;
|
||||
if (ide->secount)
|
||||
@@ -1898,9 +1691,7 @@ void callbackide(int ide_board)
|
||||
else
|
||||
{
|
||||
/*DMA successful*/
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fwrite(ide->buffer, 512, 1, ide->hdfile);
|
||||
hdd_image_write(ide->hdc_num, ide_get_sector(ide), 1, (uint8_t *) ide->buffer);
|
||||
|
||||
ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT;
|
||||
|
||||
@@ -1931,9 +1722,7 @@ void callbackide(int ide_board)
|
||||
{
|
||||
goto id_not_found;
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fwrite(ide->buffer, 512, 1, ide->hdfile);
|
||||
hdd_image_write(ide->hdc_num, ide_get_sector(ide), 1, (uint8_t *) ide->buffer);
|
||||
ide->blockcount++;
|
||||
if (ide->blockcount >= ide->blocksize || ide->secount == 1)
|
||||
{
|
||||
@@ -1980,13 +1769,8 @@ void callbackide(int ide_board)
|
||||
{
|
||||
goto id_not_found;
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
memset(ide->buffer, 0, 512);
|
||||
for (c=0;c<ide->secount;c++)
|
||||
{
|
||||
fwrite(ide->buffer, 512, 1, ide->hdfile);
|
||||
}
|
||||
hdd_image_zero(ide->hdc_num, ide_get_sector(ide), ide->secount);
|
||||
|
||||
ide->atastat = READY_STAT | DSC_STAT;
|
||||
ide_irq_raise(ide);
|
||||
|
||||
@@ -2019,14 +1803,7 @@ void callbackide(int ide_board)
|
||||
full_size /= (ide->head+1);
|
||||
full_size /= ide->secount;
|
||||
ide->specify_success = 1;
|
||||
if (ide->hdi == 2)
|
||||
{
|
||||
hdc[ide->hdc_num].at_hpc = ide->head+1;
|
||||
hdc[ide->hdc_num].at_spt = ide->secount;
|
||||
fseeko64(ide->hdfile, 0x20, SEEK_SET);
|
||||
fwrite(&(hdc[ide->hdc_num].at_spt), 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[ide->hdc_num].at_hpc), 1, 4, ide->hdfile);
|
||||
}
|
||||
hdd_image_specify(ide->hdc_num, ide->head + 1, ide->secount);
|
||||
ide->spt=ide->secount;
|
||||
ide->hpc=ide->head+1;
|
||||
ide->atastat = READY_STAT | DSC_STAT;
|
||||
|
||||
@@ -38,7 +38,6 @@ typedef struct {
|
||||
int packetstatus;
|
||||
uint8_t asc;
|
||||
int reset;
|
||||
FILE *hdfile;
|
||||
uint16_t buffer[65536];
|
||||
int irqstat;
|
||||
int service;
|
||||
|
||||
@@ -85,17 +85,21 @@ static uint8_t flash_read(uint32_t addr, void *p)
|
||||
static uint16_t flash_readw(uint32_t addr, void *p)
|
||||
{
|
||||
flash_t *flash = (flash_t *)p;
|
||||
uint16_t *q;
|
||||
addr &= 0x1ffff;
|
||||
if (flash->invert_high_pin) addr ^= 0x10000;
|
||||
return *(uint16_t *)&(flash->array[addr]);
|
||||
q = (uint16_t *)&(flash->array[addr]);
|
||||
return *q;
|
||||
}
|
||||
|
||||
static uint32_t flash_readl(uint32_t addr, void *p)
|
||||
{
|
||||
flash_t *flash = (flash_t *)p;
|
||||
uint32_t *q;
|
||||
addr &= 0x1ffff;
|
||||
if (flash->invert_high_pin) addr ^= 0x10000;
|
||||
return *(uint32_t *)&(flash->array[addr]);
|
||||
q = (uint32_t *)&(flash->array[addr]);
|
||||
return *q;
|
||||
}
|
||||
|
||||
static void flash_write(uint32_t addr, uint8_t val, void *p)
|
||||
|
||||
@@ -112,7 +112,7 @@ void keyboard_amstrad_write(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
uint8_t keyboard_amstrad_read(uint16_t port, void *priv)
|
||||
{
|
||||
uint8_t temp;
|
||||
uint8_t temp = 0xff;
|
||||
switch (port)
|
||||
{
|
||||
case 0x60:
|
||||
|
||||
@@ -45,7 +45,6 @@ static uint8_t mouse_scancodes[7];
|
||||
void keyboard_olim24_poll()
|
||||
{
|
||||
keybsenddelay += (1000 * TIMER_USEC);
|
||||
//pclog("poll %i\n", keyboard_olim24.wantirq);
|
||||
if (keyboard_olim24.wantirq)
|
||||
{
|
||||
keyboard_olim24.wantirq = 0;
|
||||
@@ -108,8 +107,6 @@ void keyboard_olim24_write(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
default:
|
||||
pclog("Bad keyboard command complete %02X\n", keyboard_olim24.command);
|
||||
// dumpregs();
|
||||
// exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,8 +134,6 @@ void keyboard_olim24_write(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
default:
|
||||
pclog("Bad keyboard command %02X\n", val);
|
||||
// dumpregs();
|
||||
// exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,8 +157,7 @@ void keyboard_olim24_write(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
uint8_t keyboard_olim24_read(uint16_t port, void *priv)
|
||||
{
|
||||
uint8_t temp;
|
||||
// pclog("keyboard_olim24 : read %04X ", port);
|
||||
uint8_t temp = 0xff;
|
||||
switch (port)
|
||||
{
|
||||
case 0x60:
|
||||
@@ -193,10 +187,7 @@ uint8_t keyboard_olim24_read(uint16_t port, void *priv)
|
||||
|
||||
default:
|
||||
pclog("\nBad olim24 keyboard read %04X\n", port);
|
||||
// dumpregs();
|
||||
// exit(-1);
|
||||
}
|
||||
// pclog("%02X\n", temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -231,8 +222,6 @@ uint8_t mouse_olim24_poll(int x, int y, int z, int b, void *p)
|
||||
mouse->x += x;
|
||||
mouse->y += y;
|
||||
|
||||
// pclog("mouse_poll - %i, %i %i, %i\n", x, y, mouse->x, mouse->y);
|
||||
|
||||
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
||||
return(0xff);
|
||||
if ((b & 1) && !(mouse->b & 1))
|
||||
@@ -342,7 +331,6 @@ mouse_t mouse_olim24 =
|
||||
|
||||
void keyboard_olim24_init()
|
||||
{
|
||||
//return;
|
||||
io_sethandler(0x0060, 0x0002, keyboard_olim24_read, NULL, NULL, keyboard_olim24_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x0064, 0x0001, keyboard_olim24_read, NULL, NULL, keyboard_olim24_write, NULL, NULL, NULL);
|
||||
keyboard_olim24_reset();
|
||||
|
||||
16
src/mem.c
16
src/mem.c
@@ -700,6 +700,14 @@ int loadbios()
|
||||
biosmask = 0x1ffff;
|
||||
return 1;
|
||||
|
||||
case ROM_PRESIDENT:
|
||||
f = romfopen(L"roms/president/BIOS.BIN", L"rb");
|
||||
if (!f) break;
|
||||
fread(rom, 0x20000, 1, f);
|
||||
fclose(f);
|
||||
biosmask = 0x1ffff;
|
||||
return 1;
|
||||
|
||||
case ROM_P54TP4XE:
|
||||
f = romfopen(L"roms/p54tp4xe/T15I0302.AWD", L"rb");
|
||||
if (!f) break;
|
||||
@@ -716,7 +724,6 @@ int loadbios()
|
||||
biosmask = 0x1ffff;
|
||||
return 1;
|
||||
|
||||
#if 0
|
||||
case ROM_ACERV35N:
|
||||
f = romfopen(L"roms/acerv35n/V35ND1S1.BIN", L"rb");
|
||||
if (!f) break;
|
||||
@@ -724,7 +731,6 @@ int loadbios()
|
||||
fclose(f);
|
||||
biosmask = 0x1ffff;
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
case ROM_P55VA:
|
||||
f = romfopen(L"roms/p55va/VA021297.BIN", L"rb");
|
||||
@@ -1779,11 +1785,13 @@ uint8_t mem_read_romext(uint32_t addr, void *priv)
|
||||
}
|
||||
uint16_t mem_read_romextw(uint32_t addr, void *priv)
|
||||
{
|
||||
return *(uint16_t *)&romext[addr & 0x7fff];
|
||||
uint16_t *p = (uint16_t *)&romext[addr & 0x7fff];
|
||||
return *p;
|
||||
}
|
||||
uint32_t mem_read_romextl(uint32_t addr, void *priv)
|
||||
{
|
||||
return *(uint32_t *)&romext[addr & 0x7fff];
|
||||
uint32_t *p = (uint32_t *)&romext[addr & 0x7fff];
|
||||
return *p;
|
||||
}
|
||||
|
||||
void mem_write_null(uint32_t addr, uint8_t val, void *p)
|
||||
|
||||
81
src/mfm_at.c
81
src/mfm_at.c
@@ -1,16 +1,7 @@
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "ibm.h"
|
||||
#include "hdd_image.h"
|
||||
#include "device.h"
|
||||
#include "io.h"
|
||||
#include "pic.h"
|
||||
@@ -53,7 +44,8 @@ typedef struct mfm_drive_t
|
||||
int cfg_spt;
|
||||
int cfg_hpc;
|
||||
int current_cylinder;
|
||||
FILE *hdfile;
|
||||
int present;
|
||||
int hdc_num;
|
||||
} mfm_drive_t;
|
||||
|
||||
typedef struct mfm_t
|
||||
@@ -163,39 +155,21 @@ static void mfm_next_sector(mfm_t *mfm)
|
||||
static void loadhd(mfm_t *mfm, int c, int d, const wchar_t *fn)
|
||||
{
|
||||
mfm_drive_t *drive = &mfm->drives[c];
|
||||
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
/* Try to open existing hard disk image */
|
||||
drive->hdfile = _wfopen(fn, L"rb+");
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
drive->hdfile = _wfopen(fn, L"wb+");
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
pclog("Cannot create file '%s': %s",
|
||||
fn, strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed for another reason */
|
||||
pclog("Cannot open file '%s': %s",
|
||||
fn, strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
int ret = 0;
|
||||
|
||||
ret = hdd_image_load(d);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
drive->present = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
drive->spt = hdc[d].spt;
|
||||
drive->hpc = hdc[d].hpc;
|
||||
drive->tracks = hdc[d].tracks;
|
||||
drive->hdc_num = d;
|
||||
drive->present = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,14 +207,14 @@ void mfm_write(uint16_t port, uint8_t val, void *p)
|
||||
case 0x1F6: /* Drive/Head */
|
||||
mfm->head = val & 0xF;
|
||||
mfm->drive_sel = (val & 0x10) ? 1 : 0;
|
||||
if (mfm->drives[mfm->drive_sel].hdfile == NULL)
|
||||
mfm->status = 0;
|
||||
else
|
||||
if (mfm->drives[mfm->drive_sel].present)
|
||||
mfm->status = STAT_READY | STAT_DSC;
|
||||
else
|
||||
mfm->status = 0;
|
||||
return;
|
||||
|
||||
case 0x1F7: /* Command register */
|
||||
if (mfm->drives[mfm->drive_sel].hdfile == NULL)
|
||||
if (!mfm->drives[mfm->drive_sel].present)
|
||||
fatal("Command on non-present drive\n");
|
||||
|
||||
mfm_irq_lower(mfm);
|
||||
@@ -462,7 +436,6 @@ void mfm_callback(void *p)
|
||||
mfm_t *mfm = (mfm_t *)p;
|
||||
mfm_drive_t *drive = &mfm->drives[mfm->drive_sel];
|
||||
off64_t addr;
|
||||
int c;
|
||||
|
||||
mfm->callback = 0;
|
||||
if (mfm->reset)
|
||||
@@ -500,8 +473,7 @@ void mfm_callback(void *p)
|
||||
break;
|
||||
}
|
||||
|
||||
fseeko64(drive->hdfile, addr * 512, SEEK_SET);
|
||||
fread(mfm->buffer, 512, 1, drive->hdfile);
|
||||
hdd_image_read(drive->hdc_num, addr, 1, (uint8_t *) mfm->buffer);
|
||||
mfm->pos = 0;
|
||||
mfm->status = STAT_DRQ | STAT_READY | STAT_DSC;
|
||||
mfm_irq_raise(mfm);
|
||||
@@ -517,8 +489,7 @@ void mfm_callback(void *p)
|
||||
mfm_irq_raise(mfm);
|
||||
break;
|
||||
}
|
||||
fseeko64(drive->hdfile, addr * 512, SEEK_SET);
|
||||
fwrite(mfm->buffer, 512, 1, drive->hdfile);
|
||||
hdd_image_write(drive->hdc_num, addr, 1, (uint8_t *) mfm->buffer);
|
||||
mfm_irq_raise(mfm);
|
||||
mfm->secount = (mfm->secount - 1) & 0xff;
|
||||
if (mfm->secount)
|
||||
@@ -552,12 +523,7 @@ void mfm_callback(void *p)
|
||||
mfm_irq_raise(mfm);
|
||||
break;
|
||||
}
|
||||
fseeko64(drive->hdfile, addr * 512, SEEK_SET);
|
||||
memset(mfm->buffer, 0, 512);
|
||||
for (c = 0; c < mfm->secount; c++)
|
||||
{
|
||||
fwrite(mfm->buffer, 512, 1, drive->hdfile);
|
||||
}
|
||||
hdd_image_zero(drive->hdc_num, addr, mfm->secount);
|
||||
mfm->status = STAT_READY | STAT_DSC;
|
||||
mfm_irq_raise(mfm);
|
||||
update_status_bar_icon(SB_HDD | HDD_BUS_MFM, 1);
|
||||
@@ -624,9 +590,8 @@ void mfm_close(void *p)
|
||||
for (d = 0; d < 2; d++)
|
||||
{
|
||||
mfm_drive_t *drive = &mfm->drives[d];
|
||||
|
||||
if (drive->hdfile != NULL)
|
||||
fclose(drive->hdfile);
|
||||
|
||||
hdd_image_close(drive->hdc_num);
|
||||
}
|
||||
|
||||
free(mfm);
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <sys/types.h>
|
||||
#include "ibm.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "dma.h"
|
||||
#include "hdd_image.h"
|
||||
#include "io.h"
|
||||
#include "mem.h"
|
||||
#include "pic.h"
|
||||
@@ -43,7 +36,8 @@ typedef struct mfm_drive_t
|
||||
int cfg_hpc;
|
||||
int cfg_cyl;
|
||||
int current_cylinder;
|
||||
FILE *hdfile;
|
||||
int present;
|
||||
int hdc_num;
|
||||
} mfm_drive_t;
|
||||
|
||||
typedef struct xebec_t
|
||||
@@ -297,6 +291,8 @@ static void xebec_next_sector(xebec_t *xebec)
|
||||
|
||||
static void xebec_callback(void *p)
|
||||
{
|
||||
off64_t addr;
|
||||
|
||||
xebec_t *xebec = (xebec_t *)p;
|
||||
mfm_drive_t *drive;
|
||||
|
||||
@@ -310,13 +306,13 @@ static void xebec_callback(void *p)
|
||||
switch (xebec->command[0])
|
||||
{
|
||||
case CMD_TEST_DRIVE_READY:
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
xebec_error(xebec, ERR_NOT_READY);
|
||||
xebec_complete(xebec);
|
||||
break;
|
||||
|
||||
case CMD_RECALIBRATE:
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
xebec_error(xebec, ERR_NOT_READY);
|
||||
else
|
||||
{
|
||||
@@ -357,8 +353,6 @@ static void xebec_callback(void *p)
|
||||
xebec->sector_count = xebec->command[4];
|
||||
do
|
||||
{
|
||||
off64_t addr;
|
||||
|
||||
if (xebec_get_sector(xebec, &addr))
|
||||
{
|
||||
pclog("xebec_get_sector failed\n");
|
||||
@@ -384,9 +378,6 @@ static void xebec_callback(void *p)
|
||||
|
||||
case CMD_FORMAT_TRACK:
|
||||
{
|
||||
off64_t addr;
|
||||
int c;
|
||||
|
||||
xebec->cylinder = xebec->command[3] | ((xebec->command[2] & 0xc0) << 2);
|
||||
drive->current_cylinder = (xebec->cylinder >= drive->cfg_cyl) ? drive->cfg_cyl-1 : xebec->cylinder;
|
||||
xebec->head = xebec->command[1] & 0x1f;
|
||||
@@ -398,10 +389,8 @@ static void xebec_callback(void *p)
|
||||
xebec_complete(xebec);
|
||||
return;
|
||||
}
|
||||
|
||||
fseeko64(drive->hdfile, addr * 512, SEEK_SET);
|
||||
for (c = 0; c < 17; c++)
|
||||
fwrite(xebec->sector_buf, 512, 1, drive->hdfile);
|
||||
|
||||
hdd_image_zero(drive->hdc_num, addr, 17);
|
||||
|
||||
xebec_complete(xebec);
|
||||
}
|
||||
@@ -420,8 +409,6 @@ static void xebec_callback(void *p)
|
||||
xebec->data_pos = 0;
|
||||
xebec->data_len = 512;
|
||||
{
|
||||
off64_t addr;
|
||||
|
||||
if (xebec_get_sector(xebec, &addr))
|
||||
{
|
||||
xebec_error(xebec, xebec->error);
|
||||
@@ -429,8 +416,7 @@ static void xebec_callback(void *p)
|
||||
return;
|
||||
}
|
||||
|
||||
fseeko64(drive->hdfile, addr * 512, SEEK_SET);
|
||||
fread(xebec->sector_buf, 512, 1, drive->hdfile);
|
||||
hdd_image_read(drive->hdc_num, addr, 1, (uint8_t *) xebec->sector_buf);
|
||||
update_status_bar_icon(SB_HDD | HDD_BUS_MFM, 1);
|
||||
}
|
||||
if (xebec->irq_dma_mask & DMA_ENA)
|
||||
@@ -474,8 +460,6 @@ static void xebec_callback(void *p)
|
||||
|
||||
if (xebec->sector_count)
|
||||
{
|
||||
off64_t addr;
|
||||
|
||||
if (xebec_get_sector(xebec, &addr))
|
||||
{
|
||||
xebec_error(xebec, xebec->error);
|
||||
@@ -483,8 +467,7 @@ static void xebec_callback(void *p)
|
||||
return;
|
||||
}
|
||||
|
||||
fseeko64(drive->hdfile, addr * 512, SEEK_SET);
|
||||
fread(xebec->sector_buf, 512, 1, drive->hdfile);
|
||||
hdd_image_read(drive->hdc_num, addr, 1, (uint8_t *) xebec->sector_buf);
|
||||
update_status_bar_icon(SB_HDD | HDD_BUS_MFM, 1);
|
||||
|
||||
xebec->state = STATE_SEND_DATA;
|
||||
@@ -559,8 +542,6 @@ static void xebec_callback(void *p)
|
||||
memcpy(xebec->sector_buf, xebec->data, 512);
|
||||
|
||||
{
|
||||
off64_t addr;
|
||||
|
||||
if (xebec_get_sector(xebec, &addr))
|
||||
{
|
||||
xebec_error(xebec, xebec->error);
|
||||
@@ -568,8 +549,7 @@ static void xebec_callback(void *p)
|
||||
return;
|
||||
}
|
||||
|
||||
fseeko64(drive->hdfile, addr * 512, SEEK_SET);
|
||||
fwrite(xebec->sector_buf, 512, 1, drive->hdfile);
|
||||
hdd_image_write(drive->hdc_num, addr, 1, (uint8_t *) xebec->sector_buf);
|
||||
}
|
||||
|
||||
update_status_bar_icon(SB_HDD | HDD_BUS_MFM, 1);
|
||||
@@ -596,7 +576,7 @@ static void xebec_callback(void *p)
|
||||
break;
|
||||
|
||||
case CMD_SEEK:
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
xebec_error(xebec, ERR_NOT_READY);
|
||||
else
|
||||
{
|
||||
@@ -766,39 +746,21 @@ static void xebec_callback(void *p)
|
||||
static void loadhd(xebec_t *xebec, int c, int d, const wchar_t *fn)
|
||||
{
|
||||
mfm_drive_t *drive = &xebec->drives[d];
|
||||
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
/* Try to open existing hard disk image */
|
||||
drive->hdfile = _wfopen(fn, L"rb+");
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
drive->hdfile = _wfopen(fn, L"wb+");
|
||||
if (drive->hdfile == NULL)
|
||||
{
|
||||
pclog("Cannot create file '%s': %s",
|
||||
fn, strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed for another reason */
|
||||
pclog("Cannot open file '%s': %s",
|
||||
fn, strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
int ret = 0;
|
||||
|
||||
ret = hdd_image_load(d);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
drive->present = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
drive->spt = hdc[c].spt;
|
||||
drive->hpc = hdc[c].hpc;
|
||||
drive->tracks = hdc[c].tracks;
|
||||
drive->hdc_num = c;
|
||||
drive->present = 1;
|
||||
}
|
||||
|
||||
static struct
|
||||
@@ -822,7 +784,7 @@ static void xebec_set_switches(xebec_t *xebec)
|
||||
{
|
||||
mfm_drive_t *drive = &xebec->drives[d];
|
||||
|
||||
if (!drive->hdfile)
|
||||
if (!drive->present)
|
||||
continue;
|
||||
|
||||
for (c = 0; c < 4; c++)
|
||||
@@ -878,9 +840,8 @@ static void xebec_close(void *p)
|
||||
for (d = 0; d < 2; d++)
|
||||
{
|
||||
mfm_drive_t *drive = &xebec->drives[d];
|
||||
|
||||
if (drive->hdfile != NULL)
|
||||
fclose(drive->hdfile);
|
||||
|
||||
hdd_image_close(drive->hdc_num);
|
||||
}
|
||||
|
||||
free(xebec);
|
||||
|
||||
182
src/model.c
182
src/model.c
@@ -82,6 +82,9 @@
|
||||
#include "sound/snd_ps1.h"
|
||||
#include "sound/snd_pssj.h"
|
||||
#include "sound/snd_sn76489.h"
|
||||
#if 0
|
||||
#include "superio_detect.h"
|
||||
#endif
|
||||
#include "tandy_eeprom.h"
|
||||
#include "tandy_rom.h"
|
||||
#if 0
|
||||
@@ -120,16 +123,21 @@ extern void at_ali1429_init(void);
|
||||
extern void at_headland_init(void);
|
||||
extern void at_opti495_init(void);
|
||||
extern void at_batman_init(void);
|
||||
#if 0
|
||||
extern void at_586mc1_init(void);
|
||||
#endif
|
||||
extern void at_endeavor_init(void);
|
||||
|
||||
extern void at_dtk486_init(void);
|
||||
extern void at_r418_init(void);
|
||||
extern void at_plato_init(void);
|
||||
extern void at_mb500n_init(void);
|
||||
extern void at_president_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);
|
||||
extern void at_acerv35n_init(void);
|
||||
extern void at_p55t2p4_init(void);
|
||||
extern void at_p55tvp4_init(void);
|
||||
extern void at_p55va_init(void);
|
||||
@@ -151,73 +159,77 @@ int romset;
|
||||
|
||||
MODEL models[] =
|
||||
{
|
||||
{"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, 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}
|
||||
{"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_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", 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},
|
||||
{"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},
|
||||
{"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},
|
||||
{"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},
|
||||
{"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},
|
||||
#if 0
|
||||
{"Micro Star 586MC1", ROM_586MC1, "586mc1", {{"Intel", cpus_Pentium5V50}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, 127, 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, 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},
|
||||
{"President Award 430FX PCI", ROM_PRESIDENT, "president", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MODEL_AT | MODEL_HAS_IDE | MODEL_PCI, 1, 128, 1, 127, at_president_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},
|
||||
{"Intel Advanced/ATX", ROM_THOR, "thor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", 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}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_endeavor_init, NULL},
|
||||
{"AOpen AP53", ROM_AP53, "ap53", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", 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}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", 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}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_acerm3a_init, NULL},
|
||||
{"Acer V35n", ROM_ACERV35N, "acerv35n", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MODEL_AT | MODEL_PS2 | MODEL_HAS_IDE | MODEL_PCI, 1, 256, 1, 127, at_acerv35n_init, NULL},
|
||||
{"ASUS P/I-P55T2P4", ROM_P55T2P4, "p55r2p4", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", 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}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", 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}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", 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}
|
||||
};
|
||||
|
||||
|
||||
@@ -646,7 +658,7 @@ void at_premiere_common_init(void)
|
||||
pci_slot(0xc);
|
||||
pci_slot(0xe);
|
||||
pci_slot(0x6);
|
||||
sio_init(2, 0xc, 0xe, 0x6, 0);
|
||||
sio_init(1, 0xc, 0xe, 0x6, 0);
|
||||
fdc37c665_init();
|
||||
intel_batman_init();
|
||||
device_add(&intel_flash_bxt_ami_device);
|
||||
@@ -668,7 +680,7 @@ void at_586mc1_init(void)
|
||||
pci_slot(0xc);
|
||||
pci_slot(0xe);
|
||||
pci_slot(0x6);
|
||||
sio_init(2, 0xc, 0xe, 0x6, 0);
|
||||
sio_init(1, 0xc, 0xe, 0x6, 0);
|
||||
device_add(&intel_flash_bxt_device);
|
||||
secondary_ide_check();
|
||||
}
|
||||
@@ -714,6 +726,24 @@ void at_mb500n_init(void)
|
||||
device_add(&intel_flash_bxt_device);
|
||||
}
|
||||
|
||||
void at_president_init(void)
|
||||
{
|
||||
at_ide_init();
|
||||
memregs_init();
|
||||
pci_init(PCI_CONFIG_TYPE_1);
|
||||
pci_slot(8);
|
||||
pci_slot(9);
|
||||
pci_slot(10);
|
||||
pci_slot(11);
|
||||
i430fx_init();
|
||||
piix_init(7, 8, 9, 10, 11);
|
||||
#if 0
|
||||
superio_detect_init();
|
||||
#endif
|
||||
w83877f_init();
|
||||
device_add(&intel_flash_bxt_device);
|
||||
}
|
||||
|
||||
void at_p54tp4xe_init(void)
|
||||
{
|
||||
at_ide_init();
|
||||
@@ -774,30 +804,28 @@ void at_acerm3a_init(void)
|
||||
pci_slot(0xe);
|
||||
pci_slot(0xf);
|
||||
i430hx_init();
|
||||
piix_init(7, 0xc, 0xd, 0xe, 0xf);
|
||||
piix3_init(7, 0xc, 0xd, 0xe, 0xf);
|
||||
fdc37c932fr_init();
|
||||
acerm3a_io_init();
|
||||
device_add(&intel_flash_bxb_device);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void at_acerv35n_init(void)
|
||||
{
|
||||
at_ide_init();
|
||||
memregs_init();
|
||||
powermate_memregs_init();
|
||||
pci_init(PCI_CONFIG_TYPE_1);
|
||||
pci_slot(0xc);
|
||||
pci_slot(0xd);
|
||||
pci_slot(0xe);
|
||||
pci_slot(0xf);
|
||||
pci_slot(0x11);
|
||||
pci_slot(0x12);
|
||||
pci_slot(0x13);
|
||||
pci_slot(0x14);
|
||||
i430hx_init();
|
||||
piix_init(7, 0xc, 0xd, 0xe, 0xf);
|
||||
piix3_init(7, 0x11, 0x12, 0x13, 0x14);
|
||||
fdc37c932fr_init();
|
||||
acerm3a_io_init();
|
||||
device_add(&intel_flash_bxb_device);
|
||||
}
|
||||
#endif
|
||||
|
||||
void at_p55t2p4_init(void)
|
||||
{
|
||||
|
||||
@@ -380,7 +380,7 @@ static uint8_t
|
||||
bm_read(uint16_t port, void *priv)
|
||||
{
|
||||
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
||||
uint8_t r;
|
||||
uint8_t r = 0xff;
|
||||
|
||||
if (ms->flags & MOUSE_LOGITECH)
|
||||
r = lt_read(ms, port - ms->port);
|
||||
|
||||
23
src/pc.c
23
src/pc.c
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Emulation core dispatcher.
|
||||
*
|
||||
* Version: @(#)pc.c 1.0.3 2017/06/03
|
||||
* Version: @(#)pc.c 1.0.4 2017/06/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -73,10 +73,11 @@
|
||||
#include "video/video.h"
|
||||
#include "video/vid_voodoo.h"
|
||||
#include "amstrad.h"
|
||||
#include "win.h"
|
||||
#include "win_language.h"
|
||||
#include "plat_ui.h"
|
||||
#ifdef WALTJE
|
||||
# define UNICODE
|
||||
# include "plat_dir.h"
|
||||
# undef UNICODE
|
||||
#endif
|
||||
|
||||
|
||||
@@ -187,7 +188,7 @@ void fatal(const char *format, ...)
|
||||
{
|
||||
*newline = 0;
|
||||
}
|
||||
msgbox_fatal(ghwnd, msg);
|
||||
plat_msgbox_fatal(msg);
|
||||
#endif
|
||||
dumppic();
|
||||
dumpregs(1);
|
||||
@@ -288,12 +289,15 @@ void initpc(int argc, wchar_t *argv[])
|
||||
wchar_t *p;
|
||||
wchar_t *config_file = NULL;
|
||||
int c;
|
||||
FILE *ff;
|
||||
get_executable_name(pcempath, 511);
|
||||
pclog("executable_name = %ws\n", pcempath);
|
||||
p=get_filename_w(pcempath);
|
||||
*p=L'\0';
|
||||
pclog("path = %ws\n", pcempath);
|
||||
#ifdef WALTJE
|
||||
DIR *dir;
|
||||
struct direct *dp;
|
||||
#endif
|
||||
|
||||
for (c = 1; c < argc; c++)
|
||||
{
|
||||
@@ -324,9 +328,6 @@ void initpc(int argc, wchar_t *argv[])
|
||||
{
|
||||
/* some (undocumented) test function here.. */
|
||||
#ifdef WALTJE
|
||||
DIR *dir;
|
||||
struct direct *dp;
|
||||
|
||||
dir = opendirw(pcempath);
|
||||
if (dir != NULL) {
|
||||
printf("Directory '%ws':\n", pcempath);
|
||||
@@ -577,8 +578,8 @@ int serial_fifo_read, serial_fifo_write;
|
||||
|
||||
int emu_fps = 0;
|
||||
|
||||
static WCHAR wmodel[2048];
|
||||
static WCHAR wcpu[2048];
|
||||
static wchar_t wmodel[2048];
|
||||
static wchar_t wcpu[2048];
|
||||
|
||||
void runpc(void)
|
||||
{
|
||||
@@ -659,7 +660,7 @@ void runpc(void)
|
||||
win_title_update=0;
|
||||
mbstowcs(wmodel, model_getname(), strlen(model_getname()) + 1);
|
||||
mbstowcs(wcpu, models[model].cpu[cpu_manufacturer].cpus[cpu].name, strlen(models[model].cpu[cpu_manufacturer].cpus[cpu].name) + 1);
|
||||
_swprintf(s, L"%s v%s - %i%% - %s - %s - %s", EMU_NAME_W, EMU_VERSION_W, fps, wmodel, wcpu, (!mousecapture) ? win_language_get_string_from_id(2077) : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? win_language_get_string_from_id(2078) : win_language_get_string_from_id(2079)));
|
||||
_swprintf(s, L"%s v%s - %i%% - %s - %s - %s", EMU_NAME_W, EMU_VERSION_W, fps, wmodel, wcpu, (!mousecapture) ? plat_get_string_from_id(IDS_2077) : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? plat_get_string_from_id(IDS_2078) : plat_get_string_from_id(IDS_2079)));
|
||||
set_window_title(s);
|
||||
}
|
||||
done++;
|
||||
|
||||
@@ -436,7 +436,7 @@ uint8_t pit_read(uint16_t addr, void *p)
|
||||
{
|
||||
PIT *pit = (PIT *)p;
|
||||
int t;
|
||||
uint8_t temp;
|
||||
uint8_t temp = 0xff;
|
||||
cycles -= (int)PITCONST;
|
||||
switch (addr&3)
|
||||
{
|
||||
|
||||
14
src/ps1.c
14
src/ps1.c
@@ -295,13 +295,8 @@ void ps1mb_m2121_init()
|
||||
MEM_MAPPING_EXTERNAL);
|
||||
ps1_190 = 0;
|
||||
|
||||
lpt1_remove();
|
||||
lpt2_remove();
|
||||
lpt1_init(0x3bc);
|
||||
|
||||
serial_remove(1);
|
||||
serial_remove(2);
|
||||
|
||||
|
||||
mem_remap_top_384k();
|
||||
}
|
||||
|
||||
@@ -315,12 +310,7 @@ void ps1mb_m2133_init()
|
||||
|
||||
ps1_190 = 0;
|
||||
|
||||
lpt1_remove();
|
||||
lpt2_remove();
|
||||
lpt1_init(0x3bc);
|
||||
|
||||
serial_remove(1);
|
||||
serial_remove(2);
|
||||
|
||||
|
||||
mem_remap_top_384k();
|
||||
}
|
||||
|
||||
@@ -126,13 +126,8 @@ void ps2board_init()
|
||||
io_sethandler(0x0324, 0x0001, ps2_read, NULL, NULL, ps2_write, NULL, NULL, NULL);
|
||||
|
||||
ps2_190 = 0;
|
||||
|
||||
lpt1_remove();
|
||||
lpt2_remove();
|
||||
|
||||
lpt1_init(0x3bc);
|
||||
|
||||
serial_remove(1);
|
||||
serial_remove(2);
|
||||
|
||||
memset(&ps2_hd, 0, sizeof(ps2_hd));
|
||||
}
|
||||
|
||||
@@ -552,12 +552,7 @@ static void ps2_mca_board_common_init()
|
||||
|
||||
ps2.setup = 0xff;
|
||||
|
||||
lpt1_remove();
|
||||
lpt2_remove();
|
||||
lpt1_init(0x3bc);
|
||||
|
||||
serial_remove(1);
|
||||
serial_remove(2);
|
||||
}
|
||||
|
||||
void ps2_mca_board_model_50_init()
|
||||
@@ -701,7 +696,7 @@ void ps2_mca_board_model_80_type2_init()
|
||||
|
||||
mem_remap_top_256k();
|
||||
ps2.split_addr = mem_size * 1024;
|
||||
mca_init(8);
|
||||
mca_init(24);
|
||||
|
||||
ps2.planar_read = model_80_read;
|
||||
ps2.planar_write = model_80_write;
|
||||
@@ -746,7 +741,7 @@ void ps2_mca_board_model_80_type2_init()
|
||||
if (mem_size > 4096)
|
||||
{
|
||||
/* Only 4 MB supported on planar, create a memory expansion card for the rest */
|
||||
mem_mapping_set_addr(&ram_high_mapping, 0x100000, 0x300000);
|
||||
mem_mapping_set_addr(&ram_high_mapping, 0x100000, 0x800000);
|
||||
|
||||
ps2.mem_pos_regs[0] = 0xff;
|
||||
ps2.mem_pos_regs[1] = 0xfc;
|
||||
|
||||
@@ -949,15 +949,6 @@ aha_reset(aha_t *dev)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
aha_softreset(void)
|
||||
{
|
||||
if (ResetDev != NULL) {
|
||||
aha_reset(ResetDev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
aha_reset_ctrl(aha_t *dev, uint8_t Reset)
|
||||
{
|
||||
@@ -1483,8 +1474,8 @@ aha_0x01:
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
dev->DataBuf[0] = dev->aha.bid;
|
||||
dev->DataBuf[1] = 0x30;
|
||||
dev->DataBuf[0] = (dev->chip != CHIP_AHA1640) ? dev->aha.bid : 0x42;
|
||||
dev->DataBuf[1] = (dev->chip != CHIP_AHA1640) ? 0x30 : 0x42;
|
||||
dev->DataBuf[2] = dev->aha.fwh;
|
||||
dev->DataBuf[3] = dev->aha.fwl;
|
||||
dev->DataReplyLeft = 4;
|
||||
@@ -1796,12 +1787,12 @@ aha_disk_cmd(aha_t *dev)
|
||||
pclog("SCSI Cdb[%i]=%i\n", i, req->CmdBlock.common.Cdb[i]);
|
||||
}
|
||||
|
||||
memset(temp_cdb, 0, shdc[hdc_id].cdb_len);
|
||||
if (req->CmdBlock.common.CdbLength <= shdc[hdc_id].cdb_len) {
|
||||
memset(temp_cdb, 0, 12);
|
||||
if (req->CmdBlock.common.CdbLength <= 12) {
|
||||
memcpy(temp_cdb, req->CmdBlock.common.Cdb,
|
||||
req->CmdBlock.common.CdbLength);
|
||||
} else {
|
||||
memcpy(temp_cdb, req->CmdBlock.common.Cdb, shdc[hdc_id].cdb_len);
|
||||
memcpy(temp_cdb, req->CmdBlock.common.Cdb, 12);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2147,7 +2138,38 @@ uint8_t aha_mca_read(int port, void *p)
|
||||
return dev->pos_regs[port & 7];
|
||||
}
|
||||
|
||||
static uint16_t aha_mca_addr[6] = {0x130, 0x134, 0x230, 0x234, 0x330, 0x334};
|
||||
uint16_t aha_mca_get_port(uint8_t pos_port)
|
||||
{
|
||||
uint16_t addr = 0;
|
||||
switch (pos_port & 0xC7)
|
||||
{
|
||||
case 0x01:
|
||||
addr = 0x130;
|
||||
break;
|
||||
|
||||
case 0x02:
|
||||
addr = 0x230;
|
||||
break;
|
||||
|
||||
case 0x03:
|
||||
addr = 0x330;
|
||||
break;
|
||||
|
||||
case 0x41:
|
||||
addr = 0x134;
|
||||
break;
|
||||
|
||||
case 0x42:
|
||||
addr = 0x234;
|
||||
break;
|
||||
|
||||
case 0x43:
|
||||
addr = 0x334;
|
||||
break;
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
void aha_mca_write(int port, uint8_t val, void *p)
|
||||
{
|
||||
@@ -2157,18 +2179,21 @@ void aha_mca_write(int port, uint8_t val, void *p)
|
||||
if (port < 0x102)
|
||||
return;
|
||||
|
||||
addr = aha_mca_addr[dev->pos_regs[4] & 6];
|
||||
io_removehandler(addr, 0x0004, aha_read, aha_readw, NULL, aha_write, aha_writew, NULL, dev);
|
||||
|
||||
addr = aha_mca_get_port(dev->pos_regs[3]);
|
||||
io_removehandler(addr, 0x0004, aha_read, aha_readw, NULL, aha_write, aha_writew, NULL, dev);
|
||||
|
||||
dev->pos_regs[port & 7] = val;
|
||||
|
||||
if (dev->pos_regs[2] & 1)
|
||||
{
|
||||
addr = aha_mca_get_port(dev->pos_regs[3]);
|
||||
io_sethandler(addr, 0x0004, aha_read, aha_readw, NULL, aha_write, aha_writew, NULL, dev);
|
||||
}
|
||||
|
||||
dev->Irq = (dev->pos_regs[4] & 0x7) + 8;
|
||||
dev->DmaChannel = dev->pos_regs[5] & 0xf;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
aha_device_reset(void *p)
|
||||
{
|
||||
@@ -2222,14 +2247,6 @@ aha_init(int chip, int has_bios)
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->chip == CHIP_AHA1640)
|
||||
{
|
||||
pclog("Aha1640 initialized\n");
|
||||
mca_add(aha_mca_read, aha_mca_write, dev);
|
||||
dev->pos_regs[0] = 0x1F;
|
||||
dev->pos_regs[1] = 0x0F;
|
||||
}
|
||||
|
||||
timer_add(aha_reset_poll, &ResetCB, &ResetCB, dev);
|
||||
timer_add(aha_cmd_cb, &AHA_Callback, &AHA_Callback, dev);
|
||||
|
||||
@@ -2262,7 +2279,46 @@ aha_154xCF_init(void)
|
||||
static void *
|
||||
aha_1640_init(void)
|
||||
{
|
||||
return(aha_init(CHIP_AHA1640, 1));
|
||||
aha_t *dev;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
dev = malloc(sizeof(aha_t));
|
||||
memset(dev, 0x00, sizeof(aha_t));
|
||||
|
||||
ResetDev = dev;
|
||||
dev->chip = CHIP_AHA1640;
|
||||
|
||||
pclog("Aha1640 initialized\n");
|
||||
mca_add(aha_mca_read, aha_mca_write, dev);
|
||||
dev->pos_regs[0] = 0x1F;
|
||||
dev->pos_regs[1] = 0x0F;
|
||||
|
||||
pclog("Building SCSI hard disk map...\n");
|
||||
build_scsi_hd_map();
|
||||
pclog("Building SCSI CD-ROM map...\n");
|
||||
build_scsi_cdrom_map();
|
||||
|
||||
for (i=0; i<16; i++) {
|
||||
for (j=0; j<8; j++) {
|
||||
if (scsi_hard_disks[i][j] != 0xff) {
|
||||
SCSIDevices[i][j].LunType = SCSI_DISK;
|
||||
}
|
||||
else if (find_cdrom_for_scsi_id(i, j) != 0xff) {
|
||||
SCSIDevices[i][j].LunType = SCSI_CDROM;
|
||||
}
|
||||
else {
|
||||
SCSIDevices[i][j].LunType = SCSI_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timer_add(aha_reset_poll, &ResetCB, &ResetCB, dev);
|
||||
timer_add(aha_cmd_cb, &AHA_Callback, &AHA_Callback, dev);
|
||||
|
||||
aha_reset_ctrl(dev, CTRL_HRST);
|
||||
|
||||
return(dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -2373,78 +2429,6 @@ static device_config_t aha_154XCF_config[] = {
|
||||
}
|
||||
};
|
||||
|
||||
static device_config_t aha_1640_config[] = {
|
||||
{
|
||||
"base", "Address", CONFIG_HEX16, "", 0x330,
|
||||
{
|
||||
{
|
||||
"0x330", 0x330
|
||||
},
|
||||
{
|
||||
"0x334", 0x334
|
||||
},
|
||||
{
|
||||
"0x230", 0x230
|
||||
},
|
||||
{
|
||||
"0x234", 0x234
|
||||
},
|
||||
{
|
||||
"0x130", 0x130
|
||||
},
|
||||
{
|
||||
"0x134", 0x134
|
||||
},
|
||||
{
|
||||
""
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"irq", "IRQ", CONFIG_SELECTION, "", 10,
|
||||
{
|
||||
{
|
||||
"IRQ 10", 10
|
||||
},
|
||||
{
|
||||
"IRQ 11", 11
|
||||
},
|
||||
{
|
||||
"IRQ 12", 12
|
||||
},
|
||||
{
|
||||
"IRQ 14", 14
|
||||
},
|
||||
{
|
||||
"IRQ 15", 15
|
||||
},
|
||||
{
|
||||
""
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"dma", "DMA channel", CONFIG_SELECTION, "", 6,
|
||||
{
|
||||
{
|
||||
"DMA 5", 5
|
||||
},
|
||||
{
|
||||
"DMA 6", 6
|
||||
},
|
||||
{
|
||||
"DMA 7", 7
|
||||
},
|
||||
{
|
||||
""
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"", "", -1
|
||||
}
|
||||
};
|
||||
|
||||
device_t aha1540b_device = {
|
||||
"Adaptec AHA-1540B",
|
||||
0,
|
||||
@@ -2477,6 +2461,5 @@ device_t aha1640_device = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
aha_1640_config
|
||||
NULL
|
||||
};
|
||||
@@ -623,15 +623,6 @@ BuslogicReset(Buslogic_t *bl)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
BuslogicSoftReset(void)
|
||||
{
|
||||
if (BuslogicResetDevice != NULL) {
|
||||
BuslogicReset(BuslogicResetDevice);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
BuslogicResetControl(Buslogic_t *bl, uint8_t Reset)
|
||||
{
|
||||
@@ -1685,12 +1676,12 @@ BuslogicHDCommand(Buslogic_t *bl)
|
||||
pclog("SCSI Cdb[%i]=%i\n", i, req->CmdBlock.common.Cdb[i]);
|
||||
}
|
||||
|
||||
memset(temp_cdb, 0, shdc[hdc_id].cdb_len);
|
||||
if (req->CmdBlock.common.CdbLength <= shdc[hdc_id].cdb_len) {
|
||||
memset(temp_cdb, 0, 12);
|
||||
if (req->CmdBlock.common.CdbLength <= 12) {
|
||||
memcpy(temp_cdb, req->CmdBlock.common.Cdb,
|
||||
req->CmdBlock.common.CdbLength);
|
||||
} else {
|
||||
memcpy(temp_cdb, req->CmdBlock.common.Cdb, shdc[hdc_id].cdb_len);
|
||||
memcpy(temp_cdb, req->CmdBlock.common.Cdb, 12);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
552
src/scsi_disk.c
552
src/scsi_disk.c
@@ -6,26 +6,19 @@
|
||||
*
|
||||
* Emulation of SCSI fixed and removable disks.
|
||||
*
|
||||
* Version: @(#)scsi_disk.c 1.0.1 2017/06/03
|
||||
* Version: @(#)scsi_disk.c 1.0.2 2017/06/16
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2017-2017 Miran Grca.
|
||||
*/
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "86box.h"
|
||||
#include "cdrom.h"
|
||||
#include "ibm.h"
|
||||
#include "hdd_image.h"
|
||||
#include "ide.h"
|
||||
#include "piix.h"
|
||||
#include "scsi.h"
|
||||
@@ -213,278 +206,28 @@ void scsi_disk_insert(uint8_t id)
|
||||
shdc[id].unit_attention = (hdc[id].bus == HDD_BUS_SCSI_REMOVABLE) ? 1 : 0;
|
||||
}
|
||||
|
||||
static char empty_sector[512];
|
||||
static char *empty_sector_1mb;
|
||||
|
||||
void scsi_loadhd(int scsi_id, int scsi_lun, int id)
|
||||
{
|
||||
uint32_t sector_size = 512;
|
||||
uint32_t zero = 0;
|
||||
uint64_t signature = 0xD778A82044445459ll;
|
||||
uint64_t full_size = 0;
|
||||
uint64_t spt = 0, hpc = 0, tracks = 0;
|
||||
int c;
|
||||
uint64_t i = 0, s = 0, t = 0;
|
||||
wchar_t *fn = hdc[id].fn;
|
||||
int ret = 0;
|
||||
|
||||
memset(empty_sector, 0, sizeof(empty_sector));
|
||||
ret = hdd_image_load(id);
|
||||
|
||||
shdc[id].base = 0;
|
||||
|
||||
if (shdf[id] != NULL)
|
||||
if (!ret)
|
||||
{
|
||||
fclose(shdf[id]);
|
||||
shdf[id] = NULL;
|
||||
}
|
||||
|
||||
/* Try to open existing hard disk image */
|
||||
if (fn[0] == '.')
|
||||
{
|
||||
scsi_hd_log("File name starts with .\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
if (hdc[id].bus != HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
scsi_hard_disks[scsi_id][scsi_lun] = 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
return;
|
||||
}
|
||||
shdf[id] = _wfopen(fn, L"rb+");
|
||||
if (shdf[id] == NULL)
|
||||
{
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
if (hdc[id].wp)
|
||||
{
|
||||
scsi_hd_log("A write-protected image must exist\n");
|
||||
goto scsi_hd_load_error;
|
||||
}
|
||||
|
||||
shdf[id] = _wfopen(fn, L"wb+");
|
||||
if (shdf[id] == NULL)
|
||||
{
|
||||
scsi_hd_load_error:
|
||||
scsi_hd_log("Unable to open image\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
if (hdc[id].bus != HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
scsi_hard_disks[scsi_id][scsi_lun] = 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&(shdc[id]), 0, sizeof(scsi_hard_disk_t));
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
shdc[id].base = 0x1000;
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
fwrite(&(shdc[id].base), 1, 4, shdf[id]);
|
||||
fwrite(&full_size, 1, 4, shdf[id]);
|
||||
fwrite(§or_size, 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].spt), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].hpc), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].tracks), 1, 4, shdf[id]);
|
||||
for (c = 0; c < 0x3f8; c++)
|
||||
{
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
}
|
||||
}
|
||||
else if (image_is_hdx(fn, 0))
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
shdc[id].base = 0x28;
|
||||
fwrite(&signature, 1, 8, shdf[id]);
|
||||
fwrite(&full_size, 1, 8, shdf[id]);
|
||||
fwrite(§or_size, 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].spt), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].hpc), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].tracks), 1, 4, shdf[id]);
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
}
|
||||
shdc[id].last_sector = 0;
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
|
||||
scsi_disk_insert(id);
|
||||
|
||||
s = full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
|
||||
goto prepare_new_hard_disk;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed for another reason */
|
||||
scsi_hd_log("Failed for another reason\n");
|
||||
if (hdc[id].bus != HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
scsi_hard_disks[scsi_id][scsi_lun] = 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&(shdc[id]), 0, sizeof(scsi_hard_disk_t));
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
fseeko64(shdf[id], 0x8, SEEK_SET);
|
||||
fread(&(shdc[id].base), 1, 4, shdf[id]);
|
||||
fseeko64(shdf[id], 0xC, SEEK_SET);
|
||||
full_size = 0;
|
||||
fread(&full_size, 1, 4, shdf[id]);
|
||||
fseeko64(shdf[id], 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, shdf[id]);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
scsi_hd_log("HDI: Sector size is not 512\n");
|
||||
fclose(shdf[id]);
|
||||
if (hdc[id].bus != HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
scsi_hard_disks[scsi_id][scsi_lun] = 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
return;
|
||||
}
|
||||
fread(&spt, 1, 4, shdf[id]);
|
||||
fread(&hpc, 1, 4, shdf[id]);
|
||||
fread(&tracks, 1, 4, shdf[id]);
|
||||
if (hdc[id].bus == HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
if ((spt != hdc[id].spt) || (hpc != hdc[id].hpc) || (tracks != hdc[id].tracks))
|
||||
{
|
||||
fclose(shdf[id]);
|
||||
shdf[id] = NULL;
|
||||
goto scsi_hd_load_error;
|
||||
}
|
||||
}
|
||||
hdc[id].spt = spt;
|
||||
hdc[id].hpc = hpc;
|
||||
hdc[id].tracks = tracks;
|
||||
}
|
||||
else if (image_is_hdx(fn, 1))
|
||||
{
|
||||
shdc[id].base = 0x28;
|
||||
fseeko64(shdf[id], 8, SEEK_SET);
|
||||
fread(&full_size, 1, 8, shdf[id]);
|
||||
fseeko64(shdf[id], 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, shdf[id]);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
scsi_hd_log("HDX: Sector size is not 512\n");
|
||||
fclose(shdf[id]);
|
||||
if (hdc[id].bus != HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
scsi_hard_disks[scsi_id][scsi_lun] = 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
return;
|
||||
}
|
||||
fread(&spt, 1, 4, shdf[id]);
|
||||
fread(&hpc, 1, 4, shdf[id]);
|
||||
fread(&tracks, 1, 4, shdf[id]);
|
||||
if (hdc[id].bus == HDD_BUS_SCSI_REMOVABLE)
|
||||
{
|
||||
if ((spt != hdc[id].spt) || (hpc != hdc[id].hpc) || (tracks != hdc[id].tracks))
|
||||
{
|
||||
fclose(shdf[id]);
|
||||
shdf[id] = NULL;
|
||||
goto scsi_hd_load_error;
|
||||
}
|
||||
}
|
||||
hdc[id].spt = spt;
|
||||
hdc[id].hpc = hpc;
|
||||
hdc[id].tracks = tracks;
|
||||
fread(&(hdc[id].at_spt), 1, 4, shdf[id]);
|
||||
fread(&(hdc[id].at_hpc), 1, 4, shdf[id]);
|
||||
}
|
||||
else
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
}
|
||||
shdc[id].cdb_len = 12;
|
||||
scsi_disk_insert(id);
|
||||
}
|
||||
|
||||
fseeko64(shdf[id], 0, SEEK_END);
|
||||
if (ftello64(shdf[id]) < (full_size + shdc[id].base))
|
||||
{
|
||||
s = (full_size + shdc[id].base) - ftello64(shdf[id]);
|
||||
prepare_new_hard_disk:
|
||||
s >>= 9;
|
||||
t = (s >> 11) << 11;
|
||||
s -= t;
|
||||
t >>= 11;
|
||||
|
||||
empty_sector_1mb = (char *) malloc(1048576);
|
||||
memset(empty_sector_1mb, 0, 1048576);
|
||||
|
||||
if (s > 0)
|
||||
{
|
||||
for (i = 0; i < s; i++)
|
||||
{
|
||||
fwrite(empty_sector, 1, 512, shdf[id]);
|
||||
}
|
||||
}
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
for (i = 0; i < t; i++)
|
||||
{
|
||||
fwrite(empty_sector_1mb, 1, 1045876, shdf[id]);
|
||||
}
|
||||
}
|
||||
|
||||
free(empty_sector_1mb);
|
||||
}
|
||||
|
||||
shdc[id].last_sector = (uint32_t) (full_size >> 9) - 1;
|
||||
|
||||
#if 0
|
||||
fclose(shdf[id]);
|
||||
#endif
|
||||
}
|
||||
|
||||
void scsi_reloadhd(int id)
|
||||
{
|
||||
uint32_t sector_size = 512;
|
||||
uint32_t zero = 0;
|
||||
uint64_t signature = 0xD778A82044445459ll;
|
||||
uint64_t full_size = 0;
|
||||
uint64_t spt = 0, hpc = 0, tracks = 0;
|
||||
int c;
|
||||
uint64_t i = 0, s = 0, t = 0;
|
||||
wchar_t *fn = hdc[id].fn;
|
||||
|
||||
memset(empty_sector, 0, sizeof(empty_sector));
|
||||
int ret = 0;
|
||||
|
||||
if(hdc[id].prev_fn == NULL)
|
||||
{
|
||||
@@ -496,232 +239,17 @@ void scsi_reloadhd(int id)
|
||||
memset(hdc[id].prev_fn, 0, sizeof(hdc[id].prev_fn));
|
||||
}
|
||||
|
||||
shdc[id].base = 0;
|
||||
ret = hdd_image_load(id);
|
||||
|
||||
if (shdf[id] != NULL)
|
||||
if (ret)
|
||||
{
|
||||
fclose(shdf[id]);
|
||||
shdf[id] = NULL;
|
||||
}
|
||||
|
||||
/* Try to open existing hard disk image */
|
||||
if (fn[0] == '.')
|
||||
{
|
||||
scsi_hd_log("File name starts with .\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
return;
|
||||
}
|
||||
shdf[id] = _wfopen(fn, L"rb+");
|
||||
if (shdf[id] == NULL)
|
||||
{
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
if (hdc[id].wp)
|
||||
{
|
||||
scsi_hd_log("A write-protected image must exist\n");
|
||||
goto scsi_hd_reload_error;
|
||||
}
|
||||
|
||||
shdf[id] = _wfopen(fn, L"wb+");
|
||||
if (shdf[id] == NULL)
|
||||
{
|
||||
scsi_hd_reload_error:
|
||||
scsi_hd_log("Unable to open image\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&(shdc[id]), 0, sizeof(scsi_hard_disk_t));
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
shdc[id].base = 0x1000;
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
fwrite(&(shdc[id].base), 1, 4, shdf[id]);
|
||||
fwrite(&full_size, 1, 4, shdf[id]);
|
||||
fwrite(§or_size, 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].spt), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].hpc), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].tracks), 1, 4, shdf[id]);
|
||||
for (c = 0; c < 0x3f8; c++)
|
||||
{
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
}
|
||||
}
|
||||
else if (image_is_hdx(fn, 0))
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
shdc[id].base = 0x28;
|
||||
fwrite(&signature, 1, 8, shdf[id]);
|
||||
fwrite(&full_size, 1, 8, shdf[id]);
|
||||
fwrite(§or_size, 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].spt), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].hpc), 1, 4, shdf[id]);
|
||||
fwrite(&(hdc[id].tracks), 1, 4, shdf[id]);
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
fwrite(&zero, 1, 4, shdf[id]);
|
||||
}
|
||||
shdc[id].last_sector = 0;
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
|
||||
scsi_disk_insert(id);
|
||||
|
||||
s = full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
|
||||
goto reload_prepare_new_hard_disk;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed for another reason */
|
||||
scsi_hd_log("Failed for another reason\n");
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&(shdc[id]), 0, sizeof(scsi_hard_disk_t));
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
fseeko64(shdf[id], 0x8, SEEK_SET);
|
||||
fread(&(shdc[id].base), 1, 4, shdf[id]);
|
||||
fseeko64(shdf[id], 0xC, SEEK_SET);
|
||||
full_size = 0;
|
||||
fread(&full_size, 1, 4, shdf[id]);
|
||||
fseeko64(shdf[id], 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, shdf[id]);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
scsi_hd_log("HDI: Sector size is not 512\n");
|
||||
fclose(shdf[id]);
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
return;
|
||||
}
|
||||
fread(&spt, 1, 4, shdf[id]);
|
||||
fread(&hpc, 1, 4, shdf[id]);
|
||||
fread(&tracks, 1, 4, shdf[id]);
|
||||
if ((spt != hdc[id].spt) || (hpc != hdc[id].hpc) || (tracks != hdc[id].tracks))
|
||||
{
|
||||
fclose(shdf[id]);
|
||||
shdf[id] = NULL;
|
||||
goto scsi_hd_reload_error;
|
||||
}
|
||||
hdc[id].spt = spt;
|
||||
hdc[id].hpc = hpc;
|
||||
hdc[id].tracks = tracks;
|
||||
}
|
||||
else if (image_is_hdx(fn, 1))
|
||||
{
|
||||
shdc[id].base = 0x28;
|
||||
fseeko64(shdf[id], 8, SEEK_SET);
|
||||
fread(&full_size, 1, 8, shdf[id]);
|
||||
fseeko64(shdf[id], 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, shdf[id]);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
scsi_hd_log("HDX: Sector size is not 512\n");
|
||||
fclose(shdf[id]);
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
shdc[id].cdb_len = 12;
|
||||
return;
|
||||
}
|
||||
fread(&spt, 1, 4, shdf[id]);
|
||||
fread(&hpc, 1, 4, shdf[id]);
|
||||
fread(&tracks, 1, 4, shdf[id]);
|
||||
if ((spt != hdc[id].spt) || (hpc != hdc[id].hpc) || (tracks != hdc[id].tracks))
|
||||
{
|
||||
fclose(shdf[id]);
|
||||
shdf[id] = NULL;
|
||||
goto scsi_hd_reload_error;
|
||||
}
|
||||
hdc[id].spt = spt;
|
||||
hdc[id].hpc = hpc;
|
||||
hdc[id].tracks = tracks;
|
||||
fread(&(hdc[id].at_spt), 1, 4, shdf[id]);
|
||||
fread(&(hdc[id].at_hpc), 1, 4, shdf[id]);
|
||||
}
|
||||
else
|
||||
{
|
||||
full_size = hdc[id].spt * hdc[id].hpc * hdc[id].tracks * 512;
|
||||
}
|
||||
shdc[id].cdb_len = 12;
|
||||
scsi_disk_insert(id);
|
||||
}
|
||||
|
||||
fseeko64(shdf[id], 0, SEEK_END);
|
||||
if (ftello64(shdf[id]) < (full_size + shdc[id].base))
|
||||
{
|
||||
s = (full_size + shdc[id].base) - ftello64(shdf[id]);
|
||||
reload_prepare_new_hard_disk:
|
||||
s >>= 9;
|
||||
t = (s >> 11) << 11;
|
||||
s -= t;
|
||||
t >>= 11;
|
||||
|
||||
empty_sector_1mb = (char *) malloc(1048576);
|
||||
memset(empty_sector_1mb, 0, 1048576);
|
||||
|
||||
if (s > 0)
|
||||
{
|
||||
for (i = 0; i < s; i++)
|
||||
{
|
||||
fwrite(empty_sector, 1, 512, shdf[id]);
|
||||
}
|
||||
}
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
for (i = 0; i < t; i++)
|
||||
{
|
||||
fwrite(empty_sector_1mb, 1, 1045876, shdf[id]);
|
||||
}
|
||||
}
|
||||
|
||||
free(empty_sector_1mb);
|
||||
}
|
||||
|
||||
shdc[id].last_sector = (uint32_t) (full_size >> 9) - 1;
|
||||
|
||||
#if 0
|
||||
fclose(shdf[id]);
|
||||
#endif
|
||||
}
|
||||
|
||||
void scsi_unloadhd(int scsi_id, int scsi_lun, int id)
|
||||
{
|
||||
if (wcslen(hdc[id].fn) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (shdf[id] != NULL)
|
||||
{
|
||||
fclose(shdf[id]);
|
||||
shdf[id] = NULL;
|
||||
}
|
||||
|
||||
shdc[id].last_sector = -1;
|
||||
|
||||
memset(hdc[id].prev_fn, 0, sizeof(hdc[id].prev_fn));
|
||||
wcscpy(hdc[id].prev_fn, hdc[id].fn);
|
||||
|
||||
memset(hdc[id].fn, 0, sizeof(hdc[id].fn));
|
||||
|
||||
shdc[id].cdb_len = 12;
|
||||
|
||||
fclose(shdf[id]);
|
||||
hdd_image_unload(id, 1);
|
||||
}
|
||||
|
||||
void build_scsi_hd_map()
|
||||
@@ -746,10 +274,6 @@ void build_scsi_hd_map()
|
||||
{
|
||||
scsi_loadhd(i, j, scsi_hard_disks[i][j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
shdc[scsi_hard_disks[i][j]].cdb_len = 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -759,7 +283,7 @@ int scsi_hd_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *l
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
size = shdc[id].last_sector;
|
||||
size = hdd_image_get_last_sector(id);
|
||||
memset(buffer, 0, 8);
|
||||
buffer[0] = (size >> 24) & 0xff;
|
||||
buffer[1] = (size >> 16) & 0xff;
|
||||
@@ -771,16 +295,6 @@ int scsi_hd_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *l
|
||||
return 1;
|
||||
}
|
||||
|
||||
void scsi_hd_set_cdb_len(int id, int cdb_len)
|
||||
{
|
||||
shdc[id].cdb_len = cdb_len;
|
||||
}
|
||||
|
||||
void scsi_hd_reset_cdb_len(int id)
|
||||
{
|
||||
shdc[id].cdb_len = 12;
|
||||
}
|
||||
|
||||
void scsi_hd_update_request_length(uint8_t id, int len, int block_len)
|
||||
{
|
||||
/* For media access commands, make sure the requested DRQ length matches the block length. */
|
||||
@@ -1080,7 +594,7 @@ int scsi_hd_pre_execution_check(uint8_t id, uint8_t *cdb)
|
||||
static void scsi_hd_seek(uint8_t id, uint32_t pos)
|
||||
{
|
||||
/* scsi_hd_log("SCSI HD %i: Seek %08X\n", id, pos); */
|
||||
shdc[id].seek_pos = pos;
|
||||
hdd_image_seek(id, pos);
|
||||
}
|
||||
|
||||
static void scsi_hd_rezero(uint8_t id)
|
||||
@@ -1179,14 +693,16 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb)
|
||||
unsigned size_idx;
|
||||
unsigned preamble_len;
|
||||
uint32_t alloc_length;
|
||||
uint64_t pos64;
|
||||
char device_identify[9] = { '8', '6', 'B', '_', 'H', 'D', '0', '0', 0 };
|
||||
char device_identify_ex[15] = { '8', '6', 'B', '_', 'H', 'D', '0', '0', ' ', 'v', '1', '.', '0', '0', 0 };
|
||||
char *tempbuffer;
|
||||
uint8_t *tempbuffer;
|
||||
uint32_t last_sector = 0;
|
||||
|
||||
#if 0
|
||||
int CdbLength;
|
||||
#endif
|
||||
last_sector = hdd_image_get_last_sector(id);
|
||||
|
||||
shdc[id].status &= ~ERR_STAT;
|
||||
|
||||
shdc[id].packet_len = 0;
|
||||
@@ -1210,7 +726,7 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb)
|
||||
|
||||
shdc[id].data_pos = 0;
|
||||
|
||||
memcpy(shdc[id].current_cdb, cdb, shdc[id].cdb_len);
|
||||
memcpy(shdc[id].current_cdb, cdb, 12);
|
||||
|
||||
if (cdb[0] != 0)
|
||||
{
|
||||
@@ -1218,7 +734,7 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb)
|
||||
scsi_hd_log("SCSI HD %i: Request length: %04X\n", id, shdc[id].request_length);
|
||||
|
||||
#if 0
|
||||
for (CdbLength = 1; CdbLength < shdc[id].cdb_len; CdbLength++)
|
||||
for (CdbLength = 1; CdbLength < 12; CdbLength++)
|
||||
{
|
||||
scsi_hd_log("SCSI HD %i: CDB[%d] = 0x%02X\n", id, CdbLength, cdb[CdbLength]);
|
||||
}
|
||||
@@ -1284,7 +800,7 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((shdc[id].sector_pos > shdc[id].last_sector) || ((shdc[id].sector_pos + shdc[id].sector_len - 1) > shdc[id].last_sector))
|
||||
if ((shdc[id].sector_pos > last_sector) || ((shdc[id].sector_pos + shdc[id].sector_len - 1) > last_sector))
|
||||
{
|
||||
scsi_hd_lba_out_of_range(id);
|
||||
return;
|
||||
@@ -1301,27 +817,18 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb)
|
||||
max_len = shdc[id].sector_len;
|
||||
shdc[id].requested_blocks = max_len;
|
||||
|
||||
pos64 = (uint64_t) shdc[id].sector_pos;
|
||||
|
||||
alloc_length = shdc[id].packet_len = max_len << 9;
|
||||
|
||||
if ((shdc[id].requested_blocks > 0) && (SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength > 0))
|
||||
{
|
||||
#if 0
|
||||
shdf[id] = _wfopen(hdc[id].fn, L"rb+");
|
||||
#endif
|
||||
fseeko64(shdf[id], shdc[id].base + (pos64 << 9), SEEK_SET);
|
||||
if (alloc_length > SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength)
|
||||
{
|
||||
fread(hdbufferb, 1, SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength, shdf[id]);
|
||||
hdd_image_read(id, shdc[id].sector_pos, SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength >> 9, hdbufferb);
|
||||
}
|
||||
else
|
||||
{
|
||||
fread(hdbufferb, 1, alloc_length, shdf[id]);
|
||||
hdd_image_read(id, shdc[id].sector_pos, max_len, hdbufferb);
|
||||
}
|
||||
#if 0
|
||||
fclose(shdf[id]);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (shdc[id].requested_blocks > 1)
|
||||
@@ -1369,7 +876,7 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((shdc[id].sector_pos > shdc[id].last_sector) || ((shdc[id].sector_pos + shdc[id].sector_len - 1) > shdc[id].last_sector))
|
||||
if ((shdc[id].sector_pos > last_sector) || ((shdc[id].sector_pos + shdc[id].sector_len - 1) > last_sector))
|
||||
{
|
||||
scsi_hd_lba_out_of_range(id);
|
||||
return;
|
||||
@@ -1386,27 +893,18 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb)
|
||||
max_len = shdc[id].sector_len;
|
||||
shdc[id].requested_blocks = max_len;
|
||||
|
||||
pos64 = (uint64_t) shdc[id].sector_pos;
|
||||
|
||||
alloc_length = shdc[id].packet_len = max_len << 9;
|
||||
|
||||
if ((shdc[id].requested_blocks > 0) && (SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength > 0))
|
||||
{
|
||||
#if 0
|
||||
shdf[id] = _wfopen(hdc[id].fn, L"rb+");
|
||||
#endif
|
||||
fseeko64(shdf[id], shdc[id].base + (pos64 << 9), SEEK_SET);
|
||||
if (alloc_length > SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength)
|
||||
{
|
||||
fwrite(hdbufferb, 1, SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength, shdf[id]);
|
||||
hdd_image_write(id, shdc[id].sector_pos, SCSIDevices[hdc[id].scsi_id][hdc[id].scsi_lun].InitLength >> 9, hdbufferb);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(hdbufferb, 1, alloc_length, shdf[id]);
|
||||
hdd_image_write(id, shdc[id].sector_pos, max_len, hdbufferb);
|
||||
}
|
||||
#if 0
|
||||
fclose(shdf[id]);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (shdc[id].requested_blocks > 1)
|
||||
|
||||
@@ -36,14 +36,10 @@ typedef struct {
|
||||
uint8_t error;
|
||||
uint32_t sector_pos;
|
||||
uint32_t sector_len;
|
||||
uint32_t last_sector;
|
||||
uint32_t seek_pos;
|
||||
int data_pos;
|
||||
int old_len;
|
||||
int cdb_len_setting;
|
||||
int cdb_len;
|
||||
int request_pos;
|
||||
uint64_t base;
|
||||
uint8_t hd_cdb[16];
|
||||
} scsi_hard_disk_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
@@ -116,7 +116,7 @@ enum {
|
||||
#define MCR_OUT1 (0x04) /* 8250 */
|
||||
#define MCR_OUT2 (0x08) /* 8250, INTEN on IBM-PC */
|
||||
#define MCR_LMS (0x10)
|
||||
#define MCR_AUTOFLOW (0x20) /* 16750
|
||||
#define MCR_AUTOFLOW (0x20) /* 16750 */
|
||||
|
||||
/* LSR register bits. */
|
||||
#define LSR_DR (0x01)
|
||||
@@ -144,6 +144,7 @@ static SERIAL ports[NUM_SERIAL]; /* serial port data */
|
||||
int serial_do_log;
|
||||
|
||||
|
||||
#if 0
|
||||
static void
|
||||
serial_log(int lvl, const char *fmt, ...)
|
||||
{
|
||||
@@ -158,6 +159,7 @@ serial_log(int lvl, const char *fmt, ...)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
|
||||
@@ -36,8 +36,8 @@ void sio_write(int func, int addr, uint8_t val, void *priv)
|
||||
if (func > 0)
|
||||
return;
|
||||
|
||||
if (addr >= 0x0f && addr < 0x4c)
|
||||
return;
|
||||
if (addr >= 0x0f && addr < 0x4c)
|
||||
return;
|
||||
|
||||
switch (addr)
|
||||
{
|
||||
|
||||
52
src/superio_detect.c
Normal file
52
src/superio_detect.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
SMSC SMC FDC37C665 Super I/O Chip
|
||||
Used by Batman's Revenge
|
||||
*/
|
||||
|
||||
#include "ibm.h"
|
||||
|
||||
#include "io.h"
|
||||
#include "disc.h"
|
||||
#include "fdd.h"
|
||||
#include "fdc.h"
|
||||
#include "superio_detect.h"
|
||||
|
||||
static int fdc37c665_locked;
|
||||
static int fdc37c665_curreg = 0;
|
||||
static uint8_t detect_regs[2];
|
||||
static uint8_t tries;
|
||||
|
||||
void superio_detect_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
uint8_t index = (port & 1) ? 0 : 1;
|
||||
uint8_t valxor = 0;
|
||||
int temp;
|
||||
pclog("superio_detect_write : port=%04x = %02X\n", port, val);
|
||||
|
||||
detect_regs[port & 1] = val;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t superio_detect_read(uint16_t port, void *priv)
|
||||
{
|
||||
pclog("superio_detect_read : port=%04x = %02X\n", port, detect_regs[port & 1]);
|
||||
|
||||
return detect_regs[port & 1];
|
||||
}
|
||||
|
||||
void superio_detect_init()
|
||||
{
|
||||
fdc_remove();
|
||||
fdc_add_for_superio();
|
||||
|
||||
io_sethandler(0x24, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x26, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x2e, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x44, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x46, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x4e, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x108, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x250, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x370, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x3f0, 0x0002, superio_detect_read, NULL, NULL, superio_detect_write, NULL, NULL, NULL);
|
||||
}
|
||||
1
src/superio_detect.h
Normal file
1
src/superio_detect.h
Normal file
@@ -0,0 +1 @@
|
||||
extern void superio_detect_init();
|
||||
@@ -118,7 +118,7 @@ int tandy_eeprom_read()
|
||||
void *tandy_eeprom_init()
|
||||
{
|
||||
tandy_eeprom_t *eeprom = malloc(sizeof(tandy_eeprom_t));
|
||||
FILE *f;
|
||||
FILE *f = NULL;
|
||||
|
||||
memset(eeprom, 0, sizeof(tandy_eeprom_t));
|
||||
|
||||
@@ -148,7 +148,7 @@ void *tandy_eeprom_init()
|
||||
void tandy_eeprom_close(void *p)
|
||||
{
|
||||
tandy_eeprom_t *eeprom = (tandy_eeprom_t *)p;
|
||||
FILE *f;
|
||||
FILE *f = NULL;
|
||||
|
||||
switch (eeprom->romset)
|
||||
{
|
||||
|
||||
@@ -216,6 +216,7 @@ static void w83877f_remap()
|
||||
winbond_port = (HEFRAS ? 0x3f0 : 0x250);
|
||||
winbond_key_times = HEFRAS + 1;
|
||||
winbond_key = (HEFRAS ? 0x86 : 0x88) | HEFERE;
|
||||
pclog("W83877F: Remapped to port %04X, key %02X\n", winbond_port, winbond_key);
|
||||
}
|
||||
|
||||
static uint8_t is_in_array(uint16_t *port_array, uint8_t max, uint16_t port)
|
||||
@@ -282,6 +283,24 @@ static uint16_t make_port(uint8_t reg)
|
||||
return p;
|
||||
}
|
||||
|
||||
void w83877f_serial_handler(int id)
|
||||
{
|
||||
int reg_mask = (id - 1) ? 0x10 : 0x20;
|
||||
int reg_id = (id - 1) ? 0x24 : 0x25;
|
||||
int irq_mask = (id - 1) ? 0xF : 0xF0;
|
||||
|
||||
/* pclog("Registers (%i): %02X %02X %02X\n", id, w83877f_regs[4], w83877f_regs[reg_id], w83877f_regs[0x28]); */
|
||||
|
||||
if ((w83877f_regs[4] & reg_mask) || !(w83877f_regs[reg_id] & 0xc0))
|
||||
{
|
||||
serial_remove(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
serial_setup(id, make_port(reg_id), w83877f_regs[0x28] & irq_mask);
|
||||
}
|
||||
}
|
||||
|
||||
void w83877f_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
uint8_t index = (port & 1) ? 0 : 1;
|
||||
@@ -353,16 +372,11 @@ process_value:
|
||||
case 4:
|
||||
if (valxor & 0x10)
|
||||
{
|
||||
serial_remove(2);
|
||||
if (!(w83877f_regs[2] & 0x10)) serial_setup(2, make_port(0x25), w83877f_regs[0x28] & 0xF);
|
||||
w83877f_serial_handler(2);
|
||||
}
|
||||
if (valxor & 0x20)
|
||||
{
|
||||
serial_remove(1);
|
||||
if (!(w83877f_regs[4] & 0x20))
|
||||
{
|
||||
serial_setup(1, make_port(0x24), (w83877f_regs[0x28] & 0xF0) >> 8);
|
||||
}
|
||||
w83877f_serial_handler(1);
|
||||
}
|
||||
if (valxor & 0x80)
|
||||
{
|
||||
@@ -418,16 +432,13 @@ process_value:
|
||||
case 0x24:
|
||||
if (valxor & 0xfe)
|
||||
{
|
||||
if (!(w83877f_regs[4] & 0x20))
|
||||
{
|
||||
serial_setup(1, make_port(0x24), (w83877f_regs[0x28] & 0xF0) >> 8);
|
||||
}
|
||||
w83877f_serial_handler(1);
|
||||
}
|
||||
break;
|
||||
case 0x25:
|
||||
if (valxor & 0xfe)
|
||||
{
|
||||
if (!(w83877f_regs[2] & 0x10)) serial_setup(2, make_port(0x25), w83877f_regs[0x28] & 0xF);
|
||||
w83877f_serial_handler(2);
|
||||
}
|
||||
break;
|
||||
case 0x28:
|
||||
@@ -486,7 +497,7 @@ void w83877f_reset(void)
|
||||
w83877f_regs[0xA] = 0x1F;
|
||||
w83877f_regs[0xC] = 0x28;
|
||||
w83877f_regs[0xD] = 0xA3;
|
||||
w83877f_regs[0x16] = 5;
|
||||
w83877f_regs[0x16] = (romset == ROM_PRESIDENT) ? 4 : 5;
|
||||
w83877f_regs[0x1E] = 0x81;
|
||||
w83877f_regs[0x20] = (0x3f0 >> 2) & 0xfc;
|
||||
w83877f_regs[0x21] = (0x1f0 >> 2) & 0xfc;
|
||||
|
||||
Reference in New Issue
Block a user