1 // license:BSD-3-Clause
2 // copyright-holders:S. Smith,David Haywood,Fabio Priuli
3 /***********************************************************************************************************
4 
5  Neo Geo cart emulation
6  Misc. bootleg cart types (possibly to be split further at a later stage)
7 
8  ***********************************************************************************************************/
9 
10 
11 #include "emu.h"
12 #include "boot_misc.h"
13 
14 
15 //-------------------------------------------------
16 //  neogeo_bootleg_cart_device - constructor
17 //-------------------------------------------------
18 
19 DEFINE_DEVICE_TYPE(NEOGEO_BOOTLEG_CART, neogeo_bootleg_cart_device, "neocart_boot", "Neo Geo Bootleg Protected Cart")
20 
21 
neogeo_bootleg_cart_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint16_t clock)22 neogeo_bootleg_cart_device::neogeo_bootleg_cart_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint16_t clock) :
23 	neogeo_rom_device(mconfig, type, tag, owner, clock),
24 	m_prot(*this, "bootleg_prot")
25 {
26 }
27 
neogeo_bootleg_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint16_t clock)28 neogeo_bootleg_cart_device::neogeo_bootleg_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint16_t clock) :
29 	neogeo_bootleg_cart_device(mconfig, NEOGEO_BOOTLEG_CART, tag, owner, clock)
30 {
31 }
32 
33 
34 //-------------------------------------------------
35 //  mapper specific start/reset
36 //-------------------------------------------------
37 
device_start()38 void neogeo_bootleg_cart_device::device_start()
39 {
40 }
41 
device_reset()42 void neogeo_bootleg_cart_device::device_reset()
43 {
44 }
45 
46 
47 /*-------------------------------------------------
48  mapper specific handlers
49  -------------------------------------------------*/
50 
device_add_mconfig(machine_config & config)51 void neogeo_bootleg_cart_device::device_add_mconfig(machine_config &config)
52 {
53 	NEOBOOT_PROT(config, m_prot);
54 }
55 
56 
57 /*************************************************
58  garoubl
59 **************************************************/
60 
61 DEFINE_DEVICE_TYPE(NEOGEO_GAROUBL_CART, neogeo_garoubl_cart_device, "neocart_garoubl", "Neo Geo Garou Bootleg Cart")
62 
neogeo_garoubl_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)63 neogeo_garoubl_cart_device::neogeo_garoubl_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
64 	neogeo_bootleg_cart_device(mconfig, NEOGEO_GAROUBL_CART, tag, owner, clock)
65 {
66 }
67 
68 
decrypt_all(DECRYPT_ALL_PARAMS)69 void neogeo_garoubl_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
70 {
71 	m_prot->sx_decrypt(fix_region, fix_region_size, 2);
72 	m_prot->cx_decrypt(spr_region, spr_region_size);
73 }
74 
75 
76 /*************************************************
77  kof97oro
78  **************************************************/
79 
80 DEFINE_DEVICE_TYPE(NEOGEO_KOF97ORO_CART, neogeo_kof97oro_cart_device, "neocart_kof97oro", "Neo Geo KoF 97 Orochi Bootleg Cart")
81 
neogeo_kof97oro_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)82 neogeo_kof97oro_cart_device::neogeo_kof97oro_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
83 	neogeo_bootleg_cart_device(mconfig, NEOGEO_KOF97ORO_CART, tag, owner, clock)
84 {
85 }
86 
87 
decrypt_all(DECRYPT_ALL_PARAMS)88 void neogeo_kof97oro_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
89 {
90 	m_prot->kof97oro_px_decode(cpuregion, cpuregion_size);
91 	m_prot->sx_decrypt(fix_region, fix_region_size,1);
92 	m_prot->cx_decrypt(spr_region, spr_region_size);
93 }
94 
95 
96 /*************************************************
97  kf10thep
98 **************************************************/
99 
100 DEFINE_DEVICE_TYPE(NEOGEO_KF10THEP_CART, neogeo_kf10thep_cart_device, "neocart_kf10thep", "Neo Geo KoF 10th Ann. EP Bootleg Cart")
101 
neogeo_kf10thep_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)102 neogeo_kf10thep_cart_device::neogeo_kf10thep_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
103 	neogeo_bootleg_cart_device(mconfig, NEOGEO_KF10THEP_CART, tag, owner, clock)
104 {
105 }
106 
107 
decrypt_all(DECRYPT_ALL_PARAMS)108 void neogeo_kf10thep_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
109 {
110 	m_prot->kf10thep_px_decrypt(cpuregion, cpuregion_size);
111 	m_prot->sx_decrypt(fix_region, fix_region_size, 1);
112 }
113 
114 
115 /*************************************************
116  kf2k5uni
117 **************************************************/
118 
119 DEFINE_DEVICE_TYPE(NEOGEO_KF2K5UNI_CART, neogeo_kf2k5uni_cart_device, "neocart_kf2k5uni", "Neo Geo KoF 2005 Unique Bootleg Cart")
120 
neogeo_kf2k5uni_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)121 neogeo_kf2k5uni_cart_device::neogeo_kf2k5uni_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
122 	neogeo_bootleg_cart_device(mconfig, NEOGEO_KF2K5UNI_CART, tag, owner, clock)
123 {
124 }
125 
126 
decrypt_all(DECRYPT_ALL_PARAMS)127 void neogeo_kf2k5uni_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
128 {
129 	m_prot->kf2k5uni_px_decrypt(cpuregion, cpuregion_size);
130 	m_prot->kf2k5uni_sx_decrypt(fix_region, fix_region_size);
131 	m_prot->kf2k5uni_mx_decrypt(audiocpu_region, audio_region_size);
132 }
133 
134 
135 /*************************************************
136  kf2k4se
137 **************************************************/
138 
139 DEFINE_DEVICE_TYPE(NEOGEO_KF2K4SE_CART, neogeo_kf2k4se_cart_device, "neocart_kf2k4se", "Neo Geo KoF 2004 SE Bootleg Cart")
140 
neogeo_kf2k4se_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)141 neogeo_kf2k4se_cart_device::neogeo_kf2k4se_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
142 	neogeo_bootleg_cart_device(mconfig, NEOGEO_KF2K4SE_CART, tag, owner, clock)
143 {
144 }
145 
146 
decrypt_all(DECRYPT_ALL_PARAMS)147 void neogeo_kf2k4se_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
148 {
149 	m_prot->decrypt_kof2k4se_68k(cpuregion, cpuregion_size);
150 }
151 
152 
153 /*************************************************
154  lans2004
155  **************************************************/
156 
157 DEFINE_DEVICE_TYPE(NEOGEO_LANS2004_CART, neogeo_lans2004_cart_device, "neocart_lans2004", "Neo Geo Lansquenet 2004 Bootleg Cart")
158 
neogeo_lans2004_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)159 neogeo_lans2004_cart_device::neogeo_lans2004_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
160 	neogeo_bootleg_cart_device(mconfig, NEOGEO_LANS2004_CART, tag, owner, clock)
161 {
162 }
163 
decrypt_all(DECRYPT_ALL_PARAMS)164 void neogeo_lans2004_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
165 {
166 	m_prot->lans2004_decrypt_68k(cpuregion, cpuregion_size);
167 	m_prot->lans2004_vx_decrypt(ym_region, ym_region_size);
168 	m_prot->sx_decrypt(fix_region, fix_region_size,1);
169 	m_prot->cx_decrypt(spr_region, spr_region_size);
170 }
171 
172 
173 /*************************************************
174  samsho5b
175 **************************************************/
176 
177 DEFINE_DEVICE_TYPE(NEOGEO_SAMSHO5B_CART, neogeo_samsho5b_cart_device, "neocart_samsho5b", "Neo Geo Samurai Shodown 5 Bootleg Cart")
178 
neogeo_samsho5b_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)179 neogeo_samsho5b_cart_device::neogeo_samsho5b_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
180 	neogeo_bootleg_cart_device(mconfig, NEOGEO_SAMSHO5B_CART, tag, owner, clock)
181 {
182 }
183 
decrypt_all(DECRYPT_ALL_PARAMS)184 void neogeo_samsho5b_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
185 {
186 	m_prot->samsho5b_px_decrypt(cpuregion, cpuregion_size);
187 	m_prot->samsho5b_vx_decrypt(ym_region, ym_region_size);
188 	m_prot->sx_decrypt(fix_region, fix_region_size, 1);
189 	m_prot->cx_decrypt(spr_region, spr_region_size);
190 }
191 
192 
193 /*************************************************
194  mslug3b6
195  **************************************************/
196 
197 DEFINE_DEVICE_TYPE(NEOGEO_MSLUG3B6_CART, neogeo_mslug3b6_cart_device, "neocart_mslug3b6", "Neo Geo Metal Slug 6 Bootleg Cart")
198 
neogeo_mslug3b6_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)199 neogeo_mslug3b6_cart_device::neogeo_mslug3b6_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
200 	neogeo_bootleg_cart_device(mconfig, NEOGEO_MSLUG3B6_CART, tag, owner, clock),
201 	m_cmc_prot(*this, "cmc_prot")
202 {
203 }
204 
decrypt_all(DECRYPT_ALL_PARAMS)205 void neogeo_mslug3b6_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
206 {
207 	m_prot->sx_decrypt(fix_region, fix_region_size, 2);
208 	m_cmc_prot->cmc42_gfx_decrypt(spr_region, spr_region_size, MSLUG3_GFX_KEY);
209 }
210 
device_add_mconfig(machine_config & config)211 void neogeo_mslug3b6_cart_device::device_add_mconfig(machine_config &config)
212 {
213 	NG_CMC_PROT(config, m_cmc_prot);
214 	NEOBOOT_PROT(config, m_prot);
215 }
216 
217 
218 /*************************************************
219  ms5plus
220  **************************************************/
221 
222 DEFINE_DEVICE_TYPE(NEOGEO_MS5PLUS_CART, neogeo_ms5plus_cart_device, "neocart_ms5plus", "Neo Geo Metal Slug 5 Plus Bootleg Cart")
223 
neogeo_ms5plus_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)224 neogeo_ms5plus_cart_device::neogeo_ms5plus_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
225 	neogeo_bootleg_cart_device(mconfig, NEOGEO_MS5PLUS_CART, tag, owner, clock),
226 	m_cmc_prot(*this, "cmc_prot"),
227 	m_pcm2_prot(*this, "pcm2_prot")
228 {
229 }
230 
decrypt_all(DECRYPT_ALL_PARAMS)231 void neogeo_ms5plus_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
232 {
233 	m_cmc_prot->cmc50_m1_decrypt(audiocrypt_region, audiocrypt_region_size, audiocpu_region,audio_region_size);
234 	m_cmc_prot->cmc50_gfx_decrypt(spr_region, spr_region_size, MSLUG5_GFX_KEY);
235 	m_pcm2_prot->swap(ym_region, ym_region_size, 2);
236 	m_prot->sx_decrypt(fix_region, fix_region_size, 1);
237 }
238 
device_add_mconfig(machine_config & config)239 void neogeo_ms5plus_cart_device::device_add_mconfig(machine_config &config)
240 {
241 	NEOBOOT_PROT(config, m_prot);
242 	NG_CMC_PROT(config, m_cmc_prot);
243 	NG_PCM2_PROT(config, m_pcm2_prot);
244 }
245 
246 
247 /*************************************************
248  mslug5b
249  **************************************************/
250 
251 DEFINE_DEVICE_TYPE(NEOGEO_MSLUG5B_CART, neogeo_mslug5b_cart_device, "neocart_mslug5b", "Neo Geo Metal Slug 5 Bootleg Cart")
252 
neogeo_mslug5b_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)253 neogeo_mslug5b_cart_device::neogeo_mslug5b_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
254 	neogeo_bootleg_cart_device(mconfig, NEOGEO_MSLUG5B_CART, tag, owner, clock)
255 {
256 }
257 
decrypt_all(DECRYPT_ALL_PARAMS)258 void neogeo_mslug5b_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
259 {
260 	m_prot->mslug5b_vx_decrypt(ym_region, ym_region_size);
261 	m_prot->sx_decrypt(fix_region, fix_region_size, 2);
262 	m_prot->mslug5b_cx_decrypt(spr_region, spr_region_size);
263 }
264 
265 
266 /*************************************************
267  kog
268 **************************************************/
269 
270 DEFINE_DEVICE_TYPE(NEOGEO_KOG_CART, neogeo_kog_cart_device, "neocart_kog", "Neo Geo King of Gladiators Bootleg Cart")
271 
neogeo_kog_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)272 neogeo_kog_cart_device::neogeo_kog_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
273 	neogeo_bootleg_cart_device(mconfig, NEOGEO_KOG_CART, tag, owner, clock),
274 	m_jumper(*this, "JUMPER")
275 {
276 }
277 
278 
279 static INPUT_PORTS_START( kog )
280 	// a jumper on the pcb overlays a ROM address, very strange but that's how it works.
281 	PORT_START("JUMPER")
282 	PORT_DIPNAME( 0x0001, 0x0001, "Title Language" ) PORT_DIPLOCATION("CART-JUMPER:1")
DEF_STR(English)283 	PORT_DIPSETTING(      0x0001, DEF_STR( English ) )
284 	PORT_DIPSETTING(      0x0000, "Non-English" )
285 	PORT_BIT( 0x00fe, IP_ACTIVE_HIGH, IPT_UNUSED )
286 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
287 INPUT_PORTS_END
288 
289 ioport_constructor neogeo_kog_cart_device::device_input_ports() const
290 {
291 	return INPUT_PORTS_NAME( kog );
292 }
293 
294 
protection_r(address_space & space,offs_t offset)295 uint16_t neogeo_kog_cart_device::protection_r(address_space &space, offs_t offset)
296 {
297 	return m_jumper->read();
298 }
299 
decrypt_all(DECRYPT_ALL_PARAMS)300 void neogeo_kog_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
301 {
302 	m_prot->kog_px_decrypt(cpuregion, cpuregion_size);
303 	m_prot->sx_decrypt(fix_region, fix_region_size, 1);
304 	m_prot->cx_decrypt(spr_region, spr_region_size);
305 }
306