Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. REQ_DLL_VER      =  1
  3. DLL_ENTRY        =  1
  4.  
  5. HS_HORIZONTAL    =  0
  6. HS_VERTICAL      =  1
  7. HS_FDIAGONAL     =  2
  8. HS_BDIAGONAL     =  3
  9. HS_CROSS         =  4
  10. HS_DIAGCROSS     =  5
  11.  
  12. SCR_PIXMAP       = -1
  13.  
  14. PX_MEM_SYSTEM    =  0
  15. PX_MEM_LOCAL     =  1
  16. PX_MEM_GART      =  2
  17.  
  18. PX_MEM_MASK      =  3
  19.  
  20. ARGB32           = ((32 shl 24) or (2 shl 16) or 0x8888)
  21.  
  22. macro CreateHatch hatch, bkcolor, fcolor
  23. {
  24.            pushd fcolor
  25.            pushd bkcolor
  26.            pushd hatch
  27.            call [imp_CreateHatch]
  28.            add esp, 3*4
  29. }
  30.  
  31. macro DestroyBrush brush
  32. {
  33.            pushd brush
  34.            call [imp_DestroyBrush]
  35.            add esp, 4
  36. }
  37.  
  38. macro CreatePixmap width, height, format, flags
  39. {
  40.            pushd flags
  41.            pushd format
  42.            pushd height
  43.            pushd width
  44.            call [imp_CreatePixmap]
  45.            add esp, 4*4
  46. }
  47.  
  48. macro DestroyPixmap pixmap
  49. {
  50.           pushd pixmap
  51.           call [imp_DestroyPixmap]
  52.           add esp, 4
  53. };
  54.  
  55. macro LockPixmap pixmap
  56. {
  57.            pushd pixmap
  58.            call [imp_LockPixmap]
  59.            add esp, 4
  60. }
  61.  
  62. macro UnlockPixmap pixmap
  63. {
  64.            pushd pixmap
  65.            call [imp_UnlockPixmap]
  66.            add esp, 4
  67. }
  68.  
  69. macro ClearPixmap pixmap, color
  70. {
  71.            pushd color
  72.            pushd pixmap
  73.            call [imp_ClearPixmap]
  74.            add esp, 2*4
  75. }
  76.  
  77. macro Line pixmap, x0,y0,x1,y1,color
  78. {
  79.            pushd color
  80.            pushd y1
  81.            pushd x1
  82.            pushd y0
  83.            pushd x0
  84.            pushd pixmap
  85.            call [imp_Line]
  86.            add esp, 6*4
  87. };
  88.  
  89. macro DrawRect pixmap,x,y,w,h,color,border
  90. {
  91.            pushd border
  92.            pushd color
  93.            pushd h
  94.            pushd w
  95.            pushd y
  96.            pushd x
  97.            pushd pixmap
  98.            call [imp_DrawRect]
  99.            add esp, 7*4
  100. }
  101.  
  102. macro FillRect pixmap,x,y,w,h,brush,border
  103. {
  104.            pushd border
  105.            pushd brush
  106.            pushd h
  107.            pushd w
  108.            pushd y
  109.            pushd x
  110.            pushd pixmap
  111.            call [imp_FillRect]
  112.            add esp, 7*4
  113. }
  114.  
  115. macro Blit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h
  116. {
  117.            pushd h
  118.            pushd w
  119.            pushd srcy
  120.            pushd srcx
  121.            pushd srcpix
  122.            pushd dsty
  123.            pushd dstx
  124.            pushd dstpix
  125.            call [imp_Blit]
  126.            add esp, 8*4
  127. }
  128.  
  129. macro TransparentBlit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, key
  130. {
  131.            pushd key
  132.            pushd h
  133.            pushd w
  134.            pushd srcy
  135.            pushd srcx
  136.            pushd srcpix
  137.            pushd dsty
  138.            pushd dstx
  139.            pushd dstpix
  140.            call [imp_TransparentBlit]
  141.            add esp, 9*4
  142. }
  143.  
  144. szPxlib              db  '/rd/1/lib/pixlib.obj',0
  145.  
  146. szStart              db  'START',0
  147. szVersion            db  'version',0
  148.  
  149. szCreatePixmap       db  'CreatePixmap',0
  150. szDestroyPixmap      db  'DestroyPixmap',0
  151. szLockPixmap         db  'LockPixmap',0
  152. szUnlockPixmap       db  'UnlockPixmap',0
  153. szGetPixmapPitch     db  'GetPixmapPitch',0
  154.  
  155. szCreateHatch        db  'CreateHatch',0
  156. szCreateMonoBrush    db  'CreateMonoBrush',0
  157. szDestroyBrush       db  'DestroyBrush',0
  158.  
  159. szClearPixmap        db  'ClearPixmap',0
  160. szLine               db  'Line',0
  161. szDrawRect           db  'DrawRect',0
  162. szFillRect           db  'FillRect',0
  163. szBlit               db  'Blit',0
  164. szTransparentBlit    db  'TransparentBlit',0
  165.  
  166. align 4
  167.  
  168. px_import:
  169.  
  170. imp_start            dd  szStart
  171. imp_ver              dd  szVersion
  172.  
  173. imp_CreatePixmap     dd  szCreatePixmap
  174. imp_DestroyPixmap    dd  szDestroyPixmap
  175. imp_LockPixmap       dd  szLockPixmap
  176. imp_UnlockPixmap     dd  szUnlockPixmap
  177. imp_GetPixmapPitch   dd  szGetPixmapPitch
  178.  
  179. imp_CreateHatch      dd  szCreateHatch
  180. imp_CreateMonoBrush  dd  szCreateMonoBrush
  181. imp_DestroyBrush     dd  szDestroyBrush
  182.  
  183. imp_ClearPixmap      dd  szClearPixmap
  184. imp_Line             dd  szLine
  185. imp_DrawRect         dd  szDrawRect
  186. imp_FillRect         dd  szFillRect
  187. imp_Blit             dd  szBlit
  188. imp_TransparentBlit  dd  szTransparentBlit
  189.  
  190.                      dd  0
  191.  
  192.  
  193. ;szBlockClip          db  'BlockClip',0
  194. ;szLineClip           db  'LineClip',0
  195. ;imp_BlockClip        dd  szBlockClip
  196. ;imp_LineClip         dd  szLineClip
  197.  
  198.  
  199. align 4
  200.  
  201. load_pxlib:
  202.            mov  eax, 68
  203.            mov  ebx, 19
  204.            mov  ecx, szPxlib
  205.            int  0x40
  206.            test eax, eax
  207.            jz   .fail
  208.  
  209.            mov  edx, eax
  210.            mov  esi, px_import
  211. .import_loop:
  212.            lodsd
  213.            test eax, eax
  214.            jz   .import_done
  215.            push edx
  216. .import_find:
  217.            mov ebx, [edx]
  218.            test ebx, ebx
  219.            jz .fail         ;import_not_found
  220.  
  221.            push eax
  222. @@:
  223.            mov cl, [eax]
  224.            cmp cl, [ebx]
  225.            jnz .import_find_next
  226.  
  227.            test cl, cl
  228.            jz .import_found
  229.  
  230.            inc eax
  231.            inc ebx
  232.            jmp @b
  233. .import_find_next:
  234.            pop eax
  235.            add edx, 8
  236.            jmp .import_find
  237. .import_found:
  238.            pop eax
  239.            mov eax, [edx+4]
  240.            mov [esi-4], eax
  241.            pop edx
  242.            jmp .import_loop
  243. .import_done:
  244.  
  245.            cmp word [imp_ver], REQ_DLL_VER
  246.            jb .fail
  247.            cmp word [imp_ver+2], REQ_DLL_VER
  248.            ja .fail
  249.  
  250.            push DLL_ENTRY
  251.            call [imp_start]
  252.            test eax, eax
  253.            jz .fail
  254.  
  255.            ret
  256. .fail:
  257.            xor eax, eax
  258.            ret
  259.  
  260.  
  261.