home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 21 / macformat_21.iso / Shareware / Programación / VideoToolbox / VideoToolboxSources / ATMInterface.c < prev    next >
Text File  |  1995-07-26  |  4KB  |  121 lines

  1. /*
  2.  * ATMInterface.c
  3.  *
  4.  * Version 1.01
  5.  *
  6.  * Adobe Type Manager is a trademark 
  7.  * of Adobe Systems Incorporated.
  8.  
  9. As provided by Adobe, ATMInterface.c only worked if compiled as 68k code. I've
  10. enhanced it, by changing the direct calls to ATM to indirect CallUniversalProc
  11. calls, so the Mixed Mode Manager can do its magic if this file is compiled to
  12. run native. This works with the current 68k version of ATM (3.6.1), and will
  13. probably also work with the forthcoming fat version of ATM (3.8?), assuming
  14. Adobe maintains the API (Application Programming Interface). However, we will be
  15. calling the 68k code in ATM.
  16.  
  17. This program from Adobe (Version 1.01) is quite old, but its API is still
  18. supported by current versions of ATM (3.8.2). Newer versions of ATMInterface.c add a way to return
  19. an error code to some of these functions, and add a whole slew of functions
  20. for controlling SuperATM's Multiple font Master capabilities.
  21. The current version (3.0) of ATMInterface.c can be downloaded from:
  22. ftp://ftp.mv.us.adobe.com/pub/adobe/Programs/MacATM30headers.sea.hqx
  23. For current documentation of the ATM Macintosh C interface download:
  24. ftp://ftp.mv.us.adobe.com/pub/adobe/DeveloperSupport/TechNotes/5072.ATM_Adv_Mac.pdf
  25.  
  26. HISTORY:
  27. 93?    dgp I don't remember how or when I got this. Perhaps from the Adobe section 
  28. of Compuserve.
  29. 9/7/94 dgp Introduced Universal proc pointers to allow PowerPC code to call
  30. the current (68k) version of ATM (3.6.1). 
  31. 11/15/94 dgp made compatible with pre-Universal headers.
  32. 1/5/95 dgp made compatible with Universal Headers 2.
  33. */
  34. #include "ATMInterface.h"
  35. #if defined(__powerc) && !defined(__MIXEDMODE__)
  36.     #include <MixedMode.h>
  37. #endif
  38. #ifndef GENERATING68K    // Allow compilation without VideoToolbox.h, with old Apple headers.
  39.     #if defined(__powerc)
  40.         #ifndef GENERATING68K
  41.             #define GENERATING68K 0
  42.             #define GENERATINGPOWERPC 1
  43.         #endif
  44.     #else
  45.         #define GENERATING68K 1
  46.         #define GENERATINGPOWERPC 0
  47.     #endif
  48. #endif
  49. #if GENERATINGPOWERPC
  50.     enum{
  51.         uppFontAvailable=kThinkCStackBased
  52.             | RESULT_SIZE(kTwoByteCode)
  53.             | STACK_ROUTINE_PARAMETER(1,kTwoByteCode)
  54.             | STACK_ROUTINE_PARAMETER(2,kTwoByteCode)
  55.         ,uppShowText=kThinkCStackBased
  56.             | RESULT_SIZE(kTwoByteCode)
  57.             | STACK_ROUTINE_PARAMETER(1,kFourByteCode)
  58.             | STACK_ROUTINE_PARAMETER(2,kTwoByteCode)
  59.             | STACK_ROUTINE_PARAMETER(3,kFourByteCode)
  60.         ,uppXyshowText=kThinkCStackBased
  61.             | RESULT_SIZE(kTwoByteCode)
  62.             | STACK_ROUTINE_PARAMETER(1,kFourByteCode)
  63.             | STACK_ROUTINE_PARAMETER(2,kTwoByteCode)
  64.             | STACK_ROUTINE_PARAMETER(3,kFourByteCode)
  65.             | STACK_ROUTINE_PARAMETER(4,kFourByteCode)
  66.     };
  67. #elif !defined(NewRoutineDescriptor)
  68.     #define NewRoutineDescriptor(theProc,theProcInfo,theISA) (theProc)
  69. #endif
  70.  
  71. static short open=0;
  72. static ATMProcs3 procs;
  73.  
  74. short initATM(void)
  75. {
  76.     CntrlParam c;
  77.     
  78.     if(open)return 1;    // added by Denis Pelli to skip opening if already open
  79.     if(OpenDriver("\p.ATM",&c.ioCRefNum))return 0;
  80.     c.csCode = ATMProcsStatusCode;
  81.     *(ATMProcs3 **) c.csParam = &procs;
  82.     procs.version = ATMProcs3Version;
  83.     if(PBStatus((ParmBlkPtr)&c,0))return 0;
  84.     open=1;
  85.     /* replace each ProcPtr by a UniversalProcPtr. */
  86.     procs.fontAvailable=(void *)NewRoutineDescriptor((ProcPtr)procs.fontAvailable,uppFontAvailable,kM68kISA);
  87.     procs.showText=(void *)NewRoutineDescriptor((ProcPtr)procs.showText,uppShowText,kM68kISA);
  88.     procs.xyshowText=(void *)NewRoutineDescriptor((ProcPtr)procs.xyshowText,uppXyshowText,kM68kISA);
  89.     return 1;
  90. }
  91.  
  92. short fontAvailableATM(short family,short style)
  93. {
  94.     #if GENERATING68K
  95.         return open ? (*procs.fontAvailable)(family,style) : 0;
  96.     #else
  97.         return open ? CallUniversalProc(procs.fontAvailable,uppFontAvailable
  98.             ,family,style) : 0;
  99.     #endif
  100. }
  101.  
  102. short showTextATM(char *text,short length,FixedMatrix *matrix)
  103. {
  104.     #if GENERATING68K
  105.         return open ? (*procs.showText)(text,length,matrix) : length;
  106.     #else
  107.         return open ? CallUniversalProc(procs.showText,uppShowText
  108.             ,text,length,matrix) : length;
  109.     #endif
  110. }
  111.  
  112. short xyshowTextATM(char *text,short length,FixedMatrix *matrix,Fixed *displacements)
  113. {
  114.     #if GENERATING68K
  115.         return open ? (*procs.xyshowText)(text,length,matrix,displacements) : length;
  116.     #else
  117.         return open ? CallUniversalProc(procs.xyshowText,uppXyshowText
  118.             ,text,length,matrix,displacements) : length;
  119.     #endif
  120. }
  121.