Merge branch 'master' of git@github.com:optixx/snesram
Conflicts: snes/fatfstest/debug.c snes/fatfstest/main.c
This commit is contained in:
commit
ae0f35d746
@ -7,7 +7,7 @@ ifeq ($(PLATFORM),Linux)
|
|||||||
# Linux Wine
|
# Linux Wine
|
||||||
SDK=/home/david/.wine/drive_c/65xx_FreeSDK
|
SDK=/home/david/.wine/drive_c/65xx_FreeSDK
|
||||||
WINE=wine
|
WINE=wine
|
||||||
EMU=zsnes
|
EMU=../../tools/bsnes/bsnes
|
||||||
EMU_DEBUG=/home/david/Devel/arch/snes/tools/zsnes_linux_debug151/src/zsnesd -d
|
EMU_DEBUG=/home/david/Devel/arch/snes/tools/zsnes_linux_debug151/src/zsnesd -d
|
||||||
else
|
else
|
||||||
# Mac Wine
|
# Mac Wine
|
||||||
@ -69,4 +69,4 @@ $(APP): $(OBJS)
|
|||||||
ucon64 -snes -chk $(APP)
|
ucon64 -snes -chk $(APP)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -vf $(APP) *.obj
|
rm -vf $(APP) *.obj *.TMP
|
||||||
|
|||||||
@ -7,9 +7,10 @@
|
|||||||
#include "PPU.h"
|
#include "PPU.h"
|
||||||
#include "ressource.h"
|
#include "ressource.h"
|
||||||
|
|
||||||
|
|
||||||
word debugMap[0x400];
|
word debugMap[0x400];
|
||||||
static char debug_buffer[255];
|
static char debug_buffer[255];
|
||||||
char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
|
||||||
|
|
||||||
void debug_init(void) {
|
void debug_init(void) {
|
||||||
word i;
|
word i;
|
||||||
@ -19,6 +20,7 @@ void debug_init(void) {
|
|||||||
memset(debug_buffer,0,255);
|
memset(debug_buffer,0,255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void debug_enable(void){
|
void debug_enable(void){
|
||||||
VRAMLoad((word) debugFont_pic, 0x5000, 2048);
|
VRAMLoad((word) debugFont_pic, 0x5000, 2048);
|
||||||
CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16);
|
CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16);
|
||||||
@ -29,28 +31,17 @@ void debug_enable(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void int2hex(unsigned long number, char *buf,word size)
|
|
||||||
{
|
|
||||||
unsigned long n;
|
|
||||||
unsigned char i;
|
|
||||||
//unsigned char x;
|
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
n = number >> 4;
|
|
||||||
//x = (number - (n << 4));
|
|
||||||
buf[size-i-1] = hex_chars[(number - (n << 4))];
|
|
||||||
number = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
void _print_screen(word y, char *buffer){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void print_screen(char *buffer,word y){
|
|
||||||
char i;
|
char i;
|
||||||
char l;
|
char l;
|
||||||
l = strlen(buffer);
|
l = strlen(buffer);
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
for(i=0; i<32; i++) {
|
for(i=0; i<32; i++) {
|
||||||
|
if (buffer[i] == '\n' ) {
|
||||||
|
y++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (i<l)
|
if (i<l)
|
||||||
VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20)));
|
VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20)));
|
||||||
else
|
else
|
||||||
@ -58,55 +49,61 @@ void print_screen(char *buffer,word y){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _print_console(const char *buffer){
|
||||||
|
|
||||||
void print_console(char *buffer){
|
|
||||||
while(*buffer)
|
while(*buffer)
|
||||||
*(byte*) 0x3000=*buffer++;
|
*(byte*) 0x3000=*buffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printfc(char *fmt, ...){
|
|
||||||
va_list arg;
|
|
||||||
va_start(arg,fmt);
|
|
||||||
vsprintf(debug_buffer,fmt,arg);
|
|
||||||
print_console(debug_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* keep the linker happy */
|
/* keep the linker happy */
|
||||||
int open(const char * _name, int _mode){
|
int open(const char * _name, int _mode){
|
||||||
print_console("open called\n");
|
_print_console("open called\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int close(int fd){
|
int close(int fd){
|
||||||
print_console("close called\n");
|
_print_console("close called\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t read(int fd, void * buff, size_t len){
|
size_t read(int fd, void * buff, size_t len){
|
||||||
print_console("read called\n");
|
_print_console("read called\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t write(int fd, void * buffer, size_t len){
|
size_t write(int fd, void * buffer, size_t len){
|
||||||
print_console("write called\n");
|
_print_console("write called\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lseek(int fd, long off, int count){
|
long lseek(int fd, long off, int count){
|
||||||
print_console("lseek called\n");
|
_print_console("lseek called\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unlink(const char * name){
|
int unlink(const char * name){
|
||||||
print_console("unlink called\n");
|
_print_console("unlink called\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int isatty(){
|
int isatty(){
|
||||||
print_console("isatty called\n");
|
_print_console("isatty called\n");
|
||||||
return 1;
|
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,5 +1,5 @@
|
|||||||
void debug_init(void);
|
void debug_init(void);
|
||||||
void debug_enable(void);
|
void debug_enable(void);
|
||||||
void int2hex(unsigned long i, char *buf,word size);
|
void printfs(word y,char* fmt,...);
|
||||||
void print_screen(char* line,word y);
|
void printfc(char* fmt,...);
|
||||||
void print_console(char* line);
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ BYTE *image_addr;
|
|||||||
DSTATUS disk_initialize (BYTE drv) {
|
DSTATUS disk_initialize (BYTE drv) {
|
||||||
|
|
||||||
byte retval;
|
byte retval;
|
||||||
print_console("disk_initialize\n");
|
printfc("disk_initialize\n");
|
||||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ DSTATUS disk_initialize (BYTE drv) {
|
|||||||
while(*(byte*) MMIO_RETVAL == STA_VOID);
|
while(*(byte*) MMIO_RETVAL == STA_VOID);
|
||||||
retval = *(byte*) MMIO_RETVAL;
|
retval = *(byte*) MMIO_RETVAL;
|
||||||
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
||||||
print_console("disk_initialize done\n");
|
printfc("disk_initialize done\n");
|
||||||
return Stat;
|
return Stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,11 +80,11 @@ DRESULT disk_read (
|
|||||||
byte retval;
|
byte retval;
|
||||||
word i;
|
word i;
|
||||||
|
|
||||||
print_console("disk_read enter\n");
|
printfc("disk_read enter\n");
|
||||||
//if (drv || !count) return RES_PARERR;
|
//if (drv || !count) return RES_PARERR;
|
||||||
print_console("drv ok\n");
|
printfc("drv ok\n");
|
||||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
print_console("sta ok\n");
|
printfc("sta ok\n");
|
||||||
|
|
||||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||||
*(byte*) MMIO_CMD = CMD_READ;
|
*(byte*) MMIO_CMD = CMD_READ;
|
||||||
@ -92,14 +92,14 @@ DRESULT disk_read (
|
|||||||
*(byte*) MMIO_SECTOR01 = (sector >> 24) & 0xff;
|
*(byte*) MMIO_SECTOR01 = (sector >> 24) & 0xff;
|
||||||
*(byte*) MMIO_SECTOR02 = (sector >> 16) & 0xff;
|
*(byte*) MMIO_SECTOR02 = (sector >> 16) & 0xff;
|
||||||
*(byte*) MMIO_SECTOR03 = (sector >> 8) & 0xff;
|
*(byte*) MMIO_SECTOR03 = (sector >> 8) & 0xff;
|
||||||
*(byte*) MMIO_SECTOR04 = (sector >> 8) & 0xff;
|
*(byte*) MMIO_SECTOR04 = (sector) & 0xff;
|
||||||
|
|
||||||
*(byte*) MMIO_COUNT = count;
|
*(byte*) MMIO_COUNT = count;
|
||||||
|
|
||||||
while(*(byte*) MMIO_RETVAL == STA_VOID);
|
while(*(byte*) MMIO_RETVAL == STA_VOID);
|
||||||
retval = *(byte*) MMIO_RETVAL;
|
retval = *(byte*) MMIO_RETVAL;
|
||||||
|
|
||||||
print_console("copy buffer\n");
|
printfc("copy buffer\n");
|
||||||
for (i=0;i<(count*512);i++)
|
for (i=0;i<(count*512);i++)
|
||||||
*(byte*)(SHARED_ADDR+i) = buff[i];
|
*(byte*)(SHARED_ADDR+i) = buff[i];
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
#ifndef _INTEGER
|
#ifndef _INTEGER
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
|
||||||
/* These types must be 16-bit, 32-bit or larger integer */
|
/* These types must be 16-bit, 32-bit or larger integer */
|
||||||
typedef int INT;
|
typedef int INT;
|
||||||
typedef unsigned int UINT;
|
typedef unsigned int UINT;
|
||||||
@ -25,8 +29,12 @@ typedef unsigned long ULONG;
|
|||||||
typedef unsigned long DWORD;
|
typedef unsigned long DWORD;
|
||||||
|
|
||||||
/* Boolean type */
|
/* Boolean type */
|
||||||
typedef enum { FALSE = 0, TRUE } BOOL;
|
typedef enum {
|
||||||
|
FALSE = 0,
|
||||||
|
TRUE = 1
|
||||||
|
} BOOL;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _INTEGER
|
#define _INTEGER
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "data.h";
|
#include "data.h";
|
||||||
#include "pad.h";
|
#include "pad.h";
|
||||||
#include "event.h";
|
#include "event.h";
|
||||||
@ -5,27 +9,29 @@
|
|||||||
#include "ressource.h";
|
#include "ressource.h";
|
||||||
#include "PPU.h"
|
#include "PPU.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "integer.h"
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
padStatus pad1;
|
padStatus pad1;
|
||||||
|
|
||||||
|
|
||||||
WORD acc_size; /* Work register for fs command */
|
DWORD acc_size; /* Work register for fs command */
|
||||||
WORD acc_files, acc_dirs;
|
WORD acc_files, acc_dirs;
|
||||||
FILINFO finfo;
|
|
||||||
|
|
||||||
FATFS fatfs[2]; /* File system object for each logical drive */
|
FILINFO finfo;
|
||||||
BYTE buff[512]; /* Working buffer */
|
FATFS fatfs[2]; /* File system object for each logical drive */
|
||||||
|
BYTE Buff[512]; /* Working buffer */
|
||||||
|
|
||||||
|
DWORD p1, p2, p3;
|
||||||
|
BYTE res;
|
||||||
|
WORD w1;
|
||||||
|
UINT s1, s2, cnt;
|
||||||
|
|
||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
DIR dir; /* Directory object */
|
DIR dir; /* Directory object */
|
||||||
FIL file1, file2; /* File object */
|
FIL file1, file2; /* File object */
|
||||||
DWORD p1, p2, p3;
|
|
||||||
|
|
||||||
|
|
||||||
void initInternalRegisters(void) {
|
void initInternalRegisters(void) {
|
||||||
@ -56,54 +62,49 @@ DWORD get_fattime ()
|
|||||||
| ((DWORD)ptm->tm_sec >> 1);
|
| ((DWORD)ptm->tm_sec >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
|
||||||
FRESULT scan_files (char* path)
|
|
||||||
{
|
|
||||||
DIR dirs;
|
|
||||||
FRESULT res;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if ((res = f_opendir(&dirs, path)) == FR_OK) {
|
|
||||||
i = strlen(path);
|
|
||||||
//printf("Ok\n");
|
|
||||||
while (((res = f_readdir(&dirs, &finfo)) == FR_OK) && finfo.fname[0]) {
|
|
||||||
if (finfo.fattrib & AM_DIR) {
|
|
||||||
acc_dirs++;
|
|
||||||
*(path+i) = '/'; strcpy(path+i+1, &finfo.fname[0]);
|
|
||||||
res = scan_files(path);
|
|
||||||
*(path+i) = '\0';
|
|
||||||
if (res != FR_OK) break;
|
|
||||||
} else {
|
|
||||||
acc_files++;
|
|
||||||
acc_size += finfo.fsize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print_console("scan_files ret\n");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void put_rc (FRESULT rc)
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
static char str[] =
|
|
||||||
"OK\0" "NOT_READY\0" "NO_FILE\0" "FR_NO_PATH\0" "INVALID_NAME\0" "INVALID_DRIVE\0"
|
|
||||||
"DENIED\0" "EXIST\0" "RW_ERROR\0" "WRITE_PROTECTED\0" "NOT_ENABLED\0"
|
|
||||||
"NO_FILESYSTEM\0" "INVALID_OBJECT\0" "MKFS_ABORTED\0";
|
|
||||||
FRESULT i;
|
|
||||||
|
|
||||||
for (p = str, i = 0; i != rc && *p; i++) {
|
|
||||||
while(*p++);
|
|
||||||
}
|
|
||||||
print_console(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void halt(void) {
|
void halt(void) {
|
||||||
while(1);
|
while(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void put_rc (FRESULT rc){
|
||||||
|
const char *p;
|
||||||
|
static const char str[] =
|
||||||
|
"OK\0" "NOT_READY\0" "NO_FILE\0" "FR_NO_PATH\0" "INVALID_NAME\0" "INVALID_DRIVE\0"
|
||||||
|
"DENIED\0" "EXIST\0" "RW_ERROR\0" "WRITE_PROTECTED\0" "NOT_ENABLED\0"
|
||||||
|
"NO_FILESYSTEM\0" "INVALID_OBJECT\0" "MKFS_ABORTED\0";
|
||||||
|
FRESULT i;
|
||||||
|
|
||||||
|
for (p = str, i = 0; i != rc && *p; i++) {
|
||||||
|
while(*p++);
|
||||||
|
}
|
||||||
|
printfc("rc=%u FR_%s\n", (WORD)rc, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FRESULT scan_files (char* path){
|
||||||
|
DIR dirs;
|
||||||
|
FRESULT res;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ((res = f_opendir(&dirs, path)) == FR_OK) {
|
||||||
|
i = strlen(path);
|
||||||
|
while (((res = f_readdir(&dirs, &finfo)) == FR_OK) && finfo.fname[0]) {
|
||||||
|
if (finfo.fattrib & AM_DIR) {
|
||||||
|
acc_dirs++;
|
||||||
|
*(path+i) = '/'; strcpy(path+i+1, &finfo.fname[0]);
|
||||||
|
res = scan_files(path);
|
||||||
|
*(path+i) = '\0';
|
||||||
|
if (res != FR_OK) break;
|
||||||
|
} else {
|
||||||
|
acc_files++;
|
||||||
|
acc_size += finfo.fsize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
word i,j;
|
word i,j;
|
||||||
BYTE res;
|
BYTE res;
|
||||||
@ -114,46 +115,32 @@ void main(void) {
|
|||||||
*(byte*) 0x2100 = 0x0f; // enable background
|
*(byte*) 0x2100 = 0x0f; // enable background
|
||||||
|
|
||||||
debug_enable();
|
debug_enable();
|
||||||
print_screen("FATFS TEST",0);
|
printfs(0,"FATFS ");
|
||||||
print_console("mount ");
|
|
||||||
|
|
||||||
put_rc(f_mount(0, &fatfs[0]));
|
printfc("Try to init disk\n");
|
||||||
|
put_rc(f_mount(0, &fatfs[p1]));
|
||||||
|
|
||||||
print_console("disk_initialize \n");
|
res = f_getfree("/", &p2, &fs);
|
||||||
disk_initialize(0);
|
if (res)
|
||||||
print_console("disk_read \n");
|
put_rc(res);
|
||||||
disk_read(0,buff,0xaabb,1);
|
|
||||||
print_console("disk_done \n");
|
printfs(0,"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 (lba) = %lu\nDIR start (lba,clustor) = %lu\nData start (lba) = %lu\n",
|
||||||
|
(WORD)fs->fs_type, (DWORD)fs->csize * 512, (WORD)fs->n_fats,
|
||||||
|
fs->n_rootdir, (DWORD)fs->sects_fat, (DWORD)fs->max_clust - 2,
|
||||||
|
fs->fatbase, fs->dirbase, fs->database);
|
||||||
|
|
||||||
|
acc_size = acc_files = acc_dirs = 0;
|
||||||
halt();
|
res = scan_files("/");
|
||||||
|
if (res)
|
||||||
res = f_getfree("/", &p2, &fs);
|
put_rc(res);
|
||||||
if (res) {
|
|
||||||
put_rc(res);
|
printfc("%u files, %lu bytes.\n%u folders.\n"
|
||||||
}
|
"%lu KB total disk space.\n%lu KB available.\n",
|
||||||
/*
|
acc_files, acc_size, acc_dirs,
|
||||||
printf("FAT type = %u\nBytes/Cluster = %lu\nNumber of FATs = %u\n"
|
(fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2));
|
||||||
"Root DIR entries = %u\nSectors/FAT = %lu\nNumber of clusters = %lu\n"
|
|
||||||
"FAT start (lba) = %lu\nDIR start (lba,clustor) = %lu\nData start (lba) = %lu\n",
|
|
||||||
(WORD)fs->fs_type, (DWORD)fs->csize * 512, (WORD)fs->n_fats,
|
|
||||||
fs->n_rootdir, (DWORD)fs->sects_fat, (DWORD)fs->max_clust - 2,
|
|
||||||
fs->fatbase, fs->dirbase, fs->database
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
acc_size = acc_files = acc_dirs = 0;
|
|
||||||
res = scan_files("/");
|
|
||||||
if (res) {
|
|
||||||
put_rc(res);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
printf("%u files, %lu bytes.\n%u folders.\n"
|
|
||||||
"%lu KB total disk space.\n%lu KB available.\n",
|
|
||||||
acc_files, acc_size, acc_dirs,
|
|
||||||
(fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
while(!pad1.start) {
|
while(!pad1.start) {
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user