aboutsummaryrefslogtreecommitdiffstats
path: root/display.v
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-10-02 05:22:59 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-10-02 05:22:59 +0000
commitc4f3b85cc61259e6e1147d620a92f2b9eafa71a9 (patch)
tree02bba3050db6f895982b0c82ea97848f54aa1767 /display.v
parent9b5b4b4acaf2f2be2aaf59d1b93f5abd3f046caf (diff)
downloadabc80-c4f3b85cc61259e6e1147d620a92f2b9eafa71a9.tar.gz
abc80-c4f3b85cc61259e6e1147d620a92f2b9eafa71a9.tar.xz
abc80-c4f3b85cc61259e6e1147d620a92f2b9eafa71a9.zip
Fix the handling of attributes with DBLE. We really need two
independent attribute engines, sigh.
Diffstat (limited to 'display.v')
-rw-r--r--display.v211
1 files changed, 137 insertions, 74 deletions
diff --git a/display.v b/display.v
index 381a13c..8306c42 100644
--- a/display.v
+++ b/display.v
@@ -79,23 +79,41 @@ module display (
reg [9:0] x; // Horizontal pixel count
reg [8:0] y; // Vertical pixel count
+ wire xvideo; // Non-blanked in the x direction
+ wire yvideo; // Non-blanked in the y direction
wire [10:0] a80; // Character row assuming 80 columns
wire [10:0] a80u; // Character row assuming 80 columns (up 1 line)
reg [5:0] scan_counter; // Counter of total scans (for flashing et al)
reg [7:0] pixrow; // One character worth of pixels
- reg [2:0] fg; // Foreground RGB
- reg [2:0] bg; // Background RGB
+
+ // For the current text line
+ reg [2:0] curfg; // Foreground RGB
+ reg [2:0] curbg; // Background RGB
reg inverse; // Inverse video
reg isgraph; // Graphic mode?
reg isgsep; // Separated graphics?
reg isgrel; // Hold graphics?
reg isdble; // Double height?
- reg wasdble; // Double height (previous row)
reg isflsh; // Flashing?
reg ishide; // Hidden
reg [7:0] thischar; // Character code currently processing
- wire xvideo; // Non-blanked in the x direction
- wire yvideo; // Non-blanked in the y direction
+
+ // These refer to the same as above, but for the previous text line
+ reg [2:0] oldfg; // Foreground RGB
+ reg [2:0] oldbg; // Background RGB
+ reg wasgraph; // Graphic mode?
+ reg wasgsep; // Separated graphics?
+ reg wasgrel; // Hold graphics?
+ reg wasdble; // Double height?
+ reg wasflsh; // Flashing?
+ reg washide; // Hidden
+ reg [7:0] thatchar; // Character code currently processing
+
+ // The one we're currently displaying
+ wire [2:0] fg = wasdble ? oldfg : curfg;
+ wire [2:0] bg = wasdble ? oldbg : curbg;
+ wire [7:0] somechar = wasdble ? thatchar : thischar;
+ wire gsep = wasdble ? wasgsep : isgsep;
// Address mapping for 80 characters; for 40 characters
// we shift this left by 1
@@ -119,7 +137,7 @@ module display (
assign a = width ? amap[10:0] : { 1'b1, amap[10:1] };
// Character generator address mapping
- assign ga[10:4] = thischar[6:0];
+ assign ga[10:4] = somechar[6:0];
assign ga[3:0] = wasdble ? { 1'b1, y[3:1] } : isdble ? { 0'b0, y[3:1] } : y[3:0];
// Video enable signal
@@ -178,11 +196,8 @@ module display (
3'b011:
begin
- if ( (y[8:4] != 0) && (d[6:1] == 6'b000110) )
- wasdble <= d[0];
-
- if ( wasdble )
- thischar <= d;
+ // Load and process previous-line character
+ thatchar <= (y[8:4] == 0) ? 8'h00 : d;
end
3'b111:
@@ -190,13 +205,16 @@ module display (
// Load a new pixel row?
if ( xvideo )
begin
+
+ // Attribute engine for current row
+
if ( thischar[6:5] == 2'b00 )
begin
// Control character
casex ( thischar[4:0] )
5'bx0xxx:
begin
- fg <= thischar[2:0];
+ curfg <= thischar[2:0];
isgraph <= thischar[4];
end
5'b0110x:
@@ -213,93 +231,131 @@ module display (
isgsep <= 1'b1;
5'b11100: // BLBG
begin
- bg <= 3'b000;
- fg <= bg;
+ curbg <= 3'b000;
+ curfg <= curbg;
end
5'b11101: // NWBG
begin
- bg <= fg;
- fg <= 3'b000;
+ curbg <= curfg;
+ curfg <= 3'b000;
end
endcase // casex( thischar[4:0] )
end // if ( thischar[6:5] == 2'b00 )
-
- if ( isgraph & thischar[5] )
+
+ // Attribute engine for previous row
+
+ if ( thatchar[6:5] == 2'b00 )
+ begin
+ // Control character
+ casex ( thatchar[4:0] )
+ 5'bx0xxx:
+ begin
+ oldfg <= thatchar[2:0];
+ wasgraph <= thatchar[4];
+ end
+ 5'b0110x:
+ wasdble <= thatchar[0];
+ 5'b11000:
+ washide <= 1'b1;
+ 5'b1111x:
+ wasgrel <= thatchar[0];
+ 5'b0100x:
+ wasflsh <= ~thatchar[0];
+ 5'b11001:
+ wasgsep <= 1'b0;
+ 5'b11010:
+ wasgsep <= 1'b1;
+ 5'b11100: // BLBG
+ begin
+ oldbg <= 3'b000;
+ oldfg <= oldbg;
+ end
+ 5'b11101: // NWBG
+ begin
+ oldbg <= oldfg;
+ oldfg <= 3'b000;
+ end
+ endcase // casex( thatchar[4:0] )
+ end // if ( thatchar[6:5] == 2'b00 )
+
+ // Character generation
+
+ if ( wasdble ? (wasgraph & thatchar[5]) : (isgraph & thischar[5]) )
begin
// Generate graphical character
case ( ga[3:0] )
4'h0, 4'h1, 4'h2, 4'h3:
begin
- pixrow[7] <= thischar[0];
- pixrow[6] <= thischar[0];
- pixrow[5] <= thischar[0];
- pixrow[4] <= thischar[0] & ~isgsep;
- pixrow[3] <= thischar[1];
- pixrow[2] <= thischar[1];
- pixrow[1] <= thischar[1];
- pixrow[0] <= thischar[1] & ~isgsep;
+ pixrow[7] <= somechar[0];
+ pixrow[6] <= somechar[0];
+ pixrow[5] <= somechar[0];
+ pixrow[4] <= somechar[0] & ~gsep;
+ pixrow[3] <= somechar[1];
+ pixrow[2] <= somechar[1];
+ pixrow[1] <= somechar[1];
+ pixrow[0] <= somechar[1] & ~gsep;
end
4'h4:
begin
- pixrow[7] <= thischar[0] & ~isgsep;
- pixrow[6] <= thischar[0] & ~isgsep;
- pixrow[5] <= thischar[0] & ~isgsep;
- pixrow[4] <= thischar[0] & ~isgsep;
- pixrow[3] <= thischar[1] & ~isgsep;
- pixrow[2] <= thischar[1] & ~isgsep;
- pixrow[1] <= thischar[1] & ~isgsep;
- pixrow[0] <= thischar[1] & ~isgsep;
+ pixrow[7] <= somechar[0] & ~gsep;
+ pixrow[6] <= somechar[0] & ~gsep;
+ pixrow[5] <= somechar[0] & ~gsep;
+ pixrow[4] <= somechar[0] & ~gsep;
+ pixrow[3] <= somechar[1] & ~gsep;
+ pixrow[2] <= somechar[1] & ~gsep;
+ pixrow[1] <= somechar[1] & ~gsep;
+ pixrow[0] <= somechar[1] & ~gsep;
end
4'h5, 4'h6, 4'h7, 4'h8, 4'h9:
begin
- pixrow[7] <= thischar[2];
- pixrow[6] <= thischar[2];
- pixrow[5] <= thischar[2];
- pixrow[4] <= thischar[2] & ~isgsep;
- pixrow[3] <= thischar[3];
- pixrow[2] <= thischar[3];
- pixrow[1] <= thischar[3];
- pixrow[0] <= thischar[3] & ~isgsep;
+ pixrow[7] <= somechar[2];
+ pixrow[6] <= somechar[2];
+ pixrow[5] <= somechar[2];
+ pixrow[4] <= somechar[2] & ~gsep;
+ pixrow[3] <= somechar[3];
+ pixrow[2] <= somechar[3];
+ pixrow[1] <= somechar[3];
+ pixrow[0] <= somechar[3] & ~gsep;
end
4'hA:
begin
- pixrow[7] <= thischar[2] & ~isgsep;
- pixrow[6] <= thischar[2] & ~isgsep;
- pixrow[5] <= thischar[2] & ~isgsep;
- pixrow[4] <= thischar[2] & ~isgsep;
- pixrow[3] <= thischar[3] & ~isgsep;
- pixrow[2] <= thischar[3] & ~isgsep;
- pixrow[1] <= thischar[3] & ~isgsep;
- pixrow[0] <= thischar[3] & ~isgsep;
+ pixrow[7] <= somechar[2] & ~gsep;
+ pixrow[6] <= somechar[2] & ~gsep;
+ pixrow[5] <= somechar[2] & ~gsep;
+ pixrow[4] <= somechar[2] & ~gsep;
+ pixrow[3] <= somechar[3] & ~gsep;
+ pixrow[2] <= somechar[3] & ~gsep;
+ pixrow[1] <= somechar[3] & ~gsep;
+ pixrow[0] <= somechar[3] & ~gsep;
end
4'hB, 4'hC, 4'hD, 4'hE:
begin
- pixrow[7] <= thischar[4];
- pixrow[6] <= thischar[4];
- pixrow[5] <= thischar[4];
- pixrow[4] <= thischar[4] & ~isgsep;
- pixrow[3] <= thischar[6];
- pixrow[2] <= thischar[6];
- pixrow[1] <= thischar[6];
- pixrow[0] <= thischar[6] & ~isgsep;
+ pixrow[7] <= somechar[4];
+ pixrow[6] <= somechar[4];
+ pixrow[5] <= somechar[4];
+ pixrow[4] <= somechar[4] & ~gsep;
+ pixrow[3] <= somechar[6];
+ pixrow[2] <= somechar[6];
+ pixrow[1] <= somechar[6];
+ pixrow[0] <= somechar[6] & ~gsep;
end
4'hF:
begin
- pixrow[7] <= thischar[4] & ~isgsep;
- pixrow[6] <= thischar[4] & ~isgsep;
- pixrow[5] <= thischar[4] & ~isgsep;
- pixrow[4] <= thischar[4] & ~isgsep;
- pixrow[3] <= thischar[6] & ~isgsep;
- pixrow[2] <= thischar[6] & ~isgsep;
- pixrow[1] <= thischar[6] & ~isgsep;
- pixrow[0] <= thischar[6] & ~isgsep;
+ pixrow[7] <= somechar[4] & ~gsep;
+ pixrow[6] <= somechar[4] & ~gsep;
+ pixrow[5] <= somechar[4] & ~gsep;
+ pixrow[4] <= somechar[4] & ~gsep;
+ pixrow[3] <= somechar[6] & ~gsep;
+ pixrow[2] <= somechar[6] & ~gsep;
+ pixrow[1] <= somechar[6] & ~gsep;
+ pixrow[0] <= somechar[6] & ~gsep;
end
endcase // case( ga[3:0] )
- end // if ( isgraph & thischar[5] )
- else if ( (thischar[6:5] != 2'b00) | isgrel )
+ end // if ( wasdble ? (wasgraph & thatchar[5]) : (isgraph & thischar[5]) )
+ else if ( (somechar[6:5] != 2'b00) | (wasdble ? wasgrel : isgrel) )
pixrow <= gd; // Input from character ROM
end // if ( xvideo )
- inverse <= thischar[7];
+ inverse <= somechar[7];
end // case: 3'b111
endcase // case( x[2:0] )
end // if ( width | ~x[3] )
@@ -308,17 +364,24 @@ module display (
if ( x == x_max-1 )
begin
x <= 0;
- fg <= 3'b111; // Default fg is white
- bg <= 3'b000; // Default bg is black
- isgraph <= 0; // Not graphic mode
+ pixrow <= 8'b0; // Read-ahead spot is blank
inverse <= 0; // Not inverse video
+ curfg <= 3'b111; // Default fg is white
+ curbg <= 3'b000; // Default bg is black
+ isgraph <= 0; // Not graphic mode
isflsh <= 0; // Not flashing
isgsep <= 0; // Not separated
isdble <= 0; // Not double
- wasdble <= 0; // Not double
isgrel <= 1; // Release graphics
ishide <= 0; // Not hidden
- pixrow <= 8'b0; // Read-ahead spot is blank
+ oldfg <= 3'b111; // Default fg is white
+ oldbg <= 3'b000; // Default bg is black
+ wasgraph <= 0; // Not graphic mode
+ wasflsh <= 0; // Not flashing
+ wasgsep <= 0; // Not separated
+ wasdble <= 0; // Not double
+ wasgrel <= 1; // Release graphics
+ washide <= 0; // Not hidden
if ( y == y_max-1 )
begin
y <= 0;