David Voswinkel 15 anni fa
parent
commit
4a61063406

+ 4 - 4
snes/fatfstest/Makefile

@@ -28,7 +28,7 @@ LIBS=-L$(SDK)/lib/cl
 #-L$(SDK)/lib/c134
 
 
-OBJS=hook.obj StartupSnes.obj main.obj pad.obj PPU.obj debug.obj ressource.obj diskio.obj ff.obj
+OBJS=hook.obj StartupSnes.obj main.obj pad.obj PPU.obj debug.obj ressource.obj diskio.obj ff.obj crc.obj
 APP=fatfs.smc
 GFX=debugfont
 
@@ -66,11 +66,11 @@ hook.obj: hook.asm
 
 $(APP): $(OBJS)
 		$(LD) -HB -M21 -V -T -Pff \
-                -C3e8000,000000 -U000000,000000 \
+                -C3e8000,1f0000 -U000000,000000 \
                 -Avectors=FFE4,7FE4 \
                 -Aregistration_data=FFB0,7FB0 \
-                -Aressource=3f8000,8000 \
-                -Ahook=0108000,0000 \
+                -Aressource=18000,8000 \
+                -Ahook=8000,0000 \
                 -N $(OBJS) $(LIBS) -O $@
 		ucon64 -snes -chk $(APP) 2>&1 >/dev/null
 

+ 1 - 1
snes/fatfstest/config.h

@@ -15,7 +15,7 @@
 
 
 #define SHARED_SIZE     512
-#define SHARED_ADDR     0x3f0000
+#define SHARED_ADDR     0x3d0000
 
 
 #undef MMIO_DEBUG

+ 37 - 0
snes/fatfstest/crc.c

@@ -0,0 +1,37 @@
+#include "data.h"
+
+
+word crc_update (char far *data, word size)
+{
+	word i;
+    word j;
+	word crc=0;
+	for (j=0; j<size; j++){
+		crc = crc ^ ((word)data[j]<< 8);
+		for (i=0; i<8; i++){
+        	if (crc & 0x8000)
+            	crc = (crc << 1) ^ 0x1021;
+        	else
+            	crc <<= 1;
+    	}
+	}
+	return crc;
+}
+
+
+word crc_update_mem (unsigned long addr, word size)
+{
+	word i;
+    word j;
+	word crc=0;
+	for (j=0; j<size; j++){
+		crc = crc ^ ((word) *(byte*)(addr+j)<< 8);
+		for (i=0; i<8; i++){
+        	if (crc & 0x8000)
+            	crc = (crc << 1) ^ 0x1021;
+        	else
+            	crc <<= 1;
+    	}
+	}
+	return crc;
+}

+ 4 - 0
snes/fatfstest/crc.h

@@ -0,0 +1,4 @@
+
+word crc_update (byte *data, word size);
+word crc_update_mem (unsigned long, word size);
+

+ 41 - 7
snes/fatfstest/debug.c

@@ -10,14 +10,10 @@
 
 
 
-word debug_colors[] = {
-  0xff7f, 0x1f00, 0x1802, 0x9772, 0xb55a, 0xbf5a, 0x1f5b, 0x7b73,
-  0x987f, 0x7f5f, 0xff03, 0xfc7f, 0xff7f, 0xff7f, 0xff7f, 0xff7f
-};
 
 word debugMap[0x400];
