Last active
April 12, 2022 22:11
-
-
Save cmgauger/10c155a0a8f6d58f7bb1c5b61cd9d0ed to your computer and use it in GitHub Desktop.
Translation tables for IBM card code, based on 2540 reader/punch manuals and code page 037.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _CARDTAB_H | |
#define _CARDTAB_H | |
/* _CARDTAB_H | |
* | |
* Copyright (c) 2021 Christian Gauger-Cosgrove | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be included in | |
* all copies or substantial portions of the Software. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
* SOFTWARE. | |
* | |
* | |
* | |
* The following translation tables are based on the card code illustrated in | |
* IBM publication A21-9033-1 "IBM 2540 Component Description and Operating | |
* Procedures", as well as EBCDIC code page 037. | |
* | |
* The 'punchBYTE' table is a direct mapping of raw bytes to the holes punched | |
* in a column, based on the code table of the 2540 card reader/punch. | |
* | |
* The 'punchCHAR' table translates the standard (low) ASCII character set to | |
* card code, using the 2540's code table, with code page IBM037 used for the | |
* handful of ASCII characters not covered. Refer to the comment in the table | |
* for additional information on possible modifications. | |
* | |
* The punch information is stored in the following format: | |
* | |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
* | | |12|11| 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| | |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
* | |
*/ | |
#include <stdint.h> | |
const uint16_t punchBYTE[256] = { | |
05403, 04401, 04201, 04101, 04041, 04021, 04011, 04005, | |
04003, 04403, 04203, 04103, 04043, 04023, 04013, 04007, | |
06403, 02401, 02201, 02101, 02041, 02021, 02011, 02005, | |
02003, 02403, 02203, 02103, 02043, 02023, 02013, 02007, | |
03403, 01401, 01201, 01101, 01041, 01021, 01011, 01005, | |
01003, 01403, 01203, 01103, 01043, 01023, 01013, 01007, | |
07403, 00401, 00201, 00101, 00041, 00021, 00011, 00005, | |
00003, 00403, 00203, 00103, 00043, 00023, 00013, 00007, | |
00000, 05401, 05201, 05101, 05041, 05021, 05011, 05005, | |
05003, 04402, 04202, 04102, 04042, 04022, 04012, 04006, | |
04000, 06401, 06201, 06101, 06041, 06021, 06011, 06005, | |
06003, 02402, 02202, 02102, 02042, 02022, 02012, 02006, | |
02000, 01400, 03201, 03101, 03041, 03021, 03011, 03005, | |
03003, 01402, 06000, 01102, 01042, 01022, 01012, 01006, | |
07000, 07401, 07201, 07101, 07041, 07021, 07011, 07005, | |
07003, 00402, 00202, 00102, 00042, 00022, 00012, 00006, | |
05402, 05400, 05200, 05100, 05040, 05020, 05010, 05004, | |
05002, 05001, 05202, 05102, 05042, 05022, 05012, 05006, | |
06402, 06400, 06200, 06100, 06040, 06020, 06010, 06004, | |
06002, 06001, 06202, 06102, 06042, 06022, 06012, 06006, | |
03402, 03400, 03200, 03100, 03040, 03020, 03010, 03004, | |
03002, 03001, 03202, 03102, 03042, 03022, 03012, 03006, | |
07402, 07400, 07200, 07100, 07040, 07020, 07010, 07004, | |
07002, 07001, 07202, 07102, 07042, 07022, 07012, 07006, | |
05000, 04400, 04200, 04100, 04040, 04020, 04010, 04004, | |
04002, 04001, 05203, 05103, 05043, 05023, 05013, 05007, | |
03000, 02400, 02200, 02100, 02040, 02020, 02010, 02004, | |
02002, 02001, 06203, 06103, 06043, 06023, 06013, 06007, | |
01202, 03401, 01200, 01100, 01040, 01020, 01010, 01004, | |
01002, 01001, 03203, 03103, 03043, 03023, 03013, 03007, | |
01000, 00400, 00200, 00100, 00040, 00020, 00010, 00004, | |
00002, 00001, 07203, 07103, 07043, 07023, 07013, 07007 | |
}; | |
const uint16_t punchCHAR[128] = { | |
/* | |
* '~' is being represented by the "logical not" symbol of the 2540; if a true | |
* tilde is desired, replace its code with 03400. | |
* '|' is being represented by the "vertical bar" symbol of the 2540; if the | |
* broken bar symbol is desired, replace its code with 06000. | |
* As it is not in standard (low) ASCII, the cent sign is not encoded; if it is | |
* desired, either as a replacement for a standard ASCII character, it may be | |
* encoded as 04202. | |
* | |
* The ASCII control characters are NOT translated. | |
*/ | |
07777, 07777, 07777, 07777, 07777, 07777, 07777, 07777, /* */ | |
07777, 07777, 07777, 07777, 07777, 07777, 07777, 07777, /* */ | |
07777, 07777, 07777, 07777, 07777, 07777, 07777, 07777, /* */ | |
07777, 07777, 07777, 07777, 07777, 07777, 07777, 07777, /* */ | |
00000, 02202, 00006, 00102, 02102, 01042, 04000, 00022, /* !"#$%&' */ | |
04022, 02022, 02042, 04012, 01102, 02000, 04102, 01400, /* ()*+,-./ */ | |
01000, 00400, 00200, 00100, 00040, 00020, 00010, 00004, /* 01234567 */ | |
00002, 00001, 00202, 02012, 04042, 00012, 01012, 01006, /* 89:;<=>? */ | |
00042, 04400, 04200, 04100, 04040, 04020, 04010, 04004, /* @ABCDEFG */ | |
04002, 04001, 02400, 02200, 02100, 02040, 02020, 02010, /* HIJKLMNO */ | |
02004, 02002, 02001, 01200, 01100, 01040, 01020, 01010, /* PQRSTUVW */ | |
01004, 01002, 01001, 07202, 01202, 07102, 07402, 01022, /* XYZ[\]^_ */ | |
00402, 05400, 05200, 05100, 05040, 05020, 05010, 05004, /* `abcdefg */ | |
05002, 05001, 06400, 06200, 06100, 06040, 06020, 06010, /* hijklmno */ | |
06004, 06002, 06001, 03200, 03100, 03040, 03020, 03010, /* pqrstuvw */ | |
03004, 03002, 03001, 05000, 04006, 03000, 02006, 07777 /* xyz{|}~ */ | |
}; | |
#endif /* _CARDTAB_H */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment