Skip to content

Commit

Permalink
Major bitmap-related changes throughout the system. There are
Browse files Browse the repository at this point in the history
almost certainly some regressions lurking. Let me know if
something seems busted.

Bitmaps are now strongly typed based on format. bitmap_t still
exists as an abstract base class, but it is almost never used.
Instead, format-specific bitmap classes are provided:

   bitmap_ind8 == 8bpp indexed
   bitmap_ind16 == 16bpp indexed
   bitmap_ind32 == 32bpp indexed
   bitmap_ind64 == 64bpp indexed
   bitmap_rgb32 == 32bpp RGB
   bitmap_argb32 == 32bpp ARGB
   bitmap_yuy16 == 16bpp YUY

For each format, a generic pix() method is provided which
references pixels of the correct type. The old pix8/pix16/pix32/
pix64 methods still exist in the short term, but the only one
available is the one that matches the bitmap's pixel size. Note
also that the old RGB15 format bitmaps are no longer supported
at all.

Converted model1, megadriv, and stv drivers away from the RGB15
format bitmaps.

New auto_bitmap_<type>_alloc() macros are provided for allocating
the appropriate type of bitmap.

Screen update functions now must specify the correct bitmap type
as their input parameters. For static update functions the
SCREEN_UPDATE macro is now replaced with SCREEN_UPDATE_RGB32 and
SCREEN_UPDATE_IND16 macros. All existing drivers have been 
updated to use the correct macros. 

Screen update functions are now required for all screens; there
is no longer any default behavior of copying a "default" bitmap
to the screen (in fact the default bitmap has been deprecated).
Use one of the following to specify your screen_update callback:

   MCFG_SCREEN_UPDATE_STATIC(name) - static functions
   MCFG_SCREEN_UPDATE_DRIVER(class, func) - driver members
   MCFG_SCREEN_UPDATE_DEVICE(tag, class, func) - device members

Because the target bitmap format can now be deduced from the
screen update function itself, the MCFG_SCREEN_FORMAT macro is
no longer necessary, and has been removed. If you specify a
screen update callback that takes a bitmap_ind16, then the screen
will be configured to use a 16bpp indexed bitmap, and if you
specify a callback that takes a bitmap_rgb32, then a 32bpp RGB
bitmap will be provided.

Extended the bitmap classes to support wrapping a subregion of
another bitmap, and cleaner allocation/resetting. The preferred
use of bitmaps now is to define them directly in drivers/devices
and use allocate() or wrap() to set them up, rather than 
allocating them via auto_bitmap_*_alloc().

Several common devices needed overhauls or changes as a result
of the above changes:

 * Reorganized the laserdisc base driver and all the laserdisc 
    drivers as modern C++ devices, cleaning the code up 
    considerably. Merged ldsound device into the laserdsc
    device since modern devices are flexible enough to handle
    it.

 * Reorganized the v9938 device as a modern C++ device. Removed
    v9938mod.c in favor of template functions in v9938.c directly.

 * Added independent ind16 and rgb32 callbacks for TMS340x0 devices.

 * All video devices are now hard-coded to either ind16 or rgb32
    bitmaps. The most notable is the mc6845 which is rgb32, and
    required changes to a number of consumers.

 * Added screen_update methods to most video devices so they can be
    directly called via MCFG_SCREEN_UPDATE_DEVICE instead of creating
    tons of stub functions.
  • Loading branch information
