Wren Support #392

changed some func names
This commit is contained in:
BADIM-PC\Vadim 2018-02-05 21:55:15 +03:00
parent 4ff6f926f0
commit a99eb0f334
4 changed files with 205 additions and 254 deletions

View File

@ -1 +1 @@
0x78, 0xda, 0x63, 0x5c, 0xc0, 0xc4, 0x40, 0x08, 0xfc, 0xfb, 0x0f, 0x04, 0x4a, 0x4a, 0x4a, 0xfd, 0x1d, 0x1d, 0x1d, 0xfd, 0x20, 0x1a, 0xc8, 0xed, 0xff, 0xff, 0x01, 0x8e, 0xff, 0xff, 0x7f, 0xff, 0x4e, 0x49, 0xe9, 0xff, 0xbb, 0x8e, 0x8e, 0x0f, 0xef, 0x94, 0x9a, 0x3e, 0xbc, 0xfb, 0xdf, 0xff, 0xe1, 0xff, 0x87, 0xfe, 0x0f, 0x1f, 0x60, 0x18, 0xbb, 0xfe, 0xff, 0x78, 0xf5, 0xff, 0x47, 0xd2, 0xcf, 0x30, 0x0a, 0x06, 0x14, 0x80, 0xe3, 0x0a, 0x14, 0x77, 0x60, 0xf8, 0x03, 0xcc, 0xd6, 0x07, 0xc6, 0xe3, 0x7f, 0x86, 0x0f, 0xff, 0x81, 0x71, 0xfb, 0xef, 0x7f, 0x3f, 0xc3, 0x7f, 0x60, 0xdc, 0xbd, 0xef, 0x07, 0xc6, 0x5f, 0x07, 0x14, 0x83, 0xe2, 0x93, 0xe1, 0xc3, 0xfb, 0x77, 0xff, 0xff, 0xbf, 0x7b, 0x47, 0xa9, 0x7e, 0xd6, 0x65, 0x8c, 0x0c, 0xfa, 0xfa, 0x0a, 0x25, 0x99, 0x25, 0x39, 0xa9, 0x56, 0x0a, 0x0a, 0xe9, 0x89, 0xb9, 0xa9, 0x10, 0x0e, 0x17, 0x50, 0x34, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0xc8, 0x0a, 0x22, 0x9a, 0x92, 0x5a, 0x96, 0x9a, 0x93, 0x5f, 0x90, 0x5a, 0x04, 0x92, 0x49, 0x49, 0x2d, 0x4e, 0x06, 0x2a, 0x57, 0x28, 0x06, 0xca, 0x97, 0x80, 0x79, 0x45, 0x99, 0x05, 0x25, 0x99, 0xf9, 0x79, 0x20, 0x49, 0x08, 0xc7, 0x4a, 0xa1, 0xbc, 0x28, 0x35, 0x8f, 0x8b, 0x2b, 0x39, 0x27, 0xb1, 0xb8, 0x58, 0xc1, 0x1d, 0x64, 0x44, 0x66, 0xb1, 0x82, 0x6b, 0x5e, 0x7a, 0x66, 0x5e, 0xaa, 0x42, 0x35, 0x17, 0x17, 0x67, 0x72, 0x7e, 0x5e, 0x71, 0x49, 0x51, 0x69, 0x72, 0x89, 0x42, 0x5e, 0x6a, 0xb9, 0x86, 0x66, 0x35, 0x17, 0x27, 0x67, 0x7c, 0x89, 0xad, 0x01, 0x88, 0xaa, 0xb0, 0xb5, 0x34, 0x03, 0xd1, 0x95, 0xb6, 0x46, 0x26, 0x5c, 0x9c, 0xb5, 0x5c, 0x9c, 0x5c, 0x9c, 0xa5, 0x05, 0x29, 0x89, 0x25, 0xa9, 0x10, 0x65, 0x99, 0x69, 0x1a, 0x21, 0x99, 0xc9, 0x7a, 0x49, 0x25, 0x79, 0x1a, 0x06, 0x9a, 0x60, 0x11, 0x90, 0xd2, 0xf8, 0x4a, 0x5d, 0x43, 0x20, 0xb3, 0x16, 0x55, 0x81, 0x21, 0xb2, 0x02, 0x6d, 0x2c, 0x0a, 0x8c, 0x60, 0x0a, 0x2a, 0x6c, 0xe3, 0x2b, 0xb0, 0x99, 0x60, 0x8c, 0xac, 0x00, 0x6a, 0x02, 0x90, 0x00, 0x49, 0x27, 0xe7, 0x14, 0x6b, 0x18, 0x1a, 0x6b, 0x72, 0x29, 0x28, 0x80, 0x78, 0xc5, 0x05, 0x45, 0x1a, 0x86, 0xda, 0x1a, 0x1a, 0xf1, 0x25, 0xaa, 0x66, 0x06, 0x9a, 0xfa, 0xc6, 0x06, 0x35, 0x06, 0x9a, 0x5a, 0x46, 0x3a, 0xf1, 0x15, 0x3a, 0xf1, 0x95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0x14, 0x52, 0x36, 0x63, 0xd7, 0x9d, 0x7f, 0xef, 0xcf, 0xae, 0xee, 0x4c, 0x77, 0x55, 0x66, 0x84, 0xf1, 0x61, 0x34, 0x0f, 0x50, 0x8f, 0x08, 0x8f, 0x8c, 0x8b, 0x8a, 0x89, 0x81, 0x49, 0xae, 0x9f, 0x97, 0x5f, 0xab, 0x8f, 0x81, 0x49, 0xaa, 0xca, 0x05, 0x37, 0x8f, 0xd2, 0xc2, 0xc4, 0xc8, 0xda, 0x73, 0x97, 0x6a, 0x75, 0x5a, 0xa7, 0x2e, 0xcc, 0x5d, 0xa5, 0x73, 0x69, 0xd5, 0xcc, 0xdc, 0x43, 0xa7, 0x6e, 0x5d, 0x89, 0xbb, 0xf7, 0xee, 0x1a, 0x00, 0x78, 0xc5, 0x54, 0xb3,

