mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
apple2: Initial support for ComputerEyes/2 slot card [R. Belmont, Golden Child]
This commit is contained in:
parent
f53b6e7d18
commit
a40bc736e7
@ -2143,6 +2143,8 @@ if (BUSES["A2BUS"]~=null) then
|
||||
MAME_DIR .. "src/devices/bus/a2bus/transwarp.h",
|
||||
MAME_DIR .. "src/devices/bus/a2bus/4play.cpp",
|
||||
MAME_DIR .. "src/devices/bus/a2bus/4play.h",
|
||||
MAME_DIR .. "src/devices/bus/a2bus/computereyes2.cpp",
|
||||
MAME_DIR .. "src/devices/bus/a2bus/computereyes2.h",
|
||||
}
|
||||
end
|
||||
|
||||
|
224
src/devices/bus/a2bus/computereyes2.cpp
Normal file
224
src/devices/bus/a2bus/computereyes2.cpp
Normal file
@ -0,0 +1,224 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:R. Belmont
|
||||
/*********************************************************************
|
||||
|
||||
computereyes2.c
|
||||
|
||||
Implemention of the Digital Vision ComputerEyes/2 card.
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "computereyes2.h"
|
||||
|
||||
/***************************************************************************
|
||||
PARAMETERS
|
||||
***************************************************************************/
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(A2BUS_COMPUTEREYES2, a2bus_computereyes2_device, "a2ceyes2", "Digital Vision ComputerEyes/2")
|
||||
|
||||
/***************************************************************************
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_add_mconfig - add device configuration
|
||||
//-------------------------------------------------
|
||||
|
||||
void a2bus_computereyes2_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
IMAGE_PICTURE(config, m_picture);
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
a2bus_computereyes2_device::a2bus_computereyes2_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_a2bus_card_interface(mconfig, *this),
|
||||
m_picture(*this, "srcimg")
|
||||
{
|
||||
}
|
||||
|
||||
a2bus_computereyes2_device::a2bus_computereyes2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
a2bus_computereyes2_device(mconfig, A2BUS_COMPUTEREYES2, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void a2bus_computereyes2_device::device_start()
|
||||
{
|
||||
}
|
||||
|
||||
void a2bus_computereyes2_device::device_reset()
|
||||
{
|
||||
m_x = m_y = 0;
|
||||
m_cer0 = m_cer2 = 0;
|
||||
m_cer1 = 0x80; // interface disabled
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
read_c0nx - called for reads from this card's c0nx space
|
||||
|
||||
CER0 read bits
|
||||
01 = capture data bit (read)
|
||||
10 = sync (read)
|
||||
20 = test bit (used in detection) (read)
|
||||
|
||||
CER0 write bits
|
||||
0F = brightness (write)
|
||||
40 = monitor relay (write)
|
||||
80 = turn on test bit (write)
|
||||
|
||||
CER1 write bits
|
||||
0F = contrast (guessing bits 0..3?)
|
||||
80 = interface on (bit 7)
|
||||
|
||||
CER2 write bits
|
||||
(any) resets the threshold for a new pixel
|
||||
-------------------------------------------------*/
|
||||
|
||||
uint8_t a2bus_computereyes2_device::read_c0nx(uint8_t offset)
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 0:
|
||||
if (m_cer0 & 0x80)
|
||||
{
|
||||
return m_cer0 | 0x20;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 ret = (m_cer0 & 0xc0) | 0x10;
|
||||
u64 video_ticks = machine().time().as_ticks(1021800);
|
||||
int frame_time = video_ticks % (65 * 262); // 65 clocks per scanline, 262 scanlines per frame
|
||||
int h = frame_time % 65;
|
||||
int v = frame_time / 65;
|
||||
|
||||
// generate sync bit
|
||||
if (v > 224)
|
||||
{
|
||||
// vsync
|
||||
ret &= ~0x10;
|
||||
}
|
||||
else if (h > 49)
|
||||
{
|
||||
// hsync
|
||||
ret &= ~0x10;
|
||||
}
|
||||
|
||||
// is the interface enabled? (Active low, 0 = enabled)
|
||||
if (!(m_cer1 & 0x80))
|
||||
{
|
||||
{
|
||||
if (m_bActive)
|
||||
{
|
||||
//printf("read at X=%d Y=%d CX=%d CY=%d thr=%02x\n", h, v, m_x, m_y, m_threshold);
|
||||
ret |= (m_a2_bitmap[m_x + ((v-2) * 280)] > m_threshold) ? 0 : 1;
|
||||
if (m_threshold > 0x20)
|
||||
{
|
||||
m_threshold -= 0x20;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_y++;
|
||||
if (m_y >= 192)
|
||||
{
|
||||
if (m_x < 280)
|
||||
{
|
||||
m_x++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = 0;
|
||||
}
|
||||
|
||||
m_bActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* else
|
||||
{
|
||||
printf("SYNC at X=%d Y=%d CX=%d CY=%d thr=%02x\n", h, v, m_x, m_y, m_threshold);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: return m_cer1;
|
||||
case 2: return m_cer2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
write_c0nx - called for writes to this card's c0nx space
|
||||
-------------------------------------------------*/
|
||||
|
||||
void a2bus_computereyes2_device::write_c0nx(uint8_t offset, uint8_t data)
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 0:
|
||||
m_cer0 = data & 0xcf;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (!(data & 0x80))
|
||||
{
|
||||
m_bActive = false;
|
||||
}
|
||||
m_y = 0;
|
||||
|
||||
if (!(data & 0x80) && (m_cer1 & 0x80))
|
||||
{
|
||||
m_x = m_y = 0;
|
||||
std::fill_n(m_a2_bitmap, 280*193, 0);
|
||||
|
||||
m_bitmap = &m_picture->get_bitmap();
|
||||
if (m_bitmap)
|
||||
{
|
||||
// convert arbitrary sized ARGB32 image to a 188x193 image with 256 levels of grayscale
|
||||
double stepx = (double)m_bitmap->width() / 188.0;
|
||||
double stepy = (double)m_bitmap->height() / 193.0;
|
||||
|
||||
for (int y = 0; y < 193; y++)
|
||||
{
|
||||
for (int x = 0; x < 280; x++)
|
||||
{
|
||||
u32 pixel = m_bitmap->pix((int)((double)y * stepy), (int)((double)x * stepx));
|
||||
double mono = ((0.2126 * (double)(((pixel>>16) & 0xff) / 255.0)) +
|
||||
(0.7152 * (double)(((pixel>>8) & 0xff) / 255.0)) +
|
||||
(0.0722 * (double)((pixel& 0xff) / 255.0)));
|
||||
m_a2_bitmap[(y*280)+x] = (u8)(mono * 255.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_cer1 = data;
|
||||
break;
|
||||
|
||||
case 2: // written to initialize a sample
|
||||
m_cer2 = data;
|
||||
m_threshold = 0xe0;
|
||||
if (!m_bActive)
|
||||
{
|
||||
m_y = 0;
|
||||
}
|
||||
m_bActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
55
src/devices/bus/a2bus/computereyes2.h
Normal file
55
src/devices/bus/a2bus/computereyes2.h
Normal file
@ -0,0 +1,55 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:R. Belmont
|
||||
/*********************************************************************
|
||||
|
||||
computereyes2.h
|
||||
|
||||
Implemention of the Digital Vision ComputerEyes/2 card
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef MAME_BUS_A2BUS_COMPEYES2_H
|
||||
#define MAME_BUS_A2BUS_COMPEYES2_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "a2bus.h"
|
||||
#include "bitmap.h"
|
||||
#include "imagedev/picture.h"
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
class a2bus_computereyes2_device:
|
||||
public device_t,
|
||||
public device_a2bus_card_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
a2bus_computereyes2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
protected:
|
||||
a2bus_computereyes2_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
|
||||
// overrides of standard a2bus slot functions
|
||||
virtual uint8_t read_c0nx(uint8_t offset) override;
|
||||
virtual void write_c0nx(uint8_t offset, uint8_t data) override;
|
||||
|
||||
private:
|
||||
required_device<picture_image_device> m_picture;
|
||||
int m_x, m_y, m_cer0, m_cer1, m_cer2;
|
||||
u8 m_a2_bitmap[280*193];
|
||||
u8 m_threshold;
|
||||
bool m_bActive;
|
||||
bitmap_argb32 *m_bitmap;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(A2BUS_COMPUTEREYES2, a2bus_computereyes2_device)
|
||||
|
||||
#endif // MAME_BUS_A2BUS_COMPEYES2_H
|
@ -156,6 +156,7 @@ Address bus A0-A11 is Y0-Y11
|
||||
#include "bus/a2bus/transwarp.h"
|
||||
#include "bus/a2bus/a2vulcan.h"
|
||||
#include "bus/a2bus/4play.h"
|
||||
#include "bus/a2bus/computereyes2.h"
|
||||
|
||||
#include "bus/a2gameio/gameio.h"
|
||||
|
||||
@ -4432,6 +4433,7 @@ static void apple2_cards(device_slot_interface &device)
|
||||
device.option_add("twarp", A2BUS_TRANSWARP); /* AE TransWarp accelerator */
|
||||
device.option_add("vulcan", A2BUS_VULCANIIE); /* Applied Engineering Vulcan IDE drive */
|
||||
device.option_add("4play", A2BUS_4PLAY); /* 4Play Joystick Card (Rev. B) */
|
||||
device.option_add("ceyes2", A2BUS_COMPUTEREYES2); /* ComputerEyes/2 Video Digitizer */
|
||||
}
|
||||
|
||||
static void apple2eaux_cards(device_slot_interface &device)
|
||||
|
Loading…
Reference in New Issue
Block a user