void galaxian_draw_background(bitmap_rgb32 bitmap, rectangle cliprect) { /* erase the background to black first */ bitmap.fill(rgb_t.black(), cliprect); galaxian_draw_stars(bitmap, cliprect, 256); }
/************************************* * * Background rendering * *************************************/ void draw_background(bitmap_rgb32 bitmap, rectangle cliprect, int xpos, int ypos, int image) { rectangle rect; rectangle visarea = m_screen.op0.visible_area(); var paldata = m_bg_palette.op0.pens(); if (flip_screen() != 0) { xpos = 264 - xpos; ypos = 264 - ypos - BGHEIGHT; } xpos += 124; /* this may not be correct */ ypos += 16; m_bg_gfxdecode.op0.gfx(image).transpen(bitmap, cliprect, 0, 0, (int)flip_screen(), (int)flip_screen(), xpos, ypos, 0); m_bg_gfxdecode.op0.gfx(image).transpen(bitmap, cliprect, 0, 0, (int)flip_screen(), (int)flip_screen(), xpos - 256, ypos, 0); // create a solid fill below the 64 pixel high bg images if (m_do_bg_fills) { rect.min_x = visarea.min_x; rect.max_x = visarea.max_x; if (flip_screen() != 0) { rect.min_y = ypos - BGHEIGHT; rect.max_y = ypos - 1; } else { rect.min_y = ypos + BGHEIGHT; rect.max_y = ypos + 2 * BGHEIGHT - 1; } bitmap.fill(paldata[m_bg_gfxdecode.op0.gfx(image).colorbase() + 3], rect); } }
void background_draw_colorsplit(bitmap_rgb32 bitmap, rectangle cliprect, rgb_t color, int split, int split_flipped) { /* horizontal bgcolor split */ if (m_flipscreen_x != 0) { rectangle draw = cliprect; draw.max_x = std.min(draw.max_x, split_flipped * m_x_scale - 1); if (draw.min_x <= draw.max_x) { bitmap.fill(rgb_t.black(), draw); } draw = cliprect; draw.min_x = std.max(draw.min_x, split_flipped * m_x_scale); if (draw.min_x <= draw.max_x) { bitmap.fill(color, draw); } } else { rectangle draw = cliprect; draw.max_x = std.min(draw.max_x, split * m_x_scale - 1); if (draw.min_x <= draw.max_x) { bitmap.fill(color, draw); } draw = cliprect; draw.min_x = std.max(draw.min_x, split * m_x_scale); if (draw.min_x <= draw.max_x) { bitmap.fill(rgb_t.black(), draw); } } }
/************************************* * * Background rendering * *************************************/ void galaxian_draw_background(bitmap_rgb32 bitmap, rectangle cliprect) { /* erase the background to black first */ bitmap.fill(rgb_t.black(), cliprect); /* update the star origin to the current frame */ stars_update_origin(); /* render stars if enabled */ if (m_stars_enabled != 0) { int y; /* iterate over scanlines */ for (y = cliprect.min_y; y <= cliprect.max_y; y++) { UInt32 star_offs = m_star_rng_origin + (UInt32)y * 512; stars_draw_row(bitmap, 256, y, star_offs, 0xff); } } }
/************************************* * * Video render * *************************************/ u32 screen_update_m52(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect) { int offs; var paldata = m_sp_palette.op0.pens(); bitmap.fill(paldata[0], cliprect); if (!((m_bgcontrol & 0x20) != 0)) { if (!((m_bgcontrol & 0x10) != 0)) { draw_background(bitmap, cliprect, m_bg2xpos, m_bg2ypos, 0); /* distant mountains */ } // only one of these be drawn at once (they share the same scroll register) (alpha1v leaves everything enabled) if (!((m_bgcontrol & 0x02) != 0)) { draw_background(bitmap, cliprect, m_bg1xpos, m_bg1ypos, 1); /* hills */ } else if (!((m_bgcontrol & 0x04) != 0)) { draw_background(bitmap, cliprect, m_bg1xpos, m_bg1ypos, 2); /* cityscape */ } } m_tx_tilemap.set_flip((flip_screen() != 0) ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); m_tx_tilemap.draw(screen, bitmap, cliprect, 0, 0); /* draw the sprites */ for (offs = 0x3c; offs <= m_spritelimit; offs += 0x40) { draw_sprites(bitmap, cliprect, offs); } return(0); }
protected virtual uint32_t screen_update(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect) { //printf("%f %f\n", m_state.m_fragments[0].y, m_state.m_fragments[m_state.m_fragments.size()-1].y); bool force_vector = screen.screen_type() == SCREEN_TYPE_VECTOR || (m_vector.op0.read() & 1) != 0; bool debug_timing = (m_enable.op0.read() & 2) == 2; bool test_pat = (m_enable.op0.read() & 4) == 4; rgb_t backcol = debug_timing ? new rgb_t(0xff, 0xff, 0x00, 0x00) : new rgb_t(0xff, 0x00, 0x00, 0x00); if (!force_vector) { screen.set_video_attributes(0); bitmap.fill(backcol); foreach (var f in m_state.m_fragments) { if (f.y < bitmap.height()) { bitmap.plot_box((int32_t)f.x, (int32_t)f.y, (int32_t)(f.xr - f.x), 1, f.col); } } if (test_pat) { draw_testpat(screen, bitmap, cliprect); } } else { screen.set_video_attributes(VIDEO_SELF_RENDER); uint32_t flags = PRIMFLAG_ANTIALIAS(1) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD) | (screen.screen_type() == SCREEN_TYPE_VECTOR ? PRIMFLAG_VECTOR(1) : 0); rectangle visarea = screen.visible_area(); float xscale = 1.0f / (float)visarea.width(); float yscale = 1.0f / (float)visarea.height(); float xoffs = (float)visarea.min_x; float yoffs = (float)visarea.min_y; screen.container().empty(); screen.container().add_rect(0.0f, 0.0f, 1.0f, 1.0f, new rgb_t(0xff, 0x00, 0x00, 0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | (screen.screen_type() == SCREEN_TYPE_VECTOR ? PRIMFLAG_VECTORBUF(1) : 0)); float last_y = -1e6f; foreach (var f in m_state.m_fragments) { float x0 = (f.x - xoffs) * xscale; float y0 = (f.y - yoffs) * yscale; float x1 = (f.xr - xoffs) * xscale; rgb_t col = (debug_timing && f.y < last_y) ? backcol : new rgb_t(f.col); // FIXME: Debug check for proper vsync timing #if false auto w = m_scanline_height * xscale * 0.5; screen.container().add_line( x0 + w, y0, x1 - w, y0, m_scanline_height * yscale, nom_col(f.col), // (0xff << 24) | (f.col & 0xffffff), flags); #elif true float y1 = (f.y + m_scanline_height - yoffs) * yscale; screen.container().add_rect( x0, y0, x1, y1, new rgb_t(nom_col(col)), // (0xaf << 24) | (f.col & 0xffffff), flags); #else const float y1((f.y + m_scanline_height - yoffs) *yscale); // Crashes with bgfx screen.container().add_quad( x0, y0, x1, y1, rgb_t(nom_col(f.col)), // (0xaf << 24) | (f.col & 0xffffff), m_texture, flags); #endif last_y = f.y; } } m_state.m_fragments.clear(); return(0); }