atarisy2.cpp : Minor cleanups for bankswitching, Add address_map_bank_device for vram bankswitch handlers

This commit is contained in:
cam900 2018-04-07 19:37:33 +09:00
parent 26d3f01402
commit 5d681235f0
3 changed files with 70 additions and 100 deletions

View File

@ -204,8 +204,8 @@ MACHINE_START_MEMBER(atarisy2_state,atarisy2)
save_item(NAME(m_p2portrd_state));
save_item(NAME(m_sound_reset_state));
m_rombank1->configure_entries(0, 64, memregion("maincpu")->base() + 0x10000, 0x2000);
m_rombank2->configure_entries(0, 64, memregion("maincpu")->base() + 0x10000, 0x2000);
for (int bank = 0; bank < 2; bank++)
m_rombank[bank]->configure_entries(0, 64, memregion("maincpu")->base() + 0x10000, 0x2000);
}
@ -296,10 +296,7 @@ WRITE16_MEMBER(atarisy2_state::bankselect_w)
int banknumber = ((data >> 10) & 0x3f) ^ 0x03;
banknumber = bitswap<16>(banknumber, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 1, 0, 3, 2);
if (offset)
m_rombank2->set_entry(banknumber);
else
m_rombank1->set_entry(banknumber);
m_rombank[offset]->set_entry(banknumber);
}
@ -726,7 +723,6 @@ WRITE8_MEMBER(atarisy2_state::coincount_w)
}
/*************************************
*
* Main CPU memory handlers
@ -752,7 +748,7 @@ void atarisy2_state::main_map(address_map &map)
map(0x1780, 0x1781).mirror(0x007e).w(this, FUNC(atarisy2_state::yscroll_w)).share("yscroll");
map(0x1800, 0x1801).mirror(0x03fe).r(this, FUNC(atarisy2_state::switch_r)).w("watchdog", FUNC(watchdog_timer_device::reset16_w));
map(0x1c00, 0x1c01).mirror(0x03fe).r(this, FUNC(atarisy2_state::sound_r));
map(0x2000, 0x3fff).rw(this, FUNC(atarisy2_state::videoram_r), FUNC(atarisy2_state::videoram_w));
map(0x2000, 0x3fff).m(m_vrambank, FUNC(address_map_bank_device::amap16));
map(0x4000, 0x5fff).bankr("rombank1");
map(0x6000, 0x7fff).bankr("rombank2");
map(0x8000, 0xffff).rom();
@ -760,6 +756,22 @@ void atarisy2_state::main_map(address_map &map)
}
/*************************************
*
* Bankswitched VRAM handlers
*
*************************************/
/* full memory map derived from schematics */
void atarisy2_state::vrambank_map(address_map &map)
{
map.unmap_value_high();
map(0x0000, 0x17ff).ram().w(m_alpha_tilemap, FUNC(tilemap_device::write16)).share("alpha");
map(0x1800, 0x1fff).ram().w(this, FUNC(atarisy2_state::spriteram_w)).share("mob");
map(0x2000, 0x3fff).ram();
map(0x4000, 0x7fff).ram().w(m_playfield_tilemap, FUNC(tilemap_device::write16)).share("playfield");
}
/*************************************
*
@ -790,7 +802,6 @@ void atarisy2_state::sound_map(address_map &map)
}
/*************************************
*
* Port definitions
@ -1114,7 +1125,6 @@ static INPUT_PORTS_START( apb )
INPUT_PORTS_END
/*************************************
*
* Graphics definitions
@ -1127,9 +1137,9 @@ static const gfx_layout anlayout =
RGN_FRAC(1,1),
2,
{ 0, 4 },
{ 0, 1, 2, 3, 8, 9, 10, 11 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
8*16
{ STEP4(0,1), STEP4(8,1) },
{ STEP8(0,8*2) },
8*8*2
};
@ -1139,9 +1149,9 @@ static const gfx_layout pflayout =
RGN_FRAC(1,2),
4,
{ 0, 4, RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4 },
{ 0, 1, 2, 3, 8, 9, 10, 11 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
8*16
{ STEP4(0,1), STEP4(8,1) },
{ STEP8(0,8*2) },
8*8*2
};
@ -1151,9 +1161,9 @@ static const gfx_layout molayout =
RGN_FRAC(1,2),
4,
{ 0, 4, RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4 },
{ 0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27 },
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
8*64
{ STEP4(8*0,1), STEP4(8*1,1), STEP4(8*2,1), STEP4(8*3,1) },
{ STEP8(0,8*4) },
16*16*2
};
@ -1216,6 +1226,13 @@ MACHINE_CONFIG_START(atarisy2_state::atarisy2)
MCFG_SCREEN_PALETTE("palette")
MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(atarisy2_state, vblank_int))
MCFG_DEVICE_ADD("vrambank", ADDRESS_MAP_BANK, 0)
MCFG_DEVICE_PROGRAM_MAP(vrambank_map)
MCFG_ADDRESS_MAP_BANK_DATA_WIDTH(16)
MCFG_ADDRESS_MAP_BANK_ADDR_WIDTH(15)
MCFG_ADDRESS_MAP_BANK_ENDIANNESS(ENDIANNESS_LITTLE)
MCFG_ADDRESS_MAP_BANK_STRIDE(0x2000)
MCFG_VIDEO_START_OVERRIDE(atarisy2_state,atarisy2)
/* sound hardware */
@ -1279,8 +1296,6 @@ MACHINE_CONFIG_START(atarisy2_state::apb)
MACHINE_CONFIG_END
/*************************************
*
* ROM definition(s)
@ -1500,6 +1515,7 @@ ROM_START( paperboyp )
ROM_LOAD( "vid_t06.rv1", 0x000000, 0x002000, BAD_DUMP CRC(60d7aebb) SHA1(ad74221c4270496ebcfedd46ea16dca2cda1b4be) )
ROM_END
ROM_START( 720 )
ROM_REGION( 0x90000, "maincpu", 0 ) /* 9 * 64k T11 code */
ROM_LOAD16_BYTE( "136047-3126.7lm", 0x008000, 0x004000, CRC(43abd367) SHA1(bb58c42f25ef0ee5357782652e9e2b28df0ba82e) )
@ -1908,7 +1924,6 @@ ROM_START( 720gr1 )
ROM_END
ROM_START( ssprint )
ROM_REGION( 0x90000, "maincpu", 0 ) /* 9*64k for T11 code */
ROM_LOAD16_BYTE( "136042-330.7l", 0x008000, 0x004000, CRC(ee312027) SHA1(7caeaf6220022ffffc7d1feefec24163bed70275) )
@ -3237,7 +3252,6 @@ ROM_START( apbf )
ROM_END
/*************************************
*
* Driver initialization
@ -3312,7 +3326,6 @@ DRIVER_INIT_MEMBER(atarisy2_state,apb)
}
/*************************************
*
* Game driver(s)

View File

@ -10,6 +10,7 @@
#include "video/atarimo.h"
#include "cpu/m6502/m6502.h"
#include "cpu/t11/t11.h"
#include "machine/bankdev.h"
#include "machine/watchdog.h"
#include "sound/ym2151.h"
#include "sound/pokey.h"
@ -20,26 +21,27 @@ class atarisy2_state : public atarigen_state
{
public:
atarisy2_state(const machine_config &mconfig, device_type type, const char *tag)
: atarigen_state(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_mob(*this, "mob"),
m_slapstic_base(*this, "slapstic_base"),
m_playfield_tilemap(*this, "playfield"),
m_alpha_tilemap(*this, "alpha"),
m_soundcomm(*this, "soundcomm"),
m_ym2151(*this, "ymsnd"),
m_pokey(*this, "pokey%u", 1U),
m_tms5220(*this, "tms"),
m_rombank1(*this, "rombank1"),
m_rombank2(*this, "rombank2"),
m_slapstic(*this, "slapstic")
{ }
: atarigen_state(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_audiocpu(*this, "audiocpu")
, m_mob(*this, "mob")
, m_slapstic_base(*this, "slapstic_base")
, m_vrambank(*this, "vrambank")
, m_playfield_tilemap(*this, "playfield")
, m_alpha_tilemap(*this, "alpha")
, m_soundcomm(*this, "soundcomm")
, m_ym2151(*this, "ymsnd")
, m_pokey(*this, "pokey%u", 1U)
, m_tms5220(*this, "tms")
, m_rombank(*this, "rombank%u", 1U)
, m_slapstic(*this, "slapstic")
{ }
required_device<t11_device> m_maincpu;
required_device<m6502_device> m_audiocpu;
required_device<atari_motion_objects_device> m_mob;
required_shared_ptr<uint16_t> m_slapstic_base;
required_device<address_map_bank_device> m_vrambank;
uint8_t m_interrupt_enable;
@ -56,15 +58,13 @@ public:
uint8_t m_p2portwr_state;
uint8_t m_p2portrd_state;
required_memory_bank m_rombank1;
required_memory_bank m_rombank2;
required_memory_bank_array<2> m_rombank;
required_device<atari_slapstic_device> m_slapstic;
uint8_t m_sound_reset_state;
emu_timer * m_yscroll_reset_timer;
uint32_t m_playfield_tile_bank[2];
uint32_t m_videobank;
// 720 fake joystick
double m_joy_last_angle;
@ -75,8 +75,6 @@ public:
int32_t m_spin_pos; /* track fake position of spinner */
uint32_t m_spin_center_count;
uint16_t m_vram[0x8000/2];
virtual void device_post_load() override;
virtual void update_interrupts() override;
@ -112,11 +110,10 @@ public:
TIMER_CALLBACK_MEMBER(delayed_int_enable_w);
TIMER_CALLBACK_MEMBER(reset_yscroll_callback);
DECLARE_READ16_MEMBER(slapstic_r);
DECLARE_READ16_MEMBER(videoram_r);
DECLARE_WRITE16_MEMBER(slapstic_w);
DECLARE_WRITE16_MEMBER(yscroll_w);
DECLARE_WRITE16_MEMBER(xscroll_w);
DECLARE_WRITE16_MEMBER(videoram_w);
DECLARE_WRITE16_MEMBER(spriteram_w);
DECLARE_PALETTE_DECODER(RRRRGGGGBBBBIIII);
static const atari_motion_objects_config s_mob_config;
@ -128,4 +125,5 @@ public:
void csprint(machine_config &config);
void main_map(address_map &map);
void sound_map(address_map &map);
void vrambank_map(address_map &map);
};

