mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
(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.
This commit is contained in:
parent
6510f7b55e
commit
c90b350b40
@ -748,65 +748,31 @@ WRITE8_MEMBER( sega315_5124_device::register_write )
|
||||
}
|
||||
|
||||
|
||||
UINT16 sega315_5124_device::get_name_table_address()
|
||||
UINT16 sega315_5124_device::get_name_table_row(int row)
|
||||
{
|
||||
UINT16 result;
|
||||
|
||||
if ( m_y_pixels != 192 )
|
||||
{
|
||||
result = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (m_reg[0x02] << 10) & 0x3800;
|
||||
}
|
||||
|
||||
return result & (((m_reg[0x02] & 0x01) << 10) | 0x3bff);
|
||||
return ((row >> 3) << 6) & (((m_reg[0x02] & 0x01) << 10) | 0x3bff);
|
||||
}
|
||||
|
||||
|
||||
UINT16 sega315_5246_device::get_name_table_address()
|
||||
UINT16 sega315_5246_device::get_name_table_row(int row)
|
||||
{
|
||||
UINT16 result;
|
||||
|
||||
if ( m_y_pixels != 192 )
|
||||
{
|
||||
result = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (m_reg[0x02] << 10) & 0x3800;
|
||||
}
|
||||
|
||||
return result;
|
||||
return (row >> 3) << 6;
|
||||
}
|
||||
|
||||
|
||||
UINT16 sega315_5378_device::get_name_table_address()
|
||||
UINT16 sega315_5378_device::get_name_table_row(int row)
|
||||
{
|
||||
UINT16 result;
|
||||
|
||||
if ( m_y_pixels != 192 )
|
||||
{
|
||||
result = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (m_reg[0x02] << 10) & 0x3800;
|
||||
}
|
||||
|
||||
return result;
|
||||
return (row >> 3) << 6;
|
||||
}
|
||||
|
||||
|
||||
void sega315_5124_device::draw_scanline_mode4( int *line_buffer, int *priority_selected, int line )
|
||||
{
|
||||
int tile_column;
|
||||
int y_scroll;
|
||||
int y_scroll, scroll_mod;
|
||||
int pixel_x, pixel_plot_x;
|
||||
int bit_plane_0, bit_plane_1, bit_plane_2, bit_plane_3;
|
||||
const int scroll_mod = ( m_y_pixels != 192 ) ? 256 : 224;
|
||||
const UINT16 name_table_address = get_name_table_address();
|
||||
UINT16 name_table_address;
|
||||
|
||||
/* if top 2 rows of screen not affected by horizontal scrolling, then x_scroll = 0 */
|
||||
/* else x_scroll = m_reg8copy */
|
||||
@ -814,6 +780,17 @@ void sega315_5124_device::draw_scanline_mode4( int *line_buffer, int *priority_s
|
||||
|
||||
const int x_scroll_start_column = (x_scroll >> 3); /* x starting column tile */
|
||||
|
||||
if ( m_y_pixels != 192 )
|
||||
{
|
||||
name_table_address = ((m_reg[0x02] & 0x0c) << 10) | 0x0700;
|
||||
scroll_mod = 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
name_table_address = (m_reg[0x02] << 10) & 0x3800;
|
||||
scroll_mod = 224;
|
||||
}
|
||||
|
||||
/* Draw background layer */
|
||||
for (tile_column = 0; tile_column < 33; tile_column++)
|
||||
{
|
||||
@ -825,8 +802,8 @@ void sega315_5124_device::draw_scanline_mode4( int *line_buffer, int *priority_s
|
||||
/* vertical scrolling when bit 7 of reg[0x00] is set */
|
||||
y_scroll = ((m_reg[0x00] & 0x80) && (tile_column > 23)) ? 0 : m_reg9copy;
|
||||
|
||||
tile_line = ((tile_column + x_scroll_start_column) & 0x1f) * 2;
|
||||
tile_data = space().read_word(name_table_address + ((((line + y_scroll) % scroll_mod) >> 3) << 6) + tile_line);
|
||||
tile_line = ((tile_column + x_scroll_start_column) & 0x1f) << 1;
|
||||
tile_data = space().read_word(name_table_address + get_name_table_row((line + y_scroll) % scroll_mod) + tile_line);
|
||||
|
||||
tile_selected = (tile_data & 0x01ff);
|
||||
priority_select = tile_data & PRIORITY_BIT;
|
||||
@ -891,7 +868,7 @@ void sega315_5124_device::select_sprites( int line )
|
||||
/* Check if MAG is set */
|
||||
m_sprite_zoom = (m_reg[0x01] & 0x01) ? 2 : 1;
|
||||
|
||||
if (m_sprite_zoom == 2)
|
||||
if (m_sprite_zoom > 1)
|
||||
{
|
||||
/* Divide before use the value for comparison, same later with sprite_y, or
|
||||
else an off-by-one bug could occur, as seen with Tarzan, for Game Gear */
|
||||
@ -1041,10 +1018,15 @@ void sega315_5124_device::draw_sprites_mode4( int *line_buffer, int *priority_se
|
||||
bool sprite_col_occurred = false;
|
||||
int sprite_col_x = SEGA315_5124_WIDTH;
|
||||
UINT8 collision_buffer[SEGA315_5124_WIDTH];
|
||||
int plot_min_x = 0;
|
||||
|
||||
if (m_display_disabled || m_sprite_count == 0)
|
||||
return;
|
||||
|
||||
/* Sprites aren't drawn and collisions don't occur on column 0 if it is disabled */
|
||||
if (m_reg[0x00] & 0x20)
|
||||
plot_min_x = 8;
|
||||
|
||||
memset(collision_buffer, 0, SEGA315_5124_WIDTH);
|
||||
|
||||
/* Draw sprite layer */
|
||||
@ -1078,7 +1060,7 @@ void sega315_5124_device::draw_sprites_mode4( int *line_buffer, int *priority_se
|
||||
int pixel_plot_x = sprite_x + (pixel_x << 1);
|
||||
|
||||
/* check to prevent going outside of active display area */
|
||||
if (pixel_plot_x < 0 || pixel_plot_x > 255)
|
||||
if (pixel_plot_x < plot_min_x || pixel_plot_x > 255)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -1127,7 +1109,7 @@ void sega315_5124_device::draw_sprites_mode4( int *line_buffer, int *priority_se
|
||||
int pixel_plot_x = sprite_x + pixel_x;
|
||||
|
||||
/* check to prevent going outside of active display area */
|
||||
if (pixel_plot_x < 0 || pixel_plot_x > 255)
|
||||
if (pixel_plot_x < plot_min_x || pixel_plot_x > 255)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -1256,7 +1238,7 @@ void sega315_5124_device::draw_sprites_tms9918_mode( int *line_buffer, int line
|
||||
{
|
||||
sprite_tile_selected += 2;
|
||||
pattern = space().read_byte( sprite_pattern_line + sprite_tile_selected * 8 );
|
||||
sprite_x += (m_sprite_zoom == 2 ? 16 : 8);
|
||||
sprite_x += (m_sprite_zoom > 1 ? 16 : 8);
|
||||
|
||||
for (int pixel_x = 0; pixel_x < 8; pixel_x++)
|
||||
{
|
||||
|
@ -88,13 +88,13 @@ public:
|
||||
|
||||
protected:
|
||||
static const int X_SCROLL_HPOS_5124 = 21;
|
||||
static const int X_SCROLL_HPOS_5378 = 35; // Not verified
|
||||
static const int X_SCROLL_HPOS_5378 = 41; // Not verified, needed for Chicago Syndicate
|
||||
|
||||
void set_display_settings();
|
||||
virtual void update_palette();
|
||||
virtual void cram_write(UINT8 data);
|
||||
virtual void draw_scanline( int pixel_offset_x, int pixel_plot_y, int line );
|
||||
virtual UINT16 get_name_table_address();
|
||||
virtual UINT16 get_name_table_row(int row);
|
||||
void process_line_timer();
|
||||
void draw_scanline_mode4( int *line_buffer, int *priority_selected, int line );
|
||||
void draw_sprites_mode4( int *line_buffer, int *priority_selected, int line );
|
||||
@ -190,7 +190,7 @@ public:
|
||||
sega315_5246_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
protected:
|
||||
virtual UINT16 get_name_table_address();
|
||||
virtual UINT16 get_name_table_row(int row);
|
||||
};
|
||||
|
||||
|
||||
@ -210,7 +210,7 @@ protected:
|
||||
virtual void update_palette();
|
||||
virtual void cram_write(UINT8 data);
|
||||
virtual void draw_scanline( int pixel_offset_x, int pixel_plot_y, int line );
|
||||
virtual UINT16 get_name_table_address();
|
||||
virtual UINT16 get_name_table_row(int row);
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
- Gear to Gear Port SMS Controller Adaptor
|
||||
- Sega Demo Unit II (kiosk expansion device)
|
||||
- SMS Disk System (floppy disk drive expansion device) - unreleased
|
||||
- Sega Graphic Board (black version) - unreleased
|
||||
- Rapid button of Japanese Master System
|
||||
- Keyboard support for Sega Mark III (sg1000m3 driver)
|
||||
- Link between two Mark III's through keyboard, supported by F-16 Fighting Falcon
|
||||
|
@ -495,7 +495,21 @@ WRITE8_MEMBER(sms_state::sms_mapper_w)
|
||||
|
||||
UINT8 sms_state::read_bus(address_space &space, unsigned int page, UINT16 base_addr, UINT16 offset)
|
||||
{
|
||||
if (m_mem_device_enabled != ENABLE_NONE)
|
||||
if (m_is_gamegear)
|
||||
{
|
||||
// Game Gear BIOS behavior, according to Charles MacDonald: "it uses the first
|
||||
// 1K. The rest of the space is mapped to the cartridge, regardless of the slot
|
||||
// that's selected. This allows the BIOS to check for the 'TMR SEGA' string at
|
||||
// 1FF0/3FF0/7FF0, but it can't do a checksum since the first 1K of ROM is
|
||||
// unavailable. Anyway, once the BIOS decides to run the game, it disables
|
||||
// itself, and the first 1K is assigned to the cartridge ROM like normal."
|
||||
|
||||
if ((m_mem_device_enabled & ENABLE_BIOS) && page == 3)
|
||||
return m_BIOS[(m_bios_page[page] * 0x4000) + (offset & 0x3fff)];
|
||||
if (m_mem_device_enabled & ENABLE_CART)
|
||||
return m_cartslot->read_cart(space, base_addr + offset);
|
||||
}
|
||||
else if (m_mem_device_enabled != ENABLE_NONE)
|
||||
{
|
||||
UINT8 data = 0xff;
|
||||
|
||||
@ -514,10 +528,7 @@ UINT8 sms_state::read_bus(address_space &space, unsigned int page, UINT16 base_a
|
||||
|
||||
return data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_region_maincpu->base()[offset];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -583,6 +594,9 @@ WRITE8_MEMBER(sms_state::sms_mem_control_w)
|
||||
|
||||
WRITE8_MEMBER(sms_state::gg_sio_w)
|
||||
{
|
||||
if (m_cartslot->exists() && m_cartslot->m_cart->get_sms_mode())
|
||||
return;
|
||||
|
||||
logerror("*** write %02X to SIO register #%d\n", data, offset);
|
||||
|
||||
m_gg_sio[offset & 0x07] = data;
|
||||
@ -608,6 +622,9 @@ WRITE8_MEMBER(sms_state::gg_sio_w)
|
||||
|
||||
READ8_MEMBER(sms_state::gg_sio_r)
|
||||
{
|
||||
if (m_cartslot->exists() && m_cartslot->m_cart->get_sms_mode())
|
||||
return 0xff;
|
||||
|
||||
logerror("*** read SIO register #%d\n", offset);
|
||||
|
||||
switch (offset & 7)
|
||||
@ -667,7 +684,7 @@ void sms_state::setup_enabled_slots()
|
||||
logerror("Card ROM port enabled.\n");
|
||||
}
|
||||
|
||||
if (!(m_mem_ctrl_reg & IO_CARTRIDGE) && m_cartslot && m_cartslot->exists())
|
||||
if ((m_is_gamegear || !(m_mem_ctrl_reg & IO_CARTRIDGE)) && m_cartslot && m_cartslot->exists())
|
||||
{
|
||||
m_mem_device_enabled |= ENABLE_CART;
|
||||
logerror("Cartridge ROM/RAM enabled.\n");
|
||||
|
Loading…
Reference in New Issue
Block a user