home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / cdrom / compactplayer / source / autoinit.c < prev    next >
C/C++ Source or Header  |  1995-12-28  |  2KB  |  126 lines

  1. #include "sysheaders.h"
  2. #include "compactplayer.h"
  3.  
  4. /*****************************************************************
  5.  * Autoinit functions
  6.  */
  7.  
  8. extern Class *CreateCDPanelClass(void);
  9. extern void DestroyCDPanelClass(Class *);
  10. Class *CDPanelClass;
  11.  
  12. int __stdargs
  13. _STI_999_cdpanel(void)
  14. {
  15.     CDPanelClass = CreateCDPanelClass();
  16.     if (!CDPanelClass)
  17.     {
  18.         ErrorMsg(GS(CDPANEL_FAIL));
  19.         return -1;
  20.     }
  21.     return 0;
  22. }
  23.  
  24. void __stdargs
  25. _STD_999_cdpanel(void)
  26. {
  27.     if (CDPanelClass)
  28.         DestroyCDPanelClass(CDPanelClass);
  29. }
  30.  
  31. struct timerequest *TimerIO;
  32. struct MsgPort *TimerPort;
  33. struct Library *TimerBase;
  34.  
  35. int __stdargs
  36. _STI_999_timer(void)
  37. {
  38.     if (TimerPort = CreateMsgPort())
  39.     {
  40.         if (TimerIO = (struct timerequest *)CreateIORequest(TimerPort, sizeof(struct timerequest)))
  41.         {
  42.             if (!OpenDevice( "timer.device", UNIT_VBLANK, (struct IORequest *)TimerIO, NULL ))
  43.             {
  44.                 TimerIO->tr_node.io_Command = TR_ADDREQUEST; /* initialize timer */
  45.                 TimerIO->tr_time.tv_secs    = 0;
  46.                 TimerIO->tr_time.tv_micro   = 10000;
  47.                 SendIO((struct IORequest *)TimerIO);
  48.                 TimerBase = TimerIO->tr_node.io_Device;
  49.                 return 0;
  50.             }
  51.             DeleteIORequest((struct IORequest *)TimerIO);
  52.             TimerIO = NULL;
  53.         }
  54.         DeleteMsgPort(TimerPort);
  55.         TimerPort = NULL;
  56.     }
  57.     ErrorMsg(GS(TIMER_FAIL));
  58.     return -1;
  59. }
  60.  
  61. void __stdargs
  62. _STD_999_timer(void)
  63. {
  64.     if (TimerIO)
  65.     {
  66.         if (TimerIO->tr_node.io_Command == TR_ADDREQUEST)
  67.         {
  68.             AbortIO(TimerIO);
  69.             WaitIO(TimerIO);
  70.         }
  71.         CloseDevice(TimerIO);
  72.         DeleteIORequest((struct IORequest *)TimerIO);
  73.         TimerIO = NULL;
  74.     }
  75.     if (TimerPort)
  76.     {
  77.         DeleteMsgPort(TimerPort);
  78.         TimerPort = NULL;
  79.     }
  80. }
  81.  
  82. struct Library *LocaleBase;
  83.  
  84. int __stdargs
  85. _STI_120_localization(void)
  86. {
  87.     LocaleBase = OpenLibrary("locale.library", 38L);
  88.     OpenCompactPlayerCatalog(NULL,NULL);
  89.     return 0;
  90. }
  91.  
  92. void __stdargs
  93. _STD_120_localization(void)
  94. {
  95.     CloseCompactPlayerCatalog();
  96.     if (LocaleBase)
  97.         CloseLibrary(LocaleBase);
  98. }
  99.  
  100. void __stdargs
  101. _STI_130_localizemenu(void)
  102. {
  103.     struct NewMenu *menu = CompactMenu;
  104.     STRPTR s;
  105.     
  106.     while (menu->nm_Type != NM_END)
  107.     {
  108.         if (menu->nm_Label != NM_BARLABEL)
  109.         {
  110.             s = GS((APTR)menu->nm_Label);
  111.             if (menu->nm_Type != NM_TITLE)
  112.             {
  113.                 if (*s)
  114.                     menu->nm_CommKey = s;
  115.                 menu->nm_Label = s + 2;
  116.                 
  117.                 if (menu->nm_UserData == NULL)
  118.                     menu->nm_Flags = NM_ITEMDISABLED;
  119.             }
  120.             else
  121.                 menu->nm_Label = s;
  122.         }
  123.         ++menu;
  124.     }
  125. }
  126.