rearrange wram mem usage

This commit is contained in:
David Voswinkel 2009-06-14 19:12:39 +02:00
parent 396729e2e2
commit 9991dfa249
6 changed files with 84 additions and 51 deletions

View File

@ -187,9 +187,9 @@ DATA
XDEF ~~heap_end XDEF ~~heap_end
~~heap_start: ~~heap_start:
WORD $1000 WORD $1e00
~~heap_end: ~~heap_end:
WORD $1200 WORD $2000
;****************************************************************************** ;******************************************************************************
;*** SNES ROM Registartion Data *** ;*** SNES ROM Registartion Data ***

View File

@ -17,7 +17,7 @@
#define SHARED_SIZE 32768 #define SHARED_SIZE 32768
#define SHARED_ADDR 0x3d0000 #define SHARED_ADDR 0x3d8000
//#define SHARED_ADDR 0x001d00
#undef MMIO_DEBUG #undef MMIO_DEBUG

View File

@ -12,25 +12,34 @@
word debugMap[0x400]; #define DEBUG_BUFFER_SIZE 256
static char debug_buffer[512];
static char screen_buffer[512]; word debug_map[0x400];
char debug_buffer[DEBUG_BUFFER_SIZE];
//char screen_buffer[DEBUG_BUFFER_SIZE];
void debug_init(void) void debug_init(void)
{ {
word i;
for (i = 0; i < 0x400; i++) { memset(debug_map, 0, 0x800);
debugMap[i] = 0x00; memset(debug_buffer, 0,DEBUG_BUFFER_SIZE);
}
memset(debug_buffer, 0, 255); #if 0
memset(screen_buffer, 0, DEBUG_BUFFER_SIZE);
printfc("screen_buffer=%p\n",screen_buffer);
printfc("debug_buffer=%p\n",debug_buffer);
printfc("debug_map=%p\n",debug_map);
#endif
} }
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) debug_map, 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
@ -73,10 +82,12 @@ void _print_char(word y, word x, char c)
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; unsigned int x;
x = y * 0x20;
l = strlen(buffer); l = strlen(buffer);
waitForVBlank(); waitForVBlank();
while (*buffer) { while (*buffer) {
@ -86,14 +97,14 @@ void _print_screen(word y, char *buffer)
*(word *) 0x2116 = 0x4000 + x + (y * 0x20); *(word *) 0x2116 = 0x4000 + x + (y * 0x20);
*(byte *) 0x2118 = 0; *(byte *) 0x2118 = 0;
} }
x = 0; y ++;
y++; x = y * 0x20;
buffer++; buffer++;
waitForVBlank(); waitForVBlank();
continue; continue;
} }
*(byte *) 0x2115 = 0x80; *(byte *) 0x2115 = 0x80;
*(word *) 0x2116 = 0x4000 + x + (y * 0x20); *(word *) 0x2116 = 0x4000 + x;
*(byte *) 0x2118 = *buffer - 32; *(byte *) 0x2118 = *buffer - 32;
x++; x++;
buffer++; buffer++;
@ -102,6 +113,7 @@ void _print_screen(word y, char *buffer)
#endif #endif
} }
} }
void _print_console(const char *buffer) void _print_console(const char *buffer)
{ {
while (*buffer) while (*buffer)
@ -118,7 +130,7 @@ void printfc(const char *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, DEBUG_BUFFER_SIZE);
} }
@ -126,10 +138,11 @@ void printfs(word y, const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vsprintf(screen_buffer, fmt, ap); vsprintf(debug_buffer, fmt, ap);
va_end(ap); va_end(ap);
_print_screen(y, screen_buffer); _print_screen(y, debug_buffer);
memset(screen_buffer, 0, 255); //memset(debug_buffer, 0, DEBUG_BUFFER_SIZE);
//memset(screen_buffer, 0, DEBUG_BUFFER_SIZE);
} }
void printc_packet(unsigned long addr, unsigned int len, byte * packet) void printc_packet(unsigned long addr, unsigned int len, byte * packet)

View File

