trunk/src/devices/bus/cpc/transtape.cpp
| r0 | r250187 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Barry Rodewald |
| 3 | /* |
| 4 | * transtape.c -- Hard Micro SA Transtape |
| 5 | * |
| 6 | * Spanish hacking device |
| 7 | * |
| 8 | * Further info at - http://cpcwiki.eu/index.php/Transtape |
| 9 | */ |
| 10 | |
| 11 | #include "transtape.h" |
| 12 | #include "includes/amstrad.h" |
| 13 | |
| 14 | //************************************************************************** |
| 15 | // DEVICE DEFINITIONS |
| 16 | //************************************************************************** |
| 17 | |
| 18 | const device_type CPC_TRANSTAPE = &device_creator<cpc_transtape_device>; |
| 19 | |
| 20 | ROM_START( cpc_transtape ) |
| 21 | ROM_REGION( 0x4000, "tt_rom", 0 ) |
| 22 | ROM_LOAD( "tta.rom", 0x0000, 0x4000, CRC(c568da76) SHA1(cc509d21216bf11d40f9a3e0791ef7f4ada03790) ) |
| 23 | ROM_END |
| 24 | |
| 25 | const rom_entry *cpc_transtape_device::device_rom_region() const |
| 26 | { |
| 27 | return ROM_NAME( cpc_transtape ); |
| 28 | } |
| 29 | |
| 30 | static INPUT_PORTS_START(cpc_transtape) |
| 31 | PORT_START("transtape") |
| 32 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Red Button") PORT_CODE(KEYCODE_F1) PORT_CHANGED_MEMBER(DEVICE_SELF,cpc_transtape_device,button_red_w,1) |
| 33 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Black Button") PORT_CODE(KEYCODE_F2) PORT_CHANGED_MEMBER(DEVICE_SELF,cpc_transtape_device,button_black_w,1) |
| 34 | INPUT_PORTS_END |
| 35 | |
| 36 | ioport_constructor cpc_transtape_device::device_input_ports() const |
| 37 | { |
| 38 | return INPUT_PORTS_NAME( cpc_transtape ); |
| 39 | } |
| 40 | |
| 41 | //************************************************************************** |
| 42 | // LIVE DEVICE |
| 43 | //************************************************************************** |
| 44 | |
| 45 | cpc_transtape_device::cpc_transtape_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 46 | device_t(mconfig, CPC_TRANSTAPE, "HM Transtape", tag, owner, clock, "cpc_transtape", __FILE__), |
| 47 | device_cpc_expansion_card_interface(mconfig, *this), |
| 48 | m_rom_active(false), |
| 49 | m_romen(true), |
| 50 | m_output(0) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | //------------------------------------------------- |
| 55 | // device_start - device-specific startup |
| 56 | //------------------------------------------------- |
| 57 | |
| 58 | void cpc_transtape_device::device_start() |
| 59 | { |
| 60 | m_slot = dynamic_cast<cpc_expansion_slot_device *>(owner()); |
| 61 | m_cpu = static_cast<cpu_device*>(machine().device("maincpu")); |
| 62 | m_space = &m_cpu->space(AS_IO); |
| 63 | |
| 64 | m_ram = auto_alloc_array_clear(machine(), UINT8, 0x2000); |
| 65 | |
| 66 | m_space->install_write_handler(0xfbf0,0xfbf0,0,0,write8_delegate(FUNC(cpc_transtape_device::output_w),this)); |
| 67 | m_space->install_read_handler(0xfbff,0xfbff,0,0,read8_delegate(FUNC(cpc_transtape_device::input_r),this)); |
| 68 | } |
| 69 | |
| 70 | //------------------------------------------------- |
| 71 | // device_reset - device-specific reset |
| 72 | //------------------------------------------------- |
| 73 | |
| 74 | void cpc_transtape_device::device_reset() |
| 75 | { |
| 76 | // TODO |
| 77 | m_rom_active = false; |
| 78 | m_output = 0; |
| 79 | } |
| 80 | |
| 81 | void cpc_transtape_device::map_enable() |
| 82 | { |
| 83 | UINT8* ROM = memregion("tt_rom")->base(); |
| 84 | if(m_output & 0x02) // ROM enable |
| 85 | { |
| 86 | membank(":bank1")->set_base(ROM); |
| 87 | membank(":bank2")->set_base(ROM+0x2000); |
| 88 | } |
| 89 | if(m_output & 0x01) // RAM enable |
| 90 | { |
| 91 | membank(":bank7")->set_base(m_ram); |
| 92 | membank(":bank15")->set_base(m_ram); |
| 93 | membank(":bank8")->set_base(m_ram); // repeats in second 8kB |
| 94 | membank(":bank16")->set_base(m_ram); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | INPUT_CHANGED_MEMBER(cpc_transtape_device::button_red_w) |
| 99 | { |
| 100 | // enables device ROM at 0x0000, RAM at 0xc000, generates NMI |
| 101 | if(newval & 0x01) |
| 102 | { |
| 103 | m_output |= 0x1f; |
| 104 | map_enable(); |
| 105 | m_cpu->set_input_line(INPUT_LINE_NMI,PULSE_LINE); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | INPUT_CHANGED_MEMBER(cpc_transtape_device::button_black_w) |
| 110 | { |
| 111 | // enables device ROM at 0x0000, RAM at 0xc000(?), force execution to start at 0x0000 |
| 112 | if(newval & 0x01) |
| 113 | { |
| 114 | m_output |= 0x1f; |
| 115 | map_enable(); |
| 116 | m_cpu->set_pc(0); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | READ8_MEMBER(cpc_transtape_device::input_r) |
| 121 | { |
| 122 | // TODO |
| 123 | return 0x80; |
| 124 | } |
| 125 | |
| 126 | WRITE8_MEMBER(cpc_transtape_device::output_w) |
| 127 | { |
| 128 | // TODO |
| 129 | m_output = data; |
| 130 | m_slot->rom_select(space,0,get_rom_bank()); // trigger rethink |
| 131 | } |
| 132 | |
| 133 | void cpc_transtape_device::set_mapping(UINT8 type) |
| 134 | { |
| 135 | if(type != MAP_OTHER) |
| 136 | return; |
| 137 | map_enable(); |
| 138 | } |
| 139 | |
| 140 | |
trunk/src/devices/bus/cpc/transtape.h
| r0 | r250187 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Barry Rodewald |
| 3 | /* |
| 4 | * transtape.c -- Hard Micro SA Transtape |
| 5 | * |
| 6 | * Spanish hacking device |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef TRANSTAPE_H_ |
| 11 | #define TRANSTAPE_H_ |
| 12 | |
| 13 | #include "emu.h" |
| 14 | #include "cpcexp.h" |
| 15 | |
| 16 | class cpc_transtape_device : public device_t, |
| 17 | public device_cpc_expansion_card_interface |
| 18 | { |
| 19 | public: |
| 20 | // construction/destruction |
| 21 | cpc_transtape_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 22 | |
| 23 | // optional information overrides |
| 24 | virtual const rom_entry *device_rom_region() const; |
| 25 | virtual ioport_constructor device_input_ports() const; |
| 26 | |
| 27 | virtual void set_mapping(UINT8 type); |
| 28 | virtual WRITE_LINE_MEMBER( romen_w ) { m_romen = state; } |
| 29 | |
| 30 | DECLARE_READ8_MEMBER(input_r); |
| 31 | DECLARE_WRITE8_MEMBER(output_w); |
| 32 | DECLARE_INPUT_CHANGED_MEMBER(button_red_w); |
| 33 | DECLARE_INPUT_CHANGED_MEMBER(button_black_w); |
| 34 | |
| 35 | protected: |
| 36 | // device-level overrides |
| 37 | virtual void device_start(); |
| 38 | virtual void device_reset(); |
| 39 | |
| 40 | private: |
| 41 | cpc_expansion_slot_device *m_slot; |
| 42 | cpu_device* m_cpu; |
| 43 | address_space* m_space; |
| 44 | UINT8* m_ram; // 8kB internal RAM |
| 45 | bool m_rom_active; |
| 46 | bool m_romen; |
| 47 | UINT8 m_output; |
| 48 | |
| 49 | void map_enable(); |
| 50 | }; |
| 51 | |
| 52 | // device type definition |
| 53 | extern const device_type CPC_TRANSTAPE; |
| 54 | |
| 55 | #endif /* TRANSTAPE_H_ */ |
trunk/src/mame/drivers/amstrad.cpp
| r250186 | r250187 | |
| 816 | 816 | SLOT_INTERFACE("brunword4", CPC_BRUNWORD_MK4) |
| 817 | 817 | SLOT_INTERFACE("hd20", CPC_HD20) |
| 818 | 818 | SLOT_INTERFACE("doubler", CPC_DOUBLER) |
| 819 | SLOT_INTERFACE("transtape", CPC_TRANSTAPE) |
| 819 | 820 | SLOT_INTERFACE_END |
| 820 | 821 | |
| 821 | 822 | SLOT_INTERFACE_START(cpc_exp_cards) |
| r250186 | r250187 | |
| 833 | 834 | SLOT_INTERFACE("brunword4", CPC_BRUNWORD_MK4) |
| 834 | 835 | SLOT_INTERFACE("hd20", CPC_HD20) |
| 835 | 836 | SLOT_INTERFACE("doubler", CPC_DOUBLER) |
| 837 | SLOT_INTERFACE("transtape", CPC_TRANSTAPE) |
| 836 | 838 | SLOT_INTERFACE_END |
| 837 | 839 | |
| 838 | 840 | SLOT_INTERFACE_START(cpcplus_exp_cards) |
| r250186 | r250187 | |
| 848 | 850 | SLOT_INTERFACE("smartwatch", CPC_SMARTWATCH) |
| 849 | 851 | SLOT_INTERFACE("hd20", CPC_HD20) |
| 850 | 852 | SLOT_INTERFACE("doubler", CPC_DOUBLER) |
| 853 | SLOT_INTERFACE("transtape", CPC_TRANSTAPE) // Plus compatible? |
| 851 | 854 | SLOT_INTERFACE_END |
| 852 | 855 | |
| 853 | 856 | SLOT_INTERFACE_START(aleste_exp_cards) |
| r250186 | r250187 | |
| 865 | 868 | SLOT_INTERFACE("brunword4", CPC_BRUNWORD_MK4) |
| 866 | 869 | SLOT_INTERFACE("hd20", CPC_HD20) |
| 867 | 870 | SLOT_INTERFACE("doubler", CPC_DOUBLER) |
| 871 | SLOT_INTERFACE("transtape", CPC_TRANSTAPE) |
| 868 | 872 | SLOT_INTERFACE("magicsound", AL_MAGICSOUND) |
| 869 | 873 | SLOT_INTERFACE_END |
| 870 | 874 | |