/* ---------------------------------------------------------------------------- CallMyVDEF - This is a special glue routine for VDM/VDEF interfacing. It exists to allow a Pascal function to call a routine to which it has a handle that is inside a global structure. This function expects to be called like: status := CallMyVDEF (VDEFEntry, VDHandle, message, p1, p2, p3, p4); per the Video Digitizer Manager spec, returning OSERR. This routine simply gets the address of the VDEF entry point off the stack, cleans up the stack for the VDEF and jumps to the VDEF. Copyright ©, 1990-1995, Perceptics Corporation. Module History: 05-July-1990 - P Whalen Created module. 27-July-1995 - P Whalen Added PowerPC native mode option. ------------------------------------------------------------------------------*/ #include #include #ifdef PPCNative /* C glue code needed by PowerPC native version of NIH Image VDM to call VDEFs. CallUniversalProc can't be called directly from Pascal because is uses a variable number of arguments. uppCallCodeInfo = $00000EE0; { FUNCTION (4 byte param, 2 byte param, 4 byte param): OSErr; */ enum { uppVDEFEntryProcInfo = kPascalStackBased | RESULT_SIZE(SIZE_CODE(sizeof(OSErr))) | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Handle))) | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle))) }; OSErr CallMyVDEF(long VDHandle, short message, long parmsPtr, UniversalProcPtr VDEFEntry); OSErr CallMyVDEF(long VDHandle, short message, long parmsPtr, UniversalProcPtr VDEFEntry) { CallUniversalProc(VDEFEntry, uppVDEFEntryProcInfo, VDHandle, message, parmsPtr); } #else #define CallMyVDEF CALLMYVDEF asm OSErr CallMyVDEF (long VDHandle, short message, long parmsPtr, long VDEFEntry); asm OSErr CallMyVDEF (long VDHandle, short message, long parmsPtr, long VDEFEntry) { //unlk a6 // undo the automatic stack frame move.l (sp)+,d0 // get caller's return address move.l (sp)+,a0 // get VDEFEntry off the stack move.l d0,-(sp) // put return address back on stack jmp (a0) // go enter the VDEF rts // dummy to satisfy compiler--will not execute } #endif