1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
|
// license:BSD-3-Clause
// copyright-holders:Nathan Woods, Olivier Galibert, Miodrag Milanovic
/*********************************************************************
floppy.h
*********************************************************************/
#ifndef MAME_IMAGEDEV_FLOPPY_H
#define MAME_IMAGEDEV_FLOPPY_H
#pragma once
#include "sound/samples.h"
// forward declarations
class floppy_image;
class floppy_image_format_t;
namespace fs {
class manager_t;
class meta_data;
};
/*
Floppy drive sound
MZ, August 2015
Updated April 2026
In order to activate floppy drive sounds with predefined samples for 3.5"
and 5.25" drives, call
* enable_sound() or enable_sound(true) or enable_sound(nullptr)
on the instances of floppy_connector, usually appearing in device_add_mconfig
of the device where the drives are connected. If you prefer custom sounds
for the drive, create an instance of floppy_sound_samples, and register
samples on it as follows:
* clear()
Clear the sample list. Recommended to use at code locations that
may be called several times (like device_add_mconfig).
* set_form_factor(form_factor, directory)
All following add operations will use the given form factor and
assume that the samples are found in the provided directory. May be
called several times in order to add samples for different form factors.
* add_spin_sample(filename, type):
For spinning motor samples. See the enum below for type values.
* add_step_sample(filename, start, end):
Stepper sound for single steps, used in the track range from start to
end; when start and end are omitted, 0 and 99 are assumed, covering the
whole disk.
* add_seek_sample(filename, nominal_rate, max_rate, start, end):
Stepper sound for continuous movement for a rate not exceeding max_rate.
The pitch is adjusted according to the ratio of the actual rate and
the nominal rate, thus, the sample is played back at natural speed when
the actual rate matches the nominal rate. The sample is selected whose
maximum rate is the minimum among those whose maximum rate is higher
than the actual rate, and if its range contains the current track number.
When not specified, the range covers the whole disk (0..99).
For an example, see the predefined sample list in the constructor of
floppy_sound_device.
For custom samples, pass the address of the specific floppy_sound_samples
instance as
* enable_sound(&myfloppysamples);
If the custom samples cannot be found, the default samples are used. If
those cannot be found either, sound is disabled.
If the samples list does not contain a matching form factor, the following
replacement strategy is used:
* If 3" samples are requested but not found, 3.5" samples are used.
* If 3.5" or 8" samples are requested but not found, 5.25" samples are used.
*/
class floppy_sound_samples
{
public:
floppy_sound_samples();
/* Clear the list. */
void clear() { m_fulllist.clear(); }
/* Set the form factor for the following add operations. */
void set_form_factor(int form_factor, const char* dir);
enum // spin type
{
QUIET=-1, // Also used as silence for steps and seeks
START_EMPTY=0, // Start spinning without disk
SPIN_EMPTY, // Spinning without disk
END_EMPTY, // Stop spinning spinning without disk
START_LOADED_INITIAL, // Start spinning with disk, 3.5" drives make a click when latching in
START_LOADED, // Start spinning with disk, already latched in
SPIN_LOADED, // Spinning with disk (mandatory sample)
END_LOADED // Stop spinning with disk
};
/* Add spin, step, and seek samples. */
void add_spin_sample(const char* filename, int type);
void add_step_sample(const char* filename, int start=0, int end=99);
void add_seek_sample(const char* filename, int nominal_rate, int max_rate, int mintrack=0, int maxtrack=99);
/* Deliver the list of names for the parent class samples_device. */
const char* const* get_names();
/* Selects the matching form factor and prepares the samples list. */
void select(int form_factor);
int get_assumed_form_factor() { return m_current_form_factor; }
/* Search for a suitable spinning sample. Return the index into the
samples list. */
int find_spin(int kind) const;
/* Search for a suitable step sample. */
int find_step(int track) const;
/* Search for a suitable seek sample. */
int find_seek(double rate, int track, double& pitch) const;
private:
enum
{
SPIN = 0,
STEP,
SEEK
};
struct floppy_sound_entry
{
int index = 0;
int type = 0; // type: SPIN, STEP, SEEK
int form_factor; // indicates the form factor of the drive
int mintrack = 0; // valid from here (including), meaningless for spin entries
int maxtrack = 99; // to here (including), meaningless for spin entries
int rate = 0; // rate of the seek sample
int maxrate = 0; // max rate for pitching up the seek sample
int spintype = 0; // type for spin entries
const char *directory; // directory where the sample is stored
const char *filename;
};
std::string m_basedir; // Subdirectory which contains the samples
std::vector<const char*> m_samplenames;
std::vector<floppy_sound_entry> m_fulllist;
int m_current_form_factor;
const char* m_current_dir;
};
class floppy_sound_device : public samples_device
{
public:
floppy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
void motor(bool on, bool withdisk);
void step(int track);
void unload() { m_firstturn = true; }
bool samples_loaded() { return m_samples_available; }
void register_for_save_states();
void set_samples(floppy_sound_samples *samples, int form_factor);
protected:
void device_start() override ATTR_COLD;
private:
// device_sound_interface overrides
virtual void sound_stream_update(sound_stream &stream) override;
sound_stream* m_sound;
floppy_sound_samples* m_samplelist;
floppy_sound_samples m_default_samples;
bool m_motor_on;
bool m_with_disk;
int m_spin_kind;
int m_spin_sample;
int m_spin_samplepos;
int m_step_sample;
int m_step_samplepos;
int m_seek_sample;
double m_seek_samplepos; // we may using a non-integer pitch
double m_seek_pitch;
int m_seek_sound_timeout;
attotime m_last_step_time;
bool m_firstturn; // see START_LOADED_INITIAL
bool m_samples_available;
bool m_in_seek;
double m_step_rate;
};
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
class format_registration {
public:
format_registration();
void add(const floppy_image_format_t &format);
void add(const fs::manager_t &fs);
void add_fm_containers();
void add_mfm_containers();
void add_pc_formats();
std::vector<const floppy_image_format_t *> m_formats;
std::vector<const fs::manager_t *> m_fs;
};
class floppy_image_device : public device_t,
public device_image_interface
{
public:
typedef delegate<void (floppy_image_device *)> load_cb;
typedef delegate<void (floppy_image_device *)> unload_cb;
typedef delegate<void (floppy_image_device *, int)> index_pulse_cb;
typedef delegate<void (floppy_image_device *, int)> ready_cb;
typedef delegate<void (floppy_image_device *, int)> wpt_cb;
typedef delegate<void (floppy_image_device *, int)> led_cb;
struct fs_info {
const fs::manager_t *m_manager;
const floppy_image_format_t *m_type;
u32 m_image_size;
const char *m_name;
u32 m_key;
const char *m_description;
fs_info(const fs::manager_t *manager, const floppy_image_format_t *type, u32 image_size, const char *name, const char *description) :
m_manager(manager),
m_type(type),
m_image_size(image_size),
m_name(name),
m_key(0),
m_description(description)
{}
fs_info(const char *name, u32 key, const char *description) :
m_manager(nullptr),
m_type(nullptr),
m_image_size(0),
m_name(name),
m_key(key),
m_description(description)
{}
};
// construction/destruction
virtual ~floppy_image_device();
void set_formats(std::function<void (format_registration &fr)> formats);
const std::vector<const floppy_image_format_t *> &get_formats() const;
const std::vector<fs_info> &get_fs() const { return m_fs; }
const floppy_image_format_t *get_load_format() const;
std::pair<std::error_condition, const floppy_image_format_t *> identify(std::string_view filename);
void set_rpm(float rpm);
void set_sectoring_type(uint32_t sectoring_type);
uint32_t get_sectoring_type();
void init_fs(const fs_info *fs, const fs::meta_data &meta);
// device_image_interface implementation
virtual std::pair<std::error_condition, std::string> call_load() override;
virtual void call_unload() override;
virtual std::pair<std::error_condition, std::string> call_create(int format_type, util::option_resolution *format_options) override;
virtual const char *image_interface() const noexcept override = 0;
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return m_extension_list; }
virtual const char *image_type_name() const noexcept override { return "floppydisk"; }
virtual const char *image_brief_type_name() const noexcept override { return "flop"; }
void setup_write(const floppy_image_format_t *output_format);
void setup_load_cb(load_cb cb);
void setup_unload_cb(unload_cb cb);
void setup_index_pulse_cb(index_pulse_cb cb);
void setup_ready_cb(ready_cb cb);
void setup_wpt_cb(wpt_cb cb);
void setup_led_cb(led_cb cb);
int get_cyl() const { return m_cyl; }
bool on_track() const { return !m_subcyl; }
virtual void mon_w(int state);
bool ready_r();
void set_ready(bool state);
virtual void tfsel_w(int state) { } // 35SEL line for Apple Sony drives
virtual bool wpt_r(); // Mac sony drives using this for various reporting
int dskchg_r() { return m_dskchg; }
bool trk00_r() { return (m_has_trk00_sensor ? (m_cyl != 0) : 1); }
int idx_r() { return m_idx; }
int mon_r() { return m_mon; }
bool ss_r() { return m_ss; }
bool twosid_r();
bool floppy_is_hd();
bool floppy_is_ed();
virtual bool writing_disabled() const;
virtual void seek_phase_w(int phases);
void stp_w(int state);
void dir_w(int state) { m_dir = state; }
void ss_w(int state) { m_actual_ss = state; if (m_sides > 1) m_ss = state; }
void inuse_w(int state) { }
void dskchg_w(int state) { if (m_dskchg_writable) m_dskchg = state; }
void ds_w(int state) { m_ds = state; check_led(); }
attotime time_next_index();
attotime get_next_transition(const attotime &from_when);
void write_flux(const attotime &start, const attotime &end, int transition_count, const attotime *transitions);
void set_write_splice(const attotime &when);
int get_sides() { return m_sides; }
uint32_t get_form_factor() const;
uint32_t get_variant() const;
static void default_fm_floppy_formats(format_registration &fr);
static void default_mfm_floppy_formats(format_registration &fr);
static void default_pc_floppy_formats(format_registration &fr);
protected:
struct fs_enum;
floppy_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device_t implementation
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
virtual void device_config_complete() override;
virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
// device_image_interface implementation
virtual const software_list_loader &get_software_list_loader() const override;
TIMER_CALLBACK_MEMBER(index_resync);
virtual void track_changed();
virtual void setup_characteristics() = 0;
void init_floppy_load(bool write_supported);
std::function<void (format_registration &fr)> m_format_registration_cb;
const floppy_image_format_t *m_input_format;
const floppy_image_format_t *m_output_format;
std::vector<uint32_t> m_variants;
std::unique_ptr<floppy_image> m_image;
char m_extension_list[256];
std::vector<const floppy_image_format_t *> m_fif_list;
std::vector<fs_info> m_fs;
std::vector<const fs::manager_t *> m_fs_managers;
emu_timer *m_index_timer;
/* Physical characteristics, filled by setup_characteristics */
int m_tracks; /* addressable tracks */
int m_sides; /* number of heads */
uint32_t m_form_factor; /* 3"5, 5"25, etc */
uint32_t m_sectoring_type; /* SOFT, Hard 10/16/32 */
bool m_motor_always_on;
bool m_dskchg_writable;
bool m_has_trk00_sensor;
int m_drive_index;
/* state of input lines */
int m_dir; /* direction */
int m_stp; /* step */
int m_wtg; /* write gate */
int m_mon; /* motor on */
int m_ss, m_actual_ss; /* side select (forced to 0 if single-sided drive / actual value) */
int m_ds; /* drive select */
int m_phases; /* phases lines, when they exist */
/* state of output lines */
int m_idx; /* index pulse */
int m_wpt; /* write protect */
int m_rdy; /* ready */
int m_dskchg; /* disk changed */
bool m_ready;
/* rotation per minute => gives index pulse frequency */
float m_rpm;
/* angular speed, where a full circle is 2e8 */
double m_angular_speed;
attotime m_revolution_start_time, m_rev_time;
uint32_t m_revolution_count;
int m_cyl, m_subcyl;
/* Current floppy zone cache */
attotime m_cache_start_time, m_cache_end_time, m_cache_weak_start;
attotime m_amplifier_freakout_time;
int m_cache_index;
u32 m_cache_entry;
bool m_cache_weak;
bool m_image_dirty, m_track_dirty;
int m_ready_counter;
load_cb m_cur_load_cb;
unload_cb m_cur_unload_cb;
index_pulse_cb m_cur_index_pulse_cb;
ready_cb m_cur_ready_cb;
wpt_cb m_cur_wpt_cb;
led_cb m_cur_led_cb;
// Temporary structure storing a write span
struct wspan {
int start, end;
std::vector<int> flux_change_positions;
};
static void wspan_split_on_wrap(std::vector<wspan> &wspans);
static void wspan_remove_damaged(std::vector<wspan> &wspans, const std::vector<uint32_t> &track);
static void wspan_write(const std::vector<wspan> &wspans, std::vector<uint32_t> &track);
void register_formats();
void add_variant(uint32_t variant);
void check_led();
uint32_t find_position(attotime &base, const attotime &when);
attotime position_to_time(const attotime &base, int position) const;
void commit_image();
u32 hash32(u32 val) const;
void cache_clear();
void cache_fill_index(const std::vector<uint32_t> &buf, int &index, attotime &base);
void cache_fill(const attotime &when);
void cache_weakness_setup();
// Sound support
bool m_make_sound;
const floppy_sound_samples *m_samples;
required_device<floppy_sound_device> m_sound_out;
};
#define DECLARE_FLOPPY_IMAGE_DEVICE(Type, Name, Interface) \
class Name : public floppy_image_device { \
public: \
Name(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); \
virtual ~Name(); \
virtual const char *image_interface() const noexcept override { return Interface; } \
protected: \
virtual void setup_characteristics() override; \
}; \
DECLARE_DEVICE_TYPE(Type, Name)
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_3_SSSD, floppy_3_sssd, "floppy_3")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_3_DSSD, floppy_3_dssd, "floppy_3")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_3_SSDD, floppy_3_ssdd, "floppy_3")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_3_DSDD, floppy_3_dsdd, "floppy_3")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_3_DSQD, floppy_3_dsqd, "floppy_3")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_35_SSDD, floppy_35_ssdd, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_35_DD, floppy_35_dd, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_35_HD, floppy_35_hd, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_35_ED, floppy_35_ed, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_SSSD_35T, floppy_525_sssd_35t, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_SD_35T, floppy_525_sd_35t, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_VTECH, floppy_525_vtech, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_SSSD, floppy_525_sssd, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_SD, floppy_525_sd, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_SSDD, floppy_525_ssdd, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_DD, floppy_525_dd, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_SSQD, floppy_525_ssqd, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_QD, floppy_525_qd, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_525_HD, floppy_525_hd, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_8_SSSD, floppy_8_sssd, "floppy_8")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_8_DSSD, floppy_8_dssd, "floppy_8")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_8_SSDD, floppy_8_ssdd, "floppy_8")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_8_DSDD, floppy_8_dsdd, "floppy_8")
DECLARE_FLOPPY_IMAGE_DEVICE(EPSON_SMD_165, epson_smd_165, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(EPSON_SD_320, epson_sd_320, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(EPSON_SD_321, epson_sd_321, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(PANA_JU_363, pana_ju_363, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(PANA_JU_386, pana_ju_386, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(SONY_OA_D31V, sony_oa_d31v, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(SONY_OA_D32W, sony_oa_d32w, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(SONY_OA_D32V, sony_oa_d32v, "floppy_3_5")
DECLARE_FLOPPY_IMAGE_DEVICE(TEAC_FD_30A, teac_fd_30a, "floppy_3")
DECLARE_FLOPPY_IMAGE_DEVICE(TEAC_FD_55A, teac_fd_55a, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(TEAC_FD_55B, teac_fd_55b, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(TEAC_FD_55E, teac_fd_55e, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(TEAC_FD_55F, teac_fd_55f, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(TEAC_FD_55G, teac_fd_55g, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(ALPS_3255190X, alps_3255190x, "floppy_5_25")
DECLARE_FLOPPY_IMAGE_DEVICE(IBM_6360, ibm_6360, "floppy_8")
DECLARE_FLOPPY_IMAGE_DEVICE(FLOPPY_TWIGGY, floppy_twiggy, "floppy_twiggy")
DECLARE_DEVICE_TYPE(FLOPPYSOUND, floppy_sound_device)
class mac_floppy_device : public floppy_image_device {
public:
virtual ~mac_floppy_device() = default;
virtual bool wpt_r() override;
virtual void mon_w(int) override;
virtual void tfsel_w(int state) override;
virtual void seek_phase_w(int phases) override;
virtual const char *image_interface() const noexcept override { return "floppy_3_5"; }
virtual bool writing_disabled() const override;
protected:
u8 m_reg;
bool m_strb;
bool m_mfm, m_has_mfm;
mac_floppy_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
virtual void track_changed() override;
virtual bool is_2m() const = 0;
};
// 400K GCR
class oa_d34v_device : public mac_floppy_device {
public:
oa_d34v_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~oa_d34v_device() = default;
protected:
virtual void setup_characteristics() override;
virtual void track_changed() override;
virtual bool is_2m() const override;
};
// 400/800K GCR (e.g. dual-sided)
class mfd51w_device : public mac_floppy_device {
public:
mfd51w_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~mfd51w_device() = default;
protected:
virtual void setup_characteristics() override;
virtual bool is_2m() const override;
};
// 400/800K GCR + 1.44 MFM (Superdrive)
class mfd75w_device : public mac_floppy_device {
public:
mfd75w_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~mfd75w_device() = default;
protected:
virtual void setup_characteristics() override;
virtual bool is_2m() const override;
};
DECLARE_DEVICE_TYPE(OAD34V, oa_d34v_device)
DECLARE_DEVICE_TYPE(MFD51W, mfd51w_device)
DECLARE_DEVICE_TYPE(MFD75W, mfd75w_device)
class floppy_connector: public device_t,
public device_slot_interface
{
public:
template <typename T, typename U>
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, U &&formats, bool fixed = false)
: floppy_connector(mconfig, tag, owner, 0)
{
set_options(std::forward<T>(opts), dflt, fixed);
set_formats(std::forward<U>(formats));
}
template <typename T>
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, const char *option, device_type drivetype, bool is_default, T &&formats)
: floppy_connector(mconfig, tag, owner, 0)
{
option_reset();
option_add(option, drivetype);
if(is_default)
set_default_option(option);
set_fixed(false);
set_formats(std::forward<T>(formats));
}
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
virtual ~floppy_connector();
template <typename T> void set_formats(T &&_formats) { formats = std::forward<T>(_formats); }
void set_sectoring_type(uint32_t sectoring_type) { m_sectoring_type = sectoring_type; }
floppy_image_device *get_device();
// Sound support
bool use_sound() { return m_use_sound; }
void enable_sound(bool doit = true);
void enable_sound(floppy_sound_samples *samples);
floppy_sound_samples *get_samples() { return m_samples; }
protected:
virtual void device_start() override ATTR_COLD;
virtual void device_config_complete() override;
private:
std::function<void (format_registration &fr)> formats;
bool m_use_sound;
floppy_sound_samples *m_samples;
uint32_t m_sectoring_type;
};
// device type definition
DECLARE_DEVICE_TYPE(FLOPPY_CONNECTOR, floppy_connector)
extern template class device_finder<floppy_connector, false>;
extern template class device_finder<floppy_connector, true>;
#endif // MAME_IMAGEDEV_FLOPPY_H
|