1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4
5 C64 switchable 8K cartridge emulation
6
7 **********************************************************************/
8
9 /*
10
11 4040 + Fast Hack'em
12
13 PCB Layout
14 ----------
15
16 |===========================|
17 |=| |
18 |=| SW1 |
19 |=| ROM0 |
20 |=| |
21 |=| |
22 |=| ROM1 |
23 |=| |
24 |=| |
25 |===========================|
26
27 ROM0,1 - National Semiconductor NMC27C64Q 8Kx8 EPROM
28 SW1 - ROM selection switch
29
30 */
31
32 #include "emu.h"
33 #include "sw8k.h"
34
35
36
37 //**************************************************************************
38 // DEVICE DEFINITIONS
39 //**************************************************************************
40
41 DEFINE_DEVICE_TYPE(C64_SW8K, c64_switchable_8k_cartridge_device, "c64_sw8k", "C64 Switchable 8K cartridge")
42
43
44 //-------------------------------------------------
45 // INPUT_PORTS( c64_easyflash )
46 //-------------------------------------------------
47
INPUT_PORTS_START(c64_switchable_8k)48 static INPUT_PORTS_START( c64_switchable_8k )
49 PORT_START("SW")
50 PORT_DIPNAME( 0x01, 0x00, "ROM Select" )
51 PORT_DIPSETTING( 0x00, "ROM 0" )
52 PORT_DIPSETTING( 0x01, "ROM 1" )
53 INPUT_PORTS_END
54
55
56 //-------------------------------------------------
57 // input_ports - device-specific input ports
58 //-------------------------------------------------
59
60 ioport_constructor c64_switchable_8k_cartridge_device::device_input_ports() const
61 {
62 return INPUT_PORTS_NAME( c64_switchable_8k );
63 }
64
65
66
67 //**************************************************************************
68 // LIVE DEVICE
69 //**************************************************************************
70
71 //-------------------------------------------------
72 // c64_switchable_8k_cartridge_device - constructor
73 //-------------------------------------------------
74
c64_switchable_8k_cartridge_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)75 c64_switchable_8k_cartridge_device::c64_switchable_8k_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
76 device_t(mconfig, C64_SW8K, tag, owner, clock),
77 device_c64_expansion_card_interface(mconfig, *this),
78 m_sw(*this, "SW"), m_bank(0)
79 {
80 }
81
82
83 //-------------------------------------------------
84 // device_start - device-specific startup
85 //-------------------------------------------------
86
device_start()87 void c64_switchable_8k_cartridge_device::device_start()
88 {
89 }
90
91
92 //-------------------------------------------------
93 // device_reset - device-specific reset
94 //-------------------------------------------------
95
device_reset()96 void c64_switchable_8k_cartridge_device::device_reset()
97 {
98 m_bank = m_sw->read();
99 }
100
101
102 //-------------------------------------------------
103 // c64_cd_r - cartridge data read
104 //-------------------------------------------------
105
c64_cd_r(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)106 uint8_t c64_switchable_8k_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
107 {
108 if (!roml)
109 {
110 offs_t addr = (m_bank << 13) | (offset & 0x1fff);
111 data = m_roml[addr];
112 }
113
114 return data;
115 }
116