mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-06-27 15:43:11 +00:00
Send terminal text and colours separately
This gives us slightly better compression, as backgrounds will often be a single run of colours while the foreground won't be. In practice, this is rarely an issue, as most terminals are small, but worth doing anyway.
This commit is contained in:
parent
3f0704624e
commit
1fd57a874f
@ -324,9 +324,9 @@ public class Terminal
|
|||||||
TextBuffer textColour = this.textColour[y];
|
TextBuffer textColour = this.textColour[y];
|
||||||
TextBuffer backColour = backgroundColour[y];
|
TextBuffer backColour = backgroundColour[y];
|
||||||
|
|
||||||
|
for( int x = 0; x < width; x++ ) buffer.writeByte( text.charAt( x ) & 0xFF );
|
||||||
for( int x = 0; x < width; x++ )
|
for( int x = 0; x < width; x++ )
|
||||||
{
|
{
|
||||||
buffer.writeByte( text.charAt( x ) & 0xFF );
|
|
||||||
buffer.writeByte( getColour(
|
buffer.writeByte( getColour(
|
||||||
backColour.charAt( x ), Colour.BLACK ) << 4 |
|
backColour.charAt( x ), Colour.BLACK ) << 4 |
|
||||||
getColour( textColour.charAt( x ), Colour.WHITE )
|
getColour( textColour.charAt( x ), Colour.WHITE )
|
||||||
@ -353,10 +353,9 @@ public class Terminal
|
|||||||
TextBuffer textColour = this.textColour[y];
|
TextBuffer textColour = this.textColour[y];
|
||||||
TextBuffer backColour = backgroundColour[y];
|
TextBuffer backColour = backgroundColour[y];
|
||||||
|
|
||||||
|
for( int x = 0; x < width; x++ ) text.setChar( x, (char) (buffer.readByte() & 0xFF) );
|
||||||
for( int x = 0; x < width; x++ )
|
for( int x = 0; x < width; x++ )
|
||||||
{
|
{
|
||||||
text.setChar( x, (char) (buffer.readByte() & 0xFF) );
|
|
||||||
|
|
||||||
byte colour = buffer.readByte();
|
byte colour = buffer.readByte();
|
||||||
backColour.setChar( x, base16.charAt( (colour >> 4) & 0xF ) );
|
backColour.setChar( x, base16.charAt( (colour >> 4) & 0xF ) );
|
||||||
textColour.setChar( x, base16.charAt( colour & 0xF ) );
|
textColour.setChar( x, base16.charAt( colour & 0xF ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user