1 // license:BSD-3-Clause
2 // copyright-holders:Fabio Priuli
3 /***********************************************************************************************************
4
5
6 NES/Famicom cartridge emulation for NTDEC PCBs
7
8
9 Here we emulate the following PCBs
10
11 * NTDEC ASDER [mapper 112]
12 * NTDEC Fighting Hero [mapper 193]
13
14 TODO:
15 - why is Master Shooter not working?
16
17 ***********************************************************************************************************/
18
19
20 #include "emu.h"
21 #include "ntdec.h"
22
23
24 #ifdef NES_PCB_DEBUG
25 #define VERBOSE 1
26 #else
27 #define VERBOSE 0
28 #endif
29
30 #define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0)
31
32
33 //-------------------------------------------------
34 // constructor
35 //-------------------------------------------------
36
37 DEFINE_DEVICE_TYPE(NES_NTDEC_ASDER, nes_ntdec_asder_device, "nes_ntdec_asder", "NES Cart NTDEC Asder PCB")
38 DEFINE_DEVICE_TYPE(NES_NTDEC_FH, nes_ntdec_fh_device, "nes_fh_asder", "NES Cart NTDEC Fighting Hero PCB")
39
40
nes_ntdec_asder_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)41 nes_ntdec_asder_device::nes_ntdec_asder_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
42 : nes_nrom_device(mconfig, NES_NTDEC_ASDER, tag, owner, clock)
43 , m_latch(0)
44 {
45 }
46
nes_ntdec_fh_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)47 nes_ntdec_fh_device::nes_ntdec_fh_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
48 : nes_nrom_device(mconfig, NES_NTDEC_FH, tag, owner, clock)
49 {
50 }
51
52
53
54
device_start()55 void nes_ntdec_asder_device::device_start()
56 {
57 common_start();
58 save_item(NAME(m_latch));
59 }
60
pcb_reset()61 void nes_ntdec_asder_device::pcb_reset()
62 {
63 m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
64 prg16_89ab(0);
65 prg16_cdef(m_prg_chunks - 1);
66 chr8(0, m_chr_source);
67
68 m_latch = 0;
69 }
70
device_start()71 void nes_ntdec_fh_device::device_start()
72 {
73 common_start();
74 }
75
pcb_reset()76 void nes_ntdec_fh_device::pcb_reset()
77 {
78 m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
79 prg32((m_prg_chunks - 1) >> 1);
80 chr8(0, m_chr_source);
81 set_nt_mirroring(PPU_MIRROR_VERT);
82 }
83
84
85
86
87
88 /*-------------------------------------------------
89 mapper specific handlers
90 -------------------------------------------------*/
91
92 /*-------------------------------------------------
93
94 NTDEC ASDER Bootleg Board
95
96 Games: Cobra Mission, Fighting Hero III, Huang Di, Master
97 Shooter
98
99 iNES: mapper 112
100
101 In MESS: Supported.
102
103 -------------------------------------------------*/
104
write_h(offs_t offset,uint8_t data)105 void nes_ntdec_asder_device::write_h(offs_t offset, uint8_t data)
106 {
107 LOG_MMC(("ntdec_asder write_h, offset: %04x, data: %02x\n", offset, data));
108
109 switch (offset)
110 {
111 case 0x0000:
112 m_latch = data & 0x07;
113 break;
114 case 0x2000:
115 switch (m_latch)
116 {
117 case 0:
118 prg8_89(data);
119 break;
120 case 1:
121 prg8_ab(data);
122 break;
123 case 2:
124 data &= 0xfe;
125 chr1_0(data, CHRROM);
126 chr1_1(data + 1, CHRROM);
127 break;
128 case 3:
129 data &= 0xfe;
130 chr1_2(data, CHRROM);
131 chr1_3(data + 1, CHRROM);
132 break;
133 case 4:
134 chr1_4(data, CHRROM);
135 break;
136 case 5:
137 chr1_5(data, CHRROM);
138 break;
139 case 6:
140 chr1_6(data, CHRROM);
141 break;
142 case 7:
143 chr1_7(data, CHRROM);
144 break;
145 }
146 break;
147 case 0x6000:
148 set_nt_mirroring(BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
149 break;
150 }
151 }
152
153 /*-------------------------------------------------
154
155 Bootleg Board by NTDEC for Fighting Hero
156
157 Games: Fighting Hero
158
159 Very simple mapper: writes to 0x6000-0x7fff swap PRG and
160 CHR banks.
161
162 iNES: mapper 193
163
164 In MESS: Supported.
165
166 -------------------------------------------------*/
167
write_m(offs_t offset,uint8_t data)168 void nes_ntdec_fh_device::write_m(offs_t offset, uint8_t data)
169 {
170 LOG_MMC(("ntdec_fh write_m, offset: %04x, data: %02x\n", offset, data));
171
172 switch (offset & 0x03)
173 {
174 case 0:
175 chr4_0(data >> 2, CHRROM);
176 break;
177 case 1:
178 chr2_4(data >> 1, CHRROM);
179 break;
180 case 2:
181 chr2_6(data >> 1 , CHRROM);
182 break;
183 case 3:
184 prg8_89(data);
185 break;
186 }
187 }
188