1 // license:BSD-3-Clause 2 // copyright-holders:Philip Bennett 3 /*************************************************************************** 4 5 tlc34076.h 6 7 Basic implementation of the TLC34076 palette chip and similar 8 compatible chips. 9 10 ***************************************************************************/ 11 12 #ifndef MAME_VIDEO_TLC34076_H 13 #define MAME_VIDEO_TLC34076_H 14 15 #pragma once 16 17 18 /*************************************************************************** 19 TYPE DEFINITIONS 20 ***************************************************************************/ 21 22 class tlc34076_device : public device_t, public device_palette_interface 23 { 24 public: 25 enum tlc34076_bits 26 { 27 TLC34076_6_BIT = 6, 28 TLC34076_8_BIT = 8 29 }; 30 31 // construction/destruction tlc34076_device(const machine_config & mconfig,const char * tag,device_t * owner,tlc34076_bits bits)32 tlc34076_device(const machine_config &mconfig, const char *tag, device_t *owner, tlc34076_bits bits) 33 : tlc34076_device(mconfig, tag, owner, (uint32_t)0) 34 { 35 set_bits(bits); 36 } 37 38 tlc34076_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 39 40 // configuration helpers set_bits(tlc34076_bits bits)41 void set_bits(tlc34076_bits bits) { m_dacbits = bits; } 42 43 // public interface 44 u8 read(offs_t offset); 45 void write(offs_t offset, u8 data); 46 47 protected: 48 // device-level overrides 49 virtual void device_start() override; 50 virtual void device_reset() override; 51 52 // device_palette_interface overrides palette_entries()53 virtual uint32_t palette_entries() const override { return 0x100; } 54 55 private: 56 // internal helpers 57 void update_pen(uint8_t i); 58 59 // internal state 60 std::unique_ptr<uint8_t[]> m_local_paletteram[3]; 61 uint8_t m_regs[0x10]; 62 uint8_t m_palettedata[3]; 63 uint8_t m_writeindex; 64 uint8_t m_readindex; 65 uint8_t m_dacbits; 66 }; 67 68 69 DECLARE_DEVICE_TYPE(TLC34076, tlc34076_device) 70 71 #endif // MAME_VIDEO_TLC34076_H 72