aaronsgiles committed Jan 12, 2012
1 parent 6a8a2af commit e4238fb
Show file tree
Hide file tree
Showing 2,547 changed files with 16,956 additions and 18,995 deletions.
9 changes: 6 additions & 3 deletions .gitattributes
Expand Up @@ -876,14 +876,18 @@ src/emu/machine/k053252.c svneol=native#text/plain
src/emu/machine/k053252.h svneol=native#text/plain
src/emu/machine/k056230.c svneol=native#text/plain
src/emu/machine/k056230.h svneol=native#text/plain
src/emu/machine/laserdsc.c svneol=native#text/plain
src/emu/machine/laserdsc.h svneol=native#text/plain
src/emu/machine/latch8.c svneol=native#text/plain
src/emu/machine/latch8.h svneol=native#text/plain
src/emu/machine/ldcore.c svneol=native#text/plain
src/emu/machine/ldcore.h svneol=native#text/plain
src/emu/machine/ldpr8210.c svneol=native#text/plain
src/emu/machine/ldpr8210.h svneol=native#text/plain
src/emu/machine/ldstub.c svneol=native#text/plain
src/emu/machine/ldstub.h svneol=native#text/plain
src/emu/machine/ldv1000.c svneol=native#text/plain
src/emu/machine/ldv1000.h svneol=native#text/plain
src/emu/machine/ldvp931.c svneol=native#text/plain
src/emu/machine/ldvp931.h svneol=native#text/plain
src/emu/machine/matsucd.c svneol=native#text/plain
src/emu/machine/matsucd.h svneol=native#text/plain
src/emu/machine/mb14241.c svneol=native#text/plain
Expand Down Expand Up @@ -1376,7 +1380,6 @@ src/emu/video/upd3301.c svneol=native#text/plain
src/emu/video/upd3301.h svneol=native#text/plain
src/emu/video/v9938.c svneol=native#text/plain
src/emu/video/v9938.h svneol=native#text/plain
src/emu/video/v9938mod.c svneol=native#text/plain
src/emu/video/vector.c svneol=native#text/plain
src/emu/video/vector.h svneol=native#text/plain
src/emu/video/vooddefs.h svneol=native#text/plain
Expand Down
23 changes: 10 additions & 13 deletions src/build/png2bdc.c
Expand Up @@ -74,7 +74,7 @@ struct _render_font_char
INT32 width; /* width from this character to the next */
INT32 xoffs, yoffs; /* X and Y offset from baseline to top,left of bitmap */
INT32 bmwidth, bmheight; /* width and height of bitmap */
bitmap_t * bitmap; /* pointer to the bitmap containing the raw data */
bitmap_argb32 * bitmap; /* pointer to the bitmap containing the raw data */
};


Expand All @@ -93,7 +93,7 @@ struct _render_font
INLINE FUNCTIONS
***************************************************************************/

