@@ -436,6 +436,9 @@ UINT8 sony_fetchtrack(const UINT8 *buffer, size_t buffer_len, size_t *pos)
436
436
(* pos )++ ;
437
437
* pos %= (buffer_len * 8 );
438
438
}
439
+
440
+ // printf("sony_fetchtrack: pos %ld = %02x\n", *pos/8, data);
441
+
439
442
return data ;
440
443
}
441
444
@@ -465,9 +468,10 @@ static UINT32 apple35_get_offset(floppy_image_legacy *floppy, int head, int trac
465
468
466
469
if (tag_offset )
467
470
{
468
- * tag_offset = sector_index * 12 + tag -> tag_offset ;
471
+ * tag_offset = sector_index * 12 ;
469
472
if (* tag_offset >= tag -> tag_size )
470
473
* tag_offset = ~0 ;
474
+ * tag_offset += tag -> tag_offset ;
471
475
}
472
476
return sector_index * 0x200 + tag -> data_offset ;
473
477
}
@@ -477,10 +481,11 @@ static UINT32 apple35_get_offset(floppy_image_legacy *floppy, int head, int trac
477
481
static floperr_t apple35_read_sector (floppy_image_legacy * floppy , int head , int track , int sector , void * buffer , size_t buflen )
478
482
{
479
483
UINT32 data_offset ;
480
- // printf("Read sector: T %d S %d H %d\n", track, sector, head);
481
484
data_offset = apple35_get_offset (floppy , head , track , sector , NULL );
482
485
if (data_offset == ~0 )
486
+ {
483
487
return FLOPPY_ERROR_SEEKERROR ;
488
+ }
484
489
floppy_image_read (floppy , buffer , data_offset , buflen );
485
490
return FLOPPY_ERROR_SUCCESS ;
486
491
}
@@ -507,18 +512,20 @@ static floperr_t apple35_read_sector_td(floppy_image_legacy *floppy, int head, i
507
512
508
513
assert (buflen == 524 );
509
514
510
- // printf("Read sector TD: T %d S %d H %d\n", track, sector, head);
511
-
512
515
/* first read the sector */
513
516
err = apple35_read_sector (floppy , head , track , sector , ((UINT8 * ) buffer ) + 12 , 512 );
514
517
if (err )
518
+ {
515
519
return err ;
520
+ }
516
521
517
522
/* read the tag data, if possible */
518
523
memset (buffer , '\0' , 12 );
519
524
apple35_get_offset (floppy , head , track , sector , & tag_offset );
520
525
if (tag_offset != ~0 )
526
+ {
521
527
floppy_image_read (floppy , buffer , tag_offset , 12 );
528
+ }
522
529
523
530
return FLOPPY_ERROR_SUCCESS ;
524
531
}
@@ -616,7 +623,10 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
616
623
/* read the sector */
617
624
err = apple35_read_sector_td (floppy , head , track , sector , sector_data , ARRAY_LENGTH (sector_data ));
618
625
if (err )
626
+ {
619
627
return err ;
628
+ }
629
+
620
630
sony_nibblize35 (sector_data , nibble_data , checksum );
621
631
622
632
for (i = 0 ; i < ARRAY_LENGTH (blk1 ); i ++ )
@@ -644,6 +654,7 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
644
654
for (i = 0 ; i < ARRAY_LENGTH (blk3 ); i ++ )
645
655
sony_filltrack ((UINT8 * )buffer , buflen , & pos , blk3 [i ]);
646
656
}
657
+
647
658
return FLOPPY_ERROR_SUCCESS ;
648
659
}
649
660
0 commit comments