delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/02/19:50:03

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Beginner Help Wanted (getkey() and VGA)
Date: Mon, 03 Nov 1997 03:55:44 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 53
Message-ID: <345D4B40.2924@cs.com>
References: <01bce79c$05750200$9c7e9ec2 AT jbportable>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp228.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Johnny BARRAY wrote:
> 
> #include <stdio.h>
> 
> void main()
> {
>   while (1==1)
>     printf("%d ", getkey());
> }

This code doesn't lock up on me, although it doesn't work the way you
apparently want it to.  Here are the bugs:

1) getkey() is defined in <conio.h>, which you aren't including.
2) main() must return an integer under ANSI C.  void main() is illegal.
3) Because stdout in DJGPP is line-buffered, you don't actually see any
output from the program until you break out of it.

However, it doesn't lock up or crash; Ctrl-C exits just fine.

> It's a test to see getkey() returned values.
> Anyway my computer lock up when I run it from DOS 6.22.
> When I press anykey (even Ctrl-C), nothing append.
> 
> I can only reboot !!!

I ran it from a Win95 DOS shell; I haven't tried from DOS 6.22 yet.  But
there's absolutely no reason for this code to lock.  Are you _sure_ that
Ctrl-C and Ctrl-Break don't work?  Did you try pressing Enter after
hitting Ctrl-C?

> Another simple question :
> What is the VGA addresse in v2 (not the same à V1 ??)

The absolute address for video memory has not changed; it's still at
0xa0000.  However, DJGPP v2 runs in protected mode, which means that you
cannot simply write to any absolute memory address.  Doing this causes
your program to violate memory protection and crash.  Please download
and read the DJGPP FAQ (v2/faq210b.zip from SimTel or online at
http://www.delorie.com/djgpp/v2faq/), and look in chapters 10 and 18 for
precise instructions for accessing video memory and other hardware
devices.

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I  |     mailto:fighteer AT cs DOT com     |
| Plan:  To find ANYONE willing to |   http://www.cs.com/fighteer   |
| play Descent 2 on DWANGO!        | Tagline: <this space for rent> |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019