From 88f330aa8ee8b319a5ec760abc4ed5815fa3cafa Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Sun, 21 Oct 2012 21:47:04 +0000 Subject: [PATCH] (MESS) Mac: Add support for Lapis ProColor Server 8*16 PDS video card [R. Belmont, Sharkpuncher] --- .gitattributes | 2 + src/mess/drivers/mac.c | 4 +- src/mess/mess.mak | 1 + src/mess/video/pds30_procolor816.c | 353 +++++++++++++++++++++++++++++ src/mess/video/pds30_procolor816.h | 53 +++++ 5 files changed, 412 insertions(+), 1 deletion(-) create mode 100644 src/mess/video/pds30_procolor816.c create mode 100644 src/mess/video/pds30_procolor816.h diff --git a/.gitattributes b/.gitattributes index d5d75fe21ba..8cc218d6846 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7542,6 +7542,8 @@ src/mess/video/pcw16.c svneol=native#text/plain src/mess/video/pdp1.c svneol=native#text/plain src/mess/video/pds30_cb264.c svneol=native#text/plain src/mess/video/pds30_cb264.h svneol=native#text/plain +src/mess/video/pds30_procolor816.c svneol=native#text/plain +src/mess/video/pds30_procolor816.h svneol=native#text/plain src/mess/video/pecom.c svneol=native#text/plain src/mess/video/pet.c svneol=native#text/plain src/mess/video/pk8020.c svneol=native#text/plain diff --git a/src/mess/drivers/mac.c b/src/mess/drivers/mac.c index 7a67f8be3b9..44263b64906 100644 --- a/src/mess/drivers/mac.c +++ b/src/mess/drivers/mac.c @@ -70,6 +70,7 @@ #include "machine/nubus_asntmc3b.h" #include "video/nubus_m2video.h" #include "video/pds30_cb264.h" +#include "video/pds30_procolor816.h" #include "includes/mac.h" #include "mac.lh" @@ -860,7 +861,8 @@ static SLOT_INTERFACE_START(mac_nubus_cards) SLOT_INTERFACE_END static SLOT_INTERFACE_START(mac_pds030_cards) - SLOT_INTERFACE("cb264", PDS030_CB264SE30) + SLOT_INTERFACE("cb264", PDS030_CB264SE30) // RasterOps Colorboard 264/SE30 + SLOT_INTERFACE("pc816", PDS030_PROCOLOR816) // Lapis ProColor Server 8*16 PDS SLOT_INTERFACE_END /*************************************************************************** diff --git a/src/mess/mess.mak b/src/mess/mess.mak index 83c8d5d5e96..1c201a82574 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -709,6 +709,7 @@ $(MESSOBJ)/apple.a: \ $(MESS_MACHINE)/nubus_asntmc3b.o \ $(MESS_VIDEO)/nubus_wsportrait.o \ $(MESS_VIDEO)/pds30_cb264.o \ + $(MESS_VIDEO)/pds30_procolor816.o \ $(MESSOBJ)/applied.a: \ $(MESS_VIDEO)/mbee.o \ diff --git a/src/mess/video/pds30_procolor816.c b/src/mess/video/pds30_procolor816.c new file mode 100644 index 00000000000..4350c3ff9a6 --- /dev/null +++ b/src/mess/video/pds30_procolor816.c @@ -0,0 +1,353 @@ +/*************************************************************************** + + Lapis ProColor Server 8*16 video card + + FsFF6001: DAC color # (seems to have the data bits perfectly reversed) + FsFF6003: DAC color write (not bitswapped) + FsFF6017: Mode (13 = 1bpp, 17 = 2bpp, 1b = 4bpp, 1e = 8bpp, 0a = 15bpp) + FsFF7000: Bit 2 is VBL IRQ enable/ack + FsFF7001: Bit 0 is VBL status + +***************************************************************************/ + +#include "emu.h" +#include "video/pds30_procolor816.h" + +#define PROCOLOR816_SCREEN_NAME "cb264_screen" +#define PROCOLOR816_ROM_REGION "cb264_rom" + +#define VRAM_SIZE (0x200000) // 2 megs? + +MACHINE_CONFIG_FRAGMENT( procolor816 ) + MCFG_SCREEN_ADD( PROCOLOR816_SCREEN_NAME, RASTER) + MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, nubus_procolor816_device, screen_update) + MCFG_SCREEN_RAW_PARAMS(25175000, 800, 0, 640, 525, 0, 480) + MCFG_SCREEN_SIZE(1024,768) + MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) +MACHINE_CONFIG_END + +ROM_START( procolor816 ) + ROM_REGION(0x8000, PROCOLOR816_ROM_REGION, 0) + ROM_LOAD( "procolor_ver60590.bin", 0x000000, 0x008000, CRC(ebef6168) SHA1(e41ecc7d12fc13bc74f9223ca02920e8a7eb072b) ) +ROM_END + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type PDS030_PROCOLOR816 = &device_creator; + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor nubus_procolor816_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( procolor816 ); +} + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *nubus_procolor816_device::device_rom_region() const +{ + return ROM_NAME( procolor816 ); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// nubus_procolor816_device - constructor +//------------------------------------------------- + +nubus_procolor816_device::nubus_procolor816_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, PDS030_PROCOLOR816, "Lapis ProColor Server 8*16", tag, owner, clock), + device_nubus_card_interface(mconfig, *this) +{ + m_shortname = "pd3_pc16"; +} + +nubus_procolor816_device::nubus_procolor816_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, type, name, tag, owner, clock), + device_nubus_card_interface(mconfig, *this) +{ + m_shortname = "pd3_pc16"; +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void nubus_procolor816_device::device_start() +{ + UINT32 slotspace; + + // set_nubus_device makes m_slot valid + set_nubus_device(); + install_declaration_rom(this, PROCOLOR816_ROM_REGION); + + slotspace = get_slotspace(); + +// printf("[procolor816 %p] slotspace = %x\n", this, slotspace); + + m_vram = auto_alloc_array(machine(), UINT8, VRAM_SIZE); + m_vram32 = (UINT32 *)m_vram; + + m_nubus->install_device(slotspace, slotspace+VRAM_SIZE-1, read32_delegate(FUNC(nubus_procolor816_device::vram_r), this), write32_delegate(FUNC(nubus_procolor816_device::vram_w), this)); + m_nubus->install_device(slotspace+0x900000, slotspace+VRAM_SIZE-1+0x900000, read32_delegate(FUNC(nubus_procolor816_device::vram_r), this), write32_delegate(FUNC(nubus_procolor816_device::vram_w), this)); + m_nubus->install_device(slotspace+0xf00000, slotspace+0xff7fff, read32_delegate(FUNC(nubus_procolor816_device::procolor816_r), this), write32_delegate(FUNC(nubus_procolor816_device::procolor816_w), this)); + + m_timer = timer_alloc(0, NULL); + m_screen = NULL; // can we look this up now? +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void nubus_procolor816_device::device_reset() +{ + m_count = 0; + m_clutoffs = 0; + m_vbl_disable = 1; + m_mode = 3; + memset(m_vram, 0, VRAM_SIZE); + memset(m_palette, 0, sizeof(m_palette)); + + m_palette[0] = MAKE_RGB(255, 255, 255); + m_palette[0x80] = MAKE_RGB(0, 0, 0); +} + + +void nubus_procolor816_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr) +{ + if (!m_vbl_disable) + { + raise_slot_irq(); + } + + m_timer->adjust(m_screen->time_until_pos(479, 0), 0); +} + +/*************************************************************************** + + CB264 section + +***************************************************************************/ + +UINT32 nubus_procolor816_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + UINT32 *scanline; + int x, y; + UINT8 pixels, *vram; + + // first time? kick off the VBL timer + if (!m_screen) + { + m_screen = &screen; + m_timer->adjust(m_screen->time_until_pos(479, 0), 0); + } + + vram = m_vram + 4; + + switch (m_mode) + { + case 0: // 1 bpp? + for (y = 0; y < 480; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < 640/8; x++) + { + pixels = vram[(y * 640/8) + (BYTE4_XOR_BE(x))]; + + *scanline++ = m_palette[(pixels&0x80)]; + *scanline++ = m_palette[((pixels<<1)&0x80)]; + *scanline++ = m_palette[((pixels<<2)&0x80)]; + *scanline++ = m_palette[((pixels<<3)&0x80)]; + *scanline++ = m_palette[((pixels<<4)&0x80)]; + *scanline++ = m_palette[((pixels<<5)&0x80)]; + *scanline++ = m_palette[((pixels<<6)&0x80)]; + *scanline++ = m_palette[((pixels<<7)&0x80)]; + } + } + break; + + case 1: // 2 bpp + for (y = 0; y < 480; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < 640/4; x++) + { + pixels = vram[(y * 640/4) + (BYTE4_XOR_BE(x))]; + + *scanline++ = m_palette[(pixels&0xc0)]; + *scanline++ = m_palette[((pixels<<2)&0xc0)]; + *scanline++ = m_palette[((pixels<<4)&0xc0)]; + *scanline++ = m_palette[((pixels<<6)&0xc0)]; + } + } + break; + + case 2: // 4 bpp + for (y = 0; y < 480; y++) + { + scanline = &bitmap.pix32(y); + + for (x = 0; x < 640/2; x++) + { + pixels = vram[(y * 640/2) + (BYTE4_XOR_BE(x))]; + + *scanline++ = m_palette[(pixels&0xf0)]; + *scanline++ = m_palette[((pixels&0x0f)<<4)]; + } + } + break; + + case 3: // 8 bpp + for (y = 0; y < 480; y++) + { + scanline = &bitmap.pix32(y); + + for (x = 0; x < 640; x++) + { + pixels = vram[(y * 640) + (BYTE4_XOR_BE(x))]; + *scanline++ = m_palette[pixels]; + } + } + break; + + case 4: // 15 bpp + { + UINT16 *vram16 = (UINT16 *)m_vram; + UINT16 pixels; + + for (y = 0; y < 480; y++) + { + scanline = &bitmap.pix32(y); + for (x = 0; x < 640; x++) + { + pixels = vram16[(y * 640) + (x^1)]; + *scanline++ = MAKE_RGB(((pixels>>10) & 0x1f)<<3, ((pixels>>5) & 0x1f)<<3, (pixels & 0x1f)<<3); + } + } + } + break; + + default: + fatalerror("procolor816: unknown video mode %d\n", m_mode); + break; + } + return 0; +} + +WRITE32_MEMBER( nubus_procolor816_device::procolor816_w ) +{ + switch (offset) + { + case 0x3d805: // mode + if (mem_mask == 0xff) + { + switch (data & 0xff) + { + case 0x13: + m_mode = 0; + break; + + case 0x17: + m_mode = 1; + break; + + case 0x1b: + m_mode = 2; + break; + + case 0x1e: + m_mode = 3; + break; + + case 0x0a: + m_mode = 4; + break; + } + } + break; + + case 0x3d800: + if (mem_mask == 0x00ff0000) + { + // printf("%08x to DAC control (PC=%x)\n", data, space.device().safe_pc()); + m_clutoffs = BITSWAP8((data>>16)&0xff, 0, 1, 2, 3, 4, 5, 6, 7); + } + else if (mem_mask == 0x000000ff) + { + m_colors[m_count++] = (data & 0xff); + + if (m_count == 3) + { +// printf("RAMDAC: color %02x = %02x %02x %02x (PC=%x)\n", m_clutoffs, m_colors[0], m_colors[1], m_colors[2], space.device().safe_pc() ); + m_palette[m_clutoffs] = MAKE_RGB(m_colors[0], m_colors[1], m_colors[2]); + m_clutoffs++; + if (m_clutoffs > 255) + { + m_clutoffs = 0; + } + m_count = 0; + } + } + break; + + case 0x3dc00: // VBL control + if (mem_mask == 0xff000000) + { + if (data & 0x04000000) + { + m_vbl_disable = 0; + lower_slot_irq(); + } + else + { + m_vbl_disable = 1; + } + } + break; + + default: +// printf("procolor816_w: %08x @ %x, mask %08x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc()); + break; + } +} + +READ32_MEMBER( nubus_procolor816_device::procolor816_r ) +{ + if (offset == 0x3dc00) + { + m_toggle ^= 0xffffffff; + return m_toggle; + } + else if (offset == 0x3d807) + { + return 0; + } + else + { + printf("procolor816_r: @ %x, mask %08x [PC=%x]\n", offset, mem_mask, machine().device("maincpu")->safe_pc()); + } + + return 0; +} + +WRITE32_MEMBER( nubus_procolor816_device::vram_w ) +{ + COMBINE_DATA(&m_vram32[offset]); +} + +READ32_MEMBER( nubus_procolor816_device::vram_r ) +{ + return m_vram32[offset]; +} + diff --git a/src/mess/video/pds30_procolor816.h b/src/mess/video/pds30_procolor816.h new file mode 100644 index 00000000000..19d2ba536ca --- /dev/null +++ b/src/mess/video/pds30_procolor816.h @@ -0,0 +1,53 @@ +#pragma once + +#ifndef __NUBUS_PROCOLOR816_H__ +#define __NUBUS_PROCOLOR816_H__ + +#include "emu.h" +#include "machine/nubus.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> nubus_procolor816_device + +class nubus_procolor816_device : + public device_t, + public device_nubus_card_interface +{ +public: + // construction/destruction + nubus_procolor816_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + nubus_procolor816_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual machine_config_constructor device_mconfig_additions() const; + virtual const rom_entry *device_rom_region() const; + + UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + + DECLARE_READ32_MEMBER(procolor816_r); + DECLARE_WRITE32_MEMBER(procolor816_w); + DECLARE_READ32_MEMBER(vram_r); + DECLARE_WRITE32_MEMBER(vram_w); + +public: + UINT8 *m_vram; + UINT32 *m_vram32; + UINT32 m_mode, m_vbl_disable, m_toggle; + UINT32 m_palette[256], m_colors[3], m_count, m_clutoffs; + screen_device *m_screen; + emu_timer *m_timer; +}; + + +// device type definition +extern const device_type PDS030_PROCOLOR816; + +#endif /* __NUBUS_PROCOLOR816_H__ */