thedeep.cpp: use decbac06 device instead of custom routines (nw)

This commit is contained in:
Ivan Vangelista 2019-08-14 18:25:24 +02:00
parent c25c3c79ab
commit 8e727a4abb
5 changed files with 55 additions and 78 deletions

View File

@ -62,14 +62,6 @@ void thedeep_state::machine_start()
save_item(NAME(m_coin_result)); save_item(NAME(m_coin_result));
} }
void thedeep_state::machine_reset()
{
m_scroll[0] = 0;
m_scroll[1] = 0;
m_scroll[2] = 0;
m_scroll[3] = 0;
}
READ8_MEMBER(thedeep_state::protection_r) READ8_MEMBER(thedeep_state::protection_r)
{ {
m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
@ -114,11 +106,12 @@ void thedeep_state::main_map(address_map &map)
map(0xe00b, 0xe00b).portr("e00b"); // DSW2 map(0xe00b, 0xe00b).portr("e00b"); // DSW2
map(0xe00c, 0xe00c).w(m_soundlatch, FUNC(generic_latch_8_device::write)); // To Sound CPU map(0xe00c, 0xe00c).w(m_soundlatch, FUNC(generic_latch_8_device::write)); // To Sound CPU
map(0xe100, 0xe100).w(FUNC(thedeep_state::e100_w)); // ? map(0xe100, 0xe100).w(FUNC(thedeep_state::e100_w)); // ?
map(0xe210, 0xe213).writeonly().share("scroll"); // Scroll map(0xe200, 0xe207).w(m_tilegen, FUNC(deco_bac06_device::pf_control0_8bit_w));
map(0xe400, 0xe7ff).ram().share("spriteram"); // Sprites map(0xe210, 0xe217).w(m_tilegen, FUNC(deco_bac06_device::pf_control1_8bit_swap_w));
map(0xe800, 0xefff).ram().w(FUNC(thedeep_state::vram_1_w)).share("vram_1"); // Text Layer map(0xe400, 0xe7ff).ram().share(m_spriteram); // Sprites
map(0xf000, 0xf7ff).ram().w(FUNC(thedeep_state::vram_0_w)).share("vram_0"); // Background Layer map(0xe800, 0xefff).ram().w(FUNC(thedeep_state::textram_w)).share(m_textram); // Text Layer
map(0xf800, 0xf83f).ram().share("scroll2"); // Column Scroll map(0xf000, 0xf7ff).rw(m_tilegen, FUNC(deco_bac06_device::pf_data_8bit_swap_r), FUNC(deco_bac06_device::pf_data_8bit_swap_w)); // Background Layer
map(0xf800, 0xf83f).rw(m_tilegen, FUNC(deco_bac06_device::pf_colscroll_8bit_swap_r), FUNC(deco_bac06_device::pf_colscroll_8bit_swap_w));
map(0xf840, 0xffff).ram(); map(0xf840, 0xffff).ram();
} }
@ -166,6 +159,7 @@ void thedeep_state::mcu_p1_w(uint8_t data)
membank("bank1")->set_entry((data >> 1) & 0x03); membank("bank1")->set_entry((data >> 1) & 0x03);
flip_screen_set(!BIT(data, 0)); flip_screen_set(!BIT(data, 0));
m_tilegen->set_flip_screen(!BIT(data, 0));
m_spritegen->set_flip_screen(!BIT(data, 0)); m_spritegen->set_flip_screen(!BIT(data, 0));
} }
@ -370,6 +364,11 @@ void thedeep_state::thedeep(machine_config &config)
DECO_MXC06(config, m_spritegen, 0); DECO_MXC06(config, m_spritegen, 0);
DECO_BAC06(config, m_tilegen, 0);
m_tilegen->set_gfx_region_wide(1, 1, 0);
m_tilegen->set_gfxdecode_tag(m_gfxdecode);
m_tilegen->set_thedeep_kludge(); // TODO: this game wants TILE_FLIPX always set. Investigate why.
/* sound hardware */ /* sound hardware */
SPEAKER(config, "mono").front_center(); SPEAKER(config, "mono").front_center();

View File

