trunk/src/mess/machine/egret.c
| r26886 | r26887 | |
| 38 | 38 | #include "emu.h" |
| 39 | 39 | #include "egret.h" |
| 40 | 40 | #include "cpu/m6805/m6805.h" |
| 41 | | #include "machine/6522via.h" |
| 42 | 41 | #include "sound/asc.h" |
| 43 | 42 | #include "includes/mac.h" |
| 44 | 43 | |
| r26886 | r26887 | |
| 131 | 130 | adb_in = (data & 0x80) ? true : false; |
| 132 | 131 | |
| 133 | 132 | m_adb_dtime = (int)(machine().time().as_ticks(1000000) - last_adb_time); |
| 134 | | m_out_adb_func(((data & 0x80) >> 7) ^ 1); |
| 133 | write_linechange(((data & 0x80) >> 7) ^ 1); |
| 135 | 134 | |
| 136 | 135 | last_adb = data & 0x80; |
| 137 | 136 | last_adb_time = machine().time().as_ticks(1000000); |
| r26886 | r26887 | |
| 153 | 152 | printf("EG-> VIA_DATA: %d (PC=%x)\n", (data>>5)&1, m_maincpu->pc()); |
| 154 | 153 | #endif |
| 155 | 154 | via_data = (data>>5) & 1; |
| 156 | | via6522_device *via1 = machine().device<via6522_device>("via6522_0"); |
| 157 | | via1->write_cb2(via_data); |
| 155 | write_via_data(via_data); |
| 158 | 156 | } |
| 159 | 157 | if (via_clock != ((data>>4)&1)) |
| 160 | 158 | { |
| r26886 | r26887 | |
| 162 | 160 | printf("EG-> VIA_CLOCK: %d (PC=%x)\n", ((data>>4)&1)^1, m_maincpu->pc()); |
| 163 | 161 | #endif |
| 164 | 162 | via_clock = (data>>4) & 1; |
| 165 | | via6522_device *via1 = machine().device<via6522_device>("via6522_0"); |
| 166 | | via1->write_cb1(via_clock^1); |
| 163 | write_via_clock(via_clock^1); |
| 167 | 164 | } |
| 168 | 165 | } |
| 169 | 166 | break; |
| r26886 | r26887 | |
| 187 | 184 | } |
| 188 | 185 | } |
| 189 | 186 | |
| 190 | | m_out_reset_func((reset_line & 8) ? ASSERT_LINE : CLEAR_LINE); |
| 187 | write_reset((reset_line & 8) ? ASSERT_LINE : CLEAR_LINE); |
| 191 | 188 | } |
| 192 | 189 | break; |
| 193 | 190 | } |
| r26886 | r26887 | |
| 337 | 334 | egret_device::egret_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 338 | 335 | : device_t(mconfig, EGRET, "Apple Egret", tag, owner, clock, "egret", __FILE__), |
| 339 | 336 | device_nvram_interface(mconfig, *this), |
| 337 | write_reset(*this), |
| 338 | write_linechange(*this), |
| 339 | write_via_clock(*this), |
| 340 | write_via_data(*this), |
| 340 | 341 | m_maincpu(*this, EGRET_CPU_TAG) |
| 341 | 342 | { |
| 342 | 343 | } |
| r26886 | r26887 | |
| 352 | 353 | egret.rom_offset = type; |
| 353 | 354 | } |
| 354 | 355 | |
| 355 | | void egret_device::device_config_complete() |
| 356 | | { |
| 357 | | // inherit a copy of the static data |
| 358 | | const egret_interface *intf = reinterpret_cast<const egret_interface *>(static_config()); |
| 359 | | if (intf != NULL) |
| 360 | | { |
| 361 | | *static_cast<egret_interface *>(this) = *intf; |
| 362 | | } |
| 363 | | // or initialize to defaults if none provided |
| 364 | | else |
| 365 | | { |
| 366 | | memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb)); |
| 367 | | memset(&m_out_adb_cb, 0, sizeof(m_out_adb_cb)); |
| 368 | | } |
| 369 | | } |
| 370 | | |
| 371 | 356 | //------------------------------------------------- |
| 372 | 357 | // device_start - device-specific startup |
| 373 | 358 | //------------------------------------------------- |
| 374 | 359 | |
| 375 | 360 | void egret_device::device_start() |
| 376 | 361 | { |
| 377 | | m_out_reset_func.resolve(m_out_reset_cb, *this); |
| 378 | | m_out_adb_func.resolve(m_out_adb_cb, *this); |
| 362 | write_reset.resolve_safe(); |
| 363 | write_linechange.resolve_safe(); |
| 364 | write_via_clock.resolve_safe(); |
| 365 | write_via_data.resolve_safe(); |
| 379 | 366 | |
| 380 | 367 | m_timer = timer_alloc(0, NULL); |
| 381 | 368 | save_item(NAME(ddrs[0])); |
trunk/src/mess/machine/egret.h
| r26886 | r26887 | |
| 21 | 21 | // INTERFACE CONFIGURATION MACROS |
| 22 | 22 | //************************************************************************** |
| 23 | 23 | |
| 24 | | #define MCFG_EGRET_ADD(_type, _config) \ |
| 24 | #define MCFG_EGRET_ADD(_type) \ |
| 25 | 25 | MCFG_DEVICE_ADD(EGRET_TAG, EGRET, 0) \ |
| 26 | | MCFG_DEVICE_CONFIG(_config) \ |
| 27 | 26 | MCFG_EGRET_TYPE(_type) |
| 28 | 27 | |
| 29 | | #define MCFG_EGRET_REPLACE(_type, _config) \ |
| 28 | #define MCFG_EGRET_REPLACE(_type) \ |
| 30 | 29 | MCFG_DEVICE_REPLACE(EGRET_TAG, EGRET, 0) \ |
| 31 | | MCFG_DEVICE_CONFIG(_config) \ |
| 32 | 30 | MCFG_EGRET_TYPE(_type) |
| 33 | 31 | |
| 34 | 32 | #define MCFG_EGRET_TYPE(_type) \ |
| r26886 | r26887 | |
| 37 | 35 | #define MCFG_EGRET_REMOVE() \ |
| 38 | 36 | MCFG_DEVICE_REMOVE(EGRET_TAG) |
| 39 | 37 | |
| 38 | #define MCFG_EGRET_RESET_CALLBACK(_cb) \ |
| 39 | downcast<egret_device *>(device)->set_reset_cb(DEVCB2_##_cb); |
| 40 | |
| 41 | #define MCFG_EGRET_LINECHANGE_CALLBACK(_cb) \ |
| 42 | downcast<egret_device *>(device)->set_linechange_cb(DEVCB2_##_cb); |
| 43 | |
| 44 | #define MCFG_EGRET_VIA_CLOCK_CALLBACK(_cb) \ |
| 45 | downcast<egret_device *>(device)->set_via_clock_cb(DEVCB2_##_cb); |
| 46 | |
| 47 | #define MCFG_EGRET_VIA_DATA_CALLBACK(_cb) \ |
| 48 | downcast<egret_device *>(device)->set_via_data_cb(DEVCB2_##_cb); |
| 49 | |
| 40 | 50 | //************************************************************************** |
| 41 | 51 | // TYPE DEFINITIONS |
| 42 | 52 | //************************************************************************** |
| 43 | 53 | |
| 44 | | struct egret_interface |
| 45 | | { |
| 46 | | devcb_write_line m_out_reset_cb; |
| 47 | | devcb_write_line m_out_adb_cb; |
| 48 | | }; |
| 49 | | |
| 50 | 54 | // ======================> egret_device |
| 51 | 55 | |
| 52 | | class egret_device : public device_t, public device_nvram_interface, public egret_interface |
| 56 | class egret_device : public device_t, public device_nvram_interface |
| 53 | 57 | { |
| 54 | 58 | public: |
| 55 | 59 | // construction/destruction |
| r26886 | r26887 | |
| 90 | 94 | |
| 91 | 95 | int rom_offset; |
| 92 | 96 | |
| 97 | template<class _write> void set_reset_cb(_write wr) { write_reset.set_callback(wr); } |
| 98 | template<class _write> void set_linechange_cb(_write wr) { write_linechange.set_callback(wr); } |
| 99 | template<class _write> void set_via_clock_cb(_write wr) { write_via_clock.set_callback(wr); } |
| 100 | template<class _write> void set_via_data_cb(_write wr) { write_via_data.set_callback(wr); } |
| 101 | |
| 102 | devcb2_write_line write_reset, write_linechange, write_via_clock, write_via_data; |
| 103 | |
| 93 | 104 | protected: |
| 94 | 105 | // device-level overrides |
| 95 | 106 | virtual void device_start(); |
| 96 | 107 | virtual void device_reset(); |
| 97 | | virtual void device_config_complete(); |
| 98 | 108 | virtual machine_config_constructor device_mconfig_additions() const; |
| 99 | 109 | virtual const rom_entry *device_rom_region() const; |
| 100 | 110 | |
| r26886 | r26887 | |
| 120 | 130 | bool pram_loaded; |
| 121 | 131 | |
| 122 | 132 | void send_port(address_space &space, UINT8 offset, UINT8 data); |
| 123 | | |
| 124 | | devcb_resolved_write_line m_out_reset_func; |
| 125 | | devcb_resolved_write_line m_out_adb_func; |
| 126 | 133 | }; |
| 127 | 134 | |
| 128 | 135 | // device type definition |
trunk/src/mess/machine/cuda.c
| r26886 | r26887 | |
| 39 | 39 | #include "emu.h" |
| 40 | 40 | #include "cuda.h" |
| 41 | 41 | #include "cpu/m6805/m6805.h" |
| 42 | | #include "machine/6522via.h" |
| 43 | 42 | #include "sound/asc.h" |
| 44 | 43 | #include "includes/mac.h" |
| 45 | 44 | |
| r26886 | r26887 | |
| 130 | 129 | printf("CU ADB: 0->1 time %lld\n", machine().time().as_ticks(1000000) - last_adb_time); |
| 131 | 130 | }*/ |
| 132 | 131 | |
| 132 | // allow the linechange handler to override us |
| 133 | 133 | adb_in = (data & 0x80) ? true : false; |
| 134 | 134 | |
| 135 | 135 | m_adb_dtime = (int)(machine().time().as_ticks(1000000) - last_adb_time); |
| 136 | | m_out_adb_func(((data & 0x80) >> 7) ^ 1); |
| 136 | write_linechange(((data & 0x80) >> 7) ^ 1); |
| 137 | 137 | |
| 138 | 138 | last_adb = data & 0x80; |
| 139 | 139 | last_adb_time = machine().time().as_ticks(1000000); |
| r26886 | r26887 | |
| 155 | 155 | printf("CU-> VIA_DATA: %d (PC=%x)\n", (data>>5)&1, m_maincpu->pc()); |
| 156 | 156 | #endif |
| 157 | 157 | via_data = (data>>5) & 1; |
| 158 | | via6522_device *via1 = machine().device<via6522_device>("via6522_0"); |
| 159 | | via1->write_cb2(via_data); |
| 158 | write_via_data(via_data); |
| 160 | 159 | } |
| 161 | 160 | if (via_clock != ((data>>4)&1)) |
| 162 | 161 | { |
| r26886 | r26887 | |
| 164 | 163 | printf("CU-> VIA_CLOCK: %d (PC=%x)\n", ((data>>4)&1)^1, m_maincpu->pc()); |
| 165 | 164 | #endif |
| 166 | 165 | via_clock = (data>>4) & 1; |
| 167 | | via6522_device *via1 = machine().device<via6522_device>("via6522_0"); |
| 168 | | via1->write_cb1(via_clock); |
| 166 | write_via_clock(via_clock); |
| 169 | 167 | } |
| 170 | 168 | } |
| 171 | 169 | break; |
| r26886 | r26887 | |
| 180 | 178 | // falling edge, should reset the machine too |
| 181 | 179 | if ((ports[2] & 8) && !(data&8)) |
| 182 | 180 | { |
| 183 | | m_out_reset_func(ASSERT_LINE); |
| 184 | | m_out_reset_func(CLEAR_LINE); |
| 181 | write_reset(ASSERT_LINE); |
| 182 | write_reset(CLEAR_LINE); |
| 185 | 183 | |
| 186 | 184 | // if PRAM's waiting to be loaded, transfer it now |
| 187 | 185 | if (!pram_loaded) |
| r26886 | r26887 | |
| 385 | 383 | cuda_device::cuda_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 386 | 384 | : device_t(mconfig, CUDA, "Apple Cuda", tag, owner, clock, "cuda", __FILE__), |
| 387 | 385 | device_nvram_interface(mconfig, *this), |
| 386 | write_reset(*this), |
| 387 | write_linechange(*this), |
| 388 | write_via_clock(*this), |
| 389 | write_via_data(*this), |
| 388 | 390 | m_maincpu(*this, CUDA_CPU_TAG) |
| 389 | 391 | { |
| 390 | 392 | } |
| r26886 | r26887 | |
| 406 | 408 | |
| 407 | 409 | void cuda_device::device_start() |
| 408 | 410 | { |
| 409 | | m_out_reset_func.resolve(m_out_reset_cb, *this); |
| 410 | | m_out_adb_func.resolve(m_out_adb_cb, *this); |
| 411 | write_reset.resolve_safe(); |
| 412 | write_linechange.resolve_safe(); |
| 413 | write_via_clock.resolve_safe(); |
| 414 | write_via_data.resolve_safe(); |
| 411 | 415 | |
| 412 | 416 | m_timer = timer_alloc(0, NULL); |
| 413 | 417 | m_prog_timer = timer_alloc(1, NULL); |
| r26886 | r26887 | |
| 507 | 511 | } |
| 508 | 512 | } |
| 509 | 513 | |
| 510 | | void cuda_device::device_config_complete() |
| 511 | | { |
| 512 | | // inherit a copy of the static data |
| 513 | | const cuda_interface *intf = reinterpret_cast<const cuda_interface *>(static_config()); |
| 514 | | if (intf != NULL) |
| 515 | | { |
| 516 | | *static_cast<cuda_interface *>(this) = *intf; |
| 517 | | } |
| 518 | | // or initialize to defaults if none provided |
| 519 | | else |
| 520 | | { |
| 521 | | memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb)); |
| 522 | | } |
| 523 | | } |
| 524 | | |
| 525 | 514 | // the 6805 program clears PRAM on startup (on h/w it's always running once a battery is inserted) |
| 526 | 515 | // we deal with that by loading pram from disk to a secondary buffer and then slapping it into "live" |
| 527 | 516 | // once the cuda reboots the 68k |
trunk/src/mess/machine/cuda.h
| r26886 | r26887 | |
| 19 | 19 | // INTERFACE CONFIGURATION MACROS |
| 20 | 20 | //************************************************************************** |
| 21 | 21 | |
| 22 | | #define MCFG_CUDA_ADD(_type, _config) \ |
| 22 | #define MCFG_CUDA_ADD(_type) \ |
| 23 | 23 | MCFG_DEVICE_ADD(CUDA_TAG, CUDA, 0) \ |
| 24 | | MCFG_DEVICE_CONFIG(_config) \ |
| 25 | 24 | MCFG_CUDA_TYPE(_type) |
| 26 | 25 | |
| 27 | | #define MCFG_CUDA_REPLACE(_type, _config) \ |
| 26 | #define MCFG_CUDA_REPLACE(_type) \ |
| 28 | 27 | MCFG_DEVICE_REPLACE(CUDA_TAG, CUDA, 0) \ |
| 29 | | MCFG_DEVICE_CONFIG(_config) \ |
| 30 | 28 | MCFG_CUDA_TYPE(_type) |
| 31 | 29 | |
| 32 | 30 | #define MCFG_CUDA_REMOVE() \ |
| r26886 | r26887 | |
| 38 | 36 | #define MCFG_CUDA_REMOVE() \ |
| 39 | 37 | MCFG_DEVICE_REMOVE(CUDA_TAG) |
| 40 | 38 | |
| 39 | #define MCFG_CUDA_RESET_CALLBACK(_cb) \ |
| 40 | downcast<cuda_device *>(device)->set_reset_cb(DEVCB2_##_cb); |
| 41 | |
| 42 | #define MCFG_CUDA_LINECHANGE_CALLBACK(_cb) \ |
| 43 | downcast<cuda_device *>(device)->set_linechange_cb(DEVCB2_##_cb); |
| 44 | |
| 45 | #define MCFG_CUDA_VIA_CLOCK_CALLBACK(_cb) \ |
| 46 | downcast<cuda_device *>(device)->set_via_clock_cb(DEVCB2_##_cb); |
| 47 | |
| 48 | #define MCFG_CUDA_VIA_DATA_CALLBACK(_cb) \ |
| 49 | downcast<cuda_device *>(device)->set_via_data_cb(DEVCB2_##_cb); |
| 50 | |
| 41 | 51 | //************************************************************************** |
| 42 | 52 | // TYPE DEFINITIONS |
| 43 | 53 | //************************************************************************** |
| 44 | 54 | |
| 45 | | struct cuda_interface |
| 46 | | { |
| 47 | | devcb_write_line m_out_reset_cb; |
| 48 | | devcb_write_line m_out_adb_cb; |
| 49 | | }; |
| 50 | | |
| 51 | 55 | // ======================> cuda_device |
| 52 | 56 | |
| 53 | | class cuda_device : public device_t, public device_nvram_interface, public cuda_interface |
| 57 | class cuda_device : public device_t, public device_nvram_interface |
| 54 | 58 | { |
| 55 | 59 | public: |
| 56 | 60 | // construction/destruction |
| r26886 | r26887 | |
| 91 | 95 | |
| 92 | 96 | int rom_offset; |
| 93 | 97 | |
| 98 | template<class _write> void set_reset_cb(_write wr) { write_reset.set_callback(wr); } |
| 99 | template<class _write> void set_linechange_cb(_write wr) { write_linechange.set_callback(wr); } |
| 100 | template<class _write> void set_via_clock_cb(_write wr) { write_via_clock.set_callback(wr); } |
| 101 | template<class _write> void set_via_data_cb(_write wr) { write_via_data.set_callback(wr); } |
| 102 | |
| 103 | devcb2_write_line write_reset, write_linechange, write_via_clock, write_via_data; |
| 104 | |
| 94 | 105 | protected: |
| 95 | 106 | // device-level overrides |
| 96 | 107 | virtual void device_start(); |
| 97 | 108 | virtual void device_reset(); |
| 98 | | virtual void device_config_complete(); |
| 99 | 109 | virtual machine_config_constructor device_mconfig_additions() const; |
| 100 | 110 | virtual const rom_entry *device_rom_region() const; |
| 101 | 111 | |
| r26886 | r26887 | |
| 121 | 131 | bool pram_loaded; |
| 122 | 132 | |
| 123 | 133 | void send_port(address_space &space, UINT8 offset, UINT8 data); |
| 124 | | |
| 125 | | devcb_resolved_write_line m_out_reset_func; |
| 126 | | devcb_resolved_write_line m_out_adb_func; |
| 127 | 134 | }; |
| 128 | 135 | |
| 129 | 136 | // device type definition |