Subversion Repositories Kolibri OS

Rev

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