Previous 15994 Revisions Next

r15003 Sunday 22nd April, 2012 at 21:07:39 UTC by Jonathan Gevaryahu
Some additional tweaks to ap2 and dfi stuff; disabled the horribly broken load() code in ap2_dsk. [Lord Nightmare, Balrog]
[src/lib/formats]ap2_dsk.c dfi_dsk.c

src/lib/formats/dfi_dsk.c
r15002r15003
3131
3232****************************************************************************/
3333
34/* TODO:
34/* DONE:
3535 * Support auto-identification heuristics for determining disk image speed,
3636   capture clock rate, and number of multireads per image.
37 * TODO:
38 * Scale captured data based on the guessed clock rate and samplerate to match
39   the internal 200mhz representation
3740 * Handle 0xFF bytes properly
3841 * Correctly note exact index timing.
3942 */
r15002r15003
4245#include "dfi_dsk.h"
4346#include <zlib.h>
4447#define NUMBER_OF_MULTIREADS 3
45// clockspeed: 100mhz = 4, 50mhz = 2, 25mhz = 1
46#define CLOCKSPEED 4
4748// threshholds for brickwall windowing
48#define MIN_CLOCKS 65
49#define MAX_CLOCKS 260
50#define MIN_THRESH (MIN_CLOCKS*CLOCKSPEED)
51#define MAX_THRESH (MAX_CLOCKS*CLOCKSPEED)
49//define MIN_CLOCKS 65
50#define MIN_CLOCKS 40
51//define MAX_CLOCKS 260
52#define MAX_CLOCKS 270
53#define MIN_THRESH (MIN_CLOCKS*(clock_rate/25000000))
54#define MAX_THRESH (MAX_CLOCKS*(clock_rate/25000000))
5255// constants to help guess clockrate and rpm
5356// constant is 25mhz / 6 revolutions per second (360rpm) = 4166667 +- 2.5%
5457#define REV25_MIN 4062500
5558#define REV25_MAX 4270833
5659// define the following to show a histogram per track
60//define TRACK_HISTOGRAM 1
5761#undef TRACK_HISTOGRAM
5862
5963dfi_format::dfi_format() : floppy_image_format_t()
r15002r15003
200204            if(v & 0x80) { // 0xFF an index, note the index (TODO: actually do this!) and do not add number
201205               index_polarity ^= 1;
202206               index_count += index_polarity;
203               if (index_count == NUMBER_OF_MULTIREADS) break;
207               //if (index_count == NUMBER_OF_MULTIREADS) break;
204208            }
205209         }
206210         else if((v & 0x80) == 0) { // 0x00-0x7E: not an index or carry, add the number and store transition
r15002r15003
221225            }
222226            if (trans_time > MAX_THRESH) { // we probably missed a transition
223227               mg = mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A;
224               //fprintf(stderr,"missed transition, total time for transition is %d\n",trans_time);
228               if (((track%2)==0)&&(head==0)) fprintf(stderr,"missed transition, total time for transition is %d\n",trans_time);
225229               buf[tpos++] = mg | UINT32((200000000ULL*(cur_time-(trans_time/2)))/index_time); // generate imaginary transition at half period
226230               buf[tpos++] = mg | UINT32(200000000ULL*cur_time/index_time); // generate transition now
227231               prev_time = cur_time;
r15002r15003
239243            if (((i+1)%10)==0) fprintf(stderr,"\n");
240244         }
241245      }
246      fprintf(stderr,"\n");
242247#endif
243248      index_count = 0;
244249      image->set_track_size(track, head, tpos);
src/lib/formats/ap2_dsk.c
r15002r15003
613613
614614bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
615615{
616
616/*      TODO: rewrite me properly
617617      UINT8 sector_data[(256)*16];
618618      memset(sector_data, 0, sizeof(sector_data));
619619
r15002r15003
637637                  generate_track(mac_gcr, track, head, sectors, 16, 3104*16, image);
638638            }
639639      }
640      return true;
640      return true;*/
641      return false; // I hope that throws an error...
641642}
642643
643644UINT8 a2_16sect_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap)
r15002r15003
664665      int g_tracks, g_heads;
665666      int visualgrid[16][35]; // visualizer grid, cleared/initialized below
666667#define NOTFOUND 0
668// address mark was found
667669#define ADDRFOUND 1
670// address checksum is good
668671#define ADDRGOOD 2
672// data mark was found (requires addrfound and sane values)
669673#define DATAFOUND 4
674// data checksum is good
670675#define DATAGOOD 8
676// data postamble is good
671677#define DATAPOST 16
672678      for (int i = 0; i < 16; i++) {
673679         for (int j = 0; j < 35; j++) {
r15002r15003
686692            int nsect = 16;
687693            UINT8 buf[130000]; // originally 13000, multiread dfi disks need larger
688694            int ts;
689fprintf(stderr,"DEBUG: a2_16sect_format::save() about to generate bitstream from physical track %d (logical %d)...", track, track/2);
695//fprintf(stderr,"DEBUG: a2_16sect_format::save() about to generate bitstream from physical track %d (logical %d)...", track, track/2);
690696            //~332 samples per cell, times 3+8+3 (14) for address mark, 24 for sync, 3+343+3 (349) for data mark, 24 for sync is around 743, near 776 expected
691            generate_bitstream_from_track(track, head, 200000000/(1552*nsect*2), buf, ts, image); // 3104 needs tweaking, *3 is 3x multiread from a dfi disk
692fprintf(stderr,"done.\n");
697            generate_bitstream_from_track(track, head, 200000000/(3104*nsect*3), buf, ts, image); // 3104 needs tweaking, *3 is 3x multiread from a dfi disk
698//fprintf(stderr,"done.\n");
693699            int pos = 0;
694700            int wrap = 0;
695701            int hb = 0;
r15002r15003
767773                                    // now decode it into 256 bytes
768774                                    // but only write it if the bitfield of the track shows datagood is NOT set.
769775                                    // if it is set we don't want to overwrite a guaranteed good read with a bad one
770                                    if ((visualgrid[se][track/2]&DATAGOOD)==0) {
771                                       // TODO:
772                                       // if the current read is good but the postamble isn't, write it in.
773                                       // if the current read isn't good but the postamble is, its better than nothing.
776                                    // if past read had a bad checksum or bad postamble...
777#ifndef USE_OLD_BEST_SECTOR_PRIORITY
778                                    if (((visualgrid[se][track/2]&DATAGOOD)==0)||((visualgrid[se][track/2]&DATAPOST)==0)) {
779                                       // if the current read is good, and postamble is good, write it in, no matter what.
780                                       // if the current read is good and the current postamble is bad, write it in unless the postamble was good before
781                                       // if the current read is bad and the current postamble is good and the previous read had neither good, write it in
774782                                       // if the current read isn't good and neither is the postamble but nothing better
775783                                       // has been written before, write it anyway.
776                                       for(int i=0x56; i<0x156; i++) {
777                                          UINT8 dv = data[i];
778                                          *dest++ = dv;
784                                       if ( ((data[0x156] == c) && (dpost&0xFFFF00)==0xDEAA00) ||
785                                       (((data[0x156] == c) && (dpost&0xFFFF00)!=0xDEAA00) && ((visualgrid[se][track/2]&DATAPOST)==0)) ||
786                                       (((data[0x156] != c) && (dpost&0xFFFF00)==0xDEAA00) && (((visualgrid[se][track/2]&DATAGOOD)==0)&&(visualgrid[se][track/2]&DATAPOST)==0)) ||
787                                       (((data[0x156] != c) && (dpost&0xFFFF00)!=0xDEAA00) && (((visualgrid[se][track/2]&DATAGOOD)==0)&&(visualgrid[se][track/2]&DATAPOST)==0))
788                                       ) {
789                                          for(int i=0x56; i<0x156; i++) {
790                                             UINT8 dv = data[i];
791                                             *dest++ = dv;
792                                          }
779793                                       }
780794                                    }
795#else
796                                    if ((visualgrid[se][track/2]&DATAGOOD)==0) {
797                                          for(int i=0x56; i<0x156; i++) {
798                                             UINT8 dv = data[i];
799                                             *dest++ = dv;
800                                          }
801                                    }
802#endif
781803                                    // do some checking
782                                    if ((data[0x156] != c) || (dpost&0xFFFF00)!=0xDEAA00) {
783                                    printf("Data Mark:\tChecksum xpctd %d found %d: %s, Postamble %03X: %s\n", data[0x156], c, (data[0x156]==c)?"OK":"BAD", dpost, (dpost&0xFFFF00)==0xDEAA00?"OK":"BAD");
784                                    }
785                                    else visualgrid[se][track/2] |= DATAGOOD;
804                                    if ((data[0x156] != c) || (dpost&0xFFFF00)!=0xDEAA00)
805                                       fprintf(stderr,"Data Mark:\tChecksum xpctd %d found %d: %s, Postamble %03X: %s\n", data[0x156], c, (data[0x156]==c)?"OK":"BAD", dpost, (dpost&0xFFFF00)==0xDEAA00?"OK":"BAD");
806                                    if (data[0x156] == c) visualgrid[se][track/2] |= DATAGOOD;
807                                    if ((dpost&0xFFFF00)==0xDEAA00) visualgrid[se][track/2] |= DATAPOST;
786808                              } else {
787809                                    pos = opos;
788810                                    wrap = owrap;
r15002r15003
805827      for (int j = 0; j < 35; j++) {
806828         printf("T%2d: ",j);
807829         for (int i = 0; i < 16; i++) {
808            if (visualgrid[i][j] == NOTFOUND) printf("-NF-");
830            if (visualgrid[i][j] == NOTFOUND) printf("-NF- ");
809831            else {
810832            if (visualgrid[i][j] & ADDRFOUND) printf("a"); else printf(" ");
811833            if (visualgrid[i][j] & ADDRGOOD) printf("A"); else printf(" ");
812834            if (visualgrid[i][j] & DATAFOUND) printf("d"); else printf(" ");
813835            if (visualgrid[i][j] & DATAGOOD) printf("D"); else printf(" ");
836            if (visualgrid[i][j] & DATAPOST) printf("."); else printf(" ");
814837            }
815            printf(" ");
816838         }
817839         printf("\n");
818840      }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team