Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. ; pngwio.asm - functions for data output
  3.  
  4. ; Last changed in libpng 1.6.24 [August 4, 2016]
  5. ; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
  6. ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  7. ; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  8.  
  9. ; This code is released under the libpng license.
  10. ; For conditions of distribution and use, see the disclaimer
  11. ; and license in png.inc
  12.  
  13. ; This file provides a location for all output.  Users who need
  14. ; special handling are expected to write functions that have the same
  15. ; arguments as these and perform similar functions, but that possibly
  16. ; use different output methods.  Note that you shouldn't change these
  17. ; functions, but rather write replacement functions and then change
  18. ; them at run time with png_set_write_fn(...).
  19.  
  20.  
  21. ; Write the data to whatever output you are using.  The default routine
  22. ; writes to a file pointer.  Note that this routine sometimes gets called
  23. ; with very small lengths, so you should implement some kind of simple
  24. ; buffering if you are using unbuffered writes.  This should never be asked
  25. ; to write more than 64K on a 16-bit machine.
  26.  
  27. ;void (png_structrp png_ptr, bytep data, png_size_t length)
  28. align 4
  29. proc png_write_data uses edi, png_ptr:dword, p2data:dword, length:dword
  30.         ; NOTE: write_data_fn must not change the buffer!
  31.         mov edi,[png_ptr]
  32.         cmp dword[edi+png_struct.write_data_fn],0
  33.         je @f ;if (..!=0)
  34.                 stdcall dword[edi+png_struct.write_data_fn], edi, [p2data], [length]
  35.                 jmp .end_f
  36.         @@: ;else
  37.                 png_error edi, 'Call to NULL write function'
  38.         .end_f:
  39.         ret
  40. endp
  41.  
  42. ; This is the function that does the actual writing of data.  If you are
  43. ; not writing to a standard C stream, you should create a replacement
  44. ; write_data function and use it at run time with png_set_write_fn(), rather
  45. ; than changing the library.
  46.  
  47. ;void (png_structp png_ptr, bytep data, png_size_t length)
  48. align 4
  49. proc png_default_write_data uses eax edi, png_ptr:dword, p2data:dword, length:dword
  50. ;   png_size_t check;
  51.  
  52.         mov edi,[png_ptr]
  53.         cmp edi,0
  54.         je .end_f ;if (..==0) return
  55.  
  56. ;   check = fwrite(p2data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
  57.  
  58. ;   if (check != length)
  59. ;      png_error(png_ptr, "Write Error");
  60. .end_f:
  61.         ret
  62. endp
  63.  
  64. ; This function is called to output any data pending writing (normally
  65. ; to disk).  After png_flush is called, there should be no data pending
  66. ; writing in any buffers.
  67.  
  68. ;void (png_structrp png_ptr)
  69. align 4
  70. proc png_flush uses edi, png_ptr:dword
  71.         mov edi,[png_ptr]
  72.         cmp dword[edi+png_struct.output_flush_fn],0
  73.         je @f ;if (..!=..)
  74.                 stdcall dword[edi+png_struct.output_flush_fn],edi
  75.         @@:
  76.         ret
  77. endp
  78.  
  79. ;void (png_structp png_ptr)
  80. align 4
  81. proc png_default_flush uses eax edi, png_ptr:dword
  82.         mov edi,[png_ptr]
  83.         cmp edi,0
  84.         je @f ;if (..==0) return
  85. ;;;             stdcall fflush, [edi+png_struct.io_ptr]
  86.         @@:
  87.         ret
  88. endp
  89.  
  90. ; This function allows the application to supply new output functions for
  91. ; libpng if standard C streams aren't being used.
  92.  
  93. ; This function takes as its arguments:
  94. ; png_ptr       - pointer to a png output data structure
  95. ; io_ptr        - pointer to user supplied structure containing info about
  96. ;                 the output functions.  May be NULL.
  97. ; write_data_fn - pointer to a new output function that takes as its
  98. ;                 arguments a pointer to a png_struct, a pointer to
  99. ;                 data to be written, and a 32-bit unsigned int that is
  100. ;                 the number of bytes to be written.  The new write
  101. ;                 function should call png_error(png_ptr, "Error msg")
  102. ;                 to exit and output any fatal error messages.  May be
  103. ;                 NULL, in which case libpng's default function will
  104. ;                 be used.
  105. ; flush_data_fn - pointer to a new flush function that takes as its
  106. ;                 arguments a pointer to a png_struct.  After a call to
  107. ;                 the flush function, there should be no data in any buffers
  108. ;                 or pending transmission.  If the output method doesn't do
  109. ;                 any buffering of output, a function prototype must still be
  110. ;                 supplied although it doesn't have to do anything.  If
  111. ;                 PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
  112. ;                 time, output_flush_fn will be ignored, although it must be
  113. ;                 supplied for compatibility.  May be NULL, in which case
  114. ;                 libpng's default function will be used, if
  115. ;                 PNG_WRITE_FLUSH_SUPPORTED is defined.  This is not
  116. ;                 a good idea if io_ptr does not point to a standard
  117. ;                 *FILE structure.
  118.  
  119. ;void (png_structrp png_ptr, voidp io_ptr,
  120. ;    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
  121. align 4
  122. proc png_set_write_fn uses eax edi, png_ptr:dword, io_ptr:dword, write_data_fn:dword, output_flush_fn:dword
  123.         mov edi,[png_ptr]
  124.         cmp edi,0
  125.         je .end_f ;if (..==0) return
  126.  
  127.         mov eax,[io_ptr]
  128.         mov [edi+png_struct.io_ptr],eax
  129.  
  130. if PNG_STDIO_SUPPORTED eq 1
  131.         mov eax,png_default_write_data ;else
  132.         cmp dword[write_data_fn],0
  133.         je @f ;if (..!=0)
  134.                 mov eax,[write_data_fn]
  135.         @@:
  136. else
  137.         mov eax,[write_data_fn]
  138. end if
  139.         mov [edi+png_struct.write_data_fn],eax
  140.  
  141. if PNG_WRITE_FLUSH_SUPPORTED eq 1
  142.         if PNG_STDIO_SUPPORTED eq 1
  143.                 mov eax,[png_default_flush] ;else
  144.                 cmp dword[output_flush_fn],0
  145.                 je @f ;if (..!=0)
  146.                         mov eax,[output_flush_fn]
  147.                 @@:
  148.         else
  149.                 mov eax,[output_flush_fn]
  150.         end if
  151.         mov [edi+png_struct.output_flush_fn],eax
  152. end if ;WRITE_FLUSH
  153.  
  154. if PNG_READ_SUPPORTED eq 1
  155.         ; It is an error to read while writing a png file
  156.         cmp dword[edi+png_struct.read_data_fn],0
  157.         je @f ;if (..!=0)
  158.                 mov dword[edi+png_struct.read_data_fn], 0
  159.  
  160.                 png_warning edi, <'Can',39,'t set both read_data_fn and write_data_fn in the same structure'>
  161.         @@:
  162. end if
  163. .end_f:
  164.         ret
  165. endp
  166.