From 7456bb6a4b40f04ed01b91ca2787a08296989d6c Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Sun, 25 Dec 2011 17:55:49 +0000 Subject: [PATCH] Added preliminary superimposing flag for CGA, and implemented for Tetris KR, now it properly mixes between CGA graphics and external background [Angelo Salese] --- src/mame/drivers/pcxt.c | 4 ++- src/mame/video/pc_cga.c | 61 +++++++++++++++++++++++++++++++++++++++-- src/mame/video/pc_cga.h | 1 + 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/mame/drivers/pcxt.c b/src/mame/drivers/pcxt.c index 44d98d59504..3980d01898f 100644 --- a/src/mame/drivers/pcxt.c +++ b/src/mame/drivers/pcxt.c @@ -117,6 +117,7 @@ static SCREEN_UPDATE( tetriskr ) for(xi=0;xi<8;xi++) { color = 0; + /* TODO: first byte seems bogus? */ for(pen_i = 0;pen_i<4;pen_i++) color |= ((bg_rom[y*320/8+x+(pen_i*0x20000)+yi*0x400+state->m_bg_bank*0x2000+1] >> (7-xi)) & 1) << pen_i; @@ -127,7 +128,7 @@ static SCREEN_UPDATE( tetriskr ) } } - //SCREEN_UPDATE_CALL(mc6845_cga); + SCREEN_UPDATE_CALL(mc6845_cga); return 0; } @@ -711,6 +712,7 @@ static MACHINE_CONFIG_DERIVED( tetriskr, filetto ) MCFG_CPU_IO_MAP(tetriskr_io) MCFG_DEVICE_MODIFY("screen") + MCFG_VIDEO_START(pc_cga_superimpose) MCFG_SCREEN_UPDATE(tetriskr) MCFG_DEVICE_REMOVE("voice") diff --git a/src/mame/video/pc_cga.c b/src/mame/video/pc_cga.c index 8a82cf610e6..0d0ff2c1918 100644 --- a/src/mame/video/pc_cga.c +++ b/src/mame/video/pc_cga.c @@ -265,6 +265,7 @@ static struct size_t videoram_size; UINT8 *videoram; + UINT8 is_superimpose; } cga; @@ -350,6 +351,7 @@ static VIDEO_START( pc_cga ) internal_pc_cga_video_start(machine); cga.videoram_size = 0x4000; cga.videoram = auto_alloc_array(machine, UINT8, 0x4000); + cga.is_superimpose = 0; memory_set_bankptr(machine,"bank11", cga.videoram); } @@ -390,6 +392,7 @@ static VIDEO_START( pc_cga32k ) cga.videoram_size = 0x8000; cga.videoram = auto_alloc_array(machine, UINT8, 0x8000); + cga.is_superimpose = 0; memory_set_bankptr(machine,"bank11", cga.videoram); } @@ -439,6 +442,13 @@ static SCREEN_UPDATE( cga_poisk2 ) return 0; } +/* for superimposing CGA over a different source video (i.e. tetriskr) */ +VIDEO_START( pc_cga_superimpose ) +{ + VIDEO_START_CALL( pc_cga ); + cga.is_superimpose = 1; +} + /*************************************************************************** Draw text mode with 40x25 characters (default) with high intensity bg. The character cell size is 16x8 @@ -602,6 +612,51 @@ static MC6845_UPDATE_ROW( cga_text_blink_update_row ) } } +static MC6845_UPDATE_ROW( cga_text_blink_update_row_si ) +{ + UINT8 *videoram = cga.videoram; + UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); + int i; + running_machine &machine = device->machine(); + + if ( y == 0 ) CGA_LOG(1,"cga_text_blink_update_row",("\n")); + for ( i = 0; i < x_count; i++ ) + { + UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; + UINT8 chr = videoram[ offset ]; + UINT8 attr = videoram[ offset +1 ]; + UINT8 data = cga.chr_gen[ chr * 8 + ra ]; + UINT16 fg = attr & 0x0F; + UINT16 bg = attr >> 4; + UINT8 xi; + + if ( i == cursor_x ) + { + if ( cga.frame & 0x08 ) + { + data = 0xFF; + } + } + else + { + if ( ( attr & 0x80 ) && ( cga.frame & 0x10 ) ) + { + data = 0x00; + } + } + + for(xi=0;xi<8;xi++) + { + UINT8 pen_data, dot; + + dot = (data & (1 << (7-xi))); + pen_data = dot ? fg : bg; + if(pen_data || dot) + *p = pen_data; + p++; + } + } +} /*************************************************************************** Draw text mode with 40x25 characters (default) and blinking colors. @@ -981,18 +1036,18 @@ static void pc_cga_mode_control_w(running_machine &machine, int data) if ( cga.mode_control & 0x04 ) { /* Composite greyscale */ - cga.update_row = cga_text_blink_update_row; + cga.update_row = cga.is_superimpose ? cga_text_blink_update_row_si : cga_text_blink_update_row; } else { /* Composite colour */ - cga.update_row = cga_text_blink_update_row; + cga.update_row = cga.is_superimpose ? cga_text_blink_update_row_si : cga_text_blink_update_row; } } else { /* RGB colour */ - cga.update_row = cga_text_blink_update_row; + cga.update_row = cga.is_superimpose ? cga_text_blink_update_row_si : cga_text_blink_update_row; } break; case 0x38: case 0x39: case 0x3C: case 0x3D: diff --git a/src/mame/video/pc_cga.h b/src/mame/video/pc_cga.h index 053732a42f2..dac5d13325b 100644 --- a/src/mame/video/pc_cga.h +++ b/src/mame/video/pc_cga.h @@ -11,6 +11,7 @@ MACHINE_CONFIG_EXTERN( pcvideo_cga_320x200 ); MACHINE_CONFIG_EXTERN( pcvideo_cga32k ); INPUT_PORTS_EXTERN( pcvideo_cga ); SCREEN_UPDATE( mc6845_cga ); +VIDEO_START( pc_cga_superimpose ); /* has a special 640x200 in 16 color mode, 4 banks at 0xb8000 */ MACHINE_CONFIG_EXTERN( pcvideo_pc1512 );