2003-08-15 23:07:20 +00:00
|
|
|
#include <geos.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
unsigned char x,y;
|
|
|
|
|
2003-08-15 23:17:11 +00:00
|
|
|
void_func oldMouseVector, oldKeyVector;
|
2003-08-15 23:07:20 +00:00
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
void foo1 (void)
|
|
|
|
{
|
2003-08-15 23:07:20 +00:00
|
|
|
// do something on mouse press/release
|
|
|
|
gotoxy(x,y);
|
|
|
|
++x;
|
|
|
|
cputc('A');
|
2012-02-09 12:32:53 +00:00
|
|
|
|
2003-08-15 23:07:20 +00:00
|
|
|
// call previous routine
|
|
|
|
oldMouseVector();
|
|
|
|
}
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
void foo2 (void)
|
|
|
|
{
|
2003-08-15 23:07:20 +00:00
|
|
|
// do something on key press/release
|
|
|
|
gotoxy(x,y);
|
|
|
|
++y;
|
|
|
|
cputc('B');
|
2012-02-09 12:32:53 +00:00
|
|
|
|
2003-08-15 23:07:20 +00:00
|
|
|
// call previous routine
|
|
|
|
oldKeyVector();
|
|
|
|
}
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
void hook_into_system(void)
|
|
|
|
{
|
2003-08-15 23:07:20 +00:00
|
|
|
// hook into system vectors - preserve old value
|
2003-08-15 23:17:11 +00:00
|
|
|
oldMouseVector = mouseVector;
|
|
|
|
mouseVector = foo1;
|
|
|
|
oldKeyVector = keyVector;
|
|
|
|
keyVector = foo2;
|
2003-08-15 23:07:20 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
void remove_hooks(void)
|
|
|
|
{
|
2003-08-15 23:17:11 +00:00
|
|
|
mouseVector = oldMouseVector;
|
|
|
|
keyVector = oldKeyVector;
|
2003-08-15 23:07:20 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
2003-08-15 23:07:20 +00:00
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
// To make cc65 do something for you before exiting you might register
|
|
|
|
// a function to be called using atexit call. #include <stdlib.h> then and
|
|
|
|
// write:
|
2003-08-15 23:07:20 +00:00
|
|
|
atexit(&remove_hooks);
|
|
|
|
|
|
|
|
clrscr();
|
|
|
|
cputsxy(0,1, CBOLDON "Just" COUTLINEON "a " CITALICON "string." CPLAINTEXT );
|
|
|
|
|
|
|
|
hook_into_system();
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
// This program will loop forever though
|
2003-08-15 23:07:20 +00:00
|
|
|
MainLoop();
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
// If not using atexit() you have to remember about restoring system vectors
|
|
|
|
// right before exiting your application. Otherwise the system will most
|
|
|
|
// likely crash.
|
|
|
|
// remove_hooks();
|
2003-08-15 23:07:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|