mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-28 03:39:35 +03:00
KosJS: Replace static functions with dynamic
git-svn-id: svn://kolibrios.org@8477 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0f14837705
commit
f458b2c462
@ -1,12 +1,36 @@
|
||||
var button_text = 0
|
||||
var button = 2
|
||||
|
||||
// Dynamic functions! //
|
||||
//////////////////////////////////////////////////
|
||||
function Delay(long)
|
||||
{
|
||||
KolibriSyscall(5, long, 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
function StartDraw()
|
||||
{
|
||||
KolibriSyscall(12, 1, 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
function EndDraw()
|
||||
{
|
||||
KolibriSyscall(12, 2, 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
function GetEvent()
|
||||
{
|
||||
return KolibriSyscallReturnEAX(10, 0, 0, 0, 0, 0)
|
||||
}
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
function Redraw()
|
||||
{
|
||||
StartDraw()
|
||||
WindowCreate(10, 40, 400, 200, "My window", 0xFFFFFF, 0x14)
|
||||
WriteText("KolibriOS JS example", 15, 34, 0, 0x90000000, 0xFFFFFF)
|
||||
ButtonCreate((150 << 16) + 100, (100 << 16) + 50, button, 0x177245)
|
||||
// Delay(100)
|
||||
WriteText("Click!", 155,115, 0, 0x91000000 | 0xFFFFFF)
|
||||
WriteText(button_text, 15,100, 0, 0x92000000)
|
||||
EndDraw()
|
||||
|
@ -14,27 +14,12 @@ static void _WindowCreate()
|
||||
sys_create_window(js_toint(J, 1), js_toint(J, 2), js_toint(J, 3), js_toint(J, 4), js_tostring(J,5), js_touint32(J,6), js_touint32(J,7));
|
||||
}
|
||||
|
||||
static void _StartDraw()
|
||||
{
|
||||
begin_draw();
|
||||
}
|
||||
|
||||
static void _EndDraw()
|
||||
{
|
||||
end_draw();
|
||||
}
|
||||
|
||||
static void _DebugPrintS()
|
||||
{
|
||||
puts(js_tostring(J,1));
|
||||
|
||||
}
|
||||
|
||||
static void _GetEvent()
|
||||
{
|
||||
js_pushnumber(J, get_os_event());
|
||||
}
|
||||
|
||||
static void _GetButtonEvent()
|
||||
{
|
||||
js_pushnumber(J,get_os_button());
|
||||
@ -45,6 +30,36 @@ static void _WriteText()
|
||||
draw_text_sys(js_tostring(J,1), js_toint32(J,2), js_toint32(J,3), js_toint32(J,4), js_touint32(J,5));
|
||||
}
|
||||
|
||||
// KolibriSyscall(EAX, EBX, ECX, EDX, EDI, ESI)
|
||||
static void _KolibriSyscall()
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
::"a"(js_toint32(J,1)),
|
||||
"b"(js_toint32(J,2)),
|
||||
"c"(js_toint32(J,3)),
|
||||
"d"(js_toint32(J,4)),
|
||||
"D"(js_toint32(J,5)),
|
||||
"S"(js_toint32(J,6)) : "memory");
|
||||
}
|
||||
|
||||
static void _KolibriSyscallReturnEAX()
|
||||
{
|
||||
int _eax_;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
:"=a"(_eax_)
|
||||
:"a"(js_toint32(J,1)),
|
||||
"b"(js_toint32(J,2)),
|
||||
"c"(js_toint32(J,3)),
|
||||
"d"(js_toint32(J,4)),
|
||||
"D"(js_toint32(J,5)),
|
||||
"S"(js_toint32(J,6)) : "memory");
|
||||
|
||||
js_pushnumber(J, _eax_);
|
||||
}
|
||||
|
||||
void import_functions()
|
||||
{
|
||||
J = js_newstate(NULL, NULL, JS_STRICT);
|
||||
@ -52,15 +67,6 @@ void import_functions()
|
||||
js_newcfunction(J, _WindowCreate, "WindowCreate", 7);
|
||||
js_setglobal(J, "WindowCreate");
|
||||
|
||||
js_newcfunction(J, _StartDraw, "StartDraw", 0);
|
||||
js_setglobal(J, "StartDraw");
|
||||
|
||||
js_newcfunction(J, _EndDraw, "EndDraw", 0);
|
||||
js_setglobal(J, "EndDraw");
|
||||
|
||||
js_newcfunction(J, _GetEvent, "GetEvent", 0);
|
||||
js_setglobal(J, "GetEvent");
|
||||
|
||||
js_newcfunction(J, _DebugPrintS, "DebugPrintS", 0);
|
||||
js_setglobal(J, "DebugPrintS");
|
||||
|
||||
@ -76,4 +82,10 @@ void import_functions()
|
||||
js_newcfunction(J, _WriteText, "WriteText", 5);
|
||||
js_setglobal(J, "WriteText");
|
||||
|
||||
js_newcfunction(J, _KolibriSyscall, "KolibriSyscall", 6);
|
||||
js_setglobal(J, "KolibriSyscall");
|
||||
|
||||
js_newcfunction(J, _KolibriSyscallReturnEAX, "KolibriSyscallReturnEAX", 6);
|
||||
js_setglobal(J, "KolibriSyscallReturnEAX");
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user