Index: firmware_5200/actions.c
===================================================================
--- firmware_5200/actions.c	(revision 191)
+++ firmware_5200/actions.c	(nonexistent)
@@ -1,59 +0,0 @@
-int bit_set(int var, int bit)
-{
-	return (((1<<bit)&var)!=0);
-}
-
-void actions()
-{
-	unsigned int i = 0;
-	//unsigned volatile char * store = 0xf00000; // SDRAM - fails!!
-	//unsigned volatile char * store  = 0xf80000; // SRAM...
-	//unsigned volatile char * store2 = 0xfc0000; // custom chips...
-
-	// cold start (need to clear a few key locations to make OS cold start)
-	// file selector (where applicable)
-	// options (where applicable)
-
-	int keys = *zpu_in;
-
-	if (bit_set(keys,0))
-	{
-		coldstart();
-	}
-	else if (bit_set(keys,1))
-	{
-		set_pause_6502(1);
-		freeze();
-		menu_options();
-		restore();
-		set_pause_6502(0);
-	}
-	else if (bit_set(keys,2))
-	{
-		set_pause_6502(1);
-		freeze();
-		menu_fileselector();
-		coldstart();
-	}
-}
-
-void menu_options()
-{
-	// title
-	// memory
-	// rom
-	// turbo
-	// disks
-	// exit/reboot
-
-	// simple state machine for menu, so I set up a small data structure then it just runs from that...
-}
-
-void menu_fileselector()
-{
-	// title
-	// loads of stuff, filtered by type
-	// directories can be selected
-	// initial directory set, after that starts where it was left
-}
-
Index: firmware_5200/mif_file_stuff/rom_epilogue.vhd
===================================================================
--- firmware_5200/mif_file_stuff/rom_epilogue.vhd	(revision 191)
+++ firmware_5200/mif_file_stuff/rom_epilogue.vhd	(nonexistent)
@@ -1 +0,0 @@
-END; 
Index: firmware_5200/mif_file_stuff/zpuromgen
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: firmware_5200/mif_file_stuff/zpuromgen
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: firmware_5200/mif_file_stuff/zpuromgen.c
===================================================================
--- firmware_5200/mif_file_stuff/zpuromgen.c	(revision 191)
+++ firmware_5200/mif_file_stuff/zpuromgen.c	(nonexistent)
@@ -1,59 +0,0 @@
-// zpuromgen.c
-//
-// Program to turn a binary file into a VHDL lookup table.
-//   by Adam Pierce
-//   29-Feb-2008
-//
-// This software is free to use by anyone for any purpose.
-//
-
-#include <unistd.h>
-#include <stdio.h>
-
-typedef unsigned char BYTE;
-
-main(int argc, char **argv)
-{
-       BYTE    opcode[4];
-       int     fd;
-       int     addr = 0;
-       ssize_t s;
-
-// Check the user has given us an input file.
-       if(argc < 2)
-       {
-               printf("Usage: %s <binary_file>\n\n", argv[0]);
-               return 1;
-       }
-
-// Open the input file.
-       fd = open(argv[1], 0);
-       if(fd == -1)
-       {
-               perror("File Open");
-               return 2;
-       }
-
-       while(1)
-       {
-       // Read 32 bits.
-               s = read(fd, opcode, 4);
-               if(s == -1)
-               {
-                       perror("File read");
-                       return 3;
-               }
-
-               if(s == 0)
-                       break; // End of file.
-
-       // Output to STDOUT.
-               printf("%04x : %02x%02x%02x%02x;\n",
-                      addr++, opcode[0], opcode[1],
-                      opcode[2], opcode[3]);
-       }
-
-       close(fd);
-       return 0;
-}
-
Index: firmware_5200/mif_file_stuff/rom_prologue.vhd
===================================================================
--- firmware_5200/mif_file_stuff/rom_prologue.vhd	(revision 191)
+++ firmware_5200/mif_file_stuff/rom_prologue.vhd	(nonexistent)
@@ -1,10 +0,0 @@
-DEPTH = 4096; % Memory depth and width are required % 
- % DEPTH is the number of addresses % 
-WIDTH = 32; % WIDTH is the number of bits of data per word % 
-% DEPTH and WIDTH should be entered as decimal numbers % 
-ADDRESS_RADIX = HEX; % Address and value radixes are required % 
-DATA_RADIX = HEX; % Enter BIN, DEC, HEX, OCT, or UNS; unless % 
- % otherwise specified, radixes = HEX % 
--- Specify values for addresses, which can be single address or range 
-CONTENT 
-BEGIN 
Index: firmware_5200/main_aeon_lite.c
===================================================================
--- firmware_5200/main_aeon_lite.c	(revision 191)
+++ firmware_5200/main_aeon_lite.c	(nonexistent)
@@ -1,3 +0,0 @@
-#include "aeon_lite/memory.h"
-#include "main_real.c"
-
Index: firmware_5200/build_sd_test
===================================================================
--- firmware_5200/build_sd_test	(revision 191)
+++ firmware_5200/build_sd_test	(nonexistent)
@@ -1 +0,0 @@
-gcc -g -O0 printf/printf.c test_sd.c fileutils.c fileselector.c fat/pff_file.c fat/pff.c common/utils.c native/regs.c native/joystick.c sd_direct/mmc.c sd_direct/diskio_mmc.c  native/screen.c native/spi.c -I. -Ifat -Icommon -Iprintf

Property changes on: firmware_5200/build_sd_test
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/joystick.h
===================================================================
--- firmware_5200/joystick.h	(revision 191)
+++ firmware_5200/joystick.h	(nonexistent)
@@ -1,14 +0,0 @@
-#pragma once
-
-struct joystick_status
-{
-	int x_;
-	int y_;
-	int fire_;
-};
-
-enum JoyWait {WAIT_QUIET, WAIT_FIRE, WAIT_MOVE, WAIT_EITHER};
-
-void joystick_poll(struct joystick_status * status);
-void joystick_wait(struct joystick_status * status, enum JoyWait waitFor);
-
Index: firmware_5200/main.c_DISKDEBUG
===================================================================
--- firmware_5200/main.c_DISKDEBUG	(revision 191)
+++ firmware_5200/main.c_DISKDEBUG	(nonexistent)
@@ -1,630 +0,0 @@
-#include "integer.h"
-#include "regs.h"
-#include "pause.h"
-#include "printf.h"
-#include "joystick.h"
-#include "freeze.h"
-
-#include "simpledir.h"
-#include "simplefile.h"
-#include "fileselector.h"
-
-#include "atari_drive_emulator.h"
-
-extern char ROM_DIR[];
-
-// FUNCTIONS in here
-// i) pff init - NOT USED EVERYWHERE
-// ii) file selector - kind of crap, no fine scrolling - NOT USED EVERYWHERE
-// iii) cold reset atari (clears base ram...)
-// iv) start atari (begins paused)
-// v) freeze/resume atari - NOT USED EVERYWHERE!
-// vi) menu for various options - NOT USED EVERYWHERE!
-// vii) pause - TODO - base this on pokey clock...
-
-// standard ZPU IN/OUT use...
-// OUT1 - 6502 settings (pause,reset,speed)
-// pause_n: bit 0 
-// reset_n: bit 1
-// turbo: bit 2-4: meaning... 0=1.79Mhz,1=3.58MHz,2=7.16MHz,3=14.32MHz,4=28.64MHz,5=57.28MHz,etc.
-// ram_select: bit 5-7: 
-//   		RAM_SELECT : in std_logic_vector(2 downto 0); -- 64K,128K,320KB Compy, 320KB Rambo, 576K Compy, 576K Rambo, 1088K, 4MB
-// rom_select: bit 8-13:
-//    		ROM_SELECT : in std_logic_vector(5 downto 0); -- 16KB ROM Bank
-
-#define BIT_REG(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-} \
-void set_ ## name(int param) \
-{ \
-	int val = *reg; \
-	 \
-	val = (val&~(mask<<shift)); \
-	val |= op(param)<<shift; \
-	 \
-	*reg = val; \
-}
-
-#define BIT_REG_RO(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-}
-
-BIT_REG(,0x1,0,pause_6502,zpu_out1)
-BIT_REG(,0x1,1,reset_6502,zpu_out1)
-BIT_REG(,0x3f,2,turbo_6502,zpu_out1)
-BIT_REG(,0x7,8,ram_select,zpu_out1)
-BIT_REG(,0x3f,11,rom_select,zpu_out1)
-
-BIT_REG_RO(,0x1,8,hotkey_softboot,zpu_in1)
-BIT_REG_RO(,0x1,9,hotkey_coldboot,zpu_in1)
-BIT_REG_RO(,0x1,10,hotkey_fileselect,zpu_in1)
-BIT_REG_RO(,0x1,11,hotkey_settings,zpu_in1)
-
-void
-wait_us(int unsigned num)
-{
-	// pause counter runs at pokey frequency - should be 1.79MHz
-	int unsigned cycles = (num*230)>>7;
-	*zpu_pause = cycles;
-}
-
-void memset8(void * address, int value, int length)
-{
-	char * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void memset32(void * address, int value, int length)
-{
-	int * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void clear_64k_ram()
-{
-	memset8((void *)0x200000, 0, 65536); // SRAM, if present (TODO)
-	memset32((void *)0x800000, 0, 16384);
-}
-
-void
-reboot(int cold)
-{
-	set_pause_6502(1);
-	if (cold)
-	{
-		clear_64k_ram();
-	}
-	set_reset_6502(1);
-	// Do nothing in here - this resets the memory controller!
-	set_reset_6502(0);
-	set_pause_6502(0);
-}
-
-unsigned char toatarichar(int val)
-{
-	int inv = val>=128;
-	if (inv)
-	{
-		val-=128;
-	}
-	if (val>='A' && val<='Z')
-	{
-		val+=-'A'+33;
-	}
-	else if (val>='a' && val<='z')
-	{
-		val+=-'a'+33+64;
-	}
-	else if (val>='0' && val<='9')
-	{
-		val+=-'0'+16;	
-	}
-	else if (val>=32 && val<=47)
-	{
-		val+=-32;
-	}
-	else
-	{
-		val = 0;
-	}
-	if (inv)
-	{
-		val+=128;
-	}
-	return val;
-}
-
-int debug_pos;
-int debug_adjust;
-unsigned char volatile * baseaddr;
-
-void clearscreen()
-{
-	unsigned volatile char * screen;
-	for (screen=(unsigned volatile char *)40000+atari_regbase; screen!=(unsigned volatile char *)(atari_regbase+40000+1024); ++screen)
-		*screen = 0x00;
-}
-
-void char_out ( void* p, char c)
-{
-	unsigned char val = toatarichar(c);
-	if (debug_pos>=0)
-	{
-		*(baseaddr+debug_pos) = val|debug_adjust;
-		++debug_pos;
-	}
-}
-
-// Memory usage...
-// 0x410000-0x41FFFF (0xc10000 in zpu space) = directory cache - 64k
-// 0x420000-0x43FFFF (0xc20000 in zpu space) = freeze backup
-
-struct SimpleFile * files[6];
-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)
-{
-	if (SimpleFile_OK == file_open_name(path, files[4]))
-	{
-		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);
-	}
-}
-
-void loadosrom()
-{
-	if (file_size(files[5]) == 0x4000)
-	{
-		loadromfile(files[5],0x4000, (void *)0x704000);
-	}
-	else if (file_size(files[5]) ==0x2800)
-	{
-		loadromfile(files[5],0x2800, (void *)0x705800);
-	}
-}
-
-int main(void)
-{
-	{
-		char buffer[512];
-
-		freeze_init((void*)0xc20000); // 128k
-	
-		debug_pos = -1;
-		debug_adjust = 0;
-		baseaddr = (unsigned char volatile *)(40000 + atari_regbase);
-		set_pause_6502(1);
-		set_reset_6502(1);
-		set_reset_6502(0);
-		set_turbo_6502(1);
-		set_rom_select(1);
-		set_ram_select(0);
-	
-		init_printf(0, char_out);
-		reboot(1);
-	//	for (;;);
-		wait_us(5000000);
-
-		disk_debug();
-
-		//for (;;);
-		wait_us(10000000);
-	}
-
-/*	disk_initialize();
-	{
-		char buffer[512];
-
-		freeze_init((void*)0xc20000); // 128k
-	
-		debug_pos = -1;
-		debug_adjust = 0;
-		baseaddr = (unsigned char volatile *)(40000 + atari_regbase);
-		set_pause_6502(1);
-		set_reset_6502(1);
-		set_reset_6502(0);
-		set_turbo_6502(1);
-		set_rom_select(1);
-		set_ram_select(0);
-	
-		init_printf(0, char_out);
-		reboot(1);
-	//	for (;;);
-		wait_us(5000000);
-
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-
-		printf("Hello world 3");
-		debug_pos = 40;
-		int i;
-		for (i=0;i!=512; ++i)
-		{
-			buffer[i] = i;
-		}
-		int volatile * x = (int volatile *)0x4000;
-		int volatile * y = (int volatile *)&buffer[0];
-		for (i=0;i!=128; ++i)
-		{
-			x[i] = y[i];
-		}
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 120;
-
-		printf(" Writing sector ");
-		n_actual_mmc_sector = 30;
-		disk_writeflush();
-		printf(" Wrote sector ");
-
-		for (i=0;i!=128; ++i)
-		{
-			x[i] = 0;
-		}
-		n_actual_mmc_sector = -1;
-		disk_readp(&buffer[0],30,0,512);
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 200;
-
-		disk_readp(&buffer[0],0x103,0,512);
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 280;
-
-		disk_readp(&buffer[0],0,0,512);
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 360;
-
-		printf("OK...");
-
-		//for (;;);
-		wait_us(10000000);
-	}*/
-
-/*	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!=6; ++i)
-	{
-		files[i] = (struct SimpleFile *)alloca(file_struct_size());
-		file_init(files[i]);
-	}
-
-	freeze_init((void*)0xc20000); // 128k
-
-	debug_pos = -1;
-	debug_adjust = 0;
-	baseaddr = (unsigned char volatile *)(40000 + atari_regbase);
-	set_pause_6502(1);
-	set_reset_6502(1);
-	set_reset_6502(0);
-	set_turbo_6502(1);
-	set_rom_select(1);
-	set_ram_select(2);
-
-	init_printf(0, char_out);
-
-	// TODO...
-
-	if (SimpleFile_OK == dir_init((void *)0xc10000, 65536))
-	{
-	//	printf("DIR init ok\n");
-		init_drive_emulator();
-
-		
-		struct SimpleDirEntry * entries = dir_entries(ROM_DIR);
-		
-		//loadrom_indir(entries,"atarixl.rom",0x4000, (void *)0x704000);
-		if (SimpleFile_OK == file_open_name_in_dir(entries, "atarixl.rom", files[5]))
-		{
-			loadosrom();
-		}
-
-		/*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
-		//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");
-	}
-	reboot(1);
-	for (;;) actions();
-}
-
-//		struct SimpleFile * file = alloca(file_struct_size());
-//		printf("Opening file\n");
-//		if (SimpleFile_OK == file_open_name("GUNPOWDR.ATR",file))
-//		{
-//			printf("FILE open ok\n");
-//
-//			set_drive_status(0,file);
-//
-//		}
-//		else
-//		{
-//			printf("FILE open failed\n");
-//		}
-
-char const * get_ram()
-{
-	static char const * ram[] = 
-	{
-		"64K",
-		"128K",
-		"320K(Compy)",
-		"320K(Rambo)",
-		"576K(Compy)",
-		"576K(Rambo)",
-		"1MB",
-		"4MB"
-	};
-	return ram[get_ram_select()];
-	/*switch(get_ram_select())
-	{
-	case 0:
-		return "64K";
-	case 1:
-		return "128K";
-	case 2:
-		return "320K(Compy)";
-	case 3:
-		return "320K(Rambo)";
-	case 4:
-		return "576K(Compy)";
-	case 5:
-		return "576K(Rambo)";
-	case 6:
-		return "1MB";
-	case 7:
-		return "4MB";
-	}*/
-}
-
-/*
-int settings()
-{
-	struct joystick_status joy;
-	joy.x_ = joy.y_ = joy.fire_ = 0;
-
-	int row = 0;
-
-	int done = 0;
-	for (;!done;)
-	{
-		// Render
-		clearscreen();
-		debug_pos = 0;
-		debug_adjust = 0;
-		printf("Se");
-		debug_adjust = 128;
-		printf("ttings");
-		debug_pos = 80;
-		debug_adjust = row==0 ? 128 : 0;
-		printf("Turbo:%dx", get_turbo_6502());
-		debug_pos = 120;
-		debug_adjust = row==1 ? 128 : 0;
-		printf("Ram:%s", get_ram());
-		debug_pos = 160;
-		debug_adjust = row==2 ? 128 : 0;
-		{
-			printf("Rom:%s", file_name(files[5]));
-		}
-		debug_pos = 240;
-		int i;
-		for (i=1;i!=5;++i)
-		{
-			int temp = debug_pos;
-			debug_adjust = row==i+2 ? 128 : 0;
-			char buffer[20];
-			describe_disk(i-1,&buffer[0]);
-			printf("Drive %d:%s %s", i, file_name(files[i-1]), &buffer[0]);
-			debug_pos = temp+40;
-		}
-
-		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
-		wait_us(100000);
-
-		// move
-		joystick_wait(&joy,WAIT_QUIET);
-		joystick_wait(&joy,WAIT_EITHER);
-
-		row+=joy.y_;
-		if (row<0) row = 0;
-		if (row>8) row = 8;
-		switch (row)
-		{
-		case 0:
-			{
-				int turbo = get_turbo_6502();
-				if (joy.x_==1) turbo<<=1;
-				if (joy.x_==-1) turbo>>=1;
-				if (turbo>16) turbo = 16;
-				if (turbo<1) turbo = 1;
-				set_turbo_6502(turbo);
-			}
-			break;
-		case 1:
-			{
-				int ram_select = get_ram_select();
-				ram_select+=joy.x_;
-				if (ram_select<0) ram_select = 0;
-				if (ram_select>7) ram_select = 7;
-				set_ram_select(ram_select);
-			}
-			break;
-		case 2:
-			{
-				if (joy.x_ || joy.fire_)
-				{
-					filter = filter_roms;
-					file_selector(files[5]);
-					loadosrom();
-				}
-			}
-			break;
-		case 3:
-		case 4:
-		case 5:
-		case 6:
-			{
-				if (joy.x_>0)
-				{
-					// Choose new disk
-					filter = filter_disks;
-					file_selector(files[row-3]);
-					set_drive_status(row-3,files[row-3]);
-				}
-				else if(joy.x_<0)
-				{
-					// Remove disk
-					file_init(files[row-3]);
-					set_drive_status(row-3,0);
-				}
-				else if (joy.fire_)
-				{
-					{
-						// Swap files
-						struct SimpleFile * temp = files[row-3];
-						files[row-3] = files[0];
-						files[0] = temp;
-					}
-
-					{
-						// Swap disks
-						struct SimpleFile * temp = get_drive_status(row-3);
-						set_drive_status(row-3, get_drive_status(0));
-						set_drive_status(0,temp);
-					}
-				}
-			}
-			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;
-			}
-			break;
-		}
-	}
-
-	return 0;
-}
-*/
-
-void actions()
-{
-	// Show some activity!
-	//*atari_colbk = *atari_random;
-	
-	// Hot keys
-/*	if (get_hotkey_softboot())
-	{
-		reboot(0);	
-	}
-	else */if (get_hotkey_coldboot())
-	{
-		reboot(1);	
-	}
-/*	else if (get_hotkey_settings())
-	{
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-		int do_reboot = settings();
-		debug_pos = -1;
-		restore();
-		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();
-		set_drive_status(0,files[0]);
-		reboot(1);
-*/
-
-	disk_debug();
-	}
-}
-
-
Index: firmware_5200/native/spi.c
===================================================================
--- firmware_5200/native/spi.c	(revision 191)
+++ firmware_5200/native/spi.c	(nonexistent)
@@ -1,58 +0,0 @@
-#include "spi.h"
-
-#include "integer.h"
-
-#include <stdio.h>
-
-int spi_slow; // 1 is slow
-int spi_chip_select_n; // 0 is selected
-int display;
-
-// access routines
-void setSpiFast()
-{
-	fprintf(stderr,"SPI:Fast\n");
-}
-
-void setSpiSlow()
-{
-	fprintf(stderr,"SPI:Slow\n");
-}
-
-void set_spi_clock_freq() // avr handles spi clock?
-{
-	setSpiFast();
-}
-
-void spiInit()
-{
-	fprintf(stderr,"SPI:Init Slow,deselect\n");
-}
-
-void mmcChipSelect(int select)
-{
-	spi_chip_select_n = !select;
-	fprintf(stderr,"SPI:%s\n",select? "Select":"deselect");
-}
-
-u08 spiTransferByte(u08 data)
-{
-	fprintf(stderr,"SPI:Send:%02x\n",data);
-
-	return 0xff; // TODO...
-}
-
-u08 spiTransferFF()
-{
-	return spiTransferByte(0xFF);
-}
-
-void spiReceiveData(u08 * from, u08 * to)
-{
-	while (from!=to)
-	{
-		*from = spiTransferFF();
-		++from;
-	}
-}
-
Index: firmware_5200/native/uart.c
===================================================================
--- firmware_5200/native/uart.c	(revision 191)
+++ firmware_5200/native/uart.c	(nonexistent)
@@ -1,57 +0,0 @@
-#include "uart.h"
-
-#include <stdio.h>
-
-char native_command;
-
-char receive_buffer[1024*1024];
-int receive_buffer_pos=0;
-int receive_buffer_last=0;
-
-void USART_Init( u08 value )
-{
-	fprintf(stderr, "USART_Init:%d\n",value);
-}
-
-void USART_Transmit_Byte( unsigned char data )
-{
-	fprintf(stderr, "USART_Transmit:%02x\n", data);
-}
-
-unsigned char USART_Receive_Byte( void )
-{
-	unsigned char res = receive_buffer[receive_buffer_pos++];
-	fprintf(stderr, "USART_Receive:%02x\n",res);
-	return res;
-}
-
-int USART_Data_Ready()
-{
-	return 0;
-}
-
-void USART_Transmit_Mode()
-{
-	fprintf(stderr,"USART_Transmit mode\n");
-}
-
-void USART_Receive_Mode()
-{
-	fprintf(stderr,"USART_Receive mode\n");
-}
-
-int USART_Framing_Error()
-{
-	return 0;
-}
-
-void USART_Wait_Transmit_Complete()
-{
-	return;
-}
-
-int USART_Command_Line()
-{
-	return native_command;
-}
-
Index: firmware_5200/native/mmc.c
===================================================================
--- firmware_5200/native/mmc.c	(revision 191)
+++ firmware_5200/native/mmc.c	(nonexistent)
@@ -1,57 +0,0 @@
-#include "mmc.h"
-
-#include <stdio.h>
-
-FILE * disk_image;
-char mmc_sector_buffer[512];
-
-void set_spi_clock_freq()
-{
-}
-
-//! Initialize AVR<->MMC hardware interface.
-/// Prepares hardware for MMC access.
-
-void mmc_init()
-{
-	mmcInit();
-}
-
-void mmcInit(void)
-{
-	//disk_image = fopen("/home/markw/fpga/sd_images/sd.image","r+");
-	//disk_image = fopen("/home/markw/fpga/sd_images/sd_large.image","r+");
-	//disk_image = fopen("/home/markw/fpga/sd_images/sdimage_elektraglide","r+");
-	disk_image = fopen("/home/markw/fpga/sd_images/sdimage_mist","r+");
-
-	fprintf(stderr,"mmcInit:%x\n",disk_image);
-}
-
-//! Initialize the card and prepare it for use.
-/// Returns zero if successful.
-u08 mmcReset(void){ return 0;}
-
-//! Read 512-byte sector from card to buffer
-/// Returns zero if successful.
-u08 mmcRead(u32 sector)
-{
-	//fprintf(stderr,"mmcRead:%x\n",sector);
-
-	fseek(disk_image, sector*512, SEEK_SET);
-	fread(&mmc_sector_buffer,512,1,disk_image);
-
-	return 0;
-}
-
-//! Write 512-byte sector from buffer to card
-/// Returns zero if successful.
-u08 mmcWrite(u32 sector)
-{
-	fprintf(stderr,"mmcWrite:%x\n",sector);
-
-	fseek(disk_image, sector*512, SEEK_SET);
-	fwrite(&mmc_sector_buffer,512,1,disk_image);
-
-	return 0;
-}
-
Index: firmware_5200/native/diskio_mmc.c
===================================================================
--- firmware_5200/native/diskio_mmc.c	(revision 191)
+++ firmware_5200/native/diskio_mmc.c	(nonexistent)
@@ -1 +0,0 @@
-link ../sd_direct/diskio_mmc.c
\ No newline at end of file

Property changes on: firmware_5200/native/diskio_mmc.c
___________________________________________________________________
Deleted: svn:special
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/native/joystick.c
===================================================================
--- firmware_5200/native/joystick.c	(revision 191)
+++ firmware_5200/native/joystick.c	(nonexistent)
@@ -1,116 +0,0 @@
-#include "joystick.h"
-#include <poll.h>
-#include <termios.h>
-#include <unistd.h>
-
-extern char native_porta;
-extern char native_trig;
-
-struct termios oldt, newt;
-void term_init()
-{
-	tcgetattr(STDIN_FILENO, &oldt);
-	newt = oldt;
-	newt.c_lflag &= ~( ICANON | ECHO );
-	tcsetattr( STDIN_FILENO, TCSANOW, &newt);
-}
-
-void term_close()
-{
-	tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
-}
-
-void read_keys()
-{
-	struct pollfd fds[1];
-	fds[0].fd = STDIN_FILENO;
-	fds[0].events = POLLIN;
-	native_porta = 0xff;
-	native_trig = 0xff;
-	while (poll(&fds[0], 1, 0))
-	{
-		char buffer[0];
-		read(0,&buffer[0],1);
-
-	/*	if (buffer[0] == 0x41) fprintf(stderr, "UP\n");
-		if (buffer[0] == 0x42) fprintf(stderr, "DOWN\n");
-		if (buffer[0] == 0x44) fprintf(stderr, "LEFT\n");
-		if (buffer[0] == 0x43) fprintf(stderr, "RIGHT\n");
-		if (buffer[0] == 0x20) fprintf(stderr, "FIRE\n");*/
-
-		// RLDU
-		if (buffer[0] == 0x41) native_porta=0xff&~(1<<0);
-		if (buffer[0] == 0x42) native_porta=0xff&~(1<<1);
-		if (buffer[0] == 0x44) native_porta=0xff&~(1<<2);
-		if (buffer[0] == 0x43) native_porta=0xff&~(1<<3);
-		if (buffer[0] == 0x20) native_trig=0xff&~1;
-
-		fds[0].fd = STDIN_FILENO;
-		fds[0].events = POLLIN;
-	}
-}
-
-#include "regs.h"
-
-void joystick_poll(struct joystick_status * status)
-{
-	static int first = 1;
-	if (first)
-	{
-		first = 0;
-		term_init();
-	}
-
-	read_keys();
-
-	status->x_ = 0;
-	status->y_ = 0;
-	status->fire_ = 0;
-
-	unsigned char porta = *atari_porta;
-	if (0==(porta&0x2)) // down
-	{
-		status->y_ =1;
-	}
-	else if (0==(porta&0x1)) // up
-	{
-		status->y_ =-1;
-	}
-	if (0==(porta&0x8)) // right
-	{
-		status->x_ = 1;
-	}
-	else if (0==(porta&0x4)) // left
-	{
-		status->x_ = -1;
-	}
-	if (0==(1&*atari_trig0)) // fire
-	{
-		status->fire_ = 1;
-	}
-}
-
-void joystick_wait(struct joystick_status * status, enum JoyWait waitFor)
-{
-	while (1)
-	{
-		joystick_poll(status);
-		switch (waitFor)
-		{
-		case WAIT_QUIET:
-			if (status->x_ == 0 && status->y_ == 0 && status->fire_ == 0) return;
-			break;
-		case WAIT_FIRE:
-			if (status->fire_ == 1) return;
-			break;
-		case WAIT_EITHER:
-			if (status->fire_ == 1) return;
-			// fall through
-		case WAIT_MOVE:
-			if (status->x_ != 0 || status->y_ != 0) return;
-			break;
-		}
-	}
-}
-
-
Index: firmware_5200/native/screen.c
===================================================================
--- firmware_5200/native/screen.c	(revision 191)
+++ firmware_5200/native/screen.c	(nonexistent)
@@ -1,4 +0,0 @@
-void clearscreen()
-{
-}
-
Index: firmware_5200/native/regs.c
===================================================================
--- firmware_5200/native/regs.c	(revision 191)
+++ firmware_5200/native/regs.c	(nonexistent)
@@ -1,8 +0,0 @@
-#include "regs.h"
-
-char native_porta;
-char native_trig;
-
-unsigned char volatile * atari_porta = (unsigned char volatile *)&native_porta;
-unsigned char volatile * atari_trig0 = (unsigned char volatile *)&native_trig;
-
Index: firmware_5200/native/mmc.h
===================================================================
--- firmware_5200/native/mmc.h	(revision 191)
+++ firmware_5200/native/mmc.h	(nonexistent)
@@ -1 +0,0 @@
-link ../sd_direct/mmc.h
\ No newline at end of file

Property changes on: firmware_5200/native/mmc.h
___________________________________________________________________
Deleted: svn:special
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/test_sd.c
===================================================================
--- firmware_5200/test_sd.c	(revision 191)
+++ firmware_5200/test_sd.c	(nonexistent)
@@ -1,60 +0,0 @@
-
-#include "simpledir.h"
-#include "simplefile.h"
-#include "fileselector.h"
-
-//#include "fat/pff_file.h"
-// XXX - BEST NOT to include this?
-char USER_DIR[]="/";
-char ROM_DIR[]="/";
-
-#include "stdio.h"
-#include "stdlib.h"
-
-int debug_pos = 0;
-int prev_debug_pos = 0;
-int debug_adjust = 0;
-void wait_us(int us)
-{
-	usleep(us);
-}
-
-void char_out ( void* p, char c)
-{
-	if (debug_pos!=prev_debug_pos)
-	{
-		fprintf(stderr,"\n");
-	}
-	//fprintf(stderr,"\n%dWTFWTF\n", debug_pos);
-	if (debug_adjust == 128)
-	{
-		putc('*',stderr);
-	}
-	putc(c, stderr);
-	++debug_pos;
-	prev_debug_pos = debug_pos;
-}
-int main(void)
-{
-	init_printf(NULL, char_out);
-
-	char * mem = (char *)malloc(65536);
-	if (SimpleFile_OK != dir_init(mem, 65536))
-	{
-		fprintf(stderr,"Failed to open dir!");
-		return -1;
-	}
-	struct SimpleDirEntry * entry = dir_entries("");
-	while (entry)
-	{
-		fprintf(stderr, "Path:%s", dir_path(entry));
-		fprintf(stderr, " Name:%s", dir_filename(entry));
-		fprintf(stderr, " Size:%d", dir_filesize(entry));
-		fprintf(stderr, " Subdir:%d\n", dir_is_subdir(entry));
-
-		entry = dir_next(entry);
-	}
-
-	fprintf(stderr,"\n\n");
-}
-
Index: firmware_5200/defunct/led.c
===================================================================
--- firmware_5200/defunct/led.c	(revision 191)
+++ firmware_5200/defunct/led.c	(nonexistent)
@@ -1,20 +0,0 @@
-#include "led.h"
-
-#include "regs.h"
-
-void set_green_led(int i)
-{
-	*zpu_ledg = i;
-}
-void set_red_led(int i)
-{
-	*zpu_ledr = i;
-}
-void set_drive_number(int i)
-{
-	*zpu_hex = i;
-}
-void init_display()
-{
-	*zpu_hex = 0;
-}
Index: firmware_5200/defunct/stuff.c
===================================================================
--- firmware_5200/defunct/stuff.c	(revision 191)
+++ firmware_5200/defunct/stuff.c	(nonexistent)
@@ -1,13 +0,0 @@
-#include "regs.h"
-#include "regs.c"
-#include "main.c"
-#include "fat.c" 
-#include "SDrive.c"
-#include "mmc.c"
-#include "spi.c"
-#include "uart.c"
-#include "led.c"
-#include "pind.c" 
-#include "eeprom.c"
-#include "pause.c"
-
Index: firmware_5200/defunct/led.h
===================================================================
--- firmware_5200/defunct/led.h	(revision 191)
+++ firmware_5200/defunct/led.h	(nonexistent)
@@ -1,10 +0,0 @@
-#ifndef LEDS_H
-#define LEDS_H
-
-void set_green_led(int i);
-void set_red_led(int i);
-void set_drive_number(int i);
-void init_display();
-
-#endif
-
Index: firmware_5200/defunct/types.h
===================================================================
--- firmware_5200/defunct/types.h	(revision 191)
+++ firmware_5200/defunct/types.h	(nonexistent)
@@ -1,13 +0,0 @@
-#ifndef types_h
-#define types_h
-
-typedef unsigned char u08;
-typedef unsigned char uint8_t;
-typedef unsigned short u16;
-typedef unsigned int u32;
-
-#define EEMEM
-
-#endif
-
-
Index: firmware_5200/defunct/chksum.c
===================================================================
--- firmware_5200/defunct/chksum.c	(revision 191)
+++ firmware_5200/defunct/chksum.c	(nonexistent)
@@ -1,40 +0,0 @@
-unsigned char abuffer[] = {
-0x00,0x03,0x00,0x07,0x14,0x07,0x4c,0x14,0x07,0x74,0x0d,0x00,0x00,0xa9,0x46,0x8d
-,0xc6,0x02,0xd0,0xfe,0xa0,0x00,0xa9,0x6b,0x91,0x58,0x20,0xd9,0x07,0xb0,0xee,0x20
-,0xc4,0x07,0xad,0x7a,0x08,0x0d,0x76,0x08,0xd0,0xe3,0xa5,0x80,0x8d,0xe0,0x02,0xa5
-,0x81,0x8d,0xe1,0x02,0xa9,0x00,0x8d,0xe2,0x02,0x8d,0xe3,0x02,0x20,0xeb,0x07,0xb0
-,0xcc,0xa0,0x00,0x91,0x80,0xa5,0x80,0xc5,0x82,0xd0,0x06,0xa5,0x81,0xc5,0x83,0xf0
-,0x08,0xe6,0x80,0xd0,0x02,0xe6,0x81,0xd0,0xe3,0xad,0x76,0x08,0xd0,0xaf,0xad,0xe2
-,0x02,0x8d,0x70,0x07,0x0d,0xe3,0x02,0xf0,0x0e,0xad,0xe3,0x02,0x8d,0x71,0x07,0x20
-,0xff,0xff,0xad,0x7a,0x08,0xd0,0x13,0xa9,0x00,0x8d,0xe2,0x02,0x8d,0xe3,0x02,0x20
-};
-
-
-unsigned char buffer[] = {
-0x98,0xff,0xe0,0x00
-};
-
-typedef unsigned short u16;
-typedef unsigned char u08;
-
-unsigned char get_checksum(unsigned char* buffer, u16 len)
-{
-        u16 i;
-        u08 sumo,sum;
-        sum=sumo=0;
-        for(i=0;i<len;i++)
-        {
-                sum+=buffer[i];
-                if(sum<sumo) sum++;
-                sumo = sum;
-        }
-        return sum;
-}
-
-int main(void)
-{
-	int res = get_checksum(buffer,sizeof(buffer));
-	printf("%x %d\n",res,sizeof(buffer));
-	return 0;
-}
-
Index: firmware_5200/defunct/fat.c
===================================================================
--- firmware_5200/defunct/fat.c	(revision 191)
+++ firmware_5200/defunct/fat.c	(nonexistent)
@@ -1,445 +0,0 @@
-/*! \file fat.c \brief FAT16/32 file system driver. */
-//*****************************************************************************
-//
-// File Name	: 'fat.c'
-// Title		: FAT16/32 file system driver
-// Author		: Pascal Stang
-// Date			: 11/07/2000
-// Revised		: 12/12/2000
-// Version		: 0.3
-// Target MCU	: ATmega103 (should work for Atmel AVR Series)
-// Editor Tabs	: 4
-//
-// This code is based in part on work done by Jesper Hansen for his
-//		YAMPP MP3 player project.
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-#include <stdio.h>
-#include <string.h>
-
-#include "fat.h"
-#include "mmc.h"
-#include "spi.h"
-
-void USART_SendString(char *buff);
-void mmcReadCached(u32 sector);
-
-
-#define FileNameBuffer atari_sector_buffer
-extern unsigned char atari_sector_buffer[256];
-extern unsigned char mmc_sector_buffer[512];	// one sector
-extern struct GlobalSystemValues GS;
-extern struct FileInfoStruct FileInfo;			//< file information for last file accessed
-
-
-unsigned long fatClustToSect(unsigned short clust)
-{
-	u32 ret;
-	if(clust==MSDOSFSROOT)
-	{
-		debug("fatClustToSect:");
-		u32 res = (u32)((u32)(FirstDataSector) - (u32)(RootDirSectors));
-		plotnextnumber(res);
-		debug(" ");
-		plotnextnumber(FirstDataSector);
-		debug(" ");
-		plotnextnumber(RootDirSectors);
-		debug("\n");
-		return res;
-	}
-	
-	ret = (u32)(clust-2);
-	ret *= (u32)SectorsPerCluster;
-	ret += (u32)FirstDataSector;
-	return ((unsigned long)ret);
-}
-
-
-//POZOR - DEBUG !!!
-//prvne definovana promenna
-u32 debug_endofvariables;		//promenna co je v pameti jako posledni (za ni je uz jen stack)
-//POZOR - DEBUG !!!
-
-unsigned short last_dir_start_cluster;
-unsigned char last_dir_valid;
-unsigned short last_dir_entry;
-unsigned long last_dir_sector;
-unsigned char last_dir_sector_count;
-unsigned short last_dir_cluster;
-unsigned char last_dir_index;
-
-
-unsigned char fatInit()
-{
-	struct partrecord PartInfo;
-	struct bpb710 *bpb;
-
-	// Moved here since init vars are in ROM!
-	last_dir_entry=0x0;
-	last_dir_sector=0;
-	last_dir_sector_count=0;
-	last_dir_cluster=0;
-	last_dir_index=0;
-
-	// read partition table
-	// TODO.... error checking
-	debug("FAT INIT:");
-	mmcReadCached(0);
-	// map first partition record	
-	// save partition information to global PartInfo
-	PartInfo = *((struct partrecord *) ((struct partsector *) (char*)mmc_sector_buffer)->psPart);
-
-	if(mmc_sector_buffer[0x36]=='F' && mmc_sector_buffer[0x37]=='A' && mmc_sector_buffer[0x38]=='T' && mmc_sector_buffer[0x39]=='1' && mmc_sector_buffer[0x3a]=='6')
-	{
-		PartInfo.prPartType = PART_TYPE_FAT16LBA; //0x04
-		PartInfo.prStartLBA = 0x00;
-	}
-	
-	// Read the Partition BootSector
-	// **first sector of partition in PartInfo.prStartLBA
-	mmcReadCached(PartInfo.prStartLBA);
-	bpb = (struct bpb710 *) ((struct bootsector710 *) (char*)mmc_sector_buffer)->bsBPB;
-
-	// setup global disk constants
-	PartInfo.prStartLBA = 0x1e8; // FIXME
-	FirstDataSector	= PartInfo.prStartLBA;
-
-	RootDirSectors = bpb->bpbRootDirEnts>>4; // /16 ; 512/16 = 32  (sector size / max entries in one sector = number of sectors)
-
-	debug("PartInto ");
-	plotnextnumber(PartInfo.prStartLBA);
-	debug(" ");
-	plotnextnumber(bpb->bpbRootDirEnts>>4);
-	debug("\n");
-
-	// bpbFATsecs is non-zero and is therefore valid
-	FirstDataSector	+= bpb->bpbResSectors + bpb->bpbFATs * bpb->bpbFATsecs + RootDirSectors;
-
-	SectorsPerCluster	= bpb->bpbSecPerClust;
-	BytesPerSector		= bpb->bpbBytesPerSec;
-	FirstFATSector		= bpb->bpbResSectors + PartInfo.prStartLBA;
-
-	// set current directory to root (\)
-	FileInfo.vDisk.dir_cluster = MSDOSFSROOT; //RootDirStartCluster;
-
-    last_dir_start_cluster=0xffff;
-	//last_dir_valid=0;		//<-- neni potreba, protoze na zacatku fatGetDirEntry se pri zjisteni
-							//ze je (FileInfo.vDisk.dir_cluster!=last_dir_start_cluster)
-							//vynuluje last_dir_valid=0;
-
-	if (   PartInfo.prPartType==PART_TYPE_DOSFAT16
-		|| PartInfo.prPartType==PART_TYPE_FAT16
-		|| PartInfo.prPartType==PART_TYPE_FAT16LBA
-	   )
-	{
-		return 1; //je to ok
-		debug("OK\n");
-	}
-	else
-	{
-		return 0; //neni to zadny filesystem co umime
-		debug("FAIL\n");
-	}
-}
-
-//////////////////////////////////////////////////////////////
-
-unsigned char fatGetDirEntry(unsigned short entry, unsigned char use_long_names)
-{
-	unsigned long sector;
-	struct direntry *de = 0;	// avoid compiler warning by initializing
-	struct winentry *we;
-	unsigned char haveLongNameEntry;
-	unsigned char gotEntry;
-	unsigned short b;
-	u08 index;
-	unsigned short entrycount = 0;
-	unsigned short actual_cluster = FileInfo.vDisk.dir_cluster;
-	unsigned char seccount=0;
-
-	haveLongNameEntry = 0;
-	gotEntry = 0;
-
-	if (FileInfo.vDisk.dir_cluster!=last_dir_start_cluster)
-	{
-		//zmenil se adresar, takze musi pracovat s nim
-		//a zneplatnit last_dir polozky
-		last_dir_start_cluster=FileInfo.vDisk.dir_cluster;
-		last_dir_valid=0;
-
-		debug("LastDirStartCluster:");
-		plotnextnumber(last_dir_start_cluster);
-		plotnextnumber(last_dir_valid);
-		debug("\n");
-	}
-
-	if ( !last_dir_valid
-		 || (entry<=last_dir_entry && (entry!=last_dir_entry || last_dir_valid!=1 || use_long_names!=0))
-	   )
-	{
-		//musi zacit od zacatku
-		sector = fatClustToSect(FileInfo.vDisk.dir_cluster);
-		//index = 0;
-		debug("ReadFromBegin:");
-		plotnextnumber(sector);
-		debug("\n");
-		goto fat_read_from_begin;
-	}
-	else
-	{
-		//muze zacit od posledne pouzite
-		entrycount=last_dir_entry;
-		index = last_dir_index;
-		sector=last_dir_sector;
-		actual_cluster=last_dir_cluster;
-		seccount = last_dir_sector_count;
-		debug("ReadFromLastEntry:");
-		plotnextnumber(sector);
-		debug("\n");
-		goto fat_read_from_last_entry;
-	}
-
-	while(1)
-	{
-		debug("Index:");
-		plotnextnumber(index);
-		debug("\n");
-		if(index==16)	// time for next sector ?
-		{
-			if ( actual_cluster==MSDOSFSROOT )
-			{
-				//v MSDOSFSROOT se nerozlisuji clustery
-				//protoze MSDOSFSROOT ma sektory stale dal za sebou bez clusterovani
-				if (seccount>=RootDirSectors) return 0; //prekrocil maximalni pocet polozek v MSDOSFSROOT
-			}
-			else //MUSI BYT!!! (aby neporovnaval seccount je-li actual_cluster==MSDOSFSROOT)
-			if( seccount>=SectorsPerCluster )
-			{
-				//next cluster
-				//pri prechodu pres pocet sektoru v clusteru
-				actual_cluster = nextCluster(actual_cluster);
-				sector=fatClustToSect(actual_cluster);
-				seccount=0;
-			}
-fat_read_from_begin:
-			index = 0;
-			seccount++;		//ted bude nacitat dalsi sektor (musi ho zapocitat)
-fat_read_from_last_entry:
-			mmcReadCached( sector++ ); 	//prave ho nacetl
-			de = (struct direntry *) (char*)mmc_sector_buffer;
-			de+=index;
-		}
-		
-		// check the status of this directory entry slot
-		if(de->deName[0] == 0x00) //SLOT_EMPTY
-		{
-			// slot is empty and this is the end of directory
-			gotEntry = 0;
-			break;
-		}
-		else if(de->deName[0] == 0xE5)	//SLOT_DELETED
-		{
-			// this is an empty slot
-			// do nothing and move to the next one
-		}
-		else
-		{
-			// this is a valid and occupied entry
-			// is it a part of a long file/dir name?
-			if( de->deAttributes==ATTR_LONG_FILENAME )
-			{
-				// we have a long name entry
-				// cast this directory entry as a "windows" (LFN: LongFileName) entry
-				u08 i;
-				unsigned char *fnbPtr;
-
-				//pokud nechceme longname, NESMI je vubec kompletovat
-				//a preskoci na dalsi polozku
-				//( takze ani haveLongNameEntry nikdy nebude nastaveno na 1)
-				//Jinak by totiz preplacaval dalsi kusy atari_sector_bufferu 12-255 ! BACHA!!!
-				if (!use_long_names) goto fat_next_dir_entry;
-
-				we = (struct winentry *) de;
-				
-				b = WIN_ENTRY_CHARS*( (unsigned short)((we->weCnt-1) & 0x0f));		// index into string
-				fnbPtr = &FileNameBuffer[b];
-
-				for (i=0;i<5;i++)	*fnbPtr++ = we->wePart1[i*2];	// copy first part
-				for (i=0;i<6;i++)	*fnbPtr++ = we->wePart2[i*2];	// second part
-				for (i=0;i<2;i++)	*fnbPtr++ = we->wePart3[i*2];	// and third part
-
-				/*
-				{
-				//unsigned char * sptr;
-				//sptr=we->wePart1;
-				//do { *fnbPtr++ = *sptr++; sptr++; } while (sptr<(we->wePart1+10)); // copy first part
-				//^-- pouziti jen tohoto prvniho a druhe dva pres normalni for(..) uspori 10 bajtu,
-				//pri pouziti i dalsich dvou timto stylem uz se to ale zase prodlouzi - nechaaaaaapu!
-				//sptr=we->wePart2;
-				//do { *fnbPtr++ = *sptr++; sptr++; } while (sptr<(we->wePart2+12)); // second part
-				//sptr=we->wePart3;
-				//do { *fnbPtr++ = *sptr++; sptr++; } while (sptr<(we->wePart3+4));  // and third part
-				}
-				*/
-
-				if (we->weCnt & WIN_LAST) *fnbPtr = 0;				// in case dirnamelength is multiple of 13, add termination
-				if ((we->weCnt & 0x0f) == 1) haveLongNameEntry = 1;	// flag that we have a complete long name entry set
-			}
-			else
-			{
-				// we have a short name entry
-				
-				// check if this is the short name entry corresponding
-				// to the end of a multi-part long name entry
-				if(haveLongNameEntry)
-				{
-					// a long entry name has been collected
-					if(entrycount == entry)		
-					{
-						// desired entry has been found, break out
-						gotEntry = 2;
-						break;
-					}
-					// otherwise
-					haveLongNameEntry = 0;	// clear long name flag
-					entrycount++;			// increment entry counter		
-				}
-				else
-				{
-					// entry is a short name (8.3 format) without a
-					// corresponding multi-part long name entry
-
-					//Zcela vynecha adresar "." a disk label
-					if( (de->deName[0]=='.' && de->deName[1]==' ' && (de->deAttributes & ATTR_DIRECTORY) ) //je to "." adresar
-						|| (de->deAttributes & ATTR_VOLUME) ) goto fat_next_dir_entry;
-
-					if(entrycount == entry)
-					{
-						/*
-						fnbPtr = &FileNameBuffer[string_offset];
-						for (i=0;i<8;i++)	*fnbPtr++ = de->deName[i];		// copy name
-						for (i=0;i<3;i++)	*fnbPtr++ = de->deExtension[i];	// copy extension
-						*fnbPtr = 0;										// null-terminate
-						*/
-						u08 i;
-						unsigned char *dptr;
-
-						dptr = &FileNameBuffer;
-						for (i=0;i<11;i++)	*dptr++ = de->deName[i];		// copy name+ext
-						*dptr=0;	//ukonceni za nazvem
-
-						// desired entry has been found, break out
-						//pokud chtel longname, tak to neni a proto upravi 8+3 jmeno na nazev.ext
-						//aby to melo formatovani jako longname
-						if (use_long_names)
-						{
-							//upravi 'NAME    EXT' na 'NAME.EXT'
-							//(vyhazi mezery a prida tecku)
-							//krome nazvu '.          ', a '..         ', tam jen vyhaze mezery
-							unsigned char *sptr;
-							//EXT => .EXT   (posune vcetne 0x00 za koncem extenderu)
-							dptr=(FileNameBuffer+12);
-							i=4; do { sptr=dptr-1; *dptr=*sptr; dptr=sptr; i--; } while(i>0);
-							if (FileNameBuffer[0]!='.') *dptr='.'; //jen pro jine nez '.' a '..'
-							//NAME    .EXT => NAME.EXT
-							sptr=dptr=&FileNameBuffer;
-							do
-							{
-							 if ((*sptr)!=' ') *dptr++=*sptr;
-							 sptr++;
-							} while (*sptr);
-							*dptr=0; //ukonceni
-						}
-						//
-						gotEntry = 1;
-						break;
-					}
-					// otherwise
-					entrycount++;			// increment entry counter		
-				}
-			}
-		}
-fat_next_dir_entry:
-		// next directory entry
-		de++;
-		// next index
-		index++;
-	}
-	
-	// we have a file/dir to return
-	// store file/dir starting cluster (start of data)
-	FileInfo.vDisk.start_cluster = (unsigned short) (de->deStartCluster);
-	// fileindex
-	FileInfo.vDisk.file_index = entry;	//fileindex teto polozky
-	// store file/dir size (note: size field for subdirectory entries is always zero)
-	FileInfo.vDisk.size = de->deFileSize;
-	// store file/dir attributes
-	FileInfo.Attr = de->deAttributes;
-	// store file/dir last update time
-	FileInfo.Time = (unsigned short) (de->deMTime[0] | de->deMTime[1]<<8);
-	// store file/dir last update date
-	FileInfo.Date = (unsigned short) (de->deMDate[0] | de->deMDate[1]<<8);
-
-	if(gotEntry)
-	{
-		debug(" gotEntry ");
-		last_dir_entry = entrycount;
-		last_dir_index = index;
-		last_dir_sector = sector-1; //protoze ihned po nacteni se posune
-		last_dir_cluster = actual_cluster;
-		last_dir_sector_count = seccount; //skace se az za inkrementaci seccount, takze tady se 1 neodecita!
-		last_dir_valid=gotEntry;
-	}
-	else
-	{
-		debug(" not gotEntry ");
-	}
-
-	return gotEntry;
-}
-
-
-unsigned short nextCluster(unsigned short cluster)
-{
-	  unsigned short nextCluster;
-	  unsigned long fatOffset;
-	  unsigned long sector;
-	  unsigned long offset;
-
-	  // two FAT bytes (16 bits) for every cluster
-	  fatOffset = ((u32)cluster) << 1;
-
-	  // calculate the FAT sector that we're interested in
-	  sector = FirstFATSector + (fatOffset / ((u32)BytesPerSector));
-	  // calculate offset of the our entry within that FAT sector
-	  offset = fatOffset % ((u32)BytesPerSector);
-
-	  // if we don't already have this FAT chunk loaded, go get it
-	  // read sector of FAT table
-  	  mmcReadCached( sector );
-
-	  // read the nextCluster value
-	  nextCluster = (*((unsigned short*) &((char*)mmc_sector_buffer)[offset])) & FAT16_MASK;
-
-	  // check to see if we're at the end of the chain
-	  if (nextCluster == (CLUST_EOFE & FAT16_MASK))
-		nextCluster = 0;
-
-	return (nextCluster&0xFFFF);
-}
Index: firmware_5200/defunct/mt6502dis
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: firmware_5200/defunct/mt6502dis
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: firmware_5200/defunct/fat.h
===================================================================
--- firmware_5200/defunct/fat.h	(revision 191)
+++ firmware_5200/defunct/fat.h	(nonexistent)
@@ -1,435 +0,0 @@
-/*! \file fat.h \brief FAT16/32 file system driver. */
-//*****************************************************************************
-//
-// File Name	: 'fat.h'
-// Title		: FAT16/32 file system driver
-// Author		: Pascal Stang
-// Date			: 11/07/2000
-// Revised		: 12/12/2000
-// Version		: 0.3
-// Target MCU	: ATmega103 (should work for Atmel AVR Series)
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-///	\ingroup general
-/// \defgroup fat FAT16/32 File System Interface (fat.c)
-/// \code #include "fat.h" \endcode
-/// \par Overview
-///		This FAT16/32 interface allows you to detect and mount FAT16/32
-///		partitions, browse directories and files, and read file data.
-///		The interface is designed to operate with the avrlib IDE/ATA driver.
-///		Reading FAT efficiently requires at least 512+ bytes of RAM so this
-///		interface may not be suitable for processors with less than 1K of RAM.
-///		This interface will properly follow a file's cluster chain so files
-///		need not be defragmented.
-///
-/// \note This code is based in part on work done by Jesper Hansen for his
-///		excellent YAMPP MP3 player project.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-#ifndef FAT_H
-#define FAT_H
-
-#define FALSE 0
-#define TRUE -1
-
-#define DRIVE0 1
-
-// Some useful cluster numbers
-#define MSDOSFSROOT     0		// cluster 0 means the root dir
-#define CLUST_FREE      0               // cluster 0 also means a free cluster
-#define MSDOSFSFREE     CLUST_FREE
-#define CLUST_FIRST     2               // first legal cluster number
-#define CLUST_RSRVD     0xfffffff6      // reserved cluster range
-#define CLUST_BAD       0xfffffff7      // a cluster with a defect
-#define CLUST_EOFS      0xfffffff8      // start of eof cluster range
-#define CLUST_EOFE      0xffffffff      // end of eof cluster range
-
-#define FAT12_MASK      0x00000fff      // mask for 12 bit cluster numbers
-#define FAT16_MASK      0x0000ffff      // mask for 16 bit cluster numbers
-#define FAT32_MASK      0x0fffffff      // mask for FAT32 cluster numbers
-
-
-// Partition Type used in the partition record
-#define PART_TYPE_UNKNOWN		0x00
-#define PART_TYPE_FAT12			0x01
-#define PART_TYPE_XENIX			0x02
-#define PART_TYPE_DOSFAT16		0x04
-#define PART_TYPE_EXTDOS		0x05
-#define PART_TYPE_FAT16			0x06
-#define PART_TYPE_NTFS			0x07
-#define PART_TYPE_FAT32			0x0B
-#define PART_TYPE_FAT32LBA		0x0C
-#define PART_TYPE_FAT16LBA		0x0E
-#define PART_TYPE_EXTDOSLBA		0x0F
-#define PART_TYPE_ONTRACK		0x33
-#define PART_TYPE_NOVELL		0x40
-#define PART_TYPE_PCIX			0x4B
-#define PART_TYPE_PHOENIXSAVE	0xA0
-#define PART_TYPE_CPM			0xDB
-#define PART_TYPE_DBFS			0xE0
-#define PART_TYPE_BBT			0xFF
-
-struct partrecord // length 16 bytes
-{			
-	unsigned char	prIsActive;					// 0x80 indicates active partition
-	unsigned char	prStartHead;				// starting head for partition
-	unsigned short	prStartCylSect;				// starting cylinder and sector
-	unsigned char	prPartType;					// partition type (see above)
-	unsigned char	prEndHead;					// ending head for this partition
-	unsigned short	prEndCylSect;				// ending cylinder and sector
-	unsigned long	prStartLBA;					// first LBA sector for this partition
-	unsigned long	prSize;						// size of this partition (bytes or sectors ?)
-};
-
-        
-struct partsector
-{
-	unsigned char	psPartCode[512-64-2];		// pad so struct is 512b
-	unsigned char	psPart[64];					// four partition records (64 bytes)
-	unsigned char	psBootSectSig0;				// two signature bytes (2 bytes)
-	unsigned char	psBootSectSig1;
-#define BOOTSIG0        0x55
-#define BOOTSIG1        0xaa
-};
-
-
-// Format of a boot sector.  This is the first sector on a DOS floppy disk
-// or the first sector of a partition on a hard disk.  But, it is not the
-// first sector of a partitioned hard disk.
-struct bootsector33 {
-	unsigned char 	bsJump[3];					// jump inst E9xxxx or EBxx90
-	unsigned char	bsOemName[8];				// OEM name and version
-	unsigned char	bsBPB[19];					// BIOS parameter block
-	unsigned char	bsDriveNumber;				// drive number (0x80)
-	unsigned char	bsBootCode[479];			// pad so struct is 512b
-	unsigned char	bsBootSectSig0;				// boot sector signature byte 0x55
-	unsigned char	bsBootSectSig1;				// boot sector signature byte 0xAA
-#define BOOTSIG0        0x55
-#define BOOTSIG1        0xaa
-};
-
-struct extboot {
-	unsigned char	exDriveNumber;				// drive number (0x80)
-	unsigned char	exReserved1;				// reserved
-	unsigned char	exBootSignature;			// ext. boot signature (0x29)
-#define EXBOOTSIG       0x29
-	unsigned char	exVolumeID[4];				// volume ID number
-	unsigned char	exVolumeLabel[11];			// volume label
-	unsigned char	exFileSysType[8];			// fs type (FAT12 or FAT16)
-};
-
-struct bootsector50 {
-	unsigned char	bsJump[3];					// jump inst E9xxxx or EBxx90
-	unsigned char	bsOemName[8];				// OEM name and version
-	unsigned char	bsBPB[25];					// BIOS parameter block
-	unsigned char	bsExt[26];					// Bootsector Extension
-	unsigned char	bsBootCode[448];			// pad so structure is 512b
-	unsigned char	bsBootSectSig0;				// boot sector signature byte 0x55 
-	unsigned char	bsBootSectSig1;				// boot sector signature byte 0xAA
-#define BOOTSIG0        0x55
-#define BOOTSIG1        0xaa
-};
-
-struct bootsector710 {
-	unsigned char	bsJump[3];					// jump inst E9xxxx or EBxx90
-	unsigned char	bsOEMName[8];				// OEM name and version
-	unsigned char	bsBPB[53];					// BIOS parameter block
-	unsigned char	bsExt[26];					// Bootsector Extension
-	unsigned char	bsBootCode[418];			// pad so structure is 512b
-	unsigned char	bsBootSectSig2;				// 2 & 3 are only defined for FAT32?
-	unsigned char	bsBootSectSig3;
-	unsigned char	bsBootSectSig0;				// boot sector signature byte 0x55
-	unsigned char	bsBootSectSig1;				// boot sector signature byte 0xAA
-#define BOOTSIG0        0x55
-#define BOOTSIG1        0xaa
-#define BOOTSIG2        0
-#define BOOTSIG3        0
-};
-
-
-/***************************************************************/
-/***************************************************************/
-
-// BIOS Parameter Block (BPB) for DOS 3.3
-struct bpb33 {
-        unsigned short	bpbBytesPerSec; // bytes per sector
-        unsigned char    bpbSecPerClust;	// sectors per cluster
-        unsigned short	bpbResSectors;	// number of reserved sectors
-        unsigned char	bpbFATs;		// number of FATs
-        unsigned short	bpbRootDirEnts;	// number of root directory entries
-        unsigned short	bpbSectors;		// total number of sectors
-        unsigned char	bpbMedia;		// media descriptor
-        unsigned short	bpbFATsecs;     // number of sectors per FAT
-        unsigned short	bpbSecPerTrack; // sectors per track
-        unsigned short	bpbHeads;       // number of heads
-        unsigned short	bpbHiddenSecs;  // number of hidden sectors
-};
-
-// BPB for DOS 5.0
-// The difference is bpbHiddenSecs is a short for DOS 3.3,
-// and bpbHugeSectors is not present in the DOS 3.3 bpb.
-struct bpb50 {
-        unsigned short	bpbBytesPerSec; // bytes per sector
-        unsigned char	bpbSecPerClust; // sectors per cluster
-        unsigned short	bpbResSectors;  // number of reserved sectors
-        unsigned char	bpbFATs;        // number of FATs
-        unsigned short	bpbRootDirEnts; // number of root directory entries
-        unsigned short	bpbSectors;     // total number of sectors
-        unsigned char	bpbMedia;       // media descriptor
-        unsigned short	bpbFATsecs;     // number of sectors per FAT
-        unsigned short	bpbSecPerTrack; // sectors per track
-        unsigned short	bpbHeads;       // number of heads
-        unsigned long	bpbHiddenSecs;  // # of hidden sectors
-// 3.3 compat ends here
-        unsigned long	bpbHugeSectors; // # of sectors if bpbSectors == 0
-};
-
-// BPB for DOS 7.10 (FAT32)
-// This one has a few extensions to bpb50.
-struct bpb710 {
-		unsigned short	bpbBytesPerSec;	// bytes per sector
-		unsigned char	bpbSecPerClust;	// sectors per cluster
-		unsigned short	bpbResSectors;	// number of reserved sectors
-		unsigned char	bpbFATs;		// number of FATs
-		unsigned short	bpbRootDirEnts;	// number of root directory entries
-		unsigned short	bpbSectors;		// total number of sectors
-		unsigned char	bpbMedia;		// media descriptor
-		unsigned short	bpbFATsecs;		// number of sectors per FAT
-		unsigned short	bpbSecPerTrack;	// sectors per track
-		unsigned short	bpbHeads;		// number of heads
-		unsigned long	bpbHiddenSecs;	// # of hidden sectors
-// 3.3 compat ends here
-		unsigned long	bpbHugeSectors;	// # of sectors if bpbSectors == 0
-// 5.0 compat ends here
-		unsigned long     bpbBigFATsecs;// like bpbFATsecs for FAT32
-		unsigned short      bpbExtFlags;	// extended flags:
-#define FATNUM    0xf			// mask for numbering active FAT
-#define FATMIRROR 0x80			// FAT is mirrored (like it always was)
-		unsigned short      bpbFSVers;	// filesystem version
-#define FSVERS    0				// currently only 0 is understood
-		unsigned long     bpbRootClust;	// start cluster for root directory
-		unsigned short      bpbFSInfo;	// filesystem info structure sector
-		unsigned short      bpbBackup;	// backup boot sector
-		// There is a 12 byte filler here, but we ignore it
-};
-
-
-// ***************************************************************
-// * byte versions of the above structs                          *
-// ***************************************************************
-
-// BIOS Parameter Block (BPB) for DOS 3.3
-struct byte_bpb33 {
-        unsigned char bpbBytesPerSec[2];		// bytes per sector
-        unsigned char bpbSecPerClust;        // sectors per cluster
-        unsigned char bpbResSectors[2];      // number of reserved sectors
-        unsigned char bpbFATs;               // number of FATs
-        unsigned char bpbRootDirEnts[2];     // number of root directory entries
-        unsigned char bpbSectors[2];         // total number of sectors
-        unsigned char bpbMedia;              // media descriptor
-        unsigned char bpbFATsecs[2];         // number of sectors per FAT
-        unsigned char bpbSecPerTrack[2];     // sectors per track
-        unsigned char bpbHeads[2];           // number of heads
-        unsigned char bpbHiddenSecs[2];      // number of hidden sectors
-};
-
-// BPB for DOS 5.0
-// The difference is bpbHiddenSecs is a short for DOS 3.3,
-// and bpbHugeSectors is not in the 3.3 bpb.
-struct byte_bpb50 {
-        unsigned char bpbBytesPerSec[2];     // bytes per sector
-        unsigned char bpbSecPerClust;        // sectors per cluster
-        unsigned char bpbResSectors[2];      // number of reserved sectors
-        unsigned char bpbFATs;               // number of FATs
-        unsigned char bpbRootDirEnts[2];     // number of root directory entries
-        unsigned char bpbSectors[2];         // total number of sectors
-        unsigned char bpbMedia;              // media descriptor
-        unsigned char bpbFATsecs[2];         // number of sectors per FAT
-        unsigned char bpbSecPerTrack[2];     // sectors per track
-        unsigned char bpbHeads[2];           // number of heads
-        unsigned char bpbHiddenSecs[4];      // number of hidden sectors
-        unsigned char bpbHugeSectors[4];		// # of sectors if bpbSectors == 0
-};
-
-// BPB for DOS 7.10 (FAT32).
-// This one has a few extensions to bpb50.
-struct byte_bpb710 {
-        unsigned char bpbBytesPerSec[2];     // bytes per sector
-        unsigned char bpbSecPerClust;        // sectors per cluster
-        unsigned char bpbResSectors[2];      // number of reserved sectors
-        unsigned char bpbFATs;               // number of FATs
-        unsigned char bpbRootDirEnts[2];     // number of root directory entries
-        unsigned char bpbSectors[2];         // total number of sectors
-        unsigned char bpbMedia;              // media descriptor
-        unsigned char bpbFATsecs[2];         // number of sectors per FAT
-        unsigned char bpbSecPerTrack[2];     // sectors per track
-        unsigned char bpbHeads[2];           // number of heads
-        unsigned char bpbHiddenSecs[4];      // # of hidden sectors
-        unsigned char bpbHugeSectors[4];     // # of sectors if bpbSectors == 0
-        unsigned char bpbBigFATsecs[4];      // like bpbFATsecs for FAT32
-        unsigned char bpbExtFlags[2];        // extended flags:
-        unsigned char bpbFSVers[2];          // filesystem version
-        unsigned char bpbRootClust[4];       // start cluster for root directory
-        unsigned char bpbFSInfo[2];          // filesystem info structure sector
-        unsigned char bpbBackup[2];          // backup boot sector
-        // There is a 12 byte filler here, but we ignore it
-};
-
-// FAT32 FSInfo block.
-struct fsinfo {
-        unsigned char fsisig1[4];
-        unsigned char fsifill1[480];
-        unsigned char fsisig2[4];
-        unsigned char fsinfree[4];
-        unsigned char fsinxtfree[4];
-        unsigned char fsifill2[12];
-        unsigned char fsisig3[4];
-        unsigned char fsifill3[508];
-        unsigned char fsisig4[4];
-};
-
-
-// Structure of a dos directory entry.
-struct direntry {
-		unsigned char		deName[8];      // filename, blank filled
-#define SLOT_EMPTY      0x00            // slot has never been used
-#define SLOT_E5         0x05            // the real value is 0xE5
-#define SLOT_DELETED    0xE5            // file in this slot deleted
-		unsigned char		deExtension[3]; // extension, blank filled
-		unsigned char		deAttributes;   // file attributes
-#define ATTR_NORMAL     0x00            // normal file
-#define ATTR_READONLY   0x01            // file is readonly
-#define ATTR_HIDDEN     0x02            // file is hidden
-#define ATTR_SYSTEM     0x04            // file is a system file
-#define ATTR_VOLUME     0x08            // entry is a volume label
-#define ATTR_LONG_FILENAME	0x0F		// this is a long filename entry			    
-#define ATTR_DIRECTORY  0x10            // entry is a directory name
-#define ATTR_ARCHIVE    0x20            // file is new or modified
-		unsigned char        deLowerCase;    // NT VFAT lower case flags  (set to zero)
-#define LCASE_BASE      0x08            // filename base in lower case
-#define LCASE_EXT       0x10            // filename extension in lower case
-		unsigned char        deCHundredth;   // hundredth of seconds in CTime
-		unsigned char        deCTime[2];     // create time
-		unsigned char        deCDate[2];     // create date
-		unsigned char        deADate[2];     // access date
-		unsigned short        deHighClust; 	// high bytes of cluster number
-		unsigned char        deMTime[2];     // last update time
-		unsigned char        deMDate[2];     // last update date
-		unsigned short        deStartCluster; // starting cluster of file
-		unsigned long       deFileSize;  	// size of file in bytes
-};
-
-// number of directory entries in one sector
-#define DIRENTRIES_PER_SECTOR	0x10
-
-// Structure of a Win95 long name directory entry
-struct winentry {
-		unsigned char		weCnt;			// 
-#define WIN_LAST        0x40
-#define WIN_CNT         0x3f
-		unsigned char		wePart1[10];
-		unsigned char		weAttributes;
-#define ATTR_WIN95      0x0f
-		unsigned char		weReserved1;
-		unsigned char		weChksum;
-		unsigned char		wePart2[12];
-		unsigned short       	weReserved2;
-		unsigned char		wePart3[4];
-};
-
-#define WIN_ENTRY_CHARS	13      // Number of chars per winentry
-
-// Maximum filename length in Win95
-// Note: Must be < sizeof(dirent.d_name)
-#define WIN_MAXLEN      255
-
-// This is the format of the contents of the deTime field in the direntry
-// structure.
-// We don't use bitfields because we don't know how compilers for
-// arbitrary machines will lay them out.
-#define DT_2SECONDS_MASK        0x1F    // seconds divided by 2
-#define DT_2SECONDS_SHIFT       0
-#define DT_MINUTES_MASK         0x7E0   // minutes
-#define DT_MINUTES_SHIFT        5
-#define DT_HOURS_MASK           0xF800  // hours
-#define DT_HOURS_SHIFT          11
-
-// This is the format of the contents of the deDate field in the direntry
-// structure.
-#define DD_DAY_MASK				0x1F	// day of month
-#define DD_DAY_SHIFT			0
-#define DD_MONTH_MASK			0x1E0	// month
-#define DD_MONTH_SHIFT			5
-#define DD_YEAR_MASK			0xFE00	// year - 1980
-#define DD_YEAR_SHIFT			9
-
-
-#define FLAGS_ATRMEDIUMSIZE		0x80
-#define FLAGS_XEXLOADER			0x40
-#define FLAGS_ATRDOUBLESECTORS	0x20
-#define FLAGS_XFDTYPE			0x10
-#define FLAGS_READONLY			0x08
-#define FLAGS_WRITEERROR		0x04
-#define FLAGS_DRIVEON			0x01
-
-// Stuctures
-typedef struct						//2+2+2+2+2+4+1=15
-{
-	unsigned short start_cluster;		//< file starting cluster
-	unsigned short dir_cluster;
-	unsigned short current_cluster;
-	unsigned short ncluster;
-	unsigned short file_index;			//< file index
-	unsigned long size;					//< file size
-	unsigned char flags;				//< file flags
-}virtual_disk_t;
-
-struct FileInfoStruct
-{
-	unsigned char Attr;				//< file attr for last file accessed
-	unsigned short Date;			//< last update date
-	unsigned short Time;			//< last update time
-	unsigned char percomstate;		//=0 default, 1=percomwrite ok (single sectors), 2=percomwrite ok (double sectors), 3=percomwrite bad
-	//
-	virtual_disk_t vDisk;
-};
-
-struct GlobalSystemValues			//4+4+2+2+1=13 bytes
-{
-	unsigned long FirstFATSector;
-	unsigned long FirstDataSector;
-	unsigned short RootDirSectors;
-	unsigned short BytesPerSector;
-	unsigned char SectorsPerCluster;
-};
-
-#define FirstFATSector		GS.FirstFATSector
-#define FirstDataSector		GS.FirstDataSector
-#define RootDirSectors		GS.RootDirSectors
-#define BytesPerSector		GS.BytesPerSector
-#define SectorsPerCluster	GS.SectorsPerCluster
-
-
-unsigned char fatInit();
-unsigned long fatClustToSect(unsigned short clust);
-unsigned char fatChangeDirectory(unsigned short entry);
-unsigned char fatGetDirEntry(unsigned short entry, unsigned char use_long_names);
-unsigned short nextCluster(unsigned short cluster);
-
-#endif
Index: firmware_5200/defunct/test.c
===================================================================
--- firmware_5200/defunct/test.c	(revision 191)
+++ firmware_5200/defunct/test.c	(nonexistent)
@@ -1,71 +0,0 @@
-
-
-unsigned char toatarichar(int val)
-{
-	if (val>='A' && val<='Z')
-	{
-		val+=-'A'+33;
-	}
-	else if (val>='a' && val<='z')
-	{
-		val+=-'a'+33+64;
-	}
-	else if (val>='0' && val<='9')
-	{
-		val+=-'0'+16;	
-	}
-	else
-	{
-		val = 0;
-	}
-	return val;
-}
-
-int xpos = 0;
-int ypos = 0;
-
-void nextline()
-{
-	xpos=0;
-	ypos+=1;
-	if (ypos==24)
-		ypos = 0;
-}
-void plot(unsigned char a, int x, int y)
-{
-	printf("%d %d %d\n",a,x,y);
-}
-
-void debug(char const * str)
-{
-//        char buffer[256];
-//        buffer[0] = 'W';
-//        buffer[1] = 'T';
-//        buffer[2] = 'F';
-//        buffer[3] = 0;
-//        str = buffer;
-
-        while (1)
-        {
-                int val = *str++;
-                if (val==0) break;
-
-                plot(toatarichar(val),xpos,ypos);
-                ++xpos;
-                if (xpos==40)
-                {
-                        nextline();
-                }
-        }
-        nextline();
-        //Delay100usX(10000);
-}
-
-
-int main(void)
-{
-	printf("%d %d\n", 'H', toatarichar('H'));
-	debug("Goodbye sweet world!");
-	return 0;
-}
-
Index: firmware_5200/test_drive.c
===================================================================
--- firmware_5200/test_drive.c	(revision 191)
+++ firmware_5200/test_drive.c	(nonexistent)
@@ -1,152 +0,0 @@
-#include "simpledir.h"
-#include "simplefile.h"
-
-#include "atari_drive_emulator.h"
-
-#include "stdio.h"
-#include "stdlib.h"
-
-#include <sys/time.h>
-
-extern char native_command;
-extern char receive_buffer[];
-extern int receive_buffer_pos;
-extern int receive_buffer_last;
-
-double start_time;
-double now()
-{
-	struct timeval tv;
-	gettimeofday(&tv,0);
-
-	return ((double)tv.tv_sec + (double)tv.tv_usec/1e6);
-}
-
-void char_out ( void* p, char c)
-{
-	putc(c, stderr);
-}
-
-struct SimpleFile * files[5];
-
-int main(void)
-{
-	init_printf(NULL, char_out);
-
-	struct SimpleDirEntry * entry;
-	char * mem = (char *)malloc(8192);
-	if (SimpleFile_OK != dir_init(mem, 8192))
-	{
-		fprintf(stderr,"Failed to open dir!");
-		return -1;
-	}
-	entry = dir_entries("");
-	entry = dir_next(dir_next(dir_next(entry)));
-	fprintf(stderr, " Name:%s", dir_filename(entry));
-	int i;
-	for (i=0;i!=5;++i)
-	{
-		struct SimpleFile * file = alloca(file_struct_size());
-		file_init(file);
-		files[i] = file;
-	}
-	//file_open_dir(entry,file);
-	if (SimpleFile_OK == file_open_name("GUNPOWDR.ATR",files[0]))
-	{
-	}
-	else
-	{
-		fprintf(stderr,"\nARG\n");
-	}
-
-	int read = 0;
-	char buffer[1024];
-	//file_seek(file,100);
-	file_read(files[0],&buffer[0],1024,&read);
-	for (i=0; i!=read; ++i)
-	{
-		fprintf(stderr,"|%02x", (unsigned char)buffer[i]);
-		//fprintf(stderr,"%c", buffer[i]);
-	}
-
-	fprintf(stderr,"\n");
-
-	native_command = 1;
-
-	init_drive_emulator();
-
-	//set_drive_status(0,files[0]);
-	for (i=1;i!=5;++i)
-	{
-		char buffer[20];
-		describe_disk(i-1,&buffer[0]);
-		fprintf(stderr, "Drive %d:%s %s\n", i, file_name(get_file_status(i-1)), &buffer[0]);
-	}
-
-					int row = 6;
-					{
-						// Swap files
-						struct SimpleFile * temp = files[row-3];
-						files[row-3] = files[0];
-						files[0] = temp;
-					}
-
-					{
-						// Swap disks
-						struct SimpleFile * temp = get_drive_status(row-3);
-						set_drive_status(row-3, get_drive_status(0));
-						set_drive_status(0,temp);
-					}
-	for (i=1;i!=5;++i)
-	{
-		char buffer[20];
-		describe_disk(i-1,&buffer[0]);
-		fprintf(stderr, "Drive %d:%s %s\n", i, file_name(get_file_status(i-1)), &buffer[0]);
-	}
-
-	start_time = now();
-	run_drive_emulator();
-
-	return 0;
-}
-
-void actions()
-{
-	// USART_TransmitByte();
-	// native_command
-
-	double when = now();
-	if ((when-start_time) > 1.0 && (when-start_time)<1.1)
-	{
-		native_command = 0;
-
-		static int once = 0;
-		if (!once)
-		{
-			once = 1;
-
-			receive_buffer[receive_buffer_last++] = 0x31;
-			//receive_buffer[receive_buffer_last++] = 0x32;
-			receive_buffer[receive_buffer_last++] = 0x52;
-			receive_buffer[receive_buffer_last++] = 0x01;
-			receive_buffer[receive_buffer_last++] = 0x00;
-			receive_buffer[receive_buffer_last++] = 0x84;
-			//receive_buffer[receive_buffer_last++] = 0x85;
-		}
-		else
-		{
-			native_command = 1;
-		}
-	}
-	else
-	{
-		native_command = 1;
-	}
-}
-
-void
-wait_us(int unsigned num)
-{
-	usleep(num);
-}
-
Index: firmware_5200/hexdump.c
===================================================================
--- firmware_5200/hexdump.c	(revision 191)
+++ firmware_5200/hexdump.c	(nonexistent)
@@ -1,11 +0,0 @@
-#include "hexdump.h"
-#include "printf.h"
-
-void hexdump_pure(void const * str, int length)
-{
-	for (;length>0;--length)
-	{
-		unsigned char val= *(unsigned char *)str++;
-		printf("%02x",val);
-	}
-}
Index: firmware_5200/mww.c
===================================================================
--- firmware_5200/mww.c	(revision 191)
+++ firmware_5200/mww.c	(nonexistent)
@@ -1,103 +0,0 @@
-#include "stdio.h"
-//#include <string.h>
-
-//#define stricmp strncasecmp
-
-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);
-int strcmp(char const * a, char const * b)
-{
-	while (*a || *b)
-	{
-		if (*a<*b)
-			return -1;
-		else if (*a>*b)
-			return 1;
-
-		++a;
-		++b;
-	}
-	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++);
-}
-
-void stricpy(char * dest, char const * src)
-{
-	while (*src)
-	{
-		char val = *src++;
-		if (val>='A' && val<='Z') val+=-'A'+'a';
-
-		*dest++ = val;
-	}
-	*dest = '\0';
-}
-
-int strlen(char const * a)
-{
-	int count;
-	for (count=0; *a; ++a,++count);
-	return count;
-}
-
-int compare_ext(char const * filename, char const * ext)
-{
-	int dot = 0;
-	//printf("WTFA:%s %s\n",filenamein, extin);
-	//printf("WTFB:%s %s\n",filename, ext);
-
-	char const * end = strlen(filename) + filename;
-	while (--end != filename)
-	{
-		if (*end == '.')
-			break;
-	}
-	if (0==stricmp(end+1,ext)) return 1;
-
-	return 0;
-}
-
-//int compare_ext(char const * filename, char const * ext)
-//{
-//        int dot = 0;
-//        //printf("WTFA:%s %s\n",filenamein, extin);
-//        //printf("WTFB:%s %s\n",filename, ext);
-//
-//        char const * end = strlen(filename) + filename;
-//        while (--end != filename)
-//        {
-//                if (*end == '.')
-//                        break;
-//        }
-//        if (0==stricmp(end+1,ext,1000)) return 1;
-//
-//        return 0;
-//}
-
-int main(void)
-{
-	fprintf(stderr,"%d %d %d %d\n",
-		compare_ext("Elektra Glide.ATR","atr"),
-		compare_ext("Elektra Glide (1985)(English Software Company).xex","XEX"),
-		compare_ext("International Karate.atr","atr"),
-		compare_ext("World Karate Championship.atx","xex"));
-
-	return 0;
-}
-
Index: firmware_5200/aeon_lite/memory.h
===================================================================
--- firmware_5200/aeon_lite/memory.h	(revision 191)
+++ firmware_5200/aeon_lite/memory.h	(nonexistent)
@@ -1,12 +0,0 @@
-#pragma once
-
-// Memory usage...
-// 0x90000-0x9FFFF (0x890000 in zpu space) = directory cache - 64k
-// 0xA0000-0xBFFFF (0x8a0000 in zpu space) = freeze backup
-// 0xC0000-0xDFFFF (0x8c0000 in zpu space) = os rom/basic rom
-
-#define DIR_INIT_MEM 0x890000
-#define DIR_INIT_MEMSIZE 65536
-#define FREEZE_MEM 0x8a0000
-#define ROM_MEM 0xc0000
-
Index: firmware_5200/sd_direct/spi.c
===================================================================
--- firmware_5200/sd_direct/spi.c	(revision 191)
+++ firmware_5200/sd_direct/spi.c	(nonexistent)
@@ -1,126 +0,0 @@
-/*! \file spi.c \brief SPI interface driver. */
-//*****************************************************************************
-//
-// File Name	: 'spi.c'
-// Title		: SPI interface driver
-// Author		: Pascal Stang - Copyright (C) 2000-2002
-// Created		: 11/22/2000
-// Revised		: 06/06/2002
-// Version		: 0.6
-// Target MCU	: Atmel AVR series
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-#include "spi.h"
-
-#include "regs.h"
-#include "spi.h"
-
-#include "printf.h"
-
-int spi_slow; // 1 is slow
-int spi_chip_select_n; // 0 is selected
-int display;
-void updateSpiState()
-{
-	*zpu_spi_state = (spi_slow<<1)|(spi_chip_select_n);
-}
-
-// access routines
-void setSpiFast()
-{
-	spi_slow = 0;
-	updateSpiState();
-}
-
-void setSpiSlow()
-{
-	spi_slow = 1;
-	updateSpiState();
-}
-
-void set_spi_clock_freq() // avr handles spi clock?
-{
-	setSpiFast();
-}
-
-void spiInit()
-{
-	spiDisplay(0);
-	spi_slow = 1;
-	spi_chip_select_n = 1;
-	updateSpiState();
-}
-
-void mmcChipSelect(int select)
-{
-	spi_chip_select_n = !select;
-	updateSpiState();
-}
-
-u08 spiTransferByte(u08 data)
-{
-	u08 res = 0;
-
-	//debug("spiTransferByte");
-
-	/*if (display!=0)
-	{
-		plotnext(hextoatarichar((data&0xf0) >> 4));
-		plotnext(hextoatarichar((data&0xf)));
-	}*/
-
-	// send the given data
-	*zpu_spi_data = data;
-
-	// wait for transfer to complete
-	while ((1&*zpu_spi_state) == 1);
-
-	// return the received data
-	res = *zpu_spi_data;
-
-	if (display!=0)
-	{
-		//XXX plotnext(hextoatarichar((res&0xf0) >> 4));
-		//XXX plotnext(hextoatarichar((res&0xf)));
-
-		//plotnext(toatarichar(' '));
-	}
-
-	return res;
-}
-
-u08 spiTransferFF()
-{
-	return spiTransferByte(0xFF);
-}
-
-void spiDisplay(int i)
-{
-	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_5200/sd_direct/spi.h_SPITEST
===================================================================
--- firmware_5200/sd_direct/spi.h_SPITEST	(revision 191)
+++ firmware_5200/sd_direct/spi.h_SPITEST	(nonexistent)
@@ -1,68 +0,0 @@
-/*! \file spi.h \brief SPI interface driver. */
-//*****************************************************************************
-//
-// File Name	: 'spi.h'
-// Title		: SPI interface driver
-// Author		: Pascal Stang - Copyright (C) 2000-2002
-// Created		: 11/22/2000
-// Revised		: 06/06/2002
-// Version		: 0.6
-// Target MCU	: Atmel AVR series
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-///	\ingroup driver_avr
-/// \defgroup spi SPI (Serial Peripheral Interface) Function Library (spi.c)
-/// \code #include "spi.h" \endcode
-/// \par Overview
-///		Provides basic byte and word transmitting and receiving via the AVR
-///	SPI interface.� Due to the nature of SPI, every SPI communication operation
-/// is both a transmit and simultaneous receive.
-///
-///	\note Currently, only MASTER mode is supported.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-
-#ifndef SPI_H
-#define SPI_H
-
-#include "integer.h"
-
-// function prototypes
-void mmcChipSelect(int select);
-
-void set_spi_clock_freq();
-
-// SPI interface initializer
-void spiInit(void);
-
-// spiTransferByte(u08 data) waits until the SPI interface is ready
-// and then sends a single byte over the SPI port.  The function also
-// returns the byte that was received during transmission.
-u08 spiTransferByte(u08 data);
-
-// spiTransferWord(u08 data) works just like spiTransferByte but
-// operates on a whole word (16-bits of data).
-u08 spiTransferFF();
-void spiTransferTwoFF();
-
-void spiDisplay(int i);
-
-void spiReceiveBlock(void * mem, int count);
-
-#endif
Index: firmware_5200/sd_direct/mmc.c
===================================================================
--- firmware_5200/sd_direct/mmc.c	(revision 191)
+++ firmware_5200/sd_direct/mmc.c	(nonexistent)
@@ -1,284 +0,0 @@
-/*! \file mmc.c \brief MultiMedia and SD Flash Card Interface. */
-//*****************************************************************************
-//
-// File Name	: 'mmc.c'
-// Title		: MultiMedia and SD Flash Card Interface
-// Author		: Pascal Stang - Copyright (C) 2004
-// Created		: 2004.09.22
-// Revised		: 2004.09.22
-// Version		: 0.1
-// Target MCU	: Atmel AVR Series
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-//----- Include Files ---------------------------------------------------------
-#include "spi.h"		// include spi bus support
-
-
-//#define spiTransferTwoFF()	{ spiTransferFF(); spiTransferFF(); }
-
-
-#include "mmc.h"
-
-// include project-specific hardware configuration
-#include "mmcconf.h"
-#include "debug.h"
-
-u08 mmcSendCommand(u08 cmd, u32 arg);
-u08 mmcCommand(u08 cmd, u32 arg);
-
-void mmcInit(void)
-{
-	// initialize SPI interface
-	spiInit();
-	// release chip select
-	mmcChipSelect(0);
-}
-
-u08 mmcReset(void)
-{
-	u16 retry;
-	u08 r1;
-	u08 i;
-	u08 sdcard;
-
-	//
-	i=0xff; //255x
-	do { spiTransferFF(); i--; } while(i);	//255x
-
-	//
-	r1 = mmcSendCommand(MMC_GO_IDLE_STATE, 0);
-	if (r1!=1) return -1;
-
-	retry=0xffff; //65535x
-	do
-	{
-		r1 = mmcSendCommand(55, 0);
-		if (r1!=1) break; //MMC
-		//if (r1==5) break; //MMC  <--- kontrolovat takhle rekl Bob 27.6.2008
-								//Strana 120 ve specifikaci.
-								//bit 0 - in idle state, bit 2 - illegal command
-
-		r1 = mmcSendCommand(41, 0);
-		if (r1==0) break; //SD
-
-		retry--;
-	}
-	while(retry);
-
-	// initializing card for operation
-	r1 = mmcSendCommand(MMC_SEND_OP_COND, 0);
-	// SDkarty vraceji 0
-	// MMCkarta vraci 1
-	//if (r1>=2) return -1; //problem (MMC taky nefunguje)
-	if (r1!=0) return -1;
-
-	//kdyz jsem to tady nechal jit s MMC kartou dal (s r1=1)
-	//tak to na nekterem z dalsich povelu zustalo zasekle
-	//a po vytazeni MMC a vlozeni jine SD se muset mackat Reset :-(
-
-	/*
-	if( r1!=0  &&  r1!=5)
-	{
-		u08 v;
-		v=inb(PINC)&0xf0;
-		v|=(0x0f ^ (r1 & 0x0f) );
-		PORTC=v;
-	 	while(1); //nekonecna smycka
-	 return -1;
-	}
-	*/
-
-	// turn off CRC checking to simplify communication
-	//r1 = 
-	mmcSendCommand(MMC_CRC_ON_OFF, 0);
-
-	// set block length to 512 bytes
-	//r1 = 
-	mmcSendCommand(MMC_SET_BLOCKLEN, 512);
-
-	// return success
-	return 0;
-}
-
-void mmc_init()
-{
-       do
-       {
-               mmcInit();
-       }
-       while(mmcReset());      //dokud nenulove, tak smycka (return 0 => ok!)
-}
-
-u08 mmcSendCommand(u08 cmd, u32 arg)
-{
-	u08 r1;
-
-	// assert chip select
-	mmcChipSelect(1);
-	//
-	//spiTransferFF();			//pribude 34 bajtu kodu (!)
-	// issue the command
-	r1 = mmcCommand(cmd, arg);
-	//
-	//spiTransferFF();
-	// release chip select
-	mmcChipSelect(0);
-
-	return r1;
-}
-
-unsigned char mmc_sector_buffer[512];
-
-void mmcReadLoop()
-{
-	u16 i;
-	u08 *buffer=mmc_sector_buffer;	//natvrdo!
-
-	spiReceiveData(buffer,buffer+512);
-	//spiReceiveData(buffer,buffer+3);
-
-/*	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);
-
-	//spiDisplay(1);
-	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);
-
-	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);
-
-	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);*/
-
-	//spiDisplay(0);
-
-}
-
-u08 mmcRead(u32 sector)
-{
-	u08 r1;
-
-	// assert chip select
-	mmcChipSelect(1);
-	// issue command
-	r1 = mmcCommand(MMC_READ_SINGLE_BLOCK, sector<<9);
-
-	// check for valid response
-	if(r1 != 0x00) return r1;
-
-	// wait for block start
-	while(spiTransferFF() != MMC_STARTBLOCK_READ);
-
-	//zacatek bloku
-
-	//nacti 512 bytu
-	mmcReadLoop();
-
-	// read 16-bit CRC
-	//2x FF:
-	spiTransferFF();
-	spiTransferFF();
-	//// + 1x FF navic pred releasnutim chip selectu
-	//spiTransferFF();
-	//
-	// release chip select
-	mmcChipSelect(0);
-
-	//debug("Hexdump\n");
-	//hexdump(mmc_sector_buffer,80);
-
-	//
-	return 0;	//success
-}
-
-u08 mmcWrite(u32 sector)
-{
-	u08 r1;
-	u16 i;
-	u08 *buffer=mmc_sector_buffer;	//natvrdo!
-
-	// assert chip select
-	mmcChipSelect(1);
-	// issue command
-	r1 = mmcCommand(MMC_WRITE_BLOCK, sector<<9);
-	// check for valid response
-	if(r1 != 0x00)
-		return r1;
-	// send dummy
-	spiTransferFF();
-	// send data start token
-	spiTransferByte(MMC_STARTBLOCK_WRITE);
-
-	// write data (512 bytes)
-	i=0x200;
-	do { spiTransferByte(*buffer++); i--; }	while(i);
-
-	// write 16-bit CRC (dummy values)
-	//2x FF:
-	spiTransferFF();
-	spiTransferFF();
-	// read data response token
-	r1 = spiTransferFF();
-	if( (r1&MMC_DR_MASK) != MMC_DR_ACCEPT)
-		return r1;
-	// wait until card not busy
-	while(!spiTransferFF());
-	// release chip select
-	mmcChipSelect(0);
-	// return success
-	return 0;
-}
-
-u08 mmcCommand(u08 cmd, u32 arg)
-{
-	u08 r1;
-	u08 retry=0xff;	//255x
-	//
-
-	spiTransferFF();
-
-	spiTransferFF();	//pridano navic! 27.6.2008 doporucil Bob!k
-	spiTransferFF();	//pridano navic! 27.6.2008 doporucil Bob!k
-	spiTransferFF();	//pridano navic! 27.6.2008 doporucil Bob!k
-
-	// send command
-	spiTransferByte(cmd | 0x40);
-	//
-	spiTransferByte(arg>>24);
-	spiTransferByte(arg>>16);
-	spiTransferByte(arg>>8);
-	spiTransferByte(arg);
-	//Alternativni zpusob pres ((u08*)&arg)[] je delsi.
-
-	spiTransferByte(0x95);	// crc valid only for MMC_GO_IDLE_STATE
-	// end command
-	// wait for response
-	// if more than 255 retries, card has timed-out
-	// return the received 0xFF
-	do
-	{
-		r1 = spiTransferFF();
-		retry--;
-	}
-	while(retry && (r1 == 0xFF) );
-
-	// return response
-	return r1;
-}
Index: firmware_5200/sd_direct/diskio_mmc.c
===================================================================
--- firmware_5200/sd_direct/diskio_mmc.c	(revision 191)
+++ firmware_5200/sd_direct/diskio_mmc.c	(nonexistent)
@@ -1,147 +0,0 @@
-#include "diskio.h"
-
-#include "mmc.h"
-#include "spi.h"
-
-//#include "printf.h"
-
-void mmcReadCached(u32 sector);
-u32 n_actual_mmc_sector;
-extern unsigned char mmc_sector_buffer[512];
-
-void mmcReadCached(u32 sector)
-{
-	//debug("mmcReadCached");
-	//plotnext(toatarichar(' '));
-	//plotnextnumber(sector);
-	//debug("\n");
-	if(sector==n_actual_mmc_sector) return;
-	//debug("mmcReadREAL");
-	//plotnext(toatarichar(' '));
-	//plotnextnumber(sector);
-	//debug("\n");
-
-	u08 ret,retry;
-	//predtim nez nacte jiny, musi ulozit soucasny
-	// TODO mmcWriteCachedFlush();
-	//az ted nacte novy
-	retry=0; //zkusi to maximalne 256x
-	do
-	{
-		ret = mmcRead(sector);	//vraci 0 kdyz ok
-		retry--;
-	} while (ret && retry);
-	while(ret); //a pokud se vubec nepovedlo, tady zustane zablokovany cely SDrive!
-	n_actual_mmc_sector=sector;
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Initialize Disk Drive                                                 */
-/*-----------------------------------------------------------------------*/
-
-DSTATUS disk_initialize (void)
-{
-	DSTATUS stat;
-
-	//printf(" in init ");
-	n_actual_mmc_sector = 0xffffffff;
-	for(;;)
-	{
-		mmc_init();
-		if (0==mmcRead(1))
-			break;
-	}
-
-	//printf(" setting freq ");
-
-	set_spi_clock_freq();
-
-	stat = RES_OK;
-
-	return stat;
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Read Partial Sector                                                   */
-/*-----------------------------------------------------------------------*/
-
-DRESULT disk_readp (
-	BYTE* dest,			/* Pointer to the destination object */
-	DWORD sector,		/* Sector number (LBA) */
-	WORD sofs,			/* Offset in the sector */
-	WORD count			/* Byte count (bit15:destination) */
-)
-{
-	DRESULT res;
-
-	/*debug("readp:");
-	plotnextnumber(sector);
-	debug(" ");
-	plotnextnumber((int)dest);
-	debug(" ");
-	plotnextnumber(sofs);
-	debug(" ");
-	plotnextnumber(count);
-	debug(" ");
-	plotnextnumber(atari_sector_buffer);
-	debug(" ");
-	plotnextnumber(mmc_sector_buffer);
-	debug("\n");
-	*/
-	// Put your code here
-	mmcReadCached(sector);
-	for(;count>0;++sofs,--count)
-	{
-		unsigned char x = mmc_sector_buffer[sofs];
-		//printf("char:%c loc:%d ", x,sofs);
-		*dest++ = x;
-	}
-
-	res = RES_OK;
-
-	return res;
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Write Partial Sector                                                  */
-/*-----------------------------------------------------------------------*/
-
-DRESULT disk_writep (const BYTE* buff, DWORD sofs, DWORD count)
-{
-	DRESULT res;
-
-	int i=sofs;
-	int end=sofs+count;
-	int pos = 0;
-	for (;i!=end;++i,++pos)
-	{
-		mmc_sector_buffer[i] = buff[pos];
-		//printf("char:%c loc:%d,", buff[pos],i);
-	}
-
-	res = RES_OK;
-
-	return res;
-}
-
-void disk_writeflush()
-{
-	// Finalize write process
-	int retry=16; //zkusi to maximalne 16x
-	int ret;
-	//printf(":WSECT:%d",n_actual_mmc_sector);
-	do
-	{
-		ret = mmcWrite(n_actual_mmc_sector); //vraci 0 kdyz ok
-		retry--;
-	} while (ret && retry);
-	//printf(":WD:");
-}
-
-
Index: firmware_5200/sd_direct/mmc2.c
===================================================================
--- firmware_5200/sd_direct/mmc2.c	(revision 191)
+++ firmware_5200/sd_direct/mmc2.c	(nonexistent)
@@ -1,255 +0,0 @@
-/*-------------------------------------------------------------------------*/
-/* PFF - Low level disk control module for PIC            (C)ChaN, 2014    */
-/*-------------------------------------------------------------------------*/
-
-#include "pff.h"
-#include "diskio.h"
-
-//#include "printf.h"
-
-/*-------------------------------------------------------------------------*/
-/* Platform dependent macros and functions needed to be modified           */
-/*-------------------------------------------------------------------------*/
-
-#define SELECT() mmcChipSelect(1)
-#define	DESELECT() mmcChipSelect(0)
-
-unsigned char mmc_sector_buffer[512];
-
-extern u32 n_actual_mmc_sector;
-
-/*--------------------------------------------------------------------------
-
-   Module Private Functions
-
----------------------------------------------------------------------------*/
-
-/* Definitions for MMC/SDC command */
-#define CMD0	(0x40+0)	/* GO_IDLE_STATE */
-#define CMD1	(0x40+1)	/* SEND_OP_COND (MMC) */
-#define	ACMD41	(0xC0+41)	/* SEND_OP_COND (SDC) */
-#define CMD8	(0x40+8)	/* SEND_IF_COND */
-#define CMD16	(0x40+16)	/* SET_BLOCKLEN */
-#define CMD17	(0x40+17)	/* READ_SINGLE_BLOCK */
-#define CMD24	(0x40+24)	/* WRITE_BLOCK */
-#define CMD55	(0x40+55)	/* APP_CMD */
-#define CMD58	(0x40+58)	/* READ_OCR */
-
-
-/* Card type flags (CardType) */
-#define CT_MMC				0x01	/* MMC ver 3 */
-#define CT_SD1				0x02	/* SD ver 1 */
-#define CT_SD2				0x04	/* SD ver 2 */
-#define CT_BLOCK			0x08	/* Block addressing */
-
-BYTE CardType;
-
-
-extern int debug_pos;
-
-void disk_debug()
-{
-/*	{
-		char buffer[512];
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-
-		printf("Hello world 5");
-		debug_pos = 40;
-
-		printf("Di");
-
-		debug_pos = 80;
-		disk_initialize();
-
-		printf("Did:%02x",CardType);
-
-		debug_pos = 120;
-
-		n_actual_mmc_sector = -1;
-		printf(" PP");
-		disk_readp(&buffer[0],0,0,512);
-		printf(" DD");
-		hexdump_pure(&buffer[0],512);
-
-		wait_us(10000000);
-		restore();
-	}
-*/
-}
-
-/*-----------------------------------------------------------------------*/
-/* Send a command packet to the SDC/MMC                                  */
-/*-----------------------------------------------------------------------*/
-
-static
-BYTE send_cmd (
-	BYTE cmd,		/* 1st byte (Start + Index) */
-	DWORD arg		/* Argument (32 bits) */
-)
-{
-	BYTE n, res;
-
-
-	if (cmd & 0x80) {	/* ACMD<n> is the command sequense of CMD55-CMD<n> */
-		cmd &= 0x7F;
-		res = send_cmd(CMD55, 0);
-		if (res > 1) return res;
-	}
-
-	/* Select the card */
-	DESELECT();
-	spiTransferFF();
-	SELECT();
-	spiTransferFF();
-
-	/* Send a command packet */
-	spiTransferByte(cmd);						/* Start + Command index */
-	spiTransferByte((BYTE)(arg >> 24));		/* Argument[31..24] */
-	spiTransferByte((BYTE)(arg >> 16));		/* Argument[23..16] */
-	spiTransferByte((BYTE)(arg >> 8));			/* Argument[15..8] */
-	spiTransferByte((BYTE)arg);				/* Argument[7..0] */
-	n = 0x01;							/* Dummy CRC + Stop */
-	if (cmd == CMD0) n = 0x95;			/* Valid CRC for CMD0(0) */
-	if (cmd == CMD8) n = 0x87;			/* Valid CRC for CMD8(0x1AA) */
-	spiTransferByte(n);
-
-	/* Receive a command response */
-	n = 10;								/* Wait for a valid response in timeout of 10 attempts */
-	do {
-		res = spiTransferFF();
-	} while ((res & 0x80) && --n);
-
-	return res;			/* Return with the response value */
-}
-
-
-
-
-/*--------------------------------------------------------------------------
-
-   Public Functions
-
----------------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------*/
-/* Initialize Disk Drive                                                 */
-/*-----------------------------------------------------------------------*/
-
-void mmc_init (void)
-{
-	BYTE n, cmd, ty, ocr[4];
-	UINT tmr;
-
-	// initialize SPI interface
-	spiInit();
-
-	DESELECT();
-	for (n = 10; n; n--) spiTransferFF();	/* 80 Dummy clocks with CS=H */
-
-	ty = 0;
-	if (send_cmd(CMD0, 0) == 1) {			/* Enter Idle state */
-		if (send_cmd(CMD8, 0x1AA) == 1) {	/* SDv2 */
-			for (n = 0; n < 4; n++) ocr[n] = spiTransferFF();		/* Get trailing return value of R7 resp */
-			if (ocr[2] == 0x01 && ocr[3] == 0xAA) {			/* The card can work at vdd range of 2.7-3.6V */
-				for (tmr = 10000; tmr && send_cmd(ACMD41, 1UL << 30); tmr--) wait_us(100);	/* Wait for leaving idle state (ACMD41 with HCS bit) */
-				if (tmr && send_cmd(CMD58, 0) == 0) {		/* Check CCS bit in the OCR */
-					for (n = 0; n < 4; n++) ocr[n] = spiTransferFF();
-					ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2;	/* SDv2 (HC or SC) */
-				}
-			}
-		} else {							/* SDv1 or MMCv3 */
-			if (send_cmd(ACMD41, 0) <= 1) 	{
-				ty = CT_SD1; cmd = ACMD41;	/* SDv1 */
-			} else {
-				ty = CT_MMC; cmd = CMD1;	/* MMCv3 */
-			}
-			for (tmr = 10000; tmr && send_cmd(cmd, 0); tmr--) wait_us(100);	/* Wait for leaving idle state */
-			if (!tmr || send_cmd(CMD16, 512) != 0)			/* Set R/W block length to 512 */
-				ty = 0;
-		}
-	}
-	CardType = ty;
-	DESELECT();
-	spiTransferFF();
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Read partial sector                                                   */
-/*-----------------------------------------------------------------------*/
-
-u08 mmcRead(u32 sector)
-{
-	BYTE rc;
-	UINT bc;
-	int res = 0;
-
-	//printf("mr:%x",sector);
-
-	if (!(CardType & CT_BLOCK)) sector *= 512;	/* Convert to byte address if needed */
-
-	if (send_cmd(CMD17, sector) == 0) {		/* READ_SINGLE_BLOCK */
-
-		bc = 40000;
-		do {							/* Wait for data packet */
-			rc = spiTransferFF();
-		} while (rc == 0xFF && --bc);
-
-		if (rc == 0xFE) {				/* A data packet arrived */
-			bc = 514 - 512;
-
-			u08 *buffer=mmc_sector_buffer;	//natvrdo!
-
-			spiReceiveData(buffer,buffer+512);
-
-			/* Skip remaining bytes and CRC */
-			do spiTransferFF(); while (--bc); // checksum
-		}
-	}
-	else
-	{
-		res = 1;
-	}
-
-	DESELECT();
-	spiTransferFF();
-	return res;
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Write partial sector                                                  */
-/*-----------------------------------------------------------------------*/
-
-u08 mmcWrite(u32 sc)
-{
-	u08 *buff=mmc_sector_buffer;	//natvrdo!
-
-	WORD wc;
-
-	SELECT();
-
-	if (!(CardType & CT_BLOCK)) sc *= 512;	/* Convert to byte address if needed */
-	if (send_cmd(CMD24, sc) == 0) {			/* WRITE_SINGLE_BLOCK */
-		spiTransferByte(0xFF); spiTransferByte(0xFE);		/* Data block header */
-		wc = 512;							/* Set byte counter */
-
-		while (wc) {		/* Send data bytes to the card */
-			spiTransferByte(*buff++);
-			wc--; 
-		}
-
-		DWORD bc = 2;
-		while (bc--) spiTransferByte(0);	/* Fill left bytes and CRC with zeros */
-		if ((spiTransferFF() & 0x1F) == 0x05) {	/* Receive data resp and wait for end of write process in timeout of 500ms */
-			for (bc = 5000; spiTransferFF() != 0xFF && bc; bc--) wait_us(100);	/* Wait ready */
-		}
-		DESELECT();
-		spiTransferFF();
-	}
-	return 0;
-}
Index: firmware_5200/sd_direct/spi.h
===================================================================
--- firmware_5200/sd_direct/spi.h	(revision 191)
+++ firmware_5200/sd_direct/spi.h	(nonexistent)
@@ -1,68 +0,0 @@
-/*! \file spi.h \brief SPI interface driver. */
-//*****************************************************************************
-//
-// File Name	: 'spi.h'
-// Title		: SPI interface driver
-// Author		: Pascal Stang - Copyright (C) 2000-2002
-// Created		: 11/22/2000
-// Revised		: 06/06/2002
-// Version		: 0.6
-// Target MCU	: Atmel AVR series
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-///	\ingroup driver_avr
-/// \defgroup spi SPI (Serial Peripheral Interface) Function Library (spi.c)
-/// \code #include "spi.h" \endcode
-/// \par Overview
-///		Provides basic byte and word transmitting and receiving via the AVR
-///	SPI interface.� Due to the nature of SPI, every SPI communication operation
-/// is both a transmit and simultaneous receive.
-///
-///	\note Currently, only MASTER mode is supported.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-
-#ifndef SPI_H
-#define SPI_H
-
-#include "integer.h"
-
-// function prototypes
-void mmcChipSelect(int select);
-
-void set_spi_clock_freq();
-
-// SPI interface initializer
-void spiInit(void);
-
-// spiTransferByte(u08 data) waits until the SPI interface is ready
-// and then sends a single byte over the SPI port.  The function also
-// returns the byte that was received during transmission.
-u08 spiTransferByte(u08 data);
-
-// spiTransferWord(u08 data) works just like spiTransferByte but
-// operates on a whole word (16-bits of data).
-u08 spiTransferFF();
-void spiTransferTwoFF();
-
-void spiDisplay(int i);
-
-void spiReceiveData(u08 * from, u08 * to);
-
-#endif
Index: firmware_5200/sd_direct/mmc.h
===================================================================
--- firmware_5200/sd_direct/mmc.h	(revision 191)
+++ firmware_5200/sd_direct/mmc.h	(nonexistent)
@@ -1,145 +0,0 @@
-/*! \file mmc.h \brief MultiMedia and SD Flash Card Interface. */
-//*****************************************************************************
-//
-// File Name	: 'mmc.h'
-// Title		: MultiMedia and SD Flash Card Interface
-// Author		: Pascal Stang - Copyright (C) 2004
-// Created		: 2004.09.22
-// Revised		: 2004.09.22
-// Version		: 0.1
-// Target MCU	: Atmel AVR Series
-// Editor Tabs	: 4
-//
-///	\ingroup driver_hw
-/// \defgroup mmc MultiMedia and SD Flash Card Interface (mmc.c)
-/// \code #include "mmc.h" \endcode
-/// \par Description
-///		This library offers some simple functions which can be used
-///		to read and write data on a MultiMedia or SecureDigital (SD) Flash
-///		Card.  Although MM and SD Cards are designed to operate with their own
-///		special bus wiring and protocols, both types of cards also provide a
-///		simple SPI-like interface mode which is exceptionally useful when 
-///		attempting to use the cards in embedded systems.
-///
-/// \par Wiring
-///		To work with this library, the card must be wired to the SPI port of
-///		the Atmel microcontroller as described below.  Typical cards can
-///		operate at up to 25MHz maximum SPI clock rate (thus faster than most
-///		AVR's maximum SPI clock rate).
-/// <pre>
-///	      _________________
-///	     /  1 2 3 4 5 6 78 |	<- view of MMC/SD card looking at contacts
-///	    / 9                |	Pins 8 and 9 are present only on SD cards
-///	    |    MMC/SD Card   |
-///	    |                  |
-///	    --------------------
-///	    1 - CS   (chip select)          - wire to any available I/O pin(*)
-///	    2 - DIN  (data in, card<-host)  - wire to SPI MOSI pin
-///	    3 - VSS  (ground)               - wire to ground
-///	    4 - VDD  (power, 3.3V only?)    - wire to power (MIGHT BE 3.3V ONLY!)
-///	    5 - SCLK (data clock)           - wire to SPI SCK pin
-///	    6 - VSS  (ground)               - wire to ground
-///	    7 - DOUT (data out, card->host) - wire to SPI MISO pin
-///
-///	    (*) you must define this chip select I/O pin in mmcconf.h
-/// </pre>
-/// \note This code is currently below version 1.0, and therefore is considered
-/// to be lacking in some functionality or documentation, or may not be fully
-/// tested.  Nonetheless, you can expect most functions to work.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-
-#ifndef MMC_H
-#define MMC_H
-
-#include "integer.h"
-
-// constants/macros/typdefs
-// MMC commands (taken from sandisk MMC reference)
-#define MMC_GO_IDLE_STATE			0		///< initialize card to SPI-type access
-#define MMC_SEND_OP_COND			1		///< set card operational mode
-#define MMC_SEND_CSD				9		///< get card's CSD
-#define MMC_SEND_CID				10		///< get card's CID
-#define MMC_SEND_STATUS				13
-#define MMC_SET_BLOCKLEN			16		///< Set number of bytes to transfer per block
-#define MMC_READ_SINGLE_BLOCK		17		///< read a block
-#define MMC_WRITE_BLOCK				24		///< write a block
-#define MMC_PROGRAM_CSD				27
-#define MMC_SET_WRITE_PROT			28
-#define MMC_CLR_WRITE_PROT			29
-#define MMC_SEND_WRITE_PROT			30
-#define MMC_TAG_SECTOR_START		32
-#define MMC_TAG_SECTOR_END			33
-#define MMC_UNTAG_SECTOR			34
-#define MMC_TAG_ERASE_GROUP_START 	35		///< Sets beginning of erase group (mass erase)
-#define MMC_TAG_ERARE_GROUP_END		36		///< Sets end of erase group (mass erase)
-#define MMC_UNTAG_ERASE_GROUP		37		///< Untag (unset) erase group (mass erase)
-#define MMC_ERASE					38		///< Perform block/mass erase
-#define MMC_CRC_ON_OFF				59		///< Turns CRC check on/off
-// R1 Response bit-defines
-#define MMC_R1_BUSY					0x80	///< R1 response: bit indicates card is busy
-#define MMC_R1_PARAMETER			0x40
-#define MMC_R1_ADDRESS				0x20
-#define MMC_R1_ERASE_SEQ			0x10
-#define MMC_R1_COM_CRC				0x08
-#define MMC_R1_ILLEGAL_COM			0x04
-#define MMC_R1_ERASE_RESET			0x02
-#define MMC_R1_IDLE_STATE			0x01
-// Data Start tokens
-#define MMC_STARTBLOCK_READ			0xFE	///< when received from card, indicates that a block of data will follow
-#define MMC_STARTBLOCK_WRITE		0xFE	///< when sent to card, indicates that a block of data will follow
-#define MMC_STARTBLOCK_MWRITE		0xFC
-// Data Stop tokens
-#define MMC_STOPTRAN_WRITE			0xFD
-// Data Error Token values
-#define MMC_DE_MASK					0x1F
-#define MMC_DE_ERROR				0x01
-#define MMC_DE_CC_ERROR				0x02
-#define MMC_DE_ECC_FAIL				0x04
-#define MMC_DE_OUT_OF_RANGE			0x04
-#define MMC_DE_CARD_LOCKED			0x04
-// Data Response Token values
-#define MMC_DR_MASK					0x1F
-#define MMC_DR_ACCEPT				0x05
-#define MMC_DR_REJECT_CRC			0x0B
-#define MMC_DR_REJECT_WRITE_ERROR	0x0D
-
-// functions
-
-//! Initialize AVR<->MMC hardware interface.
-/// Prepares hardware for MMC access.
-void mmc_init(void);
-
-//! Initialize the card and prepare it for use.
-/// Returns zero if successful.
-//u08 mmcReset(void);
-
-//! Send card an MMC command.
-/// Returns R1 result code.
-//u08 mmcSendCommand(u08 cmd, u32 arg);
-
-//! Read 512-byte sector from card to buffer
-/// Returns zero if successful.
-u08 mmcRead(u32 sector);
-
-//! Write 512-byte sector from buffer to card
-/// Returns zero if successful.
-u08 mmcWrite(u32 sector);
-
-//! Internal command function.
-/// Issues a generic MMC command as specified by cmd and arg.
-//u08 mmcCommand(u08 cmd, u32 arg);
-
-#endif
Index: firmware_5200/sd_direct/TODO
===================================================================
--- firmware_5200/sd_direct/TODO	(revision 191)
+++ firmware_5200/sd_direct/TODO	(nonexistent)
@@ -1 +0,0 @@
-spiInit...
Index: firmware_5200/sd_direct/mmc.c_defunct
===================================================================
--- firmware_5200/sd_direct/mmc.c_defunct	(revision 191)
+++ firmware_5200/sd_direct/mmc.c_defunct	(nonexistent)
@@ -1,272 +0,0 @@
-/*! \file mmc.c \brief MultiMedia and SD Flash Card Interface. */
-//*****************************************************************************
-//
-// File Name	: 'mmc.c'
-// Title		: MultiMedia and SD Flash Card Interface
-// Author		: Pascal Stang - Copyright (C) 2004
-// Created		: 2004.09.22
-// Revised		: 2004.09.22
-// Version		: 0.1
-// Target MCU	: Atmel AVR Series
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-//----- Include Files ---------------------------------------------------------
-#include "spi.h"		// include spi bus support
-
-
-//#define spiTransferTwoFF()	{ spiTransferFF(); spiTransferFF(); }
-
-
-#include "mmc.h"
-
-// include project-specific hardware configuration
-#include "mmcconf.h"
-#include "debug.h"
-
-void mmcInit(void)
-{
-	// initialize SPI interface
-	spiInit();
-	// release chip select
-	mmcChipSelect(0);
-}
-
-u08 mmcReset(void)
-{
-	u16 retry;
-	u08 r1;
-	u08 i;
-	u08 sdcard;
-
-	//
-	i=0xff; //255x
-	do { spiTransferFF(); i--; } while(i);	//255x
-
-	//
-	r1 = mmcSendCommand(MMC_GO_IDLE_STATE, 0);
-	if (r1!=1) return -1;
-
-	retry=0xffff; //65535x
-	do
-	{
-		r1 = mmcSendCommand(55, 0);
-		if (r1!=1) break; //MMC
-		//if (r1==5) break; //MMC  <--- kontrolovat takhle rekl Bob 27.6.2008
-								//Strana 120 ve specifikaci.
-								//bit 0 - in idle state, bit 2 - illegal command
-
-		r1 = mmcSendCommand(41, 0);
-		if (r1==0) break; //SD
-
-		retry--;
-	}
-	while(retry);
-
-	// initializing card for operation
-	r1 = mmcSendCommand(MMC_SEND_OP_COND, 0);
-	// SDkarty vraceji 0
-	// MMCkarta vraci 1
-	//if (r1>=2) return -1; //problem (MMC taky nefunguje)
-	if (r1!=0) return -1;
-
-	//kdyz jsem to tady nechal jit s MMC kartou dal (s r1=1)
-	//tak to na nekterem z dalsich povelu zustalo zasekle
-	//a po vytazeni MMC a vlozeni jine SD se muset mackat Reset :-(
-
-	/*
-	if( r1!=0  &&  r1!=5)
-	{
-		u08 v;
-		v=inb(PINC)&0xf0;
-		v|=(0x0f ^ (r1 & 0x0f) );
-		PORTC=v;
-	 	while(1); //nekonecna smycka
-	 return -1;
-	}
-	*/
-
-	// turn off CRC checking to simplify communication
-	//r1 = 
-	mmcSendCommand(MMC_CRC_ON_OFF, 0);
-
-	// set block length to 512 bytes
-	//r1 = 
-	mmcSendCommand(MMC_SET_BLOCKLEN, 512);
-
-	// return success
-	return 0;
-}
-
-u08 mmcSendCommand(u08 cmd, u32 arg)
-{
-	u08 r1;
-
-	// assert chip select
-	mmcChipSelect(1);
-	//
-	//spiTransferFF();			//pribude 34 bajtu kodu (!)
-	// issue the command
-	r1 = mmcCommand(cmd, arg);
-	//
-	//spiTransferFF();
-	// release chip select
-	mmcChipSelect(0);
-
-	return r1;
-}
-
-unsigned char mmc_sector_buffer[512];
-
-void mmcReadLoop()
-{
-	u16 i;
-	u08 *buffer=mmc_sector_buffer;	//natvrdo!
-
-	spiReceiveData(buffer,buffer+512);
-	//spiReceiveData(buffer,buffer+3);
-
-/*	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);
-
-	//spiDisplay(1);
-	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);
-
-	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);
-
-	i=0x80;	//512
-	do { *buffer++ = spiTransferFF(); i--; } while(i);*/
-
-	//spiDisplay(0);
-
-}
-
-u08 mmcRead(u32 sector)
-{
-	u08 r1;
-
-	// assert chip select
-	mmcChipSelect(1);
-	// issue command
-	r1 = mmcCommand(MMC_READ_SINGLE_BLOCK, sector<<9);
-
-	// check for valid response
-	if(r1 != 0x00) return r1;
-
-	// wait for block start
-	while(spiTransferFF() != MMC_STARTBLOCK_READ);
-
-	//zacatek bloku
-
-	//nacti 512 bytu
-	mmcReadLoop();
-
-	// read 16-bit CRC
-	//2x FF:
-	spiTransferFF();
-	spiTransferFF();
-	//// + 1x FF navic pred releasnutim chip selectu
-	//spiTransferFF();
-	//
-	// release chip select
-	mmcChipSelect(0);
-
-	//debug("Hexdump\n");
-	//hexdump(mmc_sector_buffer,80);
-
-	//
-	return 0;	//success
-}
-
-u08 mmcWrite(u32 sector)
-{
-	u08 r1;
-	u16 i;
-	u08 *buffer=mmc_sector_buffer;	//natvrdo!
-
-	// assert chip select
-	mmcChipSelect(1);
-	// issue command
-	r1 = mmcCommand(MMC_WRITE_BLOCK, sector<<9);
-	// check for valid response
-	if(r1 != 0x00)
-		return r1;
-	// send dummy
-	spiTransferFF();
-	// send data start token
-	spiTransferByte(MMC_STARTBLOCK_WRITE);
-
-	// write data (512 bytes)
-	i=0x200;
-	do { spiTransferByte(*buffer++); i--; }	while(i);
-
-	// write 16-bit CRC (dummy values)
-	//2x FF:
-	spiTransferFF();
-	spiTransferFF();
-	// read data response token
-	r1 = spiTransferFF();
-	if( (r1&MMC_DR_MASK) != MMC_DR_ACCEPT)
-		return r1;
-	// wait until card not busy
-	while(!spiTransferFF());
-	// release chip select
-	mmcChipSelect(0);
-	// return success
-	return 0;
-}
-
-u08 mmcCommand(u08 cmd, u32 arg)
-{
-	u08 r1;
-	u08 retry=0xff;	//255x
-	//
-
-	spiTransferFF();
-
-	spiTransferFF();	//pridano navic! 27.6.2008 doporucil Bob!k
-	spiTransferFF();	//pridano navic! 27.6.2008 doporucil Bob!k
-	spiTransferFF();	//pridano navic! 27.6.2008 doporucil Bob!k
-
-	// send command
-	spiTransferByte(cmd | 0x40);
-	//
-	spiTransferByte(arg>>24);
-	spiTransferByte(arg>>16);
-	spiTransferByte(arg>>8);
-	spiTransferByte(arg);
-	//Alternativni zpusob pres ((u08*)&arg)[] je delsi.
-
-	spiTransferByte(0x95);	// crc valid only for MMC_GO_IDLE_STATE
-	// end command
-	// wait for response
-	// if more than 255 retries, card has timed-out
-	// return the received 0xFF
-	do
-	{
-		r1 = spiTransferFF();
-		retry--;
-	}
-	while(retry && (r1 == 0xFF) );
-
-	// return response
-	return r1;
-}
Index: firmware_5200/sd_direct/spi.c_SPITEST
===================================================================
--- firmware_5200/sd_direct/spi.c_SPITEST	(revision 191)
+++ firmware_5200/sd_direct/spi.c_SPITEST	(nonexistent)
@@ -1,134 +0,0 @@
-/*! \file spi.c \brief SPI interface driver. */
-//*****************************************************************************
-//
-// File Name	: 'spi.c'
-// Title		: SPI interface driver
-// Author		: Pascal Stang - Copyright (C) 2000-2002
-// Created		: 11/22/2000
-// Revised		: 06/06/2002
-// Version		: 0.6
-// Target MCU	: Atmel AVR series
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-#include "spi.h"
-
-#include "regs.h"
-#include "spi.h"
-
-#include "printf.h"
-
-int spi_slow; // 1 is slow
-int spi_chip_select_n; // 0 is selected
-int display;
-void updateSpiState()
-{
-	*zpu_spi_state = (spi_slow<<1)|(spi_chip_select_n);
-}
-
-// access routines
-void setSpiFast()
-{
-	spi_slow = 0;
-	updateSpiState();
-}
-
-void setSpiSlow()
-{
-	spi_slow = 1;
-	updateSpiState();
-}
-
-void set_spi_clock_freq() // avr handles spi clock?
-{
-	setSpiFast();
-}
-
-void spiInit()
-{
-	spiDisplay(0);
-	spi_slow = 1;
-	spi_chip_select_n = 1;
-	updateSpiState();
-}
-
-void mmcChipSelect(int select)
-{
-	spi_chip_select_n = !select;
-	updateSpiState();
-}
-
-u08 spiTransferByte(u08 data)
-{
-	u08 res = 0;
-
-	//debug("spiTransferByte");
-
-	/*if (display!=0)
-	{
-		plotnext(hextoatarichar((data&0xf0) >> 4));
-		plotnext(hextoatarichar((data&0xf)));
-	}*/
-
-	// send the given data
-	*zpu_spi_data = data;
-
-	// wait for transfer to complete
-	while ((1&*zpu_spi_state) == 1);
-
-	// return the received data
-	res = *zpu_spi_data;
-
-	if (display!=0)
-	{
-		//XXX plotnext(hextoatarichar((res&0xf0) >> 4));
-		//XXX plotnext(hextoatarichar((res&0xf)));
-
-		//plotnext(toatarichar(' '));
-	}
-
-	return res;
-}
-
-u08 spiTransferFF()
-{
-	return spiTransferByte(0xFF);
-}
-
-void spiDisplay(int i)
-{
-	display = i;
-}
-
-void spiReceiveBlock(void * mem, int count)
-{
-	unsigned char * buffer = (unsigned char *)(mem);
-	while (--count)
-	{
-		// send the given data
-		*zpu_spi_data = 0xff;
-
-		// wait for transfer to complete
-		while ((1&*zpu_spi_state) == 1);
-
-		// return the received data
-		*buffer++ = *zpu_spi_data;
-	}
-}
-
Index: firmware_5200/sd_direct/mmcconf.h
===================================================================
--- firmware_5200/sd_direct/mmcconf.h	(revision 191)
+++ firmware_5200/sd_direct/mmcconf.h	(nonexistent)
@@ -1,33 +0,0 @@
-/*! \file mmcconf.h \brief MultiMedia and SD Flash Card Interface Configuration. */
-//*****************************************************************************
-//
-// File Name	: 'mmcconf.h'
-// Title		: MultiMedia and SD Flash Card Interface Configuration
-// Author		: Pascal Stang - Copyright (C) 2004
-// Created		: 2004.09.22
-// Revised		: 2004.09.22
-// Version		: 0.1
-// Target MCU	: Atmel AVR Series
-// Editor Tabs	: 4
-//
-// NOTE: This code is currently below version 1.0, and therefore is considered
-// to be lacking in some functionality or documentation, or may not be fully
-// tested.  Nonetheless, you can expect most functions to work.
-//
-// ----------------------------------------------------------------------------
-// 17.8.2008
-// Bob!k & Raster, C.P.U.
-// Original code was modified especially for the SDrive device. 
-// Some parts of code have been added, removed, rewrited or optimized due to
-// lack of MCU AVR Atmega8 memory.
-// ----------------------------------------------------------------------------
-//
-// This code is distributed under the GNU Public License
-//		which can be found at http://www.gnu.org/licenses/gpl.txt
-//
-//*****************************************************************************
-
-#ifndef MMCCONF_H
-#define MMCCONF_H
-
-#endif
Index: firmware_5200/hexdump.h
===================================================================
--- firmware_5200/hexdump.h	(revision 191)
+++ firmware_5200/hexdump.h	(nonexistent)
@@ -1,4 +0,0 @@
-#pragma once
-
-void hexdump_pure(void const * str, int length);
-
Index: firmware_5200/mcc/dirs.c
===================================================================
--- firmware_5200/mcc/dirs.c	(revision 191)
+++ firmware_5200/mcc/dirs.c	(nonexistent)
@@ -1,2 +0,0 @@
-char USER_DIR[]="/atari800/user";
-char ROM_DIR[]="/system/rom/atari800";
Index: firmware_5200/debug.c
===================================================================
--- firmware_5200/debug.c	(revision 191)
+++ firmware_5200/debug.c	(nonexistent)
@@ -1,177 +0,0 @@
-#include "debug.h"
-#include "pause.h"
-
-int xpos;
-int ypos;
-int onoff; // perhaps we can plot to another address buffer, which we can scroll through in the monitor?
-
-int debugoffsetval;
-
-void topofscreen()
-{
-	xpos = 0;
-	ypos = 0;
-}
-
-void setxpos(int val)
-{
-	xpos = val;
-}
-
-void setypos(int val)
-{
-	ypos = val;
-}
-
-void initdebug(int onoff_in)
-{
-	xpos = 0;
-	ypos = 0;
-	onoff = onoff_in;
-}
-
-void nextline()
-{
-	int i;
-	xpos=0;
-	ypos+=1;
-	if (ypos==24)
-		ypos = 0;
-	for (i=0;i!=40;++i)
-		plot(0,i,ypos);
-
-	//Delay100usX(5000);
-}
-
-unsigned char toatarichar(int val)
-{
-	int inv = val>=128;
-	if (inv)
-	{
-		val-=128;
-	}
-	if (val>='A' && val<='Z')
-	{
-		val+=-'A'+33;
-	}
-	else if (val>='a' && val<='z')
-	{
-		val+=-'a'+33+64;
-	}
-	else if (val>='0' && val<='9')
-	{
-		val+=-'0'+16;	
-	}
-	else if (val>=32 && val<=47)
-	{
-		val+=-32;
-	}
-	else
-	{
-		val = 0;
-	}
-	if (inv)
-	{
-		val+=128;
-	}
-	return val;
-}
-unsigned char hextoatarichar(int val)
-{
-	if (val>=0 && val<=9)
-	{
-		val+=+16;	
-	}
-	else if (val>=10 && val<=15)
-	{
-		val+=-10+33;
-	}
-	return val;
-}
-void plot(unsigned char val, int x, int y)
-{
-	if (onoff == 0) return;
-
-	unsigned char volatile * baseaddr = (unsigned char volatile *)(11328 + atari_regbase);
-	*(baseaddr + y*40+x) = val+debugoffsetval;
-}
-void debugoffset(int x)
-{
-	debugoffsetval = x;
-}
-void debug(char const * str)
-{
-	while (1)
-	{
-		int val = *str++;
-		if (val==0) break;
-		if (val=='\n') {nextline();continue;};
-
-		plot(toatarichar(val),xpos,ypos);
-		++xpos;
-		if (xpos==40)
-		{
-			nextline();
-		}
-	}
-	debugoffsetval = 0;
-}
-
-void plotnext(unsigned char val)
-{
-	plot(val,xpos,ypos);
-
-	++xpos;
-	if (xpos==40) nextline();
-}
-
-void plotnextnumber(unsigned short val)
-{
-	plotnext(hextoatarichar((val&0xf000)>>12));
-	plotnext(hextoatarichar((val&0x0f00)>>8));
-	plotnext(hextoatarichar((val&0x00f0)>>4));
-	plotnext(hextoatarichar((val&0x000f)>>0));
-	debugoffsetval = 0;
-}
-
-void hexdump(unsigned void const * str, int length)
-{
-	nextline();
-
-	for (;length>0;--length)
-	{
-		unsigned char val= *str++;
-		
-		// LH 10 cols = char
-		// RH 20 cols = hex
-
-		plot(toatarichar(val),xpos,ypos);
-		plot(hextoatarichar((val&0xf0) >> 4),xpos*2+20,ypos);
-		plot(hextoatarichar(val&0xf),xpos*2+21,ypos);
-
-		++xpos;
-		if (xpos==10)
-		{
-			nextline();
-		}
-	}
-	nextline();
-}
-
-void hexdump_pure(unsigned void const * str, int length)
-{
-	xpos = xpos&0xfffe;
-	for (;length>0;--length)
-	{
-		unsigned char val= *str++;
-		
-		plot(hextoatarichar((val&0xf0) >> 4),xpos++,ypos);
-		plot(hextoatarichar(val&0xf),xpos++,ypos);
-
-		if (xpos==40)
-		{
-			nextline();
-		}
-	}
-}
-
Index: firmware_5200/de1/dirs.c
===================================================================
--- firmware_5200/de1/dirs.c	(revision 191)
+++ firmware_5200/de1/dirs.c	(nonexistent)
@@ -1,2 +0,0 @@
-char USER_DIR[]="/atari800/user";
-char ROM_DIR[]="/atari800/rom";
Index: firmware_5200/crt0.S
===================================================================
--- firmware_5200/crt0.S	(revision 191)
+++ firmware_5200/crt0.S	(nonexistent)
@@ -1,974 +0,0 @@
-/* Startup code for ZPU
-   Copyright (C) 2005 Free Software Foundation, Inc.
-
-This file is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-In addition to the permissions in the GNU General Public License, the
-Free Software Foundation gives you unlimited permission to link the
-compiled version of this file with other programs, and to distribute
-those programs without any restriction coming from the use of this
-file.  (The General Public License restrictions do apply in other
-respects; for example, they cover modification of the file, and
-distribution when not linked into another program.)
-
-This file is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-	.file	"crt0.S"
-	
-	
-	
-	
-;	.section ".fixed_vectors","ax"
-; KLUDGE!!! we remove the executable bit to avoid relaxation 
-	.section ".fixed_vectors","a" 
-
-; DANGER!!!! 
-; we need to align these code sections to 32 bytes, which
-; means we must not use any assembler instructions that are relaxed
-; at linker time
-; DANGER!!!! 
-
-	.macro fixedim value
-			im \value
-	.endm
-
-	.macro  jsr address
-			im _memreg     	; save R0
-			load
-			im _memreg+4	; save R1
-			load
-			im _memreg+8	; save R2
-			load
-			fixedim \address
-			call
-			im _memreg+8
-			store		; restore R2
-			im _memreg+4
-			store		; restore R1
-			im _memreg
-			store		; restore R0
-	.endm
-
-
-	.macro  jmp address
-			fixedim \address
-			poppc
-	.endm
-		
-
-	.macro fast_neg
-	not
-	im 1
-	add
-	.endm
-	
-	.macro cimpl funcname
-	; save R0
-	im _memreg
-	load
-	
-	; save R1
-	im _memreg+4
-	load
-	
-	; save R2
-	im _memreg+8
-	load
-	
-	loadsp 20
-	loadsp 20
-	
-	fixedim \funcname
-	call
-
-	; destroy arguments on stack
-	storesp 0
-	storesp 0	
-	 
-	im _memreg
-	load
-	
-	; poke the result into the right slot
-	storesp 24
-
-	; restore R2
-	im _memreg+8
-	store
-	
-	; restore R1
-	im _memreg+4
-	store
-	
-	; restore r0
-	im _memreg
-	store
-	
-	
-	storesp 4
-	poppc
-	.endm
-
-	.macro mult1bit
-	; create mask of lowest bit in A
-	loadsp 8 ; A
-	im 1
-	and
-	im -1
-	add
-	not
-	loadsp 8 ; B
-	and 
-	add ; accumulate in C
-	
-	; shift B left 1 bit
-	loadsp 4 ; B
-	addsp 0
-	storesp 8 ; B
-	
-	; shift A right 1 bit
-	loadsp 8 ; A
-	flip
-	addsp 0
-	flip
-	storesp 12 ; A
-	.endm
-
-
-
-/* vectors */
-        .balign 32,0
-# offset 0x0000 0000
-		.globl _start
-_start:
-		; intSp must be 0 when we jump to _premain
-		
-		im ZPU_ID
-		loadsp 0
-		im _cpu_config
-		store
-		config
-		jmp _premain
-
-
-
-        .balign 32,0
-# offset 0x0000 0020
-		.globl _zpu_interrupt_vector
-_zpu_interrupt_vector:
-		jmp ___zpu_interrupt_vector
-
-
-        .balign 16,0
-# offset 0x0000 0030
-		.globl _memreg
-		.weak _memreg
-_memreg:
-
-
-/* instruction emulation code */
-
-# opcode 34
-# offset 0x0000 0040
-	.balign 32,0
-_loadh:
-	loadsp 4
-	; by not masking out bit 0, we cause a memory access error 
-	; on unaligned access
-	im ~0x2
-	and
-	load
-
-	; mult 8	
-	loadsp 8
-	im 3
-	and
-	fast_neg
-	im 2
-	add
-	im 3
-	ashiftleft
-	; shift right addr&3 * 8
-	lshiftright
-	im 0xffff
-	and
-	storesp 8
-	
-	poppc
-
-# opcode 35
-# offset 0x0000 0060
-	.balign 32,0
-_storeh:
-	loadsp 4
-	; by not masking out bit 0, we cause a memory access error 
-	; on unaligned access
-	im ~0x2
-	and
-	load
-
-	; mask
-	im 0xffff
-	loadsp 12
-	im 3
-	and
-	fast_neg
-	im 2
-	add
-	im 3
-	ashiftleft
-	ashiftleft
-	not
-
-	and
-
-	loadsp 12
-	im 0xffff
-
-	nop
-		
-	fixedim _storehtail
-	poppc
-
-
-# opcode 36
-# offset 0x0000 0080
-	.balign 32,0
-_lessthan:
-	loadsp 8
-	fast_neg
-	loadsp 8
-	add
-
-	; DANGER!!!!
-	; 0x80000000 will overflow when negated, so we need to mask
-	; the result above with the compare positive to negative
-	; number case
-	loadsp 12
-	loadsp 12
-	not
-	and
-	not
-	and
-
-
-	; handle case where we are comparing a negative number
-	; and positve number. This can underflow. E.g. consider 0x8000000 < 0x1000
-	loadsp 12
-	not
-	loadsp 12
-	and
-	
-	or
-
-
-
-	flip
-	im 1
-	and	
-
-	
-	storesp 12
-	storesp 4
-	poppc
-	
-
-# opcode 37
-# offset 0x0000 00a0
-	.balign 32,0
-_lessthanorequal:
-	loadsp 8
-	loadsp 8
-	lessthan
-	loadsp 12
-	loadsp 12
-	eq
-	or
-	
-	storesp 12
-	storesp 4
-	poppc
-
-	
-# opcode 38
-# offset 0x0000 00c0
-	.balign 32,0
-_ulessthan:
-	; fish up arguments 
-	loadsp 4
-	loadsp 12
-	
-	/* low: -1 if low bit dif is negative 0 otherwise:  neg (not x&1 and (y&1))
-		x&1		y&1		neg (not x&1 and (y&1))
-		1		1		0
-		1		0 		0
-		0		1		-1
-		0		0		0
-	
-	*/
-	loadsp 4 
-	not
-	loadsp 4
-	and
-	im 1
-	and
-	neg
-	
-	
-	/* high: upper 31-bit diff is only wrong when diff is 0 and low=-1
-		high=x>>1 - y>>1 + low
-		
-		extremes
-		
-		0000 - 1111:
-		low= neg(not 0 and 1) = 1111 (-1)
-		high=000+ neg(111) +low = 000 + 1001 + low = 1000 
-		OK
-		
-		1111 - 0000
-		low=neg(not 1 and 0) = 0
-		high=111+neg(000) + low = 0111
-		OK
-		 
-		
-	 */
-	loadsp 8
-	
-	flip 
-	addsp 0
-	flip
-	
-	loadsp 8
-	
-	flip	
-	addsp 0
-	flip
-
-	sub
-
-	; if they are equal, then the last bit decides...	
-	add
-	
-	/* test if negative: result = flip(diff) & 1 */
-	flip
-	im 1
-	and
-
-	; destroy a&b which are on stack	
-	storesp 4
-	storesp 4
-	
-	storesp 12
-	storesp 4
-	poppc			
-
-# opcode 39
-# offset 0x0000 00e0
-	.balign 32,0
-_ulessthanorequal:
-	loadsp 8
-	loadsp 8
-	ulessthan
-	loadsp 12
-	loadsp 12
-	eq
-	or
-	
-	storesp 12
-	storesp 4
-	poppc
-
-
-# opcode 40
-# offset 0x0000 0100
-	.balign 32,0
-	.globl _swap
-_swap:
-	breakpoint ; tbd
-
-# opcode 41
-# offset 0x0000 0120
-	.balign 32,0
-_slowmult:
-	im _slowmultImpl
-	poppc
-
-# opcode 42
-# offset 0x0000 0140
-	.balign 32,0
-_lshiftright:
-	loadsp 8
-	flip
-
-	loadsp 8
-	ashiftleft
-	flip
-	
-	storesp 12
-	storesp 4
-
-	poppc
-	
-
-# opcode 43
-# offset 0x0000 0160
-	.balign 32,0
-_ashiftleft:
-	loadsp 8
-	
-	loadsp 8
-	im 0x1f
-	and
-	fast_neg
-	im _ashiftleftEnd
-	add
-	poppc
-	
-	
-	
-# opcode 44
-# offset 0x0000 0180
-	.balign 32,0
-_ashiftright:
-	loadsp 8
-	loadsp 8
-	lshiftright
-	
-	; handle signed value
-	im -1
-	loadsp 12
-	im 0x1f
-	and
-	lshiftright
-	not	; now we have an integer on the stack with the signed 
-		; bits in the right position
-
-	; mask these bits with the signed bit.
-	loadsp 16
-	not
-	flip
-	im 1
-	and
-	im -1
-	add
-	
-	and	
-	
-	; stuff in the signed bits...
-	or
-	
-	; store result into correct stack slot	
-	storesp 12
-	
-	; move up return value 
-	storesp 4
-	poppc
-
-# opcode 45
-# offset 0x0000 01a0
-	.balign 32,0
-_call:
-	; fn
-	loadsp 4
-	
-	; return address
-	loadsp 4
-
-	; store return address
-	storesp 12
-	
-	; fn to call
-	storesp 4
-	
-	pushsp	; flush internal stack
-	popsp
-		
-	poppc
-
-_storehtail:
-
-	and
-	loadsp 12
-	im 3
-	and
-	fast_neg
-	im 2
-	add
-	im 3
-	ashiftleft
-	nop
-	ashiftleft
-	
-	or
-	
-	loadsp 8
-	im  ~0x3
-	and
-
-	store
-	
-	storesp 4
-	storesp 4
-	poppc
-
-
-# opcode 46
-# offset 0x0000 01c0
-	.balign 32,0
-_eq:
-	loadsp 8
-	fast_neg
-	loadsp 8
-	add
-	
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-	im 1
-	and
-	
-	storesp 12
-	storesp 4
-	poppc
-
-# opcode 47
-# offset 0x0000 01e0
-	.balign 32,0
-_neq:
-	loadsp 8
-	fast_neg
-	loadsp 8
-	add
-	
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-
-	not
-
-	im 1
-	and
-		
-	storesp 12
-	storesp 4
-	poppc
-	
-
-# opcode 48
-# offset 0x0000 0200
-	.balign 32,0
-_neg:
-	loadsp 4
-	not
-	im 1
-	add
-	storesp 8
-	
-	poppc
-	
-
-# opcode 49
-# offset 0x0000 0220
-	.balign 32,0
-_sub:
-	loadsp 8
-	loadsp 8
-	fast_neg
-	add
-	storesp 12
-
-	storesp 4
-
-	poppc
-
-
-# opcode 50
-# offset 0x0000 0240
-	.balign 32,0
-_xor:
-	loadsp 8
-	not
-	loadsp 8
-	and
-	
-	loadsp 12
-	loadsp 12
-	not
-	and
-
-	or
-
-	storesp 12
-	storesp 4
-	poppc
-
-# opcode 51
-# offset 0x0000 0260
-	.balign 32,0
-_loadb:
-	loadsp 4
-	im ~0x3
-	and
-	load
-
-	loadsp 8
-	im 3
-	and
-	fast_neg
-	im 3
-	add
-	; x8
-	addsp 0
-	addsp 0
-	addsp 0
-
-	lshiftright
-
-	im 0xff
-	and
-	storesp 8
-	
-	poppc
-
-
-# opcode 52
-# offset 0x0000 0280
-	.balign 32,0
-_storeb:
-	loadsp 4
-	im ~0x3
-	and
-	load
-
-	; mask away destination
-	im _mask
-	loadsp 12
-	im 3
-	and
-	addsp 0
-	addsp 0
-	add
-	load
-
-	and
-
-
-	im _storebtail
-	poppc
-	
-# opcode 53
-# offset 0x0000 02a0
-	.balign 32,0
-_div:
-	jmp ___div
-	
-# opcode 54
-# offset 0x0000 02c0
-	.balign 32,0
-_mod:
-	jmp ___mod
-
-# opcode 55
-# offset 0x0000 02e0
-	.balign 32,0
-	.globl _eqbranch
-_eqbranch:
-	loadsp 8
-	
-	; eq
-
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-	im 1
-	and
-
-	; mask
-	im -1
-	add
-	loadsp 0
-	storesp 16
-
-	; no branch address
-	loadsp 4
-	
-	and
-
-	; fetch boolean & neg mask
-	loadsp 12
-	not
-	
-	; calc address & mask for branch
-	loadsp 8
-	loadsp 16
-	add
-	; subtract 1 to find PC of branch instruction
-	im -1
-	add
-	
-	and
-
-	or	
-	
-	storesp 4
-	storesp 4
-	storesp 4
-	poppc	
-
-
-# opcode 56
-# offset 0x0000 0300
-	.balign 32,0
-	.globl _neqbranch
-_neqbranch:
-	loadsp 8
-	
-	; neq
-
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-	
-	not
-	
-	im 1
-	and
-
-	; mask
-	im -1
-	add
-	loadsp 0
-	storesp 16
-
-	; no branch address
-	loadsp 4
-	
-	and
-
-	; fetch boolean & neg mask
-	loadsp 12
-	not
-	
-	; calc address & mask for branch
-	loadsp 8
-	loadsp 16
-	add
-	; find address of branch instruction
-	im -1
-	add
-	
-	and
-
-	or	
-	
-	storesp 4
-	storesp 4
-	storesp 4
-	poppc	
-
-# opcode 57
-# offset 0x0000 0320
-	.balign 32,0
-	.globl _poppcrel
-_poppcrel:
-	add
-	; address of poppcrel
-	im -1
-	add
-	poppc
-		
-# opcode 58
-# offset 0x0000 0340
-	.balign 32,0
-	.globl _config
-_config:
-	im 1 
-	nop
-	im _hardware
-	store
-	storesp 4
-	poppc
-
-# opcode 59
-# offset 0x0000 0360
-	.balign 32,0
-_pushpc:
-	loadsp 4
-	im 1
-	add 
-	storesp 8
-	poppc
-	
-# opcode 60
-# offset 0x0000 0380
-	.balign 32,0
-_syscall_emulate:
-	.byte 0
-	
-# opcode 61
-# offset 0x0000 03a0
-	.balign 32,0
-_pushspadd:
-	pushsp
-	im 4
-	add
-	loadsp 8
-	addsp 0
-	addsp 0
-	add
-	storesp 8
-	
-	poppc
-
-# opcode 62
-# offset 0x0000 03c0
-	.balign 32,0
-_halfmult:
-	breakpoint
-	
-# opcode 63
-# offset 0x0000 03e0
-	.balign 32,0
-_callpcrel:
-	loadsp 4
-	loadsp 4
-	add
-	im -1
-	add
-	loadsp 4
-	
-	storesp 12	; return address
-	storesp 4 
-	pushsp		; this will flush the internal stack.
-	popsp
-	poppc
-
-	.text
-
-	
-
-
-_ashiftleftBegin:
-	.rept 0x1f
-	addsp 0
-	.endr
-_ashiftleftEnd:
-	storesp 12
-	storesp 4
-	poppc
-	
-_storebtail:
-	loadsp 12
-	im 0xff
-	and
-	loadsp 12
-	im 3
-	and
-
-	fast_neg
-	im 3
-	add
-	; x8
-	addsp 0
-	addsp 0
-	addsp 0
-
-	ashiftleft
-	 
-	or
-	
-	loadsp 8
-	im  ~0x3
-	and
-
-	store
-	
-	storesp 4
-	storesp 4
-	poppc
-	
-
-
-
-; NB! this is not an EMULATE instruction. It is a varargs fn.
-	.globl _syscall	
-_syscall:
-	syscall
-	poppc
-	
-_slowmultImpl:
-	
-	loadsp 8 ; A
-	loadsp 8 ; B
-	im 0 ; C
-
-.LmoreMult:
-	mult1bit
-	
-	; cutoff
-	loadsp 8
-	.byte (.LmoreMult-.Lbranch)&0x7f+0x80
-.Lbranch:
-	neqbranch
-
-	storesp 4
-	storesp 4
-	storesp 12
-	storesp 4
-	poppc
-
-___mod:
-	cimpl __modsi3
-___div:
-	cimpl __divsi3
-
-        .globl ___zpu_interrupt_vector
-        .weak ___zpu_interrupt_vector
-
-___zpu_interrupt_vector:
-	jsr _zpu_interrupt
-	poppc
-
-	.section ".rodata"
-	.balign 4,0
-_mask:
-	.long 0x00ffffff
-	.long 0xff00ffff
-	.long 0xffff00ff
-	.long 0xffffff00
-
-	.data
-	.balign 4,0
-	
-	.globl _hardware
-_hardware:
-	.long 0
-	.globl _cpu_config
-_cpu_config:
-	.long 0
-

Property changes on: firmware_5200/crt0.S
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/fat/pff_file.h
===================================================================
--- firmware_5200/fat/pff_file.h	(revision 191)
+++ firmware_5200/fat/pff_file.h	(nonexistent)
@@ -1,28 +0,0 @@
-#pragma once
-
-#include "simplefile.h"
-#include "simpledir.h"
-
-#define MAX_DIR_LENGTH (9*5+1)
-#define MAX_FILE_LENGTH (8+3+1+1)
-#define MAX_PATH_LENGTH (9*5 + 8+3+1 + 1)
-
-// Do not access these directly... They vary by architecture, just the simplefile/simpledir interface is the same
-struct SimpleFile
-{
-	char path[MAX_PATH_LENGTH];
-	int is_readonly;
-	int size;
-};
-
-struct SimpleDirEntry
-{
-	char path[MAX_PATH_LENGTH];
-	char * filename_ptr;
-	char lfn[256];
-	int size;
-	int is_subdir;
-	int is_readonly;
-	struct SimpleDirEntry * next; // as linked list - want to allow sorting...
-};
-
Index: firmware_5200/fat/pff.h
===================================================================
--- firmware_5200/fat/pff.h	(revision 191)
+++ firmware_5200/fat/pff.h	(nonexistent)
@@ -1,193 +0,0 @@
-/*---------------------------------------------------------------------------/
-/  Petit FatFs - FAT file system module include file  R0.02a   (C)ChaN, 2010
-/----------------------------------------------------------------------------/
-/ Petit FatFs module is an open source software to implement FAT file system to
-/ small embedded systems. This is a free software and is opened for education,
-/ research and commercial developments under license policy of following trems.
-/
-/  Copyright (C) 2010, ChaN, all right reserved.
-/
-/ * The Petit FatFs module is a free software and there is NO WARRANTY.
-/ * No restriction on use. You can use, modify and redistribute it for
-/   personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
-/ * Redistributions of source code must retain the above copyright notice.
-/
-/----------------------------------------------------------------------------*/
-
-#include "integer.h"
-
-/*---------------------------------------------------------------------------/
-/ Petit FatFs Configuration Options
-/
-/ CAUTION! Do not forget to make clean the project after any changes to
-/ the configuration options.
-/
-/----------------------------------------------------------------------------*/
-#ifndef _FATFS
-#define _FATFS
-
-#define	_USE_READ	1	/* 1:Enable pf_read() */
-
-#define	_USE_DIR	1	/* 1:Enable pf_opendir() and pf_readdir() */
-
-#define	_USE_LSEEK	1	/* 1:Enable pf_lseek() */
-
-#define	_USE_WRITE	0	/* 1:Enable pf_write() */
-
-#define _FS_FAT12	1	/* 1:Enable FAT12 support */
-#define _FS_FAT32	1	/* 1:Enable FAT32 support */
-
-
-#define	_CODE_PAGE	1
-/* Defines which code page is used for path name. Supported code pages are:
-/  932, 936, 949, 950, 437, 720, 737, 775, 850, 852, 855, 857, 858, 862, 866,
-/  874, 1250, 1251, 1252, 1253, 1254, 1255, 1257, 1258 and 1 (ASCII only).
-/  SBCS code pages except for 1 requiers a case conversion table. This
-/  might occupy 128 bytes on the RAM on some platforms, e.g. avr-gcc. */
-
-
-#define _WORD_ACCESS	0
-/* The _WORD_ACCESS option defines which access method is used to the word
-/  data in the FAT structure.
-/
-/   0: Byte-by-byte access. Always compatible with all platforms.
-/   1: Word access. Do not choose this unless following condition is met.
-/
-/  When the byte order on the memory is big-endian or address miss-aligned
-/  word access results incorrect behavior, the _WORD_ACCESS must be set to 0.
-/  If it is not the case, the value can also be set to 1 to improve the
-/  performance and code efficiency. */
-
-
-/* End of configuration options. Do not change followings without care.     */
-/*--------------------------------------------------------------------------*/
-
-
-
-#if _FS_FAT32
-#define	CLUST	DWORD
-#else
-#define	CLUST	WORD
-#endif
-
-
-/* File system object structure */
-
-typedef struct {
-	BYTE	fs_type;	/* FAT sub type */
-	BYTE	flag;		/* File status flags */
-	BYTE	csize;		/* Number of sectors per cluster */
-	BYTE	pad1;
-	WORD	n_rootdir;	/* Number of root directory entries (0 on FAT32) */
-	CLUST	n_fatent;	/* Number of FAT entries (= number of clusters + 2) */
-	DWORD	fatbase;	/* FAT start sector */
-	DWORD	dirbase;	/* Root directory start sector (Cluster# on FAT32) */
-	DWORD	database;	/* Data start sector */
-	DWORD	fptr;		/* File R/W pointer */
-	DWORD	fsize;		/* File size */
-	CLUST	org_clust;	/* File start cluster */
-	CLUST	curr_clust;	/* File current cluster */
-	DWORD	dsect;		/* File current data sector */
-} FATFS;
-
-
-
-/* Directory object structure */
-
-typedef struct {
-	WORD	index;		/* Current read/write index number */
-	BYTE*	fn;			/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
-	CLUST	sclust;		/* Table start cluster (0:Static table) */
-	CLUST	clust;		/* Current cluster */
-	DWORD	sect;		/* Current sector */
-} DIR;
-
-
-
-/* File status structure */
-
-typedef struct {
-	DWORD	fsize;		/* File size */
-	WORD	fdate;		/* Last modified date */
-	WORD	ftime;		/* Last modified time */
-	BYTE	fattrib;	/* Attribute */
-	char	fname[13];	/* File name */
-	char	lfname[256];	/* File name */
-} FILINFO;
-
-
-
-/* File function return code (FRESULT) */
-
-typedef enum {
-	FR_OK = 0,			/* 0 */
-	FR_DISK_ERR,		/* 1 */
-	FR_NOT_READY,		/* 2 */
-	FR_NO_FILE,			/* 3 */
-	FR_NO_PATH,			/* 4 */
-	FR_NOT_OPENED,		/* 5 */
-	FR_NOT_ENABLED,		/* 6 */
-	FR_NO_FILESYSTEM	/* 7 */
-} FRESULT;
-
-
-
-/*--------------------------------------------------------------*/
-/* Petit FatFs module application interface                     */
-
-FRESULT pf_mount (FATFS*);						/* Mount/Unmount a logical drive */
-FRESULT pf_open (const char*);					/* Open a file */
-FRESULT pf_read (void*, WORD, WORD*);			/* Read data from the open file */
-FRESULT pf_write (const void*, WORD, WORD*);	/* Write data to the open file */
-FRESULT pf_lseek (DWORD);						/* Move file pointer of the open file */
-FRESULT pf_opendir (DIR*, const char*);			/* Open a directory */
-FRESULT pf_readdir (DIR*, FILINFO*);			/* Read a directory item from the open directory */
-
-
-
-/*--------------------------------------------------------------*/
-/* Flags and offset address                                     */
-
-/* File status flag (FATFS.flag) */
-
-#define	FA_OPENED	0x01
-#define	FA_WPRT		0x02
-#define	FA__WIP		0x40
-
-
-/* FAT sub type (FATFS.fs_type) */
-
-#define FS_FAT12	1
-#define FS_FAT16	2
-#define FS_FAT32	3
-
-
-/* File attribute bits for directory entry */
-
-#define	AM_RDO	0x01	/* Read only */
-#define	AM_HID	0x02	/* Hidden */
-#define	AM_SYS	0x04	/* System */
-#define	AM_VOL	0x08	/* Volume label */
-#define AM_LFN	0x0F	/* LFN entry */
-#define AM_DIR	0x10	/* Directory */
-#define AM_ARC	0x20	/* Archive */
-#define AM_MASK	0x3F	/* Mask of defined bits */
-
-
-/*--------------------------------*/
-/* Multi-byte word access macros  */
-
-#if _WORD_ACCESS == 1	/* Enable word access to the FAT structure */
-#define	LD_WORD(ptr)		(WORD)(*(WORD*)(BYTE*)(ptr))
-#define	LD_DWORD(ptr)		(DWORD)(*(DWORD*)(BYTE*)(ptr))
-#define	ST_WORD(ptr,val)	*(WORD*)(BYTE*)(ptr)=(WORD)(val)
-#define	ST_DWORD(ptr,val)	*(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
-#else					/* Use byte-by-byte access to the FAT structure */
-#define	LD_WORD(ptr)		(WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
-#define	LD_DWORD(ptr)		(DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
-#define	ST_WORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
-#define	ST_DWORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
-#endif
-
-
-#endif /* _FATFS */
Index: firmware_5200/fat/diskio.h
===================================================================
--- firmware_5200/fat/diskio.h	(revision 191)
+++ firmware_5200/fat/diskio.h	(nonexistent)
@@ -1,42 +0,0 @@
-/*-----------------------------------------------------------------------
-/  PFF - Low level disk interface modlue include file    (C)ChaN, 2009
-/-----------------------------------------------------------------------*/
-
-#ifndef _DISKIO
-
-#include "integer.h"
-
-
-/* Status of Disk Functions */
-typedef BYTE	DSTATUS;
-
-
-/* Results of Disk Functions */
-typedef enum {
-	RES_OK = 0,		/* 0: Function succeeded */
-	RES_ERROR,		/* 1: Disk error */
-	RES_NOTRDY,		/* 2: Not ready */
-	RES_PARERR		/* 3: Invalid parameter */
-} DRESULT;
-
-
-/*---------------------------------------*/
-/* Prototypes for disk control functions */
-
-DSTATUS disk_initialize (void);
-DRESULT disk_readp (BYTE*, DWORD, WORD, WORD);
-DRESULT disk_writep (const BYTE* buff, DWORD sofs, DWORD count);
-void disk_writeflush();
-
-#define STA_NOINIT		0x01	/* Drive not initialized */
-#define STA_NODISK		0x02	/* No medium in the drive */
-
-/* Card type flags (CardType) */
-#define CT_MMC				0x01	/* MMC ver 3 */
-#define CT_SD1				0x02	/* SD ver 1 */
-#define CT_SD2				0x04	/* SD ver 2 */
-#define CT_SDC				(CT_SD1|CT_SD2)	/* SD */
-#define CT_BLOCK			0x08	/* Block addressing */
-
-#define _DISKIO
-#endif
Index: firmware_5200/fat/pff_file.c
===================================================================
--- firmware_5200/fat/pff_file.c	(revision 191)
+++ firmware_5200/fat/pff_file.c	(nonexistent)
@@ -1,465 +0,0 @@
-#include "pff_file.h"
-
-#include "pff.h"
-#include "utils.h"
-#include "diskio.h"
-#include "simplefile.h"
-#include "printf.h"
-
-struct SimpleFile * openfile;
-
-void * dir_cache;
-int dir_cache_size;
-
-FATFS fatfs;
-DIR dir;
-FILINFO filinfo;
-
-int write_pending;
-
-#define translateStatus(res) (res == FR_OK ? SimpleFile_OK: SimpleFile_FAIL)
-#define translateDStatus(res) (res == RES_OK ? SimpleFile_OK: SimpleFile_FAIL)
-
-/*
-enum SimpleFileStatus translateStatus(FRESULT res)
-{
-	return res == FR_OK ? SimpleFile_OK: SimpleFile_FAIL;
-}
-
-enum SimpleFileStatus translateDStatus(DSTATUS res)
-{
-	return res == RES_OK ? SimpleFile_OK: SimpleFile_FAIL;
-}*/
-
-char const * file_of(char const * path)
-{
-	char const * start = path + strlen(path);
-	while (start!=path)
-	{
-		--start;
-		if (*start == '/')
-		{
-			++start;
-			break;
-		}
-	}
-	return start;
-}
-
-void dir_of(char * dir, char const * path)
-{
-	char const * end = file_of(path);
-	if (end != path) 
-	{
-		int len = end-path;
-		while (len--)
-		{
-			*dir++ = *path++;
-		}
-		--dir;
-	}
-
-	*dir = '\0';
-	return;
-}
-
-char const * file_name(struct SimpleFile * file)
-{
-	return file_of(&file->path[0]);
-}
-
-char const * file_path(struct SimpleFile * file)
-{
-	return &file->path[0];
-}
-
-void file_init(struct SimpleFile * file)
-{
-	file->path[0] = '\0';
-	file->is_readonly = 1;
-	file->size = 0;
-}
-
-void file_check_open(struct SimpleFile * file)
-{
-	if (openfile!=file)
-	{
-		file_write_flush();
-
-		pf_open(&file->path[0]);
-		openfile = file;
-	}
-}
-
-enum SimpleFileStatus file_read(struct SimpleFile * file, void * buffer, int bytes, int * bytesread)
-{
-	WORD bytesread_word;
-	FRESULT res;
-
-	file_write_flush();
-	file_check_open(file);
-
-	res = pf_read(buffer, bytes, &bytesread_word);
-	*bytesread = bytesread_word;
-
-	return translateStatus(res);
-}
-
-enum SimpleFileStatus file_write(struct SimpleFile * file, void * buffer, int bytes, int * byteswritten)
-{
-	WORD byteswritten_word;
-	FRESULT res;
-
-	//printf("went\n");
-	if (file->is_readonly) return SimpleFile_FAIL;
-
-	file_check_open(file);
-
-	int rem = bytes;
-	while (rem>0)
-	{
-		int sector = fatfs.fptr>>9;
-		int pos = fatfs.fptr&0x1ff;
-
-		int bytes_this_cycle = rem;
-		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);
-
-		if (sector != write_pending)
-		{
-			file_write_flush();
-		}
-
-		if (write_pending <0)
-		{
-			// read the sector into our 512 byte buffer...
-			pf_lseek(sector<<9);
-			int fptr = fatfs.fptr;
-
-			char temp_buffer[1];
-			pf_read(&temp_buffer[0], 1, &byteswritten_word);
-
-			//printf("Writing initial pos:%d\n",pos);
-
-			// seek to the initial pos
-			fatfs.fptr = fptr + pos;
-
-			write_pending = sector;
-		}
-
-		res = disk_writep(buffer, pos, bytes_this_cycle);
-
-		fatfs.fptr += bytes_this_cycle;
-		rem-=bytes_this_cycle;
-		buffer+=bytes_this_cycle;
-	}
-	*byteswritten = bytes;
-
-	//printf("wend\n");
-	return translateStatus(res);
-}
-
-enum SimpleFileStatus file_write_flush()
-{
-	if (write_pending >= 0)
-	{
-		//printf("wflush\n");
-		disk_writeflush();
-		write_pending = -1;
-	}
-	return SimpleFile_OK;
-}
-
-enum SimpleFileStatus file_seek(struct SimpleFile * file, int offsetFromStart)
-{
-	FRESULT res;
-
-	int location = offsetFromStart>>9;
-	if (write_pending >=0 && write_pending != offsetFromStart)
-	{
-		//printf("flush on seek\n");
-		file_write_flush();
-	}
-
-	file_check_open(file);
-
-	pf_lseek(offsetFromStart);
-	return translateStatus(res);
-}
-
-int file_size(struct SimpleFile * file)
-{
-	return file->size;
-}
-
-int file_readonly(struct SimpleFile * file)
-{
-	return file->is_readonly;
-}
-
-int file_struct_size()
-{
-	return sizeof(struct SimpleFile);
-}
-
-enum SimpleFileStatus file_open_name_in_dir(struct SimpleDirEntry * entry, char const * filename, struct SimpleFile * file)
-{
-	file_write_flush();
-
-	while (entry)
-	{
-		//printf("%s ",entry->filename_ptr);
-		if (0==stricmp(filename,entry->filename_ptr))
-		{
-			return file_open_dir(entry, file);
-		}
-		entry = entry->next;
-	}
-
-	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;
-
-	strcpy(&file->path[0],dir->path);
-	file->is_readonly = dir->is_readonly;
-	file->size = dir->size;
-
-	file_write_flush();
-
-	res = pf_open(&file->path[0]);
-	openfile = file;
-
-	return translateStatus(res);
-}
-
-enum SimpleFileStatus dir_init(void * mem, int space)
-{
-	FRESULT fres;
-	DSTATUS res;
-
-	write_pending = -1;
-
-	//printf("dir_init\n");
-
-	dir_cache = mem;
-	dir_cache_size = space;
-
-	//printf("disk_init go\n");
-	res = disk_initialize();
-	//printf("disk_init done\n");
-	if (res!=RES_OK) return translateDStatus(res);
-
-	//printf("pf_mount\n");
-	fres = pf_mount(&fatfs);
-	//printf("pf_mount done\n");
-
-	return translateStatus(fres);
-}
-
-// Read entire dir into memory (i.e. give it a decent chunk of sdram)
-struct SimpleDirEntry * dir_entries(char const * dirPath)
-{
-	return dir_entries_filtered(dirPath,0);
-}
-
-int dircmp(struct SimpleDirEntry * a, struct SimpleDirEntry * b)
-{
-	if (a->is_subdir==b->is_subdir)
-		return strcmp(a->lfn,b->lfn);
-	else
-		return a->is_subdir<b->is_subdir;
-}
-
-void sort_ll(struct SimpleDirEntry * h)
-{
-//struct SimpleDirEntry
-//{
-//	char path[MAX_PATH_LENGTH];
-//	char * filename_ptr;
-//	int size;
-//	int is_subdir;
-//	struct SimpleDirEntry * next; // as linked list - want to allow sorting...
-//};
-
-	struct SimpleDirEntry * p,*temp,*prev;
-	int i,j,n,sorted=0;
-	temp=h;
-	prev=0;
-	for(n=0;temp!=0;temp=temp->next) n++;
-
-	for(i=0;i<n-1 && !sorted;i++){
-		p=h;sorted=1;
-		prev=0;
-		for(j=0;j<n-(i+1);j++){
-	//		printf("p->issubdir:%d(%s) p->next->issubdir:%d(%s)",p->is_subdir,p->path,p->next->is_subdir,p->next->path);
-
-			if(dircmp(p,p->next)>0) {
-	//			printf("SWITCH!\n");
-				struct SimpleDirEntry * a = p;
-				struct SimpleDirEntry * b = p->next;
-				a->next=b->next;
-				b->next=a;
-				if (prev)
-					prev->next=b;
-				p=b;
-
-				sorted=0;
-			}
-			prev=p;
-			p=p->next;
-		}
-	}
-
-	//temp=h;
-	//for(n=0;temp!=0;temp=temp->next) printf("POST:%s\n",temp->path);
-}
-
-struct SimpleDirEntry * dir_entries_filtered(char const * dirPath,int(* filter)(struct SimpleDirEntry *))
-{
-	int room = dir_cache_size/sizeof(struct SimpleDirEntry);
-
-	file_write_flush();
-
-	printf("opendir ");
-	if (FR_OK != pf_opendir(&dir,dirPath))
-	{
-		//printf("FAIL ");
-		return 0;
-	}
-	printf("OK ");
-
-	struct SimpleDirEntry * prev = (struct SimpleDirEntry *)dir_cache;
-	strcpy(prev->path,"..");
-	strcpy(prev->lfn,"..");
-	prev->filename_ptr = prev->path;
-	prev->size = 0;
-	prev->is_subdir = 1;
-	prev->is_readonly = 1;
-	--room;
-
-	//int count=0;
-	struct SimpleDirEntry * entry = 0;
-	while (FR_OK == pf_readdir(&dir,&filinfo) && filinfo.fname[0]!='\0')
-	{
-		char * ptr;
-
-		if (filinfo.fattrib & AM_SYS)
-		{
-			continue;
-		}
-		if (filinfo.fattrib & AM_HID)
-		{
-			continue;
-		}
-
-		if (room)
-		{
-			entry = prev+1;
-			--room;
-		}
-		else
-		{
-			//printf("OUT of room!\n");
-			break; // OUT OF ROOM!
-		}
-
-		//printf("next %x %d ",entry,room);
-
-		entry->is_subdir = (filinfo.fattrib & AM_DIR) ? 1 : 0;
-		entry->is_readonly = (filinfo.fattrib & AM_RDO) ? 1 : 0;
-
-		printf("%s ",filinfo.fname);
-
-		strcpy(&entry->path[0],dirPath);
-		ptr = &entry->path[0];
-		ptr += strlen(&entry->path[0]);
-		*ptr++ = '/';
-		entry->filename_ptr = ptr;
-		strcpy(ptr,filinfo.fname);
-		entry->size = filinfo.fsize;
-
-		//printf("LFN:%s\n",&filinfo.lfname[0]);
-		strcpy(&entry->lfn[0],&filinfo.lfname[0]);
-
-		//int count;
-		//printf("%d %s %s\n",count++, filinfo.fname, filinfo.lfname);
-
-		entry->next = 0;
-
-		if (filter && !filter(entry))
-		{
-			continue;	
-		}
-
-		if (prev)
-			prev->next = entry;
-		prev = entry;
-
-		printf("n %d %d %x ",filinfo.fsize, entry->size, entry->next);
-	}
-
-	printf("dir_entries done ");
-
-	entry->next = 0;
-
-	/*struct SimpleDirEntry * begin = (struct SimpleDirEntry *) dir_cache;
-	int count = 0;
-	while (begin)
-	{
-		printf("%d %s\n",count++, begin->path);
-		begin = begin->next;
-	}*/
-
-	if (filter)
-	{
-		sort_ll((struct SimpleDirEntry *) dir_cache);
-	}
-	return (struct SimpleDirEntry *) dir_cache;
-}
-
-char const * dir_path(struct SimpleDirEntry * entry)
-{
-	return &entry->path[0];
-}
-
-char const * dir_filename(struct SimpleDirEntry * entry)
-{
-	//return entry->filename_ptr;
-	return &entry->lfn[0];
-}
-
-int dir_filesize(struct SimpleDirEntry * entry)
-{
-	return entry->size;
-}
-
-struct SimpleDirEntry * dir_next(struct SimpleDirEntry * entry)
-{
-	return entry->next;
-}
-
-int dir_is_subdir(struct SimpleDirEntry * entry)
-{
-	return entry->is_subdir;
-}
-
-
Index: firmware_5200/fat/pff.c
===================================================================
--- firmware_5200/fat/pff.c	(revision 191)
+++ firmware_5200/fat/pff.c	(nonexistent)
@@ -1,1148 +0,0 @@
-/*----------------------------------------------------------------------------/
-/  Petit FatFs - FAT file system module  R0.02a                (C)ChaN, 2010
-/-----------------------------------------------------------------------------/
-/ Petit FatFs module is an open source software to implement FAT file system to
-/ small embedded systems. This is a free software and is opened for education,
-/ research and commercial developments under license policy of following trems.
-/
-/  Copyright (C) 2010, ChaN, all right reserved.
-/
-/ * The Petit FatFs module is a free software and there is NO WARRANTY.
-/ * No restriction on use. You can use, modify and redistribute it for
-/   personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
-/ * Redistributions of source code must retain the above copyright notice.
-/
-/-----------------------------------------------------------------------------/
-/ Jun 15,'09  R0.01a  First release. (Branched from FatFs R0.07b.)
-/
-/ Dec 14,'09  R0.02   Added multiple code page support.
-/                     Added write funciton.
-/                     Changed stream read mode interface.
-/ Dec 07,'10  R0.02a  Added some configuration options.
-/                     Fixed fails to open objects with DBCS character.
-/----------------------------------------------------------------------------*/
-
-#include "pff.h"		/* Petit FatFs configurations and declarations */
-#include "diskio.h"		/* Declarations of low level disk I/O functions */
-//#include "printf.h"
-
-
-
-/*--------------------------------------------------------------------------
-
-   Module Private Definitions
-
----------------------------------------------------------------------------*/
-
-
-#if _FS_FAT32
-#define LD_CLUST(dir)	(((DWORD)LD_WORD(dir+DIR_FstClusHI)<<16) | LD_WORD(dir+DIR_FstClusLO))
-#else
-#define LD_CLUST(dir)	LD_WORD(dir+DIR_FstClusLO)
-#endif
-
-
-/*--------------------------------------------------------*/
-/* DBCS code ranges and SBCS extend char conversion table */
-
-#if _CODE_PAGE == 932	/* Japanese Shift-JIS */
-#define _DF1S	0x81	/* DBC 1st byte range 1 start */
-#define _DF1E	0x9F	/* DBC 1st byte range 1 end */
-#define _DF2S	0xE0	/* DBC 1st byte range 2 start */
-#define _DF2E	0xFC	/* DBC 1st byte range 2 end */
-#define _DS1S	0x40	/* DBC 2nd byte range 1 start */
-#define _DS1E	0x7E	/* DBC 2nd byte range 1 end */
-#define _DS2S	0x80	/* DBC 2nd byte range 2 start */
-#define _DS2E	0xFC	/* DBC 2nd byte range 2 end */
-
-#elif _CODE_PAGE == 936	/* Simplified Chinese GBK */
-#define _DF1S	0x81
-#define _DF1E	0xFE
-#define _DS1S	0x40
-#define _DS1E	0x7E
-#define _DS2S	0x80
-#define _DS2E	0xFE
-
-#elif _CODE_PAGE == 949	/* Korean */
-#define _DF1S	0x81
-#define _DF1E	0xFE
-#define _DS1S	0x41
-#define _DS1E	0x5A
-#define _DS2S	0x61
-#define _DS2E	0x7A
-#define _DS3S	0x81
-#define _DS3E	0xFE
-
-#elif _CODE_PAGE == 950	/* Traditional Chinese Big5 */
-#define _DF1S	0x81
-#define _DF1E	0xFE
-#define _DS1S	0x40
-#define _DS1E	0x7E
-#define _DS2S	0xA1
-#define _DS2E	0xFE
-
-#elif _CODE_PAGE == 437	/* U.S. (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 720	/* Arabic (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 737	/* Greek (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \
-				0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 775	/* Baltic (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 850	/* Multilingual Latin 1 (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \
-				0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 852	/* Latin 2 (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \
-				0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF}
-
-#elif _CODE_PAGE == 855	/* Cyrillic (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \
-				0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \
-				0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 857	/* Turkish (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \
-				0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 858	/* Multilingual Latin 1 + Euro (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \
-				0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 862	/* Hebrew (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 866	/* Russian (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 874	/* Thai (OEM, Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}
-
-#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \
-				0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF}
-
-#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \
-				0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}
-
-#elif _CODE_PAGE == 1253 /* Greek (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \
-				0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF}
-
-#elif _CODE_PAGE == 1254 /* Turkish (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \
-				0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}
-
-#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 1256 /* Arabic (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 1257 /* Baltic (Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}
-
-#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \
-				0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F}
-
-#elif _CODE_PAGE == 1	/* ASCII (for only non-LFN cfg) */
-#define _DF1S	0
-
-#else
-#error Unknown code page
-
-#endif
-
-
-
-/* Character code support macros */
-
-#define IsUpper(c)	(((c)>='A')&&((c)<='Z'))
-#define IsLower(c)	(((c)>='a')&&((c)<='z'))
-
-#if _DF1S		/* DBCS configuration */
-
-#ifdef _DF2S	/* Two 1st byte areas */
-#define IsDBCS1(c)	(((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
-#else			/* One 1st byte area */
-#define IsDBCS1(c)	((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
-#endif
-
-#ifdef _DS3S	/* Three 2nd byte areas */
-#define IsDBCS2(c)	(((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))
-#else			/* Two 2nd byte areas */
-#define IsDBCS2(c)	(((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
-#endif
-
-#else			/* SBCS configuration */
-
-#define IsDBCS1(c)	0
-#define IsDBCS2(c)	0
-
-#endif /* _DF1S */
-
-
-/* FatFs refers the members in the FAT structures with byte offset instead
-/ of structure member because there are incompatibility of the packing option
-/ between various compilers. */
-
-#define BS_jmpBoot			0
-#define BS_OEMName			3
-#define BPB_BytsPerSec		11
-#define BPB_SecPerClus		13
-#define BPB_RsvdSecCnt		14
-#define BPB_NumFATs			16
-#define BPB_RootEntCnt		17
-#define BPB_TotSec16		19
-#define BPB_Media			21
-#define BPB_FATSz16			22
-#define BPB_SecPerTrk		24
-#define BPB_NumHeads		26
-#define BPB_HiddSec			28
-#define BPB_TotSec32		32
-#define BS_55AA				510
-
-#define BS_DrvNum			36
-#define BS_BootSig			38
-#define BS_VolID			39
-#define BS_VolLab			43
-#define BS_FilSysType		54
-
-#define BPB_FATSz32			36
-#define BPB_ExtFlags		40
-#define BPB_FSVer			42
-#define BPB_RootClus		44
-#define BPB_FSInfo			48
-#define BPB_BkBootSec		50
-#define BS_DrvNum32			64
-#define BS_BootSig32		66
-#define BS_VolID32			67
-#define BS_VolLab32			71
-#define BS_FilSysType32		82
-
-#define MBR_Table			446
-
-#define	DIR_Name			0
-#define	DIR_Attr			11
-#define	DIR_NTres			12
-#define	DIR_CrtTime			14
-#define	DIR_CrtDate			16
-#define	DIR_FstClusHI		20
-#define	DIR_WrtTime			22
-#define	DIR_WrtDate			24
-#define	DIR_FstClusLO		26
-#define	DIR_FileSize		28
-
-
-
-/*--------------------------------------------------------------------------
-
-   Private Functions
-
----------------------------------------------------------------------------*/
-
-
-static
-FATFS *FatFs;	/* Pointer to the file system object (logical drive) */
-
-
-/* Fill memory */
-static
-void mem_set (void* dst, int val, int cnt) {
-	char *d = (char*)dst;
-	while (cnt--) *d++ = (char)val;
-}
-
-/* Compare memory to memory */
-static
-int mem_cmp (const void* dst, const void* src, int cnt) {
-	const char *d = (const char *)dst, *s = (const char *)src;
-	int r = 0;
-	while (cnt-- && (r = *d++ - *s++) == 0) ;
-	return r;
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* FAT access - Read value of a FAT entry                                */
-/*-----------------------------------------------------------------------*/
-
-static
-CLUST get_fat (	/* 1:IO error, Else:Cluster status */
-	CLUST clst	/* Cluster# to get the link information */
-)
-{
-	WORD wc, bc, ofs;
-	BYTE buf[4];
-	FATFS *fs = FatFs;
-
-
-	if (clst < 2 || clst >= fs->n_fatent)	/* Range check */
-		return 1;
-
-	switch (fs->fs_type) {
-#if _FS_FAT12
-	case FS_FAT12 :
-		bc = (WORD)clst; bc += bc / 2;
-		ofs = bc % 512; bc /= 512;
-		if (ofs != 511) {
-			if (disk_readp(buf, fs->fatbase + bc, ofs, 2)) break;
-		} else {
-			if (disk_readp(buf, fs->fatbase + bc, 511, 1)) break;
-			if (disk_readp(buf+1, fs->fatbase + bc + 1, 0, 1)) break;
-		}
-		wc = LD_WORD(buf);
-		return (clst & 1) ? (wc >> 4) : (wc & 0xFFF);
-#endif
-	case FS_FAT16 :
-		if (disk_readp(buf, fs->fatbase + clst / 256, (WORD)(((WORD)clst % 256) * 2), 2)) break;
-		return LD_WORD(buf);
-#if _FS_FAT32
-	case FS_FAT32 :
-		if (disk_readp(buf, fs->fatbase + clst / 128, (WORD)(((WORD)clst % 128) * 4), 4)) break;
-		return LD_DWORD(buf) & 0x0FFFFFFF;
-#endif
-	}
-
-	return 1;	/* An error occured at the disk I/O layer */
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Get sector# from cluster#                                             */
-/*-----------------------------------------------------------------------*/
-
-static
-DWORD clust2sect (	/* !=0: Sector number, 0: Failed - invalid cluster# */
-	CLUST clst		/* Cluster# to be converted */
-)
-{
-	FATFS *fs = FatFs;
-
-
-	clst -= 2;
-	if (clst >= (fs->n_fatent - 2)) return 0;		/* Invalid cluster# */
-	return (DWORD)clst * fs->csize + fs->database;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Directory handling - Rewind directory index                           */
-/*-----------------------------------------------------------------------*/
-
-static
-FRESULT dir_rewind (
-	DIR *dj			/* Pointer to directory object */
-)
-{
-	CLUST clst;
-	FATFS *fs = FatFs;
-
-
-	dj->index = 0;
-	clst = dj->sclust;
-	if (clst == 1 || clst >= fs->n_fatent)	/* Check start cluster range */
-		return FR_DISK_ERR;
-	if (_FS_FAT32 && !clst && fs->fs_type == FS_FAT32)	/* Replace cluster# 0 with root cluster# if in FAT32 */
-		clst = (CLUST)fs->dirbase;
-	dj->clust = clst;						/* Current cluster */
-	dj->sect = clst ? clust2sect(clst) : fs->dirbase;	/* Current sector */
-
-	return FR_OK;	/* Seek succeeded */
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Directory handling - Move directory index next                        */
-/*-----------------------------------------------------------------------*/
-
-static
-FRESULT dir_next2 (	/* FR_OK:Succeeded, FR_NO_FILE:End of table */
-	DIR *dj			/* Pointer to directory object */
-)
-{
-	CLUST clst;
-	WORD i;
-	FATFS *fs = FatFs;
-
-
-	i = dj->index + 1;
-	if (!i || !dj->sect)	/* Report EOT when index has reached 65535 */
-		return FR_NO_FILE;
-
-	if (!(i % 16)) {		/* Sector changed? */
-		dj->sect++;			/* Next sector */
-
-		if (dj->clust == 0) {	/* Static table */
-			if (i >= fs->n_rootdir)	/* Report EOT when end of table */
-				return FR_NO_FILE;
-		}
-		else {					/* Dynamic table */
-			if (((i / 16) & (fs->csize-1)) == 0) {	/* Cluster changed? */
-				clst = get_fat(dj->clust);		/* Get next cluster */
-				if (clst <= 1) return FR_DISK_ERR;
-				if (clst >= fs->n_fatent)		/* When it reached end of dynamic table */
-					return FR_NO_FILE;			/* Report EOT */
-				dj->clust = clst;				/* Initialize data for new cluster */
-				dj->sect = clust2sect(clst);
-			}
-		}
-	}
-
-	dj->index = i;
-
-	return FR_OK;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Directory handling - Find an object in the directory                  */
-/*-----------------------------------------------------------------------*/
-
-static
-FRESULT dir_find (
-	DIR *dj,		/* Pointer to the directory object linked to the file name */
-	BYTE *dir		/* 32-byte working buffer */
-)
-{
-	FRESULT res;
-	BYTE c;
-
-
-	res = dir_rewind(dj);			/* Rewind directory object */
-	if (res != FR_OK) return res;
-
-	do {
-		res = disk_readp(dir, dj->sect, (WORD)((dj->index % 16) * 32), 32)	/* Read an entry */
-			? FR_DISK_ERR : FR_OK;
-		if (res != FR_OK) break;
-		c = dir[DIR_Name];	/* First character */
-		if (c == 0) { res = FR_NO_FILE; break; }	/* Reached to end of table */
-		if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) /* Is it a valid entry? */
-			break;
-		res = dir_next2(dj);					/* Next entry */
-	} while (res == FR_OK);
-
-	return res;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Read an object from the directory                                     */
-/*-----------------------------------------------------------------------*/
-#if _USE_DIR
-static
-FRESULT dir_read (
-	DIR *dj,		/* Pointer to the directory object to store read object name */
-	BYTE *dir,		/* 32-byte working buffer */
-	BYTE *lfn_buffer        /* 256-byte lfn buffer */
-)
-{
-	FRESULT res;
-	BYTE a, c;
-
-
-	int lfn = 0;
-	char *lfn_pos = &lfn_buffer[255];
-	lfn_buffer[255] = '\0';
-
-	res = FR_NO_FILE;
-	while (dj->sect) {
-		res = disk_readp(dir, dj->sect, (WORD)((dj->index % 16) * 32), 32)	/* Read an entry */
-			? FR_DISK_ERR : FR_OK;
-
-		if (res != FR_OK) break;
-		c = dir[DIR_Name];
-		if (c == 0) { res = FR_NO_FILE; break; }	/* Reached to end of table */
-		a = dir[DIR_Attr] & AM_MASK;
-
-	//	printf("LFN2:%x:%x:%x:%x\n",a&AM_LFN==AM_LFN,dir[0],dir[0x1a],dir[0x1c]);
-		if (a&AM_LFN == AM_LFN && ((dir[0]&0xbf) < 16) && dir[0x1a]==0) // && dir[0x1c]!=0)
-		{
-			lfn_pos-=13;
-			char * ptr = lfn_pos;
-			int i;
-			for (i=1;i!=32;i+=2)
-			{
-				if (i==0xb) i=0xe;
-				if (i==0x1a) i=0x1c;
-				char b1 = dir[i];
-				char b2 = dir[i+1];
-				if (b2==0) *ptr++ = b1; else *ptr++ = '_';
-			}
-			//printf("LFN seq:%d %c%c%c%c%c%c%c%c%c%c%c%c%c \n",dir[0],dir[1],dir[3],dir[5],dir[7],dir[9],dir[14],dir[16],dir[18],dir[20],dir[22],dir[24],dir[28],dir[30]);
-			lfn = 1;
-		}
-
-		if (c != 0xE5 && c != '.' && !(a & AM_VOL))	/* Is it a valid entry? */
-			break;
-		res = dir_next2(dj);			/* Next entry */
-		if (res != FR_OK) break;
-	}
-
-	lfn_buffer[0] = '\0';
-	if (lfn)
-	{
-		strcpy(&lfn_buffer[0],lfn_pos);
-	}
-
-	if (res != FR_OK) dj->sect = 0;
-
-	return res;
-}
-#endif
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Pick a segment and create the object name in directory form           */
-/*-----------------------------------------------------------------------*/
-
-#ifdef _EXCVT
-	static const BYTE cvt[] = _EXCVT;
-#endif
-
-static
-FRESULT create_name (
-	DIR *dj,			/* Pointer to the directory object */
-	const char **path	/* Pointer to pointer to the segment in the path string */
-)
-{
-	BYTE c, d, ni, si, i, *sfn;
-	const char *p;
-
-	/* Create file name in directory form */
-	sfn = dj->fn;
-	mem_set(sfn, ' ', 11);
-	si = i = 0; ni = 8;
-	p = *path;
-	for (;;) {
-		c = p[si++];
-		if (c <= ' ' || c == '/') break;	/* Break on end of segment */
-		if (c == '.' || i >= ni) {
-			if (ni != 8 || c != '.') break;
-			i = 8; ni = 11;
-			continue;
-		}
-#ifdef _EXCVT
-		if (c >= 0x80)					/* To upper extended char (SBCS) */
-			c = cvt[c - 0x80];
-#endif
-		if (IsDBCS1(c) && i < ni - 1) {	/* DBC 1st byte? */
-			d = p[si++];				/* Get 2nd byte */
-			sfn[i++] = c;
-			sfn[i++] = d;
-		} else {						/* Single byte code */
-			if (IsLower(c)) c -= 0x20;	/* toupper */
-			sfn[i++] = c;
-		}
-	}
-	*path = &p[si];						/* Rerurn pointer to the next segment */
-
-	sfn[11] = (c <= ' ') ? 1 : 0;		/* Set last segment flag if end of path */
-
-	return FR_OK;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Get file information from directory entry                             */
-/*-----------------------------------------------------------------------*/
-#if _USE_DIR
-static
-void get_fileinfo (		/* No return code */
-	DIR *dj,			/* Pointer to the directory object */
-	BYTE *dir,			/* 32-byte working buffer */
-	FILINFO *fno	 	/* Pointer to store the file information */
-)
-{
-	BYTE i, c;
-	char *p;
-
-
-	p = fno->fname;
-	if (dj->sect) {
-		for (i = 0; i < 8; i++) {	/* Copy file name body */
-			c = dir[i];
-			if (c == ' ') break;
-			if (c == 0x05) c = 0xE5;
-			*p++ = c;
-		}
-		if (dir[8] != ' ') {		/* Copy file name extension */
-			*p++ = '.';
-			for (i = 8; i < 11; i++) {
-				c = dir[i];
-				if (c == ' ') break;
-				*p++ = c;
-			}
-		}
-		fno->fattrib = dir[DIR_Attr];				/* Attribute */
-		fno->fsize = LD_DWORD(dir+DIR_FileSize);	/* Size */
-		fno->fdate = LD_WORD(dir+DIR_WrtDate);		/* Date */
-		fno->ftime = LD_WORD(dir+DIR_WrtTime);		/* Time */
-	}
-	*p = 0;
-}
-#endif /* _USE_DIR */
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Follow a file path                                                    */
-/*-----------------------------------------------------------------------*/
-
-static
-FRESULT follow_path (	/* FR_OK(0): successful, !=0: error code */
-	DIR *dj,			/* Directory object to return last directory and found object */
-	BYTE *dir,			/* 32-byte working buffer */
-	const char *path	/* Full-path string to find a file or directory */
-)
-{
-	FRESULT res;
-
-
-	while (*path == ' ') path++;		/* Skip leading spaces */
-	if (*path == '/') path++;			/* Strip heading separator */
-	dj->sclust = 0;						/* Set start directory (always root dir) */
-
-	if ((BYTE)*path <= ' ') {			/* Null path means the root directory */
-		res = dir_rewind(dj);
-		dir[0] = 0;
-
-	} else {							/* Follow path */
-		for (;;) {
-			res = create_name(dj, &path);	/* Get a segment */
-			if (res != FR_OK) break;
-			res = dir_find(dj, dir);		/* Find it */
-			if (res != FR_OK) {				/* Could not find the object */
-				if (res == FR_NO_FILE && !*(dj->fn+11))
-					res = FR_NO_PATH;
-				break;
-			}
-			if (*(dj->fn+11)) break;		/* Last segment match. Function completed. */
-			if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow because it is a file */
-				res = FR_NO_PATH; break;
-			}
-			dj->sclust = LD_CLUST(dir);
-		}
-	}
-
-	return res;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Check a sector if it is an FAT boot record                            */
-/*-----------------------------------------------------------------------*/
-
-static
-BYTE check_fs (	/* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */
-	BYTE *buf,	/* Working buffer */
-	DWORD sect	/* Sector# (lba) to check if it is an FAT boot record or not */
-)
-{
-	if (disk_readp(buf, sect, 510, 2))		/* Read the boot sector */
-		return 3;
-	if (LD_WORD(buf) != 0xAA55)				/* Check record signature */
-		return 2;
-
-	if (!disk_readp(buf, sect, BS_FilSysType, 2) && LD_WORD(buf) == 0x4146)	/* Check FAT12/16 */
-		return 0;
-	if (_FS_FAT32 && !disk_readp(buf, sect, BS_FilSysType32, 2) && LD_WORD(buf) == 0x4146)	/* Check FAT32 */
-		return 0;
-	return 1;
-}
-
-
-
-
-/*--------------------------------------------------------------------------
-
-   Public Functions
-
---------------------------------------------------------------------------*/
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Mount/Unmount a Locical Drive                                         */
-/*-----------------------------------------------------------------------*/
-
-FRESULT pf_mount (
-	FATFS *fs		/* Pointer to new file system object (NULL: Unmount) */
-)
-{
-	BYTE fmt, buf[36];
-	DWORD bsect, fsize, tsect, mclst;
-
-
-	FatFs = 0;
-	if (!fs) return FR_OK;				/* Unregister fs object */
-
-	if (disk_initialize() & STA_NOINIT)	/* Check if the drive is ready or not */
-		return FR_NOT_READY;
-
-	/* Search FAT partition on the drive */
-	bsect = 0;
-	fmt = check_fs(buf, bsect);			/* Check sector 0 as an SFD format */
-	if (fmt == 1) {						/* Not an FAT boot record, it may be FDISK format */
-		/* Check a partition listed in top of the partition table */
-		if (disk_readp(buf, bsect, MBR_Table, 16)) {	/* 1st partition entry */
-			fmt = 3;
-		} else {
-			if (buf[4]) {					/* Is the partition existing? */
-				bsect = LD_DWORD(&buf[8]);	/* Partition offset in LBA */
-				fmt = check_fs(buf, bsect);	/* Check the partition */
-			}
-		}
-	}
-	if (fmt == 3) return FR_DISK_ERR;
-	if (fmt) return FR_NO_FILESYSTEM;	/* No valid FAT patition is found */
-
-	/* Initialize the file system object */
-	if (disk_readp(buf, bsect, 13, sizeof(buf))) return FR_DISK_ERR;
-
-	fsize = LD_WORD(buf+BPB_FATSz16-13);				/* Number of sectors per FAT */
-	if (!fsize) fsize = LD_DWORD(buf+BPB_FATSz32-13);
-
-	fsize *= buf[BPB_NumFATs-13];						/* Number of sectors in FAT area */
-	fs->fatbase = bsect + LD_WORD(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */
-	fs->csize = buf[BPB_SecPerClus-13];					/* Number of sectors per cluster */
-	fs->n_rootdir = LD_WORD(buf+BPB_RootEntCnt-13);		/* Nmuber of root directory entries */
-	tsect = LD_WORD(buf+BPB_TotSec16-13);				/* Number of sectors on the file system */
-	if (!tsect) tsect = LD_DWORD(buf+BPB_TotSec32-13);
-	mclst = (tsect						/* Last cluster# + 1 */
-		- LD_WORD(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16
-		) / fs->csize + 2;
-	fs->n_fatent = (CLUST)mclst;
-
-	fmt = FS_FAT16;							/* Determine the FAT sub type */
-	if (mclst < 0xFF7) 						/* Number of clusters < 0xFF5 */
-#if _FS_FAT12
-		fmt = FS_FAT12;
-#else
-		return FR_NO_FILESYSTEM;
-#endif
-	if (mclst >= 0xFFF7)					/* Number of clusters >= 0xFFF5 */
-#if _FS_FAT32
-		fmt = FS_FAT32;
-#else
-		return FR_NO_FILESYSTEM;
-#endif
-
-	fs->fs_type = fmt;		/* FAT sub-type */
-	if (_FS_FAT32 && fmt == FS_FAT32)
-		fs->dirbase = LD_DWORD(buf+(BPB_RootClus-13));	/* Root directory start cluster */
-	else
-		fs->dirbase = fs->fatbase + fsize;				/* Root directory start sector (lba) */
-	fs->database = fs->fatbase + fsize + fs->n_rootdir / 16;	/* Data start sector (lba) */
-
-	fs->flag = 0;
-	FatFs = fs;
-
-	return FR_OK;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Open or Create a File                                                 */
-/*-----------------------------------------------------------------------*/
-
-FRESULT pf_open (
-	const char *path	/* Pointer to the file name */
-)
-{
-	FRESULT res;
-	DIR dj;
-	BYTE sp[12], dir[32];
-	FATFS *fs = FatFs;
-
-
-	if (!fs)						/* Check file system */
-		return FR_NOT_ENABLED;
-
-	fs->flag = 0;
-	dj.fn = sp;
-	res = follow_path(&dj, dir, path);	/* Follow the file path */
-	if (res != FR_OK) return res;		/* Follow failed */
-	if (!dir[0] || (dir[DIR_Attr] & AM_DIR))	/* It is a directory */
-		return FR_NO_FILE;
-
-	fs->org_clust = LD_CLUST(dir);			/* File start cluster */
-	fs->fsize = LD_DWORD(dir+DIR_FileSize);	/* File size */
-	fs->fptr = 0;						/* File pointer */
-	fs->flag = FA_OPENED;
-
-	return FR_OK;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Read File                                                             */
-/*-----------------------------------------------------------------------*/
-#if _USE_READ
-
-FRESULT pf_read (
-	void* buff,		/* Pointer to the read buffer (NULL:Forward data to the stream)*/
-	WORD btr,		/* Number of bytes to read */
-	WORD* br		/* Pointer to number of bytes read */
-)
-{
-	DRESULT dr;
-	CLUST clst;
-	DWORD sect, remain;
-	WORD rcnt;
-	BYTE cs, *rbuff = (BYTE *)buff;
-	FATFS *fs = FatFs;
-
-
-	*br = 0;
-	if (!fs) return FR_NOT_ENABLED;		/* Check file system */
-	if (!(fs->flag & FA_OPENED))		/* Check if opened */
-		return FR_NOT_OPENED;
-
-	remain = fs->fsize - fs->fptr;
-	if (btr > remain) btr = (WORD)remain;			/* Truncate btr by remaining bytes */
-
-	while (btr)	{									/* Repeat until all data transferred */
-		if ((fs->fptr % 512) == 0) {				/* On the sector boundary? */
-			cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1));	/* Sector offset in the cluster */
-			if (!cs) {								/* On the cluster boundary? */
-				clst = (fs->fptr == 0) ?			/* On the top of the file? */
-					fs->org_clust : get_fat(fs->curr_clust);
-				if (clst <= 1) goto fr_abort;
-				fs->curr_clust = clst;				/* Update current cluster */
-			}
-			sect = clust2sect(fs->curr_clust);		/* Get current sector */
-			if (!sect) goto fr_abort;
-			fs->dsect = sect + cs;
-		}
-		rcnt = (WORD)(512 - (fs->fptr % 512));		/* Get partial sector data from sector buffer */
-		if (rcnt > btr) rcnt = btr;
-		dr = disk_readp(!buff ? 0 : rbuff, fs->dsect, (WORD)(fs->fptr % 512), rcnt);
-		if (dr) goto fr_abort;
-		fs->fptr += rcnt; rbuff += rcnt;			/* Update pointers and counters */
-		btr -= rcnt; *br += rcnt;
-	}
-
-	return FR_OK;
-
-fr_abort:
-	fs->flag = 0;
-	return FR_DISK_ERR;
-}
-#endif
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Write File                                                            */
-/*-----------------------------------------------------------------------*/
-#if _USE_WRITE
-
-FRESULT pf_write (
-	const void* buff,	/* Pointer to the data to be written */
-	WORD btw,			/* Number of bytes to write (0:Finalize the current write operation) */
-	WORD* bw			/* Pointer to number of bytes written */
-)
-{
-	CLUST clst;
-	DWORD sect, remain;
-	const BYTE *p = buff;
-	BYTE cs;
-	WORD wcnt;
-	FATFS *fs = FatFs;
-
-
-	*bw = 0;
-	if (!fs) return FR_NOT_ENABLED;		/* Check file system */
-	if (!(fs->flag & FA_OPENED))		/* Check if opened */
-		return FR_NOT_OPENED;
-
-	if (!btw) {		/* Finalize request */
-		if ((fs->flag & FA__WIP) && disk_writep(0, 0)) goto fw_abort;
-		fs->flag &= ~FA__WIP;
-		return FR_OK;
-	} else {		/* Write data request */
-		if (!(fs->flag & FA__WIP))		/* Round-down fptr to the sector boundary */
-			fs->fptr &= 0xFFFFFE00;
-	}
-	remain = fs->fsize - fs->fptr;
-	if (btw > remain) btw = (WORD)remain;			/* Truncate btw by remaining bytes */
-
-	while (btw)	{									/* Repeat until all data transferred */
-		if (((WORD)fs->fptr % 512) == 0) {			/* On the sector boundary? */
-			cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1));	/* Sector offset in the cluster */
-			if (!cs) {								/* On the cluster boundary? */
-				clst = (fs->fptr == 0) ?			/* On the top of the file? */
-					fs->org_clust : get_fat(fs->curr_clust);
-				if (clst <= 1) goto fw_abort;
-				fs->curr_clust = clst;				/* Update current cluster */
-			}
-			sect = clust2sect(fs->curr_clust);		/* Get current sector */
-			if (!sect) goto fw_abort;
-			fs->dsect = sect + cs;
-			if (disk_writep(0, fs->dsect)) goto fw_abort;	/* Initiate a sector write operation */
-			fs->flag |= FA__WIP;
-		}
-		wcnt = 512 - ((WORD)fs->fptr % 512);		/* Number of bytes to write to the sector */
-		if (wcnt > btw) wcnt = btw;
-		if (disk_writep(p, wcnt)) goto fw_abort;	/* Send data to the sector */
-		fs->fptr += wcnt; p += wcnt;				/* Update pointers and counters */
-		btw -= wcnt; *bw += wcnt;
-		if (((WORD)fs->fptr % 512) == 0) {
-			if (disk_writep(0, 0)) goto fw_abort;	/* Finalize the currtent secter write operation */
-			fs->flag &= ~FA__WIP;
-		}
-	}
-
-	return FR_OK;
-
-fw_abort:
-	fs->flag = 0;
-	return FR_DISK_ERR;
-}
-#endif
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Seek File R/W Pointer                                                 */
-/*-----------------------------------------------------------------------*/
-#if _USE_LSEEK
-
-FRESULT pf_lseek (
-	DWORD ofs		/* File pointer from top of file */
-)
-{
-	CLUST clst;
-	DWORD bcs, sect, ifptr;
-	FATFS *fs = FatFs;
-
-
-	if (!fs) return FR_NOT_ENABLED;		/* Check file system */
-	if (!(fs->flag & FA_OPENED))		/* Check if opened */
-			return FR_NOT_OPENED;
-
-	if (ofs > fs->fsize) ofs = fs->fsize;	/* Clip offset with the file size */
-	ifptr = fs->fptr;
-	fs->fptr = 0;
-	if (ofs > 0) {
-		bcs = (DWORD)fs->csize * 512;	/* Cluster size (byte) */
-		if (ifptr > 0 &&
-			(ofs - 1) / bcs >= (ifptr - 1) / bcs) {	/* When seek to same or following cluster, */
-			fs->fptr = (ifptr - 1) & ~(bcs - 1);	/* start from the current cluster */
-			ofs -= fs->fptr;
-			clst = fs->curr_clust;
-		} else {							/* When seek to back cluster, */
-			clst = fs->org_clust;			/* start from the first cluster */
-			fs->curr_clust = clst;
-		}
-		while (ofs > bcs) {				/* Cluster following loop */
-			clst = get_fat(clst);		/* Follow cluster chain */
-			if (clst <= 1 || clst >= fs->n_fatent) goto fe_abort;
-			fs->curr_clust = clst;
-			fs->fptr += bcs;
-			ofs -= bcs;
-		}
-		fs->fptr += ofs;
-		sect = clust2sect(clst);		/* Current sector */
-		if (!sect) goto fe_abort;
-		fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1));
-	}
-
-	return FR_OK;
-
-fe_abort:
-	fs->flag = 0;
-	return FR_DISK_ERR;
-}
-#endif
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Create a Directroy Object                                             */
-/*-----------------------------------------------------------------------*/
-#if _USE_DIR
-
-FRESULT pf_opendir (
-	DIR *dj,			/* Pointer to directory object to create */
-	const char *path	/* Pointer to the directory path */
-)
-{
-	FRESULT res;
-	BYTE sp[12], dir[32];
-	FATFS *fs = FatFs;
-
-
-	if (!fs) {				/* Check file system */
-		res = FR_NOT_ENABLED;
-	} else {
-		dj->fn = sp;
-		res = follow_path(dj, dir, path);		/* Follow the path to the directory */
-		if (res == FR_OK) {						/* Follow completed */
-			if (dir[0]) {						/* It is not the root dir */
-				if (dir[DIR_Attr] & AM_DIR)		/* The object is a directory */
-					dj->sclust = LD_CLUST(dir);
-				else							/* The object is not a directory */
-					res = FR_NO_PATH;
-			}
-			if (res == FR_OK)
-				res = dir_rewind(dj);			/* Rewind dir */
-		}
-		if (res == FR_NO_FILE) res = FR_NO_PATH;
-	}
-
-	return res;
-}
-
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Read Directory Entry in Sequense                                      */
-/*-----------------------------------------------------------------------*/
-
-FRESULT pf_readdir (
-	DIR *dj,			/* Pointer to the open directory object */
-	FILINFO *fno		/* Pointer to file information to return */
-)
-{
-	FRESULT res;
-	BYTE sp[12], dir[32];
-	FATFS *fs = FatFs;
-
-
-	if (!fs) {				/* Check file system */
-		res = FR_NOT_ENABLED;
-	} else {
-		dj->fn = sp;
-		if (!fno) {
-			res = dir_rewind(dj);
-		} else {
-			res = dir_read(dj, dir, &fno->lfname[0]);
-			if (res == FR_NO_FILE) {
-				dj->sect = 0;
-				res = FR_OK;
-			}
-			if (res == FR_OK) {				/* A valid entry is found */
-				get_fileinfo(dj, dir, fno);	/* Get the object information */
-				res = dir_next2(dj);			/* Increment index for next */
-				if (res == FR_NO_FILE) {
-					dj->sect = 0;
-					res = FR_OK;
-				}
-			}
-		}
-	}
-
-	if (fno->lfname[0] == '\0') strcpy(&fno->lfname[0],&fno->fname[0]);
-	//printf("%s %s(%d)\n",&fno->fname[0], &fno->lfname[0],strlen(&fno->lfname[0]));
-	return res;
-}
-
-#endif /* _USE_DIR */
-
Index: firmware_5200/main.c_DEBUG
===================================================================
--- firmware_5200/main.c_DEBUG	(revision 191)
+++ firmware_5200/main.c_DEBUG	(nonexistent)
@@ -1,515 +0,0 @@
-#include "integer.h"
-#include "regs.h"
-#include "pause.h"
-#include "printf.h"
-#include "joystick.h"
-
-#include "simpledir.h"
-#include "simplefile.h"
-#include "fileselector.h"
-
-#include "atari_drive_emulator.h"
-
-// FUNCTIONS in here
-// i) pff init - NOT USED EVERYWHERE
-// ii) file selector - kind of crap, no fine scrolling - NOT USED EVERYWHERE
-// iii) cold reset atari (clears base ram...)
-// iv) start atari (begins paused)
-// v) freeze/resume atari - NOT USED EVERYWHERE!
-// vi) menu for various options - NOT USED EVERYWHERE!
-// vii) pause - TODO - base this on pokey clock...
-
-// standard ZPU IN/OUT use...
-// OUT1 - 6502 settings (pause,reset,speed)
-// pause_n: bit 0 
-// reset_n: bit 1
-// turbo: bit 2-4: meaning... 0=1.79Mhz,1=3.58MHz,2=7.16MHz,3=14.32MHz,4=28.64MHz,5=57.28MHz,etc.
-// ram_select: bit 5-7: 
-//   		RAM_SELECT : in std_logic_vector(2 downto 0); -- 64K,128K,320KB Compy, 320KB Rambo, 576K Compy, 576K Rambo, 1088K, 4MB
-// rom_select: bit 8-13:
-//    		ROM_SELECT : in std_logic_vector(5 downto 0); -- 16KB ROM Bank
-
-#define BIT_REG(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-} \
-void set_ ## name(int param) \
-{ \
-	int val = *reg; \
-	 \
-	val = (val&~(mask<<shift)); \
-	val |= op(param)<<shift; \
-	 \
-	*reg = val; \
-}
-
-#define BIT_REG_RO(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-}
-
-BIT_REG(,0x1,0,pause_6502,zpu_out1)
-BIT_REG(,0x1,1,reset_6502,zpu_out1)
-BIT_REG(,0x3f,2,turbo_6502,zpu_out1)
-BIT_REG(,0x7,8,ram_select,zpu_out1)
-BIT_REG(,0x3f,11,rom_select,zpu_out1)
-
-BIT_REG_RO(,0x1,8,hotkey_softboot,zpu_in1)
-BIT_REG_RO(,0x1,9,hotkey_coldboot,zpu_in1)
-BIT_REG_RO(,0x1,10,hotkey_fileselect,zpu_in1)
-BIT_REG_RO(,0x1,11,hotkey_settings,zpu_in1)
-
-void
-wait_us(int unsigned num)
-{
-	// pause counter runs at pokey frequency - should be 1.79MHz
-	int unsigned cycles = (num*230)>>7;
-	*zpu_pause = cycles;
-}
-
-void memset8(void * address, int value, int length)
-{
-	char * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void memset32(void * address, int value, int length)
-{
-	int * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void clear_64k_ram()
-{
-	memset8((void *)0x200000, 0, 65536); // SRAM, if present (TODO)
-	memset32((void *)0x800000, 0, 16384);
-}
-
-void
-reboot(int cold)
-{
-	set_pause_6502(1);
-	if (cold)
-	{
-		clear_64k_ram();
-	}
-	set_reset_6502(1);
-	// Do nothing in here - this resets the memory controller!
-	set_reset_6502(0);
-	set_pause_6502(0);
-}
-
-unsigned char toatarichar(int val)
-{
-	int inv = val>=128;
-	if (inv)
-	{
-		val-=128;
-	}
-	if (val>='A' && val<='Z')
-	{
-		val+=-'A'+33;
-	}
-	else if (val>='a' && val<='z')
-	{
-		val+=-'a'+33+64;
-	}
-	else if (val>='0' && val<='9')
-	{
-		val+=-'0'+16;	
-	}
-	else if (val>=32 && val<=47)
-	{
-		val+=-32;
-	}
-	else
-	{
-		val = 0;
-	}
-	if (inv)
-	{
-		val+=128;
-	}
-	return val;
-}
-
-int debug_pos;
-int debug_adjust;
-unsigned char volatile * baseaddr;
-
-void clearscreen()
-{
-	unsigned volatile char * screen;
-	for (screen=(unsigned volatile char *)40000+atari_regbase; screen!=(unsigned volatile char *)(atari_regbase+40000+1024); ++screen)
-		*screen = 0x00;
-}
-
-void char_out ( void* p, char c)
-{
-	unsigned char val = toatarichar(c);
-	if (debug_pos>=0)
-	{
-		*(baseaddr+debug_pos) = val|debug_adjust;
-		++debug_pos;
-	}
-}
-
-// Memory usage...
-// 0x410000-0x41FFFF (0xc10000 in zpu space) = directory cache - 64k
-// 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)
-{
-	if (SimpleFile_OK == file_open_name(path, files[4]))
-	{
-		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)
-{
-	disk_initialize();
-	{
-		char buffer[512];
-		disk_readp(&buffer[0],0,0,512);
-		disk_readp(&buffer[0],1,0,512);
-		disk_readp(&buffer[0],0,0,512);
-
-		freeze_init((void*)0xc20000); // 128k
-	
-		debug_pos = -1;
-		debug_adjust = 0;
-		baseaddr = (unsigned char volatile *)(40000 + atari_regbase);
-		set_pause_6502(1);
-		set_reset_6502(1);
-		set_reset_6502(0);
-		set_turbo_6502(1);
-		set_rom_select(1);
-		set_ram_select(0);
-	
-		init_printf(0, char_out);
-		reboot(1);
-	//	for (;;);
-		wait_us(5000000);
-
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-
-		printf("Hello world");
-		debug_pos = 40;
-		hexdump_pure(0x4000,512);
-
-		for (;;);
-	}
-
-/*	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)
-	{
-		files[i] = (struct SimpleFile *)alloca(file_struct_size());
-		file_init(files[i]);
-	}
-
-	freeze_init((void*)0xc20000); // 128k
-
-	debug_pos = -1;
-	debug_adjust = 0;
-	baseaddr = (unsigned char volatile *)(40000 + atari_regbase);
-	set_reset_6502(1);
-	set_turbo_6502(1);
-	set_rom_select(2);
-	set_ram_select(2);
-
-	init_printf(0, char_out);
-
-	// TODO...
-
-	if (SimpleFile_OK == dir_init((void *)0xc10000, 65536))
-	{
-	//	printf("DIR init ok\n");
-		init_drive_emulator();
-
-		
-		struct SimpleDirEntry * entries = dir_entries("/system/rom/atari800");
-		
-		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
-		//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");
-	}
-	reboot(1);
-	for (;;) actions();
-}
-
-//		struct SimpleFile * file = alloca(file_struct_size());
-//		printf("Opening file\n");
-//		if (SimpleFile_OK == file_open_name("GUNPOWDR.ATR",file))
-//		{
-//			printf("FILE open ok\n");
-//
-//			set_drive_status(0,file);
-//
-//		}
-//		else
-//		{
-//			printf("FILE open failed\n");
-//		}
-
-char const * get_ram()
-{
-	switch(get_ram_select())
-	{
-	case 0:
-		return "64K";
-	case 1:
-		return "128K";
-	case 2:
-		return "320K(Compy)";
-	case 3:
-		return "320K(Rambo)";
-	case 4:
-		return "576K(Compy)";
-	case 5:
-		return "576K(Rambo)";
-	case 6:
-		return "1MB";
-	case 7:
-		return "4MB";
-	}
-}
-
-int settings()
-{
-	struct joystick_status joy;
-	joy.x_ = joy.y_ = joy.fire_ = 0;
-
-	int row = 0;
-
-	int done = 0;
-	for (;!done;)
-	{
-		// Render
-		clearscreen();
-		debug_pos = 0;
-		debug_adjust = 0;
-		printf("Se");
-		debug_adjust = 128;
-		printf("ttings");
-		debug_pos = 80;
-		debug_adjust = row==0 ? 128 : 0;
-		printf("Turbo:%dx", get_turbo_6502());
-		debug_pos = 120;
-		debug_adjust = row==1 ? 128 : 0;
-		printf("Ram:%s", get_ram());
-		debug_pos = 160;
-		debug_adjust = row==2 ? 128 : 0;
-		printf("Rom bank:%d", get_rom_select());
-		debug_pos = 240;
-		int i;
-		for (i=1;i!=5;++i)
-		{
-			int temp = debug_pos;
-			debug_adjust = row==i+2 ? 128 : 0;
-			char buffer[20];
-			describe_disk(i-1,&buffer[0]);
-			printf("Drive %d:%s %s", i, file_name(files[i-1]), &buffer[0]);
-			debug_pos = temp+40;
-		}
-
-		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
-		wait_us(100000);
-
-		// move
-		joystick_wait(&joy,WAIT_QUIET);
-		joystick_wait(&joy,WAIT_EITHER);
-
-		row+=joy.y_;
-		if (row<0) row = 0;
-		if (row>8) row = 8;
-		switch (row)
-		{
-		case 0:
-			{
-				int turbo = get_turbo_6502();
-				if (joy.x_==1) turbo<<=1;
-				if (joy.x_==-1) turbo>>=1;
-				if (turbo>16) turbo = 16;
-				if (turbo<1) turbo = 1;
-				set_turbo_6502(turbo);
-			}
-			break;
-		case 1:
-			{
-				int ram_select = get_ram_select();
-				ram_select+=joy.x_;
-				if (ram_select<0) ram_select = 0;
-				if (ram_select>7) ram_select = 7;
-				set_ram_select(ram_select);
-			}
-			break;
-		case 2:
-			{
-				int rom_select = get_rom_select();
-				rom_select+=joy.x_;
-				if (rom_select<1) rom_select = 1;
-				if (rom_select>6) rom_select = 6; // TODO
-				set_rom_select(rom_select);
-			}
-			break;
-		case 3:
-		case 4:
-		case 5:
-		case 6:
-			{
-				if (joy.x_>0)
-				{
-					// Choose new disk
-					filter = filter_disks;
-					file_selector(files[row-3]);
-					set_drive_status(row-3,files[row-3]);
-				}
-				else if(joy.x_<0)
-				{
-					// Remove disk
-					file_init(files[row-3]);
-					set_drive_status(row-3,0);
-				}
-				else if (joy.fire_)
-				{
-					files[0] = get_drive_status(row-3);
-					files[row-3] = get_drive_status(0);
-
-					set_drive_status(row-3,files[row-3]);
-					set_drive_status(0,files[0]);
-				}
-			}
-			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;
-			}
-			break;
-		}
-	}
-
-	return 0;
-}
-
-void actions()
-{
-	// Show some activity!
-	//*atari_colbk = *atari_random;
-	
-	// Hot keys
-	if (get_hotkey_softboot())
-	{
-		reboot(0);	
-	}
-	else if (get_hotkey_coldboot())
-	{
-		reboot(1);	
-	}
-	else if (get_hotkey_settings())
-	{
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-		int do_reboot = settings();
-		debug_pos = -1;
-		restore();
-		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();
-		set_drive_status(0,files[0]);
-		reboot(1);
-	}
-}
-
-
Index: firmware_5200/debug.h
===================================================================
--- firmware_5200/debug.h	(revision 191)
+++ firmware_5200/debug.h	(nonexistent)
@@ -1,20 +0,0 @@
-#ifndef debug_h
-#define debug_h
-
-void topofscreen();
-void setxpos(int val);
-void setypos(int val);
-unsigned char toatarichar(int val);
-unsigned char hextoatarichar(int val);
-void plot(unsigned char val, int x, int y);
-void plotnext(unsigned char val);
-void plotnextnumber(unsigned short val);
-void debugoffset(int x);
-void debug(char const * str);
-
-void hexdump(char const * str, int length);
-void hexdump_pure(char const * str, int length);
-
-void initdebug(int onoff_in);
-
-#endif //debug_h
Index: firmware_5200/Makefile
===================================================================
--- firmware_5200/Makefile	(revision 191)
+++ firmware_5200/Makefile	(nonexistent)
@@ -1,117 +0,0 @@
-BASE	= zpu-elf
-CC      = $(BASE)-gcc
-LD      = $(BASE)-gcc
-AS      = $(BASE)-as
-CP      = $(BASE)-objcopy
-DUMP    = $(BASE)-objdump
-
-# we use mincrt0.s from here
-STARTUP_DIR = .
-
-# we fetch ROM prologue / epilogue from here
-RTL_DIR = $(ZPUFLEXDIR)/RTL/
-
-
-BUILD_DIR=zpu_obj
-
-#MINSTARTUP_SRC = mincrt0.s
-MINSTARTUP_SRC = mycrt0.s
-MINSTARTUP_OBJ = $(patsubst $(STARTUP_DIR)/%.s,$(BUILD_DIR)/%.o,$(MINSTARTUP_SRC))
-
-AEON_LITE_PRJ = AEON_LITE
-AEON_LITE_SRC = main_aeon_lite.c regs.c freeze.c joystick.c fileutils.c fileselector.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c sd_direct/diskio_mmc.c sd_direct/spi.c sd_direct/mmc2.c de1/dirs.c
-AEON_LITE_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(AEON_LITE_SRC))
-
-DE1_PRJ = DE1
-DE1_SRC = main.c regs.c freeze.c joystick.c fileutils.c fileselector.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c sd_direct/diskio_mmc.c sd_direct/spi.c sd_direct/mmc2.c de1/dirs.c
-DE1_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(DE1_SRC))
-
-CHAMELEON_PRJ = CHAMELEON
-CHAMELEON_SRC = main.c regs.c freeze.c joystick.c fileutils.c fileselector.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c sd_direct/diskio_mmc.c sd_direct/spi.c sd_direct/mmc2.c chameleon/dirs.c
-CHAMELEON_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(CHAMELEON_SRC))
-
-MCC_PRJ = MCC216
-MCC_SRC = main.c regs.c freeze.c joystick.c fileutils.c fileselector.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c sd_direct/diskio_mmc.c sd_direct/spi.c sd_direct/mmc2.c mcc/dirs.c
-MCC_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(MCC_SRC))
-
-MIST_PRJ = MIST
-MIST_SRC = main.c regs.c freeze.c joystick.c fileutils.c fileselector.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c mist/diskio_sectorrequest.c mist/dirs.c
-MIST_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(MIST_SRC))
-
-LINKMAP  = ./standalone_simple.ld
-
-
-# Commandline options for each tool.
-
-#ZPUOPTS= -mno-poppcrel -mno-pushspadd -mno-callpcrel -mno-shortop -mno-neg # No-neg requires bugfixed toolchain
-#Include everything -> need to include emulation rom...
-ZPUOPTS =
-CFLAGS  = -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -Os $(ZPUOPTS) -DDISABLE_UART_RX
-
-LFLAGS  = -nostartfiles -Wl,--relax -g -Os
-#LFLAGS  = -nostartfiles -Os
-
-
-# Our target.
-all: mcc mist de1 aeon_lite chameleon 
-
-install:
-	cd ../common/romgen && ./createall && cd ../../firmware
-
-aeon_lite: $(BUILD_DIR) $(AEON_LITE_PRJ).bin $(AEON_LITE_PRJ).rpt
-
-de1: $(BUILD_DIR) $(DE1_PRJ).bin $(DE1_PRJ).rpt
-
-chameleon: $(BUILD_DIR) $(CHAMELEON_PRJ).bin $(CHAMELEON_PRJ).rpt
-
-mcc: $(BUILD_DIR) $(MCC_PRJ).bin $(MCC_PRJ).rpt
-
-mist: $(BUILD_DIR) $(MIST_PRJ).bin $(MIST_PRJ).rpt
-
-clean:
-	rm -rf $(BUILD_DIR)/* *.hex *.elf *.map *.lst *.srec *.bin *.rpt
-
-
-# Convert ELF binary to bin file.
-%.bin: %.elf
-	$(CP) -O binary $< $@
-
-%.rpt: %.elf
-	echo >$@ -n "End of code:\t"
-	$(DUMP) -x $< | grep >>$@ _romend
-	echo >>$@ -n "Start of BSS:\t"
-	$(DUMP) -x $< | grep  >>$@ __bss_start__
-	echo >>$@ -n "End of BSS:\t"
-	$(DUMP) -x $< | grep >>$@ __bss_end__
-	cat $@
-
-# Link - this produces an ELF binary.
-
-$(AEON_LITE_PRJ).elf: $(MINSTARTUP_OBJ) $(AEON_LITE_OBJ)
-	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
-
-$(DE1_PRJ).elf: $(MINSTARTUP_OBJ) $(DE1_OBJ)
-	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
-
-$(CHAMELEON_PRJ).elf: $(MINSTARTUP_OBJ) $(CHAMELEON_OBJ)
-	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
-
-$(MCC_PRJ).elf: $(MINSTARTUP_OBJ) $(MCC_OBJ)
-	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
-
-$(MIST_PRJ).elf: $(MINSTARTUP_OBJ) $(MIST_OBJ)
-	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
-
-$(BUILD_DIR)/%.o: %.c Makefile
-	mkdir -p `dirname $@`
-	$(CC) $(CFLAGS)  -o $@ -c $<
-
-$(BUILD_DIR)/%.o: %.s
-	$(AS) -o $@ $<
-
-$(BUILD_DIR)/%.o: $(STARTUP_DIR)/%.s
-	$(AS) -o $@ $<
-
-$(BUILD_DIR):
-	mkdir $(BUILD_DIR)
-
Index: firmware_5200/sdram_common/memory.h
===================================================================
--- firmware_5200/sdram_common/memory.h	(revision 191)
+++ firmware_5200/sdram_common/memory.h	(nonexistent)
@@ -1,12 +0,0 @@
-#pragma once
-
-// Memory usage...
-// 0x410000-0x44FFFF (0xc10000 in zpu space) = directory cache - 256k
-// 0x450000-0x46FFFF (0xc50000 in zpu space) = freeze backup
-// 0x700000-0x77FFFF (0xf00000 in zpu space) = os rom/basic rom
-
-#define DIR_INIT_MEM 0xc10000
-#define DIR_INIT_MEMSIZE 262144
-#define FREEZE_MEM 0xc50000
-#define ROM_MEM 0x700000
-
Index: firmware_5200/test_joy.c
===================================================================
--- firmware_5200/test_joy.c	(revision 191)
+++ firmware_5200/test_joy.c	(nonexistent)
@@ -1,83 +0,0 @@
-#include "joystick.h"
-
-#include <stdio.h>
-#include <poll.h>
-#include <termios.h>
-#include <unistd.h>
-
-extern char native_porta;
-extern char native_trig;
-
-void read_keys();
-
-struct termios oldt, newt;
-void term_init()
-{
-	tcgetattr(STDIN_FILENO, &oldt);
-	newt = oldt;
-	newt.c_lflag &= ~( ICANON | ECHO );
-	tcsetattr( STDIN_FILENO, TCSANOW, &newt);
-}
-
-void term_close()
-{
-	tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
-}
-
-int main(void)
-{
-	term_init();
-
-	fprintf(stderr,"Polling\n");
-	int i;
-	for (i=0;i!=200;++i)
-	{
-		struct joystick_status joy;
-		read_keys();
-		joystick_poll(&joy);
-
-		fprintf(stderr, "x:%d y:%d fire:%d\n", joy.x_, joy.y_, joy.fire_);
-
-		usleep(100000);
-	}
-
-
-//void joystick_poll(struct joystick_status * status);
-//void joystick_wait(struct joystick_status * status, enum JoyWait waitFor);
-
-	term_close();
-
-	return 0;
-}
-
-void read_keys()
-{
-	struct pollfd fds[1];
-	fds[0].fd = STDIN_FILENO;
-	fds[0].events = POLLIN;
-	native_porta = 0xff;
-	native_trig = 0xff;
-	while (poll(&fds[0], 1, 0))
-	{
-		char buffer[0];
-		read(0,&buffer[0],1);
-
-		if (buffer[0] == 0x41) fprintf(stderr, "UP\n");
-		if (buffer[0] == 0x42) fprintf(stderr, "DOWN\n");
-		if (buffer[0] == 0x44) fprintf(stderr, "LEFT\n");
-		if (buffer[0] == 0x43) fprintf(stderr, "RIGHT\n");
-		if (buffer[0] == 0x20) fprintf(stderr, "FIRE\n");
-
-		// RLDU
-		if (buffer[0] == 0x41) native_porta=0xff&~(1<<0);
-		if (buffer[0] == 0x42) native_porta=0xff&~(1<<1);
-		if (buffer[0] == 0x44) native_porta=0xff&~(1<<2);
-		if (buffer[0] == 0x43) native_porta=0xff&~(1<<3);
-		if (buffer[0] == 0x20) native_trig=0xff&~1;
-
-		fds[0].fd = STDIN_FILENO;
-		fds[0].events = POLLIN;
-	}
-}
-
-
Index: firmware_5200/fileutils.c
===================================================================
--- firmware_5200/fileutils.c	(revision 191)
+++ firmware_5200/fileutils.c	(nonexistent)
@@ -1,21 +0,0 @@
-#include "printf.h"
-
-#include "utils.h"
-
-int compare_ext(char const * filename, char const * ext)
-{
-	int dot = 0;
-	//printf("WTFA:%s %s\n",filenamein, extin);
-	//printf("WTFB:%s %s\n",filename, ext);
-
-	char const * end = strlen(filename) + filename;
-	while (--end != filename)
-	{
-		if (*end == '.')
-			break;
-	}
-	if (0==stricmp(end+1,ext)) return 1;
-
-	return 0;
-}
-
Index: firmware_5200/build_native_joystick
===================================================================
--- firmware_5200/build_native_joystick	(revision 191)
+++ firmware_5200/build_native_joystick	(nonexistent)
@@ -1 +0,0 @@
-gcc -g -O0 test_joy.c joystick.c native/regs.c -I.

Property changes on: firmware_5200/build_native_joystick
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/fileutils.h
===================================================================
--- firmware_5200/fileutils.h	(revision 191)
+++ firmware_5200/fileutils.h	(nonexistent)
@@ -1,4 +0,0 @@
-#pragma once
-
-int compare_ext(char const * filename, char const * ext);
-
Index: firmware_5200/pokey/uart.c
===================================================================
--- firmware_5200/pokey/uart.c	(revision 191)
+++ firmware_5200/pokey/uart.c	(nonexistent)
@@ -1,108 +0,0 @@
-#include "uart.h"
-
-#include "regs.h"
-
-void actions();
-
-int USART_Data_Needed()
-{
-	int needed = 0==(0x10&(*zpu_pokey_irqen));
-	if (needed)
-	{
-		*zpu_pokey_irqen = 0x28;
-		*zpu_pokey_irqen = 0x38;
-	}
-	return needed;
-}
-
-int USART_Data_Ready()
-{
-	int ready = 0==(0x20&(*zpu_pokey_irqen));
-	if (ready)
-	{
-		*zpu_pokey_irqen = 0x18;
-		*zpu_pokey_irqen = 0x38;
-	}
-	return ready;
-}
-
-void USART_Init( u08 value )
-{
-	// value is pokey div + 6
-	*zpu_pokey_skctl = 0;
-	wait_us(10);
-	USART_Receive_Mode(); // turn of reset and listen to commands
-	*zpu_pokey_audctl = 0x78; // linked channels, fast clocked
-	*zpu_pokey_audf1 = 0x00;
-	*zpu_pokey_audf0 = value-6;
-	*zpu_pokey_audf3 = 0x00;
-	*zpu_pokey_audf2 = value-6;
-
-	*zpu_pokey_irqen = 0x00;
-	*zpu_pokey_irqen = 0x38;
-}
-
-void USART_Transmit_Byte( unsigned char data )
-{
-	*zpu_pokey_serout = data;
-
-	// wait until next byte is needed 
-	while (!USART_Data_Needed());
-}
-unsigned char USART_Receive_Byte( void )
-{
-	// wait for data
-	while (!USART_Data_Ready())
-	{
-		actions();
-	}
-
-	u08 res = *zpu_pokey_serout; //serin at same address
-	return res;
-}
-
-void USART_Transmit_Mode()
-{
-	*zpu_pokey_skctl = 0x23; // 010 for transmission
-	*zpu_pokey_skrest = 0xff;
-	*zpu_pokey_irqen = 0x28; // clear data needed
-	*zpu_pokey_irqen = 0x38;
-}
-
-void USART_Receive_Mode()
-{
-	*zpu_pokey_skctl = 0x13; // 001 for receiving
-	*zpu_pokey_skrest = 0xff;
-}
-
-int USART_Framing_Error()
-{
-	if (0xc0&(*zpu_pokey_skctl))
-	{
-		return 0;
-	}
-	else
-	{
-		return 1;
-	}
-}
-
-void USART_Wait_Transmit_Complete()
-{
-	while (1)
-	{
-		int ready = 0==(0x08&(*zpu_pokey_irqen));
-		if (ready)
-		{
-			*zpu_pokey_irqen = 0x30;
-			*zpu_pokey_irqen = 0x38;
-			return;
-		}
-	}
-}
-
-int USART_Command_Line()
-{
-	return (1&(*zpu_sio));
-}
-
Index: firmware_5200/common/utils.c
===================================================================
--- firmware_5200/common/utils.c	(revision 191)
+++ firmware_5200/common/utils.c	(nonexistent)
@@ -1,50 +0,0 @@
-#include "utils.h"
-
-int strcmp(char const * a, char const * b)
-{
-	while (*a || *b)
-	{
-		if (*a<*b)
-			return -1;
-		else if (*a>*b)
-			return 1;
-
-		++a;
-		++b;
-	}
-	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++);
-}
-
-void stricpy(char * dest, char const * src)
-{
-	while (*src)
-	{
-		char val = *src++;
-		if (val>='A' && val<='Z') val+=-'A'+'a';
-
-		*dest++ = val;
-	}
-	*dest = '\0';
-}
-
-int strlen(char const * a)
-{
-	int count;
-	for (count=0; *a; ++a,++count);
-	return count;
-}
-
Index: firmware_5200/common/integer.h
===================================================================
--- firmware_5200/common/integer.h	(revision 191)
+++ firmware_5200/common/integer.h	(nonexistent)
@@ -1,30 +0,0 @@
-#ifndef _INTEGER
-#define _INTEGER
-
-/* These types must be 16-bit, 32-bit or larger integer */
-typedef int				INT;
-typedef unsigned int	UINT;
-
-/* These types must be 8-bit integer */
-typedef char			CHAR;
-typedef unsigned char	UCHAR;
-typedef unsigned char	BYTE;
-typedef unsigned char u08;
-typedef unsigned char uint8_t;
-
-/* These types must be 16-bit integer */
-typedef short			SHORT;
-typedef unsigned short	USHORT;
-typedef unsigned short	WORD;
-typedef unsigned short	WCHAR;
-typedef unsigned short u16;
-
-/* These types must be 32-bit integer */
-typedef long			LONG;
-typedef unsigned long	ULONG;
-typedef unsigned long	DWORD;
-typedef unsigned int u32;
-
-#define EEMEM
-
-#endif
Index: firmware_5200/common/utils.h
===================================================================
--- firmware_5200/common/utils.h	(revision 191)
+++ firmware_5200/common/utils.h	(nonexistent)
@@ -1,6 +0,0 @@
-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_5200/common/x
===================================================================
--- firmware_5200/common/x	(revision 191)
+++ firmware_5200/common/x	(nonexistent)
@@ -1,3 +0,0 @@
-g++: error: fat/pff_file.c: No such file or directory
-g++: fatal error: no input files
-compilation terminated.
Index: firmware_5200/chameleon/dirs.c
===================================================================
--- firmware_5200/chameleon/dirs.c	(revision 191)
+++ firmware_5200/chameleon/dirs.c	(nonexistent)
@@ -1,2 +0,0 @@
-char USER_DIR[]="/atari800/user";
-char ROM_DIR[]="/atari800/rom";
Index: firmware_5200/build_native_drive
===================================================================
--- firmware_5200/build_native_drive	(revision 191)
+++ firmware_5200/build_native_drive	(nonexistent)
@@ -1 +0,0 @@
-gcc -g -O0 -DLITTLE_ENDIAN test_drive.c fileutils.c atari_drive_emulator.c native/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c sd_direct/diskio_mmc.c native/mmc.c -I. -Iprintf -Ifat -Icommon

Property changes on: firmware_5200/build_native_drive
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/build
===================================================================
--- firmware_5200/build	(revision 191)
+++ firmware_5200/build	(nonexistent)
@@ -1,17 +0,0 @@
-zpu-elf-gcc -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -O2  -DDISABLE_UART_RX  -o zpu_obj/uart.o -c pokey/uart.c
-zpu-elf-gcc -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -O2  -DDISABLE_UART_RX  -o zpu_obj/hexdump.o -c hexdump.c
-zpu-elf-gcc -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -O2  -DDISABLE_UART_RX  -o zpu_obj/printf.o -c printf/printf.c
-zpu-elf-gcc -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -O2  -DDISABLE_UART_RX  -o zpu_obj/pff_file.o -c fat/pff_file.c
-zpu-elf-gcc -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -O2  -DDISABLE_UART_RX  -o zpu_obj/pff.o -c fat/pff.c
-zpu-elf-gcc -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -O2  -DDISABLE_UART_RX  -o zpu_obj/utils.o -c common/utils.c
-zpu-elf-gcc -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -O2  -DDISABLE_UART_RX  -o zpu_obj/diskio_mmc.o -c diskio_mmc.c
-zpu-elf-gcc -nostartfiles -Wl,--relax -g -Os -T ./standalone_simple.ld -o JustStartAtari.elf mycrt0.s zpu_obj/main.o zpu_obj/regs.o zpu_obj/atari_drive_emulator.o zpu_obj/pokey/uart.o zpu_obj/hexdump.o zpu_obj/printf/printf.o zpu_obj/fat/pff_file.o zpu_obj/fat/pff.o zpu_obj/common/utils.o zpu_obj/diskio_mmc.o 
-zpu-elf-objcopy -O binary JustStartAtari.elf JustStartAtari.bin
-echo >JustStartAtari.rpt -n "End of code:\t"
-zpu-elf-objdump -x JustStartAtari.elf | grep >>JustStartAtari.rpt _romend
-echo >>JustStartAtari.rpt -n "Start of BSS:\t"
-zpu-elf-objdump -x JustStartAtari.elf | grep  >>JustStartAtari.rpt __bss_start__
-echo >>JustStartAtari.rpt -n "End of BSS:\t"
-zpu-elf-objdump -x JustStartAtari.elf | grep >>JustStartAtari.rpt __bss_end__
-cat JustStartAtari.rpt
-

Property changes on: firmware_5200/build
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/standalone_simple.ld
===================================================================
--- firmware_5200/standalone_simple.ld	(revision 191)
+++ firmware_5200/standalone_simple.ld	(nonexistent)
@@ -1,59 +0,0 @@
-
-/* Memory Definitions for a ZPU program running either from external RAM (up to 8 meg).
-   or from unremapped Boot ROM / Stack RAM. */
-
-MEMORY
-{
-  CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x04000 /* 16k */
-  RAM (rx) : ORIGIN = 0x0000f000, LENGTH = 0x600 /* 32 bytes */
-}
-
-
-/* Section Definitions */
-
-SECTIONS
-{
-  /* first section is .fixed_vectors which is used for startup code */
-  . = 0x0000000;
-  .fixed_vectors :
-  {
-    *(.fixed_vectors)
-  }>CODE
-
-  /* Remaining code sections */
-  . = ALIGN(4);
-  .text :
-  {
-    *(.text)                   /* remaining code */
-  } >CODE
-
-  /* .rodata section which is used for read-only data (constants) */
-  . = ALIGN(4);
-  .rodata :
-  {
-    *(.rodata)
-  } >CODE
-  . = ALIGN(4);
-
-  /* .data section which is used for initialized data. */
-  . = ALIGN(4);
-  .data :
-  {
-    _data = . ;
-    *(.data)
-    SORT(CONSTRUCTORS)
-    . = ALIGN(4);
-  } >CODE
-  _romend = . ;
-
-  /* .bss section which is used for uninitialized data */
-  . = ALIGN(4);
-  .bss :
-  {
-    __bss_start = . ;
-    __bss_start__ = . ;
-    *(.bss)
-    *(COMMON)
-  } >RAM
-  __bss_end__ = . ;
-}
Index: firmware_5200/test_file.c
===================================================================
--- firmware_5200/test_file.c	(revision 191)
+++ firmware_5200/test_file.c	(nonexistent)
@@ -1,274 +0,0 @@
-#include "simpledir.h"
-#include "simplefile.h"
-#include "fileselector.h"
-
-//#include "fat/pff_file.h"
-// XXX - BEST NOT to include this?
-char USER_DIR[]="/";
-char ROM_DIR[]="/atari800/rom";
-
-#include "stdio.h"
-#include "stdlib.h"
-
-int debug_pos = 0;
-int prev_debug_pos = 0;
-int debug_adjust = 0;
-void wait_us(int us)
-{
-	usleep(us);
-}
-
-struct SimpleFile * file;
-#define ROM_MEM 0x700000
-
-void char_out ( void* p, char c)
-{
-	if (debug_pos!=prev_debug_pos)
-	{
-		fprintf(stderr,"\n");
-	}
-	//fprintf(stderr,"\n%dWTFWTF\n", debug_pos);
-	if (debug_adjust == 128)
-	{
-		putc('*',stderr);
-	}
-	putc(c, stderr);
-	++debug_pos;
-	prev_debug_pos = debug_pos;
-}
-
-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(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");
-	}
-}
-
-void loadosrom()
-{
-	if (file_size(file) == 0x0800)
-	{
-		printf("Hello world!\n");
-		int i=0;
-		unsigned char * src = (unsigned char *)(ROM_MEM + 0x4000);
-		unsigned char * dest1 = (unsigned char *)(ROM_MEM + 0x4800);
-		loadromfile(file,0x0800, (void *)(ROM_MEM + 0x4000));
-		for (i=0; i!=0x800; ++i)
-		{
-			dest1[i] = src[i];
-		}
-	}
-	else if (file_size(file) == 0x4000)
-	{
-		loadromfile(file,0x4000, (void *)(ROM_MEM + 0x4000));
-	}
-	else if (file_size(file) ==0x2800)
-	{
-		loadromfile(file,0x2800, (void *)(ROM_MEM + 0x5800));
-	}
-}
-
-int main(void)
-{
-	init_printf(NULL, char_out);
-
-	char * mem = (char *)malloc(65536);
-	if (SimpleFile_OK != dir_init(mem, 65536))
-	{
-		fprintf(stderr,"Failed to open dir!");
-		return -1;
-	}
-	struct SimpleDirEntry * entry = dir_entries("");
-	while (entry)
-	{
-		fprintf(stderr, "Path:%s", dir_path(entry));
-		fprintf(stderr, " Name:%s", dir_filename(entry));
-		fprintf(stderr, " Size:%d", dir_filesize(entry));
-		fprintf(stderr, " Subdir:%d\n", dir_is_subdir(entry));
-
-		entry = dir_next(entry);
-	}
-
-	fprintf(stderr,"\n\n");
-
-	entry = dir_entries("/atari800");
-	while (entry)
-	{
-		fprintf(stderr, "Path:%s", dir_path(entry));
-		fprintf(stderr, " Name:%s", dir_filename(entry));
-		fprintf(stderr, " Size:%d", dir_filesize(entry));
-		fprintf(stderr, " Subdir:%d\n", dir_is_subdir(entry));
-
-		entry = dir_next(entry);
-	}
-
-	fprintf(stderr,"\n\n");
-
-	entry = dir_entries("/atari800/user");
-	while (entry)
-	{
-		fprintf(stderr, "Path:%s", dir_path(entry));
-		fprintf(stderr, " Name:%s", dir_filename(entry));
-		fprintf(stderr, " Size:%d", dir_filesize(entry));
-		fprintf(stderr, " Subdir:%d\n", dir_is_subdir(entry));
-
-		entry = dir_next(entry);
-	}
-
-
-/*
-	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);
-	entry = dir_entries("/UAE4ALL");
-	entry = dir_next(entry);
-	fprintf(stderr, " Name:%s", dir_filename(entry));
-	struct SimpleFile * file = alloca(file_struct_size());
-	file_open_dir(entry,file);
-
-//char const * file_name(struct SimpleFile * file);
-//enum SimpleFileStatus file_read(struct SimpleFile * file, void * buffer, int bytes, int * bytesread);
-//enum SimpleFileStatus file_write(struct SimpleFile * file, void * buffer, int bytes, int * byteswritten);
-//enum SimpleFileStatus file_seek(struct SimpleFile * file, int offsetFromStart);
-//int file_size(struct SimpleFile * file);
-	fprintf(stderr, " Size:%d\n---\n", file_size(file));
-
-	int read = 0;
-	char buffer[2048];
-	file_seek(file,10);
-	file_read(file,&buffer[0],2048,&read);
-	int i;
-	for (i=0; i!=read; ++i)
-	{
-		//fprintf(stderr,"%02x", buffer[i]);
-		fprintf(stderr,"%c", buffer[i]);
-	}
-
-	fprintf(stderr,"\n\n");
-
-	int written;
-	file_seek(file,10);
-	file_write(file,"Mark",4,&written); // in order to write 'mark' as position 10...
-	//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);
-
-	printf("\n*** WTF:%s - %s - %s\n",file_name(file), file_of("/WTF"),file_of("/BLAH/BOOP"));
-
-	// So... for write can only seek to nearest 512...
-
-	fprintf(stderr,"\n\n");
-	file_seek(file,10);
-	file_read(file,&buffer[0],2048,&read);
-	for (i=0; i!=read; ++i)
-	{
-		//fprintf(stderr,"%02x", buffer[i]);
-		fprintf(stderr,"%c", buffer[i]);
-	}
-*/
-
-	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);
-
-	/*{
-		printf("WTF\n");
-		struct SimpleDirEntry * entries = dir_entries("/system/rom/atari800");
-		entries = dir_next(entries);
-		printf("WTF:%s\n",dir_filename(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("/atari800/user");
-	//entry = dir_next(entry);
-	//fprintf(stderr, " Name:%s", dir_filename(entry));
-	file = alloca(file_struct_size());
-	//file_open_name("/atari800/user/acid800.atr",file);
-	//fprintf(stderr, "XXX Name:%s", file_name(file));
-	filter = filter_disks;
-	//file_selector(file);
-
-	fprintf(stderr, "\n\n\n HERE WE GO!\n\n\n");
-
-	{
-		struct SimpleDirEntry * entries = dir_entries(ROM_DIR);
-
-		fprintf(stderr, "\n\n\n HERE WE GO! 222 \n\n\n");
-		
-		if (SimpleFile_OK == file_open_name_in_dir(entries, "5200.rom", file))
-		{
-			fprintf(stderr, "\n\n\n HERE WE GO! 333 \n\n\n");
-			loadosrom();
-		}
-	}
-
-	return 0;
-}
-
-
Index: firmware_5200/setup
===================================================================
--- firmware_5200/setup	(revision 191)
+++ firmware_5200/setup	(nonexistent)
@@ -1 +0,0 @@
-export PATH=${PATH}:/home/markw/fpga/zpugcc/toolchain/install/bin/
Index: firmware_5200/test_freeze.c
===================================================================
--- firmware_5200/test_freeze.c	(revision 191)
+++ firmware_5200/test_freeze.c	(nonexistent)
@@ -1,64 +0,0 @@
-#include "regs.h"
-
-#include "stdlib.h"
-#include "stdio.h"
-
-#undef atari_regbase
-static char * atari_regbase = (char *)malloc(65536);
-#undef atari_regmirror
-static char * atari_regmirror = (char *)malloc(65536);
-#include "freeze.h"
-#include "freeze.c"
-#include "regs.c"
-
-int main(void)
-{
-	char * buffer = (char *)malloc(1024*128);
-	freeze_init(buffer);
-
-	for (int i=0; i!=64*1024; ++i)
-	{
-		*((unsigned char *)(atari_regbase+i)) = i%256;
-	}
-	
-	for (int i=0;i!=0x10000;++i)
-	{
-		*((atari_regmirror+i)) = i%256-2;
-	}
-	freeze();
-	/*for (int i=0; i!=64*1024; ++i)
-	{
-		fprintf(stderr,"i:%x val:%x\n",i,*((unsigned char *)(buffer+i)));
-		if (i%256!=*((unsigned char *)(buffer+i)))
-		{
-			fprintf(stderr,"!!FAIL!%d %d %d", i, i%256, *(unsigned char *)(atari_regbase+i));
-			return -1;
-		}
-	}*/
-
-	for (int i=0;i!=0xd000; ++i)
-	{
-		*((atari_regbase+i)) = 0;
-	}
-	for (int i=0xd800;i!=0x10000; ++i)
-	{
-		*((atari_regbase+i)) = 0;
-	}
-	restore();
-
-	for (int i=0; i!=64*1024; ++i)
-	{
-		unsigned char exp = i%256;
-		if (i>=0xd000 && i<0xd800) exp-=2;
-		if (i>=0xd020 && i<0xd200) exp+=2;
-		if (i>=0xd220 && i<0xd400) exp+=2;
-		if (i>=0xd410 && i<0xd800) exp+=2;
-		if (exp!=*((unsigned char *)(atari_regbase+i)))
-		{
-			fprintf(stderr,"FAIL!addr:%x exp:%d got:%d", i, exp, *(unsigned char *)(atari_regbase+i));
-			return -1;
-		}
-	}
-	return 0;
-}
-
Index: firmware_5200/fileselector.c
===================================================================
--- firmware_5200/fileselector.c	(revision 191)
+++ firmware_5200/fileselector.c	(nonexistent)
@@ -1,219 +0,0 @@
-#include "simplefile.h"
-#include "simpledir.h"
-#include "joystick.h"
-#include "regs.h" // NO NEED!!! 
-#include "printf.h"
-#include "fileutils.h"
-
-extern int debug_pos; // ARG!
-extern int debug_adjust; // ARG!
-extern char USER_DIR[];
-
-// TODO!
-#define MAX_PATH_LENGTH (9*5 + 8+3+1 + 1) 
-
-int (* filter)(struct SimpleDirEntry * entry);
-
-int filter_disks(struct SimpleDirEntry * entry)
-{
-	if (dir_is_subdir(entry)) return 1;
-	char const * f = dir_filename(entry);
-	int res = (compare_ext(f,"ATR") || compare_ext(f,"XFD") || compare_ext(f,"XEX"));
-	printf("filter_disks:%s:%d\n",f,res);
-	return res;
-}
-
-int filter_roms(struct SimpleDirEntry * entry)
-{
-	if (dir_is_subdir(entry)) return 1;
-	char const * f = dir_filename(entry);
-	return (compare_ext(f,"ROM"));
-}
-
-int filter_bins(struct SimpleDirEntry * entry)
-{
-	if (dir_is_subdir(entry)) return 1;
-	char const * f = dir_filename(entry);
-	return (compare_ext(f,"BIN"));
-}
-
-void dir_of(char * dir, char const * path); // TODO - into simpledir
-
-void file_selector(struct SimpleFile * file)
-{
-	char dir[MAX_PATH_LENGTH];
-	if (file_name(file)[0] == '\0')
-	{
-		strcpy(&dir[0],USER_DIR);
-	}
-	else
-	{
-		dir_of(&dir[0],file_path(file));
-	}
-	for (;;)
-	{
-		struct SimpleDirEntry * entry = dir_entries_filtered(dir,filter);
-
-		// Count how many we have
-		int entries = 0;
-		struct SimpleDirEntry * temp_entry = entry;
-		while (temp_entry)
-		{
-			++entries;
-			temp_entry = dir_next(temp_entry);
-		}
-		//printf("Entries:%d\n",entries);
-
-		// Selected item
-		int pos = 0;
-		int prevstartpos = -1;
-
-		struct joystick_status joy;
-		joy.x_ = joy.y_ = joy.fire_ = 0;
-
-		for (;;)
-		{
-			if (pos<0) pos = 0;
-			if (pos>=entries) pos = entries-1;
-
-			// render
-			{
-				// find which chunk to render
-				int startpos = pos-10;
-				//printf("\nA pos:%d, startpos:%d\n",pos,startpos);
-				//startpos &= 0xfffffffe;
-				//printf("startpos:%d\n",startpos);
-				if (startpos<0) startpos=0;
-				//printf("pos:%d, startpos:%d\n",pos,startpos);
-
-				// get the dir entries for these
-				struct SimpleDirEntry * render_entry = entry;
-				int skip = startpos;
-				while (skip-->0)
-				{
-					render_entry =  dir_next(render_entry);
-				}
-
-				// clear the screen
-				if (startpos!=prevstartpos)
-				{
-					clearscreen();
-					prevstartpos = startpos;
-				}
-
-				// find selected entry
-				struct SimpleDirEntry * sel_entry = entry;
-				skip = pos;
-				while (skip-->0)
-				{
-					sel_entry =  dir_next(sel_entry);
-				}
-
-				// output the new entries
-				int line;
-				debug_pos = 0;
-				debug_adjust = 0;
-				printf("Choose ");
-				debug_adjust = 128;
-				printf("file");
-				debug_pos = 40;
-				int end = 22*40;
-				for (;;)
-				{
-					if (!render_entry) break;
-					
-					int prev_debug_pos = debug_pos;
-					if (render_entry == sel_entry)
-					{
-						debug_adjust = 128;
-					}
-					else
-					{
-						debug_adjust = 0;
-					}
-					if (dir_is_subdir(render_entry))
-					{
-						printf("DIR:");
-					}
-					printf("%s",dir_filename(render_entry));
-
-					render_entry = dir_next(render_entry);
-
-					while(prev_debug_pos<debug_pos)
-					{
-						prev_debug_pos+=40;
-					}
-					debug_pos = prev_debug_pos;
-					//printf("debug_pos:%d",debug_pos);
-					if (debug_pos>=end) break;
-				}
-
-				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",dir_is_subdir(sel_entry) ? "DIR":"", dir_filename(sel_entry));
-				}
-				int i;
-				for (i=0;i!=40;++i) printf(" ");
-			}
-
-			// Slow it down a bit
-			wait_us(100000);
-
-			// move
-			joystick_wait(&joy,WAIT_QUIET);
-			joystick_wait(&joy,WAIT_EITHER);
-			
-			if (joy.fire_)
-			{
-				int i = pos;
-				while(i--)
-				{
-					if (!entry) break;
-					entry = dir_next(entry);
-				}
-
-				if (entry)
-				{
-					if (!dir_is_subdir(entry))
-					{
-						file_open_dir(entry, file);
-						return;
-					}
-					else
-					{
-						char const *f = dir_filename(entry);
-						if (strcmp("..",f)==0)
-						{
-							int x = strlen(dir);
-							while (x-->0)
-							{
-								if (dir[x] == '/')
-								{
-									dir[x] = '\0';
-									break;
-								}
-							}
-							//printf("\nDIR UP! %s\n",dir);
-						}
-						else
-						{
-							//strcpy(dir + strlen(dir),"/");
-							//strcpy(dir + strlen(dir),f);
-							//printf("\nDIR DOWN:%s -> %s\n",f,dir);
-							strcpy(dir,dir_path(entry));
-						}
-					}
-					break;
-				}
-
-				return;
-			}
-			
-			pos += joy.x_*10;
-			pos += joy.y_;
-		}
-	}
-}
-
Index: firmware_5200/uart.h
===================================================================
--- firmware_5200/uart.h	(revision 191)
+++ firmware_5200/uart.h	(nonexistent)
@@ -1,25 +0,0 @@
-#ifndef UART_H
-#define UART_H
-
-#include "integer.h"
-
-// Might be simplest to use another Pokey as the UART...
-
-void USART_Init( u08 value ); // value is baud rate
-// must flush too
-
-void USART_Transmit_Byte( unsigned char data );
-unsigned char USART_Receive_Byte( void );
-
-int USART_Data_Ready();
-
-void USART_Transmit_Mode();
-void USART_Receive_Mode();
-
-int USART_Framing_Error();
-
-void USART_Wait_Transmit_Complete();
-
-int USART_Command_Line();
-
-#endif
Index: firmware_5200/printf/printf.c
===================================================================
--- firmware_5200/printf/printf.c	(revision 191)
+++ firmware_5200/printf/printf.c	(nonexistent)
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2004,2012 Kustaa Nyholm / SpareTimeLabs
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list 
- * of conditions and the following disclaimer.
- * 
- * Redistributions in binary form must reproduce the above copyright notice, this 
- * list of conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *  
- * Neither the name of the Kustaa Nyholm or SpareTimeLabs nor the names of its 
- * contributors may be used to endorse or promote products derived from this software 
- * without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- */
-
-#include "printf.h"
-
-typedef void (*putcf) (void*,char);
-static putcf stdout_putf;
-static void* stdout_putp;
-
-
-#ifdef PRINTF_LONG_SUPPORT
-
-static void uli2a(unsigned long int num, unsigned int base, int uc,char * bf)
-	{
-	int n=0;
-	unsigned int d=1;
-	while (num/d >= base)
-		d*=base;		 
-	while (d!=0) {
-		int dgt = num / d;
-		num%=d;
-		d/=base;
-		if (n || dgt>0|| d==0) {
-			*bf++ = dgt+(dgt<10 ? '0' : (uc ? 'A' : 'a')-10);
-			++n;
-			}
-		}
-	*bf=0;
-	}
-
-static void li2a (long num, char * bf)
-	{
-	if (num<0) {
-		num=-num;
-		*bf++ = '-';
-		}
-	uli2a(num,10,0,bf);
-	}
-
-#endif
-
-static void ui2a(unsigned int num, unsigned int base, int uc,char * bf)
-	{
-	int n=0;
-	unsigned int d=1;
-	while (num/d >= base)
-		d*=base;		
-	while (d!=0) {
-		int dgt = num / d;
-		num%= d;
-		d/=base;
-		if (n || dgt>0 || d==0) {
-			*bf++ = dgt+(dgt<10 ? '0' : (uc ? 'A' : 'a')-10);
-			++n;
-			}
-		}
-	*bf=0;
-	}
-
-static void i2a (int num, char * bf)
-	{
-	if (num<0) {
-		num=-num;
-		*bf++ = '-';
-		}
-	ui2a(num,10,0,bf);
-	}
-
-static int a2d(char ch)
-	{
-	if (ch>='0' && ch<='9') 
-		return ch-'0';
-	else if (ch>='a' && ch<='f')
-		return ch-'a'+10;
-	else if (ch>='A' && ch<='F')
-		return ch-'A'+10;
-	else return -1;
-	}
-
-static char a2i(char ch, char** src,int base,int* nump)
-	{
-	char* p= *src;
-	int num=0;
-	int digit;
-	while ((digit=a2d(ch))>=0) {
-		if (digit>base) break;
-		num=num*base+digit;
-		ch=*p++;
-		}
-	*src=p;
-	*nump=num;
-	return ch;
-	}
-
-static void putchw(void* putp,putcf putf,int n, char z, char* bf)
-	{
-	char fc=z? '0' : ' ';
-	char ch;
-	char* p=bf;
-	while (*p++ && n > 0)
-		n--;
-	while (n-- > 0) 
-		putf(putp,fc);
-	while ((ch= *bf++))
-		putf(putp,ch);
-	}
-
-void tfp_format(void* putp,putcf putf,char *fmt, va_list va)
-	{
-	char bf[12];
-    
-	char ch;
-
-
-	while ((ch=*(fmt++))) {
-		if (ch!='%') 
-			putf(putp,ch);
-		else {
-			char lz=0;
-#ifdef 	PRINTF_LONG_SUPPORT
-			char lng=0;
-#endif
-			int w=0;
-			ch=*(fmt++);
-			if (ch=='0') {
-				ch=*(fmt++);
-				lz=1;
-				}
-			if (ch>='0' && ch<='9') {
-				ch=a2i(ch,&fmt,10,&w);
-				}
-#ifdef 	PRINTF_LONG_SUPPORT
-			if (ch=='l') {
-				ch=*(fmt++);
-				lng=1;
-			}
-#endif
-			switch (ch) {
-				case 0: 
-					goto abort;
-				case 'u' : {
-#ifdef 	PRINTF_LONG_SUPPORT
-					if (lng)
-						uli2a(va_arg(va, unsigned long int),10,0,bf);
-					else
-#endif
-					ui2a(va_arg(va, unsigned int),10,0,bf);
-					putchw(putp,putf,w,lz,bf);
-					break;
-					}
-				case 'd' :  {
-#ifdef 	PRINTF_LONG_SUPPORT
-					if (lng)
-						li2a(va_arg(va, unsigned long int),bf);
-					else
-#endif
-					i2a(va_arg(va, int),bf);
-					putchw(putp,putf,w,lz,bf);
-					break;
-					}
-				case 'x': case 'X' : 
-#ifdef 	PRINTF_LONG_SUPPORT
-					if (lng)
-						uli2a(va_arg(va, unsigned long int),16,(ch=='X'),bf);
-					else
-#endif
-					ui2a(va_arg(va, unsigned int),16,(ch=='X'),bf);
-					putchw(putp,putf,w,lz,bf);
-					break;
-				case 'c' : 
-					putf(putp,(char)(va_arg(va, int)));
-					break;
-				case 's' : 
-					putchw(putp,putf,w,0,va_arg(va, char*));
-					break;
-				case '%' :
-					putf(putp,ch);
-				default:
-					break;
-				}
-			}
-		}
-	abort:;
-	}
-
-
-void init_printf(void* putp,void (*putf) (void*,char))
-	{
-	stdout_putf=putf;
-	stdout_putp=putp;
-	}
-
-void tfp_printf(char *fmt, ...)
-	{
-	va_list va;
-	va_start(va,fmt);
-	tfp_format(stdout_putp,stdout_putf,fmt,va);
-	va_end(va);
-	}
-
-static void putcp(void* p,char c)
-	{
-	*(*((char**)p))++ = c;
-	}
-
-
-
-void tfp_sprintf(char* s,char *fmt, ...)
-	{
-	va_list va;
-	va_start(va,fmt);
-	tfp_format(&s,putcp,fmt,va);
-	putcp(&s,0);
-	va_end(va);
-	}
-
-

Property changes on: firmware_5200/printf/printf.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/printf/printf.h
===================================================================
--- firmware_5200/printf/printf.h	(revision 191)
+++ firmware_5200/printf/printf.h	(nonexistent)
@@ -1,124 +0,0 @@
-/*
-File: printf.h
- 
-Copyright (c) 2004,2012 Kustaa Nyholm / SpareTimeLabs
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, 
-are permitted provided that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this list 
-of conditions and the following disclaimer.
-
-Redistributions in binary form must reproduce the above copyright notice, this 
-list of conditions and the following disclaimer in the documentation and/or other
-materials provided with the distribution.
- 
-Neither the name of the Kustaa Nyholm or SpareTimeLabs nor the names of its 
-contributors may be used to endorse or promote products derived from this software 
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
-OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-
-This library is realy just two files: 'printf.h' and 'printf.c'.
-
-They provide a simple and small (+200 loc) printf functionality to 
-be used in embedded systems.
-
-I've found them so usefull in debugging that I do not bother with a 
-debugger at all.
-
-They are distributed in source form, so to use them, just compile them 
-into your project. 
-
-Two printf variants are provided: printf and sprintf. 
-
-The formats supported by this implementation are: 'd' 'u' 'c' 's' 'x' 'X'.
-
-Zero padding and field width are also supported.
-
-If the library is compiled with 'PRINTF_SUPPORT_LONG' defined then the 
-long specifier is also
-supported. Note that this will pull in some long math routines (pun intended!)
-and thus make your executable noticably longer.
-
-The memory foot print of course depends on the target cpu, compiler and 
-compiler options, but a rough guestimate (based on a H8S target) is about 
-1.4 kB for code and some twenty 'int's and 'char's, say 60 bytes of stack space. 
-Not too bad. Your milage may vary. By hacking the source code you can 
-get rid of some hunred bytes, I'm sure, but personally I feel the balance of 
-functionality and flexibility versus  code size is close to optimal for
-many embedded systems.
-
-To use the printf you need to supply your own character output function, 
-something like :
-
-void putc ( void* p, char c)
-	{
-	while (!SERIAL_PORT_EMPTY) ;
-	SERIAL_PORT_TX_REGISTER = c;
-	}
-
-Before you can call printf you need to initialize it to use your 
-character output function with something like:
-
-init_printf(NULL,putc);
-
-Notice the 'NULL' in 'init_printf' and the parameter 'void* p' in 'putc', 
-the NULL (or any pointer) you pass into the 'init_printf' will eventually be 
-passed to your 'putc' routine. This allows you to pass some storage space (or 
-anything realy) to the character output function, if necessary. 
-This is not often needed but it was implemented like that because it made 
-implementing the sprintf function so neat (look at the source code).
-
-The code is re-entrant, except for the 'init_printf' function, so it 
-is safe to call it from interupts too, although this may result in mixed output. 
-If you rely on re-entrancy, take care that your 'putc' function is re-entrant!
-
-The printf and sprintf functions are actually macros that translate to 
-'tfp_printf' and 'tfp_sprintf'. This makes it possible
-to use them along with 'stdio.h' printf's in a single source file. 
-You just need to undef the names before you include the 'stdio.h'.
-Note that these are not function like macros, so if you have variables
-or struct members with these names, things will explode in your face.
-Without variadic macros this is the best we can do to wrap these
-fucnction. If it is a problem just give up the macros and use the
-functions directly or rename them.
-
-For further details see source code.
-
-regs Kusti, 23.10.2004
-*/
-
-
-#ifndef __TFP_PRINTF__
-#define __TFP_PRINTF__
-
-#include <stdarg.h>
-
-void init_printf(void* putp,void (*putf) (void*,char));
-
-void tfp_printf(char *fmt, ...);
-void tfp_sprintf(char* s,char *fmt, ...);
-
-void tfp_format(void* putp,void (*putf) (void*,char),char *fmt, va_list va);
-
-#define printf tfp_printf 
-#define sprintf tfp_sprintf 
-
-#endif
-
-
-

Property changes on: firmware_5200/printf/printf.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/build_native_file_test
===================================================================
--- firmware_5200/build_native_file_test	(revision 191)
+++ firmware_5200/build_native_file_test	(nonexistent)
@@ -1 +0,0 @@
-gcc -g -O0 printf/printf.c test_file.c fileutils.c fileselector.c fat/pff_file.c fat/pff.c common/utils.c native/regs.c native/joystick.c native/diskio_mmc.c native/mmc.c native/screen.c -I. -Ifat -Icommon -Iprintf

Property changes on: firmware_5200/build_native_file_test
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: firmware_5200/pause.h
===================================================================
--- firmware_5200/pause.h	(revision 191)
+++ firmware_5200/pause.h	(nonexistent)
@@ -1,6 +0,0 @@
-#ifndef PAUSE_H
-#define PAUSE_H
-
-void wait_us(int unsigned num);
-
-#endif
Index: firmware_5200/main.c
===================================================================
--- firmware_5200/main.c	(revision 191)
+++ firmware_5200/main.c	(nonexistent)
@@ -1,3 +0,0 @@
-#include "sdram_common/memory.h"
-#include "main_real.c"
-
Index: firmware_5200/TODO
===================================================================
--- firmware_5200/TODO	(revision 191)
+++ firmware_5200/TODO	(nonexistent)
@@ -1,6 +0,0 @@
-DONE i) Test writes at pf_file level on PC
-DONE! ii) When file selected, boot rather than just printing something!
-DONE iii) Add settings
-DONE iv) Try out writes on Atari side
-v) Check that read-only works...
-DONE!--vi) Show selected file clearly!
Index: firmware_5200/sdrive_parts/bootdump
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: firmware_5200/sdrive_parts/bootdump
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: firmware_5200/sdrive_parts/bootdump.c
===================================================================
--- firmware_5200/sdrive_parts/bootdump.c	(revision 191)
+++ firmware_5200/sdrive_parts/bootdump.c	(nonexistent)
@@ -1,23 +0,0 @@
-unsigned char boot_xex_loader[179] = {
-	0x72,0x02,0x5f,0x07,0xf8,0x07,0xa9,0x00,0x8d,0x04,0x03,0x8d,0x44,0x02,0xa9,0x07,
-	0x8d,0x05,0x03,0xa9,0x70,0x8d,0x0a,0x03,0xa9,0x01,0x8d,0x0b,0x03,0x85,0x09,0x60,
-	0x7d,0x8a,0x48,0x20,0x53,0xe4,0x88,0xd0,0xfa,0x68,0xaa,0x8c,0x8e,0x07,0xad,0x7d,
-	0x07,0xee,0x8e,0x07,0x60,0xa9,0x93,0x8d,0xe2,0x02,0xa9,0x07,0x8d,0xe3,0x02,0xa2,
-	0x02,0x20,0xda,0x07,0x95,0x43,0x20,0xda,0x07,0x95,0x44,0x35,0x43,0xc9,0xff,0xf0,
-	0xf0,0xca,0xca,0x10,0xec,0x30,0x06,0xe6,0x45,0xd0,0x02,0xe6,0x46,0x20,0xda,0x07,
-	0xa2,0x01,0x81,0x44,0xb5,0x45,0xd5,0x43,0xd0,0xed,0xca,0x10,0xf7,0x20,0xd2,0x07,
-	0x4c,0x94,0x07,0xa9,0x03,0x8d,0x0f,0xd2,0x6c,0xe2,0x02,0xad,0x8e,0x07,0xcd,0x7f,
-	0x07,0xd0,0xab,0xee,0x0a,0x03,0xd0,0x03,0xee,0x0b,0x03,0xad,0x7d,0x07,0x0d,0x7e,
-	0x07,0xd0,0x8e,0x20,0xd2,0x07,0x6c,0xe0,0x02,0x20,0xda,0x07,0x8d,0xe0,0x02,0x20,
-	0xda,0x07,0x8d,0xe1,0x02,0x2d,0xe0,0x02,0xc9,0xff,0xf0,0xed,0xa9,0x00,0x8d,0x8e,
-	0x07,0xf0,0x82 };
-
-int main(void)
-{
-	for (int i=0;i!=sizeof(boot_xex_loader);++i)
-	{
-		printf("%c",boot_xex_loader[i]);
-	}
-	return 0;
-}
-
Index: firmware_5200/sdrive_parts/bootloader
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: firmware_5200/sdrive_parts/bootloader
___________________________________________________________________
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: firmware_5200/fileselector.h
===================================================================
--- firmware_5200/fileselector.h	(revision 191)
+++ firmware_5200/fileselector.h	(nonexistent)
@@ -1,10 +0,0 @@
-#pragma once
-
-void file_selector(struct SimpleFile * file);
-
-int filter_disks(struct SimpleDirEntry * entry);
-int filter_roms(struct SimpleDirEntry * entry);
-int filter_bins(struct SimpleDirEntry * entry);
-
-extern int (* filter)(struct SimpleDirEntry * entry);
-
Index: firmware_5200/out
===================================================================
--- firmware_5200/out	(revision 191)
+++ firmware_5200/out	(nonexistent)
@@ -1,84 +0,0 @@
-In file included from fileutils.c:3:0:
-common/utils.h:3:6: warning: conflicting types for built-in function ‘strcpy’ [enabled by default]
- void strcpy(char * dest, char const * src);
-      ^
-common/utils.h:5:5: warning: conflicting types for built-in function ‘strlen’ [enabled by default]
- int strlen(char const * a);
-     ^
-fileselector.c: In function ‘file_selector’:
-fileselector.c:38:3: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default]
-   strcpy(&dir[0],USER_DIR);
-   ^
-fileselector.c:180:16: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
-        int x = strlen(dir);
-                ^
-fileselector.c:193:8: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default]
-        strcpy(dir + strlen(dir),"/");
-        ^
-fileselector.c:193:21: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
-        strcpy(dir + strlen(dir),"/");
-                     ^
-In file included from fat/pff_file.c:4:0:
-common/utils.h:3:6: warning: conflicting types for built-in function ‘strcpy’ [enabled by default]
- void strcpy(char * dest, char const * src);
-      ^
-common/utils.h:5:5: warning: conflicting types for built-in function ‘strlen’ [enabled by default]
- int strlen(char const * a);
-     ^
-fat/pff.c: In function ‘dir_read’:
-fat/pff.c:578:3: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default]
-   strcpy(&lfn_buffer[0],lfn_pos);
-   ^
-fat/pff.c: In function ‘pf_readdir’:
-fat/pff.c:1140:30: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default]
-  if (fno->lfname[0] == '\0') strcpy(&fno->lfname[0],&fno->fname[0]);
-                              ^
-In file included from common/utils.c:1:0:
-common/utils.h:3:6: warning: conflicting types for built-in function ‘strcpy’ [enabled by default]
- void strcpy(char * dest, char const * src);
-      ^
-common/utils.h:5:5: warning: conflicting types for built-in function ‘strlen’ [enabled by default]
- int strlen(char const * a);
-     ^
-/tmp/ccxbYgZ4.o: In function `mmcInit':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:48: undefined reference to `spiInit'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:50: undefined reference to `mmcChipSelect'
-/tmp/ccxbYgZ4.o: In function `mmcReset':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:62: undefined reference to `spiTransferFF'
-/tmp/ccxbYgZ4.o: In function `mmcSendCommand':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:124: undefined reference to `mmcChipSelect'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:132: undefined reference to `mmcChipSelect'
-/tmp/ccxbYgZ4.o: In function `mmcReadLoop':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:144: undefined reference to `spiReceiveData'
-/tmp/ccxbYgZ4.o: In function `mmcRead':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:169: undefined reference to `mmcChipSelect'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:177: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:186: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:187: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:192: undefined reference to `mmcChipSelect'
-/tmp/ccxbYgZ4.o: In function `mmcWrite':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:208: undefined reference to `mmcChipSelect'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:215: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:217: undefined reference to `spiTransferByte'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:221: undefined reference to `spiTransferByte'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:225: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:226: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:228: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:232: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:234: undefined reference to `mmcChipSelect'
-/tmp/ccxbYgZ4.o: In function `mmcCommand':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:245: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:247: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:248: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:249: undefined reference to `spiTransferFF'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:252: undefined reference to `spiTransferByte'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:254: undefined reference to `spiTransferByte'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:255: undefined reference to `spiTransferByte'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:256: undefined reference to `spiTransferByte'
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:257: undefined reference to `spiTransferByte'
-/tmp/ccxbYgZ4.o:/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:260: more undefined references to `spiTransferByte' follow
-/tmp/ccxbYgZ4.o: In function `mmcCommand':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/mmc.c:267: undefined reference to `spiTransferFF'
-/tmp/ccE4noa4.o: In function `disk_initialize':
-/home/markw/fpga/svn/repo/trunk/atari_800xl/firmware/sd_direct/diskio_mmc.c:54: undefined reference to `set_spi_clock_freq'
-collect2: error: ld returned 1 exit status
Index: firmware_5200/main_real.c
===================================================================
--- firmware_5200/main_real.c	(revision 191)
+++ firmware_5200/main_real.c	(nonexistent)
@@ -1,617 +0,0 @@
-#include "integer.h"
-#include "regs.h"
-#include "pause.h"
-#include "printf.h"
-#include "joystick.h"
-#include "freeze.h"
-
-#include "simpledir.h"
-#include "simplefile.h"
-#include "fileselector.h"
-
-void actions();
-
-extern char ROM_DIR[];
-
-// FUNCTIONS in here
-// i) pff init - NOT USED EVERYWHERE
-// ii) file selector - kind of crap, no fine scrolling - NOT USED EVERYWHERE
-// iii) cold reset atari (clears base ram...)
-// iv) start atari (begins paused)
-// v) freeze/resume atari - NOT USED EVERYWHERE!
-// vi) menu for various options - NOT USED EVERYWHERE!
-// vii) pause - TODO - base this on pokey clock...
-
-// standard ZPU IN/OUT use...
-// OUT1 - 6502 settings (pause,reset,speed)
-// pause_n: bit 0 
-// reset_n: bit 1
-// turbo: bit 2-4: meaning... 0=1.79Mhz,1=3.58MHz,2=7.16MHz,3=14.32MHz,4=28.64MHz,5=57.28MHz,etc.
-// ram_select: bit 5-7: 
-//   		RAM_SELECT : in std_logic_vector(2 downto 0); -- 64K,128K,320KB Compy, 320KB Rambo, 576K Compy, 576K Rambo, 1088K, 4MB
-// rom_select: bit 8-13:
-//    		ROM_SELECT : in std_logic_vector(5 downto 0); -- 16KB ROM Bank
-
-#define BIT_REG(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-} \
-void set_ ## name(int param) \
-{ \
-	int val = *reg; \
-	 \
-	val = (val&~(mask<<shift)); \
-	val |= op(param)<<shift; \
-	 \
-	*reg = val; \
-}
-
-#define BIT_REG_RO(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-}
-
-BIT_REG(,0x1,0,pause_6502,zpu_out1)
-BIT_REG(,0x1,1,reset_6502,zpu_out1)
-BIT_REG(,0x3f,2,turbo_6502,zpu_out1)
-BIT_REG(,0x7,8,ram_select,zpu_out1)
-BIT_REG(,0x3f,11,rom_select,zpu_out1)
-
-BIT_REG_RO(,0x1,8,hotkey_softboot,zpu_in1)
-BIT_REG_RO(,0x1,9,hotkey_coldboot,zpu_in1)
-BIT_REG_RO(,0x1,10,hotkey_fileselect,zpu_in1)
-BIT_REG_RO(,0x1,11,hotkey_settings,zpu_in1)
-
-void
-wait_us(int unsigned num)
-{
-	// pause counter runs at pokey frequency - should be 1.79MHz
-	int unsigned cycles = (num*230)>>7;
-	*zpu_pause = cycles;
-}
-
-void memset8(void * address, int value, int length)
-{
-	char * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void memset32(void * address, int value, int length)
-{
-	int * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void clear_64k_ram()
-{
-	memset8((void *)0x200000, 0, 16384); // SRAM, if present (TODO)
-	memset32((void *)0x800000, 0, 4096);
-}
-
-void
-reboot(int cold)
-{
-	set_pause_6502(1);
-	if (cold)
-	{
-		clear_64k_ram();
-	}
-	set_reset_6502(1);
-	// Do nothing in here - this resets the memory controller!
-	set_reset_6502(0);
-	set_pause_6502(0);
-}
-
-unsigned char toatarichar(int val)
-{
-	int inv = val>=128;
-	if (inv)
-	{
-		val-=128;
-	}
-	if (val>='A' && val<='Z')
-	{
-		val+=-'A'+33;
-	}
-	else if (val>='a' && val<='z')
-	{
-		val+=-'a'+33+64;
-	}
-	else if (val>='0' && val<='9')
-	{
-		val+=-'0'+16;	
-	}
-	else if (val>=32 && val<=47)
-	{
-		val+=-32;
-	}
-	else
-	{
-		val = 0;
-	}
-	if (inv)
-	{
-		val+=128;
-	}
-	return val;
-}
-
-int debug_pos;
-int debug_adjust;
-unsigned char volatile * baseaddr;
-
-void clearscreen()
-{
-	unsigned volatile char * screen;
-	for (screen=(unsigned volatile char *)11328+atari_regbase; screen!=(unsigned volatile char *)(atari_regbase+11328+1024); ++screen)
-		*screen = 0x00;
-}
-
-void char_out ( void* p, char c)
-{
-	unsigned char val = toatarichar(c);
-	if (debug_pos>=0)
-	{
-		*(baseaddr+debug_pos) = val|debug_adjust;
-		++debug_pos;
-	}
-}
-
-struct SimpleFile * files[6];
-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)
-{
-	if (SimpleFile_OK == file_open_name(path, files[4]))
-	{
-		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);
-	}
-}
-
-void loadosrom()
-{
-	int j=0;
-	if (file_size(files[5]) == 0x0800)
-	{
-		//wait_us(2000000);
-		//*atari_colbk = 0x48;
-
-		int i=0;
-		unsigned char * src = (unsigned char *)(ROM_MEM + 0x4000 + 0x800000);
-		unsigned char * dest1 = (unsigned char *)(ROM_MEM + 0x4800 + 0x800000);
-		loadromfile(files[5],0x0800, (void *)(ROM_MEM + 0x4000));
-
-		//wait_us(2000000);
-		//*atari_colbk = 0x58;
-
-		for (i=0; i!=0x800; ++i)
-		{
-			dest1[i] = src[i];
-		}
-
-	//	wait_us(2000000);
-	//	*atari_colbk = 0x68;
-	//	wait_us(2000000);
-	}
-	/*else if (file_size(files[5]) == 0x4000)
-	{
-		loadromfile(files[5],0x4000, (void *)(ROM_MEM + 0x4000));
-	}
-	else if (file_size(files[5]) ==0x2800)
-	{
-		loadromfile(files[5],0x2800, (void *)(ROM_MEM + 0x5800));
-	}*/
-}
-
-int main(void)
-{
-/*	disk_initialize();
-	{
-		char buffer[512];
-
-		freeze_init((void*)FREEZE_MEM); // 128k
-	
-		debug_pos = -1;
-		debug_adjust = 0;
-		baseaddr = (unsigned char volatile *)(11328 + atari_regbase);
-		set_pause_6502(1);
-		set_reset_6502(1);
-		set_reset_6502(0);
-		set_turbo_6502(1);
-		set_rom_select(1);
-		set_ram_select(0);
-	
-		init_printf(0, char_out);
-		reboot(1);
-	//	for (;;);
-		wait_us(5000000);
-
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-
-		printf("Hello world 3");
-		debug_pos = 40;
-		int i;
-		for (i=0;i!=512; ++i)
-		{
-			buffer[i] = i;
-		}
-		int volatile * x = (int volatile *)0x4000;
-		int volatile * y = (int volatile *)&buffer[0];
-		for (i=0;i!=128; ++i)
-		{
-			x[i] = y[i];
-		}
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 120;
-
-		printf(" Writing sector ");
-		n_actual_mmc_sector = 30;
-		disk_writeflush();
-		printf(" Wrote sector ");
-
-		for (i=0;i!=128; ++i)
-		{
-			x[i] = 0;
-		}
-		n_actual_mmc_sector = -1;
-		disk_readp(&buffer[0],30,0,512);
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 200;
-
-		disk_readp(&buffer[0],0x103,0,512);
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 280;
-
-		disk_readp(&buffer[0],0,0,512);
-		hexdump_pure(0x4000,8);
-		hexdump_pure(0x41f8,8);
-		debug_pos = 360;
-
-		printf("OK...");
-
-		//for (;;);
-		wait_us(10000000);
-	}*/
-
-/*	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!=6; ++i)
-	{
-		files[i] = (struct SimpleFile *)alloca(file_struct_size());
-		file_init(files[i]);
-	}
-
-	freeze_init((void*)FREEZE_MEM); // 128k
-
-	debug_pos = -1;
-	debug_adjust = 0;
-	baseaddr = (unsigned char volatile *)(11328 + atari_regbase);
-	set_pause_6502(1);
-	set_reset_6502(1);
-	set_reset_6502(0);
-	set_turbo_6502(1);
-	set_rom_select(1);
-	set_ram_select(2);
-
-	init_printf(0, char_out);
-
-	//wait_us(2000000);
-	//*atari_colbk = 0x38;
-
-	// TODO...
-
-	if (SimpleFile_OK == dir_init((void *)DIR_INIT_MEM, DIR_INIT_MEMSIZE))
-	{
-	//	printf("DIR init ok\n");
-	//	init_drive_emulator();
-
-		
-		struct SimpleDirEntry * entries = dir_entries(ROM_DIR);
-		
-		//loadrom_indir(entries,"atarixl.rom",0x4000, (void *)0x704000);
-		/*if (SimpleFile_OK == file_open_name_in_dir(entries, "atarixl.rom", files[5]))
-		{
-			loadosrom();
-		}*/
-
-		/*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 *)ROM_MEM);
-
-		if (SimpleFile_OK == file_open_name_in_dir(entries, "5200.rom", files[5]))
-		{
-			loadosrom();
-		}
-
-		loadrom_indir(entries,"acid5200.rom",0x8000,(void *)0x004000); // XXX - just for 5200 test... do not commit!
-
-		//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");
-	}
-	reboot(1);
-	for (;;) actions();
-}
-
-//		struct SimpleFile * file = alloca(file_struct_size());
-//		printf("Opening file\n");
-//		if (SimpleFile_OK == file_open_name("GUNPOWDR.ATR",file))
-//		{
-//			printf("FILE open ok\n");
-//
-//			set_drive_status(0,file);
-//
-//		}
-//		else
-//		{
-//			printf("FILE open failed\n");
-//		}
-
-char const * get_ram()
-{
-	return "16K";
-}
-
-int settings()
-{
-	struct joystick_status joy;
-	joy.x_ = joy.y_ = joy.fire_ = 0;
-
-	int row = 0;
-
-	int done = 0;
-	for (;!done;)
-	{
-		// Render
-		clearscreen();
-		debug_pos = 0;
-		debug_adjust = 0;
-		printf("Se");
-		debug_adjust = 128;
-		printf("ttings");
-		debug_pos = 80;
-		debug_adjust = row==0 ? 128 : 0;
-		printf("Turbo:%dx", get_turbo_6502());
-		debug_pos = 120;
-		debug_adjust = row==1 ? 128 : 0;
-		printf("Ram:%s", get_ram());
-		debug_pos = 160;
-		debug_adjust = row==2 ? 128 : 0;
-		{
-			printf("Rom:%s", file_name(files[5]));
-		}
-		int i;
-
-		debug_pos = 200;
-		debug_adjust = row==3 ? 128 : 0;
-		printf("Cartridge 32k");
-
-		debug_pos = 240;
-		debug_adjust = row==4 ? 128 : 0;
-		printf("Cartridge 16k one chip");
-
-		debug_pos = 280;
-		debug_adjust = row==5 ? 128 : 0;
-		printf("Cartridge 16k two chip");
-
-		debug_pos = 320;
-		debug_adjust = row==6 ? 128 : 0;
-		printf("Exit");
-
-		// Slow it down a bit
-		wait_us(100000);
-
-		// move
-		joystick_wait(&joy,WAIT_QUIET);
-		joystick_wait(&joy,WAIT_EITHER);
-
-		row+=joy.y_;
-		if (row<0) row = 0;
-		if (row>6) row = 6;
-		switch (row)
-		{
-		case 0:
-			{
-				int turbo = get_turbo_6502();
-				if (joy.x_==1) turbo<<=1;
-				if (joy.x_==-1) turbo>>=1;
-				if (turbo>16) turbo = 16;
-				if (turbo<1) turbo = 1;
-				set_turbo_6502(turbo);
-			}
-			break;
-		case 1:
-			{
-				int ram_select = get_ram_select();
-				ram_select+=joy.x_;
-				if (ram_select<0) ram_select = 0;
-				if (ram_select>7) ram_select = 7;
-				set_ram_select(ram_select);
-			}
-			break;
-		case 2:
-			{
-				if (joy.x_ || joy.fire_)
-				{
-					filter = filter_roms;
-					file_selector(files[5]);
-					loadosrom();
-				}
-			}
-			break;
-		case 3:
-		case 4:
-		case 5:
-			{
-				if (joy.fire_)
-				{
-					filter = filter_bins;
-					file_selector(files[4]);
-					//loadrom_indir(entries,"acid5200.rom",0x8000,(void *)0x004000); // XXX - just for 5200 test... do not commit!
-					if (row == 3)
-					{
-						//*atari_colbk = 0x48;
-						//wait_us(3000000);
-						loadromfile(files[4],0x8000,(void *)0x004000);
-					}
-					else if (row == 4)
-					{
-						//*atari_colbk = 0x58;
-						//wait_us(4000000);
-						loadromfile(files[4],0x4000,(void *)0x008000);
-						unsigned char * src = (unsigned char *)(0x8000 + 0x800000);
-						unsigned char * dest1 = (unsigned char *)(0x4000 + 0x800000);
-						int i = 0;
-						for (i=0; i!=0x4000; ++i)
-						{
-							dest1[i] = src[i];
-						}
-					}
-					else if (row == 5)
-					{
-						unsigned char * src = (unsigned char *)(0x4000 + 0x800000);
-						unsigned char * dest1 = (unsigned char *)(0x6000 + 0x800000);
-						unsigned char * src2 = (unsigned char *)(0x8000 + 0x800000);
-						unsigned char * dest2 = (unsigned char *)(0xa000+ 0x800000);
-						int i = 0;
-						//*atari_colbk = 0x68;
-						//wait_us(5000000);
-
-						loadromfile(files[4],0x2000,(void *)0x004000);
-						loadromfile(files[4],0x2000,(void *)0x008000);
-				
-						for (i=0; i!=0x2000; ++i)
-						{
-							dest1[i] = src[i];
-							dest2[i] = src2[i];
-						}
-					}
-					return 1;
-				}
-			}
-			break;
-		case 6:
-			if (joy.fire_)
-			{
-				done = 1;
-			}
-			break;
-		}
-	}
-
-	return 0;
-}
-
-void actions()
-{
-	// Show some activity!
-	//*atari_colbk = *atari_random;
-	
-	// Hot keys
-	if (get_hotkey_softboot())
-	{
-		reboot(0);	
-	}
-	else if (get_hotkey_coldboot())
-	{
-		reboot(1);	
-	}
-	else if (get_hotkey_settings())
-	{
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-		int do_reboot = settings();
-		debug_pos = -1;
-		restore();
-		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();
-		//set_drive_status(0,files[0]);
-		reboot(1);
-
-
-/*	disk_initialize();
-	{
-		char buffer[512];
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-
-		printf("Hello world 3");
-		debug_pos = 40;
-		n_actual_mmc_sector = -1;
-		disk_readp(&buffer[0],0,0,512);
-		hexdump_pure(&buffer[0],512);
-
-		wait_us(10000000);
-		restore();
-	}*/
-	}
-}
-
-
Index: firmware_5200/mist/diskio_sectorrequest.c
===================================================================
--- firmware_5200/mist/diskio_sectorrequest.c	(revision 191)
+++ firmware_5200/mist/diskio_sectorrequest.c	(nonexistent)
@@ -1,202 +0,0 @@
-#include "diskio.h"
-
-#include "regs.h"
-
-#include "printf.h"
-extern int debug_pos;
-
-void mmcReadCached(u32 sector);
-u32 n_actual_mmc_sector;
-unsigned char * mmc_sector_buffer;
-
-void mmcReadCached(u32 sector)
-{
-	//debug("mmcReadCached");
-	//plotnext(toatarichar(' '));
-	//plotnextnumber(sector);
-	//debug("\n");
-	if(sector==n_actual_mmc_sector) return;
-	//debug("mmcReadREAL");
-	//plotnext(toatarichar(' '));
-	//plotnextnumber(sector);
-	//debug("\n");
-
-	//u08 ret,retry;
-	//predtim nez nacte jiny, musi ulozit soucasny
-	// TODO mmcWriteCachedFlush();
-	//az ted nacte novy
-	//retry=0; //zkusi to maximalne 256x
-	/*do
-	{
-		ret = mmcRead(sector);	//vraci 0 kdyz ok
-		retry--;
-	} while (ret && retry);
-	while(ret); //a pokud se vubec nepovedlo, tady zustane zablokovany cely SDrive!
-*/
-
-	//printf("Reading sector:%d", sector);
-	*zpu_out4 = sector|0x04000000;
-	while (!*zpu_in4)
-	{
-		// Wait until ready
-	}
-	*zpu_out4 = 0;
-	//printf(" RD1 ");
-	while (*zpu_in4)
-	{
-		// Wait until ready cleared
-	}
-
-	//printf(" RD2 ");
-
-	n_actual_mmc_sector=sector;
-}
-
-
-/*-----------------------------------------------------------------------*/
-/* Initialize Disk Drive                                                 */
-/*-----------------------------------------------------------------------*/
-
-DSTATUS disk_initialize (void)
-{
-	DSTATUS stat;
-
-	n_actual_mmc_sector = 0xffffffff;
-	//do
-	//{
-	//	mmcInit();
-	//}
-	//while(mmcReset());	//dokud nenulove, tak smycka (return 0 => ok!)
-
-	//set_spi_clock_freq();
-
-	// no longer in ram (yet!), misuse will break us...
-	mmc_sector_buffer = (unsigned char *)0x4000;  // 512 bytes in the middle of memory space!
-
-	stat = RES_OK;
-
-	return stat;
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Read Partial Sector                                                   */
-/*-----------------------------------------------------------------------*/
-
-DRESULT disk_readp (
-	BYTE* dest,			/* Pointer to the destination object */
-	DWORD sector,		/* Sector number (LBA) */
-	WORD sofs,			/* Offset in the sector */
-	WORD count			/* Byte count (bit15:destination) */
-)
-{
-	DRESULT res;
-
-	/*debug("readp:");
-	plotnextnumber(sector);
-	debug(" ");
-	plotnextnumber((int)dest);
-	debug(" ");
-	plotnextnumber(sofs);
-	debug(" ");
-	plotnextnumber(count);
-	debug(" ");
-	plotnextnumber(atari_sector_buffer);
-	debug(" ");
-	plotnextnumber(mmc_sector_buffer);
-	debug("\n");
-	*/
-	// Put your code here
-	mmcReadCached(sector);
-	for(;count>0;++sofs,--count)
-	{
-		unsigned char x = mmc_sector_buffer[sofs];
-		//printf("char:%02x loc:%d", x,sofs);
-		*dest++ = x;
-	}
-
-	res = RES_OK;
-
-	return res;
-}
-
-
-
-/*-----------------------------------------------------------------------*/
-/* Write Partial Sector                                                  */
-/*-----------------------------------------------------------------------*/
-
-DRESULT disk_writep (const BYTE* buff, DWORD sofs, DWORD count)
-{
-	DRESULT res;
-
-	int i=sofs;
-	int end=sofs+count;
-	int pos = 0;
-
-/*	debug_pos = 0;
-	printf("WP:%x %d %d"),buff,sofs,count;
-	debug_pos = -1;*/
-
-	for (;i!=end;++i,++pos)
-	{
-                unsigned char temp = buff[pos];
-
-                unsigned int volatile* addr = (unsigned int volatile *)&mmc_sector_buffer[i&~3];
-                unsigned int prev = *(unsigned int volatile*)addr;
-                ((char unsigned *)&prev)[i&3] = temp;
-                *addr = prev;
-		
-		//mmc_sector_buffer[i] = buff[pos];
-		//printf("char:%c loc:%d,", buff[pos],i);
-	}
-
-/*	debug_pos = 40;
-	printf("WP DONE:%x %d %d"),buff,sofs,count;
-	debug_pos = -1;*/
-
-	res = RES_OK;
-
-	return res;
-}
-
-void disk_writeflush()
-{
-/*	// Finalize write process
-	int retry=16; //zkusi to maximalne 16x
-	int ret;
-	//printf(":WSECT:%d",n_actual_mmc_sector);
-	do
-	{
-		ret = mmcWrite(n_actual_mmc_sector); //vraci 0 kdyz ok
-		retry--;
-	} while (ret && retry);
-	//printf(":WD:");
-*/
-
-	/*debug_pos = 0;
-	printf("WF");
-	debug_pos = -1;*/
-
-	//printf(" WTF:%d:%x ", n_actual_mmc_sector, ((unsigned int *)mmc_sector_buffer)[0]);
-
-	*zpu_out4 = n_actual_mmc_sector|0x08000000;
-	while (!*zpu_in4)
-	{
-		// Wait until ready
-	}
-	*zpu_out4 = 0;
-	//printf(" PT1 ");
-	while (*zpu_in4)
-	{
-		// Wait until ready cleared
-	}
-
-	//printf(" PT2 ");
-
-	/*debug_pos = 40;
-	printf("DONE");
-	debug_pos = -1;*/
-}
-
Index: firmware_5200/mist/dirs.c
===================================================================
--- firmware_5200/mist/dirs.c	(revision 191)
+++ firmware_5200/mist/dirs.c	(nonexistent)
@@ -1,2 +0,0 @@
-char USER_DIR[]="/atari800/user";
-char ROM_DIR[]="/atari800/rom";
Index: firmware_5200/simpledir.h
===================================================================
--- firmware_5200/simpledir.h	(revision 191)
+++ firmware_5200/simpledir.h	(nonexistent)
@@ -1,24 +0,0 @@
-#pragma once
-
-#include "simplefile.h"
-
-// Extends simple dir with way of opening files and looking at dirs!
-// Not all systems provide this...
-
-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)
-enum SimpleFileStatus dir_init(void * mem, int space);
-struct SimpleDirEntry * dir_entries_filtered(char const * dirPath, int (*filter)(struct SimpleDirEntry *));
-struct SimpleDirEntry * dir_entries(char const * dirPath);
-
-char const * dir_filename(struct SimpleDirEntry *);
-char const * dir_path(struct SimpleDirEntry *);
-int dir_filesize(struct SimpleDirEntry *);
-struct SimpleDirEntry * dir_next(struct SimpleDirEntry *);
-int dir_is_subdir(struct SimpleDirEntry *);
-
Index: firmware_5200/mycrt0.s
===================================================================
--- firmware_5200/mycrt0.s	(revision 191)
+++ firmware_5200/mycrt0.s	(nonexistent)
@@ -1,976 +0,0 @@
-/* Startup code for ZPU
-   Copyright (C) 2005 Free Software Foundation, Inc.
-
-This file is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-In addition to the permissions in the GNU General Public License, the
-Free Software Foundation gives you unlimited permission to link the
-compiled version of this file with other programs, and to distribute
-those programs without any restriction coming from the use of this
-file.  (The General Public License restrictions do apply in other
-respects; for example, they cover modification of the file, and
-distribution when not linked into another program.)
-
-This file is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-	.file	"mincrt0.S"
-
-
-/* Minimal startup code, usable where the core is complete enough not to require emulated instructions */
-	
-
-	.section ".fixed_vectors","ax"
-; KLUDGE!!! we remove the executable bit to avoid relaxation 
-	.section ".fixed_vectors","a" 
-
-	.macro fixedim value
-			im \value
-	.endm
-
-	.macro  jmp address
-			fixedim \address
-			poppc
-	.endm
-
-	.macro fast_neg
-	not
-	im 1
-	add
-	.endm
-
-	.macro mult1bit
-	; create mask of lowest bit in A
-	loadsp 8 ; A
-	im 1
-	and
-	im -1
-	add
-	not
-	loadsp 8 ; B
-	and 
-	add ; accumulate in C
-	
-	; shift B left 1 bit
-	loadsp 4 ; B
-	addsp 0
-	storesp 8 ; B
-	
-	; shift A right 1 bit
-	loadsp 8 ; A
-	flip
-	addsp 0
-	flip
-	storesp 12 ; A
-	.endm
-
-	.macro cimpl funcname
-	; save R0
-	im _memreg
-	load
-	
-	; save R1
-	im _memreg+4
-	load
-	
-	; save R2
-	im _memreg+8
-	load
-	
-	loadsp 20
-	loadsp 20
-	
-	fixedim \funcname
-	call
-
-	; destroy arguments on stack
-	storesp 0
-	storesp 0	
-	 
-	im _memreg
-	load
-	
-	; poke the result into the right slot
-	storesp 24
-
-	; restore R2
-	im _memreg+8
-	store
-	
-	; restore R1
-	im _memreg+4
-	store
-	
-	; restore r0
-	im _memreg
-	store
-	
-	
-	storesp 4
-	poppc
-	.endm
-
-
-		.globl _start
-_start:
-		jmp _premain
-
-/* vectors */
-/* instruction emulation code */
-        nop
-        nop
-        nop
-	nop
-        nop
-        nop
-        nop
-        nop
-	nop
-        nop
-        nop
-        nop
-        nop
-        nop
-        nop
-	nop
-        nop
-        nop
-        nop
-        nop
-	nop
-        nop
-        nop
-        nop
-        nop
-        nop
-	nop
-        nop
-        nop
-        nop
-
-# opcode 34
-# offset 0x0000 0040
-	.balign 32,0
-_loadh:
-	loadsp 4
-	; by not masking out bit 0, we cause a memory access error 
-	; on unaligned access
-	im ~0x2
-	and
-	load
-
-	; mult 8	
-	loadsp 8
-	im 3
-	and
-	fast_neg
-	im 2
-	add
-	im 3
-	ashiftleft
-	; shift right addr&3 * 8
-	lshiftright
-	im 0xffff
-	and
-	storesp 8
-	
-	poppc
-
-# opcode 35
-# offset 0x0000 0060
-	.balign 32,0
-_storeh:
-	loadsp 4
-	; by not masking out bit 0, we cause a memory access error 
-	; on unaligned access
-	im ~0x2
-	and
-	load
-
-	; mask
-	im 0xffff
-	loadsp 12
-	im 3
-	and
-	fast_neg
-	im 2
-	add
-	im 3
-	ashiftleft
-	ashiftleft
-	not
-
-	and
-
-	loadsp 12
-	im 0xffff
-
-	nop
-		
-	fixedim _storehtail
-	poppc
-
-
-# opcode 36
-# offset 0x0000 0080
-	.balign 32,0
-_lessthan:
-	loadsp 8
-	fast_neg
-	loadsp 8
-	add
-
-	; DANGER!!!!
-	; 0x80000000 will overflow when negated, so we need to mask
-	; the result above with the compare positive to negative
-	; number case
-	loadsp 12
-	loadsp 12
-	not
-	and
-	not
-	and
-
-
-	; handle case where we are comparing a negative number
-	; and positve number. This can underflow. E.g. consider 0x8000000 < 0x1000
-	loadsp 12
-	not
-	loadsp 12
-	and
-	
-	or
-
-
-
-	flip
-	im 1
-	and	
-
-	
-	storesp 12
-	storesp 4
-	poppc
-	
-
-# opcode 37
-# offset 0x0000 00a0
-	.balign 32,0
-_lessthanorequal:
-	loadsp 8
-	loadsp 8
-	lessthan
-	loadsp 12
-	loadsp 12
-	eq
-	or
-	
-	storesp 12
-	storesp 4
-	poppc
-
-	
-# opcode 38
-# offset 0x0000 00c0
-	.balign 32,0
-_ulessthan:
-	; fish up arguments 
-	loadsp 4
-	loadsp 12
-	
-	/* low: -1 if low bit dif is negative 0 otherwise:  neg (not x&1 and (y&1))
-		x&1		y&1		neg (not x&1 and (y&1))
-		1		1		0
-		1		0 		0
-		0		1		-1
-		0		0		0
-	
-	*/
-	loadsp 4 
-	not
-	loadsp 4
-	and
-	im 1
-	and
-	neg
-	
-	
-	/* high: upper 31-bit diff is only wrong when diff is 0 and low=-1
-		high=x>>1 - y>>1 + low
-		
-		extremes
-		
-		0000 - 1111:
-		low= neg(not 0 and 1) = 1111 (-1)
-		high=000+ neg(111) +low = 000 + 1001 + low = 1000 
-		OK
-		
-		1111 - 0000
-		low=neg(not 1 and 0) = 0
-		high=111+neg(000) + low = 0111
-		OK
-		 
-		
-	 */
-	loadsp 8
-	
-	flip 
-	addsp 0
-	flip
-	
-	loadsp 8
-	
-	flip	
-	addsp 0
-	flip
-
-	sub
-
-	; if they are equal, then the last bit decides...	
-	add
-	
-	/* test if negative: result = flip(diff) & 1 */
-	flip
-	im 1
-	and
-
-	; destroy a&b which are on stack	
-	storesp 4
-	storesp 4
-	
-	storesp 12
-	storesp 4
-	poppc			
-
-# opcode 39
-# offset 0x0000 00e0
-	.balign 32,0
-_ulessthanorequal:
-	loadsp 8
-	loadsp 8
-	ulessthan
-	loadsp 12
-	loadsp 12
-	eq
-	or
-	
-	storesp 12
-	storesp 4
-	poppc
-
-
-# opcode 40
-# offset 0x0000 0100
-	.balign 32,0
-	.globl _swap
-_swap:
-	breakpoint ; tbd
-
-# opcode 41
-# offset 0x0000 0120
-	.balign 32,0
-_slowmult:
-	im _slowmultImpl
-	poppc
-
-# opcode 42
-# offset 0x0000 0140
-	.balign 32,0
-_lshiftright:
-	loadsp 8
-	flip
-
-	loadsp 8
-	ashiftleft
-	flip
-	
-	storesp 12
-	storesp 4
-
-	poppc
-	
-
-# opcode 43
-# offset 0x0000 0160
-	.balign 32,0
-_ashiftleft:
-	loadsp 8
-	
-	loadsp 8
-	im 0x1f
-	and
-	fast_neg
-	im _ashiftleftEnd
-	add
-	poppc
-	
-	
-	
-# opcode 44
-# offset 0x0000 0180
-	.balign 32,0
-_ashiftright:
-	loadsp 8
-	loadsp 8
-	lshiftright
-	
-	; handle signed value
-	im -1
-	loadsp 12
-	im 0x1f
-	and
-	lshiftright
-	not	; now we have an integer on the stack with the signed 
-		; bits in the right position
-
-	; mask these bits with the signed bit.
-	loadsp 16
-	not
-	flip
-	im 1
-	and
-	im -1
-	add
-	
-	and	
-	
-	; stuff in the signed bits...
-	or
-	
-	; store result into correct stack slot	
-	storesp 12
-	
-	; move up return value 
-	storesp 4
-	poppc
-
-# opcode 45
-# offset 0x0000 01a0
-	.balign 32,0
-_call:
-	; fn
-	loadsp 4
-	
-	; return address
-	loadsp 4
-
-	; store return address
-	storesp 12
-	
-	; fn to call
-	storesp 4
-	
-	pushsp	; flush internal stack
-	popsp
-		
-	poppc
-
-_storehtail:
-
-	and
-	loadsp 12
-	im 3
-	and
-	fast_neg
-	im 2
-	add
-	im 3
-	ashiftleft
-	nop
-	ashiftleft
-	
-	or
-	
-	loadsp 8
-	im  ~0x3
-	and
-
-	store
-	
-	storesp 4
-	storesp 4
-	poppc
-
-
-# opcode 46
-# offset 0x0000 01c0
-	.balign 32,0
-_eq:
-	loadsp 8
-	fast_neg
-	loadsp 8
-	add
-	
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-	im 1
-	and
-	
-	storesp 12
-	storesp 4
-	poppc
-
-# opcode 47
-# offset 0x0000 01e0
-	.balign 32,0
-_neq:
-	loadsp 8
-	fast_neg
-	loadsp 8
-	add
-	
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-
-	not
-
-	im 1
-	and
-		
-	storesp 12
-	storesp 4
-	poppc
-	
-
-# opcode 48
-# offset 0x0000 0200
-	.balign 32,0
-_neg:
-	loadsp 4
-	not
-	im 1
-	add
-	storesp 8
-	
-	poppc
-	
-
-# opcode 49
-# offset 0x0000 0220
-	.balign 32,0
-_sub:
-	loadsp 8
-	loadsp 8
-	fast_neg
-	add
-	storesp 12
-
-	storesp 4
-
-	poppc
-
-
-# opcode 50
-# offset 0x0000 0240
-	.balign 32,0
-_xor:
-	loadsp 8
-	not
-	loadsp 8
-	and
-	
-	loadsp 12
-	loadsp 12
-	not
-	and
-
-	or
-
-	storesp 12
-	storesp 4
-	poppc
-
-# opcode 51
-# offset 0x0000 0260
-	.balign 32,0
-_loadb:
-	loadsp 4
-	im ~0x3
-	and
-	load
-
-	loadsp 8
-	im 3
-	and
-	fast_neg
-	im 3
-	add
-	; x8
-	addsp 0
-	addsp 0
-	addsp 0
-
-	lshiftright
-
-	im 0xff
-	and
-	storesp 8
-	
-	poppc
-
-
-# opcode 52
-# offset 0x0000 0280
-	.balign 32,0
-_storeb:
-	loadsp 4
-	im ~0x3
-	and
-	load
-
-	; mask away destination
-	im _mask
-	loadsp 12
-	im 3
-	and
-	addsp 0
-	addsp 0
-	add
-	load
-
-	and
-
-
-	im _storebtail
-	poppc
-	
-# opcode 53
-# offset 0x0000 02a0
-	.balign 32,0
-_div:
-	jmp ___div
-	
-# opcode 54
-# offset 0x0000 02c0
-	.balign 32,0
-_mod:
-	jmp ___mod
-
-# opcode 55
-# offset 0x0000 02e0
-	.balign 32,0
-	.globl _eqbranch
-_eqbranch:
-	loadsp 8
-	
-	; eq
-
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-	im 1
-	and
-
-	; mask
-	im -1
-	add
-	loadsp 0
-	storesp 16
-
-	; no branch address
-	loadsp 4
-	
-	and
-
-	; fetch boolean & neg mask
-	loadsp 12
-	not
-	
-	; calc address & mask for branch
-	loadsp 8
-	loadsp 16
-	add
-	; subtract 1 to find PC of branch instruction
-	im -1
-	add
-	
-	and
-
-	or	
-	
-	storesp 4
-	storesp 4
-	storesp 4
-	poppc	
-
-
-# opcode 56
-# offset 0x0000 0300
-	.balign 32,0
-	.globl _neqbranch
-_neqbranch:
-	loadsp 8
-	
-	; neq
-
-	not 
-	loadsp 0
-	im 1
-	add
-	not
-	and
-	flip
-	
-	not
-	
-	im 1
-	and
-
-	; mask
-	im -1
-	add
-	loadsp 0
-	storesp 16
-
-	; no branch address
-	loadsp 4
-	
-	and
-
-	; fetch boolean & neg mask
-	loadsp 12
-	not
-	
-	; calc address & mask for branch
-	loadsp 8
-	loadsp 16
-	add
-	; find address of branch instruction
-	im -1
-	add
-	
-	and
-
-	or	
-	
-	storesp 4
-	storesp 4
-	storesp 4
-	poppc	
-
-# opcode 57
-# offset 0x0000 0320
-	.balign 32,0
-	.globl _poppcrel
-_poppcrel:
-	add
-	; address of poppcrel
-	im -1
-	add
-	poppc
-		
-# opcode 58
-# offset 0x0000 0340
-	.balign 32,0
-	.globl _config
-_config:
-	im 1 
-	nop
-	im _hardware
-	store
-	storesp 4
-	poppc
-
-# opcode 59
-# offset 0x0000 0360
-	.balign 32,0
-_pushpc:
-	loadsp 4
-	im 1
-	add 
-	storesp 8
-	poppc
-	
-# opcode 60
-# offset 0x0000 0380
-	.balign 32,0
-_syscall_emulate:
-	.byte 0
-	
-# opcode 61
-# offset 0x0000 03a0
-	.balign 32,0
-_pushspadd:
-	pushsp
-	im 4
-	add
-	loadsp 8
-	addsp 0
-	addsp 0
-	add
-	storesp 8
-	
-	poppc
-
-# opcode 62
-# offset 0x0000 03c0
-	.balign 32,0
-_halfmult:
-	breakpoint
-	
-# opcode 63
-# offset 0x0000 03e0
-	.balign 32,0
-_callpcrel:
-	loadsp 4
-	loadsp 4
-	add
-	im -1
-	add
-	loadsp 4
-	
-	storesp 12	; return address
-	storesp 4 
-	pushsp		; this will flush the internal stack.
-	popsp
-	poppc
-
-	.text
-
-	
-
-
-_ashiftleftBegin:
-	.rept 0x1f
-	addsp 0
-	.endr
-_ashiftleftEnd:
-	storesp 12
-	storesp 4
-	poppc
-	
-_storebtail:
-	loadsp 12
-	im 0xff
-	and
-	loadsp 12
-	im 3
-	and
-
-	fast_neg
-	im 3
-	add
-	; x8
-	addsp 0
-	addsp 0
-	addsp 0
-
-	ashiftleft
-	 
-	or
-	
-	loadsp 8
-	im  ~0x3
-	and
-
-	store
-	
-	storesp 4
-	storesp 4
-	poppc
-	
-
-
-
-; NB! this is not an EMULATE instruction. It is a varargs fn.
-	.globl _syscall	
-_syscall:
-	syscall
-	poppc
-	
-_slowmultImpl:
-	
-	loadsp 8 ; A
-	loadsp 8 ; B
-	im 0 ; C
-
-.LmoreMult:
-	mult1bit
-	
-	; cutoff
-	loadsp 8
-	.byte (.LmoreMult-.Lbranch)&0x7f+0x80
-.Lbranch:
-	neqbranch
-
-	storesp 4
-	storesp 4
-	storesp 12
-	storesp 4
-	poppc
-
-___mod:
-	cimpl __modsi3
-___div:
-	cimpl __divsi3
-
-	.section ".rodata"
-	.balign 4,0
-_mask:
-	.long 0x00ffffff
-	.long 0xff00ffff
-	.long 0xffff00ff
-	.long 0xffffff00
-
-	.section ".text","ax"
-	.global _boot
-	.balign 4,0
-_boot:
-	im 0
-	poppc
-
-	.global _break;
-_break:
-	im	_break
-	poppc ; infinite loop
-
-_premain:
-	im _break
-	nop
-	fixedim main
-	poppc
-
-
-	.data
-	.balign 4,0
-	
-	.globl _hardware
-_hardware:
-	.long 0
-	.globl _cpu_config
-_cpu_config:
-	.long 0
-
-
-	.section ".bss"
-    .balign 4,0
-	.globl _memreg
-_memreg:
-		.long 0
-		.long 0
-		.long 0
-		.long 0
-
Index: firmware_5200/simplefile.h
===================================================================
--- firmware_5200/simplefile.h	(revision 191)
+++ firmware_5200/simplefile.h	(nonexistent)
@@ -1,22 +0,0 @@
-#pragma once
-
-enum SimpleFileStatus {SimpleFile_OK, SimpleFile_FAIL};
-
-struct SimpleFile;
-
-// NB when switching file, the other file may loose its position, depending on implementation!
-
-int file_struct_size();
-
-void file_init(struct SimpleFile * file);
-
-char const * file_path(struct SimpleFile * file);
-char const * file_name(struct SimpleFile * file);
-enum SimpleFileStatus file_read(struct SimpleFile * file, void * buffer, int bytes, int * bytesread);
-enum SimpleFileStatus file_seek(struct SimpleFile * file, int offsetFromStart);
-int file_size(struct SimpleFile * file);
-int file_readonly(struct SimpleFile * file);
-
-enum SimpleFileStatus file_write(struct SimpleFile * file, void * buffer, int bytes, int * byteswritten);
-enum SimpleFileStatus file_write_flush();
-
Index: firmware_5200/main.c_SPITEST
===================================================================
--- firmware_5200/main.c_SPITEST	(revision 191)
+++ firmware_5200/main.c_SPITEST	(nonexistent)
@@ -1,464 +0,0 @@
-#include "integer.h"
-#include "regs.h"
-#include "pause.h"
-#include "printf.h"
-#include "joystick.h"
-
-#include "simpledir.h"
-#include "simplefile.h"
-#include "fileselector.h"
-
-#include "atari_drive_emulator.h"
-
-#include "spi.h"
-#include "mmc.h"
-
-// FUNCTIONS in here
-// i) pff init - NOT USED EVERYWHERE
-// ii) file selector - kind of crap, no fine scrolling - NOT USED EVERYWHERE
-// iii) cold reset atari (clears base ram...)
-// iv) start atari (begins paused)
-// v) freeze/resume atari - NOT USED EVERYWHERE!
-// vi) menu for various options - NOT USED EVERYWHERE!
-// vii) pause - TODO - base this on pokey clock...
-
-// standard ZPU IN/OUT use...
-// OUT1 - 6502 settings (pause,reset,speed)
-// pause_n: bit 0 
-// reset_n: bit 1
-// turbo: bit 2-4: meaning... 0=1.79Mhz,1=3.58MHz,2=7.16MHz,3=14.32MHz,4=28.64MHz,5=57.28MHz,etc.
-// ram_select: bit 5-7: 
-//   		RAM_SELECT : in std_logic_vector(2 downto 0); -- 64K,128K,320KB Compy, 320KB Rambo, 576K Compy, 576K Rambo, 1088K, 4MB
-// rom_select: bit 8-13:
-//    		ROM_SELECT : in std_logic_vector(5 downto 0); -- 16KB ROM Bank
-
-#define BIT_REG(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-} \
-void set_ ## name(int param) \
-{ \
-	int val = *reg; \
-	 \
-	val = (val&~(mask<<shift)); \
-	val |= op(param)<<shift; \
-	 \
-	*reg = val; \
-}
-
-#define BIT_REG_RO(op,mask,shift,name,reg) \
-int get_ ## name() \
-{ \
-	int val = *reg; \
-	return op((val>>shift)&mask); \
-}
-
-BIT_REG(,0x1,0,pause_6502,zpu_out1)
-BIT_REG(,0x1,1,reset_6502,zpu_out1)
-BIT_REG(,0x3f,2,turbo_6502,zpu_out1)
-BIT_REG(,0x7,8,ram_select,zpu_out1)
-BIT_REG(,0x3f,11,rom_select,zpu_out1)
-
-BIT_REG_RO(,0x1,4,hotkey_softboot,zpu_in1)
-BIT_REG_RO(,0x1,5,hotkey_coldboot,zpu_in1)
-BIT_REG_RO(,0x1,6,hotkey_fileselect,zpu_in1)
-BIT_REG_RO(,0x1,7,hotkey_settings,zpu_in1)
-
-void
-wait_us(int unsigned num)
-{
-	// pause counter runs at pokey frequency - should be 1.79MHz
-	int unsigned cycles = (num*230)>>7;
-	*zpu_pause = cycles;
-}
-
-void memset8(void * address, int value, int length)
-{
-	char * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void memset32(void * address, int value, int length)
-{
-	int * mem = address;
-	while (length--)
-		*mem++=value;
-}
-
-void clear_64k_ram()
-{
-	memset8((void *)0x200000, 0, 65536); // SRAM, if present (TODO)
-	memset32((void *)0x800000, 0, 16384);
-}
-
-void
-reboot(int cold)
-{
-	set_reset_6502(1);
-	if (cold)
-	{
-		clear_64k_ram();
-	}
-	set_reset_6502(0);
-	set_pause_6502(0);
-}
-
-unsigned char toatarichar(int val)
-{
-	int inv = val>=128;
-	if (inv)
-	{
-		val-=128;
-	}
-	if (val>='A' && val<='Z')
-	{
-		val+=-'A'+33;
-	}
-	else if (val>='a' && val<='z')
-	{
-		val+=-'a'+33+64;
-	}
-	else if (val>='0' && val<='9')
-	{
-		val+=-'0'+16;	
-	}
-	else if (val>=32 && val<=47)
-	{
-		val+=-32;
-	}
-	else
-	{
-		val = 0;
-	}
-	if (inv)
-	{
-		val+=128;
-	}
-	return val;
-}
-
-int debug_pos;
-int debug_adjust;
-unsigned char volatile * baseaddr;
-
-void clearscreen()
-{
-	unsigned volatile char * screen;
-	for (screen=(unsigned volatile char *)40000+atari_regbase; screen!=(unsigned volatile char *)(atari_regbase+40000+1024); ++screen)
-		*screen = 0x00;
-}
-
-void char_out ( void* p, char c)
-{
-	unsigned char val = toatarichar(c);
-	if (debug_pos>=0)
-	{
-		*(baseaddr+debug_pos) = val|debug_adjust;
-		++debug_pos;
-	}
-}
-
-// Memory usage...
-// 0x410000-0x41FFFF (0xc10000 in zpu space) = directory cache - 64k
-// 0x420000-0x43FFFF (0xc20000 in zpu space) = freeze backup
-
-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)
-{
-	spiInit();
-	set_spi_clock_freq();
-	char buffer[512];
-	while (1)
-	{
-		mmcReadLoop();
-		wait_us(500);
-		spiReceiveBlock(&buffer[0],512);
-		wait_us(500);
-	}
-
-
-	int i;
-	for (i=0; i!=5; ++i)
-	{
-		files[i] = (struct SimpleFile *)alloca(file_struct_size());
-		file_init(files[i]);
-	}
-
-	freeze_init((void*)0xc20000); // 128k
-
-	debug_pos = -1;
-	debug_adjust = 0;
-	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...
-
-	if (SimpleFile_OK == dir_init((void *)0xc10000, 65536))
-	{
-	//	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");
-	}
-	reboot(1);
-	for (;;) actions();
-}
-
-//		struct SimpleFile * file = alloca(file_struct_size());
-//		printf("Opening file\n");
-//		if (SimpleFile_OK == file_open_name("GUNPOWDR.ATR",file))
-//		{
-//			printf("FILE open ok\n");
-//
-//			set_drive_status(0,file);
-//
-//		}
-//		else
-//		{
-//			printf("FILE open failed\n");
-//		}
-
-char const * get_ram()
-{
-	switch(get_ram_select())
-	{
-	case 0:
-		return "64K";
-	case 1:
-		return "128K";
-	case 2:
-		return "320K(Compy)";
-	case 3:
-		return "320K(Rambo)";
-	case 4:
-		return "576K(Compy)";
-	case 5:
-		return "576K(Rambo)";
-	case 6:
-		return "1MB";
-	case 7:
-		return "4MB";
-	}
-}
-
-int settings()
-{
-	struct joystick_status joy;
-	joy.x_ = joy.y_ = joy.fire_ = 0;
-
-	int row = 0;
-
-	int done = 0;
-	for (;!done;)
-	{
-		// Render
-		clearscreen();
-		debug_pos = 0;
-		debug_adjust = 0;
-		printf("Se");
-		debug_adjust = 128;
-		printf("ttings");
-		debug_pos = 80;
-		debug_adjust = row==0 ? 128 : 0;
-		printf("Turbo:%dx", get_turbo_6502());
-		debug_pos = 120;
-		debug_adjust = row==1 ? 128 : 0;
-		printf("Ram:%s", get_ram());
-		debug_pos = 160;
-		debug_adjust = row==2 ? 128 : 0;
-		printf("Rom bank:%d", get_rom_select());
-		debug_pos = 240;
-		int i;
-		for (i=1;i!=5;++i)
-		{
-			int temp = debug_pos;
-			debug_adjust = row==i+2 ? 128 : 0;
-			char buffer[20];
-			describe_disk(i-1,&buffer[0]);
-			printf("Drive %d:%s %s", i, file_name(files[i-1]), &buffer[0]);
-			debug_pos = temp+40;
-		}
-
-		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
-		wait_us(100000);
-
-		// move
-		joystick_wait(&joy,WAIT_QUIET);
-		joystick_wait(&joy,WAIT_EITHER);
-
-		row+=joy.y_;
-		if (row<0) row = 0;
-		if (row>8) row = 8;
-		switch (row)
-		{
-		case 0:
-			{
-				int turbo = get_turbo_6502();
-				if (joy.x_==1) turbo<<=1;
-				if (joy.x_==-1) turbo>>=1;
-				if (turbo>16) turbo = 16;
-				if (turbo<1) turbo = 1;
-				set_turbo_6502(turbo);
-			}
-			break;
-		case 1:
-			{
-				int ram_select = get_ram_select();
-				ram_select+=joy.x_;
-				if (ram_select<0) ram_select = 0;
-				if (ram_select>7) ram_select = 7;
-				set_ram_select(ram_select);
-			}
-			break;
-		case 2:
-			{
-				int rom_select = get_rom_select();
-				rom_select+=joy.x_;
-				if (rom_select<1) rom_select = 1;
-				if (rom_select>6) rom_select = 6; // TODO
-				set_rom_select(rom_select);
-			}
-			break;
-		case 3:
-		case 4:
-		case 5:
-		case 6:
-			{
-				if (joy.x_>0)
-				{
-					// Choose new disk
-					filter = filter_disks;
-					file_selector(files[row-3]);
-					set_drive_status(row-3,files[row-3]);
-				}
-				else if(joy.x_<0)
-				{
-					// Remove disk
-					file_init(files[row-3]);
-					set_drive_status(row-3,0);
-				}
-				else if (joy.fire_)
-				{
-					struct SimpleFile * temp;
-					temp = files[0];
-					files[0] = files[row-3];
-					files[row-3] = temp;
-					set_drive_status(row-3,temp);
-					set_drive_status(0,files[0]);
-				}
-			}
-			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;
-			}
-			break;
-		}
-	}
-
-	return 0;
-}
-
-void actions()
-{
-	// Show some activity!
-	//*atari_colbk = *atari_random;
-	
-	// Hot keys
-	if (get_hotkey_softboot())
-	{
-		reboot(0);	
-	}
-	else if (get_hotkey_coldboot())
-	{
-		reboot(1);	
-	}
-	else if (get_hotkey_settings())
-	{
-		set_pause_6502(1);
-		freeze();
-		debug_pos = 0;	
-		int do_reboot = settings();
-		debug_pos = -1;
-		restore();
-		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();
-		set_drive_status(0,files[0]);
-		reboot(1);
-	}
-}
-
-
