Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #ifndef SDL_kos
  2. #define SDL_kos
  3.  
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7.  
  8. typedef unsigned char       __u8;
  9. typedef unsigned short      __u16;
  10. typedef unsigned long       __u32;
  11.  
  12. struct process_table_entry
  13. {
  14.  __u32 cpu_usage;
  15.  __u16 pos_in_windowing_stack;
  16.  __u16 win_stack_val_at_ecx;
  17.  __u16 reserved1;
  18.  char name[12];
  19.  __u32 memstart;
  20.  __u32 memused;
  21.  __u32 pid;
  22.  __u32 winx_start,winy_start;
  23.  __u32 winx_size,winy_size;
  24.  __u16 thread_state;
  25.  __u16 reserved2;
  26.  __u32 client_left,client_top,client_width,client_height;
  27.  __u8 window_state;
  28.  __u8 reserved3[1024-71];
  29. };
  30.  
  31. static inline
  32. void __kos__define_window(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,
  33.      __u32 body_color,__u32 grab_color,__u32 frame_color)
  34. {
  35.  __u32 a,b;
  36.  a=(x1<<16)|xsize;
  37.  b=(y1<<16)|ysize;
  38.  __asm__ __volatile__("int $0x40"::"a"(0),"b"(a),"c"(b),"d"(body_color),"S"(grab_color),
  39.                       "D"(frame_color));
  40. }
  41.  
  42. static inline void __kos__window_redraw(int status)
  43. {
  44.  __asm__ __volatile__("int $0x40"::"a"(12),"b"(status));
  45. }
  46.  
  47. static inline
  48. void __kos__draw_bitmap(void *bitmap, int x, int y, int w, int h)
  49. {
  50.     __asm__ __volatile__(
  51.     "int $0x40"
  52.     ::"a"(7), "b"(bitmap),
  53.       "c"((w << 16) | h),
  54.       "d"((x << 16) | y));
  55. }
  56.  
  57. static inline
  58. int __kos__getkey(void)
  59. {
  60.  __u16 __ret;
  61.  __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(2));
  62.  if(!(__ret & 0xFF)) return (__ret>>8)&0xFF; else return 0;
  63. }
  64.  
  65. static inline
  66. int __kos__check_for_event(void)
  67. {
  68.  __u32 __ret;
  69.  __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(11));
  70.  return __ret;
  71. }
  72.  
  73. static inline
  74. int __kos__set_events_mask(__u32 mask)
  75. {
  76.     register __u32 val;
  77.     asm volatile ("int $0x40":"=a"(val):"a"(40), "b"(mask));
  78.     return val;
  79. }
  80.  
  81. static inline
  82. void __kos__delay100(int time)
  83. {
  84.     __asm__ __volatile__(
  85.     "int $0x40"
  86.     ::"a"(5), "b"(time)
  87.     :"memory");
  88. };
  89.  
  90. static inline
  91. int __kos__get_button_id()
  92. {
  93.     __u32 val;
  94.     __asm__ __volatile__(
  95.         "int $0x40"
  96.         :"=a"(val)
  97.         :"a"(17)
  98.     );
  99.     return val>>8;
  100. }
  101.  
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105.  
  106. #endif