Previous 199869 Revisions Next

r32685 Sunday 12th October, 2014 at 11:04:55 UTC by Wilbert Pol
(MESS) sms.c: Misc fixes:  [Enik Land]
- Disable gamegear sio register when in ggsms mode.
- Fixed tilemap mirroring on sms1 vdp needed for Japanese version of Ys.
- Fixed BIOS support in the gamegear driver.
- Fixed collisions when column #0 is disabled.
[src/emu/video]315_5124.c 315_5124.h
[src/mess/drivers]sms.c
[src/mess/machine]sms.c

trunk/src/emu/video/315_5124.c
r32684r32685
748748}
749749
750750
751UINT16 sega315_5124_device::get_name_table_address()
751UINT16 sega315_5124_device::get_name_table_row(int row)
752752{
753   UINT16 result;
754
755   if ( m_y_pixels != 192 )
756   {
757      result = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
758   }
759   else
760   {
761      result = (m_reg[0x02] << 10) & 0x3800;
762   }
763
764   return result & (((m_reg[0x02] & 0x01) << 10) | 0x3bff);
753   return ((row >> 3) << 6) & (((m_reg[0x02] & 0x01) << 10) | 0x3bff);
765754}
766755
767756
768UINT16 sega315_5246_device::get_name_table_address()
757UINT16 sega315_5246_device::get_name_table_row(int row)
769758{
770   UINT16 result;
771
772   if ( m_y_pixels != 192 )
773   {
774      result = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
775   }
776   else
777   {
778      result = (m_reg[0x02] << 10) & 0x3800;
779   }
780
781   return result;
759   return (row >> 3) << 6;
782760}
783761
784762
785UINT16 sega315_5378_device::get_name_table_address()
763UINT16 sega315_5378_device::get_name_table_row(int row)
786764{
787   UINT16 result;
788
789   if ( m_y_pixels != 192 )
790   {
791      result = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
792   }
793   else
794   {
795      result = (m_reg[0x02] << 10) & 0x3800;
796   }
797
798   return result;
765   return (row >> 3) << 6;
799766}
800767
801768
802769void sega315_5124_device::draw_scanline_mode4( int *line_buffer, int *priority_selected, int line )
803770{
804771   int tile_column;
805   int y_scroll;
772   int y_scroll, scroll_mod;
806773   int pixel_x, pixel_plot_x;
807774   int bit_plane_0, bit_plane_1, bit_plane_2, bit_plane_3;
808   const int scroll_mod = ( m_y_pixels != 192 ) ? 256 : 224;
809   const UINT16 name_table_address = get_name_table_address();
775   UINT16 name_table_address;
810776
811777   /* if top 2 rows of screen not affected by horizontal scrolling, then x_scroll = 0 */
812778   /* else x_scroll = m_reg8copy                                                      */
r32684r32685
814780
815781   const int x_scroll_start_column = (x_scroll >> 3);             /* x starting column tile */
816782
783   if ( m_y_pixels != 192 )
784   {
785      name_table_address = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
786      scroll_mod = 256;
787   }
788   else
789   {
790      name_table_address = (m_reg[0x02] << 10) & 0x3800;
791      scroll_mod = 224;
792   }
793
817794   /* Draw background layer */
818795   for (tile_column = 0; tile_column < 33; tile_column++)
819796   {
r32684r32685
825802      /* vertical scrolling when bit 7 of reg[0x00] is set */
826803      y_scroll = ((m_reg[0x00] & 0x80) && (tile_column > 23)) ? 0 : m_reg9copy;
827804
828      tile_line = ((tile_column + x_scroll_start_column) & 0x1f) * 2;
829      tile_data = space().read_word(name_table_address + ((((line + y_scroll) % scroll_mod) >> 3) << 6) + tile_line);
805      tile_line = ((tile_column + x_scroll_start_column) & 0x1f) << 1;
806      tile_data = space().read_word(name_table_address + get_name_table_row((line + y_scroll) % scroll_mod) + tile_line);
830807
831808      tile_selected = (tile_data & 0x01ff);
832809      priority_select = tile_data & PRIORITY_BIT;
r32684r32685
891868   /* Check if MAG is set */
892869   m_sprite_zoom = (m_reg[0x01] & 0x01) ? 2 : 1;
893870
894   if (m_sprite_zoom == 2)
871   if (m_sprite_zoom > 1)
895872   {
896873      /* Divide before use the value for comparison, same later with sprite_y, or
897874         else an off-by-one bug could occur, as seen with Tarzan, for Game Gear */
r32684r32685
10411018   bool sprite_col_occurred = false;
10421019   int sprite_col_x = SEGA315_5124_WIDTH;
10431020   UINT8 collision_buffer[SEGA315_5124_WIDTH];
1021   int plot_min_x = 0;
10441022
10451023   if (m_display_disabled || m_sprite_count == 0)
10461024      return;
10471025
1026   /* Sprites aren't drawn and collisions don't occur on column 0 if it is disabled */
1027   if (m_reg[0x00] & 0x20)
1028      plot_min_x = 8;
1029
10481030   memset(collision_buffer, 0, SEGA315_5124_WIDTH);
10491031
10501032   /* Draw sprite layer */
r32684r32685
10781060            int pixel_plot_x = sprite_x + (pixel_x << 1);
10791061
10801062            /* check to prevent going outside of active display area */
1081            if (pixel_plot_x < 0 || pixel_plot_x > 255)
1063            if (pixel_plot_x < plot_min_x || pixel_plot_x > 255)
10821064            {
10831065               continue;
10841066            }
r32684r32685
11271109            int pixel_plot_x = sprite_x + pixel_x;
11281110
11291111            /* check to prevent going outside of active display area */
1130            if (pixel_plot_x < 0 || pixel_plot_x > 255)
1112            if (pixel_plot_x < plot_min_x || pixel_plot_x > 255)
11311113            {
11321114               continue;
11331115            }
r32684r32685
12561238      {
12571239         sprite_tile_selected += 2;
12581240         pattern = space().read_byte( sprite_pattern_line + sprite_tile_selected * 8 );
1259         sprite_x += (m_sprite_zoom == 2 ? 16 : 8);
1241         sprite_x += (m_sprite_zoom > 1 ? 16 : 8);
12601242
12611243         for (int pixel_x = 0; pixel_x < 8; pixel_x++)
12621244         {
trunk/src/emu/video/315_5124.h
r32684r32685
8888
8989protected:
9090   static const int X_SCROLL_HPOS_5124 = 21;
91   static const int X_SCROLL_HPOS_5378 = 35;  // Not verified
91   static const int X_SCROLL_HPOS_5378 = 41;  // Not verified, needed for Chicago Syndicate
9292
9393   void set_display_settings();
9494   virtual void update_palette();
9595   virtual void cram_write(UINT8 data);
9696   virtual void draw_scanline( int pixel_offset_x, int pixel_plot_y, int line );
97   virtual UINT16 get_name_table_address();
97   virtual UINT16 get_name_table_row(int row);
9898   void process_line_timer();
9999   void draw_scanline_mode4( int *line_buffer, int *priority_selected, int line );
100100   void draw_sprites_mode4( int *line_buffer, int *priority_selected, int line );
r32684r32685
190190   sega315_5246_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
191191
192192protected:
193   virtual UINT16 get_name_table_address();
193   virtual UINT16 get_name_table_row(int row);
194194};
195195
196196
r32684r32685
210210   virtual void update_palette();
211211   virtual void cram_write(UINT8 data);
212212   virtual void draw_scanline( int pixel_offset_x, int pixel_plot_y, int line );
213   virtual UINT16 get_name_table_address();
213   virtual UINT16 get_name_table_row(int row);
214214};
215215
216216
trunk/src/mess/drivers/sms.c
r32684r32685
1616 - Gear to Gear Port SMS Controller Adaptor
1717 - Sega Demo Unit II (kiosk expansion device)
1818 - SMS Disk System (floppy disk drive expansion device) - unreleased
19 - Sega Graphic Board (black version) - unreleased
2019 - Rapid button of Japanese Master System
2120 - Keyboard support for Sega Mark III (sg1000m3 driver)
2221 - Link between two Mark III's through keyboard, supported by F-16 Fighting Falcon
trunk/src/mess/machine/sms.c
r32684r32685
495495
496496UINT8 sms_state::read_bus(address_space &space, unsigned int page, UINT16 base_addr, UINT16 offset)
497497{
498   if (m_mem_device_enabled != ENABLE_NONE)
498   if (m_is_gamegear)
499499   {
500      // Game Gear BIOS behavior, according to Charles MacDonald: "it uses the first
501      // 1K. The rest of the space is mapped to the cartridge, regardless of the slot
502      // that's selected. This allows the BIOS to check for the 'TMR SEGA' string at
503      // 1FF0/3FF0/7FF0, but it can't do a checksum since the first 1K of ROM is
504      // unavailable. Anyway, once the BIOS decides to run the game, it disables
505      // itself, and the first 1K is assigned to the cartridge ROM like normal."
506
507      if ((m_mem_device_enabled & ENABLE_BIOS) && page == 3)
508         return m_BIOS[(m_bios_page[page] * 0x4000) + (offset & 0x3fff)];
509      if (m_mem_device_enabled & ENABLE_CART)
510         return m_cartslot->read_cart(space, base_addr + offset);
511   }
512   else if (m_mem_device_enabled != ENABLE_NONE)
513   {
500514      UINT8 data = 0xff;
501515
502516      // SMS2 behavior described by Charles MacDonald's SMS notes:
r32684r32685
514528
515529      return data;
516530   }
517   else
518   {
519      return m_region_maincpu->base()[offset];
520   }
531   return m_region_maincpu->base()[offset];
521532}
522533
523534
r32684r32685
583594
584595WRITE8_MEMBER(sms_state::gg_sio_w)
585596{
597   if (m_cartslot->exists() && m_cartslot->m_cart->get_sms_mode())
598      return;
599
586600   logerror("*** write %02X to SIO register #%d\n", data, offset);
587601
588602   m_gg_sio[offset & 0x07] = data;
r32684r32685
608622
609623READ8_MEMBER(sms_state::gg_sio_r)
610624{
625   if (m_cartslot->exists() && m_cartslot->m_cart->get_sms_mode())
626      return 0xff;
627
611628   logerror("*** read SIO register #%d\n", offset);
612629
613630   switch (offset & 7)
r32684r32685
667684      logerror("Card ROM port enabled.\n");
668685   }
669686
670   if (!(m_mem_ctrl_reg & IO_CARTRIDGE) && m_cartslot && m_cartslot->exists())
687   if ((m_is_gamegear || !(m_mem_ctrl_reg & IO_CARTRIDGE)) && m_cartslot && m_cartslot->exists())
671688   {
672689      m_mem_device_enabled |= ENABLE_CART;
673690      logerror("Cartridge ROM/RAM enabled.\n");

Previous 199869 Revisions Next


© 1997-2024 The MAME Team