cleanup code
This commit is contained in:
parent
cb0ea4f8c8
commit
309e1062b9
@ -29,22 +29,15 @@ LIBS=-L$(SDK)/lib/cl
|
|||||||
#-L$(SDK)/lib/c134
|
#-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
|
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
|
APP=fatfs.smc
|
||||||
GFX=debugfont
|
GFX=debugfont
|
||||||
|
|
||||||
all: $(APP) repair
|
all: $(APP)
|
||||||
|
|
||||||
run:
|
run:
|
||||||
$(EMU) $(APP)
|
$(EMU) $(APP)
|
||||||
|
|
||||||
debugger:
|
|
||||||
$(EMU_DEBUG) $(APP)
|
|
||||||
|
|
||||||
upload:
|
upload:
|
||||||
ucon64 -chk $(APP)
|
ucon64 -chk $(APP)
|
||||||
cp -rv $(APP) /Volumes/SNES
|
cp -rv $(APP) /Volumes/SNES
|
||||||
@ -55,6 +48,10 @@ disasm: $(APP)
|
|||||||
rm -rf fatfs.asm
|
rm -rf fatfs.asm
|
||||||
$(DISASM) fatfs.smc > 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
|
StartupSnes.obj: StartupSnes.asm
|
||||||
$(AS) -V $?
|
$(AS) -V $?
|
||||||
|
|
||||||
@ -65,45 +62,17 @@ hook.obj: hook.asm
|
|||||||
$(AS) -V $?
|
$(AS) -V $?
|
||||||
|
|
||||||
%.obj: %.c
|
%.obj: %.c
|
||||||
<<<<<<< HEAD:snes/fatfstest/Makefile
|
|
||||||
$(CC) -wl -wp -sop -ML -I $(INC) $?
|
$(CC) -wl -wp -sop -ML -I $(INC) $?
|
||||||
|
|
||||||
#$(APP): $(OBJS)
|
$(APP): $(OBJS)
|
||||||
# $(LD) -HB -M21 -V -T -Pff \
|
echo "test"
|
||||||
# -C008000,0000 -U0000,0000 \
|
|
||||||
# -Avectors=FFE4,7FE4 \
|
|
||||||
# -Aregistration_data=FFB0,7FB0 \
|
|
||||||
# -Aressource=18000,8000 \
|
|
||||||
# -N $(OBJS) $(LIBS) -O $@
|
|
||||||
|
|
||||||
$(APP): $(OBJS) hook.obj
|
|
||||||
$(LD) -B -HB -M21 -V -T -Pff \
|
$(LD) -B -HB -M21 -V -T -Pff \
|
||||||
-C3e8000,1f0000 -U000000,000000 \
|
-C3e8000,1f0000 -U000000,000000 \
|
||||||
-Avectors=FFE4,7FE4 \
|
-Avectors=FFE4,7FE4 \
|
||||||
-Aregistration_data=FFB0,7FB0 \
|
-Aregistration_data=FFB0,7FB0 \
|
||||||
-Aressource=3f8000,1f8000 \
|
-Aressource=18000,8000 \
|
||||||
-Ahook=008000,0000 \
|
-Ahook=008000,0000 \
|
||||||
-N $(OBJS) hook.obj $(LIBS) -O $@
|
-N $(OBJS) $(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 \
|
|
||||||
-N $(OBJS) $(LIBS) -O $@
|
|
||||||
ucon64 -snes -chk $(APP) 2>&1 >/dev/null
|
|
||||||
>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/Makefile
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -vf $(APP) *.obj *.TMP
|
rm -vf $(APP) *.obj *.TMP
|
||||||
|
|||||||
@ -1,80 +1,80 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
byte tileMapLocation[4];
|
byte tileMapLocation[4];
|
||||||
word characterLocation[4];
|
word characterLocation[4];
|
||||||
|
|
||||||
void waitForVBlank(void) {
|
void waitForVBlank(void) {
|
||||||
byte Status;
|
byte Status;
|
||||||
do {
|
do {
|
||||||
Status = *(byte*)0x4210;
|
Status = *(byte*)0x4210;
|
||||||
} while (!(Status & 0x80));
|
} while (!(Status & 0x80));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber) {
|
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber) {
|
||||||
tileMapLocation[bgNumber] = ((vramDst >> 8) & 0xfc) | ( screenProp & 0x03 );
|
tileMapLocation[bgNumber] = ((vramDst >> 8) & 0xfc) | ( screenProp & 0x03 );
|
||||||
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreTileMapLocation(byte bgNumber) {
|
void restoreTileMapLocation(byte bgNumber) {
|
||||||
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCharacterLocation(word vramDst, byte bgNumber) {
|
void setCharacterLocation(word vramDst, byte bgNumber) {
|
||||||
characterLocation[bgNumber] = vramDst;
|
characterLocation[bgNumber] = vramDst;
|
||||||
if(bgNumber < 2) {
|
if(bgNumber < 2) {
|
||||||
*(byte*) 0x210b = (characterLocation[1] >> 8 & 0xf0 ) + (characterLocation[0] >> 12);
|
*(byte*) 0x210b = (characterLocation[1] >> 8 & 0xf0 ) + (characterLocation[0] >> 12);
|
||||||
} else {
|
} else {
|
||||||
*(byte*) 0x210c = (characterLocation[3] >> 8 & 0xf0 ) + (characterLocation[2] >> 12);
|
*(byte*) 0x210c = (characterLocation[3] >> 8 & 0xf0 ) + (characterLocation[2] >> 12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreCharacterLocation(byte bgNumber) {
|
void restoreCharacterLocation(byte bgNumber) {
|
||||||
setCharacterLocation(characterLocation[bgNumber], bgNumber);
|
setCharacterLocation(characterLocation[bgNumber], bgNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VRAMByteWrite(byte value, word vramDst) {
|
void VRAMByteWrite(byte value, word vramDst) {
|
||||||
*(byte*)0x2115 = 0x80;
|
*(byte*)0x2115 = 0x80;
|
||||||
*(word*)0x2116 = vramDst;
|
*(word*)0x2116 = vramDst;
|
||||||
|
|
||||||
*(byte*)0x2118 = value;
|
*(byte*)0x2118 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VRAMLoad(word src, word vramDst, word size) {
|
void VRAMLoad(word src, word vramDst, word size) {
|
||||||
// set address in VRam for read or write ($2116) + block size transfer ($2115)
|
// set address in VRam for read or write ($2116) + block size transfer ($2115)
|
||||||
*(byte*)0x2115 = 0x80;
|
*(byte*)0x2115 = 0x80;
|
||||||
*(word*)0x2116 = vramDst;
|
*(word*)0x2116 = vramDst;
|
||||||
|
|
||||||
*(word*)0x4300 = 0x1801; // set DMA control register (1 word inc)
|
*(word*)0x4300 = 0x1801; // set DMA control register (1 word inc)
|
||||||
// and destination ($21xx xx -> 0x18)
|
// and destination ($21xx xx -> 0x18)
|
||||||
*(word*)0x4302 = src; // DMA channel x source address offset
|
*(word*)0x4302 = src; // DMA channel x source address offset
|
||||||
// (low $4302 and high $4303 optimisation)
|
// (low $4302 and high $4303 optimisation)
|
||||||
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
||||||
*(word*)0x4305 = size; // DMA channel x transfer size
|
*(word*)0x4305 = size; // DMA channel x transfer size
|
||||||
// (low $4305 and high $4306 optimisation)
|
// (low $4305 and high $4306 optimisation)
|
||||||
|
|
||||||
// Turn on DMA transfer for this channel
|
// Turn on DMA transfer for this channel
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
*(byte*)0x2100 = 0x80;
|
*(byte*)0x2100 = 0x80;
|
||||||
*(byte*)0x420b = 0x01;
|
*(byte*)0x420b = 0x01;
|
||||||
*(byte*)0x2100 = 0x00;
|
*(byte*)0x2100 = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGRAMLoad(word src, byte cgramDst, word size) {
|
void CGRAMLoad(word src, byte cgramDst, word size) {
|
||||||
|
|
||||||
// set address in VRam for read or write + block size
|
// set address in VRam for read or write + block size
|
||||||
*(byte*)0x2121 = cgramDst;
|
*(byte*)0x2121 = cgramDst;
|
||||||
|
|
||||||
*(word*)0x4300 = 0x2200; // set DMA control register (1 byte inc)
|
*(word*)0x4300 = 0x2200; // set DMA control register (1 byte inc)
|
||||||
// and destination ($21xx xx -> 022)
|
// and destination ($21xx xx -> 022)
|
||||||
*(word*)0x4302 = src; // DMA channel x source address offset
|
*(word*)0x4302 = src; // DMA channel x source address offset
|
||||||
// (low $4302 and high $4303 optimisation)
|
// (low $4302 and high $4303 optimisation)
|
||||||
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
||||||
*(word*)0x4305 = size; // DMA channel x transfer size
|
*(word*)0x4305 = size; // DMA channel x transfer size
|
||||||
// (low $4305 and high $4306 optimisation)
|
// (low $4305 and high $4306 optimisation)
|
||||||
|
|
||||||
// Turn on DMA transfer for this channel
|
// Turn on DMA transfer for this channel
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
*(byte*)0x2100 = 0x80;
|
*(byte*)0x2100 = 0x80;
|
||||||
*(byte*)0x420b = 0x01;
|
*(byte*)0x420b = 0x01;
|
||||||
*(byte*)0x2100 = 0x00;
|
*(byte*)0x2100 = 0x00;
|
||||||
}
|
}
|
||||||
@ -1,11 +1,11 @@
|
|||||||
extern byte tileMapLocation[4];
|
extern byte tileMapLocation[4];
|
||||||
extern word characterLocation[4];
|
extern word characterLocation[4];
|
||||||
|
|
||||||
void waitForVBlank(void);
|
void waitForVBlank(void);
|
||||||
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber);
|
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber);
|
||||||
void restoreTileMapLocation(byte bgNumber);
|
void restoreTileMapLocation(byte bgNumber);
|
||||||
void setCharacterLocation(word vramDst, byte bgNumber);
|
void setCharacterLocation(word vramDst, byte bgNumber);
|
||||||
void restoreCharacterLocation(byte bgNumber);
|
void restoreCharacterLocation(byte bgNumber);
|
||||||
void VRAMByteWrite(byte value, word vramDst);
|
void VRAMByteWrite(byte value, word vramDst);
|
||||||
void VRAMLoad(word src, word vramDst, word size);
|
void VRAMLoad(word src, word vramDst, word size);
|
||||||
void CGRAMLoad(word src, byte cgramDst, word size);
|
void CGRAMLoad(word src, byte cgramDst, word size);
|
||||||
|
|||||||
@ -4,7 +4,9 @@
|
|||||||
#define CMD_WRITE 0x02
|
#define CMD_WRITE 0x02
|
||||||
#define CMD_NONE 0xff
|
#define CMD_NONE 0xff
|
||||||
|
|
||||||
/* Memory Map */
|
/*
|
||||||
|
* Memory Map
|
||||||
|
*/
|
||||||
#define MMIO_CMD 0x3010
|
#define MMIO_CMD 0x3010
|
||||||
#define MMIO_SECTOR01 0x3011
|
#define MMIO_SECTOR01 0x3011
|
||||||
#define MMIO_SECTOR02 0x3012
|
#define MMIO_SECTOR02 0x3012
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
word crc_update (byte *data, word size);
|
word crc_update(byte * data, word size);
|
||||||
word crc_update_mem (unsigned long, word size);
|
word crc_update_mem(unsigned long, word size);
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
#ifndef _DATA
|
#ifndef _DATA
|
||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
typedef unsigned short word;
|
typedef unsigned short word;
|
||||||
|
|
||||||
#define _DATA
|
#define _DATA
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,185 +1,185 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.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];
|
||||||
static char debug_buffer[512];
|
static char debug_buffer[512];
|
||||||
static char screen_buffer[512];
|
static char screen_buffer[512];
|
||||||
|
|
||||||
|
|
||||||
void debug_init(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;
|
||||||
}
|
}
|
||||||
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);
|
||||||
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
||||||
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
|
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
|
||||||
setCharacterLocation(0x5000, (byte) 0);
|
setCharacterLocation(0x5000, (byte) 0);
|
||||||
*(byte*) 0x2100 = 0x0f; // enable background
|
*(byte*) 0x2100 = 0x0f; // enable background
|
||||||
|
|
||||||
// hex(24 << 10 | 24 << 5 | 24 )
|
// hex(24 << 10 | 24 << 5 | 24 )
|
||||||
// '0x6318'
|
// '0x6318'
|
||||||
|
|
||||||
*(byte*) 0x2121 = 0x00;
|
*(byte*) 0x2121 = 0x00;
|
||||||
*(byte*) 0x2122 = 0x18;
|
*(byte*) 0x2122 = 0x18;
|
||||||
*(byte*) 0x2122 = 0x63;
|
*(byte*) 0x2122 = 0x63;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clears(void) {
|
void clears(void) {
|
||||||
word i,y;
|
word i,y;
|
||||||
for(y=0; y<20; y++){
|
for(y=0; y<20; y++){
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
for(i=0; i<32; i++){
|
for(i=0; i<32; i++){
|
||||||
*(byte*)0x2115 = 0x80;
|
*(byte*)0x2115 = 0x80;
|
||||||
*(word*)0x2116 = 0x4000+i+(y*0x20);
|
*(word*)0x2116 = 0x4000+i+(y*0x20);
|
||||||
*(byte*)0x2118 = 0;
|
*(byte*)0x2118 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _print_char(word y,word x, char c){
|
void _print_char(word y,word x, char c){
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
VRAMByteWrite((byte) (c-32), (word) (0x4000+x+(y*0x20)));
|
VRAMByteWrite((byte) (c-32), (word) (0x4000+x+(y*0x20)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _print_screen(word y, char *buffer){
|
void _print_screen(word y, char *buffer){
|
||||||
char l;
|
char l;
|
||||||
char x = 0;
|
char x = 0;
|
||||||
l = strlen(buffer);
|
l = strlen(buffer);
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
while(*buffer){
|
while(*buffer){
|
||||||
if (*buffer == '\n' ) {
|
if (*buffer == '\n' ) {
|
||||||
while(x++<32){
|
while(x++<32){
|
||||||
*(byte*)0x2115 = 0x80;
|
*(byte*)0x2115 = 0x80;
|
||||||
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
||||||
*(byte*)0x2118 = 0;
|
*(byte*)0x2118 = 0;
|
||||||
}
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
y++;
|
y++;
|
||||||
buffer++;
|
buffer++;
|
||||||
waitForVBlank();
|
waitForVBlank();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*(byte*)0x2115 = 0x80;
|
*(byte*)0x2115 = 0x80;
|
||||||
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
||||||
*(byte*)0x2118 = *buffer-32;
|
*(byte*)0x2118 = *buffer-32;
|
||||||
x++;
|
x++;
|
||||||
buffer++;
|
buffer++;
|
||||||
//waitForVBlank();
|
//waitForVBlank();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void _print_console(const char *buffer){
|
void _print_console(const char *buffer){
|
||||||
while(*buffer)
|
while(*buffer)
|
||||||
*(byte*) 0x3000=*buffer++;
|
*(byte*) 0x3000=*buffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void printfc(char *fmt,...){
|
void printfc(char *fmt,...){
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,fmt);
|
va_start(ap,fmt);
|
||||||
vsprintf(debug_buffer,fmt,ap);
|
vsprintf(debug_buffer,fmt,ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
_print_console(debug_buffer);
|
_print_console(debug_buffer);
|
||||||
//memset(debug_buffer,0,255);
|
//memset(debug_buffer,0,255);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printfs(word y,char *fmt,...){
|
void printfs(word y,char *fmt,...){
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,fmt);
|
va_start(ap,fmt);
|
||||||
vsprintf(screen_buffer,fmt,ap);
|
vsprintf(screen_buffer,fmt,ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
_print_screen(y,screen_buffer);
|
_print_screen(y,screen_buffer);
|
||||||
memset(screen_buffer,0,255);
|
memset(screen_buffer,0,255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printc_packet(unsigned long addr,unsigned int len,byte *packet){
|
void printc_packet(unsigned long addr,unsigned int len,byte *packet){
|
||||||
unsigned int i,j;
|
unsigned int i,j;
|
||||||
unsigned int sum = 0;
|
unsigned int sum = 0;
|
||||||
unsigned int clear=0;
|
unsigned int clear=0;
|
||||||
|
|
||||||
for (i=0;i<len;i+=16) {
|
for (i=0;i<len;i+=16) {
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (j=0;j<16;j++) {
|
for (j=0;j<16;j++) {
|
||||||
sum +=packet[i+j];
|
sum +=packet[i+j];
|
||||||
}
|
}
|
||||||
if (!sum){
|
if (!sum){
|
||||||
clear=1;
|
clear=1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (clear){
|
if (clear){
|
||||||
printfc("*\n");
|
printfc("*\n");
|
||||||
clear = 0;
|
clear = 0;
|
||||||
}
|
}
|
||||||
printfc("%lx:", addr + i);
|
printfc("%lx:", addr + i);
|
||||||
for (j=0;j<16;j++) {
|
for (j=0;j<16;j++) {
|
||||||
printfc(" %x", packet[i+j]);
|
printfc(" %x", packet[i+j]);
|
||||||
}
|
}
|
||||||
printfc(" |");
|
printfc(" |");
|
||||||
for (j=0;j<16;j++) {
|
for (j=0;j<16;j++) {
|
||||||
if (packet[i+j]>=33 && packet[i+j]<=126 )
|
if (packet[i+j]>=33 && packet[i+j]<=126 )
|
||||||
printfc("%c", packet[i+j]);
|
printfc("%c", packet[i+j]);
|
||||||
else
|
else
|
||||||
printfc(".");
|
printfc(".");
|
||||||
}
|
}
|
||||||
printfc("|\n");
|
printfc("|\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
void debug_init(void);
|
void debug_init(void);
|
||||||
void debug_enable(void);
|
void debug_enable(void);
|
||||||
void printfs(word y,char* fmt,...);
|
void printfs(word y, char *fmt, ...);
|
||||||
void printfc(char* fmt,...);
|
void printfc(char *fmt, ...);
|
||||||
void clears(void);
|
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);
|
||||||
|
|
||||||
|
|||||||
@ -1,199 +1,199 @@
|
|||||||
|
|
||||||
#include "integer.h"
|
#include "integer.h"
|
||||||
#include "diskio.h"
|
#include "diskio.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Interface
|
/* Interface
|
||||||
** Scratch Buffer
|
** Scratch Buffer
|
||||||
addr 3 byte
|
addr 3 byte
|
||||||
size 1 byte
|
size 1 byte
|
||||||
|
|
||||||
** Call Interface
|
** Call Interface
|
||||||
cmd 1 byte
|
cmd 1 byte
|
||||||
sector 4 bytes
|
sector 4 bytes
|
||||||
count 1 byte
|
count 1 byte
|
||||||
return 1 byte
|
return 1 byte
|
||||||
|
|
||||||
** Commands
|
** Commands
|
||||||
* disk_init
|
* disk_init
|
||||||
* disk_read
|
* disk_read
|
||||||
* disk_write
|
* disk_write
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Initialize Disk Drive */
|
/* Initialize Disk Drive */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
// TODO: Figure out gobal vars ?!?
|
// TODO: Figure out gobal vars ?!?
|
||||||
|
|
||||||
DSTATUS Stat = 0 ; //STA_NOINIT; /* Disk status */
|
DSTATUS Stat = 0 ; //STA_NOINIT; /* Disk status */
|
||||||
|
|
||||||
|
|
||||||
DSTATUS disk_initialize (BYTE drv) {
|
DSTATUS disk_initialize (BYTE drv) {
|
||||||
|
|
||||||
byte retval;
|
byte retval;
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize called drv=%i stat=%i\n",drv,Stat);
|
printfc("SNES::disk_initialize called drv=%i stat=%i\n",drv,Stat);
|
||||||
#endif
|
#endif
|
||||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||||
Stat |= STA_NOINIT;
|
Stat |= STA_NOINIT;
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize stat=%i\n",Stat);
|
printfc("SNES::disk_initialize stat=%i\n",Stat);
|
||||||
#endif
|
#endif
|
||||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||||
*(byte*) MMIO_CMD = CMD_INIT;
|
*(byte*) MMIO_CMD = CMD_INIT;
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize poll retval\n");
|
printfc("SNES::disk_initialize poll retval\n");
|
||||||
#endif
|
#endif
|
||||||
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
||||||
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_initialize done Stat=%i\n",Stat);
|
printfc("SNES::disk_initialize done Stat=%i\n",Stat);
|
||||||
#endif
|
#endif
|
||||||
return Stat;
|
return Stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Return Disk Status */
|
/* Return Disk Status */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DSTATUS disk_status (BYTE drv){
|
DSTATUS disk_status (BYTE drv){
|
||||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||||
return Stat;
|
return Stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Read Sector(s) */
|
/* Read Sector(s) */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRESULT disk_read (
|
DRESULT disk_read (
|
||||||
BYTE drv, /* Physical drive nmuber (0) */
|
BYTE drv, /* Physical drive nmuber (0) */
|
||||||
BYTE *buff, /* Data buffer to store read data */
|
BYTE *buff, /* Data buffer to store read data */
|
||||||
DWORD sector, /* Sector number (LBA) */
|
DWORD sector, /* Sector number (LBA) */
|
||||||
BYTE count /* Sector count (1..255) */
|
BYTE count /* Sector count (1..255) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD offset;
|
DWORD offset;
|
||||||
INT size;
|
INT size;
|
||||||
byte retval;
|
byte retval;
|
||||||
word i;
|
word i;
|
||||||
|
|
||||||
//#ifdef MMIO_DEBUG
|
//#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read called sector=%li count=%i\n",sector,count);
|
printfc("SNES::disk_read called sector=%li count=%i\n",sector,count);
|
||||||
//#endif
|
//#endif
|
||||||
if (drv || !count) return RES_PARERR;
|
if (drv || !count) return RES_PARERR;
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read drv ok\n");
|
printfc("SNES::disk_read drv ok\n");
|
||||||
#endif
|
#endif
|
||||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read sta ok\n");
|
printfc("SNES::disk_read sta ok\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||||
*(byte*) MMIO_CMD = CMD_READ;
|
*(byte*) MMIO_CMD = CMD_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) & 0xff;
|
*(byte*) MMIO_SECTOR04 = (sector) & 0xff;
|
||||||
|
|
||||||
*(byte*) MMIO_COUNT = count;
|
*(byte*) MMIO_COUNT = count;
|
||||||
|
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read poll retval\n");
|
printfc("SNES::disk_read poll retval\n");
|
||||||
#endif
|
#endif
|
||||||
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("SNES::disk_read copy buffer to %06lx\n",SHARED_ADDR);
|
printfc("SNES::disk_read copy buffer to %06lx\n",SHARED_ADDR);
|
||||||
#endif
|
#endif
|
||||||
for (i=0;i<(count*512);i++){
|
for (i=0;i<(count*512);i++){
|
||||||
buff[i] = *(byte*)(SHARED_ADDR+i);
|
buff[i] = *(byte*)(SHARED_ADDR+i);
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
if ( i < 8)
|
if ( i < 8)
|
||||||
printfc("0x%02x ",buff[i]);
|
printfc("0x%02x ",buff[i]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef MMIO_DEBUG
|
#ifdef MMIO_DEBUG
|
||||||
printfc("\n");
|
printfc("\n");
|
||||||
#endif
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Write Sector(s) */
|
/* Write Sector(s) */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if _READONLY == 0
|
#if _READONLY == 0
|
||||||
DRESULT disk_write (
|
DRESULT disk_write (
|
||||||
BYTE drv, /* Physical drive nmuber (0) */
|
BYTE drv, /* Physical drive nmuber (0) */
|
||||||
const BYTE *buff, /* Data to be written */
|
const BYTE *buff, /* Data to be written */
|
||||||
DWORD sector, /* Sector number (LBA) */
|
DWORD sector, /* Sector number (LBA) */
|
||||||
BYTE count /* Sector count (1..255) */
|
BYTE count /* Sector count (1..255) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD offset;
|
DWORD offset;
|
||||||
INT size;
|
INT size;
|
||||||
|
|
||||||
if (drv || !count) return RES_PARERR;
|
if (drv || !count) return RES_PARERR;
|
||||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
|
|
||||||
offset = sector * 512;
|
offset = sector * 512;
|
||||||
size = count * 512;
|
size = count * 512;
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
#endif /* _READONLY */
|
#endif /* _READONLY */
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Miscellaneous Functions */
|
/* Miscellaneous Functions */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if _USE_IOCTL != 0
|
#if _USE_IOCTL != 0
|
||||||
DRESULT disk_ioctl (
|
DRESULT disk_ioctl (
|
||||||
BYTE drv, /* Physical drive nmuber (0) */
|
BYTE drv, /* Physical drive nmuber (0) */
|
||||||
BYTE ctrl, /* Control code */
|
BYTE ctrl, /* Control code */
|
||||||
void *buff /* Buffer to send/receive data block */
|
void *buff /* Buffer to send/receive data block */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BYTE n, w, ofs, dl, dh, *ptr = (BYTE*)buff;
|
BYTE n, w, ofs, dl, dh, *ptr = (BYTE*)buff;
|
||||||
|
|
||||||
|
|
||||||
if (drv) return RES_PARERR;
|
if (drv) return RES_PARERR;
|
||||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||||
|
|
||||||
switch (ctrl) {
|
switch (ctrl) {
|
||||||
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||||
ofs = 60; w = 2; n = 0;
|
ofs = 60; w = 2; n = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
|
case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
|
||||||
*(WORD*)buff = 512;
|
*(WORD*)buff = 512;
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
|
||||||
case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */
|
case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */
|
||||||
*(DWORD*)buff = 32;
|
*(DWORD*)buff = 32;
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return RES_PARERR;
|
return RES_PARERR;
|
||||||
}
|
}
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
#endif /* _USE_IOCTL != 0 */
|
#endif /* _USE_IOCTL != 0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,71 +1,83 @@
|
|||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
/ Low level disk interface modlue include file R0.05 (C)ChaN, 2007
|
/ Low level disk interface modlue include file R0.05 (C)ChaN, 2007
|
||||||
/-----------------------------------------------------------------------*/
|
/-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _DISKIO
|
#ifndef _DISKIO
|
||||||
|
|
||||||
#define _READONLY 0 /* 1: Read-only mode */
|
#define _READONLY 0 /* 1: Read-only mode */
|
||||||
#define _USE_IOCTL 1
|
#define _USE_IOCTL 1
|
||||||
|
|
||||||
#include "integer.h"
|
#include "integer.h"
|
||||||
|
|
||||||
|
|
||||||
/* Status of Disk Functions */
|
/*
|
||||||
typedef BYTE DSTATUS;
|
* Status of Disk Functions
|
||||||
|
*/
|
||||||
/* Results of Disk Functions */
|
typedef BYTE DSTATUS;
|
||||||
typedef enum {
|
|
||||||
RES_OK = 0, /* 0: Successful */
|
/*
|
||||||
RES_ERROR, /* 1: R/W Error */
|
* Results of Disk Functions
|
||||||
RES_WRPRT, /* 2: Write Protected */
|
*/
|
||||||
RES_NOTRDY, /* 3: Not Ready */
|
typedef enum {
|
||||||
RES_PARERR /* 4: Invalid Parameter */
|
RES_OK = 0, /* 0: Successful */
|
||||||
} DRESULT;
|
RES_ERROR, /* 1: R/W Error */
|
||||||
|
RES_WRPRT, /* 2: Write Protected */
|
||||||
|
RES_NOTRDY, /* 3: Not Ready */
|
||||||
/*---------------------------------------*/
|
RES_PARERR /* 4: Invalid Parameter */
|
||||||
/* Prototypes for disk control functions */
|
} DRESULT;
|
||||||
|
|
||||||
DSTATUS disk_initialize (BYTE);
|
|
||||||
DSTATUS disk_status (BYTE);
|
/*---------------------------------------*/
|
||||||
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
|
/*
|
||||||
#if _READONLY == 0
|
* Prototypes for disk control functions
|
||||||
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
|
*/
|
||||||
#endif
|
|
||||||
DRESULT disk_ioctl (BYTE, BYTE, void*);
|
DSTATUS disk_initialize(BYTE);
|
||||||
void disk_timerproc (void);
|
DSTATUS disk_status(BYTE);
|
||||||
|
DRESULT disk_read(BYTE, BYTE *, DWORD, BYTE);
|
||||||
|
#if _READONLY == 0
|
||||||
|
DRESULT disk_write(BYTE, const BYTE *, DWORD, BYTE);
|
||||||
|
#endif
|
||||||
/* Disk Status Bits (DSTATUS) */
|
DRESULT disk_ioctl(BYTE, BYTE, void *);
|
||||||
|
void disk_timerproc(void);
|
||||||
#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
|
|
||||||
|
/*
|
||||||
|
* Disk Status Bits (DSTATUS)
|
||||||
/* Command code for disk_ioctrl() */
|
*/
|
||||||
|
|
||||||
/* Generic command */
|
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||||
#define CTRL_SYNC 0 /* Mandatory for write functions */
|
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||||
#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
|
#define STA_PROTECT 0x04 /* Write protected */
|
||||||
#define GET_SECTOR_SIZE 2
|
#define STA_VOID 0xff
|
||||||
#define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
|
|
||||||
#define CTRL_POWER 4
|
|
||||||
#define CTRL_LOCK 5
|
/*
|
||||||
#define CTRL_EJECT 6
|
* Command code for disk_ioctrl()
|
||||||
|
*/
|
||||||
#define _DISKIO
|
|
||||||
#endif
|
/*
|
||||||
|
* Generic command
|
||||||
|
*/
|
||||||
#ifdef __cplusplus
|
#define CTRL_SYNC 0 /* Mandatory for write functions */
|
||||||
}
|
#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
|
||||||
#endif
|
#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
|
||||||
|
|||||||
@ -1,101 +1,101 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "data.h";
|
#include "data.h";
|
||||||
#include "event.h";
|
#include "event.h";
|
||||||
|
|
||||||
event *events;
|
event *events;
|
||||||
|
|
||||||
void initEvents(void) {
|
void initEvents(void) {
|
||||||
events = NULL;
|
events = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
event *createEvent(char (*callback)(word counter)) {
|
event *createEvent(char (*callback)(word counter)) {
|
||||||
event *myEvent;
|
event *myEvent;
|
||||||
|
|
||||||
myEvent = (event*) malloc(sizeof(event));
|
myEvent = (event*) malloc(sizeof(event));
|
||||||
|
|
||||||
myEvent->VBlankCount = 0;
|
myEvent->VBlankCount = 0;
|
||||||
myEvent->callback = callback;
|
myEvent->callback = callback;
|
||||||
myEvent->nextEvent = NULL;
|
myEvent->nextEvent = NULL;
|
||||||
myEvent->previousEvent = NULL;
|
myEvent->previousEvent = NULL;
|
||||||
|
|
||||||
|
|
||||||
return myEvent;
|
return myEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
event* addEvent(char (*callback)(word counter), int noDuplicateCallback) {
|
event* addEvent(char (*callback)(word counter), int noDuplicateCallback) {
|
||||||
|
|
||||||
event *lastEvent;
|
event *lastEvent;
|
||||||
event *myEvent;
|
event *myEvent;
|
||||||
|
|
||||||
if(events == NULL) {
|
if(events == NULL) {
|
||||||
events = createEvent(callback);
|
events = createEvent(callback);
|
||||||
return events;
|
return events;
|
||||||
} else {
|
} else {
|
||||||
lastEvent = events;
|
lastEvent = events;
|
||||||
// TODO optimise this with noduplicate
|
// TODO optimise this with noduplicate
|
||||||
while(lastEvent->nextEvent != NULL) {
|
while(lastEvent->nextEvent != NULL) {
|
||||||
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
lastEvent = lastEvent->nextEvent;
|
lastEvent = lastEvent->nextEvent;
|
||||||
}
|
}
|
||||||
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
myEvent = createEvent(callback);
|
myEvent = createEvent(callback);
|
||||||
myEvent->previousEvent = lastEvent;
|
myEvent->previousEvent = lastEvent;
|
||||||
lastEvent->nextEvent = myEvent;
|
lastEvent->nextEvent = myEvent;
|
||||||
return myEvent;
|
return myEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeEvent(event *eventElement) {
|
void removeEvent(event *eventElement) {
|
||||||
|
|
||||||
byte alone = 0;
|
byte alone = 0;
|
||||||
event *next, *previous;
|
event *next, *previous;
|
||||||
|
|
||||||
next = eventElement->nextEvent;
|
next = eventElement->nextEvent;
|
||||||
previous = eventElement->previousEvent;
|
previous = eventElement->previousEvent;
|
||||||
|
|
||||||
if(eventElement->nextEvent != NULL && eventElement->previousEvent != NULL) {
|
if(eventElement->nextEvent != NULL && eventElement->previousEvent != NULL) {
|
||||||
alone++;
|
alone++;
|
||||||
next->previousEvent = previous;
|
next->previousEvent = previous;
|
||||||
previous->nextEvent = next;
|
previous->nextEvent = next;
|
||||||
|
|
||||||
} else if(eventElement->nextEvent != NULL) {
|
} else if(eventElement->nextEvent != NULL) {
|
||||||
alone++;
|
alone++;
|
||||||
next->previousEvent = NULL;
|
next->previousEvent = NULL;
|
||||||
events = next;
|
events = next;
|
||||||
|
|
||||||
} else if(eventElement->previousEvent != NULL) {
|
} else if(eventElement->previousEvent != NULL) {
|
||||||
alone++;
|
alone++;
|
||||||
previous->nextEvent = NULL;
|
previous->nextEvent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(eventElement);
|
free(eventElement);
|
||||||
|
|
||||||
if(alone == 0) {
|
if(alone == 0) {
|
||||||
events = NULL;
|
events = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void processEvents(void) {
|
void processEvents(void) {
|
||||||
|
|
||||||
event *currentEvent;
|
event *currentEvent;
|
||||||
char returnValue;
|
char returnValue;
|
||||||
|
|
||||||
currentEvent = events;
|
currentEvent = events;
|
||||||
while(currentEvent != NULL) {
|
while(currentEvent != NULL) {
|
||||||
returnValue = currentEvent->callback(currentEvent->VBlankCount);
|
returnValue = currentEvent->callback(currentEvent->VBlankCount);
|
||||||
if(returnValue == EVENT_CONTINUE) {
|
if(returnValue == EVENT_CONTINUE) {
|
||||||
currentEvent->VBlankCount++;
|
currentEvent->VBlankCount++;
|
||||||
} else {
|
} else {
|
||||||
removeEvent(currentEvent);
|
removeEvent(currentEvent);
|
||||||
}
|
}
|
||||||
currentEvent = currentEvent->nextEvent;
|
currentEvent = currentEvent->nextEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
typedef struct event{
|
typedef struct event {
|
||||||
word VBlankCount;
|
word VBlankCount;
|
||||||
char (*callback)(word counter);
|
char (*callback) (word counter);
|
||||||
struct event *previousEvent;
|
struct event *previousEvent;
|
||||||
struct event *nextEvent;
|
struct event *nextEvent;
|
||||||
} event;
|
} event;
|
||||||
|
|
||||||
#define EVENT_STOP 0
|
#define EVENT_STOP 0
|
||||||
#define EVENT_CONTINUE 1
|
#define EVENT_CONTINUE 1
|
||||||
|
|
||||||
extern event *events;
|
extern event *events;
|
||||||
|
|
||||||
void initEvents(void);
|
void initEvents(void);
|
||||||
extern event* addEvent(char (*callback)(word counter), int noDuplicateCallback);
|
extern event *addEvent(char (*callback) (word counter),
|
||||||
extern void removeEvent(event *eventElement);
|
int noDuplicateCallback);
|
||||||
extern void processEvents(void);
|
extern void removeEvent(event * eventElement);
|
||||||
|
extern void processEvents(void);
|
||||||
|
|||||||
5872
snes/fatfstest/ff.c
5872
snes/fatfstest/ff.c
File diff suppressed because it is too large
Load Diff
1131
snes/fatfstest/ff.h
1131
snes/fatfstest/ff.h
File diff suppressed because it is too large
Load Diff
@ -1,36 +1,48 @@
|
|||||||
/*-------------------------------------------*/
|
/*-------------------------------------------*/
|
||||||
/* Integer type definitions for FatFs module */
|
/*
|
||||||
/*-------------------------------------------*/
|
* Integer type definitions for FatFs module
|
||||||
|
*/
|
||||||
#ifndef _INTEGER
|
/*-------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef _INTEGER
|
||||||
/* These types must be 16-bit, 32-bit or larger integer */
|
|
||||||
typedef int INT;
|
|
||||||
typedef unsigned int UINT;
|
/*
|
||||||
|
* These types must be 16-bit, 32-bit or larger integer
|
||||||
/* These types must be 8-bit integer */
|
*/
|
||||||
typedef signed char CHAR;
|
typedef int INT;
|
||||||
typedef unsigned char UCHAR;
|
typedef unsigned int UINT;
|
||||||
typedef unsigned char BYTE;
|
|
||||||
|
/*
|
||||||
/* These types must be 16-bit integer */
|
* These types must be 8-bit integer
|
||||||
typedef short SHORT;
|
*/
|
||||||
typedef unsigned short USHORT;
|
typedef signed char CHAR;
|
||||||
typedef unsigned short WORD;
|
typedef unsigned char UCHAR;
|
||||||
typedef unsigned short WCHAR;
|
typedef unsigned char BYTE;
|
||||||
|
|
||||||
/* These types must be 32-bit integer */
|
/*
|
||||||
typedef long LONG;
|
* These types must be 16-bit integer
|
||||||
typedef unsigned long ULONG;
|
*/
|
||||||
typedef unsigned long DWORD;
|
typedef short SHORT;
|
||||||
|
typedef unsigned short USHORT;
|
||||||
/* Boolean type */
|
typedef unsigned short WORD;
|
||||||
// enum { false = 0 , true } bool;
|
typedef unsigned short WCHAR;
|
||||||
|
|
||||||
typedef int BOOL;
|
/*
|
||||||
#define FALSE 0
|
* These types must be 32-bit integer
|
||||||
#define TRUE 1
|
*/
|
||||||
|
typedef long LONG;
|
||||||
#define _INTEGER
|
typedef unsigned long ULONG;
|
||||||
#endif
|
typedef unsigned long DWORD;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Boolean type
|
||||||
|
*/
|
||||||
|
// enum { false = 0 , true } bool;
|
||||||
|
|
||||||
|
typedef int BOOL;
|
||||||
|
#define FALSE 0
|
||||||
|
#define TRUE 1
|
||||||
|
|
||||||
|
#define _INTEGER
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,313 +1,300 @@
|
|||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "data.h";
|
#include "data.h";
|
||||||
#include "pad.h";
|
#include "pad.h";
|
||||||
#include "event.h";
|
#include "event.h";
|
||||||
#include "myEvents.h";
|
#include "myEvents.h";
|
||||||
#include "ressource.h";
|
#include "ressource.h";
|
||||||
#include "PPU.h"
|
#include "PPU.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "crc.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
|
// #pragma section CODE=BANK2,offset $2:0000
|
||||||
o relocate main code
|
|
||||||
o exec loaded file
|
#define ROM_NAME "MRDO.SMC"
|
||||||
*/
|
// #define ROM_NAME "TEST.TXT"
|
||||||
|
#define BLOCK_SIZE 512
|
||||||
//#pragma section CODE=BANK2,offset $2:0000
|
#define BASE_ADDR 0x008000
|
||||||
|
padStatus pad1;
|
||||||
#define ROM_NAME "MRDO.SMC"
|
DWORD acc_size; /* Work register for fs command */
|
||||||
//#define ROM_NAME "TEST.TXT"
|
WORD acc_files,
|
||||||
#define BLOCK_SIZE 512
|
acc_dirs;
|
||||||
#define BASE_ADDR 0x008000
|
FILINFO finfo;
|
||||||
|
FATFS fatfs[2]; /* File system object for each logical * drive */
|
||||||
|
BYTE Buff[512]; /* Working buffer */
|
||||||
padStatus pad1;
|
DWORD p1,
|
||||||
|
p2,
|
||||||
DWORD acc_size; /* Work register for fs command */
|
p3;
|
||||||
WORD acc_files, acc_dirs;
|
DWORD addr;
|
||||||
|
DWORD crc_addr;
|
||||||
FILINFO finfo;
|
UINT crc;
|
||||||
FATFS fatfs[2]; /* File system object for each logical drive */
|
BYTE res,
|
||||||
BYTE Buff[512]; /* Working buffer */
|
bank;
|
||||||
|
WORD w1;
|
||||||
DWORD p1, p2, p3;
|
UINT s1,
|
||||||
DWORD addr;
|
s2,
|
||||||
DWORD crc_addr;
|
cnt;
|
||||||
UINT crc;
|
FATFS *fs;
|
||||||
|
DIR dir; /* Directory object */
|
||||||
BYTE res,bank;
|
FIL file1,
|
||||||
WORD w1;
|
file2;
|
||||||
UINT s1, s2, cnt;
|
void initInternalRegisters(void)
|
||||||
|
{
|
||||||
FATFS *fs;
|
characterLocation[0] = 0x0000;
|
||||||
DIR dir; /* Directory object */
|
characterLocation[1] = 0x0000;
|
||||||
FIL file1,file2;
|
characterLocation[2] = 0x0000;
|
||||||
|
characterLocation[3] = 0x0000;
|
||||||
|
debug_init();
|
||||||
|
} void
|
||||||
|
preInit(void)
|
||||||
void initInternalRegisters(void) {
|
{
|
||||||
characterLocation[0] = 0x0000;
|
|
||||||
characterLocation[1] = 0x0000;
|
// For testing purpose ...
|
||||||
characterLocation[2] = 0x0000;
|
// Insert code here to be executed before register init
|
||||||
characterLocation[3] = 0x0000;
|
} DWORD get_fattime()
|
||||||
debug_init();
|
{
|
||||||
}
|
time_t rawtime;
|
||||||
|
struct tm *ptm;
|
||||||
void preInit(void) {
|
|
||||||
// For testing purpose ...
|
// time ( &rawtime );
|
||||||
// Insert code here to be executed before register init
|
ptm = gmtime(&rawtime);
|
||||||
}
|
return ((DWORD) (ptm->tm_year - 80) << 25)
|
||||||
|
| ((DWORD) (ptm->tm_mon + 1) << 21)
|
||||||
DWORD get_fattime ()
|
| ((DWORD) ptm->tm_mday << 16)
|
||||||
{
|
| ((DWORD) ptm->tm_hour << 11)
|
||||||
time_t rawtime;
|
| ((DWORD) ptm->tm_min << 5) | ((DWORD) ptm->tm_sec >> 1);
|
||||||
struct tm * ptm;
|
}
|
||||||
//time ( &rawtime );
|
|
||||||
ptm = gmtime ( &rawtime );
|
void halt(void)
|
||||||
|
{
|
||||||
return ((DWORD)(ptm->tm_year - 80) << 25)
|
while (1);
|
||||||
| ((DWORD)(ptm->tm_mon +1) << 21)
|
}
|
||||||
| ((DWORD)ptm->tm_mday << 16)
|
|
||||||
| ((DWORD)ptm->tm_hour << 11)
|
void put_rc(FRESULT rc)
|
||||||
| ((DWORD)ptm->tm_min << 5)
|
{
|
||||||
| ((DWORD)ptm->tm_sec >> 1);
|
const char *p;
|
||||||
}
|
static const char str[] =
|
||||||
|
"OK\0" "NOT_READY\0" "NO_FILE\0" "NO_PATH\0" "INVALID_NAME\0"
|
||||||
void halt(void) {
|
"INVALID_DRIVE\0" "DENIED\0" "EXIST\0" "RW_ERROR\0"
|
||||||
while(1);
|
"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++) {
|
||||||
void put_rc (FRESULT rc){
|
while (*p++);
|
||||||
const char *p;
|
}
|
||||||
static const char str[] =
|
printfc("rc=%u FR_%s\n", (WORD) rc, p);
|
||||||
"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 scan_files(char *path)
|
||||||
FRESULT i;
|
{
|
||||||
|
DIR dirs;
|
||||||
for (p = str, i = 0; i != rc && *p; i++) {
|
FRESULT res;
|
||||||
while(*p++);
|
int i;
|
||||||
}
|
if ((res = f_opendir(&dirs, path)) == FR_OK) {
|
||||||
printfc("rc=%u FR_%s\n", (WORD)rc, p);
|
i = strlen(path);
|
||||||
}
|
while (((res = f_readdir(&dirs, &finfo)) == FR_OK)
|
||||||
|
&& finfo.fname[0]) {
|
||||||
|
if (finfo.fattrib & AM_DIR) {
|
||||||
FRESULT scan_files (char* path){
|
acc_dirs++;
|
||||||
DIR dirs;
|
*(path + i) = '/';
|
||||||
FRESULT res;
|
strcpy(path + i + 1, &finfo.fname[0]);
|
||||||
int i;
|
res = scan_files(path);
|
||||||
|
*(path + i) = '\0';
|
||||||
if ((res = f_opendir(&dirs, path)) == FR_OK) {
|
if (res != FR_OK)
|
||||||
i = strlen(path);
|
break;
|
||||||
while (((res = f_readdir(&dirs, &finfo)) == FR_OK) && finfo.fname[0]) {
|
} else {
|
||||||
if (finfo.fattrib & AM_DIR) {
|
acc_files++;
|
||||||
acc_dirs++;
|
acc_size += finfo.fsize;
|
||||||
*(path+i) = '/'; strcpy(path+i+1, &finfo.fname[0]);
|
}
|
||||||
res = scan_files(path);
|
}
|
||||||
*(path+i) = '\0';
|
}
|
||||||
if (res != FR_OK) break;
|
return res;
|
||||||
} else {
|
}
|
||||||
acc_files++;
|
|
||||||
acc_size += finfo.fsize;
|
void wait(void)
|
||||||
}
|
{
|
||||||
}
|
printfc("SNES::wait: press A to continue\n");
|
||||||
}
|
enablePad();
|
||||||
return res;
|
|
||||||
}
|
// waitForVBlank();
|
||||||
|
pad1 = readPad((byte) 0);
|
||||||
void wait(void){
|
while (!pad1.A) {
|
||||||
printfc("SNES::wait: press A to continue\n");
|
waitForVBlank();
|
||||||
enablePad();
|
pad1 = readPad((byte) 0);
|
||||||
//waitForVBlank();
|
}
|
||||||
pad1 = readPad((byte) 0);
|
printfc("SNES::wait: done\n");
|
||||||
while(!pad1.A) {
|
|
||||||
waitForVBlank();
|
// disablePad();
|
||||||
pad1 = readPad((byte) 0);
|
}
|
||||||
}
|
|
||||||
printfc("SNES::wait: done\n");
|
void boot(void)
|
||||||
//disablePad();
|
{
|
||||||
}
|
|
||||||
|
#asm
|
||||||
void boot(void){
|
jsl $008000
|
||||||
#asm
|
#endasm
|
||||||
jsl $008000
|
} void
|
||||||
#endasm
|
main(void)
|
||||||
}
|
{
|
||||||
|
word i,
|
||||||
void main(void) {
|
j;
|
||||||
word i,j;
|
BYTE res;
|
||||||
BYTE res;
|
initInternalRegisters();
|
||||||
initInternalRegisters();
|
*(byte *) 0x2105 = 0x01; // MODE 1 value
|
||||||
|
*(byte *) 0x212c = 0x01; // Plane 0 (bit one) enable register
|
||||||
*(byte*) 0x2105 = 0x01; // MODE 1 value
|
*(byte *) 0x212d = 0x00; // All subPlane disable
|
||||||
*(byte*) 0x212c = 0x01; // Plane 0 (bit one) enable register
|
*(byte *) 0x2100 = 0x0f; // enable background
|
||||||
*(byte*) 0x212d = 0x00; // All subPlane disable
|
debug_enable();
|
||||||
*(byte*) 0x2100 = 0x0f; // enable background
|
printfs(0, "FATFS OPTIXX.ORG ");
|
||||||
|
|
||||||
debug_enable();
|
printfc("SNES::main: Try to init disk\n");
|
||||||
|
put_rc(f_mount(0, &fatfs[0]));
|
||||||
printfs(0,"FATFS OPTIXX.ORG ");
|
|
||||||
wait();
|
#if 0
|
||||||
printfc("SNES::main: Try to init disk\n");
|
printfc("SNES::main: Try to get free\n");
|
||||||
|
res = f_getfree("", &p2, &fs);
|
||||||
put_rc(f_mount(0, &fatfs[0]));
|
if (res)
|
||||||
|
put_rc(res);
|
||||||
#if 0
|
printfc("SNES::main: printf fs results\n");
|
||||||
printfc("SNES::main: Try to get free\n");
|
printfs(1,
|
||||||
res = f_getfree("", &p2, &fs);
|
"FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
|
||||||
if (res)
|
"ROOT DIR ENTRIES = %u\nSECTORS/FAT = %lu\nNUMBER OF CLUSTERS = %lu\n"
|
||||||
put_rc(res);
|
"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,
|
||||||
printfc("SNES::main: printf fs results\n");
|
(DWORD) fs->max_clust - 2, fs->fatbase, fs->dirbase, fs->database);
|
||||||
printfs(1,"FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
|
acc_size = acc_files = acc_dirs = 0;
|
||||||
"ROOT DIR ENTRIES = %u\nSECTORS/FAT = %lu\nNUMBER OF CLUSTERS = %lu\n"
|
printfc("SNES::main: scan files\n");
|
||||||
"FAT START = %lu\nDIR START LBA,CLUSTER = %lu\nDATA START LBA = %lu\n",
|
res = scan_files("");
|
||||||
(WORD)fs->fs_type, (DWORD)fs->csize * 512, (WORD)fs->n_fats,
|
if (res)
|
||||||
fs->n_rootdir, (DWORD)fs->sects_fat, (DWORD)fs->max_clust - 2,
|
put_rc(res);
|
||||||
fs->fatbase, fs->dirbase, fs->database);
|
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_files = acc_dirs = 0;
|
acc_size, acc_dirs, (fs->max_clust - 2) * (fs->csize / 2),
|
||||||
printfc("SNES::main: scan files\n");
|
p2 * (fs->csize / 2));
|
||||||
res = scan_files("");
|
res = f_opendir(&dir, "");
|
||||||
if (res)
|
if (res)
|
||||||
put_rc(res);
|
put_rc(res);
|
||||||
|
p1 = s1 = s2 = 0;
|
||||||
printfs(12,"%u FILES, %lu BYTES\n%u FOLDERS\n"
|
cnt = 0;
|
||||||
"%lu KB TOTAK DISK SPACE\n%lu KB AVAILABLE\n",
|
wait();
|
||||||
acc_files, acc_size, acc_dirs,
|
clears();
|
||||||
(fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2));
|
printfc("SNES::main: read dir\n");
|
||||||
|
for (;;) {
|
||||||
res = f_opendir(&dir, "");
|
res = f_readdir(&dir, &finfo);
|
||||||
if (res)
|
if ((res != FR_OK) || !finfo.fname[0])
|
||||||
put_rc(res);
|
break;
|
||||||
|
if (finfo.fattrib & AM_DIR) {
|
||||||
p1 = s1 = s2 = 0;
|
s2++;
|
||||||
cnt = 0;
|
} else {
|
||||||
wait();
|
s1++;
|
||||||
clears();
|
p1 += finfo.fsize;
|
||||||
printfc("SNES::main: read dir\n");
|
}
|
||||||
for(;;) {
|
;
|
||||||
res = f_readdir(&dir, &finfo);
|
printfs(cnt, "%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu\n%s\n",
|
||||||
if ((res != FR_OK) || !finfo.fname[0]) break;
|
(finfo.fattrib & AM_DIR) ? 'D' : '-',
|
||||||
if (finfo.fattrib & AM_DIR) {
|
(finfo.fattrib & AM_RDO) ? 'R' : '-',
|
||||||
s2++;
|
(finfo.fattrib & AM_HID) ? 'H' : '-',
|
||||||
} else {
|
(finfo.fattrib & AM_SYS) ? 'S' : '-',
|
||||||
s1++; p1 += finfo.fsize;
|
(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]));
|
||||||
printfs(cnt,"%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu\n%s\n",
|
cnt += 2;
|
||||||
(finfo.fattrib & AM_DIR) ? 'D' : '-',
|
|
||||||
(finfo.fattrib & AM_RDO) ? 'R' : '-',
|
/*
|
||||||
(finfo.fattrib & AM_HID) ? 'H' : '-',
|
* printfs(cnt,"%u/%02u/%02u %02u:%02u %9lu\n%s\n", (finfo.fdate >> 9) + 1980, (finfo.fdate >> 5) & 15, finfo.fdate & 31,
|
||||||
(finfo.fattrib & AM_SYS) ? 'S' : '-',
|
* (finfo.ftime >> 11), (finfo.ftime >> 5) & 63, finfo.fsize, &(finfo.fname[0]));
|
||||||
(finfo.fattrib & AM_ARC) ? 'A' : '-',
|
*/
|
||||||
(finfo.fdate >> 9) + 1980, (finfo.fdate >> 5) & 15, finfo.fdate & 31,
|
if (cnt && cnt == 20) {
|
||||||
(finfo.ftime >> 11), (finfo.ftime >> 5) & 63,
|
cnt = 0;
|
||||||
finfo.fsize, &(finfo.fname[0]));
|
wait();
|
||||||
cnt+=2;
|
clears();
|
||||||
/*
|
}
|
||||||
printfs(cnt,"%u/%02u/%02u %02u:%02u %9lu\n%s\n",
|
}
|
||||||
(finfo.fdate >> 9) + 1980, (finfo.fdate >> 5) & 15, finfo.fdate & 31,
|
printfs(20, "%4u FILES\n%10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
||||||
(finfo.ftime >> 11), (finfo.ftime >> 5) & 63,
|
if (f_getfree("", &p1, &fs) == FR_OK)
|
||||||
finfo.fsize, &(finfo.fname[0]));
|
printfs(23, "%10luK BYTES FREE\n", p1 * fs->csize / 2);
|
||||||
*/
|
wait();
|
||||||
if (cnt && cnt==20){
|
clears();
|
||||||
cnt = 0;
|
|
||||||
wait();
|
#endif /* */
|
||||||
clears();
|
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;
|
||||||
printfs(20,"%4u FILES\n%10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
p2 = 0;
|
||||||
if (f_getfree("", &p1, &fs) == FR_OK)
|
p3 = 0;
|
||||||
printfs(23,"%10luK BYTES FREE\n", p1 * fs->csize / 2);
|
cnt = 0;
|
||||||
|
bank = 0;
|
||||||
wait();
|
addr = BASE_ADDR;
|
||||||
clears();
|
crc_addr = BASE_ADDR;
|
||||||
#endif
|
while (p1) {
|
||||||
printfc("SNES::main: open %s \n",ROM_NAME);
|
cnt = BLOCK_SIZE;
|
||||||
printfs(0,"OPEN %s",ROM_NAME);
|
p1 -= BLOCK_SIZE;
|
||||||
put_rc(f_open(&file1, ROM_NAME, FA_READ));
|
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);
|
||||||
p1 = 32768L * 8;
|
|
||||||
p2 = 0 ;
|
// printfc("SNES::main: file %x %x %x
|
||||||
p3 = 0;
|
// %x\n",Buff[0],Buff[1],Buff[2],Buff[3]);
|
||||||
cnt = 0;
|
if (res != FR_OK) {
|
||||||
bank =0;
|
printfc("SNES::main: read failed\n");
|
||||||
addr = BASE_ADDR;
|
put_rc(res);
|
||||||
crc_addr = BASE_ADDR;
|
break;
|
||||||
while (p1) {
|
}
|
||||||
cnt = BLOCK_SIZE;
|
p2 += s2;
|
||||||
p1 -= BLOCK_SIZE;
|
if (cnt != s2) {
|
||||||
res = f_read(&file1, (byte*)(addr) , cnt, &s2);
|
printfc("SNES::main: read cnt=%i s2=%i\n", cnt, s2);
|
||||||
printfc("SNES::main: read cnt=%i p1=%li p2=%li s2=%i\n",cnt,p1,p2,s2);
|
break;
|
||||||
//printfc("SNES::main: file %x %x %x %x\n",Buff[0],Buff[1],Buff[2],Buff[3]);
|
}
|
||||||
if (res != FR_OK) {
|
printfs(1 + bank, "BANK %X ADDR %LX", bank, addr);
|
||||||
printfc("SNES::main: read failed\n");
|
|
||||||
put_rc(res);
|
/*
|
||||||
break;
|
* for (i=0; i<BLOCK_SIZE; i++){ *(byte*)(addr + i) = Buff[i]; }
|
||||||
}
|
*/
|
||||||
p2 += s2;
|
printfc("SNES::main: mem %x %x %x %x %lx\n",
|
||||||
if (cnt != s2){
|
*(byte *) (addr + 0), *(byte *) (addr + 1),
|
||||||
printfc("SNES::main: read cnt=%i s2=%i\n",cnt,s2);
|
*(byte *) (addr + 2), *(byte *) (addr + 3), addr);
|
||||||
break;
|
|
||||||
}
|
// if (addr=0x10fe00){
|
||||||
<<<<<<< HEAD:snes/fatfstest/main.c
|
printc_packet(addr, 512, (byte *) (addr));
|
||||||
printfs(1,"%lu BYTES READ", p2);
|
|
||||||
=======
|
// }
|
||||||
printfs(1 + bank,"BANK %X ADDR %LX",bank,addr);
|
addr += s2;
|
||||||
>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/main.c
|
if (addr % 0x10000 == 0) {
|
||||||
/*
|
|
||||||
for (i=0; i<BLOCK_SIZE; i++){
|
// crc = crc_update_mem(crc_addr,0x8000);
|
||||||
*(byte*)(addr + i) = Buff[i];
|
// printfc("addr=%lx crc=%x\n",crc_addr,crc);
|
||||||
}
|
// printfs(1 + bank,"BANK %X ADDR %LX CRC
|
||||||
*/
|
// %X",bank,addr,crc);
|
||||||
<<<<<<< HEAD:snes/fatfstest/main.c
|
addr += 0x8000;
|
||||||
printfs(2,"%i BYTES TANS %x",BLOCK_SIZE, 0x020000 + p2);
|
|
||||||
=======
|
// crc_addr+=0x8000;
|
||||||
printfc("SNES::main: mem %x %x %x %x %lx\n",*(byte*)(addr + 0) ,*(byte*)(addr + 1) ,*(byte*)(addr + 2) ,*(byte*)(addr + 3) ,addr);
|
bank++;
|
||||||
//if (addr=0x10fe00){
|
}
|
||||||
|
}
|
||||||
printc_packet(addr,512,(byte*)(addr));
|
put_rc(f_close(&file1));
|
||||||
|
boot();
|
||||||
//}
|
while (1) {
|
||||||
|
wait();
|
||||||
addr+=s2;
|
}
|
||||||
if (addr%0x10000==0){
|
while (1);
|
||||||
//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);
|
void IRQHandler(void)
|
||||||
addr+=0x8000;
|
{
|
||||||
//crc_addr+=0x8000;
|
} void
|
||||||
bank++;
|
NMIHandler(void)
|
||||||
}
|
{
|
||||||
>>>>>>> c1203c3519d95a92e82a6f2ebf741ad663e46e33:snes/fatfstest/main.c
|
|
||||||
}
|
// processEvents();
|
||||||
put_rc(f_close(&file1));
|
}
|
||||||
boot();
|
|
||||||
while(1){
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
while(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRQHandler(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void NMIHandler(void) {
|
|
||||||
//processEvents();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,97 +1,97 @@
|
|||||||
#include "data.h";
|
#include "data.h";
|
||||||
#include "pad.h";
|
#include "pad.h";
|
||||||
#include "event.h";
|
#include "event.h";
|
||||||
|
|
||||||
extern padStatus pad1;
|
extern padStatus pad1;
|
||||||
extern word scrollValue;
|
extern word scrollValue;
|
||||||
|
|
||||||
char fadeOut(word counter) {
|
char fadeOut(word counter) {
|
||||||
static byte fadeOutValue;
|
static byte fadeOutValue;
|
||||||
|
|
||||||
if(counter == 0) {
|
if(counter == 0) {
|
||||||
// init fade value
|
// init fade value
|
||||||
fadeOutValue = 0x0f;
|
fadeOutValue = 0x0f;
|
||||||
} else {
|
} else {
|
||||||
fadeOutValue--;
|
fadeOutValue--;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(byte*) 0x2100 = fadeOutValue;
|
*(byte*) 0x2100 = fadeOutValue;
|
||||||
|
|
||||||
if(fadeOutValue == 0x00) {
|
if(fadeOutValue == 0x00) {
|
||||||
return EVENT_STOP;
|
return EVENT_STOP;
|
||||||
} else {
|
} else {
|
||||||
return EVENT_CONTINUE;
|
return EVENT_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char fadeIn(word counter) {
|
char fadeIn(word counter) {
|
||||||
static byte fadeInValue;
|
static byte fadeInValue;
|
||||||
|
|
||||||
if(counter == 0) {
|
if(counter == 0) {
|
||||||
// init fade value
|
// init fade value
|
||||||
fadeInValue = 0x00;
|
fadeInValue = 0x00;
|
||||||
} else {
|
} else {
|
||||||
fadeInValue++;
|
fadeInValue++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(byte*) 0x2100 = fadeInValue;
|
*(byte*) 0x2100 = fadeInValue;
|
||||||
|
|
||||||
if(fadeInValue >= 0x0f) {
|
if(fadeInValue >= 0x0f) {
|
||||||
return EVENT_STOP;
|
return EVENT_STOP;
|
||||||
} else {
|
} else {
|
||||||
return EVENT_CONTINUE;
|
return EVENT_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char mosaicOut(word counter) {
|
char mosaicOut(word counter) {
|
||||||
static byte mosaicOutValue;
|
static byte mosaicOutValue;
|
||||||
|
|
||||||
if(counter == 0) {
|
if(counter == 0) {
|
||||||
// init fade value
|
// init fade value
|
||||||
mosaicOutValue = 0xff;
|
mosaicOutValue = 0xff;
|
||||||
} else {
|
} else {
|
||||||
mosaicOutValue -= 0x10;
|
mosaicOutValue -= 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(byte*) 0x2106 = mosaicOutValue;
|
*(byte*) 0x2106 = mosaicOutValue;
|
||||||
|
|
||||||
if(mosaicOutValue == 0x0f) {
|
if(mosaicOutValue == 0x0f) {
|
||||||
return EVENT_STOP;
|
return EVENT_STOP;
|
||||||
} else {
|
} else {
|
||||||
return EVENT_CONTINUE;
|
return EVENT_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char mosaicIn(word counter) {
|
char mosaicIn(word counter) {
|
||||||
static byte mosaicInValue;
|
static byte mosaicInValue;
|
||||||
|
|
||||||
if(counter == 0) {
|
if(counter == 0) {
|
||||||
// init fade value
|
// init fade value
|
||||||
mosaicInValue = 0x0f;
|
mosaicInValue = 0x0f;
|
||||||
} else {
|
} else {
|
||||||
mosaicInValue += 0x10;
|
mosaicInValue += 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(byte*) 0x2106 = mosaicInValue;
|
*(byte*) 0x2106 = mosaicInValue;
|
||||||
|
|
||||||
if(mosaicInValue == 0xff) {
|
if(mosaicInValue == 0xff) {
|
||||||
return EVENT_STOP;
|
return EVENT_STOP;
|
||||||
} else {
|
} else {
|
||||||
return EVENT_CONTINUE;
|
return EVENT_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char NMIReadPad(word counter) {
|
char NMIReadPad(word counter) {
|
||||||
pad1 = readPad((byte) 0);
|
pad1 = readPad((byte) 0);
|
||||||
|
|
||||||
return EVENT_CONTINUE;
|
return EVENT_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char scrollLeft(word counter) {
|
char scrollLeft(word counter) {
|
||||||
scrollValue++;
|
scrollValue++;
|
||||||
|
|
||||||
*(byte*) 0x210d = (byte) scrollValue;
|
*(byte*) 0x210d = (byte) scrollValue;
|
||||||
*(byte*) 0x210d = (byte) (scrollValue>>8);
|
*(byte*) 0x210d = (byte) (scrollValue>>8);
|
||||||
|
|
||||||
return EVENT_CONTINUE;
|
return EVENT_CONTINUE;
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
char fadeOut(word counter);
|
char fadeOut(word counter);
|
||||||
char fadeIn(word counter);
|
char fadeIn(word counter);
|
||||||
char mosaicOut(word counter);
|
char mosaicOut(word counter);
|
||||||
char mosaicIn(word counter);
|
char mosaicIn(word counter);
|
||||||
char NMIReadPad(word counter);
|
char NMIReadPad(word counter);
|
||||||
char scrollLeft(word counter);
|
char scrollLeft(word counter);
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
#include "data.h";
|
#include "data.h";
|
||||||
#include "pad.h";
|
#include "pad.h";
|
||||||
#include "debug.h";
|
#include "debug.h";
|
||||||
|
|
||||||
void enablePad(void) {
|
void enablePad(void) {
|
||||||
// Enable pad reading and NMI
|
// Enable pad reading and NMI
|
||||||
*(byte*)0x4200 = 0x01;
|
*(byte*)0x4200 = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disablePad(void) {
|
void disablePad(void) {
|
||||||
// Enable pad reading and NMI
|
// Enable pad reading and NMI
|
||||||
*(byte*)0x4200 = 0x00;
|
*(byte*)0x4200 = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
padStatus readPad(byte padNumber) {
|
padStatus readPad(byte padNumber) {
|
||||||
word test;
|
word test;
|
||||||
padStatus *status;
|
padStatus *status;
|
||||||
padNumber = padNumber << 1;
|
padNumber = padNumber << 1;
|
||||||
test = (word) *(byte*)0x4218+padNumber << 8;
|
test = (word) *(byte*)0x4218+padNumber << 8;
|
||||||
test |= (word) *(byte*)0x4219+padNumber;
|
test |= (word) *(byte*)0x4219+padNumber;
|
||||||
status = (padStatus *) &test;
|
status = (padStatus *) &test;
|
||||||
return *status;
|
return *status;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
typedef struct padStatus{
|
typedef struct padStatus {
|
||||||
byte right:1;
|
byte right:1;
|
||||||
byte left:1;
|
byte left:1;
|
||||||
byte down:1;
|
byte down:1;
|
||||||
byte up:1;
|
byte up:1;
|
||||||
byte start:1; // Enter
|
byte start:1; // Enter
|
||||||
byte select:1; // Space
|
byte select:1; // Space
|
||||||
byte Y:1; // X
|
byte Y:1; // X
|
||||||
byte B:1; // C
|
byte B:1; // C
|
||||||
//--------------------------------
|
// --------------------------------
|
||||||
byte Dummy:4;
|
byte Dummy:4;
|
||||||
byte R:1; // Z
|
byte R:1; // Z
|
||||||
byte L:1; // A
|
byte L:1; // A
|
||||||
byte X:1; // S
|
byte X:1; // S
|
||||||
byte A:1; // D
|
byte A:1; // D
|
||||||
} padStatus;
|
} padStatus;
|
||||||
|
|
||||||
extern void enablePad(void);
|
extern void enablePad(void);
|
||||||
extern void disablePad(void);
|
extern void disablePad(void);
|
||||||
extern padStatus readPad(byte padNumber);
|
extern padStatus readPad(byte padNumber);
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
|
|
||||||
extern word debugFont_pic[];
|
extern word debugFont_pic[];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user