Previous 199869 Revisions Next

r19520 Thursday 13th December, 2012 at 12:56:38 UTC by Miodrag Milanović
Added specialist mx custom format handling (nw)
[src/lib/formats]smx_dsk.c smx_dsk.h
[src/mess/drivers]special.c
[src/mess/includes]special.h

trunk/src/lib/formats/smx_dsk.c
r19519r19520
1/*********************************************************************
1/***************************************************************************
22
3    formats/smx_dsk.c
3    Copyright Olivier Galibert
4    All rights reserved.
45
5    Specialist MX disk images
6    Redistribution and use in source and binary forms, with or without
7    modification, are permitted provided that the following conditions are
8    met:
69
7*********************************************************************/
10        * Redistributions of source code must retain the above copyright
11          notice, this list of conditions and the following disclaimer.
12        * Redistributions in binary form must reproduce the above copyright
13          notice, this list of conditions and the following disclaimer in
14          the documentation and/or other materials provided with the
15          distribution.
16        * Neither the name 'MAME' nor the names of its contributors may be
17          used to endorse or promote products derived from this software
18          without specific prior written permission.
819
9#include <string.h>
20    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
21    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
24    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    POSSIBILITY OF SUCH DAMAGE.
1031
11#include "smx_dsk.h"
12#include "basicdsk.h"
32****************************************************************************/
1333
14static FLOPPY_IDENTIFY(smx_dsk_identify)
15{
16   *vote = (floppy_image_size(floppy) == 819200) ? 100 : 0;
17   return FLOPPY_ERROR_SUCCESS;
18}
34/*********************************************************************
1935
20static int smx_get_heads_per_disk(floppy_image_legacy *floppy)
21{
22   return 2;
23}
36    formats/smx_dsk.c
2437
25static int smx_get_tracks_per_disk(floppy_image_legacy *floppy)
26{
27   return 80;
28}
38    Specialist MX format
2939
30static UINT64 smx_translate_offset(floppy_image_legacy *floppy,
31    int track, int head, int sector)
32{
33   return (track * 1024 * 5 * 2) + (head * 1024 * 5) + 1024 * sector;
34}
40*********************************************************************/
3541
36static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
37{
38   UINT64 offs;
39   /* translate the sector to a raw sector */
40   if (!sector_is_index)
41   {
42      sector -= 1;
43   }
44   /* check to see if we are out of range */
45   if ((head < 0) || (head >= 2) || (track < 0) || (track >= 80)
46         || (sector < 0) || (sector >= 6))
47      return FLOPPY_ERROR_SEEKERROR;
42#include "emu.h"
43#include "formats/smx_dsk.h"
4844
49   offs = smx_translate_offset(floppy, track, head, sector);
50   if (offset)
51      *offset = offs;
52   return FLOPPY_ERROR_SUCCESS;
53}
54
55
56
57static floperr_t internal_smx_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
45smx_format::smx_format() : wd177x_format(formats)
5846{
59   UINT64 offset;
60   floperr_t err;
61   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
62   if (err)
63      return err;
64
65   floppy_image_read(floppy, buffer, offset, buflen);
66   return FLOPPY_ERROR_SUCCESS;
6747}
6848
69
70
71static floperr_t internal_smx_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
49const char *smx_format::name() const
7250{
73   UINT64 offset;
74   floperr_t err;
75
76   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
77   if (err)
78      return err;
79
80   floppy_image_write(floppy, buffer, offset, buflen);
81   return FLOPPY_ERROR_SUCCESS;
51   return "smx";
8252}
8353
84
85
86static floperr_t smx_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
54const char *smx_format::description() const
8755{
88   return internal_smx_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
56   return "Specialist MX disk image";
8957}
9058
91static floperr_t smx_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
59const char *smx_format::extensions() const
9260{
93   return internal_smx_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam);
61   return "odi";
9462}
9563
96static floperr_t smx_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
64// Unverified gap sizes
65const smx_format::format smx_format::formats[] =
9766{
98   return internal_smx_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
99}
67   {   //  720K 5.25 inch
68      floppy_image::FF_525,  floppy_image::DSQD,
69      2000, 5, 80, 2, 1024, {}, 1, {}, 100, 22, 20
70   },
71   {}
72};
10073
101static floperr_t smx_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
102{
103   return internal_smx_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam);
104}
105
106static floperr_t smx_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length)
107{
108   floperr_t err;
109   err = get_offset(floppy, head, track, sector, FALSE, NULL);
110   if (err)
111      return err;
112
113   if (sector_length) {
114      *sector_length = 1024;
115   }
116   return FLOPPY_ERROR_SUCCESS;
117}
118
119
120
121static floperr_t smx_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
122{
123   sector_index += 1;
124   if (cylinder)
125      *cylinder = track;
126   if (side)
127      *side = head;
128   if (sector)
129      *sector = sector_index;
130   if (flags)
131      /* TODO: read DAM or DDAM and determine flags */
132      *flags = 0;
133   return smx_get_sector_length(floppy, head, track, sector_index, sector_length);
134}
135
136
137static FLOPPY_CONSTRUCT(smx_dsk_construct)
138{
139   struct FloppyCallbacks *callbacks;
140   callbacks = floppy_callbacks(floppy);
141   callbacks->read_sector = smx_read_sector;
142   callbacks->write_sector = smx_write_sector;
143   callbacks->read_indexed_sector = smx_read_indexed_sector;
144   callbacks->write_indexed_sector = smx_write_indexed_sector;
145   callbacks->get_sector_length = smx_get_sector_length;
146   callbacks->get_heads_per_disk = smx_get_heads_per_disk;
147   callbacks->get_tracks_per_disk = smx_get_tracks_per_disk;
148   callbacks->get_indexed_sector_info = smx_get_indexed_sector_info;
149
150   return FLOPPY_ERROR_SUCCESS;
151}
152
153
154
155/* ----------------------------------------------------------------------- */
156
157LEGACY_FLOPPY_OPTIONS_START( specimx )
158   LEGACY_FLOPPY_OPTION( smx_dsk, "odi", "Specialist MX floppy disk image",   smx_dsk_identify, smx_dsk_construct, NULL, NULL)
159LEGACY_FLOPPY_OPTIONS_END
74const floppy_format_type FLOPPY_SMX_FORMAT = &floppy_image_format_creator<smx_format>;
trunk/src/lib/formats/smx_dsk.h
r19519r19520
22
33    formats/smx_dsk.h
44
5    SVI318 disk images
5    Specialist MX disk images
66
77*********************************************************************/
88
9#ifndef SMX_DSK_H
10#define SMX_DSK_H
9#ifndef SMX_DSK_H_
10#define SMX_DSK_H_
1111
12#include "flopimg.h"
12#include "wd177x_dsk.h"
1313
14/**************************************************************************/
14class smx_format : public wd177x_format {
15public:
16   smx_format();
1517
16LEGACY_FLOPPY_OPTIONS_EXTERN(specimx);
18   virtual const char *name() const;
19   virtual const char *description() const;
20   virtual const char *extensions() const;
1721
18#endif /* SVI_DSK_H */
22private:
23   static const format formats[];
24};
25
26extern const floppy_format_type FLOPPY_SMX_FORMAT;
27
28#endif
trunk/src/mess/drivers/special.c
r19519r19520
379379   NULL
380380};
381381
382FLOPPY_FORMATS_MEMBER( special_state::specimx_floppy_formats )
383   FLOPPY_SMX_FORMAT
384FLOPPY_FORMATS_END
385
382386static SLOT_INTERFACE_START( specimx_floppies )
383387   SLOT_INTERFACE( "525dd", FLOPPY_525_DD )
384388SLOT_INTERFACE_END
r19519r19520
446450   /* Devices */
447451   MCFG_FD1793x_ADD("fd1793", XTAL_8MHz / 8)
448452
449   MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)
450   MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)
453   MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
454   MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
451455
452456   /* internal ram */
453457   MCFG_RAM_ADD(RAM_TAG)
r19519r19520
485489   MCFG_I8255_ADD( "ppi8255", specialist_ppi8255_interface )
486490   MCFG_FD1793x_ADD("fd1793", XTAL_8MHz / 8)
487491
488   MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)
489   MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)   
492   MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
493   MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
490494
491495   /* internal ram */
492496   MCFG_RAM_ADD(RAM_TAG)
trunk/src/mess/includes/special.h
r19519r19520
1515#include "machine/i8255.h"
1616#include "machine/pit8253.h"
1717#include "imagedev/cassette.h"
18#include "formats/smx_dsk.h"
1819#include "formats/rk_cas.h"
1920#include "machine/wd_fdc.h"
2021#include "machine/ram.h"
r19519r19520
9596   TIMER_CALLBACK_MEMBER(special_reset);
9697   TIMER_CALLBACK_MEMBER(setup_pit8253_gates);
9798   void fdc_drq(bool state);   
99   DECLARE_FLOPPY_FORMATS( specimx_floppy_formats );
98100};
99101
100102

Previous 199869 Revisions Next


© 1997-2024 The MAME Team