system vector interception fixes
git-svn-id: svn://svn.cc65.org/cc65/trunk@2339 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -1607,7 +1607,7 @@ void example = {
|
|||||||
<p>
|
<p>
|
||||||
It is possible to intercept and hook in the GEOS Kernal using vectors. Here is a little example:
|
It is possible to intercept and hook in the GEOS Kernal using vectors. Here is a little example:
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
void (*oldVector)(void);
|
void_func oldVector;
|
||||||
|
|
||||||
void NewVectorHandler(void) {
|
void NewVectorHandler(void) {
|
||||||
// do something and at the end call the old vector routine
|
// do something and at the end call the old vector routine
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
unsigned char x,y;
|
unsigned char x,y;
|
||||||
|
|
||||||
void (*oldMouseVector)();
|
void_func oldMouseVector, oldKeyVector;
|
||||||
void (*oldKeyVector)();
|
|
||||||
|
|
||||||
void foo1 (void) {
|
void foo1 (void) {
|
||||||
// do something on mouse press/release
|
// do something on mouse press/release
|
||||||
@@ -28,15 +27,15 @@ void foo2 (void) {
|
|||||||
|
|
||||||
void hook_into_system(void) {
|
void hook_into_system(void) {
|
||||||
// hook into system vectors - preserve old value
|
// hook into system vectors - preserve old value
|
||||||
oldMouseVector = (void (*)())mouseVector;
|
oldMouseVector = mouseVector;
|
||||||
mouseVector = (int)foo1;
|
mouseVector = foo1;
|
||||||
oldKeyVector = (void (*)())keyVector;
|
oldKeyVector = keyVector;
|
||||||
keyVector = (int)foo2;
|
keyVector = foo2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_hooks(void) {
|
void remove_hooks(void) {
|
||||||
mouseVector = (int)oldMouseVector;
|
mouseVector = oldMouseVector;
|
||||||
keyVector = (int)oldKeyVector;
|
keyVector = oldKeyVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|||||||
Reference in New Issue
Block a user