Previous 15994 Revisions Next

r14815 Tuesday 27th March, 2012 at 15:00:51 UTC by Curt Coder
[C64] Cartridge WIP. (nw)
[src/mess/machine]c64_cpm.c c64_cpm.h

src/mess/machine/c64_cpm.c
r14814r14815
22
33    Commodore 64 CP/M cartridge emulation
44
5   http://www.baltissen.org/newhtm/c64_cpm.htm
6
57    Copyright MESS Team.
68    Visit http://mamedev.org for licensing and usage restrictions.
79
r14814r14815
6870
6971
7072//**************************************************************************
73//  INLINE HELPERS
74//**************************************************************************
75
76//-------------------------------------------------
77//  update_signals -
78//-------------------------------------------------
79
80inline void c64_cpm_cartridge_device::update_signals()
81{
82   // NOTE: none of this works until the Z80 core has been rewritten
83   
84   // C64 DMA
85   m_slot->dma_w(m_enabled ? ASSERT_LINE : CLEAR_LINE);
86   
87   // Z80 BUSRQ
88   int busrq = !(m_enabled & !m_ba) ? CLEAR_LINE : ASSERT_LINE;
89   m_maincpu->set_input_line(Z80_INPUT_LINE_BUSRQ, busrq);
90
91   // Z80 WAIT
92   m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, m_enabled ? CLEAR_LINE : ASSERT_LINE);
93}
94
95
96
97//**************************************************************************
7198//  LIVE DEVICE
7299//**************************************************************************
73100
r14814r14815
78105c64_cpm_cartridge_device::c64_cpm_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
79106   device_t(mconfig, C64_CPM, "C64 CP/M cartridge", tag, owner, clock),
80107   device_c64_expansion_card_interface(mconfig, *this),
81   m_maincpu(*this, Z80_TAG)
108   m_maincpu(*this, Z80_TAG),
109   m_enabled(0),
110   m_ba(1)
82111{
83112}
84113
r14814r14815
89118
90119void c64_cpm_cartridge_device::device_start()
91120{
92   // TODO stop the Z80 here before it gets any ideas
121   // state saving
122   save_item(NAME(m_enabled));
123   save_item(NAME(m_ba));
93124}
94125
95126
r14814r14815
99130
100131void c64_cpm_cartridge_device::device_reset()
101132{
102   m_slot->dma_w(CLEAR_LINE);
103   m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
133   m_enabled = 0;
134
135   update_signals();
104136}
105137
106138
r14814r14815
112144{
113145   if (!io1)
114146   {
115      // HACK
116      m_slot->dma_w(BIT(data, 0) ? ASSERT_LINE : CLEAR_LINE);
117      m_maincpu->set_input_line(INPUT_LINE_HALT, BIT(data, 0) ? CLEAR_LINE : ASSERT_LINE);
147      m_enabled = !BIT(data, 0);
148
149      update_signals();
118150   }
119151}
120152
121153
122154//-------------------------------------------------
155//  c64_game_r - GAME read
156//-------------------------------------------------
157
158int c64_cpm_cartridge_device::c64_game_r(offs_t offset, int ba, int rw, int hiram)
159{
160   if (m_ba != ba)
161   {
162      m_ba = ba;
163
164      update_signals();
165   }
166
167   return 1;
168}
169
170
171//-------------------------------------------------
123172//   dma_r -
124173//-------------------------------------------------
125174
126175READ8_MEMBER( c64_cpm_cartridge_device::dma_r )
127176{
128   return m_slot->dma_cd_r(offset | 0x1000);
177   UINT8 data = 0xff;
178
179   if (m_enabled)
180   {
181      offs_t addr = (offset + 0x1000) & 0xffff;
182
183      data = m_slot->dma_cd_r(addr);
184   }
185
186   return data;
129187}
130188
131189
r14814r14815
135193
136194WRITE8_MEMBER( c64_cpm_cartridge_device::dma_w )
137195{
138   m_slot->dma_cd_w(offset | 0x1000, data);
196   if (m_enabled)
197   {
198      offs_t addr = (offset + 0x1000) & 0xffff;
199
200      m_slot->dma_cd_w(addr, data);
201   }
139202}
src/mess/machine/c64_cpm.h
r14814r14815
4848
4949   // device_c64_expansion_card_interface overrides
5050   virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2);
51   virtual int c64_game_r(offs_t offset, int ba, int rw, int hiram);
5152
5253private:
54   inline void update_signals();
55
5356   required_device<cpu_device> m_maincpu;
57
58   int m_enabled;
59   int m_ba;
5460};
5561
5662

Previous 15994 Revisions Next


© 1998-2018 The MESS Team