-- Interactive Audio Manipulation Processor -- -- file: ColoursChooser.vhd -- status: simulated - no known bugs -- -- author: Stephen Tang, modified from code by Hamblen (see References -- section of report, reference [2]) -- -- This file contains the code that actually determines what appears -- onscreen. LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.all; USE IEEE.STD_LOGIC_ARITH.all; USE IEEE.STD_LOGIC_UNSIGNED.all; library work; use work.Constants_Pkg.all; entity ColourChooser is port( clock, reset: in std_logic; countX, countY: std_logic_vector(DISPLAY_X-1 downto 0); -- current pixel in the video sweep cursorX: in std_logic_vector(DISPLAY_X-1 downto 0); cursorY: in std_logic_vector(DISPLAY_Y-1 downto 0); -- current user input cursor position vga_red, vga_green, vga_blue: out boolean ); end ColourChooser; architecture behavioural of ColourChooser is -- declare a bunch of dimensional constants for the onscreen sprites constant CURSOR_WIDTH: std_logic_vector(9 downto 0) := "0000001000"; -- 8 pixels constant CURSOR_HEIGHT: std_logic_vector(9 downto 0) := "0000001000"; -- 8 pixels constant YOU_X1: std_logic_vector(9 downto 0) := "0100110110"; -- 310 constant YOU_X2: std_logic_vector(9 downto 0) := "0101001010"; -- 330 constant YOU_Y1: std_logic_vector(9 downto 0) := "0011100110"; -- 230 constant YOU_Y2: std_logic_vector(9 downto 0) := "0011111010"; -- 250 -- left-side speaker x-coordinates constant SPK_L_X1: std_logic_vector(9 downto 0) := "0000000000"; -- 000 constant SPK_L_X2: std_logic_vector(9 downto 0) := "0000011110"; -- 030 -- right-side speaker x-coordinates constant SPK_R_X1: std_logic_vector(9 downto 0) := "1001100010"; -- 610 constant SPK_R_X2: std_logic_vector(9 downto 0) := "1010000000"; -- 640 -- top-half speaker y-coordinates constant SPK_T_Y1: std_logic_vector(9 downto 0) := "0000000000"; -- 000 constant SPK_T_Y2: std_logic_vector(9 downto 0) := "0000011110"; -- 030 -- top-half speaker y-coordinates constant SPK_B_Y1: std_logic_vector(9 downto 0) := "0111000010"; -- 450 constant SPK_B_Y2: std_logic_vector(9 downto 0) := "0111100000"; -- 480 -- declare a bunch of colour constants -- input cursor is red constant CURSOR_R_LEVEL: boolean := true; constant CURSOR_G_LEVEL: boolean := false; constant CURSOR_B_LEVEL: boolean := false; -- speakers are blue constant SPK_R_LEVEL: boolean := false; constant SPK_G_LEVEL: boolean := false; constant SPK_B_LEVEL: boolean := true; -- "you are here" icon is orange constant YOU_R_LEVEL: boolean := true; constant YOU_G_LEVEL: boolean := true; constant YOU_B_LEVEL: boolean := false; signal cursorxInc, cursoryInc: std_logic_vector(DISPLAY_X-1 downto 0); ------------------------------------------------------------------------------- begin cursorxInc <= cursorx + CURSOR_WIDTH; cursoryInc <= cursory + CURSOR_HEIGHT; -- inspired by Hamblen's line_generation process from the file line.vhd; DetermineRGBlevels: process (clock) begin IF clock'EVENT and clock = '1' THEN -- Initialize screen colors to black. vga_red <= FALSE; vga_green <= FALSE; vga_blue <= FALSE; -- draw mouse/joystick cursor if ((countx >= cursorx) and (countx <= cursorxInc)) and ((county >= cursory) and (county <= cursoryInc)) then vga_red <= CURSOR_R_LEVEL; vga_green <= CURSOR_G_LEVEL; vga_blue <= CURSOR_B_LEVEL; -- draw speakers elsif ( ((countx >= SPK_L_X1) and (countx <= SPK_L_X2)) or ((countx >= SPK_R_X1) and (countx <= SPK_R_X2)) ) and ( ((county >= SPK_T_Y1) and (county <= SPK_T_Y2)) or ((county >= SPK_B_Y1) and (county <= SPK_B_Y2)) ) then vga_red <= SPK_R_LEVEL; vga_green <= SPK_G_LEVEL; vga_blue <= SPK_B_LEVEL; -- draw "you are here" icon elsif ((countx >= YOU_X1) and (countx <= YOU_X2)) and ((county >= YOU_Y1) and (county <= YOU_Y2)) then vga_red <= YOU_R_LEVEL; vga_green <= YOU_G_LEVEL; vga_blue <= YOU_B_LEVEL; end if; END IF; end process DetermineRGBlevels; end behavioural;