1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /*************************************************************************
4 
5     Mitchell hardware
6 
7 *************************************************************************/
8 
9 #include "machine/74157.h"
10 #include "machine/nvram.h"
11 #include "machine/eepromser.h"
12 #include "machine/gen_latch.h"
13 #include "machine/timer.h"
14 #include "sound/msm5205.h"
15 #include "sound/okim6295.h"
16 #include "emupal.h"
17 #include "tilemap.h"
18 
19 class mitchell_state : public driver_device
20 {
21 public:
mitchell_state(const machine_config & mconfig,device_type type,const char * tag)22 	mitchell_state(const machine_config &mconfig, device_type type, const char *tag)
23 		: driver_device(mconfig, type, tag),
24 		m_maincpu(*this, "maincpu"),
25 		m_audiocpu(*this, "audiocpu"),
26 		m_oki(*this, "oki"),
27 		m_nvram(*this, "nvram"),
28 		m_eeprom(*this, "eeprom"),
29 		m_msm(*this, "msm"),
30 		m_adpcm_select(*this, "adpcm_select"),
31 		m_gfxdecode(*this, "gfxdecode"),
32 		m_palette(*this, "palette"),
33 		m_soundlatch(*this, "soundlatch"),
34 		m_colorram(*this, "colorram"),
35 		m_videoram(*this, "videoram"),
36 		m_bank1(*this, "bank1"),
37 		m_bank0d(*this, "bank0d"),
38 		m_bank1d(*this, "bank1d"),
39 		m_soundbank(*this, "soundbank") { }
40 
41 	void pkladiesbl(machine_config &config);
42 	void mstworld(machine_config &config);
43 	void mgakuen(machine_config &config);
44 	void marukin(machine_config &config);
45 	void pang(machine_config &config);
46 	void pangba(machine_config &config);
47 	void pangnv(machine_config &config);
48 	void spangbl(machine_config &config);
49 
50 	void init_mgakuen2();
51 	void init_block();
52 	void init_pangb();
53 	void init_qtono1();
54 	void init_mgakuen();
55 	void init_hatena();
56 	void init_mstworld();
57 	void init_spangbl();
58 	void init_pkladiesbl();
59 	void init_spang();
60 	void init_cworld();
61 	void init_spangj();
62 	void init_qsangoku();
63 	void init_marukin();
64 	void init_pang();
65 	void init_sbbros();
66 	void init_pkladies();
67 	void init_blockbl();
68 	void init_dokaben();
69 
70 private:
71 	/* devices */
72 	required_device<cpu_device> m_maincpu;
73 	optional_device<cpu_device> m_audiocpu;
74 	optional_device<okim6295_device> m_oki;
75 	optional_device<nvram_device> m_nvram;
76 	optional_device<eeprom_serial_93cxx_device> m_eeprom;
77 	optional_device<msm5205_device> m_msm;
78 	optional_device<ls157_device> m_adpcm_select;
79 	required_device<gfxdecode_device> m_gfxdecode;
80 	required_device<palette_device> m_palette;
81 	optional_device<generic_latch_8_device> m_soundlatch;
82 
83 	/* memory pointers */
84 	required_shared_ptr<uint8_t> m_colorram;
85 	required_shared_ptr<uint8_t> m_videoram;
86 	required_memory_bank m_bank1;
87 	optional_memory_bank m_bank0d;
88 	optional_memory_bank m_bank1d;
89 	optional_memory_bank m_soundbank;
90 
91 	/* video-related */
92 	tilemap_t    *m_bg_tilemap;
93 	std::vector<uint8_t> m_objram;           /* Sprite RAM */
94 	int        m_flipscreen;
95 	int        m_video_bank;
96 	int        m_paletteram_bank;
97 	std::vector<uint8_t> m_paletteram;
98 
99 	/* sound-related */
100 	bool       m_sample_select;
101 
102 	/* misc */
103 	int        m_input_type;
104 	int        m_dial[2];
105 	int        m_dial_selected;
106 	int        m_dir[2];
107 	int        m_keymatrix;
108 
109 	uint8_t m_irq_source;
110 	uint8_t pang_port5_r();
111 	void pang_bankswitch_w(uint8_t data);
112 	uint8_t block_input_r(offs_t offset);
113 	void block_dial_control_w(uint8_t data);
114 	uint8_t mahjong_input_r(offs_t offset);
115 	void mahjong_input_select_w(uint8_t data);
116 	uint8_t input_r(offs_t offset);
117 	void input_w(uint8_t data);
118 	void mstworld_sound_w(uint8_t data);
119 	void pang_video_bank_w(uint8_t data);
120 	void mstworld_video_bank_w(uint8_t data);
121 	void mgakuen_videoram_w(offs_t offset, uint8_t data);
122 	uint8_t mgakuen_videoram_r(offs_t offset);
123 	void mgakuen_objram_w(offs_t offset, uint8_t data);
124 	uint8_t mgakuen_objram_r(offs_t offset);
125 	void pang_videoram_w(offs_t offset, uint8_t data);
126 	uint8_t pang_videoram_r(offs_t offset);
127 	void pang_colorram_w(offs_t offset, uint8_t data);
128 	uint8_t pang_colorram_r(offs_t offset);
129 	void pang_gfxctrl_w(uint8_t data);
130 	void pangbl_gfxctrl_w(uint8_t data);
131 	void mstworld_gfxctrl_w(uint8_t data);
132 	void pang_paletteram_w(offs_t offset, uint8_t data);
133 	uint8_t pang_paletteram_r(offs_t offset);
134 	void eeprom_cs_w(uint8_t data);
135 	void eeprom_clock_w(uint8_t data);
136 	void eeprom_serial_w(uint8_t data);
137 	void oki_banking_w(uint8_t data);
138 
139 	TILE_GET_INFO_MEMBER(get_tile_info);
140 	DECLARE_MACHINE_START(mitchell);
141 	DECLARE_MACHINE_RESET(mitchell);
142 	DECLARE_VIDEO_START(pang);
143 	uint32_t screen_update_pang(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
144 	TIMER_DEVICE_CALLBACK_MEMBER(mitchell_irq);
145 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
146 	void bootleg_decode();
147 	void configure_banks(void (*decode)(uint8_t *src, uint8_t *dst, int size));
148 	void sound_bankswitch_w(uint8_t data);
149 	DECLARE_WRITE_LINE_MEMBER(spangbl_adpcm_int);
150 
151 	void decrypted_opcodes_map(address_map &map);
152 	void mgakuen_map(address_map &map);
153 	void mitchell_io_map(address_map &map);
154 	void mitchell_map(address_map &map);
155 	void mstworld_io_map(address_map &map);
156 	void mstworld_sound_map(address_map &map);
157 	void pangba_sound_map(address_map &map);
158 	void pkladiesbl_io_map(address_map &map);
159 	void spangbl_io_map(address_map &map);
160 	void spangbl_map(address_map &map);
161 	void spangbl_sound_map(address_map &map);
162 };
163