o fix sector calc

This commit is contained in:
david 2009-06-09 10:07:38 +02:00
parent 7bdc299e61
commit a4751edf97
5 changed files with 16 additions and 14 deletions

View File

@ -20,4 +20,4 @@
#define SHARED_ADDR 0x3d0000
#define MMIO_DEBUG
#undef MMIO_DEBUG

View File

@ -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){

View File

@ -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);

View File

@ -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

View File

@ -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