@ -8,6 +8,7 @@
#include "cpu/mcs51/mcs51.h" #include "cpu/mcs51/mcs51.h"
#include "machine/gen_latch.h" #include "machine/gen_latch.h"
#include "machine/timer.h" #include "machine/timer.h"
#include "video/decbac06.h"
#include "video/decmxc06.h" #include "video/decmxc06.h"
#include "emupal.h" #include "emupal.h"
@ -22,21 +23,18 @@ public:
m_mcu(*this, "mcu"), m_mcu(*this, "mcu"),
m_gfxdecode(*this, "gfxdecode"), m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"), m_palette(*this, "palette"),
m_tilegen(*this, "tilegen"),
m_spritegen(*this, "spritegen"), m_spritegen(*this, "spritegen"),
m_soundlatch(*this, "soundlatch"), m_soundlatch(*this, "soundlatch"),
m_coins(*this, "COINS"), m_coins(*this, "COINS"),
m_spriteram(*this, "spriteram"), m_spriteram(*this, "spriteram"),
m_vram_0(*this, "vram_0"), m_textram(*this, "textram")
m_vram_1(*this, "vram_1"),
m_scroll(*this, "scroll"),
m_scroll2(*this, "scroll2")
{ } { }
void thedeep(machine_config &config); void thedeep(machine_config &config);
protected: protected:
virtual void machine_start() override; virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override; virtual void video_start() override;
private: private:
@ -45,19 +43,16 @@ private:
required_device<i8751_device> m_mcu; required_device<i8751_device> m_mcu;
required_device<gfxdecode_device> m_gfxdecode; required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette; required_device<palette_device> m_palette;
required_device<deco_bac06_device> m_tilegen;
required_device<deco_mxc06_device> m_spritegen; required_device<deco_mxc06_device> m_spritegen;
required_device<generic_latch_8_device> m_soundlatch; required_device<generic_latch_8_device> m_soundlatch;
required_ioport m_coins; required_ioport m_coins;
required_shared_ptr<uint8_t> m_spriteram; required_shared_ptr<uint8_t> m_spriteram;
required_shared_ptr<uint8_t> m_vram_0; required_shared_ptr<uint8_t> m_textram;
required_shared_ptr<uint8_t> m_vram_1;
required_shared_ptr<uint8_t> m_scroll;
required_shared_ptr<uint8_t> m_scroll2;
int m_nmi_enable; int m_nmi_enable;
tilemap_t *m_tilemap_0; tilemap_t *m_text_tilemap;
tilemap_t *m_tilemap_1;
// protection mcu // protection mcu
uint8_t mcu_p0_r(); uint8_t mcu_p0_r();
@ -78,12 +73,9 @@ private:
DECLARE_WRITE8_MEMBER(nmi_w); DECLARE_WRITE8_MEMBER(nmi_w);
DECLARE_WRITE8_MEMBER(e100_w); DECLARE_WRITE8_MEMBER(e100_w);
DECLARE_WRITE8_MEMBER(vram_0_w); DECLARE_WRITE8_MEMBER(textram_w);
DECLARE_WRITE8_MEMBER(vram_1_w);
TILEMAP_MAPPER_MEMBER(tilemap_scan_rows_back); TILE_GET_INFO_MEMBER(get_tile_info);
TILE_GET_INFO_MEMBER(get_tile_info_0);
TILE_GET_INFO_MEMBER(get_tile_info_1);
void thedeep_palette(palette_device &palette) const; void thedeep_palette(palette_device &palette) const;

View File

