branches/alto2/src/emu/machine/diablo_hd.c
| r26133 | r26134 | |
| 65 | 65 | #if DIABLO_DEBUG |
| 66 | 66 | m_log_level(9), |
| 67 | 67 | #endif |
| 68 | m_chd(*this, tag), |
| 68 | 69 | m_diablo31(true), |
| 69 | 70 | m_unit(0), |
| 70 | 71 | m_description(), |
| r26133 | r26134 | |
| 87 | 88 | m_head(-1), |
| 88 | 89 | m_sector(-1), |
| 89 | 90 | m_page(-1), |
| 90 | | m_image(), |
| 91 | | m_bits(), |
| 91 | m_pages(DIABLO_PAGES), |
| 92 | m_image(0), |
| 93 | m_bits(0), |
| 92 | 94 | m_rdfirst(-1), |
| 93 | 95 | m_rdlast(-1), |
| 94 | 96 | m_wrfirst(-1), |
| r26133 | r26134 | |
| 99 | 101 | { |
| 100 | 102 | } |
| 101 | 103 | |
| 104 | diablo_hd_device::~diablo_hd_device() |
| 105 | { |
| 106 | for (int page = 0; page < m_pages; page++) { |
| 107 | if (m_image && m_image[page]) |
| 108 | global_free(m_image[page]); |
| 109 | if (m_bits && m_bits[page]) |
| 110 | global_free(m_bits[page]); |
| 111 | } |
| 112 | if (m_image) { |
| 113 | global_free(m_image); |
| 114 | m_image = 0; |
| 115 | } |
| 116 | if (m_bits) { |
| 117 | global_free(m_bits); |
| 118 | m_bits = 0; |
| 119 | } |
| 120 | } |
| 121 | |
| 102 | 122 | #if DIABLO_DEBUG |
| 103 | 123 | void alto2_cpu_device::logprintf(int level, const char* format, ...) |
| 104 | 124 | { |
| r26133 | r26134 | |
| 278 | 298 | return; |
| 279 | 299 | } |
| 280 | 300 | |
| 281 | | /* allocate a sector buffer */ |
| 301 | /* allocate a buffer for this page */ |
| 282 | 302 | m_image[m_page] = global_alloc_array(UINT8, sizeof(diablo_sector_t)); |
| 303 | /* and read the page from the hard_disk image */ |
| 283 | 304 | if (!hard_disk_read(file, m_page, m_image[m_page])) { |
| 284 | 305 | LOG_DRIVE((0," read failed for #%d page #%d\n", m_unit, m_page)); |
| 285 | 306 | global_free(m_image[m_page]); |
| r26133 | r26134 | |
| 740 | 761 | } |
| 741 | 762 | global_free(m_bits[m_page]); |
| 742 | 763 | m_bits[m_page] = 0; |
| 764 | |
| 765 | hard_disk_file *file = m_drive->get_hard_disk_file(); |
| 766 | if (!file) { |
| 767 | LOG_DRIVE((0," no file for unit #%d\n", m_unit)); |
| 768 | return; |
| 769 | } |
| 770 | |
| 771 | if (!hard_disk_write(file, m_page, m_image[m_page])) { |
| 772 | LOG_DRIVE((0," write failed for #%d page #%d\n", m_unit, m_page)); |
| 773 | } |
| 743 | 774 | } |
| 744 | 775 | |
| 745 | 776 | /** |
| r26133 | r26134 | |
| 1168 | 1199 | } |
| 1169 | 1200 | |
| 1170 | 1201 | /** |
| 1171 | | * @brief timer callback that is called once per sector in the rotation |
| 1202 | * @brief timer callback that is called thrice per sector in the rotation |
| 1172 | 1203 | * |
| 1204 | * The timer is called three times at the events: |
| 1205 | * 0: sector mark goes inactive |
| 1206 | * 1: sector mark goes active |
| 1207 | * 2: in the middle of the active phase |
| 1208 | * |
| 1173 | 1209 | * @param id timer id |
| 1174 | 1210 | * @param arg argument supplied to timer_insert (unused) |
| 1175 | 1211 | */ |
| r26133 | r26134 | |
| 1251 | 1287 | m_sector_mark_1_time = DIABLO44_SECTOR_MARK_PULSE_PRE; |
| 1252 | 1288 | m_bit_time = DIABLO44_BIT_TIME(1); |
| 1253 | 1289 | } |
| 1254 | | |
| 1255 | 1290 | m_sector_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(diablo_hd_device::next_sector),this)); |
| 1256 | 1291 | m_sector_timer->adjust(m_sector_time - m_sector_mark_0_time, 0); |
| 1257 | 1292 | } |
| r26133 | r26134 | |
| 1282 | 1317 | m_rdfirst = -1; |
| 1283 | 1318 | m_rdlast = -1; |
| 1284 | 1319 | |
| 1285 | | m_drive = static_cast<harddisk_image_device *>(subdevice("drive")); |
| 1320 | m_drive = static_cast<diablo_image_device *>(subdevice("drive")); |
| 1286 | 1321 | } |
| 1287 | 1322 | |
| 1288 | 1323 | MACHINE_CONFIG_FRAGMENT( diablo_drive ) |
| 1289 | | MCFG_HARDDISK_ADD("drive") |
| 1324 | MCFG_DIABLO_ADD("drive") |
| 1290 | 1325 | MACHINE_CONFIG_END |
| 1291 | 1326 | |
| 1292 | 1327 | machine_config_constructor diablo_hd_device::device_mconfig_additions() const |
branches/alto2/src/emu/machine/diablo_hd.h
| r26133 | r26134 | |
| 10 | 10 | #define _DIABLO_HD_DEVICE_ |
| 11 | 11 | |
| 12 | 12 | #include "emu.h" |
| 13 | | #include "imagedev/harddriv.h" |
| 13 | #include "imagedev/diablo.h" |
| 14 | 14 | |
| 15 | 15 | #define DIABLO_DEBUG 0 |
| 16 | 16 | |
| 17 | | #define DIABLO_HD_0 "diablo:0" |
| 18 | | #define DIABLO_HD_1 "diablo:1" |
| 17 | #define DIABLO_HD_0 "diablo0" |
| 18 | #define DIABLO_HD_1 "diablo1" |
| 19 | 19 | |
| 20 | 20 | extern const device_type DIABLO_HD; |
| 21 | 21 | |
| r26133 | r26134 | |
| 23 | 23 | { |
| 24 | 24 | public: |
| 25 | 25 | diablo_hd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 26 | ~diablo_hd_device(); |
| 26 | 27 | |
| 27 | 28 | int bits_per_sector() const; |
| 28 | 29 | const char* description() const; |
| r26133 | r26134 | |
| 64 | 65 | # define LOG_DRIVE(x) |
| 65 | 66 | #endif |
| 66 | 67 | |
| 68 | required_device<diablo_image_device> m_chd; //!< image device |
| 69 | |
| 67 | 70 | static const int DIABLO_UNIT_MAX = 2; //!< max number of drive units |
| 68 | 71 | static const int DIABLO_CYLINDERS = 203; //!< number of cylinders per drive |
| 69 | 72 | static const int DIABLO_CYLINDER_MASK = 0777; //!< bit maks for cylinder number (9 bits) |
| r26133 | r26134 | |
| 97 | 100 | int m_head; //!< current head (track) number on cylinder |
| 98 | 101 | int m_sector; //!< current sector number in track |
| 99 | 102 | int m_page; //!< current page |
| 100 | | UINT8* m_image[DIABLO_PAGES]; //!< page raw bytes |
| 101 | | UINT32* m_bits[DIABLO_PAGES]; //!< page expanded to bits |
| 103 | int m_pages; //!< total number of pages |
| 104 | UINT8** m_image; //!< pages raw bytes |
| 105 | UINT32** m_bits; //!< pages expanded to bits |
| 102 | 106 | int m_rdfirst; //!< set to first bit of a sector that is read from |
| 103 | 107 | int m_rdlast; //!< set to last bit of a sector that was read from |
| 104 | 108 | int m_wrfirst; //!< set to non-zero if a sector is written to |
| 105 | 109 | int m_wrlast; //!< set to last bit of a sector that was written to |
| 106 | 110 | void (*m_sector_callback)(); //!< callback to call at the start of each sector |
| 107 | 111 | emu_timer* m_sector_timer; //!< sector timer |
| 108 | | harddisk_image_device *m_drive; |
| 112 | diablo_image_device *m_drive; |
| 109 | 113 | |
| 110 | 114 | void read_sector(); //!< translate C/H/S to a page and read the sector |
| 111 | 115 | int cksum(UINT8 *src, size_t size, int start); |
branches/alto2/src/mess/drivers/alto2.c
| r26133 | r26134 | |
| 258 | 258 | MCFG_SCREEN_VBLANK_DRIVER(alto2_state, screen_eof_alto2) |
| 259 | 259 | |
| 260 | 260 | MCFG_PALETTE_LENGTH(2) |
| 261 | |
| 262 | MCFG_DIABLO_DRIVES_ADD() |
| 261 | 263 | MACHINE_CONFIG_END |
| 262 | 264 | |
| 263 | 265 | /* Driver Init */ |
| r26133 | r26134 | |
| 269 | 271 | |
| 270 | 272 | // make the diablo drives known to the CPU core |
| 271 | 273 | alto2_cpu_device* cpu = downcast<alto2_cpu_device *>(m_maincpu.target()); |
| 272 | | cpu->set_diablo(0, m_diablo0); |
| 273 | | cpu->set_diablo(1, m_diablo1); |
| 274 | cpu->set_diablo(0, downcast<diablo_hd_device *>(machine().device(DIABLO_HD_0))); |
| 275 | cpu->set_diablo(1, downcast<diablo_hd_device *>(machine().device(DIABLO_HD_1))); |
| 274 | 276 | } |
| 275 | 277 | |
| 276 | 278 | /* Game Drivers */ |
branches/alto2/src/mess/includes/alto2.h
| r26133 | r26134 | |
| 17 | 17 | alto2_state(const machine_config &mconfig, device_type type, const char *tag) |
| 18 | 18 | : driver_device(mconfig, type, tag), |
| 19 | 19 | m_maincpu(*this, "maincpu"), |
| 20 | | m_diablo0(*this, DIABLO_HD_0), |
| 21 | | m_diablo1(*this, DIABLO_HD_1), |
| 20 | // m_diablo0(*this, DIABLO_HD_0), |
| 21 | // m_diablo1(*this, DIABLO_HD_1), |
| 22 | 22 | m_io_row0(*this, "ROW0"), |
| 23 | 23 | m_io_row1(*this, "ROW1"), |
| 24 | 24 | m_io_row2(*this, "ROW2"), |
| r26133 | r26134 | |
| 44 | 44 | |
| 45 | 45 | protected: |
| 46 | 46 | required_device<cpu_device> m_maincpu; |
| 47 | | optional_device<diablo_hd_device> m_diablo0; // should become required_device() once the devices work right |
| 48 | | optional_device<diablo_hd_device> m_diablo1; |
| 47 | // optional_device<diablo_hd_device> m_diablo0; // should become required_device() once the devices work right |
| 48 | // optional_device<diablo_hd_device> m_diablo1; |
| 49 | 49 | required_ioport m_io_row0; |
| 50 | 50 | required_ioport m_io_row1; |
| 51 | 51 | required_ioport m_io_row2; |