Mercurial > repos > blastem
annotate zlib/zutil.c @ 1775:a9fc826c6a9d mame_interp
Make refresh delay emulation play nice with Musashi
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 13 Mar 2019 18:57:11 -0700 |
parents | 00d788dac91a |
children |
rev | line source |
---|---|
1530
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 /* zutil.c -- target dependent utility functions for the compression library |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 * Copyright (C) 1995-2017 Jean-loup Gailly |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 * For conditions of distribution and use, see copyright notice in zlib.h |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 /* @(#) $Id$ */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 #include "zutil.h" |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 #ifndef Z_SOLO |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 # include "gzguts.h" |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 z_const char * const z_errmsg[10] = { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 (z_const char *)"stream end", /* Z_STREAM_END 1 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 (z_const char *)"", /* Z_OK 0 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 (z_const char *)"file error", /* Z_ERRNO (-1) */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 (z_const char *)"" |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 }; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 const char * ZEXPORT zlibVersion() |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 return ZLIB_VERSION; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 uLong ZEXPORT zlibCompileFlags() |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 uLong flags; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 flags = 0; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 switch ((int)(sizeof(uInt))) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 case 2: break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 case 4: flags += 1; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 case 8: flags += 2; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 default: flags += 3; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 switch ((int)(sizeof(uLong))) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 case 2: break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 case 4: flags += 1 << 2; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 case 8: flags += 2 << 2; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 default: flags += 3 << 2; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 switch ((int)(sizeof(voidpf))) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 case 2: break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 case 4: flags += 1 << 4; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 case 8: flags += 2 << 4; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 default: flags += 3 << 4; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 switch ((int)(sizeof(z_off_t))) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 case 2: break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 case 4: flags += 1 << 6; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 case 8: flags += 2 << 6; break; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 default: flags += 3 << 6; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 #ifdef ZLIB_DEBUG |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 flags += 1 << 8; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 #if defined(ASMV) || defined(ASMINF) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 flags += 1 << 9; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 #ifdef ZLIB_WINAPI |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 flags += 1 << 10; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 #ifdef BUILDFIXED |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 flags += 1 << 12; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 #ifdef DYNAMIC_CRC_TABLE |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 flags += 1 << 13; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 #ifdef NO_GZCOMPRESS |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 flags += 1L << 16; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 #ifdef NO_GZIP |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 flags += 1L << 17; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 #ifdef PKZIP_BUG_WORKAROUND |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 flags += 1L << 20; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 #ifdef FASTEST |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 flags += 1L << 21; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 # ifdef NO_vsnprintf |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 flags += 1L << 25; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 # ifdef HAS_vsprintf_void |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 flags += 1L << 26; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 # endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 # else |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 # ifdef HAS_vsnprintf_void |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 flags += 1L << 26; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 # endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 # endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 #else |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 flags += 1L << 24; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 # ifdef NO_snprintf |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 flags += 1L << 25; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 # ifdef HAS_sprintf_void |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 flags += 1L << 26; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 # endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 # else |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 # ifdef HAS_snprintf_void |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 flags += 1L << 26; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 # endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 # endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 return flags; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 #ifdef ZLIB_DEBUG |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 #include <stdlib.h> |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 # ifndef verbose |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 # define verbose 0 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 # endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 int ZLIB_INTERNAL z_verbose = verbose; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 void ZLIB_INTERNAL z_error (m) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 char *m; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 fprintf(stderr, "%s\n", m); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 exit(1); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 /* exported to allow conversion of error code to string for compress() and |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 * uncompress() |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 const char * ZEXPORT zError(err) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 int err; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 return ERR_MSG(err); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 #if defined(_WIN32_WCE) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 /* The Microsoft C Run-Time Library for Windows CE doesn't have |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 * errno. We define it as a global variable to simplify porting. |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 * Its value is always 0 and should not be used. |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 int errno = 0; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 #ifndef HAVE_MEMCPY |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 void ZLIB_INTERNAL zmemcpy(dest, source, len) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 Bytef* dest; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 const Bytef* source; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 uInt len; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 if (len == 0) return; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 do { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 *dest++ = *source++; /* ??? to be unrolled */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 } while (--len != 0); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 int ZLIB_INTERNAL zmemcmp(s1, s2, len) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 const Bytef* s1; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 const Bytef* s2; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 uInt len; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 uInt j; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 for (j = 0; j < len; j++) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 return 0; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 void ZLIB_INTERNAL zmemzero(dest, len) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 Bytef* dest; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 uInt len; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 if (len == 0) return; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 do { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 *dest++ = 0; /* ??? to be unrolled */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 } while (--len != 0); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 #ifndef Z_SOLO |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 #ifdef SYS16BIT |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 #ifdef __TURBOC__ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 /* Turbo C in 16-bit mode */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 # define MY_ZCALLOC |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 /* Turbo C malloc() does not allow dynamic allocation of 64K bytes |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 * and farmalloc(64K) returns a pointer with an offset of 8, so we |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 * must fix the pointer. Warning: the pointer must be put back to its |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 * original form in order to free it, use zcfree(). |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 #define MAX_PTR 10 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 /* 10*64K = 640K */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 local int next_ptr = 0; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 typedef struct ptr_table_s { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 voidpf org_ptr; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 voidpf new_ptr; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 } ptr_table; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 local ptr_table table[MAX_PTR]; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 /* This table is used to remember the original form of pointers |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 * to large buffers (64K). Such pointers are normalized with a zero offset. |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 * Since MSDOS is not a preemptive multitasking OS, this table is not |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 * protected from concurrent access. This hack doesn't work anyway on |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 * a protected system like OS/2. Use Microsoft C instead. |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 voidpf buf; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 ulg bsize = (ulg)items*size; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 (void)opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 /* If we allocate less than 65520 bytes, we assume that farmalloc |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 * will return a usable pointer which doesn't have to be normalized. |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 if (bsize < 65520L) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 buf = farmalloc(bsize); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 if (*(ush*)&buf != 0) return buf; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 } else { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 buf = farmalloc(bsize + 16L); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 if (buf == NULL || next_ptr >= MAX_PTR) return NULL; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 table[next_ptr].org_ptr = buf; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 /* Normalize the pointer to seg:0 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 *(ush*)&buf = 0; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 table[next_ptr++].new_ptr = buf; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 return buf; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 int n; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
246 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 (void)opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 if (*(ush*)&ptr != 0) { /* object < 64K */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 farfree(ptr); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 return; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
253 /* Find the original pointer */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 for (n = 0; n < next_ptr; n++) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 if (ptr != table[n].new_ptr) continue; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 farfree(table[n].org_ptr); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 while (++n < next_ptr) { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 table[n-1] = table[n]; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 next_ptr--; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 return; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 Assert(0, "zcfree: ptr not found"); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 #endif /* __TURBOC__ */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 #ifdef M_I86 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 /* Microsoft C in 16-bit mode */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 # define MY_ZCALLOC |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 # define _halloc halloc |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 # define _hfree hfree |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 (void)opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 return _halloc((long)items, size); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 (void)opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 _hfree(ptr); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 #endif /* M_I86 */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 #endif /* SYS16BIT */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 #ifndef STDC |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 extern voidp malloc OF((uInt size)); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 extern voidp calloc OF((uInt items, uInt size)); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 extern void free OF((voidpf ptr)); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 #endif |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 voidpf opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 unsigned items; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 unsigned size; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 (void)opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 (voidpf)calloc(items, size); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 void ZLIB_INTERNAL zcfree (opaque, ptr) |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 voidpf opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 voidpf ptr; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 { |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 (void)opaque; |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 free(ptr); |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 } |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 #endif /* MY_ZCALLOC */ |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
324 |
00d788dac91a
Added support for reading gzipped ROMs
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
325 #endif /* !Z_SOLO */ |