home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / scnote / trnsfrmr.020 / SCN.020.Transformer < prev    next >
Text File  |  1990-01-17  |  3KB  |  69 lines

  1. Macintosh
  2. Sample Code Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. #20:    Transformer
  6.  
  7. Written by:    Keith Rollin
  8.  
  9. Versions:            1.00                        February 1990
  10.  
  11. Components:            MTransformer.p                February 1, 1990
  12.                     Transformer.c                February 1, 1990
  13.                     Transformer.r                February 1, 1990
  14.                     UTransformer.p                February 1, 1990
  15.                     UTransformer.inc1.p            February 1, 1990
  16.                     Transformer.MAMake          February 1, 1990
  17.  
  18. Additional Documentatation:    The BitMap Transmogrifier (MacWrite)
  19. _____________________________________________________________________________
  20.  
  21. Transformer is a sample program that demonstrates:
  22.  
  23.     - bitmap transformations
  24.     - mixing MacApp with C subroutines
  25.     - mixing 68881 and non-68881 code together
  26.     - calling of MacApp routines from C
  27.     - using CursorCtl routines
  28.     - turning on and off the MacApp BusyCursor mechanism
  29.     
  30. It uses a MacApp shell to open file, open windows, and handle menus, but
  31. uses a core routine written in vanilla C to perform the actual transformation.
  32. The transformation consists of translating, scaling, and rotating. The comments
  33. in the source code are sparse, if existant at all, so gleaning how the
  34. transformation routine works is very difficult. To explain what is going on,
  35. a sister document, "The BitMap Transmogrifier," has been included. It explains
  36. all of the necessary math, and shows how the formulas were derived. There are
  37. also lots of pictures.
  38.  
  39. Adding C routines to a MacApp program used to be a pain, but no longer.
  40. Previously, weird gyrations had to be performed in order to get things to
  41. link correctly and without lots of warnings or errors. Now with MacApp 2.0º9
  42. and later, support has been explicitly provided in MABuild for mixing in C.
  43.  
  44. For best performance, the C routine is compiled with the -mc68881 option (this
  45. is set in the MAMake file). A problem arises with this, as an extended value
  46. is passed from the non-FPU Pascal code to the FPU C code. Since the size of
  47. extended values changes depending on the setting of the 68881 options, the
  48. parameters have to be converted as per page 347 of the MPW 3.0 Pascal manual.
  49.  
  50. In our C routine, we make use of some of the MacApp utilities. This is
  51. done by making a small set of external declarations that match the Pascal
  52. interfaces for the routines we are interested in. This is done for FailNIL,
  53. FailOSErr, and BusyActivate.
  54.  
  55. BusyActivate is a routine that controls the BusyCursor mechanism of MacApp.
  56. This mechanism gives MacApp programs a built-in watch cursor that kicks in
  57. whenever the application is involved in a lengthy process. During our
  58. transformation routine we want this turned off, as we supply our own busy
  59. indicator with the CursorCtl library routines.
  60.  
  61. The CursorCtl library routines allow one to implement the spinning beachball
  62. cursor. We set this up when we initialize our application with a call to
  63. InitCursorCtl. This reads in our 'acur' and 'CURS' resources and initializes
  64. them in whatever way it deems necessary. When we need to show the spinning
  65. cursor, we just start calling SpinCursor() with some rotation value. This
  66. rotation value is added to an internal counter. When this counter reaches 32,
  67. the next cursor specified in the 'acur' resource is shown. More information
  68. on this is included in the interface files for CursorCtl.
  69.