Subversion Repositories Kolibri OS

Rev

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

  1. #include <SDL.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define asm_inline __asm__ __volatile__
  6.  
  7. #pragma pack(push,1)
  8. typedef union{
  9.     unsigned val;
  10.     struct{
  11.         short  h;
  12.         short  w;
  13.     };
  14. }ksys_screen_t;
  15. #pragma pack(pop)
  16.  
  17.  
  18. static inline
  19. void _ksys_change_window(int new_x, int new_y, int new_w, int new_h)
  20. {
  21.     asm_inline(
  22.         "int $0x40"
  23.         ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h)
  24.     );
  25. }
  26.  
  27. static inline
  28. ksys_screen_t _ksys_screen_size()
  29. {
  30.         ksys_screen_t size;
  31.     asm_inline(
  32.         "int $0x40"
  33.         :"=a"(size)
  34.         :"a"(14)
  35.         :"memory"
  36.     );
  37.     return size;
  38. }
  39.  
  40. void uSDL_SetWinCenter(unsigned w, unsigned h){
  41.     ksys_screen_t screen_size= _ksys_screen_size();
  42.     int new_x = screen_size.w/2-w/2;
  43.     int new_y = screen_size.h/2-h/2;
  44.     _ksys_change_window(new_x, new_y, -1, -1);
  45. }
  46.  
  47.  
  48. void uSDL_Delay(unsigned ms){
  49.     unsigned start = SDL_GetTicks();
  50.     do{
  51.        asm_inline("int $0x40" :: "a"(5),"b"(1));
  52.     }while (SDL_GetTicks()-start < ms);
  53. }