Previous 199869 Revisions Next

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

trunk/src/mame/video/snes.c
r21561r21562
117117   SNES_COLOR_DEPTH_8BPP
118118};
119119
120
121#define PPU_REG(a) m_regs[a - 0x2100]
122
123
120124/*****************************************
121125 * get_bgcolor()
122126 *
r21561r21562
15361540      update_obsel();
15371541
15381542#if SNES_LAYER_DEBUG
1539      if (dbg_video(machine, curline, snes_ram))
1543      if (dbg_video(machine, curline))
15401544      {
15411545         g_profiler.stop();
15421546         return;
r21561r21562
19601964 writing to the 'expected' address set by
19611965 $2102,$2103.
19621966
1963 Notice that, since snes_ram[OAMDATA] is never
1967 Notice that, since PPU_REG(OAMDATA) is never
19641968 read/written directly, we use it as an index
19651969 to choose the high/low byte of the snes_oam word.
19661970*************************************************/
r21561r21562
19801984         offset = 0x010c;
19811985   }
19821986
1983   return (m_oam_ram[offset] >> (snes_ram[OAMDATA] << 3)) & 0xff;
1987   return (m_oam_ram[offset] >> (PPU_REG(OAMDATA) << 3)) & 0xff;
19841988}
19851989
19861990WRITE8_MEMBER( snes_ppu_class::oam_write )
r21561r21562
19982002         offset = 0x010c;
19992003   }
20002004
2001   if (!(snes_ram[OAMDATA]))
2005   if (!(PPU_REG(OAMDATA)))
20022006      m_oam_ram[offset] = (m_oam_ram[offset] & 0xff00) | (data << 0);
20032007   else
20042008      m_oam_ram[offset] = (m_oam_ram[offset] & 0x00ff) | (data << 8);
r21561r21562
20772081   ((UINT8 *)m_cgram)[offset] = data;
20782082}
20792083
2080UINT8 snes_ppu_class::read(address_space &space, UINT32 offset, UINT8 *ram_ptr)
2084UINT8 snes_ppu_class::read(address_space &space, UINT32 offset, UINT8 wrio_bit7)
20812085{
20822086   UINT8 value;
20832087
r21561r21562
21292133         return snes_open_bus_r(space, 0);       /* Return value is meaningless */
21302134      case ROAMDATA:  /* Read data from OAM (DR) */
21312135         m_ppu1_open_bus = oam_read(space, m_oam.address);
2132         ram_ptr[OAMDATA] = (ram_ptr[OAMDATA] + 1) % 2;
2133         if (!ram_ptr[OAMDATA])
2136         PPU_REG(OAMDATA) = (PPU_REG(OAMDATA) + 1) % 2;
2137         if (!PPU_REG(OAMDATA))
21342138         {
21352139            m_oam.address++;
21362140            m_oam.address &= 0x1ff;
r21561r21562
22132217      case STAT78:    /* PPU status flag and version number */
22142218         m_read_ophct = 0;
22152219         m_read_opvct = 0;
2216         if(ram_ptr[WRIO] & 0x80)
2220         if (wrio_bit7)
22172221            m_stat78 &= ~0x40; //clear ext latch if bit 7 of WRIO is set
22182222         m_stat78 = (m_stat78 & ~0x2f) | (m_ppu2_open_bus & 0x20) | (m_ppu2_version & 0x0f);
22192223         m_ppu2_open_bus = m_stat78;
r21561r21562
22252229}
22262230
22272231
2228void snes_ppu_class::write(address_space &space, UINT32 offset, UINT8 data, UINT8 *ram_ptr)
2232void snes_ppu_class::write(address_space &space, UINT32 offset, UINT8 data)
22292233{
22302234   switch (offset)
22312235   {
r21561r21562
22482252         m_oam.saved_address_low = data;
22492253         m_oam.address = (m_oam.address & 0xff00) + data;
22502254         m_oam.first_sprite = m_oam.priority_rotation ? (m_oam.address >> 1) & 127 : 0;
2251         ram_ptr[OAMDATA] = 0;
2255         PPU_REG(OAMDATA) = 0;
22522256         break;
22532257      case OAMADDH:   /* Address for accessing OAM (high) */
22542258         m_oam.saved_address_high = data;
22552259         m_oam.address = (m_oam.address & 0x00ff) | ((data & 0x01) << 8);
22562260         m_oam.priority_rotation = BIT(data, 7);
22572261         m_oam.first_sprite = m_oam.priority_rotation ? (m_oam.address >> 1) & 127 : 0;
2258         ram_ptr[OAMDATA] = 0;
2262         PPU_REG(OAMDATA) = 0;
22592263         break;
22602264      case OAMDATA:   /* Data for OAM write (DW) */
22612265         if (m_oam.address >= 0x100)
22622266            oam_write(space, m_oam.address, data);
22632267         else
22642268         {
2265            if (!ram_ptr[OAMDATA])
2269            if (!PPU_REG(OAMDATA))
22662270               m_oam.write_latch = data;
22672271            else
22682272            {
22692273               // in this case, we not only write data to the upper byte of the word,
22702274               // but also m_oam.write_latch to the lower byte (recall that
2271               // ram_ptr[OAMDATA] is used to select high/low byte)
2275               // PPU_REG(OAMDATA) is used to select high/low byte)
22722276               oam_write(space, m_oam.address, data);
2273               ram_ptr[OAMDATA] = 0;
2277               PPU_REG(OAMDATA) = 0;
22742278               oam_write(space, m_oam.address, m_oam.write_latch);
2275               ram_ptr[OAMDATA] = 1;
2279               PPU_REG(OAMDATA) = 1;
22762280            }
22772281         }
2278         ram_ptr[OAMDATA] = (ram_ptr[OAMDATA] + 1) % 2;
2279         if (!ram_ptr[OAMDATA])
2282         PPU_REG(OAMDATA) = (PPU_REG(OAMDATA) + 1) % 2;
2283         if (!PPU_REG(OAMDATA))
22802284         {
22812285            m_oam.address++;
22822286            m_oam.address &= 0x1ff;
r21561r21562
24582462         m_cgram_address = (m_cgram_address + 1) % (SNES_CGRAM_SIZE - 2);
24592463         break;
24602464      case W12SEL:    /* Window mask settings for BG1-2 */
2461         if (data != ram_ptr[W12SEL])
2465         if (data != PPU_REG(W12SEL))
24622466         {
24632467            m_layer[SNES_BG1].window1_invert  = BIT(data, 0);
24642468            m_layer[SNES_BG1].window1_enabled = BIT(data, 1);
r21561r21562
24722476         }
24732477         break;
24742478      case W34SEL:    /* Window mask settings for BG3-4 */
2475         if (data != ram_ptr[W34SEL])
2479         if (data != PPU_REG(W34SEL))
24762480         {
24772481            m_layer[SNES_BG3].window1_invert  = BIT(data, 0);
24782482            m_layer[SNES_BG3].window1_enabled = BIT(data, 1);
r21561r21562
24862490         }
24872491         break;
24882492      case WOBJSEL:   /* Window mask settings for objects */
2489         if (data != ram_ptr[WOBJSEL])
2493         if (data != PPU_REG(WOBJSEL))
24902494         {
24912495            m_layer[SNES_OAM].window1_invert  = BIT(data, 0);
24922496            m_layer[SNES_OAM].window1_enabled = BIT(data, 1);
r21561r21562
25002504         }
25012505         break;
25022506      case WH0:       /* Window 1 left position */
2503         if (data != ram_ptr[WH0])
2507         if (data != PPU_REG(WH0))
25042508         {
25052509            m_window1_left = data;
25062510            m_update_windows = 1;
25072511         }
25082512         break;
25092513      case WH1:       /* Window 1 right position */
2510         if (data != ram_ptr[WH1])
2514         if (data != PPU_REG(WH1))
25112515         {
25122516            m_window1_right = data;
25132517            m_update_windows = 1;
25142518         }
25152519         break;
25162520      case WH2:       /* Window 2 left position */
2517         if (data != ram_ptr[WH2])
2521         if (data != PPU_REG(WH2))
25182522         {
25192523            m_window2_left = data;
25202524            m_update_windows = 1;
25212525         }
25222526         break;
25232527      case WH3:       /* Window 2 right position */
2524         if (data != ram_ptr[WH3])
2528         if (data != PPU_REG(WH3))
25252529         {
25262530            m_window2_right = data;
25272531            m_update_windows = 1;
25282532         }
25292533         break;
25302534      case WBGLOG:    /* Window mask logic for BG's */
2531         if (data != ram_ptr[WBGLOG])
2535         if (data != PPU_REG(WBGLOG))
25322536         {
25332537            m_layer[SNES_BG1].wlog_mask = data & 0x03;
25342538            m_layer[SNES_BG2].wlog_mask = (data & 0x0c) >> 2;
r21561r21562
25382542         }
25392543         break;
25402544      case WOBJLOG:   /* Window mask logic for objects */
2541         if (data != ram_ptr[WOBJLOG])
2545         if (data != PPU_REG(WOBJLOG))
25422546         {
25432547            m_layer[SNES_OAM].wlog_mask = data & 0x03;
25442548            m_layer[SNES_COLOR].wlog_mask = (data & 0x0c) >> 2;
r21561r21562
25792583         m_sub_add_mode = BIT(data, 1);
25802584         m_direct_color = BIT(data, 0);
25812585#ifdef SNES_DBG_REG_W
2582         if ((data & 0x2) != (ram_ptr[CGWSEL] & 0x2))
2586         if ((data & 0x2) != (PPU_REG(CGWSEL) & 0x2))
25832587            mame_printf_debug("Add/Sub Layer: %s\n", ((data & 0x2) >> 1) ? "Subscreen" : "Fixed colour");
25842588#endif
25852589         break;
r21561r21562
26182622         m_mode7.extbg = BIT(data, 6);
26192623         dynamic_res_change(space.machine());
26202624#ifdef SNES_DBG_REG_W
2621         if ((data & 0x8) != (ram_ptr[SETINI] & 0x8))
2625         if ((data & 0x8) != (PPU_REG(SETINI) & 0x8))
26222626            mame_printf_debug("Pseudo 512 mode: %s\n", (data & 0x8) ? "on" : "off");
26232627#endif
26242628         break;
26252629      }
26262630
2627   ram_ptr[offset] = data;
2631   PPU_REG(offset) = data;
26282632}
26292633
26302634/***** Debug Functions *****/
r21561r21562
26432647      popmessage MSG2;                          \
26442648   }
26452649
2646static UINT8 dbg_video( running_machine &machine, UINT16 curline, UINT8 *ram_ptr )
2650static UINT8 dbg_video( running_machine &machine, UINT16 curline )
26472651{
26482652   int i;
26492653   UINT8 toggles = machine.root_device().ioport("DEBUG1")->read_safe(0);
r21561r21562
26782682      logerror("%s", debug_options.windows_disabled?" ":"W");
26792683      logerror("%s1 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
26802684            debug_options.bg_disabled[0]?" ":"*",
2681            (ram_ptr[TM] & 0x1)?"M":" ",
2682            (ram_ptr[TS] & 0x1)?"S":" ",
2683            (ram_ptr[CGADSUB] & 0x1)?"B":" ",
2684            (ram_ptr[TMW] & 0x1)?"m":" ",
2685            (ram_ptr[TSW] & 0x1)?"s":" ",
2686            WINLOGIC[(ram_ptr[WBGLOG] & 0x3)],
2687            (ram_ptr[W12SEL] & 0x2)?((ram_ptr[W12SEL] & 0x1)?"o":"i"):" ",
2688            (ram_ptr[W12SEL] & 0x8)?((ram_ptr[W12SEL] & 0x4)?"o":"i"):" ",
2685            (PPU_REG(TM) & 0x1)?"M":" ",
2686            (PPU_REG(TS) & 0x1)?"S":" ",
2687            (PPU_REG(CGADSUB) & 0x1)?"B":" ",
2688            (PPU_REG(TMW) & 0x1)?"m":" ",
2689            (PPU_REG(TSW) & 0x1)?"s":" ",
2690            WINLOGIC[(PPU_REG(WBGLOG) & 0x3)],
2691            (PPU_REG(W12SEL) & 0x2)?((PPU_REG(W12SEL) & 0x1)?"o":"i"):" ",
2692            (PPU_REG(W12SEL) & 0x8)?((PPU_REG(W12SEL) & 0x4)?"o":"i"):" ",
26892693            m_layer[SNES_BG1].tile_size + 1,
2690            (ram_ptr[MOSAIC] & 0x1)?"m":" ",
2691            ram_ptr[BG1SC] & 0x3,
2692            (ram_ptr[BG1SC] & 0xfc) << 9,
2694            (PPU_REG(MOSAIC) & 0x1)?"m":" ",
2695            PPU_REG(BG1SC) & 0x3,
2696            (PPU_REG(BG1SC) & 0xfc) << 9,
26932697            m_layer[SNES_BG1].charmap << 13);
26942698      logerror("%s2 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
26952699            debug_options.bg_disabled[1]?" ":"*",
2696            (ram_ptr[TM] & 0x2)?"M":" ",
2697            (ram_ptr[TS] & 0x2)?"S":" ",
2698            (ram_ptr[CGADSUB] & 0x2)?"B":" ",
2699            (ram_ptr[TMW] & 0x2)?"m":" ",
2700            (ram_ptr[TSW] & 0x2)?"s":" ",
2701            WINLOGIC[(ram_ptr[WBGLOG] & 0xc) >> 2],
2702            (ram_ptr[W12SEL] & 0x20)?((ram_ptr[W12SEL] & 0x10)?"o":"i"):" ",
2703            (ram_ptr[W12SEL] & 0x80)?((ram_ptr[W12SEL] & 0x40)?"o":"i"):" ",
2700            (PPU_REG(TM) & 0x2)?"M":" ",
2701            (PPU_REG(TS) & 0x2)?"S":" ",
2702            (PPU_REG(CGADSUB) & 0x2)?"B":" ",
2703            (PPU_REG(TMW) & 0x2)?"m":" ",
2704            (PPU_REG(TSW) & 0x2)?"s":" ",
2705            WINLOGIC[(PPU_REG(WBGLOG) & 0xc) >> 2],
2706            (PPU_REG(W12SEL) & 0x20)?((PPU_REG(W12SEL) & 0x10)?"o":"i"):" ",
2707            (PPU_REG(W12SEL) & 0x80)?((PPU_REG(W12SEL) & 0x40)?"o":"i"):" ",
27042708            m_layer[SNES_BG2].tile_size + 1,
2705            (ram_ptr[MOSAIC] & 0x2)?"m":" ",
2706            ram_ptr[BG2SC] & 0x3,
2707            (ram_ptr[BG2SC] & 0xfc) << 9,
2709            (PPU_REG(MOSAIC) & 0x2)?"m":" ",
2710            PPU_REG(BG2SC) & 0x3,
2711            (PPU_REG(BG2SC) & 0xfc) << 9,
27082712            m_layer[SNES_BG2].charmap << 13);
27092713      logerror("%s3 %s%s%s%s%s%c%s%s%d%s%s%d %4X %4X",
27102714            debug_options.bg_disabled[2]?" ":"*",
2711            (ram_ptr[TM] & 0x4)?"M":" ",
2712            (ram_ptr[TS] & 0x4)?"S":" ",
2713            (ram_ptr[CGADSUB] & 0x4)?"B":" ",
2714            (ram_ptr[TMW] & 0x4)?"m":" ",
2715            (ram_ptr[TSW] & 0x4)?"s":" ",
2716            WINLOGIC[(ram_ptr[WBGLOG] & 0x30)>>4],
2717            (ram_ptr[W34SEL] & 0x2)?((ram_ptr[W34SEL] & 0x1)?"o":"i"):" ",
2718            (ram_ptr[W34SEL] & 0x8)?((ram_ptr[W34SEL] & 0x4)?"o":"i"):" ",
2715            (PPU_REG(TM) & 0x4)?"M":" ",
2716            (PPU_REG(TS) & 0x4)?"S":" ",
2717            (PPU_REG(CGADSUB) & 0x4)?"B":" ",
2718            (PPU_REG(TMW) & 0x4)?"m":" ",
2719            (PPU_REG(TSW) & 0x4)?"s":" ",
2720            WINLOGIC[(PPU_REG(WBGLOG) & 0x30)>>4],
2721            (PPU_REG(W34SEL) & 0x2)?((PPU_REG(W34SEL) & 0x1)?"o":"i"):" ",
2722            (PPU_REG(W34SEL) & 0x8)?((PPU_REG(W34SEL) & 0x4)?"o":"i"):" ",
27192723            m_layer[SNES_BG3].tile_size + 1,
2720            (ram_ptr[MOSAIC] & 0x4)?"m":" ",
2721            (ram_ptr[BGMODE] & 0x8)?"P":" ",
2722            ram_ptr[BG3SC] & 0x3,
2723            (ram_ptr[BG3SC] & 0xfc) << 9,
2724            (PPU_REG(MOSAIC) & 0x4)?"m":" ",
2725            (PPU_REG(BGMODE) & 0x8)?"P":" ",
2726            PPU_REG(BG3SC) & 0x3,
2727            (PPU_REG(BG3SC) & 0xfc) << 9,
27242728            m_layer[SNES_BG3].charmap << 13);
27252729      logerror("%s4 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
27262730            debug_options.bg_disabled[3]?" ":"*",
2727            (ram_ptr[TM] & 0x8)?"M":" ",
2728            (ram_ptr[TS] & 0x8)?"S":" ",
2729            (ram_ptr[CGADSUB] & 0x8)?"B":" ",
2730            (ram_ptr[TMW] & 0x8)?"m":" ",
2731            (ram_ptr[TSW] & 0x8)?"s":" ",
2732            WINLOGIC[(ram_ptr[WBGLOG] & 0xc0)>>6],
2733            (ram_ptr[W34SEL] & 0x20)?((ram_ptr[W34SEL] & 0x10)?"o":"i"):" ",
2734            (ram_ptr[W34SEL] & 0x80)?((ram_ptr[W34SEL] & 0x40)?"o":"i"):" ",
2731            (PPU_REG(TM) & 0x8)?"M":" ",
2732            (PPU_REG(TS) & 0x8)?"S":" ",
2733            (PPU_REG(CGADSUB) & 0x8)?"B":" ",
2734            (PPU_REG(TMW) & 0x8)?"m":" ",
2735            (PPU_REG(TSW) & 0x8)?"s":" ",
2736            WINLOGIC[(PPU_REG(WBGLOG) & 0xc0)>>6],
2737            (PPU_REG(W34SEL) & 0x20)?((PPU_REG(W34SEL) & 0x10)?"o":"i"):" ",
2738            (PPU_REG(W34SEL) & 0x80)?((PPU_REG(W34SEL) & 0x40)?"o":"i"):" ",
27352739            m_layer[SNES_BG4].tile_size + 1,
2736            (ram_ptr[MOSAIC] & 0x8)?"m":" ",
2737            ram_ptr[BG4SC] & 0x3,
2738            (ram_ptr[BG4SC] & 0xfc) << 9,
2740            (PPU_REG(MOSAIC) & 0x8)?"m":" ",
2741            PPU_REG(BG4SC) & 0x3,
2742            (PPU_REG(BG4SC) & 0xfc) << 9,
27392743            m_layer[SNES_BG4].charmap << 13 );
27402744      logerror("%sO %s%s%s%s%s%c%s%s       %4X",
27412745            debug_options.bg_disabled[4]?" ":"*",
2742            (ram_ptr[TM] & 0x10)?"M":" ",
2743            (ram_ptr[TS] & 0x10)?"S":" ",
2744            (ram_ptr[CGADSUB] & 0x10)?"B":" ",
2745            (ram_ptr[TMW] & 0x10)?"m":" ",
2746            (ram_ptr[TSW] & 0x10)?"s":" ",
2747            WINLOGIC[(ram_ptr[WOBJLOG] & 0x3)],
2748            (ram_ptr[WOBJSEL] & 0x2)?((ram_ptr[WOBJSEL] & 0x1)?"o":"i"):" ",
2749            (ram_ptr[WOBJSEL] & 0x8)?((ram_ptr[WOBJSEL] & 0x4)?"o":"i"):" ",
2746            (PPU_REG(TM) & 0x10)?"M":" ",
2747            (PPU_REG(TS) & 0x10)?"S":" ",
2748            (PPU_REG(CGADSUB) & 0x10)?"B":" ",
2749            (PPU_REG(TMW) & 0x10)?"m":" ",
2750            (PPU_REG(TSW) & 0x10)?"s":" ",
2751            WINLOGIC[(PPU_REG(WOBJLOG) & 0x3)],
2752            (PPU_REG(WOBJSEL) & 0x2)?((PPU_REG(WOBJSEL) & 0x1)?"o":"i"):" ",
2753            (PPU_REG(WOBJSEL) & 0x8)?((PPU_REG(WOBJSEL) & 0x4)?"o":"i"):" ",
27502754            m_layer[SNES_OAM].charmap << 13 );
27512755      logerror("%sB   %s  %c%s%s",
27522756            debug_options.colormath_disabled?" ":"*",
2753            (ram_ptr[CGADSUB] & 0x20)?"B":" ",
2754            WINLOGIC[(ram_ptr[WOBJLOG] & 0xc)>>2],
2755            (ram_ptr[WOBJSEL] & 0x20)?((ram_ptr[WOBJSEL] & 0x10)?"o":"i"):" ",
2756            (ram_ptr[WOBJSEL] & 0x80)?((ram_ptr[WOBJSEL] & 0x40)?"o":"i"):" " );
2757            (PPU_REG(CGADSUB) & 0x20)?"B":" ",
2758            WINLOGIC[(PPU_REG(WOBJLOG) & 0xc)>>2],
2759            (PPU_REG(WOBJSEL) & 0x20)?((PPU_REG(WOBJSEL) & 0x10)?"o":"i"):" ",
2760            (PPU_REG(WOBJSEL) & 0x80)?((PPU_REG(WOBJSEL) & 0x40)?"o":"i"):" " );
27572761      logerror("1) %3d %3d   2) %3d %3d", (m_bgd_offset.horizontal[0] & 0x3ff) >> 3, (m_bgd_offset.vertical[0] & 0x3ff) >> 3, (m_bgd_offset.horizontal[1] & 0x3ff) >> 3, (m_bgd_offset.vertical[1] & 0x3ff) >> 3 );
27582762      logerror("3) %3d %3d   4) %3d %3d", (m_bgd_offset.horizontal[2] & 0x3ff) >> 3, (m_bgd_offset.vertical[2] & 0x3ff) >> 3, (m_bgd_offset.horizontal[3] & 0x3ff) >> 3, (m_bgd_offset.vertical[3] & 0x3ff) >> 3 );
2759      logerror("Flags: %s%s%s %s %2d", (ram_ptr[CGWSEL] & 0x2)?"S":"F", (ram_ptr[CGADSUB] & 0x80)?"-":"+", (ram_ptr[CGADSUB] & 0x40)?" 50%":"100%",(ram_ptr[CGWSEL] & 0x1)?"D":"P", (ram_ptr[MOSAIC] & 0xf0) >> 4 );
2760      logerror("SetINI: %s %s %s %s %s %s", (ram_ptr[SETINI] & 0x1)?" I":"NI", (ram_ptr[SETINI] & 0x2)?"P":"R", (ram_ptr[SETINI] & 0x4)?"240":"225",(ram_ptr[SETINI] & 0x8)?"512":"256",(ram_ptr[SETINI] & 0x40)?"E":"N",(ram_ptr[SETINI] & 0x80)?"ES":"NS" );
2763      logerror("Flags: %s%s%s %s %2d", (PPU_REG(CGWSEL) & 0x2)?"S":"F", (PPU_REG(CGADSUB) & 0x80)?"-":"+", (PPU_REG(CGADSUB) & 0x40)?" 50%":"100%",(PPU_REG(CGWSEL) & 0x1)?"D":"P", (PPU_REG(MOSAIC) & 0xf0) >> 4 );
2764      logerror("SetINI: %s %s %s %s %s %s", (PPU_REG(SETINI) & 0x1)?" I":"NI", (PPU_REG(SETINI) & 0x2)?"P":"R", (PPU_REG(SETINI) & 0x4)?"240":"225",(PPU_REG(SETINI) & 0x8)?"512":"256",(PPU_REG(SETINI) & 0x40)?"E":"N",(PPU_REG(SETINI) & 0x80)?"ES":"NS" );
27612765      logerror("Mode7: A %5d B %5d", m_mode7.matrix_a, m_mode7.matrix_b );
2762      logerror(" %s%s%s   C %5d D %5d", (ram_ptr[M7SEL] & 0xc0)?((ram_ptr[M7SEL] & 0x40)?"0":"C"):"R", (ram_ptr[M7SEL] & 0x1)?"H":" ", (ram_ptr[M7SEL] & 0x2)?"V":" ", m_mode7.matrix_c, m_mode7.matrix_d );
2766      logerror(" %s%s%s   C %5d D %5d", (PPU_REG(M7SEL) & 0xc0)?((PPU_REG(M7SEL) & 0x40)?"0":"C"):"R", (PPU_REG(M7SEL) & 0x1)?"H":" ", (PPU_REG(M7SEL) & 0x2)?"V":" ", m_mode7.matrix_c, m_mode7.matrix_d );
27632767      logerror("       X %5d Y %5d", m_mode7.origin_x, m_mode7.origin_y );
27642768   }
27652769#endif
trunk/src/mame/includes/snes.h
r21561r21562
383383class snes_ppu_class  /* once all the regs are saved in this structure, it would be better to reorganize it a bit... */
384384{
385385public:
386   UINT8 m_regs[0x40];
387
386388   SNES_SCANLINE m_scanlines[2];
387389   
388390   struct
r21561r21562
532534   void latch_counters(running_machine &machine);
533535   void dynamic_res_change(running_machine &machine);
534536   inline UINT32 get_vram_address(running_machine &machine);
535   UINT8 dbg_video(running_machine &machine, UINT16 curline, UINT8 *ram_ptr);
537   UINT8 dbg_video(running_machine &machine, UINT16 curline);
536538
537539   void ppu_start(running_machine &machine);
538   UINT8 read(address_space &space, UINT32 offset, UINT8 *ram_ptr);
539   void write(address_space &space, UINT32 offset, UINT8 data, UINT8 *ram_ptr);
540   UINT8 read(address_space &space, UINT32 offset, UINT8 wrio_bit7);
541   void write(address_space &space, UINT32 offset, UINT8 data);
540542   
541543   DECLARE_READ8_MEMBER( oam_read );
542544   DECLARE_WRITE8_MEMBER( oam_write );
trunk/src/mame/machine/snes.c
r21561r21562
445445   // PPU accesses are from 2100 to 213f
446446   if (offset >= INIDISP && offset < APU00)
447447   {
448      return state->m_ppu.read(space, offset, snes_ram);
448      return state->m_ppu.read(space, offset, snes_ram[WRIO] & 0x80);
449449   }
450450
451451   // APU is mirrored from 2140 to 217f
r21561r21562
501501         state->m_wram_address &= 0x1ffff;
502502         return value;
503503      case OLDJOY1:   /* Data for old NES controllers (JOYSER1) */
504         if (snes_ram[offset] & 0x1)
504         if (snes_ram[OLDJOY1] & 0x1)
505505            return 0 | (snes_open_bus_r(space, 0) & 0xfc); //correct?
506506
507507         value = state->m_oldjoy1_read(space.machine());
r21561r21562
515515
516516         return value | 0x1c | (snes_open_bus_r(space, 0) & 0xe0); //correct?
517517      case RDNMI:         /* NMI flag by v-blank and version number */
518         value = (snes_ram[offset] & 0x80) | (snes_open_bus_r(space, 0) & 0x70);
519         snes_ram[offset] &= 0x70;   /* NMI flag is reset on read */
518         value = (snes_ram[RDNMI] & 0x80) | (snes_open_bus_r(space, 0) & 0x70);
519         snes_ram[RDNMI] &= 0x70;   /* NMI flag is reset on read */
520520         return value | 2; //CPU version number
521521      case TIMEUP:        /* IRQ flag by H/V count timer */
522522         value = (snes_open_bus_r(space, 0) & 0x7f) | (snes_ram[TIMEUP] & 0x80);
r21561r21562
525525         return value;
526526      case HVBJOY:        /* H/V blank and joypad controller enable */
527527         // electronics test says hcounter 272 is start of hblank, which is beampos 363
528//          if (space.machine().primary_screen->hpos() >= 363) snes_ram[offset] |= 0x40;
529//              else snes_ram[offset] &= ~0x40;
530         return (snes_ram[offset] & 0xc1) | (snes_open_bus_r(space, 0) & 0x3e);
528//          if (space.machine().primary_screen->hpos() >= 363) snes_ram[HVBJOY] |= 0x40;
529//              else snes_ram[HVBJOY] &= ~0x40;
530         return (snes_ram[HVBJOY] & 0xc1) | (snes_open_bus_r(space, 0) & 0x3e);
531531      case RDIO:          /* Programmable I/O port - echos back what's written to WRIO */
532532         return snes_ram[WRIO];
533533      case JOY1L:         /* Joypad 1 status register (low) */
r21561r21562
606606   // PPU accesses are from 2100 to 213f
607607   if (offset >= INIDISP && offset < APU00)
608608   {
609      state->m_ppu.write(space, offset, data, snes_ram);
609      state->m_ppu.write(space, offset, data);
610610      return;
611611   }
612612
r21561r21562
684684         state->m_wram_address &= 0x1ffff;
685685         return;
686686      case OLDJOY1:   /* Old NES joystick support */
687         if (((!(data & 0x1)) && (snes_ram[offset] & 0x1)))
687         if (((!(data & 0x1)) && (snes_ram[OLDJOY1] & 0x1)))
688688         {
689689            state->m_read_idx[0] = 0;
690690            state->m_read_idx[1] = 0;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team