Skip to content
Browse files

Rearrange the open_interface call.

  • Loading branch information...
1 parent ba4f0a9 commit e463f1fea87e573e0dfd67a6bf09b7e8864a92c2 Andrew Plotkin committed Apr 14, 2012
Showing with 22 additions and 3 deletions.
  1. +22 −3 fizmo-glktermw/src/fizmo-glktermw/fizmo-glktermw.c
View
25 fizmo-glktermw/src/fizmo-glktermw/fizmo-glktermw.c
@@ -96,6 +96,25 @@ int glkunix_startup_code(glkunix_startup_t *data)
return TRUE;
}
+/* This callback has the job of finding the Glk stream for the game file
+ and embedding it into a z_file object. If you pass in a z_file object,
+ it uses that rather than allocating a new one.
+
+ This should only be called once, because once you close gamefilestream,
+ you can't get it back. For fizmo-glktermw, it will only be called once.
+ (For other strange platforms, the equivalent interface is more
+ interesting. But that's not important right now.)
+*/
+static z_file *glkunix_open_game_stream(z_file *current_stream)
+{
+ if (!current_stream)
+ current_stream = zfile_from_glk_strid(gamefilestream, "Game",
+ FILETYPE_DATA, FILEACCESS_READ);
+ else
+ zfile_replace_glk_strid(current_stream, gamefilestream);
+
+ return current_stream;
+}
void glk_main(void)
{
@@ -113,9 +132,9 @@ void glk_main(void)
fizmo_register_screen_interface(&glkint_screen_interface);
fizmo_register_blorb_interface(&glkint_blorb_interface);
- glkint_open_interface();
- story_stream = zfile_from_glk_strid(gamefilestream, gamefilename,
- FILETYPE_DATA, FILEACCESS_READ);
+ story_stream = glkint_open_interface(&glkunix_open_game_stream);
+ if (!story_stream)
+ return;
fizmo_start(story_stream, NULL, NULL, -1, -1);
}

0 comments on commit e463f1f

Please sign in to comment.
Something went wrong with that request. Please try again.