1 // license:BSD-3-Clause
2 // copyright-holders:S. Smith,David Haywood,Fabio Priuli
3 /***********************************************************************************************************
4 
5  Neo Geo cart emulation
6  SMA encrypted cart type (+ CMC42 or CMC50)
7 
8  ***********************************************************************************************************/
9 
10 
11 #include "emu.h"
12 #include "sma.h"
13 
14 
15 DEFINE_DEVICE_TYPE(NEOGEO_SMA_CART,         neogeo_sma_cart_device,         "neocart_sma",     "Neo Geo SMA Cart")
16 DEFINE_DEVICE_TYPE(NEOGEO_SMA_KOF99_CART,   neogeo_sma_kof99_cart_device,   "neocart_kof99",   "Neo Geo KoF 99 SMA Cart")
17 DEFINE_DEVICE_TYPE(NEOGEO_SMA_GAROU_CART,   neogeo_sma_garou_cart_device,   "neocart_garou",   "Neo Geo Garou SMA Cart")
18 DEFINE_DEVICE_TYPE(NEOGEO_SMA_GAROUH_CART,  neogeo_sma_garouh_cart_device,  "neocart_garouh",  "Neo Geo Garou AES SMA Cart")
19 DEFINE_DEVICE_TYPE(NEOGEO_SMA_MSLUG3_CART,  neogeo_sma_mslug3_cart_device,  "neocart_mslug3",  "Neo Geo Metal Slug 3 SMA Cart (green)")
20 DEFINE_DEVICE_TYPE(NEOGEO_SMA_MSLUG3A_CART, neogeo_sma_mslug3a_cart_device, "neocart_mslug3a", "Neo Geo Metal Slug 3 SMA Cart (white)")
21 DEFINE_DEVICE_TYPE(NEOGEO_SMA_KOF2000_CART, neogeo_sma_kof2000_cart_device, "neocart_kof2000", "Neo Geo KoF 2000 SMA Cart")
22 
23 
24 //-------------------------------------------------
25 //  neogeo_sma_cart_device - constructor
26 //-------------------------------------------------
27 
neogeo_sma_cart_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint16_t clock)28 neogeo_sma_cart_device::neogeo_sma_cart_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint16_t clock) :
29 	neogeo_rom_device(mconfig, type, tag, owner, clock),
30 	m_sma_prot(*this, "sma_prot"),
31 	m_cmc_prot(*this, "cmc_prot")
32 {
33 }
34 
neogeo_sma_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint16_t clock)35 neogeo_sma_cart_device::neogeo_sma_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint16_t clock) :
36 	neogeo_sma_cart_device(mconfig, NEOGEO_SMA_CART, tag, owner, clock)
37 {
38 }
39 
40 
41 //-------------------------------------------------
42 //  mapper specific start/reset
43 //-------------------------------------------------
44 
device_start()45 void neogeo_sma_cart_device::device_start()
46 {
47 }
48 
device_reset()49 void neogeo_sma_cart_device::device_reset()
50 {
51 }
52 
53 
54 /*-------------------------------------------------
55  mapper specific handlers
56  -------------------------------------------------*/
57 
device_add_mconfig(machine_config & config)58 void neogeo_sma_cart_device::device_add_mconfig(machine_config &config)
59 {
60 	NG_SMA_PROT(config, m_sma_prot);
61 	NG_CMC_PROT(config, m_cmc_prot);
62 }
63 
64 
65 /*************************************************
66  kof99
67 **************************************************/
68 
neogeo_sma_kof99_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)69 neogeo_sma_kof99_cart_device::neogeo_sma_kof99_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
70 	neogeo_sma_cart_device(mconfig, NEOGEO_SMA_KOF99_CART, tag, owner, clock)
71 {
72 }
73 
decrypt_all(DECRYPT_ALL_PARAMS)74 void neogeo_sma_kof99_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
75 {
76 	m_sma_prot->kof99_decrypt_68k(cpuregion);
77 	m_cmc_prot->cmc42_gfx_decrypt(spr_region, spr_region_size, KOF99_GFX_KEY);
78 	m_cmc_prot->sfix_decrypt(spr_region, spr_region_size, fix_region, fix_region_size);
79 }
80 
81 
82 /*************************************************
83  garou
84 **************************************************/
85 
neogeo_sma_garou_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)86 neogeo_sma_garou_cart_device::neogeo_sma_garou_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
87 	neogeo_sma_cart_device(mconfig, NEOGEO_SMA_GAROU_CART, tag, owner, clock)
88 {
89 }
90 
decrypt_all(DECRYPT_ALL_PARAMS)91 void neogeo_sma_garou_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
92 {
93 	m_sma_prot->garou_decrypt_68k(cpuregion);
94 	m_cmc_prot->cmc42_gfx_decrypt(spr_region, spr_region_size, GAROU_GFX_KEY);
95 	m_cmc_prot->sfix_decrypt(spr_region, spr_region_size, fix_region, fix_region_size);
96 }
97 
98 
99 /*************************************************
100  garouh
101  **************************************************/
102 
neogeo_sma_garouh_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)103 neogeo_sma_garouh_cart_device::neogeo_sma_garouh_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
104 	neogeo_sma_cart_device(mconfig, NEOGEO_SMA_GAROUH_CART, tag, owner, clock)
105 {
106 }
107 
decrypt_all(DECRYPT_ALL_PARAMS)108 void neogeo_sma_garouh_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
109 {
110 	m_sma_prot->garouh_decrypt_68k(cpuregion);
111 	m_cmc_prot->cmc42_gfx_decrypt(spr_region, spr_region_size, GAROU_GFX_KEY);
112 	m_cmc_prot->sfix_decrypt(spr_region, spr_region_size, fix_region, fix_region_size);
113 }
114 
115 
116 /*************************************************
117  mslug3
118  **************************************************/
119 
neogeo_sma_mslug3_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)120 neogeo_sma_mslug3_cart_device::neogeo_sma_mslug3_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
121 	neogeo_sma_cart_device(mconfig, NEOGEO_SMA_MSLUG3_CART, tag, owner, clock)
122 {
123 }
124 
decrypt_all(DECRYPT_ALL_PARAMS)125 void neogeo_sma_mslug3_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
126 {
127 	m_sma_prot->mslug3_decrypt_68k(cpuregion);
128 	m_cmc_prot->cmc42_gfx_decrypt(spr_region, spr_region_size, MSLUG3_GFX_KEY);
129 	m_cmc_prot->sfix_decrypt(spr_region, spr_region_size, fix_region, fix_region_size);
130 }
131 
neogeo_sma_mslug3a_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)132 neogeo_sma_mslug3a_cart_device::neogeo_sma_mslug3a_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
133 	neogeo_sma_cart_device(mconfig, NEOGEO_SMA_MSLUG3A_CART, tag, owner, clock)
134 {
135 }
136 
decrypt_all(DECRYPT_ALL_PARAMS)137 void neogeo_sma_mslug3a_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
138 {
139 	m_sma_prot->mslug3a_decrypt_68k(cpuregion);
140 	m_cmc_prot->cmc42_gfx_decrypt(spr_region, spr_region_size, MSLUG3_GFX_KEY);
141 	m_cmc_prot->sfix_decrypt(spr_region, spr_region_size, fix_region, fix_region_size);
142 }
143 
144 
145 /*************************************************
146  kof2000
147 **************************************************/
148 
neogeo_sma_kof2000_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)149 neogeo_sma_kof2000_cart_device::neogeo_sma_kof2000_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
150 	neogeo_sma_cart_device(mconfig, NEOGEO_SMA_KOF2000_CART, tag, owner, clock)
151 {
152 }
153 
decrypt_all(DECRYPT_ALL_PARAMS)154 void neogeo_sma_kof2000_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
155 {
156 	m_sma_prot->kof2000_decrypt_68k(cpuregion);
157 	m_cmc_prot->cmc50_m1_decrypt(audiocrypt_region, audiocrypt_region_size, audiocpu_region, audio_region_size);
158 	m_cmc_prot->cmc50_gfx_decrypt(spr_region, spr_region_size, KOF2000_GFX_KEY);
159 	m_cmc_prot->sfix_decrypt(spr_region, spr_region_size, fix_region, fix_region_size);
160 }
161