| 1 | /* i1401_dat.h: IBM 1401 character conversion tables\r |
| 2 | \r |
| 3 | Copyright (c) 1993-2005, Robert M. Supnik\r |
| 4 | \r |
| 5 | Permission is hereby granted, free of charge, to any person obtaining a\r |
| 6 | copy of this software and associated documentation files (the "Software"),\r |
| 7 | to deal in the Software without restriction, including without limitation\r |
| 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense,\r |
| 9 | and/or sell copies of the Software, and to permit persons to whom the\r |
| 10 | Software is furnished to do so, subject to the following conditions:\r |
| 11 | \r |
| 12 | The above copyright notice and this permission notice shall be included in\r |
| 13 | all copies or substantial portions of the Software.\r |
| 14 | \r |
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r |
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r |
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r |
| 18 | ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r |
| 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r |
| 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r |
| 21 | \r |
| 22 | Except as contained in this notice, the name of Robert M Supnik shall not be\r |
| 23 | used in advertising or otherwise to promote the sale, use or other dealings\r |
| 24 | in this Software without prior written authorization from Robert M Supnik.\r |
| 25 | \r |
| 26 | 20-Sep-05 RMS Updated for compatibility with Paul Pierce conventions\r |
| 27 | */\r |
| 28 | \r |
| 29 | /* Old tables */\r |
| 30 | /* ASCII to BCD conversion */\r |
| 31 | \r |
| 32 | const char ascii_to_bcd_old[128] = {\r |
| 33 | 000, 000, 000, 000, 000, 000, 000, 000, /* 000 - 037 */\r |
| 34 | 000, 000, 000, 000, 000, 000, 000, 000,\r |
| 35 | 000, 000, 000, 000, 000, 000, 000, 000,\r |
| 36 | 000, 000, 000, 000, 000, 000, 000, 000,\r |
| 37 | 000, 052, 077, 013, 053, 034, 060, 032, /* 040 - 077 */\r |
| 38 | 017, 074, 054, 037, 033, 040, 073, 021,\r |
| 39 | 012, 001, 002, 003, 004, 005, 006, 007,\r |
| 40 | 010, 011, 015, 056, 076, 035, 016, 072,\r |
| 41 | 014, 061, 062, 063, 064, 065, 066, 067, /* 100 - 137 */\r |
| 42 | 070, 071, 041, 042, 043, 044, 045, 046,\r |
| 43 | 047, 050, 051, 022, 023, 024, 025, 026,\r |
| 44 | 027, 030, 031, 075, 036, 055, 020, 057,\r |
| 45 | 000, 061, 062, 063, 064, 065, 066, 067, /* 140 - 177 */\r |
| 46 | 070, 071, 041, 042, 043, 044, 045, 046,\r |
| 47 | 047, 050, 051, 022, 023, 024, 025, 026,\r |
| 48 | 027, 030, 031, 000, 000, 000, 000, 000\r |
| 49 | };\r |
| 50 | \r |
| 51 | /* BCD to ASCII conversion - also the "full" print chain */\r |
| 52 | \r |
| 53 | char bcd_to_ascii_old[64] = {\r |
| 54 | ' ', '1', '2', '3', '4', '5', '6', '7',\r |
| 55 | '8', '9', '0', '#', '@', ':', '>', '(',\r |
| 56 | '^', '/', 'S', 'T', 'U', 'V', 'W', 'X',\r |
| 57 | 'Y', 'Z', '\'', ',', '%', '=', '\\', '+',\r |
| 58 | '-', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\r |
| 59 | 'Q', 'R', '!', '$', '*', ']', ';', '_',\r |
| 60 | '&', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\r |
| 61 | 'H', 'I', '?', '.', ')', '[', '<', '"'\r |
| 62 | };\r |
| 63 | \r |
| 64 | /* New tables */\r |
| 65 | /* ASCII to BCD conversion */\r |
| 66 | \r |
| 67 | const char ascii_to_bcd[128] = {\r |
| 68 | 000, 000, 000, 000, 000, 000, 000, 000, /* 000 - 037 */\r |
| 69 | 000, 000, 000, 000, 000, 000, 000, 000,\r |
| 70 | 000, 000, 000, 000, 000, 000, 000, 000,\r |
| 71 | 000, 000, 000, 000, 000, 000, 000, 000,\r |
| 72 | 000, 052, 037, 013, 053, 034, 060, 014, /* 040 - 077 */\r |
| 73 | 034, 074, 054, 060, 033, 040, 073, 021,\r |
| 74 | 012, 001, 002, 003, 004, 005, 006, 007,\r |
| 75 | 010, 011, 015, 056, 076, 013, 016, 072,\r |
| 76 | 014, 061, 062, 063, 064, 065, 066, 067, /* 100 - 137 */\r |
| 77 | 070, 071, 041, 042, 043, 044, 045, 046,\r |
| 78 | 047, 050, 051, 022, 023, 024, 025, 026,\r |
| 79 | 027, 030, 031, 075, 036, 055, 020, 057,\r |
| 80 | 000, 061, 062, 063, 064, 065, 066, 067, /* 140 - 177 */\r |
| 81 | 070, 071, 041, 042, 043, 044, 045, 046,\r |
| 82 | 047, 050, 051, 022, 023, 024, 025, 026,\r |
| 83 | 027, 030, 031, 017, 032, 077, 035, 000\r |
| 84 | };\r |
| 85 | \r |
| 86 | /* BCD to ASCII conversion */\r |
| 87 | \r |
| 88 | const char bcd_to_ascii_a[64] = {\r |
| 89 | ' ', '1', '2', '3', '4', '5', '6', '7',\r |
| 90 | '8', '9', '0', '#', '@', ':', '>', '{',\r |
| 91 | '^', '/', 'S', 'T', 'U', 'V', 'W', 'X',\r |
| 92 | 'Y', 'Z', '|', ',', '%', '~', '\\', '"',\r |
| 93 | '-', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\r |
| 94 | 'Q', 'R', '!', '$', '*', ']', ';', '_',\r |
| 95 | '&', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\r |
| 96 | 'H', 'I', '?', '.', ')', '[', '<', '}'\r |
| 97 | };\r |
| 98 | \r |
| 99 | const char bcd_to_ascii_h[64] = {\r |
| 100 | ' ', '1', '2', '3', '4', '5', '6', '7',\r |
| 101 | '8', '9', '0', '=', '\'', ':', '>', '{',\r |
| 102 | '^', '/', 'S', 'T', 'U', 'V', 'W', 'X',\r |
| 103 | 'Y', 'Z', '|', ',', '(', '~', '\\', '"',\r |
| 104 | '-', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\r |
| 105 | 'Q', 'R', '!', '$', '*', ']', ';', '_',\r |
| 106 | '+', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\r |
| 107 | 'H', 'I', '?', '.', ')', '[', '<', '}'\r |
| 108 | };\r |
| 109 | \r |
| 110 | /* BCD to ASCII 48 character print chains */\r |
| 111 | \r |
| 112 | const char bcd_to_pca[64] = {\r |
| 113 | ' ', '1', '2', '3', '4', '5', '6', '7',\r |
| 114 | '8', '9', '0', '#', '@', ' ', ' ', ' ',\r |
| 115 | ' ', '/', 'S', 'T', 'U', 'V', 'W', 'X',\r |
| 116 | 'Y', 'Z', ' ', ',', '%', ' ', ' ', ' ',\r |
| 117 | '-', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\r |
| 118 | 'Q', 'R', '-', '$', '*', ' ', ' ', ' ',\r |
| 119 | '&', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\r |
| 120 | 'H', 'I', '&', '.', ')', ' ', ' ', ' '\r |
| 121 | };\r |
| 122 | \r |
| 123 | const char bcd_to_pch[64] = {\r |
| 124 | ' ', '1', '2', '3', '4', '5', '6', '7',\r |
| 125 | '8', '9', '0', '=', '\'', ' ', ' ', ' ',\r |
| 126 | ' ', '/', 'S', 'T', 'U', 'V', 'W', 'X',\r |
| 127 | 'Y', 'Z', ' ', ',', '(', ' ', ' ', ' ',\r |
| 128 | '-', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\r |
| 129 | 'Q', 'R', '-', '$', '*', ' ', ' ', ' ',\r |
| 130 | '&', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\r |
| 131 | 'H', 'I', '&', '.', ')', ' ', ' ', ' '\r |
| 132 | };\r |
| 133 | \r |
| 134 | /* BCD to column binary conversion */\r |
| 135 | \r |
| 136 | const uint32 bcd_to_colbin[64] = {\r |
| 137 | 00000, 00400, 00200, 00100, 00040, 00020, 00010, 00004,\r |
| 138 | 00002, 00001, 00202, 00102, 00042, 00022, 00012, 00006,\r |
| 139 | 01000, 01400, 01200, 01100, 01040, 01020, 01010, 01004,\r |
| 140 | 01002, 01001, 01202, 01102, 01042, 01022, 01012, 01006,\r |
| 141 | 02000, 02400, 02200, 02100, 02040, 02020, 02010, 02004,\r |
| 142 | 02002, 02001, 02202, 02102, 02042, 02022, 02012, 02006,\r |
| 143 | 04000, 04400, 04200, 04100, 04040, 04020, 04010, 04004,\r |
| 144 | 04002, 04001, 04202, 04102, 04042, 04022, 04012, 04006\r |
| 145 | };\r |