| 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) |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | typedef 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 | */ |
| 34 | int sblib_init(const char *sourceFile); |
| 35 | |
| 36 | /** |
| 37 | * @ingroup modlib |
| 38 | * |
| 39 | * returns the module name |
| 40 | * |
| 41 | * @return module name |
| 42 | */ |
| 43 | const char *sblib_get_module_name(); |
| 44 | |
| 45 | /** |
| 46 | * @ingroup modstd |
| 47 | * |
| 48 | * Closes the library. Called by module manager on unload. |
| 49 | */ |
| 50 | void sblib_close(void); |
| 51 | |
| 52 | /** |
| 53 | * @ingroup modstd |
| 54 | * |
| 55 | * plugin based event handling |
| 56 | */ |
| 57 | int 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 | */ |
| 66 | int 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 | */ |
| 77 | int 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 | */ |
| 93 | int 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 | */ |
| 102 | int 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 | */ |
| 113 | int 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 | */ |
| 126 | int 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 | */ |
| 133 | int sblib_getpen(int code); |
| 134 | int sblib_getx(); |
| 135 | int sblib_gety(); |
| 136 | int sblib_textheight(const char *str); |
| 137 | int sblib_textwidth(const char *str); |
| 138 | long sblib_getpixel(int x, int y); |
| 139 | void sblib_arc(int xc, int yc, double r, double as, double ae, double aspect); |
| 140 | void sblib_audio(const char *path); |
| 141 | void sblib_beep(); |
| 142 | void sblib_clear_sound_queue(); |
| 143 | void sblib_cls(); |
| 144 | void sblib_devinit(const char *prog, int width, int height); |
| 145 | void sblib_ellipse(int xc, int yc, int xr, int yr, int fill); |
| 146 | void sblib_line(int x1, int y1, int x2, int y2); |
| 147 | void sblib_rect(int x1, int y1, int x2, int y2, int fill); |
| 148 | void sblib_refresh(); |
| 149 | void sblib_setcolor(long color); |
| 150 | void sblib_setpenmode(int enable); |
| 151 | void sblib_setpixel(int x, int y); |
| 152 | void sblib_settextcolor(long fg, long bg); |
| 153 | void sblib_setxy(int x, int y); |
| 154 | void sblib_sound(int frq, int ms, int vol, int bgplay); |
| 155 | void sblib_write(const char *str); |
| 156 | |
| 157 | #if defined(__cplusplus) |
| 158 | } |
| 159 | #endif |
| 160 | |
| 161 | #endif |
| 162 | |