Subversion Repositories Kolibri OS

Rev

Rev 882 | 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 BlitAlpha dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, alpha
  130. {
  131.            pushd alpha
  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_BlitAlpha]
  141.            add esp, 9*4
  142. }
  143.  
  144. macro TransparentBlit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, key
  145. {
  146.            pushd key
  147.            pushd h
  148.            pushd w
  149.            pushd srcy
  150.            pushd srcx
  151.            pushd srcpix
  152.            pushd dsty
  153.            pushd dstx
  154.            pushd dstpix
  155.            call [imp_TransparentBlit]
  156.            add esp, 9*4
  157. }
  158.  
  159.  
  160. macro fix_cwd  path
  161. {
  162.           pushd path
  163.  
  164.           push '/'
  165.           push path
  166.           call _strrchr
  167.  
  168.           mov byte [eax], 0
  169.  
  170.           mov eax, 30
  171.           mov ebx, 1
  172.           mov ecx, [esp+8]
  173.           int 0x40
  174.  
  175.           add esp, 12
  176. }
  177.  
  178. szPxlib              db  '/rd/1/lib/pixlib.obj',0
  179.  
  180. szStart              db  'START',0
  181. szVersion            db  'version',0
  182.  
  183. szCreatePixmap       db  'CreatePixmap',0
  184. szDestroyPixmap      db  'DestroyPixmap',0
  185. szLockPixmap         db  'LockPixmap',0
  186. szUnlockPixmap       db  'UnlockPixmap',0
  187. szGetPixmapPitch     db  'GetPixmapPitch',0
  188.  
  189. szCreateHatch        db  'CreateHatch',0
  190. szCreateMonoBrush    db  'CreateMonoBrush',0
  191. szDestroyBrush       db  'DestroyBrush',0
  192.  
  193. szClearPixmap        db  'ClearPixmap',0
  194. szLine               db  'Line',0
  195. szDrawRect           db  'DrawRect',0
  196. szFillRect           db  'FillRect',0
  197. szBlit               db  'Blit',0
  198. szTransparentBlit    db  'TransparentBlit',0
  199. szBlitAlpha          db  'BlitAlpha',0
  200.  
  201. align 4
  202.  
  203. px_import:
  204.  
  205. imp_start            dd  szStart
  206. imp_ver              dd  szVersion
  207.  
  208. imp_CreatePixmap     dd  szCreatePixmap
  209. imp_DestroyPixmap    dd  szDestroyPixmap
  210. imp_LockPixmap       dd  szLockPixmap
  211. imp_UnlockPixmap     dd  szUnlockPixmap
  212. imp_GetPixmapPitch   dd  szGetPixmapPitch
  213.  
  214. imp_CreateHatch      dd  szCreateHatch
  215. imp_CreateMonoBrush  dd  szCreateMonoBrush
  216. imp_DestroyBrush     dd  szDestroyBrush
  217.  
  218. imp_ClearPixmap      dd  szClearPixmap
  219. imp_Line             dd  szLine
  220. imp_DrawRect         dd  szDrawRect
  221. imp_FillRect         dd  szFillRect
  222. imp_Blit             dd  szBlit
  223. imp_TransparentBlit  dd  szTransparentBlit
  224. imp_BlitAlpha        dd  szBlitAlpha
  225.  
  226.                      dd  0
  227.  
  228.  
  229. ;szBlockClip          db  'BlockClip',0
  230. ;szLineClip           db  'LineClip',0
  231. ;imp_BlockClip        dd  szBlockClip
  232. ;imp_LineClip         dd  szLineClip
  233.  
  234.  
  235. align 4
  236.  
  237. load_pxlib:
  238.            mov  eax, 68
  239.            mov  ebx, 19
  240.            mov  ecx, szPxlib
  241.            int  0x40
  242.            test eax, eax
  243.            jz   .fail
  244.  
  245.            mov  edx, eax
  246.            mov  esi, px_import
  247. .import_loop:
  248.            lodsd
  249.            test eax, eax
  250.            jz   .import_done
  251.            push edx
  252. .import_find:
  253.            mov ebx, [edx]
  254.            test ebx, ebx
  255.            jz .fail         ;import_not_found
  256.  
  257.            push eax
  258. @@:
  259.            mov cl, [eax]
  260.            cmp cl, [ebx]
  261.            jnz .import_find_next
  262.  
  263.            test cl, cl
  264.            jz .import_found
  265.  
  266.            inc eax
  267.            inc ebx
  268.            jmp @b
  269. .import_find_next:
  270.            pop eax
  271.            add edx, 8
  272.            jmp .import_find
  273. .import_found:
  274.            pop eax
  275.            mov eax, [edx+4]
  276.            mov [esi-4], eax
  277.            pop edx
  278.            jmp .import_loop
  279. .import_done:
  280.  
  281.            cmp word [imp_ver], REQ_DLL_VER
  282.            jb .fail
  283.            cmp word [imp_ver+2], REQ_DLL_VER
  284.            ja .fail
  285.  
  286.            push DLL_ENTRY
  287.            call [imp_start]
  288.            test eax, eax
  289.            jz .fail
  290.  
  291.            ret
  292. .fail:
  293.            xor eax, eax
  294.            ret
  295.  
  296. align 4
  297. _strrchr:
  298.         push    ebp
  299.         mov     ebp, esp
  300.         push    edi
  301.         mov     edi, [8+ebp]
  302.         mov     ecx, -1
  303.         xor     al, al
  304.         cld
  305.         repne
  306.         scasb
  307.         not     ecx
  308.         dec     edi
  309.         mov     al, [12+ebp]
  310.         std
  311.         repne
  312.         scasb
  313.         cld
  314.         jne     .failure
  315.         lea     eax, [edi+1]
  316.         pop     edi
  317.         pop     ebp
  318.         ret
  319. .failure:
  320.         xor     eax, eax
  321.         pop     edi
  322.         pop     ebp
  323.         ret
  324.