-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathh2cdplay_cli.c
56 lines (49 loc) · 985 Bytes
/
h2cdplay_cli.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <windows.h>
#define MAXTRACK 64
HANDLE evt[MAXTRACK];
void
create_events ()
{
char evtnamebuf[1024];
int i;
for (i = 0; i < MAXTRACK; i++)
{
sprintf (evtnamebuf, "h2cd_play_track#%02d", i);
evt[i] = CreateEvent (NULL, FALSE, FALSE, evtnamebuf);
}
}
void
fire_event (int trknum)
{
if (!SetEvent (evt[trknum]))
{
printf ("SetEvent failed (%ld)\n", (long int)GetLastError ());
return;
}
}
int
main (int argc, char **argv)
{
int trknum = 0;
printf
("HOMM2 CD music player\nEnter track number to play, 0 to stop playback, 1 to exit\n");
create_events ();
while (1)
{
int ret;
printf ("h2play> ");
ret = scanf ("%d", &trknum);
if (ret == EOF)
return 0;
if (!ret)
continue;
printf ("Event: %d\n", trknum);
fire_event (trknum);
if (trknum == 63)
{
printf ("Terminating\n");
return 0;
}
}
}