Previous 15994 Revisions Next

r2141 Saturday 29th March, 2008 at 14:46:16 UTC by Nathan Woods
Miscellaneous cleanups; moved private data associated with images into a private
data structure hanging off of running_machine. Cleaned up various #include-s
[src/emu]mame.h
[src/mess]cheatms.c image.c image.h mesvalid.c
[src/mess/devices]appldriv.h cassette.c chd_cd.c harddriv.c mflopimg.c
[src/mess/drivers]ql.c
[src/mess/formats]zx81_p.c
[src/mess/osd/windows]tapedlg.c
[src/mess/tools/imgtool]filteoln.c filter.c iflopimg.c imgtool.h main.c stream.c
[src/mess/tools/imgtool/modules]thomson.c
[src/mess/tools/imgtool/windows]wimgtool.c
[src/mess/video]zx8301.c zx8301.h

src/emu/mame.h
r2140r2141
2020#include <stdarg.h>
2121
2222#ifdef MESS
23#include "device.h"
23#include "image.h"
2424#endif /* MESS */
2525
2626
r2140r2141
203203   palette_private *      palette_data;      /* internal data from palette.c */
204204   streams_private *      streams_data;      /* internal data from streams.c */
205205   devices_private *      devices_data;      /* internal data from devices.c */
206#ifdef MESS
207   images_private *      images_data;      /* internal data from image.c */
208#endif /* MESS */
206209
207210   /* driver-specific information */
208211   void *               driver_data;      /* drivers can hang data off of here instead of using globals */
src/mess/devices/harddriv.c
r2140r2141
1515
1616*********************************************************************/
1717
18#include "mame.h"
1819#include "harddisk.h"
1920#include "harddriv.h"
2021
src/mess/devices/cassette.c
r2140r2141
66
77*********************************************************************/
88
9#include "mame.h"
910#include "cassette.h"
1011#include "formats/cassimg.h"
1112#include "ui.h"
src/mess/devices/chd_cd.c
r2140r2141
66
77*********************************************************************/
88
9#include "mame.h"
910#include "cdrom.h"
1011#include "chd_cd.h"
1112
src/mess/devices/mflopimg.c
r2140r2141
66
77*********************************************************************/
88
9#include "utils.h"
9#include "mame.h"
1010#include "mflopimg.h"
1111#include "flopdrv.h"
1212#include "formats/flopimg.h"
src/mess/devices/appldriv.h
r2140r2141
99#ifndef APPLDRIV_H
1010#define APPLDRIV_H
1111
12#include "device.h"
13#include "image.h"
12#include "mame.h"
1413
1514
1615enum
src/mess/tools/imgtool/iflopimg.c
r2140r2141
66
77*********************************************************************/
88
9#include "mame.h"
910#include "formats/flopimg.h"
1011#include "imgtoolx.h"
1112#include "library.h"
src/mess/tools/imgtool/windows/wimgtool.c
r2140r2141
2020#include "winutf8.h"
2121#include "winutil.h"
2222#include "winutils.h"
23#include "mame.h"
2324
2425const TCHAR wimgtool_class[] = TEXT("wimgtool_class");
2526const char wimgtool_producttext[] = "MESS Image Tool";
src/mess/tools/imgtool/filteoln.c
r2140r2141
77*****************************************************************************/
88
99#include <string.h>
10
1011#include "imgtool.h"
1112
1213#define EOLN (CRLF == 1 ? "\r" : (CRLF == 2 ? "\n" : (CRLF == 3 ? "\r\n" : NULL)))
src/mess/tools/imgtool/imgtool.h
r2140r2141
1111
1212#include <stdlib.h>
1313#include <stdio.h>
14
1415#include "osdepend.h"
15#include "mess.h"
16#include "mame.h"
1617#include "formats/flopimg.h"
1718#include "opresolv.h"
1819#include "library.h"
src/mess/tools/imgtool/main.c
r2140r2141
1212#include <stdlib.h>
1313#include <time.h>
1414#include <assert.h>
15
16#include "mame.h"
1517#include "imgtool.h"
1618#include "mess.h"
1719#include "main.h"
src/mess/tools/imgtool/filter.c
r2140r2141
88
99#include <assert.h>
1010#include <string.h>
11
1112#include "imgtool.h"
1213#include "utils.h"
1314
src/mess/tools/imgtool/modules/thomson.c
r2140r2141
257257    int size = f->heads * f->tracks * 16 * f->sector_size;
258258    stream_seek( f->stream, 0, SEEK_SET );
259259    if ( stream_write( f->stream, f->data, size ) < size )
260      logerror( "thom_diskimage_close_fd_qd: write error\n" );
260   {
261      /* logerror( "thom_diskimage_close_fd_qd: write error\n" ); */
262   }
261263  }
262264
263265  stream_close( f->stream );
r2140r2141
386388
387389    /* image header */
388390    if ( stream_write( f->stream, sap_header, 66 ) < 66 ) {
389      logerror( "thom_diskimage_close_sap: write error\n" );
391      /* logerror( "thom_diskimage_close_sap: write error\n" ); */
390392      return;
391393    }
392394
r2140r2141
412414   /* save */
413415   if ( stream_write( f->stream, buf, f->sector_size + 6 ) <
414416        f->sector_size + 6 ) {
415     logerror( "thom_diskimage_close_sap: write error\n" );
417     /* logerror( "thom_diskimage_close_sap: write error\n" ); */
416418     return;
417419   }
418420      }
src/mess/tools/imgtool/stream.c
r2140r2141
1111#include <zlib.h>
1212#include <assert.h>
1313
14#include "mame.h"
1415#include "unzip.h"
1516#include "osdcore.h"
1617#include "imgtool.h"
src/mess/image.c
r2140r2141
1212
1313#include <ctype.h>
1414
15#include "mame.h"
1516#include "image.h"
1617#include "mess.h"
1718#include "deprecat.h"
r2140r2141
6869
6970
7071
71/***************************************************************************
72    GLOBAL VARIABLES
73***************************************************************************/
72struct _images_private
73{
74   UINT32 multiple_dev_mask;
75   mess_image images[1];
76};
7477
75static mess_image *images;
76static UINT32 multiple_dev_mask;
7778
7879
79
8080/***************************************************************************
8181    FUNCTION PROTOTYPES
8282***************************************************************************/
r2140r2141
110110{
111111   int err;
112112   int count, indx;
113   UINT32 mask, dev_mask = 0;
113   UINT32 mask, dev_mask = 0, multiple_dev_mask = 0;
114114   const struct IODevice *dev;
115   size_t private_size;
115116
116   /* setup the globals */
117   images = NULL;
118   multiple_dev_mask = 0;
119
120117   /* first count all images, and identify multiply defined devices */
121118   count = 0;
122119   for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev))
r2140r2141
136133      count++;
137134   }
138135
139   /* allocate the array */
140   if (count > 0)
141   {
142      images = auto_malloc(count * sizeof(*images));
143      memset(images, 0, count * sizeof(*images));
144   }
136   /* allocate the private structure */
137   private_size = sizeof(*machine->images_data) + ((count - 1)
138      * sizeof(machine->images_data->images[0]));
139   machine->images_data = (images_private *) auto_malloc(private_size);
140   memset(machine->images_data, '\0', private_size);
145141
142   /* some setup */
143   machine->images_data->multiple_dev_mask = multiple_dev_mask;
144
146145   /* initialize the devices */
147146   indx = 0;
148147   for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev))
149148   {
150      images[indx].mempool = pool_alloc(memory_error);
149      machine->images_data->images[indx].mempool = pool_alloc(memory_error);
151150
152151      /* setup the device */
153      tagpool_init(&images[indx].tagpool);
154      images[indx].dev = dev;
152      tagpool_init(&machine->images_data->images[indx].tagpool);
153      machine->images_data->images[indx].dev = dev;
155154
156155      if (dev->init != NULL)
157156      {
158         err = dev->init(&images[indx]);
157         err = dev->init(&machine->images_data->images[indx]);
159158         if (err != INIT_PASS)
160159            return err;
161160      }
r2140r2141
178177   mess_image *image;
179178   const struct IODevice *dev;
180179
181   /* unload all devices */
182   image_unload_all(FALSE);
183   image_unload_all(TRUE);
180   if (machine->images_data != NULL)
181   {
182      /* unload all devices */
183      image_unload_all(FALSE);
184      image_unload_all(TRUE);
184185
185   indx = 0;
186      indx = 0;
186187
187   for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev))
188   {
189      /* identify the image */
190      image = &images[indx];
188      for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev))
189      {
190         /* identify the image */
191         image = &machine->images_data->images[indx];
191192
192      /* call the exit handler if appropriate */
193      if (dev->exit != NULL)
194         dev->exit(image);
193         /* call the exit handler if appropriate */
194         if (dev->exit != NULL)
195            dev->exit(image);
195196
196      /* free the tagpool */
197      tagpool_exit(&images[indx].tagpool);
197         /* free the tagpool */
198         tagpool_exit(&image->tagpool);
198199
199      /* free the working directory */
200      if (image->working_directory != NULL)
201      {
202         free(image->working_directory);
203         image->working_directory = NULL;
200         /* free the working directory */
201         if (image->working_directory != NULL)
202         {
203            free(image->working_directory);
204            image->working_directory = NULL;
205         }
206
207         /* free the memory pool */
208         pool_free(image->mempool);
209         image->mempool = NULL;
210         indx++;
204211      }
205212
206      /* free the memory pool */
207      pool_free(image->mempool);
208      image->mempool = NULL;
209      indx++;
213      machine->images_data = NULL;
210214   }
211215}
212216
r2140r2141
15661570
15671571int image_absolute_index(mess_image *image)
15681572{
1569   return image - images;
1573   return image - Machine->images_data->images;
15701574}
15711575
15721576
15731577
15741578mess_image *image_from_absolute_index(int absolute_index)
15751579{
1576   return &images[absolute_index];
1580   return &Machine->images_data->images[absolute_index];
15771581}
15781582
15791583
r2140r2141
15991603   {
16001604      if (device == dev)
16011605      {
1602         image = &images[indx];
1606         image = &Machine->images_data->images[indx];
16031607         break;
16041608      }
16051609      indx++;
r2140r2141
16241628   {
16251629      if (dev->tag && !strcmp(dev->tag, devtag) && (device_index++ == id))
16261630      {
1627         image = &images[indx];
1631         image = &Machine->images_data->images[indx];
16281632         break;
16291633      }
16301634      indx++;
r2140r2141
16521656   {
16531657      if ((type == dev->type) && (device_index++ == id))
16541658      {
1655         image = &images[indx];
1659         image = &Machine->images_data->images[indx];
16561660         break;
16571661      }
16581662      indx++;
src/mess/video/zx8301.c
r2140r2141
44 *
55 ****************************************************************************/
66
7#include "driver.h"
7#include "mame.h"
88#include "zx8301.h"
99
1010
src/mess/video/zx8301.h
r2140r2141
77#ifndef ZX8301_H_
88#define ZX8301_H_
99
10#include "mame.h"
11#include "driver.h"
1012
13
1114/*----------- defined in video/zx8301.c -----------*/
1215
1316WRITE8_HANDLER( zx8301_control_w );
src/mess/image.h
r2140r2141
1313#include "fileio.h"
1414#include "utils.h"
1515#include "opresolv.h"
16#include "device.h"
17#include "osdmess.h"
1618
1719typedef enum
1820{
r2140r2141
2628   IMAGE_ERROR_UNSPECIFIED
2729} image_error_t;
2830
31struct _images_private;
32typedef struct _images_private images_private;
2933
3034
35
3136/****************************************************************************
3237  A mess_image pointer represents one device entry; this could be an instance
3338  of a floppy drive or a printer.  The defining property is that either at
src/mess/mesvalid.c
r2140r2141
88
99#include <ctype.h>
1010
11#include "mame.h"
1112#include "mess.h"
1213#include "device.h"
1314#include "inputx.h"
src/mess/osd/windows/tapedlg.c
r2140r2141
1010#include <commctrl.h>
1111
1212// MAME/MESS headers
13#include "mame.h"
1314#include "tapedlg.h"
1415#include "mess.h"
1516#include "messres.h"
src/mess/cheatms.c
r2140r2141
1/****************************************************************************
2
3   cheatms.c
4
5   MESS sepcific cheat code
6
7****************************************************************************/
8
9
10#include "mame.h"
111#include "mess.h"
212#include "image.h"
313#include "cheatms.h"
r2140r2141
212
13
14/***************************************************************************
15    GLOBALS
16***************************************************************************/
17
318static UINT32            * deviceCRCList = NULL;
r2140r2141
823
924
1025
26/***************************************************************************
27    CODE
28***************************************************************************/
29
1130static void BuildCRCTable(void)
1231{
1332   int   deviceType, deviceID, listIdx;
src/mess/formats/zx81_p.c
r2140r2141
2929
3030*****************************************************************************/
3131
32#include "image.h"
32#include "mame.h"
3333#include "zx81_p.h"
3434#include "osdepend.h"
3535#include "devices/cassette.h"
src/mess/drivers/ql.c
r2140r2141
1#include "driver.h"
1#include "mame.h"
22#include "cpu/i8039/i8039.h"
33#include "cpu/m68000/m68000.h"
44#include "devices/cartslot.h"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team