1// This file is part of SmallBASIC
2//
3// SmallBASIC module header
4//
5// This program is distributed under the terms of the GPL v2.0 or later
6// Download the GNU Public License (GPL) from www.gnu.org
7//
8// Copyright(C) 2018 Chris Warren-Smith
9
10#include <stdint.h>
11
12#if !defined(_INC_MODULE_H)
13#define _INC_MODULE_H
14
15#if defined(__cplusplus)
16extern "C" {
17#endif
18
19typedef struct {
20 // the parameter
21 var_t *var_p;
22
23 // whether the parameter can be used by reference
24 uint8_t byref;
25} slib_par_t;
26
27/**
28 * @ingroup modstd
29 *
30 * Initialize the library. Called by module manager on loading.
31 *
32 * @return non-zero on success
33 */
34int sblib_init(const char *sourceFile);
35
36/**
37 * @ingroup modlib
38 *
39 * returns the module name
40 *
41 * @return module name
42 */
43const char *sblib_get_module_name();
44
45/**
46 * @ingroup modstd
47 *
48 * Closes the library. Called by module manager on unload.
49 */
50void sblib_close(void);
51
52/**
53 * @ingroup modstd
54 *
55 * plugin based event handling
56 */
57int sblib_events(int wait_flag, int *w, int *h);
58
59/**
60 * @ingroup modlib
61 *
62 * returns the number of procedures that are supported by the library
63 *
64 * @return the number of the procedures
65 */
66int sblib_proc_count(void);
67
68/**
69 * @ingroup modlib
70 *
71 * returns the name of the procedure 'index'
72 *
73 * @param index the procedure's index
74 * @param proc_name the buffer to store the name
75 * @return non-zero on success
76 */
77int sblib_proc_getname(int index, char *proc_name);
78
79/**
80 * @ingroup modlib
81 *
82 * executes a procedure
83 *
84 * the retval can be used to returns an error-message
85 * in case of an error.
86 *
87 * @param index the procedure's index
88 * @param param_count the number of the parameters
89 * @param params the parameters table
90 * @param retval a var_t object to set the return value
91 * @return non-zero on success
92 */
93int sblib_proc_exec(int index, int param_count, slib_par_t *params, var_t *retval);
94
95/**
96 * @ingroup modlib
97 *
98 * returns the number of functions that are supported by the library
99 *
100 * @return the number of the functions
101 */
102int sblib_func_count(void);
103
104/**
105 * @ingroup modlib
106 *
107 * returns the name of the function 'index'
108 *
109 * @param index the function's index
110 * @param func_name the buffer to store the name
111 * @return non-zero on success
112 */
113int sblib_func_getname(int index, char *func_name);
114
115/**
116 * @ingroup modlib
117 *
118 * executes a function
119 *
120 * @param index the procedure's index
121 * @param param_count the number of the parameters
122 * @param params the parameters table
123 * @param retval a var_t object to set the return value
124 * @return non-zero on success
125 */
126int sblib_func_exec(int index, int param_count, slib_par_t *params, var_t *retval);
127
128/**
129 * @ingroup modlib
130 *
131 * overrides for osd_xx functions
132 */
133int sblib_getpen(int code);
134int sblib_getx();
135int sblib_gety();
136int sblib_textheight(const char *str);
137int sblib_textwidth(const char *str);
138long sblib_getpixel(int x, int y);
139void sblib_arc(int xc, int yc, double r, double as, double ae, double aspect);
140void sblib_audio(const char *path);
141void sblib_beep();
142void sblib_clear_sound_queue();
143void sblib_cls();
144void sblib_devinit(const char *prog, int width, int height);
145void sblib_ellipse(int xc, int yc, int xr, int yr, int fill);
146void sblib_line(int x1, int y1, int x2, int y2);
147void sblib_rect(int x1, int y1, int x2, int y2, int fill);
148void sblib_refresh();
149void sblib_setcolor(long color);
150void sblib_setpenmode(int enable);
151void sblib_setpixel(int x, int y);
152void sblib_settextcolor(long fg, long bg);
153void sblib_setxy(int x, int y);
154void sblib_sound(int frq, int ms, int vol, int bgplay);
155void sblib_write(const char *str);
156
157#if defined(__cplusplus)
158}
159#endif
160
161#endif
162