Index: papilioduo/atari800core_papilioduo.vhd
===================================================================
--- papilioduo/atari800core_papilioduo.vhd	(revision 330)
+++ papilioduo/atari800core_papilioduo.vhd	(revision 331)
@@ -15,8 +15,10 @@
 ENTITY atari800core_papilioduo IS 
 	GENERIC
 	(
-		TV : integer := 1;  -- 1 = PAL, 0=NTSC
-		SCANDOUBLE : integer := 0; -- 1 = YES, 0=NO, (+ later scanlines etc)
+		TV : integer;  -- 1 = PAL, 0=NTSC
+		VIDEO : integer; -- 1 = RGB, 2 = VGA
+		COMPOSITE_SYNC : integer; --0 = no, 1 = yes!
+		SCANDOUBLE : integer; -- 1 = YES, 0=NO, (+ later scanlines etc)
 		internal_rom : integer := 1 ;
 		--internal_ram : integer := 16384;
 		internal_ram : integer := 0;
@@ -209,16 +211,11 @@
 	-- scandoubler
 	signal half_scandouble_enable_reg : std_logic;
 	signal half_scandouble_enable_next : std_logic;
+	signal scanlines_reg : std_logic;
+	signal scanlines_next : std_logic;
+ 	SIGNAL COMPOSITE_ON_HSYNC : std_logic;
+ 	SIGNAL VGA : std_logic;
 
-	function palette_from_scandouble( scandouble : integer ) return integer is
-	begin
-		if (scandouble = 1) then
-			return 0;
-		else
-			return 1;
-		end if;
-	end palette_from_scandouble;
-	
 	-- dma/virtual drive
 	signal DMA_ADDR_FETCH : std_logic_vector(23 downto 0);
 	signal DMA_WRITE_DATA : std_logic_vector(31 downto 0);
@@ -398,7 +395,7 @@
 		internal_rom => internal_rom,
 		internal_ram => internal_ram,
 		video_bits => 8,
-		palette => palette_from_scandouble(scandouble),
+		palette => 0,
 		low_memory => 2,
                 STEREO                     => 0,
                 COVOX                      => 0
@@ -479,59 +476,57 @@
 	);
 
 -- Video options
-	gen_scandouble_off: if scandouble=0 generate
-		VGA_HSYNC <= not(VIDEO_HS xor VIDEO_VS);
-		VGA_VSYNC <= not(VIDEO_VS);
-		VGA_BLUE <= VIDEO_B(7 downto 4);
-		VGA_GREEN <= VIDEO_G(7 downto 4);
-		VGA_RED <= VIDEO_R(7 downto 4);
-	end generate;
+	pal <= '1' when tv=1 else '0';
+	vga <= '1' when video=2 else '0';
+	composite_on_hsync <= '1' when composite_sync=1 else '0';
 
