//------------------------------------------------- // interface_post_reset - work to be done after a // device is reset //------------------------------------------------- public override void interface_post_reset() { // reset the interrupt vectors and queues for (int line = 0; line < m_input.Length; line++) { m_input[line].reset(); } // reconfingure VBLANK interrupts if (!string.IsNullOrEmpty(m_vblank_interrupt_screen)) { // get the screen that will trigger the VBLANK screen_device screen = device().siblingdevice <screen_device>(m_vblank_interrupt_screen); //assert(screen != NULL); screen.register_vblank_callback(on_vblank); } // reconfigure periodic interrupts if (m_timed_interrupt_period != attotime.zero) { attotime timedint_period = m_timed_interrupt_period; //assert(m_timedint_timer != NULL); m_timedint_timer.adjust(timedint_period, 0, timedint_period); } }
public uint32_t screen_update(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); draw_sprites(bitmap, cliprect); m_fg_tilemap.draw(screen, bitmap, cliprect, 0, 0); return(0); }
//------------------------------------------------- // interface_post_reset - work to be done after a // device is reset //------------------------------------------------- public override void interface_post_reset() { // reset the interrupt vectors and queues foreach (var elem in m_input) { elem.reset(); } // reconfingure VBLANK interrupts if (!string.IsNullOrEmpty(m_vblank_interrupt_screen)) { // get the screen that will trigger the VBLANK screen_device screen = device().siblingdevice <screen_device>(m_vblank_interrupt_screen); //throw new emu_unimplemented(); #if false assert(screen != nullptr); #endif screen.register_vblank_callback(on_vblank); } // reconfigure periodic interrupts if (m_timed_interrupt_period != attotime.zero) { attotime timedint_period = m_timed_interrupt_period; //throw new emu_unimplemented(); #if false assert(m_timedint_timer != nullptr); #endif m_timedint_timer.adjust(timedint_period, 0, timedint_period); } }
uint32_t screen_update_dkong(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { machine().tilemap().set_flip_all(m_flip != 0 ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); switch (m_hardware_type) { case HARDWARE_TKG02: case HARDWARE_TKG04: check_palette(); m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); draw_sprites(bitmap, cliprect, 0x40, 1); break; case HARDWARE_TRS01: case HARDWARE_TRS02: m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); draw_sprites(bitmap, cliprect, 0x40, 1); radarscp_draw_background(bitmap, cliprect); break; default: fatalerror("Invalid hardware type in dkong_video_update\n"); break; } return(0); }
/************************************* * * Video update * *************************************/ public u32 screen_update_centiped(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { ListBytesPointer spriteram = m_spriteram.target; //uint8_t *spriteram = m_spriteram; rectangle spriteclip = cliprect; int offs; /* draw the background */ m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); /* apply the sprite clip */ if (m_flipscreen != 0) { spriteclip.min_x += 8; } else { spriteclip.max_x -= 8; } /* draw the sprites */ for (offs = 0; offs < 0x10; offs++) { int code = ((spriteram[offs] & 0x3e) >> 1) | ((spriteram[offs] & 0x01) << 6); int color = spriteram[offs + 0x30]; int flipx = (spriteram[offs] >> 6) & 1; int flipy = (spriteram[offs] >> 7) & 1; int x = spriteram[offs + 0x20]; int y = 240 - spriteram[offs + 0x10]; m_gfxdecode.target.digfx.gfx(1).transmask(bitmap, spriteclip, (UInt32)code, (UInt32)color, flipx, flipy, x, y, m_penmask[color & 0x3f]); } return(0); }
static void draw_testpat(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect) { // Test pattern Grey scale const int stripes = 255; //auto va(screen.visible_area()); var va = cliprect; for (int i = 0; i < stripes; i++) { int l = va.left() + (i * va.width() / stripes); int w = (va.left() + (i + 1) * va.width() / stripes) - l; int v = (255 * i) / stripes; bitmap.plot_box(l, va.top() + 20, w, va.height() / 2 - 20, new rgb_t(0xff, (uint8_t)v, (uint8_t)v, (uint8_t)v)); } { int l = va.left() + va.width() / 4; int w = va.width() / 4; int t = va.top() + va.height() / 2; int h = va.height() / 2; // 50% Test pattern for (int i = t; i < t + h; i += 2) { bitmap.plot_box(l, i, w, i, new rgb_t(0xff, 0xff, 0xff, 0xff)); bitmap.plot_box(l, i + 1, w, i + 1, new rgb_t(0xff, 0, 0, 0)); } l += va.width() / 4; bitmap.plot_box(l, t, w, h, new rgb_t(0xff, 0xc3, 0xc3, 0xc3)); // 195 } }
/************************************* * * Video update * *************************************/ u32 screen_update_centiped(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { rectangle spriteclip = cliprect; /* draw the background */ m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); /* apply the sprite clip */ if (m_flipscreen != 0) { spriteclip.min_x += 8; } else { spriteclip.max_x -= 8; } /* draw the sprites */ for (int offs = 0; offs < 0x10; offs++) { int code = ((m_spriteram[offs].op & 0x3e) >> 1) | ((m_spriteram[offs].op & 0x01) << 6); int color = m_spriteram[offs + 0x30].op; int flipx = (m_spriteram[offs].op >> 6) & 1; int flipy = (m_spriteram[offs].op >> 7) & 1; int x = m_spriteram[offs + 0x20].op; int y = 240 - m_spriteram[offs + 0x10].op; m_gfxdecode.op0.gfx(1).transmask(bitmap, spriteclip, (u32)code, (u32)color, flipx, flipy, x, y, m_penmask[color & 0x3f]); } return(0); }
public UInt32 screen_update_galaga(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { bitmap.fill(m_palette.target.palette_interface.black_pen(), cliprect); draw_stars(bitmap, cliprect); draw_sprites(bitmap, cliprect); m_fg_tilemap.draw(screen, bitmap, cliprect, 0, 0); return(0); }
screen_device m_screen; // pointer to the screen device // construction/destruction //------------------------------------------------- // device_video_interface - constructor //------------------------------------------------- public device_video_interface(machine_config mconfig, device_t device, bool screen_required = true) : base(device, "video") { m_screen_required = screen_required; m_screen_base = device; m_screen_tag = s_unconfigured_screen_tag; m_screen = null; }
u32 screen_update_galaga(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { bitmap.fill(m_palette.op0.black_pen(), cliprect); m_starfield.op0.draw_starfield(bitmap, cliprect, 0); draw_sprites(bitmap, cliprect); m_fg_tilemap.draw(screen, bitmap, cliprect); return(0); }
u32 screen_update_digdug(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); m_fg_tilemap.draw(screen, bitmap, cliprect, 0, 0); draw_sprites(bitmap, cliprect); return(0); }
/************************************* * * Main refresh * *************************************/ uint32_t screen_update_atarisy2(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { // start drawing m_mob.op0.draw_async(cliprect); // reset priorities bitmap_ind8 priority_bitmap = screen.priority(); priority_bitmap.fill(0, cliprect); // draw the playfield m_playfield_tilemap.op0.tilemap.draw(screen, bitmap, cliprect, 0, 0); m_playfield_tilemap.op0.tilemap.draw(screen, bitmap, cliprect, 1, 1); m_playfield_tilemap.op0.tilemap.draw(screen, bitmap, cliprect, 2, 2); m_playfield_tilemap.op0.tilemap.draw(screen, bitmap, cliprect, 3, 3); // draw and merge the MO bitmap_ind16 mobitmap = m_mob.op0.bitmap(); for (sparse_dirty_rect rect = m_mob.op0.first_dirty_rect(cliprect); rect != null; rect = rect.next()) { for (int y = rect.m_rect.top(); y <= rect.m_rect.bottom(); y++) { PointerU16 mo = mobitmap.pix(y); //uint16_t const *const mo = &mobitmap.pix(y); PointerU16 pf = bitmap.pix(y); //uint16_t *const pf = &bitmap.pix(y); PointerU8 pri = priority_bitmap.pix(y); //uint8_t const *const pri = &priority_bitmap.pix(y); for (int x = rect.m_rect.left(); x <= rect.m_rect.right(); x++) { if (mo[x] != 0xffff) { int mopriority = mo[x] >> atari_motion_objects_device.PRIORITY_SHIFT; // high priority PF? if (((mopriority + pri[x]) & 2) != 0) { // only gets priority if PF pen is less than 8 if ((pf[x] & 0x08) == 0) { pf[x] = (uint16_t)(mo[x] & atari_motion_objects_device.DATA_MASK); } } // low priority else { pf[x] = (uint16_t)(mo[x] & atari_motion_objects_device.DATA_MASK); } } } } } // add the alpha on top m_alpha_tilemap.op0.tilemap.draw(screen, bitmap, cliprect, 0, 0); return(0); }
// optional operation overrides public override void interface_config_complete() { // find the screen if explicitly configured if (m_screen_tag != null && std.strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0) { m_screen = m_screen_base.subdevice <screen_device>(m_screen_tag); } // device_config_complete may now do whatever it needs to with the screen }
public void ___empty(machine_config config) { // video hardware screen_device screen = SCREEN(config, "screen", SCREEN_TYPE_RASTER); screen.set_screen_update(screen_update); screen.set_size(640, 480); screen.set_visarea(0, 639, 0, 479); screen.set_refresh_hz(30); }
//------------------------------------------------- // get_screen_desc - returns the description for // a given screen //------------------------------------------------- protected string get_screen_desc(screen_device screen) { if (new screen_device_iterator(m_machine.root_device()).count() > 1) { return(string.Format("Screen '{0}'", screen.tag())); } else { return("Screen"); } }
//------------------------------------------------- // get_screen_desc - returns the description for // a given screen //------------------------------------------------- protected string get_screen_desc(screen_device screen) { if (new screen_device_enumerator(m_machine.root_device()).count() > 1) { return(string_format(__("Screen '{0}'"), screen.tag())); } else { return(__("Screen")); } }
//------------------------------------------------- // interface_pre_start - make sure all our input // devices are started //------------------------------------------------- public override void interface_pre_start() { // only look up screens if we haven't explicitly requested no screen if (!string.IsNullOrEmpty(m_screen_tag)) { if (std.strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0) { // find the screen device if explicitly configured m_screen = m_screen_base.subdevice <screen_device>(m_screen_tag); if (m_screen == null) { throw new emu_fatalerror("Screen '{0}' not found, explicitly set for device '{1}'", m_screen_tag, device().tag()); } } else { // otherwise, look for a single match screen_device_enumerator iter = new screen_device_enumerator(device().machine().root_device()); m_screen = iter.first(); if (iter.count() > 1) { throw new emu_fatalerror("No screen specified for device '{0}', but multiple screens found", device().tag()); } } } // fatal error if no screen is found if (m_screen == null && m_screen_required) { throw new emu_fatalerror("Device '{0}' requires a screen", device().tag()); } // if we have a screen and it's not started, wait for it if (m_screen != null && !m_screen.started()) { // avoid circular dependency if we are also a palette device device_palette_interface palintf; if (!device().interface_(out palintf)) { throw new device_missing_dependencies(); } // no other palette may be specified if (m_screen.has_palette() && palintf != m_screen.palette()) { throw new emu_fatalerror("Device '{0}' cannot control screen '{1}' with palette '{2}'", device().tag(), m_screen_tag, m_screen.palette().device().tag()); } } }
//------------------------------------------------- // watchdog_vblank - VBLANK state callback for // watchdog timers //------------------------------------------------- void watchdog_vblank(screen_device screen, bool vblank_state) { // VBLANK starting if (vblank_state && m_enabled) { // check the watchdog if (m_vblank_count != 0) { if (--m_counter == 0) { watchdog_fired(); } } } }
bool m_first_time; // indicates that the system is starting (scanline timers only) // construction/destruction //------------------------------------------------- // timer_device - constructor //------------------------------------------------- timer_device(machine_config mconfig, string tag, device_t owner, u32 clock) : base(mconfig, TIMER, tag, owner, clock) { m_type = timer_type.TIMER_TYPE_GENERIC; m_callback = null; m_ptr = null; m_start_delay = attotime.zero; m_period = attotime.zero; m_param = 0; m_screen_tag = null; m_screen = null; m_first_vpos = 0; m_increment = 0; m_timer = null; m_first_time = true; }
// callbacks //TIMER_CALLBACK_MEMBER(timed_trigger_callback); //static void static_timed_trigger_callback(running_machine &machine, void *ptr, int param); //------------------------------------------------- // on_vblank - calls any external callbacks // for this screen //------------------------------------------------- void on_vblank(screen_device screen, bool vblank_state) { // ignore VBLANK end if (!vblank_state) { return; } // generate the interrupt callback if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE | SUSPEND_REASON_CLOCK)) { if (m_vblank_interrupt != null) { m_vblank_interrupt(device()); } } }
string m_name = ""; // name of png file // construction/destruction //------------------------------------------------- // render_crosshair - constructor //------------------------------------------------- public render_crosshair(running_machine machine, int player) { m_machine = machine; m_player = player; m_used = false; m_mode = CROSSHAIR_VISIBILITY_OFF; m_visible = false; m_texture = null; m_x = 0.0f; m_y = 0.0f; m_last_x = 0.0f; m_last_y = 0.0f; m_time = 0; // for now, use the main screen m_screen = new screen_device_enumerator(machine.root_device()).first(); }
//------------------------------------------------- // device_start - perform device-specific // startup //------------------------------------------------- protected override void device_start() { // fetch the screen if (m_screen_tag != null) { m_screen = (screen_device)machine().device(m_screen_tag); //machine().device<screen_device>(m_screen_tag); } // allocate the timer m_timer = timer_alloc(); //throw new emu_unimplemented(); #if false m_callback.bind_relative_to(*owner()); #endif // register for save states save_item(m_first_time, "m_first_time"); }
// snapshot/movie helpers //------------------------------------------------- // create_snapshot_bitmap - creates a // bitmap containing the screenshot for the // given screen //------------------------------------------------- //typedef software_renderer<UINT32, 0,0,0, 16,8,0, false, true> snap_renderer_bilinear; //typedef software_renderer<UINT32, 0,0,0, 16,8,0, false, false> snap_renderer; void create_snapshot_bitmap(screen_device screen) { // select the appropriate view in our dummy target if (m_snap_native && screen != null) { screen_device_enumerator iter = new screen_device_enumerator(machine().root_device()); int view_index = iter.indexof(screen); assert(view_index != -1); m_snap_target.set_view((unsigned)view_index); } // get the minimum width/height and set it on the target and bitmap s32 width; s32 height; compute_snapshot_size(out width, out height); m_snap_target.set_bounds(width, height); if (width != m_snap_bitmap.width() || height != m_snap_bitmap.height()) { m_snap_bitmap.resize(width, height); } // render the screen there render_primitive_list primlist = m_snap_target.get_primitives(); primlist.acquire_lock(); if (machine().options().snap_bilinear()) { //typedef software_renderer<u32, 0,0,0, 16,8,0, false, true> snap_renderer_bilinear; //snap_renderer_bilinear::draw_primitives(primlist, &m_snap_bitmap.pix(0), width, height, m_snap_bitmap.rowpixels()); software_renderer <u32, int_const_0, int_const_0, int_const_0, int_const_16, int_const_8, int_const_0, bool_const_false, bool_const_true> .draw_primitives(primlist, m_snap_bitmap.pix(0), (u32)width, (u32)height, (u32)m_snap_bitmap.rowpixels()); } else { //typedef software_renderer<u32, 0,0,0, 16,8,0, false, false> snap_renderer; //snap_renderer::draw_primitives(primlist, &m_snap_bitmap.pix(0), width, height, m_snap_bitmap.rowpixels()); software_renderer <u32, int_const_0, int_const_0, int_const_0, int_const_16, int_const_8, int_const_0, bool_const_false, bool_const_false> .draw_primitives(primlist, m_snap_bitmap.pix(0), (u32)width, (u32)height, (u32)m_snap_bitmap.rowpixels()); } primlist.release_lock(); }
/************************************* * * Common video update * *************************************/ uint32_t screen_update_galaxian(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect) { /* draw the background layer (including stars) */ m_draw_background_ptr(bitmap, cliprect); /* draw the tilemap characters over top */ m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); /* render the sprites next. Some custom pcbs (eg. zigzag, fantastc) have more than one sprite generator (ideally, this should be rendered in parallel) */ for (int i = 0; i < m_numspritegens; i++) { sprites_draw(bitmap, cliprect, new Pointer <uint8_t>(m_spriteram.op, m_sprites_base + i * 0x20)); } /* if we have bullets to draw, render them following */ if (m_draw_bullet_ptr != null) { bullets_draw(bitmap, cliprect, new Pointer <uint8_t>(m_spriteram.op, m_bullets_base)); } return(0); }
/************************************* * * 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); }
public static u32 screen_update____empty(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { bitmap.fill(rgb_t.black(), cliprect); return(0); }
// snapshots //bool snap_native() const { return m_snap_native; } //render_target &snapshot_target() { return *m_snap_target; } //------------------------------------------------- // save_snapshot - save a snapshot to the given // file handle //------------------------------------------------- void save_snapshot(screen_device screen, emu_file file) { throw new emu_unimplemented(); }
public uint32_t screen_update(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect) { uint32_t flags = PRIMFLAG_ANTIALIAS(1) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD) | PRIMFLAG_VECTOR(1); rectangle visarea = screen.visible_area(); float xscale = 1.0f / (65536 * visarea.width()); float yscale = 1.0f / (65536 * visarea.height()); float xoffs = (float)visarea.min_x; float yoffs = (float)visarea.min_y; int curpointIdx = 0; //point *curpoint; int lastx = 0; int lasty = 0; curpointIdx = 0; //curpoint = m_vector_list.get(); var curpoint = m_vector_list; 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) | PRIMFLAG_VECTORBUF(1)); for (int i = 0; i < m_vector_index; i++) { render_bounds coords = new render_bounds(); float intensity = (float)curpoint[curpointIdx].intensity / 255.0f; //float intensity = (float)curpoint->intensity / 255.0f; float intensity_weight = normalized_sigmoid(intensity, vector_options.s_beam_intensity_weight); // check for static intensity float beam_width = m_min_intensity == m_max_intensity ? vector_options.s_beam_width_min : vector_options.s_beam_width_min + intensity_weight * (vector_options.s_beam_width_max - vector_options.s_beam_width_min); // normalize width beam_width *= 1.0f / (float)VECTOR_WIDTH_DENOM; // apply point scale for points if (lastx == curpoint[curpointIdx].x && lasty == curpoint[curpointIdx].y) //if (lastx == curpoint->x && lasty == curpoint->y) { beam_width *= vector_options.s_beam_dot_size; } coords.x0 = ((float)lastx - xoffs) * xscale; coords.y0 = ((float)lasty - yoffs) * yscale; coords.x1 = ((float)curpoint[curpointIdx].x - xoffs) * xscale; //coords.x1 = ((float)curpoint->x - xoffs) * xscale; coords.y1 = ((float)curpoint[curpointIdx].y - yoffs) * yscale; //coords.y1 = ((float)curpoint->y - yoffs) * yscale; if (curpoint[curpointIdx].intensity != 0) //if (curpoint->intensity != 0) { screen.container().add_line( coords.x0, coords.y0, coords.x1, coords.y1, beam_width, new rgb_t(((uint32_t)curpoint[curpointIdx].intensity << 24) | (curpoint[curpointIdx].col & 0xffffff)), //(curpoint->intensity << 24) | (curpoint->col & 0xffffff), flags); } lastx = curpoint[curpointIdx].x; //lastx = curpoint->x; lasty = curpoint[curpointIdx].y; //lasty = curpoint->y; curpointIdx++; //curpoint++; } return(0); }
/* draws crosshair(s) in a given screen, if necessary */ public void render(screen_device screen) { //throw new emu_unimplemented(); }
void animate(screen_device device, bool vblank_state) { //throw new emu_unimplemented(); }