mirror of
https://github.com/holub/mame
synced 2025-05-12 00:58:53 +03:00
Imported CDP1862 CGC from MESS. (no whatsnew)
This commit is contained in:
parent
d3049dfe83
commit
c7d0b7bb64
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1204,6 +1204,8 @@ src/emu/video.c svneol=native#text/plain
|
||||
src/emu/video.h svneol=native#text/plain
|
||||
src/emu/video/cdp1861.c svneol=native#text/plain
|
||||
src/emu/video/cdp1861.h svneol=native#text/plain
|
||||
src/emu/video/cdp1862.c svneol=native#text/plain
|
||||
src/emu/video/cdp1862.h svneol=native#text/plain
|
||||
src/emu/video/crt9007.c svneol=native#text/plain
|
||||
src/emu/video/crt9007.h svneol=native#text/plain
|
||||
src/emu/video/crt9021.c svneol=native#text/plain
|
||||
|
@ -232,6 +232,7 @@ EMUMACHINEOBJS = \
|
||||
|
||||
EMUVIDEOOBJS = \
|
||||
$(EMUVIDEO)/cdp1861.o \
|
||||
$(EMUVIDEO)/cdp1862.o \
|
||||
$(EMUVIDEO)/crt9007.o \
|
||||
$(EMUVIDEO)/crt9021.o \
|
||||
$(EMUVIDEO)/crt9212.o \
|
||||
|
235
src/emu/video/cdp1862.c
Normal file
235
src/emu/video/cdp1862.c
Normal file
@ -0,0 +1,235 @@
|
||||
/**********************************************************************
|
||||
|
||||
RCA CDP1862 Video Display Controller emulation
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
|
||||
- calculate colors from luminance/chrominance resistors
|
||||
|
||||
*/
|
||||
|
||||
#include "emu.h"
|
||||
#include "cdp1862.h"
|
||||
#include "machine/devhelpr.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACROS / CONSTANTS
|
||||
//**************************************************************************
|
||||
|
||||
static const int CDP1862_BACKGROUND_COLOR_SEQUENCE[] = { 2, 0, 1, 4 };
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
||||
// devices
|
||||
const device_type CDP1862 = cdp1862_device_config::static_alloc_device_config;
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE CONFIGURATION
|
||||
//**************************************************************************
|
||||
|
||||
GENERIC_DEVICE_CONFIG_SETUP(cdp1862, "CDP1862")
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void cdp1862_device_config::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const cdp1862_interface *intf = reinterpret_cast<const cdp1862_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<cdp1862_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_in_rd_func, 0, sizeof(m_in_rd_func));
|
||||
memset(&m_in_bd_func, 0, sizeof(m_in_bd_func));
|
||||
memset(&m_in_gd_func, 0, sizeof(m_in_gd_func));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INLINE HELPERS
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// initialize_palette -
|
||||
//-------------------------------------------------
|
||||
|
||||
inline void cdp1862_device::initialize_palette()
|
||||
{
|
||||
int i;
|
||||
|
||||
double res_total = m_config.m_chr_r + m_config.m_chr_g + m_config.m_chr_b + m_config.m_chr_bkg;
|
||||
|
||||
int weight_r = (m_config.m_chr_r / res_total) * 100;
|
||||
int weight_g = (m_config.m_chr_g / res_total) * 100;
|
||||
int weight_b = (m_config.m_chr_b / res_total) * 100;
|
||||
int weight_bkg = (m_config.m_chr_bkg / res_total) * 100;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
int r, g, b, luma = 0;
|
||||
|
||||
luma += (i & 4) ? weight_r : 0;
|
||||
luma += (i & 1) ? weight_g : 0;
|
||||
luma += (i & 2) ? weight_b : 0;
|
||||
luma += (i & 8) ? 0 : weight_bkg;
|
||||
|
||||
luma = (luma * 0xff) / 100;
|
||||
|
||||
r = (i & 4) ? luma : 0;
|
||||
g = (i & 1) ? luma : 0;
|
||||
b = (i & 2) ? luma : 0;
|
||||
|
||||
palette_set_color_rgb(m_machine, i, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// cdp1862_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
cdp1862_device::cdp1862_device(running_machine &_machine, const cdp1862_device_config &config)
|
||||
: device_t(_machine, config),
|
||||
m_config(config)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void cdp1862_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
devcb_resolve_read_line(&m_in_rd_func, &m_config.m_in_rd_func, this);
|
||||
devcb_resolve_read_line(&m_in_bd_func, &m_config.m_in_bd_func, this);
|
||||
devcb_resolve_read_line(&m_in_gd_func, &m_config.m_in_gd_func, this);
|
||||
|
||||
// find devices
|
||||
m_screen = m_machine.device<screen_device>(m_config.m_screen_tag);
|
||||
m_bitmap = auto_bitmap_alloc(m_machine, m_screen->width(), m_screen->height(), m_screen->format());
|
||||
|
||||
// init palette
|
||||
initialize_palette();
|
||||
|
||||
// register for state saving
|
||||
save_item(NAME(m_bgcolor));
|
||||
save_item(NAME(m_con));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void cdp1862_device::device_reset()
|
||||
{
|
||||
m_bgcolor = 0;
|
||||
m_con = 1;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// dma_w -
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER( cdp1862_device::dma_w )
|
||||
{
|
||||
int rd = 1, bd = 1, gd = 1;
|
||||
int sx = m_screen->hpos() + 4;
|
||||
int y = m_screen->vpos();
|
||||
int x;
|
||||
|
||||
if (!m_con)
|
||||
{
|
||||
rd = devcb_call_read_line(&m_in_rd_func);
|
||||
bd = devcb_call_read_line(&m_in_bd_func);
|
||||
gd = devcb_call_read_line(&m_in_gd_func);
|
||||
}
|
||||
|
||||
for (x = 0; x < 8; x++)
|
||||
{
|
||||
int color = CDP1862_BACKGROUND_COLOR_SEQUENCE[m_bgcolor] + 8;
|
||||
|
||||
if (BIT(data, 7))
|
||||
{
|
||||
color = (gd << 2) | (bd << 1) | rd;
|
||||
}
|
||||
|
||||
*BITMAP_ADDR16(m_bitmap, y, sx + x) = color;
|
||||
|
||||
data <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// disp_on_w -
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( cdp1862_device::bkg_w )
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
m_bgcolor++;
|
||||
|
||||
if (m_bgcolor > 3)
|
||||
{
|
||||
m_bgcolor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// disp_off_w -
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( cdp1862_device::con_w )
|
||||
{
|
||||
if (!state)
|
||||
{
|
||||
m_con = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// update_screen -
|
||||
//-------------------------------------------------
|
||||
|
||||
void cdp1862_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
|
||||
{
|
||||
copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect);
|
||||
bitmap_fill(m_bitmap, cliprect, CDP1862_BACKGROUND_COLOR_SEQUENCE[m_bgcolor] + 8);
|
||||
}
|
149
src/emu/video/cdp1862.h
Normal file
149
src/emu/video/cdp1862.h
Normal file
@ -0,0 +1,149 @@
|
||||
/**********************************************************************
|
||||
|
||||
RCA CDP1862 COS/MOS Color Generator Controller emulation
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************
|
||||
_____ _____
|
||||
RD 1 |* \_/ | 24 Vdd
|
||||
_RESET 2 | | 23 R LUM
|
||||
_CON 3 | | 22 G LUM
|
||||
B CHR 4 | | 21 GD
|
||||
B LUM 5 | | 20 BKG LUM
|
||||
BKG 6 | CDP1862 | 19 G CHR
|
||||
_LD CLK 7 | | 18 R CHR
|
||||
STP 8 | | 17 BKG CHR
|
||||
CLK OUT 9 | | 16 BD
|
||||
_SYNC 10 | | 15 BURST
|
||||
LUM IN 11 | | 14 _XTAL
|
||||
Vss 12 |_____________| 13 XTAL
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __CDP1862__
|
||||
#define __CDP1862__
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACROS / CONSTANTS
|
||||
//**************************************************************************
|
||||
|
||||
#define CPD1862_CLOCK XTAL_7_15909MHz
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_CDP1862_ADD(_tag, _clock, _config) \
|
||||
MCFG_DEVICE_ADD(_tag, CDP1862, _clock) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
|
||||
|
||||
#define CDP1862_INTERFACE(name) \
|
||||
const cdp1862_interface (name) =
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
|
||||
// ======================> cdp1862_interface
|
||||
|
||||
struct cdp1862_interface
|
||||
{
|
||||
const char *m_screen_tag;
|
||||
|
||||
devcb_read_line m_in_rd_func;
|
||||
devcb_read_line m_in_bd_func;
|
||||
devcb_read_line m_in_gd_func;
|
||||
|
||||
double m_lum_r; // red luminance resistor value
|
||||
double m_lum_b; // blue luminance resistor value
|
||||
double m_lum_g; // green luminance resistor value
|
||||
double m_lum_bkg; // background luminance resistor value
|
||||
|
||||
double m_chr_r; // red chrominance resistor value
|
||||
double m_chr_b; // blue chrominance resistor value
|
||||
double m_chr_g; // green chrominance resistor value
|
||||
double m_chr_bkg; // background chrominance resistor value
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ======================> cdp1862_device_config
|
||||
|
||||
class cdp1862_device_config : public device_config,
|
||||
public cdp1862_interface
|
||||
{
|
||||
friend class cdp1862_device;
|
||||
|
||||
// construction/destruction
|
||||
cdp1862_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
|
||||
|
||||
public:
|
||||
// allocators
|
||||
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
|
||||
virtual device_t *alloc_device(running_machine &machine) const;
|
||||
|
||||
protected:
|
||||
// device_config overrides
|
||||
virtual void device_config_complete();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ======================> cdp1862_device
|
||||
|
||||
class cdp1862_device : public device_t
|
||||
{
|
||||
friend class cdp1862_device_config;
|
||||
|
||||
// construction/destruction
|
||||
cdp1862_device(running_machine &_machine, const cdp1862_device_config &_config);
|
||||
|
||||
public:
|
||||
DECLARE_WRITE8_MEMBER( dma_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( bkg_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( con_w );
|
||||
|
||||
void update_screen(bitmap_t *bitmap, const rectangle *cliprect);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
private:
|
||||
inline void initialize_palette();
|
||||
|
||||
devcb_resolved_read_line m_in_rd_func;
|
||||
devcb_resolved_read_line m_in_bd_func;
|
||||
devcb_resolved_read_line m_in_gd_func;
|
||||
|
||||
screen_device *m_screen; // screen
|
||||
bitmap_t *m_bitmap; // bitmap
|
||||
|
||||
int m_bgcolor; // background color
|
||||
int m_con; // color on
|
||||
|
||||
const cdp1862_device_config &m_config;
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
extern const device_type CDP1862;
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user