-	gen_scandouble_on: if scandouble=1 generate
-		process(clk,reset_n)
-		begin
-			if (reset_n='0') then
-				half_scandouble_enable_reg <= '0';
-			elsif (clk'event and clk='1') then
-				half_scandouble_enable_reg <= half_scandouble_enable_next;
-			end if;
-		end process;
+	process(clk,RESET_N,reset_atari)
+	begin
+		if ((RESET_N and not(reset_atari))='0') then
+			half_scandouble_enable_reg <= '0';
+			scanlines_reg <= '0';
+		elsif (clk'event and clk='1') then
+			half_scandouble_enable_reg <= half_scandouble_enable_next;
+			scanlines_reg <= scanlines_next;
+		end if;
+	end process;
 
-		half_scandouble_enable_next <= not(half_scandouble_enable_reg);
+	half_scandouble_enable_next <= not(half_scandouble_enable_reg);
+	scanlines_next <= scanlines_reg xor (not(ps2_keys(16#11#)) and ps2_keys_next(16#11#)); -- left alt
 
-		scandoubler1: entity work.scandoubler
-		PORT MAP
-		( 
-			CLK => CLK,
-		        RESET_N => reset_n,
-			
-			VGA => '1',
-			COMPOSITE_ON_HSYNC => '1', -- TODO
+	scandoubler1: entity work.scandoubler
+	PORT MAP
+	( 
+		CLK => CLK,
+	        RESET_N => reset_n,
+		
+		VGA => vga,
+		COMPOSITE_ON_HSYNC => composite_on_hsync,
 
-			colour_enable => half_scandouble_enable_reg,
-			doubled_enable => '1',
-			
-			-- GTIA interface
-			pal => PAL,
-			colour_in => VIDEO_B,
-			vsync_in => VIDEO_VS,
-			hsync_in => VIDEO_HS,
-			
-			-- TO TV...
-			R => VGA_RED,
-			G => VGA_GREEN,
-			B => VGA_BLUE,
-			
-			VSYNC => VGA_VSYNC,
-			HSYNC => VGA_HSYNC
-		);
-	end generate;
+		colour_enable => half_scandouble_enable_reg,
+		doubled_enable => '1',
+		scanlines_on => scanlines_reg,
+		
+		-- GTIA interface
+		pal => PAL,
+		colour_in => VIDEO_B,
+		vsync_in => VIDEO_VS,
+		hsync_in => VIDEO_HS,
+		
+		-- TO TV...
+		R => VGA_RED,
+		G => VGA_GREEN,
+		B => VGA_BLUE,
+		
+		VSYNC => VGA_VSYNC,
+		HSYNC => VGA_HSYNC
+	);
 
 zpu: entity work.zpucore
 	GENERIC MAP
 	(
 		platform => 1,
-		spi_clock_div => 1, -- 28MHz/2. Max for SD cards is 25MHz...
+		spi_clock_div => 2, -- 28MHz/2. Max for SD cards is 25MHz...
 		usb => 0
 	)
 	PORT MAP
Index: papilioduo/build.pl
===================================================================
--- papilioduo/build.pl	(nonexistent)
+++ papilioduo/build.pl	(revision 331)
@@ -0,0 +1,141 @@
+#!/usr/bin/perl -w
+use strict;
+
+my $wanted_variant = shift @ARGV;
+
+my $name="papilioduo";
+
+#variants...
+my $PAL = 1;
+my $NTSC = 0;
+
+my $RGB = 1; # i.e. not scandoubled
+my $VGA = 2;
+
+#Added like this to the generated qsf
+#set_parameter -name TV 1
+
+my %variants = 
+(
+	"PAL_RGB" => 
+	{
+		"TV" => $PAL,
+		"SCANDOUBLE" => 0,
+		"VIDEO" => $RGB,
+		"COMPOSITE_SYNC" => 1
+	},
+	"PAL_RGBHV" => 
+	{
+		"TV" => $PAL,
+		"SCANDOUBLE" => 0,
+		"VIDEO" => $RGB,
+		"COMPOSITE_SYNC" => 0
+	},
+	"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,
+		"SCANDOUBLE" => 0,
+		"VIDEO" => $RGB, 
+		"COMPOSITE_SYNC" => 1
+	},
+	"NTSC_RGBHV" =>
+	{
+		"TV" => $NTSC,
+		"SCANDOUBLE" => 0,
+		"VIDEO" => $RGB, 
+		"COMPOSITE_SYNC" => 0
+	},
+	"NTSC_VGA" => 
+	{
+		"TV" => $NTSC,
+		"SCANDOUBLE" => 1,
+		"VIDEO" => $VGA,
+		"COMPOSITE_SYNC" => 0
+	},
+	"NTSC_VGA_CS" => 
+	{
+		"TV" => $NTSC,
+		"SCANDOUBLE" => 1,
+		"VIDEO" => $VGA,
+		"COMPOSITE_SYNC" => 1
+	}
+);
+
+if (not defined $wanted_variant or (not exists $variants{$wanted_variant} and $wanted_variant ne "ALL"))
+{
+	die "Provide variant of ALL or ".join ",",sort keys %variants;
+}
+
+foreach my $variant (sort keys %variants)
+{
+	next if ($wanted_variant ne $variant and $wanted_variant ne "ALL");
+	print "Building $variant of $name\n";
+
+	my $dir = "build_$variant";
+	`rm -rf $dir`;
+	mkdir $dir;
+	chdir $dir;
+
+	`cp -p ../pll/* .`;
+	`cp -p ../../common/a8core/*.vhd .`;
+	`cp -p ../../common/a8core/*.vhdl .`;
+	`cp -p ../../common/components/*.vhd .`;
+	`cp -p ../../common/components/*.vhdl .`;
+	`cp -p ../../common/zpu/*.vhd .`;
+	`cp -p ../../common/zpu/*.vhdl .`;
+	`cp -p ../*.vhd .`;
+	`cp -p ../*.vhdl .`;
+
+	`cp -p ../$name.ucf .`;
+	`cp -p ../$name.ut .`;
+	`cp -p ../$name.prj .`;
+
+	`mkdir -p xst/projnav.tmp/`;
+
+	`cp -p ../*.xst .`;
+	# TODO make project file `../makexst ../atari800core.qsf ./common/a8core ./common/components ./common/zpu`;
+	my $generics = "-generics {";
+	foreach my $key (sort keys %{$variants{$variant}})
+	{
+		my $val = $variants{$variant}->{$key};
+		$generics.="$key=$val ";
+	}
+	$generics .= "}\n";
+	`echo '$generics' >> $name.xst`;
+
+	`echo "Starting Synthesis" >> build.log 2>>build.err`;
+	`xst -intstyle ise -ifn $name.xst -ofn $name.syr >> build.log 2>>build.err`;
+	
+	`echo "Starting NGD" >> build.log 2>>build.err`;
+	`ngdbuild -intstyle ise -uc $name.ucf -dd _ngo -nt timestamp  -p xc6slx9-tqg144-3 $name.ngc $name.ngd >> build.log 2>>build.err`;
+	
+	`echo "Starting Map..." >> build.log 2>>build.err`;
+	`map -intstyle ise -p xc6slx9-tqg144-3 -w -logic_opt off -ol high -t 1 -xt 0 -register_duplication off -r 4 -global_opt off -mt off -detail -ir off -pr off -lc off -power off -o ${name}_map.ncd $name.ngd $name.pcf >> build.log 2>>build.err`;
+	
+	`echo "Starting Place & Route..." >> build.log 2>>build.err`;
+	`par -w -intstyle ise -ol high -mt off ${name}_map.ncd $name.ncd $name.pcf >> build.log 2>>build.err`;
+	
+	`echo "Starting Timing Analysis..." >> build.log 2>>build.err`;
+	`trce -intstyle ise -v 3 -s 3 -n 3 -fastpaths -xml $name.twx $name.ncd -o $name.twr $name.pcf >> build.log 2>>build.err`;
+	
+	`echo "Starting Bitgen..." >> build.log 2>>build.err`;
+	`bitgen -intstyle ise -f $name.ut $name.ncd >> build.log 2>>build.err`;
+
+	
+	chdir "..";
+}
+

Property changes on: papilioduo/build.pl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: papilioduo/build.sh
===================================================================
--- papilioduo/build.sh	(revision 330)
+++ papilioduo/build.sh	(revision 331)
@@ -1,49 +1,18 @@
 #!/bin/bash
 
-name=papilioduo
 args=$@
 shift
 
 . /home/markw/fpga/xilinx/14.7/ISE_DS/settings64.sh
 
-mkdir -p build
-pushd build
+export XILINX_DSP
+export LD_LIBRARY_PATH
+export XILINX_EDK
+export PATH
+export XILINX_PLANAHEAD
+export XILINX
 
-# copy source files
-cp -p ../pll/* .
-cp -p ../../common/a8core/*.vhd .
-cp -p ../../common/a8core/*.vhdl .
-cp -p ../../common/components/*.vhd .
-cp -p ../../common/components/*.vhdl .
-cp -p ../../common/zpu/*.vhd .
-cp -p ../../common/zpu/*.vhdl .
-#rm -f delay_line.vhdl
-cp -p ../*.vhd .
-cp -p ../*.vhdl .
-cp -p ../*.xst .
+which xst
 
-cp -p ../$name.ucf .
-cp -p ../$name.ut .
-cp -p ../$name.prj .
+./build.pl ${args}
 
-mkdir -p xst/projnav.tmp/
-
-echo "Starting Synthesis"
-xst -intstyle ise -ifn $name.xst -ofn $name.syr
-
-echo "Starting NGD"
-ngdbuild -intstyle ise -uc $name.ucf -dd _ngo -nt timestamp  -p xc6slx9-tqg144-3 $name.ngc $name.ngd
-
-echo "Starting Map..."
-map -intstyle ise -p xc6slx9-tqg144-3 -w -logic_opt off -ol high -t 1 -xt 0 -register_duplication off -r 4 -global_opt off -mt off -detail -ir off -pr off -lc off -power off -o $name_map.ncd $name.ngd $name.pcf
-
-echo "Starting Place & Route..."
-par -w -intstyle ise -ol high -mt off $name_map.ncd $name.ncd $name.pcf
-
-echo "Starting Timing Analysis..."
-trce -intstyle ise -v 3 -s 3 -n 3 -fastpaths -xml $name.twx $name.ncd -o $name.twr $name.pcf
-
-echo "Starting Bitgen..."
-bitgen -intstyle ise -f $name.ut $name.ncd
-
-popd
Index: papilioduo/zpu_rom.vhdl
===================================================================
--- papilioduo/zpu_rom.vhdl	(revision 330)
+++ papilioduo/zpu_rom.vhdl	(revision 331)
@@ -2875,7 +2875,7 @@
 X"04fc3d0d",
 X"800b83e7",
 X"bc348480",
-X"805284a4",
+X"80528498",
 X"808051ff",
 X"b5923f83",
 X"e0800880",
@@ -2939,7 +2939,7 @@
 X"08f40508",
 X"872e0981",
 X"06ffab38",
-X"84a88080",
+X"849c8080",
 X"51ebcf3f",
 X"ff0b83e7",
 X"c00c800b",