@ -15,6 +15,7 @@
madmotor.cpp madmotor.cpp
stadhero.cpp stadhero.cpp
pcktgal.cpp pcktgal.cpp
thedeep.cpp
Notes (from dec0.cpp) Notes (from dec0.cpp)
@ -94,6 +95,7 @@ deco_bac06_device::deco_bac06_device(const machine_config &mconfig, const char *
, m_bppmult_16x16(0) , m_bppmult_16x16(0)
, m_bppmask_16x16(0) , m_bppmask_16x16(0)
, m_gfxdecode(*this, finder_base::DUMMY_TAG) , m_gfxdecode(*this, finder_base::DUMMY_TAG)
, m_thedeep_kludge(0)
{ {
std::fill(std::begin(m_pf_control_0), std::end(m_pf_control_0), 0); std::fill(std::begin(m_pf_control_0), std::end(m_pf_control_0), 0);
std::fill(std::begin(m_pf_control_1), std::end(m_pf_control_1), 0); std::fill(std::begin(m_pf_control_1), std::end(m_pf_control_1), 0);
@ -207,7 +209,7 @@ TILE_GET_INFO_MEMBER(deco_bac06_device::get_pf16x16_tile_info)
if (m_rambank & 1) tile_index += 0x1000; if (m_rambank & 1) tile_index += 0x1000;
int tile = m_pf_data[tile_index]; int tile = m_pf_data[tile_index];
int colourpri = (tile >> 12); int colourpri = (tile >> 12);
int flags = (m_pf_control_0[0] & 2) ? 0 : TILE_FLIPX; int flags = (BIT(m_pf_control_0[0], 1) ^ m_thedeep_kludge) ? 0 : TILE_FLIPX;
SET_TILE_INFO_MEMBER(m_tile_region_16,tile & 0xfff,0,flags); SET_TILE_INFO_MEMBER(m_tile_region_16,tile & 0xfff,0,flags);
tileinfo.category = colourpri; tileinfo.category = colourpri;
} }
@ -302,7 +304,7 @@ void deco_bac06_device::custom_tilemap_draw(bitmap_ind16 &bitmap,
Nb2: Real hardware exhibits a strange bug with column scroll on 'mode 2' Nb2: Real hardware exhibits a strange bug with column scroll on 'mode 2'
(256*1024) - the first column has a strange additional offset, but (256*1024) - the first column has a strange additional offset, but
curiously the first 'wrap' (at scroll offset 256) does not have this offset, curiously the first 'wrap' (at scroll offset 256) does not have this offset,
it is displayed as expected. The bug is confimed to only affect this mode, it is displayed as expected. The bug is confirmed to only affect this mode,
the other two modes work as expected. This bug is not emulated, as it the other two modes work as expected. This bug is not emulated, as it
doesn't affect any games. doesn't affect any games.
*/ */
@ -601,6 +603,22 @@ void deco_bac06_device::pf_rowscroll_8bit_swap_w(offs_t offset, u8 data)
pf_rowscroll_w(offset / 2, data, 0x00ff); pf_rowscroll_w(offset / 2, data, 0x00ff);
} }
// used by thedeep
u8 deco_bac06_device::pf_colscroll_8bit_swap_r(offs_t offset)
{
if (offset & 1)
return pf_colscroll_r(offset / 2)>>8;
else
return pf_colscroll_r(offset / 2);
}
void deco_bac06_device::pf_colscroll_8bit_swap_w(offs_t offset, u8 data)
{
if (offset & 1)
pf_colscroll_w(offset / 2, data << 8, 0xff00);
else
pf_colscroll_w(offset / 2, data, 0x00ff);
}
/* used by hippodrm */ /* used by hippodrm */
void deco_bac06_device::pf_control0_8bit_packed_w(offs_t offset, u8 data) void deco_bac06_device::pf_control0_8bit_packed_w(offs_t offset, u8 data)

View File

@ -21,6 +21,7 @@ public:
m_gfxregion16x16 = region16x16; m_gfxregion16x16 = region16x16;
m_wide = wide; m_wide = wide;
} }
void set_thedeep_kludge() { m_thedeep_kludge = 1; } // thedeep requires TILE_FLIPX always set, for reasons to be investigated
void disable_8x8() { m_supports_8x8 = false; } void disable_8x8() { m_supports_8x8 = false; }
void disable_16x16() { m_supports_16x16 = false; } void disable_16x16() { m_supports_16x16 = false; }
void disable_rc_scroll() { m_supports_rc_scroll = false; } void disable_rc_scroll() { m_supports_rc_scroll = false; }
@ -101,6 +102,8 @@ public:
void pf_data_8bit_swap_w(offs_t offset, u8 data); void pf_data_8bit_swap_w(offs_t offset, u8 data);
u8 pf_rowscroll_8bit_swap_r(offs_t offset); u8 pf_rowscroll_8bit_swap_r(offs_t offset);
void pf_rowscroll_8bit_swap_w(offs_t offset, u8 data); void pf_rowscroll_8bit_swap_w(offs_t offset, u8 data);
u8 pf_colscroll_8bit_swap_r(offs_t offset);
void pf_colscroll_8bit_swap_w(offs_t offset, u8 data);
protected: protected:
virtual void device_start() override; virtual void device_start() override;
@ -139,6 +142,8 @@ private:
TILE_GET_INFO_MEMBER(get_pf8x8_tile_info); TILE_GET_INFO_MEMBER(get_pf8x8_tile_info);
TILE_GET_INFO_MEMBER(get_pf16x16_tile_info); TILE_GET_INFO_MEMBER(get_pf16x16_tile_info);
required_device<gfxdecode_device> m_gfxdecode; required_device<gfxdecode_device> m_gfxdecode;
bool m_thedeep_kludge;
}; };
DECLARE_DEVICE_TYPE(DECO_BAC06, deco_bac06_device) DECLARE_DEVICE_TYPE(DECO_BAC06, deco_bac06_device)

