src/mess/machine/990_tap.c
| r14701 | r14702 | |
| 130 | 130 | return (tap_990_t *)downcast<legacy_device_base *>(device)->token(); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | | static DEVICE_START( ti990_tape ) |
| 134 | | { |
| 135 | | tape_unit_t *t; |
| 136 | | tap_990_t *tpc = get_safe_token(device->owner()); |
| 137 | | int id = tape_get_id(device); |
| 138 | 133 | |
| 139 | | t = &tpc->t[id]; |
| 140 | | memset(t, 0, sizeof(*t)); |
| 141 | | |
| 142 | | t->img = dynamic_cast<device_image_interface *>(device); |
| 143 | | t->wp = 1; |
| 144 | | t->bot = 0; |
| 145 | | t->eot = 0; |
| 146 | | } |
| 147 | | |
| 148 | 134 | /* |
| 149 | | Open a tape image |
| 150 | | */ |
| 151 | | static DEVICE_IMAGE_LOAD( ti990_tape ) |
| 152 | | { |
| 153 | | tape_unit_t *t; |
| 154 | | tap_990_t *tpc = get_safe_token(image.device().owner()); |
| 155 | | int id = tape_get_id(&image.device()); |
| 156 | | |
| 157 | | t = &tpc->t[id]; |
| 158 | | memset(t, 0, sizeof(*t)); |
| 159 | | |
| 160 | | /* tell whether the image is writable */ |
| 161 | | t->wp = image.is_readonly(); |
| 162 | | |
| 163 | | t->bot = 1; |
| 164 | | |
| 165 | | return IMAGE_INIT_PASS; |
| 166 | | } |
| 167 | | |
| 168 | | /* |
| 169 | | Close a tape image |
| 170 | | */ |
| 171 | | static DEVICE_IMAGE_UNLOAD( ti990_tape ) |
| 172 | | { |
| 173 | | tape_unit_t *t; |
| 174 | | tap_990_t *tpc = get_safe_token(image.device().owner()); |
| 175 | | int id = tape_get_id(&image.device()); |
| 176 | | |
| 177 | | t = &tpc->t[id]; |
| 178 | | t->wp = 1; |
| 179 | | t->bot = 0; |
| 180 | | t->eot = 0; |
| 181 | | } |
| 182 | | |
| 183 | | /* |
| 184 | 135 | Parse the tape select lines, and return the corresponding tape unit. |
| 185 | 136 | (-1 if none) |
| 186 | 137 | */ |
| r14701 | r14702 | |
| 993 | 944 | } |
| 994 | 945 | } |
| 995 | 946 | |
| 996 | | DEVICE_GET_INFO( ti990_tape ) |
| 947 | class ti990_tape_image_device : public device_t, |
| 948 | public device_image_interface |
| 997 | 949 | { |
| 998 | | switch (state) |
| 999 | | { |
| 1000 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1001 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 1002 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ti990_tape_t); break; |
| 1003 | | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_MAGTAPE; break; |
| 1004 | | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 1005 | | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 1006 | | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 0; break; |
| 950 | public: |
| 951 | // construction/destruction |
| 952 | ti990_tape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 1007 | 953 | |
| 1008 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1009 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ti990_tape); break; |
| 1010 | | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(ti990_tape); break; |
| 1011 | | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(ti990_tape); break; |
| 954 | // image-level overrides |
| 955 | virtual iodevice_t image_type() const { return IO_MAGTAPE; } |
| 1012 | 956 | |
| 1013 | | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, "tap"); break; |
| 1014 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1015 | | case DEVINFO_STR_NAME: strcpy(info->s, "TI990 Magnetic Tape"); break; |
| 1016 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Magnetic Tape"); break; |
| 1017 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1018 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1019 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 1020 | | } |
| 957 | virtual bool is_readable() const { return 1; } |
| 958 | virtual bool is_writeable() const { return 1; } |
| 959 | virtual bool is_creatable() const { return 1; } |
| 960 | virtual bool must_be_loaded() const { return 0; } |
| 961 | virtual bool is_reset_on_load() const { return 0; } |
| 962 | virtual const char *image_interface() const { return NULL; } |
| 963 | virtual const char *file_extensions() const { return "tap"; } |
| 964 | virtual const option_guide *create_option_guide() const { return NULL; } |
| 965 | |
| 966 | virtual bool call_load(); |
| 967 | virtual void call_unload(); |
| 968 | protected: |
| 969 | // device-level overrides |
| 970 | virtual void device_config_complete(); |
| 971 | virtual void device_start(); |
| 972 | }; |
| 973 | |
| 974 | // device type definition |
| 975 | extern const device_type TI990_TAPE; |
| 976 | |
| 977 | const device_type TI990_TAPE = &device_creator<ti990_tape_image_device>; |
| 978 | |
| 979 | ti990_tape_image_device::ti990_tape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 980 | : device_t(mconfig, TI990_TAPE, "TI990 Magnetic Tape", tag, owner, clock), |
| 981 | device_image_interface(mconfig, *this) |
| 982 | { |
| 1021 | 983 | } |
| 1022 | | DECLARE_LEGACY_IMAGE_DEVICE(TI990_TAPE, ti990_tape); |
| 1023 | | DEFINE_LEGACY_IMAGE_DEVICE(TI990_TAPE, ti990_tape); |
| 1024 | 984 | |
| 985 | void ti990_tape_image_device::device_config_complete() |
| 986 | { |
| 987 | update_names(); |
| 988 | } |
| 989 | |
| 990 | void ti990_tape_image_device::device_start() |
| 991 | { |
| 992 | tape_unit_t *t; |
| 993 | tap_990_t *tpc = get_safe_token(owner()); |
| 994 | int id = tape_get_id(this); |
| 995 | |
| 996 | t = &tpc->t[id]; |
| 997 | memset(t, 0, sizeof(*t)); |
| 998 | |
| 999 | t->img = this; |
| 1000 | t->wp = 1; |
| 1001 | t->bot = 0; |
| 1002 | t->eot = 0; |
| 1003 | } |
| 1004 | |
| 1005 | /* |
| 1006 | Open a tape image |
| 1007 | */ |
| 1008 | bool ti990_tape_image_device::call_load() |
| 1009 | { |
| 1010 | tape_unit_t *t; |
| 1011 | tap_990_t *tpc = get_safe_token(owner()); |
| 1012 | int id = tape_get_id(this); |
| 1013 | |
| 1014 | t = &tpc->t[id]; |
| 1015 | memset(t, 0, sizeof(*t)); |
| 1016 | |
| 1017 | /* tell whether the image is writable */ |
| 1018 | t->wp = is_readonly(); |
| 1019 | |
| 1020 | t->bot = 1; |
| 1021 | |
| 1022 | return IMAGE_INIT_PASS; |
| 1023 | } |
| 1024 | |
| 1025 | /* |
| 1026 | Close a tape image |
| 1027 | */ |
| 1028 | void ti990_tape_image_device::call_unload() |
| 1029 | { |
| 1030 | tape_unit_t *t; |
| 1031 | tap_990_t *tpc = get_safe_token(owner()); |
| 1032 | int id = tape_get_id(this); |
| 1033 | |
| 1034 | t = &tpc->t[id]; |
| 1035 | t->wp = 1; |
| 1036 | t->bot = 0; |
| 1037 | t->eot = 0; |
| 1038 | } |
| 1039 | |
| 1025 | 1040 | #define MCFG_TI990_TAPE_ADD(_tag) \ |
| 1026 | 1041 | MCFG_DEVICE_ADD((_tag), TI990_TAPE, 0) |
| 1027 | 1042 | |