[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | AMIGA NOTES |
Notice: | Join us in the *NEW* conference - HYDRA::AMIGA_V2 |
Moderator: | HYDRA::MOORE |
|
Created: | Sat Apr 26 1986 |
Last Modified: | Wed Feb 05 1992 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 5378 |
Total number of notes: | 38326 |
1763.0. "Help with Console.device!!" by RAVEN1::EVERHART (Keep them away!) Mon Oct 10 1988 14:54
Hi,
I had this nightmare with Manx C (V3.2a???). I was trying to help
a friend learn to use the CONSOLE device for the Amiga. The main
idea was to get a routine that would read keys in like the inkey$
function in BASIC. So, I pulled out my trusty Sybex Programmer's
Guide to the Amiga, and typed in the listed Console routines. I
expected some trouble since these were written in "Amiga C", and
who knows what that has mutated into. So, I typed the code in,
and lo and behold, it didn't even allocate memory. I found the
problem there, and casted an integer into a long, and managed to
get everything to work *BUT* the CGetCharacter function. Here is
the guilty code:
EnqueueRead(c, location)
struct ConIOBlocks *c;
char *location;
{
struct IOStdReq *conr;
conr = c->readReq;
conr->io_Command = CMD_READ;
conr->io_Length = 1;
conr->io_Data = (APTR) location;
SendIO(conr);
}
int
CGetCharacter(c, wait)
struct ConIOBlocks *c;
BOOL wait;
{
struct MsgPort *mp;
struct IOStdReq *conr;
char *dataAddr;
int temp;
mp = c->tpr;
if (wait)
{
WaitPort(mp);
}
conr = (struct IOStdReq *)GetMsg(mp);
if (conr == 0)
{
return(-1);
}
else
{
dataAddr = (char *)conr->io_Data;
temp = *dataAddr;
EnqueueRead(c, dataAddr);
return(temp);
}
}
I linked the whole program with the -lm -lc optios, and if it matters,
all of this was done on a 1000 with a 68010 installed.
The problem that occurs is that sometimes, it works. Other times,
all I get for the key return is junk. And occasionally, pressing
a key will cause a crash. I assume a pointer is not being passed
properly, and I end up stomping all over system memory when the
machine crashes. Can anyone figure out what the problem is?
Thanks in advance,
Chris
T.R | Title | User | Personal Name | Date | Lines |
---|
1763.1 | try recompiling using long integers | DNEAST::PFISTER_ROB | I cant put *THAT* here..... | Thu Oct 13 1988 09:12 | 9 |
|
I got bit by intermittant failures like that before myself. Remember
that Manx 'C' 3.2 defaults to 16 bit integers (while Lattice 'C',
and newer versions default to 32 bit) I'd recompile the program
using `CC +L' (for long integers) and link using `ln -lc32'
(dont think you need -lm unless you do math stuff anywhere)
Robb
|
1763.2 | That did it! | RAVEN1::EVERHART | | Fri Oct 14 1988 11:05 | 11 |
| re .1
Thanks! that seems to have been the problem. I was not aware
that MANX defaulted to 16 bit integers (Although I was suspecting
it). It was my friend's compiler. He loaned me everything but
the manuals so I could get the routine working for him. Until then,
I'd never used MANX before. I guess the next time I do something
for him, I'll take his manuals too. Thanks again for the help.
- Chris
|