Previous 15994 Revisions Next

r8396 Tuesday 6th July, 2010 at 00:24:00 UTC by Miodrag Milanović
Moved image utils to a /lib/util/imageutl.c some utils moved in other files.
[src/emu/sound]wave.c
[src/lib]lib.mak
[src/lib/util]imageutl.c* imageutl.h*
[src/mess]messcore.mak utils.c utils.h
[src/mess/audio]ted7360.c
[src/mess/devices]cassette.c flopdrv.c ti99_hd.c ti99cart.c z80bin.c
[src/mess/drivers]vtech1.c
[src/mess/formats]apridisk.c atom_atm.c cassimg.c coco_dsk.c comx35_comx.c dsk_dsk.c fdi_dsk.c flopimg.c oric_dsk.c spec_snqk.c ti99_dsk.c timex_dck.c z80ne_dsk.c
[src/mess/machine]genesis.c msx.c mtx.c smc92x4.c wd17xx.c
[src/mess/osd/windows]dialog.c menu.c
[src/mess/osd/winui]messui.c propertiesms.c
[src/mess/tools/castool]castool.mak
[src/mess/tools/dat2html]dat2html.c dat2html.mak
[src/mess/tools/imgtool]filtbas.c filter.c imgtool.c imgtool.h imgtool.mak main.c stream.c tstsuite.c
[src/mess/tools/imgtool/modules]amiga.c cococas.c fat.c fmsx_cas.c mac.c macbin.c msx_dsk.c os9.c pc_flop.c pc_hard.c prodos.c rsdos.c svi_cas.c ti85.c vmsx_tap.c vzdos.c xsa.c
[src/mess/tools/imgtool/windows]assocdlg.c hexview.c wmain.c
[src/mess/tools/messtest]core.c testimgt.c
[src/mess/video]vic4567.c

