Skip to content

Commit c66e409

Browse files
committed
103.556MHz/1AFE: Basic VT100 scrolling
Instead of blanking the screen after reaching the end of the screen, basic scrolling has been added. There are some minor bugs, for example not all of the characters are always cleared as the screen moves up. Scrolling back up could be implemented; you could only go as far back as the base pointer will allow. There are also more warnings and 'INFO' statements in the generated reports, which are always annoying, these should be removed before merging this branch into master.
1 parent 742dc4d commit c66e409

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

h2.fth

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ irqTask:
945945
.set 12 irqTask
946946
\ .set 14 irqTask
947947

948-
: irq $0040 oIrcMask ! [-1] oTimerCtrl ! 1 ien! ;
948+
: irq $0040 oIrcMask ! [-1] timer! 1 ien! ;
949949

950950
( ==================== Miscellaneous ================================= )
951951

top.vhd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ begin
422422
v_blank => v_blank,
423423
h_sync => o_vga.hsync,
424424
v_sync => o_vga.vsync);
425-
o_vga.red <= "111" when draw = '1' else "000";
425+
o_vga.red <= "111" when draw = '1' else "000";
426426
o_vga.green <= "111" when (draw = '1' and row < 100 and column < 100) else "000";
427-
o_vga.blue <= "11";
427+
o_vga.blue <= "11";
428428
end block;
429429
end generate;
430430
end block;

vga.vhd

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ package vga_pkg is
7474
vga_we_ram: in std_ulogic; -- Write enable RAM
7575
vga_din: in std_ulogic_vector(15 downto 0);
7676
vga_addr: in std_ulogic_vector(12 downto 0);
77+
base: in std_ulogic_vector(12 downto 0);
7778

