src/mess/machine/c64_cpm.c
| r0 | r14806 | |
| 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 | |
| 26 | const device_type C64_CPM = &device_creator<c64_cpm_cartridge_device>; |
| 27 | |
| 28 | |
| 29 | //------------------------------------------------- |
| 30 | // ADDRESS_MAP( z80_mem ) |
| 31 | //------------------------------------------------- |
| 32 | |
| 33 | static ADDRESS_MAP_START( z80_mem, AS_PROGRAM, 8, c64_cpm_cartridge_device ) |
| 34 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(dma_r, dma_w) |
| 35 | ADDRESS_MAP_END |
| 36 | |
| 37 | |
| 38 | //------------------------------------------------- |
| 39 | // ADDRESS_MAP( z80_io ) |
| 40 | //------------------------------------------------- |
| 41 | |
| 42 | static ADDRESS_MAP_START( z80_io, AS_IO, 8, c64_cpm_cartridge_device ) |
| 43 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(dma_r, dma_w) |
| 44 | ADDRESS_MAP_END |
| 45 | |
| 46 | |
| 47 | //------------------------------------------------- |
| 48 | // MACHINE_CONFIG_FRAGMENT( c64_cpm ) |
| 49 | //------------------------------------------------- |
| 50 | |
| 51 | static 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) |
| 55 | MACHINE_CONFIG_END |
| 56 | |
| 57 | |
| 58 | //------------------------------------------------- |
| 59 | // machine_config_additions - device-specific |
| 60 | // machine configurations |
| 61 | //------------------------------------------------- |
| 62 | |
| 63 | machine_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 | |
| 78 | c64_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 | |
| 90 | void 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 | |
| 100 | void 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 | |
| 111 | void 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 | |
| 126 | READ8_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 | |
| 136 | WRITE8_MEMBER( c64_cpm_cartridge_device::dma_w ) |
| 137 | { |
| 138 | m_slot->dma_cd_w(offset | 0x1000, data); |
| 139 | } |
src/mess/machine/c64_cpm.h
| r0 | r14806 | |
| 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 | |
| 29 | class c64_cpm_cartridge_device : public device_t, |
| 30 | public device_c64_expansion_card_interface |
| 31 | { |
| 32 | public: |
| 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 | |
| 43 | protected: |
| 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 | |
| 52 | private: |
| 53 | required_device<cpu_device> m_maincpu; |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | // device type definition |
| 58 | extern const device_type C64_CPM; |
| 59 | |
| 60 | |
| 61 | #endif |
src/mess/machine/c64_sfx_sound_expander.c
| r14805 | r14806 | |
| 32 | 32 | // C64_EXPANSION_INTERFACE( expansion_intf )
|
| 33 | 33 | //-------------------------------------------------
|
| 34 | 34 | |
| 35 | READ8_MEMBER( c64_sfx_sound_expander_cartridge_device::dma_cd_r )
|
| 36 | {
|
| 37 | return m_slot->dma_cd_r(offset);
|
| 38 | }
|
| 39 | |
| 40 | WRITE8_MEMBER( c64_sfx_sound_expander_cartridge_device::dma_cd_w )
|
| 41 | {
|
| 42 | m_slot->dma_cd_w(offset, data);
|
| 43 | }
|
| 44 | |
| 35 | 45 | WRITE_LINE_MEMBER( c64_sfx_sound_expander_cartridge_device::irq_w )
|
| 36 | 46 | {
|
| 37 | 47 | m_slot->irq_w(state);
|
| r14805 | r14806 | |
| 54 | 64 | |
| 55 | 65 | static C64_EXPANSION_INTERFACE( expansion_intf )
|
| 56 | 66 | {
|
| 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)
|
| 61 | 73 | };
|
| 62 | 74 | |
| 63 | 75 | |
src/mess/machine/c64_ieee488.c
| r14805 | r14806 | |
| 171 | 171 | // C64_EXPANSION_INTERFACE( expansion_intf )
|
| 172 | 172 | //-------------------------------------------------
|
| 173 | 173 | |
| 174 | READ8_MEMBER( c64_ieee488_device::dma_cd_r )
|
| 175 | {
|
| 176 | return m_slot->dma_cd_r(offset);
|
| 177 | }
|
| 178 | |
| 179 | WRITE8_MEMBER( c64_ieee488_device::dma_cd_w )
|
| 180 | {
|
| 181 | m_slot->dma_cd_w(offset, data);
|
| 182 | }
|
| 183 | |
| 174 | 184 | WRITE_LINE_MEMBER( c64_ieee488_device::irq_w )
|
| 175 | 185 | {
|
| 176 | 186 | m_slot->irq_w(state);
|
| r14805 | r14806 | |
| 193 | 203 | |
| 194 | 204 | static C64_EXPANSION_INTERFACE( expansion_intf )
|
| 195 | 205 | {
|
| 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)
|
| 200 | 212 | };
|
| 201 | 213 | |
| 202 | 214 | |
src/mess/machine/c64exp.c
| r14805 | r14806 | |
| 216 | 216 | // or initialize to defaults if none provided |
| 217 | 217 | else |
| 218 | 218 | { |
| 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)); |
| 219 | 221 | memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb)); |
| 220 | 222 | memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb)); |
| 221 | 223 | memset(&m_out_dma_cb, 0, sizeof(m_out_dma_cb)); |
| r14805 | r14806 | |
| 236 | 238 | m_cart = dynamic_cast<device_c64_expansion_card_interface *>(get_card_device()); |
| 237 | 239 | |
| 238 | 240 | // 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); |
| 239 | 243 | m_out_irq_func.resolve(m_out_irq_cb, *this); |
| 240 | 244 | m_out_nmi_func.resolve(m_out_nmi_cb, *this); |
| 241 | 245 | m_out_dma_func.resolve(m_out_dma_cb, *this); |
| r14805 | r14806 | |
| 503 | 507 | } |
| 504 | 508 | |
| 505 | 509 | |
| 510 | //------------------------------------------------- |
| 511 | // dma_cd_r - DMA read |
| 512 | //------------------------------------------------- |
| 513 | |
| 514 | UINT8 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 | |
| 524 | void c64_expansion_slot_device::dma_cd_w(offs_t offset, UINT8 data) |
| 525 | { |
| 526 | m_out_dma_cd_func(offset, data); |
| 527 | } |
| 528 | |
| 529 | |
| 506 | 530 | WRITE_LINE_MEMBER( c64_expansion_slot_device::irq_w ) { m_out_irq_func(state); } |
| 507 | 531 | WRITE_LINE_MEMBER( c64_expansion_slot_device::nmi_w ) { m_out_nmi_func(state); } |
| 508 | 532 | WRITE_LINE_MEMBER( c64_expansion_slot_device::dma_w ) { m_out_dma_func(state); } |
src/mess/machine/c64exp.h
| r14805 | r14806 | |
| 72 | 72 | |
| 73 | 73 | struct c64_expansion_slot_interface |
| 74 | 74 | { |
| 75 | devcb_read8 m_in_dma_cd_cb; |
| 76 | devcb_write8 m_out_dma_cd_cb; |
| 75 | 77 | devcb_write_line m_out_irq_cb; |
| 76 | 78 | devcb_write_line m_out_nmi_cb; |
| 77 | 79 | devcb_write_line m_out_dma_cb; |
| r14805 | r14806 | |
| 93 | 95 | c64_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 94 | 96 | virtual ~c64_expansion_slot_device(); |
| 95 | 97 | |
| 98 | // computer interface |
| 96 | 99 | UINT8 cd_r(address_space &space, offs_t offset, int roml, int romh, int io1, int io2); |
| 97 | 100 | void cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2); |
| 98 | 101 | int game_r(offs_t offset, int ba, int rw, int hiram); |
| 99 | 102 | DECLARE_READ_LINE_MEMBER( exrom_r ); |
| 103 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 100 | 104 | |
| 105 | // cartridge interface |
| 106 | UINT8 dma_cd_r(offs_t offset); |
| 107 | void dma_cd_w(offs_t offset, UINT8 data); |
| 101 | 108 | DECLARE_WRITE_LINE_MEMBER( irq_w ); |
| 102 | 109 | DECLARE_WRITE_LINE_MEMBER( nmi_w ); |
| 103 | 110 | DECLARE_WRITE_LINE_MEMBER( dma_w ); |
| 104 | 111 | DECLARE_WRITE_LINE_MEMBER( reset_w ); |
| 105 | 112 | |
| 106 | | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 107 | | |
| 108 | 113 | protected: |
| 109 | 114 | // device-level overrides |
| 110 | 115 | virtual void device_config_complete(); |
| r14805 | r14806 | |
| 128 | 133 | // slot interface overrides |
| 129 | 134 | virtual const char * get_default_card_software(const machine_config &config, emu_options &options); |
| 130 | 135 | |
| 136 | devcb_resolved_read8 m_in_dma_cd_func; |
| 137 | devcb_resolved_write8 m_out_dma_cd_func; |
| 131 | 138 | devcb_resolved_write_line m_out_irq_func; |
| 132 | 139 | devcb_resolved_write_line m_out_nmi_func; |
| 133 | 140 | devcb_resolved_write_line m_out_dma_func; |
src/mess/drivers/c64.c
| r14805 | r14806 | |
| 958 | 958 | // C64_EXPANSION_INTERFACE( expansion_intf ) |
| 959 | 959 | //------------------------------------------------- |
| 960 | 960 | |
| 961 | READ8_MEMBER( c64_state::exp_dma_r ) |
| 962 | { |
| 963 | return m_maincpu->memory().space(AS_PROGRAM)->read_byte(offset); |
| 964 | } |
| 965 | |
| 966 | WRITE8_MEMBER( c64_state::exp_dma_w ) |
| 967 | { |
| 968 | m_maincpu->memory().space(AS_PROGRAM)->write_byte(offset, data); |
| 969 | } |
| 970 | |
| 961 | 971 | WRITE_LINE_MEMBER( c64_state::exp_irq_w ) |
| 962 | 972 | { |
| 963 | 973 | m_exp_irq = state; |
| r14805 | r14806 | |
| 974 | 984 | |
| 975 | 985 | static C64_EXPANSION_INTERFACE( expansion_intf ) |
| 976 | 986 | { |
| 987 | DEVCB_DRIVER_MEMBER(c64_state, exp_dma_r), |
| 988 | DEVCB_DRIVER_MEMBER(c64_state, exp_dma_w), |
| 977 | 989 | DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_irq_w), |
| 978 | 990 | DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_nmi_w), |
| 979 | | DEVCB_NULL, // DMA |
| 991 | DEVCB_CPU_INPUT_LINE(M6510_TAG, INPUT_LINE_HALT), |
| 980 | 992 | DEVCB_CPU_INPUT_LINE(M6510_TAG, INPUT_LINE_RESET) |
| 981 | 993 | }; |
| 982 | 994 | |