diff --git a/src/chipset/sis_85c310.c b/src/chipset/sis_85c310.c index c3015e35b..64efba5bb 100644 --- a/src/chipset/sis_85c310.c +++ b/src/chipset/sis_85c310.c @@ -21,7 +21,8 @@ typedef struct static void rabbit_recalcmapping(rabbit_t *dev) { - uint32_t shread, shwrite; + uint32_t shread; + uint32_t shwrite; uint32_t shflags = 0; shread = !!(dev->regs[0x101] & 0x40); diff --git a/src/codegen/codegen.h b/src/codegen/codegen.h index cb9df495b..ddcf5095f 100644 --- a/src/codegen/codegen.h +++ b/src/codegen/codegen.h @@ -212,7 +212,8 @@ codeblock_tree_delete(codeblock_t *block) return; } else { /*Difficult case - node has two children. Walk right child to find lowest node*/ - codeblock_t *lowest = block->right, *highest; + codeblock_t *lowest = block->right; + codeblock_t *highest; codeblock_t *old_parent; while (lowest->left) diff --git a/src/codegen/codegen_ops_arith.h b/src/codegen/codegen_ops_arith.h index 87f1640e6..e6561208e 100644 --- a/src/codegen/codegen_ops_arith.h +++ b/src/codegen/codegen_ops_arith.h @@ -281,7 +281,8 @@ ROP_ARITH_RM(SUB, SUB, 1) static uint32_t ropCMP_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { src_reg = LOAD_REG_B(fetchdat & 7); @@ -307,7 +308,8 @@ ropCMP_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, c static uint32_t ropCMP_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { src_reg = LOAD_REG_W(fetchdat & 7); @@ -333,7 +335,8 @@ ropCMP_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, c static uint32_t ropCMP_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { src_reg = LOAD_REG_L(fetchdat & 7); @@ -360,7 +363,8 @@ ropCMP_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, c static uint32_t ropCMP_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { dst_reg = LOAD_REG_B(fetchdat & 7); @@ -386,7 +390,8 @@ ropCMP_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, static uint32_t ropCMP_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { dst_reg = LOAD_REG_W(fetchdat & 7); @@ -412,7 +417,8 @@ ropCMP_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, static uint32_t ropCMP_l_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { dst_reg = LOAD_REG_L(fetchdat & 7); diff --git a/src/codegen/codegen_ops_fpu.h b/src/codegen/codegen_ops_fpu.h index 4ffbb45a0..323a25542 100644 --- a/src/codegen/codegen_ops_fpu.h +++ b/src/codegen/codegen_ops_fpu.h @@ -156,7 +156,8 @@ static uint32_t ropFSTd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - int host_reg1, host_reg2 = 0; + int host_reg1; + int host_reg2 = 0; FP_ENTER(); op_pc--; @@ -593,7 +594,8 @@ static uint32_t ropFISTPq(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { x86seg *target_seg; - int host_reg1, host_reg2; + int host_reg1; + int host_reg2; FP_ENTER(); op_pc--; @@ -679,7 +681,7 @@ opFLDimm(Z, 0.0) static uint32_t ropFLDLN2(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { FP_ENTER(); - FP_LOAD_IMM_Q(0x3fe62e42fefa39f0ull); + FP_LOAD_IMM_Q(0x3fe62e42fefa39f0ULL); return op_pc; } diff --git a/src/codegen/codegen_ops_logic.h b/src/codegen/codegen_ops_logic.h index 55b4e117d..d0216644c 100644 --- a/src/codegen/codegen_ops_logic.h +++ b/src/codegen/codegen_ops_logic.h @@ -175,7 +175,8 @@ ROP_LOGIC(XOR, XOR, 1) static uint32_t ropTEST_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { src_reg = LOAD_REG_B(fetchdat & 7); @@ -198,7 +199,8 @@ ropTEST_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, static uint32_t ropTEST_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { src_reg = LOAD_REG_W(fetchdat & 7); @@ -221,7 +223,8 @@ ropTEST_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, static uint32_t ropTEST_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg; + int src_reg; + int dst_reg; if ((fetchdat & 0xc0) == 0xc0) { src_reg = LOAD_REG_L(fetchdat & 7); diff --git a/src/codegen/codegen_ops_mmx.h b/src/codegen/codegen_ops_mmx.h index edb5b0586..e667bc40e 100644 --- a/src/codegen/codegen_ops_mmx.h +++ b/src/codegen/codegen_ops_mmx.h @@ -1,7 +1,8 @@ static uint32_t ropMOVQ_q_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int host_reg1, host_reg2 = 0; + int host_reg1; + int host_reg2 = 0; MMX_ENTER(); @@ -29,7 +30,8 @@ ropMOVQ_mm_q(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, MMX_ENTER(); if ((fetchdat & 0xc0) == 0xc0) { - int host_reg1, host_reg2; + int host_reg1; + int host_reg2; LOAD_MMX_Q(fetchdat & 7, &host_reg1, &host_reg2); STORE_MMX_Q((fetchdat >> 3) & 7, host_reg1, host_reg2); diff --git a/src/codegen/codegen_ops_x86-64.h b/src/codegen/codegen_ops_x86-64.h index 77f7c02ab..18480a6b5 100644 --- a/src/codegen/codegen_ops_x86-64.h +++ b/src/codegen/codegen_ops_x86-64.h @@ -536,7 +536,8 @@ FETCH_EA_16(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc) addlong((fetchdat >> 8) & 0xffff); (*op_pc) += 2; } else { - int base_reg = 0, index_reg = 0; + int base_reg = 0; + int index_reg = 0; switch (rm) { case 0: @@ -639,8 +640,9 @@ FETCH_EA_32(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, uint32_t new_eaaddr; if (rm == 4) { - uint8_t sib = fetchdat >> 8; - int base_reg = -1, index_reg = -1; + uint8_t sib = fetchdat >> 8; + int base_reg = -1; + int index_reg = -1; (*op_pc)++; diff --git a/src/codegen/codegen_ops_xchg.h b/src/codegen/codegen_ops_xchg.h index 071acc3d8..820d4461a 100644 --- a/src/codegen/codegen_ops_xchg.h +++ b/src/codegen/codegen_ops_xchg.h @@ -45,7 +45,9 @@ OP_XCHG_EAX_(EBP) static uint32_t ropXCHG_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg, temp_reg; + int src_reg; + int dst_reg; + int temp_reg; if ((fetchdat & 0xc0) != 0xc0) return 0; @@ -61,7 +63,9 @@ ropXCHG_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod static uint32_t ropXCHG_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg, temp_reg; + int src_reg; + int dst_reg; + int temp_reg; if ((fetchdat & 0xc0) != 0xc0) return 0; @@ -77,7 +81,9 @@ ropXCHG_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod static uint32_t ropXCHG_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) { - int src_reg, dst_reg, temp_reg; + int src_reg; + int dst_reg; + int temp_reg; if ((fetchdat & 0xc0) != 0xc0) return 0; diff --git a/src/codegen/codegen_x86.c b/src/codegen/codegen_x86.c index f9d1d1ba5..0821d9d14 100644 --- a/src/codegen/codegen_x86.c +++ b/src/codegen/codegen_x86.c @@ -69,7 +69,8 @@ # include # endif -int codegen_flat_ds, codegen_flat_ss; +int codegen_flat_ds; +int codegen_flat_ss; int mmx_ebx_ecx_loaded; int codegen_flags_changed = 0; int codegen_fpu_entered = 0; diff --git a/src/codegen_new/codegen.c b/src/codegen_new/codegen.c index 58e5d8a06..d7aae234e 100644 --- a/src/codegen_new/codegen.c +++ b/src/codegen_new/codegen.c @@ -31,9 +31,7 @@ static struct int codegen_get_instruction_uop(codeblock_t *block, uint32_t pc, int *first_instruction, int *TOP) { - int c; - - for (c = 0; c <= block->ins; c++) { + for (uint8_t c = 0; c <= block->ins; c++) { if (codegen_instructions[c].pc == pc) { *first_instruction = c; *TOP = codegen_instructions[c].TOP; @@ -137,7 +135,9 @@ codegen_generate_ea_16_long(ir_data_t *ir, x86seg *op_ea_seg, uint32_t fetchdat, uop_MOV_IMM(ir, IREG_eaaddr, addr); (*op_pc) += 2; } else { - int base_reg, index_reg, offset; + int base_reg; + int index_reg; + int offset; switch (cpu_rm & 7) { case 0: diff --git a/src/codegen_new/codegen.h b/src/codegen_new/codegen.h index cc7e3f083..607a2e4ee 100644 --- a/src/codegen_new/codegen.h +++ b/src/codegen_new/codegen.h @@ -212,7 +212,8 @@ codeblock_tree_delete(codeblock_t *block) return; } else { /*Difficult case - node has two children. Walk right child to find lowest node*/ - codeblock_t *lowest = &codeblock[block->right], *highest; + codeblock_t *lowest = &codeblock[block->right]; + codeblock_t *highest; codeblock_t *old_parent; uint16_t lowest_nr; diff --git a/src/codegen_new/codegen_allocator.c b/src/codegen_new/codegen_allocator.c index 2badc35e8..9661cf631 100644 --- a/src/codegen_new/codegen_allocator.c +++ b/src/codegen_new/codegen_allocator.c @@ -32,8 +32,6 @@ int codegen_allocator_usage = 0; void codegen_allocator_init(void) { - int c; - #if defined WIN32 || defined _WIN32 || defined _WIN32 mem_block_alloc = VirtualAlloc(NULL, MEM_BLOCK_NR * MEM_BLOCK_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); /* TODO: check deployment target: older Intel-based versions of macOS don't play @@ -44,7 +42,7 @@ codegen_allocator_init(void) mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0); #endif - for (c = 0; c < MEM_BLOCK_NR; c++) { + for (uint32_t c = 0; c < MEM_BLOCK_NR; c++) { mem_blocks[c].offset = c * MEM_BLOCK_SIZE; mem_blocks[c].code_block = BLOCK_INVALID; if (c < MEM_BLOCK_NR - 1) diff --git a/src/codegen_new/codegen_backend_arm64_imm.c b/src/codegen_new/codegen_backend_arm64_imm.c index 5e1e1038f..6e5034cc0 100644 --- a/src/codegen_new/codegen_backend_arm64_imm.c +++ b/src/codegen_new/codegen_backend_arm64_imm.c @@ -1313,7 +1313,8 @@ static uint32_t imm_table[][2] = { uint32_t host_arm64_find_imm(uint32_t data) { - int l = 0, r = IMM_NR - 1; + int l = 0; + int r = IMM_NR - 1; while (l <= r) { int m = (l + r) >> 1; diff --git a/src/codegen_new/codegen_backend_x86.c b/src/codegen_new/codegen_backend_x86.c index 2de794ad1..f656e708f 100644 --- a/src/codegen_new/codegen_backend_x86.c +++ b/src/codegen_new/codegen_backend_x86.c @@ -263,7 +263,6 @@ void codegen_backend_init(void) { codeblock_t *block; - int c; codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t)); codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *)); @@ -271,7 +270,7 @@ codegen_backend_init(void) memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); - for (c = 0; c < BLOCK_SIZE; c++) + for (uint32_t c = 0; c < BLOCK_SIZE; c++) codeblock[c].pc = BLOCK_PC_INVALID; block_current = 0; diff --git a/src/codegen_new/codegen_backend_x86_uops.c b/src/codegen_new/codegen_backend_x86_uops.c index 83844b3cd..00ae453c3 100644 --- a/src/codegen_new/codegen_backend_x86_uops.c +++ b/src/codegen_new/codegen_backend_x86_uops.c @@ -34,8 +34,12 @@ static int codegen_ADD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -61,8 +65,10 @@ codegen_ADD(codeblock_t *block, uop_t *uop) static int codegen_ADD_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -105,8 +111,12 @@ codegen_ADD_LSHIFT(codeblock_t *block, uop_t *uop) static int codegen_AND(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PAND_XREG_XREG(block, dest_reg, src_reg_b); @@ -133,8 +143,10 @@ codegen_AND(codeblock_t *block, uop_t *uop) static int codegen_AND_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -159,8 +171,14 @@ codegen_AND_IMM(codeblock_t *block, uop_t *uop) static int codegen_ANDN(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), /*src_reg_a = HOST_REG_GET(uop->src_reg_a_real), */ src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); +#if 0 + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); +#endif + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PANDN_XREG_XREG(block, dest_reg, src_reg_b); @@ -267,8 +285,10 @@ codegen_CMP_IMM_JZ_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JB(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); uint32_t *jump_p; if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { @@ -286,8 +306,10 @@ codegen_CMP_JB(codeblock_t *block, uop_t *uop) static int codegen_CMP_JNBE(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); uint32_t *jump_p; if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { @@ -306,8 +328,10 @@ codegen_CMP_JNBE(codeblock_t *block, uop_t *uop) static int codegen_CMP_JNB_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -327,8 +351,10 @@ codegen_CMP_JNB_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JNBE_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -348,8 +374,10 @@ codegen_CMP_JNBE_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JNL_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -369,8 +397,10 @@ codegen_CMP_JNL_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JNLE_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -390,8 +420,10 @@ codegen_CMP_JNLE_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JNO_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -411,8 +443,10 @@ codegen_CMP_JNO_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JNZ_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -432,8 +466,10 @@ codegen_CMP_JNZ_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JB_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -453,8 +489,10 @@ codegen_CMP_JB_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JBE_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -474,8 +512,10 @@ codegen_CMP_JBE_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JL_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -495,8 +535,10 @@ codegen_CMP_JL_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JLE_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -516,8 +558,10 @@ codegen_CMP_JLE_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JO_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -537,8 +581,10 @@ codegen_CMP_JO_DEST(codeblock_t *block, uop_t *uop) static int codegen_CMP_JZ_DEST(codeblock_t *block, uop_t *uop) { - int src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { host_x86_CMP32_REG_REG(block, src_reg_a, src_reg_b); @@ -559,8 +605,10 @@ codegen_CMP_JZ_DEST(codeblock_t *block, uop_t *uop) static int codegen_FABS(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_D(dest_size) && REG_IS_D(src_size_a) && dest_reg == src_reg_a) { host_x86_PXOR_XREG_XREG(block, REG_XMM_TEMP, REG_XMM_TEMP); @@ -576,8 +624,10 @@ codegen_FABS(codeblock_t *block, uop_t *uop) static int codegen_FCHS(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_D(dest_size) && REG_IS_D(src_size_a)) { host_x86_MOVQ_XREG_XREG(block, REG_XMM_TEMP, src_reg_a); @@ -593,8 +643,10 @@ codegen_FCHS(codeblock_t *block, uop_t *uop) static int codegen_FSQRT(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_D(dest_size) && REG_IS_D(src_size_a)) { host_x86_SQRTSD_XREG_XREG(block, dest_reg, src_reg_a); @@ -608,8 +660,10 @@ codegen_FSQRT(codeblock_t *block, uop_t *uop) static int codegen_FTST(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_W(dest_size) && REG_IS_D(src_size_a)) { host_x86_PXOR_XREG_XREG(block, REG_XMM_TEMP, REG_XMM_TEMP); @@ -634,8 +688,12 @@ codegen_FTST(codeblock_t *block, uop_t *uop) static int codegen_FADD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_D(dest_size) && REG_IS_D(src_size_a) && REG_IS_D(src_size_b) && dest_reg == src_reg_a) { host_x86_ADDSD_XREG_XREG(block, dest_reg, src_reg_b); @@ -649,8 +707,12 @@ codegen_FADD(codeblock_t *block, uop_t *uop) static int codegen_FCOM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_W(dest_size) && REG_IS_D(src_size_a) && REG_IS_D(src_size_b)) { if (dest_reg != REG_EAX) @@ -673,8 +735,12 @@ codegen_FCOM(codeblock_t *block, uop_t *uop) static int codegen_FDIV(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_D(dest_size) && REG_IS_D(src_size_a) && REG_IS_D(src_size_b) && dest_reg == src_reg_a) { host_x86_DIVSD_XREG_XREG(block, dest_reg, src_reg_b); @@ -692,8 +758,12 @@ codegen_FDIV(codeblock_t *block, uop_t *uop) static int codegen_FMUL(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_D(dest_size) && REG_IS_D(src_size_a) && REG_IS_D(src_size_b) && dest_reg == src_reg_a) { host_x86_MULSD_XREG_XREG(block, dest_reg, src_reg_b); @@ -707,8 +777,12 @@ codegen_FMUL(codeblock_t *block, uop_t *uop) static int codegen_FSUB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_D(dest_size) && REG_IS_D(src_size_a) && REG_IS_D(src_size_b) && dest_reg == src_reg_a) { host_x86_SUBSD_XREG_XREG(block, dest_reg, src_reg_b); @@ -864,7 +938,8 @@ codegen_LOAD_SEG(codeblock_t *block, uop_t *uop) static int codegen_MEM_LOAD_ABS(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); host_x86_LEA_REG_IMM(block, REG_ESI, seg_reg, uop->imm_data); @@ -894,7 +969,9 @@ codegen_MEM_LOAD_ABS(codeblock_t *block, uop_t *uop) static int codegen_MEM_LOAD_REG(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); host_x86_LEA_REG_REG(block, REG_ESI, seg_reg, addr_reg); @@ -930,7 +1007,9 @@ codegen_MEM_LOAD_REG(codeblock_t *block, uop_t *uop) static int codegen_MEM_LOAD_SINGLE(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); # ifdef RECOMPILER_DEBUG int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); @@ -951,7 +1030,9 @@ codegen_MEM_LOAD_SINGLE(codeblock_t *block, uop_t *uop) static int codegen_MEM_LOAD_DOUBLE(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); # ifdef RECOMPILER_DEBUG int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); @@ -972,7 +1053,8 @@ codegen_MEM_LOAD_DOUBLE(codeblock_t *block, uop_t *uop) static int codegen_MEM_STORE_ABS(codeblock_t *block, uop_t *uop) { - int seg_reg = HOST_REG_GET(uop->src_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_b_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_b_real); int src_size = IREG_GET_SIZE(uop->src_reg_b_real); host_x86_LEA_REG_IMM(block, REG_ESI, seg_reg, uop->imm_data); @@ -999,7 +1081,9 @@ codegen_MEM_STORE_ABS(codeblock_t *block, uop_t *uop) static int codegen_MEM_STORE_REG(codeblock_t *block, uop_t *uop) { - int seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real), src_reg = HOST_REG_GET(uop->src_reg_c_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int src_reg = HOST_REG_GET(uop->src_reg_c_real); int src_size = IREG_GET_SIZE(uop->src_reg_c_real); host_x86_LEA_REG_REG(block, REG_ESI, seg_reg, addr_reg); @@ -1031,7 +1115,8 @@ codegen_MEM_STORE_REG(codeblock_t *block, uop_t *uop) static int codegen_MEM_STORE_IMM_8(codeblock_t *block, uop_t *uop) { - int seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); host_x86_LEA_REG_REG(block, REG_ESI, seg_reg, addr_reg); host_x86_MOV8_REG_IMM(block, REG_ECX, uop->imm_data); @@ -1044,7 +1129,8 @@ codegen_MEM_STORE_IMM_8(codeblock_t *block, uop_t *uop) static int codegen_MEM_STORE_IMM_16(codeblock_t *block, uop_t *uop) { - int seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); host_x86_LEA_REG_REG(block, REG_ESI, seg_reg, addr_reg); host_x86_MOV16_REG_IMM(block, REG_ECX, uop->imm_data); @@ -1057,7 +1143,8 @@ codegen_MEM_STORE_IMM_16(codeblock_t *block, uop_t *uop) static int codegen_MEM_STORE_IMM_32(codeblock_t *block, uop_t *uop) { - int seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); host_x86_LEA_REG_REG(block, REG_ESI, seg_reg, addr_reg); host_x86_MOV32_REG_IMM(block, REG_ECX, uop->imm_data); @@ -1071,7 +1158,9 @@ codegen_MEM_STORE_IMM_32(codeblock_t *block, uop_t *uop) static int codegen_MEM_STORE_SINGLE(codeblock_t *block, uop_t *uop) { - int seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real), src_reg = HOST_REG_GET(uop->src_reg_c_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int src_reg = HOST_REG_GET(uop->src_reg_c_real); # ifdef RECOMPILER_DEBUG int src_size = IREG_GET_SIZE(uop->src_reg_c_real); @@ -1091,7 +1180,9 @@ codegen_MEM_STORE_SINGLE(codeblock_t *block, uop_t *uop) static int codegen_MEM_STORE_DOUBLE(codeblock_t *block, uop_t *uop) { - int seg_reg = HOST_REG_GET(uop->src_reg_a_real), addr_reg = HOST_REG_GET(uop->src_reg_b_real), src_reg = HOST_REG_GET(uop->src_reg_c_real); + int seg_reg = HOST_REG_GET(uop->src_reg_a_real); + int addr_reg = HOST_REG_GET(uop->src_reg_b_real); + int src_reg = HOST_REG_GET(uop->src_reg_c_real); # ifdef RECOMPILER_DEBUG int src_size = IREG_GET_SIZE(uop->src_reg_c_real); @@ -1112,8 +1203,10 @@ codegen_MEM_STORE_DOUBLE(codeblock_t *block, uop_t *uop) static int codegen_MOV(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { host_x86_MOV32_REG_REG(block, dest_reg, src_reg); @@ -1205,8 +1298,10 @@ codegen_MOVZX_REG_PTR_16(codeblock_t *block, uop_t *uop) static int codegen_MOVSX(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_W(src_size)) { host_x86_MOVSX_REG_32_16(block, dest_reg, src_reg); @@ -1224,8 +1319,10 @@ codegen_MOVSX(codeblock_t *block, uop_t *uop) static int codegen_MOVZX(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_Q(dest_size) && REG_IS_L(src_size)) { host_x86_MOVD_XREG_REG(block, dest_reg, src_reg); @@ -1248,8 +1345,10 @@ codegen_MOVZX(codeblock_t *block, uop_t *uop) static int codegen_MOV_DOUBLE_INT(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_D(dest_size) && REG_IS_L(src_size)) { host_x86_CVTSI2SD_XREG_REG(block, dest_reg, src_reg); @@ -1273,8 +1372,10 @@ codegen_MOV_DOUBLE_INT(codeblock_t *block, uop_t *uop) static int codegen_MOV_INT_DOUBLE(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_D(src_size)) { host_x86_LDMXCSR(block, &cpu_state.new_fp_control); @@ -1296,8 +1397,13 @@ codegen_MOV_INT_DOUBLE(codeblock_t *block, uop_t *uop) static int codegen_MOV_INT_DOUBLE_64(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real), src_64_reg = HOST_REG_GET(uop->src_reg_b_real), tag_reg = HOST_REG_GET(uop->src_reg_c_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real), src_64_size = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int src_64_reg = HOST_REG_GET(uop->src_reg_b_real); + int tag_reg = HOST_REG_GET(uop->src_reg_c_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int src_64_size = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_D(src_size) && REG_IS_Q(src_64_size)) { uint32_t *branch_offset; @@ -1334,8 +1440,12 @@ codegen_NOP(codeblock_t *block, uop_t *uop) static int codegen_OR(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_POR_XREG_XREG(block, dest_reg, src_reg_b); @@ -1361,7 +1471,8 @@ codegen_OR(codeblock_t *block, uop_t *uop) static int codegen_OR_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); if (REG_IS_L(dest_size) && dest_reg == src_reg) { @@ -1381,8 +1492,10 @@ codegen_OR_IMM(codeblock_t *block, uop_t *uop) static int codegen_PACKSSWB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PACKSSWB_XREG_XREG(block, dest_reg, src_reg_b); @@ -1396,8 +1509,10 @@ codegen_PACKSSWB(codeblock_t *block, uop_t *uop) static int codegen_PACKSSDW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PACKSSDW_XREG_XREG(block, dest_reg, src_reg_b); @@ -1411,8 +1526,10 @@ codegen_PACKSSDW(codeblock_t *block, uop_t *uop) static int codegen_PACKUSWB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PACKUSWB_XREG_XREG(block, dest_reg, src_reg_b); @@ -1427,8 +1544,10 @@ codegen_PACKUSWB(codeblock_t *block, uop_t *uop) static int codegen_PADDB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PADDB_XREG_XREG(block, dest_reg, src_reg_b); @@ -1442,8 +1561,10 @@ codegen_PADDB(codeblock_t *block, uop_t *uop) static int codegen_PADDW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PADDW_XREG_XREG(block, dest_reg, src_reg_b); @@ -1457,8 +1578,10 @@ codegen_PADDW(codeblock_t *block, uop_t *uop) static int codegen_PADDD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PADDD_XREG_XREG(block, dest_reg, src_reg_b); @@ -1472,8 +1595,10 @@ codegen_PADDD(codeblock_t *block, uop_t *uop) static int codegen_PADDSB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PADDSB_XREG_XREG(block, dest_reg, src_reg_b); @@ -1487,8 +1612,10 @@ codegen_PADDSB(codeblock_t *block, uop_t *uop) static int codegen_PADDSW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PADDSW_XREG_XREG(block, dest_reg, src_reg_b); @@ -1502,8 +1629,10 @@ codegen_PADDSW(codeblock_t *block, uop_t *uop) static int codegen_PADDUSB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PADDUSB_XREG_XREG(block, dest_reg, src_reg_b); @@ -1517,8 +1646,10 @@ codegen_PADDUSB(codeblock_t *block, uop_t *uop) static int codegen_PADDUSW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PADDUSW_XREG_XREG(block, dest_reg, src_reg_b); @@ -1533,8 +1664,10 @@ codegen_PADDUSW(codeblock_t *block, uop_t *uop) static int codegen_PCMPEQB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PCMPEQB_XREG_XREG(block, dest_reg, src_reg_b); @@ -1548,8 +1681,10 @@ codegen_PCMPEQB(codeblock_t *block, uop_t *uop) static int codegen_PCMPEQW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PCMPEQW_XREG_XREG(block, dest_reg, src_reg_b); @@ -1563,8 +1698,10 @@ codegen_PCMPEQW(codeblock_t *block, uop_t *uop) static int codegen_PCMPEQD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PCMPEQD_XREG_XREG(block, dest_reg, src_reg_b); @@ -1578,8 +1715,10 @@ codegen_PCMPEQD(codeblock_t *block, uop_t *uop) static int codegen_PCMPGTB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PCMPGTB_XREG_XREG(block, dest_reg, src_reg_b); @@ -1593,8 +1732,10 @@ codegen_PCMPGTB(codeblock_t *block, uop_t *uop) static int codegen_PCMPGTW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PCMPGTW_XREG_XREG(block, dest_reg, src_reg_b); @@ -1608,8 +1749,10 @@ codegen_PCMPGTW(codeblock_t *block, uop_t *uop) static int codegen_PCMPGTD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PCMPGTD_XREG_XREG(block, dest_reg, src_reg_b); @@ -1624,8 +1767,10 @@ codegen_PCMPGTD(codeblock_t *block, uop_t *uop) static int codegen_PF2ID(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a)) { host_x86_LDMXCSR(block, &cpu_state.trunc_fp_control); @@ -1641,8 +1786,10 @@ codegen_PF2ID(codeblock_t *block, uop_t *uop) static int codegen_PFADD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_ADDPS_XREG_XREG(block, dest_reg, src_reg_b); @@ -1656,8 +1803,10 @@ codegen_PFADD(codeblock_t *block, uop_t *uop) static int codegen_PFCMPEQ(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_CMPPS_XREG_XREG(block, dest_reg, src_reg_b, CMPPS_EQ); @@ -1671,8 +1820,10 @@ codegen_PFCMPEQ(codeblock_t *block, uop_t *uop) static int codegen_PFCMPGE(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_CMPPS_XREG_XREG(block, dest_reg, src_reg_b, CMPPS_NLT); @@ -1686,8 +1837,10 @@ codegen_PFCMPGE(codeblock_t *block, uop_t *uop) static int codegen_PFCMPGT(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_CMPPS_XREG_XREG(block, dest_reg, src_reg_b, CMPPS_NLE); @@ -1701,8 +1854,10 @@ codegen_PFCMPGT(codeblock_t *block, uop_t *uop) static int codegen_PFMAX(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_MAXPS_XREG_XREG(block, dest_reg, src_reg_b); @@ -1716,8 +1871,10 @@ codegen_PFMAX(codeblock_t *block, uop_t *uop) static int codegen_PFMIN(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_MINPS_XREG_XREG(block, dest_reg, src_reg_b); @@ -1731,8 +1888,10 @@ codegen_PFMIN(codeblock_t *block, uop_t *uop) static int codegen_PFMUL(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_MULPS_XREG_XREG(block, dest_reg, src_reg_b); @@ -1746,8 +1905,10 @@ codegen_PFMUL(codeblock_t *block, uop_t *uop) static int codegen_PFRCP(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a)) { /*TODO: This could be improved (use RCPSS + iteration)*/ @@ -1766,8 +1927,10 @@ codegen_PFRCP(codeblock_t *block, uop_t *uop) static int codegen_PFRSQRT(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a)) { /*TODO: This could be improved (use RSQRTSS + iteration)*/ @@ -1786,8 +1949,12 @@ codegen_PFRSQRT(codeblock_t *block, uop_t *uop) static int codegen_PFSUB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_SUBPS_XREG_XREG(block, dest_reg, src_reg_b); @@ -1805,8 +1972,10 @@ codegen_PFSUB(codeblock_t *block, uop_t *uop) static int codegen_PI2FD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a)) { host_x86_CVTDQ2PS_XREG_XREG(block, dest_reg, src_reg_a); @@ -1821,8 +1990,10 @@ codegen_PI2FD(codeblock_t *block, uop_t *uop) static int codegen_PMADDWD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PMADDWD_XREG_XREG(block, dest_reg, src_reg_b); @@ -1836,8 +2007,10 @@ codegen_PMADDWD(codeblock_t *block, uop_t *uop) static int codegen_PMULHW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PMULHW_XREG_XREG(block, dest_reg, src_reg_b); @@ -1851,8 +2024,10 @@ codegen_PMULHW(codeblock_t *block, uop_t *uop) static int codegen_PMULLW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PMULLW_XREG_XREG(block, dest_reg, src_reg_b); @@ -2003,8 +2178,10 @@ codegen_PSRLQ_IMM(codeblock_t *block, uop_t *uop) static int codegen_PSUBB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PSUBB_XREG_XREG(block, dest_reg, src_reg_b); @@ -2018,8 +2195,10 @@ codegen_PSUBB(codeblock_t *block, uop_t *uop) static int codegen_PSUBW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PSUBW_XREG_XREG(block, dest_reg, src_reg_b); @@ -2033,8 +2212,10 @@ codegen_PSUBW(codeblock_t *block, uop_t *uop) static int codegen_PSUBD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PSUBD_XREG_XREG(block, dest_reg, src_reg_b); @@ -2048,8 +2229,10 @@ codegen_PSUBD(codeblock_t *block, uop_t *uop) static int codegen_PSUBSB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PSUBSB_XREG_XREG(block, dest_reg, src_reg_b); @@ -2063,8 +2246,10 @@ codegen_PSUBSB(codeblock_t *block, uop_t *uop) static int codegen_PSUBSW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PSUBSW_XREG_XREG(block, dest_reg, src_reg_b); @@ -2078,8 +2263,10 @@ codegen_PSUBSW(codeblock_t *block, uop_t *uop) static int codegen_PSUBUSB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PSUBUSB_XREG_XREG(block, dest_reg, src_reg_b); @@ -2093,8 +2280,10 @@ codegen_PSUBUSB(codeblock_t *block, uop_t *uop) static int codegen_PSUBUSW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PSUBUSW_XREG_XREG(block, dest_reg, src_reg_b); @@ -2109,8 +2298,10 @@ codegen_PSUBUSW(codeblock_t *block, uop_t *uop) static int codegen_PUNPCKHBW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PUNPCKLBW_XREG_XREG(block, dest_reg, src_reg_b); @@ -2125,8 +2316,10 @@ codegen_PUNPCKHBW(codeblock_t *block, uop_t *uop) static int codegen_PUNPCKHWD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PUNPCKLWD_XREG_XREG(block, dest_reg, src_reg_b); @@ -2141,8 +2334,10 @@ codegen_PUNPCKHWD(codeblock_t *block, uop_t *uop) static int codegen_PUNPCKHDQ(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PUNPCKLDQ_XREG_XREG(block, dest_reg, src_reg_b); @@ -2157,8 +2352,10 @@ codegen_PUNPCKHDQ(codeblock_t *block, uop_t *uop) static int codegen_PUNPCKLBW(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PUNPCKLBW_XREG_XREG(block, dest_reg, src_reg_b); @@ -2172,8 +2369,10 @@ codegen_PUNPCKLBW(codeblock_t *block, uop_t *uop) static int codegen_PUNPCKLWD(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PUNPCKLWD_XREG_XREG(block, dest_reg, src_reg_b); @@ -2187,8 +2386,10 @@ codegen_PUNPCKLWD(codeblock_t *block, uop_t *uop) static int codegen_PUNPCKLDQ(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PUNPCKLDQ_XREG_XREG(block, dest_reg, src_reg_b); @@ -2203,8 +2404,11 @@ codegen_PUNPCKLDQ(codeblock_t *block, uop_t *uop) static int codegen_ROL(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real), shift_reg = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int shift_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); host_x86_MOV32_REG_REG(block, REG_ECX, shift_reg); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { @@ -2229,8 +2433,10 @@ codegen_ROL(codeblock_t *block, uop_t *uop) static int codegen_ROL_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -2254,8 +2460,11 @@ codegen_ROL_IMM(codeblock_t *block, uop_t *uop) static int codegen_ROR(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real), shift_reg = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int shift_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); host_x86_MOV32_REG_REG(block, REG_ECX, shift_reg); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { @@ -2280,8 +2489,10 @@ codegen_ROR(codeblock_t *block, uop_t *uop) static int codegen_ROR_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -2306,8 +2517,11 @@ codegen_ROR_IMM(codeblock_t *block, uop_t *uop) static int codegen_SAR(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real), shift_reg = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int shift_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); host_x86_MOV32_REG_REG(block, REG_ECX, shift_reg); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { @@ -2332,8 +2546,10 @@ codegen_SAR(codeblock_t *block, uop_t *uop) static int codegen_SAR_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -2357,8 +2573,11 @@ codegen_SAR_IMM(codeblock_t *block, uop_t *uop) static int codegen_SHL(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real), shift_reg = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int shift_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); host_x86_MOV32_REG_REG(block, REG_ECX, shift_reg); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { @@ -2383,8 +2602,10 @@ codegen_SHL(codeblock_t *block, uop_t *uop) static int codegen_SHL_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -2408,8 +2629,11 @@ codegen_SHL_IMM(codeblock_t *block, uop_t *uop) static int codegen_SHR(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real), shift_reg = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int shift_reg = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); host_x86_MOV32_REG_REG(block, REG_ECX, shift_reg); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { @@ -2434,8 +2658,10 @@ codegen_SHR(codeblock_t *block, uop_t *uop) static int codegen_SHR_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -2479,8 +2705,12 @@ codegen_STORE_PTR_IMM_16(codeblock_t *block, uop_t *uop) static int codegen_SUB(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_a = HOST_REG_GET(uop->src_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_a = HOST_REG_GET(uop->src_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size_a) && REG_IS_L(src_size_b)) { if (uop->dest_reg_a_real != uop->src_reg_a_real) @@ -2504,8 +2734,10 @@ codegen_SUB(codeblock_t *block, uop_t *uop) static int codegen_SUB_IMM(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg = HOST_REG_GET(uop->src_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg = HOST_REG_GET(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size)) { if (dest_reg != src_reg) @@ -2573,8 +2805,11 @@ codegen_TEST_JS_DEST(codeblock_t *block, uop_t *uop) static int codegen_XOR(codeblock_t *block, uop_t *uop) { - int dest_reg = HOST_REG_GET(uop->dest_reg_a_real), src_reg_b = HOST_REG_GET(uop->src_reg_b_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size_a = IREG_GET_SIZE(uop->src_reg_a_real), src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); + int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); + int src_reg_b = HOST_REG_GET(uop->src_reg_b_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real); + int src_size_b = IREG_GET_SIZE(uop->src_reg_b_real); if (REG_IS_Q(dest_size) && REG_IS_Q(src_size_a) && REG_IS_Q(src_size_b) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_PXOR_XREG_XREG(block, dest_reg, src_reg_b); @@ -2595,7 +2830,8 @@ static int codegen_XOR_IMM(codeblock_t *block, uop_t *uop) { int dest_reg = HOST_REG_GET(uop->dest_reg_a_real); - int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real), src_size = IREG_GET_SIZE(uop->src_reg_a_real); + int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real); + int src_size = IREG_GET_SIZE(uop->src_reg_a_real); if (REG_IS_L(dest_size) && REG_IS_L(src_size) && uop->dest_reg_a_real == uop->src_reg_a_real) { host_x86_XOR32_REG_IMM(block, dest_reg, uop->imm_data); diff --git a/src/codegen_new/codegen_block.c b/src/codegen_new/codegen_block.c index c519b34d2..3a1a5e1ab 100644 --- a/src/codegen_new/codegen_block.c +++ b/src/codegen_new/codegen_block.c @@ -21,7 +21,8 @@ uint8_t *block_write_data = NULL; -int codegen_flat_ds, codegen_flat_ss; +int codegen_flat_ds; +int codegen_flat_ss; int mmx_ebx_ecx_loaded; int codegen_flags_changed = 0; int codegen_fpu_entered = 0; @@ -61,7 +62,8 @@ static void delete_dirty_block(codeblock_t *block); The size of this list is limited to DIRTY_LIST_MAX_SIZE blocks. When this is exceeded the oldest entry will be moved to the free list.*/ -static uint16_t block_dirty_list_head, block_dirty_list_tail; +static uint16_t block_dirty_list_head; +static uint16_t block_dirty_list_tail; static int dirty_list_size = 0; #define DIRTY_LIST_MAX_SIZE 64 @@ -210,13 +212,11 @@ block_free_list_get(void) void codegen_init(void) { - int c; - codegen_allocator_init(); codegen_backend_init(); block_free_list = 0; - for (c = 0; c < BLOCK_SIZE; c++) + for (uint32_t c = 0; c < BLOCK_SIZE; c++) block_free_list_add(&codeblock[c]); block_dirty_list_head = block_dirty_list_tail = 0; dirty_list_size = 0; @@ -472,7 +472,6 @@ codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) { uint16_t block_nr = page->block; int remove_from_evict_list = 0; - int c; while (block_nr) { codeblock_t *block = &codeblock[block_nr]; @@ -509,7 +508,7 @@ codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) page->code_present_mask &= ~page->dirty_mask; page->dirty_mask = 0; - for (c = 0; c < 64; c++) { + for (uint8_t c = 0; c < 64; c++) { if (page->byte_code_present_mask[c] & page->byte_dirty_mask[c]) remove_from_evict_list = 0; page->byte_code_present_mask[c] &= ~page->byte_dirty_mask[c]; diff --git a/src/codegen_new/codegen_ir.c b/src/codegen_new/codegen_ir.c index bc38a3666..44689a5d1 100644 --- a/src/codegen_new/codegen_ir.c +++ b/src/codegen_new/codegen_ir.c @@ -12,7 +12,8 @@ extern int has_ea; static ir_data_t ir_block; -static int codegen_unroll_start, codegen_unroll_count; +static int codegen_unroll_start; +static int codegen_unroll_count; static int codegen_unroll_first_instruction; ir_data_t * @@ -64,13 +65,12 @@ codegen_ir_compile(ir_data_t *ir, codeblock_t *block) int c; if (codegen_unroll_count) { - int unroll_count; int unroll_end; codegen_set_loop_start(ir, codegen_unroll_first_instruction); unroll_end = ir->wr_pos; - for (unroll_count = 1; unroll_count < codegen_unroll_count; unroll_count++) { + for (int unroll_count = 1; unroll_count < codegen_unroll_count; unroll_count++) { int offset = ir->wr_pos - codegen_unroll_start; // pclog("Unroll from %i to %i, offset %i - iteration %i\n", codegen_unroll_start, ir->wr_pos, offset, unroll_count); for (c = codegen_unroll_start; c < unroll_end; c++) { diff --git a/src/codegen_new/codegen_ops_branch.c b/src/codegen_new/codegen_ops_branch.c index 85ebd3f8e..9a6722342 100644 --- a/src/codegen_new/codegen_ops_branch.c +++ b/src/codegen_new/codegen_ops_branch.c @@ -264,7 +264,8 @@ ropJNE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne static int ropJBE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc) { - int jump_uop, jump_uop2 = -1; + int jump_uop; + int jump_uop2 = -1; int do_unroll = ((CF_SET() || ZF_SET()) && codegen_can_unroll(block, ir, next_pc, dest_addr)); switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { @@ -331,7 +332,8 @@ ropJBE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne static int ropJNBE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc) { - int jump_uop, jump_uop2 = -1; + int jump_uop; + int jump_uop2 = -1; int do_unroll = ((!CF_SET() && !ZF_SET()) && codegen_can_unroll(block, ir, next_pc, dest_addr)); switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { @@ -686,7 +688,8 @@ ropJNL_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne static int ropJLE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc) { - int jump_uop, jump_uop2 = -1; + int jump_uop; + int jump_uop2 = -1; int do_unroll = (((NF_SET() ? 1 : 0) != (VF_SET() ? 1 : 0) || ZF_SET()) && codegen_can_unroll(block, ir, next_pc, dest_addr)); switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { @@ -748,7 +751,8 @@ ropJLE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne static int ropJNLE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc) { - int jump_uop, jump_uop2 = -1; + int jump_uop; + int jump_uop2 = -1; int do_unroll = ((NF_SET() ? 1 : 0) == (VF_SET() ? 1 : 0) && !ZF_SET() && codegen_can_unroll(block, ir, next_pc, dest_addr)); switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) { @@ -928,7 +932,8 @@ ropLOOPE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, u { uint32_t offset = (int32_t) (int8_t) fastreadb(cs + op_pc); uint32_t dest_addr = op_pc + 1 + offset; - int jump_uop, jump_uop2; + int jump_uop; + int jump_uop2; if (!(op_32 & 0x100)) dest_addr &= 0xffff; @@ -960,7 +965,8 @@ ropLOOPNE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, { uint32_t offset = (int32_t) (int8_t) fastreadb(cs + op_pc); uint32_t dest_addr = op_pc + 1 + offset; - int jump_uop, jump_uop2; + int jump_uop; + int jump_uop2; if (!(op_32 & 0x100)) dest_addr &= 0xffff; diff --git a/src/codegen_new/codegen_ops_misc.c b/src/codegen_new/codegen_ops_misc.c index 7f7613dbf..9a23536ed 100644 --- a/src/codegen_new/codegen_ops_misc.c +++ b/src/codegen_new/codegen_ops_misc.c @@ -269,7 +269,8 @@ uint32_t ropFF_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { x86seg *target_seg = NULL; - int src_reg, sp_reg; + int src_reg; + int sp_reg; if ((fetchdat & 0x38) != 0x00 && (fetchdat & 0x38) != 0x08 && (fetchdat & 0x38) != 0x10 && (fetchdat & 0x38) != 0x20 && (fetchdat & 0x38) != 0x28 && (fetchdat & 0x38) != 0x30) return 0; @@ -367,7 +368,8 @@ uint32_t ropFF_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { x86seg *target_seg = NULL; - int src_reg, sp_reg; + int src_reg; + int sp_reg; if ((fetchdat & 0x38) != 0x00 && (fetchdat & 0x38) != 0x08 && (fetchdat & 0x38) != 0x10 && (fetchdat & 0x38) != 0x20 && (fetchdat & 0x38) != 0x28 && (fetchdat & 0x38) != 0x30) return 0; diff --git a/src/codegen_new/codegen_reg.c b/src/codegen_new/codegen_reg.c index 7cd7b418a..63277690f 100644 --- a/src/codegen_new/codegen_reg.c +++ b/src/codegen_new/codegen_reg.c @@ -30,7 +30,8 @@ typedef struct host_reg_set_t { int nr_regs; } host_reg_set_t; -static host_reg_set_t host_reg_set, host_fp_reg_set; +static host_reg_set_t host_reg_set; +static host_reg_set_t host_fp_reg_set; enum { REG_BYTE, @@ -182,9 +183,7 @@ struct void codegen_reg_mark_as_required(void) { - int reg; - - for (reg = 0; reg < IREG_COUNT; reg++) { + for (uint8_t reg = 0; reg < IREG_COUNT; reg++) { int last_version = reg_last_version[reg]; if (last_version > 0 && ireg_data[reg].is_volatile == REG_PERMANENT) @@ -533,9 +532,8 @@ alloc_reg(ir_reg_t ir_reg) { host_reg_set_t *reg_set = get_reg_set(ir_reg); int nr_regs = (reg_set == &host_reg_set) ? CODEGEN_HOST_REGS : CODEGEN_HOST_FP_REGS; - int c; - for (c = 0; c < nr_regs; c++) { + for (int c = 0; c < nr_regs; c++) { if (IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg)) { #ifndef RELEASE_BUILD if (reg_set->regs[c].version != ir_reg.version) @@ -552,9 +550,8 @@ alloc_dest_reg(ir_reg_t ir_reg, int dest_reference) { host_reg_set_t *reg_set = get_reg_set(ir_reg); int nr_regs = (reg_set == &host_reg_set) ? CODEGEN_HOST_REGS : CODEGEN_HOST_FP_REGS; - int c; - for (c = 0; c < nr_regs; c++) { + for (int c = 0; c < nr_regs; c++) { if (IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg)) { if (reg_set->regs[c].version == ir_reg.version) { reg_set->locked |= (1 << c); @@ -737,10 +734,9 @@ int codegen_reg_is_loaded(ir_reg_t ir_reg) { host_reg_set_t *reg_set = get_reg_set(ir_reg); - int c; /*Search for previous version in host register*/ - for (c = 0; c < reg_set->nr_regs; c++) { + for (int c = 0; c < reg_set->nr_regs; c++) { if (!ir_reg_is_invalid(reg_set->regs[c]) && IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg)) { if (reg_set->regs[c].version <= ir_reg.version - 1) { # ifndef RELEASE_BUILD diff --git a/src/sound/snd_cmi8x38.c b/src/sound/snd_cmi8x38.c index cd0021148..ee37d7f26 100644 --- a/src/sound/snd_cmi8x38.c +++ b/src/sound/snd_cmi8x38.c @@ -1249,8 +1249,10 @@ cmi8x38_speed_changed(void *priv) { cmi8x38_t *dev = (cmi8x38_t *) priv; double freq; - uint8_t dsr = dev->io_regs[0x09], freqreg = dev->io_regs[0x05] >> 2; - uint8_t chfmt45 = dev->io_regs[0x0b], chfmt6 = dev->io_regs[0x15]; + uint8_t dsr = dev->io_regs[0x09]; + uint8_t freqreg = dev->io_regs[0x05] >> 2; + uint8_t chfmt45 = dev->io_regs[0x0b]; + uint8_t chfmt6 = dev->io_regs[0x15]; #ifdef ENABLE_CMI8X38_LOG char buf[256]; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index addba804c..9ec196d86 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -2241,7 +2241,7 @@ rect_fill_pix: } } else if (dev->accel.output && !dev->accel.input) { while (count-- && (dev->accel.sy >= 0)) { - if ((dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b)) { + if (dev->accel.cx >= dev->accel.clip_left && dev->accel.cx <= clip_r && dev->accel.cy >= dev->accel.clip_top && dev->accel.cy <= clip_b) { src_dat = cpu_dat; if (!dev->accel.odd_out && !dev->accel.sx) { READ(dev->accel.newdest_out + dev->accel.cur_x, dest_dat); @@ -3363,7 +3363,6 @@ static void ibm8514_render_8bpp(svga_t *svga) { ibm8514_t *dev = &svga->dev8514; - int x; uint32_t *p; uint32_t dat; @@ -3378,7 +3377,7 @@ ibm8514_render_8bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x += 8) { + for (int x = 0; x <= dev->h_disp; x += 8) { dat = *(uint32_t *) (&dev->vram[dev->ma & dev->vram_mask]); p[0] = dev->map8[dat & 0xff]; p[1] = dev->map8[(dat >> 8) & 0xff]; @@ -3401,22 +3400,19 @@ ibm8514_render_8bpp(svga_t *svga) static void ibm8514_render_overscan_left(ibm8514_t *dev, svga_t *svga) { - int i; - if ((dev->displine + svga->y_add) < 0) return; if (svga->scrblank || (dev->h_disp == 0)) return; - for (i = 0; i < svga->x_add; i++) + for (int i = 0; i < svga->x_add; i++) buffer32->line[dev->displine + svga->y_add][i] = svga->overscan_color; } static void ibm8514_render_overscan_right(ibm8514_t *dev, svga_t *svga) { - int i; int right; if ((dev->displine + svga->y_add) < 0) @@ -3426,7 +3422,7 @@ ibm8514_render_overscan_right(ibm8514_t *dev, svga_t *svga) return; right = (overscan_x >> 1); - for (i = 0; i < right; i++) + for (int i = 0; i < right; i++) buffer32->line[dev->displine + svga->y_add][svga->x_add + dev->h_disp + i] = svga->overscan_color; } diff --git a/src/video/vid_ati18800.c b/src/video/vid_ati18800.c index 3781ef567..2b37eb6fd 100644 --- a/src/video/vid_ati18800.c +++ b/src/video/vid_ati18800.c @@ -207,7 +207,7 @@ ati18800_init(const device_t *info) case ATI18800_EDGE16: rom_init(&ati18800->bios_rom, BIOS_ROM_PATH_EDGE16, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); break; - }; + } if (info->local == ATI18800_EDGE16) { svga_init(info, &ati18800->svga, ati18800, 1 << 18, /*256kb*/ diff --git a/src/video/vid_ati28800.c b/src/video/vid_ati28800.c index 352ce2f7d..b41e1ca82 100644 --- a/src/video/vid_ati28800.c +++ b/src/video/vid_ati28800.c @@ -401,52 +401,52 @@ ati28800_recalctimings(svga_t *svga) switch (((ati28800->regs[0xbe] & 0x10) >> 1) | ((ati28800->regs[0xb9] & 2) << 1) | ((svga->miscout & 0x0C) >> 2)) { case 0x00: - svga->clock = (cpuclock * (double) (1ull << 32)) / 42954000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 42954000.0; break; case 0x01: - svga->clock = (cpuclock * (double) (1ull << 32)) / 48771000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 48771000.0; break; case 0x02: ati28800_log("clock 2\n"); break; case 0x03: - svga->clock = (cpuclock * (double) (1ull << 32)) / 36000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; case 0x04: - svga->clock = (cpuclock * (double) (1ull << 32)) / 50350000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 50350000.0; break; case 0x05: - svga->clock = (cpuclock * (double) (1ull << 32)) / 56640000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 56640000.0; break; case 0x06: ati28800_log("clock 2\n"); break; case 0x07: - svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 44900000.0; break; case 0x08: - svga->clock = (cpuclock * (double) (1ull << 32)) / 30240000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 30240000.0; break; case 0x09: - svga->clock = (cpuclock * (double) (1ull << 32)) / 32000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 32000000.0; break; case 0x0A: - svga->clock = (cpuclock * (double) (1ull << 32)) / 37500000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 37500000.0; break; case 0x0B: - svga->clock = (cpuclock * (double) (1ull << 32)) / 39000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 39000000.0; break; case 0x0C: - svga->clock = (cpuclock * (double) (1ull << 32)) / 50350000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 50350000.0; break; case 0x0D: - svga->clock = (cpuclock * (double) (1ull << 32)) / 56644000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 56644000.0; break; case 0x0E: - svga->clock = (cpuclock * (double) (1ull << 32)) / 75000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 75000000.0; break; case 0x0F: - svga->clock = (cpuclock * (double) (1ull << 32)) / 65000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 65000000.0; break; default: break; @@ -665,7 +665,7 @@ ati28800_init(const device_t *info) break; } - return (ati28800); + return ati28800; } static int @@ -677,20 +677,20 @@ ati28800_available(void) static int ati28800k_available(void) { - return ((rom_present(BIOS_ATIKOR_PATH) && rom_present(FONT_ATIKOR_PATH))); + return (rom_present(BIOS_ATIKOR_PATH) && rom_present(FONT_ATIKOR_PATH)); } static int compaq_ati28800_available(void) { - return ((rom_present(BIOS_VGAXL_ROM_PATH))); + return (rom_present(BIOS_VGAXL_ROM_PATH)); } #if defined(DEV_BRANCH) && defined(USE_XL24) static int ati28800_wonderxl24_available(void) { - return ((rom_present(BIOS_XL24_EVEN_PATH) && rom_present(BIOS_XL24_ODD_PATH))); + return (rom_present(BIOS_XL24_EVEN_PATH) && rom_present(BIOS_XL24_ODD_PATH)); } #endif diff --git a/src/video/vid_ati68860_ramdac.c b/src/video/vid_ati68860_ramdac.c index 49fad5815..7df04001c 100644 --- a/src/video/vid_ati68860_ramdac.c +++ b/src/video/vid_ati68860_ramdac.c @@ -201,12 +201,11 @@ void ati68860_set_ramdac_type(void *p, int type) { ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) p; - int c; if (ramdac->ramdac_type != type) { ramdac->ramdac_type = type; - for (c = 0; c < 2; c++) { + for (uint8_t c = 0; c < 2; c++) { if (ramdac->ramdac_type == RAMDAC_8BIT) ramdac->pallook[c] = makecol32(ramdac->pal[c].r, ramdac->pal[c].g, ramdac->pal[c].b); @@ -248,13 +247,13 @@ void ati68860_hwcursor_draw(svga_t *svga, int displine) { ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) svga->ramdac; - int x, offset; + int offset; uint8_t dat; uint32_t col0 = ramdac->pallook[0]; uint32_t col1 = ramdac->pallook[1]; offset = svga->dac_hwcursor_latch.xoff; - for (x = 0; x < 64 - svga->dac_hwcursor_latch.xoff; x += 4) { + for (uint8_t x = 0; x < 64 - svga->dac_hwcursor_latch.xoff; x += 4) { dat = svga->vram[svga->dac_hwcursor_latch.addr + (offset >> 2)]; if (!(dat & 2)) buffer32->line[displine][svga->dac_hwcursor_latch.x + x + svga->x_add] = (dat & 1) ? col1 : col0; diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index f1840a698..2e10216e4 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -58,7 +58,6 @@ ati_eeprom_save(ati_eeprom_t *eeprom) void ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) { - int c; if (!ena) { eeprom->out = 1; } @@ -157,7 +156,7 @@ ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) case EEPROM_OP_WRALMAIN: if (!eeprom->wp) { - for (c = 0; c < 256; c++) + for (uint16_t c = 0; c < 256; c++) eeprom->data[c] = eeprom->dat; ati_eeprom_save(eeprom); } diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index d5c83f81f..273dbdcf6 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -1179,9 +1179,6 @@ mach64_queue(mach64_t *mach64, uint32_t addr, uint32_t val, uint32_t type) void mach64_start_fill(mach64_t *mach64) { - int x; - int y; - mach64->accel.dst_x = 0; mach64->accel.dst_y = 0; mach64->accel.dst_x_start = (mach64->dst_y_x >> 16) & 0xfff; @@ -1258,8 +1255,8 @@ mach64_start_fill(mach64_t *mach64) mach64->accel.source_host = ((mach64->dp_src & 7) == SRC_HOST) || (((mach64->dp_src >> 8) & 7) == SRC_HOST); - for (y = 0; y < 8; y++) { - for (x = 0; x < 8; x++) { + for (uint8_t y = 0; y < 8; y++) { + for (uint8_t x = 0; x < 8; x++) { uint32_t temp = (y & 4) ? mach64->pat_reg1 : mach64->pat_reg0; mach64->accel.pattern[y][7 - x] = (temp >> (x + ((y & 3) * 8))) & 1; } @@ -1310,9 +1307,6 @@ mach64_start_fill(mach64_t *mach64) void mach64_start_line(mach64_t *mach64) { - int x; - int y; - mach64->accel.dst_x = (mach64->dst_y_x >> 16) & 0xfff; mach64->accel.dst_y = mach64->dst_y_x & 0xfff; @@ -1355,8 +1349,8 @@ mach64_start_line(mach64_t *mach64) mach64->accel.source_host = ((mach64->dp_src & 7) == SRC_HOST) || (((mach64->dp_src >> 8) & 7) == SRC_HOST); - for (y = 0; y < 8; y++) { - for (x = 0; x < 8; x++) { + for (uint8_t y = 0; y < 8; y++) { + for (uint8_t x = 0; x < 8; x++) { uint32_t temp = (y & 4) ? mach64->pat_reg1 : mach64->pat_reg0; mach64->accel.pattern[y][7 - x] = (temp >> (x + ((y & 3) * 8))) & 1; } @@ -2057,8 +2051,6 @@ mach64_load_context(mach64_t *mach64) static void pll_write(mach64_t *mach64, uint32_t addr, uint8_t val) { - int c; - switch (addr & 3) { case 0: /*Clock sel*/ break; @@ -2069,7 +2061,7 @@ pll_write(mach64_t *mach64, uint32_t addr, uint8_t val) mach64->pll_regs[mach64->pll_addr] = val; mach64_log("pll_write %02x,%02x\n", mach64->pll_addr, val); - for (c = 0; c < 4; c++) { + for (uint8_t c = 0; c < 4; c++) { double m = (double) mach64->pll_regs[PLL_REF_DIV]; double n = (double) mach64->pll_regs[VCLK0_FB_DIV + c]; double r = 14318184.0; @@ -3974,7 +3966,6 @@ mach64_overlay_draw(svga_t *svga, int displine) static void mach64_io_remove(mach64_t *mach64) { - int c; uint16_t io_base = 0x02ec; switch (mach64->io_base) { @@ -3995,7 +3986,7 @@ mach64_io_remove(mach64_t *mach64) io_removehandler(0x03c0, 0x0020, mach64_in, NULL, NULL, mach64_out, NULL, NULL, mach64); - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { io_removehandler((c * 0x1000) + 0x0000 + io_base, 0x0004, mach64_ext_inb, mach64_ext_inw, mach64_ext_inl, mach64_ext_outb, mach64_ext_outw, mach64_ext_outl, mach64); io_removehandler((c * 0x1000) + 0x0400 + io_base, 0x0004, mach64_ext_inb, mach64_ext_inw, mach64_ext_inl, mach64_ext_outb, mach64_ext_outw, mach64_ext_outl, mach64); io_removehandler((c * 0x1000) + 0x0800 + io_base, 0x0004, mach64_ext_inb, mach64_ext_inw, mach64_ext_inl, mach64_ext_outb, mach64_ext_outw, mach64_ext_outl, mach64); @@ -4011,14 +4002,12 @@ mach64_io_remove(mach64_t *mach64) static void mach64_io_set(mach64_t *mach64) { - int c; - mach64_io_remove(mach64); io_sethandler(0x03c0, 0x0020, mach64_in, NULL, NULL, mach64_out, NULL, NULL, mach64); if (!mach64->use_block_decoded_io) { - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { io_sethandler((c * 0x1000) + 0x2ec, 0x0004, mach64_ext_inb, mach64_ext_inw, mach64_ext_inl, mach64_ext_outb, mach64_ext_outw, mach64_ext_outl, mach64); io_sethandler((c * 0x1000) + 0x6ec, 0x0004, mach64_ext_inb, mach64_ext_inw, mach64_ext_inl, mach64_ext_outb, mach64_ext_outw, mach64_ext_outl, mach64); io_sethandler((c * 0x1000) + 0xaec, 0x0004, mach64_ext_inb, mach64_ext_inw, mach64_ext_inl, mach64_ext_outb, mach64_ext_outw, mach64_ext_outl, mach64); diff --git a/src/video/vid_bt48x_ramdac.c b/src/video/vid_bt48x_ramdac.c index daf840df8..9ef75b09e 100644 --- a/src/video/vid_bt48x_ramdac.c +++ b/src/video/vid_bt48x_ramdac.c @@ -160,7 +160,7 @@ bt48x_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *p, svga_t * break; case 0x0a: if ((ramdac->type >= BT485) && (ramdac->cmd_r0 & 0x80)) { - switch ((svga->dac_addr & ((ramdac->type >= BT485A) ? 0xff : 0x3f))) { + switch (svga->dac_addr & ((ramdac->type >= BT485A) ? 0xff : 0x3f)) { case 0x01: /* Command Register 3 (RS value = 1010) */ ramdac->cmd_r3 = val; @@ -284,7 +284,7 @@ bt48x_ramdac_in(uint16_t addr, int rs2, int rs3, void *p, svga_t *svga) break; case 0x0a: if ((ramdac->type >= BT485) && (ramdac->cmd_r0 & 0x80)) { - switch ((svga->dac_addr & ((ramdac->type >= BT485A) ? 0xff : 0x3f))) { + switch (svga->dac_addr & ((ramdac->type >= BT485A) ? 0xff : 0x3f)) { case 0x00: default: temp = ramdac->status | (svga->dac_status ? 0x04 : 0x00); @@ -355,11 +355,20 @@ bt48x_recalctimings(void *p, svga_t *svga) void bt48x_hwcursor_draw(svga_t *svga, int displine) { - int x, xx, comb, b0, b1; + int comb; + int b0; + int b1; uint16_t dat[2]; int offset = svga->dac_hwcursor_latch.x - svga->dac_hwcursor_latch.xoff; - int pitch, bppl, mode, x_pos, y_pos; - uint32_t clr1, clr2, clr3, *p; + int pitch; + int bppl; + int mode; + int x_pos; + int y_pos; + uint32_t clr1; + uint32_t clr2; + uint32_t clr3; + uint32_t *p; uint8_t *cd; bt48x_ramdac_t *ramdac = (bt48x_ramdac_t *) svga->ramdac; @@ -384,11 +393,11 @@ bt48x_hwcursor_draw(svga_t *svga, int displine) else cd = (uint8_t *) ramdac->cursor32_data; - for (x = 0; x < svga->dac_hwcursor_latch.cur_xsize; x += 16) { + for (int x = 0; x < svga->dac_hwcursor_latch.cur_xsize; x += 16) { dat[0] = (cd[svga->dac_hwcursor_latch.addr] << 8) | cd[svga->dac_hwcursor_latch.addr + 1]; dat[1] = (cd[svga->dac_hwcursor_latch.addr + bppl] << 8) | cd[svga->dac_hwcursor_latch.addr + bppl + 1]; - for (xx = 0; xx < 16; xx++) { + for (uint8_t xx = 0; xx < 16; xx++) { b0 = (dat[0] >> (15 - xx)) & 1; b1 = (dat[1] >> (15 - xx)) & 1; comb = (b0 | (b1 << 1)); diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 6ed81f616..7239790dc 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -175,7 +175,8 @@ void cga_recalctimings(cga_t *cga) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; if (cga->cgamode & 1) { disptime = (double) (cga->crtc[0] + 1); @@ -197,9 +198,13 @@ cga_poll(void *p) cga_t *cga = (cga_t *) p; uint16_t ca = (cga->crtc[15] | (cga->crtc[14] << 8)) & 0x3fff; int drawcursor; - int x, c, xs_temp, ys_temp; + int x; + int c; + int xs_temp; + int ys_temp; int oldvc; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; uint8_t border; uint16_t dat; int cols[4]; @@ -221,18 +226,18 @@ cga_poll(void *p) cga->lastline = cga->displine; for (c = 0; c < 8; c++) { if ((cga->cgamode & 0x12) == 0x12) { - buffer32->line[(cga->displine << 1)][c] = buffer32->line[(cga->displine << 1) + 1][c] = 0; + buffer32->line[cga->displine << 1][c] = buffer32->line[(cga->displine << 1) + 1][c] = 0; if (cga->cgamode & 1) { - buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 3) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 3) + 8] = 0; + buffer32->line[cga->displine << 1][c + (cga->crtc[1] << 3) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 3) + 8] = 0; } else { - buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 4) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 4) + 8] = 0; + buffer32->line[cga->displine << 1][c + (cga->crtc[1] << 4) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 4) + 8] = 0; } } else { - buffer32->line[(cga->displine << 1)][c] = buffer32->line[(cga->displine << 1) + 1][c] = (cga->cgacol & 15) + 16; + buffer32->line[cga->displine << 1][c] = buffer32->line[(cga->displine << 1) + 1][c] = (cga->cgacol & 15) + 16; if (cga->cgamode & 1) { - buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 3) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 3) + 8] = (cga->cgacol & 15) + 16; + buffer32->line[cga->displine << 1][c + (cga->crtc[1] << 3) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 3) + 8] = (cga->cgacol & 15) + 16; } else { - buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 4) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 4) + 8] = (cga->cgacol & 15) + 16; + buffer32->line[cga->displine << 1][c + (cga->crtc[1] << 4) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 4) + 8] = (cga->cgacol & 15) + 16; } } } @@ -253,11 +258,11 @@ cga_poll(void *p) cols[0] = (attr >> 4) + 16; if (drawcursor) { for (c = 0; c < 8; c++) { - buffer32->line[(cga->displine << 1)][(x << 3) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + buffer32->line[cga->displine << 1][(x << 3) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } } else { for (c = 0; c < 8; c++) { - buffer32->line[(cga->displine << 1)][(x << 3) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + buffer32->line[cga->displine << 1][(x << 3) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } } cga->ma++; @@ -265,8 +270,8 @@ cga_poll(void *p) } else if (!(cga->cgamode & 2)) { for (x = 0; x < cga->crtc[1]; x++) { if (cga->cgamode & 8) { - chr = cga->vram[((cga->ma << 1) & 0x3fff)]; - attr = cga->vram[(((cga->ma << 1) + 1) & 0x3fff)]; + chr = cga->vram[(cga->ma << 1) & 0x3fff]; + attr = cga->vram[((cga->ma << 1) + 1) & 0x3fff]; } else chr = attr = 0; drawcursor = ((cga->ma == ca) && cga->con && cga->cursoron); @@ -280,11 +285,11 @@ cga_poll(void *p) cga->ma++; if (drawcursor) { for (c = 0; c < 8; c++) { - buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + buffer32->line[cga->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[cga->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } } else { for (c = 0; c < 8; c++) { - buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + buffer32->line[cga->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[cga->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } } } @@ -311,7 +316,7 @@ cga_poll(void *p) dat = 0; cga->ma++; for (c = 0; c < 8; c++) { - buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + buffer32->line[cga->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[cga->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; dat <<= 2; } } @@ -325,7 +330,7 @@ cga_poll(void *p) dat = 0; cga->ma++; for (c = 0; c < 16; c++) { - buffer32->line[(cga->displine << 1)][(x << 4) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + c + 8] = cols[dat >> 15]; + buffer32->line[cga->displine << 1][(x << 4) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + c + 8] = cols[dat >> 15]; dat <<= 1; } } @@ -352,7 +357,7 @@ cga_poll(void *p) else border = cga->cgacol & 0x0f; - Composite_Process(cga->cgamode, border, x >> 2, buffer32->line[(cga->displine << 1)]); + Composite_Process(cga->cgamode, border, x >> 2, buffer32->line[cga->displine << 1]); Composite_Process(cga->cgamode, border, x >> 2, buffer32->line[(cga->displine << 1) + 1]); } else { video_process_8(x, cga->displine << 1); @@ -489,11 +494,11 @@ cga_poll(void *p) } if (cga->cgadispon) cga->cgastat &= ~1; - if ((cga->sc == (cga->crtc[10] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[10] & 31) >> 1)))) + if (cga->sc == (cga->crtc[10] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[10] & 31) >> 1))) cga->con = 1; if (cga->cgadispon && (cga->cgamode & 1)) { for (x = 0; x < (cga->crtc[1] << 1); x++) - cga->charbuffer[x] = cga->vram[(((cga->ma << 1) + x) & 0x3fff)]; + cga->charbuffer[x] = cga->vram[((cga->ma << 1) + x) & 0x3fff]; } } } diff --git a/src/video/vid_cga_comp.c b/src/video/vid_cga_comp.c index ad9f673fb..6ffc5cbcd 100644 --- a/src/video/vid_cga_comp.c +++ b/src/video/vid_cga_comp.c @@ -75,7 +75,12 @@ double mode_hue; double min_v; double max_v; -double video_ri, video_rq, video_gi, video_gq, video_bi, video_bq; +double video_ri; +double video_rq; +double video_gi; +double video_gq; +double video_bi; +double video_bq; int video_sharpness; int tandy_mode_control = 0; @@ -84,11 +89,18 @@ static bool new_cga = 0; void update_cga16_color(uint8_t cgamode) { - int x; - double c, i, v; - double q, a, s, r; - double iq_adjust_i, iq_adjust_q; - double i0, i3, mode_saturation; + double c; + double i; + double v; + double q; + double a; + double s; + double r; + double iq_adjust_i; + double iq_adjust_q; + double i0; + double i3; + double mode_saturation; static const double ri = 0.9563; static const double rq = 0.6210; @@ -117,7 +129,7 @@ update_cga16_color(uint8_t cgamode) mode_brightness += (new_cga ? brightness - 10 : brightness) * 5; /* new CGA: -10 */ mode_saturation = (new_cga ? 4.35 : 2.9) * saturation / 100; /* new CGA: 150% */ - for (x = 0; x < 1024; ++x) { + for (uint16_t x = 0; x < 1024; ++x) { int phase = x & 3; int right = (x >> 2) & 15; int left = (x >> 6) & 15; @@ -187,7 +199,8 @@ Composite_Process(uint8_t cgamode, Bit8u border, Bit32u blocks /*, bool doublewi int *b; int *i; Bit32u *srgb; - int *ap, *bp; + int *ap; + int *bp; #define COMPOSITE_CONVERT(I, Q) \ do { \ @@ -257,7 +270,14 @@ Composite_Process(uint8_t cgamode, Bit8u border, Bit32u blocks /*, bool doublewi i[0] = (i[0] << 3) - ap[0]; srgb = (Bit32u *) TempLine; for (x2 = 0; x2 < blocks; ++x2) { - int y, a, b, c, d, rr, gg, bb; + int y; + int a; + int b; + int c; + int d; + int rr; + int gg; + int bb; COMPOSITE_CONVERT(a, b); COMPOSITE_CONVERT(-b, a); COMPOSITE_CONVERT(-a, -b); diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index bc12d988e..637598345 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -515,22 +515,25 @@ gd54xx_overlay_draw(svga_t *svga, int displine) gd54xx_t *gd54xx = (gd54xx_t *) svga->p; int shift = (svga->crtc[0x27] >= CIRRUS_ID_CLGD5446) ? 2 : 0; int h_acc = svga->overlay_latch.h_acc; - int r[8], g[8], b[8]; - int x_read = 4, x_write = 4; - int x; + int r[8]; + int g[8]; + int b[8]; + int x_read = 4; + int x_write = 4; uint32_t *p; uint8_t *src = &svga->vram[(svga->overlay_latch.addr << shift) & svga->vram_mask]; int bpp = svga->bpp; int bytesperpix = (bpp + 7) / 8; uint8_t *src2 = &svga->vram[(svga->ma - (svga->hdisp * bytesperpix)) & svga->vram_display_mask]; - int occl, ckval; + int occl; + int ckval; p = &((uint32_t *) svga->monitor->target_buffer->line[displine])[gd54xx->overlay.region1size + svga->x_add]; src2 += gd54xx->overlay.region1size * bytesperpix; OVERLAY_SAMPLE(); - for (x = 0; (x < gd54xx->overlay.region2size) && ((x + gd54xx->overlay.region1size) < svga->hdisp); x++) { + for (int x = 0; (x < gd54xx->overlay.region2size) && ((x + gd54xx->overlay.region1size) < svga->hdisp); x++) { if (gd54xx->overlay.occlusion) { occl = 1; ckval = gd54xx->overlay.ck; @@ -614,8 +617,8 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) gd54xx_t *gd54xx = (gd54xx_t *) p; svga_t *svga = &gd54xx->svga; uint8_t old; - int c; - uint8_t o, index; + uint8_t o; + uint8_t index; uint32_t o32; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) @@ -637,7 +640,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) if (svga->attraddr < 16) svga->fullchange = changeframecount; if (svga->attraddr == 0x10 || svga->attraddr == 0x14 || svga->attraddr < 0x10) { - for (c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { if (svga->attrregs[0x10] & 0x80) svga->egapal[c] = (svga->attrregs[c] & 0xf) | ((svga->attrregs[0x14] & 0xf) << 4); else @@ -1159,7 +1162,8 @@ gd54xx_in(uint16_t addr, void *p) gd54xx_t *gd54xx = (gd54xx_t *) p; svga_t *svga = &gd54xx->svga; - uint8_t index, ret = 0xff; + uint8_t index; + uint8_t ret = 0xff; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; @@ -1550,7 +1554,8 @@ static void gd543x_recalc_mapping(gd54xx_t *gd54xx) { svga_t *svga = &gd54xx->svga; - uint32_t base, size; + uint32_t base; + uint32_t size; if ((gd54xx->pci && (!(gd54xx->pci_regs[PCI_REG_COMMAND] & PCI_COMMAND_MEM))) || (gd54xx->mca && (!(gd54xx->pos_regs[2] & 1)))) { mem_mapping_disable(&svga->mapping); @@ -1630,7 +1635,7 @@ gd543x_recalc_mapping(gd54xx_t *gd54xx) if ((svga->crtc[0x27] >= CIRRUS_ID_CLGD5436) && (gd54xx->blt.status & CIRRUS_BLT_APERTURE2) && ((gd54xx->blt.mode & (CIRRUS_BLTMODE_COLOREXPAND | CIRRUS_BLTMODE_MEMSYSSRC)) == (CIRRUS_BLTMODE_COLOREXPAND | CIRRUS_BLTMODE_MEMSYSSRC))) { if (svga->crtc[0x27] == CIRRUS_ID_CLGD5480) - mem_mapping_set_addr(&gd54xx->aperture2_mapping, gd54xx->lfb_base + (16777216), 16777216); + mem_mapping_set_addr(&gd54xx->aperture2_mapping, gd54xx->lfb_base + 16777216, 16777216); else mem_mapping_set_addr(&gd54xx->aperture2_mapping, 0xbc000, 0x04000); } else @@ -1642,7 +1647,8 @@ static void gd54xx_recalctimings(svga_t *svga) { gd54xx_t *gd54xx = (gd54xx_t *) svga->p; - uint8_t clocksel, rdmask; + uint8_t clocksel; + uint8_t rdmask; uint8_t linedbl = svga->dispend * 9 / 10 >= svga->hdisp; svga->rowoffset = (svga->crtc[0x13]) | (((int) (uint32_t) (svga->crtc[0x1b] & 0x10)) << 4); @@ -1801,7 +1807,7 @@ gd54xx_recalctimings(svga_t *svga) clocksel = (svga->miscout >> 2) & 3; if (!gd54xx->vclk_n[clocksel] || !gd54xx->vclk_d[clocksel]) - svga->clock = (cpuclock * (float) (1ull << 32)) / ((svga->miscout & 0xc) ? 28322000.0 : 25175000.0); + svga->clock = (cpuclock * (float) (1ULL << 32)) / ((svga->miscout & 0xc) ? 28322000.0 : 25175000.0); else { int n = gd54xx->vclk_n[clocksel] & 0x7f; int d = (gd54xx->vclk_d[clocksel] & 0x3e) >> 1; @@ -1818,7 +1824,7 @@ gd54xx_recalctimings(svga_t *svga) break; } } - svga->clock = (cpuclock * (double) (1ull << 32)) / freq; + svga->clock = (cpuclock * (double) (1ULL << 32)) / freq; } svga->vram_display_mask = (svga->crtc[0x1b] & 2) ? gd54xx->vram_mask : 0x3ffff; @@ -1828,7 +1834,9 @@ static void gd54xx_hwcursor_draw(svga_t *svga, int displine) { gd54xx_t *gd54xx = (gd54xx_t *) svga->p; - int x, xx, comb, b0, b1; + int comb; + int b0; + int b1; uint8_t dat[2]; int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff; int pitch = (svga->hwcursor.cur_xsize == 64) ? 16 : 4; @@ -1841,13 +1849,13 @@ gd54xx_hwcursor_draw(svga_t *svga, int displine) if (svga->interlace && svga->hwcursor_oddeven) svga->hwcursor_latch.addr += pitch; - for (x = 0; x < svga->hwcursor.cur_xsize; x += 8) { + for (int x = 0; x < svga->hwcursor.cur_xsize; x += 8) { dat[0] = svga->vram[svga->hwcursor_latch.addr & svga->vram_display_mask]; if (svga->hwcursor.cur_xsize == 64) dat[1] = svga->vram[(svga->hwcursor_latch.addr + 0x08) & svga->vram_display_mask]; else dat[1] = svga->vram[(svga->hwcursor_latch.addr + 0x80) & svga->vram_display_mask]; - for (xx = 0; xx < 8; xx++) { + for (uint8_t xx = 0; xx < 8; xx++) { b0 = (dat[0] >> (7 - xx)) & 1; b1 = (dat[1] >> (7 - xx)) & 1; comb = (b1 | (b0 << 1)); @@ -1966,15 +1974,13 @@ gd54xx_mem_sys_dest_read(gd54xx_t *gd54xx) static void gd54xx_mem_sys_src_write(gd54xx_t *gd54xx, uint8_t val) { - int i; - gd54xx->blt.sys_src32 &= ~(0xff << (gd54xx->blt.sys_cnt << 3)); gd54xx->blt.sys_src32 |= (val << (gd54xx->blt.sys_cnt << 3)); gd54xx->blt.sys_cnt = (gd54xx->blt.sys_cnt + 1) & 3; if (gd54xx->blt.sys_cnt == 0) { if ((gd54xx->blt.mode & CIRRUS_BLTMODE_COLOREXPAND) && !(gd54xx->blt.modeext & CIRRUS_BLTMODEEXT_DWORDGRANULARITY)) { - for (i = 0; i < 32; i += 8) + for (uint8_t i = 0; i < 32; i += 8) gd54xx_start_blit((gd54xx->blt.sys_src32 >> i) & 0xff, 8, gd54xx, &gd54xx->svga); } else gd54xx_start_blit(gd54xx->blt.sys_src32, 32, gd54xx, &gd54xx->svga); @@ -2064,7 +2070,8 @@ gd54xx_writel(uint32_t addr, uint32_t val, void *p) static void gd54xx_write_modes45(svga_t *svga, uint8_t val, uint32_t addr) { - uint32_t i, j; + uint32_t i; + uint32_t j; switch (svga->writemode) { case 4: @@ -3152,7 +3159,8 @@ gd54xx_get_pixel_width(gd54xx_t *gd54xx) static void gd54xx_blit(gd54xx_t *gd54xx, uint8_t mask, uint8_t *dst, uint8_t target, int skip) { - int is_transp, is_bgonly; + int is_transp; + int is_bgonly; /* skip indicates whether or not it is a pixel to be skipped (used for left skip); mask indicates transparency or not (only when transparent comparison is enabled): @@ -3204,10 +3212,16 @@ gd54xx_transparent_comp(gd54xx_t *gd54xx, uint32_t xx, uint8_t src) static void gd54xx_pattern_copy(gd54xx_t *gd54xx) { - uint8_t target, src, *dst; - int x, y, pattern_y, pattern_pitch; - uint32_t bitmask = 0, xx, pixel; - uint32_t srca, srca2, dsta; + uint8_t target; + uint8_t src; + uint8_t *dst; + int pattern_y; + int pattern_pitch; + uint32_t bitmask = 0; + uint32_t pixel; + uint32_t srca; + uint32_t srca2; + uint32_t dsta; svga_t *svga = &gd54xx->svga; pattern_pitch = gd54xx->blt.pixel_width << 3; @@ -3234,18 +3248,18 @@ gd54xx_pattern_copy(gd54xx_t *gd54xx) /* The boundary has to be equal to the size of the pattern. */ srca = (gd54xx->blt.src_addr & ~0x07) & svga->vram_mask; - for (y = 0; y <= gd54xx->blt.height; y++) { + for (uint16_t y = 0; y <= gd54xx->blt.height; y++) { /* Go to the correct pattern line. */ srca2 = srca + (pattern_y * pattern_pitch); pixel = 0; - for (x = 0; x <= gd54xx->blt.width; x += gd54xx->blt.pixel_width) { + for (uint16_t x = 0; x <= gd54xx->blt.width; x += gd54xx->blt.pixel_width) { if (gd54xx->blt.mode & CIRRUS_BLTMODE_COLOREXPAND) { if (gd54xx->blt.modeext & CIRRUS_BLTMODEEXT_SOLIDFILL) bitmask = 1; else bitmask = svga->vram[srca2 & svga->vram_mask] & (0x80 >> pixel); } - for (xx = 0; xx < gd54xx->blt.pixel_width; xx++) { + for (int xx = 0; xx < gd54xx->blt.pixel_width; xx++) { if (gd54xx->blt.mode & CIRRUS_BLTMODE_COLOREXPAND) src = gd54xx_color_expand(gd54xx, bitmask, xx); else { @@ -3280,9 +3294,12 @@ gd54xx_reset_blit(gd54xx_t *gd54xx) static void gd54xx_mem_sys_src(gd54xx_t *gd54xx, uint32_t cpu_dat, uint32_t count) { - uint8_t *dst, exp, target; + uint8_t *dst; + uint8_t exp; + uint8_t target; int mask_shift; - uint32_t byte_pos, bitmask = 0; + uint32_t byte_pos; + uint32_t bitmask = 0; svga_t *svga = &gd54xx->svga; gd54xx->blt.ms_is_dest = 0; @@ -3367,9 +3384,12 @@ gd54xx_mem_sys_src(gd54xx_t *gd54xx, uint32_t cpu_dat, uint32_t count) static void gd54xx_normal_blit(uint32_t count, gd54xx_t *gd54xx, svga_t *svga) { - uint8_t src = 0, dst; + uint8_t src = 0; + uint8_t dst; uint16_t width = gd54xx->blt.width; - int x_max = 0, shift = 0, mask = 0; + int x_max = 0; + int shift = 0; + int mask = 0; uint32_t src_addr = gd54xx->blt.src_addr; uint32_t dst_addr = gd54xx->blt.dst_addr; @@ -3740,8 +3760,8 @@ gd54xx_reset(void *priv) memset(svga->gdcreg, 0x00, sizeof(svga->gdcreg)); svga->crtc[0] = 63; svga->crtc[6] = 255; - svga->dispontime = 1000ull << 32; - svga->dispofftime = 1000ull << 32; + svga->dispontime = 1000ULL << 32; + svga->dispofftime = 1000ULL << 32; svga->bpp = 8; io_removehandler(0x03c0, 0x0020, gd54xx_in, NULL, NULL, gd54xx_out, NULL, NULL, gd54xx); @@ -3810,7 +3830,8 @@ static void int id = info->local & 0xff; int vram; char *romfn = NULL; - char *romfn1 = NULL, *romfn2 = NULL; + char *romfn1 = NULL; + char *romfn2 = NULL; memset(gd54xx, 0, sizeof(gd54xx_t)); gd54xx->pci = !!(info->flags & DEVICE_PCI); diff --git a/src/video/vid_colorplus.c b/src/video/vid_colorplus.c index ae24d8ff0..81c1746f3 100644 --- a/src/video/vid_colorplus.c +++ b/src/video/vid_colorplus.c @@ -122,9 +122,11 @@ void colorplus_poll(void *p) { colorplus_t *colorplus = (colorplus_t *) p; - int x, c; + int x; + int c; int oldvc; - uint16_t dat0, dat1; + uint16_t dat0; + uint16_t dat1; int cols[4]; int col; int oldsc; @@ -315,11 +317,11 @@ colorplus_poll(void *p) } if (colorplus->cga.cgadispon) colorplus->cga.cgastat &= ~1; - if ((colorplus->cga.sc == (colorplus->cga.crtc[10] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[10] & 31) >> 1)))) + if (colorplus->cga.sc == (colorplus->cga.crtc[10] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[10] & 31) >> 1))) colorplus->cga.con = 1; if (colorplus->cga.cgadispon && (colorplus->cga.cgamode & 1)) { for (x = 0; x < (colorplus->cga.crtc[1] << 1); x++) - colorplus->cga.charbuffer[x] = colorplus->cga.vram[(((colorplus->cga.ma << 1) + x) & 0x3fff)]; + colorplus->cga.charbuffer[x] = colorplus->cga.vram[((colorplus->cga.ma << 1) + x) & 0x3fff]; } } } diff --git a/src/video/vid_compaq_cga.c b/src/video/vid_compaq_cga.c index 68255e746..c913e6e7c 100644 --- a/src/video/vid_compaq_cga.c +++ b/src/video/vid_compaq_cga.c @@ -69,7 +69,9 @@ compaq_cga_log(const char *fmt, ...) void compaq_cga_recalctimings(compaq_cga_t *self) { - double _dispontime, _dispofftime, disptime; + double _dispontime; + double _dispofftime; + double disptime; disptime = self->cga.crtc[0] + 1; _dispontime = self->cga.crtc[1]; @@ -86,9 +88,13 @@ compaq_cga_poll(void *p) compaq_cga_t *self = (compaq_cga_t *) p; uint16_t ca = (self->cga.crtc[15] | (self->cga.crtc[14] << 8)) & 0x3fff; int drawcursor; - int x, c, xs_temp, ys_temp; + int x; + int c; + int xs_temp; + int ys_temp; int oldvc; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; uint8_t border; uint8_t cols[4]; int oldsc; @@ -176,8 +182,8 @@ compaq_cga_poll(void *p) } } else { for (x = 0; x < self->cga.crtc[1]; x++) { - chr = self->cga.vram[((self->cga.ma << 1) & 0x3fff)]; - attr = self->cga.vram[(((self->cga.ma << 1) + 1) & 0x3fff)]; + chr = self->cga.vram[(self->cga.ma << 1) & 0x3fff]; + attr = self->cga.vram[((self->cga.ma << 1) + 1) & 0x3fff]; drawcursor = ((self->cga.ma == ca) && self->cga.con && self->cga.cursoron); if (vflags) { @@ -380,12 +386,12 @@ compaq_cga_poll(void *p) if (self->cga.cgadispon) self->cga.cgastat &= ~1; - if ((self->cga.sc == (self->cga.crtc[10] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[10] & 31) >> 1)))) + if (self->cga.sc == (self->cga.crtc[10] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[10] & 31) >> 1))) self->cga.con = 1; if (self->cga.cgadispon && (self->cga.cgamode & 1)) { for (x = 0; x < (self->cga.crtc[1] << 1); x++) - self->cga.charbuffer[x] = self->cga.vram[(((self->cga.ma << 1) + x) & 0x3fff)]; + self->cga.charbuffer[x] = self->cga.vram[((self->cga.ma << 1) + x) & 0x3fff]; } } } @@ -394,7 +400,6 @@ void * compaq_cga_init(const device_t *info) { int display_type; - int c; compaq_cga_t *self = malloc(sizeof(compaq_cga_t)); memset(self, 0, sizeof(compaq_cga_t)); @@ -411,7 +416,7 @@ compaq_cga_init(const device_t *info) io_sethandler(0x03d0, 0x0010, cga_in, NULL, NULL, cga_out, NULL, NULL, self); if (info->local) { - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { mdaattr[c][0][0] = mdaattr[c][1][0] = mdaattr[c][1][1] = 16; if (c & 8) mdaattr[c][0][1] = 15 + 16; diff --git a/src/video/vid_ddc.c b/src/video/vid_ddc.c index e6fc4f175..387edaeb8 100644 --- a/src/video/vid_ddc.c +++ b/src/video/vid_ddc.c @@ -133,7 +133,8 @@ ddc_init(void *i2c) memset(edid, 0, sizeof(edid_t)); uint8_t *edid_bytes = (uint8_t *) edid; - double horiz_mm = PIXEL_MM(800), vert_mm = PIXEL_MM(600); + double horiz_mm = PIXEL_MM(800); + double vert_mm = PIXEL_MM(600); memset(&edid->magic[1], 0xff, sizeof(edid->magic) - 2); diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 3da38da35..d0434fd0e 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -54,14 +54,17 @@ enum { static video_timings_t timing_ega = { .type = VIDEO_ISA, .write_b = 8, .write_w = 16, .write_l = 32, .read_b = 8, .read_w = 16, .read_l = 32 }; static uint8_t ega_rotate[8][256]; -static uint32_t pallook16[256], pallook64[256]; -static int ega_type = 0, old_overscan_color = 0; +static uint32_t pallook16[256]; +static uint32_t pallook64[256]; +static int ega_type = 0; +static int old_overscan_color = 0; uint8_t egaremap2bpp[256]; /* 3C2 controls default mode on EGA. On VGA, it determines monitor type (mono or colour): 7=CGA mode (200 lines), 9=EGA mode (350 lines), 8=EGA mode (200 lines). */ -int egaswitchread, egaswitches = 9; +int egaswitchread; +int egaswitches = 9; int update_overscan = 0; uint8_t ega_in(uint16_t addr, void *p); @@ -70,8 +73,8 @@ void ega_out(uint16_t addr, uint8_t val, void *p) { ega_t *ega = (ega_t *) p; - int c; - uint8_t o, old; + uint8_t o; + uint8_t old; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(ega->miscout & 1)) addr ^= 0x60; @@ -117,7 +120,7 @@ ega_out(uint16_t addr, uint8_t val, void *p) if (ega->attraddr < 16) ega->fullchange = changeframecount; if (ega->attraddr == 0x10 || ega->attraddr == 0x14 || ega->attraddr < 0x10) { - for (c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { if (ega->attrregs[0x10] & 0x80) ega->egapal[c] = (ega->attrregs[c] & 0xf) | ((ega->attrregs[0x14] & 0xf) << 4); else @@ -347,7 +350,9 @@ ega_recalctimings(ega_t *ega) { int clksel; - double _dispontime, _dispofftime, disptime; + double _dispontime; + double _dispofftime; + double disptime; double crtcconst; ega->vtotal = ega->crtc[6]; @@ -392,20 +397,20 @@ ega_recalctimings(ega_t *ega) switch (clksel) { case 0: - crtcconst = (cpuclock / 25175000.0 * (double) (1ull << 32)); + crtcconst = (cpuclock / 25175000.0 * (double) (1ULL << 32)); break; case 1: - crtcconst = (cpuclock / 28322000.0 * (double) (1ull << 32)); + crtcconst = (cpuclock / 28322000.0 * (double) (1ULL << 32)); break; case 4: - crtcconst = (cpuclock / 14318181.0 * (double) (1ull << 32)); + crtcconst = (cpuclock / 14318181.0 * (double) (1ULL << 32)); break; case 5: - crtcconst = (cpuclock / 16257000.0 * (double) (1ull << 32)); + crtcconst = (cpuclock / 16257000.0 * (double) (1ULL << 32)); break; case 7: default: - crtcconst = (cpuclock / 36000000.0 * (double) (1ull << 32)); + crtcconst = (cpuclock / 36000000.0 * (double) (1ULL << 32)); break; } if (!(ega->seqregs[1] & 1)) @@ -479,8 +484,10 @@ void ega_poll(void *p) { ega_t *ega = (ega_t *) p; - int x, old_ma; - int wx = 640, wy = 350; + int x; + int old_ma; + int wx = 640; + int wy = 350; uint32_t blink_delay; if (!ega->linepos) { @@ -680,14 +687,16 @@ ega_poll(void *p) void ega_doblit(int wx, int wy, ega_t *ega) { - int y_add = (enable_overscan) ? overscan_y : 0; - int x_add = (enable_overscan) ? overscan_x : 0; - int y_start = (enable_overscan) ? 0 : (overscan_y >> 1); - int x_start = (enable_overscan) ? 0 : (overscan_x >> 1); + int y_add = enable_overscan ? overscan_y : 0; + int x_add = enable_overscan ? overscan_x : 0; + int y_start = enable_overscan ? 0 : (overscan_y >> 1); + int x_start = enable_overscan ? 0 : (overscan_x >> 1); int bottom = (overscan_y >> 1) + (ega->crtc[8] & 0x1f); uint32_t *p; - int i, j; - int xs_temp, ys_temp; + int i; + int j; + int xs_temp; + int ys_temp; if (ega->vres) { y_add <<= 1; @@ -773,7 +782,7 @@ ega_remap_cpu_addr(uint32_t inaddr, ega_t *ega) a0mux |= 1; } - switch ((ega->gdcreg[6] & 0xC)) { + switch (ega->gdcreg[6] & 0xC) { case 0x0: // 128K A000 addr &= 0xFFFF; // TODO: Confirm the behaviour of this on actual hardware @@ -824,7 +833,10 @@ void ega_write(uint32_t addr, uint8_t val, void *p) { ega_t *ega = (ega_t *) p; - uint8_t vala, valb, valc, vald; + uint8_t vala; + uint8_t valb; + uint8_t valc; + uint8_t vald; int writemask2 = ega->writemask; cycles -= video_timing_write_b; @@ -996,7 +1008,10 @@ uint8_t ega_read(uint32_t addr, void *p) { ega_t *ega = (ega_t *) p; - uint8_t temp, temp2, temp3, temp4; + uint8_t temp; + uint8_t temp2; + uint8_t temp3; + uint8_t temp4; int readplane = ega->readplane; cycles -= video_timing_read_b; @@ -1037,7 +1052,9 @@ ega_read(uint32_t addr, void *p) void ega_init(ega_t *ega, int monitor_type, int is_mono) { - int c, d, e; + int c; + int d; + int e; ega->vram = malloc(0x40000); ega->vrammask = 0x3ffff; @@ -1166,7 +1183,7 @@ static void * ega_standalone_init(const device_t *info) { ega_t *ega = malloc(sizeof(ega_t)); - int monitor_type, c; + int monitor_type; memset(ega, 0, sizeof(ega_t)); @@ -1211,7 +1228,7 @@ ega_standalone_init(const device_t *info) } if ((ega->bios_rom.rom[0x3ffe] == 0xaa) && (ega->bios_rom.rom[0x3fff] == 0x55)) { - for (c = 0; c < 0x2000; c++) { + for (uint16_t c = 0; c < 0x2000; c++) { uint8_t temp = ega->bios_rom.rom[c]; ega->bios_rom.rom[c] = ega->bios_rom.rom[0x3fff - c]; ega->bios_rom.rom[0x3fff - c] = temp; diff --git a/src/video/vid_ega_render.c b/src/video/vid_ega_render.c index 7db92b7d7..4b6710891 100644 --- a/src/video/vid_ega_render.c +++ b/src/video/vid_ega_render.c @@ -33,7 +33,7 @@ int ega_display_line(ega_t *ega) { - int y_add = (enable_overscan) ? (overscan_y >> 1) : 0; + int y_add = enable_overscan ? (overscan_y >> 1) : 0; unsigned int dl = ega->displine; if (ega->crtc[9] & 0x1f) @@ -47,12 +47,12 @@ ega_display_line(ega_t *ega) void ega_render_blank(ega_t *ega) { - int x, xx; + int xx; if ((ega->displine + ega->y_add) < 0) return; - for (x = 0; x < (ega->hdisp + ega->scrollcache); x++) { + for (int x = 0; x < (ega->hdisp + ega->scrollcache); x++) { switch (ega->seqregs[1] & 9) { case 0: for (xx = 0; xx < 9; xx++) @@ -77,22 +77,20 @@ ega_render_blank(ega_t *ega) void ega_render_overscan_left(ega_t *ega) { - int i; - if ((ega->displine + ega->y_add) < 0) return; if (ega->scrblank || (ega->hdisp == 0)) return; - for (i = 0; i < ega->x_add; i++) + for (int i = 0; i < ega->x_add; i++) buffer32->line[ega->displine + ega->y_add][i] = ega->overscan_color; } void ega_render_overscan_right(ega_t *ega) { - int i, right; + int right; if ((ega->displine + ega->y_add) < 0) return; @@ -101,7 +99,7 @@ ega_render_overscan_right(ega_t *ega) return; right = (overscan_x >> 1) + ega->scrollcache; - for (i = 0; i < right; i++) + for (int i = 0; i < right; i++) buffer32->line[ega->displine + ega->y_add][ega->x_add + ega->hdisp + i] = ega->overscan_color; } @@ -132,7 +130,8 @@ ega_render_text(ega_t *ega) int drawcursor = ((ega->ma == ega->ca) && ega->con && ega->cursoron); - uint32_t chr, attr; + uint32_t chr; + uint32_t attr; if (!crtcreset) { chr = ega->vram[addr]; attr = ega->vram[addr + 1]; @@ -141,11 +140,12 @@ ega_render_text(ega_t *ega) uint32_t charaddr; if (attr & 8) - charaddr = ega->charsetb + ((chr * 0x80)); + charaddr = ega->charsetb + (chr * 0x80); else - charaddr = ega->charseta + ((chr * 0x80)); + charaddr = ega->charseta + (chr * 0x80); - int fg, bg; + int fg; + int bg; if (drawcursor) { bg = ega->pallook[ega->egapal[attr & 0x0f]]; fg = ega->pallook[ega->egapal[attr >> 4]]; @@ -236,7 +236,7 @@ ega_render_graphics(ega_t *ega) | (edatlookup[(edat[2] >> inshift) & 3][(edat[3] >> inshift) & 3] << 2); // FIXME: Confirm blink behaviour is actually XOR on real hardware uint32_t p0 = ega->pallook[ega->egapal[((dat >> 4) & ega->plane_mask) ^ blinkmask]]; - uint32_t p1 = ega->pallook[ega->egapal[((dat ) & ega->plane_mask) ^ blinkmask]]; + uint32_t p1 = ega->pallook[ega->egapal[(dat & ega->plane_mask) ^ blinkmask]]; for (int subx = 0; subx < dotwidth; subx++) p[outoffs + subx] = p0; for (int subx = 0; subx < dotwidth; subx++) diff --git a/src/video/vid_et3000.c b/src/video/vid_et3000.c index d107afe5c..28e3a0f02 100644 --- a/src/video/vid_et3000.c +++ b/src/video/vid_et3000.c @@ -195,13 +195,13 @@ et3000_recalctimings(svga_t *svga) case 1: break; case 3: - svga->clock = (cpuclock * (double) (1ull << 32)) / 40000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 40000000.0; break; case 5: - svga->clock = (cpuclock * (double) (1ull << 32)) / 65000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 65000000.0; break; default: - svga->clock = (cpuclock * (double) (1ull << 32)) / 36000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; } } @@ -237,7 +237,7 @@ et3000_init(const device_t *info) dev->svga.packed_chain4 = 1; - return (dev); + return dev; } static void diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index 4020c0523..b4c505dae 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -561,13 +561,13 @@ et4000_recalctimings(svga_t *svga) case 1: break; case 3: - svga->clock = (cpuclock * (double) (1ull << 32)) / 40000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 40000000.0; break; case 5: - svga->clock = (cpuclock * (double) (1ull << 32)) / 65000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 65000000.0; break; default: - svga->clock = (cpuclock * (double) (1ull << 32)) / 36000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; } @@ -747,7 +747,7 @@ et4000_init(const device_t *info) dev->svga.packed_chain4 = 1; - return (dev); + return dev; } static void diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index 6e6779283..e9ea4d111 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -285,7 +285,7 @@ et4000w32p_out(uint16_t addr, uint8_t val, void *p) } } - if (((et4000->type == ET4000W32) && (svga->hwcursor.cur_xsize == 128))) { + if ((et4000->type == ET4000W32) && (svga->hwcursor.cur_xsize == 128)) { switch (svga->bpp) { case 8: svga->hwcursor.xoff += 32; @@ -437,7 +437,7 @@ et4000w32p_recalctimings(svga_t *svga) if (svga->attrregs[0x16] & 0x20) svga->hdisp <<= 1; - svga->clock = (cpuclock * (double) (1ull << 32)) / svga->getclock((svga->miscout >> 2) & 3, svga->clock_gen); + svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock((svga->miscout >> 2) & 3, svga->clock_gen); if (et4000->type != ET4000W32P_DIAMOND) { if ((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1)) { @@ -463,7 +463,7 @@ et4000w32p_recalctimings(svga_t *svga) if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /* Text mode */ svga->ma_latch--; - if ((svga->seqregs[1] & 8)) /*40 column*/ + if (svga->seqregs[1] & 8) /*40 column*/ svga->hdisp += (svga->seqregs[1] & 1) ? 16 : 18; else svga->hdisp += (svga->seqregs[1] & 1) ? 8 : 9; @@ -2080,7 +2080,9 @@ static void et4000w32_blit(int count, int cpu_input, uint32_t src_dat, uint32_t mix_dat, et4000w32p_t *et4000) { svga_t *svga = &et4000->svga; - uint8_t pattern, source, dest; + uint8_t pattern; + uint8_t source; + uint8_t dest; uint8_t rop; uint8_t out; int mixmap; @@ -2255,7 +2257,10 @@ static void et4000w32p_blit(int count, uint32_t mix, uint32_t sdat, int cpu_input, et4000w32p_t *et4000) { svga_t *svga = &et4000->svga; - uint8_t pattern, source, dest, out; + uint8_t pattern; + uint8_t source; + uint8_t dest; + uint8_t out; uint8_t rop; int mixdat; @@ -2449,7 +2454,9 @@ void et4000w32p_hwcursor_draw(svga_t *svga, int displine) { et4000w32p_t *et4000 = (et4000w32p_t *) svga->p; - int x, offset, xx, xx2; + int offset; + int xx; + int xx2; int shift = (et4000->adjust_cursor + 1); int width = (svga->hwcursor_latch.cur_xsize - svga->hwcursor_latch.xoff); int pitch = (svga->hwcursor_latch.cur_xsize == 128) ? 32 : 16; @@ -2472,7 +2479,7 @@ et4000w32p_hwcursor_draw(svga_t *svga, int displine) } } - for (x = 0; x < (width - minus_width); x += x_acc) { + for (int x = 0; x < (width - minus_width); x += x_acc) { dat = svga->vram[svga->hwcursor_latch.addr + (offset >> 2)]; xx = svga->hwcursor_latch.x + svga->x_add + x; diff --git a/src/video/vid_f82c425.c b/src/video/vid_f82c425.c index 15f4ce496..d2fd22dce 100644 --- a/src/video/vid_f82c425.c +++ b/src/video/vid_f82c425.c @@ -179,9 +179,7 @@ f82c425_smartmap_add(int a, int b, int sat) static void f82c425_smartmap(f82c425_t *f82c425) { - int i; - - for (i = 0; i < 256; i++) { + for (uint16_t i = 0; i < 256; i++) { uint8_t bg = f82c425_rgbi(i >> 4); uint8_t fg = f82c425_rgbi(i & 0xf); @@ -223,9 +221,7 @@ f82c425_smartmap(f82c425_t *f82c425) static void f82c425_colormap(f82c425_t *f82c425) { - int i; - - for (i = 0; i < 4; i++) + for (uint8_t i = 0; i < 4; i++) colormap[i] = f82c425_makecol(5 * i, 0, f82c425->function & 0x80); } @@ -330,7 +326,8 @@ static void f82c425_recalctimings(f82c425_t *f82c425) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; if (f82c425->function & 0x08) { cga_recalctimings(&f82c425->cga); @@ -349,8 +346,9 @@ static void f82c425_text_row(f82c425_t *f82c425) { uint32_t colors[2]; - int x, c; - uint8_t chr, attr; + int c; + uint8_t chr; + uint8_t attr; int drawcursor; int cursorline; int blink; @@ -371,7 +369,7 @@ f82c425_text_row(f82c425_t *f82c425) cursorline = ((f82c425->cga.crtc[0x0a] & 0x0F) <= sc) && ((f82c425->cga.crtc[0x0b] & 0x0F) >= sc); } - for (x = 0; x < columns; x++) { + for (int x = 0; x < columns; x++) { chr = f82c425->vram[(addr + 2 * x) & 0x3FFF]; attr = f82c425->vram[(addr + 2 * x + 1) & 0x3FFF]; drawcursor = ((ma == ca) && cursorline && (f82c425->cga.cgamode & 0x8) && (f82c425->cga.cgablink & 0x10)); @@ -409,7 +407,6 @@ f82c425_text_row(f82c425_t *f82c425) static void f82c425_cgaline6(f82c425_t *f82c425) { - int x, c; uint8_t dat; uint16_t addr; @@ -417,11 +414,11 @@ f82c425_cgaline6(f82c425_t *f82c425) addr = ((f82c425->displine) & 1) * 0x2000 + (f82c425->displine >> 1) * 80 + ((ma & ~1) << 1); - for (x = 0; x < 80; x++) { + for (uint8_t x = 0; x < 80; x++) { dat = f82c425->vram[addr & 0x3FFF]; addr++; - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { ((uint32_t *) buffer32->line[f82c425->displine])[x * 8 + c] = colormap[dat & 0x80 ? 3 : 0]; dat = dat << 1; @@ -433,18 +430,18 @@ f82c425_cgaline6(f82c425_t *f82c425) static void f82c425_cgaline4(f82c425_t *f82c425) { - int x, c; - uint8_t dat, pattern; + uint8_t dat; + uint8_t pattern; uint16_t addr; uint16_t ma = (f82c425->cga.crtc[0x0d] | (f82c425->cga.crtc[0x0c] << 8)) & 0x3fff; addr = ((f82c425->displine) & 1) * 0x2000 + (f82c425->displine >> 1) * 80 + ((ma & ~1) << 1); - for (x = 0; x < 80; x++) { + for (uint8_t x = 0; x < 80; x++) { dat = f82c425->vram[addr & 0x3FFF]; addr++; - for (c = 0; c < 4; c++) { + for (uint8_t c = 0; c < 4; c++) { pattern = (dat & 0xC0) >> 6; if (!(f82c425->cga.cgamode & 0x08)) pattern = 0; diff --git a/src/video/vid_genius.c b/src/video/vid_genius.c index cbf4eabfe..09f2f6ada 100644 --- a/src/video/vid_genius.c +++ b/src/video/vid_genius.c @@ -322,7 +322,8 @@ void genius_recalctimings(genius_t *genius) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; disptime = 0x31; _dispontime = 0x28; @@ -374,15 +375,24 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80) { int w = 80; /* 80 characters across */ int cw = 9; /* Each character is 9 pixels wide */ - uint8_t chr, attr, sc, ctrl; - uint8_t *crtc, bitmap[2]; - int x, blink, c, row, charh; - int drawcursor, cursorline; + uint8_t chr; + uint8_t attr; + uint8_t sc; + uint8_t ctrl; + uint8_t *crtc; + uint8_t bitmap[2]; + int blink; + int c; + int row; + int charh; + int drawcursor; + int cursorline; uint16_t addr; uint16_t ma = (genius->mda_crtc[13] | (genius->mda_crtc[12] << 8)) & 0x3fff; uint16_t ca = (genius->mda_crtc[15] | (genius->mda_crtc[14] << 8)) & 0x3fff; unsigned char *framebuf = genius->vram + 0x10000; - uint32_t col, dl = genius->displine; + uint32_t col; + uint32_t dl = genius->displine; /* Character height is 12-15 */ if (mda) { @@ -437,7 +447,7 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80) else cursorline = ((crtc[10] & 0x1F) <= sc) && ((crtc[11] & 0x1F) >= sc); - for (x = 0; x < w; x++) { + for (int x = 0; x < w; x++) { #if 0 if ((genius->genius_charh & 0x10) && ((addr + 2 * x) > 0x0FFF)) chr = 0x00; @@ -549,9 +559,10 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80) void genius_cgaline(genius_t *genius) { - int x, c; - uint32_t dat, addr; - uint8_t ink_f, ink_b; + uint32_t dat; + uint32_t addr; + uint8_t ink_f; + uint8_t ink_b; ink_f = (genius->genius_control & 0x20) ? genius_pal[0] : genius_pal[3]; ink_b = (genius->genius_control & 0x20) ? genius_pal[3] : genius_pal[0]; @@ -564,11 +575,11 @@ genius_cgaline(genius_t *genius) if ((genius->displine - 512) & 2) addr += 0x2000; - for (x = 0; x < 80; x++) { + for (uint8_t x = 0; x < 80; x++) { dat = genius->vram[addr]; addr++; - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { if (dat & 0x80) buffer32->line[genius->displine][(x << 3) + c] = ink_f; else @@ -583,9 +594,10 @@ genius_cgaline(genius_t *genius) void genius_hiresline(genius_t *genius) { - int x, c; - uint32_t dat, addr; - uint8_t ink_f, ink_b; + uint32_t dat; + uint32_t addr; + uint8_t ink_f; + uint8_t ink_b; ink_f = (genius->genius_control & 0x20) ? genius_pal[0] : genius_pal[3]; ink_b = (genius->genius_control & 0x20) ? genius_pal[3] : genius_pal[0]; @@ -596,10 +608,10 @@ genius_hiresline(genius_t *genius) else /* The second 496 live at B8000 */ addr = 0x18000 + (128 * (genius->displine - 512)); - for (x = 0; x < 91; x++) { + for (uint8_t x = 0; x < 91; x++) { dat = genius->vram[addr + x]; - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { if (dat & 0x80) buffer32->line[genius->displine][(x << 3) + c] = ink_f; else @@ -614,7 +626,6 @@ void genius_poll(void *p) { genius_t *genius = (genius_t *) p; - int x; uint8_t background; if (!genius->linepos) { @@ -633,7 +644,7 @@ genius_poll(void *p) video_wait_for_buffer(); /* Start off with a blank line */ - for (x = 0; x < GENIUS_XSIZE; x++) + for (uint16_t x = 0; x < GENIUS_XSIZE; x++) buffer32->line[genius->displine][x] = background; /* If graphics display enabled, draw graphics on top @@ -714,7 +725,6 @@ void * genius_init(const device_t *info) { - int c; genius_t *genius = malloc(sizeof(genius_t)); memset(genius, 0, sizeof(genius_t)); @@ -744,7 +754,7 @@ void /* MDA attributes */ /* I don't know if the Genius's MDA emulation actually does * emulate bright / non-bright. For the time being pretend it does. */ - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { mdaattr[c][0][0] = mdaattr[c][1][0] = mdaattr[c][1][1] = genius_pal[0]; if (c & 8) mdaattr[c][0][1] = genius_pal[3]; diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 5920ff27d..f3ce178cd 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -39,7 +39,8 @@ static void recalc_timings(hercules_t *dev) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; disptime = dev->crtc[0] + 1; _dispontime = dev->crtc[1]; @@ -187,7 +188,7 @@ hercules_in(uint16_t addr, void *priv) break; } - return (ret); + return ret; } static void @@ -236,7 +237,6 @@ hercules_read(uint32_t addr, void *priv) static void hercules_render_overscan_left(hercules_t *dev) { - int i; uint32_t width; if (dev->ctrl & 0x02) @@ -250,14 +250,13 @@ hercules_render_overscan_left(hercules_t *dev) if (width == 0) return; - for (i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) buffer32->line[dev->displine + 14][i] = 0x00000000; } static void hercules_render_overscan_right(hercules_t *dev) { - int i; uint32_t width; if (dev->ctrl & 0x02) @@ -271,7 +270,7 @@ hercules_render_overscan_right(hercules_t *dev) if (width == 0) return; - for (i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) buffer32->line[dev->displine + 14][8 + width + i] = 0x00000000; } @@ -279,11 +278,19 @@ static void hercules_poll(void *priv) { hercules_t *dev = (hercules_t *) priv; - uint8_t chr, attr; - uint16_t ca, dat; + uint8_t chr; + uint8_t attr; + uint16_t ca; + uint16_t dat; uint16_t pa; - int oldsc, blink; - int x, xx, y, yy, c, oldvc; + int oldsc; + int blink; + int x; + int xx; + int y; + int yy; + int c; + int oldvc; int drawcursor; uint32_t *p; @@ -507,7 +514,7 @@ hercules_poll(void *priv) dev->ma = dev->maback; } - if ((dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1)))) + if (dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1))) dev->con = 1; if (dev->dispon && !(dev->ctrl & 0x02)) { for (x = 0; x < (dev->crtc[1] << 1); x++) { @@ -523,7 +530,6 @@ static void * hercules_init(const device_t *info) { hercules_t *dev; - int c; dev = (hercules_t *) malloc(sizeof(hercules_t)); memset(dev, 0x00, sizeof(hercules_t)); @@ -543,7 +549,7 @@ hercules_init(const device_t *info) io_sethandler(0x03b0, 16, hercules_in, NULL, NULL, hercules_out, NULL, NULL, dev); - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { dev->cols[c][0][0] = dev->cols[c][1][0] = dev->cols[c][1][1] = 16; if (c & 0x08) @@ -578,7 +584,7 @@ hercules_init(const device_t *info) /* Force the LPT3 port to be enabled. */ lpt3_init(0x3BC); - return (dev); + return dev; } static void diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index 6561f9429..95d38f1c3 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -103,7 +103,8 @@ static void recalc_timings(herculesplus_t *dev) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; disptime = dev->crtc[0] + 1; _dispontime = dev->crtc[1]; @@ -214,9 +215,13 @@ herculesplus_read(uint32_t addr, void *priv) static void draw_char_rom(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) { - unsigned ull, val, ifg, ibg; + unsigned ull; + unsigned val; + unsigned ifg; + unsigned ibg; const uint8_t *fnt; - int i, elg, blk; + int elg; + int blk; int cw = HERCULESPLUS_CW; blk = 0; @@ -259,7 +264,7 @@ draw_char_rom(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) val |= (val >> 1) & 1; } - for (i = 0; i < cw; i++) { + for (int i = 0; i < cw; i++) { buffer32->line[dev->displine][x * cw + i] = (val & 0x100) ? ifg : ibg; val = val << 1; } @@ -268,9 +273,13 @@ draw_char_rom(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) static void draw_char_ram4(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) { - unsigned ull, val, ibg, cfg; + unsigned ull; + unsigned val; + unsigned ibg; + unsigned cfg; const uint8_t *fnt; - int i, elg, blk; + int elg; + int blk; int cw = HERCULESPLUS_CW; int blink = dev->ctrl & HERCULESPLUS_CTRL_BLINK; @@ -310,7 +319,7 @@ draw_char_ram4(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) val |= (val >> 1) & 1; } - for (i = 0; i < cw; i++) { + for (int i = 0; i < cw; i++) { /* Generate pixel colour */ cfg = 0; @@ -326,9 +335,18 @@ draw_char_ram4(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) static void draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) { - int i, elg, blk, ul, ol, bld; - unsigned ull, oll, ulc = 0, olc = 0; - unsigned val, ibg, cfg; + int elg; + int blk; + int ul; + int ol; + int bld; + unsigned ull; + unsigned oll; + unsigned ulc = 0; + unsigned olc = 0; + unsigned val; + unsigned ibg; + unsigned cfg; const unsigned char *fnt; int cw = HERCULESPLUS_CW; int blink = dev->ctrl & HERCULESPLUS_CTRL_BLINK; @@ -395,7 +413,7 @@ draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) val |= (val >> 1); } - for (i = 0; i < cw; i++) { + for (int i = 0; i < cw; i++) { /* Generate pixel colour */ cfg = val & 0x100; if (dev->sc == oll) @@ -414,11 +432,11 @@ static void text_line(herculesplus_t *dev, uint16_t ca) { int drawcursor; - int x, c; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; uint32_t col; - for (x = 0; x < dev->crtc[1]; x++) { + for (uint8_t x = 0; x < dev->crtc[1]; x++) { if (dev->ctrl & 8) { chr = dev->vram[(dev->ma << 1) & 0xfff]; attr = dev->vram[((dev->ma << 1) + 1) & 0xfff]; @@ -447,7 +465,7 @@ text_line(herculesplus_t *dev, uint16_t ca) int cw = HERCULESPLUS_CW; col = dev->cols[attr][0][1]; - for (c = 0; c < cw; c++) + for (int c = 0; c < cw; c++) buffer32->line[dev->displine][x * cw + c] = col; } } @@ -457,7 +475,8 @@ static void graphics_line(herculesplus_t *dev) { uint16_t ca; - int x, c, plane = 0; + int c; + int plane = 0; uint16_t val; /* Graphics mode. */ @@ -465,7 +484,7 @@ graphics_line(herculesplus_t *dev) if ((dev->ctrl & HERCULESPLUS_CTRL_PAGE1) && (dev->ctrl2 & HERCULESPLUS_CTRL2_PAGE1)) ca += 0x8000; - for (x = 0; x < dev->crtc[1]; x++) { + for (uint8_t x = 0; x < dev->crtc[1]; x++) { if (dev->ctrl & 8) val = (dev->vram[((dev->ma << 1) & 0x1fff) + ca + 0x10000 * plane] << 8) | dev->vram[((dev->ma << 1) & 0x1fff) + ca + 0x10000 * plane + 1]; @@ -489,7 +508,9 @@ herculesplus_poll(void *priv) { herculesplus_t *dev = (herculesplus_t *) priv; uint16_t ca = (dev->crtc[15] | (dev->crtc[14] << 8)) & 0x3fff; - int x, oldvc, oldsc; + int x; + int oldvc; + int oldsc; VIDEO_MONITOR_PROLOGUE(); if (!dev->linepos) { @@ -612,7 +633,7 @@ herculesplus_poll(void *priv) dev->ma = dev->maback; } - if ((dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1)))) + if (dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1))) dev->con = 1; } @@ -623,7 +644,6 @@ static void * herculesplus_init(const device_t *info) { herculesplus_t *dev; - int c; dev = (herculesplus_t *) malloc(sizeof(herculesplus_t)); memset(dev, 0, sizeof(herculesplus_t)); @@ -641,7 +661,7 @@ herculesplus_init(const device_t *info) io_sethandler(0x03b0, 16, herculesplus_in, NULL, NULL, herculesplus_out, NULL, NULL, dev); - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { dev->cols[c][0][0] = dev->cols[c][1][0] = dev->cols[c][1][1] = 16; if (c & 8) dev->cols[c][0][1] = 15 + 16; diff --git a/src/video/vid_ht216.c b/src/video/vid_ht216.c index 91c542164..6b99975d5 100644 --- a/src/video/vid_ht216.c +++ b/src/video/vid_ht216.c @@ -614,16 +614,16 @@ ht216_recalctimings(svga_t *svga) case 1: break; case 4: - svga->clock = (cpuclock * (double) (1ull << 32)) / 50350000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 50350000.0; break; case 5: - svga->clock = (cpuclock * (double) (1ull << 32)) / 65000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 65000000.0; break; case 7: - svga->clock = (cpuclock * (double) (1ull << 32)) / 40000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 40000000.0; break; default: - svga->clock = (cpuclock * (double) (1ull << 32)) / 36000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; } @@ -703,7 +703,7 @@ static void ht216_hwcursor_draw(svga_t *svga, int displine) { ht216_t *ht216 = (ht216_t *) svga->p; - int x, shift = (ht216->adjust_cursor ? 2 : 1); + int shift = (ht216->adjust_cursor ? 2 : 1); uint32_t dat[2]; int offset = svga->hwcursor_latch.x + svga->hwcursor_latch.xoff; int width = (ht216->adjust_cursor ? 16 : 32); @@ -717,7 +717,7 @@ ht216_hwcursor_draw(svga_t *svga, int displine) dat[0] = (svga->vram[svga->hwcursor_latch.addr] << 24) | (svga->vram[svga->hwcursor_latch.addr + 1] << 16) | (svga->vram[svga->hwcursor_latch.addr + 2] << 8) | svga->vram[svga->hwcursor_latch.addr + 3]; dat[1] = (svga->vram[svga->hwcursor_latch.addr + 128] << 24) | (svga->vram[svga->hwcursor_latch.addr + 128 + 1] << 16) | (svga->vram[svga->hwcursor_latch.addr + 128 + 2] << 8) | svga->vram[svga->hwcursor_latch.addr + 128 + 3]; - for (x = 0; x < width; x++) { + for (int x = 0; x < width; x++) { if (!(dat[0] & 0x80000000)) ((uint32_t *) buffer32->line[displine])[svga->x_add + offset + x] = 0; if (dat[1] & 0x80000000) @@ -796,10 +796,13 @@ static void ht216_dm_write(ht216_t *ht216, uint32_t addr, uint8_t cpu_dat, uint8_t cpu_dat_unexpanded) { svga_t *svga = &ht216->svga; - int writemask2 = svga->writemask, reset_wm = 0; + int writemask2 = svga->writemask; + int reset_wm = 0; latch_t vall; - uint8_t i, wm = svga->writemask; - uint8_t count = 4, fg_data[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8_t i; + uint8_t wm = svga->writemask; + uint8_t count = 4; + uint8_t fg_data[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; if (ht216->ht_regs[0xcd] & HT_REG_CD_P8PCEXP) writemask2 = svga->seqregs[2]; @@ -984,8 +987,10 @@ ht216_dm_extalu_write(ht216_t *ht216, uint32_t addr, uint8_t cpu_dat, uint8_t bi 01 = Bit mask (3CF:8) 1x = (3C4:F5)*/ svga_t *svga = &ht216->svga; - uint8_t input_a = 0, input_b = 0; - uint8_t fg, bg; + uint8_t input_a = 0; + uint8_t input_b = 0; + uint8_t fg; + uint8_t bg; uint8_t output; uint32_t remapped_addr = dword_remap(svga, addr); @@ -1024,7 +1029,8 @@ ht216_dm_masked_write(ht216_t *ht216, uint32_t addr, uint8_t val, uint8_t bit_ma { svga_t *svga = &ht216->svga; int writemask2 = svga->writemask; - uint8_t count = 4, i; + uint8_t count = 4; + uint8_t i; uint8_t full_mask = 0x0f; if (ht216->ht_regs[0xcd] & HT_REG_CD_P8PCEXP) @@ -1098,7 +1104,8 @@ ht216_write_common(ht216_t *ht216, uint32_t addr, uint8_t val) */ svga_t *svga = &ht216->svga; int i; - uint8_t bit_mask = 0, rop_select = 0; + uint8_t bit_mask = 0; + uint8_t rop_select = 0; cycles -= video_timing_write_b; @@ -1287,11 +1294,12 @@ ht216_read_common(ht216_t *ht216, uint32_t addr) { svga_t *svga = &ht216->svga; uint32_t latch_addr = 0; - int offset, readplane = svga->readplane; - uint8_t or, i; - uint8_t count = 2; - uint8_t plane, pixel; - uint8_t temp, ret; + int offset; + int readplane = svga->readplane; + uint8_t or; + uint8_t count = 2; + uint8_t temp; + uint8_t ret; if (ht216->ht_regs[0xc8] & HT_REG_C8_MOVSB) addr <<= 3; @@ -1309,7 +1317,7 @@ ht216_read_common(ht216_t *ht216, uint32_t addr) latch_addr = (addr & svga->vram_mask) & ~7; if (ht216->ht_regs[0xcd] & HT_REG_CD_ASTODE) latch_addr += (svga->gdcreg[3] & 7); - for (i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) ht216->bg_latch[i] = svga->vram[dword_remap(svga, latch_addr + i)]; return svga->vram[dword_remap(svga, addr) & svga->vram_mask]; } else if (svga->chain4) { @@ -1332,22 +1340,22 @@ ht216_read_common(ht216_t *ht216, uint32_t addr) latch_addr = addr & ~7; if (ht216->ht_regs[0xcd] & HT_REG_CD_ASTODE) { offset = addr & 7; - for (i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) ht216->bg_latch[i] = svga->vram[latch_addr | ((offset + i) & 7)]; } else { - for (i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) ht216->bg_latch[i] = svga->vram[latch_addr | i]; } or = addr & 4; - for (i = 0; i < 4; i++) + for (uint8_t i = 0; i < 4; i++) svga->latch.b[i] = ht216->bg_latch[i | or ]; if (svga->readmode) { temp = 0xff; - for (pixel = 0; pixel < 8; pixel++) { - for (plane = 0; plane < (uint8_t)(1 << count); plane++) { + for (uint8_t pixel = 0; pixel < 8; pixel++) { + for (uint8_t plane = 0; plane < (uint8_t)(1 << count); plane++) { if (svga->colournocare & (1 << plane)) { /* If we care about a plane, and the pixel has a mismatch on it, clear its bit. */ if (((svga->latch.b[plane] >> pixel) & 1) != ((svga->colourcompare >> plane) & 1)) diff --git a/src/video/vid_ibm_rgb528_ramdac.c b/src/video/vid_ibm_rgb528_ramdac.c index adfc6ea39..339cf6700 100644 --- a/src/video/vid_ibm_rgb528_ramdac.c +++ b/src/video/vid_ibm_rgb528_ramdac.c @@ -74,7 +74,6 @@ typedef struct void ibm_rgb528_render_4bpp(svga_t *svga) { - int x; uint32_t *p; ibm_rgb528_pixel32_t dat_out; uint8_t dat; @@ -98,7 +97,7 @@ ibm_rgb528_render_4bpp(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (vram_size == 3) { if (!(x & 31)) { dat64 = *(uint64_t *) (&svga->vram[svga->ma]); @@ -155,7 +154,6 @@ ibm_rgb528_render_4bpp(svga_t *svga) void ibm_rgb528_render_8bpp(svga_t *svga) { - int x; uint32_t *p; ibm_rgb528_pixel32_t dat_out; uint8_t dat; @@ -177,7 +175,7 @@ ibm_rgb528_render_8bpp(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (vram_size == 3) { if (!(x & 15)) { dat64 = *(uint64_t *) (&svga->vram[svga->ma]); @@ -225,7 +223,6 @@ ibm_rgb528_render_8bpp(svga_t *svga) void ibm_rgb528_render_15_16bpp(svga_t *svga) { - int x; uint32_t *p; ibm_rgb528_pixel16_t *dat_ex; ibm_rgb528_pixel32_t dat_out; @@ -242,7 +239,8 @@ ibm_rgb528_render_15_16bpp(svga_t *svga) uint8_t b6bit_lin = ramdac->indexed_data[0x07] & 0x80; uint8_t swaprb = ramdac->indexed_data[0x72] & 0x80; uint8_t swap_word = ramdac->indexed_data[0x72] & 0x10; - uint8_t vram_size = ramdac->indexed_data[0x70] & 0x01, temp; + uint8_t vram_size = ramdac->indexed_data[0x70] & 0x01; + uint8_t temp; if ((svga->displine + svga->y_add) < 0) return; @@ -257,7 +255,7 @@ ibm_rgb528_render_15_16bpp(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (vram_size == 2) { if (!(x & 7)) { dat64 = *(uint64_t *) (&svga->vram[svga->ma]); @@ -350,7 +348,6 @@ ibm_rgb528_render_15_16bpp(svga_t *svga) void ibm_rgb528_render_24bpp(svga_t *svga) { - int x; uint32_t *p; ibm_rgb528_pixel32_t *dat_ex; uint32_t dat; @@ -361,7 +358,8 @@ ibm_rgb528_render_24bpp(svga_t *svga) uint8_t swaprb = ramdac->indexed_data[0x72] & 0x80; uint8_t swap_word = ramdac->indexed_data[0x72] & 0x10; uint8_t vram_size = ramdac->indexed_data[0x70] & 0x01; - uint8_t b6bit_lin = ramdac->indexed_data[0x07] & 0x80, temp; + uint8_t b6bit_lin = ramdac->indexed_data[0x07] & 0x80; + uint8_t temp; if ((svga->displine + svga->y_add) < 0) return; @@ -373,7 +371,7 @@ ibm_rgb528_render_24bpp(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { dat_ex = (ibm_rgb528_pixel32_t *) &dat; if (vram_size == 3) { if ((x & 15) == 0) { @@ -392,7 +390,7 @@ ibm_rgb528_render_24bpp(svga_t *svga) dat64[5] = (dat64[5] << 32ULL) | (dat64[5] >> 32ULL); } } - dat_ex = (ibm_rgb528_pixel32_t *) &(dat8[((x & 15) * 3)]); + dat_ex = (ibm_rgb528_pixel32_t *) &(dat8[(x & 15) * 3]); } else if (vram_size == 1) { if ((x & 7) == 0) { dat64[0] = *(uint64_t *) (&svga->vram[svga->ma & svga->vram_display_mask]); @@ -404,7 +402,7 @@ ibm_rgb528_render_24bpp(svga_t *svga) dat64[2] = (dat64[2] << 32ULL) | (dat64[2] >> 32ULL); } } - dat_ex = (ibm_rgb528_pixel32_t *) &(dat8[((x & 7) * 3)]); + dat_ex = (ibm_rgb528_pixel32_t *) &(dat8[(x & 7) * 3]); } else dat = 0x00000000; if (swaprb) { @@ -439,7 +437,6 @@ ibm_rgb528_render_24bpp(svga_t *svga) void ibm_rgb528_render_32bpp(svga_t *svga) { - int x; uint32_t *p; ibm_rgb528_pixel32_t *dat_ex; uint32_t dat = 0x00000000; @@ -451,7 +448,8 @@ ibm_rgb528_render_32bpp(svga_t *svga) uint8_t swaprb = ramdac->indexed_data[0x72] & 0x80; uint8_t swap_word = ramdac->indexed_data[0x72] & 0x10; uint8_t vram_size = ramdac->indexed_data[0x70] & 0x01; - uint8_t b6bit_lin = ramdac->indexed_data[0x07] & 0x80, temp; + uint8_t b6bit_lin = ramdac->indexed_data[0x07] & 0x80; + uint8_t temp; if ((svga->displine + svga->y_add) < 0) return; @@ -463,7 +461,7 @@ ibm_rgb528_render_32bpp(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x++) { if (vram_size == 3) { if (!(x & 3)) { dat64 = *(uint64_t *) (&svga->vram[svga->ma]); @@ -489,7 +487,7 @@ ibm_rgb528_render_32bpp(svga_t *svga) dat_ex->r = dat_ex->b; dat_ex->b = temp; } - if ((b32_dcol < 0x03) && (by32_pol)) + if ((b32_dcol < 0x03) && by32_pol) dat ^= 0x01000000; if ((b32_dcol == 0x00) || ((b32_dcol == 0x01) && !(dat & 0x01000000))) { dat_ex->a = 0x00; @@ -825,8 +823,12 @@ ibm_rgb528_recalctimings(void *p, svga_t *svga) void ibm_rgb528_hwcursor_draw(svga_t *svga, int displine) { - uint8_t dat, four_pixels = 0x00; - int x, pitch, x_pos, y_pos, offset = svga->dac_hwcursor_latch.x - svga->dac_hwcursor_latch.xoff; + uint8_t dat; + uint8_t four_pixels = 0x00; + int pitch; + int x_pos; + int y_pos; + int offset = svga->dac_hwcursor_latch.x - svga->dac_hwcursor_latch.xoff; uint32_t *p; ibm_rgb528_ramdac_t *ramdac = (ibm_rgb528_ramdac_t *) svga->ramdac; uint8_t pix_ordr = ramdac->indexed_data[0x30] & 0x20; @@ -844,7 +846,7 @@ ibm_rgb528_hwcursor_draw(svga_t *svga, int displine) x_pos = offset + svga->x_add; p = buffer32->line[y_pos]; - for (x = 0; x < svga->dac_hwcursor_latch.cur_xsize; x++) { + for (int x = 0; x < svga->dac_hwcursor_latch.cur_xsize; x++) { if (!(x & 3)) four_pixels = ramdac->indexed_data[svga->dac_hwcursor_latch.addr]; diff --git a/src/video/vid_icd2061.c b/src/video/vid_icd2061.c index 3fafb65d9..57dcdce38 100644 --- a/src/video/vid_icd2061.c +++ b/src/video/vid_icd2061.c @@ -61,8 +61,16 @@ icd2061_write(void *p, int val) { icd2061_t *icd2061 = (icd2061_t *) p; - int nd, oc, nc; - int a, qa, q, pa, p_, m, ps; + int nd; + int oc; + int nc; + int a; + int qa; + int q; + int pa; + int p_; + int m; + int ps; nd = (val & 2) >> 1; /* Old data. */ oc = icd2061->state & 1; /* Old clock. */ diff --git a/src/video/vid_ics2595.c b/src/video/vid_ics2595.c index 10fc5ba39..520bcda43 100644 --- a/src/video/vid_ics2595.c +++ b/src/video/vid_ics2595.c @@ -45,7 +45,8 @@ void ics2595_write(void *p, int strobe, int dat) { ics2595_t *ics2595 = (ics2595_t *) p; - int d, n; + int d; + int n; int l; if (strobe) { diff --git a/src/video/vid_im1024.c b/src/video/vid_im1024.c index 12d884127..cb3999be4 100644 --- a/src/video/vid_im1024.c +++ b/src/video/vid_im1024.c @@ -147,7 +147,7 @@ fifo_read(im1024_t *dev) im1024_log("IM1024: fifo_read: %02x\n", ret); - return (ret); + return ret; } /* @@ -168,12 +168,12 @@ input_byte(pgc_t *pgc, uint8_t *result) } if (pgc->stopped) - return (0); + return 0; if (pgc->mapram[0x3ff]) { /* Reset triggered. */ pgc_reset(pgc); - return (0); + return 0; } if (dev->fifo_wrptr == dev->fifo_rdptr) { @@ -182,7 +182,7 @@ input_byte(pgc_t *pgc, uint8_t *result) } else *result = fifo_read(dev); - return (1); + return 1; } /* Macros to disable clipping and save clip state. */ @@ -214,7 +214,7 @@ im1024_read(uint32_t addr, void *priv) if (addr == 0xc6331 && dev->pgc.mapram[0x330] == 1) { /* Hardcode that there are 128 bytes free. */ - return (0x80); + return 0x80; } return (pgc_read(addr, &dev->pgc)); @@ -255,8 +255,10 @@ hndl_imgsiz(pgc_t *pgc) #if 0 im1024_t *dev = (im1024_t *)pgc; #endif - int16_t w, h; - uint8_t a, b; + int16_t w; + int16_t h; + uint8_t a; + uint8_t b; if (!pgc_param_word(pgc, &w)) return; @@ -318,7 +320,8 @@ hndl_linfun(pgc_t *pgc) static void hndl_pan(pgc_t *pgc) { - int16_t x, y; + int16_t x; + int16_t y; if (!pgc_param_word(pgc, &x)) return; @@ -335,7 +338,8 @@ hndl_pan(pgc_t *pgc) static void hndl_pline(pgc_t *pgc) { - int16_t x[257], y[257]; + int16_t x[257]; + int16_t y[257]; uint16_t linemask = pgc->line_pattern; uint8_t count; unsigned n; @@ -405,9 +409,12 @@ blkmov_row(pgc_t *pgc, int16_t x0, int16_t x1, int16_t x2, int16_t sy, int16_t t static void hndl_blkmov(pgc_t *pgc) { - int16_t x0, y0; - int16_t x1, y1; - int16_t x2, y2; + int16_t x0; + int16_t y0; + int16_t x1; + int16_t y1; + int16_t x2; + int16_t y2; int16_t y; if (!pgc_param_word(pgc, &x0)) @@ -451,7 +458,8 @@ hndl_blkmov(pgc_t *pgc) static void hndl_ellipse(pgc_t *pgc) { - int16_t x, y; + int16_t x; + int16_t y; if (!pgc_param_word(pgc, &x)) return; @@ -471,7 +479,8 @@ hndl_ellipse(pgc_t *pgc) static void hndl_move(pgc_t *pgc) { - int16_t x, y; + int16_t x; + int16_t y; if (!pgc_param_word(pgc, &x)) return; @@ -491,7 +500,8 @@ hndl_move(pgc_t *pgc) static void hndl_draw(pgc_t *pgc) { - int16_t x, y; + int16_t x; + int16_t y; if (!pgc_param_word(pgc, &x)) return; @@ -513,10 +523,16 @@ hndl_draw(pgc_t *pgc) static void hndl_poly(pgc_t *pgc) { - int32_t *x, *y, *nx, *ny; - int16_t xw, yw, mask; + int32_t *x; + int32_t *y; + int32_t *nx; + int32_t *ny; + int16_t xw; + int16_t yw; + int16_t mask; unsigned realcount = 0; - unsigned n, as = 256; + unsigned n; + unsigned as = 256; int parsing = 1; uint8_t count; @@ -596,7 +612,7 @@ hndl_poly(pgc_t *pgc) /* Swallow the POLY. */ pgc->clcur->rdptr++; } - }; + } im1024_log("IM1024: POLY (%i) fill_mode=%i\n", realcount, pgc->fill_mode); #ifdef ENABLE_IM1024_LOG @@ -648,7 +664,12 @@ parse_poly(pgc_t *pgc, pgc_cl_t *cl, int c) static void hndl_rect(pgc_t *pgc) { - int16_t x0, y0, x1, y1, p, q; + int16_t x0; + int16_t y0; + int16_t x1; + int16_t y1; + int16_t p; + int16_t q; x0 = pgc->x >> 16; y0 = pgc->y >> 16; @@ -698,9 +719,11 @@ static void hndl_tdefin(pgc_t *pgc) { im1024_t *dev = (im1024_t *) pgc; - uint8_t ch, bt; - uint8_t rows, cols; - unsigned len, n; + uint8_t ch; + uint8_t bt; + uint8_t rows; + uint8_t cols; + unsigned len; if (!pgc_param_byte(pgc, &ch)) return; @@ -713,7 +736,7 @@ hndl_tdefin(pgc_t *pgc) ch, rows, cols, pgc->mapram[0x300], pgc->mapram[0x301]); len = ((cols + 7) / 8) * rows; - for (n = 0; n < len; n++) { + for (unsigned int n = 0; n < len; n++) { if (!pgc_param_byte(pgc, &bt)) return; @@ -742,8 +765,11 @@ hndl_twrite(pgc_t *pgc) { uint8_t buf[256]; im1024_t *dev = (im1024_t *) pgc; - uint8_t count, mask, *row; - int x, y, wb, n; + uint8_t count; + uint8_t mask; + uint8_t *row; + int wb; + int n; int16_t x0 = pgc->x >> 16; int16_t y0 = pgc->y >> 16; @@ -764,10 +790,10 @@ hndl_twrite(pgc_t *pgc) im1024_log("IM1024: ch=0x%02x w=%i h=%i wb=%i\n", buf[n], dev->fontx[buf[n]], dev->fonty[buf[n]], wb); - for (y = 0; y < dev->fonty[buf[n]]; y++) { + for (uint8_t y = 0; y < dev->fonty[buf[n]]; y++) { mask = 0x80; row = &dev->font[buf[n]][y * wb]; - for (x = 0; x < dev->fontx[buf[n]]; x++) { + for (uint8_t x = 0; x < dev->fontx[buf[n]]; x++) { if (row[0] & mask) pgc_plot(pgc, x + x0, y0 - y); mask = mask >> 1; @@ -786,11 +812,12 @@ static void hndl_txt88(pgc_t *pgc) { uint8_t buf[256]; - uint8_t count, mask, *row; + uint8_t count; + uint8_t mask; + uint8_t *row; int16_t x0 = pgc->x >> 16; int16_t y0 = pgc->y >> 16; unsigned n; - int x, y; if (!pgc_param_byte(pgc, &count)) return; @@ -807,10 +834,10 @@ hndl_txt88(pgc_t *pgc) for (n = 0; n < count; n++) { im1024_log("ch=0x%02x w=12 h=18\n", buf[n]); - for (y = 0; y < 18; y++) { + for (uint8_t y = 0; y < 18; y++) { mask = 0x80; row = &fontdat12x18[buf[n]][y * 2]; - for (x = 0; x < 12; x++) { + for (uint8_t x = 0; x < 12; x++) { if (row[0] & mask) pgc_plot(pgc, x + x0, y0 - y); mask = mask >> 1; @@ -828,9 +855,15 @@ hndl_txt88(pgc_t *pgc) static void hndl_imagew(pgc_t *pgc) { - int16_t vp_x1, vp_y1, vp_x2, vp_y2; - int16_t row1, col1, col2; - uint8_t v1, v2; + int16_t vp_x1; + int16_t vp_y1; + int16_t vp_x2; + int16_t vp_y2; + int16_t row1; + int16_t col1; + int16_t col2; + uint8_t v1; + uint8_t v2; if (!pgc_param_word(pgc, &row1)) return; @@ -908,8 +941,8 @@ hndl_imagew(pgc_t *pgc) static void hndl_dot(pgc_t *pgc) { - int16_t x = pgc->x >> 16, - y = pgc->y >> 16; + int16_t x = pgc->x >> 16; + int16_t y = pgc->y >> 16; pgc_sto_raster(pgc, &x, &y); @@ -928,8 +961,10 @@ hndl_dot(pgc_t *pgc) static void hndl_imagex(pgc_t *pgc) { - int16_t x0, x1, y0, y1; - int16_t p, q; + int16_t x0; + int16_t x1; + int16_t y0; + int16_t y1; if (!pgc_param_word(pgc, &x0)) return; @@ -943,8 +978,8 @@ hndl_imagex(pgc_t *pgc) /* Already using raster coordinates, no need to convert. */ im1024_log("IM1024: IMAGEX (%i,%i,%i,%i)\n", x0, y0, x1, y1); - for (p = y0; p <= y1; p++) { - for (q = x0; q <= x1; q++) { + for (int16_t p = y0; p <= y1; p++) { + for (int16_t q = x0; q <= x1; q++) { if (!pgc_result_byte(pgc, pgc_read_pixel(pgc, q, p))) return; } @@ -1020,7 +1055,7 @@ im1024_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_CGA, &timing_im1024); - return (dev); + return dev; } static void diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index 68673c061..6e8054aaa 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -186,7 +186,8 @@ static void recalc_timings(incolor_t *dev) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; disptime = dev->crtc[0] + 1; _dispontime = dev->crtc[1]; @@ -299,10 +300,8 @@ incolor_write(uint32_t addr, uint8_t val, void *priv) unsigned char fg = dev->crtc[INCOLOR_CRTC_RWCOL] & 0x0F; unsigned char bg = (dev->crtc[INCOLOR_CRTC_RWCOL] >> 4) & 0x0F; unsigned char w = 0; - unsigned char vmask; /* Mask of bit within byte */ unsigned char pmask; /* Mask of plane within colour value */ unsigned char latch; - int plane; addr &= 0xffff; @@ -319,13 +318,13 @@ incolor_write(uint32_t addr, uint8_t val, void *priv) * 3: 1 => source latch, 0 => ~source latch */ pmask = 1; - for (plane = 0; plane < 4; pmask <<= 1, wmask >>= 1, addr += 0x10000, plane++) { + for (uint8_t plane = 0; plane < 4; pmask <<= 1, wmask >>= 1, addr += 0x10000, plane++) { if (wmask & 0x10) /* Ignore writes to selected plane */ { continue; } latch = dev->latch[plane]; - for (vmask = 0x80; vmask != 0; vmask >>= 1) { + for (unsigned char vmask = 0x80 /* Mask of bit within byte */; vmask != 0; vmask >>= 1) { switch (wmode) { case 0x00: if (val & vmask) @@ -375,7 +374,7 @@ incolor_read(uint32_t addr, void *priv) unsigned char dc; /* "don't care" register */ unsigned char bg; /* background colour */ unsigned char fg; - unsigned char mask, pmask; + unsigned char pmask; addr &= 0xffff; @@ -393,7 +392,7 @@ incolor_read(uint32_t addr, void *priv) } /* For each pixel, work out if its colour matches the background */ - for (mask = 0x80; mask != 0; mask >>= 1) { + for (unsigned char mask = 0x80; mask != 0; mask >>= 1) { fg = 0; dc = dev->crtc[INCOLOR_CRTC_RWCTRL] & 0x0F; bg = (dev->crtc[INCOLOR_CRTC_RWCOL] >> 4) & 0x0F; @@ -417,13 +416,15 @@ incolor_read(uint32_t addr, void *priv) static void draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { - int i; - int elg, blk; + int elg; + int blk; unsigned ull; unsigned val; - unsigned ifg, ibg; + unsigned ifg; + unsigned ibg; const unsigned char *fnt; - uint32_t fg, bg; + uint32_t fg; + uint32_t bg; int cw = INCOLOR_CW; blk = 0; @@ -488,7 +489,7 @@ draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) val |= (val >> 1) & 1; } } - for (i = 0; i < cw; i++) { + for (int i = 0; i < cw; i++) { buffer32->line[dev->displine][x * cw + i] = (val & 0x100) ? fg : bg; val = val << 1; } @@ -497,11 +498,14 @@ draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) static void draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { - int i; - int elg, blk; + int elg; + int blk; unsigned ull; unsigned val[4]; - unsigned ifg, ibg, cfg, pmask, plane; + unsigned ifg; + unsigned ibg; + unsigned cfg; + unsigned pmask; const unsigned char *fnt; uint32_t fg; int cw = INCOLOR_CW; @@ -569,11 +573,11 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) val[3] |= (val[3] >> 1) & 1; } } - for (i = 0; i < cw; i++) { + for (int i = 0; i < cw; i++) { /* Generate pixel colour */ cfg = 0; pmask = 1; - for (plane = 0; plane < 4; plane++, pmask = pmask << 1) { + for (uint8_t plane = 0; plane < 4; plane++, pmask = pmask << 1) { if (val[plane] & 0x100) cfg |= (ifg & pmask); else @@ -599,11 +603,20 @@ draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) static void draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { - int i; - int elg, blk, ul, ol, bld; - unsigned ull, oll, ulc = 0, olc = 0; + int elg; + int blk; + int ul; + int ol; + int bld; + unsigned ull; + unsigned oll; + unsigned ulc = 0; + unsigned olc = 0; unsigned val[4]; - unsigned ifg = 0, ibg, cfg, pmask, plane; + unsigned ifg = 0; + unsigned ibg; + unsigned cfg; + unsigned pmask; const unsigned char *fnt; uint32_t fg; int cw = INCOLOR_CW; @@ -692,7 +705,7 @@ draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) val[3] |= (val[3] >> 1); } } - for (i = 0; i < cw; i++) { + for (int i = 0; i < cw; i++) { /* Generate pixel colour */ cfg = 0; pmask = 1; @@ -701,7 +714,7 @@ draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) } else if (dev->sc == ull) { cfg = ulc ^ ibg; /* Underline */ } else { - for (plane = 0; plane < 4; plane++, pmask = pmask << 1) { + for (uint8_t plane = 0; plane < 4; plane++, pmask = pmask << 1) { if (val[plane] & 0x100) { if (altattr) cfg |= ((~ibg) & pmask); @@ -729,11 +742,11 @@ static void text_line(incolor_t *dev, uint16_t ca) { int drawcursor; - int x, c; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; uint32_t col; - for (x = 0; x < dev->crtc[1]; x++) { + for (uint8_t x = 0; x < dev->crtc[1]; x++) { if (dev->ctrl & 8) { chr = dev->vram[(dev->ma << 1) & 0xfff]; attr = dev->vram[((dev->ma << 1) + 1) & 0xfff]; @@ -774,7 +787,7 @@ text_line(incolor_t *dev, uint16_t ca) } else { col = dev->rgb[defpal[ink]]; } - for (c = 0; c < cw; c++) { + for (int c = 0; c < cw; c++) { buffer32->line[dev->displine][x * cw + c] = col; } } @@ -786,7 +799,8 @@ graphics_line(incolor_t *dev) { uint8_t mask; uint16_t ca; - int x, c, plane, col; + int plane; + int col; uint8_t ink; uint16_t val[4]; @@ -795,7 +809,7 @@ graphics_line(incolor_t *dev) if ((dev->ctrl & INCOLOR_CTRL_PAGE1) && (dev->ctrl2 & INCOLOR_CTRL2_PAGE1)) ca += 0x8000; - for (x = 0; x < dev->crtc[1]; x++) { + for (uint8_t x = 0; x < dev->crtc[1]; x++) { mask = dev->crtc[INCOLOR_CRTC_MASK]; /* Planes to display */ for (plane = 0; plane < 4; plane++, mask = mask >> 1) { if (dev->ctrl & 8) { @@ -808,7 +822,7 @@ graphics_line(incolor_t *dev) } dev->ma++; - for (c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { ink = 0; for (plane = 0; plane < 4; plane++) { ink = ink >> 1; @@ -952,7 +966,7 @@ incolor_poll(void *priv) dev->ma = dev->maback; } - if ((dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1)))) + if (dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1))) dev->con = 1; } } diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index 57e91637c..44f91ec95 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -105,7 +105,9 @@ mda_read(uint32_t addr, void *p) void mda_recalctimings(mda_t *mda) { - double _dispontime, _dispofftime, disptime; + double _dispontime; + double _dispofftime; + double disptime; disptime = mda->crtc[0] + 1; _dispontime = mda->crtc[1]; _dispofftime = disptime - _dispontime; @@ -121,9 +123,11 @@ mda_poll(void *p) mda_t *mda = (mda_t *) p; uint16_t ca = (mda->crtc[15] | (mda->crtc[14] << 8)) & 0x3fff; int drawcursor; - int x, c; + int x; + int c; int oldvc; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; int oldsc; int blink; @@ -252,7 +256,7 @@ mda_poll(void *p) mda->sc &= 31; mda->ma = mda->maback; } - if ((mda->sc == (mda->crtc[10] & 31) || ((mda->crtc[8] & 3) == 3 && mda->sc == ((mda->crtc[10] & 31) >> 1)))) { + if (mda->sc == (mda->crtc[10] & 31) || ((mda->crtc[8] & 3) == 3 && mda->sc == ((mda->crtc[10] & 31) >> 1))) { mda->con = 1; } } @@ -262,9 +266,7 @@ mda_poll(void *p) void mda_init(mda_t *mda) { - int c; - - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { mdacols[c][0][0] = mdacols[c][1][0] = mdacols[c][1][1] = 16; if (c & 8) mdacols[c][0][1] = 15 + 16; diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index 50ed4f5a3..677531c29 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -848,7 +848,7 @@ mystique_recalctimings(svga_t *svga) mystique_t *mystique = (mystique_t *) svga->p; int clk_sel = (svga->miscout >> 2) & 3; - svga->clock = (cpuclock * (float) (1ull << 32)) / svga->getclock(clk_sel & 3, svga->clock_gen); + svga->clock = (cpuclock * (float) (1ULL << 32)) / svga->getclock(clk_sel & 3, svga->clock_gen); if (mystique->crtcext_regs[1] & CRTCX_R1_HTOTAL8) svga->htotal += 0x100; @@ -1369,7 +1369,8 @@ mystique_ctrl_read_b(uint32_t addr, void *p) int fifocount; uint16_t addr_0x0f = 0; uint16_t addr_0x03 = 0; - int rs2 = 0, rs3 = 0; + int rs2 = 0; + int rs3 = 0; if ((mystique->type == MGA_2064W) && (addr & 0x3e00) == 0x3c00) { /*RAMDAC*/ @@ -1589,7 +1590,6 @@ mystique_accel_ctrl_write_b(uint32_t addr, uint8_t val, void *p) { mystique_t *mystique = (mystique_t *) p; int start_blit = 0; - int x; if ((addr & 0x300) == 0x100) { addr &= ~0x100; @@ -1620,7 +1620,7 @@ mystique_accel_ctrl_write_b(uint32_t addr, uint8_t val, void *p) case REG_PAT1 + 1: case REG_PAT1 + 2: case REG_PAT1 + 3: - for (x = 0; x < 8; x++) + for (uint8_t x = 0; x < 8; x++) mystique->dwgreg.pattern[addr & 7][x] = mystique->dwgreg.pattern[addr & 7][x + 8] = val & (1 << (7 - x)); break; @@ -1930,7 +1930,8 @@ mystique_ctrl_write_b(uint32_t addr, uint8_t val, void *p) svga_t *svga = &mystique->svga; uint16_t addr_0x0f = 0; uint16_t addr_0x03 = 0; - int rs2 = 0, rs3 = 0; + int rs2 = 0; + int rs3 = 0; if ((mystique->type == MGA_2064W) && (addr & 0x3e00) == 0x3c00) { /*RAMDAC*/ @@ -2174,10 +2175,8 @@ mystique_accel_ctrl_write_l(uint32_t addr, uint32_t val, void *p) mystique->dwgreg.dwgctrl = val; if (val & DWGCTRL_SOLID) { - int x, y; - - for (y = 0; y < 8; y++) { - for (x = 0; x < 16; x++) + for (uint8_t y = 0; y < 8; y++) { + for (uint8_t x = 0; x < 16; x++) mystique->dwgreg.pattern[y][x] = 1; } mystique->dwgreg.src[0] = 0xffffffff; @@ -2251,10 +2250,9 @@ mystique_accel_ctrl_write_l(uint32_t addr, uint32_t val, void *p) case REG_SRC0: { - int x = 0, y = 0; mystique->dwgreg.src[0] = val; - for (y = 0; y < 2; y++) { - for (x = 0; x < 16; x++) { + for (uint8_t y = 0; y < 2; y++) { + for (uint8_t x = 0; x < 16; x++) { mystique->dwgreg.pattern[y][x] = val & (1 << (x + (y * 16))); } } @@ -2265,10 +2263,9 @@ mystique_accel_ctrl_write_l(uint32_t addr, uint32_t val, void *p) break; case REG_SRC1: { - int x = 0, y = 0; mystique->dwgreg.src[1] = val; - for (y = 2; y < 4; y++) { - for (x = 0; x < 16; x++) { + for (uint8_t y = 2; y < 4; y++) { + for (uint8_t x = 0; x < 16; x++) { mystique->dwgreg.pattern[y][x] = val & (1 << (x + ((y - 2) * 16))); } } @@ -2279,10 +2276,9 @@ mystique_accel_ctrl_write_l(uint32_t addr, uint32_t val, void *p) break; case REG_SRC2: { - int x = 0, y = 0; mystique->dwgreg.src[2] = val; - for (y = 4; y < 6; y++) { - for (x = 0; x < 16; x++) { + for (uint8_t y = 4; y < 6; y++) { + for (uint8_t x = 0; x < 16; x++) { mystique->dwgreg.pattern[y][x] = val & (1 << (x + ((y - 4) * 16))); } } @@ -2293,10 +2289,9 @@ mystique_accel_ctrl_write_l(uint32_t addr, uint32_t val, void *p) } case REG_SRC3: { - int x = 0, y = 0; mystique->dwgreg.src[3] = val; - for (y = 6; y < 8; y++) { - for (x = 0; x < 16; x++) { + for (uint8_t y = 6; y < 8; y++) { + for (uint8_t x = 0; x < 16; x++) { mystique->dwgreg.pattern[y][x] = val & (1 << (x + ((y - 6) * 16))); } } @@ -2651,7 +2646,8 @@ run_dma(mystique_t *mystique) } if ((mystique->dma.pri_header & 0xff) != 0x15) { - uint32_t val, reg_addr; + uint32_t val; + uint32_t reg_addr; dma_bm_read(mystique->dma.primaddress & DMA_ADDR_MASK, (uint8_t *) &val, 4, 4); mystique->dma.primaddress += 4; @@ -2693,7 +2689,8 @@ run_dma(mystique_t *mystique) mystique->dma.secaddress += 4; } - uint32_t val, reg_addr; + uint32_t val; + uint32_t reg_addr; dma_bm_read(mystique->dma.secaddress & DMA_ADDR_MASK, (uint8_t *) &val, 4, 4); mystique->dma.secaddress += 4; @@ -3131,18 +3128,18 @@ blit_fbitblt(mystique_t *mystique) { svga_t *svga = &mystique->svga; uint32_t src_addr; - int y; int x_dir = mystique->dwgreg.sgn.scanleft ? -1 : 1; int16_t x_start = mystique->dwgreg.sgn.scanleft ? mystique->dwgreg.fxright : mystique->dwgreg.fxleft; int16_t x_end = mystique->dwgreg.sgn.scanleft ? mystique->dwgreg.fxleft : mystique->dwgreg.fxright; src_addr = mystique->dwgreg.ar[3]; - for (y = 0; y < mystique->dwgreg.length; y++) { + for (uint16_t y = 0; y < mystique->dwgreg.length; y++) { int16_t x = x_start; while (1) { if (x >= mystique->dwgreg.cxleft && x <= mystique->dwgreg.cxright && mystique->dwgreg.ydst_lin >= mystique->dwgreg.ytop && mystique->dwgreg.ydst_lin <= mystique->dwgreg.ybot) { - uint32_t src, old_dst; + uint32_t src; + uint32_t old_dst; switch (mystique->maccess_running & MACCESS_PWIDTH_MASK) { case MACCESS_PWIDTH_8: @@ -3206,11 +3203,13 @@ static void blit_iload_iload(mystique_t *mystique, uint32_t data, int size) { svga_t *svga = &mystique->svga; - uint32_t src, dst; + uint32_t src; + uint32_t dst; uint32_t dst2; uint64_t data64; int min_size = 8; - uint32_t bltckey = mystique->dwgreg.fcol, bltcmsk = mystique->dwgreg.bcol; + uint32_t bltckey = mystique->dwgreg.fcol; + uint32_t bltcmsk = mystique->dwgreg.bcol; const int transc = mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANSC; const int trans_sel = (mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANS_MASK) >> DWGCTRL_TRANS_SHIFT; uint8_t const *const trans = &trans_masks[trans_sel][(mystique->dwgreg.selline & 3) * 4]; @@ -3561,11 +3560,19 @@ blit_iload_iload_scale(mystique_t *mystique, uint32_t data, int size) { svga_t *svga = &mystique->svga; uint64_t data64 = 0; - int y0, y1; - int u, v; - int dR, dG, dB; - int r0, g0, b0; - int r1, g1, b1; + int y0; + int y1; + int u; + int v; + int dR; + int dG; + int dB; + int r0; + int g0; + int b0; + int r1; + int g1; + int b1; switch (mystique->dwgreg.dwgctrl_running & DWGCTRL_BLTMOD_MASK) { case DWGCTRL_BLTMOD_BUYUV: @@ -3692,10 +3699,19 @@ blit_iload_iload_high(mystique_t *mystique, uint32_t data, int size) { svga_t *svga = &mystique->svga; uint32_t out_data; - int y0, y1, u, v; - int dR, dG, dB; - int r = 0, g = 0, b = 0; - int next_r = 0, next_g = 0, next_b = 0; + int y0; + int y1; + int u; + int v; + int dR; + int dG; + int dB; + int r = 0; + int g = 0; + int b = 0; + int next_r = 0; + int next_g = 0; + int next_b = 0; switch (mystique->dwgreg.dwgctrl_running & DWGCTRL_BLTMOD_MASK) { case DWGCTRL_BLTMOD_BUYUV: @@ -3811,7 +3827,8 @@ blit_iload_iload_high(mystique_t *mystique, uint32_t data, int size) static void blit_iload_iload_highv(mystique_t *mystique, uint32_t data, int size) { - uint8_t *src0, *src1; + uint8_t *src0; + uint8_t *src1; switch (mystique->dwgreg.dwgctrl_running & DWGCTRL_BLTMOD_MASK) { case DWGCTRL_BLTMOD_BUYUV: @@ -3890,7 +3907,9 @@ static void blit_line(mystique_t *mystique, int closed) { svga_t *svga = &mystique->svga; - uint32_t src, dst, old_dst; + uint32_t src; + uint32_t dst; + uint32_t old_dst; int x; int z_write; @@ -3971,7 +3990,9 @@ blit_line(mystique_t *mystique, int closed) uint16_t old_z = z_p[x]; if (z_check(z, old_z, mystique->dwgreg.dwgctrl_running & DWGCTRL_ZMODE_MASK)) { - int r = 0, g = 0, b = 0; + int r = 0; + int g = 0; + int b = 0; if (z_write) z_p[x] = z; @@ -4072,7 +4093,10 @@ static void blit_trap(mystique_t *mystique) { svga_t *svga = &mystique->svga; - uint32_t z_back, r_back, g_back, b_back; + uint32_t z_back; + uint32_t r_back; + uint32_t g_back; + uint32_t b_back; int z_write; int y; const int trans_sel = (mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANS_MASK) >> DWGCTRL_TRANS_SHIFT; @@ -4160,7 +4184,8 @@ blit_trap(mystique_t *mystique) int xoff = (mystique->dwgreg.xoff + (x_l & 7)) & 15; int pattern = mystique->dwgreg.pattern[yoff][xoff]; uint32_t src = pattern ? mystique->dwgreg.fcol : mystique->dwgreg.bcol; - uint32_t dst, old_dst; + uint32_t dst; + uint32_t old_dst; switch (mystique->maccess_running & MACCESS_PWIDTH_MASK) { case MACCESS_PWIDTH_8: @@ -4250,8 +4275,11 @@ blit_trap(mystique_t *mystique) uint16_t old_z = z_p[x_l]; if (z_check(z, old_z, mystique->dwgreg.dwgctrl_running & DWGCTRL_ZMODE_MASK)) { - uint32_t dst = 0, old_dst; - int r = 0, g = 0, b = 0; + uint32_t dst = 0; + uint32_t old_dst; + int r = 0; + int g = 0; + int b = 0; if (!(mystique->dwgreg.dr[4] & (1 << 23))) r = (mystique->dwgreg.dr[4] >> 15) & 0xff; @@ -4351,7 +4379,8 @@ texture_read(mystique_t *mystique, int *tex_r, int *tex_g, int *tex_b, int *atra const unsigned int w_mask = (mystique->dwgreg.texwidth & TEXWIDTH_TWMASK_MASK) >> TEXWIDTH_TWMASK_SHIFT; const unsigned int h_mask = (mystique->dwgreg.texheight & TEXHEIGHT_THMASK_MASK) >> TEXHEIGHT_THMASK_SHIFT; uint16_t src = 0; - int s, t; + int s; + int t; if (mystique->dwgreg.texctl & TEXCTL_NPCEN) { const int s_shift = 20 - (mystique->dwgreg.texwidth & TEXWIDTH_TW_MASK); @@ -4362,7 +4391,7 @@ texture_read(mystique_t *mystique, int *tex_r, int *tex_g, int *tex_b, int *atra } else { const int s_shift = (20 + 16) - (mystique->dwgreg.texwidth & TEXWIDTH_TW_MASK); const int t_shift = (20 + 16) - (mystique->dwgreg.texheight & TEXHEIGHT_TH_MASK); - int64_t q = mystique->dwgreg.tmr[8] ? ((0x100000000ll / (int64_t) (int32_t) mystique->dwgreg.tmr[8]) /*>> 16*/) : 0; + int64_t q = mystique->dwgreg.tmr[8] ? (0x100000000LL / (int64_t) (int32_t) mystique->dwgreg.tmr[8] /*>> 16*/) : 0; s = (((int64_t) (int32_t) mystique->dwgreg.tmr[6] * q) /*<< 8*/) >> s_shift; /*((16+20)-12);*/ t = (((int64_t) (int32_t) mystique->dwgreg.tmr[7] * q) /*<< 8*/) >> t_shift; /*((16+20)-9);*/ @@ -4466,9 +4495,14 @@ blit_texture_trap(mystique_t *mystique) uint16_t old_z = z_p[x_l]; if (z_check(z, old_z, mystique->dwgreg.dwgctrl_running & DWGCTRL_ZMODE_MASK)) { - int tex_r = 0, tex_g = 0, tex_b = 0; - int ctransp, atransp = 0; - int i_r = 0, i_g = 0, i_b = 0; + int tex_r = 0; + int tex_g = 0; + int tex_b = 0; + int ctransp; + int atransp = 0; + int i_r = 0; + int i_g = 0; + int i_b = 0; if (!(mystique->dwgreg.dr[4] & (1 << 23))) i_r = (mystique->dwgreg.dr[4] >> 15) & 0xff; @@ -4726,7 +4760,8 @@ blit_bitblt(mystique_t *mystique) if (x >= mystique->dwgreg.cxleft && x <= mystique->dwgreg.cxright && mystique->dwgreg.ydst_lin >= mystique->dwgreg.ytop && mystique->dwgreg.ydst_lin <= mystique->dwgreg.ybot && ((svga->vram[byte_addr] & (1 << bit_offset)) || !(mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANSC)) && trans[x & 3]) { uint32_t src = (svga->vram[byte_addr] & (1 << bit_offset)) ? mystique->dwgreg.fcol : mystique->dwgreg.bcol; - uint32_t dst, old_dst; + uint32_t dst; + uint32_t old_dst; switch (mystique->maccess_running & MACCESS_PWIDTH_MASK) { case MACCESS_PWIDTH_8: @@ -4801,7 +4836,9 @@ blit_bitblt(mystique_t *mystique) while (1) { if (x >= mystique->dwgreg.cxleft && x <= mystique->dwgreg.cxright && mystique->dwgreg.ydst_lin >= mystique->dwgreg.ytop && mystique->dwgreg.ydst_lin <= mystique->dwgreg.ybot && trans[x & 3]) { - uint32_t src, dst, old_dst; + uint32_t src; + uint32_t dst; + uint32_t old_dst; switch (mystique->maccess_running & MACCESS_PWIDTH_MASK) { case MACCESS_PWIDTH_8: @@ -5112,7 +5149,6 @@ static void mystique_hwcursor_draw(svga_t *svga, int displine) { mystique_t *mystique = (mystique_t *) svga->p; - int x; uint64_t dat[2]; int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff; @@ -5124,10 +5160,10 @@ mystique_hwcursor_draw(svga_t *svga, int displine) svga->hwcursor_latch.addr += 16; switch (mystique->xcurctrl & XCURCTRL_CURMODE_MASK) { case XCURCTRL_CURMODE_XGA: - for (x = 0; x < 64; x++) { - if (!(dat[1] & (1ull << 63))) - svga->monitor->target_buffer->line[displine][offset + svga->x_add] = (dat[0] & (1ull << 63)) ? mystique->cursor.col[1] : mystique->cursor.col[0]; - else if (dat[0] & (1ull << 63)) + for (uint8_t x = 0; x < 64; x++) { + if (!(dat[1] & (1ULL << 63))) + svga->monitor->target_buffer->line[displine][offset + svga->x_add] = (dat[0] & (1ULL << 63)) ? mystique->cursor.col[1] : mystique->cursor.col[0]; + else if (dat[0] & (1ULL << 63)) svga->monitor->target_buffer->line[displine][offset + svga->x_add] ^= 0xffffff; offset++; @@ -5409,7 +5445,6 @@ mystique_pci_write(int func, int addr, uint8_t val, void *p) static void * mystique_init(const device_t *info) { - int c; mystique_t *mystique = malloc(sizeof(mystique_t)); char *romfn; @@ -5487,7 +5522,7 @@ mystique_init(const device_t *info) mystique->pci_regs[0x41] = 0x01; /* vgaboot = 1 */ mystique->pci_regs[0x43] = 0x40; /* biosen = 1 */ - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { dither5[c][0][0] = c >> 3; dither5[c][1][1] = (c + 2) >> 3; dither5[c][1][0] = (c + 4) >> 3; diff --git a/src/video/vid_nga.c b/src/video/vid_nga.c index e2e8fdc9c..2d673393b 100644 --- a/src/video/vid_nga.c +++ b/src/video/vid_nga.c @@ -50,9 +50,11 @@ static video_timings_t timing_nga = { .type = VIDEO_ISA, .write_b = 8, .write_w void nga_recalctimings(nga_t *nga) { - double _dispontime, _dispofftime, disptime; + double _dispontime; + double _dispofftime; + double disptime; - if ((nga->cga.cgamode & 1)) { + if (nga->cga.cgamode & 1) { disptime = nga->cga.crtc[0] + 1; _dispontime = nga->cga.crtc[1]; } else { @@ -136,7 +138,7 @@ nga_read(uint32_t addr, void *priv) nga->cga.charbuffer[offset | 1] = nga->cga.vram[addr & 0x7fff]; } - return (ret); + return ret; } void @@ -146,10 +148,15 @@ nga_poll(void *priv) /* set cursor position in memory */ uint16_t ca = (nga->cga.crtc[15] | (nga->cga.crtc[14] << 8)) & 0x3fff; int drawcursor; - int x, c, xs_temp, ys_temp; + int x; + int c; + int xs_temp; + int ys_temp; int oldvc; - uint8_t chr, attr; - uint16_t dat, dat2; + uint8_t chr; + uint8_t attr; + uint16_t dat; + uint16_t dat2; int cols[4]; int col; int oldsc; @@ -338,7 +345,7 @@ nga_poll(void *priv) /* nga specific */ cols[0] = ((nga->cga.cgamode & 0x12) == 0x12) ? 0 : (nga->cga.cgacol & 15) + 16; /* 80-col */ - if ((nga->cga.cgamode & 1)) { + if (nga->cga.cgamode & 1) { hline(buffer32, 0, (nga->cga.displine << 1), ((nga->cga.crtc[1] << 3) + 16) << 2, cols[0]); hline(buffer32, 0, (nga->cga.displine << 1) + 1, ((nga->cga.crtc[1] << 3) + 16) << 2, cols[0]); } else { @@ -347,7 +354,7 @@ nga_poll(void *priv) } } - if ((nga->cga.cgamode & 1)) + if (nga->cga.cgamode & 1) /* set screen width */ x = (nga->cga.crtc[1] << 3) + 16; else @@ -444,7 +451,7 @@ nga_poll(void *priv) nga->cga.vsynctime = 16; /* vsync pos */ if (nga->cga.crtc[7]) { - if ((nga->cga.cgamode & 1)) + if (nga->cga.cgamode & 1) /* set screen width */ x = (nga->cga.crtc[1] << 3) + 16; else @@ -515,7 +522,7 @@ nga_poll(void *priv) nga->cga.cgastat &= ~1; /* enable cursor if its scanline was reached */ - if ((nga->cga.sc == (nga->cga.crtc[10] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[10] & 31) >> 1)))) + if (nga->cga.sc == (nga->cga.crtc[10] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[10] & 31) >> 1))) nga->cga.con = 1; } /* 80-columns */ diff --git a/src/video/vid_oak_oti.c b/src/video/vid_oak_oti.c index cc07dc0a4..4a3b22934 100644 --- a/src/video/vid_oak_oti.c +++ b/src/video/vid_oak_oti.c @@ -69,7 +69,8 @@ oti_out(uint16_t addr, uint8_t val, void *p) oti_t *oti = (oti_t *) p; svga_t *svga = &oti->svga; uint8_t old; - uint8_t idx, enable; + uint8_t idx; + uint8_t enable; if (!oti->chip_id && !(oti->enable_register & 1) && (addr != 0x3C3)) return; @@ -202,7 +203,8 @@ oti_in(uint16_t addr, void *p) { oti_t *oti = (oti_t *) p; svga_t *svga = &oti->svga; - uint8_t idx, temp; + uint8_t idx; + uint8_t temp; if (!oti->chip_id && !(oti->enable_register & 1) && (addr != 0x3C3)) return 0xff; @@ -313,7 +315,7 @@ oti_in(uint16_t addr, void *p) break; } - return (temp); + return temp; } static void @@ -374,7 +376,7 @@ oti_recalctimings(svga_t *svga) oti_t *oti = (oti_t *) svga->p; int clk_sel = ((svga->miscout >> 2) & 3) | ((oti->regs[0x0d] & 0x20) >> 3); - svga->clock = (cpuclock * (double) (1ull << 32)) / oti_getclock(clk_sel); + svga->clock = (cpuclock * (double) (1ULL << 32)) / oti_getclock(clk_sel); if (oti->chip_id > 0) { if (oti->regs[0x14] & 0x08) @@ -473,7 +475,7 @@ oti_init(const device_t *info) oti->svga.miscout = 1; oti->svga.packed_chain4 = 1; - return (oti); + return oti; } static void diff --git a/src/video/vid_ogc.c b/src/video/vid_ogc.c index 38d993216..20be41fad 100644 --- a/src/video/vid_ogc.c +++ b/src/video/vid_ogc.c @@ -59,7 +59,9 @@ static uint8_t mdaattr[256][2][2]; void ogc_recalctimings(ogc_t *ogc) { - double _dispontime, _dispofftime, disptime; + double _dispontime; + double _dispofftime; + double disptime; if (ogc->cga.cgamode & 1) { disptime = ogc->cga.crtc[0] + 1; @@ -134,7 +136,7 @@ ogc_in(uint16_t addr, void *priv) } } - return (ret); + return ret; } void @@ -188,10 +190,15 @@ ogc_poll(void *priv) ogc_t *ogc = (ogc_t *) priv; uint16_t ca = (ogc->cga.crtc[15] | (ogc->cga.crtc[14] << 8)) & 0x3fff; int drawcursor; - int x, c, xs_temp, ys_temp; + int x; + int c; + int xs_temp; + int ys_temp; int oldvc; - uint8_t chr, attr; - uint16_t dat, dat2; + uint8_t chr; + uint8_t attr; + uint16_t dat; + uint16_t dat2; int cols[4]; int oldsc; int blink = 0; @@ -537,9 +544,7 @@ ogc_speed_changed(void *priv) void ogc_mdaattr_rebuild(void) { - int c; - - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { mdaattr[c][0][0] = mdaattr[c][1][0] = mdaattr[c][1][1] = 16; if (c & 8) mdaattr[c][0][1] = 15 + 16; diff --git a/src/video/vid_paradise.c b/src/video/vid_paradise.c index f2ec8aeb2..8971fe01e 100644 --- a/src/video/vid_paradise.c +++ b/src/video/vid_paradise.c @@ -289,7 +289,7 @@ paradise_remap(paradise_t *paradise) paradise->write_bank[1] = paradise->write_bank[3] = (svga->gdcreg[9] << 12) + ((svga->gdcreg[6] & 0x08) ? 0 : 0x8000); } - if ((((svga->gdcreg[0x0b] & 0xc0) == 0xc0) && !svga->chain4 && (svga->crtc[0x14] & 0x40) && ((svga->gdcreg[6] >> 2) & 3) == 1)) + if (((svga->gdcreg[0x0b] & 0xc0) == 0xc0) && !svga->chain4 && (svga->crtc[0x14] & 0x40) && ((svga->gdcreg[6] >> 2) & 3) == 1) paradise->check = 1; if (paradise->bank_mask == 0x7f) { @@ -349,7 +349,8 @@ paradise_write(uint32_t addr, uint8_t val, void *p) { paradise_t *paradise = (paradise_t *) p; svga_t *svga = ¶dise->svga; - uint32_t prev_addr, prev_addr2; + uint32_t prev_addr; + uint32_t prev_addr2; addr = (addr & 0x7fff) + paradise->write_bank[(addr >> 15) & 3]; @@ -397,7 +398,8 @@ paradise_writew(uint32_t addr, uint16_t val, void *p) { paradise_t *paradise = (paradise_t *) p; svga_t *svga = ¶dise->svga; - uint32_t prev_addr, prev_addr2; + uint32_t prev_addr; + uint32_t prev_addr2; addr = (addr & 0x7fff) + paradise->write_bank[(addr >> 15) & 3]; @@ -446,7 +448,8 @@ paradise_read(uint32_t addr, void *p) { paradise_t *paradise = (paradise_t *) p; svga_t *svga = ¶dise->svga; - uint32_t prev_addr, prev_addr2; + uint32_t prev_addr; + uint32_t prev_addr2; addr = (addr & 0x7fff) + paradise->read_bank[(addr >> 15) & 3]; @@ -494,7 +497,8 @@ paradise_readw(uint32_t addr, void *p) { paradise_t *paradise = (paradise_t *) p; svga_t *svga = ¶dise->svga; - uint32_t prev_addr, prev_addr2; + uint32_t prev_addr; + uint32_t prev_addr2; addr = (addr & 0x7fff) + paradise->read_bank[(addr >> 15) & 3]; diff --git a/src/video/vid_pgc.c b/src/video/vid_pgc.c index 74a20145c..d68850bef 100644 --- a/src/video/vid_pgc.c +++ b/src/video/vid_pgc.c @@ -324,7 +324,6 @@ read_command(pgc_t *dev) static int parse_command(pgc_t *dev, const pgc_cmd_t **pcmd) { - const pgc_cmd_t *cmd; char match[7]; *pcmd = NULL; @@ -343,7 +342,7 @@ parse_command(pgc_t *dev, const pgc_cmd_t **pcmd) * dev->commands may be a subclass list (terminated with '*') * or the core list (terminated with '@') */ - for (cmd = dev->commands; cmd->ascii[0] != '@'; cmd++) { + for (const pgc_cmd_t *cmd = dev->commands; cmd->ascii[0] != '@'; cmd++) { /* End of subclass command list, chain to core. */ if (cmd->ascii[0] == '*') cmd = dev->master; @@ -465,12 +464,11 @@ static void hndl_clread(pgc_t *dev) { uint8_t param = 0; - uint32_t n; if (!pgc_param_byte(dev, ¶m)) return; - for (n = 0; n < dev->clist[param].wrptr; n++) { + for (uint32_t n = 0; n < dev->clist[param].wrptr; n++) { if (!pgc_result_byte(dev, dev->clist[param].list[n])) return; } @@ -493,12 +491,11 @@ static void hndl_clears(pgc_t *dev) { uint8_t param = 0; - uint32_t y; if (!pgc_param_byte(dev, ¶m)) return; - for (y = 0; y < dev->screenh; y++) + for (uint32_t y = 0; y < dev->screenh; y++) memset(dev->vram + y * dev->maxw, param, dev->screenw); } @@ -569,7 +566,8 @@ hndl_prmfil(pgc_t *dev) static void hndl_move(pgc_t *dev) { - int32_t x = 0, y = 0; + int32_t x = 0; + int32_t y = 0; if (!pgc_param_coord(dev, &x)) return; @@ -586,7 +584,9 @@ hndl_move(pgc_t *dev) static void hndl_move3(pgc_t *dev) { - int32_t x = 0, y = 0, z = 0; + int32_t x = 0; + int32_t y = 0; + int32_t z = 0; if (!pgc_param_coord(dev, &x)) return; @@ -604,7 +604,8 @@ hndl_move3(pgc_t *dev) static void hndl_mover(pgc_t *dev) { - int32_t x = 0, y = 0; + int32_t x = 0; + int32_t y = 0; if (!pgc_param_coord(dev, &x)) return; @@ -619,7 +620,9 @@ hndl_mover(pgc_t *dev) static void hndl_mover3(pgc_t *dev) { - int32_t x = 0, y = 0, z = 0; + int32_t x = 0; + int32_t y = 0; + int32_t z = 0; if (!pgc_param_coord(dev, &x)) return; @@ -752,7 +755,12 @@ pgc_plot(pgc_t *dev, uint16_t x, uint16_t y) uint16_t pgc_draw_line_r(pgc_t *dev, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint16_t linemask) { - int32_t dx, dy, sx, sy, err, e2; + int32_t dx; + int32_t dy; + int32_t sx; + int32_t sy; + int32_t err; + int32_t e2; dx = abs(x1 - x0); dy = abs(y1 - y0); @@ -850,8 +858,11 @@ pgc_fill_polygon(pgc_t *dev, unsigned corners, int32_t *x, int32_t *y) double *nodex; double *dx; double *dy; - unsigned n, nodes, i, j; - double ymin, ymax, ypos; + unsigned nodes; + unsigned i; + unsigned j; + double ymin; + double ymax; pgc_log("PGC: fill_polygon(%i corners)\n", corners); @@ -878,7 +889,7 @@ pgc_fill_polygon(pgc_t *dev, unsigned corners, int32_t *x, int32_t *y) } ymin = ymax = y[0] / 65536.0; - for (n = 0; n < corners; n++) { + for (unsigned int n = 0; n < corners; n++) { /* Convert from PGC fixed-point to native floating-point. */ dx[n] = x[n] / 65536.0; dy[n] = y[n] / 65536.0; @@ -892,7 +903,7 @@ pgc_fill_polygon(pgc_t *dev, unsigned corners, int32_t *x, int32_t *y) /* Polygon fill. Based on */ /* For each row, work out where the polygon lines intersect with * that row. */ - for (ypos = ymin; ypos <= ymax; ypos++) { + for (double ypos = ymin; ypos <= ymax; ypos++) { nodes = 0; j = corners - 1; for (i = 0; i < corners; i++) { @@ -908,8 +919,10 @@ pgc_fill_polygon(pgc_t *dev, unsigned corners, int32_t *x, int32_t *y) /* And fill between them. */ for (i = 0; i < nodes; i += 2) { - int16_t x1 = (int16_t) nodex[i], x2 = (int16_t) nodex[i + 1], - y1 = (int16_t) ypos, y2 = (int16_t) ypos; + int16_t x1 = (int16_t) nodex[i]; + int16_t x2 = (int16_t) nodex[i + 1]; + int16_t y1 = (int16_t) ypos; + int16_t y2 = (int16_t) ypos; pgc_sto_raster(dev, &x1, &y1); pgc_sto_raster(dev, &x2, &y2); pgc_fill_line_r(dev, x1, x2, y1); @@ -930,7 +943,6 @@ pgc_draw_ellipse(pgc_t *dev, int32_t x, int32_t y) double w = x / 65536.0; double y0 = dev->y / 65536.0; double x0 = dev->x / 65536.0; - double ypos, xpos; double x1; double xlast = 0.0; int16_t linemask = dev->line_pattern; @@ -940,7 +952,7 @@ pgc_draw_ellipse(pgc_t *dev, int32_t x, int32_t y) pgc_dto_raster(dev, &x0, &y0); - for (ypos = 0; ypos <= h; ypos++) { + for (double ypos = 0; ypos <= h; ypos++) { if (ypos == 0) { if (dev->fill_mode) pgc_fill_line_r(dev, (uint16_t) (x0 - w), @@ -966,7 +978,7 @@ pgc_draw_ellipse(pgc_t *dev, int32_t x, int32_t y) } /* Draw border. */ - for (xpos = xlast; xpos >= x1; xpos--) { + for (double xpos = xlast; xpos >= x1; xpos--) { if (linemask & 0x8000) { pgc_plot(dev, (uint16_t) (x0 + xpos), (uint16_t) (y0 + ypos)); @@ -990,7 +1002,8 @@ pgc_draw_ellipse(pgc_t *dev, int32_t x, int32_t y) static void hndl_ellipse(pgc_t *dev) { - int32_t x = 0, y = 0; + int32_t x = 0; + int32_t y = 0; if (!pgc_param_coord(dev, &x)) return; @@ -1007,13 +1020,12 @@ hndl_poly(pgc_t *dev) uint8_t count; int32_t x[256]; int32_t y[256]; - int32_t n; if (!pgc_param_byte(dev, &count)) return; pgc_log("PGC: POLY (%i)\n", count); - for (n = 0; n < count; n++) { + for (uint8_t n = 0; n < count; n++) { if (!pgc_param_coord(dev, &x[n])) return; if (!pgc_param_coord(dev, &y[n])) @@ -1064,8 +1076,11 @@ hndl_display(pgc_t *dev) static void hndl_imagew(pgc_t *dev) { - int16_t row, col1, col2; - uint8_t v1, v2; + int16_t row; + int16_t col1; + int16_t col2; + uint8_t v1; + uint8_t v2; if (!pgc_param_word(dev, &row)) return; @@ -1174,9 +1189,8 @@ static void hndl_lut(pgc_t *dev) { uint8_t param[4]; - int n; - for (n = 0; n < 4; n++) { + for (uint8_t n = 0; n < 4; n++) { if (!pgc_param_byte(dev, ¶m[n])) return; if (n > 0 && param[n] > 15) { @@ -1215,9 +1229,8 @@ void pgc_hndl_lut8(pgc_t *dev) { uint8_t param[4]; - int n; - for (n = 0; n < 4; n++) + for (uint8_t n = 0; n < 4; n++) if (!pgc_param_byte(dev, ¶m[n])) return; @@ -1229,9 +1242,8 @@ static void hndl_areapt(pgc_t *dev) { int16_t pat[16]; - int n; - for (n = 0; n < 16; n++) + for (uint8_t n = 0; n < 16; n++) if (!pgc_param_word(dev, &pat[n])) return; @@ -1319,7 +1331,10 @@ hndl_tsize(pgc_t *pgc) static void hndl_vwport(pgc_t *dev) { - int16_t x1, x2, y1, y2; + int16_t x1; + int16_t x2; + int16_t y1; + int16_t y2; if (!pgc_param_word(dev, &x1)) return; @@ -1341,7 +1356,10 @@ hndl_vwport(pgc_t *dev) static void hndl_window(pgc_t *dev) { - int16_t x1, x2, y1, y2; + int16_t x1; + int16_t x2; + int16_t y1; + int16_t y2; if (!pgc_param_word(dev, &x1)) return; @@ -1583,8 +1601,6 @@ pgc_error(pgc_t *dev, int err) void pgc_reset(pgc_t *dev) { - int n; - memset(dev->mapram, 0x00, sizeof(dev->mapram)); /* The 'CGA disable' jumper is not currently implemented. */ @@ -1617,7 +1633,7 @@ pgc_reset(pgc_t *dev) dev->vp_y2 = dev->vish - 1; /* Empty command lists. */ - for (n = 0; n < 256; n++) { + for (uint16_t n = 0; n < 256; n++) { dev->clist[n].wrptr = 0; dev->clist[n].rdptr = 0; dev->clist[n].repeat = 0; @@ -1763,7 +1779,8 @@ pgc_param_byte(pgc_t *dev, uint8_t *val) int pgc_param_word(pgc_t *dev, int16_t *val) { - uint8_t lo, hi; + uint8_t lo; + uint8_t hi; int32_t c; if (dev->clcur) { @@ -1995,14 +2012,13 @@ int pgc_parse_bytes(pgc_t *dev, pgc_cl_t *cl, int count) { uint8_t *param = (uint8_t *) malloc(count); - int n; if (!param) { pgc_error(dev, PGC_ERROR_OVERFLOW); return 0; } - for (n = 0; n < count; n++) { + for (int n = 0; n < count; n++) { if (!pgc_param_byte(dev, ¶m[n])) { free(param); return 0; @@ -2025,14 +2041,13 @@ int pgc_parse_words(pgc_t *dev, pgc_cl_t *cl, int count) { int16_t *param = (int16_t *) malloc(count * sizeof(int16_t)); - int n; if (!param) { pgc_error(dev, PGC_ERROR_OVERFLOW); return 0; } - for (n = 0; n < count; n++) { + for (int n = 0; n < count; n++) { if (!pgc_param_word(dev, ¶m[n])) { free(param); return 0; @@ -2110,7 +2125,8 @@ pgc_dto_raster(pgc_t *dev, double *x, double *y) void pgc_sto_raster(pgc_t *dev, int16_t *x, int16_t *y) { - double xd = *x, yd = *y; + double xd = *x; + double yd = *y; pgc_dto_raster(dev, &xd, &yd); *x = (int16_t) xd; @@ -2120,7 +2136,8 @@ pgc_sto_raster(pgc_t *dev, int16_t *x, int16_t *y) void pgc_ito_raster(pgc_t *dev, int32_t *x, int32_t *y) { - double xd = *x, yd = *y; + double xd = *x; + double yd = *y; pgc_dto_raster(dev, &xd, &yd); *x = (int32_t) xd; @@ -2130,9 +2147,12 @@ pgc_ito_raster(pgc_t *dev, int32_t *x, int32_t *y) void pgc_recalctimings(pgc_t *dev) { - double disptime, _dispontime, _dispofftime; - double pixel_clock = (cpuclock / (dev->cga_selected ? 25175000.0 : dev->native_pixel_clock) * (double) (1ull << 32)); - uint8_t crtc0 = 97, crtc1 = 80; /* Values from MDA, taken from there due to the 25 MHz refresh rate. */ + double disptime; + double _dispontime; + double _dispofftime; + double pixel_clock = (cpuclock / (dev->cga_selected ? 25175000.0 : dev->native_pixel_clock) * (double) (1ULL << 32)); + uint8_t crtc0 = 97; /* Value from MDA, taken from there due to the 25 MHz refresh rate. */ + uint8_t crtc1 = 80; /* Value from MDA, taken from there due to the 25 MHz refresh rate. */ /* Multiply pixel clock by 8. */ pixel_clock *= 8.0; @@ -2309,8 +2329,8 @@ pgc_read(uint32_t addr, void *priv) void pgc_cga_text(pgc_t *dev, int w) { - int x, c; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; int drawcursor = 0; uint32_t cols[2]; int pitch = (dev->mapram[0x3e9] + 1) * 2; @@ -2324,7 +2344,7 @@ pgc_cga_text(pgc_t *dev, int w) addr = &dev->cga_vram[((ma + ((dev->displine / pitch) * w)) * 2) & 0x3ffe]; ma += (dev->displine / pitch) * w; - for (x = 0; x < w; x++) { + for (int x = 0; x < w; x++) { chr = *addr++; attr = *addr++; @@ -2344,7 +2364,7 @@ pgc_cga_text(pgc_t *dev, int w) cols[0] = (attr >> 4) + 16; } - for (c = 0; c < cw; c++) { + for (int c = 0; c < cw; c++) { if (drawcursor) val = cols[(fontdatm[chr + dev->fontbase][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; else @@ -2365,7 +2385,6 @@ pgc_cga_text(pgc_t *dev, int w) void pgc_cga_gfx40(pgc_t *dev) { - int x, c; uint32_t cols[4]; int col; uint16_t ma = (dev->mapram[0x3ed] | (dev->mapram[0x3ec] << 8)) & 0x3fff; @@ -2394,11 +2413,11 @@ pgc_cga_gfx40(pgc_t *dev) cols[3] = col | 6; } - for (x = 0; x < 40; x++) { + for (uint8_t x = 0; x < 40; x++) { addr = &dev->cga_vram[(ma + 2 * x + 80 * (dev->displine >> 2) + 0x2000 * ((dev->displine >> 1) & 1)) & 0x3fff]; dat = (addr[0] << 8) | addr[1]; dev->ma++; - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { buffer32->line[dev->displine][(x << 4) + (c << 1)] = buffer32->line[dev->displine][(x << 4) + (c << 1) + 1] = cols[dat >> 14]; dat <<= 2; } @@ -2409,7 +2428,6 @@ pgc_cga_gfx40(pgc_t *dev) void pgc_cga_gfx80(pgc_t *dev) { - int x, c; uint32_t cols[2]; uint16_t ma = (dev->mapram[0x3ed] | (dev->mapram[0x3ec] << 8)) & 0x3fff; uint8_t *addr; @@ -2418,11 +2436,11 @@ pgc_cga_gfx80(pgc_t *dev) cols[0] = 16; cols[1] = (dev->mapram[0x3d9] & 15) + 16; - for (x = 0; x < 40; x++) { + for (uint8_t x = 0; x < 40; x++) { addr = &dev->cga_vram[(ma + 2 * x + 80 * (dev->displine >> 2) + 0x2000 * ((dev->displine >> 1) & 1)) & 0x3fff]; dat = (addr[0] << 8) | addr[1]; dev->ma++; - for (c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { buffer32->line[dev->displine][(x << 4) + c] = cols[dat >> 15]; dat <<= 1; } @@ -2512,7 +2530,7 @@ void pgc_poll(void *priv) { pgc_t *dev = (pgc_t *) priv; - uint32_t x, y; + uint32_t y; if (dev->cga_selected) { pgc_cga_poll(dev); @@ -2532,7 +2550,7 @@ pgc_poll(void *priv) * the IM1024 driver uses PAN -112 for an offset of * 224. */ y = dev->displine - 2 * dev->pan_y; - for (x = 0; x < dev->screenw; x++) { + for (uint32_t x = 0; x < dev->screenw; x++) { if (x + dev->pan_x < dev->maxw) buffer32->line[dev->displine][x] = dev->palette[dev->vram[y * dev->maxw + x]]; else @@ -2643,8 +2661,6 @@ void pgc_init(pgc_t *dev, int maxw, int maxh, int visw, int vish, int (*inpbyte)(pgc_t *, uint8_t *), double npc) { - int i; - /* Make it a 16k mapping at C4000 (will be C4000-C7FFF), because of the emulator's granularity - the original mapping will conflict with hard disk controller BIOS'es. */ @@ -2671,7 +2687,7 @@ pgc_init(pgc_t *dev, int maxw, int maxh, int visw, int vish, /* Create and initialize command lists. */ dev->clist = (pgc_cl_t *) malloc(256 * sizeof(pgc_cl_t)); memset(dev->clist, 0x00, 256 * sizeof(pgc_cl_t)); - for (i = 0; i < 256; i++) { + for (uint16_t i = 0; i < 256; i++) { dev->clist[i].list = NULL; dev->clist[i].listmax = 0; dev->clist[i].wrptr = 0; @@ -2708,7 +2724,7 @@ pgc_standalone_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_CGA, &timing_pgc); - return (dev); + return dev; } const device_t pgc_device = { diff --git a/src/video/vid_rtg310x.c b/src/video/vid_rtg310x.c index 6f317426b..f643fd1e4 100644 --- a/src/video/vid_rtg310x.c +++ b/src/video/vid_rtg310x.c @@ -209,22 +209,22 @@ rtg_recalctimings(svga_t *svga) case 1: break; case 2: - svga->clock = (cpuclock * (double) (1ull << 32)) / 36000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; case 3: - svga->clock = (cpuclock * (double) (1ull << 32)) / 65100000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 65100000.0; break; case 4: - svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 44900000.0; break; case 5: - svga->clock = (cpuclock * (double) (1ull << 32)) / 50000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 50000000.0; break; case 6: - svga->clock = (cpuclock * (double) (1ull << 32)) / 80000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 80000000.0; break; case 7: - svga->clock = (cpuclock * (double) (1ull << 32)) / 75000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 75000000.0; break; } @@ -317,7 +317,7 @@ rtg_init(const device_t *info) rom_init(&dev->bios_rom, (char *) fn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - return (dev); + return dev; } static void diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index 346de2ebb..453972402 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -2004,12 +2004,13 @@ static void s3_hwcursor_draw(svga_t *svga, int displine) { s3_t *s3 = (s3_t *) svga->p; - int x, shift = 1; + int shift = 1; int width = 16; uint16_t dat[2]; int xx; int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff; - uint32_t fg, bg; + uint32_t fg; + uint32_t bg; uint32_t real_addr; uint32_t remapped_addr; @@ -2070,7 +2071,7 @@ s3_hwcursor_draw(svga_t *svga, int displine) real_addr = s3_hwcursor_convert_addr(svga); - for (x = 0; x < 64; x += 16) { + for (uint8_t x = 0; x < 64; x += 16) { remapped_addr = dword_remap(svga, real_addr); dat[0] = (svga->vram[remapped_addr & s3->vram_mask] << 8) | svga->vram[(remapped_addr + 1) & s3->vram_mask]; @@ -2334,9 +2335,12 @@ s3_trio64v_overlay_draw(svga_t *svga, int displine) s3_t *s3 = (s3_t *) svga->p; int offset = (s3->streams.sec_x - s3->streams.pri_x) + 1; int h_acc = s3->streams.dda_horiz_accumulator; - int r[8], g[8], b[8]; - int x_size, x_read = 4, x_write = 4; - int x; + int r[8]; + int g[8]; + int b[8]; + int x_size; + int x_read = 4; + int x_write = 4; uint32_t *p; uint8_t *src = &svga->vram[svga->overlay_latch.addr]; @@ -2349,7 +2353,7 @@ s3_trio64v_overlay_draw(svga_t *svga, int displine) OVERLAY_SAMPLE(); - for (x = 0; x < x_size; x++) { + for (int x = 0; x < x_size; x++) { *p++ = r[x_read] | (g[x_read] << 8) | (b[x_read] << 16); h_acc += s3->streams.k1_horiz_scale; @@ -2562,8 +2566,10 @@ s3_out(uint16_t addr, uint8_t val, void *p) { s3_t *s3 = (s3_t *) p; svga_t *svga = &s3->svga; - uint8_t old, mask; - int rs2, rs3; + uint8_t old; + uint8_t mask; + int rs2; + int rs3; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; @@ -2632,7 +2638,7 @@ s3_out(uint16_t addr, uint8_t val, void *p) bt48x_ramdac_out(addr, rs2, rs3, val, svga->ramdac, svga); } else if ((s3->chip == S3_VISION964 && s3->card_type == S3_ELSAWIN2KPROX_964) || (s3->chip == S3_VISION968 && (s3->card_type == S3_ELSAWIN2KPROX || s3->card_type == S3_PHOENIX_VISION968 || s3->card_type == S3_NUMBER9_9FX_771))) ibm_rgb528_ramdac_out(addr, rs2, val, svga->ramdac, svga); - else if ((s3->chip == S3_VISION968 && (s3->card_type == S3_SPEA_MERCURY_P64V || s3->card_type == S3_MIROVIDEO40SV_ERGO_968))) { + else if (s3->chip == S3_VISION968 && (s3->card_type == S3_SPEA_MERCURY_P64V || s3->card_type == S3_MIROVIDEO40SV_ERGO_968)) { rs3 = !!(svga->crtc[0x55] & 0x02); tvp3026_ramdac_out(addr, rs2, rs3, val, svga->ramdac, svga); } else if (((s3->chip == S3_86C801) || (s3->chip == S3_86C805)) && (s3->card_type != S3_MIROCRYSTAL10SD_805 && s3->card_type != S3_MIROCRYSTAL8S_805)) @@ -2906,7 +2912,8 @@ s3_in(uint16_t addr, void *p) { s3_t *s3 = (s3_t *) p; svga_t *svga = &s3->svga; - int rs2, rs3; + int rs2; + int rs3; uint8_t temp; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) @@ -3086,7 +3093,7 @@ s3_recalctimings(svga_t *svga) if ((((svga->miscout >> 2) & 3) == 3) && s3->chip < S3_TRIO32) clk_sel = svga->crtc[0x42] & 0x0f; - svga->clock = (cpuclock * (double) (1ull << 32)) / svga->getclock(clk_sel, svga->clock_gen); + svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clk_sel, svga->clock_gen); switch (svga->crtc[0x67] >> 4) { case 3: @@ -3368,7 +3375,7 @@ s3_trio64v_recalctimings(svga_t *svga) svga->split |= 0x400; svga->interlace = svga->crtc[0x42] & 0x20; - svga->clock = (cpuclock * (double) (1ull << 32)) / svga->getclock(clk_sel, svga->clock_gen); + svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clk_sel, svga->clock_gen); if ((svga->crtc[0x67] & 0xc) != 0xc) /*VGA mode*/ { @@ -3579,7 +3586,9 @@ s3_trio64_getclock(int clock, void *p) s3_t *s3 = (s3_t *) p; svga_t *svga = &s3->svga; float t; - int m, n1, n2; + int m; + int n1; + int n2; if (clock == 0) return 25175000.0; if (clock == 1) @@ -5668,9 +5677,15 @@ polygon_setup(s3_t *s3) static __inline void convert_to_rgb32(int idf, int is_yuv, uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *r2, uint8_t *g2, uint8_t *b2) { - static double dr = 0.0, dg = 0.0, db = 0.0; - static double dY1 = 0.0, dCr = 0.0, dY2 = 0.0, dCb = 0.0; - static double dU = 0.0, dV = 0.0; + static double dr = 0.0; + static double dg = 0.0; + static double db = 0.0; + static double dY1 = 0.0; + static double dCr = 0.0; + static double dY2 = 0.0; + static double dCb = 0.0; + static double dU = 0.0; + static double dV = 0.0; switch (idf) { case 0: /* 8 bpp, RGB 3-3-2 */ @@ -5750,10 +5765,18 @@ convert_to_rgb32(int idf, int is_yuv, uint32_t val, uint8_t *r, uint8_t *g, uint static __inline void convert_from_rgb32(int idf, int odf, int is_yuv, uint32_t *val, uint8_t r, uint8_t g, uint8_t b, uint8_t r2, uint8_t g2, uint8_t b2) { - static double dr = 0.0, dg = 0.0, db = 0.0; - static double dr2 = 0.0, dg2 = 0.0, db2 = 0.0; - static double dY1 = 0.0, dCr = 0.0, dY2 = 0.0, dCb = 0.0; - static double dU = 0.0, dV = 0.0; + static double dr = 0.0; + static double dg = 0.0; + static double db = 0.0; + static double dr2 = 0.0; + static double dg2 = 0.0; + static double db2 = 0.0; + static double dY1 = 0.0; + static double dCr = 0.0; + static double dY2 = 0.0; + static double dCb = 0.0; + static double dU = 0.0; + static double dV = 0.0; dr = (double) r; dg = (double) g; @@ -5832,13 +5855,23 @@ static void s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) { svga_t *svga = &s3->svga; - int idf, odf, host; + int idf; + int odf; + int host; int is_yuv; - uint32_t src, dest = 0x00000000; - uint8_t r = 0x00, g = 0x00, b = 0x00, r2 = 0x00, g2 = 0x00, b2 = 0x00; + uint32_t src; + uint32_t dest = 0x00000000; + uint8_t r = 0x00; + uint8_t g = 0x00; + uint8_t b = 0x00; + uint8_t r2 = 0x00; + uint8_t g2 = 0x00; + uint8_t b2 = 0x00; uint16_t *vram_w = (uint16_t *) svga->vram; uint32_t *vram_l = (uint32_t *) svga->vram; - uint32_t k2 = 0, dda = 0, diff = 0; + uint32_t k2 = 0; + uint32_t dda = 0; + uint32_t diff = 0; int count = -1; idf = s3->videoengine.idf; @@ -5879,8 +5912,8 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) s3->videoengine.sx = k2 - dda + diff - 1; s3->videoengine.sx_backup = s3->videoengine.len - s3->videoengine.start - 1; } - s3->videoengine.sx_scale_inc = (double) ((s3->videoengine.sx_backup >> 1)); - s3->videoengine.sx_scale_inc = s3->videoengine.sx_scale_inc / (double) ((s3->videoengine.sx >> 1)); + s3->videoengine.sx_scale_inc = (double) (s3->videoengine.sx_backup >> 1); + s3->videoengine.sx_scale_inc = s3->videoengine.sx_scale_inc / (double) (s3->videoengine.sx >> 1); } else { s3->videoengine.sx_scale = (double) (s3->videoengine.k1 - 2); s3->videoengine.sx_scale_dec = (s3->videoengine.sx_scale / (double) (s3->videoengine.len - s3->videoengine.start - 2)); @@ -5942,8 +5975,8 @@ s3_visionx68_video_engine_op(uint32_t cpu_dat, s3_t *s3) s3->videoengine.sx = k2 - dda + diff - 1; s3->videoengine.sx_backup = s3->videoengine.len - s3->videoengine.start - 1; } - s3->videoengine.sx_scale_inc = (double) ((s3->videoengine.sx_backup >> 1)); - s3->videoengine.sx_scale_inc = s3->videoengine.sx_scale_inc / (double) ((s3->videoengine.sx >> 1)); + s3->videoengine.sx_scale_inc = (double) (s3->videoengine.sx_backup >> 1); + s3->videoengine.sx_scale_inc = s3->videoengine.sx_scale_inc / (double) (s3->videoengine.sx >> 1); s3->videoengine.cx = 0.0; s3->videoengine.dx = 0.0; @@ -6036,9 +6069,13 @@ 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 = 0, dest_dat, old_dest_dat; - uint32_t out, pat_dat = 0; - int frgd_mix, bkgd_mix; + uint32_t src_dat = 0; + uint32_t dest_dat; + uint32_t old_dest_dat; + uint32_t out; + uint32_t pat_dat = 0; + int frgd_mix; + int bkgd_mix; int clip_t = s3->accel.multifunc[1] & 0xfff; int clip_l = s3->accel.multifunc[2] & 0xfff; int clip_b = s3->accel.multifunc[3] & 0xfff; @@ -6052,7 +6089,8 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ int compare_mode = (s3->accel.multifunc[0xe] >> 7) & 3; uint32_t rd_mask = s3->accel.rd_mask; int cmd = s3->accel.cmd >> 13; - uint32_t srcbase, dstbase; + uint32_t srcbase; + uint32_t dstbase; if ((s3->chip >= S3_TRIO64 || s3->chip == S3_VISION968 || s3->chip == S3_VISION868) && (s3->accel.cmd & (1 << 11))) { cmd |= 8; @@ -6077,7 +6115,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ dstbase >>= 2; } - if ((s3->accel.cmd & 0x100) && ((s3_cpu_src(s3) || (s3_cpu_dest(s3)))) && (!cpu_input || (s3_enable_fifo(s3) == 0))) { + if ((s3->accel.cmd & 0x100) && (s3_cpu_src(s3) || (s3_cpu_dest(s3))) && (!cpu_input || (s3_enable_fifo(s3) == 0))) { s3->force_busy = 1; } @@ -6476,7 +6514,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ s3->accel.temp_cnt = 16; } - if (((s3->accel.cx & 0xfff) >= clip_l && (s3->accel.cx & 0xfff) <= clip_r && (s3->accel.cy & 0xfff) >= clip_t && (s3->accel.cy & 0xfff) <= clip_b)) { + if ((s3->accel.cx & 0xfff) >= clip_l && (s3->accel.cx & 0xfff) <= clip_r && (s3->accel.cy & 0xfff) >= clip_t && (s3->accel.cy & 0xfff) <= clip_b) { if (s3_cpu_dest(s3) && ((s3->accel.multifunc[0xa] & 0xc0) == 0x00)) { mix_dat = mix_mask; /* Mix data = forced to foreground register. */ } else if (s3_cpu_dest(s3) && vram_mask) { @@ -6506,7 +6544,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ break; } - if (((compare_mode == 2 && src_dat != compare) || (compare_mode == 3 && src_dat == compare) || compare_mode < 2)) { + if ((compare_mode == 2 && src_dat != compare) || (compare_mode == 3 && src_dat == compare) || compare_mode < 2) { READ(s3->accel.dest + s3->accel.cx, dest_dat); MIX @@ -6574,7 +6612,8 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ case 3: /*Polygon Fill Solid (Vision868/968 and Trio64 only)*/ { - int end_y1, end_y2; + int end_y1; + int end_y2; if (s3->chip != S3_TRIO64 && s3->chip != S3_VISION968 && s3->chip != S3_VISION868) break; @@ -6612,7 +6651,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ break; } - if (((compare_mode == 2 && src_dat != compare) || (compare_mode == 3 && src_dat == compare) || compare_mode < 2)) { + if ((compare_mode == 2 && src_dat != compare) || (compare_mode == 3 && src_dat == compare) || compare_mode < 2) { READ(s3->accel.dest + s3->accel.poly_x, dest_dat); MIX @@ -6688,7 +6727,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ if (!cpu_input && frgd_mix == 3 && !vram_mask && !compare_mode && (s3->accel.cmd & 0xa0) == 0xa0 && (s3->accel.frgd_mix & 0xf) == 7 && (s3->accel.bkgd_mix & 0xf) == 7) { while (1) { - if (((s3->accel.dx & 0xfff) >= clip_l && (s3->accel.dx & 0xfff) <= clip_r && (s3->accel.dy & 0xfff) >= clip_t && (s3->accel.dy & 0xfff) <= clip_b)) { + if ((s3->accel.dx & 0xfff) >= clip_l && (s3->accel.dx & 0xfff) <= clip_r && (s3->accel.dy & 0xfff) >= clip_t && (s3->accel.dy & 0xfff) <= clip_b) { READ(s3->accel.src + s3->accel.cx, src_dat); READ(s3->accel.dest + s3->accel.dx, dest_dat); @@ -6747,6 +6786,7 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ } if ((((compare_mode == 2 && src_dat != compare) || (compare_mode == 3 && src_dat == compare) || compare_mode < 2))) { + READ(s3->accel.dest + s3->accel.dx, dest_dat); MIX @@ -7029,7 +7069,8 @@ s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, s3_ case 11: /*Polygon Fill Pattern (Vision868/968 and Trio64 only)*/ { - int end_y1, end_y2; + int end_y1; + int end_y2; if (s3->chip != S3_TRIO64 && s3->chip != S3_VISION968 && s3->chip != S3_VISION868) break; @@ -7455,7 +7496,8 @@ static void fifo_thread(void *param) { s3_t *s3 = (s3_t *) param; - uint64_t start_time, end_time; + uint64_t start_time; + uint64_t end_time; while (s3->fifo_thread_run) { thread_set_event(s3->fifo_not_full_event); @@ -7523,8 +7565,8 @@ s3_reset(void *priv) memset(svga->crtc, 0x00, sizeof(svga->crtc)); svga->crtc[0] = 63; svga->crtc[6] = 255; - svga->dispontime = 1000ull << 32; - svga->dispofftime = 1000ull << 32; + svga->dispontime = 1000ULL << 32; + svga->dispofftime = 1000ULL << 32; svga->bpp = 8; if (s3->pci) @@ -7661,7 +7703,8 @@ static void * s3_init(const device_t *info) { const char *bios_fn; - int chip, stepping; + int chip; + int stepping; s3_t *s3 = malloc(sizeof(s3_t)); svga_t *svga = &s3->svga; int vram; diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index d79053f0e..feaba7fe8 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -796,7 +796,7 @@ s3_virge_recalctimings(svga_t *svga) int m = svga->seqregs[0x13] & 0x7f; double freq = (((double) m + 2) / (((double) n + 2) * (double) (1 << r))) * 14318184.0; - svga->clock = (cpuclock * (float) (1ull << 32)) / freq; + svga->clock = (cpuclock * (float) (1ULL << 32)) / freq; } if ((svga->crtc[0x67] & 0xc) != 0xc) /*VGA mode*/ @@ -1179,7 +1179,7 @@ s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) { int x = addr & 4; int y = (addr >> 3) & 7; - int color, xx; + int color; int byte; virge->s3d.pattern_8[y * 8 + x] = val & 0xff; virge->s3d.pattern_8[y * 8 + x + 1] = val >> 8; @@ -1192,7 +1192,7 @@ s3_virge_mmio_fifo_write_l(uint32_t addr, uint32_t val, virge_t *virge) virge->s3d.pattern_16[y * 8 + x + 1] = val >> 16; addr &= 0x00ff; - for (xx = 0; xx < 4; xx++) { + for (uint8_t xx = 0; xx < 4; xx++) { x = ((addr + xx) / 3) % 8; y = ((addr + xx) / 24) % 8; color = ((addr + xx) % 3) << 3; @@ -2045,10 +2045,13 @@ s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) int x_mul; int cpu_dat_shift; uint32_t *pattern_data; - uint32_t src_fg_clr, src_bg_clr; + uint32_t src_fg_clr; + uint32_t src_bg_clr; uint32_t src_addr; uint32_t dest_addr; - uint32_t source = 0, dest = 0, pattern; + uint32_t source = 0; + uint32_t dest = 0; + uint32_t pattern; uint32_t out = 0; int update; @@ -2095,9 +2098,8 @@ s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) break; } if (virge->s3d.cmd_set & CMD_SET_MP) { - int x, y; - for (y = 0; y < 4; y++) { - for (x = 0; x < 8; x++) { + for (uint8_t y = 0; y < 4; y++) { + for (uint8_t x = 0; x < 8; x++) { if (virge->s3d.mono_pat_0 & (1 << (x + y * 8))) mono_pattern[y * 8 + (7 - x)] = virge->s3d.pat_fg_clr; else @@ -2311,7 +2313,9 @@ s3_virge_bitblt(virge_t *virge, int count, uint32_t cpu_dat) do { uint32_t dest_addr = virge->s3d.dest_base + (x * x_mul) + (virge->s3d.dest_y * virge->s3d.dest_str); - uint32_t source = 0, dest = 0, pattern; + uint32_t source = 0; + uint32_t dest = 0; + uint32_t pattern; uint32_t out = 0; int update = 1; @@ -2361,7 +2365,9 @@ skip_line: int xdir = (x < xend) ? 1 : -1; do { uint32_t dest_addr = virge->s3d.dest_base + (x * x_mul) + (y * virge->s3d.dest_str); - uint32_t source = 0, dest = 0, pattern; + uint32_t source = 0; + uint32_t dest = 0; + uint32_t pattern; uint32_t out = 0; int update = 1; @@ -2452,7 +2458,8 @@ static void (*dest_pixel)(s3d_state_t *state); #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) -static int _x, _y; +static int _x; +static int _y; static void tex_ARGB1555(s3d_state_t *state, s3d_texture_state_t *texture_state, rgba_t *out) @@ -2553,7 +2560,8 @@ tex_sample_normal_filter(s3d_state_t *state) s3d_texture_state_t texture_state; int tex_offset; rgba_t tex_samples[4]; - int du, dv; + int du; + int dv; int d[4]; texture_state.level = state->max_d; @@ -2610,7 +2618,8 @@ tex_sample_mipmap_filter(s3d_state_t *state) s3d_texture_state_t texture_state; int tex_offset; rgba_t tex_samples[4]; - int du, dv; + int du; + int dv; int d[4]; texture_state.level = (state->d < 0) ? state->max_d : state->max_d - ((state->d >> 27) & 0xf); @@ -2669,10 +2678,13 @@ static void tex_sample_persp_normal_filter(s3d_state_t *state) { s3d_texture_state_t texture_state; - int32_t w = 0, u, v; + int32_t w = 0; + int32_t u; + int32_t v; int tex_offset; rgba_t tex_samples[4]; - int du, dv; + int du; + int dv; int d[4]; if (state->w) @@ -2735,10 +2747,13 @@ static void tex_sample_persp_normal_filter_375(s3d_state_t *state) { s3d_texture_state_t texture_state; - int32_t w = 0, u, v; + int32_t w = 0; + int32_t u; + int32_t v; int tex_offset; rgba_t tex_samples[4]; - int du, dv; + int du; + int dv; int d[4]; if (state->w) @@ -2803,10 +2818,13 @@ static void tex_sample_persp_mipmap_filter(s3d_state_t *state) { s3d_texture_state_t texture_state; - int32_t w = 0, u, v; + int32_t w = 0; + int32_t u; + int32_t v; int tex_offset; rgba_t tex_samples[4]; - int du, dv; + int du; + int dv; int d[4]; if (state->w) @@ -2873,10 +2891,13 @@ static void tex_sample_persp_mipmap_filter_375(s3d_state_t *state) { s3d_texture_state_t texture_state; - int32_t w = 0, u, v; + int32_t w = 0; + int32_t u; + int32_t v; int tex_offset; rgba_t tex_samples[4]; - int du, dv; + int du; + int dv; int d[4]; if (state->w) @@ -3031,10 +3052,13 @@ tri(virge_t *virge, s3d_t *s3d_tri, s3d_state_t *state, int yc, int32_t dx1, int int bpp = (s3d_tri->cmd_set >> 2) & 7; - uint32_t dest_offset = 0, z_offset = 0; + uint32_t dest_offset = 0; + uint32_t z_offset = 0; uint32_t src_col; - int src_r = 0, src_g = 0, src_b = 0; + int src_r = 0; + int src_g = 0; + int src_b = 0; int x; int xe; @@ -3324,7 +3348,6 @@ s3_virge_triangle(virge_t *virge, s3d_t *s3d_tri) s3d_state_t state; uint32_t tex_base; - int c; uint64_t start_time = plat_timer_read(); uint64_t end_time; @@ -3349,7 +3372,7 @@ s3_virge_triangle(virge_t *virge, s3d_t *s3d_tri) state.base_w = s3d_tri->tws; tex_base = s3d_tri->tex_base; - for (c = 9; c >= 0; c--) { + for (uint8_t c = 9; c >= 0; c--) { state.texture[c] = (uint16_t *) &virge->svga.vram[tex_base]; if (c <= state.max_d) tex_base += ((1 << (c * 2)) * tex_size[(s3d_tri->cmd_set >> 5) & 7]) / 2; @@ -3464,11 +3487,11 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine) { virge_t *virge = (virge_t *) svga->p; - int x; uint16_t dat[2]; int xx; int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff; - uint32_t fg, bg; + uint32_t fg; + uint32_t bg; uint32_t vram_mask = virge->vram_mask; if (svga->interlace && svga->hwcursor_oddeven) @@ -3497,7 +3520,7 @@ s3_virge_hwcursor_draw(svga_t *svga, int displine) break; } - for (x = 0; x < 64; x += 16) { + for (uint8_t x = 0; x < 64; x += 16) { dat[0] = (svga->vram[svga->hwcursor_latch.addr & vram_mask] << 8) | svga->vram[(svga->hwcursor_latch.addr + 1) & vram_mask]; dat[1] = (svga->vram[(svga->hwcursor_latch.addr + 2) & vram_mask] << 8) | svga->vram[(svga->hwcursor_latch.addr + 3) & vram_mask]; if (svga->crtc[0x55] & 0x10) { @@ -3751,9 +3774,12 @@ s3_virge_overlay_draw(svga_t *svga, int displine) virge_t *virge = (virge_t *) svga->p; int offset = (virge->streams.sec_x - virge->streams.pri_x) + 1; int h_acc = virge->streams.dda_horiz_accumulator; - int r[8], g[8], b[8]; - int x_size, x_read = 4, x_write = 4; - int x; + int r[8]; + int g[8]; + int b[8]; + int x_size; + int x_read = 4; + int x_write = 4; uint32_t *p; uint8_t *src = &svga->vram[svga->overlay_latch.addr]; @@ -3766,7 +3792,7 @@ s3_virge_overlay_draw(svga_t *svga, int displine) OVERLAY_SAMPLE(); - for (x = 0; x < x_size; x++) { + for (int x = 0; x < x_size; x++) { *p++ = r[x_read] | (g[x_read] << 8) | (b[x_read] << 16); h_acc += virge->streams.k1_horiz_scale; @@ -4039,8 +4065,8 @@ s3_virge_reset(void *priv) memset(svga->crtc, 0x00, sizeof(svga->crtc)); svga->crtc[0] = 63; svga->crtc[6] = 255; - svga->dispontime = 1000ull << 32; - svga->dispofftime = 1000ull << 32; + svga->dispontime = 1000ULL << 32; + svga->dispofftime = 1000ULL << 32; svga->bpp = 8; io_removehandler(0x03c0, 0x0020, s3_virge_in, NULL, NULL, s3_virge_out, NULL, NULL, virge); diff --git a/src/video/vid_sc1148x_ramdac.c b/src/video/vid_sc1148x_ramdac.c index 873f66e92..ee75d192d 100644 --- a/src/video/vid_sc1148x_ramdac.c +++ b/src/video/vid_sc1148x_ramdac.c @@ -93,7 +93,8 @@ uint8_t sc1148x_ramdac_in(uint16_t addr, int rs2, void *p, svga_t *svga) { sc1148x_ramdac_t *ramdac = (sc1148x_ramdac_t *) p; - uint8_t ret = 0xff, rs = (addr & 0x03) | ((!!rs2) << 2); + uint8_t ret = 0xff; + uint8_t rs = (addr & 0x03) | ((!!rs2) << 2); switch (rs) { case 2: diff --git a/src/video/vid_sdac_ramdac.c b/src/video/vid_sdac_ramdac.c index 45fe714ec..1587bf0e0 100644 --- a/src/video/vid_sdac_ramdac.c +++ b/src/video/vid_sdac_ramdac.c @@ -247,7 +247,9 @@ sdac_getclock(int clock, void *p) { sdac_ramdac_t *ramdac = (sdac_ramdac_t *) p; float t; - int m, n1, n2; + int m; + int n1; + int n2; if (ramdac->regs[0xe] & (1 << 5)) clock = ramdac->regs[0xe] & 7; diff --git a/src/video/vid_sigma.c b/src/video/vid_sigma.c index 0e1833b1e..01979deba 100644 --- a/src/video/vid_sigma.c +++ b/src/video/vid_sigma.c @@ -382,7 +382,8 @@ static void sigma_recalctimings(sigma_t *sigma) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; if (sigma->sigmamode & MODE_80COLS) { disptime = (sigma->crtc[0] + 1) << 1; @@ -403,8 +404,8 @@ sigma_recalctimings(sigma_t *sigma) static void sigma_text80(sigma_t *sigma) { - int x, c; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; uint16_t ca = (sigma->crtc[15] | (sigma->crtc[14] << 8)); uint16_t ma = ((sigma->ma & 0x3FFF) << 1); int drawcursor; @@ -418,7 +419,7 @@ sigma_text80(sigma_t *sigma) /* The Sigma 400 seems to use screen widths stated in words (40 for 80-column, 20 for 40-column) */ - for (x = 0; x < (sigma->crtc[1] << 1); x++) { + for (uint8_t x = 0; x < (sigma->crtc[1] << 1); x++) { chr = vram[x << 1]; attr = vram[(x << 1) + 1]; drawcursor = ((ma == ca) && sigma->con && sigma->cursoron); @@ -434,14 +435,14 @@ sigma_text80(sigma_t *sigma) } if (drawcursor) { - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { if (sigma->sigmamode & MODE_FONT16) buffer32->line[sigma->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][sigma->sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0xf; else buffer32->line[sigma->displine][(x << 3) + c + 8] = cols[(fontdat[chr][sigma->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 0xf; } } else { - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { if (sigma->sigmamode & MODE_FONT16) buffer32->line[sigma->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][sigma->sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; else @@ -458,8 +459,8 @@ sigma_text80(sigma_t *sigma) static void sigma_text40(sigma_t *sigma) { - int x, c; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; uint16_t ca = (sigma->crtc[15] | (sigma->crtc[14] << 8)); uint16_t ma = ((sigma->ma & 0x3FFF) << 1); int drawcursor; @@ -473,7 +474,7 @@ sigma_text40(sigma_t *sigma) /* The Sigma 400 seems to use screen widths stated in words (40 for 80-column, 20 for 40-column) */ - for (x = 0; x < (sigma->crtc[1] << 1); x++) { + for (uint8_t x = 0; x < (sigma->crtc[1] << 1); x++) { chr = vram[x << 1]; attr = vram[(x << 1) + 1]; drawcursor = ((ma == ca) && sigma->con && sigma->cursoron); @@ -489,11 +490,11 @@ sigma_text40(sigma_t *sigma) } if (drawcursor) { - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { buffer32->line[sigma->displine][(x << 4) + 2 * c + 8] = buffer32->line[sigma->displine][(x << 4) + 2 * c + 9] = cols[(fontdatm[chr][sigma->sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0xf; } } else { - for (c = 0; c < 8; c++) { + for (uint8_t c = 0; c < 8; c++) { buffer32->line[sigma->displine][(x << 4) + 2 * c + 8] = buffer32->line[sigma->displine][(x << 4) + 2 * c + 9] = cols[(fontdatm[chr][sigma->sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; } } @@ -507,18 +508,17 @@ sigma_text40(sigma_t *sigma) static void sigma_gfx400(sigma_t *sigma) { - int x; unsigned char *vram = &sigma->vram[((sigma->ma << 1) & 0x1FFF) + (sigma->sc & 3) * 0x2000]; uint8_t plane[4]; - uint8_t mask, col, c; + uint8_t col; - for (x = 0; x < (sigma->crtc[1] << 1); x++) { + for (uint8_t x = 0; x < (sigma->crtc[1] << 1); x++) { plane[0] = vram[x]; plane[1] = vram[0x8000 + x]; plane[2] = vram[0x10000 + x]; plane[3] = vram[0x18000 + x]; - for (c = 0, mask = 0x80; c < 8; c++, mask >>= 1) { + for (uint8_t c = 0, mask = 0x80; c < 8; c++, mask >>= 1) { col = ((plane[3] & mask) ? 8 : 0) | ((plane[2] & mask) ? 4 : 0) | ((plane[1] & mask) ? 2 : 0) | ((plane[0] & mask) ? 1 : 0); col |= 16; buffer32->line[sigma->displine][(x << 3) + c + 8] = col; @@ -536,18 +536,17 @@ sigma_gfx400(sigma_t *sigma) static void sigma_gfx200(sigma_t *sigma) { - int x; unsigned char *vram = &sigma->vram[((sigma->ma << 1) & 0x1FFF) + (sigma->sc & 2) * 0x1000]; uint8_t plane[4]; - uint8_t mask, col, c; + uint8_t col; - for (x = 0; x < (sigma->crtc[1] << 1); x++) { + for (uint8_t x = 0; x < (sigma->crtc[1] << 1); x++) { plane[0] = vram[x]; plane[1] = vram[0x8000 + x]; plane[2] = vram[0x10000 + x]; plane[3] = vram[0x18000 + x]; - for (c = 0, mask = 0x80; c < 8; c++, mask >>= 1) { + for (uint8_t c = 0, mask = 0x80; c < 8; c++, mask >>= 1) { col = ((plane[3] & mask) ? 8 : 0) | ((plane[2] & mask) ? 4 : 0) | ((plane[1] & mask) ? 2 : 0) | ((plane[0] & mask) ? 1 : 0); col |= 16; buffer32->line[sigma->displine][(x << 3) + c + 8] = col; @@ -562,19 +561,19 @@ sigma_gfx200(sigma_t *sigma) static void sigma_gfx4col(sigma_t *sigma) { - int x; unsigned char *vram = &sigma->vram[((sigma->ma << 1) & 0x1FFF) + (sigma->sc & 2) * 0x1000]; uint8_t plane[4]; - uint8_t mask, col, c; + uint8_t mask; + uint8_t col; - for (x = 0; x < (sigma->crtc[1] << 1); x++) { + for (uint8_t x = 0; x < (sigma->crtc[1] << 1); x++) { plane[0] = vram[x]; plane[1] = vram[0x8000 + x]; plane[2] = vram[0x10000 + x]; plane[3] = vram[0x18000 + x]; mask = 0x80; - for (c = 0; c < 4; c++) { + for (uint8_t c = 0; c < 4; c++) { col = ((plane[3] & mask) ? 2 : 0) | ((plane[2] & mask) ? 1 : 0); mask = mask >> 1; col |= ((plane[3] & mask) ? 8 : 0) | ((plane[2] & mask) ? 4 : 0); @@ -593,7 +592,8 @@ static void sigma_poll(void *p) { sigma_t *sigma = (sigma_t *) p; - int x, c; + int x; + int c; int oldvc; uint32_t cols[4]; int oldsc; @@ -767,7 +767,7 @@ sigma_poll(void *p) } if (sigma->cgadispon) sigma->sigmastat &= ~STATUS_RETR_H; - if ((sigma->sc == (sigma->crtc[10] & 31) || ((sigma->crtc[8] & 3) == 3 && sigma->sc == ((sigma->crtc[10] & 31) >> 1)))) + if (sigma->sc == (sigma->crtc[10] & 31) || ((sigma->crtc[8] & 3) == 3 && sigma->sc == ((sigma->crtc[10] & 31) >> 1))) sigma->con = 1; } } @@ -829,7 +829,7 @@ static void static int sigma_available(void) { - return ((rom_present(ROM_SIGMA_FONT) && rom_present(ROM_SIGMA_BIOS))); + return (rom_present(ROM_SIGMA_FONT) && rom_present(ROM_SIGMA_BIOS)); } static void diff --git a/src/video/vid_stg_ramdac.c b/src/video/vid_stg_ramdac.c index 78a477acb..d235477c9 100644 --- a/src/video/vid_stg_ramdac.c +++ b/src/video/vid_stg_ramdac.c @@ -90,7 +90,8 @@ void stg_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga) { stg_ramdac_t *ramdac = (stg_ramdac_t *) p; - int didwrite, old; + int didwrite; + int old; switch (addr) { case 0x3c6: @@ -202,7 +203,9 @@ stg_getclock(int clock, void *p) { stg_ramdac_t *ramdac = (stg_ramdac_t *) p; float t; - int m, n, n2; + int m; + int n; + int n2; uint16_t *c; if (clock == 0) diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index ceeb9cf65..d8829eb2f 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -54,7 +54,8 @@ uint8_t svga_rotate[8][256]; /*Primary SVGA device. As multiple video cards are not yet supported this is the only SVGA device.*/ static svga_t *svga_pri; -int vga_on, ibm8514_on; +int vga_on; +int ibm8514_on; #ifdef ENABLE_SVGA_LOG int svga_do_log = ENABLE_SVGA_LOG; @@ -109,8 +110,8 @@ void svga_out(uint16_t addr, uint8_t val, void *p) { svga_t *svga = (svga_t *) p; - int c; - uint8_t o, index; + uint8_t o; + uint8_t index; switch (addr) { case 0x3c0: @@ -130,7 +131,7 @@ svga_out(uint16_t addr, uint8_t val, void *p) if (svga->attraddr < 16) svga->fullchange = svga->monitor->mon_changeframecount; if (svga->attraddr == 0x10 || svga->attraddr == 0x14 || svga->attraddr < 0x10) { - for (c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { if (svga->attrregs[0x10] & 0x80) { svga->egapal[c] = (svga->attrregs[c] & 0xf) | ((svga->attrregs[0x14] & 0xf) << 4); } else { @@ -294,7 +295,8 @@ uint8_t svga_in(uint16_t addr, void *p) { svga_t *svga = (svga_t *) p; - uint8_t index, ret = 0xff; + uint8_t index; + uint8_t ret = 0xff; switch (addr) { case 0x3c0: @@ -396,18 +398,16 @@ svga_in(uint16_t addr, void *p) break; } - return (ret); + return ret; } void svga_set_ramdac_type(svga_t *svga, int type) { - int c; - if (svga->ramdac_type != type) { svga->ramdac_type = type; - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { if (svga->ramdac_type == RAMDAC_8BIT) svga->pallook[c] = makecol32(svga->vgapal[c].r, svga->vgapal[c].g, svga->vgapal[c].b); else @@ -421,7 +421,10 @@ svga_set_ramdac_type(svga_t *svga, int type) void svga_recalctimings(svga_t *svga) { - double crtcconst, _dispontime, _dispofftime, disptime; + double crtcconst; + double _dispontime; + double _dispofftime; + double disptime; svga->vtotal = svga->crtc[6]; svga->dispend = svga->crtc[0x12]; @@ -675,9 +678,12 @@ void svga_poll(void *p) { svga_t *svga = (svga_t *) p; - uint32_t x, blink_delay; - int wx, wy; - int ret, old_ma; + uint32_t x; + uint32_t blink_delay; + int wx; + int wy; + int ret; + int old_ma; if (!vga_on && ibm8514_enabled && ibm8514_on) { ibm8514_poll(&svga->dev8514, svga); @@ -946,15 +952,15 @@ svga_init(const device_t *info, svga_t *svga, void *p, int memsize, void (*hwcursor_draw)(struct svga_t *svga, int displine), void (*overlay_draw)(struct svga_t *svga, int displine)) { - int c, d, e; + int e; svga->p = p; svga->monitor_index = monitor_index_global; svga->monitor = &monitors[svga->monitor_index]; - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { e = c; - for (d = 0; d < 8; d++) { + for (uint8_t d = 0; d < 8; d++) { svga_rotate[d][c] = e; e = (e >> 1) | ((e & 1) ? 0x80 : 0); } @@ -971,8 +977,8 @@ svga_init(const device_t *info, svga_t *svga, void *p, int memsize, svga->crtc[0] = 63; svga->crtc[6] = 255; - svga->dispontime = 1000ull << 32; - svga->dispofftime = 1000ull << 32; + svga->dispontime = 1000ULL << 32; + svga->dispofftime = 1000ULL << 32; svga->bpp = 8; svga->vram = calloc(memsize, 1); svga->vram_max = memsize; @@ -1080,10 +1086,12 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *p) { svga_t *svga = (svga_t *) p; - int writemask2 = svga->writemask, reset_wm = 0; + int writemask2 = svga->writemask; + int reset_wm = 0; latch_t vall; uint8_t wm = svga->writemask; - uint8_t count, i; + uint8_t count; + uint8_t i; if (svga->adv_flags & FLAG_ADDR_BY8) writemask2 = svga->seqregs[2]; @@ -1284,9 +1292,9 @@ svga_read_common(uint32_t addr, uint8_t linear, void *p) svga_t *svga = (svga_t *) p; uint32_t latch_addr = 0; int readplane = svga->readplane; - uint8_t count, i; - uint8_t plane, pixel; - uint8_t temp, ret; + uint8_t count; + uint8_t temp; + uint8_t ret; if (svga->adv_flags & FLAG_ADDR_BY8) readplane = svga->gdcreg[4] & 7; @@ -1337,7 +1345,7 @@ svga_read_common(uint32_t addr, uint8_t linear, void *p) if (addr >= svga->vram_max) return 0xff; latch_addr = (addr & svga->vram_mask) & ~3; - for (i = 0; i < count; i++) + for (uint8_t i = 0; i < count; i++) svga->latch.b[i] = svga->vram[latch_addr | i]; return svga->vram[addr & svga->vram_mask]; } else if (svga->chain4 && !svga->force_old_addr) { @@ -1358,12 +1366,12 @@ svga_read_common(uint32_t addr, uint8_t linear, void *p) /* standard VGA latched access */ if (latch_addr >= svga->vram_max) { - for (i = 0; i < count; i++) + for (uint8_t i = 0; i < count; i++) svga->latch.b[i] = 0xff; } else { latch_addr &= svga->vram_mask; - for (i = 0; i < count; i++) + for (uint8_t i = 0; i < count; i++) svga->latch.b[i] = svga->vram[latch_addr | i]; } @@ -1375,8 +1383,8 @@ svga_read_common(uint32_t addr, uint8_t linear, void *p) if (svga->readmode) { temp = 0xff; - for (pixel = 0; pixel < 8; pixel++) { - for (plane = 0; plane < count; plane++) { + for (uint8_t pixel = 0; pixel < 8; pixel++) { + for (uint8_t plane = 0; plane < count; plane++) { if (svga->colournocare & (1 << plane)) { /* If we care about a plane, and the pixel has a mismatch on it, clear its bit. */ if (((svga->latch.b[plane] >> pixel) & 1) != ((svga->colourcompare >> plane) & 1)) @@ -1419,15 +1427,21 @@ svga_read_linear(uint32_t addr, void *p) void svga_doblit(int wx, int wy, svga_t *svga) { - int y_add, x_add, y_start, x_start, bottom; + int y_add; + int x_add; + int y_start; + int x_start; + int bottom; uint32_t *p; - int i, j; - int xs_temp, ys_temp; + int i; + int j; + int xs_temp; + int ys_temp; - y_add = (enable_overscan) ? svga->monitor->mon_overscan_y : 0; - x_add = (enable_overscan) ? svga->monitor->mon_overscan_x : 0; - y_start = (enable_overscan) ? 0 : (svga->monitor->mon_overscan_y >> 1); - x_start = (enable_overscan) ? 0 : (svga->monitor->mon_overscan_x >> 1); + y_add = enable_overscan ? svga->monitor->mon_overscan_y : 0; + x_add = enable_overscan ? svga->monitor->mon_overscan_x : 0; + y_start = enable_overscan ? 0 : (svga->monitor->mon_overscan_y >> 1); + x_start = enable_overscan ? 0 : (svga->monitor->mon_overscan_x >> 1); bottom = (svga->monitor->mon_overscan_y >> 1) + (svga->crtc[8] & 0x1f); if (svga->vertical_linedbl) { @@ -1669,7 +1683,8 @@ svga_readw_common(uint32_t addr, uint8_t linear, void *p) addr &= svga->decode_mask; if (svga->translate_address) { - uint8_t val1 = 0xff, val2 = 0xff; + uint8_t val1 = 0xff; + uint8_t val2 = 0xff; uint32_t addr2 = svga->translate_address(addr, p); if (addr2 < svga->vram_max) val1 = svga->vram[addr2 & svga->vram_mask]; @@ -1716,7 +1731,10 @@ svga_readl_common(uint32_t addr, uint8_t linear, void *p) addr &= svga->decode_mask; if (svga->translate_address) { - uint8_t val1 = 0xff, val2 = 0xff, val3 = 0xff, val4 = 0xff; + uint8_t val1 = 0xff; + uint8_t val2 = 0xff; + uint8_t val3 = 0xff; + uint8_t val4 = 0xff; uint32_t addr2 = svga->translate_address(addr, p); if (addr2 < svga->vram_max) val1 = svga->vram[addr2 & svga->vram_mask]; diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 81621681f..af4cb83da 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -75,8 +75,6 @@ svga_render_blank(svga_t *svga) void svga_render_overscan_left(svga_t *svga) { - int i; - if ((svga->displine + svga->y_add) < 0) return; @@ -84,14 +82,14 @@ svga_render_overscan_left(svga_t *svga) return; uint32_t *line_ptr = svga->monitor->target_buffer->line[svga->displine + svga->y_add]; - for (i = 0; i < svga->x_add; i++) + for (int i = 0; i < svga->x_add; i++) *line_ptr++ = svga->overscan_color; } void svga_render_overscan_right(svga_t *svga) { - int i, right; + int right; if ((svga->displine + svga->y_add) < 0) return; @@ -101,7 +99,7 @@ svga_render_overscan_right(svga_t *svga) uint32_t *line_ptr = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add + svga->hdisp]; right = (overscan_x >> 1); - for (i = 0; i < right; i++) + for (int i = 0; i < right; i++) *line_ptr++ = svga->overscan_color; } @@ -109,11 +107,15 @@ void svga_render_text_40(svga_t *svga) { uint32_t *p; - int x, xx; - int drawcursor, xinc; - uint8_t chr, attr, dat; + int xx; + int drawcursor; + int xinc; + uint8_t chr; + uint8_t attr; + uint8_t dat; uint32_t charaddr; - int fg, bg; + int fg; + int bg; uint32_t addr = 0; if ((svga->displine + svga->y_add) < 0) @@ -127,7 +129,7 @@ svga_render_text_40(svga_t *svga) p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; xinc = (svga->seqregs[1] & 1) ? 16 : 18; - for (x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { + for (int x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { if (!svga->force_old_addr) addr = svga->remap_func(svga, svga->ma) & svga->vram_display_mask; @@ -183,11 +185,15 @@ void svga_render_text_80(svga_t *svga) { uint32_t *p; - int x, xx; - int drawcursor, xinc; - uint8_t chr, attr, dat; + int xx; + int drawcursor; + int xinc; + uint8_t chr; + uint8_t attr; + uint8_t dat; uint32_t charaddr; - int fg, bg; + int fg; + int bg; uint32_t addr = 0; if ((svga->displine + svga->y_add) < 0) @@ -201,7 +207,7 @@ svga_render_text_80(svga_t *svga) p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; xinc = (svga->seqregs[1] & 1) ? 8 : 9; - for (x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { + for (int x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { if (!svga->force_old_addr) addr = svga->remap_func(svga, svga->ma) & svga->vram_display_mask; @@ -257,11 +263,16 @@ void svga_render_text_80_ksc5601(svga_t *svga) { uint32_t *p; - int x, xx; - int drawcursor, xinc; - uint8_t chr, attr, dat, nextchr; + int xx; + int drawcursor; + int xinc; + uint8_t chr; + uint8_t attr; + uint8_t dat; + uint8_t nextchr; uint32_t charaddr; - int fg, bg; + int fg; + int bg; if ((svga->displine + svga->y_add) < 0) return; @@ -275,7 +286,7 @@ svga_render_text_80_ksc5601(svga_t *svga) xinc = (svga->seqregs[1] & 1) ? 8 : 9; - for (x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { + for (int x = 0; x < (svga->hdisp + svga->scrollcache); x += xinc) { uint32_t addr = svga->remap_func(svga, svga->ma) & svga->vram_display_mask; drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron); chr = svga->vram[addr]; @@ -381,11 +392,12 @@ svga_render_text_80_ksc5601(svga_t *svga) void svga_render_2bpp_lowres(svga_t *svga) { - int changed_offset; - int x; - uint8_t dat[2]; - uint32_t addr, *p; - uint32_t changed_addr; + int changed_offset; + int x; + uint8_t dat[2]; + uint32_t addr; + uint32_t *p; + uint32_t changed_addr; if ((svga->displine + svga->y_add) < 0) return; @@ -478,11 +490,12 @@ svga_render_2bpp_lowres(svga_t *svga) void svga_render_2bpp_highres(svga_t *svga) { - int changed_offset; - int x; - uint8_t dat[2]; - uint32_t addr, *p; - uint32_t changed_addr; + int changed_offset; + int x; + uint8_t dat[2]; + uint32_t addr; + uint32_t *p; + uint32_t changed_addr; if ((svga->displine + svga->y_add) < 0) return; @@ -575,12 +588,12 @@ svga_render_2bpp_highres(svga_t *svga) void svga_render_2bpp_headland_highres(svga_t *svga) { - int x; - int oddeven; - uint32_t addr, *p; - uint8_t edat[4]; - uint8_t dat; - uint32_t changed_addr; + int oddeven; + uint32_t addr; + uint32_t *p; + uint8_t edat[4]; + uint8_t dat; + uint32_t changed_addr; if ((svga->displine + svga->y_add) < 0) return; @@ -594,7 +607,7 @@ svga_render_2bpp_headland_highres(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { addr = svga->remap_func(svga, svga->ma); oddeven = 0; @@ -630,11 +643,13 @@ svga_render_2bpp_headland_highres(svga_t *svga) void svga_render_4bpp_lowres(svga_t *svga) { - int x, oddeven; - uint32_t addr, *p; - uint8_t edat[4]; - uint8_t dat; - uint32_t changed_addr; + int x; + int oddeven; + uint32_t addr; + uint32_t *p; + uint8_t edat[4]; + uint8_t dat; + uint32_t changed_addr; if ((svga->displine + svga->y_add) < 0) return; @@ -745,12 +760,14 @@ svga_render_4bpp_lowres(svga_t *svga) void svga_render_4bpp_highres(svga_t *svga) { - int changed_offset; - int x, oddeven; - uint32_t addr, *p; - uint8_t edat[4]; - uint8_t dat; - uint32_t changed_addr; + int changed_offset; + int x; + int oddeven; + uint32_t addr; + uint32_t *p; + uint8_t edat[4]; + uint8_t dat; + uint32_t changed_addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1018,7 +1035,6 @@ svga_render_8bpp_highres(svga_t *svga) void svga_render_8bpp_tseng_lowres(svga_t *svga) { - int x; uint32_t *p; uint32_t dat; @@ -1032,7 +1048,7 @@ svga_render_8bpp_tseng_lowres(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { dat = *(uint32_t *) (&svga->vram[svga->ma & svga->vram_display_mask]); if (svga->attrregs[0x10] & 0x80) dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4); @@ -1060,7 +1076,6 @@ svga_render_8bpp_tseng_lowres(svga_t *svga) void svga_render_8bpp_tseng_highres(svga_t *svga) { - int x; uint32_t *p; uint32_t dat; @@ -1074,7 +1089,7 @@ svga_render_8bpp_tseng_highres(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x <= (svga->hdisp /* + svga->scrollcache*/); x += 8) { + for (int x = 0; x <= (svga->hdisp /* + svga->scrollcache*/); x += 8) { dat = *(uint32_t *) (&svga->vram[svga->ma & svga->vram_display_mask]); if (svga->attrregs[0x10] & 0x80) dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4); @@ -1122,7 +1137,8 @@ svga_render_15bpp_lowres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1138,7 +1154,7 @@ svga_render_15bpp_lowres(svga_t *svga) for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 4) { dat = *(uint32_t *) (&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); - p[(x << 1)] = p[(x << 1) + 1] = video_15to32[dat & 0xffff]; + p[x << 1] = p[(x << 1) + 1] = video_15to32[dat & 0xffff]; p[(x << 1) + 2] = p[(x << 1) + 3] = video_15to32[dat >> 16]; dat = *(uint32_t *) (&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]); @@ -1193,7 +1209,8 @@ svga_render_15bpp_highres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1289,7 +1306,7 @@ svga_render_15bpp_mix_lowres(svga_t *svga) for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 4) { dat = *(uint32_t *) (&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); - p[(x << 1)] = p[(x << 1) + 1] = (dat & 0x00008000) ? svga->pallook[dat & 0xff] : video_15to32[dat & 0xffff]; + p[x << 1] = p[(x << 1) + 1] = (dat & 0x00008000) ? svga->pallook[dat & 0xff] : video_15to32[dat & 0xffff]; dat >>= 16; p[(x << 1) + 2] = p[(x << 1) + 3] = (dat & 0x00008000) ? svga->pallook[dat & 0xff] : video_15to32[dat & 0xffff]; @@ -1354,7 +1371,8 @@ svga_render_16bpp_lowres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1369,7 +1387,7 @@ svga_render_16bpp_lowres(svga_t *svga) for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 4) { dat = *(uint32_t *) (&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); - p[(x << 1)] = p[(x << 1) + 1] = video_16to32[dat & 0xffff]; + p[x << 1] = p[(x << 1) + 1] = video_16to32[dat & 0xffff]; p[(x << 1) + 2] = p[(x << 1) + 3] = video_16to32[dat >> 16]; dat = *(uint32_t *) (&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]); @@ -1423,7 +1441,8 @@ svga_render_16bpp_highres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1506,8 +1525,11 @@ svga_render_24bpp_lowres(svga_t *svga) { int x; uint32_t *p; - uint32_t changed_addr, addr; - uint32_t dat0, dat1, dat2; + uint32_t changed_addr; + uint32_t addr; + uint32_t dat0; + uint32_t dat1; + uint32_t dat2; uint32_t fg; if ((svga->displine + svga->y_add) < 0) @@ -1579,8 +1601,11 @@ svga_render_24bpp_highres(svga_t *svga) { int x; uint32_t *p; - uint32_t changed_addr, addr; - uint32_t dat0, dat1, dat2; + uint32_t changed_addr; + uint8_t addr; + uint32_t dat0; + uint32_t dat1; + uint32_t dat2; uint32_t dat; if ((svga->displine + svga->y_add) < 0) @@ -1662,7 +1687,8 @@ svga_render_32bpp_lowres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1717,7 +1743,8 @@ svga_render_32bpp_highres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1773,7 +1800,8 @@ svga_render_ABGR8888_highres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; @@ -1812,7 +1840,8 @@ svga_render_RGBA8888_highres(svga_t *svga) int x; uint32_t *p; uint32_t dat; - uint32_t changed_addr, addr; + uint32_t changed_addr; + uint32_t addr; if ((svga->displine + svga->y_add) < 0) return; diff --git a/src/video/vid_table.c b/src/video/vid_table.c index e4b53978b..a2cead1ec 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -370,7 +370,7 @@ video_card_available(int card) if (video_cards[card].device) return (device_available(video_cards[card].device)); - return (1); + return 1; } int @@ -389,7 +389,7 @@ int video_card_has_config(int card) { if (video_cards[card].device == NULL) - return (0); + return 0; return (device_has_config(video_cards[card].device) ? 1 : 0); } @@ -407,11 +407,11 @@ video_get_video_from_internal_name(char *s) while (video_cards[c].device != NULL) { if (!strcmp((char *) video_cards[c].device->internal_name, s)) - return (c); + return c; c++; } - return (0); + return 0; } int diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index f2475888b..fc191b249 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -678,7 +678,7 @@ tgui_recalctimings(svga_t *svga) if (tgui->type >= TGUI_9440) { if (svga->miscout & 8) - svga->clock = (cpuclock * (double) (1ull << 32)) / (((tgui->clock_n + 8) * 14318180.0) / ((tgui->clock_m + 2) * (1 << tgui->clock_k))); + svga->clock = (cpuclock * (double) (1ULL << 32)) / (((tgui->clock_n + 8) * 14318180.0) / ((tgui->clock_m + 2) * (1 << tgui->clock_k))); if (svga->gdcreg[0xf] & 0x08) svga->clock *= 2; @@ -687,46 +687,46 @@ tgui_recalctimings(svga_t *svga) } else { switch (((svga->miscout >> 2) & 3) | ((tgui->newctrl2 << 2) & 4) | ((tgui->newctrl2 >> 3) & 8)) { case 0x02: - svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 44900000.0; break; case 0x03: - svga->clock = (cpuclock * (double) (1ull << 32)) / 36000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; case 0x04: - svga->clock = (cpuclock * (double) (1ull << 32)) / 57272000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 57272000.0; break; case 0x05: - svga->clock = (cpuclock * (double) (1ull << 32)) / 65000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 65000000.0; break; case 0x06: - svga->clock = (cpuclock * (double) (1ull << 32)) / 50350000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 50350000.0; break; case 0x07: - svga->clock = (cpuclock * (double) (1ull << 32)) / 40000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 40000000.0; break; case 0x08: - svga->clock = (cpuclock * (double) (1ull << 32)) / 88000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 88000000.0; break; case 0x09: - svga->clock = (cpuclock * (double) (1ull << 32)) / 98000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 98000000.0; break; case 0x0a: - svga->clock = (cpuclock * (double) (1ull << 32)) / 118800000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 118800000.0; break; case 0x0b: - svga->clock = (cpuclock * (double) (1ull << 32)) / 108000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 108000000.0; break; case 0x0c: - svga->clock = (cpuclock * (double) (1ull << 32)) / 72000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 72000000.0; break; case 0x0d: - svga->clock = (cpuclock * (double) (1ull << 32)) / 77000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 77000000.0; break; case 0x0e: - svga->clock = (cpuclock * (double) (1ull << 32)) / 80000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 80000000.0; break; case 0x0f: - svga->clock = (cpuclock * (double) (1ull << 32)) / 75000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 75000000.0; break; } if (svga->gdcreg[0xf] & 0x08) { @@ -894,7 +894,6 @@ static void tgui_hwcursor_draw(svga_t *svga, int displine) { uint32_t dat[2]; - int xx; int offset = svga->hwcursor_latch.x + svga->hwcursor_latch.xoff; int pitch = (svga->hwcursor_latch.cur_xsize == 64) ? 16 : 8; @@ -903,7 +902,7 @@ tgui_hwcursor_draw(svga_t *svga, int displine) dat[0] = (svga->vram[svga->hwcursor_latch.addr] << 24) | (svga->vram[svga->hwcursor_latch.addr + 1] << 16) | (svga->vram[svga->hwcursor_latch.addr + 2] << 8) | svga->vram[svga->hwcursor_latch.addr + 3]; dat[1] = (svga->vram[svga->hwcursor_latch.addr + 4] << 24) | (svga->vram[svga->hwcursor_latch.addr + 5] << 16) | (svga->vram[svga->hwcursor_latch.addr + 6] << 8) | svga->vram[svga->hwcursor_latch.addr + 7]; - for (xx = 0; xx < 32; xx++) { + for (uint8_t xx = 0; xx < 32; xx++) { if (svga->crtc[0x50] & 0x40) { if (offset >= svga->hwcursor_latch.x) { if (dat[0] & 0x80000000) @@ -1069,7 +1068,6 @@ tgui_ext_linear_read(uint32_t addr, void *p) { svga_t *svga = (svga_t *) p; tgui_t *tgui = (tgui_t *) svga->p; - int c; cycles -= video_timing_read_b; @@ -1080,7 +1078,7 @@ tgui_ext_linear_read(uint32_t addr, void *p) addr &= ~0xf; addr = dword_remap(svga, addr); - for (c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { tgui->copy_latch[c] = svga->vram[addr + c]; addr += ((c & 3) == 3) ? 13 : 1; } @@ -1341,10 +1339,14 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) { svga_t *svga = &tgui->svga; uint32_t *pattern_data; - int x, y; - int c, d; + int x; + int y; + int c; + int d; uint32_t out; - uint32_t src_dat = 0, dst_dat, pat_dat; + uint32_t src_dat = 0; + uint32_t dst_dat; + uint32_t pat_dat; int xdir = (tgui->accel.flags & 0x200) ? -1 : 1; int ydir = (tgui->accel.flags & 0x100) ? -1 : 1; uint32_t trans_col = (tgui->accel.flags & TGUI_TRANSREV) ? tgui->accel.fg_col : tgui->accel.bg_col; @@ -3563,7 +3565,7 @@ tgui_close(void *p) if (tgui->type >= TGUI_9440) { ddc_close(tgui->ddc); i2c_gpio_close(tgui->i2c); - }; + } free(tgui); } diff --git a/src/video/vid_ti_cf62011.c b/src/video/vid_ti_cf62011.c index f804a6dde..32c37ca8b 100644 --- a/src/video/vid_ti_cf62011.c +++ b/src/video/vid_ti_cf62011.c @@ -195,7 +195,7 @@ vid_in(uint16_t addr, void *priv) break; } - return (ret); + return ret; } static void @@ -252,7 +252,7 @@ vid_init(const device_t *info) ti->svga.bpp = 8; ti->svga.miscout = 1; - return (ti); + return ti; } const device_t ibm_ps1_2121_device = { diff --git a/src/video/vid_tvga.c b/src/video/vid_tvga.c index 384770ba4..5cac5fb06 100644 --- a/src/video/vid_tvga.c +++ b/src/video/vid_tvga.c @@ -305,46 +305,46 @@ tvga_recalctimings(svga_t *svga) switch (clksel) { case 0x2: - svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 44900000.0; break; case 0x3: - svga->clock = (cpuclock * (double) (1ull << 32)) / 36000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; case 0x4: - svga->clock = (cpuclock * (double) (1ull << 32)) / 57272000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 57272000.0; break; case 0x5: - svga->clock = (cpuclock * (double) (1ull << 32)) / 65000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 65000000.0; break; case 0x6: - svga->clock = (cpuclock * (double) (1ull << 32)) / 50350000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 50350000.0; break; case 0x7: - svga->clock = (cpuclock * (double) (1ull << 32)) / 40000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 40000000.0; break; case 0x8: - svga->clock = (cpuclock * (double) (1ull << 32)) / 88000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 88000000.0; break; case 0x9: - svga->clock = (cpuclock * (double) (1ull << 32)) / 98000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 98000000.0; break; case 0xa: - svga->clock = (cpuclock * (double) (1ull << 32)) / 118800000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 118800000.0; break; case 0xb: - svga->clock = (cpuclock * (double) (1ull << 32)) / 108000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 108000000.0; break; case 0xc: - svga->clock = (cpuclock * (double) (1ull << 32)) / 72000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 72000000.0; break; case 0xd: - svga->clock = (cpuclock * (double) (1ull << 32)) / 77000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 77000000.0; break; case 0xe: - svga->clock = (cpuclock * (double) (1ull << 32)) / 80000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 80000000.0; break; case 0xf: - svga->clock = (cpuclock * (double) (1ull << 32)) / 75000000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 75000000.0; break; } diff --git a/src/video/vid_tvp3026_ramdac.c b/src/video/vid_tvp3026_ramdac.c index 783b52abf..8a59f6e01 100644 --- a/src/video/vid_tvp3026_ramdac.c +++ b/src/video/vid_tvp3026_ramdac.c @@ -452,11 +452,20 @@ tvp3026_recalctimings(void *p, svga_t *svga) void tvp3026_hwcursor_draw(svga_t *svga, int displine) { - int x, xx, comb, b0, b1; + int comb; + int b0; + int b1; uint16_t dat[2]; int offset = svga->dac_hwcursor_latch.x + svga->dac_hwcursor_latch.xoff; - int pitch, bppl, mode, x_pos, y_pos; - uint32_t clr1, clr2, clr3, *p; + int pitch; + int bppl; + int mode; + int x_pos; + int y_pos; + uint32_t clr1; + uint32_t clr2; + uint32_t clr3; + uint32_t *p; uint8_t *cd; tvp3026_ramdac_t *ramdac = (tvp3026_ramdac_t *) svga->ramdac; @@ -478,11 +487,11 @@ tvp3026_hwcursor_draw(svga_t *svga, int displine) cd = (uint8_t *) ramdac->cursor64_data; - for (x = 0; x < svga->dac_hwcursor_latch.cur_xsize; x += 16) { + for (int x = 0; x < svga->dac_hwcursor_latch.cur_xsize; x += 16) { dat[0] = (cd[svga->dac_hwcursor_latch.addr] << 8) | cd[svga->dac_hwcursor_latch.addr + 1]; dat[1] = (cd[svga->dac_hwcursor_latch.addr + bppl] << 8) | cd[svga->dac_hwcursor_latch.addr + bppl + 1]; - for (xx = 0; xx < 16; xx++) { + for (uint8_t xx = 0; xx < 16; xx++) { b0 = (dat[0] >> (15 - xx)) & 1; b1 = (dat[1] >> (15 - xx)) & 1; comb = (b0 | (b1 << 1)); @@ -544,8 +553,11 @@ float tvp3026_getclock(int clock, void *p) { tvp3026_ramdac_t *ramdac = (tvp3026_ramdac_t *) p; - int n, m, pl; - float f_vco, f_pll; + int n; + int m; + int pl; + float f_vco; + float f_pll; if (clock == 0) return 25175000.0; diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index cb5491c03..6544246be 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -48,7 +48,12 @@ #include <86box/vid_voodoo_render.h> #include <86box/vid_voodoo_texture.h> -rgba8_t rgb332[0x100], ai44[0x100], rgb565[0x10000], argb1555[0x10000], argb4444[0x10000], ai88[0x10000]; +rgba8_t rgb332[0x100]; +rgba8_t ai44[0x100]; +rgba8_t rgb565[0x10000]; +rgba8_t argb1555[0x10000]; +rgba8_t argb4444[0x10000]; +rgba8_t ai88[0x10000]; int tris = 0; @@ -1208,8 +1213,6 @@ voodoo_init(const device_t *info) void voodoo_card_close(voodoo_t *voodoo) { - int c; - voodoo->fifo_thread_run = 0; thread_set_event(voodoo->wake_fifo_thread); thread_wait(voodoo->fifo_thread); @@ -1237,7 +1240,7 @@ voodoo_card_close(voodoo_t *voodoo) thread_destroy_event(voodoo->render_not_full_event[0]); thread_destroy_event(voodoo->render_not_full_event[1]); - for (c = 0; c < TEX_CACHE_MAX; c++) { + for (uint8_t c = 0; c < TEX_CACHE_MAX; c++) { if (voodoo->dual_tmus) free(voodoo->texture_cache[1][c].data); free(voodoo->texture_cache[0][c].data); diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 6ad91ad1f..d2e57de81 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -329,8 +329,10 @@ banshee_out(uint16_t addr, uint8_t val, void *p) svga_t *svga = &banshee->svga; uint8_t old; - // /*if (addr != 0x3c9) */banshee_log("banshee_out : %04X %02X %04X:%04X\n", addr, val, CS,cpu_state.pc); - +#if 0 + if (addr != 0x3c9) + banshee_log("banshee_out : %04X %02X %04X:%04X\n", addr, val, CS,cpu_state.pc); +#endif if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) addr ^= 0x60; @@ -453,7 +455,6 @@ static void banshee_render_16bpp_tiled(svga_t *svga) { banshee_t *banshee = (banshee_t *) svga->p; - int x; uint32_t *p = &((uint32_t *) svga->monitor->target_buffer->line[svga->displine + svga->y_add])[svga->x_add]; uint32_t addr; int drawn = 0; @@ -466,14 +467,13 @@ banshee_render_16bpp_tiled(svga_t *svga) else addr = banshee->desktop_addr + (banshee->desktop_y & 31) * 128 + ((banshee->desktop_y >> 5) * banshee->desktop_stride_tiled); - for (x = 0; x <= svga->hdisp; x += 64) { + for (int x = 0; x <= svga->hdisp; x += 64) { if (svga->hwcursor_on || svga->overlay_on) svga->changedvram[addr >> 12] = 2; if (svga->changedvram[addr >> 12] || svga->fullchange) { uint16_t *vram_p = (uint16_t *) &svga->vram[addr & svga->vram_display_mask]; - int xx; - for (xx = 0; xx < 64; xx++) + for (uint8_t xx = 0; xx < 64; xx++) *p++ = video_16to32[*vram_p++]; drawn = 1; @@ -608,7 +608,7 @@ banshee_recalctimings(svga_t *svga) int n = (banshee->pllCtrl0 >> 8) & 0xff; double freq = (((double) n + 2) / (((double) m + 2) * (double) (1 << k))) * 14318184.0; - svga->clock = (cpuclock * (float) (1ull << 32)) / freq; + svga->clock = (cpuclock * (float) (1ULL << 32)) / freq; // svga->clock = cpuclock / freq; // banshee_log("svga->clock = %g %g m=%i k=%i n=%i\n", freq, freq / 1000000.0, m, k, n); @@ -1127,7 +1127,10 @@ banshee_ext_inl(uint16_t addr, void *p) break; } - // /*if (addr) */banshee_log("banshee_ext_inl: addr=%04x val=%08x\n", addr, ret); +#if 0 + if (addr) + banshee_log("banshee_ext_inl: addr=%04x val=%08x\n", addr, ret); +#endif return ret; } @@ -1360,7 +1363,10 @@ banshee_reg_readl(uint32_t addr, void *p) break; } - // /*if (addr != 0xe0000000) */banshee_log("banshee_reg_readl: addr=%08x ret=%08x %04x(%08x):%08x\n", addr, ret, CS,cs,cpu_state.pc); +#if 0 + if (addr != 0xe0000000) + banshee_log("banshee_reg_readl: addr=%08x ret=%08x %04x(%08x):%08x\n", addr, ret, CS,cs,cpu_state.pc); +#endif return ret; } @@ -1368,7 +1374,9 @@ banshee_reg_readl(uint32_t addr, void *p) static void banshee_reg_write(uint32_t addr, uint8_t val, void *p) { - // banshee_log("banshee_reg_writeb: addr=%08x val=%02x\n", addr, val); +#if 0 + banshee_log("banshee_reg_writeb: addr=%08x val=%02x\n", addr, val); +#endif } static void @@ -1379,7 +1387,9 @@ banshee_reg_writew(uint32_t addr, uint16_t val, void *p) cycles -= voodoo->write_time; - // banshee_log("banshee_reg_writew: addr=%08x val=%04x\n", addr, val); +#if 0 + banshee_log("banshee_reg_writew: addr=%08x val=%04x\n", addr, val); +#endif switch (addr & 0x1f00000) { case 0x1000000: case 0x1100000: @@ -1406,7 +1416,9 @@ static void banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val) { voodoo_t *voodoo = banshee->voodoo; - // banshee_log("banshee_cmd_write: addr=%03x val=%08x\n", addr & 0x1fc, val); +#if 0 + banshee_log("banshee_cmd_write: addr=%03x val=%08x\n", addr & 0x1fc, val); +#endif switch (addr & 0x1fc) { case Agp_agpHostAddressLow: banshee->agpHostAddressLow = val; @@ -1431,7 +1443,9 @@ banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val) case cmdBaseAddr0: voodoo->cmdfifo_base = (val & 0xfff) << 12; voodoo->cmdfifo_end = voodoo->cmdfifo_base + (((voodoo->cmdfifo_size & 0xff) + 1) << 12); - // banshee_log("cmdfifo_base=%08x cmdfifo_end=%08x %08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end, val); +#if 0 + banshee_log("cmdfifo_base=%08x cmdfifo_end=%08x %08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end, val); +#endif break; case cmdBaseSize0: @@ -1440,12 +1454,16 @@ banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val) voodoo->cmdfifo_enabled = val & 0x100; if (!voodoo->cmdfifo_enabled) voodoo->cmdfifo_in_sub = 0; /*Not sure exactly when this should be reset*/ - // banshee_log("cmdfifo_base=%08x cmdfifo_end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); +#if 0 + banshee_log("cmdfifo_base=%08x cmdfifo_end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); +#endif break; - // voodoo->cmdfifo_end = ((val >> 16) & 0x3ff) << 12; - // banshee_log("CMDFIFO base=%08x end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); - // break; +#if 0 + voodoo->cmdfifo_end = ((val >> 16) & 0x3ff) << 12; + banshee_log("CMDFIFO base=%08x end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); + break; +#endif case cmdRdPtrL0: voodoo->cmdfifo_rp = val; @@ -1466,15 +1484,17 @@ banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val) break; } - /* cmdBaseSize0 = 0x24, - cmdBump0 = 0x28, - cmdRdPtrL0 = 0x2c, - cmdRdPtrH0 = 0x30, - cmdAMin0 = 0x34, - cmdAMax0 = 0x3c, - cmdFifoDepth0 = 0x44, - cmdHoleCnt0 = 0x48 - }*/ +#if 0 + cmdBaseSize0 = 0x24, + cmdBump0 = 0x28, + cmdRdPtrL0 = 0x2c, + cmdRdPtrH0 = 0x30, + cmdAMin0 = 0x34, + cmdAMax0 = 0x3c, + cmdFifoDepth0 = 0x44, + cmdHoleCnt0 = 0x48 + } +#endif } static void @@ -1489,7 +1509,9 @@ banshee_reg_writel(uint32_t addr, uint32_t val, void *p) cycles -= voodoo->write_time; voodoo->last_write_addr = addr; - // banshee_log("banshee_reg_writel: addr=%08x val=%08x\n", addr, val); +#if 0 + banshee_log("banshee_reg_writel: addr=%08x val=%08x\n", addr, val); +#endif switch (addr & 0x1f00000) { case 0x0000000: /*IO remap*/ @@ -1497,7 +1519,9 @@ banshee_reg_writel(uint32_t addr, uint32_t val, void *p) banshee_ext_outl(addr & 0xff, val, banshee); else banshee_cmd_write(banshee, addr, val); - // banshee_log("CMD!!! write %08x %08x\n", addr, val); +#if 0 + banshee_log("CMD!!! write %08x %08x\n", addr, val); +#endif break; case 0x0100000: /*2D registers*/ @@ -1515,7 +1539,9 @@ banshee_reg_writel(uint32_t addr, uint32_t val, void *p) switch (addr & 0x3fc) { case SST_intrCtrl: banshee->intrCtrl = val & 0x0030003f; - // banshee_log("intrCtrl=%08x\n", val); +#if 0 + banshee_log("intrCtrl=%08x\n", val); +#endif break; case SST_userIntrCMD: @@ -1527,7 +1553,9 @@ banshee_reg_writel(uint32_t addr, uint32_t val, void *p) voodoo_queue_command(voodoo, (addr & 0x3fc) | FIFO_WRITEL_REG, val); if (!voodoo->voodoo_busy) voodoo_wake_fifo_threads(voodoo->set, voodoo); - // banshee_log("SST_swapbufferCMD write: %i %i\n", voodoo->cmd_written, voodoo->cmd_written_fifo); +#if 0 + banshee_log("SST_swapbufferCMD write: %i %i\n", voodoo->cmd_written, voodoo->cmd_written_fifo); +#endif break; case SST_triangleCMD: voodoo->cmd_written++; @@ -1558,7 +1586,9 @@ banshee_reg_writel(uint32_t addr, uint32_t val, void *p) thread_wait_mutex(voodoo->swap_mutex); voodoo->swap_count++; thread_release_mutex(voodoo->swap_mutex); - // voodoo->cmd_written++; +#if 0 + voodoo->cmd_written++; +#endif break; default: @@ -1608,21 +1638,26 @@ banshee_read_linear(uint32_t addr, void *p) } addr &= svga->decode_mask; if (addr >= voodoo->tile_base) { - int x, y; + int x; + int y; addr -= voodoo->tile_base; x = addr & (voodoo->tile_stride - 1); y = addr >> voodoo->tile_stride_shift; addr = voodoo->tile_base + (x & 127) + ((x >> 7) * 128 * 32) + ((y & 31) * 128) + (y >> 5) * voodoo->tile_x_real; - // banshee_log(" Tile rb %08x->%08x %i %i\n", old_addr, addr, x, y); +#if 0 + banshee_log(" Tile rb %08x->%08x %i %i\n", old_addr, addr, x, y); +#endif } if (addr >= svga->vram_max) return 0xff; cycles -= svga->monitor->mon_video_timing_read_b; - // banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); +#if 0 + banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); +#endif return svga->vram[addr & svga->vram_mask]; } @@ -1643,21 +1678,26 @@ banshee_read_linear_w(uint32_t addr, void *p) } addr &= svga->decode_mask; if (addr >= voodoo->tile_base) { - int x, y; + int x; + int y; addr -= voodoo->tile_base; x = addr & (voodoo->tile_stride - 1); y = addr >> voodoo->tile_stride_shift; addr = voodoo->tile_base + (x & 127) + ((x >> 7) * 128 * 32) + ((y & 31) * 128) + (y >> 5) * voodoo->tile_x_real; - // banshee_log(" Tile rb %08x->%08x %i %i\n", old_addr, addr, x, y); +#if 0 + banshee_log(" Tile rb %08x->%08x %i %i\n", old_addr, addr, x, y); +#endif } if (addr >= svga->vram_max) return 0xff; cycles -= svga->monitor->mon_video_timing_read_w; - // banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); +#if 0 + banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); +#endif return *(uint16_t *) &svga->vram[addr & svga->vram_mask]; } @@ -1679,21 +1719,26 @@ banshee_read_linear_l(uint32_t addr, void *p) } addr &= svga->decode_mask; if (addr >= voodoo->tile_base) { - int x, y; + int x; + int y; addr -= voodoo->tile_base; x = addr & (voodoo->tile_stride - 1); y = addr >> voodoo->tile_stride_shift; addr = voodoo->tile_base + (x & 127) + ((x >> 7) * 128 * 32) + ((y & 31) * 128) + (y >> 5) * voodoo->tile_x_real; - // banshee_log(" Tile rb %08x->%08x %i %i\n", old_addr, addr, x, y); +#if 0 + banshee_log(" Tile rb %08x->%08x %i %i\n", old_addr, addr, x, y); +#endif } if (addr >= svga->vram_max) return 0xff; cycles -= svga->monitor->mon_video_timing_read_l; - // banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); +#if 0 + banshee_log("read_linear: addr=%08x val=%02x\n", addr, svga->vram[addr & svga->vram_mask]); +#endif return *(uint32_t *) &svga->vram[addr & svga->vram_mask]; } @@ -1707,17 +1752,22 @@ banshee_write_linear(uint32_t addr, uint8_t val, void *p) cycles -= voodoo->write_time; - // banshee_log("write_linear: addr=%08x val=%02x\n", addr, val); +#if 0 + banshee_log("write_linear: addr=%08x val=%02x\n", addr, val); +#endif addr &= svga->decode_mask; if (addr >= voodoo->tile_base) { - int x, y; + int x; + int y; addr -= voodoo->tile_base; x = addr & (voodoo->tile_stride - 1); y = addr >> voodoo->tile_stride_shift; addr = voodoo->tile_base + (x & 127) + ((x >> 7) * 128 * 32) + ((y & 31) * 128) + (y >> 5) * voodoo->tile_x_real; - // banshee_log(" Tile b %08x->%08x %i %i\n", old_addr, addr, x, y); +#if 0 + banshee_log(" Tile b %08x->%08x %i %i\n", old_addr, addr, x, y); +#endif } if (addr >= svga->vram_max) return; @@ -1742,17 +1792,22 @@ banshee_write_linear_w(uint32_t addr, uint16_t val, void *p) } cycles -= voodoo->write_time; - // banshee_log("write_linear: addr=%08x val=%02x\n", addr, val); +#if 0 + banshee_log("write_linear: addr=%08x val=%02x\n", addr, val); +#endif addr &= svga->decode_mask; if (addr >= voodoo->tile_base) { - int x, y; + int x; + int y; addr -= voodoo->tile_base; x = addr & (voodoo->tile_stride - 1); y = addr >> voodoo->tile_stride_shift; addr = voodoo->tile_base + (x & 127) + ((x >> 7) * 128 * 32) + ((y & 31) * 128) + (y >> 5) * voodoo->tile_x_real; - // banshee_log(" Tile b %08x->%08x %i %i\n", old_addr, addr, x, y); +#if 0 + banshee_log(" Tile b %08x->%08x %i %i\n", old_addr, addr, x, y); +#endif } if (addr >= svga->vram_max) return; @@ -1784,17 +1839,23 @@ banshee_write_linear_l(uint32_t addr, uint32_t val, void *p) cycles -= timing; voodoo->last_write_addr = addr; - // /*if (val) */banshee_log("write_linear_l: addr=%08x val=%08x %08x\n", addr, val, voodoo->tile_base); +#if 0 + if (val) + banshee_log("write_linear_l: addr=%08x val=%08x %08x\n", addr, val, voodoo->tile_base); +#endif addr &= svga->decode_mask; if (addr >= voodoo->tile_base) { - int x, y; + int x; + int y; addr -= voodoo->tile_base; x = addr & (voodoo->tile_stride - 1); y = addr >> voodoo->tile_stride_shift; addr = voodoo->tile_base + (x & 127) + ((x >> 7) * 128 * 32) + ((y & 31) * 128) + (y >> 5) * voodoo->tile_x_real; - // banshee_log(" Tile %08x->%08x->%08x->%08x %i %i tile_x=%i\n", old_addr, addr_off, addr2, addr, x, y, voodoo->tile_x_real); +#if 0 + banshee_log(" Tile %08x->%08x->%08x->%08x %i %i tile_x=%i\n", old_addr, addr_off, addr2, addr, x, y, voodoo->tile_x_real); +#endif } if (addr >= svga->vram_max) @@ -1805,26 +1866,34 @@ banshee_write_linear_l(uint32_t addr, uint32_t val, void *p) svga->changedvram[addr >> 12] = changeframecount; *(uint32_t *) &svga->vram[addr & svga->vram_mask] = val; if (voodoo->cmdfifo_enabled && addr >= voodoo->cmdfifo_base && addr < voodoo->cmdfifo_end) { - // banshee_log("CMDFIFO write %08x %08x old amin=%08x amax=%08x hlcnt=%i depth_wr=%i rp=%08x\n", addr, val, voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, voodoo->cmdfifo_holecount, voodoo->cmdfifo_depth_wr, voodoo->cmdfifo_rp); +#if 0 + banshee_log("CMDFIFO write %08x %08x old amin=%08x amax=%08x hlcnt=%i depth_wr=%i rp=%08x\n", addr, val, voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, voodoo->cmdfifo_holecount, voodoo->cmdfifo_depth_wr, voodoo->cmdfifo_rp); +#endif if (addr == voodoo->cmdfifo_base && !voodoo->cmdfifo_holecount) { - // if (voodoo->cmdfifo_holecount) - // fatal("CMDFIFO reset pointers while outstanding holes\n"); +#if 0 + if (voodoo->cmdfifo_holecount) + fatal("CMDFIFO reset pointers while outstanding holes\n"); +#endif /*Reset pointers*/ voodoo->cmdfifo_amin = voodoo->cmdfifo_base; voodoo->cmdfifo_amax = voodoo->cmdfifo_base; voodoo->cmdfifo_depth_wr++; voodoo_wake_fifo_thread(voodoo); } else if (voodoo->cmdfifo_holecount) { - // if ((addr <= voodoo->cmdfifo_amin && voodoo->cmdfifo_amin != -4) || addr >= voodoo->cmdfifo_amax) - // fatal("CMDFIFO holecount write outside of amin/amax - amin=%08x amax=%08x holecount=%i\n", voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, voodoo->cmdfifo_holecount); - // banshee_log("holecount %i\n", voodoo->cmdfifo_holecount); +#if 0 + if ((addr <= voodoo->cmdfifo_amin && voodoo->cmdfifo_amin != -4) || addr >= voodoo->cmdfifo_amax) + fatal("CMDFIFO holecount write outside of amin/amax - amin=%08x amax=%08x holecount=%i\n", voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, voodoo->cmdfifo_holecount); + banshee_log("holecount %i\n", voodoo->cmdfifo_holecount); +#endif voodoo->cmdfifo_holecount--; if (!voodoo->cmdfifo_holecount) { /*Filled in holes, resume normal operation*/ voodoo->cmdfifo_depth_wr += ((voodoo->cmdfifo_amax - voodoo->cmdfifo_amin) >> 2); voodoo->cmdfifo_amin = voodoo->cmdfifo_amax; voodoo_wake_fifo_thread(voodoo); - // banshee_log("hole filled! amin=%08x amax=%08x added %i words\n", voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, words_to_add); +#if 0 + banshee_log("hole filled! amin=%08x amax=%08x added %i words\n", voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, words_to_add); +#endif } } else if (addr == voodoo->cmdfifo_amax + 4) { /*In-order write*/ @@ -1838,11 +1907,15 @@ banshee_write_linear_l(uint32_t addr, uint32_t val, void *p) /*Reset back to start. Note that write is still out of order!*/ voodoo->cmdfifo_amin = voodoo->cmdfifo_base - 4; } - // else if (addr < voodoo->cmdfifo_amax) - // fatal("Out-of-order write really out of order\n"); +#if 0 + else if (addr < voodoo->cmdfifo_amax) + fatal("Out-of-order write really out of order\n"); +#endif voodoo->cmdfifo_amax = addr; voodoo->cmdfifo_holecount = ((voodoo->cmdfifo_amax - voodoo->cmdfifo_amin) >> 2) - 1; - // banshee_log("CMDFIFO out of order: amin=%08x amax=%08x holecount=%i\n", voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, voodoo->cmdfifo_holecount); +#if 0 + banshee_log("CMDFIFO out of order: amin=%08x amax=%08x holecount=%i\n", voodoo->cmdfifo_amin, voodoo->cmdfifo_amax, voodoo->cmdfifo_holecount); +#endif } } } @@ -1851,16 +1924,17 @@ void banshee_hwcursor_draw(svga_t *svga, int displine) { banshee_t *banshee = (banshee_t *) svga->p; - int x, c; + int x; int x_off; int xx; uint32_t col0 = banshee->hwCurC0; uint32_t col1 = banshee->hwCurC1; - uint8_t plane0[8], plane1[8]; + uint8_t plane0[8]; + uint8_t plane1[8]; - for (c = 0; c < 8; c++) + for (uint8_t c = 0; c < 8; c++) plane0[c] = svga->vram[svga->hwcursor_latch.addr + c]; - for (c = 0; c < 8; c++) + for (uint8_t c = 0; c < 8; c++) plane1[c] = svga->vram[svga->hwcursor_latch.addr + c + 8]; svga->hwcursor_latch.addr += 16; @@ -2054,10 +2128,14 @@ banshee_hwcursor_draw(svga_t *svga, int displine) void voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg) { - int g, h; - float difference, diffg; - float thiscol, thiscolg; - float clr, clg = 0; + int g; + int h; + float difference; + float diffg; + float thiscol; + float thiscolg; + float clr; + float clg = 0; float hack = 1.0f; // pre-clamping @@ -2129,8 +2207,8 @@ voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg) if (thiscolg > 255) thiscolg = 255; - vb_filter_bx_rb[g][h] = (thiscol); - vb_filter_bx_g[g][h] = (thiscolg); + vb_filter_bx_rb[g][h] = thiscol; + vb_filter_bx_g[g][h] = thiscolg; } float lined = g + 4; if (lined > 255) @@ -2145,8 +2223,10 @@ voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg) } /* 4x1 and 2x2 filter */ - // fcr *= 5; - // fcg *= 6; +#if 0 + fcr *= 5; + fcg *= 6; +#endif for (g = 0; g < 256; g++) // pixel 1 { @@ -2211,9 +2291,11 @@ banshee_overlay_draw(svga_t *svga, int displine) if ((voodoo->overlay.src_y >> 20) < 2048) voodoo->dirty_line[voodoo->overlay.src_y >> 20] = 0; - // pclog("displine=%i addr=%08x %08x %08x %08x\n", displine, svga->overlay_latch.addr, src_addr, voodoo->overlay.vidOverlayDvdy, *(uint32_t *)src); - // if (src_addr >= 0x800000) - // fatal("overlay out of range!\n"); +#if 0 + pclog("displine=%i addr=%08x %08x %08x %08x\n", displine, svga->overlay_latch.addr, src_addr, voodoo->overlay.vidOverlayDvdy, *(uint32_t *)src); + if (src_addr >= 0x800000) + fatal("overlay out of range!\n"); +#endif p = &((uint32_t *) svga->monitor->target_buffer->line[displine])[svga->overlay_latch.x + svga->x_add]; if (banshee->voodoo->scrfilter && banshee->voodoo->scrfilterEnabled) @@ -2271,9 +2353,9 @@ banshee_overlay_draw(svga_t *svga, int displine) if (banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE) /* leilei HACK - don't know of real 4x1 hscaled behavior yet, double for now */ { for (x = 0; x < svga->overlay_latch.cur_xsize; x++) { - fil[x * 3] = ((banshee->overlay_buffer[0][src_x >> 20])); - fil[x * 3 + 1] = ((banshee->overlay_buffer[0][src_x >> 20] >> 8)); - fil[x * 3 + 2] = ((banshee->overlay_buffer[0][src_x >> 20] >> 16)); + fil[x * 3] = (banshee->overlay_buffer[0][src_x >> 20]); + fil[x * 3 + 1] = (banshee->overlay_buffer[0][src_x >> 20] >> 8); + fil[x * 3 + 2] = (banshee->overlay_buffer[0][src_x >> 20] >> 16); fil3[x * 3 + 0] = fil[x * 3 + 0]; fil3[x * 3 + 1] = fil[x * 3 + 1]; fil3[x * 3 + 2] = fil[x * 3 + 2]; @@ -2281,9 +2363,9 @@ banshee_overlay_draw(svga_t *svga, int displine) } } else { for (x = 0; x < svga->overlay_latch.cur_xsize; x++) { - fil[x * 3] = ((banshee->overlay_buffer[0][x])); - fil[x * 3 + 1] = ((banshee->overlay_buffer[0][x] >> 8)); - fil[x * 3 + 2] = ((banshee->overlay_buffer[0][x] >> 16)); + fil[x * 3] = (banshee->overlay_buffer[0][x]); + fil[x * 3 + 1] = (banshee->overlay_buffer[0][x] >> 8); + fil[x * 3 + 2] = (banshee->overlay_buffer[0][x] >> 16); fil3[x * 3 + 0] = fil[x * 3 + 0]; fil3[x * 3 + 1] = fil[x * 3 + 1]; fil3[x * 3 + 2] = fil[x * 3 + 2]; @@ -2298,24 +2380,24 @@ banshee_overlay_draw(svga_t *svga, int displine) } for (x = 1; x < svga->overlay_latch.cur_xsize; x++) { - fil3[(x) *3] = vb_filter_v1_rb[fil[x * 3]][fil[(x - 1) * 3]]; - fil3[(x) *3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; - fil3[(x) *3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; + fil3[x * 3] = vb_filter_v1_rb[fil[x * 3]][fil[(x - 1) * 3]]; + fil3[x * 3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; + fil3[x * 3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; } for (x = 1; x < svga->overlay_latch.cur_xsize; x++) { - fil[(x) *3] = vb_filter_v1_rb[fil[x * 3]][fil3[(x - 1) * 3]]; - fil[(x) *3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil3[(x - 1) * 3 + 1]]; - fil[(x) *3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil3[(x - 1) * 3 + 2]]; + fil[x * 3] = vb_filter_v1_rb[fil[x * 3]][fil3[(x - 1) * 3]]; + fil[x * 3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil3[(x - 1) * 3 + 1]]; + fil[x * 3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil3[(x - 1) * 3 + 2]]; } for (x = 1; x < svga->overlay_latch.cur_xsize; x++) { - fil3[(x) *3] = vb_filter_v1_rb[fil[x * 3]][fil[(x - 1) * 3]]; - fil3[(x) *3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; - fil3[(x) *3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; + fil3[x * 3] = vb_filter_v1_rb[fil[x * 3]][fil[(x - 1) * 3]]; + fil3[x * 3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; + fil3[x * 3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; } for (x = 0; x < svga->overlay_latch.cur_xsize; x++) { - fil[(x) *3] = vb_filter_v1_rb[fil[x * 3]][fil3[(x + 1) * 3]]; - fil[(x) *3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil3[(x + 1) * 3 + 1]]; - fil[(x) *3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil3[(x + 1) * 3 + 2]]; + fil[x * 3] = vb_filter_v1_rb[fil[x * 3]][fil3[(x + 1) * 3]]; + fil[x * 3 + 1] = vb_filter_v1_g[fil[x * 3 + 1]][fil3[(x + 1) * 3 + 1]]; + fil[x * 3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil3[(x + 1) * 3 + 2]]; p[x] = (fil[x * 3 + 2] << 16) | (fil[x * 3 + 1] << 8) | fil[x * 3]; } } else /* filter disabled by emulator option */ @@ -2346,21 +2428,21 @@ banshee_overlay_draw(svga_t *svga, int displine) src = &svga->vram[src_addr2 & svga->vram_mask]; OVERLAY_SAMPLE(banshee->overlay_buffer[1]); for (x = 0; x < svga->overlay_latch.cur_xsize; x++) { - samp1[x * 3] = ((banshee->overlay_buffer[0][x])); - samp1[x * 3 + 1] = ((banshee->overlay_buffer[0][x] >> 8)); - samp1[x * 3 + 2] = ((banshee->overlay_buffer[0][x] >> 16)); + samp1[x * 3] = (banshee->overlay_buffer[0][x]); + samp1[x * 3 + 1] = (banshee->overlay_buffer[0][x] >> 8); + samp1[x * 3 + 2] = (banshee->overlay_buffer[0][x] >> 16); - samp2[x * 3 + 0] = ((banshee->overlay_buffer[0][x + 1])); - samp2[x * 3 + 1] = ((banshee->overlay_buffer[0][x + 1] >> 8)); - samp2[x * 3 + 2] = ((banshee->overlay_buffer[0][x + 1] >> 16)); + samp2[x * 3 + 0] = (banshee->overlay_buffer[0][x + 1]); + samp2[x * 3 + 1] = (banshee->overlay_buffer[0][x + 1] >> 8); + samp2[x * 3 + 2] = (banshee->overlay_buffer[0][x + 1] >> 16); - samp3[x * 3 + 0] = ((banshee->overlay_buffer[1][x])); - samp3[x * 3 + 1] = ((banshee->overlay_buffer[1][x] >> 8)); - samp3[x * 3 + 2] = ((banshee->overlay_buffer[1][x] >> 16)); + samp3[x * 3 + 0] = (banshee->overlay_buffer[1][x]); + samp3[x * 3 + 1] = (banshee->overlay_buffer[1][x] >> 8); + samp3[x * 3 + 2] = (banshee->overlay_buffer[1][x] >> 16); - samp4[x * 3 + 0] = ((banshee->overlay_buffer[1][x + 1])); - samp4[x * 3 + 1] = ((banshee->overlay_buffer[1][x + 1] >> 8)); - samp4[x * 3 + 2] = ((banshee->overlay_buffer[1][x + 1] >> 16)); + samp4[x * 3 + 0] = (banshee->overlay_buffer[1][x + 1]); + samp4[x * 3 + 1] = (banshee->overlay_buffer[1][x + 1] >> 8); + samp4[x * 3 + 2] = (banshee->overlay_buffer[1][x + 1] >> 16); /* sample two lines */ @@ -2662,7 +2744,9 @@ banshee_pci_read(int func, int addr, void *p) ret = banshee->pci_regs[0x67]; break; } - // banshee_log("%02X\n", ret); +#if 0 + banshee_log("%02X\n", ret); +#endif return ret; } @@ -2670,11 +2754,15 @@ static void banshee_pci_write(int func, int addr, uint8_t val, void *p) { banshee_t *banshee = (banshee_t *) p; - // svga_t *svga = &banshee->svga; +#if 0 + svga_t *svga = &banshee->svga; +#endif if (func) return; - // banshee_log("Banshee write %08X %02X %04X:%08X\n", addr, val, CS, cpu_state.pc); +#if 0 + banshee_log("Banshee write %08X %02X %04X:%08X\n", addr, val, CS, cpu_state.pc); +#endif switch (addr) { case 0x00: case 0x01: @@ -2935,7 +3023,9 @@ banshee_init_common(const device_t *info, char *fn, int has_sgram, int type, int } if (!banshee->has_bios) - // mem_size = info->local; /* fixed size for on-board chips */ +#if 0 + mem_size = info->local; /* fixed size for on-board chips */ +#endif mem_size = device_get_config_int("memory"); /* MS-6168 / Bora Pro can do both 8 and 16 MB. */ else if (has_sgram) { if (banshee->type == TYPE_VELOCITY100) @@ -2982,7 +3072,9 @@ banshee_init_common(const device_t *info, char *fn, int has_sgram, int type, int banshee->svga.vblank_start = banshee_vblank_start; - // io_sethandler(0x03c0, 0x0020, banshee_in, NULL, NULL, banshee_out, NULL, NULL, banshee); +#if 0 + io_sethandler(0x03c0, 0x0020, banshee_in, NULL, NULL, banshee_out, NULL, NULL, banshee); +#endif banshee->svga.bpp = 8; banshee->svga.miscout = 1; @@ -3305,7 +3397,7 @@ const device_t voodoo_banshee_device = { { .available = banshee_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sgram_config + .config = banshee_sgram_config }; const device_t creative_voodoo_banshee_device = { @@ -3319,7 +3411,7 @@ const device_t creative_voodoo_banshee_device = { { .available = creative_banshee_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_1000_device = { @@ -3333,7 +3425,7 @@ const device_t voodoo_3_1000_device = { { .available = v3_1000_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sgram_config + .config = banshee_sgram_config }; const device_t voodoo_3_1000_agp_device = { @@ -3347,7 +3439,7 @@ const device_t voodoo_3_1000_agp_device = { { .available = v3_1000_agp_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sgram_config + .config = banshee_sgram_config }; const device_t voodoo_3_2000_device = { @@ -3361,7 +3453,7 @@ const device_t voodoo_3_2000_device = { { .available = v3_2000_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_2000_agp_device = { @@ -3375,7 +3467,7 @@ const device_t voodoo_3_2000_agp_device = { { .available = v3_2000_agp_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_2000_agp_onboard_8m_device = { @@ -3389,7 +3481,7 @@ const device_t voodoo_3_2000_agp_onboard_8m_device = { { .available = NULL }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sgram_config + .config = banshee_sgram_config }; const device_t voodoo_3_3000_device = { @@ -3403,7 +3495,7 @@ const device_t voodoo_3_3000_device = { { .available = v3_3000_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_3000_agp_device = { @@ -3417,7 +3509,7 @@ const device_t voodoo_3_3000_agp_device = { { .available = v3_3000_agp_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_3500_agp_ntsc_device = { @@ -3431,7 +3523,7 @@ const device_t voodoo_3_3500_agp_ntsc_device = { { .available = v3_3500_agp_ntsc_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_3500_agp_pal_device = { @@ -3445,7 +3537,7 @@ const device_t voodoo_3_3500_agp_pal_device = { { .available = v3_3500_agp_pal_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t compaq_voodoo_3_3500_agp_device = { @@ -3459,7 +3551,7 @@ const device_t compaq_voodoo_3_3500_agp_device = { { .available = compaq_v3_3500_agp_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_3500_se_agp_device = { @@ -3473,7 +3565,7 @@ const device_t voodoo_3_3500_se_agp_device = { { .available = v3_3500_se_agp_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t voodoo_3_3500_si_agp_device = { @@ -3487,7 +3579,7 @@ const device_t voodoo_3_3500_si_agp_device = { { .available = v3_3500_si_agp_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t velocity_100_agp_device = { @@ -3501,7 +3593,7 @@ const device_t velocity_100_agp_device = { { .available = velocity_100_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sdram_config + .config = banshee_sdram_config }; const device_t velocity_200_agp_device = { @@ -3515,5 +3607,5 @@ const device_t velocity_200_agp_device = { { .available = velocity_200_available }, .speed_changed = banshee_speed_changed, .force_redraw = banshee_force_redraw, - banshee_sgram_config + .config = banshee_sgram_config }; diff --git a/src/video/vid_voodoo_banshee_blitter.c b/src/video/vid_voodoo_banshee_blitter.c index 98f439d79..175288856 100644 --- a/src/video/vid_voodoo_banshee_blitter.c +++ b/src/video/vid_voodoo_banshee_blitter.c @@ -127,18 +127,30 @@ colorkey(voodoo_t *voodoo, uint32_t src, int src_notdst, int color_format) case COLORKEY_16: { - int r = (src >> 11) & 0x1f, r_min = (min >> 11) & 0x1f, r_max = (max >> 11) & 0x1f; - int g = (src >> 5) & 0x3f, g_min = (min >> 5) & 0x3f, g_max = (max >> 5) & 0x3f; - int b = src & 0x1f, b_min = min & 0x1f, b_max = max & 0x1f; + int r = (src >> 11) & 0x1f; + int r_min = (min >> 11) & 0x1f; + int r_max = (max >> 11) & 0x1f; + int g = (src >> 5) & 0x3f; + int g_min = (min >> 5) & 0x3f; + int g_max = (max >> 5) & 0x3f; + int b = src & 0x1f; + int b_min = min & 0x1f; + int b_max = max & 0x1f; return (r >= r_min) && (r <= r_max) && (g >= g_min) && (g <= g_max) && (b >= b_min) && (b <= b_max); } case COLORKEY_32: { - int r = (src >> 16) & 0xff, r_min = (min >> 16) & 0xff, r_max = (max >> 16) & 0xff; - int g = (src >> 8) & 0xff, g_min = (min >> 8) & 0xff, g_max = (max >> 8) & 0xff; - int b = src & 0xff, b_min = min & 0xff, b_max = max & 0xff; + int r = (src >> 16) & 0xff; + int r_min = (min >> 16) & 0xff; + int r_max = (max >> 16) & 0xff; + int g = (src >> 8) & 0xff; + int g_min = (min >> 8) & 0xff; + int g_max = (max >> 8) & 0xff; + int b = src & 0xff; + int b_min = min & 0xff; + int b_max = max & 0xff; return (r >= r_min) && (r <= r_max) && (g >= g_min) && (g <= g_max) && (b >= b_min) && (b <= b_max); } @@ -318,7 +330,9 @@ update_src_stride(voodoo_t *voodoo) voodoo->banshee_blt.src_stride_dest = voodoo->banshee_blt.src_stride; // voodoo->banshee_blt.srcFormat & SRC_FORMAT_STRIDE_MASK; voodoo->banshee_blt.host_data_size_src = (voodoo->banshee_blt.srcSizeX * bpp + 7) >> 3; voodoo->banshee_blt.host_data_size_dest = (voodoo->banshee_blt.dstSizeX * bpp + 7) >> 3; - // bansheeblt_log("Stride packing %08x %08x bpp=%i dstSizeX=%i\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest, bpp, voodoo->banshee_blt.dstSizeX); +#if 0 + bansheeblt_log("Stride packing %08x %08x bpp=%i dstSizeX=%i\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest, bpp, voodoo->banshee_blt.dstSizeX); +#endif break; case SRC_FORMAT_PACKING_BYTE: @@ -326,7 +340,9 @@ update_src_stride(voodoo_t *voodoo) voodoo->banshee_blt.src_stride_dest = (voodoo->banshee_blt.dstSizeX * bpp + 7) >> 3; voodoo->banshee_blt.host_data_size_src = voodoo->banshee_blt.src_stride_src; voodoo->banshee_blt.host_data_size_dest = voodoo->banshee_blt.src_stride_dest; - // bansheeblt_log("Byte packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#if 0 + bansheeblt_log("Byte packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#endif break; case SRC_FORMAT_PACKING_WORD: @@ -334,7 +350,9 @@ update_src_stride(voodoo_t *voodoo) voodoo->banshee_blt.src_stride_dest = ((voodoo->banshee_blt.dstSizeX * bpp + 15) >> 4) * 2; voodoo->banshee_blt.host_data_size_src = voodoo->banshee_blt.src_stride_src; voodoo->banshee_blt.host_data_size_dest = voodoo->banshee_blt.src_stride_dest; - // bansheeblt_log("Word packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#if 0 + bansheeblt_log("Word packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#endif break; case SRC_FORMAT_PACKING_DWORD: @@ -342,7 +360,9 @@ update_src_stride(voodoo_t *voodoo) voodoo->banshee_blt.src_stride_dest = ((voodoo->banshee_blt.dstSizeX * bpp + 31) >> 5) * 4; voodoo->banshee_blt.host_data_size_src = voodoo->banshee_blt.src_stride_src; voodoo->banshee_blt.host_data_size_dest = voodoo->banshee_blt.src_stride_dest; - // bansheeblt_log("Dword packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#if 0 + bansheeblt_log("Dword packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#endif break; } } @@ -372,9 +392,11 @@ banshee_do_rectfill(voodoo_t *voodoo) int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO); uint8_t rop = voodoo->banshee_blt.command >> 24; - // bansheeblt_log("banshee_do_rectfill: size=%i,%i dst=%i,%i\n", voodoo->banshee_blt.dstSizeX, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.dstX, voodoo->banshee_blt.dstY); - // bansheeblt_log("clipping: %i,%i -> %i,%i\n", clip->x_min, clip->y_min, clip->x_max, clip->y_max); - // bansheeblt_log("colorFore=%08x\n", voodoo->banshee_blt.colorFore); +#if 0 + bansheeblt_log("banshee_do_rectfill: size=%i,%i dst=%i,%i\n", voodoo->banshee_blt.dstSizeX, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.dstX, voodoo->banshee_blt.dstY); + bansheeblt_log("clipping: %i,%i -> %i,%i\n", clip->x_min, clip->y_min, clip->x_max, clip->y_max); + bansheeblt_log("colorFore=%08x\n", voodoo->banshee_blt.colorFore); +#endif for (voodoo->banshee_blt.cur_y = 0; voodoo->banshee_blt.cur_y < voodoo->banshee_blt.dstSizeY; voodoo->banshee_blt.cur_y++) { int dst_x = voodoo->banshee_blt.dstX; @@ -406,10 +428,16 @@ DECODE_YUYV422(uint32_t *buf, uint8_t *src) do { int wp = 0; - uint8_t y1, y2; - int8_t Cr, Cb; - int dR, dG, dB; - int r, g, b; + uint8_t y1; + uint8_t y2; + int8_t Cr; + int8_t Cb; + int dR; + int dG; + int dB; + int r; + int g; + int b; y1 = src[0]; Cr = src[1] - 0x80; @@ -444,10 +472,16 @@ DECODE_YUYV422_16BPP(uint16_t *buf, uint8_t *src) do { int wp = 0; - uint8_t y1, y2; - int8_t Cr, Cb; - int dR, dG, dB; - int r, g, b; + uint8_t y1; + uint8_t y2; + int8_t Cr; + int8_t Cb; + int dR; + int dG; + int dB; + int r; + int g; + int b; y1 = src[0]; Cr = src[1] - 0x80; @@ -504,7 +538,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr src_colorkey = COLORKEY_32; break; } - // bansheeblt_log("do_screen_to_screen_line: srcFormat=%08x dst=%08x\n", voodoo->banshee_blt.srcFormat, voodoo->banshee_blt.dstFormat); +#if 0 + bansheeblt_log("do_screen_to_screen_line: srcFormat=%08x dst=%08x\n", voodoo->banshee_blt.srcFormat, voodoo->banshee_blt.dstFormat); +#endif if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == (voodoo->banshee_blt.dstFormat & DST_FORMAT_COL_MASK)) { /*No conversion required*/ if (dst_y >= clip->y_min && dst_y < clip->y_max) { @@ -607,7 +643,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr src_data = (src_byte & (0x80 >> (src_x & 7))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack; if (voodoo->banshee_blt.command & COMMAND_TRANS_MONO) transparent = !(src_byte & (0x80 >> (src_x & 7))); - // bansheeblt_log(" 1bpp src_byte=%02x src_x=%i src_data=%x transparent=%i\n", src_byte, src_x, src_data, transparent); +#if 0 + bansheeblt_log(" 1bpp src_byte=%02x src_x=%i src_data=%x transparent=%i\n", src_byte, src_x, src_data, transparent); +#endif break; } case SRC_FORMAT_COL_8_BPP: @@ -723,12 +761,16 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr static void banshee_do_screen_to_screen_blt(voodoo_t *voodoo) { - // bansheeblt_log("screen_to_screen: %08x %08x %08x\n", voodoo->banshee_blt.srcFormat, voodoo->banshee_blt.src_stride, voodoo->banshee_blt.src_stride_dest); - // return; +#if 0 + bansheeblt_log("screen_to_screen: %08x %08x %08x\n", voodoo->banshee_blt.srcFormat, voodoo->banshee_blt.src_stride, voodoo->banshee_blt.src_stride_dest); + return; +#endif for (voodoo->banshee_blt.cur_y = 0; voodoo->banshee_blt.cur_y < voodoo->banshee_blt.dstSizeY; voodoo->banshee_blt.cur_y++) { uint32_t src_addr = get_addr(voodoo, 0, voodoo->banshee_blt.srcY, 1, voodoo->banshee_blt.src_stride_dest); - // if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == SRC_FORMAT_COL_1_BPP) - // bansheeblt_log(" srcY=%i src_addr=%08x\n", voodoo->banshee_blt.srcY, src_addr); +#if 0 + if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == SRC_FORMAT_COL_1_BPP) + bansheeblt_log(" srcY=%i src_addr=%08x\n", voodoo->banshee_blt.srcY, src_addr); +#endif do_screen_to_screen_line(voodoo, &voodoo->vram[src_addr], 1, voodoo->banshee_blt.srcX, voodoo->banshee_blt.srcBaseAddr_tiled); } end_command(voodoo); @@ -737,8 +779,10 @@ banshee_do_screen_to_screen_blt(voodoo_t *voodoo) static void banshee_do_host_to_screen_blt(voodoo_t *voodoo, int count, uint32_t data) { - // if (voodoo->banshee_blt.dstBaseAddr == 0xee5194) - // bansheeblt_log("banshee_do_host_to_screen_blt: data=%08x host_data_count=%i src_stride_dest=%i host_data_size_dest=%i\n", data, voodoo->banshee_blt.host_data_count, voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#if 0 + if (voodoo->banshee_blt.dstBaseAddr == 0xee5194) + bansheeblt_log("banshee_do_host_to_screen_blt: data=%08x host_data_count=%i src_stride_dest=%i host_data_size_dest=%i\n", data, voodoo->banshee_blt.host_data_count, voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#endif if (voodoo->banshee_blt.srcFormat & SRC_FORMAT_BYTE_SWIZZLE) data = (data >> 24) | ((data >> 8) & 0xff00) | ((data << 8) & 0xff0000) | (data << 24); @@ -756,7 +800,9 @@ banshee_do_host_to_screen_blt(voodoo_t *voodoo, int count, uint32_t data) *(uint32_t *) &voodoo->banshee_blt.host_data[voodoo->banshee_blt.host_data_count] = data; voodoo->banshee_blt.host_data_count += 4; if (voodoo->banshee_blt.host_data_count >= last_byte) { - // bansheeblt_log(" %i %i srcX=%i srcFormat=%08x\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.srcX); +#if 0 + bansheeblt_log(" %i %i srcX=%i srcFormat=%08x\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.srcX); +#endif if (voodoo->banshee_blt.cur_y < voodoo->banshee_blt.dstSizeY) { if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == SRC_FORMAT_COL_1_BPP) do_screen_to_screen_line(voodoo, &voodoo->banshee_blt.host_data[(voodoo->banshee_blt.srcX >> 3) & 3], 0, voodoo->banshee_blt.srcX & 7, 0); @@ -780,7 +826,9 @@ banshee_do_host_to_screen_blt(voodoo_t *voodoo, int count, uint32_t data) while (voodoo->banshee_blt.host_data_count >= voodoo->banshee_blt.src_stride_dest) { voodoo->banshee_blt.host_data_count -= voodoo->banshee_blt.src_stride_dest; - // bansheeblt_log(" %i %i\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY); +#if 0 + bansheeblt_log(" %i %i\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY); +#endif if (voodoo->banshee_blt.cur_y < voodoo->banshee_blt.dstSizeY) { do_screen_to_screen_line(voodoo, voodoo->banshee_blt.host_data, 0, 0, 0); voodoo->banshee_blt.cur_y++; @@ -789,7 +837,9 @@ banshee_do_host_to_screen_blt(voodoo_t *voodoo, int count, uint32_t data) } if (voodoo->banshee_blt.host_data_count) { - // bansheeblt_log(" remaining=%i\n", voodoo->banshee_blt.host_data_count); +#if 0 + bansheeblt_log(" remaining=%i\n", voodoo->banshee_blt.host_data_count); +#endif *(uint32_t *) &voodoo->banshee_blt.host_data[0] = data >> (4 - voodoo->banshee_blt.host_data_count) * 8; } } @@ -800,26 +850,34 @@ static void do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, int *src_y) { clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0]; - // int src_y = voodoo->banshee_blt.srcY; +#if 0 + int src_y = voodoo->banshee_blt.srcY; +#endif int dst_y = voodoo->banshee_blt.dstY; int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + voodoo->banshee_blt.dstY); uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern; int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO); uint32_t *colorPattern = voodoo->banshee_blt.colorPattern; - // int error_y = voodoo->banshee_blt.dstSizeY / 2; +#if 0 + int error_y = voodoo->banshee_blt.dstSizeY / 2; - /* bansheeblt_log("banshee_do_screen_to_screen_stretch_blt:\n"); - bansheeblt_log(" srcXY=%i,%i srcsizeXY=%i,%i\n", voodoo->banshee_blt.srcX, voodoo->banshee_blt.srcY, voodoo->banshee_blt.srcSizeX, voodoo->banshee_blt.srcSizeY); - bansheeblt_log(" dstXY=%i,%i dstsizeXY=%i,%i\n", voodoo->banshee_blt.dstX, voodoo->banshee_blt.dstY, voodoo->banshee_blt.dstSizeX, voodoo->banshee_blt.dstSizeY);*/ + bansheeblt_log("banshee_do_screen_to_screen_stretch_blt:\n"); + bansheeblt_log(" srcXY=%i,%i srcsizeXY=%i,%i\n", voodoo->banshee_blt.srcX, voodoo->banshee_blt.srcY, voodoo->banshee_blt.srcSizeX, voodoo->banshee_blt.srcSizeY); + bansheeblt_log(" dstXY=%i,%i dstsizeXY=%i,%i\n", voodoo->banshee_blt.dstX, voodoo->banshee_blt.dstY, voodoo->banshee_blt.dstSizeX, voodoo->banshee_blt.dstSizeY);*/ +#endif if (dst_y >= clip->y_min && dst_y < clip->y_max) { - // int src_x = voodoo->banshee_blt.srcX; +#if 0 + int src_x = voodoo->banshee_blt.srcX; +#endif int dst_x = voodoo->banshee_blt.dstX; int pat_x = voodoo->banshee_blt.patoff_x + voodoo->banshee_blt.dstX; uint8_t pattern_mask = pattern_mono[pat_y & 7]; int error_x = voodoo->banshee_blt.dstSizeX / 2; - // bansheeblt_log(" Plot dest line %03i : src line %03i\n", dst_y, src_y); +#if 0 + bansheeblt_log(" Plot dest line %03i : src line %03i\n", dst_y, src_y); +#endif for (voodoo->banshee_blt.cur_x = 0; voodoo->banshee_blt.cur_x < voodoo->banshee_blt.dstSizeX; voodoo->banshee_blt.cur_x++) { int pattern_trans = use_pattern_trans ? (pattern_mask & (1 << (7 - (pat_x & 7)))) : 1; @@ -845,7 +903,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; *(uint16_t *) &voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_16, COLORKEY_16); - // bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, *(uint16_t *)&voodoo->vram[dst_addr]); +#if 0 + bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, *(uint16_t *)&voodoo->vram[dst_addr]); +#endif voodoo->changedvram[dst_addr >> 12] = changeframecount; break; } @@ -857,7 +917,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; *(uint32_t *) &voodoo->vram[dst_addr] = (MIX(voodoo, dest, src, pattern, COLORKEY_32, COLORKEY_32) & 0xffffff) | (*(uint32_t *) &voodoo->vram[dst_addr] & 0xff000000); - // bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); +#if 0 + bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); +#endif voodoo->changedvram[dst_addr >> 12] = changeframecount; break; } @@ -869,7 +931,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; *(uint32_t *) &voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_32, COLORKEY_32); - // bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); +#if 0 + bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); +#endif voodoo->changedvram[dst_addr >> 12] = changeframecount; break; } @@ -893,19 +957,27 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in (*src_y) += (voodoo->banshee_blt.command & COMMAND_DY) ? -1 : 1; } voodoo->banshee_blt.dstY += (voodoo->banshee_blt.command & COMMAND_DY) ? -1 : 1; - // pat_y += (voodoo->banshee_blt.command & COMMAND_DY) ? -1 : 1; +#if 0 + pat_y += (voodoo->banshee_blt.command & COMMAND_DY) ? -1 : 1; +#endif + } static void banshee_do_screen_to_screen_stretch_blt(voodoo_t *voodoo) { - // bansheeblt_log("screen_to_screen: %08x %08x %08x\n", voodoo->banshee_blt.srcFormat, voodoo->banshee_blt.src_stride, voodoo->banshee_blt.src_stride_dest); - // return; +#if 0 + bansheeblt_log("screen_to_screen: %08x %08x %08x\n", voodoo->banshee_blt.srcFormat, voodoo->banshee_blt.src_stride, voodoo->banshee_blt.src_stride_dest); + return; +#endif for (voodoo->banshee_blt.cur_y = 0; voodoo->banshee_blt.cur_y < voodoo->banshee_blt.dstSizeY; voodoo->banshee_blt.cur_y++) { uint32_t src_addr = get_addr(voodoo, 0, voodoo->banshee_blt.srcY, 1, voodoo->banshee_blt.src_stride_src); //(voodoo->banshee_blt.srcBaseAddr + voodoo->banshee_blt.srcY*voodoo->banshee_blt.src_stride_src) & voodoo->fb_mask; - // bansheeblt_log("scale_blit %i %08x %08x\n", voodoo->banshee_blt.cur_y, src_addr, voodoo->banshee_blt.command); - // if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == SRC_FORMAT_COL_1_BPP) - // bansheeblt_log(" srcY=%i src_addr=%08x\n", voodoo->banshee_blt.srcY, src_addr); +#if 0 + + bansheeblt_log("scale_blit %i %08x %08x\n", voodoo->banshee_blt.cur_y, src_addr, voodoo->banshee_blt.command); + if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == SRC_FORMAT_COL_1_BPP) + bansheeblt_log(" srcY=%i src_addr=%08x\n", voodoo->banshee_blt.srcY, src_addr); +#endif do_screen_to_screen_stretch_line(voodoo, &voodoo->vram[src_addr], voodoo->banshee_blt.srcX, &voodoo->banshee_blt.srcY); } end_command(voodoo); @@ -914,9 +986,10 @@ banshee_do_screen_to_screen_stretch_blt(voodoo_t *voodoo) static void banshee_do_host_to_screen_stretch_blt(voodoo_t *voodoo, int count, uint32_t data) { - // if (voodoo->banshee_blt.dstBaseAddr == 0xee5194) - // bansheeblt_log("banshee_do_host_to_screen_blt: data=%08x host_data_count=%i src_stride_dest=%i host_data_size_dest=%i\n", data, voodoo->banshee_blt.host_data_count, voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); - +#if 0 + if (voodoo->banshee_blt.dstBaseAddr == 0xee5194) + bansheeblt_log("banshee_do_host_to_screen_blt: data=%08x host_data_count=%i src_stride_dest=%i host_data_size_dest=%i\n", data, voodoo->banshee_blt.host_data_count, voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); +#endif if (voodoo->banshee_blt.srcFormat & SRC_FORMAT_BYTE_SWIZZLE) data = (data >> 24) | ((data >> 8) & 0xff00) | ((data << 8) & 0xff0000) | (data << 24); if (voodoo->banshee_blt.srcFormat & SRC_FORMAT_WORD_SWIZZLE) @@ -928,7 +1001,9 @@ banshee_do_host_to_screen_stretch_blt(voodoo_t *voodoo, int count, uint32_t data *(uint32_t *) &voodoo->banshee_blt.host_data[voodoo->banshee_blt.host_data_count] = data; voodoo->banshee_blt.host_data_count += 4; if (voodoo->banshee_blt.host_data_count >= last_byte) { - // bansheeblt_log(" %i %i srcX=%i srcFormat=%08x\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.srcX); +#if 0 + bansheeblt_log(" %i %i srcX=%i srcFormat=%08x\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.srcX); +#endif if (voodoo->banshee_blt.cur_y < voodoo->banshee_blt.dstSizeY) { if ((voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) == SRC_FORMAT_COL_1_BPP) do_screen_to_screen_stretch_line(voodoo, &voodoo->banshee_blt.host_data[(voodoo->banshee_blt.srcX >> 3) & 3], voodoo->banshee_blt.srcX & 7, NULL); @@ -952,7 +1027,9 @@ banshee_do_host_to_screen_stretch_blt(voodoo_t *voodoo, int count, uint32_t data while (voodoo->banshee_blt.host_data_count >= voodoo->banshee_blt.src_stride_src) { voodoo->banshee_blt.host_data_count -= voodoo->banshee_blt.src_stride_src; - // bansheeblt_log(" %i %i\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY); +#if 0 + bansheeblt_log(" %i %i\n", voodoo->banshee_blt.cur_y, voodoo->banshee_blt.dstSizeY); +#endif if (voodoo->banshee_blt.cur_y < voodoo->banshee_blt.dstSizeY) { do_screen_to_screen_stretch_line(voodoo, voodoo->banshee_blt.host_data, 0, NULL); voodoo->banshee_blt.cur_y++; @@ -961,7 +1038,9 @@ banshee_do_host_to_screen_stretch_blt(voodoo_t *voodoo, int count, uint32_t data } if (voodoo->banshee_blt.host_data_count) { - // bansheeblt_log(" remaining=%i\n", voodoo->banshee_blt.host_data_count); +#if 0 + bansheeblt_log(" remaining=%i\n", voodoo->banshee_blt.host_data_count); +#endif *(uint32_t *) &voodoo->banshee_blt.host_data[0] = data >> (4 - voodoo->banshee_blt.host_data_count) * 8; } } @@ -1071,8 +1150,9 @@ banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data) int y = MAX(voodoo->banshee_blt.ly[0], voodoo->banshee_blt.ry[0]); int y_end; - // bansheeblt_log("Polyfill : data %08x\n", data); - +#if 0 + bansheeblt_log("Polyfill : data %08x\n", data); +#endif /*if r1.y>=l1.y, next vertex is left*/ if (voodoo->banshee_blt.ry[1] >= voodoo->banshee_blt.ly[1]) { voodoo->banshee_blt.lx[1] = ((int32_t) (data << 19)) >> 19; @@ -1090,21 +1170,26 @@ banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data) voodoo->banshee_blt.error[1] = voodoo->banshee_blt.dy[1] / 2; } - /* bansheeblt_log(" verts now : %03i,%03i %03i,%03i\n", voodoo->banshee_blt.lx[0], voodoo->banshee_blt.ly[0], voodoo->banshee_blt.rx[0], voodoo->banshee_blt.ry[0]); - bansheeblt_log(" %03i,%03i %03i,%03i\n", voodoo->banshee_blt.lx[1], voodoo->banshee_blt.ly[1], voodoo->banshee_blt.rx[1], voodoo->banshee_blt.ry[1]); - bansheeblt_log(" left dx=%i dy=%i x_inc=%i error=%i\n", voodoo->banshee_blt.dx[0],voodoo->banshee_blt.dy[0],voodoo->banshee_blt.x_inc[0],voodoo->banshee_blt.error[0]); - bansheeblt_log(" right dx=%i dy=%i x_inc=%i error=%i\n", voodoo->banshee_blt.dx[1],voodoo->banshee_blt.dy[1],voodoo->banshee_blt.x_inc[1],voodoo->banshee_blt.error[1]);*/ +#if 0 + bansheeblt_log(" verts now : %03i,%03i %03i,%03i\n", voodoo->banshee_blt.lx[0], voodoo->banshee_blt.ly[0], voodoo->banshee_blt.rx[0], voodoo->banshee_blt.ry[0]); + bansheeblt_log(" %03i,%03i %03i,%03i\n", voodoo->banshee_blt.lx[1], voodoo->banshee_blt.ly[1], voodoo->banshee_blt.rx[1], voodoo->banshee_blt.ry[1]); + bansheeblt_log(" left dx=%i dy=%i x_inc=%i error=%i\n", voodoo->banshee_blt.dx[0],voodoo->banshee_blt.dy[0],voodoo->banshee_blt.x_inc[0],voodoo->banshee_blt.error[0]); + bansheeblt_log(" right dx=%i dy=%i x_inc=%i error=%i\n", voodoo->banshee_blt.dx[1],voodoo->banshee_blt.dy[1],voodoo->banshee_blt.x_inc[1],voodoo->banshee_blt.error[1]); +#endif y_end = MIN(voodoo->banshee_blt.ly[1], voodoo->banshee_blt.ry[1]); - // bansheeblt_log("Polyfill : draw spans from %i-%i\n", y, y_end); +#if 0 + bansheeblt_log("Polyfill : draw spans from %i-%i\n", y, y_end); +#endif for (; y < y_end; y++) { - // bansheeblt_log(" %i: %i %i\n", y, voodoo->banshee_blt.lx_cur, voodoo->banshee_blt.rx_cur); +#if 0 + bansheeblt_log(" %i: %i %i\n", y, voodoo->banshee_blt.lx_cur, voodoo->banshee_blt.rx_cur); +#endif /*Draw span from lx_cur to rx_cur*/ if (y >= clip->y_min && y < clip->y_max) { int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + y); uint8_t pattern_mask = pattern_mono[pat_y & 7]; - int x; - for (x = voodoo->banshee_blt.lx_cur; x < voodoo->banshee_blt.rx_cur; x++) { + for (int x = voodoo->banshee_blt.lx_cur; x < voodoo->banshee_blt.rx_cur; x++) { int pat_x = voodoo->banshee_blt.patoff_x + x; int pattern_trans = use_pattern_trans ? (pattern_mask & (1 << (7 - (pat_x & 7)))) : 1; @@ -1182,7 +1267,11 @@ banshee_do_2d_blit(voodoo_t *voodoo, int count, uint32_t data) void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) { - // /*if ((addr & 0x1fc) != 0x80) */bansheeblt_log("2D reg write %03x %08x\n", addr & 0x1fc, val); +#if 0 + if ((addr & 0x1fc) != 0x80) + bansheeblt_log("2D reg write %03x %08x\n", addr & 0x1fc, val); +#endif + switch (addr & 0x1fc) { case 0x08: voodoo->banshee_blt.clip0Min = val; @@ -1201,7 +1290,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.dst_stride = (voodoo->banshee_blt.dstFormat & DST_FORMAT_STRIDE_MASK) * 128 * 32; else voodoo->banshee_blt.dst_stride = voodoo->banshee_blt.dstFormat & DST_FORMAT_STRIDE_MASK; - // bansheeblt_log("dstBaseAddr=%08x\n", val); +#if 0 + bansheeblt_log("dstBaseAddr=%08x\n", val); +#endif break; case 0x14: voodoo->banshee_blt.dstFormat = val; @@ -1209,7 +1300,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.dst_stride = (voodoo->banshee_blt.dstFormat & DST_FORMAT_STRIDE_MASK) * 128 * 32; else voodoo->banshee_blt.dst_stride = voodoo->banshee_blt.dstFormat & DST_FORMAT_STRIDE_MASK; - // bansheeblt_log("dstFormat=%08x\n", val); +#if 0 + bansheeblt_log("dstFormat=%08x\n", val); +#endif break; case 0x18: @@ -1239,7 +1332,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.rops[1] = val & 0xff; voodoo->banshee_blt.rops[2] = (val >> 8) & 0xff; voodoo->banshee_blt.rops[3] = (val >> 16) & 0xff; - // bansheeblt_log("rop=%08x\n", val); +#if 0 + bansheeblt_log("rop=%08x\n", val); +#endif break; case 0x34: voodoo->banshee_blt.srcBaseAddr = val & 0xffffff; @@ -1249,11 +1344,15 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) else voodoo->banshee_blt.src_stride = voodoo->banshee_blt.srcFormat & SRC_FORMAT_STRIDE_MASK; update_src_stride(voodoo); - // bansheeblt_log("srcBaseAddr=%08x\n", val); +#if 0 + bansheeblt_log("srcBaseAddr=%08x\n", val); +#endif break; case 0x38: voodoo->banshee_blt.commandExtra = val; - // bansheeblt_log("commandExtra=%08x\n", val); +#if 0 + bansheeblt_log("commandExtra=%08x\n", val); +#endif break; case 0x3c: voodoo->banshee_blt.lineStipple = val; @@ -1267,7 +1366,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) break; case 0x44: voodoo->banshee_blt.colorPattern[0] = val; - // bansheeblt_log("colorPattern0=%08x\n", val); +#if 0 + bansheeblt_log("colorPattern0=%08x\n", val); +#endif voodoo->banshee_blt.colorPattern24[0] = val & 0xffffff; voodoo->banshee_blt.colorPattern24[1] = (voodoo->banshee_blt.colorPattern24[1] & 0xffff00) | (val >> 24); voodoo->banshee_blt.colorPattern16[0] = val & 0xffff; @@ -1279,7 +1380,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) break; case 0x48: voodoo->banshee_blt.colorPattern[1] = val; - // bansheeblt_log("colorPattern1=%08x\n", val); +#if 0 + bansheeblt_log("colorPattern1=%08x\n", val); +#endif voodoo->banshee_blt.colorPattern24[1] = (voodoo->banshee_blt.colorPattern24[1] & 0xff) | ((val & 0xffff) << 8); voodoo->banshee_blt.colorPattern24[2] = (voodoo->banshee_blt.colorPattern24[2] & 0xff0000) | (val >> 16); voodoo->banshee_blt.colorPattern16[2] = val & 0xffff; @@ -1325,21 +1428,27 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.src_bpp = 16; break; } - // bansheeblt_log("srcFormat=%08x\n", val); +#if 0 + bansheeblt_log("srcFormat=%08x\n", val); +#endif break; case 0x58: voodoo->banshee_blt.srcSize = val; voodoo->banshee_blt.srcSizeX = voodoo->banshee_blt.srcSize & 0x1fff; voodoo->banshee_blt.srcSizeY = (voodoo->banshee_blt.srcSize >> 16) & 0x1fff; update_src_stride(voodoo); - // bansheeblt_log("srcSize=%08x\n", val); +#if 0 + bansheeblt_log("srcSize=%08x\n", val); +#endif break; case 0x5c: voodoo->banshee_blt.srcXY = val; voodoo->banshee_blt.srcX = ((int32_t) (val << 19)) >> 19; voodoo->banshee_blt.srcY = ((int32_t) (val << 3)) >> 19; update_src_stride(voodoo); - // bansheeblt_log("srcXY=%08x\n", val); +#if 0 + bansheeblt_log("srcXY=%08x\n", val); +#endif break; case 0x60: voodoo->banshee_blt.colorBack = val; @@ -1352,19 +1461,25 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.dstSizeX = voodoo->banshee_blt.dstSize & 0x1fff; voodoo->banshee_blt.dstSizeY = (voodoo->banshee_blt.dstSize >> 16) & 0x1fff; update_src_stride(voodoo); - // bansheeblt_log("dstSize=%08x\n", val); +#if 0 + bansheeblt_log("dstSize=%08x\n", val); +#endif break; case 0x6c: voodoo->banshee_blt.dstXY = val; voodoo->banshee_blt.dstX = ((int32_t) (val << 19)) >> 19; voodoo->banshee_blt.dstY = ((int32_t) (val << 3)) >> 19; - // bansheeblt_log("dstXY=%08x\n", val); +#if 0 + bansheeblt_log("dstXY=%08x\n", val); +#endif break; case 0x70: voodoo_wait_for_render_thread_idle(voodoo); voodoo->banshee_blt.command = val; voodoo->banshee_blt.rops[0] = val >> 24; - // bansheeblt_log("command=%x %08x\n", voodoo->banshee_blt.command & COMMAND_CMD_MASK, val); +#if 0 + bansheeblt_log("command=%x %08x\n", voodoo->banshee_blt.command & COMMAND_CMD_MASK, val); +#endif voodoo->banshee_blt.patoff_x = (val & COMMAND_PATOFF_X_MASK) >> COMMAND_PATOFF_X_SHIFT; voodoo->banshee_blt.patoff_y = (val & COMMAND_PATOFF_Y_MASK) >> COMMAND_PATOFF_Y_SHIFT; voodoo->banshee_blt.cur_x = 0; @@ -1377,19 +1492,22 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.host_data_remainder = 0; voodoo->banshee_blt.host_data_count = 0; switch (voodoo->banshee_blt.command & COMMAND_CMD_MASK) { - /* case COMMAND_CMD_SCREEN_TO_SCREEN_STRETCH_BLT: - if (voodoo->banshee_blt.bresError0 & BRES_ERROR_USE) - voodoo->banshee_blt.bres_error_0 = (int32_t)(int16_t)(voodoo->banshee_blt.bresError0 & BRES_ERROR_MASK); - else - voodoo->banshee_blt.bres_error_0 = voodoo->banshee_blt.dstSizeY / 2; - if (voodoo->banshee_blt.bresError1 & BRES_ERROR_USE) - voodoo->banshee_blt.bres_error_1 = (int32_t)(int16_t)(voodoo->banshee_blt.bresError1 & BRES_ERROR_MASK); - else - voodoo->banshee_blt.bres_error_1 = voodoo->banshee_blt.dstSizeX / 2; - if (val & COMMAND_INITIATE) - banshee_do_2d_blit(voodoo, -1, 0); - break;*/ +#if 0 + case COMMAND_CMD_SCREEN_TO_SCREEN_STRETCH_BLT: + if (voodoo->banshee_blt.bresError0 & BRES_ERROR_USE) + voodoo->banshee_blt.bres_error_0 = (int32_t)(int16_t)(voodoo->banshee_blt.bresError0 & BRES_ERROR_MASK); + else + voodoo->banshee_blt.bres_error_0 = voodoo->banshee_blt.dstSizeY / 2; + if (voodoo->banshee_blt.bresError1 & BRES_ERROR_USE) + voodoo->banshee_blt.bres_error_1 = (int32_t)(int16_t)(voodoo->banshee_blt.bresError1 & BRES_ERROR_MASK); + else + voodoo->banshee_blt.bres_error_1 = voodoo->banshee_blt.dstSizeX / 2; + + if (val & COMMAND_INITIATE) + banshee_do_2d_blit(voodoo, -1, 0); + break;*/ +#endif case COMMAND_CMD_POLYFILL: if (val & COMMAND_INITIATE) { @@ -1403,7 +1521,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) default: if (val & COMMAND_INITIATE) { banshee_do_2d_blit(voodoo, -1, 0); - // fatal("Initiate command!\n"); +#if 0 + fatal("Initiate command!\n"); +#endif } break; } @@ -1441,7 +1561,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) case 0xf4: case 0xf8: case 0xfc: - // bansheeblt_log("launch %08x %08x %08x %08x\n", voodoo->banshee_blt.command, voodoo->banshee_blt.commandExtra, voodoo->banshee_blt.srcColorkeyMin, voodoo->banshee_blt.srcColorkeyMax); +#if 0 + bansheeblt_log("launch %08x %08x %08x %08x\n", voodoo->banshee_blt.command, voodoo->banshee_blt.commandExtra, voodoo->banshee_blt.srcColorkeyMin, voodoo->banshee_blt.srcColorkeyMax); +#endif switch (voodoo->banshee_blt.command & COMMAND_CMD_MASK) { case COMMAND_CMD_SCREEN_TO_SCREEN_BLT: voodoo->banshee_blt.srcXY = val; @@ -1573,7 +1695,9 @@ voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) voodoo->banshee_blt.colorPattern8[(addr & 60) + 2] = (val >> 16) & 0xff; voodoo->banshee_blt.colorPattern8[(addr & 60) + 3] = (val >> 24) & 0xff; } - // bansheeblt_log("colorPattern%02x=%08x\n", (addr >> 2) & 63, val); +#if 0 + bansheeblt_log("colorPattern%02x=%08x\n", (addr >> 2) & 63, val); +#endif break; default: diff --git a/src/video/vid_voodoo_blitter.c b/src/video/vid_voodoo_blitter.c index f60d9e184..a1105795c 100644 --- a/src/video/vid_voodoo_blitter.c +++ b/src/video/vid_voodoo_blitter.c @@ -152,16 +152,19 @@ void voodoo_v2_blit_start(voodoo_t *voodoo) { uint64_t dat64; - int size_x = ABS(voodoo->bltSizeX), size_y = ABS(voodoo->bltSizeY); + int size_x = ABS(voodoo->bltSizeX); + int size_y = ABS(voodoo->bltSizeY); int x_dir = (voodoo->bltSizeX > 0) ? 1 : -1; int y_dir = (voodoo->bltSizeY > 0) ? 1 : -1; int dst_x; - int src_y = voodoo->bltSrcY & 0x7ff, dst_y = voodoo->bltDstY & 0x7ff; + int src_y = voodoo->bltSrcY & 0x7ff; + int dst_y = voodoo->bltDstY & 0x7ff; int src_stride = (voodoo->bltCommand & BLTCMD_SRC_TILED) ? ((voodoo->bltSrcXYStride & 0x3f) * 32 * 2) : (voodoo->bltSrcXYStride & 0xff8); int dst_stride = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstXYStride & 0x3f) * 32 * 2) : (voodoo->bltDstXYStride & 0xff8); uint32_t src_base_addr = (voodoo->bltCommand & BLTCMD_SRC_TILED) ? ((voodoo->bltSrcBaseAddr & 0x3ff) << 12) : (voodoo->bltSrcBaseAddr & 0x3ffff8); uint32_t dst_base_addr = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstBaseAddr & 0x3ff) << 12) : (voodoo->bltDstBaseAddr & 0x3ffff8); - int x, y; + int x; + int y; /* voodooblt_log("blit_start: command=%08x srcX=%i srcY=%i dstX=%i dstY=%i sizeX=%i sizeY=%i color=%04x,%04x\n", voodoo->bltCommand, voodoo->bltSrcX, voodoo->bltSrcY, voodoo->bltDstX, voodoo->bltDstY, voodoo->bltSizeX, voodoo->bltSizeY, voodoo->bltColorFg, voodoo->bltColorBg);*/ @@ -173,7 +176,8 @@ voodoo_v2_blit_start(voodoo_t *voodoo) for (y = 0; y <= size_y; y++) { uint16_t *src = (uint16_t *) &voodoo->fb_mem[src_base_addr + src_y * src_stride]; uint16_t *dst = (uint16_t *) &voodoo->fb_mem[dst_base_addr + dst_y * dst_stride]; - int src_x = voodoo->bltSrcX, dst_x = voodoo->bltDstX; + int src_x = voodoo->bltSrcX; + int dst_x = voodoo->bltDstX; for (x = 0; x <= size_x; x++) { uint16_t src_dat = src[src_x]; @@ -316,8 +320,11 @@ voodoo_v2_blit_data(voodoo_t *voodoo, uint32_t data) } while (src_bits && voodoo->blt.cur_x <= voodoo->blt.size_x) { - int r = 0, g = 0, b = 0; - uint16_t src_dat = 0, dst_dat; + int r = 0; + int g = 0; + int b = 0; + uint16_t src_dat = 0; + uint16_t dst_dat; int x = (voodoo->blt.x_dir > 0) ? (voodoo->blt.dst_x + voodoo->blt.cur_x) : (voodoo->blt.dst_x - voodoo->blt.cur_x); int rop = 0; @@ -438,7 +445,8 @@ void voodoo_fastfill(voodoo_t *voodoo, voodoo_params_t *params) { int y; - int low_y, high_y; + int low_y; + int high_y; if (params->fbzMode & (1 << 17)) { int y_origin = (voodoo->type >= VOODOO_BANSHEE) ? (voodoo->y_origin_swap + 1) : voodoo->v_disp; @@ -451,7 +459,9 @@ voodoo_fastfill(voodoo_t *voodoo, voodoo_params_t *params) } if (params->fbzMode & FBZ_RGB_WMASK) { - int r, g, b; + int r; + int g; + int b; uint16_t col; r = ((params->color1 >> 16) >> 3) & 0x1f; @@ -462,26 +472,23 @@ voodoo_fastfill(voodoo_t *voodoo, voodoo_params_t *params) if (SLI_ENABLED) { for (y = low_y; y < high_y; y += 2) { uint16_t *cbuf = (uint16_t *) &voodoo->fb_mem[(params->draw_offset + (y >> 1) * voodoo->row_width) & voodoo->fb_mask]; - int x; - for (x = params->clipLeft; x < params->clipRight; x++) + for (int x = params->clipLeft; x < params->clipRight; x++) cbuf[x] = col; } } else { for (y = low_y; y < high_y; y++) { if (voodoo->col_tiled) { uint16_t *cbuf = (uint16_t *) &voodoo->fb_mem[(params->draw_offset + (y >> 5) * voodoo->row_width + (y & 31) * 128) & voodoo->fb_mask]; - int x; - for (x = params->clipLeft; x < params->clipRight; x++) { + for (int x = params->clipLeft; x < params->clipRight; x++) { int x2 = (x & 63) | ((x >> 6) * 128 * 32 / 2); cbuf[x2] = col; } } else { uint16_t *cbuf = (uint16_t *) &voodoo->fb_mem[(params->draw_offset + y * voodoo->row_width) & voodoo->fb_mask]; - int x; - for (x = params->clipLeft; x < params->clipRight; x++) + for (int x = params->clipLeft; x < params->clipRight; x++) cbuf[x] = col; } } @@ -491,26 +498,23 @@ voodoo_fastfill(voodoo_t *voodoo, voodoo_params_t *params) if (SLI_ENABLED) { for (y = low_y; y < high_y; y += 2) { uint16_t *abuf = (uint16_t *) &voodoo->fb_mem[(params->aux_offset + (y >> 1) * voodoo->row_width) & voodoo->fb_mask]; - int x; - for (x = params->clipLeft; x < params->clipRight; x++) + for (int x = params->clipLeft; x < params->clipRight; x++) abuf[x] = params->zaColor & 0xffff; } } else { for (y = low_y; y < high_y; y++) { if (voodoo->aux_tiled) { uint16_t *abuf = (uint16_t *) &voodoo->fb_mem[(params->aux_offset + (y >> 5) * voodoo->aux_row_width + (y & 31) * 128) & voodoo->fb_mask]; - int x; - for (x = params->clipLeft; x < params->clipRight; x++) { + for (int x = params->clipLeft; x < params->clipRight; x++) { int x2 = (x & 63) | ((x >> 6) * 128 * 32 / 2); abuf[x2] = params->zaColor & 0xffff; } } else { uint16_t *abuf = (uint16_t *) &voodoo->fb_mem[(params->aux_offset + y * voodoo->aux_row_width) & voodoo->fb_mask]; - int x; - for (x = params->clipLeft; x < params->clipRight; x++) + for (int x = params->clipLeft; x < params->clipRight; x++) abuf[x] = params->zaColor & 0xffff; } } diff --git a/src/video/vid_voodoo_display.c b/src/video/vid_voodoo_display.c index aded37e2d..77d54398f 100644 --- a/src/video/vid_voodoo_display.c +++ b/src/video/vid_voodoo_display.c @@ -61,15 +61,17 @@ voodoodisp_log(const char *fmt, ...) void voodoo_update_ncc(voodoo_t *voodoo, int tmu) { - int tbl; - - for (tbl = 0; tbl < 2; tbl++) { - int col; - - for (col = 0; col < 256; col++) { - int y = (col >> 4), i = (col >> 2) & 3, q = col & 3; - int i_r, i_g, i_b; - int q_r, q_g, q_b; + for (uint8_t tbl = 0; tbl < 2; tbl++) { + for (uint16_t col = 0; col < 256; col++) { + int y = (col >> 4); + int i = (col >> 2) & 3; + int q = col & 3; + int i_r; + int i_g; + int i_b; + int q_r; + int q_g; + int q_b; y = (voodoo->nccTable[tmu][tbl].y[y >> 2] >> ((y & 3) * 8)) & 0xff; @@ -121,7 +123,7 @@ voodoo_pixelclock_update(voodoo_t *voodoo) voodoo->pixel_clock = t; clock_const = cpuclock / t; - voodoo->line_time = (uint64_t) ((double) line_length * clock_const * (double) (1ull << 32)); + voodoo->line_time = (uint64_t) ((double) line_length * clock_const * (double) (1ULL << 32)); } static void @@ -149,23 +151,31 @@ voodoo_calc_clutData(voodoo_t *voodoo) #define FILTDIV 256 -static int FILTCAP, FILTCAPG, FILTCAPB = 0; /* color filter threshold values */ +static int FILTCAP; +static int FILTCAPG; +static int FILTCAPB = 0; /* color filter threshold values */ void voodoo_generate_filter_v1(voodoo_t *voodoo) { - int g, h; - float difference, diffg, diffb; - float thiscol, thiscolg, thiscolb, lined; - float fcr, fcg, fcb; + float difference; + float diffg; + float diffb; + float thiscol; + float thiscolg; + float thiscolb; + float lined; + float fcr; + float fcg; + float fcb; fcr = FILTCAP * 5; fcg = FILTCAPG * 6; fcb = FILTCAPB * 5; - for (g = 0; g < FILTDIV; g++) // pixel 1 + for (uint16_t g = 0; g < FILTDIV; g++) // pixel 1 { - for (h = 0; h < FILTDIV; h++) // pixel 2 + for (uint16_t h = 0; h < FILTDIV; h++) // pixel 2 { difference = (float) (h - g); diffg = difference; @@ -236,11 +246,16 @@ voodoo_generate_filter_v1(voodoo_t *voodoo) void voodoo_generate_filter_v2(voodoo_t *voodoo) { - int g, h; float difference; - float thiscol, thiscolg, thiscolb; - float clr, clg, clb = 0; - float fcr, fcg, fcb = 0; + float thiscol; + float thiscolg; + float thiscolb; + float clr; + float clg; + float clb = 0; + float fcr; + float fcg; + float fcb = 0; // pre-clamping @@ -255,9 +270,9 @@ voodoo_generate_filter_v2(voodoo_t *voodoo) if (fcb > 32) fcb = 32; - for (g = 0; g < 256; g++) // pixel 1 - our target pixel we want to bleed into + for (uint16_t g = 0; g < 256; g++) // pixel 1 - our target pixel we want to bleed into { - for (h = 0; h < 256; h++) // pixel 2 - our main pixel + for (uint16_t h = 0; h < 256; h++) // pixel 2 - our main pixel { float avg; float avgdiff; @@ -325,9 +340,9 @@ voodoo_generate_filter_v2(voodoo_t *voodoo) thiscolb = 255; // add to the table - voodoo->thefilter[g][h] = (thiscol); - voodoo->thefilterg[g][h] = (thiscolg); - voodoo->thefilterb[g][h] = (thiscolb); + voodoo->thefilter[g][h] = thiscol; + voodoo->thefilterg[g][h] = thiscolg; + voodoo->thefilterb[g][h] = thiscolb; // debug the ones that don't give us much of a difference // if (difference < FILTCAP) @@ -339,7 +354,9 @@ voodoo_generate_filter_v2(voodoo_t *voodoo) void voodoo_threshold_check(voodoo_t *voodoo) { - int r, g, b; + int r; + int g; + int b; if (!voodoo->scrfilterEnabled) return; /* considered disabled; don't check and generate */ @@ -371,14 +388,12 @@ voodoo_threshold_check(voodoo_t *voodoo) static void voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, int line) { - int x; - // Scratchpad for avoiding feedback streaks uint8_t fil3[4096 * 3]; assert(voodoo->h_disp <= 4096); /* 16 to 32-bit */ - for (x = 0; x < column; x++) { + for (int x = 0; x < column; x++) { fil[x * 3] = ((src[x] & 31) << 3); fil[x * 3 + 1] = (((src[x] >> 5) & 63) << 2); fil[x * 3 + 2] = (((src[x] >> 11) & 31) << 3); @@ -392,7 +407,7 @@ voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, /* lines */ if (line & 1) { - for (x = 0; x < column; x++) { + for (int x = 0; x < column; x++) { fil[x * 3] = voodoo->purpleline[fil[x * 3]][0]; fil[x * 3 + 1] = voodoo->purpleline[fil[x * 3 + 1]][1]; fil[x * 3 + 2] = voodoo->purpleline[fil[x * 3 + 2]][2]; @@ -401,28 +416,28 @@ voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, /* filtering time */ - for (x = 1; x < column; x++) { - fil3[(x) *3] = voodoo->thefilterb[fil[x * 3]][fil[(x - 1) * 3]]; - fil3[(x) *3 + 1] = voodoo->thefilterg[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; - fil3[(x) *3 + 2] = voodoo->thefilter[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; + for (int x = 1; x < column; x++) { + fil3[x * 3] = voodoo->thefilterb[fil[x * 3]][fil[(x - 1) * 3]]; + fil3[x * 3 + 1] = voodoo->thefilterg[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; + fil3[x * 3 + 2] = voodoo->thefilter[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; } - for (x = 1; x < column; x++) { - fil[(x) *3] = voodoo->thefilterb[fil3[x * 3]][fil3[(x - 1) * 3]]; - fil[(x) *3 + 1] = voodoo->thefilterg[fil3[x * 3 + 1]][fil3[(x - 1) * 3 + 1]]; - fil[(x) *3 + 2] = voodoo->thefilter[fil3[x * 3 + 2]][fil3[(x - 1) * 3 + 2]]; + for (int x = 1; x < column; x++) { + fil[x * 3] = voodoo->thefilterb[fil3[x * 3]][fil3[(x - 1) * 3]]; + fil[x * 3 + 1] = voodoo->thefilterg[fil3[x * 3 + 1]][fil3[(x - 1) * 3 + 1]]; + fil[x * 3 + 2] = voodoo->thefilter[fil3[x * 3 + 2]][fil3[(x - 1) * 3 + 2]]; } - for (x = 1; x < column; x++) { - fil3[(x) *3] = voodoo->thefilterb[fil[x * 3]][fil[(x - 1) * 3]]; - fil3[(x) *3 + 1] = voodoo->thefilterg[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; - fil3[(x) *3 + 2] = voodoo->thefilter[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; + for (int x = 1; x < column; x++) { + fil3[x * 3] = voodoo->thefilterb[fil[x * 3]][fil[(x - 1) * 3]]; + fil3[x * 3 + 1] = voodoo->thefilterg[fil[x * 3 + 1]][fil[(x - 1) * 3 + 1]]; + fil3[x * 3 + 2] = voodoo->thefilter[fil[x * 3 + 2]][fil[(x - 1) * 3 + 2]]; } - for (x = 0; x < column - 1; x++) { - fil[(x) *3] = voodoo->thefilterb[fil3[x * 3]][fil3[(x + 1) * 3]]; - fil[(x) *3 + 1] = voodoo->thefilterg[fil3[x * 3 + 1]][fil3[(x + 1) * 3 + 1]]; - fil[(x) *3 + 2] = voodoo->thefilter[fil3[x * 3 + 2]][fil3[(x + 1) * 3 + 2]]; + for (int x = 0; x < column - 1; x++) { + fil[x * 3] = voodoo->thefilterb[fil3[x * 3]][fil3[(x + 1) * 3]]; + fil[x * 3 + 1] = voodoo->thefilterg[fil3[x * 3 + 1]][fil3[(x + 1) * 3 + 1]]; + fil[x * 3 + 2] = voodoo->thefilter[fil3[x * 3 + 2]][fil3[(x + 1) * 3 + 2]]; } } @@ -446,48 +461,48 @@ voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, /* filtering time */ for (x = 1; x < column - 3; x++) { - fil3[(x + 3) * 3] = voodoo->thefilterb[((src[x + 3] & 31) << 3)][((src[x] & 31) << 3)]; - fil3[(x + 3) * 3 + 1] = voodoo->thefilterg[(((src[x + 3] >> 5) & 63) << 2)][(((src[x] >> 5) & 63) << 2)]; - fil3[(x + 3) * 3 + 2] = voodoo->thefilter[(((src[x + 3] >> 11) & 31) << 3)][(((src[x] >> 11) & 31) << 3)]; + fil3[(x + 3) * 3] = voodoo->thefilterb[(src[x + 3] & 31) << 3][(src[x] & 31) << 3]; + fil3[(x + 3) * 3 + 1] = voodoo->thefilterg[((src[x + 3] >> 5) & 63) << 2][((src[x] >> 5) & 63) << 2]; + fil3[(x + 3) * 3 + 2] = voodoo->thefilter[((src[x + 3] >> 11) & 31) << 3][((src[x] >> 11) & 31) << 3]; - fil[(x + 2) * 3] = voodoo->thefilterb[fil3[(x + 2) * 3]][((src[x] & 31) << 3)]; - fil[(x + 2) * 3 + 1] = voodoo->thefilterg[fil3[(x + 2) * 3 + 1]][(((src[x] >> 5) & 63) << 2)]; - fil[(x + 2) * 3 + 2] = voodoo->thefilter[fil3[(x + 2) * 3 + 2]][(((src[x] >> 11) & 31) << 3)]; + fil[(x + 2) * 3] = voodoo->thefilterb[fil3[(x + 2) * 3]][(src[x] & 31) << 3]; + fil[(x + 2) * 3 + 1] = voodoo->thefilterg[fil3[(x + 2) * 3 + 1]][((src[x] >> 5) & 63) << 2]; + fil[(x + 2) * 3 + 2] = voodoo->thefilter[fil3[(x + 2) * 3 + 2]][((src[x] >> 11) & 31) << 3]; - fil3[(x + 1) * 3] = voodoo->thefilterb[fil[(x + 1) * 3]][((src[x] & 31) << 3)]; - fil3[(x + 1) * 3 + 1] = voodoo->thefilterg[fil[(x + 1) * 3 + 1]][(((src[x] >> 5) & 63) << 2)]; - fil3[(x + 1) * 3 + 2] = voodoo->thefilter[fil[(x + 1) * 3 + 2]][(((src[x] >> 11) & 31) << 3)]; + fil3[(x + 1) * 3] = voodoo->thefilterb[fil[(x + 1) * 3]][(src[x] & 31) << 3]; + fil3[(x + 1) * 3 + 1] = voodoo->thefilterg[fil[(x + 1) * 3 + 1]][((src[x] >> 5) & 63) << 2]; + fil3[(x + 1) * 3 + 2] = voodoo->thefilter[fil[(x + 1) * 3 + 2]][((src[x] >> 11) & 31) << 3]; - fil[(x - 1) * 3] = voodoo->thefilterb[fil3[(x - 1) * 3]][((src[x] & 31) << 3)]; - fil[(x - 1) * 3 + 1] = voodoo->thefilterg[fil3[(x - 1) * 3 + 1]][(((src[x] >> 5) & 63) << 2)]; - fil[(x - 1) * 3 + 2] = voodoo->thefilter[fil3[(x - 1) * 3 + 2]][(((src[x] >> 11) & 31) << 3)]; + fil[(x - 1) * 3] = voodoo->thefilterb[fil3[(x - 1) * 3]][(src[x] & 31) << 3]; + fil[(x - 1) * 3 + 1] = voodoo->thefilterg[fil3[(x - 1) * 3 + 1]][((src[x] >> 5) & 63) << 2]; + fil[(x - 1) * 3 + 2] = voodoo->thefilter[fil3[(x - 1) * 3 + 2]][((src[x] >> 11) & 31) << 3]; } // unroll for edge cases - fil3[(column - 3) * 3] = voodoo->thefilterb[((src[column - 3] & 31) << 3)][((src[column] & 31) << 3)]; - fil3[(column - 3) * 3 + 1] = voodoo->thefilterg[(((src[column - 3] >> 5) & 63) << 2)][(((src[column] >> 5) & 63) << 2)]; - fil3[(column - 3) * 3 + 2] = voodoo->thefilter[(((src[column - 3] >> 11) & 31) << 3)][(((src[column] >> 11) & 31) << 3)]; + fil3[(column - 3) * 3] = voodoo->thefilterb[(src[column - 3] & 31) << 3][(src[column] & 31) << 3]; + fil3[(column - 3) * 3 + 1] = voodoo->thefilterg[((src[column - 3] >> 5) & 63) << 2][((src[column] >> 5) & 63) << 2]; + fil3[(column - 3) * 3 + 2] = voodoo->thefilter[((src[column - 3] >> 11) & 31) << 3][((src[column] >> 11) & 31) << 3]; - fil3[(column - 2) * 3] = voodoo->thefilterb[((src[column - 2] & 31) << 3)][((src[column] & 31) << 3)]; - fil3[(column - 2) * 3 + 1] = voodoo->thefilterg[(((src[column - 2] >> 5) & 63) << 2)][(((src[column] >> 5) & 63) << 2)]; - fil3[(column - 2) * 3 + 2] = voodoo->thefilter[(((src[column - 2] >> 11) & 31) << 3)][(((src[column] >> 11) & 31) << 3)]; + fil3[(column - 2) * 3] = voodoo->thefilterb[(src[column - 2] & 31) << 3][(src[column] & 31) << 3]; + fil3[(column - 2) * 3 + 1] = voodoo->thefilterg[((src[column - 2] >> 5) & 63) << 2][((src[column] >> 5) & 63) << 2]; + fil3[(column - 2) * 3 + 2] = voodoo->thefilter[((src[column - 2] >> 11) & 31) << 3][((src[column] >> 11) & 31) << 3]; - fil3[(column - 1) * 3] = voodoo->thefilterb[((src[column - 1] & 31) << 3)][((src[column] & 31) << 3)]; - fil3[(column - 1) * 3 + 1] = voodoo->thefilterg[(((src[column - 1] >> 5) & 63) << 2)][(((src[column] >> 5) & 63) << 2)]; - fil3[(column - 1) * 3 + 2] = voodoo->thefilter[(((src[column - 1] >> 11) & 31) << 3)][(((src[column] >> 11) & 31) << 3)]; + fil3[(column - 1) * 3] = voodoo->thefilterb[(src[column - 1] & 31) << 3][(src[column] & 31) << 3]; + fil3[(column - 1) * 3 + 1] = voodoo->thefilterg[((src[column - 1] >> 5) & 63) << 2][((src[column] >> 5) & 63) << 2]; + fil3[(column - 1) * 3 + 2] = voodoo->thefilter[((src[column - 1] >> 11) & 31) << 3][((src[column] >> 11) & 31) << 3]; - fil[(column - 2) * 3] = voodoo->thefilterb[fil3[(column - 2) * 3]][((src[column] & 31) << 3)]; - fil[(column - 2) * 3 + 1] = voodoo->thefilterg[fil3[(column - 2) * 3 + 1]][(((src[column] >> 5) & 63) << 2)]; - fil[(column - 2) * 3 + 2] = voodoo->thefilter[fil3[(column - 2) * 3 + 2]][(((src[column] >> 11) & 31) << 3)]; + fil[(column - 2) * 3] = voodoo->thefilterb[fil3[(column - 2) * 3]][(src[column] & 31) << 3]; + fil[(column - 2) * 3 + 1] = voodoo->thefilterg[fil3[(column - 2) * 3 + 1]][((src[column] >> 5) & 63) << 2]; + fil[(column - 2) * 3 + 2] = voodoo->thefilter[fil3[(column - 2) * 3 + 2]][((src[column] >> 11) & 31) << 3]; - fil[(column - 1) * 3] = voodoo->thefilterb[fil3[(column - 1) * 3]][((src[column] & 31) << 3)]; - fil[(column - 1) * 3 + 1] = voodoo->thefilterg[fil3[(column - 1) * 3 + 1]][(((src[column] >> 5) & 63) << 2)]; - fil[(column - 1) * 3 + 2] = voodoo->thefilter[fil3[(column - 1) * 3 + 2]][(((src[column] >> 11) & 31) << 3)]; + fil[(column - 1) * 3] = voodoo->thefilterb[fil3[(column - 1) * 3]][(src[column] & 31) << 3]; + fil[(column - 1) * 3 + 1] = voodoo->thefilterg[fil3[(column - 1) * 3 + 1]][((src[column] >> 5) & 63) << 2]; + fil[(column - 1) * 3 + 2] = voodoo->thefilter[fil3[(column - 1) * 3 + 2]][((src[column] >> 11) & 31) << 3]; - fil3[(column - 1) * 3] = voodoo->thefilterb[fil[(column - 1) * 3]][((src[column] & 31) << 3)]; - fil3[(column - 1) * 3 + 1] = voodoo->thefilterg[fil[(column - 1) * 3 + 1]][(((src[column] >> 5) & 63) << 2)]; - fil3[(column - 1) * 3 + 2] = voodoo->thefilter[fil[(column - 1) * 3 + 2]][(((src[column] >> 11) & 31) << 3)]; + fil3[(column - 1) * 3] = voodoo->thefilterb[fil[(column - 1) * 3]][(src[column] & 31) << 3]; + fil3[(column - 1) * 3 + 1] = voodoo->thefilterg[fil[(column - 1) * 3 + 1]][((src[column] >> 5) & 63) << 2]; + fil3[(column - 1) * 3 + 2] = voodoo->thefilter[fil[(column - 1) * 3 + 2]][((src[column] >> 11) & 31) << 3]; } void diff --git a/src/video/vid_voodoo_fb.c b/src/video/vid_voodoo_fb.c index f4a4edca6..06941eb05 100644 --- a/src/video/vid_voodoo_fb.c +++ b/src/video/vid_voodoo_fb.c @@ -62,7 +62,8 @@ uint16_t voodoo_fb_readw(uint32_t addr, void *p) { voodoo_t *voodoo = (voodoo_t *) p; - int x, y; + int x; + int y; uint32_t read_addr; uint16_t temp; @@ -102,7 +103,8 @@ uint32_t voodoo_fb_readl(uint32_t addr, void *p) { voodoo_t *voodoo = (voodoo_t *) p; - int x, y; + int x; + int y; uint32_t read_addr; uint32_t temp; @@ -142,7 +144,9 @@ voodoo_fb_readl(uint32_t addr, void *p) static inline uint16_t do_dither(voodoo_params_t *params, rgba8_t col, int x, int y) { - int r, g, b; + int r; + int g; + int b; if (dither) { if (dither2x2) { @@ -168,8 +172,10 @@ voodoo_fb_writew(uint32_t addr, uint16_t val, void *p) { voodoo_t *voodoo = (voodoo_t *) p; voodoo_params_t *params = &voodoo->params; - int x, y; - uint32_t write_addr, write_addr_aux; + int x; + int y; + uint32_t write_addr; + uint32_t write_addr_aux; rgba8_t colour_data; uint16_t depth_data; uint8_t alpha_data; @@ -265,7 +271,10 @@ voodoo_fb_writew(uint32_t addr, uint16_t val, void *p) if (params->alphaMode & (1 << 4)) { uint16_t dat = *(uint16_t *) (&voodoo->fb_mem[write_addr & voodoo->fb_mask]); - int dest_r, dest_g, dest_b, dest_a; + int dest_r; + int dest_g; + int dest_b; + int dest_a; dest_r = (dat >> 8) & 0xf8; dest_g = (dat >> 3) & 0xfc; @@ -299,12 +308,15 @@ voodoo_fb_writel(uint32_t addr, uint32_t val, void *p) { voodoo_t *voodoo = (voodoo_t *) p; voodoo_params_t *params = &voodoo->params; - int x, y; - uint32_t write_addr, write_addr_aux; + int x; + int y; + uint32_t write_addr; + uint32_t write_addr_aux; rgba8_t colour_data[2]; uint16_t depth_data[2]; uint8_t alpha_data[2]; - int write_mask = 0, count = 1; + int write_mask = 0; + int count = 1; depth_data[0] = depth_data[1] = voodoo->params.zaColor & 0xffff; alpha_data[0] = alpha_data[1] = voodoo->params.zaColor >> 24; @@ -412,7 +424,10 @@ voodoo_fb_writel(uint32_t addr, uint32_t val, void *p) if (params->alphaMode & (1 << 4)) { uint16_t dat = *(uint16_t *) (&voodoo->fb_mem[write_addr & voodoo->fb_mask]); - int dest_r, dest_g, dest_b, dest_a; + int dest_r; + int dest_g; + int dest_b; + int dest_a; dest_r = (dat >> 8) & 0xf8; dest_g = (dat >> 3) & 0xfc; @@ -435,9 +450,7 @@ skip_pixel: write_addr_aux += 2; } } else { - int c; - - for (c = 0; c < count; c++) { + for (int c = 0; c < count; c++) { if (write_mask & LFB_WRITE_COLOUR) *(uint16_t *) (&voodoo->fb_mem[write_addr & voodoo->fb_mask]) = do_dither(&voodoo->params, colour_data[c], (x >> 1) + c, y); if (write_mask & LFB_WRITE_DEPTH) diff --git a/src/video/vid_voodoo_fifo.c b/src/video/vid_voodoo_fifo.c index 646e5876c..ab82d104e 100644 --- a/src/video/vid_voodoo_fifo.c +++ b/src/video/vid_voodoo_fifo.c @@ -148,11 +148,9 @@ voodoo_wait_for_swap_complete(voodoo_t *voodoo) voodoo->swap_count--; voodoo->swap_pending = 0; thread_release_mutex(voodoo->swap_mutex); - ; break; } else thread_release_mutex(voodoo->swap_mutex); - ; } } diff --git a/src/video/vid_voodoo_render.c b/src/video/vid_voodoo_render.c index 4b09cfadb..c0e6e0196 100644 --- a/src/video/vid_voodoo_render.c +++ b/src/video/vid_voodoo_render.c @@ -246,8 +246,7 @@ tex_read_4(voodoo_state_t *state, voodoo_texture_state_t *texture_state, int s, rgba_u dat[4]; if (((s | (s + 1)) & ~texture_state->w_mask) || ((t | (t + 1)) & ~texture_state->h_mask)) { - int c; - for (c = 0; c < 4; c++) { + for (uint8_t c = 0; c < 4; c++) { int _s = s + (c & 1); int _t = t + ((c & 2) >> 1); @@ -289,7 +288,8 @@ voodoo_get_texture(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *st { voodoo_texture_state_t texture_state; int d[4]; - int s, t; + int s; + int t; int tex_lod = state->tex_lod[tmu][state->lod]; texture_state.w_mask = state->tex_w_mask[tmu][state->lod]; @@ -306,7 +306,8 @@ voodoo_get_texture(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *st } if (voodoo->bilinear_enabled && params->textureMode[tmu] & 6) { - int _ds, dt; + int _ds; + int dt; state->tex_s -= 1 << (3 + tex_lod); state->tex_t -= 1 << (3 + tex_lod); @@ -407,10 +408,20 @@ voodoo_tmu_fetch(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *stat static inline void voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *state, int x) { - int r, g, b, a; - int c_reverse, a_reverse; - // int c_reverse1, a_reverse1; - int factor_r = 0, factor_g = 0, factor_b = 0, factor_a = 0; + int r; + int g; + int b; + int a; + int c_reverse; + int a_reverse; +#if 0 + int c_reverse1; + int a_reverse1; +#endif + int factor_r = 0; + int factor_g = 0; + int factor_b = 0; + int factor_a = 0; voodoo_tmu_fetch(voodoo, params, state, 1, x); @@ -653,7 +664,6 @@ voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t * int depth_op = (params->fbzMode >> 5) & 7; int dither = params->fbzMode & FBZ_DITHER;*/ int texels; - int c; #ifndef NO_CODEGEN uint8_t (*voodoo_draw)(voodoo_state_t * state, voodoo_params_t * params, int x, int real_y); #endif @@ -672,7 +682,7 @@ voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t * // int last_x; // voodoo_render_log("voodoo_triangle : bottom-half %X %X %X %X %X %i %i %i %i\n", xstart, xend, dx1, dx2, dx2 * 36, xdir, y, yend, ydir); - for (c = 0; c <= LOD_MAX; c++) { + for (uint8_t c = 0; c <= LOD_MAX; c++) { state->tex[0][c] = &voodoo->texture_cache[0][params->tex_entry[0]].data[texture_offset[c]]; state->tex[1][c] = &voodoo->texture_cache[1][params->tex_entry[1]].data[texture_offset[c]]; } @@ -753,11 +763,13 @@ voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t * // voodoo_render_log("Start %i %i\n", ystart, voodoo->fbzMode & (1 << 17)); for (; state->y < yend; state->y += y_diff) { - int x, x2; + int x; + int x2; int real_y = (state->y << 4) + 8; int start_x; int dx; - uint16_t *fb_mem, *aux_mem; + uint16_t *fb_mem; + uint16_t *aux_mem; state->ir = state->base_r; state->ig = state->base_g; @@ -907,14 +919,30 @@ voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t * // if (voodoo->fbzMode & FBZ_RGB_WMASK) { int update = 1; - uint8_t cother_r = 0, cother_g = 0, cother_b = 0, aother; - uint8_t clocal_r, clocal_g, clocal_b, alocal; - int src_r = 0, src_g = 0, src_b = 0, src_a = 0; - int msel_r, msel_g, msel_b, msel_a; - uint8_t dest_r, dest_g, dest_b, dest_a; + uint8_t cother_r = 0; + uint8_t cother_g = 0; + uint8_t cother_b = 0; + uint8_t aother; + uint8_t clocal_r; + uint8_t clocal_g; + uint8_t clocal_b; + uint8_t alocal; + int src_r = 0; + int src_g = 0; + int src_b = 0; + int src_a = 0; + int msel_r; + int msel_g; + int msel_b; + int msel_a; + uint8_t dest_r; + uint8_t dest_g; + uint8_t dest_b; + uint8_t dest_a; uint16_t dat; int sel; - int32_t new_depth, w_depth; + int32_t new_depth; + int32_t w_depth; if (state->w & 0xffff00000000) w_depth = 0; @@ -922,7 +950,7 @@ voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t * w_depth = 0xf001; else { int exp = voodoo_fls((uint16_t) ((uint32_t) state->w >> 16)); - int mant = ((~(uint32_t) state->w >> (19 - exp))) & 0xfff; + int mant = (~(uint32_t) state->w >> (19 - exp)) & 0xfff; w_depth = (exp << 12) + mant + 1; if (w_depth > 0xffff) w_depth = 0xffff; @@ -1328,9 +1356,11 @@ voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_even) voodoo_state_t state; int vertexAy_adjusted; int vertexCy_adjusted; - int dx, dy; + int dx; + int dy; - uint64_t tempdx, tempdy; + uint64_t tempdx; + uint64_t tempdy; uint64_t tempLOD; int LOD; int lodbias; diff --git a/src/video/vid_voodoo_setup.c b/src/video/vid_voodoo_setup.c index 40018ddf8..e1d13ba35 100644 --- a/src/video/vid_voodoo_setup.c +++ b/src/video/vid_voodoo_setup.c @@ -60,9 +60,14 @@ voodoo_setup_log(const char *fmt, ...) void voodoo_triangle_setup(voodoo_t *voodoo) { - float dxAB, dxBC, dyAB, dyBC; + float dxAB; + float dxBC; + float dyAB; + float dyBC; float area; - int va = 0, vb = 1, vc = 2; + int va = 0; + int vb = 1; + int vc = 2; vert_t verts[3]; verts[0] = voodoo->verts[0]; diff --git a/src/video/vid_voodoo_texture.c b/src/video/vid_voodoo_texture.c index 4f81f6d00..1e9413460 100644 --- a/src/video/vid_voodoo_texture.c +++ b/src/video/vid_voodoo_texture.c @@ -62,9 +62,9 @@ void voodoo_recalc_tex12(voodoo_t *voodoo, int tmu) { int aspect = (voodoo->params.tLOD[tmu] >> 21) & 3; - int width = 256, height = 256; + int width = 256; + int height = 256; int shift = 8; - int lod; uint32_t base = voodoo->params.texBaseAddr[tmu]; uint32_t offset = 0; int tex_lod = 0; @@ -85,7 +85,7 @@ voodoo_recalc_tex12(voodoo_t *voodoo, int tmu) base = voodoo->params.texBaseAddr1[tmu]; } - for (lod = 0; lod <= LOD_MAX + 1; lod++) { + for (uint8_t lod = 0; lod <= LOD_MAX + 1; lod++) { if (!width) width = 1; if (!height) @@ -149,14 +149,17 @@ void voodoo_recalc_tex3(voodoo_t *voodoo, int tmu) { int aspect = (voodoo->params.tLOD[tmu] >> 21) & 3; - int width = 256, height = 256; + int width = 256; + int height = 256; int shift = 8; int lod; uint32_t base = voodoo->params.texBaseAddr[tmu]; uint32_t offset = 0; int tex_lod = 0; uint32_t offsets[LOD_MAX + 3]; - int widths[LOD_MAX + 3], heights[LOD_MAX + 3], shifts[LOD_MAX + 3]; + int widths[LOD_MAX + 3]; + int heights[LOD_MAX + 3]; + int shifts[LOD_MAX + 3]; if (voodoo->params.tLOD[tmu] & LOD_S_IS_WIDER) height >>= aspect; @@ -237,10 +240,11 @@ voodoo_recalc_tex3(voodoo_t *voodoo, int tmu) void voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) { - int c, d; - int lod; - int lod_min, lod_max; - uint32_t addr = 0, addr_end; + int c; + int lod_min; + int lod_max; + uint32_t addr = 0; + uint32_t addr_end; uint32_t palette_checksum; lod_min = (params->tLOD[tmu] >> 2) & 15; @@ -301,10 +305,11 @@ voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) // voodoo_texture_log(" add new texture to %i tformat=%i %08x LOD=%i-%i tmu=%i\n", c, voodoo->params.tformat[tmu], params->texBaseAddr[tmu], lod_min, lod_max, tmu); lod_min = MIN(lod_min, 8); lod_max = MIN(lod_max, 8); - for (lod = lod_min; lod <= lod_max; lod++) { + for (int lod = lod_min; lod <= lod_max; lod++) { uint32_t *base = &voodoo->texture_cache[tmu][c].data[texture_offset[lod]]; uint32_t tex_addr = params->tex_base[tmu][lod] & voodoo->texture_mask; - int x, y; + int x; + int y; int shift = 8 - params->tex_lod[tmu][lod]; rgba_u *pal; @@ -525,7 +530,7 @@ voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) } else voodoo->texture_cache[tmu][c].addr_start[3] = voodoo->texture_cache[tmu][c].addr_end[3] = 0; - for (d = 0; d < 4; d++) { + for (uint8_t d = 0; d < 4; d++) { addr = voodoo->texture_cache[tmu][c].addr_start[d]; addr_end = voodoo->texture_cache[tmu][c].addr_end[d]; @@ -543,15 +548,12 @@ void flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu) { int wait_for_idle = 0; - int c; memset(voodoo->texture_present[tmu], 0, sizeof(voodoo->texture_present[0])); // voodoo_texture_log("Evict %08x %i\n", dirty_addr, sizeof(voodoo->texture_present)); - for (c = 0; c < TEX_CACHE_MAX; c++) { + for (uint8_t c = 0; c < TEX_CACHE_MAX; c++) { if (voodoo->texture_cache[tmu][c].base != -1) { - int d; - - for (d = 0; d < 4; d++) { + for (uint8_t d = 0; d < 4; d++) { int addr_start = voodoo->texture_cache[tmu][c].addr_start[d]; int addr_end = voodoo->texture_cache[tmu][c].addr_end[d]; @@ -583,7 +585,9 @@ flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu) void voodoo_tex_writel(uint32_t addr, uint32_t val, void *p) { - int lod, s, t; + int lod; + int s; + int t; voodoo_t *voodoo = (voodoo_t *) p; int tmu; diff --git a/src/video/vid_wy700.c b/src/video/vid_wy700.c index 1a4babb99..c81a41de8 100644 --- a/src/video/vid_wy700.c +++ b/src/video/vid_wy700.c @@ -327,7 +327,8 @@ wy700_in(uint16_t addr, void *p) void wy700_checkchanges(wy700_t *wy700) { - uint8_t curstart, curend; + uint8_t curstart; + uint8_t curend; if (wy700->last_03D8 == wy700->cga_ctrl && wy700->last_03DD == (wy700->wy700_base & 0xFF) && wy700->last_03DF == wy700->wy700_control && wy700->last_crtc_0E == wy700->cga_crtc[0x0E]) { return; /* Nothing changed */ @@ -495,7 +496,8 @@ void wy700_recalctimings(wy700_t *wy700) { double disptime; - double _dispontime, _dispofftime; + double _dispontime; + double _dispofftime; disptime = wy700->real_crtc[0] + 1; _dispontime = wy700->real_crtc[1]; @@ -510,14 +512,16 @@ wy700_recalctimings(wy700_t *wy700) void wy700_textline(wy700_t *wy700) { - int x; int w = (wy700->wy700_mode == 0) ? 40 : 80; int cw = (wy700->wy700_mode == 0) ? 32 : 16; - uint8_t chr, attr; + uint8_t chr; + uint8_t attr; uint8_t bitmap[2]; uint8_t *fontbase = &fontdatw[0][0]; - int blink, c; - int drawcursor, cursorline; + int blink; + int c; + int drawcursor; + int cursorline; int mda = 0; uint16_t addr; uint8_t sc; @@ -544,7 +548,7 @@ wy700_textline(wy700_t *wy700) cursorline = ((wy700->real_crtc[10] & 0x1F) <= sc) && ((wy700->real_crtc[11] & 0x1F) >= sc); } - for (x = 0; x < w; x++) { + for (int x = 0; x < w; x++) { chr = wy700->vram[(addr + 2 * x) & 0x3FFF]; attr = wy700->vram[(addr + 2 * x + 1) & 0x3FFF]; drawcursor = ((ma == ca) && cursorline && wy700->enabled && (wy700->cga_ctrl & 8) && (wy700->blink & 16)); @@ -588,7 +592,7 @@ wy700_textline(wy700_t *wy700) void wy700_cgaline(wy700_t *wy700) { - int x, c; + int c; uint32_t dat; uint8_t ink = 0; uint16_t addr; @@ -598,7 +602,7 @@ wy700_cgaline(wy700_t *wy700) /* The fixed mode setting here programs the real CRTC with a screen * width to 20, so draw in 20 fixed chunks of 4 bytes each */ - for (x = 0; x < 20; x++) { + for (uint8_t x = 0; x < 20; x++) { dat = ((wy700->vram[addr & 0x3FFF] << 24) | (wy700->vram[(addr + 1) & 0x3FFF] << 16) | (wy700->vram[(addr + 2) & 0x3FFF] << 8) | (wy700->vram[(addr + 3) & 0x3FFF])); addr += 4; @@ -639,14 +643,14 @@ wy700_cgaline(wy700_t *wy700) void wy700_medresline(wy700_t *wy700) { - int x, c; + int c; uint32_t dat; uint8_t ink = 0; uint32_t addr; addr = (wy700->displine >> 1) * 80 + 4 * wy700->wy700_base; - for (x = 0; x < 20; x++) { + for (uint8_t x = 0; x < 20; x++) { dat = ((wy700->vram[addr & 0x1FFFF] << 24) | (wy700->vram[(addr + 1) & 0x1FFFF] << 16) | (wy700->vram[(addr + 2) & 0x1FFFF] << 8) | (wy700->vram[(addr + 3) & 0x1FFFF])); addr += 4; @@ -689,7 +693,7 @@ wy700_medresline(wy700_t *wy700) void wy700_hiresline(wy700_t *wy700) { - int x, c; + int c; uint32_t dat; uint8_t ink = 0; uint32_t addr; @@ -701,7 +705,7 @@ wy700_hiresline(wy700_t *wy700) if (wy700->displine & 1) addr += 0x10000; } - for (x = 0; x < 40; x++) { + for (uint8_t x = 0; x < 40; x++) { dat = ((wy700->vram[addr & 0x1FFFF] << 24) | (wy700->vram[(addr + 1) & 0x1FFFF] << 16) | (wy700->vram[(addr + 2) & 0x1FFFF] << 8) | (wy700->vram[(addr + 3) & 0x1FFFF])); addr += 4; diff --git a/src/video/vid_xga.c b/src/video/vid_xga.c index 11e94f531..0c795d132 100644 --- a/src/video/vid_xga.c +++ b/src/video/vid_xga.c @@ -129,16 +129,16 @@ xga_recalctimings(svga_t *svga) switch (xga->clk_sel_1 & 0x0c) { case 0: if (xga->clk_sel_2 & 0x80) { - svga->clock = (cpuclock * (double) (1ull << 32)) / 41539000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 41539000.0; } else { - svga->clock = (cpuclock * (double) (1ull << 32)) / 25175000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 25175000.0; } break; case 4: - svga->clock = (cpuclock * (double) (1ull << 32)) / 28322000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 28322000.0; break; case 0x0c: - svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0; + svga->clock = (cpuclock * (double) (1ULL << 32)) / 44900000.0; break; } } @@ -448,7 +448,8 @@ xga_ext_inb(uint16_t addr, void *p) { svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; - uint8_t ret, index; + uint8_t ret; + uint8_t index; switch (addr & 0x0f) { case 0: @@ -845,7 +846,7 @@ xga_accel_read_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, int addr += (y * (width << 1)); addr += (x << 1); if (!skip) { - if ((xga->accel.px_map_format[map] & 8)) { + if (xga->accel.px_map_format[map] & 8) { if (xga->linear_endian_reverse) { READW(addr, byte); } else { @@ -868,7 +869,8 @@ xga_accel_write_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, ui { xga_t *xga = &svga->xga; uint32_t addr = base; - uint8_t byte, mask; + uint8_t byte; + uint8_t mask; int skip = 0; if (xga->base_addr_1mb) { @@ -881,7 +883,7 @@ xga_accel_write_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, ui switch (xga->accel.px_map_format[map] & 7) { case 0: /*1-bit*/ - addr += (y * (width) >> 3); + addr += (y * width >> 3); addr += (x >> 3); if (!skip) { READ(addr, byte); @@ -899,13 +901,13 @@ xga_accel_write_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, ui byte = (byte & ~mask) | ((pixel ? 0xff : 0) & mask); if (pixel & 1) { if (!skip) { - xga->vram[((addr)) & (xga->vram_mask)] |= mask; - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; + xga->vram[addr & (xga->vram_mask)] |= mask; + xga->changedvram[(addr & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; } } else { if (!skip) { - xga->vram[((addr)) & (xga->vram_mask)] &= ~mask; - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; + xga->vram[addr & (xga->vram_mask)] &= ~mask; + xga->changedvram[(addr & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; } } mem_writeb_phys(addr, byte); @@ -919,10 +921,10 @@ xga_accel_write_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, ui mem_writeb_phys(addr, pixel & 0xff); break; case 4: /*16-bit*/ - addr += (y * (width) << 1); + addr += (y * width << 1); addr += (x << 1); if (!skip) { - if ((xga->accel.px_map_format[map] & 8)) { + if (xga->accel.px_map_format[map] & 8) { if (xga->linear_endian_reverse) { WRITEW(addr, pixel); } else { @@ -941,14 +943,19 @@ static void xga_short_stroke(svga_t *svga, uint8_t ssv) { xga_t *xga = &svga->xga; - uint32_t src_dat, dest_dat, old_dest_dat; + uint32_t src_dat; + uint32_t dest_dat; + uint32_t old_dest_dat; uint32_t color_cmp = xga->accel.color_cmp; uint32_t plane_mask = xga->accel.plane_mask; uint32_t dstbase = xga->accel.px_map_base[xga->accel.dst_map]; uint32_t srcbase = xga->accel.px_map_base[xga->accel.src_map]; int y = ssv & 0x0f; int x = 0; - int dx, dy, dirx = 0, diry = 0; + int dx; + int dy; + int dirx = 0; + int diry = 0; dx = xga->accel.dst_map_x & 0x1fff; if (xga->accel.dst_map_x & 0x1800) @@ -1062,17 +1069,25 @@ static void xga_line_draw_write(svga_t *svga) { xga_t *xga = &svga->xga; - uint32_t src_dat, dest_dat, old_dest_dat; + uint32_t src_dat; + uint32_t dest_dat; + uint32_t old_dest_dat; uint32_t color_cmp = xga->accel.color_cmp; uint32_t plane_mask = xga->accel.plane_mask; uint32_t dstbase = xga->accel.px_map_base[xga->accel.dst_map]; uint32_t srcbase = xga->accel.px_map_base[xga->accel.src_map]; - int dminor, destxtmp, dmajor, err, tmpswap; + int dminor; + int destxtmp; + int dmajor; + int err; + int tmpswap; int steep = 1; - int xdir, ydir; + int xdir; + int ydir; int y = xga->accel.blt_width; int x = 0; - int dx, dy; + int dx; + int dy; dminor = ((int16_t) xga->accel.bres_k1); if (xga->accel.bres_k1 & 0x2000) @@ -1224,7 +1239,9 @@ static void xga_bitblt(svga_t *svga) { xga_t *xga = &svga->xga; - uint32_t src_dat, dest_dat, old_dest_dat; + uint32_t src_dat; + uint32_t dest_dat; + uint32_t old_dest_dat; uint32_t color_cmp = xga->accel.color_cmp; uint32_t plane_mask = xga->accel.plane_mask; uint32_t patbase = xga->accel.px_map_base[xga->accel.pat_src]; @@ -1236,7 +1253,8 @@ xga_bitblt(svga_t *svga) uint32_t patheight = xga->accel.px_map_height[xga->accel.pat_src]; uint32_t srcheight = xga->accel.px_map_height[xga->accel.src_map]; int mix = 0; - int xdir, ydir; + int xdir; + int ydir; if (xga->accel.octant & 0x02) { ydir = -1; @@ -2019,7 +2037,8 @@ xga_hwcursor_draw(svga_t *svga, int displine) xga_t *xga = &svga->xga; uint8_t dat = 0; int offset = xga->hwcursor_latch.x - xga->hwcursor_latch.xoff; - int x, x_pos, y_pos; + int x_pos; + int y_pos; int comb = 0; uint32_t *p; int idx = (xga->cursor_data_on) ? 32 : 0; @@ -2031,7 +2050,7 @@ xga_hwcursor_draw(svga_t *svga, int displine) x_pos = offset + svga->x_add; p = buffer32->line[y_pos]; - for (x = 0; x < xga->hwcursor_latch.cur_xsize; x++) { + for (int x = 0; x < xga->hwcursor_latch.cur_xsize; x++) { if (x >= idx) { if (!(x & 0x03)) dat = xga->sprite_data[xga->hwcursor_latch.addr & 0x3ff]; @@ -2067,22 +2086,20 @@ xga_hwcursor_draw(svga_t *svga, int displine) static void xga_render_overscan_left(xga_t *xga, svga_t *svga) { - int i; - if ((xga->displine + svga->y_add) < 0) return; if (svga->scrblank || (xga->h_disp == 0)) return; - for (i = 0; i < svga->x_add; i++) + for (int i = 0; i < svga->x_add; i++) buffer32->line[xga->displine + svga->y_add][i] = svga->overscan_color; } static void xga_render_overscan_right(xga_t *xga, svga_t *svga) { - int i, right; + int right; if ((xga->displine + svga->y_add) < 0) return; @@ -2091,14 +2108,13 @@ xga_render_overscan_right(xga_t *xga, svga_t *svga) return; right = (overscan_x >> 1); - for (i = 0; i < right; i++) + for (int i = 0; i < right; i++) buffer32->line[xga->displine + svga->y_add][svga->x_add + xga->h_disp + i] = svga->overscan_color; } static void xga_render_8bpp(xga_t *xga, svga_t *svga) { - int x; uint32_t *p; uint32_t dat; @@ -2112,7 +2128,7 @@ xga_render_8bpp(xga_t *xga, svga_t *svga) xga->firstline_draw = xga->displine; xga->lastline_draw = xga->displine; - for (x = 0; x <= xga->h_disp; x += 8) { + for (int x = 0; x <= xga->h_disp; x += 8) { dat = *(uint32_t *) (&xga->vram[xga->ma & xga->vram_mask]); p[0] = svga->pallook[dat & 0xff]; p[1] = svga->pallook[(dat >> 8) & 0xff]; @@ -2438,7 +2454,8 @@ void xga_poll(xga_t *xga, svga_t *svga) { uint32_t x; - int wx, wy; + int wx; + int wy; if (!xga->linepos) { if (xga->displine == xga->hwcursor_latch.y && xga->hwcursor_latch.ena) { @@ -2586,7 +2603,7 @@ xga_mca_read(int port, void *priv) ret |= 1; //pclog("[%04X:%08X]: POS Read Port = %x, val = %02x\n", CS, cpu_state.pc, port & 7, xga->pos_regs[port & 7]); - return (ret); + return ret; } static void diff --git a/src/video/video.c b/src/video/video.c index 0253e3c03..7ecb0e5f9 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -91,11 +91,11 @@ int fullchange = 0; int video_grayscale = 0; int video_graytype = 0; int monitor_index_global = 0; -uint32_t *video_6to8 = NULL, - *video_8togs = NULL, - *video_8to32 = NULL, - *video_15to32 = NULL, - *video_16to32 = NULL; +uint32_t *video_6to8 = NULL; +uint32_t *video_8togs = NULL; +uint32_t *video_8to32 = NULL; +uint32_t *video_15to32 = NULL; +uint32_t *video_16to32 = NULL; monitor_t monitors[MONITORS_NUM]; monitor_settings_t monitor_settings[MONITORS_NUM]; atomic_bool doresize_monitors[MONITORS_NUM]; @@ -308,7 +308,6 @@ static png_infop info_ptr[MONITORS_NUM]; static void video_take_screenshot_monitor(const char *fn, uint32_t *buf, int start_x, int start_y, int row_len, int monitor_index) { - int i, x, y; png_bytep *b_rgb = NULL; FILE *fp = NULL; uint32_t temp = 0x00000000; @@ -350,9 +349,9 @@ video_take_screenshot_monitor(const char *fn, uint32_t *buf, int start_x, int st return; } - for (y = 0; y < blit_data_ptr->h; ++y) { + for (int y = 0; y < blit_data_ptr->h; ++y) { b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr[monitor_index], info_ptr[monitor_index])); - for (x = 0; x < blit_data_ptr->w; ++x) { + for (int x = 0; x < blit_data_ptr->w; ++x) { if (buf == NULL) memset(&(b_rgb[y][x * 3]), 0x00, 3); else { @@ -371,7 +370,7 @@ video_take_screenshot_monitor(const char *fn, uint32_t *buf, int start_x, int st png_write_end(png_ptr[monitor_index], NULL); /* cleanup heap allocation */ - for (i = 0; i < blit_data_ptr->h; i++) + for (int i = 0; i < blit_data_ptr->h; i++) if (b_rgb[i]) free(b_rgb[i]); @@ -385,7 +384,8 @@ video_take_screenshot_monitor(const char *fn, uint32_t *buf, int start_x, int st void video_screenshot_monitor(uint32_t *buf, int start_x, int start_y, int row_len, int monitor_index) { - char path[1024], fn[256]; + char path[1024]; + char fn[256]; memset(fn, 0, sizeof(fn)); memset(path, 0, sizeof(path)); @@ -423,14 +423,13 @@ void * video_transform_copy(void *__restrict _Dst, const void *__restrict _Src, size_t _Size) #endif { - int i; uint32_t *dest_ex = (uint32_t *) _Dst; uint32_t *src_ex = (uint32_t *) _Src; _Size /= sizeof(uint32_t); if ((dest_ex != NULL) && (src_ex != NULL)) { - for (i = 0; i < _Size; i++) { + for (size_t i = 0; i < _Size; i++) { *dest_ex = video_color_transform(*src_ex); dest_ex++; src_ex++; @@ -483,10 +482,9 @@ video_blit_memtoscreen_monitor(int x, int y, int w, int h, int monitor_index) uint8_t pixels8(uint32_t *pixels) { - int i; uint8_t temp = 0; - for (i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) temp |= (!!*(pixels + i) << (i ^ 7)); return temp; @@ -511,9 +509,10 @@ pixel_to_color(uint8_t *pixels32, uint8_t pos) void video_blend_monitor(int x, int y, int monitor_index) { - int xx; - uint32_t pixels32_1, pixels32_2; - unsigned int val1, val2; + uint32_t pixels32_1; + uint32_t pixels32_2; + unsigned int val1; + unsigned int val2; static unsigned int carry = 0; if (!herc_blend) @@ -527,7 +526,7 @@ video_blend_monitor(int x, int y, int monitor_index) carry = (val1 & 1) << 7; pixels32_1 = cga_2_table[val1 >> 4] + cga_2_table[val2 >> 4]; pixels32_2 = cga_2_table[val1 & 0xf] + cga_2_table[val2 & 0xf]; - for (xx = 0; xx < 4; xx++) { + for (uint8_t xx = 0; xx < 4; xx++) { monitors[monitor_index].target_buffer->line[y][x + xx] = pixel_to_color((uint8_t *) &pixels32_1, xx); monitors[monitor_index].target_buffer->line[y][x + (xx | 4)] = pixel_to_color((uint8_t *) &pixels32_2, xx); } @@ -536,9 +535,7 @@ video_blend_monitor(int x, int y, int monitor_index) void video_process_8_monitor(int x, int y, int monitor_index) { - int xx; - - for (xx = 0; xx < x; xx++) { + for (int xx = 0; xx < x; xx++) { if (monitors[monitor_index].target_buffer->line[y][xx] <= 0xff) monitors[monitor_index].target_buffer->line[y][xx] = monitors[monitor_index].mon_pal_lookup[monitors[monitor_index].target_buffer->line[y][xx]]; else @@ -630,9 +627,8 @@ video_update_timing(void) int *vid_timing_write_b = NULL; int *vid_timing_write_l = NULL; int *vid_timing_write_w = NULL; - int i = 0; - for (i = 0; i < MONITORS_NUM; i++) { + for (uint8_t i = 0; i < MONITORS_NUM; i++) { monitor_vid_timings = monitors[i].mon_vid_timings; if (!monitor_vid_timings) continue; @@ -683,7 +679,8 @@ video_update_timing(void) int calc_6to8(int c) { - int ic, i8; + int ic; + int i8; double d8; ic = c; @@ -700,8 +697,12 @@ calc_6to8(int c) int calc_8to32(int c) { - int b, g, r; - double db, dg, dr; + int b; + int g; + int r; + double db; + double dg; + double dr; b = (c & 3); g = ((c >> 2) & 7); @@ -719,8 +720,12 @@ calc_8to32(int c) int calc_15to32(int c) { - int b, g, r; - double db, dg, dr; + int b; + int g; + int r; + double db; + double dg; + double dr; b = (c & 31); g = ((c >> 5) & 31); @@ -738,8 +743,12 @@ calc_15to32(int c) int calc_16to32(int c) { - int b, g, r; - double db, dg, dr; + int b; + int g; + int r; + double db; + double dg; + double dr; b = (c & 31); g = ((c >> 5) & 63); @@ -757,12 +766,10 @@ calc_16to32(int c) void hline(bitmap_t *b, int x1, int y, int x2, uint32_t col) { - int x; - if (y < 0 || y >= b->h) return; - for (x = x1; x < x2; x++) + for (int x = x1; x < x2; x++) b->line[y][x] = col; } @@ -800,15 +807,14 @@ bitmap_t * create_bitmap(int x, int y) { bitmap_t *b = malloc(sizeof(bitmap_t) + (y * sizeof(uint32_t *))); - int c; b->dat = malloc((size_t) x * y * 4); - for (c = 0; c < y; c++) + for (int c = 0; c < y; c++) b->line[c] = &(b->dat[c * x]); b->w = x; b->h = y; - return (b); + return b; } void @@ -871,7 +877,8 @@ video_monitor_close(int monitor_index) void video_init(void) { - int c, d; + int c; + int d; uint8_t total[2] = { 0, 1 }; for (c = 0; c < 16; c++) { @@ -966,7 +973,8 @@ video_force_resize_set_monitor(uint8_t res, int monitor_index) void loadfont_common(FILE *f, int format) { - int c, d; + int c; + int d; switch (format) { case 0: /* MDA */ diff --git a/src/win/win_opendir.c b/src/win/win_opendir.c index a3537a546..731cbd33a 100644 --- a/src/win/win_opendir.c +++ b/src/win/win_opendir.c @@ -72,7 +72,7 @@ opendir(const char *name) } /* All OK. */ - return (p); + return p; } /* Close an open directory. */ @@ -80,7 +80,7 @@ int closedir(DIR *p) { if (p == NULL) - return (0); + return 0; _findclose(p->handle); @@ -88,7 +88,7 @@ closedir(DIR *p) free(p->dta); free(p); - return (0); + return 0; } /* diff --git a/src/win/win_preferences.c b/src/win/win_preferences.c index 2dcd04790..a0d3fcd7b 100644 --- a/src/win/win_preferences.c +++ b/src/win/win_preferences.c @@ -168,8 +168,7 @@ preferences_settings_changed(void) static int preferences_indexof(HWND combo, LPARAM itemdata) { - int i; - for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) + for (int i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) if (SendMessage(combo, CB_GETITEMDATA, i, 0) == itemdata) return i; @@ -267,10 +266,9 @@ PreferencesDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_DESTROY: { - int i; LRESULT temp; HWND combo = GetDlgItem(hdlg, IDC_COMBO_ICON); - for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) { + for (int i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) { temp = SendMessage(combo, CB_GETITEMDATA, i, 0); if (temp) { free((void *) temp); diff --git a/src/win/win_snd_gain.c b/src/win/win_snd_gain.c index 358942e39..7b423f3fb 100644 --- a/src/win/win_snd_gain.c +++ b/src/win/win_snd_gain.c @@ -79,7 +79,7 @@ SoundGainDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) break; } - return (FALSE); + return FALSE; } void diff --git a/src/win/win_specify_dim.c b/src/win/win_specify_dim.c index c40cf35d8..0c9d46db9 100644 --- a/src/win/win_specify_dim.c +++ b/src/win/win_specify_dim.c @@ -47,7 +47,7 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM RECT r; uint32_t temp_x = 0; uint32_t temp_y = 0; - int dpi = 96; + int dpi = 96; int lock; LPTSTR lptsTemp; char *stransi; diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index f41135f13..5f25ba7fe 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -492,11 +492,20 @@ ui_sb_set_ready(int ready) void ui_sb_update_panes(void) { - int i, id; - int cart_int, mfm_int, xta_int, esdi_int, ide_int, scsi_int; + int i; + int id; + int cart_int; + int mfm_int; + int xta_int; + int esdi_int; + int ide_int; + int scsi_int; int edge = 0; - int c_mfm, c_esdi, c_xta; - int c_ide, c_scsi; + int c_mfm; + int c_esdi; + int c_xta; + int c_ide; + int c_scsi; int do_net; char *hdc_name; @@ -930,7 +939,8 @@ void StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) { RECT rectDialog; - int dw, dh; + int dw; + int dh; /* Get current DPI and calculate icon sizes */ dpi = win_get_dpi(hwndParent); diff --git a/src/win/win_toolbar.c b/src/win/win_toolbar.c index 6b1edefb2..5c8621eea 100644 --- a/src/win/win_toolbar.c +++ b/src/win/win_toolbar.c @@ -204,5 +204,5 @@ ui_window_title(wchar_t *s) s = wTitle; } - return (s); + return s; }