1 // license:BSD-3-Clause
2 // copyright-holders:Brad Oliver,Fabio Priuli
3 /***************************************************************************
4
5 video/nes.c
6
7 Routines to control the unique NES video hardware/PPU.
8
9 ***************************************************************************/
10
11 #include "emu.h"
12 #include "includes/nes.h"
13
video_reset()14 void nes_state::video_reset()
15 {
16 m_ppu->set_vidaccess_callback(*this, FUNC(nes_state::nes_ppu_vidaccess));
17 }
18
video_start()19 void nes_state::video_start()
20 {
21 m_last_frame_flip = 0;
22 }
23
24
25 /***************************************************************************
26
27 Display refresh
28
29 ***************************************************************************/
30
screen_update_nes(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)31 uint32_t nes_state::screen_update_nes(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
32 {
33 // render the ppu
34 m_ppu->render(bitmap, 0, 0, 0, 0, cliprect);
35 return 0;
36 }
37
screen_vblank_nes(int state)38 void nes_state::screen_vblank_nes(int state)
39 {
40 // on rising edge
41 if (!state)
42 {
43 // if this is a disk system game, check for the flip-disk key
44 if ((m_cartslot && m_cartslot->exists() && (m_cartslot->get_pcb_id() == STD_DISKSYS)) // first scenario = disksys in m_cartslot (= famicom)
45 || m_disk) // second scenario = disk via fixed internal disk option (fds & famitwin)
46 {
47 if (m_io_disksel)
48 {
49 // latch this input so it doesn't go at warp speed
50 if ((m_io_disksel->read() & 0x01) && (!m_last_frame_flip))
51 {
52 if (m_disk)
53 m_disk->disk_flip_side();
54 else
55 m_cartslot->disk_flip_side();
56 m_last_frame_flip = 1;
57 }
58
59 if (!(m_io_disksel->read() & 0x01))
60 m_last_frame_flip = 0;
61 }
62 }
63 }
64 }
65