Merge branch 'master' of git@github.com:optixx/snesram
Conflicts: snes/fatfstest/Makefile snes/fatfstest/main.c
This commit is contained in:
commit
6bab776497
5
.gitignore
vendored
5
.gitignore
vendored
@ -21,3 +21,8 @@
|
|||||||
*.swc
|
*.swc
|
||||||
*.rom
|
*.rom
|
||||||
*.usage
|
*.usage
|
||||||
|
*.moc
|
||||||
|
*.obj
|
||||||
|
*.TMP
|
||||||
|
*.vfat
|
||||||
|
*.wla*
|
||||||
|
|||||||
@ -25,7 +25,11 @@ LD=$(WINE) $(SDK)/bin/WDCLN.exe
|
|||||||
|
|
||||||
INC=$(SDK)/include
|
INC=$(SDK)/include
|
||||||
LIBS=$(SDK)/lib/cc
|
LIBS=$(SDK)/lib/cc
|
||||||
|
<<<<<<< HEAD:snes/fatfstest/Makefile
|
||||||
OBJS=StartupSnes.obj pad.obj main.obj PPU.obj debug.obj ressource.obj
|
OBJS=StartupSnes.obj pad.obj main.obj PPU.obj debug.obj ressource.obj
|
||||||
|
=======
|
||||||
|
OBJS=StartupSnes.obj main.obj pad.obj PPU.obj debug.obj ressource.obj diskio.obj ff.obj
|
||||||
|
>>>>>>> d69d2bf39842c032ea4660a10556e78b14b6d71c:snes/fatfstest/Makefile
|
||||||
APP=fatfs.smc
|
APP=fatfs.smc
|
||||||
GFX=debugfont
|
GFX=debugfont
|
||||||
|
|
||||||
|
|||||||
18
snes/fatfstest/config.h
Normal file
18
snes/fatfstest/config.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
#define CMD_INIT 0x00
|
||||||
|
#define CMD_READ 0x01
|
||||||
|
#define CMD_WRITE 0x02
|
||||||
|
#define CMD_NONE 0xff
|
||||||
|
|
||||||
|
/* Memory Map */
|
||||||
|
#define MMIO_CMD 0x3010
|
||||||
|
#define MMIO_SECTOR01 0x3011
|
||||||
|
#define MMIO_SECTOR02 0x3012
|
||||||
|
#define MMIO_SECTOR03 0x3013
|
||||||
|
#define MMIO_SECTOR04 0x3014
|
||||||
|
#define MMIO_COUNT 0x3015
|
||||||
|
#define MMIO_RETVAL 0x3016
|
||||||
|
|
||||||
|
|
||||||
|
#define SHARED_SIZE 512
|
||||||
|
#define SHARED_ADDR 0x3f0000
|
||||||
@ -1,10 +1,13 @@
|
|||||||
|
#include <string.h>
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "pad.h"
|
#include "pad.h"
|
||||||
#include "PPU.h"
|
#include "PPU.h"
|
||||||
#include "ressource.h"
|
#include "ressource.h"
|
||||||
|
|
||||||
word debugMap[0x400];
|
word debugMap[0x400];
|
||||||
void initDebugMap(void) {
|
|
||||||
|
|
||||||
|
void debug_init(void) {
|
||||||
word i;
|
word i;
|
||||||
for(i=0; i<0x400; i++) {
|
for(i=0; i<0x400; i++) {
|
||||||
debugMap[i] = 0x00;
|
debugMap[i] = 0x00;
|
||||||
@ -27,21 +30,25 @@ void int2hex(unsigned long number, char *buf,word size)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printDebugScreen(char *buffer,word y){
|
void print_screen(char *buffer,word y){
|
||||||
char i;
|
char i;
|
||||||
|
char l;
|
||||||
|
l = strlen(buffer);
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
for(i=0; i<32; i++) {
|
for(i=0; i<32; i++) {
|
||||||
waitForVBlank();
|
if (i<l)
|
||||||
VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20)));
|
VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20)));
|
||||||
|
else
|
||||||
|
VRAMByteWrite((byte) (' '-32), (word) (0x4000+i+(y*0x20)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printf(char *buffer){
|
void print_console(char *buffer){
|
||||||
while(*buffer)
|
while(*buffer)
|
||||||
*(byte*) 0x3000=*buffer++;
|
*(byte*) 0x3000=*buffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableDebugScreen(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);
|
||||||
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
void initDebugMap(void);
|
void debug_init(void);
|
||||||
void debug(void);
|
void debug_enable(void);
|
||||||
void int2hex(unsigned long i, char *buf,word size);
|
void int2hex(unsigned long i, char *buf,word size);
|
||||||
void printDebugScreen(char* line,word y);
|
void print_screen(char* line,word y);
|
||||||
void enableDebugScreen(void);
|
void print_console(char* line);
|
||||||
void printf(char* line);
|
|
||||||
|
|||||||
165
snes/fatfstest/diskio.c
Normal file
165
snes/fatfstest/diskio.c
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
|
||||||
|
#include "integer.h"
|
||||||
|
#include "diskio.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "data.h"
|
||||||
|
|
||||||
|
static
|
||||||
|
DSTATUS Stat = STA_NOINIT; /* Disk status */
|
||||||
|
|
||||||
|
|
||||||
|
/* Interface
|
||||||
|
** Scratch Buffer
|
||||||
|
addr 3 byte
|
||||||
|
size 1 byte
|
||||||
|
|
||||||
|
** Call Interface
|
||||||
|
cmd 1 byte
|
||||||
|
sector 4 bytes
|
||||||
|
count 1 byte
|
||||||
|
return 1 byte
|
||||||
|
|
||||||
|
** Commands
|
||||||
|
* disk_init
|
||||||
|
* disk_read
|
||||||
|
* disk_write
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Initialize Disk Drive */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define IMAGE_NAME "disk00.vfat"
|
||||||
|
|
||||||
|
BYTE *image_addr;
|
||||||
|
|
||||||
|
DSTATUS disk_initialize (BYTE drv) {
|
||||||
|
|
||||||
|
byte retval;
|
||||||
|
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||||
|
|
||||||
|
|
||||||
|
Stat |= STA_NOINIT;
|
||||||
|
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||||
|
*(byte*) MMIO_CMD = CMD_INIT;
|
||||||
|
while(*(byte*) MMIO_RETVAL == STA_VOID);
|
||||||
|
retval = *(byte*) MMIO_RETVAL;
|
||||||
|
Stat &= ~retval; /* When device goes ready, clear STA_NOINIT */
|
||||||
|
return Stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Return Disk Status */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DSTATUS disk_status (BYTE drv){
|
||||||
|
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||||
|
return Stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Read Sector(s) */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DRESULT disk_read (
|
||||||
|
BYTE drv, /* Physical drive nmuber (0) */
|
||||||
|
BYTE *buff, /* Data buffer to store read data */
|
||||||
|
DWORD sector, /* Sector number (LBA) */
|
||||||
|
BYTE count /* Sector count (1..255) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD offset;
|
||||||
|
INT size;
|
||||||
|
byte retval;
|
||||||
|
word i;
|
||||||
|
for (i=0;i<(count*512);i++)
|
||||||
|
*(byte*)(SHARED_ADDR+i) = buff[i];
|
||||||
|
|
||||||
|
if (drv || !count) return RES_PARERR;
|
||||||
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
|
|
||||||
|
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||||
|
*(byte*) MMIO_CMD = CMD_READ;
|
||||||
|
|
||||||
|
*(byte*) MMIO_SECTOR01 = (sector >> 24) & 0xff;
|
||||||
|
*(byte*) MMIO_SECTOR02 = (sector >> 16) & 0xff;
|
||||||
|
*(byte*) MMIO_SECTOR03 = (sector >> 8) & 0xff;
|
||||||
|
*(byte*) MMIO_SECTOR04 = (sector >> 8) & 0xff;
|
||||||
|
|
||||||
|
*(byte*) MMIO_COUNT = count;
|
||||||
|
|
||||||
|
while(*(byte*) MMIO_RETVAL == STA_VOID);
|
||||||
|
retval = *(byte*) MMIO_RETVAL;
|
||||||
|
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Write Sector(s) */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if _READONLY == 0
|
||||||
|
DRESULT disk_write (
|
||||||
|
BYTE drv, /* Physical drive nmuber (0) */
|
||||||
|
const BYTE *buff, /* Data to be written */
|
||||||
|
DWORD sector, /* Sector number (LBA) */
|
||||||
|
BYTE count /* Sector count (1..255) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD offset;
|
||||||
|
INT size;
|
||||||
|
|
||||||
|
if (drv || !count) return RES_PARERR;
|
||||||
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
|
|
||||||
|
offset = sector * 512;
|
||||||
|
size = count * 512;
|
||||||
|
return RES_OK;
|
||||||
|
}
|
||||||
|
#endif /* _READONLY */
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Miscellaneous Functions */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if _USE_IOCTL != 0
|
||||||
|
DRESULT disk_ioctl (
|
||||||
|
BYTE drv, /* Physical drive nmuber (0) */
|
||||||
|
BYTE ctrl, /* Control code */
|
||||||
|
void *buff /* Buffer to send/receive data block */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BYTE n, w, ofs, dl, dh, *ptr = (BYTE*)buff;
|
||||||
|
|
||||||
|
|
||||||
|
if (drv) return RES_PARERR;
|
||||||
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
|
|
||||||
|
switch (ctrl) {
|
||||||
|
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||||
|
ofs = 60; w = 2; n = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
|
||||||
|
*(WORD*)buff = 512;
|
||||||
|
return RES_OK;
|
||||||
|
|
||||||
|
case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */
|
||||||
|
*(DWORD*)buff = 32;
|
||||||
|
return RES_OK;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return RES_PARERR;
|
||||||
|
}
|
||||||
|
return RES_OK;
|
||||||
|
}
|
||||||
|
#endif /* _USE_IOCTL != 0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
71
snes/fatfstest/diskio.h
Normal file
71
snes/fatfstest/diskio.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*-----------------------------------------------------------------------
|
||||||
|
/ Low level disk interface modlue include file R0.05 (C)ChaN, 2007
|
||||||
|
/-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _DISKIO
|
||||||
|
|
||||||
|
#define _READONLY 0 /* 1: Read-only mode */
|
||||||
|
#define _USE_IOCTL 1
|
||||||
|
|
||||||
|
#include "integer.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Status of Disk Functions */
|
||||||
|
typedef BYTE DSTATUS;
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------*/
|
||||||
|
/* Prototypes for disk control functions */
|
||||||
|
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
|
DRESULT disk_ioctl (BYTE, BYTE, void*);
|
||||||
|
void disk_timerproc (void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Disk Status Bits (DSTATUS) */
|
||||||
|
|
||||||
|
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||||
|
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||||
|
#define STA_PROTECT 0x04 /* Write protected */
|
||||||
|
#define STA_VOID 0xff
|
||||||
|
|
||||||
|
|
||||||
|
/* Command code for disk_ioctrl() */
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
#define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
|
||||||
|
#define CTRL_POWER 4
|
||||||
|
#define CTRL_LOCK 5
|
||||||
|
#define CTRL_EJECT 6
|
||||||
|
|
||||||
|
#define _DISKIO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
2936
snes/fatfstest/ff.c
Normal file
2936
snes/fatfstest/ff.c
Normal file
File diff suppressed because it is too large
Load Diff
547
snes/fatfstest/ff.h
Normal file
547
snes/fatfstest/ff.h
Normal file
@ -0,0 +1,547 @@
|
|||||||
|
/*---------------------------------------------------------------------------/
|
||||||
|
/ FatFs - FAT file system module include file R0.07a (C)ChaN, 2009
|
||||||
|
/----------------------------------------------------------------------------/
|
||||||
|
/ FatFs module is an open source software to implement FAT file system to
|
||||||
|
/ small embedded systems. This is a free software and is opened for education,
|
||||||
|
/ research and commercial developments under license policy of following trems.
|
||||||
|
/
|
||||||
|
/ Copyright (C) 2009, ChaN, all right reserved.
|
||||||
|
/
|
||||||
|
/ * The FatFs module is a free software and there is NO WARRANTY.
|
||||||
|
/ * No restriction on use. You can use, modify and redistribute it for
|
||||||
|
/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
|
||||||
|
/ * Redistributions of source code must retain the above copyright notice.
|
||||||
|
/----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "integer.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------/
|
||||||
|
/ FatFs Configuration Options
|
||||||
|
/
|
||||||
|
/ CAUTION! Do not forget to make clean the project after any changes to
|
||||||
|
/ the configuration options.
|
||||||
|
/
|
||||||
|
/----------------------------------------------------------------------------*/
|
||||||
|
#ifndef _FATFS
|
||||||
|
#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. */
|
||||||
|
|
||||||
|
|
||||||
|
#define _FS_READONLY 1
|
||||||
|
/* 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. */
|
||||||
|
|
||||||
|
|
||||||
|
#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. */
|
||||||
|
|
||||||
|
|
||||||
|
#define _USE_STRFUNC 0
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
|
||||||
|
#define _USE_FORWARD 0
|
||||||
|
/* 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. */
|
||||||
|
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
|
||||||
|
|
||||||
|
#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[]. */
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#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. */
|
||||||
|
|
||||||
|
|
||||||
|
#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. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* End of configuration options. Do not change followings without care. */
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Definitions corresponds to multiple sector size */
|
||||||
|
|
||||||
|
#if _MAX_SS == 512
|
||||||
|
#define SS(fs) 512
|
||||||
|
#else
|
||||||
|
#if _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096
|
||||||
|
#define SS(fs) ((fs)->s_size)
|
||||||
|
#else
|
||||||
|
#error Sector size must be 512, 1024, 2048 or 4096.
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* File system object structure */
|
||||||
|
|
||||||
|
typedef struct _FATFS {
|
||||||
|
BYTE fs_type; /* FAT sub type */
|
||||||
|
BYTE drive; /* Physical drive number */
|
||||||
|
BYTE csize; /* Number of sectors per cluster */
|
||||||
|
BYTE n_fats; /* Number of FAT copies */
|
||||||
|
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||||
|
BYTE pad1;
|
||||||
|
WORD id; /* File system mount ID */
|
||||||
|
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
||||||
|
#if _FS_REENTRANT
|
||||||
|
_SYNC_t sobj; /* Identifier of sync object */
|
||||||
|
#endif
|
||||||
|
#if _MAX_SS != 512U
|
||||||
|
WORD s_size; /* Sector size */
|
||||||
|
#endif
|
||||||
|
#if !_FS_READONLY
|
||||||
|
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||||
|
BYTE pad2;
|
||||||
|
DWORD last_clust; /* Last allocated cluster */
|
||||||
|
DWORD free_clust; /* Number of free clusters */
|
||||||
|
DWORD fsi_sector; /* fsinfo sector */
|
||||||
|
#endif
|
||||||
|
DWORD sects_fat; /* Sectors per fat */
|
||||||
|
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */
|
||||||
|
DWORD fatbase; /* FAT start sector */
|
||||||
|
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 */
|
||||||
|
} FATFS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
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]} */
|
||||||
|
#if _USE_LFN
|
||||||
|
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||||
|
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */
|
||||||
|
#endif
|
||||||
|
} DIR;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* File object structure */
|
||||||
|
|
||||||
|
typedef struct _FIL {
|
||||||
|
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 */
|
||||||
|
DWORD fptr; /* File R/W pointer */
|
||||||
|
DWORD fsize; /* File size */
|
||||||
|
DWORD org_clust; /* File start cluster */
|
||||||
|
DWORD curr_clust; /* Current cluster */
|
||||||
|
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 */
|
||||||
|
#endif
|
||||||
|
#if !_FS_TINY
|
||||||
|
BYTE buf[_MAX_SS];/* File R/W buffer */
|
||||||
|
#endif
|
||||||
|
} FIL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* File status structure */
|
||||||
|
|
||||||
|
typedef struct _FILINFO {
|
||||||
|
DWORD fsize; /* File size */
|
||||||
|
WORD fdate; /* Last modified date */
|
||||||
|
WORD ftime; /* Last modified time */
|
||||||
|
BYTE fattrib; /* Attribute */
|
||||||
|
char fname[13]; /* Short file name (8.3 format) */
|
||||||
|
#if _USE_LFN
|
||||||
|
char *lfname; /* Pointer to the LFN buffer */
|
||||||
|
int lfsize; /* Size of LFN buffer [bytes] */
|
||||||
|
#endif
|
||||||
|
} FILINFO;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* DBCS code ranges */
|
||||||
|
|
||||||
|
#if _CODE_PAGE == 932 /* CP932 (Japanese Shift-JIS) */
|
||||||
|
#define _DF1S 0x81 /* DBC 1st byte range 1 start */
|
||||||
|
#define _DF1E 0x9F /* DBC 1st byte range 1 end */
|
||||||
|
#define _DF2S 0xE0 /* DBC 1st byte range 2 start */
|
||||||
|
#define _DF2E 0xFC /* DBC 1st byte range 2 end */
|
||||||
|
#define _DS1S 0x40 /* DBC 2nd byte range 1 start */
|
||||||
|
#define _DS1E 0x7E /* DBC 2nd byte range 1 end */
|
||||||
|
#define _DS2S 0x80 /* DBC 2nd byte range 2 start */
|
||||||
|
#define _DS2E 0xFC /* DBC 2nd byte range 2 end */
|
||||||
|
|
||||||
|
#elif _CODE_PAGE == 936 /* CP936 (Simplified Chinese GBK) */
|
||||||
|
#define _DF1S 0x81
|
||||||
|
#define _DF1E 0xFE
|
||||||
|
#define _DS1S 0x40
|
||||||
|
#define _DS1E 0x7E
|
||||||
|
#define _DS2S 0x80
|
||||||
|
#define _DS2E 0xFE
|
||||||
|
|
||||||
|
#elif _CODE_PAGE == 949 /* CP949 (Korean) */
|
||||||
|
#define _DF1S 0x81
|
||||||
|
#define _DF1E 0xFE
|
||||||
|
#define _DS1S 0x41
|
||||||
|
#define _DS1E 0x5A
|
||||||
|
#define _DS2S 0x61
|
||||||
|
#define _DS2E 0x7A
|
||||||
|
#define _DS3S 0x81
|
||||||
|
#define _DS3E 0xFE
|
||||||
|
|
||||||
|
#elif _CODE_PAGE == 950 /* CP950 (Traditional Chinese Big5) */
|
||||||
|
#define _DF1S 0x81
|
||||||
|
#define _DF1E 0xFE
|
||||||
|
#define _DS1S 0x40
|
||||||
|
#define _DS1E 0x7E
|
||||||
|
#define _DS2S 0xA1
|
||||||
|
#define _DS2E 0xFE
|
||||||
|
|
||||||
|
#else /* SBCS code pages */
|
||||||
|
#define _DF1S 0
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Character code support macros */
|
||||||
|
|
||||||
|
#define IsUpper(c) (((c)>='A')&&((c)<='Z'))
|
||||||
|
#define IsLower(c) (((c)>='a')&&((c)<='z'))
|
||||||
|
#define IsDigit(c) (((c)>='0')&&((c)<='9'))
|
||||||
|
|
||||||
|
#if _DF1S /* DBCS configuration */
|
||||||
|
|
||||||
|
#if _DF2S /* Two 1st byte areas */
|
||||||
|
#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
|
||||||
|
#else /* One 1st byte area */
|
||||||
|
#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _DS3S /* Three 2nd byte areas */
|
||||||
|
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))
|
||||||
|
#else /* Two 2nd byte areas */
|
||||||
|
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* SBCS configuration */
|
||||||
|
|
||||||
|
#define IsDBCS1(c) 0
|
||||||
|
#define IsDBCS2(c) 0
|
||||||
|
|
||||||
|
#endif /* _DF1S */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Definitions corresponds to multi partition */
|
||||||
|
|
||||||
|
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||||
|
|
||||||
|
typedef struct _PARTITION {
|
||||||
|
BYTE pd; /* Physical drive# */
|
||||||
|
BYTE pt; /* Partition # (0-3) */
|
||||||
|
} PARTITION;
|
||||||
|
|
||||||
|
extern
|
||||||
|
const PARTITION Drives[]; /* Logical drive# to physical location conversion table */
|
||||||
|
#define LD2PD(drv) (Drives[drv].pd) /* Get physical drive# */
|
||||||
|
#define LD2PT(drv) (Drives[drv].pt) /* Get partition# */
|
||||||
|
|
||||||
|
#else /* Single partition configuration */
|
||||||
|
|
||||||
|
#define LD2PD(drv) (drv) /* Physical drive# is equal to the logical drive# */
|
||||||
|
#define LD2PT(drv) 0 /* Always mounts the 1st partition */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* File function return code (FRESULT) */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FR_OK = 0, /* 0 */
|
||||||
|
FR_DISK_ERR, /* 1 */
|
||||||
|
FR_INT_ERR, /* 2 */
|
||||||
|
FR_NOT_READY, /* 3 */
|
||||||
|
FR_NO_FILE, /* 4 */
|
||||||
|
FR_NO_PATH, /* 5 */
|
||||||
|
FR_INVALID_NAME, /* 6 */
|
||||||
|
FR_DENIED, /* 7 */
|
||||||
|
FR_EXIST, /* 8 */
|
||||||
|
FR_INVALID_OBJECT, /* 9 */
|
||||||
|
FR_WRITE_PROTECTED, /* 10 */
|
||||||
|
FR_INVALID_DRIVE, /* 11 */
|
||||||
|
FR_NOT_ENABLED, /* 12 */
|
||||||
|
FR_NO_FILESYSTEM, /* 13 */
|
||||||
|
FR_MKFS_ABORTED, /* 14 */
|
||||||
|
FR_TIMEOUT /* 15 */
|
||||||
|
} FRESULT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
||||||
|
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
|
||||||
|
#ifndef EOF
|
||||||
|
#define EOF -1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* User defined functions */
|
||||||
|
|
||||||
|
/* 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) */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Unicode - OEM code conversion */
|
||||||
|
#if _USE_LFN
|
||||||
|
WCHAR ff_convert (WCHAR, UINT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Sync functions */
|
||||||
|
#if _FS_REENTRANT
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* Flags and offset address */
|
||||||
|
|
||||||
|
|
||||||
|
/* File access control and file status flags (FIL.flag) */
|
||||||
|
|
||||||
|
#define FA_READ 0x01
|
||||||
|
#define FA_OPEN_EXISTING 0x00
|
||||||
|
#if _FS_READONLY == 0
|
||||||
|
#define FA_WRITE 0x02
|
||||||
|
#define FA_CREATE_NEW 0x04
|
||||||
|
#define FA_CREATE_ALWAYS 0x08
|
||||||
|
#define FA_OPEN_ALWAYS 0x10
|
||||||
|
#define FA__WRITTEN 0x20
|
||||||
|
#define FA__DIRTY 0x40
|
||||||
|
#endif
|
||||||
|
#define FA__ERROR 0x80
|
||||||
|
|
||||||
|
|
||||||
|
/* FAT sub type (FATFS.fs_type) */
|
||||||
|
|
||||||
|
#define FS_FAT12 1
|
||||||
|
#define FS_FAT16 2
|
||||||
|
#define FS_FAT32 3
|
||||||
|
|
||||||
|
|
||||||
|
/* File attribute bits for directory entry */
|
||||||
|
|
||||||
|
#define AM_RDO 0x01 /* Read only */
|
||||||
|
#define AM_HID 0x02 /* Hidden */
|
||||||
|
#define AM_SYS 0x04 /* System */
|
||||||
|
#define AM_VOL 0x08 /* Volume label */
|
||||||
|
#define AM_LFN 0x0F /* LFN entry */
|
||||||
|
#define AM_DIR 0x10 /* Directory */
|
||||||
|
#define AM_ARC 0x20 /* Archive */
|
||||||
|
#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. */
|
||||||
|
|
||||||
|
#define BS_jmpBoot 0
|
||||||
|
#define BS_OEMName 3
|
||||||
|
#define BPB_BytsPerSec 11
|
||||||
|
#define BPB_SecPerClus 13
|
||||||
|
#define BPB_RsvdSecCnt 14
|
||||||
|
#define BPB_NumFATs 16
|
||||||
|
#define BPB_RootEntCnt 17
|
||||||
|
#define BPB_TotSec16 19
|
||||||
|
#define BPB_Media 21
|
||||||
|
#define BPB_FATSz16 22
|
||||||
|
#define BPB_SecPerTrk 24
|
||||||
|
#define BPB_NumHeads 26
|
||||||
|
#define BPB_HiddSec 28
|
||||||
|
#define BPB_TotSec32 32
|
||||||
|
#define BS_55AA 510
|
||||||
|
|
||||||
|
#define BS_DrvNum 36
|
||||||
|
#define BS_BootSig 38
|
||||||
|
#define BS_VolID 39
|
||||||
|
#define BS_VolLab 43
|
||||||
|
#define BS_FilSysType 54
|
||||||
|
|
||||||
|
#define BPB_FATSz32 36
|
||||||
|
#define BPB_ExtFlags 40
|
||||||
|
#define BPB_FSVer 42
|
||||||
|
#define BPB_RootClus 44
|
||||||
|
#define BPB_FSInfo 48
|
||||||
|
#define BPB_BkBootSec 50
|
||||||
|
#define BS_DrvNum32 64
|
||||||
|
#define BS_BootSig32 66
|
||||||
|
#define BS_VolID32 67
|
||||||
|
#define BS_VolLab32 71
|
||||||
|
#define BS_FilSysType32 82
|
||||||
|
|
||||||
|
#define FSI_LeadSig 0
|
||||||
|
#define FSI_StrucSig 484
|
||||||
|
#define FSI_Free_Count 488
|
||||||
|
#define FSI_Nxt_Free 492
|
||||||
|
|
||||||
|
#define MBR_Table 446
|
||||||
|
|
||||||
|
#define DIR_Name 0
|
||||||
|
#define DIR_Attr 11
|
||||||
|
#define DIR_NTres 12
|
||||||
|
#define DIR_CrtTime 14
|
||||||
|
#define DIR_CrtDate 16
|
||||||
|
#define DIR_FstClusHI 20
|
||||||
|
#define DIR_WrtTime 22
|
||||||
|
#define DIR_WrtDate 24
|
||||||
|
#define DIR_FstClusLO 26
|
||||||
|
#define DIR_FileSize 28
|
||||||
|
#define LDIR_Ord 0
|
||||||
|
#define LDIR_Attr 11
|
||||||
|
#define LDIR_Type 12
|
||||||
|
#define LDIR_Chksum 13
|
||||||
|
#define LDIR_FstClusLO 26
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------*/
|
||||||
|
/* Multi-byte word access macros */
|
||||||
|
|
||||||
|
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||||
|
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||||
|
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||||
|
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||||
|
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||||
|
#else /* Use byte-by-byte access to the FAT structure */
|
||||||
|
#define LD_WORD(ptr) (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
||||||
|
#define LD_DWORD(ptr) (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))
|
||||||
|
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||||
|
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _FATFS */
|
||||||
32
snes/fatfstest/integer.h
Normal file
32
snes/fatfstest/integer.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*-------------------------------------------*/
|
||||||
|
/* Integer type definitions for FatFs module */
|
||||||
|
/*-------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef _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 */
|
||||||
|
typedef signed char CHAR;
|
||||||
|
typedef unsigned char UCHAR;
|
||||||
|
typedef unsigned char BYTE;
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
typedef long LONG;
|
||||||
|
typedef unsigned long ULONG;
|
||||||
|
typedef unsigned long DWORD;
|
||||||
|
|
||||||
|
/* Boolean type */
|
||||||
|
typedef enum { FALSE = 0, TRUE } BOOL;
|
||||||
|
|
||||||
|
|
||||||
|
#define _INTEGER
|
||||||
|
#endif
|
||||||
@ -16,7 +16,7 @@ void initInternalRegisters(void) {
|
|||||||
characterLocation[1] = 0x0000;
|
characterLocation[1] = 0x0000;
|
||||||
characterLocation[2] = 0x0000;
|
characterLocation[2] = 0x0000;
|
||||||
characterLocation[3] = 0x0000;
|
characterLocation[3] = 0x0000;
|
||||||
initDebugMap();
|
debug_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void preInit(void) {
|
void preInit(void) {
|
||||||
@ -30,7 +30,6 @@ void main(void) {
|
|||||||
word crc02;
|
word crc02;
|
||||||
padStatus pad1;
|
padStatus pad1;
|
||||||
char line_header[32] = "OK2";
|
char line_header[32] = "OK2";
|
||||||
char packet[4] = "TEST";
|
|
||||||
initInternalRegisters();
|
initInternalRegisters();
|
||||||
|
|
||||||
*(byte*) 0x2105 = 0x01; // MODE 1 value
|
*(byte*) 0x2105 = 0x01; // MODE 1 value
|
||||||
@ -38,11 +37,10 @@ void main(void) {
|
|||||||
*(byte*) 0x212d = 0x00; // All subPlane disable
|
*(byte*) 0x212d = 0x00; // All subPlane disable
|
||||||
*(byte*) 0x2100 = 0x0f; // enable background
|
*(byte*) 0x2100 = 0x0f; // enable background
|
||||||
|
|
||||||
enableDebugScreen();
|
debug_enable();
|
||||||
//printDebugScreen("FATFS TEST",0);
|
print_screen("FATFS TEST",0);
|
||||||
printDebugScreen(line_header,1);
|
print_console("Debugging console test\n");
|
||||||
|
print_console("test me\n");
|
||||||
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
while(!pad1.start) {
|
while(!pad1.start) {
|
||||||
|
|||||||
206
snesram.tmproj
206
snesram.tmproj
@ -2,8 +2,6 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>currentDocument</key>
|
|
||||||
<string>snes/irqtest/debug.asm</string>
|
|
||||||
<key>documents</key>
|
<key>documents</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
@ -77,106 +75,6 @@
|
|||||||
<key>firstVisibleLine</key>
|
<key>firstVisibleLine</key>
|
||||||
<integer>211</integer>
|
<integer>211</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>snes/irqtest/LoadGraphics.asm</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>45</integer>
|
|
||||||
</dict>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
<key>snes/irqtest/debug.asm</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>22</integer>
|
|
||||||
</dict>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
<key>snes/irqtest/header.inc</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>36</integer>
|
|
||||||
</dict>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>9</integer>
|
|
||||||
</dict>
|
|
||||||
<key>snes/irqtest/init.inc</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>248</integer>
|
|
||||||
</dict>
|
|
||||||
<key>columnSelection</key>
|
|
||||||
<false/>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>211</integer>
|
|
||||||
<key>selectFrom</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>246</integer>
|
|
||||||
</dict>
|
|
||||||
<key>selectTo</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>248</integer>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>snes/irqtest/intro.asm</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
<key>snes/irqtest/irqtest.asm</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>67</integer>
|
|
||||||
</dict>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>49</integer>
|
|
||||||
</dict>
|
|
||||||
<key>tools/bsnes/cart/cart.cpp</key>
|
<key>tools/bsnes/cart/cart.cpp</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>caret</key>
|
<key>caret</key>
|
||||||
@ -205,66 +103,6 @@
|
|||||||
<key>firstVisibleLine</key>
|
<key>firstVisibleLine</key>
|
||||||
<integer>24</integer>
|
<integer>24</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>tools/bsnes/chip/cmmio/cmmio.cpp</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>1</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>17</integer>
|
|
||||||
</dict>
|
|
||||||
<key>columnSelection</key>
|
|
||||||
<false/>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>selectFrom</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>17</integer>
|
|
||||||
</dict>
|
|
||||||
<key>selectTo</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>1</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>17</integer>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>tools/bsnes/cpu/scpu/memory/memory.cpp</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>1</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>56</integer>
|
|
||||||
</dict>
|
|
||||||
<key>columnSelection</key>
|
|
||||||
<false/>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>56</integer>
|
|
||||||
<key>selectFrom</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>56</integer>
|
|
||||||
</dict>
|
|
||||||
<key>selectTo</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>2</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>56</integer>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>tools/bsnes/cpu/scpu/memory/memory.hpp</key>
|
<key>tools/bsnes/cpu/scpu/memory/memory.hpp</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>caret</key>
|
<key>caret</key>
|
||||||
@ -279,52 +117,10 @@
|
|||||||
<key>firstVisibleLine</key>
|
<key>firstVisibleLine</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>tools/bsnes/cpu/scpu/mmio/mmio.cpp</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>485</integer>
|
|
||||||
</dict>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>459</integer>
|
|
||||||
</dict>
|
|
||||||
<key>tools/bsnes/memory/memory.cpp</key>
|
|
||||||
<dict>
|
|
||||||
<key>caret</key>
|
|
||||||
<dict>
|
|
||||||
<key>column</key>
|
|
||||||
<integer>6</integer>
|
|
||||||
<key>line</key>
|
|
||||||
<integer>22</integer>
|
|
||||||
</dict>
|
|
||||||
<key>firstVisibleColumn</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
<key>firstVisibleLine</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
</dict>
|
||||||
<key>openDocuments</key>
|
|
||||||
<array>
|
|
||||||
<string>snes/irqtest/debug.asm</string>
|
|
||||||
<string>tools/bsnes/cpu/scpu/mmio/mmio.cpp</string>
|
|
||||||
<string>tools/bsnes/chip/cmmio/cmmio.cpp</string>
|
|
||||||
<string>tools/bsnes/cpu/scpu/memory/memory.cpp</string>
|
|
||||||
<string>tools/bsnes/memory/memory.cpp</string>
|
|
||||||
<string>tools/bsnes/cpu/scpu/memory/memory.hpp</string>
|
|
||||||
<string>snes/irqtest/irqtest.asm</string>
|
|
||||||
<string>snes/irqtest/intro.asm</string>
|
|
||||||
<string>snes/irqtest/LoadGraphics.asm</string>
|
|
||||||
<string>snes/irqtest/init.inc</string>
|
|
||||||
<string>snes/irqtest/header.inc</string>
|
|
||||||
</array>
|
|
||||||
<key>showFileHierarchyDrawer</key>
|
<key>showFileHierarchyDrawer</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>windowFrame</key>
|
<key>windowFrame</key>
|
||||||
<string>{{0, 59}, {895, 819}}</string>
|
<string>{{0, 51}, {1110, 827}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@ -48,7 +48,7 @@ void disk_timerproc (void);
|
|||||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||||
#define STA_PROTECT 0x04 /* Write protected */
|
#define STA_PROTECT 0x04 /* Write protected */
|
||||||
|
#define STA_VOID 0xff
|
||||||
|
|
||||||
|
|
||||||
/* Command code for disk_ioctrl() */
|
/* Command code for disk_ioctrl() */
|
||||||
|
|||||||
@ -4,14 +4,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "diskio.h"
|
#include "diskio.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#define CMD_INIT 0x00
|
|
||||||
#define CMD_READ 0x01
|
|
||||||
#define CMD_WRITE 0x02
|
|
||||||
#define CMD_NONE 0xff
|
|
||||||
|
|
||||||
#define SHARED_SIZE 512
|
|
||||||
#define SHARED_ADDR 0x3f0000
|
|
||||||
|
|
||||||
void FATFS::init() {
|
void FATFS::init() {
|
||||||
command = CMD_NONE;
|
command = CMD_NONE;
|
||||||
@ -23,16 +18,16 @@ void FATFS::init() {
|
|||||||
|
|
||||||
void FATFS::enable() {
|
void FATFS::enable() {
|
||||||
// command
|
// command
|
||||||
memory::mmio.map(0x3010, *this);
|
memory::mmio.map(MMIO_CMD, *this);
|
||||||
// sector
|
// sector
|
||||||
memory::mmio.map(0x3011, *this);
|
memory::mmio.map(MMIO_SECTOR01, *this);
|
||||||
memory::mmio.map(0x3012, *this);
|
memory::mmio.map(MMIO_SECTOR02, *this);
|
||||||
memory::mmio.map(0x3013, *this);
|
memory::mmio.map(MMIO_SECTOR03, *this);
|
||||||
memory::mmio.map(0x3014, *this);
|
memory::mmio.map(MMIO_SECTOR04, *this);
|
||||||
// offset
|
// count
|
||||||
memory::mmio.map(0x3015, *this);
|
memory::mmio.map(MMIO_COUNT, *this);
|
||||||
// return value
|
// return value
|
||||||
memory::mmio.map(0x3016, *this);
|
memory::mmio.map(MMIO_RETVAL, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FATFS::power() {
|
void FATFS::power() {
|
||||||
@ -57,7 +52,7 @@ void FATFS::pushMem() {
|
|||||||
|
|
||||||
uint8 FATFS::mmio_read(unsigned addr) {
|
uint8 FATFS::mmio_read(unsigned addr) {
|
||||||
addr &= 0xffff;
|
addr &= 0xffff;
|
||||||
if (addr == 0x3016){
|
if (addr == MMIO_RETVAL){
|
||||||
printf("FATFS::mmio_read retal=%i\n",retval);
|
printf("FATFS::mmio_read retal=%i\n",retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -89,13 +84,13 @@ void FATFS::mmio_write(unsigned addr, uint8 data) {
|
|||||||
}
|
}
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
if (addr >= 0x3011 && addr <= 0x3014){
|
if (addr >= MMIO_SECTOR01 && addr <= MMIO_SECTOR04){
|
||||||
sector = data << ( (3 - ( addr - 0x3011)) << 3);
|
sector = data << ( (3 - ( addr - MMIO_SECTOR01)) << 3);
|
||||||
printf("FATFS::mmio_write set sector: byte=%i val=%i sector=%i \n",(3 - ( addr - 0x3011)),data,sector);
|
printf("FATFS::mmio_write set sector: byte=%i val=%i sector=%i \n",(3 - ( addr - MMIO_SECTOR01)),data,sector);
|
||||||
}
|
}
|
||||||
if (addr == 0x3015){
|
if (addr == MMIO_COUNT){
|
||||||
count = data;
|
count = data;
|
||||||
printf("FATFS::mmio_write set offset: countr=%i \n",count);
|
printf("FATFS::mmio_write set count: countr=%i \n",count);
|
||||||
if (command == CMD_READ) {
|
if (command == CMD_READ) {
|
||||||
retval = disk_read (0, (BYTE*)scratch_buffer, sector, count);
|
retval = disk_read (0, (BYTE*)scratch_buffer, sector, count);
|
||||||
if (!retval)
|
if (!retval)
|
||||||
@ -107,8 +102,9 @@ void FATFS::mmio_write(unsigned addr, uint8 data) {
|
|||||||
printf("FATFS::mmio_write set offset: no command to trigger \n");
|
printf("FATFS::mmio_write set offset: no command to trigger \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addr == 0x3016){
|
if (addr == MMIO_RETVAL){
|
||||||
printf("FATFS::mmio_write reg 0x3016 retav is RW\n");
|
printf("FATFS::mmio_write reg 0x3016 reset\n");
|
||||||
|
retval = STA_VOID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user