* Added the game anchorhead to test
authorrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Sat, 23 May 2009 23:21:12 +0000 (23:21 +0000)
committerrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Sat, 23 May 2009 23:21:12 +0000 (23:21 +0000)
 * Working towards unix startup code, try: ./test-chimara anchor.z8 (error when opening the filestream)

12 files changed:
interpreters/nitfol/Makefile.am
interpreters/nitfol/startunix.c
libchimara/Makefile.am
libchimara/chimara-glk.c
libchimara/chimara-glk.h
libchimara/fileref.c
libchimara/fileref.h
libchimara/stream.c
libchimara/stream.h
libchimara/window.h
tests/anchor.z8 [new file with mode: 0644]
tests/main.c

index e15903e2ca931a8e3464fb8fcf51b998e0c76ddc..077d0fc0d036e5be4de4458ab635ec18a3ea7bcc 100644 (file)
@@ -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)
index ba9e3fe0da2f5ac7e05695b262842d84486a8ed9..b9e56d105202e04aeb1c9126ee31a2b4deac3233 100644 (file)
@@ -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);
 }
index f173bca29830068c29cb8898773dfa7bc1a47a25..63af53e31d2e4ecbc45e2813efbf02e6c5663dea 100644 (file)
@@ -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
 
index 16e674969c10f9ae9feaf92804261b0b4414c8d5..14931fb8a265b065e62f850cb23d554d9c0b1333 100644 (file)
@@ -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);
        
index ef121a2236def5c445a36d0f27d31be6f5d31122..87a3f758d205e4f2b34c04fc4f9086c55786bc2c 100644 (file)
@@ -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);
 
index 2b5cf53efd65d9f8c04bc32732699e16c6db33a4..08ae5843d2318156619ee1ffdf92d17342ae2370 100644 (file)
@@ -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);
index cfbdcca034b46396c9eb3bd119548a0c9ed8464f..9dd8e50f5a0e180f2b96931c016695a6fc36294e 100644 (file)
@@ -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
index 804399213ae7cbe87ebcbb96134130d5d4d51dd6..4a1e004cfad42e9235b5a239efb62cd88617ca14 100644 (file)
@@ -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);
+}
index 0ea398e377fc98bf561e629ac9ce4434e4527fdc..7bab826b85c8295bc228a549eab69c78af7db9a4 100644 (file)
@@ -4,6 +4,7 @@
 #include <gtk/gtk.h>
 #include "glk.h"
 #include "window.h"
+#include "fileref.h"
 
 enum StreamType
 {
index 1a0b2e987297ef6893bc5f0d1f71162eaa38650e..48ced889e332dc5464c9d5e0d89e26e290ab85cc 100644 (file)
@@ -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 (file)
index 0000000..3e99a47
Binary files /dev/null and b/tests/anchor.z8 differ
index 605a5762e29cd2a4762f48707c7d0ee41cf08fe8..5362b4a67948e308453f3a62ac27690da9f2d2cd 100644 (file)
@@ -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;
     }