2018-12-06 22:09:52 +01:00
|
|
|
|
2018-12-07 12:22:15 +01:00
|
|
|
/* Lisp functions */
|
2018-12-06 22:09:52 +01:00
|
|
|
:dword std_set(dword count, args)
|
|
|
|
{
|
|
|
|
dword name = 0;
|
|
|
|
dword value = 0;
|
2018-12-07 12:22:15 +01:00
|
|
|
WHILE(count > 0)
|
2018-12-06 22:09:52 +01:00
|
|
|
{
|
|
|
|
name = DSDWORD[args];
|
|
|
|
args += 4;
|
|
|
|
value = DSDWORD[args];
|
|
|
|
args += 4;
|
|
|
|
variables.set(name, value);
|
2018-12-07 12:22:15 +01:00
|
|
|
count -= 2;
|
2018-12-06 22:09:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
:dword std_get(dword count, args)
|
|
|
|
{
|
2018-12-07 12:22:15 +01:00
|
|
|
IF(!count) RETURN 0;
|
2018-12-06 22:09:52 +01:00
|
|
|
RETURN variables.get(DSDWORD[args]);
|
|
|
|
}
|
|
|
|
|
2018-12-06 09:59:06 +01:00
|
|
|
:dword std_str(dword count, args)
|
|
|
|
{
|
|
|
|
dword tmp = 0;
|
2018-12-07 12:22:15 +01:00
|
|
|
IF(!count) RETURN "";
|
2018-12-06 09:59:06 +01:00
|
|
|
tmp = malloc(15);
|
|
|
|
itoa_(tmp,DSDWORD[args]);
|
|
|
|
RETURN tmp;
|
|
|
|
}
|
|
|
|
|
2018-12-07 12:22:15 +01:00
|
|
|
/* Math functions */
|
2018-12-06 09:59:06 +01:00
|
|
|
:dword std_add(dword count, args)
|
|
|
|
{
|
|
|
|
dword ret = 0;
|
|
|
|
WHILE(count)
|
2018-12-04 23:34:36 +01:00
|
|
|
{
|
2018-12-06 09:59:06 +01:00
|
|
|
ret += DSDWORD[args];
|
|
|
|
args+=4;
|
|
|
|
count--;
|
2018-12-04 23:34:36 +01:00
|
|
|
}
|
2018-12-06 09:59:06 +01:00
|
|
|
RETURN ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
:dword std_sub(dword count, args)
|
|
|
|
{
|
|
|
|
dword ret = 0;
|
|
|
|
IF(count)
|
|
|
|
{
|
|
|
|
ret = DSDWORD[args];
|
|
|
|
count--;
|
|
|
|
args+=4;
|
2018-12-04 23:34:36 +01:00
|
|
|
}
|
2018-12-06 09:59:06 +01:00
|
|
|
WHILE(count)
|
2018-12-04 23:34:36 +01:00
|
|
|
{
|
2018-12-06 09:59:06 +01:00
|
|
|
ret -= DSDWORD[args];
|
2018-12-07 12:22:15 +01:00
|
|
|
args += 4;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
RETURN ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Console functions */
|
|
|
|
:dword std_print(dword count, args)
|
|
|
|
{
|
|
|
|
dword ret = 0;
|
|
|
|
WHILE(count)
|
|
|
|
{
|
|
|
|
con_printf stdcall (DSDWORD[args]);
|
2018-12-06 09:59:06 +01:00
|
|
|
args+=4;
|
|
|
|
count--;
|
2018-12-04 23:34:36 +01:00
|
|
|
}
|
2018-12-06 09:59:06 +01:00
|
|
|
RETURN ret;
|
|
|
|
}
|
|
|
|
|
2018-12-07 12:22:15 +01:00
|
|
|
:dword std_input(dword count, args)
|
|
|
|
{
|
|
|
|
dword buf = 0;
|
|
|
|
buf = malloc(100);
|
|
|
|
WHILE(count)
|
|
|
|
{
|
|
|
|
con_printf stdcall (DSDWORD[args]);
|
|
|
|
args+=4;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
con_gets stdcall(buf, 100);
|
|
|
|
RETURN EAX;
|
|
|
|
}
|
|
|
|
|
2018-12-06 09:59:06 +01:00
|
|
|
void Init()
|
|
|
|
{
|
|
|
|
functions.init(100);
|
|
|
|
|
|
|
|
/* Console functions */
|
2018-12-07 12:22:15 +01:00
|
|
|
functions.set("print", #std_print);
|
|
|
|
functions.set("input", #std_input);
|
2018-12-06 09:59:06 +01:00
|
|
|
|
|
|
|
/* String functions */
|
|
|
|
functions.set("str", #std_str);
|
|
|
|
|
|
|
|
/* System functions */
|
|
|
|
functions.set("exit", #ExitProcess);
|
|
|
|
|
|
|
|
/* Math functions */
|
|
|
|
functions.set("+", #std_add);
|
|
|
|
functions.set("-", #std_sub);
|
|
|
|
|
2018-12-06 22:09:52 +01:00
|
|
|
/* Lisp functions */
|
|
|
|
functions.set("set", #std_set);
|
|
|
|
functions.set("get", #std_get);
|
|
|
|
|
2018-12-06 09:59:06 +01:00
|
|
|
variables.init(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
dword StdCall(dword count, name, args)
|
|
|
|
{
|
|
|
|
functions.get(name);
|
2018-12-06 22:09:52 +01:00
|
|
|
IF(EAX) RETURN EAX(count, args);
|
2018-12-06 09:59:06 +01:00
|
|
|
RETURN 0;
|
2018-12-06 22:09:52 +01:00
|
|
|
}
|
|
|
|
|