Index: common/a8core/atari5200core_simplesdram.vhd
===================================================================
--- common/a8core/atari5200core_simplesdram.vhd	(revision 221)
+++ common/a8core/atari5200core_simplesdram.vhd	(revision 222)
@@ -73,26 +73,26 @@
 		DMA_MEMORY_DATA : out std_logic_vector(31 downto 0);
 
 		HALT : in std_logic;
-		THROTTLE_COUNT_6502 : in std_logic_vector(5 downto 0) -- standard speed is cycle_length-1
+		THROTTLE_COUNT_6502 : in std_logic_vector(5 downto 0); -- standard speed is cycle_length-1
 	
-		-- rename to simple_sdram...
-
 		-- JOYSTICK
-		--JOY1_n : IN std_logic_vector(4 downto 0); -- FRLDU, 0=pressed
-		--JOY2_n : IN std_logic_vector(4 downto 0); -- FRLDU, 0=pressed
+		JOY1_X : IN signed(7 downto 0);
+		JOY1_Y : IN signed(7 downto 0);
+		JOY1_BUTTON : IN std_logic;
+		JOY2_X : IN signed(7 downto 0);
+		JOY2_Y : IN signed(7 downto 0);
+		JOY2_BUTTON : IN std_logic;
 
-		-- KEYBOARD
-		--PS2_CLK : IN STD_LOGIC;
-		--PS2_DAT : IN STD_LOGIC;
+		-- Pokey keyboard matrix
+		-- Standard component available to connect this to PS2
+		KEYBOARD_RESPONSE : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
+		KEYBOARD_SCAN : OUT STD_LOGIC_VECTOR(5 DOWNTO 0);
+		CONTROLLER_SELECT : OUT STD_LOGIC_VECTOR(1 downto 0)
 	);
 end atari5200core_simplesdram;
 
 ARCHITECTURE vhdl OF atari5200core_simplesdram IS 
 
--- pokey keyboard
-SIGNAL KEYBOARD_SCAN : std_logic_vector(5 downto 0);
-SIGNAL KEYBOARD_RESPONSE : std_logic_vector(1 downto 0);
-
 -- PBI
 SIGNAL PBI_WRITE_DATA : std_logic_vector(31 downto 0);
 
@@ -112,11 +112,81 @@
 SIGNAL USE_SDRAM : STD_LOGIC;
 SIGNAL ROM_IN_RAM : STD_LOGIC;
 
+-- TRIG
+SIGNAL TRIG : STD_LOGIC_VECTOR(1 downto 0);
+
+-- CONSOL
+SIGNAL CONSOL_OUT : STD_LOGIC_VECTOR(3 downto 0);
+
+-- POTS
+SIGNAL ENABLE_179 : STD_LOGIC;
+SIGNAL POT_COUNT : STD_LOGIC;
+SIGNAL POT_RESET : STD_LOGIC;
+SIGNAL POT_IN : STD_LOGIC_VECTOR(7 downto 0);
+
 BEGIN
 
--- PS2 to pokey
-KEYBOARD_RESPONSE <= "11";
+-- triggers
+TRIG(0) <= JOY1_BUTTON;
+TRIG(1) <= JOY2_BUTTON;
 
