Previous 199869 Revisions Next

r32140 Tuesday 16th September, 2014 at 21:25:39 UTC by Wilbert Pol
(MESS) sms.c: Small improvements to the latching of some registers. Fixes flicker in Power Strike 2.  [Enik Land]
[src/emu/video]315_5124.c 315_5124.h
[src/mess/drivers]sms.c

trunk/src/emu/video/315_5124.c
r32139r32140
7171#define SPROVR_HPOS           24
7272#define SPRCOL_BASEHPOS       59
7373#define X_SCROLL_HPOS         21
74#define DISPLAY_DISABLED_HPOS 17 /* fixes 'fantdizzy' (SMS PAL game) flicker */
74#define DISPLAY_DISABLED_HPOS 24 /* not verified, works if above 18 (for 'pstrike2') and below 25 (for 'fantdizzy') */
75#define SPR_PATTERN_HPOS      26 /* not verified, needed for 'backtof3' (SMS PAL game) title screen */
7576#define DISPLAY_CB_HPOS       2  /* fixes 'roadrash' (SMS game) title scrolling, due to line counter reload timing */
7677
7778#define DRAW_TIME_GG        94      /* 9 + 2 + 14 + 8 + 13 + 96/2 */
r32139r32140
156157   , m_cram_size( SEGA315_5124_CRAM_SIZE )
157158   , m_palette_offset( 0 )
158159   , m_supports_224_240( false )
159   , m_latched_reg6(0)
160160   , m_is_pal(false)
161161   , m_int_cb(*this)
162162   , m_pause_cb(*this)
r32139r32140
173173   , m_cram_size( cram_size )
174174   , m_palette_offset( palette_offset )
175175   , m_supports_224_240( supports_224_240 )
176   , m_latched_reg6(0)
177176   , m_is_pal(false)
178177   , m_int_cb(*this)
179178   , m_pause_cb(*this)
r32139r32140
302301      with the expected VDP hclock value, if the same range is used (from 0 to width-1). */
303302   int hclock = hpos - 1;
304303   if (hclock < 0)
305      hclock += m_screen->width();
304      hclock += SEGA315_5124_WIDTH;
306305
307306   /* Calculate and store the new hcount. */
308307   m_hcounter = ((hclock - active_scr_start) >> 1) & 0xff;
r32139r32140
376375               m_int_cb(ASSERT_LINE);
377376         }
378377      }
379      m_latched_reg6 = m_reg[0x06];
380378      break;
381379
382380   case TIMER_VINT:
r32139r32140
407405               + m_frame_timing[TOP_BORDER] + m_frame_timing[ACTIVE_DISPLAY_V]
408406               + m_frame_timing[BOTTOM_BORDER] + m_frame_timing[BOTTOM_BLANKING];
409407
408   /* copy current values in case they are not changed until latch time */
410409   m_display_disabled = !(m_reg[0x01] & 0x40);
410   m_reg6copy = m_reg[0x06];
411   m_reg8copy = m_reg[0x08];
411412
412413   vpos_limit -= m_frame_timing[BOTTOM_BLANKING];
413414
r32139r32140
467468      {
468469         m_reg9copy = m_reg[0x09];
469470      }
470      m_reg8copy = m_reg[0x08];
471471
472472      if (m_line_counter == 0x00)
473473      {
474474         m_line_counter = m_reg[0x0a];
475         m_hint_timer->adjust( m_screen->time_until_pos( vpos, HINT_HPOS ) );
475476         m_pending_status |= STATUS_HINT;
476477      }
477478      else
478479      {
479480         m_line_counter--;
480481      }
481      m_hint_timer->adjust( m_screen->time_until_pos( vpos, HINT_HPOS ) );
482482
483483      /* Draw borders */
484484      m_lborder_timer->adjust( m_screen->time_until_pos( vpos, SEGA315_5124_LBORDER_START ), vpos );
r32139r32140
562562      remaining time, what could also occur due to the ahead time of the timeslice. */
563563   if (m_pending_flags_timer->remaining() == attotime::zero)
564564   {
565      hpos = m_screen->width() - 1;
565      hpos = SEGA315_5124_WIDTH - 1;
566566   }
567567   else
568568   {
r32139r32140
649649
650650WRITE8_MEMBER( sega315_5124_device::register_write )
651651{
652   int reg_num, hpos;
652   int reg_num;
653653
654654   if (m_pending_reg_write == 0)
655655   {
r32139r32140
677677         reg_num = data & 0x0f;
678678         m_reg[reg_num] = m_addr & 0xff;
679679         //logerror("%s: %s: setting register %x to %02x\n", machine().describe_context(), tag(), reg_num, m_addr & 0xf );
680         if ( reg_num == 0 && ( m_addr & 0x02 ) )
681            logerror("overscan enabled.\n");
682
683         if (reg_num == 0 || reg_num == 1)
680         
681         switch (reg_num)
682         {
683         case 0:
684684            set_display_settings();
685            if (m_addr & 0x02)
686               logerror("overscan enabled.\n");
687            break;
688         case 1:
689            set_display_settings();
690            if (m_screen->hpos() <= DISPLAY_DISABLED_HPOS)
691               m_display_disabled = !(m_reg[0x01] & 0x40);
692            break;
693         case 6:
694            if (m_screen->hpos() <= SPR_PATTERN_HPOS)
695               m_reg6copy = m_reg[0x06];
696            break;
697         case 8:
698            if (m_screen->hpos() <= X_SCROLL_HPOS)
699               m_reg8copy = m_reg[0x08];
700         }
685701
686         hpos = m_screen->hpos();
687
688         if (reg_num == 1 && hpos <= DISPLAY_DISABLED_HPOS)
689            m_display_disabled = !(m_reg[0x01] & 0x40);
690
691         if (reg_num == 8 && hpos <= X_SCROLL_HPOS)
692            m_reg8copy = m_reg[0x08];
693
694702         check_pending_flags();
695703
696704         if ( ( reg_num == 0 && (m_status & STATUS_HINT) ) ||
r32139r32140
966974void sega315_5124_device::draw_sprites_mode4( int *line_buffer, int *priority_selected, int line )
967975{
968976   bool sprite_col_occurred = false;
969   int sprite_col_x = m_screen->width();
977   int sprite_col_x = SEGA315_5124_WIDTH;
970978
971   if (m_display_disabled)
979   if (m_display_disabled || m_sprite_count == 0)
972980      return;
973981
974982   memset(m_collision_buffer, 0, SEGA315_5124_WIDTH);
r32139r32140
991999         sprite_x -= 0x08;    /* sprite shift */
9921000      }
9931001
994      if (m_latched_reg6 & 0x04)
1002      if (m_reg6copy & 0x04)
9951003      {
9961004         sprite_tile_selected += 256; /* pattern table select */
9971005      }
r32139r32140
11221130void sega315_5124_device::draw_sprites_tms9918_mode( int *line_buffer, int line )
11231131{
11241132   bool sprite_col_occurred = false;
1125   int sprite_col_x = m_screen->width();
1126   const UINT16 sprite_pattern_base = ((m_latched_reg6 & 0x07) << 11);
1133   int sprite_col_x = SEGA315_5124_WIDTH;
1134   UINT16 sprite_pattern_base;
11271135
1128   if (m_display_disabled)
1136   if (m_display_disabled || m_sprite_count == 0)
11291137      return;
11301138
1139   sprite_pattern_base = ((m_reg6copy & 0x07) << 11);
11311140   memset(m_collision_buffer, 0, SEGA315_5124_WIDTH);
11321141
11331142   /* Draw sprite layer */
r32139r32140
14011410   int *blitline_buffer = m_line_buffer;
14021411   int priority_selected[256];
14031412
1413   /* Sprite processing is restricted because collisions on top border of extended
1414      resolution break the scoreboard of Fantasy Dizzy (SMS) on smspal driver */
1415
14041416   if ( line < m_frame_timing[ACTIVE_DISPLAY_V] )
14051417   {
14061418      switch( m_vdp_mode )
r32139r32140
18091821   m_display_timer = timer_alloc(TIMER_LINE);
18101822   m_display_timer->adjust(m_screen->time_until_pos(0, DISPLAY_CB_HPOS), 0, m_screen->scan_period());
18111823   m_pending_flags_timer = timer_alloc(TIMER_FLAGS);
1812   m_pending_flags_timer->adjust(m_screen->time_until_pos(0, m_screen->width() - 1), 0, m_screen->scan_period());
1824   m_pending_flags_timer->adjust(m_screen->time_until_pos(0, SEGA315_5124_WIDTH - 1), 0, m_screen->scan_period());
18131825   m_draw_timer = timer_alloc(TIMER_DRAW);
18141826   m_lborder_timer = timer_alloc(TIMER_LBORDER);
18151827   m_rborder_timer = timer_alloc(TIMER_RBORDER);
r32139r32140
18201832   save_item(NAME(m_status));
18211833   save_item(NAME(m_pending_status));
18221834   save_item(NAME(m_pending_sprcol_x));
1835   save_item(NAME(m_reg6copy));
18231836   save_item(NAME(m_reg8copy));
18241837   save_item(NAME(m_reg9copy));
18251838   save_item(NAME(m_addrmode));
r32139r32140
18481861   save_item(NAME(m_sprite_height));
18491862   save_item(NAME(m_sprite_zoom));
18501863   save_item(NAME(m_CRAM));
1851   save_item(NAME(m_latched_reg6));
18521864
18531865   machine().save().register_postload(save_prepost_delegate(FUNC(sega315_5124_device::vdp_postload), this));
18541866}
r32139r32140
18691881   m_pending_status = 0;
18701882   m_pending_sprcol_x = 0;
18711883   m_pending_reg_write = 0;
1884   m_reg6copy = 0;
18721885   m_reg8copy = 0;
18731886   m_reg9copy = 0;
18741887   m_addrmode = 0;
trunk/src/emu/video/315_5124.h
r32139r32140
114114   UINT8            m_reg[16];                  /* All the registers */
115115   UINT8            m_status;                   /* Status register */
116116   UINT8            m_pending_status;           /* Pending status flags */
117   UINT8            m_reg6copy;                 /* Internal copy of register 6 (Sprite Patterns) */
117118   UINT8            m_reg8copy;                 /* Internal copy of register 8 (X-Scroll) */
118119   UINT8            m_reg9copy;                 /* Internal copy of register 9 (Y-Scroll) */
119120   UINT8            m_addrmode;                 /* Type of VDP action */
r32139r32140
144145   int              m_sprite_count;
145146   int              m_sprite_height;
146147   int              m_sprite_zoom;
147   UINT8            m_latched_reg6;
148148
149149   /* line_buffer will be used to hold 5 lines of line data. Line #0 is the regular blitting area.
150150      Lines #1-#4 will be used as a kind of cache to be used for vertical scaling in the gamegear
trunk/src/mess/drivers/sms.c
r32139r32140
2121 - Keyboard support for Sega Mark III (sg1000m3 driver)
2222 - Link between two Mark III's through keyboard, supported by F-16 Fighting Falcon
2323 - Mark III expansion slot, used by keyboard and FM module
24 - Disabling of the SN76489 PSG chip on smsj system (sms1krfm not confirmed)
2425 - Software compatibility flags, by region and/or BIOS
2526 - Emulate SRAM cartridges? (for use with Bock's dump tool)
2627 - Support for other DE-9 compatible controllers, like the Mega Drive 6-Button

Previous 199869 Revisions Next


© 1997-2024 The MAME Team