home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / Epoc / Palmtime / files / FrotzS5_src.ZIP / S5api.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-11  |  7.4 KB  |  283 lines

  1. // S5api.h
  2.  
  3. #define FILE void
  4. #ifndef far
  5. #define far
  6. #endif
  7. #ifndef NULL
  8. #define NULL 0
  9. #endif
  10.  
  11. #include "frotz.h"
  12. #include "s5frotz.h"
  13. #include <e32std.h>
  14.  
  15. #ifndef HISTORY_BUFSIZE
  16. #define HISTORY_BUFSIZE 500
  17. #endif
  18. #define MAX_NESTING 16
  19.  
  20.  
  21. struct sg
  22. {
  23. void *papp;
  24. void *ss; /* = RMainServ*/
  25. char thestoryname[128];
  26. TInt64 seed;
  27. unsigned char filebuffin[512];
  28. unsigned char filebuffout[512];
  29. short script_valid;
  30. short locked;
  31. short flag;
  32. short pos;
  33. void *hbuff[2+MAX_UNDO_SLOTS]; // 0 = story, 1 = reserved, 2+ = undo
  34. void *aFs;
  35. void *thisthread;
  36. short first_restart;
  37. zchar decoded[10];
  38. zword encoded[3];
  39. struct {
  40.     enum story story_id;
  41.     short pic;
  42.     short pic1;
  43.     short pic2;
  44. } mapper[28];
  45. struct {
  46.     zword y_pos;
  47.     zword x_pos;
  48.     zword y_size;
  49.     zword x_size;
  50.     zword y_cursor;
  51.     zword x_cursor;
  52.     zword left;
  53.     zword right;
  54.     zword nl_routine;
  55.     zword nl_countdown;
  56.     zword style;
  57.     zword colour;
  58.     zword font;
  59.     zword font_size;
  60.     zword attribute;
  61.     zword line_count;
  62. } wp[8], *cwp;
  63. short current_bg;
  64. short current_fg;
  65. short current_style;
  66. short current_font;
  67. byte text_bg;
  68. byte text_fg;
  69. short bg;
  70. short fg;
  71. byte scrn_attr;
  72. short cursor_x;
  73. short cursor_y;
  74. byte far *graphics_font;
  75. byte far *mcga_font;
  76. byte far *mcga_width;
  77. word far *serif_font;
  78. byte far *serif_width;
  79. long limit;
  80. struct {
  81.     zchar buffer[HISTORY_BUFSIZE];
  82.     short latest;
  83.     short current;
  84.     short prefix_len;
  85. } history;
  86. struct {
  87.     zchar *buffer;
  88.     short pos;
  89.     short length;
  90.     short max_length;
  91.     short width;
  92.     short max_width;
  93. } input;
  94. short overwrite;
  95. short keytimeout;
  96. char *progname;
  97. char stripped_story_name[10];
  98. short display;
  99. short user_background;
  100. short user_foreground;
  101. short user_emphasis;
  102. short user_bold_typing;
  103. short user_reverse_bg;
  104. short user_reverse_fg;
  105. short user_screen_height;
  106. short user_screen_width;
  107. short user_tandy_bit;
  108. short user_random_seed;
  109. short user_font;
  110. byte old_video_mode;
  111. struct {
  112.     zword xsize;
  113.     zword table;
  114.     zword width;
  115.     zword total;
  116. } redirect[MAX_NESTING];
  117. void (*op0_opcodes[0x10]) (struct sg *);
  118. void (*op1_opcodes[0x10]) (struct sg *);
  119. void (*var_opcodes[0x40]) (struct sg *);
  120. void (*ext_opcodes[0x1d]) (struct sg *);
  121. zword zargs[8];
  122. short zargc;
  123. char *optarg;
  124. char script_name[MAX_FILE_NAME + 1];
  125. char command_name[MAX_FILE_NAME + 1];
  126. struct {
  127.     enum story story_id;
  128.     zword release;
  129.     zbyte serial[7];
  130.     } records[25];
  131. unsigned char Header[64];
  132. char save_name[MAX_FILE_NAME + 1];
  133. char auxilary_name[MAX_FILE_NAME + 1];
  134. zbyte far *undo[MAX_UNDO_SLOTS];
  135. zchar buffer[TEXT_BUFFER_SIZE];
  136. char *story_name;
  137. enum story story_id;
  138. long story_size;
  139. zbyte h_version;
  140. zbyte h_config;
  141. zword h_release;
  142. zword h_resident_size;
  143. zword h_start_pc;
  144. zword h_dictionary;
  145. zword h_objects;
  146. zword h_globals;
  147. zword h_dynamic_size;
  148. zword h_flags;
  149. zbyte h_serial[6];
  150. zword h_abbreviations;
  151. zword h_file_size;
  152. zword h_checksum;
  153. zbyte h_interpreter_number;
  154. zbyte h_interpreter_version;
  155. zbyte h_screen_rows;
  156. zbyte h_screen_cols;
  157. zword h_screen_width;
  158. zword h_screen_height;
  159. zbyte h_font_height;
  160. zbyte h_font_width;
  161. zword h_functions_offset;
  162. zword h_strings_offset;
  163. zbyte h_default_background;
  164. zbyte h_default_foreground;
  165. zword h_terminating_keys;
  166. zword h_line_width;
  167. zbyte h_standard_high;
  168. zbyte h_standard_low;
  169. zword h_alphabet;
  170. zword h_extension_table;
  171. zbyte h_user_name[8];
  172. zword hx_table_size;
  173. zword hx_mouse_x;
  174. zword hx_mouse_y;
  175. zword hx_unicode_table;
  176. zword stack[STACK_SIZE];
  177. zword *sp;
  178. zword *fp;
  179. short ostream_screen;
  180. short ostream_script;
  181. short ostream_memory;
  182. short ostream_record;
  183. short istream_replay;
  184. short message;
  185. short cwin;
  186. short mwin;
  187. short mouse_y;
  188. short mouse_x;
  189. short enable_wrapping;
  190. short enable_scripting;
  191. short enable_scrolling;
  192. short enable_buffering;
  193. short option_attribute_assignment;
  194. short option_attribute_testing;
  195. short option_context_lines;
  196. short option_object_locating;
  197. short option_object_movement;
  198. short option_left_margin;
  199. short option_right_margin;
  200. short option_ignore_errors;
  201. short option_piracy;
  202. short option_undo_slots;
  203. short option_expand_abbreviations;
  204. short option_script_cols;
  205. long reserve_mem;
  206. short bufpos;
  207. zchar prev_c;
  208. zbyte far *zmp;
  209. zbyte far *pcp;
  210. FILE *story_fp;
  211. short undo_slots;
  212. short undo_count;
  213. short undo_valid;
  214. short script_width;
  215. FILE *sfp;
  216. FILE *rfp;
  217. FILE *pfp;
  218. short optind;
  219. short optopt;
  220. short finished;
  221. short interval;
  222. short counter;
  223. short depth;
  224. short font_height;
  225. short font_width;
  226. short input_redraw;
  227. short more_prompts;
  228. short discarding;
  229. short cursor;
  230. short input_window;
  231. zchar tempstr[100];     //Work area for displaying strings 
  232.  
  233. };
  234.  
  235. void __extended__ (struct sg *g);
  236. void __illegal__ (struct sg *g);
  237. int SrvDlgOpen(struct sg *g, char *pathsrc, char *file);
  238. int SrvDlgSave(struct sg *g, char *pathsrc, char *file);
  239. short frotzmain (short argc, char *argv[], struct sg *g);
  240. void SrvConnect(struct sg *g, void *tr);
  241. void SrvDisconnect(struct sg *g);
  242. unsigned short SrvGetTimedCh(struct sg *g, int delay);
  243. void SrvBeep(struct sg *g, int pitch);
  244. FILE *SrvOpenRead(struct sg *g, const char *filename); // uses RFile, returns NULL if error
  245. FILE *SrvOpenWrite(struct sg *g, const char *filename); // returns NULL if error
  246. FILE *SrvOpenRWText(struct sg *g, const char *filename); // Read/Write && text mode
  247. FILE *SrvOpenWText(struct sg *g, const char *filename); // Write && text mode
  248. FILE *SrvOpenRText(struct sg *g, const char *filename); // Read && text mode
  249. void SrvClose(struct sg *g, FILE *file);
  250. void SrvSeek(struct sg *g, FILE *file, int offset, int origin);
  251. int  SrvTell(struct sg *g, FILE *file);
  252. int  SrvRead (struct sg *g, void *buff, int width, int count, FILE *file);  // returns <= 'count' !
  253. int  SrvWrite(struct sg *g, void *buff, int width, int count, FILE *file); // returns <= 'count' !
  254. int  SrvPutc (struct sg *g, int c, FILE *file); // return the char written
  255. int  SrvGetc(struct sg *g, FILE *file); // EOF = returns 0
  256. void SrvSetFileSize(struct sg *g, FILE *file, int adjust);
  257. int  SrvError(struct sg *g, FILE *file); // return always 0....
  258. char *Srvstrchr(const char *str, char c);
  259. int  Srvstrlen(char *str);
  260. void Srvmemcpy(void *dst, void *src, int count);
  261. void Srvmemmove (void *dst, void *src, int count);
  262. char *Srvstrcpy(char *dst, const char *src); // returns dst
  263. char *Srvstrcat(char *dst, const char *src); // returns dst
  264. void *SrvMalloc(struct sg *g, int num, int size); // uses HBufC, alloc size+4 (pointer to HBufC) TDes->Ptr()
  265. void SrvFree(struct sg *g, int num, void *buff);  // uses delete
  266. void *SrvRealloc(struct sg *g, int num, void *buff, int size);
  267.  
  268. void SrvExit(struct sg *g); // To check, all exit conditions...
  269.  
  270. void SrvEraseRect(struct sg *g, int top, int left, int bottom, int right, int rev);
  271. void SrvScroll(struct sg *g, int top, int left, int bottom, int right, int units, int rev);
  272. void SrvSwitchCursor(struct sg *g, int cursor);
  273. void SrvTextAttr(struct sg *g, int attr); // bit 1 = reverse, 2 = emphasis, 3 = bold
  274. void SrvPrintf(struct sg *g, const char *msg);
  275. void SrvPutChar(struct sg *g, int x, int y, unsigned char c);
  276. void SrvPutString(struct sg *g, int x, int y, zchar *s);
  277. void SrvSetCursor(struct sg *g, int x, int y);
  278. void SrvGetStoryName(struct sg *g, char **sn);
  279. void SrvScreenSize(struct sg *g, int *w, int *h);
  280. /* Return an appropriate random seed value in the range from 0 to
  281.  * 32767, possibly by using the current system time.*/
  282. int SrvRandom(struct sg *g);
  283.