From fac66529f214e69a18885d2a51e9d18a8488254d Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Mon, 25 Feb 2019 10:19:38 +0000 Subject: [PATCH] compact parity table --- i8080.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/i8080.cpp b/i8080.cpp index 3157120..408f2ae 100644 --- a/i8080.cpp +++ b/i8080.cpp @@ -84,27 +84,17 @@ void i8080::daa() { flags.C = c; } -const uint8_t parity_table[] PROGMEM = { - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, +const uint8_t partab[] PROGMEM = { + 0x69, 0x96, 0x96, 0x69, 0x96, 0x69, 0x69, 0x96, + 0x96, 0x69, 0x69, 0x96, 0x69, 0x96, 0x96, 0x69, + 0x96, 0x69, 0x69, 0x96, 0x69, 0x96, 0x96, 0x69, + 0x69, 0x96, 0x96, 0x69, 0x96, 0x69, 0x69, 0x96, }; uint8_t parity_tbl(uint8_t r) { - return pgm_read_byte(parity_table + r); + uint8_t i = r / 8, b = pgm_read_byte(partab + i); + uint8_t m = (1 << (r % 8)); + return m == (b & m); } #define O(o, e) case o: e(); break;