From 49264dd6e17dcb434389b6c93dec56215b948a53 Mon Sep 17 00:00:00 2001 From: Nigel Barnes Date: Fri, 20 Mar 2020 22:25:46 +0000 Subject: bus/bbc/userport: Added the Clwyd Technics Colour Palette and Chameleon devices. --- scripts/src/bus.lua | 2 + src/devices/bus/bbc/userport/palette.cpp | 137 ++++++++++++++++++++++++++++++ src/devices/bus/bbc/userport/palette.h | 78 +++++++++++++++++ src/devices/bus/bbc/userport/userport.cpp | 3 + 4 files changed, 220 insertions(+) create mode 100644 src/devices/bus/bbc/userport/palette.cpp create mode 100644 src/devices/bus/bbc/userport/palette.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 4d0b8b43527..7178b11b8fa 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -587,6 +587,8 @@ if (BUSES["BBC_USERPORT"]~=null) then MAME_DIR .. "src/devices/bus/bbc/userport/userport.h", MAME_DIR .. "src/devices/bus/bbc/userport/beebspch.cpp", MAME_DIR .. "src/devices/bus/bbc/userport/beebspch.h", + MAME_DIR .. "src/devices/bus/bbc/userport/palette.cpp", + MAME_DIR .. "src/devices/bus/bbc/userport/palette.h", MAME_DIR .. "src/devices/bus/bbc/userport/pointer.cpp", MAME_DIR .. "src/devices/bus/bbc/userport/pointer.h", MAME_DIR .. "src/devices/bus/bbc/userport/usersplit.cpp", diff --git a/src/devices/bus/bbc/userport/palette.cpp b/src/devices/bus/bbc/userport/palette.cpp new file mode 100644 index 00000000000..571596e468a --- /dev/null +++ b/src/devices/bus/bbc/userport/palette.cpp @@ -0,0 +1,137 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + Clwyd Technics Colour Palette + + Micro User Chameleon (DIY) - Micro User Jan/Feb 1990 + + TODO: + - the Chameleon should also implement a CB2 handler, as this is + pulsed whenever PB is written to. pb_w should only latch the + data, then a CB2 handler would update the palette. + +**********************************************************************/ + +#include "emu.h" +#include "palette.h" + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(BBC_CHAMELEON, bbc_chameleon_device, "bbc_chameleon", "Micro User Chameleon (DIY)") +DEFINE_DEVICE_TYPE(BBC_CPALETTE, bbc_cpalette_device, "bbc_cpalette", "Clwyd Technics Colour Palette") + + +//------------------------------------------------- +// ROM( chameleon ) +//------------------------------------------------- + +ROM_START(chameleon) + ROM_REGION(0x2000, "exp_rom", 0) + ROM_LOAD("chameleon.rom", 0x0000, 0x2000, CRC(e0ea0252) SHA1(72cf334cdb866ba3dd2353fc7da0dfdb6abf63a7)) +ROM_END + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const tiny_rom_entry* bbc_chameleon_device::device_rom_region() const +{ + return ROM_NAME(chameleon); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// bbc_palette_device - constructor +//------------------------------------------------- + +bbc_palette_device::bbc_palette_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, type, tag, owner, clock) + , device_bbc_userport_interface(mconfig, *this) + , m_palette(*this, ":palette") + , m_colour(0) +{ +} + +bbc_chameleon_device::bbc_chameleon_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_palette_device(mconfig, BBC_CHAMELEON, tag, owner, clock) +{ +} + +bbc_cpalette_device::bbc_cpalette_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_palette_device(mconfig, BBC_CPALETTE, tag, owner, clock) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void bbc_palette_device::device_start() +{ + memset(m_palette_ram, 0, sizeof(m_palette_ram)); + + /* register for save states */ + save_item(NAME(m_colour)); + save_item(NAME(m_palette_ram)); +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +void bbc_chameleon_device::pb_w(uint8_t data) +{ + data ^= 0x0f; + + switch (data >> 6) + { + case 0x00: + m_palette_ram[m_colour].set_r((data << 4) | (data & 0x0f)); + break; + case 0x01: + m_palette_ram[m_colour].set_g((data << 4) | (data & 0x0f)); + break; + case 0x02: + m_palette_ram[m_colour].set_b((data << 4) | (data & 0x0f)); + break; + case 0x03: + m_colour = data & 0x0f; + m_palette->set_pen_colors(0, &m_palette_ram[BIT(data, 5) << 3], 8); + break; + } +} + +void bbc_cpalette_device::pb_w(uint8_t data) +{ + if (BIT(data, 3)) + { + switch (data & 0x07) + { + case 0x00: + m_colour = ~(data >> 4) & 0x07; + break; + case 0x01: + m_palette_ram[m_colour].set_r((data & 0xf0) | (data >> 4)); + break; + case 0x02: + m_palette_ram[m_colour].set_g((data & 0xf0) | (data >> 4)); + break; + case 0x03: + m_palette_ram[m_colour].set_b((data & 0xf0) | (data >> 4)); + break; + } + } + else + { + m_palette->set_pen_colors(0, &m_palette_ram[0], 8); + } +} diff --git a/src/devices/bus/bbc/userport/palette.h b/src/devices/bus/bbc/userport/palette.h new file mode 100644 index 00000000000..7e745dd3853 --- /dev/null +++ b/src/devices/bus/bbc/userport/palette.h @@ -0,0 +1,78 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + Clwyd Technics Colour Palette + + Micro User Chameleon (DIY) - Micro User Jan/Feb 1990 + +**********************************************************************/ + + +#ifndef MAME_BUS_BBC_USERPORT_PALETTE_H +#define MAME_BUS_BBC_USERPORT_PALETTE_H + +#pragma once + +#include "userport.h" +#include "emupal.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class bbc_palette_device : + public device_t, + public device_bbc_userport_interface +{ +protected: + // construction/destruction + bbc_palette_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + + // device-level overrides + virtual void device_start() override; + + required_device m_palette; + + uint8_t m_colour; + rgb_t m_palette_ram[16]; +}; + + +// ======================> bbc_chameleon_device + +class bbc_chameleon_device : public bbc_palette_device +{ +public: + // construction/destruction + bbc_chameleon_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // optional information overrides + virtual const tiny_rom_entry* device_rom_region() const override; + + virtual void pb_w(uint8_t data) override; +}; + + +// ======================> bbc_cpalette_device + +class bbc_cpalette_device : public bbc_palette_device +{ +public: + static constexpr feature_type imperfect_features() { return feature::PALETTE; } + + // construction/destruction + bbc_cpalette_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + virtual void pb_w(uint8_t data) override; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(BBC_CHAMELEON, bbc_chameleon_device) +DECLARE_DEVICE_TYPE(BBC_CPALETTE, bbc_cpalette_device) + + +#endif // MAME_BUS_BBC_USERPORT_PALETTE_H diff --git a/src/devices/bus/bbc/userport/userport.cpp b/src/devices/bus/bbc/userport/userport.cpp index 9e22ce28cd2..3dda13c2950 100644 --- a/src/devices/bus/bbc/userport/userport.cpp +++ b/src/devices/bus/bbc/userport/userport.cpp @@ -109,6 +109,7 @@ void bbc_userport_slot_device::pb_w(uint8_t data) #include "beebspch.h" //#include "digitiser.h" //#include "ev1.h" +#include "palette.h" #include "pointer.h" #include "usersplit.h" //#include "vci.h" @@ -122,6 +123,8 @@ void bbc_userport_devices(device_slot_interface &device) //device.option_add("atr", BBC_ATR); /* Advanced Teletext Receiver (GIS) */ device.option_add("beebspch", BBC_BEEBSPCH); /* Beeb Speech Synthesiser (Watford Electronics) */ //device.option_add("beebvdig", BBC_BEEBVDIG); /* Beeb Video Digitiser (Watford Electronics) */ + device.option_add("chameleon", BBC_CHAMELEON); /* Chameleon */ + device.option_add("cpalette", BBC_CPALETTE); /* Clwyd Technics Colour Palette */ //device.option_add("ev1", BBC_EV1); /* Micro-Robotics EV1 */ //device.option_add("hobbit", BBC_HOBBIT); /* Hobbit Floppy Tape System (Ikon) */ device.option_add("m512mouse", BBC_M512MOUSE); /* Acorn Mouse (provided with Master 512) */ -- cgit v1.2.3