Previous 15994 Revisions Next

r14806 Monday 26th March, 2012 at 16:02:44 UTC by Curt Coder
[C64] Cartridge WIP. (nw)
[src/mess]mess.mak
[src/mess/drivers]c64.c
[src/mess/includes]c64.h
[src/mess/machine]c64_cpm.c* c64_cpm.h* c64_ieee488.c c64_ieee488.h c64_sfx_sound_expander.c c64_sfx_sound_expander.h c64exp.c c64exp.h cbmipt.c cbmipt.h

src/mess/machine/c64_cpm.c
r0r14806
1/**********************************************************************
2
3    Commodore 64 CP/M cartridge emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "c64_cpm.h"
11
12
13
14//**************************************************************************
15//  MACROS/CONSTANTS
16//**************************************************************************
17
18#define Z80_TAG      "z80"
19
20
21
22//**************************************************************************
23//  DEVICE DEFINITIONS
24//**************************************************************************
25
26const device_type C64_CPM = &device_creator<c64_cpm_cartridge_device>;
27
28
29//-------------------------------------------------
30//  ADDRESS_MAP( z80_mem )
31//-------------------------------------------------
32
33static ADDRESS_MAP_START( z80_mem, AS_PROGRAM, 8, c64_cpm_cartridge_device )
34   AM_RANGE(0x0000, 0xffff) AM_READWRITE(dma_r, dma_w)
35ADDRESS_MAP_END
36
37
38//-------------------------------------------------
39//  ADDRESS_MAP( z80_io )
40//-------------------------------------------------
41
42static ADDRESS_MAP_START( z80_io, AS_IO, 8, c64_cpm_cartridge_device )
43   AM_RANGE(0x0000, 0xffff) AM_READWRITE(dma_r, dma_w)
44ADDRESS_MAP_END
45
46
47//-------------------------------------------------
48//  MACHINE_CONFIG_FRAGMENT( c64_cpm )
49//-------------------------------------------------
50
51static MACHINE_CONFIG_FRAGMENT( c64_cpm )
52   MCFG_CPU_ADD(Z80_TAG, Z80, 3000000)
53   MCFG_CPU_PROGRAM_MAP(z80_mem)
54   MCFG_CPU_IO_MAP(z80_io)
55MACHINE_CONFIG_END
56
57
58//-------------------------------------------------
59//  machine_config_additions - device-specific
60//  machine configurations
61//-------------------------------------------------
62
63machine_config_constructor c64_cpm_cartridge_device::device_mconfig_additions() const
64{
65   return MACHINE_CONFIG_NAME( c64_cpm );
66}
67
68
69
70//**************************************************************************
71//  LIVE DEVICE
72//**************************************************************************
73
74//-------------------------------------------------
75//  c64_cpm_cartridge_device - constructor
76//-------------------------------------------------
77
78c64_cpm_cartridge_device::c64_cpm_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
79   device_t(mconfig, C64_CPM, "C64 CP/M cartridge", tag, owner, clock),
80   device_c64_expansion_card_interface(mconfig, *this),
81   m_maincpu(*this, Z80_TAG)
82{
83}
84
85
86//-------------------------------------------------
87//  device_start - device-specific startup
88//-------------------------------------------------
89
90void c64_cpm_cartridge_device::device_start()
91{
92   // TODO stop the Z80 here before it gets any ideas
93}
94
95
96//-------------------------------------------------
97//  device_reset - device-specific reset
98//-------------------------------------------------
99
100void c64_cpm_cartridge_device::device_reset()
101{
102   m_slot->dma_w(CLEAR_LINE);
103   m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
104}
105
106
107//-------------------------------------------------
108//  c64_cd_w - cartridge data write
109//-------------------------------------------------
110
111void c64_cpm_cartridge_device::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2)
112{
113   if (!io1)
114   {
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);
118   }
119}
120
121
122//-------------------------------------------------
123//   dma_r -
124//-------------------------------------------------
125
126READ8_MEMBER( c64_cpm_cartridge_device::dma_r )
127{
128   return m_slot->dma_cd_r(offset | 0x1000);
129}
130
131
132//-------------------------------------------------
133//  dma_w -
134//-------------------------------------------------
135
136WRITE8_MEMBER( c64_cpm_cartridge_device::dma_w )
137{
138   m_slot->dma_cd_w(offset | 0x1000, data);
139}
src/mess/machine/c64_cpm.h
r0r14806
1/**********************************************************************
2
3    Commodore 64 CP/M cartridge emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __CPM__
13#define __CPM__
14
15#define ADDRESS_MAP_MODERN
16
17#include "emu.h"
18#include "cpu/z80/z80.h"
19#include "machine/c64exp.h"
20
21
22
23//**************************************************************************
24//  TYPE DEFINITIONS
25//**************************************************************************
26
27// ======================> c64_cpm_cartridge_device
28
29class c64_cpm_cartridge_device : public device_t,
30                         public device_c64_expansion_card_interface
31{
32public:
33   // construction/destruction
34   c64_cpm_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
35
36   // optional information overrides
37   virtual machine_config_constructor device_mconfig_additions() const;
38
39   // not really public
40   DECLARE_READ8_MEMBER( dma_r );
41   DECLARE_WRITE8_MEMBER( dma_w );
42
43protected:
44   // device-level overrides
45   virtual void device_start();
46   virtual void device_reset();
47   virtual void device_config_complete() { m_shortname = "c64_cpm"; }
48
49   // device_c64_expansion_card_interface overrides
50   virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2);
51
52private:
53   required_device<cpu_device> m_maincpu;
54};
55
56
57// device type definition
58extern const device_type C64_CPM;
59
60
61#endif
src/mess/machine/c64_sfx_sound_expander.c
r14805r14806
3232//  C64_EXPANSION_INTERFACE( expansion_intf )
3333//-------------------------------------------------
3434 
35READ8_MEMBER( c64_sfx_sound_expander_cartridge_device::dma_cd_r )
36{
37   return m_slot->dma_cd_r(offset);
38}
39 
40WRITE8_MEMBER( c64_sfx_sound_expander_cartridge_device::dma_cd_w )
41{
42   m_slot->dma_cd_w(offset, data);
43}
44 
3545WRITE_LINE_MEMBER( c64_sfx_sound_expander_cartridge_device::irq_w )
3646{
3747   m_slot->irq_w(state);
r14805r14806
5464 
5565static C64_EXPANSION_INTERFACE( expansion_intf )
5666{
57   DEVCB_LINE_MEMBER(c64_sfx_sound_expander_cartridge_device, irq_w),
58   DEVCB_LINE_MEMBER(c64_sfx_sound_expander_cartridge_device, nmi_w),
59   DEVCB_LINE_MEMBER(c64_sfx_sound_expander_cartridge_device, dma_w),
60   DEVCB_LINE_MEMBER(c64_sfx_sound_expander_cartridge_device, reset_w)
67   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c64_sfx_sound_expander_cartridge_device, dma_cd_r),
68   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c64_sfx_sound_expander_cartridge_device, dma_cd_w),
69   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_sfx_sound_expander_cartridge_device, irq_w),
70   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_sfx_sound_expander_cartridge_device, nmi_w),
71   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_sfx_sound_expander_cartridge_device, dma_w),
72   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_sfx_sound_expander_cartridge_device, reset_w)
6173};
6274 
6375 
src/mess/machine/cbmipt.c
r14805r14806
11421142SLOT_INTERFACE_END
11431143
11441144SLOT_INTERFACE_START( c64_expansion_cards )
1145   SLOT_INTERFACE("cpm", C64_CPM)
11451146   SLOT_INTERFACE("dqbb", C64_DQBB)
11461147   SLOT_INTERFACE("easyflash", C64_EASYFLASH)
11471148   SLOT_INTERFACE("georam", C64_GEORAM)
src/mess/machine/c64_sfx_sound_expander.h
r14805r14806
3939   virtual ioport_constructor device_input_ports() const;
4040 
4141   // not really public
42   DECLARE_READ8_MEMBER( dma_cd_r );
43   DECLARE_WRITE8_MEMBER( dma_cd_w );
4244   DECLARE_WRITE_LINE_MEMBER( irq_w );
4345   DECLARE_WRITE_LINE_MEMBER( nmi_w );
4446   DECLARE_WRITE_LINE_MEMBER( dma_w );
src/mess/machine/cbmipt.h
r14805r14806
99#include "machine/c64_4tba.h"
1010#include "machine/c64_bn1541.h"
1111#include "machine/c64_comal80.h"
12#include "machine/c64_cpm.h"
1213#include "machine/c64_dela_ep256.h"
1314#include "machine/c64_dela_ep64.h"
1415#include "machine/c64_dela_ep7x8.h"
src/mess/machine/c64_ieee488.c
r14805r14806
171171//  C64_EXPANSION_INTERFACE( expansion_intf )
172172//-------------------------------------------------
173173 
174READ8_MEMBER( c64_ieee488_device::dma_cd_r )
175{
176   return m_slot->dma_cd_r(offset);
177}
178 
179WRITE8_MEMBER( c64_ieee488_device::dma_cd_w )
180{
181   m_slot->dma_cd_w(offset, data);
182}
183 
174184WRITE_LINE_MEMBER( c64_ieee488_device::irq_w )
175185{
176186   m_slot->irq_w(state);
r14805r14806
193203 
194204static C64_EXPANSION_INTERFACE( expansion_intf )
195205{
196   DEVCB_LINE_MEMBER(c64_ieee488_device, irq_w),
197   DEVCB_LINE_MEMBER(c64_ieee488_device, nmi_w),
198   DEVCB_LINE_MEMBER(c64_ieee488_device, dma_w),
199   DEVCB_LINE_MEMBER(c64_ieee488_device, reset_w)
206   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c64_ieee488_device, dma_cd_r),
207   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c64_ieee488_device, dma_cd_w),
208   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_ieee488_device, irq_w),
209   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_ieee488_device, nmi_w),
210   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_ieee488_device, dma_w),
211   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_ieee488_device, reset_w)
200212};
201213 
202214 
src/mess/machine/c64_ieee488.h
r14805r14806
4444   DECLARE_WRITE8_MEMBER( tpi_pa_w );
4545   DECLARE_READ8_MEMBER( tpi_pc_r );
4646   DECLARE_WRITE8_MEMBER( tpi_pc_w );
47   DECLARE_READ8_MEMBER( dma_cd_r );
48   DECLARE_WRITE8_MEMBER( dma_cd_w );
4749   DECLARE_WRITE_LINE_MEMBER( irq_w );
4850   DECLARE_WRITE_LINE_MEMBER( nmi_w );
4951   DECLARE_WRITE_LINE_MEMBER( dma_w );
src/mess/machine/c64exp.c
r14805r14806
216216   // or initialize to defaults if none provided
217217   else
218218   {
219       memset(&m_in_dma_cd_cb, 0, sizeof(m_in_dma_cd_cb));
220       memset(&m_out_dma_cd_cb, 0, sizeof(m_out_dma_cd_cb));
219221       memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
220222       memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb));
221223       memset(&m_out_dma_cb, 0, sizeof(m_out_dma_cb));
r14805r14806
236238   m_cart = dynamic_cast<device_c64_expansion_card_interface *>(get_card_device());
237239
238240   // resolve callbacks
241   m_in_dma_cd_func.resolve(m_in_dma_cd_cb, *this);
242   m_out_dma_cd_func.resolve(m_out_dma_cd_cb, *this);
239243   m_out_irq_func.resolve(m_out_irq_cb, *this);
240244   m_out_nmi_func.resolve(m_out_nmi_cb, *this);
241245   m_out_dma_func.resolve(m_out_dma_cb, *this);
r14805r14806
503507}
504508
505509
510//-------------------------------------------------
511//  dma_cd_r - DMA read
512//-------------------------------------------------
513
514UINT8 c64_expansion_slot_device::dma_cd_r(offs_t offset)
515{
516   return m_in_dma_cd_func(offset);
517}
518
519
520//-------------------------------------------------
521//  dma_cd_w - DMA write
522//-------------------------------------------------
523
524void c64_expansion_slot_device::dma_cd_w(offs_t offset, UINT8 data)
525{
526   m_out_dma_cd_func(offset, data);
527}
528
529
506530WRITE_LINE_MEMBER( c64_expansion_slot_device::irq_w ) { m_out_irq_func(state); }
507531WRITE_LINE_MEMBER( c64_expansion_slot_device::nmi_w ) { m_out_nmi_func(state); }
508532WRITE_LINE_MEMBER( c64_expansion_slot_device::dma_w ) { m_out_dma_func(state); }
src/mess/machine/c64exp.h
r14805r14806
7272
7373struct c64_expansion_slot_interface
7474{
75   devcb_read8         m_in_dma_cd_cb;
76   devcb_write8      m_out_dma_cd_cb;
7577    devcb_write_line   m_out_irq_cb;
7678    devcb_write_line   m_out_nmi_cb;
7779    devcb_write_line   m_out_dma_cb;
r14805r14806
9395   c64_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
9496   virtual ~c64_expansion_slot_device();
9597
98   // computer interface
9699   UINT8 cd_r(address_space &space, offs_t offset, int roml, int romh, int io1, int io2);
97100   void cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2);
98101   int game_r(offs_t offset, int ba, int rw, int hiram);
99102   DECLARE_READ_LINE_MEMBER( exrom_r );
103   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
100104
105   // cartridge interface
106   UINT8 dma_cd_r(offs_t offset);
107   void dma_cd_w(offs_t offset, UINT8 data);
101108   DECLARE_WRITE_LINE_MEMBER( irq_w );
102109   DECLARE_WRITE_LINE_MEMBER( nmi_w );
103110   DECLARE_WRITE_LINE_MEMBER( dma_w );
104111   DECLARE_WRITE_LINE_MEMBER( reset_w );
105112
106   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
107
108113protected:
109114   // device-level overrides
110115   virtual void device_config_complete();
r14805r14806
128133   // slot interface overrides
129134   virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
130135
136   devcb_resolved_read8      m_in_dma_cd_func;
137   devcb_resolved_write8      m_out_dma_cd_func;
131138   devcb_resolved_write_line   m_out_irq_func;
132139   devcb_resolved_write_line   m_out_nmi_func;
133140   devcb_resolved_write_line   m_out_dma_func;
src/mess/includes/c64.h
r14805r14806
100100   DECLARE_READ8_MEMBER( cpu_r );
101101   DECLARE_WRITE8_MEMBER( cpu_w );
102102   DECLARE_WRITE_LINE_MEMBER( iec_srq_w );
103   DECLARE_READ8_MEMBER( exp_dma_r );
104   DECLARE_WRITE8_MEMBER( exp_dma_w );
103105   DECLARE_WRITE_LINE_MEMBER( exp_irq_w );
104106   DECLARE_WRITE_LINE_MEMBER( exp_nmi_w );
105107
src/mess/drivers/c64.c
r14805r14806
958958//  C64_EXPANSION_INTERFACE( expansion_intf )
959959//-------------------------------------------------
960960
961READ8_MEMBER( c64_state::exp_dma_r )
962{
963   return m_maincpu->memory().space(AS_PROGRAM)->read_byte(offset);
964}
965
966WRITE8_MEMBER( c64_state::exp_dma_w )
967{
968   m_maincpu->memory().space(AS_PROGRAM)->write_byte(offset, data);
969}
970
961971WRITE_LINE_MEMBER( c64_state::exp_irq_w )
962972{
963973   m_exp_irq = state;
r14805r14806
974984
975985static C64_EXPANSION_INTERFACE( expansion_intf )
976986{
987   DEVCB_DRIVER_MEMBER(c64_state, exp_dma_r),
988   DEVCB_DRIVER_MEMBER(c64_state, exp_dma_w),
977989   DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_irq_w),
978990   DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_nmi_w),
979   DEVCB_NULL, // DMA
991   DEVCB_CPU_INPUT_LINE(M6510_TAG, INPUT_LINE_HALT),
980992   DEVCB_CPU_INPUT_LINE(M6510_TAG, INPUT_LINE_RESET)
981993};
982994
src/mess/mess.mak
r14805r14806
778778   $(MESS_MACHINE)/c64_4tba.o   \
779779   $(MESS_MACHINE)/c64_bn1541.o   \
780780   $(MESS_MACHINE)/c64_comal80.o   \
781   $(MESS_MACHINE)/c64_cpm.o   \
781782   $(MESS_MACHINE)/c64_dela_ep256.o   \
782783   $(MESS_MACHINE)/c64_dela_ep64.o   \
783784   $(MESS_MACHINE)/c64_dela_ep7x8.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team