Fixing installed headers and directories
[projects/chimara/chimara.git] / interpreters / nitfol / startmac.c
1 #line 576 "opt2glkc.pl"
2 #include "nitfol.h"
3 #include "macglk_startup.h"
4
5 static strid_t mac_gamefile;
6
7 static BOOL hashandle = FALSE;
8 static AliasHandle gamehandle;
9 #line 694 "opt2glkc.pl"
10 strid_t startup_findfile(void)
11 {
12   ;
13 }
14 #line 586 "opt2glkc.pl"
15 strid_t intd_filehandle_open(strid_t savefile, glui32 operating_id,
16                              glui32 contents_id, glui32 interp_id,
17                              glui32 length)
18 {
19   FSSpec file;
20   Boolean wasChanged;
21   if(operating_id != 0x4d414353 /* 'MACS' */)
22     return 0;
23   if(contents_id != 0)
24     return 0;
25   if(interp_id != 0x20202020 /* '    ' */)
26     return 0;
27
28   gamehandle = NewHandle(length);
29   glk_get_buffer_stream(savefile, *gamehandle, length);
30   hashandle = TRUE;
31   ResolveAlias(NULL, gamehandle, &file, &wasChanged);
32   return macglk_stream_open_fsspec(&file, 0, 0);  
33 }
34
35 void intd_filehandle_make(strid_t savefile)
36 {
37   if(!hashandle)
38     return;
39   glk_put_string_stream(savefile, "MACS");
40   glk_put_char_stream(savefile, b00000010); /* Flags */
41   glk_put_char_stream(savefile, 0);         /* Contents ID */
42   glk_put_char_stream(savefile, 0);         /* Reserved */
43   glk_put_char_stream(savefile, 0);         /* Reserved */
44   glk_put_string_stream(savefile, "    ");/* Interpreter ID */
45   glk_put_buffer_stream(savefile, *gamehandle, *gamehandle->aliasSize);
46 }
47
48 glui32 intd_get_size(void)
49 {
50   if(!hashandle)
51     return 0;
52   return *gamehandle->aliasSize + 12;
53 }
54
55 static Boolean mac_whenselected(FSSpec *file, OSType filetype)
56 {
57   NewAlias(NULL, file, &gamehandle);
58   hashandle = TRUE;
59   return game_use_file(mac_gamefile);
60 }
61
62 static Boolean mac_whenbuiltin()
63 {
64   return game_use_file(mac_gamefile);
65 }
66
67 Boolean macglk_startup_code(macglk_startup_t *data)
68 {
69   OSType mac_gamefile_types[] = { 0x5a434f44 /* 'ZCOD' */, 0x49465253 /* 'IFRS' */, 0x49465a53 /* 'IFZS' */ };
70
71   data->startup_model  = macglk_model_ChooseOrBuiltIn;
72   data->app_creator    = 0x6e695466 /* 'niTf' */;
73   data->gamefile_types = mac_gamefile_types;
74   data->num_gamefile_types = sizeof(mac_gamefile_types) / sizeof(*mac_gamefile_types);
75   data->savefile_type  = 0x49465a53 /* 'IFZS' */;
76   data->datafile_type  = 0x5a697044 /* 'ZipD' */;
77   data->gamefile       = &mac_gamefile;
78   data->when_selected  = mac_whenselected;
79   data->when_builtin   = mac_whenbuiltin;
80
81   return TRUE;
82 }