From cf090451df3f8cc81d2913d374dd3d4ff789a20d Mon Sep 17 00:00:00 2001 From: optixx Date: Tue, 11 Aug 2009 15:42:14 +0200 Subject: [PATCH] add dir ent to sram copy --- avr/usbload/Makefile | 2 +- avr/usbload/dir.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ avr/usbload/dir.h | 46 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 avr/usbload/dir.c create mode 100644 avr/usbload/dir.h 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..db3aed1 --- /dev/null +++ b/avr/usbload/dir.c @@ -0,0 +1,46 @@ +/* + * ===================================================================================== + * + * ________ .__ __ ________ ____ ________ + * \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/ + * / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \ + * / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \ + * \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ / + * \__> \/ \/ \/ \/ \/ + * + * 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++; + +} + + + diff --git a/avr/usbload/dir.h b/avr/usbload/dir.h new file mode 100644 index 0000000..6e82c30 --- /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 + + +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 id, uint8_t header); + + +#endif