this was an Allman file (nw)

This commit is contained in:
Vas Crabb 2018-08-13 15:06:14 +10:00
parent 85fcb47e79
commit 58b1bfebf4
2 changed files with 288 additions and 266 deletions

View File

@ -314,9 +314,8 @@ void hp1ll3_device::line(int x1, int y1, int x2, int y2)
{
point(y, x, m_udl & udl_scan,rop_masks);
udl_scan >>= 1;
if (!udl_scan) {
if (!udl_scan)
udl_scan = MSB_MASK;
}
if (e > 0)
{
@ -356,8 +355,6 @@ void hp1ll3_device::line(int x1, int y1, int x2, int y2)
} while (x <= x2);
}
return;
}
void hp1ll3_device::label(uint8_t chr, int width)
@ -416,21 +413,21 @@ void hp1ll3_device::clip_coord(int size_1 , int& p1 , int origin_clip , int size
int corner_2 = origin_2 + size_2;
// Clip origin_2 & p1 w.r.t. clip rectangle
int t = origin_2 - origin_clip;
if (t < 0) {
if (t < 0)
{
p1 -= t;
origin_2 = origin_clip;
}
// Clip size_2 w.r.t. clip rectangle
int corner_clip = origin_clip + size_clip;
if (corner_2 > corner_clip) {
if (corner_2 > corner_clip)
size_2 = corner_clip - origin_2;
}
// Clip size_2 w.r.t. rectangle 1 (whose origin is 0,0)
t = p1 + size_2 - size_1;
if (t > 0) {
if (t > 0)
size_2 -= t;
}
}
bool hp1ll3_device::bitblt(uint16_t src_base_addr, unsigned src_width, unsigned src_height, Point src_p,
const Rectangle &clip_rect, const Rectangle &dst_rect, uint16_t rop, bool use_m_org)
@ -454,11 +451,9 @@ bool hp1ll3_device::bitblt(uint16_t src_base_addr , unsigned src_width , unsigne
// Clip y-coordinates
clip_coord(src_height, src_y, clip_rect.origin.y, clip_rect.size.y, dst_y, dst_height);
DBG_LOG(3,0,("bitblt (%u,%u) (%u,%u,%u,%u)\n" , src_x , src_y ,
dst_x , dst_y , dst_width , dst_height));
if (dst_width <= 0 || dst_height <= 0) {
DBG_LOG(3,0,("bitblt (%u,%u) (%u,%u,%u,%u)\n", src_x, src_y, dst_x, dst_y, dst_width, dst_height));
if (dst_width <= 0 || dst_height <= 0)
return false;
}
unsigned dst_rounded_width = m_conf[CONF_WPL] * WS;
@ -470,7 +465,8 @@ bool hp1ll3_device::bitblt(uint16_t src_base_addr , unsigned src_width , unsigne
uint16_t rop_masks[4];
get_rop_masks(rop, rop_masks);
if (p1_pix < p2_pix) {
if (p1_pix < p2_pix)
{
// Move block going up (decrease y)
p1_pix += dst_height * src_width + dst_width - 1;
p2_pix += dst_height * dst_rounded_width + dst_width - 1;
@ -480,10 +476,13 @@ bool hp1ll3_device::bitblt(uint16_t src_base_addr , unsigned src_width , unsigne
p2_pix -= dst_rounded_width;
rowbltneg(p1_pix, p2_pix, dst_width, rop_masks);
}
} else {
}
else
{
// Move block going down (increase y)
DBG_LOG(3,0,("bitblt fwd\n"));
while (dst_height--) {
while (dst_height--)
{
rowbltpos(p1_pix, p2_pix, dst_width, rop_masks);
p1_pix += src_width;
p2_pix += dst_rounded_width;
@ -496,25 +495,28 @@ bool hp1ll3_device::bitblt(uint16_t src_base_addr , unsigned src_width , unsigne
void hp1ll3_device::rowbltpos(unsigned p1_pix, unsigned p2_pix, int width, const uint16_t masks[])
{
// p1_pix and p2_pix point to the leftmost pixel of the row
while (width > 0) {
while (width > 0)
{
unsigned p1_word = p1_pix / WS;
unsigned p1_bit = p1_pix % WS;
// Get src pixels and align to MSB
uint16_t new_pix = rd_video(p1_word) << p1_bit;
if (p1_bit) {
if (p1_bit)
new_pix |= rd_video(p1_word + 1) >> (WS - p1_bit);
}
unsigned p2_word = p2_pix / WS;
unsigned p2_bit = p2_pix % WS;
uint16_t old_pix = rd_video(p2_word);
unsigned w = p2_bit + width;
uint16_t glob_mask = ~0;
if (p2_bit) {
if (p2_bit)
{
// Left end
new_pix >>= p2_bit;
glob_mask >>= p2_bit;
}
if (w < WS) {
if (w < WS)
{
// Right end
glob_mask &= ~0 << (WS - w);
}
@ -530,7 +532,8 @@ void hp1ll3_device::rowbltpos(unsigned p1_pix , unsigned p2_pix , int width , co
void hp1ll3_device::rowbltneg(unsigned p1_pix, unsigned p2_pix, int width, const uint16_t masks[])
{
// p1_pix and p2_pix point to the rightmost pixel of the row
while (width > 0) {
while (width > 0)
{
unsigned p1_word = p1_pix / WS;
unsigned p1_bit = p1_pix % WS;
// Get src pixels and align to LSB
@ -543,12 +546,14 @@ void hp1ll3_device::rowbltneg(unsigned p1_pix , unsigned p2_pix , int width , co
uint16_t old_pix = rd_video(p2_word);
int w = p2_bit - width;
uint16_t glob_mask = ~0;
if (p2_bit != (WS - 1)) {
if (p2_bit != (WS - 1))
{
// Right end
new_pix <<= (WS - 1 - p2_bit);
glob_mask <<= (WS - 1 - p2_bit);
}
if (w >= 0) {
if (w >= 0)
{
// Left end
uint16_t tmp = ~0;
glob_mask &= tmp >> (w + 1);
@ -572,7 +577,8 @@ void hp1ll3_device::fill(const Rectangle& fill_rect , uint16_t pattern_no)
Rectangle dst_rect{{ start_x, uint16_t(fill_rect.origin.y & ~0xf) }, { 16, 16 }};
// Iterate over vertical span
while (bitblt(pattern_addr, 16, 16, src_p, fill_rect, dst_rect, m_rr)) {
while (bitblt(pattern_addr, 16, 16, src_p, fill_rect, dst_rect, m_rr))
{
// Iterate over horizontal span
do {
dst_rect.origin.x += 16;
@ -589,7 +595,8 @@ uint16_t hp1ll3_device::get_pattern_addr(uint16_t pattern_no) const
void hp1ll3_device::draw_cursor()
{
if (m_enable_cursor) {
if (m_enable_cursor)
{
Rectangle dst{{ uint16_t(m_cursor_x + m_cursor_offset), m_cursor_y }, { 16, 16 }};
bitblt(get_pattern_addr(m_cursor_pattern), 16, 16, Point{ 0, 0 }, get_screen(), dst, RR_XOR, false);
}
@ -597,7 +604,8 @@ void hp1ll3_device::draw_cursor()
void hp1ll3_device::draw_sprite()
{
if (m_enable_sprite) {
if (m_enable_sprite)
{
Rectangle dst{{ m_sprite_x, m_sprite_y }, { 16, 16 }};
bitblt(get_pattern_addr(m_sprite_pattern), 16, 16, Point{ 0, 0 }, get_screen(), dst, RR_XOR, false);
}
@ -611,7 +619,8 @@ void hp1ll3_device::draw_cursor_sprite()
void hp1ll3_device::set_pen_pos(Point p)
{
if (p.x != m_cursor_x || p.y != m_cursor_y) {
if (p.x != m_cursor_x || p.y != m_cursor_y)
{
draw_cursor();
m_cursor_x = p.x;
m_cursor_y = p.y;
@ -621,7 +630,8 @@ void hp1ll3_device::set_pen_pos(Point p)
void hp1ll3_device::set_sprite_pos(Point p)
{
if (p.x != m_sprite_x || p.y != m_sprite_y) {
if (p.x != m_sprite_x || p.y != m_sprite_y)
{
draw_sprite();
m_sprite_x = p.x;
m_sprite_y = p.y;
@ -646,22 +656,21 @@ void hp1ll3_device::apply_conf()
uint32_t hp1ll3_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int x, y, offset;
uint16_t gfx, *p;
if (!m_enable_video) {
if (!m_enable_video)
{
bitmap.fill(rgb_t::black());
return 0;
}
// XXX last line is not actually drawn on real hw
for (y = 0; y < m_vert_pix_total; y++) {
offset = m_sad + y*(m_horiz_pix_total/16);
p = &m_bitmap.pix16(y);
for (x = offset; x < offset + m_horiz_pix_total/16; x++)
for (int y = 0; y < m_vert_pix_total; y++)
{
gfx = m_videoram[x];
int const offset = m_sad + y * (m_horiz_pix_total / 16);
uint16_t *p = &m_bitmap.pix16(y);
for (int x = offset; x < offset + m_horiz_pix_total / 16; x++)
{
uint16_t const gfx = m_videoram[x];
*p++ = BIT(gfx, 15);
*p++ = BIT(gfx, 14);
@ -706,12 +715,16 @@ READ8_MEMBER( hp1ll3_device::read )
{
uint8_t data = 0;
if (offset == 0) {
if (offset == 0)
{
data = m_busy ? 1 : 0;
data |= 2;
data |= (screen().vblank() ? 8 : 0);
} else {
if ((m_io_ptr & 1) == 0) {
}
else
{
if (!(m_io_ptr & 1))
{
switch (m_command)
{
case RDMEM:
@ -723,22 +736,25 @@ READ8_MEMBER( hp1ll3_device::read )
uint16_t addr = get_pix_addr(m_rw_win_x, m_rw_win_y);
unsigned bit = m_rw_win_x % WS;
int width = m_window.width + m_window.org_x - m_rw_win_x;
if (width <= 0) {
if (width <= 0)
{
m_command = NOP;
break;
}
else
{
unsigned w = std::min(WS, unsigned(width));
m_io_word = rd_video(addr) << bit;
if ((bit + w) > WS) {
if ((bit + w) > WS)
m_io_word |= rd_video(addr + 1) >> (WS - bit);
}
m_io_word &= ~0 << (WS - w);
m_rw_win_x += w;
if (m_rw_win_x >= (m_window.width + m_window.org_x)) {
if (m_rw_win_x >= (m_window.width + m_window.org_x))
{
m_rw_win_x = m_window.org_x;
m_rw_win_y++;
if (m_rw_win_y >= (m_window.height + m_window.org_y)) {
if (m_rw_win_y >= (m_window.height + m_window.org_y))
m_command = NOP;
}
}
@ -746,20 +762,19 @@ READ8_MEMBER( hp1ll3_device::read )
break;
case RDP:
if (m_io_ptr == 0) {
if (m_io_ptr == 0)
m_io_word = m_cursor_x;
} else if (m_io_ptr == 2) {
else if (m_io_ptr == 2)
m_io_word = m_cursor_y;
}
break;
case RDSP:
if (m_io_ptr == 0) {
if (m_io_ptr == 0)
m_io_word = m_sprite_x;
} else if (m_io_ptr == 2) {
else if (m_io_ptr == 2)
m_io_word = m_sprite_y;
}
break;
case ID:
/*
* 'diagb' ROM accepts either of these ID values
@ -769,7 +784,8 @@ READ8_MEMBER( hp1ll3_device::read )
break;
}
data = uint8_t(m_io_word >> 8);
} else {
} else
{
data = m_io_word & 0xff;
}
m_io_ptr++;
@ -789,12 +805,18 @@ WRITE8_MEMBER( hp1ll3_device::write )
{
DBG_LOG(1,"HPGPU", ("W @ %d <- %02x\n", offset, data));
if (offset == 0) {
if (offset == 0)
{
command(data);
} else {
if ((m_io_ptr & 1) == 0) {
}
else
{
if (!(m_io_ptr & 1))
{
m_io_word = uint16_t(data) << 8;
} else {
}
else
{
m_io_word |= data;
switch (m_command)
{
@ -821,29 +843,35 @@ WRITE8_MEMBER( hp1ll3_device::write )
uint16_t glob_mask = ~0;
unsigned bit = m_rw_win_x % WS;
int width = m_window.width + m_window.org_x - m_rw_win_x;
if (width <= 0) {
if (width <= 0)
{
m_command = NOP;
draw_cursor_sprite();
} else {
}
else
{
unsigned w = std::min(WS, unsigned(width));
glob_mask >>= bit;
if ((bit + w) < WS) {
if ((bit + w) < WS)
glob_mask &= ~0 << (WS - (bit + w));
}
rmw_rop(addr, m_io_word >> bit, glob_mask, rop_masks);
DBG_LOG(3, 0, ("WRWIN (%u,%u) %d %04x %04x\n", m_rw_win_x, m_rw_win_y, width, m_io_word >> bit, glob_mask));
if ((bit + w) > WS) {
if ((bit + w) > WS)
{
unsigned pad = WS - bit;
glob_mask = ~0 << (2 * WS - bit - w);
rmw_rop(addr + 1, uint16_t(m_io_word << pad), glob_mask, rop_masks);
DBG_LOG(3, 0, ("WRWIN %u %04x %04x\n", pad, m_io_word << pad, glob_mask));
}
m_rw_win_x += w;
if (m_rw_win_x >= (m_window.width + m_window.org_x)) {
if (m_rw_win_x >= (m_window.width + m_window.org_x))
{
m_rw_win_x = m_window.org_x;
m_rw_win_y++;
if (m_rw_win_y >= (m_window.height + m_window.org_y)) {
if (m_rw_win_y >= (m_window.height + m_window.org_y))
{
m_command = NOP;
draw_cursor_sprite();
}
@ -853,9 +881,8 @@ WRITE8_MEMBER( hp1ll3_device::write )
break;
default:
if (m_io_ptr <= 4) {
if (m_io_ptr <= 4)
m_input[m_io_ptr / 2] = m_io_word;
}
DBG_LOG(2,"HPGPU",("wrote %02x at %d, input buffer is %04X %04X\n", data, m_io_ptr, m_input[0], m_input[1]));
}
}
@ -866,8 +893,6 @@ WRITE8_MEMBER( hp1ll3_device::write )
void hp1ll3_device::command(int command)
{
int c, w;
switch (command)
{
@ -980,13 +1005,15 @@ void hp1ll3_device::command(int command)
break;
case LABEL:
{
DBG_LOG(2,"HPGPU",("command: LABEL [%d, 0x%x] (0x%04x, '%c') at %d,%d\n", command, command, m_input[0],
(m_input[0]<32||m_input[0]>127) ? ' ' : m_input[0], m_cursor_x, m_cursor_y));
c = m_input[0] & 255;
w = (c & 1) ?
int const c = m_input[0] & 255;
int const w = (c & 1) ?
(rd_video(m_fad + 2 + (c>>1)) & 255) :
(rd_video(m_fad + 2 + (c>>1)) >> 8);
label(c, w);
}
break;
// Write window

View File

@ -12,13 +12,6 @@
#pragma once
///*************************************************************************
// INTERFACE CONFIGURATION MACROS
///*************************************************************************
#define MCFG_HP1LL3_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, HP1LL3, 0)
///*************************************************************************
// TYPE DEFINITIONS
///*************************************************************************
@ -43,10 +36,12 @@ protected:
virtual void device_reset() override;
private:
struct Point {
struct Point
{
uint16_t x, y;
};
struct Rectangle {
struct Rectangle
{
Point origin;
Point size;
};