View File

@ -40,41 +40,20 @@
***************************************************************************/ ***************************************************************************/
TILEMAP_MAPPER_MEMBER(thedeep_state::tilemap_scan_rows_back) TILE_GET_INFO_MEMBER(thedeep_state::get_tile_info)
{ {
return (col & 0x0f) + ((col & 0x10) << 5) + (row << 4); uint8_t code = m_textram[ tile_index * 2 + 0 ];
} uint8_t color = m_textram[ tile_index * 2 + 1 ];
TILE_GET_INFO_MEMBER(thedeep_state::get_tile_info_0)
{
uint8_t code = m_vram_0[ tile_index * 2 + 0 ];
uint8_t color = m_vram_0[ tile_index * 2 + 1 ];
SET_TILE_INFO_MEMBER(1,
code + (color << 8),
(color & 0xf0) >> 4,
TILE_FLIPX ); // why?
}
TILE_GET_INFO_MEMBER(thedeep_state::get_tile_info_1)
{
uint8_t code = m_vram_1[ tile_index * 2 + 0 ];
uint8_t color = m_vram_1[ tile_index * 2 + 1 ];
SET_TILE_INFO_MEMBER(2, SET_TILE_INFO_MEMBER(2,
code + (color << 8), code + (color << 8),
(color & 0xf0) >> 4, (color & 0xf0) >> 4,
0); 0);
} }
WRITE8_MEMBER(thedeep_state::vram_0_w) WRITE8_MEMBER(thedeep_state::textram_w)
{ {
m_vram_0[offset] = data; m_textram[offset] = data;
m_tilemap_0->mark_tile_dirty(offset / 2); m_text_tilemap->mark_tile_dirty(offset / 2);
}
WRITE8_MEMBER(thedeep_state::vram_1_w)
{
m_vram_1[offset] = data;
m_tilemap_1->mark_tile_dirty(offset / 2);
} }
@ -99,13 +78,9 @@ void thedeep_state::thedeep_palette(palette_device &palette) const
void thedeep_state::video_start() void thedeep_state::video_start()
{ {
m_tilemap_0 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(thedeep_state::get_tile_info_0),this),tilemap_mapper_delegate(FUNC(thedeep_state::tilemap_scan_rows_back),this),16,16,0x20,0x20); m_text_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(thedeep_state::get_tile_info), this), TILEMAP_SCAN_ROWS, 8, 8, 0x20, 0x20);
m_tilemap_1 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(thedeep_state::get_tile_info_1),this),TILEMAP_SCAN_ROWS,8,8,0x20,0x20);
m_tilemap_0->set_transparent_pen(0 ); m_text_tilemap->set_transparent_pen(0);
m_tilemap_1->set_transparent_pen(0 );
m_tilemap_0->set_scroll_cols(0x20); // column scroll for the background
} }
/*************************************************************************** /***************************************************************************
@ -116,22 +91,10 @@ void thedeep_state::video_start()
uint32_t thedeep_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) uint32_t thedeep_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
int scrollx = m_scroll[0] + (m_scroll[1]<<8);
int scrolly = m_scroll[2] + (m_scroll[3]<<8);
int x;
m_tilemap_0->set_scrollx(0, scrollx);
for (x = 0; x < 0x20; x++)
{
int y = m_scroll2[x*2+0] + (m_scroll2[x*2+1]<<8);
m_tilemap_0->set_scrolly(x, y + scrolly);
}
bitmap.fill(m_palette->black_pen(), cliprect); bitmap.fill(m_palette->black_pen(), cliprect);
m_tilemap_0->draw(screen, bitmap, cliprect, 0,0); m_tilegen->deco_bac06_pf_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 0);
m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(0), reinterpret_cast<uint16_t *>(m_spriteram.target()), 0x400/2); m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(0), reinterpret_cast<uint16_t *>(m_spriteram.target()), 0x400/2);
m_tilemap_1->draw(screen, bitmap, cliprect, 0,0); m_text_tilemap->draw(screen, bitmap, cliprect, 0,0);
return 0; return 0;
} }