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

  1. #include "sysheaders.h"
  2. #include "cdpanel.h"
  3. #include "CompactPlayer.h"
  4.  
  5. #ifndef AREXX_DefExtension /* typo in headers */
  6. #define AREXX_DefExtension AREXX_DefExtention
  7. #endif
  8.  
  9. /*************************************************
  10.  * ARexx interface
  11.  */
  12.  
  13. static void __asm __saveds
  14. ARexxPlay(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  15. {
  16.     CD_Play( cmd->ac_ArgList[0] ? *(ULONG *)cmd->ac_ArgList[0] : 1 );
  17.     
  18.     cmd->ac_RC = 0;
  19. }
  20.  
  21. static void __asm __saveds
  22. ARexxStop(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  23. {
  24.     CD_Stop();
  25.  
  26.     cmd->ac_RC = 0;
  27. }
  28.  
  29. static void __asm __saveds
  30. ARexxPause(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  31. {
  32.     CD_PauseResume(0x00);
  33.     
  34.     cmd->ac_RC = 0;
  35. }
  36.  
  37. static void __asm __saveds
  38. ARexxResume(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  39. {
  40.     CD_PauseResume(0x01);
  41.     
  42.     cmd->ac_RC = 0;
  43. }
  44.  
  45. static void __asm __saveds
  46. ARexxEject(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  47. {
  48.     CD_Eject(0x01);
  49.     
  50.     cmd->ac_RC = 0;
  51. }
  52.  
  53. static void __asm __saveds
  54. ARexxLoad(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  55. {
  56.     CD_Eject(0x00);
  57.     
  58.     cmd->ac_RC = 0;
  59. }
  60.  
  61. static void __asm __saveds
  62. ARexxQuit(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  63. {
  64.     done = TRUE;
  65.     
  66.     cmd->ac_RC = 0;
  67. }
  68.  
  69. static void __asm __saveds
  70. ARexxActivate(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  71. {
  72.     UnIconify();
  73.     
  74.     cmd->ac_RC = 0;
  75. }
  76.  
  77. static void __asm __saveds
  78. ARexxDeactivate(register __a0 struct ARexxCmd *cmd, register __a1 struct RexxMsg *msg)
  79. {
  80.     Iconify();
  81.     
  82.     cmd->ac_RC = 0;
  83. }
  84.  
  85. struct ARexxCmd arexxCommands[] =
  86. {
  87.     "PLAY", 1, ARexxPlay, "TRACK/N", 0, NULL, 0, 0, NULL,
  88.     "STOP", 2, ARexxStop, NULL, 0, NULL, 0, 0, NULL,
  89.     "PAUSE", 3, ARexxPause, NULL, 0, NULL, 0, 0, NULL,
  90.     "RESUME", 4, ARexxResume, NULL, 0, NULL, 0, 0, NULL,
  91.     "EJECT", 5, ARexxEject, NULL, 0, NULL, 0, 0, NULL,
  92.     "LOAD", 6, ARexxLoad, NULL, 0, NULL, 0, 0, NULL,
  93.     "QUIT", 7, ARexxQuit, NULL, 0, NULL, 0, 0, NULL,
  94.     "ACTIVATE", 8, ARexxActivate, NULL, 0, NULL, 0, 0, NULL,
  95.     "DEACTIVATE", 9, ARexxDeactivate, NULL, 0, NULL, 0, 0, NULL,
  96.     NULL
  97. };
  98.  
  99. Object *ARexxObj;
  100.  
  101. STRPTR
  102. InitARexx( void )
  103. {
  104.     ULONG error;
  105.     
  106.     if (FindPort("COMPACTPLAYER")) 
  107.     {
  108.         LONG rc, rc2;
  109.         STRPTR res;
  110.         
  111.         /* create a temporary ARexx object so that we can use it to signal the
  112.          * running CompactPlayer that it should wake up. */
  113.  
  114.         ARexxObj = ARexxObject, 
  115.             AREXX_HostName, "COMPACTPLAYER",
  116.             AREXX_ErrorCode, &error,
  117.             End;
  118.  
  119.         DoMethod( ARexxObj, AM_EXECUTE,
  120.             "'ACTIVATE'", "COMPACTPLAYER",
  121.              &rc, &rc2, &res, NULL );
  122.              
  123.          kprintf("%lx\n", ARexxObj);
  124.                  
  125.         CloseARexx();
  126.         
  127.         return (APTR)~0;     
  128.     }
  129.     else
  130.     {
  131.         ARexxObj = ARexxObject, 
  132.             AREXX_HostName, "COMPACTPLAYER",
  133.             AREXX_DefExtension, "cp",
  134.             AREXX_Commands, arexxCommands,
  135.             AREXX_ErrorCode, &error,
  136.             AREXX_NoSlot, TRUE,    /* this port will not have a number appended to it */
  137.             End;
  138.             
  139.         if (ARexxObj)
  140.         {
  141.             STRPTR hostname;
  142.             
  143.             GetAttr( AREXX_HostName, ARexxObj, (ULONG *)&hostname );
  144.     
  145.             return hostname;
  146.         }
  147.     }
  148.  
  149.     return NULL;
  150. }
  151.  
  152. void
  153. CloseARexx( void )
  154. {
  155.     DisposeObject( ARexxObj );
  156.     ARexxObj = NULL;
  157. }
  158.