src/emu/sound/wave.c
r8395r8396
1717#include "streams.h"
1818#ifdef MESS
1919#include "messdrv.h"
20#include "utils.h"
2120#include "devices/cassette.h"
2221#endif
2322#include "wave.h"
src/lib/lib.mak
r8395r8396
3737   $(LIBOBJ)/util/coreutil.o \
3838   $(LIBOBJ)/util/harddisk.o \
3939   $(LIBOBJ)/util/huffman.o \
40   $(LIBOBJ)/util/imageutl.o \
4041   $(LIBOBJ)/util/jedparse.o \
4142   $(LIBOBJ)/util/md5.o \
4243   $(LIBOBJ)/util/opresolv.o \
src/lib/util/imageutl.c
r0r8396
1/***************************************************************************
2
3    imageutl.h
4
5    Image related utilities
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#include <ctype.h>
41#include "imageutl.h"
42
43int compute_log2(int val)
44{
45   int count = 0;
46
47   while(val > 1)
48   {
49      if (val & 1)
50         return -1;
51      val /= 2;
52      count++;
53   }
54   return (val == 0) ? -1 : count;
55}
56
57/*
58   Compute CCITT CRC-16 using the correct bit order for floppy disks.
59   CRC code courtesy of Tim Mann.
60*/
61
62/* Accelerator table to compute the CRC eight bits at a time */
63static const unsigned short ccitt_crc16_table[256] =
64{
65   0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
66   0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
67   0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
68   0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
69   0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
70   0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
71   0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
72   0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
73   0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
74   0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
75   0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
76   0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
77   0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
78   0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
79   0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
80   0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
81   0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
82   0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
83   0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
84   0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
85   0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
86   0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
87   0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
88   0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
89   0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
90   0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
91   0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
92   0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
93   0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
94   0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
95   0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
96   0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
97};
98
99unsigned short ccitt_crc16(unsigned short crc, const unsigned char *buffer, size_t buffer_len)
100{
101   size_t i;
102   for (i = 0; i < buffer_len; i++)
103      crc = (crc << 8) ^ ccitt_crc16_table[(crc >> 8) ^ buffer[i]];
104   return crc;
105}
106
107unsigned short ccitt_crc16_one( unsigned short crc, const unsigned char data )
108{
109    return (crc << 8) ^ ccitt_crc16_table[(crc >> 8) ^ data];
110}
111
112
113/*-------------------------------------------------
114    is_delim - returns whether c is a comma or \0
115-------------------------------------------------*/
116
117static int is_delim(char c)
118{
119   return (c == '\0') || (c == ',');
120}
121
122
123
124/*-------------------------------------------------
125    image_internal_find_extension - find an extension in
126    an extension list
127-------------------------------------------------*/
128
129static int image_internal_find_extension(const char *extension_list, const char *target_extension)
130{
131   /* this version allows target_extension to be delimited with a comma */
132   int pos = 0;
133   int i;
134
135   while(extension_list[pos] != '\0')
136   {
137      /* compare a file extension */
138      i = 0;
139      while(!is_delim(extension_list[pos + i])
140         && !is_delim(target_extension[i])
141         && (tolower(extension_list[pos + i]) == tolower(target_extension[i])))
142      {
143         i++;
144      }
145
146      /* check to see if it was found */
147      if (is_delim(extension_list[pos + i]) && is_delim(target_extension[i]))
148         return TRUE;
149
150      /* move to next position in the buffer */
151      pos += i;
152      while(!is_delim(extension_list[pos]))
153         pos++;
154      while(extension_list[pos] == ',')
155         pos++;
156   }
157
158   /* not found */
159   return FALSE;
160}
161
162
163
164/*-------------------------------------------------
165    image_find_extension - find an extension in an extension
166    list
167-------------------------------------------------*/
168
169int image_find_extension(const char *extension_list, const char *target_extension)
170{
171   /* the internal function allows something that we do not */
172   if (strchr(target_extension, ','))
173      return FALSE;
174
175   /* special case to allow ext to be in the form '.EXT' */
176   if (*target_extension == '.')
177      target_extension++;
178
179   /* do the actual work */
180   return image_internal_find_extension(extension_list, target_extension);
181}
182
183
184
185/*-------------------------------------------------
186    image_specify_extension - merge a comma-delimited
187    list of file extensions onto an existing list
188-------------------------------------------------*/
189
190void image_specify_extension(char *buffer, size_t buffer_len, const char *extension)
191{
192   int extension_pos = 0;
193   int len;
194   int found;
195
196   /* determine the length of the buffer */
197   len = strlen(buffer);
198
199   /* be aware that extension can be NULL */
200   if (extension != NULL)
201   {
202      while(extension[extension_pos] != '\0')
203      {
204         /* try to find the file extension */
205         found = image_internal_find_extension(buffer, &extension[extension_pos]);
206
207         /* append a delimiter if we have to */
208         if (!found && (len > 0))
209            len += snprintf(&buffer[len], buffer_len - len, ",");
210
211         /* move to the next extension, appending the extension if not found */
212         while(!is_delim(extension[extension_pos]))
213         {
214            if (!found)
215               len += snprintf(&buffer[len], buffer_len - len, "%c", extension[extension_pos]);
216            extension_pos++;
217         }
218         while(extension[extension_pos] == ',')
219            extension_pos++;
220      }
221   }
222}
223
src/lib/util/imageutl.h
r0r8396
1/***************************************************************************
2
3    imageutl.h
4
5    Image related utilities
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#pragma once
41
42#ifndef __IMAGEUTL_H__
43#define __IMAGEUTL_H__
44
45#include "osdcore.h"
46
47/* -----------------------------------------------------------------------
48 * CRC stuff
49 * ----------------------------------------------------------------------- */
50unsigned short ccitt_crc16(unsigned short crc, const unsigned char *buffer, size_t buffer_len);
51unsigned short ccitt_crc16_one( unsigned short crc, const unsigned char data );
52
53/* -----------------------------------------------------------------------
54 * Alignment-friendly integer placement
55 * ----------------------------------------------------------------------- */
56
57INLINE void place_integer_be(void *ptr, size_t offset, size_t size, UINT64 value)
58{
59   UINT8 *byte_ptr = ((UINT8 *) ptr) + offset;
60   UINT16 val16;
61   UINT32 val32;
62
63   switch(size)
64   {
65      case 2:
66         val16 = BIG_ENDIANIZE_INT16((UINT16) value);
67         memcpy(byte_ptr, &val16, sizeof(val16));
68         break;
69
70      case 4:
71         val32 = BIG_ENDIANIZE_INT32((UINT32) value);
72         memcpy(byte_ptr, &val32, sizeof(val32));
73         break;
74
75      default:
76         if (size >= 1)   byte_ptr[0] = (UINT8) (value >> ((size - 1) * 8));
77         if (size >= 2)   byte_ptr[1] = (UINT8) (value >> ((size - 2) * 8));
78         if (size >= 3)   byte_ptr[2] = (UINT8) (value >> ((size - 3) * 8));
79         if (size >= 4)   byte_ptr[3] = (UINT8) (value >> ((size - 4) * 8));
80         if (size >= 5)   byte_ptr[4] = (UINT8) (value >> ((size - 5) * 8));
81         if (size >= 6)   byte_ptr[5] = (UINT8) (value >> ((size - 6) * 8));
82         if (size >= 7)   byte_ptr[6] = (UINT8) (value >> ((size - 7) * 8));
83         if (size >= 8)   byte_ptr[7] = (UINT8) (value >> ((size - 8) * 8));
84         break;
85   }
86}
87
88INLINE UINT64 pick_integer_be(const void *ptr, size_t offset, size_t size)
89{
90   UINT64 result = 0;
91   const UINT8 *byte_ptr = ((const UINT8 *) ptr) + offset;
92   UINT16 val16;
93   UINT32 val32;
94
95   switch(size)
96   {
97      case 1:
98         result = *byte_ptr;
99         break;
100
101      case 2:
102         memcpy(&val16, byte_ptr, sizeof(val16));
103         result = BIG_ENDIANIZE_INT16(val16);
104         break;
105
106      case 4:
107         memcpy(&val32, byte_ptr, sizeof(val32));
108         result = BIG_ENDIANIZE_INT32(val32);
109         break;
110
111      default:
112         if (size >= 1)   result |= ((UINT64) byte_ptr[0]) << ((size - 1) * 8);
113         if (size >= 2)   result |= ((UINT64) byte_ptr[1]) << ((size - 2) * 8);
114         if (size >= 3)   result |= ((UINT64) byte_ptr[2]) << ((size - 3) * 8);
115         if (size >= 4)   result |= ((UINT64) byte_ptr[3]) << ((size - 4) * 8);
116         if (size >= 5)   result |= ((UINT64) byte_ptr[4]) << ((size - 5) * 8);
117         if (size >= 6)   result |= ((UINT64) byte_ptr[5]) << ((size - 6) * 8);
118         if (size >= 7)   result |= ((UINT64) byte_ptr[6]) << ((size - 7) * 8);
119         if (size >= 8)   result |= ((UINT64) byte_ptr[7]) << ((size - 8) * 8);
120         break;
121   }
122   return result;
123}
124
125INLINE void place_integer_le(void *ptr, size_t offset, size_t size, UINT64 value)
126{
127   UINT8 *byte_ptr = ((UINT8 *) ptr) + offset;
128   UINT16 val16;
129   UINT32 val32;
130
131   switch(size)
132   {
133      case 2:
134         val16 = LITTLE_ENDIANIZE_INT16((UINT16) value);
135         memcpy(byte_ptr, &val16, sizeof(val16));
136         break;
137
138      case 4:
139         val32 = LITTLE_ENDIANIZE_INT32((UINT32) value);
140         memcpy(byte_ptr, &val32, sizeof(val32));
141         break;
142
143      default:
144         if (size >= 1)   byte_ptr[0] = (UINT8) (value >> (0 * 8));
145         if (size >= 2)   byte_ptr[1] = (UINT8) (value >> (1 * 8));
146         if (size >= 3)   byte_ptr[2] = (UINT8) (value >> (2 * 8));
147         if (size >= 4)   byte_ptr[3] = (UINT8) (value >> (3 * 8));
148         if (size >= 5)   byte_ptr[4] = (UINT8) (value >> (4 * 8));
149         if (size >= 6)   byte_ptr[5] = (UINT8) (value >> (5 * 8));
150         if (size >= 7)   byte_ptr[6] = (UINT8) (value >> (6 * 8));
151         if (size >= 8)   byte_ptr[7] = (UINT8) (value >> (7 * 8));
152         break;
153   }
154}
155
156INLINE UINT64 pick_integer_le(const void *ptr, size_t offset, size_t size)
157{
158   UINT64 result = 0;
159   const UINT8 *byte_ptr = ((const UINT8 *) ptr) + offset;
160   UINT16 val16;
161   UINT32 val32;
162
163   switch(size)
164   {
165      case 1:
166         result = *byte_ptr;
167         break;
168
169      case 2:
170         memcpy(&val16, byte_ptr, sizeof(val16));
171         result = LITTLE_ENDIANIZE_INT16(val16);
172         break;
173
174      case 4:
175         memcpy(&val32, byte_ptr, sizeof(val32));
176         result = LITTLE_ENDIANIZE_INT32(val32);
177         break;
178
179      default:
180         if (size >= 1)   result |= ((UINT64) byte_ptr[0]) << (0 * 8);
181         if (size >= 2)   result |= ((UINT64) byte_ptr[1]) << (1 * 8);
182         if (size >= 3)   result |= ((UINT64) byte_ptr[2]) << (2 * 8);
183         if (size >= 4)   result |= ((UINT64) byte_ptr[3]) << (3 * 8);
184         if (size >= 5)   result |= ((UINT64) byte_ptr[4]) << (4 * 8);
185         if (size >= 6)   result |= ((UINT64) byte_ptr[5]) << (5 * 8);
186         if (size >= 7)   result |= ((UINT64) byte_ptr[6]) << (6 * 8);
187         if (size >= 8)   result |= ((UINT64) byte_ptr[7]) << (7 * 8);
188         break;
189   }
190   return result;
191}
192
193/* -----------------------------------------------------------------------
194 * Miscellaneous
195 * ----------------------------------------------------------------------- */
196
197/* miscellaneous functions */
198int compute_log2(int val);
199
200/* -----------------------------------------------------------------------
201 * Extension list handling
202 * ----------------------------------------------------------------------- */
203
204int image_find_extension(const char *extensions, const char *ext);
205void image_specify_extension(char *buffer, size_t buffer_len, const char *extension);
206
207#endif /* __IMAGEUTL_H__ */
src/mess/utils.c
r8395r8396
1#include <stdio.h>
2#include <ctype.h>
3#include <stdlib.h>
4#include "emu.h"
5#include "utils.h"
6
7char *strncpyz(char *dest, const char *source, size_t len)
8{
9   char *s;
10   if (len) {
11      s = strncpy(dest, source, len - 1);
12      dest[len-1] = '\0';
13   }
14   else {
15      s = dest;
16   }
17   return s;
18}
19
20char *strncatz(char *dest, const char *source, size_t len)
21{
22   size_t l;
23   l = strlen(dest);
24   dest += l;
25   if (len > l)
26      len -= l;
27   else
28      len = 0;
29   return strncpyz(dest, source, len);
30}
31
32void rtrim(char *buf)
33{
34   size_t buflen;
35   char *s;
36
37   buflen = strlen(buf);
38   if (buflen)
39   {
40      for (s = &buf[buflen-1]; s >= buf && (*s >= '\0') && isspace(*s); s--)
41         *s = '\0';
42   }
43}
44
45#ifndef strncmpi
46int strncmpi(const char *dst, const char *src, size_t n)
47{
48   int result = 0;
49
50   while( !result && *src && *dst && n)
51   {
52      result = tolower(*dst) - tolower(*src);
53      src++;
54      dst++;
55      n--;
56   }
57   return result;
58}
59#endif /* strncmpi */
60
61#ifndef memset16
62void *memset16 (void *dest, int value, size_t size)
63{
64   register int i;
65
66   for (i = 0; i < size; i++)
67      ((short *) dest)[i] = value;
68   return dest;
69}
70#endif
71
72int compute_log2(int val)
73{
74   int count = 0;
75
76   while(val > 1)
77   {
78      if (val & 1)
79         return -1;
80      val /= 2;
81      count++;
82   }
83   return (val == 0) ? -1 : count;
84}
85
86
87
88/*
89   Compute CCITT CRC-16 using the correct bit order for floppy disks.
90   CRC code courtesy of Tim Mann.
91*/
92
93/* Accelerator table to compute the CRC eight bits at a time */
94static const unsigned short ccitt_crc16_table[256] =
95{
96   0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
97   0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
98   0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
99   0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
100   0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
101   0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
102   0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
103   0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
104   0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
105   0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
106   0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
107   0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
108   0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
109   0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
110   0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
111   0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
112   0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
113   0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
114   0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
115   0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
116   0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
117   0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
118   0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
119   0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
120   0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
121   0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
122   0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
123   0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
124   0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
125   0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
126   0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
127   0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
128};
129
130unsigned short ccitt_crc16(unsigned short crc, const unsigned char *buffer, size_t buffer_len)
131{
132   size_t i;
133   for (i = 0; i < buffer_len; i++)
134      crc = (crc << 8) ^ ccitt_crc16_table[(crc >> 8) ^ buffer[i]];
135   return crc;
136}
137
138unsigned short ccitt_crc16_one( unsigned short crc, const unsigned char data )
139{
140    return (crc << 8) ^ ccitt_crc16_table[(crc >> 8) ^ data];
141}
142
143
144
145int hexdigit(char c)
146{
147   int result = 0;
148   if (isdigit(c))
149      result = c - '0';
150   else if (isxdigit(c))
151      result = toupper(c) - 'A' + 10;
152   return result;
153}
154
155
156/*-------------------------------------------------
157    is_delim - returns whether c is a comma or \0
158-------------------------------------------------*/
159
160static int is_delim(char c)
161{
162   return (c == '\0') || (c == ',');
163}
164
165
166
167/*-------------------------------------------------
168    image_internal_find_extension - find an extension in
169    an extension list
170-------------------------------------------------*/
171
172static int image_internal_find_extension(const char *extension_list, const char *target_extension)
173{
174   /* this version allows target_extension to be delimited with a comma */
175   int pos = 0;
176   int i;
177
178   while(extension_list[pos] != '\0')
179   {
180      /* compare a file extension */
181      i = 0;
182      while(!is_delim(extension_list[pos + i])
183         && !is_delim(target_extension[i])
184         && (tolower(extension_list[pos + i]) == tolower(target_extension[i])))
185      {
186         i++;
187      }
188
189      /* check to see if it was found */
190      if (is_delim(extension_list[pos + i]) && is_delim(target_extension[i]))
191         return TRUE;
192
193      /* move to next position in the buffer */
194      pos += i;
195      while(!is_delim(extension_list[pos]))
196         pos++;
197      while(extension_list[pos] == ',')
198         pos++;
199   }
200
201   /* not found */
202   return FALSE;
203}
204
205
206
207/*-------------------------------------------------
208    image_find_extension - find an extension in an extension
209    list
210-------------------------------------------------*/
211
212int image_find_extension(const char *extension_list, const char *target_extension)
213{
214   /* the internal function allows something that we do not */
215   if (strchr(target_extension, ','))
216      return FALSE;
217
218   /* special case to allow ext to be in the form '.EXT' */
219   if (*target_extension == '.')
220      target_extension++;
221
222   /* do the actual work */
223   return image_internal_find_extension(extension_list, target_extension);
224}
225
226
227
228/*-------------------------------------------------
229    image_specify_extension - merge a comma-delimited
230    list of file extensions onto an existing list
231-------------------------------------------------*/
232
233void image_specify_extension(char *buffer, size_t buffer_len, const char *extension)
234{
235   int extension_pos = 0;
236   int len;
237   int found;
238
239   /* determine the length of the buffer */
240   len = strlen(buffer);
241
242   /* be aware that extension can be NULL */
243   if (extension != NULL)
244   {
245      while(extension[extension_pos] != '\0')
246      {
247         /* try to find the file extension */
248         found = image_internal_find_extension(buffer, &extension[extension_pos]);
249
250         /* append a delimiter if we have to */
251         if (!found && (len > 0))
252            len += snprintf(&buffer[len], buffer_len - len, ",");
253
254         /* move to the next extension, appending the extension if not found */
255         while(!is_delim(extension[extension_pos]))
256         {
257            if (!found)
258               len += snprintf(&buffer[len], buffer_len - len, "%c", extension[extension_pos]);
259            extension_pos++;
260         }
261         while(extension[extension_pos] == ',')
262            extension_pos++;
263      }
264   }
265}
266
src/mess/utils.h
r8395r8396
1/***********************************************************
2
3  utils.h
4
5  Nifty utility code
6
7***********************************************************/
8
9#ifndef UTILS_H
10#define UTILS_H
11
12#include <string.h>
13
14/* -----------------------------------------------------------------------
15 * strncpyz
16 * strncatz
17 *
18 * strncpy done right :-)
19 * ----------------------------------------------------------------------- */
20char *strncpyz(char *dest, const char *source, size_t len);
21char *strncatz(char *dest, const char *source, size_t len);
22
23/* -----------------------------------------------------------------------
24 * rtrim
25 *
26 * Removes all trailing spaces from a string
27 * ----------------------------------------------------------------------- */
28void rtrim(char *buf);
29
30/* -----------------------------------------------------------------------
31 * memset16
32 *
33 * 16 bit memset
34 * ----------------------------------------------------------------------- */
35#ifndef memset16
36void *memset16 (void *dest, int value, size_t size);
37#endif /* memset16 */
38
39
40/* -----------------------------------------------------------------------
41 * CRC stuff
42 * ----------------------------------------------------------------------- */
43unsigned short ccitt_crc16(unsigned short crc, const unsigned char *buffer, size_t buffer_len);
44unsigned short ccitt_crc16_one( unsigned short crc, const unsigned char data );
45
46/* -----------------------------------------------------------------------
47 * Alignment-friendly integer placement
48 * ----------------------------------------------------------------------- */
49
50INLINE void place_integer_be(void *ptr, size_t offset, size_t size, UINT64 value)
51{
52   UINT8 *byte_ptr = ((UINT8 *) ptr) + offset;
53   UINT16 val16;
54   UINT32 val32;
55
56   switch(size)
57   {
58      case 2:
59         val16 = BIG_ENDIANIZE_INT16((UINT16) value);
60         memcpy(byte_ptr, &val16, sizeof(val16));
61         break;
62
63      case 4:
64         val32 = BIG_ENDIANIZE_INT32((UINT32) value);
65         memcpy(byte_ptr, &val32, sizeof(val32));
66         break;
67
68      default:
69         if (size >= 1)   byte_ptr[0] = (UINT8) (value >> ((size - 1) * 8));
70         if (size >= 2)   byte_ptr[1] = (UINT8) (value >> ((size - 2) * 8));
71         if (size >= 3)   byte_ptr[2] = (UINT8) (value >> ((size - 3) * 8));
72         if (size >= 4)   byte_ptr[3] = (UINT8) (value >> ((size - 4) * 8));
73         if (size >= 5)   byte_ptr[4] = (UINT8) (value >> ((size - 5) * 8));
74         if (size >= 6)   byte_ptr[5] = (UINT8) (value >> ((size - 6) * 8));
75         if (size >= 7)   byte_ptr[6] = (UINT8) (value >> ((size - 7) * 8));
76         if (size >= 8)   byte_ptr[7] = (UINT8) (value >> ((size - 8) * 8));
77         break;
78   }
79}
80
81INLINE UINT64 pick_integer_be(const void *ptr, size_t offset, size_t size)
82{
83   UINT64 result = 0;
84   const UINT8 *byte_ptr = ((const UINT8 *) ptr) + offset;
85   UINT16 val16;
86   UINT32 val32;
87
88   switch(size)
89   {
90      case 1:
91         result = *byte_ptr;
92         break;
93
94      case 2:
95         memcpy(&val16, byte_ptr, sizeof(val16));
96         result = BIG_ENDIANIZE_INT16(val16);
97         break;
98
99      case 4:
100         memcpy(&val32, byte_ptr, sizeof(val32));
101         result = BIG_ENDIANIZE_INT32(val32);
102         break;
103
104      default:
105         if (size >= 1)   result |= ((UINT64) byte_ptr[0]) << ((size - 1) * 8);
106         if (size >= 2)   result |= ((UINT64) byte_ptr[1]) << ((size - 2) * 8);
107         if (size >= 3)   result |= ((UINT64) byte_ptr[2]) << ((size - 3) * 8);
108         if (size >= 4)   result |= ((UINT64) byte_ptr[3]) << ((size - 4) * 8);
109         if (size >= 5)   result |= ((UINT64) byte_ptr[4]) << ((size - 5) * 8);
110         if (size >= 6)   result |= ((UINT64) byte_ptr[5]) << ((size - 6) * 8);
111         if (size >= 7)   result |= ((UINT64) byte_ptr[6]) << ((size - 7) * 8);
112         if (size >= 8)   result |= ((UINT64) byte_ptr[7]) << ((size - 8) * 8);
113         break;
114   }
115   return result;
116}
117
118INLINE void place_integer_le(void *ptr, size_t offset, size_t size, UINT64 value)
119{
120   UINT8 *byte_ptr = ((UINT8 *) ptr) + offset;
121   UINT16 val16;
122   UINT32 val32;
123
124   switch(size)
125   {
126      case 2:
127         val16 = LITTLE_ENDIANIZE_INT16((UINT16) value);
128         memcpy(byte_ptr, &val16, sizeof(val16));
129         break;
130
131      case 4:
132         val32 = LITTLE_ENDIANIZE_INT32((UINT32) value);
133         memcpy(byte_ptr, &val32, sizeof(val32));
134         break;
135
136      default:
137         if (size >= 1)   byte_ptr[0] = (UINT8) (value >> (0 * 8));
138         if (size >= 2)   byte_ptr[1] = (UINT8) (value >> (1 * 8));
139         if (size >= 3)   byte_ptr[2] = (UINT8) (value >> (2 * 8));
140         if (size >= 4)   byte_ptr[3] = (UINT8) (value >> (3 * 8));
141         if (size >= 5)   byte_ptr[4] = (UINT8) (value >> (4 * 8));
142         if (size >= 6)   byte_ptr[5] = (UINT8) (value >> (5 * 8));
143         if (size >= 7)   byte_ptr[6] = (UINT8) (value >> (6 * 8));
144         if (size >= 8)   byte_ptr[7] = (UINT8) (value >> (7 * 8));
145         break;
146   }
147}
148
149INLINE UINT64 pick_integer_le(const void *ptr, size_t offset, size_t size)
150{
151   UINT64 result = 0;
152   const UINT8 *byte_ptr = ((const UINT8 *) ptr) + offset;
153   UINT16 val16;
154   UINT32 val32;
155
156   switch(size)
157   {
158      case 1:
159         result = *byte_ptr;
160         break;
161
162      case 2:
163         memcpy(&val16, byte_ptr, sizeof(val16));
164         result = LITTLE_ENDIANIZE_INT16(val16);
165         break;
166
167      case 4:
168         memcpy(&val32, byte_ptr, sizeof(val32));
169         result = LITTLE_ENDIANIZE_INT32(val32);
170         break;
171
172      default:
173         if (size >= 1)   result |= ((UINT64) byte_ptr[0]) << (0 * 8);
174         if (size >= 2)   result |= ((UINT64) byte_ptr[1]) << (1 * 8);
175         if (size >= 3)   result |= ((UINT64) byte_ptr[2]) << (2 * 8);
176         if (size >= 4)   result |= ((UINT64) byte_ptr[3]) << (3 * 8);
177         if (size >= 5)   result |= ((UINT64) byte_ptr[4]) << (4 * 8);
178         if (size >= 6)   result |= ((UINT64) byte_ptr[5]) << (5 * 8);
179         if (size >= 7)   result |= ((UINT64) byte_ptr[6]) << (6 * 8);
180         if (size >= 8)   result |= ((UINT64) byte_ptr[7]) << (7 * 8);
181         break;
182   }
183   return result;
184}
185
186/* -----------------------------------------------------------------------
187 * Miscellaneous
188 * ----------------------------------------------------------------------- */
189
190/* miscellaneous functions */
191int compute_log2(int val);
192int hexdigit(char c);
193
194/* extension list handling */
195int image_find_extension(const char *extensions, const char *ext);
196void image_specify_extension(char *buffer, size_t buffer_len, const char *extension);
197
198#endif /* UTILS_H */
src/mess/devices/ti99cart.c
r8395r8396
88
99*********************************************************************/
1010#include "emu.h"
11#include "utils.h"
1211#include "ti99cart.h"
1312#include "cartslot.h"
1413#include "machine/ti99_4x.h"
src/mess/devices/ti99_hd.c
r8395r8396
1212**************************************************************************/
1313
1414#include "emu.h"
15#include "utils.h"
15#include "imageutl.h"
1616#include "harddisk.h"
1717#include "harddriv.h"
1818#include "machine/smc92x4.h"
src/mess/devices/z80bin.c
r8395r8396
88*********************************************************************/
99
1010#include "emu.h"
11#include "utils.h"
1211#include "z80bin.h"
1312#include "snapquik.h"
1413
src/mess/devices/cassette.c
r8395r8396
77*********************************************************************/
88
99#include "emu.h"
10#include "utils.h"
10#include "imageutl.h"
1111#include "cassette.h"
1212#include "formats/cassimg.h"
1313#include "ui.h"
src/mess/devices/flopdrv.c
r8395r8396
1212*/
1313
1414#include "emu.h"
15#include "utils.h"
15#include "imageutl.h"
1616#include "flopdrv.h"
1717
1818#define VERBOSE      0
src/mess/osd/windows/dialog.c
r8395r8396
1212
1313#include "dialog.h"
1414#include "emu.h"
15#include "utils.h"
1615#include "strconv.h"
1716#include "pool.h"
1817#include "winutil.h"
src/mess/osd/windows/menu.c
r8395r8396
2323#include "dialog.h"
2424#include "opcntrl.h"
2525#include "strconv.h"
26#include "utils.h"
2726#include "debug/debugcpu.h"
2827#include "inptport.h"
2928#include "devices/cassette.h"
src/mess/osd/winui/messui.c
r8395r8396
3131#include "softwarelist.h"
3232#include "devview.h"
3333#include "windows/window.h"
34#include "utils.h"
3534#include "strconv.h"
3635#include "messui.h"
3736#include "winutf8.h"
r8395r8396
254253//============================================================
255254//  IMPLEMENTATION
256255//============================================================
256static char *strncpyz(char *dest, const char *source, size_t len)
257{
258   char *s;
259   if (len) {
260      s = strncpy(dest, source, len - 1);
261      dest[len-1] = '\0';
262   }
263   else {
264      s = dest;
265   }
266   return s;
267}
257268
258269static const device_entry *lookupdevice(iodevice_t d)
259270{
src/mess/osd/winui/propertiesms.c
r8395r8396
2525#include "mui_opts.h"
2626#include "resourcems.h"
2727#include "mess.h"
28#include "utils.h"
2928#include "propertiesms.h"
3029#include "optionsms.h"
3130#include "msuiutil.h"
src/mess/messcore.mak
r8395r8396
7474EMUOBJS += \
7575   $(MESSOBJ)/mess.o      \
7676   $(MESSOBJ)/uimess.o      \
77   $(MESSOBJ)/utils.o      \
7877   $(MESSOBJ)/cheatms.o   \
7978
8079$(LIBEMU): $(EMUOBJS)
src/mess/tools/dat2html/dat2html.c
r8395r8396
1414
1515#include "emu.h"
1616#include "osdcore.h"
17#include "utils.h"
1817
1918static void replace_lt_gt(char *line)
2019{
src/mess/tools/dat2html/dat2html.mak
r8395r8396
2525   $(EMUOBJ)/emucore.o                  \
2626   $(MESSOBJ)/tools/dat2html/dat2html.o   \
2727   $(MESSOBJ)/tools/imgtool/stubs.o      \
28   $(MESSOBJ)/utils.o                  \
2928
3029
3130
src/mess/tools/castool/castool.mak
r8395r8396
3434   $(EMUOBJ)/emucore.o               \
3535   $(EMUOBJ)/emuopts.o             \
3636   $(EMUOBJ)/memory.o               \
37   $(EMUOBJ)/ioprocs.o         \
38   $(MESSOBJ)/utils.o               \
37   $(EMUOBJ)/ioprocs.o               \
3938   $(MESS_FORMATS)/a26_cas.o           \
4039   $(MESS_FORMATS)/apf_apt.o           \
4140   $(MESS_FORMATS)/cbm_tap.o           \
src/mess/tools/messtest/testimgt.c
r8395r8396
77*********************************************************************/
88
99#include "testimgt.h"
10#include "utils.h"
10#include "imageutl.h"
1111#include "../imgtool/imgtool.h"
1212#include "../imgtool/modules.h"
1313
src/mess/tools/messtest/core.c
r8395r8396
1515#include <windows.h>
1616#endif /* WIN32 */
1717#include "emu.h"
18#include "utils.h"
1918#include "core.h"
2019#include "testmess.h"
2120#include "testimgt.h"
r8395r8396
4342static int is_failure;
4443
4544
45int hexdigit(char c)
46{
47   int result = 0;
48   if (isdigit(c))
49      result = c - '0';
50   else if (isxdigit(c))
51      result = toupper(c) - 'A' + 10;
52   return result;
53}
4654
4755void error_report(const char *message)
4856{
src/mess/tools/imgtool/imgtool.mak
r8395r8396
3636   $(EMUOBJ)/emucore.o            \
3737   $(EMUOBJ)/emuopts.o             \
3838   $(EMUOBJ)/memory.o            \
39   $(MESSOBJ)/utils.o            \
4039   $(EMUOBJ)/ioprocs.o         \
4140   $(MESS_FORMATS)/flopimg.o         \
4241   $(MESS_FORMATS)/cassimg.o         \
src/mess/tools/imgtool/windows/assocdlg.c
r8395r8396
1717#include "wimgres.h"
1818#include "strconv.h"
1919#include "../imgtool.h"
20#include "utils.h"
20#include "imageutl.h"
2121
22
2322//============================================================
2423//  PARAMETERS
2524//============================================================
src/mess/tools/imgtool/windows/wmain.c
r8395r8396
1313#include "../modules.h"
1414#include "winutf8.h"
1515#include "strconv.h"
16#include "utils.h"
1716
1817int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
1918   LPWSTR command_line_w, int cmd_show)
src/mess/tools/imgtool/windows/hexview.c
r8395r8396
1414#include <tchar.h>
1515#include "emu.h"
1616#include "hexview.h"
17#include "utils.h"
1817
1918const TCHAR hexview_class[] = TEXT("hexview_class");
2019
src/mess/tools/imgtool/imgtool.c
r8395r8396
1212
1313#include "osdepend.h"
1414#include "imgtoolx.h"
15#include "utils.h"
15#include "imageutl.h"
1616#include "library.h"
1717#include "modules.h"
1818#include "pool.h"
r8395r8396
9494    Imgtool initialization and basics
9595
9696***************************************************************************/
97void rtrim(char *buf)
98{
99   size_t buflen;
100   char *s;
97101
102   buflen = strlen(buf);
103   if (buflen)
104   {
105      for (s = &buf[buflen-1]; s >= buf && (*s >= '\0') && isspace(*s); s--)
106         *s = '\0';
107   }
108}
109
110char *strncpyz(char *dest, const char *source, size_t len)
111{
112   char *s;
113   if (len) {
114      s = strncpy(dest, source, len - 1);
115      dest[len-1] = '\0';
116   }
117   else {
118      s = dest;
119   }
120   return s;
121}
122
123char *strncatz(char *dest, const char *source, size_t len)
124{
125   size_t l;
126   l = strlen(dest);
127   dest += l;
128   if (len > l)
129      len -= l;
130   else
131      len = 0;
132   return strncpyz(dest, source, len);
133}
134
98135/*-------------------------------------------------
99136    markerrorsource - marks where an error source
100137-------------------------------------------------*/
src/mess/tools/imgtool/imgtool.h
r8395r8396
162162int imgtool_validitychecks(void);
163163void unknown_partition_get_info(const imgtool_class *imgclass, UINT32 state, union imgtoolinfo *info);
164164
165char *strncpyz(char *dest, const char *source, size_t len);
166char *strncatz(char *dest, const char *source, size_t len);
167void rtrim(char *buf);
168
165169#endif /* IMGTOOL_H */
src/mess/tools/imgtool/filtbas.c
r8395r8396
2222#include <ctype.h>
2323
2424#include "imgtool.h"
25#include "utils.h"
25#include "imageutl.h"
2626
2727
2828/***************************************************************************
src/mess/tools/imgtool/main.c
r8395r8396
1717#include "imgtool.h"
1818#include "mess.h"
1919#include "main.h"
20#include "utils.h"
2120#include "fileio.h"
2221#include "modules.h"
2322
src/mess/tools/imgtool/tstsuite.c
r8395r8396
11#include <ctype.h>
22#include "imgtool.h"
33#include "main.h"
4#include "utils.h"
54#include "snprintf.h"
65
76#ifdef MAME_DEBUG
src/mess/tools/imgtool/filter.c
r8395r8396
1010#include <string.h>
1111
1212#include "imgtool.h"
13#include "utils.h"
1413
1514/* ----------------------------------------------------------------------- */
1615
src/mess/tools/imgtool/modules/pc_hard.c
r8395r8396
4949****************************************************************************/
5050
5151#include "imgtool.h"
52#include "utils.h"
52#include "imageutl.h"
5353#include "imghd.h"
5454
5555#define FAT_SECLEN   512
src/mess/tools/imgtool/modules/fmsx_cas.c
r8395r8396
44#include "osdepend.h"
55#include "formats/fmsx_cas.h"
66#include "imgtoolx.h"
7#include "utils.h"
87
98/*
109    MSX module
src/mess/tools/imgtool/modules/os9.c
r8395r8396
99#include <time.h>
1010
1111#include "imgtool.h"
12#include "utils.h"
12#include "imageutl.h"
1313#include "formats/coco_dsk.h"
1414#include "iflopimg.h"
1515
src/mess/tools/imgtool/modules/cococas.c
r8395r8396
44#include "osdepend.h"
55#include "imgtoolx.h"
66#include "formats/cococas.h"
7#include "utils.h"
87
98static int cococas_initalt(imgtool_stream *instream, imgtool_stream **outstream, int *basepos,
109   int *length, int *channels, int *frequency, int *resolution);
src/mess/tools/imgtool/modules/amiga.c
r8395r8396
1818
1919#include "imgtool.h"
2020#include "iflopimg.h"
21#include "utils.h"
21#include "imageutl.h"
2222#include "formats/ami_dsk.h"
2323
2424
src/mess/tools/imgtool/modules/ti85.c
r8395r8396
11#include "osdepend.h"
22#include "imgtoolx.h"
3#include "utils.h"
43#include "formats/ti85_ser.h"
54
65static const char *const var_type[] = {
src/mess/tools/imgtool/modules/macbin.c
r8395r8396
4747#include <string.h>
4848
4949#include "imgtool.h"
50#include "utils.h"
50#include "imageutl.h"
5151#include "macutil.h"
5252
5353
src/mess/tools/imgtool/modules/mac.c
r8395r8396
9494#include <stddef.h>
9595
9696#include "emu.h"
97#include "utils.h"
97#include "imageutl.h"
9898#include "osdepend.h"
9999#include "imgtoolx.h"
100100#include "macutil.h"
src/mess/tools/imgtool/modules/vmsx_tap.c
r8395r8396
4545
4646#include "osdepend.h"
4747#include "imgtoolx.h"
48#include "utils.h"
4948
5049typedef struct
5150    {
src/mess/tools/imgtool/modules/vzdos.c
r8395r8396
1313#include "osdepend.h"
1414#include "imgtool.h"
1515#include "imgtoolx.h"
16#include "utils.h"
16#include "imageutl.h"
1717#include "formats/vt_dsk.h"
1818#include "iflopimg.h"
1919
src/mess/tools/imgtool/modules/prodos.c
r8395r8396
122122*****************************************************************************/
123123
124124#include "imgtool.h"
125#include "utils.h"
125#include "imageutl.h"
126126#include "formats/ap2_dsk.h"
127127#include "formats/ap_dsk35.h"
128128#include "iflopimg.h"
src/mess/tools/imgtool/modules/msx_dsk.c
r8395r8396
4242#include <assert.h>
4343#include "osdepend.h"
4444#include "imgtoolx.h"
45#include "utils.h"
4645
4746
4847typedef struct
src/mess/tools/imgtool/modules/fat.c
r8395r8396
136136#include <ctype.h>
137137
138138#include "imgtool.h"
139#include "utils.h"
139#include "imageutl.h"
140140#include "unicode.h"
141141#include "fat.h"
142142
src/mess/tools/imgtool/modules/pc_flop.c
r8395r8396
77****************************************************************************/
88
99#include "imgtool.h"
10#include "utils.h"
10#include "imageutl.h"
1111#include "formats/pc_dsk.h"
1212#include "fat.h"
1313#include "iflopimg.h"
src/mess/tools/imgtool/modules/svi_cas.c
r8395r8396
44#include "osdepend.h"
55#include "formats/svi_cas.h"
66#include "imgtoolx.h"
7#include "utils.h"
87
98/*
109    SVI module
src/mess/tools/imgtool/modules/rsdos.c
r8395r8396
1111#include <stdlib.h>
1212#include "osdepend.h"
1313#include "imgtoolx.h"
14#include "utils.h"
1514#include "formats/coco_dsk.h"
1615#include "iflopimg.h"
17#include "utils.h"
1816
1917
2018/* this structure mirrors the structure of an RS-DOS directory entry on disk */
src/mess/tools/imgtool/modules/xsa.c
r8395r8396
66
77#include "osdepend.h"
88#include "imgtoolx.h"
9#include "utils.h"
109
1110
1211typedef struct
src/mess/tools/imgtool/stream.c
r8395r8396
1515#include "unzip.h"
1616#include "osdcore.h"
1717#include "imgtool.h"
18#include "utils.h"
1918
2019typedef enum
2120{
src/mess/audio/ted7360.c
r8395r8396
360360*/
361361#include "emu.h"
362362#include "streams.h"
363#include "utils.h"
364363#include "audio/ted7360.h"
365364
366365
r8395r8396
666665   }
667666}
668667
668#ifndef memset16
669static void *memset16 (void *dest, int value, size_t size)
670{
671   register int i;
672
673   for (i = 0; i < size; i++)
674      ((short *) dest)[i] = value;
675   return dest;
676}
677#endif
678
669679static void ted7360_draw_cursor( running_device *device, int ybegin, int yend, int yoff, int xoff, int color )
670680{
671681   ted7360_state *ted7360 = get_safe_token(device);
src/mess/machine/wd17xx.c
r8395r8396
134134
135135
136136#include "emu.h"
137#include "utils.h"
137#include "imageutl.h"
138138#include "machine/wd17xx.h"
139139#include "devices/flopdrv.h"
140
141140#include "formats/flopimg.h"
142141
143142/***************************************************************************
src/mess/machine/msx.c
r8395r8396
2424#include "video/v9938.h"
2525#include "machine/ctronics.h"
2626#include "devices/cassette.h"
27#include "utils.h"
2827#include "osdepend.h"
2928#include "sound/ay8910.h"
3029#include "sound/2413intf.h"
src/mess/machine/mtx.c
r8395r8396
77**************************************************************************/
88
99#include "emu.h"
10#include "utils.h"
10#include "imageutl.h"
1111#include "includes/mtx.h"
1212#include "cpu/z80/z80.h"
1313#include "devices/cassette.h"
src/mess/machine/genesis.c
r8395r8396
1919
2020
2121#include "emu.h"
22#include "utils.h"
22#include "imageutl.h"
2323#include "cpu/m68000/m68000.h"
2424
2525#include "devices/cartslot.h"
src/mess/machine/smc92x4.c
r8395r8396
1616*/
1717
1818#include "emu.h"
19#include "utils.h"
19#include "imageutl.h"
2020#include "devices/flopdrv.h"
2121#include "devices/harddriv.h"
2222#include "harddisk.h"
src/mess/video/vic4567.c
r8395r8396
1414***************************************************************************/
1515
1616#include "emu.h"
17#include "utils.h"
1817#include "video/vic4567.h"
1918
2019#define SPRITE_BASE_X_SIZE      24
r8395r8396
673672   }
674673}
675674
675#ifndef memset16
676static void *memset16 (void *dest, int value, size_t size)
677{
678   register int i;
679
680   for (i = 0; i < size; i++)
681      ((short *) dest)[i] = value;
682   return dest;
683}
684#endif
685
676686static void vic3_drawlines( running_device *device, int first, int last, int start_x, int end_x )
677687{
678688   vic3_state *vic3 = get_safe_token(device);
src/mess/formats/coco_dsk.c
r8395r8396
1313#include "osdepend.h"
1414#include "formats/coco_dsk.h"
1515#include "formats/basicdsk.h"
16#include "utils.h"
16#include "imageutl.h"
1717
1818/* -----------------------------------------------------------------------
1919 * JVC (Jeff Vavasour CoCo) format
src/mess/formats/flopimg.c
r8395r8396
1616#include "osdepend.h"
1717#include "formats/flopimg.h"
1818#include "pool.h"
19#include "utils.h"
19#include "imageutl.h"
2020
2121#define TRACK_LOADED      0x01
2222#define TRACK_DIRTY         0x02
src/mess/formats/apridisk.c
r8395r8396
55***************************************************************************/
66
77#include "apridisk.h"
8#include "utils.h"
8#include "imageutl.h"
99
1010/***************************************************************************
1111    CONSTANTS
src/mess/formats/atom_atm.c
r8395r8396
77*********************************************************************/
88
99#include "emu.h"
10#include "utils.h"
10#include "imageutl.h"
1111#include "formats/atom_atm.h"
1212
1313/***************************************************************************
src/mess/formats/dsk_dsk.c
r8395r8396
99#include <string.h>
1010
1111#include "emu.h"
12#include "utils.h"
12#include "imageutl.h"
1313#include "formats/flopimg.h"
1414#include "devices/flopdrv.h"
1515
src/mess/formats/cassimg.c
r8395r8396
1010#include <string.h>
1111
1212#include "emu.h"
13#include "utils.h"
13#include "imageutl.h"
1414#include "pool.h"
1515#include "formats/cassimg.h"
1616
src/mess/formats/z80ne_dsk.c
r8395r8396
1010#include "formats/z80ne_dsk.h"
1111#include "formats/basicdsk.h"
1212#include "devices/flopdrv.h"
13#include "utils.h"
13#include "imageutl.h"
1414
1515/* -----------------------------------------------------------------------
1616 * DMK file format
src/mess/formats/ti99_dsk.c
r8395r8396
7777#include <time.h>
7878
7979#include "osdepend.h"
80#include "imageutl.h"
8081#include "formats/ti99_dsk.h"
81#include "utils.h"
8282
8383#define SECTOR_SIZE 256
8484#define TI99_IDAM_LENGTH 7
src/mess/formats/fdi_dsk.c
r8395r8396
1515*/
1616
1717#include "emu.h"
18#include "utils.h"
18#include "imageutl.h"
1919#include "formats/flopimg.h"
2020#include "devices/flopdrv.h"
2121
src/mess/formats/spec_snqk.c
r8395r8396
3030#include "includes/spectrum.h"
3131#include "sound/ay8910.h"
3232#include "formats/spec_snqk.h"
33#include "utils.h"
3433
3534
3635/*******************************************************************
src/mess/formats/comx35_comx.c
r8395r8396
77*********************************************************************/
88
99#include "emu.h"
10#include "utils.h"
10#include "imageutl.h"
1111#include "formats/comx35_comx.h"
1212#include "cpu/cdp1802/cdp1802.h"
1313#include "devices/messram.h"
src/mess/formats/timex_dck.c
r8395r8396
2626#include "emu.h"
2727#include "formats/timex_dck.h"
2828#include "sound/ay8910.h"
29#include "utils.h"
3029
3130
3231int timex_cart_type;
src/mess/formats/oric_dsk.c
r8395r8396
99#include <string.h>
1010
1111#include "emu.h"
12#include "utils.h"
12#include "imageutl.h"
1313#include "formats/oric_dsk.h"
1414#include "formats/basicdsk.h"
1515#include "devices/flopdrv.h"
src/mess/drivers/vtech1.c
r8395r8396
112112******************************************************************************/
113113
114114#include "emu.h"
115#include "utils.h"
115#include "imageutl.h"
116116#include "cpu/z80/z80.h"
117117#include "video/m6847.h"
118118#include "machine/ctronics.h"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team