From a7af82d1ff69d3f90957a7345df07946044f2177 Mon Sep 17 00:00:00 2001 From: redcode Date: Fri, 11 Aug 2023 21:47:13 +0200 Subject: [PATCH] Coding style changes; `Z_USIZE_BITS` -> `Z_USIZE_WIDTH`. --- sources/Z80.c | 36 ++++++++++++------------------------ sources/test-Z80.c | 16 +++++++--------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/sources/Z80.c b/sources/Z80.c index 43549117..3e29bf1a 100644 --- a/sources/Z80.c +++ b/sources/Z80.c @@ -248,8 +248,7 @@ static zuint8 const pf_parity_table[256] = { /* C */ 4, 0, 0, 4, 0, 4, 4, 0, 0, 4, 4, 0, 4, 0, 0, 4, /* D */ 0, 4, 4, 0, 4, 0, 0, 4, 4, 0, 0, 4, 0, 4, 4, 0, /* E */ 0, 4, 4, 0, 4, 0, 0, 4, 4, 0, 0, 4, 0, 4, 4, 0, -/* F */ 4, 0, 0, 4, 0, 4, 4, 0, 0, 4, 4, 0, 4, 0, 0, 4 -}; +/* F */ 4, 0, 0, 4, 0, 4, 4, 0, 0, 4, 4, 0, 4, 0, 0, 4}; #define PF_PARITY(value) pf_parity_table[value] @@ -313,8 +312,7 @@ static zusize const j_k_table[8] = { Z_MEMBER_OFFSET(Z80, hl.uint8_values.at_1), Z_MEMBER_OFFSET(Z80, hl.uint8_values.at_0), 0, - Z_MEMBER_OFFSET(Z80, af.uint8_values.at_1) -}; + Z_MEMBER_OFFSET(Z80, af.uint8_values.at_1)}; static zusize const o_p_table[8] = { Z_MEMBER_OFFSET(Z80, bc.uint8_values.at_1), @@ -324,8 +322,7 @@ static zusize const o_p_table[8] = { Z_MEMBER_OFFSET(Z80, xy.uint8_values.at_1), Z_MEMBER_OFFSET(Z80, xy.uint8_values.at_0), 0, - Z_MEMBER_OFFSET(Z80, af.uint8_values.at_1) -}; + Z_MEMBER_OFFSET(Z80, af.uint8_values.at_1)}; #define REGISTER_8(table, offset, shift) \ *((zuint8 *)self + table[(DATA[offset] shift) & 7]) @@ -354,22 +351,19 @@ static zusize const s_table[4] = { Z_MEMBER_OFFSET(Z80, bc.uint16_value), Z_MEMBER_OFFSET(Z80, de.uint16_value), Z_MEMBER_OFFSET(Z80, hl.uint16_value), - Z_MEMBER_OFFSET(Z80, sp) -}; + Z_MEMBER_OFFSET(Z80, sp)}; static zusize const t_table[4] = { Z_MEMBER_OFFSET(Z80, bc.uint16_value), Z_MEMBER_OFFSET(Z80, de.uint16_value), Z_MEMBER_OFFSET(Z80, hl.uint16_value), - Z_MEMBER_OFFSET(Z80, af.uint16_value) -}; + Z_MEMBER_OFFSET(Z80, af.uint16_value)}; static zusize const w_table[4] = { Z_MEMBER_OFFSET(Z80, bc.uint16_value), Z_MEMBER_OFFSET(Z80, de.uint16_value), Z_MEMBER_OFFSET(Z80, xy.uint16_value), - Z_MEMBER_OFFSET(Z80, sp) -}; + Z_MEMBER_OFFSET(Z80, sp)}; #define REGISTER_16(table, offset) \ *(zuint16 *)(void *)((zchar *)self + table[(DATA[offset] >> 4) & 3]) @@ -1793,8 +1787,7 @@ static Insn const insn_table[256] = { /* C */ ret_Z, pop_TT, jp_Z_WORD, jp_WORD, call_Z_WORD, push_TT, U_a_BYTE, rst_N, ret_Z, ret, jp_Z_WORD, cb_prefix, call_Z_WORD, call_WORD, U_a_BYTE, rst_N, /* D */ ret_Z, pop_TT, jp_Z_WORD, out_vBYTE_a, call_Z_WORD, push_TT, U_a_BYTE, rst_N, ret_Z, exx, jp_Z_WORD, in_a_vBYTE, call_Z_WORD, dd_prefix, U_a_BYTE, rst_N, /* E */ ret_Z, pop_TT, jp_Z_WORD, ex_vsp_hl, call_Z_WORD, push_TT, U_a_BYTE, rst_N, ret_Z, jp_hl, jp_Z_WORD, ex_de_hl, call_Z_WORD, ed_prefix, U_a_BYTE, rst_N, -/* F */ ret_Z, pop_TT, jp_Z_WORD, di, call_Z_WORD, push_TT, U_a_BYTE, rst_N, ret_Z, ld_sp_hl, jp_Z_WORD, ei, call_Z_WORD, fd_prefix, U_a_BYTE, rst_N -}; +/* F */ ret_Z, pop_TT, jp_Z_WORD, di, call_Z_WORD, push_TT, U_a_BYTE, rst_N, ret_Z, ld_sp_hl, jp_Z_WORD, ei, call_Z_WORD, fd_prefix, U_a_BYTE, rst_N}; static Insn const cb_insn_table[256] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ @@ -1813,8 +1806,7 @@ static Insn const cb_insn_table[256] = { /* C */ M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, /* D */ M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, /* E */ M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, -/* F */ M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K -}; +/* F */ M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_K, M_N_vhl, M_N_K}; static Insn const ed_insn_table[256] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ @@ -1833,8 +1825,7 @@ static Insn const ed_insn_table[256] = { /* C */ ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, /* D */ ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, /* E */ ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, -/* F */ ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal -}; +/* F */ ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal, ed_illegal}; static Insn const xy_insn_table[256] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ @@ -1853,8 +1844,7 @@ static Insn const xy_insn_table[256] = { /* C */ xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_cb_prefix, xy_illegal, xy_illegal, xy_illegal, xy_illegal, /* D */ xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_xy, xy_illegal, xy_illegal, /* E */ xy_illegal, pop_XY, xy_illegal, ex_vsp_XY, xy_illegal, push_XY, xy_illegal, xy_illegal, xy_illegal, jp_XY, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, -/* F */ xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, ld_sp_XY, xy_illegal, xy_illegal, xy_illegal, xy_xy, xy_illegal, xy_illegal -}; +/* F */ xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, xy_illegal, ld_sp_XY, xy_illegal, xy_illegal, xy_illegal, xy_xy, xy_illegal, xy_illegal}; static Insn const xy_cb_insn_table[256] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ @@ -1873,8 +1863,7 @@ static Insn const xy_cb_insn_table[256] = { /* C */ M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, /* D */ M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, /* E */ M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, -/* F */ M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K -}; +/* F */ M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET_K, M_N_vXYpOFFSET, M_N_vXYpOFFSET_K}; /* MARK: - Instructions: Prefix Handling */ @@ -2038,8 +2027,7 @@ INSN(hook) /* C */ 1, 0, 3, 0, 3, 0, 0, 1, 1, 0, 3, 0, 3, 3, 0, 1, /* D */ 1, 0, 3, 0, 3, 0, 0, 1, 1, 0, 3, 0, 3, 0, 0, 1, /* E */ 1, 0, 3, 0, 3, 0, 0, 1, 1, 0, 3, 0, 3, 0, 0, 1, - /* F */ 1, 0, 3, 0, 3, 0, 0, 1, 1, 0, 3, 0, 3, 0, 0, 1 - }; + /* F */ 1, 0, 3, 0, 3, 0, 0, 1, 1, 0, 3, 0, 3, 0, 0, 1}; #endif diff --git a/sources/test-Z80.c b/sources/test-Z80.c index 70c6a0af..ffed0aa5 100644 --- a/sources/test-Z80.c +++ b/sources/test-Z80.c @@ -66,7 +66,7 @@ typedef struct { char const* file_path; /* Total number of clock cycles executed when the test is passed. */ - zusize cycles_expected[1 + (Z_USIZE_BITS < 64)]; + zusize cycles_expected[1 + (Z_USIZE_WIDTH < 64)]; /* Size of the file. */ zuint16 file_size; @@ -96,7 +96,7 @@ typedef struct { /* MARK: - Global Variables */ -#if Z_USIZE_BITS < 64 +#if Z_USIZE_WIDTH < 64 # define C(high, low) {Z_USIZE(0x##low), Z_USIZE(0x##high)} #else # define C(high, low) {Z_USIZE(0x##high##low)} @@ -124,8 +124,7 @@ static Test const tests[22] = { {"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80flags.tap", C(0, 212F17D5) /* 556,734,421 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32}, {"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80docflags.tap", C(0, 2152FFDA) /* 559,087,578 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32}, {"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80ccf.tap", C(0, 23F34E43) /* 603,147,843 */, 14875, 91, 14783, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32}, - {"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80memptr.tap", C(0, 219FC276) /* 564,118,134 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32} -}; + {"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80memptr.tap", C(0, 219FC276) /* 564,118,134 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32}}; #undef C @@ -133,8 +132,7 @@ static struct {char const *key; zuint8 options;} const cpu_models[4] = { {"zilog-nmos", Z80_MODEL_ZILOG_NMOS}, {"zilog-cmos", Z80_MODEL_ZILOG_CMOS}, {"nec-nmos", Z80_MODEL_NEC_NMOS }, - {"st-cmos", Z80_MODEL_ST_CMOS } -}; + {"st-cmos", Z80_MODEL_ST_CMOS }}; static char const new_line[2] = "\n"; @@ -494,7 +492,7 @@ static zuint8 run_test(int test_index) zboolean passed; zuint i = 0; -# if Z_USIZE_BITS < 64 +# if Z_USIZE_WIDTH < 64 zuint32 j = 0; # endif @@ -615,7 +613,7 @@ static zuint8 run_test(int test_index) if (verbosity >= 3) printf("* Running program%s", show_test_output ? ":\n\n" : "... "); -# if Z_USIZE_BITS < 64 +# if Z_USIZE_WIDTH < 64 for (i = 0; i < test->cycles_expected[1];) { RUN(&cpu, Z_UINT32_MAXIMUM / 2); @@ -649,7 +647,7 @@ static zuint8 run_test(int test_index) && lines == test->lines_expected && columns == test->columns_expected && cycles == test->cycles_expected[0] -# if Z_USIZE_BITS < 64 +# if Z_USIZE_WIDTH < 64 && i == test->cycles_expected[1] # endif ;