[A89] aaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrgggggggggggggggghhhhhhhh


[Prev][Next][Index][Thread]

[A89] aaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrgggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!!




no, I'm not trying to take advantage of that buffer problem in outlook :) I AM
fustrated though!

ok, I've got  this sample tsr that some of you no doubt have heard or even
possibly seen...
I want to get rid of the fixed-a2 flag or whatever...

to do that, when I call the next event hook in line, I need to push the event
pointer to the stack and also place it in a2... easy right? I can't get it to
work... I am beginning to hate C because it does stupid things... I like asm
when it works... but of course assembly language never worked in the first
place; someone just said it did and everyone else followed so they wouldn't look
dumb... ok maybe not really... anyway...

here is the complete event handler from the sample tsr on my website. The rest
can be found in my sample tsr at: http://www.geocities.com/gdietsche/index.html
if you want/need to look at it.

I'll gladly take any optimizations, bug fixes, rants, raves, ideas, or help....

Thanks,
Greg

p.s. what is the nbitem parameter stored in d2.b in the function
userlib::smallmenu? Also, is it just me or is userlib buggy depending upon ams
kernel etc...?

___________________________________________
// C Header File
// Created 2/12/01; 9:18:22 PM

#ifndef __Handlerh__
#define __Handlerh__

//function prototype(s)
void AFunction(void);

///////////////////////////////////////////////////////////////////////
//the actual event handler... it is the first to recieve an event   //
//the _main function of event handlers in C if you will...         //
////////////////////////////////////////////////////////////////////
void EventHandler(EVENT *ev)
{
 #ifdef OPTIMIZE_ROM_CALLS
  asm("move.l %a5,-(%sp) /*support for OPTIMIZE_ROM_CALLS*/");
  asm("move.l 0xC8,%a5 /*support for OPTIMIZE_ROM_CALLS*/");
 #endif

////////////////////////////////
//Event Handler Starts here  //
//////////////////////////////
 if(ev->Type==CM_KEYPRESS)
 {
  //this is a lame example (good april fools joke though)
   if(ev->extra.Key.Code=='a')
   {
     ev->extra.Key.Code='A';

    //proof that you can call functions
     AFunction();
   }
 }
//////////////////////////////
//End of the event handler //
////////////////////////////
//let the problems begin!!!
asm("
 move.l %1,%%a0    /*get the pointer to the next event hook in a0*/
 /*move.l (%%a0),%%a0*/
 tst.l (%%a0)      /*is it zero ?*/
 jbeq FinishUp    /*it was zero so goto FinishUp*/
 move.l %0,%%a2     /*Pass the pointer to the event in a2 for TEOS*/
 move.l %%a2,-(%%sp) /*Pass the pointer to the event on the stack for most other
event hooks*/
 jsr (%%a0)       /*Run the event hook*/
 addq.l #4,%%sp     /*Restore the stack*/
FinishUp:         /*The exit point when there is no event hook to call*/
"::"p"(ev),"g"(gpOldHandler):"a0","a2");
 #ifdef OPTIMIZE_ROM_CALLS
  asm("move.l (%sp)+,%a5 /*support for OPTIMIZE_ROM_CALLS*/");
 #endif
 /*
 the inline asm takes the place of this code:

 the main reason for the inline asm is to make a2 contain the pointer to
 the event as well as pushing it to the stack.

 void (*OldHook)(EVENT*);
 ...
 //get the address of the next TSR in line to be executed NULL if there is none
  (unsigned long*)OldHook=*((unsigned long*)gpOldHandler);

//Call the old hook if there is one to be called
  if(OldHook)
   OldHook(ev);

   */
}


///////////////////////////////////////////////////////////////////////////
//A Small function to prove that it is possible to call other functions //
/////////////////////////////////////////////////////////////////////////
void AFunction(void)
{
 ST_helpMsg("April Fools!");
}

#endif

___________________________________


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




Follow-Ups: