2020-04-29 20:58:22 +02:00
|
|
|
/*
|
|
|
|
STDCALL function
|
|
|
|
Author: PaulCodeman
|
|
|
|
*/
|
2018-12-06 22:09:52 +01:00
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
void initFunctionLisp()
|
|
|
|
{
|
|
|
|
set_procedure("TEST", #lisp_test);
|
|
|
|
set_procedure("SLEEP", #lisp_sleep);
|
|
|
|
set_procedure("PRINT", #lisp_print);
|
|
|
|
set_procedure("INPUT", #lisp_input);
|
|
|
|
set_procedure("STDCALL", #lisp_stdcall);
|
|
|
|
set_procedure("SETQ", #lisp_setq);
|
|
|
|
set_procedure("DEFVAR", #lisp_setq);
|
|
|
|
set_procedure("+", #lisp_add);
|
|
|
|
set_procedure("-", #lisp_sub);
|
|
|
|
set_procedure("=", #lisp_cmp);
|
|
|
|
}
|
2020-03-22 12:50:49 +01:00
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_test(dword args)
|
2018-12-27 12:27:01 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
malloc(sizeStruct);
|
|
|
|
DSDWORD[EAX] = TString;
|
|
|
|
DSDWORD[EAX+4] = "ZZZ";
|
|
|
|
return EAX;
|
2018-12-27 12:27:01 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_setq(dword args)
|
2018-12-06 22:09:52 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword i = 0;
|
2018-12-06 22:09:52 +01:00
|
|
|
dword name = 0;
|
2020-04-29 20:58:22 +02:00
|
|
|
dword data = 0;
|
|
|
|
while(1)
|
2018-12-06 22:09:52 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
i++;
|
|
|
|
data = indexArray(args, i);
|
|
|
|
data = DSDWORD[data];
|
|
|
|
IF (!data) break;
|
|
|
|
|
|
|
|
if (i&1)
|
|
|
|
{
|
|
|
|
name = DSDWORD[data+4];
|
|
|
|
}
|
|
|
|
else
|
2020-03-22 00:26:21 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
set_variable(name, data);
|
2020-03-22 00:26:21 +01:00
|
|
|
}
|
2018-12-06 22:09:52 +01:00
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
return 0;
|
2018-12-06 22:09:52 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_print(dword args)
|
2018-12-06 22:09:52 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword i = 0;
|
|
|
|
consoleInit();
|
|
|
|
while(1)
|
2020-03-22 00:26:21 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
i++;
|
|
|
|
indexArray(args, i);
|
|
|
|
IF (!DSDWORD[EAX]) break;
|
|
|
|
con_printf stdcall (string(DSDWORD[EAX]));
|
2020-03-22 00:26:21 +01:00
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
con_printf stdcall ("\r\n");
|
|
|
|
return 0;
|
2018-12-06 09:59:06 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_stdcall(dword args)
|
2018-12-06 09:59:06 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword i = 0;
|
|
|
|
dword buffer = 0;
|
|
|
|
while(1)
|
2018-12-04 23:34:36 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
i++;
|
|
|
|
indexArray(args, i);
|
|
|
|
buffer = DSDWORD[EAX];
|
|
|
|
IF (!buffer) break;
|
|
|
|
$push DSDWORD[buffer+4];
|
2018-12-04 23:34:36 +01:00
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
IF (i == 2) $pop eax
|
|
|
|
IF (i == 3) $pop ebx
|
|
|
|
IF (i == 4) $pop ecx
|
|
|
|
$int 0x40
|
|
|
|
return EAX;
|
2018-12-06 09:59:06 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_input(dword args)
|
2020-03-22 12:50:49 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword buffer = 0;
|
|
|
|
consoleInit();
|
|
|
|
buffer = malloc(100);
|
|
|
|
con_gets stdcall(buffer, 100);
|
|
|
|
malloc(sizeStruct);
|
|
|
|
DSDWORD[EAX] = TString;
|
|
|
|
DSDWORD[EAX+4] = buffer;
|
|
|
|
return EAX;
|
2020-03-22 12:50:49 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_inc(dword args)
|
2018-12-06 09:59:06 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword i = 0;
|
|
|
|
dword sum = 0;
|
|
|
|
dword buffer = 0;
|
|
|
|
while(1)
|
2018-12-04 23:34:36 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
i++;
|
|
|
|
buffer = indexArray(args, i);
|
|
|
|
IF (!DSDWORD[buffer]) break;
|
|
|
|
buffer = DSDWORD[buffer];
|
2018-12-07 12:22:15 +01:00
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
return 0;
|
2018-12-07 12:22:15 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_add(dword args)
|
2020-03-22 12:50:49 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword i = 0;
|
|
|
|
dword sum = 0;
|
|
|
|
dword buffer = 0;
|
|
|
|
while(1)
|
2020-03-22 12:50:49 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
i++;
|
|
|
|
buffer = indexArray(args, i);
|
|
|
|
IF (!DSDWORD[buffer]) break;
|
|
|
|
buffer = DSDWORD[buffer];
|
|
|
|
|
|
|
|
sum += number(buffer);
|
2020-03-22 12:50:49 +01:00
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
malloc(sizeStruct);
|
|
|
|
DSDWORD[EAX] = TNumber;
|
|
|
|
DSDWORD[EAX+4] = sum;
|
|
|
|
return EAX;
|
2020-03-22 12:50:49 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_sub(dword args)
|
2018-12-07 12:22:15 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword i = 0;
|
|
|
|
dword sum = 0;
|
|
|
|
while(1)
|
2018-12-07 12:22:15 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
i++;
|
|
|
|
indexArray(args, i);
|
|
|
|
IF (!DSDWORD[EAX]) break;
|
|
|
|
sum -= number(DSDWORD[EAX]);
|
2018-12-04 23:34:36 +01:00
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
malloc(sizeStruct);
|
|
|
|
DSDWORD[EAX] = TNumber;
|
|
|
|
DSDWORD[EAX+4] = sum;
|
|
|
|
return EAX;
|
2018-12-06 09:59:06 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_cmp(dword args)
|
2018-12-07 12:22:15 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword i = 0;
|
|
|
|
dword first = 0;
|
|
|
|
dword buffer = 0;
|
|
|
|
|
|
|
|
while(1)
|
2020-03-22 00:26:21 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
i++;
|
|
|
|
buffer = indexArray(args, i);
|
|
|
|
buffer = DSDWORD[buffer];
|
|
|
|
IF (!buffer) break;
|
|
|
|
if (i == 1)
|
2020-03-22 00:26:21 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
first = buffer;
|
2020-03-22 00:26:21 +01:00
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
else
|
2020-03-22 00:26:21 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
if (DSDWORD[first+4] != DSDWORD[buffer+4])
|
|
|
|
{
|
|
|
|
malloc(sizeStruct);
|
|
|
|
DSDWORD[EAX] = TSymbol;
|
|
|
|
DSDWORD[EAX+4] = NIL;
|
|
|
|
return EAX;
|
|
|
|
}
|
2020-03-22 00:26:21 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-29 20:58:22 +02:00
|
|
|
if (i == 1) error_message("*** - EVAL: too few arguments given to =: (=)");
|
|
|
|
malloc(sizeStruct);
|
|
|
|
DSDWORD[EAX] = TSymbol;
|
|
|
|
DSDWORD[EAX+4] = "T";
|
|
|
|
return EAX;
|
2020-03-22 00:26:21 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:58:22 +02:00
|
|
|
dword lisp_sleep(dword args)
|
2020-03-22 00:26:21 +01:00
|
|
|
{
|
2020-04-29 20:58:22 +02:00
|
|
|
dword time = 0;
|
|
|
|
indexArray(args, 1);
|
|
|
|
time = number(DSDWORD[EAX]);
|
|
|
|
EAX = 5;
|
|
|
|
EBX = time;
|
|
|
|
$int 0x40
|
|
|
|
return 0;
|
2018-12-07 12:22:15 +01:00
|
|
|
}
|