Updated interpreters
[projects/chimara/chimara.git] / interpreters / frotz / process.c
index e79edf518eea73f7a9e752c4a2eae4fe698454b1..58c86078b0c10547c6180833451ce6babf17833b 100644 (file)
@@ -138,7 +138,7 @@ void (*var_opcodes[0x40]) (void) = {
     z_check_arg_count
 };
 
-void (*ext_opcodes[0x1d]) (void) = {
+void (*ext_opcodes[0x1e]) (void) = {
     z_save,
     z_restore,
     z_log_shift,
@@ -152,7 +152,7 @@ void (*ext_opcodes[0x1d]) (void) = {
     z_restore_undo,
     z_print_unicode,
     z_check_unicode,
-    __illegal__,
+    z_set_true_colour, /* spec 1.1 */
     __illegal__,
     __illegal__,
     __illegal__, // glkify - z_move_window,
@@ -168,20 +168,21 @@ void (*ext_opcodes[0x1d]) (void) = {
     z_print_form,
     z_make_menu,
     __illegal__, // glkify - z_picture_table
+    z_buffer_screen, /* spec 1.1 */
 };
 
 
 /*
- * init_process
+ * init_proc
  *
  * Initialize process variables.
  *
  */
 
-void init_process (void)
+void init_proc (void)
 {
     finished = 0;
-} /* init_process */
+} /* init_proc */
 
 
 /*
@@ -337,7 +338,7 @@ void call (zword routine, int argc, zword *args, int ct)
     *--sp = (zword) (pc >> 9);
     *--sp = (zword) (pc & 0x1ff);
     *--sp = (zword) (fp - stack - 1);
-    *--sp = (zword) (argc | (ct << (f_setup.save_quetzal ? 12 : 8)));
+    *--sp = (zword) (argc | (ct << (option_save_quetzal ? 12 : 8)));
 
     fp = sp;
     frame_count++;
@@ -350,8 +351,12 @@ void call (zword routine, int argc, zword *args, int ct)
        pc = (long) routine << 2;
     else if (h_version <= V7)
        pc = ((long) routine << 2) + ((long) h_functions_offset << 3);
-    else /* h_version == V8 */
+    else if (h_version <= V8)
        pc = (long) routine << 3;
+    else /* h_version == V9 */ {
+       long indirect = (long) routine << 2;
+       HIGH_LONG(indirect, pc);
+     }
 
     if (pc >= story_size)
        runtime_error (ERR_ILL_CALL_ADDR);
@@ -367,7 +372,7 @@ void call (zword routine, int argc, zword *args, int ct)
     if (sp - stack < count)
        runtime_error (ERR_STK_OVF);
 
-    if (f_setup.save_quetzal)
+    if (option_save_quetzal)
        fp[0] |= (zword) count << 8;    /* Save local var count for Quetzal. */
 
     value = 0;
@@ -408,7 +413,7 @@ void ret (zword value)
 
     sp = fp;
 
-    ct = *sp++ >> (f_setup.save_quetzal ? 12 : 8);
+    ct = *sp++ >> (option_save_quetzal ? 12 : 8);
     frame_count--;
     fp = stack + 1 + *sp++;
     pc = *sp++;
@@ -573,7 +578,7 @@ static void __extended__ (void)
 
     load_all_operands (specifier);
 
-    if (opcode < 0x1d)                 /* extended opcodes from 0x1d on */
+    if (opcode < 0x1e)                 /* extended opcodes from 0x1e on */
        ext_opcodes[opcode] ();         /* are reserved for future spec' */
 
 }/* __extended__ */
@@ -602,7 +607,7 @@ static void __illegal__ (void)
 void z_catch (void)
 {
 
-    store (f_setup.save_quetzal ? frame_count : (zword) (fp - stack));
+    store (option_save_quetzal ? frame_count : (zword) (fp - stack));
 
 }/* z_catch */
 
@@ -617,7 +622,7 @@ void z_catch (void)
 void z_throw (void)
 {
 
-    if (f_setup.save_quetzal) {
+    if (option_save_quetzal) {
        if (zargs[1] > frame_count)
            runtime_error (ERR_BAD_FRAME);