1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4
5 Zaxxon/Super Zaxxon cartridge emulation
6
7 **********************************************************************/
8
9 #include "emu.h"
10 #include "zaxxon.h"
11
12
13
14 //**************************************************************************
15 // DEVICE DEFINITIONS
16 //**************************************************************************
17
18 DEFINE_DEVICE_TYPE(C64_ZAXXON, c64_zaxxon_cartridge_device, "c64_zaxxon", "C64 Zaxxon cartridge")
19
20
21
22 //**************************************************************************
23 // LIVE DEVICE
24 //**************************************************************************
25
26 //-------------------------------------------------
27 // c64_zaxxon_cartridge_device - constructor
28 //-------------------------------------------------
29
c64_zaxxon_cartridge_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)30 c64_zaxxon_cartridge_device::c64_zaxxon_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
31 device_t(mconfig, C64_ZAXXON, tag, owner, clock),
32 device_c64_expansion_card_interface(mconfig, *this),
33 m_bank(0)
34 {
35 }
36
37
38 //-------------------------------------------------
39 // device_start - device-specific startup
40 //-------------------------------------------------
41
device_start()42 void c64_zaxxon_cartridge_device::device_start()
43 {
44 // state saving
45 save_item(NAME(m_bank));
46 }
47
48
49 //-------------------------------------------------
50 // c64_cd_r - cartridge data read
51 //-------------------------------------------------
52
c64_cd_r(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)53 uint8_t c64_zaxxon_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
54 {
55 if (!roml)
56 {
57 data = m_roml[offset & 0xfff];
58
59 m_bank = BIT(offset, 12);
60 }
61 else if (!romh)
62 {
63 offs_t addr = (m_bank << 13) | (offset & 0x1fff);
64 data = m_romh[addr];
65 }
66
67 return data;
68 }
69