@@ -436,6 +436,9 @@ UINT8 sony_fetchtrack(const UINT8 *buffer, size_t buffer_len, size_t *pos)
436436 (* pos )++ ;
437437 * pos %= (buffer_len * 8 );
438438 }
439+
440+ // printf("sony_fetchtrack: pos %ld = %02x\n", *pos/8, data);
441+
439442 return data ;
440443}
441444
@@ -465,9 +468,10 @@ static UINT32 apple35_get_offset(floppy_image_legacy *floppy, int head, int trac
465468
466469 if (tag_offset )
467470 {
468- * tag_offset = sector_index * 12 + tag -> tag_offset ;
471+ * tag_offset = sector_index * 12 ;
469472 if (* tag_offset >= tag -> tag_size )
470473 * tag_offset = ~0 ;
474+ * tag_offset += tag -> tag_offset ;
471475 }
472476 return sector_index * 0x200 + tag -> data_offset ;
473477}
@@ -477,10 +481,11 @@ static UINT32 apple35_get_offset(floppy_image_legacy *floppy, int head, int trac
477481static floperr_t apple35_read_sector (floppy_image_legacy * floppy , int head , int track , int sector , void * buffer , size_t buflen )
478482{
479483 UINT32 data_offset ;
480- // printf("Read sector: T %d S %d H %d\n", track, sector, head);
481484 data_offset = apple35_get_offset (floppy , head , track , sector , NULL );
482485 if (data_offset == ~0 )
486+ {
483487 return FLOPPY_ERROR_SEEKERROR ;
488+ }
484489 floppy_image_read (floppy , buffer , data_offset , buflen );
485490 return FLOPPY_ERROR_SUCCESS ;
486491}
@@ -507,18 +512,20 @@ static floperr_t apple35_read_sector_td(floppy_image_legacy *floppy, int head, i
507512
508513 assert (buflen == 524 );
509514
510- // printf("Read sector TD: T %d S %d H %d\n", track, sector, head);
511-
512515 /* first read the sector */
513516 err = apple35_read_sector (floppy , head , track , sector , ((UINT8 * ) buffer ) + 12 , 512 );
514517 if (err )
518+ {
515519 return err ;
520+ }
516521
517522 /* read the tag data, if possible */
518523 memset (buffer , '\0' , 12 );
519524 apple35_get_offset (floppy , head , track , sector , & tag_offset );
520525 if (tag_offset != ~0 )
526+ {
521527 floppy_image_read (floppy , buffer , tag_offset , 12 );
528+ }
522529
523530 return FLOPPY_ERROR_SUCCESS ;
524531}
@@ -616,7 +623,10 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
616623 /* read the sector */
617624 err = apple35_read_sector_td (floppy , head , track , sector , sector_data , ARRAY_LENGTH (sector_data ));
618625 if (err )
626+ {
619627 return err ;
628+ }
629+
620630 sony_nibblize35 (sector_data , nibble_data , checksum );
621631
622632 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
644654 for (i = 0 ; i < ARRAY_LENGTH (blk3 ); i ++ )
645655 sony_filltrack ((UINT8 * )buffer , buflen , & pos , blk3 [i ]);
646656 }
657+
647658 return FLOPPY_ERROR_SUCCESS ;
648659}
649660
0 commit comments