~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to docs/go32ex/keyclick.pp

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{$ASMMODE ATT}
2
 
{$MODE FPC}
3
 
 
4
 
uses
5
 
        crt,
6
 
        go32;
7
 
 
8
 
const
9
 
        kbdint = $9;
10
 
 
11
 
var
12
 
        oldint9_handler : tseginfo;
13
 
        newint9_handler : tseginfo;
14
 
 
15
 
        clickproc : pointer;
16
 
        backupDS : Word; external name '___v2prt0_ds_alias';
17
 
 
18
 
procedure int9_handler; assembler;
19
 
asm
20
 
        cli
21
 
        pushl %ds
22
 
        pushl %es
23
 
        pushl %fs
24
 
        pushl %gs
25
 
        pushal
26
 
        movw %cs:backupDS, %ax
27
 
        movw %ax, %ds
28
 
        movw %ax, %es
29
 
        movw dosmemselector, %ax
30
 
        movw %ax, %fs
31
 
        call *clickproc
32
 
        popal
33
 
        popl %gs
34
 
        popl %fs
35
 
        popl %es
36
 
        popl %ds
37
 
        ljmp %cs:oldint9_handler
38
 
end;
39
 
procedure int9_dummy; begin end;
40
 
 
41
 
procedure clicker;
42
 
begin
43
 
        sound(500); delay(10); nosound;
44
 
end;
45
 
procedure clicker_dummy; begin end;
46
 
 
47
 
procedure install_click;
48
 
begin
49
 
        clickproc := @clicker;
50
 
        lock_data(clickproc, sizeof(clickproc));
51
 
        lock_data(dosmemselector, sizeof(dosmemselector));
52
 
 
53
 
        lock_code(@clicker,
54
 
                longint(@clicker_dummy) - longint(@clicker));
55
 
        lock_code(@int9_handler,
56
 
                longint(@int9_dummy)-longint(@int9_handler));
57
 
        newint9_handler.offset := @int9_handler;
58
 
        newint9_handler.segment := get_cs;
59
 
        get_pm_interrupt(kbdint, oldint9_handler);
60
 
        set_pm_interrupt(kbdint, newint9_handler);
61
 
end;
62
 
 
63
 
procedure remove_click;
64
 
begin
65
 
        set_pm_interrupt(kbdint, oldint9_handler);
66
 
        unlock_data(dosmemselector, sizeof(dosmemselector));
67
 
        unlock_data(clickproc, sizeof(clickproc));
68
 
 
69
 
        unlock_code(@clicker,
70
 
                longint(@clicker_dummy)-longint(@clicker));
71
 
        unlock_code(@int9_handler,
72
 
                longint(@int9_dummy)-longint(@int9_handler));
73
 
end;
74
 
 
75
 
var
76
 
        ch : char;
77
 
 
78
 
begin
79
 
        install_click;
80
 
        Writeln('Enter any message. Press return when finished');
81
 
        while (ch <> #13) do begin
82
 
                ch := readkey; write(ch);
83
 
        end;
84
 
        remove_click;
85
 
end.
 
 
b'\\ No newline at end of file'