summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/amunits/examples/otherlibs/smallplay.pas
blob: f8281c8601826465bee66f7154472f9da79c0cce (plain)
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
program smallplay;

{****************************************

 PT-Player 2.0   © 1994 BetaSoft

 uses PTReplay.library also by BetaSoft
 and Andreas [Pucko] Pålsson

****************************************}
uses exec, amigados, ptreplay;

const
    vstr : pchar = '$VER: SmallPlay 2.0 (23.12.93)';

var
    module : pModule;
    SigBit : shortint;
    SigMask : longint;

procedure CleanUp(why : string, err : integer);
begin
    if why <> '' then writeln(why);
    halt(err);
end;

begin
    module := nil;
    if ParamCount > 1 then
       CleanUp('Specify one module only',20);
    if ParamCount < 0 then
       CleanUp('Play what module?',20);

    module := PTLoadModule(ParamStr[1]);
    if not assigned(module) then
       CleanUp('Couldn''t open/load module',20);

    SigBit := AllocSignal(-1);
    if SigBit = -1 then
       CleanUp('Couldn''t allocate signal',10);

    PTInstallBits(module,SigBit,-1,-1,-1);
    PTPlay(module);

    SigMask := Wait(SIGBREAKF_CTRL_C or (1 shl SigBit));
    if (SigMask and SIGBREAKF_CTRL_C) then
        PTFade(module,1)
    else
        PTStop(module);

    FreeSignal(SigBit);

    PTUnloadModule(module);
end.