Debian Codegraph @

terps/glulxe/gestalt.c

raw symbols SCIP
1 /* gestalt.c: Glulxe code for gestalt selectors
2 Designed by Andrew Plotkin <[email protected]>
3 http://eblong.com/zarf/glulx/index.html
4 */
5
6 #include "glk.h"
7 #include "glulxe.h"
8 #include "gestalt.h"
9
10 glui32 do_gestalt(glui32 val, glui32 val2)
11 {
12 switch (val) {
13
14 case gestulx_GlulxVersion:
15 return 0x00030103; /* Glulx spec version 3.1.3 */
16
17 case gestulx_TerpVersion:
18 return 0x00000601; /* Glulxe version 0.6.1 */
19
20 case gestulx_ResizeMem:
21 #ifdef FIXED_MEMSIZE
22 return 0; /* The setmemsize opcodes are compiled out. */
23 #else /* FIXED_MEMSIZE */
24 return 1; /* We can handle setmemsize. */
25 #endif /* FIXED_MEMSIZE */
26
27 case gestulx_Undo:
28 if (max_undo_level > 0)
29 return 1; /* We can handle saveundo and restoreundo. */
30 return 0; /* Got "--undo 0", so nope. */
31
32 case gestulx_IOSystem:
33 switch (val2) {
34 case 0:
35 return 1; /* The "null" system always works. */
36 case 1:
37 return 1; /* The "filter" system always works. */
38 case 2:
39 return 1; /* A Glk library is hooked up. */
40 default:
41 return 0;
42 }
43
44 case gestulx_Unicode:
45 return 1; /* We can handle Unicode. */
46
47 case gestulx_MemCopy:
48 return 1; /* We can do mcopy/mzero. */
49
50 case gestulx_MAlloc:
51 #ifdef FIXED_MEMSIZE
52 return 0; /* The malloc opcodes are compiled out. */
53 #else /* FIXED_MEMSIZE */
54 return 1; /* We can handle malloc/mfree. */
55 #endif /* FIXED_MEMSIZE */
56
57 case gestulx_MAllocHeap:
58 return heap_get_start();
59
60 case gestulx_Acceleration:
61 return 1; /* We can do accelfunc/accelparam. */
62
63 case gestulx_AccelFunc:
64 if (accel_find_func(val2))
65 return 1; /* We know this accelerated function. */
66 return 0;
67
68 case gestulx_Float:
69 #ifdef FLOAT_SUPPORT
70 return 1; /* We can do floating-point operations. */
71 #else /* FLOAT_SUPPORT */
72 return 0; /* The floating-point opcodes are not compiled in. */
73 #endif /* FLOAT_SUPPORT */
74
75 case gestulx_ExtUndo:
76 return 1; /* We can handle hasundo and discardundo. */
77
78 case gestulx_Double:
79 #ifdef FLOAT_SUPPORT
80 #ifdef DOUBLE_SUPPORT /* Inside FLOAT_SUPPORT! */
81 return 1; /* We can do double-precision operations. */
82 #else /* DOUBLE_SUPPORT */
83 return 0; /* The double-precision opcodes are not compiled in. */
84 #endif /* DOUBLE_SUPPORT */
85 #else /* FLOAT_SUPPORT */
86 return 0; /* Neither float nor double opcodes are compiled in. */
87 #endif /* FLOAT_SUPPORT */
88
89 #ifdef GLULX_EXTEND_GESTALT
90 GLULX_EXTEND_GESTALT
91 #endif /* GLULX_EXTEND_GESTALT */
92
93 default:
94 return 0;
95
96 }
97 }