home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 13 Mar 1997 : hb
-
- $AUT Holger Burkarth
- $DAT >>VBlankIRQ.c<< 15 Mar 1997 18:05:55 - (C) ProDAD
- *******************************************************************/
-
- //##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
-
- /***********************************************************
- pOS programing example - Copyright (C) 1995-97 proDAD
-
- This code was written as an easy to understand example,
- how to program pOS features. It is provided 'as-is',
- without any express or implied warranty.
-
- Permission is hereby granted to use, copy and modify
- this source code for any purpose, without fee, subject
- to the following conditions:
-
- (1) This notice may not be removed or altered from any
- source distribution.
-
- (2) Altered source versions must be plainly marked as
- such, and must not be misrepresented as being
- the original source code.
-
- (3) If only executable code is distributed, then the
- accompanying documentation have to state that
- "this software is based in part on examples of
- the pOS developer packet".
-
- (4) Permission for use of this code is granted only
- if the user accepts full responsibility for any
- undesirable consequences. proDAD accept NO LIABILITY
- for damages of any kind.
-
- ©proDAD
- ***********************************************************/
-
- /*\
- *** Example:
- ***
- \*/
-
-
- #define __COMPUTER_AMIGA 1
- #define NOMYDEBUG
-
- #include "p:pExec/Interupt.h"
- #include "p:pResource/IRQRes.h"
- #include "p:pExec/Node.h"
- #include "p:pDOS/ArgTags.h"
- #include "p:pDOS/DosSig.h"
-
- #include "p:proto/pDos2.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pOS.h"
-
-
- ULONG VBlank_func(_R_A0 struct pOS_Interrupt*);
-
-
- const CHAR *HelpText=
- ""
- ;
-
- const CHAR *PrgHeader=
- "";
-
- const CHAR *PrgVerText=
- "$VER: 1.0 ("__DATE2__") (Copyright 1997 by proDAD) (Created by Holger Burkarth)";
-
-
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- ULONG Ops[1]={0};
-
- Args=pOS_ReadDosArgs(
- // 0
- "",
- Ops,sizeof(Ops)/sizeof(ULONG),
-
- ARGTAG_PrgHeaderText, (ULONG)PrgHeader, /* kurze Programm-Beschreibung */
- ARGTAG_HelpText, (ULONG)HelpText, /* Help-Texte */
- ARGTAG_PrgVerText, (ULONG)PrgVerText, /* VER-String */
- TAG_END);
-
- if(Args) {
- struct pOS_Resource *IRQBase;
-
- IRQBase=pOS_OpenResource("IRQ.resource");
- if(IRQBase) {
- struct pOS_StdIRQResourceMFunction *const IRQ=_pOS_GetIRQResourceFunction(IRQBase);
- struct pOS_Interrupt Inter={0};
-
- Inter.is_Node.ln_Type=NTYP_INTERRUPT;
- Inter.is_Node.ln_Name="VBlankIRQ-Test";
- Inter.is_Code=(ULONG(*)(_R_A0 const struct pOS_Interrupt*,_R_A1 APTR)) VBlank_func;
- Inter.is_UserData[0]=(ULONG)pOS_FindTask(NULL);
- Inter.is_UserData[1]=1000;
-
- if((*IRQ->pOS_AddIRQServer_func)(IRQBase,IRQTYP_VBlank,&Inter)) {
- printf("VBlank installed, waiting 1000 blanks, or Ctrl-F\n");
- pOS_WaitSignal(DOSSIGF_CTRL_F);
- (*IRQ->pOS_RemIRQServer_func)(IRQBase,IRQTYP_VBlank,&Inter);
- printf("removed, is_UserData[1]=%ld\n",Inter.is_UserData[1]);
- }
- else printf("Cannot add IRQ-Server\n");
- pOS_CloseResource(IRQBase);
- }
- else printf("Cannot open IRQ.resource\n");
- pOS_DeleteDosArgs(Args); /* Args freigeben */
- }
- }
-
-
-
- ULONG VBlank_func(_R_A0 struct pOS_Interrupt* inter)
- {
- if(--inter->is_UserData[1]==0) {
- pOS_SendSignal((struct pOS_Task*)inter->is_UserData[0],DOSSIGB_CTRL_F);
- }
- return(0); /* pass other IRQ */
- }
-