revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / lowlevel / addvblankint.c
bloba14588e94b6eea601f5bae93e0e3a9b3aafdb249
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include "lowlevel_intern.h"
11 #include <aros/libcall.h>
12 #include <exec/types.h>
13 #include <libraries/lowlevel.h>
14 #include <hardware/intbits.h>
16 /*****************************************************************************
18 NAME */
20 AROS_LH2(APTR, AddVBlankInt,
22 /* SYNOPSIS */
23 AROS_LHA(APTR, intRoutine, A0),
24 AROS_LHA(APTR, intData, A1),
26 /* LOCATION */
27 struct LowLevelBase *, LowLevelBase, 18, LowLevel)
29 /* FUNCTION
31 Add a callback function that should be executed every vertical blank.
32 If your program can exit without rebooting the machine, RemVBlankInt()
33 has to be called prior to exiting.
34 Only one interrupt routine may be added; always check the return
35 value of this function in case some other program already has used this
36 function.
38 INPUTS
40 intRoutine -- the callback function to invoke each vertical blank
41 intData -- data passed to the callback function
43 RESULT
45 A handle used to manipulate the interrupt or NULL if the call failed.
47 BUGS
49 SEE ALSO
51 RemVBlankInt()
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
59 APTR result;
61 if (intRoutine == NULL)
63 return NULL;
66 ObtainSemaphore(&LowLevelBase->ll_Lock);
68 if (LowLevelBase->ll_VBlank.is_Code == NULL)
70 LowLevelBase->ll_VBlank.is_Code = intRoutine;
71 LowLevelBase->ll_VBlank.is_Data = intData;
73 AddIntServer(INTB_VERTB, &LowLevelBase->ll_VBlank);
74 result = (APTR)&LowLevelBase->ll_VBlank;
76 else
78 result = NULL;
81 ReleaseSemaphore(&LowLevelBase->ll_Lock);
83 return result;
85 AROS_LIBFUNC_EXIT
86 } /* AddVBlankInt */