Index: buildall.sh
===================================================================
--- buildall.sh	(revision 39)
+++ buildall.sh	(revision 40)
@@ -6,4 +6,8 @@
 cd ../mist
 ./build.sh > build.log 2> build.err&
 cd ../mcc216
-./build.sh > build.log 2> build.err&
+./build.sh ALL &
+
+# TODO variations?
+# TODO SOCkit
+
Index: common/components/generic_ram_infer.vhdl
===================================================================
--- common/components/generic_ram_infer.vhdl	(revision 39)
+++ common/components/generic_ram_infer.vhdl	(revision 40)
@@ -32,6 +32,8 @@
 
    SIGNAL q_ram : std_logic_vector(data_width-1 downto 0);
    SIGNAL we_ram : std_logic;
+
+   signal address2 : std_logic_vector(address_width-1 downto 0);
 BEGIN
 
    PROCESS (clock)
@@ -38,21 +40,23 @@
    BEGIN
      IF (clock'event AND clock = '1') THEN
 	 IF (we_ram = '1') THEN
-		 ram_block(to_integer(to_01(unsigned(address), '0'))) <= data;
+		 ram_block(to_integer(to_01(unsigned(address2), '0'))) <= data;
 		 q_ram <= data;
 	 ELSE
-		 q_ram <= ram_block(to_integer(to_01(unsigned(address), '0')));
+		 q_ram <= ram_block(to_integer(to_01(unsigned(address2), '0')));
 	  END IF;
      END IF;
    END PROCESS;
 
-   PROCESS(address)
+   PROCESS(address, we, q_ram)
    begin
 	q <= (others=>'1');
 	we_ram <= '0';
+	address2 <= (others=>'0');
 	IF (to_integer(to_01(unsigned(address))) < space) THEN
 		q <= q_ram;
 		we_ram <= we;
+		address2 <= address;
 	end if;
    end process;
 END rtl;
Index: common/components/scandoubler.vhdl
===================================================================
--- common/components/scandoubler.vhdl	(revision 39)
+++ common/components/scandoubler.vhdl	(revision 40)
@@ -10,6 +10,7 @@
 use ieee.numeric_std.all;
 
 ENTITY scandoubler IS
+--TODO video bits
 PORT 
 ( 
 	CLK : IN STD_LOGIC;
Index: common/tb/atari800core_helloworld_tb.vhd
===================================================================
--- common/tb/atari800core_helloworld_tb.vhd	(revision 39)
+++ common/tb/atari800core_helloworld_tb.vhd	(revision 40)
@@ -14,12 +14,12 @@
 
   constant CLK_A_PERIOD : time := 1 us / (1.79*32);
 
-  signal VGA_VS : std_logic;
-  signal VGA_HS : std_logic;
+  signal VIDEO_VS : std_logic;
+  signal VIDEO_HS : std_logic;
 
-  signal VGA_G : std_logic_vector(7 downto 0);
-  signal VGA_B : std_logic_vector(7 downto 0);
-  signal VGA_R : std_logic_vector(7 downto 0);
+  signal VIDEO_G : std_logic_vector(7 downto 0);
+  signal VIDEO_B : std_logic_vector(7 downto 0);
+  signal VIDEO_R : std_logic_vector(7 downto 0);
 
   signal AUDIO_L : std_logic_vector(15 downto 0);
   signal AUDIO_R : std_logic_vector(15 downto 0);
@@ -55,7 +55,8 @@
 	GENERIC MAP
 	(
 		cycle_length => 32,
-		internal_ram => 16384
+		internal_ram => 16384,
+		internal_rom => 1
 	)
 	PORT MAP
 	(
@@ -62,11 +63,11 @@
 		CLK => clk_a,
 		RESET_N => reset_n,
 
-		VGA_VS => vga_vs,
-		VGA_HS => vga_hs,
-		VGA_B => vga_b,
-		VGA_G => vga_g,
-		VGA_R => vga_r,
+		VIDEO_VS => video_vs,
+		VIDEO_HS => video_hs,
+		VIDEO_B => video_b,
+		VIDEO_G => video_g,
+		VIDEO_R => video_r,
 
 		AUDIO_L => audio_l,
 		AUDIO_R => audio_r,
Index: de1/atari800core_de1.vhd
===================================================================
--- de1/atari800core_de1.vhd	(revision 39)
+++ de1/atari800core_de1.vhd	(revision 40)
@@ -452,7 +452,7 @@
 GPIO_0(1) <= SIO_COMMAND;
 
 -- THROTTLE
-THROTTLE_COUNT_6502 <= std_logic_vector(to_unsigned(32-1,6));
+THROTTLE_COUNT_6502 <= std_logic_vector(to_unsigned(1,6));
 
 -- VIDEO
 VGA_HS <= not(VGA_HS_RAW xor VGA_VS_RAW);
@@ -469,11 +469,11 @@
 		CLK => CLK,
 		RESET_N => RESET_N and SDRAM_RESET_N and not(SYSTEM_RESET_REQUEST),
 
-		VGA_VS => VGA_VS_RAW,
-		VGA_HS => VGA_HS_RAW,
-		VGA_B => VGA_B,
-		VGA_G => VGA_G,
-		VGA_R => VGA_R,
+		VIDEO_VS => VGA_VS_RAW,
+		VIDEO_HS => VGA_HS_RAW,
+		VIDEO_B => VGA_B,
+		VIDEO_G => VGA_G,
+		VIDEO_R => VGA_R,
 
 		AUDIO_L => AUDIO_LEFT,
 		AUDIO_R => AUDIO_RIGHT,
@@ -534,7 +534,7 @@
 		SDRAM_ADDR => SDRAM_ADDR,
 		SDRAM_DO => SDRAM_DO,
 
-		SDRAM_REFRESH => open, -- TODO
+		ANTIC_REFRESH => open, -- TODO
 
 		RAM_ADDR => RAM_ADDR,
 		RAM_DO => RAM_DO,
Index: mcc216/atari800core_mcc.vhd
===================================================================
--- mcc216/atari800core_mcc.vhd	(revision 39)
+++ mcc216/atari800core_mcc.vhd	(revision 40)
@@ -18,12 +18,21 @@
 		TV : integer;  -- 1 = PAL, 0=NTSC
 		VIDEO : integer; -- 1 = SVIDEO, 2 = VGA
 		SCANDOUBLE : integer; -- 1 = YES, 0=NO, (+ later scanlines etc)
-		internal_ram : integer
+		internal_ram : integer;
+		ext_clock : integer
 	);
 	PORT
 	(
 		FPGA_CLK :  IN  STD_LOGIC;
 
+		-- For test bench
+		EXT_CLK_SDRAM : in std_logic_vector(ext_clock downto 1);
+		EXT_CLK : in std_logic_vector(ext_clock downto 1);
+		EXT_SDRAM_CLK : in std_logic_vector(ext_clock downto 1);
+                EXT_SVIDEO_DAC_CLK : in std_logic_vector(ext_clock downto 1);
+                EXT_SCANDOUBLE_CLK : in std_logic_vector(ext_clock downto 1);
+                EXT_PLL_LOCKED : in std_logic_vector(ext_clock downto 1);
+
 		PS2K_CLK :  IN  STD_LOGIC;
 		PS2K_DAT :  IN  STD_LOGIC;
 		PS2M_CLK :  IN  STD_LOGIC;
@@ -258,6 +267,10 @@
 	signal sdram_dq_i : std_logic_vector(15 downto 0);
 	
 	signal sdram_rdy : std_logic;
+	signal sdram_reset_ctrl_n_next : std_logic;
+	signal sdram_reset_ctrl_n_reg : std_logic;
+	signal sdram_reset_n_next : std_logic;
+	signal sdram_reset_n_reg : std_logic;
 
 	-- pokey keyboard
 	SIGNAL KEYBOARD_SCAN : std_logic_vector(5 downto 0);
@@ -314,36 +327,47 @@
   dac_out => audio_r
 );
 
-gen_tv_pal : if tv=1 generate
-	mcc_pll : entity work.pal_pll
-	PORT MAP(inclk0 => FPGA_CLK,
-			 c0 => CLK_PLL1,
-			 locked => PLL1_LOCKED);
-	mcc_pll2 : entity work.pll_downstream_pal
-	PORT MAP(inclk0 => CLK_PLL1,
-			 c0 => CLK_SDRAM,
-			 c1 => CLK,
-			 c2 => SDRAM_CLK,
-                         c3 => SVIDEO_DAC_CLK,
-                         c4 => SCANDOUBLE_CLK,      
-			 areset => not(PLL1_LOCKED),
-			 locked => PLL_LOCKED);
+gen_fake_pll : if ext_clock=1 generate
+	CLK_SDRAM <= EXT_CLK_SDRAM(1);
+	CLK <= EXT_CLK(1);
+	SDRAM_CLK <= EXT_CLK_SDRAM(1);
+	SVIDEO_DAC_CLK <= EXT_SVIDEO_DAC_CLK(1);
+	SCANDOUBLE_CLK <= EXT_SCANDOUBLE_CLK(1);
+	PLL_LOCKED <= EXT_PLL_LOCKED(1);
 end generate;
 
-gen_tv_ntsc : if tv=0 generate
-	mcc_pll : entity work.ntsc_pll
-	PORT MAP(inclk0 => FPGA_CLK,
-			 c0 => CLK_PLL1,
-			 locked => PLL1_LOCKED);
-	mcc_pll2 : entity work.pll_downstream_ntsc
-	PORT MAP(inclk0 => CLK_PLL1,
-			 c0 => CLK_SDRAM,
-			 c1 => CLK,
-			 c2 => SDRAM_CLK,
-                         c3 => SVIDEO_DAC_CLK,
-                         c4 => SCANDOUBLE_CLK,      
-			 areset => not(PLL1_LOCKED),
-			 locked => PLL_LOCKED);
+gen_real_pll : if ext_clock=0 generate
+	gen_tv_pal : if tv=1 generate
+		mcc_pll : entity work.pal_pll
+		PORT MAP(inclk0 => FPGA_CLK,
+				 c0 => CLK_PLL1,
+				 locked => PLL1_LOCKED);
+		mcc_pll2 : entity work.pll_downstream_pal
+		PORT MAP(inclk0 => CLK_PLL1,
+				 c0 => CLK_SDRAM,
+				 c1 => CLK,
+				 c2 => SDRAM_CLK,
+				 c3 => SVIDEO_DAC_CLK,
+				 c4 => SCANDOUBLE_CLK,      
+				 areset => not(PLL1_LOCKED),
+				 locked => PLL_LOCKED);
+	end generate;
+
+	gen_tv_ntsc : if tv=0 generate
+		mcc_pll : entity work.ntsc_pll
+		PORT MAP(inclk0 => FPGA_CLK,
+				 c0 => CLK_PLL1,
+				 locked => PLL1_LOCKED);
+		mcc_pll2 : entity work.pll_downstream_ntsc
+		PORT MAP(inclk0 => CLK_PLL1,
+				 c0 => CLK_SDRAM,
+				 c1 => CLK,
+				 c2 => SDRAM_CLK,
+				 c3 => SVIDEO_DAC_CLK,
+				 c4 => SCANDOUBLE_CLK,      
+				 areset => not(PLL1_LOCKED),
+				 locked => PLL_LOCKED);
+	end generate;
 end generate;
 
 reset_n <= PLL_LOCKED;
@@ -351,7 +375,7 @@
 JOY2_IN_N <= JOY2_n(4)&JOY2_n(0)&JOY2_n(1)&JOY2_n(2)&JOY2_n(3);
 
 -- THROTTLE
-THROTTLE_COUNT_6502 <= std_logic_vector(to_unsigned(32-1,6));
+THROTTLE_COUNT_6502 <= std_logic_vector(to_unsigned(1,6));
 
 --atari800xl : entity work.atari800core_helloworld
 --	GENERIC MAP
@@ -417,7 +441,7 @@
 	(
 		CLK => CLK,
 		--RESET_N => RESET_N and SDRAM_RESET_N and not(SYSTEM_RESET_REQUEST),
-		RESET_N => RESET_N and sdram_rdy,
+		RESET_N => RESET_N and SDRAM_RESET_N_REG,
 
 		VIDEO_VS => VIDEO_VS,
 		VIDEO_HS => VIDEO_HS,
@@ -474,11 +498,11 @@
 		THROTTLE_COUNT_6502 => THROTTLE_COUNT_6502
 	);
 
-	process(clk_sdram,reset_n)
+	process(clk_sdram,sdram_reset_ctrl_n_reg)
 	begin
-		if (reset_n='0') then
-			seq_reg <= "000000000001";
-			seq_ph_reg <= '0';
+		if (sdram_reset_ctrl_n_reg='0') then
+			seq_reg <= "100000000000";
+			seq_ph_reg <= '1';
 			ref_reg <= '0';
 
 			ram_do_reg <= (others=>'0');
@@ -499,6 +523,17 @@
 		end if;
 	end process;
 
+	process(clk,reset_n)
+	begin
+		if (reset_n='0') then
+			sdram_reset_n_reg <= '0';
+			sdram_reset_ctrl_n_reg <= '0';
+		elsif (clk'event and clk = '1') then
+			sdram_reset_n_reg <= sdram_reset_n_next;
+			sdram_reset_ctrl_n_reg <= reset_n;
+		end if;
+	end process;
+
 	-- Generate sdram sequence
 	process(seq_reg, seq_ph_reg, ref_reg)
 	begin
@@ -505,12 +540,20 @@
 		seq_next <= seq_reg(10 downto 0)&seq_reg(11);
 		seq_ph_next <= seq_ph_reg;
 		ref_next <= ref_reg;
-		if (seq_reg(10) = '1') then
+		if (seq_reg(11) = '1') then
 			seq_ph_next <= not(seq_ph_reg);
 			ref_next <= not(ref_reg);
 		end if;
 	end process;
 
+	process(seq_reg, seq_next, sdram_rdy, sdram_reset_n_reg)
+	begin
+		sdram_reset_n_next <= sdram_reset_n_reg;
+		if (sdram_rdy = '1' and seq_next(8)='1' and seq_reg(8)='0') then
+			sdram_reset_n_next <= '1';
+		end if;
+	end process;
+
 	-- Adapt SDRAM
 	process(sdram_request_reg, sdram_request, sdram_request_complete_reg, ram_do_reg, seq_reg, ram_do, ram_rd_active, ram_wr_active, SDRAM_WIDTH_8BIT_ACCESS, SDRAM_WRITE_ENABLE, SDRAM_READ_ENABLE, SDRAM_DI, SDRAM_ADDR)
 	begin
@@ -549,11 +592,11 @@
 		when "000000001000" =>
 			-- nop
 		when "000000010000" =>
+			sdram_request_complete_next <= '0';
 			-- nop
 		when "000000100000" =>
 			-- nop
 		when "000001000000" =>
-			sdram_request_complete_next <= '0';
 			if (SDRAM_READ_ENABLE = '1') then
 				if (SDRAM_WIDTH_8BIT_ACCESS = '1') then
 					if (SDRAM_ADDR(0) = '0') then
@@ -582,9 +625,9 @@
 		when "001000000000" =>
 			-- nop
 		when "010000000000" =>
+			sdram_request_complete_next <= '0';
 			-- nop
 		when "100000000000" =>
-			sdram_request_complete_next <= '0';
 			-- nop
 		when others =>
 			-- never
@@ -596,13 +639,13 @@
 	PORT MAP
 	(
 		CLK => CLK_SDRAM,
-		rst => not(reset_n),
+		rst => not(sdram_reset_ctrl_n_reg),
 		seq_cyc => seq_reg(11 downto 0),
 		seq_ph => seq_ph_reg,
 		--refr_cyc => ref_reg,
 		refr_cyc => SDRAM_REFRESH,
 
-		ap1_ram_sel => SDRAM_REQUEST_REG,
+		ap1_ram_sel => SDRAM_REQUEST_NEXT,
 		ap1_address => '0'&SDRAM_ADDR(22 downto 1),
 		ap1_rden => SDRAM_READ_ENABLE,
 		ap1_wren => SDRAM_WRITE_ENABLE,
Index: mcc216/build.sh
===================================================================
--- mcc216/build.sh	(revision 39)
+++ mcc216/build.sh	(revision 40)
@@ -20,7 +20,8 @@
 		"TV" => $PAL,
 		"SCANDOUBLE" => 0,
 		"VIDEO" => $VGA,
-		"internal_ram" => 16384
+		"internal_ram" => 16384,
+		"ext_clock" => 0
 	},
 	"PAL_SVIDEO" => 
 	{
@@ -27,7 +28,8 @@
 		"TV" => $PAL,
 		"SCANDOUBLE" => 0,
 		"VIDEO" => $SVIDEO,
-		"internal_ram" => 0
+		"internal_ram" => 0,
+		"ext_clock" => 0
 	},
 	"PAL_VGA" =>
 	{
@@ -34,7 +36,8 @@
 		"TV" => $PAL,
 		"SCANDOUBLE" => 1,
 		"VIDEO" => $VGA,
-		"internal_ram" => 0
+		"internal_ram" => 0,
+		"ext_clock" => 0
 	},
 	"NTSC_SVIDEO" =>
 	{
@@ -41,7 +44,8 @@
 		"TV" => $NTSC,
 		"SCANDOUBLE" => 0,
 		"VIDEO" => $SVIDEO,
-		"internal_ram" => 0
+		"internal_ram" => 0,
+		"ext_clock" => 0
 	},
 	"NTSC_VGA" => 
 	{
@@ -48,7 +52,8 @@
 		"TV" => $NTSC,
 		"SCANDOUBLE" => 1,
 		"VIDEO" => $VGA,
-		"internal_ram" => 0
+		"internal_ram" => 0,
+		"ext_clock" => 0
 	}
 );
 
Index: mcc216/simulate_full.sh
===================================================================
--- mcc216/simulate_full.sh	(revision 39)
+++ mcc216/simulate_full.sh	(revision 40)
@@ -32,9 +32,10 @@
 	cp `find ../../common/a8core/ -iname "*.vhdl"` .
 	cp `find ../../common/components/ -iname "*.vhd"` .
 	cp `find ../../common/components/ -iname "*.vhdl"` .
-	cp ../atari800core_mcc_nopll.vhd .
-	cp ../pll.vhd .
+	cp ../atari800core_mcc.vhd .
 	cp ../sdram_ctrl_3_ports.v .
+	cp ../*pll*.vhd* .
+	cp ../svideo/* .
 
         # set up project definition file
 	ls *.v | perl -e 'while (<>){s/(.*)/verilog work $1/;print $_;}' | cat > $name.prj
Index: mcc216/tb_full/atari800core_mcc_tb.vhd
===================================================================
--- mcc216/tb_full/atari800core_mcc_tb.vhd	(revision 39)
+++ mcc216/tb_full/atari800core_mcc_tb.vhd	(revision 40)
@@ -12,14 +12,19 @@
 
 architecture rtl of atari800core_mcc_tb is
 
-  constant CLK_A_PERIOD : time := 1 us / (1.79*16);
+--  constant CLK_PERIOD : time := 1 us / (1.79*16);
+--  constant CLK_PERIOD_FOUR : time := 1 us / (1.79*64);
+--  constant CLK_PERIOD_THREE : time := 1 us / (1.79*48);
+--  constant CLK_PERIOD_TWO : time := 1 us / (1.79*32);
+  constant CLK_PERIOD : time := 36ns;
+  constant CLK_PERIOD_FOUR : time := 9ns;
+  constant CLK_PERIOD_THREE : time := 12ns;
+  constant CLK_PERIOD_TWO : time := 18ns;
+  signal CLK : std_logic;
+  signal CLK_TWO : std_logic;
+  signal CLK_THREE : std_logic;
+  signal CLK_FOUR : std_logic;
 
-  signal CLK_A : std_logic;
-
-  constant CLK_B_PERIOD : time := 3 us / (1.79*16);
-
-  signal CLK_B : std_logic;
-
   signal reset_n : std_logic;
   signal reset : std_logic;
 
@@ -41,33 +46,62 @@
   signal	SDRAM_DQ : std_logic_vector(15 downto 0);
 
 begin
-	p_clk_gen_a : process
+	p_clk_gen_1 : process
 	begin
-	clk_a <= '1';
-	wait for CLK_A_PERIOD/2;
-	clk_a <= '0';
-	wait for CLK_A_PERIOD - (CLK_A_PERIOD/2 );
+	clk <= '1';
+	wait for CLK_PERIOD/2;
+	clk <= '0';
+	wait for CLK_PERIOD - (CLK_PERIOD/2 );
 	end process;
 
-	p_clk_gen_b : process
+	p_clk_gen_2 : process
 	begin
-	clk_b <= '1';
-	wait for CLK_B_PERIOD/2;
-	clk_b <= '0';
-	wait for CLK_B_PERIOD - (CLK_B_PERIOD/2 );
+	clk_two <= '1';
+	wait for CLK_PERIOD_TWO/2;
+	clk_two <= '0';
+	wait for CLK_PERIOD_TWO - (CLK_PERIOD_TWO/2 );
 	end process;
 
+	p_clk_gen_3 : process
+	begin
+	clk_three <= '1';
+	wait for CLK_PERIOD_three/2;
+	clk_three <= '0';
+	wait for CLK_PERIOD_three - (CLK_PERIOD_three/2 );
+	end process;
+
+	p_clk_gen_4 : process
+	begin
+	clk_four <= '1';
+	wait for CLK_PERIOD_four/2;
+	clk_four <= '0';
+	wait for CLK_PERIOD_four - (CLK_PERIOD_four/2 );
+	end process;
+
 	reset_n <= '0', '1' after 1000ns;
 
 	reset <= not(reset_n);
 
 atari : ENTITY work.atari800core_mcc 
+	GENERIC map
+	(
+		TV => 1,
+		VIDEO => 2,
+		SCANDOUBLE => 1,
+		internal_ram => 0,
+		ext_clock => 1
+	)
 	port map
 	(
-		CLK => clk_b,
-		CLK_SDRAM =>clk_a,
-		PLL_LOCKED=>reset_n,
+		FPGA_CLK => '0',
 
+		EXT_CLK_SDRAM(1) => clk_three,
+		EXT_CLK(1) => clk,
+		EXT_SDRAM_CLK(1) => clk_three,
+                EXT_SVIDEO_DAC_CLK(1) => clk_four,
+                EXT_SCANDOUBLE_CLK(1) => clk_two,
+                EXT_PLL_LOCKED(1) => reset_n,
+
 		PS2K_CLK => '1',
 		PS2K_DAT => '1',
 		PS2M_CLK => '1',
Index: mist/atari800core_mist.vhd
===================================================================
--- mist/atari800core_mist.vhd	(revision 39)
+++ mist/atari800core_mist.vhd	(revision 40)
@@ -453,7 +453,7 @@
 reset_n <= PLL_LOCKED;
 
 -- THROTTLE
-THROTTLE_COUNT_6502 <= std_logic_vector(to_unsigned(32-1,6));
+THROTTLE_COUNT_6502 <= std_logic_vector(to_unsigned(1,6));
 
 atarixl_simple_sdram1 : entity work.atari800core_simple_sdram
 	GENERIC MAP
@@ -468,11 +468,11 @@
 		CLK => CLK,
 		RESET_N => RESET_N and SDRAM_RESET_N and not(SYSTEM_RESET_REQUEST),
 
-		VGA_VS => VGA_VS_RAW,
-		VGA_HS => VGA_HS_RAW,
-		VGA_B => VGA_B,
-		VGA_G => VGA_G,
-		VGA_R => VGA_R,
+		VIDEO_VS => VGA_VS_RAW,
+		VIDEO_HS => VGA_HS_RAW,
+		VIDEO_B => VGA_B,
+		VIDEO_G => VGA_G,
+		VIDEO_R => VGA_R,
 
 		AUDIO_L => AUDIO_L_PCM,
 		AUDIO_R => AUDIO_R_PCM,
Index: replay/Replay.prj
===================================================================
--- replay/Replay.prj	(revision 39)
+++ replay/Replay.prj	(revision 40)
@@ -46,7 +46,6 @@
 gtia_player.vhdl
 gtia_priority.vhdl
 gtia.vhdl
-internalromram.vhd
 irq_glue.vhdl
 pia.vhdl
 pokey_countdown_timer.vhdl
@@ -66,6 +65,7 @@
 basic.vhdl
 os16.vhdl
 os16_loop.vhdl
+internalromram.vhd
 covox.vhd
 atari800core.vhd
 atari800core_simple_sdram.vhd
Index: replay/sdcard/atari800.bin
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: replay/sdcard/replay.ini
===================================================================
--- replay/sdcard/replay.ini	(revision 39)
+++ replay/sdcard/replay.ini	(revision 40)
@@ -98,262 +98,7 @@
 
 #How does this not conflict with RAM? I use this area...
 
-DATA = 0xff,0xff,0x00020000,2
-DATA = 0xff,0xff,0x00020002,2
-DATA = 0xff,0xff,0x00020004,2
-DATA = 0x88,0xff,0x00020006,2
-DATA = 0xa0,0xff,0x00020008,2
-DATA = 0,0xff,0x0002000A,2
-DATA = 0xc0,0xff,0x0002000C,2
-DATA = 0xff,0xff,0x0002000E,2
-DATA = 0xff,0xff,0x00020010,2
-DATA = 0xff,0xff,0x00020012,2
-DATA = 0xff,0xff,0x00020014,2
-DATA = 0xff,0xff,0x00020016,2
-DATA = 0x90,0xff,0x00020018,2
-DATA = 0x54,0xff,0x0002001A,2
-DATA = 0xff,0xff,0x0002001C,2
-DATA = 0xff,0xff,0x0002001E,2
-DATA = 0xff,0xff,0x00020020,2
-DATA = 0xff,0xff,0x00020022,2
-DATA = 0x81,0xff,0x00020024,2
-DATA = 0xff,0xff,0x00020026,2
-DATA = 0x82,0xff,0x00020028,2
-DATA = 0x57,0xff,0x0002002A,2
-DATA = 0x37,0xff,0x0002002C,2
-DATA = 0xff,0xff,0x0002002E,2
-DATA = 0xff,0xff,0x00020030,2
-DATA = 0xff,0xff,0x00020032,2
-DATA = 0x27,0xff,0x00020034,2
-DATA = 0x76,0xff,0x00020036,2
-DATA = 0x77,0xff,0x00020038,2
-DATA = 0x56,0xff,0x0002003A,2
-DATA = 0x36,0xff,0x0002003C,2
-DATA = 0xff,0xff,0x0002003E,2
-DATA = 0xff,0xff,0x00020040,2
-DATA = 0x22,0xff,0x00020042,2
-DATA = 0x26,0xff,0x00020044,2
-DATA = 0x72,0xff,0x00020046,2
-DATA = 0x52,0xff,0x00020048,2
-DATA = 0x30,0xff,0x0002004A,2
-DATA = 0x32,0xff,0x0002004C,2
-DATA = 0xff,0xff,0x0002004E,2
-DATA = 0xff,0xff,0x00020050,2
-DATA = 0x41,0xff,0x00020052,2
-DATA = 0x20,0xff,0x00020054,2
-DATA = 0x70,0xff,0x00020056,2
-DATA = 0x55,0xff,0x00020058,2
-DATA = 0x50,0xff,0x0002005A,2
-DATA = 0x35,0xff,0x0002005C,2
-DATA = 0xff,0xff,0x0002005E,2
-DATA = 0xff,0xff,0x00020060,2
-DATA = 0x43,0xff,0x00020062,2
-DATA = 0x25,0xff,0x00020064,2
-DATA = 0x71,0xff,0x00020066,2
-DATA = 0x75,0xff,0x00020068,2
-DATA = 0x53,0xff,0x0002006A,2
-DATA = 0x33,0xff,0x0002006C,2
-DATA = 0xff,0xff,0x0002006E,2
-DATA = 0xff,0xff,0x00020070,2
-DATA = 0xff,0xff,0x00020072,2
-DATA = 0x45,0xff,0x00020074,2
-DATA = 0x1,0xff,0x00020076,2
-DATA = 0x13,0xff,0x00020078,2
-DATA = 0x63,0xff,0x0002007A,2
-DATA = 0x65,0xff,0x0002007C,2
-DATA = 0xff,0xff,0x0002007E,2
-DATA = 0xff,0xff,0x00020080,2
-DATA = 0x40,0xff,0x00020082,2
-DATA = 0x5,0xff,0x00020084,2
-DATA = 0x15,0xff,0x00020086,2
-DATA = 0x10,0xff,0x00020088,2
-DATA = 0x62,0xff,0x0002008A,2
-DATA = 0x60,0xff,0x0002008C,2
-DATA = 0xff,0xff,0x0002008E,2
-DATA = 0xff,0xff,0x00020090,2
-DATA = 0x42,0xff,0x00020092,2
-DATA = 0x46,0xff,0x00020094,2
-DATA = 0x0,0xff,0x00020096,2
-DATA = 0x2,0xff,0x00020098,2
-DATA = 0x12,0xff,0x0002009A,2
-DATA = 0x66,0xff,0x0002009C,2
-DATA = 0xff,0xff,0x0002009E,2
-DATA = 0xff,0xff,0x000200A0,2
-DATA = 0xff,0xff,0x000200A2,2
-DATA = 0x6,0xff,0x000200A4,2
-DATA = 0xff,0xff,0x000200A6,2
-DATA = 0x16,0xff,0x000200A8,2
-DATA = 0x67,0xff,0x000200AA,2
-DATA = 0xff,0xff,0x000200AC,2
-DATA = 0xff,0xff,0x000200AE,2
-DATA = 0x74,0xff,0x000200B0,2
-DATA = 0x81,0xff,0x000200B2,2
-DATA = 0x14,0xff,0x000200B4,2
-DATA = 0x17,0xff,0x000200B6,2
-DATA = 0xff,0xff,0x000200B8,2
-DATA = 0x7,0xff,0x000200BA,2
-DATA = 0xff,0xff,0x000200BC,2
-DATA = 0xff,0xff,0x000200BE,2
-DATA = 0xff,0xff,0x000200C0,2
-DATA = 0xff,0xff,0x000200C2,2
-DATA = 0xff,0xff,0x000200C4,2
-DATA = 0xff,0xff,0x000200C6,2
-DATA = 0xff,0xff,0x000200C8,2
-DATA = 0xff,0xff,0x000200CA,2
-DATA = 0x64,0xff,0x000200CC,2
-DATA = 0xff,0xff,0x000200CE,2
-DATA = 0xff,0xff,0x000200D0,2
-DATA = 0xff,0xff,0x000200D2,2
-DATA = 0xff,0xff,0x000200D4,2
-DATA = 0xff,0xff,0x000200D6,2
-DATA = 0xff,0xff,0x000200D8,2
-DATA = 0xff,0xff,0x000200DA,2
-DATA = 0xff,0xff,0x000200DC,2
-DATA = 0xff,0xff,0x000200DE,2
-DATA = 0xff,0xff,0x000200E0,2
-DATA = 0xff,0xff,0x000200E2,2
-DATA = 0xff,0xff,0x000200E4,2
-DATA = 0xff,0xff,0x000200E6,2
-DATA = 0xff,0xff,0x000200E8,2
-DATA = 0xff,0xff,0x000200EA,2
-DATA = 0x34,0xff,0x000200EC,2
-DATA = 0xff,0xff,0x000200EE,2
-DATA = 0xff,0xff,0x000200F0,2
-DATA = 0xff,0xff,0x000200F2,2
-DATA = 0xff,0xff,0x000200F4,2
-DATA = 0xff,0xff,0x000200F6,2
-DATA = 0xff,0xff,0x000200F8,2
-DATA = 0xff,0xff,0x000200FA,2
-DATA = 0xff,0xff,0x000200FC,2
-DATA = 0xff,0xff,0x000200FE,2
-DATA = 0xff,0xff,0x00020100,2
-DATA = 0xff,0xff,0x00020102,2
-DATA = 0xff,0xff,0x00020104,2
-DATA = 0xff,0xff,0x00020106,2
-DATA = 0xff,0xff,0x00020108,2
-DATA = 0xff,0xff,0x0002010A,2
-DATA = 0xff,0xff,0x0002010C,2
-DATA = 0xff,0xff,0x0002010E,2
-DATA = 0xff,0xff,0x00020110,2
-DATA = 0xff,0xff,0x00020112,2
-DATA = 0xff,0xff,0x00020114,2
-DATA = 0xff,0xff,0x00020116,2
-DATA = 0xff,0xff,0x00020118,2
-DATA = 0xff,0xff,0x0002011A,2
-DATA = 0xff,0xff,0x0002011C,2
-DATA = 0xff,0xff,0x0002011E,2
-DATA = 0xff,0xff,0x00020120,2
-DATA = 0x47,0xff,0x00020122,2
-DATA = 0xff,0xff,0x00020124,2
-DATA = 0xff,0xff,0x00020126,2
-DATA = 0x82,0xff,0x00020128,2
-DATA = 0xff,0xff,0x0002012A,2
-DATA = 0xff,0xff,0x0002012C,2
-DATA = 0xff,0xff,0x0002012E,2
-DATA = 0xff,0xff,0x00020130,2
-DATA = 0xff,0xff,0x00020132,2
-DATA = 0xff,0xff,0x00020134,2
-DATA = 0xff,0xff,0x00020136,2
-DATA = 0xff,0xff,0x00020138,2
-DATA = 0xff,0xff,0x0002013A,2
-DATA = 0xff,0xff,0x0002013C,2
-DATA = 0xff,0xff,0x0002013E,2
-DATA = 0xff,0xff,0x00020140,2
-DATA = 0xff,0xff,0x00020142,2
-DATA = 0xff,0xff,0x00020144,2
-DATA = 0xff,0xff,0x00020146,2
-DATA = 0xff,0xff,0x00020148,2
-DATA = 0xff,0xff,0x0002014A,2
-DATA = 0xff,0xff,0x0002014C,2
-DATA = 0xff,0xff,0x0002014E,2
-DATA = 0xff,0xff,0x00020150,2
-DATA = 0xff,0xff,0x00020152,2
-DATA = 0xff,0xff,0x00020154,2
-DATA = 0xff,0xff,0x00020156,2
-DATA = 0xff,0xff,0x00020158,2
-DATA = 0xff,0xff,0x0002015A,2
-DATA = 0xff,0xff,0x0002015C,2
-DATA = 0xff,0xff,0x0002015E,2
-DATA = 0xff,0xff,0x00020160,2
-DATA = 0xff,0xff,0x00020162,2
-DATA = 0xff,0xff,0x00020164,2
-DATA = 0xff,0xff,0x00020166,2
-DATA = 0xff,0xff,0x00020168,2
-DATA = 0xff,0xff,0x0002016A,2
-DATA = 0xff,0xff,0x0002016C,2
-DATA = 0xff,0xff,0x0002016E,2
-DATA = 0xff,0xff,0x00020170,2
-DATA = 0xff,0xff,0x00020172,2
-DATA = 0xff,0xff,0x00020174,2
-DATA = 0xff,0xff,0x00020176,2
-DATA = 0xff,0xff,0x00020178,2
-DATA = 0xff,0xff,0x0002017A,2
-DATA = 0xff,0xff,0x0002017C,2
-DATA = 0xff,0xff,0x0002017E,2
-DATA = 0xff,0xff,0x00020180,2
-DATA = 0xff,0xff,0x00020182,2
-DATA = 0xff,0xff,0x00020184,2
-DATA = 0xff,0xff,0x00020186,2
-DATA = 0xff,0xff,0x00020188,2
-DATA = 0xff,0xff,0x0002018A,2
-DATA = 0xff,0xff,0x0002018C,2
-DATA = 0xff,0xff,0x0002018E,2
-DATA = 0xff,0xff,0x00020190,2
-DATA = 0xff,0xff,0x00020192,2
-DATA = 0xff,0xff,0x00020194,2
-DATA = 0xff,0xff,0x00020196,2
-DATA = 0xff,0xff,0x00020198,2
-DATA = 0xff,0xff,0x0002019A,2
-DATA = 0xff,0xff,0x0002019C,2
-DATA = 0xff,0xff,0x0002019E,2
-DATA = 0xff,0xff,0x000201A0,2
-DATA = 0xff,0xff,0x000201A2,2
-DATA = 0xff,0xff,0x000201A4,2
-DATA = 0xff,0xff,0x000201A6,2
-DATA = 0xff,0xff,0x000201A8,2
-DATA = 0xff,0xff,0x000201AA,2
-DATA = 0xff,0xff,0x000201AC,2
-DATA = 0xff,0xff,0x000201AE,2
-DATA = 0xff,0xff,0x000201B0,2
-DATA = 0xff,0xff,0x000201B2,2
-DATA = 0xff,0xff,0x000201B4,2
-DATA = 0xff,0xff,0x000201B6,2
-DATA = 0xff,0xff,0x000201B8,2
-DATA = 0xff,0xff,0x000201BA,2
-DATA = 0xff,0xff,0x000201BC,2
-DATA = 0xff,0xff,0x000201BE,2
-DATA = 0xff,0xff,0x000201C0,2
-DATA = 0xff,0xff,0x000201C2,2
-DATA = 0xff,0xff,0x000201C4,2
-DATA = 0xff,0xff,0x000201C6,2
-DATA = 0xff,0xff,0x000201C8,2
-DATA = 0xff,0xff,0x000201CA,2
-DATA = 0xff,0xff,0x000201CC,2
-DATA = 0xff,0xff,0x000201CE,2
-DATA = 0xff,0xff,0x000201D0,2
-DATA = 0xff,0xff,0x000201D2,2
-DATA = 0xff,0xff,0x000201D4,2
-DATA = 0xff,0xff,0x000201D6,2
-DATA = 0x21,0xff,0x000201D8,2
-DATA = 0xff,0xff,0x000201DA,2
-DATA = 0xff,0xff,0x000201DC,2
-DATA = 0xff,0xff,0x000201DE,2
-DATA = 0xff,0xff,0x000201E0,2
-DATA = 0xff,0xff,0x000201E2,2
-DATA = 0xff,0xff,0x000201E4,2
-DATA = 0xff,0xff,0x000201E6,2
-DATA = 0xff,0xff,0x000201E8,2
-DATA = 0xff,0xff,0x000201EA,2
-DATA = 0xff,0xff,0x000201EC,2
-DATA = 0xff,0xff,0x000201EE,2
-DATA = 0xff,0xff,0x000201F0,2
-DATA = 0xff,0xff,0x000201F2,2
-DATA = 0xff,0xff,0x000201F4,2
-DATA = 0xff,0xff,0x000201F6,2
-DATA = 0xff,0xff,0x000201F8,2
-DATA = 0xff,0xff,0x000201FA,2
-DATA = 0xff,0xff,0x000201FC,2
-DATA = 0xff,0xff,0x000201FE,2
+#DATA = 0xff,0xff,0x000201FE,2
 
 [MENU]
 
@@ -370,6 +115,12 @@
 option = "Med (1)",   0x00020000
 option = "Min (0)",   0x00000000
 
+item = "Scanlines",   0x00180000,dynamic
+option = "Max (3)",   0x00180000
+option = "Med (2)",   0x00100000
+option = "Min (1)",   0x00080000,default
+option = "Off (0)",   0x00000000
+
 ## menu entry - ATARIXL SETUP
 title = "800XL Setup"
 
@@ -391,3 +142,10 @@
 option = "OSB original",0x00000028
 option = "OSA original",0x00000030
 
+item = "Speed",0x00003e00,dynamic
+option = "1x", 0x00000200,default
+option = "2x", 0x00000400
+option = "4x", 0x00000800
+option = "8x", 0x00001000
+option = "16x",0x00002000
+
Index: replay/source/Core_Top.vhd
===================================================================
--- replay/source/Core_Top.vhd	(revision 39)
+++ replay/source/Core_Top.vhd	(revision 40)
@@ -93,6 +93,7 @@
     i_Rst_Core            : in    bit1;
     i_Halt_Core           : in    bit1;
     i_HD_Mode             : in    bit1; -- selects between the HD and SD video mode generic
+    i_scn_lvl             : in  word(1 downto 0); -- sets scanline strength: "00": off ... "11": maximum
     o_act_led_n           : out   bit1;
     --
     i_Audio_lvl           : in    word(1 downto 0);
@@ -145,7 +146,8 @@
     CONF_DI               : in    word(7 downto 0);
 
     ram_select            : in word(2 downto 0);
-    rom_select            : in word(5 downto 0)
+    rom_select            : in word(5 downto 0);
+    speed_select          : in word(4 downto 0)
     );
 end;
 
@@ -155,6 +157,8 @@
   constant int_dla_core_debug : boolean := false;
 
   signal PLL_LOCKED : std_logic;
+  signal PLL_LOCKED_NEXT : std_logic_vector(2 downto 0);
+  signal PLL_LOCKED_REG : std_logic_vector(2 downto 0);
 
   signal res_s                     : bit1;
   signal core_en_s                 : bit1;
@@ -228,6 +232,304 @@
   signal keyboard_scan_inv : std_logic_vector(5 downto 0);
   signal matrix_out_match : std_logic_vector(7 downto 0);
 
+  constant c_800xl_kb_map : keylut_type := (
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"88",X"ff",
+X"a0",X"ff",
+X"00",X"ff",
+X"c0",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"90",X"ff",
+X"54",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"81",X"ff",
+X"ff",X"ff",
+X"82",X"ff",
+X"57",X"ff",
+X"37",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"27",X"ff",
+X"76",X"ff",
+X"77",X"ff",
+X"56",X"ff",
+X"36",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"22",X"ff",
+X"26",X"ff",
+X"72",X"ff",
+X"52",X"ff",
+X"30",X"ff",
+X"32",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"41",X"ff",
+X"20",X"ff",
+X"70",X"ff",
+X"55",X"ff",
+X"50",X"ff",
+X"35",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"43",X"ff",
+X"25",X"ff",
+X"71",X"ff",
+X"75",X"ff",
+X"53",X"ff",
+X"33",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"45",X"ff",
+X"01",X"ff",
+X"13",X"ff",
+X"63",X"ff",
+X"65",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"40",X"ff",
+X"05",X"ff",
+X"15",X"ff",
+X"10",X"ff",
+X"62",X"ff",
+X"60",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"42",X"ff",
+X"46",X"ff",
+X"00",X"ff",
+X"02",X"ff",
+X"12",X"ff",
+X"66",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"06",X"ff",
+X"ff",X"ff",
+X"16",X"ff",
+X"67",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"74",X"ff",
+X"81",X"ff",
+X"14",X"ff",
+X"17",X"ff",
+X"ff",X"ff",
+X"07",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"64",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"34",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"47",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"82",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"21",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff",
+X"ff",X"ff"
+
+--    --    x0          x1          x2          x3          x4          x5          x6          x7          x8          x9          xA          xB          xC          xD          xE          xF               
+--    --    --    --    F9    F9    --    --    F5    F5    F3    F3    F1    F1    F2    F2    F12   F12   --    --    F10   F10   F8    F8    F6    F6    F4    F4    STOP  STOP  POUND POUND --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"71",X"FF",X"72",X"FF",X"73",X"FF",X"60",X"73",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"60",X"74",X"60",X"71",X"60",X"72",X"00",X"FF",X"17",X"FF",X"FF",X"FF",  -- 0x
+--    --    --    --   lALT  lALT  lSHI  lSHI   --    --    +     +     Q     Q     1     1     --    --    --    --    --    --    Z     Z     S     S     A     A     W     W     2     2     --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"60",X"FF",X"FF",X"FF",X"27",X"FF",X"01",X"FF",X"07",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"63",X"FF",X"62",X"FF",X"65",X"FF",X"66",X"FF",X"04",X"FF",X"FF",X"FF",  -- 1x
+--    --    --    --    C     C     X     X     D     D     E     E     4     4     3     3     --    --    --    --   SPAC  SPAC   V     V     F     F     T     T     R     R     5     5     --    --         
+--        X"FF",X"FF",X"53",X"FF",X"50",X"FF",X"55",X"FF",X"61",X"FF",x"64",X"FF",X"67",X"FF",X"FF",X"FF",X"FF",X"FF",X"03",X"FF",X"40",X"FF",X"52",X"FF",X"51",X"FF",X"56",X"FF",X"57",X"FF",X"FF",X"FF",  -- 2x
+--    --    --    --    N     N     B     B     H     H     G     G     Y     Y     6     6     --    --    --    --    --    --    M     M     J     J     U     U     7     7     8     8     --    --         
+--        X"FF",X"FF",X"30",X"FF",X"43",X"FF",X"42",X"FF",X"45",X"FF",X"46",X"FF",X"54",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"33",X"FF",X"35",X"FF",X"41",X"FF",X"47",X"FF",X"44",X"FF",X"FF",X"FF",  -- 3x
+--    --    --    --    ,     ,     K     K     I     I     O     O     0     0     9     9     --    --    --    --    .     .     /     /     L     L     ;     ;     P     P     +     +     --    --         
+--        X"FF",X"FF",X"20",X"FF",X"32",X"FF",X"36",X"FF",X"31",X"FF",X"34",X"FF",X"37",X"FF",X"FF",X"FF",X"FF",X"FF",X"23",X"FF",X"10",X"FF",X"25",X"FF",X"15",X"FF",X"26",X"FF",X"27",X"FF",X"FF",X"FF",  -- 4x
+--    --    --    --    --    --    :     :     --    --    @     @     -     -     --    --    --    --   CAPS  CAPS  rSHI  rSHI  ENTE  ENTE   *     *     --    --    UP    UP    --    --    --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"22",X"FF",X"FF",X"FF",X"21",X"FF",X"24",X"FF",X"FF",X"FF",X"FF",X"FF",X"C0",X"FF",X"13",X"FF",X"76",X"FF",X"16",X"FF",X"FF",X"FF",X"11",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 5x
+--    --    --    --    --    --    --    --    --    --    --    --    --    --   BKSP  BKSP   --    --    --    --    KP1   KP1   --    --    KP4   KP4   KP7   KP7   --    --    --    --    --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"77",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",x"84",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 6x
+--    --    KP0   KP0   KP.   KP.   KP2   KP2   KP5   KP5   KP6   KP6   KP8   KP8   ESC   ESC   NUM   NUM   F11   F11   KP+   KP+   KP3   KP3   KP-   KP-   KP*   KP*   KP9   KP9  SCRL  SCRL   --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"82",X"FF",X"90",X"FF",X"88",X"FF",X"81",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 7x
+--    --
+--    -- "0xE0-based" PS/2 SET 2
+--    --
+--    --    x0          x1          x2          x3          x4          x5          x6          x7          x8          x9          xA          xB          xC          xD          xE          xF               
+--    --    --    --    --    --    --    --    F7    F7    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"74",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 0x
+--    --    --    --   rALT  rALT *PRNT *PRNT   --    --   rCTL  rCTL   --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --   lGUI  lGUI        
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"06",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"02",X"FF",  -- 1x
+--    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --   rGUI  rGUI   --    --    --    --    --    --    --    --    --    --    --    --    --    --   APPS  APPS        
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"02",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 2x
+--    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    PWR   PWR   --    --    --    --    --    --    --    --    --    --    --    --    --    --   SLEE  SLEE        
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 3x
+--    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    KP/   KP/   --    --    --    --    --    --    --    --    --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 4x
+--    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --   KPen  KPen   --    --    --    --    --    --   WAKE  WAKE   --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 5x
+--    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    --    END   END   --    --   lARR  lARR  HOME  HOME   --    --    --    --    --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"77",X"FF",X"FF",X"FF",X"60",X"75",X"14",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",  -- 6x
+--    --    INS   INS   DEL   DEL  dARR  dARR   --    --   rARR  rARR  uARR  uARR   --    --    --    --    --    --    --    --    =     =     --    --  *SCRN *SCRN  PGUP  PGUP   --    --    --    --         
+--        X"FF",X"FF",X"FF",X"FF",X"70",X"FF",X"FF",X"FF",X"75",X"FF",X"60",X"70",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"12",X"FF",X"FF",X"FF",X"FF",X"FF",X"A0",X"FF",X"FF",X"FF",X"FF",X"FF"   -- 7x
+       );
+
+
 begin
   -- core control
   res_s <= i_Rst_Core;
@@ -275,9 +577,20 @@
 	CONSOL_OPTION <= static_keys(4);
 --	system_reset_request <= static_keys(3);
 
-	PLL_LOCKED <= not(i_rst_sys or i_Rst_Core);
+	PLL_LOCKED <= pll_locked_reg(2);
+
+	process(i_rst_sys, i_rst_core, pll_locked_reg, i_ena_sys)
+	begin
+		pll_locked_next <= pll_locked_reg;
+		if (i_ena_sys = '1') then
+			pll_locked_next(0) <= not(i_rst_sys or i_Rst_Core);
+		end if;
+		pll_locked_next(2 downto 1) <= pll_locked_reg(1 downto 0);
+	end process;
 	
-	THROTTLE_COUNT_6502 <= std_logic_vector(to_unsigned(16-1,6));
+	
+	THROTTLE_COUNT_6502 <= '0'&speed_select;
+	--THROTTLE_COUNT_6502 <= "000100";
 
 atarixl_simple_sdram1 : entity work.atari800core_simple_sdram
 	GENERIC MAP
@@ -291,11 +604,11 @@
 		CLK => i_clk_sys,
 		RESET_N => PLL_LOCKED,
 
-		VGA_VS => core_vsync,
-		VGA_HS => core_hsync,
-		VGA_B => core_b_s,
-		VGA_G => core_g_s,
-		VGA_R => core_r_s,
+		VIDEO_VS => core_vsync,
+		VIDEO_HS => core_hsync,
+		VIDEO_B => core_b_s,
+		VIDEO_G => core_g_s,
+		VIDEO_R => core_r_s,
 
 		AUDIO_L => lsound_s,
 		AUDIO_R => rsound_s,
@@ -393,7 +706,7 @@
 
   u_Kbd : entity work.Replay_TranslatePS2
   generic map (
-    g_kb_map              => c_vic20_kb_map -- TODO make atari version rather than putting it all in the ini file!
+    g_kb_map              => c_800xl_kb_map
   )
   port map (
     i_ClK_Sys               => i_ClK_Sys,
@@ -518,6 +831,7 @@
       i_Rst_Sys       => i_Rst_Sys,
       --
       i_HD_Mode       => i_HD_Mode,
+      i_scanline_lvl  => i_scn_lvl,
       --
       i_Vid_r         => std_logic_vector(core_r_s),
       i_Vid_g         => std_logic_vector(core_g_s),
@@ -623,9 +937,11 @@
 	if (i_rst_sys = '1') then
 		ddr_request_pending_reg <= '0';
 		ddr_response_pending_reg <= '0';
+		pll_locked_reg <= (others=>'0');
 	elsif (i_clk_sys'event and i_clk_sys='1') then
 		ddr_request_pending_reg <= ddr_request_pending_next;
 		ddr_response_pending_reg <= ddr_response_pending_next;
+		pll_locked_reg <= pll_locked_next;
 	end if;
 end process;
 
Index: replay/source/Replay_Top.vhd
===================================================================
--- replay/source/Replay_Top.vhd	(revision 39)
+++ replay/source/Replay_Top.vhd	(revision 40)
@@ -472,6 +472,7 @@
     i_Rst_Core            => rst_soft,
     i_Halt_Core           => halt_soft,
     i_HD_Mode             => cfg_dynamic(16),
+    i_scn_lvl             => cfg_dynamic(20 downto 19), -- sets scanline strength: "00": off ... "11": maximum
     o_act_led_n           => o_Disk_Led,
     --
     i_Audio_lvl           => cfg_dynamic(18 downto 17),
@@ -523,7 +524,8 @@
     CONF_DI               => mch_data,
     -- 
     ram_select            => cfg_dynamic(2 downto 0),
-    rom_select           => cfg_dynamic(8 downto 3)
+    rom_select            => cfg_dynamic(8 downto 3),
+    speed_select          => cfg_dynamic(13 downto 9)
     );
 
   --                            8                16              1             1           1            1           1           1            1        1          1           1                 2
