summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine_sw_sdl.lua570
-rw-r--r--main.lua5
-rw-r--r--ui.lua4
-rw-r--r--util.lua10
4 files changed, 8 insertions, 581 deletions
diff --git a/engine_sw_sdl.lua b/engine_sw_sdl.lua
deleted file mode 100644
index 2bc2862..0000000
--- a/engine_sw_sdl.lua
+++ /dev/null
@@ -1,570 +0,0 @@
1local ffi = require("ffi")
2local ffi_cast = ffi.cast
3local ffi_str = ffi.string
4local bor = bit.bor
5
6local util = require("util")
7
8local write_out = util.write_out
9
10local lsdl = util.load_lib("SDL")
11if not lsdl then return { init = function() end } end
12local levas = util.get_lib("evas")
13
14ffi.cdef [[
15typedef struct SDL_Surface {
16 uint32_t flags;
17 void *format;
18 int w, h;
19 int pitch;
20 void *pixels;
21} SDL_Surface;
22
23typedef enum {
24 SDLK_UNKNOWN = 0,
25 SDLK_FIRST = 0,
26 SDLK_BACKSPACE = 8,
27 SDLK_TAB = 9,
28 SDLK_CLEAR = 12,
29 SDLK_RETURN = 13,
30 SDLK_PAUSE = 19,
31 SDLK_ESCAPE = 27,
32 SDLK_SPACE = 32,
33 SDLK_EXCLAIM = 33,
34 SDLK_QUOTEDBL = 34,
35 SDLK_HASH = 35,
36 SDLK_DOLLAR = 36,
37 SDLK_AMPERSAND = 38,
38 SDLK_QUOTE = 39,
39 SDLK_LEFTPAREN = 40,
40 SDLK_RIGHTPAREN = 41,
41 SDLK_ASTERISK = 42,
42 SDLK_PLUS = 43,
43 SDLK_COMMA = 44,
44 SDLK_MINUS = 45,
45 SDLK_PERIOD = 46,
46 SDLK_SLASH = 47,
47 SDLK_0 = 48,
48 SDLK_1 = 49,
49 SDLK_2 = 50,
50 SDLK_3 = 51,
51 SDLK_4 = 52,
52 SDLK_5 = 53,
53 SDLK_6 = 54,
54 SDLK_7 = 55,
55 SDLK_8 = 56,
56 SDLK_9 = 57,
57 SDLK_COLON = 58,
58 SDLK_SEMICOLON = 59,
59 SDLK_LESS = 60,
60 SDLK_EQUALS = 61,
61 SDLK_GREATER = 62,
62 SDLK_QUESTION = 63,
63 SDLK_AT = 64,
64 SDLK_LEFTBRACKET = 91,
65 SDLK_BACKSLASH = 92,
66 SDLK_RIGHTBRACKET = 93,
67 SDLK_CARET = 94,
68 SDLK_UNDERSCORE = 95,
69 SDLK_BACKQUOTE = 96,
70 SDLK_a = 97,
71 SDLK_b = 98,
72 SDLK_c = 99,
73 SDLK_d = 100,
74 SDLK_e = 101,
75 SDLK_f = 102,
76 SDLK_g = 103,
77 SDLK_h = 104,
78 SDLK_i = 105,
79 SDLK_j = 106,
80 SDLK_k = 107,
81 SDLK_l = 108,
82 SDLK_m = 109,
83 SDLK_n = 110,
84 SDLK_o = 111,
85 SDLK_p = 112,
86 SDLK_q = 113,
87 SDLK_r = 114,
88 SDLK_s = 115,
89 SDLK_t = 116,
90 SDLK_u = 117,
91 SDLK_v = 118,
92 SDLK_w = 119,
93 SDLK_x = 120,
94 SDLK_y = 121,
95 SDLK_z = 122,
96 SDLK_DELETE = 127,
97 SDLK_WORLD_0 = 160,
98 SDLK_WORLD_1 = 161,
99 SDLK_WORLD_2 = 162,
100 SDLK_WORLD_3 = 163,
101 SDLK_WORLD_4 = 164,
102 SDLK_WORLD_5 = 165,
103 SDLK_WORLD_6 = 166,
104 SDLK_WORLD_7 = 167,
105 SDLK_WORLD_8 = 168,
106 SDLK_WORLD_9 = 169,
107 SDLK_WORLD_10 = 170,
108 SDLK_WORLD_11 = 171,
109 SDLK_WORLD_12 = 172,
110 SDLK_WORLD_13 = 173,
111 SDLK_WORLD_14 = 174,
112 SDLK_WORLD_15 = 175,
113 SDLK_WORLD_16 = 176,
114 SDLK_WORLD_17 = 177,
115 SDLK_WORLD_18 = 178,
116 SDLK_WORLD_19 = 179,
117 SDLK_WORLD_20 = 180,
118 SDLK_WORLD_21 = 181,
119 SDLK_WORLD_22 = 182,
120 SDLK_WORLD_23 = 183,
121 SDLK_WORLD_24 = 184,
122 SDLK_WORLD_25 = 185,
123 SDLK_WORLD_26 = 186,
124 SDLK_WORLD_27 = 187,
125 SDLK_WORLD_28 = 188,
126 SDLK_WORLD_29 = 189,
127 SDLK_WORLD_30 = 190,
128 SDLK_WORLD_31 = 191,
129 SDLK_WORLD_32 = 192,
130 SDLK_WORLD_33 = 193,
131 SDLK_WORLD_34 = 194,
132 SDLK_WORLD_35 = 195,
133 SDLK_WORLD_36 = 196,
134 SDLK_WORLD_37 = 197,
135 SDLK_WORLD_38 = 198,
136 SDLK_WORLD_39 = 199,
137 SDLK_WORLD_40 = 200,
138 SDLK_WORLD_41 = 201,
139 SDLK_WORLD_42 = 202,
140 SDLK_WORLD_43 = 203,
141 SDLK_WORLD_44 = 204,
142 SDLK_WORLD_45 = 205,
143 SDLK_WORLD_46 = 206,
144 SDLK_WORLD_47 = 207,
145 SDLK_WORLD_48 = 208,
146 SDLK_WORLD_49 = 209,
147 SDLK_WORLD_50 = 210,
148 SDLK_WORLD_51 = 211,
149 SDLK_WORLD_52 = 212,
150 SDLK_WORLD_53 = 213,
151 SDLK_WORLD_54 = 214,
152 SDLK_WORLD_55 = 215,
153 SDLK_WORLD_56 = 216,
154 SDLK_WORLD_57 = 217,
155 SDLK_WORLD_58 = 218,
156 SDLK_WORLD_59 = 219,
157 SDLK_WORLD_60 = 220,
158 SDLK_WORLD_61 = 221,
159 SDLK_WORLD_62 = 222,
160 SDLK_WORLD_63 = 223,
161 SDLK_WORLD_64 = 224,
162 SDLK_WORLD_65 = 225,
163 SDLK_WORLD_66 = 226,
164 SDLK_WORLD_67 = 227,
165 SDLK_WORLD_68 = 228,
166 SDLK_WORLD_69 = 229,
167 SDLK_WORLD_70 = 230,
168 SDLK_WORLD_71 = 231,
169 SDLK_WORLD_72 = 232,
170 SDLK_WORLD_73 = 233,
171 SDLK_WORLD_74 = 234,
172 SDLK_WORLD_75 = 235,
173 SDLK_WORLD_76 = 236,
174 SDLK_WORLD_77 = 237,
175 SDLK_WORLD_78 = 238,
176 SDLK_WORLD_79 = 239,
177 SDLK_WORLD_80 = 240,
178 SDLK_WORLD_81 = 241,
179 SDLK_WORLD_82 = 242,
180 SDLK_WORLD_83 = 243,
181 SDLK_WORLD_84 = 244,
182 SDLK_WORLD_85 = 245,
183 SDLK_WORLD_86 = 246,
184 SDLK_WORLD_87 = 247,
185 SDLK_WORLD_88 = 248,
186 SDLK_WORLD_89 = 249,
187 SDLK_WORLD_90 = 250,
188 SDLK_WORLD_91 = 251,
189 SDLK_WORLD_92 = 252,
190 SDLK_WORLD_93 = 253,
191 SDLK_WORLD_94 = 254,
192 SDLK_WORLD_95 = 255,
193 SDLK_KP0 = 256,
194 SDLK_KP1 = 257,
195 SDLK_KP2 = 258,
196 SDLK_KP3 = 259,
197 SDLK_KP4 = 260,
198 SDLK_KP5 = 261,
199 SDLK_KP6 = 262,
200 SDLK_KP7 = 263,
201 SDLK_KP8 = 264,
202 SDLK_KP9 = 265,
203 SDLK_KP_PERIOD = 266,
204 SDLK_KP_DIVIDE = 267,
205 SDLK_KP_MULTIPLY = 268,
206 SDLK_KP_MINUS = 269,
207 SDLK_KP_PLUS = 270,
208 SDLK_KP_ENTER = 271,
209 SDLK_KP_EQUALS = 272,
210 SDLK_UP = 273,
211 SDLK_DOWN = 274,
212 SDLK_RIGHT = 275,
213 SDLK_LEFT = 276,
214 SDLK_INSERT = 277,
215 SDLK_HOME = 278,
216 SDLK_END = 279,
217 SDLK_PAGEUP = 280,
218 SDLK_PAGEDOWN = 281,
219 SDLK_F1 = 282,
220 SDLK_F2 = 283,
221 SDLK_F3 = 284,
222 SDLK_F4 = 285,
223 SDLK_F5 = 286,
224 SDLK_F6 = 287,
225 SDLK_F7 = 288,
226 SDLK_F8 = 289,
227 SDLK_F9 = 290,
228 SDLK_F10 = 291,
229 SDLK_F11 = 292,
230 SDLK_F12 = 293,
231 SDLK_F13 = 294,
232 SDLK_F14 = 295,
233 SDLK_F15 = 296,
234 SDLK_NUMLOCK = 300,
235 SDLK_CAPSLOCK = 301,
236 SDLK_SCROLLOCK = 302,
237 SDLK_RSHIFT = 303,
238 SDLK_LSHIFT = 304,
239 SDLK_RCTRL = 305,
240 SDLK_LCTRL = 306,
241 SDLK_RALT = 307,
242 SDLK_LALT = 308,
243 SDLK_RMETA = 309,
244 SDLK_LMETA = 310,
245 SDLK_LSUPER = 311,
246 SDLK_RSUPER = 312,
247 SDLK_MODE = 313,
248 SDLK_COMPOSE = 314,
249 SDLK_HELP = 315,
250 SDLK_PRINT = 316,
251 SDLK_SYSREQ = 317,
252 SDLK_BREAK = 318,
253 SDLK_MENU = 319,
254 SDLK_POWER = 320,
255 SDLK_EURO = 321,
256 SDLK_UNDO = 322,
257 SDLK_LAST
258} SDLKey;
259
260typedef enum {
261 KMOD_NONE = 0x0000,
262 KMOD_LSHIFT = 0x0001,
263 KMOD_RSHIFT = 0x0002,
264 KMOD_LCTRL = 0x0040,
265 KMOD_RCTRL = 0x0080,
266 KMOD_LALT = 0x0100,
267 KMOD_RALT = 0x0200,
268 KMOD_LMETA = 0x0400,
269 KMOD_RMETA = 0x0800,
270 KMOD_NUM = 0x1000,
271 KMOD_CAPS = 0x2000,
272 KMOD_MODE = 0x4000,
273 KMOD_RESERVED = 0x8000
274} SDLMod;
275
276typedef enum {
277 SDL_NOEVENT = 0,
278 SDL_ACTIVEEVENT,
279 SDL_KEYDOWN,
280 SDL_KEYUP,
281 SDL_MOUSEMOTION,
282 SDL_MOUSEBUTTONDOWN,
283 SDL_MOUSEBUTTONUP,
284 SDL_JOYAXISMOTION,
285 SDL_JOYBALLMOTION,
286 SDL_JOYHATMOTION,
287 SDL_JOYBUTTONDOWN,
288 SDL_JOYBUTTONUP,
289 SDL_QUIT,
290 SDL_SYSWMEVENT,
291 SDL_EVENT_RESERVEDA,
292 SDL_EVENT_RESERVEDB,
293 SDL_VIDEORESIZE,
294 SDL_VIDEOEXPOSE,
295 SDL_EVENT_RESERVED2,
296 SDL_EVENT_RESERVED3,
297 SDL_EVENT_RESERVED4,
298 SDL_EVENT_RESERVED5,
299 SDL_EVENT_RESERVED6,
300 SDL_EVENT_RESERVED7,
301 SDL_USEREVENT = 24,
302 SDL_NUMEVENTS = 32
303} SDL_EventType;
304
305typedef struct SDL_keysym {
306 uint8_t scancode;
307 SDLKey sym;
308 SDLMod mod;
309 uint16_t unicode;
310} SDL_keysym;
311
312typedef struct SDL_KeyboardEvent {
313 uint8_t type;
314 uint8_t which;
315 uint8_t state;
316 SDL_keysym keysym;
317} SDL_KeyboardEvent;
318
319typedef struct SDL_MouseMotionEvent {
320 uint8_t type;
321 uint8_t which;
322 uint8_t state;
323 uint16_t x, y;
324 int16_t xrel;
325 int16_t yrel;
326} SDL_MouseMotionEvent;
327
328typedef struct SDL_MouseButtonEvent {
329 uint8_t type;
330 uint8_t which;
331 uint8_t button;
332 uint8_t state;
333 uint16_t x, y;
334} SDL_MouseButtonEvent;
335
336typedef struct SDL_ResizeEvent {
337 uint8_t type;
338 int w;
339 int h;
340} SDL_ResizeEvent;
341
342typedef union {
343 SDL_KeyboardEvent key;
344 SDL_MouseMotionEvent motion;
345 SDL_MouseButtonEvent button;
346 SDL_ResizeEvent resize;
347 uint8_t type;
348} SDL_Event;
349
350int SDL_Flip(SDL_Surface *screen);
351int SDL_Init(uint32_t flags);
352const char *SDL_GetError(void);
353void SDL_Quit(void);
354SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, uint32_t flags);
355int SDL_SetAlpha(SDL_Surface *surface, uint32_t flag, uint8_t alpha);
356int SDL_FillRect(SDL_Surface *dst, void *dstrect, uint32_t color);
357int SDL_PollEvent(SDL_Event *event);
358void SDL_WM_SetCaption(const char *title, const char *icon);
359
360typedef struct _Evas_Engine_Info_Buffer Evas_Engine_Info_Buffer;
361
362struct _Evas_Engine_Info_Buffer {
363 Evas_Engine_Info magic;
364 struct {
365 int depth_type;
366
367 void *dest_buffer;
368 int dest_buffer_row_bytes;
369
370 char use_color_key : 1;
371 int alpha_threshold;
372 int color_key_r;
373 int color_key_g;
374 int color_key_b;
375 struct {
376 void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes);
377 void (*free_update_region) (int x, int y, int w, int h, void *data);
378 void * (*switch_buffer) (void *data, void *dest_buffer);
379 } func;
380
381 void *switch_data;
382 } info;
383
384 Evas_Engine_Render_Mode render_mode;
385};
386]]
387
388local evas
389local flip_cb
390local win_w, win_h
391
392local engine_sdl_setup = function(engine, width, height)
393 if not lsdl then return false end
394 win_w, win_h = width, height
395 evas = util.conf.evas
396 local ok = (engine == "sdl")
397 if not ok then return false end
398 levas.evas_output_method_set(evas, levas.evas_render_method_lookup(
399 "buffer"))
400 local einfo = ffi.cast("Evas_Engine_Info_Buffer*",
401 levas.evas_engine_info_get(evas))
402 if not einfo then return false end
403 -- video, noparachute
404 if lsdl.SDL_Init(bor(0x00100000, 0x00000020)) < 0 then
405 write_out("SDL_Init failed with " .. ffi_str(lsdl.SDL_GetError()))
406 lsdl.SDL_Quit()
407 return false
408 end
409 einfo.info.depth_type = 4 -- rgb32
410 einfo.info.switch_data = lsdl.SDL_SetVideoMode(width, height, 32,
411 bor(0x00000001, 0x40000000))
412 if einfo.info.switch_data == nil then
413 write_out("SDL_SetVideoMode failed!\n")
414 lsdl.SDL_Quit()
415 return false
416 end
417 lsdl.SDL_WM_SetCaption("Luaxpedite - Luaified Evas Test Suite", nil)
418 lsdl.SDL_SetAlpha(einfo.info.switch_data, 0x00010000, 0) -- SDL_SRCALPHA
419 lsdl.SDL_FillRect(einfo.info.switch_data, nil, 0)
420 einfo.info.dest_buffer = ffi_cast("SDL_Surface*",
421 einfo.info.switch_data).pixels
422 einfo.info.dest_buffer_row_bytes = width * ffi.sizeof("int")
423 einfo.info.use_color_key = 0
424 einfo.info.alpha_threshold = 0
425 einfo.info.func.new_update_region = nil
426 einfo.info.func.free_update_region = nil
427 einfo.info.func.switch_buffer = function(data, dest)
428 lsdl.SDL_Flip(data)
429 return ffi_cast("SDL_Surface*", data).pixels
430 end
431 flip_cb = einfo.info.func.switch_buffer
432 if levas.evas_engine_info_set(evas, ffi.cast("Evas_Engine_Info*", einfo))
433 == 0 then
434 write_out("evas_engine_info_set() for engine 'sdl' with "
435 .. "'buffer' backend failed.\n")
436 lsdl.SDL_Quit()
437 return false
438 end
439 return true
440end
441
442local modkeys = {
443 [lsdl.SDLK_LSHIFT] = "Shift", [lsdl.SDLK_RSHIFT] = "Shift",
444 [lsdl.SDLK_LCTRL] = "Control", [lsdl.SDLK_RCTRL] = "Control",
445 [lsdl.SDLK_MENU] = "Alt",
446 [lsdl.SDLK_LALT] = "Alt", [lsdl.SDLK_RALT] = "Alt",
447 [lsdl.SDLK_LSUPER] = "Super", [lsdl.SDLK_RSUPER] = "Super",
448}
449
450local lockkeys = {
451 [lsdl.SDLK_CAPSLOCK] = "Caps_Lock", [lsdl.SDLK_NUMLOCK] = "Num_Lock",
452 [lsdl.SDLK_SCROLLOCK] = "Scroll_Lock"
453}
454
455local feedkeys = {
456 [lsdl.SDLK_ESCAPE] = "Escape",
457 [lsdl.SDLK_KP_ENTER] = "Return", [lsdl.SDLK_RETURN] = "Return",
458 [lsdl.SDLK_LEFT] = "Left", [lsdl.SDLK_RIGHT] = "Right"
459}
460
461local evtypes = {
462 [lsdl.SDL_MOUSEMOTION] = function(ev)
463 levas.evas_event_feed_mouse_move(evas, ev.motion.x, ev.motion.y,
464 0, nil)
465 end,
466 [lsdl.SDL_MOUSEBUTTONDOWN] = function(ev)
467 levas.evas_event_feed_mouse_move(evas, ev.button.x, ev.button.y,
468 0, nil)
469 levas.evas_event_feed_mouse_down(evas, ev.button.button,
470 levas.EVAS_BUTTON_NONE, 0, nil)
471 end,
472 [lsdl.SDL_MOUSEBUTTONUP] = function(ev)
473 levas.evas_event_feed_mouse_move(evas, ev.button.x, ev.button.y,
474 0, nil)
475 levas.evas_event_feed_mouse_up(evas, ev.button.button,
476 levas.EVAS_BUTTON_NONE, 0, nil)
477 end,
478 [lsdl.SDL_VIDEORESIZE] = function(ev)
479 -- we're not resizable, don't bother
480 end,
481 [lsdl.SDL_VIDEOEXPOSE] = function(ev)
482 levas.evas_damage_rectangle_add(evas, 0, 0, win_w, win_h)
483 end,
484 [lsdl.SDL_KEYDOWN] = function(ev)
485 local sym = tonumber(ev.key.keysym.sym)
486 local mod = modkeys[sym]
487 if mod then
488 levas.evas_key_modifier_on(evas, mod)
489 return
490 end
491 local lock = lockkeys[sym]
492 if lock then
493 if levas.evas_key_lock_is_set(levas.evas_key_lock_get(evas),
494 lock) ~= 0 then
495 levas.evas_key_lock_off(evas, lock)
496 else
497 levas.evas_key_lock_on(evas, lock)
498 end
499 return
500 end
501 local feed = feedkeys[sym]
502 if feed then
503 levas.evas_event_feed_key_down(evas, feed, feed, nil, nil,
504 0, nil)
505 return
506 end
507 if sym == lsdl.SDLK_q then
508 if levas.evas_key_lock_is_set(levas.evas_key_lock_get(evas),
509 "Caps_Lock") ~= 0 then
510 levas.evas_event_feed_key_down(evas, "Q", "Q", nil, nil,
511 0, nil)
512 else
513 levas.evas_event_feed_key_down(evas, "q", "q", nil, nil,
514 0, nil)
515 end
516 end
517 end,
518 [lsdl.SDL_KEYUP] = function(ev)
519 local sym = tonumber(ev.key.keysym.sym)
520 local mod = modkeys[sym]
521 if mod then
522 levas.evas_key_modifier_off(evas, mod)
523 return
524 end
525 local feed = feedkeys[sym]
526 if feed then
527 levas.evas_event_feed_key_up(evas, feed, feed, nil, nil, 0, nil)
528 return
529 end
530 if sym == lsdl.SDLK_q then
531 if levas.evas_key_lock_is_set(levas.evas_key_lock_get(evas),
532 "Caps_Lock") ~= 0 then
533 levas.evas_event_feed_key_up(evas, "Q", "Q", nil, nil,
534 0, nil)
535 else
536 levas.evas_event_feed_key_up(evas, "q", "q", nil, nil,
537 0, nil)
538 end
539 end
540 end,
541 [lsdl.SDL_QUIT] = function(ev)
542 levas.evas_event_feed_key_down(evas, "Escape", "Escape", nil, nil,
543 0, nil)
544 end,
545 [lsdl.SDL_SYSWMEVENT] = function(ev) end,
546 [lsdl.SDL_USEREVENT] = function(ev) end,
547 [lsdl.SDL_ACTIVEEVENT] = function(ev) end,
548 [lsdl.SDL_JOYAXISMOTION] = function(ev) end,
549 [lsdl.SDL_JOYHATMOTION] = function(ev) end,
550 [lsdl.SDL_JOYBUTTONDOWN] = function(ev) end,
551 [lsdl.SDL_JOYBUTTONUP] = function(ev) end
552}
553
554local ev = ffi.new("SDL_Event")
555local engine_sdl_loop; engine_sdl_loop = function()
556 if lsdl.SDL_PollEvent(ev) == 0 then return end
557 local f = evtypes[ev.type]
558 if f then f(ev) end
559 return engine_sdl_loop()
560end
561
562local engine_sdl_shutdown = function()
563 lsdl.SDL_Quit()
564end
565
566return { init = function(engines)
567 engines[#engines + 1] = {
568 "sdl", engine_sdl_setup, engine_sdl_loop, engine_sdl_shutdown
569 }
570end } \ No newline at end of file
diff --git a/main.lua b/main.lua
index 915c8d4..1e904f8 100644
--- a/main.lua
+++ b/main.lua
@@ -365,15 +365,12 @@ engine_loop = function()
365end 365end
366local engine_loop = engine_loop 366local engine_loop = engine_loop
367 367
368-- TODO: moar engines
369
370local engines = {} 368local engines = {}
371 369
372have_engine_x11 = false 370have_engine_x11 = false
373 371
374require("engine_x11").init(engines, "software_x11") 372require("engine_x11").init(engines, "software_x11")
375require("engine_x11").init(engines, "gl_x11") 373require("engine_x11").init(engines, "gl_x11")
376require("engine_sw_sdl").init(engines)
377 374
378local C = ffi.C 375local C = ffi.C
379 376
@@ -467,4 +464,4 @@ local main = function(args)
467 levas.evas_shutdown() 464 levas.evas_shutdown()
468 return 0 465 return 0
469end 466end
470util.exit(main(arg)) \ No newline at end of file 467main(arg) \ No newline at end of file
diff --git a/ui.lua b/ui.lua
index 5a1c887..af593be 100644
--- a/ui.lua
+++ b/ui.lua
@@ -670,9 +670,9 @@ ui_func_set = M.func_set
670 670
671local queue_tests = function(tests) 671local queue_tests = function(tests)
672 for i = 1, #tests, 2 do 672 for i = 1, #tests, 2 do
673 local name = "tests." .. tests[i] 673 local f = dofile("tests/" .. tests[i] .. ".lua")
674 for j = 1, tests[i + 1] do 674 for j = 1, tests[i + 1] do
675 menu_queue[#menu_queue + 1] = { require(name)(M, j) } 675 menu_queue[#menu_queue + 1] = { f(M, j) }
676 end 676 end
677 end 677 end
678end 678end
diff --git a/util.lua b/util.lua
index bae2e44..0308a4f 100644
--- a/util.lua
+++ b/util.lua
@@ -7,7 +7,7 @@ local tonumber = tonumber
7local M = {} 7local M = {}
8 8
9local rp = 0 9local rp = 0
10local r = { 10local r = ffi.new("short[65536]", {
1111423, 23305, 22422, 3286, 28841, 6652, 3499, 3618, 8363, 31491, 15444, 5852, 19081, 28074, 15631, 28112, 32389, 13015, 26077, 16467, 10087, 12788, 9679, 15525, 29177, 24, 1856, 21048, 2684, 5022, 8091, 14107, 28327, 30513, 17394, 24400, 4397, 20893, 28018, 12761, 19616, 10695, 18613, 5930, 6001, 1477, 1274, 5622, 14492, 27351, 22089, 1111423, 23305, 22422, 3286, 28841, 6652, 3499, 3618, 8363, 31491, 15444, 5852, 19081, 28074, 15631, 28112, 32389, 13015, 26077, 16467, 10087, 12788, 9679, 15525, 29177, 24, 1856, 21048, 2684, 5022, 8091, 14107, 28327, 30513, 17394, 24400, 4397, 20893, 28018, 12761, 19616, 10695, 18613, 5930, 6001, 1477, 1274, 5622, 14492, 27351, 22089,
1224579, 7371, 31769, 7336, 3780, 31793, 9193, 24828, 1709, 14215, 151, 15817, 9774, 30664, 443, 1407, 2294, 21336, 29425, 15055, 8184, 7352, 900, 14114, 13354, 2377, 15389, 18976, 16869, 9972, 8298, 8681, 17344, 7299, 16017, 21124, 6324, 25210, 13185, 8033, 6657, 13336, 23850, 16432, 11233, 24293, 17839, 13527, 12861, 14496, 28582, 21046, 21849, 29482, 2392, 2435, 31860, 17781, 21411, 15961, 27754, 29709, 24642, 12330, 1224579, 7371, 31769, 7336, 3780, 31793, 9193, 24828, 1709, 14215, 151, 15817, 9774, 30664, 443, 1407, 2294, 21336, 29425, 15055, 8184, 7352, 900, 14114, 13354, 2377, 15389, 18976, 16869, 9972, 8298, 8681, 17344, 7299, 16017, 21124, 6324, 25210, 13185, 8033, 6657, 13336, 23850, 16432, 11233, 24293, 17839, 13527, 12861, 14496, 28582, 21046, 21849, 29482, 2392, 2435, 31860, 17781, 21411, 15961, 27754, 29709, 24642, 12330,
134240, 7892, 686, 10564, 334, 13871, 18598, 6992, 27208, 9680, 23424, 5673, 1206, 8495, 19200, 14067, 22991, 15014, 2345, 12072, 11728, 4738, 14507, 10820, 22519, 3151, 26782, 17505, 92, 18656, 29835, 4333, 26548, 30522, 14897, 26883, 11625, 727, 1107, 6065, 10408, 24531, 11738, 11614, 258, 30938, 25681, 23249, 13184, 28027, 2554, 24913, 32765, 17061, 2965, 22516, 20212, 29747, 7254, 20305, 15636, 4321, 24638, 9416, 134240, 7892, 686, 10564, 334, 13871, 18598, 6992, 27208, 9680, 23424, 5673, 1206, 8495, 19200, 14067, 22991, 15014, 2345, 12072, 11728, 4738, 14507, 10820, 22519, 3151, 26782, 17505, 92, 18656, 29835, 4333, 26548, 30522, 14897, 26883, 11625, 727, 1107, 6065, 10408, 24531, 11738, 11614, 258, 30938, 25681, 23249, 13184, 28027, 2554, 24913, 32765, 17061, 2965, 22516, 20212, 29747, 7254, 20305, 15636, 4321, 24638, 9416,
@@ -1032,17 +1032,17 @@ local r = {
103218039, 8159, 1700, 9938, 32158, 11635, 32630, 19918, 14834, 32120, 17573, 7589, 10837, 14373, 14921, 1047, 4953, 19338, 21330, 2343, 2881, 22275, 28321, 12977, 32676, 3700, 8260, 28601, 24809, 2645, 14884, 10080, 10804, 16584, 20019, 10195, 28220, 19881, 30113, 10286, 19233, 14918, 17875, 30070, 29292, 28, 31117, 1477, 19366, 19679, 3820, 22248, 9187, 32142, 2457, 9095, 3074, 10718, 4928, 27884, 13363, 19813, 5196, 24167, 103218039, 8159, 1700, 9938, 32158, 11635, 32630, 19918, 14834, 32120, 17573, 7589, 10837, 14373, 14921, 1047, 4953, 19338, 21330, 2343, 2881, 22275, 28321, 12977, 32676, 3700, 8260, 28601, 24809, 2645, 14884, 10080, 10804, 16584, 20019, 10195, 28220, 19881, 30113, 10286, 19233, 14918, 17875, 30070, 29292, 28, 31117, 1477, 19366, 19679, 3820, 22248, 9187, 32142, 2457, 9095, 3074, 10718, 4928, 27884, 13363, 19813, 5196, 24167,
10333629, 25215, 1594, 31849, 12328, 31708, 9367, 31561, 13858, 27242, 28863, 10382, 27270, 27212, 11859, 13869, 14124, 15680, 3349, 23311, 15054, 5806, 32406, 18128, 16524, 4567, 13244, 29887, 24380, 18441, 21287, 28009, 10888, 22881, 27091, 23217, 21821, 3690, 22010, 2912, 30933, 18106, 13294, 25435, 12550, 25154, 6536, 26674, 8066, 9885, 17217, 23120, 15692, 16856, 8480, 32216, 21423, 21725, 29336, 13035, 7398, 17855, 8276, 18286, 10333629, 25215, 1594, 31849, 12328, 31708, 9367, 31561, 13858, 27242, 28863, 10382, 27270, 27212, 11859, 13869, 14124, 15680, 3349, 23311, 15054, 5806, 32406, 18128, 16524, 4567, 13244, 29887, 24380, 18441, 21287, 28009, 10888, 22881, 27091, 23217, 21821, 3690, 22010, 2912, 30933, 18106, 13294, 25435, 12550, 25154, 6536, 26674, 8066, 9885, 17217, 23120, 15692, 16856, 8480, 32216, 21423, 21725, 29336, 13035, 7398, 17855, 8276, 18286,
10347968, 2599, 8735, 29790, 6290, 30746, 32702, 4455, 16084, 13228, 29890, 28634, 5614, 3659, 22541, 13680, 13544, 6990, 4032, 29236, 23846, 12513, 28685, 12501, 1470, 25253, 25536, 8868, 10340, 1045, 27154, 18308, 3644, 3122, 15330, 9934, 1100, 15264, 14389, 17184, 28493, 11512, 13050, 1339, 15171, 2823, 15020, 28715, 9814, 19052, 25184, 892, 31565, 21101, 13394, 267, 13586, 6162, 9135, 23926, 7207, 3522, 9466, 10852 10347968, 2599, 8735, 29790, 6290, 30746, 32702, 4455, 16084, 13228, 29890, 28634, 5614, 3659, 22541, 13680, 13544, 6990, 4032, 29236, 23846, 12513, 28685, 12501, 1470, 25253, 25536, 8868, 10340, 1045, 27154, 18308, 3644, 3122, 15330, 9934, 1100, 15264, 14389, 17184, 28493, 11512, 13050, 1339, 15171, 2823, 15020, 28715, 9814, 19052, 25184, 892, 31565, 21101, 13394, 267, 13586, 6162, 9135, 23926, 7207, 3522, 9466, 10852
1035} 1035})
1036 1036
1037local lsh, bor = bit.lshift, bit.bor 1037local lsh, bor = bit.lshift, bit.bor
1038 1038
1039M.randomseed = function() rp = 0 end 1039M.randomseed = function() rp = 0 end
1040M.random = function() 1040M.random = function()
1041 local r1, r2 1041 local r1, r2
1042 r1 = r[rp + 1] 1042 r1 = r[rp]
1043 rp = (rp + 1) % 65536 1043 rp = (rp + 1) % 65536
1044 rp = r[rp + 1] 1044 rp = r[rp]
1045 r2 = r[rp + 1] 1045 r2 = r[rp]
1046 rp = (rp + 1) % 65536 1046 rp = (rp + 1) % 65536
1047 return bor(lsh(r1, 16), r2) 1047 return bor(lsh(r1, 16), r2)
1048end 1048end