fix strange inverted address line bug, lots of other stuff

This commit is contained in:
ikari
2009-12-19 10:16:55 +01:00
parent 09e2480eac
commit b37fc1b846
13 changed files with 125 additions and 84 deletions

View File

@@ -81,7 +81,7 @@ uint16_t scan_dir(char* path, char mkdb, uint32_t this_dir_tgt) {
}
res = f_opendir(&dir, (unsigned char*)path);
if (res == FR_OK) {
if(pass && parent_tgt) {
if(pass && parent_tgt && mkdb) {
// write backlink to parent dir
// switch to next bank if record does not fit in current bank
if((db_tgt&0xffff) > ((0x10000-(sizeof(next_subdir_tgt)+sizeof(len)+4))&0xffff)) {

View File

@@ -141,6 +141,7 @@ void set_avr_bank(uint8_t val) {
uint8_t fpga_test() {
spi_fpga();
spiTransferByte(0xF0); // TEST
spiTransferByte(0x00); // dummy
uint8_t result = spiTransferByte(0x00);
spi_none();
return result;

View File

@@ -21,6 +21,8 @@ void set_avr_mapper(uint8_t val);
void set_avr_bank(uint8_t val);
#define FPGA_TEST_TOKEN (0xa5)
// some macros for bulk transfers (faster)
#define FPGA_SEND_BYTE(data) do {SET_AVR_DATA(data); CCLK();} while (0)
#define FPGA_SEND_BYTE_SERIAL(data) do {SET_AVR_DATA(data); CCLK();\

View File

@@ -49,6 +49,32 @@
#include "avrcompat.h"
#include "filetypes.h"
void writetest(void) {
// HERE BE LIONS, GET IN THE CAR
char teststring[58];
while(1) {
sram_writeblock((void*)"Testtext of DOOM!!1! 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", SRAM_SCRATCHPAD+0x20, 58);
sram_readblock((void*)teststring, SRAM_SCRATCHPAD+0x20, 58);
teststring[57]=0;
dprintf("%s\n", teststring);
}
// END OF LIONS
}
void memtest(void) {
/* HERE BE DRAGONS */
uint32_t dbg_i;
for(dbg_i=0; dbg_i < 65536; dbg_i++) {
sram_writeshort((uint16_t)dbg_i&0xffff, dbg_i*2);
}
save_sram((uint8_t*)"/sd2snes/memtest", 0x20000, 0);
set_pwr_led(0);
while(1);
/* END OF DRAGONS */
}
/* Make sure the watchdog is disabled as soon as possible */
/* Copy this code to your bootloader if you use one and your */
/* MCU doesn't disable the WDT after reset! */
@@ -163,14 +189,13 @@ restart:
uint16_t mem_dir_id = sram_readshort(SRAM_DIRID);
uint32_t mem_magic = sram_readlong(SRAM_SCRATCHPAD);
if((mem_magic != 0x12345678) || (mem_dir_id != saved_dir_id)) {
uint16_t curr_dir_id = scan_dir(fs_path, 0, 0); // generate files footprint
dprintf("curr dir id = %x\n", curr_dir_id);
if((get_db_id(&saved_dir_id) != FR_OK) // no database?
|| saved_dir_id != curr_dir_id) { // files changed? // XXX
dprintf("saved dir id = %x\n", saved_dir_id);
_delay_ms(50);
dprintf("rebuilding database...");
_delay_ms(50);
curr_dir_id = scan_dir(fs_path, 1, 0); // then rebuild database
@@ -184,6 +209,7 @@ restart:
dprintf("done\n");
sram_hexdump(SRAM_DB_ADDR, 0x400);
} else {
dprintf("saved dir id = %x\n", saved_dir_id);
dprintf("different card, consistent db, loading db...\n");
load_sram((uint8_t*)"/sd2snes/sd2snes.db", SRAM_DB_ADDR);
load_sram((uint8_t*)"/sd2snes/sd2snes.dir", SRAM_DIR_ADDR);
@@ -220,7 +246,6 @@ restart:
uint8_t cmd = 0;
while(!sram_reliable());
while(!cmd) {
cmd=menu_main_loop();
switch(cmd) {
@@ -255,7 +280,8 @@ restart:
cmd=0;
uint8_t snes_reset_prev=0, snes_reset_now=0, snes_reset_state=0;
uint16_t reset_count=0;
while(fpga_test() == 0xa5) {
while(fpga_test() == FPGA_TEST_TOKEN) {
dprintf("%02X\n", fpga_test());
snes_reset_now=get_snes_reset();
if(snes_reset_now) {
if(!snes_reset_prev) {
@@ -307,7 +333,6 @@ restart:
_delay_ms(150);
}
/* HERE BE LIONS */
while(1) {
set_avr_addr(0x600000);
@@ -335,6 +360,6 @@ while(1) {
}
spi_none();
}
while(1);
while(1);
}

View File

@@ -286,6 +286,7 @@ uint8_t sram_reliable() {
if(val==0x12345678) {
score++;
}
// dprintf("val=%08lX\n", val);
}
if(score<SRAM_RELIABILITY_SCORE) {
result = 0;