* Working towards unix startup code, try: ./test-chimara anchor.z8 (error when opening the filestream)
# 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
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)
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) {
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;
}
}
{
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);
}
-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
#include "glk.h"
#include "abort.h"
#include "window.h"
+#include "glkstart.h"
#define CHIMARA_GLK_MIN_WIDTH 0
#define CHIMARA_GLK_MIN_HEIGHT 0
*/
typedef void (* glk_main_t) (void);
+typedef void (* glkunix_startup_code_t) (glkunix_startup_t*);
enum {
PROP_0,
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");
* 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);
/* 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);
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);
}
/* 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);
glui32 usage;
};
+G_GNUC_INTERNAL frefid_t fileref_new(gchar *filename, glui32 rock, glui32 usage, glui32 orig_filemode);
#endif
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);
+}
#include <gtk/gtk.h>
#include "glk.h"
#include "window.h"
+#include "fileref.h"
enum StreamType
{
#include "glk.h"
#include "stream.h"
-#include "error.h"
#include "input.h"
#include "style.h"
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;
}