summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/nes_camerica.c
blob: 1e7b7af7c0768a62583c75f9dbabe5ce7d2fe687 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/***********************************************************************************************************


 NES/Famicom cartridge emulation for Camerica/Codemasters PCBs

 Copyright MESS Team.
 Visit http://mamedev.org for licensing and usage restrictions.


 Here we emulate the following PCBs

 * Camerica BF9093, BF9097, BF909X & ALGNV11 [mapper 71, two variants]
 * Camerica BF9096 & ALGQV11 Boards [mapper 232]
 * Camerica Golden Five [mapper 104]


 TODO:
 - check what causes flickering from PPU in Fire Hawk, Poogie and Big Nose (same PPU issue as Back to 
   Future 2&3?)
 - not all the Golden Five games work. investigate!

 ***********************************************************************************************************/


#include "emu.h"
#include "machine/nes_camerica.h"


#ifdef NES_PCB_DEBUG
#define VERBOSE 1
#else
#define VERBOSE 0
#endif

#define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0)


//-------------------------------------------------
//  constructor
//-------------------------------------------------

const device_type NES_BF9093 = &device_creator<nes_bf9093_device>;
const device_type NES_BF9096 = &device_creator<nes_bf9096_device>;
const device_type NES_GOLDEN5 = &device_creator<nes_golden5_device>;


nes_bf9093_device::nes_bf9093_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: nes_nrom_device(mconfig, NES_BF9093, "NES Cart Camerica BF9093 PCB", tag, owner, clock, "nes_bf9093", __FILE__)
{
}

nes_bf9096_device::nes_bf9096_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: nes_nrom_device(mconfig, NES_BF9096, "NES Cart Camerica BF9096 PCB", tag, owner, clock, "nes_bf9096", __FILE__)
{
}

nes_golden5_device::nes_golden5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: nes_nrom_device(mconfig, NES_GOLDEN5, "NES Cart Camerica Golden 5 PCB", tag, owner, clock, "nes_golden5", __FILE__)
{
}




void nes_bf9093_device::device_start()
{
	common_start();
}

void nes_bf9093_device::pcb_reset()
{
	m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
	prg32(0xff);
	chr8(0, m_chr_source);
}

void nes_bf9096_device::device_start()
{
	common_start();
	save_item(NAME(m_latch1));
	save_item(NAME(m_latch2));
}

void nes_bf9096_device::pcb_reset()
{
	m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
	chr8(0, m_chr_source);

	m_latch1 = 0x18;
	m_latch2 = 0x00;
	set_prg();
}

void nes_golden5_device::device_start()
{
	common_start();
	save_item(NAME(m_latch));
}

void nes_golden5_device::pcb_reset()
{
	m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
	prg16_89ab(0x00);
	prg16_cdef(0x0f);
	chr8(0, m_chr_source);

	m_latch = 0;
}





/*-------------------------------------------------
 mapper specific handlers
 -------------------------------------------------*/

/*-------------------------------------------------

 Camerica Boards (BF9093, BF9097, BF909X, ALGNV11)

 Games: Linus Spacehead's Cosmic Crusade, Micro Machines,
 Mig-29, Stunt Kids

 To emulate NT mirroring for BF9097 board (missing in BF9093)
 we use crc_hack, however Fire Hawk is broken (but without
 mirroring there would be no helicopter graphics).

 iNES: mapper 71

 In MESS: Partially Supported.

 -------------------------------------------------*/

WRITE8_MEMBER(nes_bf9093_device::write_h)
{
	LOG_MMC(("bf9093 write_h, offset: %04x, data: %02x\n", offset, data));

	switch (offset & 0x7000)
	{
		case 0x0000:
		case 0x1000:
			if (m_pcb_ctrl_mirror)
				set_nt_mirroring(BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
			break;
		case 0x4000:
		case 0x5000:
		case 0x6000:
		case 0x7000:
			prg16_89ab(data);
			break;
	}
}

/*-------------------------------------------------

 Camerica BF9096 & ALGQV11 Boards

 Games: Quattro Adventure, Quattro Arcade, Quattro Sports

 Writes to 0x8000-0x9fff set prg block to (data&0x18)>>1,
 writes to 0xa000-0xbfff set prg page to data&3. selected
 prg are: prg16_89ab = block|page, prg_cdef = 3|page.
 For more info on the hardware to bypass the NES lockout, see
 Kevtris' Camerica Mappers documentation.

 iNES: mapper 232

 In MESS: Supported.

 -------------------------------------------------*/

void nes_bf9096_device::set_prg()
{
	prg16_89ab((m_latch2 & 0x03) | ((m_latch1 & 0x18) >> 1));
	prg16_cdef(0x03 | ((m_latch1 & 0x18) >> 1));
}

WRITE8_MEMBER(nes_bf9096_device::write_h)
{
	LOG_MMC(("bf9096 write_h, offset: %04x, data: %02x\n", offset, data));

	if (offset < 0x2000)
		m_latch1 = data;
	else
		m_latch2 = data;

	set_prg();
}

/*-------------------------------------------------

 Camerica Golden Five board

 Games: Pegasus 5 in 1

 iNES: mapper 104

 In MESS: Supported.

 -------------------------------------------------*/

WRITE8_MEMBER(nes_golden5_device::write_h)
{
	LOG_MMC(("golden5 write_h, offset: %04x, data: %02x\n", offset, data));

	if (offset < 0x4000)
	{
		if (data & 0x08)
		{
			m_latch = ((data & 0x07) << 4) | (m_latch & 0x0f);
			prg16_89ab(m_latch);
			prg16_cdef(((data & 0x07) << 4) | 0x0f);
		}

	}
	else
	{
		m_latch = (m_latch & 0x70) | (data & 0x0f);
		prg16_89ab(m_latch);
	}
}