+-- pots 
+-- TODO linear or not?
+enable_179_clock_div : entity work.enable_divider
+	generic map (COUNT=>cycle_length)
+	port map(clk=>clk,reset_n=>reset_n,enable_in=>'1',enable_out=>enable_179);
+
+-- 114K to 386k (51 to 172) 121 lines.  i.e. 121*114 cycles/256 values = ~54
+pot_clock_div : entity work.enable_divider
+	generic map (COUNT=>54)
+	port map(clk=>clk,reset_n=>reset_n,enable_in=>enable_179,enable_out=>pot_count);
+
+pot0 : entity work.pot_from_signed
+	PORT MAP
+	(
+		CLK => CLK,
+		RESET_N => RESET_N,
+		ENABLED => CONSOL_OUT(2),
+		POT_RESET => POT_RESET,
+		COUNT_ENABLE => POT_COUNT,
+		POS => JOY1_X,
+		POT_HIGH => POT_IN(0)
+	);
+pot1 : entity work.pot_from_signed
+	PORT MAP
+	(
+		CLK => CLK,
+		RESET_N => RESET_N,
+		ENABLED => CONSOL_OUT(2),
+		POT_RESET => POT_RESET,
+		COUNT_ENABLE => POT_COUNT,
+		POS => JOY1_Y,
+		POT_HIGH => POT_IN(1)
+	);
+pot2 : entity work.pot_from_signed
+	PORT MAP
+	(
+		CLK => CLK,
+		RESET_N => RESET_N,
+		ENABLED => CONSOL_OUT(2),
+		POT_RESET => POT_RESET,
+		COUNT_ENABLE => POT_COUNT,
+		POS => JOY2_X,
+		POT_HIGH => POT_IN(2)
+	);
+pot3 : entity work.pot_from_signed
+	PORT MAP
+	(
+		CLK => CLK,
+		RESET_N => RESET_N,
+		ENABLED => CONSOL_OUT(2),
+		POT_RESET => POT_RESET,
+		COUNT_ENABLE => POT_COUNT,
+		POS => JOY2_Y,
+		POT_HIGH => POT_IN(3)
+	);
+POT_IN(7 downto 4) <= (others=>'0');
+
 atari5200_simple_sdram1 : entity work.atari5200core
 	GENERIC MAP
 	(
@@ -144,12 +214,12 @@
 
 		-- Pokey keyboard matrix
 		-- Standard component available to connect this to PS2
-		KEYBOARD_RESPONSE => KEYBOARD_RESPONSE, -- TODO controller
+		KEYBOARD_RESPONSE => KEYBOARD_RESPONSE,
 		KEYBOARD_SCAN => KEYBOARD_SCAN,
 
 		-- Pokey pots
-		POT_IN => (others=>'1'), -- TODO analog controller
-		POT_RESET => open,
+		POT_IN => POT_IN,
+		POT_RESET => POT_RESET,
 		
 		-- PBI
 		PBI_ADDR => open,
@@ -171,9 +241,9 @@
 		SIO_TXD => open,
 
 		-- GTIA consol
-		CONSOL_OUT => open, -- TODO sound, pots(err, pokey?), 2bit controller keyboard select
+		CONSOL_OUT => CONSOL_OUT, -- TODO sound, pots(err, pokey?), 2bit controller keyboard select
 		CONSOL_IN => (others=>'1'),
-		GTIA_TRIG => (others=>'1'), -- triggers (4 ports...)
+		GTIA_TRIG => "11"&TRIG, -- triggers (4 ports...)
 
 		-- ANTIC 
 		ANTIC_REFRESH => SDRAM_REFRESH,
@@ -241,8 +311,10 @@
 		RAM_DATA => RAM_DO(7 downto 0)
 	);
 
-	USE_SDRAM <= '1' when internal_ram=0 else '0';
-	ROM_IN_RAM <= '1' when internal_rom=0 else '0';
+USE_SDRAM <= '1' when internal_ram=0 else '0';
+ROM_IN_RAM <= '1' when internal_rom=0 else '0';
 
+CONTROLLER_SELECT <= CONSOL_OUT(1 downto 0);
+
 end vhdl;
 
