diff --git a/snes/fatfstest/config.h b/snes/fatfstest/config.h index 127dbe7..93cacbd 100644 --- a/snes/fatfstest/config.h +++ b/snes/fatfstest/config.h @@ -20,4 +20,4 @@ #define SHARED_ADDR 0x3d0000 -#define MMIO_DEBUG +#undef MMIO_DEBUG diff --git a/snes/fatfstest/debug.c b/snes/fatfstest/debug.c index 5295008..a53ff70 100644 --- a/snes/fatfstest/debug.c +++ b/snes/fatfstest/debug.c @@ -93,7 +93,7 @@ void _print_screen(word y, char *buffer){ *(byte*)0x2118 = *buffer-32; x++; buffer++; - //waitForVBlank(); + waitForVBlank(); } } void _print_console(const char *buffer){ diff --git a/snes/fatfstest/diskio.c b/snes/fatfstest/diskio.c index 23bd456..10a76cb 100644 --- a/snes/fatfstest/diskio.c +++ b/snes/fatfstest/diskio.c @@ -40,22 +40,22 @@ DSTATUS disk_initialize (BYTE drv) { byte retval; #ifdef MMIO_DEBUG - printfc("SNES::disk_initialize called drv=%i stat=%i\n",drv,Stat); + printfc("SNES::disk_initialize: called drv=%i stat=%i\n",drv,Stat); #endif if (drv) return STA_NOINIT; /* Supports only single drive */ Stat |= STA_NOINIT; #ifdef MMIO_DEBUG - printfc("SNES::disk_initialize stat=%i\n",Stat); + printfc("SNES::disk_initialize: stat=%i\n",Stat); #endif *(byte*) MMIO_RETVAL = STA_VOID; *(byte*) MMIO_CMD = CMD_INIT; #ifdef MMIO_DEBUG - printfc("SNES::disk_initialize poll retval\n"); + printfc("SNES::disk_initialize: poll retval\n"); #endif while((retval = *(byte*) MMIO_RETVAL) == STA_VOID); Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */ #ifdef MMIO_DEBUG - printfc("SNES::disk_initialize done Stat=%i\n",Stat); + printfc("SNES::disk_initialize: done Stat=%i\n",Stat); #endif return Stat; } @@ -88,15 +88,15 @@ DRESULT disk_read ( word i; //#ifdef MMIO_DEBUG - printfc("SNES::disk_read called sector=%li count=%i\n",sector,count); + printfc("SNES::disk_read: sector=%li count=%i\n",sector,count); //#endif if (drv || !count) return RES_PARERR; #ifdef MMIO_DEBUG - printfc("SNES::disk_read drv ok\n"); + printfc("SNES::disk_read: drv ok\n"); #endif if (Stat & STA_NOINIT) return RES_NOTRDY; #ifdef MMIO_DEBUG - printfc("SNES::disk_read sta ok\n"); + printfc("SNES::disk_read: sta ok\n"); #endif *(byte*) MMIO_RETVAL = STA_VOID; @@ -110,13 +110,13 @@ DRESULT disk_read ( *(byte*) MMIO_COUNT = count; #ifdef MMIO_DEBUG - printfc("SNES::disk_read poll retval\n"); + printfc("SNES::disk_read: poll retval\n"); #endif while((retval = *(byte*) MMIO_RETVAL) == STA_VOID); #ifdef MMIO_DEBUG - printfc("SNES::disk_read copy buffer to %lx\n",SHARED_ADDR); + printfc("SNES::disk_read: copy buffer to %lx\n",SHARED_ADDR); #endif for (i=0;i<(count*512);i++){ buff[i] = *(byte*)(SHARED_ADDR+i); diff --git a/tools/bsnes/chip/fatfs/config.h b/tools/bsnes/chip/fatfs/config.h index 639399d..8b245ab 100644 --- a/tools/bsnes/chip/fatfs/config.h +++ b/tools/bsnes/chip/fatfs/config.h @@ -17,6 +17,6 @@ #define SHARED_MAX_SIZE 512 #define SHARED_ADDR 0x3d0000 -#undef MMIO_DEBUG -#undef FATFS_DEBUG +#define MMIO_DEBUG +#define FATFS_DEBUG #define DISKIO_DEBUG 1 \ No newline at end of file diff --git a/tools/bsnes/chip/fatfs/fatfs.cpp b/tools/bsnes/chip/fatfs/fatfs.cpp index 3699011..0218353 100644 --- a/tools/bsnes/chip/fatfs/fatfs.cpp +++ b/tools/bsnes/chip/fatfs/fatfs.cpp @@ -102,7 +102,9 @@ void FATFS::mmio_write(unsigned addr, uint8 data) { fflush(stderr); } if (addr >= MMIO_SECTOR01 && addr <= MMIO_SECTOR04){ - sector = data << ( (3 - ( addr - MMIO_SECTOR01)) << 3); + if (addr == MMIO_SECTOR01) + sector = 0; + sector |= data << ( (3 - ( addr - MMIO_SECTOR01)) << 3); #ifdef FATFS_DEBUG printf("BSNES::mmio_write set sector: byte=%i val=%i sector=%i \n",(3 - ( addr - MMIO_SECTOR01)),data,sector); #endif