@ -25,7 +25,7 @@
#ifndef _FATFS #ifndef _FATFS
#define _FATFS #define _FATFS
#define _WORD_ACCESS 0 #define _WORD_ACCESS 1
/* /*
* The _WORD_ACCESS option defines which access method is used to the word / data in the FAT structure. / / 0: Byte-by-byte access. Always * 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 * compatible with all platforms. / 1: Word access. Do not choose this unless following condition is met. / / When the byte order on the

View File

@ -23,21 +23,25 @@
typedef void (*FUNC) (void); typedef void (*FUNC) (void);
padStatus pad1; padStatus pad1;
DWORD acc_size; /* Work register for fs command */
WORD acc_files, acc_dirs;
FILINFO finfo; FILINFO finfo;
FATFS fatfs[2]; /* File system object for each logical * drive */ FATFS fatfs[1]; /* File system object for each logical * drive */
// BYTE Buff[512]; /* Working buffer */
DWORD p1, p2, p3;
DWORD addr;
DWORD crc_addr;
UINT crc;
BYTE res, bank;
WORD w1;
UINT s1, s2, cnt;
FATFS *fs; FATFS *fs;
DIR dir; /* Directory object */ DIR dir; /* Directory object */
FIL file1, file2; FIL file1;
char buffer[512];
char *ptr;
DWORD acc_size; /* Work register for fs command */
WORD acc_files, acc_dirs;
DWORD p1, p2;
UINT s1, s2, cnt,crc,bank;
DWORD addr,crc_addr;
BYTE res;
char rom_name[]= ROM_NAME;
void initInternalRegisters(void) void initInternalRegisters(void)
{ {
characterLocation[0] = 0x0000; characterLocation[0] = 0x0000;
@ -83,7 +87,7 @@ void put_rc(FRESULT rc)
for (p = str, i = 0; i != rc && *p; i++) { for (p = str, i = 0; i != rc && *p; i++) {
while (*p++); while (*p++);
} }
printfc("rc=%u FR_%s\n", (WORD) rc, p); printfc("rc=%i FR_%s\n", (WORD) rc, p);
} }
FRESULT scan_files(char *path) FRESULT scan_files(char *path)
@ -128,7 +132,7 @@ void boot(DWORD addr)
{ {
FUNC fn; FUNC fn;
printfc("SNES::boot addr=%lx\n", addr); printfc("SNES::boot addr=%lx\n", addr);
fn = (FUNC) addr; fn = (FUNC)addr;
fn(); fn();
} void main(void) } void main(void)
@ -145,11 +149,14 @@ void boot(DWORD addr)
printfc("SNES::main: Try to init disk\n"); printfc("SNES::main: Try to init disk\n");
put_rc(f_mount((BYTE) 0, &fatfs[0])); put_rc(f_mount((BYTE) 0, &fatfs[0]));
#if 0
printfs(0, "FATFS OPTIXX.ORG "); printfs(0, "FATFS OPTIXX.ORG ");
printfc("SNES::main: Try to get free\n"); printfc("SNES::main: Try to get free\n");
res = f_getfree("", &p2, &fs); res = f_getfree("", &p2, &fs);
if (res) if (res)
put_rc(res); put_rc(res);
printfc("SNES::main: printf fs results\n"); printfc("SNES::main: printf fs results\n");
printfs(1, printfs(1,
"FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n" "FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
@ -159,6 +166,7 @@ void boot(DWORD addr)
(WORD) fs->n_fats, fs->n_rootdir, (DWORD) fs->sects_fat, (WORD) fs->n_fats, fs->n_rootdir, (DWORD) fs->sects_fat,
(DWORD) fs->max_clust - 2, fs->fatbase, fs->dirbase, fs->database); (DWORD) fs->max_clust - 2, fs->fatbase, fs->dirbase, fs->database);
acc_size = acc_files = acc_dirs = 0; acc_size = acc_files = acc_dirs = 0;
printfc("SNES::main: scan files\n"); printfc("SNES::main: scan files\n");
res = scan_files(""); res = scan_files("");
if (res) if (res)
@ -170,10 +178,14 @@ void boot(DWORD addr)
res = f_opendir(&dir, ""); res = f_opendir(&dir, "");
if (res) if (res)
put_rc(res); put_rc(res);
p1 = s1 = s2 = 0; p1 = s1 = s2 = 0;
cnt = 0; cnt = 0;
wait(); wait();
clears(); clears();
#endif
#if 0 #if 0
printfc("SNES::main: read dir\n"); printfc("SNES::main: read dir\n");
for (;;) { for (;;) {
@ -214,55 +226,63 @@ void boot(DWORD addr)
wait(); wait();
clears(); clears();
#endif /* */ #endif
printfc("SNES::main: open %s \n", ROM_NAME);
printfs(0, "OPEN %s", ROM_NAME);
put_rc(f_open(&file1, ROM_NAME, (BYTE) FA_READ));
p1 = BANK_SIZE * BANK_COUNT; p1 = BANK_SIZE * BANK_COUNT;
p2 = 0; p2 = 0;
p3 = 0;
cnt = 0; cnt = 0;
bank = 0; bank = 0;
addr = BASE_ADDR; addr = BASE_ADDR;
crc_addr = BASE_ADDR; crc_addr = BASE_ADDR;
printfc("SNES::main: open %s \n", rom_name);
printfs(0, "OPEN %s", rom_name);
put_rc(f_open(&file1, rom_name, (BYTE) FA_READ));
while (p1) { while (p1) {
cnt = BLOCK_SIZE; cnt = BLOCK_SIZE;
p1 -= BLOCK_SIZE; p1 -= BLOCK_SIZE;
res = f_read(&file1, (byte *) (addr), cnt, &s2);
res = f_read(&file1, buffer, cnt, &s2);
if (res != FR_OK) { if (res != FR_OK) {
printfc("SNES::main: read failed\n"); printfc("SNES::main: read failed\n");
put_rc(res); put_rc(res);
break; break;
} }
p2 += s2; p2 += s2;
if (cnt != s2) { if (cnt != s2) {
printfc("SNES::main: read cnt=%i s2=%i\n", cnt, s2); printfc("SNES::main: read cnt=%i s2=%i\n", cnt, s2);
break; break;
} }
for (i=0;i<BLOCK_SIZE;i++)
*(byte*)(addr++) = buffer[i];
#if 0 #if 0
printc_packet(addr, 512, (byte *) (addr)); printc_packet(addr, 512, (byte *) (addr));
wait(); wait();
#endif #endif
addr += s2; //addr += s2;
if (addr % 0x10000 == 0) { if (addr % 0x10000 == 0) {
printfc("SNES::main: read cnt=%i p1=%li p2=%li s2=%i \n", cnt, //printfc("SNES::main: read p1=%li p2=%li cnt=%i s2=%i\n",
p1, p2, s2); // p1, p2, cnt, s2);
#if 0 #if 0
crc = crc_update_mem(crc_addr, 0x8000); crc = crc_update_mem(crc_addr, 0x8000);
printfc("SNES::main: crc_addr=%lx crc=%x\n", crc_addr, crc); printfc("SNES::main: crc_addr=%lx crc=%x\n", crc_addr, crc);
crc_addr += 0x8000; crc_addr += 0x8000;
#endif #endif
printfs((1 + bank), "BANK %i ADDR 0X%lx ", bank, addr);
printfs(bank+1, "BANK 0X%X ADDR 0X%lX", bank, addr);
addr += 0x8000; addr += 0x8000;
bank++; bank++;
} }
} }
put_rc(f_close(&file1)); put_rc(f_close(&file1));
addr = *(byte *) 0xFFFD; addr = *(byte *) 0xFFFD;
addr = addr << 8; addr = addr << 8;

View File

@ -15,8 +15,8 @@
#define SHARED_MAX_SIZE 32768 #define SHARED_MAX_SIZE 32768
#define SHARED_ADDR 0x3d0000 #define SHARED_ADDR 0x3d8000
//#define SHARED_ADDR 0x001d00
#undef MMIO_DEBUG #undef MMIO_DEBUG
#undef FATFS_DEBUG #undef FATFS_DEBUG
#undef DISKIO_DEBUG 1 #undef DISKIO_DEBUG 1