7879
-- VGA control registers
7980
i_font_sel: in std_ulogic_vector(0 downto 0);
@@ -472,6 +473,8 @@ architecture rtl of vt100 is
472473
signal saved_attr_n, saved_attr_c: unsigned(attr_default'range) := (others => '0');
473474

474475
signal reverse_video_c, reverse_video_n: boolean := false;
476+
signal base_n, base_c: unsigned(addr'range) := (others => '0');
477+
signal addr_sel: unsigned(addr'range) := (others => '0');
475478
begin
476479
accumulator_0: work.vga_pkg.atoi
477480
generic map(g => g, N => number)
@@ -487,25 +490,25 @@ begin
487490
n_o => n_o);
488491

489492
address: block
490-
signal addr_int: unsigned(addr'range) := (others => '0');
491493
signal mul: unsigned(15 downto 0) := (others => '0');
494+
signal addr_int: unsigned(addr'range) := (others => '0');
492495
begin
493496
mul <= to_unsigned(to_integer(y_c) * width, mul'length);
494497
addr_int <= mul(addr_int'range) + ("000000" & x_c);
495-
-- addr_int <= mul(addr_int'range) + ("000000" & x_c) + unsigned(base_c);
496-
addr <= std_ulogic_vector(addr_int) when state_c /= ERASING else std_ulogic_vector(count_c);
498+
addr_sel <= addr_int when state_c /= ERASING else count_c;
499+
addr <= std_ulogic_vector(addr_sel + base_c);
497500
end block;
498501

499502
x_minus_one <= x_c - 1;
500503
x_plus_one <= x_c + 1;
501-
x_underflow <= x_minus_one >= (width - 1);
502504
x_overflow <= x_c > (width - 1);
505+
x_underflow <= x_minus_one >= (width - 1);
503506
x_minus_one_limited <= (others => '0') when x_underflow else x_minus_one;
504507
x_plus_one_limited <= to_unsigned(width - 1, x_c'length) when x_overflow else x_plus_one;
505508

506509
y_plus_one <= y_c + 1;
507510
y_minus_one <= y_c - 1;
508-
y_overflow <= y_c >= (height - 1);
511+
y_overflow <= y_c >= (height - 1); -- NB. > for 1 more row, slightly off edge of screen
509512
y_underflow <= y_minus_one > (height - 1);
510513
y_minus_one_limited <= (others => '0') when y_underflow else y_minus_one;
511514
y_plus_one_limited <= to_unsigned(height - 1, y_c'length) when y_overflow else y_plus_one;
@@ -542,6 +545,7 @@ begin
542545
vga_we_ram => data_we,
543546
vga_din => vga_din,
544547
vga_addr => addr,
548+
base => std_ulogic_vector(base_c),
545549
i_font_sel => font_sel_c,
546550
i_vga_control_we => vga_ctr_we,
547551
i_vga_control => vga_ctr,
@@ -601,6 +605,7 @@ begin
601605
saved_y_c <= saved_y_n;
602606
saved_attr_c <= saved_attr_n;
603607
reverse_video_c <= reverse_video_n;
608+
base_c <= base_n;
604609

605610
if state_c = RESET then
606611
n1_n <= (others => '0');
@@ -619,6 +624,7 @@ begin
619624
ctl_n <= ctl_default;
620625
conceal_n <= false;
621626
reverse_video_n <= false;
627+
base_n <= (others => '0');
622628
elsif state_c = ACCEPT then
623629
if we = '1' then
624630
c_n <= unsigned(char);
@@ -665,6 +671,7 @@ begin
665671
count_n <= (others => '0');
666672
limit_n <= "1000000000";
667673
state_n <= ERASING;
674+
base_n <= (others => '0');
668675
when lsqb =>
669676
state_n <= NUMBER1;
670677
akk_init <= '1';
@@ -722,6 +729,7 @@ begin
722729
when x"4a" => -- CSI n 'J'
723730
x_n <= (others => '0');
724731
y_n <= (others => '0');
732+
base_n <= (others => '0');
725733
cursor_we <= '1';
726734
state_n <= ERASING;
727735
c_n <= blank;
@@ -732,6 +740,8 @@ begin
732740
akk_init <= '1';
733741
when x"6d" => -- CSI n 'm' : SGR
734742
state_n <= ATTRIB;
743+
744+
-- TODO: Fixing scrolling, or remove
735745
when x"53" => -- CSI n 'S' : scroll up
736746
ctl_n(4) <= '0';
737747
state_n <= WRITE;
@@ -796,11 +806,13 @@ begin
796806
y_n <= y_plus_one;
797807
elsif y_overflow then
798808
x_n <= (others => '0');
799-
y_n <= (others => '0');
809+
y_n <= y_minus_one;
800810
state_n <= ERASING;
801811
c_n <= blank;
802-
count_n <= (others => '0');
803-
limit_n <= "1000000000";
812+
count_n <= unsigned(addr_sel);
813+
limit_value := unsigned(addr_sel) + width;
814+
limit_n <= limit_value(limit_n'high + 3 downto limit_n'low + 3);
815+
base_n <= base_c + width;
804816
else
805817
state_n <= WRITE;
806818
end if;
@@ -904,6 +916,7 @@ entity vga_top is
904916
vga_we_ram: in std_ulogic; -- Write enable RAM
905917
vga_din: in std_ulogic_vector(15 downto 0);
906918
vga_addr: in std_ulogic_vector(12 downto 0);
919+
base: in std_ulogic_vector(12 downto 0);
907920

908921
-- VGA control registers
909922
i_font_sel: in std_ulogic_vector(0 downto 0);
@@ -990,7 +1003,7 @@ begin
9901003

9911004
o_vga => o_vga);
9921005

993-
text_addr_full <= control_c.ctl(4) & text_addr;
1006+
text_addr_full <= std_ulogic_vector(unsigned(base) + unsigned(text_addr));
9941007

9951008
u_text_memory: entity work.dual_port_block_ram -- holds at least 80x40 characters
9961009
generic map(g => g,

0 commit comments

Comments
 (0)