---------------------------------------------------------------------- Patch name: patch.vga-dohzono Author: dohzono (uploaded by cbothamy) Date: 31 oct 2002 Status: Proposed (we have to do some tests, e.g. compiling with MSVC) Detailed description: This patch adds VGA write mode 2 support and includes various speed improvements posted by the author on the ml. Here are very detailed (nice!) notes from the author : ------------- The feature I added is "VGA write mode 2" support (which is required by Japanese Windows 9x). Not tested much, yet. The original version causes panic like this. | case 2: /* write mode 2 */ | if (BX_VGA_THIS s.graphics_ctrl.raster_op) | BX_PANIC(("vga_mem_write: write mode 2: op = %u", | (unsigned) BX_VGA_THIS s.graphics_ctrl.raster_op)); I consulted its specification to the FreeVGA project's documentation. | Write Mode 2: | | Write Mode 2 is used to unpack a pixel value packed into the lower 4 | bits of the host data byte into the 4 display planes. In the byte | from the host, the bit representing each plane will be replicated | across all 8 bits of the corresponding planes. Then the operation | specified by the Logical Operation field is performed on the | resulting data and the data in the read latches. The Bit Mask field | is then used to select between the resulting data and data from the | latch register. Finally, the resulting data is written to the | display memory planes enabled in the Memory Plane Write Enable | field. ------------- I also made some changes for speed. Some are (really) dirty hacks, so I want someone to make them clean. * The file "rdat.h" contains rotated data which makes bochs need not to calculate them each time. For example: /* perform rotate on CPU data */ value = (value >> BX_VGA_THIS s.graphics_ctrl.data_rotate) | (value << (8 - BX_VGA_THIS s.graphics_ctrl.data_rotate)); can be: /* perform rotate on CPU data */ value = rdatp[value]; `rdatp' is changed with the variable `data_rotate'. case 3: /* Data Rotate */ BX_VGA_THIS s.graphics_ctrl.data_rotate = value & 0x07; rdatp = rdat[value & 0x07]; * I made some variable scopes to be local. GNU C compier seems to generate better code for this. unsigned xti, yti; ... for (yti=0; yti> 3) & 0x03; /* ??? */ break; @@ -1308,7 +1294,6 @@ { // specific VBE code display update code // this is partly copied/modified from the 320x200x8 update more below - unsigned xc, yc, xti, yti; Bit8u color; unsigned r, c; unsigned long byte_offset; @@ -1320,10 +1305,8 @@ // incl virtual xres correction Bit32u start_offset = ((BX_VGA_THIS s.vbe_offset_y) * (BX_VGA_THIS s.vbe_virtual_xres)) + BX_VGA_THIS s.vbe_offset_x; - yti = 0; - for (yc=0; ycgraphics_tile_update(BX_VGA_THIS s.tile, xc, yc); } - xti++; } - yti++; } old_iWidth = iWidth; old_iHeight = iHeight; @@ -1365,7 +1346,6 @@ Bit8u color; unsigned bit_no, r, c, x, y; unsigned long byte_offset, start_addr; - unsigned xc, yc, xti, yti; start_addr = (BX_VGA_THIS s.CRTC.reg[0x0c] << 8) | BX_VGA_THIS s.CRTC.reg[0x0d]; @@ -1389,10 +1369,8 @@ if (BX_VGA_THIS s.graphics_ctrl.memory_mapping == 3) { // CGA 640x200x2 - yti = 0; - for (yc=0; ycgraphics_tile_update(BX_VGA_THIS s.tile, xc, yc); } - xti++; } - yti++; } } else { // output data in serial fashion with each display plane // output on its associated serial output. Standard EGA/VGA format @@ -1426,10 +1402,8 @@ line_compare = BX_VGA_THIS s.line_compare; if (BX_VGA_THIS s.y_doublescan) line_compare >>= 1; - yti = 0; - for (yc=0; ycgraphics_tile_update(BX_VGA_THIS s.tile, xc, yc); } - xti++; } - yti++; } } break; // case 0 @@ -1494,10 +1466,8 @@ old_iHeight = iHeight; } - yti = 0; - for (yc=0; ycgraphics_tile_update(BX_VGA_THIS s.tile, xc, yc); } - xti++; } - yti++; } /* CGA 320x200x4 end */ @@ -1549,10 +1517,8 @@ old_iWidth = iWidth; } - yti = 0; - for (yc=0; ycgraphics_tile_update(BX_VGA_THIS s.tile, xc, yc); } - xti++; } - yti++; } } @@ -1585,10 +1549,8 @@ old_iHeight = iHeight; } - yti = 0; - for (yc=0; ycgraphics_tile_update(BX_VGA_THIS s.tile, xc, yc); } - xti++; } - yti++; } } break; // case 2 @@ -1727,7 +1687,46 @@ iWidth = cWidth * BX_VGA_THIS s.CRTC.reg[1]; iHeight = 400; } else { +#if 0 rows = (VDE+1)/(MSL+1); +#else + switch (MSL) { +#define case_n(n) case n: rows = (VDE + 1)/((n) + 1); break + case_n(0x01); + case_n(0x02); + case_n(0x03); + case_n(0x04); + case_n(0x05); + case_n(0x06); + case_n(0x07); + case_n(0x08); + case_n(0x09); + case_n(0x0a); + case_n(0x0b); + case_n(0x0c); + case_n(0x0d); + case_n(0x0e); + case_n(0x0f); + case_n(0x10); + case_n(0x11); + case_n(0x12); + case_n(0x13); + case_n(0x14); + case_n(0x15); + case_n(0x16); + case_n(0x17); + case_n(0x18); + case_n(0x19); + case_n(0x1a); + case_n(0x1b); + case_n(0x1c); + case_n(0x1d); + case_n(0x1e); + case_n(0x1f); +#undef case_n + default: rows = 25; + } +#endif if (rows > BX_MAX_TEXT_LINES) BX_PANIC(("text rows>%d: %d",BX_MAX_TEXT_LINES,rows)); cWidth = ((BX_VGA_THIS s.sequencer.reg1 & 0x01) == 1) ? 8 : 9; @@ -2006,8 +2005,7 @@ const Bit8u enable_set_reset = BX_VGA_THIS s.graphics_ctrl.enable_set_reset; /* perform rotate on CPU data in case its needed */ if (BX_VGA_THIS s.graphics_ctrl.data_rotate) { - value = (value >> BX_VGA_THIS s.graphics_ctrl.data_rotate) | - (value << (8 - BX_VGA_THIS s.graphics_ctrl.data_rotate)); + value = rdatp[value]; } new_val[0] = BX_VGA_THIS s.graphics_ctrl.latch[0] & ~bitmask; new_val[1] = BX_VGA_THIS s.graphics_ctrl.latch[1] & ~bitmask; @@ -2183,8 +2181,7 @@ /* perform rotate on CPU data */ if (BX_VGA_THIS s.graphics_ctrl.data_rotate) { - value = (value >> BX_VGA_THIS s.graphics_ctrl.data_rotate) | - (value << (8 - BX_VGA_THIS s.graphics_ctrl.data_rotate)); + value = rdatp[value]; } new_val[0] = BX_VGA_THIS s.graphics_ctrl.latch[0] & ~bitmask; new_val[1] = BX_VGA_THIS s.graphics_ctrl.latch[1] & ~bitmask; @@ -2392,7 +2389,7 @@ bx_vga_c::redraw_area(unsigned x0, unsigned y0, unsigned width, unsigned height) { - unsigned xi, yi, x1, y1, xmax, ymax; + unsigned x1, y1, xmax, ymax; BX_VGA_THIS s.vga_mem_updated = 1; @@ -2413,8 +2410,8 @@ ymax = BX_VGA_THIS s.vbe_yres; } #endif - for (yi=0; yi (xi+X_TILESIZE-1)) continue; @@ -2422,8 +2419,6 @@ // is redraw rectangle outside y boundaries of this tile? if (y1 < yi) continue; if (y0 > (yi+Y_TILESIZE-1)) continue; - unsigned xti = xi/X_TILESIZE; - unsigned yti = yi/Y_TILESIZE; SET_TILE_UPDATED (xti, yti, 1); } } diff -u ../bochs/iodev/vga_tables.h iodev/vga_tables.h --- iodev/vga_tables.h 1970-01-01 01:00:00 +0100 +++ iodev/vga_tables.h 2003-06-16 22:16:25 +0200 @@ -0,0 +1,313 @@ +///////////////////////////////////////////////////////////////////////// +// $Id: patch.vga-mode2-speed-dohzono,v 1.6 2003-06-16 20:41:12 vruppert Exp $ +///////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2002 MandrakeSoft S.A. +// +// MandrakeSoft S.A. +// 43, rue d'Aboukir +// 75002 Paris - France +// http://www.linux-mandrake.com/ +// http://www.mandrakesoft.com/ +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +const Bit8u rdat[][0x100] = { +{ +0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, +0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, +0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, +0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, +0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, +0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, +0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, +0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, +0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, +0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, +0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, +0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, +0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, +0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, +0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, +0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, +0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, +0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, +0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, +0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, +0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, +0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, +0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, +0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, +0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, +0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, +0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, +0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, +0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, +0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, +0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, +},{ +0x00, 0x80, 0x01, 0x81, 0x02, 0x82, 0x03, 0x83, +0x04, 0x84, 0x05, 0x85, 0x06, 0x86, 0x07, 0x87, +0x08, 0x88, 0x09, 0x89, 0x0a, 0x8a, 0x0b, 0x8b, +0x0c, 0x8c, 0x0d, 0x8d, 0x0e, 0x8e, 0x0f, 0x8f, +0x10, 0x90, 0x11, 0x91, 0x12, 0x92, 0x13, 0x93, +0x14, 0x94, 0x15, 0x95, 0x16, 0x96, 0x17, 0x97, +0x18, 0x98, 0x19, 0x99, 0x1a, 0x9a, 0x1b, 0x9b, +0x1c, 0x9c, 0x1d, 0x9d, 0x1e, 0x9e, 0x1f, 0x9f, +0x20, 0xa0, 0x21, 0xa1, 0x22, 0xa2, 0x23, 0xa3, +0x24, 0xa4, 0x25, 0xa5, 0x26, 0xa6, 0x27, 0xa7, +0x28, 0xa8, 0x29, 0xa9, 0x2a, 0xaa, 0x2b, 0xab, +0x2c, 0xac, 0x2d, 0xad, 0x2e, 0xae, 0x2f, 0xaf, +0x30, 0xb0, 0x31, 0xb1, 0x32, 0xb2, 0x33, 0xb3, +0x34, 0xb4, 0x35, 0xb5, 0x36, 0xb6, 0x37, 0xb7, +0x38, 0xb8, 0x39, 0xb9, 0x3a, 0xba, 0x3b, 0xbb, +0x3c, 0xbc, 0x3d, 0xbd, 0x3e, 0xbe, 0x3f, 0xbf, +0x40, 0xc0, 0x41, 0xc1, 0x42, 0xc2, 0x43, 0xc3, +0x44, 0xc4, 0x45, 0xc5, 0x46, 0xc6, 0x47, 0xc7, +0x48, 0xc8, 0x49, 0xc9, 0x4a, 0xca, 0x4b, 0xcb, +0x4c, 0xcc, 0x4d, 0xcd, 0x4e, 0xce, 0x4f, 0xcf, +0x50, 0xd0, 0x51, 0xd1, 0x52, 0xd2, 0x53, 0xd3, +0x54, 0xd4, 0x55, 0xd5, 0x56, 0xd6, 0x57, 0xd7, +0x58, 0xd8, 0x59, 0xd9, 0x5a, 0xda, 0x5b, 0xdb, +0x5c, 0xdc, 0x5d, 0xdd, 0x5e, 0xde, 0x5f, 0xdf, +0x60, 0xe0, 0x61, 0xe1, 0x62, 0xe2, 0x63, 0xe3, +0x64, 0xe4, 0x65, 0xe5, 0x66, 0xe6, 0x67, 0xe7, +0x68, 0xe8, 0x69, 0xe9, 0x6a, 0xea, 0x6b, 0xeb, +0x6c, 0xec, 0x6d, 0xed, 0x6e, 0xee, 0x6f, 0xef, +0x70, 0xf0, 0x71, 0xf1, 0x72, 0xf2, 0x73, 0xf3, +0x74, 0xf4, 0x75, 0xf5, 0x76, 0xf6, 0x77, 0xf7, +0x78, 0xf8, 0x79, 0xf9, 0x7a, 0xfa, 0x7b, 0xfb, +0x7c, 0xfc, 0x7d, 0xfd, 0x7e, 0xfe, 0x7f, 0xff, +},{ +0x00, 0x40, 0x80, 0xc0, 0x01, 0x41, 0x81, 0xc1, +0x02, 0x42, 0x82, 0xc2, 0x03, 0x43, 0x83, 0xc3, +0x04, 0x44, 0x84, 0xc4, 0x05, 0x45, 0x85, 0xc5, +0x06, 0x46, 0x86, 0xc6, 0x07, 0x47, 0x87, 0xc7, +0x08, 0x48, 0x88, 0xc8, 0x09, 0x49, 0x89, 0xc9, +0x0a, 0x4a, 0x8a, 0xca, 0x0b, 0x4b, 0x8b, 0xcb, +0x0c, 0x4c, 0x8c, 0xcc, 0x0d, 0x4d, 0x8d, 0xcd, +0x0e, 0x4e, 0x8e, 0xce, 0x0f, 0x4f, 0x8f, 0xcf, +0x10, 0x50, 0x90, 0xd0, 0x11, 0x51, 0x91, 0xd1, +0x12, 0x52, 0x92, 0xd2, 0x13, 0x53, 0x93, 0xd3, +0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 0xe0, +0x01, 0x21, 0x41, 0x61, 0x81, 0xa1, 0xc1, 0xe1, +0x02, 0x22, 0x42, 0x62, 0x82, 0xa2, 0xc2, 0xe2, +0x03, 0x23, 0x43, 0x63, 0x83, 0xa3, 0xc3, 0xe3, +0x04, 0x24, 0x44, 0x64, 0x84, 0xa4, 0xc4, 0xe4, +0x05, 0x25, 0x45, 0x65, 0x85, 0xa5, 0xc5, 0xe5, +0x06, 0x26, 0x46, 0x66, 0x86, 0xa6, 0xc6, 0xe6, +0x07, 0x27, 0x47, 0x67, 0x87, 0xa7, 0xc7, 0xe7, +0x08, 0x28, 0x48, 0x68, 0x88, 0xa8, 0xc8, 0xe8, +0x09, 0x29, 0x49, 0x69, 0x89, 0xa9, 0xc9, 0xe9, +0x0a, 0x2a, 0x4a, 0x6a, 0x8a, 0xaa, 0xca, 0xea, +0x0b, 0x2b, 0x4b, 0x6b, 0x8b, 0xab, 0xcb, 0xeb, +0x0c, 0x2c, 0x4c, 0x6c, 0x8c, 0xac, 0xcc, 0xec, +0x0d, 0x2d, 0x4d, 0x6d, 0x8d, 0xad, 0xcd, 0xed, +0x0e, 0x2e, 0x4e, 0x6e, 0x8e, 0xae, 0xce, 0xee, +0x0f, 0x2f, 0x4f, 0x6f, 0x8f, 0xaf, 0xcf, 0xef, +0x10, 0x30, 0x50, 0x70, 0x90, 0xb0, 0xd0, 0xf0, +0x11, 0x31, 0x51, 0x71, 0x91, 0xb1, 0xd1, 0xf1, +0x12, 0x32, 0x52, 0x72, 0x92, 0xb2, 0xd2, 0xf2, +0x13, 0x33, 0x53, 0x73, 0x93, 0xb3, 0xd3, 0xf3, +0x14, 0x34, 0x54, 0x74, 0x94, 0xb4, 0xd4, 0xf4, +0x15, 0x35, 0x55, 0x75, 0x95, 0xb5, 0xd5, 0xf5, +0x16, 0x36, 0x56, 0x76, 0x96, 0xb6, 0xd6, 0xf6, +0x17, 0x37, 0x57, 0x77, 0x97, 0xb7, 0xd7, 0xf7, +0x18, 0x38, 0x58, 0x78, 0x98, 0xb8, 0xd8, 0xf8, +0x19, 0x39, 0x59, 0x79, 0x99, 0xb9, 0xd9, 0xf9, +0x1a, 0x3a, 0x5a, 0x7a, 0x9a, 0xba, 0xda, 0xfa, +0x1b, 0x3b, 0x5b, 0x7b, 0x9b, 0xbb, 0xdb, 0xfb, +0x1c, 0x3c, 0x5c, 0x7c, 0x9c, 0xbc, 0xdc, 0xfc, +0x1d, 0x3d, 0x5d, 0x7d, 0x9d, 0xbd, 0xdd, 0xfd, +0x1e, 0x3e, 0x5e, 0x7e, 0x9e, 0xbe, 0xde, 0xfe, +0x1f, 0x3f, 0x5f, 0x7f, 0x9f, 0xbf, 0xdf, 0xff, +},{ +0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, +0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, +0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, +0x81, 0x91, 0xa1, 0xb1, 0xc1, 0xd1, 0xe1, 0xf1, +0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, +0x82, 0x92, 0xa2, 0xb2, 0xc2, 0xd2, 0xe2, 0xf2, +0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, +0x83, 0x93, 0xa3, 0xb3, 0xc3, 0xd3, 0xe3, 0xf3, +0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, +0x84, 0x94, 0xa4, 0xb4, 0xc4, 0xd4, 0xe4, 0xf4, +0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, +0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, +0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, +0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, +0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, +0x87, 0x97, 0xa7, 0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f, +0x47, 0x4f, 0x57, 0x5f, 0x67, 0x6f, 0x77, 0x7f, +0x87, 0x8f, 0x97, 0x9f, 0xa7, 0xaf, 0xb7, 0xbf, +0xc7, 0xcf, 0xd7, 0xdf, 0xe7, 0xef, 0xf7, 0xff, +},{ +0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c, +0x20, 0x24, 0x28, 0x2c, 0x30, 0x34, 0x38, 0x3c, +0x40, 0x44, 0x48, 0x4c, 0x50, 0x54, 0x58, 0x5c, +0x60, 0x64, 0x68, 0x6c, 0x70, 0x74, 0x78, 0x7c, +0x80, 0x84, 0x88, 0x8c, 0x90, 0x94, 0x98, 0x9c, +0xa0, 0xa4, 0xa8, 0xac, 0xb0, 0xb4, 0xb8, 0xbc, +0xc0, 0xc4, 0xc8, 0xcc, 0xd0, 0xd4, 0xd8, 0xdc, +0xe0, 0xe4, 0xe8, 0xec, 0xf0, 0xf4, 0xf8, 0xfc, +0x01, 0x05, 0x09, 0x0d, 0x11, 0x15, 0x19, 0x1d, +0x21, 0x25, 0x29, 0x2d, 0x31, 0x35, 0x39, 0x3d, +0x41, 0x45, 0x49, 0x4d, 0x51, 0x55, 0x59, 0x5d, +0x61, 0x65, 0x69, 0x6d, 0x71, 0x75, 0x79, 0x7d, +0x81, 0x85, 0x89, 0x8d, 0x91, 0x95, 0x99, 0x9d, +0xa1, 0xa5, 0xa9, 0xad, 0xb1, 0xb5, 0xb9, 0xbd, +0xc1, 0xc5, 0xc9, 0xcd, 0xd1, 0xd5, 0xd9, 0xdd, +0xe1, 0xe5, 0xe9, 0xed, 0xf1, 0xf5, 0xf9, 0xfd, +0x02, 0x06, 0x0a, 0x0e, 0x12, 0x16, 0x1a, 0x1e, +0x22, 0x26, 0x2a, 0x2e, 0x32, 0x36, 0x3a, 0x3e, +0x42, 0x46, 0x4a, 0x4e, 0x52, 0x56, 0x5a, 0x5e, +0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76, 0x7a, 0x7e, +0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e, +0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe, +0xc2, 0xc6, 0xca, 0xce, 0xd2, 0xd6, 0xda, 0xde, +0xe2, 0xe6, 0xea, 0xee, 0xf2, 0xf6, 0xfa, 0xfe, +0x03, 0x07, 0x0b, 0x0f, 0x13, 0x17, 0x1b, 0x1f, +0x23, 0x27, 0x2b, 0x2f, 0x33, 0x37, 0x3b, 0x3f, +0x43, 0x47, 0x4b, 0x4f, 0x53, 0x57, 0x5b, 0x5f, +0x63, 0x67, 0x6b, 0x6f, 0x73, 0x77, 0x7b, 0x7f, +0x83, 0x87, 0x8b, 0x8f, 0x93, 0x97, 0x9b, 0x9f, +0xa3, 0xa7, 0xab, 0xaf, 0xb3, 0xb7, 0xbb, 0xbf, +0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7, 0xdb, 0xdf, +0xe3, 0xe7, 0xeb, 0xef, 0xf3, 0xf7, 0xfb, 0xff, +},{ +0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, +0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, +0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, +0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, +0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, +0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, +0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, +0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, +0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, +0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, +0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, +0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, +0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, +0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, +0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, +0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe, +0x01, 0x03, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, +0x11, 0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f, +0x21, 0x23, 0x25, 0x27, 0x29, 0x2b, 0x2d, 0x2f, +0x31, 0x33, 0x35, 0x37, 0x39, 0x3b, 0x3d, 0x3f, +0x41, 0x43, 0x45, 0x47, 0x49, 0x4b, 0x4d, 0x4f, +0x51, 0x53, 0x55, 0x57, 0x59, 0x5b, 0x5d, 0x5f, +0x61, 0x63, 0x65, 0x67, 0x69, 0x6b, 0x6d, 0x6f, +0x71, 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d, 0x7f, +0x81, 0x83, 0x85, 0x87, 0x89, 0x8b, 0x8d, 0x8f, +0x91, 0x93, 0x95, 0x97, 0x99, 0x9b, 0x9d, 0x9f, +0xa1, 0xa3, 0xa5, 0xa7, 0xa9, 0xab, 0xad, 0xaf, +0xb1, 0xb3, 0xb5, 0xb7, 0xb9, 0xbb, 0xbd, 0xbf, +0xc1, 0xc3, 0xc5, 0xc7, 0xc9, 0xcb, 0xcd, 0xcf, +0xd1, 0xd3, 0xd5, 0xd7, 0xd9, 0xdb, 0xdd, 0xdf, +0xe1, 0xe3, 0xe5, 0xe7, 0xe9, 0xeb, 0xed, 0xef, +0xf1, 0xf3, 0xf5, 0xf7, 0xf9, 0xfb, 0xfd, 0xff, +} +}; + + +static const Bit8u ccdat[16][4] = { + { 0x00, 0x00, 0x00, 0x00 }, + { 0xff, 0x00, 0x00, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0xff, 0xff, 0x00, 0x00 }, + { 0x00, 0x00, 0xff, 0x00 }, + { 0xff, 0x00, 0xff, 0x00 }, + { 0x00, 0xff, 0xff, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 }, + { 0x00, 0x00, 0x00, 0xff }, + { 0xff, 0x00, 0x00, 0xff }, + { 0x00, 0xff, 0x00, 0xff }, + { 0xff, 0xff, 0x00, 0xff }, + { 0x00, 0x00, 0xff, 0xff }, + { 0xff, 0x00, 0xff, 0xff }, + { 0x00, 0xff, 0xff, 0xff }, + { 0xff, 0xff, 0xff, 0xff }, +};