o cleanup debug
This commit is contained in:
@@ -15,4 +15,7 @@
|
||||
|
||||
|
||||
#define SHARED_SIZE 512
|
||||
#define SHARED_ADDR 0x3f0000
|
||||
#define SHARED_ADDR 0x3f0000
|
||||
|
||||
|
||||
#undef MMIO_DEBUG
|
||||
|
||||
@@ -31,23 +31,26 @@ void debug_enable(void){
|
||||
}
|
||||
|
||||
|
||||
void _print_char(word y,word x, unsigned char c){
|
||||
VRAMByteWrite((byte) (c-32), (word) (0x4000+x+(y*0x20)));
|
||||
}
|
||||
|
||||
void _print_screen(word y, char *buffer){
|
||||
char i;
|
||||
char l;
|
||||
char x = 0;
|
||||
l = strlen(buffer);
|
||||
waitForVBlank();
|
||||
|
||||
for(i=0; i<32; i++) {
|
||||
if (buffer[i] == '\n' ) {
|
||||
while(*buffer){
|
||||
if (*buffer == '\n' ) {
|
||||
while(x++<32)
|
||||
_print_char(y,x,' ');
|
||||
x = 0;
|
||||
y++;
|
||||
continue;
|
||||
}
|
||||
if (i<l)
|
||||
VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20)));
|
||||
else
|
||||
VRAMByteWrite((byte) (' '-32), (word) (0x4000+i+(y*0x20)));
|
||||
}
|
||||
}
|
||||
_print_char(y,x,*buffer);
|
||||
x++;
|
||||
buffer++;
|
||||
}
|
||||
}
|
||||
|
||||
void _print_console(const char *buffer){
|
||||
@@ -55,8 +58,6 @@ void _print_console(const char *buffer){
|
||||
*(byte*) 0x3000=*buffer++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* keep the linker happy */
|
||||
int open(const char * _name, int _mode){
|
||||
_print_console("open called\n");
|
||||
|
||||
@@ -39,16 +39,24 @@ DSTATUS Stat = 0 ; //STA_NOINIT; /* Disk status */
|
||||
DSTATUS disk_initialize (BYTE drv) {
|
||||
|
||||
byte retval;
|
||||
#ifdef MMIO_DEBUG
|
||||
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);
|
||||
#endif
|
||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||
*(byte*) MMIO_CMD = CMD_INIT;
|
||||
#ifdef MMIO_DEBUG
|
||||
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);
|
||||
#endif
|
||||
return Stat;
|
||||
}
|
||||
|
||||
@@ -79,11 +87,17 @@ DRESULT disk_read (
|
||||
byte retval;
|
||||
word i;
|
||||
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read called sector=%li count=%i\n",sector,count);
|
||||
#endif
|
||||
if (drv || !count) return RES_PARERR;
|
||||
#ifdef MMIO_DEBUG
|
||||
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");
|
||||
#endif
|
||||
|
||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||
*(byte*) MMIO_CMD = CMD_READ;
|
||||
@@ -95,18 +109,25 @@ DRESULT disk_read (
|
||||
|
||||
*(byte*) MMIO_COUNT = count;
|
||||
|
||||
#ifdef MMIO_DEBUG
|
||||
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 %06lx\n",SHARED_ADDR);
|
||||
#endif
|
||||
for (i=0;i<(count*512);i++){
|
||||
buff[i] = *(byte*)(SHARED_ADDR+i);
|
||||
#ifdef MMIO_DEBUG
|
||||
if ( i < 8)
|
||||
printfc("0x%02x ",buff[i]);
|
||||
|
||||
#endif
|
||||
}
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("\n");
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -1368,14 +1368,12 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
||||
} else {
|
||||
vol = 0; /* No drive number is given, use drive number 0 as default */
|
||||
}
|
||||
printfc("auto_mount drv %i\n",vol);
|
||||
/* Check if the logical drive number is valid or not */
|
||||
if (vol >= _DRIVES) return FR_INVALID_DRIVE; /* Is the drive number valid? */
|
||||
*rfs = fs = FatFs[vol]; /* Returen pointer to the corresponding file system object */
|
||||
if (!fs) return FR_NOT_ENABLED; /* Is the file system object registered? */
|
||||
|
||||
ENTER_FF(fs); /* Lock file system */
|
||||
printfc("auto_mount ok enter_ff\n");
|
||||
|
||||
if (fs->fs_type) { /* If the logical drive has been mounted */
|
||||
stat = disk_status(fs->drive);
|
||||
@@ -1388,13 +1386,11 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
||||
}
|
||||
}
|
||||
|
||||
printfc("auto_mount mount now\n");
|
||||
/* The logical drive must be re-mounted. Following code attempts to mount the volume */
|
||||
|
||||
fs->fs_type = 0; /* Clear the file system object */
|
||||
fs->drive = LD2PD(vol); /* Bind the logical drive and a physical drive */
|
||||
stat = disk_initialize(fs->drive); /* Initialize low level disk I/O layer */
|
||||
printfc("auto_mount disk_initialize return %i\n",stat);
|
||||
if (stat & STA_NOINIT) /* Check if the drive is ready */
|
||||
return FR_NOT_READY;
|
||||
#if _MAX_SS != 512 /* Get disk sector size if needed */
|
||||
@@ -1405,7 +1401,6 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
||||
if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
|
||||
return FR_WRITE_PROTECTED;
|
||||
#endif
|
||||
printfc("auto_mount search fat now\n");
|
||||
/* Search FAT partition on the drive */
|
||||
fmt = check_fs(fs, bsect = 0); /* Check sector 0 as an SFD format */
|
||||
if (fmt == 1) { /* Not an FAT boot record, it may be patitioned */
|
||||
|
||||
@@ -119,8 +119,10 @@ void main(void) {
|
||||
|
||||
debug_enable();
|
||||
printfs(0,"FATFS ");
|
||||
|
||||
//halt();
|
||||
printfs(2,"FATFS ");
|
||||
printfs(3,"FATFS ");
|
||||
printfs(4,"FATFS ");
|
||||
halt();
|
||||
printfc("SNES::main: Try to init disk\n");
|
||||
put_rc(f_mount(0, &fatfs[0]));
|
||||
|
||||
@@ -129,7 +131,6 @@ void main(void) {
|
||||
res = f_getfree("", &p2, &fs);
|
||||
if (res)
|
||||
put_rc(res);
|
||||
//halt();
|
||||
|
||||
printfc("SNES::main: printf fs results\n");
|
||||
printfc("FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
|
||||
@@ -150,7 +151,35 @@ void main(void) {
|
||||
acc_files, acc_size, acc_dirs,
|
||||
(fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2));
|
||||
|
||||
while(1){
|
||||
res = f_opendir(&dir, "");
|
||||
if (res)
|
||||
put_rc(res);
|
||||
|
||||
p1 = s1 = s2 = 0;
|
||||
printfc("SNES::main: read dir\n");
|
||||
for(;;) {
|
||||
res = f_readdir(&dir, &finfo);
|
||||
if ((res != FR_OK) || !finfo.fname[0]) break;
|
||||
if (finfo.fattrib & AM_DIR) {
|
||||
s2++;
|
||||
} else {
|
||||
s1++; p1 += finfo.fsize;
|
||||
}
|
||||
printfc("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu %s\n",
|
||||
(finfo.fattrib & AM_DIR) ? 'D' : '-',
|
||||
(finfo.fattrib & AM_RDO) ? 'R' : '-',
|
||||
(finfo.fattrib & AM_HID) ? 'H' : '-',
|
||||
(finfo.fattrib & AM_SYS) ? 'S' : '-',
|
||||
(finfo.fattrib & AM_ARC) ? 'A' : '-',
|
||||
(finfo.fdate >> 9) + 1980, (finfo.fdate >> 5) & 15, finfo.fdate & 31,
|
||||
(finfo.ftime >> 11), (finfo.ftime >> 5) & 63,
|
||||
finfo.fsize, &(finfo.fname[0]));
|
||||
}
|
||||
printfc("%4u FILES, %10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
||||
if (f_getfree("", &p1, &fs) == FR_OK)
|
||||
printfc(", %10luK BYTES FREE\n", p1 * fs->csize / 2);
|
||||
|
||||
while(1){
|
||||
while(!pad1.start) {
|
||||
waitForVBlank();
|
||||
pad1 = readPad((byte) 0);
|
||||
|
||||
Reference in New Issue
Block a user