Core Native GBA 0.0.17
create your own game-engine with just lua for nitendo game boy advance console.
Loading...
Searching...
No Matches
text.c
Go to the documentation of this file.
1#include "zeebo.h"
2#include "font/gly_type_render.h"
3
4static uint8_t previous_font_size = 5;
5static uint8_t font_size = 5;
6
7static int native_text_mock(lua_State *L)
8{
9 lua_settop(L, 0);
10 return 0;
11}
12
13/**
14 * @param[in] x @c double
15 * @param[in] y @c double
16 * @param[in] message @c string
17 */
18static int native_text_print(lua_State *L)
19{
20 uint8_t x = luaL_checknumber(L, 1);
21 uint8_t y = luaL_checknumber(L, 2);
22 const char* text = luaL_checkstring(L, 3);
24 lua_settop(L, 0);
25 return 2;
26}
27
28/**
29 * @param[in] message @c string
30 * @retval width @c double
31 * @retval height @c double
32 */
33static int native_text_mensure(lua_State *L)
34{
35 lua_settop(L, 0);
36 lua_pushnumber(L, 1);
37 lua_pushnumber(L, 1);
38 return 2;
39}
40
41/**
42 * @param[in] size @c int
43 */
44static int native_text_font_size(lua_State *L)
45{
47 font_size = luaL_checknumber(L, 1) - 1;
48 if (font_size < 3) {
49 font_size = 3;
50 }
51 lua_settop(L, 0);
52 return 0;
53}
54
55static int native_text_font_previous(lua_State *L)
56{
58 lua_settop(L, 0);
59 return 0;
60}
61
62void text_library_install(lua_State* L)
63{
64 int i = 0;
65 static const luaL_Reg lib[] = {
66 {"native_text_print", native_text_print},
67 {"native_text_mensure", native_text_mensure},
68 {"native_text_font_size", native_text_font_size},
69 {"native_text_font_name", native_text_mock},
70 {"native_text_font_default", native_text_mock},
71 {"native_text_font_previous", native_text_font_previous},
72 };
73
74 while(i < sizeof(lib)/sizeof(luaL_Reg)) {
75 lua_pushcfunction(L, lib[i].func);
76 lua_setglobal(L, lib[i].name);
77 i = i + 1;
78 }
79}
void gly_type_render(uint8_t, uint8_t, uint8_t, char *, void *)
cmd_t draw_queue_clojure(uint8_t cmd)
Definition draw_queue.c:19
static int native_text_print(lua_State *L)
Definition text.c:18
void text_library_install(lua_State *L)
Definition text.c:62
static int native_text_font_size(lua_State *L)
Definition text.c:44
static int native_text_mensure(lua_State *L)
Definition text.c:33
static uint8_t font_size
Definition text.c:5
static uint8_t previous_font_size
Definition text.c:4
static int native_text_font_previous(lua_State *L)
Definition text.c:55
static int native_text_mock(lua_State *L)
Definition text.c:7