本文整理汇总了C++中running_machine::tilemap方法的典型用法代码示例。如果您正苦于以下问题:C++ running_machine::tilemap方法的具体用法?C++ running_machine::tilemap怎么用?C++ running_machine::tilemap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类running_machine
的用法示例。
在下文中一共展示了running_machine::tilemap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wgp_core_vh_start
static void wgp_core_vh_start( running_machine &machine, int piv_xoffs, int piv_yoffs )
{
wgp_state *state = machine.driver_data<wgp_state>();
state->m_piv_tilemap[0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(wgp_state::get_piv0_tile_info),state), TILEMAP_SCAN_ROWS, 16, 16, 64, 64);
state->m_piv_tilemap[1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(wgp_state::get_piv1_tile_info),state), TILEMAP_SCAN_ROWS, 16, 16, 64, 64);
state->m_piv_tilemap[2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(wgp_state::get_piv2_tile_info),state), TILEMAP_SCAN_ROWS, 16, 16, 64, 64);
state->m_piv_xoffs = piv_xoffs;
state->m_piv_yoffs = piv_yoffs;
state->m_piv_tilemap[0]->set_transparent_pen(0);
state->m_piv_tilemap[1]->set_transparent_pen(0);
state->m_piv_tilemap[2]->set_transparent_pen(0);
/* flipscreen n/a */
state->m_piv_tilemap[0]->set_scrolldx(-piv_xoffs, 0);
state->m_piv_tilemap[1]->set_scrolldx(-piv_xoffs, 0);
state->m_piv_tilemap[2]->set_scrolldx(-piv_xoffs, 0);
state->m_piv_tilemap[0]->set_scrolldy(-piv_yoffs, 0);
state->m_piv_tilemap[1]->set_scrolldy(-piv_yoffs, 0);
state->m_piv_tilemap[2]->set_scrolldy(-piv_yoffs, 0);
/* We don't need tilemap_set_scroll_rows, as the custom draw routine applies rowscroll manually */
tc0100scn_set_colbanks(state->m_tc0100scn, 0x80, 0xc0, 0x40);
state->save_item(NAME(state->m_piv_ctrl_reg));
state->save_item(NAME(state->m_rotate_ctrl));
state->save_item(NAME(state->m_piv_zoom));
state->save_item(NAME(state->m_piv_scrollx));
state->save_item(NAME(state->m_piv_scrolly));
}
示例2: twincobr_create_tilemaps
static void twincobr_create_tilemaps(running_machine &machine)
{
twincobr_state *state = machine.driver_data<twincobr_state>();
state->m_bg_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_bg_tile_info),state),TILEMAP_SCAN_ROWS,8,8,64,64);
state->m_fg_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_fg_tile_info),state),TILEMAP_SCAN_ROWS,8,8,64,64);
state->m_tx_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_tx_tile_info),state),TILEMAP_SCAN_ROWS,8,8,64,32);
state->m_fg_tilemap->set_transparent_pen(0);
state->m_tx_tilemap->set_transparent_pen(0);
}
示例3: create_tilemaps
static void create_tilemaps(running_machine &machine)
{
megasys1_state *state = machine.driver_data<megasys1_state>();
int layer, i;
for (layer = 0; layer < 3; layer++)
{
/* 16x16 tilemaps */
state->m_tilemap[layer][0][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
8,8, TILES_PER_PAGE_X * 16, TILES_PER_PAGE_Y * 2);
state->m_tilemap[layer][0][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 4);
state->m_tilemap[layer][0][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 8);
state->m_tilemap[layer][0][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 16);
/* 8x8 tilemaps */
state->m_tilemap[layer][1][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 1);
state->m_tilemap[layer][1][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
state->m_tilemap[layer][1][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
state->m_tilemap[layer][1][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 4);
/* set user data and transparency */
for (i = 0; i < 8; i++)
{
state->m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer);
state->m_tilemap[layer][i/4][i%4]->set_transparent_pen(15);
}
}
}
示例4: tilemap_update_bitmap
static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state *state, int width, int height)
{
/* swap the coordinates back if they were talking about a rotated surface */
if (state->tilemap.rotate & ORIENTATION_SWAP_XY)
{ UINT32 temp = width; width = height; height = temp; }
/* realloc the bitmap if it is too small */
if (state->bitmap == NULL || state->texture == NULL || state->bitmap->width() != width || state->bitmap->height() != height)
{
/* free the old stuff */
machine.render().texture_free(state->texture);
global_free(state->bitmap);
/* allocate new stuff */
state->bitmap = global_alloc(bitmap_rgb32(width, height));
state->bitmap->set_palette(machine.palette);
state->texture = machine.render().texture_alloc();
state->texture->set_bitmap(*state->bitmap, state->bitmap->cliprect(), TEXFORMAT_RGB32);
/* force a redraw */
state->bitmap_dirty = TRUE;
}
/* handle the redraw */
if (state->bitmap_dirty)
{
tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which);
tilemap->draw_debug(*state->bitmap, state->tilemap.xoffs, state->tilemap.yoffs);
/* reset the texture to force an update */
state->texture->set_bitmap(*state->bitmap, state->bitmap->cliprect(), TEXFORMAT_RGB32);
state->bitmap_dirty = FALSE;
}
}
示例5: tilemap_update_bitmap
static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, int width, int height)
{
// swap the coordinates back if they were talking about a rotated surface
if (state.tilemap.rotate & ORIENTATION_SWAP_XY)
std::swap(width, height);
// realloc the bitmap if it is too small
if (state.bitmap == nullptr || state.texture == nullptr || state.bitmap->width() != width || state.bitmap->height() != height)
{
// free the old stuff
machine.render().texture_free(state.texture);
global_free(state.bitmap);
// allocate new stuff
state.bitmap = global_alloc(bitmap_rgb32(width, height));
state.texture = machine.render().texture_alloc();
state.texture->set_bitmap(*state.bitmap, state.bitmap->cliprect(), TEXFORMAT_RGB32);
// force a redraw
state.bitmap_dirty = true;
}
// handle the redraw
if (state.bitmap_dirty)
{
state.bitmap->fill(0);
tilemap_t *tilemap = machine.tilemap().find(state.tilemap.which);
tilemap->draw_debug(*machine.first_screen(), *state.bitmap, state.tilemap.xoffs, state.tilemap.yoffs, state.tilemap.flags);
// reset the texture to force an update
state.texture->set_bitmap(*state.bitmap, state.bitmap->cliprect(), TEXFORMAT_RGB32);
state.bitmap_dirty = false;
}
}
示例6: video_start_common
static void video_start_common(running_machine &machine, int pagecount)
{
system1_state *state = machine.driver_data<system1_state>();
int pagenum;
/* allocate memory for the collision arrays */
state->m_mix_collide = auto_alloc_array_clear(machine, UINT8, 64);
state->m_sprite_collide = auto_alloc_array_clear(machine, UINT8, 1024);
/* allocate memory for videoram */
state->m_tilemap_pages = pagecount;
state->m_videoram = auto_alloc_array_clear(machine, UINT8, 0x800 * pagecount);
/* create the tilemap pages */
for (pagenum = 0; pagenum < pagecount; pagenum++)
{
state->m_tilemap_page[pagenum] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(system1_state::tile_get_info),state), TILEMAP_SCAN_ROWS, 8,8, 32,32);
state->m_tilemap_page[pagenum]->set_transparent_pen(0);
state->m_tilemap_page[pagenum]->set_user_data(state->m_videoram + 0x800 * pagenum);
}
/* allocate a temporary bitmap for sprite rendering */
state->m_sprite_bitmap = auto_bitmap_ind16_alloc(machine, 512, 256);
/* register for save stats */
state_save_register_global(machine, state->m_video_mode);
state_save_register_global(machine, state->m_mix_collide_summary);
state_save_register_global(machine, state->m_sprite_collide_summary);
state->save_pointer(NAME(state->m_videoram), 0x800 * pagecount);
state_save_register_global_pointer(machine, state->m_mix_collide, 64);
state_save_register_global_pointer(machine, state->m_sprite_collide, 1024);
}
示例7: ui_gfx_is_relevant
bool ui_gfx_is_relevant(running_machine &machine)
{
ui_gfx_state &state = ui_gfx;
if (!state.started)
ui_gfx_count_devices(machine, state);
return state.palette.devcount > 0
|| state.gfxset.devcount > 0
|| machine.tilemap().count() > 0;
}
示例8: twincobr_flipscreen
void twincobr_flipscreen(running_machine &machine, int flip)
{
twincobr_state *state = machine.driver_data<twincobr_state>();
machine.tilemap().set_flip_all((flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0));
state->m_flip_screen = flip;
if (flip) {
state->m_scroll_x = 0x008;
state->m_scroll_y = 0x0c5;
}
else {
state->m_scroll_x = 0x037;
state->m_scroll_y = 0x01e;
}
}
示例9: tilemap_handle_keys
static void tilemap_handle_keys(running_machine &machine, ui_gfx_state *state, int viswidth, int visheight)
{
ui_gfx_state oldstate = *state;
UINT32 mapwidth, mapheight;
int step;
/* handle tilemap selection (open bracket,close bracket) */
if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
state->tilemap.which--;
if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
state->tilemap.which++;
/* clamp within range */
if (state->tilemap.which < 0)
state->tilemap.which = 0;
if (state->tilemap.which >= machine.tilemap().count())
state->tilemap.which = machine.tilemap().count() - 1;
/* cache some info in locals */
tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which);
mapwidth = tilemap->width();
mapheight = tilemap->height();
/* handle zoom (minus,plus) */
if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
state->tilemap.zoom--;
if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
state->tilemap.zoom++;
/* clamp within range */
if (state->tilemap.zoom < 0)
state->tilemap.zoom = 0;
if (state->tilemap.zoom > 8)
state->tilemap.zoom = 8;
if (state->tilemap.zoom != oldstate.tilemap.zoom)
{
if (state->tilemap.zoom != 0)
popmessage("Zoom = %d", state->tilemap.zoom);
else
popmessage("Zoom Auto");
}
/* handle rotation (R) */
if (ui_input_pressed(machine, IPT_UI_ROTATE))
state->tilemap.rotate = orientation_add(ROT90, state->tilemap.rotate);
/* handle navigation (up,down,left,right) */
step = 8;
if (machine.input().code_pressed(KEYCODE_LSHIFT)) step = 1;
if (machine.input().code_pressed(KEYCODE_LCONTROL)) step = 64;
if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
state->tilemap.yoffs -= step;
if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
state->tilemap.yoffs += step;
if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 6))
state->tilemap.xoffs -= step;
if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 6))
state->tilemap.xoffs += step;
/* clamp within range */
while (state->tilemap.xoffs < 0)
state->tilemap.xoffs += mapwidth;
while (state->tilemap.xoffs >= mapwidth)
state->tilemap.xoffs -= mapwidth;
while (state->tilemap.yoffs < 0)
state->tilemap.yoffs += mapheight;
while (state->tilemap.yoffs >= mapheight)
state->tilemap.yoffs -= mapheight;
/* if something changed, we need to force an update to the bitmap */
if (state->tilemap.which != oldstate.tilemap.which ||
state->tilemap.xoffs != oldstate.tilemap.xoffs ||
state->tilemap.yoffs != oldstate.tilemap.yoffs ||
state->tilemap.rotate != oldstate.tilemap.rotate)
{
state->bitmap_dirty = TRUE;
}
}
示例10: tilemap_handler
static void tilemap_handler(running_machine &machine, render_container *container, ui_gfx_state *state)
{
render_font *ui_font = ui_get_font(machine);
float chwidth, chheight;
render_bounds mapboxbounds;
render_bounds boxbounds;
int targwidth = machine.render().ui_target().width();
int targheight = machine.render().ui_target().height();
float titlewidth;
float x0, y0;
int mapboxwidth, mapboxheight;
int maxxscale, maxyscale;
UINT32 mapwidth, mapheight;
int x, pixelscale;
char title[100];
/* get the size of the tilemap itself */
tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which);
mapwidth = tilemap->width();
mapheight = tilemap->height();
if (state->tilemap.rotate & ORIENTATION_SWAP_XY)
{ UINT32 temp = mapwidth; mapwidth = mapheight; mapheight = temp; }
/* add a half character padding for the box */
chheight = ui_get_line_height(machine);
chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0');
boxbounds.x0 = 0.0f + 0.5f * chwidth;
boxbounds.x1 = 1.0f - 0.5f * chwidth;
boxbounds.y0 = 0.0f + 0.5f * chheight;
boxbounds.y1 = 1.0f - 0.5f * chheight;
/* the tilemap box bounds starts a half character in from the box */
mapboxbounds = boxbounds;
mapboxbounds.x0 += 0.5f * chwidth;
mapboxbounds.x1 -= 0.5f * chwidth;
mapboxbounds.y0 += 0.5f * chheight;
mapboxbounds.y1 -= 0.5f * chheight;
/* add space on the top for a title and a half line of padding */
mapboxbounds.y0 += 1.5f * chheight;
/* convert back to pixels */
mapboxwidth = (mapboxbounds.x1 - mapboxbounds.x0) * (float)targwidth;
mapboxheight = (mapboxbounds.y1 - mapboxbounds.y0) * (float)targheight;
/* determine the maximum integral scaling factor */
pixelscale = state->tilemap.zoom;
if (pixelscale == 0)
{
for (maxxscale = 1; mapwidth * (maxxscale + 1) < mapboxwidth; maxxscale++) ;
for (maxyscale = 1; mapheight * (maxyscale + 1) < mapboxheight; maxyscale++) ;
pixelscale = MIN(maxxscale, maxyscale);
}
/* recompute the final box size */
mapboxwidth = MIN(mapboxwidth, mapwidth * pixelscale);
mapboxheight = MIN(mapboxheight, mapheight * pixelscale);
/* recompute the bounds, centered within the existing bounds */
mapboxbounds.x0 += 0.5f * ((mapboxbounds.x1 - mapboxbounds.x0) - (float)mapboxwidth / (float)targwidth);
mapboxbounds.x1 = mapboxbounds.x0 + (float)mapboxwidth / (float)targwidth;
mapboxbounds.y0 += 0.5f * ((mapboxbounds.y1 - mapboxbounds.y0) - (float)mapboxheight / (float)targheight);
mapboxbounds.y1 = mapboxbounds.y0 + (float)mapboxheight / (float)targheight;
/* now recompute the outer box against this new info */
boxbounds.x0 = mapboxbounds.x0 - 0.5f * chwidth;
boxbounds.x1 = mapboxbounds.x1 + 0.5f * chwidth;
boxbounds.y0 = mapboxbounds.y0 - 2.0f * chheight;
boxbounds.y1 = mapboxbounds.y1 + 0.5f * chheight;
/* figure out the title and expand the outer box to fit */
sprintf(title, "TMAP %d/%d %dx%d OFFS %d,%d", state->tilemap.which, machine.tilemap().count() - 1, mapwidth, mapheight, state->tilemap.xoffs, state->tilemap.yoffs);
titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title);
if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
{
boxbounds.x0 = 0.5f - 0.5f * (titlewidth + chwidth);
boxbounds.x1 = boxbounds.x0 + titlewidth + chwidth;
}
/* go ahead and draw the outer box now */
ui_draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
/* draw the title */
x0 = 0.5f - 0.5f * titlewidth;
y0 = boxbounds.y0 + 0.5f * chheight;
for (x = 0; title[x] != 0; x++)
{
container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]);
x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]);
}
/* update the bitmap */
tilemap_update_bitmap(machine, state, mapboxwidth / pixelscale, mapboxheight / pixelscale);
/* add the final quad */
container->add_quad(mapboxbounds.x0, mapboxbounds.y0,
mapboxbounds.x1, mapboxbounds.y1,
ARGB_WHITE, state->texture,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state->tilemap.rotate));
//.........这里部分代码省略.........
示例11: ui_gfx_ui_handler
UINT32 ui_gfx_ui_handler(running_machine &machine, render_container *container, UINT32 uistate)
{
ui_gfx_state *state = &ui_gfx;
/* if we have nothing, implicitly cancel */
if (machine.total_colors() == 0 && machine.colortable == NULL && machine.gfx[0] == NULL && machine.tilemap().count() == 0)
goto cancel;
/* if we're not paused, mark the bitmap dirty */
if (!machine.paused())
state->bitmap_dirty = TRUE;
/* switch off the state to display something */
again:
switch (state->mode)
{
case 0:
/* if we have a palette, display it */
if (machine.total_colors() > 0)
{
palette_handler(machine, container, state);
break;
}
/* fall through...*/
state->mode++;
case 1:
/* if we have graphics sets, display them */
if (machine.gfx[0] != NULL)
{
gfxset_handler(machine, container, state);
break;
}
/* fall through...*/
state->mode++;
case 2:
/* if we have tilemaps, display them */
if (machine.tilemap().count() > 0)
{
tilemap_handler(machine, container, state);
break;
}
state->mode = 0;
goto again;
}
/* handle keys */
if (ui_input_pressed(machine, IPT_UI_SELECT))
{
state->mode = (state->mode + 1) % 3;
state->bitmap_dirty = TRUE;
}
if (ui_input_pressed(machine, IPT_UI_PAUSE))
{
if (machine.paused())
machine.resume();
else
machine.pause();
}
if (ui_input_pressed(machine, IPT_UI_CANCEL) || ui_input_pressed(machine, IPT_UI_SHOW_GFX))
goto cancel;
return uistate;
cancel:
if (!uistate)
machine.resume();
state->bitmap_dirty = TRUE;
return UI_HANDLER_CANCEL;
}
示例12: karnov_flipscreen_w
void karnov_flipscreen_w( running_machine &machine, int data )
{
karnov_state *state = machine.driver_data<karnov_state>();
state->m_flipscreen = data;
machine.tilemap().set_flip_all(state->m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
}
示例13: tilemap_handle_keys
static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, int viswidth, int visheight)
{
// handle tilemap selection (open bracket,close bracket)
if (machine.ui_input().pressed(IPT_UI_PREV_GROUP) && state.tilemap.which > 0)
{ state.tilemap.which--; state.bitmap_dirty = true; }
if (machine.ui_input().pressed(IPT_UI_NEXT_GROUP) && state.tilemap.which < machine.tilemap().count() - 1)
{ state.tilemap.which++; state.bitmap_dirty = true; }
// cache some info in locals
tilemap_t *tilemap = machine.tilemap().find(state.tilemap.which);
uint32_t mapwidth = tilemap->width();
uint32_t mapheight = tilemap->height();
// handle zoom (minus,plus)
if (machine.ui_input().pressed(IPT_UI_ZOOM_OUT) && state.tilemap.zoom > 0)
{
state.tilemap.zoom--;
state.bitmap_dirty = true;
if (state.tilemap.zoom != 0)
machine.popmessage("Zoom = %d", state.tilemap.zoom);
else
machine.popmessage("Zoom Auto");
}
if (machine.ui_input().pressed(IPT_UI_ZOOM_IN) && state.tilemap.zoom < 8)
{
state.tilemap.zoom++;
state.bitmap_dirty = true;
machine.popmessage("Zoom = %d", state.tilemap.zoom);
}
// handle rotation (R)
if (machine.ui_input().pressed(IPT_UI_ROTATE))
{
state.tilemap.rotate = orientation_add(ROT90, state.tilemap.rotate);
state.bitmap_dirty = true;
}
// return to (0,0) (HOME)
if( machine.ui_input().pressed(IPT_UI_HOME))
{
state.tilemap.xoffs = 0;
state.tilemap.yoffs = 0;
state.bitmap_dirty = true;
}
// handle flags (category)
if (machine.ui_input().pressed(IPT_UI_PAGE_UP) && state.tilemap.flags != TILEMAP_DRAW_ALL_CATEGORIES)
{
if (state.tilemap.flags > 0)
{
state.tilemap.flags--;
machine.popmessage("Category = %d", state.tilemap.flags);
}
else
{
state.tilemap.flags = TILEMAP_DRAW_ALL_CATEGORIES;
machine.popmessage("Category All");
}
state.bitmap_dirty = true;
}
if (machine.ui_input().pressed(IPT_UI_PAGE_DOWN) && (state.tilemap.flags < TILEMAP_DRAW_CATEGORY_MASK || (state.tilemap.flags == TILEMAP_DRAW_ALL_CATEGORIES)))
{
if (state.tilemap.flags == TILEMAP_DRAW_ALL_CATEGORIES)
state.tilemap.flags = 0;
else
state.tilemap.flags++;
state.bitmap_dirty = true;
machine.popmessage("Category = %d", state.tilemap.flags);
}
// handle navigation (up,down,left,right), taking orientation into account
int step = 8; // this may be applied more than once if multiple directions are pressed
if (machine.input().code_pressed(KEYCODE_LSHIFT)) step = 1;
if (machine.input().code_pressed(KEYCODE_LCONTROL)) step = 64;
if (machine.ui_input().pressed_repeat(IPT_UI_UP, 4))
{
if (state.tilemap.rotate & ORIENTATION_SWAP_XY)
state.tilemap.xoffs -= (state.tilemap.rotate & ORIENTATION_FLIP_Y) ? -step : step;
else
state.tilemap.yoffs -= (state.tilemap.rotate & ORIENTATION_FLIP_Y) ? -step : step;
state.bitmap_dirty = true;
}
if (machine.ui_input().pressed_repeat(IPT_UI_DOWN, 4))
{
if (state.tilemap.rotate & ORIENTATION_SWAP_XY)
state.tilemap.xoffs += (state.tilemap.rotate & ORIENTATION_FLIP_Y) ? -step : step;
else
state.tilemap.yoffs += (state.tilemap.rotate & ORIENTATION_FLIP_Y) ? -step : step;
state.bitmap_dirty = true;
}
if (machine.ui_input().pressed_repeat(IPT_UI_LEFT, 6))
{
if (state.tilemap.rotate & ORIENTATION_SWAP_XY)
state.tilemap.yoffs -= (state.tilemap.rotate & ORIENTATION_FLIP_X) ? -step : step;
else
state.tilemap.xoffs -= (state.tilemap.rotate & ORIENTATION_FLIP_X) ? -step : step;
state.bitmap_dirty = true;
}
if (machine.ui_input().pressed_repeat(IPT_UI_RIGHT, 6))
{
//.........这里部分代码省略.........
示例14: ui_gfx_ui_handler
UINT32 ui_gfx_ui_handler(running_machine &machine, render_container *container, UINT32 uistate)
{
ui_gfx_state &state = ui_gfx;
// if we have nothing, implicitly cancel
if (!ui_gfx_is_relevant(machine))
goto cancel;
// if we're not paused, mark the bitmap dirty
if (!machine.paused())
state.bitmap_dirty = true;
// switch off the state to display something
again:
switch (state.mode)
{
case UI_GFX_PALETTE:
// if we have a palette, display it
if (state.palette.devcount > 0)
{
palette_handler(machine, container, state);
break;
}
// fall through...
state.mode++;
case UI_GFX_GFXSET:
// if we have graphics sets, display them
if (state.gfxset.devcount > 0)
{
gfxset_handler(machine, container, state);
break;
}
// fall through...
state.mode++;
case UI_GFX_TILEMAP:
// if we have tilemaps, display them
if (machine.tilemap().count() > 0)
{
tilemap_handler(machine, container, state);
break;
}
state.mode = UI_GFX_PALETTE;
goto again;
}
// handle keys
if (ui_input_pressed(machine, IPT_UI_SELECT))
{
state.mode = (state.mode + 1) % 3;
state.bitmap_dirty = true;
}
if (ui_input_pressed(machine, IPT_UI_PAUSE))
{
if (machine.paused())
machine.resume();
else
machine.pause();
}
if (ui_input_pressed(machine, IPT_UI_CANCEL) || ui_input_pressed(machine, IPT_UI_SHOW_GFX))
goto cancel;
return uistate;
cancel:
if (!uistate)
machine.resume();
state.bitmap_dirty = true;
return UI_HANDLER_CANCEL;
}
示例15: tilemap_handle_keys
static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, int viswidth, int visheight)
{
UINT32 mapwidth, mapheight;
int step;
// handle tilemap selection (open bracket,close bracket)
if (ui_input_pressed(machine, IPT_UI_PREV_GROUP) && state.tilemap.which > 0)
{ state.tilemap.which--; state.bitmap_dirty = true; }
if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP) && state.tilemap.which < machine.tilemap().count() - 1)
{ state.tilemap.which++; state.bitmap_dirty = true; }
// cache some info in locals
tilemap_t *tilemap = machine.tilemap().find(state.tilemap.which);
mapwidth = tilemap->width();
mapheight = tilemap->height();
// handle zoom (minus,plus)
if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT) && state.tilemap.zoom > 0)
{
state.tilemap.zoom--;
state.bitmap_dirty = true;
if (state.tilemap.zoom != 0)
machine.popmessage("Zoom = %d", state.tilemap.zoom);
else
machine.popmessage("Zoom Auto");
}
if (ui_input_pressed(machine, IPT_UI_ZOOM_IN) && state.tilemap.zoom < 8)
{
state.tilemap.zoom++;
state.bitmap_dirty = true;
machine.popmessage("Zoom = %d", state.tilemap.zoom);
}
// handle rotation (R)
if (ui_input_pressed(machine, IPT_UI_ROTATE))
{
state.tilemap.rotate = orientation_add(ROT90, state.tilemap.rotate);
state.bitmap_dirty = true;
}
// handle navigation (up,down,left,right)
step = 8;
if (machine.input().code_pressed(KEYCODE_LSHIFT)) step = 1;
if (machine.input().code_pressed(KEYCODE_LCONTROL)) step = 64;
if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
{ state.tilemap.yoffs -= step; state.bitmap_dirty = true; }
if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
{ state.tilemap.yoffs += step; state.bitmap_dirty = true; }
if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 6))
{ state.tilemap.xoffs -= step; state.bitmap_dirty = true; }
if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 6))
{ state.tilemap.xoffs += step; state.bitmap_dirty = true; }
// clamp within range
while (state.tilemap.xoffs < 0)
state.tilemap.xoffs += mapwidth;
while (state.tilemap.xoffs >= mapwidth)
state.tilemap.xoffs -= mapwidth;
while (state.tilemap.yoffs < 0)
state.tilemap.yoffs += mapheight;
while (state.tilemap.yoffs >= mapheight)
state.tilemap.yoffs -= mapheight;
}