diff --git a/avr/usbload/Makefile b/avr/usbload/Makefile index 5a50dfb..4537a21 100644 --- a/avr/usbload/Makefile +++ b/avr/usbload/Makefile @@ -33,7 +33,7 @@ ifeq ($(DEBUG),1) OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \ main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \ dump.o timer.o watchdog.o rle.c loader.o info.o shared_memory.o \ - command.o mmc.o fat.o file.o testing.o + command.o mmc.o fat.o file.o dir.o testing.o else LDFLAGS = -Wl,-u CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO diff --git a/avr/usbload/dir.c b/avr/usbload/dir.c new file mode 100644 index 0000000..56e346d --- /dev/null +++ b/avr/usbload/dir.c @@ -0,0 +1,51 @@ +/* + * ===================================================================================== + * + * ________ .__ __ ________ ____ ________ + * \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/ + * / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \ + * / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \ + * \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ / + * \__> \/ \/ \/ \/ \/ + * + * www.optixx.org + * + * + * Version: 1.0 + * Created: 07/21/2009 03:32:16 PM + * Author: david@optixx.org + * + * ===================================================================================== + */ + + +#include "dir.h" + +#include + + +uint16_t positon = 0; + +void dir_entry_start(){ + positon = 0; +} + +void dir_add_entry(uint16_t id, uint8_t file_name,uint32_t file_size,uint8_t file_attr){ + uint32_t addr; + dir_ent_t ent; + strncpy(ent.file_name,file_name,13); + ent.file_size = file_size; + ent.file_attr = file_attr; + addr = DIR_ENTRY_LOC + (positon << DIR_ENTRY_SIZE_SHIFT ); + sram_bulk_copy(addr, (uint8_t *) &ent, DIR_ENTRY_SIZE ); + positon++; +} + +void dir_add_header(uint16_t position, uint8_t * header){ + uint32_t addr; + dir_ent_t ent; + addr = DIR_ENTRY_LOC + ( position << DIR_ENTRY_SIZE_SHIFT ) + DIR_ENTRY_HEADER_OFF; + sram_bulk_copy(addr, (uint8_t *) header, DIR_ENTRY_HEADER_SIZE); +} + + diff --git a/avr/usbload/dir.h b/avr/usbload/dir.h new file mode 100644 index 0000000..f9307d2 --- /dev/null +++ b/avr/usbload/dir.h @@ -0,0 +1,46 @@ +/* + * ===================================================================================== + * + * ________ .__ __ ________ ____ ________ + * \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/ + * / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \ + * / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \ + * \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ / + * \__> \/ \/ \/ \/ \/ + * + * www.optixx.org + * + * + * Version: 1.0 + * Created: 07/21/2009 03:32:16 PM + * Author: david@optixx.org + * + * ===================================================================================== + */ + + +#ifndef __DIR_H__ +#define __DIR_H__ + +#include +#include + +#define DIR_ENTRY_LOC 0x010000 +#define DIR_ENTRY_SIZE 64 +#define DIR_ENTRY_SIZE_SHIFT 6 +#define DIR_ENTRY_HEADER_SIZE 44 +#define DIR_ENTRY_HEADER_OFF 20 + +typedef struct { + uint16_t id; // 1 + uint8_t file_name[13]; // 8.3 = 12 + 1 = 12 + uint32_t file_size; // 4 + uint8_t file_attr; // 1 + uint8_t snes_header[44]; // 44 +} dir_ent_t; // 64 + +void dir_entry_start(); +void dir_entry_add_(uint16_t id, uint8_t file_name,uint32_t file_size,uint8_t file_attr); +void dir_entry_header(uint16_t position, uint8_t * header); + +#endif diff --git a/avr/usbload/file.c b/avr/usbload/file.c index 6ed89f9..fae69cd 100644 --- a/avr/usbload/file.c +++ b/avr/usbload/file.c @@ -178,6 +178,7 @@ void ffls(void) uint16_t s; // fat16 root dir sektoren if (fat.dir == 0 && fat.fatType == 16) { // IM ROOTDIR. fat16 + printf("Fat16\n"); for (s = 0; s < (uint16_t) (fat.dataDirSec + 2 - fat.rootDir); s++) { // zählt durch RootDir sektoren (errechnet anzahl // rootDir sektoren). lsRowsOfClust(fat.rootDir + s); // zeigt reihen eines root dir clust an @@ -185,6 +186,7 @@ void ffls(void) } else { + printf("Fat32\n"); if (fat.dir == 0 && fat.fatType == 32) clust = fat.rootDir; // IM ROOTDIR. fat32 else