src/mess/image.c
| r2214 | r2215 | |
| 89 | 89 | static void image_exit(running_machine *machine); |
| 90 | 90 | static void image_clear(image_slot_data *image); |
| 91 | 91 | static void image_clear_error(image_slot_data *image); |
| 92 | static void image_unload_internal(image_slot_data *slot); |
| 92 | 93 | |
| 93 | 94 | |
| 94 | 95 | |
| r2214 | r2215 | |
| 111 | 112 | image_init - initialize the core image system |
| 112 | 113 | -------------------------------------------------*/ |
| 113 | 114 | |
| 114 | | int image_init(running_machine *machine) |
| 115 | void image_init(running_machine *machine) |
| 115 | 116 | { |
| 116 | 117 | int count, indx; |
| 117 | 118 | UINT32 mask, dev_mask = 0, multiple_dev_mask = 0; |
| r2214 | r2215 | |
| 174 | 175 | indx++; |
| 175 | 176 | } |
| 176 | 177 | |
| 178 | /* add a callback for when we shut down */ |
| 177 | 179 | add_exit_callback(machine, image_exit); |
| 178 | | return INIT_PASS; |
| 179 | 180 | } |
| 180 | 181 | |
| 181 | 182 | |
| r2214 | r2215 | |
| 191 | 192 | |
| 192 | 193 | if (machine->images_data != NULL) |
| 193 | 194 | { |
| 194 | | /* unload all devices */ |
| 195 | | image_unload_all(FALSE); |
| 196 | | image_unload_all(TRUE); |
| 195 | /* extract the options */ |
| 196 | mess_options_extract(machine); |
| 197 | 197 | |
| 198 | 198 | for (i = 0; i < machine->images_data->slot_count; i++) |
| 199 | 199 | { |
| 200 | 200 | /* identify the image slot */ |
| 201 | 201 | slot = &machine->images_data->slots[i]; |
| 202 | 202 | |
| 203 | /* unload this image */ |
| 204 | image_unload_internal(slot); |
| 205 | |
| 203 | 206 | /* free the working directory */ |
| 204 | 207 | if (slot->working_directory != NULL) |
| 205 | 208 | { |
| r2214 | r2215 | |
| 806 | 809 | images |
| 807 | 810 | -------------------------------------------------*/ |
| 808 | 811 | |
| 809 | | static void image_unload_internal(image_slot_data *image, int is_final_unload) |
| 812 | static void image_unload_internal(image_slot_data *slot) |
| 810 | 813 | { |
| 811 | | const struct IODevice *iodev; |
| 812 | | |
| 813 | 814 | /* 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); |
| 816 | 820 | |
| 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 | } |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | |
| r2214 | r2215 | |
| 832 | 832 | void image_unload(const device_config *image) |
| 833 | 833 | { |
| 834 | 834 | image_slot_data *slot = find_image_slot(image); |
| 835 | | image_unload_internal(slot, FALSE); |
| 835 | image_unload_internal(slot); |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | |
| 839 | 839 | |
| 840 | | /*------------------------------------------------- |
| 841 | | image_unload_all - unload all images |
| 842 | | -------------------------------------------------*/ |
| 843 | | |
| 844 | | void 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 | | |
| 872 | 840 | /**************************************************************************** |
| 873 | 841 | ERROR HANDLING |
| 874 | 842 | ****************************************************************************/ |
src/mess/image.h
| r2214 | r2215 | |
| 61 | 61 | /* ----- core implementation ----- */ |
| 62 | 62 | |
| 63 | 63 | /* core initialization */ |
| 64 | | int image_init(running_machine *machine); |
| 64 | void image_init(running_machine *machine); |
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | /* ----- image device enumeration ----- */ |
| r2214 | r2215 | |
| 93 | 93 | /* used to retrieve error information during image loading */ |
| 94 | 94 | const char *image_error(const device_config *img); |
| 95 | 95 | |
| 96 | | /* used for driver init and machine init */ |
| 97 | | void image_unload_all(int ispreload); |
| 98 | | |
| 99 | 96 | /* used to set the error that occured during image loading */ |
| 100 | 97 | void image_seterror(const device_config *img, image_error_t err, const char *message); |
| 101 | 98 | |