summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/nes/sealie.cpp
blob: 32adda5680cf7b3c231cbb882b22b3c4c62d6905 (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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// license:BSD-3-Clause
// copyright-holders:kmg
/***********************************************************************************************************


 NES/Famicom cartridge emulation for Sealie Computing and related PCBs


 Here we emulate the following homebrew PCBs

 * SEALIE RET-CUFROM [mapper 29]
 * SEALIE DPCMcart [mapper 409]
 * SEALIE UNROM 512 [mapper 30]
 * SEALIE 8BIT XMAS [mapper 30]

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


#include "emu.h"
#include "sealie.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
//-------------------------------------------------

DEFINE_DEVICE_TYPE(NES_8BITXMAS, nes_8bitxmas_device, "nes_8bitxmas", "NES Cart Sealie 8BIT XMAS PCB")
DEFINE_DEVICE_TYPE(NES_CUFROM,   nes_cufrom_device,   "nes_cufrom",   "NES Cart Sealie RET-CUFROM PCB")
DEFINE_DEVICE_TYPE(NES_DPCMCART, nes_dpcmcart_device, "nes_dpcmcart", "NES Cart Sealie DPCMcart PCB")
DEFINE_DEVICE_TYPE(NES_UNROM512, nes_unrom512_device, "nes_unrom512", "NES Cart Sealie UNROM 512 PCB")


nes_cufrom_device::nes_cufrom_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: nes_nrom_device(mconfig, NES_CUFROM, tag, owner, clock)
{
}

nes_dpcmcart_device::nes_dpcmcart_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: nes_nrom_device(mconfig, NES_DPCMCART, tag, owner, clock)
{
}

nes_unrom512_device::nes_unrom512_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
	: nes_nrom_device(mconfig, type, tag, owner, clock)
{
}

nes_unrom512_device::nes_unrom512_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: nes_unrom512_device(mconfig, NES_UNROM512, tag, owner, clock)
{
}

nes_8bitxmas_device::nes_8bitxmas_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: nes_unrom512_device(mconfig, NES_8BITXMAS, tag, owner, clock), m_led(0)
{
}



void nes_cufrom_device::pcb_reset()
{
	prg16_89ab(0);
	prg16_cdef(m_prg_chunks - 1);
	chr8(0, CHRRAM);
}

void nes_dpcmcart_device::pcb_reset()
{
	prg16_89ab(0);
	prg16_cdef(m_prg_chunks - 1);
}

void nes_unrom512_device::pcb_reset()
{
	prg16_89ab(0);
	prg16_cdef(m_prg_chunks - 1);
	chr8(0, CHRRAM);
	if (m_pcb_ctrl_mirror)
		set_nt_mirroring(PPU_MIRROR_LOW);
}

void nes_8bitxmas_device::device_start()
{
	nes_unrom512_device::device_start();
	save_item(NAME(m_led));

	m_bus_conflict = false;
}

void nes_8bitxmas_device::pcb_reset()
{
	nes_unrom512_device::pcb_reset();

	m_led = 0;
	update_led();
}



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

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

 Sealie RET-CUFROM board

 Games: Glider (only?)

 This homebrew mapper supports 8x16k PRG banks at 0x8000,
 8k WRAM at 0x6000, and 4x8k VRAM banks. PRG is stored on
 flash ROM, though unlike mapper 30 it doesn't appear to
 be self-flashable, only through an external tool.

 iNES: mapper 29

 In MAME: Supported.

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

void nes_cufrom_device::write_h(offs_t offset, u8 data)
{
	LOG_MMC(("cufrom write_h, offset: %04x, data: %02x\n", offset, data));

	prg16_89ab(BIT(data, 2, 3));
	chr8(data & 0x03, CHRRAM);
}

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

 Sealie DPCMcart board

 Games: A Winner is You

 This homebrew mapper supports a whopping 64MB which
 is paged in 16K chucks at 0x8000. 0xc000 is fixed.

 NES 2.0: mapper 409

 In MAME: Partially supported.

 TODO: Controls other than 'next track' don't work.

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

void nes_dpcmcart_device::write_h(offs_t offset, u8 data)
{
	LOG_MMC(("dpcmcart write_h, offset: %04x, data: %02x\n", offset, data));
	prg16_89ab(offset & 0x0fff);
}

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

 Sealie UNROM 512 board

 Games: Battle Kid 1 & 2, E.T., many more

 This board has several variations and jumper configurations.
 Currently we only support the Sealie nonflashable config
 with 32x16k PRG banks at 0x8000, 4x8k VRAM, and three
 mirroring configs (H, V, or PCB selected 1-screen modes).

 iNES: mapper 30

 In MAME: Preliminary partial support.

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

void nes_unrom512_device::write_h(offs_t offset, u8 data)
{
	LOG_MMC(("unrom512 write_h, offset: %04x, data: %02x\n", offset, data));

	// this pcb is subject to bus conflict in its nonflashable configuration
	data = account_bus_conflict(offset, data);

	if (m_pcb_ctrl_mirror)
		set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
	prg16_89ab(data & 0x1f);
	chr8(BIT(data, 5, 2), CHRRAM);
}

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

 Sealie 8BIT XMAS revD board

 Games: 8-bit Xmas 2012-2016 and 2018-2021?

 This board is a variant of UNROM512 with 16 LEDs
 in 4 colors, blue, yellow, green, red, which are
 controlled in pairs by each byte written to
 0x8000-0xbfff. Bits are [BYGR bygr] where bygr
 control LEDs 1,2 and BYGR control LEDs 3,4. On
 the 8BIT XMAS revD 2012 board LEDS are arranged:

  _______________________________
 | RED2                     GRN3 |
 |                               |
 | YEL2                     BLU3 |
 |                               |
 | BLU1                     YEL4 |
 |                               |
 | GRN1                     RED4 |
 |                               |
 | RED1                     GRN4 |
 |                               |
 | YEL1                     BLU4 |
  --                           --
    |   GRN2 BLU2 YEL3 RED3   |
    |                         |

 iNES: mapper 30

 In MAME: Preliminary partial support.

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

void nes_8bitxmas_device::update_led()
{
	// TODO: add artwork
}

void nes_8bitxmas_device::write_h(offs_t offset, u8 data)
{
	LOG_MMC(("8bitxmas write_h, offset: %04x, data: %02x\n", offset, data));

	if (BIT(offset, 14))
		nes_unrom512_device::write_h(offset, data);
	else if (m_led != data)
	{
		m_led = data;
		update_led();
	}
}