return 0xFF;
+ case 0x3B4: case 0x3D4: /* VGA CRT controller index */
+
+ return port == cpu->crtc_base ? cpu->crtc_index : 0xFF;
+
case 0x3B5: case 0x3D5: { /* 6845 CRT controller data */
uint8_t index = cpu->crtc_index;
return 0xFF; /* adapter not installed */
}
- if (index >= 0x0E && index <= 0x11) {
+ if (index < 25) {
return cpu->crtc_registers[index];
}
- return 0x00; /* write-only / undefined register */
+ return 0xFF; /* undefined register */
}
-
- case 0x3DA: /* CGA/EGA/VGA status */
+ case 0x3BA: case 0x3DA: /* VGA input status 1 */
+
+ cpu->vga_attr_flipflop = 0;
cpu->vga_status_flip++;
+
return (uint8_t) ((cpu->vga_status_flip & 0x01) | ((cpu->vga_status_flip & 0xE0) == 0xE0 ? 0x08 : 0x00));
+ case 0x3C0: /* VGA attribute controller index */
+
+ return cpu->vga_attr_index;
+
+ case 0x3C1: /* VGA attribute controller data */
+
+ return (cpu->vga_attr_index & 0x1F) < 21 ? cpu->vga_attr_registers[cpu->vga_attr_index & 0x1F] : 0xFF;
+
+ case 0x3C2: /* VGA input status 0 */
+
+ return 0;
+
+ case 0x3C3: /* VGA video subsystem enable */
+
+ return cpu->vga_enable;
+
+ case 0x3C4: /* VGA sequencer index */
+
+ return cpu->vga_seq_index;
+
+ case 0x3C5: /* VGA sequencer data */
+
+ return cpu->vga_seq_index < 5 ? cpu->vga_seq_registers[cpu->vga_seq_index] : 0xFF;
+
+ case 0x3C6: /* VGA DAC pixel mask */
+
+ return cpu->vga_dac_mask;
+
+ case 0x3C7: /* VGA DAC state */
+
+ return cpu->vga_dac_state;
+
+ case 0x3C8: /* VGA DAC write index */
+
+ return cpu->vga_dac_write_index;
+
+ case 0x3C9: { /* VGA DAC palette data */
+
+ uint8_t value = cpu->vga_dac_palette[cpu->vga_dac_read_index][cpu->vga_dac_read_component];
+
+ if (++cpu->vga_dac_read_component == 3) {
+
+ cpu->vga_dac_read_component = 0;
+ cpu->vga_dac_read_index++;
+
+ }
+
+ return value;
+
+ }
+
+ case 0x3CC: /* VGA miscellaneous output */
+
+ return cpu->vga_misc_output;
+
+ case 0x3CE: /* VGA graphics controller index */
+
+ return cpu->vga_gc_index;
+
+ case 0x3CF: /* VGA graphics controller data */
+
+ return cpu->vga_gc_index < 9 ? cpu->vga_gc_registers[cpu->vga_gc_index] : 0xFF;
+
default:
if (io_absent_sound_port (port)) {
case 0x3B5: case 0x3D5: /* 6845 register data */
- if (port == (uint16_t) (cpu->crtc_base + 1) && cpu->crtc_index < 0x10) {
+ if (port == (uint16_t) (cpu->crtc_base + 1) && cpu->crtc_index < 25) {
if (cpu->crtc_index == 0x0E) {
value &= 0x3F;
break;
+ case 0x3C0: /* VGA attribute controller */
+
+ if (cpu->vga_attr_flipflop) {
+
+ if ((cpu->vga_attr_index & 0x1F) < 21) {
+ cpu->vga_attr_registers[cpu->vga_attr_index & 0x1F] = value;
+ }
+
+ } else {
+ cpu->vga_attr_index = value;
+ }
+
+ cpu->vga_attr_flipflop ^= 1;
+ break;
+
+ case 0x3C2: /* VGA miscellaneous output */
+
+ cpu->vga_misc_output = value;
+ break;
+
+ case 0x3C3: /* VGA video subsystem enable */
+
+ cpu->vga_enable = value & 1;
+ break;
+
+ case 0x3C4: /* VGA sequencer index */
+
+ cpu->vga_seq_index = value & 7;
+ break;
+
+ case 0x3C5: /* VGA sequencer data */
+
+ if (cpu->vga_seq_index < 5) {
+ cpu->vga_seq_registers[cpu->vga_seq_index] = value;
+ }
+
+ break;
+
+ case 0x3C6: /* VGA DAC pixel mask */
+
+ cpu->vga_dac_mask = value;
+ break;
+
+ case 0x3C7: /* VGA DAC read index */
+
+ cpu->vga_dac_read_index = value;
+ cpu->vga_dac_read_component = 0;
+ cpu->vga_dac_state = 0;
+
+ break;
+
+ case 0x3C8: /* VGA DAC write index */
+
+ cpu->vga_dac_write_index = value;
+ cpu->vga_dac_write_component = 0;
+ cpu->vga_dac_state = 3;
+
+ break;
+
+ case 0x3C9: /* VGA DAC palette data */
+
+ cpu->vga_dac_palette[cpu->vga_dac_write_index][cpu->vga_dac_write_component] = value & 0x3F;
+
+ if (++cpu->vga_dac_write_component == 3) {
+
+ cpu->vga_dac_write_component = 0;
+ cpu->vga_dac_write_index++;
+
+ }
+
+ break;
+
+ case 0x3CE: /* VGA graphics controller index */
+
+ cpu->vga_gc_index = value & 0x0F;
+ break;
+
+ case 0x3CF: /* VGA graphics controller data */
+
+ if (cpu->vga_gc_index < 9) {
+ cpu->vga_gc_registers[cpu->vga_gc_index] = value;
+ }
+
+ break;
+
case 0x3D8: case 0x3D9:
/* CGA mode control / colour select - not yet modelled */
}
}
+
+ } else if (subop == 1) { /* ROR r/m32, imm8 */
+
+ result = (value >> count) | (value << (32 - count));
+
+ if (result & 0x80000000UL) {
+ cpu->flags |= FLAG_CF;
+ } else {
+ cpu->flags &= (uint16_t) ~FLAG_CF;
+ }
+
+ if (count == 1) {
+
+ if (((result >> 31) ^ (result >> 30)) & 1) {
+ cpu->flags |= FLAG_OF;
+ } else {
+ cpu->flags &= (uint16_t) ~FLAG_OF;
+ }
+
+ }
} else if (subop == 4) { /* SHL r/m32, imm8 */
mem_write8 (cpu->mem, cpu->mem_size, 0x449, bios_video_mode);
mem_write16 (cpu->mem, cpu->mem_size, 0x44A, bios_video_columns);
- mem_write16 (cpu->mem, cpu->mem_size, 0x44C, bios_video_page_size ());
+ mem_write16 (cpu->mem, cpu->mem_size, 0x44C, bios_video_mode == 0x13 ? 0xFA00 : bios_video_page_size ());
mem_write16 (cpu->mem, cpu->mem_size, 0x44E, bios_video_page * bios_video_page_size ());
for (page = 0; page < 8; page++) {
unsigned row, col;
- if (mode != 0x00 && mode != 0x01 && mode != 0x02 && mode != 0x03 && mode != 0x07) {
+ if (mode != 0x00 && mode != 0x01 && mode != 0x02 && mode != 0x03 && mode != 0x07 && mode != 0x13) {
fprintf (stderr, "Unsupported Video Mode 0x%02X\n", mode);
break;
}
- bios_video_columns = mode <= 1 ? 40 : 80;
+ bios_video_columns = mode == 0x13 ? 40 : (mode <= 1 ? 40 : 80);
+
bios_video_mode = mode;
bios_video_page = 0;
bios_video_initialize ();
+ if (mode == 0x13) {
+
+ if (!(requested & 0x80)) {
+ memset (cpu->mem + 0xA0000, 0, 0x10000);
+ }
+
+ cpu->vga_misc_output = 0x63;
+ cpu->vga_seq_registers[0] = 0x03;
+ cpu->vga_seq_registers[1] = 0x01;
+ cpu->vga_seq_registers[2] = 0x0F;
+ cpu->vga_seq_registers[3] = 0x00;
+ cpu->vga_seq_registers[4] = 0x0E;
+ cpu->vga_gc_registers[5] = 0x40;
+ cpu->vga_gc_registers[6] = 0x05;
+ cpu->vga_dac_mask = 0xFF;
+ cpu->vga_dac_state = 3;
+ cpu->vga_attr_flipflop = 0;
+ cpu->vga_enable = 1;
+
+ bios_video_update_bda (cpu);
+
+ fflush (stdout);
+ break;
+
+ }
+
if (!(requested & 0x80)) {
for (row = 0; row < bios_video_rows; row++) {
mem_video_dirty = 0;
bios_video_force_redraw = 0;
- if (!(dirty & (bios_video_mode == 0x07 ? 1 : 2)) && !full_redraw) {
+ if (bios_video_mode == 0x13 || (!(dirty & (bios_video_mode == 0x07 ? 1 : 2)) && !full_redraw)) {
return;
}