English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 15 November 2016, 19:40   #21
arti
Registered User

 
Join Date: Jul 2008
Location: Poland
Posts: 514
I want use inflate from here https://raw.githubusercontent.com/ke...er/inflate.asm

Code:
long inflate(register z_streamp instream __asm("a5"), register int outdata __asm("a4"));
Can I use other types than long ?

Last edited by arti; 15 November 2016 at 19:55.
arti is offline  
Old 15 November 2016, 19:48   #22
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
The order is important. I ended up changing the macro syntax slightly to get the universal macros to work. I changed the example and there is now a test for GCC and vbcc which are now working for me. I updated my earlier post in this thread with an attachment to a new universal macro archive.

Quote:
Originally Posted by arti View Post
Can I use other types than long ?
Yes, but remember the 68k registers are 32 bits. Wider integer datatypes will not work and most datatypes can vary in size. The safest datatypes are probably int32_t, uint32_t, LONG, ULONG, APTR because they shouldn't vary in width. Narrower datatypes than 32 bit should be handled correctly but may be slower in some cases on the 68020+.

Last edited by matthey; 15 November 2016 at 20:03.
matthey is offline  
Old 16 November 2016, 00:53   #23
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 454
Quote:
Originally Posted by arti View Post
I want use inflate from here https://raw.githubusercontent.com/ke...er/inflate.asm

Code:
long inflate(register z_streamp instream __asm("a5"), register int outdata __asm("a4"));
Can I use other types than long ?
Yes.

Something like
Code:
void inflate(register char *instream __asm("a5"), register char *outdata __asm("a4"));
would work.
alkis is offline  
Old 16 November 2016, 20:54   #24
arti
Registered User

 
Join Date: Jul 2008
Location: Poland
Posts: 514
That's how I have implemented it, posted here:
http://eab.abime.net/showpost.php?p=...9&postcount=55
arti is offline  
Old 17 November 2016, 01:34   #25
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 454
Is it possible to have a small encoded and a decoded sample in order to play with it?
alkis is offline  
Old 17 November 2016, 13:57   #26
arti
Registered User

 
Join Date: Jul 2008
Location: Poland
Posts: 514
http://netsurf.baderman.net/inflate.zip
arti is offline  
Old 17 November 2016, 18:42   #27
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 454
Can't really compile it. But...

You are doing
Code:
int inflate_asm(register z_streamp instream __asm("a5"), register int outdata __asm("a4"));

int __wrap_inflate2(z_streamp instream, int flush)
{
	int outdata;
	
    inflate_asm(instream, outdata);  

	//return inflate(instream, flush);
	
    return  outdata;
}
Your instream is a not a pointer to the encoded buffer.

z_streamp is (if you peek at zlib.h)

Code:
typedef struct z_stream_s {
    Bytef    *next_in;  /* next input byte */
    uInt     avail_in;  /* number of bytes available at next_in */
    uLong    total_in;  /* total nb of input bytes read so far */

    Bytef    *next_out; /* next output byte should be put there */
    uInt     avail_out; /* remaining free space at next_out */
    uLong    total_out; /* total nb of bytes output so far */

    char     *msg;      /* last error message, NULL if no error */
    struct internal_state FAR *state; /* not visible by applications */

    alloc_func zalloc;  /* used to allocate the internal state */
    free_func  zfree;   /* used to free the internal state */
    voidpf     opaque;  /* private data object passed to zalloc and zfree */

    int     data_type;  /* best guess about the data type: binary or text */
    uLong   adler;      /* adler32 value of the uncompressed data */
    uLong   reserved;   /* reserved for future use */
} z_stream;

typedef z_stream FAR *z_streamp;
As I understand the inflate.asm expects a pointer to (let's say) 200 bytes which are compressed and a large enough buffer (let's say 1000 bytes) to uncompress.

Your input pointer is not pointing to that. That's your problem, I think
alkis is offline  
Old 03 December 2016, 15:52   #28
arti
Registered User

 
Join Date: Jul 2008
Location: Poland
Posts: 514
That's how I corrected it :

Code:
#include "zlib.h"


int inflate_asm(register png_structrp png_ptr __asm("a5"), register int outdata __asm("a4"));

int /* PRIVATE */
png_zlib_inflate(png_structrp png_ptr, int flush)
{
   int outdata;
    
   if (png_ptr->zstream_start && png_ptr->zstream.avail_in > 0)
   {
      if ((*png_ptr->zstream.next_in >> 4) > 7)
      {
         png_ptr->zstream.msg = "invalid window size (libpng)";
         return Z_DATA_ERROR;
      }

      png_ptr->zstream_start = 0;
   }
   
    inflate_asm(&png_ptr->zstream, outdata);
   
   return  outdata;
}
but still doesn't work :/
arti is offline  
Old 03 December 2016, 20:27   #29
nogginthenog
Amigan

 
Join Date: Feb 2012
Location: London
Posts: 678
> register int outdata

Try using 'unsigned char *' instead of int. In C int is a signed type which may cause problems (use unsigned int at least).

For example:
Code:
int inflate_asm(register png_structrp png_ptr __asm("a5"), register unsigned char *outdata __asm("a4"));
unsigned char *png_zlib_inflate(png_structrp png_ptr, int flush)
inflate_asm(&png_ptr->zstream, outdata);
After this line add this and see what it outputs:
printf("%lx\n", outdata);
nogginthenog is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing OS4 functions for OS3.x arti Coders. C/C++ 22 03 May 2013 18:27
functions benchmark wawa Coders. System 2 15 April 2013 19:55
How do the non-i/o functions work? mikro project.WHDLoad 3 03 November 2011 15:33
Lost F key Functions on WINuae startup breadbaker support.WinUAE 8 06 December 2005 21:09
CD32 blue button functions differently oldpx support.WinUAE 6 09 August 2004 14:43

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:53.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.07619 seconds with 16 queries