🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #25999

Reading the upper byte of typed chars

#25999
From: jpexg
Date: Wed, 01 Apr 1987 06:25
34 lines
1628 bytes
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 <stdio.h>
include <osbind.h>

#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 */
	}
}
Technical Details
Message-ID: <2825@mit-hermes.AI.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!bacchus!mit-hermes!jpexg

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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