瀏覽代碼

o cleanup code
o get ls working

david 15 年之前
父節點
當前提交
0a50554f4a
共有 7 個文件被更改,包括 106 次插入41 次删除
  1. 62 27
      snes/fatfstest/debug.c
  2. 1 0
      snes/fatfstest/debug.h
  3. 34 12
      snes/fatfstest/main.c
  4. 6 0
      snes/fatfstest/pad.c
  5. 1 0
      snes/fatfstest/pad.h
  6. 二進制
      snes/fatfstest/ressource/debugFont.clr
  7. 2 2
      tools/ffsample/linux/Makefile

+ 62 - 27
snes/fatfstest/debug.c

@@ -2,6 +2,7 @@
 #include <stdarg.h>
 #include <fcntl.h>
 
+#include "debug.h"
 #include "data.h"
 #include "pad.h"
 #include "PPU.h"
@@ -10,7 +11,27 @@
 
 word debugMap[0x400];
 static char debug_buffer[255];
-
+static char screen_buffer[255];
+
+word col[] = {
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+      0x03ff,
+
+};
 
 void debug_init(void) {
 	word i;
@@ -31,7 +52,16 @@ void debug_enable(void){
 }
 
 
-void _print_char(word y,word x, unsigned char c){
+void clears(void) {
+    word x,y;
+    for(y=0; y<16; y++)
+      for(x=0; x<32; x++)
+        VRAMByteWrite((byte) (' '-32), (word) (0x4000+x+(y*0x20)));
+}
+
+
+void _print_char(word y,word x,  char c){
+  waitForVBlank();
   VRAMByteWrite((byte) (c-32), (word) (0x4000+x+(y*0x20)));
 }
 
@@ -41,23 +71,42 @@ void _print_screen(word y, char *buffer){
     l = strlen(buffer);
     waitForVBlank();
     while(*buffer){
+        
         if (*buffer == '\n' ) {
-          while(x++<32)
-              _print_char(y,x,' ');
-          x = 0;
-          y++;
-      }
-      _print_char(y,x,*buffer);
-      x++;
-      buffer++;
+            while(x++<32)
+                _print_char(y,x,' ');
+            x = 0;
+            y++;
+            buffer++;
+            continue;
+        }
+        _print_char(y,x,*buffer);
+        x++;
+        buffer++;
     }
 }
-
 void _print_console(const char *buffer){
-	while(*buffer)
-	    *(byte*) 0x3000=*buffer++;
+    while(*buffer)
+        *(byte*) 0x3000=*buffer++;
 }
 
+void printfc(char *fmt,...){
+  va_list ap;
+  va_start(ap,fmt);
+  vsprintf(debug_buffer,fmt,ap);
+  va_end(ap);
+  _print_console(debug_buffer);
+}
+
+void printfs(word y,char *fmt,...){
+  va_list ap;
+  va_start(ap,fmt);
+  vsprintf(screen_buffer,fmt,ap);
+  va_end(ap);
+  _print_screen(y,screen_buffer);
+}
+
+
 /* keep the linker happy */
 int open(const char * _name, int _mode){
     _print_console("open called\n");
@@ -94,18 +143,4 @@ int isatty(){
     _print_console("isatty called\n");
     return 1;
 }
-void printfc(char *fmt,...){
-  va_list ap;
-  va_start(ap,fmt);
-  vsprintf(debug_buffer,fmt,ap);
-  va_end(ap);
-  _print_console(debug_buffer);
-}
 
-void printfs(word y,char *fmt,...){
-  va_list ap;
-  va_start(ap,fmt);
-  vsprintf(debug_buffer,fmt,ap);
-  va_end(ap);
-  _print_screen(y,debug_buffer);
-}

+ 1 - 0
snes/fatfstest/debug.h

@@ -4,4 +4,5 @@ void debug_init(void);
 void debug_enable(void);
 void printfs(word y,char* fmt,...);
 void printfc(char* fmt,...);
+void clears(void);
 

+ 34 - 12
snes/fatfstest/main.c

@@ -108,22 +108,34 @@ FRESULT scan_files (char* path){
     return res;
 }
 
+void wait(){
+    printfc("SNES::wait: press A to continue\n");
+    enablePad();
+    pad1 = readPad((byte) 0);
+    while(!pad1.A) {
+        pad1 = readPad((byte) 0);
+    }
+    printfc("SNES::wait: done\n");
+    disablePad();
+}
+
+
 void main(void) {
 	word i,j;
     BYTE res;
 	initInternalRegisters();
+    
 	*(byte*) 0x2105 = 0x01;	// MODE 1 value
 	*(byte*) 0x212c = 0x01; // Plane 0 (bit one) enable register
 	*(byte*) 0x212d = 0x00;	// All subPlane disable
 	*(byte*) 0x2100 = 0x0f; // enable background
 
     debug_enable();
+
     printfs(0,"FATFS ");
-    printfs(2,"FATFS ");
-    printfs(3,"FATFS ");
-    printfs(4,"FATFS ");
-    halt();
+    //wait();
     printfc("SNES::main: Try to init disk\n");
+
     put_rc(f_mount(0, &fatfs[0]));
     
     
@@ -133,7 +145,7 @@ void main(void) {
         put_rc(res);
 
     printfc("SNES::main: printf fs results\n");
-    printfc("FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
+    printfs(1,"FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
             "ROOT DIR ENTRIES = %u\nSECTORS/FAT = %lu\nNUMBER OF CLUSTERS = %lu\n"
             "FAT START = %lu\nDIR START LBA,CLUSTER = %lu\nDATA START LBA = %lu\n",
             (WORD)fs->fs_type, (DWORD)fs->csize * 512, (WORD)fs->n_fats,
@@ -146,7 +158,7 @@ void main(void) {
     if (res)
         put_rc(res);
     
-    printfc("%u FILES, %lu BYTES\n%u FOLDERS\n"
+    printfs(12,"%u FILES, %lu BYTES\n%u FOLDERS\n"
            "%lu KB TOTAK DISK SPACE\n%lu KB AVAILABLE\n",
            acc_files, acc_size, acc_dirs,
            (fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2));
@@ -156,6 +168,9 @@ void main(void) {
       put_rc(res);
 
     p1 = s1 = s2 = 0;
+    cnt = 0;
+    wait();
+    clears();
     printfc("SNES::main: read dir\n");
     for(;;) {
         res = f_readdir(&dir, &finfo);
@@ -165,7 +180,9 @@ void main(void) {
         } else {
             s1++; p1 += finfo.fsize;
         }
-        printfc("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu  %s\n",
+        ;
+        
+        printfs(cnt,"%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu\n%s\n",
                     (finfo.fattrib & AM_DIR) ? 'D' : '-',
                     (finfo.fattrib & AM_RDO) ? 'R' : '-',
                     (finfo.fattrib & AM_HID) ? 'H' : '-',
@@ -174,16 +191,21 @@ void main(void) {
                     (finfo.fdate >> 9) + 1980, (finfo.fdate >> 5) & 15, finfo.fdate & 31,
                     (finfo.ftime >> 11), (finfo.ftime >> 5) & 63,
                     finfo.fsize, &(finfo.fname[0]));
+        cnt+=2;
+        /*
+        printfs(cnt,"%u/%02u/%02u %02u:%02u %9lu\n%s\n",
+                    (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);
-		}
+      wait();
 	}	
 	while(1);
 }

+ 6 - 0
snes/fatfstest/pad.c

@@ -1,11 +1,17 @@
 #include "data.h";
 #include "pad.h";
+#include "debug.h";
 
 void enablePad(void) {
 	// Enable pad reading and NMI
 	*(byte*)0x4200 = 0x81;
 }
 
+void disablePad(void) {
+    // Enable pad reading and NMI
+    *(byte*)0x4200 = 0x00;
+}
+
 padStatus readPad(byte padNumber) {
 	word test;
 	padStatus *status;

+ 1 - 0
snes/fatfstest/pad.h

@@ -16,4 +16,5 @@ typedef struct padStatus{
 } padStatus;
 
 extern void enablePad(void);
+extern void disablePad(void);
 extern padStatus readPad(byte padNumber);

二進制
snes/fatfstest/ressource/debugFont.clr


+ 2 - 2
tools/ffsample/linux/Makefile

@@ -44,9 +44,9 @@ image_not_parted:
 
 image:
 	rm -fv disk00.vfat
-	mkfs.vfat  -I -F 16 -v -C disk00.vfat 4000 
+	mkfs.vfat  -I -F 16 -v -C disk00.vfat 32000 
 	sudo mount -o loop disk00.vfat disk
-	sudo cp -v /var/log/*.log disk/
+	sudo cp -v ../../../roms/*smc  disk/
 	sudo umount disk
 
 mount: