Index: firmware/atari_drive_emulator.c
===================================================================
--- firmware/atari_drive_emulator.c	(revision 54)
+++ firmware/atari_drive_emulator.c	(revision 55)
@@ -250,10 +250,10 @@
 
 	if (atr_header.wSecSize == 0x80)
 	{
-		if (atr_header.wPars>(720*128/16))
+	/*	if (atr_header.wPars>(720*128/16))
 			printf("MD ");
 		else
-			printf("SD ");
+			printf("SD ");*/
 	}
 	else if (atr_header.wSecSize == 0x100)
 	{
@@ -480,7 +480,7 @@
 
 				if (command.command == 0x57)
 				{
-					char buffer[256];
+					unsigned char buffer[256];
 					int read;
 					file_read(file,buffer,sectorSize,&read);
 
Index: firmware/common/utils.c
===================================================================
--- firmware/common/utils.c	(revision 54)
+++ firmware/common/utils.c	(revision 55)
@@ -1,3 +1,5 @@
+#include "utils.h"
+
 int strcmp(char const * a, char const * b)
 {
 	while (*a || *b)
@@ -13,6 +15,15 @@
 	return 0;
 }
 
+int stricmp(char const * a, char const * b)
+{
+	char buffer[128];
+	char buffer2[128];
+	stricpy(&buffer[0],a);
+	stricpy(&buffer2[0],b);
+	return strcmp(&buffer[0],&buffer2[0]);
+}
+
 void strcpy(char * dest, char const * src)
 {
 	while (*dest++=*src++);
Index: firmware/common/utils.h
===================================================================
--- firmware/common/utils.h	(revision 54)
+++ firmware/common/utils.h	(revision 55)
@@ -1,4 +1,5 @@
 int strcmp(char const * a, char const * b);
+int stricmp(char const * a, char const * b);
 void strcpy(char * dest, char const * src);
 void stricpy(char * dest, char const * src);
 int strlen(char const * a);
Index: firmware/fat/pff.c
===================================================================
--- firmware/fat/pff.c	(revision 54)
+++ firmware/fat/pff.c	(revision 55)
@@ -24,7 +24,7 @@
 
 #include "pff.h"		/* Petit FatFs configurations and declarations */
 #include "diskio.h"		/* Declarations of low level disk I/O functions */
-#include "printf.h"
+//#include "printf.h"
 
 
 
Index: firmware/fat/pff_file.c
===================================================================
--- firmware/fat/pff_file.c	(revision 54)
+++ firmware/fat/pff_file.c	(revision 55)
@@ -4,7 +4,7 @@
 #include "utils.h"
 #include "diskio.h"
 #include "simplefile.h"
-#include "printf.h"
+//#include "printf.h"
 
 struct SimpleFile * openfile;
 
@@ -99,7 +99,7 @@
 	WORD byteswritten_word;
 	FRESULT res;
 
-	printf("went\n");
+	//printf("went\n");
 
 	file_check_open(file);
 
@@ -113,7 +113,7 @@
 		if (bytes_this_cycle>(512-pos))
 			bytes_this_cycle = 512-pos;
 
-		printf("file_write:%d/%d - %d/%d\n",sector,pos,bytes_this_cycle,bytes);
+		//printf("file_write:%d/%d - %d/%d\n",sector,pos,bytes_this_cycle,bytes);
 
 		if (sector != write_pending)
 		{
@@ -129,7 +129,7 @@
 			char temp_buffer[1];
 			pf_read(&temp_buffer[0], 1, &byteswritten_word);
 
-			printf("Writing initial pos:%d\n",pos);
+			//printf("Writing initial pos:%d\n",pos);
 
 			// seek to the initial pos
 			fatfs.fptr = fptr + pos;
@@ -145,7 +145,7 @@
 	}
 	*byteswritten = bytes;
 
-	printf("wend\n");
+	//printf("wend\n");
 	return translateStatus(res);
 }
 
@@ -153,7 +153,7 @@
 {
 	if (write_pending >= 0)
 	{
-		printf("wflush\n");
+		//printf("wflush\n");
 		disk_writeflush();
 		write_pending = -1;
 	}
@@ -167,7 +167,7 @@
 	int location = offsetFromStart>>9;
 	if (write_pending >=0 && write_pending != offsetFromStart)
 	{
-		printf("flush on seek\n");
+		//printf("flush on seek\n");
 		file_write_flush();
 	}
 
@@ -195,13 +195,13 @@
 
 	file_write_flush();
 
-	printf("filename:%s dirname:%s ", filename,&dirname[0]);
+	//printf("filename:%s dirname:%s ", filename,&dirname[0]);
 
 	struct SimpleDirEntry * entry = dir_entries(&dirname[0]);
 	while (entry)
 	{
-		printf("%s ",entry->filename_ptr);
-		if (0==strcmp(filename,entry->filename_ptr))
+		//printf("%s ",entry->filename_ptr);
+		if (0==stricmp(filename,entry->filename_ptr))
 		{
 			return file_open_dir(entry, file);
 		}
@@ -233,19 +233,19 @@
 
 	write_pending = -1;
 
-	printf("dir_init\n");
+	//printf("dir_init\n");
 
 	dir_cache = mem;
 	dir_cache_size = space;
 
-	printf("disk_init go\n");
+	//printf("disk_init go\n");
 	res = disk_initialize();
-	printf("disk_init done\n");
+	//printf("disk_init done\n");
 	if (res!=RES_OK) return translateDStatus(res);
 
-	printf("pf_mount\n");
+	//printf("pf_mount\n");
 	fres = pf_mount(&fatfs);
-	printf("pf_mount done\n");
+	//printf("pf_mount done\n");
 
 	return translateStatus(fres);
 }
@@ -314,13 +314,13 @@
 
 	file_write_flush();
 
-	printf("opendir ");
+	//printf("opendir ");
 	if (FR_OK != pf_opendir(&dir,dirPath))
 	{
-		printf("FAIL ");
+		//printf("FAIL ");
 		return 0;
 	}
-	printf("OK ");
+	//printf("OK ");
 
 	struct SimpleDirEntry * prev = (struct SimpleDirEntry *)dir_cache;
 	strcpy(prev->path,"..");
@@ -352,6 +352,7 @@
 		}
 		else
 		{
+			//printf("OUT of room!\n");
 			break; // OUT OF ROOM!
 		}
 
@@ -371,7 +372,8 @@
 
 		strcpy(&entry->lfn[0],&filinfo.lfname[0]);
 
-	//	printf("%d %s %s\n",count++, filinfo.fname, filinfo.lfname);
+		//int count;
+		//printf("%d %s %s\n",count++, filinfo.fname, filinfo.lfname);
 
 		entry->next = 0;
 
@@ -391,8 +393,8 @@
 
 	entry->next = 0;
 
-/*	struct SimpleDirEntry * begin = (struct SimpleDirEntry *) dir_cache;
-	count = 0;
+	/*struct SimpleDirEntry * begin = (struct SimpleDirEntry *) dir_cache;
+	int count = 0;
 	while (begin)
 	{
 		printf("%d %s\n",count++, begin->path);
Index: firmware/fileselector.c
===================================================================
--- firmware/fileselector.c	(revision 54)
+++ firmware/fileselector.c	(revision 55)
@@ -11,7 +11,9 @@
 // TODO!
 #define MAX_PATH_LENGTH (9*5 + 8+3+1 + 1) 
 
-int filter(struct SimpleDirEntry * entry)
+int (* filter)(struct SimpleDirEntry * entry);
+
+int filter_disks(struct SimpleDirEntry * entry)
 {
 	if (dir_is_subdir(entry)) return 1;
 	char const * f = dir_filename(entry);
@@ -18,6 +20,14 @@
 	return (compare_ext(f,"ATR") || compare_ext(f,"XFD") || compare_ext(f,"XEX"));
 }
 
+int filter_roms(struct SimpleDirEntry * entry)
+{
+	if (dir_is_subdir(entry)) return 1;
+	char const * f = dir_filename(entry);
+	return (compare_ext(f,"ROM"));
+}
+
+
 void file_selector(struct SimpleFile * file)
 {
 	char dir[MAX_PATH_LENGTH] = "";
@@ -34,7 +44,7 @@
 			++entries;
 			temp_entry = dir_next(temp_entry);
 		}
-		printf("Entries:%d\n",entries);
+		//printf("Entries:%d\n",entries);
 
 		// Selected item
 		int pos = 0;
@@ -79,7 +89,12 @@
 				// output the new entries
 				int line;
 				debug_pos = 0;
-				int end = 21*40;
+				debug_adjust = 0;
+				printf("Choose ");
+				debug_adjust = 128;
+				printf("file");
+				debug_pos = 40;
+				int end = 22*40;
 				for (;;)
 				{
 					if (!render_entry) break;
@@ -113,7 +128,8 @@
 				debug_pos = 40*23;
 				if (sel_entry)
 				{
-					printf("%s %s %d %d %d",dir_is_subdir(sel_entry) ? "DIR":"", dir_filename(sel_entry), joy.x_, joy.y_, pos);
+					//printf("%s %s %d %d %d",dir_is_subdir(sel_entry) ? "DIR":"", dir_filename(sel_entry), joy.x_, joy.y_, pos);
+					printf("%s %s",dir_is_subdir(sel_entry) ? "DIR":"", dir_filename(sel_entry));
 				}
 			}
 
Index: firmware/fileselector.h
===================================================================
--- firmware/fileselector.h	(revision 54)
+++ firmware/fileselector.h	(revision 55)
@@ -2,3 +2,8 @@
 
 void file_selector(struct SimpleFile * file);
 
+int filter_disks(struct SimpleDirEntry * entry);
+int filter_roms(struct SimpleDirEntry * entry);
+
+extern int (* filter)(struct SimpleDirEntry * entry);
+
Index: firmware/freeze.c
===================================================================
--- firmware/freeze.c	(revision 54)
+++ firmware/freeze.c	(revision 55)
@@ -55,36 +55,38 @@
 	}
 
 	//Clear, except dl (first 0x40 bytes)
-	for (i=0x9c40; i!=(0x9c40+1024); i++)
-	{
-		atari_base[i] = 0;
-	}
+	clearscreen();
 
 	// Put custom chips in a safe state
-	// write a display list at 9c00
-	char dl[] = {
-		0x70,0x70,0x70,
-		0x42,0x40,0x9c,
+	// write a display list at 0600
+	unsigned char dl[] = {
+		0x70,
+		0x70,
+		0x47,0x40,0x9c,
+		0x70,
+		0x42,0x68,0x9c,
 		0x2,0x2,0x2,0x2,0x2,
 		0x2,0x2,0x2,0x2,0x2,
 		0x2,0x2,0x2,0x2,0x2,
 		0x2,0x2,0x2,0x2,0x2,
-		0x2,0x2,0x2,
-		0x70,
-		0x41,0x00,0x9c
+		0x2,0x2,
+		0x41,0x00,0x06
 	};
 	int j = 0;
-	for (i=0x9c00; j!=sizeof(dl); ++i,++j)
+	for (i=0x0600; j!=sizeof(dl); ++i,++j)
 	{
 		atari_base[i] = dl[j];
 	}
 
 	// point antic at my display list
+	*atari_dlisth = 0x06;
 	*atari_dlistl = 0x00;
-	*atari_dlisth = 0x9c;
+
 	*atari_colbk = 0x00;
-	*atari_colpf1 = 0x0f;
+	*atari_colpf0 = 0x2f;
+	*atari_colpf1 = 0x3f;
 	*atari_colpf2 = 0x00;
+	*atari_colpf3 = 0x1f;
 	*atari_prior = 0x00;
 	*atari_chbase = 0xe0;
 	*atari_dmactl = 0x22;
Index: firmware/main.c
===================================================================
--- firmware/main.c	(revision 54)
+++ firmware/main.c	(revision 55)
@@ -162,12 +162,22 @@
 // 0x410000-0x41FFFF (0xc10000 in zpu space) = directory cache - 64k
 // 0x420000-0x43FFFF (0xc20000 in zpu space) = freeze backup
 
-struct SimpleFile * files[4];
+struct SimpleFile * files[5];
 
+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);
+	}
+}
+
 int main(void)
 {
 	int i;
-	for (i=0; i!=4; ++i)
+	for (i=0; i!=5; ++i)
 	{
 		files[i] = (struct SimpleFile *)alloca(file_struct_size());
 		file_init(files[i]);
@@ -180,23 +190,42 @@
 	baseaddr = (unsigned char volatile *)(40000 + atari_regbase);
 	set_reset_6502(1);
 	set_turbo_6502(1);
+	set_rom_select(1);
 
 	init_printf(0, char_out);
 
 	// TODO...
 
-	printf("Hello World\n I am an Atari!\n");
-
 	if (SimpleFile_OK == dir_init((void *)0xc10000, 65536))
 	{
-		printf("DIR init ok\n");
+	//	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);
+
+		//ROM = xlorig.rom,0x4000, (void *)0x704000
+		//ROM = xlhias.rom,0x4000, (void *)0x708000
+		//ROM = ultimon.rom,0x4000, (void *)0x70c000
+		//ROM = osbhias.rom,0x4000, (void *)0x710000
+		//ROM = osborig.rom,0x2800, (void *)0x715800
+		//ROM = osaorig.rom,0x2800, (void *)0x719800
+		//
+		//ROM = ataribas.rom,0x2000,(void *)0x700000
+
+		//--SDRAM_BASIC_ROM_ADDR <= "111"&"000000"   &"00000000000000";
+		//--SDRAM_OS_ROM_ADDR    <= "111"&rom_select &"00000000000000";
 		reboot(1);
 		run_drive_emulator();
 	}
 	else
 	{
-		printf("DIR init failed\n");
+		//printf("DIR init failed\n");
 	}
 	reboot(1);
 	for (;;) actions();
@@ -223,7 +252,7 @@
 	case 0:
 		return "64K";
 	case 1:
-		return "128";
+		return "128K";
 	case 2:
 		return "320K(Compy)";
 	case 3:
@@ -239,7 +268,7 @@
 	}
 }
 
-void settings()
+int settings()
 {
 	struct joystick_status joy;
 	joy.x_ = joy.y_ = joy.fire_ = 0;
@@ -251,9 +280,11 @@
 	{
 		// Render
 		clearscreen();
-		debug_pos = 20;
+		debug_pos = 0;
 		debug_adjust = 0;
-		printf("Settings");
+		printf("Se");
+		debug_adjust = 128;
+		printf("ttings");
 		debug_pos = 80;
 		debug_adjust = row==0 ? 128 : 0;
 		printf("Turbo:%dx", get_turbo_6502());
@@ -273,8 +304,12 @@
 			debug_pos = temp+40;
 		}
 
-		debug_pos = 440;
+		debug_pos = 400;
 		debug_adjust = row==7 ? 128 : 0;
+		printf("Cartridge 8k simple");
+
+		debug_pos = 480;
+		debug_adjust = row==8 ? 128 : 0;
 		printf("Exit");
 
 		// Slow it down a bit
@@ -286,7 +321,7 @@
 
 		row+=joy.y_;
 		if (row<0) row = 0;
-		if (row>7) row = 7;
+		if (row>8) row = 8;
 		switch (row)
 		{
 		case 0:
@@ -312,8 +347,8 @@
 			{
 				int rom_select = get_rom_select();
 				rom_select+=joy.x_;
-				if (rom_select<0) rom_select = 0;
-				if (rom_select>7) rom_select = 7; // TODO
+				if (rom_select<1) rom_select = 1;
+				if (rom_select>6) rom_select = 6; // TODO
 				set_rom_select(rom_select);
 			}
 			break;
@@ -325,6 +360,7 @@
 				if (joy.x_>0)
 				{
 					// Choose new disk
+					filter = filter_disks;
 					file_selector(files[row-3]);
 					set_drive_status(row-3,files[row-3]);
 				}
@@ -346,6 +382,17 @@
 			}
 			break;
 		case 7:
+			{
+				if (joy.fire_)
+				{
+					filter = filter_roms;
+					file_selector(files[4]);
+					loadrom(file_name(files[4]),0x2000,(void *)0x700000);
+					return 1;
+				}
+			}
+			break;
+		case 8:
 			if (joy.fire_)
 			{
 				done = 1;
@@ -353,6 +400,8 @@
 			break;
 		}
 	}
+
+	return 0;
 }
 
 void actions()
@@ -374,15 +423,19 @@
 		set_pause_6502(1);
 		freeze();
 		debug_pos = 0;	
-		settings();
+		int do_reboot = settings();
 		debug_pos = -1;
 		restore();
-		set_pause_6502(0);
+		if (do_reboot)
+			reboot(1);
+		else
+			set_pause_6502(0);
 	}
 	else if (get_hotkey_fileselect())
 	{
 		set_pause_6502(1);
 		freeze();
+		filter = filter_disks;
 		file_selector(files[0]);
 		debug_pos = -1;
 		restore();
Index: firmware/regs.c
===================================================================
--- firmware/regs.c	(revision 54)
+++ firmware/regs.c	(revision 55)
@@ -42,6 +42,8 @@
 unsigned char volatile * atari_colbk = (unsigned char *)(0xd01a + atari_regbase);
 unsigned char volatile * atari_colpf1 = (unsigned char *)(0xd017 + atari_regbase);
 unsigned char volatile * atari_colpf2 = (unsigned char *)(0xd018 + atari_regbase);
+unsigned char volatile * atari_colpf3 = (unsigned char *)(0xd019 + atari_regbase);
+unsigned char volatile * atari_colpf0 = (unsigned char *)(0xd016 + atari_regbase);
 unsigned char volatile * atari_prior = (unsigned char *)(0xd01b + atari_regbase);
 unsigned char volatile * atari_random = (unsigned char *)(0xd20a + atari_regbase);
 unsigned char volatile * atari_porta = (unsigned char *)(0xd300 + atari_regbase);
Index: firmware/regs.h
===================================================================
--- firmware/regs.h	(revision 54)
+++ firmware/regs.h	(revision 55)
@@ -42,6 +42,8 @@
 extern unsigned char volatile * atari_colbk;
 extern unsigned char volatile * atari_colpf1;
 extern unsigned char volatile * atari_colpf2;
+extern unsigned char volatile * atari_colpf3;
+extern unsigned char volatile * atari_colpf0;
 extern unsigned char volatile * atari_prior;
 extern unsigned char volatile * atari_random;
 extern unsigned char volatile * atari_porta;
Index: firmware/sd_direct/diskio_mmc.c
===================================================================
--- firmware/sd_direct/diskio_mmc.c	(revision 54)
+++ firmware/sd_direct/diskio_mmc.c	(revision 55)
@@ -45,7 +45,7 @@
 {
 	DSTATUS stat;
 
-	printf(" in init ");
+	//printf(" in init ");
 	n_actual_mmc_sector = 0xffffffff;
 	do
 	{
@@ -53,7 +53,7 @@
 	}
 	while(mmcReset());	//dokud nenulove, tak smycka (return 0 => ok!)
 
-	printf(" setting freq ");
+	//printf(" setting freq ");
 
 	set_spi_clock_freq();
 
Index: firmware/standalone_simple.ld
===================================================================
--- firmware/standalone_simple.ld	(revision 54)
+++ firmware/standalone_simple.ld	(revision 55)
@@ -5,7 +5,7 @@
 MEMORY
 {
   CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x04000 /* 16k */
-  RAM (rx) : ORIGIN = 0x0000f000, LENGTH = 0x500 /* 32 bytes */
+  RAM (rx) : ORIGIN = 0x0000f000, LENGTH = 0x600 /* 32 bytes */
 }
 
 
Index: firmware/test_file.c
===================================================================
--- firmware/test_file.c	(revision 54)
+++ firmware/test_file.c	(revision 55)
@@ -20,12 +20,31 @@
 	putc(c, stderr);
 }
 
+struct SimpleFile * temp_file;
+
+void loadrom(char const * path, int size, void * ram_address)
+{
+	filter = 0;
+	fprintf(stderr,"loadrom:%s\n",path);
+	ram_address += 0x800000;
+	if (SimpleFile_OK == file_open_name(path, temp_file))
+	{
+		int read = 0;
+		//file_read(files[4], ram_address, size, &read);
+		printf("file_read:%s %x %x\n",file_name(temp_file), ram_address,size); 
+	}
+	else
+	{
+		printf("FAILED\n");
+	}
+}
+
 int main(void)
 {
 	init_printf(NULL, char_out);
 
-	char * mem = (char *)malloc(8192);
-	if (SimpleFile_OK != dir_init(mem, 8192))
+	char * mem = (char *)malloc(65536);
+	if (SimpleFile_OK != dir_init(mem, 65536))
 	{
 		fprintf(stderr,"Failed to open dir!");
 		return -1;
@@ -68,6 +87,7 @@
 	}
 
 
+/*
 	fprintf(stderr,"\n\n");
 //enum SimpleFileStatus file_open_name(char const * path, struct SimpleFile * file);
 //enum SimpleFileStatus file_open_dir(struct SimpleDirEntry * filename, struct SimpleFile * file);
@@ -103,14 +123,14 @@
 	//file_write_flush(); // Done automatically on next read, or can be forced with this...
 
 	file_seek(file,512);
-/*	for (i=0;i!=130;++i)
-	{
-		char towrite[9];
-		sprintf(&towrite[0],"Mark:%03d",i);
-		fprintf(stderr,"Writing \"%s\"\n",towrite);
-		file_write(file,towrite,8,&written);
-	}*/
-	file_write(file,"Blah",4,&written);
+//	for (i=0;i!=130;++i)
+//	{
+//		char towrite[9];
+//		sprintf(&towrite[0],"Mark:%03d",i);
+//		fprintf(stderr,"Writing \"%s\"\n",towrite);
+//		file_write(file,towrite,8,&written);
+//	}
+//	file_write(file,"Blah",4,&written);
 
 	printf("\n*** WTF:%s - %s - %s\n",file_name(file), file_of("/WTF"),file_of("/BLAH/BOOP"));
 
@@ -124,9 +144,21 @@
 		//fprintf(stderr,"%02x", buffer[i]);
 		fprintf(stderr,"%c", buffer[i]);
 	}
+*/
 
-	file_selector(file);
+	temp_file = alloca(file_struct_size());
+		loadrom("ASTEROID.BIN",0x4000, (void *)0x704000);
+		loadrom("asteroid.bin",0x4000, (void *)0x704000);
+		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);
 
+	//file_selector(file);
+
 	return 0;
 }
 