View File

@ -12,7 +12,6 @@
#include "includes/atarisy2.h"
/*************************************
*
* Tilemap callbacks
@ -31,14 +30,13 @@ TILE_GET_INFO_MEMBER(atarisy2_state::get_alpha_tile_info)
TILE_GET_INFO_MEMBER(atarisy2_state::get_playfield_tile_info)
{
uint16_t data = m_playfield_tilemap->basemem_read(tile_index);
int code = m_playfield_tile_bank[(data >> 10) & 1] + (data & 0x3ff);
int code = (m_playfield_tile_bank[(data >> 10) & 1] << 10) | (data & 0x3ff);
int color = (data >> 11) & 7;
SET_TILE_INFO_MEMBER(0, code, color, 0);
tileinfo.category = (~data >> 14) & 3;
}
/*************************************
*
* Video system start
@ -81,23 +79,15 @@ const atari_motion_objects_config atarisy2_state::s_mob_config =
VIDEO_START_MEMBER(atarisy2_state,atarisy2)
{
/* initialize banked memory */
m_alpha_tilemap->basemem().set(&m_vram[0x0000], 0x2000, 16, ENDIANNESS_NATIVE, 2);
m_playfield_tilemap->basemem().set(&m_vram[0x2000], 0x2000, 16, ENDIANNESS_NATIVE, 2);
m_mob->set_spriteram(&m_vram[0x0c00], 0x0400);
/* reset the statics */
m_yscroll_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(atarisy2_state::reset_yscroll_callback),this));
m_videobank = 0;
m_vrambank->set_bank(0);
/* save states */
save_item(NAME(m_playfield_tile_bank));
save_item(NAME(m_videobank));
save_item(NAME(m_vram));
}
/*************************************
*
* Scroll/playfield bank write
@ -118,9 +108,9 @@ WRITE16_MEMBER( atarisy2_state::xscroll_w )
m_playfield_tilemap->set_scrollx(0, newscroll >> 6);
/* update the playfield banking */
if (m_playfield_tile_bank[0] != (newscroll & 0x0f) * 0x400)
if (m_playfield_tile_bank[0] != (newscroll & 0x0f))
{
m_playfield_tile_bank[0] = (newscroll & 0x0f) * 0x400;
m_playfield_tile_bank[0] = (newscroll & 0x0f);
m_playfield_tilemap->mark_all_dirty();
}
@ -152,9 +142,9 @@ WRITE16_MEMBER( atarisy2_state::yscroll_w )
m_yscroll_reset_timer->adjust(m_screen->time_until_pos(0), newscroll >> 6);
/* update the playfield banking */
if (m_playfield_tile_bank[1] != (newscroll & 0x0f) * 0x400)
if (m_playfield_tile_bank[1] != (newscroll & 0x0f))
{
m_playfield_tile_bank[1] = (newscroll & 0x0f) * 0x400;
m_playfield_tile_bank[1] = (newscroll & 0x0f);
m_playfield_tilemap->mark_all_dirty();
}
@ -163,7 +153,6 @@ WRITE16_MEMBER( atarisy2_state::yscroll_w )
}
/*************************************
*
* Palette RAM to RGB converter
@ -194,7 +183,6 @@ PALETTE_DECODER_MEMBER( atarisy2_state, RRRRGGGGBBBBIIII )
}
/*************************************
*
* Video RAM bank read/write handlers
@ -207,7 +195,7 @@ READ16_MEMBER( atarisy2_state::slapstic_r )
m_slapstic->slapstic_tweak(space, offset);
/* an extra tweak for the next opcode fetch */
m_videobank = m_slapstic->slapstic_tweak(space, 0x1234) * 0x1000;
m_vrambank->set_bank(m_slapstic->slapstic_tweak(space, 0x1234));
return result;
}
@ -217,54 +205,25 @@ WRITE16_MEMBER( atarisy2_state::slapstic_w )
m_slapstic->slapstic_tweak(space, offset);
/* an extra tweak for the next opcode fetch */
m_videobank = m_slapstic->slapstic_tweak(space, 0x1234) * 0x1000;
m_vrambank->set_bank(m_slapstic->slapstic_tweak(space, 0x1234));
}
/*************************************
*
* Video RAM read/write handlers
*
*************************************/
READ16_MEMBER( atarisy2_state::videoram_r )
WRITE16_MEMBER( atarisy2_state::spriteram_w )
{
int offs = offset | m_videobank;
return m_vram[offs];
/* force an update if the link of object 0 is about to change */
if (offs == 0x0003)
m_screen->update_partial(m_screen->vpos());
COMBINE_DATA(&m_mob->spriteram()[offset]);
}
WRITE16_MEMBER( atarisy2_state::videoram_w )
{
int offs = offset | m_videobank;
/* alpharam? */
if (offs < 0x0c00)
m_alpha_tilemap->write16(space, offs, data, mem_mask);
/* spriteram? */
else if (offs < 0x1000)
{
/* force an update if the link of object 0 is about to change */
if (offs == 0x0c03)
m_screen->update_partial(m_screen->vpos());
COMBINE_DATA(&m_mob->spriteram()[offs - 0x0c00]);
}
/* playfieldram? */
else if (offs >= 0x2000)
m_playfield_tilemap->write16(space, offs - 0x2000, data, mem_mask);
/* generic case */
else
{
COMBINE_DATA(&m_vram[offs]);
}
}
/*************************************
*
* Main refresh