pete@titan.rice.edu (Pete Keleher) (12/02/89)
Ok. I don't really know what LSC is doing with this CallPascal business, and besides, Amanda used assembly. I know assembly. So, I quickly whipped up an assembly version where I did EVERYTHING myself. It now works MUCH better. No crashes, no address error. Unfortunately, it doesn't work either. The bits may or may not be twiddled, but option-a still prints out a funny-looking char. To see if I was in the right place, I nulled out the entire 16-bit keyCode quantity instead of twiddling with it. No change. "Is this thing really getting called?", says I. So, I put a "jsr (a5)" in at the beginning of my trap code, and everything died as expected. It's getting called, but it doesn't seem to make any difference. ============================================================================= static __GetTrapAddr() { asm { bsr.s @1 dc.l 0 ; store trap address here @1 move.l (sp)+,a0 } } asmblyTry() { asm { move.w 6(sp),d0 ; get the modifiers param move.w d0,d1 ; get two copies of the modifiers move.w d0,d2 andi.w #cmdKey,d1 ; get 'cmdKey' bit in d1 lsr.w #1,d1 ; shift into the 'optionKey' position andi.w #optionKey,d2 ; get 'optionKey bit in d2 lsl.w #1,d2 ; shift into the 'cmdKey' position or.w d1,d2 ; get the switched bits into one reg*/ andi.w #0xe7ff,d0 ; mask off the two bits in the original copy or.w d2,d0 ; set the switched bits in the origninal copy move.w d0,6(sp) ; and write the modified flags back into the param } __GetTrapAddr(); /* puts the location of the trap address in a0 */ asm { move.l (a0),a0 ; get the trap address from our location jmp (a0) ; Jump to the silly trap } } initappl() { extern char last_uncomp_pat[]; wins.next = (win_t *)&wins; wins.prev = (win_t *)&wins; last_pat[0] = last_uncomp_pat[0] = 0; init_menus(); initBindings(); initOptions(); keyTransAddr = NGetTrapAddress((int)0xac93,ToolTrap); __GetTrapAddr(); asm { move.l keyTransAddr,(a0) ; store the trap address } NSetTrapAddress(asmblyTry,(int)0xac93,ToolTrap); if (NGetTrapAddress((int)0xac93,ToolTrap) != (long)asmblyTry) { SysBeep(1); Debugger(); } } -- =========================================================================== Pete Keleher pete@titan.rice.edu Rice University knows nuttin about what I say, or what I do ... ===========================================================================
amanda@intercon.com (Amanda Walker) (12/02/89)
I think you want 8(sp) instead of 6(sp). You could also use BTST and BSET/BCLR instructions to do the bit fiddling... Aside from that it looks like you're on the right track. -- Amanda Walker InterCon Systems Corporation amanda@intercon.com