aboutsummaryrefslogtreecommitdiff
path: root/apps/plugin.c
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-02-17 15:33:03 -0500
committerFranklin Wei <frankhwei536@gmail.com>2015-02-17 15:33:03 -0500
commit6030b176c2819c83c625f257ad7e8632a8245ed9 (patch)
treefd98417c4f40a3bc8479a5900920a0ccd40fedd6 /apps/plugin.c
parentef4cc242dc8ad04320d19af22931fcbdbf670c13 (diff)
downloadkappa-6030b176c2819c83c625f257ad7e8632a8245ed9.zip
kappa-6030b176c2819c83c625f257ad7e8632a8245ed9.tar.gz
kappa-6030b176c2819c83c625f257ad7e8632a8245ed9.tar.bz2
kappa-6030b176c2819c83c625f257ad7e8632a8245ed9.tar.xz
Emulate the Rockbox plugin API, ported xracer
Tons of changes
Diffstat (limited to 'apps/plugin.c')
-rw-r--r--apps/plugin.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
new file mode 100644
index 0000000..440841a
--- /dev/null
+++ b/apps/plugin.c
@@ -0,0 +1,52 @@
+#include <stdlib.h>
+#include "plugin.h"
+#include "gfx.h"
+
+static void plugin_clear(void)
+{
+ gfx_clear();
+}
+
+static void plugin_drawpix(int x, int y)
+{
+ gfx_drawpixel(x, y);
+}
+
+static void plugin_vline(int a, int b, int c)
+{
+ gfx_vline(a, b, c);
+}
+
+static void plugin_hline(int a, int b, int c)
+{
+ gfx_hline(a, b, c);
+}
+
+static const struct plugin_api kappa_api = {
+ &plugin_clear,
+ &plugin_hline,
+ &plugin_vline,
+ &plugin_drawpix,
+ &gfx_drawline,
+ &gfx_drawrect,
+ &gfx_fillrect,
+ &gfx_set_foreground,
+ &gfx_get_foreground,
+ &gfx_set_background,
+ &gfx_get_background,
+ &srand,
+ &rand,
+ &gfx_filltriangle,
+ &gfx_drawcircle,
+ &gfx_fillcircle,
+ &gfx_update,
+ &gfx_putsxy
+};
+
+void plugin_load(enum plugin_status (*plugin)(const struct plugin_api*))
+{
+ bool status = gfx_get_doublebuffer();
+ gfx_set_doublebuffer(true);
+ plugin(&kappa_api);
+ gfx_set_doublebuffer(status);
+}