Previous 15994 Revisions Next

r5954 Sunday 4th October, 2009 at 08:03:49 UTC by Robbbert
[EXIDY] Added preliminary floppy support, not working.
[src/mess]mess.mak
[src/mess/drivers]exidy.c
[src/mess/formats]exidydsk.c* exidydsk.h*

src/mess/mess.mak
r5953r5954
840840
841841$(MESSOBJ)/exidy.a:            \
842842   $(MESS_MACHINE)/exidy.o      \
843   $(MESS_FORMATS)/exidydsk.o   \
843844   $(MESS_DRIVERS)/exidy.o      \
844845   $(MESS_VIDEO)/exidy.o      \
845846
src/mess/formats/exidydsk.c
r0r5954
1/*********************************************************************
2 
3   formats/exi_dsk.c
4 
5   Exidy Sorcerer floppy-disk images
6 
7*********************************************************************/
8 
9#include <string.h>
10 
11#include "formats/exidydsk.h"
12#include "formats/basicdsk.h"
13#include "driver.h"
14 
15static FLOPPY_IDENTIFY(exi_dsk_identify)
16{
17   *vote = (floppy_image_size(floppy) == 332640) ? 100 : 0;
18   return FLOPPY_ERROR_SUCCESS;
19}
20 
21static int exi_get_heads_per_disk(floppy_image *floppy)
22{
23   return 1;
24}
25 
26static int exi_get_tracks_per_disk(floppy_image *floppy)
27{
28   return 77;
29}
30 
31static UINT64 exi_translate_offset(floppy_image *floppy, int track, int head, int sector)
32{
33   return 13+270*(16*track+sector);
34}
35 
36static floperr_t get_offset(floppy_image *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) || (track < 0) || (track >= 77) || (sector < 0) || (sector >= 16))
46      return FLOPPY_ERROR_SEEKERROR;
47 
48   offs = exi_translate_offset(floppy, track, head, sector);
49   if (offset)
50      *offset = offs;
51   return FLOPPY_ERROR_SUCCESS;
52}
53 
54 
55 
56static floperr_t internal_exi_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
57{
58   UINT64 offset;
59   floperr_t err;
60   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
61   if (err)
62      return err;
63 
64   floppy_image_read(floppy, buffer, offset, buflen);
65   return FLOPPY_ERROR_SUCCESS;
66}
67 
68 
69 
70static floperr_t internal_exi_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
71{
72   UINT64 offset;
73   floperr_t err;
74 
75   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
76   if (err)
77      return err;
78 
79   floppy_image_write(floppy, buffer, offset, buflen);
80   return FLOPPY_ERROR_SUCCESS;
81}
82 
83 
84 
85static floperr_t exi_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
86{
87   return internal_exi_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
88}
89 
90static floperr_t exi_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
91{
92   return internal_exi_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam);
93}
94 
95static floperr_t exi_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
96{
97   return internal_exi_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
98}
99 
100static floperr_t exi_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
101{
102   return internal_exi_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam);
103}
104 
105static floperr_t exi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
106{
107   floperr_t err;
108   err = get_offset(floppy, head, track, sector, FALSE, NULL);
109   if (err)
110      return err;
111 
112   if (sector_length) {
113      *sector_length = 256;
114   }
115   return FLOPPY_ERROR_SUCCESS;
116}
117 
118 
119 
120static floperr_t exi_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
121{
122   sector_index += 1;
123   if (cylinder)
124      *cylinder = track;
125   if (side)
126      *side = head;
127   if (sector)
128      *sector = sector_index;
129   if (flags)
130      /* TODO: read DAM or DDAM and determine flags */
131      *flags = 0;
132   return exi_get_sector_length(floppy, head, track, sector_index, sector_length);
133}
134 
135 
136static FLOPPY_CONSTRUCT(exi_dsk_construct)
137{
138   struct FloppyCallbacks *callbacks;
139   callbacks = floppy_callbacks(floppy);
140   callbacks->read_sector = exi_read_sector;
141   callbacks->write_sector = exi_write_sector;
142   callbacks->read_indexed_sector = exi_read_indexed_sector;
143   callbacks->write_indexed_sector = exi_write_indexed_sector;
144   callbacks->get_sector_length = exi_get_sector_length;
145   callbacks->get_heads_per_disk = exi_get_heads_per_disk;
146   callbacks->get_tracks_per_disk = exi_get_tracks_per_disk;
147   callbacks->get_indexed_sector_info = exi_get_indexed_sector_info;
148   
149   return FLOPPY_ERROR_SUCCESS;   
150}
151 
152 
153 
154/* ----------------------------------------------------------------------- */
155 
156FLOPPY_OPTIONS_START( exidy )
157   FLOPPY_OPTION( exi_dsk, "dsk", "Exidy Sorcerer floppy disk image", exi_dsk_identify, exi_dsk_construct, NULL)
158FLOPPY_OPTIONS_END
src/mess/formats/exidydsk.h
r0r5954
1/*********************************************************************
2 
3   formats/exi_dsk.h
4 
5   Exidy Sorcerer disk images
6 
7*********************************************************************/
8 
9#ifndef EXI_DSK_H
10#define EXI_DSK_H
11 
12#include "formats/flopimg.h"
13 
14/**************************************************************************/
15 
16FLOPPY_OPTIONS_EXTERN(exidy);
17 
18#endif /* EXI_DSK_H */
src/mess/drivers/exidy.c
r5953r5954
147147#include "devices/cartslot.h"
148148#include "machine/ay31015.h"
149149#include "devices/flopdrv.h"
150#include "formats/basicdsk.h"
150#include "formats/exidydsk.h"
151151#include "includes/exidy.h"
152152
153153
r5953r5954
339339   CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED
340340};
341341
342static FLOPPY_OPTIONS_START(exidy)
343   FLOPPY_OPTION(exidy, "dsk", "Exidy disk image", basicdsk_identify_default, basicdsk_construct_default,
344      HEADS([2])
345      TRACKS([80])
346      SECTORS([9])
347      SECTOR_LENGTH([512])
348      FIRST_SECTOR_ID([1]))
349FLOPPY_OPTIONS_END
350
351342static const floppy_config exidy_floppy_config =
352343{
353344   FLOPPY_DRIVE_DS_80,

Previous 15994 Revisions Next


© 1998-2018 The MESS Team