| Line 140... |
Line 140... |
| 140 |
|
140 |
|
| 141 |
static void main()
|
141 |
static void main()
|
| 142 |
{
|
142 |
{
|
| 143 |
int i;
|
143 |
int i;
|
| 144 |
|
144 |
|
| 145 |
struct emcorelib_header* libui = get_library(0x49554365, LIBUI_API_VERSION, LIBSOURCE_BOOTFLASH, "libui ");
|
145 |
struct emcorelib_header* libui = get_library(LIBUI_IDENTIFIER, LIBUI_API_VERSION, LIBSOURCE_BOOTFLASH, "libui ");
|
| 146 |
if (!libui) panicf(PANIC_KILLTHREAD, "Could not load user interface library!");
|
146 |
if (!libui) panicf(PANIC_KILLTHREAD, "Could not load user interface library!");
|
| 147 |
ui = (struct libui_api*)libui->api;
|
147 |
ui = (struct libui_api*)libui->api;
|
| 148 |
|
148 |
|
| 149 |
int width = lcd_get_width();
|
149 |
int width = lcd_get_width();
|
| 150 |
int height = lcd_get_height();
|
150 |
int height = lcd_get_height();
|
| Line 157... |
Line 157... |
| 157 |
offsetx = (width - framebufx) / 2;
|
157 |
offsetx = (width - framebufx) / 2;
|
| 158 |
offsety = (height - framebufy) / 2;
|
158 |
offsety = (height - framebufy) / 2;
|
| 159 |
xrandshift = __emcore_syscall->__clzsi2(tilesx - 1) - 1;
|
159 |
xrandshift = __emcore_syscall->__clzsi2(tilesx - 1) - 1;
|
| 160 |
yrandshift = __emcore_syscall->__clzsi2(tilesy - 1) - 1;
|
160 |
yrandshift = __emcore_syscall->__clzsi2(tilesy - 1) - 1;
|
| 161 |
framebuf = malloc(framebufsize);
|
161 |
framebuf = malloc(framebufsize);
|
| 162 |
field = malloc(tilecount * sizeof(typeof(field)));
|
162 |
field = malloc(tilecount * sizeof(typeof(*field)));
|
| 163 |
snake = malloc(tilecount * sizeof(typeof(snake)));
|
163 |
snake = malloc(tilecount * sizeof(typeof(*snake)));
|
| 164 |
if (!framebuf || !field || !snake) panicf(PANIC_KILLTHREAD, "Out of memory!");
|
164 |
if (!framebuf || !field || !snake) panicf(PANIC_KILLTHREAD, "Out of memory!");
|
| 165 |
struct button_hook_entry* hook = button_register_handler(buttonhandler, NULL);
|
165 |
struct button_hook_entry* hook = button_register_handler(buttonhandler, NULL);
|
| 166 |
if (!hook) panicf(PANIC_KILLTHREAD, "Could not register button hook!");
|
166 |
if (!hook) panicf(PANIC_KILLTHREAD, "Could not register button hook!");
|
| 167 |
|
167 |
|
| 168 |
memset(field, STATE_FREE, tilesx * tilesy);
|
168 |
memset(field, STATE_FREE, tilesx * tilesy);
|