-static char debug_buffer[255];
-static char screen_buffer[255];
+static char debug_buffer[512];
+static char screen_buffer[512];
 
 /*
 word debug_colors[] = {
@@ -37,7 +33,6 @@ void debug_init(void) {
 
 void debug_enable(void){
 	VRAMLoad((word) debugFont_pic, 0x5000, 2048);
-	//CGRAMLoad((word) debug_colors, (byte) 0x00, (word) 16);
 	VRAMLoad((word) debugMap, 0x4000, 0x0800);
 	setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
 	setCharacterLocation(0x5000, (byte) 0);
@@ -101,12 +96,17 @@ void _print_console(const char *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);
+  //memset(debug_buffer,0,255);
+
 }
 
 void printfs(word y,char *fmt,...){
@@ -115,8 +115,42 @@ void printfs(word y,char *fmt,...){
   vsprintf(screen_buffer,fmt,ap);
   va_end(ap);
   _print_screen(y,screen_buffer);
+  memset(screen_buffer,0,255);
 }
 
+void printc_packet(unsigned long addr,unsigned int len,byte *packet){
+	unsigned int i,j;
+	unsigned int sum = 0;
+	unsigned int clear=0;
+	
+	for (i=0;i<len;i+=16) {
+		
+		sum = 0;
+		for (j=0;j<16;j++) {
+			sum +=packet[i+j];
+		}
+		if (!sum){
+			clear=1;
+			continue;
+		}
+		if (clear){
+			printfc("*\n");
+			clear = 0;
+		}	
+		printfc("%lx:", addr + i);
+		for (j=0;j<16;j++) {
+			printfc(" %x", packet[i+j]);
+		}
+		printfc(" |");
+		for (j=0;j<16;j++) {
+			if (packet[i+j]>=33 && packet[i+j]<=126 )
+				printfc("%c", packet[i+j]);
+			else
+				printfc(".");
+		}
+		printfc("|\n");
+	}
+}
 
 /* keep the linker happy */
 int open(const char * _name, int _mode){

+ 1 - 0
snes/fatfstest/debug.h

@@ -5,4 +5,5 @@ void debug_enable(void);
 void printfs(word y,char* fmt,...);
 void printfc(char* fmt,...);
 void clears(void);
+void printc_packet(unsigned long addr,unsigned int len,byte *packet);
 

+ 2 - 2
snes/fatfstest/diskio.c

@@ -87,9 +87,9 @@ DRESULT disk_read (
     byte retval;
     word i;
     
-    #ifdef MMIO_DEBUG
+    //#ifdef MMIO_DEBUG
     printfc("SNES::disk_read called sector=%li count=%i\n",sector,count);
-    #endif
+    //#endif
     if (drv || !count) return RES_PARERR;
     #ifdef MMIO_DEBUG
     printfc("SNES::disk_read drv ok\n");

+ 2 - 0
snes/fatfstest/hook.asm

@@ -3,3 +3,5 @@ HOOK SECTION
 HOOK:
     jsr   	>START
     brk
+
+

+ 46 - 16
snes/fatfstest/main.c

@@ -11,7 +11,7 @@
 #include "ressource.h";
 #include "PPU.h"
 #include "debug.h"
-
+#include "crc.h"
 
 /*
 
@@ -23,8 +23,11 @@ o exec loaded file
 */
 
 //#pragma section CODE=BANK2,offset $2:0000
-#define ROM_NAME "SUPER02.SMC"
+
+#define ROM_NAME "MRDO.SMC"
+//#define ROM_NAME "TEST.TXT"
 #define BLOCK_SIZE 512
+#define BASE_ADDR 0x008000
 
 
 padStatus pad1;
@@ -37,7 +40,11 @@ FATFS fatfs[2];             /* File system object for each logical drive */
 BYTE Buff[512];            /* Working buffer */
 
 DWORD p1, p2, p3;
-BYTE res;
+DWORD addr;
+DWORD crc_addr; 
+UINT crc;
+ 
+BYTE res,bank;
 WORD w1;
 UINT s1, s2, cnt;
 
@@ -132,7 +139,11 @@ void wait(void){
     //disablePad();
 }
 
-
+void boot(void){
+    #asm 
+        jsl  $008000 
+    #endasm 
+}
 
 void main(void) {
 	word i,j;
@@ -152,7 +163,7 @@ void main(void) {
 
     put_rc(f_mount(0, &fatfs[0]));
     
-#if 1
+#if 0
     printfc("SNES::main: Try to get free\n");
     res = f_getfree("", &p2, &fs);
     if (res)
@@ -232,14 +243,19 @@ void main(void) {
     put_rc(f_open(&file1, ROM_NAME, FA_READ));
 
 
-    p1 = 1024 * 16;
-    p2 = 0;
+    p1 = 32768L * 8; 
+    p2 = 0 ;
+    p3 = 0;
+    cnt = 0;
+    bank =0;
+    addr = BASE_ADDR;
+    crc_addr = BASE_ADDR;
     while (p1) {
         cnt = BLOCK_SIZE;
         p1 -= BLOCK_SIZE;
-        res = f_read(&file1, Buff, cnt, &s2);
-        printfc("SNES::main: read cnt=%i p1=%i p2=%i s2=%i\n",cnt,p1,p2,s2);
-        //printfc("SNES::main: read %x %x %x %x \n",Buff[0],Buff[1],Buff[2],Buff[3]);
+        res = f_read(&file1, (byte*)(addr) , cnt, &s2);
+        printfc("SNES::main: read cnt=%i p1=%li p2=%li s2=%i\n",cnt,p1,p2,s2);
+        //printfc("SNES::main: file %x %x %x %x\n",Buff[0],Buff[1],Buff[2],Buff[3]);
         if (res != FR_OK) {
             printfc("SNES::main: read failed\n");
             put_rc(res);
@@ -250,17 +266,31 @@ void main(void) {
           printfc("SNES::main: read cnt=%i s2=%i\n",cnt,s2);
           break;
         }
-        printfs(1,"%lu BYTES READ", p2);
-        
+        printfs(1 + bank,"BANK %X  ADDR %LX",bank,addr);
+        /*
         for (i=0; i<BLOCK_SIZE; i++){
-          *(byte*)(0x020000 + i) = Buff[i];
+          *(byte*)(addr  + i) = Buff[i];
         }
+        */
+        printfc("SNES::main: mem  %x %x %x %x %lx\n",*(byte*)(addr  + 0) ,*(byte*)(addr  + 1) ,*(byte*)(addr  + 2) ,*(byte*)(addr  + 3) ,addr);
+        //if (addr=0x10fe00){
+            
+        printc_packet(addr,512,(byte*)(addr));
+            
+        //}
         
-        printfs(2,"%i BYTES TANS %x",BLOCK_SIZE, 0x020000 + p2);
+        addr+=s2;
+        if (addr%0x10000==0){
+    		//crc = crc_update_mem(crc_addr,0x8000);
+            //printfc("addr=%lx crc=%x\n",crc_addr,crc);
+            //printfs(1 + bank,"BANK %X  ADDR %LX CRC %X",bank,addr,crc);
+            addr+=0x8000;
+            //crc_addr+=0x8000;
+            bank++;
+        }
     }
-    printfs(1,"%lu BYTES READ", p2);
     put_rc(f_close(&file1));
-  
+    boot();
     while(1){
       wait();
 	}	

+ 0 - 3
snes/fatfstest/ressource.asm

@@ -16,8 +16,5 @@ ressource	.section
 ~~debugFont_pic
 	INSERT ressource/debugFont.pic
 
-	XDEF ~~debugFont_pal
-~~debugFont_pal
-	INSERT ressource/debugFont.clr
 
 .ends

+ 0 - 1
snes/fatfstest/ressource.h

@@ -1,3 +1,2 @@
 
 extern word debugFont_pic[];
-extern word debugFont_pal[];