Beispiel #1
0
void z_read( zmachine *zm ) {
  zbyte max = read_byte( zm, zm->zargs[0] );
  zbyte size = read_byte( zm, zm->zargs[0] + 1 );

  VALUE line;

  int i;

  if( h_version(zm) < 5 ) {
    max -= 1;
    size = 0;
  }

  line = rb_funcall( keyboard(zm), id_read_line, 1, UINT2NUM(max - size) );

  for( i = 0; i < RSTRING_LEN(line); i++ ) {
    zchar c = *(RSTRING_PTR(line) + i);

    write_byte( zm, zm->zargs[0] + text_buffer_offset(zm) + size + i, 
      translate_to_zscii( zm->m, c ) );
  }

  if( h_version(zm) < 5 ) {
    write_byte( zm, zm->zargs[0] + text_buffer_offset(zm) + size + i, 0 );
  }

  if( h_version(zm) > 4 ) {
    write_byte( zm, zm->zargs[0] + 1, i );
  }

  /* write the parse table */

  if( zm->zargs[1] != 0 ) {
    write_parse_table( zm, line, zm->zargs[1], h_dictionary(zm), 0 );
  }

  /* echo the input back to the output */

  print_cstr( zm, "> " );
  print_rstr( zm, line );
  print_cstr( zm, "\n" );

  /* store the terminating character (if required) */

  if( h_version(zm) > 4 ) {
    p_store( zm, translate_to_zscii( zm->m, 10 ) );
  }
}
Beispiel #2
0
VALUE status_location_number( VALUE self ) {
  VALUE machine = rb_iv_get( self, "@machine" );
  zmachine *zm;

  Data_Get_Struct( machine, zmachine, zm );

  if( h_version(zm) > 3 ) {
    return Qnil;
  }

  return UINT2NUM(read_word( zm, h_global_table(zm) ));
}
Beispiel #3
0
VALUE status_minutes( VALUE self ) {
  VALUE machine = rb_iv_get( self, "@machine" );
  zmachine *zm;

  Data_Get_Struct( machine, zmachine, zm );

  if( h_version(zm) > 3 ) {
    return Qnil;
  }

  if( ! h_status_line_time(zm) ) {
    return Qnil;
  }

  return INT2NUM(read_word( zm, h_global_table(zm) + 4 ));
}
Beispiel #4
0
VALUE status_location_name( VALUE self ) {
  VALUE machine = rb_iv_get( self, "@machine" );
  zmachine *zm;
  zaddr naddr;
  zword n;

  Data_Get_Struct( machine, zmachine, zm );

  if( h_version(zm) > 3 ) {
    return Qnil;
  }

  n = read_word( zm, h_global_table(zm) );

  naddr = obj_name_addr( zm, n ) + 1; /* skip the size byte */

  return machine_read_string( zm->self, LONG2NUM((long) naddr) );
}
Beispiel #5
0
VALUE status_type( VALUE self ) {
  VALUE machine = rb_iv_get( self, "@machine" );
  zmachine *zm;

  Data_Get_Struct( machine, zmachine, zm );

  if( h_version(zm) > 3 ) {
    return Qnil;
  }

  if( h_status_line_score(zm) ) {
    return sym_score;
  }
  else if( h_status_line_time(zm) ) {
    return sym_time;
  }

  return Qnil;
}