Adds support for cursors. All 4 blinking modes are supported (always on, always off, fast, slow)

This commit is contained in:
Zsolt Vasvari 2008-02-28 02:01:37 +00:00
parent b0735fe318
commit 7d092ece83
7 changed files with 67 additions and 11 deletions

View File

@ -53,6 +53,8 @@ struct _mc6845_t
UINT16 light_pen;
emu_timer *display_enable_changed_timer;
UINT8 cursor_state; /* 0 = off, 1 = on */
UINT8 cursor_count;
/* saved screen parameters so we don't call
video_screen_configure() unneccessarily.
@ -373,6 +375,38 @@ UINT8 mc6845_get_ra(mc6845_t *mc6845)
}
static void update_cursor_state(mc6845_t *mc6845)
{
/* save and increment cursor counter */
UINT8 old_count = mc6845->cursor_count;
mc6845->cursor_count = mc6845->cursor_count + 1;
/* switch on cursor blinking mode */
switch (mc6845->cursor_start_ras & 0x60)
{
/* always on */
case 0x00: mc6845->cursor_state = TRUE; break;
/* always off */
default:
case 0x20: mc6845->cursor_state = FALSE; break;
/* fast blink */
case 0x40:
if ((old_count & 0x10) != (mc6845->cursor_count & 0x10))
mc6845->cursor_state = !mc6845->cursor_state;
break;
/* slow blink */
case 0x60:
if ((old_count & 0x20) != (mc6845->cursor_count & 0x20))
mc6845->cursor_state = !mc6845->cursor_state;
break;
}
}
void mc6845_update(mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect)
{
if (mc6845->has_valid_parameters)
@ -380,22 +414,38 @@ void mc6845_update(mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *clipr
UINT16 y;
/* call the set up function if any */
void *param = 0;
void *param = NULL;
if (mc6845->intf->begin_update)
param = mc6845->intf->begin_update(mc6845->machine, mc6845, bitmap, cliprect);
/* read the start address at the beginning of the frame */
if (cliprect->min_y == 0)
{
/* read the start address at the beginning of the frame */
mc6845->current_ma = mc6845->start_addr;
/* also update the cursor state here */
update_cursor_state(mc6845);
}
/* for each row in the visible region */
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
{
/* compute the current raster line */
UINT8 ra = y % (mc6845->max_ras_addr + 1);
/* check if the cursor is visible and is on this scanline */
int cursor_visible = mc6845->cursor_state &&
(ra >= (mc6845->cursor_start_ras & 0x1f)) &&
(ra <= mc6845->cursor_end_ras) &&
(mc6845->cursor >= mc6845->current_ma) &&
(mc6845->cursor < (mc6845->current_ma + mc6845->horiz_disp));
/* compute the cursor x position, or -1 if not visible */
INT8 cursor_x = cursor_visible ? (mc6845->cursor - mc6845->current_ma) : -1;
/* call the external system to draw it */
mc6845->intf->update_row(mc6845->machine, mc6845, bitmap, cliprect, mc6845->current_ma, ra, y, mc6845->horiz_disp, param);
mc6845->intf->update_row(mc6845->machine, mc6845, bitmap, cliprect, mc6845->current_ma, ra, y, mc6845->horiz_disp, cursor_x, param);
/* update MA if the last raster address */
if (ra == mc6845->max_ras_addr)
@ -453,6 +503,8 @@ static void *mc6845_start(running_machine *machine, const char *tag, const void
state_save_register_item(unique_tag, 0, mc6845->start_addr);
state_save_register_item(unique_tag, 0, mc6845->cursor);
state_save_register_item(unique_tag, 0, mc6845->light_pen);
state_save_register_item(unique_tag, 0, mc6845->cursor_state);
state_save_register_item(unique_tag, 0, mc6845->cursor_count);
return mc6845;
}
@ -483,7 +535,7 @@ void mc6845_get_info(running_machine *machine, void *token, UINT32 state, device
/* --- the following bits of info are returned as NULL-terminated strings --- */
case DEVINFO_STR_NAME: info->s = "MC6845"; break;
case DEVINFO_STR_FAMILY: info->s = "MC6845 CRTC"; break;
case DEVINFO_STR_VERSION: info->s = "1.0"; break;
case DEVINFO_STR_VERSION: info->s = "1.5"; break;
case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break;
case DEVINFO_STR_CREDITS: info->s = "Copyright Nicola Salmoria and the MAME Team"; break;
}

View File

@ -40,9 +40,12 @@ struct _mc6845_interface
mame_bitmap *bitmap, const rectangle *cliprect);
/* this gets called for every row, the driver must output
x_count * hpixels_per_column pixels */
x_count * hpixels_per_column pixels.
cursor_x indicates the character position where the cursor is, or -1
if there is no cursor on this row */
void (*update_row)(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap,
const rectangle *cliprect, UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, void *param);
const rectangle *cliprect, UINT16 ma, UINT8 ra,
UINT16 y, UINT8 x_count, INT8 cursor_x, void *param);
/* if specified, this gets called after all row updating is complete */
void (*end_update)(running_machine *machine, mc6845_t *mc6845,

View File

@ -304,7 +304,7 @@ static void *nyny_begin_update(running_machine *machine, mc6845_t *mc6845, mame_
static void nyny_update_row(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect,
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, void *param)
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
{
UINT8 cx;

View File

@ -338,7 +338,7 @@ static void *begin_update(running_machine *machine, mc6845_t *mc6845, mame_bitma
static void update_row(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect,
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, void *param)
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
{
UINT8 cx;

View File

@ -450,7 +450,7 @@ static void *begin_update(running_machine *machine, mc6845_t *mc6845, mame_bitma
static void update_row(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect,
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, void *param)
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
{
UINT8 cx;

View File

@ -48,7 +48,7 @@ static const UINT8 ssingles_colors[NUM_PENS*3]=
};
static void update_row(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect,
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, void *param)
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
{
int cx,x;
UINT32 tile_address;

View File

@ -31,6 +31,7 @@ static void qix_update_row(running_machine *machine,
UINT8 ra,
UINT16 y,
UINT8 x_count,
INT8 cursor_x,
void *param);
@ -353,7 +354,7 @@ static void *qix_begin_update(running_machine *machine, mc6845_t *mc6845, mame_b
static void qix_update_row(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect,
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, void *param)
UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
{
qix_state *state = machine->driver_data;
UINT16 x;