src/mess/machine/sc499.c
| r14697 | r14698 | |
| 148 | 148 | #define SC499_TIMER_6 6 |
| 149 | 149 | #define SC499_TIMER_7 7 |
| 150 | 150 | |
| 151 | | typedef struct _ctape_data ctape_data; |
| 152 | | struct _ctape_data |
| 153 | | { |
| 154 | | device_image_interface *image; |
| 155 | | }; |
| 156 | 151 | |
| 157 | 152 | /*************************************************************************** |
| 158 | 153 | IMPLEMENTATION |
| r14697 | r14698 | |
| 196 | 191 | m_timer1 = m_device->machine().scheduler().timer_alloc(FUNC(static_timer_func), this); |
| 197 | 192 | |
| 198 | 193 | device_t *ctape_device = machine().device(SC499_CTAPE_TAG); |
| 199 | | ctape_data *ctape = (ctape_data *) downcast<legacy_device_base *> (ctape_device)->token(); |
| 200 | | m_image = ctape->image; |
| 194 | m_image = dynamic_cast<device_image_interface *> (ctape_device); |
| 201 | 195 | |
| 202 | 196 | if (m_image->image_core_file() == NULL) |
| 203 | 197 | { |
| r14697 | r14698 | |
| 1144 | 1138 | } |
| 1145 | 1139 | |
| 1146 | 1140 | //########################################################################## |
| 1147 | | |
| 1148 | | DECLARE_LEGACY_IMAGE_DEVICE(SC499_CTAPE, sc499_ctape); |
| 1149 | | |
| 1150 | | /*------------------------------------------------- |
| 1151 | | ctape device start callback |
| 1152 | | -------------------------------------------------*/ |
| 1153 | | |
| 1154 | | static DEVICE_START( sc499_ctape ) |
| 1141 | class sc499_ctape_image_device : public device_t, |
| 1142 | public device_image_interface |
| 1155 | 1143 | { |
| 1156 | | assert(device != NULL); |
| 1157 | | assert(device->type() == SC499_CTAPE); |
| 1158 | | ctape_data *ctape = (ctape_data *) downcast<legacy_device_base *>(device)->token(); |
| 1144 | public: |
| 1145 | // construction/destruction |
| 1146 | sc499_ctape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 1159 | 1147 | |
| 1160 | | ctape->image = dynamic_cast<device_image_interface *> (device); |
| 1161 | | } |
| 1148 | // image-level overrides |
| 1149 | virtual iodevice_t image_type() const { return IO_MAGTAPE; } |
| 1162 | 1150 | |
| 1163 | | /*------------------------------------------------- |
| 1164 | | ctape device get info callback |
| 1165 | | -------------------------------------------------*/ |
| 1151 | virtual bool is_readable() const { return 1; } |
| 1152 | virtual bool is_writeable() const { return 1; } |
| 1153 | virtual bool is_creatable() const { return 1; } |
| 1154 | virtual bool must_be_loaded() const { return 0; } |
| 1155 | virtual bool is_reset_on_load() const { return 0; } |
| 1156 | virtual const char *image_interface() const { return NULL; } |
| 1157 | virtual const char *file_extensions() const { return "act"; } |
| 1158 | virtual const option_guide *create_option_guide() const { return NULL; } |
| 1159 | protected: |
| 1160 | // device-level overrides |
| 1161 | virtual void device_config_complete(); |
| 1162 | virtual void device_start() { }; |
| 1163 | }; |
| 1166 | 1164 | |
| 1167 | | DEVICE_GET_INFO( sc499_ctape ) |
| 1168 | | { |
| 1169 | | switch (state) |
| 1170 | | { |
| 1171 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1172 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ctape_data); break; |
| 1173 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 1174 | | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_MAGTAPE; break; |
| 1175 | | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 1176 | | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 1177 | | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 1; break; |
| 1165 | // device type definition |
| 1166 | extern const device_type SC499_CTAPE; |
| 1178 | 1167 | |
| 1179 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1180 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(sc499_ctape); break; |
| 1168 | const device_type SC499_CTAPE = &device_creator<sc499_ctape_image_device>; |
| 1181 | 1169 | |
| 1182 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1183 | | case DEVINFO_STR_NAME: strcpy(info->s, "Cartridge Tape"); break; |
| 1184 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Cartridge Tape"); break; |
| 1185 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1186 | | |
| 1187 | | case DEVINFO_STR_IMAGE_INSTANCE_NAME: strcpy(info->s, "ctape"); break; |
| 1188 | | case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME: strcpy(info->s, "ct"); break; |
| 1189 | | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, "act"); break; |
| 1190 | | } |
| 1170 | sc499_ctape_image_device::sc499_ctape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 1171 | : device_t(mconfig, SC499_CTAPE, "Cartridge Tape", tag, owner, clock), |
| 1172 | device_image_interface(mconfig, *this) |
| 1173 | { |
| 1191 | 1174 | } |
| 1192 | 1175 | |
| 1193 | | DEFINE_LEGACY_IMAGE_DEVICE(SC499_CTAPE, sc499_ctape); |
| 1176 | void sc499_ctape_image_device::device_config_complete() |
| 1177 | { |
| 1178 | update_names(SC499_CTAPE, "ctape", "ct"); |
| 1179 | }; |
| 1194 | 1180 | |
| 1195 | 1181 | MACHINE_CONFIG_FRAGMENT( sc499_ctape ) |
| 1196 | 1182 | MCFG_DEVICE_ADD(SC499_CTAPE_TAG, SC499_CTAPE, 0) |
src/mess/machine/omti8621.c
| r14697 | r14698 | |
| 1198 | 1198 | DEFINE_LEGACY_DEVICE(OMTI8621, omti8621); |
| 1199 | 1199 | |
| 1200 | 1200 | //########################################################################## |
| 1201 | class omti_disk_image_device : public device_t, |
| 1202 | public device_image_interface |
| 1203 | { |
| 1204 | public: |
| 1205 | // construction/destruction |
| 1206 | omti_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 1201 | 1207 | |
| 1202 | | DECLARE_LEGACY_IMAGE_DEVICE(OMTI_DISK0, omti_disk0); |
| 1203 | | DECLARE_LEGACY_IMAGE_DEVICE(OMTI_DISK1, omti_disk1); |
| 1208 | // image-level overrides |
| 1209 | virtual iodevice_t image_type() const { return IO_HARDDISK; } |
| 1204 | 1210 | |
| 1211 | virtual bool is_readable() const { return 1; } |
| 1212 | virtual bool is_writeable() const { return 1; } |
| 1213 | virtual bool is_creatable() const { return 1; } |
| 1214 | virtual bool must_be_loaded() const { return 0; } |
| 1215 | virtual bool is_reset_on_load() const { return 0; } |
| 1216 | virtual const char *image_interface() const { return NULL; } |
| 1217 | virtual const char *file_extensions() const { return "awd"; } |
| 1218 | virtual const option_guide *create_option_guide() const { return NULL; } |
| 1219 | |
| 1220 | virtual bool call_create(int format_type, option_resolution *format_options); |
| 1221 | |
| 1222 | disk_data *token() { return &m_token; } |
| 1223 | protected: |
| 1224 | // device-level overrides |
| 1225 | virtual void device_config_complete(); |
| 1226 | virtual void device_start(); |
| 1227 | virtual void device_reset(); |
| 1228 | |
| 1229 | disk_data m_token; |
| 1230 | }; |
| 1231 | |
| 1232 | // device type definition |
| 1233 | extern const device_type OMTI_DISK; |
| 1234 | |
| 1235 | const device_type OMTI_DISK = &device_creator<omti_disk_image_device>; |
| 1236 | |
| 1237 | omti_disk_image_device::omti_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 1238 | : device_t(mconfig, OMTI_DISK, "Winchester", tag, owner, clock), |
| 1239 | device_image_interface(mconfig, *this) |
| 1240 | { |
| 1241 | } |
| 1242 | |
| 1243 | void omti_disk_image_device::device_config_complete() |
| 1244 | { |
| 1245 | update_names(OMTI_DISK, "disk", "disk"); |
| 1246 | }; |
| 1247 | |
| 1248 | |
| 1205 | 1249 | /*************************************************************************** |
| 1206 | 1250 | get_safe_disk_token - makes sure that the passed in device is a OMTI disk |
| 1207 | 1251 | ***************************************************************************/ |
| 1208 | 1252 | |
| 1209 | 1253 | INLINE disk_data *get_safe_disk_token(device_t *device) { |
| 1210 | 1254 | assert(device != NULL); |
| 1211 | | assert(device->type() == OMTI_DISK0 || device->type() == OMTI_DISK1); |
| 1212 | | return (disk_data *) downcast<legacy_device_base *>(device)->token(); |
| 1255 | assert(device->type() == OMTI_DISK); |
| 1256 | return (disk_data *) downcast<omti_disk_image_device *>(device)->token(); |
| 1213 | 1257 | } |
| 1214 | 1258 | |
| 1215 | 1259 | /*************************************************************************** |
| r14697 | r14698 | |
| 1245 | 1289 | device start callback |
| 1246 | 1290 | -------------------------------------------------*/ |
| 1247 | 1291 | |
| 1248 | | static DEVICE_START( omti_disk ) |
| 1292 | void omti_disk_image_device::device_start() |
| 1249 | 1293 | { |
| 1250 | | disk_data *disk = get_safe_disk_token(device); |
| 1294 | disk_data *disk = get_safe_disk_token(this); |
| 1251 | 1295 | |
| 1252 | | disk->device = device; |
| 1296 | disk->device = this; |
| 1253 | 1297 | // note: we must have disk->device before we can log |
| 1254 | 1298 | |
| 1255 | | disk->image = dynamic_cast<device_image_interface *> (disk->device); |
| 1299 | disk->image = this; |
| 1256 | 1300 | |
| 1257 | 1301 | if (disk->image->image_core_file() == NULL) |
| 1258 | 1302 | { |
| r14697 | r14698 | |
| 1271 | 1315 | device reset callback |
| 1272 | 1316 | -------------------------------------------------*/ |
| 1273 | 1317 | |
| 1274 | | static DEVICE_RESET( omti_disk ) |
| 1318 | void omti_disk_image_device::device_reset() |
| 1275 | 1319 | { |
| 1276 | | disk_data *disk = get_safe_disk_token(device); |
| 1320 | disk_data *disk = get_safe_disk_token(this); |
| 1277 | 1321 | DLOG1(("device_reset_omti_disk")); |
| 1278 | 1322 | |
| 1279 | | if (disk->image->exists() && disk->image->fseek(0, SEEK_END) == 0) |
| 1323 | if (exists() && fseek(0, SEEK_END) == 0) |
| 1280 | 1324 | { |
| 1281 | | UINT32 disk_size = (UINT32)(disk->image->ftell() / OMTI_DISK_SECTOR_SIZE); |
| 1325 | UINT32 disk_size = (UINT32)(ftell() / OMTI_DISK_SECTOR_SIZE); |
| 1282 | 1326 | UINT16 disk_type = disk_size >= 300000 ? OMTI_DISK_TYPE_348_MB : OMTI_DISK_TYPE_155_MB; |
| 1283 | 1327 | if (disk_type != disk->type) { |
| 1284 | 1328 | DLOG1(("device_reset_omti_disk: disk size=%d blocks, disk type=%x", disk_size, disk_type )); |
| r14697 | r14698 | |
| 1291 | 1335 | disk image create callback |
| 1292 | 1336 | -------------------------------------------------*/ |
| 1293 | 1337 | |
| 1294 | | DEVICE_IMAGE_CREATE( omti_disk ) |
| 1338 | bool omti_disk_image_device::call_create(int format_type, option_resolution *format_options) |
| 1295 | 1339 | { |
| 1296 | | disk_data *disk = get_safe_disk_token(&image.device()); |
| 1340 | disk_data *disk = get_safe_disk_token(this); |
| 1297 | 1341 | DLOG(("device_create_omti_disk: creating OMTI Disk with %d blocks", disk->sector_count)); |
| 1298 | 1342 | |
| 1299 | 1343 | int x; |
| r14697 | r14698 | |
| 1303 | 1347 | memset(sectordata, 0x55, sizeof(sectordata)); |
| 1304 | 1348 | for (x = 0; x < disk->sector_count; x++) |
| 1305 | 1349 | { |
| 1306 | | if (image.fwrite(sectordata, OMTI_DISK_SECTOR_SIZE) |
| 1350 | if (fwrite(sectordata, OMTI_DISK_SECTOR_SIZE) |
| 1307 | 1351 | < OMTI_DISK_SECTOR_SIZE) |
| 1308 | 1352 | { |
| 1309 | 1353 | return IMAGE_INIT_FAIL; |
| r14697 | r14698 | |
| 1312 | 1356 | return IMAGE_INIT_PASS; |
| 1313 | 1357 | } |
| 1314 | 1358 | |
| 1315 | | /*------------------------------------------------- |
| 1316 | | device get info callback |
| 1317 | | -------------------------------------------------*/ |
| 1318 | | |
| 1319 | | DEVICE_GET_INFO( omti_disk0 ) |
| 1320 | | { |
| 1321 | | switch (state) |
| 1322 | | { |
| 1323 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1324 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(disk_data); break; |
| 1325 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 1326 | | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_HARDDISK; break; |
| 1327 | | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 1328 | | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 1329 | | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 1; break; |
| 1330 | | |
| 1331 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1332 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(omti_disk); break; |
| 1333 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1334 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(omti_disk); break; |
| 1335 | | // case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(omti_disk); break; |
| 1336 | | // case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(omti_disk); break; |
| 1337 | | case DEVINFO_FCT_IMAGE_CREATE: info->f = (genf *)DEVICE_IMAGE_CREATE_NAME(omti_disk); break; |
| 1338 | | |
| 1339 | | |
| 1340 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1341 | | case DEVINFO_STR_NAME: strcpy(info->s, "Winchester"); break; |
| 1342 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Winchester"); break; |
| 1343 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1344 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1345 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; |
| 1346 | | |
| 1347 | | case DEVINFO_STR_IMAGE_INSTANCE_NAME: strcpy(info->s, "disk"); break; |
| 1348 | | case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME: strcpy(info->s, "disk"); break; |
| 1349 | | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, "awd"); break; |
| 1350 | | } |
| 1351 | | } |
| 1352 | | |
| 1353 | | DEVICE_GET_INFO( omti_disk1 ) |
| 1354 | | { |
| 1355 | | switch (state) |
| 1356 | | { |
| 1357 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1358 | | case DEVINFO_STR_NAME: strcpy(info->s, "Winchester 1"); break; |
| 1359 | | case DEVINFO_STR_IMAGE_INSTANCE_NAME: strcpy(info->s, "disk1"); break; |
| 1360 | | case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME: strcpy(info->s, "disk1"); break; |
| 1361 | | |
| 1362 | | default: DEVICE_GET_INFO_CALL( omti_disk0 ); break; |
| 1363 | | } |
| 1364 | | } |
| 1365 | | |
| 1366 | | DEFINE_LEGACY_IMAGE_DEVICE(OMTI_DISK0, omti_disk0); |
| 1367 | | DEFINE_LEGACY_IMAGE_DEVICE(OMTI_DISK1, omti_disk1); |
| 1368 | | |
| 1369 | 1359 | MACHINE_CONFIG_FRAGMENT( omti_disk ) |
| 1370 | | MCFG_DEVICE_ADD(OMTI_DISK0_TAG, OMTI_DISK0, 0) |
| 1371 | | MCFG_DEVICE_ADD(OMTI_DISK1_TAG, OMTI_DISK1, 0) |
| 1360 | MCFG_DEVICE_ADD(OMTI_DISK0_TAG, OMTI_DISK, 0) |
| 1361 | MCFG_DEVICE_ADD(OMTI_DISK1_TAG, OMTI_DISK, 0) |
| 1372 | 1362 | MACHINE_CONFIG_END |
| 1373 | 1363 | |