Subversion Repositories Kolibri OS

Rev

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

  1. /*-------------------------------------------------------------------------------
  2. C-- base library for Kolibri, Nable's variant.
  3. -------------------------------------------------------------------------------*/
  4.  
  5. inline fastcall dword WaitEventTimeout(dword EBX){
  6.  EAX = 23;              // wait here for event
  7.  $int 0x40
  8. }
  9.  
  10. //-------------------------------------------------------------------------------
  11. struct IMAGE_INFO{
  12.    word  Left,Top,Width,Height; //+0, +2, +4, +6
  13.    dword Delay,Displacement,StartOfImage; //+8, +12, +16
  14.    dword pPalette,BitsPerPixel; //+20, +24
  15. };
  16.  
  17. IMAGE_INFO      CurrentImage;
  18.  
  19. //-------------------------------------------------------------------------------
  20. fastcall int GetNthImageInfo(dword ESI, EDI, ECX)
  21. //esi - pointer to structure with multiple images
  22. //edi - pointer to structure of type IMG_INFO
  23. //ecx - CurrentFrameNum
  24. //returns 0 if error
  25. int pCurrentImage;
  26. {
  27.    pCurrentImage = EDI;
  28.    EAX = 0;
  29.    EBX = ESI;
  30.    $jecxz _END_LOOP
  31. _1:
  32.    $TEST ESI,ESI
  33.    $JE  __EXIT
  34.  
  35.    //MOV ESI,[ESI] - c-- refused to compile it
  36.    $DB 8Bh
  37.    $DB 36h
  38.  
  39.    $ADD ESI,EBX
  40.    $loop _1
  41. _END_LOOP:
  42.    $LODSD
  43.    //left and top
  44.    $MOVSD
  45.    //width and height
  46.    $MOVSD
  47.    //delay
  48.    $MOVSD
  49.    //displacement
  50.    $MOVSD
  51.  
  52.    EDI = pCurrentImage;
  53.  
  54.    $LODSD
  55.    $TEST EAX,EAX
  56.    $JS _NO_PALETTE
  57.    $ADD EAX,EBX
  58.  
  59.    //Stay calm, this pervertion is only because of uncomplete
  60.    //pointers' support in C--
  61.  
  62.    //CurrentImage.pPalette=ESI;
  63.    DSDWORD[EDI+20] = ESI;
  64.  
  65.    //CurrentImage.StartOfImage=EAX;
  66.    DSDWORD[EDI+16] = EAX;
  67.  
  68.    //CurrentImage.BitsPerPixel=8;
  69.    DSDWORD[EDI+24] = 8;
  70.    GOTO __EXIT;
  71.  
  72. _NO_PALETTE:
  73.    $NEG EAX
  74.    //CurrentImage.BitsPerPixel=EAX;
  75.    DSDWORD[EDI+24] = EAX;
  76.  
  77.    //CurrentImage.pPalette=0;
  78.    DSDWORD[EDI+20] = 0;
  79.  
  80.    //CurrentImage.StartOfImage=ESI;
  81.    DSDWORD[EDI+16] = ESI;
  82. __EXIT:
  83. }
  84.  
  85. //As a parameter you should send PID of needed slot
  86. //return value will be 0 if not found
  87. inline fastcall int PIDtoSlot(dword EDX)
  88. {
  89.         proc_info _p_info;
  90.         EBX=#_p_info; //pointer to the structure
  91.         ECX=2;//slot 1 is system
  92.         WHILE(ECX<256){
  93.                 EAX=9;
  94.                 $INT 0x40
  95.                 IF(_p_info.ID == EDX) return ECX;
  96.                 ECX++;
  97.         }
  98.         return 0;
  99. }
  100.  
  101.  
  102. void fastcall DrawImage(dword EBX, EDX)
  103. {
  104.    $PUSHAD
  105.    EAX = 65;
  106.    EBP = 0;
  107.    EDI = DSDWORD[EBX+20];
  108.    ESI = DSDWORD[EBX+24];
  109.    $ROR EDX,16
  110.    EDX += DSDWORD[EBX];
  111.    $ROR EDX,16
  112.    ECX = DSDWORD[EBX+4];
  113.    $ROR ECX,16
  114.    EBX = DSDWORD[EBX+16];
  115.    $INT 0x40
  116.    $POPAD
  117. }
  118.  
  119.  
  120.