Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!bacchus!mit-hermes!jpexg From: jpexg@mit-hermes.UUCP Newsgroups: comp.sys.atari.st Subject: Reading the upper byte of typed chars Message-ID: <2825@mit-hermes.AI.MIT.EDU> Date: Wed, 1-Apr-87 01:25:39 EST Article-I.D.: mit-herm.2825 Posted: Wed Apr 1 01:25:39 1987 Date-Received: Sat, 4-Apr-87 05:22:23 EST Organization: MIT AI Lab, Cambridge, MA Lines: 34 Keywords: Sample program included This is in reply to the person who was having trouble reading the full 16-bit character with Crawcin() calls, etc. You'd think that since the character-reading calls get a 16-bit word, the extra byte would be packed into the top byte. Not so, but Megamax is wrong when they say that Crawcin(), Cnecin(), Cconin() etc read 1 word: they can just as easily read a longword, and if you do this you will find the extra byte in the low half of the top word. See below for an example, which types low and high byte for any key and pings the bell if you hit the "help" key. include include #define HELPLOW 0 #define HELPHIGH 98 #define BELL 7 main(){ long z; while (1) /* Loop till you droop */ { while (!Cconis()) ; /* Wait for it..... */ z = Cnecin(); if (z == ((long)HELPLOW | (long)(HELPHIGH << 16))) Cconout(BELL); /* Ping */ printf("16-bit character <%c>, value 0x%lx, ", (char)z, z); printf("low byte 0x%lx, high byte 0x%lx\n", z&0xFFFF, (z >> 16)&0xFFFF); if ((char)z == 3) break; /* Control-c exits */ } }