cga: support 400 line text modes (nw)

This commit is contained in:
cracyc 2017-11-25 14:16:51 -06:00
parent 32d777854d
commit cc82442e48
2 changed files with 78 additions and 246 deletions

View File

@ -190,22 +190,22 @@ MC6845_UPDATE_ROW( isa8_cga_device::crtc_update_row )
switch (m_update_row_type) switch (m_update_row_type)
{ {
case CGA_TEXT_INTEN: case CGA_TEXT_INTEN:
cga_text_inten_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); cga_text<false, false, false, false, 8>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break; break;
case CGA_TEXT_INTEN_ALT: case CGA_TEXT_INTEN_ALT:
cga_text_inten_alt_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); cga_text<false, false, false, true, 8>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break; break;
case CGA_TEXT_INTEN_CG: case CGA_TEXT_INTEN_CG:
cga_text_inten_comp_grey_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); cga_text<false, false, true, false, 8>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break; break;
case CGA_TEXT_BLINK: case CGA_TEXT_BLINK:
cga_text_blink_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); cga_text<true, false, false, false, 8>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break; break;
case CGA_TEXT_BLINK_ALT: case CGA_TEXT_BLINK_ALT:
cga_text_blink_alt_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); cga_text<true, false, false, true, 8>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break; break;
case CGA_TEXT_BLINK_SI: case CGA_TEXT_BLINK_SI:
cga_text_blink_update_row_si(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); cga_text<true, true, false, false, 8>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break; break;
case CGA_GFX_1BPP: case CGA_GFX_1BPP:
cga_gfx_1bpp_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); cga_gfx_1bpp_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
@ -467,200 +467,41 @@ isa8_cga_superimpose_device::isa8_cga_superimpose_device(const machine_config &m
m_superimpose = true; m_superimpose = true;
} }
/*************************************************************************** template<bool blink, bool si, bool comp, bool alt, int width>
Draw text mode with 40x25 characters (default) with high intensity bg. MC6845_UPDATE_ROW( isa8_cga_device::cga_text )
The character cell size is 16x8
***************************************************************************/
MC6845_UPDATE_ROW( isa8_cga_device::cga_text_inten_update_row )
{ {
uint8_t *videoram = &m_vram[m_start_offset]; uint8_t *videoram = &m_vram[m_start_offset];
uint32_t *p = &bitmap.pix32(y); uint32_t *p = &bitmap.pix32(y);
const rgb_t *palette = m_palette->palette()->entry_list_raw(); const rgb_t *palette = m_palette->palette()->entry_list_raw();
int i; int i;
if ( y == 0 ) CGA_LOG(1,"cga_text_inten_update_row",("\n")); if ( y == 0 ) CGA_LOG(1,"cga_text_8",("\n"));
for ( i = 0; i < x_count; i++ ) for ( i = 0; i < x_count; i++ )
{ {
uint16_t offset = ( ( ma + i ) << 1 ) & 0x3fff; uint16_t offset = ( ( ma + i ) << 1 ) & 0x3fff;
uint8_t chr = videoram[ offset ]; uint8_t chr = videoram[ offset ];
uint8_t attr = videoram[ offset +1 ]; uint8_t attr = videoram[ offset +1 ];
uint8_t data = m_chr_gen[ chr * 8 + ra ]; uint8_t data = m_chr_gen[ chr * width + ra ];
uint16_t fg = attr & 0x0F; uint16_t fg, bg;
uint16_t bg = attr >> 4;
if ( i == cursor_x && ( m_framecnt & 0x08 ) )
{
data = 0xFF;
}
*p = palette[( data & 0x80 ) ? fg : bg]; p++;
*p = palette[( data & 0x40 ) ? fg : bg]; p++;
*p = palette[( data & 0x20 ) ? fg : bg]; p++;
*p = palette[( data & 0x10 ) ? fg : bg]; p++;
*p = palette[( data & 0x08 ) ? fg : bg]; p++;
*p = palette[( data & 0x04 ) ? fg : bg]; p++;
*p = palette[( data & 0x02 ) ? fg : bg]; p++;
*p = palette[( data & 0x01 ) ? fg : bg]; p++;
}
}
/***************************************************************************
Draw text mode with 40x25 characters (default) with high intensity bg.
The character cell size is 16x8. Composite monitor, greyscale.
***************************************************************************/
MC6845_UPDATE_ROW( isa8_cga_device::cga_text_inten_comp_grey_update_row )
{
uint8_t *videoram = &m_vram[m_start_offset];
uint32_t *p = &bitmap.pix32(y);
const rgb_t *palette = m_palette->palette()->entry_list_raw();
int i;
if ( y == 0 ) CGA_LOG(1,"cga_text_inten_comp_grey_update_row",("\n"));
for ( i = 0; i < x_count; i++ )
{
uint16_t offset = ( ( ma + i ) << 1 ) & 0x3fff;
uint8_t chr = videoram[ offset ];
uint8_t attr = videoram[ offset +1 ];
uint8_t data = m_chr_gen[ chr * 8 + ra ];
uint16_t fg = 0x10 + ( attr & 0x0F );
uint16_t bg = 0x10 + ( ( attr >> 4 ) & 0x07 );
if ( i == cursor_x && ( m_framecnt & 0x08 ) )
{
data = 0xFF;
}
*p = palette[( data & 0x80 ) ? fg : bg]; p++;
*p = palette[( data & 0x40 ) ? fg : bg]; p++;
*p = palette[( data & 0x20 ) ? fg : bg]; p++;
*p = palette[( data & 0x10 ) ? fg : bg]; p++;
*p = palette[( data & 0x08 ) ? fg : bg]; p++;
*p = palette[( data & 0x04 ) ? fg : bg]; p++;
*p = palette[( data & 0x02 ) ? fg : bg]; p++;
*p = palette[( data & 0x01 ) ? fg : bg]; p++;
}
}
/***************************************************************************
Draw text mode with 40x25 characters (default) with high intensity bg.
The character cell size is 16x8
***************************************************************************/
MC6845_UPDATE_ROW( isa8_cga_device::cga_text_inten_alt_update_row )
{
uint8_t *videoram = &m_vram[m_start_offset];
uint32_t *p = &bitmap.pix32(y);
const rgb_t *palette = m_palette->palette()->entry_list_raw();
int i;
if ( y == 0 ) CGA_LOG(1,"cga_text_inten_alt_update_row",("\n"));
for ( i = 0; i < x_count; i++ )
{
uint16_t offset = ( ( ma + i ) << 1 ) & 0x3fff;
uint8_t chr = videoram[ offset ];
uint8_t attr = videoram[ offset +1 ];
uint8_t data = m_chr_gen[ chr * 8 + ra ];
uint16_t fg = attr & 0x0F;
if ( i == cursor_x && ( m_framecnt & 0x08 ) )
{
data = 0xFF;
}
*p = palette[( data & 0x80 ) ? fg : 0]; p++;
*p = palette[( data & 0x40 ) ? fg : 0]; p++;
*p = palette[( data & 0x20 ) ? fg : 0]; p++;
*p = palette[( data & 0x10 ) ? fg : 0]; p++;
*p = palette[( data & 0x08 ) ? fg : 0]; p++;
*p = palette[( data & 0x04 ) ? fg : 0]; p++;
*p = palette[( data & 0x02 ) ? fg : 0]; p++;
*p = palette[( data & 0x01 ) ? fg : 0]; p++;
}
}
/***************************************************************************
Draw text mode with 40x25 characters (default) and blinking colors.
The character cell size is 16x8
***************************************************************************/
MC6845_UPDATE_ROW( isa8_cga_device::cga_text_blink_update_row )
{
uint8_t *videoram = &m_vram[m_start_offset];
uint32_t *p = &bitmap.pix32(y);
const rgb_t *palette = m_palette->palette()->entry_list_raw();
int i;
if ( y == 0 ) CGA_LOG(1,"cga_text_blink_update_row",("\n"));
for ( i = 0; i < x_count; i++ )
{
uint16_t offset = ( ( ma + i ) << 1 ) & 0x3fff;
uint8_t chr = videoram[ offset ];
uint8_t attr = videoram[ offset +1 ];
uint8_t data = m_chr_gen[ chr * 8 + ra ];
uint16_t fg = attr & 0x0F;
uint16_t bg = (attr >> 4) & 0x07;
if ( i == cursor_x )
{
if ( m_framecnt & 0x08 )
{
data = 0xFF;
}
}
else
{
if ( ( attr & 0x80 ) && ( m_framecnt & 0x10 ) )
{
data = 0x00;
}
}
*p = palette[( data & 0x80 ) ? fg : bg]; p++;
*p = palette[( data & 0x40 ) ? fg : bg]; p++;
*p = palette[( data & 0x20 ) ? fg : bg]; p++;
*p = palette[( data & 0x10 ) ? fg : bg]; p++;
*p = palette[( data & 0x08 ) ? fg : bg]; p++;
*p = palette[( data & 0x04 ) ? fg : bg]; p++;
*p = palette[( data & 0x02 ) ? fg : bg]; p++;
*p = palette[( data & 0x01 ) ? fg : bg]; p++;
}
}
MC6845_UPDATE_ROW( isa8_cga_device::cga_text_blink_update_row_si )
{
uint8_t *videoram = &m_vram[m_start_offset];
uint32_t *p = &bitmap.pix32(y);
const rgb_t *palette = m_palette->palette()->entry_list_raw();
int i;
if ( y == 0 ) CGA_LOG(1,"cga_text_blink_update_row_si",("\n"));
for ( i = 0; i < x_count; i++ )
{
uint16_t offset = ( ( ma + i ) << 1 ) & 0x3fff;
uint8_t chr = videoram[ offset ];
uint8_t attr = videoram[ offset +1 ];
uint8_t data = m_chr_gen[ chr * 8 + ra ];
uint16_t fg = attr & 0x0F;
uint16_t bg = (attr >> 4) & 0x07;
uint8_t xi; uint8_t xi;
if ( i == cursor_x ) if ( comp )
{ {
if ( m_framecnt & 0x08 ) fg = 0x10 + ( attr & 0x0F );
{ bg = alt ? 0 : ( 0x10 + ( ( attr >> 4 ) & 0x07 ) );
data = 0xFF;
}
} }
else else
{ {
if ( ( attr & 0x80 ) && ( m_framecnt & 0x10 ) ) fg = attr & 0x0F;
{ bg = alt ? 0 : ( ( attr >> 4 ) & ( blink ? 0x07 : 0x0f ) );
data = 0x00; }
}
if ( ( i == cursor_x ) && ( m_framecnt & 0x08 ) )
data = 0xFF;
else if ( blink && ( attr & 0x80 ) && ( m_framecnt & 0x10 ) )
{
data = 0x00;
bg = ( attr >> 4 ) & 0x07;
} }
for(xi=0;xi<8;xi++) for(xi=0;xi<8;xi++)
@ -669,62 +510,13 @@ MC6845_UPDATE_ROW( isa8_cga_device::cga_text_blink_update_row_si )
dot = (data & (1 << (7-xi))); dot = (data & (1 << (7-xi)));
pen_data = dot ? fg : bg; pen_data = dot ? fg : bg;
if(pen_data || dot) if(!si || (pen_data || dot))
*p = palette[pen_data]; *p = palette[pen_data];
p++; p++;
} }
} }
} }
/***************************************************************************
Draw text mode with 40x25 characters (default) and blinking colors.
The character cell size is 16x8
***************************************************************************/
MC6845_UPDATE_ROW( isa8_cga_device::cga_text_blink_alt_update_row )
{
uint8_t *videoram = &m_vram[m_start_offset];
uint32_t *p = &bitmap.pix32(y);
const rgb_t *palette = m_palette->palette()->entry_list_raw();
int i;
if ( y == 0 ) CGA_LOG(1,"cga_text_blink_alt_update_row",("\n"));
for ( i = 0; i < x_count; i++ )
{
uint16_t offset = ( ( ma + i ) << 1 ) & 0x3fff;
uint8_t chr = videoram[ offset ];
uint8_t attr = videoram[ offset +1 ];
uint8_t data = m_chr_gen[ chr * 8 + ra ];
uint16_t fg = attr & 0x07;
uint16_t bg = 0;
if ( i == cursor_x )
{
if ( m_framecnt & 0x08 )
{
data = 0xFF;
}
}
else
{
if ( ( attr & 0x80 ) && ( m_framecnt & 0x10 ) )
{
data = 0x00;
bg = ( attr >> 4 ) & 0x07;
}
}
*p = palette[( data & 0x80 ) ? fg : bg]; p++;
*p = palette[( data & 0x40 ) ? fg : bg]; p++;
*p = palette[( data & 0x20 ) ? fg : bg]; p++;
*p = palette[( data & 0x10 ) ? fg : bg]; p++;
*p = palette[( data & 0x08 ) ? fg : bg]; p++;
*p = palette[( data & 0x04 ) ? fg : bg]; p++;
*p = palette[( data & 0x02 ) ? fg : bg]; p++;
*p = palette[( data & 0x01 ) ? fg : bg]; p++;
}
}
/* The lo-res (320x200) graphics mode on a colour composite monitor */ /* The lo-res (320x200) graphics mode on a colour composite monitor */
@ -2076,18 +1868,18 @@ void isa8_cga_cportiii_device::device_reset()
m_isa->install_device(0x13c6, 0x13c7, read8_delegate(FUNC(isa8_cga_cportiii_device::port_13c6_r), this), write8_delegate(FUNC(isa8_cga_cportiii_device::port_13c6_w), this)); m_isa->install_device(0x13c6, 0x13c7, read8_delegate(FUNC(isa8_cga_cportiii_device::port_13c6_r), this), write8_delegate(FUNC(isa8_cga_cportiii_device::port_13c6_w), this));
m_isa->install_device(0x23c6, 0x23c7, read8_delegate(FUNC(isa8_cga_cportiii_device::port_23c6_r), this), write8_delegate(FUNC(isa8_cga_cportiii_device::port_23c6_w), this)); m_isa->install_device(0x23c6, 0x23c7, read8_delegate(FUNC(isa8_cga_cportiii_device::port_23c6_r), this), write8_delegate(FUNC(isa8_cga_cportiii_device::port_23c6_w), this));
m_palette->set_pen_color(0, 100, 25, 0); m_palette->set_pen_color(0, 100, 25, 0);
m_chr_gen_offset[0] = m_chr_gen_offset[2] = 0x0000;
m_chr_gen_offset[1] = m_chr_gen_offset[3] = 0x1000;
} }
WRITE8_MEMBER(isa8_cga_cportiii_device::char_ram_write) WRITE8_MEMBER(isa8_cga_cportiii_device::char_ram_write)
{ {
if(!BIT(offset, 0)) // FIXME: the font is 16 chars high, this needs it's own text drawing m_chr_gen_base[offset] = data;
m_chr_gen_base[(offset >> 1) + 0x1000] = data;
} }
READ8_MEMBER(isa8_cga_cportiii_device::char_ram_read) READ8_MEMBER(isa8_cga_cportiii_device::char_ram_read)
{ {
return m_chr_gen_base[(offset >> 1) + 0x1000]; return m_chr_gen_base[offset];
} }
READ8_MEMBER(isa8_cga_cportiii_device::port_13c6_r) READ8_MEMBER(isa8_cga_cportiii_device::port_13c6_r)
@ -2106,9 +1898,55 @@ READ8_MEMBER(isa8_cga_cportiii_device::port_23c6_r)
WRITE8_MEMBER(isa8_cga_cportiii_device::port_23c6_w) WRITE8_MEMBER(isa8_cga_cportiii_device::port_23c6_w)
{ {
io_write(space, 0x0e, BIT(data, 0)); m_mode2 = data & 1;
if(BIT(data, 3)) if(BIT(data, 3))
m_isa->install_memory(0xb8000, 0xb9fff, read8_delegate(FUNC(isa8_cga_cportiii_device::char_ram_read), this), write8_delegate(FUNC(isa8_cga_cportiii_device::char_ram_write), this)); m_isa->install_memory(0xb8000, 0xb9fff, read8_delegate(FUNC(isa8_cga_cportiii_device::char_ram_read), this), write8_delegate(FUNC(isa8_cga_cportiii_device::char_ram_write), this));
else else
m_isa->install_bank(0xb8000, 0xb8000 + 0x8000 - 1, "bank_cga", &m_vram[0]); m_isa->install_bank(0xb8000, 0xb8000 + 0x8000 - 1, "bank_cga", &m_vram[0]);
} }
MC6845_UPDATE_ROW(isa8_cga_cportiii_device::crtc_update_row)
{
if(m_mode2 & 1)
m24_gfx_1bpp_m24_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
if (m_update_row_type == -1)
return;
y = m_y;
if(m_y >= bitmap.height())
return;
switch (m_update_row_type)
{
case CGA_TEXT_INTEN:
cga_text<false, false, false, false, 16>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break;
case CGA_TEXT_INTEN_ALT:
cga_text<false, false, false, true, 16>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break;
case CGA_TEXT_INTEN_CG: // this hardware doesn't support composite
break;
case CGA_TEXT_BLINK:
cga_text<true, false, false, false, 16>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break;
case CGA_TEXT_BLINK_ALT:
cga_text<true, false, false, true, 16>(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp);
break;
case CGA_TEXT_BLINK_SI:
break;
case CGA_GFX_1BPP:
cga_gfx_1bpp_update_row(bitmap, cliprect, ma, ra >> 1, y, x_count, cursor_x, de, hbp, vbp);
break;
case CGA_GFX_2BPP:
cga_gfx_2bpp_update_row(bitmap, cliprect, ma, ra >> 1, y, x_count, cursor_x, de, hbp, vbp);
break;
case CGA_GFX_4BPPL:
cga_gfx_4bppl_update_row(bitmap, cliprect, ma, ra >> 1, y, x_count, cursor_x, de, hbp, vbp);
break;
case CGA_GFX_4BPPH:
cga_gfx_4bpph_update_row(bitmap, cliprect, ma, ra >> 1, y, x_count, cursor_x, de, hbp, vbp);
break;
}
}

