diff --git a/snes/fatfstest/Makefile b/snes/fatfstest/Makefile index 70ea76b..271a0e9 100644 --- a/snes/fatfstest/Makefile +++ b/snes/fatfstest/Makefile @@ -29,7 +29,11 @@ LIBS=-L$(SDK)/lib/cl #-L$(SDK)/lib/c134 +<<<<<<< HEAD:snes/fatfstest/Makefile OBJS=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 +>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/Makefile APP=fatfs.smc GFX=debugfont @@ -61,6 +65,7 @@ hook.obj: hook.asm $(AS) -V $? %.obj: %.c +<<<<<<< HEAD:snes/fatfstest/Makefile $(CC) -wl -wp -sop -ML -I $(INC) $? #$(APP): $(OBJS) @@ -84,6 +89,19 @@ $(APP): $(OBJS) hook.obj repair: $(APP) $(UCON) -snes -chk $(APP) 2>&1 >/dev/null rm -rf fatfs.bak +======= + $(CC) -wl -wp -sop -ML -I $(INC) $? + +$(APP): $(OBJS) + $(LD) -HB -M21 -V -T -Pff \ + -C3e8000,1f0000 -U000000,000000 \ + -Avectors=FFE4,7FE4 \ + -Aregistration_data=FFB0,7FB0 \ + -Aressource=18000,8000 \ + -Ahook=8000,0000 \ + -N $(OBJS) $(LIBS) -O $@ + ucon64 -snes -chk $(APP) 2>&1 >/dev/null +>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/Makefile diff --git a/snes/fatfstest/config.h b/snes/fatfstest/config.h index 6094016..c870802 100644 --- a/snes/fatfstest/config.h +++ b/snes/fatfstest/config.h @@ -15,7 +15,7 @@ #define SHARED_SIZE 512 -#define SHARED_ADDR 0x3f0000 +#define SHARED_ADDR 0x3d0000 #undef MMIO_DEBUG diff --git a/snes/fatfstest/crc.c b/snes/fatfstest/crc.c new file mode 100644 index 0000000..8c951a0 --- /dev/null +++ b/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=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){ diff --git a/snes/fatfstest/debug.h b/snes/fatfstest/debug.h index c9ed2a1..e8ba412 100644 --- a/snes/fatfstest/debug.h +++ b/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); diff --git a/snes/fatfstest/diskio.c b/snes/fatfstest/diskio.c index 166aa45..bf811db 100644 --- a/snes/fatfstest/diskio.c +++ b/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"); diff --git a/snes/fatfstest/hook.asm b/snes/fatfstest/hook.asm index b6c81ab..4b959dc 100644 --- a/snes/fatfstest/hook.asm +++ b/snes/fatfstest/hook.asm @@ -3,3 +3,5 @@ HOOK SECTION HOOK: jsr >START brk + + diff --git a/snes/fatfstest/main.c b/snes/fatfstest/main.c index e6cf141..d376d38 100644 --- a/snes/fatfstest/main.c +++ b/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,39 @@ void main(void) { printfc("SNES::main: read cnt=%i s2=%i\n",cnt,s2); break; } +<<<<<<< HEAD:snes/fatfstest/main.c printfs(1,"%lu BYTES READ", p2); +======= + printfs(1 + bank,"BANK %X ADDR %LX",bank,addr); +>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/main.c /* for (i=0; i>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/main.c } - printfs(1,"%lu BYTES READ", p2); put_rc(f_close(&file1)); - + boot(); while(1){ wait(); } diff --git a/snesram.tmproj b/snesram.tmproj index 72a28d8..0f8b05d 100644 --- a/snesram.tmproj +++ b/snesram.tmproj @@ -3,7 +3,7 @@ currentDocument - snes/fatfstest/integer.h + snes/fatfstest/pad.c documents @@ -35,6 +35,36 @@ firstVisibleLine 0 + poc/avr_sdcard/main.c + + caret + + column + 0 + line + 113 + + columnSelection + + firstVisibleColumn + 0 + firstVisibleLine + 106 + selectFrom + + column + 0 + line + 146 + + selectTo + + column + 0 + line + 113 + + poc/avr_sdcard/mmc.h caret @@ -77,33 +107,215 @@ firstVisibleLine 211 - snes/fatfstest/debug.c + snes/crc/crc.c caret column - 1 - line 39 + line + 27 firstVisibleColumn 0 firstVisibleLine 0 + snes/crc/debug.c + + caret + + column + 3 + line + 6 + + firstVisibleColumn + 0 + firstVisibleLine + 2 + + snes/crc/debug.h + + caret + + column + 10 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/crc/main.c + + caret + + column + 0 + line + 49 + + firstVisibleColumn + 0 + firstVisibleLine + 20 + + snes/fatfstest/Makefile + + caret + + column + 23 + line + 72 + + firstVisibleColumn + 0 + firstVisibleLine + 29 + + snes/fatfstest/StartupSnes.asm + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 97 + + snes/fatfstest/config.h + + caret + + column + 28 + line + 17 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/fatfstest/crc.c + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/fatfstest/crc.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/fatfstest/data.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/fatfstest/debug.c + + caret + + column + 0 + line + 144 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/fatfstest/debug.h + + caret + + column + 32 + line + 7 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/fatfstest/dis + + caret + + column + 0 + line + 32759 + + firstVisibleColumn + 0 + firstVisibleLine + 32759 + snes/fatfstest/diskio.c caret column - 25 + 6 line - 39 + 91 firstVisibleColumn 0 firstVisibleLine - 13 + 72 + + snes/fatfstest/event.c + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 39 snes/fatfstest/event.h @@ -119,14 +331,56 @@ firstVisibleLine 0 + snes/fatfstest/ff.c + + caret + + column + 0 + line + 1281 + + firstVisibleColumn + 0 + firstVisibleLine + 153 + + snes/fatfstest/ff.h + + caret + + column + 18 + line + 56 + + firstVisibleColumn + 0 + firstVisibleLine + 42 + + snes/fatfstest/hook.asm + + caret + + column + 0 + line + 7 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + snes/fatfstest/integer.h caret column - 2 + 28 line - 35 + 24 firstVisibleColumn 0 @@ -138,14 +392,28 @@ caret column - 13 + 0 line - 22 + 26 firstVisibleColumn 0 firstVisibleLine - 62 + 0 + + snes/fatfstest/myEvents.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 snes/fatfstest/pad.c @@ -161,19 +429,47 @@ firstVisibleLine 0 - tools/bsnes/cart/cart.cpp + snes/fatfstest/ressource.asm caret column 0 line - 95 + 14 firstVisibleColumn 0 firstVisibleLine - 44 + 0 + + snes/fatfstest/ressource.h + + caret + + column + 0 + line + 2 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tools/bsnes/cart/cart.cpp + + caret + + column + 24 + line + 48 + + firstVisibleColumn + 0 + firstVisibleLine + 33 tools/bsnes/cart/cart.hpp @@ -189,35 +485,77 @@ firstVisibleLine 24 - tools/bsnes/chip/fatfs/diskio.cpp + tools/bsnes/chip/fatfs/config.h caret column 0 line - 0 + 21 firstVisibleColumn 0 firstVisibleLine - 24 + 0 + + tools/bsnes/chip/fatfs/diskio.cpp + + caret + + column + 58 + line + 102 + + firstVisibleColumn + 0 + firstVisibleLine + 65 + + tools/bsnes/chip/fatfs/diskio.h + + caret + + column + 28 + line + 50 + + firstVisibleColumn + 0 + firstVisibleLine + 0 tools/bsnes/chip/fatfs/fatfs.cpp caret column - 23 + 2 line - 69 + 56 firstVisibleColumn 0 firstVisibleLine - 43 + 17 tools/bsnes/chip/fatfs/fatfs.hpp + + caret + + column + 31 + line + 10 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tools/bsnes/chip/fatfs/integer.h caret @@ -245,22 +583,121 @@ firstVisibleLine 0 + tools/bsnes/memory/memory.cpp + + caret + + column + 6 + line + 22 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tools/bsnes/memory/memory.hpp + + caret + + column + 31 + line + 132 + + firstVisibleColumn + 0 + firstVisibleLine + 84 + + tools/bsnes/memory/smemory/smemory.cpp + + caret + + column + 20 + line + 9 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tools/bsnes/memory/smemory/smemory.hpp + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tools/ffsample/linux/main.c + + caret + + column + 18 + line + 385 + + firstVisibleColumn + 0 + firstVisibleLine + 229 + openDocuments snes/fatfstest/debug.c snes/fatfstest/pad.c snes/fatfstest/diskio.c + snes/fatfstest/ff.c + tools/bsnes/memory/memory.hpp + tools/bsnes/memory/memory.cpp + tools/bsnes/memory/smemory/smemory.cpp + tools/bsnes/cart/cart.cpp + tools/bsnes/memory/smemory/smemory.hpp + snes/fatfstest/data.h + snes/fatfstest/ff.h + snes/fatfstest/event.c + snes/fatfstest/StartupSnes.asm snes/fatfstest/main.c + tools/ffsample/linux/main.c + snes/crc/crc.c + snes/crc/main.c + poc/avr_sdcard/main.c + snes/crc/debug.h + snes/crc/debug.c + snes/fatfstest/crc.h + snes/fatfstest/crc.c + snes/fatfstest/Makefile + snes/fatfstest/hook.asm + snes/fatfstest/myEvents.h + snes/fatfstest/ressource.asm + snes/fatfstest/ressource.h + snes/fatfstest/dis snes/fatfstest/event.h snes/fatfstest/integer.h tools/bsnes/chip/fatfs/fatfs.hpp + tools/bsnes/chip/fatfs/diskio.h tools/bsnes/chip/fatfs/fatfs.cpp + snes/fatfstest/debug.h + tools/bsnes/chip/fatfs/config.h + snes/fatfstest/config.h + tools/bsnes/chip/fatfs/integer.h tools/bsnes/chip/fatfs/diskio.cpp showFileHierarchyDrawer windowFrame - {{0, 60}, {1110, 818}} + {{0, 52}, {1205, 826}} diff --git a/tools/bsnes/cart/cart.cpp b/tools/bsnes/cart/cart.cpp index 60ea832..4daf269 100755 --- a/tools/bsnes/cart/cart.cpp +++ b/tools/bsnes/cart/cart.cpp @@ -46,8 +46,8 @@ void Cartridge::load_end() { memory::stAram.map(stA.ram, stA.ram_size); memory::stBrom.map(stB.rom, stB.rom_size); memory::stBram.map(stB.ram, stB.ram_size); - - memory::cartrom.write_protect(true); + /* enable rom write */ + memory::cartrom.write_protect(false); memory::cartram.write_protect(false); memory::bscram.write_protect(true); memory::stArom.write_protect(true); diff --git a/tools/bsnes/chip/fatfs/config.h b/tools/bsnes/chip/fatfs/config.h index 77ac0d0..c9b48f0 100644 --- a/tools/bsnes/chip/fatfs/config.h +++ b/tools/bsnes/chip/fatfs/config.h @@ -14,8 +14,8 @@ #define MMIO_RETVAL 0x3016 -#define SHARED_SIZE 512 -#define SHARED_ADDR 0x3f0000 +#define SHARED_MAX_SIZE 512 +#define SHARED_ADDR 0x3d0000 #undef MMIO_DEBUG #undef FATFS_DEBUG diff --git a/tools/bsnes/chip/fatfs/diskio.cpp b/tools/bsnes/chip/fatfs/diskio.cpp index 3387932..ad6c529 100644 --- a/tools/bsnes/chip/fatfs/diskio.cpp +++ b/tools/bsnes/chip/fatfs/diskio.cpp @@ -96,10 +96,11 @@ DRESULT disk_read ( DWORD offset = sector * 512; int size = count * 512; - #ifdef MMIO_DEBUG + //#ifdef MMIO_DEBUG printf("DISKIO::disk_read: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size); - #endif + //#endif memcpy(buff,image_addr + offset,size); + printf("%x %x %x %x\n",buff[0],buff[1],buff[2],buff[3]); #ifdef MMIO_DEBUG printf("DISKIO::disk_read: done\n"); #endif diff --git a/tools/bsnes/chip/fatfs/fatfs.cpp b/tools/bsnes/chip/fatfs/fatfs.cpp index 3edde01..974c7fc 100644 --- a/tools/bsnes/chip/fatfs/fatfs.cpp +++ b/tools/bsnes/chip/fatfs/fatfs.cpp @@ -13,7 +13,7 @@ void FATFS::init() { sector = 0; count = 0; retval = -1; - scratch_buffer = (unsigned char*)malloc(SHARED_SIZE); + scratch_buffer = (unsigned char*)malloc(SHARED_MAX_SIZE); } void FATFS::enable() { @@ -38,17 +38,17 @@ void FATFS::reset() { } -void FATFS::fetchMem() { - for ( int i=0;i - Open a file */ - if (!(&ptr, &p1)) break; + //if (!(&ptr, &p1)) break; while (*ptr == ' ') ptr++; - put_rc(f_open(&file1, ptr, (BYTE)p1)); + put_rc(f_open(&file1, ptr, (BYTE)FA_READ)); break; case 'c' : /* fc - Close a file */ @@ -383,7 +383,7 @@ int main (void) p2 += s2; if (cnt != s2) break; } - s2 = Timer; + s2 = Timer + 1; printf("%lu bytes read with %lu bytes/sec.\n", p2, p2 * 100 / s2); break;