trunk/src/emu/bus/a2bus/corvfdc02.c
r32456 | r32457 | |
5 | 5 | Implemention of the Corvus Systems CORVUS02 floppy controller |
6 | 6 | aka the "Buffered Floppy Controller" |
7 | 7 | |
8 | | Boot PROM 0.8 says 8" DSDD or 5.25" DSDD |
| 8 | Boot PROM 0.8 says 8" SSDD or 5.25" DSDD; we stick with 5.25" here |
| 9 | and let the FDC01 handle 8". |
9 | 10 | |
10 | 11 | *********************************************************************/ |
11 | 12 | |
12 | 13 | #include "corvfdc02.h" |
| 14 | #include "formats/concept_dsk.h" |
13 | 15 | |
14 | 16 | /*************************************************************************** |
15 | 17 | PARAMETERS |
r32456 | r32457 | |
25 | 27 | #define FDC02_FDC_TAG "fdc02_fdc" |
26 | 28 | |
27 | 29 | FLOPPY_FORMATS_MEMBER( a2bus_corvfdc02_device::corv_floppy_formats ) |
| 30 | FLOPPY_CONCEPT_525DSDD_FORMAT, |
28 | 31 | FLOPPY_IMD_FORMAT |
29 | 32 | FLOPPY_FORMATS_END |
30 | 33 | |
31 | 34 | static SLOT_INTERFACE_START( corv_floppies ) |
32 | | SLOT_INTERFACE( "8dsdd", FLOPPY_8_DSDD ) |
33 | 35 | SLOT_INTERFACE( "525dsqd", FLOPPY_525_QD ) |
34 | 36 | SLOT_INTERFACE_END |
35 | 37 | |
r32456 | r32457 | |
121 | 123 | m_fdc_local_status = 2; |
122 | 124 | m_fdc_local_command = 0; |
123 | 125 | m_curfloppy = NULL; |
| 126 | m_in_drq = false; |
124 | 127 | } |
125 | 128 | |
126 | 129 | /*------------------------------------------------- |
r32456 | r32457 | |
142 | 145 | |
143 | 146 | case 3: |
144 | 147 | // printf("Read buffer @ %x = %02x\n", m_bufptr, m_buffer[m_bufptr]); |
145 | | return m_buffer[m_bufptr]; |
| 148 | return m_buffer[m_bufptr--]; |
146 | 149 | |
147 | 150 | case 4: // local status |
148 | 151 | if (m_curfloppy) |
r32456 | r32457 | |
182 | 185 | break; |
183 | 186 | |
184 | 187 | case 3: // buffer write |
185 | | // printf("%02x to buffer @ %x\n", data, m_bufptr); |
| 188 | // printf("%02x to buffer[%x]\n", data, m_bufptr); |
186 | 189 | m_buffer[m_bufptr--] = data; |
187 | 190 | break; |
188 | 191 | |
r32456 | r32457 | |
261 | 264 | |
262 | 265 | WRITE_LINE_MEMBER(a2bus_corvfdc02_device::drq_w) |
263 | 266 | { |
264 | | // printf("DRQ: %d\n", state); |
| 267 | if (state) |
| 268 | { |
| 269 | // pseudo-DMA direction? |
| 270 | if (m_fdc_local_command & 0x40) |
| 271 | { |
| 272 | m_buffer[m_bufptr] = m_fdc->dma_r(); |
| 273 | // printf("DMA %02x to buffer[%x]\n", m_buffer[m_bufptr], m_bufptr); |
| 274 | m_bufptr--; |
| 275 | m_bufptr &= 0x1ff; |
| 276 | } |
| 277 | else |
| 278 | { |
| 279 | m_fdc->dma_w(m_buffer[m_bufptr++]); |
| 280 | m_bufptr &= 0x1ff; |
| 281 | } |
| 282 | } |
265 | 283 | } |
266 | 284 | |
trunk/src/lib/formats/concept_dsk.c
r0 | r32457 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Olivier Galibert, R. Belmont |
| 3 | /********************************************************************* |
| 4 | |
| 5 | formats/concept_dsk.c |
| 6 | |
| 7 | Formats for Corvus Concept |
| 8 | |
| 9 | 5.25" DSDD is PC MFM, 77 tracks, double-sided, with 9 sectors per track |
| 10 | |
| 11 | *********************************************************************/ |
| 12 | |
| 13 | #include "emu.h" |
| 14 | #include "flopimg.h" |
| 15 | #include "formats/concept_dsk.h" |
| 16 | |
| 17 | /* 9 sectors / track, 512 bytes per sector */ |
| 18 | const floppy_image_format_t::desc_e cc525dsdd_format::cc_9_desc[] = { |
| 19 | { MFM, 0x4e, 80 }, |
| 20 | { MFM, 0x00, 12 }, |
| 21 | { RAW, 0x5224, 3 }, |
| 22 | { MFM, 0xfc, 1 }, |
| 23 | { MFM, 0x4e, 50 }, |
| 24 | { MFM, 0x00, 12 }, |
| 25 | { SECTOR_LOOP_START, 1, 9 }, |
| 26 | { CRC_CCITT_START, 1 }, |
| 27 | { RAW, 0x4489, 3 }, |
| 28 | { MFM, 0xfe, 1 }, |
| 29 | { TRACK_ID }, |
| 30 | { HEAD_ID }, |
| 31 | { SECTOR_ID }, |
| 32 | { SIZE_ID }, |
| 33 | { CRC_END, 1 }, |
| 34 | { CRC, 1 }, |
| 35 | { MFM, 0x4e, 22 }, |
| 36 | { MFM, 0x00, 12 }, |
| 37 | { CRC_CCITT_START, 2 }, |
| 38 | { RAW, 0x4489, 3 }, |
| 39 | { MFM, 0xfb, 1 }, |
| 40 | { SECTOR_DATA, -1 }, |
| 41 | { CRC_END, 2 }, |
| 42 | { CRC, 2 }, |
| 43 | { MFM, 0x4e, 84 }, |
| 44 | { MFM, 0x00, 12 }, |
| 45 | { SECTOR_LOOP_END }, |
| 46 | { MFM, 0x4e, 170 }, |
| 47 | { END } |
| 48 | }; |
| 49 | |
| 50 | cc525dsdd_format::cc525dsdd_format() |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | const char *cc525dsdd_format::name() const |
| 55 | { |
| 56 | return "img"; |
| 57 | } |
| 58 | |
| 59 | const char *cc525dsdd_format::description() const |
| 60 | { |
| 61 | return "Corvus Concept 5.25\" DSDD floppy disk image"; |
| 62 | } |
| 63 | |
| 64 | const char *cc525dsdd_format::extensions() const |
| 65 | { |
| 66 | return "img"; |
| 67 | } |
| 68 | |
| 69 | bool cc525dsdd_format::supports_save() const |
| 70 | { |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | void cc525dsdd_format::find_size(io_generic *io, UINT8 &track_count, UINT8 &head_count, UINT8 §or_count) |
| 75 | { |
| 76 | UINT64 size = io_generic_size(io); |
| 77 | |
| 78 | track_count = 77; |
| 79 | head_count = 2; |
| 80 | sector_count = 9; |
| 81 | |
| 82 | UINT32 expected_size = 512 * track_count*head_count*sector_count; |
| 83 | if (size == expected_size) |
| 84 | { |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | track_count = head_count = sector_count = 0; |
| 89 | } |
| 90 | |
| 91 | int cc525dsdd_format::identify(io_generic *io, UINT32 form_factor) |
| 92 | { |
| 93 | UINT8 track_count, head_count, sector_count; |
| 94 | find_size(io, track_count, head_count, sector_count); |
| 95 | |
| 96 | if(track_count) |
| 97 | return 50; |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | bool cc525dsdd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) |
| 102 | { |
| 103 | UINT8 track_count, head_count, sector_count; |
| 104 | find_size(io, track_count, head_count, sector_count); |
| 105 | |
| 106 | UINT8 sectdata[10*512]; |
| 107 | desc_s sectors[10]; |
| 108 | for(int i=0; i<sector_count; i++) { |
| 109 | sectors[i+1].data = sectdata + 512*i; |
| 110 | sectors[i+1].size = 512; |
| 111 | sectors[i+1].sector_id = i+1; |
| 112 | } |
| 113 | |
| 114 | int track_size = sector_count*512; |
| 115 | for(int track=0; track < track_count; track++) { |
| 116 | for(int head=0; head < head_count; head++) { |
| 117 | io_generic_read(io, sectdata, (track*head_count + head)*track_size, track_size); |
| 118 | generate_track(cc_9_desc, track, head, sectors, sector_count, 100000, image); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | image->set_variant(floppy_image::DSDD); |
| 123 | |
| 124 | return true; |
| 125 | } |
| 126 | |
| 127 | bool cc525dsdd_format::save(io_generic *io, floppy_image *image) |
| 128 | { |
| 129 | int track_count, head_count, sector_count; |
| 130 | get_geometry_mfm_pc(image, 2000, track_count, head_count, sector_count); |
| 131 | |
| 132 | if(track_count != 77) |
| 133 | track_count = 77; |
| 134 | |
| 135 | // Happens for a fully unformatted floppy |
| 136 | if(!head_count) |
| 137 | head_count = 2; |
| 138 | |
| 139 | if(sector_count != 9) |
| 140 | sector_count = 9; |
| 141 | |
| 142 | UINT8 sectdata[9*512]; |
| 143 | int track_size = sector_count*512; |
| 144 | |
| 145 | for(int track=0; track < track_count; track++) { |
| 146 | for(int head=0; head < head_count; head++) { |
| 147 | get_track_data_mfm_pc(track, head, image, 2000, 512, sector_count, sectdata); |
| 148 | io_generic_write(io, sectdata, (track*head_count + head)*track_size, track_size); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return true; |
| 153 | } |
| 154 | |
| 155 | const floppy_format_type FLOPPY_CONCEPT_525DSDD_FORMAT = &floppy_image_format_creator<cc525dsdd_format>; |
trunk/src/lib/formats/concept_dsk.h
r0 | r32457 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | formats/concept_dsk.h |
| 4 | |
| 5 | Formats for Corvus Concept |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #ifndef CONCEPT_DSK_H_ |
| 10 | #define CONCEPT_DSK_H_ |
| 11 | |
| 12 | #include "flopimg.h" |
| 13 | |
| 14 | class cc525dsdd_format : public floppy_image_format_t |
| 15 | { |
| 16 | public: |
| 17 | cc525dsdd_format(); |
| 18 | |
| 19 | virtual int identify(io_generic *io, UINT32 form_factor); |
| 20 | virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); |
| 21 | virtual bool save(io_generic *io, floppy_image *image); |
| 22 | |
| 23 | virtual const char *name() const; |
| 24 | virtual const char *description() const; |
| 25 | virtual const char *extensions() const; |
| 26 | virtual bool supports_save() const; |
| 27 | |
| 28 | static const desc_e cc_9_desc[]; |
| 29 | |
| 30 | private: |
| 31 | void find_size(io_generic *io, UINT8 &track_count, UINT8 &head_count, UINT8 §or_count); |
| 32 | }; |
| 33 | |
| 34 | extern const floppy_format_type FLOPPY_CONCEPT_525DSDD_FORMAT; |
| 35 | |
| 36 | #endif /* CONCEPT_DSK_H_ */ |