o fix wait, optimize printfs , implement file load
This commit is contained in:
parent
0a50554f4a
commit
53e0a0999e
@ -64,9 +64,9 @@ $(APP): $(OBJS)
|
||||
-C008000,0000 -U0000,0000 \
|
||||
-Avectors=FFE4,7FE4 \
|
||||
-Aregistration_data=FFB0,7FB0 \
|
||||
-Aressource=18000,8000 \
|
||||
-Aressource=3f8000,8000 \
|
||||
-N $(OBJS) $(LIBS) -O $@
|
||||
ucon64 -snes -chk $(APP)
|
||||
ucon64 -snes -chk $(APP) 2>&1 >/dev/null
|
||||
|
||||
clean:
|
||||
rm -vf $(APP) *.obj *.TMP
|
||||
|
||||
@ -9,29 +9,22 @@
|
||||
#include "ressource.h"
|
||||
|
||||
|
||||
|
||||
word debug_colors[] = {
|
||||
0xff7f, 0x1f00, 0x1802, 0x9772, 0xb55a, 0xbf5a, 0x1f5b, 0x7b73,
|
||||
0x987f, 0x7f5f, 0xff03, 0xfc7f, 0xff7f, 0xff7f, 0xff7f, 0xff7f
|
||||
};
|
||||
|
||||
word debugMap[0x400];
|
||||
static char debug_buffer[255];
|
||||
static char screen_buffer[255];
|
||||
|
||||
word col[] = {
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
0x03ff,
|
||||
|
||||
/*
|
||||
word debug_colors[] = {
|
||||
0x0000, 0x001f, 0x0218, 0x7297, 0x5ab5, 0x5abf, 0x5b1f, 0x737b,
|
||||
0x7f98, 0x5f7f, 0x03ff, 0x7ffc, 0x7fff, 0x0000, 0x0000, 0x0000
|
||||
};
|
||||
*/
|
||||
|
||||
void debug_init(void) {
|
||||
word i;
|
||||
@ -44,22 +37,34 @@ void debug_init(void) {
|
||||
|
||||
void debug_enable(void){
|
||||
VRAMLoad((word) debugFont_pic, 0x5000, 2048);
|
||||
CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16);
|
||||
//CGRAMLoad((word) debug_colors, (byte) 0x00, (word) 16);
|
||||
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
||||
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
|
||||
setCharacterLocation(0x5000, (byte) 0);
|
||||
*(byte*) 0x2100 = 0x0f; // enable background
|
||||
}
|
||||
|
||||
// hex(24 << 10 | 24 << 5 | 24 )
|
||||
// '0x6318'
|
||||
|
||||
*(byte*) 0x2121 = 0x00;
|
||||
*(byte*) 0x2122 = 0x18;
|
||||
*(byte*) 0x2122 = 0x63;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void clears(void) {
|
||||
word x,y;
|
||||
for(y=0; y<16; y++)
|
||||
for(x=0; x<32; x++)
|
||||
VRAMByteWrite((byte) (' '-32), (word) (0x4000+x+(y*0x20)));
|
||||
word i,y;
|
||||
for(y=0; y<20; y++){
|
||||
waitForVBlank();
|
||||
for(i=0; i<32; i++){
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = 0x4000+i+(y*0x20);
|
||||
*(byte*)0x2118 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _print_char(word y,word x, char c){
|
||||
waitForVBlank();
|
||||
VRAMByteWrite((byte) (c-32), (word) (0x4000+x+(y*0x20)));
|
||||
@ -71,18 +76,24 @@ void _print_screen(word y, char *buffer){
|
||||
l = strlen(buffer);
|
||||
waitForVBlank();
|
||||
while(*buffer){
|
||||
|
||||
if (*buffer == '\n' ) {
|
||||
while(x++<32)
|
||||
_print_char(y,x,' ');
|
||||
while(x++<32){
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
||||
*(byte*)0x2118 = 0;
|
||||
}
|
||||
x = 0;
|
||||
y++;
|
||||
buffer++;
|
||||
waitForVBlank();
|
||||
continue;
|
||||
}
|
||||
_print_char(y,x,*buffer);
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
||||
*(byte*)0x2118 = *buffer-32;
|
||||
x++;
|
||||
buffer++;
|
||||
//waitForVBlank();
|
||||
}
|
||||
}
|
||||
void _print_console(const char *buffer){
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
|
||||
//#include "integer.h"
|
||||
#include "ff.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "ff.h"
|
||||
#include "data.h";
|
||||
#include "pad.h";
|
||||
#include "event.h";
|
||||
@ -15,16 +13,24 @@
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
o debug STA global
|
||||
o optimize internal transfer buffer
|
||||
o direct write to mempage
|
||||
o relocate main code
|
||||
o exec loaded file
|
||||
*/
|
||||
|
||||
|
||||
padStatus pad1;
|
||||
|
||||
|
||||
unsigned long addr;
|
||||
DWORD acc_size; /* Work register for fs command */
|
||||
WORD acc_files, acc_dirs;
|
||||
|
||||
FILINFO finfo;
|
||||
FATFS fatfs[2]; /* File system object for each logical drive */
|
||||
BYTE Buff[1024]; /* Working buffer */
|
||||
BYTE Buff[512]; /* Working buffer */
|
||||
|
||||
DWORD p1, p2, p3;
|
||||
BYTE res;
|
||||
@ -33,9 +39,14 @@ UINT s1, s2, cnt;
|
||||
|
||||
FATFS *fs;
|
||||
DIR dir; /* Directory object */
|
||||
FIL file1, file2; /* File object */
|
||||
FIL file1;
|
||||
|
||||
|
||||
#define ROM_NAME "BANK01.SMC"
|
||||
#define BLOCK_SIZE 512
|
||||
|
||||
//#pragma section CODE=BANK2,offset $2:0000
|
||||
|
||||
|
||||
void initInternalRegisters(void) {
|
||||
characterLocation[0] = 0x0000;
|
||||
@ -111,15 +122,18 @@ FRESULT scan_files (char* path){
|
||||
void wait(){
|
||||
printfc("SNES::wait: press A to continue\n");
|
||||
enablePad();
|
||||
//waitForVBlank();
|
||||
pad1 = readPad((byte) 0);
|
||||
while(!pad1.A) {
|
||||
waitForVBlank();
|
||||
pad1 = readPad((byte) 0);
|
||||
}
|
||||
printfc("SNES::wait: done\n");
|
||||
disablePad();
|
||||
//disablePad();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void main(void) {
|
||||
word i,j;
|
||||
BYTE res;
|
||||
@ -132,18 +146,19 @@ void main(void) {
|
||||
|
||||
debug_enable();
|
||||
|
||||
printfs(0,"FATFS ");
|
||||
printfs(0,"FATFS OPTIXX.ORG ");
|
||||
//wait();
|
||||
printfc("SNES::main: Try to init disk\n");
|
||||
|
||||
put_rc(f_mount(0, &fatfs[0]));
|
||||
|
||||
|
||||
#if 0
|
||||
printfc("SNES::main: Try to get free\n");
|
||||
res = f_getfree("", &p2, &fs);
|
||||
if (res)
|
||||
put_rc(res);
|
||||
|
||||
|
||||
printfc("SNES::main: printf fs results\n");
|
||||
printfs(1,"FAT TYPE = %u\nBYTES/CLUSTER = %lu\nNUMBER OF FATS = %u\n"
|
||||
"ROOT DIR ENTRIES = %u\nSECTORS/FAT = %lu\nNUMBER OF CLUSTERS = %lu\n"
|
||||
@ -198,12 +213,55 @@ void main(void) {
|
||||
(finfo.ftime >> 11), (finfo.ftime >> 5) & 63,
|
||||
finfo.fsize, &(finfo.fname[0]));
|
||||
*/
|
||||
if (cnt && cnt==20){
|
||||
cnt = 0;
|
||||
wait();
|
||||
clears();
|
||||
}
|
||||
}
|
||||
/*
|
||||
printfc("%4u FILES, %10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
||||
|
||||
printfs(20,"%4u FILES\n%10lu BYTES TOTAL\n%4u DIRS", s1, p1, s2);
|
||||
if (f_getfree("", &p1, &fs) == FR_OK)
|
||||
printfc(", %10luK BYTES FREE\n", p1 * fs->csize / 2);
|
||||
*/
|
||||
printfs(23,"%10luK BYTES FREE\n", p1 * fs->csize / 2);
|
||||
|
||||
wait();
|
||||
clears();
|
||||
#endif
|
||||
printfc("SNES::main: open %s \n",ROM_NAME);
|
||||
printfs(0,"OPEN %s",ROM_NAME);
|
||||
put_rc(f_open(&file1, ROM_NAME, FA_READ));
|
||||
|
||||
|
||||
addr = 0x020000;
|
||||
p1 = 1024 * 31;
|
||||
p2 = 0;
|
||||
while (p1) {
|
||||
cnt = BLOCK_SIZE;
|
||||
p1 -= BLOCK_SIZE;
|
||||
res = f_read(&file1, Buff, cnt, &s2);
|
||||
printfc("SNES::main: read cnt=%i p1=%i p2=%i s2=%i\n",cnt,p1,p2,s2);
|
||||
//printfc("SNES::main: read %x %x %x %x \n",Buff[0],Buff[1],Buff[2],Buff[3]);
|
||||
if (res != FR_OK) {
|
||||
printfc("SNES::main: read failed\n");
|
||||
put_rc(res);
|
||||
break;
|
||||
}
|
||||
p2 += s2;
|
||||
if (cnt != s2){
|
||||
printfc("SNES::main: read cnt=%i s2=%i\n",cnt,s2);
|
||||
break;
|
||||
}
|
||||
printfs(1,"%lu BYTES READ", p2);
|
||||
/*
|
||||
for (i=0; i<BLOCK_SIZE; i++){
|
||||
*(byte*)(0x020000 + i) = Buff[i];
|
||||
}
|
||||
*/
|
||||
printfs(2,"%i BYTES TANS %x",BLOCK_SIZE, 0x020000 + p2);
|
||||
}
|
||||
printfs(1,"%lu BYTES READ", p2);
|
||||
put_rc(f_close(&file1));
|
||||
|
||||
while(1){
|
||||
wait();
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
void enablePad(void) {
|
||||
// Enable pad reading and NMI
|
||||
*(byte*)0x4200 = 0x81;
|
||||
*(byte*)0x4200 = 0x01;
|
||||
}
|
||||
|
||||
void disablePad(void) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user