Previous 199869 Revisions Next

r26134 Wednesday 13th November, 2013 at 10:03:20 UTC by Jürgen Buchmüller
Trying to solve the diablo_hd_device -> diablo_image_device -> MCFG_DIABLO_DRIVES_ADD() chaining.
[/branches/alto2/src/emu/imagedev]diablo.h
[/branches/alto2/src/emu/machine]diablo_hd.c diablo_hd.h
[/branches/alto2/src/mess/drivers]alto2.c
[/branches/alto2/src/mess/includes]alto2.h

branches/alto2/src/emu/imagedev/diablo.h
r26133r26134
1111
1212#include "harddisk.h"
1313
14#define   DIABLO_TAG(_id) "diablo:"#_id
14#define   DIABLO_TAG(_id) "diablo"#_id
1515
1616/***************************************************************************
1717   TYPE DEFINITIONS
branches/alto2/src/emu/machine/diablo_hd.c
r26133r26134
6565#if   DIABLO_DEBUG
6666   m_log_level(9),
6767#endif
68   m_chd(*this, tag),
6869   m_diablo31(true),
6970   m_unit(0),
7071   m_description(),
r26133r26134
8788   m_head(-1),
8889   m_sector(-1),
8990   m_page(-1),
90   m_image(),
91   m_bits(),
91   m_pages(DIABLO_PAGES),
92   m_image(0),
93   m_bits(0),
9294   m_rdfirst(-1),
9395   m_rdlast(-1),
9496   m_wrfirst(-1),
r26133r26134
99101{
100102}
101103
104diablo_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
102122#if   DIABLO_DEBUG
103123void alto2_cpu_device::logprintf(int level, const char* format, ...)
104124{
r26133r26134
278298      return;
279299   }
280300
281   /* allocate a sector buffer */
301   /* allocate a buffer for this page */
282302   m_image[m_page] = global_alloc_array(UINT8, sizeof(diablo_sector_t));
303   /* and read the page from the hard_disk image */
283304   if (!hard_disk_read(file, m_page, m_image[m_page])) {
284305      LOG_DRIVE((0,"   read failed for #%d page #%d\n", m_unit, m_page));
285306      global_free(m_image[m_page]);
r26133r26134
740761   }
741762   global_free(m_bits[m_page]);
742763   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   }
743774}
744775
745776/**
r26133r26134
11681199}
11691200
11701201/**
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
11721203 *
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 *
11731209 * @param id timer id
11741210 * @param arg argument supplied to timer_insert (unused)
11751211 */
r26133r26134
12511287      m_sector_mark_1_time = DIABLO44_SECTOR_MARK_PULSE_PRE;
12521288      m_bit_time = DIABLO44_BIT_TIME(1);
12531289   }
1254
12551290   m_sector_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(diablo_hd_device::next_sector),this));
12561291   m_sector_timer->adjust(m_sector_time - m_sector_mark_0_time, 0);
12571292}
r26133r26134
12821317   m_rdfirst = -1;
12831318   m_rdlast = -1;
12841319
1285   m_drive = static_cast<harddisk_image_device *>(subdevice("drive"));
1320   m_drive = static_cast<diablo_image_device *>(subdevice("drive"));
12861321}
12871322
12881323MACHINE_CONFIG_FRAGMENT( diablo_drive )
1289   MCFG_HARDDISK_ADD("drive")
1324   MCFG_DIABLO_ADD("drive")
12901325MACHINE_CONFIG_END
12911326
12921327machine_config_constructor diablo_hd_device::device_mconfig_additions() const
branches/alto2/src/emu/machine/diablo_hd.h
r26133r26134
1010#define _DIABLO_HD_DEVICE_
1111
1212#include "emu.h"
13#include "imagedev/harddriv.h"
13#include "imagedev/diablo.h"
1414
1515#define   DIABLO_DEBUG   0
1616
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"
1919
2020extern const device_type DIABLO_HD;
2121
r26133r26134
2323{
2424public:
2525   diablo_hd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
26   ~diablo_hd_device();
2627
2728   int bits_per_sector() const;
2829   const char* description() const;
r26133r26134
6465#   define   LOG_DRIVE(x)
6566#endif
6667
68   required_device<diablo_image_device> m_chd;      //!< image device
69
6770   static const int DIABLO_UNIT_MAX = 2;         //!< max number of drive units
6871   static const int DIABLO_CYLINDERS = 203;      //!< number of cylinders per drive
6972   static const int DIABLO_CYLINDER_MASK = 0777;   //!< bit maks for cylinder number (9 bits)
r26133r26134
97100   int m_head;                  //!< current head (track) number on cylinder
98101   int m_sector;               //!< current sector number in track
99102   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
102106   int m_rdfirst;               //!< set to first bit of a sector that is read from
103107   int m_rdlast;               //!< set to last bit of a sector that was read from
104108   int m_wrfirst;               //!< set to non-zero if a sector is written to
105109   int m_wrlast;               //!< set to last bit of a sector that was written to
106110   void (*m_sector_callback)();   //!< callback to call at the start of each sector
107111   emu_timer* m_sector_timer;      //!< sector timer
108   harddisk_image_device *m_drive;
112   diablo_image_device *m_drive;
109113
110114   void read_sector();            //!< translate C/H/S to a page and read the sector
111115   int cksum(UINT8 *src, size_t size, int start);
branches/alto2/src/mess/drivers/alto2.c
r26133r26134
258258   MCFG_SCREEN_VBLANK_DRIVER(alto2_state, screen_eof_alto2)
259259
260260   MCFG_PALETTE_LENGTH(2)
261
262   MCFG_DIABLO_DRIVES_ADD()
261263MACHINE_CONFIG_END
262264
263265/* Driver Init */
r26133r26134
269271
270272   // make the diablo drives known to the CPU core
271273   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)));
274276}
275277
276278/* Game Drivers */
branches/alto2/src/mess/includes/alto2.h
r26133r26134
1717   alto2_state(const machine_config &mconfig, device_type type, const char *tag)
1818      : driver_device(mconfig, type, tag),
1919      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),
2222      m_io_row0(*this, "ROW0"),
2323      m_io_row1(*this, "ROW1"),
2424      m_io_row2(*this, "ROW2"),
r26133r26134
4444
4545protected:
4646   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;
4949   required_ioport m_io_row0;
5050   required_ioport m_io_row1;
5151   required_ioport m_io_row2;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team