home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Pascal / Snippets / Calling ShowIcon7 / Calling ShowIcon7.p next >
Encoding:
Text File  |  1995-12-06  |  3.5 KB  |  70 lines  |  [TEXT/PJMM]

  1. { This program, an INIT, demonstrates how to use the code resource ShowIcon7, for displaying INIT icons at startup.    }
  2. { This involves loading, locking, calling, then unloading the code resource.                                                    }
  3. { Written by: Tony Andreoli. 01/01/93                                                                                        }
  4.  
  5. unit CallingShowIcon7;
  6.  
  7. interface
  8.     procedure main;
  9.     procedure ShowIcon (iconID: Integer; advance: Boolean; procAddress: ProcPtr);
  10.     inline
  11.         $205f,      {   movea.l (a7)+,a0  }
  12.         $4e90;    {    jsr(a0)            }
  13.     { This is the standard calling convention to call any loaded resource.  Your calling routine should accept 1 more    }
  14.     { parameter than the code resource. i.e. ShowIcon7 takes two parameters, the iconID, and advance.  Our routine    }
  15.     { to call ShowIcon7 takes 3 parameters, the two mentioned, and the routine's address.  The parameters are         }
  16.     { pushed on to the stack (the address being last), then we make an inline call to do a sub-routine.  The address of    }
  17.     { the sub-routine is popped off of the stack (since the stack works in FILO [First In Last Out]), and the                }
  18.     { JSR is executed.  Our other two parameters are now sitting in the stack when ShowIcon7 is executed, and life    }
  19.     { is good again.  If our code resource didn't require any parameters, then this inline procedure would only require    }
  20.     { one (the JSR address), the inline instructions remain the same.                                                        }
  21.  
  22. implementation
  23.     procedure main;
  24.         var
  25.             codeResourceHandle: Handle;                                    { Handle to our code resource                            }
  26.             codeResourcePtr: ProcPtr;                                        { Pointer to our code resource                            }
  27.  
  28.     begin
  29.         codeResourceHandle := GetResource('Code', -4048);            { Load the desired resource                                }
  30.         if (codeResourceHandle <> nil) then                                { If the load went OK                                        }
  31.             begin
  32.                 HLock(codeResourceHandle);                                    { Lock the code resource in place                        }
  33.                 codeResourcePtr := ProcPtr(codeResourceHandle^);        { Get the address of our code resource                    }
  34.  
  35.                 ShowIcon(128, false, codeResourcePtr);                    { The following calls the code resource, with the icon    }
  36.                 ShowIcon(129, false, codeResourcePtr);                    { to display in succession.  The final line has a "true"    }
  37.                 ShowIcon(130, false, codeResourcePtr);                    { in the advance field, allowing the next extension to    }
  38.                 ShowIcon(131, false, codeResourcePtr);                    { draw an icon, and not overwrite ours.                }
  39.                 ShowIcon(132, false, codeResourcePtr);
  40.                 ShowIcon(133, false, codeResourcePtr);
  41.                 ShowIcon(134, false, codeResourcePtr);
  42.                 ShowIcon(135, false, codeResourcePtr);
  43.                 ShowIcon(136, false, codeResourcePtr);
  44.                 ShowIcon(137, false, codeResourcePtr);
  45.                 ShowIcon(138, false, codeResourcePtr);
  46.                 ShowIcon(139, false, codeResourcePtr);
  47.                 ShowIcon(140, false, codeResourcePtr);
  48.                 ShowIcon(141, false, codeResourcePtr);
  49.                 ShowIcon(142, false, codeResourcePtr);
  50.                 ShowIcon(143, false, codeResourcePtr);
  51.                 ShowIcon(144, false, codeResourcePtr);
  52.                 ShowIcon(145, false, codeResourcePtr);
  53.                 ShowIcon(146, false, codeResourcePtr);
  54.                 ShowIcon(147, false, codeResourcePtr);
  55.                 ShowIcon(148, false, codeResourcePtr);
  56.                 ShowIcon(149, false, codeResourcePtr);
  57.                 ShowIcon(150, false, codeResourcePtr);
  58.                 ShowIcon(151, false, codeResourcePtr);
  59.                 ShowIcon(152, false, codeResourcePtr);
  60.                 ShowIcon(153, false, codeResourcePtr);
  61.                 ShowIcon(154, false, codeResourcePtr);
  62.                 ShowIcon(155, false, codeResourcePtr);
  63.                 ShowIcon(156, true, codeResourcePtr);
  64.  
  65.                 HUnlock(codeResourceHandle);                                { Unlock the code resource, we're outta here!            }
  66.             end
  67.         else
  68.             SysBeep(1);                                                    { If the code resource was nil, to an audio alert    }
  69.     end;
  70. end.