Exemple #1
0
int runblorb(char *path, char *game)
{
    char magic[4];
    strid_t file;
    giblorb_result_t res;
    giblorb_err_t err;
    giblorb_map_t *map;

    sprintf(tmp, "Could not load Blorb file:\n%s\n", game);

    file = glkunix_stream_open_pathname(game, 0, 0);
    if (!file)
    {
        winmsg(tmp);
        return FALSE;
    }

    err = giblorb_create_map(file, &map);
    if (err)
    {
        winmsg(tmp);
        return FALSE;
    }

    err = giblorb_load_resource(map, giblorb_method_FilePos,
            &res, giblorb_ID_Exec, 0);
    if (err)
    {
        winmsg(tmp);
        return FALSE;
    }

    glk_stream_set_position(file, res.data.startpos, 0);
    glk_get_buffer_stream(file, magic, 4);

    switch (res.chunktype)
    {
        case ID_ZCOD:
            if (strlen(terp))
                return winterp(path, strcat(exe,terp), flags, game);
            else if (magic[0] == 6)
                return winterp(path, strcat(exe,T_ZSIX), flags, game);
            else
                return winterp(path, strcat(exe,T_ZCODE), flags, game);
            break;

        case ID_GLUL:
            if (strlen(terp))
                return winterp(path, strcat(exe,terp), flags, game);
            else
                return winterp(path, strcat(exe,T_GLULX), flags, game);
            break;

        default:
            sprintf(tmp, "Unknown game type in Blorb file:\n%s\n", game);
            winmsg(tmp);
    }
    
    return FALSE;
}
Exemple #2
0
giblorb_err_t giblorb_set_resource_map(strid_t file)
{
  giblorb_err_t err;
  
  err = giblorb_create_map(file, &blorbmap);
  if (err) {
    blorbmap = 0; /* NULL */
    return err;
  }
  
  return giblorb_err_None;
}
Exemple #3
0
giblorb_err_t giblorb_set_resource_map(strid_t file)
{
  giblorb_err_t err;

  /* For the moment, we only allow file-streams, because the resource
     loaders expect a FILE*. This could be changed, but I see no
     reason right now. */
  if (file->type != strtype_File)
    return giblorb_err_NotAMap;
  
  err = giblorb_create_map(file, &blorbmap);
  if (err) {
    blorbmap = NULL;
    return err;
  }
  
  blorbfile = file;
  
  return giblorb_err_None;
}
Exemple #4
0
/**
 * giblorb_set_resource_map:
 * @file: The file stream to read the resource map from
 *
 * This function tells the library that the file is indeed the Blorby source
 * of all resource goodness. Whenever your program calls an image or sound
 * function, such as glk_image_draw(), the library will search this file for
 * the resource you request. 
 *
 * Do <emphasis>not</emphasis> close the stream after calling this function. 
 * The library is responsible for closing the stream at shutdown time.
 *
 * Returns: a Blorb error code.
 */
giblorb_err_t
giblorb_set_resource_map(strid_t file)
{
	ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
	giblorb_map_t *newmap; /* create map allocates memory */
	giblorb_err_t error = giblorb_create_map(file, &newmap);

	if(error != giblorb_err_None) {
		g_free(newmap);
		return error;
	}

	/* Check if there was already an existing resource map */
	if(glk_data->resource_map != NULL) {
		WARNING("Overwriting existing resource map.\n");
		giblorb_destroy_map(glk_data->resource_map);
		glk_stream_close(glk_data->resource_file, NULL);
	}

	glk_data->resource_map = newmap;
	glk_data->resource_file = file;

	return giblorb_err_None;
}
Exemple #5
0
giblorb_err_t wrap_gib_create_map(strid_t file, giblorb_map_t **newmap)
{
  return giblorb_create_map(file, newmap);
}