--------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F5G00381 Date: 04/15/98 From: FRANK ADAM Time: 09:35pm \/To: CAREY BLOODWORTH (Read 1 times) Subj: VIDMGR On Apr 09 21:11, 1998, Carey Bloodworth of 1:3822/1 wrote: G'day Carey, CB> 3) You have to be able to read the keyboard shift state (is the shift CB> / CB> alt / ctrl keys being pressed). There are a few areas that detect CB> when CB> change, or even if there is a need to do so (ie: can most systems tell CB> you the status of the shift/control/alt keys?) This is one of the Don't know if this'll help you at all, but it's the thought that counts. ;-) I think it should work on most common systems at least. don't look at the style this is from 2 and a half years ago. :-) From BcPort.c... UCHAR ShiftDown( void ) { return (((UCHAR) *(char far*) MK_FP(0x0040,0x0017) & 1) | ((UCHAR) *(char far*) MK_FP(0x0040,0x0017) & 2)); } UCHAR CtrlDown( void ) { UCHAR ret = 0; if(!((UCHAR) *(char far*) MK_FP(0x0040,0x0017) & 4)) return 0; if( (UCHAR) *(char far*) MK_FP(0x0040,0x0096) & 4) ret = 4; if( (UCHAR) *(char far*) MK_FP(0x0040,0x0018) & 1) ret += 8; return ret; } UCHAR AltDown( void ) { UCHAR ret = 0; if(!((UCHAR) *(char far*) MK_FP(0x0040,0x0017) & 8)) return 0; if( (UCHAR) *(char far*) MK_FP(0x0040,0x0096) & 8) ret = 16; if( (UCHAR) *(char far*) MK_FP(0x0040,0x0018) & 2) ret += 32; return ret; } From BcPort.h... /* MISC STUFF */ #define NUMSACTIVE ((UCHAR) (*(char FAR*) MK_FP(0x0040,0x0017)) & 32) #define CAPSACTIVE ((UCHAR) (*(char FAR*) MK_FP(0x0040,0x0017)) & 64) #define SCRLACTIVE ((UCHAR) (*(char FAR*) MK_FP(0x0040,0x0017)) & 16) #define INSACTIVE ((UCHAR) (*(char FAR*) MK_FP(0x0040,0x0017)) & 128) #define ENHANCEDKB (UCHAR) (*(char FAR*) MK_FP(0x0040,0x0096) & 16) UCHAR ShiftDown( void ); UCHAR CtrlDown( void ); UCHAR AltDown( void ); /* These don't seem to be as quick or reliable as i would like, */ /* but they do work most of the time. */ #define GRAYKEY ((UCHAR) (*(char FAR*) MK_FP(0x0040,0x0096) & 2) #define ISRSHIFT ShiftDown() == 1 ? TRUE : FALSE #define ISLSHIFT ShiftDown() == 2 ? TRUE : FALSE #define ISRCNTRL CtrlDown() == 4 ? TRUE : FALSE #define ISLCNTRL CtrlDown() == 8 ? TRUE : FALSE #define ISRALT AltDown() == 16 ? TRUE : FALSE #define ISLALT AltDown() == 32 ? TRUE : FALSE Regards, Frank. Email: fadam@sensation.net.au. --- Msged 4.30 beta 1 * Origin: The ticking point, Melbourne, Australia. (3:635/728.21@fidonet) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F5G00382 Date: 04/17/98 From: DARIN MCBRIDE Time: 08:23am \/To: HERMAN SCHONFELD (Read 1 times) Subj: Event Handler DM>recall you going on about some non-standard code DM>(cprintf?) that happens DM>to work on YOUR compilers, but not really _ALL_ current compilers. HS> How many other compilers need cprintf? There's no use HS> Pfft. You don't even know what it does. Sure I do. It does slightly different things on each compiler I've used it on. For example, when using cprintf in Turbo, to replicate the same thing on Watcom, I couldn't use cprintf but the combination of sprintf and _outtext. DM>This echo is not just for those who already know C, but for those DM>learning, too. Your exclusion of those learning is one of the reasons DM>that you are slowly being twitted by anyone who knows better. HS> Your unwarranted assumption is noted, and rejected. HS> Please stay ontopic or stop bothering me altogether. Stay on topic? Coming from you? Wow, I'm impressed. I've been told to stay on topic by the guy who doesn't seem to know what the topic is. The topic, for your information, is _C_. Not _Borland C_, or _Microsoft C_, or anything else. It is _C_. The C in the standard. We pay particular attention to the standard in the hopes of getting everyone's compilers (even _Visual Age_, _EMX_, and _PCC_, or even non-Intel machines) giving the same results. Use of extentions is therefore limited to times where it is absolutely necessary. HS> You believe? I KNOW that mainstream compilers have it Well, if you're going to be pedantic, I *know* I've seen the list, I just don't recall which compilers they were. HS> .. Watcom, Borland, Djgpp, etc. If a compiler doesn't HS> have it, then it most likely contains an equivalent. They don't do the same thing on all compilers. HS> then it would most likely contain an equivalent. Sure - but not called cprintf! So why would you write code using cprintf when it isn't the same on all compilers being used? Just stick to the standard code and everything is fine. DM>Why? What happened to printf anyway? HS> With cprintf, the string is written either directly to HS> screen memory or by way of a BIOS call, depending on HS> the value of directvideo. I've seen implementations that do the same thing for printf (where stdout is not redirected) in an attempt to speed up output. HS> Ever wondered why textcolor(), textbackground(), HS> textattr().. etc don't seem to affect stdout with HS> printf? That's why they implemented cprintf() for They do sometimes, depending on the underlying implementation. Watcom, I believe it was, did become affected. Mind you, it wasn't textcolor, textbackground, textattr, but _settextcolor and _setbkcolor. In fact, I have the following snippet that I wrote years ago to handle the differences: >>>>>>>>>> CSplit: Version 2.2 >>>>>>>>>> >>>>>>>>>> CSplit: Begin part 1/1 >>>>>>>>>> >>>>>>>>>> CSplit: Begin file watcomc.c >>>>>>>>>> /* * WatcomC specific functions/global variables */ #include "watcomc.h" #ifdef __WATCOMC__ #include long g_lbkcolors[16] = { _BLACK, _BLUE, _GREEN, _CYAN, _RED, _MAGENTA, _BROWN, _WHITE, _GRAY, _LIGHTBLUE, _LIGHTGREEN, _LIGHTCYAN, _LIGHTRED, _LIGHTMAGENTA, _YELLOW, _BRIGHTWHITE }; #endif >>>>>>>>>> CSplit: End file watcomc.c >>>>>>>>>> >>>>>>>>>> CSplit: Begin file watcomc.h >>>>>>>>>> /* * functions/macros that convert from Borland code to Watcom */ #ifndef WATCOMC_H #define WATCOMC_H #include #ifdef __WATCOMC__ #include #define gotoxy(x,y) _settextposition(y,x) #define clrscr() _clearscreen(_GCLEARSCREEN) extern long g_lbkcolors[16]; /* located in watcomc.c */ #define textattr(c) { _settextcolor((c) & 0x0F); _setbkcolor( \ \ g_lbkcolors[((c) & 0xF0) >> 4] ); } #define OUTTEXT(str) _outtext(str) #define wherex() _gettextposition().col #define wherey() _gettextposition().row /* for outporting... */ #define outportb outp #else #define _dos_findclose(x) #define OUTTEXT(str) cprintf("%s",str) #endif /* Turbo C++ doesn't define this for access(), so we will here */ #ifndef F_OK #define F_OK 0 #endif #endif /* watcomc_h */ >>>>>>>>>> CSplit: End file watcomc.h >>>>>>>>>> >>>>>>>>>> CSplit: End part 1/1 crc: 721d >>>>>>>>>> HS> direct output to screen. If a compiler contains the HS> functions textcolor() etc, then it HAS an equivalent HS> for cprintf(). Which is NOT cprintf! HS> SomeType *mytime = (SomeType *)malloc(sizeof(SomeType)) HS> when, HS> SomeType *mytype = malloc(.... etc HS> compiles. Even though ANSI-C++ forbids void * DM>We're not talking about C++, are we? I thought this was the C echo. HS> Same concept applies to C. You did realize that, didn't you? HS> No. The same general concept applies - Even though it's HS> erroneous to the standard, it works. I love it when you start disagreeing with yourself. And failing to cast void* to the appropriate type hasn't worked on any of my compilers for a while... DM>Something like that. Now, if you'd stop using infantile logic... HS> Education begins at the lowest level. Come back when you've finished grade 1. --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F5G00383 Date: 04/18/98 From: HERMAN SCHONFELD Time: 09:52am \/To: BILL BIRRELL (Read 1 times) Subj: Event Handler BB>Herman, > You'll look what up for yourself? Make sense. BB> It made perfect sense, Herman. I'm sorry you failed to comprehend BB>it. Apology accepted. BB>Obviously I will have to keep my use of language to a level you can BB>cope with. Yes, I cope best with ethiopian. BB>To answer your question, I looked up the rules for control BB>variables in iteration statements. What good is this to me now, after you didn't quote the original message. How am I supposed to remember week old mail? > Took a while, but congratulations. How does it feel to > actually get some code running for the first time? > Pretty good, eh? BB> Without the bugs, it would have run immediately. As it was, it took BB>a minute or two to find and eliminate the impossible from your code. If BB>you can't take constructive criticism just say so and we'll leave you BB>alone. No, that's were you're wrong, drastically, again. The code compiles flawlessly with DJGPP and Watcom. I can't be held liable if my code doesn't seem to work on obsolete useless 16bit borland compilers who have a max dataseg of 64k! BB> This whole sarcastic message of yours looks like an attempt to start BB>a flame war. That's your interpretation. ... For sale: Hourglass for timing Windows. --- Ezycom V1.48g0 01fd016b * Origin: Fox's Lair BBS Bris Aus +61-7-38033908 V34+ Node 2 (3:640/238) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F5G00384 Date: 04/17/98 From: JANIS KRACHT Time: 08:48pm \/To: ALL (Read 1 times) Subj: New Arrivals at PDN HQ! Today, Friday 17-04-98, < TOPIC: 239 C LANGUAGE Ref: F5G00385 Date: 04/17/98 From: JANIS KRACHT Time: 08:50pm \/To: ALL (Read 1 times) Subj: New Arrivals at PDN HQ! Today, Friday 17-04-98, < TOPIC: 239 C LANGUAGE Ref: F5G00386 Date: 04/21/98 From: DARIN MCBRIDE Time: 09:39pm \/To: AUKE REITSMA (Read 1 times) Subj: Curioser and curioser... SA> I'm scared to post the read code now. I've embarrassed myself SA> enough for a while. ') AR> ;-) Happens to everyone. The well known "Foot in Mouth" AR> disease. The solution for that is to remove the other AR> foot (or feet) from the mouth first ;-) Of course. That leaves MUCH more room to fit NEW feet in your mouth. Really, until you start posting code, you never realize that you have more than two feet... :-) --- * Origin: Tanktalus' Tower BBS (1:250/102)