UINT32 segaorun_state::screen_update_shangon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { // start the sprites drawing m_sprites->draw_async(cliprect); // reset priorities machine().priority_bitmap.fill(0, cliprect); // draw the low priority road layer segaic16_road_draw(0, bitmap, cliprect, SEGAIC16_ROAD_BACKGROUND); // draw background segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 0, 0x01); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 1, 0x02); // draw foreground segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 0, 0x02); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 1, 0x04); // draw the high priority road segaic16_road_draw(0, bitmap, cliprect, SEGAIC16_ROAD_FOREGROUND); // text layer // note that we inflate the priority of the text layer to prevent sprites // from drawing over the high scores segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 0, 0x08); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 1, 0x08); // mix in sprites bitmap_ind16 &sprites = m_sprites->bitmap(); for (const sparse_dirty_rect *rect = m_sprites->first_dirty_rect(cliprect); rect != NULL; rect = rect->next()) for (int y = rect->min_y; y <= rect->max_y; y++) { UINT16 *dest = &bitmap.pix(y); UINT16 *src = &sprites.pix(y); UINT8 *pri = &machine().priority_bitmap.pix(y); for (int x = rect->min_x; x <= rect->max_x; x++) { // only process written pixels UINT16 pix = src[x]; if (pix != 0xffff) { // compare sprite priority against tilemap priority int priority = (pix >> 10) & 3; if ((1 << priority) > pri[x]) { // if the color is set to maximum, shadow pixels underneath us if ((pix & 0x03f0) == 0x03f0) dest[x] += (m_paletteram[dest[x]] & 0x8000) ? m_palette_entries*2 : m_palette_entries; // otherwise, just add in sprite palette base else dest[x] = 0x400 | (pix & 0x3ff); } } } }
UINT32 segaxbd_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { // if no drawing is happening, fill with black and get out if (!segaic16_display_enable) { bitmap.fill(get_black_pen(machine()), cliprect); return 0; } // reset priorities machine().priority_bitmap.fill(0, cliprect); // draw the low priority road layer segaic16_road_draw(0, bitmap, cliprect, SEGAIC16_ROAD_BACKGROUND); if (m_road_priority == 0) segaic16_road_draw(0, bitmap, cliprect, SEGAIC16_ROAD_FOREGROUND); // draw background segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 0, 0x01); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 1, 0x02); // draw foreground segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 0, 0x02); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 1, 0x04); // draw the high priority road if (m_road_priority == 1) segaic16_road_draw(0, bitmap, cliprect, SEGAIC16_ROAD_FOREGROUND); // text layer segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 0, 0x04); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 1, 0x08); // draw the sprites segaic16_sprites_draw(screen, bitmap, cliprect, 0); return 0; }
UINT32 segas18_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { /* Current understanding of VDP mixing: mixing = 0x00: astorm: layer = 0, pri = 0x00 or 0x01 lghost: layer = 0, pri = 0x00 or 0x01 mixing = 0x01: ddcrew: layer = 0, pri = 0x00 or 0x01 or 0x02 mixing = 0x02: never seen mixing = 0x03: ddcrew: layer = 1, pri = 0x00 or 0x01 or 0x02 mixing = 0x04: astorm: layer = 2 or 3, pri = 0x00 or 0x01 or 0x02 mwalk: layer = 2 or 3, pri = 0x00 or 0x01 or 0x02 mixing = 0x05: ddcrew: layer = 2, pri = 0x04 wwally: layer = 2, pri = 0x04 mixing = 0x06: never seen mixing = 0x07: cltchitr: layer = 1 or 2 or 3, pri = 0x02 or 0x04 or 0x08 mwalk: layer = 3, pri = 0x04 or 0x08 */ int vdplayer = (m_vdp_mixing >> 1) & 3; int vdppri = (m_vdp_mixing & 1) ? (1 << vdplayer) : 0; #if DEBUG_VDP if (machine().input().code_pressed(KEYCODE_Q)) vdplayer = 0; if (machine().input().code_pressed(KEYCODE_W)) vdplayer = 1; if (machine().input().code_pressed(KEYCODE_E)) vdplayer = 2; if (machine().input().code_pressed(KEYCODE_R)) vdplayer = 3; if (machine().input().code_pressed(KEYCODE_A)) vdppri = 0x00; if (machine().input().code_pressed(KEYCODE_S)) vdppri = 0x01; if (machine().input().code_pressed(KEYCODE_D)) vdppri = 0x02; if (machine().input().code_pressed(KEYCODE_F)) vdppri = 0x04; if (machine().input().code_pressed(KEYCODE_G)) vdppri = 0x08; #endif // if no drawing is happening, fill with black and get out if (!segaic16_display_enable) { bitmap.fill(get_black_pen(machine()), cliprect); return 0; } // start the sprites drawing m_sprites->draw_async(cliprect); // reset priorities machine().priority_bitmap.fill(0, cliprect); // draw background opaquely first, not setting any priorities segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 0 | TILEMAP_DRAW_OPAQUE, 0x00); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 1 | TILEMAP_DRAW_OPAQUE, 0x00); if (m_vdp_enable && vdplayer == 0) draw_vdp(screen, bitmap, cliprect, vdppri); // draw background again to draw non-transparent pixels over the VDP and set the priority segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 0, 0x01); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 1, 0x02); if (m_vdp_enable && vdplayer == 1) draw_vdp(screen, bitmap, cliprect, vdppri); // draw foreground segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 0, 0x02); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 1, 0x04); if (m_vdp_enable && vdplayer == 2) draw_vdp(screen, bitmap, cliprect, vdppri); // text layer segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 0, 0x04); segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 1, 0x08); if (m_vdp_enable && vdplayer == 3) draw_vdp(screen, bitmap, cliprect, vdppri); // mix in sprites bitmap_ind16 &sprites = m_sprites->bitmap(); for (const sparse_dirty_rect *rect = m_sprites->first_dirty_rect(cliprect); rect != NULL; rect = rect->next()) for (int y = rect->min_y; y <= rect->max_y; y++) { UINT16 *dest = &bitmap.pix(y); UINT16 *src = &sprites.pix(y); UINT8 *pri = &machine().priority_bitmap.pix(y); for (int x = rect->min_x; x <= rect->max_x; x++) { // only process written pixels UINT16 pix = src[x]; if (pix != 0xffff) { // compare sprite priority against tilemap priority int priority = (pix >> 10) & 3; if ((1 << priority) > pri[x]) { // if the color is set to maximum, shadow pixels underneath us if ((pix & 0x03f0) == 0x03f0) dest[x] += (m_paletteram[dest[x]] & 0x8000) ? m_palette_entries*2 : m_palette_entries; // otherwise, just add in sprite palette base else dest[x] = 0x400 | (pix & 0x3ff); } } } }