Previous 199869 Revisions Next

r34102 Monday 29th December, 2014 at 19:21:57 UTC by Osso
snes_ppu_device: removed unneeded running_machine parameter were it wasn't needed and removed some machine().first_screen() calls (nw)
[src/emu/video]snes_ppu.c snes_ppu.h
[src/mame/machine]snes.c

trunk/src/emu/video/snes_ppu.c
r242613r242614
18101810 * the optimized averaging algorithm.
18111811 *********************************************/
18121812
1813void snes_ppu_device::refresh_scanline( running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline )
1813void snes_ppu_device::refresh_scanline( bitmap_rgb32 &bitmap, UINT16 curline )
18141814{
18151815   UINT16 ii;
18161816   int x;
r242613r242614
18181818   struct SNES_SCANLINE *scanline1, *scanline2;
18191819   UINT16 c;
18201820   UINT16 prev_colour = 0;
1821   int blurring = machine.root_device().ioport("OPTIONS")->read_safe(0) & 0x01;
1821   int blurring = machine().root_device().ioport("OPTIONS")->read_safe(0) & 0x01;
18221822
18231823   g_profiler.start(PROFILER_VIDEO);
18241824
r242613r242614
18661866      update_obsel();
18671867
18681868#if SNES_LAYER_DEBUG
1869      if (dbg_video(machine, curline))
1869      if (dbg_video(curline))
18701870      {
18711871         g_profiler.stop();
18721872         return;
r242613r242614
19781978static const UINT16 vram_fgr_shiftab[4] = { 0, 5, 6, 7 };
19791979
19801980// utility function - latches the H/V counters.  Used by IRQ, writes to WRIO, etc.
1981void snes_ppu_device::latch_counters( running_machine &machine )
1981void snes_ppu_device::latch_counters()
19821982{
1983   m_beam.current_horz = machine.first_screen()->hpos() / m_htmult;
1984   m_beam.latch_vert = machine.first_screen()->vpos();
1983   m_beam.current_horz = m_screen->hpos() / m_htmult;
1984   m_beam.latch_vert = m_screen->vpos();
19851985   m_beam.latch_horz = m_beam.current_horz;
19861986   m_stat78 |= 0x40;   // indicate we latched
19871987//  m_read_ophct = m_read_opvct = 0;    // clear read flags - 2009-08: I think we must clear these when STAT78 is read...
r242613r242614
19891989//  printf("latched @ H %d V %d\n", m_beam.latch_horz, m_beam.latch_vert);
19901990}
19911991
1992void snes_ppu_device::dynamic_res_change( running_machine &machine )
1992void snes_ppu_device::dynamic_res_change()
19931993{
1994   rectangle visarea = machine.first_screen()->visible_area();
1994   rectangle visarea = m_screen->visible_area();
19951995   attoseconds_t refresh;
19961996
19971997   visarea.min_x = visarea.min_y = 0;
r242613r242614
20082008   if ((m_stat78 & 0x10) == SNES_NTSC)
20092009   {
20102010      refresh = HZ_TO_ATTOSECONDS(DOTCLK_NTSC) * SNES_HTOTAL * SNES_VTOTAL_NTSC;
2011      machine.first_screen()->configure(SNES_HTOTAL * 2, SNES_VTOTAL_NTSC * m_interlace, visarea, refresh);
2011      m_screen->configure(SNES_HTOTAL * 2, SNES_VTOTAL_NTSC * m_interlace, visarea, refresh);
20122012   }
20132013   else
20142014   {
20152015      refresh = HZ_TO_ATTOSECONDS(DOTCLK_PAL) * SNES_HTOTAL * SNES_VTOTAL_PAL;
2016      machine.first_screen()->configure(SNES_HTOTAL * 2, SNES_VTOTAL_PAL * m_interlace, visarea, refresh);
2016      m_screen->configure(SNES_HTOTAL * 2, SNES_VTOTAL_PAL * m_interlace, visarea, refresh);
20172017   }
20182018}
20192019
r242613r242614
20332033 when interlace is active.
20342034*************************************************/
20352035
2036inline UINT32 snes_ppu_device::get_vram_address( running_machine &machine )
2036inline UINT32 snes_ppu_device::get_vram_address()
20372037{
20382038   UINT32 addr = m_vmadd;
20392039
r242613r242614
23082308            return m_ppu1_open_bus;
23092309         }
23102310      case SLHV:      /* Software latch for H/V counter */
2311         latch_counters(space.machine());
2311         latch_counters();
23122312         return m_openbus_cb(space, 0);       /* Return value is meaningless */
23132313
23142314      case ROAMDATA:  /* Read data from OAM (DR) */
r242613r242614
23232323         return m_ppu1_open_bus;
23242324      case RVMDATAL:  /* Read data from VRAM (low) */
23252325         {
2326            UINT32 addr = get_vram_address(space.machine());
2326            UINT32 addr = get_vram_address();
23272327            m_ppu1_open_bus = m_vram_read_buffer & 0xff;
23282328
23292329            if (!m_vram_fgr_high)
r242613r242614
23382338         }
23392339      case RVMDATAH:  /* Read data from VRAM (high) */
23402340         {
2341            UINT32 addr = get_vram_address(space.machine());
2341            UINT32 addr = get_vram_address();
23422342            m_ppu1_open_bus = (m_vram_read_buffer >> 8) & 0xff;
23432343
23442344            if (m_vram_fgr_high)
r242613r242614
24692469         return;
24702470      case BGMODE:    /* BG mode and character size settings */
24712471         m_mode = data & 0x07;
2472         dynamic_res_change(space.machine());
2472         dynamic_res_change();
24732473         m_bg3_priority_bit = BIT(data, 3);
24742474         m_layer[SNES_BG1].tile_size = BIT(data, 4);
24752475         m_layer[SNES_BG2].tile_size = BIT(data, 5);
r242613r242614
25712571         {
25722572            UINT32 addr;
25732573            m_vmadd = (m_vmadd & 0xff00) | (data << 0);
2574            addr = get_vram_address(space.machine());
2574            addr = get_vram_address();
25752575            m_vram_read_buffer = vram_read(space, addr);
25762576            m_vram_read_buffer |= (vram_read(space, addr + 1) << 8);
25772577         }
r242613r242614
25802580         {
25812581            UINT32 addr;
25822582            m_vmadd = (m_vmadd & 0x00ff) | (data << 8);
2583            addr = get_vram_address(space.machine());
2583            addr = get_vram_address();
25842584            m_vram_read_buffer = vram_read(space, addr);
25852585            m_vram_read_buffer |= (vram_read(space, addr + 1) << 8);
25862586         }
25872587         break;
25882588      case VMDATAL:   /* 2118: Data for VRAM write (low) */
25892589         {
2590            UINT32 addr = get_vram_address(space.machine());
2590            UINT32 addr = get_vram_address();
25912591            vram_write(space, addr, data);
25922592
25932593            if (!m_vram_fgr_high)
r242613r242614
25962596         return;
25972597      case VMDATAH:   /* 2119: Data for VRAM write (high) */
25982598         {
2599            UINT32 addr = get_vram_address(space.machine());
2599            UINT32 addr = get_vram_address();
26002600            vram_write(space, addr + 1, data);
26012601
26022602            if (m_vram_fgr_high)
r242613r242614
28002800         m_beam.last_visible_line = (data & 0x04) ? 240 : 225;
28012801         m_pseudo_hires = BIT(data, 3);
28022802         m_mode7.extbg = BIT(data, 6);
2803         dynamic_res_change(space.machine());
2803         dynamic_res_change();
28042804#ifdef SNES_DBG_REG_W
28052805         if ((data & 0x8) != (PPU_REG(SETINI) & 0x8))
28062806            osd_printf_debug("Pseudo 512 mode: %s\n", (data & 0x8) ? "on" : "off");
r242613r242614
28272827      popmessage MSG2;                          \
28282828   }
28292829
2830UINT8 snes_ppu_device::dbg_video( running_machine &machine, UINT16 curline )
2830UINT8 snes_ppu_device::dbg_video( UINT16 curline )
28312831{
28322832   int i;
2833   UINT8 toggles = machine.root_device().ioport("DEBUG1")->read_safe(0);
2833   UINT8 toggles = machine().root_device().ioport("DEBUG1")->read_safe(0);
28342834   m_debug_options.select_pri[SNES_BG1] = (toggles & 0x03);
28352835   m_debug_options.select_pri[SNES_BG2] = (toggles & 0x0c) >> 2;
28362836   m_debug_options.select_pri[SNES_BG3] = (toggles & 0x30) >> 4;
28372837   m_debug_options.select_pri[SNES_BG4] = (toggles & 0xc0) >> 6;
28382838
2839   toggles = machine.root_device().ioport("DEBUG2")->read_safe(0);
2839   toggles = machine().root_device().ioport("DEBUG2")->read_safe(0);
28402840   for (i = 0; i < 4; i++)
28412841      DEBUG_TOGGLE(i, m_debug_options.bg_disabled[i], ("Debug: Disabled BG%d.\n", i + 1), ("Debug: Enabled BG%d.\n", i + 1))
28422842   DEBUG_TOGGLE(4, m_debug_options.bg_disabled[SNES_OAM], ("Debug: Disabled OAM.\n"), ("Debug: Enabled OAM.\n"))
r242613r242614
28442844   DEBUG_TOGGLE(6, m_debug_options.colormath_disabled, ("Debug: Disabled Color Math.\n"), ("Debug: Enabled Color Math.\n"))
28452845   DEBUG_TOGGLE(7, m_debug_options.windows_disabled, ("Debug: Disabled Window Masks.\n"), ("Debug: Enabled Window Masks.\n"))
28462846
2847   toggles = machine.root_device().ioport("DEBUG4")->read_safe(0);
2847   toggles = machine().root_device().ioport("DEBUG4")->read_safe(0);
28482848   for (i = 0; i < 8; i++)
28492849      DEBUG_TOGGLE(i, m_debug_options.mode_disabled[i], ("Debug: Disabled Mode %d drawing.\n", i), ("Debug: Enabled Mode %d drawing.\n", i))
28502850
2851   toggles = machine.root_device().ioport("DEBUG3")->read_safe(0);
2851   toggles = machine().root_device().ioport("DEBUG3")->read_safe(0);
28522852   DEBUG_TOGGLE(2, m_debug_options.mosaic_disabled, ("Debug: Disabled Mosaic.\n"), ("Debug: Enabled Mosaic.\n"))
28532853   m_debug_options.sprite_reversed = BIT(toggles, 7);
28542854   m_debug_options.select_pri[SNES_OAM] = (toggles & 0x70) >> 4;
trunk/src/emu/video/snes_ppu.h
r242613r242614
248248   void update_windowmasks(void);
249249   void update_offsets(void);
250250   inline void draw_blend(UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens);
251   void refresh_scanline(running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline);
251   void refresh_scanline(bitmap_rgb32 &bitmap, UINT16 curline);
252252
253   void latch_counters(running_machine &machine);
254   void dynamic_res_change(running_machine &machine);
255   inline UINT32 get_vram_address(running_machine &machine);
256   UINT8 dbg_video(running_machine &machine, UINT16 curline);
253   void latch_counters();
254   void dynamic_res_change();
255   inline UINT32 get_vram_address();
256   UINT8 dbg_video(UINT16 curline);
257257
258258   UINT8 read(address_space &space, UINT32 offset, UINT8 wrio_bit7);
259259   void write(address_space &space, UINT32 offset, UINT8 data);
trunk/src/mame/machine/snes.c
r242613r242614
3232{
3333   /* NTSC SNES draw range is 1-225. */
3434   for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
35      m_ppu->refresh_scanline(machine(), bitmap, y + 1);
35      m_ppu->refresh_scanline(bitmap, y + 1);
3636
3737   return 0;
3838}
r242613r242614
8787{
8888   // latch the counters and pull IRQ
8989   // (don't need to switch to the 65816 context, we don't do anything dependant on it)
90   m_ppu->latch_counters(machine());
90   m_ppu->latch_counters();
9191   SNES_CPU_REG(TIMEUP) = 0x80;    /* Indicate that irq occurred */
9292   m_maincpu->set_input_line(G65816_LINE_IRQ, ASSERT_LINE);
9393
r242613r242614
142142      {
143143         SNES_CPU_REG(TIMEUP) = 0x80;    /* Indicate that irq occurred */
144144         // IRQ latches the counters, do it now
145         m_ppu->latch_counters(machine());
145         m_ppu->latch_counters();
146146         m_maincpu->set_input_line(G65816_LINE_IRQ, ASSERT_LINE );
147147      }
148148   }
r242613r242614
539539         if (!(SNES_CPU_REG(WRIO) & 0x80) && (data & 0x80))
540540         {
541541            // external latch
542            m_ppu->latch_counters(space.machine());
542            m_ppu->latch_counters();
543543         }
544544         SNES_CPU_REG(WRIO) = data;
545545         return;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team