summaryrefslogtreecommitdiffstats
path: root/src/scripting
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-08-25 13:10:39 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-08-25 13:10:39 (EDT)
commita22741efd694332f3b69e087ed77e353ed75a85d (patch)
tree2e0deb024870eac54a6ecf4f4969d156444a3265 /src/scripting
parent2c4ba39153c8fd7b03e81689ed6103dc91ce0168 (diff)
downloadoverworld-rpg-a22741efd694332f3b69e087ed77e353ed75a85d.zip
overworld-rpg-a22741efd694332f3b69e087ed77e353ed75a85d.tar.gz
overworld-rpg-a22741efd694332f3b69e087ed77e353ed75a85d.tar.bz2
Add bouken.viewport bindings
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/bindings.c7
-rw-r--r--src/scripting/bindings.h5
-rw-r--r--src/scripting/bindings/local.mk3
-rw-r--r--src/scripting/bindings/viewport.c43
4 files changed, 55 insertions, 3 deletions
diff --git a/src/scripting/bindings.c b/src/scripting/bindings.c
index 1edc1e3..7e45146 100644
--- a/src/scripting/bindings.c
+++ b/src/scripting/bindings.c
@@ -16,14 +16,17 @@
* <http://www.gnu.org/licenses/>.
*/
+#define _SCRIPTING_BINDINGS_C_
+
#include <stdlib.h>
#include "ffi.h"
#include "bindings.h"
-static struct ffi_namespace *ns;
+struct ffi_namespace *top_ns;
void
bindings_init(void)
{
- ns = ffi_add_namespace(NULL, "bouken");
+ top_ns = ffi_add_namespace(NULL, "bouken");
+ bindings_viewport_init();
}
diff --git a/src/scripting/bindings.h b/src/scripting/bindings.h
index c0cef2a..4ad7386 100644
--- a/src/scripting/bindings.h
+++ b/src/scripting/bindings.h
@@ -19,6 +19,11 @@
#ifndef _SCRIPTING_BINDINGS_H_
#define _SCRIPTING_BINDINGS_H_
+#ifndef _SCRIPTING_BINDINGS_C_
+extern struct ffi_namespace *top_ns;
+#endif
+
void bindings_init(void);
+void bindings_viewport_init(void);
#endif
diff --git a/src/scripting/bindings/local.mk b/src/scripting/bindings/local.mk
index 44655b5..1ec4a43 100644
--- a/src/scripting/bindings/local.mk
+++ b/src/scripting/bindings/local.mk
@@ -1 +1,2 @@
-boukengine_SOURCES +=
+boukengine_SOURCES += \
+ src/scripting/bindings/viewport.c
diff --git a/src/scripting/bindings/viewport.c b/src/scripting/bindings/viewport.c
new file mode 100644
index 0000000..2f3c03d
--- /dev/null
+++ b/src/scripting/bindings/viewport.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2015 Patrick "P. J." McDermott
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <SDL.h>
+#include "../../viewport.h"
+#include "../ffi.h"
+#include "../bindings.h"
+
+static struct ffi_namespace *ns;
+
+static void
+binding_set_size(void)
+{
+ Uint16 width;
+ Uint16 height;
+
+ width = ffi_stack_get_int();
+ height = ffi_stack_get_int();
+
+ init_viewport(width, height, 8);
+}
+
+void
+bindings_viewport_init(void)
+{
+ ns = ffi_add_namespace(top_ns, "viewport");
+ ffi_add_function(ns, "set_size", binding_set_size);
+}