1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4
5 Scanntronik Pagefox cartridge emulation
6
7 **********************************************************************/
8
9 /*
10
11 PCB Layout
12 ----------
13
14 |===========================|
15 |=| |
16 |=| RAM LS11 |
17 |=| |
18 |=| LS139 |
19 |=| ROM0 |
20 |=| LS273 |
21 |=| |
22 |=| ROM1 LS00 |
23 |===========================|
24
25 RAM - NEC D43256-12L 32Kx8 RAM
26 ROM0 - SGS M27256-2FI 32Kx8 EPROM
27 ROM1 - National Instruments NMC27C256Q 32Kx8 EPROM
28
29 */
30
31 #include "emu.h"
32 #include "pagefox.h"
33
34
35
36 //**************************************************************************
37 // DEVICE DEFINITIONS
38 //**************************************************************************
39
40 DEFINE_DEVICE_TYPE(C64_PAGEFOX, c64_pagefox_cartridge_device, "c64_pagefox", "C64 Pagefox cartridge")
41
42
43
44 //**************************************************************************
45 // LIVE DEVICE
46 //**************************************************************************
47
48 //-------------------------------------------------
49 // c64_pagefox_cartridge_device - constructor
50 //-------------------------------------------------
51
c64_pagefox_cartridge_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)52 c64_pagefox_cartridge_device::c64_pagefox_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
53 device_t(mconfig, C64_PAGEFOX, tag, owner, clock),
54 device_c64_expansion_card_interface(mconfig, *this),
55 m_ram(*this, "ram"), m_bank(0)
56 {
57 }
58
59
60 //-------------------------------------------------
61 // device_start - device-specific startup
62 //-------------------------------------------------
63
device_start()64 void c64_pagefox_cartridge_device::device_start()
65 {
66 // allocate memory
67 m_ram.allocate(0x8000);
68
69 // state saving
70 save_item(NAME(m_bank));
71 }
72
73
74 //-------------------------------------------------
75 // device_reset - device-specific reset
76 //-------------------------------------------------
77
device_reset()78 void c64_pagefox_cartridge_device::device_reset()
79 {
80 m_bank = 0;
81 }
82
83
84 //-------------------------------------------------
85 // c64_cd_r - cartridge data read
86 //-------------------------------------------------
87
c64_cd_r(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)88 uint8_t c64_pagefox_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
89 {
90 if (!roml || !romh)
91 {
92 if (BIT(m_bank, 3))
93 {
94 offs_t addr = (BIT(m_bank, 1) << 14) | (offset & 0x3fff);
95 data = m_ram[addr];
96 }
97 else
98 {
99 int bank = (m_bank >> 1) & 0x07;
100 offs_t addr = (bank << 14) | (offset & 0x3fff);
101 data = m_roml[addr];
102 }
103 }
104
105 return data;
106 }
107
108
109 //-------------------------------------------------
110 // c64_cd_w - cartridge data write
111 //-------------------------------------------------
112
c64_cd_w(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)113 void c64_pagefox_cartridge_device::c64_cd_w(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
114 {
115 if (offset >= 0x8000 && offset < 0xc000)
116 {
117 if (BIT(m_bank, 3))
118 {
119 offs_t addr = (BIT(m_bank, 1) << 14) | (offset & 0x3fff);
120 m_ram[addr] = data;
121 }
122 }
123 else if (!io1 && BIT(offset, 7))
124 {
125 if (data == 0xff)
126 {
127 m_game = 1;
128 m_exrom = 1;
129 }
130 else
131 {
132 m_game = 0;
133 m_exrom = 0;
134 }
135
136 m_bank = data;
137 }
138 }
139