#include "glkfrotz.h"
-#define VERSION "2.43"
-
-f_setup_t f_setup;
+#define VERSION "2.50"
int curr_status_ht = 0;
int mach_status_ht = 0;
winid_t gos_curwin = NULL;
int gos_linepending = 0;
-char *gos_linebuf = NULL;
+zchar *gos_linebuf = NULL;
winid_t gos_linewin = NULL;
schanid_t gos_channel = NULL;
" -a watch attribute setting\n"\
" -A watch attribute testing\n"\
" -i ignore fatal errors\n"\
-" -I # interpreter number\n"\
" -o watch object movement\n"\
" -O watch object locating\n"\
" -P alter piracy opcode\n"\
/* Parse the options */
do {
- c = zgetopt(argc, argv, "aAiI:oOPQs:S:tu:xZ:");
+ c = zgetopt(argc, argv, "aAioOPQs:S:tu:xZ:");
switch (c)
{
- case 'a': f_setup.attribute_assignment = 1; break;
- case 'A': f_setup.attribute_testing = 1; break;
- case 'i': f_setup.ignore_errors = 1; break;
- case 'I': f_setup.interpreter_number = atoi(zoptarg); break;
- case 'o': f_setup.object_movement = 1; break;
- case 'O': f_setup.object_locating = 1; break;
- case 'P': f_setup.piracy = 1; break;
- case 'Q': f_setup.save_quetzal = 0; break;
+ case 'a': option_attribute_assignment = 1; break;
+ case 'A': option_attribute_testing = 1; break;
+ case 'i': option_ignore_errors = 1; break;
+ case 'o': option_object_movement = 1; break;
+ case 'O': option_object_locating = 1; break;
+ case 'P': option_piracy = 1; break;
+ case 'Q': option_save_quetzal = 0; break;
case 's': user_random_seed = atoi(zoptarg); break;
- case 'S': f_setup.script_cols = atoi(zoptarg); break;
+ case 'S': option_script_cols = atoi(zoptarg); break;
case 't': user_tandy_bit = 1; break;
- case 'u': f_setup.undo_slots = atoi(zoptarg); break;
- case 'x': f_setup.expand_abbreviations = 1; break;
- case 'Z': f_setup.err_report_mode = atoi(zoptarg);
- if ((f_setup.err_report_mode < ERR_REPORT_NEVER) ||
- (f_setup.err_report_mode > ERR_REPORT_FATAL))
- f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;
+ case 'u': option_undo_slots = atoi(zoptarg); break;
+ case 'x': option_expand_abbreviations = 1; break;
+ case 'Z': option_err_report_mode = atoi(zoptarg);
+ if ((option_err_report_mode < ERR_REPORT_NEVER) ||
+ (option_err_report_mode > ERR_REPORT_FATAL))
+ option_err_report_mode = ERR_DEFAULT_REPORT_MODE;
break;
}
} while (c != EOF);
char buf[256];
win = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
glk_set_window(win);
- glk_put_string("FROTZ V" VERSION " -- Glk 0.6.1 interface.\n");
+ glk_put_string("FROTZ V" VERSION " -- Glk 0.7.0 interface.\n");
glk_put_string(INFORMATION);
sprintf(buf,
" -Z # error checking mode (default = %d)\n"
* Init glk stuff
*/
- glk_stylehint_set(wintype_TextGrid, style_User1, stylehint_ReverseColor, 1);
-
+ /* monor */
+ glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Weight, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Oblique, 0);
+
+ /* monob */
+ glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Weight, 1);
+ glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Oblique, 0);
+
+ /* monoi */
+ glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Weight, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Oblique, 1);
+
+ /* monoz */
+ glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Weight, 1);
+ glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Oblique, 1);
+
+ /* propr */
+ glk_stylehint_set(wintype_TextBuffer, style_Normal, stylehint_Proportional, 1);
+ glk_stylehint_set(wintype_TextGrid, style_Normal, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Weight, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Oblique, 0);
+
+ /* propb */
+ glk_stylehint_set(wintype_TextBuffer, style_Header, stylehint_Proportional, 1);
+ glk_stylehint_set(wintype_TextGrid, style_Header, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_Weight, 1);
+ glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_Oblique, 0);
+
+ /* propi */
+ glk_stylehint_set(wintype_TextBuffer, style_Emphasized, stylehint_Proportional, 1);
+ glk_stylehint_set(wintype_TextGrid, style_Emphasized, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_Weight, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_Oblique, 1);
+
+ /* propi */
+ glk_stylehint_set(wintype_TextBuffer, style_Note, stylehint_Proportional, 1);
+ glk_stylehint_set(wintype_TextGrid, style_Note, stylehint_Proportional, 0);
+ glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_Weight, 1);
+ glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_Oblique, 1);
gos_lower = glk_window_open(0, 0, 0, wintype_TextGrid, 0);
if (!gos_lower)
if (h_version >= V4)
h_config |= CONFIG_BOLDFACE | CONFIG_EMPHASIS |
- CONFIG_FIXED | CONFIG_TIMEDINPUT;
+ CONFIG_FIXED | CONFIG_TIMEDINPUT | CONFIG_COLOUR;
if (h_version >= V5)
h_flags &= ~(GRAPHICS_FLAG | MOUSE_FLAG | MENU_FLAG);
if ((h_version == 3) && (h_flags & OLD_SOUND_FLAG))
h_flags |= OLD_SOUND_FLAG;
- if ((h_version == 6) && (f_setup.sound != 0))
+ if ((h_version == 6) && (option_sound != 0))
h_config |= CONFIG_SOUND;
if (h_version >= V5 && (h_flags & UNDO_FLAG))
- if (f_setup.undo_slots == 0)
+ if (option_undo_slots == 0)
h_flags &= ~UNDO_FLAG;
h_screen_cols = width;
/* Use the ms-dos interpreter number for v6, because that's the
* kind of graphics files we understand. Otherwise, use DEC. */
h_interpreter_number = h_version == 6 ? INTERP_MSDOS : INTERP_DEC_20;
- if (f_setup.interpreter_number > 0)
- h_interpreter_number = f_setup.interpreter_number;
h_interpreter_version = 'F';
{
/* Set these per spec 8.3.2. */
void os_restart_game (int stage) {}
-void os_fatal (char *s)
+void os_fatal (const char *s)
{
+ char err[256];
+ sprintf(err,"%s",s);
+
if (!gos_lower)
gos_lower = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
glk_set_window(gos_lower);
glk_set_style(style_Normal);
glk_put_string("\n\nFatal error: ");
- glk_put_string(s);
+ glk_put_string(err);
glk_put_string("\n");
glk_exit();
}
void os_init_setup(void)
{
- f_setup.attribute_assignment = 0;
- f_setup.attribute_testing = 0;
- f_setup.context_lines = 0;
- f_setup.object_locating = 0;
- f_setup.object_movement = 0;
- f_setup.left_margin = 0;
- f_setup.right_margin = 0;
- f_setup.ignore_errors = 0;
- f_setup.interpreter_number = 0;
- f_setup.piracy = 0;
- f_setup.undo_slots = MAX_UNDO_SLOTS;
- f_setup.expand_abbreviations = 0;
- f_setup.script_cols = 80;
- f_setup.save_quetzal = 1;
- f_setup.sound = 1;
- f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;
+ option_attribute_assignment = 0;
+ option_attribute_testing = 0;
+ option_context_lines = 0;
+ option_object_locating = 0;
+ option_object_movement = 0;
+ option_left_margin = 0;
+ option_right_margin = 0;
+ option_ignore_errors = 0;
+ option_piracy = 0;
+ option_undo_slots = MAX_UNDO_SLOTS;
+ option_expand_abbreviations = 0;
+ option_script_cols = 80;
+ option_save_quetzal = 1;
+ option_sound = 1;
+ option_err_report_mode = ERR_DEFAULT_REPORT_MODE;
}
void gos_cancel_pending_line(void)
if (gos_linepending)
gos_cancel_pending_line();
- glk_request_char_event(win);
+ glk_request_char_event_uni(win);
if (timeout != 0)
glk_request_timer_events(timeout * 100);
if (!continued || !gos_linepending)
{
- glk_request_line_event(win, buf, max, strlen(buf));
+ glk_request_line_event_uni(win, buf, max, os_string_length(buf));
if (timeout != 0)
glk_request_timer_events(timeout * 100);
}
return 0;
}
+void os_scrollback_char (zchar z)
+{
+ /* NOT IMPLEMENTED */
+}
+
+void os_scrollback_erase (int amount)
+{
+ /* NOT IMPLEMENTED */
+}
+
static glui32 flag2usage(int flag)
{
switch (flag)
return filemode_ReadWrite;
}
+frefid_t script_fref = NULL;
+int script_exists = 0;
+
strid_t frotzopenprompt(int flag)
{
frefid_t fref;
stm = glk_stream_open_file(fref, gmode, 0);
+ if (flag == FILE_SCRIPT)
+ {
+ if (script_fref)
+ glk_fileref_destroy(script_fref);
+ script_fref = glk_fileref_create_from_fileref(gusage, fref, 0);
+ script_exists = (script_fref != NULL);
+ }
+
glk_fileref_destroy(fref);
return stm;
}
+strid_t frotzreopen(int flag)
+{
+ frefid_t fref;
+
+ if (flag == FILE_SCRIPT && script_exists)
+ fref = script_fref;
+ else
+ return NULL;
+
+ strid_t stm;
+ glui32 gusage = flag2usage(flag);
+ glui32 gmode = flag2mode(flag);
+
+ stm = glk_stream_open_file(fref, gmode, 0);
+
+ return stm;
+}
+
strid_t frotzopen(char *filename, int flag)
{
frefid_t fref;