INLINE int pixel_is_set(bitmap_t &bitmap, int y, int x)
INLINE int pixel_is_set(bitmap_argb32 &bitmap, int y, int x)
{
return (bitmap.pix32(y, x) & 0xffffff) == 0;
}
Expand Down Expand Up @@ -258,7 +258,7 @@ static int render_font_save_cached(render_font *font, const char *filename, UINT
characters in the given font
-------------------------------------------------*/

static int bitmap_to_chars(bitmap_t &bitmap, render_font *font)
static int bitmap_to_chars(bitmap_argb32 &bitmap, render_font *font)
{
int rowstart = 0;
int x, y;
Expand Down Expand Up @@ -352,7 +352,7 @@ static int bitmap_to_chars(bitmap_t &bitmap, render_font *font)
// printf(" Character %X - width = %d\n", chstart, colend - colstart + 1);

/* allocate a bitmap */
ch->bitmap = new(std::nothrow) bitmap_t(colend - colstart + 1, font->height, BITMAP_FORMAT_ARGB32);
ch->bitmap = new(std::nothrow) bitmap_argb32(colend - colstart + 1, font->height);
if (ch->bitmap == NULL)
{
fprintf(stderr, "Error allocating character bitmap (%dx%d)\n", colend - colstart + 1, font->height);
Expand Down Expand Up @@ -414,21 +414,19 @@ int main(int argc, char *argv[])
/* iterate over input files */
for (curarg = 1; curarg < argc - 1; curarg++)
{
/* load the png file */
const char *pngname = argv[curarg];
file_error filerr;
png_error pngerr;
bitmap_t *bitmap;
core_file *file;

/* load the png file */
filerr = core_fopen(pngname, OPEN_FLAG_READ, &file);
file_error filerr = core_fopen(pngname, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Error %d attempting to open PNG file\n", filerr);
error = TRUE;
break;
}
pngerr = png_read_bitmap(file, &bitmap);

bitmap_argb32 bitmap;
png_error pngerr = png_read_bitmap(file, bitmap);
core_fclose(file);
if (pngerr != PNGERR_NONE)
{
Expand All @@ -438,8 +436,7 @@ int main(int argc, char *argv[])
}

/* parse the PNG into characters */
error = bitmap_to_chars(*bitmap, font);
delete bitmap;
error = bitmap_to_chars(bitmap, font);
if (error)
break;
}
Expand Down
71 changes: 54 additions & 17 deletions src/emu/cpu/tms34010/tms34010.c
Expand Up @@ -959,7 +959,7 @@ static TIMER_CALLBACK( scanline_callback )
{
/* only do this if we have an incoming pixel clock */
/* also, only do it if the HEBLNK/HSBLNK values are stable */
if (master && tms->config->scanline_callback != NULL)
if (master && (tms->config->scanline_callback_ind16 != NULL || tms->config->scanline_callback_rgb32 != NULL))
{
int htotal = SMART_IOREG(tms, HTOTAL);
if (htotal > 0 && vtotal > 0)
Expand Down Expand Up @@ -1003,7 +1003,7 @@ static TIMER_CALLBACK( scanline_callback )
}

/* force a partial update within the visible area */
if (vcount >= current_visarea.min_y && vcount <= current_visarea.max_y && tms->config->scanline_callback != NULL)
if (vcount >= current_visarea.min_y && vcount <= current_visarea.max_y && (tms->config->scanline_callback_ind16 != NULL || tms->config->scanline_callback_rgb32 != NULL))
tms->screen->update_partial(vcount);

/* if we are in the visible area, increment DPYADR by DUDATE */
Expand Down Expand Up @@ -1078,7 +1078,7 @@ void tms34010_get_display_params(device_t *cpu, tms34010_display_params *params)
}


SCREEN_UPDATE( tms340x0 )
SCREEN_UPDATE_IND16( tms340x0_ind16 )
{
pen_t blackpen = get_black_pen(screen.machine());
tms34010_display_params params;
Expand All @@ -1093,7 +1093,7 @@ SCREEN_UPDATE( tms340x0 )
if (type == TMS34010 || type == TMS34020)
{
tms = get_safe_token(cpu);
if (tms->config != NULL && tms->config->scanline_callback != NULL && tms->screen == &screen)
if (tms->config != NULL && tms->config->scanline_callback_ind16 != NULL && tms->screen == &screen)
break;
tms = NULL;
}
Expand All @@ -1109,30 +1109,67 @@ SCREEN_UPDATE( tms340x0 )
{
/* call through to the callback */
LOG((" Update: scan=%3d ROW=%04X COL=%04X\n", cliprect.min_y, params.rowaddr, params.coladdr));
(*tms->config->scanline_callback)(screen, bitmap, cliprect.min_y, &params);
(*tms->config->scanline_callback_ind16)(screen, bitmap, cliprect.min_y, &params);
}

/* otherwise, just blank the current scanline */
else
params.heblnk = params.hsblnk = cliprect.max_x + 1;

/* blank out the blank regions */
if (bitmap.bpp() == 16)
UINT16 *dest = &bitmap.pix16(cliprect.min_y);
for (x = cliprect.min_x; x < params.heblnk; x++)
dest[x] = blackpen;
for (x = params.hsblnk; x <= cliprect.max_y; x++)
dest[x] = blackpen;
return 0;

}

SCREEN_UPDATE_RGB32( tms340x0_rgb32 )
{
pen_t blackpen = get_black_pen(screen.machine());
tms34010_display_params params;
tms34010_state *tms = NULL;
device_t *cpu;
int x;

/* find the owning CPU */
for (cpu = screen.machine().devicelist().first(); cpu != NULL; cpu = cpu->next())
{
UINT16 *dest = &bitmap.pix16(cliprect.min_y);
for (x = cliprect.min_x; x < params.heblnk; x++)
dest[x] = blackpen;
for (x = params.hsblnk; x <= cliprect.max_y; x++)
dest[x] = blackpen;
device_type type = cpu->type();
if (type == TMS34010 || type == TMS34020)
{
tms = get_safe_token(cpu);
if (tms->config != NULL && tms->config->scanline_callback_rgb32 != NULL && tms->screen == &screen)
break;
tms = NULL;
}
}
else if (bitmap.bpp() == 32)
if (tms == NULL)
fatalerror("Unable to locate matching CPU for screen '%s'\n", screen.tag());

/* get the display parameters for the screen */
tms34010_get_display_params(tms->device, &params);

/* if the display is enabled, call the scanline callback */
if (params.enabled)
{
UINT32 *dest = &bitmap.pix32(cliprect.min_y);
for (x = cliprect.min_x; x < params.heblnk; x++)
dest[x] = blackpen;
for (x = params.hsblnk; x <= cliprect.max_y; x++)
dest[x] = blackpen;
/* call through to the callback */
LOG((" Update: scan=%3d ROW=%04X COL=%04X\n", cliprect.min_y, params.rowaddr, params.coladdr));
(*tms->config->scanline_callback_rgb32)(screen, bitmap, cliprect.min_y, &params);
}

/* otherwise, just blank the current scanline */
else
params.heblnk = params.hsblnk = cliprect.max_x + 1;

/* blank out the blank regions */
UINT32 *dest = &bitmap.pix32(cliprect.min_y);
for (x = cliprect.min_x; x < params.heblnk; x++)
dest[x] = blackpen;
for (x = params.hsblnk; x <= cliprect.max_y; x++)
dest[x] = blackpen;
return 0;
}

Expand Down
6 changes: 4 additions & 2 deletions src/emu/cpu/tms34010/tms34010.h
Expand Up @@ -196,15 +196,17 @@ struct _tms34010_config
const char *screen_tag; /* the screen operated on */
UINT32 pixclock; /* the pixel clock (0 means don't adjust screen size) */
int pixperclock; /* pixels per clock */
void (*scanline_callback)(screen_device &screen, bitmap_t &bitmap, int scanline, const tms34010_display_params *params);
void (*scanline_callback_ind16)(screen_device &screen, bitmap_ind16 &bitmap, int scanline, const tms34010_display_params *params);
void (*scanline_callback_rgb32)(screen_device &screen, bitmap_rgb32 &bitmap, int scanline, const tms34010_display_params *params);
void (*output_int)(device_t *device, int state); /* output interrupt callback */
void (*to_shiftreg)(address_space *space, offs_t, UINT16 *); /* shift register write */
void (*from_shiftreg)(address_space *space, offs_t, UINT16 *); /* shift register read */
};


/* PUBLIC FUNCTIONS - 34010 */
SCREEN_UPDATE( tms340x0 );
SCREEN_UPDATE_IND16( tms340x0_ind16 );
SCREEN_UPDATE_RGB32( tms340x0_rgb32 );
void tms34010_get_display_params(device_t *cpu, tms34010_display_params *params);

DECLARE_LEGACY_CPU_DEVICE(TMS34010, tms34010);
Expand Down
19 changes: 10 additions & 9 deletions src/emu/crsshair.c
Expand Up @@ -37,7 +37,7 @@ struct _crosshair_global
UINT8 used[MAX_PLAYERS]; /* usage per player */
UINT8 mode[MAX_PLAYERS]; /* visibility mode per player */
UINT8 visible[MAX_PLAYERS]; /* visibility per player */
bitmap_t * bitmap[MAX_PLAYERS]; /* bitmap per player */
bitmap_argb32 * bitmap[MAX_PLAYERS]; /* bitmap per player */
render_texture * texture[MAX_PLAYERS]; /* texture per player */
device_t *screen[MAX_PLAYERS]; /* the screen on which this player's crosshair is drawn */
float x[MAX_PLAYERS]; /* current X position */
Expand Down Expand Up @@ -155,32 +155,33 @@ static void create_bitmap(running_machine &machine, int player)
rgb_t color = crosshair_colors[player];

/* if we have a bitmap and texture for this player, kill it */
global_free(global.bitmap[player]);
if (global.bitmap[player] == NULL)
global.bitmap[player] = global_alloc(bitmap_argb32);
machine.render().texture_free(global.texture[player]);

emu_file crossfile(machine.options().crosshair_path(), OPEN_FLAG_READ);
if (global.name[player][0] != 0)
{
/* look for user specified file */
sprintf(filename, "%s.png", global.name[player]);
global.bitmap[player] = render_load_png(crossfile, NULL, filename, NULL, NULL);
render_load_png(*global.bitmap[player], crossfile, NULL, filename);
}
else
{
/* look for default cross?.png in crsshair\game dir */
sprintf(filename, "cross%d.png", player + 1);
global.bitmap[player] = render_load_png(crossfile, machine.system().name, filename, NULL, NULL);
render_load_png(*global.bitmap[player], crossfile, machine.system().name, filename);

/* look for default cross?.png in crsshair dir */
if (global.bitmap[player] == NULL)
global.bitmap[player] = render_load_png(crossfile, NULL, filename, NULL, NULL);
if (!global.bitmap[player]->valid())
render_load_png(*global.bitmap[player], crossfile, NULL, filename);
}

/* if that didn't work, use the built-in one */
if (global.bitmap[player] == NULL)
if (!global.bitmap[player]->valid())
{
/* allocate a blank bitmap to start with */
global.bitmap[player] = global_alloc(bitmap_t(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32));
global.bitmap[player]->allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE);
global.bitmap[player]->fill(MAKE_ARGB(0x00,0xff,0xff,0xff));

/* extract the raw source data to it */
Expand All @@ -199,7 +200,7 @@ static void create_bitmap(running_machine &machine, int player)

/* create a texture to reference the bitmap */
global.texture[player] = machine.render().texture_alloc(render_texture::hq_scale);
global.texture[player]->set_bitmap(global.bitmap[player], NULL, TEXFORMAT_ARGB32);
global.texture[player]->set_bitmap(*global.bitmap[player], global.bitmap[player]->cliprect(), TEXFORMAT_ARGB32);
}


Expand Down
1 change: 1 addition & 0 deletions src/emu/device.h
Expand Up @@ -78,6 +78,7 @@
device_t::static_set_input_default(*device, DEVICE_INPUT_DEFAULTS_NAME(_config)); \



//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
Expand Down
11 changes: 11 additions & 0 deletions src/emu/disound.c
Expand Up @@ -102,6 +102,17 @@ void device_sound_interface::static_reset_routes(device_t &device)
}


//-------------------------------------------------
// stream_alloc - allocate a stream implicitly
// associated with this device
//-------------------------------------------------

sound_stream *device_sound_interface::stream_alloc(int inputs, int outputs, int sample_rate)
{
return device().machine().sound().stream_alloc(*this, inputs, outputs, sample_rate);
}


//-------------------------------------------------
// inputs - return the total number of inputs
// for the given device
Expand Down
3 changes: 3 additions & 0 deletions src/emu/disound.h
Expand Up @@ -126,6 +126,9 @@ class device_sound_interface : public device_interface
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) = 0;

// stream creation
sound_stream *stream_alloc(int inputs, int outputs, int sample_rate);

// helpers
int inputs() const;
int outputs() const;
Expand Down

0 comments on commit e4238fb

Please sign in to comment.