home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pExec / VBlankIRQ.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  3.6 KB  |  136 lines

  1.  
  2. /*******************************************************************
  3.  $CRT 13 Mar 1997 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>VBlankIRQ.c<<   15 Mar 1997    18:05:55 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/VBlankIRQ p:pLib/StartCode.o p:/pOS_RKRM/pExec/VBlankIRQ.c p:pLib/StdIO.o -l pOS -l pOSStub
  10.  
  11. /***********************************************************
  12.   pOS programing example - Copyright (C) 1995-97 proDAD
  13.  
  14.   This code was written as an easy to understand example,
  15.   how to program pOS features. It is provided 'as-is',
  16.   without any express or implied warranty.
  17.  
  18.   Permission is hereby granted to use, copy and modify
  19.   this source code for any purpose, without fee, subject
  20.   to the following conditions:
  21.  
  22.     (1) This notice may not be removed or altered from any
  23.         source distribution.
  24.  
  25.     (2) Altered source versions must be plainly marked as
  26.         such, and must not be misrepresented as being
  27.         the original source code.
  28.  
  29.     (3) If only executable code is distributed, then the
  30.         accompanying documentation have to state that
  31.         "this software is based in part on examples of
  32.         the pOS developer packet".
  33.  
  34.     (4) Permission for use of this code is granted only
  35.         if the user accepts full responsibility for any
  36.         undesirable consequences. proDAD accept NO LIABILITY
  37.         for damages of any kind.
  38.  
  39.   ©proDAD
  40. ***********************************************************/
  41.  
  42. /*\
  43. *** Example:
  44. ***
  45. \*/
  46.  
  47.  
  48. #define __COMPUTER_AMIGA 1
  49. #define NOMYDEBUG
  50.  
  51. #include "p:pExec/Interupt.h"
  52. #include "p:pResource/IRQRes.h"
  53. #include "p:pExec/Node.h"
  54. #include "p:pDOS/ArgTags.h"
  55. #include "p:pDOS/DosSig.h"
  56.  
  57. #include "p:proto/pDos2.h"
  58. #include "p:proto/pExec2.h"
  59. #include "p:proto/pOS.h"
  60.  
  61.  
  62. ULONG VBlank_func(_R_A0 struct pOS_Interrupt*);
  63.  
  64.  
  65. const CHAR *HelpText=
  66. ""
  67. ;
  68.  
  69. const CHAR *PrgHeader=
  70. "";
  71.  
  72. const CHAR *PrgVerText=
  73. "$VER: 1.0 ("__DATE2__") (Copyright 1997 by proDAD) (Created by Holger Burkarth)";
  74.  
  75.  
  76.  
  77.  
  78. /*----------------------------------
  79. -----------------------------------*/
  80. #ifdef __cplusplus
  81. extern "C"
  82. #endif
  83.  
  84. VOID main()
  85. {
  86.   struct pOS_DosArgs* Args;
  87.   ULONG Ops[1]={0};
  88.  
  89.   Args=pOS_ReadDosArgs(
  90. // 0
  91. "",
  92. Ops,sizeof(Ops)/sizeof(ULONG),
  93.  
  94.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  95.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  96.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  97.     TAG_END);
  98.  
  99.   if(Args) {
  100.     struct pOS_Resource *IRQBase;
  101.  
  102.     IRQBase=pOS_OpenResource("IRQ.resource");
  103.     if(IRQBase) {
  104.       struct pOS_StdIRQResourceMFunction *const IRQ=_pOS_GetIRQResourceFunction(IRQBase);
  105.       struct pOS_Interrupt Inter={0};
  106.  
  107.       Inter.is_Node.ln_Type=NTYP_INTERRUPT;
  108.       Inter.is_Node.ln_Name="VBlankIRQ-Test";
  109.       Inter.is_Code=(ULONG(*)(_R_A0 const struct pOS_Interrupt*,_R_A1 APTR)) VBlank_func;
  110.       Inter.is_UserData[0]=(ULONG)pOS_FindTask(NULL);
  111.       Inter.is_UserData[1]=1000;
  112.  
  113.       if((*IRQ->pOS_AddIRQServer_func)(IRQBase,IRQTYP_VBlank,&Inter)) {
  114.         printf("VBlank installed, waiting 1000 blanks, or Ctrl-F\n");
  115.         pOS_WaitSignal(DOSSIGF_CTRL_F);
  116.         (*IRQ->pOS_RemIRQServer_func)(IRQBase,IRQTYP_VBlank,&Inter);
  117.         printf("removed, is_UserData[1]=%ld\n",Inter.is_UserData[1]);
  118.       }
  119.       else printf("Cannot add IRQ-Server\n");
  120.       pOS_CloseResource(IRQBase);
  121.     }
  122.     else printf("Cannot open IRQ.resource\n");
  123.     pOS_DeleteDosArgs(Args);  /* Args freigeben */
  124.   }
  125. }
  126.  
  127.  
  128.  
  129. ULONG VBlank_func(_R_A0 struct pOS_Interrupt* inter)
  130. {
  131.   if(--inter->is_UserData[1]==0) {
  132.     pOS_SendSignal((struct pOS_Task*)inter->is_UserData[0],DOSSIGB_CTRL_F);
  133.   }
  134.   return(0); /* pass other IRQ */
  135. }
  136.