Merge pull request #5087 from cam900/dreamwld_args

dreamwld.cpp : Updates
This commit is contained in:
R. Belmont 2019-05-20 07:45:55 -04:00 committed by GitHub
commit 11fce8895d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,9 +112,10 @@ public:
dreamwld_state(const machine_config &mconfig, device_type type, const char *tag) dreamwld_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag) : driver_device(mconfig, type, tag)
, m_spriteram(*this, "spriteram") , m_spriteram(*this, "spriteram")
, m_vram(*this, "vram_%u", 0) , m_vram(*this, "vram_%u", 0U, u8(32))
, m_vregs(*this, "vregs") , m_vregs(*this, "vregs")
, m_workram(*this, "workram") , m_workram(*this, "workram")
, m_lineram(*this, "lineram", 32)
, m_prot(*this, "prot") , m_prot(*this, "prot")
, m_spritelut(*this, "spritelut") , m_spritelut(*this, "spritelut")
, m_okibank(*this, "oki%ubank", 1) , m_okibank(*this, "oki%ubank", 1)
@ -136,20 +137,19 @@ protected:
private: private:
/* memory pointers */ /* memory pointers */
required_shared_ptr<uint32_t> m_spriteram; required_shared_ptr<u32> m_spriteram;
required_shared_ptr_array<uint32_t, 2> m_vram; required_shared_ptr_array<u16, 2> m_vram;
required_shared_ptr<uint32_t> m_vregs; required_shared_ptr<u32> m_vregs;
required_shared_ptr<uint32_t> m_workram; required_shared_ptr<u32> m_workram;
required_shared_ptr<u16> m_lineram;
optional_memory_region m_prot; optional_memory_region m_prot;
required_memory_region m_spritelut; required_memory_region m_spritelut;
optional_memory_bank_array<2> m_okibank; optional_memory_bank_array<2> m_okibank;
required_ioport m_dsw; required_ioport m_dsw;
std::unique_ptr<uint16_t[]> m_lineram16; u16 lineram_r(offs_t offset) { return m_lineram[offset]; }
void lineram_w(offs_t offset, u16 data, u16 mem_mask = ~0) { COMBINE_DATA(&m_lineram[offset]); }
DECLARE_READ16_MEMBER(lineram16_r) { return m_lineram16[offset]; }
DECLARE_WRITE16_MEMBER(lineram16_w) { COMBINE_DATA(&m_lineram16[offset]); }
/* video-related */ /* video-related */
tilemap_t *m_tilemap[2][2]; tilemap_t *m_tilemap[2][2];
@ -157,7 +157,7 @@ private:
int m_tilebankold[2]; int m_tilebankold[2];
int m_old_linescroll[2]; int m_old_linescroll[2];
std::unique_ptr<uint32_t[]> m_spritebuf[2]; std::unique_ptr<u32[]> m_spritebuf[2];
/* misc */ /* misc */
int m_protindex; int m_protindex;
@ -166,13 +166,14 @@ private:
required_device<gfxdecode_device> m_gfxdecode; required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette; required_device<palette_device> m_palette;
template<int Layer> DECLARE_WRITE32_MEMBER(vram_w); template<int Layer> u16 vram_r(offs_t offset);
DECLARE_READ32_MEMBER(protdata_r); template<int Layer> void vram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
template<int Chip> DECLARE_WRITE32_MEMBER(okibank_w); u32 protdata_r();
template<int Chip> void okibank_w(u8 data);
template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info); template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
uint32_t screen_update_dreamwld(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank_dreamwld); DECLARE_WRITE_LINE_MEMBER(screen_vblank);
void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
void baryon_map(address_map &map); void baryon_map(address_map &map);
void dreamwld_map(address_map &map); void dreamwld_map(address_map &map);
void oki1_map(address_map &map); void oki1_map(address_map &map);
@ -180,36 +181,28 @@ private:
}; };
void dreamwld_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
void dreamwld_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
{ {
gfx_element *gfx = m_gfxdecode->gfx(0); gfx_element *gfx = m_gfxdecode->gfx(0);
uint32_t *source = m_spritebuf[0].get(); const u32 *source = m_spritebuf[0].get();
uint32_t *finish = m_spritebuf[0].get() + 0x1000 / 4; const u32 *finish = m_spritebuf[0].get() + 0x1000 / 4;
uint16_t *redirect = (uint16_t *)m_spritelut->base(); const u16 *redirect = &m_spritelut->as_u16();
int xoffset = 4; const int xoffset = 4;
while (source < finish) while (source < finish)
{ {
int xpos, ypos, tileno; int xpos = (source[0] & 0x000001ff) >> 0;
int xsize, ysize, xinc, yinc; int ypos = (source[0] & 0x01ff0000) >> 16;
int xct, yct; u8 xsize = (source[0] & 0x00000e00) >> 9;
int xflip; u8 ysize = (source[0] & 0x0e000000) >> 25;
int yflip;
int colour;
xpos = (source[0] & 0x000001ff) >> 0; u32 tileno = (source[1] & 0x0001ffff) >>0;
ypos = (source[0] & 0x01ff0000) >> 16; const u32 colour = (source[1] & 0x3f000000) >>24;
xsize = (source[0] & 0x00000e00) >> 9; const bool xflip = (source[1] & 0x40000000);
ysize = (source[0] & 0x0e000000) >> 25; const bool yflip = (source[1] & 0x80000000);
tileno = (source[1] & 0x0001ffff) >>0; int xinc = 16;
colour = (source[1] & 0x3f000000) >>24; int yinc = 16;
xflip = (source[1] & 0x40000000);
yflip = (source[1] & 0x80000000);
xinc = 16;
yinc = 16;
xpos += xoffset; xpos += xoffset;
xpos &= 0x1ff; xpos &= 0x1ff;
@ -230,10 +223,9 @@ void dreamwld_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clipre
xpos -=16; xpos -=16;
for (int yct = 0; yct < ysize; yct++)
for (yct = 0; yct < ysize; yct++)
{ {
for (xct = 0; xct < xsize; xct++) for (int xct = 0; xct < xsize; xct++)
{ {
gfx->transpen(bitmap,cliprect, redirect[tileno], colour, xflip, yflip, xpos + xct * xinc, ypos + yct * yinc, 0); gfx->transpen(bitmap,cliprect, redirect[tileno], colour, xflip, yflip, xpos + xct * xinc, ypos + yct * yinc, 0);
gfx->transpen(bitmap,cliprect, redirect[tileno], colour, xflip, yflip, (xpos + xct * xinc) - 0x200, ypos + yct * yinc, 0); gfx->transpen(bitmap,cliprect, redirect[tileno], colour, xflip, yflip, (xpos + xct * xinc) - 0x200, ypos + yct * yinc, 0);
@ -249,24 +241,27 @@ void dreamwld_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clipre
} }
template<int Layer> template<int Layer>
WRITE32_MEMBER(dreamwld_state::vram_w) u16 dreamwld_state::vram_r(offs_t offset)
{
return m_vram[Layer][offset];
}
template<int Layer>
void dreamwld_state::vram_w(offs_t offset, u16 data, u16 mem_mask)
{ {
COMBINE_DATA(&m_vram[Layer][offset]); COMBINE_DATA(&m_vram[Layer][offset]);
for (int size = 0; size < 2; size++) for (int size = 0; size < 2; size++)
{ {
m_tilemap[Layer][size]->mark_tile_dirty(offset * 2); m_tilemap[Layer][size]->mark_tile_dirty(offset);
m_tilemap[Layer][size]->mark_tile_dirty(offset * 2 + 1);
} }
} }
template<int Layer> template<int Layer>
TILE_GET_INFO_MEMBER(dreamwld_state::get_tile_info) TILE_GET_INFO_MEMBER(dreamwld_state::get_tile_info)
{ {
int tileno, colour; const u16 tileno = m_vram[Layer][tile_index];
tileno = (tile_index & 1) ? (m_vram[Layer][tile_index >> 1] & 0xffff) : ((m_vram[Layer][tile_index >> 1] >> 16) & 0xffff); const u16 colour = tileno >> 13;
colour = tileno >> 13; SET_TILE_INFO_MEMBER(1, (tileno & 0x1fff) | (m_tilebank[Layer] << 13), (Layer * 0x40) + colour, 0);
tileno &= 0x1fff;
SET_TILE_INFO_MEMBER(1, tileno + m_tilebank[Layer] * 0x2000, (Layer * 0x40) + colour, 0);
} }
@ -288,17 +283,15 @@ void dreamwld_state::video_start()
} }
} }
m_spritebuf[0] = std::make_unique<uint32_t[]>(0x2000 / 4); m_spritebuf[0] = std::make_unique<u32[]>(0x2000 / 4);
m_spritebuf[1] = std::make_unique<uint32_t[]>(0x2000 / 4); m_spritebuf[1] = std::make_unique<u32[]>(0x2000 / 4);
m_lineram16 = make_unique_clear<uint16_t[]>(0x400 / 2);
save_pointer(NAME(m_spritebuf[0]), 0x2000 / 4, 0); save_pointer(NAME(m_spritebuf[0]), 0x2000 / 4, 0);
save_pointer(NAME(m_spritebuf[1]), 0x2000 / 4, 1); save_pointer(NAME(m_spritebuf[1]), 0x2000 / 4, 1);
save_pointer(NAME(m_lineram16), 0x400/2);
} }
WRITE_LINE_MEMBER(dreamwld_state::screen_vblank_dreamwld) WRITE_LINE_MEMBER(dreamwld_state::screen_vblank)
{ {
// rising edge // rising edge
if (state) if (state)
@ -309,15 +302,13 @@ WRITE_LINE_MEMBER(dreamwld_state::screen_vblank_dreamwld)
} }
uint32_t dreamwld_state::screen_update_dreamwld(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) u32 dreamwld_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
tilemap_t *tmptilemap[2]; tilemap_t *tmptilemap[2];
uint32_t scrolly[2]{ m_vregs[(0x000 / 4)]+32, m_vregs[(0x008 / 4)]+32 }; const u32 scrolly[2]{ m_vregs[(0x000 / 4)] + 32, m_vregs[(0x008 / 4)] + 32 };
const u32 scrollx[2]{ m_vregs[(0x004 / 4)] + 0, m_vregs[(0x00c / 4)] + 2 };
uint32_t scrollx[2]{ m_vregs[(0x004 / 4)] + 0, m_vregs[(0x00c / 4)] + 2 }; const u32 layer_ctrl[2]{ m_vregs[0x010 / 4], m_vregs[0x014 / 4] };
uint32_t layer_ctrl[2]{ m_vregs[0x010 / 4], m_vregs[0x014 / 4] };
for (int layer = 0; layer < 2; layer++) for (int layer = 0; layer < 2; layer++)
{ {
@ -331,28 +322,28 @@ uint32_t dreamwld_state::screen_update_dreamwld(screen_device &screen, bitmap_in
} }
// Test mode only, Other size is enable? // Test mode only, Other size is enable?
int size = (layer_ctrl[layer] & 0x0400) >> 10; const int size = (layer_ctrl[layer] & 0x0400) >> 10;
tmptilemap[layer] = m_tilemap[layer][size]; tmptilemap[layer] = m_tilemap[layer][size];
int row_mask = 0x3ff >> size; const int row_mask = 0x3ff >> size;
tmptilemap[layer]->set_scrolly(0, scrolly[layer]); tmptilemap[layer]->set_scrolly(0, scrolly[layer]);
if (layer_ctrl[layer] & 0x0300) if (layer_ctrl[layer] & 0x0300)
{ {
int tile_rowscroll = (layer_ctrl[layer] & 0x0200) >> 7; const int tile_rowscroll = (layer_ctrl[layer] & 0x0200) >> 7;
if (m_old_linescroll[layer] != (layer_ctrl[layer] & 0x0300)) if (m_old_linescroll[layer] != (layer_ctrl[layer] & 0x0300))
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
m_tilemap[layer][i]->set_scroll_rows(((64*16) >> i)); m_tilemap[layer][i]->set_scroll_rows(((64 * 16) >> i));
} }
m_old_linescroll[layer] = (layer_ctrl[layer] & 0x0300); m_old_linescroll[layer] = (layer_ctrl[layer] & 0x0300);
} }
uint16_t* linebase = &m_lineram16[(layer * 0x200) / 2]; const u16* linebase = &m_lineram[(layer * 0x200) / 2];
for (int i = 0; i < 256; i++) /* 256 screen lines */ for (int i = 0; i < 256; i++) /* 256 screen lines */
{ {
/* per-line rowscroll */ /* per-line rowscroll */
int x0 = linebase[((i+32)&0xff) >> tile_rowscroll]; const int x0 = linebase[((i + 32) & 0xff) >> tile_rowscroll];
tmptilemap[layer]->set_scrollx( tmptilemap[layer]->set_scrollx(
(i + scrolly[layer]) & row_mask, (i + scrolly[layer]) & row_mask,
@ -383,14 +374,15 @@ uint32_t dreamwld_state::screen_update_dreamwld(screen_device &screen, bitmap_in
} }
u32 dreamwld_state::protdata_r()
READ32_MEMBER(dreamwld_state::protdata_r)
{ {
//static int count = 0; //static int count = 0;
size_t protsize = m_prot->bytes(); size_t protsize = m_prot->bytes();
uint8_t dat = m_prot->base()[(m_protindex++) % protsize]; const u8 dat = m_prot->base()[m_protindex];
if (!machine().side_effects_disabled())
m_protindex = (m_protindex + 1) % protsize;
//printf("protection read %04x %02x\n", count, dat); //printf("protection read %04x %02x\n", count, dat);
//count++; //count++;
@ -413,12 +405,9 @@ void dreamwld_state::oki2_map(address_map &map)
} }
template<int Chip> template<int Chip>
WRITE32_MEMBER(dreamwld_state::okibank_w) void dreamwld_state::okibank_w(u8 data)
{ {
if (ACCESSING_BITS_0_7) m_okibank[Chip]->set_entry(data & 3);
m_okibank[Chip]->set_entry(data&3);
else
logerror("OKI%x: unk bank write %x mem_mask %8x\n", Chip, data, mem_mask);
} }
@ -428,15 +417,15 @@ void dreamwld_state::baryon_map(address_map &map)
map(0x400000, 0x401fff).ram().share("spriteram"); map(0x400000, 0x401fff).ram().share("spriteram");
map(0x600000, 0x601fff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette"); map(0x600000, 0x601fff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette");
map(0x800000, 0x801fff).ram().w(FUNC(dreamwld_state::vram_w<0>)).share("vram_0"); map(0x800000, 0x801fff).rw(FUNC(dreamwld_state::vram_r<0>), FUNC(dreamwld_state::vram_w<0>)).share("vram_0");
map(0x802000, 0x803fff).ram().w(FUNC(dreamwld_state::vram_w<1>)).share("vram_1"); map(0x802000, 0x803fff).rw(FUNC(dreamwld_state::vram_r<1>), FUNC(dreamwld_state::vram_w<1>)).share("vram_1");
map(0x804000, 0x8043ff).rw(FUNC(dreamwld_state::lineram16_r), FUNC(dreamwld_state::lineram16_w)); // linescroll map(0x804000, 0x8043ff).rw(FUNC(dreamwld_state::lineram_r), FUNC(dreamwld_state::lineram_w)).share("lineram"); // linescroll
map(0x804400, 0x805fff).ram().share("vregs"); map(0x804400, 0x805fff).ram().share("vregs");
map(0xc00000, 0xc00003).portr("INPUTS"); map(0xc00000, 0xc00003).portr("INPUTS");
map(0xc00004, 0xc00007).lr16("c00004", [this]() { return uint16_t(m_dsw->read()); }); map(0xc00004, 0xc00007).lr16("c00004", [this]() { return u16(m_dsw->read()); });
map(0xc0000c, 0xc0000f).w(FUNC(dreamwld_state::okibank_w<0>)); // sfx map(0xc0000f, 0xc0000f).w(FUNC(dreamwld_state::okibank_w<0>)); // sfx
map(0xc00018, 0xc00018).rw("oki1", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); // sfx map(0xc00018, 0xc00018).rw("oki1", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); // sfx
map(0xc00030, 0xc00033).r(FUNC(dreamwld_state::protdata_r)); // it reads protection data (irq code) from here and puts it at ffd000 map(0xc00030, 0xc00033).r(FUNC(dreamwld_state::protdata_r)); // it reads protection data (irq code) from here and puts it at ffd000
@ -448,7 +437,7 @@ void dreamwld_state::dreamwld_map(address_map &map)
{ {
baryon_map(map); baryon_map(map);
map(0xc0002c, 0xc0002f).w(FUNC(dreamwld_state::okibank_w<1>)); // sfx map(0xc0002f, 0xc0002f).w(FUNC(dreamwld_state::okibank_w<1>)); // sfx
map(0xc00028, 0xc00028).rw("oki2", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); // sfx map(0xc00028, 0xc00028).rw("oki2", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); // sfx
} }
@ -723,13 +712,13 @@ void dreamwld_state::machine_start()
{ {
if (m_okibank[0].found()) if (m_okibank[0].found())
{ {
m_okibank[0]->configure_entries(0, 4, memregion("oki1")->base()+0x30000, 0x10000); m_okibank[0]->configure_entries(0, 4, memregion("oki1")->base() + 0x30000, 0x10000);
m_okibank[0]->set_entry(0); m_okibank[0]->set_entry(0);
} }
if (m_okibank[1].found()) if (m_okibank[1].found())
{ {
m_okibank[1]->configure_entries(0, 4, memregion("oki2")->base()+0x30000, 0x10000); m_okibank[1]->configure_entries(0, 4, memregion("oki2")->base() + 0x30000, 0x10000);
m_okibank[1]->set_entry(0); m_okibank[1]->set_entry(0);
} }
@ -761,8 +750,8 @@ void dreamwld_state::baryon(machine_config &config)
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500));
screen.set_size(512,256); screen.set_size(512,256);
screen.set_visarea(0, 308-1, 0, 224-1); screen.set_visarea(0, 308-1, 0, 224-1);
screen.set_screen_update(FUNC(dreamwld_state::screen_update_dreamwld)); screen.set_screen_update(FUNC(dreamwld_state::screen_update));
screen.screen_vblank().set(FUNC(dreamwld_state::screen_vblank_dreamwld)); screen.screen_vblank().set(FUNC(dreamwld_state::screen_vblank));
screen.set_palette(m_palette); screen.set_palette(m_palette);
PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x1000); PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x1000);