View File

@ -31,12 +31,7 @@ public:
isa8_cga_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); isa8_cga_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual MC6845_UPDATE_ROW( crtc_update_row ); virtual MC6845_UPDATE_ROW( crtc_update_row );
MC6845_UPDATE_ROW( cga_text_inten_update_row ); template<bool blink, bool si, bool comp, bool alt, int width> MC6845_UPDATE_ROW( cga_text );
MC6845_UPDATE_ROW( cga_text_inten_comp_grey_update_row );
MC6845_UPDATE_ROW( cga_text_inten_alt_update_row );
MC6845_UPDATE_ROW( cga_text_blink_update_row );
MC6845_UPDATE_ROW( cga_text_blink_update_row_si );
MC6845_UPDATE_ROW( cga_text_blink_alt_update_row );
MC6845_UPDATE_ROW( cga_gfx_4bppl_update_row ); MC6845_UPDATE_ROW( cga_gfx_4bppl_update_row );
MC6845_UPDATE_ROW( cga_gfx_4bpph_update_row ); MC6845_UPDATE_ROW( cga_gfx_4bpph_update_row );
MC6845_UPDATE_ROW( cga_gfx_2bpp_update_row ); MC6845_UPDATE_ROW( cga_gfx_2bpp_update_row );
@ -289,8 +284,6 @@ protected:
virtual void device_reset() override; virtual void device_reset() override;
// optional information overrides // optional information overrides
virtual void device_add_mconfig(machine_config &config) override; virtual void device_add_mconfig(machine_config &config) override;
private:
uint8_t m_mode2, m_index; uint8_t m_mode2, m_index;
}; };
@ -308,6 +301,7 @@ public:
DECLARE_WRITE8_MEMBER(port_23c6_w); DECLARE_WRITE8_MEMBER(port_23c6_w);
DECLARE_READ8_MEMBER(char_ram_read); DECLARE_READ8_MEMBER(char_ram_read);
DECLARE_WRITE8_MEMBER(char_ram_write); DECLARE_WRITE8_MEMBER(char_ram_write);
virtual MC6845_UPDATE_ROW( crtc_update_row ) override;
protected: protected:
virtual void device_reset() override; virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override; virtual void device_add_mconfig(machine_config &config) override;