Previous 199869 Revisions Next

r21561 Monday 4th March, 2013 at 10:52:11 UTC by Fabio Priuli
let's try to untangle a bit the knots between machine and PPU (part 3)... nw.
[src/mame/includes]snes.h
[src/mame/machine]snes.c
[src/mame/video]snes.c
[src/mess/drivers]snes.c

trunk/src/mame/machine/snes.c
r21560r21561
133133
134134   // latch the counters and pull IRQ
135135   // (don't need to switch to the 65816 context, we don't do anything dependant on it)
136   state->m_ppu.latch_counters(machine, snes_ram);
136   state->m_ppu.latch_counters(machine);
137137   snes_ram[TIMEUP] = 0x80;    /* Indicate that irq occurred */
138138   state->m_maincpu->set_input_line(G65816_LINE_IRQ, ASSERT_LINE);
139139
r21560r21561
189189      {
190190         snes_ram[TIMEUP] = 0x80;    /* Indicate that irq occurred */
191191         // IRQ latches the counters, do it now
192         m_ppu.latch_counters(machine(), snes_ram);
192         m_ppu.latch_counters(machine());
193193         m_maincpu->set_input_line(G65816_LINE_IRQ, ASSERT_LINE );
194194      }
195195   }
r21560r21561
251251   {   /* VBlank is over, time for a new frame */
252252      snes_ram[HVBJOY] &= 0x7f;       /* Clear vblank bit */
253253      snes_ram[RDNMI]  &= 0x7f;       /* Clear nmi occurred bit */
254      snes_ram[STAT78] ^= 0x80;       /* Toggle field flag */
255      m_ppu.m_stat77_flags &= 0x3f;  /* Clear Time Over and Range Over bits */
254      m_ppu.m_stat78 ^= 0x80;       /* Toggle field flag */
255      m_ppu.m_stat77 &= 0x3f;  /* Clear Time Over and Range Over bits */
256256
257257      m_maincpu->set_input_line(G65816_LINE_NMI, CLEAR_LINE );
258258   }
r21560r21561
292292
293293   /* kick off the start of scanline timer */
294294   nextscan = m_ppu.m_beam.current_vert + 1;
295   if (nextscan >= (((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC : SNES_VTOTAL_PAL))
295   if (nextscan >= (((m_ppu.m_stat78 & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC : SNES_VTOTAL_PAL))
296296   {
297297      nextscan = 0;
298298   }
r21560r21561
707707         if (!(snes_ram[WRIO] & 0x80) && (data & 0x80))
708708         {
709709            // external latch
710            state->m_ppu.latch_counters(space.machine(), snes_ram);
710            state->m_ppu.latch_counters(space.machine());
711711         }
712712         break;
713713      case HTIMEL:    /* H-Count timer settings (low)  */
r21560r21561
15741574   // SNES hcounter has a 0-339 range.  hblank starts at counter 260.
15751575   // clayfighter sets an HIRQ at 260, apparently it wants it to be before hdma kicks off, so we'll delay 2 pixels.
15761576   state->m_hblank_offset = 274;
1577   state->m_hblank_timer->adjust(machine.primary_screen->time_until_pos(((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC - 1 : SNES_VTOTAL_PAL - 1, state->m_hblank_offset));
1577   state->m_hblank_timer->adjust(machine.primary_screen->time_until_pos(((state->m_ppu.m_stat78 & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC - 1 : SNES_VTOTAL_PAL - 1, state->m_hblank_offset));
15781578}
15791579
15801580static void snes_init_ram( running_machine &machine )
r21560r21561
18021802
18031803   /* Set STAT78 to NTSC or PAL */
18041804   if (ATTOSECONDS_TO_HZ(machine.primary_screen->frame_period().attoseconds) >= 59.0f)
1805      snes_ram[STAT78] = SNES_NTSC;
1805      state->m_ppu.m_stat78 = SNES_NTSC;
18061806   else /* if (ATTOSECONDS_TO_HZ(machine.primary_screen->frame_period().attoseconds) == 50.0f) */
1807      snes_ram[STAT78] = SNES_PAL;
1807      state->m_ppu.m_stat78 = SNES_PAL;
18081808
18091809   // reset does this to these registers
18101810   snes_ram[NMITIMEN] = 0;
trunk/src/mame/includes/snes.h
r21560r21561
369369#define DSP_FIR_C7      0x7F
370370
371371/* (PPU) Video related */
372
373struct SNES_SCANLINE
374{
375   int enable, clip;
376   
377   UINT16 buffer[SNES_SCR_WIDTH];
378   UINT8  priority[SNES_SCR_WIDTH];
379   UINT8  layer[SNES_SCR_WIDTH];
380   UINT8  blend_exception[SNES_SCR_WIDTH];
381};
382
372383class snes_ppu_class  /* once all the regs are saved in this structure, it would be better to reorganize it a bit... */
373384{
374385public:
386   SNES_SCANLINE m_scanlines[2];
387   
375388   struct
376389   {
377390      /* clipmasks */
r21560r21561
473486   UINT8 m_screen_disabled;
474487   UINT8 m_pseudo_hires;
475488   UINT8 m_color_modes;
476   UINT8 m_stat77_flags;
489   UINT8 m_stat77;
490   UINT8 m_stat78;
477491
478492   UINT16                m_htmult;     /* in 512 wide, we run HTOTAL double and halve it on latching */
479493   UINT16                m_cgram_address;  /* CGRAM address */
r21560r21561
515529   inline void draw_blend(UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens);
516530   void refresh_scanline(running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline);
517531
518   void latch_counters(running_machine &machine, UINT8 *ram_ptr);
519   void dynamic_res_change(running_machine &machine, UINT8 *ram_ptr);
532   void latch_counters(running_machine &machine);
533   void dynamic_res_change(running_machine &machine);
520534   inline UINT32 get_vram_address(running_machine &machine);
521535   UINT8 dbg_video(running_machine &machine, UINT16 curline, UINT8 *ram_ptr);
522536
trunk/src/mame/video/snes.c
r21560r21561
109109   { (112*32), (112*32)+32, (112*32)+64, (112*32)+96, (112*32)+128, (112*32)+160, (112*32)+192, (112*32)+224 }
110110};
111111
112struct SCANLINE
113{
114   int enable, clip;
115112
116   UINT16 buffer[SNES_SCR_WIDTH];
117   UINT8  priority[SNES_SCR_WIDTH];
118   UINT8  layer[SNES_SCR_WIDTH];
119   UINT8  blend_exception[SNES_SCR_WIDTH];
120};
121
122static struct SCANLINE scanlines[2];
123//struct SNES_PPU_STRUCT snes_ppu;
124
125113enum
126114{
127115   SNES_COLOR_DEPTH_2BPP = 0,
r21560r21561
161149
162150inline void snes_ppu_class::set_scanline_pixel( int screen, INT16 x, UINT16 color, UINT8 priority, UINT8 layer, int blend )
163151{
164   scanlines[screen].buffer[x] = color;
165   scanlines[screen].priority[x] = priority;
166   scanlines[screen].layer[x] = layer;
167   scanlines[screen].blend_exception[x] = blend;
152   m_scanlines[screen].buffer[x] = color;
153   m_scanlines[screen].priority[x] = priority;
154   m_scanlines[screen].layer[x] = layer;
155   m_scanlines[screen].blend_exception[x] = blend;
168156}
169157
170158/*************************************************************************************************
r21560r21561
197185
198186   for (screen = SNES_MAINSCREEN; screen <= SNES_SUBSCREEN; screen++)
199187   {
200      if (ii >= 0 && ii < SNES_SCR_WIDTH && scanlines[screen].enable)
188      if (ii >= 0 && ii < SNES_SCR_WIDTH && m_scanlines[screen].enable)
201189      {
202         if (scanlines[screen].priority[ii] <= priority)
190         if (m_scanlines[screen].priority[ii] <= priority)
203191         {
204192            UINT8 clr = colour;
205193            UINT8 clipmask = m_clipmasks[layer][ii];
r21560r21561
210198#endif /* SNES_LAYER_DEBUG */
211199
212200            /* Clip to windows */
213            if (scanlines[screen].clip)
201            if (m_scanlines[screen].clip)
214202               clr &= clipmask;
215203
216204            /* Only draw if we have a colour (0 == transparent) */
r21560r21561
232220   for (screen = SNES_MAINSCREEN; screen <= SNES_SUBSCREEN; screen++)
233221   {
234222      // odd pixels to main screen, even pixels to sub screen
235      if (ii >= 0 && ii < (SNES_SCR_WIDTH << 1) && ((ii & 1) ^ screen) && scanlines[screen].enable)
223      if (ii >= 0 && ii < (SNES_SCR_WIDTH << 1) && ((ii & 1) ^ screen) && m_scanlines[screen].enable)
236224      {
237         if (scanlines[screen].priority[ii >> 1] <= priority)
225         if (m_scanlines[screen].priority[ii >> 1] <= priority)
238226         {
239227            UINT8 clr = colour;
240228            UINT8 clipmask = m_clipmasks[layer][ii >> 1];
r21560r21561
245233#endif /* SNES_LAYER_DEBUG */
246234
247235            /* Clip to windows */
248            if (scanlines[screen].clip)
236            if (m_scanlines[screen].clip)
249237               clr &= clipmask;
250238
251239            /* Only draw if we have a colour (0 == transparent) */
r21560r21561
268256
269257   for (screen = SNES_MAINSCREEN; screen <= SNES_SUBSCREEN; screen++)
270258   {
271      if (pos >= 0 && pos < SNES_SCR_WIDTH && scanlines[screen].enable)
259      if (pos >= 0 && pos < SNES_SCR_WIDTH && m_scanlines[screen].enable)
272260      {
273261         UINT8 clr = colour;
274262         UINT8 clipmask = m_clipmasks[SNES_OAM][pos];
r21560r21561
279267#endif /* SNES_LAYER_DEBUG */
280268
281269         /* Clip to windows */
282         if (scanlines[screen].clip)
270         if (m_scanlines[screen].clip)
283271            clr &= clipmask;
284272
285273         /* Only draw if we have a colour (0 == transparent) */
r21560r21561
427415      return;
428416#endif /* SNES_LAYER_DEBUG */
429417
430   scanlines[SNES_MAINSCREEN].enable = m_layer[layer].main_bg_enabled;
431   scanlines[SNES_SUBSCREEN].enable = m_layer[layer].sub_bg_enabled;
432   scanlines[SNES_MAINSCREEN].clip = m_layer[layer].main_window_enabled;
433   scanlines[SNES_SUBSCREEN].clip = m_layer[layer].sub_window_enabled;
418   m_scanlines[SNES_MAINSCREEN].enable = m_layer[layer].main_bg_enabled;
419   m_scanlines[SNES_SUBSCREEN].enable = m_layer[layer].sub_bg_enabled;
420   m_scanlines[SNES_MAINSCREEN].clip = m_layer[layer].main_window_enabled;
421   m_scanlines[SNES_SUBSCREEN].clip = m_layer[layer].sub_window_enabled;
434422
435   if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable)
423   if (!m_scanlines[SNES_MAINSCREEN].enable && !m_scanlines[SNES_SUBSCREEN].enable)
436424      return;
437425
438426   /* Handle Mosaic effects */
r21560r21561
609597      return;
610598#endif /* SNES_LAYER_DEBUG */
611599
612   scanlines[SNES_MAINSCREEN].enable = m_layer[layer].main_bg_enabled;
613   scanlines[SNES_SUBSCREEN].enable = m_layer[layer].sub_bg_enabled;
614   scanlines[SNES_MAINSCREEN].clip = m_layer[layer].main_window_enabled;
615   scanlines[SNES_SUBSCREEN].clip = m_layer[layer].sub_window_enabled;
600   m_scanlines[SNES_MAINSCREEN].enable = m_layer[layer].main_bg_enabled;
601   m_scanlines[SNES_SUBSCREEN].enable = m_layer[layer].sub_bg_enabled;
602   m_scanlines[SNES_MAINSCREEN].clip = m_layer[layer].main_window_enabled;
603   m_scanlines[SNES_SUBSCREEN].clip = m_layer[layer].sub_window_enabled;
616604
617   if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable)
605   if (!m_scanlines[SNES_MAINSCREEN].enable && !m_scanlines[SNES_SUBSCREEN].enable)
618606      return;
619607
620608   ma = m_mode7.matrix_a;
r21560r21561
728716
729717      for (screen = SNES_MAINSCREEN; screen <= SNES_SUBSCREEN; screen++)
730718      {
731         if (scanlines[screen].enable)
719         if (m_scanlines[screen].enable)
732720         {
733721            UINT8 clr = colour;
734722            UINT8 clipmask = m_clipmasks[layer][xpos];
r21560r21561
739727#endif /* SNES_LAYER_DEBUG */
740728
741729            /* Clip to windows */
742            if (scanlines[screen].clip)
730            if (m_scanlines[screen].clip)
743731               clr &= clipmask;
744732
745733            /* Draw pixel if appropriate */
746            if (scanlines[screen].priority[xpos] <= priority && clr > 0)
734            if (m_scanlines[screen].priority[xpos] <= priority && clr > 0)
747735            {
748736               /* Direct select, but only outside EXTBG! */
749737               // Direct color format is: 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded.
r21560r21561
10491037
10501038   /* set Range Over flag if necessary */
10511039   if (range_over > 32)
1052      m_stat77_flags |= 0x40;
1040      m_stat77 |= 0x40;
10531041
10541042   /* set Time Over flag if necessary */
10551043   if (time_over > 34)
1056      m_stat77_flags |= 0x80;
1044      m_stat77 |= 0x80;
10571045}
10581046
10591047/*********************************************
r21560r21561
10731061      return;
10741062#endif /* SNES_LAYER_DEBUG */
10751063
1076   scanlines[SNES_MAINSCREEN].enable = m_layer[SNES_OAM].main_bg_enabled;
1077   scanlines[SNES_SUBSCREEN].enable = m_layer[SNES_OAM].sub_bg_enabled;
1078   scanlines[SNES_MAINSCREEN].clip = m_layer[SNES_OAM].main_window_enabled;
1079   scanlines[SNES_SUBSCREEN].clip = m_layer[SNES_OAM].sub_window_enabled;
1064   m_scanlines[SNES_MAINSCREEN].enable = m_layer[SNES_OAM].main_bg_enabled;
1065   m_scanlines[SNES_SUBSCREEN].enable = m_layer[SNES_OAM].sub_bg_enabled;
1066   m_scanlines[SNES_MAINSCREEN].clip = m_layer[SNES_OAM].main_window_enabled;
1067   m_scanlines[SNES_SUBSCREEN].clip = m_layer[SNES_OAM].sub_window_enabled;
10801068
1081   if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable)
1069   if (!m_scanlines[SNES_MAINSCREEN].enable && !m_scanlines[SNES_SUBSCREEN].enable)
10821070      return;
10831071
10841072   charaddr = m_layer[SNES_OAM].charmap << 13;
r21560r21561
13891377      (prevent_color_math == SNES_CLIP_OUT && m_clipmasks[SNES_COLOR][offset]))
13901378   {
13911379      UINT16 r, g, b;
1392      struct SCANLINE *subscreen;
1380      struct SNES_SCANLINE *subscreen;
13931381      int clip_max = 0;   // if add then clip to 0x1f, if sub then clip to 0
13941382
13951383#if SNES_LAYER_DEBUG
13961384      /* Toggle drawing of SNES_SUBSCREEN or SNES_MAINSCREEN */
13971385      if (debug_options.draw_subscreen)
13981386      {
1399         subscreen = switch_screens ? &scanlines[SNES_SUBSCREEN] : &scanlines[SNES_MAINSCREEN];
1387         subscreen = switch_screens ? &m_scanlines[SNES_SUBSCREEN] : &m_scanlines[SNES_MAINSCREEN];
14001388      }
14011389      else
14021390#endif /* SNES_LAYER_DEBUG */
14031391      {
1404         subscreen = switch_screens ? &scanlines[SNES_MAINSCREEN] : &scanlines[SNES_SUBSCREEN];
1392         subscreen = switch_screens ? &m_scanlines[SNES_MAINSCREEN] : &m_scanlines[SNES_SUBSCREEN];
14051393      }
14061394
14071395      if (m_sub_add_mode) /* SNES_SUBSCREEN*/
r21560r21561
14971485   UINT16 ii;
14981486   int x;
14991487   int fade;
1500   struct SCANLINE *scanline1, *scanline2;
1488   struct SNES_SCANLINE *scanline1, *scanline2;
15011489   UINT16 c;
15021490   UINT16 prev_colour = 0;
15031491   int blurring = machine.root_device().ioport("OPTIONS")->read_safe(0) & 0x01;
r21560r21561
15171505         update_offsets();
15181506
15191507      /* Clear priority */
1520      memset(scanlines[SNES_MAINSCREEN].priority, 0, SNES_SCR_WIDTH);
1521      memset(scanlines[SNES_SUBSCREEN].priority, 0, SNES_SCR_WIDTH);
1508      memset(m_scanlines[SNES_MAINSCREEN].priority, 0, SNES_SCR_WIDTH);
1509      memset(m_scanlines[SNES_SUBSCREEN].priority, 0, SNES_SCR_WIDTH);
15221510
15231511      /* Clear layers */
1524      memset(scanlines[SNES_MAINSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH);
1525      memset(scanlines[SNES_SUBSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH);
1512      memset(m_scanlines[SNES_MAINSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH);
1513      memset(m_scanlines[SNES_SUBSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH);
15261514
15271515      /* Clear blend_exception (only used for OAM) */
1528      memset(scanlines[SNES_MAINSCREEN].blend_exception, 0, SNES_SCR_WIDTH);
1529      memset(scanlines[SNES_SUBSCREEN].blend_exception, 0, SNES_SCR_WIDTH);
1516      memset(m_scanlines[SNES_MAINSCREEN].blend_exception, 0, SNES_SCR_WIDTH);
1517      memset(m_scanlines[SNES_SUBSCREEN].blend_exception, 0, SNES_SCR_WIDTH);
15301518
15311519      /* Draw back colour */
15321520      for (ii = 0; ii < SNES_SCR_WIDTH; ii++)
15331521      {
15341522         if (m_mode == 5 || m_mode == 6 || m_pseudo_hires)
1535            scanlines[SNES_SUBSCREEN].buffer[ii] = m_cgram[0];
1523            m_scanlines[SNES_SUBSCREEN].buffer[ii] = m_cgram[0];
15361524         else
1537            scanlines[SNES_SUBSCREEN].buffer[ii] = m_cgram[FIXED_COLOUR];
1525            m_scanlines[SNES_SUBSCREEN].buffer[ii] = m_cgram[FIXED_COLOUR];
15381526
1539         scanlines[SNES_MAINSCREEN].buffer[ii] = m_cgram[0];
1527         m_scanlines[SNES_MAINSCREEN].buffer[ii] = m_cgram[0];
15401528      }
15411529
15421530      /* Prepare OAM for this scanline */
r21560r21561
15571545      /* Toggle drawing of SNES_SUBSCREEN or SNES_MAINSCREEN */
15581546      if (debug_options.draw_subscreen)
15591547      {
1560         scanline1 = &scanlines[SNES_SUBSCREEN];
1561         scanline2 = &scanlines[SNES_MAINSCREEN];
1548         scanline1 = &m_scanlines[SNES_SUBSCREEN];
1549         scanline2 = &m_scanlines[SNES_MAINSCREEN];
15621550      }
15631551      else
15641552#endif /* SNES_LAYER_DEBUG */
15651553      {
1566         scanline1 = &scanlines[SNES_MAINSCREEN];
1567         scanline2 = &scanlines[SNES_SUBSCREEN];
1554         scanline1 = &m_scanlines[SNES_MAINSCREEN];
1555         scanline2 = &m_scanlines[SNES_SUBSCREEN];
15681556      }
15691557
15701558      /* Draw the scanline to screen */
r21560r21561
17781766   state_save_register_global(machine, m_screen_disabled);
17791767   state_save_register_global(machine, m_pseudo_hires);
17801768   state_save_register_global(machine, m_color_modes);
1781   state_save_register_global(machine, m_stat77_flags);
1769   state_save_register_global(machine, m_stat77);
1770   state_save_register_global(machine, m_stat78);
17821771
17831772   state_save_register_global(machine, m_htmult);
17841773   state_save_register_global(machine, m_cgram_address);
r21560r21561
18061795static const UINT16 vram_fgr_shiftab[4] = { 0, 5, 6, 7 };
18071796
18081797// utility function - latches the H/V counters.  Used by IRQ, writes to WRIO, etc.
1809void snes_ppu_class::latch_counters( running_machine &machine, UINT8 *ram_ptr )
1798void snes_ppu_class::latch_counters( running_machine &machine )
18101799{
18111800   m_beam.current_horz = machine.primary_screen->hpos() / m_htmult;
18121801   m_beam.latch_vert = machine.primary_screen->vpos();
18131802   m_beam.latch_horz = m_beam.current_horz;
1814   ram_ptr[STAT78] |= 0x40;   // indicate we latched
1803   m_stat78 |= 0x40;   // indicate we latched
18151804//  m_read_ophct = m_read_opvct = 0;    // clear read flags - 2009-08: I think we must clear these when STAT78 is read...
18161805
18171806//  printf("latched @ H %d V %d\n", m_beam.latch_horz, m_beam.latch_vert);
18181807}
18191808
1820void snes_ppu_class::dynamic_res_change( running_machine &machine, UINT8 *ram_ptr )
1809void snes_ppu_class::dynamic_res_change( running_machine &machine )
18211810{
18221811   rectangle visarea = machine.primary_screen->visible_area();
18231812   attoseconds_t refresh;
r21560r21561
18331822      m_htmult = 1;
18341823
18351824   /* FIXME: does the timing changes when the gfx mode is equal to 5 or 6? */
1836   if ((ram_ptr[STAT78] & 0x10) == SNES_NTSC)
1825   if ((m_stat78 & 0x10) == SNES_NTSC)
1826   {
18371827      refresh = HZ_TO_ATTOSECONDS(DOTCLK_NTSC) * SNES_HTOTAL * SNES_VTOTAL_NTSC;
1838   else
1839      refresh = HZ_TO_ATTOSECONDS(DOTCLK_PAL) * SNES_HTOTAL * SNES_VTOTAL_PAL;
1840
1841   if ((ram_ptr[STAT78] & 0x10) == SNES_NTSC)
18421828      machine.primary_screen->configure(SNES_HTOTAL * 2, SNES_VTOTAL_NTSC * m_interlace, visarea, refresh);
1829   }
18431830   else
1831   {
1832      refresh = HZ_TO_ATTOSECONDS(DOTCLK_PAL) * SNES_HTOTAL * SNES_VTOTAL_PAL;
18441833      machine.primary_screen->configure(SNES_HTOTAL * 2, SNES_VTOTAL_PAL * m_interlace, visarea, refresh);
1834   }
18451835}
18461836
18471837/*************************************************
r21560r21561
18851875   {
18861876      UINT16 v = space.machine().primary_screen->vpos();
18871877      UINT16 h = space.machine().primary_screen->hpos();
1888      UINT16 ls = (((snes_ram[STAT78] & 0x10) == SNES_NTSC ? 525 : 625) >> 1) - 1;
1878      UINT16 ls = (((m_stat78 & 0x10) == SNES_NTSC ? 525 : 625) >> 1) - 1;
18891879
18901880      if (m_interlace == 2)
18911881         ls++;
r21560r21561
21352125            return m_ppu1_open_bus;
21362126         }
21372127      case SLHV:      /* Software latch for H/V counter */
2138         latch_counters(space.machine(), ram_ptr);
2128         latch_counters(space.machine());
21392129         return snes_open_bus_r(space, 0);       /* Return value is meaningless */
21402130      case ROAMDATA:  /* Read data from OAM (DR) */
21412131         m_ppu1_open_bus = oam_read(space, m_oam.address);
r21560r21561
22132203         m_read_opvct ^= 1;
22142204         return m_ppu2_open_bus;
22152205      case STAT77:    /* PPU status flag and version number */
2216         value = m_stat77_flags & 0xc0; // 0x80 & 0x40 are Time Over / Range Over Sprite flags, set by the video code
2206         value = m_stat77 & 0xc0; // 0x80 & 0x40 are Time Over / Range Over Sprite flags, set by the video code
22172207         // 0x20 - Master/slave mode select. Little is known about this bit. We always seem to read back 0 here.
22182208         value |= (m_ppu1_open_bus & 0x10);
22192209         value |= (m_ppu1_version & 0x0f);
2220         m_stat77_flags = value;  // not sure if this is needed...
2210         m_stat77 = value;  // not sure if this is needed...
22212211         m_ppu1_open_bus = value;
22222212         return m_ppu1_open_bus;
22232213      case STAT78:    /* PPU status flag and version number */
22242214         m_read_ophct = 0;
22252215         m_read_opvct = 0;
22262216         if(ram_ptr[WRIO] & 0x80)
2227            ram_ptr[STAT78] &= ~0x40; //clear ext latch if bit 7 of WRIO is set
2228         ram_ptr[STAT78] = (ram_ptr[STAT78] & ~0x2f) | (m_ppu2_open_bus & 0x20) | (m_ppu2_version & 0x0f);
2229         m_ppu2_open_bus = ram_ptr[STAT78];
2217            m_stat78 &= ~0x40; //clear ext latch if bit 7 of WRIO is set
2218         m_stat78 = (m_stat78 & ~0x2f) | (m_ppu2_open_bus & 0x20) | (m_ppu2_version & 0x0f);
2219         m_ppu2_open_bus = m_stat78;
22302220         return m_ppu2_open_bus;
22312221   }
22322222
r21560r21561
22952285         return;
22962286      case BGMODE:    /* BG mode and character size settings */
22972287         m_mode = data & 0x07;
2298         dynamic_res_change(space.machine(), ram_ptr);
2288         dynamic_res_change(space.machine());
22992289         m_bg3_priority_bit = BIT(data, 3);
23002290         m_layer[SNES_BG1].tile_size = BIT(data, 4);
23012291         m_layer[SNES_BG2].tile_size = BIT(data, 5);
r21560r21561
24682458         m_cgram_address = (m_cgram_address + 1) % (SNES_CGRAM_SIZE - 2);
24692459         break;
24702460      case W12SEL:    /* Window mask settings for BG1-2 */
2471         if (data != ram_ptr[offset])
2461         if (data != ram_ptr[W12SEL])
24722462         {
24732463            m_layer[SNES_BG1].window1_invert  = BIT(data, 0);
24742464            m_layer[SNES_BG1].window1_enabled = BIT(data, 1);
r21560r21561
24822472         }
24832473         break;
24842474      case W34SEL:    /* Window mask settings for BG3-4 */
2485         if (data != ram_ptr[offset])
2475         if (data != ram_ptr[W34SEL])
24862476         {
24872477            m_layer[SNES_BG3].window1_invert  = BIT(data, 0);
24882478            m_layer[SNES_BG3].window1_enabled = BIT(data, 1);
r21560r21561
24962486         }
24972487         break;
24982488      case WOBJSEL:   /* Window mask settings for objects */
2499         if (data != ram_ptr[offset])
2489         if (data != ram_ptr[WOBJSEL])
25002490         {
25012491            m_layer[SNES_OAM].window1_invert  = BIT(data, 0);
25022492            m_layer[SNES_OAM].window1_enabled = BIT(data, 1);
r21560r21561
25102500         }
25112501         break;
25122502      case WH0:       /* Window 1 left position */
2513         if (data != ram_ptr[offset])
2503         if (data != ram_ptr[WH0])
25142504         {
25152505            m_window1_left = data;
25162506            m_update_windows = 1;
25172507         }
25182508         break;
25192509      case WH1:       /* Window 1 right position */
2520         if (data != ram_ptr[offset])
2510         if (data != ram_ptr[WH1])
25212511         {
25222512            m_window1_right = data;
25232513            m_update_windows = 1;
25242514         }
25252515         break;
25262516      case WH2:       /* Window 2 left position */
2527         if (data != ram_ptr[offset])
2517         if (data != ram_ptr[WH2])
25282518         {
25292519            m_window2_left = data;
25302520            m_update_windows = 1;
25312521         }
25322522         break;
25332523      case WH3:       /* Window 2 right position */
2534         if (data != ram_ptr[offset])
2524         if (data != ram_ptr[WH3])
25352525         {
25362526            m_window2_right = data;
25372527            m_update_windows = 1;
25382528         }
25392529         break;
25402530      case WBGLOG:    /* Window mask logic for BG's */
2541         if (data != ram_ptr[offset])
2531         if (data != ram_ptr[WBGLOG])
25422532         {
25432533            m_layer[SNES_BG1].wlog_mask = data & 0x03;
25442534            m_layer[SNES_BG2].wlog_mask = (data & 0x0c) >> 2;
r21560r21561
25482538         }
25492539         break;
25502540      case WOBJLOG:   /* Window mask logic for objects */
2551         if (data != ram_ptr[offset])
2541         if (data != ram_ptr[WOBJLOG])
25522542         {
25532543            m_layer[SNES_OAM].wlog_mask = data & 0x03;
25542544            m_layer[SNES_COLOR].wlog_mask = (data & 0x0c) >> 2;
r21560r21561
26262616         m_beam.last_visible_line = (data & 0x04) ? 240 : 225;
26272617         m_pseudo_hires = BIT(data, 3);
26282618         m_mode7.extbg = BIT(data, 6);
2629         dynamic_res_change(space.machine(), ram_ptr);
2619         dynamic_res_change(space.machine());
26302620#ifdef SNES_DBG_REG_W
26312621         if ((data & 0x8) != (ram_ptr[SETINI] & 0x8))
26322622            mame_printf_debug("Pseudo 512 mode: %s\n", (data & 0x8) ? "on" : "off");
trunk/src/mess/drivers/snes.c
r21560r21561
391391
392392   state->m_ppu.m_beam.latch_horz = x;
393393   state->m_ppu.m_beam.latch_vert = y;
394   snes_ram[STAT78] |= 0x40;
394   state->m_ppu.m_stat78 |= 0x40;
395395}
396396
397397static void snes_input_read_joy( running_machine &machine, int port )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team