Previous 199869 Revisions Next

r17391 Wednesday 22nd August, 2012 at 03:59:49 UTC by Angelo Salese
Moved snes_oam in the state machine, allows to be showable in the debugger, nw
[src/mame/includes]snes.h
[src/mame/video]snes.c

trunk/src/mame/includes/snes.h
r17390r17391
523523   inline void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens );
524524   void snes_refresh_scanline( running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline );
525525
526   DECLARE_READ8_MEMBER( snes_oam_read );
527   DECLARE_WRITE8_MEMBER( snes_oam_write );
528   UINT16 *m_snes_oam;      /* Object Attribute Memory */
529
526530};
527531
528532/* Special chips, checked at init and used in memory handlers */
trunk/src/mame/video/snes.c
r17390r17391
132132
133133static UINT8  *snes_vram;      /* Video RAM (Should be 16-bit, but it's easier this way) */
134134static UINT16 *snes_cgram;      /* Colour RAM */
135static UINT16 *snes_oam;      /* Object Attribute Memory */
136135
137136/*****************************************
138137 * snes_get_bgcolor()
r17390r17391
843842
844843void snes_state::snes_oam_list_build( void )
845844{
846   UINT8 *oamram = (UINT8 *)snes_oam;
845   UINT8 *oamram = (UINT8 *)m_snes_oam;
847846   INT16 oam = 0x1ff;
848847   UINT16 oam_extra = oam + 0x20;
849848   UINT16 extra = 0;
r17390r17391
16581657
16591658VIDEO_START( snes )
16601659{
1660   snes_state *state = machine.driver_data<snes_state>();
16611661   int i,j;
16621662
16631663#if SNES_LAYER_DEBUG
r17390r17391
16661666
16671667   snes_vram = auto_alloc_array(machine, UINT8, SNES_VRAM_SIZE);
16681668   snes_cgram = auto_alloc_array(machine, UINT16, SNES_CGRAM_SIZE/2);
1669   snes_oam = auto_alloc_array(machine, UINT16, SNES_OAM_SIZE/2);
1669   state->m_snes_oam = auto_alloc_array(machine, UINT16, SNES_OAM_SIZE/2);
16701670
16711671   /* Inititialize registers/variables */
16721672   snes_ppu.update_windows = 1;
r17390r17391
16931693   memset((UINT8 *)snes_cgram, 0, SNES_CGRAM_SIZE);
16941694
16951695   /* Init oam RAM */
1696   memset(snes_oam, 0xff, SNES_OAM_SIZE);
1696   memset(state->m_snes_oam, 0xff, SNES_OAM_SIZE);
16971697
16981698   for (i = 0; i < 6; i++)
16991699   {
r17390r17391
17851785
17861786   state_save_register_global_pointer(machine, snes_vram, SNES_VRAM_SIZE);
17871787   state_save_register_global_pointer(machine, snes_cgram, SNES_CGRAM_SIZE/2);
1788   state_save_register_global_pointer(machine, snes_oam, SNES_OAM_SIZE/2);
1788   state_save_register_global_pointer(machine, state->m_snes_oam, SNES_OAM_SIZE/2);
17891789}
17901790
17911791SCREEN_UPDATE_RGB32( snes )
r17390r17391
19771977 to choose the high/low byte of the snes_oam word.
19781978*************************************************/
19791979
1980static READ8_HANDLER( snes_oam_read )
1980READ8_MEMBER( snes_state::snes_oam_read )
19811981{
19821982   offset &= 0x1ff;
19831983
r17390r17391
19861986
19871987   if (!snes_ppu.screen_disabled)
19881988   {
1989      UINT16 v = space->machine().primary_screen->vpos();
1989      UINT16 v = machine().primary_screen->vpos();
19901990
19911991      if (v < snes_ppu.beam.last_visible_line)
19921992         offset = 0x010c;
19931993   }
19941994
1995   return (snes_oam[offset] >> (snes_ram[OAMDATA] << 3)) & 0xff;
1995   return (m_snes_oam[offset] >> (snes_ram[OAMDATA] << 3)) & 0xff;
19961996}
19971997
1998static WRITE8_HANDLER( snes_oam_write )
1998WRITE8_MEMBER( snes_state::snes_oam_write )
19991999{
20002000   offset &= 0x1ff;
20012001
r17390r17391
20042004
20052005   if (!snes_ppu.screen_disabled)
20062006   {
2007      UINT16 v = space->machine().primary_screen->vpos();
2007      UINT16 v = machine().primary_screen->vpos();
20082008
20092009      if (v < snes_ppu.beam.last_visible_line)
20102010         offset = 0x010c;
20112011   }
20122012
20132013   if (!(snes_ram[OAMDATA]))
2014      snes_oam[offset] = (snes_oam[offset] & 0xff00) | (data << 0);
2014      m_snes_oam[offset] = (m_snes_oam[offset] & 0xff00) | (data << 0);
20152015   else
2016      snes_oam[offset] = (snes_oam[offset] & 0x00ff) | (data << 8);
2016      m_snes_oam[offset] = (m_snes_oam[offset] & 0x00ff) | (data << 8);
20172017}
20182018
20192019/*************************************************
r17390r17391
21412141         snes_latch_counters(space->machine());
21422142         return snes_open_bus_r(space, 0);      /* Return value is meaningless */
21432143      case ROAMDATA:   /* Read data from OAM (DR) */
2144         snes_ppu.ppu1_open_bus = snes_oam_read(space, snes_ppu.oam.address);
2144         snes_ppu.ppu1_open_bus = state->snes_oam_read(*space, snes_ppu.oam.address);
21452145         snes_ram[OAMDATA] = (snes_ram[OAMDATA] + 1) % 2;
21462146         if (!snes_ram[OAMDATA])
21472147         {
r17390r17391
22742274         break;
22752275      case OAMDATA:   /* Data for OAM write (DW) */
22762276         if (snes_ppu.oam.address >= 0x100)
2277            snes_oam_write(space, snes_ppu.oam.address, data);
2277            state->snes_oam_write(*space, snes_ppu.oam.address, data);
22782278         else
22792279         {
22802280            if (!snes_ram[OAMDATA])
r17390r17391
22842284               // in this case, we not only write data to the upper byte of the word,
22852285               // but also snes_ppu.oam.write_latch to the lower byte (recall that
22862286               // snes_ram[OAMDATA] is used to select high/low byte)
2287               snes_oam_write(space, snes_ppu.oam.address, data);
2287               state->snes_oam_write(*space, snes_ppu.oam.address, data);
22882288               snes_ram[OAMDATA] = 0;
2289               snes_oam_write(space, snes_ppu.oam.address, snes_ppu.oam.write_latch);
2289               state->snes_oam_write(*space, snes_ppu.oam.address, snes_ppu.oam.write_latch);
22902290               snes_ram[OAMDATA] = 1;
22912291            }
22922292         }

Previous 199869 Revisions Next


© 1997-2024 The MAME Team