From: Marijn van Vliet Date: Sat, 23 May 2009 23:21:12 +0000 (+0000) Subject: * Added the game anchorhead to test X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=278e68652925e367e726d5e462d56f40eabec1dd;p=rodin%2Fchimara.git * Added the game anchorhead to test * Working towards unix startup code, try: ./test-chimara anchor.z8 (error when opening the filestream) git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@78 ddfedd41-794f-dd11-ae45-00112f111e67 --- diff --git a/interpreters/nitfol/Makefile.am b/interpreters/nitfol/Makefile.am index e15903e..077d0fc 100644 --- a/interpreters/nitfol/Makefile.am +++ b/interpreters/nitfol/Makefile.am @@ -1,6 +1,6 @@ # TODO: There are a lot more documentation files in the Nitfol distribution -PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk_main$$" +PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk" GRAPHICS = no_graph.c # GRAPHICS = graphics.c @@ -13,7 +13,7 @@ pkglib_LTLIBRARIES = nitfol.la nitfol_la_SOURCES = automap.c solve.c infix.c debug.c inform.c quetzal.c \ undo.c op_call.c decode.c errmesg.c globals.c iff.c init.c main.c io.c \ z_io.c op_jmp.c op_math.c op_save.c op_table.c op_v6.c oplist.c stack.c \ - zscii.c tokenise.c struct.c objects.c portfunc.c hash.c \ + zscii.c tokenise.c struct.c objects.c portfunc.c hash.c startunix.c \ $(GRAPHICS) \ $(BLORB) \ $(SOUND) diff --git a/interpreters/nitfol/startunix.c b/interpreters/nitfol/startunix.c index ba9e3fe..b9e56d1 100644 --- a/interpreters/nitfol/startunix.c +++ b/interpreters/nitfol/startunix.c @@ -150,7 +150,7 @@ strid_t startup_open(const char *name) set_game_filename(name); s = strrchr(name, '\\'); if (!s) s = strrchr(name, '/'); - garglk_set_story_name(s ? s + 1 : name); + /* garglk_set_story_name(s ? s + 1 : name); */ } else { char *path = search_path; if(path) { @@ -167,7 +167,7 @@ strid_t startup_open(const char *name) set_game_filename(newname); s = strrchr(newname, '\\'); if (!s) s = strrchr(newname, '/'); - garglk_set_story_name(s ? s + 1 : newname); + /* garglk_set_story_name(s ? s + 1 : newname); */ break; } } @@ -602,10 +602,10 @@ int glkunix_startup_code(glkunix_startup_t *data) { set_defaults(); - garglk_set_program_name("Nitfol 0.5"); - garglk_set_program_info( + /* garglk_set_program_name("Nitfol 0.5"); */ + /* garglk_set_program_info( "Nitfol 0.5 by Evin Robertson\n" - "With countless patches by other people.\n"); + "With countless patches by other people.\n"); */ return parse_commands(data->argc, data->argv); } diff --git a/libchimara/Makefile.am b/libchimara/Makefile.am index f173bca..63af53e 100644 --- a/libchimara/Makefile.am +++ b/libchimara/Makefile.am @@ -27,7 +27,7 @@ libchimara_la_CPPFLAGS = \ -DG_LOG_DOMAIN=\"Chimara\" libchimara_la_CFLAGS = @CHIMARA_CFLAGS@ $(AM_CFLAGS) libchimara_la_LIBADD = @CHIMARA_LIBS@ -libchimara_la_LDFLAGS = -no-undefined -export-symbols-regex "^(chimara_)?glk_" +libchimara_la_LDFLAGS = -no-undefined -export-symbols-regex "^(glk_|chimara_glk_|glkunix_|giblorb_)" libchimara_includedir = $(includedir)/chimara/chimara libchimara_include_HEADERS = chimara-glk.h diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 16e6749..14931fb 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -10,6 +10,7 @@ #include "glk.h" #include "abort.h" #include "window.h" +#include "glkstart.h" #define CHIMARA_GLK_MIN_WIDTH 0 #define CHIMARA_GLK_MIN_HEIGHT 0 @@ -40,6 +41,7 @@ */ typedef void (* glk_main_t) (void); +typedef void (* glkunix_startup_code_t) (glkunix_startup_t*); enum { PROP_0, @@ -876,6 +878,7 @@ static gpointer glk_enter(gpointer glk_main) { extern ChimaraGlkPrivate *glk_data; + g_signal_emit_by_name(glk_data->self, "started"); ((glk_main_t)glk_main)(); g_signal_emit_by_name(glk_data->self, "stopped"); @@ -896,15 +899,17 @@ glk_enter(gpointer glk_main) * Return value: %TRUE if the Glk program was started successfully. */ gboolean -chimara_glk_run(ChimaraGlk *glk, gchar *plugin, GError **error) +chimara_glk_run(ChimaraGlk *glk, gchar *plugin, int argc, char *argv[], GError **error) { g_return_val_if_fail(glk || CHIMARA_IS_GLK(glk), FALSE); g_return_val_if_fail(plugin, FALSE); ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); + /* Open the module to run */ glk_main_t glk_main; + glkunix_startup_code_t glkunix_startup_code; g_assert( g_module_supported() ); priv->program = g_module_open(plugin, G_MODULE_BIND_LAZY); @@ -924,6 +929,15 @@ chimara_glk_run(ChimaraGlk *glk, gchar *plugin, GError **error) /* TODO: Do this with a GPrivate */ glk_data = priv; + if( g_module_symbol(priv->program, "glkunix_startup_code", (gpointer *) &glkunix_startup_code) ) + { + glkunix_startup_t data; + data.argc = argc; + data.argv = argv; + + glkunix_startup_code(&data); + } + /* Run in a separate thread */ priv->thread = g_thread_create(glk_enter, glk_main, TRUE, error); diff --git a/libchimara/chimara-glk.h b/libchimara/chimara-glk.h index ef121a2..87a3f75 100644 --- a/libchimara/chimara-glk.h +++ b/libchimara/chimara-glk.h @@ -53,7 +53,7 @@ void chimara_glk_set_monospace_font_string(ChimaraGlk *glk, const gchar *font); PangoFontDescription *chimara_glk_get_monospace_font_description(ChimaraGlk *glk); void chimara_glk_set_spacing(ChimaraGlk *glk, guint spacing); guint chimara_glk_get_spacing(ChimaraGlk *glk); -gboolean chimara_glk_run(ChimaraGlk *glk, gchar *plugin, GError **error); +gboolean chimara_glk_run(ChimaraGlk *glk, gchar *plugin, int argc, char *argv[], GError **error); void chimara_glk_stop(ChimaraGlk *glk); void chimara_glk_wait(ChimaraGlk *glk); diff --git a/libchimara/fileref.c b/libchimara/fileref.c index 2b5cf53..08ae584 100644 --- a/libchimara/fileref.c +++ b/libchimara/fileref.c @@ -57,7 +57,7 @@ glk_fileref_get_rock(frefid_t fref) } /* Internal function: create a fileref using the given parameters. */ -static frefid_t +frefid_t fileref_new(gchar *filename, glui32 rock, glui32 usage, glui32 orig_filemode) { g_return_val_if_fail(filename != NULL, NULL); diff --git a/libchimara/fileref.h b/libchimara/fileref.h index cfbdcca..9dd8e50 100644 --- a/libchimara/fileref.h +++ b/libchimara/fileref.h @@ -25,4 +25,5 @@ struct glk_fileref_struct glui32 usage; }; +G_GNUC_INTERNAL frefid_t fileref_new(gchar *filename, glui32 rock, glui32 usage, glui32 orig_filemode); #endif diff --git a/libchimara/stream.c b/libchimara/stream.c index 8043992..4a1e004 100644 --- a/libchimara/stream.c +++ b/libchimara/stream.c @@ -476,3 +476,12 @@ stream_close_common(strid_t str, stream_result_t *result) str->magic = MAGIC_FREE; g_free(str); } + +strid_t +glkunix_stream_open_pathname(char *pathname, glui32 usage, glui32 rock) +{ + printf("making new fileref: %s\n", pathname); + frefid_t fileref = fileref_new(pathname, rock, usage, filemode_ReadWrite); + printf("makeing new stream:\n"); + return file_stream_new(fileref, filemode_ReadWrite, rock, FALSE); +} diff --git a/libchimara/stream.h b/libchimara/stream.h index 0ea398e..7bab826 100644 --- a/libchimara/stream.h +++ b/libchimara/stream.h @@ -4,6 +4,7 @@ #include #include "glk.h" #include "window.h" +#include "fileref.h" enum StreamType { diff --git a/libchimara/window.h b/libchimara/window.h index 1a0b2e9..48ced88 100644 --- a/libchimara/window.h +++ b/libchimara/window.h @@ -5,7 +5,6 @@ #include "glk.h" #include "stream.h" -#include "error.h" #include "input.h" #include "style.h" diff --git a/tests/anchor.z8 b/tests/anchor.z8 new file mode 100644 index 0000000..3e99a47 Binary files /dev/null and b/tests/anchor.z8 differ diff --git a/tests/main.c b/tests/main.c index 605a576..5362b4a 100644 --- a/tests/main.c +++ b/tests/main.c @@ -118,7 +118,7 @@ main(int argc, char *argv[]) g_object_unref( G_OBJECT(builder) ); - if( !chimara_glk_run(CHIMARA_GLK(glk), ".libs/first.so", &error) ) { + if( !chimara_glk_run(CHIMARA_GLK(glk), "../interpreters/nitfol/.libs/nitfol.so", argc, argv, &error) ) { error_dialog(GTK_WINDOW(window), error, "Error starting Glk library: "); return 1; }