1 // license:BSD-3-Clause
2 // copyright-holders:Fabio Priuli
3 /***********************************************************************************************************
4 
5 
6  NES/Famicom cartridge emulation for HES PCBs
7 
8 
9  Here we emulate the HES PCBs (both the one with hardwired mirroring and the one with mapper-controlled
10  mirroring used by HES 6 in 1) [mapper 113]
11 
12 
13  ***********************************************************************************************************/
14 
15 
16 #include "emu.h"
17 #include "hes.h"
18 
19 
20 #ifdef NES_PCB_DEBUG
21 #define VERBOSE 1
22 #else
23 #define VERBOSE 0
24 #endif
25 
26 #define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0)
27 
28 
29 //-------------------------------------------------
30 //  constructor
31 //-------------------------------------------------
32 
33 DEFINE_DEVICE_TYPE(NES_HES, nes_hes_device, "nes_hes", "NES Cart HES PCB")
34 
35 
nes_hes_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)36 nes_hes_device::nes_hes_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
37 	: nes_nrom_device(mconfig, NES_HES, tag, owner, clock)
38 {
39 }
40 
41 
device_start()42 void nes_hes_device::device_start()
43 {
44 	common_start();
45 }
46 
pcb_reset()47 void nes_hes_device::pcb_reset()
48 {
49 	m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
50 	prg32(0);
51 	chr8(0, m_chr_source);
52 }
53 
54 
55 
56 /*-------------------------------------------------
57  mapper specific handlers
58  -------------------------------------------------*/
59 
60 /*-------------------------------------------------
61 
62  Bootleg Board by HES (also used by others)
63 
64  Games: AV Hanafuda Club, AV Soccer, Papillon, Sidewinder,
65  Total Funpack
66 
67  Actually, two variant: one for HES 6-in-1 with mirroring control
68  and one for AV Soccer and others with hardwired mirroring
69 
70  iNES: mapper 113
71 
72  In MESS: Supported.
73 
74  -------------------------------------------------*/
75 
write_l(offs_t offset,uint8_t data)76 void nes_hes_device::write_l(offs_t offset, uint8_t data)
77 {
78 	LOG_MMC(("hes write_l, offset: %04x, data: %02x\n", offset, data));
79 
80 	if (!(offset & 0x100))
81 	{
82 		prg32((data & 0x38) >> 3);
83 		chr8((data & 0x07) | ((data & 0x40) >> 3), CHRROM);
84 		if (m_pcb_ctrl_mirror)
85 			set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
86 	}
87 }
88