Add dac_mask to fix text mode color (#655)

This commit is contained in:
pixelsuft‮ 2022-05-17 18:42:53 +07:00 committed by GitHub
parent d685053541
commit 77a1cc47cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -254,6 +254,8 @@ function VGAScreen(cpu, bus, vga_memory_size)
this.dac_color_index_read = 0;
this.dac_state = 0;
this.dac_mask = 0xFF;
this.dac_map = new Uint8Array(0x10);
this.attribute_controller_index = -1;
@ -306,6 +308,8 @@ function VGAScreen(cpu, bus, vga_memory_size)
io.register_read(0x3CE, this, this.port3CE_read);
io.register_read(0x3CF, this, this.port3CF_read);
io.register_read(0x3C6, this, this.port3C6_read);
io.register_write(0x3C6, this, this.port3C6_write);
io.register_write(0x3C7, this, this.port3C7_write);
io.register_read(0x3C7, this, this.port3C7_read);
io.register_write(0x3C8, this, this.port3C8_write);
@ -448,6 +452,7 @@ VGAScreen.prototype.get_state = function()
state[59] = this.clocking_mode;
state[60] = this.line_compare;
state[61] = this.pixel_buffer;
state[62] = this.dac_mask;
return state;
};
@ -516,6 +521,7 @@ VGAScreen.prototype.set_state = function(state)
this.clocking_mode = state[59];
this.line_compare = state[60];
state[61] && this.pixel_buffer.set(state[61]);
this.dac_mask = state[62] === undefined ? 0xFF : state[62];
this.bus.send("screen-set-mode", this.graphical_mode);
@ -832,7 +838,8 @@ VGAScreen.prototype.text_mode_redraw = function()
color = this.vga_memory[addr | 1];
this.bus.send("screen-put-char", [row, col, chr,
this.vga256_palette[color >> 4 & 0xF], this.vga256_palette[color & 0xF]]);
this.vga256_palette[this.dac_mask & this.dac_map[color >> 4 & 0xF]],
this.vga256_palette[this.dac_mask & this.dac_map[color & 0xF]]]);
addr += 2;
}
@ -860,7 +867,8 @@ VGAScreen.prototype.vga_memory_write_text_mode = function(addr, value)
}
this.bus.send("screen-put-char", [row, col, chr,
this.vga256_palette[color >> 4 & 0xF], this.vga256_palette[color & 0xF]]);
this.vga256_palette[this.dac_mask & this.dac_map[color >> 4 & 0xF]],
this.vga256_palette[this.dac_mask & this.dac_map[color & 0xF]]]);
this.vga_memory[addr] = value;
};
@ -1490,6 +1498,16 @@ VGAScreen.prototype.port3C5_read = function()
return 0;
};
VGAScreen.prototype.port3C6_write = function(data)
{
this.dac_mask = data;
};
VGAScreen.prototype.port3C6_read = function()
{
return this.dac_mask;
};
VGAScreen.prototype.port3C7_write = function(index)
{
// index for reading the DAC