prism2.device: Compiler delint
[AROS.git] / workbench / demos / realtdemo.c
blobb3fb8128c65d37619650b026b2abe63de2a396c3
1 /*
2 Copyright © 2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Test program for RealTime.library
6 Lang: English
7 */
10 #include <aros/debug.h>
11 #include <aros/asmcall.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <dos/dos.h>
15 #include <exec/memory.h>
16 #include <utility/hooks.h>
17 #include <utility/tagitem.h>
19 #include <libraries/realtime.h>
20 #include <proto/realtime.h>
22 #include <stdio.h>
23 #include <stdlib.h>
26 AROS_UFP3(ULONG, myFunc,
27 AROS_UFPA(struct Hook * , hook , A0),
28 AROS_UFPA(struct pmTime *, message, A1),
29 AROS_UFPA(struct Player *, player , A2));
32 int main(int argc, char* argv[])
34 struct Library *RealTimeBase = OpenLibrary("realtime.library", 40);
35 struct Hook myHook;
37 struct TagItem tags[] = { { PLAYER_Name , (IPTR)"Test player" },
38 { PLAYER_Hook , (IPTR)&myHook },
39 { PLAYER_Conductor, (IPTR)"Test conductor" },
40 { TAG_DONE , (IPTR)NULL } };
42 struct Player *player;
44 myHook.h_Entry = (HOOKFUNC)myFunc;
45 myHook.h_SubEntry = NULL;
46 myHook.h_Data = NULL;
48 if (RealTimeBase == NULL)
50 printf("Couldn't open realtime.library\n");
51 exit(1);
54 player = CreatePlayerA(tags);
56 if (player == NULL)
58 printf("Couldn't create player\n");
59 CloseLibrary(RealTimeBase);
60 exit(1);
63 SetConductorState(player, CONDSTATE_RUNNING, 0);
66 struct TagItem tags[] = { { PLAYER_Ready, TRUE },
67 { TAG_DONE, 0 } };
69 SetPlayerAttrsA(player, tags);
72 Wait(SIGBREAKF_CTRL_C);
74 DeletePlayer(player);
76 CloseLibrary(RealTimeBase);
78 return 0;
82 AROS_UFH3(ULONG, myFunc,
83 AROS_UFHA(struct Hook * , hook , A0),
84 AROS_UFHA(struct pmTime *, message, A1),
85 AROS_UFHA(struct Player *, player , A2))
87 AROS_USERFUNC_INIT
89 switch (message->pmt_Method)
91 case PM_TICK:
92 kprintf("Tick at clock %u\n", message->pmt_Time);
93 break;
95 case PM_POSITION:
96 kprintf("Position change: Clock %u\n", message->pmt_Time);
97 break;
99 case PM_SHUTTLE:
100 kprintf("Shuttling into clock %u\n", message->pmt_Time);
101 break;
103 case PM_STATE:
104 kprintf("State change... old state = %u\n",
105 ((struct pmState *)message)->pms_OldState);
107 default:
108 kprintf("Error: Bogus message with method %u\n", message->pmt_Method);
109 break;
112 return 0;
114 AROS_USERFUNC_EXIT