Previous 15994 Revisions Next

r2215 Wednesday 2nd April, 2008 at 11:44:03 UTC by Nathan Woods
image.c cleanups
[src/mess]image.c image.h

src/mess/image.c
r2214r2215
8989static void image_exit(running_machine *machine);
9090static void image_clear(image_slot_data *image);
9191static void image_clear_error(image_slot_data *image);
92static void image_unload_internal(image_slot_data *slot);
9293
9394
9495
r2214r2215
111112    image_init - initialize the core image system
112113-------------------------------------------------*/
113114
114int image_init(running_machine *machine)
115void image_init(running_machine *machine)
115116{
116117   int count, indx;
117118   UINT32 mask, dev_mask = 0, multiple_dev_mask = 0;
r2214r2215
174175      indx++;
175176   }
176177
178   /* add a callback for when we shut down */
177179   add_exit_callback(machine, image_exit);
178   return INIT_PASS;
179180}
180181
181182
r2214r2215
191192
192193   if (machine->images_data != NULL)
193194   {
194      /* unload all devices */
195      image_unload_all(FALSE);
196      image_unload_all(TRUE);
195      /* extract the options */
196      mess_options_extract(machine);
197197
198198      for (i = 0; i < machine->images_data->slot_count; i++)
199199      {
200200         /* identify the image slot */
201201         slot = &machine->images_data->slots[i];
202202
203         /* unload this image */
204         image_unload_internal(slot);
205
203206         /* free the working directory */
204207         if (slot->working_directory != NULL)
205208         {
r2214r2215
806809   images
807810-------------------------------------------------*/
808811
809static void image_unload_internal(image_slot_data *image, int is_final_unload)
812static void image_unload_internal(image_slot_data *slot)
810813{
811   const struct IODevice *iodev;
812
813814   /* is there an actual image loaded? */
814   if (!is_loaded(image))
815      return;
815   if (is_loaded(slot))
816   {
817      /* call the unload function */
818      if (slot->unload != NULL)
819         slot->unload(slot->dev);
816820
817   /* call the unload function */
818   iodev = mess_device_from_core_device(image->dev);
819   if (image->unload != NULL)
820      image->unload(image->dev);
821
822   image_clear(image);
823   image_clear_error(image);
821      image_clear(slot);
822      image_clear_error(slot);
823   }
824824}
825825
826826
r2214r2215
832832void image_unload(const device_config *image)
833833{
834834   image_slot_data *slot = find_image_slot(image);
835   image_unload_internal(slot, FALSE);
835   image_unload_internal(slot);
836836}
837837
838838
839839
840/*-------------------------------------------------
841    image_unload_all - unload all images
842-------------------------------------------------*/
843
844void image_unload_all(int ispreload)
845{
846   int i;
847   image_slot_data *slot;
848   const struct IODevice *iodev;
849
850   if (!ispreload)
851      mess_options_extract(Machine);
852
853   /* normalize ispreload */
854   ispreload = ispreload ? 1 : 0;
855
856   /* unload all devices with matching preload */
857   for (i = 0; i < Machine->images_data->slot_count; i++)
858   {
859      slot = &Machine->images_data->slots[i];
860      iodev = mess_device_from_core_device(slot->dev);
861
862      if (iodev->load_at_init == ispreload)
863      {
864         /* unload this image */
865         image_unload_internal(slot, TRUE);
866      }
867   }
868}
869
870
871
872840/****************************************************************************
873841    ERROR HANDLING
874842****************************************************************************/
src/mess/image.h
r2214r2215
6161/* ----- core implementation ----- */
6262
6363/* core initialization */
64int image_init(running_machine *machine);
64void image_init(running_machine *machine);
6565
6666
6767/* ----- image device enumeration ----- */
r2214r2215
9393/* used to retrieve error information during image loading */
9494const char *image_error(const device_config *img);
9595
96/* used for driver init and machine init */
97void image_unload_all(int ispreload);
98
9996/* used to set the error that occured during image loading */
10097void image_seterror(const device_config *img, image_error_t err, const char *message);
10198

Previous 15994 Revisions Next


© 1998-2018 The MESS Team