aboutsummaryrefslogtreecommitdiff
path: root/apps/plugin.c
blob: cdca4c5db40a9d1978b64116cddac7a0f244c014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdlib.h>
#include "plugin.h"
#include "gfx.h"
#include "ps2kbd.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 int button_get(void)
{
    return ps2kbd_button_get();
}

static int modifier_get(void)
{
    return ps2kbd_modifier_get();
}

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,
    &button_get,
    &modifier_get,
};

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);
}