Index: common/a8core/pot_from_signed.vhdl
===================================================================
--- common/a8core/pot_from_signed.vhdl	(nonexistent)
+++ common/a8core/pot_from_signed.vhdl	(revision 222)
@@ -0,0 +1,71 @@
+---------------------------------------------------------------------------
+-- (c) 2014 mark watson
+-- I am happy for anyone to use this for non-commercial use.
+-- If my vhdl files are used commercially or otherwise sold,
+-- please contact me for explicit permission at scrameta (gmail).
+-- This applies for source and binary form and derived works.
+---------------------------------------------------------------------------
+LIBRARY ieee;
+USE ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+USE ieee.math_real.ceil;
+--USE ieee.math_real.log2; (non-linear version?)
+use IEEE.STD_LOGIC_MISC.all;
+
+ENTITY pot_from_signed IS
+GENERIC
+(
+	initial : integer := 108 + 128
+);
+PORT 
+( 
+	CLK : IN STD_LOGIC;
+	RESET_N : IN STD_LOGIC;
+
+	ENABLED : IN STD_LOGIC;
+	POT_RESET : IN STD_LOGIC;
+	COUNT_ENABLE : IN STD_LOGIC;
+	POS : IN SIGNED(7 downto 0);
+	POT_HIGH : OUT STD_LOGIC
+);
+END pot_from_signed;
+
+ARCHITECTURE vhdl OF pot_from_signed IS
+	signal count_reg : std_logic_vector(9 downto 0);
+	signal count_next : std_logic_vector(9 downto 0);
+
+	signal pot_out_reg : std_logic;
+	signal pot_out_next : std_logic;
+BEGIN
+	process(clk, reset_n)
+	begin
+		if (reset_n='0') then
+			count_reg <= (others=>'0');
+			pot_out_reg <= '0';
+		elsif (clk'event and clk='1') then
+			count_reg <= count_next;
+			pot_out_reg <= pot_out_next;
+		end if;
+	end process;
+
+	process(count_reg,pot_reset,count_enable,pot_out_next,enabled)
+	begin
+		count_next <= count_reg;
+
+		if (pot_reset ='1' or enabled = '1') then
+			count_next <= std_logic_vector(to_unsigned(to_integer(pos)+initial,10));
+		end if;
+
+		if (count_enable = '1') then
+			if (pot_out_next = '0') then
+				count_next <= std_logic_vector(unsigned(count_reg) -1);
+			end if;
+		end if;
+
+		pot_out_next <= not(or_reduce(count_reg));
+
+	end process;
+
+	pot_high <= pot_out_reg;
+end vhdl;
+
Index: common/a8core/ps2_to_atari5200.vhdl
===================================================================
--- common/a8core/ps2_to_atari5200.vhdl	(nonexistent)
+++ common/a8core/ps2_to_atari5200.vhdl	(revision 222)
@@ -0,0 +1,210 @@
+---------------------------------------------------------------------------
+-- (c) 2013 mark watson
+-- I am happy for anyone to use this for non-commercial use.
+-- If my vhdl files are used commercially or otherwise sold,
+-- please contact me for explicit permission at scrameta (gmail).
+-- This applies for source and binary form and derived works.
+---------------------------------------------------------------------------
+
+---------------------------------------------------------------------------
+-- (ILoveSpeccy) Added PS2_KEYS Output
+---------------------------------------------------------------------------
+
+LIBRARY ieee;
+USE ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+
+ENTITY ps2_to_atari5200 IS
+PORT 
+( 
+	CLK : IN STD_LOGIC;
+	RESET_N : IN STD_LOGIC;
+	PS2_CLK : IN STD_LOGIC;
+	PS2_DAT : IN STD_LOGIC;
+	
+	KEYBOARD_SCAN : IN STD_LOGIC_VECTOR(5 downto 0);
+	KEYBOARD_RESPONSE : OUT STD_LOGIC_VECTOR(1 downto 0);
+
+	FIRE2 : IN STD_LOGIC_VECTOR(3 downto 0);
+	CONTROLLER_SELECT : IN STD_LOGIC_VECTOR(1 downto 0);
+
+	FKEYS : OUT STD_LOGIC_VECTOR(11 downto 0);
+
+	FREEZER_ACTIVATE : OUT STD_LOGIC;
+   
+	PS2_KEYS : OUT STD_LOGIC_VECTOR(511 downto 0)
+);
+END ps2_to_atari5200;
+
+ARCHITECTURE vhdl OF ps2_to_atari5200 IS
+	signal ps2_keys_next : std_logic_vector(511 downto 0);
+	signal ps2_keys_reg : std_logic_vector(511 downto 0);
+
+	signal key_event : std_logic;
+	signal key_value : std_logic_vector(7 downto 0);
+	signal key_extended : std_logic;
+	signal key_up : std_logic;
+
+	signal FKEYS_INT : std_logic_vector(11 downto 0);
+
+	signal FREEZER_ACTIVATE_INT : std_logic;
+
+	signal atari_keyboard : std_logic_vector(15 downto 0);
+
+	signal fire_pressed_sel : std_logic;
+BEGIN
+
+   PS2_KEYS <= ps2_keys_reg;
+
+	keyboard1: entity work.ps2_keyboard
+	PORT MAP
+	( 
+		CLK => CLK,
+		RESET_N => RESET_N,
+		PS2_CLK => PS2_CLK,
+		PS2_DAT => PS2_DAT,
+		
+		KEY_EVENT => KEY_EVENT,
+		KEY_VALUE => KEY_VALUE,
+		KEY_EXTENDED => KEY_EXTENDED,
+		KEY_UP => KEY_UP
+--		KEY_EVENT : OUT STD_LOGIC; -- high for 1 cycle on new key pressed(or repeated)/released
+--		KEY_VALUE : OUT STD_LOGIC_VECTOR(7 downto 0); -- valid on event, raw scan code
+--		KEY_EXTENDED : OUT STD_LOGIC;           -- valid on event, if scan code extended
+--		KEY_UP : OUT STD_LOGIC                 -- value on event, if key released
+	);
+
+	process(clk,reset_n)
+	begin
+		if (reset_n='0') then
+			ps2_keys_reg <= (others=>'0');
+		elsif (clk'event and clk='1') then
+			ps2_keys_reg <= ps2_keys_next;
+		end if;
+	end process;
+
+	-- 1 bit per PS2 key
+	process(KEY_EVENT, KEY_VALUE, KEY_EXTENDED, KEY_UP, ps2_keys_reg)
+	begin
+		ps2_keys_next <= ps2_keys_reg;
+
+		if (key_event = '1') then
+			ps2_keys_next(to_integer(unsigned(KEY_EXTENDED&KEY_VALUE))) <= NOT(KEY_UP);
+		end if;
+	end process;
+
+	-- map to atari key code
+	process(ps2_keys_reg, fire2, controller_select)
+	begin
+		atari_keyboard <= (others=>'0');
+
+		fire_pressed_sel <= '0';
+
+		case controller_select is
+		when "00" =>
+			-- todo change order to match keycode! check with petes test
+			atari_keyboard(0)<=ps2_keys_reg(16#05#); --f1
+			atari_keyboard(1)<=ps2_keys_reg(16#06#); --f2
+			atari_keyboard(2)<=ps2_keys_reg(16#04#); --f3
+			atari_keyboard(3)<=ps2_keys_reg(16#16#); --1
+			atari_keyboard(4)<=ps2_keys_reg(16#1E#); --2
+			atari_keyboard(5)<=ps2_keys_reg(16#26#); --3
+			atari_keyboard(6)<=ps2_keys_reg(16#15#); --q
+			atari_keyboard(7)<=ps2_keys_reg(16#1D#); --w
+			atari_keyboard(8)<=ps2_keys_reg(16#24#); --e
+			atari_keyboard(9)<=ps2_keys_reg(16#1c#);   --a
+			atari_keyboard(10)<=ps2_keys_reg(16#1b#);  --s
+			atari_keyboard(11)<=ps2_keys_reg(16#23#);  --d
+			atari_keyboard(12)<=ps2_keys_reg(16#1a#);  --z 
+			atari_keyboard(13)<=ps2_keys_reg(16#22#);  --x
+			atari_keyboard(14)<=ps2_keys_reg(16#21#);  --c
+			fire_pressed_sel <= fire2(0);
+		when "01" =>
+			atari_keyboard(0)<=ps2_keys_reg(16#29#);
+			atari_keyboard(1)<=ps2_keys_reg(16#29#);
+			atari_keyboard(2)<=ps2_keys_reg(16#29#);
+			atari_keyboard(3)<=ps2_keys_reg(16#29#);
+			atari_keyboard(4)<=ps2_keys_reg(16#29#);
+			atari_keyboard(5)<=ps2_keys_reg(16#29#);
+			atari_keyboard(6)<=ps2_keys_reg(16#29#);
+			atari_keyboard(7)<=ps2_keys_reg(16#29#);
+			atari_keyboard(8)<=ps2_keys_reg(16#29#);
+			atari_keyboard(9)<=ps2_keys_reg(16#29#);
+			atari_keyboard(10)<=ps2_keys_reg(16#29#);
+			atari_keyboard(11)<=ps2_keys_reg(16#29#);
+			atari_keyboard(12)<=ps2_keys_reg(16#29#);
+			atari_keyboard(13)<=ps2_keys_reg(16#29#);
+			atari_keyboard(14)<=ps2_keys_reg(16#29#);
+			fire_pressed_sel <= fire2(1);
+		when "10" =>
+			atari_keyboard(0)<=ps2_keys_reg(16#29#);
+			atari_keyboard(1)<=ps2_keys_reg(16#29#);
+			atari_keyboard(2)<=ps2_keys_reg(16#29#);
+			atari_keyboard(3)<=ps2_keys_reg(16#29#);
+			atari_keyboard(4)<=ps2_keys_reg(16#29#);
+			atari_keyboard(5)<=ps2_keys_reg(16#29#);
+			atari_keyboard(6)<=ps2_keys_reg(16#29#);
+			atari_keyboard(7)<=ps2_keys_reg(16#29#);
+			atari_keyboard(8)<=ps2_keys_reg(16#29#);
+			atari_keyboard(9)<=ps2_keys_reg(16#29#);
+			atari_keyboard(10)<=ps2_keys_reg(16#29#);
+			atari_keyboard(11)<=ps2_keys_reg(16#29#);
+			atari_keyboard(12)<=ps2_keys_reg(16#29#);
+			atari_keyboard(13)<=ps2_keys_reg(16#29#);
+			atari_keyboard(14)<=ps2_keys_reg(16#29#);
+			fire_pressed_sel <= fire2(2);
+		when "11" =>
+			atari_keyboard(0)<=ps2_keys_reg(16#29#);
+			atari_keyboard(1)<=ps2_keys_reg(16#29#);
+			atari_keyboard(2)<=ps2_keys_reg(16#29#);
+			atari_keyboard(3)<=ps2_keys_reg(16#29#);
+			atari_keyboard(4)<=ps2_keys_reg(16#29#);
+			atari_keyboard(5)<=ps2_keys_reg(16#29#);
+			atari_keyboard(6)<=ps2_keys_reg(16#29#);
+			atari_keyboard(7)<=ps2_keys_reg(16#29#);
+			atari_keyboard(8)<=ps2_keys_reg(16#29#);
+			atari_keyboard(9)<=ps2_keys_reg(16#29#);
+			atari_keyboard(10)<=ps2_keys_reg(16#29#);
+			atari_keyboard(11)<=ps2_keys_reg(16#29#);
+			atari_keyboard(12)<=ps2_keys_reg(16#29#);
+			atari_keyboard(13)<=ps2_keys_reg(16#29#);
+			atari_keyboard(14)<=ps2_keys_reg(16#29#);
+			fire_pressed_sel <= fire2(3);
+		when others =>
+		end case;
+
+		fkeys_int(0)<=ps2_keys_reg(16#05#);
+		fkeys_int(1)<=ps2_keys_reg(16#06#);
+		fkeys_int(2)<=ps2_keys_reg(16#04#);
+		fkeys_int(3)<=ps2_keys_reg(16#0C#);
+		fkeys_int(4)<=ps2_keys_reg(16#03#);
+		fkeys_int(5)<=ps2_keys_reg(16#0B#);
+		fkeys_int(6)<=ps2_keys_reg(16#83#);
+		fkeys_int(7)<=ps2_keys_reg(16#0a#);
+		fkeys_int(8)<=ps2_keys_reg(16#01#);
+		fkeys_int(9)<=ps2_keys_reg(16#09#);
+		fkeys_int(10)<=ps2_keys_reg(16#78#);
+		fkeys_int(11)<=ps2_keys_reg(16#07#);
+
+		-- use scroll lock or delete to activate freezer (same key on my keyboard + scroll lock does not seem to work on mist!)
+		freezer_activate_int <= ps2_keys_reg(16#7e#) or ps2_keys_reg(16#171#);
+	end process;
+
+	-- provide results as if we were a grid to pokey...
+	process(keyboard_scan, atari_keyboard, fire_pressed_sel)
+		begin	
+			keyboard_response <= (others=>'1');		
+			
+			if (atari_keyboard(to_integer(unsigned(not(keyboard_scan(4 downto 1))))) = '1') then
+				keyboard_response(0) <= '0';
+			end if;
+			
+			keyboard_response(1) <= not(fire_pressed_sel);
+	end process;		 
+
+	-- outputs
+	FKEYS <= FKEYS_INT;
+	FREEZER_ACTIVATE <= FREEZER_ACTIVATE_INT;
+END vhdl;
+
Index: common/a8core/ps2_to_atari800.vhdl
===================================================================
--- common/a8core/ps2_to_atari800.vhdl	(revision 221)
+++ common/a8core/ps2_to_atari800.vhdl	(revision 222)
@@ -4,12 +4,12 @@
 -- If my vhdl files are used commercially or otherwise sold,
 -- please contact me for explicit permission at scrameta (gmail).
 -- This applies for source and binary form and derived works.
----------------------------------------------------------------------------
-
----------------------------------------------------------------------------
--- (ILoveSpeccy) Added PS2_KEYS Output
----------------------------------------------------------------------------
+---------------------------------------------------------------------------
 
+---------------------------------------------------------------------------
+-- (ILoveSpeccy) Added PS2_KEYS Output
+---------------------------------------------------------------------------
+
 LIBRARY ieee;
 USE ieee.std_logic_1164.all;
 use ieee.numeric_std.all;
@@ -30,10 +30,10 @@
 	CONSOL_SELECT : OUT STD_LOGIC;
 	CONSOL_OPTION : OUT STD_LOGIC;
    
-	FKEYS : OUT STD_LOGIC_VECTOR(11 downto 0);
+	FKEYS : OUT STD_LOGIC_VECTOR(11 downto 0);
 
 	FREEZER_ACTIVATE : OUT STD_LOGIC;
-   
+   
    PS2_KEYS : OUT STD_LOGIC_VECTOR(511 downto 0)
 );
 END ps2_to_atari800;
@@ -59,10 +59,10 @@
 	SIGNAL	SHIFT_PRESSED :  STD_LOGIC;
 	SIGNAL	BREAK_PRESSED :  STD_LOGIC;
 	SIGNAL	CONTROL_PRESSED :  STD_LOGIC;
-BEGIN
-
-   PS2_KEYS <= ps2_keys_reg;
+BEGIN
 
+   PS2_KEYS <= ps2_keys_reg;
+
 	keyboard1: entity work.ps2_keyboard
 	PORT MAP
 	( 
Index: mist_5200/atari800core.qsf
===================================================================
--- mist_5200/atari800core.qsf	(revision 221)
+++ mist_5200/atari800core.qsf	(revision 222)
@@ -308,11 +308,11 @@
 
 set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
 
-set_global_assignment -name VHDL_FILE data_io.vhdl
 set_global_assignment -name VHDL_FILE zpu_rom.vhdl
 set_global_assignment -name SDC_FILE atari800core.sdc
 set_global_assignment -name QIP_FILE mist_sector_buffer.qip
 set_global_assignment -name VHDL_FILE atari800core_mist.vhd
+set_global_assignment -name VERILOG_FILE sd_card.v
 set_global_assignment -name VERILOG_FILE user_io.v
 set_global_assignment -name QIP_FILE pll_pal_pre.qip
 set_global_assignment -name QIP_FILE pll_pal_post.qip
Index: mist_5200/atari800core_mist.vhd
===================================================================
--- mist_5200/atari800core_mist.vhd	(revision 221)
+++ mist_5200/atari800core_mist.vhd	(revision 222)
@@ -88,7 +88,7 @@
 		JOYSTICK_0 : out std_logic_vector(5 downto 0);
 		JOYSTICK_1 : out std_logic_vector(5 downto 0);
 		JOYSTICK_ANALOG_0 : out std_logic_vector(15 downto 0);
-		JOYSTICK_ANALOG_1 : out std_logic_vector(15 downto 0);
+		JOYSTICK_ANALOG_1 : out std_logic_vector(15 downto 0); -- x axis is top 8 bits, y axis is bottom 8 bits. signed.
 		BUTTONS : out std_logic_vector(1 downto 0);
 		SWITCHES : out std_logic_vector(1 downto 0);
 		STATUS : out std_logic_vector(7 downto 0); -- what is this?
@@ -160,12 +160,6 @@
 
   SIGNAL PS2_CLK : std_logic;
   SIGNAL PS2_DAT : std_logic;
-  SIGNAL	CONSOL_OPTION_RAW :  STD_LOGIC;
-  SIGNAL	CONSOL_OPTION :  STD_LOGIC;
-  SIGNAL	CONSOL_SELECT_RAW :  STD_LOGIC;
-  SIGNAL	CONSOL_SELECT :  STD_LOGIC;
-  SIGNAL	CONSOL_START_RAW :  STD_LOGIC;
-  SIGNAL	CONSOL_START :  STD_LOGIC;
   SIGNAL FKEYS : std_logic_vector(11 downto 0);
 
   signal capslock_pressed : std_logic;
@@ -179,6 +173,10 @@
 
   signal		JOY1 :  STD_LOGIC_VECTOR(5 DOWNTO 0);
   signal		JOY2 :  STD_LOGIC_VECTOR(5 DOWNTO 0);
+  signal		JOY1X : std_logic_vector(7 downto 0);
+  signal		JOY1Y : std_logic_vector(7 downto 0);
+  signal		JOY2X : std_logic_vector(7 downto 0);
+  signal		JOY2Y : std_logic_vector(7 downto 0);
   signal		JOY1_n :  STD_LOGIC_VECTOR(4 DOWNTO 0);
   signal		JOY2_n :  STD_LOGIC_VECTOR(4 DOWNTO 0);
   signal joy_still : std_logic;
@@ -185,6 +183,7 @@
 
   SIGNAL	KEYBOARD_RESPONSE :  STD_LOGIC_VECTOR(1 DOWNTO 0);
   SIGNAL	KEYBOARD_SCAN :  STD_LOGIC_VECTOR(5 DOWNTO 0);
+  signal controller_select : std_logic_vector(1 downto 0);
 
   SIGNAL PAL : std_logic;
   SIGNAL COMPOSITE_ON_HSYNC : std_logic;
@@ -277,8 +276,10 @@
 	   SPI_MOSI => SPI_DI,
 		JOYSTICK_0 => joy2,
 		JOYSTICK_1 => joy1,
-		JOYSTICK_ANALOG_0 => open,
-		JOYSTICK_ANALOG_1 => open, -- todo, wire up to paddles
+		JOYSTICK_ANALOG_0(15 downto 8) => joy2x,
+		JOYSTICK_ANALOG_0(7 downto 0) => joy2y,
+		JOYSTICK_ANALOG_1(15 downto 8) => joy1x,
+		JOYSTICK_ANALOG_1(7 downto 0) => joy1y,
 		BUTTONS => mist_buttons,
 		SWITCHES => mist_switches,
 		STATUS => open,
@@ -329,7 +330,7 @@
 	 joy2_n <= not(joy2(4 downto 0));
 
 -- PS2 to pokey
-keyboard_map1 : entity work.ps2_to_atari800
+keyboard_map1 : entity work.ps2_to_atari5200
 	PORT MAP
 	( 
 		CLK => clk,
@@ -336,21 +337,18 @@
 		RESET_N => reset_n,
 		PS2_CLK => ps2_clk,
 		PS2_DAT => ps2_dat,
+
+		FIRE2 => '0'&'0'&joy2(5)&joy1(5),
+		CONTROLLER_SELECT => CONTROLLER_SELECT, -- selected stick keyboard/shift button
 		
 		KEYBOARD_SCAN => KEYBOARD_SCAN,
 		KEYBOARD_RESPONSE => KEYBOARD_RESPONSE,
 
-		CONSOL_START => CONSOL_START_RAW,
-		CONSOL_SELECT => CONSOL_SELECT_RAW,
-		CONSOL_OPTION => CONSOL_OPTION_RAW,
-		
 		FKEYS => FKEYS
 	);
+-- stick 0: consol(1 downto 0)="00"
 
-CONSOL_START <= CONSOL_START_RAW or (mist_buttons(1) and not(joy1_n(4)));
-joy_still <= joy1_n(3) and joy1_n(2) and joy1_n(1) and joy1_n(0);
-CONSOL_SELECT <= CONSOL_SELECT_RAW or (mist_buttons(1) and joy1_n(4) and not(joy_still));
-CONSOL_OPTION <= CONSOL_OPTION_RAW or (mist_buttons(1) and joy1_n(4) and joy_still);
+joy_still <= joy1_n(3) and joy1_n(2) and joy1_n(1) and joy1_n(0); -- TODO, need something better here I think! e.g. keypad? 5200 not centreing
 	 
 dac_left : hq_dac
 port map
@@ -446,15 +444,21 @@
 		DMA_MEMORY_DATA => dma_memory_data, 
 
 		THROTTLE_COUNT_6502 => speed_6502,
-		HALT => pause_atari
+		HALT => pause_atari,
 
 		-- JOYSTICK
-		--JOY1_n : IN std_logic_vector(4 downto 0); -- FRLDU, 0=pressed
-		--JOY2_n : IN std_logic_vector(4 downto 0); -- FRLDU, 0=pressed
+		JOY1_X => signed(joy1x),
+		JOY1_Y => signed(joy1y),
+		JOY1_BUTTON => joy1(4),
+		JOY2_X => signed(joy2x),
+		JOY2_Y => signed(joy2y),
+		JOY2_BUTTON => joy2(4),
 
-		-- KEYBOARD
-		--PS2_CLK : IN STD_LOGIC;
-		--PS2_DAT : IN STD_LOGIC;
+		-- Pokey keyboard matrix
+		-- Standard component available to connect this to PS2
+		KEYBOARD_RESPONSE => KEYBOARD_RESPONSE,
+		KEYBOARD_SCAN => KEYBOARD_SCAN,
+		CONTROLLER_SELECT => CONTROLLER_SELECT
 	);
 
 --atarixl_simple_sdram1 : entity work.atari800core_simple_sdram
Index: mist_5200/build.sh
===================================================================
--- mist_5200/build.sh	(revision 221)
+++ mist_5200/build.sh	(revision 222)
@@ -4,7 +4,6 @@
 my $wanted_variant = shift @ARGV;
 
 #variants...
-my $PAL = 1;
 my $NTSC = 0;
 
 my $RGB = 1; # i.e. not scandoubled
@@ -15,27 +14,6 @@
 
 my %variants = 
 (
-	"PAL_RGB" => 
-	{
-		"TV" => $PAL,
-		"SCANDOUBLE" => 0,
-		"VIDEO" => $RGB,
-		"COMPOSITE_SYNC" => 1
-	},
-	"PAL_VGA" =>
-	{
-		"TV" => $PAL,
-		"SCANDOUBLE" => 1,
-		"VIDEO" => $VGA,
-		"COMPOSITE_SYNC" => 0
-	},
-	"PAL_VGA_CS" =>
-	{
-		"TV" => $PAL,
-		"SCANDOUBLE" => 1,
-		"VIDEO" => $VGA,
-		"COMPOSITE_SYNC" => 1
-	},
 	"NTSC_RGB" =>
 	{
 		"TV" => $NTSC,
