Index: firmware/fat/pff_file.c
===================================================================
--- firmware/fat/pff_file.c	(revision 62)
+++ firmware/fat/pff_file.c	(revision 63)
@@ -194,17 +194,10 @@
 	return sizeof(struct SimpleFile);
 }
 
-enum SimpleFileStatus file_open_name(char const * path, struct SimpleFile * file)
+enum SimpleFileStatus file_open_name_in_dir(struct SimpleDirEntry * entry, char const * filename, struct SimpleFile * file)
 {
-	char dirname[MAX_DIR_LENGTH];
-	char const * filename = file_of(path);
-	dir_of(&dirname[0], path);
-
 	file_write_flush();
 
-	//printf("filename:%s dirname:%s ", filename,&dirname[0]);
-
-	struct SimpleDirEntry * entry = dir_entries(&dirname[0]);
 	while (entry)
 	{
 		//printf("%s ",entry->filename_ptr);
@@ -218,6 +211,20 @@
 	return SimpleFile_FAIL;
 }
 
+enum SimpleFileStatus file_open_name(char const * path, struct SimpleFile * file)
+{
+	char dirname[MAX_DIR_LENGTH];
+	char const * filename = file_of(path);
+	dir_of(&dirname[0], path);
+
+	file_write_flush();
+
+	//printf("filename:%s dirname:%s ", filename,&dirname[0]);
+
+	struct SimpleDirEntry * entry = dir_entries(&dirname[0]);
+	return file_open_name_in_dir(entry,filename, file);
+}
+
 enum SimpleFileStatus file_open_dir(struct SimpleDirEntry * dir, struct SimpleFile * file)
 {
 	FRESULT res;
@@ -411,7 +418,10 @@
 		begin = begin->next;
 	}*/
 
-	sort_ll((struct SimpleDirEntry *) dir_cache);
+	if (filter)
+	{
+		sort_ll((struct SimpleDirEntry *) dir_cache);
+	}
 	return (struct SimpleDirEntry *) dir_cache;
 }
 
Index: firmware/main.c
===================================================================
--- firmware/main.c	(revision 62)
+++ firmware/main.c	(revision 63)
@@ -163,19 +163,44 @@
 // 0x420000-0x43FFFF (0xc20000 in zpu space) = freeze backup
 
 struct SimpleFile * files[5];
+void loadromfile(struct SimpleFile * file, int size, void * ram_address)
+{
+	ram_address += 0x800000;
+	int read = 0;
+	file_read(file, ram_address, size, &read);
+}
 
 void loadrom(char const * path, int size, void * ram_address)
 {
-	ram_address += 0x800000;
 	if (SimpleFile_OK == file_open_name(path, files[4]))
 	{
-		int read = 0;
-		file_read(files[4], ram_address, size, &read);
+		loadromfile(files[4], size, ram_address);
 	}
 }
 
