Subversion Repositories Kolibri OS

Rev

Rev 1665 | Rev 1673 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #include "kolibri.h"
  3. #include "string.h"
  4.  
  5.  
  6. extern char KOL_PATH[256];
  7. extern char KOL_PARAM[256];
  8. extern char KOL_DIR[256];
  9.  
  10.  
  11. void kol_exit()
  12. {
  13. asm ("int $0x40"::"a"(-1));
  14. }
  15.  
  16.  
  17. void kol_sleep(unsigned d)
  18. {
  19. asm ("int $0x40"::"a"(5), "b"(d));
  20. }
  21.  
  22.  
  23. void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c)
  24. {
  25. asm ("nop"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(c));
  26. asm ("movl $0xffffff, %esi \n int $0x40");
  27. }
  28.  
  29.  
  30. void kol_wnd_move(unsigned x, unsigned y)
  31. {
  32. asm ("nop"::"a"(67), "b"(x), "c"(y));
  33. asm ("movl $-1, %edx \n movl $-1, %esi \n int $0x40");
  34. }
  35.  
  36.  
  37. void kol_event_mask(unsigned e)
  38. {
  39. asm ("int $0x40"::"a"(40), "b"(e));
  40. }
  41.  
  42.  
  43. unsigned kol_event_wait()
  44. {
  45. asm ("int $0x40"::"a"(10));
  46. }
  47.  
  48.  
  49. unsigned kol_event_wait_time(unsigned time)
  50. {
  51. asm ("int $0x40"::"a"(23), "b"(time));
  52. }
  53.  
  54.  
  55. unsigned kol_event_check()
  56. {
  57. asm ("int $0x40"::"a"(11));
  58. }
  59.  
  60.  
  61. void kol_paint_start()
  62. {
  63. asm ("int $0x40"::"a"(12), "b"(1));
  64. }
  65.  
  66.  
  67. void kol_paint_end()
  68. {
  69. asm ("int $0x40"::"a"(12), "b"(2));
  70. }
  71.  
  72.  
  73. void kol_paint_pixel(unsigned x, unsigned y, unsigned c)
  74. {
  75. asm ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c));
  76. }
  77.  
  78.  
  79. void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c)
  80. {
  81. asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c));
  82. }
  83.  
  84.  
  85. void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c)
  86. {
  87. asm ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c));
  88. }
  89.  
  90.  
  91. void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c)
  92. {
  93. asm ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s));
  94. }
  95.  
  96.  
  97. void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d)
  98. {
  99. asm ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d));
  100. }
  101.  
  102.  
  103. void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette)
  104. {
  105. asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d));
  106. asm ("nop"::"a"(palette));
  107. asm ("movl %eax, %edi");
  108. asm ("xor %eax, %eax");
  109. asm ("movl %eax, %ebp");
  110. asm ("pushl $8");
  111. asm ("popl %esi");
  112. asm ("int $0x40"::"a"(65));
  113. }
  114.  
  115.  
  116. unsigned kol_key_get()
  117. {
  118. asm ("int $0x40"::"a"(2));
  119. }
  120.  
  121.  
  122. unsigned kol_key_control()
  123. {
  124. asm ("int $0x40"::"a"(66), "b"(3));
  125. }
  126.  
  127.  
  128. void kol_key_lang_set(unsigned lang)
  129. {
  130. asm ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang));
  131. }
  132.  
  133.  
  134. unsigned kol_key_lang_get()
  135. {
  136. asm ("int $0x40"::"a"(26), "b"(2), "c"(9));
  137. }
  138.  
  139.  
  140. void kol_key_mode_set(unsigned mode)
  141. {
  142. asm ("int $0x40"::"a"(66), "b"(1), "c"(mode));
  143. }
  144.  
  145.  
  146. unsigned kol_key_mode_get()
  147. {
  148. asm ("int $0x40"::"a"(66), "b"(2));
  149. }
  150.  
  151.  
  152. unsigned kol_btn_get()
  153. {
  154. asm ("int $0x40"::"a"(17));
  155. }
  156.  
  157.  
  158. void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c)
  159. {
  160. asm ("nop"::"b"(x*65536+w), "c"(y*65536+h), "d"(d));
  161. asm ("nop"::"a"(c));
  162. asm ("movl %eax, %esi");
  163. asm ("int $0x40"::"a"(8));
  164. }
  165.  
  166.  
  167. void kol_btn_type(unsigned t)
  168. {
  169. asm ("int $0x40"::"a"(48), "b"(1), "c"(t));
  170. }
  171.  
  172.  
  173. void kol_wnd_caption(char *s)
  174. {
  175. asm ("int $0x40"::"a"(71), "b"(1), "c"(s));
  176. }
  177.  
  178.  
  179. unsigned kol_mouse_pos()
  180. {
  181. asm ("int $0x40"::"a"(37), "b"(0));
  182. }
  183.  
  184.  
  185. unsigned kol_mouse_posw()
  186. {
  187. asm ("int $0x40"::"a"(37), "b"(1));
  188. }
  189.  
  190.  
  191. unsigned kol_mouse_btn()
  192. {
  193. asm ("int $0x40"::"a"(37), "b"(2));
  194. }
  195.  
  196.  
  197. void kol_board_putc(char c)
  198. {
  199. asm ("int $0x40"::"a"(63), "b"(1), "c"(c));
  200. }
  201.  
  202.  
  203. void kol_board_puts(char *s)
  204. {
  205. unsigned i;
  206. i = 0;
  207. while (*(s+i))
  208.         {
  209.         asm ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i)));
  210.         i++;
  211.         }
  212. }
  213.  
  214.  
  215. void kol_board_puti(int n)
  216. {
  217. char c;
  218. int i = 0;
  219. do
  220.         {
  221.         c = n % 10 + '0';
  222.         asm ("int $0x40"::"a"(63), "b"(1), "c"(c));
  223.         i++;
  224.         }
  225.         while ((n /= 10) > 0);
  226. }
  227.  
  228.  
  229. int kol_file_70(kol_struct70 *k)
  230. {
  231. asm ("int $0x40"::"a"(70), "b"(k));
  232. }
  233.  
  234.  
  235. kol_struct_import* kol_cofflib_load(char *name)
  236. {
  237. asm ("int $0x40"::"a"(68), "b"(19), "c"(name));
  238. }
  239.  
  240.  
  241. void* kol_cofflib_procload (kol_struct_import *imp, char *name)
  242. {
  243. int i;
  244. for (i=0;;i++)
  245.         if ( NULL == ((imp+i) -> name))
  246.                 break;
  247.         else
  248.                 if ( 0 == strcmp(name, (imp+i)->name) )
  249.                         return (imp+i)->data;
  250. return NULL;
  251. }
  252.  
  253.  
  254. unsigned kol_cofflib_procnum (kol_struct_import *imp)
  255. {
  256. unsigned i, n;
  257.  
  258. for (i=n=0;;i++)
  259.         if ( NULL == ((imp+i) -> name))
  260.                 break;
  261.         else
  262.                 n++;
  263.  
  264. return n;
  265. }
  266.  
  267.  
  268. void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n)
  269. {
  270. unsigned i;
  271. *name = 0;
  272.  
  273. for (i=0;;i++)
  274.         if ( NULL == ((imp+i) -> name))
  275.                 break;
  276.         else
  277.                 if ( i == n )
  278.                         {
  279.                         strcpy(name, ((imp+i)->name));
  280.                         break;
  281.                         }
  282.  
  283. }
  284.  
  285.  
  286. unsigned kol_system_cpufreq()
  287. {
  288. asm ("int $0x40"::"a"(18), "b"(5));
  289. }
  290.  
  291.  
  292. unsigned kol_system_mem()
  293. {
  294. asm ("int $0x40"::"a"(18), "b"(17));
  295. }
  296.  
  297.  
  298. unsigned kol_system_memfree()
  299. {
  300. asm ("int $0x40"::"a"(18), "b"(16));
  301. }
  302.  
  303.  
  304. unsigned kol_system_time_get()
  305. {
  306. asm ("int $0x40"::"a"(3));
  307. }
  308.  
  309.  
  310. unsigned kol_system_date_get()
  311. {
  312. asm ("int $0x40"::"a"(29));
  313. }
  314.  
  315.  
  316. unsigned kol_system_end(unsigned param)
  317. {
  318. asm ("int $0x40"::"a"(18), "b"(9), "c"(param));
  319. }
  320.  
  321.  
  322. void kol_path_file2dir(char *dir, char *fname)
  323. {
  324. unsigned i;
  325. strcpy (dir, fname);
  326. for ( i = strlen(dir);; --i)
  327.         if ( '/' == dir[i])
  328.                 {
  329.                 dir[i] = '\0';
  330.                 return;
  331.                 }
  332. }
  333.  
  334.  
  335. void kol_path_full(char *full, char *fname)
  336. {
  337. char temp[256];
  338.  
  339. switch (*fname)
  340. {
  341.  
  342. case '/':
  343.         strncpy(temp, fname+1, 2);
  344.         temp[2]=0;
  345.         if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) )
  346.                 strcpy (full, fname);
  347.         break;
  348.  
  349. case '.':
  350.         break;
  351.  
  352. default:
  353.         break;
  354.  
  355. };
  356.  
  357. }
  358.  
  359.  
  360.  
  361. void kol_screen_wait_rr()
  362. {
  363. asm ("int $0x40"::"a"(18), "b"(14));
  364. }
  365.  
  366.  
  367.  
  368. void kol_screen_get_size(unsigned *w, unsigned *h)
  369. {
  370. unsigned size;
  371. asm ("int $0x40":"=a"(size):"a"(14));
  372. *w = size / 65536;
  373. *h = size % 65536;
  374. }
  375.  
  376.  
  377.  
  378. unsigned kol_skin_height()
  379. {
  380. asm ("int $0x40"::"a"(48), "b"(4));
  381. }
  382.  
  383.  
  384. unsigned kol_thread_start(unsigned start, unsigned stack)
  385. {
  386. asm ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack));
  387. }
  388.  
  389.  
  390. unsigned kol_time_tick()
  391. {
  392. asm ("int $0x40"::"a"(26), "b"(9));
  393. }
  394.  
  395.  
  396. unsigned kol_sound_speaker(char data[])
  397. {
  398. asm ("movl %0, %%esi"::"a"(data));
  399. asm ("int $0x40"::"a"(55), "b"(55));
  400. }
  401.  
  402.  
  403. unsigned kol_process_info(unsigned slot, char buf1k[])
  404. {
  405. asm ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot));
  406. }
  407.  
  408.  
  409. int kol_process_kill_pid(unsigned process)
  410. {
  411. asm ("int $0x40"::"a"(18), "b"(18), "c"(process));
  412. }
  413.  
  414. void kol_get_kernel_ver(char buff16b[])
  415. {
  416. asm ("int $0x40"::"a"(18), "b"(13), "c"(buff16b));
  417. }