Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. txt_zv db '*',0
  3. txt_sp db ' ',0
  4. txt_buf db '1234',0
  5.         rd 1
  6.  
  7. buf_param rb 80
  8.  
  9. macro cStr dest,txt
  10. {
  11. local .end_t
  12. local .m_txt
  13. jmp .end_t
  14. align 4
  15.         .m_txt db txt,0
  16. align 4
  17. .end_t:
  18. if dest eq
  19.         mov eax,.m_txt
  20. else
  21.         mov dest,.m_txt
  22. end if
  23. }
  24.  
  25. align 4
  26. proc f_png_warning, h:dword, m_txt:dword
  27.         stdcall hex_in_str,txt_buf,[h],5
  28.         mov byte[txt_buf+5],0
  29.         stdcall dbg_print,txt_buf,[m_txt]
  30.         ret
  31. endp
  32.  
  33. align 4
  34. proc f_png_error, h:dword, m_txt:dword
  35.         stdcall hex_in_str,txt_buf,[h],5
  36.         mov byte[txt_buf+5],0
  37.         stdcall dbg_print,txt_buf,[m_txt]
  38.         ret
  39. endp
  40.  
  41. align 4
  42. proc f_png_debug, n:dword, m_txt:dword
  43.         stdcall dbg_print,txt_sp,[m_txt]
  44.         ret
  45. endp
  46.  
  47. align 4
  48. proc dbg_print, fun:dword, mes:dword
  49. pushad
  50.         mov eax,SF_BOARD
  51.         mov ebx,SSF_DEBUG_WRITE
  52.  
  53.         mov esi,[fun]
  54.         cmp esi,0
  55.         je .end0
  56.         @@:
  57.                 mov cl,byte[esi]
  58.                 int 0x40
  59.                 inc esi
  60.                 cmp byte[esi],0
  61.                 jne @b
  62.         mov cl,':'
  63.         int 0x40
  64.         mov cl,' '
  65.         int 0x40
  66.         .end0:
  67.         mov esi,[mes]
  68.         cmp esi,0
  69.         je .end_f
  70.         @@:
  71.                 mov cl,byte[esi]
  72.                 cmp cl,0
  73.                 je .end_f
  74.                 int 0x40
  75.                 inc esi
  76.                 jmp @b
  77.         .end_f:
  78. popad
  79.         ret
  80. endp
  81.  
  82. ;input:
  83. ; zif - 1...8
  84. align 4
  85. proc hex_in_str, buf:dword,val:dword,zif:dword
  86. pushad
  87.         mov edi,dword[buf]
  88.         mov ecx,dword[zif]
  89.         add edi,ecx
  90.         dec edi
  91.         mov ebx,dword[val]
  92.  
  93.         .cycle:
  94.                 mov al,bl
  95.                 and al,0xf
  96.                 cmp al,10
  97.                 jl @f
  98.                         add al,'a'-'0'-10
  99.                 @@:
  100.                 add al,'0'
  101.                 mov byte[edi],al
  102.                 dec edi
  103.                 shr ebx,4
  104.         loop .cycle
  105. popad
  106.         ret
  107. endp
  108.  
  109. ;---
  110.  
  111. macro png_warning h,txt
  112. {
  113. if txt eqtype ''
  114.         local .end_t
  115.         local .m_txt
  116.         jmp .end_t
  117.         .m_txt db txt,13,10,0
  118.         .end_t:
  119.         stdcall f_png_warning,h,.m_txt
  120. else
  121.         stdcall f_png_warning,h,txt
  122.         push eax ebx ecx
  123.         mcall SF_BOARD,SSF_DEBUG_WRITE,13
  124.         mcall ,,10
  125.         pop ecx ebx eax
  126. end if
  127. }
  128.  
  129. macro png_app_warning h,txt
  130. {
  131.         png_warning h,<txt>
  132. }
  133.  
  134. macro png_error h,txt
  135. {
  136. if txt eqtype ''
  137.         local .end_t
  138.         local .m_txt
  139.         jmp .end_t
  140.         .m_txt db txt,13,10,0
  141.         .end_t:
  142.         stdcall f_png_error,h,.m_txt
  143. else
  144.         stdcall f_png_error,h,txt
  145.         push eax ebx ecx
  146.         mcall SF_BOARD,SSF_DEBUG_WRITE,13
  147.         mcall ,,10
  148.         pop ecx ebx eax
  149. end if
  150. }
  151.  
  152. macro png_debug n,txt
  153. {
  154. if DEBUG eq 1
  155. local .end_t
  156. local .m_txt
  157. jmp .end_t
  158.         .m_txt db txt,13,10,0
  159. align 4
  160. .end_t:
  161. stdcall f_png_debug,n,.m_txt
  162. end if
  163. }
  164.  
  165. macro png_debug1 n,fmt,p1
  166. {
  167. if DEBUG eq 1
  168. local .end_t
  169.  
  170. if p1 eqtype ''
  171. local .m_txt1
  172. local .m_txt2
  173. jmp .end_t
  174.         .m_txt1 db fmt,0
  175.         .m_txt2 db p1,13,10,0
  176. align 4
  177. .end_t:
  178. stdcall dbg_print,.m_txt1,.m_txt2
  179.  
  180. else
  181. local .m_fmt
  182. jmp .end_t
  183.         .m_fmt db fmt,13,10,0
  184. align 4
  185. .end_t:
  186.         stdcall str_format_dbg, buf_param,.m_fmt,p1
  187.        
  188. end if
  189. end if
  190. }
  191.  
  192. ;output:
  193. ; eax = strlen
  194. align 4
  195. proc strlen, str1:dword
  196.         mov eax,[str1]
  197.         @@:
  198.                 cmp byte[eax],0
  199.                 je @f
  200.                 inc eax
  201.                 jmp @b
  202.         @@:
  203.         sub eax,[str1]
  204.         ret
  205. endp
  206.  
  207. align 4
  208. proc str_format_dbg, buf:dword, fmt:dword, p1:dword
  209. pushad
  210.         mov esi,[fmt]
  211.         mov edi,[buf]
  212.         mov ecx,80-1
  213.         .cycle0:
  214.                 lodsb
  215.                 cmp al,'%'
  216.                 jne .no_param
  217.                         lodsb
  218.                         dec ecx
  219.                         cmp al,0
  220.                         je .cycle0end
  221.                         cmp al,'d'
  222.                         je @f
  223.                         cmp al,'u'
  224.                         je @f
  225.                         cmp al,'l'
  226.                         je .end1
  227.                                 jmp .end0
  228.                         .end1: ;%lu %lx
  229.                                 lodsb
  230.                                 dec ecx
  231.                                 cmp al,'u'
  232.                                 jne .end0
  233.                         @@:
  234.                                 mov eax,[p1]
  235.                                 stdcall convert_int_to_str,ecx
  236.                                 xor al,al
  237.                                 repne scasb
  238.                                 dec edi
  239.                         .end0:
  240.                         loop .cycle0
  241.                 .no_param:
  242.                 stosb
  243.                 cmp al,0
  244.                 je .cycle0end
  245.                 loop .cycle0
  246.         .cycle0end:
  247.         xor al,al
  248.         stosb
  249.         stdcall dbg_print,txt_sp,[buf]
  250. popad
  251.         ret
  252. endp
  253.  
  254. ;input:
  255. ; eax - число
  256. ; edi - буфер для строки
  257. ; len - длинна буфера
  258. ;output:
  259. align 4
  260. proc convert_int_to_str, len:dword
  261. pushad
  262.         mov esi,[len]
  263.         add esi,edi
  264.         dec esi
  265.         call .str
  266. popad
  267.         ret
  268. endp
  269.  
  270. align 4
  271. .str:
  272.         mov ecx,0x0a
  273.         cmp eax,ecx
  274.         jb @f
  275.                 xor edx,edx
  276.                 div ecx
  277.                 push edx
  278.                 call .str
  279.                 pop eax
  280.         @@:
  281.         cmp edi,esi
  282.         jge @f
  283.                 or al,0x30
  284.                 stosb
  285.                 mov byte[edi],0
  286.         @@:
  287.         ret
  288.  
  289. macro std_png_image_error n,txt
  290. {
  291. local .end_t
  292. local .m_txt
  293. jmp .end_t
  294.         .m_txt db txt,13,10,0
  295. align 4
  296. .end_t:
  297. stdcall png_image_error,n,.m_txt
  298. }
  299.  
  300.