Skip to content

Commit

Permalink
Better centering in NTSC
Browse files Browse the repository at this point in the history
  • Loading branch information
gyurco committed Oct 26, 2019
1 parent 1cd1bd1 commit 15dc3a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 8 additions & 6 deletions vic20/m6561.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ library ieee ;

entity M6561 is
generic (
K_OFFSET : in std_logic_vector(4 downto 0) := "10000"
PAL_K_OFFSET : in std_logic_vector(4 downto 0) := "10000";
NTSC_K_OFFSET : in std_logic_vector(4 downto 0) := "11100"
);
port (
I_CLK : in std_logic;
Expand Down Expand Up @@ -111,21 +112,22 @@ architecture RTL of M6561 is
constant PAL_CLOCKS_PER_LINE_M1 : std_logic_vector(8 downto 0) := "100011011"; -- 284 -1
constant PAL_TOTAL_LINES_M1 : std_logic_vector(8 downto 0) := "100110111"; -- 312 -1
constant PAL_H_START_M1 : std_logic_vector(8 downto 0) := "000101011"; -- 44 -1
constant PAL_H_END_M1 : std_logic_vector(8 downto 0) := "100001111"; -- 272 -1
constant PAL_H_END_M1 : std_logic_vector(8 downto 0) := "100001111"; -- 272 -1 -- width: 228
constant PAL_V_START : std_logic_vector(8 downto 0) := "000011100"; -- 28
-- video size 228 pixels by 284 lines (PAL)

constant NTSC_CLOCKS_PER_LINE_M1 : std_logic_vector(8 downto 0) := "100000011"; -- 260 -1
constant NTSC_TOTAL_LINES_M1 : std_logic_vector(8 downto 0) := "100000100"; -- 260 (not -1)
constant NTSC_H_START_M1 : std_logic_vector(8 downto 0) := "000011111"; -- 32 -1
constant NTSC_H_END_M1 : std_logic_vector(8 downto 0) := "011101011"; -- 236 -1
constant NTSC_H_START_M1 : std_logic_vector(8 downto 0) := "000100101"; -- 38 -1
constant NTSC_H_END_M1 : std_logic_vector(8 downto 0) := "011110111"; -- 248 -1 -- width: 210
constant NTSC_V_START : std_logic_vector(8 downto 0) := "000010000"; -- 16

signal CLOCKS_PER_LINE_M1 : std_logic_vector(8 downto 0);
signal TOTAL_LINES_M1 : std_logic_vector(8 downto 0);
signal H_START_M1 : std_logic_vector(8 downto 0);
signal H_END_M1 : std_logic_vector(8 downto 0);
signal V_START : std_logic_vector(8 downto 0);
signal K_OFFSET : std_logic_vector(4 downto 0);

-- close to original RGB
constant col0 : std_logic_vector(11 downto 0) := x"000"; -- 0 - 0000 Black
Expand Down Expand Up @@ -265,7 +267,7 @@ begin
H_START_M1 <= PAL_H_START_M1 when I_PAL = '1' else NTSC_H_START_M1;
H_END_M1 <= PAL_H_END_M1 when I_PAL = '1' else NTSC_H_END_M1;
V_START <= PAL_V_START when I_PAL = '1' else NTSC_V_START;

K_OFFSET <= PAL_K_OFFSET when I_PAL = '1' else NTSC_K_OFFSET;
-- clocking
p2_h_int <= not hcnt(1);
ena_1mhz_int <= hcnt(0) and p2_h_int; -- hcnt="01";
Expand Down Expand Up @@ -520,7 +522,7 @@ begin
--
-- video gen
--
p_offset_comp : process(hcnt, r_x_offset, vcnt, r_y_offset)
p_offset_comp : process(hcnt, r_x_offset, vcnt, r_y_offset, K_OFFSET)
begin
-- nasty fudge factor to centre the piccy.
start_h <= (hcnt = ((r_x_offset & "00") + K_OFFSET)); -- looks about right, fiddle at will
Expand Down
5 changes: 1 addition & 4 deletions vic20/vic20.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ architecture RTL of VIC20 is
constant int_dla_cpu_debug : boolean := false;

-- default
constant K_OFFSET : std_logic_vector (4 downto 0) := "10000"; -- h position of screen to centre on your telly
--constant K_OFFSET : std_logic_vector (4 downto 0) := "10000"; -- h position of screen to centre on your telly
-- lunar lander is WAY off to the left
--constant K_OFFSET : std_logic_vector (4 downto 0) := "11100"; -- h position of screen to centre on your telly

Expand Down Expand Up @@ -355,9 +355,6 @@ begin
);

vic : entity work.M6561
generic map (
K_OFFSET => K_OFFSET
)
port map (
I_CLK => i_sysclk,
I_ENA_4 => ena_4,
Expand Down

0 comments on commit 15dc3a8

Please sign in to comment.