1 // license:BSD-3-Clause 2 // copyright-holders:hap 3 /****************************************************************************** 4 * 5 * CXG chess computer driver base class 6 * 7 ******************************************************************************/ 8 9 #pragma once 10 11 #ifndef MAME_INCLUDES_CXGBASE_H 12 #define MAME_INCLUDES_CXGBASE_H 13 14 #include "machine/timer.h" 15 #include "sound/dac.h" 16 17 class cxgbase_state : public driver_device 18 { 19 public: cxgbase_state(const machine_config & mconfig,device_type type,const char * tag)20 cxgbase_state(const machine_config &mconfig, device_type type, const char *tag) : 21 driver_device(mconfig, type, tag), 22 m_maincpu(*this, "maincpu"), 23 m_irq_on(*this, "irq_on"), 24 m_dac(*this, "dac"), 25 m_inp_matrix(*this, "IN.%u", 0), 26 m_out_x(*this, "%u.%u", 0U, 0U), 27 m_out_a(*this, "%u.a", 0U), 28 m_out_digit(*this, "digit%u", 0U), 29 m_display_wait(33), 30 m_display_maxy(1), 31 m_display_maxx(0) 32 { } 33 34 // devices/pointers 35 required_device<cpu_device> m_maincpu; 36 optional_device<timer_device> m_irq_on; 37 optional_device<dac_bit_interface> m_dac; 38 optional_ioport_array<10> m_inp_matrix; // max 10 39 output_finder<0x20, 0x20> m_out_x; 40 output_finder<0x20> m_out_a; 41 output_finder<0x20> m_out_digit; 42 43 // misc common 44 u16 m_inp_mux; // multiplexed keypad mask 45 u16 m_led_select; 46 u16 m_led_data; 47 48 u16 read_inputs(int columns); 49 50 // periodic interrupts TIMER_DEVICE_CALLBACK_MEMBER(irq_on)51 template<int Line> TIMER_DEVICE_CALLBACK_MEMBER(irq_on) { m_maincpu->set_input_line(Line, ASSERT_LINE); } TIMER_DEVICE_CALLBACK_MEMBER(irq_off)52 template<int Line> TIMER_DEVICE_CALLBACK_MEMBER(irq_off) { m_maincpu->set_input_line(Line, CLEAR_LINE); } 53 54 // display common 55 int m_display_wait; // led/lamp off-delay in milliseconds (default 33ms) 56 int m_display_maxy; // display matrix number of rows 57 int m_display_maxx; // display matrix number of columns (max 31 for now) 58 59 u32 m_display_state[0x20]; // display matrix rows data (last bit is used for always-on) 60 u16 m_display_segmask[0x20]; // if not 0, display matrix row is a digit, mask indicates connected segments 61 u8 m_display_decay[0x20][0x20]; // (internal use) 62 63 TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); 64 void display_update(); 65 void set_display_size(int maxx, int maxy); 66 void display_matrix(int maxx, int maxy, u32 setx, u32 sety, bool update = true); 67 68 protected: 69 virtual void machine_start() override; 70 virtual void machine_reset() override; 71 }; 72 73 74 INPUT_PORTS_EXTERN( cxg_cb_magnets ); 75 76 #endif // MAME_INCLUDES_CXGBASE_H 77