// license:BSD-3-Clause
// copyright-holders:David Haywood,Bryan McPhail
#include "machine/gen_latch.h"
#include "video/decospr.h"
#include "sound/okim6295.h"
class tumbleb_state : public driver_device
{
public:
tumbleb_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_mainram(*this, "mainram"),
m_spriteram(*this, "spriteram"),
m_pf1_data(*this, "pf1_data"),
m_pf2_data(*this, "pf2_data"),
m_control(*this, "control"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_oki(*this, "oki"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_sprgen(*this, "spritegen"),
m_soundlatch(*this, "soundlatch")
{ }
/* memory pointers */
optional_shared_ptr<uint16_t> m_mainram;
required_shared_ptr<uint16_t> m_spriteram;
required_shared_ptr<uint16_t> m_pf1_data;
required_shared_ptr<uint16_t> m_pf2_data;
optional_shared_ptr<uint16_t> m_control;
/* misc */
int m_music_command;
int m_music_bank;
int m_music_is_playing;
/* video-related */
tilemap_t *m_pf1_tilemap;
tilemap_t *m_pf1_alt_tilemap;
tilemap_t *m_pf2_tilemap;
tilemap_t *m_pf2_alt_tilemap;
uint16_t m_control_0[8];
uint16_t m_tilebank;
/* devices */
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
required_device<okim6295_device> m_oki;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
optional_device<decospr_device> m_sprgen;
optional_device<generic_latch_8_device> m_soundlatch;
uint8_t m_semicom_prot_offset;
uint16_t m_protbase;
DECLARE_WRITE16_MEMBER(tumblepb_oki_w);
DECLARE_READ16_MEMBER(tumblepb_prot_r);
DECLARE_READ16_MEMBER(tumblepopb_controls_r);
DECLARE_READ16_MEMBER(semibase_unknown_r);
DECLARE_WRITE16_MEMBER(jumpkids_sound_w);
DECLARE_WRITE16_MEMBER(semicom_soundcmd_w);
DECLARE_WRITE8_MEMBER(oki_sound_bank_w);
DECLARE_WRITE8_MEMBER(jumpkids_oki_bank_w);
DECLARE_WRITE8_MEMBER(prot_p0_w);
DECLARE_WRITE8_MEMBER(prot_p1_w);
DECLARE_WRITE8_MEMBER(prot_p2_w);
DECLARE_READ16_MEMBER(bcstory_1a0_read);
DECLARE_WRITE16_MEMBER(bcstory_tilebank_w);
DECLARE_WRITE16_MEMBER(chokchok_tilebank_w);
DECLARE_WRITE16_MEMBER(wlstar_tilebank_w);
DECLARE_WRITE16_MEMBER(suprtrio_tilebank_w);
DECLARE_WRITE16_MEMBER(tumblepb_pf1_data_w);
DECLARE_WRITE16_MEMBER(tumblepb_pf2_data_w);
DECLARE_WRITE16_MEMBER(fncywld_pf1_data_w);
DECLARE_WRITE16_MEMBER(fncywld_pf2_data_w);
DECLARE_WRITE16_MEMBER(tumblepb_control_0_w);
DECLARE_WRITE16_MEMBER(pangpang_pf1_data_w);
DECLARE_WRITE16_MEMBER(pangpang_pf2_data_w);
DECLARE_WRITE16_MEMBER(tumbleb2_soundmcu_w);
void init_dquizgo();
void init_jumpkids();
void init_htchctch();
void init_wlstar();
void init_suprtrio();
void init_tumblepb();
void init_tumblepba();
void init_bcstory();
void init_wondl96();
void init_tumbleb2();
void init_chokchok();
void init_fncywld();
void init_carket();
TILEMAP_MAPPER_MEMBER(tumblep_scan);
TILE_GET_INFO_MEMBER(get_bg1_tile_info);
TILE_GET_INFO_MEMBER(get_bg2_tile_info);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
TILE_GET_INFO_MEMBER(get_fncywld_bg1_tile_info);
TILE_GET_INFO_MEMBER(get_fncywld_bg2_tile_info);
TILE_GET_INFO_MEMBER(get_fncywld_fg_tile_info);
TILE_GET_INFO_MEMBER(pangpang_get_bg1_tile_info);
TILE_GET_INFO_MEMBER(pangpang_get_bg2_tile_info);
TILE_GET_INFO_MEMBER(pangpang_get_fg_tile_info);
DECLARE_MACHINE_START(tumbleb);
DECLARE_MACHINE_RESET(tumbleb);
DECLARE_VIDEO_START(tumblepb);
DECLARE_VIDEO_START(fncywld);
DECLARE_MACHINE_RESET(htchctch);
DECLARE_VIDEO_START(suprtrio);
DECLARE_VIDEO_START(pangpang);
DECLARE_VIDEO_START(sdfight);
uint32_t screen_update_tumblepb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_jumpkids(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_fncywld(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_semicom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_suprtrio(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_pangpang(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_semicom_altoffsets(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_bcstory(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_semibase(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_sdfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(tumbleb2_interrupt);
void tumbleb_tilemap_redraw();
inline void get_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, uint16_t *gfx_base);
inline void get_fncywld_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, uint16_t *gfx_base);
inline void pangpang_get_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, uint16_t *gfx_base );
inline void pangpang_get_bg2x_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, uint16_t *gfx_base );
void tumbleb_draw_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pf1x_offs, int pf1y_offs, int pf2x_offs, int pf2y_offs);
void tumbleb2_set_music_bank( int bank );
void tumbleb2_play_sound( okim6295_device *oki, int data );
void tumbleb2_playmusic(okim6295_device *oki);
void process_tumbleb2_music_command( okim6295_device *oki, int data );
void tumblepb_gfx_rearrange(int rgn);
void suprtrio_decrypt_code();
void suprtrio_decrypt_gfx();
void tumblepb(machine_config &config);
void bcstory(machine_config &config);
void pangpang(machine_config &config);
void semibase(machine_config &config);
void tumbleb2(machine_config &config);
void cookbib(machine_config &config);
void metlsavr(machine_config &config);
void fncywld(machine_config &config);
void suprtrio(machine_config &config);
void htchctch(machine_config &config);
void sdfight(machine_config &config);
void chokchok(machine_config &config);
void cookbib_mcu(machine_config &config);
void jumpkids(machine_config &config);
void fncywld_main_map(address_map &map);
void htchctch_main_map(address_map &map);
void jumpkids_main_map(address_map &map);
void jumpkids_sound_map(address_map &map);
void pangpang_main_map(address_map &map);
void semicom_sound_map(address_map &map);
void suprtrio_main_map(address_map &map);
void suprtrio_sound_map(address_map &map);
void tumblepopb_main_map(address_map &map);
};