Mail Archives: djgpp/1998/05/18/03:15:37
From: | claytonbrauner AT geocities DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Mouse Callback function using Allegro 3.0
|
Message-ID: | <355fcc53.30849407@news.sas.shaw.wave.ca>
|
MIME-Version: | 1.0
|
Lines: | 39
|
Date: | Mon, 18 May 1998 05:57:17 GMT
|
NNTP-Posting-Host: | cybers96d194.ss.wave.shaw.ca
|
NNTP-Posting-Date: | Sun, 17 May 1998 23:57:17 MDT
|
Organization: | Shaw Fiberlink Ltd. (Calgary)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I am trying to set up a very simple mouse event stack to catch
all mouse events by making a mouse callback that pushes pertinent data
onto a stack. The only problem is, it doesn't work. It runs and
registers the first event, but then after the first it refuses to
beleive that the counter variable is changing-and so does nothing.
I've tried making these variables "volatile", as i have been told that
that will make the compiler generate code to check it all the time
rather then when the compiler thinks it has changed. But I got the
same results.
I know the answer will be something trivial, so this is
killing me!!! Thanks for listening.
(I've written a smallish program to show my problem:)
#include <allegro.h>
volatile struct evrev {
int mev,x,y;
} events[50];
volatile int nev=0;
void mouseCB( int mev)
{
events[nev].mev=mev;
events[nev].x=mouse_x;
events[nev].y=mouse_y;
nev++;
}
END_OF_FUNCTION(mouseCB)
void main( void)
{
char* s=(char*)malloc(80);
LOCK_FUNCTION(mouseCB);
LOCK_VARIABLE(nev);
LOCK_VARIABLE(events);
allegro_init();
install_keyboard();
install_mouse();
install_timer();
install_keyboard();
set_gfx_mode(GFX_VGA,320,200,0,0);
mouse_callback=mouseCB;
show_mouse(screen);
while(!key[KEY_SPACE])
{
while(nev>0)
{
disable();
sprintf(s,"event %i",nev);
textout(screen,font,s,events[nev].x,events[nev].y,15);
nev--;
enable();
}
}
}
- Raw text -