-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGlk Events.i7x
73 lines (49 loc) · 2.01 KB
/
Glk Events.i7x
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Version 1/160919 of Glk Events (for Glulx only) by Dannii Willis begins here.
"A low level event handling system"
Use authorial modesty.
Include version 1/160919 of Glulx Definitions by Dannii Willis.
Chapter - Basic event handling
Section - Event result variables
Include (-
Global GE_Event_Struct_type;
Global GE_Event_Struct_win;
Global GE_Event_Struct_val1;
Global GE_Event_Struct_val2;
-) before "Glulx.i6t".
The glk event type is a g-event variable.
The glk event type variable translates into I6 as "GE_Event_Struct_type".
The glk event window ref is a number variable.
The glk event window ref variable translates into I6 as "GE_Event_Struct_win".
The glk event value 1 is a number variable.
The glk event value 1 variable translates into I6 as "GE_Event_Struct_val1".
The glk event value 2 is a number variable.
The glk event value 2 variable translates into I6 as "GE_Event_Struct_val2".
Section - The glulx input handling rules
The glulx input handling rules are a g-event based rulebook.
Section - Intercepting glk_select()
[ Rather than implementing HandleGlkEvent() as GEP did, we will intercept glk_select(). This allows us to intercept events before the Inform 7 template starts processing them. ]
Include (-
Replace glk_select;
-) before "Glulx.i6t".
Include (-
! Replacement function from Glk Events by Dannii Willis
[ glk_select event_struct;
! Call the real glk_select
@push event_struct;
@glk 192 1 0;
! Copy values to our variables
GE_Event_Struct_type = event_struct-->0;
GE_Event_Struct_win = event_struct-->1;
GE_Event_Struct_val1 = event_struct-->2;
GE_Event_Struct_val2 = event_struct-->3;
! Run the glulx input handling rules
FollowRulebook( (+ the glulx input handling rules +), GE_Event_Struct_type, true );
! Copy back to the original event structure
event_struct-->0 = GE_Event_Struct_type;
event_struct-->1 = GE_Event_Struct_win;
event_struct-->2 = GE_Event_Struct_val1;
event_struct-->3 = GE_Event_Struct_val2;
return 0;
];
-) after "Infglk" in "Glulx.i6t".
Glk Events ends here.