Previous 15994 Revisions Next

r5683 Friday 11th September, 2009 at 08:45:37 UTC by Miodrag Milanović
Fixed floppy handling for DSK, fixes Einstain and some CPC games
[src/mess/formats]dsk_dsk.c

src/mess/formats/dsk_dsk.c
r5682r5683
2020{
2121   int disk_image_type;  /* image type: standard or extended */
2222   int heads;
23   int tracks;
24   int tracksize;
23   int tracks;   
2524   int sector_size;
25   UINT64 track_offsets[84*2]; /* offset within data for each track */
26   
2627};
2728
2829
r5682r5683
6364
6465static UINT64 dsk_get_track_offset(floppy_image *floppy, int head, int track)
6566{
66   return 0x100 + get_tag(floppy)->tracksize * ((track * get_tag(floppy)->heads) + head);
67   return get_tag(floppy)->track_offsets[(track<<1) + head];
6768}
6869
6970static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
r5682r5683
180181   UINT8 sector_info[0x100];
181182   int pos;
182183   
183   retVal = get_offset(floppy, head, track, sector_index+1, TRUE, NULL);
184   retVal = get_offset(floppy, head, track, sector_index+1, FALSE, NULL);
184185   offset = dsk_get_track_offset(floppy,head,track);
185186   pos = 0x18 + (sector_index << 3);
186187   floppy_image_read(floppy, sector_info, offset, 0x100);
r5682r5683
192193      *sector = sector_info[pos + 2];         
193194   if (sector_length) {
194195      *sector_length = 1 << (sector_info[pos + 3] + 7);
195   }         
196   }     
197   logerror("track : %d C %02x H %02x R %02x N %02x\n",track,sector_info[pos + 0],sector_info[pos + 1],sector_info[pos + 2],sector_info[pos + 3]);
196198   if (flags)
197199      *flags = (sector_info[pos + 5] & 0x40) ? ID_FLAG_DELETED_DATA : 0;
198200   return retVal;
r5682r5683
204206   struct FloppyCallbacks *callbacks;
205207   struct dskdsk_tag *tag;
206208   UINT8 header[0x100];
209   UINT64 tmp = 0;
210   int i;
211   int skip,cnt;
207212   
208213   floppy_image_read(floppy, header, 0, 0x100);
209214     
r5682r5683
212217      return FLOPPY_ERROR_OUTOFMEMORY;
213218
214219   tag->heads   = header[0x31];
220   if (tag->heads==1) {
221      skip = 2;
222   } else {
223      skip = 1;
224   }
215225   tag->tracks  = header[0x30];   
216   
226   cnt =0;
217227   if ( memcmp( header, MV_CPC, 8 ) ==0) {     
218228      tag->disk_image_type = 0;
219      tag->tracksize = pick_integer_le(header, 0x32, 2);
229      tmp = 0x100;
230      for (i=0; i<tag->tracks * tag->heads; i++)
231      {
232         tag->track_offsets[cnt] = tmp;         
233         tmp += pick_integer_le(header, 0x32, 2);
234         cnt += skip;
235      }     
220236   } else  {
221237      tag->disk_image_type = 1;
222      tag->tracksize = header[0x34] << 8;
238      tmp = 0x100;
239      for (i=0; i<tag->tracks * tag->heads; i++)
240      {         
241         tag->track_offsets[cnt] = tmp;         
242         tmp += header[0x34 + i] << 8;
243         cnt += skip;
244      }     
223245   }
224246
225247   callbacks = floppy_callbacks(floppy);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team