Subversion Repositories Kolibri OS

Rev

Rev 8455 | Blame | Last modification | View Log | Download | RSS feed

  1. #include <kos32sys.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. #include <import.h>
  6.  
  7. static void _ButtonCreate()
  8. {
  9.     define_button(js_touint32(J, 1),js_touint32(J,2), js_touint32(J,3), js_touint32(J,4));
  10. }
  11.  
  12. static void _WindowCreate()
  13. {
  14.     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));
  15. }
  16.  
  17. static void _DebugPrintS()
  18. {
  19.     puts(js_tostring(J,1));
  20.  
  21. }
  22.  
  23. static void _GetButtonEvent()
  24. {
  25.     js_pushnumber(J,get_os_button());
  26. }
  27.  
  28. static void _WriteText()
  29. {
  30.     draw_text_sys(js_tostring(J,1), js_toint32(J,2), js_toint32(J,3), js_toint32(J,4), js_touint32(J,5));
  31. }
  32.  
  33. // KolibriSyscall(EAX, EBX, ECX, EDX, EDI, ESI)
  34. static void _KolibriSyscall()
  35. {
  36.     __asm__ __volatile__(
  37.     "int $0x40"
  38.     ::"a"(js_toint32(J,1)),
  39.      "b"(js_toint32(J,2)),
  40.      "c"(js_toint32(J,3)),
  41.      "d"(js_toint32(J,4)),
  42.      "D"(js_toint32(J,5)),
  43.      "S"(js_toint32(J,6)) : "memory");
  44. }
  45.  
  46. static void _KolibriSyscallReturnEAX()
  47. {
  48.     int _eax_;
  49.    
  50.     __asm__ __volatile__(
  51.     "int $0x40"
  52.     :"=a"(_eax_)
  53.     :"a"(js_toint32(J,1)),
  54.      "b"(js_toint32(J,2)),
  55.      "c"(js_toint32(J,3)),
  56.      "d"(js_toint32(J,4)),
  57.      "D"(js_toint32(J,5)),
  58.      "S"(js_toint32(J,6)) : "memory");
  59.      
  60.       js_pushnumber(J, _eax_);
  61. }
  62.  
  63. void import_functions()
  64. {
  65.     J = js_newstate(NULL, NULL, JS_STRICT);
  66.    
  67.     js_newcfunction(J, _WindowCreate, "WindowCreate", 7);
  68.     js_setglobal(J, "WindowCreate");
  69.  
  70.     js_newcfunction(J, _DebugPrintS, "DebugPrintS", 0);
  71.     js_setglobal(J, "DebugPrintS");
  72.  
  73.     js_newcfunction(J, _ButtonCreate, "ButtonCreate", 4);
  74.     js_setglobal(J, "ButtonCreate");
  75.  
  76.     js_newcfunction(J, _GetButtonEvent, "GetButtonEvent", 0);
  77.     js_setglobal(J, "GetButtonEvent");
  78.  
  79.     js_newcfunction(J, (void*)exit, "Exit", 0);
  80.     js_setglobal(J, "Exit");
  81.  
  82.     js_newcfunction(J, _WriteText, "WriteText", 5);
  83.     js_setglobal(J, "WriteText");
  84.    
  85.     js_newcfunction(J, _KolibriSyscall, "KolibriSyscall", 6);
  86.     js_setglobal(J, "KolibriSyscall");
  87.    
  88.     js_newcfunction(J, _KolibriSyscallReturnEAX, "KolibriSyscallReturnEAX", 6);
  89.     js_setglobal(J, "KolibriSyscallReturnEAX");
  90.  
  91. }
  92.