Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. char tmp_cursor[4096];
  3.  
  4. cursor_t *create_cursor(u32 pid, void *src, u32 flags)
  5. {
  6.   void *img;
  7.  
  8.   cursor_t *cursor = (cursor_t*)CreateObject(pid, 32);
  9.  
  10.   if(cursor==NULL)
  11.     return 0;
  12.   dbgprintf("create object at %x\n", cursor);
  13.  
  14.   cursor->magic = 0x53525543;
  15.   cursor->destroy = __destroy_cursor;
  16.  
  17.   img = rhd_mem_alloc(&rhd,RHD_MEM_FB,64*64*4);
  18.   if(img==NULL)
  19.     goto cleanup;
  20.  
  21.   dbgprintf("alloc video memory at %x size %x\n",img,64*64*4);
  22.   dbgprintf("offset %x\n", img-rhd.FbBase);
  23.   cursor->base=img;
  24.  
  25.   if( (u16)flags==LOAD_INDIRECT){
  26.     cursor->hot_x = (u8)(flags>>24);
  27.     cursor->hot_y = (u8)(flags>>16);
  28.     asm __volatile__
  29.     (
  30.       "cld \n\t"
  31.       "rep stosl"
  32.       :
  33.       :"a"(0),"c"(64*64),"D"(img)
  34.     );
  35.     asm __volatile__
  36.     (
  37.   "1: "
  38.       "movl $32, %%ecx \n\t"
  39.       "rep stosl \n\t"
  40.       "addl $128, %%edi \n\t"
  41.       "decl %%ebx \n\t"
  42.       "jnz 1b"
  43.       :
  44.       :"b"(32),"S"(src),"D"(img)
  45.     );
  46.   }
  47.   else {
  48.     cursor->hot_x = *(u16*)((char*)src+10);
  49.     cursor->hot_y = *(u16*)((char*)src+12);
  50.     copy_cursor(img, src);
  51.     dbgprintf("cursor loaded\n");
  52.   }
  53.   return cursor;
  54. cleanup:
  55.   DestroyObject(cursor);
  56.   return NULL;
  57. };
  58.  
  59. void destroy_cursor(cursor_t *cursor)
  60. {
  61.   if(cursor->base)
  62.     rhd_mem_free(&rhd,RHD_MEM_FB,cursor->base);
  63.   DestroyObject(cursor);
  64. }
  65.  
  66. void __stdcall r500_SelectCursor(cursor_t *cursor)
  67. {
  68.   CARD32 base;
  69.  
  70.   base = (CARD32)cursor->base - rhd.FbBase;
  71.   asm __volatile__
  72.   (
  73.     "cli"
  74.   );
  75.   OUTREG (D1CUR_SURFACE_ADDRESS, rhd.FbIntAddress+base);
  76.   OUTREG (D1CUR_HOT_SPOT, (cursor->hot_x<<16)|(cursor->hot_y&0xFFFF));
  77.   asm __volatile__
  78.   (
  79.     "sti"
  80.   );
  81. }
  82.  
  83. void __stdcall r500_SetCursor(cursor_t *cursor, int x, int y)
  84. {
  85.    CARD32 tmp = (x<<16)|(y & 0xFFFF) ;
  86.  
  87.    asm __volatile__
  88.    (
  89.     "pushfl \n\t"
  90.     "cli"
  91.    );
  92.  
  93.    OUTREG(D1CUR_POSITION, tmp);
  94.    OUTREG(D1CUR_CONTROL, 0x301);
  95.    asm __volatile__
  96.    (
  97.     "popfl"
  98.    );
  99. }
  100.  
  101. void __stdcall r500_CursorRestore(int x, int y)
  102. {};
  103.  
  104.