summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Zsolt Vasvari <zsoltvas@mamedev.org>2008-02-28 02:01:37 +0000
committer Zsolt Vasvari <zsoltvas@mamedev.org>2008-02-28 02:01:37 +0000
commit7d092ece837a918d7fdce12325415b29cd2e33d1 (patch)
tree0f47b26daae3a8c9513f7a546765efdc020d81e2
parentb0735fe3180ddcb4fedbdd6e2558db03fcbbb42a (diff)
Adds support for cursors. All 4 blinking modes are supported (always on, always off, fast, slow)
-rw-r--r--src/emu/video/mc6845.c60
-rw-r--r--src/emu/video/mc6845.h7
-rw-r--r--src/mame/drivers/nyny.c2
-rw-r--r--src/mame/drivers/r2dtank.c2
-rw-r--r--src/mame/drivers/spiders.c2
-rw-r--r--src/mame/drivers/ssingles.c2
-rw-r--r--src/mame/video/qix.c3
7 files changed, 67 insertions, 11 deletions
diff --git a/src/emu/video/mc6845.c b/src/emu/video/mc6845.c
index 6b9addc9772..44baaee8ac2 100644
--- a/src/emu/video/mc6845.c
+++ b/src/emu/video/mc6845.c
@@ -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;
}
diff --git a/src/emu/video/mc6845.h b/src/emu/video/mc6845.h
index fae02aad598..2e6b84cf57e 100644
--- a/src/emu/video/mc6845.h
+++ b/src/emu/video/mc6845.h
@@ -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,
diff --git a/src/mame/drivers/nyny.c b/src/mame/drivers/nyny.c
index c42e875e357..d610c29a8ec 100644
--- a/src/mame/drivers/nyny.c
+++ b/src/mame/drivers/nyny.c
@@ -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;
diff --git a/src/mame/drivers/r2dtank.c b/src/mame/drivers/r2dtank.c
index cdc399ddc12..446915938d9 100644
--- a/src/mame/drivers/r2dtank.c
+++ b/src/mame/drivers/r2dtank.c
@@ -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;
diff --git a/src/mame/drivers/spiders.c b/src/mame/drivers/spiders.c
index 96a6ec36e9a..78046fc5b20 100644
--- a/src/mame/drivers/spiders.c
+++ b/src/mame/drivers/spiders.c
@@ -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;
diff --git a/src/mame/drivers/ssingles.c b/src/mame/drivers/ssingles.c
index 351558d644d..a06c4252534 100644
--- a/src/mame/drivers/ssingles.c
+++ b/src/mame/drivers/ssingles.c
@@ -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;
diff --git a/src/mame/video/qix.c b/src/mame/video/qix.c
index 4cbdbcfc656..6f9b4d80062 100644
--- a/src/mame/video/qix.c
+++ b/src/mame/video/qix.c
@@ -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;