Binary file not shown.

View File

@ -28,7 +28,11 @@
#define SFX_DEF_SPEED (1 << SFX_SPEED_BITS)
#define API_KEYWORDS {"TIC", "SCN", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
#define TIC_FN "TIC"
#define SCN_FN "SCN"
#define OVR_FN "OVR"
#define API_KEYWORDS {TIC_FN, SCN_FN, OVR_FN, "print", "cls", "pix", "line", "rect", "rectb", \
"spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \
"memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \
"clip", "music", "sync", "reset", "key", "keyp"}

View File

@ -37,129 +37,126 @@ static WrenHandle* overlap_handle;
static bool loaded = false;
static char const* tic_wren_api = " \n"
"class Tic { \n"
" foreign static btn(id) \n"
" foreign static btnp(id) \n"
" foreign static btnp(id, hold, period) \n"
" foreign static key(id) \n"
" foreign static keyp(id) \n"
" foreign static keyp(id, hold, period) \n"
" foreign static mouse() \n"
" foreign static font(text) \n"
" foreign static font(text, x, y) \n"
" foreign static font(text, x, y, alpha_color) \n"
" foreign static font(text, x, y, alpha_color, w, h) \n"
" foreign static font(text, x, y, alpha_color, w, h, fixed) \n"
" foreign static font(text, x, y, alpha_color, w, h, fixed, scale) \n"
" foreign static spr(id) \n"
" foreign static spr(id, x, y) \n"
" foreign static spr(id, x, y, alpha_color) \n"
" foreign static spr(id, x, y, alpha_color, scale) \n"
" foreign static spr(id, x, y, alpha_color, scale, flip) \n"
" foreign static spr(id, x, y, alpha_color, scale, flip, rotate) \n"
" foreign static spr(id, x, y, alpha_color, scale, flip, rotate, cell_width, cell_height) \n"
" foreign static map(cell_x, cell_y) \n"
" foreign static map(cell_x, cell_y, cell_w, cell_h) \n"
" foreign static map(cell_x, cell_y, cell_w, cell_h, x, y) \n"
" foreign static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color) \n"
" foreign static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color, scale) \n"
" foreign static mset(cell_x, cell_y) \n"
" foreign static mset(cell_x, cell_y, index) \n"
" foreign static mget(cell_x, cell_y) \n"
" foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3) \n"
" foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, use_map) \n"
" foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, use_map, alpha_color) \n"
" foreign static pix(x, y) \n"
" foreign static pix(x, y, color) \n"
" foreign static line(x0, y0, x1, y1, color) \n"
" foreign static circ(x, y, radius, color) \n"
" foreign static circb(x, y, radius, color) \n"
" foreign static rect(x, y, w, h, color) \n"
" foreign static rectb(x, y, w, h, color) \n"
" foreign static tri(x1, y1, x2, y2, x3, y3, color) \n"
" foreign static cls() \n"
" foreign static cls(color) \n"
" foreign static clip() \n"
" foreign static clip(x, y, w, h) \n"
" foreign static peek(addr) \n"
" foreign static poke(addr, val) \n"
" foreign static peek4(addr) \n"
" foreign static poke4(addr, val) \n"
" foreign static memcpy(dst, src, size) \n"
" foreign static memset(dst, src, size) \n"
" foreign static pmem(index, val) \n"
" foreign static sfx(id) \n"
" foreign static sfx(id, note) \n"
" foreign static sfx(id, note, duration) \n"
" foreign static sfx(id, note, duration, channel) \n"
" foreign static sfx(id, note, duration, channel, volume) \n"
" foreign static sfx(id, note, duration, channel, volume, speed) \n"
" foreign static music() \n"
" foreign static music(track) \n"
" foreign static music(track, frame) \n"
" foreign static music(track, frame, loop) \n"
" foreign static time() \n"
" foreign static sync() \n"
" foreign static sync(mask) \n"
" foreign static sync(mask, bank) \n"
" foreign static sync(mask, bank, tocart) \n"
" foreign static reset() \n"
" foreign static exit() \n"
" foreign static map_width__ \n"
" foreign static map_height__ \n"
" foreign static spritesize__ \n"
" foreign static print__(v, x, y, color, fixed, scale) \n"
" foreign static trace__(msg, color) \n"
" foreign static spr__(id, x, y, alpha_color, scale, flip, rotate) \n"
" foreign static mgeti__(index) \n"
" static print(v) { Tic.print__(v.toString, 0, 0, 15, false, 1) } \n"
" static print(v,x,y) { Tic.print__(v.toString, x, y, 15, false, 1) } \n"
" static print(v,x,y,color) { Tic.print__(v.toString, x, y, color, false, 1) } \n"
" static print(v,x,y,color,fixed) { Tic.print__(v.toString, x, y, color, fixed, 1) } \n"
" static print(v,x,y,color,fixed,scale) { Tic.print__(v.toString, x, y, color, fixed, scale) } \n"
" static trace(v) { Tic.trace__(v.toString, 15) } \n"
" static trace(v,color) { Tic.trace__(v.toString, color) } \n"
" static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color, scale, remap) { \n"
" var map_w = Tic.map_width__ \n"
" var map_h = Tic.map_height__ \n"
" var size = Tic.spritesize__ * scale \n"
" var jj = y \n"
" var ii = x \n"
" var flip = 0 \n"
" var rotate = 0 \n"
" for (j in cell_y...cell_y+cell_h) { \n"
" ii = x \n"
" for (i in cell_x...cell_x+cell_w) { \n"
" var mi = i \n"
" var mj = j \n"
" while(mi < 0) mi = mi + map_w \n"
" while(mj < 0) mj = mj + map_h \n"
" while(mi >= map_w) mi = mi - map_w \n"
" while(mj >= map_h) mj = mj - map_h \n"
" var index = mi + mj * map_w \n"
" var tile_index = Tic.mgeti__(index) \n"
" var ret = remap.call(tile_index, mi, mj) \n"
" if (ret.type == List) { \n"
" tile_index = ret[0] \n"
" flip = ret[1] \n"
" rotate = ret[2] \n"
" } else if (ret.type == Num) { \n"
" tile_index = ret \n"
" } \n"
" Tic.spr__(tile_index, ii, jj, alpha_color, scale, flip, rotate) \n"
" ii = ii + size \n"
" } \n"
" jj = jj + size \n"
" } \n"
" } \n"
"} \n"
"class Engine { \n"
" update(){} \n"
" scanline(row){} \n"
" overlap(){} \n"
"} \n"
"";
static char const* tic_wren_api = "\n\
class TIC {\n\
foreign static btn(id)\n\
foreign static btnp(id)\n\
foreign static btnp(id, hold, period)\n\
foreign static key(id)\n\
foreign static keyp(id)\n\
foreign static keyp(id, hold, period)\n\
foreign static mouse()\n\
foreign static font(text)\n\
foreign static font(text, x, y)\n\
foreign static font(text, x, y, alpha_color)\n\
foreign static font(text, x, y, alpha_color, w, h)\n\
foreign static font(text, x, y, alpha_color, w, h, fixed)\n\
foreign static font(text, x, y, alpha_color, w, h, fixed, scale)\n\
foreign static spr(id)\n\
foreign static spr(id, x, y)\n\
foreign static spr(id, x, y, alpha_color)\n\
foreign static spr(id, x, y, alpha_color, scale)\n\
foreign static spr(id, x, y, alpha_color, scale, flip)\n\
foreign static spr(id, x, y, alpha_color, scale, flip, rotate)\n\
foreign static spr(id, x, y, alpha_color, scale, flip, rotate, cell_width, cell_height)\n\
foreign static map(cell_x, cell_y)\n\
foreign static map(cell_x, cell_y, cell_w, cell_h)\n\
foreign static map(cell_x, cell_y, cell_w, cell_h, x, y)\n\
foreign static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color)\n\
foreign static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color, scale)\n\
foreign static mset(cell_x, cell_y)\n\
foreign static mset(cell_x, cell_y, index)\n\
foreign static mget(cell_x, cell_y)\n\
foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3)\n\
foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, use_map)\n\
foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, use_map, alpha_color)\n\
foreign static pix(x, y)\n\
foreign static pix(x, y, color)\n\
foreign static line(x0, y0, x1, y1, color)\n\
foreign static circ(x, y, radius, color)\n\
foreign static circb(x, y, radius, color)\n\
foreign static rect(x, y, w, h, color)\n\
foreign static rectb(x, y, w, h, color)\n\
foreign static tri(x1, y1, x2, y2, x3, y3, color)\n\
foreign static cls()\n\
foreign static cls(color)\n\
foreign static clip()\n\
foreign static clip(x, y, w, h)\n\
foreign static peek(addr)\n\
foreign static poke(addr, val)\n\
foreign static peek4(addr)\n\
foreign static poke4(addr, val)\n\
foreign static memcpy(dst, src, size)\n\
foreign static memset(dst, src, size)\n\
foreign static pmem(index, val)\n\
foreign static sfx(id)\n\
foreign static sfx(id, note)\n\
foreign static sfx(id, note, duration)\n\
foreign static sfx(id, note, duration, channel)\n\
foreign static sfx(id, note, duration, channel, volume)\n\
foreign static sfx(id, note, duration, channel, volume, speed)\n\
foreign static music()\n\
foreign static music(track)\n\
foreign static music(track, frame)\n\
foreign static music(track, frame, loop)\n\
foreign static time()\n\
foreign static sync()\n\
foreign static sync(mask)\n\
foreign static sync(mask, bank)\n\
foreign static sync(mask, bank, tocart)\n\
foreign static reset()\n\
foreign static exit()\n\
foreign static map_width__\n\
foreign static map_height__\n\
foreign static spritesize__\n\
foreign static print__(v, x, y, color, fixed, scale)\n\
foreign static trace__(msg, color)\n\
foreign static spr__(id, x, y, alpha_color, scale, flip, rotate)\n\
foreign static mgeti__(index)\n\
static print(v) { TIC.print__(v.toString, 0, 0, 15, false, 1) }\n\
static print(v,x,y) { TIC.print__(v.toString, x, y, 15, false, 1) }\n\
static print(v,x,y,color) { TIC.print__(v.toString, x, y, color, false, 1) }\n\
static print(v,x,y,color,fixed) { TIC.print__(v.toString, x, y, color, fixed, 1) }\n\
static print(v,x,y,color,fixed,scale) { TIC.print__(v.toString, x, y, color, fixed, scale) }\n\
static trace(v) { TIC.trace__(v.toString, 15) }\n\
static trace(v,color) { TIC.trace__(v.toString, color) }\n\
static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color, scale, remap) {\n\
var map_w = TIC.map_width__\n\
var map_h = TIC.map_height__\n\
var size = TIC.spritesize__ * scale\n\
var jj = y\n\
var ii = x\n\
var flip = 0\n\
var rotate = 0\n\
for (j in cell_y...cell_y+cell_h) {\n\
ii = x\n\
for (i in cell_x...cell_x+cell_w) {\n\
var mi = i\n\
var mj = j\n\
while(mi < 0) mi = mi + map_w\n\
while(mj < 0) mj = mj + map_h\n\
while(mi >= map_w) mi = mi - map_w\n\
while(mj >= map_h) mj = mj - map_h\n\
var index = mi + mj * map_w\n\
var tile_index = TIC.mgeti__(index)\n\
var ret = remap.call(tile_index, mi, mj)\n\
if (ret.type == List) {\n\
tile_index = ret[0]\n\
flip = ret[1]\n\
rotate = ret[2]\n\
} else if (ret.type == Num) {\n\
tile_index = ret\n\
}\n\
TIC.spr__(tile_index, ii, jj, alpha_color, scale, flip, rotate)\n\
ii = ii + size\n\
}\n\
jj = jj + size\n\
}\n\
}\n\
" TIC_FN "(){}\n\
" SCN_FN "(row){}\n\
" OVR_FN "(){}\n\
}\n";
static inline void wrenError(WrenVM* vm, const char* msg)
{
@ -1079,94 +1076,95 @@ static void wren_exit(WrenVM* vm)
static const char* const ApiKeywords[] = API_KEYWORDS;
WrenForeignMethodFn foreignTicMethods(const char* signature){
static WrenForeignMethodFn foreignTicMethods(const char* signature)
{
if (strcmp(signature, "static Tic.btn(_)" ) == 0) return wren_btn;
if (strcmp(signature, "static Tic.btnp(_)" ) == 0) return wren_btnp;
if (strcmp(signature, "static Tic.btnp(_,_,_)" ) == 0) return wren_btnp;
if (strcmp(signature, "static Tic.key(_)" ) == 0) return wren_key;
if (strcmp(signature, "static Tic.keyp(_)" ) == 0) return wren_keyp;
if (strcmp(signature, "static Tic.keyp(_,_,_)" ) == 0) return wren_keyp;
if (strcmp(signature, "static Tic.mouse()" ) == 0) return wren_mouse;
if (strcmp(signature, "static TIC.btn(_)" ) == 0) return wren_btn;
if (strcmp(signature, "static TIC.btnp(_)" ) == 0) return wren_btnp;
if (strcmp(signature, "static TIC.btnp(_,_,_)" ) == 0) return wren_btnp;
if (strcmp(signature, "static TIC.key(_)" ) == 0) return wren_key;
if (strcmp(signature, "static TIC.keyp(_)" ) == 0) return wren_keyp;
if (strcmp(signature, "static TIC.keyp(_,_,_)" ) == 0) return wren_keyp;
if (strcmp(signature, "static TIC.mouse()" ) == 0) return wren_mouse;
if (strcmp(signature, "static Tic.font(_)" ) == 0) return wren_font;
if (strcmp(signature, "static Tic.font(_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static Tic.font(_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static Tic.font(_,_,_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static Tic.font(_,_,_,_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static Tic.font(_,_,_,_,_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static TIC.font(_)" ) == 0) return wren_font;
if (strcmp(signature, "static TIC.font(_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static TIC.font(_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static TIC.font(_,_,_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static TIC.font(_,_,_,_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static TIC.font(_,_,_,_,_,_,_,_)" ) == 0) return wren_font;
if (strcmp(signature, "static Tic.spr(_)" ) == 0) return wren_spr;
if (strcmp(signature, "static Tic.spr(_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static Tic.spr(_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static Tic.spr(_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static Tic.spr(_,_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static Tic.spr(_,_,_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static Tic.spr(_,_,_,_,_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static TIC.spr(_)" ) == 0) return wren_spr;
if (strcmp(signature, "static TIC.spr(_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static TIC.spr(_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static TIC.spr(_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static TIC.spr(_,_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static TIC.spr(_,_,_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static TIC.spr(_,_,_,_,_,_,_,_,_)" ) == 0) return wren_spr;
if (strcmp(signature, "static Tic.map(_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static Tic.map(_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static Tic.map(_,_,_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static Tic.map(_,_,_,_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static Tic.map(_,_,_,_,_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static TIC.map(_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static TIC.map(_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static TIC.map(_,_,_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static TIC.map(_,_,_,_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static TIC.map(_,_,_,_,_,_,_,_)" ) == 0) return wren_map;
if (strcmp(signature, "static Tic.mset(_,_)" ) == 0) return wren_mset;
if (strcmp(signature, "static Tic.mset(_,_,_)" ) == 0) return wren_mset;
if (strcmp(signature, "static Tic.mget(_,_)" ) == 0) return wren_mget;
if (strcmp(signature, "static TIC.mset(_,_)" ) == 0) return wren_mset;
if (strcmp(signature, "static TIC.mset(_,_,_)" ) == 0) return wren_mset;
if (strcmp(signature, "static TIC.mget(_,_)" ) == 0) return wren_mget;
if (strcmp(signature, "static Tic.textri(_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
if (strcmp(signature, "static Tic.textri(_,_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
if (strcmp(signature, "static Tic.textri(_,_,_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
if (strcmp(signature, "static TIC.textri(_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
if (strcmp(signature, "static TIC.textri(_,_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
if (strcmp(signature, "static TIC.textri(_,_,_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
if (strcmp(signature, "static Tic.pix(_,_)" ) == 0) return wren_pix;
if (strcmp(signature, "static Tic.pix(_,_,_)" ) == 0) return wren_pix;
if (strcmp(signature, "static Tic.line(_,_,_,_,_)" ) == 0) return wren_line;
if (strcmp(signature, "static Tic.circ(_,_,_,_)" ) == 0) return wren_circ;
if (strcmp(signature, "static Tic.circb(_,_,_,_)" ) == 0) return wren_circb;
if (strcmp(signature, "static Tic.rect(_,_,_,_,_)" ) == 0) return wren_rect;
if (strcmp(signature, "static Tic.rectb(_,_,_,_,_)" ) == 0) return wren_rectb;
if (strcmp(signature, "static Tic.tri(_,_,_,_,_,_,_)" ) == 0) return wren_tri;
if (strcmp(signature, "static TIC.pix(_,_)" ) == 0) return wren_pix;
if (strcmp(signature, "static TIC.pix(_,_,_)" ) == 0) return wren_pix;
if (strcmp(signature, "static TIC.line(_,_,_,_,_)" ) == 0) return wren_line;
if (strcmp(signature, "static TIC.circ(_,_,_,_)" ) == 0) return wren_circ;
if (strcmp(signature, "static TIC.circb(_,_,_,_)" ) == 0) return wren_circb;
if (strcmp(signature, "static TIC.rect(_,_,_,_,_)" ) == 0) return wren_rect;
if (strcmp(signature, "static TIC.rectb(_,_,_,_,_)" ) == 0) return wren_rectb;
if (strcmp(signature, "static TIC.tri(_,_,_,_,_,_,_)" ) == 0) return wren_tri;
if (strcmp(signature, "static Tic.cls()" ) == 0) return wren_cls;
if (strcmp(signature, "static Tic.cls(_)" ) == 0) return wren_cls;
if (strcmp(signature, "static Tic.clip()" ) == 0) return wren_clip;
if (strcmp(signature, "static Tic.clip(_,_,_,_)" ) == 0) return wren_clip;
if (strcmp(signature, "static TIC.cls()" ) == 0) return wren_cls;
if (strcmp(signature, "static TIC.cls(_)" ) == 0) return wren_cls;
if (strcmp(signature, "static TIC.clip()" ) == 0) return wren_clip;
if (strcmp(signature, "static TIC.clip(_,_,_,_)" ) == 0) return wren_clip;
if (strcmp(signature, "static Tic.peek(_)" ) == 0) return wren_peek;
if (strcmp(signature, "static Tic.poke(_,_)" ) == 0) return wren_poke;
if (strcmp(signature, "static Tic.peek4(_)" ) == 0) return wren_peek4;
if (strcmp(signature, "static Tic.poke4(_,_)" ) == 0) return wren_poke4;
if (strcmp(signature, "static Tic.memcpy(_,_,_)" ) == 0) return wren_memcpy;
if (strcmp(signature, "static Tic.memset(_,_,_)" ) == 0) return wren_memset;
if (strcmp(signature, "static Tic.pmem(_,_)" ) == 0) return wren_pmem;
if (strcmp(signature, "static TIC.peek(_)" ) == 0) return wren_peek;
if (strcmp(signature, "static TIC.poke(_,_)" ) == 0) return wren_poke;
if (strcmp(signature, "static TIC.peek4(_)" ) == 0) return wren_peek4;
if (strcmp(signature, "static TIC.poke4(_,_)" ) == 0) return wren_poke4;
if (strcmp(signature, "static TIC.memcpy(_,_,_)" ) == 0) return wren_memcpy;
if (strcmp(signature, "static TIC.memset(_,_,_)" ) == 0) return wren_memset;
if (strcmp(signature, "static TIC.pmem(_,_)" ) == 0) return wren_pmem;
if (strcmp(signature, "static Tic.sfx(_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static Tic.sfx(_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static Tic.sfx(_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static Tic.sfx(_,_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static Tic.sfx(_,_,_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static Tic.sfx(_,_,_,_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static Tic.music()" ) == 0) return wren_music;
if (strcmp(signature, "static Tic.music(_)" ) == 0) return wren_music;
if (strcmp(signature, "static Tic.music(_,_)" ) == 0) return wren_music;
if (strcmp(signature, "static Tic.music(_,_,_)" ) == 0) return wren_music;
if (strcmp(signature, "static TIC.sfx(_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static TIC.sfx(_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static TIC.sfx(_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static TIC.sfx(_,_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static TIC.sfx(_,_,_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static TIC.sfx(_,_,_,_,_,_)" ) == 0) return wren_sfx;
if (strcmp(signature, "static TIC.music()" ) == 0) return wren_music;
if (strcmp(signature, "static TIC.music(_)" ) == 0) return wren_music;
if (strcmp(signature, "static TIC.music(_,_)" ) == 0) return wren_music;
if (strcmp(signature, "static TIC.music(_,_,_)" ) == 0) return wren_music;
if (strcmp(signature, "static Tic.time()" ) == 0) return wren_time;
if (strcmp(signature, "static Tic.sync()" ) == 0) return wren_sync;
if (strcmp(signature, "static Tic.sync(_)" ) == 0) return wren_sync;
if (strcmp(signature, "static Tic.sync(_,_)" ) == 0) return wren_sync;
if (strcmp(signature, "static Tic.sync(_,_,_)" ) == 0) return wren_sync;
if (strcmp(signature, "static Tic.reset()" ) == 0) return wren_reset;
if (strcmp(signature, "static Tic.exit()" ) == 0) return wren_exit;
if (strcmp(signature, "static TIC.time()" ) == 0) return wren_time;
if (strcmp(signature, "static TIC.sync()" ) == 0) return wren_sync;
if (strcmp(signature, "static TIC.sync(_)" ) == 0) return wren_sync;
if (strcmp(signature, "static TIC.sync(_,_)" ) == 0) return wren_sync;
if (strcmp(signature, "static TIC.sync(_,_,_)" ) == 0) return wren_sync;
if (strcmp(signature, "static TIC.reset()" ) == 0) return wren_reset;
if (strcmp(signature, "static TIC.exit()" ) == 0) return wren_exit;
// internal functions
if (strcmp(signature, "static Tic.map_width__" ) == 0) return wren_map_width;
if (strcmp(signature, "static Tic.map_height__" ) == 0) return wren_map_height;
if (strcmp(signature, "static Tic.spritesize__" ) == 0) return wren_spritesize;
if (strcmp(signature, "static Tic.print__(_,_,_,_,_,_)" ) == 0) return wren_print;
if (strcmp(signature, "static Tic.trace__(_,_)" ) == 0) return wren_trace;
if (strcmp(signature, "static Tic.spr__(_,_,_,_,_,_,_)" ) == 0) return wren_spr_internal;
if (strcmp(signature, "static Tic.mgeti__(_)" ) == 0) return wren_mgeti;
if (strcmp(signature, "static TIC.map_width__" ) == 0) return wren_map_width;
if (strcmp(signature, "static TIC.map_height__" ) == 0) return wren_map_height;
if (strcmp(signature, "static TIC.spritesize__" ) == 0) return wren_spritesize;
if (strcmp(signature, "static TIC.print__(_,_,_,_,_,_)" ) == 0) return wren_print;
if (strcmp(signature, "static TIC.trace__(_,_)" ) == 0) return wren_trace;
if (strcmp(signature, "static TIC.spr__(_,_,_,_,_,_,_)" ) == 0) return wren_spr_internal;
if (strcmp(signature, "static TIC.mgeti__(_)" ) == 0) return wren_mgeti;
return NULL;
}
@ -1259,9 +1257,9 @@ static bool initWren(tic_mem* tic, const char* code)
game_class = wrenGetSlotHandle(vm, 0); // handle from game class
new_handle = wrenMakeCallHandle(vm, "new()");
update_handle = wrenMakeCallHandle(vm, "update()");
scanline_handle = wrenMakeCallHandle(vm, "scanline(_)");
overlap_handle = wrenMakeCallHandle(vm, "overlap()");
update_handle = wrenMakeCallHandle(vm, TIC_FN "()");
scanline_handle = wrenMakeCallHandle(vm, SCN_FN "(_)");
overlap_handle = wrenMakeCallHandle(vm, OVR_FN "()");
// create game class
if (game_class)
@ -1331,8 +1329,6 @@ static const char* const WrenKeywords [] =
"return", "static", "super", "var", "while", "this"
};
static inline bool isalnum_(char c) {return isalnum(c) || c == '_';}
static const tic_outline_item* getWrenOutline(const char* code, s32* size)
{
enum{Size = sizeof(tic_outline_item)};
@ -1341,55 +1337,6 @@ static const tic_outline_item* getWrenOutline(const char* code, s32* size)
static tic_outline_item* items = NULL;
if(items)
{
free(items);
items = NULL;
}
const char* ptr = code;
while(true)
{
static const char FuncString[] = "function ";
ptr = strstr(ptr, FuncString);
if(ptr)
{
ptr += sizeof FuncString - 1;
const char* start = ptr;
const char* end = start;
while(*ptr)
{
char c = *ptr;
if(isalnum_(c));
else if(c == '(')
{
end = ptr;
break;
}
else break;
ptr++;
}
if(end > start)
{
items = items ? realloc(items, (*size + 1) * Size) : malloc(Size);
items[*size].pos = start - code;
items[*size].size = end - start;
(*size)++;
}
}
else break;
}
return items;
}