+void loadrom_indir(struct SimpleDirEntry * entries, char const * filename, int size, void * ram_address)
+{
+	if (SimpleFile_OK == file_open_name_in_dir(entries, filename, files[4]))
+	{
+		loadromfile(files[4], size, ram_address);
+	}
+}
+
 int main(void)
 {
+/*	spiInit();
+	set_spi_clock_freq();
+	mmcReadLoop();*/
+
+/*	spiInit();
+	set_spi_clock_freq();
+	char buffer[512];
+	while (1)
+	{
+		mmcReadLoop();
+		wait_us(500);
+	}*/
+
 	int i;
 	for (i=0; i!=5; ++i)
 	{
@@ -201,13 +226,16 @@
 	//	printf("DIR init ok\n");
 		init_drive_emulator();
 
-		loadrom("xlorig.rom",0x4000, (void *)0x704000);
-		loadrom("xlhias.rom",0x4000, (void *)0x708000);
-		loadrom("ultimon.rom",0x4000, (void *)0x70c000);
-		loadrom("osbhias.rom",0x4000, (void *)0x710000);
-		loadrom("osborig.rom",0x2800, (void *)0x715800);
-		loadrom("osaorig.rom",0x2800, (void *)0x719800);
-		loadrom("ataribas.rom",0x2000,(void *)0x700000);
+		
+		struct SimpleDirEntry * entries = dir_entries("");
+		
+		loadrom_indir(entries,"xlorig.rom",0x4000, (void *)0x704000);
+		loadrom_indir(entries,"xlhias.rom",0x4000, (void *)0x708000);
+		loadrom_indir(entries,"ultimon.rom",0x4000, (void *)0x70c000);
+		loadrom_indir(entries,"osbhias.rom",0x4000, (void *)0x710000);
+		loadrom_indir(entries,"osborig.rom",0x2800, (void *)0x715800);
+		loadrom_indir(entries,"osaorig.rom",0x2800, (void *)0x719800);
+		loadrom_indir(entries,"ataribas.rom",0x2000,(void *)0x700000);
 
 		//ROM = xlorig.rom,0x4000, (void *)0x704000
 		//ROM = xlhias.rom,0x4000, (void *)0x708000
Index: firmware/native/mmc.c
===================================================================
--- firmware/native/mmc.c	(revision 62)
+++ firmware/native/mmc.c	(revision 63)
@@ -26,7 +26,7 @@
 /// Returns zero if successful.
 u08 mmcRead(u32 sector)
 {
-	fprintf(stderr,"mmcRead:%x\n",sector);
+	//fprintf(stderr,"mmcRead:%x\n",sector);
 
 	fseek(disk_image, sector*512, SEEK_SET);
 	fread(&mmc_sector_buffer,512,1,disk_image);
Index: firmware/regs.c
===================================================================
--- firmware/regs.c	(revision 62)
+++ firmware/regs.c	(revision 63)
@@ -20,6 +20,8 @@
 
 int volatile * zpu_board = (int *)(12*4+config_regbase);
 
+int volatile * zpu_spi_dma = (int *)(13*4+config_regbase);
+
 unsigned char volatile * zpu_pokey_audf0 = (unsigned char *)(0x10*4+config_regbase);
 unsigned char volatile * zpu_pokey_audc0 = (unsigned char *)(0x11*4+config_regbase);
 unsigned char volatile * zpu_pokey_audf1 = (unsigned char *)(0x12*4+config_regbase);
Index: firmware/regs.h
===================================================================
--- firmware/regs.h	(revision 62)
+++ firmware/regs.h	(revision 63)
@@ -19,6 +19,8 @@
 extern int volatile * zpu_spi_state;
 extern int volatile * zpu_sio;
 extern int volatile * zpu_board;
+
+extern int volatile * zpu_spi_dma;
  
 extern unsigned char volatile * zpu_pokey_audf0;
 extern unsigned char volatile * zpu_pokey_audc0;
Index: firmware/sd_direct/mmc.c
===================================================================
--- firmware/sd_direct/mmc.c	(revision 62)
+++ firmware/sd_direct/mmc.c	(revision 63)
@@ -139,7 +139,10 @@
 	u16 i;
 	u08 *buffer=mmc_sector_buffer;	//natvrdo!
 
-	i=0x80;	//512
+	spiReceiveData(buffer,buffer+512);
+	//spiReceiveData(buffer,buffer+3);
+
+/*	i=0x80;	//512
 	do { *buffer++ = spiTransferFF(); i--; } while(i);
 
 	//spiDisplay(1);
@@ -150,7 +153,7 @@
 	do { *buffer++ = spiTransferFF(); i--; } while(i);
 
 	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);
+	do { *buffer++ = spiTransferFF(); i--; } while(i);*/
 
 	//spiDisplay(0);
 
Index: firmware/sd_direct/spi.c
===================================================================
--- firmware/sd_direct/spi.c	(revision 62)
+++ firmware/sd_direct/spi.c	(revision 63)
@@ -116,3 +116,11 @@
 	display = i;
 }
 
+void spiReceiveData(u08 * from, u08 * to)
+{
+	u32 from32 = (u32)from;
+	u32 to32 = (u32)to;
+	u32 val = to32<<16 | from32;
+	*zpu_spi_dma = val;
+}
+
Index: firmware/sd_direct/spi.h
===================================================================
--- firmware/sd_direct/spi.h	(revision 62)
+++ firmware/sd_direct/spi.h	(revision 63)
@@ -63,4 +63,6 @@
 
 void spiDisplay(int i);
 
+void spiReceiveData(u08 * from, u08 * to);
+
 #endif
Index: firmware/simpledir.h
===================================================================
--- firmware/simpledir.h	(revision 62)
+++ firmware/simpledir.h	(revision 63)
@@ -8,6 +8,7 @@
 struct SimpleDirEntry;
 
 enum SimpleFileStatus file_open_name(char const * path, struct SimpleFile * file);
+enum SimpleFileStatus file_open_name_in_dir(struct SimpleDirEntry * entries, char const * filename, struct SimpleFile * file);
 enum SimpleFileStatus file_open_dir(struct SimpleDirEntry * filename, struct SimpleFile * file);
 
 // Reads entire dir into memory (i.e. give it a decent chunk of sdram)
Index: firmware/test_file.c
===================================================================
--- firmware/test_file.c	(revision 62)
+++ firmware/test_file.c	(revision 63)
@@ -22,7 +22,7 @@
 
 struct SimpleFile * temp_file;
 
-void loadrom(char const * path, int size, void * ram_address)
+/*void loadrom(char const * path, int size, void * ram_address)
 {
 	filter = 0;
 	fprintf(stderr,"loadrom:%s\n",path);
@@ -30,11 +30,43 @@
 	if (SimpleFile_OK == file_open_name(path, temp_file))
 	{
 		int read = 0;
-		//file_read(files[4], ram_address, size, &read);
+		//file_read(temp_file, ram_address, size, &read);
 		printf("file_read:%s %x %x\n",file_name(temp_file), ram_address,size); 
 	}
 	else
 	{
+		printf("%s:FAILED\n",path);
+	}
+}*/
+
+void loadromfile(struct SimpleFile * file, int size, void * ram_address)
+{
+	ram_address += 0x800000;
+	int read = 0;
+	//file_read(file, ram_address, size, &read);
+	printf("file_read:%s %x %x\n",file_name(temp_file), ram_address,size); 
+}
+
+void loadrom(char const * path, int size, void * ram_address)
+{
+	if (SimpleFile_OK == file_open_name(path, temp_file))
+	{
+		loadromfile(temp_file, size, ram_address);
+	}
+	else
+	{
+		printf("%s:FAILED\n",path);
+	}
+}
+
+void loadrom_indir(struct SimpleDirEntry * entries, char const * filename, int size, void * ram_address)
+{
+	if (SimpleFile_OK == file_open_name_in_dir(entries, filename, temp_file))
+	{
+		loadromfile(temp_file, size, ram_address);
+	}
+	else
+	{
 		printf("FAILED\n");
 	}
 }
@@ -157,6 +189,19 @@
 		loadrom("osaorig.rom",0x2800, (void *)0x719800);
 		loadrom("ataribas.rom",0x2000,(void *)0x700000);
 
+	{
+		printf("WTF\n");
+		struct SimpleDirEntry * entries = dir_entries("");
+		
+		loadrom_indir(entries,"xlorig.rom",0x4000, (void *)0x704000);
+		loadrom_indir(entries,"xlhias.rom",0x4000, (void *)0x708000);
+		loadrom_indir(entries,"ultimon.rom",0x4000, (void *)0x70c000);
+		loadrom_indir(entries,"osbhias.rom",0x4000, (void *)0x710000);
+		loadrom_indir(entries,"osborig.rom",0x2800, (void *)0x715800);
+		loadrom_indir(entries,"osaorig.rom",0x2800, (void *)0x719800);
+		loadrom_indir(entries,"ataribas.rom",0x2000,(void *)0x700000);
+	}
+
 	entry = dir_entries("/DCIM");
 	entry = dir_next(entry);
 	fprintf(stderr, " Name:%s", dir_filename(entry));
