cleanup code
This commit is contained in:
parent
cb0ea4f8c8
commit
309e1062b9
@ -29,22 +29,15 @@ 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
|
||||
|
||||
all: $(APP) repair
|
||||
all: $(APP)
|
||||
|
||||
run:
|
||||
$(EMU) $(APP)
|
||||
|
||||
debugger:
|
||||
$(EMU_DEBUG) $(APP)
|
||||
|
||||
upload:
|
||||
ucon64 -chk $(APP)
|
||||
cp -rv $(APP) /Volumes/SNES
|
||||
@ -55,6 +48,10 @@ disasm: $(APP)
|
||||
rm -rf fatfs.asm
|
||||
$(DISASM) fatfs.smc > fatfs.asm
|
||||
|
||||
repair: $(APP)
|
||||
$(UCON) -snes -chk $(APP) 2>&1 >/dev/null
|
||||
rm -rf fatfs.bak
|
||||
|
||||
StartupSnes.obj: StartupSnes.asm
|
||||
$(AS) -V $?
|
||||
|
||||
@ -65,45 +62,17 @@ hook.obj: hook.asm
|
||||
$(AS) -V $?
|
||||
|
||||
%.obj: %.c
|
||||
<<<<<<< HEAD:snes/fatfstest/Makefile
|
||||
$(CC) -wl -wp -sop -ML -I $(INC) $?
|
||||
|
||||
#$(APP): $(OBJS)
|
||||
# $(LD) -HB -M21 -V -T -Pff \
|
||||
# -C008000,0000 -U0000,0000 \
|
||||
# -Avectors=FFE4,7FE4 \
|
||||
# -Aregistration_data=FFB0,7FB0 \
|
||||
# -Aressource=18000,8000 \
|
||||
# -N $(OBJS) $(LIBS) -O $@
|
||||
|
||||
$(APP): $(OBJS) hook.obj
|
||||
$(APP): $(OBJS)
|
||||
echo "test"
|
||||
$(LD) -B -HB -M21 -V -T -Pff \
|
||||
-C3e8000,1f0000 -U000000,000000 \
|
||||
-Avectors=FFE4,7FE4 \
|
||||
-Aregistration_data=FFB0,7FB0 \
|
||||
-Aressource=3f8000,1f8000 \
|
||||
-Ahook=008000,0000 \
|
||||
-N $(OBJS) hook.obj $(LIBS) -O $@
|
||||
|
||||
|
||||
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 \
|
||||
-Ahook=008000,0000 \
|
||||
-N $(OBJS) $(LIBS) -O $@
|
||||
ucon64 -snes -chk $(APP) 2>&1 >/dev/null
|
||||
>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/Makefile
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
rm -vf $(APP) *.obj *.TMP
|
||||
|
||||
@ -4,7 +4,9 @@
|
||||
#define CMD_WRITE 0x02
|
||||
#define CMD_NONE 0xff
|
||||
|
||||
/* Memory Map */
|
||||
/*
|
||||
* Memory Map
|
||||
*/
|
||||
#define MMIO_CMD 0x3010
|
||||
#define MMIO_SECTOR01 0x3011
|
||||
#define MMIO_SECTOR02 0x3012
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
word crc_update (byte *data, word size);
|
||||
word crc_update_mem (unsigned long, word size);
|
||||
|
||||
word crc_update(byte * data, word size);
|
||||
word crc_update_mem(unsigned long, word size);
|
||||
|
||||
@ -2,8 +2,7 @@
|
||||
|
||||
void debug_init(void);
|
||||
void debug_enable(void);
|
||||
void printfs(word y,char* fmt,...);
|
||||
void printfc(char* fmt,...);
|
||||
void printfs(word y, char *fmt, ...);
|
||||
void printfc(char *fmt, ...);
|
||||
void clears(void);
|
||||
void printc_packet(unsigned long addr,unsigned int len,byte *packet);
|
||||
|
||||
void printc_packet(unsigned long addr, unsigned int len, byte * packet);
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _DISKIO
|
||||
|
||||
@ -15,35 +15,43 @@
|
||||
#include "integer.h"
|
||||
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
/*
|
||||
* Status of Disk Functions
|
||||
*/
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
/*
|
||||
* Results of Disk Functions
|
||||
*/
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
RES_PARERR /* 4: Invalid Parameter */
|
||||
} DRESULT;
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
/*
|
||||
* Prototypes for disk control functions
|
||||
*/
|
||||
|
||||
DSTATUS disk_initialize (BYTE);
|
||||
DSTATUS disk_status (BYTE);
|
||||
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
|
||||
DSTATUS disk_initialize(BYTE);
|
||||
DSTATUS disk_status(BYTE);
|
||||
DRESULT disk_read(BYTE, BYTE *, DWORD, BYTE);
|
||||
#if _READONLY == 0
|
||||
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
|
||||
DRESULT disk_write(BYTE, const BYTE *, DWORD, BYTE);
|
||||
#endif
|
||||
DRESULT disk_ioctl (BYTE, BYTE, void*);
|
||||
void disk_timerproc (void);
|
||||
DRESULT disk_ioctl(BYTE, BYTE, void *);
|
||||
void disk_timerproc(void);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
/*
|
||||
* Disk Status Bits (DSTATUS)
|
||||
*/
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
@ -51,9 +59,13 @@ void disk_timerproc (void);
|
||||
#define STA_VOID 0xff
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl() */
|
||||
/*
|
||||
* Command code for disk_ioctrl()
|
||||
*/
|
||||
|
||||
/* Generic command */
|
||||
/*
|
||||
* Generic command
|
||||
*/
|
||||
#define CTRL_SYNC 0 /* Mandatory for write functions */
|
||||
#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
|
||||
#define GET_SECTOR_SIZE 2
|
||||
@ -66,6 +78,6 @@ void disk_timerproc (void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
typedef struct event{
|
||||
typedef struct event {
|
||||
word VBlankCount;
|
||||
char (*callback)(word counter);
|
||||
char (*callback) (word counter);
|
||||
struct event *previousEvent;
|
||||
struct event *nextEvent;
|
||||
} event;
|
||||
@ -11,6 +11,7 @@ typedef struct event{
|
||||
extern event *events;
|
||||
|
||||
void initEvents(void);
|
||||
extern event* addEvent(char (*callback)(word counter), int noDuplicateCallback);
|
||||
extern void removeEvent(event *eventElement);
|
||||
extern event *addEvent(char (*callback) (word counter),
|
||||
int noDuplicateCallback);
|
||||
extern void removeEvent(event * eventElement);
|
||||
extern void processEvents(void);
|
||||
|
||||
@ -26,120 +26,118 @@
|
||||
#define _FATFS
|
||||
|
||||
#define _WORD_ACCESS 0
|
||||
/* The _WORD_ACCESS option defines which access method is used to the word
|
||||
/ data in the FAT structure.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless following condition is met.
|
||||
/
|
||||
/ When the byte order on the memory is big-endian or address miss-aligned
|
||||
/ word access results incorrect behavior, the _WORD_ACCESS must be set to 0.
|
||||
/ If it is not the case, the value can also be set to 1 to improve the
|
||||
/ performance and code efficiency. */
|
||||
/*
|
||||
* The _WORD_ACCESS option defines which access method is used to the word / data in the FAT structure. / / 0: Byte-by-byte access. Always
|
||||
* compatible with all platforms. / 1: Word access. Do not choose this unless following condition is met. / / When the byte order on the
|
||||
* memory is big-endian or address miss-aligned / word access results incorrect behavior, the _WORD_ACCESS must be set to 0. / If it is not
|
||||
* the case, the value can also be set to 1 to improve the / performance and code efficiency.
|
||||
*/
|
||||
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||
/ f_truncate and useless f_getfree. */
|
||||
/*
|
||||
* Setting _FS_READONLY to 1 defines read only configuration. This removes / writing functions, f_write, f_sync, f_unlink, f_mkdir,
|
||||
* f_chmod, f_rename, / f_truncate and useless f_getfree.
|
||||
*/
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
|
||||
/
|
||||
/ 0: Full function.
|
||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename
|
||||
/ are removed.
|
||||
/ 2: f_opendir and f_readdir are removed in addition to level 1.
|
||||
/ 3: f_lseek is removed in addition to level 2. */
|
||||
/*
|
||||
* The _FS_MINIMIZE option defines minimization level to remove some functions. / / 0: Full function. / 1: f_stat, f_getfree, f_unlink,
|
||||
* f_mkdir, f_chmod, f_truncate and f_rename / are removed. / 2: f_opendir and f_readdir are removed in addition to level 1. / 3: f_lseek
|
||||
* is removed in addition to level 2.
|
||||
*/
|
||||
|
||||
|
||||
#define _FS_TINY 0
|
||||
/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
|
||||
/ object instead of the sector buffer in the individual file object for file
|
||||
/ data transfer. This reduces memory consumption 512 bytes each file object. */
|
||||
/*
|
||||
* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system / object instead of the sector buffer in the individual file
|
||||
* object for file / data transfer. This reduces memory consumption 512 bytes each file object.
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_STRFUNC 0
|
||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||
/*
|
||||
* To enable string functions, set _USE_STRFUNC to 1 or 2.
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_MKFS 0
|
||||
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
||||
/*
|
||||
* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
|
||||
/*
|
||||
* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1.
|
||||
*/
|
||||
|
||||
|
||||
#define _DRIVES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
/*
|
||||
* Number of volumes (logical drives) to be used.
|
||||
*/
|
||||
|
||||
|
||||
#define _MAX_SS 512
|
||||
/* Maximum sector size to be handled. (512/1024/2048/4096) */
|
||||
/* 512 for memroy card and hard disk, 1024 for floppy disk, 2048 for MO disk */
|
||||
/*
|
||||
* Maximum sector size to be handled. (512/1024/2048/4096)
|
||||
*/
|
||||
/*
|
||||
* 512 for memroy card and hard disk, 1024 for floppy disk, 2048 for MO disk
|
||||
*/
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0
|
||||
/* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical
|
||||
/ drive number and can mount only first primaly partition. When it is set to 1,
|
||||
/ each volume is tied to the partitions listed in Drives[]. */
|
||||
/*
|
||||
* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical / drive number and can mount only first primaly partition.
|
||||
* When it is set to 1, / each volume is tied to the partitions listed in Drives[].
|
||||
*/
|
||||
|
||||
|
||||
#define _CODE_PAGE 437
|
||||
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
|
||||
/ When it is non LFN configuration, there is no difference between SBCS code
|
||||
/ pages. When LFN is enabled, the code page must always be set correctly.
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 775 - Baltic
|
||||
/ 850 - Multilingual Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 858 - Multilingual Latin 1 + Euro
|
||||
/ 862 - Hebrew
|
||||
/ 866 - Russian
|
||||
/ 874 - Thai
|
||||
/ 932 - Japanese Shift-JIS (DBCS)
|
||||
/ 936 - Simplified Chinese GBK (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS)
|
||||
/ 1258 - Vietnam
|
||||
*/
|
||||
/*
|
||||
* The _CODE_PAGE specifies the OEM code page to be used on the target system. / When it is non LFN configuration, there is no difference
|
||||
* between SBCS code / pages. When LFN is enabled, the code page must always be set correctly. / 437 - U.S. / 720 - Arabic / 737 - Greek /
|
||||
* 775 - Baltic / 850 - Multilingual Latin 1 / 852 - Latin 2 / 855 - Cyrillic / 857 - Turkish / 858 - Multilingual Latin 1 + Euro / 862 -
|
||||
* Hebrew / 866 - Russian / 874 - Thai / 932 - Japanese Shift-JIS (DBCS) / 936 - Simplified Chinese GBK (DBCS) / 949 - Korean (DBCS) / 950
|
||||
* - Traditional Chinese Big5 (DBCS) / 1258 - Vietnam
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_LFN 0
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (max:255) */
|
||||
/* The _USE_LFN option switches the LFN support.
|
||||
/
|
||||
/ 0: Disable LFN.
|
||||
/ 1: Enable LFN with static working buffer on the bss. NOT REENTRANT.
|
||||
/ 2: Enable LFN with dynamic working buffer on the caller's STACK.
|
||||
/
|
||||
/ The working buffer occupies (_MAX_LFN + 1) * 2 bytes. When enable LFN,
|
||||
/ a Unicode - OEM code conversion function ff_convert() must be added to
|
||||
/ the project. */
|
||||
/*
|
||||
* The _USE_LFN option switches the LFN support. / / 0: Disable LFN. / 1: Enable LFN with static working buffer on the bss. NOT REENTRANT.
|
||||
* / 2: Enable LFN with dynamic working buffer on the caller's STACK. / / The working buffer occupies (_MAX_LFN + 1) * 2 bytes. When enable
|
||||
* LFN, / a Unicode - OEM code conversion function ff_convert() must be added to / the project.
|
||||
*/
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0
|
||||
#define _TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
||||
#define _SYNC_t HANDLE /* Type of sync object used on the OS. */
|
||||
/* e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
||||
/* To make the FatFs module re-entrant, set _FS_REENTRANT to 1 and add user
|
||||
/ provided synchronization handlers, ff_req_grant, ff_rel_grant,
|
||||
/ ff_del_syncobj and ff_cre_syncobj function to the project. */
|
||||
/*
|
||||
* e.g. HANDLE, OS_EVENT*, ID and etc..
|
||||
*/
|
||||
/*
|
||||
* To make the FatFs module re-entrant, set _FS_REENTRANT to 1 and add user / provided synchronization handlers, ff_req_grant,
|
||||
* ff_rel_grant, / ff_del_syncobj and ff_cre_syncobj function to the project.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* End of configuration options. Do not change followings without care. */
|
||||
/*
|
||||
* End of configuration options. Do not change followings without care.
|
||||
*/
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* Definitions corresponds to multiple sector size */
|
||||
/*
|
||||
* Definitions corresponds to multiple sector size
|
||||
*/
|
||||
|
||||
#if _MAX_SS == 512
|
||||
#define SS(fs) 512
|
||||
@ -153,7 +151,9 @@
|
||||
|
||||
|
||||
|
||||
/* File system object structure */
|
||||
/*
|
||||
* File system object structure
|
||||
*/
|
||||
|
||||
typedef struct _FATFS {
|
||||
BYTE fs_type; /* FAT sub type */
|
||||
@ -183,34 +183,38 @@ typedef struct _FATFS {
|
||||
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS];/* Disk access window for Directory/FAT */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory/FAT */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure */
|
||||
/*
|
||||
* Directory object structure
|
||||
*/
|
||||
|
||||
typedef struct _DIR {
|
||||
WORD id; /* Owner file system mount ID */
|
||||
WORD index; /* Current index number */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
FATFS *fs; /* Pointer to the owner file system object */
|
||||
DWORD sclust; /* Table start cluster (0:Static table) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
BYTE *dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE *fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WCHAR *lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File object structure */
|
||||
/*
|
||||
* File object structure
|
||||
*/
|
||||
|
||||
typedef struct _FIL {
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
FATFS *fs; /* Pointer to the owner file system object */
|
||||
WORD id; /* Owner file system mount ID */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
@ -221,16 +225,18 @@ typedef struct _FIL {
|
||||
DWORD dsect; /* Current data sector */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
BYTE *dir_ptr; /* Ponter to the directory entry in the window */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS];/* File R/W buffer */
|
||||
BYTE buf[_MAX_SS]; /* File R/W buffer */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* File status structure */
|
||||
/*
|
||||
* File status structure
|
||||
*/
|
||||
|
||||
typedef struct _FILINFO {
|
||||
DWORD fsize; /* File size */
|
||||
@ -246,7 +252,9 @@ typedef struct _FILINFO {
|
||||
|
||||
|
||||
|
||||
/* DBCS code ranges */
|
||||
/*
|
||||
* DBCS code ranges
|
||||
*/
|
||||
|
||||
#if _CODE_PAGE == 932 /* CP932 (Japanese Shift-JIS) */
|
||||
#define _DF1S 0x81 /* DBC 1st byte range 1 start */
|
||||
@ -291,7 +299,9 @@ typedef struct _FILINFO {
|
||||
|
||||
|
||||
|
||||
/* Character code support macros */
|
||||
/*
|
||||
* Character code support macros
|
||||
*/
|
||||
|
||||
#define IsUpper(c) (((c)>='A')&&((c)<='Z'))
|
||||
#define IsLower(c) (((c)>='a')&&((c)<='z'))
|
||||
@ -320,7 +330,9 @@ typedef struct _FILINFO {
|
||||
|
||||
|
||||
|
||||
/* Definitions corresponds to multi partition */
|
||||
/*
|
||||
* Definitions corresponds to multi partition
|
||||
*/
|
||||
|
||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||
|
||||
@ -343,7 +355,9 @@ const PARTITION Drives[]; /* Logical drive# to physical location conversion ta
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
/*
|
||||
* File function return code (FRESULT)
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* 0 */
|
||||
@ -367,33 +381,35 @@ typedef enum {
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
/*
|
||||
* FatFs module application interface
|
||||
*/
|
||||
|
||||
FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_open (FIL*, const char*, BYTE); /* Open or create a file */
|
||||
FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
|
||||
FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
|
||||
FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
|
||||
FRESULT f_close (FIL*); /* Close an open file object */
|
||||
FRESULT f_opendir (DIR*, const char*); /* Open an existing directory */
|
||||
FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
|
||||
FRESULT f_stat (const char*, FILINFO*); /* Get file status */
|
||||
FRESULT f_getfree (const char*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
|
||||
FRESULT f_truncate (FIL*); /* Truncate file */
|
||||
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink (const char*); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const char*); /* Create a new directory */
|
||||
FRESULT f_chmod (const char*, BYTE, BYTE); /* Change attriburte of the file/dir */
|
||||
FRESULT f_utime (const char*, const FILINFO*); /* Change timestamp of the file/dir */
|
||||
FRESULT f_rename (const char*, const char*); /* Rename/Move a file or directory */
|
||||
FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
|
||||
FRESULT f_mkfs (BYTE, BYTE, WORD); /* Create a file system on the drive */
|
||||
FRESULT f_mount(BYTE, FATFS *); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_open(FIL *, const char *, BYTE); /* Open or create a file */
|
||||
FRESULT f_read(FIL *, void *, UINT, UINT *); /* Read data from a file */
|
||||
FRESULT f_write(FIL *, const void *, UINT, UINT *); /* Write data to a file */
|
||||
FRESULT f_lseek(FIL *, DWORD); /* Move file pointer of a file object */
|
||||
FRESULT f_close(FIL *); /* Close an open file object */
|
||||
FRESULT f_opendir(DIR *, const char *); /* Open an existing directory */
|
||||
FRESULT f_readdir(DIR *, FILINFO *); /* Read a directory item */
|
||||
FRESULT f_stat(const char *, FILINFO *); /* Get file status */
|
||||
FRESULT f_getfree(const char *, DWORD *, FATFS **); /* Get number of free clusters on the drive */
|
||||
FRESULT f_truncate(FIL *); /* Truncate file */
|
||||
FRESULT f_sync(FIL *); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink(const char *); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir(const char *); /* Create a new directory */
|
||||
FRESULT f_chmod(const char *, BYTE, BYTE); /* Change attriburte of the file/dir */
|
||||
FRESULT f_utime(const char *, const FILINFO *); /* Change timestamp of the file/dir */
|
||||
FRESULT f_rename(const char *, const char *); /* Rename/Move a file or directory */
|
||||
FRESULT f_forward(FIL *, UINT(*)(const BYTE *, UINT), UINT, UINT *); /* Forward data to the stream */
|
||||
FRESULT f_mkfs(BYTE, BYTE, WORD); /* Create a file system on the drive */
|
||||
|
||||
#if _USE_STRFUNC
|
||||
int f_putc (int, FIL*); /* Put a character to the file */
|
||||
int f_puts (const char*, FIL*); /* Put a string to the file */
|
||||
int f_printf (FIL*, const char*, ...); /* Put a formatted string to the file */
|
||||
char* f_gets (char*, int, FIL*); /* Get a string from the file */
|
||||
int f_putc(int, FIL *); /* Put a character to the file */
|
||||
int f_puts(const char *, FIL *); /* Put a string to the file */
|
||||
int f_printf(FIL *, const char *, ...); /* Put a formatted string to the file */
|
||||
char *f_gets(char *, int, FIL *); /* Get a string from the file */
|
||||
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
||||
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
|
||||
#ifndef EOF
|
||||
@ -404,22 +420,32 @@ char* f_gets (char*, int, FIL*); /* Get a string from the file */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* User defined functions */
|
||||
/*
|
||||
* User defined functions
|
||||
*/
|
||||
|
||||
/* Real time clock */
|
||||
/*
|
||||
* Real time clock
|
||||
*/
|
||||
#if !_FS_READONLY
|
||||
DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
|
||||
/* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
|
||||
DWORD get_fattime(void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
|
||||
/*
|
||||
* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2)
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* Unicode - OEM code conversion */
|
||||
/*
|
||||
* Unicode - OEM code conversion
|
||||
*/
|
||||
#if _USE_LFN
|
||||
WCHAR ff_convert (WCHAR, UINT);
|
||||
WCHAR ff_convert(WCHAR, UINT);
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
/*
|
||||
* Sync functions
|
||||
*/
|
||||
#if _FS_REENTRANT
|
||||
BOOL ff_cre_syncobj(BYTE, _SYNC_t*);
|
||||
BOOL ff_cre_syncobj(BYTE, _SYNC_t *);
|
||||
BOOL ff_del_syncobj(_SYNC_t);
|
||||
BOOL ff_req_grant(_SYNC_t);
|
||||
void ff_rel_grant(_SYNC_t);
|
||||
@ -428,10 +454,14 @@ void ff_rel_grant(_SYNC_t);
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and offset address */
|
||||
/*
|
||||
* Flags and offset address
|
||||
*/
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
/*
|
||||
* File access control and file status flags (FIL.flag)
|
||||
*/
|
||||
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
@ -446,14 +476,18 @@ void ff_rel_grant(_SYNC_t);
|
||||
#define FA__ERROR 0x80
|
||||
|
||||
|
||||
/* FAT sub type (FATFS.fs_type) */
|
||||
/*
|
||||
* FAT sub type (FATFS.fs_type)
|
||||
*/
|
||||
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
/*
|
||||
* File attribute bits for directory entry
|
||||
*/
|
||||
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
@ -465,9 +499,10 @@ void ff_rel_grant(_SYNC_t);
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
/* FatFs refers the members in the FAT structures with byte offset instead
|
||||
/ of structure member because there are incompatibility of the packing option
|
||||
/ between various compilers. */
|
||||
/*
|
||||
* FatFs refers the members in the FAT structures with byte offset instead / of structure member because there are incompatibility of the
|
||||
* packing option / between various compilers.
|
||||
*/
|
||||
|
||||
#define BS_jmpBoot 0
|
||||
#define BS_OEMName 3
|
||||
@ -529,7 +564,9 @@ void ff_rel_grant(_SYNC_t);
|
||||
|
||||
|
||||
/*--------------------------------*/
|
||||
/* Multi-byte word access macros */
|
||||
/*
|
||||
* Multi-byte word access macros
|
||||
*/
|
||||
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
|
||||
@ -1,31 +1,43 @@
|
||||
/*-------------------------------------------*/
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*
|
||||
* Integer type definitions for FatFs module
|
||||
*/
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef _INTEGER
|
||||
|
||||
|
||||
/* 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 unsigned int UINT;
|
||||
|
||||
/* These types must be 8-bit integer */
|
||||
/*
|
||||
* These types must be 8-bit integer
|
||||
*/
|
||||
typedef signed char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types must be 16-bit integer */
|
||||
/*
|
||||
* These types must be 16-bit integer
|
||||
*/
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types must be 32-bit integer */
|
||||
/*
|
||||
* These types must be 32-bit integer
|
||||
*/
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
/* Boolean type */
|
||||
/*
|
||||
* Boolean type
|
||||
*/
|
||||
// enum { false = 0 , true } bool;
|
||||
|
||||
typedef int BOOL;
|
||||
|
||||
@ -13,110 +13,103 @@
|
||||
#include "debug.h"
|
||||
#include "crc.h"
|
||||
|
||||
/*
|
||||
/*
|
||||
* o debug STA global o optimize internal transfer buffer o direct write to mempage o relocate main code o exec loaded file
|
||||
*/
|
||||
|
||||
o debug STA global
|
||||
o optimize internal transfer buffer
|
||||
o direct write to mempage
|
||||
o relocate main code
|
||||
o exec loaded file
|
||||
*/
|
||||
|
||||
//#pragma section CODE=BANK2,offset $2:0000
|
||||
// #pragma section CODE=BANK2,offset $2:0000
|
||||
|
||||
#define ROM_NAME "MRDO.SMC"
|
||||
//#define ROM_NAME "TEST.TXT"
|
||||
// #define ROM_NAME "TEST.TXT"
|
||||
#define BLOCK_SIZE 512
|
||||
#define BASE_ADDR 0x008000
|
||||
|
||||
|
||||
padStatus pad1;
|
||||
|
||||
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 */
|
||||
FATFS fatfs[2]; /* File system object for each logical * drive */
|
||||
BYTE Buff[512]; /* Working buffer */
|
||||
|
||||
DWORD p1, p2, p3;
|
||||
DWORD p1,
|
||||
p2,
|
||||
p3;
|
||||
DWORD addr;
|
||||
DWORD crc_addr;
|
||||
UINT crc;
|
||||
|
||||
BYTE res,bank;
|
||||
BYTE res,
|
||||
bank;
|
||||
WORD w1;
|
||||
UINT s1, s2, cnt;
|
||||
|
||||
UINT s1,
|
||||
s2,
|
||||
cnt;
|
||||
FATFS *fs;
|
||||
DIR dir; /* Directory object */
|
||||
FIL file1,file2;
|
||||
|
||||
|
||||
|
||||
|
||||
void initInternalRegisters(void) {
|
||||
FIL file1,
|
||||
file2;
|
||||
void initInternalRegisters(void)
|
||||
{
|
||||
characterLocation[0] = 0x0000;
|
||||
characterLocation[1] = 0x0000;
|
||||
characterLocation[2] = 0x0000;
|
||||
characterLocation[3] = 0x0000;
|
||||
debug_init();
|
||||
}
|
||||
} void
|
||||
preInit(void)
|
||||
{
|
||||
|
||||
void preInit(void) {
|
||||
// For testing purpose ...
|
||||
// Insert code here to be executed before register init
|
||||
}
|
||||
|
||||
DWORD get_fattime ()
|
||||
} DWORD get_fattime()
|
||||
{
|
||||
time_t rawtime;
|
||||
struct tm * ptm;
|
||||
//time ( &rawtime );
|
||||
ptm = gmtime ( &rawtime );
|
||||
struct tm *ptm;
|
||||
|
||||
return ((DWORD)(ptm->tm_year - 80) << 25)
|
||||
| ((DWORD)(ptm->tm_mon +1) << 21)
|
||||
| ((DWORD)ptm->tm_mday << 16)
|
||||
| ((DWORD)ptm->tm_hour << 11)
|
||||
| ((DWORD)ptm->tm_min << 5)
|
||||
| ((DWORD)ptm->tm_sec >> 1);
|
||||
// time ( &rawtime );
|
||||
ptm = gmtime(&rawtime);
|
||||
return ((DWORD) (ptm->tm_year - 80) << 25)
|
||||
| ((DWORD) (ptm->tm_mon + 1) << 21)
|
||||
| ((DWORD) ptm->tm_mday << 16)
|
||||
| ((DWORD) ptm->tm_hour << 11)
|
||||
| ((DWORD) ptm->tm_min << 5) | ((DWORD) ptm->tm_sec >> 1);
|
||||
}
|
||||
|
||||
void halt(void) {
|
||||
while(1);
|
||||
|
||||
void halt(void)
|
||||
{
|
||||
while (1);
|
||||
}
|
||||
|
||||
void put_rc (FRESULT rc){
|
||||
void put_rc(FRESULT rc)
|
||||
{
|
||||
const char *p;
|
||||
static const char str[] =
|
||||
"OK\0" "NOT_READY\0" "NO_FILE\0" "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";
|
||||
"OK\0" "NOT_READY\0" "NO_FILE\0" "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++);
|
||||
while (*p++);
|
||||
}
|
||||
printfc("rc=%u FR_%s\n", (WORD)rc, p);
|
||||
printfc("rc=%u FR_%s\n", (WORD) rc, p);
|
||||
}
|
||||
|
||||
|
||||
FRESULT scan_files (char* path){
|
||||
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]) {
|
||||
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]);
|
||||
*(path + i) = '/';
|
||||
strcpy(path + i + 1, &finfo.fname[0]);
|
||||
res = scan_files(path);
|
||||
*(path+i) = '\0';
|
||||
if (res != FR_OK) break;
|
||||
*(path + i) = '\0';
|
||||
if (res != FR_OK)
|
||||
break;
|
||||
} else {
|
||||
acc_files++;
|
||||
acc_size += finfo.fsize;
|
||||
@ -126,41 +119,43 @@ FRESULT scan_files (char* path){
|
||||
return res;
|
||||
}
|
||||
|
||||
void wait(void){
|
||||
void wait(void)
|
||||
{
|
||||
printfc("SNES::wait: press A to continue\n");
|
||||
enablePad();
|
||||
//waitForVBlank();
|
||||
|
||||
// waitForVBlank();
|
||||
pad1 = readPad((byte) 0);
|
||||
while(!pad1.A) {
|
||||
while (!pad1.A) {
|
||||
waitForVBlank();
|
||||
pad1 = readPad((byte) 0);
|
||||
}
|
||||
printfc("SNES::wait: done\n");
|
||||
//disablePad();
|
||||
|
||||
// disablePad();
|
||||
}
|
||||
|
||||
void boot(void){
|
||||
#asm
|
||||
void boot(void)
|
||||
{
|
||||
|
||||
#asm
|
||||
jsl $008000
|
||||
#endasm
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
word i,j;
|
||||
#endasm
|
||||
} 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
|
||||
|
||||
*(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 OPTIXX.ORG ");
|
||||
|
||||
printfs(0,"FATFS OPTIXX.ORG ");
|
||||
wait();
|
||||
printfc("SNES::main: Try to init disk\n");
|
||||
|
||||
put_rc(f_mount(0, &fatfs[0]));
|
||||
|
||||
#if 0
|
||||
@ -168,146 +163,138 @@ void main(void) {
|
||||
res = f_getfree("", &p2, &fs);
|
||||
if (res)
|
||||
put_rc(res);
|
||||
|
||||
|
||||
printfc("SNES::main: printf fs results\n");
|
||||
printfs(1,"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,
|
||||
fs->n_rootdir, (DWORD)fs->sects_fat, (DWORD)fs->max_clust - 2,
|
||||
fs->fatbase, fs->dirbase, fs->database);
|
||||
|
||||
(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;
|
||||
printfc("SNES::main: scan files\n");
|
||||
res = scan_files("");
|
||||
if (res)
|
||||
put_rc(res);
|
||||
|
||||
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));
|
||||
|
||||
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));
|
||||
res = f_opendir(&dir, "");
|
||||
if (res)
|
||||
put_rc(res);
|
||||
|
||||
p1 = s1 = s2 = 0;
|
||||
cnt = 0;
|
||||
wait();
|
||||
clears();
|
||||
printfc("SNES::main: read dir\n");
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &finfo);
|
||||
if ((res != FR_OK) || !finfo.fname[0]) break;
|
||||
if ((res != FR_OK) || !finfo.fname[0])
|
||||
break;
|
||||
if (finfo.fattrib & AM_DIR) {
|
||||
s2++;
|
||||
} else {
|
||||
s1++; p1 += finfo.fsize;
|
||||
s1++;
|
||||
p1 += finfo.fsize;
|
||||
}
|
||||
;
|
||||
|
||||
printfs(cnt,"%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu\n%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' : '-',
|
||||
(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]));
|
||||
cnt+=2;
|
||||
(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]));
|
||||
* 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]));
|
||||
*/
|
||||
if (cnt && cnt==20){
|
||||
if (cnt && cnt == 20) {
|
||||
cnt = 0;
|
||||
wait();
|
||||
clears();
|
||||
}
|
||||
}
|
||||
|
||||
printfs(20,"%4u FILES\n%10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
||||
printfs(20, "%4u FILES\n%10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
||||
if (f_getfree("", &p1, &fs) == FR_OK)
|
||||
printfs(23,"%10luK BYTES FREE\n", p1 * fs->csize / 2);
|
||||
|
||||
printfs(23, "%10luK BYTES FREE\n", p1 * fs->csize / 2);
|
||||
wait();
|
||||
clears();
|
||||
#endif
|
||||
printfc("SNES::main: open %s \n",ROM_NAME);
|
||||
printfs(0,"OPEN %s",ROM_NAME);
|
||||
|
||||
#endif /* */
|
||||
printfc("SNES::main: open %s \n", ROM_NAME);
|
||||
printfs(0, "OPEN %s", ROM_NAME);
|
||||
put_rc(f_open(&file1, ROM_NAME, FA_READ));
|
||||
|
||||
|
||||
p1 = 32768L * 8;
|
||||
p2 = 0 ;
|
||||
p2 = 0;
|
||||
p3 = 0;
|
||||
cnt = 0;
|
||||
bank =0;
|
||||
bank = 0;
|
||||
addr = BASE_ADDR;
|
||||
crc_addr = BASE_ADDR;
|
||||
while (p1) {
|
||||
cnt = BLOCK_SIZE;
|
||||
p1 -= BLOCK_SIZE;
|
||||
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]);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
p2 += s2;
|
||||
if (cnt != s2){
|
||||
printfc("SNES::main: read cnt=%i s2=%i\n",cnt,s2);
|
||||
if (cnt != s2) {
|
||||
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
|
||||
printfs(1 + bank, "BANK %X ADDR %LX", bank, addr);
|
||||
|
||||
/*
|
||||
for (i=0; i<BLOCK_SIZE; i++){
|
||||
*(byte*)(addr + i) = Buff[i];
|
||||
}
|
||||
* for (i=0; i<BLOCK_SIZE; i++){ *(byte*)(addr + i) = Buff[i]; }
|
||||
*/
|
||||
<<<<<<< HEAD:snes/fatfstest/main.c
|
||||
printfs(2,"%i BYTES TANS %x",BLOCK_SIZE, 0x020000 + p2);
|
||||
=======
|
||||
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){
|
||||
printfc("SNES::main: mem %x %x %x %x %lx\n",
|
||||
*(byte *) (addr + 0), *(byte *) (addr + 1),
|
||||
*(byte *) (addr + 2), *(byte *) (addr + 3), addr);
|
||||
|
||||
printc_packet(addr,512,(byte*)(addr));
|
||||
// if (addr=0x10fe00){
|
||||
printc_packet(addr, 512, (byte *) (addr));
|
||||
|
||||
//}
|
||||
// }
|
||||
addr += s2;
|
||||
if (addr % 0x10000 == 0) {
|
||||
|
||||
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;
|
||||
// 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++;
|
||||
}
|
||||
>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/main.c
|
||||
}
|
||||
put_rc(f_close(&file1));
|
||||
boot();
|
||||
while(1){
|
||||
while (1) {
|
||||
wait();
|
||||
}
|
||||
while(1);
|
||||
while (1);
|
||||
}
|
||||
|
||||
void IRQHandler(void) {
|
||||
}
|
||||
void IRQHandler(void)
|
||||
{
|
||||
} void
|
||||
NMIHandler(void)
|
||||
{
|
||||
|
||||
void NMIHandler(void) {
|
||||
//processEvents();
|
||||
// processEvents();
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
typedef struct padStatus{
|
||||
typedef struct padStatus {
|
||||
byte right:1;
|
||||
byte left:1;
|
||||
byte down:1;
|
||||
@ -7,7 +7,7 @@ typedef struct padStatus{
|
||||
byte select:1; // Space
|
||||
byte Y:1; // X
|
||||
byte B:1; // C
|
||||
//--------------------------------
|
||||
// --------------------------------
|
||||
byte Dummy:4;
|
||||
byte R:1; // Z
|
||||
byte L:1; // A
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user