Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8476 → Rev 8477

/programs/develop/kosjs/examples/example.js
1,6 → 1,29
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()
7,6 → 30,7
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()
/programs/develop/kosjs/import.c
14,16 → 14,6
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));
30,11 → 20,6
 
}
 
static void _GetEvent()
{
js_pushnumber(J, get_os_event());
}
 
static void _GetButtonEvent()
{
js_pushnumber(J,get_os_button());
45,6 → 30,36
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
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
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");
 
}